@fictjs/ssr 0.28.0 → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,202 @@
1
+ import { FictNode } from "@fictjs/runtime";
2
+
3
+ //#region src/render-core.d.ts
4
+ interface SSRDom {
5
+ window: Window;
6
+ document: Document;
7
+ }
8
+ interface RenderToStringOptions {
9
+ /**
10
+ * Provide a pre-created DOM (document + window). If omitted, a new DOM is
11
+ * created per render using `html`.
12
+ */
13
+ dom?: SSRDom;
14
+ /**
15
+ * Provide a document directly. If `window` is omitted, `document.defaultView`
16
+ * will be used when available.
17
+ */
18
+ document?: Document;
19
+ /**
20
+ * Provide a window directly. If `document` is omitted, `window.document` is used.
21
+ */
22
+ window?: Window;
23
+ /**
24
+ * HTML template used when creating a new DOM.
25
+ */
26
+ html?: string;
27
+ /**
28
+ * Provide a container element to render into.
29
+ */
30
+ container?: HTMLElement;
31
+ /**
32
+ * Tag name for the auto-created container.
33
+ */
34
+ containerTag?: string;
35
+ /**
36
+ * id applied to the auto-created container.
37
+ */
38
+ containerId?: string;
39
+ /**
40
+ * Additional attributes applied to the auto-created container.
41
+ */
42
+ containerAttributes?: Record<string, string | number | boolean | null | undefined>;
43
+ /**
44
+ * Return the container element including its outer tag.
45
+ */
46
+ includeContainer?: boolean;
47
+ /**
48
+ * Return a full HTML document string (doctype + documentElement.outerHTML).
49
+ */
50
+ fullDocument?: boolean;
51
+ /**
52
+ * Override doctype when `fullDocument` is true. Use `null` to omit.
53
+ */
54
+ doctype?: string | null;
55
+ /**
56
+ * Expose DOM globals (window/document/Node/Element/etc) during render.
57
+ * Defaults to false. Set to true only for compatibility with components
58
+ * that still read process-global DOM objects during server rendering.
59
+ * An exposed-global render is exclusive with every other SSR render. A
60
+ * renderToDocument reservation remains active until dispose().
61
+ */
62
+ exposeGlobals?: boolean;
63
+ /**
64
+ * Manifest mapping module URLs to built client chunk URLs.
65
+ * Can be an object or a path to a JSON file.
66
+ * File path mode requires Deno sync filesystem access or a CommonJS
67
+ * environment where `require('node:fs')` is available. Pass an object when
68
+ * rendering from Node ESM or edge runtimes.
69
+ */
70
+ manifest?: Record<string, string> | string;
71
+ /**
72
+ * Include the Preview SSR snapshot script for resumability.
73
+ * Defaults to false so supported SSR rendering never opts into Preview output
74
+ * implicitly.
75
+ *
76
+ * @experimental The snapshot schema is not part of the Satellite or Core 1.0 promise.
77
+ */
78
+ includeSnapshot?: boolean;
79
+ /**
80
+ * Script element id for the snapshot.
81
+ * @experimental Part of the Preview resumability snapshot contract.
82
+ */
83
+ snapshotScriptId?: string;
84
+ /**
85
+ * Where to append the snapshot script when not returning full document.
86
+ * Defaults to 'container'.
87
+ * External-runtime shell streams with incremental head snapshots require a
88
+ * non-empty scriptNonce because head placement uses an inline mover.
89
+ * @experimental Part of the Preview resumability snapshot contract.
90
+ */
91
+ snapshotTarget?: 'container' | 'body' | 'head';
92
+ /**
93
+ * Nonce applied to generated <script> tags for CSP compatibility.
94
+ */
95
+ scriptNonce?: string;
96
+ /**
97
+ * Stable namespace for resumable scope identifiers in `data-fict-s` and
98
+ * snapshot payloads. Set this when independently cached or separately rendered
99
+ * outputs can share a document, and keep it unique within that document.
100
+ * This does not change streaming Suspense patch identifiers.
101
+ *
102
+ * Values must contain 1-128 ASCII letters, digits, `_`, `.`, `:`, or `-`, and
103
+ * must not contain `--`. When omitted, each render gets an automatic edge-safe
104
+ * namespace.
105
+ *
106
+ * @experimental Part of the Preview resumability identity contract.
107
+ */
108
+ scopeIdentifierPrefix?: string;
109
+ }
110
+ interface RenderToStreamOptions extends RenderToStringOptions {
111
+ /**
112
+ * Streaming mode:
113
+ * - 'shell': send fallback shell first, then patch resolved boundaries
114
+ * - 'all': wait for all suspense boundaries, then send full HTML
115
+ */
116
+ mode?: 'shell' | 'all';
117
+ /**
118
+ * Called once the initial shell has been written.
119
+ */
120
+ onShellReady?: () => void;
121
+ /**
122
+ * Called once all pending boundaries resolve and the stream completes.
123
+ */
124
+ onAllReady?: () => void;
125
+ /**
126
+ * Called when an error occurs during streaming.
127
+ */
128
+ onError?: (err: unknown) => void;
129
+ /**
130
+ * Abort signal to cancel the stream.
131
+ */
132
+ signal?: AbortSignal;
133
+ /**
134
+ * How to load the streaming patch runtime.
135
+ * Defaults to 'inline'. Use 'external' with streamRuntimeSrc for strict CSP.
136
+ */
137
+ streamRuntime?: 'inline' | 'external';
138
+ /**
139
+ * External streaming patch runtime URL when streamRuntime is 'external'.
140
+ */
141
+ streamRuntimeSrc?: string;
142
+ /**
143
+ * How resolved Suspense patch chunks are applied.
144
+ * Defaults to 'inline' for inline runtimes and 'observer' for external runtimes.
145
+ */
146
+ streamPatchMode?: 'inline' | 'observer';
147
+ /**
148
+ * Stable namespace for Suspense patch identifiers. Set this when independently
149
+ * cached or separately rendered streams can share a document, and keep it unique
150
+ * within that document. This does not change resumable scope identifiers.
151
+ *
152
+ * Values must contain 1-128 ASCII letters, digits, `_`, `.`, `:`, or `-`, and
153
+ * must not contain `--`. When omitted, each shell stream gets an automatic
154
+ * edge-safe namespace.
155
+ */
156
+ streamIdentifierPrefix?: string;
157
+ }
158
+ interface PipeableStream {
159
+ pipe: (writable: NodeJS.WritableStream) => void;
160
+ abort: (reason?: unknown) => void;
161
+ shellReady: Promise<void>;
162
+ allReady: Promise<void>;
163
+ }
164
+ /**
165
+ * @experimental Preview PPR result; its fields and delivery model may change
166
+ * before graduation. Use `renderToStream` for supported streaming SSR.
167
+ */
168
+ interface PartialPrerenderResult {
169
+ /**
170
+ * Complete shell HTML (fallbacks + markers + initial snapshot scripts).
171
+ *
172
+ * @experimental Preview API for v1.0; the access pattern may change before
173
+ * this becomes stable.
174
+ */
175
+ shell: string;
176
+ /**
177
+ * Stream of deferred patch chunks and incremental snapshots.
178
+ */
179
+ stream: ReadableStream<Uint8Array>;
180
+ shellReady: Promise<void>;
181
+ allReady: Promise<void>;
182
+ abort: (reason?: unknown) => void;
183
+ }
184
+ interface RenderToDocumentResult extends SSRDom {
185
+ html: string;
186
+ container: HTMLElement;
187
+ dispose: () => void;
188
+ }
189
+ declare function createSSRDocument(html?: string): SSRDom;
190
+ declare function renderToDocument(view: () => FictNode, options?: RenderToStringOptions): RenderToDocumentResult;
191
+ declare function renderToString(view: () => FictNode, options?: RenderToStringOptions): string;
192
+ declare function renderToStringAsync(view: () => FictNode, options?: RenderToStringOptions): Promise<string>;
193
+ declare function renderToStream(view: () => FictNode, options?: RenderToStreamOptions): ReadableStream<Uint8Array>;
194
+ declare function renderToPipeableStream(view: () => FictNode, options?: RenderToStreamOptions): PipeableStream;
195
+ /**
196
+ * @experimental Preview API for v1.0; the return shape may change before this
197
+ * becomes stable.
198
+ */
199
+ declare function renderToPartial(view: () => FictNode, options?: RenderToStreamOptions): PartialPrerenderResult;
200
+ //#endregion
201
+ export { RenderToStringOptions as a, renderToDocument as c, renderToStream as d, renderToString as f, RenderToStreamOptions as i, renderToPartial as l, PipeableStream as n, SSRDom as o, renderToStringAsync as p, RenderToDocumentResult as r, createSSRDocument as s, PartialPrerenderResult as t, renderToPipeableStream as u };
202
+ //# sourceMappingURL=render-core-FDu-zTWN.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-core-FDu-zTWN.d.ts","names":[],"sources":["../src/render-core.ts"],"mappings":";;;UAkCiB,MAAA;EACf,MAAA,EAAQ,MAAA;EACR,QAAA,EAAU,QAAQ;AAAA;AAAA,UAGH,qBAAA;EAHG;;;;EAQlB,GAAA,GAAM,MAAA;EARY;AAAA;AAGpB;;EAUE,QAAA,GAAW,QAAA;EALL;;;EASN,MAAA,GAAS,MAAA;EAoBa;;;EAhBtB,IAAA;EAbA;;;EAiBA,SAAA,GAAY,WAAA;EARZ;;;EAYA,YAAA;EAJY;;;EAQZ,WAAA;EAIsB;;;EAAtB,mBAAA,GAAsB,MAAA;EAoBtB;;;EAhBA,gBAAA;EAqCA;;;EAjCA,YAAA;EA0DqB;AAAA;AAGvB;EAzDE,OAAA;;;;;;;;EAQA,aAAA;EAuEA;;;;;;;EA/DA,QAAA,GAAW,MAAA;EA0FI;;;;;;;EAlFf,eAAA;EAmFA;;;;EA9EA,gBAAA;EA+EQ;;;;;;AAES;EAzEjB,cAAA;EAgFqC;;;EA5ErC,WAAA;EAwFY;;;;;;;;;;;;EA3EZ,qBAAA;AAAA;AAAA,UAGe,qBAAA,SAA8B,qBAAqB;EA0E1C;AAG1B;;;;EAvEE,IAAA;EAwEA;;;EApEA,YAAA;EAsEO;AAAA;AAQT;EA1EE,UAAA;;;AA0EoE;EAtEpE,OAAA,IAAW,GAAA;EA+EmB;;;EA3E9B,MAAA,GAAS,WAAA;EA8ER;;;;EAzED,aAAA;EAwES;;;EApET,gBAAA;EAqEuB;AAkEzB;;;EAlIE,eAAA;EAkIyC;;;;;AAA6C;AAOxF;;;EA/HE,sBAAA;AAAA;AAAA,UAGe,cAAA;EACf,IAAA,GAAO,QAAA,EAAU,MAAA,CAAO,cAAA;EACxB,KAAA,GAAQ,MAAA;EACR,UAAA,EAAY,OAAA;EACZ,QAAA,EAAU,OAAA;AAAA;;;;AA2HF;UApHO,sBAAA;EAiJa;;;;;;EA1I5B,KAAA;EA6Ie;;;EAzIf,MAAA,EAAQ,cAAA,CAAe,UAAA;EACvB,UAAA,EAAY,OAAA;EACZ,QAAA,EAAU,OAAA;EACV,KAAA,GAAQ,MAAA;AAAA;AAAA,UAGO,sBAAA,SAA+B,MAAM;EACpD,IAAA;EACA,SAAA,EAAW,WAAA;EACX,OAAA;AAAA;AAAA,iBAQc,iBAAA,CAAkB,IAAA,YAA8B,MAAM;AAAA,iBAStD,gBAAA,CACd,IAAA,QAAY,QAAA,EACZ,OAAA,GAAS,qBAAA,GACR,sBAAA;AAAA,iBAkEa,cAAA,CAAe,IAAA,QAAY,QAAA,EAAU,OAAA,GAAS,qBAA0B;AAAA,iBAOlE,mBAAA,CACpB,IAAA,QAAY,QAAA,EACZ,OAAA,GAAS,qBAAA,GACR,OAAA;AAAA,iBA6Ba,cAAA,CACd,IAAA,QAAY,QAAA,EACZ,OAAA,GAAS,qBAAA,GACR,cAAA,CAAe,UAAA;AAAA,iBAkFF,sBAAA,CACd,IAAA,QAAY,QAAA,EACZ,OAAA,GAAS,qBAAA,GACR,cAAA;;;;;iBA8Ba,eAAA,CACd,IAAA,QAAY,QAAA,EACZ,OAAA,GAAS,qBAAA,GACR,sBAAA"}
@@ -0,0 +1,15 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/stream-runtime.ts
3
+ /**
4
+ * Create the browser-side streaming patch runtime as classic-script JavaScript.
5
+ *
6
+ * The generated package asset `@fictjs/ssr/fict-stream-runtime.js` is built from
7
+ * this helper with `observerMode: true`.
8
+ */
9
+ function createStreamRuntimeCode(options = {}) {
10
+ return "(function(){var runtime=window.__FICT_STREAM;function walk(root,visit){var stack=[root];while(stack.length){var node=stack.pop();if(visit(node)===false)return false;var container=node.nodeType===1&&node.localName===\"template\"&&node.content?node.content:node;for(var child=container.lastChild;child;child=child.previousSibling)stack.push(child);}return true;}if(!runtime||typeof runtime.apply!==\"function\"){var cache=new Map();function findTemplate(id){var tpl=null;walk(document,function(n){if(n.nodeType===1&&n.localName===\"template\"&&n.content&&n.getAttribute(\"data-fict-suspense\")===id){tpl=n;return false;}});return tpl;}function find(id){var hit=cache.get(id);if(hit)return hit;var startMarker=\"fict:suspense-start:\"+id,endMarker=\"fict:suspense-end:\"+id;walk(document,function(n){if(n.nodeType!==8||n.data!==startMarker)return;var end=n.nextSibling;while(end&&(end.nodeType!==8||end.data!==endMarker))end=end.nextSibling;if(end){hit={start:n,end:end};return false;}});if(hit)cache.set(id,hit);return hit;}function apply(id){if(typeof id!==\"string\"||!id)return;var tpl=findTemplate(id);if(!tpl)return;var b=find(id);if(!b)return;var parent=b.start.parentNode;if(!parent||b.end.parentNode!==parent)return;var cursor=b.start.nextSibling;while(cursor&&cursor!==b.end)cursor=cursor.nextSibling;if(cursor!==b.end)return;var content=tpl.content;var ns=tpl.getAttribute(\"data-fict-patch-namespace\");if(ns){var tag=ns===\"svg\"?\"svg\":ns===\"mathml\"?\"math\":null;var wrapper=content.firstElementChild;if(!tag||!wrapper||wrapper.localName!==tag)return;var fragment=document.createDocumentFragment();while(wrapper.firstChild)fragment.appendChild(wrapper.firstChild);content=fragment;}var node=b.start.nextSibling;while(node&&node!==b.end){var next=node.nextSibling;node.parentNode&&node.parentNode.removeChild(node);node=next;}parent.insertBefore(content,b.end);tpl.parentNode&&tpl.parentNode.removeChild(tpl);}runtime={apply:apply};window.__FICT_STREAM=runtime;}" + (options.observerMode ?? true ? "if(runtime.observerInstalled)return;runtime.observerInstalled=true;function scan(root){var ids=[];walk(root,function(n){if(n.nodeType===1&&n.localName===\"template\"&&n.content&&n.hasAttribute(\"data-fict-suspense\")){var id=n.getAttribute(\"data-fict-suspense\");if(id)ids.push(id);}});for(var i=0;i<ids.length;i++)runtime.apply(ids[i]);}if(typeof MutationObserver===\"function\"){new MutationObserver(function(muts){for(var i=0;i<muts.length;i++){for(var j=0;j<muts[i].addedNodes.length;j++){var n=muts[i].addedNodes[j];if(n.nodeType===1)scan(n);}}}).observe(document.documentElement||document,{childList:true,subtree:true});}if(document.readyState===\"loading\"){document.addEventListener(\"DOMContentLoaded\",function(){scan(document);},{once:true});}else{scan(document);}" : "") + "})();";
11
+ }
12
+ const FICT_STREAM_RUNTIME_CODE = createStreamRuntimeCode({ observerMode: true });
13
+ //#endregion
14
+ exports.FICT_STREAM_RUNTIME_CODE = FICT_STREAM_RUNTIME_CODE;
15
+ exports.createStreamRuntimeCode = createStreamRuntimeCode;
@@ -0,0 +1,20 @@
1
+ //#region src/stream-runtime.d.ts
2
+ interface StreamRuntimeCodeOptions {
3
+ /**
4
+ * Enable observer mode so patch templates are applied without per-chunk inline scripts.
5
+ * Existing template fragments are covered by the initial scan; observation follows
6
+ * additions to the document tree made while streamed HTML is parsed.
7
+ */
8
+ observerMode?: boolean;
9
+ }
10
+ /**
11
+ * Create the browser-side streaming patch runtime as classic-script JavaScript.
12
+ *
13
+ * The generated package asset `@fictjs/ssr/fict-stream-runtime.js` is built from
14
+ * this helper with `observerMode: true`.
15
+ */
16
+ declare function createStreamRuntimeCode(options?: StreamRuntimeCodeOptions): string;
17
+ declare const FICT_STREAM_RUNTIME_CODE: string;
18
+ //#endregion
19
+ export { FICT_STREAM_RUNTIME_CODE, StreamRuntimeCodeOptions, createStreamRuntimeCode };
20
+ //# sourceMappingURL=stream-runtime.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-runtime.d.cts","names":[],"sources":["../src/stream-runtime.ts"],"mappings":";UAAiB,wBAAA;EAAA;;;;AAMH;EAAZ,YAAY;AAAA;;;AASgE;AAsD9E;;;iBAtDgB,uBAAA,CAAwB,OAAsC,GAA7B,wBAA6B;AAAA,cAsDjE,wBAAA"}
@@ -0,0 +1,20 @@
1
+ //#region src/stream-runtime.d.ts
2
+ interface StreamRuntimeCodeOptions {
3
+ /**
4
+ * Enable observer mode so patch templates are applied without per-chunk inline scripts.
5
+ * Existing template fragments are covered by the initial scan; observation follows
6
+ * additions to the document tree made while streamed HTML is parsed.
7
+ */
8
+ observerMode?: boolean;
9
+ }
10
+ /**
11
+ * Create the browser-side streaming patch runtime as classic-script JavaScript.
12
+ *
13
+ * The generated package asset `@fictjs/ssr/fict-stream-runtime.js` is built from
14
+ * this helper with `observerMode: true`.
15
+ */
16
+ declare function createStreamRuntimeCode(options?: StreamRuntimeCodeOptions): string;
17
+ declare const FICT_STREAM_RUNTIME_CODE: string;
18
+ //#endregion
19
+ export { FICT_STREAM_RUNTIME_CODE, StreamRuntimeCodeOptions, createStreamRuntimeCode };
20
+ //# sourceMappingURL=stream-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-runtime.d.ts","names":[],"sources":["../src/stream-runtime.ts"],"mappings":";UAAiB,wBAAA;EAAA;;;;AAMH;EAAZ,YAAY;AAAA;;;AASgE;AAsD9E;;;iBAtDgB,uBAAA,CAAwB,OAAsC,GAA7B,wBAA6B;AAAA,cAsDjE,wBAAA"}
@@ -0,0 +1,15 @@
1
+ //#region src/stream-runtime.ts
2
+ /**
3
+ * Create the browser-side streaming patch runtime as classic-script JavaScript.
4
+ *
5
+ * The generated package asset `@fictjs/ssr/fict-stream-runtime.js` is built from
6
+ * this helper with `observerMode: true`.
7
+ */
8
+ function createStreamRuntimeCode(options = {}) {
9
+ return "(function(){var runtime=window.__FICT_STREAM;function walk(root,visit){var stack=[root];while(stack.length){var node=stack.pop();if(visit(node)===false)return false;var container=node.nodeType===1&&node.localName===\"template\"&&node.content?node.content:node;for(var child=container.lastChild;child;child=child.previousSibling)stack.push(child);}return true;}if(!runtime||typeof runtime.apply!==\"function\"){var cache=new Map();function findTemplate(id){var tpl=null;walk(document,function(n){if(n.nodeType===1&&n.localName===\"template\"&&n.content&&n.getAttribute(\"data-fict-suspense\")===id){tpl=n;return false;}});return tpl;}function find(id){var hit=cache.get(id);if(hit)return hit;var startMarker=\"fict:suspense-start:\"+id,endMarker=\"fict:suspense-end:\"+id;walk(document,function(n){if(n.nodeType!==8||n.data!==startMarker)return;var end=n.nextSibling;while(end&&(end.nodeType!==8||end.data!==endMarker))end=end.nextSibling;if(end){hit={start:n,end:end};return false;}});if(hit)cache.set(id,hit);return hit;}function apply(id){if(typeof id!==\"string\"||!id)return;var tpl=findTemplate(id);if(!tpl)return;var b=find(id);if(!b)return;var parent=b.start.parentNode;if(!parent||b.end.parentNode!==parent)return;var cursor=b.start.nextSibling;while(cursor&&cursor!==b.end)cursor=cursor.nextSibling;if(cursor!==b.end)return;var content=tpl.content;var ns=tpl.getAttribute(\"data-fict-patch-namespace\");if(ns){var tag=ns===\"svg\"?\"svg\":ns===\"mathml\"?\"math\":null;var wrapper=content.firstElementChild;if(!tag||!wrapper||wrapper.localName!==tag)return;var fragment=document.createDocumentFragment();while(wrapper.firstChild)fragment.appendChild(wrapper.firstChild);content=fragment;}var node=b.start.nextSibling;while(node&&node!==b.end){var next=node.nextSibling;node.parentNode&&node.parentNode.removeChild(node);node=next;}parent.insertBefore(content,b.end);tpl.parentNode&&tpl.parentNode.removeChild(tpl);}runtime={apply:apply};window.__FICT_STREAM=runtime;}" + (options.observerMode ?? true ? "if(runtime.observerInstalled)return;runtime.observerInstalled=true;function scan(root){var ids=[];walk(root,function(n){if(n.nodeType===1&&n.localName===\"template\"&&n.content&&n.hasAttribute(\"data-fict-suspense\")){var id=n.getAttribute(\"data-fict-suspense\");if(id)ids.push(id);}});for(var i=0;i<ids.length;i++)runtime.apply(ids[i]);}if(typeof MutationObserver===\"function\"){new MutationObserver(function(muts){for(var i=0;i<muts.length;i++){for(var j=0;j<muts[i].addedNodes.length;j++){var n=muts[i].addedNodes[j];if(n.nodeType===1)scan(n);}}}).observe(document.documentElement||document,{childList:true,subtree:true});}if(document.readyState===\"loading\"){document.addEventListener(\"DOMContentLoaded\",function(){scan(document);},{once:true});}else{scan(document);}" : "") + "})();";
10
+ }
11
+ const FICT_STREAM_RUNTIME_CODE = createStreamRuntimeCode({ observerMode: true });
12
+ //#endregion
13
+ export { FICT_STREAM_RUNTIME_CODE, createStreamRuntimeCode };
14
+
15
+ //# sourceMappingURL=stream-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-runtime.js","names":[],"sources":["../src/stream-runtime.ts"],"sourcesContent":["export interface StreamRuntimeCodeOptions {\n /**\n * Enable observer mode so patch templates are applied without per-chunk inline scripts.\n * Existing template fragments are covered by the initial scan; observation follows\n * additions to the document tree made while streamed HTML is parsed.\n */\n observerMode?: boolean\n}\n\n/**\n * Create the browser-side streaming patch runtime as classic-script JavaScript.\n *\n * The generated package asset `@fictjs/ssr/fict-stream-runtime.js` is built from\n * this helper with `observerMode: true`.\n */\nexport function createStreamRuntimeCode(options: StreamRuntimeCodeOptions = {}): string {\n const observerMode = options.observerMode ?? true\n return (\n '(function(){' +\n 'var runtime=window.__FICT_STREAM;' +\n 'function walk(root,visit){' +\n 'var stack=[root];while(stack.length){' +\n 'var node=stack.pop();if(visit(node)===false)return false;' +\n 'var container=node.nodeType===1&&node.localName===\"template\"&&node.content?node.content:node;' +\n 'for(var child=container.lastChild;child;child=child.previousSibling)stack.push(child);' +\n '}return true;' +\n '}' +\n 'if(!runtime||typeof runtime.apply!==\"function\"){' +\n 'var cache=new Map();' +\n 'function findTemplate(id){' +\n 'var tpl=null;walk(document,function(n){' +\n 'if(n.nodeType===1&&n.localName===\"template\"&&n.content&&n.getAttribute(\"data-fict-suspense\")===id){tpl=n;return false;}' +\n '});return tpl;' +\n '}' +\n 'function find(id){' +\n 'var hit=cache.get(id);if(hit)return hit;' +\n 'var startMarker=\"fict:suspense-start:\"+id,endMarker=\"fict:suspense-end:\"+id;' +\n 'walk(document,function(n){' +\n 'if(n.nodeType!==8||n.data!==startMarker)return;' +\n 'var end=n.nextSibling;while(end&&(end.nodeType!==8||end.data!==endMarker))end=end.nextSibling;' +\n 'if(end){hit={start:n,end:end};return false;}' +\n '});' +\n 'if(hit)cache.set(id,hit);return hit;' +\n '}' +\n 'function apply(id){' +\n 'if(typeof id!==\"string\"||!id)return;' +\n 'var tpl=findTemplate(id);if(!tpl)return;' +\n 'var b=find(id);if(!b)return;' +\n 'var parent=b.start.parentNode;if(!parent||b.end.parentNode!==parent)return;' +\n 'var cursor=b.start.nextSibling;while(cursor&&cursor!==b.end)cursor=cursor.nextSibling;if(cursor!==b.end)return;' +\n 'var content=tpl.content;var ns=tpl.getAttribute(\"data-fict-patch-namespace\");' +\n 'if(ns){var tag=ns===\"svg\"?\"svg\":ns===\"mathml\"?\"math\":null;var wrapper=content.firstElementChild;if(!tag||!wrapper||wrapper.localName!==tag)return;var fragment=document.createDocumentFragment();while(wrapper.firstChild)fragment.appendChild(wrapper.firstChild);content=fragment;}' +\n 'var node=b.start.nextSibling;' +\n 'while(node&&node!==b.end){var next=node.nextSibling;node.parentNode&&node.parentNode.removeChild(node);node=next;}' +\n 'parent.insertBefore(content,b.end);' +\n 'tpl.parentNode&&tpl.parentNode.removeChild(tpl);' +\n '}' +\n 'runtime={apply:apply};window.__FICT_STREAM=runtime;' +\n '}' +\n (observerMode\n ? 'if(runtime.observerInstalled)return;runtime.observerInstalled=true;' +\n 'function scan(root){var ids=[];walk(root,function(n){if(n.nodeType===1&&n.localName===\"template\"&&n.content&&n.hasAttribute(\"data-fict-suspense\")){var id=n.getAttribute(\"data-fict-suspense\");if(id)ids.push(id);}});for(var i=0;i<ids.length;i++)runtime.apply(ids[i]);}' +\n 'if(typeof MutationObserver===\"function\"){new MutationObserver(function(muts){for(var i=0;i<muts.length;i++){for(var j=0;j<muts[i].addedNodes.length;j++){var n=muts[i].addedNodes[j];if(n.nodeType===1)scan(n);}}}).observe(document.documentElement||document,{childList:true,subtree:true});}' +\n 'if(document.readyState===\"loading\"){document.addEventListener(\"DOMContentLoaded\",function(){scan(document);},{once:true});}else{scan(document);}'\n : '') +\n '})();'\n )\n}\n\nexport const FICT_STREAM_RUNTIME_CODE = createStreamRuntimeCode({ observerMode: true })\n"],"mappings":";;;;;;;AAeA,SAAgB,wBAAwB,UAAoC,CAAC,GAAW;CAEtF,OACE,87DAFmB,QAAQ,gBAAgB,OA4CvC,6wBAIA,MACJ;AAEJ;AAEA,MAAa,2BAA2B,wBAAwB,EAAE,cAAc,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fictjs/ssr",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "description": "Fict server-side rendering",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -46,11 +46,11 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "linkedom": "^0.18.12",
49
- "@fictjs/runtime": "0.28.0"
49
+ "@fictjs/runtime": "0.29.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "tsdown": "^0.22.3",
53
- "fict": "0.28.0"
53
+ "fict": "0.29.0"
54
54
  },
55
55
  "keywords": [
56
56
  "fict",