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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/dist/cdn/dom-client.cjs +1427 -1
  2. package/dist/cdn/dom-client.d.ts +2 -2
  3. package/dist/cdn/dom-client.global.js +2 -1
  4. package/dist/cdn/dom-client.js +3 -3
  5. package/dist/cdn/dom-client.mjs +1430 -1
  6. package/dist/cdn/dom.cjs +3127 -1
  7. package/dist/cdn/dom.d.ts +2 -2
  8. package/dist/cdn/dom.global.js +2 -1
  9. package/dist/cdn/dom.js +4 -4
  10. package/dist/cdn/dom.mjs +3133 -1
  11. package/dist/index.cjs +3155 -1
  12. package/dist/index.js +2 -2
  13. package/dist/index.mjs +3149 -1
  14. package/dist/lib/component/index.cjs +128 -1
  15. package/dist/lib/component/index.mjs +105 -1
  16. package/dist/lib/component/modifiers.cjs +126 -1
  17. package/dist/lib/component/modifiers.d.ts +12 -0
  18. package/dist/lib/component/modifiers.d.ts.map +1 -1
  19. package/dist/lib/component/modifiers.js +12 -84
  20. package/dist/lib/component/modifiers.mjs +105 -1
  21. package/dist/lib/dom/delegate.cjs +60 -1
  22. package/dist/lib/dom/delegate.js +1 -1
  23. package/dist/lib/dom/delegate.mjs +39 -1
  24. package/dist/lib/dom/dynamic-element.cjs +949 -1
  25. package/dist/lib/dom/dynamic-element.d.ts +3 -3
  26. package/dist/lib/dom/dynamic-element.js +2 -2
  27. package/dist/lib/dom/dynamic-element.mjs +928 -1
  28. package/dist/lib/dom/hydration-state.cjs +93 -1
  29. package/dist/lib/dom/hydration-state.d.ts +1 -1
  30. package/dist/lib/dom/hydration-state.js +1 -1
  31. package/dist/lib/dom/hydration-state.mjs +72 -1
  32. package/dist/lib/dom/hydration.cjs +685 -1
  33. package/dist/lib/dom/hydration.js +8 -8
  34. package/dist/lib/dom/hydration.mjs +664 -1
  35. package/dist/lib/dom/index.cjs +2040 -1
  36. package/dist/lib/dom/index.js +1 -1
  37. package/dist/lib/dom/index.mjs +2020 -1
  38. package/dist/lib/dom/integration.cjs +71 -1
  39. package/dist/lib/dom/integration.js +3 -3
  40. package/dist/lib/dom/integration.mjs +51 -1
  41. package/dist/lib/dom/island.cjs +790 -1
  42. package/dist/lib/dom/island.d.ts +1 -1
  43. package/dist/lib/dom/island.js +11 -11
  44. package/dist/lib/dom/island.mjs +769 -1
  45. package/dist/lib/dom/runtime.cjs +1432 -1
  46. package/dist/lib/dom/runtime.d.ts +60 -17
  47. package/dist/lib/dom/runtime.d.ts.map +1 -1
  48. package/dist/lib/dom/runtime.js +122 -79
  49. package/dist/lib/dom/runtime.mjs +1414 -1
  50. package/dist/lib/dom/server/fx-data.cjs +53 -1
  51. package/dist/lib/dom/server/fx-data.d.ts +5 -5
  52. package/dist/lib/dom/server/fx-data.js +6 -6
  53. package/dist/lib/dom/server/fx-data.mjs +32 -1
  54. package/dist/lib/dom/server/host.cjs +66 -1
  55. package/dist/lib/dom/server/host.d.ts +6 -0
  56. package/dist/lib/dom/server/host.d.ts.map +1 -1
  57. package/dist/lib/dom/server/host.js +7 -1
  58. package/dist/lib/dom/server/host.mjs +45 -1
  59. package/dist/lib/dom/server/index.cjs +759 -1
  60. package/dist/lib/dom/server/index.d.ts +1 -1
  61. package/dist/lib/dom/server/index.js +1 -1
  62. package/dist/lib/dom/server/index.mjs +743 -1
  63. package/dist/lib/dom/server/nodes.cjs +302 -1
  64. package/dist/lib/dom/server/nodes.d.ts +2 -2
  65. package/dist/lib/dom/server/nodes.d.ts.map +1 -1
  66. package/dist/lib/dom/server/nodes.js +4 -4
  67. package/dist/lib/dom/server/nodes.mjs +279 -1
  68. package/dist/lib/dom/server/parse-template.cjs +395 -1
  69. package/dist/lib/dom/server/parse-template.d.ts +1 -1
  70. package/dist/lib/dom/server/parse-template.js +4 -4
  71. package/dist/lib/dom/server/parse-template.mjs +372 -1
  72. package/dist/lib/dom/server/render.cjs +691 -1
  73. package/dist/lib/dom/server/render.d.ts +9 -1
  74. package/dist/lib/dom/server/render.d.ts.map +1 -1
  75. package/dist/lib/dom/server/render.js +23 -15
  76. package/dist/lib/dom/server/render.mjs +677 -1
  77. package/dist/lib/dom/server/request-context.cjs +110 -1
  78. package/dist/lib/dom/server/request-context.d.ts +29 -9
  79. package/dist/lib/dom/server/request-context.d.ts.map +1 -1
  80. package/dist/lib/dom/server/request-context.js +28 -8
  81. package/dist/lib/dom/server/request-context.mjs +89 -1
  82. package/dist/lib/dom/server/serialize.cjs +187 -1
  83. package/dist/lib/dom/server/serialize.js +3 -3
  84. package/dist/lib/dom/server/serialize.mjs +164 -1
  85. package/dist/lib/dom/server-renderer.cjs +760 -1
  86. package/dist/lib/dom/server-renderer.js +1 -1
  87. package/dist/lib/dom/server-renderer.mjs +745 -1
  88. package/dist/lib/dom/types.cjs +18 -1
  89. package/dist/lib/dom/utils.cjs +381 -1
  90. package/dist/lib/dom/utils.d.ts +1 -88
  91. package/dist/lib/dom/utils.d.ts.map +1 -1
  92. package/dist/lib/dom/utils.js +2 -99
  93. package/dist/lib/dom/utils.mjs +361 -1
  94. package/dist/lib/dom/versions.cjs +60 -1
  95. package/dist/lib/dom/versions.d.ts +3 -3
  96. package/dist/lib/dom/versions.d.ts.map +1 -1
  97. package/dist/lib/dom/versions.js +17 -5
  98. package/dist/lib/dom/versions.mjs +37 -1
  99. package/dist/lib/element/attributes.cjs +19 -1
  100. package/dist/lib/element/attributes.d.ts +7 -7
  101. package/dist/lib/element/attributes.js +1 -1
  102. package/dist/lib/element/attributes.mjs +1 -0
  103. package/dist/lib/element/index.cjs +19 -1
  104. package/dist/lib/element/index.mjs +1 -0
  105. package/dist/lib/element/types.cjs +18 -1
  106. package/dist/lib/element/types.d.ts +4 -5
  107. package/dist/lib/element/types.d.ts.map +1 -1
  108. package/dist/lib/element/types.js +0 -1
  109. package/dist/lib/flow/class-map.cjs +38 -1
  110. package/dist/lib/flow/class-map.d.ts +3 -3
  111. package/dist/lib/flow/class-map.js +2 -2
  112. package/dist/lib/flow/class-map.mjs +17 -1
  113. package/dist/lib/flow/client-only.cjs +57 -1
  114. package/dist/lib/flow/client-only.d.ts +4 -4
  115. package/dist/lib/flow/client-only.js +3 -3
  116. package/dist/lib/flow/client-only.mjs +36 -1
  117. package/dist/lib/flow/dynamic.cjs +53 -1
  118. package/dist/lib/flow/dynamic.d.ts +2 -2
  119. package/dist/lib/flow/dynamic.js +3 -3
  120. package/dist/lib/flow/dynamic.mjs +32 -1
  121. package/dist/lib/flow/error-boundary.cjs +43 -1
  122. package/dist/lib/flow/error-boundary.d.ts +2 -2
  123. package/dist/lib/flow/error-boundary.js +3 -3
  124. package/dist/lib/flow/error-boundary.mjs +22 -1
  125. package/dist/lib/flow/for.cjs +66 -1
  126. package/dist/lib/flow/for.d.ts +9 -9
  127. package/dist/lib/flow/for.d.ts.map +1 -1
  128. package/dist/lib/flow/for.js +2 -2
  129. package/dist/lib/flow/for.mjs +45 -1
  130. package/dist/lib/flow/index-flow.cjs +67 -1
  131. package/dist/lib/flow/index-flow.d.ts +5 -5
  132. package/dist/lib/flow/index-flow.js +4 -4
  133. package/dist/lib/flow/index-flow.mjs +46 -1
  134. package/dist/lib/flow/index.cjs +805 -1
  135. package/dist/lib/flow/index.mjs +792 -1
  136. package/dist/lib/flow/portal.cjs +538 -1
  137. package/dist/lib/flow/portal.mjs +519 -1
  138. package/dist/lib/flow/show.cjs +81 -1
  139. package/dist/lib/flow/show.d.ts +1 -1
  140. package/dist/lib/flow/show.d.ts.map +1 -1
  141. package/dist/lib/flow/show.js +4 -115
  142. package/dist/lib/flow/show.mjs +67 -1
  143. package/dist/lib/flow/style-map.cjs +43 -1
  144. package/dist/lib/flow/style-map.d.ts +3 -3
  145. package/dist/lib/flow/style-map.js +3 -3
  146. package/dist/lib/flow/style-map.mjs +22 -1
  147. package/dist/lib/flow/switch.cjs +91 -1
  148. package/dist/lib/flow/switch.d.ts +3 -3
  149. package/dist/lib/flow/switch.d.ts.map +1 -1
  150. package/dist/lib/flow/switch.js +6 -6
  151. package/dist/lib/flow/switch.mjs +70 -1
  152. package/dist/lib/flow/utils.cjs +44 -1
  153. package/dist/lib/flow/utils.d.ts +1 -1
  154. package/dist/lib/flow/utils.js +1 -1
  155. package/dist/lib/flow/utils.mjs +23 -1
  156. package/dist/lib/html.cjs +32 -1
  157. package/dist/lib/html.d.ts +6 -6
  158. package/dist/lib/html.js +5 -5
  159. package/dist/lib/html.mjs +11 -1
  160. package/dist/lib/index.cjs +3104 -1
  161. package/dist/lib/index.d.ts +0 -1
  162. package/dist/lib/index.d.ts.map +1 -1
  163. package/dist/lib/index.js +2 -3
  164. package/dist/lib/index.mjs +3097 -1
  165. package/dist/lib/shared/types.cjs +18 -1
  166. package/dist/lib/shared/types.d.ts +8 -8
  167. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  168. package/dist/version.generated.cjs +26 -1
  169. package/dist/version.generated.d.ts +1 -1
  170. package/dist/version.generated.js +2 -2
  171. package/dist/version.generated.mjs +5 -1
  172. package/package.json +7 -6
  173. package/dist/lib/jsx/control-flow/flow.cjs +0 -1
  174. package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
  175. package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
  176. package/dist/lib/jsx/control-flow/flow.js +0 -627
  177. package/dist/lib/jsx/control-flow/flow.mjs +0 -0
  178. package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
  179. package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
  180. package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
  181. package/dist/lib/jsx/control-flow/for-flow.js +0 -1
  182. package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
@@ -1 +1,790 @@
1
- "use strict";var O=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var le=(t,e)=>{for(var n in e)O(t,n,{get:e[n],enumerable:!0})},ce=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of fe(e))!ue.call(t,u)&&u!==n&&O(t,u,{get:()=>e[u],enumerable:!(o=ae(e,u))||o.enumerable});return t};var de=t=>ce(O({},"__esModule",{value:!0}),t);var Me={};le(Me,{Island:()=>Re,hydrateIslands:()=>Pe});module.exports=de(Me);var x=require("@fluixi/reactive/signal");var V="http://www.w3.org/2000/svg";function v(t,e,n,o=!1){if(n==null||n===!1){t.removeAttribute(e);return}if(n===!0){t.setAttribute(e,"");return}if(typeof n=="object"){t.setAttribute(e,JSON.stringify(n));return}t.setAttribute(e,String(n))}var _e=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;var W="1.0.0-alpha.83";var K=require("@fluixi/reactive/version"),m={dom:W,reactive:K.VERSION};function B(t){m.core&&t.setAttribute("fluixi",m.core),t.setAttribute("fx-dom",m.dom),t.setAttribute("fx-reactive",m.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=m)}function G(){let t=[m.core,m.dom,m.reactive].filter(e=>e!==void 0);new Set(t).size<=1||console.warn(`[fluixi] package versions disagree — core ${m.core??"(absent)"}, dom ${m.dom}, reactive ${m.reactive}. These ship as one release, so a mismatch usually means a stale lockfile or two copies resolved side by side. Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`)}function N(t){return typeof t=="function"&&t[Symbol.for("fluixi-component")]===!0}var y=require("@fluixi/reactive/signal");var J=Symbol.for("fluixi.server-node"),pe=Symbol.for("fluixi.dom.server-host"),ye=globalThis,$=ye[pe]??={server:typeof document>"u",nodes:null};function T(){return $.server}function D(){if(!$.nodes)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return $.nodes}function I(t){return t!=null&&t[J]===!0?!0:typeof Node<"u"&&t instanceof Node}function X(t){return t!=null&&t[J]===!0?t.nodeType===3:typeof Text<"u"&&t instanceof Text}var l={active:!1,cursor:null,parents:[]},z=null;function U(t){z=t}function H(){return z}function q(t,e){return l.active&&e.parentNode===t}function Y(t){let e=l.parents.lastIndexOf(t);e!==-1&&(l.parents.length=e),l.cursor=t.nextSibling}var ge="__fx_loc";function Z(t,e){return e&&(t[ge]=e),t}function E(t,e=!1){if(T())return D().createText(t);if(l.active&&!e){let n=H()?.hydrateText(t);if(n)return n}return document.createTextNode(t)}function Q(t,e=!1,n){if(T())return D().createElement(t,e);if(l.active){let o=H()?.hydrateElement(t);if(o)return n?Z(o,n):o}return Z(e?document.createElementNS(V,t):document.createElement(t),n)}var b=0,me=200;function xe(t,e,n,o,u){let a=o,s=new Map;return(0,y.createRenderEffect)(()=>{(0,y.reportReactiveBinding)(n??e,"content",void 0,t);let r;if(N(t)&&!(0,x.isSignal)(t)){if(!s.has(t)){b++;try{let i=t();s.set(t,i)}finally{b--}}for(r=s.get(t);typeof r=="function"&&(0,x.isSignal)(r);)r=r()}else for(r=t();typeof r=="function"&&(0,x.isSignal)(r);)r=r();{let i=0;for(;typeof r=="function"&&i++<50;)if(N(r)){if(!s.has(r)){let f=r;b++;try{let c=f();s.set(f,c)}finally{b--}}r=s.get(r)}else if((0,x.isSignal)(r))r=r();else if(r=r(),typeof r!="function"||!(0,x.isSignal)(r)&&!N(r))break}b++;try{a=C(e,r,n,a,s),u(a)}finally{b--}})}function S(t,e,n,o){if(b>me)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=E("",!0),t.appendChild(n));let u=o??null,a=i=>Array.isArray(i)&&i.some(f=>typeof f=="function"),s=i=>typeof i=="function"?i:()=>i;if(typeof e!="function"&&!a(e)){b++;try{u=C(t,e,n,u)}finally{b--}return()=>u}let r=xe(s(e),t,n,u,i=>{u=i});return()=>(r?.(),u)}function C(t,e,n,o,u){if(e==null||typeof e=="boolean")return w(t,o,n);if(typeof e=="function")for(;typeof e=="function";)e=e();if(e==null||typeof e=="boolean")return w(t,o,n);if(A(e)){let s=E("",!0);return Array.isArray(o)?o.length>0?(t.replaceChild(s,o[0]),w(t,o.slice(1),n)):g(t,s,n):o?t.replaceChild(s,o):g(t,s,n),e.then(r=>{s.parentNode===t&&C(t,r,s.nextSibling,s)}).catch(r=>{console.error("Error resolving promise in insertExpression:",r)}),s}let a=typeof e;if(a==="string"||a==="number"){if(a==="number"&&(e=String(e)),Array.isArray(o)){if(o.length===0){let r=E(e);return g(t,r,n),r}if(o.length===1&&o[0].nodeType===3)return o[0].data=e,o;o=w(t,o,n)}if(o&&X(o))return o.data=e,o;let s=E(e);return o&&o.parentNode===t?t.replaceChild(s,o):q(t,s)||g(t,s,n),s}if(I(e))return q(t,e)?(Y(e),e):Array.isArray(o)?(o.length===0?g(t,e,n):o[0].parentNode===t?(t.replaceChild(e,o[0]),w(t,o.slice(1),n)):g(t,e,n),e):(o?o!==e&&(o.parentNode===t?t.replaceChild(e,o):g(t,e,n)):g(t,e,n),e);if(Array.isArray(e)){let s=[],r=Array.isArray(o)?o:o?[o]:[],i=[];h(e,s,t,n,!0,u,i);let f=he(t,r,s,n);for(let c of i){let d=S(t,c.sig,c.marker);(0,y.onCleanup)(()=>{w(t,d()),c.marker.parentNode===t&&t.removeChild(c.marker)})}return f}if(a==="object"&&e!==null&&typeof e=="object"){let s=e;if("type"in s&&"props"in s){let r=s;if(typeof r.type=="function"){let i=r.type(r.props||{});return C(t,i,n,o)}}}return w(t,o,n)}function h(t,e,n,o,u=!0,a,s){for(let r=0;r<t.length;r++){let i=t[r];if(!(i==null||typeof i=="boolean")){for(;typeof i=="function"&&!A(i)&&!(0,x.isSignal)(i)&&!N(i)&&(i=i(),!(i==null||typeof i=="boolean")););if(!(i==null||typeof i=="boolean")){if(typeof i=="function"){let f;for(N(i)&&!(0,x.isSignal)(i)?(a||(a=new Map),a.has(i)||a.set(i,i()),f=a.get(i)):f=i();typeof f=="function"&&!A(f)&&!(0,x.isSignal)(f)&&!N(f);)a||(a=new Map),a.has(f)||a.set(f,f()),f=a.get(f);if(f==null||typeof f=="boolean")continue;if(typeof f=="function"){if((0,x.isSignal)(f)){if(s){let d=E("",!0);e.push(d),s.push({marker:d,sig:f});continue}let c=f();for(;typeof c=="function"&&(0,x.isSignal)(c);)c=c();if(c==null||typeof c=="boolean")continue;Array.isArray(c)?h(c,e,n,o,u,a):h([c],e,n,o,u,a);continue}continue}Array.isArray(f)?h(f,e,n,o,u,a,s):h([f],e,n,o,u,a,s);continue}if(A(i)){let f=E("",!0);e.push(f),i.then(c=>{if(f.parentNode){let d=[];if(h([c],d,f.parentNode,void 0,!1,a),d.length>0){f.parentNode.replaceChild(d[0],f);for(let p=1;p<d.length;p++)f.parentNode?.insertBefore(d[p],d[p-1].nextSibling)}}}).catch(c=>console.error("Error resolving promise in array:",c));continue}if(Array.isArray(i)){h(i,e,n,o,u,a,s);continue}if(I(i)){e.push(i);continue}if(typeof i=="object"&&i!==null&&"type"in i&&"props"in i){let f=i;if(typeof f.type=="function"){let c=f.type(f.props||{});Array.isArray(c)?h(c,e,n,o,!1,a):h([c],e,n,o,!1,a);continue}}if(typeof i=="string"||typeof i=="number"){let f=String(i);if(f.trim()===""&&f!==" ")continue;e.push(E(f));continue}e.push(E(String(i)))}}}}function he(t,e,n,o){for(let d=0;d<n.length;d++){let p=n[d].parentNode;p!==null&&p!==t&&p.nodeType!==11&&(n=n.slice(),n[d]=n[d].cloneNode(!0))}let u=n.length,a=e.length,s=u,r=0,i=0,f=a>0?e[a-1].nextSibling??void 0:o,c=null;for(;r<a||i<s;){if(e[r]===n[i]){r++,i++;continue}for(;a>r&&s>i&&e[a-1]===n[s-1];)a--,s--;if(a===r){let d=s<u?i?n[i-1].nextSibling??void 0:n[s-i]:f;for(;i<s;)g(t,n[i++],d)}else if(s===i)for(;r<a;)(!c||!c.has(e[r]))&&e[r].parentNode===t&&t.removeChild(e[r]),r++;else if(e[r]===n[s-1]&&n[i]===e[a-1]){let d=e[--a].nextSibling;g(t,n[i++],e[r++].nextSibling),g(t,n[--s],d),e[a]=e[r-1]}else{if(!c){c=new Map;let p=i;for(;p<s;)c.set(n[p],p++)}let d=c.get(e[r]);if(d!=null)if(i<d&&d<s){let p=r,_=1;for(;++p<a&&p<s&&!(!c.has(e[p])||c.get(e[p])!==d+_);)_++;if(_>d-i){let se=e[r];for(;i<d;)g(t,n[i++],se)}else e[r].parentNode===t?t.replaceChild(n[i++],e[r++]):(g(t,n[i++],f),r++)}else r++;else e[r].parentNode===t&&t.removeChild(e[r]),r++}}return n}function w(t,e,n){if(e)if(Array.isArray(e))for(let o=0;o<e.length;o++)e[o].parentNode===t&&t.removeChild(e[o]);else e.parentNode===t&&t.removeChild(e);return null}function g(t,e,n){l.active&&e.parentNode===t||(n&&n.parentNode===t?t.insertBefore(e,n):t.appendChild(e))}function A(t){return t!=null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"||t instanceof Promise}function ee(t,e,n){if(!e)throw new Error("Container element is required");let o,u,a=[];return(0,y.createRoot)(s=>{(0,y.batch)(()=>{l.active||(e.textContent=""),B(e),G(),S(e,t)}),u=s}),()=>{u?.(),o?.(),a.forEach(s=>s()),e.textContent=""}}var R,be={getStore:()=>R,run(t,e){let n=R;R=t;try{return e()}finally{R=n}}},Ee=be;function te(){return Ee.getStore()}var L=require("@fluixi/reactive/signal");var Ne="__FX_DATA__";var j;function ne(){let t=globalThis.__FX_DATA__;if(t)return t;if(j!==void 0)return j;let e=null;if(typeof document<"u"){let n=document.getElementById(Ne)?.textContent;if(n)try{e=JSON.parse(n)}catch{e=null}}return j=e}function P(){for(;;){for(;l.cursor&&l.cursor.nodeType===3&&l.cursor.data==="";)l.cursor=l.cursor.nextSibling;if(l.cursor!=null||!l.parents.length)return;l.cursor=l.parents.pop().nextSibling}}var we=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),M=typeof process<"u"&&process.env&&!1;function k(t,e){let n=e.nodeType===1?`<${e.tagName.toLowerCase()}>`:e.nodeType===3?`text ${JSON.stringify((e.nodeValue??"").slice(0,24))}`:e.nodeType===8?"comment":"node";console.warn(`[fluixi] hydration mismatch: expected ${t} but the server DOM has ${n}. Server and client rendered different markup; recreating this node on the client. Check for non-deterministic render (Date.now(), Math.random(), browser-only branches, untransported data).`)}function Te(t){P();let e=l.cursor;return e&&e.nodeType===1&&e.tagName.toLowerCase()===t.toLowerCase()?(we.has(t.toLowerCase())?l.cursor=e.nextSibling:(l.parents.push(e),l.cursor=e.firstChild),e):(M&&e&&k(`<${t}>`,e),null)}function Se(t){P();let e=l.cursor;return e&&e.nodeType===1&&e.tagName.toLowerCase()===t.toLowerCase()?(l.cursor=e.nextSibling,e):(M&&e&&k(`<${t}> (static)`,e),null)}function ve(t){if(t===""){let n=l.cursor;return n&&n.nodeType===3&&n.data!==""?(l.cursor=n.nextSibling,n.data="",n):null}P();let e=l.cursor;return e&&e.nodeType===3?(l.cursor=e.nextSibling,e.nodeValue!==t&&(e.nodeValue=t),e):(M&&e&&k(`text ${JSON.stringify(t.slice(0,24))}`,e),null)}function Ae(t){P();let e=l.cursor;return e&&e.nodeType===8&&e.data===t?(l.cursor=e.nextSibling,e):(M&&e&&k(`marker <!--${t.slice(0,24)}-->`,e),null)}var oe=!1;function Ce(){oe||(oe=!0,U({hydrateElement:Te,hydrateText:ve,hydrateMarker:Ae,hydrateStatic:Se}))}function re(t,e,n){Ce(),l.active=!0,l.cursor=e.firstChild,l.parents=[];let o=ne(),u=n?.resourceNamespace,a=0;(0,L.setResourceIdSource)(()=>u?`${u}:r${a++}`:`r${a++}`),(0,L.setServerDataGetter)(o?s=>s in o?{value:o[s]}:void 0:null);try{return ee(t,e)}finally{l.active=!1,l.cursor=null,l.parents=[]}}var F="fluixi-island";function Re(t){let{component:e,props:n={},name:o}=t,u=Q(F),a=o??e.name??"Island";v(u,"name",a),v(u,"props",JSON.stringify(n??{}));let s=T()?te():void 0;if(s){let r=s.nextIslandNamespace(a);S(u,()=>s.withResourceScope(r,()=>e(n)))}else S(u,()=>e(n));return u}var ie=!1;function Le(){if(ie||typeof document>"u")return;ie=!0;let t=document.createElement("style");t.textContent=`${F}{display:contents}`,document.head.appendChild(t)}function Pe(t){if(typeof document>"u")return;Le();let e=document.querySelectorAll(F),n=new Map;e.forEach(o=>{let u=o.getAttribute("name")??"",a=n.get(u)??0;n.set(u,a+1);let s=t[u];if(!s){typeof process>"u"&&console.warn(`[fluixi] island "${u}" has no component in the registry — left static.`);return}let r={};try{r=JSON.parse(o.getAttribute("props")||"{}")}catch{}re(()=>s(r),o,{resourceNamespace:`${u}#${a}`})})}
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/island.ts
21
+ var island_exports = {};
22
+ __export(island_exports, {
23
+ Island: () => Island,
24
+ hydrateIslands: () => hydrateIslands
25
+ });
26
+ module.exports = __toCommonJS(island_exports);
27
+
28
+ // src/lib/dom/runtime.ts
29
+ var import_signal2 = require("@fluixi/reactive/signal");
30
+
31
+ // src/lib/dom/utils.ts
32
+ var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
33
+ function setAttribute(element, name, value, isSVG = false) {
34
+ if (value == null || value === false) {
35
+ element.removeAttribute(name);
36
+ return;
37
+ }
38
+ if (value === true) {
39
+ element.setAttribute(name, "");
40
+ return;
41
+ }
42
+ if (typeof value === "object") {
43
+ element.setAttribute(name, JSON.stringify(value));
44
+ return;
45
+ }
46
+ element.setAttribute(name, String(value));
47
+ }
48
+ var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
49
+
50
+ // src/version.generated.ts
51
+ var VERSION = "1.0.0-alpha.85";
52
+
53
+ // src/lib/dom/versions.ts
54
+ var import_version = require("@fluixi/reactive/version");
55
+ var import_signal = require("@fluixi/reactive/signal");
56
+ var versions = { dom: VERSION, reactive: import_version.VERSION };
57
+ function stampVersions(container) {
58
+ if (versions.core) container.setAttribute("fluixi", versions.core);
59
+ container.setAttribute("fx-dom", versions.dom);
60
+ container.setAttribute("fx-reactive", versions.reactive);
61
+ if (typeof globalThis !== "undefined") globalThis.Fluixi = versions;
62
+ }
63
+ function warnOnVersionSkew() {
64
+ const builds = (0, import_signal.joinedVersions)();
65
+ if (builds.length > 1) {
66
+ console.warn(
67
+ `[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.`
68
+ );
69
+ }
70
+ const present = [versions.core, versions.dom, versions.reactive].filter(
71
+ (v) => v !== void 0
72
+ );
73
+ if (new Set(present).size <= 1) return;
74
+ console.warn(
75
+ `[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\`.`
76
+ );
77
+ }
78
+
79
+ // src/lib/component/modifiers.ts
80
+ function isComponent(value) {
81
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
82
+ }
83
+
84
+ // src/lib/dom/runtime.ts
85
+ var import_signal3 = require("@fluixi/reactive/signal");
86
+
87
+ // src/lib/dom/server/host.ts
88
+ var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
89
+ var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
90
+ var realm = globalThis;
91
+ var state = realm[STATE] ??= {
92
+ server: typeof document === "undefined",
93
+ nodes: null
94
+ };
95
+ function isServer() {
96
+ return state.server;
97
+ }
98
+ function getServerNodes() {
99
+ if (!state.nodes) {
100
+ throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
101
+ }
102
+ return state.nodes;
103
+ }
104
+ function isDomNode(x) {
105
+ if (x != null && x[SERVER_NODE] === true) return true;
106
+ return typeof Node !== "undefined" && x instanceof Node;
107
+ }
108
+ function isDomText(x) {
109
+ if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
110
+ return typeof Text !== "undefined" && x instanceof Text;
111
+ }
112
+
113
+ // src/lib/dom/hydration-state.ts
114
+ var hydration = {
115
+ active: false,
116
+ cursor: null,
117
+ parents: []
118
+ };
119
+ var _walker = null;
120
+ function registerHydrationWalker(walker) {
121
+ _walker = walker;
122
+ }
123
+ function getHydrationWalker() {
124
+ return _walker;
125
+ }
126
+ function isAdopted(parent, node) {
127
+ return hydration.active && node.parentNode === parent;
128
+ }
129
+ function ascendPast(node) {
130
+ const idx = hydration.parents.lastIndexOf(node);
131
+ if (idx !== -1) hydration.parents.length = idx;
132
+ hydration.cursor = node.nextSibling;
133
+ }
134
+
135
+ // src/lib/dom/runtime.ts
136
+ var LOC_TAG = "__fx_loc";
137
+ function located(element, at) {
138
+ if (at) element[LOC_TAG] = at;
139
+ return element;
140
+ }
141
+ function createTextNode(value, anchor = false) {
142
+ if (isServer()) return getServerNodes().createText(value);
143
+ if (hydration.active && !anchor) {
144
+ const node = getHydrationWalker()?.hydrateText(value);
145
+ if (node) return node;
146
+ }
147
+ return document.createTextNode(value);
148
+ }
149
+ function createNativeElement(tag, isSVG = false, at) {
150
+ if (isServer()) return getServerNodes().createElement(tag, isSVG);
151
+ if (hydration.active) {
152
+ const node = getHydrationWalker()?.hydrateElement(tag);
153
+ if (node) return at ? located(node, at) : node;
154
+ }
155
+ return located(
156
+ isSVG ? document.createElementNS(SVG_NAMESPACE, tag) : document.createElement(tag),
157
+ at
158
+ );
159
+ }
160
+ var _insertDepth = 0;
161
+ var MAX_INSERT_DEPTH = 200;
162
+ function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
163
+ let current = initialCurrent;
164
+ const componentCache = /* @__PURE__ */ new Map();
165
+ return (0, import_signal3.createRenderEffect)(() => {
166
+ (0, import_signal3.reportReactiveBinding)(marker ?? parent, "content", void 0, getAccessor);
167
+ let value;
168
+ if (isComponent(getAccessor) && !(0, import_signal2.isSignal)(getAccessor)) {
169
+ if (!componentCache.has(getAccessor)) {
170
+ _insertDepth++;
171
+ try {
172
+ const inst = getAccessor();
173
+ componentCache.set(getAccessor, inst);
174
+ } finally {
175
+ _insertDepth--;
176
+ }
177
+ }
178
+ value = componentCache.get(getAccessor);
179
+ while (typeof value === "function" && (0, import_signal2.isSignal)(value)) value = value();
180
+ } else {
181
+ value = getAccessor();
182
+ while (typeof value === "function" && (0, import_signal2.isSignal)(value)) {
183
+ value = value();
184
+ }
185
+ }
186
+ {
187
+ let chainDepth = 0;
188
+ while (typeof value === "function" && chainDepth++ < 50) {
189
+ if (isComponent(value)) {
190
+ if (!componentCache.has(value)) {
191
+ const thunk = value;
192
+ _insertDepth++;
193
+ try {
194
+ const inst = thunk();
195
+ componentCache.set(thunk, inst);
196
+ } finally {
197
+ _insertDepth--;
198
+ }
199
+ }
200
+ value = componentCache.get(value);
201
+ } else if ((0, import_signal2.isSignal)(value)) {
202
+ value = value();
203
+ } else {
204
+ value = value();
205
+ if (typeof value !== "function" || !(0, import_signal2.isSignal)(value) && !isComponent(value)) break;
206
+ }
207
+ }
208
+ }
209
+ _insertDepth++;
210
+ try {
211
+ current = insertExpression(parent, value, marker, current, componentCache);
212
+ setCurrent(current);
213
+ } finally {
214
+ _insertDepth--;
215
+ }
216
+ });
217
+ }
218
+ function insert(parent, accessor, marker, init) {
219
+ if (_insertDepth > MAX_INSERT_DEPTH) {
220
+ console.error("[insert] Exceeded max call depth, possible infinite loop.");
221
+ return () => null;
222
+ }
223
+ if (marker !== void 0 && !marker) {
224
+ marker = createTextNode("", true);
225
+ parent.appendChild(marker);
226
+ }
227
+ let current = init ?? null;
228
+ const isReactiveArray = (element) => {
229
+ return Array.isArray(element) && element.some((v) => typeof v === "function");
230
+ };
231
+ const normalizeAccessor = (accessor2) => {
232
+ if (typeof accessor2 === "function") return accessor2;
233
+ return () => accessor2;
234
+ };
235
+ if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
236
+ _insertDepth++;
237
+ try {
238
+ current = insertExpression(parent, accessor, marker, current);
239
+ } finally {
240
+ _insertDepth--;
241
+ }
242
+ return () => current;
243
+ }
244
+ const dispose = _createInsertEffect(
245
+ normalizeAccessor(accessor),
246
+ parent,
247
+ marker,
248
+ current,
249
+ (v) => {
250
+ current = v;
251
+ }
252
+ );
253
+ return () => {
254
+ dispose?.();
255
+ return current;
256
+ };
257
+ }
258
+ function insertExpression(parent, value, marker, current, componentCache) {
259
+ if (value == null || typeof value === "boolean") {
260
+ return cleanChildren(parent, current, marker);
261
+ }
262
+ if (typeof value === "function") {
263
+ while (typeof value === "function") {
264
+ value = value();
265
+ }
266
+ }
267
+ if (value == null || typeof value === "boolean") {
268
+ return cleanChildren(parent, current, marker);
269
+ }
270
+ if (isPromise(value)) {
271
+ const placeholder = createTextNode("", true);
272
+ if (Array.isArray(current)) {
273
+ if (current.length > 0) {
274
+ parent.replaceChild(placeholder, current[0]);
275
+ cleanChildren(parent, current.slice(1), marker);
276
+ } else {
277
+ insertBefore(parent, placeholder, marker);
278
+ }
279
+ } else if (current) {
280
+ parent.replaceChild(placeholder, current);
281
+ } else {
282
+ insertBefore(parent, placeholder, marker);
283
+ }
284
+ value.then((resolved) => {
285
+ if (placeholder.parentNode === parent) {
286
+ insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
287
+ }
288
+ }).catch((err) => {
289
+ console.error("Error resolving promise in insertExpression:", err);
290
+ });
291
+ return placeholder;
292
+ }
293
+ const t = typeof value;
294
+ if (t === "string" || t === "number") {
295
+ if (t === "number") value = String(value);
296
+ if (Array.isArray(current)) {
297
+ if (current.length === 0) {
298
+ const node2 = createTextNode(value);
299
+ insertBefore(parent, node2, marker);
300
+ return node2;
301
+ }
302
+ if (current.length === 1 && current[0].nodeType === 3) {
303
+ current[0].data = value;
304
+ return current;
305
+ }
306
+ current = cleanChildren(parent, current, marker);
307
+ }
308
+ if (current && isDomText(current)) {
309
+ current.data = value;
310
+ return current;
311
+ }
312
+ const node = createTextNode(value);
313
+ if (current && current.parentNode === parent) {
314
+ parent.replaceChild(node, current);
315
+ } else if (!isAdopted(parent, node)) {
316
+ insertBefore(parent, node, marker);
317
+ }
318
+ return node;
319
+ }
320
+ if (isDomNode(value)) {
321
+ if (isAdopted(parent, value)) {
322
+ ascendPast(value);
323
+ return value;
324
+ }
325
+ if (Array.isArray(current)) {
326
+ if (current.length === 0) {
327
+ insertBefore(parent, value, marker);
328
+ } else if (current[0].parentNode === parent) {
329
+ parent.replaceChild(value, current[0]);
330
+ cleanChildren(parent, current.slice(1), marker);
331
+ } else {
332
+ insertBefore(parent, value, marker);
333
+ }
334
+ return value;
335
+ }
336
+ if (!current) {
337
+ insertBefore(parent, value, marker);
338
+ } else if (current !== value) {
339
+ if (current.parentNode === parent) {
340
+ parent.replaceChild(value, current);
341
+ } else {
342
+ insertBefore(parent, value, marker);
343
+ }
344
+ }
345
+ return value;
346
+ }
347
+ if (Array.isArray(value)) {
348
+ const array = [];
349
+ const currentArray = Array.isArray(current) ? current : current ? [current] : [];
350
+ const reactiveSlots = [];
351
+ flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
352
+ const reconciled = reconcileArrays(parent, currentArray, array, marker);
353
+ for (const slot of reactiveSlots) {
354
+ const disposeSlot = insert(parent, slot.sig, slot.marker);
355
+ (0, import_signal3.onCleanup)(() => {
356
+ cleanChildren(parent, disposeSlot());
357
+ if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
358
+ });
359
+ }
360
+ return reconciled;
361
+ }
362
+ if (t === "object" && value !== null && typeof value === "object") {
363
+ const objValue = value;
364
+ if ("type" in objValue && "props" in objValue) {
365
+ const jsxValue = objValue;
366
+ if (typeof jsxValue.type === "function") {
367
+ const result = jsxValue.type(jsxValue.props || {});
368
+ return insertExpression(parent, result, marker, current);
369
+ }
370
+ }
371
+ }
372
+ return cleanChildren(parent, current, marker);
373
+ }
374
+ function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
375
+ for (let i = 0; i < arr.length; i++) {
376
+ let item = arr[i];
377
+ if (item == null || typeof item === "boolean") continue;
378
+ while (typeof item === "function" && !isPromise(item) && !(0, import_signal2.isSignal)(item) && !isComponent(item)) {
379
+ item = item();
380
+ if (item == null || typeof item === "boolean") break;
381
+ }
382
+ if (item == null || typeof item === "boolean") continue;
383
+ if (typeof item === "function") {
384
+ let resolved;
385
+ if (isComponent(item) && !(0, import_signal2.isSignal)(item)) {
386
+ if (!componentCache) componentCache = /* @__PURE__ */ new Map();
387
+ if (!componentCache.has(item)) componentCache.set(item, item());
388
+ resolved = componentCache.get(item);
389
+ } else {
390
+ resolved = item();
391
+ }
392
+ while (typeof resolved === "function" && !isPromise(resolved) && !(0, import_signal2.isSignal)(resolved) && !isComponent(resolved)) {
393
+ if (!componentCache) componentCache = /* @__PURE__ */ new Map();
394
+ if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
395
+ resolved = componentCache.get(resolved);
396
+ }
397
+ if (resolved == null || typeof resolved === "boolean") continue;
398
+ if (typeof resolved === "function") {
399
+ if ((0, import_signal2.isSignal)(resolved)) {
400
+ if (reactiveSlots) {
401
+ const slot = createTextNode("", true);
402
+ result.push(slot);
403
+ reactiveSlots.push({ marker: slot, sig: resolved });
404
+ continue;
405
+ }
406
+ let val = resolved();
407
+ while (typeof val === "function" && (0, import_signal2.isSignal)(val)) val = val();
408
+ if (val == null || typeof val === "boolean") continue;
409
+ if (Array.isArray(val)) {
410
+ flattenArray(val, result, parent, marker, track, componentCache);
411
+ } else flattenArray([val], result, parent, marker, track, componentCache);
412
+ continue;
413
+ }
414
+ continue;
415
+ }
416
+ if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
417
+ else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
418
+ continue;
419
+ }
420
+ if (isPromise(item)) {
421
+ const placeholder = createTextNode("", true);
422
+ result.push(placeholder);
423
+ item.then((resolved) => {
424
+ if (placeholder.parentNode) {
425
+ const tempNodes = [];
426
+ flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
427
+ if (tempNodes.length > 0) {
428
+ placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
429
+ for (let j = 1; j < tempNodes.length; j++) {
430
+ placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
431
+ }
432
+ }
433
+ }
434
+ }).catch((err) => console.error("Error resolving promise in array:", err));
435
+ continue;
436
+ }
437
+ if (Array.isArray(item)) {
438
+ flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
439
+ continue;
440
+ }
441
+ if (isDomNode(item)) {
442
+ result.push(item);
443
+ continue;
444
+ }
445
+ if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
446
+ const jsxItem = item;
447
+ if (typeof jsxItem.type === "function") {
448
+ const resolved = jsxItem.type(jsxItem.props || {});
449
+ if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
450
+ else flattenArray([resolved], result, parent, marker, false, componentCache);
451
+ continue;
452
+ }
453
+ }
454
+ if (typeof item === "string" || typeof item === "number") {
455
+ const str = String(item);
456
+ if (str.trim() === "" && str !== " ") continue;
457
+ result.push(createTextNode(str));
458
+ continue;
459
+ }
460
+ result.push(createTextNode(String(item)));
461
+ }
462
+ }
463
+ function reconcileArrays(parent, a, b, marker) {
464
+ for (let i = 0; i < b.length; i++) {
465
+ const owner = b[i].parentNode;
466
+ if (owner !== null && owner !== parent && owner.nodeType !== 11) {
467
+ b = b.slice();
468
+ b[i] = b[i].cloneNode(true);
469
+ }
470
+ }
471
+ 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;
472
+ while (aStart < aEnd || bStart < bEnd) {
473
+ if (a[aStart] === b[bStart]) {
474
+ aStart++;
475
+ bStart++;
476
+ continue;
477
+ }
478
+ while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
479
+ aEnd--;
480
+ bEnd--;
481
+ }
482
+ if (aEnd === aStart) {
483
+ const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
484
+ while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
485
+ } else if (bEnd === bStart) {
486
+ while (aStart < aEnd) {
487
+ if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
488
+ parent.removeChild(a[aStart]);
489
+ aStart++;
490
+ }
491
+ } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
492
+ const node = a[--aEnd].nextSibling;
493
+ insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
494
+ insertBefore(parent, b[--bEnd], node);
495
+ a[aEnd] = a[aStart - 1];
496
+ } else {
497
+ if (!map) {
498
+ map = /* @__PURE__ */ new Map();
499
+ let i = bStart;
500
+ while (i < bEnd) map.set(b[i], i++);
501
+ }
502
+ const index = map.get(a[aStart]);
503
+ if (index != null) {
504
+ if (bStart < index && index < bEnd) {
505
+ let i = aStart, sequence = 1;
506
+ while (++i < aEnd && i < bEnd) {
507
+ if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
508
+ sequence++;
509
+ }
510
+ if (sequence > index - bStart) {
511
+ const node = a[aStart];
512
+ while (bStart < index) insertBefore(parent, b[bStart++], node);
513
+ } else {
514
+ if (a[aStart].parentNode === parent) {
515
+ parent.replaceChild(b[bStart++], a[aStart++]);
516
+ } else {
517
+ insertBefore(parent, b[bStart++], after);
518
+ aStart++;
519
+ }
520
+ }
521
+ } else {
522
+ aStart++;
523
+ }
524
+ } else {
525
+ if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
526
+ aStart++;
527
+ }
528
+ }
529
+ }
530
+ return b;
531
+ }
532
+ function cleanChildren(parent, current, marker) {
533
+ if (current) {
534
+ if (Array.isArray(current)) {
535
+ for (let i = 0; i < current.length; i++) {
536
+ if (current[i].parentNode === parent) parent.removeChild(current[i]);
537
+ }
538
+ } else if (current.parentNode === parent) {
539
+ parent.removeChild(current);
540
+ }
541
+ }
542
+ return null;
543
+ }
544
+ function insertBefore(parent, node, marker) {
545
+ if (hydration.active && node.parentNode === parent) return;
546
+ if (marker) {
547
+ if (marker.parentNode === parent) {
548
+ parent.insertBefore(node, marker);
549
+ } else {
550
+ parent.appendChild(node);
551
+ }
552
+ } else {
553
+ parent.appendChild(node);
554
+ }
555
+ }
556
+ function isPromise(v) {
557
+ return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
558
+ }
559
+ function render(element, container, context) {
560
+ if (!container) {
561
+ throw new Error("Container element is required");
562
+ }
563
+ let rendererDispose;
564
+ let disposeRoot;
565
+ const disposers = [];
566
+ (0, import_signal3.createRoot)((dispose) => {
567
+ (0, import_signal3.batch)(() => {
568
+ if (!hydration.active) {
569
+ container.textContent = "";
570
+ }
571
+ stampVersions(container);
572
+ warnOnVersionSkew();
573
+ insert(container, element);
574
+ return;
575
+ });
576
+ disposeRoot = dispose;
577
+ });
578
+ return () => {
579
+ disposeRoot?.();
580
+ rendererDispose?.();
581
+ disposers.forEach((d) => d());
582
+ container.textContent = "";
583
+ };
584
+ }
585
+
586
+ // src/lib/dom/server/request-context.ts
587
+ var _current;
588
+ var syncStore = {
589
+ getStore: () => _current,
590
+ run(ctx, fn) {
591
+ const prev = _current;
592
+ _current = ctx;
593
+ try {
594
+ return fn();
595
+ } finally {
596
+ _current = prev;
597
+ }
598
+ }
599
+ };
600
+ var _store = syncStore;
601
+ function getRequestContext() {
602
+ return _store.getStore();
603
+ }
604
+
605
+ // src/lib/dom/hydration.ts
606
+ var import_signal4 = require("@fluixi/reactive/signal");
607
+
608
+ // src/lib/dom/server/fx-data.ts
609
+ var FX_DATA_ID = "__FX_DATA__";
610
+ var _scriptCache;
611
+ function getServerData() {
612
+ const g = globalThis.__FX_DATA__;
613
+ if (g) return g;
614
+ if (_scriptCache !== void 0) return _scriptCache;
615
+ let parsed = null;
616
+ if (typeof document !== "undefined") {
617
+ const text = document.getElementById(FX_DATA_ID)?.textContent;
618
+ if (text) {
619
+ try {
620
+ parsed = JSON.parse(text);
621
+ } catch {
622
+ parsed = null;
623
+ }
624
+ }
625
+ }
626
+ return _scriptCache = parsed;
627
+ }
628
+
629
+ // src/lib/dom/hydration.ts
630
+ function recoverCursor() {
631
+ for (; ; ) {
632
+ while (hydration.cursor && hydration.cursor.nodeType === 3 && hydration.cursor.data === "") {
633
+ hydration.cursor = hydration.cursor.nextSibling;
634
+ }
635
+ if (hydration.cursor != null || !hydration.parents.length) return;
636
+ hydration.cursor = hydration.parents.pop().nextSibling;
637
+ }
638
+ }
639
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
640
+ "area",
641
+ "base",
642
+ "br",
643
+ "col",
644
+ "embed",
645
+ "hr",
646
+ "img",
647
+ "input",
648
+ "link",
649
+ "meta",
650
+ "param",
651
+ "source",
652
+ "track",
653
+ "wbr"
654
+ ]);
655
+ var DEV = typeof process !== "undefined" && process.env && false;
656
+ function warnMismatch(expected, found) {
657
+ const f = found.nodeType === 1 ? `<${found.tagName.toLowerCase()}>` : found.nodeType === 3 ? `text ${JSON.stringify((found.nodeValue ?? "").slice(0, 24))}` : found.nodeType === 8 ? "comment" : "node";
658
+ console.warn(
659
+ `[fluixi] hydration mismatch: expected ${expected} but the server DOM has ${f}. Server and client rendered different markup; recreating this node on the client. Check for non-deterministic render (Date.now(), Math.random(), browser-only branches, untransported data).`
660
+ );
661
+ }
662
+ function hydrateElement(tag) {
663
+ recoverCursor();
664
+ const c = hydration.cursor;
665
+ if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
666
+ if (VOID_ELEMENTS.has(tag.toLowerCase())) {
667
+ hydration.cursor = c.nextSibling;
668
+ } else {
669
+ hydration.parents.push(c);
670
+ hydration.cursor = c.firstChild;
671
+ }
672
+ return c;
673
+ }
674
+ if (DEV && c) warnMismatch(`<${tag}>`, c);
675
+ return null;
676
+ }
677
+ function hydrateStatic(tag) {
678
+ recoverCursor();
679
+ const c = hydration.cursor;
680
+ if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
681
+ hydration.cursor = c.nextSibling;
682
+ return c;
683
+ }
684
+ if (DEV && c) warnMismatch(`<${tag}> (static)`, c);
685
+ return null;
686
+ }
687
+ function hydrateText(value) {
688
+ if (value === "") {
689
+ const c2 = hydration.cursor;
690
+ if (c2 && c2.nodeType === 3 && c2.data !== "") {
691
+ hydration.cursor = c2.nextSibling;
692
+ c2.data = "";
693
+ return c2;
694
+ }
695
+ return null;
696
+ }
697
+ recoverCursor();
698
+ const c = hydration.cursor;
699
+ if (c && c.nodeType === 3) {
700
+ hydration.cursor = c.nextSibling;
701
+ if (c.nodeValue !== value) c.nodeValue = value;
702
+ return c;
703
+ }
704
+ if (DEV && c) warnMismatch(`text ${JSON.stringify(value.slice(0, 24))}`, c);
705
+ return null;
706
+ }
707
+ function hydrateMarker(value) {
708
+ recoverCursor();
709
+ const c = hydration.cursor;
710
+ if (c && c.nodeType === 8 && c.data === value) {
711
+ hydration.cursor = c.nextSibling;
712
+ return c;
713
+ }
714
+ if (DEV && c) warnMismatch(`marker <!--${value.slice(0, 24)}-->`, c);
715
+ return null;
716
+ }
717
+ var _walkerRegistered = false;
718
+ function ensureWalker() {
719
+ if (_walkerRegistered) return;
720
+ _walkerRegistered = true;
721
+ registerHydrationWalker({ hydrateElement, hydrateText, hydrateMarker, hydrateStatic });
722
+ }
723
+ function hydrate(element, container, options) {
724
+ ensureWalker();
725
+ hydration.active = true;
726
+ hydration.cursor = container.firstChild;
727
+ hydration.parents = [];
728
+ const data = getServerData();
729
+ const ns = options?.resourceNamespace;
730
+ let rid = 0;
731
+ (0, import_signal4.setResourceIdSource)(() => ns ? `${ns}:r${rid++}` : `r${rid++}`);
732
+ (0, import_signal4.setServerDataGetter)(data ? (id) => id in data ? { value: data[id] } : void 0 : null);
733
+ try {
734
+ return render(element, container);
735
+ } finally {
736
+ hydration.active = false;
737
+ hydration.cursor = null;
738
+ hydration.parents = [];
739
+ }
740
+ }
741
+
742
+ // src/lib/dom/island.ts
743
+ var TAG = "fluixi-island";
744
+ function Island(props) {
745
+ const { component, props: cprops = {}, name } = props;
746
+ const el = createNativeElement(TAG);
747
+ const islandName = name ?? component.name ?? "Island";
748
+ setAttribute(el, "name", islandName);
749
+ setAttribute(el, "props", JSON.stringify(cprops ?? {}));
750
+ const ctx = isServer() ? getRequestContext() : void 0;
751
+ if (ctx) {
752
+ const ns = ctx.nextIslandNamespace(islandName);
753
+ insert(el, () => ctx.withResourceScope(ns, () => component(cprops)));
754
+ } else {
755
+ insert(el, () => component(cprops));
756
+ }
757
+ return el;
758
+ }
759
+ var _styleInjected = false;
760
+ function ensureDisplayContents() {
761
+ if (_styleInjected || typeof document === "undefined") return;
762
+ _styleInjected = true;
763
+ const style = document.createElement("style");
764
+ style.textContent = `${TAG}{display:contents}`;
765
+ document.head.appendChild(style);
766
+ }
767
+ function hydrateIslands(registry) {
768
+ if (typeof document === "undefined") return;
769
+ ensureDisplayContents();
770
+ const els = document.querySelectorAll(TAG);
771
+ const counts = /* @__PURE__ */ new Map();
772
+ els.forEach((el) => {
773
+ const name = el.getAttribute("name") ?? "";
774
+ const occ = counts.get(name) ?? 0;
775
+ counts.set(name, occ + 1);
776
+ const Comp = registry[name];
777
+ if (!Comp) {
778
+ if (typeof process === "undefined" || false) {
779
+ console.warn(`[fluixi] island "${name}" has no component in the registry, left static.`);
780
+ }
781
+ return;
782
+ }
783
+ let props = {};
784
+ try {
785
+ props = JSON.parse(el.getAttribute("props") || "{}");
786
+ } catch {
787
+ }
788
+ hydrate(() => Comp(props), el, { resourceNamespace: `${name}#${occ}` });
789
+ });
790
+ }