@bleedingdev/modern-js-runtime-utils 3.2.0-ultramodern.9 → 3.2.0-ultramodern.91
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.
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
getAsyncLocalStorage: ()=>getAsyncLocalStorage,
|
|
28
|
+
storage: ()=>storage
|
|
29
|
+
});
|
|
30
|
+
const getGlobalAsyncLocalStorage = ()=>{
|
|
31
|
+
const AsyncLocalStorage = globalThis.AsyncLocalStorage;
|
|
32
|
+
return AsyncLocalStorage ? new AsyncLocalStorage() : void 0;
|
|
33
|
+
};
|
|
34
|
+
const createFallbackStorage = ()=>{
|
|
35
|
+
const stack = [];
|
|
36
|
+
return {
|
|
37
|
+
getStore () {
|
|
38
|
+
return stack[stack.length - 1];
|
|
39
|
+
},
|
|
40
|
+
run (context, cb) {
|
|
41
|
+
stack.push(context);
|
|
42
|
+
try {
|
|
43
|
+
const result = cb();
|
|
44
|
+
if (result && 'function' == typeof result.then) return result.finally(()=>{
|
|
45
|
+
stack.pop();
|
|
46
|
+
});
|
|
47
|
+
stack.pop();
|
|
48
|
+
return result;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
stack.pop();
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const createStorage = ()=>{
|
|
57
|
+
const storage = getGlobalAsyncLocalStorage() || createFallbackStorage();
|
|
58
|
+
const run = (context, cb)=>Promise.resolve(storage.run(context, cb));
|
|
59
|
+
const useContext = ()=>{
|
|
60
|
+
const context = storage.getStore();
|
|
61
|
+
if (!context) throw new Error("Can't call useContext out of scope, make sure @modern-js/runtime-utils is a single version in node_modules");
|
|
62
|
+
return context;
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
run,
|
|
66
|
+
useContext
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const storage = createStorage();
|
|
70
|
+
const getAsyncLocalStorage = async ()=>storage;
|
|
71
|
+
exports.getAsyncLocalStorage = __webpack_exports__.getAsyncLocalStorage;
|
|
72
|
+
exports.storage = __webpack_exports__.storage;
|
|
73
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
74
|
+
"getAsyncLocalStorage",
|
|
75
|
+
"storage"
|
|
76
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
77
|
+
Object.defineProperty(exports, '__esModule', {
|
|
78
|
+
value: true
|
|
79
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const getGlobalAsyncLocalStorage = ()=>{
|
|
2
|
+
const AsyncLocalStorage = globalThis.AsyncLocalStorage;
|
|
3
|
+
return AsyncLocalStorage ? new AsyncLocalStorage() : void 0;
|
|
4
|
+
};
|
|
5
|
+
const createFallbackStorage = ()=>{
|
|
6
|
+
const stack = [];
|
|
7
|
+
return {
|
|
8
|
+
getStore () {
|
|
9
|
+
return stack[stack.length - 1];
|
|
10
|
+
},
|
|
11
|
+
run (context, cb) {
|
|
12
|
+
stack.push(context);
|
|
13
|
+
try {
|
|
14
|
+
const result = cb();
|
|
15
|
+
if (result && 'function' == typeof result.then) return result.finally(()=>{
|
|
16
|
+
stack.pop();
|
|
17
|
+
});
|
|
18
|
+
stack.pop();
|
|
19
|
+
return result;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
stack.pop();
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const createStorage = ()=>{
|
|
28
|
+
const storage = getGlobalAsyncLocalStorage() || createFallbackStorage();
|
|
29
|
+
const run = (context, cb)=>Promise.resolve(storage.run(context, cb));
|
|
30
|
+
const useContext = ()=>{
|
|
31
|
+
const context = storage.getStore();
|
|
32
|
+
if (!context) throw new Error("Can't call useContext out of scope, make sure @modern-js/runtime-utils is a single version in node_modules");
|
|
33
|
+
return context;
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
run,
|
|
37
|
+
useContext
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const async_storage_server_worker_storage = createStorage();
|
|
41
|
+
const getAsyncLocalStorage = async ()=>async_storage_server_worker_storage;
|
|
42
|
+
export { async_storage_server_worker_storage as storage, getAsyncLocalStorage };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
const getGlobalAsyncLocalStorage = ()=>{
|
|
3
|
+
const AsyncLocalStorage = globalThis.AsyncLocalStorage;
|
|
4
|
+
return AsyncLocalStorage ? new AsyncLocalStorage() : void 0;
|
|
5
|
+
};
|
|
6
|
+
const createFallbackStorage = ()=>{
|
|
7
|
+
const stack = [];
|
|
8
|
+
return {
|
|
9
|
+
getStore () {
|
|
10
|
+
return stack[stack.length - 1];
|
|
11
|
+
},
|
|
12
|
+
run (context, cb) {
|
|
13
|
+
stack.push(context);
|
|
14
|
+
try {
|
|
15
|
+
const result = cb();
|
|
16
|
+
if (result && 'function' == typeof result.then) return result.finally(()=>{
|
|
17
|
+
stack.pop();
|
|
18
|
+
});
|
|
19
|
+
stack.pop();
|
|
20
|
+
return result;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
stack.pop();
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const createStorage = ()=>{
|
|
29
|
+
const storage = getGlobalAsyncLocalStorage() || createFallbackStorage();
|
|
30
|
+
const run = (context, cb)=>Promise.resolve(storage.run(context, cb));
|
|
31
|
+
const useContext = ()=>{
|
|
32
|
+
const context = storage.getStore();
|
|
33
|
+
if (!context) throw new Error("Can't call useContext out of scope, make sure @modern-js/runtime-utils is a single version in node_modules");
|
|
34
|
+
return context;
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
run,
|
|
38
|
+
useContext
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const async_storage_server_worker_storage = createStorage();
|
|
42
|
+
const getAsyncLocalStorage = async ()=>async_storage_server_worker_storage;
|
|
43
|
+
export { async_storage_server_worker_storage as storage, getAsyncLocalStorage };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Monitors } from '@modern-js/types';
|
|
2
|
+
import type { IncomingHttpHeaders } from 'http';
|
|
3
|
+
declare const storage: {
|
|
4
|
+
run: <O>(context: {
|
|
5
|
+
monitors?: Monitors;
|
|
6
|
+
headers?: IncomingHttpHeaders;
|
|
7
|
+
request?: Request;
|
|
8
|
+
responseProxy?: {
|
|
9
|
+
headers: Record<string, string>;
|
|
10
|
+
status: number;
|
|
11
|
+
};
|
|
12
|
+
activeDeferreds?: Map<string, unknown>;
|
|
13
|
+
serverPayload?: unknown;
|
|
14
|
+
}, cb: () => O | Promise<O>) => Promise<O>;
|
|
15
|
+
useContext: () => {
|
|
16
|
+
monitors?: Monitors;
|
|
17
|
+
headers?: IncomingHttpHeaders;
|
|
18
|
+
request?: Request;
|
|
19
|
+
responseProxy?: {
|
|
20
|
+
headers: Record<string, string>;
|
|
21
|
+
status: number;
|
|
22
|
+
};
|
|
23
|
+
activeDeferreds?: Map<string, unknown>;
|
|
24
|
+
serverPayload?: unknown;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
type Storage = typeof storage;
|
|
28
|
+
export { type Storage, storage };
|
|
29
|
+
export declare const getAsyncLocalStorage: () => Promise<Storage>;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.2.0-ultramodern.
|
|
20
|
+
"version": "3.2.0-ultramodern.91",
|
|
21
21
|
"_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
|
|
22
22
|
"exports": {
|
|
23
23
|
"./router": {
|
|
@@ -157,12 +157,12 @@
|
|
|
157
157
|
}
|
|
158
158
|
},
|
|
159
159
|
"dependencies": {
|
|
160
|
-
"@swc/helpers": "^0.5.
|
|
161
|
-
"lru-cache": "^11.
|
|
162
|
-
"react-router": "7.
|
|
160
|
+
"@swc/helpers": "^0.5.23",
|
|
161
|
+
"lru-cache": "^11.5.0",
|
|
162
|
+
"react-router": "7.16.0",
|
|
163
163
|
"serialize-javascript": "^7.0.5",
|
|
164
|
-
"@modern-js/
|
|
165
|
-
"@modern-js/
|
|
164
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.91",
|
|
165
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.91"
|
|
166
166
|
},
|
|
167
167
|
"peerDependencies": {
|
|
168
168
|
"react": "^19.2.6",
|
|
@@ -179,9 +179,9 @@
|
|
|
179
179
|
"devDependencies": {
|
|
180
180
|
"@rslib/core": "0.21.5",
|
|
181
181
|
"@types/ioredis-mock": "^8.2.7",
|
|
182
|
-
"@types/node": "^25.
|
|
182
|
+
"@types/node": "^25.9.1",
|
|
183
183
|
"@types/serialize-javascript": "^5.0.4",
|
|
184
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
184
|
+
"@typescript/native-preview": "7.0.0-dev.20260527.2",
|
|
185
185
|
"ioredis-mock": "^8.13.1",
|
|
186
186
|
"react": "^19.2.6",
|
|
187
187
|
"react-dom": "^19.2.6",
|