@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
|
@@ -1 +1,949 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var ie=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of oe(t))!re.call(e,r)&&r!==n&&P(e,r,{get:()=>t[r],enumerable:!(o=ne(t,r))||o.enumerable});return e};var fe=e=>se(P({},"__esModule",{value:!0}),e);var Ae={};ie(Ae,{createDynamicElement:()=>Se});module.exports=fe(Ae);var m=require("@fluixi/reactive/signal");var M="http://www.w3.org/2000/svg";function ae(e){return e.localName.includes("-")}function H(e,t,n,o=!1){if(n==null){e.removeAttribute(t);return}if(ae(e)){e[t]=n;return}N(e,t,n,o)}function N(e,t,n,o=!1){if(n==null||n===!1){e.removeAttribute(t);return}if(n===!0){e.setAttribute(t,"");return}if(typeof n=="object"){e.setAttribute(t,JSON.stringify(n));return}e.setAttribute(t,String(n))}var Re=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function k(e){return typeof e!="function"||Object.defineProperty(e,Symbol.for("fluixi-component"),{value:!0,enumerable:!0}),e}function E(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}var l=require("@fluixi/reactive/signal");var $=Symbol.for("fluixi.server-node"),le=Symbol.for("fluixi.dom.server-host"),ue=globalThis,O=ue[le]??={server:typeof document>"u",nodes:null};function S(){return O.server}function v(){if(!O.nodes)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return O.nodes}function A(e){return e!=null&&e[$]===!0?!0:typeof Node<"u"&&e instanceof Node}function F(e){return e!=null&&e[$]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var b={active:!1,cursor:null,parents:[]},ce=null;function I(){return ce}function _(e,t){return b.active&&t.parentNode===e}function W(e){let t=b.parents.lastIndexOf(e);t!==-1&&(b.parents.length=t),b.cursor=e.nextSibling}var G="__fx_at";var D=new Set,U=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function de(e){if(!S())for(let t of e)D.has(t)||U.has(t)||(D.add(t),document.addEventListener(t,pe))}function pe(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 h(e,t=!1){if(S())return v().createText(e);if(b.active&&!t){let n=I()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}var x=0,ye=200;function me(e,t,n,o,r){let a=o,i=new Map;return(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(n??t,"content",void 0,e);let s;if(E(e)&&!(0,m.isSignal)(e)){if(!i.has(e)){x++;try{let f=e();i.set(e,f)}finally{x--}}for(s=i.get(e);typeof s=="function"&&(0,m.isSignal)(s);)s=s()}else for(s=e();typeof s=="function"&&(0,m.isSignal)(s);)s=s();{let f=0;for(;typeof s=="function"&&f++<50;)if(E(s)){if(!i.has(s)){let u=s;x++;try{let c=u();i.set(u,c)}finally{x--}}s=i.get(s)}else if((0,m.isSignal)(s))s=s();else if(s=s(),typeof s!="function"||!(0,m.isSignal)(s)&&!E(s))break}x++;try{a=R(t,s,n,a,i),r(a)}finally{x--}})}function j(e,t,n,o){if(x>ye)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=h("",!0),e.appendChild(n));let r=o??null,a=f=>Array.isArray(f)&&f.some(u=>typeof u=="function"),i=f=>typeof f=="function"?f:()=>f;if(typeof t!="function"&&!a(t)){x++;try{r=R(e,t,n,r)}finally{x--}return()=>r}let s=me(i(t),e,n,r,f=>{r=f});return()=>(s?.(),r)}function R(e,t,n,o,r){if(t==null||typeof t=="boolean")return T(e,o,n);if(typeof t=="function")for(;typeof t=="function";)t=t();if(t==null||typeof t=="boolean")return T(e,o,n);if(C(t)){let i=h("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(i,o[0]),T(e,o.slice(1),n)):y(e,i,n):o?e.replaceChild(i,o):y(e,i,n),t.then(s=>{i.parentNode===e&&R(e,s,i.nextSibling,i)}).catch(s=>{console.error("Error resolving promise in insertExpression:",s)}),i}let a=typeof t;if(a==="string"||a==="number"){if(a==="number"&&(t=String(t)),Array.isArray(o)){if(o.length===0){let s=h(t);return y(e,s,n),s}if(o.length===1&&o[0].nodeType===3)return o[0].data=t,o;o=T(e,o,n)}if(o&&F(o))return o.data=t,o;let i=h(t);return o&&o.parentNode===e?e.replaceChild(i,o):_(e,i)||y(e,i,n),i}if(A(t))return _(e,t)?(W(t),t):Array.isArray(o)?(o.length===0?y(e,t,n):o[0].parentNode===e?(e.replaceChild(t,o[0]),T(e,o.slice(1),n)):y(e,t,n),t):(o?o!==t&&(o.parentNode===e?e.replaceChild(t,o):y(e,t,n)):y(e,t,n),t);if(Array.isArray(t)){let i=[],s=Array.isArray(o)?o:o?[o]:[],f=[];g(t,i,e,n,!0,r,f);let u=ge(e,s,i,n);for(let c of f){let d=j(e,c.sig,c.marker);(0,l.onCleanup)(()=>{T(e,d()),c.marker.parentNode===e&&e.removeChild(c.marker)})}return u}if(a==="object"&&t!==null&&typeof t=="object"){let i=t;if("type"in i&&"props"in i){let s=i;if(typeof s.type=="function"){let f=s.type(s.props||{});return R(e,f,n,o)}}}return T(e,o,n)}function g(e,t,n,o,r=!0,a,i){for(let s=0;s<e.length;s++){let f=e[s];if(!(f==null||typeof f=="boolean")){for(;typeof f=="function"&&!C(f)&&!(0,m.isSignal)(f)&&!E(f)&&(f=f(),!(f==null||typeof f=="boolean")););if(!(f==null||typeof f=="boolean")){if(typeof f=="function"){let u;for(E(f)&&!(0,m.isSignal)(f)?(a||(a=new Map),a.has(f)||a.set(f,f()),u=a.get(f)):u=f();typeof u=="function"&&!C(u)&&!(0,m.isSignal)(u)&&!E(u);)a||(a=new Map),a.has(u)||a.set(u,u()),u=a.get(u);if(u==null||typeof u=="boolean")continue;if(typeof u=="function"){if((0,m.isSignal)(u)){if(i){let d=h("",!0);t.push(d),i.push({marker:d,sig:u});continue}let c=u();for(;typeof c=="function"&&(0,m.isSignal)(c);)c=c();if(c==null||typeof c=="boolean")continue;Array.isArray(c)?g(c,t,n,o,r,a):g([c],t,n,o,r,a);continue}continue}Array.isArray(u)?g(u,t,n,o,r,a,i):g([u],t,n,o,r,a,i);continue}if(C(f)){let u=h("",!0);t.push(u),f.then(c=>{if(u.parentNode){let d=[];if(g([c],d,u.parentNode,void 0,!1,a),d.length>0){u.parentNode.replaceChild(d[0],u);for(let p=1;p<d.length;p++)u.parentNode?.insertBefore(d[p],d[p-1].nextSibling)}}}).catch(c=>console.error("Error resolving promise in array:",c));continue}if(Array.isArray(f)){g(f,t,n,o,r,a,i);continue}if(A(f)){t.push(f);continue}if(typeof f=="object"&&f!==null&&"type"in f&&"props"in f){let u=f;if(typeof u.type=="function"){let c=u.type(u.props||{});Array.isArray(c)?g(c,t,n,o,!1,a):g([c],t,n,o,!1,a);continue}}if(typeof f=="string"||typeof f=="number"){let u=String(f);if(u.trim()===""&&u!==" ")continue;t.push(h(u));continue}t.push(h(String(f)))}}}}function ge(e,t,n,o){for(let d=0;d<n.length;d++){let p=n[d].parentNode;p!==null&&p!==e&&p.nodeType!==11&&(n=n.slice(),n[d]=n[d].cloneNode(!0))}let r=n.length,a=t.length,i=r,s=0,f=0,u=a>0?t[a-1].nextSibling??void 0:o,c=null;for(;s<a||f<i;){if(t[s]===n[f]){s++,f++;continue}for(;a>s&&i>f&&t[a-1]===n[i-1];)a--,i--;if(a===s){let d=i<r?f?n[f-1].nextSibling??void 0:n[i-f]:u;for(;f<i;)y(e,n[f++],d)}else if(i===f)for(;s<a;)(!c||!c.has(t[s]))&&t[s].parentNode===e&&e.removeChild(t[s]),s++;else if(t[s]===n[i-1]&&n[f]===t[a-1]){let d=t[--a].nextSibling;y(e,n[f++],t[s++].nextSibling),y(e,n[--i],d),t[a]=t[s-1]}else{if(!c){c=new Map;let p=f;for(;p<i;)c.set(n[p],p++)}let d=c.get(t[s]);if(d!=null)if(f<d&&d<i){let p=s,L=1;for(;++p<a&&p<i&&!(!c.has(t[p])||c.get(t[p])!==d+L);)L++;if(L>d-f){let te=t[s];for(;f<d;)y(e,n[f++],te)}else t[s].parentNode===e?e.replaceChild(n[f++],t[s++]):(y(e,n[f++],u),s++)}else s++;else t[s].parentNode===e&&e.removeChild(t[s]),s++}}return n}function T(e,t,n){if(t)if(Array.isArray(t))for(let o=0;o<t.length;o++)t[o].parentNode===e&&e.removeChild(t[o]);else t.parentNode===e&&e.removeChild(t);return null}function y(e,t,n){b.active&&t.parentNode===e||(n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t))}function V(e,t,n){n==null?delete e[t]:e[t]=n}function xe(e,t,n){let o=n,r;return Array.isArray(n)&&(o=n[0],r=n[1]),typeof o!="function"?()=>{}:(e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r))}function z(e,t){if(!t||typeof t!="function")return;let n=t[G]?.name;if(!n)return;let o=n.indexOf(":");o!==-1&&(0,l.reportReactiveDirective)(e,n.slice(0,o),n.slice(o+1),t)}function q(e,t,n){let o=typeof n=="function"?(0,l.untrack)(()=>n()):n;if(!(!o||typeof o!="object"))for(let r of Object.keys(o))(0,l.reportReactiveDirective)(e,t,r)}function he(e,t){let n=(o,r)=>{typeof o=="function"&&((0,l.reportReactiveDirective)(e,"use",o.name||"use",r),o(e,r??(()=>{})))};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 Ee(e,t,n,o=!1){return z(e,n),typeof n!="function"?(N(e,t,n,o),()=>{}):(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"attribute",t,n);let r=typeof n=="function"?n():n;N(e,t,r,o)})}function be(e,t,n){return typeof n!="function"?(V(e,t,n),()=>{}):(z(e,n),(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"property",t,n);let o=typeof n=="function"?n():n;V(e,t,o)}))}function Te(e,t,n){return typeof n!="function"?(N(e,t,!!n),()=>{}):(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"attribute",t,n);let o=n();N(e,t,!!o)})}function X(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"attribute","class",t),X(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 r=t[o];return typeof r=="function"?r():!!r}).join(" ");e.setAttribute("class",n);return}e.setAttribute("class",String(t))}function K(e,t,n){if(!(!t||typeof t!="object"))for(let o in t){let r=t[o],a=o.split(/\s+/).filter(Boolean);if(typeof r=="function"&&n)n.push((0,l.createRenderEffect)(()=>{let i=!!r();for(let s of a)e.classList.toggle(s,i)}));else{let i=!!(typeof r=="function"?r():r);for(let s of a)e.classList.toggle(s,i)}}}function B(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 r=n[o];r==null?e.style[o]="":e.style[o]=r}}function J(e,t,n=!1){for(let o in t){let r=t[o];if(o==="ref"){Ne(r,e);continue}if(o!=="children"){if(o==="use"){he(e,r);continue}if(o.startsWith("on:")){xe(e,o.slice(3),r);continue}if(o.startsWith("prop:")){(0,l.reportReactiveDirective)(e,"prop",o.slice(5),r),be(e,o.slice(5),r);continue}if(o.startsWith("attr:")){(0,l.reportReactiveDirective)(e,"attr",o.slice(5),r),Ee(e,o.slice(5),r,n);continue}if(o.startsWith("bool:")){(0,l.reportReactiveDirective)(e,"bool",o.slice(5),r),Te(e,o.slice(5),r);continue}if(o.startsWith("on")&&o.length>2){let a=o.slice(2).toLowerCase();if(typeof r=="function")if(U.has(a)){e[`$$${a}`]=r;let i=`__fx_${a}`;if(!e[i]){let s=f=>{e[`$$${a}`]?.(f)};e.addEventListener(a,s),e[i]=s}}else e[`$$${a}`]=r,D.has(a)||de([a]);continue}if(o==="class"||o==="className"){X(e,r);continue}if(o==="classList"){q(e,"class",r),typeof r=="function"?(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"attribute","class",r),K(e,r())}):K(e,r);continue}if(o==="style"){q(e,"style",r),typeof r=="function"?(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"attribute","style",r),B(e,r())}):B(e,r);continue}if(o==="innerHTML"){if(typeof r=="function"){let a=(0,l.createEffect)(()=>{let i=r();for(;typeof i=="function";)i=i();e.innerHTML=i});(0,l.onCleanup)(()=>a())}else e.innerHTML=r;continue}if(o==="value"&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")){if(typeof r=="function"){let a=(0,l.createEffect)(()=>{let i=r();for(;typeof i=="function"&&i.length===0;)i=i();document.activeElement!==e&&(e.value=i??"")});(0,l.onCleanup)(()=>{a()})}else(0,l.createRenderEffect)(()=>{document.activeElement!==e&&(e.value=t[o]??"")});continue}if(o==="checked"&&e.tagName==="INPUT"){if(typeof r=="function"){let a=(0,l.createEffect)(()=>{let i=r();for(;typeof i=="function"&&i.length===0;)i=i();document.activeElement!==e&&(e.checked=i??"")});(0,l.onCleanup)(()=>{a()})}else(0,l.createRenderEffect)(()=>{document.activeElement!==e&&(e.checked=t[o]??"")});continue}if(o==="value"&&e.tagName==="SELECT"){if(typeof r=="function"){let a=!0,i=(0,l.createEffect)(()=>{let s=r();for(;typeof s=="function"&&s.length===0;)s=s();a?(a=!1,queueMicrotask(()=>{e.value=s??""})):e.value=s??""});(0,l.onCleanup)(()=>{i()})}else{let a=!0;(0,l.createRenderEffect)(()=>{let i=t[o];a?(a=!1,queueMicrotask(()=>{e.value=i??""})):e.value=i??""})}continue}if(typeof r=="function"){let a=(0,l.createEffect)(()=>{let i=r();for(;typeof i=="function"&&i.length===0;)i=i();H(e,o,i,n)});(0,l.onCleanup)(()=>{a()})}else(0,l.createRenderEffect)(()=>H(e,o,t[o],n))}}}function Ne(e,t){if(!e)return;let n=e[G]?.name;if((0,l.reportReactiveDirective)(t,"ref",n||typeof e=="function"&&e.name||"ref",e),A(e)){let o=t,r=e;if(!o)return;typeof o=="function"?o(r):typeof o=="object"&&"current"in o&&(o.current=r);return}typeof e=="function"?e(t):typeof e=="object"&&"current"in e&&(e.current=t)}function Y(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 C(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}var w=require("@fluixi/reactive");var we="__fx_dom_create_component__",Z=globalThis[we]??={fn:null};function Q(e,t){if(Z.fn)return Z.fn(e,t);t&&(0,w.reportReactiveProps)(t);let n=typeof e=="function"?(0,w.untrack)(()=>e(t)):e,o=n!=null&&(typeof n=="function"||typeof n=="object");if(o)try{n.$name=e?.name}catch{}return o&&!(0,w.isSignal)(n)?k(n):n}var ee=require("@fluixi/reactive/signal");function Se(e,t={}){if(typeof e=="function")return Q(e,t);if(typeof e!="string"||e.length===0)return null;let n=Y(e);if(S())return v().createElement(e,n);let o=n?document.createElementNS(M,e):document.createElement(e);return J(o,t,n),ve(o,t),o}function ve(e,t){if(!t||t.children===void 0)return;let n=(0,ee.readChildren)(()=>t.children),o=r=>{j(e,r,typeof r=="function"?null:void 0)};Array.isArray(n)?n.forEach(o):o(n)}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/dom/dynamic-element.ts
|
|
21
|
+
var dynamic_element_exports = {};
|
|
22
|
+
__export(dynamic_element_exports, {
|
|
23
|
+
createDynamicElement: () => createDynamicElement
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(dynamic_element_exports);
|
|
26
|
+
|
|
27
|
+
// src/lib/dom/runtime.ts
|
|
28
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
29
|
+
|
|
30
|
+
// src/lib/dom/utils.ts
|
|
31
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
32
|
+
function isCustomElement(element) {
|
|
33
|
+
return element.localName.includes("-");
|
|
34
|
+
}
|
|
35
|
+
function applyElementProp(element, name, value, isSVG = false) {
|
|
36
|
+
if (value == null) {
|
|
37
|
+
element.removeAttribute(name);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (isCustomElement(element)) {
|
|
41
|
+
element[name] = value;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setAttribute(element, name, value, isSVG);
|
|
45
|
+
}
|
|
46
|
+
function setAttribute(element, name, value, isSVG = false) {
|
|
47
|
+
if (value == null || value === false) {
|
|
48
|
+
element.removeAttribute(name);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (value === true) {
|
|
52
|
+
element.setAttribute(name, "");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (typeof value === "object") {
|
|
56
|
+
element.setAttribute(name, JSON.stringify(value));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
element.setAttribute(name, String(value));
|
|
60
|
+
}
|
|
61
|
+
var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
|
|
62
|
+
|
|
63
|
+
// src/lib/component/modifiers.ts
|
|
64
|
+
function asComponent(value) {
|
|
65
|
+
if (typeof value !== "function") return value;
|
|
66
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-component"), { value: true, enumerable: true });
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
function isComponent(value) {
|
|
70
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/lib/dom/runtime.ts
|
|
74
|
+
var import_signal2 = require("@fluixi/reactive/signal");
|
|
75
|
+
|
|
76
|
+
// src/lib/dom/server/host.ts
|
|
77
|
+
var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
|
|
78
|
+
var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
|
|
79
|
+
var realm = globalThis;
|
|
80
|
+
var state = realm[STATE] ??= {
|
|
81
|
+
server: typeof document === "undefined",
|
|
82
|
+
nodes: null
|
|
83
|
+
};
|
|
84
|
+
function isServer() {
|
|
85
|
+
return state.server;
|
|
86
|
+
}
|
|
87
|
+
function getServerNodes() {
|
|
88
|
+
if (!state.nodes) {
|
|
89
|
+
throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
|
|
90
|
+
}
|
|
91
|
+
return state.nodes;
|
|
92
|
+
}
|
|
93
|
+
function isDomNode(x) {
|
|
94
|
+
if (x != null && x[SERVER_NODE] === true) return true;
|
|
95
|
+
return typeof Node !== "undefined" && x instanceof Node;
|
|
96
|
+
}
|
|
97
|
+
function isDomText(x) {
|
|
98
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
|
|
99
|
+
return typeof Text !== "undefined" && x instanceof Text;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/lib/dom/hydration-state.ts
|
|
103
|
+
var hydration = {
|
|
104
|
+
active: false,
|
|
105
|
+
cursor: null,
|
|
106
|
+
parents: []
|
|
107
|
+
};
|
|
108
|
+
var _walker = null;
|
|
109
|
+
function getHydrationWalker() {
|
|
110
|
+
return _walker;
|
|
111
|
+
}
|
|
112
|
+
function isAdopted(parent, node) {
|
|
113
|
+
return hydration.active && node.parentNode === parent;
|
|
114
|
+
}
|
|
115
|
+
function ascendPast(node) {
|
|
116
|
+
const idx = hydration.parents.lastIndexOf(node);
|
|
117
|
+
if (idx !== -1) hydration.parents.length = idx;
|
|
118
|
+
hydration.cursor = node.nextSibling;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/lib/dom/runtime.ts
|
|
122
|
+
var HOLE_TAG = "__fx_at";
|
|
123
|
+
var delegatedSet = /* @__PURE__ */ new Set();
|
|
124
|
+
var NON_DELEGATED = /* @__PURE__ */ new Set(["scroll", "focus", "blur", "load", "error", "resize", "mouseenter", "mouseleave", "pointerenter", "pointerleave", "gotpointercapture", "lostpointercapture"]);
|
|
125
|
+
function delegateEvents(eventNames) {
|
|
126
|
+
if (isServer()) return;
|
|
127
|
+
for (const name of eventNames) {
|
|
128
|
+
if (delegatedSet.has(name) || NON_DELEGATED.has(name)) continue;
|
|
129
|
+
delegatedSet.add(name);
|
|
130
|
+
document.addEventListener(name, delegatedEventHandler);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function delegatedEventHandler(e) {
|
|
134
|
+
const key = `$$${e.type}`;
|
|
135
|
+
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
136
|
+
while (node) {
|
|
137
|
+
const handler = node[key];
|
|
138
|
+
if (handler && !node.disabled) {
|
|
139
|
+
handler(e);
|
|
140
|
+
if (e.cancelBubble) return;
|
|
141
|
+
}
|
|
142
|
+
node = node.host && node.host !== node && node.host instanceof Element ? node.host : node.parentNode;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function createTextNode(value, anchor = false) {
|
|
146
|
+
if (isServer()) return getServerNodes().createText(value);
|
|
147
|
+
if (hydration.active && !anchor) {
|
|
148
|
+
const node = getHydrationWalker()?.hydrateText(value);
|
|
149
|
+
if (node) return node;
|
|
150
|
+
}
|
|
151
|
+
return document.createTextNode(value);
|
|
152
|
+
}
|
|
153
|
+
var _insertDepth = 0;
|
|
154
|
+
var MAX_INSERT_DEPTH = 200;
|
|
155
|
+
function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
|
|
156
|
+
let current = initialCurrent;
|
|
157
|
+
const componentCache = /* @__PURE__ */ new Map();
|
|
158
|
+
return (0, import_signal2.createRenderEffect)(() => {
|
|
159
|
+
(0, import_signal2.reportReactiveBinding)(marker ?? parent, "content", void 0, getAccessor);
|
|
160
|
+
let value;
|
|
161
|
+
if (isComponent(getAccessor) && !(0, import_signal.isSignal)(getAccessor)) {
|
|
162
|
+
if (!componentCache.has(getAccessor)) {
|
|
163
|
+
_insertDepth++;
|
|
164
|
+
try {
|
|
165
|
+
const inst = getAccessor();
|
|
166
|
+
componentCache.set(getAccessor, inst);
|
|
167
|
+
} finally {
|
|
168
|
+
_insertDepth--;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
value = componentCache.get(getAccessor);
|
|
172
|
+
while (typeof value === "function" && (0, import_signal.isSignal)(value)) value = value();
|
|
173
|
+
} else {
|
|
174
|
+
value = getAccessor();
|
|
175
|
+
while (typeof value === "function" && (0, import_signal.isSignal)(value)) {
|
|
176
|
+
value = value();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
{
|
|
180
|
+
let chainDepth = 0;
|
|
181
|
+
while (typeof value === "function" && chainDepth++ < 50) {
|
|
182
|
+
if (isComponent(value)) {
|
|
183
|
+
if (!componentCache.has(value)) {
|
|
184
|
+
const thunk = value;
|
|
185
|
+
_insertDepth++;
|
|
186
|
+
try {
|
|
187
|
+
const inst = thunk();
|
|
188
|
+
componentCache.set(thunk, inst);
|
|
189
|
+
} finally {
|
|
190
|
+
_insertDepth--;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
value = componentCache.get(value);
|
|
194
|
+
} else if ((0, import_signal.isSignal)(value)) {
|
|
195
|
+
value = value();
|
|
196
|
+
} else {
|
|
197
|
+
value = value();
|
|
198
|
+
if (typeof value !== "function" || !(0, import_signal.isSignal)(value) && !isComponent(value)) break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
_insertDepth++;
|
|
203
|
+
try {
|
|
204
|
+
current = insertExpression(parent, value, marker, current, componentCache);
|
|
205
|
+
setCurrent(current);
|
|
206
|
+
} finally {
|
|
207
|
+
_insertDepth--;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function insert(parent, accessor, marker, init) {
|
|
212
|
+
if (_insertDepth > MAX_INSERT_DEPTH) {
|
|
213
|
+
console.error("[insert] Exceeded max call depth, possible infinite loop.");
|
|
214
|
+
return () => null;
|
|
215
|
+
}
|
|
216
|
+
if (marker !== void 0 && !marker) {
|
|
217
|
+
marker = createTextNode("", true);
|
|
218
|
+
parent.appendChild(marker);
|
|
219
|
+
}
|
|
220
|
+
let current = init ?? null;
|
|
221
|
+
const isReactiveArray = (element) => {
|
|
222
|
+
return Array.isArray(element) && element.some((v) => typeof v === "function");
|
|
223
|
+
};
|
|
224
|
+
const normalizeAccessor = (accessor2) => {
|
|
225
|
+
if (typeof accessor2 === "function") return accessor2;
|
|
226
|
+
return () => accessor2;
|
|
227
|
+
};
|
|
228
|
+
if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
|
|
229
|
+
_insertDepth++;
|
|
230
|
+
try {
|
|
231
|
+
current = insertExpression(parent, accessor, marker, current);
|
|
232
|
+
} finally {
|
|
233
|
+
_insertDepth--;
|
|
234
|
+
}
|
|
235
|
+
return () => current;
|
|
236
|
+
}
|
|
237
|
+
const dispose = _createInsertEffect(
|
|
238
|
+
normalizeAccessor(accessor),
|
|
239
|
+
parent,
|
|
240
|
+
marker,
|
|
241
|
+
current,
|
|
242
|
+
(v) => {
|
|
243
|
+
current = v;
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
return () => {
|
|
247
|
+
dispose?.();
|
|
248
|
+
return current;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function insertExpression(parent, value, marker, current, componentCache) {
|
|
252
|
+
if (value == null || typeof value === "boolean") {
|
|
253
|
+
return cleanChildren(parent, current, marker);
|
|
254
|
+
}
|
|
255
|
+
if (typeof value === "function") {
|
|
256
|
+
while (typeof value === "function") {
|
|
257
|
+
value = value();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (value == null || typeof value === "boolean") {
|
|
261
|
+
return cleanChildren(parent, current, marker);
|
|
262
|
+
}
|
|
263
|
+
if (isPromise(value)) {
|
|
264
|
+
const placeholder = createTextNode("", true);
|
|
265
|
+
if (Array.isArray(current)) {
|
|
266
|
+
if (current.length > 0) {
|
|
267
|
+
parent.replaceChild(placeholder, current[0]);
|
|
268
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
269
|
+
} else {
|
|
270
|
+
insertBefore(parent, placeholder, marker);
|
|
271
|
+
}
|
|
272
|
+
} else if (current) {
|
|
273
|
+
parent.replaceChild(placeholder, current);
|
|
274
|
+
} else {
|
|
275
|
+
insertBefore(parent, placeholder, marker);
|
|
276
|
+
}
|
|
277
|
+
value.then((resolved) => {
|
|
278
|
+
if (placeholder.parentNode === parent) {
|
|
279
|
+
insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
|
|
280
|
+
}
|
|
281
|
+
}).catch((err) => {
|
|
282
|
+
console.error("Error resolving promise in insertExpression:", err);
|
|
283
|
+
});
|
|
284
|
+
return placeholder;
|
|
285
|
+
}
|
|
286
|
+
const t = typeof value;
|
|
287
|
+
if (t === "string" || t === "number") {
|
|
288
|
+
if (t === "number") value = String(value);
|
|
289
|
+
if (Array.isArray(current)) {
|
|
290
|
+
if (current.length === 0) {
|
|
291
|
+
const node2 = createTextNode(value);
|
|
292
|
+
insertBefore(parent, node2, marker);
|
|
293
|
+
return node2;
|
|
294
|
+
}
|
|
295
|
+
if (current.length === 1 && current[0].nodeType === 3) {
|
|
296
|
+
current[0].data = value;
|
|
297
|
+
return current;
|
|
298
|
+
}
|
|
299
|
+
current = cleanChildren(parent, current, marker);
|
|
300
|
+
}
|
|
301
|
+
if (current && isDomText(current)) {
|
|
302
|
+
current.data = value;
|
|
303
|
+
return current;
|
|
304
|
+
}
|
|
305
|
+
const node = createTextNode(value);
|
|
306
|
+
if (current && current.parentNode === parent) {
|
|
307
|
+
parent.replaceChild(node, current);
|
|
308
|
+
} else if (!isAdopted(parent, node)) {
|
|
309
|
+
insertBefore(parent, node, marker);
|
|
310
|
+
}
|
|
311
|
+
return node;
|
|
312
|
+
}
|
|
313
|
+
if (isDomNode(value)) {
|
|
314
|
+
if (isAdopted(parent, value)) {
|
|
315
|
+
ascendPast(value);
|
|
316
|
+
return value;
|
|
317
|
+
}
|
|
318
|
+
if (Array.isArray(current)) {
|
|
319
|
+
if (current.length === 0) {
|
|
320
|
+
insertBefore(parent, value, marker);
|
|
321
|
+
} else if (current[0].parentNode === parent) {
|
|
322
|
+
parent.replaceChild(value, current[0]);
|
|
323
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
324
|
+
} else {
|
|
325
|
+
insertBefore(parent, value, marker);
|
|
326
|
+
}
|
|
327
|
+
return value;
|
|
328
|
+
}
|
|
329
|
+
if (!current) {
|
|
330
|
+
insertBefore(parent, value, marker);
|
|
331
|
+
} else if (current !== value) {
|
|
332
|
+
if (current.parentNode === parent) {
|
|
333
|
+
parent.replaceChild(value, current);
|
|
334
|
+
} else {
|
|
335
|
+
insertBefore(parent, value, marker);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return value;
|
|
339
|
+
}
|
|
340
|
+
if (Array.isArray(value)) {
|
|
341
|
+
const array = [];
|
|
342
|
+
const currentArray = Array.isArray(current) ? current : current ? [current] : [];
|
|
343
|
+
const reactiveSlots = [];
|
|
344
|
+
flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
|
|
345
|
+
const reconciled = reconcileArrays(parent, currentArray, array, marker);
|
|
346
|
+
for (const slot of reactiveSlots) {
|
|
347
|
+
const disposeSlot = insert(parent, slot.sig, slot.marker);
|
|
348
|
+
(0, import_signal2.onCleanup)(() => {
|
|
349
|
+
cleanChildren(parent, disposeSlot());
|
|
350
|
+
if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return reconciled;
|
|
354
|
+
}
|
|
355
|
+
if (t === "object" && value !== null && typeof value === "object") {
|
|
356
|
+
const objValue = value;
|
|
357
|
+
if ("type" in objValue && "props" in objValue) {
|
|
358
|
+
const jsxValue = objValue;
|
|
359
|
+
if (typeof jsxValue.type === "function") {
|
|
360
|
+
const result = jsxValue.type(jsxValue.props || {});
|
|
361
|
+
return insertExpression(parent, result, marker, current);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return cleanChildren(parent, current, marker);
|
|
366
|
+
}
|
|
367
|
+
function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
|
|
368
|
+
for (let i = 0; i < arr.length; i++) {
|
|
369
|
+
let item = arr[i];
|
|
370
|
+
if (item == null || typeof item === "boolean") continue;
|
|
371
|
+
while (typeof item === "function" && !isPromise(item) && !(0, import_signal.isSignal)(item) && !isComponent(item)) {
|
|
372
|
+
item = item();
|
|
373
|
+
if (item == null || typeof item === "boolean") break;
|
|
374
|
+
}
|
|
375
|
+
if (item == null || typeof item === "boolean") continue;
|
|
376
|
+
if (typeof item === "function") {
|
|
377
|
+
let resolved;
|
|
378
|
+
if (isComponent(item) && !(0, import_signal.isSignal)(item)) {
|
|
379
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
380
|
+
if (!componentCache.has(item)) componentCache.set(item, item());
|
|
381
|
+
resolved = componentCache.get(item);
|
|
382
|
+
} else {
|
|
383
|
+
resolved = item();
|
|
384
|
+
}
|
|
385
|
+
while (typeof resolved === "function" && !isPromise(resolved) && !(0, import_signal.isSignal)(resolved) && !isComponent(resolved)) {
|
|
386
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
387
|
+
if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
|
|
388
|
+
resolved = componentCache.get(resolved);
|
|
389
|
+
}
|
|
390
|
+
if (resolved == null || typeof resolved === "boolean") continue;
|
|
391
|
+
if (typeof resolved === "function") {
|
|
392
|
+
if ((0, import_signal.isSignal)(resolved)) {
|
|
393
|
+
if (reactiveSlots) {
|
|
394
|
+
const slot = createTextNode("", true);
|
|
395
|
+
result.push(slot);
|
|
396
|
+
reactiveSlots.push({ marker: slot, sig: resolved });
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
let val = resolved();
|
|
400
|
+
while (typeof val === "function" && (0, import_signal.isSignal)(val)) val = val();
|
|
401
|
+
if (val == null || typeof val === "boolean") continue;
|
|
402
|
+
if (Array.isArray(val)) {
|
|
403
|
+
flattenArray(val, result, parent, marker, track, componentCache);
|
|
404
|
+
} else flattenArray([val], result, parent, marker, track, componentCache);
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
|
|
410
|
+
else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
if (isPromise(item)) {
|
|
414
|
+
const placeholder = createTextNode("", true);
|
|
415
|
+
result.push(placeholder);
|
|
416
|
+
item.then((resolved) => {
|
|
417
|
+
if (placeholder.parentNode) {
|
|
418
|
+
const tempNodes = [];
|
|
419
|
+
flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
|
|
420
|
+
if (tempNodes.length > 0) {
|
|
421
|
+
placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
|
|
422
|
+
for (let j = 1; j < tempNodes.length; j++) {
|
|
423
|
+
placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}).catch((err) => console.error("Error resolving promise in array:", err));
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
if (Array.isArray(item)) {
|
|
431
|
+
flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
if (isDomNode(item)) {
|
|
435
|
+
result.push(item);
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
|
|
439
|
+
const jsxItem = item;
|
|
440
|
+
if (typeof jsxItem.type === "function") {
|
|
441
|
+
const resolved = jsxItem.type(jsxItem.props || {});
|
|
442
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
|
|
443
|
+
else flattenArray([resolved], result, parent, marker, false, componentCache);
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
448
|
+
const str = String(item);
|
|
449
|
+
if (str.trim() === "" && str !== " ") continue;
|
|
450
|
+
result.push(createTextNode(str));
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
result.push(createTextNode(String(item)));
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
function reconcileArrays(parent, a, b, marker) {
|
|
457
|
+
for (let i = 0; i < b.length; i++) {
|
|
458
|
+
const owner = b[i].parentNode;
|
|
459
|
+
if (owner !== null && owner !== parent && owner.nodeType !== 11) {
|
|
460
|
+
b = b.slice();
|
|
461
|
+
b[i] = b[i].cloneNode(true);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
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;
|
|
465
|
+
while (aStart < aEnd || bStart < bEnd) {
|
|
466
|
+
if (a[aStart] === b[bStart]) {
|
|
467
|
+
aStart++;
|
|
468
|
+
bStart++;
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
|
|
472
|
+
aEnd--;
|
|
473
|
+
bEnd--;
|
|
474
|
+
}
|
|
475
|
+
if (aEnd === aStart) {
|
|
476
|
+
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
|
|
477
|
+
while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
|
|
478
|
+
} else if (bEnd === bStart) {
|
|
479
|
+
while (aStart < aEnd) {
|
|
480
|
+
if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
|
|
481
|
+
parent.removeChild(a[aStart]);
|
|
482
|
+
aStart++;
|
|
483
|
+
}
|
|
484
|
+
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
485
|
+
const node = a[--aEnd].nextSibling;
|
|
486
|
+
insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
|
|
487
|
+
insertBefore(parent, b[--bEnd], node);
|
|
488
|
+
a[aEnd] = a[aStart - 1];
|
|
489
|
+
} else {
|
|
490
|
+
if (!map) {
|
|
491
|
+
map = /* @__PURE__ */ new Map();
|
|
492
|
+
let i = bStart;
|
|
493
|
+
while (i < bEnd) map.set(b[i], i++);
|
|
494
|
+
}
|
|
495
|
+
const index = map.get(a[aStart]);
|
|
496
|
+
if (index != null) {
|
|
497
|
+
if (bStart < index && index < bEnd) {
|
|
498
|
+
let i = aStart, sequence = 1;
|
|
499
|
+
while (++i < aEnd && i < bEnd) {
|
|
500
|
+
if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
|
|
501
|
+
sequence++;
|
|
502
|
+
}
|
|
503
|
+
if (sequence > index - bStart) {
|
|
504
|
+
const node = a[aStart];
|
|
505
|
+
while (bStart < index) insertBefore(parent, b[bStart++], node);
|
|
506
|
+
} else {
|
|
507
|
+
if (a[aStart].parentNode === parent) {
|
|
508
|
+
parent.replaceChild(b[bStart++], a[aStart++]);
|
|
509
|
+
} else {
|
|
510
|
+
insertBefore(parent, b[bStart++], after);
|
|
511
|
+
aStart++;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
} else {
|
|
515
|
+
aStart++;
|
|
516
|
+
}
|
|
517
|
+
} else {
|
|
518
|
+
if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
|
|
519
|
+
aStart++;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return b;
|
|
524
|
+
}
|
|
525
|
+
function cleanChildren(parent, current, marker) {
|
|
526
|
+
if (current) {
|
|
527
|
+
if (Array.isArray(current)) {
|
|
528
|
+
for (let i = 0; i < current.length; i++) {
|
|
529
|
+
if (current[i].parentNode === parent) parent.removeChild(current[i]);
|
|
530
|
+
}
|
|
531
|
+
} else if (current.parentNode === parent) {
|
|
532
|
+
parent.removeChild(current);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
function insertBefore(parent, node, marker) {
|
|
538
|
+
if (hydration.active && node.parentNode === parent) return;
|
|
539
|
+
if (marker) {
|
|
540
|
+
if (marker.parentNode === parent) {
|
|
541
|
+
parent.insertBefore(node, marker);
|
|
542
|
+
} else {
|
|
543
|
+
parent.appendChild(node);
|
|
544
|
+
}
|
|
545
|
+
} else {
|
|
546
|
+
parent.appendChild(node);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
function setProperty(element, name, value) {
|
|
550
|
+
if (value == null) delete element[name];
|
|
551
|
+
else element[name] = value;
|
|
552
|
+
}
|
|
553
|
+
function addNativeEventListener(element, name, value) {
|
|
554
|
+
let handler = value;
|
|
555
|
+
let options;
|
|
556
|
+
if (Array.isArray(value)) {
|
|
557
|
+
handler = value[0];
|
|
558
|
+
options = value[1];
|
|
559
|
+
}
|
|
560
|
+
if (typeof handler !== "function") return () => {
|
|
561
|
+
};
|
|
562
|
+
element.addEventListener(name, handler, options);
|
|
563
|
+
return () => element.removeEventListener(name, handler, options);
|
|
564
|
+
}
|
|
565
|
+
function reportMarked(element, accessor) {
|
|
566
|
+
if (!accessor || typeof accessor !== "function") return;
|
|
567
|
+
const written = accessor[HOLE_TAG]?.name;
|
|
568
|
+
if (!written) return;
|
|
569
|
+
const colon = written.indexOf(":");
|
|
570
|
+
if (colon === -1) return;
|
|
571
|
+
(0, import_signal2.reportReactiveDirective)(element, written.slice(0, colon), written.slice(colon + 1), accessor);
|
|
572
|
+
}
|
|
573
|
+
function reportKeys(element, kind, value) {
|
|
574
|
+
const from = typeof value === "function" ? (0, import_signal2.untrack)(() => value()) : value;
|
|
575
|
+
if (!from || typeof from !== "object") return;
|
|
576
|
+
for (const key of Object.keys(from)) (0, import_signal2.reportReactiveDirective)(element, kind, key);
|
|
577
|
+
}
|
|
578
|
+
function applyUse(element, value) {
|
|
579
|
+
const call = (dir, accessor) => {
|
|
580
|
+
if (typeof dir !== "function") return;
|
|
581
|
+
(0, import_signal2.reportReactiveDirective)(element, "use", dir.name || "use", accessor);
|
|
582
|
+
dir(element, accessor ?? (() => void 0));
|
|
583
|
+
};
|
|
584
|
+
if (typeof value === "function") {
|
|
585
|
+
call(value);
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
if (!Array.isArray(value)) return;
|
|
589
|
+
if (typeof value[0] === "function") {
|
|
590
|
+
call(value[0], value[1]);
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
for (const pair of value) {
|
|
594
|
+
if (Array.isArray(pair)) call(pair[0], pair[1]);
|
|
595
|
+
else call(pair);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
function setDynamicAttribute(element, name, accessor, isSVG = false) {
|
|
599
|
+
reportMarked(element, accessor);
|
|
600
|
+
if (typeof accessor !== "function") {
|
|
601
|
+
setAttribute(element, name, accessor, isSVG);
|
|
602
|
+
return () => {
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
return (0, import_signal2.createRenderEffect)(() => {
|
|
606
|
+
(0, import_signal2.reportReactiveBinding)(element, "attribute", name, accessor);
|
|
607
|
+
const value = typeof accessor === "function" ? accessor() : accessor;
|
|
608
|
+
setAttribute(element, name, value, isSVG);
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
function setDynamicProperty(element, name, accessor) {
|
|
612
|
+
if (typeof accessor !== "function") {
|
|
613
|
+
setProperty(element, name, accessor);
|
|
614
|
+
return () => {
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
reportMarked(element, accessor);
|
|
618
|
+
return (0, import_signal2.createRenderEffect)(() => {
|
|
619
|
+
(0, import_signal2.reportReactiveBinding)(element, "property", name, accessor);
|
|
620
|
+
const value = typeof accessor === "function" ? accessor() : accessor;
|
|
621
|
+
setProperty(element, name, value);
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
function setDynamicBoolAttribute(element, name, accessor) {
|
|
625
|
+
if (typeof accessor !== "function") {
|
|
626
|
+
setAttribute(element, name, !!accessor);
|
|
627
|
+
return () => {
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
return (0, import_signal2.createRenderEffect)(() => {
|
|
631
|
+
(0, import_signal2.reportReactiveBinding)(element, "attribute", name, accessor);
|
|
632
|
+
const value = accessor();
|
|
633
|
+
setAttribute(element, name, !!value);
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
function setClassName(element, value) {
|
|
637
|
+
if (value == null) {
|
|
638
|
+
element.removeAttribute("class");
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
if (typeof value === "function") {
|
|
642
|
+
(0, import_signal2.createRenderEffect)(() => {
|
|
643
|
+
(0, import_signal2.reportReactiveBinding)(element, "attribute", "class", value);
|
|
644
|
+
setClassName(element, value());
|
|
645
|
+
});
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
if (typeof value === "string") {
|
|
649
|
+
element.setAttribute("class", value);
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
if (Array.isArray(value)) {
|
|
653
|
+
element.setAttribute("class", value.filter(Boolean).join(" "));
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
if (typeof value === "object") {
|
|
657
|
+
const classes = Object.keys(value).filter((key) => {
|
|
658
|
+
const v = value[key];
|
|
659
|
+
return typeof v === "function" ? v() : Boolean(v);
|
|
660
|
+
}).join(" ");
|
|
661
|
+
element.setAttribute("class", classes);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
element.setAttribute("class", String(value));
|
|
665
|
+
}
|
|
666
|
+
function setClassList(element, value, disposers) {
|
|
667
|
+
if (!value || typeof value !== "object") return;
|
|
668
|
+
for (const name in value) {
|
|
669
|
+
const cond = value[name];
|
|
670
|
+
const names = name.split(/\s+/).filter(Boolean);
|
|
671
|
+
if (typeof cond === "function" && disposers) {
|
|
672
|
+
disposers.push(
|
|
673
|
+
(0, import_signal2.createRenderEffect)(() => {
|
|
674
|
+
const on = !!cond();
|
|
675
|
+
for (const n of names) element.classList.toggle(n, on);
|
|
676
|
+
})
|
|
677
|
+
);
|
|
678
|
+
} else {
|
|
679
|
+
const on = !!(typeof cond === "function" ? cond() : cond);
|
|
680
|
+
for (const n of names) element.classList.toggle(n, on);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
function setStyle(element, _value) {
|
|
685
|
+
let value = _value;
|
|
686
|
+
while (typeof value === "function") value = value();
|
|
687
|
+
if (value == null) {
|
|
688
|
+
element.removeAttribute("style");
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
if (typeof value === "string") {
|
|
692
|
+
element.style.cssText = value;
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
if (typeof value === "object") {
|
|
696
|
+
for (const key in value) {
|
|
697
|
+
const styleValue = value[key];
|
|
698
|
+
if (styleValue == null) element.style[key] = "";
|
|
699
|
+
else element.style[key] = styleValue;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function applyProps(element, props, isSVG = false) {
|
|
704
|
+
for (const key in props) {
|
|
705
|
+
const val = props[key];
|
|
706
|
+
if (key === "ref") {
|
|
707
|
+
handleRef(val, element);
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
if (key === "children") continue;
|
|
711
|
+
if (key === "use") {
|
|
712
|
+
applyUse(element, val);
|
|
713
|
+
continue;
|
|
714
|
+
}
|
|
715
|
+
if (key.startsWith("on:")) {
|
|
716
|
+
addNativeEventListener(element, key.slice(3), val);
|
|
717
|
+
continue;
|
|
718
|
+
}
|
|
719
|
+
if (key.startsWith("prop:")) {
|
|
720
|
+
(0, import_signal2.reportReactiveDirective)(element, "prop", key.slice(5), val);
|
|
721
|
+
setDynamicProperty(element, key.slice(5), val);
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
if (key.startsWith("attr:")) {
|
|
725
|
+
(0, import_signal2.reportReactiveDirective)(element, "attr", key.slice(5), val);
|
|
726
|
+
setDynamicAttribute(element, key.slice(5), val, isSVG);
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
729
|
+
if (key.startsWith("bool:")) {
|
|
730
|
+
(0, import_signal2.reportReactiveDirective)(element, "bool", key.slice(5), val);
|
|
731
|
+
setDynamicBoolAttribute(element, key.slice(5), val);
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
if (key.startsWith("on") && key.length > 2) {
|
|
735
|
+
const name = key.slice(2).toLowerCase();
|
|
736
|
+
if (typeof val === "function") {
|
|
737
|
+
if (NON_DELEGATED.has(name)) {
|
|
738
|
+
element[`$$${name}`] = val;
|
|
739
|
+
const listenerKey = `__fx_${name}`;
|
|
740
|
+
if (!element[listenerKey]) {
|
|
741
|
+
const forwarder = (e) => {
|
|
742
|
+
element[`$$${name}`]?.(e);
|
|
743
|
+
};
|
|
744
|
+
element.addEventListener(name, forwarder);
|
|
745
|
+
element[listenerKey] = forwarder;
|
|
746
|
+
}
|
|
747
|
+
} else {
|
|
748
|
+
element[`$$${name}`] = val;
|
|
749
|
+
if (!delegatedSet.has(name)) delegateEvents([name]);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
754
|
+
if (key === "class" || key === "className") {
|
|
755
|
+
setClassName(element, val);
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
if (key === "classList") {
|
|
759
|
+
reportKeys(element, "class", val);
|
|
760
|
+
if (typeof val === "function")
|
|
761
|
+
(0, import_signal2.createRenderEffect)(() => {
|
|
762
|
+
(0, import_signal2.reportReactiveBinding)(element, "attribute", "class", val);
|
|
763
|
+
setClassList(element, val());
|
|
764
|
+
});
|
|
765
|
+
else setClassList(element, val);
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
if (key === "style") {
|
|
769
|
+
reportKeys(element, "style", val);
|
|
770
|
+
if (typeof val === "function")
|
|
771
|
+
(0, import_signal2.createRenderEffect)(() => {
|
|
772
|
+
(0, import_signal2.reportReactiveBinding)(element, "attribute", "style", val);
|
|
773
|
+
setStyle(element, val());
|
|
774
|
+
});
|
|
775
|
+
else setStyle(element, val);
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
if (key === "innerHTML") {
|
|
779
|
+
if (typeof val === "function") {
|
|
780
|
+
const dispose = (0, import_signal2.createEffect)(() => {
|
|
781
|
+
let v = val();
|
|
782
|
+
while (typeof v === "function") v = v();
|
|
783
|
+
element.innerHTML = v;
|
|
784
|
+
});
|
|
785
|
+
(0, import_signal2.onCleanup)(() => dispose());
|
|
786
|
+
} else {
|
|
787
|
+
element.innerHTML = val;
|
|
788
|
+
}
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
if (key === "value" && (element.tagName === "INPUT" || element.tagName === "TEXTAREA")) {
|
|
792
|
+
if (typeof val === "function") {
|
|
793
|
+
const dispose = (0, import_signal2.createEffect)(() => {
|
|
794
|
+
let v = val();
|
|
795
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
796
|
+
if (document.activeElement !== element) {
|
|
797
|
+
element.value = v ?? "";
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
(0, import_signal2.onCleanup)(() => {
|
|
801
|
+
dispose();
|
|
802
|
+
});
|
|
803
|
+
} else {
|
|
804
|
+
(0, import_signal2.createRenderEffect)(() => {
|
|
805
|
+
if (document.activeElement !== element) {
|
|
806
|
+
element.value = props[key] ?? "";
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
if (key === "checked" && element.tagName === "INPUT") {
|
|
813
|
+
if (typeof val === "function") {
|
|
814
|
+
const dispose = (0, import_signal2.createEffect)(() => {
|
|
815
|
+
let v = val();
|
|
816
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
817
|
+
if (document.activeElement !== element) {
|
|
818
|
+
element.checked = v ?? "";
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
(0, import_signal2.onCleanup)(() => {
|
|
822
|
+
dispose();
|
|
823
|
+
});
|
|
824
|
+
} else {
|
|
825
|
+
(0, import_signal2.createRenderEffect)(() => {
|
|
826
|
+
if (document.activeElement !== element) {
|
|
827
|
+
element.checked = props[key] ?? "";
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
if (key === "value" && element.tagName === "SELECT") {
|
|
834
|
+
if (typeof val === "function") {
|
|
835
|
+
let firstRun = true;
|
|
836
|
+
const dispose = (0, import_signal2.createEffect)(() => {
|
|
837
|
+
let v = val();
|
|
838
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
839
|
+
if (firstRun) {
|
|
840
|
+
firstRun = false;
|
|
841
|
+
queueMicrotask(() => {
|
|
842
|
+
element.value = v ?? "";
|
|
843
|
+
});
|
|
844
|
+
} else {
|
|
845
|
+
element.value = v ?? "";
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
(0, import_signal2.onCleanup)(() => {
|
|
849
|
+
dispose();
|
|
850
|
+
});
|
|
851
|
+
} else {
|
|
852
|
+
let firstRun = true;
|
|
853
|
+
(0, import_signal2.createRenderEffect)(() => {
|
|
854
|
+
const v = props[key];
|
|
855
|
+
if (firstRun) {
|
|
856
|
+
firstRun = false;
|
|
857
|
+
queueMicrotask(() => {
|
|
858
|
+
element.value = v ?? "";
|
|
859
|
+
});
|
|
860
|
+
} else {
|
|
861
|
+
element.value = v ?? "";
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
867
|
+
if (typeof val === "function") {
|
|
868
|
+
const dispose = (0, import_signal2.createEffect)(() => {
|
|
869
|
+
let v = val();
|
|
870
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
871
|
+
applyElementProp(element, key, v, isSVG);
|
|
872
|
+
});
|
|
873
|
+
(0, import_signal2.onCleanup)(() => {
|
|
874
|
+
dispose();
|
|
875
|
+
});
|
|
876
|
+
} else {
|
|
877
|
+
(0, import_signal2.createRenderEffect)(() => applyElementProp(element, key, props[key], isSVG));
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
function handleRef(ref, element) {
|
|
882
|
+
if (!ref) return;
|
|
883
|
+
const held = ref[HOLE_TAG]?.name;
|
|
884
|
+
(0, import_signal2.reportReactiveDirective)(
|
|
885
|
+
element,
|
|
886
|
+
"ref",
|
|
887
|
+
held || (typeof ref === "function" ? ref.name || "ref" : "ref"),
|
|
888
|
+
ref
|
|
889
|
+
);
|
|
890
|
+
if (isDomNode(ref)) {
|
|
891
|
+
const actualRef = element;
|
|
892
|
+
const actualElement = ref;
|
|
893
|
+
if (!actualRef) return;
|
|
894
|
+
if (typeof actualRef === "function") actualRef(actualElement);
|
|
895
|
+
else if (typeof actualRef === "object" && "current" in actualRef) actualRef.current = actualElement;
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
if (typeof ref === "function") ref(element);
|
|
899
|
+
else if (typeof ref === "object" && "current" in ref) ref.current = element;
|
|
900
|
+
}
|
|
901
|
+
function isSVGElement(tag) {
|
|
902
|
+
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";
|
|
903
|
+
}
|
|
904
|
+
function isPromise(v) {
|
|
905
|
+
return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
// src/lib/dom/integration.ts
|
|
909
|
+
var import_reactive = require("@fluixi/reactive");
|
|
910
|
+
var _slotKey = "__fx_dom_create_component__";
|
|
911
|
+
var _slot = globalThis[_slotKey] ??= { fn: null };
|
|
912
|
+
function createComponent(Comp, props) {
|
|
913
|
+
if (_slot.fn) return _slot.fn(Comp, props);
|
|
914
|
+
if (props) (0, import_reactive.reportReactiveProps)(props);
|
|
915
|
+
const component = typeof Comp === "function" ? (0, import_reactive.untrack)(() => Comp(props)) : Comp;
|
|
916
|
+
const nameable = component != null && (typeof component === "function" || typeof component === "object");
|
|
917
|
+
if (nameable) {
|
|
918
|
+
try {
|
|
919
|
+
component["$name"] = Comp?.name;
|
|
920
|
+
} catch {
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
if (nameable && !(0, import_reactive.isSignal)(component)) {
|
|
924
|
+
return asComponent(component);
|
|
925
|
+
}
|
|
926
|
+
return component;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// src/lib/dom/dynamic-element.ts
|
|
930
|
+
var import_signal3 = require("@fluixi/reactive/signal");
|
|
931
|
+
function createDynamicElement(type, props = {}) {
|
|
932
|
+
if (typeof type === "function") return createComponent(type, props);
|
|
933
|
+
if (typeof type !== "string" || type.length === 0) return null;
|
|
934
|
+
const svgTag = isSVGElement(type);
|
|
935
|
+
if (isServer()) return getServerNodes().createElement(type, svgTag);
|
|
936
|
+
const element = svgTag ? document.createElementNS(SVG_NAMESPACE, type) : document.createElement(type);
|
|
937
|
+
applyProps(element, props, svgTag);
|
|
938
|
+
insertChildren(element, props);
|
|
939
|
+
return element;
|
|
940
|
+
}
|
|
941
|
+
function insertChildren(element, props) {
|
|
942
|
+
if (!props || props.children === void 0) return;
|
|
943
|
+
const children = (0, import_signal3.readChildren)(() => props.children);
|
|
944
|
+
const insertOne = (child) => {
|
|
945
|
+
insert(element, child, typeof child === "function" ? null : void 0);
|
|
946
|
+
};
|
|
947
|
+
if (Array.isArray(children)) children.forEach(insertOne);
|
|
948
|
+
else insertOne(children);
|
|
949
|
+
}
|