@bleedingdev/modern-js-runtime 3.2.0-ultramodern.99 → 3.4.0-ultramodern.1
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 +19 -11
- 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 +20 -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/extensions.js +69 -0
- package/dist/cjs/core/context/helmetContext.js +54 -0
- package/dist/cjs/core/context/index.js +74 -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 +15 -9
- package/dist/cjs/core/server/constants.js +15 -11
- package/dist/cjs/core/server/federatedCss.js +11 -7
- package/dist/cjs/core/server/helmet.js +11 -6
- 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 +51 -34
- package/dist/cjs/core/server/routerCleanup.js +110 -0
- package/dist/cjs/core/server/scriptOrder.js +84 -9
- 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 +15 -23
- package/dist/cjs/core/server/stream/beforeTemplate.js +11 -7
- package/dist/cjs/core/server/stream/beforeTemplate.worker.js +10 -6
- package/dist/cjs/core/server/stream/createReadableStream.js +16 -10
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +15 -7
- package/dist/cjs/core/server/stream/deferredScript.js +13 -6
- 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 +10 -12
- package/dist/cjs/core/server/string/loadable.js +24 -54
- package/dist/cjs/core/server/string/ssrData.js +10 -6
- package/dist/cjs/core/server/tracer.js +13 -9
- package/dist/cjs/core/server/utils.js +63 -13
- 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 +14 -11
- 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 +153 -83
- package/dist/cjs/exports/loadable.js +27 -18
- package/dist/cjs/exports/tanstack-router.js +50 -58
- package/dist/cjs/index.js +9 -5
- package/dist/cjs/internal.js +9 -5
- package/dist/cjs/module-federation/index.js +178 -0
- 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 +16 -52
- 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/templates.js +10 -19
- 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 +10 -6
- package/dist/cjs/router/cli/index.js +11 -29
- 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 +25 -9
- 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 +29 -18
- package/dist/cjs/router/runtime/lifecycle.js +38 -19
- package/dist/cjs/router/runtime/plugin.js +11 -14
- package/dist/cjs/router/runtime/plugin.node.js +11 -12
- package/dist/cjs/router/runtime/provider.js +107 -0
- package/dist/cjs/router/runtime/routerHelper.js +9 -5
- package/dist/cjs/router/runtime/rsc-router.js +19 -9
- package/dist/cjs/router/runtime/rsc.js +9 -5
- package/dist/cjs/router/runtime/server.js +9 -5
- package/dist/cjs/router/runtime/utils.js +44 -15
- 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/esm/boundary-debugger/index.mjs +10 -6
- package/dist/esm/cli/index.mjs +4 -2
- package/dist/esm/core/context/extensions.mjs +28 -0
- package/dist/esm/core/context/helmetContext.mjs +13 -0
- package/dist/esm/core/context/index.mjs +5 -0
- package/dist/esm/core/react/wrapper.mjs +6 -4
- package/dist/esm/core/server/federatedCss.mjs +2 -2
- package/dist/esm/core/server/helmet.mjs +2 -1
- package/dist/esm/core/server/requestHandler.mjs +43 -30
- package/dist/esm/core/server/routerCleanup.mjs +66 -0
- package/dist/esm/core/server/scriptOrder.mjs +62 -3
- package/dist/esm/core/server/stream/afterTemplate.mjs +8 -20
- package/dist/esm/core/server/stream/beforeTemplate.mjs +3 -3
- package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +1 -1
- package/dist/esm/core/server/stream/createReadableStream.mjs +7 -5
- package/dist/esm/core/server/stream/createReadableStream.worker.mjs +6 -2
- package/dist/esm/core/server/stream/deferredScript.mjs +4 -1
- package/dist/esm/core/server/string/index.mjs +3 -9
- package/dist/esm/core/server/string/loadable.mjs +14 -48
- package/dist/esm/core/server/string/ssrData.mjs +2 -2
- package/dist/esm/core/server/utils.mjs +52 -9
- package/dist/esm/document/cli/index.mjs +5 -6
- package/dist/esm/exports/head.mjs +144 -78
- package/dist/esm/exports/loadable.mjs +12 -6
- package/dist/esm/exports/tanstack-router.mjs +30 -3
- package/dist/esm/module-federation/index.mjs +109 -0
- package/dist/esm/router/cli/code/index.mjs +8 -48
- package/dist/esm/router/cli/code/templates.mjs +1 -14
- package/dist/esm/router/cli/handler.mjs +1 -1
- package/dist/esm/router/cli/index.mjs +3 -25
- package/dist/esm/router/runtime/DeferredDataScripts.node.mjs +16 -4
- package/dist/esm/router/runtime/PrefetchLink.mjs +152 -21
- package/dist/esm/router/runtime/internal.mjs +16 -15
- package/dist/esm/router/runtime/lifecycle.mjs +22 -13
- package/dist/esm/router/runtime/plugin.mjs +4 -11
- package/dist/esm/router/runtime/plugin.node.mjs +4 -9
- package/dist/esm/router/runtime/provider.mjs +57 -0
- package/dist/esm/router/runtime/rsc-router.mjs +10 -4
- package/dist/esm/router/runtime/utils.mjs +35 -10
- package/dist/esm-node/boundary-debugger/index.mjs +10 -6
- package/dist/esm-node/cli/index.mjs +4 -2
- package/dist/esm-node/core/context/extensions.mjs +29 -0
- package/dist/esm-node/core/context/helmetContext.mjs +14 -0
- package/dist/esm-node/core/context/index.mjs +5 -0
- package/dist/esm-node/core/react/wrapper.mjs +6 -4
- package/dist/esm-node/core/server/federatedCss.mjs +2 -2
- package/dist/esm-node/core/server/helmet.mjs +2 -1
- package/dist/esm-node/core/server/requestHandler.mjs +43 -30
- package/dist/esm-node/core/server/routerCleanup.mjs +67 -0
- package/dist/esm-node/core/server/scriptOrder.mjs +62 -3
- package/dist/esm-node/core/server/stream/afterTemplate.mjs +8 -20
- package/dist/esm-node/core/server/stream/beforeTemplate.mjs +3 -3
- package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +1 -1
- package/dist/esm-node/core/server/stream/createReadableStream.mjs +7 -5
- package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +6 -2
- package/dist/esm-node/core/server/stream/deferredScript.mjs +4 -1
- package/dist/esm-node/core/server/string/index.mjs +3 -9
- package/dist/esm-node/core/server/string/loadable.mjs +14 -48
- package/dist/esm-node/core/server/string/ssrData.mjs +2 -2
- package/dist/esm-node/core/server/utils.mjs +52 -9
- package/dist/esm-node/document/cli/index.mjs +5 -6
- package/dist/esm-node/exports/head.mjs +144 -78
- package/dist/esm-node/exports/loadable.mjs +12 -6
- package/dist/esm-node/exports/tanstack-router.mjs +30 -3
- package/dist/esm-node/module-federation/index.mjs +110 -0
- package/dist/esm-node/router/cli/code/index.mjs +8 -48
- package/dist/esm-node/router/cli/code/templates.mjs +1 -14
- package/dist/esm-node/router/cli/handler.mjs +1 -1
- package/dist/esm-node/router/cli/index.mjs +3 -25
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.mjs +16 -4
- package/dist/esm-node/router/runtime/PrefetchLink.mjs +152 -21
- package/dist/esm-node/router/runtime/internal.mjs +16 -15
- package/dist/esm-node/router/runtime/lifecycle.mjs +22 -13
- package/dist/esm-node/router/runtime/plugin.mjs +4 -11
- package/dist/esm-node/router/runtime/plugin.node.mjs +4 -9
- package/dist/esm-node/router/runtime/provider.mjs +58 -0
- package/dist/esm-node/router/runtime/rsc-router.mjs +10 -4
- package/dist/esm-node/router/runtime/utils.mjs +35 -10
- package/dist/types/cli/entry.d.ts +2 -2
- package/dist/types/cli/index.d.ts +3 -1
- package/dist/types/core/context/extensions.d.ts +37 -0
- package/dist/types/core/context/helmetContext.d.ts +10 -0
- package/dist/types/core/context/index.d.ts +6 -0
- package/dist/types/core/context/response/index.server.d.ts +4 -1
- package/dist/types/core/context/runtime.d.ts +1 -11
- package/dist/types/core/plugin/index.d.ts +1 -1
- package/dist/types/core/server/routerCleanup.d.ts +28 -0
- package/dist/types/core/server/scriptOrder.d.ts +24 -0
- package/dist/types/core/server/string/loadable.d.ts +1 -7
- package/dist/types/core/server/utils.d.ts +19 -1
- package/dist/types/document/constants.d.ts +3 -1
- package/dist/types/exports/head.d.ts +4 -4
- package/dist/types/exports/loadable.d.ts +1 -1
- package/dist/types/exports/tanstack-router.d.ts +88 -5
- package/dist/types/module-federation/index.d.ts +65 -0
- package/dist/types/router/cli/code/index.d.ts +1 -3
- 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/cli/handler.d.ts +0 -3
- package/dist/types/router/runtime/DeferredDataScripts.d.ts +1 -1
- package/dist/types/router/runtime/PrefetchLink.d.ts +5 -1
- package/dist/types/router/runtime/internal.d.ts +1 -0
- package/dist/types/router/runtime/lifecycle.d.ts +2 -0
- package/dist/types/router/runtime/plugin.d.ts +1 -1
- package/dist/types/router/runtime/plugin.node.d.ts +1 -1
- package/dist/types/router/runtime/provider.d.ts +61 -0
- package/package.json +34 -26
- package/rstest.config.mts +2 -4
- package/dist/cjs/router/cli/code/tanstackTypes.js +0 -443
- package/dist/cjs/router/runtime/tanstack/basepathRewrite.js +0 -62
- package/dist/cjs/router/runtime/tanstack/dataMutation.js +0 -345
- package/dist/cjs/router/runtime/tanstack/hydrationBoundary.js +0 -43
- package/dist/cjs/router/runtime/tanstack/plugin.js +0 -240
- package/dist/cjs/router/runtime/tanstack/plugin.node.js +0 -268
- package/dist/cjs/router/runtime/tanstack/prefetchLink.js +0 -55
- package/dist/cjs/router/runtime/tanstack/routeTree.js +0 -510
- package/dist/cjs/router/runtime/tanstack/rsc/ClientSlot.js +0 -53
- package/dist/cjs/router/runtime/tanstack/rsc/CompositeComponent.js +0 -75
- package/dist/cjs/router/runtime/tanstack/rsc/ReplayableStream.js +0 -141
- package/dist/cjs/router/runtime/tanstack/rsc/RscNodeRenderer.js +0 -65
- package/dist/cjs/router/runtime/tanstack/rsc/SlotContext.js +0 -54
- package/dist/cjs/router/runtime/tanstack/rsc/client.js +0 -93
- package/dist/cjs/router/runtime/tanstack/rsc/createRscProxy.js +0 -141
- package/dist/cjs/router/runtime/tanstack/rsc/index.js +0 -42
- package/dist/cjs/router/runtime/tanstack/rsc/server.js +0 -246
- package/dist/cjs/router/runtime/tanstack/rsc/slotUsageSanitizer.js +0 -65
- package/dist/cjs/router/runtime/tanstack/rsc/symbols.js +0 -72
- package/dist/cjs/ssr/index.node.js +0 -121
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +0 -84
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +0 -196
- package/dist/cjs/ssr/serverRender/types.js +0 -36
- package/dist/esm/router/cli/code/tanstackTypes.mjs +0 -396
- package/dist/esm/router/runtime/tanstack/basepathRewrite.mjs +0 -28
- package/dist/esm/router/runtime/tanstack/dataMutation.mjs +0 -305
- package/dist/esm/router/runtime/tanstack/hydrationBoundary.mjs +0 -9
- package/dist/esm/router/runtime/tanstack/plugin.mjs +0 -206
- package/dist/esm/router/runtime/tanstack/plugin.node.mjs +0 -234
- package/dist/esm/router/runtime/tanstack/prefetchLink.mjs +0 -18
- package/dist/esm/router/runtime/tanstack/routeTree.mjs +0 -470
- package/dist/esm/router/runtime/tanstack/rsc/ClientSlot.mjs +0 -19
- package/dist/esm/router/runtime/tanstack/rsc/CompositeComponent.mjs +0 -41
- package/dist/esm/router/runtime/tanstack/rsc/ReplayableStream.mjs +0 -104
- package/dist/esm/router/runtime/tanstack/rsc/RscNodeRenderer.mjs +0 -31
- package/dist/esm/router/runtime/tanstack/rsc/SlotContext.mjs +0 -17
- package/dist/esm/router/runtime/tanstack/rsc/client.mjs +0 -53
- package/dist/esm/router/runtime/tanstack/rsc/createRscProxy.mjs +0 -107
- package/dist/esm/router/runtime/tanstack/rsc/index.mjs +0 -1
- package/dist/esm/router/runtime/tanstack/rsc/server.mjs +0 -200
- package/dist/esm/router/runtime/tanstack/rsc/slotUsageSanitizer.mjs +0 -31
- package/dist/esm/router/runtime/tanstack/rsc/symbols.mjs +0 -17
- package/dist/esm/ssr/index.node.mjs +0 -44
- package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.after.mjs +0 -50
- package/dist/esm/ssr/serverRender/renderToString/entry.mjs +0 -151
- package/dist/esm/ssr/serverRender/types.mjs +0 -1
- package/dist/esm-node/router/cli/code/tanstackTypes.mjs +0 -397
- package/dist/esm-node/router/runtime/tanstack/basepathRewrite.mjs +0 -29
- package/dist/esm-node/router/runtime/tanstack/dataMutation.mjs +0 -306
- package/dist/esm-node/router/runtime/tanstack/hydrationBoundary.mjs +0 -10
- package/dist/esm-node/router/runtime/tanstack/plugin.mjs +0 -207
- package/dist/esm-node/router/runtime/tanstack/plugin.node.mjs +0 -235
- package/dist/esm-node/router/runtime/tanstack/prefetchLink.mjs +0 -19
- package/dist/esm-node/router/runtime/tanstack/routeTree.mjs +0 -471
- package/dist/esm-node/router/runtime/tanstack/rsc/ClientSlot.mjs +0 -20
- package/dist/esm-node/router/runtime/tanstack/rsc/CompositeComponent.mjs +0 -42
- package/dist/esm-node/router/runtime/tanstack/rsc/ReplayableStream.mjs +0 -105
- package/dist/esm-node/router/runtime/tanstack/rsc/RscNodeRenderer.mjs +0 -32
- package/dist/esm-node/router/runtime/tanstack/rsc/SlotContext.mjs +0 -18
- package/dist/esm-node/router/runtime/tanstack/rsc/client.mjs +0 -54
- package/dist/esm-node/router/runtime/tanstack/rsc/createRscProxy.mjs +0 -108
- package/dist/esm-node/router/runtime/tanstack/rsc/index.mjs +0 -2
- package/dist/esm-node/router/runtime/tanstack/rsc/server.mjs +0 -201
- package/dist/esm-node/router/runtime/tanstack/rsc/slotUsageSanitizer.mjs +0 -32
- package/dist/esm-node/router/runtime/tanstack/rsc/symbols.mjs +0 -18
- package/dist/esm-node/ssr/index.node.mjs +0 -45
- package/dist/esm-node/ssr/serverRender/renderToStream/buildTemplate.after.mjs +0 -51
- package/dist/esm-node/ssr/serverRender/renderToString/entry.mjs +0 -152
- package/dist/esm-node/ssr/serverRender/types.mjs +0 -2
- package/dist/types/router/cli/code/tanstackTypes.d.ts +0 -10
- package/dist/types/router/runtime/tanstack/basepathRewrite.d.ts +0 -8
- package/dist/types/router/runtime/tanstack/dataMutation.d.ts +0 -29
- package/dist/types/router/runtime/tanstack/hydrationBoundary.d.ts +0 -2
- package/dist/types/router/runtime/tanstack/plugin.d.ts +0 -6
- package/dist/types/router/runtime/tanstack/plugin.node.d.ts +0 -6
- package/dist/types/router/runtime/tanstack/prefetchLink.d.ts +0 -11
- package/dist/types/router/runtime/tanstack/routeTree.d.ts +0 -8
- package/dist/types/router/runtime/tanstack/rsc/ClientSlot.d.ts +0 -5
- package/dist/types/router/runtime/tanstack/rsc/CompositeComponent.d.ts +0 -3
- package/dist/types/router/runtime/tanstack/rsc/ReplayableStream.d.ts +0 -24
- package/dist/types/router/runtime/tanstack/rsc/RscNodeRenderer.d.ts +0 -5
- package/dist/types/router/runtime/tanstack/rsc/SlotContext.d.ts +0 -11
- package/dist/types/router/runtime/tanstack/rsc/client.d.ts +0 -11
- package/dist/types/router/runtime/tanstack/rsc/createRscProxy.d.ts +0 -7
- package/dist/types/router/runtime/tanstack/rsc/index.d.ts +0 -2
- package/dist/types/router/runtime/tanstack/rsc/server.d.ts +0 -14
- package/dist/types/router/runtime/tanstack/rsc/slotUsageSanitizer.d.ts +0 -2
- package/dist/types/router/runtime/tanstack/rsc/symbols.d.ts +0 -46
|
@@ -77,9 +77,13 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
77
77
|
if (shellChunkStatus !== ShellChunkStatus.FINISH) {
|
|
78
78
|
chunkVec.push(new TextDecoder().decode(value));
|
|
79
79
|
const concatedChunk = chunkVec.join('');
|
|
80
|
-
|
|
80
|
+
const markerIndex = concatedChunk.indexOf(ESCAPED_SHELL_STREAM_END_MARK);
|
|
81
|
+
if (-1 !== markerIndex) {
|
|
82
|
+
const beforeMark = concatedChunk.slice(0, markerIndex);
|
|
83
|
+
const afterMark = concatedChunk.slice(markerIndex + ESCAPED_SHELL_STREAM_END_MARK.length);
|
|
81
84
|
shellChunkStatus = ShellChunkStatus.FINISH;
|
|
82
|
-
safeEnqueue(encodeForWebStream(`${shellBefore}${
|
|
85
|
+
safeEnqueue(encodeForWebStream(`${shellBefore}${beforeMark}${shellAfter}`));
|
|
86
|
+
if (afterMark.length > 0) safeEnqueue(encodeForWebStream(afterMark));
|
|
83
87
|
flushPendingScripts();
|
|
84
88
|
}
|
|
85
89
|
} else safeEnqueue(value);
|
|
@@ -22,12 +22,15 @@ function isPromiseLike(value) {
|
|
|
22
22
|
return !!value && 'function' == typeof value.then;
|
|
23
23
|
}
|
|
24
24
|
function toErrorInfo(error) {
|
|
25
|
+
if ('production' === process.env.NODE_ENV) return {
|
|
26
|
+
message: 'Unexpected Server Error'
|
|
27
|
+
};
|
|
25
28
|
if (error && 'object' == typeof error) {
|
|
26
29
|
const maybeMsg = error.message;
|
|
27
30
|
const maybeStack = error.stack;
|
|
28
31
|
return {
|
|
29
32
|
message: 'string' == typeof maybeMsg ? maybeMsg : String(maybeMsg ?? error),
|
|
30
|
-
stack:
|
|
33
|
+
stack: maybeStack
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
return {
|
|
@@ -4,9 +4,9 @@ import server from "react-dom/server";
|
|
|
4
4
|
import { RenderLevel } from "../../constants.mjs";
|
|
5
5
|
import { getGlobalInternalRuntimeContext } from "../../context/index.mjs";
|
|
6
6
|
import { wrapRuntimeContextProvider } from "../../react/wrapper.mjs";
|
|
7
|
-
import { CHUNK_CSS_PLACEHOLDER,
|
|
7
|
+
import { CHUNK_CSS_PLACEHOLDER, HTML_PLACEHOLDER, SSR_DATA_PLACEHOLDER } from "../constants.mjs";
|
|
8
8
|
import { createReplaceHelemt, getHelmetData } from "../helmet.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { replaceChunkJsPlaceholder } from "../scriptOrder.mjs";
|
|
10
10
|
import { buildHtml } from "../shared.mjs";
|
|
11
11
|
import { SSRErrors, SSRTimings } from "../tracer.mjs";
|
|
12
12
|
import { getSSRConfigByEntry, safeReplace } from "../utils.mjs";
|
|
@@ -98,13 +98,7 @@ function createReplaceSSRDataScript(data) {
|
|
|
98
98
|
return (template)=>safeReplace(template, SSR_DATA_PLACEHOLDER, data);
|
|
99
99
|
}
|
|
100
100
|
function createReplaceChunkJs(js, entryName) {
|
|
101
|
-
return (template)=>
|
|
102
|
-
if (!js) return safeReplace(template, CHUNK_JS_PLACEHOLDER, '');
|
|
103
|
-
const withoutPlaceholder = safeReplace(template, CHUNK_JS_PLACEHOLDER, '');
|
|
104
|
-
const withEarlyScripts = injectBeforeHydrationEntryScript(withoutPlaceholder, js, entryName);
|
|
105
|
-
if (withEarlyScripts !== withoutPlaceholder) return withEarlyScripts;
|
|
106
|
-
return safeReplace(template, CHUNK_JS_PLACEHOLDER, js);
|
|
107
|
-
};
|
|
101
|
+
return (template)=>replaceChunkJsPlaceholder(template, js, entryName);
|
|
108
102
|
}
|
|
109
103
|
function createReplaceChunkCss(css) {
|
|
110
104
|
return (template)=>safeReplace(template, CHUNK_CSS_PLACEHOLDER, css);
|
|
@@ -1,39 +1,21 @@
|
|
|
1
1
|
import { ChunkExtractor } from "@loadable/server";
|
|
2
|
-
import { getRouterMatchedRouteIds } from "../../../router/runtime/lifecycle.mjs";
|
|
3
2
|
import { createFederatedCssLinks } from "../federatedCss.mjs";
|
|
4
|
-
import {
|
|
3
|
+
import { getMatchedRouteAssets, orderHydrationScriptChunks } from "../scriptOrder.mjs";
|
|
4
|
+
import { attributesToString, checkIsNode, hasStylesheetLink } from "../utils.mjs";
|
|
5
5
|
const extname = (uri)=>{
|
|
6
6
|
if ('string' != typeof uri || !uri.includes('.')) return '';
|
|
7
7
|
return `.${uri?.split('.').pop()}` || '';
|
|
8
8
|
};
|
|
9
9
|
const generateChunks = (chunks, ext)=>chunks.filter((chunk)=>Boolean(chunk.url)).filter((chunk)=>extname(chunk.url).slice(1) === ext);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const routeAssetToChunk = (asset)=>({
|
|
11
|
+
chunk: asset,
|
|
12
|
+
filename: asset.replace(/^\//, ''),
|
|
13
|
+
linkType: 'preload',
|
|
14
|
+
path: asset,
|
|
15
|
+
scriptType: asset.endsWith('.css') ? 'style' : "script",
|
|
16
|
+
type: 'routeAsset',
|
|
17
|
+
url: asset
|
|
16
18
|
});
|
|
17
|
-
};
|
|
18
|
-
const isAsyncEntryScriptChunk = (chunk, entryName)=>{
|
|
19
|
-
if (!chunk.url?.endsWith('.js')) return false;
|
|
20
|
-
const asyncEntryName = `async-${entryName}`;
|
|
21
|
-
const filename = chunk.filename || chunk.url;
|
|
22
|
-
const basename = filename.split('/').pop() || filename;
|
|
23
|
-
return basename === `${asyncEntryName}.js` || basename.startsWith(`${asyncEntryName}.`) || basename.startsWith(`${asyncEntryName}-`);
|
|
24
|
-
};
|
|
25
|
-
const orderHydrationScriptChunks = ({ asyncEntryChunks, collectedChunks, matchedRouteChunks, entryName })=>{
|
|
26
|
-
const asyncEntryScriptChunks = [];
|
|
27
|
-
const asyncEntryDependencyChunks = [];
|
|
28
|
-
for (const chunk of asyncEntryChunks)if (isAsyncEntryScriptChunk(chunk, entryName)) asyncEntryScriptChunks.push(chunk);
|
|
29
|
-
else asyncEntryDependencyChunks.push(chunk);
|
|
30
|
-
return dedupeChunksByUrl([
|
|
31
|
-
...asyncEntryDependencyChunks,
|
|
32
|
-
...collectedChunks,
|
|
33
|
-
...matchedRouteChunks,
|
|
34
|
-
...asyncEntryScriptChunks
|
|
35
|
-
]);
|
|
36
|
-
};
|
|
37
19
|
const checkIsInline = (chunk, enableInline)=>{
|
|
38
20
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
39
21
|
if (enableInline instanceof RegExp) return enableInline.test(chunk.url);
|
|
@@ -52,17 +34,8 @@ class LoadableCollector {
|
|
|
52
34
|
}
|
|
53
35
|
getMatchedRouteChunks() {
|
|
54
36
|
const { routeManifest, runtimeContext } = this.options;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const matchedRouteIds = getRouterMatchedRouteIds(runtimeContext) ?? [];
|
|
58
|
-
return matchedRouteIds.flatMap((routeId)=>{
|
|
59
|
-
const routeAsset = routeAssets[routeId];
|
|
60
|
-
return (routeAsset?.assets ?? []).map((asset)=>({
|
|
61
|
-
filename: asset.replace(/^\//, ''),
|
|
62
|
-
path: asset,
|
|
63
|
-
url: asset
|
|
64
|
-
}));
|
|
65
|
-
});
|
|
37
|
+
if (!routeManifest) return [];
|
|
38
|
+
return getMatchedRouteAssets(runtimeContext, routeManifest).map(routeAssetToChunk);
|
|
66
39
|
}
|
|
67
40
|
collect(comopnent) {
|
|
68
41
|
const { stats, entryName } = this.options;
|
|
@@ -136,11 +109,7 @@ class LoadableCollector {
|
|
|
136
109
|
const { template, chunkSet, config, moduleFederationCssAssets } = this.options;
|
|
137
110
|
const { inlineStyles } = config;
|
|
138
111
|
const atrributes = attributesToString(this.generateAttributes());
|
|
139
|
-
const
|
|
140
|
-
const matchs = template.matchAll(linkRegExp);
|
|
141
|
-
const existedLinks = [];
|
|
142
|
-
for (const match of matchs)existedLinks.push(match[1]);
|
|
143
|
-
const emittedChunks = chunks.filter((chunk)=>!existedLinks.includes(chunk.url) && !this.existsAssets?.includes(chunk.path));
|
|
112
|
+
const emittedChunks = chunks.filter((chunk)=>!hasStylesheetLink(template, chunk.url) && !this.existsAssets?.includes(chunk.path));
|
|
144
113
|
const css = await Promise.all(emittedChunks.map(async (chunk)=>{
|
|
145
114
|
const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
|
|
146
115
|
if (checkIsNode() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<style>${content}</style>`).catch((_)=>link);
|
|
@@ -150,10 +119,7 @@ class LoadableCollector {
|
|
|
150
119
|
chunkSet.cssChunk += createFederatedCssLinks(moduleFederationCssAssets, {
|
|
151
120
|
template,
|
|
152
121
|
attributes: this.generateAttributes(),
|
|
153
|
-
existingAssets:
|
|
154
|
-
...existedLinks,
|
|
155
|
-
...emittedChunks.map((chunk)=>chunk.url)
|
|
156
|
-
]
|
|
122
|
+
existingAssets: emittedChunks.map((chunk)=>chunk.url)
|
|
157
123
|
});
|
|
158
124
|
}
|
|
159
125
|
generateAttributes(extraAtr = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
2
|
-
import { getRouterHydrationScripts } from "../../../router/runtime/lifecycle.mjs";
|
|
2
|
+
import { getRouterHydrationScripts, getRouterServerSnapshot } from "../../../router/runtime/lifecycle.mjs";
|
|
3
3
|
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "../../constants.mjs";
|
|
4
4
|
import { attributesToString, serializeErrors } from "../utils.mjs";
|
|
5
5
|
function _check_private_redeclaration(obj, privateCollection) {
|
|
@@ -89,7 +89,7 @@ function getSSRData() {
|
|
|
89
89
|
}
|
|
90
90
|
function getRouterData() {
|
|
91
91
|
const { routerContext, runtimeContext } = _class_private_field_get(this, _options);
|
|
92
|
-
const snapshotRouterData = runtimeContext
|
|
92
|
+
const snapshotRouterData = getRouterServerSnapshot(runtimeContext)?.routerData;
|
|
93
93
|
if (snapshotRouterData) return {
|
|
94
94
|
loaderData: snapshotRouterData.loaderData,
|
|
95
95
|
errors: serializeErrors(snapshotRouterData.errors || null)
|
|
@@ -12,17 +12,40 @@ function serializeErrors(errors) {
|
|
|
12
12
|
if (!errors) return null;
|
|
13
13
|
const entries = Object.entries(errors);
|
|
14
14
|
const serialized = {};
|
|
15
|
-
for (const [key, val] of entries)if (isRouteErrorResponse(val)) serialized[key] =
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
for (const [key, val] of entries)if (isRouteErrorResponse(val)) serialized[key] = serializeRouteErrorResponse(val);
|
|
16
|
+
else if (val instanceof Error) serialized[key] = serializeError(val);
|
|
17
|
+
else serialized[key] = val;
|
|
18
|
+
return serialized;
|
|
19
|
+
}
|
|
20
|
+
function shouldRedactServerError() {
|
|
21
|
+
return 'development' !== process.env.NODE_ENV && 'test' !== process.env.NODE_ENV;
|
|
22
|
+
}
|
|
23
|
+
function serializeError(error) {
|
|
24
|
+
if (shouldRedactServerError()) return {
|
|
25
|
+
message: 'Unexpected Server Error',
|
|
26
|
+
stack: void 0,
|
|
27
|
+
__type: 'Error'
|
|
18
28
|
};
|
|
19
|
-
|
|
20
|
-
message:
|
|
21
|
-
stack:
|
|
29
|
+
return {
|
|
30
|
+
message: error.message,
|
|
31
|
+
stack: error.stack,
|
|
22
32
|
__type: 'Error'
|
|
23
33
|
};
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
}
|
|
35
|
+
function serializeRouteErrorResponse(error) {
|
|
36
|
+
if (!isRouteErrorResponse(error)) return error;
|
|
37
|
+
if (error.status >= 500 && shouldRedactServerError()) return {
|
|
38
|
+
status: error.status,
|
|
39
|
+
statusText: 'Internal Server Error',
|
|
40
|
+
data: 'Unexpected Server Error',
|
|
41
|
+
__type: 'RouteErrorResponse'
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
status: error.status,
|
|
45
|
+
statusText: error.statusText,
|
|
46
|
+
data: error.data,
|
|
47
|
+
__type: 'RouteErrorResponse'
|
|
48
|
+
};
|
|
26
49
|
}
|
|
27
50
|
function getSSRConfigByEntry(entryName, ssr, ssrByEntries) {
|
|
28
51
|
if (ssrByEntries?.[entryName]) return ssrByEntries[entryName];
|
|
@@ -36,4 +59,24 @@ function getSSRMode(ssrConfig) {
|
|
|
36
59
|
const result = ssrConfig?.mode === 'string' ? 'string' : 'stream';
|
|
37
60
|
return result;
|
|
38
61
|
}
|
|
39
|
-
|
|
62
|
+
const getLinkAttributes = (linkTag)=>{
|
|
63
|
+
const attributes = new Map();
|
|
64
|
+
const attributeRegExp = /([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
|
|
65
|
+
let match;
|
|
66
|
+
while(match = attributeRegExp.exec(linkTag)){
|
|
67
|
+
const [, name, doubleQuotedValue, singleQuotedValue, unquotedValue] = match;
|
|
68
|
+
if ('link' === name.toLowerCase()) continue;
|
|
69
|
+
attributes.set(name.toLowerCase(), doubleQuotedValue ?? singleQuotedValue ?? unquotedValue ?? '');
|
|
70
|
+
}
|
|
71
|
+
return attributes;
|
|
72
|
+
};
|
|
73
|
+
const hasStylesheetLink = (template, href)=>{
|
|
74
|
+
const linkTags = template.match(/<link\b[^>]*>/gi) ?? [];
|
|
75
|
+
return linkTags.some((linkTag)=>{
|
|
76
|
+
const attributes = getLinkAttributes(linkTag);
|
|
77
|
+
const linkHref = attributes.get('href');
|
|
78
|
+
const rel = attributes.get('rel');
|
|
79
|
+
return linkHref === href && rel?.split(/\s+/).some((relToken)=>'stylesheet' === relToken.toLowerCase());
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
export { attributesToString, checkIsNode, getSSRConfigByEntry, getSSRMode, hasStylesheetLink, safeReplace, serializeErrors };
|
|
@@ -295,12 +295,13 @@ const documentPlugin = ()=>({
|
|
|
295
295
|
processedHtml = processCommentPlaceholders(processedHtml);
|
|
296
296
|
return `<!DOCTYPE html>${processedHtml}`.replace(DOCUMENT_META_PLACEHOLDER, ()=>metas).replace(DOCUMENT_SSR_PLACEHOLDER, ()=>HTML_SEPARATOR).replace(DOCUMENT_SCRIPTS_PLACEHOLDER, ()=>scripts).replace(DOCUMENT_LINKS_PLACEHOLDER, ()=>links).replace(DOCUMENT_CHUNKSMAP_PLACEHOLDER, ()=>PLACEHOLDER_REPLACER_MAP[DOCUMENT_CHUNKSMAP_PLACEHOLDER]).replace(DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, ()=>PLACEHOLDER_REPLACER_MAP[DOCUMENT_SSRDATASCRIPT_PLACEHOLDER]).replace(DOCUMENT_TITLE_PLACEHOLDER, ()=>titles);
|
|
297
297
|
};
|
|
298
|
-
const documentEntry = (entryName
|
|
298
|
+
const documentEntry = (entryName)=>{
|
|
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
|
+
const { compilation: _compilation, htmlPlugin, rspackConfig: _rspackConfig, ...templateParameters } = templateData;
|
|
304
305
|
const documentParams = getDocParams({
|
|
305
306
|
config: config,
|
|
306
307
|
entryName,
|
|
@@ -318,6 +319,7 @@ const documentPlugin = ()=>({
|
|
|
318
319
|
debug("entry %s's document jsx rendered html: %o", entryName, html);
|
|
319
320
|
const { partialsByEntrypoint } = api.getAppContext();
|
|
320
321
|
html = processPartials(html, entryName, partialsByEntrypoint || {});
|
|
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
|
};
|
|
@@ -328,10 +330,7 @@ const documentPlugin = ()=>({
|
|
|
328
330
|
return {
|
|
329
331
|
tools: {
|
|
330
332
|
htmlPlugin: (options, entry)=>{
|
|
331
|
-
const
|
|
332
|
-
...options?.templateParameters
|
|
333
|
-
};
|
|
334
|
-
const templateContent = documentEntry(entry.entryName, hackParameters);
|
|
333
|
+
const templateContent = documentEntry(entry.entryName);
|
|
335
334
|
const documentHtmlOptions = templateContent ? {
|
|
336
335
|
templateContent,
|
|
337
336
|
inject: false
|
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
import react from "react";
|
|
3
3
|
import { Helmet, HelmetData, HelmetProvider } from "react-helmet-async";
|
|
4
4
|
import { InternalRuntimeContext } from "../core/context/index.mjs";
|
|
5
|
+
import { ensureHelmetContext } from "../core/context/helmetContext.mjs";
|
|
5
6
|
const ATTRIBUTE_NAME_MAP = {
|
|
6
7
|
charSet: 'charset',
|
|
7
8
|
className: 'class',
|
|
8
9
|
contentEditable: 'contenteditable',
|
|
9
10
|
httpEquiv: 'http-equiv',
|
|
11
|
+
hrefLang: 'hreflang',
|
|
10
12
|
itemProp: 'itemprop',
|
|
11
13
|
tabIndex: 'tabindex'
|
|
12
14
|
};
|
|
15
|
+
const CONTENT_PROPERTIES = new Set([
|
|
16
|
+
'innerHTML',
|
|
17
|
+
'cssText'
|
|
18
|
+
]);
|
|
13
19
|
const escapeHtml = (value)=>String(value).replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>');
|
|
14
20
|
const toHtmlAttributeName = (name)=>ATTRIBUTE_NAME_MAP[name] ?? name;
|
|
15
21
|
const attributesToString = (attributes, includeHelmetAttribute = false)=>{
|
|
@@ -17,6 +23,7 @@ const attributesToString = (attributes, includeHelmetAttribute = false)=>{
|
|
|
17
23
|
if (includeHelmetAttribute) pairs.push('data-rh="true"');
|
|
18
24
|
for (const [name, value] of Object.entries(attributes ?? {})){
|
|
19
25
|
if (false === value || null == value) continue;
|
|
26
|
+
if (CONTENT_PROPERTIES.has(name)) continue;
|
|
20
27
|
const htmlName = toHtmlAttributeName(name);
|
|
21
28
|
if (true === value) pairs.push(htmlName);
|
|
22
29
|
else pairs.push(`${htmlName}="${escapeHtml(value)}"`);
|
|
@@ -40,23 +47,15 @@ const createAttributeDatum = (attributes)=>({
|
|
|
40
47
|
const createTitleDatum = (title, attributes)=>({
|
|
41
48
|
toComponent: ()=>[],
|
|
42
49
|
toString: ()=>{
|
|
43
|
-
if (
|
|
50
|
+
if (void 0 === title || '' === title) return '';
|
|
44
51
|
const attrs = attributesToString(attributes, true);
|
|
45
52
|
return `<title ${attrs}>${escapeHtml(title)}</title>`;
|
|
46
53
|
}
|
|
47
54
|
});
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
link: createDatum('link', []),
|
|
53
|
-
meta: createDatum('meta', []),
|
|
54
|
-
noscript: createDatum("noscript", []),
|
|
55
|
-
priority: createDatum('meta', []),
|
|
56
|
-
script: createDatum("script", []),
|
|
57
|
-
style: createDatum('style', []),
|
|
58
|
-
title: createTitleDatum(void 0, {})
|
|
59
|
-
});
|
|
55
|
+
const normalizeHelmetTitle = (title)=>{
|
|
56
|
+
if ('string' == typeof title) return title;
|
|
57
|
+
if (Array.isArray(title)) return title.map((part)=>String(part)).join('');
|
|
58
|
+
};
|
|
60
59
|
const mergeAttributes = (current, next)=>({
|
|
61
60
|
...current,
|
|
62
61
|
...next ?? {}
|
|
@@ -72,7 +71,14 @@ const collectChildren = (children, draft)=>{
|
|
|
72
71
|
draft.titleAttributes = mergeAttributes(draft.titleAttributes, props);
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
75
|
-
if ('html' === child.type
|
|
74
|
+
if ('html' === child.type) {
|
|
75
|
+
draft.htmlAttributes = mergeAttributes(draft.htmlAttributes ?? {}, props);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if ('body' === child.type) {
|
|
79
|
+
draft.bodyAttributes = mergeAttributes(draft.bodyAttributes ?? {}, props);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
76
82
|
if ('base' === child.type || 'link' === child.type || 'meta' === child.type || "noscript" === child.type || "script" === child.type || 'style' === child.type) {
|
|
77
83
|
const tag = {
|
|
78
84
|
...props
|
|
@@ -82,11 +88,10 @@ const collectChildren = (children, draft)=>{
|
|
|
82
88
|
}
|
|
83
89
|
});
|
|
84
90
|
};
|
|
85
|
-
const
|
|
86
|
-
const baseState = current ?? createEmptyHelmetState();
|
|
91
|
+
const createHelmetRecord = (props)=>{
|
|
87
92
|
const draft = {
|
|
88
93
|
base: [
|
|
89
|
-
...props.base ? [
|
|
94
|
+
...void 0 !== props.base ? [
|
|
90
95
|
props.base
|
|
91
96
|
] : []
|
|
92
97
|
],
|
|
@@ -107,75 +112,136 @@ const collectHelmetProps = (current, props)=>{
|
|
|
107
112
|
style: [
|
|
108
113
|
...props.style ?? []
|
|
109
114
|
],
|
|
110
|
-
title:
|
|
115
|
+
title: normalizeHelmetTitle(props.title),
|
|
111
116
|
titleAttributes: props.titleAttributes ?? {}
|
|
112
117
|
};
|
|
113
118
|
collectChildren(props.children, draft);
|
|
114
|
-
const title = draft.title && props.titleTemplate ? props.titleTemplate.replaceAll('%s', draft.title) : draft.title ?? props.defaultTitle;
|
|
115
119
|
return {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
]),
|
|
120
|
-
bodyAttributes: createAttributeDatum(mergeAttributes(baseState.__bodyAttributes ?? {}, draft.bodyAttributes)),
|
|
121
|
-
htmlAttributes: createAttributeDatum(mergeAttributes(baseState.__htmlAttributes ?? {}, draft.htmlAttributes)),
|
|
122
|
-
link: createDatum('link', [
|
|
123
|
-
...baseState.__linkTags ?? [],
|
|
124
|
-
...draft.link
|
|
125
|
-
]),
|
|
126
|
-
meta: createDatum('meta', [
|
|
127
|
-
...baseState.__metaTags ?? [],
|
|
128
|
-
...draft.meta
|
|
129
|
-
]),
|
|
130
|
-
noscript: createDatum("noscript", [
|
|
131
|
-
...baseState.__noscriptTags ?? [],
|
|
132
|
-
...draft.noscript
|
|
133
|
-
]),
|
|
134
|
-
priority: createDatum('meta', []),
|
|
135
|
-
script: createDatum("script", [
|
|
136
|
-
...baseState.__scriptTags ?? [],
|
|
137
|
-
...draft.script
|
|
138
|
-
]),
|
|
139
|
-
style: createDatum('style', [
|
|
140
|
-
...baseState.__styleTags ?? [],
|
|
141
|
-
...draft.style
|
|
142
|
-
]),
|
|
143
|
-
title: createTitleDatum(title ?? baseState.__title, mergeAttributes(baseState.__titleAttributes ?? {}, draft.titleAttributes)),
|
|
144
|
-
__baseTags: [
|
|
145
|
-
...baseState.__baseTags ?? [],
|
|
146
|
-
...draft.base
|
|
147
|
-
],
|
|
148
|
-
__bodyAttributes: mergeAttributes(baseState.__bodyAttributes ?? {}, draft.bodyAttributes),
|
|
149
|
-
__htmlAttributes: mergeAttributes(baseState.__htmlAttributes ?? {}, draft.htmlAttributes),
|
|
150
|
-
__linkTags: [
|
|
151
|
-
...baseState.__linkTags ?? [],
|
|
152
|
-
...draft.link
|
|
153
|
-
],
|
|
154
|
-
__metaTags: [
|
|
155
|
-
...baseState.__metaTags ?? [],
|
|
156
|
-
...draft.meta
|
|
157
|
-
],
|
|
158
|
-
__noscriptTags: [
|
|
159
|
-
...baseState.__noscriptTags ?? [],
|
|
160
|
-
...draft.noscript
|
|
161
|
-
],
|
|
162
|
-
__scriptTags: [
|
|
163
|
-
...baseState.__scriptTags ?? [],
|
|
164
|
-
...draft.script
|
|
165
|
-
],
|
|
166
|
-
__styleTags: [
|
|
167
|
-
...baseState.__styleTags ?? [],
|
|
168
|
-
...draft.style
|
|
169
|
-
],
|
|
170
|
-
__title: title ?? baseState.__title,
|
|
171
|
-
__titleAttributes: mergeAttributes(baseState.__titleAttributes ?? {}, draft.titleAttributes)
|
|
120
|
+
...draft,
|
|
121
|
+
titleTemplate: props.titleTemplate,
|
|
122
|
+
defaultTitle: props.defaultTitle
|
|
172
123
|
};
|
|
173
124
|
};
|
|
125
|
+
const getInnermostDefined = (records, pick)=>{
|
|
126
|
+
for(let i = records.length - 1; i >= 0; i -= 1){
|
|
127
|
+
const value = pick(records[i]);
|
|
128
|
+
if (void 0 !== value) return value;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const deriveTitle = (records)=>{
|
|
132
|
+
const innermostTitle = getInnermostDefined(records, (record)=>record.title);
|
|
133
|
+
const innermostTemplate = getInnermostDefined(records, (record)=>record.titleTemplate);
|
|
134
|
+
if (innermostTemplate && innermostTitle) return innermostTemplate.replaceAll('%s', innermostTitle);
|
|
135
|
+
return innermostTitle || getInnermostDefined(records, (record)=>record.defaultTitle);
|
|
136
|
+
};
|
|
137
|
+
const mergeRecordAttributes = (records, pick)=>records.reduce((merged, record)=>mergeAttributes(merged, pick(record)), {});
|
|
138
|
+
const deriveBaseTags = (records)=>{
|
|
139
|
+
for(let i = records.length - 1; i >= 0; i -= 1){
|
|
140
|
+
const tags = records[i].base;
|
|
141
|
+
for(let j = tags.length - 1; j >= 0; j -= 1)if (tags[j].href) return [
|
|
142
|
+
tags[j]
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
return [];
|
|
146
|
+
};
|
|
147
|
+
const TAG_PRIMARY_ATTRIBUTES = {
|
|
148
|
+
link: [
|
|
149
|
+
'rel',
|
|
150
|
+
'href'
|
|
151
|
+
],
|
|
152
|
+
meta: [
|
|
153
|
+
'name',
|
|
154
|
+
'charset',
|
|
155
|
+
'http-equiv',
|
|
156
|
+
'property',
|
|
157
|
+
'itemprop'
|
|
158
|
+
],
|
|
159
|
+
noscript: [
|
|
160
|
+
'innerHTML'
|
|
161
|
+
],
|
|
162
|
+
script: [
|
|
163
|
+
'src',
|
|
164
|
+
'innerHTML'
|
|
165
|
+
],
|
|
166
|
+
style: [
|
|
167
|
+
'cssText'
|
|
168
|
+
]
|
|
169
|
+
};
|
|
170
|
+
const getPrimaryAttribute = (tagName, tag)=>{
|
|
171
|
+
const candidates = TAG_PRIMARY_ATTRIBUTES[tagName];
|
|
172
|
+
let selectedKey;
|
|
173
|
+
let selectedValue;
|
|
174
|
+
for (const [key, value] of Object.entries(tag)){
|
|
175
|
+
const normalizedKey = CONTENT_PROPERTIES.has(key) ? key : toHtmlAttributeName(key).toLowerCase();
|
|
176
|
+
if (candidates.includes(normalizedKey)) {
|
|
177
|
+
if ('rel' !== selectedKey || 'canonical' !== String(selectedValue).toLowerCase()) {
|
|
178
|
+
if ('rel' !== normalizedKey || 'stylesheet' !== String(value).toLowerCase()) {
|
|
179
|
+
selectedKey = normalizedKey;
|
|
180
|
+
selectedValue = value;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (void 0 === selectedKey || !selectedValue) return;
|
|
186
|
+
return {
|
|
187
|
+
key: selectedKey,
|
|
188
|
+
value: String(selectedValue).toLowerCase()
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
const dedupeTags = (tagName, records)=>{
|
|
192
|
+
const approvedValues = new Map();
|
|
193
|
+
const approved = [];
|
|
194
|
+
for(let i = records.length - 1; i >= 0; i -= 1){
|
|
195
|
+
const instanceValues = new Map();
|
|
196
|
+
const kept = [];
|
|
197
|
+
for (const tag of records[i][tagName]){
|
|
198
|
+
const primary = getPrimaryAttribute(tagName, tag);
|
|
199
|
+
if (void 0 === primary) continue;
|
|
200
|
+
if (approvedValues.get(primary.key)?.has(primary.value)) continue;
|
|
201
|
+
let seen = instanceValues.get(primary.key);
|
|
202
|
+
if (void 0 === seen) {
|
|
203
|
+
seen = new Set();
|
|
204
|
+
instanceValues.set(primary.key, seen);
|
|
205
|
+
}
|
|
206
|
+
seen.add(primary.value);
|
|
207
|
+
kept.push(tag);
|
|
208
|
+
}
|
|
209
|
+
approved.unshift(...kept);
|
|
210
|
+
for (const [key, values] of instanceValues){
|
|
211
|
+
const target = approvedValues.get(key);
|
|
212
|
+
if (void 0 === target) approvedValues.set(key, values);
|
|
213
|
+
else for (const value of values)target.add(value);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return approved;
|
|
217
|
+
};
|
|
218
|
+
const deriveHelmetServerState = (records)=>({
|
|
219
|
+
base: createDatum('base', deriveBaseTags(records)),
|
|
220
|
+
bodyAttributes: createAttributeDatum(mergeRecordAttributes(records, (record)=>record.bodyAttributes)),
|
|
221
|
+
htmlAttributes: createAttributeDatum(mergeRecordAttributes(records, (record)=>record.htmlAttributes)),
|
|
222
|
+
link: createDatum('link', dedupeTags('link', records)),
|
|
223
|
+
meta: createDatum('meta', dedupeTags('meta', records)),
|
|
224
|
+
noscript: createDatum("noscript", dedupeTags("noscript", records)),
|
|
225
|
+
priority: createDatum('meta', []),
|
|
226
|
+
script: createDatum("script", dedupeTags("script", records)),
|
|
227
|
+
style: createDatum('style', dedupeTags('style', records)),
|
|
228
|
+
title: createTitleDatum(deriveTitle(records), mergeRecordAttributes(records, (record)=>record.titleAttributes))
|
|
229
|
+
});
|
|
230
|
+
const serverHelmetRecords = new WeakMap();
|
|
231
|
+
const collectServerHelmet = (runtimeContext, props)=>{
|
|
232
|
+
const helmetContext = ensureHelmetContext(runtimeContext);
|
|
233
|
+
let records = serverHelmetRecords.get(helmetContext);
|
|
234
|
+
if (void 0 === records) {
|
|
235
|
+
records = [];
|
|
236
|
+
serverHelmetRecords.set(helmetContext, records);
|
|
237
|
+
}
|
|
238
|
+
records.push(createHelmetRecord(props));
|
|
239
|
+
helmetContext.helmet = deriveHelmetServerState(records);
|
|
240
|
+
};
|
|
174
241
|
const head_Helmet = (props)=>{
|
|
175
242
|
const runtimeContext = react.useContext(InternalRuntimeContext);
|
|
176
|
-
if (runtimeContext &&
|
|
177
|
-
runtimeContext
|
|
178
|
-
runtimeContext._helmetContext.helmet = collectHelmetProps(runtimeContext._helmetContext.helmet ?? void 0, props);
|
|
243
|
+
if (null !== runtimeContext && false === runtimeContext.isBrowser) {
|
|
244
|
+
collectServerHelmet(runtimeContext, props);
|
|
179
245
|
return null;
|
|
180
246
|
}
|
|
181
247
|
return react.createElement(Helmet, props);
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import * as __rspack_external__loadable_component_0aaae075 from "@loadable/component";
|
|
2
2
|
export * from "@loadable/component";
|
|
3
|
+
function asLoadableNamespace(value) {
|
|
4
|
+
return 'object' == typeof value && null !== value ? value : {};
|
|
5
|
+
}
|
|
3
6
|
function resolveLoadable(module) {
|
|
4
|
-
const namespace = module;
|
|
5
|
-
const defaultExport = namespace.default;
|
|
7
|
+
const namespace = asLoadableNamespace(module);
|
|
8
|
+
const defaultExport = asLoadableNamespace(namespace.default);
|
|
6
9
|
const candidates = [
|
|
7
10
|
module,
|
|
8
11
|
namespace.default,
|
|
9
12
|
defaultExport?.default
|
|
10
13
|
];
|
|
11
14
|
const loadable = candidates.find((candidate)=>'function' == typeof candidate);
|
|
12
|
-
if (
|
|
15
|
+
if ('function' != typeof loadable) throw new TypeError('Modern.js runtime loadable export must resolve to a function');
|
|
13
16
|
return loadable;
|
|
14
17
|
}
|
|
15
18
|
const loadable_loadable = resolveLoadable(__rspack_external__loadable_component_0aaae075);
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
+
const loadableNamespace = asLoadableNamespace(__rspack_external__loadable_component_0aaae075);
|
|
20
|
+
const loadableDefaultNamespace = asLoadableNamespace(loadableNamespace.default);
|
|
21
|
+
const callableLoadableNamespace = asLoadableNamespace(loadable_loadable);
|
|
22
|
+
const lazy = loadableNamespace.lazy ?? loadableDefaultNamespace.lazy ?? callableLoadableNamespace.lazy;
|
|
23
|
+
const loadableReady = loadableNamespace.loadableReady ?? loadableDefaultNamespace.loadableReady ?? callableLoadableNamespace.loadableReady;
|
|
24
|
+
const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = loadableNamespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ?? loadableDefaultNamespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ?? callableLoadableNamespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
19
25
|
const exports_loadable = loadable_loadable;
|
|
20
26
|
export default exports_loadable;
|
|
21
27
|
export { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, lazy, loadableReady };
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
const COMPAT_BINDINGS_SLOT = Symbol.for('@modern-js/plugin-tanstack:runtime-compat-bindings');
|
|
3
|
+
function readCompatBindings() {
|
|
4
|
+
return globalThis[COMPAT_BINDINGS_SLOT];
|
|
5
|
+
}
|
|
6
|
+
function resolveCompatBindings(exportName) {
|
|
7
|
+
const bindings = readCompatBindings();
|
|
8
|
+
if (void 0 === bindings) throw new Error(`[@modern-js/runtime] '${exportName}' from the deprecated '@modern-js/runtime/tanstack-router' alias is provided by @modern-js/plugin-tanstack. Install @modern-js/plugin-tanstack, add \`tanstackRouterPlugin()\` to the \`plugins\` array in modern.config.ts, and make sure '@modern-js/plugin-tanstack/runtime' is imported (e.g. in modern.runtime.ts) before '${exportName}' is used. Prefer importing '${exportName}' from '@modern-js/plugin-tanstack/runtime' directly.`);
|
|
9
|
+
return bindings;
|
|
10
|
+
}
|
|
11
|
+
const Link = (props)=>createElement(resolveCompatBindings('Link').Link, props);
|
|
12
|
+
const NavLink = (props)=>createElement(resolveCompatBindings('NavLink').NavLink, props);
|
|
13
|
+
const Outlet = ()=>createElement(resolveCompatBindings('Outlet').Outlet);
|
|
14
|
+
const Form = (props)=>createElement(resolveCompatBindings('Form').Form, props);
|
|
15
|
+
function useFetcher() {
|
|
16
|
+
return resolveCompatBindings('useFetcher').useFetcher();
|
|
17
|
+
}
|
|
18
|
+
function RouteActionResponseErrorPlaceholder() {}
|
|
19
|
+
const RouteActionResponseError = new Proxy(RouteActionResponseErrorPlaceholder, {
|
|
20
|
+
construct (_target, args) {
|
|
21
|
+
const RealError = resolveCompatBindings('RouteActionResponseError').RouteActionResponseError;
|
|
22
|
+
return new RealError(...args);
|
|
23
|
+
},
|
|
24
|
+
get (target, property, receiver) {
|
|
25
|
+
const RealError = readCompatBindings()?.RouteActionResponseError;
|
|
26
|
+
if (void 0 !== RealError) return Reflect.get(RealError, property);
|
|
27
|
+
return Reflect.get(target, property, receiver);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export { Form, Link, NavLink, Outlet, RouteActionResponseError, useFetcher };
|