@fictjs/ssr 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,36 +1,15 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/stream-runtime.ts
21
- var stream_runtime_exports = {};
22
- __export(stream_runtime_exports, {
23
- FICT_STREAM_RUNTIME_CODE: () => FICT_STREAM_RUNTIME_CODE,
24
- createStreamRuntimeCode: () => createStreamRuntimeCode
25
- });
26
- module.exports = __toCommonJS(stream_runtime_exports);
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
+ */
27
9
  function createStreamRuntimeCode(options = {}) {
28
- const observerMode = options.observerMode ?? true;
29
- return `(function(){if(window.__FICT_STREAM)return;var cache=new Map();function find(id){var hit=cache.get(id);if(hit)return hit;var start=null,end=null;var w=document.createTreeWalker(document,NodeFilter.SHOW_COMMENT);while(w.nextNode()){var n=w.currentNode;var d=n.data;if(d==="fict:suspense-start:"+id)start=n;else if(d==="fict:suspense-end:"+id)end=n;if(start&&end)break;}if(start&&end){hit={start:start,end:end};cache.set(id,hit);}return hit;}function apply(id){var tpl=document.querySelector('template[data-fict-suspense="' + id + '"]');if(!tpl)return;var b=find(id);if(!b)return;var node=b.start.nextSibling;while(node&&node!==b.end){var next=node.nextSibling;node.parentNode&&node.parentNode.removeChild(node);node=next;}b.end.parentNode&&b.end.parentNode.insertBefore(tpl.content,b.end);tpl.parentNode&&tpl.parentNode.removeChild(tpl);}window.__FICT_STREAM={apply:apply};` + (observerMode ? 'function scan(root){var list=(root&&root.querySelectorAll?root:document).querySelectorAll("template[data-fict-suspense]");for(var i=0;i<list.length;i++){apply(list[i].getAttribute("data-fict-suspense"));}}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){if(n.matches&&n.matches("template[data-fict-suspense]"))apply(n.getAttribute("data-fict-suspense"));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
+ return "(function(){if(window.__FICT_STREAM)return;var cache=new Map();function find(id){var hit=cache.get(id);if(hit)return hit;var start=null,end=null;var w=document.createTreeWalker(document,NodeFilter.SHOW_COMMENT);while(w.nextNode()){var n=w.currentNode;var d=n.data;if(d===\"fict:suspense-start:\"+id)start=n;else if(d===\"fict:suspense-end:\"+id)end=n;if(start&&end)break;}if(start&&end){hit={start:start,end:end};cache.set(id,hit);}return hit;}function apply(id){var tpl=document.querySelector('template[data-fict-suspense=\"' + id + '\"]');if(!tpl)return;var b=find(id);if(!b)return;var node=b.start.nextSibling;while(node&&node!==b.end){var next=node.nextSibling;node.parentNode&&node.parentNode.removeChild(node);node=next;}b.end.parentNode&&b.end.parentNode.insertBefore(tpl.content,b.end);tpl.parentNode&&tpl.parentNode.removeChild(tpl);}window.__FICT_STREAM={apply:apply};" + (options.observerMode ?? true ? "function scan(root){var list=(root&&root.querySelectorAll?root:document).querySelectorAll(\"template[data-fict-suspense]\");for(var i=0;i<list.length;i++){apply(list[i].getAttribute(\"data-fict-suspense\"));}}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){if(n.matches&&n.matches(\"template[data-fict-suspense]\"))apply(n.getAttribute(\"data-fict-suspense\"));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);}" : "") + "})();";
30
11
  }
31
- var FICT_STREAM_RUNTIME_CODE = createStreamRuntimeCode({ observerMode: true });
32
- // Annotate the CommonJS export names for ESM import in node:
33
- 0 && (module.exports = {
34
- FICT_STREAM_RUNTIME_CODE,
35
- createStreamRuntimeCode
36
- });
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;
@@ -1,8 +1,9 @@
1
+ //#region src/stream-runtime.d.ts
1
2
  interface StreamRuntimeCodeOptions {
2
- /**
3
- * Enable observer mode so patch templates are applied without per-chunk inline scripts.
4
- */
5
- observerMode?: boolean;
3
+ /**
4
+ * Enable observer mode so patch templates are applied without per-chunk inline scripts.
5
+ */
6
+ observerMode?: boolean;
6
7
  }
7
8
  /**
8
9
  * Create the browser-side streaming patch runtime as classic-script JavaScript.
@@ -12,5 +13,6 @@ interface StreamRuntimeCodeOptions {
12
13
  */
13
14
  declare function createStreamRuntimeCode(options?: StreamRuntimeCodeOptions): string;
14
15
  declare const FICT_STREAM_RUNTIME_CODE: string;
15
-
16
- export { FICT_STREAM_RUNTIME_CODE, type StreamRuntimeCodeOptions, createStreamRuntimeCode };
16
+ //#endregion
17
+ export { FICT_STREAM_RUNTIME_CODE, StreamRuntimeCodeOptions, createStreamRuntimeCode };
18
+ //# 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;;;EAIf,YAAY;AAAA;AASd;;;;AAA8E;AAqC9E;AArCA,iBAAgB,uBAAA,CAAwB,OAAsC,GAA7B,wBAA6B;AAAA,cAqCjE,wBAAA"}
@@ -1,8 +1,9 @@
1
+ //#region src/stream-runtime.d.ts
1
2
  interface StreamRuntimeCodeOptions {
2
- /**
3
- * Enable observer mode so patch templates are applied without per-chunk inline scripts.
4
- */
5
- observerMode?: boolean;
3
+ /**
4
+ * Enable observer mode so patch templates are applied without per-chunk inline scripts.
5
+ */
6
+ observerMode?: boolean;
6
7
  }
7
8
  /**
8
9
  * Create the browser-side streaming patch runtime as classic-script JavaScript.
@@ -12,5 +13,6 @@ interface StreamRuntimeCodeOptions {
12
13
  */
13
14
  declare function createStreamRuntimeCode(options?: StreamRuntimeCodeOptions): string;
14
15
  declare const FICT_STREAM_RUNTIME_CODE: string;
15
-
16
- export { FICT_STREAM_RUNTIME_CODE, type StreamRuntimeCodeOptions, createStreamRuntimeCode };
16
+ //#endregion
17
+ export { FICT_STREAM_RUNTIME_CODE, StreamRuntimeCodeOptions, createStreamRuntimeCode };
18
+ //# 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;;;EAIf,YAAY;AAAA;AASd;;;;AAA8E;AAqC9E;AArCA,iBAAgB,uBAAA,CAAwB,OAAsC,GAA7B,wBAA6B;AAAA,cAqCjE,wBAAA"}
@@ -1,8 +1,15 @@
1
- import {
2
- FICT_STREAM_RUNTIME_CODE,
3
- createStreamRuntimeCode
4
- } from "./chunk-DI4PFT6R.js";
5
- export {
6
- FICT_STREAM_RUNTIME_CODE,
7
- createStreamRuntimeCode
8
- };
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(){if(window.__FICT_STREAM)return;var cache=new Map();function find(id){var hit=cache.get(id);if(hit)return hit;var start=null,end=null;var w=document.createTreeWalker(document,NodeFilter.SHOW_COMMENT);while(w.nextNode()){var n=w.currentNode;var d=n.data;if(d===\"fict:suspense-start:\"+id)start=n;else if(d===\"fict:suspense-end:\"+id)end=n;if(start&&end)break;}if(start&&end){hit={start:start,end:end};cache.set(id,hit);}return hit;}function apply(id){var tpl=document.querySelector('template[data-fict-suspense=\"' + id + '\"]');if(!tpl)return;var b=find(id);if(!b)return;var node=b.start.nextSibling;while(node&&node!==b.end){var next=node.nextSibling;node.parentNode&&node.parentNode.removeChild(node);node=next;}b.end.parentNode&&b.end.parentNode.insertBefore(tpl.content,b.end);tpl.parentNode&&tpl.parentNode.removeChild(tpl);}window.__FICT_STREAM={apply:apply};" + (options.observerMode ?? true ? "function scan(root){var list=(root&&root.querySelectorAll?root:document).querySelectorAll(\"template[data-fict-suspense]\");for(var i=0;i<list.length;i++){apply(list[i].getAttribute(\"data-fict-suspense\"));}}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){if(n.matches&&n.matches(\"template[data-fict-suspense]\"))apply(n.getAttribute(\"data-fict-suspense\"));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 */\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 'if(window.__FICT_STREAM)return;' +\n 'var cache=new Map();' +\n 'function find(id){' +\n 'var hit=cache.get(id);if(hit)return hit;' +\n 'var start=null,end=null;' +\n 'var w=document.createTreeWalker(document,NodeFilter.SHOW_COMMENT);' +\n 'while(w.nextNode()){' +\n 'var n=w.currentNode;var d=n.data;' +\n 'if(d===\"fict:suspense-start:\"+id)start=n;' +\n 'else if(d===\"fict:suspense-end:\"+id)end=n;' +\n 'if(start&&end)break;' +\n '}' +\n 'if(start&&end){hit={start:start,end:end};cache.set(id,hit);}return hit;' +\n '}' +\n 'function apply(id){' +\n \"var tpl=document.querySelector('template[data-fict-suspense=\\\"' + id + '\\\"]');\" +\n 'if(!tpl)return;' +\n 'var b=find(id);if(!b)return;' +\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 'b.end.parentNode&&b.end.parentNode.insertBefore(tpl.content,b.end);' +\n 'tpl.parentNode&&tpl.parentNode.removeChild(tpl);' +\n '}' +\n 'window.__FICT_STREAM={apply:apply};' +\n (observerMode\n ? 'function scan(root){var list=(root&&root.querySelectorAll?root:document).querySelectorAll(\"template[data-fict-suspense]\");for(var i=0;i<list.length;i++){apply(list[i].getAttribute(\"data-fict-suspense\"));}}' +\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){if(n.matches&&n.matches(\"template[data-fict-suspense]\"))apply(n.getAttribute(\"data-fict-suspense\"));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":";;;;;;;AAaA,SAAgB,wBAAwB,UAAoC,CAAC,GAAW;CAEtF,OACE,o3BAFmB,QAAQ,gBAAgB,OA4BvC,qvBAGA,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.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Fict server-side rendering",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -38,11 +38,11 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "linkedom": "^0.18.12",
41
- "@fictjs/runtime": "0.22.0"
41
+ "@fictjs/runtime": "0.23.0"
42
42
  },
43
43
  "devDependencies": {
44
- "tsup": "^8.5.1",
45
- "fict": "0.22.0"
44
+ "tsdown": "^0.22.3",
45
+ "fict": "0.23.0"
46
46
  },
47
47
  "keywords": [
48
48
  "fict",
@@ -54,9 +54,9 @@
54
54
  "author": "unadlib",
55
55
  "license": "MIT",
56
56
  "scripts": {
57
- "build": "tsup src/index.ts src/experimental.ts src/stream-runtime.ts --format cjs,esm --dts && pnpm run build:stream-runtime",
57
+ "build": "tsdown && pnpm run build:stream-runtime",
58
58
  "build:stream-runtime": "node scripts/write-stream-runtime-asset.mjs",
59
- "dev": "tsup src/index.ts src/experimental.ts src/stream-runtime.ts --format cjs,esm --dts --watch --onSuccess \"pnpm run build:stream-runtime\"",
59
+ "dev": "tsdown --watch --on-success \"pnpm run build:stream-runtime\"",
60
60
  "test": "vitest run",
61
61
  "test:edge": "node test/edge-runtime.smoke.mjs",
62
62
  "test:matrix": "pnpm run test && pnpm run test:edge",
@@ -1,11 +0,0 @@
1
- // src/stream-runtime.ts
2
- function createStreamRuntimeCode(options = {}) {
3
- const observerMode = options.observerMode ?? true;
4
- return `(function(){if(window.__FICT_STREAM)return;var cache=new Map();function find(id){var hit=cache.get(id);if(hit)return hit;var start=null,end=null;var w=document.createTreeWalker(document,NodeFilter.SHOW_COMMENT);while(w.nextNode()){var n=w.currentNode;var d=n.data;if(d==="fict:suspense-start:"+id)start=n;else if(d==="fict:suspense-end:"+id)end=n;if(start&&end)break;}if(start&&end){hit={start:start,end:end};cache.set(id,hit);}return hit;}function apply(id){var tpl=document.querySelector('template[data-fict-suspense="' + id + '"]');if(!tpl)return;var b=find(id);if(!b)return;var node=b.start.nextSibling;while(node&&node!==b.end){var next=node.nextSibling;node.parentNode&&node.parentNode.removeChild(node);node=next;}b.end.parentNode&&b.end.parentNode.insertBefore(tpl.content,b.end);tpl.parentNode&&tpl.parentNode.removeChild(tpl);}window.__FICT_STREAM={apply:apply};` + (observerMode ? 'function scan(root){var list=(root&&root.querySelectorAll?root:document).querySelectorAll("template[data-fict-suspense]");for(var i=0;i<list.length;i++){apply(list[i].getAttribute("data-fict-suspense"));}}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){if(n.matches&&n.matches("template[data-fict-suspense]"))apply(n.getAttribute("data-fict-suspense"));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);}' : "") + "})();";
5
- }
6
- var FICT_STREAM_RUNTIME_CODE = createStreamRuntimeCode({ observerMode: true });
7
-
8
- export {
9
- createStreamRuntimeCode,
10
- FICT_STREAM_RUNTIME_CODE
11
- };