@bleedingdev/modern-js-runtime 3.2.0-ultramodern.101 → 3.2.0-ultramodern.103
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/boundary-debugger/index.js +9 -5
- package/dist/cjs/cache/index.js +9 -5
- package/dist/cjs/cli/alias.js +9 -5
- package/dist/cjs/cli/code.js +9 -5
- package/dist/cjs/cli/constants.js +20 -16
- package/dist/cjs/cli/entry.js +9 -5
- package/dist/cjs/cli/index.js +9 -5
- package/dist/cjs/cli/ssr/index.js +9 -5
- package/dist/cjs/cli/ssr/loadable-bundler-plugin.js +9 -5
- package/dist/cjs/cli/ssr/mode.js +12 -8
- package/dist/cjs/cli/template.js +9 -5
- package/dist/cjs/cli/template.server.js +9 -5
- package/dist/cjs/common.js +14 -10
- package/dist/cjs/core/browser/hydrate.js +9 -5
- package/dist/cjs/core/browser/index.js +9 -5
- package/dist/cjs/core/browser/withCallback.js +9 -5
- package/dist/cjs/core/compat/hooks.js +14 -10
- package/dist/cjs/core/compat/index.js +9 -5
- package/dist/cjs/core/compat/requestContext.js +13 -9
- package/dist/cjs/core/config.js +12 -8
- package/dist/cjs/core/constants.js +15 -10
- package/dist/cjs/core/context/index.js +9 -5
- package/dist/cjs/core/context/monitors/default.js +12 -8
- package/dist/cjs/core/context/monitors/index.js +9 -5
- package/dist/cjs/core/context/monitors/index.server.js +9 -5
- package/dist/cjs/core/context/request/index.js +12 -8
- package/dist/cjs/core/context/request/index.server.js +9 -5
- package/dist/cjs/core/context/response/index.js +15 -11
- package/dist/cjs/core/context/response/index.server.js +9 -5
- package/dist/cjs/core/context/runtime.js +9 -5
- package/dist/cjs/core/context/serverPayload/index.js +13 -9
- package/dist/cjs/core/context/serverPayload/index.server.js +9 -5
- package/dist/cjs/core/index.js +9 -5
- package/dist/cjs/core/plugin/index.js +9 -5
- package/dist/cjs/core/react/index.js +9 -5
- package/dist/cjs/core/react/wrapper.js +9 -5
- package/dist/cjs/core/server/constants.js +15 -11
- package/dist/cjs/core/server/federatedCss.js +9 -5
- package/dist/cjs/core/server/helmet.js +9 -5
- package/dist/cjs/core/server/index.js +9 -5
- package/dist/cjs/core/server/react/index.js +9 -5
- package/dist/cjs/core/server/react/no-ssr-cache/index.js +9 -5
- package/dist/cjs/core/server/react/nossr/index.js +9 -5
- package/dist/cjs/core/server/requestHandler.js +9 -5
- package/dist/cjs/core/server/scriptOrder.js +12 -8
- package/dist/cjs/core/server/server.js +9 -5
- package/dist/cjs/core/server/shared.js +12 -8
- package/dist/cjs/core/server/stream/afterTemplate.js +9 -5
- package/dist/cjs/core/server/stream/beforeTemplate.js +9 -5
- package/dist/cjs/core/server/stream/beforeTemplate.worker.js +9 -5
- package/dist/cjs/core/server/stream/createReadableStream.js +9 -5
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +9 -5
- package/dist/cjs/core/server/stream/deferredScript.js +9 -5
- package/dist/cjs/core/server/stream/index.js +9 -5
- package/dist/cjs/core/server/stream/shared.js +9 -5
- package/dist/cjs/core/server/stream/template.js +9 -5
- package/dist/cjs/core/server/string/index.js +9 -5
- package/dist/cjs/core/server/string/loadable.js +9 -5
- package/dist/cjs/core/server/string/ssrData.js +9 -5
- package/dist/cjs/core/server/tracer.js +13 -9
- package/dist/cjs/core/server/utils.js +9 -5
- package/dist/cjs/document/Body.js +9 -5
- package/dist/cjs/document/Comment.js +9 -5
- package/dist/cjs/document/DocumentContext.js +9 -5
- package/dist/cjs/document/DocumentStructureContext.js +9 -5
- package/dist/cjs/document/Head.js +9 -5
- package/dist/cjs/document/Html.js +9 -5
- package/dist/cjs/document/Links.js +9 -5
- package/dist/cjs/document/Root.js +9 -5
- package/dist/cjs/document/Script.js +9 -5
- package/dist/cjs/document/Scripts.js +9 -5
- package/dist/cjs/document/Style.js +9 -5
- package/dist/cjs/document/Title.js +9 -5
- package/dist/cjs/document/cli/index.js +12 -6
- package/dist/cjs/document/constants.js +9 -5
- package/dist/cjs/document/index.js +9 -5
- package/dist/cjs/exports/config-routes.js +12 -8
- package/dist/cjs/exports/head.js +9 -5
- package/dist/cjs/exports/loadable.js +15 -11
- package/dist/cjs/exports/tanstack-router.js +9 -5
- package/dist/cjs/index.js +9 -5
- package/dist/cjs/internal.js +9 -5
- package/dist/cjs/react-server.js +9 -5
- package/dist/cjs/router/cli/code/getClientRoutes/getRoutes.js +9 -5
- package/dist/cjs/router/cli/code/getClientRoutes/index.js +9 -5
- package/dist/cjs/router/cli/code/getClientRoutes/utils.js +9 -5
- package/dist/cjs/router/cli/code/index.js +9 -5
- package/dist/cjs/router/cli/code/inspect.js +9 -5
- package/dist/cjs/router/cli/code/makeLegalIdentifier.js +12 -8
- package/dist/cjs/router/cli/code/nestedRoutes.js +9 -5
- package/dist/cjs/router/cli/code/tanstackTypes.js +9 -5
- package/dist/cjs/router/cli/code/templates.js +9 -5
- package/dist/cjs/router/cli/code/utils.js +9 -5
- package/dist/cjs/router/cli/config-routes/converter.js +9 -5
- package/dist/cjs/router/cli/config-routes/parseRouteConfig.js +9 -5
- package/dist/cjs/router/cli/constants.js +23 -19
- package/dist/cjs/router/cli/entry.js +9 -5
- package/dist/cjs/router/cli/handler.js +9 -5
- package/dist/cjs/router/cli/index.js +9 -5
- package/dist/cjs/router/index.js +9 -5
- package/dist/cjs/router/internal.js +12 -8
- package/dist/cjs/router/runtime/CSSLinks.js +9 -5
- package/dist/cjs/router/runtime/DefaultNotFound.js +9 -5
- package/dist/cjs/router/runtime/DeferredDataScripts.js +12 -8
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +9 -5
- package/dist/cjs/router/runtime/PrefetchLink.js +161 -26
- package/dist/cjs/router/runtime/constants.js +9 -5
- package/dist/cjs/router/runtime/hooks.js +9 -5
- package/dist/cjs/router/runtime/index.js +15 -10
- package/dist/cjs/router/runtime/internal.js +9 -5
- package/dist/cjs/router/runtime/lifecycle.js +18 -14
- package/dist/cjs/router/runtime/plugin.js +9 -5
- package/dist/cjs/router/runtime/plugin.node.js +9 -5
- package/dist/cjs/router/runtime/routerHelper.js +9 -5
- package/dist/cjs/router/runtime/rsc-router.js +9 -5
- package/dist/cjs/router/runtime/rsc.js +9 -5
- package/dist/cjs/router/runtime/server.js +9 -5
- package/dist/cjs/router/runtime/tanstack/basepathRewrite.js +12 -8
- package/dist/cjs/router/runtime/tanstack/dataMutation.js +9 -5
- package/dist/cjs/router/runtime/tanstack/hydrationBoundary.js +9 -5
- package/dist/cjs/router/runtime/tanstack/outlet.js +9 -5
- package/dist/cjs/router/runtime/tanstack/plugin.js +9 -5
- package/dist/cjs/router/runtime/tanstack/plugin.node.js +9 -5
- package/dist/cjs/router/runtime/tanstack/prefetchLink.js +10 -6
- package/dist/cjs/router/runtime/tanstack/routeTree.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/ClientSlot.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/CompositeComponent.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/ReplayableStream.js +14 -9
- package/dist/cjs/router/runtime/tanstack/rsc/RscNodeRenderer.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/SlotContext.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/client.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/createRscProxy.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/index.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/server.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/slotUsageSanitizer.js +9 -5
- package/dist/cjs/router/runtime/tanstack/rsc/symbols.js +20 -15
- package/dist/cjs/router/runtime/utils.js +9 -5
- package/dist/cjs/router/runtime/withRouter.js +9 -5
- package/dist/cjs/rsc/client.js +12 -8
- package/dist/cjs/rsc/server.js +9 -5
- package/dist/cjs/rsc/server.worker.js +9 -5
- package/dist/cjs/ssr/index.node.js +13 -9
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +9 -5
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +9 -5
- package/dist/cjs/ssr/serverRender/types.js +9 -5
- package/dist/esm/document/cli/index.mjs +3 -1
- package/dist/esm/router/runtime/PrefetchLink.mjs +152 -21
- package/dist/esm/router/runtime/tanstack/prefetchLink.mjs +1 -1
- package/dist/esm-node/document/cli/index.mjs +3 -1
- package/dist/esm-node/router/runtime/PrefetchLink.mjs +152 -21
- package/dist/esm-node/router/runtime/tanstack/prefetchLink.mjs +1 -1
- package/dist/types/cli/entry.d.ts +2 -2
- package/dist/types/core/context/response/index.server.d.ts +4 -1
- package/dist/types/core/plugin/index.d.ts +1 -1
- package/dist/types/core/server/utils.d.ts +11 -1
- package/dist/types/router/cli/code/utils.d.ts +1 -1
- package/dist/types/router/cli/entry.d.ts +1 -1
- package/dist/types/router/runtime/PrefetchLink.d.ts +5 -1
- package/package.json +10 -10
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
package/dist/cjs/rsc/client.js
CHANGED
|
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
|
|
|
24
24
|
};
|
|
25
25
|
})();
|
|
26
26
|
(()=>{
|
|
27
|
-
__webpack_require__.d = (exports1,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
28
|
+
var define = (defs, kind)=>{
|
|
29
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
[kind]: defs[key]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
define(getters, "get");
|
|
35
|
+
define(values, "value");
|
|
32
36
|
};
|
|
33
37
|
})();
|
|
34
38
|
(()=>{
|
|
@@ -47,9 +51,6 @@ function __webpack_require__(moduleId) {
|
|
|
47
51
|
var __webpack_exports__ = {};
|
|
48
52
|
(()=>{
|
|
49
53
|
__webpack_require__.r(__webpack_exports__);
|
|
50
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
51
|
-
isRedirectResponse: ()=>isRedirectResponse
|
|
52
|
-
});
|
|
53
54
|
var _modern_js_render_client__rspack_import_0 = __webpack_require__("@modern-js/render/client");
|
|
54
55
|
var __rspack_reexport = {};
|
|
55
56
|
for(const __rspack_import_key in _modern_js_render_client__rspack_import_0)if ([
|
|
@@ -58,6 +59,9 @@ var __webpack_exports__ = {};
|
|
|
58
59
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_modern_js_render_client__rspack_import_0[__rspack_import_key];
|
|
59
60
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
60
61
|
const isRedirectResponse = (res)=>null != res.headers.get('X-Modernjs-Redirect');
|
|
62
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
63
|
+
isRedirectResponse: isRedirectResponse
|
|
64
|
+
});
|
|
61
65
|
})();
|
|
62
66
|
exports.isRedirectResponse = __webpack_exports__.isRedirectResponse;
|
|
63
67
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
package/dist/cjs/rsc/server.js
CHANGED
|
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
|
|
|
24
24
|
};
|
|
25
25
|
})();
|
|
26
26
|
(()=>{
|
|
27
|
-
__webpack_require__.d = (exports1,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
28
|
+
var define = (defs, kind)=>{
|
|
29
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
[kind]: defs[key]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
define(getters, "get");
|
|
35
|
+
define(values, "value");
|
|
32
36
|
};
|
|
33
37
|
})();
|
|
34
38
|
(()=>{
|
|
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
|
|
|
24
24
|
};
|
|
25
25
|
})();
|
|
26
26
|
(()=>{
|
|
27
|
-
__webpack_require__.d = (exports1,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
28
|
+
var define = (defs, kind)=>{
|
|
29
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
[kind]: defs[key]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
define(getters, "get");
|
|
35
|
+
define(values, "value");
|
|
32
36
|
};
|
|
33
37
|
})();
|
|
34
38
|
(()=>{
|
|
@@ -33,11 +33,15 @@ function __webpack_require__(moduleId) {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
(()=>{
|
|
36
|
-
__webpack_require__.d = (exports1,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
37
|
+
var define = (defs, kind)=>{
|
|
38
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
[kind]: defs[key]
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
define(getters, "get");
|
|
44
|
+
define(values, "value");
|
|
41
45
|
};
|
|
42
46
|
})();
|
|
43
47
|
(()=>{
|
|
@@ -56,10 +60,6 @@ function __webpack_require__(moduleId) {
|
|
|
56
60
|
var __webpack_exports__ = {};
|
|
57
61
|
(()=>{
|
|
58
62
|
__webpack_require__.r(__webpack_exports__);
|
|
59
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
60
|
-
default: ()=>__rspack_default_export,
|
|
61
|
-
ssr: ()=>ssr
|
|
62
|
-
});
|
|
63
63
|
var _serverRender__rspack_import_0 = __webpack_require__("./serverRender");
|
|
64
64
|
var _serverRender__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(_serverRender__rspack_import_0);
|
|
65
65
|
var _serverRender_tracker__rspack_import_1 = __webpack_require__("./serverRender/tracker");
|
|
@@ -109,6 +109,10 @@ var __webpack_exports__ = {};
|
|
|
109
109
|
})
|
|
110
110
|
});
|
|
111
111
|
const __rspack_default_export = ssr;
|
|
112
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
113
|
+
default: __rspack_default_export,
|
|
114
|
+
ssr: ssr
|
|
115
|
+
});
|
|
112
116
|
})();
|
|
113
117
|
exports["default"] = __webpack_exports__["default"];
|
|
114
118
|
exports.ssr = __webpack_exports__.ssr;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -299,7 +299,7 @@ const documentPlugin = ()=>({
|
|
|
299
299
|
const { entrypoints, internalDirectory, appDirectory } = api.getAppContext();
|
|
300
300
|
const documentFilePath = getDocumentByEntryName(entrypoints, entryName, appDirectory);
|
|
301
301
|
if (!documentFilePath) return null;
|
|
302
|
-
return async (
|
|
302
|
+
return async (templateData)=>{
|
|
303
303
|
const config = api.getNormalizedConfig();
|
|
304
304
|
const documentParams = getDocParams({
|
|
305
305
|
config: config,
|
|
@@ -318,6 +318,8 @@ const documentPlugin = ()=>({
|
|
|
318
318
|
debug("entry %s's document jsx rendered html: %o", entryName, html);
|
|
319
319
|
const { partialsByEntrypoint } = api.getAppContext();
|
|
320
320
|
html = processPartials(html, entryName, partialsByEntrypoint || {});
|
|
321
|
+
const htmlPlugin = templateData.htmlPlugin || templateData.htmlWebpackPlugin || templateData.htmlRspackPlugin;
|
|
322
|
+
if (!htmlPlugin) throw new Error('Failed to get HTML plugin tags from template parameters.');
|
|
321
323
|
const { scripts, links, metas, titles } = extractHtmlTags(htmlPlugin, templateParameters);
|
|
322
324
|
return processPlaceholders(html, config, scripts, links, metas, titles);
|
|
323
325
|
};
|
|
@@ -10,45 +10,141 @@ function composeEventHandlers(theirHandler, ourHandler) {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const DEFAULT_PREFETCH_BEHAVIOR = 'render';
|
|
14
|
+
const DEFAULT_PRELOAD_BEHAVIOR = 'viewport';
|
|
15
|
+
const INTENT_DELAY = 100;
|
|
16
|
+
const VIEWPORT_ROOT_MARGIN = '200px';
|
|
17
|
+
const MAX_CONCURRENT_WARMUPS = 4;
|
|
18
|
+
const WARMUP_TTL = 30000;
|
|
19
|
+
const SLOW_EFFECTIVE_TYPES = new Set([
|
|
20
|
+
'slow-2g',
|
|
21
|
+
'2g'
|
|
22
|
+
]);
|
|
23
|
+
const warmupCache = new Map();
|
|
24
|
+
const warmupQueue = [];
|
|
25
|
+
let activeWarmups = 0;
|
|
26
|
+
const getConnection = ()=>{
|
|
27
|
+
const nav = globalThis.navigator;
|
|
28
|
+
return nav?.connection || nav?.mozConnection || nav?.webkitConnection;
|
|
29
|
+
};
|
|
30
|
+
const shouldWarmupOnCurrentNetwork = ()=>{
|
|
31
|
+
const connection = getConnection();
|
|
32
|
+
if (connection?.saveData) return false;
|
|
33
|
+
if ('string' == typeof connection?.effectiveType && SLOW_EFFECTIVE_TYPES.has(connection.effectiveType)) return false;
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
36
|
+
const pruneWarmupCache = (now = Date.now())=>{
|
|
37
|
+
for (const [key, timestamp] of warmupCache)if (now - timestamp > WARMUP_TTL) warmupCache.delete(key);
|
|
38
|
+
};
|
|
39
|
+
const runNextWarmup = ()=>{
|
|
40
|
+
while(activeWarmups < MAX_CONCURRENT_WARMUPS && warmupQueue.length > 0){
|
|
41
|
+
const task = warmupQueue.shift();
|
|
42
|
+
if (task.cancelled) continue;
|
|
43
|
+
activeWarmups += 1;
|
|
44
|
+
task.run().catch((error)=>{
|
|
45
|
+
console.error(error);
|
|
46
|
+
warmupCache.delete(task.key);
|
|
47
|
+
}).finally(()=>{
|
|
48
|
+
activeWarmups -= 1;
|
|
49
|
+
runNextWarmup();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const scheduleWarmup = (key, run)=>{
|
|
54
|
+
if (!shouldWarmupOnCurrentNetwork()) return ()=>{};
|
|
55
|
+
pruneWarmupCache();
|
|
56
|
+
if (warmupCache.has(key)) return ()=>{};
|
|
57
|
+
warmupCache.set(key, Date.now());
|
|
58
|
+
const task = {
|
|
59
|
+
key,
|
|
60
|
+
run,
|
|
61
|
+
cancelled: false
|
|
62
|
+
};
|
|
63
|
+
warmupQueue.push(task);
|
|
64
|
+
runNextWarmup();
|
|
65
|
+
return ()=>{
|
|
66
|
+
task.cancelled = true;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const setRef = (ref, value)=>{
|
|
70
|
+
if (!ref) return;
|
|
71
|
+
if ('function' == typeof ref) return void ref(value);
|
|
72
|
+
try {
|
|
73
|
+
ref.current = value;
|
|
74
|
+
} catch {}
|
|
75
|
+
};
|
|
76
|
+
const isDataWarmupEnabled = (route)=>{
|
|
77
|
+
const handle = route.handle;
|
|
78
|
+
return handle?.navigationWarmup?.data === true;
|
|
79
|
+
};
|
|
80
|
+
function usePrefetchBehavior(prefetch, preload, theirElementProps) {
|
|
81
|
+
const [maybeWarmup, setMaybeWarmup] = react.useState(false);
|
|
15
82
|
const [shouldPrefetch, setShouldPrefetch] = react.useState(false);
|
|
83
|
+
const [shouldPreload, setShouldPreload] = react.useState(false);
|
|
84
|
+
const [viewportElement, setViewportElement] = react.useState(null);
|
|
16
85
|
const { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
|
|
17
86
|
react.useEffect(()=>{
|
|
18
87
|
if ('render' === prefetch) setShouldPrefetch(true);
|
|
88
|
+
if ('render' === preload) setShouldPreload(true);
|
|
19
89
|
}, [
|
|
20
|
-
prefetch
|
|
90
|
+
prefetch,
|
|
91
|
+
preload
|
|
21
92
|
]);
|
|
22
93
|
const setIntent = ()=>{
|
|
23
|
-
if ('intent' === prefetch)
|
|
94
|
+
if ('intent' === prefetch || 'intent' === preload) setMaybeWarmup(true);
|
|
24
95
|
};
|
|
25
96
|
const cancelIntent = ()=>{
|
|
26
|
-
if ('intent' === prefetch) {
|
|
27
|
-
|
|
97
|
+
if ('intent' === prefetch || 'intent' === preload) {
|
|
98
|
+
setMaybeWarmup(false);
|
|
28
99
|
setShouldPrefetch(false);
|
|
100
|
+
setShouldPreload(false);
|
|
29
101
|
}
|
|
30
102
|
};
|
|
31
103
|
react.useEffect(()=>{
|
|
32
|
-
if (
|
|
104
|
+
if (maybeWarmup) {
|
|
33
105
|
const id = setTimeout(()=>{
|
|
34
|
-
setShouldPrefetch(true);
|
|
35
|
-
|
|
106
|
+
if ('intent' === prefetch) setShouldPrefetch(true);
|
|
107
|
+
if ('intent' === preload) setShouldPreload(true);
|
|
108
|
+
}, INTENT_DELAY);
|
|
36
109
|
return ()=>{
|
|
37
110
|
clearTimeout(id);
|
|
38
111
|
};
|
|
39
112
|
}
|
|
40
113
|
}, [
|
|
41
|
-
|
|
114
|
+
maybeWarmup,
|
|
115
|
+
prefetch,
|
|
116
|
+
preload
|
|
117
|
+
]);
|
|
118
|
+
react.useEffect(()=>{
|
|
119
|
+
if (!viewportElement || 'viewport' !== prefetch && 'viewport' !== preload || "u" < typeof IntersectionObserver) return;
|
|
120
|
+
const observer = new IntersectionObserver((entries)=>{
|
|
121
|
+
if (!entries.some((entry)=>entry.isIntersecting)) return;
|
|
122
|
+
if ('viewport' === prefetch) setShouldPrefetch(true);
|
|
123
|
+
if ('viewport' === preload) setShouldPreload(true);
|
|
124
|
+
observer.disconnect();
|
|
125
|
+
}, {
|
|
126
|
+
rootMargin: VIEWPORT_ROOT_MARGIN
|
|
127
|
+
});
|
|
128
|
+
observer.observe(viewportElement);
|
|
129
|
+
return ()=>{
|
|
130
|
+
observer.disconnect();
|
|
131
|
+
};
|
|
132
|
+
}, [
|
|
133
|
+
prefetch,
|
|
134
|
+
preload,
|
|
135
|
+
viewportElement
|
|
42
136
|
]);
|
|
43
137
|
return [
|
|
44
138
|
shouldPrefetch,
|
|
139
|
+
shouldPreload,
|
|
45
140
|
{
|
|
46
141
|
onFocus: composeEventHandlers(onFocus, setIntent),
|
|
47
142
|
onBlur: composeEventHandlers(onBlur, cancelIntent),
|
|
48
143
|
onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
|
|
49
144
|
onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
|
|
50
145
|
onTouchStart: composeEventHandlers(onTouchStart, setIntent)
|
|
51
|
-
}
|
|
146
|
+
},
|
|
147
|
+
setViewportElement
|
|
52
148
|
];
|
|
53
149
|
}
|
|
54
150
|
async function loadRouteModule(route, routeAssets) {
|
|
@@ -83,14 +179,34 @@ const getDataHref = (route, pathname, basename)=>{
|
|
|
83
179
|
const url = getRequestUrl(path, id);
|
|
84
180
|
return createDataHref(url.toString());
|
|
85
181
|
};
|
|
86
|
-
const PrefetchPageLinks = ({ path })=>{
|
|
182
|
+
const PrefetchPageLinks = ({ path, includeData })=>{
|
|
87
183
|
const { pathname } = path;
|
|
88
184
|
const context = useContext(InternalRuntimeContext);
|
|
89
185
|
const { routeManifest, routes } = context;
|
|
90
186
|
const { routeAssets } = routeManifest || {};
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
187
|
+
const allowNetworkWarmup = shouldWarmupOnCurrentNetwork();
|
|
188
|
+
const matches = useMemo(()=>Array.isArray(routes) ? matchRoutes(routes, pathname) : [], [
|
|
189
|
+
pathname,
|
|
190
|
+
routes
|
|
191
|
+
]);
|
|
192
|
+
react.useEffect(()=>{
|
|
193
|
+
if (!allowNetworkWarmup || !Array.isArray(matches) || !routeAssets || !__webpack_chunk_load__) return;
|
|
194
|
+
const cancellations = matches.map((match)=>{
|
|
195
|
+
const routeId = match.route.id;
|
|
196
|
+
const routeAsset = routeId ? routeAssets[routeId] : void 0;
|
|
197
|
+
const chunkIds = routeAsset?.chunkIds;
|
|
198
|
+
if (!routeId || !Array.isArray(chunkIds) || 0 === chunkIds.length) return ()=>{};
|
|
199
|
+
return scheduleWarmup(`route-module:${routeId}:${chunkIds.join(',')}`, ()=>loadRouteModule(match.route, routeAssets));
|
|
200
|
+
});
|
|
201
|
+
return ()=>{
|
|
202
|
+
cancellations.forEach((cancel)=>cancel());
|
|
203
|
+
};
|
|
204
|
+
}, [
|
|
205
|
+
allowNetworkWarmup,
|
|
206
|
+
matches,
|
|
207
|
+
routeAssets
|
|
208
|
+
]);
|
|
209
|
+
if (!allowNetworkWarmup || !includeData || !window._SSR_DATA) return null;
|
|
94
210
|
return /*#__PURE__*/ jsx(PrefetchDataLinks, {
|
|
95
211
|
matches: matches,
|
|
96
212
|
path: path,
|
|
@@ -102,7 +218,7 @@ const PrefetchDataLinks = ({ matches, path, routeManifest })=>{
|
|
|
102
218
|
const currentMatches = useMatches();
|
|
103
219
|
const basename = useHref('/');
|
|
104
220
|
const dataHrefs = useMemo(()=>matches?.filter((match, index)=>{
|
|
105
|
-
if (!match.route.loader || 'function' != typeof match.route.loader || 0 === match.route.loader.length) return false;
|
|
221
|
+
if (!isDataWarmupEnabled(match.route) || !match.route.loader || 'function' != typeof match.route.loader || 0 === match.route.loader.length) return false;
|
|
106
222
|
if (match.route.shouldRevalidate) {
|
|
107
223
|
const currentUrl = new URL(location.pathname + location.search + location.hash, window.origin);
|
|
108
224
|
const nextUrl = new URL(pathname + search + hash, window.origin);
|
|
@@ -129,20 +245,35 @@ const PrefetchDataLinks = ({ matches, path, routeManifest })=>{
|
|
|
129
245
|
children: dataHrefs
|
|
130
246
|
});
|
|
131
247
|
};
|
|
132
|
-
const
|
|
248
|
+
const normalizePreloadBehavior = (preload, prefetch)=>{
|
|
249
|
+
if (false === preload || 'none' === preload) return 'none';
|
|
250
|
+
if (void 0 !== preload) return preload;
|
|
251
|
+
if ('none' === prefetch) return 'none';
|
|
252
|
+
return DEFAULT_PRELOAD_BEHAVIOR;
|
|
253
|
+
};
|
|
254
|
+
const createPrefetchLink = (Link)=>/*#__PURE__*/ react.forwardRef(({ to, prefetch = DEFAULT_PREFETCH_BEHAVIOR, preload, ...props }, forwardedRef)=>{
|
|
133
255
|
const isAbsolute = 'string' == typeof to && ABSOLUTE_URL_REGEX.test(to);
|
|
134
|
-
const
|
|
256
|
+
const resolvedPreload = normalizePreloadBehavior(preload, prefetch);
|
|
257
|
+
const [shouldPrefetch, shouldPreload, prefetchHandlers, setViewportElement] = usePrefetchBehavior(prefetch, resolvedPreload, props);
|
|
258
|
+
const setAnchorRef = react.useCallback((element)=>{
|
|
259
|
+
setViewportElement(element);
|
|
260
|
+
setRef(forwardedRef, element);
|
|
261
|
+
}, [
|
|
262
|
+
forwardedRef,
|
|
263
|
+
setViewportElement
|
|
264
|
+
]);
|
|
135
265
|
const resolvedPath = useResolvedPath(to);
|
|
136
266
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
137
267
|
children: [
|
|
138
268
|
/*#__PURE__*/ jsx(Link, {
|
|
139
|
-
ref:
|
|
269
|
+
ref: setAnchorRef,
|
|
140
270
|
to: to,
|
|
141
271
|
...props,
|
|
142
272
|
...prefetchHandlers
|
|
143
273
|
}),
|
|
144
|
-
shouldPrefetch
|
|
145
|
-
path: resolvedPath
|
|
274
|
+
(shouldPrefetch || shouldPreload) && !isAbsolute ? /*#__PURE__*/ jsx(PrefetchPageLinks, {
|
|
275
|
+
path: resolvedPath,
|
|
276
|
+
includeData: shouldPrefetch
|
|
146
277
|
}) : null
|
|
147
278
|
]
|
|
148
279
|
});
|
|
@@ -4,7 +4,7 @@ function resolvePreloadFromPrefetch(prefetch, preload) {
|
|
|
4
4
|
if (void 0 !== preload) return preload;
|
|
5
5
|
if ('none' === prefetch) return false;
|
|
6
6
|
if ('intent' === prefetch || 'render' === prefetch || 'viewport' === prefetch) return prefetch;
|
|
7
|
-
return
|
|
7
|
+
return 'viewport';
|
|
8
8
|
}
|
|
9
9
|
const LinkComponentImpl = (props)=>{
|
|
10
10
|
const { prefetch, preload, ...rest } = props;
|
|
@@ -301,7 +301,7 @@ const documentPlugin = ()=>({
|
|
|
301
301
|
const { entrypoints, internalDirectory, appDirectory } = api.getAppContext();
|
|
302
302
|
const documentFilePath = getDocumentByEntryName(entrypoints, entryName, appDirectory);
|
|
303
303
|
if (!documentFilePath) return null;
|
|
304
|
-
return async (
|
|
304
|
+
return async (templateData)=>{
|
|
305
305
|
const config = api.getNormalizedConfig();
|
|
306
306
|
const documentParams = getDocParams({
|
|
307
307
|
config: config,
|
|
@@ -320,6 +320,8 @@ const documentPlugin = ()=>({
|
|
|
320
320
|
debug("entry %s's document jsx rendered html: %o", entryName, html);
|
|
321
321
|
const { partialsByEntrypoint } = api.getAppContext();
|
|
322
322
|
html = processPartials(html, entryName, partialsByEntrypoint || {});
|
|
323
|
+
const htmlPlugin = templateData.htmlPlugin || templateData.htmlWebpackPlugin || templateData.htmlRspackPlugin;
|
|
324
|
+
if (!htmlPlugin) throw new Error('Failed to get HTML plugin tags from template parameters.');
|
|
323
325
|
const { scripts, links, metas, titles } = extractHtmlTags(htmlPlugin, templateParameters);
|
|
324
326
|
return processPlaceholders(html, config, scripts, links, metas, titles);
|
|
325
327
|
};
|