@cloudflare/vitest-pool-workers 0.16.3 → 0.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-v3-to-v4.mjs","names":[],"sources":["../../src/codemods/vitest-v3-to-v4.ts"],"sourcesContent":["/**\n * jscodeshift codemod: migrate @cloudflare/vitest-pool-workers config from v3 to v4.\n *\n * Transforms:\n * import { defineWorkersProject } from \"@cloudflare/vitest-pool-workers/config\";\n * export default defineWorkersProject({ test: { poolOptions: { workers: { ... } } } });\n *\n * Into:\n * import { cloudflareTest } from \"@cloudflare/vitest-pool-workers\";\n * import { defineConfig } from \"vitest/config\";\n * export default defineConfig({ plugins: [cloudflareTest({ ... })], test: { ... } });\n *\n * Usage:\n * npx jscodeshift -t node_modules/@cloudflare/vitest-pool-workers/dist/codemods/vitest-v3-to-v4.mjs vitest.config.ts\n */\n\n// Minimal jscodeshift types — avoids requiring @types/jscodeshift as a dependency.\ninterface FileInfo {\n\tpath: string;\n\tsource: string;\n}\ninterface JSCodeshift {\n\t(source: string): Collection;\n\tImportDeclaration: ASTType;\n\tCallExpression: ASTType;\n\tObjectExpression: { check(node: unknown): node is ObjectExpressionNode };\n\tObjectProperty: { check(node: unknown): node is PropertyNode };\n\tProperty: { check(node: unknown): node is PropertyNode };\n\tIdentifier: { check(node: unknown): node is IdentifierNode };\n\tFunctionExpression: { check(node: unknown): boolean };\n\tArrowFunctionExpression: { check(node: unknown): boolean };\n\tArrayExpression: { check(node: unknown): node is ArrayExpressionNode };\n\timportDeclaration(\n\t\tspecifiers: ImportSpecifierNode[],\n\t\tsource: LiteralNode\n\t): ImportDeclarationNode;\n\timportSpecifier(\n\t\timported: IdentifierNode,\n\t\tlocal?: IdentifierNode\n\t): ImportSpecifierNode;\n\tidentifier(name: string): IdentifierNode;\n\tstringLiteral(value: string): LiteralNode;\n\tcallExpression(\n\t\tcallee: IdentifierNode,\n\t\targs: ExpressionNode[]\n\t): CallExpressionNode;\n\tarrayExpression(elements: ExpressionNode[]): ArrayExpressionNode;\n\tobjectProperty(key: IdentifierNode, value: ExpressionNode): PropertyNode;\n}\n\ninterface ASTType {\n\tname: string;\n}\n\ninterface ASTNode {\n\ttype: string;\n}\n\ninterface IdentifierNode extends ASTNode {\n\ttype: \"Identifier\";\n\tname: string;\n}\n\ninterface LiteralNode extends ASTNode {\n\tvalue: string;\n}\n\ninterface ImportSpecifierNode extends ASTNode {\n\ttype: \"ImportSpecifier\";\n\timported: IdentifierNode;\n\tlocal?: IdentifierNode;\n}\n\ninterface ImportDeclarationNode extends ASTNode {\n\ttype: \"ImportDeclaration\";\n\tsource: LiteralNode;\n\tspecifiers: ImportSpecifierNode[];\n}\n\ninterface PropertyNode extends ASTNode {\n\tkey: ASTNode;\n\tvalue: ASTNode;\n}\n\ninterface ObjectExpressionNode extends ASTNode {\n\ttype: \"ObjectExpression\";\n\tproperties: PropertyNode[];\n}\n\ninterface ArrayExpressionNode extends ASTNode {\n\ttype: \"ArrayExpression\";\n\telements: ExpressionNode[];\n}\n\ninterface CallExpressionNode extends ASTNode {\n\ttype: \"CallExpression\";\n\tcallee: ASTNode;\n\targuments: ASTNode[];\n}\n\ntype ExpressionNode = ASTNode;\n\ninterface NodePath<T = ASTNode> {\n\tnode: T;\n\tparent: NodePath;\n\tinsertAfter(node: ASTNode): void;\n}\n\ninterface Collection {\n\tfind(type: ASTType, filter?: Record<string, unknown>): Collection;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tforEach(callback: (path: NodePath<any>) => void): Collection;\n\tat(index: number): Collection;\n\tpaths(): NodePath[];\n\tlength: number;\n\ttoSource(): string;\n}\n\ninterface API {\n\tjscodeshift: JSCodeshift;\n}\n\nfunction isNamedProp(\n\tj: JSCodeshift,\n\tprop: ASTNode,\n\tname: string\n): prop is PropertyNode {\n\treturn (\n\t\t(j.Property.check(prop) || j.ObjectProperty.check(prop)) &&\n\t\tj.Identifier.check(prop.key) &&\n\t\t(prop.key as IdentifierNode).name === name\n\t);\n}\n\nfunction findNamedProp(\n\tj: JSCodeshift,\n\tproperties: PropertyNode[],\n\tname: string\n): PropertyNode | undefined {\n\treturn properties.find((prop) => isNamedProp(j, prop, name));\n}\n\nexport default function transform(fileInfo: FileInfo, api: API): string {\n\tconst j = api.jscodeshift;\n\tconst root = j(fileInfo.source);\n\n\t// 1. Find the import of @cloudflare/vitest-pool-workers/config with defineWorkersProject\n\tconst configImports = root.find(j.ImportDeclaration, {\n\t\tsource: { value: \"@cloudflare/vitest-pool-workers/config\" },\n\t});\n\n\tif (configImports.length === 0) {\n\t\t// Nothing to transform\n\t\treturn fileInfo.source;\n\t}\n\n\t// Update the import: change source and swap defineWorkersProject → cloudflareTest\n\tconfigImports.forEach((path: NodePath<ImportDeclarationNode>) => {\n\t\tpath.node.source.value = \"@cloudflare/vitest-pool-workers\";\n\t\tpath.node.specifiers = [\n\t\t\tj.importSpecifier(j.identifier(\"cloudflareTest\")),\n\t\t\t...(path.node.specifiers?.filter(\n\t\t\t\t(s) =>\n\t\t\t\t\t!(\n\t\t\t\t\t\ts.type === \"ImportSpecifier\" &&\n\t\t\t\t\t\ts.imported?.name === \"defineWorkersProject\"\n\t\t\t\t\t)\n\t\t\t) ?? []),\n\t\t];\n\t});\n\n\t// 2. Add `import { defineConfig } from \"vitest/config\"` after the last import\n\tconst allImports = root.find(j.ImportDeclaration);\n\tif (allImports.length > 0) {\n\t\tconst lastImport = allImports.at(-1);\n\t\tlastImport.forEach((path: NodePath) => {\n\t\t\tpath.insertAfter(\n\t\t\t\tj.importDeclaration(\n\t\t\t\t\t[j.importSpecifier(j.identifier(\"defineConfig\"))],\n\t\t\t\t\tj.stringLiteral(\"vitest/config\")\n\t\t\t\t)\n\t\t\t);\n\t\t});\n\t}\n\n\t// 3. Transform defineWorkersProject() → defineConfig() with plugins\n\troot\n\t\t.find(j.CallExpression, {\n\t\t\tcallee: { name: \"defineWorkersProject\" },\n\t\t})\n\t\t.forEach((path: NodePath<CallExpressionNode>) => {\n\t\t\t// Rename callee\n\t\t\t(path.node.callee as IdentifierNode).name = \"defineConfig\";\n\n\t\t\tconst config = path.node.arguments[0];\n\t\t\tif (!j.ObjectExpression.check(config)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"defineWorkersProject() is called with a function and not an object, \" +\n\t\t\t\t\t\t\"and so is too complex to apply a codemod to. \" +\n\t\t\t\t\t\t\"Please refer to the migration docs to perform the migration manually.\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Find test.poolOptions.workers\n\t\t\tconst testProp = findNamedProp(j, config.properties, \"test\");\n\t\t\tif (!testProp || !j.ObjectExpression.check(testProp.value)) {\n\t\t\t\tthrow new Error(\"Could not find `test` property in config\");\n\t\t\t}\n\t\t\tconst testObj = testProp.value as ObjectExpressionNode;\n\n\t\t\tconst poolOptionsProp = findNamedProp(\n\t\t\t\tj,\n\t\t\t\ttestObj.properties,\n\t\t\t\t\"poolOptions\"\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!poolOptionsProp ||\n\t\t\t\t!j.ObjectExpression.check(poolOptionsProp.value)\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Could not find `test.poolOptions` property in config\");\n\t\t\t}\n\t\t\tconst poolOptionsObj = poolOptionsProp.value as ObjectExpressionNode;\n\n\t\t\tconst workersProp = findNamedProp(\n\t\t\t\tj,\n\t\t\t\tpoolOptionsObj.properties,\n\t\t\t\t\"workers\"\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!workersProp ||\n\t\t\t\t!(\n\t\t\t\t\tj.ObjectExpression.check(workersProp.value) ||\n\t\t\t\t\tj.FunctionExpression.check(workersProp.value) ||\n\t\t\t\t\tj.ArrowFunctionExpression.check(workersProp.value)\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Could not find `test.poolOptions.workers` property in config\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Create plugins: [cloudflareTest(<workers value>)]\n\t\t\tconst pluginCall = j.callExpression(j.identifier(\"cloudflareTest\"), [\n\t\t\t\tworkersProp.value as ExpressionNode,\n\t\t\t]);\n\n\t\t\tconst pluginsProp = findNamedProp(j, config.properties, \"plugins\");\n\t\t\tif (pluginsProp && j.ArrayExpression.check(pluginsProp.value)) {\n\t\t\t\t// Prepend to existing plugins array\n\t\t\t\t(pluginsProp.value as ArrayExpressionNode).elements.unshift(pluginCall);\n\t\t\t} else {\n\t\t\t\t// Create new plugins property at the start\n\t\t\t\tconfig.properties.unshift(\n\t\t\t\t\tj.objectProperty(\n\t\t\t\t\t\tj.identifier(\"plugins\"),\n\t\t\t\t\t\tj.arrayExpression([pluginCall])\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Remove poolOptions from test\n\t\t\ttestObj.properties = testObj.properties.filter(\n\t\t\t\t(prop) => !isNamedProp(j, prop, \"poolOptions\")\n\t\t\t);\n\t\t});\n\n\treturn root.toSource();\n}\n\n// Tell jscodeshift to use the TypeScript parser\nexport const parser = \"ts\";\n"],"mappings":";AA0HA,SAAS,YACR,GACA,MACA,MACuB;AACvB,SACE,EAAE,SAAS,MAAM,KAAK,IAAI,EAAE,eAAe,MAAM,KAAK,KACvD,EAAE,WAAW,MAAM,KAAK,IAAI,IAC3B,KAAK,IAAuB,SAAS;;AAIxC,SAAS,cACR,GACA,YACA,MAC2B;AAC3B,QAAO,WAAW,MAAM,SAAS,YAAY,GAAG,MAAM,KAAK,CAAC;;AAG7D,SAAwB,UAAU,UAAoB,KAAkB;CACvE,MAAM,IAAI,IAAI;CACd,MAAM,OAAO,EAAE,SAAS,OAAO;CAG/B,MAAM,gBAAgB,KAAK,KAAK,EAAE,mBAAmB,EACpD,QAAQ,EAAE,OAAO,0CAA0C,EAC3D,CAAC;AAEF,KAAI,cAAc,WAAW,EAE5B,QAAO,SAAS;AAIjB,eAAc,SAAS,SAA0C;AAChE,OAAK,KAAK,OA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+DACA;EAIF,MAAM,aAAa,EAAE,eAAe,EAAE,WAAW,iBAAiB,EAAE,CACnE,YAAY,MACZ,CAAC;EAEF,MAAM,cAAc,cAAc,GAAG,OAAO,YAAY,UAAU;AAClE,MAAI,eAAe,EAAE,gBAAgB,MAAM,YAAY,MAAM,CAE5D,CAAC,YAAY,MAA8B,SAAS,QAAQ,WAAW;MAGvE,QAAO,WAAW,QACjB,EAAE,eACD,EAAE,WAAW,UAAU,EACvB,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAC/B,CACD;AAIF,UAAQ,aAAa,QAAQ,WAAW,QACtC,SAAS,CAAC,YAAY,GAAG,MAAM,cAAc,CAC9C;GACA;AAEH,QAAO,KAAK,UAAU;;AAIvB,MAAa,SAAS"}
|
|
1
|
+
{"version":3,"file":"vitest-v3-to-v4.mjs","names":[],"sources":["../../src/codemods/vitest-v3-to-v4.ts"],"sourcesContent":["/**\n * jscodeshift codemod: migrate @cloudflare/vitest-pool-workers config from v3 to v4.\n *\n * Transforms:\n * import { defineWorkersProject } from \"@cloudflare/vitest-pool-workers/config\";\n * export default defineWorkersProject({ test: { poolOptions: { workers: { ... } } } });\n *\n * Into:\n * import { cloudflareTest } from \"@cloudflare/vitest-pool-workers\";\n * import { defineConfig } from \"vitest/config\";\n * export default defineConfig({ plugins: [cloudflareTest({ ... })], test: { ... } });\n *\n * Usage:\n * npx jscodeshift -t node_modules/@cloudflare/vitest-pool-workers/dist/codemods/vitest-v3-to-v4.mjs vitest.config.ts\n */\n\n// Minimal jscodeshift types — avoids requiring @types/jscodeshift as a dependency.\ninterface FileInfo {\n\tpath: string;\n\tsource: string;\n}\ninterface JSCodeshift {\n\t(source: string): Collection;\n\tImportDeclaration: ASTType;\n\tCallExpression: ASTType;\n\tObjectExpression: { check(node: unknown): node is ObjectExpressionNode };\n\tObjectProperty: { check(node: unknown): node is PropertyNode };\n\tProperty: { check(node: unknown): node is PropertyNode };\n\tIdentifier: { check(node: unknown): node is IdentifierNode };\n\tFunctionExpression: { check(node: unknown): boolean };\n\tArrowFunctionExpression: { check(node: unknown): boolean };\n\tArrayExpression: { check(node: unknown): node is ArrayExpressionNode };\n\timportDeclaration(\n\t\tspecifiers: ImportSpecifierNode[],\n\t\tsource: LiteralNode\n\t): ImportDeclarationNode;\n\timportSpecifier(\n\t\timported: IdentifierNode,\n\t\tlocal?: IdentifierNode\n\t): ImportSpecifierNode;\n\tidentifier(name: string): IdentifierNode;\n\tstringLiteral(value: string): LiteralNode;\n\tcallExpression(\n\t\tcallee: IdentifierNode,\n\t\targs: ExpressionNode[]\n\t): CallExpressionNode;\n\tarrayExpression(elements: ExpressionNode[]): ArrayExpressionNode;\n\tobjectProperty(key: IdentifierNode, value: ExpressionNode): PropertyNode;\n}\n\ninterface ASTType {\n\tname: string;\n}\n\ninterface ASTNode {\n\ttype: string;\n}\n\ninterface IdentifierNode extends ASTNode {\n\ttype: \"Identifier\";\n\tname: string;\n}\n\ninterface LiteralNode extends ASTNode {\n\tvalue: string;\n}\n\ninterface ImportSpecifierNode extends ASTNode {\n\ttype: \"ImportSpecifier\";\n\timported: IdentifierNode;\n\tlocal?: IdentifierNode;\n}\n\ninterface ImportDeclarationNode extends ASTNode {\n\ttype: \"ImportDeclaration\";\n\tsource: LiteralNode;\n\tspecifiers: ImportSpecifierNode[];\n}\n\ninterface PropertyNode extends ASTNode {\n\tkey: ASTNode;\n\tvalue: ASTNode;\n}\n\ninterface ObjectExpressionNode extends ASTNode {\n\ttype: \"ObjectExpression\";\n\tproperties: PropertyNode[];\n}\n\ninterface ArrayExpressionNode extends ASTNode {\n\ttype: \"ArrayExpression\";\n\telements: ExpressionNode[];\n}\n\ninterface CallExpressionNode extends ASTNode {\n\ttype: \"CallExpression\";\n\tcallee: ASTNode;\n\targuments: ASTNode[];\n}\n\ntype ExpressionNode = ASTNode;\n\ninterface NodePath<T = ASTNode> {\n\tnode: T;\n\tparent: NodePath;\n\tinsertAfter(node: ASTNode): void;\n}\n\ninterface Collection {\n\tfind(type: ASTType, filter?: Record<string, unknown>): Collection;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- jscodeshift Collection.forEach accepts callbacks with narrowed NodePath types\n\tforEach(callback: (path: NodePath<any>) => void): Collection;\n\tat(index: number): Collection;\n\tpaths(): NodePath[];\n\tlength: number;\n\ttoSource(): string;\n}\n\ninterface API {\n\tjscodeshift: JSCodeshift;\n}\n\nfunction isNamedProp(\n\tj: JSCodeshift,\n\tprop: ASTNode,\n\tname: string\n): prop is PropertyNode {\n\treturn (\n\t\t(j.Property.check(prop) || j.ObjectProperty.check(prop)) &&\n\t\tj.Identifier.check(prop.key) &&\n\t\t(prop.key as IdentifierNode).name === name\n\t);\n}\n\nfunction findNamedProp(\n\tj: JSCodeshift,\n\tproperties: PropertyNode[],\n\tname: string\n): PropertyNode | undefined {\n\treturn properties.find((prop) => isNamedProp(j, prop, name));\n}\n\nexport default function transform(fileInfo: FileInfo, api: API): string {\n\tconst j = api.jscodeshift;\n\tconst root = j(fileInfo.source);\n\n\t// 1. Find the import of @cloudflare/vitest-pool-workers/config with defineWorkersProject\n\tconst configImports = root.find(j.ImportDeclaration, {\n\t\tsource: { value: \"@cloudflare/vitest-pool-workers/config\" },\n\t});\n\n\tif (configImports.length === 0) {\n\t\t// Nothing to transform\n\t\treturn fileInfo.source;\n\t}\n\n\t// Update the import: change source and swap defineWorkersProject → cloudflareTest\n\tconfigImports.forEach((path: NodePath<ImportDeclarationNode>) => {\n\t\tpath.node.source.value = \"@cloudflare/vitest-pool-workers\";\n\t\tpath.node.specifiers = [\n\t\t\tj.importSpecifier(j.identifier(\"cloudflareTest\")),\n\t\t\t...(path.node.specifiers?.filter(\n\t\t\t\t(s) =>\n\t\t\t\t\t!(\n\t\t\t\t\t\ts.type === \"ImportSpecifier\" &&\n\t\t\t\t\t\ts.imported?.name === \"defineWorkersProject\"\n\t\t\t\t\t)\n\t\t\t) ?? []),\n\t\t];\n\t});\n\n\t// 2. Add `import { defineConfig } from \"vitest/config\"` after the last import\n\tconst allImports = root.find(j.ImportDeclaration);\n\tif (allImports.length > 0) {\n\t\tconst lastImport = allImports.at(-1);\n\t\tlastImport.forEach((path: NodePath) => {\n\t\t\tpath.insertAfter(\n\t\t\t\tj.importDeclaration(\n\t\t\t\t\t[j.importSpecifier(j.identifier(\"defineConfig\"))],\n\t\t\t\t\tj.stringLiteral(\"vitest/config\")\n\t\t\t\t)\n\t\t\t);\n\t\t});\n\t}\n\n\t// 3. Transform defineWorkersProject() → defineConfig() with plugins\n\troot\n\t\t.find(j.CallExpression, {\n\t\t\tcallee: { name: \"defineWorkersProject\" },\n\t\t})\n\t\t.forEach((path: NodePath<CallExpressionNode>) => {\n\t\t\t// Rename callee\n\t\t\t(path.node.callee as IdentifierNode).name = \"defineConfig\";\n\n\t\t\tconst config = path.node.arguments[0];\n\t\t\tif (!j.ObjectExpression.check(config)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"defineWorkersProject() is called with a function and not an object, \" +\n\t\t\t\t\t\t\"and so is too complex to apply a codemod to. \" +\n\t\t\t\t\t\t\"Please refer to the migration docs to perform the migration manually.\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Find test.poolOptions.workers\n\t\t\tconst testProp = findNamedProp(j, config.properties, \"test\");\n\t\t\tif (!testProp || !j.ObjectExpression.check(testProp.value)) {\n\t\t\t\tthrow new Error(\"Could not find `test` property in config\");\n\t\t\t}\n\t\t\tconst testObj = testProp.value as ObjectExpressionNode;\n\n\t\t\tconst poolOptionsProp = findNamedProp(\n\t\t\t\tj,\n\t\t\t\ttestObj.properties,\n\t\t\t\t\"poolOptions\"\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!poolOptionsProp ||\n\t\t\t\t!j.ObjectExpression.check(poolOptionsProp.value)\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Could not find `test.poolOptions` property in config\");\n\t\t\t}\n\t\t\tconst poolOptionsObj = poolOptionsProp.value as ObjectExpressionNode;\n\n\t\t\tconst workersProp = findNamedProp(\n\t\t\t\tj,\n\t\t\t\tpoolOptionsObj.properties,\n\t\t\t\t\"workers\"\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!workersProp ||\n\t\t\t\t!(\n\t\t\t\t\tj.ObjectExpression.check(workersProp.value) ||\n\t\t\t\t\tj.FunctionExpression.check(workersProp.value) ||\n\t\t\t\t\tj.ArrowFunctionExpression.check(workersProp.value)\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Could not find `test.poolOptions.workers` property in config\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Create plugins: [cloudflareTest(<workers value>)]\n\t\t\tconst pluginCall = j.callExpression(j.identifier(\"cloudflareTest\"), [\n\t\t\t\tworkersProp.value as ExpressionNode,\n\t\t\t]);\n\n\t\t\tconst pluginsProp = findNamedProp(j, config.properties, \"plugins\");\n\t\t\tif (pluginsProp && j.ArrayExpression.check(pluginsProp.value)) {\n\t\t\t\t// Prepend to existing plugins array\n\t\t\t\t(pluginsProp.value as ArrayExpressionNode).elements.unshift(pluginCall);\n\t\t\t} else {\n\t\t\t\t// Create new plugins property at the start\n\t\t\t\tconfig.properties.unshift(\n\t\t\t\t\tj.objectProperty(\n\t\t\t\t\t\tj.identifier(\"plugins\"),\n\t\t\t\t\t\tj.arrayExpression([pluginCall])\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Remove poolOptions from test\n\t\t\ttestObj.properties = testObj.properties.filter(\n\t\t\t\t(prop) => !isNamedProp(j, prop, \"poolOptions\")\n\t\t\t);\n\t\t});\n\n\treturn root.toSource();\n}\n\n// Tell jscodeshift to use the TypeScript parser\nexport const parser = \"ts\";\n"],"mappings":";AA0HA,SAAS,YACR,GACA,MACA,MACuB;AACvB,SACE,EAAE,SAAS,MAAM,KAAK,IAAI,EAAE,eAAe,MAAM,KAAK,KACvD,EAAE,WAAW,MAAM,KAAK,IAAI,IAC3B,KAAK,IAAuB,SAAS;;AAIxC,S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kBAAkB,cACvB,GACA,QAAQ,YACR,cACA;AACD,MACC,CAAC,mBACD,CAAC,EAAE,iBAAiB,MAAM,gBAAgB,MAAM,CAEhD,OAAM,IAAI,MAAM,uDAAuD;EAExE,MAAM,iBAAiB,gBAAgB;EAEvC,MAAM,cAAc,cACnB,GACA,eAAe,YACf,UACA;AACD,MACC,CAAC,eACD,EACC,EAAE,iBAAiB,MAAM,YAAY,MAAM,IAC3C,EAAE,mBAAmB,MAAM,YAAY,MAAM,IAC7C,EAAE,wBAAwB,MAAM,YAAY,MAAM,EAGnD,OAAM,IAAI,MACT,+DACA;EAIF,MAAM,aAAa,EAAE,eAAe,EAAE,WAAW,iBAAiB,EAAE,CACnE,YAAY,MACZ,CAAC;EAEF,MAAM,cAAc,cAAc,GAAG,OAAO,YAAY,UAAU;AAClE,MAAI,eAAe,EAAE,gBAAgB,MAAM,YAAY,MAAM,CAE5D,CAAC,YAAY,MAA8B,SAAS,QAAQ,WAAW;MAGvE,QAAO,WAAW,QACjB,EAAE,eACD,EAAE,WAAW,UAAU,EACvB,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAC/B,CACD;AAIF,UAAQ,aAAa,QAAQ,WAAW,QACtC,SAAS,CAAC,YAAY,GAAG,MAAM,cAAc,CAC9C;GACA;AAEH,QAAO,KAAK,UAAU;;AAIvB,MAAa,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["index","value","structuredSerializableReducers: ReducersRevivers","structuredSerializableRevivers: ReducersRevivers","devalue.stringify","devalue.parse","name: string","cwd: string | undefined","fileName: string | null","error: { stack?: string }","promiseResolve: (() => void) | undefined"],"sources":["../../../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/utils.js","../../../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/base64.js","../../../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/constants.js","../../../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/parse.js","../../../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/stringify.js","../../../miniflare/src/workers/core/devalue.ts","../../src/worker/index.ts"],"sourcesContent":["/** @type {Record<string, string>} */\nexport const escaped = {\n\t'<': '\\\\u003C',\n\t'\\\\': '\\\\\\\\',\n\t'\\b': '\\\\b',\n\t'\\f': '\\\\f',\n\t'\\n': '\\\\n',\n\t'\\r': '\\\\r',\n\t'\\t': '\\\\t',\n\t'\\u2028': '\\\\u2028',\n\t'\\u2029': '\\\\u2029'\n};\n\nexport class DevalueError extends Error {\n\t/**\n\t * @param {string} message\n\t * @param {string[]} keys\n\t * @param {any} [value] - The value that failed to be serialized\n\t * @param {any} [root] - The root value being serialized\n\t */\n\tconstructor(message, keys, value, root) {\n\t\tsuper(message);\n\t\tthis.name = 'DevalueError';\n\t\tthis.path = keys.join('');\n\t\tthis.value = value;\n\t\tthis.root = root;\n\t}\n}\n\n/** @param {any} thing */\nexport function is_primitive(thing) {\n\treturn Object(thing) !== thing;\n}\n\nconst object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(\n\tObject.prototype\n)\n\t.sort()\n\t.join('\\0');\n\n/** @param {any} thing */\nexport function is_plain_object(thing) {\n\tconst proto = Object.getPrototypeOf(thing);\n\n\treturn (\n\t\tproto === Object.prototype ||\n\t\tproto === null ||\n\t\tObject.getPrototypeOf(proto) === null ||\n\t\tObject.getOwnPropertyNames(proto).sort().join('\\0') === object_proto_names\n\t);\n}\n\n/** @param {any} thing */\nexport function get_type(thing) {\n\treturn Object.prototype.toString.call(thing).slice(8, -1);\n}\n\n/** @param {string} char */\nfunction get_escaped_char(char) {\n\tswitch (char) {\n\t\tcase '\"':\n\t\t\treturn '\\\\\"';\n\t\tcase '<':\n\t\t\treturn '\\\\u003C';\n\t\tcase '\\\\':\n\t\t\treturn '\\\\\\\\';\n\t\tcase '\\n':\n\t\t\treturn '\\\\n';\n\t\tcase '\\r':\n\t\t\treturn '\\\\r';\n\t\tcase '\\t':\n\t\t\treturn '\\\\t';\n\t\tcase '\\b':\n\t\t\treturn '\\\\b';\n\t\tcase '\\f':\n\t\t\treturn '\\\\f';\n\t\tcase '\\u2028':\n\t\t\treturn '\\\\u2028';\n\t\tcase '\\u2029':\n\t\t\treturn '\\\\u2029';\n\t\tdefault:\n\t\t\treturn char < ' '\n\t\t\t\t? `\\\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`\n\t\t\t\t: '';\n\t}\n}\n\n/** @param {string} str */\nexport function stringify_string(str) {\n\tlet result = '';\n\tlet last_pos = 0;\n\tconst len = str.length;\n\n\tfor (let i = 0; i < len; i += 1) {\n\t\tconst char = str[i];\n\t\tconst replacement = get_escaped_char(char);\n\t\tif (replacement) {\n\t\t\tresult += str.slice(last_pos, i) + replacement;\n\t\t\tlast_pos = i + 1;\n\t\t}\n\t}\n\n\treturn `\"${last_pos === 0 ? str : result + str.slice(last_pos)}\"`;\n}\n\n/** @param {Record<string | symbol, any>} object */\nexport function enumerable_symbols(object) {\n\treturn Object.getOwnPropertySymbols(object).filter(\n\t\t(symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable\n\t);\n}\n\nconst is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;\n\n/** @param {string} key */\nexport function stringify_key(key) {\n\treturn is_identifier.test(key) ? '.' + key : '[' + JSON.stringify(key) + ']';\n}\n\n/** @param {string} s */\nfunction is_valid_array_index(s) {\n\tif (s.length === 0) return false;\n\tif (s.length > 1 && s.charCodeAt(0) === 48) return false; // leading zero\n\tfor (let i = 0; i < s.length; i++) {\n\t\tconst c = s.charCodeAt(i);\n\t\tif (c < 48 || c > 57) return false;\n\t}\n\t// by this point we know it's a string of digits, but it has to be within the range of valid array indices\n\tconst n = +s;\n\tif (n >= 2 ** 32 - 1) return false;\n\tif (n < 0) return false;\n\treturn true;\n}\n\n/**\n * Finds the populated indices of an array.\n * @param {unknown[]} array\n */\nexport function valid_array_indices(array) {\n\tconst keys = Object.keys(array);\n\tfor (var i = keys.length - 1; i >= 0; i--) {\n\t\tif (is_valid_array_index(keys[i])) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tkeys.length = i + 1;\n\treturn keys;\n}\n","/**\n * Base64 Encodes an arraybuffer\n * @param {ArrayBuffer} arraybuffer\n * @returns {string}\n */\nexport function encode64(arraybuffer) {\n const dv = new DataView(arraybuffer);\n let binaryString = \"\";\n\n for (let i = 0; i < arraybuffer.byteLength; i++) {\n binaryString += String.fromCharCode(dv.getUint8(i));\n }\n\n return binaryToAscii(binaryString);\n}\n\n/**\n * Decodes a base64 string into an arraybuffer\n * @param {string} string\n * @returns {ArrayBuffer}\n */\nexport function decode64(string) {\n const binaryString = asciiToBinary(string);\n const arraybuffer = new ArrayBuffer(binaryString.length);\n const dv = new DataView(arraybuffer);\n\n for (let i = 0; i < arraybuffer.byteLength; i++) {\n dv.setUint8(i, binaryString.charCodeAt(i));\n }\n\n return arraybuffer;\n}\n\nconst KEY_STRING =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n/**\n * Substitute for atob since it's deprecated in node.\n * Does not do any input validation.\n *\n * @see https://github.com/jsdom/abab/blob/master/lib/atob.js\n *\n * @param {string} data\n * @returns {string}\n */\nfunction asciiToBinary(data) {\n if (data.length % 4 === 0) {\n data = data.replace(/==?$/, \"\");\n }\n\n let output = \"\";\n let buffer = 0;\n let accumulatedBits = 0;\n\n for (let i = 0; i < data.length; i++) {\n buffer <<= 6;\n buffer |= KEY_STRING.indexOf(data[i]);\n accumulatedBits += 6;\n if (accumulatedBits === 24) {\n output += String.fromCharCode((buffer & 0xff0000) >> 16);\n output += String.fromCharCode((buffer & 0xff00) >> 8);\n output += String.fromCharCode(buffer & 0xff);\n buffer = accumulatedBits = 0;\n }\n }\n if (accumulatedBits === 12) {\n buffer >>= 4;\n output += String.fromCharCode(buffer);\n } else if (accumulatedBits === 18) {\n buffer >>= 2;\n output += String.fromCharCode((buffer & 0xff00) >> 8);\n output += String.fromCharCode(buffer & 0xff);\n }\n return output;\n}\n\n/**\n * Substitute for btoa since it's deprecated in node.\n * Does not do any input validation.\n *\n * @see https://github.com/jsdom/abab/blob/master/lib/btoa.js\n *\n * @param {string} str\n * @returns {string}\n */\nfunction binaryToAscii(str) {\n let out = \"\";\n for (let i = 0; i < str.length; i += 3) {\n /** @type {[number, number, number, number]} */\n const groupsOfSix = [undefined, undefined, undefined, undefined];\n groupsOfSix[0] = str.charCodeAt(i) >> 2;\n groupsOfSix[1] = (str.charCodeAt(i) & 0x03) << 4;\n if (str.length > i + 1) {\n groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;\n groupsOfSix[2] = (str.charCodeAt(i + 1) & 0x0f) << 2;\n }\n if (str.length > i + 2) {\n groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;\n groupsOfSix[3] = str.charCodeAt(i + 2) & 0x3f;\n }\n for (let j = 0; j < groupsOfSix.length; j++) {\n if (typeof groupsOfSix[j] === \"undefined\") {\n out += \"=\";\n } else {\n out += KEY_STRING[groupsOfSix[j]];\n }\n }\n }\n return out;\n}\n","export const UNDEFINED = -1;\nexport const HOLE = -2;\nexport const NAN = -3;\nexport const POSITIVE_INFINITY = -4;\nexport const NEGATIVE_INFINITY = -5;\nexport const NEGATIVE_ZERO = -6;\nexport const SPARSE = -7;\n","import { decode64 } from './base64.js';\nimport {\n\tHOLE,\n\tNAN,\n\tNEGATIVE_INFINITY,\n\tNEGATIVE_ZERO,\n\tPOSITIVE_INFINITY,\n\tSPARSE,\n\tUNDEFINED\n} from './constants.js';\n\n/**\n * Revive a value serialized with `devalue.stringify`\n * @param {string} serialized\n * @param {Record<string, (value: any) => any>} [revivers]\n */\nexport function parse(serialized, revivers) {\n\treturn unflatten(JSON.parse(serialized), revivers);\n}\n\n/**\n * Revive a value flattened with `devalue.stringify`\n * @param {number | any[]} parsed\n * @param {Record<string, (value: any) => any>} [revivers]\n */\nexport function unflatten(parsed, revivers) {\n\tif (typeof parsed === 'number') return hydrate(parsed, true);\n\n\tif (!Array.isArray(parsed) || parsed.length === 0) {\n\t\tthrow new Error('Invalid input');\n\t}\n\n\tconst values = /** @type {any[]} */ (parsed);\n\n\tconst hydrated = Array(values.length);\n\n\t/**\n\t * A set of values currently being hydrated with custom revivers,\n\t * used to detect invalid cyclical dependencies\n\t * @type {Set<number> | null}\n\t */\n\tlet hydrating = null;\n\n\t/**\n\t * @param {number} index\n\t * @returns {any}\n\t */\n\tfunction hydrate(index, standalone = false) {\n\t\tif (index === UNDEFINED) return undefined;\n\t\tif (index === NAN) return NaN;\n\t\tif (index === POSITIVE_INFINITY) return Infinity;\n\t\tif (index === NEGATIVE_INFINITY) return -Infinity;\n\t\tif (index === NEGATIVE_ZERO) return -0;\n\n\t\tif (standalone || typeof index !== 'number') {\n\t\t\tthrow new Error(`Invalid input`);\n\t\t}\n\n\t\tif (index in hydrated) return hydrated[index];\n\n\t\tconst value = values[index];\n\n\t\tif (!value || typeof value !== 'object') {\n\t\t\thydrated[index] = value;\n\t\t} else if (Array.isArray(value)) {\n\t\t\tif (typeof value[0] === 'string') {\n\t\t\t\tconst type = value[0];\n\n\t\t\t\tconst reviver =\n\t\t\t\t\trevivers && Object.hasOwn(revivers, type)\n\t\t\t\t\t\t? revivers[type]\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\tif (reviver) {\n\t\t\t\t\tlet i = value[1];\n\t\t\t\t\tif (typeof i !== 'number') {\n\t\t\t\t\t\t// if it's not a number, it was serialized by a builtin reviver\n\t\t\t\t\t\t// so we need to munge it into the format expected by a custom reviver\n\t\t\t\t\t\ti = values.push(value[1]) - 1;\n\t\t\t\t\t}\n\n\t\t\t\t\thydrating ??= new Set();\n\n\t\t\t\t\tif (hydrating.has(i)) {\n\t\t\t\t\t\tthrow new Error('Invalid circular reference');\n\t\t\t\t\t}\n\n\t\t\t\t\thydrating.add(i);\n\t\t\t\t\thydrated[index] = reviver(hydrate(i));\n\t\t\t\t\thydrating.delete(i);\n\n\t\t\t\t\treturn hydrated[index];\n\t\t\t\t}\n\n\t\t\t\tswitch (type) {\n\t\t\t\t\tcase 'Date':\n\t\t\t\t\t\thydrated[index] = new Date(value[1]);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'Set':\n\t\t\t\t\t\tconst set = new Set();\n\t\t\t\t\t\thydrated[index] = set;\n\t\t\t\t\t\tfor (let i = 1; i < value.length; i += 1) {\n\t\t\t\t\t\t\tset.add(hydrate(value[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'Map':\n\t\t\t\t\t\tconst map = new Map();\n\t\t\t\t\t\thydrated[index] = map;\n\t\t\t\t\t\tfor (let i = 1; i < value.length; i += 2) {\n\t\t\t\t\t\t\tmap.set(hydrate(value[i]), hydrate(value[i + 1]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'RegExp':\n\t\t\t\t\t\thydrated[index] = new RegExp(value[1], value[2]);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'Object':\n\t\t\t\t\t\thydrated[index] = Object(value[1]);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'BigInt':\n\t\t\t\t\t\thydrated[index] = BigInt(value[1]);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'null':\n\t\t\t\t\t\tconst obj = Object.create(null);\n\t\t\t\t\t\thydrated[index] = obj;\n\t\t\t\t\t\tfor (let i = 1; i < value.length; i += 2) {\n\t\t\t\t\t\t\tobj[value[i]] = hydrate(value[i + 1]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'Int8Array':\n\t\t\t\t\tcase 'Uint8Array':\n\t\t\t\t\tcase 'Uint8ClampedArray':\n\t\t\t\t\tcase 'Int16Array':\n\t\t\t\t\tcase 'Uint16Array':\n\t\t\t\t\tcase 'Int32Array':\n\t\t\t\t\tcase 'Uint32Array':\n\t\t\t\t\tcase 'Float32Array':\n\t\t\t\t\tcase 'Float64Array':\n\t\t\t\t\tcase 'BigInt64Array':\n\t\t\t\t\tcase 'BigUint64Array': {\n\t\t\t\t\t\tif (values[value[1]][0] !== 'ArrayBuffer') {\n\t\t\t\t\t\t\t// without this, if we receive malformed input we could\n\t\t\t\t\t\t\t// end up trying to hydrate in a circle or allocate\n\t\t\t\t\t\t\t// huge amounts of memory when we call `new TypedArrayConstructor(buffer)`\n\t\t\t\t\t\t\tthrow new Error('Invalid data');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst TypedArrayConstructor = globalThis[type];\n\t\t\t\t\t\tconst buffer = hydrate(value[1]);\n\t\t\t\t\t\tconst typedArray = new TypedArrayConstructor(buffer);\n\n\t\t\t\t\t\thydrated[index] =\n\t\t\t\t\t\t\tvalue[2] !== undefined\n\t\t\t\t\t\t\t\t? typedArray.subarray(value[2], value[3])\n\t\t\t\t\t\t\t\t: typedArray;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'ArrayBuffer': {\n\t\t\t\t\t\tconst base64 = value[1];\n\t\t\t\t\t\tif (typeof base64 !== 'string') {\n\t\t\t\t\t\t\tthrow new Error('Invalid ArrayBuffer encoding');\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst arraybuffer = decode64(base64);\n\t\t\t\t\t\thydrated[index] = arraybuffer;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'Temporal.Duration':\n\t\t\t\t\tcase 'Temporal.Instant':\n\t\t\t\t\tcase 'Temporal.PlainDate':\n\t\t\t\t\tcase 'Temporal.PlainTime':\n\t\t\t\t\tcase 'Temporal.PlainDateTime':\n\t\t\t\t\tcase 'Temporal.PlainMonthDay':\n\t\t\t\t\tcase 'Temporal.PlainYearMonth':\n\t\t\t\t\tcase 'Temporal.ZonedDateTime': {\n\t\t\t\t\t\tconst temporalName = type.slice(9);\n\t\t\t\t\t\t// @ts-expect-error TS doesn't know about Temporal yet\n\t\t\t\t\t\thydrated[index] = Temporal[temporalName].from(value[1]);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'URL': {\n\t\t\t\t\t\tconst url = new URL(value[1]);\n\t\t\t\t\t\thydrated[index] = url;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'URLSearchParams': {\n\t\t\t\t\t\tconst url = new URLSearchParams(value[1]);\n\t\t\t\t\t\thydrated[index] = url;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(`Unknown type ${type}`);\n\t\t\t\t}\n\t\t\t} else if (value[0] === SPARSE) {\n\t\t\t\t// Sparse array encoding: [SPARSE, length, idx, val, idx, val, ...]\n\t\t\t\tconst len = value[1];\n\n\t\t\t\tconst array = new Array(len);\n\t\t\t\thydrated[index] = array;\n\n\t\t\t\tfor (let i = 2; i < value.length; i += 2) {\n\t\t\t\t\tconst idx = value[i];\n\t\t\t\t\tarray[idx] = hydrate(value[i + 1]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst array = new Array(value.length);\n\t\t\t\thydrated[index] = array;\n\n\t\t\t\tfor (let i = 0; i < value.length; i += 1) {\n\t\t\t\t\tconst n = value[i];\n\t\t\t\t\tif (n === HOLE) continue;\n\n\t\t\t\t\tarray[i] = hydrate(n);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t/** @type {Record<string, any>} */\n\t\t\tconst object = {};\n\t\t\thydrated[index] = object;\n\n\t\t\tfor (const key of Object.keys(value)) {\n\t\t\t\tif (key === '__proto__') {\n\t\t\t\t\tthrow new Error('Cannot parse an object with a `__proto__` property');\n\t\t\t\t}\n\n\t\t\t\tconst n = value[key];\n\t\t\t\tobject[key] = hydrate(n);\n\t\t\t}\n\t\t}\n\n\t\treturn hydrated[index];\n\t}\n\n\treturn hydrate(0);\n}\n","import {\n\tDevalueError,\n\tenumerable_symbols,\n\tget_type,\n\tis_plain_object,\n\tis_primitive,\n\tstringify_key,\n\tstringify_string,\n\tvalid_array_indices\n} from './utils.js';\nimport {\n\tHOLE,\n\tNAN,\n\tNEGATIVE_INFINITY,\n\tNEGATIVE_ZERO,\n\tPOSITIVE_INFINITY,\n\tSPARSE,\n\tUNDEFINED\n} from './constants.js';\nimport { encode64 } from './base64.js';\n\n/**\n * Turn a value into a JSON string that can be parsed with `devalue.parse`\n * @param {any} value\n * @param {Record<string, (value: any) => any>} [reducers]\n */\nexport function stringify(value, reducers) {\n\t/** @type {any[]} */\n\tconst stringified = [];\n\n\t/** @type {Map<any, number>} */\n\tconst indexes = new Map();\n\n\t/** @type {Array<{ key: string, fn: (value: any) => any }>} */\n\tconst custom = [];\n\tif (reducers) {\n\t\tfor (const key of Object.getOwnPropertyNames(reducers)) {\n\t\t\tcustom.push({ key, fn: reducers[key] });\n\t\t}\n\t}\n\n\t/** @type {string[]} */\n\tconst keys = [];\n\n\tlet p = 0;\n\n\t/** @param {any} thing */\n\tfunction flatten(thing) {\n\t\tif (thing === undefined) return UNDEFINED;\n\t\tif (Number.isNaN(thing)) return NAN;\n\t\tif (thing === Infinity) return POSITIVE_INFINITY;\n\t\tif (thing === -Infinity) return NEGATIVE_INFINITY;\n\t\tif (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;\n\n\t\tif (indexes.has(thing)) return indexes.get(thing);\n\n\t\tconst index = p++;\n\t\tindexes.set(thing, index);\n\n\t\tfor (const { key, fn } of custom) {\n\t\t\tconst value = fn(thing);\n\t\t\tif (value) {\n\t\t\t\tstringified[index] = `[\"${key}\",${flatten(value)}]`;\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\n\t\tif (typeof thing === 'function') {\n\t\t\tthrow new DevalueError(`Cannot stringify a function`, keys, thing, value);\n\t\t}\n\n\t\tlet str = '';\n\n\t\tif (is_primitive(thing)) {\n\t\t\tstr = stringify_primitive(thing);\n\t\t} else {\n\t\t\tconst type = get_type(thing);\n\n\t\t\tswitch (type) {\n\t\t\t\tcase 'Number':\n\t\t\t\tcase 'String':\n\t\t\t\tcase 'Boolean':\n\t\t\t\t\tstr = `[\"Object\",${stringify_primitive(thing)}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'BigInt':\n\t\t\t\t\tstr = `[\"BigInt\",${thing}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Date':\n\t\t\t\t\tconst valid = !isNaN(thing.getDate());\n\t\t\t\t\tstr = `[\"Date\",\"${valid ? thing.toISOString() : ''}\"]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'URL':\n\t\t\t\t\tstr = `[\"URL\",${stringify_string(thing.toString())}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'URLSearchParams':\n\t\t\t\t\tstr = `[\"URLSearchParams\",${stringify_string(thing.toString())}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'RegExp':\n\t\t\t\t\tconst { source, flags } = thing;\n\t\t\t\t\tstr = flags\n\t\t\t\t\t\t? `[\"RegExp\",${stringify_string(source)},\"${flags}\"]`\n\t\t\t\t\t\t: `[\"RegExp\",${stringify_string(source)}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Array': {\n\t\t\t\t\t// For dense arrays (no holes), we iterate normally.\n\t\t\t\t\t// When we encounter the first hole, we call Object.keys\n\t\t\t\t\t// to determine the sparseness, then decide between:\n\t\t\t\t\t// - HOLE encoding: [-2, val, -2, ...] (default)\n\t\t\t\t\t// - Sparse encoding: [-7, length, idx, val, ...] (for very sparse arrays)\n\t\t\t\t\t// Only the sparse path avoids iterating every slot, which\n\t\t\t\t\t// is what protects against the DoS of e.g. `arr[1000000] = 1`.\n\t\t\t\t\tlet mostly_dense = false;\n\n\t\t\t\t\tstr = '[';\n\n\t\t\t\t\tfor (let i = 0; i < thing.length; i += 1) {\n\t\t\t\t\t\tif (i > 0) str += ',';\n\n\t\t\t\t\t\tif (Object.hasOwn(thing, i)) {\n\t\t\t\t\t\t\tkeys.push(`[${i}]`);\n\t\t\t\t\t\t\tstr += flatten(thing[i]);\n\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t} else if (mostly_dense) {\n\t\t\t\t\t\t\t// Use dense encoding. The heuristic guarantees the\n\t\t\t\t\t\t\t// array is only mildly sparse, so iterating over every\n\t\t\t\t\t\t\t// slot is fine.\n\t\t\t\t\t\t\tstr += HOLE;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Decide between HOLE encoding and sparse encoding.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// HOLE encoding: each hole is serialized as the HOLE\n\t\t\t\t\t\t\t// sentinel (-2). For example, [, \"a\", ,] becomes\n\t\t\t\t\t\t\t// [-2, 0, -2]. Each hole costs 3 chars (\"-2\" + comma).\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Sparse encoding: lists only populated indices.\n\t\t\t\t\t\t\t// For example, [, \"a\", ,] becomes [-7, 3, 1, 0] — the\n\t\t\t\t\t\t\t// -7 sentinel, the array length (3), then index-value\n\t\t\t\t\t\t\t// pairs. This avoids paying per-hole, but each element\n\t\t\t\t\t\t\t// costs extra chars to write its index.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// The values are the same size either way, so the\n\t\t\t\t\t\t\t// choice comes down to structural overhead:\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// HOLE overhead:\n\t\t\t\t\t\t\t// 3 chars per hole (\"-2\" + comma)\n\t\t\t\t\t\t\t// = (L - P) * 3\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Sparse overhead:\n\t\t\t\t\t\t\t// \"-7,\" — 3 chars (sparse sentinel + comma)\n\t\t\t\t\t\t\t// + length + \",\" — (d + 1) chars (array length + comma)\n\t\t\t\t\t\t\t// + per element: index + \",\" — (d + 1) chars\n\t\t\t\t\t\t\t// = (4 + d) + P * (d + 1)\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// where L is the array length, P is the number of\n\t\t\t\t\t\t\t// populated elements, and d is the number of digits\n\t\t\t\t\t\t\t// in L (an upper bound on the digits in any index).\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Sparse encoding is cheaper when:\n\t\t\t\t\t\t\t// (4 + d) + P * (d + 1) < (L - P) * 3\n\t\t\t\t\t\t\tconst populated_keys = valid_array_indices(/** @type {any[]} */ (thing));\n\t\t\t\t\t\t\tconst population = populated_keys.length;\n\t\t\t\t\t\t\tconst d = String(thing.length).length;\n\n\t\t\t\t\t\t\tconst hole_cost = (thing.length - population) * 3;\n\t\t\t\t\t\t\tconst sparse_cost = 4 + d + population * (d + 1);\n\n\t\t\t\t\t\t\tif (hole_cost > sparse_cost) {\n\t\t\t\t\t\t\t\tstr = '[' + SPARSE + ',' + thing.length;\n\t\t\t\t\t\t\t\tfor (let j = 0; j < populated_keys.length; j++) {\n\t\t\t\t\t\t\t\t\tconst key = populated_keys[j];\n\t\t\t\t\t\t\t\t\tkeys.push(`[${key}]`);\n\t\t\t\t\t\t\t\t\tstr += ',' + key + ',' + flatten(thing[key]);\n\t\t\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmostly_dense = true;\n\t\t\t\t\t\t\t\tstr += HOLE;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'Set':\n\t\t\t\t\tstr = '[\"Set\"';\n\n\t\t\t\t\tfor (const value of thing) {\n\t\t\t\t\t\tstr += `,${flatten(value)}`;\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Map':\n\t\t\t\t\tstr = '[\"Map\"';\n\n\t\t\t\t\tfor (const [key, value] of thing) {\n\t\t\t\t\t\tkeys.push(\n\t\t\t\t\t\t\t`.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstr += `,${flatten(key)},${flatten(value)}`;\n\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Int8Array':\n\t\t\t\tcase 'Uint8Array':\n\t\t\t\tcase 'Uint8ClampedArray':\n\t\t\t\tcase 'Int16Array':\n\t\t\t\tcase 'Uint16Array':\n\t\t\t\tcase 'Int32Array':\n\t\t\t\tcase 'Uint32Array':\n\t\t\t\tcase 'Float32Array':\n\t\t\t\tcase 'Float64Array':\n\t\t\t\tcase 'BigInt64Array':\n\t\t\t\tcase 'BigUint64Array': {\n\t\t\t\t\t/** @type {import(\"./types.js\").TypedArray} */\n\t\t\t\t\tconst typedArray = thing;\n\t\t\t\t\tstr = '[\"' + type + '\",' + flatten(typedArray.buffer);\n\n\t\t\t\t\tconst a = thing.byteOffset;\n\t\t\t\t\tconst b = a + thing.byteLength;\n\n\t\t\t\t\t// handle subarrays\n\t\t\t\t\tif (a > 0 || b !== typedArray.buffer.byteLength) {\n\t\t\t\t\t\tconst m = +/(\\d+)/.exec(type)[1] / 8;\n\t\t\t\t\t\tstr += `,${a / m},${b / m}`;\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'ArrayBuffer': {\n\t\t\t\t\t/** @type {ArrayBuffer} */\n\t\t\t\t\tconst arraybuffer = thing;\n\t\t\t\t\tconst base64 = encode64(arraybuffer);\n\n\t\t\t\t\tstr = `[\"ArrayBuffer\",\"${base64}\"]`;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'Temporal.Duration':\n\t\t\t\tcase 'Temporal.Instant':\n\t\t\t\tcase 'Temporal.PlainDate':\n\t\t\t\tcase 'Temporal.PlainTime':\n\t\t\t\tcase 'Temporal.PlainDateTime':\n\t\t\t\tcase 'Temporal.PlainMonthDay':\n\t\t\t\tcase 'Temporal.PlainYearMonth':\n\t\t\t\tcase 'Temporal.ZonedDateTime':\n\t\t\t\t\tstr = `[\"${type}\",${stringify_string(thing.toString())}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tif (!is_plain_object(thing)) {\n\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t`Cannot stringify arbitrary non-POJOs`,\n\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (enumerable_symbols(thing).length > 0) {\n\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t`Cannot stringify POJOs with symbolic keys`,\n\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (Object.getPrototypeOf(thing) === null) {\n\t\t\t\t\t\tstr = '[\"null\"';\n\t\t\t\t\t\tfor (const key of Object.keys(thing)) {\n\t\t\t\t\t\t\tif (key === '__proto__') {\n\t\t\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t\t\t`Cannot stringify objects with __proto__ keys`,\n\t\t\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tkeys.push(stringify_key(key));\n\t\t\t\t\t\t\tstr += `,${stringify_string(key)},${flatten(thing[key])}`;\n\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstr += ']';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstr = '{';\n\t\t\t\t\t\tlet started = false;\n\t\t\t\t\t\tfor (const key of Object.keys(thing)) {\n\t\t\t\t\t\t\tif (key === '__proto__') {\n\t\t\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t\t\t`Cannot stringify objects with __proto__ keys`,\n\t\t\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (started) str += ',';\n\t\t\t\t\t\t\tstarted = true;\n\t\t\t\t\t\t\tkeys.push(stringify_key(key));\n\t\t\t\t\t\t\tstr += `${stringify_string(key)}:${flatten(thing[key])}`;\n\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstr += '}';\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tstringified[index] = str;\n\t\treturn index;\n\t}\n\n\tconst index = flatten(value);\n\n\t// special case — value is represented as a negative index\n\tif (index < 0) return `${index}`;\n\n\treturn `[${stringified.join(',')}]`;\n}\n\n/**\n * @param {any} thing\n * @returns {string}\n */\nfunction stringify_primitive(thing) {\n\tconst type = typeof thing;\n\tif (type === 'string') return stringify_string(thing);\n\tif (thing instanceof String) return stringify_string(thing.toString());\n\tif (thing === void 0) return UNDEFINED.toString();\n\tif (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();\n\tif (type === 'bigint') return `[\"BigInt\",\"${thing}\"]`;\n\treturn String(thing);\n}\n","import assert from \"node:assert\";\nimport { Buffer } from \"node:buffer\";\nimport { parse, stringify } from \"devalue\";\nimport type {\n\tBlob as WorkerBlob,\n\tBlobOptions as WorkerBlobOptions,\n\tFile as WorkerFile,\n\tFileOptions as WorkerFileOptions,\n\tHeaders as WorkerHeaders,\n\tReadableStream as WorkerReadableStream,\n\tRequest as WorkerRequest,\n\tResponse as WorkerResponse,\n} from \"@cloudflare/workers-types/experimental\";\n\n// This file implements `devalue` reducers and revivers for structured-\n// serialisable types not supported by default. See serialisable types here:\n// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types\n\nexport type ReducerReviver = (value: unknown) => unknown;\nexport type ReducersRevivers = Record<string, ReducerReviver>;\n\nconst ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS = [\n\tDataView<ArrayBuffer>,\n\tInt8Array,\n\tUint8Array,\n\tUint8ClampedArray,\n\tInt16Array,\n\tUint16Array,\n\tInt32Array,\n\tUint32Array,\n\tFloat32Array,\n\tFloat64Array,\n\tBigInt64Array,\n\tBigUint64Array,\n] as const;\nconst ALLOWED_ERROR_CONSTRUCTORS = [\n\tEvalError,\n\tRangeError,\n\tReferenceError,\n\tSyntaxError,\n\tTypeError,\n\tURIError,\n\tError, // `Error` last so more specific error subclasses preferred\n] as const;\n\nexport const structuredSerializableReducers: ReducersRevivers = {\n\tArrayBuffer(value) {\n\t\tif (value instanceof ArrayBuffer) {\n\t\t\t// Return single element array so empty `ArrayBuffer` serialised as truthy\n\t\t\treturn [Buffer.from(value).toString(\"base64\")];\n\t\t}\n\t},\n\tArrayBufferView(value) {\n\t\tif (ArrayBuffer.isView(value)) {\n\t\t\tlet name = value.constructor.name;\n\t\t\t// Subclasses like Node.js `Buffer` extend standard typed arrays but\n\t\t\t// aren't available in all runtimes. Normalise to the parent constructor.\n\t\t\tif (\n\t\t\t\t!ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS.some((c) => c.name === name)\n\t\t\t) {\n\t\t\t\tfor (const ctor of ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS) {\n\t\t\t\t\tif (value instanceof ctor) {\n\t\t\t\t\t\tname = ctor.name;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet buf = value.buffer;\n\t\t\tlet off = value.byteOffset;\n\t\t\tif (off !== 0 || buf.byteLength !== value.byteLength) {\n\t\t\t\tbuf = buf.slice(off, off + value.byteLength);\n\t\t\t\toff = 0;\n\t\t\t}\n\t\t\treturn [name, buf, off, value.byteLength];\n\t\t}\n\t},\n\tRegExp(value) {\n\t\tif (value instanceof RegExp) {\n\t\t\tconst { source, flags } = value;\n\t\t\tconst encoded = Buffer.from(source).toString(\"base64\");\n\t\t\treturn flags ? [\"RegExp\", encoded, flags] : [\"RegExp\", encoded];\n\t\t}\n\t},\n\tError(value) {\n\t\tfor (const ctor of ALLOWED_ERROR_CONSTRUCTORS) {\n\t\t\tif (value instanceof ctor && value.name === ctor.name) {\n\t\t\t\treturn [value.name, value.message, value.stack, value.cause];\n\t\t\t}\n\t\t}\n\t\tif (value instanceof Error) {\n\t\t\treturn [\"Error\", value.message, value.stack, value.cause];\n\t\t}\n\t},\n};\nexport const structuredSerializableRevivers: ReducersRevivers = {\n\tArrayBuffer(value) {\n\t\tassert(Array.isArray(value));\n\t\tconst [encoded] = value as unknown[];\n\t\tassert(typeof encoded === \"string\");\n\t\tconst view = Buffer.from(encoded, \"base64\");\n\t\treturn view.buffer.slice(\n\t\t\tview.byteOffset,\n\t\t\tview.byteOffset + view.byteLength\n\t\t);\n\t},\n\tArrayBufferView(value) {\n\t\tassert(Array.isArray(value));\n\t\tconst [name, buffer, byteOffset, byteLength] = value as unknown[];\n\t\tassert(typeof name === \"string\");\n\t\tassert(buffer instanceof ArrayBuffer);\n\t\tassert(typeof byteOffset === \"number\");\n\t\tassert(typeof byteLength === \"number\");\n\t\tconst ctor = (globalThis as Record<string, unknown>)[\n\t\t\tname\n\t\t] as (typeof ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS)[number];\n\t\tassert(ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS.includes(ctor));\n\t\tlet length = byteLength;\n\t\tif (\"BYTES_PER_ELEMENT\" in ctor) length /= ctor.BYTES_PER_ELEMENT;\n\t\treturn new ctor(buffer as ArrayBuffer, byteOffset, length);\n\t},\n\tRegExp(value) {\n\t\tassert(Array.isArray(value));\n\t\tconst [name, encoded, flags] = value;\n\t\tassert(typeof name === \"string\");\n\t\tassert(typeof encoded === \"string\");\n\t\tconst source = Buffer.from(encoded, \"base64\").toString(\"utf-8\");\n\t\treturn new RegExp(source, flags);\n\t},\n\tError(value) {\n\t\tassert(Array.isArray(value));\n\t\tconst [name, message, stack, cause] = value as unknown[];\n\t\tassert(typeof name === \"string\");\n\t\tassert(typeof message === \"string\");\n\t\tassert(stack === undefined || typeof stack === \"string\");\n\t\tconst ctor = (globalThis as Record<string, unknown>)[\n\t\t\tname\n\t\t] as (typeof ALLOWED_ERROR_CONSTRUCTORS)[number];\n\t\tassert(ALLOWED_ERROR_CONSTRUCTORS.includes(ctor));\n\t\tconst error = new ctor(message, { cause });\n\t\terror.stack = stack;\n\t\treturn error;\n\t},\n};\n\n// This file gets imported both by Node and workers. These platforms have\n// different ways of accessing/performing operations required by this code.\n// This interface should be implemented by both platforms to provide this\n// functionality. `RS` is the type of `ReadableStream`.\nexport interface PlatformImpl<RS> {\n\tBlob: typeof WorkerBlob;\n\tFile: typeof WorkerFile;\n\tHeaders: typeof WorkerHeaders;\n\tRequest: typeof WorkerRequest;\n\tResponse: typeof WorkerResponse;\n\n\tisReadableStream(value: unknown): value is RS;\n\tbufferReadableStream(stream: RS): Promise<ArrayBuffer>;\n\tunbufferReadableStream(buffer: ArrayBuffer): RS;\n}\n\nexport function createHTTPReducers(\n\timpl: PlatformImpl<unknown>\n): ReducersRevivers {\n\treturn {\n\t\tHeaders(val) {\n\t\t\tif (val instanceof impl.Headers) return [...val.entries()];\n\t\t},\n\t\tRequest(val) {\n\t\t\tif (val instanceof impl.Request) {\n\t\t\t\treturn [val.method, val.url, val.headers, val.cf, val.body];\n\t\t\t}\n\t\t},\n\t\tResponse(val) {\n\t\t\tif (val instanceof impl.Response) {\n\t\t\t\treturn [val.status, val.statusText, val.headers, val.cf, val.body];\n\t\t\t}\n\t\t},\n\t};\n}\nexport function createHTTPRevivers<RS>(\n\timpl: PlatformImpl<RS>\n): ReducersRevivers {\n\treturn {\n\t\tHeaders(value) {\n\t\t\tassert(typeof value === \"object\" && value !== null);\n\t\t\treturn new impl.Headers(value as string[][]);\n\t\t},\n\t\tRequest(value) {\n\t\t\tassert(Array.isArray(value));\n\t\t\tconst [method, url, headers, cf, body] = value as unknown[];\n\t\t\tassert(typeof method === \"string\");\n\t\t\tassert(typeof url === \"string\");\n\t\t\tassert(headers instanceof impl.Headers);\n\t\t\tassert(body === null || impl.isReadableStream(body));\n\t\t\treturn new impl.Request(url, {\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\tcf,\n\t\t\t\t// @ts-expect-error `duplex` is not required by `workerd` yet\n\t\t\t\tduplex: body === null ? undefined : \"half\",\n\t\t\t\tbody: body as WorkerReadableStream | null,\n\t\t\t});\n\t\t},\n\t\tResponse(value) {\n\t\t\tassert(Array.isArray(value));\n\t\t\tconst [status, statusText, headers, cf, body] = value as unknown[];\n\t\t\tassert(typeof status === \"number\");\n\t\t\tassert(typeof statusText === \"string\");\n\t\t\tassert(headers instanceof impl.Headers);\n\t\t\tassert(body === null || impl.isReadableStream(body));\n\t\t\treturn new impl.Response(body as WorkerReadableStream | null, {\n\t\t\t\tstatus,\n\t\t\t\tstatusText,\n\t\t\t\theaders,\n\t\t\t\tcf,\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport interface StringifiedWithStream<RS> {\n\tvalue: string;\n\tunbufferedStream?: RS;\n}\n// `devalue` `stringify()` that allows a single stream to be \"unbuffered\", and\n// sent separately. Other streams will be buffered.\nexport function stringifyWithStreams<RS>(\n\timpl: PlatformImpl<RS>,\n\tvalue: unknown,\n\treducers: ReducersRevivers,\n\tallowUnbufferedStream: boolean\n): StringifiedWithStream<RS> | Promise<StringifiedWithStream<RS>> {\n\tlet unbufferedStream: RS | undefined;\n\t// The tricky thing here is that `devalue` `stringify()` is synchronous, and\n\t// doesn't support asynchronous reducers. Assuming we visit values in the same\n\t// order each time, we can use an array to store buffer promises.\n\tconst bufferPromises: Promise<ArrayBuffer>[] = [];\n\tconst streamReducers: ReducersRevivers = {\n\t\tReadableStream(value) {\n\t\t\tif (impl.isReadableStream(value)) {\n\t\t\t\tif (allowUnbufferedStream && unbufferedStream === undefined) {\n\t\t\t\t\tunbufferedStream = value;\n\t\t\t\t} else {\n\t\t\t\t\tbufferPromises.push(impl.bufferReadableStream(value));\n\t\t\t\t}\n\t\t\t\t// Using `true` to signify unbuffered stream, buffered streams will\n\t\t\t\t// have this replaced with an `ArrayBuffer` on the 2nd `stringify()`\n\t\t\t\t// If we don't have any buffer promises, this will encode to the correct\n\t\t\t\t// value, so we don't need to re-`stringify()`.\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\tBlob(value) {\n\t\t\tif (value instanceof impl.Blob) {\n\t\t\t\t// `Blob`s are always buffered. We can't just serialise with a stream\n\t\t\t\t// here (and recursively use the reducer above), because `workerd`\n\t\t\t\t// doesn't allow us to synchronously reconstruct a `Blob` from a stream:\n\t\t\t\t// its `new Blob([...])` doesn't support `ReadableStream` blob bits.\n\t\t\t\tbufferPromises.push(value.arrayBuffer());\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\n\t\t...reducers,\n\t};\n\tif (typeof value === \"function\") {\n\t\tvalue = new __MiniflareFunctionWrapper(\n\t\t\tvalue as ConstructorParameters<typeof __MiniflareFunctionWrapper>[0]\n\t\t);\n\t}\n\tconst stringifiedValue = stringify(value, streamReducers);\n\t// If we didn't need to buffer anything, we've just encoded correctly. Note\n\t// `unbufferedStream` may be undefined if the `value` didn't contain streams.\n\t// Note also in this case we're returning synchronously, so we can use this\n\t// for synchronous methods too.\n\tif (bufferPromises.length === 0) {\n\t\treturn { value: stringifiedValue, unbufferedStream };\n\t}\n\n\t// Otherwise, wait for buffering to complete, and `stringify()` again with\n\t// a reducer that expects buffers.\n\treturn Promise.all(bufferPromises).then((streamBuffers) => {\n\t\t// Again, we're assuming values are visited in the same order, so `shift()`\n\t\t// will give us the next correct buffer\n\t\tstreamReducers.ReadableStream = function (value) {\n\t\t\tif (impl.isReadableStream(value)) {\n\t\t\t\tif (value === unbufferedStream) {\n\t\t\t\t\treturn true;\n\t\t\t\t} else {\n\t\t\t\t\treturn streamBuffers.shift();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tstreamReducers.Blob = function (value) {\n\t\t\tif (value instanceof impl.Blob) {\n\t\t\t\tconst array: unknown[] = [streamBuffers.shift(), value.type];\n\t\t\t\tif (value instanceof impl.File) {\n\t\t\t\t\tarray.push(value.name, value.lastModified);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t}\n\t\t};\n\t\tconst stringifiedValue = stringify(value, streamReducers);\n\t\treturn { value: stringifiedValue, unbufferedStream };\n\t});\n}\n\n// functions can't be stringified, so we wrap them into a class that we then use to pseudo-serialize them\n// we also add a proxy and make sure that properties set on the function object are accessible\n// (this is in particular necessary for RpcStubs)\nexport class __MiniflareFunctionWrapper {\n\tconstructor(\n\t\tfnWithProps: ((...args: unknown[]) => unknown) & {\n\t\t\t[key: string | symbol]: unknown;\n\t\t}\n\t) {\n\t\treturn new Proxy(this, {\n\t\t\tget: (_, key) => {\n\t\t\t\tif (key === \"__miniflareWrappedFunction\") return fnWithProps;\n\t\t\t\treturn fnWithProps[key];\n\t\t\t},\n\t\t});\n\t}\n}\n\nexport function parseWithReadableStreams<RS>(\n\timpl: PlatformImpl<RS>,\n\tstringified: StringifiedWithStream<RS>,\n\trevivers: ReducersRevivers\n): unknown {\n\tconst streamRevivers: ReducersRevivers = {\n\t\tReadableStream(value) {\n\t\t\tif (value === true) {\n\t\t\t\tassert(stringified.unbufferedStream !== undefined);\n\t\t\t\treturn stringified.unbufferedStream;\n\t\t\t}\n\t\t\tassert(value instanceof ArrayBuffer);\n\t\t\treturn impl.unbufferReadableStream(value);\n\t\t},\n\t\tBlob(value) {\n\t\t\tassert(Array.isArray(value));\n\t\t\tif (value.length === 2) {\n\t\t\t\t// Blob\n\t\t\t\tconst [buffer, type] = value as unknown[];\n\t\t\t\tassert(buffer instanceof ArrayBuffer);\n\t\t\t\tassert(typeof type === \"string\");\n\t\t\t\tconst opts: WorkerBlobOptions = {};\n\t\t\t\tif (type !== \"\") opts.type = type;\n\t\t\t\treturn new impl.Blob([buffer], opts);\n\t\t\t} else {\n\t\t\t\t// File\n\t\t\t\tassert(value.length === 4);\n\t\t\t\tconst [buffer, type, name, lastModified] = value as unknown[];\n\t\t\t\tassert(buffer instanceof ArrayBuffer);\n\t\t\t\tassert(typeof type === \"string\");\n\t\t\t\tassert(typeof name === \"string\");\n\t\t\t\tassert(typeof lastModified === \"number\");\n\t\t\t\tconst opts: WorkerFileOptions = { lastModified };\n\t\t\t\tif (type !== \"\") opts.type = type;\n\t\t\t\treturn new impl.File([buffer], name, opts);\n\t\t\t}\n\t\t},\n\t\t...revivers,\n\t};\n\n\treturn parse(stringified.value, streamRevivers);\n}\n","import assert from \"node:assert\";\nimport * as vm from \"node:vm\";\nimport defines from \"__VITEST_POOL_WORKERS_DEFINES\";\nimport {\n\tcreateWorkerEntrypointWrapper,\n\tmaybeHandleRunRequest,\n\tregisterHandlerAndGlobalWaitUntil,\n\trunInRunnerObject,\n} from \"cloudflare:test-internal\";\nimport { DurableObject } from \"cloudflare:workers\";\nimport * as devalue from \"devalue\";\n// Using relative path here to ensure `esbuild` bundles it\nimport {\n\tstructuredSerializableReducers,\n\tstructuredSerializableRevivers,\n} from \"../../../miniflare/src/workers/core/devalue\";\n\nfunction structuredSerializableStringify(value: unknown): string {\n\treturn devalue.stringify(value, structuredSerializableReducers);\n}\nfunction structuredSerializableParse(value: string): unknown {\n\treturn devalue.parse(value, structuredSerializableRevivers);\n}\n\n// Mock Service Worker needs this — stub with no-op methods since workerd\n// doesn't provide BroadcastChannel\nglobalThis.BroadcastChannel = class {\n\tconstructor(public name: string) {}\n\tpostMessage(_message: unknown) {}\n\tclose() {}\n\taddEventListener(_type: string, _listener: unknown) {}\n\tremoveEventListener(_type: string, _listener: unknown) {}\n\tonmessage: ((event: unknown) => void) | null = null;\n\tonmessageerror: ((event: unknown) => void) | null = null;\n} as unknown as typeof BroadcastChannel;\n\nlet cwd: string | undefined;\nprocess.cwd = () => {\n\tassert(cwd !== undefined, \"Expected cwd to be set\");\n\treturn cwd;\n};\n\nglobalThis.__console = console;\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction getCallerFileName(of: Function): string | null {\n\tconst originalStackTraceLimit = Error.stackTraceLimit;\n\tconst originalPrepareStackTrace = Error.prepareStackTrace;\n\ttry {\n\t\tlet fileName: string | null = null;\n\t\tError.stackTraceLimit = 1;\n\t\tError.prepareStackTrace = (_error, callSites) => {\n\t\t\tfileName = callSites[0]?.getFileName();\n\t\t\treturn \"\";\n\t\t};\n\t\tconst error: { stack?: string } = {};\n\t\tError.captureStackTrace(error, of);\n\t\tvoid error.stack; // Access to generate stack trace\n\t\treturn fileName;\n\t} finally {\n\t\tError.stackTraceLimit = originalStackTraceLimit;\n\t\tError.prepareStackTrace = originalPrepareStackTrace;\n\t}\n}\n\nconst originalSetTimeout = globalThis.setTimeout;\nconst originalClearTimeout = globalThis.clearTimeout;\n\nconst timeoutPromiseResolves = new Map<unknown, () => void>();\nconst monkeypatchedSetTimeout = (...args: Parameters<typeof setTimeout>) => {\n\tconst [callback, delay, ...restArgs] = args;\n\tconst callbackName = args[0]?.name ?? \"\";\n\tconst callerFileName = getCallerFileName(monkeypatchedSetTimeout);\n\tconst fromVitest =\n\t\t/\\/node_modules\\/(\\.pnpm\\/|\\.store\\/)?vitest/.test(callerFileName ?? \"\") ||\n\t\t/\\/packages\\/vitest\\/dist/.test(callerFileName ?? \"\") ||\n\t\t/\\/node_modules\\/(\\.pnpm\\/|\\.store\\/)?@voidzero-dev[+/]vite-plus-test/.test(\n\t\t\tcallerFileName ?? \"\"\n\t\t);\n\n\t// If this `setTimeout()` isn't from Vitest, or has a non-zero delay,\n\t// just call the original function\n\tif (!fromVitest || delay) {\n\t\treturn originalSetTimeout.apply(globalThis, args);\n\t}\n\n\t// HACK: `vitest/dist/vendor/vi.js` attempts to call `setTimeout` when setting\n\t// up global mocks. Unfortunately, the runner Durable Object's IO context\n\t// isn't preserved through `import()` so this fails. To get around this, look\n\t// for the `setTimeout()` call and return a recognisable timeout value that's\n\t// still `number` typed\n\t// (https://github.com/sinonjs/fake-timers/blob/c85ef142837afdbc732b0f73fdba30c3bd037965/src/fake-timers-src.js#L154)\n\tif (callbackName === \"NOOP\") {\n\t\treturn -0.5;\n\t}\n\n\t// Make sure `setTimeout()`s from Vitest without delays are `waitUntil()`ed\n\t// if we're running within an `export default` handler. This ensures all\n\t// `console.log()`s are displayed, as Vitest uses `setTimeout()` for grouping.\n\tlet promiseResolve: (() => void) | undefined;\n\tconst promise = new Promise<void>((resolve) => {\n\t\tpromiseResolve = resolve;\n\t});\n\tassert(promiseResolve !== undefined);\n\tregisterHandlerAndGlobalWaitUntil(promise);\n\tconst id = originalSetTimeout.call(globalThis, () => {\n\t\tpromiseResolve?.();\n\t\tcallback?.(...restArgs);\n\t});\n\ttimeoutPromiseResolves.set(id, promiseResolve);\n\treturn id;\n};\n// @ts-expect-error __promisify__ types only required for Node.js\nglobalThis.setTimeout = monkeypatchedSetTimeout;\n// @ts-expect-error overload types not compatible\nglobalThis.clearTimeout = (...args: Parameters<typeof clearTimeout>) => {\n\tconst id = args[0];\n\tif (id === -0.5) {\n\t\treturn;\n\t}\n\n\t// Make sure we resolve any timeout promises we're clearing\n\t// (e.g. `console.log()`ing twice, the 2nd will clear the timeout set by the\n\t// first, but we'll still be `waitUntil()`ing on the original `Promise`)\n\tconst maybePromiseResolve = timeoutPromiseResolves.get(id);\n\ttimeoutPromiseResolves.delete(id);\n\tmaybePromiseResolve?.();\n\n\treturn originalClearTimeout.apply(globalThis, args);\n};\n\nfunction isDifferentIOContextError(e: unknown) {\n\treturn (\n\t\te instanceof Error &&\n\t\te.message.startsWith(\"Cannot perform I/O on behalf of a different\") // \"request\" or \"Durable Object\"\n\t);\n}\n\nlet patchedFunction = false;\nfunction ensurePatchedFunction(unsafeEval: UnsafeEval) {\n\tif (patchedFunction) {\n\t\treturn;\n\t}\n\tpatchedFunction = true;\n\t// `new Function()` is used by `@vitest/snapshot`\n\tglobalThis.Function = new Proxy(globalThis.Function, {\n\t\tconstruct(_target, args, _newTarget) {\n\t\t\t// `new Function()` and `UnsafeEval#newFunction()` have reversed args\n\t\t\tconst script = args.pop();\n\t\t\treturn unsafeEval.newFunction(script, \"anonymous\", ...args);\n\t\t},\n\t});\n}\n\nfunction applyDefines() {\n\t// Based off `/@vite/env` implementation:\n\t// https://github.com/vitejs/vite/blob/v5.1.4/packages/vite/src/client/env.ts\n\tfor (const [key, value] of Object.entries(defines)) {\n\t\tconst segments = key.split(\".\");\n\t\tlet target = globalThis as Record<string, unknown>;\n\t\tfor (let i = 0; i < segments.length; i++) {\n\t\t\tconst segment = segments[i];\n\t\t\tif (i === segments.length - 1) {\n\t\t\t\ttarget[segment] = value;\n\t\t\t} else {\n\t\t\t\ttarget = (target[segment] ??= {}) as Record<string, unknown>;\n\t\t\t}\n\t\t}\n\t}\n}\n\n// `__VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__` is a singleton\nexport class __VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__ extends DurableObject {\n\tconstructor(_state: DurableObjectState, doEnv: Cloudflare.Env) {\n\t\tsuper(_state, doEnv);\n\t\tvm._setUnsafeEval(doEnv.__VITEST_POOL_WORKERS_UNSAFE_EVAL);\n\t\tensurePatchedFunction(doEnv.__VITEST_POOL_WORKERS_UNSAFE_EVAL);\n\t\tapplyDefines();\n\t}\n\n\tasync handleVitestRunRequest(request: Request): Promise<Response> {\n\t\tassert.strictEqual(request.headers.get(\"Upgrade\"), \"websocket\");\n\t\tconst { 0: poolSocket, 1: poolResponseSocket } = new WebSocketPair();\n\n\t\tconst workerDataHeader = request.headers.get(\"MF-Vitest-Worker-Data\");\n\t\tassert(workerDataHeader);\n\n\t\tconst wd = structuredSerializableParse(workerDataHeader);\n\t\tassert(\n\t\t\twd && typeof wd === \"object\" && \"cwd\" in wd && typeof wd.cwd === \"string\"\n\t\t);\n\n\t\tcwd = wd.cwd;\n\n\t\tconst { init, runBaseTests, setupEnvironment } =\n\t\t\tawait import(\"vitest/worker\");\n\n\t\tpoolSocket.accept();\n\n\t\tinit({\n\t\t\tpost: (response) => {\n\t\t\t\ttry {\n\t\t\t\t\tpoolSocket.send(structuredSerializableStringify(response));\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// If the user called `console.log()` or similar from inside an\n\t\t\t\t\t// `export default { fetch() {} }` handler (via `SELF`/`exports`) or\n\t\t\t\t\t// from inside their own Durable Object, Vitest will try to send an\n\t\t\t\t\t// RPC message from a non-`RunnerObject` I/O context. We'd still like\n\t\t\t\t\t// to send the message, so if we detect a cross-DO I/O error we\n\t\t\t\t\t// resend from the runner object.\n\t\t\t\t\t// (Dynamic `import()` cross-DO errors are handled separately by the\n\t\t\t\t\t// onModuleRunner transport patch below — see #12924.)\n\t\t\t\t\tif (isDifferentIOContextError(error)) {\n\t\t\t\t\t\tconst promise = runInRunnerObject(() => {\n\t\t\t\t\t\t\tpoolSocket.send(structuredSerializableStringify(response));\n\t\t\t\t\t\t}).catch((e) => {\n\t\t\t\t\t\t\t__console.error(\n\t\t\t\t\t\t\t\t\"Error sending to pool inside runner:\",\n\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t\tresponse\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tregisterHandlerAndGlobalWaitUntil(promise);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t__console.error(\"Error sending to pool:\", error, response);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\ton: (callback) => {\n\t\t\t\tpoolSocket.addEventListener(\"message\", (m) => {\n\t\t\t\t\tcallback(structuredSerializableParse(m.data));\n\t\t\t\t});\n\t\t\t},\n\t\t\trunTests: (state, traces) => runBaseTests(\"run\", state, traces),\n\t\t\tcollectTests: (state, traces) => runBaseTests(\"collect\", state, traces),\n\t\t\tsetup: setupEnvironment,\n\t\t\t// Patch the module runner's transport so that `invoke()` calls always\n\t\t\t// execute inside the Runner DO's I/O context. Without this, a dynamic\n\t\t\t// `import()` inside an entrypoint handler (which runs in a *different*\n\t\t\t// DO context) fails with \"Cannot perform I/O on behalf of a different\n\t\t\t// Durable Object\". See: https://github.com/cloudflare/workers-sdk/issues/12924\n\t\t\tonModuleRunner(moduleRunner: unknown) {\n\t\t\t\tconst runner = moduleRunner as {\n\t\t\t\t\ttransport?: { invoke?: (...args: unknown[]) => unknown };\n\t\t\t\t};\n\t\t\t\tif (runner.transport?.invoke) {\n\t\t\t\t\tconst originalInvoke = runner.transport.invoke.bind(runner.transport);\n\t\t\t\t\trunner.transport.invoke = (...args: unknown[]) => {\n\t\t\t\t\t\treturn runInRunnerObject(() => originalInvoke(...args));\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\t__console.warn(\n\t\t\t\t\t\t\"[vitest-pool-workers] Could not patch module runner transport. \" +\n\t\t\t\t\t\t\t\"Dynamic import() inside entrypoint/DO handlers may fail.\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\treturn new Response(null, { status: 101, webSocket: poolResponseSocket });\n\t}\n\n\tasync fetch(request: Request): Promise<Response> {\n\t\tconst response = await maybeHandleRunRequest(request, this);\n\t\tif (response !== undefined) {\n\t\t\treturn response;\n\t\t}\n\n\t\treturn this.handleVitestRunRequest(request);\n\t}\n}\n\nexport default createWorkerEntrypointWrapper(\"default\");\n\n// Re-export user export wrappers\nexport * from \"__VITEST_POOL_WORKERS_USER_OBJECT\";\n"],"x_google_ignoreList":[0,1,2,3,4],"mappings":";;;;;;;;;;AAaA,IAAa,eAAb,cAAkC,MAAM;;;;;;;CAOvC,YAAY,SAAS,MAAM,OAAO,MAAM;AACvC,QAAM,QAAQ;AACd,OAAK,OAAO;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AAM,OAAO;AAEd,aAAW,QAAQ;AAEnB,OAAK;GACJ,OAAO,aAAa;AACnB,QAAI;AACH,gBAAW,KAAK,gCAAgC,SAAS,CAAC;aAClD,OAAO;AASf,SAAI,0BAA0B,MAAM,CAUnC,mCATgB,wBAAwB;AACvC,iBAAW,KAAK,gCAAgC,SAAS,CAAC;OACzD,CAAC,OAAO,MAAM;AACf,gBAAU,MACT,wCACA,GACA,SACA;OACA,CACwC;SAE1C,WAAU,MAAM,0BAA0B,OAAO,SAAS;;;GAI7D,KAAK,aAAa;AACjB,eAAW,iBAAiB,YAAY,MAAM;AAC7C,cAAS,4BAA4B,EAAE,KAAK,CAAC;MAC5C;;GAEH,WAAW,OAAO,WAAW,aAAa,OAAO,OAAO,OAAO;GAC/D,eAAe,OAAO,WAAW,aAAa,WAAW,OAAO,OAAO;GACvE,OAAO;GAMP,eAAe,cAAuB;IACrC,MAAM,SAAS;AAGf,QAAI,OAAO,WAAW,QAAQ;KAC7B,MAAM,iBAAiB,OAAO,UAAU,OAAO,KAAK,OAAO,UAAU;AACrE,YAAO,UAAU,UAAU,GAAG,SAAoB;AACjD,aAAO,wBAAwB,eAAe,GAAG,KAAK,CAAC;;UAGxD,WAAU,KACT,0HAEA;;GAGH,CAAC;AAEF,SAAO,IAAI,SAAS,MAAM;GAAE,QAAQ;GAAK,WAAW;GAAoB,CAAC;;CAG1E,MAAM,MAAM,SAAqC;EAChD,MAAM,WAAW,MAAM,sBAAsB,SAAS,KAAK;AAC3D,MAAI,aAAa,OAChB,QAAO;AAGR,SAAO,KAAK,uBAAuB,QAAQ;;;AAI7C,qBAAe,8BAA8B,UAAU"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["index","value","structuredSerializableReducers: ReducersRevivers","structuredSerializableRevivers: ReducersRevivers","devalue.stringify","devalue.parse","name: string","cwd: string | undefined","fileName: string | null","error: { stack?: string }","promiseResolve: (() => void) | undefined"],"sources":["../../../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/utils.js","../../../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/base64.js","../../../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/constants.js","../../../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/parse.js","../../../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/stringify.js","../../../miniflare/src/workers/core/devalue.ts","../../src/worker/index.ts"],"sourcesContent":["/** @type {Record<string, string>} */\nexport const escaped = {\n\t'<': '\\\\u003C',\n\t'\\\\': '\\\\\\\\',\n\t'\\b': '\\\\b',\n\t'\\f': '\\\\f',\n\t'\\n': '\\\\n',\n\t'\\r': '\\\\r',\n\t'\\t': '\\\\t',\n\t'\\u2028': '\\\\u2028',\n\t'\\u2029': '\\\\u2029'\n};\n\nexport class DevalueError extends Error {\n\t/**\n\t * @param {string} message\n\t * @param {string[]} keys\n\t * @param {any} [value] - The value that failed to be serialized\n\t * @param {any} [root] - The root value being serialized\n\t */\n\tconstructor(message, keys, value, root) {\n\t\tsuper(message);\n\t\tthis.name = 'DevalueError';\n\t\tthis.path = keys.join('');\n\t\tthis.value = value;\n\t\tthis.root = root;\n\t}\n}\n\n/** @param {any} thing */\nexport function is_primitive(thing) {\n\treturn Object(thing) !== thing;\n}\n\nconst object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(\n\tObject.prototype\n)\n\t.sort()\n\t.join('\\0');\n\n/** @param {any} thing */\nexport function is_plain_object(thing) {\n\tconst proto = Object.getPrototypeOf(thing);\n\n\treturn (\n\t\tproto === Object.prototype ||\n\t\tproto === null ||\n\t\tObject.getPrototypeOf(proto) === null ||\n\t\tObject.getOwnPropertyNames(proto).sort().join('\\0') === object_proto_names\n\t);\n}\n\n/** @param {any} thing */\nexport function get_type(thing) {\n\treturn Object.prototype.toString.call(thing).slice(8, -1);\n}\n\n/** @param {string} char */\nfunction get_escaped_char(char) {\n\tswitch (char) {\n\t\tcase '\"':\n\t\t\treturn '\\\\\"';\n\t\tcase '<':\n\t\t\treturn '\\\\u003C';\n\t\tcase '\\\\':\n\t\t\treturn '\\\\\\\\';\n\t\tcase '\\n':\n\t\t\treturn '\\\\n';\n\t\tcase '\\r':\n\t\t\treturn '\\\\r';\n\t\tcase '\\t':\n\t\t\treturn '\\\\t';\n\t\tcase '\\b':\n\t\t\treturn '\\\\b';\n\t\tcase '\\f':\n\t\t\treturn '\\\\f';\n\t\tcase '\\u2028':\n\t\t\treturn '\\\\u2028';\n\t\tcase '\\u2029':\n\t\t\treturn '\\\\u2029';\n\t\tdefault:\n\t\t\treturn char < ' '\n\t\t\t\t? `\\\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`\n\t\t\t\t: '';\n\t}\n}\n\n/** @param {string} str */\nexport function stringify_string(str) {\n\tlet result = '';\n\tlet last_pos = 0;\n\tconst len = str.length;\n\n\tfor (let i = 0; i < len; i += 1) {\n\t\tconst char = str[i];\n\t\tconst replacement = get_escaped_char(char);\n\t\tif (replacement) {\n\t\t\tresult += str.slice(last_pos, i) + replacement;\n\t\t\tlast_pos = i + 1;\n\t\t}\n\t}\n\n\treturn `\"${last_pos === 0 ? str : result + str.slice(last_pos)}\"`;\n}\n\n/** @param {Record<string | symbol, any>} object */\nexport function enumerable_symbols(object) {\n\treturn Object.getOwnPropertySymbols(object).filter(\n\t\t(symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable\n\t);\n}\n\nconst is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;\n\n/** @param {string} key */\nexport function stringify_key(key) {\n\treturn is_identifier.test(key) ? '.' + key : '[' + JSON.stringify(key) + ']';\n}\n\n/** @param {string} s */\nfunction is_valid_array_index(s) {\n\tif (s.length === 0) return false;\n\tif (s.length > 1 && s.charCodeAt(0) === 48) return false; // leading zero\n\tfor (let i = 0; i < s.length; i++) {\n\t\tconst c = s.charCodeAt(i);\n\t\tif (c < 48 || c > 57) return false;\n\t}\n\t// by this point we know it's a string of digits, but it has to be within the range of valid array indices\n\tconst n = +s;\n\tif (n >= 2 ** 32 - 1) return false;\n\tif (n < 0) return false;\n\treturn true;\n}\n\n/**\n * Finds the populated indices of an array.\n * @param {unknown[]} array\n */\nexport function valid_array_indices(array) {\n\tconst keys = Object.keys(array);\n\tfor (var i = keys.length - 1; i >= 0; i--) {\n\t\tif (is_valid_array_index(keys[i])) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tkeys.length = i + 1;\n\treturn keys;\n}\n","/**\n * Base64 Encodes an arraybuffer\n * @param {ArrayBuffer} arraybuffer\n * @returns {string}\n */\nexport function encode64(arraybuffer) {\n const dv = new DataView(arraybuffer);\n let binaryString = \"\";\n\n for (let i = 0; i < arraybuffer.byteLength; i++) {\n binaryString += String.fromCharCode(dv.getUint8(i));\n }\n\n return binaryToAscii(binaryString);\n}\n\n/**\n * Decodes a base64 string into an arraybuffer\n * @param {string} string\n * @returns {ArrayBuffer}\n */\nexport function decode64(string) {\n const binaryString = asciiToBinary(string);\n const arraybuffer = new ArrayBuffer(binaryString.length);\n const dv = new DataView(arraybuffer);\n\n for (let i = 0; i < arraybuffer.byteLength; i++) {\n dv.setUint8(i, binaryString.charCodeAt(i));\n }\n\n return arraybuffer;\n}\n\nconst KEY_STRING =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n/**\n * Substitute for atob since it's deprecated in node.\n * Does not do any input validation.\n *\n * @see https://github.com/jsdom/abab/blob/master/lib/atob.js\n *\n * @param {string} data\n * @returns {string}\n */\nfunction asciiToBinary(data) {\n if (data.length % 4 === 0) {\n data = data.replace(/==?$/, \"\");\n }\n\n let output = \"\";\n let buffer = 0;\n let accumulatedBits = 0;\n\n for (let i = 0; i < data.length; i++) {\n buffer <<= 6;\n buffer |= KEY_STRING.indexOf(data[i]);\n accumulatedBits += 6;\n if (accumulatedBits === 24) {\n output += String.fromCharCode((buffer & 0xff0000) >> 16);\n output += String.fromCharCode((buffer & 0xff00) >> 8);\n output += String.fromCharCode(buffer & 0xff);\n buffer = accumulatedBits = 0;\n }\n }\n if (accumulatedBits === 12) {\n buffer >>= 4;\n output += String.fromCharCode(buffer);\n } else if (accumulatedBits === 18) {\n buffer >>= 2;\n output += String.fromCharCode((buffer & 0xff00) >> 8);\n output += String.fromCharCode(buffer & 0xff);\n }\n return output;\n}\n\n/**\n * Substitute for btoa since it's deprecated in node.\n * Does not do any input validation.\n *\n * @see https://github.com/jsdom/abab/blob/master/lib/btoa.js\n *\n * @param {string} str\n * @returns {string}\n */\nfunction binaryToAscii(str) {\n let out = \"\";\n for (let i = 0; i < str.length; i += 3) {\n /** @type {[number, number, number, number]} */\n const groupsOfSix = [undefined, undefined, undefined, undefined];\n groupsOfSix[0] = str.charCodeAt(i) >> 2;\n groupsOfSix[1] = (str.charCodeAt(i) & 0x03) << 4;\n if (str.length > i + 1) {\n groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;\n groupsOfSix[2] = (str.charCodeAt(i + 1) & 0x0f) << 2;\n }\n if (str.length > i + 2) {\n groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;\n groupsOfSix[3] = str.charCodeAt(i + 2) & 0x3f;\n }\n for (let j = 0; j < groupsOfSix.length; j++) {\n if (typeof groupsOfSix[j] === \"undefined\") {\n out += \"=\";\n } else {\n out += KEY_STRING[groupsOfSix[j]];\n }\n }\n }\n return out;\n}\n","export const UNDEFINED = -1;\nexport const HOLE = -2;\nexport const NAN = -3;\nexport const POSITIVE_INFINITY = -4;\nexport const NEGATIVE_INFINITY = -5;\nexport const NEGATIVE_ZERO = -6;\nexport const SPARSE = -7;\n","import { decode64 } from './base64.js';\nimport {\n\tHOLE,\n\tNAN,\n\tNEGATIVE_INFINITY,\n\tNEGATIVE_ZERO,\n\tPOSITIVE_INFINITY,\n\tSPARSE,\n\tUNDEFINED\n} from './constants.js';\n\n/**\n * Revive a value serialized with `devalue.stringify`\n * @param {string} serialized\n * @param {Record<string, (value: any) => any>} [revivers]\n */\nexport function parse(serialized, revivers) {\n\treturn unflatten(JSON.parse(serialized), revivers);\n}\n\n/**\n * Revive a value flattened with `devalue.stringify`\n * @param {number | any[]} parsed\n * @param {Record<string, (value: any) => any>} [revivers]\n */\nexport function unflatten(parsed, revivers) {\n\tif (typeof parsed === 'number') return hydrate(parsed, true);\n\n\tif (!Array.isArray(parsed) || parsed.length === 0) {\n\t\tthrow new Error('Invalid input');\n\t}\n\n\tconst values = /** @type {any[]} */ (parsed);\n\n\tconst hydrated = Array(values.length);\n\n\t/**\n\t * A set of values currently being hydrated with custom revivers,\n\t * used to detect invalid cyclical dependencies\n\t * @type {Set<number> | null}\n\t */\n\tlet hydrating = null;\n\n\t/**\n\t * @param {number} index\n\t * @returns {any}\n\t */\n\tfunction hydrate(index, standalone = false) {\n\t\tif (index === UNDEFINED) return undefined;\n\t\tif (index === NAN) return NaN;\n\t\tif (index === POSITIVE_INFINITY) return Infinity;\n\t\tif (index === NEGATIVE_INFINITY) return -Infinity;\n\t\tif (index === NEGATIVE_ZERO) return -0;\n\n\t\tif (standalone || typeof index !== 'number') {\n\t\t\tthrow new Error(`Invalid input`);\n\t\t}\n\n\t\tif (index in hydrated) return hydrated[index];\n\n\t\tconst value = values[index];\n\n\t\tif (!value || typeof value !== 'object') {\n\t\t\thydrated[index] = value;\n\t\t} else if (Array.isArray(value)) {\n\t\t\tif (typeof value[0] === 'string') {\n\t\t\t\tconst type = value[0];\n\n\t\t\t\tconst reviver =\n\t\t\t\t\trevivers && Object.hasOwn(revivers, type)\n\t\t\t\t\t\t? revivers[type]\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\tif (reviver) {\n\t\t\t\t\tlet i = value[1];\n\t\t\t\t\tif (typeof i !== 'number') {\n\t\t\t\t\t\t// if it's not a number, it was serialized by a builtin reviver\n\t\t\t\t\t\t// so we need to munge it into the format expected by a custom reviver\n\t\t\t\t\t\ti = values.push(value[1]) - 1;\n\t\t\t\t\t}\n\n\t\t\t\t\thydrating ??= new Set();\n\n\t\t\t\t\tif (hydrating.has(i)) {\n\t\t\t\t\t\tthrow new Error('Invalid circular reference');\n\t\t\t\t\t}\n\n\t\t\t\t\thydrating.add(i);\n\t\t\t\t\thydrated[index] = reviver(hydrate(i));\n\t\t\t\t\thydrating.delete(i);\n\n\t\t\t\t\treturn hydrated[index];\n\t\t\t\t}\n\n\t\t\t\tswitch (type) {\n\t\t\t\t\tcase 'Date':\n\t\t\t\t\t\thydrated[index] = new Date(value[1]);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'Set':\n\t\t\t\t\t\tconst set = new Set();\n\t\t\t\t\t\thydrated[index] = set;\n\t\t\t\t\t\tfor (let i = 1; i < value.length; i += 1) {\n\t\t\t\t\t\t\tset.add(hydrate(value[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'Map':\n\t\t\t\t\t\tconst map = new Map();\n\t\t\t\t\t\thydrated[index] = map;\n\t\t\t\t\t\tfor (let i = 1; i < value.length; i += 2) {\n\t\t\t\t\t\t\tmap.set(hydrate(value[i]), hydrate(value[i + 1]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'RegExp':\n\t\t\t\t\t\thydrated[index] = new RegExp(value[1], value[2]);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'Object':\n\t\t\t\t\t\thydrated[index] = Object(value[1]);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'BigInt':\n\t\t\t\t\t\thydrated[index] = BigInt(value[1]);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'null':\n\t\t\t\t\t\tconst obj = Object.create(null);\n\t\t\t\t\t\thydrated[index] = obj;\n\t\t\t\t\t\tfor (let i = 1; i < value.length; i += 2) {\n\t\t\t\t\t\t\tobj[value[i]] = hydrate(value[i + 1]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'Int8Array':\n\t\t\t\t\tcase 'Uint8Array':\n\t\t\t\t\tcase 'Uint8ClampedArray':\n\t\t\t\t\tcase 'Int16Array':\n\t\t\t\t\tcase 'Uint16Array':\n\t\t\t\t\tcase 'Int32Array':\n\t\t\t\t\tcase 'Uint32Array':\n\t\t\t\t\tcase 'Float32Array':\n\t\t\t\t\tcase 'Float64Array':\n\t\t\t\t\tcase 'BigInt64Array':\n\t\t\t\t\tcase 'BigUint64Array': {\n\t\t\t\t\t\tif (values[value[1]][0] !== 'ArrayBuffer') {\n\t\t\t\t\t\t\t// without this, if we receive malformed input we could\n\t\t\t\t\t\t\t// end up trying to hydrate in a circle or allocate\n\t\t\t\t\t\t\t// huge amounts of memory when we call `new TypedArrayConstructor(buffer)`\n\t\t\t\t\t\t\tthrow new Error('Invalid data');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst TypedArrayConstructor = globalThis[type];\n\t\t\t\t\t\tconst buffer = hydrate(value[1]);\n\t\t\t\t\t\tconst typedArray = new TypedArrayConstructor(buffer);\n\n\t\t\t\t\t\thydrated[index] =\n\t\t\t\t\t\t\tvalue[2] !== undefined\n\t\t\t\t\t\t\t\t? typedArray.subarray(value[2], value[3])\n\t\t\t\t\t\t\t\t: typedArray;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'ArrayBuffer': {\n\t\t\t\t\t\tconst base64 = value[1];\n\t\t\t\t\t\tif (typeof base64 !== 'string') {\n\t\t\t\t\t\t\tthrow new Error('Invalid ArrayBuffer encoding');\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst arraybuffer = decode64(base64);\n\t\t\t\t\t\thydrated[index] = arraybuffer;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'Temporal.Duration':\n\t\t\t\t\tcase 'Temporal.Instant':\n\t\t\t\t\tcase 'Temporal.PlainDate':\n\t\t\t\t\tcase 'Temporal.PlainTime':\n\t\t\t\t\tcase 'Temporal.PlainDateTime':\n\t\t\t\t\tcase 'Temporal.PlainMonthDay':\n\t\t\t\t\tcase 'Temporal.PlainYearMonth':\n\t\t\t\t\tcase 'Temporal.ZonedDateTime': {\n\t\t\t\t\t\tconst temporalName = type.slice(9);\n\t\t\t\t\t\t// @ts-expect-error TS doesn't know about Temporal yet\n\t\t\t\t\t\thydrated[index] = Temporal[temporalName].from(value[1]);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'URL': {\n\t\t\t\t\t\tconst url = new URL(value[1]);\n\t\t\t\t\t\thydrated[index] = url;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'URLSearchParams': {\n\t\t\t\t\t\tconst url = new URLSearchParams(value[1]);\n\t\t\t\t\t\thydrated[index] = url;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(`Unknown type ${type}`);\n\t\t\t\t}\n\t\t\t} else if (value[0] === SPARSE) {\n\t\t\t\t// Sparse array encoding: [SPARSE, length, idx, val, idx, val, ...]\n\t\t\t\tconst len = value[1];\n\n\t\t\t\tconst array = new Array(len);\n\t\t\t\thydrated[index] = array;\n\n\t\t\t\tfor (let i = 2; i < value.length; i += 2) {\n\t\t\t\t\tconst idx = value[i];\n\t\t\t\t\tarray[idx] = hydrate(value[i + 1]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst array = new Array(value.length);\n\t\t\t\thydrated[index] = array;\n\n\t\t\t\tfor (let i = 0; i < value.length; i += 1) {\n\t\t\t\t\tconst n = value[i];\n\t\t\t\t\tif (n === HOLE) continue;\n\n\t\t\t\t\tarray[i] = hydrate(n);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t/** @type {Record<string, any>} */\n\t\t\tconst object = {};\n\t\t\thydrated[index] = object;\n\n\t\t\tfor (const key of Object.keys(value)) {\n\t\t\t\tif (key === '__proto__') {\n\t\t\t\t\tthrow new Error('Cannot parse an object with a `__proto__` property');\n\t\t\t\t}\n\n\t\t\t\tconst n = value[key];\n\t\t\t\tobject[key] = hydrate(n);\n\t\t\t}\n\t\t}\n\n\t\treturn hydrated[index];\n\t}\n\n\treturn hydrate(0);\n}\n","import {\n\tDevalueError,\n\tenumerable_symbols,\n\tget_type,\n\tis_plain_object,\n\tis_primitive,\n\tstringify_key,\n\tstringify_string,\n\tvalid_array_indices\n} from './utils.js';\nimport {\n\tHOLE,\n\tNAN,\n\tNEGATIVE_INFINITY,\n\tNEGATIVE_ZERO,\n\tPOSITIVE_INFINITY,\n\tSPARSE,\n\tUNDEFINED\n} from './constants.js';\nimport { encode64 } from './base64.js';\n\n/**\n * Turn a value into a JSON string that can be parsed with `devalue.parse`\n * @param {any} value\n * @param {Record<string, (value: any) => any>} [reducers]\n */\nexport function stringify(value, reducers) {\n\t/** @type {any[]} */\n\tconst stringified = [];\n\n\t/** @type {Map<any, number>} */\n\tconst indexes = new Map();\n\n\t/** @type {Array<{ key: string, fn: (value: any) => any }>} */\n\tconst custom = [];\n\tif (reducers) {\n\t\tfor (const key of Object.getOwnPropertyNames(reducers)) {\n\t\t\tcustom.push({ key, fn: reducers[key] });\n\t\t}\n\t}\n\n\t/** @type {string[]} */\n\tconst keys = [];\n\n\tlet p = 0;\n\n\t/** @param {any} thing */\n\tfunction flatten(thing) {\n\t\tif (thing === undefined) return UNDEFINED;\n\t\tif (Number.isNaN(thing)) return NAN;\n\t\tif (thing === Infinity) return POSITIVE_INFINITY;\n\t\tif (thing === -Infinity) return NEGATIVE_INFINITY;\n\t\tif (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;\n\n\t\tif (indexes.has(thing)) return indexes.get(thing);\n\n\t\tconst index = p++;\n\t\tindexes.set(thing, index);\n\n\t\tfor (const { key, fn } of custom) {\n\t\t\tconst value = fn(thing);\n\t\t\tif (value) {\n\t\t\t\tstringified[index] = `[\"${key}\",${flatten(value)}]`;\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\n\t\tif (typeof thing === 'function') {\n\t\t\tthrow new DevalueError(`Cannot stringify a function`, keys, thing, value);\n\t\t}\n\n\t\tlet str = '';\n\n\t\tif (is_primitive(thing)) {\n\t\t\tstr = stringify_primitive(thing);\n\t\t} else {\n\t\t\tconst type = get_type(thing);\n\n\t\t\tswitch (type) {\n\t\t\t\tcase 'Number':\n\t\t\t\tcase 'String':\n\t\t\t\tcase 'Boolean':\n\t\t\t\t\tstr = `[\"Object\",${stringify_primitive(thing)}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'BigInt':\n\t\t\t\t\tstr = `[\"BigInt\",${thing}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Date':\n\t\t\t\t\tconst valid = !isNaN(thing.getDate());\n\t\t\t\t\tstr = `[\"Date\",\"${valid ? thing.toISOString() : ''}\"]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'URL':\n\t\t\t\t\tstr = `[\"URL\",${stringify_string(thing.toString())}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'URLSearchParams':\n\t\t\t\t\tstr = `[\"URLSearchParams\",${stringify_string(thing.toString())}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'RegExp':\n\t\t\t\t\tconst { source, flags } = thing;\n\t\t\t\t\tstr = flags\n\t\t\t\t\t\t? `[\"RegExp\",${stringify_string(source)},\"${flags}\"]`\n\t\t\t\t\t\t: `[\"RegExp\",${stringify_string(source)}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Array': {\n\t\t\t\t\t// For dense arrays (no holes), we iterate normally.\n\t\t\t\t\t// When we encounter the first hole, we call Object.keys\n\t\t\t\t\t// to determine the sparseness, then decide between:\n\t\t\t\t\t// - HOLE encoding: [-2, val, -2, ...] (default)\n\t\t\t\t\t// - Sparse encoding: [-7, length, idx, val, ...] (for very sparse arrays)\n\t\t\t\t\t// Only the sparse path avoids iterating every slot, which\n\t\t\t\t\t// is what protects against the DoS of e.g. `arr[1000000] = 1`.\n\t\t\t\t\tlet mostly_dense = false;\n\n\t\t\t\t\tstr = '[';\n\n\t\t\t\t\tfor (let i = 0; i < thing.length; i += 1) {\n\t\t\t\t\t\tif (i > 0) str += ',';\n\n\t\t\t\t\t\tif (Object.hasOwn(thing, i)) {\n\t\t\t\t\t\t\tkeys.push(`[${i}]`);\n\t\t\t\t\t\t\tstr += flatten(thing[i]);\n\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t} else if (mostly_dense) {\n\t\t\t\t\t\t\t// Use dense encoding. The heuristic guarantees the\n\t\t\t\t\t\t\t// array is only mildly sparse, so iterating over every\n\t\t\t\t\t\t\t// slot is fine.\n\t\t\t\t\t\t\tstr += HOLE;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Decide between HOLE encoding and sparse encoding.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// HOLE encoding: each hole is serialized as the HOLE\n\t\t\t\t\t\t\t// sentinel (-2). For example, [, \"a\", ,] becomes\n\t\t\t\t\t\t\t// [-2, 0, -2]. Each hole costs 3 chars (\"-2\" + comma).\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Sparse encoding: lists only populated indices.\n\t\t\t\t\t\t\t// For example, [, \"a\", ,] becomes [-7, 3, 1, 0] — the\n\t\t\t\t\t\t\t// -7 sentinel, the array length (3), then index-value\n\t\t\t\t\t\t\t// pairs. This avoids paying per-hole, but each element\n\t\t\t\t\t\t\t// costs extra chars to write its index.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// The values are the same size either way, so the\n\t\t\t\t\t\t\t// choice comes down to structural overhead:\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// HOLE overhead:\n\t\t\t\t\t\t\t// 3 chars per hole (\"-2\" + comma)\n\t\t\t\t\t\t\t// = (L - P) * 3\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Sparse overhead:\n\t\t\t\t\t\t\t// \"-7,\" — 3 chars (sparse sentinel + comma)\n\t\t\t\t\t\t\t// + length + \",\" — (d + 1) chars (array length + comma)\n\t\t\t\t\t\t\t// + per element: index + \",\" — (d + 1) chars\n\t\t\t\t\t\t\t// = (4 + d) + P * (d + 1)\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// where L is the array length, P is the number of\n\t\t\t\t\t\t\t// populated elements, and d is the number of digits\n\t\t\t\t\t\t\t// in L (an upper bound on the digits in any index).\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Sparse encoding is cheaper when:\n\t\t\t\t\t\t\t// (4 + d) + P * (d + 1) < (L - P) * 3\n\t\t\t\t\t\t\tconst populated_keys = valid_array_indices(/** @type {any[]} */ (thing));\n\t\t\t\t\t\t\tconst population = populated_keys.length;\n\t\t\t\t\t\t\tconst d = String(thing.length).length;\n\n\t\t\t\t\t\t\tconst hole_cost = (thing.length - population) * 3;\n\t\t\t\t\t\t\tconst sparse_cost = 4 + d + population * (d + 1);\n\n\t\t\t\t\t\t\tif (hole_cost > sparse_cost) {\n\t\t\t\t\t\t\t\tstr = '[' + SPARSE + ',' + thing.length;\n\t\t\t\t\t\t\t\tfor (let j = 0; j < populated_keys.length; j++) {\n\t\t\t\t\t\t\t\t\tconst key = populated_keys[j];\n\t\t\t\t\t\t\t\t\tkeys.push(`[${key}]`);\n\t\t\t\t\t\t\t\t\tstr += ',' + key + ',' + flatten(thing[key]);\n\t\t\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmostly_dense = true;\n\t\t\t\t\t\t\t\tstr += HOLE;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'Set':\n\t\t\t\t\tstr = '[\"Set\"';\n\n\t\t\t\t\tfor (const value of thing) {\n\t\t\t\t\t\tstr += `,${flatten(value)}`;\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Map':\n\t\t\t\t\tstr = '[\"Map\"';\n\n\t\t\t\t\tfor (const [key, value] of thing) {\n\t\t\t\t\t\tkeys.push(\n\t\t\t\t\t\t\t`.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstr += `,${flatten(key)},${flatten(value)}`;\n\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Int8Array':\n\t\t\t\tcase 'Uint8Array':\n\t\t\t\tcase 'Uint8ClampedArray':\n\t\t\t\tcase 'Int16Array':\n\t\t\t\tcase 'Uint16Array':\n\t\t\t\tcase 'Int32Array':\n\t\t\t\tcase 'Uint32Array':\n\t\t\t\tcase 'Float32Array':\n\t\t\t\tcase 'Float64Array':\n\t\t\t\tcase 'BigInt64Array':\n\t\t\t\tcase 'BigUint64Array': {\n\t\t\t\t\t/** @type {import(\"./types.js\").TypedArray} */\n\t\t\t\t\tconst typedArray = thing;\n\t\t\t\t\tstr = '[\"' + type + '\",' + flatten(typedArray.buffer);\n\n\t\t\t\t\tconst a = thing.byteOffset;\n\t\t\t\t\tconst b = a + thing.byteLength;\n\n\t\t\t\t\t// handle subarrays\n\t\t\t\t\tif (a > 0 || b !== typedArray.buffer.byteLength) {\n\t\t\t\t\t\tconst m = +/(\\d+)/.exec(type)[1] / 8;\n\t\t\t\t\t\tstr += `,${a / m},${b / m}`;\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'ArrayBuffer': {\n\t\t\t\t\t/** @type {ArrayBuffer} */\n\t\t\t\t\tconst arraybuffer = thing;\n\t\t\t\t\tconst base64 = encode64(arraybuffer);\n\n\t\t\t\t\tstr = `[\"ArrayBuffer\",\"${base64}\"]`;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'Temporal.Duration':\n\t\t\t\tcase 'Temporal.Instant':\n\t\t\t\tcase 'Temporal.PlainDate':\n\t\t\t\tcase 'Temporal.PlainTime':\n\t\t\t\tcase 'Temporal.PlainDateTime':\n\t\t\t\tcase 'Temporal.PlainMonthDay':\n\t\t\t\tcase 'Temporal.PlainYearMonth':\n\t\t\t\tcase 'Temporal.ZonedDateTime':\n\t\t\t\t\tstr = `[\"${type}\",${stringify_string(thing.toString())}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tif (!is_plain_object(thing)) {\n\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t`Cannot stringify arbitrary non-POJOs`,\n\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (enumerable_symbols(thing).length > 0) {\n\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t`Cannot stringify POJOs with symbolic keys`,\n\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (Object.getPrototypeOf(thing) === null) {\n\t\t\t\t\t\tstr = '[\"null\"';\n\t\t\t\t\t\tfor (const key of Object.keys(thing)) {\n\t\t\t\t\t\t\tif (key === '__proto__') {\n\t\t\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t\t\t`Cannot stringify objects with __proto__ keys`,\n\t\t\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tkeys.push(stringify_key(key));\n\t\t\t\t\t\t\tstr += `,${stringify_string(key)},${flatten(thing[key])}`;\n\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstr += ']';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstr = '{';\n\t\t\t\t\t\tlet started = false;\n\t\t\t\t\t\tfor (const key of Object.keys(thing)) {\n\t\t\t\t\t\t\tif (key === '__proto__') {\n\t\t\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t\t\t`Cannot stringify objects with __proto__ keys`,\n\t\t\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (started) str += ',';\n\t\t\t\t\t\t\tstarted = true;\n\t\t\t\t\t\t\tkeys.push(stringify_key(key));\n\t\t\t\t\t\t\tstr += `${stringify_string(key)}:${flatten(thing[key])}`;\n\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstr += '}';\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tstringified[index] = str;\n\t\treturn index;\n\t}\n\n\tconst index = flatten(value);\n\n\t// special case — value is represented as a negative index\n\tif (index < 0) return `${index}`;\n\n\treturn `[${stringified.join(',')}]`;\n}\n\n/**\n * @param {any} thing\n * @returns {string}\n */\nfunction stringify_primitive(thing) {\n\tconst type = typeof thing;\n\tif (type === 'string') return stringify_string(thing);\n\tif (thing instanceof String) return stringify_string(thing.toString());\n\tif (thing === void 0) return UNDEFINED.toString();\n\tif (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();\n\tif (type === 'bigint') return `[\"BigInt\",\"${thing}\"]`;\n\treturn String(thing);\n}\n","import assert from \"node:assert\";\nimport { Buffer } from \"node:buffer\";\nimport { parse, stringify } from \"devalue\";\nimport type {\n\tBlob as WorkerBlob,\n\tBlobOptions as WorkerBlobOptions,\n\tFile as WorkerFile,\n\tFileOptions as WorkerFileOptions,\n\tHeaders as WorkerHeaders,\n\tReadableStream as WorkerReadableStream,\n\tRequest as WorkerRequest,\n\tResponse as WorkerResponse,\n} from \"@cloudflare/workers-types/experimental\";\n\n// This file implements `devalue` reducers and revivers for structured-\n// serialisable types not supported by default. See serialisable types here:\n// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types\n\nexport type ReducerReviver = (value: unknown) => unknown;\nexport type ReducersRevivers = Record<string, ReducerReviver>;\n\nconst ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS = [\n\tDataView<ArrayBuffer>,\n\tInt8Array,\n\tUint8Array,\n\tUint8ClampedArray,\n\tInt16Array,\n\tUint16Array,\n\tInt32Array,\n\tUint32Array,\n\tFloat32Array,\n\tFloat64Array,\n\tBigInt64Array,\n\tBigUint64Array,\n] as const;\nconst ALLOWED_ERROR_CONSTRUCTORS = [\n\tEvalError,\n\tRangeError,\n\tReferenceError,\n\tSyntaxError,\n\tTypeError,\n\tURIError,\n\tError, // `Error` last so more specific error subclasses preferred\n] as const;\n\nexport const structuredSerializableReducers: ReducersRevivers = {\n\tArrayBuffer(value) {\n\t\tif (value instanceof ArrayBuffer) {\n\t\t\t// Return single element array so empty `ArrayBuffer` serialised as truthy\n\t\t\treturn [Buffer.from(value).toString(\"base64\")];\n\t\t}\n\t},\n\tArrayBufferView(value) {\n\t\tif (ArrayBuffer.isView(value)) {\n\t\t\tlet name = value.constructor.name;\n\t\t\t// Subclasses like Node.js `Buffer` extend standard typed arrays but\n\t\t\t// aren't available in all runtimes. Normalise to the parent constructor.\n\t\t\tif (\n\t\t\t\t!ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS.some((c) => c.name === name)\n\t\t\t) {\n\t\t\t\tfor (const ctor of ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS) {\n\t\t\t\t\tif (value instanceof ctor) {\n\t\t\t\t\t\tname = ctor.name;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet buf = value.buffer;\n\t\t\tlet off = value.byteOffset;\n\t\t\tif (off !== 0 || buf.byteLength !== value.byteLength) {\n\t\t\t\tbuf = buf.slice(off, off + value.byteLength);\n\t\t\t\toff = 0;\n\t\t\t}\n\t\t\treturn [name, buf, off, value.byteLength];\n\t\t}\n\t},\n\tRegExp(value) {\n\t\tif (value instanceof RegExp) {\n\t\t\tconst { source, flags } = value;\n\t\t\tconst encoded = Buffer.from(source).toString(\"base64\");\n\t\t\treturn flags ? [\"RegExp\", encoded, flags] : [\"RegExp\", encoded];\n\t\t}\n\t},\n\tError(value) {\n\t\tfor (const ctor of ALLOWED_ERROR_CONSTRUCTORS) {\n\t\t\tif (value instanceof ctor && value.name === ctor.name) {\n\t\t\t\treturn [value.name, value.message, value.stack, value.cause];\n\t\t\t}\n\t\t}\n\t\tif (value instanceof Error) {\n\t\t\treturn [\"Error\", value.message, value.stack, value.cause];\n\t\t}\n\t},\n};\nexport const structuredSerializableRevivers: ReducersRevivers = {\n\tArrayBuffer(value) {\n\t\tassert(Array.isArray(value));\n\t\tconst [encoded] = value as unknown[];\n\t\tassert(typeof encoded === \"string\");\n\t\tconst view = Buffer.from(encoded, \"base64\");\n\t\treturn view.buffer.slice(\n\t\t\tview.byteOffset,\n\t\t\tview.byteOffset + view.byteLength\n\t\t);\n\t},\n\tArrayBufferView(value) {\n\t\tassert(Array.isArray(value));\n\t\tconst [name, buffer, byteOffset, byteLength] = value as unknown[];\n\t\tassert(typeof name === \"string\");\n\t\tassert(buffer instanceof ArrayBuffer);\n\t\tassert(typeof byteOffset === \"number\");\n\t\tassert(typeof byteLength === \"number\");\n\t\tconst ctor = (globalThis as Record<string, unknown>)[\n\t\t\tname\n\t\t] as (typeof ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS)[number];\n\t\tassert(ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS.includes(ctor));\n\t\tlet length = byteLength;\n\t\tif (\"BYTES_PER_ELEMENT\" in ctor) length /= ctor.BYTES_PER_ELEMENT;\n\t\treturn new ctor(buffer as ArrayBuffer, byteOffset, length);\n\t},\n\tRegExp(value) {\n\t\tassert(Array.isArray(value));\n\t\tconst [name, encoded, flags] = value;\n\t\tassert(typeof name === \"string\");\n\t\tassert(typeof encoded === \"string\");\n\t\tconst source = Buffer.from(encoded, \"base64\").toString(\"utf-8\");\n\t\treturn new RegExp(source, flags);\n\t},\n\tError(value) {\n\t\tassert(Array.isArray(value));\n\t\tconst [name, message, stack, cause] = value as unknown[];\n\t\tassert(typeof name === \"string\");\n\t\tassert(typeof message === \"string\");\n\t\tassert(stack === undefined || typeof stack === \"string\");\n\t\tconst ctor = (globalThis as Record<string, unknown>)[\n\t\t\tname\n\t\t] as (typeof ALLOWED_ERROR_CONSTRUCTORS)[number];\n\t\tassert(ALLOWED_ERROR_CONSTRUCTORS.includes(ctor));\n\t\tconst error = new ctor(message, { cause });\n\t\terror.stack = stack;\n\t\treturn error;\n\t},\n};\n\n// This file gets imported both by Node and workers. These platforms have\n// different ways of accessing/performing operations required by this code.\n// This interface should be implemented by both platforms to provide this\n// functionality. `RS` is the type of `ReadableStream`.\nexport interface PlatformImpl<RS> {\n\tBlob: typeof WorkerBlob;\n\tFile: typeof WorkerFile;\n\tHeaders: typeof WorkerHeaders;\n\tRequest: typeof WorkerRequest;\n\tResponse: typeof WorkerResponse;\n\n\tisReadableStream(value: unknown): value is RS;\n\tbufferReadableStream(stream: RS): Promise<ArrayBuffer>;\n\tunbufferReadableStream(buffer: ArrayBuffer): RS;\n}\n\nexport function createHTTPReducers(\n\timpl: PlatformImpl<unknown>\n): ReducersRevivers {\n\treturn {\n\t\tHeaders(val) {\n\t\t\tif (val instanceof impl.Headers) return [...val.entries()];\n\t\t},\n\t\tRequest(val) {\n\t\t\tif (val instanceof impl.Request) {\n\t\t\t\treturn [val.method, val.url, val.headers, val.cf, val.body];\n\t\t\t}\n\t\t},\n\t\tResponse(val) {\n\t\t\tif (val instanceof impl.Response) {\n\t\t\t\treturn [val.status, val.statusText, val.headers, val.cf, val.body];\n\t\t\t}\n\t\t},\n\t};\n}\nexport function createHTTPRevivers<RS>(\n\timpl: PlatformImpl<RS>\n): ReducersRevivers {\n\treturn {\n\t\tHeaders(value) {\n\t\t\tassert(typeof value === \"object\" && value !== null);\n\t\t\treturn new impl.Headers(value as string[][]);\n\t\t},\n\t\tRequest(value) {\n\t\t\tassert(Array.isArray(value));\n\t\t\tconst [method, url, headers, cf, body] = value as unknown[];\n\t\t\tassert(typeof method === \"string\");\n\t\t\tassert(typeof url === \"string\");\n\t\t\tassert(headers instanceof impl.Headers);\n\t\t\tassert(body === null || impl.isReadableStream(body));\n\t\t\treturn new impl.Request(url, {\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\tcf,\n\t\t\t\t// @ts-expect-error `duplex` is not required by `workerd` yet\n\t\t\t\tduplex: body === null ? undefined : \"half\",\n\t\t\t\tbody: body as WorkerReadableStream | null,\n\t\t\t});\n\t\t},\n\t\tResponse(value) {\n\t\t\tassert(Array.isArray(value));\n\t\t\tconst [status, statusText, headers, cf, body] = value as unknown[];\n\t\t\tassert(typeof status === \"number\");\n\t\t\tassert(typeof statusText === \"string\");\n\t\t\tassert(headers instanceof impl.Headers);\n\t\t\tassert(body === null || impl.isReadableStream(body));\n\t\t\treturn new impl.Response(body as WorkerReadableStream | null, {\n\t\t\t\tstatus,\n\t\t\t\tstatusText,\n\t\t\t\theaders,\n\t\t\t\tcf,\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport interface StringifiedWithStream<RS> {\n\tvalue: string;\n\tunbufferedStream?: RS;\n}\n// `devalue` `stringify()` that allows a single stream to be \"unbuffered\", and\n// sent separately. Other streams will be buffered.\nexport function stringifyWithStreams<RS>(\n\timpl: PlatformImpl<RS>,\n\tvalue: unknown,\n\treducers: ReducersRevivers,\n\tallowUnbufferedStream: boolean\n): StringifiedWithStream<RS> | Promise<StringifiedWithStream<RS>> {\n\tlet unbufferedStream: RS | undefined;\n\t// The tricky thing here is that `devalue` `stringify()` is synchronous, and\n\t// doesn't support asynchronous reducers. Assuming we visit values in the same\n\t// order each time, we can use an array to store buffer promises.\n\tconst bufferPromises: Promise<ArrayBuffer>[] = [];\n\tconst streamReducers: ReducersRevivers = {\n\t\tReadableStream(value) {\n\t\t\tif (impl.isReadableStream(value)) {\n\t\t\t\tif (allowUnbufferedStream && unbufferedStream === undefined) {\n\t\t\t\t\tunbufferedStream = value;\n\t\t\t\t} else {\n\t\t\t\t\tbufferPromises.push(impl.bufferReadableStream(value));\n\t\t\t\t}\n\t\t\t\t// Using `true` to signify unbuffered stream, buffered streams will\n\t\t\t\t// have this replaced with an `ArrayBuffer` on the 2nd `stringify()`\n\t\t\t\t// If we don't have any buffer promises, this will encode to the correct\n\t\t\t\t// value, so we don't need to re-`stringify()`.\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\tBlob(value) {\n\t\t\tif (value instanceof impl.Blob) {\n\t\t\t\t// `Blob`s are always buffered. We can't just serialise with a stream\n\t\t\t\t// here (and recursively use the reducer above), because `workerd`\n\t\t\t\t// doesn't allow us to synchronously reconstruct a `Blob` from a stream:\n\t\t\t\t// its `new Blob([...])` doesn't support `ReadableStream` blob bits.\n\t\t\t\tbufferPromises.push(value.arrayBuffer());\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\n\t\t...reducers,\n\t};\n\tif (typeof value === \"function\") {\n\t\tvalue = new __MiniflareFunctionWrapper(\n\t\t\tvalue as ConstructorParameters<typeof __MiniflareFunctionWrapper>[0]\n\t\t);\n\t}\n\tconst stringifiedValue = stringify(value, streamReducers);\n\t// If we didn't need to buffer anything, we've just encoded correctly. Note\n\t// `unbufferedStream` may be undefined if the `value` didn't contain streams.\n\t// Note also in this case we're returning synchronously, so we can use this\n\t// for synchronous methods too.\n\tif (bufferPromises.length === 0) {\n\t\treturn { value: stringifiedValue, unbufferedStream };\n\t}\n\n\t// Otherwise, wait for buffering to complete, and `stringify()` again with\n\t// a reducer that expects buffers.\n\treturn Promise.all(bufferPromises).then((streamBuffers) => {\n\t\t// Again, we're assuming values are visited in the same order, so `shift()`\n\t\t// will give us the next correct buffer\n\t\tstreamReducers.ReadableStream = function (value) {\n\t\t\tif (impl.isReadableStream(value)) {\n\t\t\t\tif (value === unbufferedStream) {\n\t\t\t\t\treturn true;\n\t\t\t\t} else {\n\t\t\t\t\treturn streamBuffers.shift();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tstreamReducers.Blob = function (value) {\n\t\t\tif (value instanceof impl.Blob) {\n\t\t\t\tconst array: unknown[] = [streamBuffers.shift(), value.type];\n\t\t\t\tif (value instanceof impl.File) {\n\t\t\t\t\tarray.push(value.name, value.lastModified);\n\t\t\t\t}\n\t\t\t\treturn array;\n\t\t\t}\n\t\t};\n\t\tconst stringifiedValue = stringify(value, streamReducers);\n\t\treturn { value: stringifiedValue, unbufferedStream };\n\t});\n}\n\n// functions can't be stringified, so we wrap them into a class that we then use to pseudo-serialize them\n// we also add a proxy and make sure that properties set on the function object are accessible\n// (this is in particular necessary for RpcStubs)\nexport class __MiniflareFunctionWrapper {\n\tconstructor(\n\t\tfnWithProps: ((...args: unknown[]) => unknown) & {\n\t\t\t[key: string | symbol]: unknown;\n\t\t}\n\t) {\n\t\treturn new Proxy(this, {\n\t\t\tget: (_, key) => {\n\t\t\t\tif (key === \"__miniflareWrappedFunction\") return fnWithProps;\n\t\t\t\treturn fnWithProps[key];\n\t\t\t},\n\t\t});\n\t}\n}\n\nexport function parseWithReadableStreams<RS>(\n\timpl: PlatformImpl<RS>,\n\tstringified: StringifiedWithStream<RS>,\n\trevivers: ReducersRevivers\n): unknown {\n\tconst streamRevivers: ReducersRevivers = {\n\t\tReadableStream(value) {\n\t\t\tif (value === true) {\n\t\t\t\tassert(stringified.unbufferedStream !== undefined);\n\t\t\t\treturn stringified.unbufferedStream;\n\t\t\t}\n\t\t\tassert(value instanceof ArrayBuffer);\n\t\t\treturn impl.unbufferReadableStream(value);\n\t\t},\n\t\tBlob(value) {\n\t\t\tassert(Array.isArray(value));\n\t\t\tif (value.length === 2) {\n\t\t\t\t// Blob\n\t\t\t\tconst [buffer, type] = value as unknown[];\n\t\t\t\tassert(buffer instanceof ArrayBuffer);\n\t\t\t\tassert(typeof type === \"string\");\n\t\t\t\tconst opts: WorkerBlobOptions = {};\n\t\t\t\tif (type !== \"\") opts.type = type;\n\t\t\t\treturn new impl.Blob([buffer], opts);\n\t\t\t} else {\n\t\t\t\t// File\n\t\t\t\tassert(value.length === 4);\n\t\t\t\tconst [buffer, type, name, lastModified] = value as unknown[];\n\t\t\t\tassert(buffer instanceof ArrayBuffer);\n\t\t\t\tassert(typeof type === \"string\");\n\t\t\t\tassert(typeof name === \"string\");\n\t\t\t\tassert(typeof lastModified === \"number\");\n\t\t\t\tconst opts: WorkerFileOptions = { lastModified };\n\t\t\t\tif (type !== \"\") opts.type = type;\n\t\t\t\treturn new impl.File([buffer], name, opts);\n\t\t\t}\n\t\t},\n\t\t...revivers,\n\t};\n\n\treturn parse(stringified.value, streamRevivers);\n}\n","import assert from \"node:assert\";\nimport * as vm from \"node:vm\";\nimport defines from \"__VITEST_POOL_WORKERS_DEFINES\";\nimport {\n\tcreateWorkerEntrypointWrapper,\n\tmaybeHandleRunRequest,\n\tregisterHandlerAndGlobalWaitUntil,\n\trunInRunnerObject,\n} from \"cloudflare:test-internal\";\nimport { DurableObject } from \"cloudflare:workers\";\nimport * as devalue from \"devalue\";\n// Using relative path here to ensure `esbuild` bundles it\nimport {\n\tstructuredSerializableReducers,\n\tstructuredSerializableRevivers,\n} from \"../../../miniflare/src/workers/core/devalue\";\n\nfunction structuredSerializableStringify(value: unknown): string {\n\treturn devalue.stringify(value, structuredSerializableReducers);\n}\nfunction structuredSerializableParse(value: string): unknown {\n\treturn devalue.parse(value, structuredSerializableRevivers);\n}\n\n// Mock Service Worker needs this — stub with no-op methods since workerd\n// doesn't provide BroadcastChannel\nglobalThis.BroadcastChannel = class {\n\tconstructor(public name: string) {}\n\tpostMessage(_message: unknown) {}\n\tclose() {}\n\taddEventListener(_type: string, _listener: unknown) {}\n\tremoveEventListener(_type: string, _listener: unknown) {}\n\tonmessage: ((event: unknown) => void) | null = null;\n\tonmessageerror: ((event: unknown) => void) | null = null;\n} as unknown as typeof BroadcastChannel;\n\nlet cwd: string | undefined;\nprocess.cwd = () => {\n\tassert(cwd !== undefined, \"Expected cwd to be set\");\n\treturn cwd;\n};\n\nglobalThis.__console = console;\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type -- V8 stack trace API requires Function type for Error.captureStackTrace\nfunction getCallerFileName(of: Function): string | null {\n\tconst originalStackTraceLimit = Error.stackTraceLimit;\n\tconst originalPrepareStackTrace = Error.prepareStackTrace;\n\ttry {\n\t\tlet fileName: string | null = null;\n\t\tError.stackTraceLimit = 1;\n\t\tError.prepareStackTrace = (_error, callSites) => {\n\t\t\tfileName = callSites[0]?.getFileName();\n\t\t\treturn \"\";\n\t\t};\n\t\tconst error: { stack?: string } = {};\n\t\tError.captureStackTrace(error, of);\n\t\tvoid error.stack; // Access to generate stack trace\n\t\treturn fileName;\n\t} finally {\n\t\tError.stackTraceLimit = originalStackTraceLimit;\n\t\tError.prepareStackTrace = originalPrepareStackTrace;\n\t}\n}\n\nconst originalSetTimeout = globalThis.setTimeout;\nconst originalClearTimeout = globalThis.clearTimeout;\n\nconst timeoutPromiseResolves = new Map<unknown, () => void>();\nconst monkeypatchedSetTimeout = (...args: Parameters<typeof setTimeout>) => {\n\tconst [callback, delay, ...restArgs] = args;\n\tconst callbackName = args[0]?.name ?? \"\";\n\tconst callerFileName = getCallerFileName(monkeypatchedSetTimeout);\n\tconst fromVitest =\n\t\t/\\/node_modules\\/(\\.pnpm\\/|\\.store\\/)?vitest/.test(callerFileName ?? \"\") ||\n\t\t/\\/packages\\/vitest\\/dist/.test(callerFileName ?? \"\") ||\n\t\t/\\/node_modules\\/(\\.pnpm\\/|\\.store\\/)?@voidzero-dev[+/]vite-plus-test/.test(\n\t\t\tcallerFileName ?? \"\"\n\t\t);\n\n\t// If this `setTimeout()` isn't from Vitest, or has a non-zero delay,\n\t// just call the original function\n\tif (!fromVitest || delay) {\n\t\treturn originalSetTimeout.apply(globalThis, args);\n\t}\n\n\t// HACK: `vitest/dist/vendor/vi.js` attempts to call `setTimeout` when setting\n\t// up global mocks. Unfortunately, the runner Durable Object's IO context\n\t// isn't preserved through `import()` so this fails. To get around this, look\n\t// for the `setTimeout()` call and return a recognisable timeout value that's\n\t// still `number` typed\n\t// (https://github.com/sinonjs/fake-timers/blob/c85ef142837afdbc732b0f73fdba30c3bd037965/src/fake-timers-src.js#L154)\n\tif (callbackName === \"NOOP\") {\n\t\treturn -0.5;\n\t}\n\n\t// Make sure `setTimeout()`s from Vitest without delays are `waitUntil()`ed\n\t// if we're running within an `export default` handler. This ensures all\n\t// `console.log()`s are displayed, as Vitest uses `setTimeout()` for grouping.\n\tlet promiseResolve: (() => void) | undefined;\n\tconst promise = new Promise<void>((resolve) => {\n\t\tpromiseResolve = resolve;\n\t});\n\tassert(promiseResolve !== undefined);\n\tregisterHandlerAndGlobalWaitUntil(promise);\n\tconst id = originalSetTimeout.call(globalThis, () => {\n\t\tpromiseResolve?.();\n\t\tcallback?.(...restArgs);\n\t});\n\ttimeoutPromiseResolves.set(id, promiseResolve);\n\treturn id;\n};\n// @ts-expect-error __promisify__ types only required for Node.js\nglobalThis.setTimeout = monkeypatchedSetTimeout;\n// @ts-expect-error overload types not compatible\nglobalThis.clearTimeout = (...args: Parameters<typeof clearTimeout>) => {\n\tconst id = args[0];\n\tif (id === -0.5) {\n\t\treturn;\n\t}\n\n\t// Make sure we resolve any timeout promises we're clearing\n\t// (e.g. `console.log()`ing twice, the 2nd will clear the timeout set by the\n\t// first, but we'll still be `waitUntil()`ing on the original `Promise`)\n\tconst maybePromiseResolve = timeoutPromiseResolves.get(id);\n\ttimeoutPromiseResolves.delete(id);\n\tmaybePromiseResolve?.();\n\n\treturn originalClearTimeout.apply(globalThis, args);\n};\n\nfunction isDifferentIOContextError(e: unknown) {\n\treturn (\n\t\te instanceof Error &&\n\t\te.message.startsWith(\"Cannot perform I/O on behalf of a different\") // \"request\" or \"Durable Object\"\n\t);\n}\n\nlet patchedFunction = false;\nfunction ensurePatchedFunction(unsafeEval: UnsafeEval) {\n\tif (patchedFunction) {\n\t\treturn;\n\t}\n\tpatchedFunction = true;\n\t// `new Function()` is used by `@vitest/snapshot`\n\tglobalThis.Function = new Proxy(globalThis.Function, {\n\t\tconstruct(_target, args, _newTarget) {\n\t\t\t// `new Function()` and `UnsafeEval#newFunction()` have reversed args\n\t\t\tconst script = args.pop();\n\t\t\treturn unsafeEval.newFunction(script, \"anonymous\", ...args);\n\t\t},\n\t});\n}\n\nfunction applyDefines() {\n\t// Based off `/@vite/env` implementation:\n\t// https://github.com/vitejs/vite/blob/v5.1.4/packages/vite/src/client/env.ts\n\tfor (const [key, value] of Object.entries(defines)) {\n\t\tconst segments = key.split(\".\");\n\t\tlet target = globalThis as Record<string, unknown>;\n\t\tfor (let i = 0; i < segments.length; i++) {\n\t\t\tconst segment = segments[i];\n\t\t\tif (i === segments.length - 1) {\n\t\t\t\ttarget[segment] = value;\n\t\t\t} else {\n\t\t\t\ttarget = (target[segment] ??= {}) as Record<string, unknown>;\n\t\t\t}\n\t\t}\n\t}\n}\n\n// `__VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__` is a singleton\nexport class __VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__ extends DurableObject {\n\tconstructor(_state: DurableObjectState, doEnv: Cloudflare.Env) {\n\t\tsuper(_state, doEnv);\n\t\tvm._setUnsafeEval(doEnv.__VITEST_POOL_WORKERS_UNSAFE_EVAL);\n\t\tensurePatchedFunction(doEnv.__VITEST_POOL_WORKERS_UNSAFE_EVAL);\n\t\tapplyDefines();\n\t}\n\n\tasync handleVitestRunRequest(request: Request): Promise<Response> {\n\t\tassert.strictEqual(request.headers.get(\"Upgrade\"), \"websocket\");\n\t\tconst { 0: poolSocket, 1: poolResponseSocket } = new WebSocketPair();\n\n\t\tconst workerDataHeader = request.headers.get(\"MF-Vitest-Worker-Data\");\n\t\tassert(workerDataHeader);\n\n\t\tconst wd = structuredSerializableParse(workerDataHeader);\n\t\tassert(\n\t\t\twd && typeof wd === \"object\" && \"cwd\" in wd && typeof wd.cwd === \"string\"\n\t\t);\n\n\t\tcwd = wd.cwd;\n\n\t\tconst { init, runBaseTests, setupEnvironment } =\n\t\t\tawait import(\"vitest/worker\");\n\n\t\tpoolSocket.accept();\n\n\t\tinit({\n\t\t\tpost: (response) => {\n\t\t\t\ttry {\n\t\t\t\t\tpoolSocket.send(structuredSerializableStringify(response));\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// If the user called `console.log()` or similar from inside an\n\t\t\t\t\t// `export default { fetch() {} }` handler (via `SELF`/`exports`) or\n\t\t\t\t\t// from inside their own Durable Object, Vitest will try to send an\n\t\t\t\t\t// RPC message from a non-`RunnerObject` I/O context. We'd still like\n\t\t\t\t\t// to send the message, so if we detect a cross-DO I/O error we\n\t\t\t\t\t// resend from the runner object.\n\t\t\t\t\t// (Dynamic `import()` cross-DO errors are handled separately by the\n\t\t\t\t\t// onModuleRunner transport patch below — see #12924.)\n\t\t\t\t\tif (isDifferentIOContextError(error)) {\n\t\t\t\t\t\tconst promise = runInRunnerObject(() => {\n\t\t\t\t\t\t\tpoolSocket.send(structuredSerializableStringify(response));\n\t\t\t\t\t\t}).catch((e) => {\n\t\t\t\t\t\t\t__console.error(\n\t\t\t\t\t\t\t\t\"Error sending to pool inside runner:\",\n\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t\tresponse\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tregisterHandlerAndGlobalWaitUntil(promise);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t__console.error(\"Error sending to pool:\", error, response);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\ton: (callback) => {\n\t\t\t\tpoolSocket.addEventListener(\"message\", (m) => {\n\t\t\t\t\tcallback(structuredSerializableParse(m.data));\n\t\t\t\t});\n\t\t\t},\n\t\t\trunTests: (state, traces) => runBaseTests(\"run\", state, traces),\n\t\t\tcollectTests: (state, traces) => runBaseTests(\"collect\", state, traces),\n\t\t\tsetup: setupEnvironment,\n\t\t\t// Patch the module runner's transport so that `invoke()` calls always\n\t\t\t// execute inside the Runner DO's I/O context. Without this, a dynamic\n\t\t\t// `import()` inside an entrypoint handler (which runs in a *different*\n\t\t\t// DO context) fails with \"Cannot perform I/O on behalf of a different\n\t\t\t// Durable Object\". See: https://github.com/cloudflare/workers-sdk/issues/12924\n\t\t\tonModuleRunner(moduleRunner: unknown) {\n\t\t\t\tconst runner = moduleRunner as {\n\t\t\t\t\ttransport?: { invoke?: (...args: unknown[]) => unknown };\n\t\t\t\t};\n\t\t\t\tif (runner.transport?.invoke) {\n\t\t\t\t\tconst originalInvoke = runner.transport.invoke.bind(runner.transport);\n\t\t\t\t\trunner.transport.invoke = (...args: unknown[]) => {\n\t\t\t\t\t\treturn runInRunnerObject(() => originalInvoke(...args));\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\t__console.warn(\n\t\t\t\t\t\t\"[vitest-pool-workers] Could not patch module runner transport. \" +\n\t\t\t\t\t\t\t\"Dynamic import() inside entrypoint/DO handlers may fail.\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\treturn new Response(null, { status: 101, webSocket: poolResponseSocket });\n\t}\n\n\tasync fetch(request: Request): Promise<Response> {\n\t\tconst response = await maybeHandleRunRequest(request, this);\n\t\tif (response !== undefined) {\n\t\t\treturn response;\n\t\t}\n\n\t\treturn this.handleVitestRunRequest(request);\n\t}\n}\n\nexport default createWorkerEntrypointWrapper(\"default\");\n\n// Re-export user export wrappers\nexport * from \"__V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|
1
|
-
{"version":3,"file":"test-internal.mjs","names":["sameIsolatedNamespaces: DurableObjectNamespace[] | undefined","env","errors: unknown[]","timeoutId: ReturnType<typeof setTimeout> | undefined","globalWaitUntil: unknown[]","exports","runtimeEnv","env","DurableObjectClass","#controller","timestamp: Date","attempts: number","metadata: MessageBatchMetadata","retryMessages: QueueRetryMessage[]","explicitAcks: string[]","#workflow","#instanceId","#instanceModifierPromise","#instanceModifier","InstanceStatusNumber","modifierCallbacks: ModifierCallback[]","instanceIntrospectors: WorkflowInstanceIntrospector[]","env","#modifierCallbacks","#instanceIntrospectors","#disposeCallback"],"sources":["../../../../src/worker/fetch-mock.ts","../../../../src/worker/d1.ts","../../../../src/worker/env.ts","../../../../src/worker/durable-objects.ts","../../../../src/worker/wait-until.ts","../../../../src/worker/patch-ctx.ts","../../../../src/worker/entrypoints.ts","../../../../src/worker/events.ts","../../../../src/worker/reset.ts","../../../../src/worker/secrets-store.ts","../../../../../workflows-shared/src/instance.ts","../../../../src/worker/workflows.ts"],"sourcesContent":["const originalFetch = fetch;\n\n// Monkeypatch `fetch()`. This looks like a no-op, but it's not. It allows MSW to intercept fetch calls using it's Fetch interceptor.\nglobalThis.fetch = async (input, init) => {\n\treturn originalFetch.call(globalThis, input, init);\n};\n","import type { D1Migration } from \"../shared/d1\";\n\nfunction isD1Database(v: unknown): v is D1Database {\n\treturn (\n\t\ttypeof v === \"object\" &&\n\t\tv !== null &&\n\t\tv.constructor.name === \"D1Database\" &&\n\t\t\"prepare\" in v &&\n\t\ttypeof v.prepare === \"function\" &&\n\t\t\"batch\" in v &&\n\t\ttypeof v.batch === \"function\" &&\n\t\t\"exec\" in v &&\n\t\ttypeof v.exec === \"function\"\n\t);\n}\n\nfunction isD1Migration(v: unknown): v is D1Migration {\n\treturn (\n\t\ttypeof v === \"object\" &&\n\t\tv !== null &&\n\t\t\"name\" in v &&\n\t\ttypeof v.name === \"string\" &&\n\t\t\"queries\" in v &&\n\t\tArray.isArray(v.queries) &&\n\t\tv.queries.every((query) => typeof query === \"string\")\n\t);\n}\nfunction isD1Migrations(v: unknown): v is D1Migration[] {\n\treturn Array.isArray(v) && v.every(isD1Migration);\n}\n\nexport async function applyD1Migrations(\n\tdb: D1Database,\n\tmigrations: D1Migration[],\n\tmigrationsTableName = \"d1_migrations\"\n) {\n\tif (!isD1Database(db)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'applyD1Migrations': parameter 1 is not of type 'D1Database'.\"\n\t\t);\n\t}\n\tif (!isD1Migrations(migrations)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'applyD1Migrations': parameter 2 is not of type 'D1Migration[]'.\"\n\t\t);\n\t}\n\t// noinspection SuspiciousTypeOfGuard\n\tif (typeof migrationsTableName !== \"string\") {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'applyD1Migrations': parameter 3 is not of type 'string'.\"\n\t\t);\n\t}\n\n\t// Create migrations table if it doesn't exist\n\tconst schema = `CREATE TABLE IF NOT EXISTS ${migrationsTableName} (\n\t\tid INTEGER PRIMARY KEY AUTOINCREMENT,\n\t\tname TEXT UNIQUE,\n\t\tapplied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL\n\t);`;\n\tawait db.prepare(schema).run();\n\n\t// Find applied migrations\n\tconst appliedMigrationNamesResult = await db\n\t\t.prepare(`SELECT name FROM ${migrationsTableName};`)\n\t\t.all<{ name: string }>();\n\tconst appliedMigrationNames = appliedMigrationNamesResult.results.map(\n\t\t({ name }) => name\n\t);\n\n\t// Apply un-applied migrations\n\tconst insertMigrationStmt = db.prepare(\n\t\t`INSERT INTO ${migrationsTableName} (name) VALUES (?);`\n\t);\n\tfor (const migration of migrations) {\n\t\tif (appliedMigrationNames.includes(migration.name)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst queries = migration.queries.map((query) => db.prepare(query));\n\t\tqueries.push(insertMigrationStmt.bind(migration.name));\n\t\tawait db.batch(queries);\n\t}\n}\n","import assert from \"node:assert\";\nimport { exports } from \"cloudflare:workers\";\n\nexport { env } from \"cloudflare:workers\";\n\n/**\n * For reasons that aren't clear to me, just `SELF = exports.default` ends up with SELF being\n * undefined in a test. This Proxy solution works.\n */\nexport const SELF = new Proxy(\n\t{},\n\t{\n\t\tget(_, p) {\n\t\t\tconst target = exports.default as unknown as Record<\n\t\t\t\tstring | symbol,\n\t\t\t\tunknown\n\t\t\t>;\n\t\t\tconst value = target[p];\n\t\t\treturn typeof value === \"function\" ? value.bind(target) : value;\n\t\t},\n\t}\n);\n\nexport function getSerializedOptions(): SerializedOptions {\n\tassert(typeof __vitest_worker__ === \"object\", \"Expected global Vitest state\");\n\tconst options = __vitest_worker__.providedContext.cloudflarePoolOptions;\n\t// `options` should always be defined when running tests\n\n\tassert(\n\t\toptions !== undefined,\n\t\t\"Expected serialised options, got keys: \" +\n\t\t\tObject.keys(__vitest_worker__.providedContext).join(\", \")\n\t);\n\tconst parsedOptions = JSON.parse(options);\n\treturn {\n\t\t...parsedOptions,\n\t\tdurableObjectBindingDesignators: new Map(\n\t\t\tparsedOptions.durableObjectBindingDesignators\n\t\t),\n\t};\n}\n\nexport function getResolvedMainPath(\n\tforBindingType: \"service\" | \"Durable Object\"\n): string {\n\tconst options = getSerializedOptions();\n\tif (options.main === undefined) {\n\t\tthrow new Error(\n\t\t\t`Using ${forBindingType} bindings to the current worker requires \\`poolOptions.workers.main\\` to be set to your worker's entrypoint: ${JSON.stringify(options)}`\n\t\t);\n\t}\n\treturn options.main;\n}\n","import assert from \"node:assert\";\nimport { env, exports } from \"cloudflare:workers\";\nimport { getSerializedOptions } from \"./env\";\nimport type { __VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__ } from \"./index\";\n\nconst CF_KEY_ACTION = \"vitestPoolWorkersDurableObjectAction\";\n\nlet nextActionId = 0;\nconst kUseResponse = Symbol(\"kUseResponse\");\nconst actionResults = new Map<number /* id */, unknown>();\n\nfunction isDurableObjectNamespace(v: unknown): v is DurableObjectNamespace {\n\treturn (\n\t\tv instanceof Object &&\n\t\t/^(?:Loopback)?DurableObjectNamespace$/.test(v.constructor.name) &&\n\t\t\"newUniqueId\" in v &&\n\t\ttypeof v.newUniqueId === \"function\" &&\n\t\t\"idFromName\" in v &&\n\t\ttypeof v.idFromName === \"function\" &&\n\t\t\"idFromString\" in v &&\n\t\ttypeof v.idFromString === \"function\" &&\n\t\t\"get\" in v &&\n\t\ttypeof v.get === \"function\"\n\t);\n}\nfunction isDurableObjectStub(v: unknown): v is DurableObjectStub {\n\treturn (\n\t\ttypeof v === \"object\" &&\n\t\tv !== null &&\n\t\t(v.constructor.name === \"DurableObject\" ||\n\t\t\tv.constructor.name === \"WorkerRpc\") &&\n\t\t\"fetch\" in v &&\n\t\ttypeof v.fetch === \"function\" &&\n\t\t\"id\" in v &&\n\t\ttypeof v.id === \"object\"\n\t);\n}\n\n// Whilst `sameIsolatedNamespaces` depends on `getSerializedOptions()`,\n// `durableObjectBindingDesignators` is derived from the user Durable Object\n// config. If this were to change, the Miniflare options would change too\n// restarting this worker. This means we only need to compute this once, as it\n// will automatically invalidate when needed.\nlet sameIsolatedNamespaces: DurableObjectNamespace[] | undefined;\nfunction getSameIsolateNamespaces(): DurableObjectNamespace[] {\n\tif (sameIsolatedNamespaces !== undefined) {\n\t\treturn sameIsolatedNamespaces;\n\t}\n\tsameIsolatedNamespaces = [];\n\n\tconst options = getSerializedOptions();\n\tif (options.durableObjectBindingDesignators === undefined) {\n\t\treturn sameIsolatedNamespaces;\n\t}\n\n\tfor (const [key, designator] of options.durableObjectBindingDesignators) {\n\t\t// We're assuming the user isn't able to guess the current worker name, so\n\t\t// if a `scriptName` is set, the designator is for another worker.\n\t\tif (designator.scriptName !== undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst namespace = env[key] ?? (exports as Record<string, unknown>)?.[key];\n\t\tassert(\n\t\t\tisDurableObjectNamespace(namespace),\n\t\t\t`Expected ${key} to be a DurableObjectNamespace binding`\n\t\t);\n\t\tsameIsolatedNamespaces.push(namespace);\n\t}\n\n\treturn sameIsolatedNamespaces;\n}\n\nfunction assertSameIsolate(stub: DurableObjectStub) {\n\t// Make sure our special `cf` requests get handled correctly and aren't\n\t// routed to user fetch handlers\n\tconst idString = stub.id.toString();\n\tconst namespaces = getSameIsolateNamespaces();\n\t// Try to recreate the stub's ID using each same-isolate namespace.\n\t// `idFromString()` will throw if the ID is not for that namespace.\n\t// If a call succeeds, we know the ID is for an object in this isolate.\n\tfor (const namespace of namespaces) {\n\t\ttry {\n\t\t\tnamespace.idFromString(idString);\n\t\t\treturn;\n\t\t} catch {}\n\t}\n\t// If no calls succeed, we know the ID is for an object outside this isolate,\n\t// and we won't be able to use the `actionResults` map to share data.\n\tthrow new Error(\n\t\t\"Durable Object test helpers can only be used with stubs pointing to objects defined within the same worker.\"\n\t);\n}\n\nasync function runInStub<O extends DurableObject, R>(\n\tstub: Fetcher,\n\tcallback: (instance: O, state: DurableObjectState) => R | Promise<R>\n): Promise<R> {\n\tconst id = nextActionId++;\n\tactionResults.set(id, callback);\n\n\tconst response = await stub.fetch(\"http://x\", {\n\t\tcf: { [CF_KEY_ACTION]: id },\n\t\t// Prevent the runtime from following redirects returned by the callback,\n\t\t// which would re-enter `maybeHandleRunRequest` with a consumed action ID.\n\t\tredirect: \"manual\",\n\t});\n\n\t// `result` may be `undefined`\n\tassert(actionResults.has(id), `Expected action result for ${id}`);\n\tconst result = actionResults.get(id);\n\tactionResults.delete(id);\n\n\tif (result === kUseResponse) {\n\t\treturn response as R;\n\t} else if (response.ok) {\n\t\treturn result as R;\n\t} else {\n\t\tthrow result;\n\t}\n}\n\n// See public facing `cloudflare:test` types for docs\n// (`async` so it throws asynchronously/rejects)\nexport async function runInDurableObject<O extends DurableObject, R>(\n\tstub: DurableObjectStub,\n\tcallback: (instance: O, state: DurableObjectState) => R | Promise<R>\n): Promise<R> {\n\tif (!isDurableObjectStub(stub)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'runInDurableObject': parameter 1 is not of type 'DurableObjectStub'.\"\n\t\t);\n\t}\n\tif (typeof callback !== \"function\") {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'runInDurableObject': parameter 2 is not of type 'function'.\"\n\t\t);\n\t}\n\n\tassertSameIsolate(stub);\n\treturn runInStub(stub, callback);\n}\n\nasync function runAlarm(instance: DurableObject, state: DurableObjectState) {\n\tconst alarm = await state.storage.getAlarm();\n\tif (alarm === null) {\n\t\treturn false;\n\t}\n\tawait state.storage.deleteAlarm();\n\tawait instance.alarm?.();\n\treturn true;\n}\n// See public facing `cloudflare:test` types for docs\n// (`async` so it throws asynchronously/rejects)\nexport async function runDurableObjectAlarm(\n\tstub: DurableObjectStub\n): Promise<boolean /* ran */> {\n\tif (!isDurableObjectStub(stub)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'runDurableObjectAlarm': parameter 1 is not of type 'DurableObjectStub'.\"\n\t\t);\n\t}\n\treturn await runInDurableObject(stub, runAlarm);\n}\n\n/**\n * Internal method for running `callback` inside the I/O context of the\n * Runner Durable Object.\n *\n * Tests run in this context by default. This is required for performing\n * operations that use Vitest's RPC mechanism as the Durable Object\n * owns the RPC WebSocket. For example, importing modules or sending logs.\n * Trying to perform those operations from a different context (e.g. within\n * a `export default { fetch() {} }` handler or user Durable Object's `fetch()`\n * handler) without using this function will result in a `Cannot perform I/O on\n * behalf of a different request` error.\n */\nexport function runInRunnerObject<R>(\n\tcallback: (\n\t\tinstance: __VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__\n\t) => R | Promise<R>\n): Promise<R> {\n\t// Runner DO is ephemeral (ColoLocalActorNamespace), which has .get(name)\n\t// instead of the standard idFromName()/get(id) API.\n\tconst ns = env[\"__VITEST_POOL_WORKERS_RUNNER_OBJECT\"] as unknown as {\n\t\tget(name: string): Fetcher;\n\t};\n\tconst stub = ns.get(\"singleton\");\n\treturn runInStub(stub, callback);\n}\n\nexport async function maybeHandleRunRequest(\n\trequest: Request,\n\tinstance: unknown,\n\tstate?: DurableObjectState\n): Promise<Response | undefined> {\n\tconst actionId = request.cf?.[CF_KEY_ACTION];\n\tif (actionId === undefined) {\n\t\treturn;\n\t}\n\n\tassert(typeof actionId === \"number\", `Expected numeric ${CF_KEY_ACTION}`);\n\ttry {\n\t\tconst callback = actionResults.get(actionId);\n\t\tassert(typeof callback === \"function\", `Expected callback for ${actionId}`);\n\t\tconst result = await callback(instance, state);\n\t\t// If the callback returns a `Response`, we can't pass it back to the\n\t\t// caller through `actionResults`. If we did that, we'd get a `Cannot\n\t\t// perform I/O on behalf of a different Durable Object` error if we\n\t\t// tried to use it. Instead, we set a flag in `actionResults` that\n\t\t// instructs the caller to use the `Response` returned by\n\t\t// `DurableObjectStub#fetch()` directly.\n\t\tif (result instanceof Response) {\n\t\t\tactionResults.set(actionId, kUseResponse);\n\t\t\treturn result;\n\t\t} else {\n\t\t\tactionResults.set(actionId, result);\n\t\t}\n\t\treturn new Response(null, { status: 204 });\n\t} catch (e) {\n\t\tactionResults.set(actionId, e);\n\t\treturn new Response(null, { status: 500 });\n\t}\n}\n\nexport async function listDurableObjectIds(\n\tnamespace: DurableObjectNamespace\n): Promise<DurableObjectId[]> {\n\tif (!isDurableObjectNamespace(namespace)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'listDurableObjectIds': parameter 1 is not of type 'DurableObjectNamespace'.\"\n\t\t);\n\t}\n\n\t// To get an instance of `DurableObjectNamespace`, the user must've bound the\n\t// namespace to the test runner worker, since `DurableObjectNamespace` has no\n\t// user-accessible constructor. This means `namespace` must be in `globalEnv`.\n\t// We can use this to find the bound name for this binding. We inject a\n\t// mapping between bound names and unique keys for namespaces. We then use\n\t// this to get a unique key and find all IDs on disk.\n\tconst boundName = Object.entries(env).find(\n\t\t(entry) => namespace === entry[1]\n\t)?.[0];\n\tassert(boundName !== undefined, \"Expected to find bound name for namespace\");\n\n\tconst options = getSerializedOptions();\n\tconst designator = options.durableObjectBindingDesignators?.get(boundName);\n\tassert(designator !== undefined, \"Expected to find designator for namespace\");\n\n\tlet uniqueKey = designator.unsafeUniqueKey;\n\tif (uniqueKey === undefined) {\n\t\tconst scriptName = designator.scriptName ?? options.selfName;\n\t\tconst className = designator.className;\n\t\tuniqueKey = `${scriptName}-${className}`;\n\t}\n\n\tconst url = `http://placeholder/durable-objects?unique_key=${encodeURIComponent(\n\t\tuniqueKey\n\t)}`;\n\tconst res = await env.__VITEST_POOL_WORKERS_LOOPBACK_SERVICE.fetch(url);\n\tassert.strictEqual(res.status, 200);\n\tconst ids = await res.json();\n\tassert(Array.isArray(ids));\n\treturn ids.map((id) => {\n\t\tassert(typeof id === \"string\");\n\t\treturn namespace.idFromString(id);\n\t});\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\n\n/**\n * In production, Workers have a 30-second limit for `waitUntil` promises.\n * We use the same limit here. If promises are still pending after this,\n * they almost certainly indicate a bug (e.g. a `waitUntil` promise that\n * will never resolve). We log a warning and move on so the test suite\n * doesn't hang indefinitely.\n */\nlet WAIT_UNTIL_TIMEOUT = 30_000;\n\n/** @internal — only exposed for tests */\nexport function setWaitUntilTimeout(ms: number): void {\n\tWAIT_UNTIL_TIMEOUT = ms;\n}\n\nconst kTimedOut = Symbol(\"kTimedOut\");\n\n/**\n * Empty array and wait for all promises to resolve until no more added.\n * If a single promise rejects, the rejection will be passed-through.\n * If multiple promises reject, the rejections will be aggregated.\n *\n * If any batch of promises hasn't settled after {@link WAIT_UNTIL_TIMEOUT}ms,\n * a warning is logged and the remaining promises are abandoned.\n */\nexport async function waitForWaitUntil(\n\t/* mut */ waitUntil: unknown[]\n): Promise<void> {\n\tconst errors: unknown[] = [];\n\n\twhile (waitUntil.length > 0) {\n\t\tconst batch = waitUntil.splice(0);\n\t\tlet timeoutId: ReturnType<typeof setTimeout> | undefined;\n\t\tconst result = await Promise.race([\n\t\t\tPromise.allSettled(batch).then((results) => ({ results })),\n\t\t\tnew Promise<typeof kTimedOut>(\n\t\t\t\t(resolve) =>\n\t\t\t\t\t(timeoutId = setTimeout(() => resolve(kTimedOut), WAIT_UNTIL_TIMEOUT))\n\t\t\t),\n\t\t]);\n\t\tclearTimeout(timeoutId);\n\n\t\tif (result === kTimedOut) {\n\t\t\t__console.warn(\n\t\t\t\t`[vitest-pool-workers] ${batch.length} waitUntil promise(s) did not ` +\n\t\t\t\t\t`resolve within ${WAIT_UNTIL_TIMEOUT / 1000}s and will be abandoned. ` +\n\t\t\t\t\t`This normally means your Worker's waitUntil handler has a bug ` +\n\t\t\t\t\t`that prevents it from settling (e.g. a fetch that never completes ` +\n\t\t\t\t\t`or a missing resolve/reject call).`\n\t\t\t);\n\t\t\t// Stop draining — any promises added during this batch are also abandoned\n\t\t\twaitUntil.length = 0;\n\t\t\tbreak;\n\t\t}\n\n\t\t// Record all rejected promises\n\t\tfor (const settled of result.results) {\n\t\t\tif (settled.status === \"rejected\") {\n\t\t\t\terrors.push(settled.reason);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (errors.length === 1) {\n\t\t// If there was only one rejection, rethrow it\n\t\tthrow errors[0];\n\t} else if (errors.length > 1) {\n\t\t// If there were more rejections, rethrow them all\n\t\tthrow new AggregateError(errors);\n\t}\n}\n\n// If isolated storage is enabled, we ensure all `waitUntil()`s are `await`ed at\n// the end of each test, as these may contain storage calls (e.g. caching\n// responses). Note we can't wait at the end of `.concurrent` tests, as we can't\n// track which `waitUntil()`s belong to which tests.\n//\n// If isolated storage is disabled, we ensure all `waitUntil()`s are `await`ed\n// at the end of each test *file*. This ensures we don't try to dispose the\n// runtime until all `waitUntil()`s complete.\nconst globalWaitUntil: unknown[] = [];\nexport function registerGlobalWaitUntil(promise: unknown) {\n\tglobalWaitUntil.push(promise);\n}\nexport function waitForGlobalWaitUntil(): Promise<void> {\n\treturn waitForWaitUntil(globalWaitUntil);\n}\n\nexport const handlerContextStore = new AsyncLocalStorage<ExecutionContext>();\nexport function registerHandlerAndGlobalWaitUntil(promise: Promise<unknown>) {\n\tconst handlerContext = handlerContextStore.getStore();\n\tif (handlerContext === undefined) {\n\t\tregisterGlobalWaitUntil(promise);\n\t} else {\n\t\t// `patchAndRunWithHandlerContext()` ensures handler `waitUntil()` calls\n\t\t// `registerGlobalWaitUntil()` too\n\t\thandlerContext.waitUntil(promise);\n\t}\n}\n","import { handlerContextStore, registerGlobalWaitUntil } from \"./wait-until\";\n\nconst patchedHandlerContexts = new WeakSet<ExecutionContext>();\n\n/**\n * Executes the given callback within the provided ExecutionContext,\n * patching the context to ensure that:\n *\n * - waitUntil calls are registered globally\n * - ctx.exports shows a warning if accessing missing exports\n */\nexport function patchAndRunWithHandlerContext<T>(\n\t/* mut */ ctx: ExecutionContext,\n\tcallback: () => T\n): T {\n\t// Ensure calls to `ctx.waitUntil()` registered with global wait-until\n\tif (!patchedHandlerContexts.has(ctx)) {\n\t\tpatchedHandlerContexts.add(ctx);\n\n\t\t// Patch `ctx.waitUntil()`\n\t\tconst originalWaitUntil = ctx.waitUntil;\n\t\tctx.waitUntil = (promise: Promise<unknown>) => {\n\t\t\tregisterGlobalWaitUntil(promise);\n\t\t\treturn originalWaitUntil.call(ctx, promise);\n\t\t};\n\n\t\t// Patch `ctx.exports`\n\t\tif (isCtxExportsEnabled(ctx.exports)) {\n\t\t\tObject.defineProperty(ctx, \"exports\", {\n\t\t\t\tvalue: getCtxExportsProxy(ctx.exports),\n\t\t\t});\n\t\t}\n\t}\n\treturn handlerContextStore.run(ctx, callback);\n}\n\n/**\n * Creates a proxy to the `ctx.exports` object that will warn the user if they attempt\n * to access an undefined property. This could be a valid mistake by the user or\n * it could mean that our static analysis of the main Worker's exports missed something.\n */\nexport function getCtxExportsProxy(\n\texports: Cloudflare.Exports\n): Cloudflare.Exports {\n\treturn new Proxy(exports, {\n\t\tget(target, p: keyof Cloudflare.Exports) {\n\t\t\tif (p in target) {\n\t\t\t\treturn target[p];\n\t\t\t}\n\t\t\tconsole.warn(\n\t\t\t\t`Attempted to access 'ctx.exports.${p}', which was not defined for the main Worker.\\n` +\n\t\t\t\t\t`Check that '${p}' is exported as an entry-point from the Worker.\\n` +\n\t\t\t\t\t`The '@cloudflare/vitest-pool-workers' integration tries to infer these exports by analyzing the source code of the main Worker.\\n`\n\t\t\t);\n\t\t\treturn undefined;\n\t\t},\n\t});\n}\n\n/**\n * Returns true if `ctx.exports` is enabled via compatibility flags.\n */\nexport function isCtxExportsEnabled(\n\texports: Cloudflare.Exports | undefined\n): exports is Cloudflare.Exports {\n\treturn (\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t(globalThis as any).Cloudflare?.compatibilityFlags.enable_ctx_exports &&\n\t\texports !== undefined\n\t);\n}\n","import assert from \"node:assert\";\nimport {\n\tDurableObject as DurableObjectClass,\n\tenv as runtimeEnv,\n\tWorkerEntrypoint,\n\tWorkflowEntrypoint,\n} from \"cloudflare:workers\";\nimport { maybeHandleRunRequest, runInRunnerObject } from \"./durable-objects\";\nimport { getResolvedMainPath } from \"./env\";\nimport { patchAndRunWithHandlerContext } from \"./patch-ctx\";\n\n// =============================================================================\n// Common Entrypoint Helpers\n// =============================================================================\n\n/**\n * Internal method for importing a module using Vite's transformation and\n * execution pipeline. Can be called from any I/O context, and will ensure the\n * request is run from within the `__VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__`.\n */\nasync function importModule(\n\tspecifier: string\n): Promise<Record<string, unknown>> {\n\t/**\n\t * We need to run this import inside the Runner Object, or we get errors like:\n\t * - The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response. Refer to: https://developers.cloudflare.com/workers/observability/errors/\n\t * - Cannot perform I/O on behalf of a different Durable Object. I/O objects (such as streams, request/response bodies, and others) created in the context of one Durable Object cannot be accessed from a different Durable Object in the same isolate. This is a limitation of Cloudflare Workers which allows us to improve overall performance.\n\t */\n\treturn runInRunnerObject(() => {\n\t\treturn __vitest_mocker__.moduleRunner.import(specifier);\n\t});\n}\n\nconst IGNORED_KEYS = [\"self\"];\n\n/**\n * Create a class extending `superClass` with a `Proxy` as a `prototype`.\n * Unknown accesses on the `prototype` will defer to `getUnknownPrototypeKey()`.\n * `workerd` will only look for RPC methods/properties on the prototype, not the\n * instance. This helps avoid accidentally exposing things over RPC, but makes\n * things a little trickier for us...\n */\nfunction createProxyPrototypeClass<\n\tT extends\n\t\t| typeof WorkerEntrypoint\n\t\t| typeof DurableObjectClass\n\t\t| typeof WorkflowEntrypoint,\n\tExtraPrototype = unknown,\n>(\n\tsuperClass: T,\n\tgetUnknownPrototypeKey: (key: string) => unknown\n): T & { prototype: ExtraPrototype } {\n\t// Build a class with a \"Proxy\"-prototype, so we can intercept RPC calls\n\tfunction Class(...args: ConstructorParameters<typeof superClass>) {\n\t\t// Delay proxying prototype until construction, so workerd sees this as a\n\t\t// regular class when introspecting it. This check fails if we don't do this:\n\t\t// https://github.com/cloudflare/workerd/blob/9e915ed637d65adb3c57522607d2cd8b8d692b6b/src/workerd/io/worker.c%2B%2B#L1920-L1921\n\t\tClass.prototype = new Proxy(Class.prototype, {\n\t\t\tget(target, key, receiver) {\n\t\t\t\tconst value = Reflect.get(target, key, receiver);\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t\t// noinspection SuspiciousTypeOfGuard\n\t\t\t\tif (typeof key === \"symbol\" || IGNORED_KEYS.includes(key)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\treturn getUnknownPrototypeKey.call(receiver, key as string);\n\t\t\t},\n\t\t});\n\n\t\treturn Reflect.construct(superClass, args, Class);\n\t}\n\n\tReflect.setPrototypeOf(Class.prototype, superClass.prototype);\n\tReflect.setPrototypeOf(Class, superClass);\n\n\treturn Class as unknown as T & { prototype: ExtraPrototype };\n}\n\n/**\n * Only properties and methods declared on the prototype can be accessed over\n * RPC. This function gets a property from the prototype if it's defined, and\n * throws a helpful error message if not. Note we need to distinguish between a\n * property that returns `undefined` and something not being defined at all.\n */\nfunction getRPCProperty(\n\tctor: WorkerEntrypointConstructor | DurableObjectConstructor,\n\tinstance:\n\t\t| WorkerEntrypoint<Record<string, unknown> | Cloudflare.Env>\n\t\t| DurableObjectClass<Record<string, unknown> | Cloudflare.Env>,\n\tkey: string\n): unknown {\n\tconst prototypeHasKey = Reflect.has(ctor.prototype, key);\n\tif (!prototypeHasKey) {\n\t\tconst quotedKey = JSON.stringify(key);\n\t\tconst instanceHasKey = Reflect.has(instance, key);\n\t\tlet message = \"\";\n\t\tif (instanceHasKey) {\n\t\t\tmessage = [\n\t\t\t\t`The RPC receiver's prototype does not implement ${quotedKey}, but the receiver instance does.`,\n\t\t\t\t\"Only properties and methods defined on the prototype can be accessed over RPC.\",\n\t\t\t\t`Ensure properties are declared like \\`get ${key}() { ... }\\` instead of \\`${key} = ...\\`,`,\n\t\t\t\t`and methods are declared like \\`${key}() { ... }\\` instead of \\`${key} = () => { ... }\\`.`,\n\t\t\t].join(\"\\n\");\n\t\t} else {\n\t\t\tmessage = `The RPC receiver does not implement ${quotedKey}.`;\n\t\t}\n\t\tthrow new TypeError(message);\n\t}\n\n\t// `receiver` is the value of `this` provided if a getter is encountered\n\treturn Reflect.get(/* target */ ctor.prototype, key, /* receiver */ instance);\n}\n\n/**\n * When calling RPC methods dynamically, we don't know whether the `property`\n * returned from `getSELFRPCProperty()` or `getDurableObjectRPCProperty()` below\n * is just a property or a method. If we just returned `property`, but the\n * client tried to call it as a method, `workerd` would throw an \"x is not a\n * function\" error.\n *\n * Instead, we return a *callable, custom thenable*. This behaves like a\n * function and a `Promise`! If `workerd` calls it, we'll wait for the promise\n * to resolve then forward the call. Otherwise, this just appears like a regular\n * async property. Note all client calls are async, so converting sync\n * properties and methods to async is fine here.\n *\n * Unfortunately, wrapping `property` with a `Proxy` and an `apply()` trap gives\n * `TypeError: Method Promise.prototype.then called on incompatible receiver #<Promise>`. :(\n */\nfunction getRPCPropertyCallableThenable(\n\tkey: string,\n\tproperty: Promise<unknown>\n) {\n\tconst fn = async function (...args: unknown[]) {\n\t\tconst maybeFn = await property;\n\t\tif (typeof maybeFn === \"function\") {\n\t\t\treturn maybeFn(...args);\n\t\t} else {\n\t\t\tthrow new TypeError(`${JSON.stringify(key)} is not a function.`);\n\t\t}\n\t} as Promise<unknown> & ((...args: unknown[]) => Promise<unknown>);\n\tfn.then = (onFulfilled, onRejected) => property.then(onFulfilled, onRejected);\n\tfn.catch = (onRejected) => property.catch(onRejected);\n\tfn.finally = (onFinally) => property.finally(onFinally);\n\treturn fn;\n}\n\n/**\n * `ctx` and `env` are defined as `protected` within `WorkerEntrypoint` and\n * `DurableObjectClass`. Usually this isn't a problem, as `protected` members\n * can be accessed from subclasses defined with `class extends` keywords.\n * Unfortunately, we have to define our classes with a `Proxy` prototype to\n * support forwarding RPC. This prevents us accessing `protected` members.\n * Instead, we define this function to extract these members, and provide type\n * safety for callers.\n */\nfunction getEntrypointState(instance: WorkerEntrypoint<Cloudflare.Env>): {\n\tctx: ExecutionContext;\n\tenv: Cloudflare.Env;\n};\nfunction getEntrypointState(instance: DurableObjectClass<Cloudflare.Env>): {\n\tctx: DurableObjectState;\n\tenv: Cloudflare.Env;\n};\nfunction getEntrypointState(\n\tinstance:\n\t\t| WorkerEntrypoint<Cloudflare.Env>\n\t\t| DurableObjectClass<Cloudflare.Env>\n) {\n\treturn instance as unknown as {\n\t\tctx: ExecutionContext | DurableObjectState;\n\t\tenv: Cloudflare.Env;\n\t};\n}\n\nconst WORKER_ENTRYPOINT_KEYS = [\n\t\"connect\",\n\t\"tailStream\",\n\t\"fetch\",\n\t\"tail\",\n\t\"trace\",\n\t\"scheduled\",\n\t\"queue\",\n\t\"test\",\n\t\"email\",\n] as const;\nconst DURABLE_OBJECT_KEYS = [\n\t\"connect\",\n\t\"fetch\",\n\t\"alarm\",\n\t\"webSocketMessage\",\n\t\"webSocketClose\",\n\t\"webSocketError\",\n] as const;\n\n// This type will grab the keys from T and remove \"branded\" keys\ntype UnbrandedKeys<T> = Exclude<keyof T, `__${string}_BRAND`>;\n\n// Check that we've included all possible keys\n// noinspection JSUnusedLocalSymbols\nconst _workerEntrypointExhaustive: (typeof WORKER_ENTRYPOINT_KEYS)[number] =\n\tundefined as unknown as UnbrandedKeys<WorkerEntrypoint<Cloudflare.Env>>;\n// noinspection JSUnusedLocalSymbols\nconst _durableObjectExhaustive: (typeof DURABLE_OBJECT_KEYS)[number] =\n\tundefined as unknown as UnbrandedKeys<DurableObjectClass<Cloudflare.Env>>;\n\n// =============================================================================\n// `WorkerEntrypoint` wrappers\n// =============================================================================\n\n// `WorkerEntrypoint` is `abstract`, so we need to cast before constructing\ntype WorkerEntrypointConstructor = {\n\tnew (\n\t\t...args: ConstructorParameters<typeof WorkerEntrypoint>\n\t): WorkerEntrypoint;\n};\n\n/**\n * Get the export to use for `entrypoint`. This is used for the `SELF` service\n * binding in `cloudflare:test`, which sets `entrypoint` to \"default\".\n * This requires importing the `main` module with Vite.\n */\nasync function getWorkerEntrypointExport(\n\tenv: Cloudflare.Env,\n\tentrypoint: string\n): Promise<{ mainPath: string; entrypointValue: unknown }> {\n\tconst mainPath = getResolvedMainPath(\"service\");\n\tconst mainModule = await importModule(mainPath);\n\tconst entrypointValue =\n\t\ttypeof mainModule === \"object\" &&\n\t\tmainModule !== null &&\n\t\tentrypoint in mainModule &&\n\t\tmainModule[entrypoint];\n\tif (!entrypointValue) {\n\t\tconst message =\n\t\t\t`${mainPath} does not export a ${entrypoint} entrypoint. \\`@cloudflare/vitest-pool-workers\\` does not support service workers or named entrypoints for \\`SELF\\`.\\n` +\n\t\t\t\"If you're using service workers, please migrate to the modules format: https://developers.cloudflare.com/workers/reference/migrate-to-module-workers.\";\n\t\tthrow new TypeError(message);\n\t}\n\treturn { mainPath, entrypointValue };\n}\n\n/**\n * Get a property named `key` from the user's `WorkerEntrypoint`. `wrapper` here\n * is an instance of a `WorkerEntrypoint` wrapper (i.e. the return value of\n * `createWorkerEntrypointWrapper()`). This requires importing the `main` module\n * with Vite, so will always return a `Promise.`\n */\nasync function getWorkerEntrypointRPCProperty(\n\twrapper: WorkerEntrypoint<Cloudflare.Env>,\n\tentrypoint: string,\n\tkey: string\n): Promise<unknown> {\n\tconst { ctx } = getEntrypointState(wrapper);\n\tconst { mainPath, entrypointValue } = await getWorkerEntrypointExport(\n\t\truntimeEnv as Cloudflare.Env,\n\t\tentrypoint\n\t);\n\t// Ensure constructor and properties execute with ctx `AsyncLocalStorage` set\n\treturn patchAndRunWithHandlerContext(ctx, () => {\n\t\t// Use the dynamic env from `cloudflare:workers` to respect `withEnv()`\n\t\tconst env = runtimeEnv as Cloudflare.Env;\n\t\tconst expectedWorkerEntrypointMessage = `Expected ${entrypoint} export of ${mainPath} to be a subclass of \\`WorkerEntrypoint\\` for RPC`;\n\t\tif (typeof entrypointValue !== \"function\") {\n\t\t\tthrow new TypeError(expectedWorkerEntrypointMessage);\n\t\t}\n\t\tconst ctor = entrypointValue as WorkerEntrypointConstructor;\n\t\tconst instance = new ctor(ctx, env);\n\t\t// noinspection SuspiciousTypeOfGuard\n\t\tif (!(instance instanceof WorkerEntrypoint)) {\n\t\t\tthrow new TypeError(expectedWorkerEntrypointMessage);\n\t\t}\n\n\t\tconst value = getRPCProperty(ctor, instance, key);\n\t\tif (typeof value === \"function\") {\n\t\t\t// If this is a function, ensure it executes with ctx `AsyncLocalStorage`\n\t\t\t// set, and with a correctly bound `this`\n\t\t\treturn (...args: unknown[]) =>\n\t\t\t\tpatchAndRunWithHandlerContext(ctx, () => value.apply(instance, args));\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t});\n}\n\nexport function createWorkerEntrypointWrapper(\n\tentrypoint: string\n): typeof WorkerEntrypoint {\n\tconst Wrapper = createProxyPrototypeClass(\n\t\tWorkerEntrypoint,\n\t\tfunction (this: WorkerEntrypoint<Cloudflare.Env>, key) {\n\t\t\t// All `ExportedHandler` keys are reserved and cannot be called over RPC\n\t\t\tif ((DURABLE_OBJECT_KEYS as readonly string[]).includes(key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst property = getWorkerEntrypointRPCProperty(this, entrypoint, key);\n\t\t\treturn getRPCPropertyCallableThenable(key, property);\n\t\t}\n\t);\n\n\t// Add prototype methods for all default handlers\n\tfor (const key of WORKER_ENTRYPOINT_KEYS) {\n\t\tWrapper.prototype[key] = async function (\n\t\t\tthis: WorkerEntrypoint<Cloudflare.Env>,\n\t\t\tthing: unknown\n\t\t) {\n\t\t\tconst { mainPath, entrypointValue } = await getWorkerEntrypointExport(\n\t\t\t\tthis.env,\n\t\t\t\tentrypoint\n\t\t\t);\n\n\t\t\treturn patchAndRunWithHandlerContext(this.ctx, () => {\n\t\t\t\tif (typeof entrypointValue === \"object\" && entrypointValue !== null) {\n\t\t\t\t\t// Assuming the user has defined an `ExportedHandler`\n\t\t\t\t\tconst maybeFn = (entrypointValue as Record<string, unknown>)[key];\n\t\t\t\t\tif (typeof maybeFn === \"function\") {\n\t\t\t\t\t\treturn maybeFn.call(entrypointValue, thing, runtimeEnv, this.ctx);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to define a \\`${key}()\\` function`;\n\t\t\t\t\t\tthrow new TypeError(message);\n\t\t\t\t\t}\n\t\t\t\t} else if (typeof entrypointValue === \"function\") {\n\t\t\t\t\t// Assuming the user has defined a `WorkerEntrypoint` subclass\n\t\t\t\t\tconst ctor = entrypointValue as WorkerEntrypointConstructor;\n\t\t\t\t\tconst instance = new ctor(this.ctx, runtimeEnv);\n\t\t\t\t\t// noinspection SuspiciousTypeOfGuard\n\t\t\t\t\tif (!(instance instanceof WorkerEntrypoint)) {\n\t\t\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to be a subclass of \\`WorkerEntrypoint\\``;\n\t\t\t\t\t\tthrow new TypeError(message);\n\t\t\t\t\t}\n\t\t\t\t\tconst maybeFn = instance[key];\n\t\t\t\t\tif (typeof maybeFn === \"function\") {\n\t\t\t\t\t\treturn (maybeFn as (arg: unknown) => unknown).call(instance, thing);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to define a \\`${key}()\\` method`;\n\t\t\t\t\t\tthrow new TypeError(message);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Assuming the user has messed up\n\t\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to be an object or a class, got ${entrypointValue}`;\n\t\t\t\t\tthrow new TypeError(message);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t}\n\treturn Wrapper;\n}\n\n// =============================================================================\n// `DurableObject` wrappers\n// =============================================================================\n\ntype DurableObjectConstructor = {\n\tnew (\n\t\t...args: ConstructorParameters<typeof DurableObjectClass>\n\t): DurableObject | DurableObjectClass;\n};\n\nconst kInstanceConstructor = Symbol(\"kInstanceConstructor\");\nconst kInstance = Symbol(\"kInstance\");\nconst kEnsureInstance = Symbol(\"kEnsureInstance\");\ntype DurableObjectWrapperExtraPrototype = {\n\t[kInstanceConstructor]: DurableObjectConstructor;\n\t[kInstance]:\n\t\t| DurableObject\n\t\t| DurableObjectClass<Record<string, unknown> | Cloudflare.Env>;\n\t[kEnsureInstance](): Promise<{\n\t\tmainPath: string;\n\t\tinstanceCtor: DurableObjectConstructor;\n\t\tinstance:\n\t\t\t| DurableObject\n\t\t\t| DurableObjectClass<Record<string, unknown> | Cloudflare.Env>;\n\t}>;\n};\ntype DurableObjectWrapper = DurableObjectClass<Cloudflare.Env> &\n\tDurableObjectWrapperExtraPrototype;\n\nasync function getDurableObjectRPCProperty(\n\twrapper: DurableObjectWrapper,\n\tclassName: string,\n\tkey: string\n): Promise<unknown> {\n\tconst { mainPath, instanceCtor, instance } = await wrapper[kEnsureInstance]();\n\tif (!(instance instanceof DurableObjectClass)) {\n\t\tconst message = `Expected ${className} exported by ${mainPath} be a subclass of \\`DurableObject\\` for RPC`;\n\t\tthrow new TypeError(message);\n\t}\n\tconst value = getRPCProperty(instanceCtor, instance, key);\n\tif (typeof value === \"function\") {\n\t\t// If this is a function, ensure correctly bound `this`\n\t\treturn value.bind(instance);\n\t} else {\n\t\treturn value;\n\t}\n}\n\nexport function createDurableObjectWrapper(\n\tclassName: string\n): typeof DurableObjectClass {\n\tconst Wrapper = createProxyPrototypeClass<\n\t\ttypeof DurableObjectClass,\n\t\tDurableObjectWrapperExtraPrototype\n\t>(DurableObjectClass, function (this: DurableObjectWrapper, key) {\n\t\t// All `ExportedHandler` keys are reserved and cannot be called over RPC\n\t\tif ((WORKER_ENTRYPOINT_KEYS as readonly string[]).includes(key)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst property = getDurableObjectRPCProperty(this, className, key);\n\t\treturn getRPCPropertyCallableThenable(key, property);\n\t});\n\n\tWrapper.prototype[kEnsureInstance] = async function (\n\t\tthis: DurableObjectWrapper\n\t) {\n\t\tconst { ctx, env } = getEntrypointState(this);\n\t\tconst mainPath = getResolvedMainPath(\"Durable Object\");\n\t\t// `ensureInstance()` may be called multiple times concurrently.\n\t\t// We're assuming `importModule()` will only import the module once.\n\t\tconst mainModule = await importModule(mainPath);\n\t\tconst constructor = mainModule[className];\n\t\tif (typeof constructor !== \"function\") {\n\t\t\tthrow new TypeError(\n\t\t\t\t`${mainPath} does not export a ${className} Durable Object`\n\t\t\t);\n\t\t}\n\t\tthis[kInstanceConstructor] ??= constructor as DurableObjectConstructor;\n\t\tif (this[kInstanceConstructor] !== constructor) {\n\t\t\t// This would be if the module was invalidated\n\t\t\t// (i.e. source file changed), then the Durable Object was `fetch()`ed\n\t\t\t// again. We reset all Durable Object instances between each test, so it's\n\t\t\t// unlikely multiple constructors would be used by the same instance,\n\t\t\t// unless the user did something funky with Durable Objects outside tests.\n\t\t\tawait ctx.blockConcurrencyWhile<never>(() => {\n\t\t\t\t// Throw inside `blockConcurrencyWhile()` to abort this object\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${mainPath} changed, invalidating this Durable Object. ` +\n\t\t\t\t\t\t\"Please retry the `DurableObjectStub#fetch()` call.\"\n\t\t\t\t);\n\t\t\t});\n\t\t\tassert.fail(\"Unreachable\");\n\t\t}\n\t\tif (this[kInstance] === undefined) {\n\t\t\tthis[kInstance] = new this[kInstanceConstructor](ctx, env);\n\t\t\t// Wait for any `blockConcurrencyWhile()`s in the constructor to complete\n\t\t\tawait ctx.blockConcurrencyWhile(async () => {});\n\t\t}\n\t\treturn {\n\t\t\tmainPath,\n\t\t\tinstanceCtor: this[kInstanceConstructor],\n\t\t\tinstance: this[kInstance],\n\t\t};\n\t};\n\n\t// Add prototype method for `fetch` handler to handle `runInDurableObject()`s\n\tWrapper.prototype.fetch = async function (\n\t\tthis: DurableObjectWrapper,\n\t\trequest: Request\n\t) {\n\t\tconst { ctx } = getEntrypointState(this);\n\n\t\t// Make sure we've initialised user code\n\t\tconst { mainPath, instance } = await this[kEnsureInstance]();\n\n\t\t// If this is an internal Durable Object action, handle it...\n\t\tconst response = await maybeHandleRunRequest(request, instance, ctx);\n\t\tif (response !== undefined) {\n\t\t\treturn response;\n\t\t}\n\n\t\t// Otherwise, pass through to the user code\n\t\tif (instance.fetch === undefined) {\n\t\t\tconst message = `${className} exported by ${mainPath} does not define a \\`fetch()\\` method`;\n\t\t\tthrow new TypeError(message);\n\t\t}\n\t\treturn instance.fetch(request);\n\t};\n\n\t// Add prototype methods for all other default handlers\n\tfor (const key of DURABLE_OBJECT_KEYS) {\n\t\tif (key === \"fetch\") {\n\t\t\tcontinue;\n\t\t} // `fetch()` has special handling above\n\t\tWrapper.prototype[key] = async function (\n\t\t\tthis: DurableObjectWrapper,\n\t\t\t...args: unknown[]\n\t\t) {\n\t\t\tconst { mainPath, instance } = await this[kEnsureInstance]();\n\t\t\tconst maybeFn = instance[key];\n\t\t\tif (typeof maybeFn === \"function\") {\n\t\t\t\treturn (maybeFn as (...a: unknown[]) => void).apply(instance, args);\n\t\t\t} else {\n\t\t\t\tconst message = `${className} exported by ${mainPath} does not define a \\`${key}()\\` method`;\n\t\t\t\tthrow new TypeError(message);\n\t\t\t}\n\t\t};\n\t}\n\n\treturn Wrapper;\n}\n\n// =============================================================================\n// `WorkflowEntrypoint` wrappers\n// =============================================================================\n\ntype WorkflowEntrypointConstructor = {\n\tnew (\n\t\t...args: ConstructorParameters<typeof WorkflowEntrypoint>\n\t): WorkflowEntrypoint;\n};\n\nexport function createWorkflowEntrypointWrapper(entrypoint: string) {\n\tconst Wrapper = createProxyPrototypeClass(\n\t\tWorkflowEntrypoint,\n\t\tfunction (this: WorkflowEntrypoint<Cloudflare.Env>, key) {\n\t\t\t// only Workflow `run` should be exposed over RPC\n\t\t\tif (![\"run\"].includes(key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst property = getWorkerEntrypointRPCProperty(\n\t\t\t\tthis as unknown as WorkerEntrypoint<Cloudflare.Env>,\n\t\t\t\tentrypoint,\n\t\t\t\tkey\n\t\t\t);\n\t\t\treturn getRPCPropertyCallableThenable(key, property);\n\t\t}\n\t);\n\n\tWrapper.prototype.run = async function (\n\t\tthis: WorkflowEntrypoint<Cloudflare.Env>,\n\t\t...args\n\t) {\n\t\tconst { mainPath, entrypointValue } = await getWorkerEntrypointExport(\n\t\t\truntimeEnv,\n\t\t\tentrypoint\n\t\t);\n\t\t// workflow entrypoint value should always be a constructor\n\t\tif (typeof entrypointValue === \"function\") {\n\t\t\t// Assuming the user has defined a `WorkflowEntrypoint` subclass\n\t\t\tconst ctor = entrypointValue as WorkflowEntrypointConstructor;\n\t\t\tconst instance = new ctor(this.ctx, runtimeEnv);\n\t\t\t// noinspection SuspiciousTypeOfGuard\n\t\t\tif (!(instance instanceof WorkflowEntrypoint)) {\n\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to be a subclass of \\`WorkflowEntrypoint\\``;\n\t\t\t\tthrow new TypeError(message);\n\t\t\t}\n\t\t\tconst maybeFn = instance[\"run\"];\n\t\t\tif (typeof maybeFn === \"function\") {\n\t\t\t\treturn patchAndRunWithHandlerContext(this.ctx, () =>\n\t\t\t\t\tmaybeFn.call(instance, ...args)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to define a \\`run()\\` method, but got ${typeof maybeFn}`;\n\t\t\t\tthrow new TypeError(message);\n\t\t\t}\n\t\t} else {\n\t\t\t// Assuming the user has messed up\n\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to be a subclass of \\`WorkflowEntrypoint\\`, but got ${entrypointValue}`;\n\t\t\tthrow new TypeError(message);\n\t\t}\n\t};\n\n\treturn Wrapper;\n}\n","import { exports } from \"cloudflare:workers\";\nimport { env } from \"./env\";\nimport { getCtxExportsProxy, isCtxExportsEnabled } from \"./patch-ctx\";\nimport { registerGlobalWaitUntil, waitForWaitUntil } from \"./wait-until\";\n\n// `workerd` doesn't allow these internal classes to be constructed directly.\n// To replicate this behaviour require this unique symbol to be specified as the\n// first constructor argument. If this is missing, throw `Illegal invocation`.\nconst kConstructFlag = Symbol(\"kConstructFlag\");\n\n// See public facing `cloudflare:test` types for docs.\n\n// =============================================================================\n// `ExecutionContext`\n// =============================================================================\n\nconst kWaitUntil = Symbol(\"kWaitUntil\");\nclass ExecutionContext {\n\t// https://github.com/cloudflare/workerd/blob/v1.20231218.0/src/workerd/api/global-scope.h#L168\n\t[kWaitUntil]: unknown[] = [];\n\n\tconstructor(flag: typeof kConstructFlag) {\n\t\tif (flag !== kConstructFlag) {\n\t\t\tthrow new TypeError(\"Illegal constructor\");\n\t\t}\n\t}\n\n\t// Expose the ctx.exports from the main \"SELF\" Worker if there is one.\n\treadonly exports = isCtxExportsEnabled(exports)\n\t\t? getCtxExportsProxy(exports)\n\t\t: undefined;\n\n\twaitUntil(promise: unknown) {\n\t\tif (!(this instanceof ExecutionContext)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\tthis[kWaitUntil].push(promise);\n\t\tregisterGlobalWaitUntil(promise);\n\t}\n\n\tpassThroughOnException(): void {}\n}\nexport function createExecutionContext(): ExecutionContext {\n\treturn new ExecutionContext(kConstructFlag);\n}\n\nfunction isExecutionContextLike(v: unknown): v is { [kWaitUntil]: unknown[] } {\n\treturn (\n\t\ttypeof v === \"object\" &&\n\t\tv !== null &&\n\t\tkWaitUntil in v &&\n\t\tArray.isArray(v[kWaitUntil])\n\t);\n}\nexport async function waitOnExecutionContext(ctx: unknown): Promise<void> {\n\tif (!isExecutionContextLike(ctx)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'getWaitUntil': parameter 1 is not of type 'ExecutionContext'.\\n\" +\n\t\t\t\t\"You must call 'createExecutionContext()' or 'createPagesEventContext()' to get an 'ExecutionContext' instance.\"\n\t\t);\n\t}\n\treturn waitForWaitUntil(ctx[kWaitUntil]);\n}\n\n// =============================================================================\n// `ScheduledController`\n// =============================================================================\n\nclass ScheduledController {\n\t// https://github.com/cloudflare/workerd/blob/v1.20231218.0/src/workerd/api/scheduled.h#L35\n\treadonly scheduledTime!: number;\n\treadonly cron!: string;\n\n\tconstructor(flag: typeof kConstructFlag, options?: FetcherScheduledOptions) {\n\t\tif (flag !== kConstructFlag) {\n\t\t\tthrow new TypeError(\"Illegal constructor\");\n\t\t}\n\n\t\tconst scheduledTime = Number(options?.scheduledTime ?? Date.now());\n\t\tconst cron = String(options?.cron ?? \"\");\n\n\t\t// Match `JSG_READONLY_INSTANCE_PROPERTY` behaviour\n\t\tObject.defineProperties(this, {\n\t\t\tscheduledTime: {\n\t\t\t\tget() {\n\t\t\t\t\treturn scheduledTime;\n\t\t\t\t},\n\t\t\t},\n\t\t\tcron: {\n\t\t\t\tget() {\n\t\t\t\t\treturn cron;\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\tnoRetry(): void {\n\t\tif (!(this instanceof ScheduledController)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t}\n}\nexport function createScheduledController(\n\toptions?: FetcherScheduledOptions\n): ScheduledController {\n\tif (options !== undefined && typeof options !== \"object\") {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'createScheduledController': parameter 1 is not of type 'ScheduledOptions'.\"\n\t\t);\n\t}\n\treturn new ScheduledController(kConstructFlag, options);\n}\n\n// =============================================================================\n// `MessageBatch`\n// =============================================================================\n\nconst kRetry = Symbol(\"kRetry\");\nconst kAck = Symbol(\"kAck\");\nconst kRetryAll = Symbol(\"kRetryAll\");\nconst kAckAll = Symbol(\"kAckAll\");\nclass QueueMessage<Body = unknown> /* Message */ {\n\t// https://github.com/cloudflare/workerd/blob/v1.20231218.0/src/workerd/api/queue.h#L113\n\treadonly #controller: QueueController;\n\treadonly id!: string;\n\treadonly timestamp!: Date;\n\treadonly body!: Body;\n\treadonly attempts!: number;\n\t[kRetry] = false;\n\t[kAck] = false;\n\n\tconstructor(\n\t\tflag: typeof kConstructFlag,\n\t\tcontroller: QueueController,\n\t\tmessage: ServiceBindingQueueMessage<Body>\n\t) {\n\t\tif (flag !== kConstructFlag) {\n\t\t\tthrow new TypeError(\"Illegal constructor\");\n\t\t}\n\t\tthis.#controller = controller;\n\n\t\tconst id = String(message.id);\n\n\t\tlet timestamp: Date;\n\t\t// noinspection SuspiciousTypeOfGuard\n\t\tif (typeof message.timestamp === \"number\") {\n\t\t\ttimestamp = new Date(message.timestamp);\n\t\t} else if (message.timestamp instanceof Date) {\n\t\t\ttimestamp = new Date(message.timestamp.getTime()); // Prevent external mutations\n\t\t} else {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"Incorrect type for the 'timestamp' field on 'ServiceBindingQueueMessage': the provided value is not of type 'date'.\"\n\t\t\t);\n\t\t}\n\n\t\tlet attempts: number;\n\t\t// noinspection SuspiciousTypeOfGuard\n\t\tif (typeof message.attempts === \"number\") {\n\t\t\tattempts = message.attempts;\n\t\t} else {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"Incorrect type for the 'attempts' field on 'ServiceBindingQueueMessage': the provided value is not of type 'number'.\"\n\t\t\t);\n\t\t}\n\n\t\tif (\"serializedBody\" in message) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"Cannot use `serializedBody` with `createMessageBatch()`\"\n\t\t\t);\n\t\t}\n\t\tconst body = structuredClone(message.body); // Prevent external mutations\n\n\t\t// Match `JSG_READONLY_INSTANCE_PROPERTY` behaviour\n\t\tObject.defineProperties(this, {\n\t\t\tid: {\n\t\t\t\tget() {\n\t\t\t\t\treturn id;\n\t\t\t\t},\n\t\t\t},\n\t\t\ttimestamp: {\n\t\t\t\tget() {\n\t\t\t\t\treturn timestamp;\n\t\t\t\t},\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tget() {\n\t\t\t\t\treturn body;\n\t\t\t\t},\n\t\t\t},\n\t\t\tattempts: {\n\t\t\t\tget() {\n\t\t\t\t\treturn attempts;\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\tretry() {\n\t\tif (!(this instanceof QueueMessage)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\tif (this.#controller[kRetryAll]) {\n\t\t\treturn;\n\t\t}\n\t\tif (this.#controller[kAckAll]) {\n\t\t\tconsole.warn(\n\t\t\t\t`Received a call to retry() on message ${this.id} after ackAll() was already called. ` +\n\t\t\t\t\t\"Calling retry() on a message after calling ackAll() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (this[kAck]) {\n\t\t\tconsole.warn(\n\t\t\t\t`Received a call to retry() on message ${this.id} after ack() was already called. ` +\n\t\t\t\t\t\"Calling retry() on a message after calling ack() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis[kRetry] = true;\n\t}\n\n\tack() {\n\t\tif (!(this instanceof QueueMessage)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\tif (this.#controller[kAckAll]) {\n\t\t\treturn;\n\t\t}\n\t\tif (this.#controller[kRetryAll]) {\n\t\t\tconsole.warn(\n\t\t\t\t`Received a call to ack() on message ${this.id} after retryAll() was already called. ` +\n\t\t\t\t\t\"Calling ack() on a message after calling retryAll() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (this[kRetry]) {\n\t\t\tconsole.warn(\n\t\t\t\t`Received a call to ack() on message ${this.id} after retry() was already called. ` +\n\t\t\t\t\t\"Calling ack() on a message after calling retry() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis[kAck] = true;\n\t}\n}\nclass QueueController<Body = unknown> /* MessageBatch */ {\n\t// https://github.com/cloudflare/workerd/blob/v1.20231218.0/src/workerd/api/queue.h#L198\n\treadonly queue!: string;\n\treadonly messages!: QueueMessage<Body>[];\n\treadonly metadata!: MessageBatchMetadata;\n\t[kRetryAll] = false;\n\t[kAckAll] = false;\n\n\tconstructor(\n\t\tflag: typeof kConstructFlag,\n\t\tqueueOption: string,\n\t\tmessagesOption: ServiceBindingQueueMessage<Body>[]\n\t) {\n\t\tif (flag !== kConstructFlag) {\n\t\t\tthrow new TypeError(\"Illegal constructor\");\n\t\t}\n\n\t\tconst queue = String(queueOption);\n\t\tconst messages = messagesOption.map(\n\t\t\t(message) => new QueueMessage(kConstructFlag, this, message)\n\t\t);\n\t\tconst metadata: MessageBatchMetadata = {\n\t\t\tmetrics: {\n\t\t\t\tbacklogCount: 0,\n\t\t\t\tbacklogBytes: 0,\n\t\t\t\toldestMessageTimestamp: new Date(0),\n\t\t\t},\n\t\t};\n\n\t\t// Match `JSG_READONLY_INSTANCE_PROPERTY` behaviour\n\t\tObject.defineProperties(this, {\n\t\t\tqueue: {\n\t\t\t\tget() {\n\t\t\t\t\treturn queue;\n\t\t\t\t},\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\tget() {\n\t\t\t\t\treturn messages;\n\t\t\t\t},\n\t\t\t},\n\t\t\tmetadata: {\n\t\t\t\tget() {\n\t\t\t\t\treturn metadata;\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\tretryAll() {\n\t\tif (!(this instanceof QueueController)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\tif (this[kAckAll]) {\n\t\t\tconsole.warn(\n\t\t\t\t\"Received a call to retryAll() after ackAll() was already called. \" +\n\t\t\t\t\t\"Calling retryAll() after calling ackAll() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis[kRetryAll] = true;\n\t}\n\n\tackAll() {\n\t\tif (!(this instanceof QueueController)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\tif (this[kRetryAll]) {\n\t\t\tconsole.warn(\n\t\t\t\t\"Received a call to ackAll() after retryAll() was already called. \" +\n\t\t\t\t\t\"Calling ackAll() after calling retryAll() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis[kAckAll] = true;\n\t}\n}\nexport function createMessageBatch<Body = unknown>(\n\tqueueName: string,\n\tmessages: ServiceBindingQueueMessage<Body>[]\n): MessageBatch<Body> {\n\tif (arguments.length === 0) {\n\t\t// `queueName` will be coerced to a `string`, but it must be defined\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'createMessageBatch': parameter 1 is not of type 'string'.\"\n\t\t);\n\t}\n\tif (!Array.isArray(messages)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'createMessageBatch': parameter 2 is not of type 'Array'.\"\n\t\t);\n\t}\n\treturn new QueueController(kConstructFlag, queueName, messages);\n}\nexport async function getQueueResult(\n\tbatch: QueueController,\n\tctx: ExecutionContext\n): Promise<FetcherQueueResult> {\n\t// noinspection SuspiciousTypeOfGuard\n\tif (!(batch instanceof QueueController)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'getQueueResult': parameter 1 is not of type 'MessageBatch'.\\n\" +\n\t\t\t\t\"You must call 'createMessageBatch()' to get a 'MessageBatch' instance.\"\n\t\t);\n\t}\n\t// noinspection SuspiciousTypeOfGuard\n\tif (!(ctx instanceof ExecutionContext)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'getQueueResult': parameter 2 is not of type 'ExecutionContext'.\\n\" +\n\t\t\t\t\"You must call 'createExecutionContext()' to get an 'ExecutionContext' instance.\"\n\t\t);\n\t}\n\tawait waitOnExecutionContext(ctx);\n\n\tconst retryMessages: QueueRetryMessage[] = [];\n\tconst explicitAcks: string[] = [];\n\tfor (const message of batch.messages) {\n\t\tif (message[kRetry]) {\n\t\t\tretryMessages.push({ msgId: message.id });\n\t\t}\n\t\tif (message[kAck]) {\n\t\t\texplicitAcks.push(message.id);\n\t\t}\n\t}\n\treturn {\n\t\toutcome: \"ok\",\n\t\tretryBatch: {\n\t\t\tretry: batch[kRetryAll],\n\t\t},\n\t\tackAll: batch[kAckAll],\n\t\tretryMessages,\n\t\texplicitAcks,\n\t};\n}\n\n// =============================================================================\n// Pages Functions `EventContext`\n// =============================================================================\n\nfunction hasASSETSServiceBinding(\n\tvalue: Record<string, unknown>\n): value is Record<string, unknown> & { ASSETS: Fetcher } {\n\treturn (\n\t\t\"ASSETS\" in value &&\n\t\ttypeof value.ASSETS === \"object\" &&\n\t\tvalue.ASSETS !== null &&\n\t\t\"fetch\" in value.ASSETS &&\n\t\ttypeof value.ASSETS.fetch === \"function\"\n\t);\n}\n\ninterface EventContextInit {\n\trequest: Request<unknown, IncomingRequestCfProperties>;\n\tfunctionPath?: string;\n\tnext?(request: Request): Response | Promise<Response>;\n\tparams?: Record<string, string | string[]>;\n\tdata?: Record<string, unknown>;\n}\n\nexport function createPagesEventContext<F extends PagesFunction>(\n\topts: EventContextInit\n): Parameters<F>[0] & { [kWaitUntil]: unknown[] } {\n\tif (typeof opts !== \"object\" || opts === null) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'createPagesEventContext': parameter 1 is not of type 'EventContextInit'.\"\n\t\t);\n\t}\n\tif (!(opts.request instanceof Request)) {\n\t\tthrow new TypeError(\n\t\t\t\"Incorrect type for the 'request' field on 'EventContextInit': the provided value is not of type 'Request'.\"\n\t\t);\n\t}\n\t// noinspection SuspiciousTypeOfGuard\n\tif (\n\t\topts.functionPath !== undefined &&\n\t\ttypeof opts.functionPath !== \"string\"\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"Incorrect type for the 'functionPath' field on 'EventContextInit': the provided value is not of type 'string'.\"\n\t\t);\n\t}\n\tif (opts.next !== undefined && typeof opts.next !== \"function\") {\n\t\tthrow new TypeError(\n\t\t\t\"Incorrect type for the 'next' field on 'EventContextInit': the provided value is not of type 'function'.\"\n\t\t);\n\t}\n\tif (\n\t\topts.params !== undefined &&\n\t\t!(typeof opts.params === \"object\" && opts.params !== null)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"Incorrect type for the 'params' field on 'EventContextInit': the provided value is not of type 'object'.\"\n\t\t);\n\t}\n\tif (\n\t\topts.data !== undefined &&\n\t\t!(typeof opts.data === \"object\" && opts.data !== null)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"Incorrect type for the 'data' field on 'EventContextInit': the provided value is not of type 'object'.\"\n\t\t);\n\t}\n\n\tif (!hasASSETSServiceBinding(env)) {\n\t\tthrow new TypeError(\n\t\t\t\"Cannot call `createPagesEventContext()` without defining `ASSETS` service binding\"\n\t\t);\n\t}\n\n\tconst ctx = createExecutionContext();\n\treturn {\n\t\t// If we might need to re-use this request, clone it\n\t\trequest: opts.next ? opts.request.clone() : opts.request,\n\t\tfunctionPath: opts.functionPath ?? \"\",\n\t\t[kWaitUntil]: ctx[kWaitUntil],\n\t\twaitUntil: ctx.waitUntil.bind(ctx),\n\t\tpassThroughOnException: ctx.passThroughOnException.bind(ctx),\n\t\tasync next(nextInput, nextInit) {\n\t\t\tif (opts.next === undefined) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\"Cannot call `EventContext#next()` without including `next` property in 2nd argument to `createPagesEventContext()`\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (nextInput === undefined) {\n\t\t\t\treturn opts.next(opts.request);\n\t\t\t} else {\n\t\t\t\tif (typeof nextInput === \"string\") {\n\t\t\t\t\tnextInput = new URL(nextInput, opts.request.url).toString();\n\t\t\t\t}\n\t\t\t\tconst nextRequest = new Request(nextInput, nextInit);\n\t\t\t\treturn opts.next(nextRequest);\n\t\t\t}\n\t\t},\n\t\tenv,\n\t\tparams: opts.params ?? {},\n\t\tdata: opts.data ?? {},\n\t};\n}\n","import workerdUnsafe from \"workerd:unsafe\";\n\nexport async function reset(): Promise<void> {\n\tawait workerdUnsafe.deleteAllDurableObjects();\n}\n\nexport async function abortAllDurableObjects(): Promise<void> {\n\tawait workerdUnsafe.abortAllDurableObjects();\n}\n","import type { SecretsStoreSecretAdmin } from \"miniflare\";\n\n// Must match ADMIN_API in miniflare/src/workers/secrets-store/constants.ts\nconst ADMIN_API = \"SecretsStoreSecret::admin_api\";\n\n/**\n * Returns the admin API for a secrets store binding, allowing tests to\n * create, update, and delete secrets that would otherwise be read-only.\n *\n * ```ts\n * import { adminSecretsStore } from \"cloudflare:test\";\n *\n * const admin = adminSecretsStore(env.MY_SECRET);\n * await admin.create(\"my-secret-value\");\n * ```\n */\nexport function adminSecretsStore(binding: unknown): SecretsStoreSecretAdmin {\n\tif (\n\t\ttypeof binding !== \"object\" ||\n\t\tbinding === null ||\n\t\ttypeof (binding as Record<string, unknown>)[ADMIN_API] !== \"function\"\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'adminSecretsStore': parameter 1 is not a secrets store binding.\"\n\t\t);\n\t}\n\n\treturn (binding as Record<string, (...args: unknown[]) => unknown>)[\n\t\tADMIN_API\n\t]() as SecretsStoreSecretAdmin;\n}\n","import type { ResolvedStepConfig } from \"./context\";\nimport type {\n\tDatabaseInstance,\n\tDatabaseVersion,\n\tDatabaseWorkflow,\n} from \"./engine\";\nimport type { WorkflowEvent } from \"cloudflare:workers\";\n\nexport type Instance = {\n\tid: string;\n\tcreated_on: string;\n\tmodified_on: string;\n\tworkflow_id: string;\n\tversion_id: string;\n\tstatus: InstanceStatus;\n\tstarted_on: string | null;\n\tended_on: string | null;\n};\n\nexport const INSTANCE_METADATA = `INSTANCE_METADATA`;\n\nexport type InstanceMetadata = {\n\taccountId: number;\n\tworkflow: DatabaseWorkflow;\n\tversion: DatabaseVersion;\n\tinstance: DatabaseInstance;\n\tevent: WorkflowEvent<unknown>;\n};\n\nexport enum InstanceStatus {\n\tQueued = 0, // Queued and waiting to start\n\tRunning = 1,\n\tPaused = 2, // TODO (WOR-73): Implement pause\n\tErrored = 3, // Stopped due to a user or system Error\n\tTerminated = 4, // Stopped explicitly by user\n\tComplete = 5, // Successful completion\n\tWaitingForPause = 6,\n\tWaiting = 7,\n}\n\nexport function instanceStatusName(status: InstanceStatus) {\n\tswitch (status) {\n\t\tcase InstanceStatus.Queued:\n\t\t\treturn \"queued\";\n\t\tcase InstanceStatus.Running:\n\t\t\treturn \"running\";\n\t\tcase InstanceStatus.Paused:\n\t\t\treturn \"paused\";\n\t\tcase InstanceStatus.Errored:\n\t\t\treturn \"errored\";\n\t\tcase InstanceStatus.Terminated:\n\t\t\treturn \"terminated\";\n\t\tcase InstanceStatus.Complete:\n\t\t\treturn \"complete\";\n\t\tcase InstanceStatus.WaitingForPause:\n\t\t\treturn \"waitingForPause\";\n\t\tcase InstanceStatus.Waiting:\n\t\t\treturn \"waiting\";\n\t\tdefault:\n\t\t\treturn \"unknown\";\n\t}\n}\n\nexport const instanceStatusNames = [\n\t\"queued\",\n\t\"running\",\n\t\"paused\",\n\t\"errored\",\n\t\"terminated\",\n\t\"complete\",\n\t\"waitingForPause\",\n\t\"waiting\",\n\t\"unknown\",\n] as const;\n\nexport function toInstanceStatus(status: string): InstanceStatus {\n\tswitch (status) {\n\t\tcase \"queued\":\n\t\t\treturn InstanceStatus.Queued;\n\t\tcase \"running\":\n\t\t\treturn InstanceStatus.Running;\n\t\tcase \"paused\":\n\t\t\treturn InstanceStatus.Paused;\n\t\tcase \"errored\":\n\t\t\treturn InstanceStatus.Errored;\n\t\tcase \"terminated\":\n\t\t\treturn InstanceStatus.Terminated;\n\t\tcase \"complete\":\n\t\t\treturn InstanceStatus.Complete;\n\t\tcase \"waitingForPause\":\n\t\t\treturn InstanceStatus.WaitingForPause;\n\t\tcase \"waiting\":\n\t\t\treturn InstanceStatus.Waiting;\n\t\tcase \"unknown\":\n\t\t\tthrow new Error(\"unknown cannot be parsed into a InstanceStatus\");\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`${status} was not handled because it's not a valid InstanceStatus`\n\t\t\t);\n\t}\n}\n\nexport const enum InstanceEvent {\n\tWORKFLOW_QUEUED = 0,\n\tWORKFLOW_START = 1,\n\tWORKFLOW_SUCCESS = 2,\n\tWORKFLOW_FAILURE = 3,\n\tWORKFLOW_TERMINATED = 4,\n\n\tSTEP_START = 5,\n\tSTEP_SUCCESS = 6,\n\tSTEP_FAILURE = 7,\n\n\tSLEEP_START = 8,\n\tSLEEP_COMPLETE = 9,\n\n\tATTEMPT_START = 10,\n\tATTEMPT_SUCCESS = 11,\n\tATTEMPT_FAILURE = 12,\n\n\t// It's here just to make it sequential and to not have gaps in the event types.\n\t__INTERNAL_PROD = 13,\n\n\tWAIT_START = 14,\n\tWAIT_COMPLETE = 15,\n\tWAIT_TIMED_OUT = 16,\n}\n\nexport const enum InstanceTrigger {\n\tAPI = 0,\n\tBINDING = 1,\n\tEVENT = 2,\n\tCRON = 3,\n}\n\nexport function instanceTriggerName(trigger: InstanceTrigger) {\n\tswitch (trigger) {\n\t\tcase InstanceTrigger.API:\n\t\t\treturn \"api\";\n\t\tcase InstanceTrigger.BINDING:\n\t\t\treturn \"binding\";\n\t\tcase InstanceTrigger.EVENT:\n\t\t\treturn \"event\";\n\t\tcase InstanceTrigger.CRON:\n\t\t\treturn \"cron\";\n\t\tdefault:\n\t\t\treturn \"unknown\";\n\t}\n}\n\nexport type RawInstanceLog = {\n\tid: number;\n\ttimestamp: string;\n\tevent: InstanceEvent;\n\tgroupKey: string | null;\n\ttarget: string | null;\n\tmetadata: string;\n};\n\nexport type InstanceAttempt = {\n\tstart: string;\n\tend: string | null;\n\tsuccess: boolean | null;\n\terror: { name: string; message: string } | null;\n};\n\nexport type InstanceStepLog = {\n\tname: string;\n\tstart: string;\n\tend: string | null;\n\tattempts: InstanceAttempt[];\n\tconfig: ResolvedStepConfig;\n\toutput: unknown;\n\tsuccess: boolean | null;\n\ttype: \"step\";\n};\n\nexport type InstanceSleepLog = {\n\tname: string;\n\tstart: string;\n\tend: string;\n\tfinished: boolean;\n\ttype: \"sleep\";\n};\n\nexport type InstanceTerminateLog = {\n\ttype: \"termination\";\n\ttrigger: {\n\t\tsource: string;\n\t};\n};\n\nexport type InstanceLogsResponse = {\n\tparams: Record<string, unknown>;\n\ttrigger: {\n\t\tsource: ReturnType<typeof instanceTriggerName>;\n\t};\n\tversionId: string;\n\tqueued: string;\n\tstart: string | null;\n\tend: string | null;\n\tsteps: (InstanceStepLog | InstanceSleepLog | InstanceTerminateLog)[];\n\tsuccess: boolean | null;\n\terror: { name: string; message: string } | null;\n\toutput: Rpc.Serializable<unknown>;\n};\n\nexport type WakerPriorityEntry = {\n\thash: string;\n\ttype: WakerPriorityType;\n\ttargetTimestamp: number;\n};\n\nexport type WakerPriorityType = \"sleep\" | \"retry\" | \"timeout\";\n","import {\n\tinstanceStatusName,\n\tInstanceStatus as InstanceStatusNumber,\n} from \"@cloudflare/workflows-shared/src/instance\";\nimport { env } from \"cloudflare:workers\";\nimport { runInRunnerObject } from \"./durable-objects\";\nimport type { WorkflowBinding } from \"@cloudflare/workflows-shared/src/binding\";\nimport type {\n\tStepSelector,\n\tWorkflowInstanceModifier,\n} from \"@cloudflare/workflows-shared/src/modifier\";\n\ntype ModifierCallback = (m: WorkflowInstanceModifier) => Promise<void>;\n\n// See public facing `cloudflare:test` types for docs\nexport interface WorkflowInstanceIntrospector {\n\tmodify(fn: ModifierCallback): Promise<WorkflowInstanceIntrospector>;\n\n\twaitForStepResult(step: StepSelector): Promise<unknown>;\n\n\twaitForStatus(status: string): Promise<void>;\n\n\tdispose(): Promise<void>;\n}\n\n// Note(osilva): `introspectWorkflowInstance()` doesn’t need to be async, but we keep it that way\n// to avoid potential breaking changes later and to stay consistent with `introspectWorkflow`.\n\n// In the \"cloudflare:test\" module, the exposed type is `Workflow`. Here we use `WorkflowBinding`\n// (which implements `Workflow`) to access unsafe functions.\nexport async function introspectWorkflowInstance(\n\tworkflow: WorkflowBinding,\n\tinstanceId: string\n): Promise<WorkflowInstanceIntrospector> {\n\tif (!workflow || !instanceId) {\n\t\tthrow new Error(\n\t\t\t\"[WorkflowIntrospector] Workflow binding and instance id are required.\"\n\t\t);\n\t}\n\treturn new WorkflowInstanceIntrospectorHandle(workflow, instanceId);\n}\n\nclass WorkflowInstanceIntrospectorHandle implements WorkflowInstanceIntrospector {\n\t#workflow: WorkflowBinding;\n\t#instanceId: string;\n\t#instanceModifier: WorkflowInstanceModifier | undefined;\n\t#instanceModifierPromise: Promise<WorkflowInstanceModifier> | undefined;\n\n\tconstructor(workflow: WorkflowBinding, instanceId: string) {\n\t\tthis.#workflow = workflow;\n\t\tthis.#instanceId = instanceId;\n\t\tthis.#instanceModifierPromise = workflow\n\t\t\t.unsafeGetInstanceModifier(instanceId)\n\t\t\t.then((res) => {\n\t\t\t\tthis.#instanceModifier = res as WorkflowInstanceModifier;\n\t\t\t\tthis.#instanceModifierPromise = undefined;\n\t\t\t\treturn this.#instanceModifier;\n\t\t\t});\n\t}\n\n\tasync modify(fn: ModifierCallback): Promise<WorkflowInstanceIntrospector> {\n\t\tif (this.#instanceModifierPromise !== undefined) {\n\t\t\tthis.#instanceModifier = await this.#instanceModifierPromise;\n\t\t}\n\t\tif (this.#instanceModifier === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"could not apply modifications due to internal error. Retrying the test may resolve the issue.\"\n\t\t\t);\n\t\t}\n\n\t\tawait fn(this.#instanceModifier);\n\n\t\treturn this;\n\t}\n\n\tasync waitForStepResult(step: StepSelector): Promise<unknown> {\n\t\tconst stepResult = await this.#workflow.unsafeWaitForStepResult(\n\t\t\tthis.#instanceId,\n\t\t\tstep.name,\n\t\t\tstep.index\n\t\t);\n\n\t\treturn stepResult;\n\t}\n\n\tasync waitForStatus(status: InstanceStatus[\"status\"]): Promise<void> {\n\t\tif (status === instanceStatusName(InstanceStatusNumber.Queued)) {\n\t\t\t// we currently don't have a queue mechanism, but it would happen before it\n\t\t\t// starts running, so waiting for it to be queued should always return\n\t\t\treturn;\n\t\t}\n\t\tawait this.#workflow.unsafeWaitForStatus(this.#instanceId, status);\n\t}\n\n\tasync getOutput(): Promise<unknown> {\n\t\treturn await this.#workflow.unsafeGetOutputOrError(this.#instanceId, true);\n\t}\n\n\tasync getError(): Promise<{ name: string; message: string }> {\n\t\treturn (await this.#workflow.unsafeGetOutputOrError(\n\t\t\tthis.#instanceId,\n\t\t\tfalse\n\t\t)) as { name: string; message: string };\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tawait this.#workflow.unsafeAbort(this.#instanceId, \"Instance dispose\");\n\t}\n\n\tasync [Symbol.asyncDispose](): Promise<void> {\n\t\tawait this.dispose();\n\t}\n}\n\n// See public facing `cloudflare:test` types for docs\nexport interface WorkflowIntrospector {\n\tmodifyAll(fn: ModifierCallback): Promise<void>;\n\n\tget(): WorkflowInstanceIntrospector[];\n\n\tdispose(): Promise<void>;\n}\n\n// Note(osilva): `introspectWorkflow` could be sync with some changes, but we keep it async\n// to avoid potential breaking changes later.\n\n// In the \"cloudflare:test\" module, the exposed type is `Workflow`. Here we use `WorkflowBinding`\n// (which implements `Workflow`) to access unsafe functions.\nexport async function introspectWorkflow(\n\tworkflow: WorkflowBinding\n): Promise<WorkflowIntrospectorHandle> {\n\tif (!workflow) {\n\t\tthrow new Error(\"[WorkflowIntrospector] Workflow binding is required.\");\n\t}\n\n\tconst modifierCallbacks: ModifierCallback[] = [];\n\tconst instanceIntrospectors: WorkflowInstanceIntrospector[] = [];\n\n\tconst bindingName = await workflow.unsafeGetBindingName();\n\tconst originalWorkflow = env[bindingName] as Workflow;\n\n\tconst introspectAndModifyInstance = async (instanceId: string) => {\n\t\ttry {\n\t\t\tawait runInRunnerObject(async () => {\n\t\t\t\tconst introspector = await introspectWorkflowInstance(\n\t\t\t\t\tworkflow,\n\t\t\t\t\tinstanceId\n\t\t\t\t);\n\t\t\t\tinstanceIntrospectors.push(introspector);\n\t\t\t\t// Apply any stored modifier functions\n\t\t\t\tfor (const callback of modifierCallbacks) {\n\t\t\t\t\tawait introspector.modify(callback);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error(\n\t\t\t\t`[WorkflowIntrospector] Error during introspection for instance ${instanceId}:`,\n\t\t\t\terror\n\t\t\t);\n\t\t\tthrow new Error(\n\t\t\t\t`[WorkflowIntrospector] Failed to introspect Workflow instance ${instanceId}.`\n\t\t\t);\n\t\t}\n\t};\n\n\tconst createWorkflowProxyGetHandler = <\n\t\tT extends Workflow,\n\t>(): ProxyHandler<T>[\"get\"] => {\n\t\treturn (target, property) => {\n\t\t\tif (property === \"create\") {\n\t\t\t\treturn new Proxy(target[property], {\n\t\t\t\t\tasync apply(func, thisArg, argArray) {\n\t\t\t\t\t\tconst hasId = Object.hasOwn(argArray[0] ?? {}, \"id\");\n\t\t\t\t\t\tif (!hasId) {\n\t\t\t\t\t\t\targArray = [{ id: crypto.randomUUID(), ...(argArray[0] ?? {}) }];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst instanceId = (argArray[0] as { id: string }).id;\n\n\t\t\t\t\t\tawait introspectAndModifyInstance(instanceId);\n\n\t\t\t\t\t\treturn target[property](...argArray);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (property === \"createBatch\") {\n\t\t\t\treturn new Proxy(target[property], {\n\t\t\t\t\tasync apply(func, thisArg, argArray) {\n\t\t\t\t\t\tfor (const [index, arg] of argArray[0]?.entries() ?? []) {\n\t\t\t\t\t\t\tconst hasId = Object.hasOwn(arg, \"id\");\n\t\t\t\t\t\t\tif (!hasId) {\n\t\t\t\t\t\t\t\targArray[0][index] = { id: crypto.randomUUID(), ...arg };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\targArray[0].map((options: { id: string }) =>\n\t\t\t\t\t\t\t\tintrospectAndModifyInstance(options.id)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst createPromises = (argArray[0] ?? []).map(\n\t\t\t\t\t\t\t(arg: WorkflowInstanceCreateOptions) => target[\"create\"](arg)\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn Promise.all(createPromises);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\t// @ts-expect-error index signature\n\t\t\treturn target[property];\n\t\t};\n\t};\n\n\tconst dispose = () => {\n\t\tenv[bindingName] = originalWorkflow;\n\t};\n\n\t// Create a single handler instance to be reused\n\tconst proxyGetHandler = createWorkflowProxyGetHandler();\n\n\t// Apply the proxies using the shared handler logic\n\n\tenv[bindingName] = new Proxy(originalWorkflow, {\n\t\tget: proxyGetHandler,\n\t});\n\n\treturn new WorkflowIntrospectorHandle(\n\t\tworkflow,\n\t\tmodifierCallbacks,\n\t\tinstanceIntrospectors,\n\t\tdispose\n\t);\n}\n\nclass WorkflowIntrospectorHandle implements WorkflowIntrospector {\n\tworkflow: WorkflowBinding;\n\t#modifierCallbacks: ModifierCallback[];\n\t#instanceIntrospectors: WorkflowInstanceIntrospector[];\n\t#disposeCallback: () => void;\n\n\tconstructor(\n\t\tworkflow: WorkflowBinding,\n\t\tmodifierCallbacks: ModifierCallback[],\n\t\tinstanceIntrospectors: WorkflowInstanceIntrospector[],\n\t\tdisposeCallback: () => void\n\t) {\n\t\tthis.workflow = workflow;\n\t\tthis.#modifierCallbacks = modifierCallbacks;\n\t\tthis.#instanceIntrospectors = instanceIntrospectors;\n\t\tthis.#disposeCallback = disposeCallback;\n\t}\n\n\tasync modifyAll(fn: ModifierCallback): Promise<void> {\n\t\tthis.#modifierCallbacks.push(fn);\n\t}\n\n\tget(): WorkflowInstanceIntrospector[] {\n\t\treturn this.#instanceIntrospectors;\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\t// Restore the original env binding immediately so the next test gets a\n\t\t// clean binding even if instance disposal (unsafeAbort) is still in flight.\n\t\tthis.#disposeCallback();\n\t\tconst introspectors = this.#instanceIntrospectors;\n\t\tthis.#modifierCallbacks = [];\n\t\tthis.#instanceIntrospectors = [];\n\t\t// Dispose all instance introspectors after binding is restored\n\t\tawait Promise.all(\n\t\t\tintrospectors.map((introspector) => introspector.dispose())\n\t\t);\n\t}\n\n\tasync [Symbol.asyncDispose](): Promise<void> {\n\t\tawait this.dispose();\n\t}\n}\n"],"mappings":";;;;;;AAAA,MAAM,gBAAgB;AAGtB,WAAW,QAAQ,OAAO,OAAO,SAAS;AACzC,QAAO,cAAc,KAAK,YAAY,OAAO,KAAK;;;;;ACFnD,SAAS,aAAa,GAA6B;AAClD,QACC,OAAO,MAAM,YACb,MAAM,QACN,EAAE,YAAY,SAAS,gBACvB,aAAa,KACb,OAAO,EAAE,YAAY,cACrB,WAAW,KACX,OAAO,EAAE,UAAU,cACnB,UAAU,KACV,OAAO,EAAE,SAAS;;AAIpB,SAAS,cAAc,GAA8B;AACpD,QACC,OAAO,MAAM,YACb,MAAM,QACN,UAAU,KACV,OAAO,EAAE,SAAS,YAClB,aAAa,KACb,MAAM,QAAQ,EAAE,QAAQ,IACxB,EAAE,QAAQ,OAAO,UAAU,OAAO,UAAU,SAAS;;AAGvD,SAAS,eAAe,GAAgC;AACvD,QAAO,MAAM,QAAQ,EAAE,IAAI,EAAE,MAAM,cAAc;;AAGlD,eAAsB,kBACrB,IACA,YACA,sBAAsB,iBACrB;AACD,KAAI,CAAC,aAAa,GAAG,CACpB,OAAM,IAAI,UACT,kFACA;AAEF,KAAI,CAAC,eAAe,WAAW,CAC9B,OAAM,IAAI,UACT,qFACA;AAGF,KAAI,OAAO,wBAAwB,SAClC,OAAM,IAAI,UACT,8EACA;CAIF,MAAM,SAAS,8BAA8B,oBAAoB;;;;;AAKj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,CACvC,CACD;IAED,MAAM,kBAAkB,SAAS,MAAM,EAAE,EAAE,KACzC,QAAuC,OAAO,UAAU,IAAI,CAC7D;AACD,WAAO,QAAQ,IAAI,eAAe;MAEnC,CAAC;AAGH,UAAO,OAAO;;;CAIhB,MAAM,gBAAgB;AACrB,QAAI,eAAe;;CAIpB,MAAM,kBAAkB,+BAA+B;AAIvD,OAAI,eAAe,IAAI,MAAM,kBAAkB,EAC9C,KAAK,iBACL,CAAC;AAEF,QAAO,IAAI,2BACV,UACA,mBACA,uBACA,QACA;;AAGF,IAAM,6BAAN,MAAiE;CAChE;CACA;CACA;CACA;CAEA,YACC,UACA,mBACA,uBACA,iBACC;AACD,OAAK,WAAW;AAChB,QAAKC,oBAAqB;AAC1B,QAAKC,wBAAyB;AAC9B,QAAKC,kBAAmB;;CAGzB,MAAM,UAAU,IAAqC;AACpD,QAAKF,kBAAmB,KAAK,GAAG;;CAGjC,MAAsC;AACrC,SAAO,MAAKC;;CAGb,MAAM,UAAyB;AAG9B,QAAKC,iBAAkB;EACvB,MAAM,gBAAgB,MAAKD;AAC3B,QAAKD,oBAAqB,EAAE;AAC5B,QAAKC,wBAAyB,EAAE;AAEhC,QAAM,QAAQ,IACb,cAAc,KAAK,iBAAiB,aAAa,SAAS,CAAC,CAC3D;;CAGF,OAAO,OAAO,gBAA+B;AAC5C,QAAM,KAAK,SAAS"}
|
|
1
|
+
{"version":3,"file":"test-internal.mjs","names":["sameIsolatedNamespaces: DurableObjectNamespace[] | undefined","env","errors: unknown[]","timeoutId: ReturnType<typeof setTimeout> | undefined","globalWaitUntil: unknown[]","exports","runtimeEnv","env","DurableObjectClass","#controller","timestamp: Date","attempts: number","metadata: MessageBatchMetadata","retryMessages: QueueRetryMessage[]","explicitAcks: string[]","#workflow","#instanceId","#instanceModifierPromise","#instanceModifier","InstanceStatusNumber","modifierCallbacks: ModifierCallback[]","instanceIntrospectors: WorkflowInstanceIntrospector[]","env","#modifierCallbacks","#instanceIntrospectors","#disposeCallback"],"sources":["../../../../src/worker/fetch-mock.ts","../../../../src/worker/d1.ts","../../../../src/worker/env.ts","../../../../src/worker/durable-objects.ts","../../../../src/worker/wait-until.ts","../../../../src/worker/patch-ctx.ts","../../../../src/worker/entrypoints.ts","../../../../src/worker/events.ts","../../../../src/worker/reset.ts","../../../../src/worker/secrets-store.ts","../../../../../workflows-shared/src/instance.ts","../../../../src/worker/workflows.ts"],"sourcesContent":["const originalFetch = fetch;\n\n// Monkeypatch `fetch()`. This looks like a no-op, but it's not. It allows MSW to intercept fetch calls using it's Fetch interceptor.\nglobalThis.fetch = async (input, init) => {\n\treturn originalFetch.call(globalThis, input, init);\n};\n","import type { D1Migration } from \"../shared/d1\";\n\nfunction isD1Database(v: unknown): v is D1Database {\n\treturn (\n\t\ttypeof v === \"object\" &&\n\t\tv !== null &&\n\t\tv.constructor.name === \"D1Database\" &&\n\t\t\"prepare\" in v &&\n\t\ttypeof v.prepare === \"function\" &&\n\t\t\"batch\" in v &&\n\t\ttypeof v.batch === \"function\" &&\n\t\t\"exec\" in v &&\n\t\ttypeof v.exec === \"function\"\n\t);\n}\n\nfunction isD1Migration(v: unknown): v is D1Migration {\n\treturn (\n\t\ttypeof v === \"object\" &&\n\t\tv !== null &&\n\t\t\"name\" in v &&\n\t\ttypeof v.name === \"string\" &&\n\t\t\"queries\" in v &&\n\t\tArray.isArray(v.queries) &&\n\t\tv.queries.every((query) => typeof query === \"string\")\n\t);\n}\nfunction isD1Migrations(v: unknown): v is D1Migration[] {\n\treturn Array.isArray(v) && v.every(isD1Migration);\n}\n\nexport async function applyD1Migrations(\n\tdb: D1Database,\n\tmigrations: D1Migration[],\n\tmigrationsTableName = \"d1_migrations\"\n) {\n\tif (!isD1Database(db)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'applyD1Migrations': parameter 1 is not of type 'D1Database'.\"\n\t\t);\n\t}\n\tif (!isD1Migrations(migrations)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'applyD1Migrations': parameter 2 is not of type 'D1Migration[]'.\"\n\t\t);\n\t}\n\t// noinspection SuspiciousTypeOfGuard\n\tif (typeof migrationsTableName !== \"string\") {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'applyD1Migrations': parameter 3 is not of type 'string'.\"\n\t\t);\n\t}\n\n\t// Create migrations table if it doesn't exist\n\tconst schema = `CREATE TABLE IF NOT EXISTS ${migrationsTableName} (\n\t\tid INTEGER PRIMARY KEY AUTOINCREMENT,\n\t\tname TEXT UNIQUE,\n\t\tapplied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL\n\t);`;\n\tawait db.prepare(schema).run();\n\n\t// Find applied migrations\n\tconst appliedMigrationNamesResult = await db\n\t\t.prepare(`SELECT name FROM ${migrationsTableName};`)\n\t\t.all<{ name: string }>();\n\tconst appliedMigrationNames = appliedMigrationNamesResult.results.map(\n\t\t({ name }) => name\n\t);\n\n\t// Apply un-applied migrations\n\tconst insertMigrationStmt = db.prepare(\n\t\t`INSERT INTO ${migrationsTableName} (name) VALUES (?);`\n\t);\n\tfor (const migration of migrations) {\n\t\tif (appliedMigrationNames.includes(migration.name)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst queries = migration.queries.map((query) => db.prepare(query));\n\t\tqueries.push(insertMigrationStmt.bind(migration.name));\n\t\tawait db.batch(queries);\n\t}\n}\n","import assert from \"node:assert\";\nimport { exports } from \"cloudflare:workers\";\n\nexport { env } from \"cloudflare:workers\";\n\n/**\n * For reasons that aren't clear to me, just `SELF = exports.default` ends up with SELF being\n * undefined in a test. This Proxy solution works.\n */\nexport const SELF = new Proxy(\n\t{},\n\t{\n\t\tget(_, p) {\n\t\t\tconst target = exports.default as unknown as Record<\n\t\t\t\tstring | symbol,\n\t\t\t\tunknown\n\t\t\t>;\n\t\t\tconst value = target[p];\n\t\t\treturn typeof value === \"function\" ? value.bind(target) : value;\n\t\t},\n\t}\n);\n\nexport function getSerializedOptions(): SerializedOptions {\n\tassert(typeof __vitest_worker__ === \"object\", \"Expected global Vitest state\");\n\tconst options = __vitest_worker__.providedContext.cloudflarePoolOptions;\n\t// `options` should always be defined when running tests\n\n\tassert(\n\t\toptions !== undefined,\n\t\t\"Expected serialised options, got keys: \" +\n\t\t\tObject.keys(__vitest_worker__.providedContext).join(\", \")\n\t);\n\tconst parsedOptions = JSON.parse(options);\n\treturn {\n\t\t...parsedOptions,\n\t\tdurableObjectBindingDesignators: new Map(\n\t\t\tparsedOptions.durableObjectBindingDesignators\n\t\t),\n\t};\n}\n\nexport function getResolvedMainPath(\n\tforBindingType: \"service\" | \"Durable Object\"\n): string {\n\tconst options = getSerializedOptions();\n\tif (options.main === undefined) {\n\t\tthrow new Error(\n\t\t\t`Using ${forBindingType} bindings to the current worker requires \\`poolOptions.workers.main\\` to be set to your worker's entrypoint: ${JSON.stringify(options)}`\n\t\t);\n\t}\n\treturn options.main;\n}\n","import assert from \"node:assert\";\nimport { env, exports } from \"cloudflare:workers\";\nimport { getSerializedOptions } from \"./env\";\nimport type { __VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__ } from \"./index\";\n\nconst CF_KEY_ACTION = \"vitestPoolWorkersDurableObjectAction\";\n\nlet nextActionId = 0;\nconst kUseResponse = Symbol(\"kUseResponse\");\nconst actionResults = new Map<number /* id */, unknown>();\n\nfunction isDurableObjectNamespace(v: unknown): v is DurableObjectNamespace {\n\treturn (\n\t\tv instanceof Object &&\n\t\t/^(?:Loopback)?DurableObjectNamespace$/.test(v.constructor.name) &&\n\t\t\"newUniqueId\" in v &&\n\t\ttypeof v.newUniqueId === \"function\" &&\n\t\t\"idFromName\" in v &&\n\t\ttypeof v.idFromName === \"function\" &&\n\t\t\"idFromString\" in v &&\n\t\ttypeof v.idFromString === \"function\" &&\n\t\t\"get\" in v &&\n\t\ttypeof v.get === \"function\"\n\t);\n}\nfunction isDurableObjectStub(v: unknown): v is DurableObjectStub {\n\treturn (\n\t\ttypeof v === \"object\" &&\n\t\tv !== null &&\n\t\t(v.constructor.name === \"DurableObject\" ||\n\t\t\tv.constructor.name === \"WorkerRpc\") &&\n\t\t\"fetch\" in v &&\n\t\ttypeof v.fetch === \"function\" &&\n\t\t\"id\" in v &&\n\t\ttypeof v.id === \"object\"\n\t);\n}\n\n// Whilst `sameIsolatedNamespaces` depends on `getSerializedOptions()`,\n// `durableObjectBindingDesignators` is derived from the user Durable Object\n// config. If this were to change, the Miniflare options would change too\n// restarting this worker. This means we only need to compute this once, as it\n// will automatically invalidate when needed.\nlet sameIsolatedNamespaces: DurableObjectNamespace[] | undefined;\nfunction getSameIsolateNamespaces(): DurableObjectNamespace[] {\n\tif (sameIsolatedNamespaces !== undefined) {\n\t\treturn sameIsolatedNamespaces;\n\t}\n\tsameIsolatedNamespaces = [];\n\n\tconst options = getSerializedOptions();\n\tif (options.durableObjectBindingDesignators === undefined) {\n\t\treturn sameIsolatedNamespaces;\n\t}\n\n\tfor (const [key, designator] of options.durableObjectBindingDesignators) {\n\t\t// We're assuming the user isn't able to guess the current worker name, so\n\t\t// if a `scriptName` is set, the designator is for another worker.\n\t\tif (designator.scriptName !== undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst namespace = env[key] ?? (exports as Record<string, unknown>)?.[key];\n\t\tassert(\n\t\t\tisDurableObjectNamespace(namespace),\n\t\t\t`Expected ${key} to be a DurableObjectNamespace binding`\n\t\t);\n\t\tsameIsolatedNamespaces.push(namespace);\n\t}\n\n\treturn sameIsolatedNamespaces;\n}\n\nfunction assertSameIsolate(stub: DurableObjectStub) {\n\t// Make sure our special `cf` requests get handled correctly and aren't\n\t// routed to user fetch handlers\n\tconst idString = stub.id.toString();\n\tconst namespaces = getSameIsolateNamespaces();\n\t// Try to recreate the stub's ID using each same-isolate namespace.\n\t// `idFromString()` will throw if the ID is not for that namespace.\n\t// If a call succeeds, we know the ID is for an object in this isolate.\n\tfor (const namespace of namespaces) {\n\t\ttry {\n\t\t\tnamespace.idFromString(idString);\n\t\t\treturn;\n\t\t} catch {}\n\t}\n\t// If no calls succeed, we know the ID is for an object outside this isolate,\n\t// and we won't be able to use the `actionResults` map to share data.\n\tthrow new Error(\n\t\t\"Durable Object test helpers can only be used with stubs pointing to objects defined within the same worker.\"\n\t);\n}\n\nasync function runInStub<O extends DurableObject, R>(\n\tstub: Fetcher,\n\tcallback: (instance: O, state: DurableObjectState) => R | Promise<R>\n): Promise<R> {\n\tconst id = nextActionId++;\n\tactionResults.set(id, callback);\n\n\tconst response = await stub.fetch(\"http://x\", {\n\t\tcf: { [CF_KEY_ACTION]: id },\n\t\t// Prevent the runtime from following redirects returned by the callback,\n\t\t// which would re-enter `maybeHandleRunRequest` with a consumed action ID.\n\t\tredirect: \"manual\",\n\t});\n\n\t// `result` may be `undefined`\n\tassert(actionResults.has(id), `Expected action result for ${id}`);\n\tconst result = actionResults.get(id);\n\tactionResults.delete(id);\n\n\tif (result === kUseResponse) {\n\t\treturn response as R;\n\t} else if (response.ok) {\n\t\treturn result as R;\n\t} else {\n\t\tthrow result;\n\t}\n}\n\n// See public facing `cloudflare:test` types for docs\n// (`async` so it throws asynchronously/rejects)\nexport async function runInDurableObject<O extends DurableObject, R>(\n\tstub: DurableObjectStub,\n\tcallback: (instance: O, state: DurableObjectState) => R | Promise<R>\n): Promise<R> {\n\tif (!isDurableObjectStub(stub)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'runInDurableObject': parameter 1 is not of type 'DurableObjectStub'.\"\n\t\t);\n\t}\n\tif (typeof callback !== \"function\") {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'runInDurableObject': parameter 2 is not of type 'function'.\"\n\t\t);\n\t}\n\n\tassertSameIsolate(stub);\n\treturn runInStub(stub, callback);\n}\n\nasync function runAlarm(instance: DurableObject, state: DurableObjectState) {\n\tconst alarm = await state.storage.getAlarm();\n\tif (alarm === null) {\n\t\treturn false;\n\t}\n\tawait state.storage.deleteAlarm();\n\tawait instance.alarm?.();\n\treturn true;\n}\n// See public facing `cloudflare:test` types for docs\n// (`async` so it throws asynchronously/rejects)\nexport async function runDurableObjectAlarm(\n\tstub: DurableObjectStub\n): Promise<boolean /* ran */> {\n\tif (!isDurableObjectStub(stub)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'runDurableObjectAlarm': parameter 1 is not of type 'DurableObjectStub'.\"\n\t\t);\n\t}\n\treturn await runInDurableObject(stub, runAlarm);\n}\n\n/**\n * Internal method for running `callback` inside the I/O context of the\n * Runner Durable Object.\n *\n * Tests run in this context by default. This is required for performing\n * operations that use Vitest's RPC mechanism as the Durable Object\n * owns the RPC WebSocket. For example, importing modules or sending logs.\n * Trying to perform those operations from a different context (e.g. within\n * a `export default { fetch() {} }` handler or user Durable Object's `fetch()`\n * handler) without using this function will result in a `Cannot perform I/O on\n * behalf of a different request` error.\n */\nexport function runInRunnerObject<R>(\n\tcallback: (\n\t\tinstance: __VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__\n\t) => R | Promise<R>\n): Promise<R> {\n\t// Runner DO is ephemeral (ColoLocalActorNamespace), which has .get(name)\n\t// instead of the standard idFromName()/get(id) API.\n\tconst ns = env[\"__VITEST_POOL_WORKERS_RUNNER_OBJECT\"] as unknown as {\n\t\tget(name: string): Fetcher;\n\t};\n\tconst stub = ns.get(\"singleton\");\n\treturn runInStub(stub, callback);\n}\n\nexport async function maybeHandleRunRequest(\n\trequest: Request,\n\tinstance: unknown,\n\tstate?: DurableObjectState\n): Promise<Response | undefined> {\n\tconst actionId = request.cf?.[CF_KEY_ACTION];\n\tif (actionId === undefined) {\n\t\treturn;\n\t}\n\n\tassert(typeof actionId === \"number\", `Expected numeric ${CF_KEY_ACTION}`);\n\ttry {\n\t\tconst callback = actionResults.get(actionId);\n\t\tassert(typeof callback === \"function\", `Expected callback for ${actionId}`);\n\t\tconst result = await callback(instance, state);\n\t\t// If the callback returns a `Response`, we can't pass it back to the\n\t\t// caller through `actionResults`. If we did that, we'd get a `Cannot\n\t\t// perform I/O on behalf of a different Durable Object` error if we\n\t\t// tried to use it. Instead, we set a flag in `actionResults` that\n\t\t// instructs the caller to use the `Response` returned by\n\t\t// `DurableObjectStub#fetch()` directly.\n\t\tif (result instanceof Response) {\n\t\t\tactionResults.set(actionId, kUseResponse);\n\t\t\treturn result;\n\t\t} else {\n\t\t\tactionResults.set(actionId, result);\n\t\t}\n\t\treturn new Response(null, { status: 204 });\n\t} catch (e) {\n\t\tactionResults.set(actionId, e);\n\t\treturn new Response(null, { status: 500 });\n\t}\n}\n\nexport async function listDurableObjectIds(\n\tnamespace: DurableObjectNamespace\n): Promise<DurableObjectId[]> {\n\tif (!isDurableObjectNamespace(namespace)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'listDurableObjectIds': parameter 1 is not of type 'DurableObjectNamespace'.\"\n\t\t);\n\t}\n\n\t// To get an instance of `DurableObjectNamespace`, the user must've bound the\n\t// namespace to the test runner worker, since `DurableObjectNamespace` has no\n\t// user-accessible constructor. This means `namespace` must be in `globalEnv`.\n\t// We can use this to find the bound name for this binding. We inject a\n\t// mapping between bound names and unique keys for namespaces. We then use\n\t// this to get a unique key and find all IDs on disk.\n\tconst boundName = Object.entries(env).find(\n\t\t(entry) => namespace === entry[1]\n\t)?.[0];\n\tassert(boundName !== undefined, \"Expected to find bound name for namespace\");\n\n\tconst options = getSerializedOptions();\n\tconst designator = options.durableObjectBindingDesignators?.get(boundName);\n\tassert(designator !== undefined, \"Expected to find designator for namespace\");\n\n\tlet uniqueKey = designator.unsafeUniqueKey;\n\tif (uniqueKey === undefined) {\n\t\tconst scriptName = designator.scriptName ?? options.selfName;\n\t\tconst className = designator.className;\n\t\tuniqueKey = `${scriptName}-${className}`;\n\t}\n\n\tconst url = `http://placeholder/durable-objects?unique_key=${encodeURIComponent(\n\t\tuniqueKey\n\t)}`;\n\tconst res = await env.__VITEST_POOL_WORKERS_LOOPBACK_SERVICE.fetch(url);\n\tassert.strictEqual(res.status, 200);\n\tconst ids = await res.json();\n\tassert(Array.isArray(ids));\n\treturn ids.map((id) => {\n\t\tassert(typeof id === \"string\");\n\t\treturn namespace.idFromString(id);\n\t});\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\n\n/**\n * In production, Workers have a 30-second limit for `waitUntil` promises.\n * We use the same limit here. If promises are still pending after this,\n * they almost certainly indicate a bug (e.g. a `waitUntil` promise that\n * will never resolve). We log a warning and move on so the test suite\n * doesn't hang indefinitely.\n */\nlet WAIT_UNTIL_TIMEOUT = 30_000;\n\n/** @internal — only exposed for tests */\nexport function setWaitUntilTimeout(ms: number): void {\n\tWAIT_UNTIL_TIMEOUT = ms;\n}\n\nconst kTimedOut = Symbol(\"kTimedOut\");\n\n/**\n * Empty array and wait for all promises to resolve until no more added.\n * If a single promise rejects, the rejection will be passed-through.\n * If multiple promises reject, the rejections will be aggregated.\n *\n * If any batch of promises hasn't settled after {@link WAIT_UNTIL_TIMEOUT}ms,\n * a warning is logged and the remaining promises are abandoned.\n */\nexport async function waitForWaitUntil(\n\t/* mut */ waitUntil: unknown[]\n): Promise<void> {\n\tconst errors: unknown[] = [];\n\n\twhile (waitUntil.length > 0) {\n\t\tconst batch = waitUntil.splice(0);\n\t\tlet timeoutId: ReturnType<typeof setTimeout> | undefined;\n\t\tconst result = await Promise.race([\n\t\t\tPromise.allSettled(batch).then((results) => ({ results })),\n\t\t\tnew Promise<typeof kTimedOut>(\n\t\t\t\t(resolve) =>\n\t\t\t\t\t(timeoutId = setTimeout(() => resolve(kTimedOut), WAIT_UNTIL_TIMEOUT))\n\t\t\t),\n\t\t]);\n\t\tclearTimeout(timeoutId);\n\n\t\tif (result === kTimedOut) {\n\t\t\t__console.warn(\n\t\t\t\t`[vitest-pool-workers] ${batch.length} waitUntil promise(s) did not ` +\n\t\t\t\t\t`resolve within ${WAIT_UNTIL_TIMEOUT / 1000}s and will be abandoned. ` +\n\t\t\t\t\t`This normally means your Worker's waitUntil handler has a bug ` +\n\t\t\t\t\t`that prevents it from settling (e.g. a fetch that never completes ` +\n\t\t\t\t\t`or a missing resolve/reject call).`\n\t\t\t);\n\t\t\t// Stop draining — any promises added during this batch are also abandoned\n\t\t\twaitUntil.length = 0;\n\t\t\tbreak;\n\t\t}\n\n\t\t// Record all rejected promises\n\t\tfor (const settled of result.results) {\n\t\t\tif (settled.status === \"rejected\") {\n\t\t\t\terrors.push(settled.reason);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (errors.length === 1) {\n\t\t// If there was only one rejection, rethrow it\n\t\tthrow errors[0];\n\t} else if (errors.length > 1) {\n\t\t// If there were more rejections, rethrow them all\n\t\tthrow new AggregateError(errors);\n\t}\n}\n\n// If isolated storage is enabled, we ensure all `waitUntil()`s are `await`ed at\n// the end of each test, as these may contain storage calls (e.g. caching\n// responses). Note we can't wait at the end of `.concurrent` tests, as we can't\n// track which `waitUntil()`s belong to which tests.\n//\n// If isolated storage is disabled, we ensure all `waitUntil()`s are `await`ed\n// at the end of each test *file*. This ensures we don't try to dispose the\n// runtime until all `waitUntil()`s complete.\nconst globalWaitUntil: unknown[] = [];\nexport function registerGlobalWaitUntil(promise: unknown) {\n\tglobalWaitUntil.push(promise);\n}\nexport function waitForGlobalWaitUntil(): Promise<void> {\n\treturn waitForWaitUntil(globalWaitUntil);\n}\n\nexport const handlerContextStore = new AsyncLocalStorage<ExecutionContext>();\nexport function registerHandlerAndGlobalWaitUntil(promise: Promise<unknown>) {\n\tconst handlerContext = handlerContextStore.getStore();\n\tif (handlerContext === undefined) {\n\t\tregisterGlobalWaitUntil(promise);\n\t} else {\n\t\t// `patchAndRunWithHandlerContext()` ensures handler `waitUntil()` calls\n\t\t// `registerGlobalWaitUntil()` too\n\t\thandlerContext.waitUntil(promise);\n\t}\n}\n","import { handlerContextStore, registerGlobalWaitUntil } from \"./wait-until\";\n\nconst patchedHandlerContexts = new WeakSet<ExecutionContext>();\n\n/**\n * Executes the given callback within the provided ExecutionContext,\n * patching the context to ensure that:\n *\n * - waitUntil calls are registered globally\n * - ctx.exports shows a warning if accessing missing exports\n */\nexport function patchAndRunWithHandlerContext<T>(\n\t/* mut */ ctx: ExecutionContext,\n\tcallback: () => T\n): T {\n\t// Ensure calls to `ctx.waitUntil()` registered with global wait-until\n\tif (!patchedHandlerContexts.has(ctx)) {\n\t\tpatchedHandlerContexts.add(ctx);\n\n\t\t// Patch `ctx.waitUntil()`\n\t\tconst originalWaitUntil = ctx.waitUntil;\n\t\tctx.waitUntil = (promise: Promise<unknown>) => {\n\t\t\tregisterGlobalWaitUntil(promise);\n\t\t\treturn originalWaitUntil.call(ctx, promise);\n\t\t};\n\n\t\t// Patch `ctx.exports`\n\t\tif (isCtxExportsEnabled(ctx.exports)) {\n\t\t\tObject.defineProperty(ctx, \"exports\", {\n\t\t\t\tvalue: getCtxExportsProxy(ctx.exports),\n\t\t\t});\n\t\t}\n\t}\n\treturn handlerContextStore.run(ctx, callback);\n}\n\n/**\n * Creates a proxy to the `ctx.exports` object that will warn the user if they attempt\n * to access an undefined property. This could be a valid mistake by the user or\n * it could mean that our static analysis of the main Worker's exports missed something.\n */\nexport function getCtxExportsProxy(\n\texports: Cloudflare.Exports\n): Cloudflare.Exports {\n\treturn new Proxy(exports, {\n\t\tget(target, p: keyof Cloudflare.Exports) {\n\t\t\tif (p in target) {\n\t\t\t\treturn target[p];\n\t\t\t}\n\t\t\tconsole.warn(\n\t\t\t\t`Attempted to access 'ctx.exports.${p}', which was not defined for the main Worker.\\n` +\n\t\t\t\t\t`Check that '${p}' is exported as an entry-point from the Worker.\\n` +\n\t\t\t\t\t`The '@cloudflare/vitest-pool-workers' integration tries to infer these exports by analyzing the source code of the main Worker.\\n`\n\t\t\t);\n\t\t\treturn undefined;\n\t\t},\n\t});\n}\n\n/**\n * Returns true if `ctx.exports` is enabled via compatibility flags.\n */\nexport function isCtxExportsEnabled(\n\texports: Cloudflare.Exports | undefined\n): exports is Cloudflare.Exports {\n\treturn (\n\t\t(globalThis as unknown as { Cloudflare: Cloudflare }).Cloudflare\n\t\t\t?.compatibilityFlags.enable_ctx_exports && exports !== undefined\n\t);\n}\n","import assert from \"node:assert\";\nimport {\n\tDurableObject as DurableObjectClass,\n\tenv as runtimeEnv,\n\tWorkerEntrypoint,\n\tWorkflowEntrypoint,\n} from \"cloudflare:workers\";\nimport { maybeHandleRunRequest, runInRunnerObject } from \"./durable-objects\";\nimport { getResolvedMainPath } from \"./env\";\nimport { patchAndRunWithHandlerContext } from \"./patch-ctx\";\n\n// =============================================================================\n// Common Entrypoint Helpers\n// =============================================================================\n\n/**\n * Internal method for importing a module using Vite's transformation and\n * execution pipeline. Can be called from any I/O context, and will ensure the\n * request is run from within the `__VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__`.\n */\nasync function importModule(\n\tspecifier: string\n): Promise<Record<string, unknown>> {\n\t/**\n\t * We need to run this import inside the Runner Object, or we get errors like:\n\t * - The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response. Refer to: https://developers.cloudflare.com/workers/observability/errors/\n\t * - Cannot perform I/O on behalf of a different Durable Object. I/O objects (such as streams, request/response bodies, and others) created in the context of one Durable Object cannot be accessed from a different Durable Object in the same isolate. This is a limitation of Cloudflare Workers which allows us to improve overall performance.\n\t */\n\treturn runInRunnerObject(() => {\n\t\treturn __vitest_mocker__.moduleRunner.import(specifier);\n\t});\n}\n\nconst IGNORED_KEYS = [\"self\"];\n\n/**\n * Create a class extending `superClass` with a `Proxy` as a `prototype`.\n * Unknown accesses on the `prototype` will defer to `getUnknownPrototypeKey()`.\n * `workerd` will only look for RPC methods/properties on the prototype, not the\n * instance. This helps avoid accidentally exposing things over RPC, but makes\n * things a little trickier for us...\n */\nfunction createProxyPrototypeClass<\n\tT extends\n\t\t| typeof WorkerEntrypoint\n\t\t| typeof DurableObjectClass\n\t\t| typeof WorkflowEntrypoint,\n\tExtraPrototype = unknown,\n>(\n\tsuperClass: T,\n\tgetUnknownPrototypeKey: (key: string) => unknown\n): T & { prototype: ExtraPrototype } {\n\t// Build a class with a \"Proxy\"-prototype, so we can intercept RPC calls\n\tfunction Class(...args: ConstructorParameters<typeof superClass>) {\n\t\t// Delay proxying prototype until construction, so workerd sees this as a\n\t\t// regular class when introspecting it. This check fails if we don't do this:\n\t\t// https://github.com/cloudflare/workerd/blob/9e915ed637d65adb3c57522607d2cd8b8d692b6b/src/workerd/io/worker.c%2B%2B#L1920-L1921\n\t\tClass.prototype = new Proxy(Class.prototype, {\n\t\t\tget(target, key, receiver) {\n\t\t\t\tconst value = Reflect.get(target, key, receiver);\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t\t// noinspection SuspiciousTypeOfGuard\n\t\t\t\tif (typeof key === \"symbol\" || IGNORED_KEYS.includes(key)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\treturn getUnknownPrototypeKey.call(receiver, key as string);\n\t\t\t},\n\t\t});\n\n\t\treturn Reflect.construct(superClass, args, Class);\n\t}\n\n\tReflect.setPrototypeOf(Class.prototype, superClass.prototype);\n\tReflect.setPrototypeOf(Class, superClass);\n\n\treturn Class as unknown as T & { prototype: ExtraPrototype };\n}\n\n/**\n * Only properties and methods declared on the prototype can be accessed over\n * RPC. This function gets a property from the prototype if it's defined, and\n * throws a helpful error message if not. Note we need to distinguish between a\n * property that returns `undefined` and something not being defined at all.\n */\nfunction getRPCProperty(\n\tctor: WorkerEntrypointConstructor | DurableObjectConstructor,\n\tinstance:\n\t\t| WorkerEntrypoint<Record<string, unknown> | Cloudflare.Env>\n\t\t| DurableObjectClass<Record<string, unknown> | Cloudflare.Env>,\n\tkey: string\n): unknown {\n\tconst prototypeHasKey = Reflect.has(ctor.prototype, key);\n\tif (!prototypeHasKey) {\n\t\tconst quotedKey = JSON.stringify(key);\n\t\tconst instanceHasKey = Reflect.has(instance, key);\n\t\tlet message = \"\";\n\t\tif (instanceHasKey) {\n\t\t\tmessage = [\n\t\t\t\t`The RPC receiver's prototype does not implement ${quotedKey}, but the receiver instance does.`,\n\t\t\t\t\"Only properties and methods defined on the prototype can be accessed over RPC.\",\n\t\t\t\t`Ensure properties are declared like \\`get ${key}() { ... }\\` instead of \\`${key} = ...\\`,`,\n\t\t\t\t`and methods are declared like \\`${key}() { ... }\\` instead of \\`${key} = () => { ... }\\`.`,\n\t\t\t].join(\"\\n\");\n\t\t} else {\n\t\t\tmessage = `The RPC receiver does not implement ${quotedKey}.`;\n\t\t}\n\t\tthrow new TypeError(message);\n\t}\n\n\t// `receiver` is the value of `this` provided if a getter is encountered\n\treturn Reflect.get(/* target */ ctor.prototype, key, /* receiver */ instance);\n}\n\n/**\n * When calling RPC methods dynamically, we don't know whether the `property`\n * returned from `getSELFRPCProperty()` or `getDurableObjectRPCProperty()` below\n * is just a property or a method. If we just returned `property`, but the\n * client tried to call it as a method, `workerd` would throw an \"x is not a\n * function\" error.\n *\n * Instead, we return a *callable, custom thenable*. This behaves like a\n * function and a `Promise`! If `workerd` calls it, we'll wait for the promise\n * to resolve then forward the call. Otherwise, this just appears like a regular\n * async property. Note all client calls are async, so converting sync\n * properties and methods to async is fine here.\n *\n * Unfortunately, wrapping `property` with a `Proxy` and an `apply()` trap gives\n * `TypeError: Method Promise.prototype.then called on incompatible receiver #<Promise>`. :(\n */\nfunction getRPCPropertyCallableThenable(\n\tkey: string,\n\tproperty: Promise<unknown>\n) {\n\tconst fn = async function (...args: unknown[]) {\n\t\tconst maybeFn = await property;\n\t\tif (typeof maybeFn === \"function\") {\n\t\t\treturn maybeFn(...args);\n\t\t} else {\n\t\t\tthrow new TypeError(`${JSON.stringify(key)} is not a function.`);\n\t\t}\n\t} as Promise<unknown> & ((...args: unknown[]) => Promise<unknown>);\n\tfn.then = (onFulfilled, onRejected) => property.then(onFulfilled, onRejected);\n\tfn.catch = (onRejected) => property.catch(onRejected);\n\tfn.finally = (onFinally) => property.finally(onFinally);\n\treturn fn;\n}\n\n/**\n * `ctx` and `env` are defined as `protected` within `WorkerEntrypoint` and\n * `DurableObjectClass`. Usually this isn't a problem, as `protected` members\n * can be accessed from subclasses defined with `class extends` keywords.\n * Unfortunately, we have to define our classes with a `Proxy` prototype to\n * support forwarding RPC. This prevents us accessing `protected` members.\n * Instead, we define this function to extract these members, and provide type\n * safety for callers.\n */\nfunction getEntrypointState(instance: WorkerEntrypoint<Cloudflare.Env>): {\n\tctx: ExecutionContext;\n\tenv: Cloudflare.Env;\n};\nfunction getEntrypointState(instance: DurableObjectClass<Cloudflare.Env>): {\n\tctx: DurableObjectState;\n\tenv: Cloudflare.Env;\n};\nfunction getEntrypointState(\n\tinstance:\n\t\t| WorkerEntrypoint<Cloudflare.Env>\n\t\t| DurableObjectClass<Cloudflare.Env>\n) {\n\treturn instance as unknown as {\n\t\tctx: ExecutionContext | DurableObjectState;\n\t\tenv: Cloudflare.Env;\n\t};\n}\n\nconst WORKER_ENTRYPOINT_KEYS = [\n\t\"connect\",\n\t\"tailStream\",\n\t\"fetch\",\n\t\"tail\",\n\t\"trace\",\n\t\"scheduled\",\n\t\"queue\",\n\t\"test\",\n\t\"email\",\n] as const;\nconst DURABLE_OBJECT_KEYS = [\n\t\"connect\",\n\t\"fetch\",\n\t\"alarm\",\n\t\"webSocketMessage\",\n\t\"webSocketClose\",\n\t\"webSocketError\",\n] as const;\n\n// This type will grab the keys from T and remove \"branded\" keys\ntype UnbrandedKeys<T> = Exclude<keyof T, `__${string}_BRAND`>;\n\n// Check that we've included all possible keys\n// noinspection JSUnusedLocalSymbols\nconst _workerEntrypointExhaustive: (typeof WORKER_ENTRYPOINT_KEYS)[number] =\n\tundefined as unknown as UnbrandedKeys<WorkerEntrypoint<Cloudflare.Env>>;\n// noinspection JSUnusedLocalSymbols\nconst _durableObjectExhaustive: (typeof DURABLE_OBJECT_KEYS)[number] =\n\tundefined as unknown as UnbrandedKeys<DurableObjectClass<Cloudflare.Env>>;\n\n// =============================================================================\n// `WorkerEntrypoint` wrappers\n// =============================================================================\n\n// `WorkerEntrypoint` is `abstract`, so we need to cast before constructing\ntype WorkerEntrypointConstructor = {\n\tnew (\n\t\t...args: ConstructorParameters<typeof WorkerEntrypoint>\n\t): WorkerEntrypoint;\n};\n\n/**\n * Get the export to use for `entrypoint`. This is used for the `SELF` service\n * binding in `cloudflare:test`, which sets `entrypoint` to \"default\".\n * This requires importing the `main` module with Vite.\n */\nasync function getWorkerEntrypointExport(\n\tenv: Cloudflare.Env,\n\tentrypoint: string\n): Promise<{ mainPath: string; entrypointValue: unknown }> {\n\tconst mainPath = getResolvedMainPath(\"service\");\n\tconst mainModule = await importModule(mainPath);\n\tconst entrypointValue =\n\t\ttypeof mainModule === \"object\" &&\n\t\tmainModule !== null &&\n\t\tentrypoint in mainModule &&\n\t\tmainModule[entrypoint];\n\tif (!entrypointValue) {\n\t\tconst message =\n\t\t\t`${mainPath} does not export a ${entrypoint} entrypoint. \\`@cloudflare/vitest-pool-workers\\` does not support service workers or named entrypoints for \\`SELF\\`.\\n` +\n\t\t\t\"If you're using service workers, please migrate to the modules format: https://developers.cloudflare.com/workers/reference/migrate-to-module-workers.\";\n\t\tthrow new TypeError(message);\n\t}\n\treturn { mainPath, entrypointValue };\n}\n\n/**\n * Get a property named `key` from the user's `WorkerEntrypoint`. `wrapper` here\n * is an instance of a `WorkerEntrypoint` wrapper (i.e. the return value of\n * `createWorkerEntrypointWrapper()`). This requires importing the `main` module\n * with Vite, so will always return a `Promise.`\n */\nasync function getWorkerEntrypointRPCProperty(\n\twrapper: WorkerEntrypoint<Cloudflare.Env>,\n\tentrypoint: string,\n\tkey: string\n): Promise<unknown> {\n\tconst { ctx } = getEntrypointState(wrapper);\n\tconst { mainPath, entrypointValue } = await getWorkerEntrypointExport(\n\t\truntimeEnv as Cloudflare.Env,\n\t\tentrypoint\n\t);\n\t// Ensure constructor and properties execute with ctx `AsyncLocalStorage` set\n\treturn patchAndRunWithHandlerContext(ctx, () => {\n\t\t// Use the dynamic env from `cloudflare:workers` to respect `withEnv()`\n\t\tconst env = runtimeEnv as Cloudflare.Env;\n\t\tconst expectedWorkerEntrypointMessage = `Expected ${entrypoint} export of ${mainPath} to be a subclass of \\`WorkerEntrypoint\\` for RPC`;\n\t\tif (typeof entrypointValue !== \"function\") {\n\t\t\tthrow new TypeError(expectedWorkerEntrypointMessage);\n\t\t}\n\t\tconst ctor = entrypointValue as WorkerEntrypointConstructor;\n\t\tconst instance = new ctor(ctx, env);\n\t\t// noinspection SuspiciousTypeOfGuard\n\t\tif (!(instance instanceof WorkerEntrypoint)) {\n\t\t\tthrow new TypeError(expectedWorkerEntrypointMessage);\n\t\t}\n\n\t\tconst value = getRPCProperty(ctor, instance, key);\n\t\tif (typeof value === \"function\") {\n\t\t\t// If this is a function, ensure it executes with ctx `AsyncLocalStorage`\n\t\t\t// set, and with a correctly bound `this`\n\t\t\treturn (...args: unknown[]) =>\n\t\t\t\tpatchAndRunWithHandlerContext(ctx, () => value.apply(instance, args));\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t});\n}\n\nexport function createWorkerEntrypointWrapper(\n\tentrypoint: string\n): typeof WorkerEntrypoint {\n\tconst Wrapper = createProxyPrototypeClass(\n\t\tWorkerEntrypoint,\n\t\tfunction (this: WorkerEntrypoint<Cloudflare.Env>, key) {\n\t\t\t// All `ExportedHandler` keys are reserved and cannot be called over RPC\n\t\t\tif ((DURABLE_OBJECT_KEYS as readonly string[]).includes(key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst property = getWorkerEntrypointRPCProperty(this, entrypoint, key);\n\t\t\treturn getRPCPropertyCallableThenable(key, property);\n\t\t}\n\t);\n\n\t// Add prototype methods for all default handlers\n\tfor (const key of WORKER_ENTRYPOINT_KEYS) {\n\t\tWrapper.prototype[key] = async function (\n\t\t\tthis: WorkerEntrypoint<Cloudflare.Env>,\n\t\t\tthing: unknown\n\t\t) {\n\t\t\tconst { mainPath, entrypointValue } = await getWorkerEntrypointExport(\n\t\t\t\tthis.env,\n\t\t\t\tentrypoint\n\t\t\t);\n\n\t\t\treturn patchAndRunWithHandlerContext(this.ctx, () => {\n\t\t\t\tif (typeof entrypointValue === \"object\" && entrypointValue !== null) {\n\t\t\t\t\t// Assuming the user has defined an `ExportedHandler`\n\t\t\t\t\tconst maybeFn = (entrypointValue as Record<string, unknown>)[key];\n\t\t\t\t\tif (typeof maybeFn === \"function\") {\n\t\t\t\t\t\treturn maybeFn.call(entrypointValue, thing, runtimeEnv, this.ctx);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to define a \\`${key}()\\` function`;\n\t\t\t\t\t\tthrow new TypeError(message);\n\t\t\t\t\t}\n\t\t\t\t} else if (typeof entrypointValue === \"function\") {\n\t\t\t\t\t// Assuming the user has defined a `WorkerEntrypoint` subclass\n\t\t\t\t\tconst ctor = entrypointValue as WorkerEntrypointConstructor;\n\t\t\t\t\tconst instance = new ctor(this.ctx, runtimeEnv);\n\t\t\t\t\t// noinspection SuspiciousTypeOfGuard\n\t\t\t\t\tif (!(instance instanceof WorkerEntrypoint)) {\n\t\t\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to be a subclass of \\`WorkerEntrypoint\\``;\n\t\t\t\t\t\tthrow new TypeError(message);\n\t\t\t\t\t}\n\t\t\t\t\tconst maybeFn = instance[key];\n\t\t\t\t\tif (typeof maybeFn === \"function\") {\n\t\t\t\t\t\treturn (maybeFn as (arg: unknown) => unknown).call(instance, thing);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to define a \\`${key}()\\` method`;\n\t\t\t\t\t\tthrow new TypeError(message);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Assuming the user has messed up\n\t\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to be an object or a class, got ${entrypointValue}`;\n\t\t\t\t\tthrow new TypeError(message);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t}\n\treturn Wrapper;\n}\n\n// =============================================================================\n// `DurableObject` wrappers\n// =============================================================================\n\ntype DurableObjectConstructor = {\n\tnew (\n\t\t...args: ConstructorParameters<typeof DurableObjectClass>\n\t): DurableObject | DurableObjectClass;\n};\n\nconst kInstanceConstructor = Symbol(\"kInstanceConstructor\");\nconst kInstance = Symbol(\"kInstance\");\nconst kEnsureInstance = Symbol(\"kEnsureInstance\");\ntype DurableObjectWrapperExtraPrototype = {\n\t[kInstanceConstructor]: DurableObjectConstructor;\n\t[kInstance]:\n\t\t| DurableObject\n\t\t| DurableObjectClass<Record<string, unknown> | Cloudflare.Env>;\n\t[kEnsureInstance](): Promise<{\n\t\tmainPath: string;\n\t\tinstanceCtor: DurableObjectConstructor;\n\t\tinstance:\n\t\t\t| DurableObject\n\t\t\t| DurableObjectClass<Record<string, unknown> | Cloudflare.Env>;\n\t}>;\n};\ntype DurableObjectWrapper = DurableObjectClass<Cloudflare.Env> &\n\tDurableObjectWrapperExtraPrototype;\n\nasync function getDurableObjectRPCProperty(\n\twrapper: DurableObjectWrapper,\n\tclassName: string,\n\tkey: string\n): Promise<unknown> {\n\tconst { mainPath, instanceCtor, instance } = await wrapper[kEnsureInstance]();\n\tif (!(instance instanceof DurableObjectClass)) {\n\t\tconst message = `Expected ${className} exported by ${mainPath} be a subclass of \\`DurableObject\\` for RPC`;\n\t\tthrow new TypeError(message);\n\t}\n\tconst value = getRPCProperty(instanceCtor, instance, key);\n\tif (typeof value === \"function\") {\n\t\t// If this is a function, ensure correctly bound `this`\n\t\treturn value.bind(instance);\n\t} else {\n\t\treturn value;\n\t}\n}\n\nexport function createDurableObjectWrapper(\n\tclassName: string\n): typeof DurableObjectClass {\n\tconst Wrapper = createProxyPrototypeClass<\n\t\ttypeof DurableObjectClass,\n\t\tDurableObjectWrapperExtraPrototype\n\t>(DurableObjectClass, function (this: DurableObjectWrapper, key) {\n\t\t// All `ExportedHandler` keys are reserved and cannot be called over RPC\n\t\tif ((WORKER_ENTRYPOINT_KEYS as readonly string[]).includes(key)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst property = getDurableObjectRPCProperty(this, className, key);\n\t\treturn getRPCPropertyCallableThenable(key, property);\n\t});\n\n\tWrapper.prototype[kEnsureInstance] = async function (\n\t\tthis: DurableObjectWrapper\n\t) {\n\t\tconst { ctx, env } = getEntrypointState(this);\n\t\tconst mainPath = getResolvedMainPath(\"Durable Object\");\n\t\t// `ensureInstance()` may be called multiple times concurrently.\n\t\t// We're assuming `importModule()` will only import the module once.\n\t\tconst mainModule = await importModule(mainPath);\n\t\tconst constructor = mainModule[className];\n\t\tif (typeof constructor !== \"function\") {\n\t\t\tthrow new TypeError(\n\t\t\t\t`${mainPath} does not export a ${className} Durable Object`\n\t\t\t);\n\t\t}\n\t\tthis[kInstanceConstructor] ??= constructor as DurableObjectConstructor;\n\t\tif (this[kInstanceConstructor] !== constructor) {\n\t\t\t// This would be if the module was invalidated\n\t\t\t// (i.e. source file changed), then the Durable Object was `fetch()`ed\n\t\t\t// again. We reset all Durable Object instances between each test, so it's\n\t\t\t// unlikely multiple constructors would be used by the same instance,\n\t\t\t// unless the user did something funky with Durable Objects outside tests.\n\t\t\tawait ctx.blockConcurrencyWhile<never>(() => {\n\t\t\t\t// Throw inside `blockConcurrencyWhile()` to abort this object\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${mainPath} changed, invalidating this Durable Object. ` +\n\t\t\t\t\t\t\"Please retry the `DurableObjectStub#fetch()` call.\"\n\t\t\t\t);\n\t\t\t});\n\t\t\tassert.fail(\"Unreachable\");\n\t\t}\n\t\tif (this[kInstance] === undefined) {\n\t\t\tthis[kInstance] = new this[kInstanceConstructor](ctx, env);\n\t\t\t// Wait for any `blockConcurrencyWhile()`s in the constructor to complete\n\t\t\tawait ctx.blockConcurrencyWhile(async () => {});\n\t\t}\n\t\treturn {\n\t\t\tmainPath,\n\t\t\tinstanceCtor: this[kInstanceConstructor],\n\t\t\tinstance: this[kInstance],\n\t\t};\n\t};\n\n\t// Add prototype method for `fetch` handler to handle `runInDurableObject()`s\n\tWrapper.prototype.fetch = async function (\n\t\tthis: DurableObjectWrapper,\n\t\trequest: Request\n\t) {\n\t\tconst { ctx } = getEntrypointState(this);\n\n\t\t// Make sure we've initialised user code\n\t\tconst { mainPath, instance } = await this[kEnsureInstance]();\n\n\t\t// If this is an internal Durable Object action, handle it...\n\t\tconst response = await maybeHandleRunRequest(request, instance, ctx);\n\t\tif (response !== undefined) {\n\t\t\treturn response;\n\t\t}\n\n\t\t// Otherwise, pass through to the user code\n\t\tif (instance.fetch === undefined) {\n\t\t\tconst message = `${className} exported by ${mainPath} does not define a \\`fetch()\\` method`;\n\t\t\tthrow new TypeError(message);\n\t\t}\n\t\treturn instance.fetch(request);\n\t};\n\n\t// Add prototype methods for all other default handlers\n\tfor (const key of DURABLE_OBJECT_KEYS) {\n\t\tif (key === \"fetch\") {\n\t\t\tcontinue;\n\t\t} // `fetch()` has special handling above\n\t\tWrapper.prototype[key] = async function (\n\t\t\tthis: DurableObjectWrapper,\n\t\t\t...args: unknown[]\n\t\t) {\n\t\t\tconst { mainPath, instance } = await this[kEnsureInstance]();\n\t\t\tconst maybeFn = instance[key];\n\t\t\tif (typeof maybeFn === \"function\") {\n\t\t\t\treturn (maybeFn as (...a: unknown[]) => void).apply(instance, args);\n\t\t\t} else {\n\t\t\t\tconst message = `${className} exported by ${mainPath} does not define a \\`${key}()\\` method`;\n\t\t\t\tthrow new TypeError(message);\n\t\t\t}\n\t\t};\n\t}\n\n\treturn Wrapper;\n}\n\n// =============================================================================\n// `WorkflowEntrypoint` wrappers\n// =============================================================================\n\ntype WorkflowEntrypointConstructor = {\n\tnew (\n\t\t...args: ConstructorParameters<typeof WorkflowEntrypoint>\n\t): WorkflowEntrypoint;\n};\n\nexport function createWorkflowEntrypointWrapper(entrypoint: string) {\n\tconst Wrapper = createProxyPrototypeClass(\n\t\tWorkflowEntrypoint,\n\t\tfunction (this: WorkflowEntrypoint<Cloudflare.Env>, key) {\n\t\t\t// only Workflow `run` should be exposed over RPC\n\t\t\tif (![\"run\"].includes(key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst property = getWorkerEntrypointRPCProperty(\n\t\t\t\tthis as unknown as WorkerEntrypoint<Cloudflare.Env>,\n\t\t\t\tentrypoint,\n\t\t\t\tkey\n\t\t\t);\n\t\t\treturn getRPCPropertyCallableThenable(key, property);\n\t\t}\n\t);\n\n\tWrapper.prototype.run = async function (\n\t\tthis: WorkflowEntrypoint<Cloudflare.Env>,\n\t\t...args\n\t) {\n\t\tconst { mainPath, entrypointValue } = await getWorkerEntrypointExport(\n\t\t\truntimeEnv,\n\t\t\tentrypoint\n\t\t);\n\t\t// workflow entrypoint value should always be a constructor\n\t\tif (typeof entrypointValue === \"function\") {\n\t\t\t// Assuming the user has defined a `WorkflowEntrypoint` subclass\n\t\t\tconst ctor = entrypointValue as WorkflowEntrypointConstructor;\n\t\t\tconst instance = new ctor(this.ctx, runtimeEnv);\n\t\t\t// noinspection SuspiciousTypeOfGuard\n\t\t\tif (!(instance instanceof WorkflowEntrypoint)) {\n\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to be a subclass of \\`WorkflowEntrypoint\\``;\n\t\t\t\tthrow new TypeError(message);\n\t\t\t}\n\t\t\tconst maybeFn = instance[\"run\"];\n\t\t\tif (typeof maybeFn === \"function\") {\n\t\t\t\treturn patchAndRunWithHandlerContext(this.ctx, () =>\n\t\t\t\t\tmaybeFn.call(instance, ...args)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to define a \\`run()\\` method, but got ${typeof maybeFn}`;\n\t\t\t\tthrow new TypeError(message);\n\t\t\t}\n\t\t} else {\n\t\t\t// Assuming the user has messed up\n\t\t\tconst message = `Expected ${entrypoint} export of ${mainPath} to be a subclass of \\`WorkflowEntrypoint\\`, but got ${entrypointValue}`;\n\t\t\tthrow new TypeError(message);\n\t\t}\n\t};\n\n\treturn Wrapper;\n}\n","import { exports } from \"cloudflare:workers\";\nimport { env } from \"./env\";\nimport { getCtxExportsProxy, isCtxExportsEnabled } from \"./patch-ctx\";\nimport { registerGlobalWaitUntil, waitForWaitUntil } from \"./wait-until\";\n\n// `workerd` doesn't allow these internal classes to be constructed directly.\n// To replicate this behaviour require this unique symbol to be specified as the\n// first constructor argument. If this is missing, throw `Illegal invocation`.\nconst kConstructFlag = Symbol(\"kConstructFlag\");\n\n// See public facing `cloudflare:test` types for docs.\n\n// =============================================================================\n// `ExecutionContext`\n// =============================================================================\n\nconst kWaitUntil = Symbol(\"kWaitUntil\");\nclass ExecutionContext {\n\t// https://github.com/cloudflare/workerd/blob/v1.20231218.0/src/workerd/api/global-scope.h#L168\n\t[kWaitUntil]: unknown[] = [];\n\n\tconstructor(flag: typeof kConstructFlag) {\n\t\tif (flag !== kConstructFlag) {\n\t\t\tthrow new TypeError(\"Illegal constructor\");\n\t\t}\n\t}\n\n\t// Expose the ctx.exports from the main \"SELF\" Worker if there is one.\n\treadonly exports = isCtxExportsEnabled(exports)\n\t\t? getCtxExportsProxy(exports)\n\t\t: undefined;\n\n\twaitUntil(promise: unknown) {\n\t\tif (!(this instanceof ExecutionContext)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\tthis[kWaitUntil].push(promise);\n\t\tregisterGlobalWaitUntil(promise);\n\t}\n\n\tpassThroughOnException(): void {}\n}\nexport function createExecutionContext(): ExecutionContext {\n\treturn new ExecutionContext(kConstructFlag);\n}\n\nfunction isExecutionContextLike(v: unknown): v is { [kWaitUntil]: unknown[] } {\n\treturn (\n\t\ttypeof v === \"object\" &&\n\t\tv !== null &&\n\t\tkWaitUntil in v &&\n\t\tArray.isArray(v[kWaitUntil])\n\t);\n}\nexport async function waitOnExecutionContext(ctx: unknown): Promise<void> {\n\tif (!isExecutionContextLike(ctx)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'getWaitUntil': parameter 1 is not of type 'ExecutionContext'.\\n\" +\n\t\t\t\t\"You must call 'createExecutionContext()' or 'createPagesEventContext()' to get an 'ExecutionContext' instance.\"\n\t\t);\n\t}\n\treturn waitForWaitUntil(ctx[kWaitUntil]);\n}\n\n// =============================================================================\n// `ScheduledController`\n// =============================================================================\n\nclass ScheduledController {\n\t// https://github.com/cloudflare/workerd/blob/v1.20231218.0/src/workerd/api/scheduled.h#L35\n\treadonly scheduledTime!: number;\n\treadonly cron!: string;\n\n\tconstructor(flag: typeof kConstructFlag, options?: FetcherScheduledOptions) {\n\t\tif (flag !== kConstructFlag) {\n\t\t\tthrow new TypeError(\"Illegal constructor\");\n\t\t}\n\n\t\tconst scheduledTime = Number(options?.scheduledTime ?? Date.now());\n\t\tconst cron = String(options?.cron ?? \"\");\n\n\t\t// Match `JSG_READONLY_INSTANCE_PROPERTY` behaviour\n\t\tObject.defineProperties(this, {\n\t\t\tscheduledTime: {\n\t\t\t\tget() {\n\t\t\t\t\treturn scheduledTime;\n\t\t\t\t},\n\t\t\t},\n\t\t\tcron: {\n\t\t\t\tget() {\n\t\t\t\t\treturn cron;\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\tnoRetry(): void {\n\t\tif (!(this instanceof ScheduledController)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t}\n}\nexport function createScheduledController(\n\toptions?: FetcherScheduledOptions\n): ScheduledController {\n\tif (options !== undefined && typeof options !== \"object\") {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'createScheduledController': parameter 1 is not of type 'ScheduledOptions'.\"\n\t\t);\n\t}\n\treturn new ScheduledController(kConstructFlag, options);\n}\n\n// =============================================================================\n// `MessageBatch`\n// =============================================================================\n\nconst kRetry = Symbol(\"kRetry\");\nconst kAck = Symbol(\"kAck\");\nconst kRetryAll = Symbol(\"kRetryAll\");\nconst kAckAll = Symbol(\"kAckAll\");\nclass QueueMessage<Body = unknown> /* Message */ {\n\t// https://github.com/cloudflare/workerd/blob/v1.20231218.0/src/workerd/api/queue.h#L113\n\treadonly #controller: QueueController;\n\treadonly id!: string;\n\treadonly timestamp!: Date;\n\treadonly body!: Body;\n\treadonly attempts!: number;\n\t[kRetry] = false;\n\t[kAck] = false;\n\n\tconstructor(\n\t\tflag: typeof kConstructFlag,\n\t\tcontroller: QueueController,\n\t\tmessage: ServiceBindingQueueMessage<Body>\n\t) {\n\t\tif (flag !== kConstructFlag) {\n\t\t\tthrow new TypeError(\"Illegal constructor\");\n\t\t}\n\t\tthis.#controller = controller;\n\n\t\tconst id = String(message.id);\n\n\t\tlet timestamp: Date;\n\t\t// noinspection SuspiciousTypeOfGuard\n\t\tif (typeof message.timestamp === \"number\") {\n\t\t\ttimestamp = new Date(message.timestamp);\n\t\t} else if (message.timestamp instanceof Date) {\n\t\t\ttimestamp = new Date(message.timestamp.getTime()); // Prevent external mutations\n\t\t} else {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"Incorrect type for the 'timestamp' field on 'ServiceBindingQueueMessage': the provided value is not of type 'date'.\"\n\t\t\t);\n\t\t}\n\n\t\tlet attempts: number;\n\t\t// noinspection SuspiciousTypeOfGuard\n\t\tif (typeof message.attempts === \"number\") {\n\t\t\tattempts = message.attempts;\n\t\t} else {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"Incorrect type for the 'attempts' field on 'ServiceBindingQueueMessage': the provided value is not of type 'number'.\"\n\t\t\t);\n\t\t}\n\n\t\tif (\"serializedBody\" in message) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"Cannot use `serializedBody` with `createMessageBatch()`\"\n\t\t\t);\n\t\t}\n\t\tconst body = structuredClone(message.body); // Prevent external mutations\n\n\t\t// Match `JSG_READONLY_INSTANCE_PROPERTY` behaviour\n\t\tObject.defineProperties(this, {\n\t\t\tid: {\n\t\t\t\tget() {\n\t\t\t\t\treturn id;\n\t\t\t\t},\n\t\t\t},\n\t\t\ttimestamp: {\n\t\t\t\tget() {\n\t\t\t\t\treturn timestamp;\n\t\t\t\t},\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tget() {\n\t\t\t\t\treturn body;\n\t\t\t\t},\n\t\t\t},\n\t\t\tattempts: {\n\t\t\t\tget() {\n\t\t\t\t\treturn attempts;\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\tretry() {\n\t\tif (!(this instanceof QueueMessage)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\tif (this.#controller[kRetryAll]) {\n\t\t\treturn;\n\t\t}\n\t\tif (this.#controller[kAckAll]) {\n\t\t\tconsole.warn(\n\t\t\t\t`Received a call to retry() on message ${this.id} after ackAll() was already called. ` +\n\t\t\t\t\t\"Calling retry() on a message after calling ackAll() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (this[kAck]) {\n\t\t\tconsole.warn(\n\t\t\t\t`Received a call to retry() on message ${this.id} after ack() was already called. ` +\n\t\t\t\t\t\"Calling retry() on a message after calling ack() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis[kRetry] = true;\n\t}\n\n\tack() {\n\t\tif (!(this instanceof QueueMessage)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\tif (this.#controller[kAckAll]) {\n\t\t\treturn;\n\t\t}\n\t\tif (this.#controller[kRetryAll]) {\n\t\t\tconsole.warn(\n\t\t\t\t`Received a call to ack() on message ${this.id} after retryAll() was already called. ` +\n\t\t\t\t\t\"Calling ack() on a message after calling retryAll() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (this[kRetry]) {\n\t\t\tconsole.warn(\n\t\t\t\t`Received a call to ack() on message ${this.id} after retry() was already called. ` +\n\t\t\t\t\t\"Calling ack() on a message after calling retry() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis[kAck] = true;\n\t}\n}\nclass QueueController<Body = unknown> /* MessageBatch */ {\n\t// https://github.com/cloudflare/workerd/blob/v1.20231218.0/src/workerd/api/queue.h#L198\n\treadonly queue!: string;\n\treadonly messages!: QueueMessage<Body>[];\n\treadonly metadata!: MessageBatchMetadata;\n\t[kRetryAll] = false;\n\t[kAckAll] = false;\n\n\tconstructor(\n\t\tflag: typeof kConstructFlag,\n\t\tqueueOption: string,\n\t\tmessagesOption: ServiceBindingQueueMessage<Body>[]\n\t) {\n\t\tif (flag !== kConstructFlag) {\n\t\t\tthrow new TypeError(\"Illegal constructor\");\n\t\t}\n\n\t\tconst queue = String(queueOption);\n\t\tconst messages = messagesOption.map(\n\t\t\t(message) => new QueueMessage(kConstructFlag, this, message)\n\t\t);\n\t\tconst metadata: MessageBatchMetadata = {\n\t\t\tmetrics: {\n\t\t\t\tbacklogCount: 0,\n\t\t\t\tbacklogBytes: 0,\n\t\t\t\toldestMessageTimestamp: new Date(0),\n\t\t\t},\n\t\t};\n\n\t\t// Match `JSG_READONLY_INSTANCE_PROPERTY` behaviour\n\t\tObject.defineProperties(this, {\n\t\t\tqueue: {\n\t\t\t\tget() {\n\t\t\t\t\treturn queue;\n\t\t\t\t},\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\tget() {\n\t\t\t\t\treturn messages;\n\t\t\t\t},\n\t\t\t},\n\t\t\tmetadata: {\n\t\t\t\tget() {\n\t\t\t\t\treturn metadata;\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\tretryAll() {\n\t\tif (!(this instanceof QueueController)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\tif (this[kAckAll]) {\n\t\t\tconsole.warn(\n\t\t\t\t\"Received a call to retryAll() after ackAll() was already called. \" +\n\t\t\t\t\t\"Calling retryAll() after calling ackAll() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis[kRetryAll] = true;\n\t}\n\n\tackAll() {\n\t\tif (!(this instanceof QueueController)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\tif (this[kRetryAll]) {\n\t\t\tconsole.warn(\n\t\t\t\t\"Received a call to ackAll() after retryAll() was already called. \" +\n\t\t\t\t\t\"Calling ackAll() after calling retryAll() has no effect.\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tthis[kAckAll] = true;\n\t}\n}\nexport function createMessageBatch<Body = unknown>(\n\tqueueName: string,\n\tmessages: ServiceBindingQueueMessage<Body>[]\n): MessageBatch<Body> {\n\tif (arguments.length === 0) {\n\t\t// `queueName` will be coerced to a `string`, but it must be defined\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'createMessageBatch': parameter 1 is not of type 'string'.\"\n\t\t);\n\t}\n\tif (!Array.isArray(messages)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'createMessageBatch': parameter 2 is not of type 'Array'.\"\n\t\t);\n\t}\n\treturn new QueueController(kConstructFlag, queueName, messages);\n}\nexport async function getQueueResult(\n\tbatch: QueueController,\n\tctx: ExecutionContext\n): Promise<FetcherQueueResult> {\n\t// noinspection SuspiciousTypeOfGuard\n\tif (!(batch instanceof QueueController)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'getQueueResult': parameter 1 is not of type 'MessageBatch'.\\n\" +\n\t\t\t\t\"You must call 'createMessageBatch()' to get a 'MessageBatch' instance.\"\n\t\t);\n\t}\n\t// noinspection SuspiciousTypeOfGuard\n\tif (!(ctx instanceof ExecutionContext)) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'getQueueResult': parameter 2 is not of type 'ExecutionContext'.\\n\" +\n\t\t\t\t\"You must call 'createExecutionContext()' to get an 'ExecutionContext' instance.\"\n\t\t);\n\t}\n\tawait waitOnExecutionContext(ctx);\n\n\tconst retryMessages: QueueRetryMessage[] = [];\n\tconst explicitAcks: string[] = [];\n\tfor (const message of batch.messages) {\n\t\tif (message[kRetry]) {\n\t\t\tretryMessages.push({ msgId: message.id });\n\t\t}\n\t\tif (message[kAck]) {\n\t\t\texplicitAcks.push(message.id);\n\t\t}\n\t}\n\treturn {\n\t\toutcome: \"ok\",\n\t\tretryBatch: {\n\t\t\tretry: batch[kRetryAll],\n\t\t},\n\t\tackAll: batch[kAckAll],\n\t\tretryMessages,\n\t\texplicitAcks,\n\t};\n}\n\n// =============================================================================\n// Pages Functions `EventContext`\n// =============================================================================\n\nfunction hasASSETSServiceBinding(\n\tvalue: Record<string, unknown>\n): value is Record<string, unknown> & { ASSETS: Fetcher } {\n\treturn (\n\t\t\"ASSETS\" in value &&\n\t\ttypeof value.ASSETS === \"object\" &&\n\t\tvalue.ASSETS !== null &&\n\t\t\"fetch\" in value.ASSETS &&\n\t\ttypeof value.ASSETS.fetch === \"function\"\n\t);\n}\n\ninterface EventContextInit {\n\trequest: Request<unknown, IncomingRequestCfProperties>;\n\tfunctionPath?: string;\n\tnext?(request: Request): Response | Promise<Response>;\n\tparams?: Record<string, string | string[]>;\n\tdata?: Record<string, unknown>;\n}\n\nexport function createPagesEventContext<F extends PagesFunction>(\n\topts: EventContextInit\n): Parameters<F>[0] & { [kWaitUntil]: unknown[] } {\n\tif (typeof opts !== \"object\" || opts === null) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'createPagesEventContext': parameter 1 is not of type 'EventContextInit'.\"\n\t\t);\n\t}\n\tif (!(opts.request instanceof Request)) {\n\t\tthrow new TypeError(\n\t\t\t\"Incorrect type for the 'request' field on 'EventContextInit': the provided value is not of type 'Request'.\"\n\t\t);\n\t}\n\t// noinspection SuspiciousTypeOfGuard\n\tif (\n\t\topts.functionPath !== undefined &&\n\t\ttypeof opts.functionPath !== \"string\"\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"Incorrect type for the 'functionPath' field on 'EventContextInit': the provided value is not of type 'string'.\"\n\t\t);\n\t}\n\tif (opts.next !== undefined && typeof opts.next !== \"function\") {\n\t\tthrow new TypeError(\n\t\t\t\"Incorrect type for the 'next' field on 'EventContextInit': the provided value is not of type 'function'.\"\n\t\t);\n\t}\n\tif (\n\t\topts.params !== undefined &&\n\t\t!(typeof opts.params === \"object\" && opts.params !== null)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"Incorrect type for the 'params' field on 'EventContextInit': the provided value is not of type 'object'.\"\n\t\t);\n\t}\n\tif (\n\t\topts.data !== undefined &&\n\t\t!(typeof opts.data === \"object\" && opts.data !== null)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"Incorrect type for the 'data' field on 'EventContextInit': the provided value is not of type 'object'.\"\n\t\t);\n\t}\n\n\tif (!hasASSETSServiceBinding(env)) {\n\t\tthrow new TypeError(\n\t\t\t\"Cannot call `createPagesEventContext()` without defining `ASSETS` service binding\"\n\t\t);\n\t}\n\n\tconst ctx = createExecutionContext();\n\treturn {\n\t\t// If we might need to re-use this request, clone it\n\t\trequest: opts.next ? opts.request.clone() : opts.request,\n\t\tfunctionPath: opts.functionPath ?? \"\",\n\t\t[kWaitUntil]: ctx[kWaitUntil],\n\t\twaitUntil: ctx.waitUntil.bind(ctx),\n\t\tpassThroughOnException: ctx.passThroughOnException.bind(ctx),\n\t\tasync next(nextInput, nextInit) {\n\t\t\tif (opts.next === undefined) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\"Cannot call `EventContext#next()` without including `next` property in 2nd argument to `createPagesEventContext()`\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (nextInput === undefined) {\n\t\t\t\treturn opts.next(opts.request);\n\t\t\t} else {\n\t\t\t\tif (typeof nextInput === \"string\") {\n\t\t\t\t\tnextInput = new URL(nextInput, opts.request.url).toString();\n\t\t\t\t}\n\t\t\t\tconst nextRequest = new Request(nextInput, nextInit);\n\t\t\t\treturn opts.next(nextRequest);\n\t\t\t}\n\t\t},\n\t\tenv,\n\t\tparams: opts.params ?? {},\n\t\tdata: opts.data ?? {},\n\t};\n}\n","import workerdUnsafe from \"workerd:unsafe\";\n\nexport async function reset(): Promise<void> {\n\tawait workerdUnsafe.deleteAllDurableObjects();\n}\n\nexport async function abortAllDurableObjects(): Promise<void> {\n\tawait workerdUnsafe.abortAllDurableObjects();\n}\n","import type { SecretsStoreSecretAdmin } from \"miniflare\";\n\n// Must match ADMIN_API in miniflare/src/workers/secrets-store/constants.ts\nconst ADMIN_API = \"SecretsStoreSecret::admin_api\";\n\n/**\n * Returns the admin API for a secrets store binding, allowing tests to\n * create, update, and delete secrets that would otherwise be read-only.\n *\n * ```ts\n * import { adminSecretsStore } from \"cloudflare:test\";\n *\n * const admin = adminSecretsStore(env.MY_SECRET);\n * await admin.create(\"my-secret-value\");\n * ```\n */\nexport function adminSecretsStore(binding: unknown): SecretsStoreSecretAdmin {\n\tif (\n\t\ttypeof binding !== \"object\" ||\n\t\tbinding === null ||\n\t\ttypeof (binding as Record<string, unknown>)[ADMIN_API] !== \"function\"\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"Failed to execute 'adminSecretsStore': parameter 1 is not a secrets store binding.\"\n\t\t);\n\t}\n\n\treturn (binding as Record<string, (...args: unknown[]) => unknown>)[\n\t\tADMIN_API\n\t]() as SecretsStoreSecretAdmin;\n}\n","import type { ResolvedStepConfig } from \"./context\";\nimport type {\n\tDatabaseInstance,\n\tDatabaseVersion,\n\tDatabaseWorkflow,\n} from \"./engine\";\nimport type { WorkflowEvent } from \"cloudflare:workers\";\n\nexport type Instance = {\n\tid: string;\n\tcreated_on: string;\n\tmodified_on: string;\n\tworkflow_id: string;\n\tversion_id: string;\n\tstatus: InstanceStatus;\n\tstarted_on: string | null;\n\tended_on: string | null;\n};\n\nexport const INSTANCE_METADATA = `INSTANCE_METADATA`;\n\nexport type InstanceMetadata = {\n\taccountId: number;\n\tworkflow: DatabaseWorkflow;\n\tversion: DatabaseVersion;\n\tinstance: DatabaseInstance;\n\tevent: WorkflowEvent<unknown>;\n};\n\nexport enum InstanceStatus {\n\tQueued = 0, // Queued and waiting to start\n\tRunning = 1,\n\tPaused = 2, // TODO (WOR-73): Implement pause\n\tErrored = 3, // Stopped due to a user or system Error\n\tTerminated = 4, // Stopped explicitly by user\n\tComplete = 5, // Successful completion\n\tWaitingForPause = 6,\n\tWaiting = 7,\n}\n\nexport function instanceStatusName(status: InstanceStatus) {\n\tswitch (status) {\n\t\tcase InstanceStatus.Queued:\n\t\t\treturn \"queued\";\n\t\tcase InstanceStatus.Running:\n\t\t\treturn \"running\";\n\t\tcase InstanceStatus.Paused:\n\t\t\treturn \"paused\";\n\t\tcase InstanceStatus.Errored:\n\t\t\treturn \"errored\";\n\t\tcase InstanceStatus.Terminated:\n\t\t\treturn \"terminated\";\n\t\tcase InstanceStatus.Complete:\n\t\t\treturn \"complete\";\n\t\tcase InstanceStatus.WaitingForPause:\n\t\t\treturn \"waitingForPause\";\n\t\tcase InstanceStatus.Waiting:\n\t\t\treturn \"waiting\";\n\t\tdefault:\n\t\t\treturn \"unknown\";\n\t}\n}\n\nexport const instanceStatusNames = [\n\t\"queued\",\n\t\"running\",\n\t\"paused\",\n\t\"errored\",\n\t\"terminated\",\n\t\"complete\",\n\t\"waitingForPause\",\n\t\"waiting\",\n\t\"unknown\",\n] as const;\n\nexport function toInstanceStatus(status: string): InstanceStatus {\n\tswitch (status) {\n\t\tcase \"queued\":\n\t\t\treturn InstanceStatus.Queued;\n\t\tcase \"running\":\n\t\t\treturn InstanceStatus.Running;\n\t\tcase \"paused\":\n\t\t\treturn InstanceStatus.Paused;\n\t\tcase \"errored\":\n\t\t\treturn InstanceStatus.Errored;\n\t\tcase \"terminated\":\n\t\t\treturn InstanceStatus.Terminated;\n\t\tcase \"complete\":\n\t\t\treturn InstanceStatus.Complete;\n\t\tcase \"waitingForPause\":\n\t\t\treturn InstanceStatus.WaitingForPause;\n\t\tcase \"waiting\":\n\t\t\treturn InstanceStatus.Waiting;\n\t\tcase \"unknown\":\n\t\t\tthrow new Error(\"unknown cannot be parsed into a InstanceStatus\");\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`${status} was not handled because it's not a valid InstanceStatus`\n\t\t\t);\n\t}\n}\n\nexport const enum InstanceEvent {\n\tWORKFLOW_QUEUED = 0,\n\tWORKFLOW_START = 1,\n\tWORKFLOW_SUCCESS = 2,\n\tWORKFLOW_FAILURE = 3,\n\tWORKFLOW_TERMINATED = 4,\n\n\tSTEP_START = 5,\n\tSTEP_SUCCESS = 6,\n\tSTEP_FAILURE = 7,\n\n\tSLEEP_START = 8,\n\tSLEEP_COMPLETE = 9,\n\n\tATTEMPT_START = 10,\n\tATTEMPT_SUCCESS = 11,\n\tATTEMPT_FAILURE = 12,\n\n\t// It's here just to make it sequential and to not have gaps in the event types.\n\t__INTERNAL_PROD = 13,\n\n\tWAIT_START = 14,\n\tWAIT_COMPLETE = 15,\n\tWAIT_TIMED_OUT = 16,\n}\n\nexport const enum InstanceTrigger {\n\tAPI = 0,\n\tBINDING = 1,\n\tEVENT = 2,\n\tCRON = 3,\n}\n\nexport function instanceTriggerName(trigger: InstanceTrigger) {\n\tswitch (trigger) {\n\t\tcase InstanceTrigger.API:\n\t\t\treturn \"api\";\n\t\tcase InstanceTrigger.BINDING:\n\t\t\treturn \"binding\";\n\t\tcase InstanceTrigger.EVENT:\n\t\t\treturn \"event\";\n\t\tcase InstanceTrigger.CRON:\n\t\t\treturn \"cron\";\n\t\tdefault:\n\t\t\treturn \"unknown\";\n\t}\n}\n\nexport type RawInstanceLog = {\n\tid: number;\n\ttimestamp: string;\n\tevent: InstanceEvent;\n\tgroupKey: string | null;\n\ttarget: string | null;\n\tmetadata: string;\n};\n\nexport type InstanceAttempt = {\n\tstart: string;\n\tend: string | null;\n\tsuccess: boolean | null;\n\terror: { name: string; message: string } | null;\n};\n\nexport type InstanceStepLog = {\n\tname: string;\n\tstart: string;\n\tend: string | null;\n\tattempts: InstanceAttempt[];\n\tconfig: ResolvedStepConfig;\n\toutput: unknown;\n\tsuccess: boolean | null;\n\ttype: \"step\";\n};\n\nexport type InstanceSleepLog = {\n\tname: string;\n\tstart: string;\n\tend: string;\n\tfinished: boolean;\n\ttype: \"sleep\";\n};\n\nexport type InstanceTerminateLog = {\n\ttype: \"termination\";\n\ttrigger: {\n\t\tsource: string;\n\t};\n};\n\nexport type InstanceLogsResponse = {\n\tparams: Record<string, unknown>;\n\ttrigger: {\n\t\tsource: ReturnType<typeof instanceTriggerName>;\n\t};\n\tversionId: string;\n\tqueued: string;\n\tstart: string | null;\n\tend: string | null;\n\tsteps: (InstanceStepLog | InstanceSleepLog | InstanceTerminateLog)[];\n\tsuccess: boolean | null;\n\terror: { name: string; message: string } | null;\n\toutput: Rpc.Serializable<unknown>;\n};\n\nexport type WakerPriorityEntry = {\n\thash: string;\n\ttype: WakerPriorityType;\n\ttargetTimestamp: number;\n};\n\nexport type WakerPriorityType = \"sleep\" | \"retry\" | \"timeout\";\n","import {\n\tinstanceStatusName,\n\tInstanceStatus as InstanceStatusNumber,\n} from \"@cloudflare/workflows-shared/src/instance\";\nimport { env } from \"cloudflare:workers\";\nimport { runInRunnerObject } from \"./durable-objects\";\nimport type { WorkflowBinding } from \"@cloudflare/workflows-shared/src/binding\";\nimport type {\n\tStepSelector,\n\tWorkflowInstanceModifier,\n} from \"@cloudflare/workflows-shared/src/modifier\";\n\ntype ModifierCallback = (m: WorkflowInstanceModifier) => Promise<void>;\n\n// See public facing `cloudflare:test` types for docs\nexport interface WorkflowInstanceIntrospector {\n\tmodify(fn: ModifierCallback): Promise<WorkflowInstanceIntrospector>;\n\n\twaitForStepResult(step: StepSelector): Promise<unknown>;\n\n\twaitForStatus(status: string): Promise<void>;\n\n\tdispose(): Promise<void>;\n}\n\n// Note(osilva): `introspectWorkflowInstance()` doesn’t need to be async, but we keep it that way\n// to avoid potential breaking changes later and to stay consistent with `introspectWorkflow`.\n\n// In the \"cloudflare:test\" module, the exposed type is `Workflow`. Here we use `WorkflowBinding`\n// (which implements `Workflow`) to access unsafe functions.\nexport async function introspectWorkflowInstance(\n\tworkflow: WorkflowBinding,\n\tinstanceId: string\n): Promise<WorkflowInstanceIntrospector> {\n\tif (!workflow || !instanceId) {\n\t\tthrow new Error(\n\t\t\t\"[WorkflowIntrospector] Workflow binding and instance id are required.\"\n\t\t);\n\t}\n\treturn new WorkflowInstanceIntrospectorHandle(workflow, instanceId);\n}\n\nclass WorkflowInstanceIntrospectorHandle implements WorkflowInstanceIntrospector {\n\t#workflow: WorkflowBinding;\n\t#instanceId: string;\n\t#instanceModifier: WorkflowInstanceModifier | undefined;\n\t#instanceModifierPromise: Promise<WorkflowInstanceModifier> | undefined;\n\n\tconstructor(workflow: WorkflowBinding, instanceId: string) {\n\t\tthis.#workflow = workflow;\n\t\tthis.#instanceId = instanceId;\n\t\tthis.#instanceModifierPromise = workflow\n\t\t\t.unsafeGetInstanceModifier(instanceId)\n\t\t\t.then((res) => {\n\t\t\t\tthis.#instanceModifier = res as WorkflowInstanceModifier;\n\t\t\t\tthis.#instanceModifierPromise = undefined;\n\t\t\t\treturn this.#instanceModifier;\n\t\t\t});\n\t}\n\n\tasync modify(fn: ModifierCallback): Promise<WorkflowInstanceIntrospector> {\n\t\tif (this.#instanceModifierPromise !== undefined) {\n\t\t\tthis.#instanceModifier = await this.#instanceModifierPromise;\n\t\t}\n\t\tif (this.#instanceModifier === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"could not apply modifications due to internal error. Retrying the test may resolve the issue.\"\n\t\t\t);\n\t\t}\n\n\t\tawait fn(this.#instanceModifier);\n\n\t\treturn this;\n\t}\n\n\tasync waitForStepResult(step: StepSelector): Promise<unknown> {\n\t\tconst stepResult = await this.#workflow.unsafeWaitForStepResult(\n\t\t\tthis.#instanceId,\n\t\t\tstep.name,\n\t\t\tstep.index\n\t\t);\n\n\t\treturn stepResult;\n\t}\n\n\tasync waitForStatus(status: InstanceStatus[\"status\"]): Promise<void> {\n\t\tif (status === instanceStatusName(InstanceStatusNumber.Queued)) {\n\t\t\t// we currently don't have a queue mechanism, but it would happen before it\n\t\t\t// starts running, so waiting for it to be queued should always return\n\t\t\treturn;\n\t\t}\n\t\tawait this.#workflow.unsafeWaitForStatus(this.#instanceId, status);\n\t}\n\n\tasync getOutput(): Promise<unknown> {\n\t\treturn await this.#workflow.unsafeGetOutputOrError(this.#instanceId, true);\n\t}\n\n\tasync getError(): Promise<{ name: string; message: string }> {\n\t\treturn (await this.#workflow.unsafeGetOutputOrError(\n\t\t\tthis.#instanceId,\n\t\t\tfalse\n\t\t)) as { name: string; message: string };\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tawait this.#workflow.unsafeAbort(this.#instanceId, \"Instance dispose\");\n\t}\n\n\tasync [Symbol.asyncDispose](): Promise<void> {\n\t\tawait this.dispose();\n\t}\n}\n\n// See public facing `cloudflare:test` types for docs\nexport interface WorkflowIntrospector {\n\tmodifyAll(fn: ModifierCallback): Promise<void>;\n\n\tget(): WorkflowInstanceIntrospector[];\n\n\tdispose(): Promise<void>;\n}\n\n// Note(osilva): `introspectWorkflow` could be sync with some changes, but we keep it async\n// to avoid potential breaking changes later.\n\n// In the \"cloudflare:test\" module, the exposed type is `Workflow`. Here we use `WorkflowBinding`\n// (which implements `Workflow`) to access unsafe functions.\nexport async function introspectWorkflow(\n\tworkflow: WorkflowBinding\n): Promise<WorkflowIntrospectorHandle> {\n\tif (!workflow) {\n\t\tthrow new Error(\"[WorkflowIntrospector] Workflow binding is required.\");\n\t}\n\n\tconst modifierCallbacks: ModifierCallback[] = [];\n\tconst instanceIntrospectors: WorkflowInstanceIntrospector[] = [];\n\n\tconst bindingName = await workflow.unsafeGetBindingName();\n\tconst originalWorkflow = env[bindingName] as Workflow;\n\n\tconst introspectAndModifyInstance = async (instanceId: string) => {\n\t\ttry {\n\t\t\tawait runInRunnerObject(async () => {\n\t\t\t\tconst introspector = await introspectWorkflowInstance(\n\t\t\t\t\tworkflow,\n\t\t\t\t\tinstanceId\n\t\t\t\t);\n\t\t\t\tinstanceIntrospectors.push(introspector);\n\t\t\t\t// Apply any stored modifier functions\n\t\t\t\tfor (const callback of modifierCallbacks) {\n\t\t\t\t\tawait introspector.modify(callback);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error(\n\t\t\t\t`[WorkflowIntrospector] Error during introspection for instance ${instanceId}:`,\n\t\t\t\terror\n\t\t\t);\n\t\t\tthrow new Error(\n\t\t\t\t`[WorkflowIntrospector] Failed to introspect Workflow instance ${instanceId}.`\n\t\t\t);\n\t\t}\n\t};\n\n\tconst createWorkflowProxyGetHandler = <\n\t\tT extends Workflow,\n\t>(): ProxyHandler<T>[\"get\"] => {\n\t\treturn (target, property) => {\n\t\t\tif (property === \"create\") {\n\t\t\t\treturn new Proxy(target[property], {\n\t\t\t\t\tasync apply(func, thisArg, argArray) {\n\t\t\t\t\t\tconst hasId = Object.hasOwn(argArray[0] ?? {}, \"id\");\n\t\t\t\t\t\tif (!hasId) {\n\t\t\t\t\t\t\targArray = [{ id: crypto.randomUUID(), ...(argArray[0] ?? {}) }];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst instanceId = (argArray[0] as { id: string }).id;\n\n\t\t\t\t\t\tawait introspectAndModifyInstance(instanceId);\n\n\t\t\t\t\t\treturn target[property](...argArray);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (property === \"createBatch\") {\n\t\t\t\treturn new Proxy(target[property], {\n\t\t\t\t\tasync apply(func, thisArg, argArray) {\n\t\t\t\t\t\tfor (const [index, arg] of argArray[0]?.entries() ?? []) {\n\t\t\t\t\t\t\tconst hasId = Object.hasOwn(arg, \"id\");\n\t\t\t\t\t\t\tif (!hasId) {\n\t\t\t\t\t\t\t\targArray[0][index] = { id: crypto.randomUUID(), ...arg };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\targArray[0].map((options: { id: string }) =>\n\t\t\t\t\t\t\t\tintrospectAndModifyInstance(options.id)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst createPromises = (argArray[0] ?? []).map(\n\t\t\t\t\t\t\t(arg: WorkflowInstanceCreateOptions) => target[\"create\"](arg)\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn Promise.all(createPromises);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\t// @ts-expect-error index signature\n\t\t\treturn target[property];\n\t\t};\n\t};\n\n\tconst dispose = () => {\n\t\tenv[bindingName] = originalWorkflow;\n\t};\n\n\t// Create a single handler instance to be reused\n\tconst proxyGetHandler = createWorkflowProxyGetHandler();\n\n\t// Apply the proxies using the shared handler logic\n\n\tenv[bindingName] = new Proxy(originalWorkflow, {\n\t\tget: proxyGetHandler,\n\t});\n\n\treturn new WorkflowIntrospectorHandle(\n\t\tworkflow,\n\t\tmodifierCallbacks,\n\t\tinstanceIntrospectors,\n\t\tdispose\n\t);\n}\n\nclass WorkflowIntrospectorHandle implements WorkflowIntrospector {\n\tworkflow: WorkflowBinding;\n\t#modifierCallbacks: ModifierCallback[];\n\t#instanceIntrospectors: WorkflowInstanceIntrospector[];\n\t#disposeCallback: () => void;\n\n\tconstructor(\n\t\tworkflow: WorkflowBinding,\n\t\tmodifierCallbacks: ModifierCallback[],\n\t\tinstanceIntrospectors: WorkflowInstanceIntrospector[],\n\t\tdisposeCallback: () => void\n\t) {\n\t\tthis.workflow = workflow;\n\t\tthis.#modifierCallbacks = modifierCallbacks;\n\t\tthis.#instanceIntrospectors = instanceIntrospectors;\n\t\tthis.#disposeCallback = disposeCallback;\n\t}\n\n\tasync modifyAll(fn: ModifierCallback): Promise<void> {\n\t\tthis.#modifierCallbacks.push(fn);\n\t}\n\n\tget(): WorkflowInstanceIntrospector[] {\n\t\treturn this.#instanceIntrospectors;\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\t// Restore the original env binding immediately so the next test gets a\n\t\t// clean binding even if instance disposal (unsafeAbort) is still in flight.\n\t\tthis.#disposeCallback();\n\t\tconst introspectors = this.#instanceIntrospectors;\n\t\tthis.#modifierCallbacks = [];\n\t\tthis.#instanceIntrospectors = [];\n\t\t// Dispose all instance introspectors after binding is restored\n\t\tawait Promise.all(\n\t\t\tintrospectors.map((introspector) => introspector.dispose())\n\t\t);\n\t}\n\n\tasync [Symbol.asyncDispose](): Promise<void> {\n\t\tawait this.dispose();\n\t}\n}\n"],"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;CAEA,YACC,UACA,mBACA,uBACA,iBACC;AACD,OAAK,WAAW;AAChB,QAAKC,oBAAqB;AAC1B,QAAKC,wBAAyB;AAC9B,QAAKC,kBAAmB;;CAGzB,MAAM,UAAU,IAAqC;AACpD,QAAKF,kBAAmB,KAAK,GAAG;;CAGjC,MAAsC;AACrC,SAAO,MAAKC;;CAGb,MAAM,UAAyB;AAG9B,QAAKC,iBAAkB;EACvB,MAAM,gBAAgB,MAAKD;AAC3B,QAAKD,oBAAqB,EAAE;AAC5B,QAAKC,wBAAyB,EAAE;AAEhC,QAAM,QAAQ,IACb,cAAc,KAAK,iBAAiB,aAAa,SAAS,CAAC,CAC3D;;CAGF,OAAO,OAAO,gBAA+B;AAC5C,QAAM,KAAK,SAAS"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vitest-pool-workers",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"description": "Workers Vitest integration for writing Vitest unit and integration tests that run inside the Workers runtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"cjs-module-lexer": "^1.2.3",
|
|
49
49
|
"esbuild": "0.27.3",
|
|
50
50
|
"zod": "^3.25.76",
|
|
51
|
-
"miniflare": "4.
|
|
52
|
-
"wrangler": "4.90.
|
|
51
|
+
"miniflare": "4.20260508.0",
|
|
52
|
+
"wrangler": "4.90.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@cloudflare/workers-types": "^4.
|
|
55
|
+
"@cloudflare/workers-types": "^4.20260508.1",
|
|
56
56
|
"@types/jscodeshift": "^17.3.0",
|
|
57
57
|
"@types/node": "^22.10.1",
|
|
58
58
|
"@types/semver": "^7.5.1",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"undici": "7.24.8",
|
|
72
72
|
"vitest": "4.1.0",
|
|
73
73
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
74
|
-
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
75
74
|
"@cloudflare/workers-utils": "0.21.0",
|
|
75
|
+
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
76
76
|
"@cloudflare/workflows-shared": "0.10.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
declare module "cloudflare:test" {
|
|
3
2
|
/**
|
|
4
3
|
* @deprecated Instead, use `import { env } from "cloudflare:workers"`
|
|
@@ -88,7 +87,7 @@ declare module "cloudflare:test" {
|
|
|
88
87
|
* `EventContext`s return by `createPagesEventContext()`.
|
|
89
88
|
*/
|
|
90
89
|
export function waitOnExecutionContext(
|
|
91
|
-
ctx: ExecutionContext | EventContext<Cloudflare.Env, string,
|
|
90
|
+
ctx: ExecutionContext | EventContext<Cloudflare.Env, string, unknown>
|
|
92
91
|
): Promise<void>;
|
|
93
92
|
/**
|
|
94
93
|
* Creates an instance of `ScheduledController` for use as the 1st argument to
|
|
@@ -632,8 +631,8 @@ declare module "cloudflare:test" {
|
|
|
632
631
|
: { params: Record<Params, string | string[]> };
|
|
633
632
|
type EventContextInitData<Data> =
|
|
634
633
|
Data extends Record<string, never> ? { data?: Data } : { data: Data };
|
|
635
|
-
type EventContextInit<E extends EventContext<
|
|
636
|
-
E extends EventContext<
|
|
634
|
+
type EventContextInit<E extends EventContext<unknown, unknown, unknown>> =
|
|
635
|
+
E extends EventContext<unknown, infer Params, infer Data>
|
|
637
636
|
? EventContextInitBase &
|
|
638
637
|
EventContextInitParams<Params> &
|
|
639
638
|
EventContextInitData<Data>
|
|
@@ -644,6 +643,7 @@ declare module "cloudflare:test" {
|
|
|
644
643
|
* Functions.
|
|
645
644
|
*/
|
|
646
645
|
export function createPagesEventContext<
|
|
646
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any is required: PagesFunction wraps Data in a function parameter, which flips subtyping — unknown would reject PagesFunction types with specific Data
|
|
647
647
|
F extends PagesFunction<Cloudflare.Env, string, any>,
|
|
648
648
|
>(init: EventContextInit<Parameters<F>[0]>): Parameters<F>[0];
|
|
649
649
|
|