Skip to content

Commit a301ae9

Browse files
Merge pull request #83 from sebastianwessel/codex/fix-bug-from-github-issue-#82
Fix root scope serialization bug
2 parents efe72e8 + 0687bed commit a301ae9

File tree

14 files changed

+118
-45
lines changed

14 files changed

+118
-45
lines changed

bun.lock

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181

182182
"@hono/zod-validator": ["@hono/[email protected]", "", { "peerDependencies": { "hono": ">=3.9.0", "zod": "^3.25.0" } }, "sha512-qe2ZE6sHFE98dcUrbYMtS3bAV8hqcCOflykvZga2S7XhmNSZzT+dIz4OuMILsjLHkJw9JMn912/dB7dQOmuPvg=="],
183183

184-
"@iconify-json/simple-icons": ["@iconify-json/[email protected].39", "", { "dependencies": { "@iconify/types": "*" } }, "sha512-XlhW73c4dHvUrwWckVY76HDjnaZ2fWKD6hNZtd5kuv23GC0g3Lu0MXnYscpkIYOeiXO+Gtlw8FM53J7C84mCtA=="],
184+
"@iconify-json/simple-icons": ["@iconify-json/[email protected].40", "", { "dependencies": { "@iconify/types": "*" } }, "sha512-sr2fbrS8rRhJNap41ucTStctxTcWQ3lcsHkY3loc4Yt1KNOne6D+l1JTOQCDj9f/VrUktVIEdaRQoYTvqfuSSw=="],
185185

186186
"@iconify/types": ["@iconify/[email protected]", "", {}, "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg=="],
187187

@@ -279,6 +279,8 @@
279279

280280
"@pnpm/npm-conf": ["@pnpm/[email protected]", "", { "dependencies": { "@pnpm/config.env-replace": "^1.1.0", "@pnpm/network.ca-file": "^1.0.1", "config-chain": "^1.1.11" } }, "sha512-c83qWb22rNRuB0UaVCI0uRPNRr8Z0FWnEIvT47jiHAmOIUHbBOg5XvV7pM5x+rKn9HRpjxquDbXYSXr3fAKFcw=="],
281281

282+
"@rolldown/pluginutils": ["@rolldown/[email protected]", "", {}, "sha512-3FL3mnMbPu0muGOCaKAhhFEYmqv9eTfPSJRJmANrCwtgK8VuxpsZDGK+m0LYAGoyO8+0j5uRe4PeyPDK1yA/hA=="],
283+
282284
"@rollup/rollup-android-arm-eabi": ["@rollup/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-xEiEE5oDW6tK4jXCAyliuntGR+amEMO7HLtdSshVuhFnKTYoeYMyXQK7pLouAJJj5KHdwdn87bfHAR2nSdNAUA=="],
283285

284286
"@rollup/rollup-android-arm64": ["@rollup/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-uNSk/TgvMbskcHxXYHzqwiyBlJ/lGcv8DaUfcnNwict8ba9GTTNxfn3/FAoFZYgkaXXAdrAA+SLyKplyi349Jw=="],
@@ -343,15 +345,15 @@
343345

344346
"@types/autocannon": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-Pd4nPf7wRpacULa6D/EC9x3CwzFQXwA0z5WFuik/fvJjW44V3WzBTM3jtt8nSBoflUNgswPiMCtgrr1bwnAcMg=="],
345347

346-
"@types/bun": ["@types/[email protected].16", "", { "dependencies": { "bun-types": "1.2.16" } }, "sha512-1aCZJ/6nSiViw339RsaNhkNoEloLaPzZhxMOYEa7OzRzO41IGg5n/7I43/ZIAW/c+Q6cT12Vf7fOZOoVIzb5BQ=="],
348+
"@types/bun": ["@types/[email protected].17", "", { "dependencies": { "bun-types": "1.2.17" } }, "sha512-l/BYs/JYt+cXA/0+wUhulYJB6a6p//GTPiJ7nV+QHa8iiId4HZmnu/3J/SowP5g0rTiERY2kfGKXEK5Ehltx4Q=="],
347349

348350
"@types/estree": ["@types/[email protected]", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
349351

350352
"@types/hast": ["@types/[email protected]", "", { "dependencies": { "@types/unist": "*" } }, "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ=="],
351353

352354
"@types/mdast": ["@types/[email protected]", "", { "dependencies": { "@types/unist": "*" } }, "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA=="],
353355

354-
"@types/node": ["@types/[email protected].3", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-R4I/kzCYAdRLzfiCabn9hxWfbuHS573x+r0dJMkkzThEa7pbrcDWK+9zu3e7aBOouf+rQAciqPFMnxwr0aWgKg=="],
356+
"@types/node": ["@types/[email protected].4", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-ulyqAkrhnuNq9pB76DRBTkcS6YsmDALy6Ua63V8OhrOBgbcYt6IOdzpw5P1+dyRIyMerzLkeYWBeOXPpA9GMAA=="],
355357

356358
"@types/normalize-package-data": ["@types/[email protected]", "", {}, "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA=="],
357359

@@ -361,7 +363,7 @@
361363

362364
"@ungap/structured-clone": ["@ungap/[email protected]", "", {}, "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g=="],
363365

364-
"@vitejs/plugin-vue": ["@vitejs/plugin-vue@5.2.4", "", { "peerDependencies": { "vite": "^5.0.0 || ^6.0.0", "vue": "^3.2.25" } }, "sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA=="],
366+
"@vitejs/plugin-vue": ["@vitejs/plugin-vue@6.0.0", "", { "dependencies": { "@rolldown/pluginutils": "1.0.0-beta.19" }, "peerDependencies": { "vite": "^5.0.0 || ^6.0.0 || ^7.0.0", "vue": "^3.2.25" } }, "sha512-iAliE72WsdhjzTOp2DtvKThq1VBC4REhwRcaA+zPAAph6I+OQhUXv+Xu2KS7ElxYtb7Zc/3R30Hwv1DxEo7NXQ=="],
365367

366368
"@vue/compiler-core": ["@vue/[email protected]", "", { "dependencies": { "@babel/parser": "^7.27.5", "@vue/shared": "3.5.17", "entities": "^4.5.0", "estree-walker": "^2.0.2", "source-map-js": "^1.2.1" } }, "sha512-Xe+AittLbAyV0pabcN7cP7/BenRBNcteM4aSDCtRvGw0d9OL+HG1u/XHLY/kt1q4fyMeZYXyIYrsHuPSiDPosA=="],
367369

@@ -435,7 +437,7 @@
435437

436438
"buffer": ["[email protected]", "", { "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.1.13" } }, "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ=="],
437439

438-
"bun-types": ["[email protected].16", "", { "dependencies": { "@types/node": "*" } }, "sha512-ciXLrHV4PXax9vHvUrkvun9VPVGOVwbbbBF/Ev1cXz12lyEZMoJpIJABOfPcN9gDJRaiKF9MVbSygLg4NXu3/A=="],
440+
"bun-types": ["[email protected].17", "", { "dependencies": { "@types/node": "*" } }, "sha512-ElC7ItwT3SCQwYZDYoAH+q6KT4Fxjl8DtZ6qDulUFBmXA8YB4xo+l54J9ZJN+k2pphfn9vk7kfubeSd5QfTVJQ=="],
439441

440442
"bundle-name": ["[email protected]", "", { "dependencies": { "run-applescript": "^7.0.0" } }, "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q=="],
441443

@@ -873,7 +875,7 @@
873875

874876
"open": ["[email protected]", "", { "dependencies": { "default-browser": "^5.2.1", "define-lazy-prop": "^3.0.0", "is-inside-container": "^1.0.0", "is-wsl": "^3.1.0" } }, "sha512-cxN6aIDPz6rm8hbebcP7vrQNhvRcveZoJU72Y7vskh4oIm+BZwBECnx5nTmrlres1Qapvx27Qo1Auukpf8PKXw=="],
875877

876-
"openai": ["openai@5.6.0", "", { "peerDependencies": { "ws": "^8.18.0", "zod": "^3.23.8" }, "optionalPeers": ["ws", "zod"], "bin": { "openai": "bin/cli" } }, "sha512-jNH5z+hYAdOMZXyEt0yZ7246s+UZjg2AwFQqkAhZIPPjxNtHHO5mykOefau6FkOqj16aC94MOdJl/rZBcKj/cQ=="],
878+
"openai": ["openai@5.7.0", "", { "peerDependencies": { "ws": "^8.18.0", "zod": "^3.23.8" }, "optionalPeers": ["ws", "zod"], "bin": { "openai": "bin/cli" } }, "sha512-zXWawZl6J/P5Wz57/nKzVT3kJQZvogfuyuNVCdEp4/XU2UNrjL7SsuNpWAyLZbo6HVymwmnfno9toVzBhelygA=="],
877879

878880
"openapi3-ts": ["[email protected]", "", { "dependencies": { "yaml": "^2.5.0" } }, "sha512-9asTNB9IkKEzWMcHmVZE7Ts3kC9G7AFHfs8i7caD8HbI76gEjdkId4z/AkP83xdZsH7PLAnnbl47qZkXuxpArw=="],
879881

@@ -1127,9 +1129,9 @@
11271129

11281130
"vfile-message": ["[email protected]", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw=="],
11291131

1130-
"vite": ["vite@6.3.5", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.4", "picomatch": "^4.0.2", "postcss": "^8.5.3", "rollup": "^4.34.9", "tinyglobby": "^0.2.13" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "jiti": ">=1.21.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ=="],
1132+
"vite": ["vite@7.0.0", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.6", "picomatch": "^4.0.2", "postcss": "^8.5.6", "rollup": "^4.40.0", "tinyglobby": "^0.2.14" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-ixXJB1YRgDIw2OszKQS9WxGHKwLdCsbQNkpJN171udl6szi/rIySHL6/Os3s2+oE4P/FLD4dxg4mD7Wust+u5g=="],
11311133

1132-
"vitepress": ["[email protected].6", "", { "dependencies": { "@docsearch/css": "^3.9.0", "@docsearch/js": "^3.9.0", "@iconify-json/simple-icons": "^1.2.38", "@shikijs/core": "^3.6.0", "@shikijs/transformers": "^3.6.0", "@shikijs/types": "^3.6.0", "@vitejs/plugin-vue": "^5.2.4", "@vue/devtools-api": "^7.7.6", "@vue/shared": "^3.5.16", "@vueuse/core": "^13.3.0", "@vueuse/integrations": "^13.3.0", "focus-trap": "^7.6.5", "mark.js": "8.11.1", "minisearch": "^7.1.2", "shiki": "^3.6.0", "vite": "^6.3.5", "vue": "^3.5.16" }, "peerDependencies": { "markdown-it-mathjax3": "^4", "oxc-minify": "^0.72.3", "postcss": "^8" }, "optionalPeers": ["markdown-it-mathjax3", "oxc-minify", "postcss"], "bin": { "vitepress": "bin/vitepress.js" } }, "sha512-k58ZsFJi+ml0eHM6skEC3wSUm0piDJJmNJu2LSa9BhGMge69vSN07qTBDK5Ad87aDyYhmkbiIFW2AG6bboMFcg=="],
1134+
"vitepress": ["[email protected].7", "", { "dependencies": { "@docsearch/css": "^3.9.0", "@docsearch/js": "^3.9.0", "@iconify-json/simple-icons": "^1.2.40", "@shikijs/core": "^3.7.0", "@shikijs/transformers": "^3.7.0", "@shikijs/types": "^3.7.0", "@vitejs/plugin-vue": "^6.0.0", "@vue/devtools-api": "^7.7.7", "@vue/shared": "^3.5.17", "@vueuse/core": "^13.4.0", "@vueuse/integrations": "^13.4.0", "focus-trap": "^7.6.5", "mark.js": "8.11.1", "minisearch": "^7.1.2", "shiki": "^3.7.0", "vite": "^7.0.0", "vue": "^3.5.17" }, "peerDependencies": { "markdown-it-mathjax3": "^4", "oxc-minify": "^0.74.0", "postcss": "^8" }, "optionalPeers": ["markdown-it-mathjax3", "oxc-minify", "postcss"], "bin": { "vitepress": "bin/vitepress.js" } }, "sha512-75xXvCWymnSgA7BFt1BmiXnusl4aeV4sM6DpIo9sf2OvkNER3cMLWN6xqZrLGu3SNaQccfS5u3ikCqAnA4p70w=="],
11331135

11341136
"vitepress-sidebar": ["[email protected]", "", { "dependencies": { "glob": "10.4.5", "gray-matter": "4.0.3", "qsu": "^1.10.0" } }, "sha512-Hx10z5le87jIIXVfKq4AtRrVqVJJ/1cQsZhmwT+ghVR/j4Yor9FjNMszyigJ54ktrEtoxSLO6C9tvuLauT4lZA=="],
11351137

@@ -1169,6 +1171,8 @@
11691171

11701172
"@pnpm/network.ca-file/graceful-fs": ["[email protected]", "", {}, "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA=="],
11711173

1174+
"@types/autocannon/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-R4I/kzCYAdRLzfiCabn9hxWfbuHS573x+r0dJMkkzThEa7pbrcDWK+9zu3e7aBOouf+rQAciqPFMnxwr0aWgKg=="],
1175+
11721176
"ansi-escapes/type-fest": ["[email protected]", "", {}, "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w=="],
11731177

11741178
"anymatch/picomatch": ["[email protected]", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,21 @@
9191
"@jitl/quickjs-ng-wasmfile-release-asyncify": "^0.31.0",
9292
"@jitl/quickjs-ng-wasmfile-release-sync": "^0.31.0",
9393
"@types/autocannon": "^7.12.7",
94-
"@types/bun": "^1.2.16",
95-
"@types/node": "^24.0.3",
94+
"@types/bun": "^1.2.17",
95+
"@types/node": "^24.0.4",
9696
"autocannon": "^8.0.0",
9797
"chai": "^5.2.0",
9898
"git-cliff": "^2.9.1",
9999
"hono": "^4.8.2",
100100
"knip": "^5.61.2",
101101
"np": "^10.2.0",
102-
"openai": "^5.6.0",
102+
"openai": "^5.7.0",
103103
"poolifier-web-worker": "^0.4.31",
104104
"tshy": "^3.0.2",
105105
"typedoc": "^0.28.5",
106106
"typedoc-plugin-markdown": "^4.7.0",
107107
"typescript": "^5.8.3",
108-
"vitepress": "^2.0.0-alpha.6",
108+
"vitepress": "^2.0.0-alpha.7",
109109
"vitepress-sidebar": "^1.31.1",
110110
"vue": "^3.5.17"
111111
},

src/sandbox/handleToNative/handleToNative.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export const handleToNative = (ctx: QuickJSContext | QuickJSAsyncContext, handle
168168
if (typeof errorType === 'string') {
169169
const s = getSerializer(errorType)
170170
if (s) {
171-
const ret = s(ctx, handle)
171+
const ret = s(ctx, handle, rootScope)
172172
if (ret) {
173173
return ret
174174
}
@@ -206,7 +206,7 @@ export const handleToNative = (ctx: QuickJSContext | QuickJSAsyncContext, handle
206206

207207
const serializer = getSerializer(constructorName)
208208
if (serializer) {
209-
const ret = serializer(ctx, handle)
209+
const ret = serializer(ctx, handle, rootScope)
210210
if (ret) {
211211
return ret
212212
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle } from 'quickjs-emscripten-core'
1+
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle, Scope } from 'quickjs-emscripten-core'
22
import type { Serializer } from '../../../types/Serializer.js'
33

4-
export const serializeArrayBuffer: Serializer = (ctx: QuickJSContext | QuickJSAsyncContext, handle: QuickJSHandle) => {
4+
export const serializeArrayBuffer: Serializer = (
5+
ctx: QuickJSContext | QuickJSAsyncContext,
6+
handle: QuickJSHandle,
7+
_rootScope?: Scope,
8+
) => {
59
const b = ctx.getArrayBuffer(handle)
610
return Uint8Array.from(b.value)
711
}

src/sandbox/handleToNative/serializer/serializeBuffer.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle } from 'quickjs-emscripten-core'
1+
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle, Scope } from 'quickjs-emscripten-core'
22
import type { Serializer } from '../../../types/Serializer.js'
33
import { call } from '../../helper.js'
44
import { handleToNative } from '../handleToNative.js'
55

6-
export const serializeBuffer: Serializer = (ctx: QuickJSContext | QuickJSAsyncContext, handle: QuickJSHandle) => {
6+
export const serializeBuffer: Serializer = (
7+
ctx: QuickJSContext | QuickJSAsyncContext,
8+
handle: QuickJSHandle,
9+
rootScope?: Scope,
10+
) => {
711
let b: Buffer | undefined
812
ctx
913
.newFunction('', value => {
10-
const v = handleToNative(ctx, value)
14+
const v = handleToNative(ctx, value, rootScope)
1115
b = Buffer.from(v)
1216
})
1317
.consume(f => {

src/sandbox/handleToNative/serializer/serializeDate.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle } from 'quickjs-emscripten-core'
1+
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle, Scope } from 'quickjs-emscripten-core'
22
import type { Serializer } from '../../../types/Serializer.js'
33
import { call } from '../../helper.js'
44
import { handleToNative } from '../handleToNative.js'
55

6-
export const serializeDate: Serializer = (ctx: QuickJSContext | QuickJSAsyncContext, handle: QuickJSHandle) => {
6+
export const serializeDate: Serializer = (
7+
ctx: QuickJSContext | QuickJSAsyncContext,
8+
handle: QuickJSHandle,
9+
rootScope?: Scope,
10+
) => {
711
const d = new Date()
812
ctx
913
.newFunction('', value => {
10-
const v = handleToNative(ctx, value)
14+
const v = handleToNative(ctx, value, rootScope)
1115
d.setTime(v)
1216
})
1317
.consume(f => {

src/sandbox/handleToNative/serializer/serializeError.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle } from 'quickjs-emscripten-core'
1+
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle, Scope } from 'quickjs-emscripten-core'
22
import type { Serializer } from '../../../types/Serializer.js'
33
import { call } from '../../helper.js'
44
import { handleToNative } from '../handleToNative.js'
55

6-
export const serializeError: Serializer = (ctx: QuickJSContext | QuickJSAsyncContext, handle: QuickJSHandle) => {
6+
export const serializeError: Serializer = (
7+
ctx: QuickJSContext | QuickJSAsyncContext,
8+
handle: QuickJSHandle,
9+
rootScope?: Scope,
10+
) => {
711
const d: Error = new Error()
812

913
ctx
1014
.newFunction('serializeError', (value, name) => {
11-
const v = handleToNative(ctx, value)
12-
const n = handleToNative(ctx, name)
15+
const v = handleToNative(ctx, value, rootScope)
16+
const n = handleToNative(ctx, name, rootScope)
1317
Object.defineProperties(d, v)
1418
d.name = n
1519
})

src/sandbox/handleToNative/serializer/serializeHeaders.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle } from 'quickjs-emscripten-core'
1+
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle, Scope } from 'quickjs-emscripten-core'
22
import type { Serializer } from '../../../types/Serializer.js'
33
import { call } from '../../helper.js'
44
import { handleToNative } from '../handleToNative.js'
55

6-
export const serializeHeaders: Serializer = (ctx: QuickJSContext | QuickJSAsyncContext, handle: QuickJSHandle) => {
6+
export const serializeHeaders: Serializer = (
7+
ctx: QuickJSContext | QuickJSAsyncContext,
8+
handle: QuickJSHandle,
9+
rootScope?: Scope,
10+
) => {
711
const h = new Headers()
812
ctx
913
.newFunction('', (value, name) => {
10-
const v = handleToNative(ctx, value)
11-
const n = handleToNative(ctx, name)
14+
const v = handleToNative(ctx, value, rootScope)
15+
const n = handleToNative(ctx, name, rootScope)
1216
h.append(n, v)
1317
})
1418
.consume(f => {

src/sandbox/handleToNative/serializer/serializeMap.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle } from 'quickjs-emscripten-core'
1+
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle, Scope } from 'quickjs-emscripten-core'
22
import type { Serializer } from '../../../types/Serializer.js'
33
import { call } from '../../helper.js'
44
import { handleToNative } from '../handleToNative.js'
55

6-
export const serializeMap: Serializer = (ctx: QuickJSContext | QuickJSAsyncContext, handle: QuickJSHandle) => {
6+
export const serializeMap: Serializer = (
7+
ctx: QuickJSContext | QuickJSAsyncContext,
8+
handle: QuickJSHandle,
9+
rootScope?: Scope,
10+
) => {
711
const m = new Map()
812
ctx
913
.newFunction('', (key, value) => {
10-
const k = handleToNative(ctx, key)
11-
const v = handleToNative(ctx, value)
14+
const k = handleToNative(ctx, key, rootScope)
15+
const v = handleToNative(ctx, value, rootScope)
1216
m.set(k, v)
1317
})
1418
.consume(f => {

src/sandbox/handleToNative/serializer/serializeSet.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle } from 'quickjs-emscripten-core'
1+
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle, Scope } from 'quickjs-emscripten-core'
22
import type { Serializer } from '../../../types/Serializer.js'
33
import { call } from '../../helper.js'
44
import { handleToNative } from '../handleToNative.js'
55

6-
export const serializeSet: Serializer = (ctx: QuickJSContext | QuickJSAsyncContext, handle: QuickJSHandle) => {
6+
export const serializeSet: Serializer = (
7+
ctx: QuickJSContext | QuickJSAsyncContext,
8+
handle: QuickJSHandle,
9+
rootScope?: Scope,
10+
) => {
711
const s = new Set()
812
ctx
913
.newFunction('', value => {
10-
const v = handleToNative(ctx, value)
14+
const v = handleToNative(ctx, value, rootScope)
1115
s.add(v)
1216
})
1317
.consume(f => {

0 commit comments

Comments
 (0)