@bleedingdev/modern-js-runtime-utils 3.9.0-ultramodern.2 → 3.9.0-ultramodern.20

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.
@@ -125,7 +125,7 @@ function createLoader(route) {
125
125
  }
126
126
  return res;
127
127
  };
128
- return ()=>{
128
+ else return ()=>{
129
129
  if ('function' == typeof route.lazyImport) route.lazyImport();
130
130
  return null;
131
131
  };
@@ -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);
@@ -69,7 +69,7 @@ var __webpack_exports__ = {};
69
69
  };
70
70
  const defer = (data, init)=>{
71
71
  if (void 0 === init) return data;
72
- {
72
+ else {
73
73
  const responseInit = init ? 'number' == typeof init ? {
74
74
  status: init
75
75
  } : init : void 0;
@@ -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
- if (!IS_WEB_FALLBACK) try {
38
- const serverStorage = await import("./async_storage.server.js");
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 (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
- });
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
@@ -92,7 +92,7 @@ function createLoader(route) {
92
92
  }
93
93
  return res;
94
94
  };
95
- return ()=>{
95
+ else return ()=>{
96
96
  if ('function' == typeof route.lazyImport) route.lazyImport();
97
97
  return null;
98
98
  };
@@ -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);
@@ -8,7 +8,7 @@ const json = (data, init)=>{
8
8
  };
9
9
  const defer = (data, init)=>{
10
10
  if (void 0 === init) return data;
11
- {
11
+ else {
12
12
  const responseInit = init ? 'number' == typeof init ? {
13
13
  status: init
14
14
  } : init : void 0;
@@ -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
- console.error('You should not get async storage in browser');
5
- return null;
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
- export { normalizePathname };
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 };
@@ -93,7 +93,7 @@ function createLoader(route) {
93
93
  }
94
94
  return res;
95
95
  };
96
- return ()=>{
96
+ else return ()=>{
97
97
  if ('function' == typeof route.lazyImport) route.lazyImport();
98
98
  return null;
99
99
  };
@@ -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);
@@ -9,7 +9,7 @@ const json = (data, init)=>{
9
9
  };
10
10
  const defer = (data, init)=>{
11
11
  if (void 0 === init) return data;
12
- {
12
+ else {
13
13
  const responseInit = init ? 'number' == typeof init ? {
14
14
  status: init
15
15
  } : init : void 0;
@@ -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
- if (!IS_WEB_FALLBACK) try {
10
- const serverStorage = await import("./async_storage.server.mjs");
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 (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
- });
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 };
@@ -3,4 +3,17 @@ function normalizePathname(pathname) {
3
3
  const normalized = '/' + pathname.replace(/^\/+|\/+$/g, '');
4
4
  return normalized;
5
5
  }
6
- export { normalizePathname };
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 };
@@ -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.2",
20
+ "version": "3.9.0-ultramodern.20",
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.2",
147
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.2",
150
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.20",
151
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.20",
148
152
  "@swc/helpers": "^0.5.23",
149
- "lru-cache": "^11.5.2",
150
- "react-router": "7.18.2"
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.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.4.1",
172
+ "@types/node": "^26.6.2",
169
173
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
170
- "happy-dom": "^20.14.0",
174
+ "happy-dom": "^20.14.5",
171
175
  "ioredis": "^5.11.1",
172
176
  "ioredis-mock": "^8.13.1",
173
- "react": "^19.2.8",
174
- "react-dom": "^19.2.8",
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 --passWithNoTests"
185
+ "test": "rstest"
182
186
  }
183
187
  }