@fluixi/dom 1.0.0-alpha.69 → 1.0.0-alpha.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/dom.cjs +1 -1
- package/dist/cdn/dom.global.js +1 -1
- package/dist/cdn/dom.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/dom/dynamic-element.cjs +1 -1
- package/dist/lib/dom/dynamic-element.mjs +1 -1
- package/dist/lib/dom/hydration-state.cjs +1 -1
- package/dist/lib/dom/hydration-state.d.ts +2 -0
- package/dist/lib/dom/hydration-state.d.ts.map +1 -1
- package/dist/lib/dom/hydration-state.mjs +1 -1
- package/dist/lib/dom/hydration.cjs +1 -1
- package/dist/lib/dom/hydration.d.ts.map +1 -1
- package/dist/lib/dom/hydration.js +20 -1
- package/dist/lib/dom/hydration.mjs +1 -1
- package/dist/lib/dom/index.cjs +1 -1
- package/dist/lib/dom/index.mjs +1 -1
- package/dist/lib/dom/island.cjs +1 -1
- package/dist/lib/dom/island.mjs +1 -1
- package/dist/lib/dom/runtime.cjs +1 -1
- package/dist/lib/dom/runtime.d.ts +48 -0
- package/dist/lib/dom/runtime.d.ts.map +1 -1
- package/dist/lib/dom/runtime.js +100 -1
- package/dist/lib/dom/runtime.mjs +1 -1
- package/dist/lib/dom/server/host.cjs +1 -1
- package/dist/lib/dom/server/host.d.ts +4 -0
- package/dist/lib/dom/server/host.d.ts.map +1 -1
- package/dist/lib/dom/server/host.mjs +1 -1
- package/dist/lib/dom/server/index.cjs +1 -1
- package/dist/lib/dom/server/index.mjs +1 -1
- package/dist/lib/dom/server/nodes.cjs +1 -1
- package/dist/lib/dom/server/nodes.d.ts +15 -0
- package/dist/lib/dom/server/nodes.d.ts.map +1 -1
- package/dist/lib/dom/server/nodes.js +23 -0
- package/dist/lib/dom/server/nodes.mjs +1 -1
- package/dist/lib/dom/server/parse-template.cjs +1 -0
- package/dist/lib/dom/server/parse-template.d.ts +26 -0
- package/dist/lib/dom/server/parse-template.d.ts.map +1 -0
- package/dist/lib/dom/server/parse-template.js +154 -0
- package/dist/lib/dom/server/parse-template.mjs +1 -0
- package/dist/lib/dom/server/render.cjs +1 -1
- package/dist/lib/dom/server/render.d.ts.map +1 -1
- package/dist/lib/dom/server/render.js +4 -1
- package/dist/lib/dom/server/render.mjs +1 -1
- package/dist/lib/dom/server/serialize.cjs +1 -1
- package/dist/lib/dom/server/serialize.d.ts.map +1 -1
- package/dist/lib/dom/server/serialize.js +11 -1
- package/dist/lib/dom/server/serialize.mjs +1 -1
- package/dist/lib/dom/server-renderer.cjs +1 -1
- package/dist/lib/dom/server-renderer.mjs +1 -1
- package/dist/lib/dom/versions.cjs +1 -0
- package/dist/lib/dom/versions.d.ts +33 -0
- package/dist/lib/dom/versions.d.ts.map +1 -0
- package/dist/lib/dom/versions.js +57 -0
- package/dist/lib/dom/versions.mjs +1 -0
- package/dist/lib/flow/client-only.cjs +1 -1
- package/dist/lib/flow/client-only.mjs +1 -1
- package/dist/lib/flow/index-flow.cjs +1 -1
- package/dist/lib/flow/index-flow.mjs +1 -1
- package/dist/lib/flow/index.cjs +1 -1
- package/dist/lib/flow/index.mjs +1 -1
- package/dist/lib/flow/portal.cjs +1 -1
- package/dist/lib/flow/portal.mjs +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +1 -0
- package/dist/version.generated.d.ts +3 -0
- package/dist/version.generated.d.ts.map +1 -0
- package/dist/version.generated.js +3 -0
- package/dist/version.generated.mjs +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a compiler-emitted template into server nodes.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately **not** an HTML parser. The only input it ever sees is the output of the
|
|
5
|
+
* compiler's `serializeStatic`, which emits a narrow, known grammar: lowercase tag names,
|
|
6
|
+
* double-quoted attribute values, entity-escaped text, void elements left unclosed, no
|
|
7
|
+
* namespaces, no comments, no raw `<script>`/`<style>` content. Keeping the input
|
|
8
|
+
* controlled is what makes this a small total function instead of a spec project — and
|
|
9
|
+
* the round-trip test pins the two together, so the grammar cannot drift on one side.
|
|
10
|
+
*
|
|
11
|
+
* A hole-free template never reaches here: it is carried verbatim as a `ServerRaw` node,
|
|
12
|
+
* which is strictly cheaper. This exists for templates with holes, where the server has
|
|
13
|
+
* to produce real nodes for the hole content to be inserted into.
|
|
14
|
+
*/
|
|
15
|
+
import { ServerComment, ServerElement, ServerText } from './nodes.js';
|
|
16
|
+
/** Elements the HTML parser closes itself — they never have children. */
|
|
17
|
+
const VOID_ELEMENTS = new Set([
|
|
18
|
+
'area',
|
|
19
|
+
'base',
|
|
20
|
+
'br',
|
|
21
|
+
'col',
|
|
22
|
+
'embed',
|
|
23
|
+
'hr',
|
|
24
|
+
'img',
|
|
25
|
+
'input',
|
|
26
|
+
'link',
|
|
27
|
+
'meta',
|
|
28
|
+
'param',
|
|
29
|
+
'source',
|
|
30
|
+
'track',
|
|
31
|
+
'wbr',
|
|
32
|
+
]);
|
|
33
|
+
const ENTITIES = {
|
|
34
|
+
amp: '&',
|
|
35
|
+
lt: '<',
|
|
36
|
+
gt: '>',
|
|
37
|
+
quot: '"',
|
|
38
|
+
'#39': "'",
|
|
39
|
+
};
|
|
40
|
+
function unescape(text) {
|
|
41
|
+
return text.replace(/&(#?\w+);/g, (whole, name) => ENTITIES[name] ?? whole);
|
|
42
|
+
}
|
|
43
|
+
export class TemplateParseError extends Error {
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build the server-node tree for `html`.
|
|
47
|
+
*
|
|
48
|
+
* Returns the single root element. The compiler only ever emits a template rooted at one
|
|
49
|
+
* element, so more than one root is a bug on the emitting side rather than something to
|
|
50
|
+
* paper over here.
|
|
51
|
+
*/
|
|
52
|
+
export function parseTemplate(html, isSVG = false) {
|
|
53
|
+
let i = 0;
|
|
54
|
+
const roots = [];
|
|
55
|
+
const stack = [];
|
|
56
|
+
const append = (node) => {
|
|
57
|
+
const parent = stack[stack.length - 1];
|
|
58
|
+
if (parent)
|
|
59
|
+
parent.appendChild(node);
|
|
60
|
+
else
|
|
61
|
+
roots.push(node);
|
|
62
|
+
};
|
|
63
|
+
while (i < html.length) {
|
|
64
|
+
const lt = html.indexOf('<', i);
|
|
65
|
+
if (lt === -1) {
|
|
66
|
+
addText(html.slice(i));
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
if (lt > i)
|
|
70
|
+
addText(html.slice(i, lt));
|
|
71
|
+
// `<!---->` marks a hole. It has to survive into the server's markup, or hydration
|
|
72
|
+
// would see a different shape from the one the generated paths describe.
|
|
73
|
+
if (html.startsWith('<!--', lt)) {
|
|
74
|
+
const end = html.indexOf('-->', lt);
|
|
75
|
+
if (end === -1)
|
|
76
|
+
throw new TemplateParseError(`unterminated comment at ${lt}`);
|
|
77
|
+
append(new ServerComment(html.slice(lt + 4, end)));
|
|
78
|
+
i = end + 3;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (html[lt + 1] === '/') {
|
|
82
|
+
const end = html.indexOf('>', lt);
|
|
83
|
+
if (end === -1)
|
|
84
|
+
throw new TemplateParseError(`unterminated closing tag at ${lt}`);
|
|
85
|
+
const tag = html.slice(lt + 2, end).trim().toLowerCase();
|
|
86
|
+
const open = stack.pop();
|
|
87
|
+
if (!open || open.localName !== tag) {
|
|
88
|
+
throw new TemplateParseError(`</${tag}> does not close <${open?.localName ?? 'nothing'}>`);
|
|
89
|
+
}
|
|
90
|
+
i = end + 1;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
i = openTag(lt);
|
|
94
|
+
}
|
|
95
|
+
if (stack.length > 0) {
|
|
96
|
+
throw new TemplateParseError(`unclosed <${stack[stack.length - 1].localName}>`);
|
|
97
|
+
}
|
|
98
|
+
const root = roots[0];
|
|
99
|
+
if (roots.length !== 1 || !(root instanceof ServerElement)) {
|
|
100
|
+
throw new TemplateParseError(`expected exactly one root element, got ${roots.length}`);
|
|
101
|
+
}
|
|
102
|
+
return root;
|
|
103
|
+
function addText(raw) {
|
|
104
|
+
if (raw === '')
|
|
105
|
+
return;
|
|
106
|
+
append(new ServerText(unescape(raw)));
|
|
107
|
+
}
|
|
108
|
+
/** Consume `<tag attr="v" …>` starting at `lt`, returning the offset just past it. */
|
|
109
|
+
function openTag(lt) {
|
|
110
|
+
const nameEnd = /[\s/>]/.exec(html.slice(lt + 1));
|
|
111
|
+
if (!nameEnd)
|
|
112
|
+
throw new TemplateParseError(`unterminated tag at ${lt}`);
|
|
113
|
+
const tag = html.slice(lt + 1, lt + 1 + nameEnd.index).toLowerCase();
|
|
114
|
+
const el = new ServerElement(tag, isSVG);
|
|
115
|
+
let j = lt + 1 + nameEnd.index;
|
|
116
|
+
while (j < html.length) {
|
|
117
|
+
while (j < html.length && /\s/.test(html[j]))
|
|
118
|
+
j++;
|
|
119
|
+
if (html[j] === '>') {
|
|
120
|
+
j++;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
if (html[j] === '/' && html[j + 1] === '>') {
|
|
124
|
+
j += 2;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
const attrStart = j;
|
|
128
|
+
while (j < html.length && !/[\s=/>]/.test(html[j]))
|
|
129
|
+
j++;
|
|
130
|
+
const name = html.slice(attrStart, j);
|
|
131
|
+
if (name === '')
|
|
132
|
+
throw new TemplateParseError(`malformed attribute at ${j}`);
|
|
133
|
+
if (html[j] === '=') {
|
|
134
|
+
// The serializer always quotes, so an unquoted value means the input did not
|
|
135
|
+
// come from it — refuse rather than guess.
|
|
136
|
+
if (html[j + 1] !== '"') {
|
|
137
|
+
throw new TemplateParseError(`attribute ${name} must have a double-quoted value`);
|
|
138
|
+
}
|
|
139
|
+
const close = html.indexOf('"', j + 2);
|
|
140
|
+
if (close === -1)
|
|
141
|
+
throw new TemplateParseError(`unterminated value for ${name}`);
|
|
142
|
+
el.setAttribute(name, unescape(html.slice(j + 2, close)));
|
|
143
|
+
j = close + 1;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
el.setAttribute(name, '');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
append(el);
|
|
150
|
+
if (!VOID_ELEMENTS.has(tag))
|
|
151
|
+
stack.push(el);
|
|
152
|
+
return j;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var S=Symbol.for("fluixi.server-node");var A=1,O=3,L=8,T;T=S;var h=class{constructor(){this[T]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let t=this.parentNode;if(!t)return null;let e=t.childNodes.indexOf(this);return e>=0?t.childNodes[e+1]??null:null}get previousSibling(){let t=this.parentNode;if(!t)return null;let e=t.childNodes.indexOf(this);return e>0?t.childNodes[e-1]??null:null}get parentElement(){return this.parentNode}appendChild(t){return t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes.push(t),t}insertBefore(t,e){if(e==null)return this.appendChild(t);t.parentNode&&t.parentNode.removeChild(t);let r=this.childNodes.indexOf(e);return t.parentNode=this,r<0?this.childNodes.push(t):this.childNodes.splice(r,0,t),t}removeChild(t){let e=this.childNodes.indexOf(t);return e>=0&&this.childNodes.splice(e,1),t.parentNode=null,t}replaceChild(t,e){let r=this.childNodes.indexOf(e);return r>=0&&(t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes[r]=t,e.parentNode=null),e}addEventListener(){}removeEventListener(){}},g=class n extends h{constructor(e){super();this.nodeType=O;this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e==null?"":String(e)}get textContent(){return this.data}set textContent(e){this.data=e==null?"":String(e)}cloneNode(){return new n(this.data)}};var f=class n extends h{constructor(e){super();this.nodeType=L;this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e==null?"":String(e)}cloneNode(){return new n(this.data)}},m=class{constructor(){this.cssText=""}setProperty(t,e){this[t]=e}removeProperty(t){delete this[t]}},w=class{constructor(t){this.el=t}list(){let t=this.el.getAttribute("class");return t?t.split(/\s+/).filter(Boolean):[]}write(t){t.length?this.el.setAttribute("class",t.join(" ")):this.el.removeAttribute("class")}add(...t){let e=this.list();for(let r of t)e.includes(r)||e.push(r);this.write(e)}remove(...t){this.write(this.list().filter(e=>!t.includes(e)))}contains(t){return this.list().includes(t)}toggle(t,e){let r=this.contains(t),l=e===void 0?!r:e;return l?this.add(t):this.remove(t),l}},p=class n extends h{constructor(e,r=!1){super();this.nodeType=A;this.attributes=new Map;this.style=new m;this.classList=new w(this);this.rawHTML=null;this.localName=e.toLowerCase(),this.tagName=r?e:e.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(e,r){this.attributes.set(e,String(r))}removeAttribute(e){this.attributes.delete(e)}getAttribute(e){return this.attributes.has(e)?this.attributes.get(e):null}hasAttribute(e){return this.attributes.has(e)}get id(){return this.getAttribute("id")??""}set id(e){e==null?this.removeAttribute("id"):this.setAttribute("id",e)}get className(){return this.getAttribute("class")??""}set className(e){e==null?this.removeAttribute("class"):this.setAttribute("class",e)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(e){e==null?this.removeAttribute("for"):this.setAttribute("for",e)}set value(e){e==null?this.removeAttribute("value"):this.setAttribute("value",String(e))}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(e){e?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(e){}get textContent(){return this.childNodes.map(e=>e.textContent??"").join("")}set textContent(e){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,e!=null&&e!==""&&this.appendChild(new g(String(e)))}set innerText(e){this.textContent=e}set innerHTML(e){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=e==null?"":String(e)}cloneNode(e=!1){let r=new n(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,e)for(let l of this.childNodes)r.appendChild(l.cloneNode(!0));return r}};var M=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),k={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'"};function y(n){return n.replace(/&(#?\w+);/g,(t,e)=>k[e]??t)}var a=class extends Error{};function R(n,t=!1){let e=0,r=[],l=[],N=s=>{let o=l[l.length-1];o?o.appendChild(s):r.push(s)};for(;e<n.length;){let s=n.indexOf("<",e);if(s===-1){x(n.slice(e));break}if(s>e&&x(n.slice(e,s)),n.startsWith("<!--",s)){let o=n.indexOf("-->",s);if(o===-1)throw new a(`unterminated comment at ${s}`);N(new f(n.slice(s+4,o))),e=o+3;continue}if(n[s+1]==="/"){let o=n.indexOf(">",s);if(o===-1)throw new a(`unterminated closing tag at ${s}`);let u=n.slice(s+2,o).trim().toLowerCase(),d=l.pop();if(!d||d.localName!==u)throw new a(`</${u}> does not close <${d?.localName??"nothing"}>`);e=o+1;continue}e=E(s)}if(l.length>0)throw new a(`unclosed <${l[l.length-1].localName}>`);let b=r[0];if(r.length!==1||!(b instanceof p))throw new a(`expected exactly one root element, got ${r.length}`);return b;function x(s){s!==""&&N(new g(y(s)))}function E(s){let o=/[\s/>]/.exec(n.slice(s+1));if(!o)throw new a(`unterminated tag at ${s}`);let u=n.slice(s+1,s+1+o.index).toLowerCase(),d=new p(u,t),i=s+1+o.index;for(;i<n.length;){for(;i<n.length&&/\s/.test(n[i]);)i++;if(n[i]===">"){i++;break}if(n[i]==="/"&&n[i+1]===">"){i+=2;break}let C=i;for(;i<n.length&&!/[\s=/>]/.test(n[i]);)i++;let c=n.slice(C,i);if(c==="")throw new a(`malformed attribute at ${i}`);if(n[i]==="="){if(n[i+1]!=='"')throw new a(`attribute ${c} must have a double-quoted value`);let v=n.indexOf('"',i+2);if(v===-1)throw new a(`unterminated value for ${c}`);d.setAttribute(c,y(n.slice(i+2,v))),i=v+1}else d.setAttribute(c,"")}return N(d),M.has(u)||l.push(d),i}}export{a as TemplateParseError,R as parseTemplate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var B=(n,e)=>{for(var t in e)y(n,t,{get:e[t],enumerable:!0})},G=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of W(e))!J.call(n,s)&&s!==t&&y(n,s,{get:()=>e[s],enumerable:!(r=U(e,s))||r.enumerable});return n};var K=n=>G(y({},"__esModule",{value:!0}),n);var pe={};B(pe,{renderToString:()=>ue,renderToStringAsync:()=>de,serializeResourceData:()=>z,setDataRedactor:()=>le});module.exports=K(pe);var k=require("@fluixi/reactive/signal"),i=require("@fluixi/reactive/signal");var f=typeof document>"u";function c(n){f=n}var _=Symbol.for("fluixi.server-node"),Q=null;function D(n){Q=n}var w=1,R=3,b=8,M;M=_;var d=class{constructor(){this[M]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let e=this.parentNode;if(!e)return null;let t=e.childNodes.indexOf(this);return t>=0?e.childNodes[t+1]??null:null}get previousSibling(){let e=this.parentNode;if(!e)return null;let t=e.childNodes.indexOf(this);return t>0?e.childNodes[t-1]??null:null}get parentElement(){return this.parentNode}appendChild(e){return e.parentNode&&e.parentNode.removeChild(e),e.parentNode=this,this.childNodes.push(e),e}insertBefore(e,t){if(t==null)return this.appendChild(e);e.parentNode&&e.parentNode.removeChild(e);let r=this.childNodes.indexOf(t);return e.parentNode=this,r<0?this.childNodes.push(e):this.childNodes.splice(r,0,e),e}removeChild(e){let t=this.childNodes.indexOf(e);return t>=0&&this.childNodes.splice(t,1),e.parentNode=null,e}replaceChild(e,t){let r=this.childNodes.indexOf(t);return r>=0&&(e.parentNode&&e.parentNode.removeChild(e),e.parentNode=this,this.childNodes[r]=e,t.parentNode=null),t}addEventListener(){}removeEventListener(){}},p=class n extends d{constructor(t){super();this.nodeType=R;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}get textContent(){return this.data}set textContent(t){this.data=t==null?"":String(t)}cloneNode(){return new n(this.data)}},g=class n extends d{constructor(t){super();this.nodeType=b;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}cloneNode(){return new n(this.data)}},S=class{constructor(){this.cssText=""}setProperty(e,t){this[e]=t}removeProperty(e){delete this[e]}},T=class{constructor(e){this.el=e}list(){let e=this.el.getAttribute("class");return e?e.split(/\s+/).filter(Boolean):[]}write(e){e.length?this.el.setAttribute("class",e.join(" ")):this.el.removeAttribute("class")}add(...e){let t=this.list();for(let r of e)t.includes(r)||t.push(r);this.write(t)}remove(...e){this.write(this.list().filter(t=>!e.includes(t)))}contains(e){return this.list().includes(e)}toggle(e,t){let r=this.contains(e),s=t===void 0?!r:t;return s?this.add(e):this.remove(e),s}},h=class n extends d{constructor(t,r=!1){super();this.nodeType=w;this.attributes=new Map;this.style=new S;this.classList=new T(this);this.rawHTML=null;this.localName=t.toLowerCase(),this.tagName=r?t:t.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(t,r){this.attributes.set(t,String(r))}removeAttribute(t){this.attributes.delete(t)}getAttribute(t){return this.attributes.has(t)?this.attributes.get(t):null}hasAttribute(t){return this.attributes.has(t)}get id(){return this.getAttribute("id")??""}set id(t){t==null?this.removeAttribute("id"):this.setAttribute("id",t)}get className(){return this.getAttribute("class")??""}set className(t){t==null?this.removeAttribute("class"):this.setAttribute("class",t)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(t){t==null?this.removeAttribute("for"):this.setAttribute("for",t)}set value(t){t==null?this.removeAttribute("value"):this.setAttribute("value",String(t))}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(t){t?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(t){}get textContent(){return this.childNodes.map(t=>t.textContent??"").join("")}set textContent(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,t!=null&&t!==""&&this.appendChild(new p(String(t)))}set innerText(t){this.textContent=t}set innerHTML(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=t==null?"":String(t)}cloneNode(t=!1){let r=new n(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,t)for(let s of this.childNodes)r.appendChild(s.cloneNode(!0));return r}};var Y=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),L=/&/g,Z=/</g,ee=/>/g,te=/"/g;function E(n){return n.replace(L,"&").replace(Z,"<").replace(ee,">")}function O(n){return n.replace(L,"&").replace(te,""")}function ne(n){return n.startsWith("--")?n:n.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function re(n){if(!n)return"";let e=[];n.cssText&&e.push(n.cssText.trim().replace(/;\s*$/,""));for(let t of Object.keys(n)){if(t==="cssText")continue;let r=n[t];r==null||r===""||e.push(`${ne(t)}: ${r}`)}return e.join("; ")}function se(n){let e="",t=re(n.style);for(let[r,s]of n.attributes)r==="style"&&t||(e+=` ${r}="${O(s)}"`);if(t){let r=n.attributes.get("style"),s=r?`${r.replace(/;\s*$/,"")}; ${t}`:t;e+=` style="${O(s)}"`}return e}function a(n){if(n==null||n===!1||n===!0)return"";if(typeof n=="string")return E(n);if(typeof n=="number")return E(String(n));if(typeof n=="function")return a(n());if(Array.isArray(n))return n.map(a).join("");switch(n.nodeType){case R:return E(n.data??"");case b:return`<!--${n.data??""}-->`;case w:{let e=n.localName,t=`<${e}${se(n)}>`;if(Y.has(e))return t;let r=n.rawHTML!=null?n.rawHTML:(n.childNodes??[]).map(a).join("");return`${t}${r}</${e}>`}}return Array.isArray(n.childNodes)?n.childNodes.map(a).join(""):""}var $="__FX_DATA__";function I(n){return n.replace(/[<>&\u2028\u2029]/g,e=>"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0"))}var m,ie={getStore:()=>m,run(n,e){let t=m;m=n;try{return e()}finally{m=t}}},F=ie;function C(n={}){n.locals||(n.locals=n.request?oe(n.request):{});let e=0,t=0,r=null,s=new Map,o=new Map;return{event:n,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${e++}`,nextResourceId:()=>{if(r===null)return`r${t++}`;let u=s.get(r)??0;return s.set(r,u+1),`${r}:r${u}`},nextIslandNamespace:u=>{let l=o.get(u)??0;return o.set(u,l+1),`${u}#${l}`},withResourceScope(u,l){let v=r;r=u;try{return l()}finally{r=v}},pending:new Set,data:new Map}}function A(n,e){return F.run(n,e)}function N(){return F.getStore()}var j=new WeakMap;function oe(n){let e=j.get(n);return e||(e={},j.set(n,e)),e}var H=!1;function X(){H||(H=!0,D({createElement:(n,e)=>new h(n,e),createText:n=>new p(n),createComment:n=>new g(n)}))}function ue(n,e={}){let t=f;X(),c(!0);let r=C(e.event);try{return A(r,()=>(0,k.createRoot)(s=>{try{let o=typeof n=="function"?n():n;return a(o)}finally{s()}}))}finally{c(t)}}var V=!1;function ae(){V||(V=!0,(0,i.setResourceTracker)(n=>{N()?.pending.add(n)}),(0,i.setResourceIdSource)(()=>N()?.nextResourceId()??""),(0,i.setResourceDataSink)((n,e)=>{n&&N()?.data.set(n,e)}))}var q=null;function le(n){q=n}function z(n){if(n.data.size===0)return"";let e={};for(let[r,s]of n.data){let o=s;if(q)try{o=q(s,r)}catch{continue}o!==void 0&&(e[r]=o)}if(Object.keys(e).length===0)return"";let t=I(JSON.stringify(e));return`<script type="application/json" id="${$}">${t}<\/script>`}var ce=50;async function de(n,e={}){let t=f;X(),c(!0),ae();let r=C(e.event);try{return await A(r,async()=>{e.preload&&await e.preload(e.event);let s,o=null,u=()=>{};(0,k.createRoot)(x=>{u=x,o=(0,i.getOwner)(),s=typeof n=="function"?n():n});let l=()=>{try{(0,i.runWithOwner)(o,()=>a(s))}catch{}};l();let v=0;for(;r.pending.size>0&&v++<ce;){let x=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(x),await(0,i.flush)(),l()}let P=(0,i.runWithOwner)(o,()=>a(s))+z(r);return u(),P})}finally{c(t)}}
|
|
1
|
+
"use strict";var k=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var oe=(e,n)=>{for(var t in n)k(e,t,{get:n[t],enumerable:!0})},ae=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of se(n))!ie.call(e,s)&&s!==t&&k(e,s,{get:()=>n[s],enumerable:!(r=re(n,s))||r.enumerable});return e};var ue=e=>ae(k({},"__esModule",{value:!0}),e);var be={};oe(be,{renderToString:()=>we,renderToStringAsync:()=>Te,serializeResourceData:()=>te,setDataRedactor:()=>Se});module.exports=ue(be);var j=require("@fluixi/reactive/signal"),c=require("@fluixi/reactive/signal");var T=typeof document>"u";function y(e){T=e}var H=Symbol.for("fluixi.server-node"),le=null;function F(e){le=e}var R=1,M=3,_=8,V;V=H;var x=class{constructor(){this[V]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let n=this.parentNode;if(!n)return null;let t=n.childNodes.indexOf(this);return t>=0?n.childNodes[t+1]??null:null}get previousSibling(){let n=this.parentNode;if(!n)return null;let t=n.childNodes.indexOf(this);return t>0?n.childNodes[t-1]??null:null}get parentElement(){return this.parentNode}appendChild(n){return n.parentNode&&n.parentNode.removeChild(n),n.parentNode=this,this.childNodes.push(n),n}insertBefore(n,t){if(t==null)return this.appendChild(n);n.parentNode&&n.parentNode.removeChild(n);let r=this.childNodes.indexOf(t);return n.parentNode=this,r<0?this.childNodes.push(n):this.childNodes.splice(r,0,n),n}removeChild(n){let t=this.childNodes.indexOf(n);return t>=0&&this.childNodes.splice(t,1),n.parentNode=null,n}replaceChild(n,t){let r=this.childNodes.indexOf(t);return r>=0&&(n.parentNode&&n.parentNode.removeChild(n),n.parentNode=this,this.childNodes[r]=n,t.parentNode=null),t}addEventListener(){}removeEventListener(){}},h=class e extends x{constructor(t){super();this.nodeType=M;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}get textContent(){return this.data}set textContent(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},b=class e extends x{constructor(t){super();this.nodeType=R;this.rawOuterHTML=t}get textContent(){return this.rawOuterHTML.replace(/<[^>]*>/g,"")}cloneNode(){return new e(this.rawOuterHTML)}},v=class e extends x{constructor(t){super();this.nodeType=_;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},q=class{constructor(){this.cssText=""}setProperty(n,t){this[n]=t}removeProperty(n){delete this[n]}},O=class{constructor(n){this.el=n}list(){let n=this.el.getAttribute("class");return n?n.split(/\s+/).filter(Boolean):[]}write(n){n.length?this.el.setAttribute("class",n.join(" ")):this.el.removeAttribute("class")}add(...n){let t=this.list();for(let r of n)t.includes(r)||t.push(r);this.write(t)}remove(...n){this.write(this.list().filter(t=>!n.includes(t)))}contains(n){return this.list().includes(n)}toggle(n,t){let r=this.contains(n),s=t===void 0?!r:t;return s?this.add(n):this.remove(n),s}},m=class e extends x{constructor(t,r=!1){super();this.nodeType=R;this.attributes=new Map;this.style=new q;this.classList=new O(this);this.rawHTML=null;this.localName=t.toLowerCase(),this.tagName=r?t:t.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(t,r){this.attributes.set(t,String(r))}removeAttribute(t){this.attributes.delete(t)}getAttribute(t){return this.attributes.has(t)?this.attributes.get(t):null}hasAttribute(t){return this.attributes.has(t)}get id(){return this.getAttribute("id")??""}set id(t){t==null?this.removeAttribute("id"):this.setAttribute("id",t)}get className(){return this.getAttribute("class")??""}set className(t){t==null?this.removeAttribute("class"):this.setAttribute("class",t)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(t){t==null?this.removeAttribute("for"):this.setAttribute("for",t)}set value(t){t==null?this.removeAttribute("value"):this.setAttribute("value",String(t))}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(t){t?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(t){}get textContent(){return this.childNodes.map(t=>t.textContent??"").join("")}set textContent(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,t!=null&&t!==""&&this.appendChild(new h(String(t)))}set innerText(t){this.textContent=t}set innerHTML(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=t==null?"":String(t)}cloneNode(t=!1){let r=new e(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,t)for(let s of this.childNodes)r.appendChild(s.cloneNode(!0));return r}};var ce=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),z=/&/g,P=/</g,W=/>/g,de=/"/g;function L(e){return e.replace(z,"&").replace(P,"<").replace(W,">")}function X(e){return e.replace(z,"&").replace(de,""").replace(P,"<").replace(W,">")}function pe(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}function fe(e){if(!e)return"";let n=[];e.cssText&&n.push(e.cssText.trim().replace(/;\s*$/,""));for(let t of Object.keys(e)){if(t==="cssText")continue;let r=e[t];r==null||r===""||n.push(`${pe(t)}: ${r}`)}return n.join("; ")}function ge(e){let n="",t=fe(e.style);for(let[r,s]of e.attributes)r==="style"&&t||(n+=` ${r}="${X(s)}"`);if(t){let r=e.attributes.get("style"),s=r?`${r.replace(/;\s*$/,"")}; ${t}`:t;n+=` style="${X(s)}"`}return n}function g(e){if(e==null||e===!1||e===!0)return"";if(typeof e=="string")return L(e);if(typeof e=="number")return L(String(e));if(typeof e=="function")return g(e());if(Array.isArray(e))return e.map(g).join("");if(typeof e.rawOuterHTML=="string")return e.rawOuterHTML;switch(e.nodeType){case M:return L(e.data??"");case _:return`<!--${e.data??""}-->`;case R:{let n=e.localName,t=`<${n}${ge(e)}>`;if(ce.has(n))return t;let r=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(g).join("");return`${t}${r}</${n}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(g).join(""):""}var he=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),me={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'"};function U(e){return e.replace(/&(#?\w+);/g,(n,t)=>me[t]??n)}var d=class extends Error{};function G(e,n=!1){let t=0,r=[],s=[],u=i=>{let a=s[s.length-1];a?a.appendChild(i):r.push(i)};for(;t<e.length;){let i=e.indexOf("<",t);if(i===-1){p(e.slice(t));break}if(i>t&&p(e.slice(t,i)),e.startsWith("<!--",i)){let a=e.indexOf("-->",i);if(a===-1)throw new d(`unterminated comment at ${i}`);u(new v(e.slice(i+4,a))),t=a+3;continue}if(e[i+1]==="/"){let a=e.indexOf(">",i);if(a===-1)throw new d(`unterminated closing tag at ${i}`);let N=e.slice(i+2,a).trim().toLowerCase(),f=s.pop();if(!f||f.localName!==N)throw new d(`</${N}> does not close <${f?.localName??"nothing"}>`);t=a+1;continue}t=w(i)}if(s.length>0)throw new d(`unclosed <${s[s.length-1].localName}>`);let l=r[0];if(r.length!==1||!(l instanceof m))throw new d(`expected exactly one root element, got ${r.length}`);return l;function p(i){i!==""&&u(new h(U(i)))}function w(i){let a=/[\s/>]/.exec(e.slice(i+1));if(!a)throw new d(`unterminated tag at ${i}`);let N=e.slice(i+1,i+1+a.index).toLowerCase(),f=new m(N,n),o=i+1+a.index;for(;o<e.length;){for(;o<e.length&&/\s/.test(e[o]);)o++;if(e[o]===">"){o++;break}if(e[o]==="/"&&e[o+1]===">"){o+=2;break}let ne=o;for(;o<e.length&&!/[\s=/>]/.test(e[o]);)o++;let S=e.slice(ne,o);if(S==="")throw new d(`malformed attribute at ${o}`);if(e[o]==="="){if(e[o+1]!=='"')throw new d(`attribute ${S} must have a double-quoted value`);let A=e.indexOf('"',o+2);if(A===-1)throw new d(`unterminated value for ${S}`);f.setAttribute(S,U(e.slice(o+2,A))),o=A+1}else f.setAttribute(S,"")}return u(f),he.has(N)||s.push(f),o}}var J="__FX_DATA__";function B(e){return e.replace(/[<>&\u2028\u2029]/g,n=>"\\u"+n.charCodeAt(0).toString(16).padStart(4,"0"))}var E,xe={getStore:()=>E,run(e,n){let t=E;E=e;try{return n()}finally{E=t}}},Q=xe;function $(e={}){e.locals||(e.locals=e.request?ve(e.request):{});let n=0,t=0,r=null,s=new Map,u=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${n++}`,nextResourceId:()=>{if(r===null)return`r${t++}`;let l=s.get(r)??0;return s.set(r,l+1),`${r}:r${l}`},nextIslandNamespace:l=>{let p=u.get(l)??0;return u.set(l,p+1),`${l}#${p}`},withResourceScope(l,p){let w=r;r=l;try{return p()}finally{r=w}},pending:new Set,data:new Map}}function D(e,n){return Q.run(e,n)}function C(){return Q.getStore()}var K=new WeakMap;function ve(e){let n=K.get(e);return n||(n={},K.set(e,n)),n}var Y=!1;function ee(){Y||(Y=!0,F({createElement:(e,n)=>new m(e,n),createText:e=>new h(e),createRaw:e=>new b(e),parseTemplate:(e,n)=>G(e,n),createComment:e=>new v(e)}))}function we(e,n={}){let t=T;ee(),y(!0);let r=$(n.event);try{return D(r,()=>(0,j.createRoot)(s=>{try{let u=typeof e=="function"?e():e;return g(u)}finally{s()}}))}finally{y(t)}}var Z=!1;function Ne(){Z||(Z=!0,(0,c.setResourceTracker)(e=>{C()?.pending.add(e)}),(0,c.setResourceIdSource)(()=>C()?.nextResourceId()??""),(0,c.setResourceDataSink)((e,n)=>{e&&C()?.data.set(e,n)}))}var I=null;function Se(e){I=e}function te(e){if(e.data.size===0)return"";let n={};for(let[r,s]of e.data){let u=s;if(I)try{u=I(s,r)}catch{continue}u!==void 0&&(n[r]=u)}if(Object.keys(n).length===0)return"";let t=B(JSON.stringify(n));return`<script type="application/json" id="${J}">${t}<\/script>`}var ye=50;async function Te(e,n={}){let t=T;ee(),y(!0),Ne();let r=$(n.event);try{return await D(r,async()=>{n.preload&&await n.preload(n.event);let s,u=null,l=()=>{};(0,j.createRoot)(a=>{l=a,u=(0,c.getOwner)(),s=typeof e=="function"?e():e});let p=()=>{try{(0,c.runWithOwner)(u,()=>g(s))}catch{}};p();let w=0;for(;r.pending.size>0&&w++<ye;){let a=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(a),await(0,c.flush)(),p()}let i=(0,c.runWithOwner)(u,()=>g(s))+te(r);return l(),i})}finally{y(t)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/render.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/render.ts"],"names":[],"mappings":"AAqCA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAmBlF;AAqBD;;;;;;;;;;;;;;GAcG;AACH,KAAK,YAAY,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;AAE5D,wBAAgB,eAAe,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,GAAG,IAAI,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,CAsBjE;AAKD,oFAAoF;AAEpF;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,GAAG,EACd,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAyDjB"}
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
import { createRoot } from '@fluixi/reactive/signal';
|
|
9
9
|
import { setResourceTracker, setResourceIdSource, setResourceDataSink, getOwner, runWithOwner, flush, } from '@fluixi/reactive/signal';
|
|
10
10
|
import { isServer, setServerMode, registerServerNodes } from './host.js';
|
|
11
|
-
import { ServerElement, ServerText, ServerComment } from './nodes.js';
|
|
11
|
+
import { ServerElement, ServerText, ServerRaw, ServerComment } from './nodes.js';
|
|
12
12
|
import { serializeNode } from './serialize.js';
|
|
13
|
+
import { parseTemplate } from './parse-template.js';
|
|
13
14
|
// Register the node classes with the runtime seam on first render. Done from here
|
|
14
15
|
// (not the client barrel) so the classes only load on the server.
|
|
15
16
|
let _nodesRegistered = false;
|
|
@@ -20,6 +21,8 @@ function ensureServerNodes() {
|
|
|
20
21
|
registerServerNodes({
|
|
21
22
|
createElement: (tag, isSVG) => new ServerElement(tag, isSVG),
|
|
22
23
|
createText: (value) => new ServerText(value),
|
|
24
|
+
createRaw: (html) => new ServerRaw(html),
|
|
25
|
+
parseTemplate: (html, isSVG) => parseTemplate(html, isSVG),
|
|
23
26
|
createComment: (value) => new ServerComment(value),
|
|
24
27
|
});
|
|
25
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRoot as
|
|
1
|
+
import{createRoot as Y}from"@fluixi/reactive/signal";import{setResourceTracker as de,setResourceIdSource as pe,setResourceDataSink as fe,getOwner as ge,runWithOwner as B,flush as he}from"@fluixi/reactive/signal";var y=typeof document>"u";function S(e){y=e}var D=Symbol.for("fluixi.server-node"),te=null;function I(e){te=e}var b=1,q=3,O=8,j;j=D;var m=class{constructor(){this[j]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let n=this.parentNode;if(!n)return null;let t=n.childNodes.indexOf(this);return t>=0?n.childNodes[t+1]??null:null}get previousSibling(){let n=this.parentNode;if(!n)return null;let t=n.childNodes.indexOf(this);return t>0?n.childNodes[t-1]??null:null}get parentElement(){return this.parentNode}appendChild(n){return n.parentNode&&n.parentNode.removeChild(n),n.parentNode=this,this.childNodes.push(n),n}insertBefore(n,t){if(t==null)return this.appendChild(n);n.parentNode&&n.parentNode.removeChild(n);let r=this.childNodes.indexOf(t);return n.parentNode=this,r<0?this.childNodes.push(n):this.childNodes.splice(r,0,n),n}removeChild(n){let t=this.childNodes.indexOf(n);return t>=0&&this.childNodes.splice(t,1),n.parentNode=null,n}replaceChild(n,t){let r=this.childNodes.indexOf(t);return r>=0&&(n.parentNode&&n.parentNode.removeChild(n),n.parentNode=this,this.childNodes[r]=n,t.parentNode=null),t}addEventListener(){}removeEventListener(){}},g=class e extends m{constructor(t){super();this.nodeType=q;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}get textContent(){return this.data}set textContent(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},T=class e extends m{constructor(t){super();this.nodeType=b;this.rawOuterHTML=t}get textContent(){return this.rawOuterHTML.replace(/<[^>]*>/g,"")}cloneNode(){return new e(this.rawOuterHTML)}},x=class e extends m{constructor(t){super();this.nodeType=O;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},A=class{constructor(){this.cssText=""}setProperty(n,t){this[n]=t}removeProperty(n){delete this[n]}},k=class{constructor(n){this.el=n}list(){let n=this.el.getAttribute("class");return n?n.split(/\s+/).filter(Boolean):[]}write(n){n.length?this.el.setAttribute("class",n.join(" ")):this.el.removeAttribute("class")}add(...n){let t=this.list();for(let r of n)t.includes(r)||t.push(r);this.write(t)}remove(...n){this.write(this.list().filter(t=>!n.includes(t)))}contains(n){return this.list().includes(n)}toggle(n,t){let r=this.contains(n),s=t===void 0?!r:t;return s?this.add(n):this.remove(n),s}},h=class e extends m{constructor(t,r=!1){super();this.nodeType=b;this.attributes=new Map;this.style=new A;this.classList=new k(this);this.rawHTML=null;this.localName=t.toLowerCase(),this.tagName=r?t:t.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(t,r){this.attributes.set(t,String(r))}removeAttribute(t){this.attributes.delete(t)}getAttribute(t){return this.attributes.has(t)?this.attributes.get(t):null}hasAttribute(t){return this.attributes.has(t)}get id(){return this.getAttribute("id")??""}set id(t){t==null?this.removeAttribute("id"):this.setAttribute("id",t)}get className(){return this.getAttribute("class")??""}set className(t){t==null?this.removeAttribute("class"):this.setAttribute("class",t)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(t){t==null?this.removeAttribute("for"):this.setAttribute("for",t)}set value(t){t==null?this.removeAttribute("value"):this.setAttribute("value",String(t))}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(t){t?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(t){}get textContent(){return this.childNodes.map(t=>t.textContent??"").join("")}set textContent(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,t!=null&&t!==""&&this.appendChild(new g(String(t)))}set innerText(t){this.textContent=t}set innerHTML(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=t==null?"":String(t)}cloneNode(t=!1){let r=new e(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,t)for(let s of this.childNodes)r.appendChild(s.cloneNode(!0));return r}};var ne=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),F=/&/g,V=/</g,X=/>/g,re=/"/g;function M(e){return e.replace(F,"&").replace(V,"<").replace(X,">")}function H(e){return e.replace(F,"&").replace(re,""").replace(V,"<").replace(X,">")}function se(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}function ie(e){if(!e)return"";let n=[];e.cssText&&n.push(e.cssText.trim().replace(/;\s*$/,""));for(let t of Object.keys(e)){if(t==="cssText")continue;let r=e[t];r==null||r===""||n.push(`${se(t)}: ${r}`)}return n.join("; ")}function oe(e){let n="",t=ie(e.style);for(let[r,s]of e.attributes)r==="style"&&t||(n+=` ${r}="${H(s)}"`);if(t){let r=e.attributes.get("style"),s=r?`${r.replace(/;\s*$/,"")}; ${t}`:t;n+=` style="${H(s)}"`}return n}function f(e){if(e==null||e===!1||e===!0)return"";if(typeof e=="string")return M(e);if(typeof e=="number")return M(String(e));if(typeof e=="function")return f(e());if(Array.isArray(e))return e.map(f).join("");if(typeof e.rawOuterHTML=="string")return e.rawOuterHTML;switch(e.nodeType){case q:return M(e.data??"");case O:return`<!--${e.data??""}-->`;case b:{let n=e.localName,t=`<${n}${oe(e)}>`;if(ne.has(n))return t;let r=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(f).join("");return`${t}${r}</${n}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(f).join(""):""}var ae=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ue={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'"};function z(e){return e.replace(/&(#?\w+);/g,(n,t)=>ue[t]??n)}var c=class extends Error{};function P(e,n=!1){let t=0,r=[],s=[],u=i=>{let a=s[s.length-1];a?a.appendChild(i):r.push(i)};for(;t<e.length;){let i=e.indexOf("<",t);if(i===-1){d(e.slice(t));break}if(i>t&&d(e.slice(t,i)),e.startsWith("<!--",i)){let a=e.indexOf("-->",i);if(a===-1)throw new c(`unterminated comment at ${i}`);u(new x(e.slice(i+4,a))),t=a+3;continue}if(e[i+1]==="/"){let a=e.indexOf(">",i);if(a===-1)throw new c(`unterminated closing tag at ${i}`);let w=e.slice(i+2,a).trim().toLowerCase(),p=s.pop();if(!p||p.localName!==w)throw new c(`</${w}> does not close <${p?.localName??"nothing"}>`);t=a+1;continue}t=v(i)}if(s.length>0)throw new c(`unclosed <${s[s.length-1].localName}>`);let l=r[0];if(r.length!==1||!(l instanceof h))throw new c(`expected exactly one root element, got ${r.length}`);return l;function d(i){i!==""&&u(new g(z(i)))}function v(i){let a=/[\s/>]/.exec(e.slice(i+1));if(!a)throw new c(`unterminated tag at ${i}`);let w=e.slice(i+1,i+1+a.index).toLowerCase(),p=new h(w,n),o=i+1+a.index;for(;o<e.length;){for(;o<e.length&&/\s/.test(e[o]);)o++;if(e[o]===">"){o++;break}if(e[o]==="/"&&e[o+1]===">"){o+=2;break}let ee=o;for(;o<e.length&&!/[\s=/>]/.test(e[o]);)o++;let N=e.slice(ee,o);if(N==="")throw new c(`malformed attribute at ${o}`);if(e[o]==="="){if(e[o+1]!=='"')throw new c(`attribute ${N} must have a double-quoted value`);let C=e.indexOf('"',o+2);if(C===-1)throw new c(`unterminated value for ${N}`);p.setAttribute(N,z(e.slice(o+2,C))),o=C+1}else p.setAttribute(N,"")}return u(p),ae.has(w)||s.push(p),o}}var W="__FX_DATA__";function U(e){return e.replace(/[<>&\u2028\u2029]/g,n=>"\\u"+n.charCodeAt(0).toString(16).padStart(4,"0"))}var R,le={getStore:()=>R,run(e,n){let t=R;R=e;try{return n()}finally{R=t}}},J=le;function _(e={}){e.locals||(e.locals=e.request?ce(e.request):{});let n=0,t=0,r=null,s=new Map,u=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${n++}`,nextResourceId:()=>{if(r===null)return`r${t++}`;let l=s.get(r)??0;return s.set(r,l+1),`${r}:r${l}`},nextIslandNamespace:l=>{let d=u.get(l)??0;return u.set(l,d+1),`${l}#${d}`},withResourceScope(l,d){let v=r;r=l;try{return d()}finally{r=v}},pending:new Set,data:new Map}}function L(e,n){return J.run(e,n)}function E(){return J.getStore()}var G=new WeakMap;function ce(e){let n=G.get(e);return n||(n={},G.set(e,n)),n}var K=!1;function Z(){K||(K=!0,I({createElement:(e,n)=>new h(e,n),createText:e=>new g(e),createRaw:e=>new T(e),parseTemplate:(e,n)=>P(e,n),createComment:e=>new x(e)}))}function Ie(e,n={}){let t=y;Z(),S(!0);let r=_(n.event);try{return L(r,()=>Y(s=>{try{let u=typeof e=="function"?e():e;return f(u)}finally{s()}}))}finally{S(t)}}var Q=!1;function me(){Q||(Q=!0,de(e=>{E()?.pending.add(e)}),pe(()=>E()?.nextResourceId()??""),fe((e,n)=>{e&&E()?.data.set(e,n)}))}var $=null;function je(e){$=e}function xe(e){if(e.data.size===0)return"";let n={};for(let[r,s]of e.data){let u=s;if($)try{u=$(s,r)}catch{continue}u!==void 0&&(n[r]=u)}if(Object.keys(n).length===0)return"";let t=U(JSON.stringify(n));return`<script type="application/json" id="${W}">${t}<\/script>`}var ve=50;async function He(e,n={}){let t=y;Z(),S(!0),me();let r=_(n.event);try{return await L(r,async()=>{n.preload&&await n.preload(n.event);let s,u=null,l=()=>{};Y(a=>{l=a,u=ge(),s=typeof e=="function"?e():e});let d=()=>{try{B(u,()=>f(s))}catch{}};d();let v=0;for(;r.pending.size>0&&v++<ve;){let a=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(a),await he(),d()}let i=B(u,()=>f(s))+xe(r);return l(),i})}finally{S(t)}}export{Ie as renderToString,He as renderToStringAsync,xe as serializeResourceData,je as setDataRedactor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var b=(t,e)=>{for(var r in e)o(t,r,{get:e[r],enumerable:!0})},x=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of T(e))!y.call(t,s)&&s!==r&&o(t,s,{get:()=>e[s],enumerable:!(n=v(e,s))||n.enumerable});return t};var S=t=>x(o({},"__esModule",{value:!0}),t);var O={};b(O,{serializeNode:()=>i});module.exports=S(O);var a=Symbol.for("fluixi.server-node");var c=1,h=3,p=8,d;d=a;var u=class{constructor(){this[d]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let e=this.parentNode;if(!e)return null;let r=e.childNodes.indexOf(this);return r>=0?e.childNodes[r+1]??null:null}get previousSibling(){let e=this.parentNode;if(!e)return null;let r=e.childNodes.indexOf(this);return r>0?e.childNodes[r-1]??null:null}get parentElement(){return this.parentNode}appendChild(e){return e.parentNode&&e.parentNode.removeChild(e),e.parentNode=this,this.childNodes.push(e),e}insertBefore(e,r){if(r==null)return this.appendChild(e);e.parentNode&&e.parentNode.removeChild(e);let n=this.childNodes.indexOf(r);return e.parentNode=this,n<0?this.childNodes.push(e):this.childNodes.splice(n,0,e),e}removeChild(e){let r=this.childNodes.indexOf(e);return r>=0&&this.childNodes.splice(r,1),e.parentNode=null,e}replaceChild(e,r){let n=this.childNodes.indexOf(r);return n>=0&&(e.parentNode&&e.parentNode.removeChild(e),e.parentNode=this,this.childNodes[n]=e,r.parentNode=null),r}addEventListener(){}removeEventListener(){}};var w=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),f=/&/g,N=/</g,m=/>/g,E=/"/g;function l(t){return t.replace(f,"&").replace(N,"<").replace(m,">")}function g(t){return t.replace(f,"&").replace(E,""").replace(N,"<").replace(m,">")}function A(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function M(t){if(!t)return"";let e=[];t.cssText&&e.push(t.cssText.trim().replace(/;\s*$/,""));for(let r of Object.keys(t)){if(r==="cssText")continue;let n=t[r];n==null||n===""||e.push(`${A(r)}: ${n}`)}return e.join("; ")}function C(t){let e="",r=M(t.style);for(let[n,s]of t.attributes)n==="style"&&r||(e+=` ${n}="${g(s)}"`);if(r){let n=t.attributes.get("style"),s=n?`${n.replace(/;\s*$/,"")}; ${r}`:r;e+=` style="${g(s)}"`}return e}function i(t){if(t==null||t===!1||t===!0)return"";if(typeof t=="string")return l(t);if(typeof t=="number")return l(String(t));if(typeof t=="function")return i(t());if(Array.isArray(t))return t.map(i).join("");if(typeof t.rawOuterHTML=="string")return t.rawOuterHTML;switch(t.nodeType){case h:return l(t.data??"");case p:return`<!--${t.data??""}-->`;case c:{let e=t.localName,r=`<${e}${C(t)}>`;if(w.has(e))return r;let n=t.rawHTML!=null?t.rawHTML:(t.childNodes??[]).map(i).join("");return`${r}${n}</${e}>`}}return Array.isArray(t.childNodes)?t.childNodes.map(i).join(""):""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/serialize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/serialize.ts"],"names":[],"mappings":"AAmEA,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAsC/C"}
|
|
@@ -16,7 +16,14 @@ function escapeText(s) {
|
|
|
16
16
|
return s.replace(AMP, '&').replace(LT, '<').replace(GT, '>');
|
|
17
17
|
}
|
|
18
18
|
function escapeAttr(s) {
|
|
19
|
-
|
|
19
|
+
// `<` and `>` are escaped too. Not strictly required inside a quoted value, but it
|
|
20
|
+
// keeps this identical to the compiler's template serializer, so markup produced by
|
|
21
|
+
// either side round-trips through the other unchanged.
|
|
22
|
+
return s
|
|
23
|
+
.replace(AMP, '&')
|
|
24
|
+
.replace(QUOT, '"')
|
|
25
|
+
.replace(LT, '<')
|
|
26
|
+
.replace(GT, '>');
|
|
20
27
|
}
|
|
21
28
|
function camelToKebab(k) {
|
|
22
29
|
// leave custom props (--var) and already-kebab keys alone
|
|
@@ -71,6 +78,9 @@ export function serializeNode(node) {
|
|
|
71
78
|
return serializeNode(node());
|
|
72
79
|
if (Array.isArray(node))
|
|
73
80
|
return node.map(serializeNode).join('');
|
|
81
|
+
// A template subtree carried as text — written out untouched.
|
|
82
|
+
if (typeof node.rawOuterHTML === 'string')
|
|
83
|
+
return node.rawOuterHTML;
|
|
74
84
|
// Duck-type on nodeType rather than `instanceof`: a node can come from a
|
|
75
85
|
// different bundled copy of @fluixi/dom (separate package entry points), so
|
|
76
86
|
// class identity is unreliable across the renderToString boundary.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var l=Symbol.for("fluixi.server-node");var d=1,c=3,h=8,u;u=l;var a=class{constructor(){this[u]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let e=this.parentNode;if(!e)return null;let r=e.childNodes.indexOf(this);return r>=0?e.childNodes[r+1]??null:null}get previousSibling(){let e=this.parentNode;if(!e)return null;let r=e.childNodes.indexOf(this);return r>0?e.childNodes[r-1]??null:null}get parentElement(){return this.parentNode}appendChild(e){return e.parentNode&&e.parentNode.removeChild(e),e.parentNode=this,this.childNodes.push(e),e}insertBefore(e,r){if(r==null)return this.appendChild(e);e.parentNode&&e.parentNode.removeChild(e);let n=this.childNodes.indexOf(r);return e.parentNode=this,n<0?this.childNodes.push(e):this.childNodes.splice(n,0,e),e}removeChild(e){let r=this.childNodes.indexOf(e);return r>=0&&this.childNodes.splice(r,1),e.parentNode=null,e}replaceChild(e,r){let n=this.childNodes.indexOf(r);return n>=0&&(e.parentNode&&e.parentNode.removeChild(e),e.parentNode=this,this.childNodes[n]=e,r.parentNode=null),r}addEventListener(){}removeEventListener(){}};var
|
|
1
|
+
var l=Symbol.for("fluixi.server-node");var d=1,c=3,h=8,u;u=l;var a=class{constructor(){this[u]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let e=this.parentNode;if(!e)return null;let r=e.childNodes.indexOf(this);return r>=0?e.childNodes[r+1]??null:null}get previousSibling(){let e=this.parentNode;if(!e)return null;let r=e.childNodes.indexOf(this);return r>0?e.childNodes[r-1]??null:null}get parentElement(){return this.parentNode}appendChild(e){return e.parentNode&&e.parentNode.removeChild(e),e.parentNode=this,this.childNodes.push(e),e}insertBefore(e,r){if(r==null)return this.appendChild(e);e.parentNode&&e.parentNode.removeChild(e);let n=this.childNodes.indexOf(r);return e.parentNode=this,n<0?this.childNodes.push(e):this.childNodes.splice(n,0,e),e}removeChild(e){let r=this.childNodes.indexOf(e);return r>=0&&this.childNodes.splice(r,1),e.parentNode=null,e}replaceChild(e,r){let n=this.childNodes.indexOf(r);return n>=0&&(e.parentNode&&e.parentNode.removeChild(e),e.parentNode=this,this.childNodes[n]=e,r.parentNode=null),r}addEventListener(){}removeEventListener(){}};var m=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),g=/&/g,f=/</g,N=/>/g,v=/"/g;function o(t){return t.replace(g,"&").replace(f,"<").replace(N,">")}function p(t){return t.replace(g,"&").replace(v,""").replace(f,"<").replace(N,">")}function T(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function y(t){if(!t)return"";let e=[];t.cssText&&e.push(t.cssText.trim().replace(/;\s*$/,""));for(let r of Object.keys(t)){if(r==="cssText")continue;let n=t[r];n==null||n===""||e.push(`${T(r)}: ${n}`)}return e.join("; ")}function b(t){let e="",r=y(t.style);for(let[n,i]of t.attributes)n==="style"&&r||(e+=` ${n}="${p(i)}"`);if(r){let n=t.attributes.get("style"),i=n?`${n.replace(/;\s*$/,"")}; ${r}`:r;e+=` style="${p(i)}"`}return e}function s(t){if(t==null||t===!1||t===!0)return"";if(typeof t=="string")return o(t);if(typeof t=="number")return o(String(t));if(typeof t=="function")return s(t());if(Array.isArray(t))return t.map(s).join("");if(typeof t.rawOuterHTML=="string")return t.rawOuterHTML;switch(t.nodeType){case c:return o(t.data??"");case h:return`<!--${t.data??""}-->`;case d:{let e=t.localName,r=`<${e}${b(t)}>`;if(m.has(e))return r;let n=t.rawHTML!=null?t.rawHTML:(t.childNodes??[]).map(s).join("");return`${r}${n}</${e}>`}}return Array.isArray(t.childNodes)?t.childNodes.map(s).join(""):""}export{s as serializeNode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var b=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var r in t)b(e,r,{get:t[r],enumerable:!0})},le=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ie(t))!ue.call(e,s)&&s!==r&&b(e,s,{get:()=>t[s],enumerable:!(n=oe(t,s))||n.enumerable});return e};var ce=e=>le(b({},"__esModule",{value:!0}),e);var Se={};ae(Se,{FX_DATA_ID:()=>v,ServerComment:()=>h,ServerElement:()=>m,ServerNode:()=>l,ServerText:()=>p,createRequestContext:()=>N,escapeFxJson:()=>S,getLocals:()=>Q,getRequestContext:()=>f,getRequestEvent:()=>O,getRequestLocals:()=>L,getServerData:()=>U,isDomElement:()=>H,isDomNode:()=>V,isDomText:()=>z,isServer:()=>g,isServerNodeValue:()=>P,renderToString:()=>te,renderToStringAsync:()=>ne,runWithRequestContext:()=>y,serializeNode:()=>a,serializeResourceData:()=>F,setDataRedactor:()=>re,setRequestStore:()=>K,setServerMode:()=>d});module.exports=ce(Se);var g=typeof document>"u";function d(e){g=e}var x=Symbol.for("fluixi.server-node"),de=null;function j(e){de=e}function V(e){return e!=null&&e[x]===!0?!0:typeof Node<"u"&&e instanceof Node}function H(e){return e!=null&&e[x]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function z(e){return e!=null&&e[x]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var q=1,A=3,D=8,X;X=x;var l=class{constructor(){this[X]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let t=this.parentNode;if(!t)return null;let r=t.childNodes.indexOf(this);return r>=0?t.childNodes[r+1]??null:null}get previousSibling(){let t=this.parentNode;if(!t)return null;let r=t.childNodes.indexOf(this);return r>0?t.childNodes[r-1]??null:null}get parentElement(){return this.parentNode}appendChild(t){return t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes.push(t),t}insertBefore(t,r){if(r==null)return this.appendChild(t);t.parentNode&&t.parentNode.removeChild(t);let n=this.childNodes.indexOf(r);return t.parentNode=this,n<0?this.childNodes.push(t):this.childNodes.splice(n,0,t),t}removeChild(t){let r=this.childNodes.indexOf(t);return r>=0&&this.childNodes.splice(r,1),t.parentNode=null,t}replaceChild(t,r){let n=this.childNodes.indexOf(r);return n>=0&&(t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes[n]=t,r.parentNode=null),r}addEventListener(){}removeEventListener(){}},p=class e extends l{constructor(r){super();this.nodeType=A;this.data=r}get nodeValue(){return this.data}set nodeValue(r){this.data=r==null?"":String(r)}get textContent(){return this.data}set textContent(r){this.data=r==null?"":String(r)}cloneNode(){return new e(this.data)}},h=class e extends l{constructor(r){super();this.nodeType=D;this.data=r}get nodeValue(){return this.data}set nodeValue(r){this.data=r==null?"":String(r)}cloneNode(){return new e(this.data)}},E=class{constructor(){this.cssText=""}setProperty(t,r){this[t]=r}removeProperty(t){delete this[t]}},C=class{constructor(t){this.el=t}list(){let t=this.el.getAttribute("class");return t?t.split(/\s+/).filter(Boolean):[]}write(t){t.length?this.el.setAttribute("class",t.join(" ")):this.el.removeAttribute("class")}add(...t){let r=this.list();for(let n of t)r.includes(n)||r.push(n);this.write(r)}remove(...t){this.write(this.list().filter(r=>!t.includes(r)))}contains(t){return this.list().includes(t)}toggle(t,r){let n=this.contains(t),s=r===void 0?!n:r;return s?this.add(t):this.remove(t),s}},m=class e extends l{constructor(r,n=!1){super();this.nodeType=q;this.attributes=new Map;this.style=new E;this.classList=new C(this);this.rawHTML=null;this.localName=r.toLowerCase(),this.tagName=n?r:r.toUpperCase(),this.isSVG=n,this.namespaceURI=n?"http://www.w3.org/2000/svg":null}setAttribute(r,n){this.attributes.set(r,String(n))}removeAttribute(r){this.attributes.delete(r)}getAttribute(r){return this.attributes.has(r)?this.attributes.get(r):null}hasAttribute(r){return this.attributes.has(r)}get id(){return this.getAttribute("id")??""}set id(r){r==null?this.removeAttribute("id"):this.setAttribute("id",r)}get className(){return this.getAttribute("class")??""}set className(r){r==null?this.removeAttribute("class"):this.setAttribute("class",r)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(r){r==null?this.removeAttribute("for"):this.setAttribute("for",r)}set value(r){r==null?this.removeAttribute("value"):this.setAttribute("value",String(r))}set checked(r){r?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(r){r?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(r){}get textContent(){return this.childNodes.map(r=>r.textContent??"").join("")}set textContent(r){for(let n of this.childNodes)n.parentNode=null;this.childNodes=[],this.rawHTML=null,r!=null&&r!==""&&this.appendChild(new p(String(r)))}set innerText(r){this.textContent=r}set innerHTML(r){for(let n of this.childNodes)n.parentNode=null;this.childNodes=[],this.rawHTML=r==null?"":String(r)}cloneNode(r=!1){let n=new e(this.localName,this.isSVG);if(n.attributes=new Map(this.attributes),n.style.cssText=this.style.cssText,n.rawHTML=this.rawHTML,r)for(let s of this.childNodes)n.appendChild(s.cloneNode(!0));return n}};function P(e){return e instanceof l}var pe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),J=/&/g,fe=/</g,ge=/>/g,he=/"/g;function _(e){return e.replace(J,"&").replace(fe,"<").replace(ge,">")}function W(e){return e.replace(J,"&").replace(he,""")}function me(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function xe(e){if(!e)return"";let t=[];e.cssText&&t.push(e.cssText.trim().replace(/;\s*$/,""));for(let r of Object.keys(e)){if(r==="cssText")continue;let n=e[r];n==null||n===""||t.push(`${me(r)}: ${n}`)}return t.join("; ")}function ve(e){let t="",r=xe(e.style);for(let[n,s]of e.attributes)n==="style"&&r||(t+=` ${n}="${W(s)}"`);if(r){let n=e.attributes.get("style"),s=n?`${n.replace(/;\s*$/,"")}; ${r}`:r;t+=` style="${W(s)}"`}return t}function a(e){if(e==null||e===!1||e===!0)return"";if(typeof e=="string")return _(e);if(typeof e=="number")return _(String(e));if(typeof e=="function")return a(e());if(Array.isArray(e))return e.map(a).join("");switch(e.nodeType){case A:return _(e.data??"");case D:return`<!--${e.data??""}-->`;case q:{let t=e.localName,r=`<${t}${ve(e)}>`;if(pe.has(t))return r;let n=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(a).join("");return`${r}${n}</${t}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(a).join(""):""}var v="__FX_DATA__";function S(e){return e.replace(/[<>&\u2028\u2029]/g,t=>"\\u"+t.charCodeAt(0).toString(16).padStart(4,"0"))}var k;function U(){let e=globalThis.__FX_DATA__;if(e)return e;if(k!==void 0)return k;let t=null;if(typeof document<"u"){let r=document.getElementById(v)?.textContent;if(r)try{t=JSON.parse(r)}catch{t=null}}return k=t}var I=require("@fluixi/reactive/signal"),o=require("@fluixi/reactive/signal");var R,G={getStore:()=>R,run(e,t){let r=R;R=e;try{return t()}finally{R=r}}},M=G;function K(e){M=e??G}function N(e={}){e.locals||(e.locals=e.request?L(e.request):{});let t=0,r=0,n=null,s=new Map,i=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${t++}`,nextResourceId:()=>{if(n===null)return`r${r++}`;let u=s.get(n)??0;return s.set(n,u+1),`${n}:r${u}`},nextIslandNamespace:u=>{let c=i.get(u)??0;return i.set(u,c+1),`${u}#${c}`},withResourceScope(u,c){let T=n;n=u;try{return c()}finally{n=T}},pending:new Set,data:new Map}}function y(e,t){return M.run(e,t)}function f(){return M.getStore()}function O(){return f()?.event}function Q(){let e=O();return e?(e.locals||(e.locals={}),e.locals):{}}var B=new WeakMap;function L(e){let t=B.get(e);return t||(t={},B.set(e,t)),t}var Y=!1;function ee(){Y||(Y=!0,j({createElement:(e,t)=>new m(e,t),createText:e=>new p(e),createComment:e=>new h(e)}))}function te(e,t={}){let r=g;ee(),d(!0);let n=N(t.event);try{return y(n,()=>(0,I.createRoot)(s=>{try{let i=typeof e=="function"?e():e;return a(i)}finally{s()}}))}finally{d(r)}}var Z=!1;function Ne(){Z||(Z=!0,(0,o.setResourceTracker)(e=>{f()?.pending.add(e)}),(0,o.setResourceIdSource)(()=>f()?.nextResourceId()??""),(0,o.setResourceDataSink)((e,t)=>{e&&f()?.data.set(e,t)}))}var $=null;function re(e){$=e}function F(e){if(e.data.size===0)return"";let t={};for(let[n,s]of e.data){let i=s;if($)try{i=$(s,n)}catch{continue}i!==void 0&&(t[n]=i)}if(Object.keys(t).length===0)return"";let r=S(JSON.stringify(t));return`<script type="application/json" id="${v}">${r}<\/script>`}var ye=50;async function ne(e,t={}){let r=g;ee(),d(!0),Ne();let n=N(t.event);try{return await y(n,async()=>{t.preload&&await t.preload(t.event);let s,i=null,u=()=>{};(0,I.createRoot)(w=>{u=w,i=(0,o.getOwner)(),s=typeof e=="function"?e():e});let c=()=>{try{(0,o.runWithOwner)(i,()=>a(s))}catch{}};c();let T=0;for(;n.pending.size>0&&T++<ye;){let w=Array.from(n.pending);n.pending.clear(),await Promise.allSettled(w),await(0,o.flush)(),c()}let se=(0,o.runWithOwner)(i,()=>a(s))+F(n);return u(),se})}finally{d(r)}}
|
|
1
|
+
"use strict";var _=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var we=(e,n)=>{for(var t in n)_(e,t,{get:n[t],enumerable:!0})},Se=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of ve(n))!Ne.call(e,s)&&s!==t&&_(e,s,{get:()=>n[s],enumerable:!(r=xe(n,s))||r.enumerable});return e};var ye=e=>Se(_({},"__esModule",{value:!0}),e);var Me={};we(Me,{FX_DATA_ID:()=>E,ServerComment:()=>v,ServerElement:()=>m,ServerNode:()=>g,ServerText:()=>h,createRequestContext:()=>C,escapeFxJson:()=>O,getLocals:()=>le,getRequestContext:()=>w,getRequestEvent:()=>z,getRequestLocals:()=>X,getServerData:()=>re,isDomElement:()=>B,isDomNode:()=>G,isDomText:()=>K,isServer:()=>S,isServerNodeValue:()=>Y,renderToString:()=>fe,renderToStringAsync:()=>he,runWithRequestContext:()=>q,serializeNode:()=>f,serializeResourceData:()=>J,setDataRedactor:()=>ge,setRequestStore:()=>ue,setServerMode:()=>N});module.exports=ye(Me);var S=typeof document>"u";function N(e){S=e}var b=Symbol.for("fluixi.server-node"),Te=null;function U(e){Te=e}function G(e){return e!=null&&e[b]===!0?!0:typeof Node<"u"&&e instanceof Node}function B(e){return e!=null&&e[b]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function K(e){return e!=null&&e[b]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var k=1,I=3,j=8,Q;Q=b;var g=class{constructor(){this[Q]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let n=this.parentNode;if(!n)return null;let t=n.childNodes.indexOf(this);return t>=0?n.childNodes[t+1]??null:null}get previousSibling(){let n=this.parentNode;if(!n)return null;let t=n.childNodes.indexOf(this);return t>0?n.childNodes[t-1]??null:null}get parentElement(){return this.parentNode}appendChild(n){return n.parentNode&&n.parentNode.removeChild(n),n.parentNode=this,this.childNodes.push(n),n}insertBefore(n,t){if(t==null)return this.appendChild(n);n.parentNode&&n.parentNode.removeChild(n);let r=this.childNodes.indexOf(t);return n.parentNode=this,r<0?this.childNodes.push(n):this.childNodes.splice(r,0,n),n}removeChild(n){let t=this.childNodes.indexOf(n);return t>=0&&this.childNodes.splice(t,1),n.parentNode=null,n}replaceChild(n,t){let r=this.childNodes.indexOf(t);return r>=0&&(n.parentNode&&n.parentNode.removeChild(n),n.parentNode=this,this.childNodes[r]=n,t.parentNode=null),t}addEventListener(){}removeEventListener(){}},h=class e extends g{constructor(t){super();this.nodeType=I;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}get textContent(){return this.data}set textContent(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},A=class e extends g{constructor(t){super();this.nodeType=k;this.rawOuterHTML=t}get textContent(){return this.rawOuterHTML.replace(/<[^>]*>/g,"")}cloneNode(){return new e(this.rawOuterHTML)}},v=class e extends g{constructor(t){super();this.nodeType=j;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},L=class{constructor(){this.cssText=""}setProperty(n,t){this[n]=t}removeProperty(n){delete this[n]}},$=class{constructor(n){this.el=n}list(){let n=this.el.getAttribute("class");return n?n.split(/\s+/).filter(Boolean):[]}write(n){n.length?this.el.setAttribute("class",n.join(" ")):this.el.removeAttribute("class")}add(...n){let t=this.list();for(let r of n)t.includes(r)||t.push(r);this.write(t)}remove(...n){this.write(this.list().filter(t=>!n.includes(t)))}contains(n){return this.list().includes(n)}toggle(n,t){let r=this.contains(n),s=t===void 0?!r:t;return s?this.add(n):this.remove(n),s}},m=class e extends g{constructor(t,r=!1){super();this.nodeType=k;this.attributes=new Map;this.style=new L;this.classList=new $(this);this.rawHTML=null;this.localName=t.toLowerCase(),this.tagName=r?t:t.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(t,r){this.attributes.set(t,String(r))}removeAttribute(t){this.attributes.delete(t)}getAttribute(t){return this.attributes.has(t)?this.attributes.get(t):null}hasAttribute(t){return this.attributes.has(t)}get id(){return this.getAttribute("id")??""}set id(t){t==null?this.removeAttribute("id"):this.setAttribute("id",t)}get className(){return this.getAttribute("class")??""}set className(t){t==null?this.removeAttribute("class"):this.setAttribute("class",t)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(t){t==null?this.removeAttribute("for"):this.setAttribute("for",t)}set value(t){t==null?this.removeAttribute("value"):this.setAttribute("value",String(t))}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(t){t?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(t){}get textContent(){return this.childNodes.map(t=>t.textContent??"").join("")}set textContent(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,t!=null&&t!==""&&this.appendChild(new h(String(t)))}set innerText(t){this.textContent=t}set innerHTML(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=t==null?"":String(t)}cloneNode(t=!1){let r=new e(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,t)for(let s of this.childNodes)r.appendChild(s.cloneNode(!0));return r}};function Y(e){return e instanceof g}var Re=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ee=/&/g,te=/</g,ne=/>/g,be=/"/g;function H(e){return e.replace(ee,"&").replace(te,"<").replace(ne,">")}function Z(e){return e.replace(ee,"&").replace(be,""").replace(te,"<").replace(ne,">")}function Ee(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}function Ce(e){if(!e)return"";let n=[];e.cssText&&n.push(e.cssText.trim().replace(/;\s*$/,""));for(let t of Object.keys(e)){if(t==="cssText")continue;let r=e[t];r==null||r===""||n.push(`${Ee(t)}: ${r}`)}return n.join("; ")}function qe(e){let n="",t=Ce(e.style);for(let[r,s]of e.attributes)r==="style"&&t||(n+=` ${r}="${Z(s)}"`);if(t){let r=e.attributes.get("style"),s=r?`${r.replace(/;\s*$/,"")}; ${t}`:t;n+=` style="${Z(s)}"`}return n}function f(e){if(e==null||e===!1||e===!0)return"";if(typeof e=="string")return H(e);if(typeof e=="number")return H(String(e));if(typeof e=="function")return f(e());if(Array.isArray(e))return e.map(f).join("");if(typeof e.rawOuterHTML=="string")return e.rawOuterHTML;switch(e.nodeType){case I:return H(e.data??"");case j:return`<!--${e.data??""}-->`;case k:{let n=e.localName,t=`<${n}${qe(e)}>`;if(Re.has(n))return t;let r=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(f).join("");return`${t}${r}</${n}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(f).join(""):""}var E="__FX_DATA__";function O(e){return e.replace(/[<>&\u2028\u2029]/g,n=>"\\u"+n.charCodeAt(0).toString(16).padStart(4,"0"))}var F;function re(){let e=globalThis.__FX_DATA__;if(e)return e;if(F!==void 0)return F;let n=null;if(typeof document<"u"){let t=document.getElementById(E)?.textContent;if(t)try{n=JSON.parse(t)}catch{n=null}}return F=n}var P=require("@fluixi/reactive/signal"),c=require("@fluixi/reactive/signal");var Ae=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ke={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'"};function se(e){return e.replace(/&(#?\w+);/g,(n,t)=>ke[t]??n)}var d=class extends Error{};function oe(e,n=!1){let t=0,r=[],s=[],u=o=>{let a=s[s.length-1];a?a.appendChild(o):r.push(o)};for(;t<e.length;){let o=e.indexOf("<",t);if(o===-1){p(e.slice(t));break}if(o>t&&p(e.slice(t,o)),e.startsWith("<!--",o)){let a=e.indexOf("-->",o);if(a===-1)throw new d(`unterminated comment at ${o}`);u(new v(e.slice(o+4,a))),t=a+3;continue}if(e[o+1]==="/"){let a=e.indexOf(">",o);if(a===-1)throw new d(`unterminated closing tag at ${o}`);let T=e.slice(o+2,a).trim().toLowerCase(),x=s.pop();if(!x||x.localName!==T)throw new d(`</${T}> does not close <${x?.localName??"nothing"}>`);t=a+1;continue}t=y(o)}if(s.length>0)throw new d(`unclosed <${s[s.length-1].localName}>`);let l=r[0];if(r.length!==1||!(l instanceof m))throw new d(`expected exactly one root element, got ${r.length}`);return l;function p(o){o!==""&&u(new h(se(o)))}function y(o){let a=/[\s/>]/.exec(e.slice(o+1));if(!a)throw new d(`unterminated tag at ${o}`);let T=e.slice(o+1,o+1+a.index).toLowerCase(),x=new m(T,n),i=o+1+a.index;for(;i<e.length;){for(;i<e.length&&/\s/.test(e[i]);)i++;if(e[i]===">"){i++;break}if(e[i]==="/"&&e[i+1]===">"){i+=2;break}let me=i;for(;i<e.length&&!/[\s=/>]/.test(e[i]);)i++;let R=e.slice(me,i);if(R==="")throw new d(`malformed attribute at ${i}`);if(e[i]==="="){if(e[i+1]!=='"')throw new d(`attribute ${R} must have a double-quoted value`);let M=e.indexOf('"',i+2);if(M===-1)throw new d(`unterminated value for ${R}`);x.setAttribute(R,se(e.slice(i+2,M))),i=M+1}else x.setAttribute(R,"")}return u(x),Ae.has(T)||s.push(x),i}}var D,ae={getStore:()=>D,run(e,n){let t=D;D=e;try{return n()}finally{D=t}}},V=ae;function ue(e){V=e??ae}function C(e={}){e.locals||(e.locals=e.request?X(e.request):{});let n=0,t=0,r=null,s=new Map,u=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${n++}`,nextResourceId:()=>{if(r===null)return`r${t++}`;let l=s.get(r)??0;return s.set(r,l+1),`${r}:r${l}`},nextIslandNamespace:l=>{let p=u.get(l)??0;return u.set(l,p+1),`${l}#${p}`},withResourceScope(l,p){let y=r;r=l;try{return p()}finally{r=y}},pending:new Set,data:new Map}}function q(e,n){return V.run(e,n)}function w(){return V.getStore()}function z(){return w()?.event}function le(){let e=z();return e?(e.locals||(e.locals={}),e.locals):{}}var ie=new WeakMap;function X(e){let n=ie.get(e);return n||(n={},ie.set(e,n)),n}var ce=!1;function pe(){ce||(ce=!0,U({createElement:(e,n)=>new m(e,n),createText:e=>new h(e),createRaw:e=>new A(e),parseTemplate:(e,n)=>oe(e,n),createComment:e=>new v(e)}))}function fe(e,n={}){let t=S;pe(),N(!0);let r=C(n.event);try{return q(r,()=>(0,P.createRoot)(s=>{try{let u=typeof e=="function"?e():e;return f(u)}finally{s()}}))}finally{N(t)}}var de=!1;function Oe(){de||(de=!0,(0,c.setResourceTracker)(e=>{w()?.pending.add(e)}),(0,c.setResourceIdSource)(()=>w()?.nextResourceId()??""),(0,c.setResourceDataSink)((e,n)=>{e&&w()?.data.set(e,n)}))}var W=null;function ge(e){W=e}function J(e){if(e.data.size===0)return"";let n={};for(let[r,s]of e.data){let u=s;if(W)try{u=W(s,r)}catch{continue}u!==void 0&&(n[r]=u)}if(Object.keys(n).length===0)return"";let t=O(JSON.stringify(n));return`<script type="application/json" id="${E}">${t}<\/script>`}var De=50;async function he(e,n={}){let t=S;pe(),N(!0),Oe();let r=C(n.event);try{return await q(r,async()=>{n.preload&&await n.preload(n.event);let s,u=null,l=()=>{};(0,P.createRoot)(a=>{l=a,u=(0,c.getOwner)(),s=typeof e=="function"?e():e});let p=()=>{try{(0,c.runWithOwner)(u,()=>f(s))}catch{}};p();let y=0;for(;r.pending.size>0&&y++<De;){let a=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(a),await(0,c.flush)(),p()}let o=(0,c.runWithOwner)(u,()=>f(s))+J(r);return l(),o})}finally{N(t)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var f=typeof document>"u";function c(e){f=e}var g=Symbol.for("fluixi.server-node"),B=null;function M(e){B=e}function G(e){return e!=null&&e[g]===!0?!0:typeof Node<"u"&&e instanceof Node}function K(e){return e!=null&&e[g]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function Q(e){return e!=null&&e[g]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var b=1,E=3,C=8,O;O=g;var l=class{constructor(){this[O]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let r=this.parentNode;if(!r)return null;let t=r.childNodes.indexOf(this);return t>=0?r.childNodes[t+1]??null:null}get previousSibling(){let r=this.parentNode;if(!r)return null;let t=r.childNodes.indexOf(this);return t>0?r.childNodes[t-1]??null:null}get parentElement(){return this.parentNode}appendChild(r){return r.parentNode&&r.parentNode.removeChild(r),r.parentNode=this,this.childNodes.push(r),r}insertBefore(r,t){if(t==null)return this.appendChild(r);r.parentNode&&r.parentNode.removeChild(r);let n=this.childNodes.indexOf(t);return r.parentNode=this,n<0?this.childNodes.push(r):this.childNodes.splice(n,0,r),r}removeChild(r){let t=this.childNodes.indexOf(r);return t>=0&&this.childNodes.splice(t,1),r.parentNode=null,r}replaceChild(r,t){let n=this.childNodes.indexOf(t);return n>=0&&(r.parentNode&&r.parentNode.removeChild(r),r.parentNode=this,this.childNodes[n]=r,t.parentNode=null),t}addEventListener(){}removeEventListener(){}},d=class e extends l{constructor(t){super();this.nodeType=E;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}get textContent(){return this.data}set textContent(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},h=class e extends l{constructor(t){super();this.nodeType=C;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},T=class{constructor(){this.cssText=""}setProperty(r,t){this[r]=t}removeProperty(r){delete this[r]}},w=class{constructor(r){this.el=r}list(){let r=this.el.getAttribute("class");return r?r.split(/\s+/).filter(Boolean):[]}write(r){r.length?this.el.setAttribute("class",r.join(" ")):this.el.removeAttribute("class")}add(...r){let t=this.list();for(let n of r)t.includes(n)||t.push(n);this.write(t)}remove(...r){this.write(this.list().filter(t=>!r.includes(t)))}contains(r){return this.list().includes(r)}toggle(r,t){let n=this.contains(r),s=t===void 0?!n:t;return s?this.add(r):this.remove(r),s}},m=class e extends l{constructor(t,n=!1){super();this.nodeType=b;this.attributes=new Map;this.style=new T;this.classList=new w(this);this.rawHTML=null;this.localName=t.toLowerCase(),this.tagName=n?t:t.toUpperCase(),this.isSVG=n,this.namespaceURI=n?"http://www.w3.org/2000/svg":null}setAttribute(t,n){this.attributes.set(t,String(n))}removeAttribute(t){this.attributes.delete(t)}getAttribute(t){return this.attributes.has(t)?this.attributes.get(t):null}hasAttribute(t){return this.attributes.has(t)}get id(){return this.getAttribute("id")??""}set id(t){t==null?this.removeAttribute("id"):this.setAttribute("id",t)}get className(){return this.getAttribute("class")??""}set className(t){t==null?this.removeAttribute("class"):this.setAttribute("class",t)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(t){t==null?this.removeAttribute("for"):this.setAttribute("for",t)}set value(t){t==null?this.removeAttribute("value"):this.setAttribute("value",String(t))}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(t){t?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(t){}get textContent(){return this.childNodes.map(t=>t.textContent??"").join("")}set textContent(t){for(let n of this.childNodes)n.parentNode=null;this.childNodes=[],this.rawHTML=null,t!=null&&t!==""&&this.appendChild(new d(String(t)))}set innerText(t){this.textContent=t}set innerHTML(t){for(let n of this.childNodes)n.parentNode=null;this.childNodes=[],this.rawHTML=t==null?"":String(t)}cloneNode(t=!1){let n=new e(this.localName,this.isSVG);if(n.attributes=new Map(this.attributes),n.style.cssText=this.style.cssText,n.rawHTML=this.rawHTML,t)for(let s of this.childNodes)n.appendChild(s.cloneNode(!0));return n}};function Y(e){return e instanceof l}var Z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$=/&/g,ee=/</g,te=/>/g,re=/"/g;function q(e){return e.replace($,"&").replace(ee,"<").replace(te,">")}function L(e){return e.replace($,"&").replace(re,""")}function ne(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,r=>"-"+r.toLowerCase())}function se(e){if(!e)return"";let r=[];e.cssText&&r.push(e.cssText.trim().replace(/;\s*$/,""));for(let t of Object.keys(e)){if(t==="cssText")continue;let n=e[t];n==null||n===""||r.push(`${ne(t)}: ${n}`)}return r.join("; ")}function oe(e){let r="",t=se(e.style);for(let[n,s]of e.attributes)n==="style"&&t||(r+=` ${n}="${L(s)}"`);if(t){let n=e.attributes.get("style"),s=n?`${n.replace(/;\s*$/,"")}; ${t}`:t;r+=` style="${L(s)}"`}return r}function u(e){if(e==null||e===!1||e===!0)return"";if(typeof e=="string")return q(e);if(typeof e=="number")return q(String(e));if(typeof e=="function")return u(e());if(Array.isArray(e))return e.map(u).join("");switch(e.nodeType){case E:return q(e.data??"");case C:return`<!--${e.data??""}-->`;case b:{let r=e.localName,t=`<${r}${oe(e)}>`;if(Z.has(r))return t;let n=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(u).join("");return`${t}${n}</${r}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(u).join(""):""}var x="__FX_DATA__";function D(e){return e.replace(/[<>&\u2028\u2029]/g,r=>"\\u"+r.charCodeAt(0).toString(16).padStart(4,"0"))}var A;function ie(){let e=globalThis.__FX_DATA__;if(e)return e;if(A!==void 0)return A;let r=null;if(typeof document<"u"){let t=document.getElementById(x)?.textContent;if(t)try{r=JSON.parse(t)}catch{r=null}}return A=r}import{createRoot as P}from"@fluixi/reactive/signal";import{setResourceTracker as le,setResourceIdSource as ce,setResourceDataSink as de,getOwner as pe,runWithOwner as H,flush as fe}from"@fluixi/reactive/signal";var v,F={getStore:()=>v,run(e,r){let t=v;v=e;try{return r()}finally{v=t}}},_=F;function ue(e){_=e??F}function N(e={}){e.locals||(e.locals=e.request?V(e.request):{});let r=0,t=0,n=null,s=new Map,o=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${r++}`,nextResourceId:()=>{if(n===null)return`r${t++}`;let i=s.get(n)??0;return s.set(n,i+1),`${n}:r${i}`},nextIslandNamespace:i=>{let a=o.get(i)??0;return o.set(i,a+1),`${i}#${a}`},withResourceScope(i,a){let S=n;n=i;try{return a()}finally{n=S}},pending:new Set,data:new Map}}function y(e,r){return _.run(e,r)}function p(){return _.getStore()}function j(){return p()?.event}function ae(){let e=j();return e?(e.locals||(e.locals={}),e.locals):{}}var I=new WeakMap;function V(e){let r=I.get(e);return r||(r={},I.set(e,r)),r}var z=!1;function W(){z||(z=!0,M({createElement:(e,r)=>new m(e,r),createText:e=>new d(e),createComment:e=>new h(e)}))}function ge(e,r={}){let t=f;W(),c(!0);let n=N(r.event);try{return y(n,()=>P(s=>{try{let o=typeof e=="function"?e():e;return u(o)}finally{s()}}))}finally{c(t)}}var X=!1;function he(){X||(X=!0,le(e=>{p()?.pending.add(e)}),ce(()=>p()?.nextResourceId()??""),de((e,r)=>{e&&p()?.data.set(e,r)}))}var k=null;function me(e){k=e}function J(e){if(e.data.size===0)return"";let r={};for(let[n,s]of e.data){let o=s;if(k)try{o=k(s,n)}catch{continue}o!==void 0&&(r[n]=o)}if(Object.keys(r).length===0)return"";let t=D(JSON.stringify(r));return`<script type="application/json" id="${x}">${t}<\/script>`}var xe=50;async function ve(e,r={}){let t=f;W(),c(!0),he();let n=N(r.event);try{return await y(n,async()=>{r.preload&&await r.preload(r.event);let s,o=null,i=()=>{};P(R=>{i=R,o=pe(),s=typeof e=="function"?e():e});let a=()=>{try{H(o,()=>u(s))}catch{}};a();let S=0;for(;n.pending.size>0&&S++<xe;){let R=Array.from(n.pending);n.pending.clear(),await Promise.allSettled(R),await fe(),a()}let U=H(o,()=>u(s))+J(n);return i(),U})}finally{c(t)}}export{x as FX_DATA_ID,h as ServerComment,m as ServerElement,l as ServerNode,d as ServerText,N as createRequestContext,D as escapeFxJson,ae as getLocals,p as getRequestContext,j as getRequestEvent,V as getRequestLocals,ie as getServerData,K as isDomElement,G as isDomNode,Q as isDomText,f as isServer,Y as isServerNodeValue,ge as renderToString,ve as renderToStringAsync,y as runWithRequestContext,u as serializeNode,J as serializeResourceData,me as setDataRedactor,ue as setRequestStore,c as setServerMode};
|
|
1
|
+
var T=typeof document>"u";function v(e){T=e}var R=Symbol.for("fluixi.server-node"),ie=null;function V(e){ie=e}function ae(e){return e!=null&&e[R]===!0?!0:typeof Node<"u"&&e instanceof Node}function ue(e){return e!=null&&e[R]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function le(e){return e!=null&&e[R]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var E=1,_=3,L=8,z;z=R;var g=class{constructor(){this[z]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let n=this.parentNode;if(!n)return null;let t=n.childNodes.indexOf(this);return t>=0?n.childNodes[t+1]??null:null}get previousSibling(){let n=this.parentNode;if(!n)return null;let t=n.childNodes.indexOf(this);return t>0?n.childNodes[t-1]??null:null}get parentElement(){return this.parentNode}appendChild(n){return n.parentNode&&n.parentNode.removeChild(n),n.parentNode=this,this.childNodes.push(n),n}insertBefore(n,t){if(t==null)return this.appendChild(n);n.parentNode&&n.parentNode.removeChild(n);let r=this.childNodes.indexOf(t);return n.parentNode=this,r<0?this.childNodes.push(n):this.childNodes.splice(r,0,n),n}removeChild(n){let t=this.childNodes.indexOf(n);return t>=0&&this.childNodes.splice(t,1),n.parentNode=null,n}replaceChild(n,t){let r=this.childNodes.indexOf(t);return r>=0&&(n.parentNode&&n.parentNode.removeChild(n),n.parentNode=this,this.childNodes[r]=n,t.parentNode=null),t}addEventListener(){}removeEventListener(){}},h=class e extends g{constructor(t){super();this.nodeType=_;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}get textContent(){return this.data}set textContent(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},b=class e extends g{constructor(t){super();this.nodeType=E;this.rawOuterHTML=t}get textContent(){return this.rawOuterHTML.replace(/<[^>]*>/g,"")}cloneNode(){return new e(this.rawOuterHTML)}},x=class e extends g{constructor(t){super();this.nodeType=L;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},D=class{constructor(){this.cssText=""}setProperty(n,t){this[n]=t}removeProperty(n){delete this[n]}},M=class{constructor(n){this.el=n}list(){let n=this.el.getAttribute("class");return n?n.split(/\s+/).filter(Boolean):[]}write(n){n.length?this.el.setAttribute("class",n.join(" ")):this.el.removeAttribute("class")}add(...n){let t=this.list();for(let r of n)t.includes(r)||t.push(r);this.write(t)}remove(...n){this.write(this.list().filter(t=>!n.includes(t)))}contains(n){return this.list().includes(n)}toggle(n,t){let r=this.contains(n),s=t===void 0?!r:t;return s?this.add(n):this.remove(n),s}},m=class e extends g{constructor(t,r=!1){super();this.nodeType=E;this.attributes=new Map;this.style=new D;this.classList=new M(this);this.rawHTML=null;this.localName=t.toLowerCase(),this.tagName=r?t:t.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(t,r){this.attributes.set(t,String(r))}removeAttribute(t){this.attributes.delete(t)}getAttribute(t){return this.attributes.has(t)?this.attributes.get(t):null}hasAttribute(t){return this.attributes.has(t)}get id(){return this.getAttribute("id")??""}set id(t){t==null?this.removeAttribute("id"):this.setAttribute("id",t)}get className(){return this.getAttribute("class")??""}set className(t){t==null?this.removeAttribute("class"):this.setAttribute("class",t)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(t){t==null?this.removeAttribute("for"):this.setAttribute("for",t)}set value(t){t==null?this.removeAttribute("value"):this.setAttribute("value",String(t))}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(t){t?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(t){}get textContent(){return this.childNodes.map(t=>t.textContent??"").join("")}set textContent(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,t!=null&&t!==""&&this.appendChild(new h(String(t)))}set innerText(t){this.textContent=t}set innerHTML(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=t==null?"":String(t)}cloneNode(t=!1){let r=new e(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,t)for(let s of this.childNodes)r.appendChild(s.cloneNode(!0));return r}};function ce(e){return e instanceof g}var de=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),W=/&/g,P=/</g,J=/>/g,pe=/"/g;function $(e){return e.replace(W,"&").replace(P,"<").replace(J,">")}function X(e){return e.replace(W,"&").replace(pe,""").replace(P,"<").replace(J,">")}function fe(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}function ge(e){if(!e)return"";let n=[];e.cssText&&n.push(e.cssText.trim().replace(/;\s*$/,""));for(let t of Object.keys(e)){if(t==="cssText")continue;let r=e[t];r==null||r===""||n.push(`${fe(t)}: ${r}`)}return n.join("; ")}function he(e){let n="",t=ge(e.style);for(let[r,s]of e.attributes)r==="style"&&t||(n+=` ${r}="${X(s)}"`);if(t){let r=e.attributes.get("style"),s=r?`${r.replace(/;\s*$/,"")}; ${t}`:t;n+=` style="${X(s)}"`}return n}function p(e){if(e==null||e===!1||e===!0)return"";if(typeof e=="string")return $(e);if(typeof e=="number")return $(String(e));if(typeof e=="function")return p(e());if(Array.isArray(e))return e.map(p).join("");if(typeof e.rawOuterHTML=="string")return e.rawOuterHTML;switch(e.nodeType){case _:return $(e.data??"");case L:return`<!--${e.data??""}-->`;case E:{let n=e.localName,t=`<${n}${he(e)}>`;if(de.has(n))return t;let r=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(p).join("");return`${t}${r}</${n}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(p).join(""):""}var C="__FX_DATA__";function j(e){return e.replace(/[<>&\u2028\u2029]/g,n=>"\\u"+n.charCodeAt(0).toString(16).padStart(4,"0"))}var I;function me(){let e=globalThis.__FX_DATA__;if(e)return e;if(I!==void 0)return I;let n=null;if(typeof document<"u"){let t=document.getElementById(C)?.textContent;if(t)try{n=JSON.parse(t)}catch{n=null}}return I=n}import{createRoot as ne}from"@fluixi/reactive/signal";import{setResourceTracker as Se,setResourceIdSource as ye,setResourceDataSink as Te,getOwner as Re,runWithOwner as Z,flush as be}from"@fluixi/reactive/signal";var xe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ve={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'"};function U(e){return e.replace(/&(#?\w+);/g,(n,t)=>ve[t]??n)}var c=class extends Error{};function G(e,n=!1){let t=0,r=[],s=[],u=o=>{let a=s[s.length-1];a?a.appendChild(o):r.push(o)};for(;t<e.length;){let o=e.indexOf("<",t);if(o===-1){d(e.slice(t));break}if(o>t&&d(e.slice(t,o)),e.startsWith("<!--",o)){let a=e.indexOf("-->",o);if(a===-1)throw new c(`unterminated comment at ${o}`);u(new x(e.slice(o+4,a))),t=a+3;continue}if(e[o+1]==="/"){let a=e.indexOf(">",o);if(a===-1)throw new c(`unterminated closing tag at ${o}`);let S=e.slice(o+2,a).trim().toLowerCase(),f=s.pop();if(!f||f.localName!==S)throw new c(`</${S}> does not close <${f?.localName??"nothing"}>`);t=a+1;continue}t=w(o)}if(s.length>0)throw new c(`unclosed <${s[s.length-1].localName}>`);let l=r[0];if(r.length!==1||!(l instanceof m))throw new c(`expected exactly one root element, got ${r.length}`);return l;function d(o){o!==""&&u(new h(U(o)))}function w(o){let a=/[\s/>]/.exec(e.slice(o+1));if(!a)throw new c(`unterminated tag at ${o}`);let S=e.slice(o+1,o+1+a.index).toLowerCase(),f=new m(S,n),i=o+1+a.index;for(;i<e.length;){for(;i<e.length&&/\s/.test(e[i]);)i++;if(e[i]===">"){i++;break}if(e[i]==="/"&&e[i+1]===">"){i+=2;break}let oe=i;for(;i<e.length&&!/[\s=/>]/.test(e[i]);)i++;let y=e.slice(oe,i);if(y==="")throw new c(`malformed attribute at ${i}`);if(e[i]==="="){if(e[i+1]!=='"')throw new c(`attribute ${y} must have a double-quoted value`);let O=e.indexOf('"',i+2);if(O===-1)throw new c(`unterminated value for ${y}`);f.setAttribute(y,U(e.slice(i+2,O))),i=O+1}else f.setAttribute(y,"")}return u(f),xe.has(S)||s.push(f),i}}var q,K={getStore:()=>q,run(e,n){let t=q;q=e;try{return n()}finally{q=t}}},H=K;function Ne(e){H=e??K}function A(e={}){e.locals||(e.locals=e.request?Y(e.request):{});let n=0,t=0,r=null,s=new Map,u=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${n++}`,nextResourceId:()=>{if(r===null)return`r${t++}`;let l=s.get(r)??0;return s.set(r,l+1),`${r}:r${l}`},nextIslandNamespace:l=>{let d=u.get(l)??0;return u.set(l,d+1),`${l}#${d}`},withResourceScope(l,d){let w=r;r=l;try{return d()}finally{r=w}},pending:new Set,data:new Map}}function k(e,n){return H.run(e,n)}function N(){return H.getStore()}function Q(){return N()?.event}function we(){let e=Q();return e?(e.locals||(e.locals={}),e.locals):{}}var B=new WeakMap;function Y(e){let n=B.get(e);return n||(n={},B.set(e,n)),n}var ee=!1;function re(){ee||(ee=!0,V({createElement:(e,n)=>new m(e,n),createText:e=>new h(e),createRaw:e=>new b(e),parseTemplate:(e,n)=>G(e,n),createComment:e=>new x(e)}))}function Ee(e,n={}){let t=T;re(),v(!0);let r=A(n.event);try{return k(r,()=>ne(s=>{try{let u=typeof e=="function"?e():e;return p(u)}finally{s()}}))}finally{v(t)}}var te=!1;function Ce(){te||(te=!0,Se(e=>{N()?.pending.add(e)}),ye(()=>N()?.nextResourceId()??""),Te((e,n)=>{e&&N()?.data.set(e,n)}))}var F=null;function qe(e){F=e}function se(e){if(e.data.size===0)return"";let n={};for(let[r,s]of e.data){let u=s;if(F)try{u=F(s,r)}catch{continue}u!==void 0&&(n[r]=u)}if(Object.keys(n).length===0)return"";let t=j(JSON.stringify(n));return`<script type="application/json" id="${C}">${t}<\/script>`}var Ae=50;async function ke(e,n={}){let t=T;re(),v(!0),Ce();let r=A(n.event);try{return await k(r,async()=>{n.preload&&await n.preload(n.event);let s,u=null,l=()=>{};ne(a=>{l=a,u=Re(),s=typeof e=="function"?e():e});let d=()=>{try{Z(u,()=>p(s))}catch{}};d();let w=0;for(;r.pending.size>0&&w++<Ae;){let a=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(a),await be(),d()}let o=Z(u,()=>p(s))+se(r);return l(),o})}finally{v(t)}}export{C as FX_DATA_ID,x as ServerComment,m as ServerElement,g as ServerNode,h as ServerText,A as createRequestContext,j as escapeFxJson,we as getLocals,N as getRequestContext,Q as getRequestEvent,Y as getRequestLocals,me as getServerData,ue as isDomElement,ae as isDomNode,le as isDomText,T as isServer,ce as isServerNodeValue,Ee as renderToString,ke as renderToStringAsync,k as runWithRequestContext,p as serializeNode,se as serializeResourceData,qe as setDataRedactor,Ne as setRequestStore,v as setServerMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var u=(e,o)=>{for(var s in o)t(e,s,{get:o[s],enumerable:!0})},m=(e,o,s,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of d(o))!f.call(e,r)&&r!==s&&t(e,r,{get:()=>o[r],enumerable:!(n=c(o,r))||n.enumerable});return e};var p=e=>m(t({},"__esModule",{value:!0}),e);var V={};u(V,{registerCoreVersion:()=>x,stampVersions:()=>v,versions:()=>i,warnOnVersionSkew:()=>g});module.exports=p(V);var a="1.0.0-alpha.71";var l=require("@fluixi/reactive"),i={dom:a,reactive:l.VERSION};function x(e){i.core=e}function v(e){i.core&&e.setAttribute("fluixi",i.core),e.setAttribute("fx-dom",i.dom),e.setAttribute("fx-reactive",i.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=i)}function g(){let e=[i.core,i.dom,i.reactive].filter(o=>o!==void 0);new Set(e).size<=1||console.warn(`[fluixi] package versions disagree — core ${i.core??"(absent)"}, dom ${i.dom}, reactive ${i.reactive}. These ship as one release, so a mismatch usually means a stale lockfile or two copies resolved side by side. Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`)}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The versions of the packages this app is running. */
|
|
2
|
+
export interface FluixiVersions {
|
|
3
|
+
/** Absent when the app does not use `@fluixi/core` — dom and reactive can run alone. */
|
|
4
|
+
core?: string;
|
|
5
|
+
dom: string;
|
|
6
|
+
reactive: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const versions: FluixiVersions;
|
|
9
|
+
declare global {
|
|
10
|
+
var Fluixi: FluixiVersions | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Record the `@fluixi/core` version, called by core when it is loaded.
|
|
14
|
+
*
|
|
15
|
+
* Inverted rather than imported, because core sits above this package.
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerCoreVersion(version: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Stamp the versions onto the mount element and expose them as `window.Fluixi`.
|
|
20
|
+
*
|
|
21
|
+
* The attributes make it visible in the page source and in a screenshot of devtools —
|
|
22
|
+
* usually all a bug report contains — while the global is what you reach for in a console.
|
|
23
|
+
*/
|
|
24
|
+
export declare function stampVersions(container: Element): void;
|
|
25
|
+
/**
|
|
26
|
+
* Warn when the packages are not all from the same release.
|
|
27
|
+
*
|
|
28
|
+
* They are versioned as one unit, so a mismatch means the install is wrong rather than a
|
|
29
|
+
* combination that needs supporting. Worth saying once, loudly, rather than letting it
|
|
30
|
+
* surface later as a reactivity bug nobody can reproduce.
|
|
31
|
+
*/
|
|
32
|
+
export declare function warnOnVersionSkew(): void;
|
|
33
|
+
//# sourceMappingURL=versions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../src/lib/dom/versions.ts"],"names":[],"mappings":"AAmBA,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,QAAQ,EAAE,cAAiD,CAAC;AAEzE,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;CACxC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAMtD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAYxC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which build of each package is actually running.
|
|
3
|
+
*
|
|
4
|
+
* This used to live in `@fluixi/core`, stamped only by *its* `render`. But an app can
|
|
5
|
+
* reach the DOM through either entry point — `@fluixi/core`'s `render`, or this package's
|
|
6
|
+
* `render`/`hydrate` by way of `startClient` — and only the first stamped anything. An app
|
|
7
|
+
* that hydrated (the docs site, every SSR app) therefore had no version attributes at all,
|
|
8
|
+
* which is exactly the case where a bug report needs them most.
|
|
9
|
+
*
|
|
10
|
+
* So the stamping sits at the bottom instead, where both paths pass through.
|
|
11
|
+
*
|
|
12
|
+
* The core version cannot be imported here: `@fluixi/core` depends on this package, not
|
|
13
|
+
* the other way round, and reversing that would be a cycle. Core registers its own version
|
|
14
|
+
* on import instead, and whichever render runs stamps whatever has been registered. That
|
|
15
|
+
* keeps the dependency direction intact and still gets all three onto the element.
|
|
16
|
+
*/
|
|
17
|
+
import { VERSION as DOM } from '../../version.generated.js';
|
|
18
|
+
import { VERSION as REACTIVE } from '@fluixi/reactive';
|
|
19
|
+
export const versions = { dom: DOM, reactive: REACTIVE };
|
|
20
|
+
/**
|
|
21
|
+
* Record the `@fluixi/core` version, called by core when it is loaded.
|
|
22
|
+
*
|
|
23
|
+
* Inverted rather than imported, because core sits above this package.
|
|
24
|
+
*/
|
|
25
|
+
export function registerCoreVersion(version) {
|
|
26
|
+
versions.core = version;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Stamp the versions onto the mount element and expose them as `window.Fluixi`.
|
|
30
|
+
*
|
|
31
|
+
* The attributes make it visible in the page source and in a screenshot of devtools —
|
|
32
|
+
* usually all a bug report contains — while the global is what you reach for in a console.
|
|
33
|
+
*/
|
|
34
|
+
export function stampVersions(container) {
|
|
35
|
+
if (versions.core)
|
|
36
|
+
container.setAttribute('fluixi', versions.core);
|
|
37
|
+
container.setAttribute('fx-dom', versions.dom);
|
|
38
|
+
container.setAttribute('fx-reactive', versions.reactive);
|
|
39
|
+
if (typeof globalThis !== 'undefined')
|
|
40
|
+
globalThis.Fluixi = versions;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Warn when the packages are not all from the same release.
|
|
44
|
+
*
|
|
45
|
+
* They are versioned as one unit, so a mismatch means the install is wrong rather than a
|
|
46
|
+
* combination that needs supporting. Worth saying once, loudly, rather than letting it
|
|
47
|
+
* surface later as a reactivity bug nobody can reproduce.
|
|
48
|
+
*/
|
|
49
|
+
export function warnOnVersionSkew() {
|
|
50
|
+
const present = [versions.core, versions.dom, versions.reactive].filter((v) => v !== undefined);
|
|
51
|
+
if (new Set(present).size <= 1)
|
|
52
|
+
return;
|
|
53
|
+
console.warn(`[fluixi] package versions disagree — core ${versions.core ?? '(absent)'}, ` +
|
|
54
|
+
`dom ${versions.dom}, reactive ${versions.reactive}. These ship as one release, so a ` +
|
|
55
|
+
`mismatch usually means a stale lockfile or two copies resolved side by side. ` +
|
|
56
|
+
`Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`);
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o="1.0.0-alpha.71";import{VERSION as s}from"@fluixi/reactive";var e={dom:o,reactive:s};function l(i){e.core=i}function c(i){e.core&&i.setAttribute("fluixi",e.core),i.setAttribute("fx-dom",e.dom),i.setAttribute("fx-reactive",e.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=e)}function d(){let i=[e.core,e.dom,e.reactive].filter(r=>r!==void 0);new Set(i).size<=1||console.warn(`[fluixi] package versions disagree — core ${e.core??"(absent)"}, dom ${e.dom}, reactive ${e.reactive}. These ship as one release, so a mismatch usually means a stale lockfile or two copies resolved side by side. Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`)}export{l as registerCoreVersion,c as stampVersions,e as versions,d as warnOnVersionSkew};
|