@bleedingdev/modern-js-server-core 3.5.0-ultramodern.97 → 3.5.0-ultramodern.99
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/plugins/render/render.js +5 -2
- package/dist/cjs/utils/storage.js +12 -8
- package/dist/esm/adapters/node/plugins/static.mjs +2 -2
- package/dist/esm/plugins/render/render.mjs +1 -1
- package/dist/esm/utils/storage.mjs +12 -8
- package/dist/esm-node/adapters/node/plugins/static.mjs +2 -2
- package/dist/esm-node/plugins/render/render.mjs +1 -1
- package/dist/esm-node/utils/storage.mjs +12 -8
- package/dist/types/plugins/render/render.d.ts +4 -0
- package/dist/types/types/config/dev.d.ts +6 -0
- package/dist/types/utils/storage.d.ts +2 -1
- package/package.json +7 -6
|
@@ -43,7 +43,8 @@ var __webpack_exports__ = {};
|
|
|
43
43
|
(()=>{
|
|
44
44
|
__webpack_require__.r(__webpack_exports__);
|
|
45
45
|
__webpack_require__.d(__webpack_exports__, {
|
|
46
|
-
createRender: ()=>createRender
|
|
46
|
+
createRender: ()=>createRender,
|
|
47
|
+
matchRoute: ()=>matchRoute
|
|
47
48
|
});
|
|
48
49
|
const universal_namespaceObject = require("@modern-js/utils/universal");
|
|
49
50
|
const trie_router_namespaceObject = require("hono/router/trie-router");
|
|
@@ -274,8 +275,10 @@ var __webpack_exports__ = {};
|
|
|
274
275
|
}
|
|
275
276
|
})();
|
|
276
277
|
exports.createRender = __webpack_exports__.createRender;
|
|
278
|
+
exports.matchRoute = __webpack_exports__.matchRoute;
|
|
277
279
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
278
|
-
"createRender"
|
|
280
|
+
"createRender",
|
|
281
|
+
"matchRoute"
|
|
279
282
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
280
283
|
Object.defineProperty(exports, '__esModule', {
|
|
281
284
|
value: true
|
|
@@ -31,14 +31,17 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
createStorage: ()=>createStorage
|
|
32
32
|
});
|
|
33
33
|
const external_async_hooks_namespaceObject = require("async_hooks");
|
|
34
|
+
const getGlobalStorage = (storageKey)=>{
|
|
35
|
+
const globalStore = globalThis;
|
|
36
|
+
const key = 'string' == typeof storageKey ? Symbol.for(storageKey) : storageKey;
|
|
37
|
+
const sharedStorage = globalStore[key];
|
|
38
|
+
const storage = sharedStorage ?? new external_async_hooks_namespaceObject.AsyncLocalStorage();
|
|
39
|
+
globalStore[key] = storage;
|
|
40
|
+
return storage;
|
|
41
|
+
};
|
|
34
42
|
const createStorage = (storageKey)=>{
|
|
35
43
|
let storage;
|
|
36
|
-
if (void 0 !== external_async_hooks_namespaceObject.AsyncLocalStorage)
|
|
37
|
-
const globalStore = globalThis;
|
|
38
|
-
const sharedStorage = globalStore[storageKey];
|
|
39
|
-
storage = sharedStorage ?? new external_async_hooks_namespaceObject.AsyncLocalStorage();
|
|
40
|
-
globalStore[storageKey] = storage;
|
|
41
|
-
} else storage = new external_async_hooks_namespaceObject.AsyncLocalStorage();
|
|
44
|
+
if (void 0 !== external_async_hooks_namespaceObject.AsyncLocalStorage) storage = storageKey ? getGlobalStorage(storageKey) : new external_async_hooks_namespaceObject.AsyncLocalStorage();
|
|
42
45
|
const run = (context, cb)=>{
|
|
43
46
|
if (!storage) throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
44
47
|
`);
|
|
@@ -56,12 +59,13 @@ const createStorage = (storageKey)=>{
|
|
|
56
59
|
if (!storage) throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
57
60
|
`);
|
|
58
61
|
const context = storage.getStore();
|
|
59
|
-
if (!context) throw new Error("Can't call
|
|
62
|
+
if (!context) throw new Error("Can't call useContext out of server scope");
|
|
60
63
|
return context;
|
|
61
64
|
};
|
|
62
65
|
return {
|
|
63
66
|
run,
|
|
64
|
-
useContext
|
|
67
|
+
useContext,
|
|
68
|
+
useHonoContext: useContext
|
|
65
69
|
};
|
|
66
70
|
};
|
|
67
71
|
exports.createStorage = __webpack_exports__.createStorage;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path_0 from "path";
|
|
2
2
|
import { sortRoutes } from "../../../utils/index.mjs";
|
|
3
3
|
import { getPublicDirPatterns } from "../../../utils/publicDir.mjs";
|
|
4
4
|
import { createModuleFederationStaticServing, servePreCompressedPublicRouteAsset, servePublicDirectoryAsset } from "./staticServing.mjs";
|
|
@@ -87,7 +87,7 @@ function createStaticMiddleware(options) {
|
|
|
87
87
|
return async (c, next)=>{
|
|
88
88
|
const pageRoute = c.get('route');
|
|
89
89
|
const pathname = c.req.path;
|
|
90
|
-
if (pageRoute && '' ===
|
|
90
|
+
if (pageRoute && '' === path_0.extname(pathname)) return next();
|
|
91
91
|
const hit = staticPathRegExp.test(pathname);
|
|
92
92
|
const staticServingRequest = await moduleFederationStaticServing.resolveRequest(pathname);
|
|
93
93
|
if (null === staticServingRequest) return next();
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as __rspack_external_async_hooks from "async_hooks";
|
|
2
|
+
const getGlobalStorage = (storageKey)=>{
|
|
3
|
+
const globalStore = globalThis;
|
|
4
|
+
const key = 'string' == typeof storageKey ? Symbol.for(storageKey) : storageKey;
|
|
5
|
+
const sharedStorage = globalStore[key];
|
|
6
|
+
const storage = sharedStorage ?? new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
7
|
+
globalStore[key] = storage;
|
|
8
|
+
return storage;
|
|
9
|
+
};
|
|
2
10
|
const createStorage = (storageKey)=>{
|
|
3
11
|
let storage;
|
|
4
|
-
if (void 0 !== __rspack_external_async_hooks.AsyncLocalStorage)
|
|
5
|
-
const globalStore = globalThis;
|
|
6
|
-
const sharedStorage = globalStore[storageKey];
|
|
7
|
-
storage = sharedStorage ?? new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
8
|
-
globalStore[storageKey] = storage;
|
|
9
|
-
} else storage = new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
12
|
+
if (void 0 !== __rspack_external_async_hooks.AsyncLocalStorage) storage = storageKey ? getGlobalStorage(storageKey) : new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
10
13
|
const run = (context, cb)=>{
|
|
11
14
|
if (!storage) throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
12
15
|
`);
|
|
@@ -24,12 +27,13 @@ const createStorage = (storageKey)=>{
|
|
|
24
27
|
if (!storage) throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
25
28
|
`);
|
|
26
29
|
const context = storage.getStore();
|
|
27
|
-
if (!context) throw new Error("Can't call
|
|
30
|
+
if (!context) throw new Error("Can't call useContext out of server scope");
|
|
28
31
|
return context;
|
|
29
32
|
};
|
|
30
33
|
return {
|
|
31
34
|
run,
|
|
32
|
-
useContext
|
|
35
|
+
useContext,
|
|
36
|
+
useHonoContext: useContext
|
|
33
37
|
};
|
|
34
38
|
};
|
|
35
39
|
export { createStorage };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import
|
|
2
|
+
import path_0 from "path";
|
|
3
3
|
import { sortRoutes } from "../../../utils/index.mjs";
|
|
4
4
|
import { getPublicDirPatterns } from "../../../utils/publicDir.mjs";
|
|
5
5
|
import { createModuleFederationStaticServing, servePreCompressedPublicRouteAsset, servePublicDirectoryAsset } from "./staticServing.mjs";
|
|
@@ -88,7 +88,7 @@ function createStaticMiddleware(options) {
|
|
|
88
88
|
return async (c, next)=>{
|
|
89
89
|
const pageRoute = c.get('route');
|
|
90
90
|
const pathname = c.req.path;
|
|
91
|
-
if (pageRoute && '' ===
|
|
91
|
+
if (pageRoute && '' === path_0.extname(pathname)) return next();
|
|
92
92
|
const hit = staticPathRegExp.test(pathname);
|
|
93
93
|
const staticServingRequest = await moduleFederationStaticServing.resolveRequest(pathname);
|
|
94
94
|
if (null === staticServingRequest) return next();
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import * as __rspack_external_async_hooks from "async_hooks";
|
|
3
|
+
const getGlobalStorage = (storageKey)=>{
|
|
4
|
+
const globalStore = globalThis;
|
|
5
|
+
const key = 'string' == typeof storageKey ? Symbol.for(storageKey) : storageKey;
|
|
6
|
+
const sharedStorage = globalStore[key];
|
|
7
|
+
const storage = sharedStorage ?? new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
8
|
+
globalStore[key] = storage;
|
|
9
|
+
return storage;
|
|
10
|
+
};
|
|
3
11
|
const createStorage = (storageKey)=>{
|
|
4
12
|
let storage;
|
|
5
|
-
if (void 0 !== __rspack_external_async_hooks.AsyncLocalStorage)
|
|
6
|
-
const globalStore = globalThis;
|
|
7
|
-
const sharedStorage = globalStore[storageKey];
|
|
8
|
-
storage = sharedStorage ?? new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
9
|
-
globalStore[storageKey] = storage;
|
|
10
|
-
} else storage = new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
13
|
+
if (void 0 !== __rspack_external_async_hooks.AsyncLocalStorage) storage = storageKey ? getGlobalStorage(storageKey) : new __rspack_external_async_hooks.AsyncLocalStorage();
|
|
11
14
|
const run = (context, cb)=>{
|
|
12
15
|
if (!storage) throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
13
16
|
`);
|
|
@@ -25,12 +28,13 @@ const createStorage = (storageKey)=>{
|
|
|
25
28
|
if (!storage) throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
26
29
|
`);
|
|
27
30
|
const context = storage.getStore();
|
|
28
|
-
if (!context) throw new Error("Can't call
|
|
31
|
+
if (!context) throw new Error("Can't call useContext out of server scope");
|
|
29
32
|
return context;
|
|
30
33
|
};
|
|
31
34
|
return {
|
|
32
35
|
run,
|
|
33
|
-
useContext
|
|
36
|
+
useContext,
|
|
37
|
+
useHonoContext: useContext
|
|
34
38
|
};
|
|
35
39
|
};
|
|
36
40
|
export { createStorage };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ServerRoute } from '@modern-js/types';
|
|
2
|
+
import type { Router } from 'hono/router';
|
|
2
3
|
import type { CacheConfig, OnFallback, Render, UserConfig } from '../../types';
|
|
4
|
+
import type { Params } from '../../types/requestHandler';
|
|
3
5
|
interface CreateRenderOptions {
|
|
4
6
|
pwd: string;
|
|
5
7
|
routes: ServerRoute[];
|
|
@@ -12,5 +14,7 @@ interface CreateRenderOptions {
|
|
|
12
14
|
forceCSRMap?: Map<string, boolean>;
|
|
13
15
|
nonce?: string;
|
|
14
16
|
}
|
|
17
|
+
type MatchedRoute = [ServerRoute | undefined, Params];
|
|
18
|
+
export declare function matchRoute(router: Router<ServerRoute>, pathname: string, entryName?: string): MatchedRoute;
|
|
15
19
|
export declare function createRender({ routes, pwd, metaName, staticGenerate, cacheConfig, forceCSR, forceCSRMap, config, onFallback, }: CreateRenderOptions): Promise<Render>;
|
|
16
20
|
export {};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export interface DevUserConfig {
|
|
2
2
|
assetPrefix?: string;
|
|
3
|
+
/**
|
|
4
|
+
* Customize the directory containing the Mock API entry file.
|
|
5
|
+
* Relative paths are resolved from the application directory.
|
|
6
|
+
* @default './config/mock'
|
|
7
|
+
*/
|
|
8
|
+
mockDir?: string;
|
|
3
9
|
}
|
|
4
10
|
export type DevNormalizedConfig = DevUserConfig;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
declare const createStorage: <T>(storageKey?: symbol) => {
|
|
1
|
+
declare const createStorage: <T>(storageKey?: string | symbol) => {
|
|
2
2
|
run: <O>(context: T, cb: () => O | Promise<O>) => Promise<O>;
|
|
3
3
|
useContext: () => T;
|
|
4
|
+
useHonoContext: () => T;
|
|
4
5
|
};
|
|
5
6
|
export { createStorage };
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.5.0-ultramodern.
|
|
20
|
+
"version": "3.5.0-ultramodern.99",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"node": ">=20"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.
|
|
70
|
-
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.
|
|
71
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.
|
|
69
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.99",
|
|
70
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.99",
|
|
71
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.99",
|
|
72
72
|
"@swc/helpers": "^0.5.23",
|
|
73
73
|
"@web-std/fetch": "^4.2.1",
|
|
74
74
|
"@web-std/file": "^3.0.3",
|
|
@@ -79,14 +79,15 @@
|
|
|
79
79
|
"ts-deepmerge": "8.0.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.
|
|
82
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.99",
|
|
83
83
|
"@rslib/core": "0.23.2",
|
|
84
84
|
"@scripts/rstest-config": "2.66.0",
|
|
85
85
|
"@types/cloneable-readable": "^2.0.3",
|
|
86
86
|
"@types/merge-deep": "^3.0.3",
|
|
87
87
|
"@types/node": "^26.1.1",
|
|
88
88
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
89
|
-
"http-proxy-middleware": "^4.2.0"
|
|
89
|
+
"http-proxy-middleware": "^4.2.0",
|
|
90
|
+
"typescript": "^7.0.2"
|
|
90
91
|
},
|
|
91
92
|
"sideEffects": false,
|
|
92
93
|
"publishConfig": {
|