@bleedingdev/modern-js-runtime 3.9.0-ultramodern.17 → 3.9.0-ultramodern.18
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/cli/ssr/loadable-bundler-plugin.js +2 -0
- package/dist/cjs/core/browser/hydrate.js +1 -7
- package/dist/cjs/core/browser/index.js +4 -5
- package/dist/cjs/core/context/index.js +8 -2
- package/dist/cjs/core/context/public.js +4 -4
- package/dist/cjs/core/context/runtime.js +3 -9
- package/dist/cjs/core/index.js +3 -3
- package/dist/cjs/core/plugin/index.js +2 -2
- package/dist/cjs/core/react/index.js +3 -3
- package/dist/cjs/core/react/wrapper.js +7 -8
- package/dist/cjs/core/server/requestHandler.js +6 -7
- package/dist/cjs/core/server/stream/createReadableStream.js +20 -9
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +21 -10
- package/dist/cjs/core/server/string/index.js +6 -4
- package/dist/cjs/exports/head.js +2 -2
- package/dist/cjs/internal.js +2 -2
- package/dist/cjs/router/runtime/PrefetchLink.js +4 -4
- package/dist/cjs/router/runtime/plugin.js +9 -9
- package/dist/cjs/router/runtime/plugin.node.js +6 -6
- package/dist/esm/cli/ssr/loadable-bundler-plugin.mjs +2 -0
- package/dist/esm/core/browser/hydrate.mjs +1 -7
- package/dist/esm/core/browser/index.mjs +1 -2
- package/dist/esm/core/context/index.mjs +1 -1
- package/dist/esm/core/context/public.mjs +1 -1
- package/dist/esm/core/context/runtime.mjs +3 -9
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/core/plugin/index.mjs +1 -1
- package/dist/esm/core/react/index.mjs +1 -1
- package/dist/esm/core/react/wrapper.mjs +1 -2
- package/dist/esm/core/server/requestHandler.mjs +1 -2
- package/dist/esm/core/server/stream/createReadableStream.mjs +16 -5
- package/dist/esm/core/server/stream/createReadableStream.worker.mjs +19 -8
- package/dist/esm/core/server/string/index.mjs +3 -1
- package/dist/esm/exports/head.mjs +1 -1
- package/dist/esm/internal.mjs +1 -1
- package/dist/esm/router/runtime/PrefetchLink.mjs +1 -1
- package/dist/esm/router/runtime/plugin.mjs +1 -1
- package/dist/esm/router/runtime/plugin.node.mjs +1 -1
- package/dist/esm-node/cli/ssr/loadable-bundler-plugin.mjs +2 -0
- package/dist/esm-node/core/browser/hydrate.mjs +1 -7
- package/dist/esm-node/core/browser/index.mjs +1 -2
- package/dist/esm-node/core/context/index.mjs +1 -1
- package/dist/esm-node/core/context/public.mjs +1 -1
- package/dist/esm-node/core/context/runtime.mjs +3 -9
- package/dist/esm-node/core/index.mjs +1 -1
- package/dist/esm-node/core/plugin/index.mjs +1 -1
- package/dist/esm-node/core/react/index.mjs +1 -1
- package/dist/esm-node/core/react/wrapper.mjs +1 -2
- package/dist/esm-node/core/server/requestHandler.mjs +1 -2
- package/dist/esm-node/core/server/stream/createReadableStream.mjs +16 -5
- package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +19 -8
- package/dist/esm-node/core/server/string/index.mjs +3 -1
- package/dist/esm-node/exports/head.mjs +1 -1
- package/dist/esm-node/internal.mjs +1 -1
- package/dist/esm-node/router/runtime/PrefetchLink.mjs +1 -1
- package/dist/esm-node/router/runtime/plugin.mjs +1 -1
- package/dist/esm-node/router/runtime/plugin.node.mjs +1 -1
- package/dist/types/core/context/index.d.ts +1 -1
- package/dist/types/core/context/public.d.ts +1 -1
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/react/wrapper.d.ts +1 -1
- package/dist/types/core/server/requestHandler.d.ts +1 -1
- package/dist/types/core/server/stream/shared.d.ts +6 -1
- package/dist/types/internal.d.ts +1 -1
- package/package.json +10 -10
- package/rslib.config.mts +3 -0
- package/rstest.config.mts +0 -4
- package/dist/cjs/rsc/server.worker.js +0 -62
- package/dist/esm/rsc/server.worker.mjs +0 -1
- package/dist/esm-node/rsc/server.worker.mjs +0 -2
- package/dist/types/rsc/server.worker.d.ts +0 -1
|
@@ -44,6 +44,7 @@ const external_path_namespaceObject = require("path");
|
|
|
44
44
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
45
45
|
const normalizeChunkId = (id)=>'string' == typeof id && /^\d+$/.test(id) ? Number(id) : id;
|
|
46
46
|
const DEFAULT_CHUNK_LOADING_GLOBAL = '__LOADABLE_LOADED_CHUNKS__';
|
|
47
|
+
const normalizeStatsPublicPath = (publicPath)=>'auto' === publicPath || 'auto/' === publicPath ? '/' : publicPath;
|
|
47
48
|
const normalizeChunkGroup = (group)=>({
|
|
48
49
|
...group,
|
|
49
50
|
chunks: (group.chunks || []).map(normalizeChunkId)
|
|
@@ -86,6 +87,7 @@ class LoadablePlugin {
|
|
|
86
87
|
for (const [name, ep] of Object.entries(stats.entrypoints || {}))entrypoints[name] = normalizeChunkGroup(ep);
|
|
87
88
|
const output = {
|
|
88
89
|
...stats,
|
|
90
|
+
publicPath: normalizeStatsPublicPath(stats.publicPath),
|
|
89
91
|
namedChunkGroups,
|
|
90
92
|
entrypoints,
|
|
91
93
|
generator: 'loadable-components',
|
|
@@ -86,13 +86,7 @@ function hydrateRoot(App, context, ModernRender, ModernHydrate) {
|
|
|
86
86
|
});
|
|
87
87
|
return ModernHydrate((0, wrapper_js_namespaceObject.wrapRuntimeContextProvider)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SSRApp, {}), hydrateContext));
|
|
88
88
|
});
|
|
89
|
-
|
|
90
|
-
if (null !== runtimeConsole && 'object' == typeof runtimeConsole) {
|
|
91
|
-
const warn = Reflect.get(runtimeConsole, 'warn');
|
|
92
|
-
if ('function' == typeof warn) Reflect.apply(warn, runtimeConsole, [
|
|
93
|
-
`unknow render level: ${renderLevel}, execute render()`
|
|
94
|
-
]);
|
|
95
|
-
}
|
|
89
|
+
console.warn(`unknow render level: ${renderLevel}, execute render()`);
|
|
96
90
|
return ModernRender((0, wrapper_js_namespaceObject.wrapRuntimeContextProvider)(App, context));
|
|
97
91
|
}
|
|
98
92
|
}
|
|
@@ -35,10 +35,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
35
35
|
renderWithReact17: ()=>renderWithReact17,
|
|
36
36
|
renderWithReact18: ()=>renderWithReact18
|
|
37
37
|
});
|
|
38
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
38
39
|
const external_cookie_namespaceObject = require("cookie");
|
|
39
40
|
const client_namespaceObject = require("react-dom/client");
|
|
40
|
-
const index_js_namespaceObject = require("../context/index.js");
|
|
41
|
-
const runtime_js_namespaceObject = require("../context/runtime.js");
|
|
42
41
|
const wrapper_js_namespaceObject = require("../react/wrapper.js");
|
|
43
42
|
const external_hydrate_js_namespaceObject = require("./hydrate.js");
|
|
44
43
|
const IS_REACT18 = 'true' === process.env.IS_REACT18;
|
|
@@ -85,7 +84,7 @@ function isClientArgs(id) {
|
|
|
85
84
|
return void 0 === id || 'string' == typeof id || "u" > typeof HTMLElement && id instanceof HTMLElement;
|
|
86
85
|
}
|
|
87
86
|
async function renderApp(App, id, hydrateFromSsrData, internalRuntimeContext) {
|
|
88
|
-
const context = (0,
|
|
87
|
+
const context = (0, context_namespaceObject.getInitialContext)();
|
|
89
88
|
const runBeforeRender = async (context)=>{
|
|
90
89
|
const api = internalRuntimeContext.pluginAPI;
|
|
91
90
|
api.updateRuntimeContext(context);
|
|
@@ -115,10 +114,10 @@ async function renderApp(App, id, hydrateFromSsrData, internalRuntimeContext) {
|
|
|
115
114
|
throw Error('`render` function needs id in browser environment, it needs to be string or element');
|
|
116
115
|
}
|
|
117
116
|
async function render(App, id) {
|
|
118
|
-
return renderApp(App, id, true, (0,
|
|
117
|
+
return renderApp(App, id, true, (0, context_namespaceObject.getGlobalInternalRuntimeContext)());
|
|
119
118
|
}
|
|
120
119
|
function createNestedAppRenderer() {
|
|
121
|
-
const internalRuntimeContext = (0,
|
|
120
|
+
const internalRuntimeContext = (0, context_namespaceObject.getGlobalInternalRuntimeContext)();
|
|
122
121
|
return (App, id)=>renderApp(App, id, false, internalRuntimeContext);
|
|
123
122
|
}
|
|
124
123
|
async function renderWithReact18(App, rootElement) {
|
|
@@ -30,6 +30,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
DefaultNotFound: ()=>DefaultNotFound_js_namespaceObject.DefaultNotFound,
|
|
32
32
|
InternalRuntimeContext: ()=>external_runtime_js_namespaceObject.InternalRuntimeContext,
|
|
33
|
+
ReactRuntimeContext: ()=>external_runtime_js_namespaceObject.ReactRuntimeContext,
|
|
33
34
|
RuntimeComponentResolverContext: ()=>external_runtime_js_namespaceObject.RuntimeComponentResolverContext,
|
|
34
35
|
RuntimeContext: ()=>external_runtime_js_namespaceObject.RuntimeContext,
|
|
35
36
|
getCurrentEntryName: ()=>getCurrentEntryName,
|
|
@@ -52,7 +53,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
52
53
|
routerProviderRegistryHooks: ()=>hooks_js_namespaceObject.routerProviderRegistryHooks,
|
|
53
54
|
setGlobalContext: ()=>setGlobalContext,
|
|
54
55
|
setGlobalInternalRuntimeContext: ()=>setGlobalInternalRuntimeContext,
|
|
55
|
-
setServerPayload: ()=>index_js_namespaceObject.setServerPayload
|
|
56
|
+
setServerPayload: ()=>index_js_namespaceObject.setServerPayload,
|
|
57
|
+
useRuntimeContext: ()=>external_runtime_js_namespaceObject.useRuntimeContext
|
|
56
58
|
});
|
|
57
59
|
const DefaultNotFound_js_namespaceObject = require("../../router/runtime/DefaultNotFound.js");
|
|
58
60
|
const hooks_js_namespaceObject = require("../../router/runtime/hooks.js");
|
|
@@ -102,6 +104,7 @@ function getGlobalBasename() {
|
|
|
102
104
|
}
|
|
103
105
|
exports.DefaultNotFound = __webpack_exports__.DefaultNotFound;
|
|
104
106
|
exports.InternalRuntimeContext = __webpack_exports__.InternalRuntimeContext;
|
|
107
|
+
exports.ReactRuntimeContext = __webpack_exports__.ReactRuntimeContext;
|
|
105
108
|
exports.RuntimeComponentResolverContext = __webpack_exports__.RuntimeComponentResolverContext;
|
|
106
109
|
exports.RuntimeContext = __webpack_exports__.RuntimeContext;
|
|
107
110
|
exports.getCurrentEntryName = __webpack_exports__.getCurrentEntryName;
|
|
@@ -125,9 +128,11 @@ exports.routerProviderRegistryHooks = __webpack_exports__.routerProviderRegistry
|
|
|
125
128
|
exports.setGlobalContext = __webpack_exports__.setGlobalContext;
|
|
126
129
|
exports.setGlobalInternalRuntimeContext = __webpack_exports__.setGlobalInternalRuntimeContext;
|
|
127
130
|
exports.setServerPayload = __webpack_exports__.setServerPayload;
|
|
131
|
+
exports.useRuntimeContext = __webpack_exports__.useRuntimeContext;
|
|
128
132
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
129
133
|
"DefaultNotFound",
|
|
130
134
|
"InternalRuntimeContext",
|
|
135
|
+
"ReactRuntimeContext",
|
|
131
136
|
"RuntimeComponentResolverContext",
|
|
132
137
|
"RuntimeContext",
|
|
133
138
|
"getCurrentEntryName",
|
|
@@ -150,7 +155,8 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
150
155
|
"routerProviderRegistryHooks",
|
|
151
156
|
"setGlobalContext",
|
|
152
157
|
"setGlobalInternalRuntimeContext",
|
|
153
|
-
"setServerPayload"
|
|
158
|
+
"setServerPayload",
|
|
159
|
+
"useRuntimeContext"
|
|
154
160
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
155
161
|
Object.defineProperty(exports, '__esModule', {
|
|
156
162
|
value: true
|
|
@@ -28,11 +28,11 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
ReactRuntimeContext: ()=>
|
|
32
|
-
RuntimeContext: ()=>
|
|
33
|
-
useRuntimeContext: ()=>
|
|
31
|
+
ReactRuntimeContext: ()=>context_namespaceObject.ReactRuntimeContext,
|
|
32
|
+
RuntimeContext: ()=>context_namespaceObject.RuntimeContext,
|
|
33
|
+
useRuntimeContext: ()=>context_namespaceObject.useRuntimeContext
|
|
34
34
|
});
|
|
35
|
-
const
|
|
35
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
36
36
|
exports.ReactRuntimeContext = __webpack_exports__.ReactRuntimeContext;
|
|
37
37
|
exports.RuntimeContext = __webpack_exports__.RuntimeContext;
|
|
38
38
|
exports.useRuntimeContext = __webpack_exports__.useRuntimeContext;
|
|
@@ -37,15 +37,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
37
37
|
});
|
|
38
38
|
const external_react_namespaceObject = require("react");
|
|
39
39
|
const ROUTE_MANIFEST = '_MODERNJS_ROUTE_MANIFEST';
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
contexts[key] ??= create();
|
|
44
|
-
return contexts[key];
|
|
45
|
-
}
|
|
46
|
-
const InternalRuntimeContext = getRuntimeReactContext('internal', ()=>(0, external_react_namespaceObject.createContext)({}));
|
|
47
|
-
const RuntimeContext = getRuntimeReactContext('public', ()=>(0, external_react_namespaceObject.createContext)({}));
|
|
48
|
-
const RuntimeComponentResolverContext = getRuntimeReactContext('component-resolver', ()=>(0, external_react_namespaceObject.createContext)(void 0));
|
|
40
|
+
const InternalRuntimeContext = (0, external_react_namespaceObject.createContext)({});
|
|
41
|
+
const RuntimeContext = (0, external_react_namespaceObject.createContext)({});
|
|
42
|
+
const RuntimeComponentResolverContext = (0, external_react_namespaceObject.createContext)(void 0);
|
|
49
43
|
const ReactRuntimeContext = RuntimeContext;
|
|
50
44
|
const useRuntimeContext = ()=>(0, external_react_namespaceObject.useContext)(RuntimeContext);
|
|
51
45
|
const getInitialContext = (isBrowser = true, routeManifest)=>{
|
package/dist/cjs/core/index.js
CHANGED
|
@@ -28,12 +28,12 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
RuntimeContext: ()=>
|
|
31
|
+
RuntimeContext: ()=>context_namespaceObject.RuntimeContext,
|
|
32
32
|
defineRuntimeConfig: ()=>external_config_js_namespaceObject.defineRuntimeConfig,
|
|
33
|
-
useRuntimeContext: ()=>
|
|
33
|
+
useRuntimeContext: ()=>context_namespaceObject.useRuntimeContext
|
|
34
34
|
});
|
|
35
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
35
36
|
const external_config_js_namespaceObject = require("./config.js");
|
|
36
|
-
const runtime_js_namespaceObject = require("./context/runtime.js");
|
|
37
37
|
exports.RuntimeContext = __webpack_exports__.RuntimeContext;
|
|
38
38
|
exports.defineRuntimeConfig = __webpack_exports__.defineRuntimeConfig;
|
|
39
39
|
exports.useRuntimeContext = __webpack_exports__.useRuntimeContext;
|
|
@@ -32,11 +32,11 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
registerPlugin: ()=>registerPlugin
|
|
33
33
|
});
|
|
34
34
|
const runtime_namespaceObject = require("@modern-js/plugin/runtime");
|
|
35
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
35
36
|
const merge_namespaceObject = require("@modern-js/runtime-utils/merge");
|
|
36
37
|
const index_js_namespaceObject = require("../compat/index.js");
|
|
37
38
|
const hooks_js_namespaceObject = require("../compat/hooks.js");
|
|
38
39
|
const requestContext_js_namespaceObject = require("../compat/requestContext.js");
|
|
39
|
-
const external_context_index_js_namespaceObject = require("../context/index.js");
|
|
40
40
|
function registerPlugin(internalPlugins, runtimeConfig) {
|
|
41
41
|
const { plugins = [] } = runtimeConfig || {};
|
|
42
42
|
const { runtimeContext } = runtime_namespaceObject.runtime.run({
|
|
@@ -50,7 +50,7 @@ function registerPlugin(internalPlugins, runtimeConfig) {
|
|
|
50
50
|
handleSetupResult: hooks_js_namespaceObject.handleSetupResult
|
|
51
51
|
});
|
|
52
52
|
const internalRuntimeContext = runtimeContext;
|
|
53
|
-
(0,
|
|
53
|
+
(0, context_namespaceObject.setGlobalInternalRuntimeContext)(internalRuntimeContext);
|
|
54
54
|
return internalRuntimeContext;
|
|
55
55
|
}
|
|
56
56
|
function mergeConfig(config, ...otherConfig) {
|
|
@@ -30,17 +30,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
createRoot: ()=>createRoot
|
|
32
32
|
});
|
|
33
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
33
34
|
const parsed_namespaceObject = require("@modern-js/runtime-utils/parsed");
|
|
34
35
|
const external_common_js_namespaceObject = require("../../common.js");
|
|
35
36
|
const external_constants_js_namespaceObject = require("../constants.js");
|
|
36
|
-
const index_js_namespaceObject = require("../context/index.js");
|
|
37
37
|
function createRoot(UserApp) {
|
|
38
|
-
const App = UserApp || (0,
|
|
38
|
+
const App = UserApp || (0, context_namespaceObject.getGlobalApp)();
|
|
39
39
|
if ((0, external_common_js_namespaceObject.isBrowser)()) {
|
|
40
40
|
window._SSR_DATA = window._SSR_DATA || (0, parsed_namespaceObject.parsedJSONFromElement)(external_constants_js_namespaceObject.SSR_DATA_JSON_ID);
|
|
41
41
|
window._ROUTER_DATA = window._ROUTER_DATA || (0, parsed_namespaceObject.parsedJSONFromElement)(external_constants_js_namespaceObject.ROUTER_DATA_JSON_ID);
|
|
42
42
|
}
|
|
43
|
-
const internalRuntimeContext = (0,
|
|
43
|
+
const internalRuntimeContext = (0, context_namespaceObject.getGlobalInternalRuntimeContext)();
|
|
44
44
|
const hooks = internalRuntimeContext.hooks;
|
|
45
45
|
const WrapperApp = hooks.wrapRoot.call(App);
|
|
46
46
|
return WrapperApp;
|
|
@@ -32,10 +32,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
wrapRuntimeContextProvider: ()=>wrapRuntimeContextProvider
|
|
33
33
|
});
|
|
34
34
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(runtime_js_namespaceObject.RuntimeComponentResolverContext.Provider, {
|
|
35
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
36
|
+
function wrapRuntimeComponentResolver(root, hooks = (0, context_namespaceObject.getGlobalInternalRuntimeContext)()?.hooks) {
|
|
37
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(context_namespaceObject.RuntimeComponentResolverContext.Provider, {
|
|
39
38
|
value: hooks?.resolveComponent?.call,
|
|
40
39
|
children: root
|
|
41
40
|
});
|
|
@@ -49,18 +48,18 @@ function wrapRuntimeContextProvider(App, contextValue) {
|
|
|
49
48
|
context,
|
|
50
49
|
...rest
|
|
51
50
|
};
|
|
52
|
-
const isRsc = true === (0,
|
|
51
|
+
const isRsc = true === (0, context_namespaceObject.getGlobalEnableRsc)();
|
|
53
52
|
const projection = {
|
|
54
53
|
internalContext: contextValue,
|
|
55
54
|
publicContext: runtimeContextValue
|
|
56
55
|
};
|
|
57
|
-
const values = (0,
|
|
56
|
+
const values = (0, context_namespaceObject.getGlobalInternalRuntimeContext)()?.hooks.transformRuntimeContext?.call(projection, {
|
|
58
57
|
context: contextValue,
|
|
59
58
|
isRsc
|
|
60
59
|
}) ?? projection;
|
|
61
|
-
const root = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
60
|
+
const root = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(context_namespaceObject.InternalRuntimeContext.Provider, {
|
|
62
61
|
value: values.internalContext,
|
|
63
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
62
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(context_namespaceObject.RuntimeContext.Provider, {
|
|
64
63
|
value: values.publicContext,
|
|
65
64
|
children: App
|
|
66
65
|
})
|
|
@@ -40,26 +40,25 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
40
40
|
createRequestHandler: ()=>createRequestHandler
|
|
41
41
|
});
|
|
42
42
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
43
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
43
44
|
const node_namespaceObject = require("@modern-js/runtime-utils/node");
|
|
44
45
|
const request_namespaceObject = require("@modern-js/runtime-utils/universal/request");
|
|
45
46
|
const external_react_namespaceObject = require("react");
|
|
46
47
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
47
|
-
const index_js_namespaceObject = require("../context/index.js");
|
|
48
|
-
const runtime_js_namespaceObject = require("../context/runtime.js");
|
|
49
|
-
const serverPayload_index_js_namespaceObject = require("../context/serverPayload/index.js");
|
|
48
|
+
const index_js_namespaceObject = require("../context/serverPayload/index.js");
|
|
50
49
|
const external_react_index_js_namespaceObject = require("../react/index.js");
|
|
51
50
|
const external_constants_js_namespaceObject = require("./constants.js");
|
|
52
51
|
const external_requestResponse_js_namespaceObject = require("./requestResponse.js");
|
|
53
52
|
const external_routerCleanup_js_namespaceObject = require("./routerCleanup.js");
|
|
54
53
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
55
54
|
async function handleRSCRequest(request, Root, context, options, handleRequest) {
|
|
56
|
-
const serverPayload = (0,
|
|
55
|
+
const serverPayload = (0, index_js_namespaceObject.getServerPayload)();
|
|
57
56
|
if (void 0 !== serverPayload) return await handleRequest(request, Root, {
|
|
58
57
|
...options,
|
|
59
58
|
runtimeContext: context,
|
|
60
59
|
rscRoot: serverPayload
|
|
61
60
|
});
|
|
62
|
-
const App = (0,
|
|
61
|
+
const App = (0, context_namespaceObject.getGlobalRSCRoot)();
|
|
63
62
|
if (App) return await handleRequest(request, external_react_namespaceObject.Fragment, {
|
|
64
63
|
...options,
|
|
65
64
|
runtimeContext: context,
|
|
@@ -151,10 +150,10 @@ const createRequestHandler = async (handleRequest, createRequestOptions)=>{
|
|
|
151
150
|
serverPayload: void 0
|
|
152
151
|
}, async ()=>{
|
|
153
152
|
const Root = (0, external_react_index_js_namespaceObject.createRoot)();
|
|
154
|
-
const internalRuntimeContext = (0,
|
|
153
|
+
const internalRuntimeContext = (0, context_namespaceObject.getGlobalInternalRuntimeContext)();
|
|
155
154
|
const hooks = internalRuntimeContext.hooks;
|
|
156
155
|
const { routeManifest } = options.resource;
|
|
157
|
-
const context = (0,
|
|
156
|
+
const context = (0, context_namespaceObject.getInitialContext)(false, routeManifest);
|
|
158
157
|
const runBeforeRender = async (context)=>{
|
|
159
158
|
const result = await hooks.onBeforeRender.call(context);
|
|
160
159
|
if ("u" > typeof Response && result instanceof Response) return result;
|
|
@@ -30,13 +30,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
createReadableStreamFromElement: ()=>createReadableStreamFromElement
|
|
32
32
|
});
|
|
33
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
33
34
|
const node_namespaceObject = require("@modern-js/runtime-utils/node");
|
|
34
35
|
const constants_namespaceObject = require("@modern-js/utils/universal/constants");
|
|
35
36
|
const external_stream_namespaceObject = require("stream");
|
|
36
37
|
const external_common_js_namespaceObject = require("../../../common.js");
|
|
37
38
|
const external_constants_js_namespaceObject = require("../../constants.js");
|
|
38
|
-
const index_js_namespaceObject = require("../../context/index.js");
|
|
39
|
-
const monitors_index_js_namespaceObject = require("../../context/monitors/index.js");
|
|
39
|
+
const index_js_namespaceObject = require("../../context/monitors/index.js");
|
|
40
40
|
const wrapper_js_namespaceObject = require("../../react/wrapper.js");
|
|
41
41
|
const external_helmet_js_namespaceObject = require("../helmet.js");
|
|
42
42
|
const external_shared_js_namespaceObject = require("../shared.js");
|
|
@@ -46,8 +46,8 @@ const external_template_js_namespaceObject = require("./template.js");
|
|
|
46
46
|
const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
47
47
|
const { renderToPipeableStream } = await import("react-dom/server");
|
|
48
48
|
const { runtimeContext, htmlTemplate, config, ssrConfig, entryName, resource } = options;
|
|
49
|
-
const hooks = (0,
|
|
50
|
-
const isRsc = true === (0,
|
|
49
|
+
const hooks = (0, context_namespaceObject.getGlobalInternalRuntimeContext)().hooks;
|
|
50
|
+
const isRsc = true === (0, context_namespaceObject.getGlobalEnableRsc)();
|
|
51
51
|
const extenders = hooks.extendStreamSSR.call({
|
|
52
52
|
runtimeContext,
|
|
53
53
|
request,
|
|
@@ -55,6 +55,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
55
55
|
config,
|
|
56
56
|
platform: 'node',
|
|
57
57
|
mode: 'stream',
|
|
58
|
+
monitors: (0, index_js_namespaceObject.getMonitors)(),
|
|
58
59
|
isRsc,
|
|
59
60
|
terminalMarker: external_common_js_namespaceObject.ESCAPED_SHELL_STREAM_END_MARK
|
|
60
61
|
}) || [];
|
|
@@ -153,7 +154,9 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
153
154
|
});
|
|
154
155
|
if (failed) return;
|
|
155
156
|
const chunks = [];
|
|
157
|
+
let bufferedLength = 0;
|
|
156
158
|
const marker = Buffer.from(external_common_js_namespaceObject.ESCAPED_SHELL_STREAM_END_MARK);
|
|
159
|
+
let markerTail = Buffer.alloc(0);
|
|
157
160
|
const pendingScripts = [];
|
|
158
161
|
let shellChunkStatus = external_shared_js_namespaceObject_1.ShellChunkStatus.START;
|
|
159
162
|
const emitShell = (destination, buffered, markerIndex)=>{
|
|
@@ -161,6 +164,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
161
164
|
const completedShellBefore = (0, external_helmet_js_namespaceObject.createReplaceHelemt)((0, external_helmet_js_namespaceObject.getHelmetData)(extenders))(shellBefore);
|
|
162
165
|
shellChunkStatus = external_shared_js_namespaceObject_1.ShellChunkStatus.FINISH;
|
|
163
166
|
chunks.length = 0;
|
|
167
|
+
bufferedLength = 0;
|
|
164
168
|
destination.push(`${completedShellBefore}${beforeMark}${shellAfter}`);
|
|
165
169
|
const afterMark = buffered.subarray(markerIndex + marker.length);
|
|
166
170
|
if (afterMark.length > 0) destination.push(afterMark);
|
|
@@ -172,10 +176,17 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
172
176
|
try {
|
|
173
177
|
if (shellChunkStatus === external_shared_js_namespaceObject_1.ShellChunkStatus.FINISH) this.push(chunk);
|
|
174
178
|
else {
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
180
|
+
const window = Buffer.concat([
|
|
181
|
+
markerTail,
|
|
182
|
+
bytes
|
|
183
|
+
]);
|
|
184
|
+
const windowIndex = window.indexOf(marker);
|
|
185
|
+
const windowStart = bufferedLength - markerTail.length;
|
|
186
|
+
chunks.push(bytes);
|
|
187
|
+
bufferedLength += bytes.length;
|
|
188
|
+
if (-1 === windowIndex) markerTail = window.subarray(Math.max(0, window.length - marker.length + 1));
|
|
189
|
+
else emitShell(this, Buffer.concat(chunks, bufferedLength), windowStart + windowIndex);
|
|
179
190
|
}
|
|
180
191
|
callback();
|
|
181
192
|
} catch (error) {
|
|
@@ -212,7 +223,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
212
223
|
else pendingScripts.push(script);
|
|
213
224
|
});
|
|
214
225
|
} catch (error) {
|
|
215
|
-
(0,
|
|
226
|
+
(0, index_js_namespaceObject.getMonitors)().error("cannot inject router data script", error);
|
|
216
227
|
}
|
|
217
228
|
};
|
|
218
229
|
const renderFallback = async (error)=>{
|
|
@@ -40,12 +40,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
40
40
|
createReadableStreamFromElement: ()=>createReadableStreamFromElement
|
|
41
41
|
});
|
|
42
42
|
const ssr_namespaceObject = require("@modern-js/render/ssr");
|
|
43
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
43
44
|
const node_namespaceObject = require("@modern-js/runtime-utils/node");
|
|
44
45
|
const external_react_namespaceObject = require("react");
|
|
45
46
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
46
47
|
const external_common_js_namespaceObject = require("../../../common.js");
|
|
47
48
|
const external_constants_js_namespaceObject = require("../../constants.js");
|
|
48
|
-
const index_js_namespaceObject = require("../../context/index.js");
|
|
49
|
+
const index_js_namespaceObject = require("../../context/monitors/index.js");
|
|
49
50
|
const wrapper_js_namespaceObject = require("../../react/wrapper.js");
|
|
50
51
|
const external_helmet_js_namespaceObject = require("../helmet.js");
|
|
51
52
|
const external_shared_js_namespaceObject = require("../shared.js");
|
|
@@ -54,8 +55,8 @@ const external_shared_js_namespaceObject_1 = require("./shared.js");
|
|
|
54
55
|
const external_template_js_namespaceObject = require("./template.js");
|
|
55
56
|
const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
56
57
|
const { htmlTemplate, runtimeContext, config, ssrConfig, entryName, resource, rscManifest, rscRoot } = options;
|
|
57
|
-
const hooks = (0,
|
|
58
|
-
const isRsc = true === (0,
|
|
58
|
+
const hooks = (0, context_namespaceObject.getGlobalInternalRuntimeContext)().hooks;
|
|
59
|
+
const isRsc = true === (0, context_namespaceObject.getGlobalEnableRsc)();
|
|
59
60
|
const extenders = hooks.extendStreamSSR.call({
|
|
60
61
|
runtimeContext,
|
|
61
62
|
request,
|
|
@@ -63,6 +64,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
63
64
|
config,
|
|
64
65
|
platform: 'web',
|
|
65
66
|
mode: 'stream',
|
|
67
|
+
monitors: (0, index_js_namespaceObject.getMonitors)(),
|
|
66
68
|
isRsc,
|
|
67
69
|
terminalMarker: external_common_js_namespaceObject.ESCAPED_SHELL_STREAM_END_MARK
|
|
68
70
|
}) || [];
|
|
@@ -122,7 +124,9 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
122
124
|
const decoder = new TextDecoder();
|
|
123
125
|
const encoder = new TextEncoder();
|
|
124
126
|
const pendingScripts = [];
|
|
125
|
-
|
|
127
|
+
const buffered = [];
|
|
128
|
+
let bufferedLength = 0;
|
|
129
|
+
let markerTail = '';
|
|
126
130
|
let shellChunkStatus = external_shared_js_namespaceObject_1.ShellChunkStatus.START;
|
|
127
131
|
let bodyController;
|
|
128
132
|
const emit = (chunk, controller)=>{
|
|
@@ -130,14 +134,21 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
130
134
|
if (chunk.length > 0) controller.enqueue(encoder.encode(chunk));
|
|
131
135
|
return;
|
|
132
136
|
}
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
const window = markerTail + chunk;
|
|
138
|
+
const windowIndex = window.indexOf(external_common_js_namespaceObject.ESCAPED_SHELL_STREAM_END_MARK);
|
|
139
|
+
const markerIndex = bufferedLength - markerTail.length + windowIndex;
|
|
140
|
+
buffered.push(chunk);
|
|
141
|
+
bufferedLength += chunk.length;
|
|
142
|
+
if (-1 === windowIndex) {
|
|
143
|
+
markerTail = window.slice(Math.max(0, window.length - external_common_js_namespaceObject.ESCAPED_SHELL_STREAM_END_MARK.length + 1));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const shell = buffered.join('');
|
|
147
|
+
const beforeMark = lifecycle.completedBody(shell.slice(0, markerIndex), 'shell');
|
|
148
|
+
const afterMark = shell.slice(markerIndex + external_common_js_namespaceObject.ESCAPED_SHELL_STREAM_END_MARK.length);
|
|
138
149
|
const completedShellBefore = (0, external_helmet_js_namespaceObject.createReplaceHelemt)((0, external_helmet_js_namespaceObject.getHelmetData)(extenders))(shellBefore);
|
|
139
150
|
shellChunkStatus = external_shared_js_namespaceObject_1.ShellChunkStatus.FINISH;
|
|
140
|
-
buffered =
|
|
151
|
+
buffered.length = 0;
|
|
141
152
|
controller.enqueue(encoder.encode(`${completedShellBefore}${beforeMark}${shellAfter}`));
|
|
142
153
|
if (afterMark.length > 0) controller.enqueue(encoder.encode(afterMark));
|
|
143
154
|
for (const script of pendingScripts)controller.enqueue(encoder.encode(script));
|
|
@@ -39,12 +39,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
39
39
|
__webpack_require__.d(__webpack_exports__, {
|
|
40
40
|
renderString: ()=>renderString
|
|
41
41
|
});
|
|
42
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
42
43
|
const time_namespaceObject = require("@modern-js/runtime-utils/time");
|
|
43
44
|
const constants_namespaceObject = require("@modern-js/utils/universal/constants");
|
|
44
45
|
const server_namespaceObject = require("react-dom/server");
|
|
45
46
|
var server_default = /*#__PURE__*/ __webpack_require__.n(server_namespaceObject);
|
|
46
47
|
const external_constants_js_namespaceObject = require("../../constants.js");
|
|
47
|
-
const index_js_namespaceObject = require("../../context/index.js");
|
|
48
|
+
const index_js_namespaceObject = require("../../context/monitors/index.js");
|
|
48
49
|
const wrapper_js_namespaceObject = require("../../react/wrapper.js");
|
|
49
50
|
const external_constants_js_namespaceObject_1 = require("../constants.js");
|
|
50
51
|
const external_helmet_js_namespaceObject = require("../helmet.js");
|
|
@@ -91,7 +92,7 @@ const renderString = async (request, serverRoot, options)=>{
|
|
|
91
92
|
useJsonScript: config.useJsonScript,
|
|
92
93
|
lifecycle
|
|
93
94
|
}));
|
|
94
|
-
const internalRuntimeContext = (0,
|
|
95
|
+
const internalRuntimeContext = (0, context_namespaceObject.getGlobalInternalRuntimeContext)();
|
|
95
96
|
const hooks = internalRuntimeContext.hooks;
|
|
96
97
|
const extraCollectors = hooks.extendStringSSRCollectors.call({
|
|
97
98
|
chunkSet,
|
|
@@ -102,14 +103,15 @@ const renderString = async (request, serverRoot, options)=>{
|
|
|
102
103
|
config,
|
|
103
104
|
platform: 'node',
|
|
104
105
|
mode: 'string',
|
|
105
|
-
|
|
106
|
+
monitors: (0, index_js_namespaceObject.getMonitors)(),
|
|
107
|
+
isRsc: true === (0, context_namespaceObject.getGlobalEnableRsc)()
|
|
106
108
|
}
|
|
107
109
|
});
|
|
108
110
|
for (const c of extraCollectors)if (c) collectors.unshift(c);
|
|
109
111
|
let rootElement = (0, wrapper_js_namespaceObject.wrapRuntimeContextProvider)(serverRoot, Object.assign(runtimeContext, {
|
|
110
112
|
ssr: true
|
|
111
113
|
}));
|
|
112
|
-
if (true === (0,
|
|
114
|
+
if (true === (0, context_namespaceObject.getGlobalEnableRsc)() && false === runtimeContext.isBrowser) rootElement = (0, wrapper_js_namespaceObject.wrapRuntimeComponentResolver)(rootElement, hooks);
|
|
113
115
|
const html = await generateHtml(rootElement, htmlTemplate, chunkSet, collectors, runtimeContext.ssrContext?.htmlModifiers || [], tracer, request.signal, lifecycle, loadableCollector.stylesheetInfo);
|
|
114
116
|
return html;
|
|
115
117
|
};
|
package/dist/cjs/exports/head.js
CHANGED
|
@@ -41,12 +41,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
41
41
|
Helmet: ()=>Helmet,
|
|
42
42
|
default: ()=>exports_head
|
|
43
43
|
});
|
|
44
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
44
45
|
const external_react_namespaceObject = require("react");
|
|
45
46
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
46
47
|
const external_react_helmet_async_namespaceObject = require("react-helmet-async");
|
|
47
|
-
const runtime_js_namespaceObject = require("../core/context/runtime.js");
|
|
48
48
|
const Helmet = (props)=>{
|
|
49
|
-
const resolveComponent = external_react_default().useContext(
|
|
49
|
+
const resolveComponent = external_react_default().useContext(context_namespaceObject.RuntimeComponentResolverContext);
|
|
50
50
|
const Component = resolveComponent?.(external_react_helmet_async_namespaceObject.Helmet, {
|
|
51
51
|
name: 'head.Helmet'
|
|
52
52
|
}) ?? external_react_helmet_async_namespaceObject.Helmet;
|
package/dist/cjs/internal.js
CHANGED
|
@@ -28,9 +28,9 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
InternalRuntimeContext: ()=>
|
|
31
|
+
InternalRuntimeContext: ()=>context_namespaceObject.InternalRuntimeContext
|
|
32
32
|
});
|
|
33
|
-
const
|
|
33
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
34
34
|
exports.InternalRuntimeContext = __webpack_exports__.InternalRuntimeContext;
|
|
35
35
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
36
36
|
"InternalRuntimeContext"
|
|
@@ -70,10 +70,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
70
70
|
NavLink: ()=>NavLink
|
|
71
71
|
});
|
|
72
72
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
73
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
73
74
|
const router_namespaceObject = require("@modern-js/runtime-utils/router");
|
|
74
75
|
const external_react_namespaceObject = require("react");
|
|
75
76
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
76
|
-
const index_js_namespaceObject = require("../../core/context/index.js");
|
|
77
77
|
const getWebpackChunkLoader = ()=>__webpack_chunk_load__;
|
|
78
78
|
const getWebpackPublicPath = ()=>{
|
|
79
79
|
try {
|
|
@@ -200,7 +200,7 @@ const getDataHref = (route, pathname, basename)=>{
|
|
|
200
200
|
};
|
|
201
201
|
const PrefetchPageLinks = ({ path, includeData })=>{
|
|
202
202
|
const { pathname } = path;
|
|
203
|
-
const context = (0, external_react_namespaceObject.useContext)(
|
|
203
|
+
const context = (0, external_react_namespaceObject.useContext)(context_namespaceObject.InternalRuntimeContext);
|
|
204
204
|
const { routeManifest, routes } = context;
|
|
205
205
|
const { routeAssets } = routeManifest || {};
|
|
206
206
|
const policy = context.linkPrefetchPolicy;
|
|
@@ -254,7 +254,7 @@ const PrefetchPageLinks = ({ path, includeData })=>{
|
|
|
254
254
|
};
|
|
255
255
|
const PrefetchDataLinks = ({ matches, path, routeManifest })=>{
|
|
256
256
|
const { pathname, search, hash } = path;
|
|
257
|
-
const policy = (0, external_react_namespaceObject.useContext)(
|
|
257
|
+
const policy = (0, external_react_namespaceObject.useContext)(context_namespaceObject.InternalRuntimeContext).linkPrefetchPolicy;
|
|
258
258
|
const currentMatches = (0, router_namespaceObject.useMatches)();
|
|
259
259
|
const basename = (0, router_namespaceObject.useHref)('/');
|
|
260
260
|
const dataHrefs = (0, external_react_namespaceObject.useMemo)(()=>matches?.filter((match, index)=>{
|
|
@@ -287,7 +287,7 @@ const PrefetchDataLinks = ({ matches, path, routeManifest })=>{
|
|
|
287
287
|
};
|
|
288
288
|
const createPrefetchLink = (Link)=>/*#__PURE__*/ (external_react_default()).forwardRef(({ to, prefetch, preload, ...props }, forwardedRef)=>{
|
|
289
289
|
const isAbsolute = 'string' == typeof to && ABSOLUTE_URL_REGEX.test(to);
|
|
290
|
-
const policy = (0, external_react_namespaceObject.useContext)(
|
|
290
|
+
const policy = (0, external_react_namespaceObject.useContext)(context_namespaceObject.InternalRuntimeContext).linkPrefetchPolicy;
|
|
291
291
|
const [shouldPrefetch, shouldPreload, prefetchHandlers, setViewportElement] = usePrefetchBehavior(prefetch, preload, props, policy);
|
|
292
292
|
const setAnchorRef = external_react_default().useCallback((element)=>{
|
|
293
293
|
setViewportElement(element);
|