@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/lib/dom/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;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R,GAAG,IAAI,EAAE,CAAC,GACT,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CA8BlD;AAQD,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAe1D;AAMD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,QAgDpE;AAKD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMjD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAOnD;AAMD,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAE9D;AAED,mGAAmG;AACnG,wBAAgB,MAAM,CAAC,CAAC,EACtB,OAAO,EAAE,CAAC,EACV,SAAS,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,GAAG,GACZ,MAAM,IAAI,CAuCZ"}
|
package/dist/lib/dom/runtime.js
CHANGED
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { isSignal, } from '@fluixi/reactive/signal';
|
|
16
16
|
import { JSX_PROPERTIES, setAttribute, applyElementProp, SVG_NAMESPACE } from './utils.js';
|
|
17
|
+
import { stampVersions, warnOnVersionSkew } from './versions.js';
|
|
17
18
|
import { isComponent } from '../component/modifiers.js';
|
|
18
19
|
// Reactive primitives come straight from the signal core (the globalThis-singleton graph makes
|
|
19
20
|
// this duplication-safe). The integration bridge is only for framework-provided glue that is
|
|
20
21
|
// NOT in the reactive core (e.g. createComponent).
|
|
21
22
|
import { batch, createEffect, createRenderEffect, createRoot, onCleanup, readChildren } from '@fluixi/reactive/signal';
|
|
22
23
|
import { isServer, getServerNodes, isDomNode, isDomElement, isDomText, } from './server/host.js';
|
|
23
|
-
import { hydration, getHydrationWalker, isAdopted, ascendPast, } from './hydration-state.js';
|
|
24
|
+
import { hydration, getHydrationWalker, isAdopted, runHydrationAt, ascendPast, } from './hydration-state.js';
|
|
24
25
|
function getElementFingerprint(el) {
|
|
25
26
|
const parts = [];
|
|
26
27
|
while (el && el.nodeType === 1) {
|
|
@@ -210,6 +211,100 @@ export function createTemplate(html, isSVG = false) {
|
|
|
210
211
|
templateCache.set(html, template);
|
|
211
212
|
return template;
|
|
212
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* A node for a compiler-emitted static template, built the way the current environment
|
|
216
|
+
* needs it.
|
|
217
|
+
*
|
|
218
|
+
* The three cases mirror {@link createNativeElement}, which is the point: a template has
|
|
219
|
+
* to behave like the elements it replaces, or it works only in client-rendered apps —
|
|
220
|
+
* which is exactly how it failed before this existed.
|
|
221
|
+
*
|
|
222
|
+
* - **server** — carried as text and written out verbatim. Parsing it into elements
|
|
223
|
+
* only to serialize them straight back would be pure cost.
|
|
224
|
+
* - **hydrating** — adopt the server's existing subtree and skip past it. The subtree
|
|
225
|
+
* is inert, so there is nothing inside to wire up.
|
|
226
|
+
* - **client** — parse once (cached by HTML) and clone per instance.
|
|
227
|
+
*/
|
|
228
|
+
export function templateNode(html, tag, holes = false, isSVG = false) {
|
|
229
|
+
if (isServer) {
|
|
230
|
+
// With holes the server needs real nodes for the hole content to be inserted into;
|
|
231
|
+
// without them the string can be written out untouched, which is strictly cheaper.
|
|
232
|
+
const nodes = getServerNodes();
|
|
233
|
+
return (holes ? nodes.parseTemplate(html, isSVG) : nodes.createRaw(html));
|
|
234
|
+
}
|
|
235
|
+
if (hydration.active) {
|
|
236
|
+
// Adopt the server's root either way. With holes the generated walk reaches them
|
|
237
|
+
// through the adopted tree, whose structure matches the template by construction.
|
|
238
|
+
const node = getHydrationWalker()?.hydrateStatic(tag);
|
|
239
|
+
if (node)
|
|
240
|
+
return node;
|
|
241
|
+
}
|
|
242
|
+
return cloneTemplate(createTemplate(html, isSVG), isSVG).firstChild;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Evaluate a hole's content with the hydration cursor placed at what the server rendered
|
|
246
|
+
* for *that hole*.
|
|
247
|
+
*
|
|
248
|
+
* Without this, only the hole's top level adopts. `templateNode` moves the cursor past the
|
|
249
|
+
* whole template — the subtree is inert, so there is nothing in it to walk — which leaves
|
|
250
|
+
* the cursor in the wrong place for anything the hole builds internally. A component in a
|
|
251
|
+
* hole would then recreate its own elements: no duplication, but every server node thrown
|
|
252
|
+
* away, which is most of what hydration is for.
|
|
253
|
+
*
|
|
254
|
+
* The markers make the position exact: the content starts immediately after `start`.
|
|
255
|
+
*/
|
|
256
|
+
export function holeScope(start, produce) {
|
|
257
|
+
if (!hydration.active)
|
|
258
|
+
return produce();
|
|
259
|
+
// `produce` is called with the cursor already placed, because the value may be built
|
|
260
|
+
// eagerly — `props.children` is a getter, and reading it constructs its nodes there and
|
|
261
|
+
// then. Wrapping the result instead would be too late: the DOM would already exist,
|
|
262
|
+
// built against whatever cursor happened to be current, and the server's nodes would be
|
|
263
|
+
// left behind as duplicates.
|
|
264
|
+
const value = runHydrationAt(start.nextSibling, produce);
|
|
265
|
+
// A memo or accessor builds nothing until it is read, which happens inside `insert`'s
|
|
266
|
+
// effect — so it needs the cursor placed again at that moment. The guard matters: once
|
|
267
|
+
// hydration is over, later updates must render normally rather than re-enter it.
|
|
268
|
+
if (typeof value === 'function') {
|
|
269
|
+
const accessor = value;
|
|
270
|
+
return ((...args) => hydration.active
|
|
271
|
+
? runHydrationAt(start.nextSibling, () => accessor(...args))
|
|
272
|
+
: accessor(...args));
|
|
273
|
+
}
|
|
274
|
+
return value;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* The closing marker for a hole opened at `start`.
|
|
278
|
+
*
|
|
279
|
+
* Found by scanning rather than by position: on a fresh clone it is the very next node,
|
|
280
|
+
* but the server's DOM has the rendered content in between, and hydration walks that DOM.
|
|
281
|
+
* Scanning is what makes one set of generated references work in both.
|
|
282
|
+
*/
|
|
283
|
+
export function holeEnd(start) {
|
|
284
|
+
for (let n = start.nextSibling; n; n = n.nextSibling) {
|
|
285
|
+
if (n.nodeType === 8 && n.data === 'fx/')
|
|
286
|
+
return n;
|
|
287
|
+
}
|
|
288
|
+
/* c8 ignore next 2 */
|
|
289
|
+
throw new Error('[fluixi] template hole is missing its closing marker');
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The nodes a hole already contains, for `insert` to reconcile against.
|
|
293
|
+
*
|
|
294
|
+
* On a fresh clone the markers are adjacent and this is empty, so `insert` builds the
|
|
295
|
+
* content. When hydrating, the server's rendered content sits between them and is handed
|
|
296
|
+
* back — `insertExpression` then reuses those nodes (setting `.data` on a text node
|
|
297
|
+
* rather than creating one), which is what adoption means here.
|
|
298
|
+
*
|
|
299
|
+
* Paired markers are what make this exact: a hole's content is *by definition* the nodes
|
|
300
|
+
* between its own two markers, with no dependence on the hydration cursor's position.
|
|
301
|
+
*/
|
|
302
|
+
export function holeContent(start, end) {
|
|
303
|
+
const nodes = [];
|
|
304
|
+
for (let n = start.nextSibling; n && n !== end; n = n.nextSibling)
|
|
305
|
+
nodes.push(n);
|
|
306
|
+
return nodes;
|
|
307
|
+
}
|
|
213
308
|
export function cloneTemplate(template, isSVG = false) {
|
|
214
309
|
const clone = template.content.cloneNode(true);
|
|
215
310
|
if (isSVG)
|
|
@@ -1537,6 +1632,10 @@ export function render(element, container, context) {
|
|
|
1537
1632
|
if (!hydration.active) {
|
|
1538
1633
|
container.textContent = '';
|
|
1539
1634
|
}
|
|
1635
|
+
// Which build is running, on the element and as `window.Fluixi`. Stamped here
|
|
1636
|
+
// rather than in core's render so the hydrate path gets it too.
|
|
1637
|
+
stampVersions(container);
|
|
1638
|
+
warnOnVersionSkew();
|
|
1540
1639
|
// console.log('inserting', element);
|
|
1541
1640
|
insert(container, element);
|
|
1542
1641
|
return;
|
package/dist/lib/dom/runtime.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isSignal as g}from"@fluixi/reactive/signal";var _="http://www.w3.org/2000/svg";function re(e){return e.localName.includes("-")}function D(e,t,n,o=!1){if(n==null){e.removeAttribute(t);return}if(re(e)){e[t]=n;return}N(e,t,n,o)}var F=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function N(e,t,n,o=!1){if(n==null||n===!1){e.removeAttribute(t);return}if(n===!0){e.setAttribute(t,"");return}if(typeof n=="object"){e.setAttribute(t,JSON.stringify(n));return}e.setAttribute(t,String(n))}var me=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function h(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as Y,createEffect as A,createRenderEffect as d,createRoot as fe,onCleanup as w,readChildren as ae}from"@fluixi/reactive/signal";var v=typeof document>"u";var W=Symbol.for("fluixi.server-node"),q=null;function I(){if(!q)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return q}function S(e){return e!=null&&e[W]===!0?!0:typeof Node<"u"&&e instanceof Node}function G(e){return e!=null&&e[W]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function X(e){return e!=null&&e[W]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var x={active:!1,cursor:null,parents:[]},se=null;function k(){return se}function V(e,t){return x.active&&t.parentNode===e}function z(e){let t=x.parents.lastIndexOf(e);t!==-1&&(x.parents.length=t),x.cursor=e.nextSibling}function ue(e){let t=[];for(;e&&e.nodeType===1;){let n=e.tagName.toLowerCase();if(e.id){n+=`#${e.id}`,t.unshift(n);break}e.getAttribute("data-id")&&(n+=`[data-id="${e.getAttribute("data-id")}"]`);let o=0,f=e;for(;f=f.previousElementSibling;)f.tagName===e.tagName&&o++;n+=`:nth-of-type(${o+1})`,t.unshift(n),e=e.parentElement}return t.join(">")}function le(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return`el_${Math.abs(t)}`}function Me(e){return le(ue(e))}var Re=()=>"xxyxxxxxxy-4xx8".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),ce={};var J=new Map,C=new Set,j=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function Z(e){if(!v)for(let t of e)C.has(t)||j.has(t)||(C.add(t),document.addEventListener(t,de))}function de(e){let t=`$$${e.type}`,n=e.composedPath&&e.composedPath()[0]||e.target;for(;n;){let o=n[t];if(o&&!n.disabled&&(o(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Element?n.host:n.parentNode}}function ye(e,t,n){if(e[`$$${t}`]=n,j.has(t)){let o=`__fx_${t}`;if(!e[o]){let f=a=>{e[`$$${t}`]?.(a)};e.addEventListener(t,f),e[o]=f}return}C.has(t)||Z([t])}function U(e,t){delete e[`$$${t}`];let n=`__fx_${t}`,o=e[n];o&&(e.removeEventListener(t,o),delete e[n])}function Oe(e){return!j.has(e)}function He(e){return typeof e=="function"}function b(e,t=!1){if(v)return I().createText(e);if(x.active&&!t){let n=k()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}function je(e,t=!1){if(v)return I().createElement(e,t);if(x.active){let n=k()?.hydrateElement(e);if(n)return n}return t?document.createElementNS(_,e):document.createElement(e)}function $e(e,t=!1){let n=J.get(e);if(n)return n;let o=document.createElement("template");return t?o.innerHTML=`<svg>${e}</svg>`:o.innerHTML=e,J.set(e,o),o}function _e(e,t=!1){let n=e.content.cloneNode(!0);return t?n.firstChild:n}function pe(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?pe(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}function De(e){return typeof e!="function"?null:e._name||e.name||"anonymous"}function Fe(e){if(g(e)||h(e)||typeof e!="function")return e;let t=e();for(;typeof t=="function"&&!g(t)&&!h(t);)t=t();return t}var E=0,ge=200;function he(e,t,n,o,f){let a=o,s=new Map;return d(()=>{let r;if(h(e)&&!g(e)){if(!s.has(e)){E++;try{let i=e();s.set(e,i)}finally{E--}}for(r=s.get(e);typeof r=="function"&&g(r);)r=r()}else for(r=e();typeof r=="function"&&g(r);)r=r();{let i=0;for(;typeof r=="function"&&i++<50;)if(h(r)){if(!s.has(r)){let u=r;E++;try{let l=u();s.set(u,l)}finally{E--}}r=s.get(r)}else if(g(r))r=r();else if(r=r(),typeof r!="function"||!g(r)&&!h(r))break}E++;try{a=P(t,r,n,a,s),f(a)}finally{E--}})}function Q(e,t,n,o){if(E>ge)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=b("",!0),e.appendChild(n));let f=o??null,a=i=>Array.isArray(i)&&i.some(u=>typeof u=="function"),s=i=>typeof i=="function"?i:()=>i;if(typeof t!="function"&&!a(t)){E++;try{f=P(e,t,n,null)}finally{E--}return()=>f}let r=he(s(t),e,n,f,i=>{f=i});return()=>(r?.(),f)}function P(e,t,n,o,f){if(t==null||typeof t=="boolean")return T(e,o,n);if(typeof t=="function")for(;typeof t=="function";)t=t();if(t==null||typeof t=="boolean")return T(e,o,n);if(L(t)){let s=b("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(s,o[0]),T(e,o.slice(1),n)):p(e,s,n):o?e.replaceChild(s,o):p(e,s,n),t.then(r=>{s.parentNode===e&&P(e,r,s.nextSibling,s)}).catch(r=>{console.error("Error resolving promise in insertExpression:",r)}),s}let a=typeof t;if(a==="string"||a==="number"){if(a==="number"&&(t=String(t)),Array.isArray(o)){if(o.length===0){let r=b(t);return p(e,r,n),r}if(o.length===1&&o[0].nodeType===3)return o[0].data=t,o;o=T(e,o,n)}if(o&&X(o))return o.data=t,o;let s=b(t);return o&&o.parentNode===e?e.replaceChild(s,o):V(e,s)||p(e,s,n),s}if(S(t))return V(e,t)?(z(t),t):Array.isArray(o)?(o.length===0?p(e,t,n):o[0].parentNode===e?(e.replaceChild(t,o[0]),T(e,o.slice(1),n)):p(e,t,n),t):(o?o!==t&&(o.parentNode===e?e.replaceChild(t,o):p(e,t,n)):p(e,t,n),t);if(Array.isArray(t)){let s=[],r=Array.isArray(o)?o:o?[o]:[],i=[];m(t,s,e,n,!0,f,i);let u=xe(e,r,s,n);for(let l of i){let c=Q(e,l.sig,l.marker);w(()=>{T(e,c()),l.marker.parentNode===e&&e.removeChild(l.marker)})}return u}if(a==="object"&&t!==null&&typeof t=="object"){let s=t;if("type"in s&&"props"in s){let r=s;if(typeof r.type=="function"){let i=r.type(r.props||{});return P(e,i,n,o)}}}return T(e,o,n)}function m(e,t,n,o,f=!0,a,s){for(let r=0;r<e.length;r++){let i=e[r];if(!(i==null||typeof i=="boolean")){for(;typeof i=="function"&&!L(i)&&!g(i)&&!h(i)&&(i=i(),!(i==null||typeof i=="boolean")););if(!(i==null||typeof i=="boolean")){if(typeof i=="function"){let u;for(h(i)&&!g(i)?(a||(a=new Map),a.has(i)||a.set(i,i()),u=a.get(i)):u=i();typeof u=="function"&&!L(u)&&!g(u)&&!h(u);)a||(a=new Map),a.has(u)||a.set(u,u()),u=a.get(u);if(u==null||typeof u=="boolean")continue;if(typeof u=="function"){if(g(u)){if(s){let c=b("",!0);t.push(c),s.push({marker:c,sig:u});continue}let l=u();for(;typeof l=="function"&&g(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?m(l,t,n,o,f,a):m([l],t,n,o,f,a);continue}continue}Array.isArray(u)?m(u,t,n,o,f,a,s):m([u],t,n,o,f,a,s);continue}if(L(i)){let u=b("",!0);t.push(u),i.then(l=>{if(u.parentNode){let c=[];if(m([l],c,u.parentNode,void 0,!1,a),c.length>0){u.parentNode.replaceChild(c[0],u);for(let y=1;y<c.length;y++)u.parentNode?.insertBefore(c[y],c[y-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(i)){m(i,t,n,o,f,a,s);continue}if(S(i)){t.push(i);continue}if(typeof i=="object"&&i!==null&&"type"in i&&"props"in i){let u=i;if(typeof u.type=="function"){let l=u.type(u.props||{});Array.isArray(l)?m(l,t,n,o,!1,a):m([l],t,n,o,!1,a);continue}}if(typeof i=="string"||typeof i=="number"){let u=String(i);if(u.trim()===""&&u!==" ")continue;t.push(b(u));continue}t.push(b(String(i)))}}}}function xe(e,t,n,o){for(let c=0;c<n.length;c++)n[c].parentNode!==null&&n[c].parentNode!==e&&(n=n.slice(),n[c]=n[c].cloneNode(!0));let f=n.length,a=t.length,s=f,r=0,i=0,u=a>0?t[a-1].nextSibling??void 0:o,l=null;for(;r<a||i<s;){if(t[r]===n[i]){r++,i++;continue}for(;a>r&&s>i&&t[a-1]===n[s-1];)a--,s--;if(a===r){let c=s<f?i?n[i-1].nextSibling??void 0:n[s-i]:u;for(;i<s;)p(e,n[i++],c)}else if(s===i)for(;r<a;)(!l||!l.has(t[r]))&&t[r].parentNode===e&&e.removeChild(t[r]),r++;else if(t[r]===n[s-1]&&n[i]===t[a-1]){let c=t[--a].nextSibling;p(e,n[i++],t[r++].nextSibling),p(e,n[--s],c),t[a]=t[r-1]}else{if(!l){l=new Map;let y=i;for(;y<s;)l.set(n[y],y++)}let c=l.get(t[r]);if(c!=null)if(i<c&&c<s){let y=r,$=1;for(;++y<a&&y<s&&!(!l.has(t[y])||l.get(t[y])!==c+$);)$++;if($>c-i){let ie=t[r];for(;i<c;)p(e,n[i++],ie)}else t[r].parentNode===e?e.replaceChild(n[i++],t[r++]):(p(e,n[i++],u),r++)}else r++;else t[r].parentNode===e&&e.removeChild(t[r]),r++}}return n}function T(e,t,n){if(t)if(Array.isArray(t))for(let o=0;o<t.length;o++)t[o].parentNode===e&&e.removeChild(t[o]);else t.parentNode===e&&e.removeChild(t);return null}function p(e,t,n){x.active&&t.parentNode===e||(n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t))}function M(e,t,n){n==null?delete e[t]:e[t]=n}function ee(e,t,n){let o=n,f;return Array.isArray(n)&&(o=n[0],f=n[1]),typeof o!="function"?()=>{}:(e.addEventListener(t,o,f),()=>e.removeEventListener(t,o,f))}function te(e,t){let n=(o,f)=>{typeof o=="function"&&o(e,f??(()=>{}))};if(typeof t=="function"){n(t);return}if(Array.isArray(t)){if(typeof t[0]=="function"){n(t[0],t[1]);return}for(let o of t)Array.isArray(o)?n(o[0],o[1]):n(o)}}function K(e,t,n,o=!1){return typeof n!="function"?(N(e,t,n,o),()=>{}):d(()=>{let f=typeof n=="function"?n():n;N(e,t,f,o)})}function B(e,t,n){return typeof n!="function"?(M(e,t,n),()=>{}):d(()=>{let o=typeof n=="function"?n():n;M(e,t,o)})}function ne(e,t,n){return typeof n!="function"?(N(e,t,!!n),()=>{}):d(()=>{let o=n();N(e,t,!!o)})}function R(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){d(()=>R(e,t()));return}if(typeof t=="string"){e.setAttribute("class",t);return}if(Array.isArray(t)){e.setAttribute("class",t.filter(Boolean).join(" "));return}if(typeof t=="object"){let n=Object.keys(t).filter(o=>{let f=t[o];return typeof f=="function"?f():!!f}).join(" ");e.setAttribute("class",n);return}e.setAttribute("class",String(t))}function O(e,t,n){if(!(!t||typeof t!="object"))for(let o in t){let f=t[o],a=o.split(/\s+/).filter(Boolean);if(typeof f=="function"&&n)n.push(d(()=>{let s=!!f();for(let r of a)e.classList.toggle(r,s)}));else{let s=!!(typeof f=="function"?f():f);for(let r of a)e.classList.toggle(r,s)}}}function H(e,t){let n=t;for(;typeof n=="function";)n=n();if(n==null){e.removeAttribute("style");return}if(typeof n=="string"){e.style.cssText=n;return}if(typeof n=="object")for(let o in n){let f=n[o];f==null?e.style[o]="":e.style[o]=f}}function We(e){let{element:t,props:n,prevProps:o=ce,isSVG:f=!1,skipChildren:a=!1}=e;if(!t||!G(t))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!n)return console.warn("[spread] Warning: props is undefined!"),()=>{};let s=f||t.namespaceURI===_,r=[];for(let i in n){if(a&&i==="children")continue;let u=n[i],l=o[i];if(u===l)continue;if(i==="ref"){oe(u,t);continue}if(i==="use"){te(t,u);continue}if(i.startsWith("on:")){r.push(ee(t,i.slice(3),u));continue}if(i.startsWith("prop:")){r.push(B(t,i.slice(5),u));continue}if(i.startsWith("attr:")){r.push(K(t,i.slice(5),u,s));continue}if(i.startsWith("bool:")){r.push(ne(t,i.slice(5),u));continue}if(i==="class"||i==="className"){typeof u=="function"?r.push(d(()=>R(t,u()))):R(t,u);continue}if(i==="classList"){typeof u=="function"?r.push(d(()=>O(t,u()))):O(t,u,r);continue}if(i==="style"){typeof u=="function"?r.push(d(()=>H(t,u()))):H(t,u);continue}if(i.startsWith("on")){let y=i.slice(2).toLowerCase();l&&U(t,y),u&&ye(t,y,u);continue}let c=F.has(i)||!s&&i in t;typeof u=="function"?r.push(c?B(t,i,u):K(t,i,u,s)):r.push(d(()=>c?M(t,i,n[i]):N(t,i,n[i],s)))}for(let i in o)if(!(i in n))if(i.startsWith("on")){let u=i.slice(2).toLowerCase();U(t,u)}else F.has(i)?M(t,i,null):t.removeAttribute(i);return()=>{r.forEach(i=>i())}}function Ie(e,t,n=!1){for(let o in t){let f=t[o];if(o==="ref"){oe(f,e);continue}if(o!=="children"){if(o==="use"){te(e,f);continue}if(o.startsWith("on:")){ee(e,o.slice(3),f);continue}if(o.startsWith("prop:")){B(e,o.slice(5),f);continue}if(o.startsWith("attr:")){K(e,o.slice(5),f,n);continue}if(o.startsWith("bool:")){ne(e,o.slice(5),f);continue}if(o.startsWith("on")&&o.length>2){let a=o.slice(2).toLowerCase();if(typeof f=="function")if(j.has(a)){e[`$$${a}`]=f;let s=`__fx_${a}`;if(!e[s]){let r=i=>{e[`$$${a}`]?.(i)};e.addEventListener(a,r),e[s]=r}}else e[`$$${a}`]=f,C.has(a)||Z([a]);continue}if(o==="class"||o==="className"){R(e,f);continue}if(o==="classList"){typeof f=="function"?d(()=>O(e,f())):O(e,f);continue}if(o==="style"){typeof f=="function"?d(()=>H(e,f())):H(e,f);continue}if(o==="innerHTML"){if(typeof f=="function"){let a=A(()=>{let s=f();for(;typeof s=="function";)s=s();e.innerHTML=s});w(()=>a())}else e.innerHTML=f;continue}if(o==="value"&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")){if(typeof f=="function"){let a=A(()=>{let s=f();for(;typeof s=="function"&&s.length===0;)s=s();document.activeElement!==e&&(e.value=s??"")});w(()=>{a()})}else d(()=>{document.activeElement!==e&&(e.value=t[o]??"")});continue}if(o==="checked"&&e.tagName==="INPUT"){if(typeof f=="function"){let a=A(()=>{let s=f();for(;typeof s=="function"&&s.length===0;)s=s();document.activeElement!==e&&(e.checked=s??"")});w(()=>{a()})}else d(()=>{document.activeElement!==e&&(e.checked=t[o]??"")});continue}if(o==="value"&&e.tagName==="SELECT"){if(typeof f=="function"){let a=!0,s=A(()=>{let r=f();for(;typeof r=="function"&&r.length===0;)r=r();a?(a=!1,queueMicrotask(()=>{e.value=r??""})):e.value=r??""});w(()=>{s()})}else{let a=!0;d(()=>{let s=t[o];a?(a=!1,queueMicrotask(()=>{e.value=s??""})):e.value=s??""})}continue}if(typeof f=="function"){let a=A(()=>{let s=f();for(;typeof s=="function"&&s.length===0;)s=s();D(e,o,s,n)});w(()=>{a()})}else d(()=>D(e,o,t[o],n))}}}function ke(...e){let t=o=>{for(let f=e.length-1;f>=0;f--){let a=e[f];if(a&&o in a&&a[o]!==void 0)return a[o]}},n=o=>{for(let f of e)if(f&&o in f)return!0;return!1};return new Proxy({},{get:(o,f)=>t(f),has:(o,f)=>n(f),ownKeys:()=>{let o=new Set;for(let f of e)if(f)for(let a of Reflect.ownKeys(f))o.add(a);return[...o]},getOwnPropertyDescriptor:(o,f)=>n(f)?{enumerable:!0,configurable:!0,get:()=>t(f)}:void 0})}function Ve(e,...t){let n=new Set;for(let s of t)for(let r of s)n.add(r);let o=s=>({enumerable:!0,configurable:!0,get:()=>e[s]}),f=t.map(s=>{let r=new Set(s);return new Proxy({},{get:(i,u)=>r.has(u)?e[u]:void 0,has:(i,u)=>r.has(u)&&u in e,ownKeys:()=>Array.from(r).filter(i=>i in e),getOwnPropertyDescriptor:(i,u)=>r.has(u)&&u in e?o(u):void 0})}),a=new Proxy({},{get:(s,r)=>n.has(r)?void 0:e[r],has:(s,r)=>!n.has(r)&&r in e,ownKeys:()=>Reflect.ownKeys(e).filter(s=>!n.has(s)),getOwnPropertyDescriptor:(s,r)=>!n.has(r)&&r in e?o(r):void 0});return[...f,a]}function oe(e,t){if(e){if(S(e)){let n=t,o=e;if(!n)return;typeof n=="function"?n(o):typeof n=="object"&&"current"in n&&(n.current=o);return}typeof e=="function"?e(t):typeof e=="object"&&"current"in e&&(e.current=t)}}function Ke(e,t,n){let o=t||document.body,f=ae(()=>e),a=[];return Y(()=>{let s=d(()=>{let r=f();Array.isArray(r)?(r.forEach(i=>o.appendChild(i)),a.push(()=>{r.forEach(i=>{i.parentNode===o&&o.removeChild(i)})})):S(r)&&(o.appendChild(r),a.push(()=>{r.parentNode===o&&o.removeChild(r)}))});a.push(s),w(()=>{a.forEach(r=>r())})}),null}function Be(e){return typeof e=="string"&&e.toLowerCase()===e}function qe(e){return e==="svg"||e==="path"||e==="circle"||e==="rect"||e==="line"||e==="polygon"||e==="polyline"||e==="ellipse"||e==="g"||e==="defs"||e==="clipPath"||e==="text"}function Ge(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function L(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function Xe(e){return typeof e=="function"&&e.length===0&&g(e)}function ze(e,t,n){if(!t)throw new Error("Container element is required");let o,f,a=[];return fe(s=>{Y(()=>{x.active||(t.textContent=""),Q(t,e)}),f=s}),()=>{f?.(),o?.(),a.forEach(s=>s()),t.textContent=""}}export{ye as addDelegatedEventListener,ee as addNativeEventListener,Ie as applyProps,te as applyUse,T as cleanChildren,_e as cloneTemplate,je as createNativeElement,Ke as createPortal,$e as createTemplate,Z as delegateEvents,Ge as escapeHTML,De as fnName,Re as generateID,Me as getStableElementId,oe as handleRef,Q as insert,P as insertExpression,Xe as isAccessor,Oe as isDelegatedEvent,He as isFunction,Be as isNativeElement,L as isPromise,qe as isSVGElement,Fe as iterateFn,pe as makeArrayFlat,ke as mergeProps,U as removeDelegatedEventListener,ze as render,O as setClassList,R as setClassName,K as setDynamicAttribute,ne as setDynamicBoolAttribute,B as setDynamicProperty,M as setProperty,H as setStyle,Ve as splitProps,We as spread};
|
|
1
|
+
import{isSignal as m}from"@fluixi/reactive/signal";var k="http://www.w3.org/2000/svg";function ue(e){return e.localName.includes("-")}function I(e,t,n,o=!1){if(n==null){e.removeAttribute(t);return}if(ue(e)){e[t]=n;return}T(e,t,n,o)}var V=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function T(e,t,n,o=!1){if(n==null||n===!1){e.removeAttribute(t);return}if(n===!0){e.setAttribute(t,"");return}if(typeof n=="object"){e.setAttribute(t,JSON.stringify(n));return}e.setAttribute(t,String(n))}var Ae=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;var z="1.0.0-alpha.71";import{VERSION as ce}from"@fluixi/reactive";var x={dom:z,reactive:ce};function X(e){x.core&&e.setAttribute("fluixi",x.core),e.setAttribute("fx-dom",x.dom),e.setAttribute("fx-reactive",x.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=x)}function J(){let e=[x.core,x.dom,x.reactive].filter(t=>t!==void 0);new Set(e).size<=1||console.warn(`[fluixi] package versions disagree — core ${x.core??"(absent)"}, dom ${x.dom}, reactive ${x.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\`.`)}function h(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as ne,createEffect as C,createRenderEffect as p,createRoot as pe,onCleanup as S,readChildren as ye}from"@fluixi/reactive/signal";var v=typeof document>"u";var W=Symbol.for("fluixi.server-node"),U=null;function L(){if(!U)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return U}function A(e){return e!=null&&e[W]===!0?!0:typeof Node<"u"&&e instanceof Node}function Y(e){return e!=null&&e[W]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function Z(e){return e!=null&&e[W]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var d={active:!1,cursor:null,parents:[]},de=null;function P(){return de}function K(e,t){return d.active&&t.parentNode===e}function Q(e){let t=d.parents.lastIndexOf(e);t!==-1&&(d.parents.length=t),d.cursor=e.nextSibling}function B(e,t){if(!e||e.parentNode==null)return t();let n=d.active,o=d.cursor,s=d.parents;d.active=!0,d.cursor=e,d.parents=[];try{return t()}finally{d.active=n,d.cursor=o,d.parents=s}}function ge(e){let t=[];for(;e&&e.nodeType===1;){let n=e.tagName.toLowerCase();if(e.id){n+=`#${e.id}`,t.unshift(n);break}e.getAttribute("data-id")&&(n+=`[data-id="${e.getAttribute("data-id")}"]`);let o=0,s=e;for(;s=s.previousElementSibling;)s.tagName===e.tagName&&o++;n+=`:nth-of-type(${o+1})`,t.unshift(n),e=e.parentElement}return t.join(">")}function me(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return`el_${Math.abs(t)}`}function Ke(e){return me(ge(e))}var Be=()=>"xxyxxxxxxy-4xx8".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),xe={};var ee=new Map,R=new Set,D=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function oe(e){if(!v)for(let t of e)R.has(t)||D.has(t)||(R.add(t),document.addEventListener(t,he))}function he(e){let t=`$$${e.type}`,n=e.composedPath&&e.composedPath()[0]||e.target;for(;n;){let o=n[t];if(o&&!n.disabled&&(o(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Element?n.host:n.parentNode}}function Ee(e,t,n){if(e[`$$${t}`]=n,D.has(t)){let o=`__fx_${t}`;if(!e[o]){let s=a=>{e[`$$${t}`]?.(a)};e.addEventListener(t,s),e[o]=s}return}R.has(t)||oe([t])}function te(e,t){delete e[`$$${t}`];let n=`__fx_${t}`,o=e[n];o&&(e.removeEventListener(t,o),delete e[n])}function qe(e){return!D.has(e)}function Ge(e){return typeof e=="function"}function N(e,t=!1){if(v)return L().createText(e);if(d.active&&!t){let n=P()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}function ze(e,t=!1){if(v)return L().createElement(e,t);if(d.active){let n=P()?.hydrateElement(e);if(n)return n}return t?document.createElementNS(k,e):document.createElement(e)}function be(e,t=!1){let n=ee.get(e);if(n)return n;let o=document.createElement("template");return t?o.innerHTML=`<svg>${e}</svg>`:o.innerHTML=e,ee.set(e,o),o}function Xe(e,t,n=!1,o=!1){if(v){let s=L();return n?s.parseTemplate(e,o):s.createRaw(e)}if(d.active){let s=P()?.hydrateStatic(t);if(s)return s}return Ne(be(e,o),o).firstChild}function Je(e,t){if(!d.active)return t();let n=B(e.nextSibling,t);if(typeof n=="function"){let o=n;return((...s)=>d.active?B(e.nextSibling,()=>o(...s)):o(...s))}return n}function Ue(e){for(let t=e.nextSibling;t;t=t.nextSibling)if(t.nodeType===8&&t.data==="fx/")return t;throw new Error("[fluixi] template hole is missing its closing marker")}function Ye(e,t){let n=[];for(let o=e.nextSibling;o&&o!==t;o=o.nextSibling)n.push(o);return n}function Ne(e,t=!1){let n=e.content.cloneNode(!0);return t?n.firstChild:n}function Te(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Te(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}function Ze(e){return typeof e!="function"?null:e._name||e.name||"anonymous"}function Qe(e){if(m(e)||h(e)||typeof e!="function")return e;let t=e();for(;typeof t=="function"&&!m(t)&&!h(t);)t=t();return t}var b=0,we=200;function Se(e,t,n,o,s){let a=o,f=new Map;return p(()=>{let r;if(h(e)&&!m(e)){if(!f.has(e)){b++;try{let i=e();f.set(e,i)}finally{b--}}for(r=f.get(e);typeof r=="function"&&m(r);)r=r()}else for(r=e();typeof r=="function"&&m(r);)r=r();{let i=0;for(;typeof r=="function"&&i++<50;)if(h(r)){if(!f.has(r)){let l=r;b++;try{let u=l();f.set(l,u)}finally{b--}}r=f.get(r)}else if(m(r))r=r();else if(r=r(),typeof r!="function"||!m(r)&&!h(r))break}b++;try{a=O(t,r,n,a,f),s(a)}finally{b--}})}function ie(e,t,n,o){if(b>we)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=N("",!0),e.appendChild(n));let s=o??null,a=i=>Array.isArray(i)&&i.some(l=>typeof l=="function"),f=i=>typeof i=="function"?i:()=>i;if(typeof t!="function"&&!a(t)){b++;try{s=O(e,t,n,null)}finally{b--}return()=>s}let r=Se(f(t),e,n,s,i=>{s=i});return()=>(r?.(),s)}function O(e,t,n,o,s){if(t==null||typeof t=="boolean")return w(e,o,n);if(typeof t=="function")for(;typeof t=="function";)t=t();if(t==null||typeof t=="boolean")return w(e,o,n);if(M(t)){let f=N("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(f,o[0]),w(e,o.slice(1),n)):g(e,f,n):o?e.replaceChild(f,o):g(e,f,n),t.then(r=>{f.parentNode===e&&O(e,r,f.nextSibling,f)}).catch(r=>{console.error("Error resolving promise in insertExpression:",r)}),f}let a=typeof t;if(a==="string"||a==="number"){if(a==="number"&&(t=String(t)),Array.isArray(o)){if(o.length===0){let r=N(t);return g(e,r,n),r}if(o.length===1&&o[0].nodeType===3)return o[0].data=t,o;o=w(e,o,n)}if(o&&Z(o))return o.data=t,o;let f=N(t);return o&&o.parentNode===e?e.replaceChild(f,o):K(e,f)||g(e,f,n),f}if(A(t))return K(e,t)?(Q(t),t):Array.isArray(o)?(o.length===0?g(e,t,n):o[0].parentNode===e?(e.replaceChild(t,o[0]),w(e,o.slice(1),n)):g(e,t,n),t):(o?o!==t&&(o.parentNode===e?e.replaceChild(t,o):g(e,t,n)):g(e,t,n),t);if(Array.isArray(t)){let f=[],r=Array.isArray(o)?o:o?[o]:[],i=[];E(t,f,e,n,!0,s,i);let l=ve(e,r,f,n);for(let u of i){let c=ie(e,u.sig,u.marker);S(()=>{w(e,c()),u.marker.parentNode===e&&e.removeChild(u.marker)})}return l}if(a==="object"&&t!==null&&typeof t=="object"){let f=t;if("type"in f&&"props"in f){let r=f;if(typeof r.type=="function"){let i=r.type(r.props||{});return O(e,i,n,o)}}}return w(e,o,n)}function E(e,t,n,o,s=!0,a,f){for(let r=0;r<e.length;r++){let i=e[r];if(!(i==null||typeof i=="boolean")){for(;typeof i=="function"&&!M(i)&&!m(i)&&!h(i)&&(i=i(),!(i==null||typeof i=="boolean")););if(!(i==null||typeof i=="boolean")){if(typeof i=="function"){let l;for(h(i)&&!m(i)?(a||(a=new Map),a.has(i)||a.set(i,i()),l=a.get(i)):l=i();typeof l=="function"&&!M(l)&&!m(l)&&!h(l);)a||(a=new Map),a.has(l)||a.set(l,l()),l=a.get(l);if(l==null||typeof l=="boolean")continue;if(typeof l=="function"){if(m(l)){if(f){let c=N("",!0);t.push(c),f.push({marker:c,sig:l});continue}let u=l();for(;typeof u=="function"&&m(u);)u=u();if(u==null||typeof u=="boolean")continue;Array.isArray(u)?E(u,t,n,o,s,a):E([u],t,n,o,s,a);continue}continue}Array.isArray(l)?E(l,t,n,o,s,a,f):E([l],t,n,o,s,a,f);continue}if(M(i)){let l=N("",!0);t.push(l),i.then(u=>{if(l.parentNode){let c=[];if(E([u],c,l.parentNode,void 0,!1,a),c.length>0){l.parentNode.replaceChild(c[0],l);for(let y=1;y<c.length;y++)l.parentNode?.insertBefore(c[y],c[y-1].nextSibling)}}}).catch(u=>console.error("Error resolving promise in array:",u));continue}if(Array.isArray(i)){E(i,t,n,o,s,a,f);continue}if(A(i)){t.push(i);continue}if(typeof i=="object"&&i!==null&&"type"in i&&"props"in i){let l=i;if(typeof l.type=="function"){let u=l.type(l.props||{});Array.isArray(u)?E(u,t,n,o,!1,a):E([u],t,n,o,!1,a);continue}}if(typeof i=="string"||typeof i=="number"){let l=String(i);if(l.trim()===""&&l!==" ")continue;t.push(N(l));continue}t.push(N(String(i)))}}}}function ve(e,t,n,o){for(let c=0;c<n.length;c++)n[c].parentNode!==null&&n[c].parentNode!==e&&(n=n.slice(),n[c]=n[c].cloneNode(!0));let s=n.length,a=t.length,f=s,r=0,i=0,l=a>0?t[a-1].nextSibling??void 0:o,u=null;for(;r<a||i<f;){if(t[r]===n[i]){r++,i++;continue}for(;a>r&&f>i&&t[a-1]===n[f-1];)a--,f--;if(a===r){let c=f<s?i?n[i-1].nextSibling??void 0:n[f-i]:l;for(;i<f;)g(e,n[i++],c)}else if(f===i)for(;r<a;)(!u||!u.has(t[r]))&&t[r].parentNode===e&&e.removeChild(t[r]),r++;else if(t[r]===n[f-1]&&n[i]===t[a-1]){let c=t[--a].nextSibling;g(e,n[i++],t[r++].nextSibling),g(e,n[--f],c),t[a]=t[r-1]}else{if(!u){u=new Map;let y=i;for(;y<f;)u.set(n[y],y++)}let c=u.get(t[r]);if(c!=null)if(i<c&&c<f){let y=r,_=1;for(;++y<a&&y<f&&!(!u.has(t[y])||u.get(t[y])!==c+_);)_++;if(_>c-i){let le=t[r];for(;i<c;)g(e,n[i++],le)}else t[r].parentNode===e?e.replaceChild(n[i++],t[r++]):(g(e,n[i++],l),r++)}else r++;else t[r].parentNode===e&&e.removeChild(t[r]),r++}}return n}function w(e,t,n){if(t)if(Array.isArray(t))for(let o=0;o<t.length;o++)t[o].parentNode===e&&e.removeChild(t[o]);else t.parentNode===e&&e.removeChild(t);return null}function g(e,t,n){d.active&&t.parentNode===e||(n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t))}function H(e,t,n){n==null?delete e[t]:e[t]=n}function re(e,t,n){let o=n,s;return Array.isArray(n)&&(o=n[0],s=n[1]),typeof o!="function"?()=>{}:(e.addEventListener(t,o,s),()=>e.removeEventListener(t,o,s))}function se(e,t){let n=(o,s)=>{typeof o=="function"&&o(e,s??(()=>{}))};if(typeof t=="function"){n(t);return}if(Array.isArray(t)){if(typeof t[0]=="function"){n(t[0],t[1]);return}for(let o of t)Array.isArray(o)?n(o[0],o[1]):n(o)}}function q(e,t,n,o=!1){return typeof n!="function"?(T(e,t,n,o),()=>{}):p(()=>{let s=typeof n=="function"?n():n;T(e,t,s,o)})}function G(e,t,n){return typeof n!="function"?(H(e,t,n),()=>{}):p(()=>{let o=typeof n=="function"?n():n;H(e,t,o)})}function fe(e,t,n){return typeof n!="function"?(T(e,t,!!n),()=>{}):p(()=>{let o=n();T(e,t,!!o)})}function $(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){p(()=>$(e,t()));return}if(typeof t=="string"){e.setAttribute("class",t);return}if(Array.isArray(t)){e.setAttribute("class",t.filter(Boolean).join(" "));return}if(typeof t=="object"){let n=Object.keys(t).filter(o=>{let s=t[o];return typeof s=="function"?s():!!s}).join(" ");e.setAttribute("class",n);return}e.setAttribute("class",String(t))}function j(e,t,n){if(!(!t||typeof t!="object"))for(let o in t){let s=t[o],a=o.split(/\s+/).filter(Boolean);if(typeof s=="function"&&n)n.push(p(()=>{let f=!!s();for(let r of a)e.classList.toggle(r,f)}));else{let f=!!(typeof s=="function"?s():s);for(let r of a)e.classList.toggle(r,f)}}}function F(e,t){let n=t;for(;typeof n=="function";)n=n();if(n==null){e.removeAttribute("style");return}if(typeof n=="string"){e.style.cssText=n;return}if(typeof n=="object")for(let o in n){let s=n[o];s==null?e.style[o]="":e.style[o]=s}}function et(e){let{element:t,props:n,prevProps:o=xe,isSVG:s=!1,skipChildren:a=!1}=e;if(!t||!Y(t))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!n)return console.warn("[spread] Warning: props is undefined!"),()=>{};let f=s||t.namespaceURI===k,r=[];for(let i in n){if(a&&i==="children")continue;let l=n[i],u=o[i];if(l===u)continue;if(i==="ref"){ae(l,t);continue}if(i==="use"){se(t,l);continue}if(i.startsWith("on:")){r.push(re(t,i.slice(3),l));continue}if(i.startsWith("prop:")){r.push(G(t,i.slice(5),l));continue}if(i.startsWith("attr:")){r.push(q(t,i.slice(5),l,f));continue}if(i.startsWith("bool:")){r.push(fe(t,i.slice(5),l));continue}if(i==="class"||i==="className"){typeof l=="function"?r.push(p(()=>$(t,l()))):$(t,l);continue}if(i==="classList"){typeof l=="function"?r.push(p(()=>j(t,l()))):j(t,l,r);continue}if(i==="style"){typeof l=="function"?r.push(p(()=>F(t,l()))):F(t,l);continue}if(i.startsWith("on")){let y=i.slice(2).toLowerCase();u&&te(t,y),l&&Ee(t,y,l);continue}let c=V.has(i)||!f&&i in t;typeof l=="function"?r.push(c?G(t,i,l):q(t,i,l,f)):r.push(p(()=>c?H(t,i,n[i]):T(t,i,n[i],f)))}for(let i in o)if(!(i in n))if(i.startsWith("on")){let l=i.slice(2).toLowerCase();te(t,l)}else V.has(i)?H(t,i,null):t.removeAttribute(i);return()=>{r.forEach(i=>i())}}function tt(e,t,n=!1){for(let o in t){let s=t[o];if(o==="ref"){ae(s,e);continue}if(o!=="children"){if(o==="use"){se(e,s);continue}if(o.startsWith("on:")){re(e,o.slice(3),s);continue}if(o.startsWith("prop:")){G(e,o.slice(5),s);continue}if(o.startsWith("attr:")){q(e,o.slice(5),s,n);continue}if(o.startsWith("bool:")){fe(e,o.slice(5),s);continue}if(o.startsWith("on")&&o.length>2){let a=o.slice(2).toLowerCase();if(typeof s=="function")if(D.has(a)){e[`$$${a}`]=s;let f=`__fx_${a}`;if(!e[f]){let r=i=>{e[`$$${a}`]?.(i)};e.addEventListener(a,r),e[f]=r}}else e[`$$${a}`]=s,R.has(a)||oe([a]);continue}if(o==="class"||o==="className"){$(e,s);continue}if(o==="classList"){typeof s=="function"?p(()=>j(e,s())):j(e,s);continue}if(o==="style"){typeof s=="function"?p(()=>F(e,s())):F(e,s);continue}if(o==="innerHTML"){if(typeof s=="function"){let a=C(()=>{let f=s();for(;typeof f=="function";)f=f();e.innerHTML=f});S(()=>a())}else e.innerHTML=s;continue}if(o==="value"&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")){if(typeof s=="function"){let a=C(()=>{let f=s();for(;typeof f=="function"&&f.length===0;)f=f();document.activeElement!==e&&(e.value=f??"")});S(()=>{a()})}else p(()=>{document.activeElement!==e&&(e.value=t[o]??"")});continue}if(o==="checked"&&e.tagName==="INPUT"){if(typeof s=="function"){let a=C(()=>{let f=s();for(;typeof f=="function"&&f.length===0;)f=f();document.activeElement!==e&&(e.checked=f??"")});S(()=>{a()})}else p(()=>{document.activeElement!==e&&(e.checked=t[o]??"")});continue}if(o==="value"&&e.tagName==="SELECT"){if(typeof s=="function"){let a=!0,f=C(()=>{let r=s();for(;typeof r=="function"&&r.length===0;)r=r();a?(a=!1,queueMicrotask(()=>{e.value=r??""})):e.value=r??""});S(()=>{f()})}else{let a=!0;p(()=>{let f=t[o];a?(a=!1,queueMicrotask(()=>{e.value=f??""})):e.value=f??""})}continue}if(typeof s=="function"){let a=C(()=>{let f=s();for(;typeof f=="function"&&f.length===0;)f=f();I(e,o,f,n)});S(()=>{a()})}else p(()=>I(e,o,t[o],n))}}}function nt(...e){let t=o=>{for(let s=e.length-1;s>=0;s--){let a=e[s];if(a&&o in a&&a[o]!==void 0)return a[o]}},n=o=>{for(let s of e)if(s&&o in s)return!0;return!1};return new Proxy({},{get:(o,s)=>t(s),has:(o,s)=>n(s),ownKeys:()=>{let o=new Set;for(let s of e)if(s)for(let a of Reflect.ownKeys(s))o.add(a);return[...o]},getOwnPropertyDescriptor:(o,s)=>n(s)?{enumerable:!0,configurable:!0,get:()=>t(s)}:void 0})}function ot(e,...t){let n=new Set;for(let f of t)for(let r of f)n.add(r);let o=f=>({enumerable:!0,configurable:!0,get:()=>e[f]}),s=t.map(f=>{let r=new Set(f);return new Proxy({},{get:(i,l)=>r.has(l)?e[l]:void 0,has:(i,l)=>r.has(l)&&l in e,ownKeys:()=>Array.from(r).filter(i=>i in e),getOwnPropertyDescriptor:(i,l)=>r.has(l)&&l in e?o(l):void 0})}),a=new Proxy({},{get:(f,r)=>n.has(r)?void 0:e[r],has:(f,r)=>!n.has(r)&&r in e,ownKeys:()=>Reflect.ownKeys(e).filter(f=>!n.has(f)),getOwnPropertyDescriptor:(f,r)=>!n.has(r)&&r in e?o(r):void 0});return[...s,a]}function ae(e,t){if(e){if(A(e)){let n=t,o=e;if(!n)return;typeof n=="function"?n(o):typeof n=="object"&&"current"in n&&(n.current=o);return}typeof e=="function"?e(t):typeof e=="object"&&"current"in e&&(e.current=t)}}function it(e,t,n){let o=t||document.body,s=ye(()=>e),a=[];return ne(()=>{let f=p(()=>{let r=s();Array.isArray(r)?(r.forEach(i=>o.appendChild(i)),a.push(()=>{r.forEach(i=>{i.parentNode===o&&o.removeChild(i)})})):A(r)&&(o.appendChild(r),a.push(()=>{r.parentNode===o&&o.removeChild(r)}))});a.push(f),S(()=>{a.forEach(r=>r())})}),null}function rt(e){return typeof e=="string"&&e.toLowerCase()===e}function st(e){return e==="svg"||e==="path"||e==="circle"||e==="rect"||e==="line"||e==="polygon"||e==="polyline"||e==="ellipse"||e==="g"||e==="defs"||e==="clipPath"||e==="text"}function ft(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function M(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function at(e){return typeof e=="function"&&e.length===0&&m(e)}function lt(e,t,n){if(!t)throw new Error("Container element is required");let o,s,a=[];return pe(f=>{ne(()=>{d.active||(t.textContent=""),X(t),J(),ie(t,e)}),s=f}),()=>{s?.(),o?.(),a.forEach(f=>f()),t.textContent=""}}export{Ee as addDelegatedEventListener,re as addNativeEventListener,tt as applyProps,se as applyUse,w as cleanChildren,Ne as cloneTemplate,ze as createNativeElement,it as createPortal,be as createTemplate,oe as delegateEvents,ft as escapeHTML,Ze as fnName,Be as generateID,Ke as getStableElementId,ae as handleRef,Ye as holeContent,Ue as holeEnd,Je as holeScope,ie as insert,O as insertExpression,at as isAccessor,qe as isDelegatedEvent,Ge as isFunction,rt as isNativeElement,M as isPromise,st as isSVGElement,Qe as iterateFn,Te as makeArrayFlat,nt as mergeProps,te as removeDelegatedEventListener,lt as render,j as setClassList,$ as setClassName,q as setDynamicAttribute,fe as setDynamicBoolAttribute,G as setDynamicProperty,H as setProperty,F as setStyle,ot as splitProps,et as spread,Xe as templateNode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var c=(e,r)=>{for(var t in r)i(e,t,{get:r[t],enumerable:!0})},y=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of s(r))!f.call(e,n)&&n!==t&&i(e,n,{get:()=>r[n],enumerable:!(a=d(r,n))||a.enumerable});return e};var m=e=>y(i({},"__esModule",{value:!0}),e);var g={};c(g,{SERVER_NODE:()=>o,getServerNodes:()=>x,isDomElement:()=>N,isDomNode:()=>S,isDomText:()=>E,isServer:()=>l,registerServerNodes:()=>v,setServerMode:()=>p});module.exports=m(g);var l=typeof document>"u";function p(e){l=e}var o=Symbol.for("fluixi.server-node"),u=null;function v(e){u=e}function x(){if(!u)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return u}function S(e){return e!=null&&e[o]===!0?!0:typeof Node<"u"&&e instanceof Node}function N(e){return e!=null&&e[o]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function E(e){return e!=null&&e[o]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}
|
|
@@ -5,6 +5,10 @@ export interface ServerNodeFactory {
|
|
|
5
5
|
createElement(tag: string, isSVG: boolean): any;
|
|
6
6
|
createText(value: string): any;
|
|
7
7
|
createComment(value: string): any;
|
|
8
|
+
/** A pre-rendered static subtree, serialized verbatim. */
|
|
9
|
+
createRaw(html: string): any;
|
|
10
|
+
/** A template with holes, parsed into real nodes so the holes can be filled. */
|
|
11
|
+
parseTemplate(html: string, isSVG: boolean): any;
|
|
8
12
|
}
|
|
9
13
|
export declare function registerServerNodes(factory: ServerNodeFactory): void;
|
|
10
14
|
export declare function getServerNodes(): ServerNodeFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/host.ts"],"names":[],"mappings":"AAKA,eAAO,IAAI,QAAQ,SAAkC,CAAC;AACtD,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAE/C;AAID,eAAO,MAAM,WAAW,EAAE,OAAO,MAAyC,CAAC;AAE3E,MAAM,WAAW,iBAAiB;IAChC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC;IAChD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;IAC/B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/host.ts"],"names":[],"mappings":"AAKA,eAAO,IAAI,QAAQ,SAAkC,CAAC;AACtD,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAE/C;AAID,eAAO,MAAM,WAAW,EAAE,OAAO,MAAyC,CAAC;AAE3E,MAAM,WAAW,iBAAiB;IAChC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC;IAChD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;IAC/B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;IAClC,0DAA0D;IAC1D,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;IAC7B,gFAAgF;IAChF,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC;CAClD;AAID,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAEpE;AAED,wBAAgB,cAAc,IAAI,iBAAiB,CAKlD;AAID,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,IAAI,CAG3C;AACD,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAGjD;AACD,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,IAAI,CAG3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=typeof document>"u";function o(e){t=e}var n=Symbol.for("fluixi.server-node"),r=null;function i(e){r=e}function u(){if(!r)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return r}function
|
|
1
|
+
var t=typeof document>"u";function o(e){t=e}var n=Symbol.for("fluixi.server-node"),r=null;function i(e){r=e}function u(){if(!r)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return r}function a(e){return e!=null&&e[n]===!0?!0:typeof Node<"u"&&e instanceof Node}function l(e){return e!=null&&e[n]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function d(e){return e!=null&&e[n]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}export{n as SERVER_NODE,u as getServerNodes,l as isDomElement,a as isDomNode,d as isDomText,t as isServer,i as registerServerNodes,o as setServerMode};
|
|
@@ -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 n in t)b(e,n,{get:t[n],enumerable:!0})},le=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ie(t))!ue.call(e,s)&&s!==n&&b(e,s,{get:()=>t[s],enumerable:!(r=oe(t,s))||r.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:()=>re,runWithRequestContext:()=>y,serializeNode:()=>a,serializeResourceData:()=>F,setDataRedactor:()=>ne,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 n=t.childNodes.indexOf(this);return n>=0?t.childNodes[n+1]??null:null}get previousSibling(){let t=this.parentNode;if(!t)return null;let n=t.childNodes.indexOf(this);return n>0?t.childNodes[n-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,n){if(n==null)return this.appendChild(t);t.parentNode&&t.parentNode.removeChild(t);let r=this.childNodes.indexOf(n);return t.parentNode=this,r<0?this.childNodes.push(t):this.childNodes.splice(r,0,t),t}removeChild(t){let n=this.childNodes.indexOf(t);return n>=0&&this.childNodes.splice(n,1),t.parentNode=null,t}replaceChild(t,n){let r=this.childNodes.indexOf(n);return r>=0&&(t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes[r]=t,n.parentNode=null),n}addEventListener(){}removeEventListener(){}},p=class e extends l{constructor(n){super();this.nodeType=A;this.data=n}get nodeValue(){return this.data}set nodeValue(n){this.data=n==null?"":String(n)}get textContent(){return this.data}set textContent(n){this.data=n==null?"":String(n)}cloneNode(){return new e(this.data)}},h=class e extends l{constructor(n){super();this.nodeType=D;this.data=n}get nodeValue(){return this.data}set nodeValue(n){this.data=n==null?"":String(n)}cloneNode(){return new e(this.data)}},E=class{constructor(){this.cssText=""}setProperty(t,n){this[t]=n}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 n=this.list();for(let r of t)n.includes(r)||n.push(r);this.write(n)}remove(...t){this.write(this.list().filter(n=>!t.includes(n)))}contains(t){return this.list().includes(t)}toggle(t,n){let r=this.contains(t),s=n===void 0?!r:n;return s?this.add(t):this.remove(t),s}},m=class e extends l{constructor(n,r=!1){super();this.nodeType=q;this.attributes=new Map;this.style=new E;this.classList=new C(this);this.rawHTML=null;this.localName=n.toLowerCase(),this.tagName=r?n:n.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(n,r){this.attributes.set(n,String(r))}removeAttribute(n){this.attributes.delete(n)}getAttribute(n){return this.attributes.has(n)?this.attributes.get(n):null}hasAttribute(n){return this.attributes.has(n)}get id(){return this.getAttribute("id")??""}set id(n){n==null?this.removeAttribute("id"):this.setAttribute("id",n)}get className(){return this.getAttribute("class")??""}set className(n){n==null?this.removeAttribute("class"):this.setAttribute("class",n)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(n){n==null?this.removeAttribute("for"):this.setAttribute("for",n)}set value(n){n==null?this.removeAttribute("value"):this.setAttribute("value",String(n))}set checked(n){n?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(n){n?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(n){}get textContent(){return this.childNodes.map(n=>n.textContent??"").join("")}set textContent(n){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,n!=null&&n!==""&&this.appendChild(new p(String(n)))}set innerText(n){this.textContent=n}set innerHTML(n){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=n==null?"":String(n)}cloneNode(n=!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,n)for(let s of this.childNodes)r.appendChild(s.cloneNode(!0));return r}};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 n of Object.keys(e)){if(n==="cssText")continue;let r=e[n];r==null||r===""||t.push(`${me(n)}: ${r}`)}return t.join("; ")}function ve(e){let t="",n=xe(e.style);for(let[r,s]of e.attributes)r==="style"&&n||(t+=` ${r}="${W(s)}"`);if(n){let r=e.attributes.get("style"),s=r?`${r.replace(/;\s*$/,"")}; ${n}`:n;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,n=`<${t}${ve(e)}>`;if(pe.has(t))return n;let r=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(a).join("");return`${n}${r}</${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 n=document.getElementById(v)?.textContent;if(n)try{t=JSON.parse(n)}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 n=R;R=e;try{return t()}finally{R=n}}},M=G;function K(e){M=e??G}function N(e={}){e.locals||(e.locals=e.request?L(e.request):{});let t=0,n=0,r=null,s=new Map,i=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${t++}`,nextResourceId:()=>{if(r===null)return`r${n++}`;let u=s.get(r)??0;return s.set(r,u+1),`${r}:r${u}`},nextIslandNamespace:u=>{let c=i.get(u)??0;return i.set(u,c+1),`${u}#${c}`},withResourceScope(u,c){let T=r;r=u;try{return c()}finally{r=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 n=g;ee(),d(!0);let r=N(t.event);try{return y(r,()=>(0,I.createRoot)(s=>{try{let i=typeof e=="function"?e():e;return a(i)}finally{s()}}))}finally{d(n)}}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 ne(e){$=e}function F(e){if(e.data.size===0)return"";let t={};for(let[r,s]of e.data){let i=s;if($)try{i=$(s,r)}catch{continue}i!==void 0&&(t[r]=i)}if(Object.keys(t).length===0)return"";let n=S(JSON.stringify(t));return`<script type="application/json" id="${v}">${n}<\/script>`}var ye=50;async function re(e,t={}){let n=g;ee(),d(!0),Ne();let r=N(t.event);try{return await y(r,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(;r.pending.size>0&&T++<ye;){let w=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(w),await(0,o.flush)(),c()}let se=(0,o.runWithOwner)(i,()=>a(s))+F(r);return u(),se})}finally{d(n)}}
|
|
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 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(){}},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(n,t){this[n]=t}removeProperty(n){delete this[n]}},w=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 l{constructor(t,r=!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=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 d(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 l}var Z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$=/&/g,ee=/</g,te=/>/g,ne=/"/g;function q(e){return e.replace($,"&").replace(ee,"<").replace(te,">")}function L(e){return e.replace($,"&").replace(ne,""")}function re(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}function se(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(`${re(t)}: ${r}`)}return n.join("; ")}function oe(e){let n="",t=se(e.style);for(let[r,s]of e.attributes)r==="style"&&t||(n+=` ${r}="${L(s)}"`);if(t){let r=e.attributes.get("style"),s=r?`${r.replace(/;\s*$/,"")}; ${t}`:t;n+=` style="${L(s)}"`}return n}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 n=e.localName,t=`<${n}${oe(e)}>`;if(Z.has(n))return t;let r=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(u).join("");return`${t}${r}</${n}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(u).join(""):""}var x="__FX_DATA__";function D(e){return e.replace(/[<>&\u2028\u2029]/g,n=>"\\u"+n.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 n=null;if(typeof document<"u"){let t=document.getElementById(x)?.textContent;if(t)try{n=JSON.parse(t)}catch{n=null}}return A=n}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,n){let t=v;v=e;try{return n()}finally{v=t}}},_=F;function ue(e){_=e??F}function N(e={}){e.locals||(e.locals=e.request?V(e.request):{});let n=0,t=0,r=null,s=new Map,o=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${n++}`,nextResourceId:()=>{if(r===null)return`r${t++}`;let i=s.get(r)??0;return s.set(r,i+1),`${r}:r${i}`},nextIslandNamespace:i=>{let a=o.get(i)??0;return o.set(i,a+1),`${i}#${a}`},withResourceScope(i,a){let S=r;r=i;try{return a()}finally{r=S}},pending:new Set,data:new Map}}function y(e,n){return _.run(e,n)}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 n=I.get(e);return n||(n={},I.set(e,n)),n}var z=!1;function W(){z||(z=!0,M({createElement:(e,n)=>new m(e,n),createText:e=>new d(e),createComment:e=>new h(e)}))}function ge(e,n={}){let t=f;W(),c(!0);let r=N(n.event);try{return y(r,()=>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,n)=>{e&&p()?.data.set(e,n)}))}var k=null;function me(e){k=e}function J(e){if(e.data.size===0)return"";let n={};for(let[r,s]of e.data){let o=s;if(k)try{o=k(s,r)}catch{continue}o!==void 0&&(n[r]=o)}if(Object.keys(n).length===0)return"";let t=D(JSON.stringify(n));return`<script type="application/json" id="${x}">${t}<\/script>`}var xe=50;async function ve(e,n={}){let t=f;W(),c(!0),he();let r=N(n.event);try{return await y(r,async()=>{n.preload&&await n.preload(n.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(;r.pending.size>0&&S++<xe;){let R=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(R),await fe(),a()}let U=H(o,()=>u(s))+J(r);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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var T=(s,t)=>{for(var e in t)a(s,e,{get:t[e],enumerable:!0})},y=(s,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of b(t))!x.call(s,n)&&n!==e&&a(s,n,{get:()=>t[n],enumerable:!(r=m(t,n))||r.enumerable});return s};var S=s=>y(a({},"__esModule",{value:!0}),s);var E={};T(E,{NODE_COMMENT:()=>v,NODE_ELEMENT:()=>g,NODE_TEXT:()=>f,ServerComment:()=>u,ServerElement:()=>c,ServerNode:()=>i,ServerRaw:()=>d,ServerStyle:()=>l,ServerText:()=>o,isServerNodeValue:()=>w});module.exports=S(E);var p=Symbol.for("fluixi.server-node");var g=1,f=3,v=8,N;N=p;var i=class{constructor(){this[N]=!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(){}},o=class s extends i{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 s(this.data)}},d=class s extends i{constructor(e){super();this.nodeType=g;this.rawOuterHTML=e}get textContent(){return this.rawOuterHTML.replace(/<[^>]*>/g,"")}cloneNode(){return new s(this.rawOuterHTML)}},u=class s extends i{constructor(e){super();this.nodeType=v;this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e==null?"":String(e)}cloneNode(){return new s(this.data)}},l=class{constructor(){this.cssText=""}setProperty(t,e){this[t]=e}removeProperty(t){delete this[t]}},h=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),n=e===void 0?!r:e;return n?this.add(t):this.remove(t),n}},c=class s extends i{constructor(e,r=!1){super();this.nodeType=g;this.attributes=new Map;this.style=new l;this.classList=new h(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 o(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 s(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,e)for(let n of this.childNodes)r.appendChild(n.cloneNode(!0));return r}};function w(s){return s instanceof i}
|
|
@@ -44,6 +44,21 @@ export declare class ServerText extends ServerNode {
|
|
|
44
44
|
set textContent(v: string);
|
|
45
45
|
cloneNode(): ServerText;
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* A pre-rendered subtree, serialized verbatim.
|
|
49
|
+
*
|
|
50
|
+
* Static markup the compiler turned into a template arrives as an HTML string. On the
|
|
51
|
+
* client it is parsed once and cloned; on the server there is nothing to gain from
|
|
52
|
+
* parsing it into elements only to serialize them straight back, so it is carried as-is
|
|
53
|
+
* and written out. `serializeNode` checks `rawOuterHTML` before anything else.
|
|
54
|
+
*/
|
|
55
|
+
export declare class ServerRaw extends ServerNode {
|
|
56
|
+
nodeType: number;
|
|
57
|
+
rawOuterHTML: string;
|
|
58
|
+
constructor(html: string);
|
|
59
|
+
get textContent(): string;
|
|
60
|
+
cloneNode(): ServerRaw;
|
|
61
|
+
}
|
|
47
62
|
export declare class ServerComment extends ServerNode {
|
|
48
63
|
nodeType: number;
|
|
49
64
|
data: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/nodes.ts"],"names":[],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|
+
/**
|
|
120
|
+
* A pre-rendered subtree, serialized verbatim.
|
|
121
|
+
*
|
|
122
|
+
* Static markup the compiler turned into a template arrives as an HTML string. On the
|
|
123
|
+
* client it is parsed once and cloned; on the server there is nothing to gain from
|
|
124
|
+
* parsing it into elements only to serialize them straight back, so it is carried as-is
|
|
125
|
+
* and written out. `serializeNode` checks `rawOuterHTML` before anything else.
|
|
126
|
+
*/
|
|
127
|
+
export class ServerRaw extends ServerNode {
|
|
128
|
+
nodeType = NODE_ELEMENT;
|
|
129
|
+
rawOuterHTML;
|
|
130
|
+
constructor(html) {
|
|
131
|
+
super();
|
|
132
|
+
this.rawOuterHTML = html;
|
|
133
|
+
}
|
|
134
|
+
get textContent() {
|
|
135
|
+
// Approximate: strip tags. Only used by diagnostics, never for output.
|
|
136
|
+
return this.rawOuterHTML.replace(/<[^>]*>/g, '');
|
|
137
|
+
}
|
|
138
|
+
cloneNode() {
|
|
139
|
+
return new ServerRaw(this.rawOuterHTML);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
119
142
|
export class ServerComment extends ServerNode {
|
|
120
143
|
nodeType = NODE_COMMENT;
|
|
121
144
|
data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var d=Symbol.for("fluixi.server-node");var p=1,N=3,f=8,g;g=d;var n=class{constructor(){this[g]=!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(){}},o=class s extends n{constructor(e){super();this.nodeType=N;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 s(this.data)}},u=class s extends n{constructor(e){super();this.nodeType=p;this.rawOuterHTML=e}get textContent(){return this.rawOuterHTML.replace(/<[^>]*>/g,"")}cloneNode(){return new s(this.rawOuterHTML)}},h=class s extends n{constructor(e){super();this.nodeType=f;this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e==null?"":String(e)}cloneNode(){return new s(this.data)}},l=class{constructor(){this.cssText=""}setProperty(t,e){this[t]=e}removeProperty(t){delete this[t]}},a=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),i=e===void 0?!r:e;return i?this.add(t):this.remove(t),i}},c=class s extends n{constructor(e,r=!1){super();this.nodeType=p;this.attributes=new Map;this.style=new l;this.classList=new a(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 o(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 s(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,e)for(let i of this.childNodes)r.appendChild(i.cloneNode(!0));return r}};function b(s){return s instanceof n}export{f as NODE_COMMENT,p as NODE_ELEMENT,N as NODE_TEXT,h as ServerComment,c as ServerElement,n as ServerNode,u as ServerRaw,l as ServerStyle,o as ServerText,b as isServerNodeValue};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var m=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var k=(n,t)=>{for(var e in t)m(n,e,{get:t[e],enumerable:!0})},V=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of L(t))!M.call(n,o)&&o!==e&&m(n,o,{get:()=>t[o],enumerable:!(r=O(t,o))||r.enumerable});return n};var H=n=>V(m({},"__esModule",{value:!0}),n);var _={};k(_,{TemplateParseError:()=>a,parseTemplate:()=>j});module.exports=H(_);var T=Symbol.for("fluixi.server-node");var $=1,D=3,R=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=D;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=R;this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e==null?"":String(e)}cloneNode(){return new n(this.data)}},w=class{constructor(){this.cssText=""}setProperty(t,e){this[t]=e}removeProperty(t){delete this[t]}},b=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=$;this.attributes=new Map;this.style=new w;this.classList=new b(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 F=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),I={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'"};function E(n){return n.replace(/&(#?\w+);/g,(t,e)=>I[e]??t)}var a=class extends Error{};function j(n,t=!1){let e=0,r=[],o=[],N=s=>{let l=o[o.length-1];l?l.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 l=n.indexOf("-->",s);if(l===-1)throw new a(`unterminated comment at ${s}`);N(new f(n.slice(s+4,l))),e=l+3;continue}if(n[s+1]==="/"){let l=n.indexOf(">",s);if(l===-1)throw new a(`unterminated closing tag at ${s}`);let u=n.slice(s+2,l).trim().toLowerCase(),d=o.pop();if(!d||d.localName!==u)throw new a(`</${u}> does not close <${d?.localName??"nothing"}>`);e=l+1;continue}e=C(s)}if(o.length>0)throw new a(`unclosed <${o[o.length-1].localName}>`);let x=r[0];if(r.length!==1||!(x instanceof p))throw new a(`expected exactly one root element, got ${r.length}`);return x;function S(s){s!==""&&N(new g(E(s)))}function C(s){let l=/[\s/>]/.exec(n.slice(s+1));if(!l)throw new a(`unterminated tag at ${s}`);let u=n.slice(s+1,s+1+l.index).toLowerCase(),d=new p(u,t),i=s+1+l.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 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,E(n.slice(i+2,v))),i=v+1}else d.setAttribute(c,"")}return N(d),F.has(u)||o.push(d),i}}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { ServerElement } from './nodes.js';
|
|
16
|
+
export declare class TemplateParseError extends Error {
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build the server-node tree for `html`.
|
|
20
|
+
*
|
|
21
|
+
* Returns the single root element. The compiler only ever emits a template rooted at one
|
|
22
|
+
* element, so more than one root is a bug on the emitting side rather than something to
|
|
23
|
+
* paper over here.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseTemplate(html: string, isSVG?: boolean): ServerElement;
|
|
26
|
+
//# sourceMappingURL=parse-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-template.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/parse-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAiB,aAAa,EAAc,MAAM,YAAY,CAAC;AAiCtE,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,aAAa,CAwGxE"}
|