@openworkers/adapter-sveltekit 0.5.0 → 0.5.1
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/dist/index.js +9 -7
- package/dist/lib/async-hooks.js +31 -0
- package/dist/lib/node-fs.js +13 -0
- package/dist/lib/node-path.js +27 -0
- package/dist/lib/node-url.js +13 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -241,8 +241,7 @@ export { Server, manifest, prerendered, base_path };
|
|
|
241
241
|
`
|
|
242
242
|
);
|
|
243
243
|
const workerDest = `${dest}/_worker.js`;
|
|
244
|
-
const libDir = posixify(path2.resolve(files, "
|
|
245
|
-
const libAsyncHooks = `${libDir}/async-hooks.ts`;
|
|
244
|
+
const libDir = posixify(path2.resolve(files, "lib"));
|
|
246
245
|
await build2({
|
|
247
246
|
entryPoints: [`${files}/worker.js`],
|
|
248
247
|
bundle: true,
|
|
@@ -253,11 +252,14 @@ export { Server, manifest, prerendered, base_path };
|
|
|
253
252
|
alias: {
|
|
254
253
|
SERVER: entryPoint,
|
|
255
254
|
MANIFEST: entryPoint,
|
|
256
|
-
"node:async_hooks":
|
|
255
|
+
"node:async_hooks": `${libDir}/async-hooks.js`,
|
|
257
256
|
...nodeCompat ? {
|
|
258
|
-
"path": `${libDir}/node-path.
|
|
259
|
-
"
|
|
260
|
-
"
|
|
257
|
+
"path": `${libDir}/node-path.js`,
|
|
258
|
+
"node:path": `${libDir}/node-path.js`,
|
|
259
|
+
"fs": `${libDir}/node-fs.js`,
|
|
260
|
+
"node:fs": `${libDir}/node-fs.js`,
|
|
261
|
+
"url": `${libDir}/node-url.js`,
|
|
262
|
+
"node:url": `${libDir}/node-url.js`
|
|
261
263
|
} : {}
|
|
262
264
|
},
|
|
263
265
|
external: ["node:*"],
|
|
@@ -320,7 +322,7 @@ globalThis.process = globalThis.process || { env: { NODE_ENV: "production" } };`
|
|
|
320
322
|
function extractEndpointsFromManifest(manifest, serverDir) {
|
|
321
323
|
const endpoints = [];
|
|
322
324
|
for (const [key, entry] of Object.entries(manifest)) {
|
|
323
|
-
if (!key.includes("+server.ts")) continue;
|
|
325
|
+
if (!key.includes("+server.ts") && !key.includes("+server.js")) continue;
|
|
324
326
|
const sourcePath = entry.src;
|
|
325
327
|
if (!sourcePath || !sourcePath.startsWith("src/routes/")) continue;
|
|
326
328
|
const routePart = sourcePath.replace(/^src\/routes/, "").replace(/\/\+server\.(ts|js)$/, "");
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/lib/async-hooks.ts
|
|
2
|
+
var AsyncLocalStorage = class {
|
|
3
|
+
#store;
|
|
4
|
+
run(store, fn, ...args) {
|
|
5
|
+
this.#store = store;
|
|
6
|
+
return fn(...args);
|
|
7
|
+
}
|
|
8
|
+
getStore() {
|
|
9
|
+
return this.#store;
|
|
10
|
+
}
|
|
11
|
+
// Stubs for API completeness
|
|
12
|
+
enterWith(store) {
|
|
13
|
+
this.#store = store;
|
|
14
|
+
}
|
|
15
|
+
exit(fn, ...args) {
|
|
16
|
+
this.#store = void 0;
|
|
17
|
+
return fn(...args);
|
|
18
|
+
}
|
|
19
|
+
disable() {
|
|
20
|
+
this.#store = void 0;
|
|
21
|
+
}
|
|
22
|
+
static bind(fn) {
|
|
23
|
+
return fn;
|
|
24
|
+
}
|
|
25
|
+
static snapshot() {
|
|
26
|
+
return (fn, ...args) => fn(...args);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
AsyncLocalStorage
|
|
31
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/lib/node-path.ts
|
|
2
|
+
var sep = "/";
|
|
3
|
+
function dirname(p) {
|
|
4
|
+
return p.replace(/\/[^/]*$/, "") || "/";
|
|
5
|
+
}
|
|
6
|
+
function join(...parts) {
|
|
7
|
+
return parts.join("/").replace(/\/+/g, "/");
|
|
8
|
+
}
|
|
9
|
+
function resolve(...parts) {
|
|
10
|
+
return join(...parts);
|
|
11
|
+
}
|
|
12
|
+
function relative(_from, _to) {
|
|
13
|
+
return _to;
|
|
14
|
+
}
|
|
15
|
+
function isAbsolute(p) {
|
|
16
|
+
return p.startsWith("/");
|
|
17
|
+
}
|
|
18
|
+
var node_path_default = { sep, dirname, join, resolve, relative, isAbsolute };
|
|
19
|
+
export {
|
|
20
|
+
node_path_default as default,
|
|
21
|
+
dirname,
|
|
22
|
+
isAbsolute,
|
|
23
|
+
join,
|
|
24
|
+
relative,
|
|
25
|
+
resolve,
|
|
26
|
+
sep
|
|
27
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/lib/node-url.ts
|
|
2
|
+
function pathToFileURL(p) {
|
|
3
|
+
return new URL(`file://${p}`);
|
|
4
|
+
}
|
|
5
|
+
function fileURLToPath(u) {
|
|
6
|
+
return typeof u === "string" ? u.replace("file://", "") : u.pathname;
|
|
7
|
+
}
|
|
8
|
+
var node_url_default = { pathToFileURL, fileURLToPath };
|
|
9
|
+
export {
|
|
10
|
+
node_url_default as default,
|
|
11
|
+
fileURLToPath,
|
|
12
|
+
pathToFileURL
|
|
13
|
+
};
|