rsbuild-plugin-cloudflare 0.0.6 → 0.0.7
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.
- package/README.md +4 -0
- package/dist/additional-modules-BLip8fmB.mjs +44050 -0
- package/dist/constants-BSTDVDmV.mjs +8 -0
- package/dist/index.d.mts +0 -6
- package/dist/index.mjs +1553 -80694
- package/dist/miniflare-options-CKef80Zq.mjs +73 -0
- package/dist/miniflare-options-r5z9uaFO.mjs +14232 -0
- package/dist/{open-NPEHYJ5T-CLdHWlOO.mjs → open-BPppUKSJ-BoP51JHy.mjs} +97 -118
- package/dist/{package-gWrKQHzY.mjs → package-DtrwVBfL.mjs} +4 -6
- package/dist/request-handler-n9oFuRPf.mjs +254 -0
- package/dist/rolldown-runtime-BMUeFane-BXI4m9DX.mjs +29 -0
- package/dist/rolldown-runtime-DegdyBIC.mjs +25 -0
- package/dist/shared-BgcTKVNO.mjs +5 -0
- package/dist/websockets-BRFceXs5.mjs +88 -0
- package/dist/workers/asset-worker/index.js +131 -266
- package/dist/workers/asset-worker/index.js.map +1 -1
- package/dist/workers/router-worker/index.js +94 -202
- package/dist/workers/router-worker/index.js.map +1 -1
- package/dist/workers/runner-worker/index.js +26 -30
- package/dist/workers/runner-worker/index.js.map +1 -1
- package/dist/workers/runner-worker/module-runner-legacy.js +61 -18
- package/dist/workers/runner-worker/module-runner-legacy.js.map +1 -1
- package/dist/workers/runner-worker/module-runner.js +104 -54
- package/dist/workers/runner-worker/module-runner.js.map +1 -1
- package/dist/workers/vite-proxy-worker/index.js +1 -2
- package/dist/workers/vite-proxy-worker/index.js.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-53YJWLG7-_ps118Xl.mjs +0 -43
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import { DurableObject, WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
|
|
1
|
+
import { DurableObject, WorkerEntrypoint, WorkflowEntrypoint, waitUntil } from "cloudflare:workers";
|
|
2
2
|
import { ModuleRunner, ssrDynamicImportKey, ssrModuleExportsKey } from "vite/module-runner";
|
|
3
|
-
|
|
4
3
|
//#region src/shared.ts
|
|
5
4
|
const UNKNOWN_HOST = "http://localhost";
|
|
6
|
-
const INIT_PATH = "/__vite_plugin_cloudflare_init__";
|
|
7
|
-
const GET_EXPORT_TYPES_PATH = "/__vite_plugin_cloudflare_get_export_types__";
|
|
8
5
|
const WORKER_ENTRY_PATH_HEADER = "__VITE_WORKER_ENTRY_PATH__";
|
|
9
6
|
const IS_ENTRY_WORKER_HEADER = "__VITE_IS_ENTRY_WORKER__";
|
|
10
7
|
const ENVIRONMENT_NAME_HEADER = "__VITE_ENVIRONMENT_NAME__";
|
|
11
|
-
const IS_PARENT_ENVIRONMENT_HEADER = "__VITE_IS_PARENT_ENVIRONMENT__";
|
|
12
8
|
const virtualPrefix = "virtual:cloudflare/";
|
|
13
9
|
const VIRTUAL_WORKER_ENTRY = `${virtualPrefix}worker-entry`;
|
|
14
10
|
const VIRTUAL_EXPORT_TYPES = `${virtualPrefix}export-types`;
|
|
15
|
-
|
|
16
11
|
//#endregion
|
|
17
12
|
//#region src/workers/runner-worker/env.ts
|
|
18
13
|
/**
|
|
@@ -21,10 +16,9 @@ const VIRTUAL_EXPORT_TYPES = `${virtualPrefix}export-types`;
|
|
|
21
16
|
* @returns The user-defined env
|
|
22
17
|
*/
|
|
23
18
|
function stripInternalEnv(internalEnv) {
|
|
24
|
-
const { __VITE_RUNNER_OBJECT__
|
|
19
|
+
const { __VITE_RUNNER_OBJECT__, __VITE_INVOKE_MODULE__, __VITE_UNSAFE_EVAL__, ...userEnv } = internalEnv;
|
|
25
20
|
return userEnv;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
//#endregion
|
|
29
23
|
//#region src/workers/runner-worker/errors.ts
|
|
30
24
|
/**
|
|
@@ -56,7 +50,6 @@ async function maybeCaptureError(options, fn) {
|
|
|
56
50
|
});
|
|
57
51
|
}
|
|
58
52
|
}
|
|
59
|
-
|
|
60
53
|
//#endregion
|
|
61
54
|
//#region src/workers/runner-worker/keys.ts
|
|
62
55
|
/** Keys that should be ignored during RPC property access */
|
|
@@ -84,7 +77,6 @@ const DURABLE_OBJECT_KEYS = [
|
|
|
84
77
|
];
|
|
85
78
|
/** Available methods for `WorkflowEntrypoint` classes */
|
|
86
79
|
const WORKFLOW_ENTRYPOINT_KEYS = ["run"];
|
|
87
|
-
|
|
88
80
|
//#endregion
|
|
89
81
|
//#region src/workers/runner-worker/module-runner.ts
|
|
90
82
|
/** Module runner instances keyed by environment name */
|
|
@@ -100,16 +92,20 @@ const callbackResults = /* @__PURE__ */ new Map();
|
|
|
100
92
|
* since both run in the same V8 isolate). Only a numeric ID crosses the RPC
|
|
101
93
|
* boundary.
|
|
102
94
|
*/
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
95
|
+
function runInRunnerObject(env, callback) {
|
|
96
|
+
const operation = (async () => {
|
|
97
|
+
const id = nextCallbackId++;
|
|
98
|
+
pendingCallbacks.set(id, callback);
|
|
99
|
+
try {
|
|
100
|
+
await env.__VITE_RUNNER_OBJECT__.get("singleton").executeCallback(id);
|
|
101
|
+
return callbackResults.get(id);
|
|
102
|
+
} finally {
|
|
103
|
+
pendingCallbacks.delete(id);
|
|
104
|
+
callbackResults.delete(id);
|
|
105
|
+
}
|
|
106
|
+
})();
|
|
107
|
+
waitUntil(operation);
|
|
108
|
+
return operation;
|
|
113
109
|
}
|
|
114
110
|
/**
|
|
115
111
|
* Durable Object that provides an IoContext for module evaluation and handles
|
|
@@ -127,11 +123,11 @@ var __VITE_RUNNER_OBJECT__ = class extends DurableObject {
|
|
|
127
123
|
*/
|
|
128
124
|
async fetch(request) {
|
|
129
125
|
const { pathname } = new URL(request.url);
|
|
130
|
-
if (pathname !==
|
|
126
|
+
if (pathname !== "/__vite_plugin_cloudflare_init__") throw new Error(`__VITE_RUNNER_OBJECT__ received invalid pathname: "${pathname}"`);
|
|
131
127
|
const environmentName = request.headers.get(ENVIRONMENT_NAME_HEADER);
|
|
132
128
|
if (!environmentName) throw new Error(`__VITE_RUNNER_OBJECT__ received request without "${ENVIRONMENT_NAME_HEADER}" header`);
|
|
133
129
|
if (moduleRunners.has(environmentName)) throw new Error(`Module runner already initialized for environment: "${environmentName}"`);
|
|
134
|
-
if (request.headers.get(
|
|
130
|
+
if (request.headers.get("__VITE_IS_PARENT_ENVIRONMENT__") === "true") {
|
|
135
131
|
parentEnvironmentName = environmentName;
|
|
136
132
|
globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__ = async (envName, id) => {
|
|
137
133
|
const runner = moduleRunners.get(envName);
|
|
@@ -236,11 +232,11 @@ async function createModuleRunner(env, webSocket, environmentName) {
|
|
|
236
232
|
/**
|
|
237
233
|
* Retrieves a specific export from a Worker entry module using the module runner.
|
|
238
234
|
*/
|
|
239
|
-
async function getWorkerEntryExport(workerEntryPath
|
|
235
|
+
async function getWorkerEntryExport(workerEntryPath, exportName) {
|
|
240
236
|
if (!parentEnvironmentName) throw new Error(`Parent environment not initialized`);
|
|
241
237
|
const module = await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(parentEnvironmentName, VIRTUAL_WORKER_ENTRY);
|
|
242
238
|
const exportValue = typeof module === "object" && module !== null && exportName in module && module[exportName];
|
|
243
|
-
if (!exportValue) throw new Error(`"${workerEntryPath
|
|
239
|
+
if (!exportValue) throw new Error(`"${workerEntryPath}" does not define a "${exportName}" export.`);
|
|
244
240
|
return exportValue;
|
|
245
241
|
}
|
|
246
242
|
/**
|
|
@@ -251,7 +247,6 @@ async function getWorkerEntryExportTypes() {
|
|
|
251
247
|
const { getExportTypes } = await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(parentEnvironmentName, VIRTUAL_EXPORT_TYPES);
|
|
252
248
|
return getExportTypes(await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(parentEnvironmentName, VIRTUAL_WORKER_ENTRY));
|
|
253
249
|
}
|
|
254
|
-
|
|
255
250
|
//#endregion
|
|
256
251
|
//#region src/workers/runner-worker/index.ts
|
|
257
252
|
/** The path to the Worker entry file. We store it in the module scope so that it is easily accessible in error messages etc.. */
|
|
@@ -341,8 +336,8 @@ function createWorkerEntrypointWrapper(exportName) {
|
|
|
341
336
|
if (key === "fetch") {
|
|
342
337
|
const request = arg;
|
|
343
338
|
const url = new URL(request.url);
|
|
344
|
-
if (url.pathname ===
|
|
345
|
-
if (request.headers.get(
|
|
339
|
+
if (url.pathname === "/__vite_plugin_cloudflare_init__") {
|
|
340
|
+
if (request.headers.get("__VITE_IS_PARENT_ENVIRONMENT__") === "true") {
|
|
346
341
|
const workerEntryPathHeader = request.headers.get(WORKER_ENTRY_PATH_HEADER);
|
|
347
342
|
if (!workerEntryPathHeader) throw new Error(`Unexpected error: "${WORKER_ENTRY_PATH_HEADER}" header not set.`);
|
|
348
343
|
const isEntryWorkerHeader = request.headers.get(IS_ENTRY_WORKER_HEADER);
|
|
@@ -352,7 +347,7 @@ function createWorkerEntrypointWrapper(exportName) {
|
|
|
352
347
|
}
|
|
353
348
|
return this.env.__VITE_RUNNER_OBJECT__.get("singleton").fetch(request);
|
|
354
349
|
}
|
|
355
|
-
if (url.pathname ===
|
|
350
|
+
if (url.pathname === "/__vite_plugin_cloudflare_get_export_types__") {
|
|
356
351
|
const workerEntryExportTypes = await getWorkerEntryExportTypes();
|
|
357
352
|
return Response.json(workerEntryExportTypes);
|
|
358
353
|
}
|
|
@@ -415,9 +410,10 @@ function createDurableObjectWrapper(exportName) {
|
|
|
415
410
|
if (typeof ctor !== "function") throw new TypeError(`Expected "${exportName}" export of "${workerEntryPath}" to be a subclass of \`DurableObject\`.`);
|
|
416
411
|
if (!this[kInstance] || this[kInstance].ctor !== ctor) {
|
|
417
412
|
const userEnv = stripInternalEnv(this.env);
|
|
413
|
+
const instance = new ctor(this.ctx, userEnv);
|
|
418
414
|
this[kInstance] = {
|
|
419
415
|
ctor,
|
|
420
|
-
instance
|
|
416
|
+
instance
|
|
421
417
|
};
|
|
422
418
|
await this.ctx.blockConcurrencyWhile(async () => {});
|
|
423
419
|
}
|
|
@@ -451,7 +447,7 @@ function createWorkflowEntrypointWrapper(exportName) {
|
|
|
451
447
|
};
|
|
452
448
|
return Wrapper;
|
|
453
449
|
}
|
|
454
|
-
|
|
455
450
|
//#endregion
|
|
456
451
|
export { __VITE_RUNNER_OBJECT__, createDurableObjectWrapper, createWorkerEntrypointWrapper, createWorkflowEntrypointWrapper };
|
|
452
|
+
|
|
457
453
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["parentEnvironmentName: string | undefined","#webSockets","lastError: unknown","workerEntryPath"],"sources":["../../../src/shared.ts","../../../src/workers/runner-worker/env.ts","../../../src/workers/runner-worker/errors.ts","../../../src/workers/runner-worker/keys.ts","../../../src/workers/runner-worker/module-runner.ts","../../../src/workers/runner-worker/index.ts"],"sourcesContent":["export const UNKNOWN_HOST = \"http://localhost\";\n\n// pathnames\nexport const INIT_PATH = \"/__vite_plugin_cloudflare_init__\";\nexport const GET_EXPORT_TYPES_PATH =\n\t\"/__vite_plugin_cloudflare_get_export_types__\";\n\n// headers\nexport const WORKER_ENTRY_PATH_HEADER = \"__VITE_WORKER_ENTRY_PATH__\";\nexport const IS_ENTRY_WORKER_HEADER = \"__VITE_IS_ENTRY_WORKER__\";\nexport const ENVIRONMENT_NAME_HEADER = \"__VITE_ENVIRONMENT_NAME__\";\nexport const IS_PARENT_ENVIRONMENT_HEADER = \"__VITE_IS_PARENT_ENVIRONMENT__\";\n\n// virtual modules\nexport const virtualPrefix = \"virtual:cloudflare/\";\nexport const VIRTUAL_WORKER_ENTRY = `${virtualPrefix}worker-entry`;\nexport const VIRTUAL_EXPORT_TYPES = `${virtualPrefix}export-types`;\n","import type { __VITE_RUNNER_OBJECT__ } from \"./module-runner\";\n\n/**\n * Env type that includes both user-defined properties and properties required for internal use\n */\nexport interface WrapperEnv {\n\t/** Durable Object binding for the Vite module runner */\n\t__VITE_RUNNER_OBJECT__: { get(id: \"singleton\"): __VITE_RUNNER_OBJECT__ };\n\t/** Service binding for fetching modules from the Vite dev server */\n\t__VITE_INVOKE_MODULE__: {\n\t\tfetch: (request: Request) => Promise<Response>;\n\t};\n\t/** Binding for evaluating code */\n\t__VITE_UNSAFE_EVAL__: {\n\t\teval: (code: string, filename: string) => (...args: unknown[]) => unknown;\n\t};\n\t/** User-defined env */\n\t[key: string]: unknown;\n}\n\n/**\n * Strips internal properties from the `env` object, returning only the user-defined properties.\n * @param internalEnv - The full wrapper env, including internal properties\n * @returns The user-defined env\n */\nexport function stripInternalEnv(internalEnv: WrapperEnv) {\n\tconst {\n\t\t__VITE_RUNNER_OBJECT__,\n\t\t__VITE_INVOKE_MODULE__,\n\t\t__VITE_UNSAFE_EVAL__,\n\t\t...userEnv\n\t} = internalEnv;\n\n\treturn userEnv;\n}\n","// Note: the approach used here has the following implications:\n// - Errors that occur in named entrypoints, auxiliary Workers etc. will display in stack traces as occurring in the default export of the entry Worker\n// - If an error occurs in a named entrypoint or auxiliary Worker and the `fetch` handler in the default export of the entry Worker returns the response from the binding directly then the stack trace will be incorrect\n\n/**\n * Converts an error to an object that can be be serialized and revived by Miniflare.\n * Copied from `packages/wrangler/templates/middleware/middleware-miniflare3-json-error.ts`\n */\nfunction reduceError(e: unknown): unknown {\n\tconst errorObj = (e ?? {}) as Record<string, unknown>;\n\treturn {\n\t\tname: errorObj.name,\n\t\tmessage: errorObj.message ?? String(e),\n\t\tstack: errorObj.stack,\n\t\tcause:\n\t\t\terrorObj.cause === undefined ? undefined : reduceError(errorObj.cause),\n\t};\n}\n\n/**\n * Captures errors in the `fetch` handler of the default export of the entry Worker.\n * These are returned as a JSON response that is revived by Miniflare.\n * See comment in `/packages/wrangler/src/deployment-bundle/bundle.ts` for more info.\n */\nexport async function maybeCaptureError<T>(\n\toptions: { isEntryWorker: boolean; key: string; exportName: string },\n\tfn: () => T\n) {\n\tif (\n\t\t!options.isEntryWorker ||\n\t\toptions.exportName !== \"default\" ||\n\t\toptions.key !== \"fetch\"\n\t) {\n\t\treturn fn();\n\t}\n\n\ttry {\n\t\treturn await fn();\n\t} catch (error) {\n\t\treturn Response.json(reduceError(error), {\n\t\t\tstatus: 500,\n\t\t\theaders: { \"MF-Experimental-Error-Stack\": \"true\" },\n\t\t});\n\t}\n}\n","import type {\n\tDurableObject,\n\tWorkerEntrypoint,\n\tWorkflowEntrypoint,\n} from \"cloudflare:workers\";\n\n/** Keys that should be ignored during RPC property access */\nexport const IGNORED_KEYS = [\"self\"] as const;\n\n/** Available methods for `WorkerEntrypoint` class */\nexport const WORKER_ENTRYPOINT_KEYS = [\n\t\"connect\",\n\t\"email\",\n\t\"fetch\",\n\t\"queue\",\n\t\"tail\",\n\t\"tailStream\",\n\t\"test\",\n\t\"trace\",\n\t\"scheduled\",\n] as const;\n\n/** Available methods for `DurableObject` class */\nexport const DURABLE_OBJECT_KEYS = [\n\t\"alarm\",\n\t\"connect\",\n\t\"fetch\",\n\t\"webSocketClose\",\n\t\"webSocketError\",\n\t\"webSocketMessage\",\n] as const;\n\n/** Available methods for `WorkflowEntrypoint` classes */\nexport const WORKFLOW_ENTRYPOINT_KEYS = [\"run\"] as const;\n\n/**\n * This function is not used.\n * It is is included to check that we have included all the necessary keys.\n */\n// @ts-expect-error: function declaration only used to check types\nfunction _checkExhaustiveKeys() {\n\t// Remove branded keys\n\ttype UnbrandedKeys<T> = Exclude<keyof T, `__${string}_BRAND`>;\n\n\tconst _workerEntrypointExhaustive: (typeof WORKER_ENTRYPOINT_KEYS)[number] =\n\t\tundefined as unknown as UnbrandedKeys<WorkerEntrypoint>;\n\tconst _durableObjectExhaustive: (typeof DURABLE_OBJECT_KEYS)[number] =\n\t\tundefined as unknown as UnbrandedKeys<DurableObject>;\n\tconst _workflowEntrypointExhaustive: (typeof WORKFLOW_ENTRYPOINT_KEYS)[number] =\n\t\tundefined as unknown as UnbrandedKeys<WorkflowEntrypoint>;\n\n\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- these unused expressions are here to exercise the typechecker\n\t_workerEntrypointExhaustive ||\n\t\t_durableObjectExhaustive ||\n\t\t_workflowEntrypointExhaustive;\n}\n","import { DurableObject } from \"cloudflare:workers\";\nimport {\n\tModuleRunner,\n\tssrDynamicImportKey,\n\tssrModuleExportsKey,\n} from \"vite/module-runner\";\nimport {\n\tENVIRONMENT_NAME_HEADER,\n\tINIT_PATH,\n\tIS_PARENT_ENVIRONMENT_HEADER,\n\tUNKNOWN_HOST,\n\tVIRTUAL_EXPORT_TYPES,\n\tVIRTUAL_WORKER_ENTRY,\n} from \"../../shared\";\nimport { stripInternalEnv } from \"./env\";\nimport type { WrapperEnv } from \"./env\";\n\ndeclare global {\n\t// This global variable is accessed by `@vitejs/plugin-rsc`\n\tvar __VITE_ENVIRONMENT_RUNNER_IMPORT__: (\n\t\tenvironmentName: string,\n\t\tid: string\n\t) => Promise<unknown>;\n}\n\n/** Module runner instances keyed by environment name */\nconst moduleRunners = new Map<string, ModuleRunner>();\n\n/** The parent environment name (set explicitly via IS_PARENT_ENVIRONMENT_HEADER) */\nlet parentEnvironmentName: string | undefined;\n\nlet nextCallbackId = 0;\nconst pendingCallbacks = new Map<number, () => Promise<unknown>>();\nconst callbackResults = new Map<number, unknown>();\n\n/**\n * Executes a callback in the runner Durable Object's IoContext via RPC + shared memory.\n * The callback function is stored in a module-scope map (shared with the DO\n * since both run in the same V8 isolate). Only a numeric ID crosses the RPC\n * boundary.\n */\nasync function runInRunnerObject(\n\tenv: WrapperEnv,\n\tcallback: () => Promise<unknown>\n): Promise<unknown> {\n\tconst id = nextCallbackId++;\n\tpendingCallbacks.set(id, callback);\n\n\ttry {\n\t\tconst stub = env.__VITE_RUNNER_OBJECT__.get(\"singleton\");\n\t\tawait stub.executeCallback(id);\n\n\t\treturn callbackResults.get(id);\n\t} finally {\n\t\tpendingCallbacks.delete(id);\n\t\tcallbackResults.delete(id);\n\t}\n}\n\n/**\n * Durable Object that provides an IoContext for module evaluation and handles\n * WebSocket communication with the Vite dev server.\n *\n * In workerd, a Durable Object has a single shared IoContext across all\n * incoming events, so promises are freely shareable within the DO without\n * cross-context issues.\n */\nexport class __VITE_RUNNER_OBJECT__ extends DurableObject<WrapperEnv> {\n\t/** Per-environment WebSockets */\n\t#webSockets = new Map<string, WebSocket>();\n\n\t/**\n\t * Creates a WebSocket pair for communication with the Vite dev server and initializes the ModuleRunner.\n\t */\n\toverride async fetch(request: Request) {\n\t\tconst { pathname } = new URL(request.url);\n\n\t\tif (pathname !== INIT_PATH) {\n\t\t\tthrow new Error(\n\t\t\t\t`__VITE_RUNNER_OBJECT__ received invalid pathname: \"${pathname}\"`\n\t\t\t);\n\t\t}\n\n\t\tconst environmentName = request.headers.get(ENVIRONMENT_NAME_HEADER);\n\n\t\tif (!environmentName) {\n\t\t\tthrow new Error(\n\t\t\t\t`__VITE_RUNNER_OBJECT__ received request without \"${ENVIRONMENT_NAME_HEADER}\" header`\n\t\t\t);\n\t\t}\n\n\t\tif (moduleRunners.has(environmentName)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Module runner already initialized for environment: \"${environmentName}\"`\n\t\t\t);\n\t\t}\n\n\t\tconst isParentEnvironment =\n\t\t\trequest.headers.get(IS_PARENT_ENVIRONMENT_HEADER) === \"true\";\n\n\t\tif (isParentEnvironment) {\n\t\t\tparentEnvironmentName = environmentName;\n\n\t\t\tglobalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__ = async (\n\t\t\t\tenvName: string,\n\t\t\t\tid: string\n\t\t\t): Promise<unknown> => {\n\t\t\t\tconst runner = moduleRunners.get(envName);\n\n\t\t\t\tif (!runner) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Module runner not initialized for environment: \"${envName}\". Do you need to set \\`childEnvironments: [\"${envName}\"]\\` in the plugin config?`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn runInRunnerObject(this.env, () => runner.import(id));\n\t\t\t};\n\t\t}\n\n\t\tconst { 0: client, 1: server } = new WebSocketPair();\n\t\tserver.accept();\n\n\t\tconst moduleRunner = await createModuleRunner(\n\t\t\tthis.env,\n\t\t\tserver,\n\t\t\tenvironmentName\n\t\t);\n\n\t\tmoduleRunners.set(environmentName, moduleRunner);\n\t\tthis.#webSockets.set(environmentName, server);\n\n\t\treturn new Response(null, { status: 101, webSocket: client });\n\t}\n\n\t/**\n\t * Sends data to the Vite dev server via the WebSocket for a specific environment.\n\t */\n\tsend(environmentName: string, data: string): void {\n\t\tconst webSocket = this.#webSockets.get(environmentName);\n\n\t\tif (!webSocket) {\n\t\t\tthrow new Error(\n\t\t\t\t`Module runner not initialized for environment: \"${environmentName}\"`\n\t\t\t);\n\t\t}\n\n\t\twebSocket.send(data);\n\t}\n\n\t/**\n\t * Executes a callback stored in the module-scope `pendingCallbacks` map.\n\t * The callback runs in the DO's IoContext, ensuring all promises created\n\t * during execution belong to the DO's shared context.\n\t */\n\tasync executeCallback(id: number): Promise<void> {\n\t\tconst callback = pendingCallbacks.get(id);\n\n\t\tif (!callback) {\n\t\t\tthrow new Error(`No pending callback with id ${id}`);\n\t\t}\n\n\t\tconst result = await callback();\n\t\tcallbackResults.set(id, result);\n\t}\n}\n\n/**\n * Creates a new module runner instance with a WebSocket transport.\n * @param env - The wrapper env\n * @param webSocket - WebSocket connection for communication with Vite dev server\n * @param environmentName - The name of the environment this runner is for\n * @returns Configured module runner instance\n */\nasync function createModuleRunner(\n\tenv: WrapperEnv,\n\twebSocket: WebSocket,\n\tenvironmentName: string\n) {\n\treturn new ModuleRunner(\n\t\t{\n\t\t\tsourcemapInterceptor: \"prepareStackTrace\",\n\t\t\ttransport: {\n\t\t\t\tconnect({ onMessage }) {\n\t\t\t\t\twebSocket.addEventListener(\"message\", async ({ data }) => {\n\t\t\t\t\t\tonMessage(JSON.parse(data.toString()));\n\t\t\t\t\t});\n\n\t\t\t\t\tonMessage({\n\t\t\t\t\t\ttype: \"custom\",\n\t\t\t\t\t\tevent: \"vite:ws:connect\",\n\t\t\t\t\t\tdata: { webSocket },\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tdisconnect() {\n\t\t\t\t\twebSocket.close();\n\t\t\t\t},\n\t\t\t\tsend(data) {\n\t\t\t\t\t// We send messages via a binding to the Durable Object.\n\t\t\t\t\t// This is because `import.meta.send` may be called within a Worker's request context.\n\t\t\t\t\t// Directly using a WebSocket created in another context would be forbidden.\n\t\t\t\t\tconst stub = env.__VITE_RUNNER_OBJECT__.get(\"singleton\");\n\t\t\t\t\tstub.send(environmentName, JSON.stringify(data));\n\t\t\t\t},\n\t\t\t\tasync invoke(data) {\n\t\t\t\t\t// The fetch can fail transiently (e.g. the runtime reusing a\n\t\t\t\t\t// pooled connection to the loopback server just as it closes).\n\t\t\t\t\t// A failed invoke is cached by the module runner and poisons the\n\t\t\t\t\t// module graph for the rest of the session, so retry before\n\t\t\t\t\t// giving up. Invokes are idempotent requests for module code,\n\t\t\t\t\t// making retries safe.\n\t\t\t\t\tlet lastError: unknown;\n\n\t\t\t\t\tfor (let attempt = 0; attempt < 3; attempt++) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst response = await env.__VITE_INVOKE_MODULE__.fetch(\n\t\t\t\t\t\t\t\tnew Request(UNKNOWN_HOST, {\n\t\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t\t\t[ENVIRONMENT_NAME_HEADER]: environmentName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tbody: JSON.stringify(data),\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst result = await response.json();\n\n\t\t\t\t\t\t\treturn result as { result: unknown } | { error: unknown };\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tlastError = error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow lastError;\n\t\t\t\t},\n\t\t\t},\n\t\t\thmr: true,\n\t\t},\n\t\t{\n\t\t\tasync runInlinedModule(context, transformed, module) {\n\t\t\t\t// Wrap dynamic imports to route deferred dynamic imports\n\t\t\t\t// through the DO's IoContext.\n\t\t\t\tconst originalDynamicImport = context[ssrDynamicImportKey];\n\t\t\t\tcontext[ssrDynamicImportKey] = (dep) => {\n\t\t\t\t\treturn runInRunnerObject(env, () => originalDynamicImport(dep));\n\t\t\t\t};\n\n\t\t\t\t// The trailing newline ensures a `//` comment on the last line of\n\t\t\t\t// `transformed` (e.g. a sourceMappingURL comment preserved by\n\t\t\t\t// vite-plus) cannot swallow the closing brace.\n\t\t\t\tconst code = `\"use strict\";async (${Object.keys(context).join(\",\")})=>{${transformed}\\n}`;\n\t\t\t\tconst fn = env.__VITE_UNSAFE_EVAL__.eval(code, module.id);\n\t\t\t\tawait fn(...Object.values(context));\n\t\t\t\tObject.seal(context[ssrModuleExportsKey]);\n\t\t\t},\n\t\t\tasync runExternalModule(filepath) {\n\t\t\t\tif (filepath === \"cloudflare:workers\") {\n\t\t\t\t\tconst originalCloudflareWorkersModule =\n\t\t\t\t\t\tawait import(\"cloudflare:workers\");\n\n\t\t\t\t\treturn Object.seal({\n\t\t\t\t\t\t...originalCloudflareWorkersModule,\n\t\t\t\t\t\tenv: stripInternalEnv(\n\t\t\t\t\t\t\toriginalCloudflareWorkersModule.env as WrapperEnv\n\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn import(filepath);\n\t\t\t},\n\t\t}\n\t);\n}\n\n/**\n * Retrieves a specific export from a Worker entry module using the module runner.\n */\nexport async function getWorkerEntryExport(\n\tworkerEntryPath: string,\n\texportName: string\n): Promise<unknown> {\n\tif (!parentEnvironmentName) {\n\t\tthrow new Error(`Parent environment not initialized`);\n\t}\n\n\tconst module = await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(\n\t\tparentEnvironmentName,\n\t\tVIRTUAL_WORKER_ENTRY\n\t);\n\n\tconst exportValue =\n\t\ttypeof module === \"object\" &&\n\t\tmodule !== null &&\n\t\texportName in module &&\n\t\t(module as Record<string, unknown>)[exportName];\n\n\tif (!exportValue) {\n\t\tthrow new Error(\n\t\t\t`\"${workerEntryPath}\" does not define a \"${exportName}\" export.`\n\t\t);\n\t}\n\n\treturn exportValue;\n}\n\n/**\n * Retrieves the export types of the Worker entry module.\n */\nexport async function getWorkerEntryExportTypes() {\n\tif (!parentEnvironmentName) {\n\t\tthrow new Error(`Parent environment not initialized`);\n\t}\n\n\tconst { getExportTypes } =\n\t\t(await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(\n\t\t\tparentEnvironmentName,\n\t\t\tVIRTUAL_EXPORT_TYPES\n\t\t)) as { getExportTypes: (module: unknown) => unknown };\n\n\tconst module = await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(\n\t\tparentEnvironmentName,\n\t\tVIRTUAL_WORKER_ENTRY\n\t);\n\n\treturn getExportTypes(module);\n}\n","import {\n\tDurableObject,\n\tWorkerEntrypoint,\n\tWorkflowEntrypoint,\n} from \"cloudflare:workers\";\nimport {\n\tGET_EXPORT_TYPES_PATH,\n\tINIT_PATH,\n\tIS_ENTRY_WORKER_HEADER,\n\tIS_PARENT_ENVIRONMENT_HEADER,\n\tWORKER_ENTRY_PATH_HEADER,\n} from \"../../shared\";\nimport { stripInternalEnv } from \"./env\";\nimport { maybeCaptureError } from \"./errors\";\nimport {\n\tDURABLE_OBJECT_KEYS,\n\tIGNORED_KEYS,\n\tWORKER_ENTRYPOINT_KEYS,\n\tWORKFLOW_ENTRYPOINT_KEYS,\n} from \"./keys\";\nimport {\n\tgetWorkerEntryExport,\n\tgetWorkerEntryExportTypes,\n} from \"./module-runner\";\nimport type { WrapperEnv } from \"./env\";\n\nexport { __VITE_RUNNER_OBJECT__ } from \"./module-runner\";\n\n/**\n * Constructor interface for `WorkerEntrypoint` class.\n * @template T - The `env` type\n */\ninterface WorkerEntrypointConstructor<T = Cloudflare.Env> {\n\tnew (\n\t\t...args: ConstructorParameters<typeof WorkerEntrypoint<T>>\n\t): WorkerEntrypoint<T>;\n}\n\n/**\n * Constructor interface for `DurableObject` class.\n * @template T - The `env` type\n */\ninterface DurableObjectConstructor<T = Cloudflare.Env> {\n\tnew (\n\t\t...args: ConstructorParameters<typeof DurableObject<T>>\n\t): DurableObject<T>;\n}\n\n/**\n * Constructor interface for `WorkflowEntrypoint` class.\n * @template T - The `env` type\n */\ninterface WorkflowEntrypointConstructor<T = Cloudflare.Env> {\n\tnew (\n\t\t...args: ConstructorParameters<typeof WorkflowEntrypoint<T>>\n\t): WorkflowEntrypoint<T>;\n}\n\n/** The path to the Worker entry file. We store it in the module scope so that it is easily accessible in error messages etc.. */\nlet workerEntryPath = \"\";\nlet isEntryWorker = false;\n\n/**\n * Creates a callable thenable that is used to access the properties of an RPC target.\n * It can be both awaited and invoked as a function.\n * This enables RPC properties to be used both as promises and callable functions.\n * @param key - The property key name used for error messages\n * @param property - The promise that resolves to the property value\n * @returns A callable thenable that implements both Promise and function interfaces\n */\nfunction getRpcPropertyCallableThenable(\n\tkey: string,\n\tproperty: Promise<unknown>\n): Promise<unknown> & ((...args: unknown[]) => Promise<unknown>) {\n\tconst fn = async function (...args: unknown[]) {\n\t\tconst maybeFn = await property;\n\n\t\tif (typeof maybeFn !== \"function\") {\n\t\t\tthrow new TypeError(`\"${key}\" is not a function.`);\n\t\t}\n\n\t\treturn maybeFn(...args);\n\t} as Promise<unknown> & ((...args: unknown[]) => Promise<unknown>);\n\n\tfn.then = (onFulfilled, onRejected) => property.then(onFulfilled, onRejected);\n\tfn.catch = (onRejected) => property.catch(onRejected);\n\tfn.finally = (onFinally) => property.finally(onFinally);\n\n\treturn fn;\n}\n\n/**\n * Retrieves an RPC property from a constructor prototype, ensuring it exists on the prototype rather than the instance to maintain RPC compatibility.\n * @param ctor - The constructor function (`WorkerEntrypoint` or `DurableObject`)\n * @param instance - The instance to bind methods to\n * @param key - The property key to retrieve\n * @returns The property value from the prototype\n * @throws TypeError if the property doesn't exist on the prototype\n */\nfunction getRpcProperty(\n\tctor: WorkerEntrypointConstructor | DurableObjectConstructor,\n\tinstance: WorkerEntrypoint | DurableObject,\n\tkey: string\n): unknown {\n\tconst prototypeHasKey = Reflect.has(ctor.prototype, key);\n\n\tif (!prototypeHasKey) {\n\t\tconst instanceHasKey = Reflect.has(instance, key);\n\n\t\tif (instanceHasKey) {\n\t\t\tthrow new TypeError(\n\t\t\t\t[\n\t\t\t\t\t`The RPC receiver's prototype does not implement \"${key}\", but the receiver instance does.`,\n\t\t\t\t\t\"Only properties and methods defined on the prototype can be accessed over RPC.\",\n\t\t\t\t\t`Ensure properties are declared as \\`get ${key}() { ... }\\` instead of \\`${key} = ...\\`,`,\n\t\t\t\t\t`and methods are declared as \\`${key}() { ... }\\` instead of \\`${key} = () => { ... }\\`.`,\n\t\t\t\t].join(\"\\n\")\n\t\t\t);\n\t\t}\n\n\t\tthrow new TypeError(`The RPC receiver does not implement \"${key}\".`);\n\t}\n\n\treturn Reflect.get(ctor.prototype, key, instance);\n}\n\n/**\n * Retrieves an RPC property from a `WorkerEntrypoint` export, creating an instance and returning the bound method or property value.\n * @param exportName - The name of the `WorkerEntrypoint` export\n * @param key - The property key to access on the `WorkerEntrypoint` instance\n * @returns The property value, with methods bound to the instance\n * @throws TypeError if the export is not a `WorkerEntrypoint` subclass\n */\nasync function getWorkerEntrypointRpcProperty(\n\tthis: WorkerEntrypoint<WrapperEnv>,\n\texportName: string,\n\tkey: string\n): Promise<unknown> {\n\tconst ctor = (await getWorkerEntryExport(\n\t\tworkerEntryPath,\n\t\texportName\n\t)) as WorkerEntrypointConstructor;\n\tconst userEnv = stripInternalEnv(this.env);\n\tconst expectedWorkerEntrypointMessage = `Expected \"${exportName}\" export of \"${workerEntryPath}\" to be a subclass of \\`WorkerEntrypoint\\` for RPC.`;\n\n\tif (typeof ctor !== \"function\") {\n\t\tthrow new TypeError(expectedWorkerEntrypointMessage);\n\t}\n\n\tconst instance = new ctor(this.ctx, userEnv);\n\n\tif (!(instance instanceof WorkerEntrypoint)) {\n\t\tthrow new TypeError(expectedWorkerEntrypointMessage);\n\t}\n\n\tconst value = getRpcProperty(ctor, instance, key);\n\n\tif (typeof value === \"function\") {\n\t\treturn value.bind(instance);\n\t}\n\n\treturn value;\n}\n\n/**\n * Creates a proxy wrapper for `WorkerEntrypoint` classes that enables RPC functionality.\n * The wrapper intercepts property access and delegates to the user code, handling both direct method calls and RPC property access.\n * @param exportName - The name of the `WorkerEntrypoint` export to wrap\n * @returns A `WorkerEntrypoint` constructor that acts as a proxy to the user code\n */\nexport function createWorkerEntrypointWrapper(\n\texportName: string\n): WorkerEntrypointConstructor<WrapperEnv> {\n\tclass Wrapper extends WorkerEntrypoint<WrapperEnv> {\n\t\tconstructor(ctx: ExecutionContext, env: WrapperEnv) {\n\t\t\tsuper(ctx, env);\n\n\t\t\treturn new Proxy(this, {\n\t\t\t\tget(target, key, receiver) {\n\t\t\t\t\tconst value = Reflect.get(target, key, receiver);\n\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof key === \"symbol\" ||\n\t\t\t\t\t\t(IGNORED_KEYS as readonly string[]).includes(key) ||\n\t\t\t\t\t\t// The class methods are accessed to determine the type of the export.\n\t\t\t\t\t\t// We should therefore avoid proxying `DurableObject` methods on the `WorkerEntrypoint` class.\n\t\t\t\t\t\t(DURABLE_OBJECT_KEYS as readonly string[]).includes(key)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst property = getWorkerEntrypointRpcProperty.call(\n\t\t\t\t\t\treceiver,\n\t\t\t\t\t\texportName,\n\t\t\t\t\t\tkey\n\t\t\t\t\t);\n\n\t\t\t\t\treturn getRpcPropertyCallableThenable(key, property);\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\tfor (const key of WORKER_ENTRYPOINT_KEYS) {\n\t\tWrapper.prototype[key] = async function (arg) {\n\t\t\treturn maybeCaptureError({ isEntryWorker, exportName, key }, async () => {\n\t\t\t\tif (key === \"fetch\") {\n\t\t\t\t\tconst request = arg as Request;\n\t\t\t\t\tconst url = new URL(request.url);\n\n\t\t\t\t\t// Initialize the module runner\n\t\t\t\t\tif (url.pathname === INIT_PATH) {\n\t\t\t\t\t\tconst isParentEnvironmentHeader = request.headers.get(\n\t\t\t\t\t\t\tIS_PARENT_ENVIRONMENT_HEADER\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Only set Worker variables when initializing the parent environment\n\t\t\t\t\t\tif (isParentEnvironmentHeader === \"true\") {\n\t\t\t\t\t\t\tconst workerEntryPathHeader = request.headers.get(\n\t\t\t\t\t\t\t\tWORKER_ENTRY_PATH_HEADER\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (!workerEntryPathHeader) {\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Unexpected error: \"${WORKER_ENTRY_PATH_HEADER}\" header not set.`\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\tconst isEntryWorkerHeader = request.headers.get(\n\t\t\t\t\t\t\t\tIS_ENTRY_WORKER_HEADER\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (!isEntryWorkerHeader) {\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Unexpected error: \"${IS_ENTRY_WORKER_HEADER}\" header not set.`\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\tworkerEntryPath = decodeURIComponent(workerEntryPathHeader);\n\t\t\t\t\t\t\tisEntryWorker = isEntryWorkerHeader === \"true\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst stub = this.env.__VITE_RUNNER_OBJECT__.get(\"singleton\");\n\n\t\t\t\t\t\t// Forward the request to the Durable Object to initialize the module runner and return the WebSocket\n\t\t\t\t\t\treturn stub.fetch(request);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (url.pathname === GET_EXPORT_TYPES_PATH) {\n\t\t\t\t\t\tconst workerEntryExportTypes = await getWorkerEntryExportTypes();\n\n\t\t\t\t\t\treturn Response.json(workerEntryExportTypes);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst exportValue = await getWorkerEntryExport(\n\t\t\t\t\tworkerEntryPath,\n\t\t\t\t\texportName\n\t\t\t\t);\n\t\t\t\tconst userEnv = stripInternalEnv(this.env);\n\n\t\t\t\tif (typeof exportValue === \"object\" && exportValue !== null) {\n\t\t\t\t\t// The export is an `ExportedHandler`\n\t\t\t\t\tconst maybeFn = (exportValue as Record<string, unknown>)[key];\n\n\t\t\t\t\tif (typeof maybeFn !== \"function\") {\n\t\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to define a \\`${key}()\\` function.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn maybeFn.call(exportValue, arg, userEnv, this.ctx);\n\t\t\t\t} else if (typeof exportValue === \"function\") {\n\t\t\t\t\t// The export is a `WorkerEntrypoint`\n\t\t\t\t\tconst ctor = exportValue as WorkerEntrypointConstructor;\n\t\t\t\t\tconst instance = new ctor(this.ctx, userEnv);\n\n\t\t\t\t\tif (!(instance instanceof WorkerEntrypoint)) {\n\t\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to be a subclass of \\`WorkerEntrypoint\\`.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst maybeFn = instance[key];\n\n\t\t\t\t\tif (typeof maybeFn !== \"function\") {\n\t\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to define a \\`${key}()\\` method.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (maybeFn as (arg: unknown) => unknown).call(instance, arg);\n\t\t\t\t} else {\n\t\t\t\t\treturn new TypeError(\n\t\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to be an object or a class.`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t}\n\n\treturn Wrapper;\n}\n\n/** Symbol key for storing the `DurableObject` instance */\nconst kInstance = Symbol(\"kInstance\");\n/** Symbol key for the instance initialization method */\nconst kEnsureInstance = Symbol(\"kEnsureInstance\");\n\n/**\n * Container for a `DurableObject` constructor and its instance.\n */\ninterface DurableObjectInstance {\n\tctor: DurableObjectConstructor;\n\tinstance: DurableObject;\n}\n\n/**\n * Extended `DurableObject` interface that includes instance management methods.\n */\ninterface DurableObjectWrapper extends DurableObject<WrapperEnv> {\n\t[kInstance]?: DurableObjectInstance;\n\t[kEnsureInstance](): Promise<DurableObjectInstance>;\n}\n\n/**\n * Retrieves an RPC property from a `DurableObject` export, ensuring an instance is properly initialized and returning the bound method or property value.\n * @param exportName - The name of the `DurableObject` export\n * @param key - The property key to access on the `DurableObject` instance\n * @returns The property value, with methods bound to the instance\n * @throws TypeError if the export is not a `DurableObject` subclass\n */\nasync function getDurableObjectRpcProperty(\n\tthis: DurableObjectWrapper,\n\texportName: string,\n\tkey: string\n): Promise<unknown> {\n\tconst { ctor, instance } = await this[kEnsureInstance]();\n\n\tif (!(instance instanceof DurableObject)) {\n\t\tthrow new TypeError(\n\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to be a subclass of \\`DurableObject\\` for RPC.`\n\t\t);\n\t}\n\n\tconst value = getRpcProperty(ctor, instance, key);\n\n\tif (typeof value === \"function\") {\n\t\treturn value.bind(instance);\n\t}\n\n\treturn value;\n}\n\n/**\n * Creates a proxy wrapper for `DurableObject` classes that enables RPC functionality.\n * The wrapper manages instance lifecycle and delegates method calls to the user code, handling both direct method calls and RPC property access.\n * @param exportName - The name of the `DurableObject` export to wrap\n * @returns A `DurableObject` constructor that acts as a proxy to the user code\n */\nexport function createDurableObjectWrapper(\n\texportName: string\n): DurableObjectConstructor<WrapperEnv> {\n\tclass Wrapper\n\t\textends DurableObject<WrapperEnv>\n\t\timplements DurableObjectWrapper\n\t{\n\t\t[kInstance]?: DurableObjectInstance;\n\n\t\tconstructor(ctx: DurableObjectState, env: WrapperEnv) {\n\t\t\tsuper(ctx, env);\n\n\t\t\treturn new Proxy(this, {\n\t\t\t\tget(target, key, receiver) {\n\t\t\t\t\tconst value = Reflect.get(target, key, receiver);\n\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof key === \"symbol\" ||\n\t\t\t\t\t\t(IGNORED_KEYS as readonly string[]).includes(key) ||\n\t\t\t\t\t\t// The class methods are accessed to determine the type of the export.\n\t\t\t\t\t\t// We should therefore avoid proxying `WorkerEntrypoint` methods on the `DurableObject` class.\n\t\t\t\t\t\t(WORKER_ENTRYPOINT_KEYS as readonly string[]).includes(key)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst property = getDurableObjectRpcProperty.call(\n\t\t\t\t\t\treceiver,\n\t\t\t\t\t\texportName,\n\t\t\t\t\t\tkey\n\t\t\t\t\t);\n\n\t\t\t\t\treturn getRpcPropertyCallableThenable(key, property);\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tasync [kEnsureInstance]() {\n\t\t\tconst ctor = (await getWorkerEntryExport(\n\t\t\t\tworkerEntryPath,\n\t\t\t\texportName\n\t\t\t)) as DurableObjectConstructor;\n\n\t\t\tif (typeof ctor !== \"function\") {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to be a subclass of \\`DurableObject\\`.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// We reuse the same instance unless the constructor changes\n\t\t\tif (!this[kInstance] || this[kInstance].ctor !== ctor) {\n\t\t\t\tconst userEnv = stripInternalEnv(this.env);\n\t\t\t\tconst instance = new ctor(this.ctx, userEnv);\n\n\t\t\t\tthis[kInstance] = { ctor, instance };\n\n\t\t\t\t// Wait for `blockConcurrencyWhile()`s in the constructor to complete\n\t\t\t\tawait this.ctx.blockConcurrencyWhile(async () => {});\n\t\t\t}\n\n\t\t\treturn this[kInstance];\n\t\t}\n\t}\n\n\tfor (const key of DURABLE_OBJECT_KEYS) {\n\t\tWrapper.prototype[key] = async function (...args: unknown[]) {\n\t\t\tconst { instance } = await this[kEnsureInstance]();\n\t\t\tconst maybeFn = instance[key];\n\n\t\t\tif (typeof maybeFn !== \"function\") {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to define a \\`${key}()\\` function.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- dynamic method assignment in a loop can't satisfy the intersection of all method signatures\n\t\t\treturn (maybeFn as (...args: unknown[]) => any).apply(instance, args);\n\t\t};\n\t}\n\n\treturn Wrapper;\n}\n\n/**\n * Creates a proxy wrapper for `WorkflowEntrypoint` classes.\n * The wrapper delegates method calls to the user code.\n * @param exportName - The name of the `WorkflowEntrypoint` export to wrap\n * @returns A `WorkflowEntrypoint` constructor that acts as a proxy to the user code\n */\nexport function createWorkflowEntrypointWrapper(\n\texportName: string\n): WorkflowEntrypointConstructor<WrapperEnv> {\n\tclass Wrapper extends WorkflowEntrypoint<WrapperEnv> {}\n\n\tfor (const key of WORKFLOW_ENTRYPOINT_KEYS) {\n\t\tWrapper.prototype[key] = async function (...args: unknown[]) {\n\t\t\tconst ctor = (await getWorkerEntryExport(\n\t\t\t\tworkerEntryPath,\n\t\t\t\texportName\n\t\t\t)) as WorkflowEntrypointConstructor;\n\t\t\tconst userEnv = stripInternalEnv(this.env);\n\t\t\tconst instance = new ctor(this.ctx, userEnv);\n\n\t\t\tif (!(instance instanceof WorkflowEntrypoint)) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to be a subclass of \\`WorkflowEntrypoint\\`.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst maybeFn = instance[key];\n\n\t\t\tif (typeof maybeFn !== \"function\") {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to define a \\`${key}()\\` function.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (maybeFn as (...args: unknown[]) => unknown).apply(instance, args);\n\t\t};\n\t}\n\n\treturn Wrapper;\n}\n"],"mappings":";;;;AAAA,MAAa,eAAe;AAG5B,MAAa,YAAY;AACzB,MAAa,wBACZ;AAGD,MAAa,2BAA2B;AACxC,MAAa,yBAAyB;AACtC,MAAa,0BAA0B;AACvC,MAAa,+BAA+B;AAG5C,MAAa,gBAAgB;AAC7B,MAAa,uBAAuB,GAAG,cAAc;AACrD,MAAa,uBAAuB,GAAG,cAAc;;;;;;;;;ACSrD,SAAgB,iBAAiB,aAAyB;CACzD,MAAM,EACL,kDACA,wBACA,qBACA,GAAG,YACA;AAEJ,QAAO;;;;;;;;;ACzBR,SAAS,YAAY,GAAqB;CACzC,MAAM,WAAY,KAAK,EAAE;AACzB,QAAO;EACN,MAAM,SAAS;EACf,SAAS,SAAS,WAAW,OAAO,EAAE;EACtC,OAAO,SAAS;EAChB,OACC,SAAS,UAAU,SAAY,SAAY,YAAY,SAAS,MAAM;EACvE;;;;;;;AAQF,eAAsB,kBACrB,SACA,IACC;AACD,KACC,CAAC,QAAQ,iBACT,QAAQ,eAAe,aACvB,QAAQ,QAAQ,Q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AAM,UAAU,iBAAiB,KAAK,IAAI;EAC1C,MAAM,WAAW,IAAI,KAAK,KAAK,KAAK,QAAQ;AAE5C,MAAI,EAAE,oBAAoB,oBACzB,OAAM,IAAI,UACT,aAAa,WAAW,eAAe,gBAAgB,+CACvD;EAGF,MAAM,UAAU,SAAS;AAEzB,MAAI,OAAO,YAAY,WACtB,OAAM,IAAI,UACT,aAAa,WAAW,eAAe,gBAAgB,kBAAkB,IAAI,gBAC7E;AAGF,SAAQ,QAA4C,MAAM,UAAU,KAAK;;AAI3E,QAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ctor"],"sources":["../../../src/shared.ts","../../../src/workers/runner-worker/env.ts","../../../src/workers/runner-worker/errors.ts","../../../src/workers/runner-worker/keys.ts","../../../src/workers/runner-worker/module-runner.ts","../../../src/workers/runner-worker/index.ts"],"sourcesContent":["export const UNKNOWN_HOST = \"http://localhost\";\n\n// pathnames\nexport const INIT_PATH = \"/__vite_plugin_cloudflare_init__\";\nexport const GET_EXPORT_TYPES_PATH =\n\t\"/__vite_plugin_cloudflare_get_export_types__\";\n\n// headers\nexport const WORKER_ENTRY_PATH_HEADER = \"__VITE_WORKER_ENTRY_PATH__\";\nexport const IS_ENTRY_WORKER_HEADER = \"__VITE_IS_ENTRY_WORKER__\";\nexport const ENVIRONMENT_NAME_HEADER = \"__VITE_ENVIRONMENT_NAME__\";\nexport const IS_PARENT_ENVIRONMENT_HEADER = \"__VITE_IS_PARENT_ENVIRONMENT__\";\n\n// virtual modules\nexport const virtualPrefix = \"virtual:cloudflare/\";\nexport const VIRTUAL_WORKER_ENTRY = `${virtualPrefix}worker-entry`;\nexport const VIRTUAL_EXPORT_TYPES = `${virtualPrefix}export-types`;\n","import type { __VITE_RUNNER_OBJECT__ } from \"./module-runner\";\n\n/**\n * Env type that includes both user-defined properties and properties required for internal use\n */\nexport interface WrapperEnv {\n\t/** Durable Object binding for the Vite module runner */\n\t__VITE_RUNNER_OBJECT__: { get(id: \"singleton\"): __VITE_RUNNER_OBJECT__ };\n\t/** Service binding for fetching modules from the Vite dev server */\n\t__VITE_INVOKE_MODULE__: {\n\t\tfetch: (request: Request) => Promise<Response>;\n\t};\n\t/** Binding for evaluating code */\n\t__VITE_UNSAFE_EVAL__: {\n\t\teval: (code: string, filename: string) => (...args: unknown[]) => unknown;\n\t};\n\t/** User-defined env */\n\t[key: string]: unknown;\n}\n\n/**\n * Strips internal properties from the `env` object, returning only the user-defined properties.\n * @param internalEnv - The full wrapper env, including internal properties\n * @returns The user-defined env\n */\nexport function stripInternalEnv(internalEnv: WrapperEnv) {\n\tconst {\n\t\t__VITE_RUNNER_OBJECT__,\n\t\t__VITE_INVOKE_MODULE__,\n\t\t__VITE_UNSAFE_EVAL__,\n\t\t...userEnv\n\t} = internalEnv;\n\n\treturn userEnv;\n}\n","// Note: the approach used here has the following implications:\n// - Errors that occur in named entrypoints, auxiliary Workers etc. will display in stack traces as occurring in the default export of the entry Worker\n// - If an error occurs in a named entrypoint or auxiliary Worker and the `fetch` handler in the default export of the entry Worker returns the response from the binding directly then the stack trace will be incorrect\n\n/**\n * Converts an error to an object that can be be serialized and revived by Miniflare.\n * Copied from `packages/wrangler/templates/middleware/middleware-miniflare3-json-error.ts`\n */\nfunction reduceError(e: unknown): unknown {\n\tconst errorObj = (e ?? {}) as Record<string, unknown>;\n\treturn {\n\t\tname: errorObj.name,\n\t\tmessage: errorObj.message ?? String(e),\n\t\tstack: errorObj.stack,\n\t\tcause:\n\t\t\terrorObj.cause === undefined ? undefined : reduceError(errorObj.cause),\n\t};\n}\n\n/**\n * Captures errors in the `fetch` handler of the default export of the entry Worker.\n * These are returned as a JSON response that is revived by Miniflare.\n * See comment in `/packages/wrangler/src/deployment-bundle/bundle.ts` for more info.\n */\nexport async function maybeCaptureError<T>(\n\toptions: { isEntryWorker: boolean; key: string; exportName: string },\n\tfn: () => T\n) {\n\tif (\n\t\t!options.isEntryWorker ||\n\t\toptions.exportName !== \"default\" ||\n\t\toptions.key !== \"fetch\"\n\t) {\n\t\treturn fn();\n\t}\n\n\ttry {\n\t\treturn await fn();\n\t} catch (error) {\n\t\treturn Response.json(reduceError(error), {\n\t\t\tstatus: 500,\n\t\t\theaders: { \"MF-Experimental-Error-Stack\": \"true\" },\n\t\t});\n\t}\n}\n","import type {\n\tDurableObject,\n\tWorkerEntrypoint,\n\tWorkflowEntrypoint,\n} from \"cloudflare:workers\";\n\n/** Keys that should be ignored during RPC property access */\nexport const IGNORED_KEYS = [\"self\"] as const;\n\n/** Available methods for `WorkerEntrypoint` class */\nexport const WORKER_ENTRYPOINT_KEYS = [\n\t\"connect\",\n\t\"email\",\n\t\"fetch\",\n\t\"queue\",\n\t\"tail\",\n\t\"tailStream\",\n\t\"test\",\n\t\"trace\",\n\t\"scheduled\",\n] as const;\n\n/** Available methods for `DurableObject` class */\nexport const DURABLE_OBJECT_KEYS = [\n\t\"alarm\",\n\t\"connect\",\n\t\"fetch\",\n\t\"webSocketClose\",\n\t\"webSocketError\",\n\t\"webSocketMessage\",\n] as const;\n\n/** Available methods for `WorkflowEntrypoint` classes */\nexport const WORKFLOW_ENTRYPOINT_KEYS = [\"run\"] as const;\n\n/**\n * This function is not used.\n * It is is included to check that we have included all the necessary keys.\n */\n// @ts-expect-error: function declaration only used to check types\nfunction _checkExhaustiveKeys() {\n\t// Remove branded keys\n\ttype UnbrandedKeys<T> = Exclude<keyof T, `__${string}_BRAND`>;\n\n\tconst _workerEntrypointExhaustive: (typeof WORKER_ENTRYPOINT_KEYS)[number] =\n\t\tundefined as unknown as UnbrandedKeys<WorkerEntrypoint>;\n\tconst _durableObjectExhaustive: (typeof DURABLE_OBJECT_KEYS)[number] =\n\t\tundefined as unknown as UnbrandedKeys<DurableObject>;\n\tconst _workflowEntrypointExhaustive: (typeof WORKFLOW_ENTRYPOINT_KEYS)[number] =\n\t\tundefined as unknown as UnbrandedKeys<WorkflowEntrypoint>;\n\n\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- these unused expressions are here to exercise the typechecker\n\t_workerEntrypointExhaustive ||\n\t\t_durableObjectExhaustive ||\n\t\t_workflowEntrypointExhaustive;\n}\n","import { DurableObject, waitUntil } from \"cloudflare:workers\";\nimport {\n\tModuleRunner,\n\tssrDynamicImportKey,\n\tssrModuleExportsKey,\n} from \"vite/module-runner\";\nimport {\n\tENVIRONMENT_NAME_HEADER,\n\tINIT_PATH,\n\tIS_PARENT_ENVIRONMENT_HEADER,\n\tUNKNOWN_HOST,\n\tVIRTUAL_EXPORT_TYPES,\n\tVIRTUAL_WORKER_ENTRY,\n} from \"../../shared\";\nimport { stripInternalEnv } from \"./env\";\nimport type { WrapperEnv } from \"./env\";\n\ndeclare global {\n\t// This global variable is accessed by `@vitejs/plugin-rsc`\n\tvar __VITE_ENVIRONMENT_RUNNER_IMPORT__: (\n\t\tenvironmentName: string,\n\t\tid: string\n\t) => Promise<unknown>;\n}\n\n/** Module runner instances keyed by environment name */\nconst moduleRunners = new Map<string, ModuleRunner>();\n\n/** The parent environment name (set explicitly via IS_PARENT_ENVIRONMENT_HEADER) */\nlet parentEnvironmentName: string | undefined;\n\nlet nextCallbackId = 0;\nconst pendingCallbacks = new Map<number, () => Promise<unknown>>();\nconst callbackResults = new Map<number, unknown>();\n\n/**\n * Executes a callback in the runner Durable Object's IoContext via RPC + shared memory.\n * The callback function is stored in a module-scope map (shared with the DO\n * since both run in the same V8 isolate). Only a numeric ID crosses the RPC\n * boundary.\n */\nfunction runInRunnerObject(\n\tenv: WrapperEnv,\n\tcallback: () => Promise<unknown>\n): Promise<unknown> {\n\tconst operation = (async () => {\n\t\tconst id = nextCallbackId++;\n\t\tpendingCallbacks.set(id, callback);\n\n\t\ttry {\n\t\t\tconst stub = env.__VITE_RUNNER_OBJECT__.get(\"singleton\");\n\t\t\tawait stub.executeCallback(id);\n\n\t\t\treturn callbackResults.get(id);\n\t\t} finally {\n\t\t\tpendingCallbacks.delete(id);\n\t\t\tcallbackResults.delete(id);\n\t\t}\n\t})();\n\n\t// Keep the caller's RPC continuation alive when its request ends.\n\twaitUntil(operation);\n\treturn operation;\n}\n\n/**\n * Durable Object that provides an IoContext for module evaluation and handles\n * WebSocket communication with the Vite dev server.\n *\n * In workerd, a Durable Object has a single shared IoContext across all\n * incoming events, so promises are freely shareable within the DO without\n * cross-context issues.\n */\nexport class __VITE_RUNNER_OBJECT__ extends DurableObject<WrapperEnv> {\n\t/** Per-environment WebSockets */\n\t#webSockets = new Map<string, WebSocket>();\n\n\t/**\n\t * Creates a WebSocket pair for communication with the Vite dev server and initializes the ModuleRunner.\n\t */\n\toverride async fetch(request: Request) {\n\t\tconst { pathname } = new URL(request.url);\n\n\t\tif (pathname !== INIT_PATH) {\n\t\t\tthrow new Error(\n\t\t\t\t`__VITE_RUNNER_OBJECT__ received invalid pathname: \"${pathname}\"`\n\t\t\t);\n\t\t}\n\n\t\tconst environmentName = request.headers.get(ENVIRONMENT_NAME_HEADER);\n\n\t\tif (!environmentName) {\n\t\t\tthrow new Error(\n\t\t\t\t`__VITE_RUNNER_OBJECT__ received request without \"${ENVIRONMENT_NAME_HEADER}\" header`\n\t\t\t);\n\t\t}\n\n\t\tif (moduleRunners.has(environmentName)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Module runner already initialized for environment: \"${environmentName}\"`\n\t\t\t);\n\t\t}\n\n\t\tconst isParentEnvironment =\n\t\t\trequest.headers.get(IS_PARENT_ENVIRONMENT_HEADER) === \"true\";\n\n\t\tif (isParentEnvironment) {\n\t\t\tparentEnvironmentName = environmentName;\n\n\t\t\tglobalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__ = async (\n\t\t\t\tenvName: string,\n\t\t\t\tid: string\n\t\t\t): Promise<unknown> => {\n\t\t\t\tconst runner = moduleRunners.get(envName);\n\n\t\t\t\tif (!runner) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Module runner not initialized for environment: \"${envName}\". Do you need to set \\`childEnvironments: [\"${envName}\"]\\` in the plugin config?`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn runInRunnerObject(this.env, () => runner.import(id));\n\t\t\t};\n\t\t}\n\n\t\tconst { 0: client, 1: server } = new WebSocketPair();\n\t\tserver.accept();\n\n\t\tconst moduleRunner = await createModuleRunner(\n\t\t\tthis.env,\n\t\t\tserver,\n\t\t\tenvironmentName\n\t\t);\n\n\t\tmoduleRunners.set(environmentName, moduleRunner);\n\t\tthis.#webSockets.set(environmentName, server);\n\n\t\treturn new Response(null, { status: 101, webSocket: client });\n\t}\n\n\t/**\n\t * Sends data to the Vite dev server via the WebSocket for a specific environment.\n\t */\n\tsend(environmentName: string, data: string): void {\n\t\tconst webSocket = this.#webSockets.get(environmentName);\n\n\t\tif (!webSocket) {\n\t\t\tthrow new Error(\n\t\t\t\t`Module runner not initialized for environment: \"${environmentName}\"`\n\t\t\t);\n\t\t}\n\n\t\twebSocket.send(data);\n\t}\n\n\t/**\n\t * Executes a callback stored in the module-scope `pendingCallbacks` map.\n\t * The callback runs in the DO's IoContext, ensuring all promises created\n\t * during execution belong to the DO's shared context.\n\t */\n\tasync executeCallback(id: number): Promise<void> {\n\t\tconst callback = pendingCallbacks.get(id);\n\n\t\tif (!callback) {\n\t\t\tthrow new Error(`No pending callback with id ${id}`);\n\t\t}\n\n\t\tconst result = await callback();\n\t\tcallbackResults.set(id, result);\n\t}\n}\n\n/**\n * Creates a new module runner instance with a WebSocket transport.\n * @param env - The wrapper env\n * @param webSocket - WebSocket connection for communication with Vite dev server\n * @param environmentName - The name of the environment this runner is for\n * @returns Configured module runner instance\n */\nasync function createModuleRunner(\n\tenv: WrapperEnv,\n\twebSocket: WebSocket,\n\tenvironmentName: string\n) {\n\treturn new ModuleRunner(\n\t\t{\n\t\t\tsourcemapInterceptor: \"prepareStackTrace\",\n\t\t\ttransport: {\n\t\t\t\tconnect({ onMessage }) {\n\t\t\t\t\twebSocket.addEventListener(\"message\", async ({ data }) => {\n\t\t\t\t\t\tonMessage(JSON.parse(data.toString()));\n\t\t\t\t\t});\n\n\t\t\t\t\tonMessage({\n\t\t\t\t\t\ttype: \"custom\",\n\t\t\t\t\t\tevent: \"vite:ws:connect\",\n\t\t\t\t\t\tdata: { webSocket },\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tdisconnect() {\n\t\t\t\t\twebSocket.close();\n\t\t\t\t},\n\t\t\t\tsend(data) {\n\t\t\t\t\t// We send messages via a binding to the Durable Object.\n\t\t\t\t\t// This is because `import.meta.send` may be called within a Worker's request context.\n\t\t\t\t\t// Directly using a WebSocket created in another context would be forbidden.\n\t\t\t\t\tconst stub = env.__VITE_RUNNER_OBJECT__.get(\"singleton\");\n\t\t\t\t\tstub.send(environmentName, JSON.stringify(data));\n\t\t\t\t},\n\t\t\t\tasync invoke(data) {\n\t\t\t\t\t// The fetch can fail transiently (e.g. the runtime reusing a\n\t\t\t\t\t// pooled connection to the loopback server just as it closes).\n\t\t\t\t\t// A failed invoke is cached by the module runner and poisons the\n\t\t\t\t\t// module graph for the rest of the session, so retry before\n\t\t\t\t\t// giving up. Invokes are idempotent requests for module code,\n\t\t\t\t\t// making retries safe.\n\t\t\t\t\tlet lastError: unknown;\n\n\t\t\t\t\tfor (let attempt = 0; attempt < 3; attempt++) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst response = await env.__VITE_INVOKE_MODULE__.fetch(\n\t\t\t\t\t\t\t\tnew Request(UNKNOWN_HOST, {\n\t\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t\t\t[ENVIRONMENT_NAME_HEADER]: environmentName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tbody: JSON.stringify(data),\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst result = await response.json();\n\n\t\t\t\t\t\t\treturn result as { result: unknown } | { error: unknown };\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tlastError = error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow lastError;\n\t\t\t\t},\n\t\t\t},\n\t\t\thmr: true,\n\t\t},\n\t\t{\n\t\t\tasync runInlinedModule(context, transformed, module) {\n\t\t\t\t// Wrap dynamic imports to route deferred dynamic imports\n\t\t\t\t// through the DO's IoContext.\n\t\t\t\tconst originalDynamicImport = context[ssrDynamicImportKey];\n\t\t\t\tcontext[ssrDynamicImportKey] = (dep) => {\n\t\t\t\t\treturn runInRunnerObject(env, () => originalDynamicImport(dep));\n\t\t\t\t};\n\n\t\t\t\t// The trailing newline ensures a `//` comment on the last line of\n\t\t\t\t// `transformed` (e.g. a sourceMappingURL comment preserved by\n\t\t\t\t// vite-plus) cannot swallow the closing brace.\n\t\t\t\tconst code = `\"use strict\";async (${Object.keys(context).join(\",\")})=>{${transformed}\\n}`;\n\t\t\t\tconst fn = env.__VITE_UNSAFE_EVAL__.eval(code, module.id);\n\t\t\t\tawait fn(...Object.values(context));\n\t\t\t\tObject.seal(context[ssrModuleExportsKey]);\n\t\t\t},\n\t\t\tasync runExternalModule(filepath) {\n\t\t\t\tif (filepath === \"cloudflare:workers\") {\n\t\t\t\t\tconst originalCloudflareWorkersModule =\n\t\t\t\t\t\tawait import(\"cloudflare:workers\");\n\n\t\t\t\t\treturn Object.seal({\n\t\t\t\t\t\t...originalCloudflareWorkersModule,\n\t\t\t\t\t\tenv: stripInternalEnv(\n\t\t\t\t\t\t\toriginalCloudflareWorkersModule.env as WrapperEnv\n\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn import(filepath);\n\t\t\t},\n\t\t}\n\t);\n}\n\n/**\n * Retrieves a specific export from a Worker entry module using the module runner.\n */\nexport async function getWorkerEntryExport(\n\tworkerEntryPath: string,\n\texportName: string\n): Promise<unknown> {\n\tif (!parentEnvironmentName) {\n\t\tthrow new Error(`Parent environment not initialized`);\n\t}\n\n\tconst module = await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(\n\t\tparentEnvironmentName,\n\t\tVIRTUAL_WORKER_ENTRY\n\t);\n\n\tconst exportValue =\n\t\ttypeof module === \"object\" &&\n\t\tmodule !== null &&\n\t\texportName in module &&\n\t\t(module as Record<string, unknown>)[exportName];\n\n\tif (!exportValue) {\n\t\tthrow new Error(\n\t\t\t`\"${workerEntryPath}\" does not define a \"${exportName}\" export.`\n\t\t);\n\t}\n\n\treturn exportValue;\n}\n\n/**\n * Retrieves the export types of the Worker entry module.\n */\nexport async function getWorkerEntryExportTypes() {\n\tif (!parentEnvironmentName) {\n\t\tthrow new Error(`Parent environment not initialized`);\n\t}\n\n\tconst { getExportTypes } =\n\t\t(await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(\n\t\t\tparentEnvironmentName,\n\t\t\tVIRTUAL_EXPORT_TYPES\n\t\t)) as { getExportTypes: (module: unknown) => unknown };\n\n\tconst module = await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__(\n\t\tparentEnvironmentName,\n\t\tVIRTUAL_WORKER_ENTRY\n\t);\n\n\treturn getExportTypes(module);\n}\n","import {\n\tDurableObject,\n\tWorkerEntrypoint,\n\tWorkflowEntrypoint,\n} from \"cloudflare:workers\";\nimport {\n\tGET_EXPORT_TYPES_PATH,\n\tINIT_PATH,\n\tIS_ENTRY_WORKER_HEADER,\n\tIS_PARENT_ENVIRONMENT_HEADER,\n\tWORKER_ENTRY_PATH_HEADER,\n} from \"../../shared\";\nimport { stripInternalEnv } from \"./env\";\nimport { maybeCaptureError } from \"./errors\";\nimport {\n\tDURABLE_OBJECT_KEYS,\n\tIGNORED_KEYS,\n\tWORKER_ENTRYPOINT_KEYS,\n\tWORKFLOW_ENTRYPOINT_KEYS,\n} from \"./keys\";\nimport {\n\tgetWorkerEntryExport,\n\tgetWorkerEntryExportTypes,\n} from \"./module-runner\";\nimport type { WrapperEnv } from \"./env\";\n\nexport { __VITE_RUNNER_OBJECT__ } from \"./module-runner\";\n\n/**\n * Constructor interface for `WorkerEntrypoint` class.\n * @template T - The `env` type\n */\ninterface WorkerEntrypointConstructor<T = Cloudflare.Env> {\n\tnew (\n\t\t...args: ConstructorParameters<typeof WorkerEntrypoint<T>>\n\t): WorkerEntrypoint<T>;\n}\n\n/**\n * Constructor interface for `DurableObject` class.\n * @template T - The `env` type\n */\ninterface DurableObjectConstructor<T = Cloudflare.Env> {\n\tnew (\n\t\t...args: ConstructorParameters<typeof DurableObject<T>>\n\t): DurableObject<T>;\n}\n\n/**\n * Constructor interface for `WorkflowEntrypoint` class.\n * @template T - The `env` type\n */\ninterface WorkflowEntrypointConstructor<T = Cloudflare.Env> {\n\tnew (\n\t\t...args: ConstructorParameters<typeof WorkflowEntrypoint<T>>\n\t): WorkflowEntrypoint<T>;\n}\n\n/** The path to the Worker entry file. We store it in the module scope so that it is easily accessible in error messages etc.. */\nlet workerEntryPath = \"\";\nlet isEntryWorker = false;\n\n/**\n * Creates a callable thenable that is used to access the properties of an RPC target.\n * It can be both awaited and invoked as a function.\n * This enables RPC properties to be used both as promises and callable functions.\n * @param key - The property key name used for error messages\n * @param property - The promise that resolves to the property value\n * @returns A callable thenable that implements both Promise and function interfaces\n */\nfunction getRpcPropertyCallableThenable(\n\tkey: string,\n\tproperty: Promise<unknown>\n): Promise<unknown> & ((...args: unknown[]) => Promise<unknown>) {\n\tconst fn = async function (...args: unknown[]) {\n\t\tconst maybeFn = await property;\n\n\t\tif (typeof maybeFn !== \"function\") {\n\t\t\tthrow new TypeError(`\"${key}\" is not a function.`);\n\t\t}\n\n\t\treturn maybeFn(...args);\n\t} as Promise<unknown> & ((...args: unknown[]) => Promise<unknown>);\n\n\tfn.then = (onFulfilled, onRejected) => property.then(onFulfilled, onRejected);\n\tfn.catch = (onRejected) => property.catch(onRejected);\n\tfn.finally = (onFinally) => property.finally(onFinally);\n\n\treturn fn;\n}\n\n/**\n * Retrieves an RPC property from a constructor prototype, ensuring it exists on the prototype rather than the instance to maintain RPC compatibility.\n * @param ctor - The constructor function (`WorkerEntrypoint` or `DurableObject`)\n * @param instance - The instance to bind methods to\n * @param key - The property key to retrieve\n * @returns The property value from the prototype\n * @throws TypeError if the property doesn't exist on the prototype\n */\nfunction getRpcProperty(\n\tctor: WorkerEntrypointConstructor | DurableObjectConstructor,\n\tinstance: WorkerEntrypoint | DurableObject,\n\tkey: string\n): unknown {\n\tconst prototypeHasKey = Reflect.has(ctor.prototype, key);\n\n\tif (!prototypeHasKey) {\n\t\tconst instanceHasKey = Reflect.has(instance, key);\n\n\t\tif (instanceHasKey) {\n\t\t\tthrow new TypeError(\n\t\t\t\t[\n\t\t\t\t\t`The RPC receiver's prototype does not implement \"${key}\", but the receiver instance does.`,\n\t\t\t\t\t\"Only properties and methods defined on the prototype can be accessed over RPC.\",\n\t\t\t\t\t`Ensure properties are declared as \\`get ${key}() { ... }\\` instead of \\`${key} = ...\\`,`,\n\t\t\t\t\t`and methods are declared as \\`${key}() { ... }\\` instead of \\`${key} = () => { ... }\\`.`,\n\t\t\t\t].join(\"\\n\")\n\t\t\t);\n\t\t}\n\n\t\tthrow new TypeError(`The RPC receiver does not implement \"${key}\".`);\n\t}\n\n\treturn Reflect.get(ctor.prototype, key, instance);\n}\n\n/**\n * Retrieves an RPC property from a `WorkerEntrypoint` export, creating an instance and returning the bound method or property value.\n * @param exportName - The name of the `WorkerEntrypoint` export\n * @param key - The property key to access on the `WorkerEntrypoint` instance\n * @returns The property value, with methods bound to the instance\n * @throws TypeError if the export is not a `WorkerEntrypoint` subclass\n */\nasync function getWorkerEntrypointRpcProperty(\n\tthis: WorkerEntrypoint<WrapperEnv>,\n\texportName: string,\n\tkey: string\n): Promise<unknown> {\n\tconst ctor = (await getWorkerEntryExport(\n\t\tworkerEntryPath,\n\t\texportName\n\t)) as WorkerEntrypointConstructor;\n\tconst userEnv = stripInternalEnv(this.env);\n\tconst expectedWorkerEntrypointMessage = `Expected \"${exportName}\" export of \"${workerEntryPath}\" to be a subclass of \\`WorkerEntrypoint\\` for RPC.`;\n\n\tif (typeof ctor !== \"function\") {\n\t\tthrow new TypeError(expectedWorkerEntrypointMessage);\n\t}\n\n\tconst instance = new ctor(this.ctx, userEnv);\n\n\tif (!(instance instanceof WorkerEntrypoint)) {\n\t\tthrow new TypeError(expectedWorkerEntrypointMessage);\n\t}\n\n\tconst value = getRpcProperty(ctor, instance, key);\n\n\tif (typeof value === \"function\") {\n\t\treturn value.bind(instance);\n\t}\n\n\treturn value;\n}\n\n/**\n * Creates a proxy wrapper for `WorkerEntrypoint` classes that enables RPC functionality.\n * The wrapper intercepts property access and delegates to the user code, handling both direct method calls and RPC property access.\n * @param exportName - The name of the `WorkerEntrypoint` export to wrap\n * @returns A `WorkerEntrypoint` constructor that acts as a proxy to the user code\n */\nexport function createWorkerEntrypointWrapper(\n\texportName: string\n): WorkerEntrypointConstructor<WrapperEnv> {\n\tclass Wrapper extends WorkerEntrypoint<WrapperEnv> {\n\t\tconstructor(ctx: ExecutionContext, env: WrapperEnv) {\n\t\t\tsuper(ctx, env);\n\n\t\t\treturn new Proxy(this, {\n\t\t\t\tget(target, key, receiver) {\n\t\t\t\t\tconst value = Reflect.get(target, key, receiver);\n\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof key === \"symbol\" ||\n\t\t\t\t\t\t(IGNORED_KEYS as readonly string[]).includes(key) ||\n\t\t\t\t\t\t// The class methods are accessed to determine the type of the export.\n\t\t\t\t\t\t// We should therefore avoid proxying `DurableObject` methods on the `WorkerEntrypoint` class.\n\t\t\t\t\t\t(DURABLE_OBJECT_KEYS as readonly string[]).includes(key)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst property = getWorkerEntrypointRpcProperty.call(\n\t\t\t\t\t\treceiver,\n\t\t\t\t\t\texportName,\n\t\t\t\t\t\tkey\n\t\t\t\t\t);\n\n\t\t\t\t\treturn getRpcPropertyCallableThenable(key, property);\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\tfor (const key of WORKER_ENTRYPOINT_KEYS) {\n\t\tWrapper.prototype[key] = async function (arg) {\n\t\t\treturn maybeCaptureError({ isEntryWorker, exportName, key }, async () => {\n\t\t\t\tif (key === \"fetch\") {\n\t\t\t\t\tconst request = arg as Request;\n\t\t\t\t\tconst url = new URL(request.url);\n\n\t\t\t\t\t// Initialize the module runner\n\t\t\t\t\tif (url.pathname === INIT_PATH) {\n\t\t\t\t\t\tconst isParentEnvironmentHeader = request.headers.get(\n\t\t\t\t\t\t\tIS_PARENT_ENVIRONMENT_HEADER\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Only set Worker variables when initializing the parent environment\n\t\t\t\t\t\tif (isParentEnvironmentHeader === \"true\") {\n\t\t\t\t\t\t\tconst workerEntryPathHeader = request.headers.get(\n\t\t\t\t\t\t\t\tWORKER_ENTRY_PATH_HEADER\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (!workerEntryPathHeader) {\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Unexpected error: \"${WORKER_ENTRY_PATH_HEADER}\" header not set.`\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\tconst isEntryWorkerHeader = request.headers.get(\n\t\t\t\t\t\t\t\tIS_ENTRY_WORKER_HEADER\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (!isEntryWorkerHeader) {\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Unexpected error: \"${IS_ENTRY_WORKER_HEADER}\" header not set.`\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\tworkerEntryPath = decodeURIComponent(workerEntryPathHeader);\n\t\t\t\t\t\t\tisEntryWorker = isEntryWorkerHeader === \"true\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst stub = this.env.__VITE_RUNNER_OBJECT__.get(\"singleton\");\n\n\t\t\t\t\t\t// Forward the request to the Durable Object to initialize the module runner and return the WebSocket\n\t\t\t\t\t\treturn stub.fetch(request);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (url.pathname === GET_EXPORT_TYPES_PATH) {\n\t\t\t\t\t\tconst workerEntryExportTypes = await getWorkerEntryExportTypes();\n\n\t\t\t\t\t\treturn Response.json(workerEntryExportTypes);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst exportValue = await getWorkerEntryExport(\n\t\t\t\t\tworkerEntryPath,\n\t\t\t\t\texportName\n\t\t\t\t);\n\t\t\t\tconst userEnv = stripInternalEnv(this.env);\n\n\t\t\t\tif (typeof exportValue === \"object\" && exportValue !== null) {\n\t\t\t\t\t// The export is an `ExportedHandler`\n\t\t\t\t\tconst maybeFn = (exportValue as Record<string, unknown>)[key];\n\n\t\t\t\t\tif (typeof maybeFn !== \"function\") {\n\t\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to define a \\`${key}()\\` function.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn maybeFn.call(exportValue, arg, userEnv, this.ctx);\n\t\t\t\t} else if (typeof exportValue === \"function\") {\n\t\t\t\t\t// The export is a `WorkerEntrypoint`\n\t\t\t\t\tconst ctor = exportValue as WorkerEntrypointConstructor;\n\t\t\t\t\tconst instance = new ctor(this.ctx, userEnv);\n\n\t\t\t\t\tif (!(instance instanceof WorkerEntrypoint)) {\n\t\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to be a subclass of \\`WorkerEntrypoint\\`.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst maybeFn = instance[key];\n\n\t\t\t\t\tif (typeof maybeFn !== \"function\") {\n\t\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to define a \\`${key}()\\` method.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (maybeFn as (arg: unknown) => unknown).call(instance, arg);\n\t\t\t\t} else {\n\t\t\t\t\treturn new TypeError(\n\t\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to be an object or a class.`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t}\n\n\treturn Wrapper;\n}\n\n/** Symbol key for storing the `DurableObject` instance */\nconst kInstance = Symbol(\"kInstance\");\n/** Symbol key for the instance initialization method */\nconst kEnsureInstance = Symbol(\"kEnsureInstance\");\n\n/**\n * Container for a `DurableObject` constructor and its instance.\n */\ninterface DurableObjectInstance {\n\tctor: DurableObjectConstructor;\n\tinstance: DurableObject;\n}\n\n/**\n * Extended `DurableObject` interface that includes instance management methods.\n */\ninterface DurableObjectWrapper extends DurableObject<WrapperEnv> {\n\t[kInstance]?: DurableObjectInstance;\n\t[kEnsureInstance](): Promise<DurableObjectInstance>;\n}\n\n/**\n * Retrieves an RPC property from a `DurableObject` export, ensuring an instance is properly initialized and returning the bound method or property value.\n * @param exportName - The name of the `DurableObject` export\n * @param key - The property key to access on the `DurableObject` instance\n * @returns The property value, with methods bound to the instance\n * @throws TypeError if the export is not a `DurableObject` subclass\n */\nasync function getDurableObjectRpcProperty(\n\tthis: DurableObjectWrapper,\n\texportName: string,\n\tkey: string\n): Promise<unknown> {\n\tconst { ctor, instance } = await this[kEnsureInstance]();\n\n\tif (!(instance instanceof DurableObject)) {\n\t\tthrow new TypeError(\n\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to be a subclass of \\`DurableObject\\` for RPC.`\n\t\t);\n\t}\n\n\tconst value = getRpcProperty(ctor, instance, key);\n\n\tif (typeof value === \"function\") {\n\t\treturn value.bind(instance);\n\t}\n\n\treturn value;\n}\n\n/**\n * Creates a proxy wrapper for `DurableObject` classes that enables RPC functionality.\n * The wrapper manages instance lifecycle and delegates method calls to the user code, handling both direct method calls and RPC property access.\n * @param exportName - The name of the `DurableObject` export to wrap\n * @returns A `DurableObject` constructor that acts as a proxy to the user code\n */\nexport function createDurableObjectWrapper(\n\texportName: string\n): DurableObjectConstructor<WrapperEnv> {\n\tclass Wrapper\n\t\textends DurableObject<WrapperEnv>\n\t\timplements DurableObjectWrapper\n\t{\n\t\t[kInstance]?: DurableObjectInstance;\n\n\t\tconstructor(ctx: DurableObjectState, env: WrapperEnv) {\n\t\t\tsuper(ctx, env);\n\n\t\t\treturn new Proxy(this, {\n\t\t\t\tget(target, key, receiver) {\n\t\t\t\t\tconst value = Reflect.get(target, key, receiver);\n\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof key === \"symbol\" ||\n\t\t\t\t\t\t(IGNORED_KEYS as readonly string[]).includes(key) ||\n\t\t\t\t\t\t// The class methods are accessed to determine the type of the export.\n\t\t\t\t\t\t// We should therefore avoid proxying `WorkerEntrypoint` methods on the `DurableObject` class.\n\t\t\t\t\t\t(WORKER_ENTRYPOINT_KEYS as readonly string[]).includes(key)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst property = getDurableObjectRpcProperty.call(\n\t\t\t\t\t\treceiver,\n\t\t\t\t\t\texportName,\n\t\t\t\t\t\tkey\n\t\t\t\t\t);\n\n\t\t\t\t\treturn getRpcPropertyCallableThenable(key, property);\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tasync [kEnsureInstance]() {\n\t\t\tconst ctor = (await getWorkerEntryExport(\n\t\t\t\tworkerEntryPath,\n\t\t\t\texportName\n\t\t\t)) as DurableObjectConstructor;\n\n\t\t\tif (typeof ctor !== \"function\") {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to be a subclass of \\`DurableObject\\`.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// We reuse the same instance unless the constructor changes\n\t\t\tif (!this[kInstance] || this[kInstance].ctor !== ctor) {\n\t\t\t\tconst userEnv = stripInternalEnv(this.env);\n\t\t\t\tconst instance = new ctor(this.ctx, userEnv);\n\n\t\t\t\tthis[kInstance] = { ctor, instance };\n\n\t\t\t\t// Wait for `blockConcurrencyWhile()`s in the constructor to complete\n\t\t\t\tawait this.ctx.blockConcurrencyWhile(async () => {});\n\t\t\t}\n\n\t\t\treturn this[kInstance];\n\t\t}\n\t}\n\n\tfor (const key of DURABLE_OBJECT_KEYS) {\n\t\tWrapper.prototype[key] = async function (...args: unknown[]) {\n\t\t\tconst { instance } = await this[kEnsureInstance]();\n\t\t\tconst maybeFn = instance[key];\n\n\t\t\tif (typeof maybeFn !== \"function\") {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to define a \\`${key}()\\` function.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- dynamic method assignment in a loop can't satisfy the intersection of all method signatures\n\t\t\treturn (maybeFn as (...args: unknown[]) => any).apply(instance, args);\n\t\t};\n\t}\n\n\treturn Wrapper;\n}\n\n/**\n * Creates a proxy wrapper for `WorkflowEntrypoint` classes.\n * The wrapper delegates method calls to the user code.\n * @param exportName - The name of the `WorkflowEntrypoint` export to wrap\n * @returns A `WorkflowEntrypoint` constructor that acts as a proxy to the user code\n */\nexport function createWorkflowEntrypointWrapper(\n\texportName: string\n): WorkflowEntrypointConstructor<WrapperEnv> {\n\tclass Wrapper extends WorkflowEntrypoint<WrapperEnv> {}\n\n\tfor (const key of WORKFLOW_ENTRYPOINT_KEYS) {\n\t\tWrapper.prototype[key] = async function (...args: unknown[]) {\n\t\t\tconst ctor = (await getWorkerEntryExport(\n\t\t\t\tworkerEntryPath,\n\t\t\t\texportName\n\t\t\t)) as WorkflowEntrypointConstructor;\n\t\t\tconst userEnv = stripInternalEnv(this.env);\n\t\t\tconst instance = new ctor(this.ctx, userEnv);\n\n\t\t\tif (!(instance instanceof WorkflowEntrypoint)) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to be a subclass of \\`WorkflowEntrypoint\\`.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst maybeFn = instance[key];\n\n\t\t\tif (typeof maybeFn !== \"function\") {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Expected \"${exportName}\" export of \"${workerEntryPath}\" to define a \\`${key}()\\` function.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (maybeFn as (...args: unknown[]) => unknown).apply(instance, args);\n\t\t};\n\t}\n\n\treturn Wrapper;\n}\n"],"mappings":";;;AAAA,MAAa,eAAe;AAQ5B,MAAa,2BAA2B;AACxC,MAAa,yBAAyB;AACtC,MAAa,0BAA0B;AAIvC,MAAa,gBAAgB;AAC7B,MAAa,uBAAuB,GAAG,cAAc;AACrD,MAAa,uBAAuB,GAAG,cAAc;;;;;;;;ACSrD,SAAgB,iBAAiB,aAAyB;CACzD,MAAM,EACL,wBACA,wBACA,sBACA,GAAG,YACA;CAEJ,OAAO;AACR;;;;;;;AC1BA,SAAS,YAAY,GAAqB;CACzC,MAAM,WAAY,KAAK,CAAC;CACxB,OAAO;EACN,MAAM,SAAS;EACf,SAAS,SAAS,WAAW,OAAO,CAAC;EACrC,OAAO,SAAS;EAChB,OACC,SAAS,UAAU,KAAA,IAAY,KAAA,IAAY,YAAY,SAAS,KAAK;CACvE;AACD;;;;;;AAOA,eAAsB,kBACrB,SACA,IACC;CACD,IACC,CAAC,QAAQ,iBACT,QAAQ,eAAe,aACvB,QAAQ,QAAQ,SAEhB,OAAO,GAAG;CAGX,IAAI;EACH,OAAO,MAAM,GAAG;CACjB,SAAS,OAAO;EACf,OAAO,SAAS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,kBAAkB,IAAI,eAC9E;EAID,OAAQ,QAAwC,MAAM,UAAU,IAAI;CACrE;CAGD,OAAO;AACR;;;;;;;AAQA,SAAgB,gCACf,YAC4C;CAC5C,MAAM,gBAAgB,mBAA+B,CAAC;CAEtD,KAAK,MAAM,OAAO,0BACjB,QAAQ,UAAU,OAAO,eAAgB,GAAG,MAAiB;EAC5D,MAAM,OAAQ,MAAM,qBACnB,iBACA,UACD;EACA,MAAM,UAAU,iBAAiB,KAAK,GAAG;EACzC,MAAM,WAAW,IAAI,KAAK,KAAK,KAAK,OAAO;EAE3C,IAAI,EAAE,oBAAoB,qBACzB,MAAM,IAAI,UACT,aAAa,WAAW,eAAe,gBAAgB,8CACxD;EAGD,MAAM,UAAU,SAAS;EAEzB,IAAI,OAAO,YAAY,YACtB,MAAM,IAAI,UACT,aAAa,WAAW,eAAe,gBAAgB,kBAAkB,IAAI,eAC9E;EAGD,OAAQ,QAA4C,MAAM,UAAU,IAAI;CACzE;CAGD,OAAO;AACR"}
|
|
@@ -39,7 +39,8 @@ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
|
39
39
|
function normalizeWindowsPath(input = "") {
|
|
40
40
|
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
41
41
|
}
|
|
42
|
-
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]
|
|
42
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
43
|
+
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
43
44
|
function cwd() {
|
|
44
45
|
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
45
46
|
}
|
|
@@ -79,14 +80,24 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
79
80
|
}
|
|
80
81
|
const isAbsolute = function(p) {
|
|
81
82
|
return _IS_ABSOLUTE_RE.test(p);
|
|
82
|
-
}
|
|
83
|
+
};
|
|
84
|
+
const dirname = function(p) {
|
|
83
85
|
let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
84
86
|
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
85
|
-
}
|
|
87
|
+
};
|
|
88
|
+
const decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8");
|
|
89
|
+
const percentRegEx = /%/g;
|
|
90
|
+
const backslashRegEx = /\\/g;
|
|
91
|
+
const newlineRegEx = /\n/g;
|
|
92
|
+
const carriageReturnRegEx = /\r/g;
|
|
93
|
+
const tabRegEx = /\t/g;
|
|
94
|
+
const questionRegex = /\?/g;
|
|
95
|
+
const hashRegex = /#/g;
|
|
86
96
|
function encodePathChars(filepath) {
|
|
87
97
|
return filepath.indexOf("%") !== -1 && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.indexOf("\\") !== -1 && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.indexOf("\n") !== -1 && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.indexOf("\r") !== -1 && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.indexOf(" ") !== -1 && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
|
|
88
98
|
}
|
|
89
|
-
const posixDirname = dirname
|
|
99
|
+
const posixDirname = dirname;
|
|
100
|
+
const posixResolve = resolve;
|
|
90
101
|
function posixPathToFileHref(posixPath) {
|
|
91
102
|
let resolved = posixResolve(posixPath), filePathLast = posixPath.charCodeAt(posixPath.length - 1);
|
|
92
103
|
return (filePathLast === 47 || isWindows && filePathLast === 92) && resolved[resolved.length - 1] !== "/" && (resolved += "/"), resolved = encodePathChars(resolved), resolved.indexOf("?") !== -1 && (resolved = resolved.replace(questionRegex, "%3F")), resolved.indexOf("#") !== -1 && (resolved = resolved.replace(hashRegex, "%23")), new URL(`file://${resolved}`).href;
|
|
@@ -94,7 +105,10 @@ function posixPathToFileHref(posixPath) {
|
|
|
94
105
|
function toWindowsPath(path) {
|
|
95
106
|
return path.replace(/\//g, "\\");
|
|
96
107
|
}
|
|
97
|
-
var comma = 44
|
|
108
|
+
var comma = 44;
|
|
109
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
110
|
+
var intToChar = /* @__PURE__ */ new Uint8Array(64);
|
|
111
|
+
var charToInt = /* @__PURE__ */ new Uint8Array(128);
|
|
98
112
|
for (let i = 0; i < chars.length; i++) {
|
|
99
113
|
let c = chars.charCodeAt(i);
|
|
100
114
|
intToChar[i] = c, charToInt[c] = i;
|
|
@@ -154,7 +168,12 @@ function sort(line) {
|
|
|
154
168
|
function sortComparator(a, b) {
|
|
155
169
|
return a[0] - b[0];
|
|
156
170
|
}
|
|
157
|
-
var COLUMN = 0
|
|
171
|
+
var COLUMN = 0;
|
|
172
|
+
var SOURCES_INDEX = 1;
|
|
173
|
+
var SOURCE_LINE = 2;
|
|
174
|
+
var SOURCE_COLUMN = 3;
|
|
175
|
+
var NAMES_INDEX = 4;
|
|
176
|
+
var found = !1;
|
|
158
177
|
function binarySearch(haystack, needle, low, high) {
|
|
159
178
|
for (; low <= high;) {
|
|
160
179
|
let mid = low + (high - low >> 1), cmp = haystack[mid][COLUMN] - needle;
|
|
@@ -179,7 +198,10 @@ function memoizedBinarySearch(haystack, needle, state, key) {
|
|
|
179
198
|
}
|
|
180
199
|
return state.lastKey = key, state.lastNeedle = needle, state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
181
200
|
}
|
|
182
|
-
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)"
|
|
201
|
+
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
202
|
+
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
203
|
+
var LEAST_UPPER_BOUND = -1;
|
|
204
|
+
var GREATEST_LOWER_BOUND = 1;
|
|
183
205
|
function cast(map) {
|
|
184
206
|
return map;
|
|
185
207
|
}
|
|
@@ -250,7 +272,8 @@ var EvaluatedModuleNode = class {
|
|
|
250
272
|
constructor(id, url) {
|
|
251
273
|
this.id = id, this.url = url, this.file = cleanUrl(id);
|
|
252
274
|
}
|
|
253
|
-
}
|
|
275
|
+
};
|
|
276
|
+
var EvaluatedModules = class {
|
|
254
277
|
idToModuleMap = /* @__PURE__ */ new Map();
|
|
255
278
|
fileToModulesMap = /* @__PURE__ */ new Map();
|
|
256
279
|
urlToIdModuleMap = /* @__PURE__ */ new Map();
|
|
@@ -290,7 +313,7 @@ var EvaluatedModuleNode = class {
|
|
|
290
313
|
this.idToModuleMap.clear(), this.fileToModulesMap.clear(), this.urlToIdModuleMap.clear();
|
|
291
314
|
}
|
|
292
315
|
};
|
|
293
|
-
const prefixedBuiltins = new Set([
|
|
316
|
+
const prefixedBuiltins = /* @__PURE__ */ new Set([
|
|
294
317
|
"node:sea",
|
|
295
318
|
"node:sqlite",
|
|
296
319
|
"node:test",
|
|
@@ -380,7 +403,8 @@ var HMRContext = class {
|
|
|
380
403
|
fn: callback
|
|
381
404
|
}), this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
|
|
382
405
|
}
|
|
383
|
-
}
|
|
406
|
+
};
|
|
407
|
+
var HMRClient = class {
|
|
384
408
|
hotModulesMap = /* @__PURE__ */ new Map();
|
|
385
409
|
disposeMap = /* @__PURE__ */ new Map();
|
|
386
410
|
pruneMap = /* @__PURE__ */ new Map();
|
|
@@ -548,7 +572,8 @@ const createInvokeableTransport = (transport) => {
|
|
|
548
572
|
}
|
|
549
573
|
}
|
|
550
574
|
};
|
|
551
|
-
}
|
|
575
|
+
};
|
|
576
|
+
const normalizeModuleRunnerTransport = (transport) => {
|
|
552
577
|
let invokeableTransport = createInvokeableTransport(transport), isConnected = !invokeableTransport.connect, connectingPromise;
|
|
553
578
|
return {
|
|
554
579
|
...transport,
|
|
@@ -582,7 +607,8 @@ const createInvokeableTransport = (transport) => {
|
|
|
582
607
|
return invokeableTransport.invoke(name, data);
|
|
583
608
|
}
|
|
584
609
|
};
|
|
585
|
-
}
|
|
610
|
+
};
|
|
611
|
+
const createWebSocketModuleRunnerTransport = (options) => {
|
|
586
612
|
let pingInterval = options.pingInterval ?? 3e4, ws, pingIntervalId;
|
|
587
613
|
return {
|
|
588
614
|
async connect({ onMessage, onDisconnection }) {
|
|
@@ -620,10 +646,19 @@ const createInvokeableTransport = (transport) => {
|
|
|
620
646
|
ws.send(JSON.stringify(data));
|
|
621
647
|
}
|
|
622
648
|
};
|
|
623
|
-
}
|
|
649
|
+
};
|
|
650
|
+
const ssrModuleExportsKey = "__vite_ssr_exports__";
|
|
651
|
+
const ssrImportKey = "__vite_ssr_import__";
|
|
652
|
+
const ssrDynamicImportKey = "__vite_ssr_dynamic_import__";
|
|
653
|
+
const ssrExportAllKey = "__vite_ssr_exportAll__";
|
|
654
|
+
const ssrExportNameKey = "__vite_ssr_exportName__";
|
|
655
|
+
const ssrImportMetaKey = "__vite_ssr_import_meta__";
|
|
656
|
+
const noop = () => {};
|
|
657
|
+
const silentConsole = {
|
|
624
658
|
debug: noop,
|
|
625
659
|
error: noop
|
|
626
|
-
}
|
|
660
|
+
};
|
|
661
|
+
const hmrLogger = {
|
|
627
662
|
debug: (...msg) => console.log("[vite]", ...msg),
|
|
628
663
|
error: (error) => console.log("[vite]", error)
|
|
629
664
|
};
|
|
@@ -715,13 +750,20 @@ function findAllEntrypoints(runner, entrypoints = /* @__PURE__ */ new Set()) {
|
|
|
715
750
|
for (let mod of runner.evaluatedModules.idToModuleMap.values()) mod.importers.size || entrypoints.add(mod.url);
|
|
716
751
|
return entrypoints;
|
|
717
752
|
}
|
|
718
|
-
const sourceMapCache = {}
|
|
753
|
+
const sourceMapCache = {};
|
|
754
|
+
const fileContentsCache = {};
|
|
755
|
+
const evaluatedModulesCache = /* @__PURE__ */ new Set();
|
|
756
|
+
const retrieveFileHandlers = /* @__PURE__ */ new Set();
|
|
757
|
+
const retrieveSourceMapHandlers = /* @__PURE__ */ new Set();
|
|
758
|
+
const createExecHandlers = (handlers) => ((...args) => {
|
|
719
759
|
for (let handler of handlers) {
|
|
720
760
|
let result = handler(...args);
|
|
721
761
|
if (result) return result;
|
|
722
762
|
}
|
|
723
763
|
return null;
|
|
724
|
-
})
|
|
764
|
+
});
|
|
765
|
+
const retrieveFileFromHandlers = createExecHandlers(retrieveFileHandlers);
|
|
766
|
+
const retrieveSourceMapFromHandlers = createExecHandlers(retrieveSourceMapHandlers);
|
|
725
767
|
let overridden = !1;
|
|
726
768
|
const originalPrepare = Error.prepareStackTrace;
|
|
727
769
|
function resetInterceptor(runner, options) {
|
|
@@ -909,7 +951,8 @@ var ESModulesEvaluator = class {
|
|
|
909
951
|
return import(filepath);
|
|
910
952
|
}
|
|
911
953
|
};
|
|
912
|
-
const customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/"
|
|
954
|
+
const customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/";
|
|
955
|
+
const customizationHooksModule = `
|
|
913
956
|
|
|
914
957
|
export async function resolve(specifier, context, nextResolve) {
|
|
915
958
|
if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
|
|
@@ -1124,7 +1167,7 @@ function exportAll(exports, sourceModule) {
|
|
|
1124
1167
|
} catch {}
|
|
1125
1168
|
}
|
|
1126
1169
|
}
|
|
1127
|
-
|
|
1128
1170
|
//#endregion
|
|
1129
1171
|
export { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|
|
1172
|
+
|
|
1130
1173
|
//# sourceMappingURL=module-runner-legacy.js.map
|