@askrjs/askr 0.0.42 → 0.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/benchmark.js +2 -2
- package/dist/boot/index.d.ts.map +1 -1
- package/dist/boot/index.js +2 -0
- package/dist/boot/index.js.map +1 -1
- package/dist/common/route-activity.js +30 -0
- package/dist/common/route-activity.js.map +1 -0
- package/dist/common/router.d.ts +4 -2
- package/dist/common/router.d.ts.map +1 -1
- package/dist/common/ssr.d.ts +22 -1
- package/dist/common/ssr.d.ts.map +1 -1
- package/dist/common/ssr.js +9 -1
- package/dist/common/ssr.js.map +1 -1
- package/dist/data/index.d.ts +21 -2
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +56 -3
- package/dist/data/index.js.map +1 -1
- package/dist/data/invalidation-listeners.js +15 -0
- package/dist/data/invalidation-listeners.js.map +1 -0
- package/dist/renderer/dom.js +23 -15
- package/dist/renderer/dom.js.map +1 -1
- package/dist/renderer/evaluate.js +9 -13
- package/dist/renderer/evaluate.js.map +1 -1
- package/dist/renderer/for-commit.js +9 -0
- package/dist/renderer/for-commit.js.map +1 -1
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +2 -2
- package/dist/router/match.js +31 -6
- package/dist/router/match.js.map +1 -1
- package/dist/router/navigate.d.ts.map +1 -1
- package/dist/router/navigate.js +30 -4
- package/dist/router/navigate.js.map +1 -1
- package/dist/router/route.d.ts +10 -1
- package/dist/router/route.d.ts.map +1 -1
- package/dist/router/route.js +38 -8
- package/dist/router/route.js.map +1 -1
- package/dist/runtime/component.d.ts +7 -1
- package/dist/runtime/component.d.ts.map +1 -1
- package/dist/runtime/component.js +205 -44
- package/dist/runtime/component.js.map +1 -1
- package/dist/runtime/fastlane.js +6 -0
- package/dist/runtime/fastlane.js.map +1 -1
- package/dist/runtime/operations.d.ts +11 -3
- package/dist/runtime/operations.d.ts.map +1 -1
- package/dist/runtime/operations.js +161 -22
- package/dist/runtime/operations.js.map +1 -1
- package/dist/runtime/readable.d.ts +1 -0
- package/dist/runtime/readable.d.ts.map +1 -1
- package/dist/runtime/readable.js +7 -4
- package/dist/runtime/readable.js.map +1 -1
- package/dist/ssg/batch-render.js +27 -5
- package/dist/ssg/batch-render.js.map +1 -1
- package/dist/ssg/create-static-gen.d.ts.map +1 -1
- package/dist/ssg/create-static-gen.js +6 -4
- package/dist/ssg/create-static-gen.js.map +1 -1
- package/dist/ssg/index.d.ts +2 -1
- package/dist/ssg/resolve-ssg-data.js +18 -1
- package/dist/ssg/resolve-ssg-data.js.map +1 -1
- package/dist/ssg/types.d.ts +3 -0
- package/dist/ssg/types.d.ts.map +1 -1
- package/dist/ssr/context.d.ts +1 -2
- package/dist/ssr/context.d.ts.map +1 -1
- package/dist/ssr/index.d.ts +10 -11
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/index.js +104 -68
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/render-resolved.d.ts +1 -1
- package/dist/testing/index.d.ts +53 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +172 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +12 -4
package/dist/benchmark.js
CHANGED
|
@@ -10,8 +10,8 @@ import { BenchmarkTable } from "./bench/components/benchmark-table.js";
|
|
|
10
10
|
installRendererBridge();
|
|
11
11
|
const benchmarkMetadata = {
|
|
12
12
|
packageName: "@askrjs/askr",
|
|
13
|
-
packageVersion: "0.0.
|
|
14
|
-
buildLabel: "0.0.
|
|
13
|
+
packageVersion: "0.0.44",
|
|
14
|
+
buildLabel: "0.0.44-local"
|
|
15
15
|
};
|
|
16
16
|
function getBenchmarkMetadata() {
|
|
17
17
|
return { ...benchmarkMetadata };
|
package/dist/boot/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/boot/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/boot/index.ts"],"mappings":";;;;;KAkXY,YAAA;EACV,IAAA,EAAM,OAAA;EACN,SAAA,EAAW,iBAAiB;EAE5B,aAAA;EAEA,MAAA;AAAA;AAAA,KAGU,aAAA;EACV,OAAA,EAAS,YAAY;AAAA;AAAA,KAGlB,eAAA;EAEC,QAAA,EAAU,aAAA;EACV,MAAA,GAAS,KAAA;AAAA;EAGT,QAAA,GAAW,aAAA;EACX,MAAA,EAAQ,KAAA;AAAA;AAAA,KAGF,SAAA,GAAY,eAAA;EACtB,IAAA,EAAM,OAAA;EAXY;;;;;;;EAmBlB,IAAA,GAAO,gBAAA;EACP,iBAAA,aAA8B,wBAAA;EAC9B,aAAA;EACA,SAAA;AAAA;AAAA,KAGU,gBAAA,GAAmB,eAAA;EAC7B,IAAA,EAAM,OAAA,WAnBF;EAqBJ,IAAA,GAAO,gBAAA;EACP,iBAAA,aAA8B,wBAAA;EAC9B,aAAA;EACA,OAAA;IACE,YAAA;IACA,cAAA;IACA,cAAA;IACA,aAAA;IACA,aAAA;EAAA;AAAA;;;;iBAkDY,YAAA,CAAa,MAAoB,EAAZ,YAAY;;;;;iBA6CjC,aAAA,CAAc,MAAqB,EAAb,aAAa;;;AA7GxC;AAGX;;;;;;;;;;;iBAqIsB,SAAA,CAAU,MAAA,EAAQ,SAAA,GAAY,OAAO;;;;;iBA4VrC,UAAA,CAAW,MAAA,EAAQ,gBAAA,GAAmB,OAAO;;;;;iBAuJnD,UAAA,CAAW,IAAsB,EAAhB,OAAO;;;AA7mBvB;iBAsoBD,MAAA,CAAO,IAAsB,EAAhB,OAAO"}
|
package/dist/boot/index.js
CHANGED
|
@@ -154,6 +154,8 @@ function mountOrUpdate(rootElement, componentFn, options) {
|
|
|
154
154
|
instance.notifyUpdate = null;
|
|
155
155
|
instance.stateIndexCheck = -1;
|
|
156
156
|
instance.mountOperations = [];
|
|
157
|
+
instance.commitOperations = [];
|
|
158
|
+
instance.lifecycleSlots = [];
|
|
157
159
|
instance.cleanupFns = [];
|
|
158
160
|
instance._currentRenderToken = void 0;
|
|
159
161
|
instance.lastRenderToken = 0;
|
package/dist/boot/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/boot/index.ts"],"sourcesContent":["/**\n * App bootstrap and mount\n */\n\nimport {\n createComponentInstance,\n mountComponent,\n cleanupComponent,\n type ComponentFunction,\n type ComponentInstance,\n} from '../runtime/component';\nimport {\n isDevelopmentEnvironment,\n isProductionEnvironment,\n} from '../common/env';\nimport { logger } from '../dev/logger';\nimport {\n initializeNavigation,\n registerAppInstance,\n unregisterAppInstance,\n} from '../router/navigate';\nimport {\n configureScrollRestoration,\n type ScrollRestorationOptions,\n} from '../router/navigate';\nimport {\n _applyManifest,\n _drainLazy,\n _setActiveRouteAuthOptions,\n _snapshotLazy,\n clearRoutes,\n lockRouteRegistration,\n resolveRouteRequest,\n route as registerRoute,\n setServerLocation,\n} from '../router/route';\nimport { globalScheduler } from '../runtime/scheduler';\nimport { assertExecutionModel } from '../runtime/execution-model';\nimport { setStaticChildSlotsCacheEnabled } from '../renderer/dom';\nimport { isPromiseLike } from '../common/promise';\nimport { SSR_RENDER_DATA_ATTR, type SSRData } from '../common/ssr';\nimport {\n startHydrationRenderPhase,\n stopHydrationRenderPhase,\n} from '../ssr/render-keys';\n\nconst HAS_ROUTES_KEY = Symbol.for('__ASKR_HAS_ROUTES__');\n\nlet componentIdCounter = 0;\n\n// Track instances by root element to support multiple createIsland calls on same root\nconst instancesByRoot = new WeakMap<Element, ComponentInstance>();\n\n// Symbol for storing cleanup on elements\nconst CLEANUP_SYMBOL = Symbol.for('__askrCleanup__');\nconst ROOT_CLEANUP_CALLBACKS_SYMBOL = Symbol.for(\n '__askrRootCleanupCallbacks__'\n);\n\ntype RootCleanupOptions = {\n preserveInstance?: boolean;\n};\n\n// Type for elements that have cleanup functions attached\ninterface ElementWithCleanup extends Element {\n [CLEANUP_SYMBOL]?: (options?: RootCleanupOptions) => void;\n [ROOT_CLEANUP_CALLBACKS_SYMBOL]?: Set<() => void>;\n}\n\nfunction takeHydrationRenderData(rootElement: Element): SSRData | null {\n for (const child of Array.from(rootElement.children)) {\n if (\n child instanceof HTMLScriptElement &&\n child.getAttribute(SSR_RENDER_DATA_ATTR) === 'true'\n ) {\n const raw = child.textContent ?? '';\n child.remove();\n if (!raw) {\n return {};\n }\n\n try {\n return JSON.parse(raw) as SSRData;\n } catch (err) {\n throw new Error(\n '[Askr] Failed to parse embedded SSR render data during hydration.',\n { cause: err }\n );\n }\n }\n }\n\n return null;\n}\n\nfunction clearRootCleanupCallbacks(rootElement: Element): void {\n try {\n delete (rootElement as ElementWithCleanup)[ROOT_CLEANUP_CALLBACKS_SYMBOL];\n } catch {\n (rootElement as ElementWithCleanup)[ROOT_CLEANUP_CALLBACKS_SYMBOL]?.clear();\n }\n}\n\nfunction registerRootCleanupCallback(\n rootElement: Element,\n callback: () => void\n): () => void {\n const elementWithCleanup = rootElement as ElementWithCleanup;\n const callbacks =\n elementWithCleanup[ROOT_CLEANUP_CALLBACKS_SYMBOL] ?? new Set();\n callbacks.add(callback);\n elementWithCleanup[ROOT_CLEANUP_CALLBACKS_SYMBOL] = callbacks;\n\n return () => {\n callbacks.delete(callback);\n if (callbacks.size === 0) {\n clearRootCleanupCallbacks(rootElement);\n }\n };\n}\n\nfunction runRootCleanupCallbacks(\n rootElement: Element,\n errors: unknown[]\n): void {\n const callbacks = (rootElement as ElementWithCleanup)[\n ROOT_CLEANUP_CALLBACKS_SYMBOL\n ];\n if (!callbacks || callbacks.size === 0) {\n clearRootCleanupCallbacks(rootElement);\n return;\n }\n\n clearRootCleanupCallbacks(rootElement);\n for (const callback of callbacks) {\n try {\n callback();\n } catch (e) {\n errors.push(e);\n }\n }\n}\n\nfunction cleanupRootInstance(\n rootElement: Element,\n instance: ComponentInstance,\n options?: RootCleanupOptions\n) {\n // Attempt to remove listeners and cleanup instances under the root.\n // In non-strict mode we preserve previous behavior by swallowing errors\n // (but logging in dev); in strict mode we aggregate and re-throw.\n const errors: unknown[] = [];\n try {\n teardownNodeSubtree(rootElement);\n } catch (e) {\n errors.push(e);\n }\n\n try {\n cleanupComponent(instance);\n } catch (e) {\n errors.push(e);\n }\n\n runRootCleanupCallbacks(rootElement, errors);\n\n if (!options?.preserveInstance) {\n unregisterAppInstance(instance);\n instancesByRoot.delete(rootElement);\n clearRootCleanupCallbacks(rootElement);\n try {\n delete (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n } catch {\n // Ignore cleanup marker removal failures.\n }\n }\n\n if (errors.length > 0) {\n if (instance.cleanupStrict) {\n throw new AggregateError(errors, `cleanup failed for app root`);\n } else if (isDevelopmentEnvironment()) {\n for (const err of errors) logger.warn('[Askr] cleanup error:', err);\n }\n }\n}\n\nfunction attachCleanupForRoot(\n rootElement: Element,\n instance: ComponentInstance\n) {\n (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL] = (options) => {\n cleanupRootInstance(rootElement, instance, options);\n };\n\n try {\n const descriptor =\n Object.getOwnPropertyDescriptor(rootElement, 'innerHTML') ||\n Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(rootElement),\n 'innerHTML'\n ) ||\n Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML');\n\n if (descriptor && (descriptor.get || descriptor.set)) {\n Object.defineProperty(rootElement, 'innerHTML', {\n get: descriptor.get\n ? function (this: Element) {\n return descriptor.get!.call(this);\n }\n : undefined,\n set: function (this: Element, value: string) {\n if (value === '' && instancesByRoot.get(this) === instance) {\n cleanupRootInstance(rootElement, instance);\n }\n if (descriptor.set) {\n return descriptor.set.call(this, value);\n }\n },\n configurable: true,\n });\n }\n } catch {\n // If Object.defineProperty fails, ignore\n }\n}\n\nimport { Fragment, ELEMENT_TYPE } from '../jsx';\n\nimport { DefaultPortal } from '../foundations/structures/portal';\nimport { disposeDefaultPortalScope } from '../foundations/structures/portal';\n\nfunction mountOrUpdate(\n rootElement: Element,\n componentFn: ComponentFunction,\n options?: { cleanupStrict?: boolean }\n) {\n // Ensure root component always includes a DefaultPortal host by wrapping it.\n const wrappedFn: ComponentFunction = (props, ctx) => {\n const out = componentFn(props, ctx);\n if (isPromiseLike(out)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n const portalVNode = {\n $$typeof: ELEMENT_TYPE,\n type: DefaultPortal,\n props: {},\n key: '__default_portal',\n } as unknown;\n return {\n $$typeof: ELEMENT_TYPE,\n type: Fragment,\n props: {\n children:\n out === undefined || out === null\n ? [portalVNode]\n : [out, portalVNode],\n },\n } as unknown as ReturnType<ComponentFunction>;\n };\n // Preserve the original component name for debugging/dev warnings\n Object.defineProperty(wrappedFn, 'name', {\n value: componentFn.name || 'Component',\n });\n\n // Clean up existing cleanup function before mounting new one\n const existingCleanup = (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n const reusedExistingInstance = typeof existingCleanup === 'function';\n if (reusedExistingInstance) {\n existingCleanup({ preserveInstance: true });\n }\n\n let instance = instancesByRoot.get(rootElement);\n\n if (instance) {\n const shouldResetHookState = instance.fn.name !== wrappedFn.name;\n\n if (!reusedExistingInstance) {\n removeAllListeners(rootElement);\n try {\n cleanupComponent(instance);\n } catch (e) {\n // If previous cleanup threw in strict mode, log but continue mounting new instance\n if (isDevelopmentEnvironment()) {\n logger.warn('[Askr] prior cleanup threw:', e);\n }\n }\n }\n\n instance.fn = wrappedFn;\n instance.evaluationGeneration++;\n instance.mounted = false;\n instance.expectedStateIndices = [];\n instance.firstRenderComplete = false;\n instance.isRoot = true;\n instance.portalScope = instance;\n\n if (shouldResetHookState) {\n instance.stateValues = [];\n instance.hasPendingUpdate = false;\n instance.notifyUpdate = null;\n instance.stateIndexCheck = -1;\n instance.mountOperations = [];\n instance.cleanupFns = [];\n instance._currentRenderToken = undefined;\n instance.lastRenderToken = 0;\n instance._pendingReadSources = undefined;\n instance._lastReadSources = undefined;\n instance._placeholder = undefined;\n instance.errorBoundaryState = undefined;\n instance.devWarningsEmitted = undefined;\n }\n\n // Update strict flag if provided\n if (options && typeof options.cleanupStrict === 'boolean') {\n instance.cleanupStrict = options.cleanupStrict;\n }\n } else {\n const componentId = String(++componentIdCounter);\n instance = createComponentInstance(componentId, wrappedFn, {}, rootElement);\n instancesByRoot.set(rootElement, instance);\n instance.isRoot = true;\n instance.portalScope = instance;\n // Initialize strict flag from options\n if (options && typeof options.cleanupStrict === 'boolean') {\n instance.cleanupStrict = options.cleanupStrict;\n }\n }\n\n attachCleanupForRoot(rootElement, instance);\n registerRootCleanupCallback(rootElement, () => {\n disposeDefaultPortalScope(instance.portalScope ?? instance);\n });\n mountComponent(instance);\n globalScheduler.flush();\n}\n\nfunction bindResolvedRouteHandler(resolved: ResolvedRoute): ComponentFunction {\n return () =>\n resolved.handler(resolved.params) as ReturnType<ComponentFunction>;\n}\n\nfunction bindDeniedStatus(status: number): ComponentFunction {\n return () => ({\n type: 'div',\n props: {\n 'data-route-denied': String(status),\n },\n children: [String(status)],\n });\n}\n\n// New strongly-typed init functions\nimport type {\n Route,\n RouteManifest,\n ResolvedRoute,\n RouteAuthOptions,\n RouteRequestResult,\n} from '../common/router';\nimport {\n installRendererBridge,\n removeAllListeners,\n teardownNodeSubtree,\n} from '../renderer';\ninstallRendererBridge();\n\nexport type IslandConfig = {\n root: Element | string;\n component: ComponentFunction;\n // Optional: surface cleanup errors during teardown for this island\n cleanupStrict?: boolean;\n // Explicitly disallow routes on islands at type level\n routes?: never;\n};\n\nexport type IslandsConfig = {\n islands: IslandConfig[];\n};\n\ntype BootRouteSource =\n | {\n manifest: RouteManifest;\n routes?: Route[];\n }\n | {\n manifest?: RouteManifest;\n routes: Route[];\n };\n\nexport type SPAConfig = BootRouteSource & {\n root: Element | string;\n /**\n * Preferred: pass the route manifest built via `registerRoutes(() => { ... })`.\n * ```ts\n * import { getManifest } from '@askrjs/askr/router';\n * await createSPA({ root: '#app', manifest: getManifest() });\n * ```\n */\n auth?: RouteAuthOptions;\n scrollRestoration?: boolean | ScrollRestorationOptions;\n cleanupStrict?: boolean;\n component?: never;\n};\n\nexport type HydrateSPAConfig = BootRouteSource & {\n root: Element | string;\n /** Preferred manifest input — see `SPAConfig.manifest`. */\n auth?: RouteAuthOptions;\n scrollRestoration?: boolean | ScrollRestorationOptions;\n cleanupStrict?: boolean;\n hydrate?: {\n verifyMarkup?: boolean;\n deferUntilIdle?: boolean;\n deferBelowFold?: boolean;\n foldThreshold?: number;\n skipSelectors?: string[];\n };\n};\n\nconst MAX_INITIAL_ROUTE_REDIRECTS = 20;\n\nasync function resolveInitialRoute(\n auth?: RouteAuthOptions\n): Promise<{ path: string; href: string; resolved: RouteRequestResult }> {\n let path = typeof window !== 'undefined' ? window.location.pathname : '/';\n let href =\n typeof window !== 'undefined'\n ? `${window.location.pathname}${window.location.search}${window.location.hash}`\n : path;\n const visited = new Set<string>();\n\n for (\n let redirects = 0;\n redirects <= MAX_INITIAL_ROUTE_REDIRECTS;\n redirects++\n ) {\n if (visited.has(href)) {\n throw new Error(`[Askr] Route redirect cycle detected at ${href}.`);\n }\n visited.add(href);\n\n const resolved = await resolveRouteRequest(href, { auth });\n if (\n typeof window === 'undefined' ||\n !resolved ||\n resolved.kind !== 'redirect'\n ) {\n return { path, href, resolved };\n }\n\n const redirectTarget = new URL(resolved.to, window.location.href);\n const redirectHref = `${redirectTarget.pathname}${redirectTarget.search}${redirectTarget.hash}`;\n window.history.replaceState({ path: redirectHref }, '', redirectHref);\n path = redirectTarget.pathname;\n href = redirectHref;\n }\n\n throw new Error(\n `[Askr] Route redirect limit exceeded (${MAX_INITIAL_ROUTE_REDIRECTS}).`\n );\n}\n\n/**\n * createIsland: Enhances existing DOM (no router, mounts once)\n */\nexport function createIsland(config: IslandConfig): void {\n assertExecutionModel('islands');\n if (!config || typeof config !== 'object') {\n throw new Error('createIsland requires a config object');\n }\n if (typeof config.component !== 'function') {\n throw new Error('createIsland: component must be a function');\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n\n // Islands must not initialize router or routes\n if ('routes' in config) {\n throw new Error(\n 'createIsland does not accept routes; use createSPA for routed apps'\n );\n }\n\n // Routes are never supported with islands.\n // If routes were registered (even at module load time), fail fast to avoid\n // surprising partial router behavior.\n try {\n const g = globalThis as unknown as Record<string | symbol, unknown>;\n if (g[HAS_ROUTES_KEY]) {\n throw new Error(\n 'Routes are not supported with islands. Use createSPA (client) or createSSR (server) instead.'\n );\n }\n } catch {\n // ignore\n }\n\n mountOrUpdate(rootElement, config.component, {\n cleanupStrict: config.cleanupStrict,\n });\n}\n\n/**\n * createIslands: Enhances one or more existing DOM roots (no router).\n * The only public islands constructor.\n */\nexport function createIslands(config: IslandsConfig): void {\n assertExecutionModel('islands');\n if (!config || typeof config !== 'object') {\n throw new Error('createIslands requires a config object');\n }\n if (!Array.isArray(config.islands) || config.islands.length === 0) {\n throw new Error('createIslands requires a non-empty islands array');\n }\n for (const island of config.islands) {\n createIsland(island);\n }\n}\n\n/**\n * createSPA: Initializes router and mounts the app with the provided route manifest or route table.\n *\n * Preferred usage with manifest:\n * ```ts\n * import { getManifest } from '@askrjs/askr/router';\n * await createSPA({ root: '#app', manifest: getManifest() });\n * ```\n *\n * Legacy usage with plain routes array (still supported):\n * ```ts\n * await createSPA({ root: '#app', routes: getRoutes() });\n * ```\n */\nexport async function createSPA(config: SPAConfig): Promise<void> {\n assertExecutionModel('spa');\n if (!config || typeof config !== 'object') {\n throw new Error('createSPA requires a config object');\n }\n\n const hasManifest =\n config.manifest != null && config.manifest.records.length > 0;\n const hasRoutes = Array.isArray(config.routes) && config.routes.length > 0;\n\n if (!hasManifest && !hasRoutes) {\n throw new Error(\n 'createSPA requires a route manifest or route table. ' +\n 'Pass `manifest: getManifest()` or `routes: getRoutes()`. ' +\n 'If you are enhancing existing HTML, use createIsland instead.'\n );\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n\n const pendingLazyAtBoot = _snapshotLazy();\n\n configureScrollRestoration(config.scrollRestoration);\n\n clearRoutes();\n\n if (hasManifest) {\n // Preferred path: apply pre-built manifest records directly\n _applyManifest(config.manifest!);\n } else {\n // Legacy path: register plain Route objects (no layout metadata)\n for (const r of config.routes!) {\n registerRoute(r.path, r.handler as Parameters<typeof registerRoute>[1]);\n }\n }\n\n const routeAuth = config.auth ?? config.manifest?.auth;\n _setActiveRouteAuthOptions(routeAuth);\n\n // Drain any lazy() imports so all split chunks are ready before mounting\n await _drainLazy(pendingLazyAtBoot);\n\n // Lock registration in production to prevent late registration surprises\n if (isProductionEnvironment()) lockRouteRegistration();\n\n // Mount the currently-resolved route handler (if any)\n const { path, resolved } = await resolveInitialRoute(routeAuth);\n\n if (!resolved) {\n mountOrUpdate(rootElement, () => ({ type: 'div', children: [] }), {\n cleanupStrict: config.cleanupStrict,\n });\n\n await registerAppNavigation(rootElement, path, {\n manifest: config.manifest,\n routes: config.routes,\n auth: routeAuth,\n });\n return;\n }\n\n if (resolved.kind === 'redirect') {\n mountOrUpdate(rootElement, () => ({ type: 'div', children: [] }), {\n cleanupStrict: config.cleanupStrict,\n });\n\n await registerAppNavigation(rootElement, path, {\n manifest: config.manifest,\n routes: config.routes,\n auth: routeAuth,\n });\n return;\n }\n\n mountOrUpdate(\n rootElement,\n resolved.kind === 'deny'\n ? bindDeniedStatus(resolved.status)\n : bindResolvedRouteHandler({\n handler: resolved.handler,\n params: resolved.params,\n }),\n {\n cleanupStrict: config.cleanupStrict,\n }\n );\n\n await registerAppNavigation(rootElement, path, {\n manifest: config.manifest,\n routes: config.routes,\n auth: routeAuth,\n });\n}\n\n/**\n * Mark elements that should be skipped during hydration\n */\nfunction markSkippedElements(root: Element, skipSelectors: string[]): void {\n if (skipSelectors.length === 0) {\n return;\n }\n\n const uniqueSelectors = Array.from(new Set(skipSelectors));\n const selectorList = uniqueSelectors.join(', ');\n const elements = root.querySelectorAll(selectorList);\n elements.forEach((el) => el.setAttribute('data-skip-hydrate', 'true'));\n}\n\nfunction collectDeferredBelowFoldBoundaries(\n root: Element,\n foldY: number\n): Element[] {\n const boundaries: Element[] = [];\n const stack: Element[] = [];\n\n for (let index = root.children.length - 1; index >= 0; index -= 1) {\n stack.push(root.children[index]);\n }\n\n while (stack.length > 0) {\n const element = stack.pop()!;\n\n if (element.hasAttribute('data-skip-hydrate')) {\n continue;\n }\n\n const rect = element.getBoundingClientRect();\n if (rect.top >= foldY) {\n element.setAttribute('data-skip-hydrate', 'true');\n boundaries.push(element);\n continue;\n }\n\n for (let index = element.children.length - 1; index >= 0; index -= 1) {\n stack.push(element.children[index]);\n }\n }\n\n return boundaries;\n}\n\nfunction activateVisibleDeferredBoundaries(\n boundaries: Element[],\n foldY: number\n): { activated: boolean; remaining: number } {\n let activated = false;\n let remaining = 0;\n\n for (const element of boundaries) {\n if (!element.hasAttribute('data-skip-hydrate')) {\n continue;\n }\n\n const rect = element.getBoundingClientRect();\n if (rect.top < foldY) {\n element.removeAttribute('data-skip-hydrate');\n activated = true;\n } else {\n remaining += 1;\n }\n }\n\n return { activated, remaining };\n}\n\nfunction queueIdleWork(work: () => void): Promise<void> {\n return new Promise((resolve) => {\n if (typeof requestIdleCallback !== 'undefined') {\n requestIdleCallback(\n () => {\n work();\n resolve();\n },\n { timeout: 2000 }\n );\n return;\n }\n\n setTimeout(() => {\n work();\n resolve();\n }, 0);\n });\n}\n\nfunction flushHydrationActivation(rootElement: Element): void {\n const instance = instancesByRoot.get(rootElement);\n if (!instance) return;\n instance._enqueueRun?.();\n globalScheduler.flush();\n}\n\nfunction shouldVerifyHydrationMarkup(config: HydrateSPAConfig): boolean {\n const explicit = config.hydrate?.verifyMarkup;\n if (typeof explicit === 'boolean') {\n return explicit;\n }\n\n return !isProductionEnvironment();\n}\n\nasync function registerAppNavigation(\n rootElement: Element,\n path: string,\n source?: {\n manifest?: RouteManifest;\n routes?: Route[];\n auth?: RouteAuthOptions;\n }\n) {\n const instance = instancesByRoot.get(rootElement);\n if (!instance) throw new Error('Internal error: app instance missing');\n registerAppInstance(instance as ComponentInstance, path, source);\n initializeNavigation();\n}\n\n/**\n * Apply selective hydration with deferral options\n */\nasync function applySelectiveHydration(\n rootElement: Element,\n resolved: { handler: ComponentFunction; params: Record<string, unknown> },\n path: string,\n cleanupStrict: boolean | undefined,\n hydrateOptions: NonNullable<HydrateSPAConfig['hydrate']>\n): Promise<void> {\n const hasPermanentSkips = (hydrateOptions.skipSelectors?.length ?? 0) > 0;\n const hasBelowFoldDeferral = !!hydrateOptions.deferBelowFold;\n const hasSelectiveBoundaries = hasPermanentSkips || hasBelowFoldDeferral;\n let staticChildSlotsCacheSuspended = false;\n let releaseSelectiveHydrationResources = () => {};\n\n const restoreStaticChildSlotsCache = () => {\n if (!staticChildSlotsCacheSuspended) {\n return;\n }\n\n setStaticChildSlotsCacheEnabled(true);\n staticChildSlotsCacheSuspended = false;\n };\n\n if (hydrateOptions.skipSelectors?.length) {\n markSkippedElements(rootElement, hydrateOptions.skipSelectors);\n }\n\n let deferredBoundaries: Element[] = [];\n if (hydrateOptions.deferBelowFold) {\n setStaticChildSlotsCacheEnabled(false);\n staticChildSlotsCacheSuspended = true;\n const foldY = hydrateOptions.foldThreshold ?? window.innerHeight;\n deferredBoundaries = collectDeferredBelowFoldBoundaries(rootElement, foldY);\n\n let selectiveHydrationResourcesReleased = false;\n let unregisterRootCleanupCallback = () => {};\n\n function handleScroll() {\n const { activated, remaining } = activateVisibleDeferredBoundaries(\n deferredBoundaries,\n foldY\n );\n\n if (!activated) {\n return;\n }\n\n flushHydrationActivation(rootElement);\n\n if (remaining === 0) {\n releaseSelectiveHydrationResources();\n }\n }\n\n releaseSelectiveHydrationResources = () => {\n if (selectiveHydrationResourcesReleased) {\n return;\n }\n\n selectiveHydrationResourcesReleased = true;\n unregisterRootCleanupCallback();\n window.removeEventListener('scroll', handleScroll);\n restoreStaticChildSlotsCache();\n };\n\n unregisterRootCleanupCallback = registerRootCleanupCallback(\n rootElement,\n releaseSelectiveHydrationResources\n );\n\n window.addEventListener('scroll', handleScroll, { passive: true });\n }\n\n if (hydrateOptions.deferUntilIdle && !hasSelectiveBoundaries) {\n await queueIdleWork(() => {\n mountOrUpdate(\n rootElement,\n (() => resolved.handler(resolved.params)) as ComponentFunction,\n {\n cleanupStrict,\n }\n );\n });\n await registerAppNavigation(rootElement, path);\n return;\n }\n\n try {\n mountOrUpdate(\n rootElement,\n (() => resolved.handler(resolved.params)) as ComponentFunction,\n {\n cleanupStrict,\n }\n );\n await registerAppNavigation(rootElement, path);\n } catch (error) {\n releaseSelectiveHydrationResources();\n throw error;\n }\n\n if (hydrateOptions.deferUntilIdle && deferredBoundaries.length > 0) {\n await queueIdleWork(() => {\n try {\n const { activated } = activateVisibleDeferredBoundaries(\n deferredBoundaries,\n Number.POSITIVE_INFINITY\n );\n if (activated) {\n flushHydrationActivation(rootElement);\n }\n } finally {\n releaseSelectiveHydrationResources();\n }\n });\n }\n\n if (deferredBoundaries.length === 0) {\n releaseSelectiveHydrationResources();\n }\n}\n\n/**\n * hydrateSPA: Hydrate server-rendered HTML.\n * Accepts either a `manifest` (preferred) or a legacy `routes` array.\n */\nexport async function hydrateSPA(config: HydrateSPAConfig): Promise<void> {\n assertExecutionModel('spa');\n if (!config || typeof config !== 'object') {\n throw new Error('hydrateSPA requires a config object');\n }\n\n const hasManifest =\n config.manifest != null && config.manifest.records.length > 0;\n const hasRoutes = Array.isArray(config.routes) && config.routes.length > 0;\n\n if (!hasManifest && !hasRoutes) {\n throw new Error(\n 'hydrateSPA requires a route manifest or route table. ' +\n 'Pass `manifest: getManifest()` or `routes: getRoutes()`. ' +\n 'If you are enhancing existing HTML, use createIsland instead.'\n );\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n const hydrationRenderData = takeHydrationRenderData(rootElement);\n\n const pendingLazyAtHydrationBoot = _snapshotLazy();\n\n configureScrollRestoration(config.scrollRestoration);\n\n clearRoutes();\n\n if (hasManifest) {\n _applyManifest(config.manifest!);\n } else {\n for (const r of config.routes!) {\n registerRoute(r.path, r.handler as Parameters<typeof registerRoute>[1]);\n }\n }\n\n _setActiveRouteAuthOptions(config.auth ?? config.manifest?.auth);\n\n // Drain any lazy() imports so all split chunks are ready before mounting\n await _drainLazy(pendingLazyAtHydrationBoot);\n\n const {\n path,\n href: currentUrl,\n resolved,\n } = await resolveInitialRoute(config.auth ?? config.manifest?.auth);\n setServerLocation(currentUrl);\n if (isProductionEnvironment()) lockRouteRegistration();\n\n if (!resolved) {\n throw new Error(`hydrateSPA: no route found for current path (${path}).`);\n }\n\n if (resolved.kind === 'redirect') {\n throw new Error(\n `hydrateSPA: unresolved redirect for current path (${path}).`\n );\n }\n\n const hydrationResolved: ResolvedRoute =\n resolved.kind === 'deny'\n ? { handler: bindDeniedStatus(resolved.status), params: {} }\n : { handler: resolved.handler, params: resolved.params };\n\n if (shouldVerifyHydrationMarkup(config)) {\n const legacyRouteTable = hasManifest\n ? config.manifest!.records.map((r) => ({\n path: r.path,\n handler: r.handler,\n namespace: r.options.namespace,\n }))\n : config.routes!;\n\n const { verifyHydrationSyncForUrl } =\n await import('../ssr/verify-hydration');\n if (\n !verifyHydrationSyncForUrl({\n root: rootElement,\n url: currentUrl,\n routes: legacyRouteTable,\n resolved: hydrationResolved,\n options: {\n data: hydrationRenderData ?? undefined,\n },\n })\n ) {\n throw new Error(\n '[Askr] Hydration mismatch detected. Server HTML does not match expected server-render output.'\n );\n }\n }\n\n const hydrateOptions = config.hydrate;\n if (hydrateOptions) {\n if (hydrateOptions.deferUntilIdle || hydrateOptions.deferBelowFold) {\n if (hydrationRenderData) {\n startHydrationRenderPhase(hydrationRenderData);\n }\n try {\n await applySelectiveHydration(\n rootElement,\n hydrationResolved,\n path,\n config.cleanupStrict,\n hydrateOptions\n );\n } finally {\n if (hydrationRenderData) {\n stopHydrationRenderPhase();\n }\n }\n return;\n }\n\n if (hydrateOptions.skipSelectors?.length) {\n markSkippedElements(rootElement, hydrateOptions.skipSelectors);\n }\n }\n\n if (hydrationRenderData) {\n startHydrationRenderPhase(hydrationRenderData);\n }\n try {\n mountOrUpdate(\n rootElement,\n resolved.kind === 'deny'\n ? bindDeniedStatus(resolved.status)\n : bindResolvedRouteHandler(hydrationResolved),\n {\n cleanupStrict: config.cleanupStrict,\n }\n );\n } finally {\n if (hydrationRenderData) {\n stopHydrationRenderPhase();\n }\n }\n await registerAppNavigation(rootElement, path, {\n manifest: config.manifest,\n routes: config.routes,\n auth: config.auth ?? config.manifest?.auth,\n });\n}\n\n/**\n * Cleanup an app mounted on a root element (element or id).\n * Safe to call multiple times — no-op when nothing is mounted.\n */\nexport function cleanupApp(root: Element | string): void {\n const rootElement =\n typeof root === 'string' ? document.getElementById(root) : root;\n\n if (!rootElement) return;\n\n const cleanupFn = (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n try {\n if (typeof cleanupFn === 'function') {\n cleanupFn();\n }\n } finally {\n instancesByRoot.delete(rootElement);\n clearRootCleanupCallbacks(rootElement);\n try {\n delete (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n } catch {\n // Ignore cleanup marker removal failures.\n }\n }\n}\n\n/**\n * Check whether an app is mounted on the given root\n */\nexport function hasApp(root: Element | string): boolean {\n const rootElement =\n typeof root === 'string' ? document.getElementById(root) : root;\n\n if (!rootElement) return false;\n return instancesByRoot.has(rootElement);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,iBAAiB,OAAO,IAAI,qBAAqB;AAEvD,IAAI,qBAAqB;AAGzB,MAAM,kCAAkB,IAAI,QAAoC;AAGhE,MAAM,iBAAiB,OAAO,IAAI,iBAAiB;AACnD,MAAM,gCAAgC,OAAO,IAC3C,8BACF;AAYA,SAAS,wBAAwB,aAAsC;CACrE,KAAK,MAAM,SAAS,MAA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;EACR,IAAI,qBACF,yBAAyB;CAE7B;CACA,MAAM,sBAAsB,aAAa,MAAM;EAC7C,UAAU,OAAO;EACjB,QAAQ,OAAO;EACf,MAAM,OAAO,QAAQ,OAAO,UAAU;CACxC,CAAC;AACH;;;;;AAMA,SAAgB,WAAW,MAA8B;CACvD,MAAM,cACJ,OAAO,SAAS,WAAW,SAAS,eAAe,IAAI,IAAI;CAE7D,IAAI,CAAC,aAAa;CAElB,MAAM,YAAa,YAAmC;CACtD,IAAI;EACF,IAAI,OAAO,cAAc,YACvB,UAAU;CAEd,UAAU;EACR,gBAAgB,OAAO,WAAW;EAClC,0BAA0B,WAAW;EACrC,IAAI;GACF,OAAQ,YAAmC;EAC7C,QAAQ,CAER;CACF;AACF;;;;AAKA,SAAgB,OAAO,MAAiC;CACtD,MAAM,cACJ,OAAO,SAAS,WAAW,SAAS,eAAe,IAAI,IAAI;CAE7D,IAAI,CAAC,aAAa,OAAO;CACzB,OAAO,gBAAgB,IAAI,WAAW;AACxC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/boot/index.ts"],"sourcesContent":["/**\n * App bootstrap and mount\n */\n\nimport {\n createComponentInstance,\n mountComponent,\n cleanupComponent,\n type ComponentFunction,\n type ComponentInstance,\n} from '../runtime/component';\nimport {\n isDevelopmentEnvironment,\n isProductionEnvironment,\n} from '../common/env';\nimport { logger } from '../dev/logger';\nimport {\n initializeNavigation,\n registerAppInstance,\n unregisterAppInstance,\n} from '../router/navigate';\nimport {\n configureScrollRestoration,\n type ScrollRestorationOptions,\n} from '../router/navigate';\nimport {\n _applyManifest,\n _drainLazy,\n _setActiveRouteAuthOptions,\n _snapshotLazy,\n clearRoutes,\n lockRouteRegistration,\n resolveRouteRequest,\n route as registerRoute,\n setServerLocation,\n} from '../router/route';\nimport { globalScheduler } from '../runtime/scheduler';\nimport { assertExecutionModel } from '../runtime/execution-model';\nimport { setStaticChildSlotsCacheEnabled } from '../renderer/dom';\nimport { isPromiseLike } from '../common/promise';\nimport { SSR_RENDER_DATA_ATTR, type SSRData } from '../common/ssr';\nimport {\n startHydrationRenderPhase,\n stopHydrationRenderPhase,\n} from '../ssr/render-keys';\n\nconst HAS_ROUTES_KEY = Symbol.for('__ASKR_HAS_ROUTES__');\n\nlet componentIdCounter = 0;\n\n// Track instances by root element to support multiple createIsland calls on same root\nconst instancesByRoot = new WeakMap<Element, ComponentInstance>();\n\n// Symbol for storing cleanup on elements\nconst CLEANUP_SYMBOL = Symbol.for('__askrCleanup__');\nconst ROOT_CLEANUP_CALLBACKS_SYMBOL = Symbol.for(\n '__askrRootCleanupCallbacks__'\n);\n\ntype RootCleanupOptions = {\n preserveInstance?: boolean;\n};\n\n// Type for elements that have cleanup functions attached\ninterface ElementWithCleanup extends Element {\n [CLEANUP_SYMBOL]?: (options?: RootCleanupOptions) => void;\n [ROOT_CLEANUP_CALLBACKS_SYMBOL]?: Set<() => void>;\n}\n\nfunction takeHydrationRenderData(rootElement: Element): SSRData | null {\n for (const child of Array.from(rootElement.children)) {\n if (\n child instanceof HTMLScriptElement &&\n child.getAttribute(SSR_RENDER_DATA_ATTR) === 'true'\n ) {\n const raw = child.textContent ?? '';\n child.remove();\n if (!raw) {\n return {};\n }\n\n try {\n return JSON.parse(raw) as SSRData;\n } catch (err) {\n throw new Error(\n '[Askr] Failed to parse embedded SSR render data during hydration.',\n { cause: err }\n );\n }\n }\n }\n\n return null;\n}\n\nfunction clearRootCleanupCallbacks(rootElement: Element): void {\n try {\n delete (rootElement as ElementWithCleanup)[ROOT_CLEANUP_CALLBACKS_SYMBOL];\n } catch {\n (rootElement as ElementWithCleanup)[ROOT_CLEANUP_CALLBACKS_SYMBOL]?.clear();\n }\n}\n\nfunction registerRootCleanupCallback(\n rootElement: Element,\n callback: () => void\n): () => void {\n const elementWithCleanup = rootElement as ElementWithCleanup;\n const callbacks =\n elementWithCleanup[ROOT_CLEANUP_CALLBACKS_SYMBOL] ?? new Set();\n callbacks.add(callback);\n elementWithCleanup[ROOT_CLEANUP_CALLBACKS_SYMBOL] = callbacks;\n\n return () => {\n callbacks.delete(callback);\n if (callbacks.size === 0) {\n clearRootCleanupCallbacks(rootElement);\n }\n };\n}\n\nfunction runRootCleanupCallbacks(\n rootElement: Element,\n errors: unknown[]\n): void {\n const callbacks = (rootElement as ElementWithCleanup)[\n ROOT_CLEANUP_CALLBACKS_SYMBOL\n ];\n if (!callbacks || callbacks.size === 0) {\n clearRootCleanupCallbacks(rootElement);\n return;\n }\n\n clearRootCleanupCallbacks(rootElement);\n for (const callback of callbacks) {\n try {\n callback();\n } catch (e) {\n errors.push(e);\n }\n }\n}\n\nfunction cleanupRootInstance(\n rootElement: Element,\n instance: ComponentInstance,\n options?: RootCleanupOptions\n) {\n // Attempt to remove listeners and cleanup instances under the root.\n // In non-strict mode we preserve previous behavior by swallowing errors\n // (but logging in dev); in strict mode we aggregate and re-throw.\n const errors: unknown[] = [];\n try {\n teardownNodeSubtree(rootElement);\n } catch (e) {\n errors.push(e);\n }\n\n try {\n cleanupComponent(instance);\n } catch (e) {\n errors.push(e);\n }\n\n runRootCleanupCallbacks(rootElement, errors);\n\n if (!options?.preserveInstance) {\n unregisterAppInstance(instance);\n instancesByRoot.delete(rootElement);\n clearRootCleanupCallbacks(rootElement);\n try {\n delete (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n } catch {\n // Ignore cleanup marker removal failures.\n }\n }\n\n if (errors.length > 0) {\n if (instance.cleanupStrict) {\n throw new AggregateError(errors, `cleanup failed for app root`);\n } else if (isDevelopmentEnvironment()) {\n for (const err of errors) logger.warn('[Askr] cleanup error:', err);\n }\n }\n}\n\nfunction attachCleanupForRoot(\n rootElement: Element,\n instance: ComponentInstance\n) {\n (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL] = (options) => {\n cleanupRootInstance(rootElement, instance, options);\n };\n\n try {\n const descriptor =\n Object.getOwnPropertyDescriptor(rootElement, 'innerHTML') ||\n Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(rootElement),\n 'innerHTML'\n ) ||\n Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML');\n\n if (descriptor && (descriptor.get || descriptor.set)) {\n Object.defineProperty(rootElement, 'innerHTML', {\n get: descriptor.get\n ? function (this: Element) {\n return descriptor.get!.call(this);\n }\n : undefined,\n set: function (this: Element, value: string) {\n if (value === '' && instancesByRoot.get(this) === instance) {\n cleanupRootInstance(rootElement, instance);\n }\n if (descriptor.set) {\n return descriptor.set.call(this, value);\n }\n },\n configurable: true,\n });\n }\n } catch {\n // If Object.defineProperty fails, ignore\n }\n}\n\nimport { Fragment, ELEMENT_TYPE } from '../jsx';\n\nimport { DefaultPortal } from '../foundations/structures/portal';\nimport { disposeDefaultPortalScope } from '../foundations/structures/portal';\n\nfunction mountOrUpdate(\n rootElement: Element,\n componentFn: ComponentFunction,\n options?: { cleanupStrict?: boolean }\n) {\n // Ensure root component always includes a DefaultPortal host by wrapping it.\n const wrappedFn: ComponentFunction = (props, ctx) => {\n const out = componentFn(props, ctx);\n if (isPromiseLike(out)) {\n throw new Error(\n 'Async components are not supported. Components must return synchronously.'\n );\n }\n const portalVNode = {\n $$typeof: ELEMENT_TYPE,\n type: DefaultPortal,\n props: {},\n key: '__default_portal',\n } as unknown;\n return {\n $$typeof: ELEMENT_TYPE,\n type: Fragment,\n props: {\n children:\n out === undefined || out === null\n ? [portalVNode]\n : [out, portalVNode],\n },\n } as unknown as ReturnType<ComponentFunction>;\n };\n // Preserve the original component name for debugging/dev warnings\n Object.defineProperty(wrappedFn, 'name', {\n value: componentFn.name || 'Component',\n });\n\n // Clean up existing cleanup function before mounting new one\n const existingCleanup = (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n const reusedExistingInstance = typeof existingCleanup === 'function';\n if (reusedExistingInstance) {\n existingCleanup({ preserveInstance: true });\n }\n\n let instance = instancesByRoot.get(rootElement);\n\n if (instance) {\n const shouldResetHookState = instance.fn.name !== wrappedFn.name;\n\n if (!reusedExistingInstance) {\n removeAllListeners(rootElement);\n try {\n cleanupComponent(instance);\n } catch (e) {\n // If previous cleanup threw in strict mode, log but continue mounting new instance\n if (isDevelopmentEnvironment()) {\n logger.warn('[Askr] prior cleanup threw:', e);\n }\n }\n }\n\n instance.fn = wrappedFn;\n instance.evaluationGeneration++;\n instance.mounted = false;\n instance.expectedStateIndices = [];\n instance.firstRenderComplete = false;\n instance.isRoot = true;\n instance.portalScope = instance;\n\n if (shouldResetHookState) {\n instance.stateValues = [];\n instance.hasPendingUpdate = false;\n instance.notifyUpdate = null;\n instance.stateIndexCheck = -1;\n instance.mountOperations = [];\n instance.commitOperations = [];\n instance.lifecycleSlots = [];\n instance.cleanupFns = [];\n instance._currentRenderToken = undefined;\n instance.lastRenderToken = 0;\n instance._pendingReadSources = undefined;\n instance._lastReadSources = undefined;\n instance._placeholder = undefined;\n instance.errorBoundaryState = undefined;\n instance.devWarningsEmitted = undefined;\n }\n\n // Update strict flag if provided\n if (options && typeof options.cleanupStrict === 'boolean') {\n instance.cleanupStrict = options.cleanupStrict;\n }\n } else {\n const componentId = String(++componentIdCounter);\n instance = createComponentInstance(componentId, wrappedFn, {}, rootElement);\n instancesByRoot.set(rootElement, instance);\n instance.isRoot = true;\n instance.portalScope = instance;\n // Initialize strict flag from options\n if (options && typeof options.cleanupStrict === 'boolean') {\n instance.cleanupStrict = options.cleanupStrict;\n }\n }\n\n attachCleanupForRoot(rootElement, instance);\n registerRootCleanupCallback(rootElement, () => {\n disposeDefaultPortalScope(instance.portalScope ?? instance);\n });\n mountComponent(instance);\n globalScheduler.flush();\n}\n\nfunction bindResolvedRouteHandler(resolved: ResolvedRoute): ComponentFunction {\n return () =>\n resolved.handler(resolved.params) as ReturnType<ComponentFunction>;\n}\n\nfunction bindDeniedStatus(status: number): ComponentFunction {\n return () => ({\n type: 'div',\n props: {\n 'data-route-denied': String(status),\n },\n children: [String(status)],\n });\n}\n\n// New strongly-typed init functions\nimport type {\n Route,\n RouteManifest,\n ResolvedRoute,\n RouteAuthOptions,\n RouteRequestResult,\n} from '../common/router';\nimport {\n installRendererBridge,\n removeAllListeners,\n teardownNodeSubtree,\n} from '../renderer';\ninstallRendererBridge();\n\nexport type IslandConfig = {\n root: Element | string;\n component: ComponentFunction;\n // Optional: surface cleanup errors during teardown for this island\n cleanupStrict?: boolean;\n // Explicitly disallow routes on islands at type level\n routes?: never;\n};\n\nexport type IslandsConfig = {\n islands: IslandConfig[];\n};\n\ntype BootRouteSource =\n | {\n manifest: RouteManifest;\n routes?: Route[];\n }\n | {\n manifest?: RouteManifest;\n routes: Route[];\n };\n\nexport type SPAConfig = BootRouteSource & {\n root: Element | string;\n /**\n * Preferred: pass the route manifest built via `registerRoutes(() => { ... })`.\n * ```ts\n * import { getManifest } from '@askrjs/askr/router';\n * await createSPA({ root: '#app', manifest: getManifest() });\n * ```\n */\n auth?: RouteAuthOptions;\n scrollRestoration?: boolean | ScrollRestorationOptions;\n cleanupStrict?: boolean;\n component?: never;\n};\n\nexport type HydrateSPAConfig = BootRouteSource & {\n root: Element | string;\n /** Preferred manifest input — see `SPAConfig.manifest`. */\n auth?: RouteAuthOptions;\n scrollRestoration?: boolean | ScrollRestorationOptions;\n cleanupStrict?: boolean;\n hydrate?: {\n verifyMarkup?: boolean;\n deferUntilIdle?: boolean;\n deferBelowFold?: boolean;\n foldThreshold?: number;\n skipSelectors?: string[];\n };\n};\n\nconst MAX_INITIAL_ROUTE_REDIRECTS = 20;\n\nasync function resolveInitialRoute(\n auth?: RouteAuthOptions\n): Promise<{ path: string; href: string; resolved: RouteRequestResult }> {\n let path = typeof window !== 'undefined' ? window.location.pathname : '/';\n let href =\n typeof window !== 'undefined'\n ? `${window.location.pathname}${window.location.search}${window.location.hash}`\n : path;\n const visited = new Set<string>();\n\n for (\n let redirects = 0;\n redirects <= MAX_INITIAL_ROUTE_REDIRECTS;\n redirects++\n ) {\n if (visited.has(href)) {\n throw new Error(`[Askr] Route redirect cycle detected at ${href}.`);\n }\n visited.add(href);\n\n const resolved = await resolveRouteRequest(href, { auth });\n if (\n typeof window === 'undefined' ||\n !resolved ||\n resolved.kind !== 'redirect'\n ) {\n return { path, href, resolved };\n }\n\n const redirectTarget = new URL(resolved.to, window.location.href);\n const redirectHref = `${redirectTarget.pathname}${redirectTarget.search}${redirectTarget.hash}`;\n window.history.replaceState({ path: redirectHref }, '', redirectHref);\n path = redirectTarget.pathname;\n href = redirectHref;\n }\n\n throw new Error(\n `[Askr] Route redirect limit exceeded (${MAX_INITIAL_ROUTE_REDIRECTS}).`\n );\n}\n\n/**\n * createIsland: Enhances existing DOM (no router, mounts once)\n */\nexport function createIsland(config: IslandConfig): void {\n assertExecutionModel('islands');\n if (!config || typeof config !== 'object') {\n throw new Error('createIsland requires a config object');\n }\n if (typeof config.component !== 'function') {\n throw new Error('createIsland: component must be a function');\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n\n // Islands must not initialize router or routes\n if ('routes' in config) {\n throw new Error(\n 'createIsland does not accept routes; use createSPA for routed apps'\n );\n }\n\n // Routes are never supported with islands.\n // If routes were registered (even at module load time), fail fast to avoid\n // surprising partial router behavior.\n try {\n const g = globalThis as unknown as Record<string | symbol, unknown>;\n if (g[HAS_ROUTES_KEY]) {\n throw new Error(\n 'Routes are not supported with islands. Use createSPA (client) or createSSR (server) instead.'\n );\n }\n } catch {\n // ignore\n }\n\n mountOrUpdate(rootElement, config.component, {\n cleanupStrict: config.cleanupStrict,\n });\n}\n\n/**\n * createIslands: Enhances one or more existing DOM roots (no router).\n * The only public islands constructor.\n */\nexport function createIslands(config: IslandsConfig): void {\n assertExecutionModel('islands');\n if (!config || typeof config !== 'object') {\n throw new Error('createIslands requires a config object');\n }\n if (!Array.isArray(config.islands) || config.islands.length === 0) {\n throw new Error('createIslands requires a non-empty islands array');\n }\n for (const island of config.islands) {\n createIsland(island);\n }\n}\n\n/**\n * createSPA: Initializes router and mounts the app with the provided route manifest or route table.\n *\n * Preferred usage with manifest:\n * ```ts\n * import { getManifest } from '@askrjs/askr/router';\n * await createSPA({ root: '#app', manifest: getManifest() });\n * ```\n *\n * Legacy usage with plain routes array (still supported):\n * ```ts\n * await createSPA({ root: '#app', routes: getRoutes() });\n * ```\n */\nexport async function createSPA(config: SPAConfig): Promise<void> {\n assertExecutionModel('spa');\n if (!config || typeof config !== 'object') {\n throw new Error('createSPA requires a config object');\n }\n\n const hasManifest =\n config.manifest != null && config.manifest.records.length > 0;\n const hasRoutes = Array.isArray(config.routes) && config.routes.length > 0;\n\n if (!hasManifest && !hasRoutes) {\n throw new Error(\n 'createSPA requires a route manifest or route table. ' +\n 'Pass `manifest: getManifest()` or `routes: getRoutes()`. ' +\n 'If you are enhancing existing HTML, use createIsland instead.'\n );\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n\n const pendingLazyAtBoot = _snapshotLazy();\n\n configureScrollRestoration(config.scrollRestoration);\n\n clearRoutes();\n\n if (hasManifest) {\n // Preferred path: apply pre-built manifest records directly\n _applyManifest(config.manifest!);\n } else {\n // Legacy path: register plain Route objects (no layout metadata)\n for (const r of config.routes!) {\n registerRoute(r.path, r.handler as Parameters<typeof registerRoute>[1]);\n }\n }\n\n const routeAuth = config.auth ?? config.manifest?.auth;\n _setActiveRouteAuthOptions(routeAuth);\n\n // Drain any lazy() imports so all split chunks are ready before mounting\n await _drainLazy(pendingLazyAtBoot);\n\n // Lock registration in production to prevent late registration surprises\n if (isProductionEnvironment()) lockRouteRegistration();\n\n // Mount the currently-resolved route handler (if any)\n const { path, resolved } = await resolveInitialRoute(routeAuth);\n\n if (!resolved) {\n mountOrUpdate(rootElement, () => ({ type: 'div', children: [] }), {\n cleanupStrict: config.cleanupStrict,\n });\n\n await registerAppNavigation(rootElement, path, {\n manifest: config.manifest,\n routes: config.routes,\n auth: routeAuth,\n });\n return;\n }\n\n if (resolved.kind === 'redirect') {\n mountOrUpdate(rootElement, () => ({ type: 'div', children: [] }), {\n cleanupStrict: config.cleanupStrict,\n });\n\n await registerAppNavigation(rootElement, path, {\n manifest: config.manifest,\n routes: config.routes,\n auth: routeAuth,\n });\n return;\n }\n\n mountOrUpdate(\n rootElement,\n resolved.kind === 'deny'\n ? bindDeniedStatus(resolved.status)\n : bindResolvedRouteHandler({\n handler: resolved.handler,\n params: resolved.params,\n }),\n {\n cleanupStrict: config.cleanupStrict,\n }\n );\n\n await registerAppNavigation(rootElement, path, {\n manifest: config.manifest,\n routes: config.routes,\n auth: routeAuth,\n });\n}\n\n/**\n * Mark elements that should be skipped during hydration\n */\nfunction markSkippedElements(root: Element, skipSelectors: string[]): void {\n if (skipSelectors.length === 0) {\n return;\n }\n\n const uniqueSelectors = Array.from(new Set(skipSelectors));\n const selectorList = uniqueSelectors.join(', ');\n const elements = root.querySelectorAll(selectorList);\n elements.forEach((el) => el.setAttribute('data-skip-hydrate', 'true'));\n}\n\nfunction collectDeferredBelowFoldBoundaries(\n root: Element,\n foldY: number\n): Element[] {\n const boundaries: Element[] = [];\n const stack: Element[] = [];\n\n for (let index = root.children.length - 1; index >= 0; index -= 1) {\n stack.push(root.children[index]);\n }\n\n while (stack.length > 0) {\n const element = stack.pop()!;\n\n if (element.hasAttribute('data-skip-hydrate')) {\n continue;\n }\n\n const rect = element.getBoundingClientRect();\n if (rect.top >= foldY) {\n element.setAttribute('data-skip-hydrate', 'true');\n boundaries.push(element);\n continue;\n }\n\n for (let index = element.children.length - 1; index >= 0; index -= 1) {\n stack.push(element.children[index]);\n }\n }\n\n return boundaries;\n}\n\nfunction activateVisibleDeferredBoundaries(\n boundaries: Element[],\n foldY: number\n): { activated: boolean; remaining: number } {\n let activated = false;\n let remaining = 0;\n\n for (const element of boundaries) {\n if (!element.hasAttribute('data-skip-hydrate')) {\n continue;\n }\n\n const rect = element.getBoundingClientRect();\n if (rect.top < foldY) {\n element.removeAttribute('data-skip-hydrate');\n activated = true;\n } else {\n remaining += 1;\n }\n }\n\n return { activated, remaining };\n}\n\nfunction queueIdleWork(work: () => void): Promise<void> {\n return new Promise((resolve) => {\n if (typeof requestIdleCallback !== 'undefined') {\n requestIdleCallback(\n () => {\n work();\n resolve();\n },\n { timeout: 2000 }\n );\n return;\n }\n\n setTimeout(() => {\n work();\n resolve();\n }, 0);\n });\n}\n\nfunction flushHydrationActivation(rootElement: Element): void {\n const instance = instancesByRoot.get(rootElement);\n if (!instance) return;\n instance._enqueueRun?.();\n globalScheduler.flush();\n}\n\nfunction shouldVerifyHydrationMarkup(config: HydrateSPAConfig): boolean {\n const explicit = config.hydrate?.verifyMarkup;\n if (typeof explicit === 'boolean') {\n return explicit;\n }\n\n return !isProductionEnvironment();\n}\n\nasync function registerAppNavigation(\n rootElement: Element,\n path: string,\n source?: {\n manifest?: RouteManifest;\n routes?: Route[];\n auth?: RouteAuthOptions;\n }\n) {\n const instance = instancesByRoot.get(rootElement);\n if (!instance) throw new Error('Internal error: app instance missing');\n registerAppInstance(instance as ComponentInstance, path, source);\n initializeNavigation();\n}\n\n/**\n * Apply selective hydration with deferral options\n */\nasync function applySelectiveHydration(\n rootElement: Element,\n resolved: { handler: ComponentFunction; params: Record<string, unknown> },\n path: string,\n cleanupStrict: boolean | undefined,\n hydrateOptions: NonNullable<HydrateSPAConfig['hydrate']>\n): Promise<void> {\n const hasPermanentSkips = (hydrateOptions.skipSelectors?.length ?? 0) > 0;\n const hasBelowFoldDeferral = !!hydrateOptions.deferBelowFold;\n const hasSelectiveBoundaries = hasPermanentSkips || hasBelowFoldDeferral;\n let staticChildSlotsCacheSuspended = false;\n let releaseSelectiveHydrationResources = () => {};\n\n const restoreStaticChildSlotsCache = () => {\n if (!staticChildSlotsCacheSuspended) {\n return;\n }\n\n setStaticChildSlotsCacheEnabled(true);\n staticChildSlotsCacheSuspended = false;\n };\n\n if (hydrateOptions.skipSelectors?.length) {\n markSkippedElements(rootElement, hydrateOptions.skipSelectors);\n }\n\n let deferredBoundaries: Element[] = [];\n if (hydrateOptions.deferBelowFold) {\n setStaticChildSlotsCacheEnabled(false);\n staticChildSlotsCacheSuspended = true;\n const foldY = hydrateOptions.foldThreshold ?? window.innerHeight;\n deferredBoundaries = collectDeferredBelowFoldBoundaries(rootElement, foldY);\n\n let selectiveHydrationResourcesReleased = false;\n let unregisterRootCleanupCallback = () => {};\n\n function handleScroll() {\n const { activated, remaining } = activateVisibleDeferredBoundaries(\n deferredBoundaries,\n foldY\n );\n\n if (!activated) {\n return;\n }\n\n flushHydrationActivation(rootElement);\n\n if (remaining === 0) {\n releaseSelectiveHydrationResources();\n }\n }\n\n releaseSelectiveHydrationResources = () => {\n if (selectiveHydrationResourcesReleased) {\n return;\n }\n\n selectiveHydrationResourcesReleased = true;\n unregisterRootCleanupCallback();\n window.removeEventListener('scroll', handleScroll);\n restoreStaticChildSlotsCache();\n };\n\n unregisterRootCleanupCallback = registerRootCleanupCallback(\n rootElement,\n releaseSelectiveHydrationResources\n );\n\n window.addEventListener('scroll', handleScroll, { passive: true });\n }\n\n if (hydrateOptions.deferUntilIdle && !hasSelectiveBoundaries) {\n await queueIdleWork(() => {\n mountOrUpdate(\n rootElement,\n (() => resolved.handler(resolved.params)) as ComponentFunction,\n {\n cleanupStrict,\n }\n );\n });\n await registerAppNavigation(rootElement, path);\n return;\n }\n\n try {\n mountOrUpdate(\n rootElement,\n (() => resolved.handler(resolved.params)) as ComponentFunction,\n {\n cleanupStrict,\n }\n );\n await registerAppNavigation(rootElement, path);\n } catch (error) {\n releaseSelectiveHydrationResources();\n throw error;\n }\n\n if (hydrateOptions.deferUntilIdle && deferredBoundaries.length > 0) {\n await queueIdleWork(() => {\n try {\n const { activated } = activateVisibleDeferredBoundaries(\n deferredBoundaries,\n Number.POSITIVE_INFINITY\n );\n if (activated) {\n flushHydrationActivation(rootElement);\n }\n } finally {\n releaseSelectiveHydrationResources();\n }\n });\n }\n\n if (deferredBoundaries.length === 0) {\n releaseSelectiveHydrationResources();\n }\n}\n\n/**\n * hydrateSPA: Hydrate server-rendered HTML.\n * Accepts either a `manifest` (preferred) or a legacy `routes` array.\n */\nexport async function hydrateSPA(config: HydrateSPAConfig): Promise<void> {\n assertExecutionModel('spa');\n if (!config || typeof config !== 'object') {\n throw new Error('hydrateSPA requires a config object');\n }\n\n const hasManifest =\n config.manifest != null && config.manifest.records.length > 0;\n const hasRoutes = Array.isArray(config.routes) && config.routes.length > 0;\n\n if (!hasManifest && !hasRoutes) {\n throw new Error(\n 'hydrateSPA requires a route manifest or route table. ' +\n 'Pass `manifest: getManifest()` or `routes: getRoutes()`. ' +\n 'If you are enhancing existing HTML, use createIsland instead.'\n );\n }\n\n const rootElement =\n typeof config.root === 'string'\n ? document.getElementById(config.root)\n : config.root;\n if (!rootElement) throw new Error(`Root element not found: ${config.root}`);\n const hydrationRenderData = takeHydrationRenderData(rootElement);\n\n const pendingLazyAtHydrationBoot = _snapshotLazy();\n\n configureScrollRestoration(config.scrollRestoration);\n\n clearRoutes();\n\n if (hasManifest) {\n _applyManifest(config.manifest!);\n } else {\n for (const r of config.routes!) {\n registerRoute(r.path, r.handler as Parameters<typeof registerRoute>[1]);\n }\n }\n\n _setActiveRouteAuthOptions(config.auth ?? config.manifest?.auth);\n\n // Drain any lazy() imports so all split chunks are ready before mounting\n await _drainLazy(pendingLazyAtHydrationBoot);\n\n const {\n path,\n href: currentUrl,\n resolved,\n } = await resolveInitialRoute(config.auth ?? config.manifest?.auth);\n setServerLocation(currentUrl);\n if (isProductionEnvironment()) lockRouteRegistration();\n\n if (!resolved) {\n throw new Error(`hydrateSPA: no route found for current path (${path}).`);\n }\n\n if (resolved.kind === 'redirect') {\n throw new Error(\n `hydrateSPA: unresolved redirect for current path (${path}).`\n );\n }\n\n const hydrationResolved: ResolvedRoute =\n resolved.kind === 'deny'\n ? { handler: bindDeniedStatus(resolved.status), params: {} }\n : { handler: resolved.handler, params: resolved.params };\n\n if (shouldVerifyHydrationMarkup(config)) {\n const legacyRouteTable = hasManifest\n ? config.manifest!.records.map((r) => ({\n path: r.path,\n handler: r.handler,\n namespace: r.options.namespace,\n }))\n : config.routes!;\n\n const { verifyHydrationSyncForUrl } =\n await import('../ssr/verify-hydration');\n if (\n !verifyHydrationSyncForUrl({\n root: rootElement,\n url: currentUrl,\n routes: legacyRouteTable,\n resolved: hydrationResolved,\n options: {\n data: hydrationRenderData ?? undefined,\n },\n })\n ) {\n throw new Error(\n '[Askr] Hydration mismatch detected. Server HTML does not match expected server-render output.'\n );\n }\n }\n\n const hydrateOptions = config.hydrate;\n if (hydrateOptions) {\n if (hydrateOptions.deferUntilIdle || hydrateOptions.deferBelowFold) {\n if (hydrationRenderData) {\n startHydrationRenderPhase(hydrationRenderData);\n }\n try {\n await applySelectiveHydration(\n rootElement,\n hydrationResolved,\n path,\n config.cleanupStrict,\n hydrateOptions\n );\n } finally {\n if (hydrationRenderData) {\n stopHydrationRenderPhase();\n }\n }\n return;\n }\n\n if (hydrateOptions.skipSelectors?.length) {\n markSkippedElements(rootElement, hydrateOptions.skipSelectors);\n }\n }\n\n if (hydrationRenderData) {\n startHydrationRenderPhase(hydrationRenderData);\n }\n try {\n mountOrUpdate(\n rootElement,\n resolved.kind === 'deny'\n ? bindDeniedStatus(resolved.status)\n : bindResolvedRouteHandler(hydrationResolved),\n {\n cleanupStrict: config.cleanupStrict,\n }\n );\n } finally {\n if (hydrationRenderData) {\n stopHydrationRenderPhase();\n }\n }\n await registerAppNavigation(rootElement, path, {\n manifest: config.manifest,\n routes: config.routes,\n auth: config.auth ?? config.manifest?.auth,\n });\n}\n\n/**\n * Cleanup an app mounted on a root element (element or id).\n * Safe to call multiple times — no-op when nothing is mounted.\n */\nexport function cleanupApp(root: Element | string): void {\n const rootElement =\n typeof root === 'string' ? document.getElementById(root) : root;\n\n if (!rootElement) return;\n\n const cleanupFn = (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n try {\n if (typeof cleanupFn === 'function') {\n cleanupFn();\n }\n } finally {\n instancesByRoot.delete(rootElement);\n clearRootCleanupCallbacks(rootElement);\n try {\n delete (rootElement as ElementWithCleanup)[CLEANUP_SYMBOL];\n } catch {\n // Ignore cleanup marker removal failures.\n }\n }\n}\n\n/**\n * Check whether an app is mounted on the given root\n */\nexport function hasApp(root: Element | string): boolean {\n const rootElement =\n typeof root === 'string' ? document.getElementById(root) : root;\n\n if (!rootElement) return false;\n return instancesByRoot.has(rootElement);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,iBAAiB,OAAO,IAAI,qBAAqB;AAEvD,IAAI,qBAAqB;AAGzB,MAAM,kCAAkB,IAAI,QAAoC;AAGhE,MAAM,iBAAiB,OAAO,IAAI,iBAAiB;AACnD,MAAM,gCAAgC,OAAO,IAC3C,8BACF;AAYA,SAAS,wBAAwB,aAAsC;CACrE,KAAK,MAAM,SAAS,MAAM,KAAK,YAAY,QAAQ,GACjD,IACE,iBAAiB,qBACjB,MAAM,aAAA,uBAAiC,MAAM,QAC7C;EACA,MAAM,MAAM,MAAM,eAAe;EACjC,MAAM,OAAO;EACb,IAAI,CAAC,KACH,OAAO,CAAC;EAGV,IAAI;GACF,OAAO,KAAK,MAAM,GAAG;EACvB,SAAS,KAAK;GACZ,MAAM,IAAI,MACR,qEACA,EAAE,OAAO,IAAI,CACf;EACF;CACF;CAGF,OAAO;AACT;AAEA,SAAS,0BAA0B,aAA4B;CAC7D,IAAI;EACF,OAAQ,YAAmC;CAC7C,QAAQ;EACN,YAAoC,gCAAgC,MAAM;CAC5E;AACF;AAEA,SAAS,4BACP,aACA,UACY;CACZ,MAAM,qBAAqB;CAC3B,MAAM,YACJ,mBAAmB,kDAAkC,IAAI,IAAI;CAC/D,UAAU,IAAI,QAAQ;CACtB,mBAAmB,iCAAiC;CAEpD,aAAa;EACX,UAAU,OAAO,QAAQ;EACzB,IAAI,UAAU,SAAS,GACrB,0BAA0B,WAAW;CAEzC;AACF;AAEA,SAAS,wBACP,aACA,QACM;CACN,MAAM,YAAa,YAC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30 @@
|
|
|
1
|
+
//#region src/common/route-activity.ts
|
|
2
|
+
let currentRouteActivity = {
|
|
3
|
+
path: "/",
|
|
4
|
+
matches: []
|
|
5
|
+
};
|
|
6
|
+
function normalizeRouteActivityPath(path) {
|
|
7
|
+
const pathname = ((path.split("#", 1)[0] ?? "").split("?", 1)[0] ?? "") || "/";
|
|
8
|
+
const absolutePathname = pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
9
|
+
return absolutePathname.endsWith("/") && absolutePathname !== "/" ? absolutePathname.slice(0, -1) : absolutePathname;
|
|
10
|
+
}
|
|
11
|
+
function readActivePathname() {
|
|
12
|
+
if (typeof window !== "undefined" && window.location) return window.location.pathname || "/";
|
|
13
|
+
return currentRouteActivity.path;
|
|
14
|
+
}
|
|
15
|
+
function syncRouteActivitySnapshot(pathname, matches = []) {
|
|
16
|
+
currentRouteActivity = {
|
|
17
|
+
path: normalizeRouteActivityPath(pathname),
|
|
18
|
+
matches: Object.freeze([...matches])
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function isRouteActivityActive(pathOrPaths) {
|
|
22
|
+
const candidates = new Set((Array.isArray(pathOrPaths) ? pathOrPaths : [pathOrPaths]).map(normalizeRouteActivityPath));
|
|
23
|
+
const activePath = normalizeRouteActivityPath(readActivePathname());
|
|
24
|
+
if (candidates.has(activePath)) return true;
|
|
25
|
+
return currentRouteActivity.matches.some((match) => candidates.has(normalizeRouteActivityPath(match.path)));
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { isRouteActivityActive, syncRouteActivitySnapshot };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=route-activity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-activity.js","names":[],"sources":["../../src/common/route-activity.ts"],"sourcesContent":["import type { RouteMatch } from './router';\n\nexport type RouteActivityMatch = Pick<RouteMatch, 'path'>;\n\ntype RouteActivitySnapshot = {\n path: string;\n matches: readonly RouteActivityMatch[];\n};\n\nlet currentRouteActivity: RouteActivitySnapshot = {\n path: '/',\n matches: [],\n};\n\nfunction normalizeRouteActivityPath(path: string): string {\n const withoutHash = path.split('#', 1)[0] ?? '';\n const withoutSearch = withoutHash.split('?', 1)[0] ?? '';\n const pathname = withoutSearch || '/';\n const absolutePathname = pathname.startsWith('/') ? pathname : `/${pathname}`;\n\n return absolutePathname.endsWith('/') && absolutePathname !== '/'\n ? absolutePathname.slice(0, -1)\n : absolutePathname;\n}\n\nfunction readActivePathname(): string {\n if (typeof window !== 'undefined' && window.location) {\n return window.location.pathname || '/';\n }\n\n return currentRouteActivity.path;\n}\n\nexport function syncRouteActivitySnapshot(\n pathname: string,\n matches: readonly RouteActivityMatch[] = []\n): void {\n currentRouteActivity = {\n path: normalizeRouteActivityPath(pathname),\n matches: Object.freeze([...matches]),\n };\n}\n\nexport function isRouteActivityActive(\n pathOrPaths: string | readonly string[]\n): boolean {\n const candidates = new Set(\n (Array.isArray(pathOrPaths) ? pathOrPaths : [pathOrPaths]).map(\n normalizeRouteActivityPath\n )\n );\n\n const activePath = normalizeRouteActivityPath(readActivePathname());\n if (candidates.has(activePath)) {\n return true;\n }\n\n return currentRouteActivity.matches.some((match) =>\n candidates.has(normalizeRouteActivityPath(match.path))\n );\n}\n"],"mappings":";AASA,IAAI,uBAA8C;CAChD,MAAM;CACN,SAAS,CAAC;AACZ;AAEA,SAAS,2BAA2B,MAAsB;CAGxD,MAAM,aAFc,KAAK,MAAM,KAAK,CAAC,EAAE,MAAM,IACX,MAAM,KAAK,CAAC,EAAE,MAAM,OACpB;CAClC,MAAM,mBAAmB,SAAS,WAAW,GAAG,IAAI,WAAW,IAAI;CAEnE,OAAO,iBAAiB,SAAS,GAAG,KAAK,qBAAqB,MAC1D,iBAAiB,MAAM,GAAG,EAAE,IAC5B;AACN;AAEA,SAAS,qBAA6B;CACpC,IAAI,OAAO,WAAW,eAAe,OAAO,UAC1C,OAAO,OAAO,SAAS,YAAY;CAGrC,OAAO,qBAAqB;AAC9B;AAEA,SAAgB,0BACd,UACA,UAAyC,CAAC,GACpC;CACN,uBAAuB;EACrB,MAAM,2BAA2B,QAAQ;EACzC,SAAS,OAAO,OAAO,CAAC,GAAG,OAAO,CAAC;CACrC;AACF;AAEA,SAAgB,sBACd,aACS;CACT,MAAM,aAAa,IAAI,KACpB,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,GAAG,IACzD,0BACF,CACF;CAEA,MAAM,aAAa,2BAA2B,mBAAmB,CAAC;CAClE,IAAI,WAAW,IAAI,UAAU,GAC3B,OAAO;CAGT,OAAO,qBAAqB,QAAQ,MAAM,UACxC,WAAW,IAAI,2BAA2B,MAAM,IAAI,CAAC,CACvD;AACF"}
|
package/dist/common/router.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ import { RenderableChild } from "./vnode.js";
|
|
|
7
7
|
type RouteParams = Record<string, string>;
|
|
8
8
|
type StripRoutePathSuffix<Path extends string> = Path extends `${infer Base}?${string}` ? StripRoutePathSuffix<Base> : Path extends `${infer Base}#${string}` ? StripRoutePathSuffix<Base> : Path;
|
|
9
9
|
type TrimRoutePathSlashes<Path extends string> = Path extends `/${infer Rest}` ? TrimRoutePathSlashes<Rest> : Path extends `${infer Rest}/` ? TrimRoutePathSlashes<Rest> : Path;
|
|
10
|
-
type
|
|
10
|
+
type TrimRoutePathWhitespace<Path extends string> = Path extends `${' ' | '\n' | '\t' | '\r'}${infer Rest}` ? TrimRoutePathWhitespace<Rest> : Path extends `${infer Rest}${' ' | '\n' | '\t' | '\r'}` ? TrimRoutePathWhitespace<Rest> : Path;
|
|
11
|
+
type ExtractRouteSegmentParam<Segment extends string> = Segment extends `{${infer Param}}` ? TrimRoutePathWhitespace<Param> extends `*${infer SplatParam}` ? TrimRoutePathWhitespace<SplatParam> extends '' ? never : TrimRoutePathWhitespace<SplatParam> extends '*' ? never : TrimRoutePathWhitespace<SplatParam> : TrimRoutePathWhitespace<Param> extends '' ? never : TrimRoutePathWhitespace<Param> : Segment extends '*' ? '*' : never;
|
|
11
12
|
type ExtractRoutePathParamNames<Path extends string> = TrimRoutePathSlashes<StripRoutePathSuffix<Path>> extends `${infer Segment}/${infer Rest}` ? ExtractRouteSegmentParam<Segment> | ExtractRoutePathParamNames<Rest> : ExtractRouteSegmentParam<TrimRoutePathSlashes<StripRoutePathSuffix<Path>>>;
|
|
12
13
|
type RoutePathParams<Path extends string> = [ExtractRoutePathParamNames<Path>] extends [never] ? Record<never, string> : { [Key in ExtractRoutePathParamNames<Path>]: string };
|
|
13
14
|
/**
|
|
@@ -89,10 +90,11 @@ interface PageHelperOptions extends CommonAccessOptions {}
|
|
|
89
90
|
* - `static`: a literal path segment, e.g. `"users"` in `/users/{id}`
|
|
90
91
|
* - `param`: a `{name}` capture group — `value` holds the param name
|
|
91
92
|
* - `wildcard`: a bare `*` segment that captures exactly one segment
|
|
93
|
+
* - `splat`: a `{*name}` capture group that captures the remaining path
|
|
92
94
|
* - `catchall`: the `/*` catch-all that matches any depth
|
|
93
95
|
*/
|
|
94
96
|
interface ParsedSegment {
|
|
95
|
-
kind: 'static' | 'param' | 'wildcard' | 'catchall';
|
|
97
|
+
kind: 'static' | 'param' | 'wildcard' | 'splat' | 'catchall';
|
|
96
98
|
/** For static/wildcard/catchall: the literal text; for param: the param name. */
|
|
97
99
|
value: string;
|
|
98
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","names":[],"sources":["../../src/common/router.ts"],"mappings":";;;;;AAMA;KAAY,WAAA,GAAc,MAAM;AAAA,KAE3B,oBAAA,wBACH,IAAA,qCACI,oBAAA,CAAqB,IAAA,IACrB,IAAA,qCACE,oBAAA,CAAqB,IAAA,IACrB,IAAA;AAAA,KAEH,oBAAA,wBAA4C,IAAA,4BAC7C,oBAAA,CAAqB,IAAA,IACrB,IAAA,4BACE,oBAAA,CAAqB,IAAA,IACrB,IAAA;AAAA,KAED,wBAAA,2BACH,OAAA,8BACI,KAAA,
|
|
1
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;AAAA,UAGR,YAAA,iBAA6B,WAAA,GAAc,WAAA;EAAA,CACzD,MAAA,EAAQ,OAAA,EAAS,OAAA;IAAY,MAAA,EAAQ,WAAA;EAAA,IAAgB,eAAA;AAAA;AAAA,UAGvC,KAAA,iBAAsB,WAAA,GAAc,WAAA;EACnD,IAAA;EACA,OAAA,EAAS,YAAA,CAAa,OAAA;EACtB,SAAA;AAAA;AAAA,UAGe,aAAA,iBAA8B,WAAA,GAAc,WAAA;EAC3D,OAAA,EAAS,YAAA,CAAa,OAAA;EACtB,MAAA,EAAQ,OAAA;AAAA;AAAA,UAGO,UAAA,iBAA2B,WAAA,GAAc,WAAA;EACxD,IAAA;EACA,MAAA,EAAQ,QAAA,CAAS,OAAA;EACjB,IAAA;EACA,SAAA;AAAA;AAAA,UAGe,UAAA;EACf,GAAA,CAAI,GAAA;EACJ,MAAA,CAAO,GAAA;EACP,GAAA,CAAI,GAAA;EACJ,MAAA,IAAU,MAAM;AAAA;AAAA,UAGD,aAAA,iBAA8B,WAAA,GAAc,WAAA;EAC3D,IAAA;EACA,MAAA,EAAQ,QAAA,CAAS,OAAA;EACjB,KAAA,EAAO,QAAA,CAAS,UAAA;EAChB,IAAA;EAEA,IAAA;EACA,SAAA;EACA,OAAA,WAAkB,UAAA,CAAW,OAAA;AAAA"}
|
package/dist/common/ssr.d.ts
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
* Common call contracts: SSR types
|
|
4
4
|
*/
|
|
5
5
|
type SSRData = Record<string, unknown>;
|
|
6
|
+
interface DocumentRenderRoute {
|
|
7
|
+
path: string;
|
|
8
|
+
namespace?: string;
|
|
9
|
+
}
|
|
10
|
+
interface DocumentRenderContext {
|
|
11
|
+
mode: 'ssr' | 'ssg';
|
|
12
|
+
url: string;
|
|
13
|
+
pathname: string;
|
|
14
|
+
search: string;
|
|
15
|
+
hash: string;
|
|
16
|
+
params: Record<string, string>;
|
|
17
|
+
data?: SSRData;
|
|
18
|
+
seed: number;
|
|
19
|
+
route: DocumentRenderRoute;
|
|
20
|
+
}
|
|
21
|
+
interface DocumentRenderArgs {
|
|
22
|
+
appHtml: string;
|
|
23
|
+
context: DocumentRenderContext;
|
|
24
|
+
}
|
|
25
|
+
type DocumentRenderer = (args: DocumentRenderArgs) => string;
|
|
26
|
+
declare function renderDocument(document: DocumentRenderer, args: DocumentRenderArgs, apiName: string): string;
|
|
6
27
|
declare const SSR_RENDER_DATA_ATTR = "data-askr-render-data";
|
|
7
28
|
/** Full context for sink-based streaming SSR */
|
|
8
29
|
type SSRContext = {
|
|
@@ -17,5 +38,5 @@ type RenderContext = {
|
|
|
17
38
|
seed: number;
|
|
18
39
|
};
|
|
19
40
|
//#endregion
|
|
20
|
-
export { SSRData };
|
|
41
|
+
export { DocumentRenderArgs, DocumentRenderContext, DocumentRenderer, SSRData };
|
|
21
42
|
//# sourceMappingURL=ssr.d.ts.map
|
package/dist/common/ssr.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr.d.ts","names":[],"sources":["../../src/common/ssr.ts"],"mappings":";;AAIA;;KAAY,OAAA,GAAU,MAAM;AAAA,
|
|
1
|
+
{"version":3,"file":"ssr.d.ts","names":[],"sources":["../../src/common/ssr.ts"],"mappings":";;AAIA;;KAAY,OAAA,GAAU,MAAM;AAAA,UAEX,mBAAA;EACf,IAAA;EACA,SAAS;AAAA;AAAA,UAGM,qBAAA;EACf,IAAA;EACA,GAAA;EACA,QAAA;EACA,MAAA;EACA,IAAA;EACA,MAAA,EAAQ,MAAA;EACR,IAAA,GAAO,OAAA;EACP,IAAA;EACA,KAAA,EAAO,mBAAA;AAAA;AAAA,UAGQ,kBAAA;EACf,OAAA;EACA,OAAA,EAAS,qBAAqB;AAAA;AAAA,KAGpB,gBAAA,IAAoB,IAAwB,EAAlB,kBAAkB;AAAA,iBAExC,cAAA,CACd,QAAA,EAAU,gBAAA,EACV,IAAA,EAAM,kBAAkB,EACxB,OAAA;AAAA,cA0BW,oBAAA;;KAGD,UAAA;EACV,GAAA;EACA,IAAA;EACA,IAAA,GAAO,OAAA;EACP,MAAA,GAAS,MAAA;EACT,MAAA,GAAS,WAAA;AAAA;;KAIC,aAAA;EACV,IAAI;AAAA"}
|
package/dist/common/ssr.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
//#region src/common/ssr.ts
|
|
2
|
+
function renderDocument(document, args, apiName) {
|
|
3
|
+
const html = document(args);
|
|
4
|
+
if (typeof html !== "string") {
|
|
5
|
+
const received = typeof html === "object" && html !== null && "then" in html && typeof html.then === "function" ? "a Promise-like value" : html === null ? "null" : Array.isArray(html) ? "an array" : typeof html;
|
|
6
|
+
throw new Error(`${apiName} document() must synchronously return a string; received ${received}.`);
|
|
7
|
+
}
|
|
8
|
+
return html;
|
|
9
|
+
}
|
|
2
10
|
const SSR_RENDER_DATA_ATTR = "data-askr-render-data";
|
|
3
11
|
//#endregion
|
|
4
|
-
export { SSR_RENDER_DATA_ATTR };
|
|
12
|
+
export { SSR_RENDER_DATA_ATTR, renderDocument };
|
|
5
13
|
|
|
6
14
|
//# sourceMappingURL=ssr.js.map
|
package/dist/common/ssr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr.js","names":[],"sources":["../../src/common/ssr.ts"],"sourcesContent":["/**\n * Common call contracts: SSR types\n */\n\nexport type SSRData = Record<string, unknown>;\n\nexport const SSR_RENDER_DATA_ATTR = 'data-askr-render-data';\n\n/** Full context for sink-based streaming SSR */\nexport type SSRContext = {\n url: string;\n seed: number;\n data?: SSRData;\n params?: Record<string, string>;\n signal?: AbortSignal;\n};\n\n/** Lightweight context for synchronous render passes */\nexport type RenderContext = {\n seed: number;\n};\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"ssr.js","names":[],"sources":["../../src/common/ssr.ts"],"sourcesContent":["/**\n * Common call contracts: SSR types\n */\n\nexport type SSRData = Record<string, unknown>;\n\nexport interface DocumentRenderRoute {\n path: string;\n namespace?: string;\n}\n\nexport interface DocumentRenderContext {\n mode: 'ssr' | 'ssg';\n url: string;\n pathname: string;\n search: string;\n hash: string;\n params: Record<string, string>;\n data?: SSRData;\n seed: number;\n route: DocumentRenderRoute;\n}\n\nexport interface DocumentRenderArgs {\n appHtml: string;\n context: DocumentRenderContext;\n}\n\nexport type DocumentRenderer = (args: DocumentRenderArgs) => string;\n\nexport function renderDocument(\n document: DocumentRenderer,\n args: DocumentRenderArgs,\n apiName: string\n): string {\n const html = document(args);\n\n if (typeof html !== 'string') {\n const isPromiseLike =\n typeof html === 'object' &&\n html !== null &&\n 'then' in html &&\n typeof html.then === 'function';\n const received = isPromiseLike\n ? 'a Promise-like value'\n : html === null\n ? 'null'\n : Array.isArray(html)\n ? 'an array'\n : typeof html;\n\n throw new Error(\n `${apiName} document() must synchronously return a string; received ${received}.`\n );\n }\n\n return html;\n}\n\nexport const SSR_RENDER_DATA_ATTR = 'data-askr-render-data';\n\n/** Full context for sink-based streaming SSR */\nexport type SSRContext = {\n url: string;\n seed: number;\n data?: SSRData;\n params?: Record<string, string>;\n signal?: AbortSignal;\n};\n\n/** Lightweight context for synchronous render passes */\nexport type RenderContext = {\n seed: number;\n};\n"],"mappings":";AA8BA,SAAgB,eACd,UACA,MACA,SACQ;CACR,MAAM,OAAO,SAAS,IAAI;CAE1B,IAAI,OAAO,SAAS,UAAU;EAM5B,MAAM,WAJJ,OAAO,SAAS,YAChB,SAAS,QACT,UAAU,QACV,OAAO,KAAK,SAAS,aAEnB,yBACA,SAAS,OACP,SACA,MAAM,QAAQ,IAAI,IAChB,aACA,OAAO;EAEf,MAAM,IAAI,MACR,GAAG,QAAQ,2DAA2D,SAAS,EACjF;CACF;CAEA,OAAO;AACT;AAEA,MAAa,uBAAuB"}
|
package/dist/data/index.d.ts
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
//#region src/data/index.d.ts
|
|
2
2
|
type QueryConsistency = 'fresh' | 'stale' | 'refreshing' | 'pending-write';
|
|
3
3
|
type QueryStaleReason = 'aborted' | 'error' | 'inconsistent';
|
|
4
|
+
interface InvalidateOptions {
|
|
5
|
+
markPendingWrite?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface InvalidateOnIntervalOptions extends InvalidateOptions {
|
|
8
|
+
intervalMs: number;
|
|
9
|
+
activeOn?: string | readonly string[];
|
|
10
|
+
visibleOnly?: boolean;
|
|
11
|
+
focusedOnly?: boolean;
|
|
12
|
+
}
|
|
13
|
+
type QueryKeyPart = string | number | boolean | null | undefined | readonly QueryKeyPart[] | {
|
|
14
|
+
readonly [key: string]: QueryKeyPart;
|
|
15
|
+
};
|
|
16
|
+
interface QueryScope {
|
|
17
|
+
key(...parts: QueryKeyPart[]): string;
|
|
18
|
+
prefix(...parts: QueryKeyPart[]): string;
|
|
19
|
+
invalidate(parts: readonly QueryKeyPart[], options?: InvalidateOptions): void;
|
|
20
|
+
}
|
|
4
21
|
type QueryControls = {
|
|
5
22
|
refresh(): Promise<void>;
|
|
6
23
|
};
|
|
@@ -116,8 +133,10 @@ type MutationOptions<TInput, TResult> = {
|
|
|
116
133
|
afterSuccess?: 'invalidate';
|
|
117
134
|
};
|
|
118
135
|
declare function createQuery<T extends {}>(options: QueryOptions<T>): Query<T>;
|
|
119
|
-
declare function invalidate(prefix: string): void;
|
|
136
|
+
declare function invalidate(prefix: string, options?: InvalidateOptions): void;
|
|
137
|
+
declare function queryScope(namespace: string): QueryScope;
|
|
138
|
+
declare function invalidateOnInterval(prefix: string, options: InvalidateOnIntervalOptions): void;
|
|
120
139
|
declare function createMutation<TInput, TResult>(options: MutationOptions<TInput, TResult>): Mutation<TInput, TResult>;
|
|
121
140
|
//#endregion
|
|
122
|
-
export { Mutation, Query, QueryConsistency, QueryStaleReason, createMutation, createQuery, invalidate };
|
|
141
|
+
export { InvalidateOnIntervalOptions, InvalidateOptions, Mutation, Query, QueryConsistency, QueryKeyPart, QueryScope, QueryStaleReason, createMutation, createQuery, invalidate, invalidateOnInterval, queryScope };
|
|
123
142
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/data/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/data/index.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/data/index.ts"],"mappings":";KAwBY,gBAAA;AAAA,KAMA,gBAAA;AAAA,UAEK,iBAAA;EACf,gBAAgB;AAAA;AAAA,UAGD,2BAAA,SAAoC,iBAAiB;EACpE,UAAA;EACA,QAAA;EACA,WAAA;EACA,WAAA;AAAA;AAAA,KAGU,YAAA,2DAMC,YAAA;EAAA,UACG,GAAA,WAAc,YAAY;AAAA;AAAA,UAEzB,UAAA;EACf,GAAA,IAAO,KAAA,EAAO,YAAA;EACd,MAAA,IAAU,KAAA,EAAO,YAAA;EACjB,UAAA,CAAW,KAAA,WAAgB,YAAA,IAAgB,OAAA,GAAU,iBAAA;AAAA;AAAA,KAGlD,aAAA;EACH,OAAA,IAAW,OAAO;AAAA;AAAA,KAGf,YAAA;EACH,IAAA;EACA,KAAA;EACA,OAAA;EACA,UAAA;EACA,KAAA;EACA,WAAA;EACA,WAAA;AAAA;AAAA,KAGG,UAAA;EACH,IAAA,EAAM,CAAC;EACP,KAAA;EACA,OAAA;EACA,UAAA;EACA,KAAA;EACA,WAAA;EACA,WAAA;AAAA;AAAA,KAGG,eAAA;EACH,IAAA,EAAM,CAAC;EACP,KAAA;EACA,OAAA;EACA,UAAA;EACA,KAAA;EACA,WAAA;EACA,WAAA;AAAA;AAAA,KAGG,iBAAA;EACH,IAAA,EAAM,CAAC;EACP,KAAA;EACA,OAAA;EACA,UAAA;EACA,KAAA;EACA,WAAA;EACA,WAAA;AAAA;AAAA,KAGG,eAAA;EACH,IAAA,EAAM,CAAC;EACP,KAAA;EACA,OAAA;EACA,UAAA;EACA,KAAA;EACA,WAAA;EACA,WAAA;AAAA;AAAA,KAGG,wBAAA;EACH,IAAA,EA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Q,OAAA;EACjE,OAAA,IAAW,KAAA,EAAO,MAAA,EAAQ,MAAA,EAAQ,OAAA;EAClC,YAAA;AAAA;AAAA,iBAopBc,WAAA,eAA0B,OAAA,EAAS,YAAA,CAAa,CAAA,IAAK,KAAA,CAAM,CAAA;AAAA,iBA8C3D,UAAA,CAAW,MAAA,UAAgB,OAAA,GAAU,iBAAiB;AAAA,iBA6DtD,UAAA,CAAW,SAAA,WAAoB,UAAU;AAAA,iBA4BzC,oBAAA,CACd,MAAA,UACA,OAAA,EAAS,2BAA2B;AAAA,iBAoCtB,cAAA,kBACd,OAAA,EAAS,eAAA,CAAgB,MAAA,EAAQ,OAAA,IAChC,QAAA,CAAS,MAAA,EAAQ,OAAA"}
|
package/dist/data/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import { globalScheduler } from "../runtime/scheduler.js";
|
|
|
3
3
|
import { markReactivePropsDirtySource, markReadableDerivedSubscribersDirty, notifyReadableReaders, recordReadableRead } from "../runtime/readable.js";
|
|
4
4
|
import { claimHookIndex, getCurrentComponentInstance } from "../runtime/component.js";
|
|
5
5
|
import { getRenderContext } from "../ssr/context.js";
|
|
6
|
+
import { emitInvalidation } from "./invalidation-listeners.js";
|
|
7
|
+
import { documentVisible, routeActive, timer, windowFocused } from "../runtime/operations.js";
|
|
6
8
|
//#region src/data/index.ts
|
|
7
9
|
const RECONCILE_MAX_ATTEMPTS = 3;
|
|
8
10
|
const RECONCILE_RETRY_DELAY_MS = 25;
|
|
@@ -75,6 +77,10 @@ function normalizeAsyncDataError(error, fallbackMessage) {
|
|
|
75
77
|
return error ?? new Error(fallbackMessage);
|
|
76
78
|
}
|
|
77
79
|
function invalidateQueries(prefix, markPendingWrite) {
|
|
80
|
+
emitInvalidation({
|
|
81
|
+
prefix,
|
|
82
|
+
markPendingWrite
|
|
83
|
+
});
|
|
78
84
|
const cache = getQueryCache();
|
|
79
85
|
for (const [key, query] of cache) {
|
|
80
86
|
if (!key.startsWith(prefix)) continue;
|
|
@@ -462,8 +468,55 @@ function createQuery(options) {
|
|
|
462
468
|
cell.attach(instance, hookIndex);
|
|
463
469
|
return cell;
|
|
464
470
|
}
|
|
465
|
-
function invalidate(prefix) {
|
|
466
|
-
invalidateQueries(prefix, false);
|
|
471
|
+
function invalidate(prefix, options) {
|
|
472
|
+
invalidateQueries(prefix, options?.markPendingWrite ?? false);
|
|
473
|
+
}
|
|
474
|
+
function serializeQueryKeyNumber(part) {
|
|
475
|
+
if (Number.isNaN(part)) return "NaN";
|
|
476
|
+
if (Object.is(part, -0)) return "-0";
|
|
477
|
+
if (part === Infinity) return "Infinity";
|
|
478
|
+
if (part === -Infinity) return "-Infinity";
|
|
479
|
+
return String(part);
|
|
480
|
+
}
|
|
481
|
+
function serializeQueryKeyPart(part) {
|
|
482
|
+
if (typeof part === "symbol") throw new Error("[Askr] queryScope() key parts cannot be symbols.");
|
|
483
|
+
if (part === null) return "null";
|
|
484
|
+
if (part === void 0) return "undefined";
|
|
485
|
+
switch (typeof part) {
|
|
486
|
+
case "string": return `s=${encodeURIComponent(part)}`;
|
|
487
|
+
case "number": return `n=${serializeQueryKeyNumber(part)}`;
|
|
488
|
+
case "boolean": return `b=${part ? "1" : "0"}`;
|
|
489
|
+
case "object":
|
|
490
|
+
if (Array.isArray(part)) return `a[${part.map((item) => serializeQueryKeyPart(item)).join(",")}]`;
|
|
491
|
+
return `o{${Object.keys(part).sort().map((key) => `${encodeURIComponent(key)}=${serializeQueryKeyPart(part[key])}`).join(",")}}`;
|
|
492
|
+
default: return String(part);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
function queryScope(namespace) {
|
|
496
|
+
if (typeof namespace !== "string" || namespace.trim().length === 0) throw new Error("[Askr] queryScope() requires a non-empty namespace string.");
|
|
497
|
+
const build = (parts) => [namespace, ...parts].map(serializeQueryKeyPart).join(":") + ":";
|
|
498
|
+
return {
|
|
499
|
+
key(...parts) {
|
|
500
|
+
return build(parts);
|
|
501
|
+
},
|
|
502
|
+
prefix(...parts) {
|
|
503
|
+
return build(parts);
|
|
504
|
+
},
|
|
505
|
+
invalidate(parts, options) {
|
|
506
|
+
invalidate(build(parts), options);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
const INVALIDATE_ON_INTERVAL_OPTIONS_ERROR = "[Askr] invalidateOnInterval() requires an options object with a finite numeric intervalMs.";
|
|
511
|
+
function invalidateOnInterval(prefix, options) {
|
|
512
|
+
if (!options || typeof options !== "object" || typeof options.intervalMs !== "number" || !Number.isFinite(options.intervalMs)) throw new Error(INVALIDATE_ON_INTERVAL_OPTIONS_ERROR);
|
|
513
|
+
const when = [];
|
|
514
|
+
if (options.activeOn) when.push(routeActive(options.activeOn));
|
|
515
|
+
if (options.visibleOnly) when.push(documentVisible());
|
|
516
|
+
if (options.focusedOnly) when.push(windowFocused());
|
|
517
|
+
timer(options.intervalMs, () => {
|
|
518
|
+
invalidate(prefix, { markPendingWrite: options.markPendingWrite });
|
|
519
|
+
}, when.length > 0 ? { when } : void 0);
|
|
467
520
|
}
|
|
468
521
|
function createMutation(options) {
|
|
469
522
|
const instance = getCurrentComponentInstance();
|
|
@@ -481,6 +534,6 @@ function createMutation(options) {
|
|
|
481
534
|
return created;
|
|
482
535
|
}
|
|
483
536
|
//#endregion
|
|
484
|
-
export { createMutation, createQuery, invalidate };
|
|
537
|
+
export { createMutation, createQuery, invalidate, invalidateOnInterval, queryScope };
|
|
485
538
|
|
|
486
539
|
//# sourceMappingURL=index.js.map
|