@modern-js/runtime-utils 3.9.1 → 3.9.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/dist/cjs/browser/nestedRoutes.js +1 -1
- package/dist/cjs/node/fileReader.js +3 -2
- package/dist/cjs/node/loaderContext/createRequestCtx.js +1 -1
- package/dist/cjs/router.js +1 -1
- package/dist/cjs/universal/async_storage.js +14 -13
- package/dist/esm/browser/nestedRoutes.mjs +1 -1
- package/dist/esm/node/fileReader.mjs +3 -2
- package/dist/esm/node/loaderContext/createRequestCtx.mjs +1 -1
- package/dist/esm/router.mjs +1 -1
- package/dist/esm/universal/async_storage.mjs +4 -2
- package/dist/esm-node/browser/nestedRoutes.mjs +1 -1
- package/dist/esm-node/node/fileReader.mjs +3 -2
- package/dist/esm-node/node/loaderContext/createRequestCtx.mjs +1 -1
- package/dist/esm-node/router.mjs +1 -1
- package/dist/esm-node/universal/async_storage.mjs +14 -13
- package/dist/types/universal/async_storage.server.d.ts +2 -0
- package/package.json +7 -7
|
@@ -68,9 +68,10 @@ class FileReader {
|
|
|
68
68
|
const content = await fs.promises.readFile(path);
|
|
69
69
|
this.storage.set(path, content);
|
|
70
70
|
return this.encodingContent(content, encoding);
|
|
71
|
+
} else {
|
|
72
|
+
this.storage.set(path, null);
|
|
73
|
+
return null;
|
|
71
74
|
}
|
|
72
|
-
this.storage.set(path, null);
|
|
73
|
-
return null;
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
reset(fs) {
|
|
@@ -31,7 +31,7 @@ function createRequestContext(context) {
|
|
|
31
31
|
const _context = context || new Map();
|
|
32
32
|
function get(key) {
|
|
33
33
|
if ('string' == typeof key) return _context.get(key);
|
|
34
|
-
return _context.get(key.symbol) || key.getDefaultValue();
|
|
34
|
+
else return _context.get(key.symbol) || key.getDefaultValue();
|
|
35
35
|
}
|
|
36
36
|
function set(key, value) {
|
|
37
37
|
if ('string' == typeof key) _context.set(key, value);
|
package/dist/cjs/router.js
CHANGED
|
@@ -33,22 +33,23 @@ const getAsyncLocalStorage = async ()=>{
|
|
|
33
33
|
if (isBrowser) {
|
|
34
34
|
console.error('You should not get async storage in browser');
|
|
35
35
|
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return serverStorage.getAsyncLocalStorage();
|
|
40
|
-
} catch (extensionError) {
|
|
41
|
-
try {
|
|
42
|
-
const serverStorage = await import("./async_storage.server");
|
|
36
|
+
} else {
|
|
37
|
+
if (!IS_WEB_FALLBACK) try {
|
|
38
|
+
const serverStorage = await import("./async_storage.server.js");
|
|
43
39
|
return serverStorage.getAsyncLocalStorage();
|
|
44
|
-
} catch (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})
|
|
40
|
+
} catch (extensionError) {
|
|
41
|
+
try {
|
|
42
|
+
const serverStorage = await import("./async_storage.server");
|
|
43
|
+
return serverStorage.getAsyncLocalStorage();
|
|
44
|
+
} catch (fallbackError) {
|
|
45
|
+
console.error('Failed to load server async storage', {
|
|
46
|
+
extensionError: extensionError instanceof Error ? extensionError.message : extensionError,
|
|
47
|
+
fallbackError: fallbackError instanceof Error ? fallbackError.message : fallbackError
|
|
48
|
+
});
|
|
49
|
+
}
|
|
49
50
|
}
|
|
51
|
+
return null;
|
|
50
52
|
}
|
|
51
|
-
return null;
|
|
52
53
|
};
|
|
53
54
|
__webpack_require__.d(__webpack_exports__, {}, {
|
|
54
55
|
getAsyncLocalStorage: getAsyncLocalStorage
|
|
@@ -25,9 +25,10 @@ class FileReader {
|
|
|
25
25
|
const content = await fs.promises.readFile(path);
|
|
26
26
|
this.storage.set(path, content);
|
|
27
27
|
return this.encodingContent(content, encoding);
|
|
28
|
+
} else {
|
|
29
|
+
this.storage.set(path, null);
|
|
30
|
+
return null;
|
|
28
31
|
}
|
|
29
|
-
this.storage.set(path, null);
|
|
30
|
-
return null;
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
reset(fs) {
|
|
@@ -2,7 +2,7 @@ function createRequestContext(context) {
|
|
|
2
2
|
const _context = context || new Map();
|
|
3
3
|
function get(key) {
|
|
4
4
|
if ('string' == typeof key) return _context.get(key);
|
|
5
|
-
return _context.get(key.symbol) || key.getDefaultValue();
|
|
5
|
+
else return _context.get(key.symbol) || key.getDefaultValue();
|
|
6
6
|
}
|
|
7
7
|
function set(key, value) {
|
|
8
8
|
if ('string' == typeof key) _context.set(key, value);
|
package/dist/esm/router.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const isBrowser = "u" > typeof window && void 0 !== window.document;
|
|
2
2
|
const getAsyncLocalStorage = async ()=>{
|
|
3
3
|
if (!isBrowser) return null;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
else {
|
|
5
|
+
console.error('You should not get async storage in browser');
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
6
8
|
};
|
|
7
9
|
export { getAsyncLocalStorage };
|
|
@@ -26,9 +26,10 @@ class FileReader {
|
|
|
26
26
|
const content = await fs.promises.readFile(path);
|
|
27
27
|
this.storage.set(path, content);
|
|
28
28
|
return this.encodingContent(content, encoding);
|
|
29
|
+
} else {
|
|
30
|
+
this.storage.set(path, null);
|
|
31
|
+
return null;
|
|
29
32
|
}
|
|
30
|
-
this.storage.set(path, null);
|
|
31
|
-
return null;
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
reset(fs) {
|
|
@@ -3,7 +3,7 @@ function createRequestContext(context) {
|
|
|
3
3
|
const _context = context || new Map();
|
|
4
4
|
function get(key) {
|
|
5
5
|
if ('string' == typeof key) return _context.get(key);
|
|
6
|
-
return _context.get(key.symbol) || key.getDefaultValue();
|
|
6
|
+
else return _context.get(key.symbol) || key.getDefaultValue();
|
|
7
7
|
}
|
|
8
8
|
function set(key, value) {
|
|
9
9
|
if ('string' == typeof key) _context.set(key, value);
|
package/dist/esm-node/router.mjs
CHANGED
|
@@ -5,21 +5,22 @@ const getAsyncLocalStorage = async ()=>{
|
|
|
5
5
|
if (isBrowser) {
|
|
6
6
|
console.error('You should not get async storage in browser');
|
|
7
7
|
return null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return serverStorage.getAsyncLocalStorage();
|
|
12
|
-
} catch (extensionError) {
|
|
13
|
-
try {
|
|
14
|
-
const serverStorage = await import("./async_storage.server");
|
|
8
|
+
} else {
|
|
9
|
+
if (!IS_WEB_FALLBACK) try {
|
|
10
|
+
const serverStorage = await import("./async_storage.server.mjs");
|
|
15
11
|
return serverStorage.getAsyncLocalStorage();
|
|
16
|
-
} catch (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
12
|
+
} catch (extensionError) {
|
|
13
|
+
try {
|
|
14
|
+
const serverStorage = await import("./async_storage.server");
|
|
15
|
+
return serverStorage.getAsyncLocalStorage();
|
|
16
|
+
} catch (fallbackError) {
|
|
17
|
+
console.error('Failed to load server async storage', {
|
|
18
|
+
extensionError: extensionError instanceof Error ? extensionError.message : extensionError,
|
|
19
|
+
fallbackError: fallbackError instanceof Error ? fallbackError.message : fallbackError
|
|
20
|
+
});
|
|
21
|
+
}
|
|
21
22
|
}
|
|
23
|
+
return null;
|
|
22
24
|
}
|
|
23
|
-
return null;
|
|
24
25
|
};
|
|
25
26
|
export { getAsyncLocalStorage };
|
|
@@ -10,6 +10,7 @@ declare const storage: {
|
|
|
10
10
|
status: number;
|
|
11
11
|
};
|
|
12
12
|
activeDeferreds?: Map<string, unknown>;
|
|
13
|
+
deferredScriptKeys?: Map<string, string[]>;
|
|
13
14
|
serverPayload?: unknown;
|
|
14
15
|
}, cb: () => O | Promise<O>) => Promise<O>;
|
|
15
16
|
useContext: () => {
|
|
@@ -21,6 +22,7 @@ declare const storage: {
|
|
|
21
22
|
status: number;
|
|
22
23
|
};
|
|
23
24
|
activeDeferreds?: Map<string, unknown>;
|
|
25
|
+
deferredScriptKeys?: Map<string, string[]>;
|
|
24
26
|
serverPayload?: unknown;
|
|
25
27
|
};
|
|
26
28
|
};
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.9.
|
|
18
|
+
"version": "3.9.3",
|
|
19
19
|
"_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
|
|
20
20
|
"exports": {
|
|
21
21
|
"./router": {
|
|
@@ -157,10 +157,10 @@
|
|
|
157
157
|
"dependencies": {
|
|
158
158
|
"@swc/helpers": "^0.5.17",
|
|
159
159
|
"lru-cache": "^10.4.3",
|
|
160
|
-
"react-router": "7.
|
|
161
|
-
"serialize-javascript": "^
|
|
162
|
-
"@modern-js/
|
|
163
|
-
"@modern-js/
|
|
160
|
+
"react-router": "7.18.4",
|
|
161
|
+
"serialize-javascript": "^7.0.0",
|
|
162
|
+
"@modern-js/utils": "3.9.3",
|
|
163
|
+
"@modern-js/types": "3.9.3"
|
|
164
164
|
},
|
|
165
165
|
"peerDependencies": {
|
|
166
166
|
"react": ">=18.3.1",
|
|
@@ -175,8 +175,8 @@
|
|
|
175
175
|
}
|
|
176
176
|
},
|
|
177
177
|
"devDependencies": {
|
|
178
|
-
"@rslib/core": "1.0.
|
|
179
|
-
"@types/ioredis-mock": "^8.2.
|
|
178
|
+
"@rslib/core": "1.0.1",
|
|
179
|
+
"@types/ioredis-mock": "^8.2.8",
|
|
180
180
|
"@types/node": "^20",
|
|
181
181
|
"@types/serialize-javascript": "^5.0.4",
|
|
182
182
|
"ioredis-mock": "^8.13.1",
|