sygnal 5.3.7 → 6.0.0
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/CHANGELOG.md +646 -0
- package/README.md +77 -47
- package/dist/astro/client.cjs.js +33 -8114
- package/dist/astro/client.cjs.js.map +1 -0
- package/dist/astro/client.mjs +33 -8114
- package/dist/astro/client.mjs.map +1 -0
- package/dist/astro/index.cjs.js +1039 -9
- package/dist/astro/index.cjs.js.map +1 -0
- package/dist/astro/index.mjs +1038 -9
- package/dist/astro/index.mjs.map +1 -0
- package/dist/astro/server.cjs.js +3400 -166
- package/dist/astro/server.cjs.js.map +1 -0
- package/dist/astro/server.mjs +3400 -166
- package/dist/astro/server.mjs.map +1 -0
- package/dist/devtools.cjs.js +1431 -0
- package/dist/devtools.cjs.js.map +1 -0
- package/dist/devtools.esm.js +1419 -0
- package/dist/devtools.esm.js.map +1 -0
- package/dist/diagnostics.cjs.js +4033 -0
- package/dist/diagnostics.cjs.js.map +1 -0
- package/dist/diagnostics.esm.js +4003 -0
- package/dist/diagnostics.esm.js.map +1 -0
- package/dist/element.cjs.js +230 -0
- package/dist/element.cjs.js.map +1 -0
- package/dist/element.esm.js +228 -0
- package/dist/element.esm.js.map +1 -0
- package/dist/guide/accessibility.md +257 -0
- package/dist/guide/adapters.md +221 -0
- package/dist/guide/behaviors.md +312 -0
- package/dist/guide/browser-sources.md +203 -0
- package/dist/guide/drag-and-drop.md +342 -0
- package/dist/guide/element-commands.md +306 -0
- package/dist/guide/error-boundaries.md +169 -0
- package/dist/guide/forms-reference.md +381 -0
- package/dist/guide/forms.md +250 -0
- package/dist/guide/http.md +299 -0
- package/dist/guide/inputs.md +173 -0
- package/dist/guide/persistence.md +245 -0
- package/dist/guide/recipes/carousel.md +155 -0
- package/dist/guide/recipes/charts.md +177 -0
- package/dist/guide/recipes/code-editor.md +135 -0
- package/dist/guide/recipes/data-grid.md +155 -0
- package/dist/guide/recipes/data-table.md +196 -0
- package/dist/guide/recipes/i18n.md +222 -0
- package/dist/guide/recipes/icons.md +115 -0
- package/dist/guide/recipes/overview.md +33 -0
- package/dist/guide/recipes/rich-text.md +154 -0
- package/dist/guide/resources.md +471 -0
- package/dist/guide/ssr.md +255 -0
- package/dist/guide/timers.md +178 -0
- package/dist/guide/ui/accordion.md +93 -0
- package/dist/guide/ui/combobox.md +144 -0
- package/dist/guide/ui/dialog.md +124 -0
- package/dist/guide/ui/disclosure.md +60 -0
- package/dist/guide/ui/menu.md +125 -0
- package/dist/guide/ui/overview.md +166 -0
- package/dist/guide/ui/popover.md +101 -0
- package/dist/guide/ui/select.md +114 -0
- package/dist/guide/ui/tabs.md +161 -0
- package/dist/guide/ui/toaster.md +152 -0
- package/dist/guide/ui/tooltip.md +103 -0
- package/dist/guide/undo.md +178 -0
- package/dist/guide/virtual-collections.md +183 -0
- package/dist/guide/web-components.md +179 -0
- package/dist/guide/widgets.md +217 -0
- package/dist/index.cjs.js +15283 -6279
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +3739 -370
- package/dist/index.esm.js +15230 -6274
- package/dist/index.esm.js.map +1 -0
- package/dist/jsx-dev-runtime.cjs.js +27 -329
- package/dist/jsx-dev-runtime.cjs.js.map +1 -0
- package/dist/jsx-dev-runtime.esm.js +20 -322
- package/dist/jsx-dev-runtime.esm.js.map +1 -0
- package/dist/jsx-runtime.cjs.js +27 -329
- package/dist/jsx-runtime.cjs.js.map +1 -0
- package/dist/jsx-runtime.esm.js +20 -322
- package/dist/jsx-runtime.esm.js.map +1 -0
- package/dist/jsx.cjs.js +11 -309
- package/dist/jsx.cjs.js.map +1 -0
- package/dist/jsx.esm.js +9 -310
- package/dist/jsx.esm.js.map +1 -0
- package/dist/react.cjs.js +117 -0
- package/dist/react.cjs.js.map +1 -0
- package/dist/react.esm.js +115 -0
- package/dist/react.esm.js.map +1 -0
- package/dist/shims/globalthis.cjs +20 -0
- package/dist/sygnal.min.js +2 -1
- package/dist/sygnal.min.js.map +1 -0
- package/dist/ui-combobox.cjs.js +169 -0
- package/dist/ui-combobox.cjs.js.map +1 -0
- package/dist/ui-combobox.esm.js +148 -0
- package/dist/ui-combobox.esm.js.map +1 -0
- package/dist/ui-menu.cjs.js +87 -0
- package/dist/ui-menu.cjs.js.map +1 -0
- package/dist/ui-menu.esm.js +66 -0
- package/dist/ui-menu.esm.js.map +1 -0
- package/dist/ui-select.cjs.js +104 -0
- package/dist/ui-select.cjs.js.map +1 -0
- package/dist/ui-select.esm.js +83 -0
- package/dist/ui-select.esm.js.map +1 -0
- package/dist/ui.cjs.js +738 -0
- package/dist/ui.cjs.js.map +1 -0
- package/dist/ui.esm.js +727 -0
- package/dist/ui.esm.js.map +1 -0
- package/dist/vike/ClientOnly.cjs.js +5 -14
- package/dist/vike/ClientOnly.cjs.js.map +1 -0
- package/dist/vike/ClientOnly.mjs +5 -14
- package/dist/vike/ClientOnly.mjs.map +1 -0
- package/dist/vike/{+config.js → config/+config.js} +10 -1
- package/dist/vike/config/+config.js.map +1 -0
- package/dist/vike/config/package.json +6 -0
- package/dist/vike/onRenderClient.cjs.js +166 -95
- package/dist/vike/onRenderClient.cjs.js.map +1 -0
- package/dist/vike/onRenderClient.mjs +166 -95
- package/dist/vike/onRenderClient.mjs.map +1 -0
- package/dist/vike/onRenderHtml.cjs.js +60 -24
- package/dist/vike/onRenderHtml.cjs.js.map +1 -0
- package/dist/vike/onRenderHtml.mjs +61 -25
- package/dist/vike/onRenderHtml.mjs.map +1 -0
- package/dist/vite/plugin.cjs.js +926 -65
- package/dist/vite/plugin.cjs.js.map +1 -0
- package/dist/vite/plugin.mjs +925 -65
- package/dist/vite/plugin.mjs.map +1 -0
- package/dist/zag.cjs.js +408 -0
- package/dist/zag.cjs.js.map +1 -0
- package/dist/zag.esm.js +405 -0
- package/dist/zag.esm.js.map +1 -0
- package/llms.txt +313 -0
- package/package.json +109 -16
- package/src/astro/client.ts +40 -18
- package/src/astro/index.d.ts +48 -1
- package/src/astro/index.ts +106 -9
- package/src/astro/server.ts +11 -3
- package/src/collection.ts +6 -90
- package/src/core/actions.ts +134 -0
- package/src/core/cell.ts +202 -0
- package/src/core/debug.ts +23 -0
- package/src/core/define.ts +242 -0
- package/src/core/hooks.ts +314 -0
- package/src/core/hosts/collection.ts +325 -0
- package/src/core/hosts/switchable.ts +146 -0
- package/src/core/instance.ts +592 -0
- package/src/core/markers/clientonly.ts +13 -0
- package/src/core/markers/lazy.ts +40 -0
- package/src/core/markers/portal.ts +96 -0
- package/src/core/markers/suspense.ts +41 -0
- package/src/core/markers/transition.ts +70 -0
- package/src/core/registry.ts +25 -0
- package/src/core/runtime.ts +573 -0
- package/src/core/statics.ts +104 -0
- package/src/core/teardown.ts +60 -0
- package/src/core/view.ts +37 -0
- package/src/cycle/dom/DocumentDOMSource.ts +13 -8
- package/src/cycle/dom/ElementFinder.ts +7 -9
- package/src/cycle/dom/EventDelegator.ts +174 -223
- package/src/cycle/dom/IsolateModule.ts +65 -35
- package/src/cycle/dom/MainDOMSource.ts +13 -2
- package/src/cycle/dom/PriorityQueue.ts +4 -2
- package/src/cycle/dom/SymbolTree.ts +18 -47
- package/src/cycle/dom/classNameModule.ts +76 -0
- package/src/cycle/dom/controlledInputModule.ts +50 -0
- package/src/cycle/dom/enrichEventStream.ts +29 -45
- package/src/cycle/dom/fragment.ts +7 -0
- package/src/cycle/dom/isolate.ts +30 -27
- package/src/cycle/dom/makeDOMDriver.ts +115 -57
- package/src/cycle/dom/mockDOMSource.ts +83 -9
- package/src/cycle/dom/modules.ts +21 -4
- package/src/cycle/dom/propsModule.ts +65 -0
- package/src/cycle/dom/selectModule.ts +22 -17
- package/src/cycle/dom/snabbdom.ts +1 -6
- package/src/cycle/dom/thunk.ts +3 -0
- package/src/cycle/dom/utils.ts +98 -0
- package/src/cycle/dom/viewTransition.ts +43 -0
- package/src/cycle/state/StateSource.ts +20 -4
- package/src/cycle/state/objIsEqual.ts +50 -0
- package/src/cycle/state/types.ts +0 -10
- package/src/defineComponent.ts +34 -0
- package/src/devtools.d.ts +151 -0
- package/src/devtools.ts +34 -0
- package/src/element.d.ts +59 -0
- package/src/element.ts +235 -0
- package/src/extra/backoff.ts +9 -0
- package/src/extra/behaviors.ts +169 -0
- package/src/extra/browserSignals.ts +23 -0
- package/src/extra/browserSources.ts +326 -0
- package/src/extra/command.ts +3 -3
- package/src/extra/controls.ts +47 -0
- package/src/extra/copyAsTest.ts +286 -0
- package/src/extra/devtools.ts +109 -31
- package/src/extra/devtoolsActions.ts +379 -0
- package/src/extra/devtoolsHook.ts +9 -0
- package/src/extra/devtoolsNext.ts +83 -0
- package/src/extra/diagnostics/checks/actionLog.ts +108 -0
- package/src/extra/diagnostics/checks/behaviors.ts +49 -0
- package/src/extra/diagnostics/checks/browserSources.ts +96 -0
- package/src/extra/diagnostics/checks/collections.ts +67 -0
- package/src/extra/diagnostics/checks/controls.ts +148 -0
- package/src/extra/diagnostics/checks/dataset.ts +57 -0
- package/src/extra/diagnostics/checks/dom.ts +250 -0
- package/src/extra/diagnostics/checks/elementCommands.ts +175 -0
- package/src/extra/diagnostics/checks/events.ts +83 -0
- package/src/extra/diagnostics/checks/fetch.ts +135 -0
- package/src/extra/diagnostics/checks/forms.ts +163 -0
- package/src/extra/diagnostics/checks/index.ts +202 -0
- package/src/extra/diagnostics/checks/inspect.ts +427 -0
- package/src/extra/diagnostics/checks/next.ts +417 -0
- package/src/extra/diagnostics/checks/persist.ts +54 -0
- package/src/extra/diagnostics/checks/props.ts +56 -0
- package/src/extra/diagnostics/checks/public.d.ts +302 -0
- package/src/extra/diagnostics/checks/replies.ts +128 -0
- package/src/extra/diagnostics/checks/router.ts +100 -0
- package/src/extra/diagnostics/checks/rxjsHints.ts +88 -0
- package/src/extra/diagnostics/checks/shared.ts +203 -0
- package/src/extra/diagnostics/checks/shorthand.ts +115 -0
- package/src/extra/diagnostics/checks/sortable.ts +129 -0
- package/src/extra/diagnostics/checks/state.ts +148 -0
- package/src/extra/diagnostics/checks/statics.ts +48 -0
- package/src/extra/diagnostics/checks/strict.ts +55 -0
- package/src/extra/diagnostics/checks/timers.ts +80 -0
- package/src/extra/diagnostics/checks/viewTransitions.ts +47 -0
- package/src/extra/diagnostics/checks/virtual.ts +73 -0
- package/src/extra/diagnostics/checks/widgets.ts +109 -0
- package/src/extra/diagnostics/checks/wiring.ts +121 -0
- package/src/extra/diagnostics/codes.ts +477 -0
- package/src/extra/diagnostics/index.ts +353 -0
- package/src/extra/diagnostics/legacy.ts +76 -0
- package/src/extra/driverFactories.ts +172 -60
- package/src/extra/elementCommands.ts +53 -0
- package/src/extra/eventDriver.ts +4 -0
- package/src/extra/fetchDriver.ts +519 -0
- package/src/extra/flatten.ts +75 -0
- package/src/extra/focusWithin.ts +27 -0
- package/src/extra/form.ts +268 -0
- package/src/extra/formHelpers.ts +139 -0
- package/src/extra/head.ts +106 -0
- package/src/extra/hmr.ts +2 -3
- package/src/extra/owned.ts +24 -0
- package/src/extra/pager.ts +50 -0
- package/src/extra/persist.ts +133 -0
- package/src/extra/pwa.ts +1 -1
- package/src/extra/queryCache.ts +107 -0
- package/src/extra/reducers.ts +13 -6
- package/src/extra/reduxDevtools.ts +92 -0
- package/src/extra/replies.ts +54 -0
- package/src/extra/router.ts +323 -0
- package/src/extra/run.ts +94 -210
- package/src/extra/selection.ts +76 -0
- package/src/extra/socketDriver.ts +265 -0
- package/src/extra/sortable.ts +377 -0
- package/src/extra/ssr.ts +427 -160
- package/src/extra/standardSchema.ts +27 -0
- package/src/extra/testing.ts +3158 -190
- package/src/extra/timers.ts +95 -0
- package/src/extra/undo.ts +261 -0
- package/src/extra/viewTransitions.ts +38 -0
- package/src/extra/virtual.ts +513 -0
- package/src/extra/widget.ts +201 -0
- package/src/extra/xstreamExtras.ts +269 -0
- package/src/index.d.ts +3012 -87
- package/src/index.ts +32 -10
- package/src/jsx-runtime.ts +15 -1
- package/src/jsx.ts +2 -1
- package/src/lazy.ts +50 -7
- package/src/portal.ts +3 -1
- package/src/pragma/index.ts +262 -134
- package/src/react-peers.d.ts +5 -0
- package/src/react.d.ts +43 -0
- package/src/react.ts +110 -0
- package/src/shared.ts +48 -0
- package/src/slot.ts +1 -1
- package/src/suspense.ts +3 -1
- package/src/switchable.ts +6 -119
- package/src/transition.ts +3 -1
- package/src/ui/accordion.ts +64 -0
- package/src/ui/dialog.ts +129 -0
- package/src/ui/disclosure.ts +35 -0
- package/src/ui/popover.ts +45 -0
- package/src/ui/shared.ts +94 -0
- package/src/ui/tabs.ts +82 -0
- package/src/ui/toaster.ts +198 -0
- package/src/ui/tooltip.ts +70 -0
- package/src/ui/zag/combobox.ts +115 -0
- package/src/ui/zag/menu.ts +40 -0
- package/src/ui/zag/select.ts +54 -0
- package/src/ui/zag/shared.ts +43 -0
- package/src/ui-combobox.d.ts +20 -0
- package/src/ui-combobox.ts +6 -0
- package/src/ui-menu.d.ts +30 -0
- package/src/ui-menu.ts +6 -0
- package/src/ui-select.d.ts +17 -0
- package/src/ui-select.ts +6 -0
- package/src/ui-zag-types.d.ts +42 -0
- package/src/ui.d.ts +208 -0
- package/src/ui.ts +15 -0
- package/src/vike/+config.ts +9 -1
- package/src/vike/ClientOnly.ts +1 -1
- package/src/vike/onRenderClient.ts +144 -96
- package/src/vike/onRenderHtml.ts +69 -26
- package/src/vike/types.ts +27 -4
- package/src/vite/globalthis-shim.ts +18 -0
- package/src/vite/globalthis.ts +56 -0
- package/src/vite/plugin.d.ts +114 -2
- package/src/vite/plugin.ts +920 -56
- package/src/zag.d.ts +64 -0
- package/src/zag.ts +238 -0
- package/dist/astro/astro/client.d.ts +0 -5
- package/dist/astro/astro/index.d.ts +0 -16
- package/dist/astro/astro/server.d.ts +0 -12
- package/dist/astro/client.d.ts +0 -5
- package/dist/astro/client.esm.js +0 -4665
- package/dist/astro/collection.d.ts +0 -12
- package/dist/astro/component.d.ts +0 -22
- package/dist/astro/cycle/dom/BodyDOMSource.d.ts +0 -10
- package/dist/astro/cycle/dom/DOMSource.d.ts +0 -11
- package/dist/astro/cycle/dom/DocumentDOMSource.d.ts +0 -12
- package/dist/astro/cycle/dom/ElementFinder.d.ts +0 -8
- package/dist/astro/cycle/dom/EventDelegator.d.ts +0 -34
- package/dist/astro/cycle/dom/IsolateModule.d.ts +0 -23
- package/dist/astro/cycle/dom/MainDOMSource.d.ts +0 -32
- package/dist/astro/cycle/dom/PriorityQueue.d.ts +0 -7
- package/dist/astro/cycle/dom/ScopeChecker.d.ts +0 -9
- package/dist/astro/cycle/dom/SymbolTree.d.ts +0 -9
- package/dist/astro/cycle/dom/VNodeWrapper.d.ts +0 -8
- package/dist/astro/cycle/dom/enrichEventStream.d.ts +0 -24
- package/dist/astro/cycle/dom/fromEvent.d.ts +0 -6
- package/dist/astro/cycle/dom/index.d.ts +0 -8
- package/dist/astro/cycle/dom/isolate.d.ts +0 -9
- package/dist/astro/cycle/dom/makeDOMDriver.d.ts +0 -11
- package/dist/astro/cycle/dom/mockDOMSource.d.ts +0 -17
- package/dist/astro/cycle/dom/modules.d.ts +0 -5
- package/dist/astro/cycle/dom/snabbdom.d.ts +0 -22
- package/dist/astro/cycle/dom/styleModule.d.ts +0 -13
- package/dist/astro/cycle/dom/thunk.d.ts +0 -11
- package/dist/astro/cycle/dom/utils.d.ts +0 -8
- package/dist/astro/cycle/isolate/index.d.ts +0 -42
- package/dist/astro/cycle/run/adapt.d.ts +0 -6
- package/dist/astro/cycle/run/index.d.ts +0 -36
- package/dist/astro/cycle/run/internals.d.ts +0 -8
- package/dist/astro/cycle/run/types.d.ts +0 -49
- package/dist/astro/cycle/state/Collection.d.ts +0 -29
- package/dist/astro/cycle/state/StateSource.d.ts +0 -20
- package/dist/astro/cycle/state/index.d.ts +0 -5
- package/dist/astro/cycle/state/pickCombine.d.ts +0 -3
- package/dist/astro/cycle/state/pickMerge.d.ts +0 -3
- package/dist/astro/cycle/state/types.d.ts +0 -18
- package/dist/astro/cycle/state/withState.d.ts +0 -17
- package/dist/astro/extra/classes.d.ts +0 -7
- package/dist/astro/extra/devtools.d.ts +0 -78
- package/dist/astro/extra/dragDriver.d.ts +0 -20
- package/dist/astro/extra/driverFactories.d.ts +0 -12
- package/dist/astro/extra/eventDriver.d.ts +0 -9
- package/dist/astro/extra/exactState.d.ts +0 -1
- package/dist/astro/extra/hmr.d.ts +0 -17
- package/dist/astro/extra/logDriver.d.ts +0 -2
- package/dist/astro/extra/processDrag.d.ts +0 -19
- package/dist/astro/extra/processForm.d.ts +0 -15
- package/dist/astro/extra/run.d.ts +0 -13
- package/dist/astro/extra/xstreamCompat.d.ts +0 -5
- package/dist/astro/index.d.ts +0 -19
- package/dist/astro/index.esm.js +0 -27
- package/dist/astro/jsx-dev-runtime.d.ts +0 -1
- package/dist/astro/jsx-runtime.d.ts +0 -4
- package/dist/astro/jsx.d.ts +0 -2
- package/dist/astro/pragma/fn.d.ts +0 -7
- package/dist/astro/pragma/index.d.ts +0 -7
- package/dist/astro/pragma/is.d.ts +0 -10
- package/dist/astro/server.d.ts +0 -12
- package/dist/astro/server.esm.js +0 -25
- package/dist/astro/switchable.d.ts +0 -7
- package/dist/collection.d.ts +0 -12
- package/dist/component.d.ts +0 -22
- package/dist/cycle/dom/BodyDOMSource.d.ts +0 -10
- package/dist/cycle/dom/DOMSource.d.ts +0 -11
- package/dist/cycle/dom/DocumentDOMSource.d.ts +0 -12
- package/dist/cycle/dom/ElementFinder.d.ts +0 -8
- package/dist/cycle/dom/EventDelegator.d.ts +0 -34
- package/dist/cycle/dom/IsolateModule.d.ts +0 -23
- package/dist/cycle/dom/MainDOMSource.d.ts +0 -32
- package/dist/cycle/dom/PriorityQueue.d.ts +0 -7
- package/dist/cycle/dom/ScopeChecker.d.ts +0 -9
- package/dist/cycle/dom/SymbolTree.d.ts +0 -9
- package/dist/cycle/dom/VNodeWrapper.d.ts +0 -8
- package/dist/cycle/dom/enrichEventStream.d.ts +0 -24
- package/dist/cycle/dom/fromEvent.d.ts +0 -6
- package/dist/cycle/dom/index.d.ts +0 -8
- package/dist/cycle/dom/isolate.d.ts +0 -9
- package/dist/cycle/dom/makeDOMDriver.d.ts +0 -11
- package/dist/cycle/dom/mockDOMSource.d.ts +0 -17
- package/dist/cycle/dom/modules.d.ts +0 -5
- package/dist/cycle/dom/snabbdom.d.ts +0 -22
- package/dist/cycle/dom/styleModule.d.ts +0 -13
- package/dist/cycle/dom/thunk.d.ts +0 -11
- package/dist/cycle/dom/utils.d.ts +0 -8
- package/dist/cycle/isolate/index.d.ts +0 -42
- package/dist/cycle/run/adapt.d.ts +0 -6
- package/dist/cycle/run/index.d.ts +0 -36
- package/dist/cycle/run/internals.d.ts +0 -8
- package/dist/cycle/run/types.d.ts +0 -49
- package/dist/cycle/state/Collection.d.ts +0 -29
- package/dist/cycle/state/StateSource.d.ts +0 -20
- package/dist/cycle/state/index.d.ts +0 -5
- package/dist/cycle/state/pickCombine.d.ts +0 -3
- package/dist/cycle/state/pickMerge.d.ts +0 -3
- package/dist/cycle/state/types.d.ts +0 -18
- package/dist/cycle/state/withState.d.ts +0 -17
- package/dist/extra/classes.d.ts +0 -7
- package/dist/extra/devtools.d.ts +0 -78
- package/dist/extra/dragDriver.d.ts +0 -20
- package/dist/extra/driverFactories.d.ts +0 -12
- package/dist/extra/eventDriver.d.ts +0 -9
- package/dist/extra/exactState.d.ts +0 -1
- package/dist/extra/hmr.d.ts +0 -17
- package/dist/extra/logDriver.d.ts +0 -2
- package/dist/extra/processDrag.d.ts +0 -19
- package/dist/extra/processForm.d.ts +0 -15
- package/dist/extra/run.d.ts +0 -13
- package/dist/extra/xstreamCompat.d.ts +0 -5
- package/dist/jsx-dev-runtime.d.ts +0 -1
- package/dist/jsx-dev-runtime.js +0 -224
- package/dist/jsx-runtime.d.ts +0 -4
- package/dist/jsx-runtime.js +0 -224
- package/dist/jsx.d.ts +0 -2
- package/dist/pragma/fn.d.ts +0 -7
- package/dist/pragma/index.d.ts +0 -7
- package/dist/pragma/is.d.ts +0 -10
- package/dist/switchable.d.ts +0 -7
- package/dist/vike/+config.cjs.js +0 -65
- package/src/component.ts +0 -2256
- package/src/cycle/isolate/index.ts +0 -196
- package/src/cycle/run/index.ts +0 -151
- package/src/cycle/run/internals.ts +0 -143
- package/src/cycle/state/Collection.ts +0 -174
- package/src/cycle/state/index.ts +0 -5
- package/src/cycle/state/pickCombine.ts +0 -167
- package/src/cycle/state/pickMerge.ts +0 -122
- package/src/cycle/state/withState.ts +0 -47
- package/src/pragma/fn.ts +0 -55
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { run } from 'sygnal';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* PLAN-4.5 G-275: marks an initial state that a wrapper built from its caller's values (an
|
|
5
|
+
* element's host props, Vike's pageContext.data or hydrated state, renderComponent's
|
|
6
|
+
* initialState option). The dev statics freeze (D152, checks/statics.ts) leaves a marked object
|
|
7
|
+
* and everything in it alone: the caller may still change those values. A non-enumerable symbol
|
|
8
|
+
* key: spreads, JSON and Object.keys don't see it.
|
|
9
|
+
*/
|
|
10
|
+
const OWNED = Symbol.for('sygnal.owned');
|
|
11
|
+
const owned = (v) => {
|
|
12
|
+
// G-289: an object that refuses the key (a Proxy) is returned as is
|
|
13
|
+
try {
|
|
14
|
+
if (v && typeof v == 'object' && Object.isExtensible(v))
|
|
15
|
+
Object.defineProperty(v, OWNED, { value: 1 });
|
|
16
|
+
}
|
|
17
|
+
catch { }
|
|
18
|
+
return v;
|
|
19
|
+
};
|
|
20
|
+
|
|
3
21
|
/**
|
|
4
22
|
* Vike client-side render hook for Sygnal.
|
|
5
23
|
*
|
|
@@ -30,40 +48,55 @@ let currentPageData = {};
|
|
|
30
48
|
let currentRouteParams = {};
|
|
31
49
|
let currentUrlPathname = '';
|
|
32
50
|
let pageNavCounter = 0;
|
|
51
|
+
/**
|
|
52
|
+
* PLAN-4 G-207: the uid() path part of a shell component or the Page: wrapper_0 → 'w0',
|
|
53
|
+
* layout_1 → 'l1', page → 'p'. Given as the nested vnode's `id` prop, so the Page's uid is
|
|
54
|
+
* 'u-w0-l0-p' however the shell nests it; onRenderHtml renders each one with the same root
|
|
55
|
+
* (renderToString's `uid`), so server and client ids match. (Same helper in onRenderHtml.ts.)
|
|
56
|
+
*/
|
|
57
|
+
function uidPart(key) {
|
|
58
|
+
return key == 'page' ? 'p' : key[0] + key.slice(key.indexOf('_') + 1);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* PLAN-4.6 R4 (04 §3.11): the core instantiates a component from the vnode's `data.c`, a
|
|
62
|
+
* component function, and reads its statics there (no options object). A shell component or a
|
|
63
|
+
* Page is wrapped once (a per-app / per-navigation function) with the statics the options
|
|
64
|
+
* gave the 5.x core: isolatedState, and the initial state.
|
|
65
|
+
*/
|
|
66
|
+
const shellFns = new WeakMap();
|
|
67
|
+
function shellFn(comp, initialState, cache = true) {
|
|
68
|
+
let f = cache ? shellFns.get(comp) : undefined;
|
|
69
|
+
if (!f) {
|
|
70
|
+
f = Object.assign((p) => comp(p), comp, { isolatedState: true, initialState });
|
|
71
|
+
try {
|
|
72
|
+
Object.defineProperty(f, 'name', { value: comp.name, configurable: true });
|
|
73
|
+
}
|
|
74
|
+
catch (_) { }
|
|
75
|
+
if (cache)
|
|
76
|
+
shellFns.set(comp, f);
|
|
77
|
+
}
|
|
78
|
+
return f;
|
|
79
|
+
}
|
|
80
|
+
let pageFn, pageFnNav = -1;
|
|
33
81
|
/**
|
|
34
82
|
* Build a component vnode that matches what the JSX pragma produces.
|
|
35
83
|
*/
|
|
36
|
-
function componentVNode(comp, stateField, children, compInitialState) {
|
|
84
|
+
function componentVNode(comp, key, stateField, children, compInitialState) {
|
|
37
85
|
const name = comp.componentName || comp.name || 'FUNCTION_COMPONENT';
|
|
38
86
|
return {
|
|
39
87
|
sel: name,
|
|
40
88
|
data: {
|
|
89
|
+
c: shellFn(comp, owned(comp.initialState)),
|
|
41
90
|
props: {
|
|
42
91
|
state: stateField,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
view: comp,
|
|
46
|
-
model: comp.model,
|
|
47
|
-
intent: comp.intent,
|
|
48
|
-
hmrActions: comp.hmrActions,
|
|
49
|
-
context: comp.context,
|
|
50
|
-
peers: comp.peers,
|
|
51
|
-
components: comp.components,
|
|
52
|
-
initialState: compInitialState,
|
|
53
|
-
isolatedState: true,
|
|
54
|
-
calculated: comp.calculated,
|
|
55
|
-
storeCalculatedInState: comp.storeCalculatedInState,
|
|
56
|
-
DOMSourceName: comp.DOMSourceName,
|
|
57
|
-
stateSourceName: comp.stateSourceName,
|
|
58
|
-
onError: comp.onError,
|
|
59
|
-
debug: comp.debug,
|
|
60
|
-
},
|
|
92
|
+
// G-207: the uid() base, as onRenderHtml gives this shell component (see uidPart)
|
|
93
|
+
id: uidPart(key),
|
|
61
94
|
},
|
|
62
95
|
},
|
|
63
96
|
children,
|
|
64
97
|
text: undefined,
|
|
65
98
|
elm: undefined,
|
|
66
|
-
key: '__vike_' +
|
|
99
|
+
key: '__vike_' + key + '__',
|
|
67
100
|
};
|
|
68
101
|
}
|
|
69
102
|
/**
|
|
@@ -71,33 +104,22 @@ function componentVNode(comp, stateField, children, compInitialState) {
|
|
|
71
104
|
* Reads from mutable `currentPage` / `currentPageName` so the wrapper
|
|
72
105
|
* view picks up the new Page component on navigation without being recreated.
|
|
73
106
|
*/
|
|
74
|
-
function pageChildVNode(pageState) {
|
|
75
|
-
//
|
|
76
|
-
//
|
|
107
|
+
function pageChildVNode(pageState, stateField = 'page') {
|
|
108
|
+
// a new function per navigation, so the Page is made again even when both pages are the same
|
|
109
|
+
// function (e.g. 'Page'); the nav counter in `sel` keeps the vnodes apart
|
|
77
110
|
const sel = currentPageName + '__nav' + pageNavCounter;
|
|
111
|
+
if (pageFnNav !== pageNavCounter) {
|
|
112
|
+
pageFnNav = pageNavCounter;
|
|
113
|
+
pageFn = shellFn(currentPage, undefined, false);
|
|
114
|
+
}
|
|
78
115
|
return {
|
|
79
116
|
sel,
|
|
80
117
|
data: {
|
|
118
|
+
c: pageFn,
|
|
81
119
|
props: {
|
|
82
|
-
state:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
view: currentPage,
|
|
86
|
-
model: currentPage.model,
|
|
87
|
-
intent: currentPage.intent,
|
|
88
|
-
hmrActions: currentPage.hmrActions,
|
|
89
|
-
context: currentPage.context,
|
|
90
|
-
peers: currentPage.peers,
|
|
91
|
-
components: currentPage.components,
|
|
92
|
-
initialState: pageState,
|
|
93
|
-
isolatedState: true,
|
|
94
|
-
calculated: currentPage.calculated,
|
|
95
|
-
storeCalculatedInState: currentPage.storeCalculatedInState,
|
|
96
|
-
DOMSourceName: currentPage.DOMSourceName,
|
|
97
|
-
stateSourceName: currentPage.stateSourceName,
|
|
98
|
-
onError: currentPage.onError,
|
|
99
|
-
debug: currentPage.debug,
|
|
100
|
-
},
|
|
120
|
+
state: stateField,
|
|
121
|
+
// G-207: the Page's uid() base, as onRenderHtml gives it (the same across navigations)
|
|
122
|
+
id: uidPart('page'),
|
|
101
123
|
},
|
|
102
124
|
},
|
|
103
125
|
children: [],
|
|
@@ -119,24 +141,47 @@ function pageChildVNode(pageState) {
|
|
|
119
141
|
function createLayoutWrapper(wrappers, layouts, Page) {
|
|
120
142
|
currentPage = Page;
|
|
121
143
|
currentPageName = Page.componentName || Page.name || 'VikePageComponent';
|
|
122
|
-
// Combined shell = wrappers (outermost) + layouts (innermost around Page)
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
144
|
+
// Combined shell = wrappers (outermost) + layouts (innermost around Page).
|
|
145
|
+
// D50: the root state holds every slice as a sibling, as in 5.4.0 but with the Page at the
|
|
146
|
+
// root too: { wrapper_0, ..., layout_0, ..., page }. A component's `state` prop selects from
|
|
147
|
+
// its parent component's state, and the shell components are nested in each other, so each
|
|
148
|
+
// one (and the Page) gets a { get, set } lens onto its own ROOT slice: an outer component's
|
|
149
|
+
// reducer replacing its state can't wipe the inner slices (R2-2), and no view sees another
|
|
150
|
+
// component's slice.
|
|
151
|
+
const keys = shellKeys(wrappers, layouts);
|
|
152
|
+
const shell = [...wrappers, ...layouts].map((comp, i) => ({ comp, key: keys[i] }));
|
|
153
|
+
// The latest root state. Only the outermost lens gets the root itself; the nested lenses get
|
|
154
|
+
// their parent shell component's state. In both directions the outermost lens runs first and
|
|
155
|
+
// synchronously (state: root -> outer get -> inner get; a reducer: outer get, inner get, inner
|
|
156
|
+
// set, outer set), so the nested lenses read and write through `root`.
|
|
157
|
+
let root = {};
|
|
158
|
+
const rootLens = (key, outermost, fresh) => ({
|
|
159
|
+
get: (state) => {
|
|
160
|
+
if (outermost)
|
|
161
|
+
root = state || {};
|
|
162
|
+
const slice = root[key];
|
|
163
|
+
// a shell slice is a new object on every root state, so the components nested in the
|
|
164
|
+
// shell component see every change (their state stream drops repeated objects)
|
|
165
|
+
return fresh && slice && typeof slice === 'object' && !Array.isArray(slice) ? { ...slice } : slice;
|
|
166
|
+
},
|
|
167
|
+
set: (state, slice) => {
|
|
168
|
+
root = { ...root, [key]: slice };
|
|
169
|
+
// a nested lens returns a changed parent state, so the parent's lens writes `root` back
|
|
170
|
+
return outermost ? root : { ...state };
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
const lenses = keys.map((key, i) => rootLens(key, i === 0, true));
|
|
174
|
+
const pageLens = rootLens('page', false, false);
|
|
129
175
|
function LayoutWrapperView({ state }) {
|
|
130
176
|
if (shell.length === 0) {
|
|
131
177
|
// No wrappers or layouts — render Page directly
|
|
132
178
|
return pageChildVNode(state.page);
|
|
133
179
|
}
|
|
134
180
|
const lastIdx = shell.length - 1;
|
|
135
|
-
|
|
136
|
-
let inner = componentVNode(shell[lastIdx].comp, shell[lastIdx].key, [pageChildVNode(innermostState.page)], innermostState);
|
|
181
|
+
let inner = componentVNode(shell[lastIdx].comp, shell[lastIdx].key, lenses[lastIdx], [pageChildVNode(state.page, pageLens)], state[shell[lastIdx].key]);
|
|
137
182
|
// Wrap with outer shell components
|
|
138
183
|
for (let i = lastIdx - 1; i >= 0; i--) {
|
|
139
|
-
inner = componentVNode(shell[i].comp, shell[i].key, [inner], state[shell[i].key]);
|
|
184
|
+
inner = componentVNode(shell[i].comp, shell[i].key, lenses[i], [inner], state[shell[i].key]);
|
|
140
185
|
}
|
|
141
186
|
// Wrap in a plain div so the view returns a regular DOM vnode.
|
|
142
187
|
// Sub-component vnodes at the root position are not processed correctly
|
|
@@ -151,17 +196,18 @@ function createLayoutWrapper(wrappers, layouts, Page) {
|
|
|
151
196
|
};
|
|
152
197
|
}
|
|
153
198
|
LayoutWrapperView.componentName = 'VikeLayoutWrapper';
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
199
|
+
// run() names the root by `name` first
|
|
200
|
+
try {
|
|
201
|
+
Object.defineProperty(LayoutWrapperView, 'name', { value: 'VikeLayoutWrapper', configurable: true });
|
|
202
|
+
}
|
|
203
|
+
catch (_) { }
|
|
204
|
+
// The wrapper's initial state: a sibling slice for each shell component and the Page.
|
|
205
|
+
// Must match onRenderHtml's serialized state.
|
|
206
|
+
const initialState = {};
|
|
207
|
+
shell.forEach(({ comp, key }) => { initialState[key] = { ...(comp.initialState || {}) }; });
|
|
208
|
+
initialState.page = Page.initialState || {};
|
|
209
|
+
// G-275: owned (built from the hydrated state and pageContext.data: never frozen in dev)
|
|
210
|
+
LayoutWrapperView.initialState = root = owned(initialState);
|
|
165
211
|
// Context uses mutable references so navigation updates are picked up.
|
|
166
212
|
// Wrapper and Layout contexts are merged once; page-level context
|
|
167
213
|
// (pageData, routeParams, urlPathname) reads from mutable variables
|
|
@@ -181,6 +227,13 @@ function createLayoutWrapper(wrappers, layouts, Page) {
|
|
|
181
227
|
};
|
|
182
228
|
return LayoutWrapperView;
|
|
183
229
|
}
|
|
230
|
+
/** State keys of the shell components, outermost first: wrapper_0, ..., layout_0, ... */
|
|
231
|
+
function shellKeys(wrappers, layouts) {
|
|
232
|
+
return [
|
|
233
|
+
...wrappers.map((_, i) => 'wrapper_' + i),
|
|
234
|
+
...layouts.map((_, i) => 'layout_' + i),
|
|
235
|
+
];
|
|
236
|
+
}
|
|
184
237
|
/**
|
|
185
238
|
* Normalize a cumulative config value into an array of functions.
|
|
186
239
|
*/
|
|
@@ -195,34 +248,39 @@ function onRenderClient(pageContext) {
|
|
|
195
248
|
const wrappers = toComponentArray(config.Wrapper);
|
|
196
249
|
const layouts = toComponentArray(config.Layout);
|
|
197
250
|
const hasShell = wrappers.length > 0 || layouts.length > 0;
|
|
198
|
-
// The shell is wrappers (outermost) + layouts
|
|
199
|
-
//
|
|
200
|
-
const shell =
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
251
|
+
// The shell is wrappers (outermost) + layouts; their state slices and the Page's are
|
|
252
|
+
// siblings at the root (D50).
|
|
253
|
+
const shell = shellKeys(wrappers, layouts);
|
|
254
|
+
// PLAN-3 5-5 (H-7): seed the caches of the fetch drivers (makeFetchDriver({ cache: queryCache() })
|
|
255
|
+
// exposes it as driver.cache) before the page renders, so its resources start at 'success'
|
|
256
|
+
if (pageContext.queryCache) {
|
|
257
|
+
for (const d of Object.values(config.drivers || {}))
|
|
258
|
+
d?.cache?.hydrate?.(pageContext.queryCache);
|
|
259
|
+
}
|
|
205
260
|
// Update mutable context references (used by the wrapper's context functions)
|
|
206
261
|
currentPageData = data;
|
|
207
262
|
currentRouteParams = pageContext.routeParams || {};
|
|
208
|
-
|
|
263
|
+
// urlPathname is built in on the client with Client Routing (G-046: it is
|
|
264
|
+
// not in passToClient); fall back to the location with Server Routing.
|
|
265
|
+
currentUrlPathname = pageContext.urlPathname
|
|
266
|
+
|| (typeof window !== 'undefined' && window.location ? window.location.pathname : '');
|
|
209
267
|
// --- Shell path: hot-swap Page, keep Layout/Wrapper alive ---
|
|
210
268
|
if (hasShell) {
|
|
211
269
|
if (currentApp) {
|
|
212
270
|
// Client-side navigation: swap the Page without disposing the shell.
|
|
271
|
+
// PLAN-3 5-4b: a router given Vike's navigate() (makeRouter({ routes, navigate })) re-reads
|
|
272
|
+
// the route on this event; sent before the swap, so the new Page declares after it
|
|
273
|
+
if (typeof window !== 'undefined')
|
|
274
|
+
window.dispatchEvent?.(new Event('sygnal:navigate'));
|
|
213
275
|
currentPage = Page;
|
|
214
276
|
currentPageName = Page.componentName || Page.name || 'VikePageComponent';
|
|
215
277
|
pageNavCounter++;
|
|
216
278
|
const newPageState = { ...(Page.initialState || {}), ...data };
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
[innermostKey]: { ...shellState, page: newPageState },
|
|
223
|
-
};
|
|
224
|
-
});
|
|
225
|
-
}
|
|
279
|
+
// replace the page slice, keeping every shell slice (G-106, D50)
|
|
280
|
+
const swapPage = (state) => ({ ...state, page: newPageState });
|
|
281
|
+
// (PLAN-4.6 core: through the runtime API, 04 §3.11)
|
|
282
|
+
const rt = currentApp.__runtime;
|
|
283
|
+
rt?.setState('root', swapPage);
|
|
226
284
|
}
|
|
227
285
|
else {
|
|
228
286
|
// First load: read hydrated state or build from initialState
|
|
@@ -234,25 +292,28 @@ function onRenderClient(pageContext) {
|
|
|
234
292
|
else {
|
|
235
293
|
initialState = null;
|
|
236
294
|
}
|
|
237
|
-
if (initialState &&
|
|
238
|
-
// Hydrated
|
|
295
|
+
if (initialState && initialState[shell[shell.length - 1]] !== undefined) {
|
|
296
|
+
// Hydrated shell state: sibling slices (D50), or the 5.4.0 shape with the Page state
|
|
297
|
+
// under the innermost shell slice (R2-9) — distribute the slices to each component
|
|
239
298
|
const allShellComps = [...wrappers, ...layouts];
|
|
299
|
+
let pageState = initialState.page;
|
|
240
300
|
shell.forEach((key, i) => {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
301
|
+
let slice = initialState[key];
|
|
302
|
+
if (slice === undefined)
|
|
303
|
+
return;
|
|
304
|
+
if (i === shell.length - 1 && slice && 'page' in slice) {
|
|
305
|
+
const { page, ...rest } = slice;
|
|
306
|
+
if (pageState === undefined)
|
|
307
|
+
pageState = page;
|
|
308
|
+
slice = rest;
|
|
250
309
|
}
|
|
310
|
+
allShellComps[i].initialState = owned(slice);
|
|
251
311
|
});
|
|
312
|
+
Page.initialState = owned(pageState || { ...(Page.initialState || {}), ...data });
|
|
252
313
|
}
|
|
253
314
|
else {
|
|
254
315
|
// SPA mode or client-side first navigation
|
|
255
|
-
Page.initialState = { ...(Page.initialState || {}), ...data };
|
|
316
|
+
Page.initialState = owned({ ...(Page.initialState || {}), ...data });
|
|
256
317
|
}
|
|
257
318
|
// Inject page-level context into Page (for SSR renderToString compat)
|
|
258
319
|
Page.context = {
|
|
@@ -263,7 +324,9 @@ function onRenderClient(pageContext) {
|
|
|
263
324
|
};
|
|
264
325
|
const Component = createLayoutWrapper(wrappers, layouts, Page);
|
|
265
326
|
try {
|
|
266
|
-
|
|
327
|
+
// 3-B2: `__vike` marks the shell's components (Page, Layouts, Wrappers: sub-components of
|
|
328
|
+
// the shell root) for the dev entry, whose SYG224 then says persist() isn't supported there
|
|
329
|
+
currentApp = run(Component, { ...config.drivers, __vike: () => 1 }, { mountPoint: '#page-view', onError: config.sygnalOnError });
|
|
267
330
|
}
|
|
268
331
|
catch (err) {
|
|
269
332
|
console.error('[sygnal/vike] Client render error:', err);
|
|
@@ -284,14 +347,17 @@ function onRenderClient(pageContext) {
|
|
|
284
347
|
currentApp = null;
|
|
285
348
|
}
|
|
286
349
|
let initialState;
|
|
350
|
+
// 3-B2: the server's state is here when the page hydrates its HTML
|
|
351
|
+
let serverState = false;
|
|
287
352
|
if (typeof window !== 'undefined' && window.__VIKE_SYGNAL_STATE__ !== undefined) {
|
|
288
353
|
initialState = window.__VIKE_SYGNAL_STATE__;
|
|
289
354
|
delete window.__VIKE_SYGNAL_STATE__;
|
|
355
|
+
serverState = true;
|
|
290
356
|
}
|
|
291
357
|
else {
|
|
292
358
|
initialState = { ...(Page.initialState || {}), ...data };
|
|
293
359
|
}
|
|
294
|
-
Page.initialState = initialState;
|
|
360
|
+
Page.initialState = owned(initialState);
|
|
295
361
|
Page.context = {
|
|
296
362
|
...Page.context,
|
|
297
363
|
pageData: () => currentPageData,
|
|
@@ -299,7 +365,11 @@ function onRenderClient(pageContext) {
|
|
|
299
365
|
urlPathname: () => currentUrlPathname,
|
|
300
366
|
};
|
|
301
367
|
try {
|
|
302
|
-
|
|
368
|
+
// 3-B2: the Page is the root, so its persist() restores after the first render when this
|
|
369
|
+
// is a hydration (`__hydrate`), keeping that render equal to the server's HTML. A client-side
|
|
370
|
+
// navigation isn't one, though the previous page's markup is still in #page-view
|
|
371
|
+
const hydrating = pageContext.isHydration ?? serverState;
|
|
372
|
+
currentApp = run(Page, { ...config.drivers, __hydrate: () => hydrating }, { mountPoint: '#page-view', onError: config.sygnalOnError });
|
|
303
373
|
}
|
|
304
374
|
catch (err) {
|
|
305
375
|
console.error('[sygnal/vike] Client render error:', err);
|
|
@@ -319,3 +389,4 @@ function onRenderClient(pageContext) {
|
|
|
319
389
|
}
|
|
320
390
|
|
|
321
391
|
export { onRenderClient };
|
|
392
|
+
//# sourceMappingURL=onRenderClient.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onRenderClient.mjs","sources":["../../src/extra/owned.ts","../../src/vike/onRenderClient.ts"],"sourcesContent":["/**\n * PLAN-4.5 G-275: marks an initial state that a wrapper built from its caller's values (an\n * element's host props, Vike's pageContext.data or hydrated state, renderComponent's\n * initialState option). The dev statics freeze (D152, checks/statics.ts) leaves a marked object\n * and everything in it alone: the caller may still change those values. A non-enumerable symbol\n * key: spreads, JSON and Object.keys don't see it.\n */\nexport const OWNED = Symbol.for('sygnal.owned')\n\nexport const owned = <T>(v: T): T => {\n // G-289: an object that refuses the key (a Proxy) is returned as is\n try { if (v && typeof v == 'object' && Object.isExtensible(v)) Object.defineProperty(v, OWNED, {value: 1}) } catch {}\n return v\n}\n\n/**\n * G-289: owned() of a shallow copy of a plain object or array (the caller's own object stays\n * unmarked: it may be a component's static, which the freeze must still cover, or sealed, which\n * can't be marked); anything else as owned()\n */\nexport const ownedCopy = <T>(v: T): T => {\n const p = v && typeof v == 'object' ? Object.getPrototypeOf(v) : 0\n return owned(Array.isArray(v) ? [...v] as any : p == Object.prototype || p === null ? {...v} : v)\n}\n","/**\n * Vike client-side render hook for Sygnal.\n *\n * On first page load (hydration): reads server-serialized state and\n * boots the Sygnal app via run().\n *\n * On client-side navigation with a Layout/Wrapper: the Layout and Wrapper\n * stay mounted and only the Page sub-component is hot-swapped. Layout and\n * Wrapper state persists across navigations. Without either, the app is\n * disposed and recreated.\n *\n * Nesting order: Wrapper > Layout > Page\n * - Wrappers are outermost (context providers, state management)\n * - Layouts are inside wrappers (visual structure, navigation chrome)\n * - Page is innermost (route-specific content, swapped on navigation)\n */\n\n// Import from the package entry so rollup externalizes it\n// @ts-ignore — resolved at runtime via package exports\nimport { run } from 'sygnal'\nimport { owned } from '../extra/owned'\n\ndeclare global {\n interface Window {\n __VIKE_SYGNAL_STATE__?: any\n }\n}\n\ninterface PageContext {\n Page: any\n data?: any\n routeParams?: Record<string, string>\n urlPathname?: string\n isHydration?: boolean\n /** PLAN-3 5-5 (H-7): the queryCache() snapshot a loader seeded (see onRenderHtml) */\n queryCache?: any\n config: {\n Layout?: any | any[]\n Wrapper?: any | any[]\n title?: string\n ssr?: boolean\n drivers?: Record<string, (sink: any) => any>\n // PLAN-4 GS-11: the app-level error hook (not Vike's own onError)\n sygnalOnError?: (error: any, info: any) => void\n }\n}\n\n/** Track the running Sygnal app for disposal on navigation */\nlet currentApp: { sources: any; sinks: any; dispose: () => void } | null = null\n\n/**\n * Mutable references read by the wrapper's view function.\n * Updated on navigation to swap the Page without disposing the Layout.\n */\nlet currentPage: any = null\nlet currentPageName: string = ''\nlet currentPageData: any = {}\nlet currentRouteParams: any = {}\nlet currentUrlPathname: string = ''\nlet pageNavCounter: number = 0\n\n/**\n * PLAN-4 G-207: the uid() path part of a shell component or the Page: wrapper_0 → 'w0',\n * layout_1 → 'l1', page → 'p'. Given as the nested vnode's `id` prop, so the Page's uid is\n * 'u-w0-l0-p' however the shell nests it; onRenderHtml renders each one with the same root\n * (renderToString's `uid`), so server and client ids match. (Same helper in onRenderHtml.ts.)\n */\nfunction uidPart(key: string): string {\n return key == 'page' ? 'p' : key[0] + key.slice(key.indexOf('_') + 1)\n}\n\n/**\n * PLAN-4.6 R4 (04 §3.11): the core instantiates a component from the vnode's `data.c`, a\n * component function, and reads its statics there (no options object). A shell component or a\n * Page is wrapped once (a per-app / per-navigation function) with the statics the options\n * gave the 5.x core: isolatedState, and the initial state.\n */\nconst shellFns = new WeakMap<any, any>()\nfunction shellFn(comp: any, initialState: any, cache = true): any {\n let f = cache ? shellFns.get(comp) : undefined\n if (!f) {\n f = Object.assign((p: any) => comp(p), comp, { isolatedState: true, initialState })\n try { Object.defineProperty(f, 'name', { value: comp.name, configurable: true }) } catch (_) {}\n if (cache) shellFns.set(comp, f)\n }\n return f\n}\nlet pageFn: any, pageFnNav = -1\n\n/**\n * Build a component vnode that matches what the JSX pragma produces.\n */\nfunction componentVNode(comp: any, key: string, stateField: any, children: any[], compInitialState?: any): any {\n const name = comp.componentName || comp.name || 'FUNCTION_COMPONENT'\n return {\n sel: name,\n data: {\n c: shellFn(comp, owned(comp.initialState)),\n props: {\n state: stateField,\n // G-207: the uid() base, as onRenderHtml gives this shell component (see uidPart)\n id: uidPart(key),\n },\n },\n children,\n text: undefined,\n elm: undefined,\n key: '__vike_' + key + '__',\n }\n}\n\n/**\n * Build a vnode for the current Page as a child of the Layout.\n * Reads from mutable `currentPage` / `currentPageName` so the wrapper\n * view picks up the new Page component on navigation without being recreated.\n */\nfunction pageChildVNode(pageState: any, stateField: any = 'page'): any {\n // a new function per navigation, so the Page is made again even when both pages are the same\n // function (e.g. 'Page'); the nav counter in `sel` keeps the vnodes apart\n const sel = currentPageName + '__nav' + pageNavCounter\n if (pageFnNav !== pageNavCounter) { pageFnNav = pageNavCounter; pageFn = shellFn(currentPage, undefined, false) }\n return {\n sel,\n data: {\n c: pageFn,\n props: {\n state: stateField,\n // G-207: the Page's uid() base, as onRenderHtml gives it (the same across navigations)\n id: uidPart('page'),\n },\n },\n children: [],\n text: undefined,\n elm: undefined,\n key: '__vike_page__',\n }\n}\n\n/**\n * Create a synthetic wrapper component that nests Page inside Layout(s)\n * inside Wrapper(s).\n *\n * Nesting order: Wrapper(s) > Layout(s) > Page\n *\n * The wrapper's view reads `currentPage` from the mutable closure, so\n * on client-side navigation only the Page sub-component changes while\n * the Layout and Wrapper stay mounted with their state preserved.\n */\nfunction createLayoutWrapper(wrappers: any[], layouts: any[], Page: any): any {\n currentPage = Page\n currentPageName = Page.componentName || Page.name || 'VikePageComponent'\n\n // Combined shell = wrappers (outermost) + layouts (innermost around Page).\n // D50: the root state holds every slice as a sibling, as in 5.4.0 but with the Page at the\n // root too: { wrapper_0, ..., layout_0, ..., page }. A component's `state` prop selects from\n // its parent component's state, and the shell components are nested in each other, so each\n // one (and the Page) gets a { get, set } lens onto its own ROOT slice: an outer component's\n // reducer replacing its state can't wipe the inner slices (R2-2), and no view sees another\n // component's slice.\n const keys = shellKeys(wrappers, layouts)\n const shell = [...wrappers, ...layouts].map((comp: any, i: number) => ({ comp, key: keys[i] }))\n\n // The latest root state. Only the outermost lens gets the root itself; the nested lenses get\n // their parent shell component's state. In both directions the outermost lens runs first and\n // synchronously (state: root -> outer get -> inner get; a reducer: outer get, inner get, inner\n // set, outer set), so the nested lenses read and write through `root`.\n let root: any = {}\n const rootLens = (key: string, outermost: boolean, fresh: boolean) => ({\n get: (state: any) => {\n if (outermost) root = state || {}\n const slice = root[key]\n // a shell slice is a new object on every root state, so the components nested in the\n // shell component see every change (their state stream drops repeated objects)\n return fresh && slice && typeof slice === 'object' && !Array.isArray(slice) ? { ...slice } : slice\n },\n set: (state: any, slice: any) => {\n root = { ...root, [key]: slice }\n // a nested lens returns a changed parent state, so the parent's lens writes `root` back\n return outermost ? root : { ...state }\n },\n })\n const lenses = keys.map((key, i) => rootLens(key, i === 0, true))\n const pageLens = rootLens('page', false, false)\n\n function LayoutWrapperView({ state }: any) {\n if (shell.length === 0) {\n // No wrappers or layouts — render Page directly\n return pageChildVNode(state.page)\n }\n\n const lastIdx = shell.length - 1\n let inner: any = componentVNode(\n shell[lastIdx].comp,\n shell[lastIdx].key,\n lenses[lastIdx],\n [pageChildVNode(state.page, pageLens)],\n state[shell[lastIdx].key]\n )\n\n // Wrap with outer shell components\n for (let i = lastIdx - 1; i >= 0; i--) {\n inner = componentVNode(shell[i].comp, shell[i].key, lenses[i], [inner], state[shell[i].key])\n }\n\n // Wrap in a plain div so the view returns a regular DOM vnode.\n // Sub-component vnodes at the root position are not processed correctly\n // by the rendering pipeline — they must be children of a DOM element.\n return {\n sel: 'div',\n data: { attrs: { id: 'vike-shell' } },\n children: [inner],\n text: undefined,\n elm: undefined,\n key: '__vike_shell__',\n }\n }\n\n LayoutWrapperView.componentName = 'VikeLayoutWrapper'\n // run() names the root by `name` first\n try { Object.defineProperty(LayoutWrapperView, 'name', { value: 'VikeLayoutWrapper', configurable: true }) } catch (_) {}\n\n // The wrapper's initial state: a sibling slice for each shell component and the Page.\n // Must match onRenderHtml's serialized state.\n const initialState: any = {}\n shell.forEach(({ comp, key }: any) => { initialState[key] = { ...(comp.initialState || {}) } })\n initialState.page = Page.initialState || {}\n // G-275: owned (built from the hydrated state and pageContext.data: never frozen in dev)\n LayoutWrapperView.initialState = root = owned(initialState)\n\n // Context uses mutable references so navigation updates are picked up.\n // Wrapper and Layout contexts are merged once; page-level context\n // (pageData, routeParams, urlPathname) reads from mutable variables\n // updated on each navigation.\n const shellContext: any = {}\n shell.forEach(({ comp }: any) => {\n if (comp.context) {\n Object.assign(shellContext, comp.context)\n }\n })\n\n LayoutWrapperView.context = {\n ...shellContext,\n ...(Page.context || {}),\n pageData: () => currentPageData,\n routeParams: () => currentRouteParams,\n urlPathname: () => currentUrlPathname,\n }\n\n return LayoutWrapperView\n}\n\n/** State keys of the shell components, outermost first: wrapper_0, ..., layout_0, ... */\nfunction shellKeys(wrappers: any[], layouts: any[]): string[] {\n return [\n ...wrappers.map((_: any, i: number) => 'wrapper_' + i),\n ...layouts.map((_: any, i: number) => 'layout_' + i),\n ]\n}\n\n/**\n * Normalize a cumulative config value into an array of functions.\n */\nfunction toComponentArray(val: any): any[] {\n if (!val) return []\n return (Array.isArray(val) ? val : [val]).filter((c: any) => typeof c === 'function')\n}\n\nexport function onRenderClient(pageContext: PageContext) {\n const { Page, config } = pageContext\n const data = pageContext.data || {}\n\n const wrappers = toComponentArray(config.Wrapper)\n const layouts = toComponentArray(config.Layout)\n const hasShell = wrappers.length > 0 || layouts.length > 0\n\n // The shell is wrappers (outermost) + layouts; their state slices and the Page's are\n // siblings at the root (D50).\n const shell = shellKeys(wrappers, layouts)\n\n // PLAN-3 5-5 (H-7): seed the caches of the fetch drivers (makeFetchDriver({ cache: queryCache() })\n // exposes it as driver.cache) before the page renders, so its resources start at 'success'\n if (pageContext.queryCache) {\n for (const d of Object.values(config.drivers || {})) (d as any)?.cache?.hydrate?.(pageContext.queryCache)\n }\n\n // Update mutable context references (used by the wrapper's context functions)\n currentPageData = data\n currentRouteParams = pageContext.routeParams || {}\n // urlPathname is built in on the client with Client Routing (G-046: it is\n // not in passToClient); fall back to the location with Server Routing.\n currentUrlPathname = pageContext.urlPathname\n || (typeof window !== 'undefined' && window.location ? window.location.pathname : '')\n\n // --- Shell path: hot-swap Page, keep Layout/Wrapper alive ---\n if (hasShell) {\n if (currentApp) {\n // Client-side navigation: swap the Page without disposing the shell.\n // PLAN-3 5-4b: a router given Vike's navigate() (makeRouter({ routes, navigate })) re-reads\n // the route on this event; sent before the swap, so the new Page declares after it\n if (typeof window !== 'undefined') window.dispatchEvent?.(new Event('sygnal:navigate'))\n currentPage = Page\n currentPageName = Page.componentName || Page.name || 'VikePageComponent'\n pageNavCounter++\n\n const newPageState = { ...(Page.initialState || {}), ...data }\n // replace the page slice, keeping every shell slice (G-106, D50)\n const swapPage = (state: any) => ({ ...state, page: newPageState })\n // (PLAN-4.6 core: through the runtime API, 04 §3.11)\n const rt = (currentApp as any).__runtime\n rt?.setState('root', swapPage)\n } else {\n // First load: read hydrated state or build from initialState\n let initialState: any\n if (typeof window !== 'undefined' && window.__VIKE_SYGNAL_STATE__ !== undefined) {\n initialState = window.__VIKE_SYGNAL_STATE__\n delete window.__VIKE_SYGNAL_STATE__\n } else {\n initialState = null\n }\n\n if (initialState && initialState[shell[shell.length - 1]] !== undefined) {\n // Hydrated shell state: sibling slices (D50), or the 5.4.0 shape with the Page state\n // under the innermost shell slice (R2-9) — distribute the slices to each component\n const allShellComps = [...wrappers, ...layouts]\n let pageState = initialState.page\n shell.forEach((key: string, i: number) => {\n let slice = initialState[key]\n if (slice === undefined) return\n if (i === shell.length - 1 && slice && 'page' in slice) {\n const { page, ...rest } = slice\n if (pageState === undefined) pageState = page\n slice = rest\n }\n allShellComps[i].initialState = owned(slice)\n })\n Page.initialState = owned(pageState || { ...(Page.initialState || {}), ...data })\n } else {\n // SPA mode or client-side first navigation\n Page.initialState = owned({ ...(Page.initialState || {}), ...data })\n }\n\n // Inject page-level context into Page (for SSR renderToString compat)\n Page.context = {\n ...Page.context,\n pageData: () => currentPageData,\n routeParams: () => currentRouteParams,\n urlPathname: () => currentUrlPathname,\n }\n\n const Component = createLayoutWrapper(wrappers, layouts, Page)\n\n try {\n // 3-B2: `__vike` marks the shell's components (Page, Layouts, Wrappers: sub-components of\n // the shell root) for the dev entry, whose SYG224 then says persist() isn't supported there\n currentApp = run(Component, { ...config.drivers, __vike: () => 1 }, { mountPoint: '#page-view', onError: config.sygnalOnError }) as any\n } catch (err: any) {\n console.error('[sygnal/vike] Client render error:', err)\n const container = document.getElementById('page-view')\n if (container) {\n container.innerHTML = `<div data-sygnal-error style=\"padding:2rem;color:#e74c3c;font-family:monospace\">\n <h2>Render Error</h2>\n <pre>${String(err.message || err)}</pre>\n </div>`\n }\n }\n }\n\n // --- No shell path: dispose and recreate ---\n } else {\n if (currentApp) {\n currentApp.dispose()\n currentApp = null\n }\n\n let initialState: any\n // 3-B2: the server's state is here when the page hydrates its HTML\n let serverState = false\n if (typeof window !== 'undefined' && window.__VIKE_SYGNAL_STATE__ !== undefined) {\n initialState = window.__VIKE_SYGNAL_STATE__\n delete window.__VIKE_SYGNAL_STATE__\n serverState = true\n } else {\n initialState = { ...(Page.initialState || {}), ...data }\n }\n\n Page.initialState = owned(initialState)\n Page.context = {\n ...Page.context,\n pageData: () => currentPageData,\n routeParams: () => currentRouteParams,\n urlPathname: () => currentUrlPathname,\n }\n\n try {\n // 3-B2: the Page is the root, so its persist() restores after the first render when this\n // is a hydration (`__hydrate`), keeping that render equal to the server's HTML. A client-side\n // navigation isn't one, though the previous page's markup is still in #page-view\n const hydrating = pageContext.isHydration ?? serverState\n currentApp = run(Page, { ...config.drivers, __hydrate: () => hydrating }, { mountPoint: '#page-view', onError: config.sygnalOnError }) as any\n } catch (err: any) {\n console.error('[sygnal/vike] Client render error:', err)\n const container = document.getElementById('page-view')\n if (container) {\n container.innerHTML = `<div data-sygnal-error style=\"padding:2rem;color:#e74c3c;font-family:monospace\">\n <h2>Render Error</h2>\n <pre>${String(err.message || err)}</pre>\n </div>`\n }\n }\n }\n\n // Update document title on client navigation\n if (config.title) {\n document.title = config.title\n }\n}\n"],"names":[],"mappings":";;AAAA;;;;;;AAMG;AACI,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;AAExC,MAAM,KAAK,GAAG,CAAI,CAAI,KAAO;;AAElC,IAAA,IAAI;AAAE,QAAA,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,QAAQ,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CA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B;AACH;;;;"}
|
|
@@ -28,6 +28,15 @@ function esc(str) {
|
|
|
28
28
|
.replace(/>/g, '>')
|
|
29
29
|
.replace(/"/g, '"');
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* PLAN-4 G-207: the uid() path part of a shell component or the Page (wrapper_0 → 'w0',
|
|
33
|
+
* layout_1 → 'l1', page → 'p'), as onRenderClient gives each nested vnode in its `id` prop. Each
|
|
34
|
+
* one renders here as its own root, so its root is 'u' plus the parts of the shell around it and
|
|
35
|
+
* its own: the same uids as the client's nested instances.
|
|
36
|
+
*/
|
|
37
|
+
function uidPart(key) {
|
|
38
|
+
return key == 'page' ? 'p' : key[0] + key.slice(key.indexOf('_') + 1);
|
|
39
|
+
}
|
|
31
40
|
function onRenderHtml(pageContext) {
|
|
32
41
|
const { Page, config } = pageContext;
|
|
33
42
|
const data = pageContext.data || {};
|
|
@@ -84,6 +93,8 @@ function onRenderHtml(pageContext) {
|
|
|
84
93
|
routeParams: () => pageContext.routeParams || {},
|
|
85
94
|
urlPathname: () => pageContext.urlPathname || '',
|
|
86
95
|
};
|
|
96
|
+
// PLAN-3 5-5 (H-7): the seeded cache the components' resources render from
|
|
97
|
+
const cache = pageContext.queryCache ? sygnal.queryCache({ initial: pageContext.queryCache }) : undefined;
|
|
87
98
|
// Determine if Wrapper(s) and/or Layout(s) are present — this affects hydration state shape
|
|
88
99
|
const wrapperArray = config.Wrapper
|
|
89
100
|
? (Array.isArray(config.Wrapper) ? config.Wrapper : [config.Wrapper])
|
|
@@ -94,14 +105,31 @@ function onRenderHtml(pageContext) {
|
|
|
94
105
|
.filter((L) => typeof L === 'function')
|
|
95
106
|
: [];
|
|
96
107
|
const hasShell = wrapperArray.length > 0 || layoutArray.length > 0;
|
|
108
|
+
// Combined shell: wrappers (outermost) + layouts (innermost around Page)
|
|
109
|
+
// Must match the order used in onRenderClient's createLayoutWrapper.
|
|
110
|
+
const shell = [
|
|
111
|
+
...wrapperArray.map((w, i) => ({ comp: w, key: 'wrapper_' + i })),
|
|
112
|
+
...layoutArray.map((l, i) => ({ comp: l, key: 'layout_' + i })),
|
|
113
|
+
];
|
|
114
|
+
// G-207: with a shell, the client nests each shell component and the Page in the one outside it
|
|
115
|
+
// with an `id` prop (onRenderClient), so their uid roots are 'u-w0', 'u-w0-l0', 'u-w0-l0-p'
|
|
116
|
+
const uidRoot = (i) => ['u', ...shell.slice(0, i + 1).map(s => uidPart(s.key))].join('-');
|
|
117
|
+
const pageUid = hasShell ? uidRoot(shell.length - 1) + '-' + uidPart('page') : undefined;
|
|
97
118
|
// Render the page component to HTML, with error boundary.
|
|
98
119
|
// When layouts are present, the hydration state is serialized separately
|
|
99
120
|
// as the wrapper's combined state (with page + layout slices).
|
|
121
|
+
// PLAN-3 (HEAD driver): the `head` statics of the rendered components (shell first, so the page's win)
|
|
122
|
+
const pageHeads = [], shellHeads = [];
|
|
100
123
|
let pageHtml;
|
|
101
124
|
try {
|
|
102
125
|
pageHtml = sygnal.renderToString(Page, {
|
|
103
126
|
state: initialState,
|
|
127
|
+
onError: config.sygnalOnError,
|
|
128
|
+
// G-207: the client's uid base and `id` prop for the nested Page
|
|
129
|
+
...(hasShell && { uid: pageUid, props: { id: uidPart('page') } }),
|
|
104
130
|
hydrateState: hasShell ? false : '__VIKE_SYGNAL_STATE__',
|
|
131
|
+
head: pageHeads,
|
|
132
|
+
cache,
|
|
105
133
|
});
|
|
106
134
|
}
|
|
107
135
|
catch (err) {
|
|
@@ -131,26 +159,34 @@ function onRenderHtml(pageContext) {
|
|
|
131
159
|
// If Layout(s) and/or Wrapper(s) are defined, render them wrapping the page content.
|
|
132
160
|
// HTML is rendered INSIDE #page-view so the structure matches the client-side
|
|
133
161
|
// wrapper component. Nesting order: Wrapper > Layout > Page.
|
|
134
|
-
// Each shell component receives page content
|
|
162
|
+
// Each shell component receives the page content as a placeholder. G-464: a placeholder element
|
|
163
|
+
// as its `children` (`<main>{children}</main>`, as on the client), and, for a Layout written
|
|
164
|
+
// for the server only, the `innerHTML` prop.
|
|
135
165
|
let pageViewContent = pageHtml;
|
|
136
166
|
if (hasShell) {
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
...layoutArray.map((l, i) => ({ comp: l, key: 'layout_' + i })),
|
|
142
|
-
];
|
|
167
|
+
// G-491: with attributes too (a shell whose root, or fragment's first element, is the slot
|
|
168
|
+
// carries the SSR root stamp: data-sygnal-ssr="")
|
|
169
|
+
const SLOT = /<sygnal-page-slot(?:\s[^>]*)?><\/sygnal-page-slot>/;
|
|
170
|
+
const PLACEHOLDER = '<!--SYGNAL_PAGE_SLOT-->';
|
|
143
171
|
// Wrap from innermost to outermost (reverse order)
|
|
144
172
|
for (let i = shell.length - 1; i >= 0; i--) {
|
|
145
|
-
const { comp } = shell[i];
|
|
146
|
-
const
|
|
173
|
+
const { comp, key } = shell[i];
|
|
174
|
+
const slot = { sel: 'sygnal-page-slot', data: {}, children: [], text: undefined, elm: undefined, key: undefined };
|
|
147
175
|
const compHtml = sygnal.renderToString(comp, {
|
|
148
176
|
state: comp.initialState || {},
|
|
149
|
-
|
|
177
|
+
// G-207: the uid root and `id` prop the client's nested instance has
|
|
178
|
+
uid: uidRoot(i),
|
|
179
|
+
props: { innerHTML: PLACEHOLDER, id: uidPart(key), children: [slot] },
|
|
180
|
+
head: shellHeads,
|
|
181
|
+
cache,
|
|
182
|
+
onError: config.sygnalOnError,
|
|
150
183
|
});
|
|
151
|
-
const
|
|
184
|
+
const m = SLOT.exec(compHtml);
|
|
185
|
+
let splitIdx = m ? m.index : -1, len = m ? m[0].length : 0;
|
|
186
|
+
if (splitIdx === -1)
|
|
187
|
+
splitIdx = compHtml.indexOf(PLACEHOLDER), len = PLACEHOLDER.length;
|
|
152
188
|
if (splitIdx !== -1) {
|
|
153
|
-
pageViewContent = compHtml.substring(0, splitIdx) + pageViewContent + compHtml.substring(splitIdx +
|
|
189
|
+
pageViewContent = compHtml.substring(0, splitIdx) + pageViewContent + compHtml.substring(splitIdx + len);
|
|
154
190
|
}
|
|
155
191
|
else {
|
|
156
192
|
// Fallback: component didn't use children/innerHTML, wrap content after it
|
|
@@ -159,17 +195,12 @@ function onRenderHtml(pageContext) {
|
|
|
159
195
|
}
|
|
160
196
|
// Wrap in a shell div matching the client-side wrapper's root element
|
|
161
197
|
pageViewContent = `<div id="vike-shell">${pageViewContent}</div>`;
|
|
162
|
-
// Serialize the wrapper's combined state for hydration.
|
|
163
|
-
//
|
|
164
|
-
// { wrapper_0: {...}, layout_0: { ...layoutState, page: pageState }
|
|
198
|
+
// Serialize the wrapper's combined state for hydration. Must match the state shape
|
|
199
|
+
// from createLayoutWrapper (D50: sibling slices at the root):
|
|
200
|
+
// { wrapper_0: { ...wrapperState }, layout_0: { ...layoutState }, page: pageState }
|
|
165
201
|
const wrapperState = {};
|
|
166
|
-
shell.forEach(({ comp, key }
|
|
167
|
-
|
|
168
|
-
if (i === shell.length - 1) {
|
|
169
|
-
compState.page = initialState;
|
|
170
|
-
}
|
|
171
|
-
wrapperState[key] = compState;
|
|
172
|
-
});
|
|
202
|
+
shell.forEach(({ comp, key }) => { wrapperState[key] = { ...(comp.initialState || {}) }; });
|
|
203
|
+
wrapperState.page = initialState;
|
|
173
204
|
pageViewContent += `<script>window.__VIKE_SYGNAL_STATE__=${JSON.stringify(wrapperState)}</script>`;
|
|
174
205
|
}
|
|
175
206
|
// Render Head component for <head> tags
|
|
@@ -186,8 +217,12 @@ function onRenderHtml(pageContext) {
|
|
|
186
217
|
const description = config.description || '';
|
|
187
218
|
const favicon = config.favicon || '';
|
|
188
219
|
const lang = config.lang || 'en';
|
|
189
|
-
const
|
|
190
|
-
|
|
220
|
+
const heads = [...shellHeads, ...pageHeads].filter(Boolean);
|
|
221
|
+
// with `head` statics, config.title / description are the defaults they override
|
|
222
|
+
const titleTag = heads.length
|
|
223
|
+
? sygnal.renderHead([{ title: title || undefined, meta: { description: description || undefined } }, ...heads])
|
|
224
|
+
: title ? `<title>${esc(title)}</title>` : '';
|
|
225
|
+
const descTag = description && !heads.length
|
|
191
226
|
? `<meta name="description" content="${esc(description)}">`
|
|
192
227
|
: '';
|
|
193
228
|
const faviconTag = favicon
|
|
@@ -215,3 +250,4 @@ function onRenderHtml(pageContext) {
|
|
|
215
250
|
}
|
|
216
251
|
|
|
217
252
|
exports.onRenderHtml = onRenderHtml;
|
|
253
|
+
//# sourceMappingURL=onRenderHtml.cjs.js.map
|