@askrjs/askr 0.0.36 → 0.0.38
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/README.md +17 -9
- package/dist/bench/components/benchmark-table.js +2 -2
- package/dist/bench/components/benchmark-table.js.map +1 -1
- package/dist/benchmark.js +3 -3
- package/dist/boot/index.d.ts +1 -7
- package/dist/boot/index.d.ts.map +1 -1
- package/dist/boot/index.js +22 -13
- package/dist/boot/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/link.d.ts +4 -5
- package/dist/components/link.d.ts.map +1 -1
- package/dist/components/link.js +2 -1
- package/dist/components/link.js.map +1 -1
- package/dist/foundations/icon/icon.d.ts.map +1 -1
- package/dist/foundations/icon/icon.js.map +1 -1
- package/dist/foundations/icon/icon.types.d.ts +2 -1
- package/dist/foundations/icon/icon.types.d.ts.map +1 -1
- package/dist/foundations/icon/index.d.ts +3 -0
- package/dist/foundations/icon/index.js +2 -0
- package/dist/foundations/index.d.ts +1 -18
- package/dist/foundations/index.js +2 -18
- package/dist/foundations/interactions/index.d.ts +7 -0
- package/dist/foundations/interactions/index.js +7 -0
- package/dist/foundations/interactions/interaction-policy.js +2 -2
- package/dist/foundations/state/index.d.ts +2 -0
- package/dist/foundations/state/index.js +2 -0
- package/dist/foundations/structures/index.d.ts +8 -0
- package/dist/foundations/structures/index.js +7 -0
- package/dist/foundations/utilities/index.d.ts +7 -0
- package/dist/foundations/utilities/index.js +6 -0
- package/dist/index.d.ts +3 -14
- package/dist/index.js +2 -14
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/renderer/dom.js +26 -366
- package/dist/renderer/dom.js.map +1 -1
- package/dist/renderer/evaluate.js.map +1 -1
- package/dist/renderer/fastpath.js +20 -18
- package/dist/renderer/fastpath.js.map +1 -1
- package/dist/renderer/for-commit.js +486 -0
- package/dist/renderer/for-commit.js.map +1 -0
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/keyed.js +84 -23
- package/dist/renderer/keyed.js.map +1 -1
- package/dist/renderer/reconcile.js +11 -18
- package/dist/renderer/reconcile.js.map +1 -1
- package/dist/renderer/utils.js +5 -1
- package/dist/renderer/utils.js.map +1 -1
- package/dist/resources/index.d.ts +1 -2
- package/dist/resources/index.js +1 -2
- package/dist/router/route.js +1 -1
- package/dist/runtime/for.d.ts.map +1 -1
- package/dist/runtime/for.js +33 -21
- package/dist/runtime/for.js.map +1 -1
- package/dist/runtime/operations.js +1 -1
- package/dist/runtime/selector.d.ts.map +1 -1
- package/dist/runtime/selector.js +180 -103
- package/dist/runtime/selector.js.map +1 -1
- package/dist/runtime/state.d.ts +12 -4
- package/dist/runtime/state.d.ts.map +1 -1
- package/dist/runtime/state.js +1 -1
- package/dist/runtime/state.js.map +1 -1
- package/dist/ssg/index.d.ts +1 -6
- package/dist/ssg/index.js +1 -6
- package/dist/ssr/context.d.ts +2 -1
- package/dist/ssr/context.d.ts.map +1 -1
- package/dist/ssr/context.js +28 -11
- package/dist/ssr/context.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -31
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/index.js +4 -46
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/render-keys.js +1 -12
- package/dist/ssr/render-keys.js.map +1 -1
- package/dist/ssr/verify-hydration.js +25 -0
- package/dist/ssr/verify-hydration.js.map +1 -0
- package/package.json +39 -16
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/foundations/core.d.ts +0 -15
- package/dist/foundations/core.js +0 -13
- package/dist/foundations/structures.d.ts +0 -7
- package/dist/foundations/structures.js +0 -6
- package/dist/ssg/batch-render.d.ts +0 -16
- package/dist/ssg/batch-render.d.ts.map +0 -1
- package/dist/ssg/generate-metadata.d.ts +0 -24
- package/dist/ssg/generate-metadata.d.ts.map +0 -1
- package/dist/ssg/resolve-ssg-data.d.ts +0 -23
- package/dist/ssg/resolve-ssg-data.d.ts.map +0 -1
- package/dist/ssg/route-utils.d.ts +0 -16
- package/dist/ssg/route-utils.d.ts.map +0 -1
- package/dist/ssg/write-static-files.d.ts +0 -15
- package/dist/ssg/write-static-files.d.ts.map +0 -1
- package/dist/ssr/render-keys.d.ts +0 -37
- package/dist/ssr/render-keys.d.ts.map +0 -1
- package/dist/ssr/stream-render.js +0 -88
- package/dist/ssr/stream-render.js.map +0 -1
package/dist/ssr/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../src/ssr/context.ts"],"sourcesContent":["/**\n * SSR Context Management\n *\n * Provides
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../src/ssr/context.ts"],"sourcesContent":["/**\n * SSR Context Management\n *\n * Provides render-context storage for server-side rendering.\n * Node SSR lazily installs AsyncLocalStorage on first use; browser builds use\n * the fallback stack.\n */\n\nimport { SSRDataMissingError } from './errors';\nimport { clearEscapeCache } from './escape';\n\nexport type { SSRData } from '../common/ssr';\nimport type { SSRData } from '../common/ssr';\nimport type { Route, RouteAuthOptions } from '../common/router';\n\n// Unified per-render context combining SSRContext and RenderContext\nexport interface RenderContext {\n url: string;\n seed: number;\n data?: SSRData;\n params?: Record<string, string>;\n routes?: readonly Route[];\n routeAuth?: RouteAuthOptions;\n signal?: AbortSignal;\n queryCache?: Map<string, unknown>;\n // Per-render key state (moved from render-keys.ts globals)\n keyCounter: number;\n renderData: Record<string, unknown> | null;\n}\n\n// Legacy alias for compatibility\nexport type SSRContext = RenderContext;\n\ntype RenderContextAccessor = {\n getStore(): RenderContext | undefined;\n run<R>(store: RenderContext, fn: () => R): R;\n};\n\ntype AsyncHooksModule = {\n AsyncLocalStorage?: new () => RenderContextAccessor;\n};\n\nlet renderContextAccessor: RenderContextAccessor | null = null;\nlet renderContextAccessorInitialized = false;\n\n// Fallback stack for non-Node environments\nlet fallbackStack: RenderContext | null = null;\n\nfunction ensureRenderContextAccessor(): void {\n if (renderContextAccessorInitialized) {\n return;\n }\n\n renderContextAccessorInitialized = true;\n\n if (typeof process === 'undefined' || !process.versions?.node) {\n return;\n }\n\n try {\n // Hide the Node builtin from browser dependency scanners.\n // eslint-disable-next-line @typescript-eslint/no-implied-eval\n const loadAsyncHooks = new Function(\n 'return require(' + JSON.stringify('async_hooks') + ');'\n ) as () => AsyncHooksModule;\n const asyncHooks = loadAsyncHooks();\n\n if (asyncHooks.AsyncLocalStorage) {\n const asyncLocalStorage = new asyncHooks.AsyncLocalStorage();\n renderContextAccessor = {\n getStore() {\n return asyncLocalStorage.getStore();\n },\n run<R>(store: RenderContext, fn: () => R): R {\n return asyncLocalStorage.run(store, fn);\n },\n };\n }\n } catch {\n // Keep the fallback stack when async_hooks is unavailable.\n }\n}\n\nexport function createRenderContext(\n seed = 12345,\n opts: {\n url?: string;\n data?: SSRData;\n params?: Record<string, string>;\n routes?: readonly Route[];\n routeAuth?: RouteAuthOptions;\n signal?: AbortSignal;\n } = {}\n): RenderContext {\n clearEscapeCache();\n\n return {\n url: opts.url ?? '',\n seed,\n data: opts.data,\n params: opts.params,\n routes: opts.routes,\n routeAuth: opts.routeAuth,\n signal: opts.signal,\n queryCache: new Map<string, unknown>(),\n keyCounter: 0,\n renderData: null,\n };\n}\n\n/**\n * Run a function with the given render context.\n * Concurrency-safe in Node.js via AsyncLocalStorage.\n */\nexport function withRenderContext<T>(ctx: RenderContext, fn: () => T): T {\n ensureRenderContextAccessor();\n if (renderContextAccessor) {\n return renderContextAccessor.run(ctx, fn);\n }\n // Fallback: stack-based (not concurrency-safe)\n const prev = fallbackStack;\n fallbackStack = ctx;\n try {\n return fn();\n } finally {\n fallbackStack = prev;\n }\n}\n\n/**\n * Get the current render context.\n * Returns null if not inside a render.\n */\nexport function getRenderContext(): RenderContext | null {\n ensureRenderContextAccessor();\n if (renderContextAccessor) {\n return renderContextAccessor.getStore() ?? null;\n }\n return fallbackStack;\n}\n\n// Legacy API aliases (deprecated, for backwards compatibility)\nexport const getSSRContext = getRenderContext;\nexport const withSSRContext = withRenderContext;\nexport const getCurrentSSRContext = getRenderContext;\n\nexport function runWithSSRContext<T>(ctx: RenderContext, fn: () => T): T {\n // This was a separate path for sync detection; now unified\n return withRenderContext(ctx, fn);\n}\n\n/**\n * Centralized SSR enforcement helper — throws a consistent error when async\n * data is encountered during synchronous SSR.\n */\nexport function throwSSRDataMissing(): never {\n throw new SSRDataMissingError();\n}\n\nexport { SSRDataMissingError };\n"],"mappings":";;;;;;;;;;;AA0CA,IAAI,wBAAsD;AAC1D,IAAI,mCAAmC;AAGvC,IAAI,gBAAsC;AAE1C,SAAS,8BAAoC;CAC3C,IAAI,kCACF;CAGF,mCAAmC;CAEnC,IAAI,OAAO,YAAY,eAAe,CAAC,QAAQ,UAAU,MACvD;CAGF,IAAI;EAMF,MAAM,aAAa,IAHQ,SACzB,oBAAoB,KAAK,UAAU,cAAc,GAAG,KAEnC,EAAgB;EAEnC,IAAI,WAAW,mBAAmB;GAChC,MAAM,oBAAoB,IAAI,WAAW,mBAAmB;GAC5D,wBAAwB;IACtB,WAAW;KACT,OAAO,kBAAkB,UAAU;;IAErC,IAAO,OAAsB,IAAgB;KAC3C,OAAO,kBAAkB,IAAI,OAAO,GAAG;;IAE1C;;SAEG;;AAKV,SAAgB,oBACd,OAAO,OACP,OAOI,EAAE,EACS;CACf,kBAAkB;CAElB,OAAO;EACL,KAAK,KAAK,OAAO;EACjB;EACA,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,QAAQ,KAAK;EACb,4BAAY,IAAI,KAAsB;EACtC,YAAY;EACZ,YAAY;EACb;;;;;;AAOH,SAAgB,kBAAqB,KAAoB,IAAgB;CACvE,6BAA6B;CAC7B,IAAI,uBACF,OAAO,sBAAsB,IAAI,KAAK,GAAG;CAG3C,MAAM,OAAO;CACb,gBAAgB;CAChB,IAAI;EACF,OAAO,IAAI;WACH;EACR,gBAAgB;;;;;;;AAQpB,SAAgB,mBAAyC;CACvD,6BAA6B;CAC7B,IAAI,uBACF,OAAO,sBAAsB,UAAU,IAAI;CAE7C,OAAO;;;;;;AAiBT,SAAgB,sBAA6B;CAC3C,MAAM,IAAI,qBAAqB"}
|
package/dist/ssr/index.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { JSXElement } from "../common/jsx.js";
|
|
2
2
|
import { RouteAuthOptions, RouteHandler, RouteManifest, RouteRequestResult } from "../common/router.js";
|
|
3
|
-
import { SSRData } from "../common/ssr.js";
|
|
4
3
|
import { SSRDataMissingError } from "../common/ssr-errors.js";
|
|
4
|
+
import { SSRData } from "../common/ssr.js";
|
|
5
5
|
import { SSRComponent, VNode } from "./types.js";
|
|
6
|
-
import { ResourcePlan, collectResources, resolvePlan, resolveResources } from "./render-keys.js";
|
|
7
6
|
|
|
8
7
|
//#region src/ssr/index.d.ts
|
|
9
|
-
type Component = SSRComponent;
|
|
10
|
-
declare function pushSSRStrictPurityGuard(): void;
|
|
11
|
-
declare function popSSRStrictPurityGuard(): void;
|
|
12
8
|
/**
|
|
13
9
|
* Single synchronous SSR entrypoint: render a component to an HTML string.
|
|
14
10
|
* This is strictly synchronous and deterministic. Optionally provide a seed
|
|
@@ -43,31 +39,6 @@ declare function resolveRequest(opts: {
|
|
|
43
39
|
auth?: RouteAuthOptions;
|
|
44
40
|
signal?: AbortSignal;
|
|
45
41
|
}): Promise<RouteRequestResult>;
|
|
46
|
-
declare function renderToStringSyncForUrl(opts: {
|
|
47
|
-
url: string;
|
|
48
|
-
routes: Array<{
|
|
49
|
-
path: string;
|
|
50
|
-
handler: RouteHandler;
|
|
51
|
-
namespace?: string;
|
|
52
|
-
}>;
|
|
53
|
-
options?: {
|
|
54
|
-
seed?: number;
|
|
55
|
-
data?: SSRData;
|
|
56
|
-
};
|
|
57
|
-
}): string;
|
|
58
|
-
declare function verifyHydrationSyncForUrl(opts: {
|
|
59
|
-
root: Element;
|
|
60
|
-
url: string;
|
|
61
|
-
routes: Array<{
|
|
62
|
-
path: string;
|
|
63
|
-
handler: RouteHandler;
|
|
64
|
-
namespace?: string;
|
|
65
|
-
}>;
|
|
66
|
-
options?: {
|
|
67
|
-
seed?: number;
|
|
68
|
-
data?: SSRData;
|
|
69
|
-
};
|
|
70
|
-
}): boolean;
|
|
71
42
|
type SSRRoute = {
|
|
72
43
|
path: string;
|
|
73
44
|
handler: RouteHandler;
|
|
@@ -89,5 +60,5 @@ declare function renderToStream(opts: {
|
|
|
89
60
|
onComplete(): void;
|
|
90
61
|
}): void;
|
|
91
62
|
//#endregion
|
|
92
|
-
export {
|
|
63
|
+
export { type SSRComponent, SSRDataMissingError, SSRRoute, type VNode, renderResolvedToStringSync, renderToStream, renderToString, renderToStringSync, resolveRequest };
|
|
93
64
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ssr/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/ssr/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/ssr/index.ts"],"mappings":";;;;;;;;;;;;iBA4nCgB,kBAAA,CACd,SAAA,GACE,KAAA,GAAQ,MAAA,sBACL,KAAA,GAAQ,UAAA,iDACb,KAAA,GAAQ,MAAA,mBACR,OAAA;EAAY,IAAA;EAAe,IAAA,GAAO,OAAA;AAAA;AAAA,iBA2BpB,0BAAA,CAA2B,IAAA;EACzC,GAAA;EACA,MAAA,EAAQ,KAAA;IAAQ,IAAA;IAAc,OAAA,EAAS,YAAA;IAAc,SAAA;EAAA;EACrD,OAAA,EAAS,YAAA;EACT,MAAA,GAAS,MAAA;EACT,OAAA;IAAY,IAAA;IAAe,IAAA,GAAO,OAAA;EAAA;AAAA;AAAA,iBA6Bd,cAAA,CAAe,IAAA;EACnC,GAAA;EACA,QAAA,GAAW,aAAA;EACX,MAAA,GAAS,KAAA;IAAQ,IAAA;IAAc,OAAA,EAAS,YAAA;IAAc,SAAA;EAAA;EACtD,IAAA,GAAO,gBAAA;EACP,MAAA,GAAS,WAAA;AAAA,IACP,OAAA,CAAQ,kBAAA;AAAA,KAqCA,QAAA;EACV,IAAA;EACA,OAAA,EAAS,YAAA;EACT,SAAA;AAAA;AAAA,iBAGc,cAAA,CACd,SAAA,GACE,KAAA,GAAQ,MAAA,sBACL,KAAA,GAAQ,UAAA;AAAA,iBAEC,cAAA,CAAe,IAAA;EAC7B,GAAA;EACA,MAAA,EAAQ,QAAA;EACR,IAAA;EACA,IAAA,GAAO,OAAA;AAAA;AAAA,iBAuBO,cAAA,CAAe,IAAA;EAC7B,GAAA;EACA,MAAA,EAAQ,QAAA;EACR,IAAA;EACA,IAAA,GAAO,OAAA;EACP,OAAA,CAAQ,IAAA;EACR,UAAA;AAAA"}
|
package/dist/ssr/index.js
CHANGED
|
@@ -5,17 +5,16 @@ import { ELEMENT_TYPE, Fragment } from "../common/jsx.js";
|
|
|
5
5
|
import { createComponentInstance, getCurrentComponentInstance, setCurrentComponentInstance } from "../runtime/component.js";
|
|
6
6
|
import { evaluateForState } from "../runtime/for.js";
|
|
7
7
|
import { evaluateCaseState, evaluateShowState } from "../runtime/control.js";
|
|
8
|
-
import { installSSRBridge } from "../runtime/ssr-bridge.js";
|
|
9
8
|
import { SSRDataMissingError } from "../common/ssr-errors.js";
|
|
10
9
|
import { VOID_ELEMENTS, escapeText, styleObjToCss } from "./escape.js";
|
|
11
10
|
import { createRenderContext, getRenderContext, throwSSRDataMissing, withRenderContext } from "./context.js";
|
|
12
11
|
import { resolveRouteFromRoutes, resolveRouteRequest } from "../router/route.js";
|
|
13
12
|
import "../jsx/index.js";
|
|
14
13
|
import { DefaultPortal } from "../foundations/structures/portal.js";
|
|
15
|
-
import {
|
|
14
|
+
import { installSSRBridge } from "../runtime/ssr-bridge.js";
|
|
15
|
+
import { getCurrentRenderData, getNextKey, startRenderPhase, stopRenderPhase } from "./render-keys.js";
|
|
16
16
|
import { renderAttrs, renderAttrsDirect } from "./attrs.js";
|
|
17
17
|
import { StreamSink, StringSink } from "./sink.js";
|
|
18
|
-
import { renderNodeToSink } from "./stream-render.js";
|
|
19
18
|
//#region src/ssr/index.ts
|
|
20
19
|
const __SSR_DEBUG = process.env.ASKR_SSR_DEBUG === "1" || process.env.ASKR_SSR_DEBUG === "true";
|
|
21
20
|
function isSSRAttrEventHandler(key) {
|
|
@@ -568,14 +567,6 @@ function verifyExpectedNode(node, state, ctx) {
|
|
|
568
567
|
state.current = actualElement.nextSibling;
|
|
569
568
|
return true;
|
|
570
569
|
}
|
|
571
|
-
function verifyHydrationRoot(root, node, ctx) {
|
|
572
|
-
const state = {
|
|
573
|
-
current: root.firstChild,
|
|
574
|
-
pendingText: ""
|
|
575
|
-
};
|
|
576
|
-
if (!verifyExpectedNode(node, state, ctx)) return false;
|
|
577
|
-
return flushPendingText(state) && state.current === null;
|
|
578
|
-
}
|
|
579
570
|
function verifyExpectedChildren(children, state, ctx) {
|
|
580
571
|
if (!children || children.length === 0) return true;
|
|
581
572
|
for (let index = 0; index < children.length; index += 1) if (!verifyExpectedNode(children[index], state, ctx)) return false;
|
|
@@ -643,39 +634,6 @@ async function resolveRequest(opts) {
|
|
|
643
634
|
params: resolved.params
|
|
644
635
|
};
|
|
645
636
|
}
|
|
646
|
-
function renderToStringSyncForUrl(opts) {
|
|
647
|
-
const { url, routes, options } = opts;
|
|
648
|
-
const routeTable = routes.map((route) => ({ ...route }));
|
|
649
|
-
const resolved = resolveRouteFromRoutes(new URL(url, "http://localhost").pathname, routeTable);
|
|
650
|
-
if (!resolved) throw new Error(`renderToStringSyncForUrl: no route found for url: ${url}`);
|
|
651
|
-
return renderResolvedToStringSync({
|
|
652
|
-
url,
|
|
653
|
-
routes: routeTable,
|
|
654
|
-
handler: resolved.handler,
|
|
655
|
-
params: resolved.params,
|
|
656
|
-
options
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
function verifyHydrationSyncForUrl(opts) {
|
|
660
|
-
const { root, url, routes, options } = opts;
|
|
661
|
-
const routeTable = routes.map((route) => ({ ...route }));
|
|
662
|
-
const resolved = resolveRouteFromRoutes(new URL(url, "http://localhost").pathname, routeTable);
|
|
663
|
-
if (!resolved) throw new Error(`verifyHydrationSyncForUrl: no route found for url: ${url}`);
|
|
664
|
-
const ctx = createRenderContext(options?.seed ?? 12345, {
|
|
665
|
-
url,
|
|
666
|
-
data: options?.data,
|
|
667
|
-
params: resolved.params,
|
|
668
|
-
routes: routeTable
|
|
669
|
-
});
|
|
670
|
-
return withRenderContext(ctx, () => {
|
|
671
|
-
startRenderPhase(options?.data ?? null);
|
|
672
|
-
try {
|
|
673
|
-
return verifyHydrationRoot(root, renderSyncComponentRoot(resolved.handler, resolved.params || {}, ctx), ctx);
|
|
674
|
-
} finally {
|
|
675
|
-
stopRenderPhase();
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
637
|
function renderToString(arg) {
|
|
680
638
|
if (typeof arg === "function") return renderToStringSync(arg);
|
|
681
639
|
const opts = arg;
|
|
@@ -709,13 +667,13 @@ function renderToSinkInternal(opts) {
|
|
|
709
667
|
withRenderContext(ctx, () => {
|
|
710
668
|
startRenderPhase(data || null);
|
|
711
669
|
try {
|
|
712
|
-
|
|
670
|
+
renderNodeSyncToSink(executeComponentSync(resolved.handler, resolved.params, ctx), sink, ctx);
|
|
713
671
|
} finally {
|
|
714
672
|
stopRenderPhase();
|
|
715
673
|
}
|
|
716
674
|
});
|
|
717
675
|
}
|
|
718
676
|
//#endregion
|
|
719
|
-
export { SSRDataMissingError,
|
|
677
|
+
export { SSRDataMissingError, renderResolvedToStringSync, renderToStream, renderToString, renderToStringSync, resolveRequest };
|
|
720
678
|
|
|
721
679
|
//# sourceMappingURL=index.js.map
|
package/dist/ssr/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RouteModule.resolveRouteRequest","RouteModule.resolveRouteFromRoutes"],"sources":["../../src/ssr/index.ts"],"sourcesContent":["/**\n * SSR - Server-Side Rendering\n *\n * Renders Askr components to static HTML strings for server-side rendering.\n * SSR is synchronous: async components are not supported; async work should use\n * `resource()` which is rejected during synchronous SSR. This module throws\n * when an async component or async resource is encountered during sync SSR.\n *\n * Concurrency: Each render call uses AsyncLocalStorage (Node.js) to isolate\n * render state, making concurrent SSR requests safe.\n */\n\nimport type { JSXElement } from '../common/jsx';\nimport { __CONTROL_BOUNDARY__ } from '../common/control';\nimport type {\n RouteAuthOptions,\n RouteHandler,\n RouteManifest,\n RouteRequestResult,\n} from '../common/router';\nimport * as RouteModule from '../router/route';\nimport type { Props } from '../common/props';\nimport { Fragment, ELEMENT_TYPE } from '../jsx';\nimport { DefaultPortal } from '../foundations/structures/portal';\nimport {\n createRenderContext,\n getRenderContext,\n withRenderContext,\n throwSSRDataMissing,\n type RenderContext,\n type SSRData,\n} from './context';\nimport { installSSRBridge } from '../runtime/ssr-bridge';\nimport { getCurrentRenderData, getNextKey } from './render-keys';\nimport {\n createComponentInstance,\n setCurrentComponentInstance,\n getCurrentComponentInstance,\n} from '../runtime/component';\nimport type { ComponentFunction } from '../common/component';\nimport type { DOMElement } from '../common/vnode';\nimport { __ERROR_BOUNDARY__ } from '../common/vnode';\nimport { VOID_ELEMENTS, escapeText, styleObjToCss } from './escape';\nimport { renderAttrs, renderAttrsDirect } from './attrs';\nimport type { VNode, SSRComponent } from './types';\n\nimport { logger } from '../dev/logger';\nimport {\n type ControlBoundaryState,\n evaluateCaseState,\n evaluateShowState,\n} from '../runtime/control';\nimport { evaluateForState } from '../runtime/for';\n\nconst __SSR_DEBUG =\n process.env.NODE_ENV !== 'production' &&\n (process.env.ASKR_SSR_DEBUG === '1' || process.env.ASKR_SSR_DEBUG === 'true');\n\nfunction isSSRAttrEventHandler(key: string): boolean {\n return (\n key.length >= 3 &&\n key.charCodeAt(0) === 111 &&\n key.charCodeAt(1) === 110 &&\n key.charCodeAt(2) >= 65 &&\n key.charCodeAt(2) <= 90\n );\n}\n\nfunction inheritRenderableKey(\n source: VNode | JSXElement,\n result: VNode | JSXElement\n): VNode | JSXElement {\n const inheritedKey = (source as DOMElement).key;\n if (inheritedKey === undefined || inheritedKey === null) {\n return result;\n }\n\n if (!result || typeof result !== 'object' || !('type' in result)) {\n return result;\n }\n\n const resultVNode = result as DOMElement;\n if (resultVNode.key === undefined || resultVNode.key === null) {\n resultVNode.key = inheritedKey;\n }\n\n if (typeof resultVNode.type === 'string') {\n if (!resultVNode.props) {\n resultVNode.props = {};\n }\n\n if (resultVNode.props['data-key'] === undefined) {\n resultVNode.props['data-key'] = String(inheritedKey);\n }\n }\n\n return result;\n}\n\n// Install SSR bridge once so runtime primitives (resource/derive/etc) can\n// detect SSR mode and access deterministic render-phase data without a\n// runtime->ssr import.\ninstallSSRBridge({\n getCurrentSSRContext: getRenderContext,\n throwSSRDataMissing,\n getCurrentRenderData,\n getNextKey,\n});\n\nexport { SSRDataMissingError } from './context';\nexport type { VNode, SSRComponent } from './types';\n\n// Re-export for backwards compatibility\nexport type Component = SSRComponent;\n\n// Dev-only SSR strictness guard helpers. We mutate globals in dev to make\n// accidental usage of Math.random/Date.now during sync SSR fail fast.\n// We implement a re-entrant stack so nested or concurrent calls don't clobber\n// global values unexpectedly.\nconst __ssrGuardStack: Array<{ random: () => number; now: () => number }> = [];\n\nexport function pushSSRStrictPurityGuard() {\n /* istanbul ignore if - dev-only guard */\n if (process.env.NODE_ENV === 'production') return;\n __ssrGuardStack.push({\n random: Reflect.get(Math, 'random') as () => number,\n now: Reflect.get(Date, 'now') as () => number,\n });\n Reflect.set(Math, 'random', () => {\n throw new Error(\n 'SSR Strict Purity: Math.random is not allowed during synchronous SSR. Use the provided `ssr` context RNG instead.'\n );\n });\n Reflect.set(Date, 'now', () => {\n throw new Error(\n 'SSR Strict Purity: Date.now is not allowed during synchronous SSR. Pass timestamps explicitly or use deterministic helpers.'\n );\n });\n}\n\nexport function popSSRStrictPurityGuard() {\n /* istanbul ignore if - dev-only guard */\n if (process.env.NODE_ENV === 'production') return;\n const prev = __ssrGuardStack.pop();\n if (prev) {\n Reflect.set(Math, 'random', prev.random);\n Reflect.set(Date, 'now', prev.now);\n }\n}\n\n/**\n * Synchronous rendering helpers (used for strictly synchronous SSR)\n */\nfunction renderChildSync(child: unknown, ctx: RenderContext): string {\n if (typeof child === 'string') return escapeText(child);\n if (typeof child === 'number') return escapeText(String(child));\n if (child === null || child === undefined || child === false) return '';\n if (child && typeof child === 'object' && 'type' in child) {\n // We already verified the shape above; assert as VNode for the sync renderer\n return renderNodeSync(child as VNode, ctx);\n }\n return '';\n}\n\nfunction renderChildSyncToSink(\n child: unknown,\n sink: { write(html: string): void },\n ctx: RenderContext\n): void {\n if (child === null || child === undefined || child === false) return;\n if (typeof child === 'string') {\n sink.write(escapeText(child));\n return;\n }\n if (typeof child === 'number') {\n sink.write(escapeText(String(child)));\n return;\n }\n if (child && typeof child === 'object' && 'type' in child) {\n renderNodeSyncToSink(child as VNode, sink, ctx);\n }\n}\n\nfunction renderChildrenSync(\n children: unknown[] | undefined,\n ctx: RenderContext\n): string {\n if (!children || !Array.isArray(children) || children.length === 0) return '';\n if (children.length === 1) return renderChildSync(children[0], ctx);\n\n // Small child arrays are common; concatenation is usually faster than\n // allocating + joining. Large sibling lists (10k+) need join to avoid O(n^2)\n // concatenation costs.\n if (children.length <= 8) {\n let result = '';\n for (const child of children) result += renderChildSync(child, ctx);\n return result;\n }\n\n const parts = Array.from({ length: children.length }, (_, index) =>\n renderChildSync(children[index], ctx)\n );\n return parts.join('');\n}\n\nfunction normalizeRenderableChildren(value: unknown): unknown[] {\n if (value === null || value === undefined || value === false) {\n return [];\n }\n\n return Array.isArray(value) ? value : [value];\n}\n\nfunction getErrorBoundaryState(\n node: VNode | JSXElement\n): NonNullable<ComponentInstance['errorBoundaryState']> | null {\n return (\n (node as DOMElement & { __instance?: ComponentInstance }).__instance\n ?.errorBoundaryState ?? null\n );\n}\n\nfunction createDefaultErrorBoundaryFallbackVNode(error: unknown): JSXElement {\n const message =\n error instanceof Error\n ? error.stack || error.message || error.name\n : typeof error === 'string'\n ? error\n : (() => {\n try {\n return JSON.stringify(error);\n } catch {\n return String(error);\n }\n })();\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: 'div',\n props: {\n role: 'alert',\n 'data-askr-error-boundary': 'true',\n style: {\n boxSizing: 'border-box',\n padding: '1rem',\n border: '1px solid currentColor',\n borderRadius: '0.75rem',\n display: 'grid',\n gap: '0.75rem',\n maxWidth: '100%',\n },\n children: [\n {\n $$typeof: ELEMENT_TYPE,\n type: 'strong',\n props: {\n children: ['Something went wrong while rendering this view.'],\n },\n },\n {\n $$typeof: ELEMENT_TYPE,\n type: 'p',\n props: {\n style: { margin: '0' },\n children: [\n 'The app recovered into a visible fallback so the error is not hidden in the console.',\n ],\n },\n },\n {\n $$typeof: ELEMENT_TYPE,\n type: 'details',\n props: {\n open: process.env.NODE_ENV !== 'production',\n children: [\n {\n $$typeof: ELEMENT_TYPE,\n type: 'summary',\n props: {\n children: ['Error details'],\n },\n },\n {\n $$typeof: ELEMENT_TYPE,\n type: 'pre',\n props: {\n style: {\n margin: '0',\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n },\n children: [message],\n },\n },\n ],\n },\n },\n ],\n },\n key: null,\n } as JSXElement;\n}\n\nfunction resolveErrorBoundaryFallbackNode(\n fallback: unknown,\n error: unknown,\n reset: () => void\n): unknown {\n return typeof fallback === 'function'\n ? (fallback as (error: unknown, reset: () => void) => unknown)(error, reset)\n : fallback !== undefined\n ? fallback\n : createDefaultErrorBoundaryFallbackVNode(error);\n}\n\nfunction renderErrorBoundaryFallbackValue(\n fallback: unknown,\n error: unknown,\n reset: () => void,\n ctx: RenderContext\n): string {\n const nextValue = resolveErrorBoundaryFallbackNode(fallback, error, reset);\n\n return Array.isArray(nextValue)\n ? renderChildrenSync(normalizeRenderableChildren(nextValue), ctx)\n : renderChildSync(nextValue, ctx);\n}\n\nfunction renderErrorBoundaryFallbackValueToSink(\n fallback: unknown,\n error: unknown,\n reset: () => void,\n sink: { write(html: string): void },\n ctx: RenderContext\n): void {\n sink.write(renderErrorBoundaryFallbackValue(fallback, error, reset, ctx));\n}\n\nfunction getControlBoundaryState(\n node: VNode | JSXElement\n): ControlBoundaryState | null {\n const boundaryNode = node as DOMElement;\n\n return (\n boundaryNode._controlState ??\n (boundaryNode._forState as ControlBoundaryState | undefined) ??\n null\n );\n}\n\nfunction evaluateControlBoundaryChildren(\n node: VNode | JSXElement\n): unknown[] | undefined {\n if (node.type !== __CONTROL_BOUNDARY__) {\n return undefined;\n }\n\n const controlState = getControlBoundaryState(node);\n if (!controlState) {\n return [];\n }\n\n if (controlState.kind === 'for') {\n return evaluateForState(controlState);\n }\n if (controlState.kind === 'show') {\n return evaluateShowState(controlState);\n }\n return evaluateCaseState(controlState);\n}\n\nfunction renderChildrenSyncToSink(\n children: unknown[] | undefined,\n sink: { write(html: string): void },\n ctx: RenderContext\n): void {\n if (!children || !Array.isArray(children) || children.length === 0) return;\n if (children.length >= 32) {\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child === null || child === undefined || child === false) continue;\n if (typeof child === 'string') {\n sink.write(escapeText(child));\n continue;\n }\n if (typeof child === 'number') {\n sink.write(escapeText(String(child)));\n continue;\n }\n if (child && typeof child === 'object' && 'type' in child) {\n renderNodeSyncToSink(child as VNode, sink, ctx);\n }\n }\n return;\n }\n for (let i = 0; i < children.length; i++) {\n renderChildSyncToSink(children[i], sink, ctx);\n }\n}\n\nfunction sinkWrite2(\n sink: { write(html: string): void; write2?: (a: string, b: string) => void },\n a: string,\n b: string\n): void {\n if (typeof sink.write2 === 'function') {\n sink.write2(a, b);\n return;\n }\n sink.write(a);\n sink.write(b);\n}\n\nfunction sinkWrite3(\n sink: {\n write(html: string): void;\n write3?: (a: string, b: string, c: string) => void;\n },\n a: string,\n b: string,\n c: string\n): void {\n if (typeof sink.write3 === 'function') {\n sink.write3(a, b, c);\n return;\n }\n sink.write(a);\n sink.write(b);\n sink.write(c);\n}\n\n/**\n * Render a VNode synchronously. Throws if an async component is encountered.\n */\nfunction renderNodeSync(node: VNode | JSXElement, ctx: RenderContext): string {\n const { type, props } = node;\n\n /* istanbul ignore if - dev-only debug */\n if (__SSR_DEBUG) {\n try {\n logger.warn('[SSR] renderNodeSync type:', typeof type, type);\n } catch {\n // Ignore coercion errors for Symbols\n }\n }\n\n if (typeof type === 'function') {\n const result = executeComponentSync(type as Component, props, ctx);\n if (result instanceof Promise) {\n // Use centralized SSR error to maintain a single failure mode\n throwSSRDataMissing();\n }\n // executeComponentSync already normalizes primitives into VNode wrappers,\n // so result is always a VNode or JSXElement here. Safe to recurse directly.\n return renderNodeSync(result, ctx);\n }\n\n // Special-case fragments (symbols) - render children directly\n if (typeof type === 'symbol') {\n if (type === Fragment) {\n // Prefer explicit `children` array; fallback to `props.children` for\n // JSX runtimes that place children on props.\n const childrenArr = Array.isArray((node as VNode).children)\n ? (node as VNode).children\n : Array.isArray(props?.children)\n ? (props?.children as unknown[])\n : undefined;\n /* istanbul ignore if - dev-only debug */\n if (__SSR_DEBUG) {\n try {\n logger.warn('[SSR] fragment children length:', childrenArr?.length);\n } catch {\n // Ignore\n }\n }\n return renderChildrenSync(childrenArr, ctx);\n }\n if (type === __CONTROL_BOUNDARY__) {\n return renderChildrenSync(evaluateControlBoundaryChildren(node), ctx);\n }\n if (type === __ERROR_BOUNDARY__) {\n const boundaryState = getErrorBoundaryState(node);\n const fallback = props?.fallback;\n const reset = () => {\n const instance = (\n node as DOMElement & { __instance?: ComponentInstance }\n ).__instance;\n const state = instance?.errorBoundaryState;\n if (state) {\n state.error = null;\n state.notified = false;\n }\n };\n\n if (boundaryState?.error != null) {\n return renderErrorBoundaryFallbackValue(\n fallback,\n boundaryState.error,\n reset,\n ctx\n );\n }\n\n try {\n return renderChildrenSync(\n normalizeRenderableChildren(props?.children),\n ctx\n );\n } catch (error) {\n if (boundaryState) {\n boundaryState.error = error;\n boundaryState.notified = true;\n }\n logger.error('[Askr] ErrorBoundary caught render error:', error);\n return renderErrorBoundaryFallbackValue(fallback, error, reset, ctx);\n }\n }\n // Unknown symbol type - throw a helpful error instead of letting\n // a built-in TypeError bubble up when attempting to coerce to string.\n throw new Error(\n `renderNodeSync: unsupported VNode symbol type: ${String(type)}`\n );\n }\n\n const typeStr = type as string;\n if (VOID_ELEMENTS.has(typeStr)) {\n const attrs = renderAttrs(props);\n return `<${typeStr}${attrs} />`;\n }\n\n // Hot path: most nodes don't use dangerouslySetInnerHTML.\n // Avoid allocating the `{ attrs, dangerousHtml }` object unless the prop exists.\n const maybeDangerous = (\n props as unknown as { dangerouslySetInnerHTML?: unknown }\n )?.dangerouslySetInnerHTML;\n if (maybeDangerous !== undefined && maybeDangerous !== null) {\n const { attrs, dangerousHtml } = renderAttrs(props, {\n returnDangerousHtml: true,\n });\n if (dangerousHtml !== undefined) {\n return `<${typeStr}${attrs}>${dangerousHtml}</${typeStr}>`;\n }\n const childrenHtml = renderChildrenSync((node as VNode).children, ctx);\n return `<${typeStr}${attrs}>${childrenHtml}</${typeStr}>`;\n }\n\n const attrs = renderAttrs(props);\n const childrenHtml = renderChildrenSync((node as VNode).children, ctx);\n return `<${typeStr}${attrs}>${childrenHtml}</${typeStr}>`;\n}\n\nfunction renderNodeSyncToSink(\n node: VNode | JSXElement,\n sink: {\n write(html: string): void;\n write2?: (a: string, b: string) => void;\n write3?: (a: string, b: string, c: string) => void;\n },\n ctx: RenderContext\n): void {\n const { type, props } = node;\n\n if (typeof type === 'function') {\n const result = executeComponentSync(type as Component, props, ctx);\n // executeComponentSync guarantees synchronous result.\n renderNodeSyncToSink(inheritRenderableKey(node, result), sink, ctx);\n return;\n }\n\n // Fragment\n if (typeof type === 'symbol') {\n if (type === Fragment) {\n const childrenArr = Array.isArray((node as VNode).children)\n ? (node as VNode).children\n : Array.isArray(props?.children)\n ? (props?.children as unknown[])\n : undefined;\n renderChildrenSyncToSink(childrenArr, sink, ctx);\n return;\n }\n if (type === __CONTROL_BOUNDARY__) {\n renderChildrenSyncToSink(\n evaluateControlBoundaryChildren(node),\n sink,\n ctx\n );\n return;\n }\n if (type === __ERROR_BOUNDARY__) {\n const boundaryState = getErrorBoundaryState(node);\n const fallback = props?.fallback;\n const reset = () => {\n const instance = (\n node as DOMElement & { __instance?: ComponentInstance }\n ).__instance;\n const state = instance?.errorBoundaryState;\n if (state) {\n state.error = null;\n state.notified = false;\n }\n };\n\n if (boundaryState?.error != null) {\n renderErrorBoundaryFallbackValueToSink(\n fallback,\n boundaryState.error,\n reset,\n sink,\n ctx\n );\n return;\n }\n\n try {\n renderChildrenSyncToSink(\n normalizeRenderableChildren(props?.children),\n sink,\n ctx\n );\n } catch (error) {\n if (boundaryState) {\n boundaryState.error = error;\n boundaryState.notified = true;\n }\n logger.error('[Askr] ErrorBoundary caught render error:', error);\n renderErrorBoundaryFallbackValueToSink(\n fallback,\n error,\n reset,\n sink,\n ctx\n );\n }\n return;\n }\n throw new Error(\n `renderNodeSyncToSink: unsupported VNode symbol type: ${String(type)}`\n );\n }\n\n const typeStr = type as string;\n if (VOID_ELEMENTS.has(typeStr)) {\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write(' />');\n return;\n }\n\n const maybeDangerous = props\n ? (props as unknown as { dangerouslySetInnerHTML?: unknown })\n ?.dangerouslySetInnerHTML\n : undefined;\n\n if (maybeDangerous !== undefined && maybeDangerous !== null) {\n const dangerousHtml =\n typeof maybeDangerous === 'object' && '__html' in maybeDangerous\n ? String((maybeDangerous as { __html: unknown }).__html)\n : undefined;\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write('>');\n if (dangerousHtml !== undefined) {\n sink.write(dangerousHtml);\n } else {\n renderChildrenSyncToSink((node as VNode).children, sink, ctx);\n }\n sinkWrite3(sink, '</', typeStr, '>');\n return;\n }\n\n // Normalize children: prefer node.children, fallback to props.children (for JSXElement)\n let children = (node as VNode).children;\n if (children === undefined && props?.children !== undefined) {\n const propsChildren = props.children as unknown;\n if (Array.isArray(propsChildren)) {\n children = propsChildren;\n } else if (propsChildren !== null && propsChildren !== false) {\n children = [propsChildren];\n }\n }\n\n // Hot path: empty element (no children) - single write\n if (!children || (Array.isArray(children) && children.length === 0)) {\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write('>');\n sinkWrite3(sink, '</', typeStr, '>');\n return;\n }\n\n // Hot path: single text child - single write\n if (Array.isArray(children) && children.length === 1) {\n const only = children[0];\n if (typeof only === 'string') {\n const content = escapeText(only);\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write('>');\n sink.write(content);\n sinkWrite3(sink, '</', typeStr, '>');\n return;\n }\n if (typeof only === 'number') {\n const content = escapeText(String(only));\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write('>');\n sink.write(content);\n sinkWrite3(sink, '</', typeStr, '>');\n return;\n }\n }\n\n // General case: element with complex children\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write('>');\n renderChildrenSyncToSink(children, sink, ctx);\n sinkWrite3(sink, '</', typeStr, '>');\n}\n\n/**\n * Execute a component function (synchronously or async) and return VNode\n */\n/**\n * Execute a component synchronously inside a render-only context.\n * This must not create or reuse runtime ComponentInstance objects. We pass\n * the render context explicitly as `context.ssr` in the second argument so\n * components can opt-in to deterministic randomness/time via the provided RNG.\n */\nfunction executeComponentSync(\n component: Component,\n props: Record<string, unknown> | undefined,\n ctx: RenderContext\n): VNode | JSXElement {\n // Dev-only: enforce SSR purity with clear messages. We temporarily override\n // `Math.random` and `Date.now` while rendering to produce a targeted error\n // if components call them directly. We restore them immediately afterwards.\n // Re-entrant guard for dev-only SSR strict purity checks.\n // We avoid clobbering globals permanently by pushing the original functions\n // onto a stack and restoring them on exit. This is safer for nested or\n // stacked SSR render invocations.\n\n try {\n if (process.env.NODE_ENV !== 'production') {\n pushSSRStrictPurityGuard();\n }\n // Create a temporary, lightweight component instance so runtime APIs like\n // `state()` and `currentRoute()` can be called during SSR render. We avoid mounting\n // or side-effects by not attaching the instance to any DOM target.\n const prev = getCurrentComponentInstance();\n const temp = createComponentInstance(\n 'ssr-temp',\n component as ComponentFunction,\n (props || {}) as Props,\n null\n );\n temp.ssr = true;\n setCurrentComponentInstance(temp);\n try {\n // Context already set via withRenderContext at render entry point\n const result = component((props || {}) as Props, { ssr: ctx });\n if (result instanceof Promise) {\n // Use the centralized SSR error for async data/components during SSR\n throwSSRDataMissing();\n }\n if (\n typeof result === 'string' ||\n typeof result === 'number' ||\n typeof result === 'boolean' ||\n result === null ||\n result === undefined\n ) {\n // Return a Fragment with the text content, not a div wrapper\n const inner =\n result === null || result === undefined || result === false\n ? ''\n : String(result);\n return {\n $$typeof: ELEMENT_TYPE,\n type: Fragment,\n props: { children: inner ? [inner] : [] },\n } as unknown as VNode | JSXElement;\n }\n return result as VNode | JSXElement;\n } finally {\n // Restore the previous instance (if any)\n setCurrentComponentInstance(prev);\n }\n } finally {\n if (process.env.NODE_ENV !== 'production') popSSRStrictPurityGuard();\n }\n}\n\nfunction wrapWithDefaultPortal(out: unknown): VNode | JSXElement {\n const portalVNode = {\n $$typeof: ELEMENT_TYPE,\n type: DefaultPortal,\n props: {},\n key: '__default_portal',\n } as unknown;\n\n if (out == null) {\n return {\n $$typeof: ELEMENT_TYPE,\n type: Fragment,\n props: { children: [portalVNode] },\n } as unknown as VNode | JSXElement;\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: Fragment,\n props: { children: [out as unknown, portalVNode] },\n } as unknown as VNode | JSXElement;\n}\n\nfunction renderSyncComponentRoot(\n component: Component,\n props: Record<string, unknown> | undefined,\n ctx: RenderContext\n): VNode | JSXElement {\n const wrapped: Component = (\n p?: Record<string, unknown>,\n c?: { signal?: AbortSignal; ssr?: RenderContext }\n ) => wrapWithDefaultPortal(component(p ?? {}, c));\n\n return executeComponentSync(wrapped, props || {}, ctx);\n}\n\nfunction getRenderableChildren(\n node: VNode | JSXElement\n): unknown[] | undefined {\n if (Array.isArray((node as VNode).children)) {\n return (node as VNode).children;\n }\n if (Array.isArray(node.props?.children)) {\n return node.props.children as unknown[];\n }\n if (\n node.props?.children !== undefined &&\n node.props.children !== null &&\n node.props.children !== false\n ) {\n return [node.props.children];\n }\n return undefined;\n}\n\ntype VerifyState = {\n current: ChildNode | null;\n pendingText: string;\n};\n\nfunction flushPendingText(state: VerifyState): boolean {\n if (state.pendingText.length === 0) {\n return true;\n }\n if (!state.current || state.current.nodeType !== Node.TEXT_NODE) {\n return false;\n }\n if (state.current.textContent !== state.pendingText) {\n return false;\n }\n state.current = state.current.nextSibling;\n state.pendingText = '';\n return true;\n}\n\nfunction verifyRenderedAttrs(\n element: Element,\n props: Props | undefined\n): { matched: boolean; dangerousHtml?: string } {\n const matchedAttrs = new Set<string>();\n let dangerousHtml: string | undefined;\n\n if (!props || typeof props !== 'object') {\n return {\n matched: element.attributes.length === 0,\n dangerousHtml,\n };\n }\n\n const propsObj = props as Record<string, unknown>;\n for (const key in propsObj) {\n const value = propsObj[key];\n\n if (\n key === 'children' ||\n key === 'key' ||\n key === 'ref' ||\n key === 'dangerouslySetInnerHTML'\n ) {\n if (\n key === 'dangerouslySetInnerHTML' &&\n value &&\n typeof value === 'object' &&\n '__html' in value\n ) {\n dangerousHtml = String((value as { __html: unknown }).__html);\n }\n continue;\n }\n\n if (isSSRAttrEventHandler(key) || key.charCodeAt(0) === 95) {\n continue;\n }\n\n const attrName = key === 'class' || key === 'className' ? 'class' : key;\n\n if (attrName === 'style') {\n const css = typeof value === 'string' ? value : styleObjToCss(value);\n if (!css) continue;\n if (element.getAttribute('style') !== css) {\n return { matched: false };\n }\n matchedAttrs.add('style');\n continue;\n }\n\n if (value === true) {\n if (!element.hasAttribute(attrName)) {\n return { matched: false };\n }\n matchedAttrs.add(attrName);\n continue;\n }\n\n if (value === false || value === null || value === undefined) {\n continue;\n }\n\n const stringValue = String(value);\n if (element.getAttribute(attrName) !== stringValue) {\n return { matched: false };\n }\n matchedAttrs.add(attrName);\n }\n\n if (element.attributes.length !== matchedAttrs.size) {\n return { matched: false };\n }\n\n return { matched: true, dangerousHtml };\n}\n\nfunction verifyExpectedNode(\n node: unknown,\n state: VerifyState,\n ctx: RenderContext\n): boolean {\n if (node === null || node === undefined || node === false) {\n return true;\n }\n\n if (typeof node === 'string' || typeof node === 'number') {\n state.pendingText += String(node);\n return true;\n }\n\n if (!node || typeof node !== 'object' || !('type' in node)) {\n return true;\n }\n\n const vnode = node as VNode | JSXElement;\n const { type, props } = vnode;\n\n if (typeof type === 'function') {\n return verifyExpectedNode(\n inheritRenderableKey(\n vnode,\n executeComponentSync(type as Component, props, ctx)\n ),\n state,\n ctx\n );\n }\n\n if (typeof type === 'symbol') {\n if (type === __CONTROL_BOUNDARY__) {\n const children = evaluateControlBoundaryChildren(vnode);\n if (!children || children.length === 0) {\n return true;\n }\n for (let index = 0; index < children.length; index += 1) {\n if (!verifyExpectedNode(children[index], state, ctx)) {\n return false;\n }\n }\n return true;\n }\n if (type === __ERROR_BOUNDARY__) {\n const boundaryState = getErrorBoundaryState(vnode);\n const fallback = props?.fallback;\n const reset = () => {\n const instance = (\n vnode as DOMElement & { __instance?: ComponentInstance }\n ).__instance;\n const stateRef = instance?.errorBoundaryState;\n if (stateRef) {\n stateRef.error = null;\n stateRef.notified = false;\n }\n };\n\n const snapshot: VerifyState = {\n current: state.current,\n pendingText: state.pendingText,\n };\n\n if (boundaryState?.error != null) {\n const fallbackNode = resolveErrorBoundaryFallbackNode(\n fallback,\n boundaryState.error,\n reset\n );\n return verifyRenderableNode(fallbackNode, state, ctx);\n }\n\n try {\n if (\n verifyExpectedChildren(\n normalizeRenderableChildren(props?.children),\n state,\n ctx\n )\n ) {\n return true;\n }\n } catch (error) {\n if (boundaryState) {\n boundaryState.error = error;\n boundaryState.notified = true;\n }\n }\n\n state.current = snapshot.current;\n state.pendingText = snapshot.pendingText;\n\n const fallbackNode = resolveErrorBoundaryFallbackNode(\n fallback,\n boundaryState?.error ?? new Error('ErrorBoundary render failed'),\n reset\n );\n return verifyRenderableNode(fallbackNode, state, ctx);\n }\n if (type !== Fragment) {\n throw new Error(\n `verifyHydrationSyncForUrl: unsupported VNode symbol type: ${String(type)}`\n );\n }\n const children = getRenderableChildren(vnode);\n if (!children || children.length === 0) {\n return true;\n }\n for (let index = 0; index < children.length; index += 1) {\n if (!verifyExpectedNode(children[index], state, ctx)) {\n return false;\n }\n }\n return true;\n }\n\n if (!flushPendingText(state)) {\n return false;\n }\n\n if (!state.current || state.current.nodeType !== Node.ELEMENT_NODE) {\n return false;\n }\n\n const actualElement = state.current as Element;\n if (actualElement.tagName.toLowerCase() !== String(type).toLowerCase()) {\n return false;\n }\n\n const attrMatch = verifyRenderedAttrs(actualElement, props);\n if (!attrMatch.matched) {\n return false;\n }\n\n if (VOID_ELEMENTS.has(String(type))) {\n if (actualElement.firstChild !== null) {\n return false;\n }\n state.current = actualElement.nextSibling;\n return true;\n }\n\n if (attrMatch.dangerousHtml !== undefined) {\n if (actualElement.innerHTML !== attrMatch.dangerousHtml) {\n return false;\n }\n state.current = actualElement.nextSibling;\n return true;\n }\n\n const childState: VerifyState = {\n current: actualElement.firstChild,\n pendingText: '',\n };\n const children = getRenderableChildren(vnode);\n if (children && children.length > 0) {\n for (let index = 0; index < children.length; index += 1) {\n if (!verifyExpectedNode(children[index], childState, ctx)) {\n return false;\n }\n }\n }\n\n if (!flushPendingText(childState) || childState.current !== null) {\n return false;\n }\n\n state.current = actualElement.nextSibling;\n return true;\n}\n\nfunction verifyHydrationRoot(\n root: Element,\n node: VNode | JSXElement,\n ctx: RenderContext\n): boolean {\n const state: VerifyState = {\n current: root.firstChild,\n pendingText: '',\n };\n if (!verifyExpectedNode(node, state, ctx)) {\n return false;\n }\n return flushPendingText(state) && state.current === null;\n}\n\nfunction verifyExpectedChildren(\n children: unknown[] | undefined,\n state: VerifyState,\n ctx: RenderContext\n): boolean {\n if (!children || children.length === 0) {\n return true;\n }\n\n for (let index = 0; index < children.length; index += 1) {\n if (!verifyExpectedNode(children[index], state, ctx)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction verifyRenderableNode(\n value: unknown,\n state: VerifyState,\n ctx: RenderContext\n): boolean {\n return Array.isArray(value)\n ? verifyExpectedChildren(normalizeRenderableChildren(value), state, ctx)\n : verifyExpectedNode(value, state, ctx);\n}\n\n/**\n * Single synchronous SSR entrypoint: render a component to an HTML string.\n * This is strictly synchronous and deterministic. Optionally provide a seed\n * for deterministic randomness via `options.seed`.\n */\nexport function renderToStringSync(\n component: (\n props?: Record<string, unknown>\n ) => VNode | JSXElement | string | number | boolean | null | undefined,\n props?: Record<string, unknown>,\n options?: { seed?: number; data?: SSRData }\n): string {\n const seed = options?.seed ?? 12345;\n const ctx = createRenderContext(seed, { data: options?.data });\n\n return withRenderContext(ctx, () => {\n // Set render data on context (startRenderPhase now reads from context)\n startRenderPhase(options?.data ?? null);\n try {\n const node = renderSyncComponentRoot(\n component as unknown as Component,\n props || {},\n ctx\n );\n if (!node) {\n throw new Error('renderToStringSync: wrapped component returned empty');\n }\n const sink = new StringSink();\n renderNodeSyncToSink(node, sink, ctx);\n sink.end();\n return sink.toString();\n } finally {\n stopRenderPhase();\n }\n });\n}\n\nexport function renderResolvedToStringSync(opts: {\n url: string;\n routes: Array<{ path: string; handler: RouteHandler; namespace?: string }>;\n handler: RouteHandler;\n params?: Record<string, string>;\n options?: { seed?: number; data?: SSRData };\n}): string {\n const { url, routes, handler, params, options } = opts;\n const seed = options?.seed ?? 12345;\n const ctx = createRenderContext(seed, {\n url,\n data: options?.data,\n params,\n routes,\n });\n\n return withRenderContext(ctx, () => {\n startRenderPhase(options?.data ?? null);\n try {\n const node = renderSyncComponentRoot(\n handler as unknown as Component,\n params || {},\n ctx\n );\n const sink = new StringSink();\n renderNodeSyncToSink(node, sink, ctx);\n sink.end();\n return sink.toString();\n } finally {\n stopRenderPhase();\n }\n });\n}\n\nexport async function resolveRequest(opts: {\n url: string;\n manifest?: RouteManifest;\n routes?: Array<{ path: string; handler: RouteHandler; namespace?: string }>;\n auth?: RouteAuthOptions;\n signal?: AbortSignal;\n}): Promise<RouteRequestResult> {\n const { url, manifest, routes, auth, signal } = opts;\n\n if (manifest) {\n return await RouteModule.resolveRouteRequest(url, {\n manifest,\n mode: 'ssr',\n auth,\n signal,\n });\n }\n\n if (!routes) {\n throw new Error('resolveRequest requires a route manifest or route table.');\n }\n\n const requestUrl = new URL(url, 'http://localhost');\n const resolved = RouteModule.resolveRouteFromRoutes(\n requestUrl.pathname,\n routes\n );\n\n if (!resolved) {\n return null;\n }\n\n return {\n kind: 'render',\n handler: resolved.handler,\n params: resolved.params,\n };\n}\n\n// Synchronous server render for strict checks. Routes are resolved against the\n// provided route table and kept in the per-render SSR context.\nexport function renderToStringSyncForUrl(opts: {\n url: string;\n routes: Array<{ path: string; handler: RouteHandler; namespace?: string }>;\n options?: { seed?: number; data?: SSRData };\n}): string {\n const { url, routes, options } = opts;\n const routeTable = routes.map((route) => ({ ...route }));\n const requestUrl = new URL(url, 'http://localhost');\n const resolved = RouteModule.resolveRouteFromRoutes(\n requestUrl.pathname,\n routeTable\n );\n if (!resolved)\n throw new Error(`renderToStringSyncForUrl: no route found for url: ${url}`);\n\n return renderResolvedToStringSync({\n url,\n routes: routeTable,\n handler: resolved.handler,\n params: resolved.params,\n options,\n });\n}\n\nexport function verifyHydrationSyncForUrl(opts: {\n root: Element;\n url: string;\n routes: Array<{ path: string; handler: RouteHandler; namespace?: string }>;\n options?: { seed?: number; data?: SSRData };\n}): boolean {\n const { root, url, routes, options } = opts;\n const routeTable = routes.map((route) => ({ ...route }));\n const requestUrl = new URL(url, 'http://localhost');\n const resolved = RouteModule.resolveRouteFromRoutes(\n requestUrl.pathname,\n routeTable\n );\n if (!resolved) {\n throw new Error(\n `verifyHydrationSyncForUrl: no route found for url: ${url}`\n );\n }\n\n const seed = options?.seed ?? 12345;\n const ctx = createRenderContext(seed, {\n url,\n data: options?.data,\n params: resolved.params,\n routes: routeTable,\n });\n\n return withRenderContext(ctx, () => {\n startRenderPhase(options?.data ?? null);\n try {\n const node = renderSyncComponentRoot(\n resolved.handler as unknown as Component,\n resolved.params || {},\n ctx\n );\n return verifyHydrationRoot(root, node, ctx);\n } finally {\n stopRenderPhase();\n }\n });\n}\n\n// --- Streaming sink-based renderer (v2) --------------------------------------------------\nimport { StringSink, StreamSink } from './sink';\nimport { renderNodeToSink } from './stream-render';\nimport {\n startRenderPhase,\n stopRenderPhase,\n collectResources,\n resolvePlan,\n resolveResources,\n type ResourcePlan,\n} from './render-keys';\n\nexport type SSRRoute = {\n path: string;\n handler: RouteHandler;\n namespace?: string;\n};\n\nexport function renderToString(\n component: (\n props?: Record<string, unknown>\n ) => VNode | JSXElement | string | number | null\n): string;\nexport function renderToString(opts: {\n url: string;\n routes: SSRRoute[];\n seed?: number;\n data?: SSRData;\n}): string;\nexport function renderToString(arg: unknown): string {\n // Convenience: if a component function is passed, delegate to sync render\n if (typeof arg === 'function') {\n return renderToStringSync(\n arg as (\n props?: Record<string, unknown>\n ) => VNode | JSXElement | string | number | null\n );\n }\n const opts = arg as {\n url: string;\n routes: SSRRoute[];\n seed?: number;\n data?: SSRData;\n };\n const sink = new StringSink();\n renderToSinkInternal({ ...opts, sink });\n sink.end();\n return sink.toString();\n}\n\nexport function renderToStream(opts: {\n url: string;\n routes: SSRRoute[];\n seed?: number;\n data?: SSRData;\n onChunk(html: string): void;\n onComplete(): void;\n}): void {\n const sink = new StreamSink(opts.onChunk, opts.onComplete);\n renderToSinkInternal({ ...opts, sink });\n sink.end();\n}\n\nfunction renderToSinkInternal(opts: {\n url: string;\n routes: SSRRoute[];\n seed?: number;\n data?: SSRData;\n sink: { write(html: string): void; end(): void };\n}) {\n const { url, routes, seed = 12345, data, sink } = opts;\n\n const routeTable = routes.map((route) => ({ ...route }));\n const requestUrl = new URL(url, 'http://localhost');\n const resolved = RouteModule.resolveRouteFromRoutes(\n requestUrl.pathname,\n routeTable\n );\n if (!resolved) throw new Error(`SSR: no route found for url: ${url}`);\n\n const ctx = createRenderContext(seed, {\n url,\n data,\n params: resolved.params,\n routes: routeTable,\n });\n\n withRenderContext(ctx, () => {\n // Start render-phase keying so resource() can lookup resolved `data` by key\n startRenderPhase(data || null);\n try {\n const node = executeComponentSync(\n resolved.handler as unknown as Component,\n resolved.params,\n ctx\n );\n renderNodeToSink(node, sink, ctx);\n } finally {\n stopRenderPhase();\n }\n });\n}\n\nexport { collectResources, resolvePlan, resolveResources, ResourcePlan };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsDA,MAAM,cAEH,QAAQ,IAAI,mBAAmB,OAAO,QAAQ,IAAI,mBAAmB;AAExE,SAAS,sBAAsB,KAAsB;CACnD,OACE,IAAI,UAAU,KACd,IAAI,WAAW,EAAE,KAAK,OACtB,IAAI,WAAW,EAAE,KAAK,OACtB,IAAI,WAAW,EAAE,IAAI,MACrB,IAAI,WAAW,EAAE,IAAI;;AAIzB,SAAS,qBACP,QACA,QACoB;CACpB,MAAM,eAAgB,OAAsB;CAC5C,IAAI,iBAAiB,UAAa,iBAAiB,MACjD,OAAO;CAGT,IAAI,CAAC,UAAU,OAAO,WAAW,YAAY,EAAE,UAAU,SACvD,OAAO;CAGT,MAAM,cAAc;CACpB,IAAI,YAAY,QAAQ,UAAa,YAAY,QAAQ,MACvD,YAAY,MAAM;CAGpB,IAAI,OAAO,YAAY,SAAS,UAAU;EACxC,IAAI,CAAC,YAAY,OACf,YAAY,QAAQ,EAAE;EAGxB,IAAI,YAAY,MAAM,gBAAgB,QACpC,YAAY,MAAM,cAAc,OAAO,aAAa;;CAIxD,OAAO;;AAMT,iBAAiB;CACf,sBAAsB;CACtB;CACA;CACA;CACD,CAAC;AAYF,MAAM,kBAAsE,EAAE;AAE9E,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AkB,WAAW;EAClC,iBAAiB,SAAS,QAAQ,KAAK;EACvC,IAAI;GAMF,OAAO,oBAAoB,MALd,wBACX,SAAS,SACT,SAAS,UAAU,EAAE,EACrB,IAE+B,EAAM,IAAI;YACnC;GACR,iBAAiB;;GAEnB;;AAgCJ,SAAgB,eAAe,KAAsB;CAEnD,IAAI,OAAO,QAAQ,YACjB,OAAO,mBACL,IAGD;CAEH,MAAM,OAAO;CAMb,MAAM,OAAO,IAAI,YAAY;CAC7B,qBAAqB;EAAE,GAAG;EAAM;EAAM,CAAC;CACvC,KAAK,KAAK;CACV,OAAO,KAAK,UAAU;;AAGxB,SAAgB,eAAe,MAOtB;CACP,MAAM,OAAO,IAAI,WAAW,KAAK,SAAS,KAAK,WAAW;CAC1D,qBAAqB;EAAE,GAAG;EAAM;EAAM,CAAC;CACvC,KAAK,KAAK;;AAGZ,SAAS,qBAAqB,MAM3B;CACD,MAAM,EAAE,KAAK,QAAQ,OAAO,OAAO,MAAM,SAAS;CAElD,MAAM,aAAa,OAAO,KAAK,WAAW,EAAE,GAAG,OAAO,EAAE;CAExD,MAAM,WAAWA,uBACf,IAFqB,IAAI,KAAK,mBAE9B,CAAW,UACX,WACD;CACD,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,gCAAgC,MAAM;CAErE,MAAM,MAAM,oBAAoB,MAAM;EACpC;EACA;EACA,QAAQ,SAAS;EACjB,QAAQ;EACT,CAAC;CAEF,kBAAkB,WAAW;EAE3B,iBAAiB,QAAQ,KAAK;EAC9B,IAAI;GAMF,iBALa,qBACX,SAAS,SACT,SAAS,QACT,IAEe,EAAM,MAAM,IAAI;YACzB;GACR,iBAAiB;;GAEnB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["RouteModule.resolveRouteRequest","RouteModule.resolveRouteFromRoutes"],"sources":["../../src/ssr/index.ts"],"sourcesContent":["/**\n * SSR - Server-Side Rendering\n *\n * Renders Askr components to static HTML strings for server-side rendering.\n * SSR is synchronous: async components are not supported; async work should use\n * `resource()` which is rejected during synchronous SSR. This module throws\n * when an async component or async resource is encountered during sync SSR.\n *\n * Concurrency: Each render call uses AsyncLocalStorage (Node.js) to isolate\n * render state, making concurrent SSR requests safe.\n */\n\nimport type { JSXElement } from '../common/jsx';\nimport { __CONTROL_BOUNDARY__ } from '../common/control';\nimport type {\n RouteAuthOptions,\n RouteHandler,\n RouteManifest,\n RouteRequestResult,\n} from '../common/router';\nimport * as RouteModule from '../router/route';\nimport type { Props } from '../common/props';\nimport { Fragment, ELEMENT_TYPE } from '../jsx';\nimport { DefaultPortal } from '../foundations/structures/portal';\nimport {\n createRenderContext,\n getRenderContext,\n withRenderContext,\n throwSSRDataMissing,\n type RenderContext,\n type SSRData,\n} from './context';\nimport { installSSRBridge } from '../runtime/ssr-bridge';\nimport { getCurrentRenderData, getNextKey } from './render-keys';\nimport {\n createComponentInstance,\n setCurrentComponentInstance,\n getCurrentComponentInstance,\n} from '../runtime/component';\nimport type { ComponentFunction } from '../common/component';\nimport type { DOMElement } from '../common/vnode';\nimport { __ERROR_BOUNDARY__ } from '../common/vnode';\nimport { VOID_ELEMENTS, escapeText, styleObjToCss } from './escape';\nimport { renderAttrs, renderAttrsDirect } from './attrs';\nimport type { VNode } from './types';\n\nimport { logger } from '../dev/logger';\nimport {\n type ControlBoundaryState,\n evaluateCaseState,\n evaluateShowState,\n} from '../runtime/control';\nimport { evaluateForState } from '../runtime/for';\n\nconst __SSR_DEBUG =\n process.env.NODE_ENV !== 'production' &&\n (process.env.ASKR_SSR_DEBUG === '1' || process.env.ASKR_SSR_DEBUG === 'true');\n\nfunction isSSRAttrEventHandler(key: string): boolean {\n return (\n key.length >= 3 &&\n key.charCodeAt(0) === 111 &&\n key.charCodeAt(1) === 110 &&\n key.charCodeAt(2) >= 65 &&\n key.charCodeAt(2) <= 90\n );\n}\n\nfunction inheritRenderableKey(\n source: VNode | JSXElement,\n result: VNode | JSXElement\n): VNode | JSXElement {\n const inheritedKey = (source as DOMElement).key;\n if (inheritedKey === undefined || inheritedKey === null) {\n return result;\n }\n\n if (!result || typeof result !== 'object' || !('type' in result)) {\n return result;\n }\n\n const resultVNode = result as DOMElement;\n if (resultVNode.key === undefined || resultVNode.key === null) {\n resultVNode.key = inheritedKey;\n }\n\n if (typeof resultVNode.type === 'string') {\n if (!resultVNode.props) {\n resultVNode.props = {};\n }\n\n if (resultVNode.props['data-key'] === undefined) {\n resultVNode.props['data-key'] = String(inheritedKey);\n }\n }\n\n return result;\n}\n\n// Install SSR bridge once so runtime primitives (resource/derive/etc) can\n// detect SSR mode and access deterministic render-phase data without a\n// runtime->ssr import.\ninstallSSRBridge({\n getCurrentSSRContext: getRenderContext,\n throwSSRDataMissing,\n getCurrentRenderData,\n getNextKey,\n});\n\nexport { SSRDataMissingError } from './context';\nexport type { VNode, SSRComponent } from './types';\n\n// Dev-only SSR strictness guard helpers. We mutate globals in dev to make\n// accidental usage of Math.random/Date.now during sync SSR fail fast.\n// We implement a re-entrant stack so nested or concurrent calls don't clobber\n// global values unexpectedly.\nconst __ssrGuardStack: Array<{ random: () => number; now: () => number }> = [];\n\nfunction pushSSRStrictPurityGuard() {\n /* istanbul ignore if - dev-only guard */\n if (process.env.NODE_ENV === 'production') return;\n __ssrGuardStack.push({\n random: Reflect.get(Math, 'random') as () => number,\n now: Reflect.get(Date, 'now') as () => number,\n });\n Reflect.set(Math, 'random', () => {\n throw new Error(\n 'SSR Strict Purity: Math.random is not allowed during synchronous SSR. Use the provided `ssr` context RNG instead.'\n );\n });\n Reflect.set(Date, 'now', () => {\n throw new Error(\n 'SSR Strict Purity: Date.now is not allowed during synchronous SSR. Pass timestamps explicitly or use deterministic helpers.'\n );\n });\n}\n\nfunction popSSRStrictPurityGuard() {\n /* istanbul ignore if - dev-only guard */\n if (process.env.NODE_ENV === 'production') return;\n const prev = __ssrGuardStack.pop();\n if (prev) {\n Reflect.set(Math, 'random', prev.random);\n Reflect.set(Date, 'now', prev.now);\n }\n}\n\n/**\n * Synchronous rendering helpers (used for strictly synchronous SSR)\n */\nfunction renderChildSync(child: unknown, ctx: RenderContext): string {\n if (typeof child === 'string') return escapeText(child);\n if (typeof child === 'number') return escapeText(String(child));\n if (child === null || child === undefined || child === false) return '';\n if (child && typeof child === 'object' && 'type' in child) {\n // We already verified the shape above; assert as VNode for the sync renderer\n return renderNodeSync(child as VNode, ctx);\n }\n return '';\n}\n\nfunction renderChildSyncToSink(\n child: unknown,\n sink: { write(html: string): void },\n ctx: RenderContext\n): void {\n if (child === null || child === undefined || child === false) return;\n if (typeof child === 'string') {\n sink.write(escapeText(child));\n return;\n }\n if (typeof child === 'number') {\n sink.write(escapeText(String(child)));\n return;\n }\n if (child && typeof child === 'object' && 'type' in child) {\n renderNodeSyncToSink(child as VNode, sink, ctx);\n }\n}\n\nfunction renderChildrenSync(\n children: unknown[] | undefined,\n ctx: RenderContext\n): string {\n if (!children || !Array.isArray(children) || children.length === 0) return '';\n if (children.length === 1) return renderChildSync(children[0], ctx);\n\n // Small child arrays are common; concatenation is usually faster than\n // allocating + joining. Large sibling lists (10k+) need join to avoid O(n^2)\n // concatenation costs.\n if (children.length <= 8) {\n let result = '';\n for (const child of children) result += renderChildSync(child, ctx);\n return result;\n }\n\n const parts = Array.from({ length: children.length }, (_, index) =>\n renderChildSync(children[index], ctx)\n );\n return parts.join('');\n}\n\nfunction normalizeRenderableChildren(value: unknown): unknown[] {\n if (value === null || value === undefined || value === false) {\n return [];\n }\n\n return Array.isArray(value) ? value : [value];\n}\n\nfunction getErrorBoundaryState(\n node: VNode | JSXElement\n): NonNullable<ComponentInstance['errorBoundaryState']> | null {\n return (\n (node as DOMElement & { __instance?: ComponentInstance }).__instance\n ?.errorBoundaryState ?? null\n );\n}\n\nfunction createDefaultErrorBoundaryFallbackVNode(error: unknown): JSXElement {\n const message =\n error instanceof Error\n ? error.stack || error.message || error.name\n : typeof error === 'string'\n ? error\n : (() => {\n try {\n return JSON.stringify(error);\n } catch {\n return String(error);\n }\n })();\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: 'div',\n props: {\n role: 'alert',\n 'data-askr-error-boundary': 'true',\n style: {\n boxSizing: 'border-box',\n padding: '1rem',\n border: '1px solid currentColor',\n borderRadius: '0.75rem',\n display: 'grid',\n gap: '0.75rem',\n maxWidth: '100%',\n },\n children: [\n {\n $$typeof: ELEMENT_TYPE,\n type: 'strong',\n props: {\n children: ['Something went wrong while rendering this view.'],\n },\n },\n {\n $$typeof: ELEMENT_TYPE,\n type: 'p',\n props: {\n style: { margin: '0' },\n children: [\n 'The app recovered into a visible fallback so the error is not hidden in the console.',\n ],\n },\n },\n {\n $$typeof: ELEMENT_TYPE,\n type: 'details',\n props: {\n open: process.env.NODE_ENV !== 'production',\n children: [\n {\n $$typeof: ELEMENT_TYPE,\n type: 'summary',\n props: {\n children: ['Error details'],\n },\n },\n {\n $$typeof: ELEMENT_TYPE,\n type: 'pre',\n props: {\n style: {\n margin: '0',\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n },\n children: [message],\n },\n },\n ],\n },\n },\n ],\n },\n key: null,\n } as JSXElement;\n}\n\nfunction resolveErrorBoundaryFallbackNode(\n fallback: unknown,\n error: unknown,\n reset: () => void\n): unknown {\n return typeof fallback === 'function'\n ? (fallback as (error: unknown, reset: () => void) => unknown)(error, reset)\n : fallback !== undefined\n ? fallback\n : createDefaultErrorBoundaryFallbackVNode(error);\n}\n\nfunction renderErrorBoundaryFallbackValue(\n fallback: unknown,\n error: unknown,\n reset: () => void,\n ctx: RenderContext\n): string {\n const nextValue = resolveErrorBoundaryFallbackNode(fallback, error, reset);\n\n return Array.isArray(nextValue)\n ? renderChildrenSync(normalizeRenderableChildren(nextValue), ctx)\n : renderChildSync(nextValue, ctx);\n}\n\nfunction renderErrorBoundaryFallbackValueToSink(\n fallback: unknown,\n error: unknown,\n reset: () => void,\n sink: { write(html: string): void },\n ctx: RenderContext\n): void {\n sink.write(renderErrorBoundaryFallbackValue(fallback, error, reset, ctx));\n}\n\nfunction getControlBoundaryState(\n node: VNode | JSXElement\n): ControlBoundaryState | null {\n const boundaryNode = node as DOMElement;\n\n return (\n boundaryNode._controlState ??\n (boundaryNode._forState as ControlBoundaryState | undefined) ??\n null\n );\n}\n\nfunction evaluateControlBoundaryChildren(\n node: VNode | JSXElement\n): unknown[] | undefined {\n if (node.type !== __CONTROL_BOUNDARY__) {\n return undefined;\n }\n\n const controlState = getControlBoundaryState(node);\n if (!controlState) {\n return [];\n }\n\n if (controlState.kind === 'for') {\n return evaluateForState(controlState);\n }\n if (controlState.kind === 'show') {\n return evaluateShowState(controlState);\n }\n return evaluateCaseState(controlState);\n}\n\nfunction renderChildrenSyncToSink(\n children: unknown[] | undefined,\n sink: { write(html: string): void },\n ctx: RenderContext\n): void {\n if (!children || !Array.isArray(children) || children.length === 0) return;\n if (children.length >= 32) {\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child === null || child === undefined || child === false) continue;\n if (typeof child === 'string') {\n sink.write(escapeText(child));\n continue;\n }\n if (typeof child === 'number') {\n sink.write(escapeText(String(child)));\n continue;\n }\n if (child && typeof child === 'object' && 'type' in child) {\n renderNodeSyncToSink(child as VNode, sink, ctx);\n }\n }\n return;\n }\n for (let i = 0; i < children.length; i++) {\n renderChildSyncToSink(children[i], sink, ctx);\n }\n}\n\nfunction sinkWrite2(\n sink: { write(html: string): void; write2?: (a: string, b: string) => void },\n a: string,\n b: string\n): void {\n if (typeof sink.write2 === 'function') {\n sink.write2(a, b);\n return;\n }\n sink.write(a);\n sink.write(b);\n}\n\nfunction sinkWrite3(\n sink: {\n write(html: string): void;\n write3?: (a: string, b: string, c: string) => void;\n },\n a: string,\n b: string,\n c: string\n): void {\n if (typeof sink.write3 === 'function') {\n sink.write3(a, b, c);\n return;\n }\n sink.write(a);\n sink.write(b);\n sink.write(c);\n}\n\n/**\n * Render a VNode synchronously. Throws if an async component is encountered.\n */\nfunction renderNodeSync(node: VNode | JSXElement, ctx: RenderContext): string {\n const { type, props } = node;\n\n /* istanbul ignore if - dev-only debug */\n if (__SSR_DEBUG) {\n try {\n logger.warn('[SSR] renderNodeSync type:', typeof type, type);\n } catch {\n // Ignore coercion errors for Symbols\n }\n }\n\n if (typeof type === 'function') {\n const result = executeComponentSync(type as Component, props, ctx);\n if (result instanceof Promise) {\n // Use centralized SSR error to maintain a single failure mode\n throwSSRDataMissing();\n }\n // executeComponentSync already normalizes primitives into VNode wrappers,\n // so result is always a VNode or JSXElement here. Safe to recurse directly.\n return renderNodeSync(result, ctx);\n }\n\n // Special-case fragments (symbols) - render children directly\n if (typeof type === 'symbol') {\n if (type === Fragment) {\n // Prefer explicit `children` array; fallback to `props.children` for\n // JSX runtimes that place children on props.\n const childrenArr = Array.isArray((node as VNode).children)\n ? (node as VNode).children\n : Array.isArray(props?.children)\n ? (props?.children as unknown[])\n : undefined;\n /* istanbul ignore if - dev-only debug */\n if (__SSR_DEBUG) {\n try {\n logger.warn('[SSR] fragment children length:', childrenArr?.length);\n } catch {\n // Ignore\n }\n }\n return renderChildrenSync(childrenArr, ctx);\n }\n if (type === __CONTROL_BOUNDARY__) {\n return renderChildrenSync(evaluateControlBoundaryChildren(node), ctx);\n }\n if (type === __ERROR_BOUNDARY__) {\n const boundaryState = getErrorBoundaryState(node);\n const fallback = props?.fallback;\n const reset = () => {\n const instance = (\n node as DOMElement & { __instance?: ComponentInstance }\n ).__instance;\n const state = instance?.errorBoundaryState;\n if (state) {\n state.error = null;\n state.notified = false;\n }\n };\n\n if (boundaryState?.error != null) {\n return renderErrorBoundaryFallbackValue(\n fallback,\n boundaryState.error,\n reset,\n ctx\n );\n }\n\n try {\n return renderChildrenSync(\n normalizeRenderableChildren(props?.children),\n ctx\n );\n } catch (error) {\n if (boundaryState) {\n boundaryState.error = error;\n boundaryState.notified = true;\n }\n logger.error('[Askr] ErrorBoundary caught render error:', error);\n return renderErrorBoundaryFallbackValue(fallback, error, reset, ctx);\n }\n }\n // Unknown symbol type - throw a helpful error instead of letting\n // a built-in TypeError bubble up when attempting to coerce to string.\n throw new Error(\n `renderNodeSync: unsupported VNode symbol type: ${String(type)}`\n );\n }\n\n const typeStr = type as string;\n if (VOID_ELEMENTS.has(typeStr)) {\n const attrs = renderAttrs(props);\n return `<${typeStr}${attrs} />`;\n }\n\n // Hot path: most nodes don't use dangerouslySetInnerHTML.\n // Avoid allocating the `{ attrs, dangerousHtml }` object unless the prop exists.\n const maybeDangerous = (\n props as unknown as { dangerouslySetInnerHTML?: unknown }\n )?.dangerouslySetInnerHTML;\n if (maybeDangerous !== undefined && maybeDangerous !== null) {\n const { attrs, dangerousHtml } = renderAttrs(props, {\n returnDangerousHtml: true,\n });\n if (dangerousHtml !== undefined) {\n return `<${typeStr}${attrs}>${dangerousHtml}</${typeStr}>`;\n }\n const childrenHtml = renderChildrenSync((node as VNode).children, ctx);\n return `<${typeStr}${attrs}>${childrenHtml}</${typeStr}>`;\n }\n\n const attrs = renderAttrs(props);\n const childrenHtml = renderChildrenSync((node as VNode).children, ctx);\n return `<${typeStr}${attrs}>${childrenHtml}</${typeStr}>`;\n}\n\nfunction renderNodeSyncToSink(\n node: VNode | JSXElement,\n sink: {\n write(html: string): void;\n write2?: (a: string, b: string) => void;\n write3?: (a: string, b: string, c: string) => void;\n },\n ctx: RenderContext\n): void {\n const { type, props } = node;\n\n if (typeof type === 'function') {\n const result = executeComponentSync(type as Component, props, ctx);\n // executeComponentSync guarantees synchronous result.\n renderNodeSyncToSink(inheritRenderableKey(node, result), sink, ctx);\n return;\n }\n\n // Fragment\n if (typeof type === 'symbol') {\n if (type === Fragment) {\n const childrenArr = Array.isArray((node as VNode).children)\n ? (node as VNode).children\n : Array.isArray(props?.children)\n ? (props?.children as unknown[])\n : undefined;\n renderChildrenSyncToSink(childrenArr, sink, ctx);\n return;\n }\n if (type === __CONTROL_BOUNDARY__) {\n renderChildrenSyncToSink(\n evaluateControlBoundaryChildren(node),\n sink,\n ctx\n );\n return;\n }\n if (type === __ERROR_BOUNDARY__) {\n const boundaryState = getErrorBoundaryState(node);\n const fallback = props?.fallback;\n const reset = () => {\n const instance = (\n node as DOMElement & { __instance?: ComponentInstance }\n ).__instance;\n const state = instance?.errorBoundaryState;\n if (state) {\n state.error = null;\n state.notified = false;\n }\n };\n\n if (boundaryState?.error != null) {\n renderErrorBoundaryFallbackValueToSink(\n fallback,\n boundaryState.error,\n reset,\n sink,\n ctx\n );\n return;\n }\n\n try {\n renderChildrenSyncToSink(\n normalizeRenderableChildren(props?.children),\n sink,\n ctx\n );\n } catch (error) {\n if (boundaryState) {\n boundaryState.error = error;\n boundaryState.notified = true;\n }\n logger.error('[Askr] ErrorBoundary caught render error:', error);\n renderErrorBoundaryFallbackValueToSink(\n fallback,\n error,\n reset,\n sink,\n ctx\n );\n }\n return;\n }\n throw new Error(\n `renderNodeSyncToSink: unsupported VNode symbol type: ${String(type)}`\n );\n }\n\n const typeStr = type as string;\n if (VOID_ELEMENTS.has(typeStr)) {\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write(' />');\n return;\n }\n\n const maybeDangerous = props\n ? (props as unknown as { dangerouslySetInnerHTML?: unknown })\n ?.dangerouslySetInnerHTML\n : undefined;\n\n if (maybeDangerous !== undefined && maybeDangerous !== null) {\n const dangerousHtml =\n typeof maybeDangerous === 'object' && '__html' in maybeDangerous\n ? String((maybeDangerous as { __html: unknown }).__html)\n : undefined;\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write('>');\n if (dangerousHtml !== undefined) {\n sink.write(dangerousHtml);\n } else {\n renderChildrenSyncToSink((node as VNode).children, sink, ctx);\n }\n sinkWrite3(sink, '</', typeStr, '>');\n return;\n }\n\n // Normalize children: prefer node.children, fallback to props.children (for JSXElement)\n let children = (node as VNode).children;\n if (children === undefined && props?.children !== undefined) {\n const propsChildren = props.children as unknown;\n if (Array.isArray(propsChildren)) {\n children = propsChildren;\n } else if (propsChildren !== null && propsChildren !== false) {\n children = [propsChildren];\n }\n }\n\n // Hot path: empty element (no children) - single write\n if (!children || (Array.isArray(children) && children.length === 0)) {\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write('>');\n sinkWrite3(sink, '</', typeStr, '>');\n return;\n }\n\n // Hot path: single text child - single write\n if (Array.isArray(children) && children.length === 1) {\n const only = children[0];\n if (typeof only === 'string') {\n const content = escapeText(only);\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write('>');\n sink.write(content);\n sinkWrite3(sink, '</', typeStr, '>');\n return;\n }\n if (typeof only === 'number') {\n const content = escapeText(String(only));\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write('>');\n sink.write(content);\n sinkWrite3(sink, '</', typeStr, '>');\n return;\n }\n }\n\n // General case: element with complex children\n sinkWrite2(sink, '<', typeStr);\n renderAttrsDirect(props, sink);\n sink.write('>');\n renderChildrenSyncToSink(children, sink, ctx);\n sinkWrite3(sink, '</', typeStr, '>');\n}\n\n/**\n * Execute a component function (synchronously or async) and return VNode\n */\n/**\n * Execute a component synchronously inside a render-only context.\n * This must not create or reuse runtime ComponentInstance objects. We pass\n * the render context explicitly as `context.ssr` in the second argument so\n * components can opt-in to deterministic randomness/time via the provided RNG.\n */\nfunction executeComponentSync(\n component: Component,\n props: Record<string, unknown> | undefined,\n ctx: RenderContext\n): VNode | JSXElement {\n // Dev-only: enforce SSR purity with clear messages. We temporarily override\n // `Math.random` and `Date.now` while rendering to produce a targeted error\n // if components call them directly. We restore them immediately afterwards.\n // Re-entrant guard for dev-only SSR strict purity checks.\n // We avoid clobbering globals permanently by pushing the original functions\n // onto a stack and restoring them on exit. This is safer for nested or\n // stacked SSR render invocations.\n\n try {\n if (process.env.NODE_ENV !== 'production') {\n pushSSRStrictPurityGuard();\n }\n // Create a temporary, lightweight component instance so runtime APIs like\n // `state()` and `currentRoute()` can be called during SSR render. We avoid mounting\n // or side-effects by not attaching the instance to any DOM target.\n const prev = getCurrentComponentInstance();\n const temp = createComponentInstance(\n 'ssr-temp',\n component as ComponentFunction,\n (props || {}) as Props,\n null\n );\n temp.ssr = true;\n setCurrentComponentInstance(temp);\n try {\n // Context already set via withRenderContext at render entry point\n const result = component((props || {}) as Props, { ssr: ctx });\n if (result instanceof Promise) {\n // Use the centralized SSR error for async data/components during SSR\n throwSSRDataMissing();\n }\n if (\n typeof result === 'string' ||\n typeof result === 'number' ||\n typeof result === 'boolean' ||\n result === null ||\n result === undefined\n ) {\n // Return a Fragment with the text content, not a div wrapper\n const inner =\n result === null || result === undefined || result === false\n ? ''\n : String(result);\n return {\n $$typeof: ELEMENT_TYPE,\n type: Fragment,\n props: { children: inner ? [inner] : [] },\n } as unknown as VNode | JSXElement;\n }\n return result as VNode | JSXElement;\n } finally {\n // Restore the previous instance (if any)\n setCurrentComponentInstance(prev);\n }\n } finally {\n if (process.env.NODE_ENV !== 'production') popSSRStrictPurityGuard();\n }\n}\n\nfunction wrapWithDefaultPortal(out: unknown): VNode | JSXElement {\n const portalVNode = {\n $$typeof: ELEMENT_TYPE,\n type: DefaultPortal,\n props: {},\n key: '__default_portal',\n } as unknown;\n\n if (out == null) {\n return {\n $$typeof: ELEMENT_TYPE,\n type: Fragment,\n props: { children: [portalVNode] },\n } as unknown as VNode | JSXElement;\n }\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: Fragment,\n props: { children: [out as unknown, portalVNode] },\n } as unknown as VNode | JSXElement;\n}\n\nfunction renderSyncComponentRoot(\n component: Component,\n props: Record<string, unknown> | undefined,\n ctx: RenderContext\n): VNode | JSXElement {\n const wrapped: Component = (\n p?: Record<string, unknown>,\n c?: { signal?: AbortSignal; ssr?: RenderContext }\n ) => wrapWithDefaultPortal(component(p ?? {}, c));\n\n return executeComponentSync(wrapped, props || {}, ctx);\n}\n\nfunction getRenderableChildren(\n node: VNode | JSXElement\n): unknown[] | undefined {\n if (Array.isArray((node as VNode).children)) {\n return (node as VNode).children;\n }\n if (Array.isArray(node.props?.children)) {\n return node.props.children as unknown[];\n }\n if (\n node.props?.children !== undefined &&\n node.props.children !== null &&\n node.props.children !== false\n ) {\n return [node.props.children];\n }\n return undefined;\n}\n\ntype VerifyState = {\n current: ChildNode | null;\n pendingText: string;\n};\n\nfunction flushPendingText(state: VerifyState): boolean {\n if (state.pendingText.length === 0) {\n return true;\n }\n if (!state.current || state.current.nodeType !== Node.TEXT_NODE) {\n return false;\n }\n if (state.current.textContent !== state.pendingText) {\n return false;\n }\n state.current = state.current.nextSibling;\n state.pendingText = '';\n return true;\n}\n\nfunction verifyRenderedAttrs(\n element: Element,\n props: Props | undefined\n): { matched: boolean; dangerousHtml?: string } {\n const matchedAttrs = new Set<string>();\n let dangerousHtml: string | undefined;\n\n if (!props || typeof props !== 'object') {\n return {\n matched: element.attributes.length === 0,\n dangerousHtml,\n };\n }\n\n const propsObj = props as Record<string, unknown>;\n for (const key in propsObj) {\n const value = propsObj[key];\n\n if (\n key === 'children' ||\n key === 'key' ||\n key === 'ref' ||\n key === 'dangerouslySetInnerHTML'\n ) {\n if (\n key === 'dangerouslySetInnerHTML' &&\n value &&\n typeof value === 'object' &&\n '__html' in value\n ) {\n dangerousHtml = String((value as { __html: unknown }).__html);\n }\n continue;\n }\n\n if (isSSRAttrEventHandler(key) || key.charCodeAt(0) === 95) {\n continue;\n }\n\n const attrName = key === 'class' || key === 'className' ? 'class' : key;\n\n if (attrName === 'style') {\n const css = typeof value === 'string' ? value : styleObjToCss(value);\n if (!css) continue;\n if (element.getAttribute('style') !== css) {\n return { matched: false };\n }\n matchedAttrs.add('style');\n continue;\n }\n\n if (value === true) {\n if (!element.hasAttribute(attrName)) {\n return { matched: false };\n }\n matchedAttrs.add(attrName);\n continue;\n }\n\n if (value === false || value === null || value === undefined) {\n continue;\n }\n\n const stringValue = String(value);\n if (element.getAttribute(attrName) !== stringValue) {\n return { matched: false };\n }\n matchedAttrs.add(attrName);\n }\n\n if (element.attributes.length !== matchedAttrs.size) {\n return { matched: false };\n }\n\n return { matched: true, dangerousHtml };\n}\n\nfunction verifyExpectedNode(\n node: unknown,\n state: VerifyState,\n ctx: RenderContext\n): boolean {\n if (node === null || node === undefined || node === false) {\n return true;\n }\n\n if (typeof node === 'string' || typeof node === 'number') {\n state.pendingText += String(node);\n return true;\n }\n\n if (!node || typeof node !== 'object' || !('type' in node)) {\n return true;\n }\n\n const vnode = node as VNode | JSXElement;\n const { type, props } = vnode;\n\n if (typeof type === 'function') {\n return verifyExpectedNode(\n inheritRenderableKey(\n vnode,\n executeComponentSync(type as Component, props, ctx)\n ),\n state,\n ctx\n );\n }\n\n if (typeof type === 'symbol') {\n if (type === __CONTROL_BOUNDARY__) {\n const children = evaluateControlBoundaryChildren(vnode);\n if (!children || children.length === 0) {\n return true;\n }\n for (let index = 0; index < children.length; index += 1) {\n if (!verifyExpectedNode(children[index], state, ctx)) {\n return false;\n }\n }\n return true;\n }\n if (type === __ERROR_BOUNDARY__) {\n const boundaryState = getErrorBoundaryState(vnode);\n const fallback = props?.fallback;\n const reset = () => {\n const instance = (\n vnode as DOMElement & { __instance?: ComponentInstance }\n ).__instance;\n const stateRef = instance?.errorBoundaryState;\n if (stateRef) {\n stateRef.error = null;\n stateRef.notified = false;\n }\n };\n\n const snapshot: VerifyState = {\n current: state.current,\n pendingText: state.pendingText,\n };\n\n if (boundaryState?.error != null) {\n const fallbackNode = resolveErrorBoundaryFallbackNode(\n fallback,\n boundaryState.error,\n reset\n );\n return verifyRenderableNode(fallbackNode, state, ctx);\n }\n\n try {\n if (\n verifyExpectedChildren(\n normalizeRenderableChildren(props?.children),\n state,\n ctx\n )\n ) {\n return true;\n }\n } catch (error) {\n if (boundaryState) {\n boundaryState.error = error;\n boundaryState.notified = true;\n }\n }\n\n state.current = snapshot.current;\n state.pendingText = snapshot.pendingText;\n\n const fallbackNode = resolveErrorBoundaryFallbackNode(\n fallback,\n boundaryState?.error ?? new Error('ErrorBoundary render failed'),\n reset\n );\n return verifyRenderableNode(fallbackNode, state, ctx);\n }\n if (type !== Fragment) {\n throw new Error(\n `verifyHydrationSyncForUrl: unsupported VNode symbol type: ${String(type)}`\n );\n }\n const children = getRenderableChildren(vnode);\n if (!children || children.length === 0) {\n return true;\n }\n for (let index = 0; index < children.length; index += 1) {\n if (!verifyExpectedNode(children[index], state, ctx)) {\n return false;\n }\n }\n return true;\n }\n\n if (!flushPendingText(state)) {\n return false;\n }\n\n if (!state.current || state.current.nodeType !== Node.ELEMENT_NODE) {\n return false;\n }\n\n const actualElement = state.current as Element;\n if (actualElement.tagName.toLowerCase() !== String(type).toLowerCase()) {\n return false;\n }\n\n const attrMatch = verifyRenderedAttrs(actualElement, props);\n if (!attrMatch.matched) {\n return false;\n }\n\n if (VOID_ELEMENTS.has(String(type))) {\n if (actualElement.firstChild !== null) {\n return false;\n }\n state.current = actualElement.nextSibling;\n return true;\n }\n\n if (attrMatch.dangerousHtml !== undefined) {\n if (actualElement.innerHTML !== attrMatch.dangerousHtml) {\n return false;\n }\n state.current = actualElement.nextSibling;\n return true;\n }\n\n const childState: VerifyState = {\n current: actualElement.firstChild,\n pendingText: '',\n };\n const children = getRenderableChildren(vnode);\n if (children && children.length > 0) {\n for (let index = 0; index < children.length; index += 1) {\n if (!verifyExpectedNode(children[index], childState, ctx)) {\n return false;\n }\n }\n }\n\n if (!flushPendingText(childState) || childState.current !== null) {\n return false;\n }\n\n state.current = actualElement.nextSibling;\n return true;\n}\n\nfunction verifyExpectedChildren(\n children: unknown[] | undefined,\n state: VerifyState,\n ctx: RenderContext\n): boolean {\n if (!children || children.length === 0) {\n return true;\n }\n\n for (let index = 0; index < children.length; index += 1) {\n if (!verifyExpectedNode(children[index], state, ctx)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction verifyRenderableNode(\n value: unknown,\n state: VerifyState,\n ctx: RenderContext\n): boolean {\n return Array.isArray(value)\n ? verifyExpectedChildren(normalizeRenderableChildren(value), state, ctx)\n : verifyExpectedNode(value, state, ctx);\n}\n\n/**\n * Single synchronous SSR entrypoint: render a component to an HTML string.\n * This is strictly synchronous and deterministic. Optionally provide a seed\n * for deterministic randomness via `options.seed`.\n */\nexport function renderToStringSync(\n component: (\n props?: Record<string, unknown>\n ) => VNode | JSXElement | string | number | boolean | null | undefined,\n props?: Record<string, unknown>,\n options?: { seed?: number; data?: SSRData }\n): string {\n const seed = options?.seed ?? 12345;\n const ctx = createRenderContext(seed, { data: options?.data });\n\n return withRenderContext(ctx, () => {\n // Set render data on context (startRenderPhase now reads from context)\n startRenderPhase(options?.data ?? null);\n try {\n const node = renderSyncComponentRoot(\n component as unknown as Component,\n props || {},\n ctx\n );\n if (!node) {\n throw new Error('renderToStringSync: wrapped component returned empty');\n }\n const sink = new StringSink();\n renderNodeSyncToSink(node, sink, ctx);\n sink.end();\n return sink.toString();\n } finally {\n stopRenderPhase();\n }\n });\n}\n\nexport function renderResolvedToStringSync(opts: {\n url: string;\n routes: Array<{ path: string; handler: RouteHandler; namespace?: string }>;\n handler: RouteHandler;\n params?: Record<string, string>;\n options?: { seed?: number; data?: SSRData };\n}): string {\n const { url, routes, handler, params, options } = opts;\n const seed = options?.seed ?? 12345;\n const ctx = createRenderContext(seed, {\n url,\n data: options?.data,\n params,\n routes,\n });\n\n return withRenderContext(ctx, () => {\n startRenderPhase(options?.data ?? null);\n try {\n const node = renderSyncComponentRoot(\n handler as unknown as Component,\n params || {},\n ctx\n );\n const sink = new StringSink();\n renderNodeSyncToSink(node, sink, ctx);\n sink.end();\n return sink.toString();\n } finally {\n stopRenderPhase();\n }\n });\n}\n\nexport async function resolveRequest(opts: {\n url: string;\n manifest?: RouteManifest;\n routes?: Array<{ path: string; handler: RouteHandler; namespace?: string }>;\n auth?: RouteAuthOptions;\n signal?: AbortSignal;\n}): Promise<RouteRequestResult> {\n const { url, manifest, routes, auth, signal } = opts;\n\n if (manifest) {\n return await RouteModule.resolveRouteRequest(url, {\n manifest,\n mode: 'ssr',\n auth,\n signal,\n });\n }\n\n if (!routes) {\n throw new Error('resolveRequest requires a route manifest or route table.');\n }\n\n const requestUrl = new URL(url, 'http://localhost');\n const resolved = RouteModule.resolveRouteFromRoutes(\n requestUrl.pathname,\n routes\n );\n\n if (!resolved) {\n return null;\n }\n\n return {\n kind: 'render',\n handler: resolved.handler,\n params: resolved.params,\n };\n}\n\n// --- Streaming sink-based renderer (v2) --------------------------------------------------\nimport { StringSink, StreamSink } from './sink';\nimport { startRenderPhase, stopRenderPhase } from './render-keys';\n\nexport type SSRRoute = {\n path: string;\n handler: RouteHandler;\n namespace?: string;\n};\n\nexport function renderToString(\n component: (\n props?: Record<string, unknown>\n ) => VNode | JSXElement | string | number | null\n): string;\nexport function renderToString(opts: {\n url: string;\n routes: SSRRoute[];\n seed?: number;\n data?: SSRData;\n}): string;\nexport function renderToString(arg: unknown): string {\n // Convenience: if a component function is passed, delegate to sync render\n if (typeof arg === 'function') {\n return renderToStringSync(\n arg as (\n props?: Record<string, unknown>\n ) => VNode | JSXElement | string | number | null\n );\n }\n const opts = arg as {\n url: string;\n routes: SSRRoute[];\n seed?: number;\n data?: SSRData;\n };\n const sink = new StringSink();\n renderToSinkInternal({ ...opts, sink });\n sink.end();\n return sink.toString();\n}\n\nexport function renderToStream(opts: {\n url: string;\n routes: SSRRoute[];\n seed?: number;\n data?: SSRData;\n onChunk(html: string): void;\n onComplete(): void;\n}): void {\n const sink = new StreamSink(opts.onChunk, opts.onComplete);\n renderToSinkInternal({ ...opts, sink });\n sink.end();\n}\n\nfunction renderToSinkInternal(opts: {\n url: string;\n routes: SSRRoute[];\n seed?: number;\n data?: SSRData;\n sink: { write(html: string): void; end(): void };\n}) {\n const { url, routes, seed = 12345, data, sink } = opts;\n\n const routeTable = routes.map((route) => ({ ...route }));\n const requestUrl = new URL(url, 'http://localhost');\n const resolved = RouteModule.resolveRouteFromRoutes(\n requestUrl.pathname,\n routeTable\n );\n if (!resolved) throw new Error(`SSR: no route found for url: ${url}`);\n\n const ctx = createRenderContext(seed, {\n url,\n data,\n params: resolved.params,\n routes: routeTable,\n });\n\n withRenderContext(ctx, () => {\n // Start render-phase keying so resource() can lookup resolved `data` by key\n startRenderPhase(data || null);\n try {\n const node = executeComponentSync(\n resolved.handler as unknown as Component,\n resolved.params,\n ctx\n );\n renderNodeSyncToSink(node, sink, ctx);\n } finally {\n stopRenderPhase();\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsDA,MAAM,cAEH,QAAQ,IAAI,mBAAmB,OAAO,QAAQ,IAAI,mBAAmB;AAExE,SAAS,sBAAsB,KAAsB;CACnD,OACE,IAAI,UAAU,KACd,IAAI,WAAW,EAAE,KAAK,OACtB,IAAI,WAAW,EAAE,KAAK,OACtB,IAAI,WAAW,EAAE,IAAI,MACrB,IAAI,WAAW,EAAE,IAAI;;AAIzB,SAAS,qBACP,QACA,QACoB;CACpB,MAAM,eAAgB,OAAsB;CAC5C,IAAI,iBAAiB,UAAa,iBAAiB,MACjD,OAAO;CAGT,IAAI,CAAC,UAAU,OAAO,WAAW,YAAY,EAAE,UAAU,SACvD,OAAO;CAGT,MAAM,cAAc;CACpB,IAAI,YAAY,QAAQ,UAAa,YAAY,QAAQ,MACvD,YAAY,MAAM;CAGpB,IAAI,OAAO,YAAY,SAAS,UAAU;EACxC,IAAI,CAAC,YAAY,OACf,YAAY,QAAQ,EAAE;EAGxB,IAAI,YAAY,MAAM,gBAAgB,QACpC,YAAY,MAAM,cAAc,OAAO,aAAa;;CAIxD,OAAO;;AAMT,iBAAiB;CACf,sBAAsB;CACtB;CACA;CACA;CACD,CAAC;AASF,MAAM,kBAAsE,EAAE;AAE9E,SAAS,2BAA2B;CAGlC,gBAAgB,KAAK;EACnB,QAAQ,QAAQ,IAAI,MAAM,SAAS;EACnC,KAAK,QAAQ,IAAI,MAAM,MAAM;EAC9B,CAAC;CACF,QAAQ,IAAI,MAAM,gBAAgB;EAChC,MAAM,IAAI,MACR,oHACD;GACD;CACF,QAAQ,IAAI,MAAM,aAAa;EAC7B,MAAM,IAAI,MACR,8HACD;GACD;;AAGJ,SAAS,0BAA0B;CAGjC,MAAM,OAAO,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EAClB,QAAQ,SAAS;EAClB;;AAwBH,SAAgB,eAAe,KAAsB;CAEnD,IAAI,OAAO,QAAQ,YACjB,OAAO,mBACL,IAGD;CAEH,MAAM,OAAO;CAMb,MAAM,OAAO,IAAI,YAAY;CAC7B,qBAAqB;EAAE,GAAG;EAAM;EAAM,CAAC;CACvC,KAAK,KAAK;CACV,OAAO,KAAK,UAAU;;AAGxB,SAAgB,eAAe,MAOtB;CACP,MAAM,OAAO,IAAI,WAAW,KAAK,SAAS,KAAK,WAAW;CAC1D,qBAAqB;EAAE,GAAG;EAAM;EAAM,CAAC;CACvC,KAAK,KAAK;;AAGZ,SAAS,qBAAqB,MAM3B;CACD,MAAM,EAAE,KAAK,QAAQ,OAAO,OAAO,MAAM,SAAS;CAElD,MAAM,aAAa,OAAO,KAAK,WAAW,EAAE,GAAG,OAAO,EAAE;CAExD,MAAM,WAAWA,uBACf,IAFqB,IAAI,KAAK,mBAE9B,CAAW,UACX,WACD;CACD,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,gCAAgC,MAAM;CAErE,MAAM,MAAM,oBAAoB,MAAM;EACpC;EACA;EACA,QAAQ,SAAS;EACjB,QAAQ;EACT,CAAC;CAEF,kBAAkB,WAAW;EAE3B,iBAAiB,QAAQ,KAAK;EAC9B,IAAI;GAMF,qBALa,qBACX,SAAS,SACT,SAAS,QACT,IAEmB,EAAM,MAAM,IAAI;YAC7B;GACR,iBAAiB;;GAEnB"}
|
package/dist/ssr/render-keys.js
CHANGED
|
@@ -22,18 +22,7 @@ function stopRenderPhase() {
|
|
|
22
22
|
ctx.keyCounter = 0;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
const PREPASS_REMOVED_MSG = "SSR collection/prepass is removed: SSR is strictly synchronous";
|
|
26
|
-
/** @deprecated SSR prepass has been removed */
|
|
27
|
-
async function resolvePlan(_plan) {
|
|
28
|
-
throw new Error(`${PREPASS_REMOVED_MSG}; async resource plans are not supported`);
|
|
29
|
-
}
|
|
30
|
-
/** @deprecated SSR prepass has been removed */
|
|
31
|
-
function collectResources(_opts) {
|
|
32
|
-
throw new Error(`${PREPASS_REMOVED_MSG}; collectResources is disabled`);
|
|
33
|
-
}
|
|
34
|
-
/** @deprecated Alias for resolvePlan */
|
|
35
|
-
const resolveResources = resolvePlan;
|
|
36
25
|
//#endregion
|
|
37
|
-
export {
|
|
26
|
+
export { getCurrentRenderData, getNextKey, startRenderPhase, stopRenderPhase };
|
|
38
27
|
|
|
39
28
|
//# sourceMappingURL=render-keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-keys.js","names":[],"sources":["../../src/ssr/render-keys.ts"],"sourcesContent":["/**\n * SSR Data Management\n *\n * Manages render-phase keying for deterministic SSR data lookup.\n * All state is stored in the per-render context for concurrency safety.\n */\n\nimport type { SSRRoute } from './index';\nimport { getRenderContext } from './context';\n\nexport type ResourceDescriptor = {\n key: string;\n fn: (opts: { signal?: AbortSignal }) => Promise<unknown> | unknown;\n deps: unknown[];\n index: number;\n};\n\nexport type ResourcePlan = {\n resources: ResourceDescriptor[]; // declarative manifest in stable order\n};\n\nexport function getCurrentRenderData(): Record<string, unknown> | null {\n const ctx = getRenderContext();\n return ctx?.renderData ?? null;\n}\n\nexport function resetKeyCounter() {\n const ctx = getRenderContext();\n if (ctx) ctx.keyCounter = 0;\n}\n\nexport function getNextKey(): string {\n const ctx = getRenderContext();\n if (!ctx) return `r:0`; // Fallback for edge cases\n return `r:${ctx.keyCounter++}`;\n}\n\nexport function startRenderPhase(data: Record<string, unknown> | null) {\n const ctx = getRenderContext();\n if (ctx) {\n ctx.renderData = data ?? null;\n ctx.keyCounter = 0;\n }\n}\n\nexport function stopRenderPhase() {\n const ctx = getRenderContext();\n if (ctx) {\n ctx.renderData = null;\n ctx.keyCounter = 0;\n }\n}\n\n// --- Deprecated APIs (throw descriptive errors) ---\n\nconst PREPASS_REMOVED_MSG =\n 'SSR collection/prepass is removed: SSR is strictly synchronous';\n\n/** @deprecated SSR prepass has been removed */\nexport function startCollection(): never {\n throw new Error(`${PREPASS_REMOVED_MSG}; do not call startCollection()`);\n}\n\n/** @deprecated SSR prepass has been removed */\nexport function stopCollection(): ResourcePlan {\n throw new Error(`${PREPASS_REMOVED_MSG}; do not call stopCollection()`);\n}\n\n/** @deprecated SSR prepass has been removed */\nexport function registerResourceIntent(\n _fn: ResourceDescriptor['fn'],\n _deps: unknown[]\n): string {\n throw new Error(\n `${PREPASS_REMOVED_MSG}; resource() no longer registers intents for prepass`\n );\n}\n\n/** @deprecated SSR prepass has been removed */\nexport async function resolvePlan(\n _plan: ResourcePlan\n): Promise<Record<string, unknown>> {\n throw new Error(\n `${PREPASS_REMOVED_MSG}; async resource plans are not supported`\n );\n}\n\n/** @deprecated SSR prepass has been removed */\nexport function collectResources(_opts: {\n url: string;\n routes: SSRRoute[];\n}): ResourcePlan {\n throw new Error(`${PREPASS_REMOVED_MSG}; collectResources is disabled`);\n}\n\n/** @deprecated Alias for resolvePlan */\nexport const resolveResources = resolvePlan;\n"],"mappings":";;AAqBA,SAAgB,uBAAuD;CAErE,OADY,kBACL,EAAK,cAAc;;AAQ5B,SAAgB,aAAqB;CACnC,MAAM,MAAM,kBAAkB;CAC9B,IAAI,CAAC,KAAK,OAAO;CACjB,OAAO,KAAK,IAAI;;AAGlB,SAAgB,iBAAiB,MAAsC;CACrE,MAAM,MAAM,kBAAkB;CAC9B,IAAI,KAAK;EACP,IAAI,aAAa,QAAQ;EACzB,IAAI,aAAa;;;AAIrB,SAAgB,kBAAkB;CAChC,MAAM,MAAM,kBAAkB;CAC9B,IAAI,KAAK;EACP,IAAI,aAAa;EACjB,IAAI,aAAa
|
|
1
|
+
{"version":3,"file":"render-keys.js","names":[],"sources":["../../src/ssr/render-keys.ts"],"sourcesContent":["/**\n * SSR Data Management\n *\n * Manages render-phase keying for deterministic SSR data lookup.\n * All state is stored in the per-render context for concurrency safety.\n */\n\nimport type { SSRRoute } from './index';\nimport { getRenderContext } from './context';\n\nexport type ResourceDescriptor = {\n key: string;\n fn: (opts: { signal?: AbortSignal }) => Promise<unknown> | unknown;\n deps: unknown[];\n index: number;\n};\n\nexport type ResourcePlan = {\n resources: ResourceDescriptor[]; // declarative manifest in stable order\n};\n\nexport function getCurrentRenderData(): Record<string, unknown> | null {\n const ctx = getRenderContext();\n return ctx?.renderData ?? null;\n}\n\nexport function resetKeyCounter() {\n const ctx = getRenderContext();\n if (ctx) ctx.keyCounter = 0;\n}\n\nexport function getNextKey(): string {\n const ctx = getRenderContext();\n if (!ctx) return `r:0`; // Fallback for edge cases\n return `r:${ctx.keyCounter++}`;\n}\n\nexport function startRenderPhase(data: Record<string, unknown> | null) {\n const ctx = getRenderContext();\n if (ctx) {\n ctx.renderData = data ?? null;\n ctx.keyCounter = 0;\n }\n}\n\nexport function stopRenderPhase() {\n const ctx = getRenderContext();\n if (ctx) {\n ctx.renderData = null;\n ctx.keyCounter = 0;\n }\n}\n\n// --- Deprecated APIs (throw descriptive errors) ---\n\nconst PREPASS_REMOVED_MSG =\n 'SSR collection/prepass is removed: SSR is strictly synchronous';\n\n/** @deprecated SSR prepass has been removed */\nexport function startCollection(): never {\n throw new Error(`${PREPASS_REMOVED_MSG}; do not call startCollection()`);\n}\n\n/** @deprecated SSR prepass has been removed */\nexport function stopCollection(): ResourcePlan {\n throw new Error(`${PREPASS_REMOVED_MSG}; do not call stopCollection()`);\n}\n\n/** @deprecated SSR prepass has been removed */\nexport function registerResourceIntent(\n _fn: ResourceDescriptor['fn'],\n _deps: unknown[]\n): string {\n throw new Error(\n `${PREPASS_REMOVED_MSG}; resource() no longer registers intents for prepass`\n );\n}\n\n/** @deprecated SSR prepass has been removed */\nexport async function resolvePlan(\n _plan: ResourcePlan\n): Promise<Record<string, unknown>> {\n throw new Error(\n `${PREPASS_REMOVED_MSG}; async resource plans are not supported`\n );\n}\n\n/** @deprecated SSR prepass has been removed */\nexport function collectResources(_opts: {\n url: string;\n routes: SSRRoute[];\n}): ResourcePlan {\n throw new Error(`${PREPASS_REMOVED_MSG}; collectResources is disabled`);\n}\n\n/** @deprecated Alias for resolvePlan */\nexport const resolveResources = resolvePlan;\n"],"mappings":";;AAqBA,SAAgB,uBAAuD;CAErE,OADY,kBACL,EAAK,cAAc;;AAQ5B,SAAgB,aAAqB;CACnC,MAAM,MAAM,kBAAkB;CAC9B,IAAI,CAAC,KAAK,OAAO;CACjB,OAAO,KAAK,IAAI;;AAGlB,SAAgB,iBAAiB,MAAsC;CACrE,MAAM,MAAM,kBAAkB;CAC9B,IAAI,KAAK;EACP,IAAI,aAAa,QAAQ;EACzB,IAAI,aAAa;;;AAIrB,SAAgB,kBAAkB;CAChC,MAAM,MAAM,kBAAkB;CAC9B,IAAI,KAAK;EACP,IAAI,aAAa;EACjB,IAAI,aAAa"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { resolveRouteFromRoutes } from "../router/route.js";
|
|
2
|
+
import { renderResolvedToStringSync } from "./index.js";
|
|
3
|
+
//#region src/ssr/verify-hydration.ts
|
|
4
|
+
function normalizeHydrationHtml(html) {
|
|
5
|
+
const template = document.createElement("template");
|
|
6
|
+
template.innerHTML = html;
|
|
7
|
+
return template.innerHTML.replace(/<!--.*?-->/g, "");
|
|
8
|
+
}
|
|
9
|
+
function verifyHydrationSyncForUrl(opts) {
|
|
10
|
+
const { root, url, routes, options } = opts;
|
|
11
|
+
const resolved = resolveRouteFromRoutes(new URL(url, "http://localhost").pathname, routes);
|
|
12
|
+
if (!resolved) return false;
|
|
13
|
+
const expected = renderResolvedToStringSync({
|
|
14
|
+
url,
|
|
15
|
+
routes,
|
|
16
|
+
handler: resolved.handler,
|
|
17
|
+
params: resolved.params,
|
|
18
|
+
options
|
|
19
|
+
});
|
|
20
|
+
return normalizeHydrationHtml(root.innerHTML) === normalizeHydrationHtml(expected);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { verifyHydrationSyncForUrl };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=verify-hydration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-hydration.js","names":["RouteModule.resolveRouteFromRoutes"],"sources":["../../src/ssr/verify-hydration.ts"],"sourcesContent":["import { renderResolvedToStringSync, type SSRRoute } from './index';\nimport type { SSRData } from './context';\nimport * as RouteModule from '../router/route';\n\nfunction normalizeHydrationHtml(html: string): string {\n const template = document.createElement('template');\n template.innerHTML = html;\n return template.innerHTML.replace(/<!--.*?-->/g, '');\n}\n\nexport function verifyHydrationSyncForUrl(opts: {\n root: Element;\n url: string;\n routes: SSRRoute[];\n options?: { seed?: number; data?: SSRData };\n}): boolean {\n const { root, url, routes, options } = opts;\n const requestUrl = new URL(url, 'http://localhost');\n const resolved = RouteModule.resolveRouteFromRoutes(\n requestUrl.pathname,\n routes\n );\n\n if (!resolved) {\n return false;\n }\n\n const expected = renderResolvedToStringSync({\n url,\n routes,\n handler: resolved.handler,\n params: resolved.params,\n options,\n });\n\n return (\n normalizeHydrationHtml(root.innerHTML) === normalizeHydrationHtml(expected)\n );\n}\n"],"mappings":";;;AAIA,SAAS,uBAAuB,MAAsB;CACpD,MAAM,WAAW,SAAS,cAAc,WAAW;CACnD,SAAS,YAAY;CACrB,OAAO,SAAS,UAAU,QAAQ,eAAe,GAAG;;AAGtD,SAAgB,0BAA0B,MAK9B;CACV,MAAM,EAAE,MAAM,KAAK,QAAQ,YAAY;CAEvC,MAAM,WAAWA,uBACf,IAFqB,IAAI,KAAK,mBAE9B,CAAW,UACX,OACD;CAED,IAAI,CAAC,UACH,OAAO;CAGT,MAAM,WAAW,2BAA2B;EAC1C;EACA;EACA,SAAS,SAAS;EAClB,QAAQ,SAAS;EACjB;EACD,CAAC;CAEF,OACE,uBAAuB,KAAK,UAAU,KAAK,uBAAuB,SAAS"}
|