@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,685 @@
1
- "use strict";var P=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var ne=(n,e)=>{for(var t in e)P(n,t,{get:e[t],enumerable:!0})},te=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of Z(e))!ee.call(n,c)&&c!==t&&P(n,c,{get:()=>e[c],enumerable:!(i=Q(e,c))||i.enumerable});return n};var oe=n=>te(P({},"__esModule",{value:!0}),n);var xe={};ne(xe,{hydrate:()=>he});module.exports=oe(xe);var x=require("@fluixi/reactive/signal");var $="1.0.0-alpha.83";var O=require("@fluixi/reactive/version"),h={dom:$,reactive:O.VERSION};function H(n){h.core&&n.setAttribute("fluixi",h.core),n.setAttribute("fx-dom",h.dom),n.setAttribute("fx-reactive",h.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=h)}function F(){let n=[h.core,h.dom,h.reactive].filter(e=>e!==void 0);new Set(n).size<=1||console.warn(`[fluixi] package versions disagree — core ${h.core??"(absent)"}, dom ${h.dom}, reactive ${h.reactive}. These ship as one release, so a mismatch usually means a stale lockfile or two copies resolved side by side. Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`)}function E(n){return typeof n=="function"&&n[Symbol.for("fluixi-component")]===!0}var p=require("@fluixi/reactive/signal");var j=Symbol.for("fluixi.server-node"),re=Symbol.for("fluixi.dom.server-host"),ie=globalThis,R=ie[re]??={server:typeof document>"u",nodes:null};function V(){return R.server}function I(){if(!R.nodes)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return R.nodes}function L(n){return n!=null&&n[j]===!0?!0:typeof Node<"u"&&n instanceof Node}function W(n){return n!=null&&n[j]===!0?n.nodeType===3:typeof Text<"u"&&n instanceof Text}var u={active:!1,cursor:null,parents:[]},K=null;function B(n){K=n}function q(){return K}function M(n,e){return u.active&&e.parentNode===n}function X(n){let e=u.parents.lastIndexOf(n);e!==-1&&(u.parents.length=e),u.cursor=n.nextSibling}function N(n,e=!1){if(V())return I().createText(n);if(u.active&&!e){let t=q()?.hydrateText(n);if(t)return t}return document.createTextNode(n)}var b=0,se=200;function fe(n,e,t,i,c){let f=i,s=new Map;return(0,p.createRenderEffect)(()=>{(0,p.reportReactiveBinding)(t??e,"content",void 0,n);let r;if(E(n)&&!(0,x.isSignal)(n)){if(!s.has(n)){b++;try{let o=n();s.set(n,o)}finally{b--}}for(r=s.get(n);typeof r=="function"&&(0,x.isSignal)(r);)r=r()}else for(r=n();typeof r=="function"&&(0,x.isSignal)(r);)r=r();{let o=0;for(;typeof r=="function"&&o++<50;)if(E(r)){if(!s.has(r)){let a=r;b++;try{let l=a();s.set(a,l)}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)&&!E(r))break}b++;try{f=S(e,r,t,f,s),c(f)}finally{b--}})}function J(n,e,t,i){if(b>se)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=N("",!0),n.appendChild(t));let c=i??null,f=o=>Array.isArray(o)&&o.some(a=>typeof a=="function"),s=o=>typeof o=="function"?o:()=>o;if(typeof e!="function"&&!f(e)){b++;try{c=S(n,e,t,c)}finally{b--}return()=>c}let r=fe(s(e),n,t,c,o=>{c=o});return()=>(r?.(),c)}function S(n,e,t,i,c){if(e==null||typeof e=="boolean")return T(n,i,t);if(typeof e=="function")for(;typeof e=="function";)e=e();if(e==null||typeof e=="boolean")return T(n,i,t);if(w(e)){let s=N("",!0);return Array.isArray(i)?i.length>0?(n.replaceChild(s,i[0]),T(n,i.slice(1),t)):g(n,s,t):i?n.replaceChild(s,i):g(n,s,t),e.then(r=>{s.parentNode===n&&S(n,r,s.nextSibling,s)}).catch(r=>{console.error("Error resolving promise in insertExpression:",r)}),s}let f=typeof e;if(f==="string"||f==="number"){if(f==="number"&&(e=String(e)),Array.isArray(i)){if(i.length===0){let r=N(e);return g(n,r,t),r}if(i.length===1&&i[0].nodeType===3)return i[0].data=e,i;i=T(n,i,t)}if(i&&W(i))return i.data=e,i;let s=N(e);return i&&i.parentNode===n?n.replaceChild(s,i):M(n,s)||g(n,s,t),s}if(L(e))return M(n,e)?(X(e),e):Array.isArray(i)?(i.length===0?g(n,e,t):i[0].parentNode===n?(n.replaceChild(e,i[0]),T(n,i.slice(1),t)):g(n,e,t),e):(i?i!==e&&(i.parentNode===n?n.replaceChild(e,i):g(n,e,t)):g(n,e,t),e);if(Array.isArray(e)){let s=[],r=Array.isArray(i)?i:i?[i]:[],o=[];m(e,s,n,t,!0,c,o);let a=ae(n,r,s,t);for(let l of o){let d=J(n,l.sig,l.marker);(0,p.onCleanup)(()=>{T(n,d()),l.marker.parentNode===n&&n.removeChild(l.marker)})}return a}if(f==="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 o=r.type(r.props||{});return S(n,o,t,i)}}}return T(n,i,t)}function m(n,e,t,i,c=!0,f,s){for(let r=0;r<n.length;r++){let o=n[r];if(!(o==null||typeof o=="boolean")){for(;typeof o=="function"&&!w(o)&&!(0,x.isSignal)(o)&&!E(o)&&(o=o(),!(o==null||typeof o=="boolean")););if(!(o==null||typeof o=="boolean")){if(typeof o=="function"){let a;for(E(o)&&!(0,x.isSignal)(o)?(f||(f=new Map),f.has(o)||f.set(o,o()),a=f.get(o)):a=o();typeof a=="function"&&!w(a)&&!(0,x.isSignal)(a)&&!E(a);)f||(f=new Map),f.has(a)||f.set(a,a()),a=f.get(a);if(a==null||typeof a=="boolean")continue;if(typeof a=="function"){if((0,x.isSignal)(a)){if(s){let d=N("",!0);e.push(d),s.push({marker:d,sig:a});continue}let l=a();for(;typeof l=="function"&&(0,x.isSignal)(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?m(l,e,t,i,c,f):m([l],e,t,i,c,f);continue}continue}Array.isArray(a)?m(a,e,t,i,c,f,s):m([a],e,t,i,c,f,s);continue}if(w(o)){let a=N("",!0);e.push(a),o.then(l=>{if(a.parentNode){let d=[];if(m([l],d,a.parentNode,void 0,!1,f),d.length>0){a.parentNode.replaceChild(d[0],a);for(let y=1;y<d.length;y++)a.parentNode?.insertBefore(d[y],d[y-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(o)){m(o,e,t,i,c,f,s);continue}if(L(o)){e.push(o);continue}if(typeof o=="object"&&o!==null&&"type"in o&&"props"in o){let a=o;if(typeof a.type=="function"){let l=a.type(a.props||{});Array.isArray(l)?m(l,e,t,i,!1,f):m([l],e,t,i,!1,f);continue}}if(typeof o=="string"||typeof o=="number"){let a=String(o);if(a.trim()===""&&a!==" ")continue;e.push(N(a));continue}e.push(N(String(o)))}}}}function ae(n,e,t,i){for(let d=0;d<t.length;d++){let y=t[d].parentNode;y!==null&&y!==n&&y.nodeType!==11&&(t=t.slice(),t[d]=t[d].cloneNode(!0))}let c=t.length,f=e.length,s=c,r=0,o=0,a=f>0?e[f-1].nextSibling??void 0:i,l=null;for(;r<f||o<s;){if(e[r]===t[o]){r++,o++;continue}for(;f>r&&s>o&&e[f-1]===t[s-1];)f--,s--;if(f===r){let d=s<c?o?t[o-1].nextSibling??void 0:t[s-o]:a;for(;o<s;)g(n,t[o++],d)}else if(s===o)for(;r<f;)(!l||!l.has(e[r]))&&e[r].parentNode===n&&n.removeChild(e[r]),r++;else if(e[r]===t[s-1]&&t[o]===e[f-1]){let d=e[--f].nextSibling;g(n,t[o++],e[r++].nextSibling),g(n,t[--s],d),e[f]=e[r-1]}else{if(!l){l=new Map;let y=o;for(;y<s;)l.set(t[y],y++)}let d=l.get(e[r]);if(d!=null)if(o<d&&d<s){let y=r,_=1;for(;++y<f&&y<s&&!(!l.has(e[y])||l.get(e[y])!==d+_);)_++;if(_>d-o){let Y=e[r];for(;o<d;)g(n,t[o++],Y)}else e[r].parentNode===n?n.replaceChild(t[o++],e[r++]):(g(n,t[o++],a),r++)}else r++;else e[r].parentNode===n&&n.removeChild(e[r]),r++}}return t}function T(n,e,t){if(e)if(Array.isArray(e))for(let i=0;i<e.length;i++)e[i].parentNode===n&&n.removeChild(e[i]);else e.parentNode===n&&n.removeChild(e);return null}function g(n,e,t){u.active&&e.parentNode===n||(t&&t.parentNode===n?n.insertBefore(e,t):n.appendChild(e))}function w(n){return n!=null&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"||n instanceof Promise}function G(n,e,t){if(!e)throw new Error("Container element is required");let i,c,f=[];return(0,p.createRoot)(s=>{(0,p.batch)(()=>{u.active||(e.textContent=""),H(e),F(),J(e,n)}),c=s}),()=>{c?.(),i?.(),f.forEach(s=>s()),e.textContent=""}}var v=require("@fluixi/reactive/signal");var ue="__FX_DATA__";var D;function U(){let n=globalThis.__FX_DATA__;if(n)return n;if(D!==void 0)return D;let e=null;if(typeof document<"u"){let t=document.getElementById(ue)?.textContent;if(t)try{e=JSON.parse(t)}catch{e=null}}return D=e}function A(){for(;;){for(;u.cursor&&u.cursor.nodeType===3&&u.cursor.data==="";)u.cursor=u.cursor.nextSibling;if(u.cursor!=null||!u.parents.length)return;u.cursor=u.parents.pop().nextSibling}}var le=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),k=typeof process<"u"&&process.env&&!1;function C(n,e){let t=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 ${n} but the server DOM has ${t}. 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 ce(n){A();let e=u.cursor;return e&&e.nodeType===1&&e.tagName.toLowerCase()===n.toLowerCase()?(le.has(n.toLowerCase())?u.cursor=e.nextSibling:(u.parents.push(e),u.cursor=e.firstChild),e):(k&&e&&C(`<${n}>`,e),null)}function de(n){A();let e=u.cursor;return e&&e.nodeType===1&&e.tagName.toLowerCase()===n.toLowerCase()?(u.cursor=e.nextSibling,e):(k&&e&&C(`<${n}> (static)`,e),null)}function ye(n){if(n===""){let t=u.cursor;return t&&t.nodeType===3&&t.data!==""?(u.cursor=t.nextSibling,t.data="",t):null}A();let e=u.cursor;return e&&e.nodeType===3?(u.cursor=e.nextSibling,e.nodeValue!==n&&(e.nodeValue=n),e):(k&&e&&C(`text ${JSON.stringify(n.slice(0,24))}`,e),null)}function pe(n){A();let e=u.cursor;return e&&e.nodeType===8&&e.data===n?(u.cursor=e.nextSibling,e):(k&&e&&C(`marker <!--${n.slice(0,24)}-->`,e),null)}var z=!1;function ge(){z||(z=!0,B({hydrateElement:ce,hydrateText:ye,hydrateMarker:pe,hydrateStatic:de}))}function he(n,e,t){ge(),u.active=!0,u.cursor=e.firstChild,u.parents=[];let i=U(),c=t?.resourceNamespace,f=0;(0,v.setResourceIdSource)(()=>c?`${c}:r${f++}`:`r${f++}`),(0,v.setServerDataGetter)(i?s=>s in i?{value:i[s]}:void 0:null);try{return G(n,e)}finally{u.active=!1,u.cursor=null,u.parents=[]}}
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/hydration.ts
21
+ var hydration_exports = {};
22
+ __export(hydration_exports, {
23
+ hydrate: () => hydrate
24
+ });
25
+ module.exports = __toCommonJS(hydration_exports);
26
+
27
+ // src/lib/dom/runtime.ts
28
+ var import_signal2 = require("@fluixi/reactive/signal");
29
+
30
+ // src/version.generated.ts
31
+ var VERSION = "1.0.0-alpha.85";
32
+
33
+ // src/lib/dom/versions.ts
34
+ var import_version = require("@fluixi/reactive/version");
35
+ var import_signal = require("@fluixi/reactive/signal");
36
+ var versions = { dom: VERSION, reactive: import_version.VERSION };
37
+ function stampVersions(container) {
38
+ if (versions.core) container.setAttribute("fluixi", versions.core);
39
+ container.setAttribute("fx-dom", versions.dom);
40
+ container.setAttribute("fx-reactive", versions.reactive);
41
+ if (typeof globalThis !== "undefined") globalThis.Fluixi = versions;
42
+ }
43
+ function warnOnVersionSkew() {
44
+ const builds = (0, import_signal.joinedVersions)();
45
+ if (builds.length > 1) {
46
+ console.warn(
47
+ `[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.`
48
+ );
49
+ }
50
+ const present = [versions.core, versions.dom, versions.reactive].filter(
51
+ (v) => v !== void 0
52
+ );
53
+ if (new Set(present).size <= 1) return;
54
+ console.warn(
55
+ `[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\`.`
56
+ );
57
+ }
58
+
59
+ // src/lib/component/modifiers.ts
60
+ function isComponent(value) {
61
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
62
+ }
63
+
64
+ // src/lib/dom/runtime.ts
65
+ var import_signal3 = require("@fluixi/reactive/signal");
66
+
67
+ // src/lib/dom/server/host.ts
68
+ var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
69
+ var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
70
+ var realm = globalThis;
71
+ var state = realm[STATE] ??= {
72
+ server: typeof document === "undefined",
73
+ nodes: null
74
+ };
75
+ function isServer() {
76
+ return state.server;
77
+ }
78
+ function getServerNodes() {
79
+ if (!state.nodes) {
80
+ throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
81
+ }
82
+ return state.nodes;
83
+ }
84
+ function isDomNode(x) {
85
+ if (x != null && x[SERVER_NODE] === true) return true;
86
+ return typeof Node !== "undefined" && x instanceof Node;
87
+ }
88
+ function isDomText(x) {
89
+ if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
90
+ return typeof Text !== "undefined" && x instanceof Text;
91
+ }
92
+
93
+ // src/lib/dom/hydration-state.ts
94
+ var hydration = {
95
+ active: false,
96
+ cursor: null,
97
+ parents: []
98
+ };
99
+ var _walker = null;
100
+ function registerHydrationWalker(walker) {
101
+ _walker = walker;
102
+ }
103
+ function getHydrationWalker() {
104
+ return _walker;
105
+ }
106
+ function isAdopted(parent, node) {
107
+ return hydration.active && node.parentNode === parent;
108
+ }
109
+ function ascendPast(node) {
110
+ const idx = hydration.parents.lastIndexOf(node);
111
+ if (idx !== -1) hydration.parents.length = idx;
112
+ hydration.cursor = node.nextSibling;
113
+ }
114
+
115
+ // src/lib/dom/runtime.ts
116
+ function createTextNode(value, anchor = false) {
117
+ if (isServer()) return getServerNodes().createText(value);
118
+ if (hydration.active && !anchor) {
119
+ const node = getHydrationWalker()?.hydrateText(value);
120
+ if (node) return node;
121
+ }
122
+ return document.createTextNode(value);
123
+ }
124
+ var _insertDepth = 0;
125
+ var MAX_INSERT_DEPTH = 200;
126
+ function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
127
+ let current = initialCurrent;
128
+ const componentCache = /* @__PURE__ */ new Map();
129
+ return (0, import_signal3.createRenderEffect)(() => {
130
+ (0, import_signal3.reportReactiveBinding)(marker ?? parent, "content", void 0, getAccessor);
131
+ let value;
132
+ if (isComponent(getAccessor) && !(0, import_signal2.isSignal)(getAccessor)) {
133
+ if (!componentCache.has(getAccessor)) {
134
+ _insertDepth++;
135
+ try {
136
+ const inst = getAccessor();
137
+ componentCache.set(getAccessor, inst);
138
+ } finally {
139
+ _insertDepth--;
140
+ }
141
+ }
142
+ value = componentCache.get(getAccessor);
143
+ while (typeof value === "function" && (0, import_signal2.isSignal)(value)) value = value();
144
+ } else {
145
+ value = getAccessor();
146
+ while (typeof value === "function" && (0, import_signal2.isSignal)(value)) {
147
+ value = value();
148
+ }
149
+ }
150
+ {
151
+ let chainDepth = 0;
152
+ while (typeof value === "function" && chainDepth++ < 50) {
153
+ if (isComponent(value)) {
154
+ if (!componentCache.has(value)) {
155
+ const thunk = value;
156
+ _insertDepth++;
157
+ try {
158
+ const inst = thunk();
159
+ componentCache.set(thunk, inst);
160
+ } finally {
161
+ _insertDepth--;
162
+ }
163
+ }
164
+ value = componentCache.get(value);
165
+ } else if ((0, import_signal2.isSignal)(value)) {
166
+ value = value();
167
+ } else {
168
+ value = value();
169
+ if (typeof value !== "function" || !(0, import_signal2.isSignal)(value) && !isComponent(value)) break;
170
+ }
171
+ }
172
+ }
173
+ _insertDepth++;
174
+ try {
175
+ current = insertExpression(parent, value, marker, current, componentCache);
176
+ setCurrent(current);
177
+ } finally {
178
+ _insertDepth--;
179
+ }
180
+ });
181
+ }
182
+ function insert(parent, accessor, marker, init) {
183
+ if (_insertDepth > MAX_INSERT_DEPTH) {
184
+ console.error("[insert] Exceeded max call depth, possible infinite loop.");
185
+ return () => null;
186
+ }
187
+ if (marker !== void 0 && !marker) {
188
+ marker = createTextNode("", true);
189
+ parent.appendChild(marker);
190
+ }
191
+ let current = init ?? null;
192
+ const isReactiveArray = (element) => {
193
+ return Array.isArray(element) && element.some((v) => typeof v === "function");
194
+ };
195
+ const normalizeAccessor = (accessor2) => {
196
+ if (typeof accessor2 === "function") return accessor2;
197
+ return () => accessor2;
198
+ };
199
+ if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
200
+ _insertDepth++;
201
+ try {
202
+ current = insertExpression(parent, accessor, marker, current);
203
+ } finally {
204
+ _insertDepth--;
205
+ }
206
+ return () => current;
207
+ }
208
+ const dispose = _createInsertEffect(
209
+ normalizeAccessor(accessor),
210
+ parent,
211
+ marker,
212
+ current,
213
+ (v) => {
214
+ current = v;
215
+ }
216
+ );
217
+ return () => {
218
+ dispose?.();
219
+ return current;
220
+ };
221
+ }
222
+ function insertExpression(parent, value, marker, current, componentCache) {
223
+ if (value == null || typeof value === "boolean") {
224
+ return cleanChildren(parent, current, marker);
225
+ }
226
+ if (typeof value === "function") {
227
+ while (typeof value === "function") {
228
+ value = value();
229
+ }
230
+ }
231
+ if (value == null || typeof value === "boolean") {
232
+ return cleanChildren(parent, current, marker);
233
+ }
234
+ if (isPromise(value)) {
235
+ const placeholder = createTextNode("", true);
236
+ if (Array.isArray(current)) {
237
+ if (current.length > 0) {
238
+ parent.replaceChild(placeholder, current[0]);
239
+ cleanChildren(parent, current.slice(1), marker);
240
+ } else {
241
+ insertBefore(parent, placeholder, marker);
242
+ }
243
+ } else if (current) {
244
+ parent.replaceChild(placeholder, current);
245
+ } else {
246
+ insertBefore(parent, placeholder, marker);
247
+ }
248
+ value.then((resolved) => {
249
+ if (placeholder.parentNode === parent) {
250
+ insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
251
+ }
252
+ }).catch((err) => {
253
+ console.error("Error resolving promise in insertExpression:", err);
254
+ });
255
+ return placeholder;
256
+ }
257
+ const t = typeof value;
258
+ if (t === "string" || t === "number") {
259
+ if (t === "number") value = String(value);
260
+ if (Array.isArray(current)) {
261
+ if (current.length === 0) {
262
+ const node2 = createTextNode(value);
263
+ insertBefore(parent, node2, marker);
264
+ return node2;
265
+ }
266
+ if (current.length === 1 && current[0].nodeType === 3) {
267
+ current[0].data = value;
268
+ return current;
269
+ }
270
+ current = cleanChildren(parent, current, marker);
271
+ }
272
+ if (current && isDomText(current)) {
273
+ current.data = value;
274
+ return current;
275
+ }
276
+ const node = createTextNode(value);
277
+ if (current && current.parentNode === parent) {
278
+ parent.replaceChild(node, current);
279
+ } else if (!isAdopted(parent, node)) {
280
+ insertBefore(parent, node, marker);
281
+ }
282
+ return node;
283
+ }
284
+ if (isDomNode(value)) {
285
+ if (isAdopted(parent, value)) {
286
+ ascendPast(value);
287
+ return value;
288
+ }
289
+ if (Array.isArray(current)) {
290
+ if (current.length === 0) {
291
+ insertBefore(parent, value, marker);
292
+ } else if (current[0].parentNode === parent) {
293
+ parent.replaceChild(value, current[0]);
294
+ cleanChildren(parent, current.slice(1), marker);
295
+ } else {
296
+ insertBefore(parent, value, marker);
297
+ }
298
+ return value;
299
+ }
300
+ if (!current) {
301
+ insertBefore(parent, value, marker);
302
+ } else if (current !== value) {
303
+ if (current.parentNode === parent) {
304
+ parent.replaceChild(value, current);
305
+ } else {
306
+ insertBefore(parent, value, marker);
307
+ }
308
+ }
309
+ return value;
310
+ }
311
+ if (Array.isArray(value)) {
312
+ const array = [];
313
+ const currentArray = Array.isArray(current) ? current : current ? [current] : [];
314
+ const reactiveSlots = [];
315
+ flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
316
+ const reconciled = reconcileArrays(parent, currentArray, array, marker);
317
+ for (const slot of reactiveSlots) {
318
+ const disposeSlot = insert(parent, slot.sig, slot.marker);
319
+ (0, import_signal3.onCleanup)(() => {
320
+ cleanChildren(parent, disposeSlot());
321
+ if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
322
+ });
323
+ }
324
+ return reconciled;
325
+ }
326
+ if (t === "object" && value !== null && typeof value === "object") {
327
+ const objValue = value;
328
+ if ("type" in objValue && "props" in objValue) {
329
+ const jsxValue = objValue;
330
+ if (typeof jsxValue.type === "function") {
331
+ const result = jsxValue.type(jsxValue.props || {});
332
+ return insertExpression(parent, result, marker, current);
333
+ }
334
+ }
335
+ }
336
+ return cleanChildren(parent, current, marker);
337
+ }
338
+ function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
339
+ for (let i = 0; i < arr.length; i++) {
340
+ let item = arr[i];
341
+ if (item == null || typeof item === "boolean") continue;
342
+ while (typeof item === "function" && !isPromise(item) && !(0, import_signal2.isSignal)(item) && !isComponent(item)) {
343
+ item = item();
344
+ if (item == null || typeof item === "boolean") break;
345
+ }
346
+ if (item == null || typeof item === "boolean") continue;
347
+ if (typeof item === "function") {
348
+ let resolved;
349
+ if (isComponent(item) && !(0, import_signal2.isSignal)(item)) {
350
+ if (!componentCache) componentCache = /* @__PURE__ */ new Map();
351
+ if (!componentCache.has(item)) componentCache.set(item, item());
352
+ resolved = componentCache.get(item);
353
+ } else {
354
+ resolved = item();
355
+ }
356
+ while (typeof resolved === "function" && !isPromise(resolved) && !(0, import_signal2.isSignal)(resolved) && !isComponent(resolved)) {
357
+ if (!componentCache) componentCache = /* @__PURE__ */ new Map();
358
+ if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
359
+ resolved = componentCache.get(resolved);
360
+ }
361
+ if (resolved == null || typeof resolved === "boolean") continue;
362
+ if (typeof resolved === "function") {
363
+ if ((0, import_signal2.isSignal)(resolved)) {
364
+ if (reactiveSlots) {
365
+ const slot = createTextNode("", true);
366
+ result.push(slot);
367
+ reactiveSlots.push({ marker: slot, sig: resolved });
368
+ continue;
369
+ }
370
+ let val = resolved();
371
+ while (typeof val === "function" && (0, import_signal2.isSignal)(val)) val = val();
372
+ if (val == null || typeof val === "boolean") continue;
373
+ if (Array.isArray(val)) {
374
+ flattenArray(val, result, parent, marker, track, componentCache);
375
+ } else flattenArray([val], result, parent, marker, track, componentCache);
376
+ continue;
377
+ }
378
+ continue;
379
+ }
380
+ if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
381
+ else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
382
+ continue;
383
+ }
384
+ if (isPromise(item)) {
385
+ const placeholder = createTextNode("", true);
386
+ result.push(placeholder);
387
+ item.then((resolved) => {
388
+ if (placeholder.parentNode) {
389
+ const tempNodes = [];
390
+ flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
391
+ if (tempNodes.length > 0) {
392
+ placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
393
+ for (let j = 1; j < tempNodes.length; j++) {
394
+ placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
395
+ }
396
+ }
397
+ }
398
+ }).catch((err) => console.error("Error resolving promise in array:", err));
399
+ continue;
400
+ }
401
+ if (Array.isArray(item)) {
402
+ flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
403
+ continue;
404
+ }
405
+ if (isDomNode(item)) {
406
+ result.push(item);
407
+ continue;
408
+ }
409
+ if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
410
+ const jsxItem = item;
411
+ if (typeof jsxItem.type === "function") {
412
+ const resolved = jsxItem.type(jsxItem.props || {});
413
+ if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
414
+ else flattenArray([resolved], result, parent, marker, false, componentCache);
415
+ continue;
416
+ }
417
+ }
418
+ if (typeof item === "string" || typeof item === "number") {
419
+ const str = String(item);
420
+ if (str.trim() === "" && str !== " ") continue;
421
+ result.push(createTextNode(str));
422
+ continue;
423
+ }
424
+ result.push(createTextNode(String(item)));
425
+ }
426
+ }
427
+ function reconcileArrays(parent, a, b, marker) {
428
+ for (let i = 0; i < b.length; i++) {
429
+ const owner = b[i].parentNode;
430
+ if (owner !== null && owner !== parent && owner.nodeType !== 11) {
431
+ b = b.slice();
432
+ b[i] = b[i].cloneNode(true);
433
+ }
434
+ }
435
+ 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;
436
+ while (aStart < aEnd || bStart < bEnd) {
437
+ if (a[aStart] === b[bStart]) {
438
+ aStart++;
439
+ bStart++;
440
+ continue;
441
+ }
442
+ while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
443
+ aEnd--;
444
+ bEnd--;
445
+ }
446
+ if (aEnd === aStart) {
447
+ const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
448
+ while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
449
+ } else if (bEnd === bStart) {
450
+ while (aStart < aEnd) {
451
+ if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
452
+ parent.removeChild(a[aStart]);
453
+ aStart++;
454
+ }
455
+ } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
456
+ const node = a[--aEnd].nextSibling;
457
+ insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
458
+ insertBefore(parent, b[--bEnd], node);
459
+ a[aEnd] = a[aStart - 1];
460
+ } else {
461
+ if (!map) {
462
+ map = /* @__PURE__ */ new Map();
463
+ let i = bStart;
464
+ while (i < bEnd) map.set(b[i], i++);
465
+ }
466
+ const index = map.get(a[aStart]);
467
+ if (index != null) {
468
+ if (bStart < index && index < bEnd) {
469
+ let i = aStart, sequence = 1;
470
+ while (++i < aEnd && i < bEnd) {
471
+ if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
472
+ sequence++;
473
+ }
474
+ if (sequence > index - bStart) {
475
+ const node = a[aStart];
476
+ while (bStart < index) insertBefore(parent, b[bStart++], node);
477
+ } else {
478
+ if (a[aStart].parentNode === parent) {
479
+ parent.replaceChild(b[bStart++], a[aStart++]);
480
+ } else {
481
+ insertBefore(parent, b[bStart++], after);
482
+ aStart++;
483
+ }
484
+ }
485
+ } else {
486
+ aStart++;
487
+ }
488
+ } else {
489
+ if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
490
+ aStart++;
491
+ }
492
+ }
493
+ }
494
+ return b;
495
+ }
496
+ function cleanChildren(parent, current, marker) {
497
+ if (current) {
498
+ if (Array.isArray(current)) {
499
+ for (let i = 0; i < current.length; i++) {
500
+ if (current[i].parentNode === parent) parent.removeChild(current[i]);
501
+ }
502
+ } else if (current.parentNode === parent) {
503
+ parent.removeChild(current);
504
+ }
505
+ }
506
+ return null;
507
+ }
508
+ function insertBefore(parent, node, marker) {
509
+ if (hydration.active && node.parentNode === parent) return;
510
+ if (marker) {
511
+ if (marker.parentNode === parent) {
512
+ parent.insertBefore(node, marker);
513
+ } else {
514
+ parent.appendChild(node);
515
+ }
516
+ } else {
517
+ parent.appendChild(node);
518
+ }
519
+ }
520
+ function isPromise(v) {
521
+ return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
522
+ }
523
+ function render(element, container, context) {
524
+ if (!container) {
525
+ throw new Error("Container element is required");
526
+ }
527
+ let rendererDispose;
528
+ let disposeRoot;
529
+ const disposers = [];
530
+ (0, import_signal3.createRoot)((dispose) => {
531
+ (0, import_signal3.batch)(() => {
532
+ if (!hydration.active) {
533
+ container.textContent = "";
534
+ }
535
+ stampVersions(container);
536
+ warnOnVersionSkew();
537
+ insert(container, element);
538
+ return;
539
+ });
540
+ disposeRoot = dispose;
541
+ });
542
+ return () => {
543
+ disposeRoot?.();
544
+ rendererDispose?.();
545
+ disposers.forEach((d) => d());
546
+ container.textContent = "";
547
+ };
548
+ }
549
+
550
+ // src/lib/dom/hydration.ts
551
+ var import_signal4 = require("@fluixi/reactive/signal");
552
+
553
+ // src/lib/dom/server/fx-data.ts
554
+ var FX_DATA_ID = "__FX_DATA__";
555
+ var _scriptCache;
556
+ function getServerData() {
557
+ const g = globalThis.__FX_DATA__;
558
+ if (g) return g;
559
+ if (_scriptCache !== void 0) return _scriptCache;
560
+ let parsed = null;
561
+ if (typeof document !== "undefined") {
562
+ const text = document.getElementById(FX_DATA_ID)?.textContent;
563
+ if (text) {
564
+ try {
565
+ parsed = JSON.parse(text);
566
+ } catch {
567
+ parsed = null;
568
+ }
569
+ }
570
+ }
571
+ return _scriptCache = parsed;
572
+ }
573
+
574
+ // src/lib/dom/hydration.ts
575
+ function recoverCursor() {
576
+ for (; ; ) {
577
+ while (hydration.cursor && hydration.cursor.nodeType === 3 && hydration.cursor.data === "") {
578
+ hydration.cursor = hydration.cursor.nextSibling;
579
+ }
580
+ if (hydration.cursor != null || !hydration.parents.length) return;
581
+ hydration.cursor = hydration.parents.pop().nextSibling;
582
+ }
583
+ }
584
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
585
+ "area",
586
+ "base",
587
+ "br",
588
+ "col",
589
+ "embed",
590
+ "hr",
591
+ "img",
592
+ "input",
593
+ "link",
594
+ "meta",
595
+ "param",
596
+ "source",
597
+ "track",
598
+ "wbr"
599
+ ]);
600
+ var DEV = typeof process !== "undefined" && process.env && false;
601
+ function warnMismatch(expected, found) {
602
+ const f = found.nodeType === 1 ? `<${found.tagName.toLowerCase()}>` : found.nodeType === 3 ? `text ${JSON.stringify((found.nodeValue ?? "").slice(0, 24))}` : found.nodeType === 8 ? "comment" : "node";
603
+ console.warn(
604
+ `[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).`
605
+ );
606
+ }
607
+ function hydrateElement(tag) {
608
+ recoverCursor();
609
+ const c = hydration.cursor;
610
+ if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
611
+ if (VOID_ELEMENTS.has(tag.toLowerCase())) {
612
+ hydration.cursor = c.nextSibling;
613
+ } else {
614
+ hydration.parents.push(c);
615
+ hydration.cursor = c.firstChild;
616
+ }
617
+ return c;
618
+ }
619
+ if (DEV && c) warnMismatch(`<${tag}>`, c);
620
+ return null;
621
+ }
622
+ function hydrateStatic(tag) {
623
+ recoverCursor();
624
+ const c = hydration.cursor;
625
+ if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
626
+ hydration.cursor = c.nextSibling;
627
+ return c;
628
+ }
629
+ if (DEV && c) warnMismatch(`<${tag}> (static)`, c);
630
+ return null;
631
+ }
632
+ function hydrateText(value) {
633
+ if (value === "") {
634
+ const c2 = hydration.cursor;
635
+ if (c2 && c2.nodeType === 3 && c2.data !== "") {
636
+ hydration.cursor = c2.nextSibling;
637
+ c2.data = "";
638
+ return c2;
639
+ }
640
+ return null;
641
+ }
642
+ recoverCursor();
643
+ const c = hydration.cursor;
644
+ if (c && c.nodeType === 3) {
645
+ hydration.cursor = c.nextSibling;
646
+ if (c.nodeValue !== value) c.nodeValue = value;
647
+ return c;
648
+ }
649
+ if (DEV && c) warnMismatch(`text ${JSON.stringify(value.slice(0, 24))}`, c);
650
+ return null;
651
+ }
652
+ function hydrateMarker(value) {
653
+ recoverCursor();
654
+ const c = hydration.cursor;
655
+ if (c && c.nodeType === 8 && c.data === value) {
656
+ hydration.cursor = c.nextSibling;
657
+ return c;
658
+ }
659
+ if (DEV && c) warnMismatch(`marker <!--${value.slice(0, 24)}-->`, c);
660
+ return null;
661
+ }
662
+ var _walkerRegistered = false;
663
+ function ensureWalker() {
664
+ if (_walkerRegistered) return;
665
+ _walkerRegistered = true;
666
+ registerHydrationWalker({ hydrateElement, hydrateText, hydrateMarker, hydrateStatic });
667
+ }
668
+ function hydrate(element, container, options) {
669
+ ensureWalker();
670
+ hydration.active = true;
671
+ hydration.cursor = container.firstChild;
672
+ hydration.parents = [];
673
+ const data = getServerData();
674
+ const ns = options?.resourceNamespace;
675
+ let rid = 0;
676
+ (0, import_signal4.setResourceIdSource)(() => ns ? `${ns}:r${rid++}` : `r${rid++}`);
677
+ (0, import_signal4.setServerDataGetter)(data ? (id) => id in data ? { value: data[id] } : void 0 : null);
678
+ try {
679
+ return render(element, container);
680
+ } finally {
681
+ hydration.active = false;
682
+ hydration.cursor = null;
683
+ hydration.parents = [];
684
+ }
685
+ }