@fluixi/dom 1.0.0-alpha.83 → 1.0.0-alpha.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +2 -2
- 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.js +3 -3
- 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 +11 -11
- package/dist/lib/dom/island.mjs +769 -1
- package/dist/lib/dom/runtime.cjs +1432 -1
- package/dist/lib/dom/runtime.d.ts +60 -17
- package/dist/lib/dom/runtime.d.ts.map +1 -1
- package/dist/lib/dom/runtime.js +122 -79
- 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 +6 -0
- package/dist/lib/dom/server/host.d.ts.map +1 -1
- package/dist/lib/dom/server/host.js +7 -1
- 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 +23 -15
- 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 +2 -2
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +4 -115
- 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 +3 -3
- 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 +6 -6
- 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 m}from"@fluixi/reactive/signal";var K="http://www.w3.org/2000/svg";function he(e){return e.localName.includes("-")}function q(e,t,n,o=!1){if(n==null){e.removeAttribute(t);return}if(he(e)){e[t]=n;return}S(e,t,n,o)}var B=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function S(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 Fe=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;var Z="1.0.0-alpha.83";import{VERSION as be}from"@fluixi/reactive/version";var x={dom:Z,reactive:be};function Q(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 ee(){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 E(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as ae,createEffect as L,createRenderEffect as y,createRoot as we,onCleanup as A,readChildren as Se,reportReactiveBinding as h,reportReactiveDirective as b,untrack as ve}from"@fluixi/reactive/signal";var z=Symbol.for("fluixi.server-node"),Ee=Symbol.for("fluixi.dom.server-host"),Ne=globalThis,G=Ne[Ee]??={server:typeof document>"u",nodes:null};function C(){return G.server}function M(){if(!G.nodes)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return G.nodes}function P(e){return e!=null&&e[z]===!0?!0:typeof Node<"u"&&e instanceof Node}function te(e){return e!=null&&e[z]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function ne(e){return e!=null&&e[z]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var d={active:!1,cursor:null,parents:[]},Te=null;function R(){return Te}function X(e,t){return d.active&&t.parentNode===e}function oe(e){let t=d.parents.lastIndexOf(e);t!==-1&&(d.parents.length=t),d.cursor=e.nextSibling}function J(e,t){if(!e||e.parentNode==null)return t();let n=d.active,o=d.cursor,i=d.parents;d.active=!0,d.cursor=e,d.parents=[];try{return t()}finally{d.active=n,d.cursor=o,d.parents=i}}function Ae(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,i=e;for(;i=i.previousElementSibling;)i.tagName===e.tagName&&o++;n+=`:nth-of-type(${o+1})`,t.unshift(n),e=e.parentElement}return t.join(">")}function Ce(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 et(e){return Ce(Ae(e))}var tt=()=>"xxyxxxxxxy-4xx8".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),Pe={};var H="__fx_at",le="__fx_loc";function ie(e,t){return t&&(e[le]=t),e}var re=new Map,k=new Set,V=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function ue(e){if(!C())for(let t of e)k.has(t)||V.has(t)||(k.add(t),document.addEventListener(t,Le))}function Le(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 Me(e,t,n){if(e[`$$${t}`]=n,V.has(t)){let o=`__fx_${t}`;if(!e[o]){let i=a=>{e[`$$${t}`]?.(a)};e.addEventListener(t,i),e[o]=i}return}k.has(t)||ue([t])}function se(e,t){delete e[`$$${t}`];let n=`__fx_${t}`,o=e[n];o&&(e.removeEventListener(t,o),delete e[n])}function nt(e){return!V.has(e)}function ot(e){return typeof e=="function"}function w(e,t=!1){if(C())return M().createText(e);if(d.active&&!t){let n=R()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}function it(e,t=!1,n){if(C())return M().createElement(e,t);if(d.active){let o=R()?.hydrateElement(e);if(o)return n?ie(o,n):o}return ie(t?document.createElementNS(K,e):document.createElement(e),n)}function Re(e,t=!1){let n=re.get(e);if(n)return n;let o=document.createElement("template");return t?o.innerHTML=`<svg>${e}</svg>`:o.innerHTML=e,re.set(e,o),o}function rt(e,t,n=!1,o=!1,i){if(C()){let a=M();return n?a.parseTemplate(e,o):a.createRaw(e)}if(d.active){let a=R()?.hydrateStatic(t);if(a)return fe(a,i)}return fe(He(Re(e,o),o).firstChild,i)}function fe(e,t){let n=e;if(!t||typeof n?.querySelectorAll!="function")return e;let o=[n,...n.querySelectorAll("*")];for(let i=0;i<o.length&&i*2+1<t.pos.length;i++){let a=t.pos[i*2];a&&(o[i][le]={file:t.file,line:a,column:t.pos[i*2+1]})}return e}function st(e,t){if(!d.active)return t();let n=J(e.nextSibling,t);if(typeof n=="function"){let o=n;return Oe(o,(...a)=>d.active?J(e.nextSibling,()=>o(...a)):o(...a))}return n}function Oe(e,t){let n=e[H];return n!==void 0&&(t[H]=n),t}function ft(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 at(e,t){let n=[];for(let o=e.nextSibling;o&&o!==t;o=o.nextSibling)n.push(o);return n}function He(e,t=!1){let n=e.content.cloneNode(!0);return t?n.firstChild:n}function ke(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?ke(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}function lt(e){return typeof e!="function"?null:e._name||e.name||"anonymous"}function ut(e){if(m(e)||E(e)||typeof e!="function")return e;let t=e();for(;typeof t=="function"&&!m(t)&&!E(t);)t=t();return t}var T=0,je=200;function _e(e,t,n,o,i){let a=o,f=new Map;return y(()=>{h(n??t,"content",void 0,e);let s;if(E(e)&&!m(e)){if(!f.has(e)){T++;try{let r=e();f.set(e,r)}finally{T--}}for(s=f.get(e);typeof s=="function"&&m(s);)s=s()}else for(s=e();typeof s=="function"&&m(s);)s=s();{let r=0;for(;typeof s=="function"&&r++<50;)if(E(s)){if(!f.has(s)){let l=s;T++;try{let u=l();f.set(l,u)}finally{T--}}s=f.get(s)}else if(m(s))s=s();else if(s=s(),typeof s!="function"||!m(s)&&!E(s))break}T++;try{a=j(t,s,n,a,f),i(a)}finally{T--}})}function ce(e,t,n,o){if(T>je)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=w("",!0),e.appendChild(n));let i=o??null,a=r=>Array.isArray(r)&&r.some(l=>typeof l=="function"),f=r=>typeof r=="function"?r:()=>r;if(typeof t!="function"&&!a(t)){T++;try{i=j(e,t,n,i)}finally{T--}return()=>i}let s=_e(f(t),e,n,i,r=>{i=r});return()=>(s?.(),i)}function j(e,t,n,o,i){if(t==null||typeof t=="boolean")return v(e,o,n);if(typeof t=="function")for(;typeof t=="function";)t=t();if(t==null||typeof t=="boolean")return v(e,o,n);if(O(t)){let f=w("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(f,o[0]),v(e,o.slice(1),n)):g(e,f,n):o?e.replaceChild(f,o):g(e,f,n),t.then(s=>{f.parentNode===e&&j(e,s,f.nextSibling,f)}).catch(s=>{console.error("Error resolving promise in insertExpression:",s)}),f}let a=typeof t;if(a==="string"||a==="number"){if(a==="number"&&(t=String(t)),Array.isArray(o)){if(o.length===0){let s=w(t);return g(e,s,n),s}if(o.length===1&&o[0].nodeType===3)return o[0].data=t,o;o=v(e,o,n)}if(o&&ne(o))return o.data=t,o;let f=w(t);return o&&o.parentNode===e?e.replaceChild(f,o):X(e,f)||g(e,f,n),f}if(P(t))return X(e,t)?(oe(t),t):Array.isArray(o)?(o.length===0?g(e,t,n):o[0].parentNode===e?(e.replaceChild(t,o[0]),v(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=[],s=Array.isArray(o)?o:o?[o]:[],r=[];N(t,f,e,n,!0,i,r);let l=$e(e,s,f,n);for(let u of r){let c=ce(e,u.sig,u.marker);A(()=>{v(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 s=f;if(typeof s.type=="function"){let r=s.type(s.props||{});return j(e,r,n,o)}}}return v(e,o,n)}function N(e,t,n,o,i=!0,a,f){for(let s=0;s<e.length;s++){let r=e[s];if(!(r==null||typeof r=="boolean")){for(;typeof r=="function"&&!O(r)&&!m(r)&&!E(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let l;for(E(r)&&!m(r)?(a||(a=new Map),a.has(r)||a.set(r,r()),l=a.get(r)):l=r();typeof l=="function"&&!O(l)&&!m(l)&&!E(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=w("",!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)?N(u,t,n,o,i,a):N([u],t,n,o,i,a);continue}continue}Array.isArray(l)?N(l,t,n,o,i,a,f):N([l],t,n,o,i,a,f);continue}if(O(r)){let l=w("",!0);t.push(l),r.then(u=>{if(l.parentNode){let c=[];if(N([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(r)){N(r,t,n,o,i,a,f);continue}if(P(r)){t.push(r);continue}if(typeof r=="object"&&r!==null&&"type"in r&&"props"in r){let l=r;if(typeof l.type=="function"){let u=l.type(l.props||{});Array.isArray(u)?N(u,t,n,o,!1,a):N([u],t,n,o,!1,a);continue}}if(typeof r=="string"||typeof r=="number"){let l=String(r);if(l.trim()===""&&l!==" ")continue;t.push(w(l));continue}t.push(w(String(r)))}}}}function $e(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 i=n.length,a=t.length,f=i,s=0,r=0,l=a>0?t[a-1].nextSibling??void 0:o,u=null;for(;s<a||r<f;){if(t[s]===n[r]){s++,r++;continue}for(;a>s&&f>r&&t[a-1]===n[f-1];)a--,f--;if(a===s){let c=f<i?r?n[r-1].nextSibling??void 0:n[f-r]:l;for(;r<f;)g(e,n[r++],c)}else if(f===r)for(;s<a;)(!u||!u.has(t[s]))&&t[s].parentNode===e&&e.removeChild(t[s]),s++;else if(t[s]===n[f-1]&&n[r]===t[a-1]){let c=t[--a].nextSibling;g(e,n[r++],t[s++].nextSibling),g(e,n[--f],c),t[a]=t[s-1]}else{if(!u){u=new Map;let p=r;for(;p<f;)u.set(n[p],p++)}let c=u.get(t[s]);if(c!=null)if(r<c&&c<f){let p=s,W=1;for(;++p<a&&p<f&&!(!u.has(t[p])||u.get(t[p])!==c+W);)W++;if(W>c-r){let xe=t[s];for(;r<c;)g(e,n[r++],xe)}else t[s].parentNode===e?e.replaceChild(n[r++],t[s++]):(g(e,n[r++],l),s++)}else s++;else t[s].parentNode===e&&e.removeChild(t[s]),s++}}return n}function v(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 _(e,t,n){n==null?delete e[t]:e[t]=n}function de(e,t,n){let o=n,i;return Array.isArray(n)&&(o=n[0],i=n[1]),typeof o!="function"?()=>{}:(e.addEventListener(t,o,i),()=>e.removeEventListener(t,o,i))}function pe(e,t){if(!t||typeof t!="function")return;let n=t[H]?.name;if(!n)return;let o=n.indexOf(":");o!==-1&&b(e,n.slice(0,o),n.slice(o+1),t)}function $(e,t,n){let o=typeof n=="function"?ve(()=>n()):n;if(!(!o||typeof o!="object"))for(let i of Object.keys(o))b(e,t,i)}function ye(e,t){let n=(o,i)=>{typeof o=="function"&&(b(e,"use",o.name||"use",i),o(e,i??(()=>{})))};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 U(e,t,n,o=!1){return pe(e,n),typeof n!="function"?(S(e,t,n,o),()=>{}):y(()=>{h(e,"attribute",t,n);let i=typeof n=="function"?n():n;S(e,t,i,o)})}function Y(e,t,n){return typeof n!="function"?(_(e,t,n),()=>{}):(pe(e,n),y(()=>{h(e,"property",t,n);let o=typeof n=="function"?n():n;_(e,t,o)}))}function ge(e,t,n){return typeof n!="function"?(S(e,t,!!n),()=>{}):y(()=>{h(e,"attribute",t,n);let o=n();S(e,t,!!o)})}function F(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){y(()=>{h(e,"attribute","class",t),F(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 i=t[o];return typeof i=="function"?i():!!i}).join(" ");e.setAttribute("class",n);return}e.setAttribute("class",String(t))}function D(e,t,n){if(!(!t||typeof t!="object"))for(let o in t){let i=t[o],a=o.split(/\s+/).filter(Boolean);if(typeof i=="function"&&n)n.push(y(()=>{let f=!!i();for(let s of a)e.classList.toggle(s,f)}));else{let f=!!(typeof i=="function"?i():i);for(let s of a)e.classList.toggle(s,f)}}}function I(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 i=n[o];i==null?e.style[o]="":e.style[o]=i}}function ct(e){let{element:t,props:n,prevProps:o=Pe,isSVG:i=!1,skipChildren:a=!1}=e;if(!t||!te(t))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!n)return console.warn("[spread] Warning: props is undefined!"),()=>{};let f=i||t.namespaceURI===K,s=[];for(let r in n){if(a&&r==="children")continue;let l=n[r],u=o[r];if(l===u)continue;if(r==="ref"){me(l,t);continue}if(r==="use"){ye(t,l);continue}if(r.startsWith("on:")){s.push(de(t,r.slice(3),l));continue}if(r.startsWith("prop:")){b(t,"prop",r.slice(5),l),s.push(Y(t,r.slice(5),l));continue}if(r.startsWith("attr:")){b(t,"attr",r.slice(5),l),s.push(U(t,r.slice(5),l,f));continue}if(r.startsWith("bool:")){b(t,"bool",r.slice(5),l),s.push(ge(t,r.slice(5),l));continue}if(r==="class"||r==="className"){typeof l=="function"?s.push(y(()=>{h(t,"attribute","class",l),F(t,l())})):F(t,l);continue}if(r==="classList"){$(t,"class",l),typeof l=="function"?s.push(y(()=>{h(t,"attribute","class",l),D(t,l())})):D(t,l,s);continue}if(r==="style"){$(t,"style",l),typeof l=="function"?s.push(y(()=>{h(t,"attribute","style",l),I(t,l())})):I(t,l);continue}if(r.startsWith("on")){let p=r.slice(2).toLowerCase();u&&se(t,p),l&&Me(t,p,l);continue}let c=B.has(r)||!f&&r in t;typeof l=="function"?s.push(c?Y(t,r,l):U(t,r,l,f)):s.push(y(()=>c?_(t,r,n[r]):S(t,r,n[r],f)))}for(let r in o)if(!(r in n))if(r.startsWith("on")){let l=r.slice(2).toLowerCase();se(t,l)}else B.has(r)?_(t,r,null):t.removeAttribute(r);return()=>{s.forEach(r=>r())}}function dt(e,t,n=!1){for(let o in t){let i=t[o];if(o==="ref"){me(i,e);continue}if(o!=="children"){if(o==="use"){ye(e,i);continue}if(o.startsWith("on:")){de(e,o.slice(3),i);continue}if(o.startsWith("prop:")){b(e,"prop",o.slice(5),i),Y(e,o.slice(5),i);continue}if(o.startsWith("attr:")){b(e,"attr",o.slice(5),i),U(e,o.slice(5),i,n);continue}if(o.startsWith("bool:")){b(e,"bool",o.slice(5),i),ge(e,o.slice(5),i);continue}if(o.startsWith("on")&&o.length>2){let a=o.slice(2).toLowerCase();if(typeof i=="function")if(V.has(a)){e[`$$${a}`]=i;let f=`__fx_${a}`;if(!e[f]){let s=r=>{e[`$$${a}`]?.(r)};e.addEventListener(a,s),e[f]=s}}else e[`$$${a}`]=i,k.has(a)||ue([a]);continue}if(o==="class"||o==="className"){F(e,i);continue}if(o==="classList"){$(e,"class",i),typeof i=="function"?y(()=>{h(e,"attribute","class",i),D(e,i())}):D(e,i);continue}if(o==="style"){$(e,"style",i),typeof i=="function"?y(()=>{h(e,"attribute","style",i),I(e,i())}):I(e,i);continue}if(o==="innerHTML"){if(typeof i=="function"){let a=L(()=>{let f=i();for(;typeof f=="function";)f=f();e.innerHTML=f});A(()=>a())}else e.innerHTML=i;continue}if(o==="value"&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")){if(typeof i=="function"){let a=L(()=>{let f=i();for(;typeof f=="function"&&f.length===0;)f=f();document.activeElement!==e&&(e.value=f??"")});A(()=>{a()})}else y(()=>{document.activeElement!==e&&(e.value=t[o]??"")});continue}if(o==="checked"&&e.tagName==="INPUT"){if(typeof i=="function"){let a=L(()=>{let f=i();for(;typeof f=="function"&&f.length===0;)f=f();document.activeElement!==e&&(e.checked=f??"")});A(()=>{a()})}else y(()=>{document.activeElement!==e&&(e.checked=t[o]??"")});continue}if(o==="value"&&e.tagName==="SELECT"){if(typeof i=="function"){let a=!0,f=L(()=>{let s=i();for(;typeof s=="function"&&s.length===0;)s=s();a?(a=!1,queueMicrotask(()=>{e.value=s??""})):e.value=s??""});A(()=>{f()})}else{let a=!0;y(()=>{let f=t[o];a?(a=!1,queueMicrotask(()=>{e.value=f??""})):e.value=f??""})}continue}if(typeof i=="function"){let a=L(()=>{let f=i();for(;typeof f=="function"&&f.length===0;)f=f();q(e,o,f,n)});A(()=>{a()})}else y(()=>q(e,o,t[o],n))}}}function pt(...e){let t=o=>{for(let i=e.length-1;i>=0;i--){let a=e[i];if(a&&o in a&&a[o]!==void 0)return a[o]}},n=o=>{for(let i of e)if(i&&o in i)return!0;return!1};return new Proxy({},{get:(o,i)=>t(i),has:(o,i)=>n(i),ownKeys:()=>{let o=new Set;for(let i of e)if(i)for(let a of Reflect.ownKeys(i))o.add(a);return[...o]},getOwnPropertyDescriptor:(o,i)=>n(i)?{enumerable:!0,configurable:!0,get:()=>t(i)}:void 0})}function yt(e,...t){let n=new Set;for(let f of t)for(let s of f)n.add(s);let o=f=>({enumerable:!0,configurable:!0,get:()=>e[f]}),i=t.map(f=>{let s=new Set(f);return new Proxy({},{get:(r,l)=>s.has(l)?e[l]:void 0,has:(r,l)=>s.has(l)&&l in e,ownKeys:()=>Array.from(s).filter(r=>r in e),getOwnPropertyDescriptor:(r,l)=>s.has(l)&&l in e?o(l):void 0})}),a=new Proxy({},{get:(f,s)=>n.has(s)?void 0:e[s],has:(f,s)=>!n.has(s)&&s in e,ownKeys:()=>Reflect.ownKeys(e).filter(f=>!n.has(f)),getOwnPropertyDescriptor:(f,s)=>!n.has(s)&&s in e?o(s):void 0});return[...i,a]}function me(e,t){if(!e)return;let n=e[H]?.name;if(b(t,"ref",n||typeof e=="function"&&e.name||"ref",e),P(e)){let o=t,i=e;if(!o)return;typeof o=="function"?o(i):typeof o=="object"&&"current"in o&&(o.current=i);return}typeof e=="function"?e(t):typeof e=="object"&&"current"in e&&(e.current=t)}function gt(e,t,n){let o=t||document.body,i=Se(()=>e),a=[];return ae(()=>{let f=y(()=>{let s=i();Array.isArray(s)?(s.forEach(r=>o.appendChild(r)),a.push(()=>{s.forEach(r=>{r.parentNode===o&&o.removeChild(r)})})):P(s)&&(o.appendChild(s),a.push(()=>{s.parentNode===o&&o.removeChild(s)}))});a.push(f),A(()=>{a.forEach(s=>s())})}),null}function mt(e){return typeof e=="string"&&e.toLowerCase()===e}function xt(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 ht(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function O(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function bt(e){return typeof e=="function"&&e.length===0&&m(e)}function Et(e,t,n){if(!t)throw new Error("Container element is required");let o,i,a=[];return we(f=>{ae(()=>{d.active||(t.textContent=""),Q(t),ee(),ce(t,e)}),i=f}),()=>{i?.(),o?.(),a.forEach(f=>f()),t.textContent=""}}function Nt(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{Me as addDelegatedEventListener,de as addNativeEventListener,dt as applyProps,ye as applyUse,Nt as bindPair,v as cleanChildren,He as cloneTemplate,it as createNativeElement,gt as createPortal,Re as createTemplate,ue as delegateEvents,ht as escapeHTML,lt as fnName,tt as generateID,et as getStableElementId,me as handleRef,at as holeContent,ft as holeEnd,st as holeScope,ce as insert,j as insertExpression,bt as isAccessor,nt as isDelegatedEvent,ot as isFunction,mt as isNativeElement,O as isPromise,xt as isSVGElement,ut as iterateFn,ke as makeArrayFlat,pt as mergeProps,se as removeDelegatedEventListener,Et as render,D as setClassList,F as setClassName,U as setDynamicAttribute,ge as setDynamicBoolAttribute,Y as setDynamicProperty,_ as setProperty,I as setStyle,yt as splitProps,ct as spread,rt as templateNode};
|
|
1
|
+
/*! @fluixi/dom v1.0.0-alpha.85 | (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.85";
|
|
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
|
+
};
|