@openworkers/adapter-sveltekit 0.2.2 → 0.2.3
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/files/shims/async_hooks.js +41 -0
- package/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal AsyncLocalStorage shim for OpenWorkers.
|
|
3
|
+
*
|
|
4
|
+
* OpenWorkers creates a fresh V8 context per request.
|
|
5
|
+
* Module-level state is already isolated, so no real async tracking is needed.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export class AsyncLocalStorage {
|
|
9
|
+
#store;
|
|
10
|
+
|
|
11
|
+
run(store, fn, ...args) {
|
|
12
|
+
this.#store = store;
|
|
13
|
+
return fn(...args);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getStore() {
|
|
17
|
+
return this.#store;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Stubs for API completeness
|
|
21
|
+
enterWith(store) {
|
|
22
|
+
this.#store = store;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exit(fn, ...args) {
|
|
26
|
+
this.#store = undefined;
|
|
27
|
+
return fn(...args);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
disable() {
|
|
31
|
+
this.#store = undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static bind(fn) {
|
|
35
|
+
return fn;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static snapshot() {
|
|
39
|
+
return (fn, ...args) => fn(...args);
|
|
40
|
+
}
|
|
41
|
+
}
|
package/index.js
CHANGED
|
@@ -60,6 +60,7 @@ export default function (options = {}) {
|
|
|
60
60
|
|
|
61
61
|
// Bundle worker with esbuild
|
|
62
62
|
const workerDest = `${dest}/worker.js`;
|
|
63
|
+
const shimAsyncHooks = posixify(path.resolve(files, 'shims/async_hooks.js'));
|
|
63
64
|
|
|
64
65
|
await build({
|
|
65
66
|
entryPoints: [`${files}/worker.js`],
|
|
@@ -69,7 +70,8 @@ export default function (options = {}) {
|
|
|
69
70
|
outfile: workerDest,
|
|
70
71
|
alias: {
|
|
71
72
|
SERVER: entryPoint,
|
|
72
|
-
MANIFEST: entryPoint
|
|
73
|
+
MANIFEST: entryPoint,
|
|
74
|
+
'node:async_hooks': shimAsyncHooks
|
|
73
75
|
},
|
|
74
76
|
external: ['node:*'],
|
|
75
77
|
minify: false,
|