sygnal 6.2.0 → 6.3.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 +61 -0
- package/README.md +3 -1
- package/dist/ai.cjs.js +36 -0
- package/dist/ai.cjs.js.map +1 -1
- package/dist/ai.esm.js +1 -1
- package/dist/astro/server.cjs.js +3 -3
- package/dist/astro/server.cjs.js.map +1 -1
- package/dist/astro/server.mjs +3 -3
- package/dist/astro/server.mjs.map +1 -1
- package/dist/diagnostics.cjs.js +164 -3
- package/dist/diagnostics.cjs.js.map +1 -1
- package/dist/diagnostics.esm.js +164 -3
- package/dist/diagnostics.esm.js.map +1 -1
- package/dist/guide/agent.md +7 -1
- package/dist/guide/ai-cards.md +319 -0
- package/dist/guide/ai-chat.md +4 -0
- package/dist/guide/ai-compose.md +881 -0
- package/dist/guide/ai-decisions.md +16 -0
- package/dist/guide/http.md +1 -0
- package/dist/index.cjs.js +5695 -347
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +638 -8
- package/dist/index.esm.js +5685 -347
- package/dist/index.esm.js.map +1 -1
- package/dist/sygnal.min.js +1 -1
- package/dist/sygnal.min.js.map +1 -1
- package/dist/vike/config/package.json +1 -1
- package/dist/vike/onRenderClient.cjs.js +3 -2
- package/dist/vike/onRenderClient.cjs.js.map +1 -1
- package/dist/vike/onRenderClient.mjs +3 -2
- package/dist/vike/onRenderClient.mjs.map +1 -1
- package/llms.txt +6 -4
- package/package.json +2 -1
- package/src/ai.d.ts +642 -7
- package/src/ai.ts +6 -0
- package/src/collection.ts +2 -1
- package/src/core/instance.ts +6 -3
- package/src/core/markers/lazy.ts +7 -3
- package/src/core/markers/portal.ts +5 -2
- package/src/core/markers/suspense.ts +3 -2
- package/src/core/markers/transition.ts +6 -3
- package/src/core/registry.ts +9 -5
- package/src/cycle/dom/IsolateModule.ts +25 -22
- package/src/extra/ai/chat/behavior.ts +354 -81
- package/src/extra/ai/chat/driver.ts +7 -4
- package/src/extra/ai/compose/agent.ts +55 -0
- package/src/extra/ai/compose/ask.ts +147 -0
- package/src/extra/ai/compose/behavior.ts +183 -0
- package/src/extra/ai/compose/catalog.ts +211 -0
- package/src/extra/ai/compose/composed.ts +61 -0
- package/src/extra/ai/compose/decisions.ts +1649 -0
- package/src/extra/ai/compose/diag.ts +33 -0
- package/src/extra/ai/compose/index.ts +23 -0
- package/src/extra/ai/compose/layout.ts +441 -0
- package/src/extra/ai/compose/llm.ts +1120 -0
- package/src/extra/ai/compose/render.ts +159 -0
- package/src/extra/ai/compose/testing.ts +71 -0
- package/src/extra/ai/compose/types.ts +159 -0
- package/src/extra/ai/decide.ts +97 -1
- package/src/extra/ai/index.ts +6 -1
- package/src/extra/diagnostics/checks/next.ts +86 -2
- package/src/extra/diagnostics/codes.ts +54 -0
- package/src/extra/fetchDriver.ts +58 -27
- package/src/extra/lens.ts +15 -0
- package/src/extra/ssr.ts +3 -3
- package/src/extra/testing.ts +2 -0
- package/src/extra/widget.ts +3 -3
- package/src/index.d.ts +41 -0
- package/src/index.ts +8 -0
- package/src/lazy.ts +3 -2
- package/src/portal.ts +5 -2
- package/src/pragma/index.ts +2 -1
- package/src/suspense.ts +5 -2
- package/src/switchable.ts +2 -1
- package/src/transition.ts +5 -2
- package/src/vike/onRenderClient.ts +3 -2
|
@@ -98,7 +98,8 @@ function componentVNode(comp, key, stateField, children, compInitialState) {
|
|
|
98
98
|
children,
|
|
99
99
|
text: undefined,
|
|
100
100
|
elm: undefined,
|
|
101
|
-
key:
|
|
101
|
+
// no vnode key: it would be the instance identity (D456); `id` is (G-207)
|
|
102
|
+
key: undefined,
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
105
|
/**
|
|
@@ -127,7 +128,7 @@ function pageChildVNode(pageState, stateField = 'page') {
|
|
|
127
128
|
children: [],
|
|
128
129
|
text: undefined,
|
|
129
130
|
elm: undefined,
|
|
130
|
-
key:
|
|
131
|
+
key: undefined,
|
|
131
132
|
};
|
|
132
133
|
}
|
|
133
134
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onRenderClient.cjs.js","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":["run"],"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,CAAC;AAAE,YAAA,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,CAAA;KAAE;IAAC,MAAM,GAAE;AACrH,IAAA,OAAO,CAAC,CAAA;AACV,CAAC;;ACbD;;;;;;;;;;;;;;;AAeG;AAEH;AACA;AA6BA;AACA,IAAI,UAAU,GAA6D,IAAI,CAAA;AAE/E;;;AAGG;AACH,IAAI,WAAW,GAAQ,IAAI,CAAA;AAC3B,IAAI,eAAe,GAAW,EAAE,CAAA;AAChC,IAAI,eAAe,GAAQ,EAAE,CAAA;AAC7B,IAAI,kBAAkB,GAAQ,EAAE,CAAA;AAChC,IAAI,kBAAkB,GAAW,EAAE,CAAA;AACnC,IAAI,cAAc,GAAW,CAAC,CAAA;AAE9B;;;;;AAKG;AACH,SAAS,OAAO,CAAC,GAAW,EAAA;AAC1B,IAAA,OAAO,GAAG,IAAI,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AACvE,CAAC;AAED;;;;;AAKG;AACH,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAY,CAAA;AACxC,SAAS,OAAO,C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GAAQ,EAAE;AACjB,YAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAA;YACxD,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;YACtD,IAAI,SAAS,EAAE;gBACb,SAAS,CAAC,SAAS,GAAG,CAAA;;AAEb,eAAA,EAAA,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAA;eAC5B,CAAA;aACR;SACF;KACF;;AAGD,IAAA,IAAI,MAAM,CAAC,KAAK,EAAE;AAChB,QAAA,QAAQ,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;KAC9B;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"onRenderClient.cjs.js","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 // no vnode key: it would be the instance identity (D456); `id` is (G-207)\n key: undefined,\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: undefined,\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":["run"],"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,CAAC;AAAE,YAAA,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,CAAA;KAAE;IAAC,MAAM,GAAE;AACrH,IAAA,OAAO,CAAC,CAAA;AACV,CAAC;;ACbD;;;;;;;;;;;;;;;AAeG;AAEH;AACA;AA6BA;AACA,IAAI,UAAU,GAA6D,IAAI,CAAA;AAE/E;;;AAGG;AACH,IAAI,WAAW,GAAQ,IAAI,CAAA;AAC3B,IAAI,eAAe,GAAW,EAAE,CAAA;AAChC,IAAI,eAAe,GAAQ,EAAE,CAAA;AAC7B,IAAI,kBAAkB,GAAQ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W,EAAE,MAAM,kBAAkB;AACrC,YAAA,WAAW,EAAE,MAAM,kBAAkB;SACtC,CAAA;AAED,QAAA,IAAI;;;;AAIF,YAAA,MAAM,SAAS,GAAG,WAAW,CAAC,WAAW,IAAI,WAAW,CAAA;AACxD,YAAA,UAAU,GAAGA,UAAG,CAAC,IAAI,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,CAAQ,CAAA;SAC9I;QAAC,OAAO,GAAQ,EAAE;AACjB,YAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAA;YACxD,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;YACtD,IAAI,SAAS,EAAE;gBACb,SAAS,CAAC,SAAS,GAAG,CAAA;;AAEb,eAAA,EAAA,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAA;eAC5B,CAAA;aACR;SACF;KACF;;AAGD,IAAA,IAAI,MAAM,CAAC,KAAK,EAAE;AAChB,QAAA,QAAQ,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;KAC9B;AACH;;;;"}
|
|
@@ -96,7 +96,8 @@ function componentVNode(comp, key, stateField, children, compInitialState) {
|
|
|
96
96
|
children,
|
|
97
97
|
text: undefined,
|
|
98
98
|
elm: undefined,
|
|
99
|
-
key:
|
|
99
|
+
// no vnode key: it would be the instance identity (D456); `id` is (G-207)
|
|
100
|
+
key: undefined,
|
|
100
101
|
};
|
|
101
102
|
}
|
|
102
103
|
/**
|
|
@@ -125,7 +126,7 @@ function pageChildVNode(pageState, stateField = 'page') {
|
|
|
125
126
|
children: [],
|
|
126
127
|
text: undefined,
|
|
127
128
|
elm: undefined,
|
|
128
|
-
key:
|
|
129
|
+
key: undefined,
|
|
129
130
|
};
|
|
130
131
|
}
|
|
131
132
|
/**
|
|
@@ -1 +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,CAAC;AAAE,YAAA,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,CAAA;KAAE;IAAC,MAAM,GAAE;AACrH,IAAA,OAAO,CAAC,CAAA;AACV,CAAC;;ACbD;;;;;;;;;;;;;;;AAeG;AAEH;AACA;AA6BA;AACA,IAAI,UAAU,GAA6D,IAAI,CAAA;AAE/E;;;AAGG;AACH,IAAI,WAAW,GAAQ,IAAI,CAAA;AAC3B,IAAI,eAAe,GAAW,EAAE,CAAA;AAChC,IAAI,eAAe,GAAQ,EAAE,CAAA;AAC7B,IAAI,kBAAkB,GAAQ,EAAE,CAAA;AAChC,IAAI,kBAAkB,GAAW,EAAE,CAAA;AACnC,IAAI,cAAc,GAAW,CAAC,CAAA;AAE9B;;;;;AAKG;AACH,SAAS,OAAO,CAAC,GAAW,EAAA;AAC1B,IAAA,OAAO,GAAG,IAAI,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AACvE,CAAC;AAED;;;;;AAKG;AACH,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAY,CAAA;AACxC,SAAS,OAAO,CAAC,IAAS,EAAE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,YAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAA;YACxD,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;YACtD,IAAI,SAAS,EAAE;gBACb,SAAS,CAAC,SAAS,GAAG,CAAA;;AAEb,eAAA,EAAA,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAA;eAC5B,CAAA;aACR;SACF;KACF;;AAGD,IAAA,IAAI,MAAM,CAAC,KAAK,EAAE;AAChB,QAAA,QAAQ,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;KAC9B;AACH;;;;"}
|
|
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 // no vnode key: it would be the instance identity (D456); `id` is (G-207)\n key: undefined,\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: undefined,\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,CAAC;AAAE,YAAA,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,CAAA;KAAE;IAAC,MAAM,GAAE;AACrH,IAAA,OAAO,CAAC,CAAA;AACV,CAAC;;ACbD;;;;;;;;;;;;;;;AAeG;AAEH;AACA;AA6BA;AACA,IAAI,UAAU,GAA6D,IAAI,CAAA;AAE/E;;;AAGG;AACH,IAAI,WAAW,GAAQ,IAAI,CAAA;AAC3B,IAAI,eAAe,GAAW,EAAE,CAAA;AAChC,IAAI,eAAe,GAAQ,EAAE,CAAA;AAC7B,IAAI,kBAAkB,GAAQ,EAAE,CAAA;AAChC,IAAI,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C,YAAA,WAAW,EAAE,MAAM,kBAAkB;SACtC,CAAA;AAED,QAAA,IAAI;;;;AAIF,YAAA,MAAM,SAAS,GAAG,WAAW,CAAC,WAAW,IAAI,WAAW,CAAA;AACxD,YAAA,UAAU,GAAG,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,CAAQ,CAAA;SAC9I;QAAC,OAAO,GAAQ,EAAE;AACjB,YAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAA;YACxD,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;YACtD,IAAI,SAAS,EAAE;gBACb,SAAS,CAAC,SAAS,GAAG,CAAA;;AAEb,eAAA,EAAA,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAA;eAC5B,CAAA;aACR;SACF;KACF;;AAGD,IAAA,IAAI,MAAM,CAAC,KAAK,EAAE;AAChB,QAAA,QAAQ,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;KAC9B;AACH;;;;"}
|
package/llms.txt
CHANGED
|
@@ -248,15 +248,17 @@ TaskPage.model = { // a page shares the parent's state: no initialState (SYG40
|
|
|
248
248
|
- Links are plain `<a href={href(...)}>`, never click handlers: the driver intercepts same-origin left clicks at the document (not modified clicks, `target`, `download`, `rel="external"`, `data-router-ignore`, other origins). `params` and `query` values are strings; `href()` is typed from the route table (an unknown name or a missing param is a type error; SYG130/SYG131 at run time). `instance={state.route.path}` re-creates the page for `/tasks/1` → `/tasks/2`. Pages derive `resources` from `state.route.params`.
|
|
249
249
|
- ROUTER commands: `{ to, params, query, hash, replace, scroll }`, `{ url }`, `{ back: true }`, `{ forward: true }`, `{ go: n }`, `{ block: 'ACTION' | false }` (also stops back/forward; `proceed` navigates anyway), `{ prefetch: 'task', params }` (calls `makeRouter({ prefetch })`). `route` is reserved for the declaration. A bad command is SYG620. The first declarer (the root) gets each route first, so keep guards there.
|
|
250
250
|
- Options: `makeRouter({ routes, base: '/app', mode: 'hash', scroll, focus })`. SSR: `router.current(req.url)` in the seeded state; `renderToString(App, { head: list })` + `renderHead(list)`. Vike: `makeRouter({ routes, navigate })` with `navigate` from `'vike/client/router'`, registered in `pages/+drivers.js`. HEAD: a later-mounted component's title wins; `meta`/`link` merge; a model entry can also send `HEAD: (state, data) => ({ title })`. Guides: https://sygnal.js.org/guide/router/, https://sygnal.js.org/guide/head/
|
|
251
|
-
### AI (`sygnal/ai`): chat, agents, decisions
|
|
251
|
+
### AI (`sygnal/ai`): chat, agents, decisions, composed UI
|
|
252
252
|
- **A chat conversation** (send, streaming draft, Stop keeping the partial reply, Retry) is the `chat` behavior with no tools; don't hand-roll it: `Chat.uses = { chat: chat({ agent: false, form: '.ask', prompt: '.prompt', stop: '.stop', regenerate: '.retry' }) }` → `state.chat` (`messages`, `prompt` (bind `<input className="prompt" value={state.chat.prompt} />`), `draft`, `status`: `'ready' | 'submitted' | 'streaming' | 'error'`, `error`), the markup in the host's own view (SYG104), `next('chat.SEND', text)` to send from code, a host entry `'chat.DONE'` after a reply; options and slice: agent.md "Options and state". **One-off requests** (a summary, structured `output`, or your own state shape) are a driver request, like HTTP: `SEND: { STATE: (s) => ({ ...s, messages: [...s.messages, { role: 'user', content: s.prompt }], prompt: '' }), LLM: (s) => ({ messages: [...s.messages, { role: 'user', content: s.prompt }], key: 'reply', delta: 'DELTA', ok: 'DONE', error: 'FAILED' }) }` (both sinks see the state before the action: each builds the new message), `DELTA: (s, { text }) => ({ ...s, draft: text })` (all the text so far), `DONE: (s, { message }) => ({ ...s, messages: [...s.messages, message], draft: '' })` (also `text`, `toolCalls`, and `value` for `output: schema`), `FAILED` gets `{ error }`; `{ abort: 'reply' }` stops it (nothing more arrives; `latest` is on: a new request with the same key aborts the old); render with `messageText(m)`. main.js, a local Ollama: `run(App, { LLM: makeChatDriver({ transport: openResponses({ baseURL: 'http://localhost:11434/v1', model: 'llama3.2' }) }) })`; production: `transport: uiMessageStream('/api/chat')` (an AI SDK route on your server; the JSON it POSTs: ai-chat.md, "What uiMessageStream sends"). Tests need no driver: `await t.stream('LLM', ['Hel', 'lo'])` (then `ok`), `t.respond('LLM', text)`, `t.fail('LLM', 429)`, `t.requests('LLM')`.
|
|
253
253
|
- **`agent` static**: what an LLM may do in the app: `TodoApp.agent = { name: 'todos', description: 'The todo list', read: (state) => ({ todos: state.todos.map(({ id, text, done }) => ({ id, text, done })) }), actions: { ADD: { description: 'Add a todo', input: z.string().min(1) }, CLEAR_DONE: { description: 'Delete the done todos', consequential: true } } }` → tools `todos_add`, `todos_clear_done`, `todos_read`. **Only declared actions are tools, and `read` is all agents see** (a projection: keep ids, leave out secrets; `untrusted: true` when it holds text users typed). Per action: `input` (a Standard Schema with JSON Schema: zod 4.2+, or `jsonSchema({ type: 'string' })`), `consequential` (the user confirms), `when: (state) => bool`, `idempotent`, `until: 'search'` (the call answers once that resource has loaded, with the `read`, not `loading`; or `until: (state) => bool` for a reply action; `timeout` → `{ ok: true, pending: true }`); an entry counts as a trigger (SYG102); a Collection item's `agent` (+ `label: (s) => s.text`) gives one tool per action with an `id` parameter. Data too large for `read` (a long list, one record): `queries: { find: { description, input, run: (state, input) => state.todos.filter(…) } }` → read-only tool `todos_find`, `{ ok: true, result }`, nothing dispatched; `run` is pure and synchronous (async is SYG246: load data with an action + `until`). A reducer refuses with `abort('reason')` (from `'sygnal'`). Tests: `t.tools()`, `await t.callTool('todos_add', { value: 'milk' })` → `{ ok: true, state }` (a consequential tool needs `{ confirm: true }`), `t.agentContext()`.
|
|
254
254
|
- **Decisions** (typed answers from a decision model; a fetch-driver request, `HTTP: makeFetchDriver()`): `const questions = { topic: choice('What is this ticket about?', { billing: 'Payments, invoices', bug: 'Something is broken' }), urgent: noul('Does it need handling today?'), mood: score('How upset is the customer?', ['calm', 'annoyed', 'angry']) }`, as a resource: `Ticket.resources = { triage: (state) => state.text && decide({ model: 'jev-latest', state: state.text, questions }) }` → `state.triage.data.answers.topic.choice` (`.confidence`: below ~0.6, ask a chat model), `answers.urgent.noul` (0–1), `answers.mood.score`; a click-triggered one is an `HTTP` sink `decide({ …, ok, error })`. Tests: `await t.respond('HTTP', answers(questions, { topic: 'bug', urgent: true }), 'triage')`.
|
|
255
|
-
- **
|
|
256
|
-
-
|
|
255
|
+
- **A page a model composes from your parts** (a dashboard the user describes in words; the model only picks parts, params and places, never markup): `const catalog = defineCatalog({ parts: { revenue: { component: Kpi, props: { metric: 'revenue' }, description: 'Revenue (KPI card: the total this month)' }, orders: { component: OrdersTable, description: 'Orders (table of recent orders)', params: { status: { default: 'any', options: { any: 'orders of every status', pending: 'pending orders (not paid yet)' } } } }, tasks: { component: Checklist, state: 'tasks', description: "Tasks (the user's checklist)" } } })` (`description` is all a model sees: "Noun (what it shows)", no overlap between parts; params arrive as props; `state` is a key, a lens, or for a record param (`{ from: (state) => records }`) `(node) => byId('customers', node.params.id)` with `byId` from `'sygnal'`; `containers: { tabs: { slots, render: ({ slots, control }) => … } }` are view functions, never components (SYG161)), `Dashboard.uses = { page: compose(catalog, { backend: compose.decisions({ model: 'jev-latest' }), form: '.ask', prompt: '.prompt' }) }` (or `compose.llm()` on the `LLM` sink: same app, same tests) → `state.page` (`status`: `'composing' | 'preview' | 'done' | 'unavailable' | 'error'`, `layout`, `decisions`, `error`), rendered in the host's view as `{catalog.render(state.page, state)}` or `<Composed catalog={catalog} from="page" />`: the parts are the host's children (lenses, `CHILD.select`) keyed by identity, so a follow-up `next('page.COMPOSE', 'Move the orders to the top')` edits the page and keeps the untouched parts' instances (`{ prompt, fresh: true }` starts over; `persist` the slice to keep the page); for an agent: `actions: { ...compose.action('page') }`, `read: (s) => ({ page: compose.summary(s.page) })`. Tests (either backend): `t.simulateAction('page.COMPOSE', 'Pending orders')`, then `await composeWith(t, catalog, [{ part: 'orders', params: { status: 'pending' } }])`.
|
|
256
|
+
- **Cards in a chat** (the assistant asks with your parts; the user clicks the answer): `uses = { assistant: chat({ form: '.ask', prompt: '.prompt', ask: { catalog } }) }` gives the model the tool `ask_user({ need })`; the card composes from the catalog (`compose.llm()` on the chat's sink by default, or `ask: { catalog, backend: compose.decisions({ model: 'jev-latest' }) }`) and lives on the tool part as `part.ui` (`status`: `'composing' | 'open' | 'answered' | 'failed' | 'cancelled'`; persisted with the chat): render it where the view renders a `tool-ask_user` message part, `askCard(catalog, state, part) ?? <p>Composing…</p>`. A part with `result: true` answers it: `PICK: { PARENT: (state, id, next, props) => compose.answer(props, id) }` → the call's output is `{ part, answer }` and the chat goes on (no result part in the catalog: SYG686). Tools the app answers itself: `clientTools: { confirm: { description, inputSchema } }`, listed by `openToolCalls(state.assistant)`, answered with `next('assistant.TOOL_OUTPUT', { toolCallId, output })`. `chat({ model: (state) => state.chatModel })` picks the model per request. Tests: `await t.stream('LLM', [{ toolCall: { id: 'c1', name: 'ask_user', input: { need: 'Pick a plan' } } }])`, then `await composeWith(t, catalog, [{ part: 'plans' }])`.
|
|
257
|
+
- **Never put a provider API key in browser code**: the browser calls your server (`uiMessageStream('/api/chat')`, the default `/api/decide` of `decide()` and `compose.decisions()`), which adds the key, fixes the model and instructions, and rate-limits; an auth header to another origin is refused (SYG670). Strict provider schemas: `openResponses({ baseURL, model, strict: strictSchemas })` (an import; `strict: true` is SYG672). Every request sends the whole conversation (models are stateless); never `fetch` a provider from a component.
|
|
258
|
+
- Guides: `node_modules/sygnal/dist/guide/ai-chat.md` (transports, structured `output`, tools, shipping), `ai-decisions.md` (escalation, `decide.openai()`), `ai-compose.md` (catalogs, containers, edits, `byId`), `ai-cards.md` (`chat({ ask })`, client tools), `agent.md` (the in-app assistant `uses = { assistant: chat({ form: '.ask', prompt: '.prompt', instructions }) }`, `commandBar`, security), `webmcp.md` (`experimentalExposeWebMcp(app)`, `form(schema, { tool: formTool({ name, description }) })`: experimental, outside semver), `mcp-apps.md` (`makeMcpAppDriver()`: the app inside Claude or ChatGPT); online https://sygnal.js.org/guide/ai-chat/ (and `/guide/ai-decisions/`, `/guide/ai-compose/`, `/guide/ai-cards/`, `/guide/agent/`, `/guide/webmcp/`, `/guide/mcp-apps/`)
|
|
257
259
|
|
|
258
260
|
## 4. API facts
|
|
259
|
-
- **Child props**: `<Rating name="food" value={state.food} />` → `function Rating({ state, name, value })`; reducers read `props.name` (4th arg); intent gets the `props$` stream. Reserved: `state` (lens: `"key"` or `{ get, set }`), `children`, `slots`, `context`, `uid` (SYG106; an error in strict mode). Without `state=` a child shares its parent's whole state. A child rendered by tag (`<Stopwatch state="stopwatch" />`) has no `initialState`: its start values go in the parent's (`stopwatch: { ms: 0 }`); its own throws SYG405 and the parent renders its error fallback (a test rendering the child as the root doesn't show it). Test a child alone with `renderComponent(Child, { initialState, context: { lang: 'fr' } })` (the ancestors' context). `uid(name?)` (a view prop, also on reducers' `props`) is a stable per-instance id for `id`/`for`/`aria-*` pairs: `<label for={uid('email')}>`, `<input id={uid('email')} />`.
|
|
261
|
+
- **Child props**: `<Rating name="food" value={state.food} />` → `function Rating({ state, name, value })`; reducers read `props.name` (4th arg); intent gets the `props$` stream. Reserved: `state` (lens: `"key"` or `{ get, set }`), `children`, `slots`, `context`, `uid` (SYG106; an error in strict mode). `key={…}` is a child's identity (not a prop; else its `id` prop, else its place in the view): a new key re-creates it. Without `state=` a child shares its parent's whole state. A child rendered by tag (`<Stopwatch state="stopwatch" />`) has no `initialState`: its start values go in the parent's (`stopwatch: { ms: 0 }`); its own throws SYG405 and the parent renders its error fallback (a test rendering the child as the root doesn't show it). Test a child alone with `renderComponent(Child, { initialState, context: { lang: 'fr' } })` (the ancestors' context). `uid(name?)` (a view prop, also on reducers' `props`) is a stable per-instance id for `id`/`for`/`aria-*` pairs: `<label for={uid('email')}>`, `<input id={uid('email')} />`.
|
|
260
262
|
- **A sliced child with its own start values**: `Editor.isolatedState = true` lets `<Editor state="draft" />` keep an `initialState`, used only while `state.draft` is `undefined` (an existing slice is kept; SYG425 warns when it lacks keys the `initialState` has). To start it from its `initialState` on every mount: `<Editor state="draft" resetState />`.
|
|
261
263
|
- **CHILD.select(Comp)** emits exactly what the child's `PARENT` function returned, for every instance (Collection items too). Put an id in the payload.
|
|
262
264
|
- **Extract a component without changing markup**: snapshot `t.html()` on the unchanged code first; move the elements verbatim into the child (a component adds no wrapper element and no attributes, so the HTML stays identical); props in, `PARENT` out; the parent drops its old selectors and uses `CHILD.select(Child)`; the snapshot must still match. Recipe: https://sygnal.js.org/guide/parent-child/#recipe-extract-a-component-without-changing-the-markup
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sygnal",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"description": "An intuitive framework for building fast and small components or applications based on Cycle.js",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -138,6 +138,7 @@
|
|
|
138
138
|
"test:examples": "node scripts/test-examples.mjs",
|
|
139
139
|
"test:recipes": "node scripts/test-recipes.mjs",
|
|
140
140
|
"test:ai-local": "vitest run --testTimeout=600000 ollama.test",
|
|
141
|
+
"test:compose-live": "node --env-file-if-exists=\"${TYPESAFE_ENV_FILE:-$HOME/.config/typesafe/env}\" scripts/compose-live.mjs",
|
|
141
142
|
"test:types": "npx tsc --project tsconfig.json --noEmit && npx tsc --project type-tests/tsconfig.json",
|
|
142
143
|
"test:browser": "npm test --prefix browser-tests",
|
|
143
144
|
"test:watch": "vitest",
|