@bleedingdev/modern-js-runtime-utils 3.9.0-ultramodern.2 → 3.9.0-ultramodern.21
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/cjs/url.js +18 -1
- 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/url.mjs +14 -1
- 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/esm-node/url.mjs +14 -1
- package/dist/types/url.d.ts +6 -0
- package/package.json +16 -12
|
@@ -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
|
package/dist/cjs/url.js
CHANGED
|
@@ -31,12 +31,29 @@ function normalizePathname(pathname) {
|
|
|
31
31
|
const normalized = '/' + pathname.replace(/^\/+|\/+$/g, '');
|
|
32
32
|
return normalized;
|
|
33
33
|
}
|
|
34
|
+
const splitUrlTarget = (target)=>{
|
|
35
|
+
const hashIndex = target.indexOf('#');
|
|
36
|
+
const hash = hashIndex >= 0 ? target.slice(hashIndex) : '';
|
|
37
|
+
const beforeHash = hashIndex >= 0 ? target.slice(0, hashIndex) : target;
|
|
38
|
+
const searchIndex = beforeHash.indexOf('?');
|
|
39
|
+
const search = searchIndex >= 0 ? beforeHash.slice(searchIndex) : '';
|
|
40
|
+
const pathname = searchIndex >= 0 ? beforeHash.slice(0, searchIndex) : beforeHash;
|
|
41
|
+
return {
|
|
42
|
+
pathname,
|
|
43
|
+
search,
|
|
44
|
+
hash
|
|
45
|
+
};
|
|
46
|
+
};
|
|
34
47
|
__webpack_require__.d(__webpack_exports__, {
|
|
35
48
|
normalizePathname: ()=>normalizePathname
|
|
49
|
+
}, {
|
|
50
|
+
splitUrlTarget: splitUrlTarget
|
|
36
51
|
});
|
|
37
52
|
exports.normalizePathname = __webpack_exports__.normalizePathname;
|
|
53
|
+
exports.splitUrlTarget = __webpack_exports__.splitUrlTarget;
|
|
38
54
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
39
|
-
"normalizePathname"
|
|
55
|
+
"normalizePathname",
|
|
56
|
+
"splitUrlTarget"
|
|
40
57
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
41
58
|
Object.defineProperty(exports, '__esModule', {
|
|
42
59
|
value: true
|
|
@@ -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 };
|
package/dist/esm/url.mjs
CHANGED
|
@@ -2,4 +2,17 @@ function normalizePathname(pathname) {
|
|
|
2
2
|
const normalized = '/' + pathname.replace(/^\/+|\/+$/g, '');
|
|
3
3
|
return normalized;
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
const splitUrlTarget = (target)=>{
|
|
6
|
+
const hashIndex = target.indexOf('#');
|
|
7
|
+
const hash = hashIndex >= 0 ? target.slice(hashIndex) : '';
|
|
8
|
+
const beforeHash = hashIndex >= 0 ? target.slice(0, hashIndex) : target;
|
|
9
|
+
const searchIndex = beforeHash.indexOf('?');
|
|
10
|
+
const search = searchIndex >= 0 ? beforeHash.slice(searchIndex) : '';
|
|
11
|
+
const pathname = searchIndex >= 0 ? beforeHash.slice(0, searchIndex) : beforeHash;
|
|
12
|
+
return {
|
|
13
|
+
pathname,
|
|
14
|
+
search,
|
|
15
|
+
hash
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export { normalizePathname, splitUrlTarget };
|
|
@@ -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 };
|
package/dist/esm-node/url.mjs
CHANGED
|
@@ -3,4 +3,17 @@ function normalizePathname(pathname) {
|
|
|
3
3
|
const normalized = '/' + pathname.replace(/^\/+|\/+$/g, '');
|
|
4
4
|
return normalized;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
const splitUrlTarget = (target)=>{
|
|
7
|
+
const hashIndex = target.indexOf('#');
|
|
8
|
+
const hash = hashIndex >= 0 ? target.slice(hashIndex) : '';
|
|
9
|
+
const beforeHash = hashIndex >= 0 ? target.slice(0, hashIndex) : target;
|
|
10
|
+
const searchIndex = beforeHash.indexOf('?');
|
|
11
|
+
const search = searchIndex >= 0 ? beforeHash.slice(searchIndex) : '';
|
|
12
|
+
const pathname = searchIndex >= 0 ? beforeHash.slice(0, searchIndex) : beforeHash;
|
|
13
|
+
return {
|
|
14
|
+
pathname,
|
|
15
|
+
search,
|
|
16
|
+
hash
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export { normalizePathname, splitUrlTarget };
|
package/dist/types/url.d.ts
CHANGED
|
@@ -9,3 +9,9 @@
|
|
|
9
9
|
* pathname3: '/', the nomalizeResult also as '/'
|
|
10
10
|
*/
|
|
11
11
|
export declare function normalizePathname(pathname: string): string;
|
|
12
|
+
/** Split a relative target without decoding or normalizing its suffix. */
|
|
13
|
+
export declare const splitUrlTarget: (target: string) => {
|
|
14
|
+
pathname: string;
|
|
15
|
+
search: string;
|
|
16
|
+
hash: string;
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.9.0-ultramodern.
|
|
20
|
+
"version": "3.9.0-ultramodern.21",
|
|
21
21
|
"_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
|
|
22
22
|
"exports": {
|
|
23
23
|
"./router": {
|
|
@@ -80,7 +80,11 @@
|
|
|
80
80
|
},
|
|
81
81
|
"./url": {
|
|
82
82
|
"types": "./dist/types/url.d.ts",
|
|
83
|
-
"default": "./dist/esm/url.mjs"
|
|
83
|
+
"default": "./dist/esm/url.mjs",
|
|
84
|
+
"node": {
|
|
85
|
+
"import": "./dist/esm-node/url.mjs",
|
|
86
|
+
"require": "./dist/cjs/url.js"
|
|
87
|
+
}
|
|
84
88
|
},
|
|
85
89
|
"./merge": {
|
|
86
90
|
"types": "./dist/types/merge.d.ts",
|
|
@@ -143,11 +147,11 @@
|
|
|
143
147
|
}
|
|
144
148
|
},
|
|
145
149
|
"dependencies": {
|
|
146
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.
|
|
147
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.
|
|
150
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.21",
|
|
151
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.21",
|
|
148
152
|
"@swc/helpers": "^0.5.23",
|
|
149
|
-
"lru-cache": "^11.5.
|
|
150
|
-
"react-router": "7.18.
|
|
153
|
+
"lru-cache": "^11.5.3",
|
|
154
|
+
"react-router": "7.18.4"
|
|
151
155
|
},
|
|
152
156
|
"peerDependencies": {
|
|
153
157
|
"react": "^19.2.8",
|
|
@@ -162,22 +166,22 @@
|
|
|
162
166
|
}
|
|
163
167
|
},
|
|
164
168
|
"devDependencies": {
|
|
165
|
-
"@rslib/core": "1.0.
|
|
169
|
+
"@rslib/core": "1.0.2",
|
|
166
170
|
"@scripts/rstest-config": "2.66.0",
|
|
167
171
|
"@types/ioredis-mock": "^8.2.8",
|
|
168
|
-
"@types/node": "^26.
|
|
172
|
+
"@types/node": "^26.6.2",
|
|
169
173
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
170
|
-
"happy-dom": "^20.14.
|
|
174
|
+
"happy-dom": "^20.14.5",
|
|
171
175
|
"ioredis": "^5.11.1",
|
|
172
176
|
"ioredis-mock": "^8.13.1",
|
|
173
|
-
"react": "^19.
|
|
174
|
-
"react-dom": "^19.
|
|
177
|
+
"react": "^19.3.0",
|
|
178
|
+
"react-dom": "^19.3.0",
|
|
175
179
|
"typescript": "^7.0.2"
|
|
176
180
|
},
|
|
177
181
|
"sideEffects": false,
|
|
178
182
|
"scripts": {
|
|
179
183
|
"dev": "rslib build --watch",
|
|
180
184
|
"build": "rslib build",
|
|
181
|
-
"test": "rstest
|
|
185
|
+
"test": "rstest"
|
|
182
186
|
}
|
|
183
187
|
}
|