@openworkers/adapter-sveltekit 0.5.0 → 0.5.2
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 +13 -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
|
@@ -202,6 +202,9 @@ var version = pkg.version;
|
|
|
202
202
|
function index_default(options = {}) {
|
|
203
203
|
return {
|
|
204
204
|
name,
|
|
205
|
+
supports: {
|
|
206
|
+
read: () => true
|
|
207
|
+
},
|
|
205
208
|
async adapt(builder) {
|
|
206
209
|
const dest = options.outDir ?? "build";
|
|
207
210
|
const assetsDir = `${dest}/assets`;
|
|
@@ -241,8 +244,7 @@ export { Server, manifest, prerendered, base_path };
|
|
|
241
244
|
`
|
|
242
245
|
);
|
|
243
246
|
const workerDest = `${dest}/_worker.js`;
|
|
244
|
-
const libDir = posixify(path2.resolve(files, "
|
|
245
|
-
const libAsyncHooks = `${libDir}/async-hooks.ts`;
|
|
247
|
+
const libDir = posixify(path2.resolve(files, "lib"));
|
|
246
248
|
await build2({
|
|
247
249
|
entryPoints: [`${files}/worker.js`],
|
|
248
250
|
bundle: true,
|
|
@@ -253,15 +255,19 @@ export { Server, manifest, prerendered, base_path };
|
|
|
253
255
|
alias: {
|
|
254
256
|
SERVER: entryPoint,
|
|
255
257
|
MANIFEST: entryPoint,
|
|
256
|
-
"node:async_hooks":
|
|
258
|
+
"node:async_hooks": `${libDir}/async-hooks.js`,
|
|
257
259
|
...nodeCompat ? {
|
|
258
|
-
"path": `${libDir}/node-path.
|
|
259
|
-
"
|
|
260
|
-
"
|
|
260
|
+
"path": `${libDir}/node-path.js`,
|
|
261
|
+
"node:path": `${libDir}/node-path.js`,
|
|
262
|
+
"fs": `${libDir}/node-fs.js`,
|
|
263
|
+
"node:fs": `${libDir}/node-fs.js`,
|
|
264
|
+
"url": `${libDir}/node-url.js`,
|
|
265
|
+
"node:url": `${libDir}/node-url.js`
|
|
261
266
|
} : {}
|
|
262
267
|
},
|
|
263
268
|
external: ["node:*"],
|
|
264
269
|
minifySyntax: true,
|
|
270
|
+
minifyWhitespace: true,
|
|
265
271
|
minifyIdentifiers: true,
|
|
266
272
|
treeShaking: true,
|
|
267
273
|
banner: {
|
|
@@ -320,7 +326,7 @@ globalThis.process = globalThis.process || { env: { NODE_ENV: "production" } };`
|
|
|
320
326
|
function extractEndpointsFromManifest(manifest, serverDir) {
|
|
321
327
|
const endpoints = [];
|
|
322
328
|
for (const [key, entry] of Object.entries(manifest)) {
|
|
323
|
-
if (!key.includes("+server.ts")) continue;
|
|
329
|
+
if (!key.includes("+server.ts") && !key.includes("+server.js")) continue;
|
|
324
330
|
const sourcePath = entry.src;
|
|
325
331
|
if (!sourcePath || !sourcePath.startsWith("src/routes/")) continue;
|
|
326
332
|
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
|
+
};
|