@fluixi/dom 1.0.0-alpha.82 → 1.0.0-alpha.84
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-client.cjs +1427 -1
- package/dist/cdn/dom-client.d.ts +2 -2
- package/dist/cdn/dom-client.global.js +2 -1
- package/dist/cdn/dom-client.js +3 -3
- package/dist/cdn/dom-client.mjs +1430 -1
- package/dist/cdn/dom.cjs +3127 -1
- package/dist/cdn/dom.d.ts +2 -2
- package/dist/cdn/dom.global.js +2 -1
- package/dist/cdn/dom.js +4 -4
- package/dist/cdn/dom.mjs +3133 -1
- package/dist/index.cjs +3155 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +3149 -1
- package/dist/lib/component/index.cjs +128 -1
- package/dist/lib/component/index.mjs +105 -1
- package/dist/lib/component/modifiers.cjs +126 -1
- package/dist/lib/component/modifiers.d.ts +12 -0
- package/dist/lib/component/modifiers.d.ts.map +1 -1
- package/dist/lib/component/modifiers.js +12 -84
- package/dist/lib/component/modifiers.mjs +105 -1
- package/dist/lib/dom/delegate.cjs +60 -1
- package/dist/lib/dom/delegate.js +1 -1
- package/dist/lib/dom/delegate.mjs +39 -1
- package/dist/lib/dom/dynamic-element.cjs +949 -1
- package/dist/lib/dom/dynamic-element.d.ts +3 -3
- package/dist/lib/dom/dynamic-element.js +3 -3
- package/dist/lib/dom/dynamic-element.mjs +928 -1
- package/dist/lib/dom/hydration-state.cjs +93 -1
- package/dist/lib/dom/hydration-state.d.ts +1 -1
- package/dist/lib/dom/hydration-state.js +1 -1
- package/dist/lib/dom/hydration-state.mjs +72 -1
- package/dist/lib/dom/hydration.cjs +685 -1
- package/dist/lib/dom/hydration.js +8 -8
- package/dist/lib/dom/hydration.mjs +664 -1
- package/dist/lib/dom/index.cjs +2040 -1
- package/dist/lib/dom/index.js +1 -1
- package/dist/lib/dom/index.mjs +2020 -1
- package/dist/lib/dom/integration.cjs +71 -1
- package/dist/lib/dom/integration.d.ts.map +1 -1
- package/dist/lib/dom/integration.js +15 -6
- package/dist/lib/dom/integration.mjs +51 -1
- package/dist/lib/dom/island.cjs +790 -1
- package/dist/lib/dom/island.d.ts +1 -1
- package/dist/lib/dom/island.js +12 -12
- package/dist/lib/dom/island.mjs +769 -1
- package/dist/lib/dom/runtime.cjs +1432 -1
- package/dist/lib/dom/runtime.d.ts +71 -19
- package/dist/lib/dom/runtime.d.ts.map +1 -1
- package/dist/lib/dom/runtime.js +261 -100
- package/dist/lib/dom/runtime.mjs +1414 -1
- package/dist/lib/dom/server/fx-data.cjs +53 -1
- package/dist/lib/dom/server/fx-data.d.ts +5 -5
- package/dist/lib/dom/server/fx-data.js +6 -6
- package/dist/lib/dom/server/fx-data.mjs +32 -1
- package/dist/lib/dom/server/host.cjs +66 -1
- package/dist/lib/dom/server/host.d.ts +14 -2
- package/dist/lib/dom/server/host.d.ts.map +1 -1
- package/dist/lib/dom/server/host.js +38 -10
- package/dist/lib/dom/server/host.mjs +45 -1
- package/dist/lib/dom/server/index.cjs +759 -1
- package/dist/lib/dom/server/index.d.ts +1 -1
- package/dist/lib/dom/server/index.js +1 -1
- package/dist/lib/dom/server/index.mjs +743 -1
- package/dist/lib/dom/server/nodes.cjs +302 -1
- package/dist/lib/dom/server/nodes.d.ts +2 -2
- package/dist/lib/dom/server/nodes.d.ts.map +1 -1
- package/dist/lib/dom/server/nodes.js +4 -4
- package/dist/lib/dom/server/nodes.mjs +279 -1
- package/dist/lib/dom/server/parse-template.cjs +395 -1
- package/dist/lib/dom/server/parse-template.d.ts +1 -1
- package/dist/lib/dom/server/parse-template.js +4 -4
- package/dist/lib/dom/server/parse-template.mjs +372 -1
- package/dist/lib/dom/server/render.cjs +691 -1
- package/dist/lib/dom/server/render.d.ts +9 -1
- package/dist/lib/dom/server/render.d.ts.map +1 -1
- package/dist/lib/dom/server/render.js +25 -17
- package/dist/lib/dom/server/render.mjs +677 -1
- package/dist/lib/dom/server/request-context.cjs +110 -1
- package/dist/lib/dom/server/request-context.d.ts +29 -9
- package/dist/lib/dom/server/request-context.d.ts.map +1 -1
- package/dist/lib/dom/server/request-context.js +28 -8
- package/dist/lib/dom/server/request-context.mjs +89 -1
- package/dist/lib/dom/server/serialize.cjs +187 -1
- package/dist/lib/dom/server/serialize.js +3 -3
- package/dist/lib/dom/server/serialize.mjs +164 -1
- package/dist/lib/dom/server-renderer.cjs +760 -1
- package/dist/lib/dom/server-renderer.js +1 -1
- package/dist/lib/dom/server-renderer.mjs +745 -1
- package/dist/lib/dom/types.cjs +18 -1
- package/dist/lib/dom/utils.cjs +381 -1
- package/dist/lib/dom/utils.d.ts +1 -88
- package/dist/lib/dom/utils.d.ts.map +1 -1
- package/dist/lib/dom/utils.js +2 -99
- package/dist/lib/dom/utils.mjs +361 -1
- package/dist/lib/dom/versions.cjs +60 -1
- package/dist/lib/dom/versions.d.ts +3 -3
- package/dist/lib/dom/versions.d.ts.map +1 -1
- package/dist/lib/dom/versions.js +17 -5
- package/dist/lib/dom/versions.mjs +37 -1
- package/dist/lib/element/attributes.cjs +19 -1
- package/dist/lib/element/attributes.d.ts +7 -7
- package/dist/lib/element/attributes.js +1 -1
- package/dist/lib/element/attributes.mjs +1 -0
- package/dist/lib/element/index.cjs +19 -1
- package/dist/lib/element/index.mjs +1 -0
- package/dist/lib/element/types.cjs +18 -1
- package/dist/lib/element/types.d.ts +4 -5
- package/dist/lib/element/types.d.ts.map +1 -1
- package/dist/lib/element/types.js +0 -1
- package/dist/lib/flow/class-map.cjs +38 -1
- package/dist/lib/flow/class-map.d.ts +3 -3
- package/dist/lib/flow/class-map.js +3 -3
- package/dist/lib/flow/class-map.mjs +17 -1
- package/dist/lib/flow/client-only.cjs +57 -1
- package/dist/lib/flow/client-only.d.ts +4 -4
- package/dist/lib/flow/client-only.js +4 -4
- package/dist/lib/flow/client-only.mjs +36 -1
- package/dist/lib/flow/dynamic.cjs +53 -1
- package/dist/lib/flow/dynamic.d.ts +2 -2
- package/dist/lib/flow/dynamic.js +4 -4
- package/dist/lib/flow/dynamic.mjs +32 -1
- package/dist/lib/flow/error-boundary.cjs +43 -1
- package/dist/lib/flow/error-boundary.d.ts +2 -2
- package/dist/lib/flow/error-boundary.js +4 -4
- package/dist/lib/flow/error-boundary.mjs +22 -1
- package/dist/lib/flow/for.cjs +66 -1
- package/dist/lib/flow/for.d.ts +9 -9
- package/dist/lib/flow/for.d.ts.map +1 -1
- package/dist/lib/flow/for.js +2 -2
- package/dist/lib/flow/for.mjs +45 -1
- package/dist/lib/flow/index-flow.cjs +67 -1
- package/dist/lib/flow/index-flow.d.ts +5 -5
- package/dist/lib/flow/index-flow.js +4 -4
- package/dist/lib/flow/index-flow.mjs +46 -1
- package/dist/lib/flow/index.cjs +805 -1
- package/dist/lib/flow/index.mjs +792 -1
- package/dist/lib/flow/portal.cjs +538 -1
- package/dist/lib/flow/portal.mjs +519 -1
- package/dist/lib/flow/show.cjs +81 -1
- package/dist/lib/flow/show.d.ts +1 -1
- package/dist/lib/flow/show.d.ts.map +1 -1
- package/dist/lib/flow/show.js +12 -118
- package/dist/lib/flow/show.mjs +67 -1
- package/dist/lib/flow/style-map.cjs +43 -1
- package/dist/lib/flow/style-map.d.ts +3 -3
- package/dist/lib/flow/style-map.js +4 -4
- package/dist/lib/flow/style-map.mjs +22 -1
- package/dist/lib/flow/switch.cjs +91 -1
- package/dist/lib/flow/switch.d.ts +3 -3
- package/dist/lib/flow/switch.d.ts.map +1 -1
- package/dist/lib/flow/switch.js +7 -7
- package/dist/lib/flow/switch.mjs +70 -1
- package/dist/lib/flow/utils.cjs +44 -1
- package/dist/lib/flow/utils.d.ts +1 -1
- package/dist/lib/flow/utils.js +1 -1
- package/dist/lib/flow/utils.mjs +23 -1
- package/dist/lib/html.cjs +32 -1
- package/dist/lib/html.d.ts +6 -6
- package/dist/lib/html.js +5 -5
- package/dist/lib/html.mjs +11 -1
- package/dist/lib/index.cjs +3104 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -3
- package/dist/lib/index.mjs +3097 -1
- package/dist/lib/shared/types.cjs +18 -1
- package/dist/lib/shared/types.d.ts +8 -8
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +26 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +2 -2
- package/dist/version.generated.mjs +5 -1
- package/package.json +7 -6
- package/dist/lib/jsx/control-flow/flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/flow.js +0 -627
- package/dist/lib/jsx/control-flow/flow.mjs +0 -0
- package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/for-flow.js +0 -1
- package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
package/dist/lib/dom/runtime.mjs
CHANGED
|
@@ -1 +1,1414 @@
|
|
|
1
|
-
import{isSignal as h}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.82";import{VERSION as ce}from"@fluixi/reactive/version";var m={dom:z,reactive:ce};function X(e){m.core&&e.setAttribute("fluixi",m.core),e.setAttribute("fx-dom",m.dom),e.setAttribute("fx-reactive",m.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=m)}function J(){let e=[m.core,m.dom,m.reactive].filter(t=>t!==void 0);new Set(e).size<=1||console.warn(`[fluixi] package versions disagree — core ${m.core??"(absent)"}, dom ${m.dom}, reactive ${m.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 x(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as ne,createEffect as C,createRenderEffect as y,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 he(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 he(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)}),me={};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,xe))}function xe(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 be(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 Ee(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(Ee(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(h(e)||x(e)||typeof e!="function")return e;let t=e();for(;typeof t=="function"&&!h(t)&&!x(t);)t=t();return t}var E=0,we=200;function Se(e,t,n,o,s){let a=o,f=new Map;return y(()=>{let r;if(x(e)&&!h(e)){if(!f.has(e)){E++;try{let i=e();f.set(e,i)}finally{E--}}for(r=f.get(e);typeof r=="function"&&h(r);)r=r()}else for(r=e();typeof r=="function"&&h(r);)r=r();{let i=0;for(;typeof r=="function"&&i++<50;)if(x(r)){if(!f.has(r)){let l=r;E++;try{let u=l();f.set(l,u)}finally{E--}}r=f.get(r)}else if(h(r))r=r();else if(r=r(),typeof r!="function"||!h(r)&&!x(r))break}E++;try{a=O(t,r,n,a,f),s(a)}finally{E--}})}function ie(e,t,n,o){if(E>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)){E++;try{s=O(e,t,n,s)}finally{E--}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=[];b(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 b(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)&&!h(i)&&!x(i)&&(i=i(),!(i==null||typeof i=="boolean")););if(!(i==null||typeof i=="boolean")){if(typeof i=="function"){let l;for(x(i)&&!h(i)?(a||(a=new Map),a.has(i)||a.set(i,i()),l=a.get(i)):l=i();typeof l=="function"&&!M(l)&&!h(l)&&!x(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(h(l)){if(f){let c=N("",!0);t.push(c),f.push({marker:c,sig:l});continue}let u=l();for(;typeof u=="function"&&h(u);)u=u();if(u==null||typeof u=="boolean")continue;Array.isArray(u)?b(u,t,n,o,s,a):b([u],t,n,o,s,a);continue}continue}Array.isArray(l)?b(l,t,n,o,s,a,f):b([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(b([u],c,l.parentNode,void 0,!1,a),c.length>0){l.parentNode.replaceChild(c[0],l);for(let p=1;p<c.length;p++)l.parentNode?.insertBefore(c[p],c[p-1].nextSibling)}}}).catch(u=>console.error("Error resolving promise in array:",u));continue}if(Array.isArray(i)){b(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)?b(u,t,n,o,!1,a):b([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++){let p=n[c].parentNode;p!==null&&p!==e&&p.nodeType!==11&&(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 p=i;for(;p<f;)u.set(n[p],p++)}let c=u.get(t[r]);if(c!=null)if(i<c&&c<f){let p=r,_=1;for(;++p<a&&p<f&&!(!u.has(t[p])||u.get(t[p])!==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),()=>{}):y(()=>{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),()=>{}):y(()=>{let o=typeof n=="function"?n():n;H(e,t,o)})}function fe(e,t,n){return typeof n!="function"?(T(e,t,!!n),()=>{}):y(()=>{let o=n();T(e,t,!!o)})}function $(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){y(()=>$(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(y(()=>{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=me,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(y(()=>$(t,l()))):$(t,l);continue}if(i==="classList"){typeof l=="function"?r.push(y(()=>j(t,l()))):j(t,l,r);continue}if(i==="style"){typeof l=="function"?r.push(y(()=>F(t,l()))):F(t,l);continue}if(i.startsWith("on")){let p=i.slice(2).toLowerCase();u&&te(t,p),l&&be(t,p,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(y(()=>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"?y(()=>j(e,s())):j(e,s);continue}if(o==="style"){typeof s=="function"?y(()=>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 y(()=>{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 y(()=>{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;y(()=>{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 y(()=>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=y(()=>{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&&h(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=""}}function ut(e){if(Array.isArray(e))return e;if(typeof e=="function"&&typeof e.set=="function")return[e,e.set];throw new TypeError("[fluixi] bind: needs a signal — either `signal(…)` or the `[get, set]` pair from `createSignal(…)`.")}export{be as addDelegatedEventListener,re as addNativeEventListener,tt as applyProps,se as applyUse,ut as bindPair,w as cleanChildren,Ne as cloneTemplate,ze as createNativeElement,it as createPortal,Ee 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
|
+
/*! @fluixi/dom v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
|
|
3
|
+
// src/lib/dom/runtime.ts
|
|
4
|
+
import {
|
|
5
|
+
isSignal
|
|
6
|
+
} from "@fluixi/reactive/signal";
|
|
7
|
+
|
|
8
|
+
// src/lib/dom/utils.ts
|
|
9
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
10
|
+
function isCustomElement(element) {
|
|
11
|
+
return element.localName.includes("-");
|
|
12
|
+
}
|
|
13
|
+
function applyElementProp(element, name, value, isSVG = false) {
|
|
14
|
+
if (value == null) {
|
|
15
|
+
element.removeAttribute(name);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (isCustomElement(element)) {
|
|
19
|
+
element[name] = value;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
setAttribute(element, name, value, isSVG);
|
|
23
|
+
}
|
|
24
|
+
var JSX_PROPERTIES = /* @__PURE__ */ new Set([
|
|
25
|
+
"className",
|
|
26
|
+
"value",
|
|
27
|
+
"checked",
|
|
28
|
+
"selected",
|
|
29
|
+
"innerHTML",
|
|
30
|
+
"innerText",
|
|
31
|
+
"textContent",
|
|
32
|
+
"indeterminate",
|
|
33
|
+
"htmlFor"
|
|
34
|
+
]);
|
|
35
|
+
function setAttribute(element, name, value, isSVG = false) {
|
|
36
|
+
if (value == null || value === false) {
|
|
37
|
+
element.removeAttribute(name);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (value === true) {
|
|
41
|
+
element.setAttribute(name, "");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (typeof value === "object") {
|
|
45
|
+
element.setAttribute(name, JSON.stringify(value));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
element.setAttribute(name, String(value));
|
|
49
|
+
}
|
|
50
|
+
var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
|
|
51
|
+
|
|
52
|
+
// src/version.generated.ts
|
|
53
|
+
var VERSION = "1.0.0-alpha.84";
|
|
54
|
+
|
|
55
|
+
// src/lib/dom/versions.ts
|
|
56
|
+
import { VERSION as REACTIVE } from "@fluixi/reactive/version";
|
|
57
|
+
import { joinedVersions } from "@fluixi/reactive/signal";
|
|
58
|
+
var versions = { dom: VERSION, reactive: REACTIVE };
|
|
59
|
+
function stampVersions(container) {
|
|
60
|
+
if (versions.core) container.setAttribute("fluixi", versions.core);
|
|
61
|
+
container.setAttribute("fx-dom", versions.dom);
|
|
62
|
+
container.setAttribute("fx-reactive", versions.reactive);
|
|
63
|
+
if (typeof globalThis !== "undefined") globalThis.Fluixi = versions;
|
|
64
|
+
}
|
|
65
|
+
function warnOnVersionSkew() {
|
|
66
|
+
const builds = joinedVersions();
|
|
67
|
+
if (builds.length > 1) {
|
|
68
|
+
console.warn(
|
|
69
|
+
`[fluixi] ${builds.length} builds of @fluixi/reactive are driving one reactive graph: ${builds.join(", ")}. They share it on purpose, so signals still cross between them, but the oldest one decided what the graph looks like. Build the components on one release, or load them as shared-runtime bundles.`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const present = [versions.core, versions.dom, versions.reactive].filter(
|
|
73
|
+
(v) => v !== void 0
|
|
74
|
+
);
|
|
75
|
+
if (new Set(present).size <= 1) return;
|
|
76
|
+
console.warn(
|
|
77
|
+
`[fluixi] package versions disagree: core ${versions.core ?? "(absent)"}, dom ${versions.dom}, reactive ${versions.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\`.`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/lib/component/modifiers.ts
|
|
82
|
+
function isComponent(value) {
|
|
83
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/lib/dom/runtime.ts
|
|
87
|
+
import { batch, createEffect, createRenderEffect, createRoot, onCleanup, readChildren, reportReactiveBinding, reportReactiveDirective, untrack } from "@fluixi/reactive/signal";
|
|
88
|
+
|
|
89
|
+
// src/lib/dom/server/host.ts
|
|
90
|
+
var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
|
|
91
|
+
var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
|
|
92
|
+
var realm = globalThis;
|
|
93
|
+
var state = realm[STATE] ??= {
|
|
94
|
+
server: typeof document === "undefined",
|
|
95
|
+
nodes: null
|
|
96
|
+
};
|
|
97
|
+
function isServer() {
|
|
98
|
+
return state.server;
|
|
99
|
+
}
|
|
100
|
+
function getServerNodes() {
|
|
101
|
+
if (!state.nodes) {
|
|
102
|
+
throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
|
|
103
|
+
}
|
|
104
|
+
return state.nodes;
|
|
105
|
+
}
|
|
106
|
+
function isDomNode(x) {
|
|
107
|
+
if (x != null && x[SERVER_NODE] === true) return true;
|
|
108
|
+
return typeof Node !== "undefined" && x instanceof Node;
|
|
109
|
+
}
|
|
110
|
+
function isDomElement(x) {
|
|
111
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 1;
|
|
112
|
+
return typeof Element !== "undefined" && x instanceof Element;
|
|
113
|
+
}
|
|
114
|
+
function isDomText(x) {
|
|
115
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
|
|
116
|
+
return typeof Text !== "undefined" && x instanceof Text;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/lib/dom/hydration-state.ts
|
|
120
|
+
var hydration = {
|
|
121
|
+
active: false,
|
|
122
|
+
cursor: null,
|
|
123
|
+
parents: []
|
|
124
|
+
};
|
|
125
|
+
var _walker = null;
|
|
126
|
+
function getHydrationWalker() {
|
|
127
|
+
return _walker;
|
|
128
|
+
}
|
|
129
|
+
function isAdopted(parent, node) {
|
|
130
|
+
return hydration.active && node.parentNode === parent;
|
|
131
|
+
}
|
|
132
|
+
function ascendPast(node) {
|
|
133
|
+
const idx = hydration.parents.lastIndexOf(node);
|
|
134
|
+
if (idx !== -1) hydration.parents.length = idx;
|
|
135
|
+
hydration.cursor = node.nextSibling;
|
|
136
|
+
}
|
|
137
|
+
function runHydrationAt(cursor, fn) {
|
|
138
|
+
if (!cursor || cursor.parentNode == null) return fn();
|
|
139
|
+
const prevActive = hydration.active;
|
|
140
|
+
const prevCursor = hydration.cursor;
|
|
141
|
+
const prevParents = hydration.parents;
|
|
142
|
+
hydration.active = true;
|
|
143
|
+
hydration.cursor = cursor;
|
|
144
|
+
hydration.parents = [];
|
|
145
|
+
try {
|
|
146
|
+
return fn();
|
|
147
|
+
} finally {
|
|
148
|
+
hydration.active = prevActive;
|
|
149
|
+
hydration.cursor = prevCursor;
|
|
150
|
+
hydration.parents = prevParents;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/lib/dom/runtime.ts
|
|
155
|
+
function getElementFingerprint(el) {
|
|
156
|
+
const parts = [];
|
|
157
|
+
while (el && el.nodeType === 1) {
|
|
158
|
+
let part = el.tagName.toLowerCase();
|
|
159
|
+
if (el.id) {
|
|
160
|
+
part += `#${el.id}`;
|
|
161
|
+
parts.unshift(part);
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (el.getAttribute("data-id")) {
|
|
165
|
+
part += `[data-id="${el.getAttribute("data-id")}"]`;
|
|
166
|
+
}
|
|
167
|
+
let index = 0;
|
|
168
|
+
let sibling = el;
|
|
169
|
+
while (sibling = sibling.previousElementSibling) {
|
|
170
|
+
if (sibling.tagName === el.tagName) index++;
|
|
171
|
+
}
|
|
172
|
+
part += `:nth-of-type(${index + 1})`;
|
|
173
|
+
parts.unshift(part);
|
|
174
|
+
el = el.parentElement;
|
|
175
|
+
}
|
|
176
|
+
return parts.join(">");
|
|
177
|
+
}
|
|
178
|
+
function hashString(str) {
|
|
179
|
+
let hash = 0;
|
|
180
|
+
for (let i = 0; i < str.length; i++) {
|
|
181
|
+
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
182
|
+
hash |= 0;
|
|
183
|
+
}
|
|
184
|
+
return `el_${Math.abs(hash)}`;
|
|
185
|
+
}
|
|
186
|
+
function getStableElementId(el) {
|
|
187
|
+
return hashString(getElementFingerprint(el));
|
|
188
|
+
}
|
|
189
|
+
var generateID = () => {
|
|
190
|
+
return "xxyxxxxxxy-4xx8".replace(/[xy]/g, function(c) {
|
|
191
|
+
let r = Math.random() * 16 | 0;
|
|
192
|
+
let v = c === "x" ? r : r & 3 | 8;
|
|
193
|
+
return v.toString(16);
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
var EMPTY_OBJ = {};
|
|
197
|
+
var HOLE_TAG = "__fx_at";
|
|
198
|
+
var LOC_TAG = "__fx_loc";
|
|
199
|
+
function located(element, at) {
|
|
200
|
+
if (at) element[LOC_TAG] = at;
|
|
201
|
+
return element;
|
|
202
|
+
}
|
|
203
|
+
var templateCache = /* @__PURE__ */ new Map();
|
|
204
|
+
var delegatedSet = /* @__PURE__ */ new Set();
|
|
205
|
+
var NON_DELEGATED = /* @__PURE__ */ new Set(["scroll", "focus", "blur", "load", "error", "resize", "mouseenter", "mouseleave", "pointerenter", "pointerleave", "gotpointercapture", "lostpointercapture"]);
|
|
206
|
+
function delegateEvents(eventNames) {
|
|
207
|
+
if (isServer()) return;
|
|
208
|
+
for (const name of eventNames) {
|
|
209
|
+
if (delegatedSet.has(name) || NON_DELEGATED.has(name)) continue;
|
|
210
|
+
delegatedSet.add(name);
|
|
211
|
+
document.addEventListener(name, delegatedEventHandler);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function delegatedEventHandler(e) {
|
|
215
|
+
const key = `$$${e.type}`;
|
|
216
|
+
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
217
|
+
while (node) {
|
|
218
|
+
const handler = node[key];
|
|
219
|
+
if (handler && !node.disabled) {
|
|
220
|
+
handler(e);
|
|
221
|
+
if (e.cancelBubble) return;
|
|
222
|
+
}
|
|
223
|
+
node = node.host && node.host !== node && node.host instanceof Element ? node.host : node.parentNode;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function addDelegatedEventListener(element, name, handler) {
|
|
227
|
+
element[`$$${name}`] = handler;
|
|
228
|
+
if (NON_DELEGATED.has(name)) {
|
|
229
|
+
const key = `__fx_${name}`;
|
|
230
|
+
if (!element[key]) {
|
|
231
|
+
const forwarder = (e) => {
|
|
232
|
+
element[`$$${name}`]?.(e);
|
|
233
|
+
};
|
|
234
|
+
element.addEventListener(name, forwarder);
|
|
235
|
+
element[key] = forwarder;
|
|
236
|
+
}
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (!delegatedSet.has(name)) {
|
|
240
|
+
delegateEvents([name]);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function removeDelegatedEventListener(element, name) {
|
|
244
|
+
delete element[`$$${name}`];
|
|
245
|
+
const key = `__fx_${name}`;
|
|
246
|
+
const forwarder = element[key];
|
|
247
|
+
if (forwarder) {
|
|
248
|
+
element.removeEventListener(name, forwarder);
|
|
249
|
+
delete element[key];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function isDelegatedEvent(name) {
|
|
253
|
+
return !NON_DELEGATED.has(name);
|
|
254
|
+
}
|
|
255
|
+
function isFunction(value) {
|
|
256
|
+
return typeof value === "function";
|
|
257
|
+
}
|
|
258
|
+
function createTextNode(value, anchor = false) {
|
|
259
|
+
if (isServer()) return getServerNodes().createText(value);
|
|
260
|
+
if (hydration.active && !anchor) {
|
|
261
|
+
const node = getHydrationWalker()?.hydrateText(value);
|
|
262
|
+
if (node) return node;
|
|
263
|
+
}
|
|
264
|
+
return document.createTextNode(value);
|
|
265
|
+
}
|
|
266
|
+
function createNativeElement(tag, isSVG = false, at) {
|
|
267
|
+
if (isServer()) return getServerNodes().createElement(tag, isSVG);
|
|
268
|
+
if (hydration.active) {
|
|
269
|
+
const node = getHydrationWalker()?.hydrateElement(tag);
|
|
270
|
+
if (node) return at ? located(node, at) : node;
|
|
271
|
+
}
|
|
272
|
+
return located(
|
|
273
|
+
isSVG ? document.createElementNS(SVG_NAMESPACE, tag) : document.createElement(tag),
|
|
274
|
+
at
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
function createTemplate(html, isSVG = false) {
|
|
278
|
+
const cached = templateCache.get(html);
|
|
279
|
+
if (cached) return cached;
|
|
280
|
+
const template = document.createElement("template");
|
|
281
|
+
if (isSVG) {
|
|
282
|
+
template.innerHTML = `<svg>${html}</svg>`;
|
|
283
|
+
} else {
|
|
284
|
+
template.innerHTML = html;
|
|
285
|
+
}
|
|
286
|
+
templateCache.set(html, template);
|
|
287
|
+
return template;
|
|
288
|
+
}
|
|
289
|
+
function templateNode(html, tag, holes = false, isSVG = false, at) {
|
|
290
|
+
if (isServer()) {
|
|
291
|
+
const nodes = getServerNodes();
|
|
292
|
+
return holes ? nodes.parseTemplate(html, isSVG) : nodes.createRaw(html);
|
|
293
|
+
}
|
|
294
|
+
if (hydration.active) {
|
|
295
|
+
const node = getHydrationWalker()?.hydrateStatic(tag);
|
|
296
|
+
if (node) return stampPositions(node, at);
|
|
297
|
+
}
|
|
298
|
+
return stampPositions(cloneTemplate(createTemplate(html, isSVG), isSVG).firstChild, at);
|
|
299
|
+
}
|
|
300
|
+
function stampPositions(node, at) {
|
|
301
|
+
const root = node;
|
|
302
|
+
if (!at || typeof root?.querySelectorAll !== "function") return node;
|
|
303
|
+
const all = [root, ...root.querySelectorAll("*")];
|
|
304
|
+
for (let i = 0; i < all.length && i * 2 + 1 < at.pos.length; i++) {
|
|
305
|
+
const line = at.pos[i * 2];
|
|
306
|
+
if (line) all[i][LOC_TAG] = { file: at.file, line, column: at.pos[i * 2 + 1] };
|
|
307
|
+
}
|
|
308
|
+
return node;
|
|
309
|
+
}
|
|
310
|
+
function holeScope(start, produce) {
|
|
311
|
+
if (!hydration.active) return produce();
|
|
312
|
+
const value = runHydrationAt(start.nextSibling, produce);
|
|
313
|
+
if (typeof value === "function") {
|
|
314
|
+
const accessor = value;
|
|
315
|
+
const wrapped = (...args) => hydration.active ? runHydrationAt(start.nextSibling, () => accessor(...args)) : accessor(...args);
|
|
316
|
+
return carryHoleTag(accessor, wrapped);
|
|
317
|
+
}
|
|
318
|
+
return value;
|
|
319
|
+
}
|
|
320
|
+
function carryHoleTag(from, to) {
|
|
321
|
+
const tag = from[HOLE_TAG];
|
|
322
|
+
if (tag !== void 0) to[HOLE_TAG] = tag;
|
|
323
|
+
return to;
|
|
324
|
+
}
|
|
325
|
+
function holeEnd(start) {
|
|
326
|
+
for (let n = start.nextSibling; n; n = n.nextSibling) {
|
|
327
|
+
if (n.nodeType === 8 && n.data === "fx/") return n;
|
|
328
|
+
}
|
|
329
|
+
throw new Error("[fluixi] template hole is missing its closing marker");
|
|
330
|
+
}
|
|
331
|
+
function holeContent(start, end) {
|
|
332
|
+
const nodes = [];
|
|
333
|
+
for (let n = start.nextSibling; n && n !== end; n = n.nextSibling) nodes.push(n);
|
|
334
|
+
return nodes;
|
|
335
|
+
}
|
|
336
|
+
function cloneTemplate(template, isSVG = false) {
|
|
337
|
+
const clone = template.content.cloneNode(true);
|
|
338
|
+
if (isSVG) return clone.firstChild;
|
|
339
|
+
return clone;
|
|
340
|
+
}
|
|
341
|
+
function makeArrayFlat(values) {
|
|
342
|
+
if (!Array.isArray(values)) return values;
|
|
343
|
+
if (values.length === 2 && values[1] === " ") {
|
|
344
|
+
if (Array.isArray(values[0])) return makeArrayFlat(values[0]);
|
|
345
|
+
if (typeof values[0] === "function") return values[0];
|
|
346
|
+
return values[0];
|
|
347
|
+
}
|
|
348
|
+
if (values.length === 1 && typeof values[0] === "function") return values[0];
|
|
349
|
+
return values;
|
|
350
|
+
}
|
|
351
|
+
function fnName(fn) {
|
|
352
|
+
if (typeof fn !== "function") return null;
|
|
353
|
+
return fn._name || fn.name || "anonymous";
|
|
354
|
+
}
|
|
355
|
+
function iterateFn(item) {
|
|
356
|
+
if (isSignal(item)) return item;
|
|
357
|
+
if (isComponent(item)) return item;
|
|
358
|
+
if (typeof item !== "function") return item;
|
|
359
|
+
let content = item();
|
|
360
|
+
while (typeof content === "function" && !isSignal(content) && !isComponent(content)) {
|
|
361
|
+
content = content();
|
|
362
|
+
}
|
|
363
|
+
return content;
|
|
364
|
+
}
|
|
365
|
+
var _insertDepth = 0;
|
|
366
|
+
var MAX_INSERT_DEPTH = 200;
|
|
367
|
+
function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
|
|
368
|
+
let current = initialCurrent;
|
|
369
|
+
const componentCache = /* @__PURE__ */ new Map();
|
|
370
|
+
return createRenderEffect(() => {
|
|
371
|
+
reportReactiveBinding(marker ?? parent, "content", void 0, getAccessor);
|
|
372
|
+
let value;
|
|
373
|
+
if (isComponent(getAccessor) && !isSignal(getAccessor)) {
|
|
374
|
+
if (!componentCache.has(getAccessor)) {
|
|
375
|
+
_insertDepth++;
|
|
376
|
+
try {
|
|
377
|
+
const inst = getAccessor();
|
|
378
|
+
componentCache.set(getAccessor, inst);
|
|
379
|
+
} finally {
|
|
380
|
+
_insertDepth--;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
value = componentCache.get(getAccessor);
|
|
384
|
+
while (typeof value === "function" && isSignal(value)) value = value();
|
|
385
|
+
} else {
|
|
386
|
+
value = getAccessor();
|
|
387
|
+
while (typeof value === "function" && isSignal(value)) {
|
|
388
|
+
value = value();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
{
|
|
392
|
+
let chainDepth = 0;
|
|
393
|
+
while (typeof value === "function" && chainDepth++ < 50) {
|
|
394
|
+
if (isComponent(value)) {
|
|
395
|
+
if (!componentCache.has(value)) {
|
|
396
|
+
const thunk = value;
|
|
397
|
+
_insertDepth++;
|
|
398
|
+
try {
|
|
399
|
+
const inst = thunk();
|
|
400
|
+
componentCache.set(thunk, inst);
|
|
401
|
+
} finally {
|
|
402
|
+
_insertDepth--;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
value = componentCache.get(value);
|
|
406
|
+
} else if (isSignal(value)) {
|
|
407
|
+
value = value();
|
|
408
|
+
} else {
|
|
409
|
+
value = value();
|
|
410
|
+
if (typeof value !== "function" || !isSignal(value) && !isComponent(value)) break;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
_insertDepth++;
|
|
415
|
+
try {
|
|
416
|
+
current = insertExpression(parent, value, marker, current, componentCache);
|
|
417
|
+
setCurrent(current);
|
|
418
|
+
} finally {
|
|
419
|
+
_insertDepth--;
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
function insert(parent, accessor, marker, init) {
|
|
424
|
+
if (_insertDepth > MAX_INSERT_DEPTH) {
|
|
425
|
+
console.error("[insert] Exceeded max call depth, possible infinite loop.");
|
|
426
|
+
return () => null;
|
|
427
|
+
}
|
|
428
|
+
if (marker !== void 0 && !marker) {
|
|
429
|
+
marker = createTextNode("", true);
|
|
430
|
+
parent.appendChild(marker);
|
|
431
|
+
}
|
|
432
|
+
let current = init ?? null;
|
|
433
|
+
const isReactiveArray = (element) => {
|
|
434
|
+
return Array.isArray(element) && element.some((v) => typeof v === "function");
|
|
435
|
+
};
|
|
436
|
+
const normalizeAccessor = (accessor2) => {
|
|
437
|
+
if (typeof accessor2 === "function") return accessor2;
|
|
438
|
+
return () => accessor2;
|
|
439
|
+
};
|
|
440
|
+
if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
|
|
441
|
+
_insertDepth++;
|
|
442
|
+
try {
|
|
443
|
+
current = insertExpression(parent, accessor, marker, current);
|
|
444
|
+
} finally {
|
|
445
|
+
_insertDepth--;
|
|
446
|
+
}
|
|
447
|
+
return () => current;
|
|
448
|
+
}
|
|
449
|
+
const dispose = _createInsertEffect(
|
|
450
|
+
normalizeAccessor(accessor),
|
|
451
|
+
parent,
|
|
452
|
+
marker,
|
|
453
|
+
current,
|
|
454
|
+
(v) => {
|
|
455
|
+
current = v;
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
return () => {
|
|
459
|
+
dispose?.();
|
|
460
|
+
return current;
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function insertExpression(parent, value, marker, current, componentCache) {
|
|
464
|
+
if (value == null || typeof value === "boolean") {
|
|
465
|
+
return cleanChildren(parent, current, marker);
|
|
466
|
+
}
|
|
467
|
+
if (typeof value === "function") {
|
|
468
|
+
while (typeof value === "function") {
|
|
469
|
+
value = value();
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (value == null || typeof value === "boolean") {
|
|
473
|
+
return cleanChildren(parent, current, marker);
|
|
474
|
+
}
|
|
475
|
+
if (isPromise(value)) {
|
|
476
|
+
const placeholder = createTextNode("", true);
|
|
477
|
+
if (Array.isArray(current)) {
|
|
478
|
+
if (current.length > 0) {
|
|
479
|
+
parent.replaceChild(placeholder, current[0]);
|
|
480
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
481
|
+
} else {
|
|
482
|
+
insertBefore(parent, placeholder, marker);
|
|
483
|
+
}
|
|
484
|
+
} else if (current) {
|
|
485
|
+
parent.replaceChild(placeholder, current);
|
|
486
|
+
} else {
|
|
487
|
+
insertBefore(parent, placeholder, marker);
|
|
488
|
+
}
|
|
489
|
+
value.then((resolved) => {
|
|
490
|
+
if (placeholder.parentNode === parent) {
|
|
491
|
+
insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
|
|
492
|
+
}
|
|
493
|
+
}).catch((err) => {
|
|
494
|
+
console.error("Error resolving promise in insertExpression:", err);
|
|
495
|
+
});
|
|
496
|
+
return placeholder;
|
|
497
|
+
}
|
|
498
|
+
const t = typeof value;
|
|
499
|
+
if (t === "string" || t === "number") {
|
|
500
|
+
if (t === "number") value = String(value);
|
|
501
|
+
if (Array.isArray(current)) {
|
|
502
|
+
if (current.length === 0) {
|
|
503
|
+
const node2 = createTextNode(value);
|
|
504
|
+
insertBefore(parent, node2, marker);
|
|
505
|
+
return node2;
|
|
506
|
+
}
|
|
507
|
+
if (current.length === 1 && current[0].nodeType === 3) {
|
|
508
|
+
current[0].data = value;
|
|
509
|
+
return current;
|
|
510
|
+
}
|
|
511
|
+
current = cleanChildren(parent, current, marker);
|
|
512
|
+
}
|
|
513
|
+
if (current && isDomText(current)) {
|
|
514
|
+
current.data = value;
|
|
515
|
+
return current;
|
|
516
|
+
}
|
|
517
|
+
const node = createTextNode(value);
|
|
518
|
+
if (current && current.parentNode === parent) {
|
|
519
|
+
parent.replaceChild(node, current);
|
|
520
|
+
} else if (!isAdopted(parent, node)) {
|
|
521
|
+
insertBefore(parent, node, marker);
|
|
522
|
+
}
|
|
523
|
+
return node;
|
|
524
|
+
}
|
|
525
|
+
if (isDomNode(value)) {
|
|
526
|
+
if (isAdopted(parent, value)) {
|
|
527
|
+
ascendPast(value);
|
|
528
|
+
return value;
|
|
529
|
+
}
|
|
530
|
+
if (Array.isArray(current)) {
|
|
531
|
+
if (current.length === 0) {
|
|
532
|
+
insertBefore(parent, value, marker);
|
|
533
|
+
} else if (current[0].parentNode === parent) {
|
|
534
|
+
parent.replaceChild(value, current[0]);
|
|
535
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
536
|
+
} else {
|
|
537
|
+
insertBefore(parent, value, marker);
|
|
538
|
+
}
|
|
539
|
+
return value;
|
|
540
|
+
}
|
|
541
|
+
if (!current) {
|
|
542
|
+
insertBefore(parent, value, marker);
|
|
543
|
+
} else if (current !== value) {
|
|
544
|
+
if (current.parentNode === parent) {
|
|
545
|
+
parent.replaceChild(value, current);
|
|
546
|
+
} else {
|
|
547
|
+
insertBefore(parent, value, marker);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return value;
|
|
551
|
+
}
|
|
552
|
+
if (Array.isArray(value)) {
|
|
553
|
+
const array = [];
|
|
554
|
+
const currentArray = Array.isArray(current) ? current : current ? [current] : [];
|
|
555
|
+
const reactiveSlots = [];
|
|
556
|
+
flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
|
|
557
|
+
const reconciled = reconcileArrays(parent, currentArray, array, marker);
|
|
558
|
+
for (const slot of reactiveSlots) {
|
|
559
|
+
const disposeSlot = insert(parent, slot.sig, slot.marker);
|
|
560
|
+
onCleanup(() => {
|
|
561
|
+
cleanChildren(parent, disposeSlot());
|
|
562
|
+
if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
return reconciled;
|
|
566
|
+
}
|
|
567
|
+
if (t === "object" && value !== null && typeof value === "object") {
|
|
568
|
+
const objValue = value;
|
|
569
|
+
if ("type" in objValue && "props" in objValue) {
|
|
570
|
+
const jsxValue = objValue;
|
|
571
|
+
if (typeof jsxValue.type === "function") {
|
|
572
|
+
const result = jsxValue.type(jsxValue.props || {});
|
|
573
|
+
return insertExpression(parent, result, marker, current);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
return cleanChildren(parent, current, marker);
|
|
578
|
+
}
|
|
579
|
+
function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
|
|
580
|
+
for (let i = 0; i < arr.length; i++) {
|
|
581
|
+
let item = arr[i];
|
|
582
|
+
if (item == null || typeof item === "boolean") continue;
|
|
583
|
+
while (typeof item === "function" && !isPromise(item) && !isSignal(item) && !isComponent(item)) {
|
|
584
|
+
item = item();
|
|
585
|
+
if (item == null || typeof item === "boolean") break;
|
|
586
|
+
}
|
|
587
|
+
if (item == null || typeof item === "boolean") continue;
|
|
588
|
+
if (typeof item === "function") {
|
|
589
|
+
let resolved;
|
|
590
|
+
if (isComponent(item) && !isSignal(item)) {
|
|
591
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
592
|
+
if (!componentCache.has(item)) componentCache.set(item, item());
|
|
593
|
+
resolved = componentCache.get(item);
|
|
594
|
+
} else {
|
|
595
|
+
resolved = item();
|
|
596
|
+
}
|
|
597
|
+
while (typeof resolved === "function" && !isPromise(resolved) && !isSignal(resolved) && !isComponent(resolved)) {
|
|
598
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
599
|
+
if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
|
|
600
|
+
resolved = componentCache.get(resolved);
|
|
601
|
+
}
|
|
602
|
+
if (resolved == null || typeof resolved === "boolean") continue;
|
|
603
|
+
if (typeof resolved === "function") {
|
|
604
|
+
if (isSignal(resolved)) {
|
|
605
|
+
if (reactiveSlots) {
|
|
606
|
+
const slot = createTextNode("", true);
|
|
607
|
+
result.push(slot);
|
|
608
|
+
reactiveSlots.push({ marker: slot, sig: resolved });
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
let val = resolved();
|
|
612
|
+
while (typeof val === "function" && isSignal(val)) val = val();
|
|
613
|
+
if (val == null || typeof val === "boolean") continue;
|
|
614
|
+
if (Array.isArray(val)) {
|
|
615
|
+
flattenArray(val, result, parent, marker, track, componentCache);
|
|
616
|
+
} else flattenArray([val], result, parent, marker, track, componentCache);
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
|
|
622
|
+
else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
if (isPromise(item)) {
|
|
626
|
+
const placeholder = createTextNode("", true);
|
|
627
|
+
result.push(placeholder);
|
|
628
|
+
item.then((resolved) => {
|
|
629
|
+
if (placeholder.parentNode) {
|
|
630
|
+
const tempNodes = [];
|
|
631
|
+
flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
|
|
632
|
+
if (tempNodes.length > 0) {
|
|
633
|
+
placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
|
|
634
|
+
for (let j = 1; j < tempNodes.length; j++) {
|
|
635
|
+
placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}).catch((err) => console.error("Error resolving promise in array:", err));
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
if (Array.isArray(item)) {
|
|
643
|
+
flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
if (isDomNode(item)) {
|
|
647
|
+
result.push(item);
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
|
|
651
|
+
const jsxItem = item;
|
|
652
|
+
if (typeof jsxItem.type === "function") {
|
|
653
|
+
const resolved = jsxItem.type(jsxItem.props || {});
|
|
654
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
|
|
655
|
+
else flattenArray([resolved], result, parent, marker, false, componentCache);
|
|
656
|
+
continue;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
660
|
+
const str = String(item);
|
|
661
|
+
if (str.trim() === "" && str !== " ") continue;
|
|
662
|
+
result.push(createTextNode(str));
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
result.push(createTextNode(String(item)));
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
function reconcileArrays(parent, a, b, marker) {
|
|
669
|
+
for (let i = 0; i < b.length; i++) {
|
|
670
|
+
const owner = b[i].parentNode;
|
|
671
|
+
if (owner !== null && owner !== parent && owner.nodeType !== 11) {
|
|
672
|
+
b = b.slice();
|
|
673
|
+
b[i] = b[i].cloneNode(true);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = aEnd > 0 ? a[aEnd - 1].nextSibling ?? void 0 : marker, map = null;
|
|
677
|
+
while (aStart < aEnd || bStart < bEnd) {
|
|
678
|
+
if (a[aStart] === b[bStart]) {
|
|
679
|
+
aStart++;
|
|
680
|
+
bStart++;
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
|
|
684
|
+
aEnd--;
|
|
685
|
+
bEnd--;
|
|
686
|
+
}
|
|
687
|
+
if (aEnd === aStart) {
|
|
688
|
+
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
|
|
689
|
+
while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
|
|
690
|
+
} else if (bEnd === bStart) {
|
|
691
|
+
while (aStart < aEnd) {
|
|
692
|
+
if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
|
|
693
|
+
parent.removeChild(a[aStart]);
|
|
694
|
+
aStart++;
|
|
695
|
+
}
|
|
696
|
+
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
697
|
+
const node = a[--aEnd].nextSibling;
|
|
698
|
+
insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
|
|
699
|
+
insertBefore(parent, b[--bEnd], node);
|
|
700
|
+
a[aEnd] = a[aStart - 1];
|
|
701
|
+
} else {
|
|
702
|
+
if (!map) {
|
|
703
|
+
map = /* @__PURE__ */ new Map();
|
|
704
|
+
let i = bStart;
|
|
705
|
+
while (i < bEnd) map.set(b[i], i++);
|
|
706
|
+
}
|
|
707
|
+
const index = map.get(a[aStart]);
|
|
708
|
+
if (index != null) {
|
|
709
|
+
if (bStart < index && index < bEnd) {
|
|
710
|
+
let i = aStart, sequence = 1;
|
|
711
|
+
while (++i < aEnd && i < bEnd) {
|
|
712
|
+
if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
|
|
713
|
+
sequence++;
|
|
714
|
+
}
|
|
715
|
+
if (sequence > index - bStart) {
|
|
716
|
+
const node = a[aStart];
|
|
717
|
+
while (bStart < index) insertBefore(parent, b[bStart++], node);
|
|
718
|
+
} else {
|
|
719
|
+
if (a[aStart].parentNode === parent) {
|
|
720
|
+
parent.replaceChild(b[bStart++], a[aStart++]);
|
|
721
|
+
} else {
|
|
722
|
+
insertBefore(parent, b[bStart++], after);
|
|
723
|
+
aStart++;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
} else {
|
|
727
|
+
aStart++;
|
|
728
|
+
}
|
|
729
|
+
} else {
|
|
730
|
+
if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
|
|
731
|
+
aStart++;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return b;
|
|
736
|
+
}
|
|
737
|
+
function cleanChildren(parent, current, marker) {
|
|
738
|
+
if (current) {
|
|
739
|
+
if (Array.isArray(current)) {
|
|
740
|
+
for (let i = 0; i < current.length; i++) {
|
|
741
|
+
if (current[i].parentNode === parent) parent.removeChild(current[i]);
|
|
742
|
+
}
|
|
743
|
+
} else if (current.parentNode === parent) {
|
|
744
|
+
parent.removeChild(current);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
function insertBefore(parent, node, marker) {
|
|
750
|
+
if (hydration.active && node.parentNode === parent) return;
|
|
751
|
+
if (marker) {
|
|
752
|
+
if (marker.parentNode === parent) {
|
|
753
|
+
parent.insertBefore(node, marker);
|
|
754
|
+
} else {
|
|
755
|
+
parent.appendChild(node);
|
|
756
|
+
}
|
|
757
|
+
} else {
|
|
758
|
+
parent.appendChild(node);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
function setProperty(element, name, value) {
|
|
762
|
+
if (value == null) delete element[name];
|
|
763
|
+
else element[name] = value;
|
|
764
|
+
}
|
|
765
|
+
function addNativeEventListener(element, name, value) {
|
|
766
|
+
let handler = value;
|
|
767
|
+
let options;
|
|
768
|
+
if (Array.isArray(value)) {
|
|
769
|
+
handler = value[0];
|
|
770
|
+
options = value[1];
|
|
771
|
+
}
|
|
772
|
+
if (typeof handler !== "function") return () => {
|
|
773
|
+
};
|
|
774
|
+
element.addEventListener(name, handler, options);
|
|
775
|
+
return () => element.removeEventListener(name, handler, options);
|
|
776
|
+
}
|
|
777
|
+
function reportMarked(element, accessor) {
|
|
778
|
+
if (!accessor || typeof accessor !== "function") return;
|
|
779
|
+
const written = accessor[HOLE_TAG]?.name;
|
|
780
|
+
if (!written) return;
|
|
781
|
+
const colon = written.indexOf(":");
|
|
782
|
+
if (colon === -1) return;
|
|
783
|
+
reportReactiveDirective(element, written.slice(0, colon), written.slice(colon + 1), accessor);
|
|
784
|
+
}
|
|
785
|
+
function reportKeys(element, kind, value) {
|
|
786
|
+
const from = typeof value === "function" ? untrack(() => value()) : value;
|
|
787
|
+
if (!from || typeof from !== "object") return;
|
|
788
|
+
for (const key of Object.keys(from)) reportReactiveDirective(element, kind, key);
|
|
789
|
+
}
|
|
790
|
+
function applyUse(element, value) {
|
|
791
|
+
const call = (dir, accessor) => {
|
|
792
|
+
if (typeof dir !== "function") return;
|
|
793
|
+
reportReactiveDirective(element, "use", dir.name || "use", accessor);
|
|
794
|
+
dir(element, accessor ?? (() => void 0));
|
|
795
|
+
};
|
|
796
|
+
if (typeof value === "function") {
|
|
797
|
+
call(value);
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
if (!Array.isArray(value)) return;
|
|
801
|
+
if (typeof value[0] === "function") {
|
|
802
|
+
call(value[0], value[1]);
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
for (const pair of value) {
|
|
806
|
+
if (Array.isArray(pair)) call(pair[0], pair[1]);
|
|
807
|
+
else call(pair);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
function setDynamicAttribute(element, name, accessor, isSVG = false) {
|
|
811
|
+
reportMarked(element, accessor);
|
|
812
|
+
if (typeof accessor !== "function") {
|
|
813
|
+
setAttribute(element, name, accessor, isSVG);
|
|
814
|
+
return () => {
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
return createRenderEffect(() => {
|
|
818
|
+
reportReactiveBinding(element, "attribute", name, accessor);
|
|
819
|
+
const value = typeof accessor === "function" ? accessor() : accessor;
|
|
820
|
+
setAttribute(element, name, value, isSVG);
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
function setDynamicProperty(element, name, accessor) {
|
|
824
|
+
if (typeof accessor !== "function") {
|
|
825
|
+
setProperty(element, name, accessor);
|
|
826
|
+
return () => {
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
reportMarked(element, accessor);
|
|
830
|
+
return createRenderEffect(() => {
|
|
831
|
+
reportReactiveBinding(element, "property", name, accessor);
|
|
832
|
+
const value = typeof accessor === "function" ? accessor() : accessor;
|
|
833
|
+
setProperty(element, name, value);
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
function setDynamicBoolAttribute(element, name, accessor) {
|
|
837
|
+
if (typeof accessor !== "function") {
|
|
838
|
+
setAttribute(element, name, !!accessor);
|
|
839
|
+
return () => {
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
return createRenderEffect(() => {
|
|
843
|
+
reportReactiveBinding(element, "attribute", name, accessor);
|
|
844
|
+
const value = accessor();
|
|
845
|
+
setAttribute(element, name, !!value);
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
function setClassName(element, value) {
|
|
849
|
+
if (value == null) {
|
|
850
|
+
element.removeAttribute("class");
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
if (typeof value === "function") {
|
|
854
|
+
createRenderEffect(() => {
|
|
855
|
+
reportReactiveBinding(element, "attribute", "class", value);
|
|
856
|
+
setClassName(element, value());
|
|
857
|
+
});
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
if (typeof value === "string") {
|
|
861
|
+
element.setAttribute("class", value);
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
if (Array.isArray(value)) {
|
|
865
|
+
element.setAttribute("class", value.filter(Boolean).join(" "));
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
if (typeof value === "object") {
|
|
869
|
+
const classes = Object.keys(value).filter((key) => {
|
|
870
|
+
const v = value[key];
|
|
871
|
+
return typeof v === "function" ? v() : Boolean(v);
|
|
872
|
+
}).join(" ");
|
|
873
|
+
element.setAttribute("class", classes);
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
element.setAttribute("class", String(value));
|
|
877
|
+
}
|
|
878
|
+
function setClassList(element, value, disposers) {
|
|
879
|
+
if (!value || typeof value !== "object") return;
|
|
880
|
+
for (const name in value) {
|
|
881
|
+
const cond = value[name];
|
|
882
|
+
const names = name.split(/\s+/).filter(Boolean);
|
|
883
|
+
if (typeof cond === "function" && disposers) {
|
|
884
|
+
disposers.push(
|
|
885
|
+
createRenderEffect(() => {
|
|
886
|
+
const on = !!cond();
|
|
887
|
+
for (const n of names) element.classList.toggle(n, on);
|
|
888
|
+
})
|
|
889
|
+
);
|
|
890
|
+
} else {
|
|
891
|
+
const on = !!(typeof cond === "function" ? cond() : cond);
|
|
892
|
+
for (const n of names) element.classList.toggle(n, on);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
function setStyle(element, _value) {
|
|
897
|
+
let value = _value;
|
|
898
|
+
while (typeof value === "function") value = value();
|
|
899
|
+
if (value == null) {
|
|
900
|
+
element.removeAttribute("style");
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
if (typeof value === "string") {
|
|
904
|
+
element.style.cssText = value;
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
if (typeof value === "object") {
|
|
908
|
+
for (const key in value) {
|
|
909
|
+
const styleValue = value[key];
|
|
910
|
+
if (styleValue == null) element.style[key] = "";
|
|
911
|
+
else element.style[key] = styleValue;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
function spread(options) {
|
|
916
|
+
const {
|
|
917
|
+
element,
|
|
918
|
+
props,
|
|
919
|
+
prevProps = EMPTY_OBJ,
|
|
920
|
+
isSVG = false,
|
|
921
|
+
skipChildren = false
|
|
922
|
+
} = options;
|
|
923
|
+
if (!element || !isDomElement(element)) {
|
|
924
|
+
console.error("[spread] Error: element is not a DOM Element!");
|
|
925
|
+
return () => {
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
if (!props) {
|
|
929
|
+
console.warn("[spread] Warning: props is undefined!");
|
|
930
|
+
return () => {
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
const elementIsSVG = isSVG || element.namespaceURI === SVG_NAMESPACE;
|
|
934
|
+
const disposers = [];
|
|
935
|
+
for (const key in props) {
|
|
936
|
+
if (skipChildren && key === "children") continue;
|
|
937
|
+
const value = props[key];
|
|
938
|
+
const prev = prevProps[key];
|
|
939
|
+
if (value === prev) continue;
|
|
940
|
+
if (key === "ref") {
|
|
941
|
+
handleRef(value, element);
|
|
942
|
+
continue;
|
|
943
|
+
}
|
|
944
|
+
if (key === "use") {
|
|
945
|
+
applyUse(element, value);
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
if (key.startsWith("on:")) {
|
|
949
|
+
disposers.push(addNativeEventListener(element, key.slice(3), value));
|
|
950
|
+
continue;
|
|
951
|
+
}
|
|
952
|
+
if (key.startsWith("prop:")) {
|
|
953
|
+
reportReactiveDirective(element, "prop", key.slice(5), value);
|
|
954
|
+
disposers.push(setDynamicProperty(element, key.slice(5), value));
|
|
955
|
+
continue;
|
|
956
|
+
}
|
|
957
|
+
if (key.startsWith("attr:")) {
|
|
958
|
+
reportReactiveDirective(element, "attr", key.slice(5), value);
|
|
959
|
+
disposers.push(setDynamicAttribute(element, key.slice(5), value, elementIsSVG));
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
962
|
+
if (key.startsWith("bool:")) {
|
|
963
|
+
reportReactiveDirective(element, "bool", key.slice(5), value);
|
|
964
|
+
disposers.push(setDynamicBoolAttribute(element, key.slice(5), value));
|
|
965
|
+
continue;
|
|
966
|
+
}
|
|
967
|
+
if (key === "class" || key === "className") {
|
|
968
|
+
if (typeof value === "function") {
|
|
969
|
+
disposers.push(
|
|
970
|
+
createRenderEffect(() => {
|
|
971
|
+
reportReactiveBinding(element, "attribute", "class", value);
|
|
972
|
+
setClassName(element, value());
|
|
973
|
+
})
|
|
974
|
+
);
|
|
975
|
+
} else {
|
|
976
|
+
setClassName(element, value);
|
|
977
|
+
}
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
980
|
+
if (key === "classList") {
|
|
981
|
+
reportKeys(element, "class", value);
|
|
982
|
+
if (typeof value === "function") {
|
|
983
|
+
disposers.push(
|
|
984
|
+
createRenderEffect(() => {
|
|
985
|
+
reportReactiveBinding(element, "attribute", "class", value);
|
|
986
|
+
setClassList(element, value());
|
|
987
|
+
})
|
|
988
|
+
);
|
|
989
|
+
} else {
|
|
990
|
+
setClassList(element, value, disposers);
|
|
991
|
+
}
|
|
992
|
+
continue;
|
|
993
|
+
}
|
|
994
|
+
if (key === "style") {
|
|
995
|
+
reportKeys(element, "style", value);
|
|
996
|
+
if (typeof value === "function") {
|
|
997
|
+
disposers.push(
|
|
998
|
+
createRenderEffect(() => {
|
|
999
|
+
reportReactiveBinding(element, "attribute", "style", value);
|
|
1000
|
+
setStyle(element, value());
|
|
1001
|
+
})
|
|
1002
|
+
);
|
|
1003
|
+
} else {
|
|
1004
|
+
setStyle(element, value);
|
|
1005
|
+
}
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
if (key.startsWith("on")) {
|
|
1009
|
+
const eventName = key.slice(2).toLowerCase();
|
|
1010
|
+
if (prev) removeDelegatedEventListener(element, eventName);
|
|
1011
|
+
if (value) addDelegatedEventListener(element, eventName, value);
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
const asProperty = JSX_PROPERTIES.has(key) || !elementIsSVG && key in element;
|
|
1015
|
+
if (typeof value === "function") {
|
|
1016
|
+
disposers.push(
|
|
1017
|
+
asProperty ? setDynamicProperty(element, key, value) : setDynamicAttribute(element, key, value, elementIsSVG)
|
|
1018
|
+
);
|
|
1019
|
+
} else {
|
|
1020
|
+
disposers.push(
|
|
1021
|
+
createRenderEffect(
|
|
1022
|
+
() => asProperty ? setProperty(element, key, props[key]) : setAttribute(element, key, props[key], elementIsSVG)
|
|
1023
|
+
)
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
for (const key in prevProps) {
|
|
1028
|
+
if (!(key in props)) {
|
|
1029
|
+
if (key.startsWith("on")) {
|
|
1030
|
+
const eventName = key.slice(2).toLowerCase();
|
|
1031
|
+
removeDelegatedEventListener(element, eventName);
|
|
1032
|
+
} else if (JSX_PROPERTIES.has(key)) {
|
|
1033
|
+
setProperty(element, key, null);
|
|
1034
|
+
} else {
|
|
1035
|
+
element.removeAttribute(key);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
return () => {
|
|
1040
|
+
disposers.forEach((d) => d());
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
function applyProps(element, props, isSVG = false) {
|
|
1044
|
+
for (const key in props) {
|
|
1045
|
+
const val = props[key];
|
|
1046
|
+
if (key === "ref") {
|
|
1047
|
+
handleRef(val, element);
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
if (key === "children") continue;
|
|
1051
|
+
if (key === "use") {
|
|
1052
|
+
applyUse(element, val);
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
if (key.startsWith("on:")) {
|
|
1056
|
+
addNativeEventListener(element, key.slice(3), val);
|
|
1057
|
+
continue;
|
|
1058
|
+
}
|
|
1059
|
+
if (key.startsWith("prop:")) {
|
|
1060
|
+
reportReactiveDirective(element, "prop", key.slice(5), val);
|
|
1061
|
+
setDynamicProperty(element, key.slice(5), val);
|
|
1062
|
+
continue;
|
|
1063
|
+
}
|
|
1064
|
+
if (key.startsWith("attr:")) {
|
|
1065
|
+
reportReactiveDirective(element, "attr", key.slice(5), val);
|
|
1066
|
+
setDynamicAttribute(element, key.slice(5), val, isSVG);
|
|
1067
|
+
continue;
|
|
1068
|
+
}
|
|
1069
|
+
if (key.startsWith("bool:")) {
|
|
1070
|
+
reportReactiveDirective(element, "bool", key.slice(5), val);
|
|
1071
|
+
setDynamicBoolAttribute(element, key.slice(5), val);
|
|
1072
|
+
continue;
|
|
1073
|
+
}
|
|
1074
|
+
if (key.startsWith("on") && key.length > 2) {
|
|
1075
|
+
const name = key.slice(2).toLowerCase();
|
|
1076
|
+
if (typeof val === "function") {
|
|
1077
|
+
if (NON_DELEGATED.has(name)) {
|
|
1078
|
+
element[`$$${name}`] = val;
|
|
1079
|
+
const listenerKey = `__fx_${name}`;
|
|
1080
|
+
if (!element[listenerKey]) {
|
|
1081
|
+
const forwarder = (e) => {
|
|
1082
|
+
element[`$$${name}`]?.(e);
|
|
1083
|
+
};
|
|
1084
|
+
element.addEventListener(name, forwarder);
|
|
1085
|
+
element[listenerKey] = forwarder;
|
|
1086
|
+
}
|
|
1087
|
+
} else {
|
|
1088
|
+
element[`$$${name}`] = val;
|
|
1089
|
+
if (!delegatedSet.has(name)) delegateEvents([name]);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
continue;
|
|
1093
|
+
}
|
|
1094
|
+
if (key === "class" || key === "className") {
|
|
1095
|
+
setClassName(element, val);
|
|
1096
|
+
continue;
|
|
1097
|
+
}
|
|
1098
|
+
if (key === "classList") {
|
|
1099
|
+
reportKeys(element, "class", val);
|
|
1100
|
+
if (typeof val === "function")
|
|
1101
|
+
createRenderEffect(() => {
|
|
1102
|
+
reportReactiveBinding(element, "attribute", "class", val);
|
|
1103
|
+
setClassList(element, val());
|
|
1104
|
+
});
|
|
1105
|
+
else setClassList(element, val);
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1108
|
+
if (key === "style") {
|
|
1109
|
+
reportKeys(element, "style", val);
|
|
1110
|
+
if (typeof val === "function")
|
|
1111
|
+
createRenderEffect(() => {
|
|
1112
|
+
reportReactiveBinding(element, "attribute", "style", val);
|
|
1113
|
+
setStyle(element, val());
|
|
1114
|
+
});
|
|
1115
|
+
else setStyle(element, val);
|
|
1116
|
+
continue;
|
|
1117
|
+
}
|
|
1118
|
+
if (key === "innerHTML") {
|
|
1119
|
+
if (typeof val === "function") {
|
|
1120
|
+
const dispose = createEffect(() => {
|
|
1121
|
+
let v = val();
|
|
1122
|
+
while (typeof v === "function") v = v();
|
|
1123
|
+
element.innerHTML = v;
|
|
1124
|
+
});
|
|
1125
|
+
onCleanup(() => dispose());
|
|
1126
|
+
} else {
|
|
1127
|
+
element.innerHTML = val;
|
|
1128
|
+
}
|
|
1129
|
+
continue;
|
|
1130
|
+
}
|
|
1131
|
+
if (key === "value" && (element.tagName === "INPUT" || element.tagName === "TEXTAREA")) {
|
|
1132
|
+
if (typeof val === "function") {
|
|
1133
|
+
const dispose = createEffect(() => {
|
|
1134
|
+
let v = val();
|
|
1135
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1136
|
+
if (document.activeElement !== element) {
|
|
1137
|
+
element.value = v ?? "";
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
onCleanup(() => {
|
|
1141
|
+
dispose();
|
|
1142
|
+
});
|
|
1143
|
+
} else {
|
|
1144
|
+
createRenderEffect(() => {
|
|
1145
|
+
if (document.activeElement !== element) {
|
|
1146
|
+
element.value = props[key] ?? "";
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
continue;
|
|
1151
|
+
}
|
|
1152
|
+
if (key === "checked" && element.tagName === "INPUT") {
|
|
1153
|
+
if (typeof val === "function") {
|
|
1154
|
+
const dispose = createEffect(() => {
|
|
1155
|
+
let v = val();
|
|
1156
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1157
|
+
if (document.activeElement !== element) {
|
|
1158
|
+
element.checked = v ?? "";
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
onCleanup(() => {
|
|
1162
|
+
dispose();
|
|
1163
|
+
});
|
|
1164
|
+
} else {
|
|
1165
|
+
createRenderEffect(() => {
|
|
1166
|
+
if (document.activeElement !== element) {
|
|
1167
|
+
element.checked = props[key] ?? "";
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
continue;
|
|
1172
|
+
}
|
|
1173
|
+
if (key === "value" && element.tagName === "SELECT") {
|
|
1174
|
+
if (typeof val === "function") {
|
|
1175
|
+
let firstRun = true;
|
|
1176
|
+
const dispose = createEffect(() => {
|
|
1177
|
+
let v = val();
|
|
1178
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1179
|
+
if (firstRun) {
|
|
1180
|
+
firstRun = false;
|
|
1181
|
+
queueMicrotask(() => {
|
|
1182
|
+
element.value = v ?? "";
|
|
1183
|
+
});
|
|
1184
|
+
} else {
|
|
1185
|
+
element.value = v ?? "";
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
onCleanup(() => {
|
|
1189
|
+
dispose();
|
|
1190
|
+
});
|
|
1191
|
+
} else {
|
|
1192
|
+
let firstRun = true;
|
|
1193
|
+
createRenderEffect(() => {
|
|
1194
|
+
const v = props[key];
|
|
1195
|
+
if (firstRun) {
|
|
1196
|
+
firstRun = false;
|
|
1197
|
+
queueMicrotask(() => {
|
|
1198
|
+
element.value = v ?? "";
|
|
1199
|
+
});
|
|
1200
|
+
} else {
|
|
1201
|
+
element.value = v ?? "";
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
if (typeof val === "function") {
|
|
1208
|
+
const dispose = createEffect(() => {
|
|
1209
|
+
let v = val();
|
|
1210
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1211
|
+
applyElementProp(element, key, v, isSVG);
|
|
1212
|
+
});
|
|
1213
|
+
onCleanup(() => {
|
|
1214
|
+
dispose();
|
|
1215
|
+
});
|
|
1216
|
+
} else {
|
|
1217
|
+
createRenderEffect(() => applyElementProp(element, key, props[key], isSVG));
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
function mergeProps(...sources) {
|
|
1222
|
+
const resolve = (key) => {
|
|
1223
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1224
|
+
const s = sources[i];
|
|
1225
|
+
if (s && key in s && s[key] !== void 0) return s[key];
|
|
1226
|
+
}
|
|
1227
|
+
return void 0;
|
|
1228
|
+
};
|
|
1229
|
+
const hasKey = (key) => {
|
|
1230
|
+
for (const s of sources) if (s && key in s) return true;
|
|
1231
|
+
return false;
|
|
1232
|
+
};
|
|
1233
|
+
return new Proxy({}, {
|
|
1234
|
+
get: (_, key) => resolve(key),
|
|
1235
|
+
has: (_, key) => hasKey(key),
|
|
1236
|
+
ownKeys: () => {
|
|
1237
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1238
|
+
for (const s of sources) if (s) for (const k of Reflect.ownKeys(s)) keys.add(k);
|
|
1239
|
+
return [...keys];
|
|
1240
|
+
},
|
|
1241
|
+
getOwnPropertyDescriptor: (_, key) => hasKey(key) ? { enumerable: true, configurable: true, get: () => resolve(key) } : void 0
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
function splitProps(props, ...keys) {
|
|
1245
|
+
const taken = /* @__PURE__ */ new Set();
|
|
1246
|
+
for (const group of keys) for (const k of group) taken.add(k);
|
|
1247
|
+
const descriptor = (p) => ({
|
|
1248
|
+
enumerable: true,
|
|
1249
|
+
configurable: true,
|
|
1250
|
+
get: () => props[p]
|
|
1251
|
+
});
|
|
1252
|
+
const groups = keys.map((group) => {
|
|
1253
|
+
const keySet = new Set(group);
|
|
1254
|
+
return new Proxy({}, {
|
|
1255
|
+
get: (_, p) => keySet.has(p) ? props[p] : void 0,
|
|
1256
|
+
has: (_, p) => keySet.has(p) && p in props,
|
|
1257
|
+
ownKeys: () => Array.from(keySet).filter((k) => k in props),
|
|
1258
|
+
getOwnPropertyDescriptor: (_, p) => keySet.has(p) && p in props ? descriptor(p) : void 0
|
|
1259
|
+
});
|
|
1260
|
+
});
|
|
1261
|
+
const rest = new Proxy({}, {
|
|
1262
|
+
get: (_, p) => taken.has(p) ? void 0 : props[p],
|
|
1263
|
+
has: (_, p) => !taken.has(p) && p in props,
|
|
1264
|
+
ownKeys: () => Reflect.ownKeys(props).filter((k) => !taken.has(k)),
|
|
1265
|
+
getOwnPropertyDescriptor: (_, p) => !taken.has(p) && p in props ? descriptor(p) : void 0
|
|
1266
|
+
});
|
|
1267
|
+
return [...groups, rest];
|
|
1268
|
+
}
|
|
1269
|
+
function handleRef(ref, element) {
|
|
1270
|
+
if (!ref) return;
|
|
1271
|
+
const held = ref[HOLE_TAG]?.name;
|
|
1272
|
+
reportReactiveDirective(
|
|
1273
|
+
element,
|
|
1274
|
+
"ref",
|
|
1275
|
+
held || (typeof ref === "function" ? ref.name || "ref" : "ref"),
|
|
1276
|
+
ref
|
|
1277
|
+
);
|
|
1278
|
+
if (isDomNode(ref)) {
|
|
1279
|
+
const actualRef = element;
|
|
1280
|
+
const actualElement = ref;
|
|
1281
|
+
if (!actualRef) return;
|
|
1282
|
+
if (typeof actualRef === "function") actualRef(actualElement);
|
|
1283
|
+
else if (typeof actualRef === "object" && "current" in actualRef) actualRef.current = actualElement;
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
if (typeof ref === "function") ref(element);
|
|
1287
|
+
else if (typeof ref === "object" && "current" in ref) ref.current = element;
|
|
1288
|
+
}
|
|
1289
|
+
function createPortal(children, element, props) {
|
|
1290
|
+
const container = element || document.body;
|
|
1291
|
+
const resolved = readChildren(() => children);
|
|
1292
|
+
const cleanups = [];
|
|
1293
|
+
batch(() => {
|
|
1294
|
+
const dispose = createRenderEffect(() => {
|
|
1295
|
+
const nodes = resolved();
|
|
1296
|
+
if (Array.isArray(nodes)) {
|
|
1297
|
+
nodes.forEach((node) => container.appendChild(node));
|
|
1298
|
+
cleanups.push(() => {
|
|
1299
|
+
nodes.forEach((node) => {
|
|
1300
|
+
if (node.parentNode === container) {
|
|
1301
|
+
container.removeChild(node);
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1304
|
+
});
|
|
1305
|
+
} else if (isDomNode(nodes)) {
|
|
1306
|
+
container.appendChild(nodes);
|
|
1307
|
+
cleanups.push(() => {
|
|
1308
|
+
if (nodes.parentNode === container) {
|
|
1309
|
+
container.removeChild(nodes);
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
cleanups.push(dispose);
|
|
1315
|
+
onCleanup(() => {
|
|
1316
|
+
cleanups.forEach((fn) => fn());
|
|
1317
|
+
});
|
|
1318
|
+
});
|
|
1319
|
+
return null;
|
|
1320
|
+
}
|
|
1321
|
+
function isNativeElement(tag) {
|
|
1322
|
+
return typeof tag === "string" && tag.toLowerCase() === tag;
|
|
1323
|
+
}
|
|
1324
|
+
function isSVGElement(tag) {
|
|
1325
|
+
return tag === "svg" || tag === "path" || tag === "circle" || tag === "rect" || tag === "line" || tag === "polygon" || tag === "polyline" || tag === "ellipse" || tag === "g" || tag === "defs" || tag === "clipPath" || tag === "text";
|
|
1326
|
+
}
|
|
1327
|
+
function escapeHTML(str) {
|
|
1328
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1329
|
+
}
|
|
1330
|
+
function isPromise(v) {
|
|
1331
|
+
return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
|
|
1332
|
+
}
|
|
1333
|
+
function isAccessor(value) {
|
|
1334
|
+
return typeof value === "function" && value.length === 0 && isSignal(value);
|
|
1335
|
+
}
|
|
1336
|
+
function render(element, container, context) {
|
|
1337
|
+
if (!container) {
|
|
1338
|
+
throw new Error("Container element is required");
|
|
1339
|
+
}
|
|
1340
|
+
let rendererDispose;
|
|
1341
|
+
let disposeRoot;
|
|
1342
|
+
const disposers = [];
|
|
1343
|
+
createRoot((dispose) => {
|
|
1344
|
+
batch(() => {
|
|
1345
|
+
if (!hydration.active) {
|
|
1346
|
+
container.textContent = "";
|
|
1347
|
+
}
|
|
1348
|
+
stampVersions(container);
|
|
1349
|
+
warnOnVersionSkew();
|
|
1350
|
+
insert(container, element);
|
|
1351
|
+
return;
|
|
1352
|
+
});
|
|
1353
|
+
disposeRoot = dispose;
|
|
1354
|
+
});
|
|
1355
|
+
return () => {
|
|
1356
|
+
disposeRoot?.();
|
|
1357
|
+
rendererDispose?.();
|
|
1358
|
+
disposers.forEach((d) => d());
|
|
1359
|
+
container.textContent = "";
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
function bindPair(source) {
|
|
1363
|
+
if (Array.isArray(source)) return source;
|
|
1364
|
+
if (typeof source === "function" && typeof source.set === "function") {
|
|
1365
|
+
return [source, source.set];
|
|
1366
|
+
}
|
|
1367
|
+
throw new TypeError(
|
|
1368
|
+
"[fluixi] bind: needs a signal, either `signal(...)` or the `[get, set]` pair from `createSignal(...)`."
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
export {
|
|
1372
|
+
addDelegatedEventListener,
|
|
1373
|
+
addNativeEventListener,
|
|
1374
|
+
applyProps,
|
|
1375
|
+
applyUse,
|
|
1376
|
+
bindPair,
|
|
1377
|
+
cleanChildren,
|
|
1378
|
+
cloneTemplate,
|
|
1379
|
+
createNativeElement,
|
|
1380
|
+
createPortal,
|
|
1381
|
+
createTemplate,
|
|
1382
|
+
delegateEvents,
|
|
1383
|
+
escapeHTML,
|
|
1384
|
+
fnName,
|
|
1385
|
+
generateID,
|
|
1386
|
+
getStableElementId,
|
|
1387
|
+
handleRef,
|
|
1388
|
+
holeContent,
|
|
1389
|
+
holeEnd,
|
|
1390
|
+
holeScope,
|
|
1391
|
+
insert,
|
|
1392
|
+
insertExpression,
|
|
1393
|
+
isAccessor,
|
|
1394
|
+
isDelegatedEvent,
|
|
1395
|
+
isFunction,
|
|
1396
|
+
isNativeElement,
|
|
1397
|
+
isPromise,
|
|
1398
|
+
isSVGElement,
|
|
1399
|
+
iterateFn,
|
|
1400
|
+
makeArrayFlat,
|
|
1401
|
+
mergeProps,
|
|
1402
|
+
removeDelegatedEventListener,
|
|
1403
|
+
render,
|
|
1404
|
+
setClassList,
|
|
1405
|
+
setClassName,
|
|
1406
|
+
setDynamicAttribute,
|
|
1407
|
+
setDynamicBoolAttribute,
|
|
1408
|
+
setDynamicProperty,
|
|
1409
|
+
setProperty,
|
|
1410
|
+
setStyle,
|
|
1411
|
+
splitProps,
|
|
1412
|
+
spread,
|
|
1413
|
+
templateNode
|
|
1414
|
+
};
|