@fluixi/dom 1.0.0-alpha.83 → 1.0.0-alpha.85

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.
Files changed (182) hide show
  1. package/dist/cdn/dom-client.cjs +1427 -1
  2. package/dist/cdn/dom-client.d.ts +2 -2
  3. package/dist/cdn/dom-client.global.js +2 -1
  4. package/dist/cdn/dom-client.js +3 -3
  5. package/dist/cdn/dom-client.mjs +1430 -1
  6. package/dist/cdn/dom.cjs +3127 -1
  7. package/dist/cdn/dom.d.ts +2 -2
  8. package/dist/cdn/dom.global.js +2 -1
  9. package/dist/cdn/dom.js +4 -4
  10. package/dist/cdn/dom.mjs +3133 -1
  11. package/dist/index.cjs +3155 -1
  12. package/dist/index.js +2 -2
  13. package/dist/index.mjs +3149 -1
  14. package/dist/lib/component/index.cjs +128 -1
  15. package/dist/lib/component/index.mjs +105 -1
  16. package/dist/lib/component/modifiers.cjs +126 -1
  17. package/dist/lib/component/modifiers.d.ts +12 -0
  18. package/dist/lib/component/modifiers.d.ts.map +1 -1
  19. package/dist/lib/component/modifiers.js +12 -84
  20. package/dist/lib/component/modifiers.mjs +105 -1
  21. package/dist/lib/dom/delegate.cjs +60 -1
  22. package/dist/lib/dom/delegate.js +1 -1
  23. package/dist/lib/dom/delegate.mjs +39 -1
  24. package/dist/lib/dom/dynamic-element.cjs +949 -1
  25. package/dist/lib/dom/dynamic-element.d.ts +3 -3
  26. package/dist/lib/dom/dynamic-element.js +2 -2
  27. package/dist/lib/dom/dynamic-element.mjs +928 -1
  28. package/dist/lib/dom/hydration-state.cjs +93 -1
  29. package/dist/lib/dom/hydration-state.d.ts +1 -1
  30. package/dist/lib/dom/hydration-state.js +1 -1
  31. package/dist/lib/dom/hydration-state.mjs +72 -1
  32. package/dist/lib/dom/hydration.cjs +685 -1
  33. package/dist/lib/dom/hydration.js +8 -8
  34. package/dist/lib/dom/hydration.mjs +664 -1
  35. package/dist/lib/dom/index.cjs +2040 -1
  36. package/dist/lib/dom/index.js +1 -1
  37. package/dist/lib/dom/index.mjs +2020 -1
  38. package/dist/lib/dom/integration.cjs +71 -1
  39. package/dist/lib/dom/integration.js +3 -3
  40. package/dist/lib/dom/integration.mjs +51 -1
  41. package/dist/lib/dom/island.cjs +790 -1
  42. package/dist/lib/dom/island.d.ts +1 -1
  43. package/dist/lib/dom/island.js +11 -11
  44. package/dist/lib/dom/island.mjs +769 -1
  45. package/dist/lib/dom/runtime.cjs +1432 -1
  46. package/dist/lib/dom/runtime.d.ts +60 -17
  47. package/dist/lib/dom/runtime.d.ts.map +1 -1
  48. package/dist/lib/dom/runtime.js +122 -79
  49. package/dist/lib/dom/runtime.mjs +1414 -1
  50. package/dist/lib/dom/server/fx-data.cjs +53 -1
  51. package/dist/lib/dom/server/fx-data.d.ts +5 -5
  52. package/dist/lib/dom/server/fx-data.js +6 -6
  53. package/dist/lib/dom/server/fx-data.mjs +32 -1
  54. package/dist/lib/dom/server/host.cjs +66 -1
  55. package/dist/lib/dom/server/host.d.ts +6 -0
  56. package/dist/lib/dom/server/host.d.ts.map +1 -1
  57. package/dist/lib/dom/server/host.js +7 -1
  58. package/dist/lib/dom/server/host.mjs +45 -1
  59. package/dist/lib/dom/server/index.cjs +759 -1
  60. package/dist/lib/dom/server/index.d.ts +1 -1
  61. package/dist/lib/dom/server/index.js +1 -1
  62. package/dist/lib/dom/server/index.mjs +743 -1
  63. package/dist/lib/dom/server/nodes.cjs +302 -1
  64. package/dist/lib/dom/server/nodes.d.ts +2 -2
  65. package/dist/lib/dom/server/nodes.d.ts.map +1 -1
  66. package/dist/lib/dom/server/nodes.js +4 -4
  67. package/dist/lib/dom/server/nodes.mjs +279 -1
  68. package/dist/lib/dom/server/parse-template.cjs +395 -1
  69. package/dist/lib/dom/server/parse-template.d.ts +1 -1
  70. package/dist/lib/dom/server/parse-template.js +4 -4
  71. package/dist/lib/dom/server/parse-template.mjs +372 -1
  72. package/dist/lib/dom/server/render.cjs +691 -1
  73. package/dist/lib/dom/server/render.d.ts +9 -1
  74. package/dist/lib/dom/server/render.d.ts.map +1 -1
  75. package/dist/lib/dom/server/render.js +23 -15
  76. package/dist/lib/dom/server/render.mjs +677 -1
  77. package/dist/lib/dom/server/request-context.cjs +110 -1
  78. package/dist/lib/dom/server/request-context.d.ts +29 -9
  79. package/dist/lib/dom/server/request-context.d.ts.map +1 -1
  80. package/dist/lib/dom/server/request-context.js +28 -8
  81. package/dist/lib/dom/server/request-context.mjs +89 -1
  82. package/dist/lib/dom/server/serialize.cjs +187 -1
  83. package/dist/lib/dom/server/serialize.js +3 -3
  84. package/dist/lib/dom/server/serialize.mjs +164 -1
  85. package/dist/lib/dom/server-renderer.cjs +760 -1
  86. package/dist/lib/dom/server-renderer.js +1 -1
  87. package/dist/lib/dom/server-renderer.mjs +745 -1
  88. package/dist/lib/dom/types.cjs +18 -1
  89. package/dist/lib/dom/utils.cjs +381 -1
  90. package/dist/lib/dom/utils.d.ts +1 -88
  91. package/dist/lib/dom/utils.d.ts.map +1 -1
  92. package/dist/lib/dom/utils.js +2 -99
  93. package/dist/lib/dom/utils.mjs +361 -1
  94. package/dist/lib/dom/versions.cjs +60 -1
  95. package/dist/lib/dom/versions.d.ts +3 -3
  96. package/dist/lib/dom/versions.d.ts.map +1 -1
  97. package/dist/lib/dom/versions.js +17 -5
  98. package/dist/lib/dom/versions.mjs +37 -1
  99. package/dist/lib/element/attributes.cjs +19 -1
  100. package/dist/lib/element/attributes.d.ts +7 -7
  101. package/dist/lib/element/attributes.js +1 -1
  102. package/dist/lib/element/attributes.mjs +1 -0
  103. package/dist/lib/element/index.cjs +19 -1
  104. package/dist/lib/element/index.mjs +1 -0
  105. package/dist/lib/element/types.cjs +18 -1
  106. package/dist/lib/element/types.d.ts +4 -5
  107. package/dist/lib/element/types.d.ts.map +1 -1
  108. package/dist/lib/element/types.js +0 -1
  109. package/dist/lib/flow/class-map.cjs +38 -1
  110. package/dist/lib/flow/class-map.d.ts +3 -3
  111. package/dist/lib/flow/class-map.js +2 -2
  112. package/dist/lib/flow/class-map.mjs +17 -1
  113. package/dist/lib/flow/client-only.cjs +57 -1
  114. package/dist/lib/flow/client-only.d.ts +4 -4
  115. package/dist/lib/flow/client-only.js +3 -3
  116. package/dist/lib/flow/client-only.mjs +36 -1
  117. package/dist/lib/flow/dynamic.cjs +53 -1
  118. package/dist/lib/flow/dynamic.d.ts +2 -2
  119. package/dist/lib/flow/dynamic.js +3 -3
  120. package/dist/lib/flow/dynamic.mjs +32 -1
  121. package/dist/lib/flow/error-boundary.cjs +43 -1
  122. package/dist/lib/flow/error-boundary.d.ts +2 -2
  123. package/dist/lib/flow/error-boundary.js +3 -3
  124. package/dist/lib/flow/error-boundary.mjs +22 -1
  125. package/dist/lib/flow/for.cjs +66 -1
  126. package/dist/lib/flow/for.d.ts +9 -9
  127. package/dist/lib/flow/for.d.ts.map +1 -1
  128. package/dist/lib/flow/for.js +2 -2
  129. package/dist/lib/flow/for.mjs +45 -1
  130. package/dist/lib/flow/index-flow.cjs +67 -1
  131. package/dist/lib/flow/index-flow.d.ts +5 -5
  132. package/dist/lib/flow/index-flow.js +4 -4
  133. package/dist/lib/flow/index-flow.mjs +46 -1
  134. package/dist/lib/flow/index.cjs +805 -1
  135. package/dist/lib/flow/index.mjs +792 -1
  136. package/dist/lib/flow/portal.cjs +538 -1
  137. package/dist/lib/flow/portal.mjs +519 -1
  138. package/dist/lib/flow/show.cjs +81 -1
  139. package/dist/lib/flow/show.d.ts +1 -1
  140. package/dist/lib/flow/show.d.ts.map +1 -1
  141. package/dist/lib/flow/show.js +4 -115
  142. package/dist/lib/flow/show.mjs +67 -1
  143. package/dist/lib/flow/style-map.cjs +43 -1
  144. package/dist/lib/flow/style-map.d.ts +3 -3
  145. package/dist/lib/flow/style-map.js +3 -3
  146. package/dist/lib/flow/style-map.mjs +22 -1
  147. package/dist/lib/flow/switch.cjs +91 -1
  148. package/dist/lib/flow/switch.d.ts +3 -3
  149. package/dist/lib/flow/switch.d.ts.map +1 -1
  150. package/dist/lib/flow/switch.js +6 -6
  151. package/dist/lib/flow/switch.mjs +70 -1
  152. package/dist/lib/flow/utils.cjs +44 -1
  153. package/dist/lib/flow/utils.d.ts +1 -1
  154. package/dist/lib/flow/utils.js +1 -1
  155. package/dist/lib/flow/utils.mjs +23 -1
  156. package/dist/lib/html.cjs +32 -1
  157. package/dist/lib/html.d.ts +6 -6
  158. package/dist/lib/html.js +5 -5
  159. package/dist/lib/html.mjs +11 -1
  160. package/dist/lib/index.cjs +3104 -1
  161. package/dist/lib/index.d.ts +0 -1
  162. package/dist/lib/index.d.ts.map +1 -1
  163. package/dist/lib/index.js +2 -3
  164. package/dist/lib/index.mjs +3097 -1
  165. package/dist/lib/shared/types.cjs +18 -1
  166. package/dist/lib/shared/types.d.ts +8 -8
  167. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  168. package/dist/version.generated.cjs +26 -1
  169. package/dist/version.generated.d.ts +1 -1
  170. package/dist/version.generated.js +2 -2
  171. package/dist/version.generated.mjs +5 -1
  172. package/package.json +7 -6
  173. package/dist/lib/jsx/control-flow/flow.cjs +0 -1
  174. package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
  175. package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
  176. package/dist/lib/jsx/control-flow/flow.js +0 -627
  177. package/dist/lib/jsx/control-flow/flow.mjs +0 -0
  178. package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
  179. package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
  180. package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
  181. package/dist/lib/jsx/control-flow/for-flow.js +0 -1
  182. package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
@@ -1 +1,395 @@
1
- "use strict";var b=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var k=(n,t)=>{for(var e in t)b(n,e,{get:t[e],enumerable:!0})},H=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of L(t))!M.call(n,o)&&o!==e&&b(n,o,{get:()=>t[o],enumerable:!(r=O(t,o))||r.enumerable});return n};var V=n=>H(b({},"__esModule",{value:!0}),n);var U={};k(U,{TemplateParseError:()=>l,parseTemplate:()=>G});module.exports=V(U);var T=Symbol.for("fluixi.server-node"),$=Symbol.for("fluixi.dom.server-host"),D=globalThis,B=D[$]??={server:typeof document>"u",nodes:null};var R=1,F=3,I=8,y;y=T;var h=class{constructor(){this[y]=!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=F;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=I;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),o=e===void 0?!r:e;return o?this.add(t):this.remove(t),o}},p=class n extends h{constructor(e,r=!1){super();this.nodeType=R;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 o of this.childNodes)r.appendChild(o.cloneNode(!0));return r}};var j=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),q={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'"};function E(n){return n.replace(/&(#?\w+);/g,(t,e)=>q[e]??t)}var l=class extends Error{};function G(n,t=!1){let e=0,r=[],o=[],N=s=>{let a=o[o.length-1];a?a.appendChild(s):r.push(s)};for(;e<n.length;){let s=n.indexOf("<",e);if(s===-1){S(n.slice(e));break}if(s>e&&S(n.slice(e,s)),n.startsWith("<!--",s)){let a=n.indexOf("-->",s);if(a===-1)throw new l(`unterminated comment at ${s}`);N(new f(n.slice(s+4,a))),e=a+3;continue}if(n[s+1]==="/"){let a=n.indexOf(">",s);if(a===-1)throw new l(`unterminated closing tag at ${s}`);let u=n.slice(s+2,a).trim().toLowerCase(),d=o.pop();if(!d||d.localName!==u)throw new l(`</${u}> does not close <${d?.localName??"nothing"}>`);e=a+1;continue}e=C(s)}if(o.length>0)throw new l(`unclosed <${o[o.length-1].localName}>`);let x=r[0];if(r.length!==1||!(x instanceof p))throw new l(`expected exactly one root element, got ${r.length}`);return x;function S(s){s!==""&&N(new g(E(s)))}function C(s){let a=/[\s/>]/.exec(n.slice(s+1));if(!a)throw new l(`unterminated tag at ${s}`);let u=n.slice(s+1,s+1+a.index).toLowerCase(),d=new p(u,t),i=s+1+a.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 A=i;for(;i<n.length&&!/[\s=/>]/.test(n[i]);)i++;let c=n.slice(A,i);if(c==="")throw new l(`malformed attribute at ${i}`);if(n[i]==="="){if(n[i+1]!=='"')throw new l(`attribute ${c} must have a double-quoted value`);let v=n.indexOf('"',i+2);if(v===-1)throw new l(`unterminated value for ${c}`);d.setAttribute(c,E(n.slice(i+2,v))),i=v+1}else d.setAttribute(c,"")}return N(d),j.has(u)||o.push(d),i}}
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/dom/server/parse-template.ts
21
+ var parse_template_exports = {};
22
+ __export(parse_template_exports, {
23
+ TemplateParseError: () => TemplateParseError,
24
+ parseTemplate: () => parseTemplate
25
+ });
26
+ module.exports = __toCommonJS(parse_template_exports);
27
+
28
+ // src/lib/dom/server/host.ts
29
+ var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
30
+ var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
31
+ var realm = globalThis;
32
+ var state = realm[STATE] ??= {
33
+ server: typeof document === "undefined",
34
+ nodes: null
35
+ };
36
+
37
+ // src/lib/dom/server/nodes.ts
38
+ var NODE_ELEMENT = 1;
39
+ var NODE_TEXT = 3;
40
+ var NODE_COMMENT = 8;
41
+ var _a;
42
+ _a = SERVER_NODE;
43
+ var ServerNode = class {
44
+ constructor() {
45
+ // Brand the host.ts guards check for (lets them skip an instanceof on these classes).
46
+ this[_a] = true;
47
+ this.parentNode = null;
48
+ this.childNodes = [];
49
+ }
50
+ get firstChild() {
51
+ return this.childNodes[0] ?? null;
52
+ }
53
+ get lastChild() {
54
+ return this.childNodes[this.childNodes.length - 1] ?? null;
55
+ }
56
+ get nextSibling() {
57
+ const p = this.parentNode;
58
+ if (!p) return null;
59
+ const i = p.childNodes.indexOf(this);
60
+ return i >= 0 ? p.childNodes[i + 1] ?? null : null;
61
+ }
62
+ get previousSibling() {
63
+ const p = this.parentNode;
64
+ if (!p) return null;
65
+ const i = p.childNodes.indexOf(this);
66
+ return i > 0 ? p.childNodes[i - 1] ?? null : null;
67
+ }
68
+ get parentElement() {
69
+ return this.parentNode;
70
+ }
71
+ appendChild(child) {
72
+ if (child.parentNode) child.parentNode.removeChild(child);
73
+ child.parentNode = this;
74
+ this.childNodes.push(child);
75
+ return child;
76
+ }
77
+ insertBefore(child, ref) {
78
+ if (ref == null) return this.appendChild(child);
79
+ if (child.parentNode) child.parentNode.removeChild(child);
80
+ const i = this.childNodes.indexOf(ref);
81
+ child.parentNode = this;
82
+ if (i < 0) this.childNodes.push(child);
83
+ else this.childNodes.splice(i, 0, child);
84
+ return child;
85
+ }
86
+ removeChild(child) {
87
+ const i = this.childNodes.indexOf(child);
88
+ if (i >= 0) this.childNodes.splice(i, 1);
89
+ child.parentNode = null;
90
+ return child;
91
+ }
92
+ replaceChild(next, old) {
93
+ const i = this.childNodes.indexOf(old);
94
+ if (i >= 0) {
95
+ if (next.parentNode) next.parentNode.removeChild(next);
96
+ next.parentNode = this;
97
+ this.childNodes[i] = next;
98
+ old.parentNode = null;
99
+ }
100
+ return old;
101
+ }
102
+ // Event listeners are inert on the server.
103
+ addEventListener() {
104
+ }
105
+ removeEventListener() {
106
+ }
107
+ };
108
+ var ServerText = class _ServerText extends ServerNode {
109
+ constructor(value) {
110
+ super();
111
+ this.nodeType = NODE_TEXT;
112
+ this.data = value;
113
+ }
114
+ get nodeValue() {
115
+ return this.data;
116
+ }
117
+ set nodeValue(v) {
118
+ this.data = v == null ? "" : String(v);
119
+ }
120
+ get textContent() {
121
+ return this.data;
122
+ }
123
+ set textContent(v) {
124
+ this.data = v == null ? "" : String(v);
125
+ }
126
+ cloneNode() {
127
+ return new _ServerText(this.data);
128
+ }
129
+ };
130
+ var ServerComment = class _ServerComment extends ServerNode {
131
+ constructor(value) {
132
+ super();
133
+ this.nodeType = NODE_COMMENT;
134
+ this.data = value;
135
+ }
136
+ get nodeValue() {
137
+ return this.data;
138
+ }
139
+ set nodeValue(v) {
140
+ this.data = v == null ? "" : String(v);
141
+ }
142
+ cloneNode() {
143
+ return new _ServerComment(this.data);
144
+ }
145
+ };
146
+ var ServerStyle = class {
147
+ constructor() {
148
+ // declared keys are stored as own props; cssText holds a raw string blob.
149
+ this.cssText = "";
150
+ }
151
+ setProperty(name, value) {
152
+ this[name] = value;
153
+ }
154
+ removeProperty(name) {
155
+ delete this[name];
156
+ }
157
+ };
158
+ var ServerClassList = class {
159
+ constructor(el) {
160
+ this.el = el;
161
+ }
162
+ list() {
163
+ const c = this.el.getAttribute("class");
164
+ return c ? c.split(/\s+/).filter(Boolean) : [];
165
+ }
166
+ write(arr) {
167
+ if (arr.length) this.el.setAttribute("class", arr.join(" "));
168
+ else this.el.removeAttribute("class");
169
+ }
170
+ add(...names) {
171
+ const arr = this.list();
172
+ for (const n of names) if (!arr.includes(n)) arr.push(n);
173
+ this.write(arr);
174
+ }
175
+ remove(...names) {
176
+ this.write(this.list().filter((c) => !names.includes(c)));
177
+ }
178
+ contains(name) {
179
+ return this.list().includes(name);
180
+ }
181
+ toggle(name, force) {
182
+ const has = this.contains(name);
183
+ const on = force === void 0 ? !has : force;
184
+ if (on) this.add(name);
185
+ else this.remove(name);
186
+ return on;
187
+ }
188
+ };
189
+ var ServerElement = class _ServerElement extends ServerNode {
190
+ constructor(tag, isSVG = false) {
191
+ super();
192
+ this.nodeType = NODE_ELEMENT;
193
+ this.attributes = /* @__PURE__ */ new Map();
194
+ this.style = new ServerStyle();
195
+ this.classList = new ServerClassList(this);
196
+ /** raw HTML set via innerHTML: emitted verbatim, bypassing childNodes. */
197
+ this.rawHTML = null;
198
+ this.localName = tag.toLowerCase();
199
+ this.tagName = isSVG ? tag : tag.toUpperCase();
200
+ this.isSVG = isSVG;
201
+ this.namespaceURI = isSVG ? "http://www.w3.org/2000/svg" : null;
202
+ }
203
+ setAttribute(name, value) {
204
+ this.attributes.set(name, String(value));
205
+ }
206
+ removeAttribute(name) {
207
+ this.attributes.delete(name);
208
+ }
209
+ getAttribute(name) {
210
+ return this.attributes.has(name) ? this.attributes.get(name) : null;
211
+ }
212
+ hasAttribute(name) {
213
+ return this.attributes.has(name);
214
+ }
215
+ get id() {
216
+ return this.getAttribute("id") ?? "";
217
+ }
218
+ set id(v) {
219
+ if (v == null) this.removeAttribute("id");
220
+ else this.setAttribute("id", v);
221
+ }
222
+ // JSX_PROPERTIES: className/value/checked/selected/innerHTML/innerText/
223
+ // textContent/indeterminate/htmlFor flow through setProperty (element[k]=v).
224
+ get className() {
225
+ return this.getAttribute("class") ?? "";
226
+ }
227
+ set className(v) {
228
+ if (v == null) this.removeAttribute("class");
229
+ else this.setAttribute("class", v);
230
+ }
231
+ get htmlFor() {
232
+ return this.getAttribute("for") ?? "";
233
+ }
234
+ set htmlFor(v) {
235
+ if (v == null) this.removeAttribute("for");
236
+ else this.setAttribute("for", v);
237
+ }
238
+ set value(v) {
239
+ if (v == null) this.removeAttribute("value");
240
+ else this.setAttribute("value", String(v));
241
+ }
242
+ set checked(v) {
243
+ if (v) this.setAttribute("checked", "");
244
+ else this.removeAttribute("checked");
245
+ }
246
+ set selected(v) {
247
+ if (v) this.setAttribute("selected", "");
248
+ else this.removeAttribute("selected");
249
+ }
250
+ // indeterminate is a live-only DOM property with no HTML serialization.
251
+ set indeterminate(_v) {
252
+ }
253
+ get textContent() {
254
+ return this.childNodes.map((c) => c.textContent ?? "").join("");
255
+ }
256
+ set textContent(v) {
257
+ for (const c of this.childNodes) c.parentNode = null;
258
+ this.childNodes = [];
259
+ this.rawHTML = null;
260
+ if (v != null && v !== "") this.appendChild(new ServerText(String(v)));
261
+ }
262
+ set innerText(v) {
263
+ this.textContent = v;
264
+ }
265
+ set innerHTML(v) {
266
+ for (const c of this.childNodes) c.parentNode = null;
267
+ this.childNodes = [];
268
+ this.rawHTML = v == null ? "" : String(v);
269
+ }
270
+ cloneNode(deep = false) {
271
+ const el = new _ServerElement(this.localName, this.isSVG);
272
+ el.attributes = new Map(this.attributes);
273
+ el.style.cssText = this.style.cssText;
274
+ el.rawHTML = this.rawHTML;
275
+ if (deep) for (const c of this.childNodes) el.appendChild(c.cloneNode(true));
276
+ return el;
277
+ }
278
+ };
279
+
280
+ // src/lib/dom/server/parse-template.ts
281
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
282
+ "area",
283
+ "base",
284
+ "br",
285
+ "col",
286
+ "embed",
287
+ "hr",
288
+ "img",
289
+ "input",
290
+ "link",
291
+ "meta",
292
+ "param",
293
+ "source",
294
+ "track",
295
+ "wbr"
296
+ ]);
297
+ var ENTITIES = {
298
+ amp: "&",
299
+ lt: "<",
300
+ gt: ">",
301
+ quot: '"',
302
+ "#39": "'"
303
+ };
304
+ function unescape(text) {
305
+ return text.replace(/&(#?\w+);/g, (whole, name) => ENTITIES[name] ?? whole);
306
+ }
307
+ var TemplateParseError = class extends Error {
308
+ };
309
+ function parseTemplate(html, isSVG = false) {
310
+ let i = 0;
311
+ const roots = [];
312
+ const stack = [];
313
+ const append = (node) => {
314
+ const parent = stack[stack.length - 1];
315
+ if (parent) parent.appendChild(node);
316
+ else roots.push(node);
317
+ };
318
+ while (i < html.length) {
319
+ const lt = html.indexOf("<", i);
320
+ if (lt === -1) {
321
+ addText(html.slice(i));
322
+ break;
323
+ }
324
+ if (lt > i) addText(html.slice(i, lt));
325
+ if (html.startsWith("<!--", lt)) {
326
+ const end = html.indexOf("-->", lt);
327
+ if (end === -1) throw new TemplateParseError(`unterminated comment at ${lt}`);
328
+ append(new ServerComment(html.slice(lt + 4, end)));
329
+ i = end + 3;
330
+ continue;
331
+ }
332
+ if (html[lt + 1] === "/") {
333
+ const end = html.indexOf(">", lt);
334
+ if (end === -1) throw new TemplateParseError(`unterminated closing tag at ${lt}`);
335
+ const tag = html.slice(lt + 2, end).trim().toLowerCase();
336
+ const open = stack.pop();
337
+ if (!open || open.localName !== tag) {
338
+ throw new TemplateParseError(
339
+ `</${tag}> does not close <${open?.localName ?? "nothing"}>`
340
+ );
341
+ }
342
+ i = end + 1;
343
+ continue;
344
+ }
345
+ i = openTag(lt);
346
+ }
347
+ if (stack.length > 0) {
348
+ throw new TemplateParseError(`unclosed <${stack[stack.length - 1].localName}>`);
349
+ }
350
+ const root = roots[0];
351
+ if (roots.length !== 1 || !(root instanceof ServerElement)) {
352
+ throw new TemplateParseError(`expected exactly one root element, got ${roots.length}`);
353
+ }
354
+ return root;
355
+ function addText(raw) {
356
+ if (raw === "") return;
357
+ append(new ServerText(unescape(raw)));
358
+ }
359
+ function openTag(lt) {
360
+ const nameEnd = /[\s/>]/.exec(html.slice(lt + 1));
361
+ if (!nameEnd) throw new TemplateParseError(`unterminated tag at ${lt}`);
362
+ const tag = html.slice(lt + 1, lt + 1 + nameEnd.index).toLowerCase();
363
+ const el = new ServerElement(tag, isSVG);
364
+ let j = lt + 1 + nameEnd.index;
365
+ while (j < html.length) {
366
+ while (j < html.length && /\s/.test(html[j])) j++;
367
+ if (html[j] === ">") {
368
+ j++;
369
+ break;
370
+ }
371
+ if (html[j] === "/" && html[j + 1] === ">") {
372
+ j += 2;
373
+ break;
374
+ }
375
+ const attrStart = j;
376
+ while (j < html.length && !/[\s=/>]/.test(html[j])) j++;
377
+ const name = html.slice(attrStart, j);
378
+ if (name === "") throw new TemplateParseError(`malformed attribute at ${j}`);
379
+ if (html[j] === "=") {
380
+ if (html[j + 1] !== '"') {
381
+ throw new TemplateParseError(`attribute ${name} must have a double-quoted value`);
382
+ }
383
+ const close = html.indexOf('"', j + 2);
384
+ if (close === -1) throw new TemplateParseError(`unterminated value for ${name}`);
385
+ el.setAttribute(name, unescape(html.slice(j + 2, close)));
386
+ j = close + 1;
387
+ } else {
388
+ el.setAttribute(name, "");
389
+ }
390
+ }
391
+ append(el);
392
+ if (!VOID_ELEMENTS.has(tag)) stack.push(el);
393
+ return j;
394
+ }
395
+ }
@@ -5,7 +5,7 @@
5
5
  * compiler's `serializeStatic`, which emits a narrow, known grammar: lowercase tag names,
6
6
  * double-quoted attribute values, entity-escaped text, void elements left unclosed, no
7
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
8
+ * controlled is what makes this a small total function instead of a spec project, and
9
9
  * the round-trip test pins the two together, so the grammar cannot drift on one side.
10
10
  *
11
11
  * A hole-free template never reaches here: it is carried verbatim as a `ServerRaw` node,
@@ -5,7 +5,7 @@
5
5
  * compiler's `serializeStatic`, which emits a narrow, known grammar: lowercase tag names,
6
6
  * double-quoted attribute values, entity-escaped text, void elements left unclosed, no
7
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
8
+ * controlled is what makes this a small total function instead of a spec project, and
9
9
  * the round-trip test pins the two together, so the grammar cannot drift on one side.
10
10
  *
11
11
  * A hole-free template never reaches here: it is carried verbatim as a `ServerRaw` node,
@@ -13,7 +13,7 @@
13
13
  * to produce real nodes for the hole content to be inserted into.
14
14
  */
15
15
  import { ServerComment, ServerElement, ServerText } from './nodes.js';
16
- /** Elements the HTML parser closes itself they never have children. */
16
+ /** Elements the HTML parser closes itself, they never have children. */
17
17
  const VOID_ELEMENTS = new Set([
18
18
  'area',
19
19
  'base',
@@ -105,7 +105,7 @@ export function parseTemplate(html, isSVG = false) {
105
105
  return;
106
106
  append(new ServerText(unescape(raw)));
107
107
  }
108
- /** Consume `<tag attr="v" …>` starting at `lt`, returning the offset just past it. */
108
+ /** Consume `<tag attr="v" ...>` starting at `lt`, returning the offset just past it. */
109
109
  function openTag(lt) {
110
110
  const nameEnd = /[\s/>]/.exec(html.slice(lt + 1));
111
111
  if (!nameEnd)
@@ -132,7 +132,7 @@ export function parseTemplate(html, isSVG = false) {
132
132
  throw new TemplateParseError(`malformed attribute at ${j}`);
133
133
  if (html[j] === '=') {
134
134
  // The serializer always quotes, so an unquoted value means the input did not
135
- // come from it refuse rather than guess.
135
+ // come from it: refuse rather than guess.
136
136
  if (html[j + 1] !== '"') {
137
137
  throw new TemplateParseError(`attribute ${name} must have a double-quoted value`);
138
138
  }