@cloudflare/vitest-pool-workers 0.12.20 → 0.13.0

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.
Files changed (40) hide show
  1. package/dist/codemods/vitest-v3-to-v4.mjs +45 -0
  2. package/dist/codemods/vitest-v3-to-v4.mjs.map +1 -0
  3. package/dist/pool/index.d.mts +133 -0
  4. package/dist/pool/index.mjs +2784 -7847
  5. package/dist/pool/index.mjs.map +1 -6
  6. package/dist/worker/index.mjs +753 -792
  7. package/dist/worker/index.mjs.map +1 -6
  8. package/dist/worker/lib/cloudflare/snapshot.mjs +39 -0
  9. package/dist/worker/lib/cloudflare/snapshot.mjs.map +1 -0
  10. package/dist/worker/lib/cloudflare/test-internal.mjs +788 -1276
  11. package/dist/worker/lib/cloudflare/test-internal.mjs.map +1 -6
  12. package/dist/worker/lib/cloudflare/test.mjs +3 -36
  13. package/dist/worker/node/console.mjs +95 -116
  14. package/dist/worker/node/console.mjs.map +1 -6
  15. package/dist/worker/node/vm.mjs +10 -11
  16. package/dist/worker/node/vm.mjs.map +1 -6
  17. package/package.json +25 -21
  18. package/types/cloudflare-test.d.ts +5 -30
  19. package/dist/config/d1.d.ts +0 -7
  20. package/dist/config/index.cjs +0 -230
  21. package/dist/config/index.cjs.map +0 -6
  22. package/dist/config/index.d.ts +0 -27
  23. package/dist/config/pages.d.ts +0 -2
  24. package/dist/pool/config.d.ts +0 -112
  25. package/dist/pool/helpers.d.ts +0 -5
  26. package/dist/shared/builtin-modules.d.ts +0 -1
  27. package/dist/shared/d1.d.ts +0 -4
  28. package/dist/worker/lib/cloudflare/empty-internal.cjs +0 -27
  29. package/dist/worker/lib/cloudflare/empty-internal.cjs.map +0 -6
  30. package/dist/worker/lib/cloudflare/mock-agent.cjs +0 -3433
  31. package/dist/worker/lib/cloudflare/mock-agent.cjs.map +0 -6
  32. package/dist/worker/lib/cloudflare/test-runner.mjs +0 -246
  33. package/dist/worker/lib/cloudflare/test-runner.mjs.map +0 -6
  34. package/dist/worker/lib/cloudflare/test.mjs.map +0 -6
  35. package/dist/worker/lib/debug.mjs +0 -9
  36. package/dist/worker/lib/debug.mjs.map +0 -6
  37. package/dist/worker/lib/mlly.mjs +0 -48
  38. package/dist/worker/lib/mlly.mjs.map +0 -6
  39. package/dist/worker/lib/tinypool.mjs +0 -6
  40. package/dist/worker/lib/tinypool.mjs.map +0 -6
@@ -0,0 +1,45 @@
1
+ //#region src/codemods/vitest-v3-to-v4.ts
2
+ function isNamedProp(j, prop, name) {
3
+ return (j.Property.check(prop) || j.ObjectProperty.check(prop)) && j.Identifier.check(prop.key) && prop.key.name === name;
4
+ }
5
+ function findNamedProp(j, properties, name) {
6
+ return properties.find((prop) => isNamedProp(j, prop, name));
7
+ }
8
+ function transform(fileInfo, api) {
9
+ const j = api.jscodeshift;
10
+ const root = j(fileInfo.source);
11
+ const configImports = root.find(j.ImportDeclaration, { source: { value: "@cloudflare/vitest-pool-workers/config" } });
12
+ if (configImports.length === 0) return fileInfo.source;
13
+ configImports.forEach((path) => {
14
+ path.node.source.value = "@cloudflare/vitest-pool-workers";
15
+ path.node.specifiers = [j.importSpecifier(j.identifier("cloudflareTest")), ...path.node.specifiers?.filter((s) => !(s.type === "ImportSpecifier" && s.imported?.name === "defineWorkersProject")) ?? []];
16
+ });
17
+ const allImports = root.find(j.ImportDeclaration);
18
+ if (allImports.length > 0) allImports.at(-1).forEach((path) => {
19
+ path.insertAfter(j.importDeclaration([j.importSpecifier(j.identifier("defineConfig"))], j.stringLiteral("vitest/config")));
20
+ });
21
+ root.find(j.CallExpression, { callee: { name: "defineWorkersProject" } }).forEach((path) => {
22
+ path.node.callee.name = "defineConfig";
23
+ const config = path.node.arguments[0];
24
+ if (!j.ObjectExpression.check(config)) throw new Error("defineWorkersProject() is called with a function and not an object, and so is too complex to apply a codemod to. Please refer to the migration docs to perform the migration manually.");
25
+ const testProp = findNamedProp(j, config.properties, "test");
26
+ if (!testProp || !j.ObjectExpression.check(testProp.value)) throw new Error("Could not find `test` property in config");
27
+ const testObj = testProp.value;
28
+ const poolOptionsProp = findNamedProp(j, testObj.properties, "poolOptions");
29
+ if (!poolOptionsProp || !j.ObjectExpression.check(poolOptionsProp.value)) throw new Error("Could not find `test.poolOptions` property in config");
30
+ const poolOptionsObj = poolOptionsProp.value;
31
+ const workersProp = findNamedProp(j, poolOptionsObj.properties, "workers");
32
+ if (!workersProp || !(j.ObjectExpression.check(workersProp.value) || j.FunctionExpression.check(workersProp.value) || j.ArrowFunctionExpression.check(workersProp.value))) throw new Error("Could not find `test.poolOptions.workers` property in config");
33
+ const pluginCall = j.callExpression(j.identifier("cloudflareTest"), [workersProp.value]);
34
+ const pluginsProp = findNamedProp(j, config.properties, "plugins");
35
+ if (pluginsProp && j.ArrayExpression.check(pluginsProp.value)) pluginsProp.value.elements.unshift(pluginCall);
36
+ else config.properties.unshift(j.objectProperty(j.identifier("plugins"), j.arrayExpression([pluginCall])));
37
+ testObj.properties = testObj.properties.filter((prop) => !isNamedProp(j, prop, "poolOptions"));
38
+ });
39
+ return root.toSource();
40
+ }
41
+ const parser = "ts";
42
+
43
+ //#endregion
44
+ export { transform as default, parser };
45
+ //# sourceMappingURL=vitest-v3-to-v4.mjs.map
@@ -0,0 +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,OAAO,QAAQ;AACzB,OAAK,KAAK,aAAa,CACtB,EAAE,gBAAgB,EAAE,WAAW,iBAAiB,CAAC,EACjD,GAAI,KAAK,KAAK,YAAY,QACxB,MACA,EACC,EAAE,SAAS,qBACX,EAAE,UAAU,SAAS,wBAEvB,IAAI,EAAE,CACP;GACA;CAGF,MAAM,aAAa,KAAK,KAAK,EAAE,kBAAkB;AACjD,KAAI,WAAW,SAAS,EAEvB,CADmB,WAAW,GAAG,GAAG,CACzB,SAAS,SAAmB;AACtC,OAAK,YACJ,EAAE,kBACD,CAAC,EAAE,gBAAgB,EAAE,WAAW,eAAe,CAAC,CAAC,EACjD,EAAE,cAAc,gBAAgB,CAChC,CACD;GACA;AAIH,MACE,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,MAAM,wBAAwB,EACxC,CAAC,CACD,SAAS,SAAuC;AAEhD,EAAC,KAAK,KAAK,OAA0B,OAAO;EAE5C,MAAM,SAAS,KAAK,KAAK,UAAU;AACnC,MAAI,CAAC,EAAE,iBAAiB,MAAM,OAAO,CACpC,OAAM,IAAI,MACT,yLAGA;EAIF,MAAM,WAAW,cAAc,GAAG,OAAO,YAAY,OAAO;AAC5D,MAAI,CAAC,YAAY,CAAC,EAAE,iBAAiB,MAAM,SAAS,MAAM,CACzD,OAAM,IAAI,MAAM,2CAA2C;EAE5D,MAAM,UAAU,SAAS;EAEzB,MAAM,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"}
@@ -0,0 +1,133 @@
1
+ import * as miniflare0 from "miniflare";
2
+ import { Miniflare, ModuleRule, Request, Response, WorkerOptions } from "miniflare";
3
+ import "wrangler";
4
+ import { z } from "zod";
5
+ import { PoolRunnerInitializer, TestProject, Vite, Vitest } from "vitest/node";
6
+ import { inject } from "vitest";
7
+
8
+ //#region src/pool/config.d.ts
9
+ declare const WorkersPoolOptionsSchema: z.ZodObject<{
10
+ /**
11
+ * Entrypoint to Worker run in the same isolate/context as tests. This is
12
+ * required to use `import { exports } from "cloudflare:workers"`, or Durable
13
+ * Objects without an explicit `scriptName`. Note this goes through Vite
14
+ * transforms and can be a TypeScript file. Note also
15
+ * `import module from "<path-to-main>"` inside tests gives exactly the same
16
+ * `module` instance as is used internally for the `SELF` and Durable Object
17
+ * bindings.
18
+ */
19
+ main: z.ZodOptional<z.ZodString>;
20
+ /**
21
+ * Enables remote bindings to access remote resources configured
22
+ * with `remote: true` in the wrangler configuration file.
23
+ */
24
+ remoteBindings: z.ZodDefault<z.ZodBoolean>;
25
+ /**
26
+ * Additional exports.
27
+ * A map of module exports to be made available on the `ctx.exports`
28
+ * that cannot be automatically inferred by analyzing the Worker source code.
29
+ *
30
+ * This is useful for exports that are re-exported implicitly, for example
31
+ * through wildcard (`export * from "..."`) re-exports from virtual modules.
32
+ */
33
+ additionalExports: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<"WorkerEntrypoint">, z.ZodLiteral<"DurableObject">, z.ZodLiteral<"WorkflowEntrypoint">]>>>;
34
+ miniflare: z.ZodOptional<z.ZodObject<{
35
+ workers: z.ZodOptional<z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">>;
36
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
37
+ workers: z.ZodOptional<z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">>;
38
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
39
+ workers: z.ZodOptional<z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">>;
40
+ }, z.ZodTypeAny, "passthrough">>>;
41
+ wrangler: z.ZodOptional<z.ZodObject<{
42
+ configPath: z.ZodOptional<z.ZodString>;
43
+ environment: z.ZodOptional<z.ZodString>;
44
+ }, "strip", z.ZodTypeAny, {
45
+ environment?: string | undefined;
46
+ configPath?: string | undefined;
47
+ }, {
48
+ environment?: string | undefined;
49
+ configPath?: string | undefined;
50
+ }>>;
51
+ }, "strip", z.ZodTypeAny, {
52
+ remoteBindings: boolean;
53
+ additionalExports: Record<string, "WorkerEntrypoint" | "DurableObject" | "WorkflowEntrypoint">;
54
+ main?: string | undefined;
55
+ miniflare?: z.objectOutputType<{
56
+ workers: z.ZodOptional<z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">>;
57
+ }, z.ZodTypeAny, "passthrough"> | undefined;
58
+ wrangler?: {
59
+ environment?: string | undefined;
60
+ configPath?: string | undefined;
61
+ } | undefined;
62
+ }, {
63
+ main?: string | undefined;
64
+ remoteBindings?: boolean | undefined;
65
+ additionalExports?: Record<string, "WorkerEntrypoint" | "DurableObject" | "WorkflowEntrypoint"> | undefined;
66
+ miniflare?: z.objectInputType<{
67
+ workers: z.ZodOptional<z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">>;
68
+ }, z.ZodTypeAny, "passthrough"> | undefined;
69
+ wrangler?: {
70
+ environment?: string | undefined;
71
+ configPath?: string | undefined;
72
+ } | undefined;
73
+ }>;
74
+ type SourcelessWorkerOptions = Omit<WorkerOptions, "script" | "scriptPath" | "modules" | "modulesRoot"> & {
75
+ modulesRules?: ModuleRule[];
76
+ };
77
+ type WorkersPoolOptions = z.input<typeof WorkersPoolOptionsSchema> & {
78
+ miniflare?: SourcelessWorkerOptions & {
79
+ workers?: WorkerOptions[];
80
+ };
81
+ };
82
+ type WorkersPoolOptionsWithDefines = WorkersPoolOptions & {
83
+ defines?: Record<string, string>;
84
+ };
85
+ //#endregion
86
+ //#region src/pool/plugin.d.ts
87
+ interface WorkerPoolOptionsContext {
88
+ inject: typeof inject;
89
+ }
90
+ declare function cloudflareTest(options: WorkersPoolOptions | ((ctx: WorkerPoolOptionsContext) => Promise<WorkersPoolOptions> | WorkersPoolOptions)): Vite.Plugin;
91
+ //#endregion
92
+ //#region src/pool/pool.d.ts
93
+ declare function cloudflarePool(poolOptions: WorkersPoolOptions | ((ctx: WorkerPoolOptionsContext) => Promise<WorkersPoolOptions> | WorkersPoolOptions)): PoolRunnerInitializer;
94
+ //#endregion
95
+ //#region src/shared/d1.d.ts
96
+ type D1Migration = {
97
+ name: string;
98
+ queries: string[];
99
+ };
100
+ //#endregion
101
+ //#region src/pool/d1.d.ts
102
+ /**
103
+ * Reads all migrations in `migrationsPath`, ordered by migration number.
104
+ * Each migration will have its contents split into an array of SQL queries.
105
+ */
106
+ declare function readD1Migrations(migrationsPath: string): Promise<D1Migration[]>;
107
+ //#endregion
108
+ //#region src/pool/pages.d.ts
109
+ declare function poolWorkerStarted(): void;
110
+ declare function poolWorkerStopped(): void;
111
+ declare function buildPagesASSETSBinding(assetsPath: string): Promise<(request: Request) => Promise<Response>>;
112
+ //#endregion
113
+ //#region src/pool/index.d.ts
114
+ declare function structuredSerializableStringify(value: unknown): string;
115
+ declare function structuredSerializableParse(value: string): unknown;
116
+ declare function getRunnerName(project: TestProject, testFile?: string): string;
117
+ interface DurableObjectDesignator {
118
+ className: string;
119
+ scriptName?: string;
120
+ unsafeUniqueKey?: string;
121
+ }
122
+ /**
123
+ * Returns a map of Durable Objects bindings' bound names to the designators of
124
+ * the objects they point to.
125
+ */
126
+ declare function getDurableObjectDesignators(options: WorkersPoolOptions): Map<string, DurableObjectDesignator>;
127
+ declare function getProjectMiniflare(ctx: Vitest, project: TestProject, poolOptions: WorkersPoolOptionsWithDefines, main: string | undefined): Promise<Miniflare>;
128
+ declare function maybeGetResolvedMainPath(project: TestProject, options: WorkersPoolOptionsWithDefines): string | undefined;
129
+ declare function connectToMiniflareSocket(mf: Miniflare, workerName: string): Promise<miniflare0.WebSocket>;
130
+ declare function assertCompatibleVitestVersion(ctx: Vitest): void;
131
+ //#endregion
132
+ export { type D1Migration, assertCompatibleVitestVersion, buildPagesASSETSBinding, cloudflarePool, cloudflareTest, connectToMiniflareSocket, getDurableObjectDesignators, getProjectMiniflare, getRunnerName, maybeGetResolvedMainPath, poolWorkerStarted, poolWorkerStopped, readD1Migrations, structuredSerializableParse, structuredSerializableStringify };
133
+ //# sourceMappingURL=index.d.mts.map