@fluixi/dom 1.0.0-alpha.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +657 -0
- package/dist/cdn/dom.cjs +1 -0
- package/dist/cdn/dom.d.ts +16 -0
- package/dist/cdn/dom.d.ts.map +1 -0
- package/dist/cdn/dom.global.js +1 -0
- package/dist/cdn/dom.js +15 -0
- package/dist/cdn/dom.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.mjs +1 -0
- package/dist/lib/component/index.cjs +1 -0
- package/dist/lib/component/index.d.ts +2 -0
- package/dist/lib/component/index.d.ts.map +1 -0
- package/dist/lib/component/index.js +1 -0
- package/dist/lib/component/index.mjs +1 -0
- package/dist/lib/component/modifiers.cjs +1 -0
- package/dist/lib/component/modifiers.d.ts +21 -0
- package/dist/lib/component/modifiers.d.ts.map +1 -0
- package/dist/lib/component/modifiers.js +171 -0
- package/dist/lib/component/modifiers.mjs +1 -0
- package/dist/lib/dom/delegate.cjs +1 -0
- package/dist/lib/dom/delegate.d.ts +17 -0
- package/dist/lib/dom/delegate.d.ts.map +1 -0
- package/dist/lib/dom/delegate.js +50 -0
- package/dist/lib/dom/delegate.mjs +1 -0
- package/dist/lib/dom/hydration-state.cjs +1 -0
- package/dist/lib/dom/hydration-state.d.ts +45 -0
- package/dist/lib/dom/hydration-state.d.ts.map +1 -0
- package/dist/lib/dom/hydration-state.js +94 -0
- package/dist/lib/dom/hydration-state.mjs +1 -0
- package/dist/lib/dom/hydration.cjs +1 -0
- package/dist/lib/dom/hydration.d.ts +10 -0
- package/dist/lib/dom/hydration.d.ts.map +1 -0
- package/dist/lib/dom/hydration.js +143 -0
- package/dist/lib/dom/hydration.mjs +1 -0
- package/dist/lib/dom/index.cjs +1 -0
- package/dist/lib/dom/index.d.ts +9 -0
- package/dist/lib/dom/index.d.ts.map +1 -0
- package/dist/lib/dom/index.js +12 -0
- package/dist/lib/dom/index.mjs +1 -0
- package/dist/lib/dom/integration.cjs +1 -0
- package/dist/lib/dom/integration.d.ts +16 -0
- package/dist/lib/dom/integration.d.ts.map +1 -0
- package/dist/lib/dom/integration.js +25 -0
- package/dist/lib/dom/integration.mjs +1 -0
- package/dist/lib/dom/island.cjs +1 -0
- package/dist/lib/dom/island.d.ts +23 -0
- package/dist/lib/dom/island.d.ts.map +1 -0
- package/dist/lib/dom/island.js +100 -0
- package/dist/lib/dom/island.mjs +1 -0
- package/dist/lib/dom/runtime.cjs +1 -0
- package/dist/lib/dom/runtime.d.ts +131 -0
- package/dist/lib/dom/runtime.d.ts.map +1 -0
- package/dist/lib/dom/runtime.js +1425 -0
- package/dist/lib/dom/runtime.mjs +1 -0
- package/dist/lib/dom/server/fx-data.cjs +1 -0
- package/dist/lib/dom/server/fx-data.d.ts +36 -0
- package/dist/lib/dom/server/fx-data.d.ts.map +1 -0
- package/dist/lib/dom/server/fx-data.js +60 -0
- package/dist/lib/dom/server/fx-data.mjs +1 -0
- package/dist/lib/dom/server/host.cjs +1 -0
- package/dist/lib/dom/server/host.d.ts +14 -0
- package/dist/lib/dom/server/host.d.ts.map +1 -0
- package/dist/lib/dom/server/host.js +38 -0
- package/dist/lib/dom/server/host.mjs +1 -0
- package/dist/lib/dom/server/index.cjs +1 -0
- package/dist/lib/dom/server/index.d.ts +13 -0
- package/dist/lib/dom/server/index.d.ts.map +1 -0
- package/dist/lib/dom/server/index.js +12 -0
- package/dist/lib/dom/server/index.mjs +1 -0
- package/dist/lib/dom/server/nodes.cjs +1 -0
- package/dist/lib/dom/server/nodes.d.ts +105 -0
- package/dist/lib/dom/server/nodes.d.ts.map +1 -0
- package/dist/lib/dom/server/nodes.js +304 -0
- package/dist/lib/dom/server/nodes.mjs +1 -0
- package/dist/lib/dom/server/render.cjs +1 -0
- package/dist/lib/dom/server/render.d.ts +45 -0
- package/dist/lib/dom/server/render.d.ts.map +1 -0
- package/dist/lib/dom/server/render.js +174 -0
- package/dist/lib/dom/server/render.mjs +1 -0
- package/dist/lib/dom/server/request-context.cjs +1 -0
- package/dist/lib/dom/server/request-context.d.ts +85 -0
- package/dist/lib/dom/server/request-context.d.ts.map +1 -0
- package/dist/lib/dom/server/request-context.js +122 -0
- package/dist/lib/dom/server/request-context.mjs +1 -0
- package/dist/lib/dom/server/serialize.cjs +1 -0
- package/dist/lib/dom/server/serialize.d.ts +2 -0
- package/dist/lib/dom/server/serialize.d.ts.map +1 -0
- package/dist/lib/dom/server/serialize.js +98 -0
- package/dist/lib/dom/server/serialize.mjs +1 -0
- package/dist/lib/dom/server-renderer.cjs +1 -0
- package/dist/lib/dom/server-renderer.d.ts +2 -0
- package/dist/lib/dom/server-renderer.d.ts.map +1 -0
- package/dist/lib/dom/server-renderer.js +5 -0
- package/dist/lib/dom/server-renderer.mjs +1 -0
- package/dist/lib/dom/types.cjs +1 -0
- package/dist/lib/dom/types.d.ts +119 -0
- package/dist/lib/dom/types.d.ts.map +1 -0
- package/dist/lib/dom/types.js +1 -0
- package/dist/lib/dom/types.mjs +0 -0
- package/dist/lib/dom/utils.cjs +1 -0
- package/dist/lib/dom/utils.d.ts +411 -0
- package/dist/lib/dom/utils.d.ts.map +1 -0
- package/dist/lib/dom/utils.js +746 -0
- package/dist/lib/dom/utils.mjs +1 -0
- package/dist/lib/element/index.cjs +1 -0
- package/dist/lib/element/index.d.ts +2 -0
- package/dist/lib/element/index.d.ts.map +1 -0
- package/dist/lib/element/index.js +1 -0
- package/dist/lib/element/index.mjs +0 -0
- package/dist/lib/element/types.cjs +1 -0
- package/dist/lib/element/types.d.ts +129 -0
- package/dist/lib/element/types.d.ts.map +1 -0
- package/dist/lib/element/types.js +5 -0
- package/dist/lib/element/types.mjs +0 -0
- package/dist/lib/flow/class-map.cjs +1 -0
- package/dist/lib/flow/class-map.d.ts +40 -0
- package/dist/lib/flow/class-map.d.ts.map +1 -0
- package/dist/lib/flow/class-map.js +44 -0
- package/dist/lib/flow/class-map.mjs +1 -0
- package/dist/lib/flow/dynamic.cjs +1 -0
- package/dist/lib/flow/dynamic.d.ts +27 -0
- package/dist/lib/flow/dynamic.d.ts.map +1 -0
- package/dist/lib/flow/dynamic.js +30 -0
- package/dist/lib/flow/dynamic.mjs +1 -0
- package/dist/lib/flow/error-boundary.cjs +1 -0
- package/dist/lib/flow/error-boundary.d.ts +34 -0
- package/dist/lib/flow/error-boundary.d.ts.map +1 -0
- package/dist/lib/flow/error-boundary.js +49 -0
- package/dist/lib/flow/error-boundary.mjs +1 -0
- package/dist/lib/flow/for.cjs +1 -0
- package/dist/lib/flow/for.d.ts +64 -0
- package/dist/lib/flow/for.d.ts.map +1 -0
- package/dist/lib/flow/for.js +28 -0
- package/dist/lib/flow/for.mjs +1 -0
- package/dist/lib/flow/index-flow.cjs +1 -0
- package/dist/lib/flow/index-flow.d.ts +34 -0
- package/dist/lib/flow/index-flow.d.ts.map +1 -0
- package/dist/lib/flow/index-flow.js +27 -0
- package/dist/lib/flow/index-flow.mjs +1 -0
- package/dist/lib/flow/index.cjs +1 -0
- package/dist/lib/flow/index.d.ts +20 -0
- package/dist/lib/flow/index.d.ts.map +1 -0
- package/dist/lib/flow/index.js +11 -0
- package/dist/lib/flow/index.mjs +1 -0
- package/dist/lib/flow/portal.cjs +1 -0
- package/dist/lib/flow/portal.d.ts +30 -0
- package/dist/lib/flow/portal.d.ts.map +1 -0
- package/dist/lib/flow/portal.js +44 -0
- package/dist/lib/flow/portal.mjs +1 -0
- package/dist/lib/flow/show.cjs +1 -0
- package/dist/lib/flow/show.d.ts +35 -0
- package/dist/lib/flow/show.d.ts.map +1 -0
- package/dist/lib/flow/show.js +162 -0
- package/dist/lib/flow/show.mjs +1 -0
- package/dist/lib/flow/style-map.cjs +1 -0
- package/dist/lib/flow/style-map.d.ts +49 -0
- package/dist/lib/flow/style-map.d.ts.map +1 -0
- package/dist/lib/flow/style-map.js +58 -0
- package/dist/lib/flow/style-map.mjs +1 -0
- package/dist/lib/flow/switch.cjs +1 -0
- package/dist/lib/flow/switch.d.ts +63 -0
- package/dist/lib/flow/switch.d.ts.map +1 -0
- package/dist/lib/flow/switch.js +69 -0
- package/dist/lib/flow/switch.mjs +1 -0
- package/dist/lib/flow/utils.cjs +1 -0
- package/dist/lib/flow/utils.d.ts +19 -0
- package/dist/lib/flow/utils.d.ts.map +1 -0
- package/dist/lib/flow/utils.js +34 -0
- package/dist/lib/flow/utils.mjs +1 -0
- package/dist/lib/index.cjs +1 -0
- package/dist/lib/index.d.ts +21 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +30 -0
- package/dist/lib/index.mjs +1 -0
- package/dist/lib/jsx/control-flow/flow.cjs +1 -0
- package/dist/lib/jsx/control-flow/flow.d.ts +2 -0
- package/dist/lib/jsx/control-flow/flow.d.ts.map +1 -0
- package/dist/lib/jsx/control-flow/flow.js +627 -0
- package/dist/lib/jsx/control-flow/flow.mjs +0 -0
- package/dist/lib/jsx/control-flow/for-flow.cjs +1 -0
- package/dist/lib/jsx/control-flow/for-flow.d.ts +2 -0
- package/dist/lib/jsx/control-flow/for-flow.d.ts.map +1 -0
- package/dist/lib/jsx/control-flow/for-flow.js +1 -0
- package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
- package/dist/lib/shared/types.cjs +1 -0
- package/dist/lib/shared/types.d.ts +47 -0
- package/dist/lib/shared/types.d.ts.map +1 -0
- package/dist/lib/shared/types.js +1 -0
- package/dist/lib/shared/types.mjs +0 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +99 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isSignal as y}from"@fluixi/reactive/signal";var j="http://www.w3.org/2000/svg";function ne(e){return e.localName.includes("-")}function _(e,t,n,o=!1){if(n==null){e.removeAttribute(t);return}if(ne(e)){e[t]=n;return}A(e,t,n,o)}var H=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function A(e,t,n,o=!1){if(n==null||n===!1){e.removeAttribute(t);return}if(n===!0){e.setAttribute(t,"");return}if(typeof n=="object"){e.setAttribute(t,JSON.stringify(n));return}e.setAttribute(t,String(n))}var he=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function g(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as Y,createEffect as w,createRenderEffect as b,createRoot as ie,onCleanup as T,readChildren as re}from"@fluixi/reactive/signal";var C=typeof document>"u";var D=Symbol.for("fluixi.server-node"),G=null;function F(){if(!G)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return G}function S(e){return e!=null&&e[D]===!0?!0:typeof Node<"u"&&e instanceof Node}function q(e){return e!=null&&e[D]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function B(e){return e!=null&&e[D]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var m={active:!1,cursor:null,parents:[]},oe=null;function I(){return oe}function W(e,t){return m.active&&t.parentNode===e}function X(e){let t=m.parents.lastIndexOf(e);t!==-1&&(m.parents.length=t),m.cursor=e.nextSibling}function se(e){let t=[];for(;e&&e.nodeType===1;){let n=e.tagName.toLowerCase();if(e.id){n+=`#${e.id}`,t.unshift(n);break}e.getAttribute("data-id")&&(n+=`[data-id="${e.getAttribute("data-id")}"]`);let o=0,f=e;for(;f=f.previousElementSibling;)f.tagName===e.tagName&&o++;n+=`:nth-of-type(${o+1})`,t.unshift(n),e=e.parentElement}return t.join(">")}function fe(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return`el_${Math.abs(t)}`}function Pe(e){return fe(se(e))}var Me=()=>"xxyxxxxxxy-4xx8".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),le={};var J=new Map,P=new Set,$=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function U(e){if(!C)for(let t of e)P.has(t)||$.has(t)||(P.add(t),document.addEventListener(t,ae))}function ae(e){let t=`$$${e.type}`,n=e.composedPath&&e.composedPath()[0]||e.target;for(;n;){let o=n[t];if(o&&!n.disabled&&(o(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Element?n.host:n.parentNode}}function ue(e,t,n){if(e[`$$${t}`]=n,$.has(t)){let o=`__fx_${t}`;if(!e[o]){let f=l=>{e[`$$${t}`]?.(l)};e.addEventListener(t,f),e[o]=f}return}P.has(t)||U([t])}function z(e,t){delete e[`$$${t}`];let n=`__fx_${t}`,o=e[n];o&&(e.removeEventListener(t,o),delete e[n])}function Re(e){return!$.has(e)}function $e(e){return typeof e=="function"}function E(e){if(C)return F().createText(e);if(m.active){let t=I()?.hydrateText(e);if(t)return t}return document.createTextNode(e)}function Oe(e,t=!1){if(C)return F().createElement(e,t);if(m.active){let n=I()?.hydrateElement(e);if(n)return n}return t?document.createElementNS(j,e):document.createElement(e)}function je(e,t=!1){let n=J.get(e);if(n)return n;let o=document.createElement("template");return t?o.innerHTML=`<svg>${e}</svg>`:o.innerHTML=e,J.set(e,o),o}function _e(e,t=!1){let n=e.content.cloneNode(!0);return t?n.firstChild:n}function ce(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?ce(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}function He(e){return typeof e!="function"?null:e._name||e.name||"anonymous"}function De(e){if(y(e)||g(e)||typeof e!="function")return e;let t=e();for(;typeof t=="function"&&!y(t)&&!g(t);)t=t();return t}var x=0,de=200;function pe(e,t,n,o,f){let l=o,s=new Map;return b(()=>{let i;if(g(e)&&!y(e)){if(!s.has(e)){x++;try{let r=e();s.set(e,r)}finally{x--}}for(i=s.get(e);typeof i=="function"&&y(i);)i=i()}else for(i=e();typeof i=="function"&&y(i);)i=i();{let r=0;for(;typeof i=="function"&&r++<50;)if(g(i)){if(!s.has(i)){let a=i;x++;try{let u=a();s.set(a,u)}finally{x--}}i=s.get(i)}else if(y(i))i=i();else if(i=i(),typeof i!="function"||!y(i)&&!g(i))break}x++;try{l=v(t,i,n,l,s),f(l)}finally{x--}})}function Z(e,t,n,o){if(x>de)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=E(""),e.appendChild(n));let f=o??null;if(typeof t!="function"){x++;try{f=v(e,t,n,null)}finally{x--}return()=>f}let l=pe(t,e,n,f,s=>{f=s});return()=>(l?.(),f)}function v(e,t,n,o,f){if(t==null||typeof t=="boolean")return N(e,o,n);if(typeof t=="function")for(;typeof t=="function";)t=t();if(t==null||typeof t=="boolean")return N(e,o,n);if(L(t)){let s=E("");return Array.isArray(o)?o.length>0?(e.replaceChild(s,o[0]),N(e,o.slice(1),n)):p(e,s,n):o?e.replaceChild(s,o):p(e,s,n),t.then(i=>{s.parentNode===e&&v(e,i,s.nextSibling,s)}).catch(i=>{console.error("Error resolving promise in insertExpression:",i)}),s}let l=typeof t;if(l==="string"||l==="number"){if(l==="number"&&(t=String(t)),Array.isArray(o)){if(o.length===0){let i=E(t);return p(e,i,n),i}if(o.length===1&&o[0].nodeType===3)return o[0].data=t,o;o=N(e,o,n)}if(o&&B(o))return o.data=t,o;let s=E(t);return o&&o.parentNode===e?e.replaceChild(s,o):W(e,s)||p(e,s,n),s}if(S(t))return W(e,t)?(X(t),t):Array.isArray(o)?(o.length===0?p(e,t,n):o[0].parentNode===e?(e.replaceChild(t,o[0]),N(e,o.slice(1),n)):p(e,t,n),t):(o?o!==t&&(o.parentNode===e?e.replaceChild(t,o):p(e,t,n)):p(e,t,n),t);if(Array.isArray(t)){let s=[],i=Array.isArray(o)?o:o?[o]:[],r=[];h(t,s,e,n,!0,f,r);let a=ye(e,i,s,n);for(let u of r){let c=Z(e,u.sig,u.marker);T(()=>{N(e,c()),u.marker.parentNode===e&&e.removeChild(u.marker)})}return a}if(l==="object"&&t!==null&&typeof t=="object"){let s=t;if("_$litType$"in s||"_$litDirective$"in s)return v(e,ee(t),n,o);if("type"in s&&"props"in s){let i=s;if(typeof i.type=="function"){let r=i.type(i.props||{});return v(e,r,n,o)}}}return N(e,o,n)}function h(e,t,n,o,f=!0,l,s){for(let i=0;i<e.length;i++){let r=e[i];if(!(r==null||typeof r=="boolean")){for(;typeof r=="function"&&!L(r)&&!y(r)&&!g(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let a;for(g(r)&&!y(r)?(l||(l=new Map),l.has(r)||l.set(r,r()),a=l.get(r)):a=r();typeof a=="function"&&!L(a)&&!y(a)&&!g(a);)l||(l=new Map),l.has(a)||l.set(a,a()),a=l.get(a);if(a==null||typeof a=="boolean")continue;if(typeof a=="function"){if(y(a)){if(s){let c=E("");t.push(c),s.push({marker:c,sig:a});continue}let u=a();for(;typeof u=="function"&&y(u);)u=u();if(u==null||typeof u=="boolean")continue;Array.isArray(u)?h(u,t,n,o,f,l):h([u],t,n,o,f,l);continue}continue}Array.isArray(a)?h(a,t,n,o,f,l,s):h([a],t,n,o,f,l,s);continue}if(L(r)){let a=E("");t.push(a),r.then(u=>{if(a.parentNode){let c=[];if(h([u],c,a.parentNode,void 0,!1,l),c.length>0){a.parentNode.replaceChild(c[0],a);for(let d=1;d<c.length;d++)a.parentNode?.insertBefore(c[d],c[d-1].nextSibling)}}}).catch(u=>console.error("Error resolving promise in array:",u));continue}if(Array.isArray(r)){h(r,t,n,o,f,l,s);continue}if(S(r)){t.push(r);continue}if(typeof r=="object"&&r!==null&&("_$litType$"in r||"_$litDirective$"in r)){let a=ee(r);for(let u of a)t.push(u);continue}if(typeof r=="object"&&r!==null&&"type"in r&&"props"in r){let a=r;if(typeof a.type=="function"){let u=a.type(a.props||{});Array.isArray(u)?h(u,t,n,o,!1,l):h([u],t,n,o,!1,l);continue}}if(typeof r=="string"||typeof r=="number"){let a=String(r);if(a.trim()===""&&a!==" ")continue;t.push(E(a));continue}t.push(E(String(r)))}}}}function ye(e,t,n,o){for(let c=0;c<n.length;c++)n[c].parentNode!==null&&n[c].parentNode!==e&&(n=n.slice(),n[c]=n[c].cloneNode(!0));let f=n.length,l=t.length,s=f,i=0,r=0,a=l>0?t[l-1].nextSibling??void 0:o,u=null;for(;i<l||r<s;){if(t[i]===n[r]){i++,r++;continue}for(;l>i&&s>r&&t[l-1]===n[s-1];)l--,s--;if(l===i){let c=s<f?r?n[r-1].nextSibling??void 0:n[s-r]:a;for(;r<s;)p(e,n[r++],c)}else if(s===r)for(;i<l;)(!u||!u.has(t[i]))&&t[i].parentNode===e&&e.removeChild(t[i]),i++;else if(t[i]===n[s-1]&&n[r]===t[l-1]){let c=t[--l].nextSibling;p(e,n[r++],t[i++].nextSibling),p(e,n[--s],c),t[l]=t[i-1]}else{if(!u){u=new Map;let d=r;for(;d<s;)u.set(n[d],d++)}let c=u.get(t[i]);if(c!=null)if(r<c&&c<s){let d=i,O=1;for(;++d<l&&d<s&&!(!u.has(t[d])||u.get(t[d])!==c+O);)O++;if(O>c-r){let te=t[i];for(;r<c;)p(e,n[r++],te)}else t[i].parentNode===e?e.replaceChild(n[r++],t[i++]):(p(e,n[r++],a),i++)}else i++;else t[i].parentNode===e&&e.removeChild(t[i]),i++}}return n}function N(e,t,n){if(t)if(Array.isArray(t))for(let o=0;o<t.length;o++)t[o].parentNode===e&&e.removeChild(t[o]);else t.parentNode===e&&e.removeChild(t);return null}function p(e,t,n){m.active&&t.parentNode===e||(n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t))}function V(e,t,n){n==null?delete e[t]:e[t]=n}function ge(e,t,n,o=!1){return typeof n!="function"?(A(e,t,n,o),()=>{}):b(()=>{let f=typeof n=="function"?n():n;A(e,t,f,o)})}function me(e,t,n){return typeof n!="function"?(V(e,t,n),()=>{}):b(()=>{let o=typeof n=="function"?n():n;V(e,t,o)})}function M(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){w(()=>{M(e,t())});return}if(typeof t=="string"){e.setAttribute("class",t);return}if(Array.isArray(t)){e.setAttribute("class",t.filter(Boolean).join(" "));return}if(typeof t=="object"){let n=Object.keys(t).filter(o=>{let f=t[o];return typeof f=="function"?f():!!f}).join(" ");e.setAttribute("class",n);return}e.setAttribute("class",String(t))}function R(e,t,n){if(!(!t||typeof t!="object"))for(let o in t){let f=t[o],l=o.split(/\s+/).filter(Boolean);if(typeof f=="function"&&n)n.push(b(()=>{let s=!!f();for(let i of l)e.classList.toggle(i,s)}));else{let s=!!(typeof f=="function"?f():f);for(let i of l)e.classList.toggle(i,s)}}}function K(e,t){let n=t;for(;typeof n=="function";)n=n();if(n==null){e.removeAttribute("style");return}if(typeof n=="string"){e.style.cssText=n;return}if(typeof n=="object")for(let o in n){let f=n[o];f==null?e.style[o]="":e.style[o]=f}}function Fe(e){let{element:t,props:n,prevProps:o=le,isSVG:f=!1,skipChildren:l=!1}=e;if(!t||!q(t))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!n)return console.warn("[spread] Warning: props is undefined!"),()=>{};let s=f||t.namespaceURI===j,i=[];for(let r in n){if(l&&r==="children")continue;let a=n[r],u=o[r];if(a!==u){if(r==="ref"){Q(a,t);continue}if(r==="class"||r==="className"){typeof a=="function"?i.push(b(()=>M(t,a()))):M(t,a);continue}if(r==="classList"){typeof a=="function"?i.push(b(()=>R(t,a()))):R(t,a,i);continue}if(r==="style"){typeof a=="function"?i.push(b(()=>K(t,a()))):K(t,a);continue}if(r.startsWith("on")){let c=r.slice(2).toLowerCase();u&&z(t,c),a&&ue(t,c,a);continue}H.has(r)||!s&&r in t?i.push(me(t,r,a)):i.push(ge(t,r,a,s))}}for(let r in o)if(!(r in n))if(r.startsWith("on")){let a=r.slice(2).toLowerCase();z(t,a)}else H.has(r)?V(t,r,null):t.removeAttribute(r);return()=>{i.forEach(r=>r())}}function Ie(e,t,n=!1){for(let o in t){let f=t[o];if(o==="ref"){Q(f,e);continue}if(o!=="children"){if(o.startsWith("on")&&o.length>2){let l=o.slice(2).toLowerCase();if(typeof f=="function")if($.has(l)){e[`$$${l}`]=f;let s=`__fx_${l}`;if(!e[s]){let i=r=>{e[`$$${l}`]?.(r)};e.addEventListener(l,i),e[s]=i}}else e[`$$${l}`]=f,P.has(l)||U([l]);continue}if(o==="class"||o==="className"){M(e,f);continue}if(o==="classList"){typeof f=="function"?b(()=>R(e,f())):R(e,f);continue}if(o==="style"){K(e,f);continue}if(o==="innerHTML"){if(typeof f=="function"){let l=w(()=>{let s=f();for(;typeof s=="function";)s=s();e.innerHTML=s});T(()=>l())}else e.innerHTML=f;continue}if(o==="value"&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")){if(typeof f=="function"){let l=w(()=>{let s=f();for(;typeof s=="function"&&s.length===0;)s=s();document.activeElement!==e&&(e.value=s??"")});T(()=>{l()})}else e.value=f??"";continue}if(o==="checked"&&e.tagName==="INPUT"){if(typeof f=="function"){let l=w(()=>{let s=f();for(;typeof s=="function"&&s.length===0;)s=s();document.activeElement!==e&&(e.checked=s??"")});T(()=>{l()})}else e.checked=f??"";continue}if(o==="value"&&e.tagName==="SELECT"){if(typeof f=="function"){let l=!0,s=w(()=>{let i=f();for(;typeof i=="function"&&i.length===0;)i=i();l?(l=!1,queueMicrotask(()=>{e.value=i??""})):e.value=i??""});T(()=>{s()})}else queueMicrotask(()=>{e.value=f??""});continue}if(typeof f=="function"){let l=w(()=>{let s=f();for(;typeof s=="function"&&s.length===0;)s=s();_(e,o,s,n)});T(()=>{l()})}else _(e,o,f,n)}}}function We(...e){let t=o=>{for(let f=e.length-1;f>=0;f--){let l=e[f];if(l&&o in l&&l[o]!==void 0)return l[o]}},n=o=>{for(let f of e)if(f&&o in f)return!0;return!1};return new Proxy({},{get:(o,f)=>t(f),has:(o,f)=>n(f),ownKeys:()=>{let o=new Set;for(let f of e)if(f)for(let l of Reflect.ownKeys(f))o.add(l);return[...o]},getOwnPropertyDescriptor:(o,f)=>n(f)?{enumerable:!0,configurable:!0,get:()=>t(f)}:void 0})}function Ve(e,...t){let n=new Set;for(let s of t)for(let i of s)n.add(i);let o=s=>({enumerable:!0,configurable:!0,get:()=>e[s]}),f=t.map(s=>{let i=new Set(s);return new Proxy({},{get:(r,a)=>i.has(a)?e[a]:void 0,has:(r,a)=>i.has(a)&&a in e,ownKeys:()=>Array.from(i).filter(r=>r in e),getOwnPropertyDescriptor:(r,a)=>i.has(a)&&a in e?o(a):void 0})}),l=new Proxy({},{get:(s,i)=>n.has(i)?void 0:e[i],has:(s,i)=>!n.has(i)&&i in e,ownKeys:()=>Reflect.ownKeys(e).filter(s=>!n.has(s)),getOwnPropertyDescriptor:(s,i)=>!n.has(i)&&i in e?o(i):void 0});return[...f,l]}function Q(e,t){if(e){if(S(e)){let n=t,o=e;if(!n)return;typeof n=="function"?n(o):typeof n=="object"&&"current"in n&&(n.current=o);return}typeof e=="function"?e(t):typeof e=="object"&&"current"in e&&(e.current=t)}}var k=null;function Ke(e){k=e}function ee(e){let t=[];if(!k)return console.warn("Lit render not registered. Call registerLitRender first."),t;try{let n=document.createElement("div");for(k(e,n);n.firstChild;)t.push(n.firstChild),n.removeChild(n.firstChild)}catch(n){console.warn("Could not render Lit template:",n)}return t}function ke(e,t,n){let o=t||document.body,f=re(()=>e),l=[];return Y(()=>{let s=b(()=>{let i=f();Array.isArray(i)?(i.forEach(r=>o.appendChild(r)),l.push(()=>{i.forEach(r=>{r.parentNode===o&&o.removeChild(r)})})):S(i)&&(o.appendChild(i),l.push(()=>{i.parentNode===o&&o.removeChild(i)}))});l.push(s),T(()=>{l.forEach(i=>i())})}),null}function Ge(e){return typeof e=="string"&&e.toLowerCase()===e}function qe(e){return e==="svg"||e==="path"||e==="circle"||e==="rect"||e==="line"||e==="polygon"||e==="polyline"||e==="ellipse"||e==="g"||e==="defs"||e==="clipPath"||e==="text"}function Be(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function L(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function Xe(e){return typeof e=="function"&&e.length===0&&y(e)}function Je(e,t,n){if(!t)throw new Error("Container element is required");let o,f,l=[];return ie(s=>{Y(()=>{m.active||(t.textContent=""),Z(t,e)}),f=s}),()=>{f?.(),o?.(),l.forEach(s=>s()),t.textContent=""}}export{ue as addDelegatedEventListener,Ie as applyProps,N as cleanChildren,_e as cloneTemplate,Oe as createNativeElement,ke as createPortal,je as createTemplate,U as delegateEvents,Be as escapeHTML,He as fnName,Me as generateID,Pe as getStableElementId,Q as handleRef,Z as insert,v as insertExpression,Xe as isAccessor,Re as isDelegatedEvent,$e as isFunction,Ge as isNativeElement,L as isPromise,qe as isSVGElement,De as iterateFn,ce as makeArrayFlat,We as mergeProps,Ke as registerLitRender,z as removeDelegatedEventListener,Je as render,ee as renderLitToNodes,R as setClassList,M as setClassName,ge as setDynamicAttribute,me as setDynamicProperty,V as setProperty,K as setStyle,Ve as splitProps,Fe as spread};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var a=(e,n)=>{for(var t in n)u(e,t,{get:n[t],enumerable:!0})},l=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of s(n))!_.call(e,r)&&r!==t&&u(e,r,{get:()=>n[r],enumerable:!(i=d(n,r))||i.enumerable});return e};var g=e=>l(u({},"__esModule",{value:!0}),e);var x={};a(x,{FX_DATA_ID:()=>c,escapeFxJson:()=>f,getServerData:()=>A,resetServerDataCache:()=>p});module.exports=g(x);var c="__FX_DATA__";function f(e){return e.replace(/[<>&\u2028\u2029]/g,n=>"\\u"+n.charCodeAt(0).toString(16).padStart(4,"0"))}var o;function p(){o=void 0}function A(){let e=globalThis.__FX_DATA__;if(e)return e;if(o!==void 0)return o;let n=null;if(typeof document<"u"){let t=document.getElementById(c)?.textContent;if(t)try{n=JSON.parse(t)}catch{n=null}}return o=n}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SSR data transport (`__FX_DATA__`) — emission escaping + client reader.
|
|
3
|
+
*
|
|
4
|
+
* The server collects resolved resource values + seeds (i18n locale, isomorphic state) and
|
|
5
|
+
* embeds them in the page so the client hydrates without refetching. SECURITY MODEL:
|
|
6
|
+
*
|
|
7
|
+
* - It is NON-SECRET BY DESIGN — it's in the page, readable by the user. Encrypting it buys
|
|
8
|
+
* nothing (the client would need the key). Keep server-only fields OUT via setDataRedactor;
|
|
9
|
+
* fetch truly sensitive data through a `"use server"` function instead. Don't obfuscate.
|
|
10
|
+
*
|
|
11
|
+
* - Emitted as a NON-EXECUTABLE `<script type="application/json">`, read via `JSON.parse` of
|
|
12
|
+
* its `textContent`. So (a) a value can never execute as JS, and (b) it's CSP-friendly —
|
|
13
|
+
* it works under a strict `script-src` that forbids inline executable scripts.
|
|
14
|
+
*
|
|
15
|
+
* - The JSON is escaped with the standard SSR-JSON set (`<`, `>`, `&`, U+2028, U+2029) so no
|
|
16
|
+
* string value can break out of the `<script>` element or corrupt the HTML/JS parse. JSON
|
|
17
|
+
* round-trips the escapes back to the original characters on `JSON.parse`.
|
|
18
|
+
*/
|
|
19
|
+
/** The id of the `<script type="application/json">` data block (also the legacy global name). */
|
|
20
|
+
export declare const FX_DATA_ID = "__FX_DATA__";
|
|
21
|
+
/**
|
|
22
|
+
* Escape a JSON string for safe embedding inside a `<script>` element.
|
|
23
|
+
* `<`/`>` → can't form `</script>`, `<!--` or `-->`; `&` → no HTML-entity surprises;
|
|
24
|
+
* U+2028/U+2029 → JS line terminators that would break an inline-script read.
|
|
25
|
+
* JSON.parse decodes every `\uXXXX` back to the original character.
|
|
26
|
+
*/
|
|
27
|
+
export declare function escapeFxJson(json: string): string;
|
|
28
|
+
/** Clear the parsed-script cache. For tests, and SPA route changes that re-read a fresh page. */
|
|
29
|
+
export declare function resetServerDataCache(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Read the server-seeded data on the client. Prefers a pre-set `globalThis.__FX_DATA__`
|
|
32
|
+
* (back-compat + unit tests), otherwise parses the `<script type="application/json"
|
|
33
|
+
* id="__FX_DATA__">` payload once. Returns `null` when the page wasn't server-rendered.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getServerData(): Record<string, unknown> | null;
|
|
36
|
+
//# sourceMappingURL=fx-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fx-data.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/fx-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iGAAiG;AACjG,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAID,iGAAiG;AACjG,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAiB9D"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SSR data transport (`__FX_DATA__`) — emission escaping + client reader.
|
|
3
|
+
*
|
|
4
|
+
* The server collects resolved resource values + seeds (i18n locale, isomorphic state) and
|
|
5
|
+
* embeds them in the page so the client hydrates without refetching. SECURITY MODEL:
|
|
6
|
+
*
|
|
7
|
+
* - It is NON-SECRET BY DESIGN — it's in the page, readable by the user. Encrypting it buys
|
|
8
|
+
* nothing (the client would need the key). Keep server-only fields OUT via setDataRedactor;
|
|
9
|
+
* fetch truly sensitive data through a `"use server"` function instead. Don't obfuscate.
|
|
10
|
+
*
|
|
11
|
+
* - Emitted as a NON-EXECUTABLE `<script type="application/json">`, read via `JSON.parse` of
|
|
12
|
+
* its `textContent`. So (a) a value can never execute as JS, and (b) it's CSP-friendly —
|
|
13
|
+
* it works under a strict `script-src` that forbids inline executable scripts.
|
|
14
|
+
*
|
|
15
|
+
* - The JSON is escaped with the standard SSR-JSON set (`<`, `>`, `&`, U+2028, U+2029) so no
|
|
16
|
+
* string value can break out of the `<script>` element or corrupt the HTML/JS parse. JSON
|
|
17
|
+
* round-trips the escapes back to the original characters on `JSON.parse`.
|
|
18
|
+
*/
|
|
19
|
+
/** The id of the `<script type="application/json">` data block (also the legacy global name). */
|
|
20
|
+
export const FX_DATA_ID = '__FX_DATA__';
|
|
21
|
+
/**
|
|
22
|
+
* Escape a JSON string for safe embedding inside a `<script>` element.
|
|
23
|
+
* `<`/`>` → can't form `</script>`, `<!--` or `-->`; `&` → no HTML-entity surprises;
|
|
24
|
+
* U+2028/U+2029 → JS line terminators that would break an inline-script read.
|
|
25
|
+
* JSON.parse decodes every `\uXXXX` back to the original character.
|
|
26
|
+
*/
|
|
27
|
+
export function escapeFxJson(json) {
|
|
28
|
+
return json.replace(/[<>&\u2028\u2029]/g, (c) => '\\u' + c.charCodeAt(0).toString(16).padStart(4, '0'));
|
|
29
|
+
}
|
|
30
|
+
let _scriptCache;
|
|
31
|
+
/** Clear the parsed-script cache. For tests, and SPA route changes that re-read a fresh page. */
|
|
32
|
+
export function resetServerDataCache() {
|
|
33
|
+
_scriptCache = undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Read the server-seeded data on the client. Prefers a pre-set `globalThis.__FX_DATA__`
|
|
37
|
+
* (back-compat + unit tests), otherwise parses the `<script type="application/json"
|
|
38
|
+
* id="__FX_DATA__">` payload once. Returns `null` when the page wasn't server-rendered.
|
|
39
|
+
*/
|
|
40
|
+
export function getServerData() {
|
|
41
|
+
// Global wins and is never cached, so it reflects the current value (tests set/delete it).
|
|
42
|
+
const g = globalThis.__FX_DATA__;
|
|
43
|
+
if (g)
|
|
44
|
+
return g;
|
|
45
|
+
if (_scriptCache !== undefined)
|
|
46
|
+
return _scriptCache; // script content is static for the page
|
|
47
|
+
let parsed = null;
|
|
48
|
+
if (typeof document !== 'undefined') {
|
|
49
|
+
const text = document.getElementById(FX_DATA_ID)?.textContent;
|
|
50
|
+
if (text) {
|
|
51
|
+
try {
|
|
52
|
+
parsed = JSON.parse(text);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
parsed = null; // malformed transport → behave as if not server-rendered (refetch)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return (_scriptCache = parsed);
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o="__FX_DATA__";function u(e){return e.replace(/[<>&\u2028\u2029]/g,n=>"\\u"+n.charCodeAt(0).toString(16).padStart(4,"0"))}var t;function i(){t=void 0}function c(){let e=globalThis.__FX_DATA__;if(e)return e;if(t!==void 0)return t;let n=null;if(typeof document<"u"){let r=document.getElementById(o)?.textContent;if(r)try{n=JSON.parse(r)}catch{n=null}}return t=n}export{o as FX_DATA_ID,u as escapeFxJson,c as getServerData,i as resetServerDataCache};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var c=(e,r)=>{for(var t in r)i(e,t,{get:r[t],enumerable:!0})},y=(e,r,t,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of a(r))!s.call(e,n)&&n!==t&&i(e,n,{get:()=>r[n],enumerable:!(d=l(r,n))||d.enumerable});return e};var p=e=>y(i({},"__esModule",{value:!0}),e);var T={};c(T,{SERVER_NODE:()=>o,getServerNodes:()=>x,isDomElement:()=>S,isDomNode:()=>N,isDomText:()=>E,isServer:()=>f,registerServerNodes:()=>m,setServerMode:()=>v});module.exports=p(T);var f=typeof document>"u";function v(e){f=e}var o=Symbol.for("fluixi.server-node"),u=null;function m(e){u=e}function x(){if(!u)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return u}function N(e){return e!=null&&e[o]===!0?!0:typeof Node<"u"&&e instanceof Node}function S(e){return e!=null&&e[o]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function E(e){return e!=null&&e[o]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare let isServer: boolean;
|
|
2
|
+
export declare function setServerMode(on: boolean): void;
|
|
3
|
+
export declare const SERVER_NODE: unique symbol;
|
|
4
|
+
export interface ServerNodeFactory {
|
|
5
|
+
createElement(tag: string, isSVG: boolean): any;
|
|
6
|
+
createText(value: string): any;
|
|
7
|
+
createComment(value: string): any;
|
|
8
|
+
}
|
|
9
|
+
export declare function registerServerNodes(factory: ServerNodeFactory): void;
|
|
10
|
+
export declare function getServerNodes(): ServerNodeFactory;
|
|
11
|
+
export declare function isDomNode(x: any): x is Node;
|
|
12
|
+
export declare function isDomElement(x: any): x is Element;
|
|
13
|
+
export declare function isDomText(x: any): x is Text;
|
|
14
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/host.ts"],"names":[],"mappings":"AAKA,eAAO,IAAI,QAAQ,SAAkC,CAAC;AACtD,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAE/C;AAID,eAAO,MAAM,WAAW,EAAE,OAAO,MAAyC,CAAC;AAE3E,MAAM,WAAW,iBAAiB;IAChC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC;IAChD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;IAC/B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;CACnC;AAID,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAEpE;AAED,wBAAgB,cAAc,IAAI,iBAAiB,CAKlD;AAID,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,IAAI,CAG3C;AACD,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAGjD;AACD,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,IAAI,CAG3C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// The server seam the runtime imports from. Deliberately class-free so the
|
|
2
|
+
// ServerNode classes in ./nodes.ts stay out of client bundles — they get pulled
|
|
3
|
+
// in (and registered) only when @fluixi/dom/server loads.
|
|
4
|
+
// Live binding; renderToString and jsdom tests flip it via setServerMode.
|
|
5
|
+
export let isServer = typeof document === 'undefined';
|
|
6
|
+
export function setServerMode(on) {
|
|
7
|
+
isServer = on;
|
|
8
|
+
}
|
|
9
|
+
// Stamped on every server node so the guards below can spot one without an
|
|
10
|
+
// instanceof against the (unbundled) classes.
|
|
11
|
+
export const SERVER_NODE = Symbol.for('fluixi.server-node');
|
|
12
|
+
let _nodes = null;
|
|
13
|
+
export function registerServerNodes(factory) {
|
|
14
|
+
_nodes = factory;
|
|
15
|
+
}
|
|
16
|
+
export function getServerNodes() {
|
|
17
|
+
if (!_nodes) {
|
|
18
|
+
throw new Error('[fluixi] server render ran before @fluixi/dom/server loaded');
|
|
19
|
+
}
|
|
20
|
+
return _nodes;
|
|
21
|
+
}
|
|
22
|
+
// Brand check for server nodes, instanceof for real DOM. On the client the brand
|
|
23
|
+
// branch just misses.
|
|
24
|
+
export function isDomNode(x) {
|
|
25
|
+
if (x != null && x[SERVER_NODE] === true)
|
|
26
|
+
return true;
|
|
27
|
+
return typeof Node !== 'undefined' && x instanceof Node;
|
|
28
|
+
}
|
|
29
|
+
export function isDomElement(x) {
|
|
30
|
+
if (x != null && x[SERVER_NODE] === true)
|
|
31
|
+
return x.nodeType === 1;
|
|
32
|
+
return typeof Element !== 'undefined' && x instanceof Element;
|
|
33
|
+
}
|
|
34
|
+
export function isDomText(x) {
|
|
35
|
+
if (x != null && x[SERVER_NODE] === true)
|
|
36
|
+
return x.nodeType === 3;
|
|
37
|
+
return typeof Text !== 'undefined' && x instanceof Text;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=typeof document>"u";function o(e){t=e}var n=Symbol.for("fluixi.server-node"),r=null;function i(e){r=e}function u(){if(!r)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return r}function d(e){return e!=null&&e[n]===!0?!0:typeof Node<"u"&&e instanceof Node}function f(e){return e!=null&&e[n]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function l(e){return e!=null&&e[n]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}export{n as SERVER_NODE,u as getServerNodes,f as isDomElement,d as isDomNode,l as isDomText,t as isServer,i as registerServerNodes,o as setServerMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var b=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var n in t)b(e,n,{get:t[n],enumerable:!0})},le=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ie(t))!ue.call(e,s)&&s!==n&&b(e,s,{get:()=>t[s],enumerable:!(r=oe(t,s))||r.enumerable});return e};var ce=e=>le(b({},"__esModule",{value:!0}),e);var Se={};ae(Se,{FX_DATA_ID:()=>v,ServerComment:()=>h,ServerElement:()=>m,ServerNode:()=>l,ServerText:()=>p,createRequestContext:()=>N,escapeFxJson:()=>S,getLocals:()=>Q,getRequestContext:()=>f,getRequestEvent:()=>O,getRequestLocals:()=>L,getServerData:()=>U,isDomElement:()=>H,isDomNode:()=>V,isDomText:()=>z,isServer:()=>g,isServerNodeValue:()=>P,renderToString:()=>te,renderToStringAsync:()=>re,runWithRequestContext:()=>y,serializeNode:()=>a,serializeResourceData:()=>F,setDataRedactor:()=>ne,setRequestStore:()=>K,setServerMode:()=>d});module.exports=ce(Se);var g=typeof document>"u";function d(e){g=e}var x=Symbol.for("fluixi.server-node"),de=null;function j(e){de=e}function V(e){return e!=null&&e[x]===!0?!0:typeof Node<"u"&&e instanceof Node}function H(e){return e!=null&&e[x]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function z(e){return e!=null&&e[x]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var q=1,A=3,D=8,X;X=x;var l=class{constructor(){this[X]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let t=this.parentNode;if(!t)return null;let n=t.childNodes.indexOf(this);return n>=0?t.childNodes[n+1]??null:null}get previousSibling(){let t=this.parentNode;if(!t)return null;let n=t.childNodes.indexOf(this);return n>0?t.childNodes[n-1]??null:null}get parentElement(){return this.parentNode}appendChild(t){return t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes.push(t),t}insertBefore(t,n){if(n==null)return this.appendChild(t);t.parentNode&&t.parentNode.removeChild(t);let r=this.childNodes.indexOf(n);return t.parentNode=this,r<0?this.childNodes.push(t):this.childNodes.splice(r,0,t),t}removeChild(t){let n=this.childNodes.indexOf(t);return n>=0&&this.childNodes.splice(n,1),t.parentNode=null,t}replaceChild(t,n){let r=this.childNodes.indexOf(n);return r>=0&&(t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes[r]=t,n.parentNode=null),n}addEventListener(){}removeEventListener(){}},p=class e extends l{constructor(n){super();this.nodeType=A;this.data=n}get nodeValue(){return this.data}set nodeValue(n){this.data=n==null?"":String(n)}get textContent(){return this.data}set textContent(n){this.data=n==null?"":String(n)}cloneNode(){return new e(this.data)}},h=class e extends l{constructor(n){super();this.nodeType=D;this.data=n}get nodeValue(){return this.data}set nodeValue(n){this.data=n==null?"":String(n)}cloneNode(){return new e(this.data)}},E=class{constructor(){this.cssText=""}setProperty(t,n){this[t]=n}removeProperty(t){delete this[t]}},C=class{constructor(t){this.el=t}list(){let t=this.el.getAttribute("class");return t?t.split(/\s+/).filter(Boolean):[]}write(t){t.length?this.el.setAttribute("class",t.join(" ")):this.el.removeAttribute("class")}add(...t){let n=this.list();for(let r of t)n.includes(r)||n.push(r);this.write(n)}remove(...t){this.write(this.list().filter(n=>!t.includes(n)))}contains(t){return this.list().includes(t)}toggle(t,n){let r=this.contains(t),s=n===void 0?!r:n;return s?this.add(t):this.remove(t),s}},m=class e extends l{constructor(n,r=!1){super();this.nodeType=q;this.attributes=new Map;this.style=new E;this.classList=new C(this);this.rawHTML=null;this.localName=n.toLowerCase(),this.tagName=r?n:n.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(n,r){this.attributes.set(n,String(r))}removeAttribute(n){this.attributes.delete(n)}getAttribute(n){return this.attributes.has(n)?this.attributes.get(n):null}hasAttribute(n){return this.attributes.has(n)}get id(){return this.getAttribute("id")??""}set id(n){n==null?this.removeAttribute("id"):this.setAttribute("id",n)}get className(){return this.getAttribute("class")??""}set className(n){n==null?this.removeAttribute("class"):this.setAttribute("class",n)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(n){n==null?this.removeAttribute("for"):this.setAttribute("for",n)}set value(n){n==null?this.removeAttribute("value"):this.setAttribute("value",String(n))}set checked(n){n?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(n){n?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(n){}get textContent(){return this.childNodes.map(n=>n.textContent??"").join("")}set textContent(n){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,n!=null&&n!==""&&this.appendChild(new p(String(n)))}set innerText(n){this.textContent=n}set innerHTML(n){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=n==null?"":String(n)}cloneNode(n=!1){let r=new e(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,n)for(let s of this.childNodes)r.appendChild(s.cloneNode(!0));return r}};function P(e){return e instanceof l}var pe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),J=/&/g,fe=/</g,ge=/>/g,he=/"/g;function _(e){return e.replace(J,"&").replace(fe,"<").replace(ge,">")}function W(e){return e.replace(J,"&").replace(he,""")}function me(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function xe(e){if(!e)return"";let t=[];e.cssText&&t.push(e.cssText.trim().replace(/;\s*$/,""));for(let n of Object.keys(e)){if(n==="cssText")continue;let r=e[n];r==null||r===""||t.push(`${me(n)}: ${r}`)}return t.join("; ")}function ve(e){let t="",n=xe(e.style);for(let[r,s]of e.attributes)r==="style"&&n||(t+=` ${r}="${W(s)}"`);if(n){let r=e.attributes.get("style"),s=r?`${r.replace(/;\s*$/,"")}; ${n}`:n;t+=` style="${W(s)}"`}return t}function a(e){if(e==null||e===!1||e===!0)return"";if(typeof e=="string")return _(e);if(typeof e=="number")return _(String(e));if(typeof e=="function")return a(e());if(Array.isArray(e))return e.map(a).join("");switch(e.nodeType){case A:return _(e.data??"");case D:return`<!--${e.data??""}-->`;case q:{let t=e.localName,n=`<${t}${ve(e)}>`;if(pe.has(t))return n;let r=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(a).join("");return`${n}${r}</${t}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(a).join(""):""}var v="__FX_DATA__";function S(e){return e.replace(/[<>&\u2028\u2029]/g,t=>"\\u"+t.charCodeAt(0).toString(16).padStart(4,"0"))}var k;function U(){let e=globalThis.__FX_DATA__;if(e)return e;if(k!==void 0)return k;let t=null;if(typeof document<"u"){let n=document.getElementById(v)?.textContent;if(n)try{t=JSON.parse(n)}catch{t=null}}return k=t}var I=require("@fluixi/reactive/signal"),o=require("@fluixi/reactive/signal");var R,G={getStore:()=>R,run(e,t){let n=R;R=e;try{return t()}finally{R=n}}},M=G;function K(e){M=e??G}function N(e={}){e.locals||(e.locals=e.request?L(e.request):{});let t=0,n=0,r=null,s=new Map,i=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${t++}`,nextResourceId:()=>{if(r===null)return`r${n++}`;let u=s.get(r)??0;return s.set(r,u+1),`${r}:r${u}`},nextIslandNamespace:u=>{let c=i.get(u)??0;return i.set(u,c+1),`${u}#${c}`},withResourceScope(u,c){let T=r;r=u;try{return c()}finally{r=T}},pending:new Set,data:new Map}}function y(e,t){return M.run(e,t)}function f(){return M.getStore()}function O(){return f()?.event}function Q(){let e=O();return e?(e.locals||(e.locals={}),e.locals):{}}var B=new WeakMap;function L(e){let t=B.get(e);return t||(t={},B.set(e,t)),t}var Y=!1;function ee(){Y||(Y=!0,j({createElement:(e,t)=>new m(e,t),createText:e=>new p(e),createComment:e=>new h(e)}))}function te(e,t={}){let n=g;ee(),d(!0);let r=N(t.event);try{return y(r,()=>(0,I.createRoot)(s=>{try{let i=typeof e=="function"?e():e;return a(i)}finally{s()}}))}finally{d(n)}}var Z=!1;function Ne(){Z||(Z=!0,(0,o.setResourceTracker)(e=>{f()?.pending.add(e)}),(0,o.setResourceIdSource)(()=>f()?.nextResourceId()??""),(0,o.setResourceDataSink)((e,t)=>{e&&f()?.data.set(e,t)}))}var $=null;function ne(e){$=e}function F(e){if(e.data.size===0)return"";let t={};for(let[r,s]of e.data){let i=s;if($)try{i=$(s,r)}catch{continue}i!==void 0&&(t[r]=i)}if(Object.keys(t).length===0)return"";let n=S(JSON.stringify(t));return`<script type="application/json" id="${v}">${n}<\/script>`}var ye=50;async function re(e,t={}){let n=g;ee(),d(!0),Ne();let r=N(t.event);try{return await y(r,async()=>{t.preload&&await t.preload(t.event);let s,i=null,u=()=>{};(0,I.createRoot)(w=>{u=w,i=(0,o.getOwner)(),s=typeof e=="function"?e():e});let c=()=>{try{(0,o.runWithOwner)(i,()=>a(s))}catch{}};c();let T=0;for(;r.pending.size>0&&T++<ye;){let w=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(w),await(0,o.flush)(),c()}let se=(0,o.runWithOwner)(i,()=>a(s))+F(r);return u(),se})}finally{d(n)}}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fluixi/dom server rendering — universal string renderer. The leaf node
|
|
3
|
+
* factories in runtime.ts branch to ServerNode when `isServer`, so the same
|
|
4
|
+
* imperative runtime (insert/spread/Show/For/createComponent) builds a
|
|
5
|
+
* serializable tree that renderToString turns into HTML.
|
|
6
|
+
*/
|
|
7
|
+
export { isServer, setServerMode, isDomNode, isDomElement, isDomText, } from './host.js';
|
|
8
|
+
export { ServerNode, ServerElement, ServerText, ServerComment, isServerNodeValue, } from './nodes.js';
|
|
9
|
+
export { serializeNode } from './serialize.js';
|
|
10
|
+
export { getServerData, escapeFxJson, FX_DATA_ID } from './fx-data.js';
|
|
11
|
+
export { renderToString, renderToStringAsync, serializeResourceData, setDataRedactor, type RenderOptions, } from './render.js';
|
|
12
|
+
export { setRequestStore, createRequestContext, runWithRequestContext, getRequestContext, getRequestEvent, getLocals, getRequestLocals, type RequestStore, type RequestContext, type RequestEvent, type RequestLocals, } from './request-context.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,QAAQ,EACR,aAAa,EACb,SAAS,EACT,YAAY,EACZ,SAAS,GACV,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,aAAa,EACb,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fluixi/dom server rendering — universal string renderer. The leaf node
|
|
3
|
+
* factories in runtime.ts branch to ServerNode when `isServer`, so the same
|
|
4
|
+
* imperative runtime (insert/spread/Show/For/createComponent) builds a
|
|
5
|
+
* serializable tree that renderToString turns into HTML.
|
|
6
|
+
*/
|
|
7
|
+
export { isServer, setServerMode, isDomNode, isDomElement, isDomText, } from './host.js';
|
|
8
|
+
export { ServerNode, ServerElement, ServerText, ServerComment, isServerNodeValue, } from './nodes.js';
|
|
9
|
+
export { serializeNode } from './serialize.js';
|
|
10
|
+
export { getServerData, escapeFxJson, FX_DATA_ID } from './fx-data.js';
|
|
11
|
+
export { renderToString, renderToStringAsync, serializeResourceData, setDataRedactor, } from './render.js';
|
|
12
|
+
export { setRequestStore, createRequestContext, runWithRequestContext, getRequestContext, getRequestEvent, getLocals, getRequestLocals, } from './request-context.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=typeof document>"u";function c(e){f=e}var g=Symbol.for("fluixi.server-node"),B=null;function M(e){B=e}function G(e){return e!=null&&e[g]===!0?!0:typeof Node<"u"&&e instanceof Node}function K(e){return e!=null&&e[g]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function Q(e){return e!=null&&e[g]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var b=1,E=3,C=8,O;O=g;var l=class{constructor(){this[O]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let n=this.parentNode;if(!n)return null;let t=n.childNodes.indexOf(this);return t>=0?n.childNodes[t+1]??null:null}get previousSibling(){let n=this.parentNode;if(!n)return null;let t=n.childNodes.indexOf(this);return t>0?n.childNodes[t-1]??null:null}get parentElement(){return this.parentNode}appendChild(n){return n.parentNode&&n.parentNode.removeChild(n),n.parentNode=this,this.childNodes.push(n),n}insertBefore(n,t){if(t==null)return this.appendChild(n);n.parentNode&&n.parentNode.removeChild(n);let r=this.childNodes.indexOf(t);return n.parentNode=this,r<0?this.childNodes.push(n):this.childNodes.splice(r,0,n),n}removeChild(n){let t=this.childNodes.indexOf(n);return t>=0&&this.childNodes.splice(t,1),n.parentNode=null,n}replaceChild(n,t){let r=this.childNodes.indexOf(t);return r>=0&&(n.parentNode&&n.parentNode.removeChild(n),n.parentNode=this,this.childNodes[r]=n,t.parentNode=null),t}addEventListener(){}removeEventListener(){}},d=class e extends l{constructor(t){super();this.nodeType=E;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}get textContent(){return this.data}set textContent(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},h=class e extends l{constructor(t){super();this.nodeType=C;this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t==null?"":String(t)}cloneNode(){return new e(this.data)}},T=class{constructor(){this.cssText=""}setProperty(n,t){this[n]=t}removeProperty(n){delete this[n]}},w=class{constructor(n){this.el=n}list(){let n=this.el.getAttribute("class");return n?n.split(/\s+/).filter(Boolean):[]}write(n){n.length?this.el.setAttribute("class",n.join(" ")):this.el.removeAttribute("class")}add(...n){let t=this.list();for(let r of n)t.includes(r)||t.push(r);this.write(t)}remove(...n){this.write(this.list().filter(t=>!n.includes(t)))}contains(n){return this.list().includes(n)}toggle(n,t){let r=this.contains(n),s=t===void 0?!r:t;return s?this.add(n):this.remove(n),s}},m=class e extends l{constructor(t,r=!1){super();this.nodeType=b;this.attributes=new Map;this.style=new T;this.classList=new w(this);this.rawHTML=null;this.localName=t.toLowerCase(),this.tagName=r?t:t.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(t,r){this.attributes.set(t,String(r))}removeAttribute(t){this.attributes.delete(t)}getAttribute(t){return this.attributes.has(t)?this.attributes.get(t):null}hasAttribute(t){return this.attributes.has(t)}get id(){return this.getAttribute("id")??""}set id(t){t==null?this.removeAttribute("id"):this.setAttribute("id",t)}get className(){return this.getAttribute("class")??""}set className(t){t==null?this.removeAttribute("class"):this.setAttribute("class",t)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(t){t==null?this.removeAttribute("for"):this.setAttribute("for",t)}set value(t){t==null?this.removeAttribute("value"):this.setAttribute("value",String(t))}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(t){t?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(t){}get textContent(){return this.childNodes.map(t=>t.textContent??"").join("")}set textContent(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,t!=null&&t!==""&&this.appendChild(new d(String(t)))}set innerText(t){this.textContent=t}set innerHTML(t){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=t==null?"":String(t)}cloneNode(t=!1){let r=new e(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,t)for(let s of this.childNodes)r.appendChild(s.cloneNode(!0));return r}};function Y(e){return e instanceof l}var Z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$=/&/g,ee=/</g,te=/>/g,ne=/"/g;function q(e){return e.replace($,"&").replace(ee,"<").replace(te,">")}function L(e){return e.replace($,"&").replace(ne,""")}function re(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase())}function se(e){if(!e)return"";let n=[];e.cssText&&n.push(e.cssText.trim().replace(/;\s*$/,""));for(let t of Object.keys(e)){if(t==="cssText")continue;let r=e[t];r==null||r===""||n.push(`${re(t)}: ${r}`)}return n.join("; ")}function oe(e){let n="",t=se(e.style);for(let[r,s]of e.attributes)r==="style"&&t||(n+=` ${r}="${L(s)}"`);if(t){let r=e.attributes.get("style"),s=r?`${r.replace(/;\s*$/,"")}; ${t}`:t;n+=` style="${L(s)}"`}return n}function u(e){if(e==null||e===!1||e===!0)return"";if(typeof e=="string")return q(e);if(typeof e=="number")return q(String(e));if(typeof e=="function")return u(e());if(Array.isArray(e))return e.map(u).join("");switch(e.nodeType){case E:return q(e.data??"");case C:return`<!--${e.data??""}-->`;case b:{let n=e.localName,t=`<${n}${oe(e)}>`;if(Z.has(n))return t;let r=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(u).join("");return`${t}${r}</${n}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(u).join(""):""}var x="__FX_DATA__";function D(e){return e.replace(/[<>&\u2028\u2029]/g,n=>"\\u"+n.charCodeAt(0).toString(16).padStart(4,"0"))}var A;function ie(){let e=globalThis.__FX_DATA__;if(e)return e;if(A!==void 0)return A;let n=null;if(typeof document<"u"){let t=document.getElementById(x)?.textContent;if(t)try{n=JSON.parse(t)}catch{n=null}}return A=n}import{createRoot as P}from"@fluixi/reactive/signal";import{setResourceTracker as le,setResourceIdSource as ce,setResourceDataSink as de,getOwner as pe,runWithOwner as H,flush as fe}from"@fluixi/reactive/signal";var v,F={getStore:()=>v,run(e,n){let t=v;v=e;try{return n()}finally{v=t}}},_=F;function ue(e){_=e??F}function N(e={}){e.locals||(e.locals=e.request?V(e.request):{});let n=0,t=0,r=null,s=new Map,o=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${n++}`,nextResourceId:()=>{if(r===null)return`r${t++}`;let i=s.get(r)??0;return s.set(r,i+1),`${r}:r${i}`},nextIslandNamespace:i=>{let a=o.get(i)??0;return o.set(i,a+1),`${i}#${a}`},withResourceScope(i,a){let S=r;r=i;try{return a()}finally{r=S}},pending:new Set,data:new Map}}function y(e,n){return _.run(e,n)}function p(){return _.getStore()}function j(){return p()?.event}function ae(){let e=j();return e?(e.locals||(e.locals={}),e.locals):{}}var I=new WeakMap;function V(e){let n=I.get(e);return n||(n={},I.set(e,n)),n}var z=!1;function W(){z||(z=!0,M({createElement:(e,n)=>new m(e,n),createText:e=>new d(e),createComment:e=>new h(e)}))}function ge(e,n={}){let t=f;W(),c(!0);let r=N(n.event);try{return y(r,()=>P(s=>{try{let o=typeof e=="function"?e():e;return u(o)}finally{s()}}))}finally{c(t)}}var X=!1;function he(){X||(X=!0,le(e=>{p()?.pending.add(e)}),ce(()=>p()?.nextResourceId()??""),de((e,n)=>{e&&p()?.data.set(e,n)}))}var k=null;function me(e){k=e}function J(e){if(e.data.size===0)return"";let n={};for(let[r,s]of e.data){let o=s;if(k)try{o=k(s,r)}catch{continue}o!==void 0&&(n[r]=o)}if(Object.keys(n).length===0)return"";let t=D(JSON.stringify(n));return`<script type="application/json" id="${x}">${t}<\/script>`}var xe=50;async function ve(e,n={}){let t=f;W(),c(!0),he();let r=N(n.event);try{return await y(r,async()=>{n.preload&&await n.preload(n.event);let s,o=null,i=()=>{};P(R=>{i=R,o=pe(),s=typeof e=="function"?e():e});let a=()=>{try{H(o,()=>u(s))}catch{}};a();let S=0;for(;r.pending.size>0&&S++<xe;){let R=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(R),await fe(),a()}let U=H(o,()=>u(s))+J(r);return i(),U})}finally{c(t)}}export{x as FX_DATA_ID,h as ServerComment,m as ServerElement,l as ServerNode,d as ServerText,N as createRequestContext,D as escapeFxJson,ae as getLocals,p as getRequestContext,j as getRequestEvent,V as getRequestLocals,ie as getServerData,K as isDomElement,G as isDomNode,Q as isDomText,f as isServer,Y as isServerNodeValue,ge as renderToString,ve as renderToStringAsync,y as runWithRequestContext,u as serializeNode,J as serializeResourceData,me as setDataRedactor,ue as setRequestStore,c as setServerMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var d=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var x=(s,t)=>{for(var e in t)d(s,e,{get:t[e],enumerable:!0})},S=(s,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of m(t))!b.call(s,n)&&n!==e&&d(s,n,{get:()=>t[n],enumerable:!(r=v(t,n))||r.enumerable});return s};var T=s=>S(d({},"__esModule",{value:!0}),s);var E={};x(E,{NODE_COMMENT:()=>f,NODE_ELEMENT:()=>p,NODE_TEXT:()=>N,ServerComment:()=>a,ServerElement:()=>h,ServerNode:()=>i,ServerStyle:()=>l,ServerText:()=>o,isServerNodeValue:()=>y});module.exports=T(E);var c=Symbol.for("fluixi.server-node");var p=1,N=3,f=8,g;g=c;var i=class{constructor(){this[g]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let t=this.parentNode;if(!t)return null;let e=t.childNodes.indexOf(this);return e>=0?t.childNodes[e+1]??null:null}get previousSibling(){let t=this.parentNode;if(!t)return null;let e=t.childNodes.indexOf(this);return e>0?t.childNodes[e-1]??null:null}get parentElement(){return this.parentNode}appendChild(t){return t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes.push(t),t}insertBefore(t,e){if(e==null)return this.appendChild(t);t.parentNode&&t.parentNode.removeChild(t);let r=this.childNodes.indexOf(e);return t.parentNode=this,r<0?this.childNodes.push(t):this.childNodes.splice(r,0,t),t}removeChild(t){let e=this.childNodes.indexOf(t);return e>=0&&this.childNodes.splice(e,1),t.parentNode=null,t}replaceChild(t,e){let r=this.childNodes.indexOf(e);return r>=0&&(t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes[r]=t,e.parentNode=null),e}addEventListener(){}removeEventListener(){}},o=class s extends i{constructor(e){super();this.nodeType=N;this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e==null?"":String(e)}get textContent(){return this.data}set textContent(e){this.data=e==null?"":String(e)}cloneNode(){return new s(this.data)}},a=class s extends i{constructor(e){super();this.nodeType=f;this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e==null?"":String(e)}cloneNode(){return new s(this.data)}},l=class{constructor(){this.cssText=""}setProperty(t,e){this[t]=e}removeProperty(t){delete this[t]}},u=class{constructor(t){this.el=t}list(){let t=this.el.getAttribute("class");return t?t.split(/\s+/).filter(Boolean):[]}write(t){t.length?this.el.setAttribute("class",t.join(" ")):this.el.removeAttribute("class")}add(...t){let e=this.list();for(let r of t)e.includes(r)||e.push(r);this.write(e)}remove(...t){this.write(this.list().filter(e=>!t.includes(e)))}contains(t){return this.list().includes(t)}toggle(t,e){let r=this.contains(t),n=e===void 0?!r:e;return n?this.add(t):this.remove(t),n}},h=class s extends i{constructor(e,r=!1){super();this.nodeType=p;this.attributes=new Map;this.style=new l;this.classList=new u(this);this.rawHTML=null;this.localName=e.toLowerCase(),this.tagName=r?e:e.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(e,r){this.attributes.set(e,String(r))}removeAttribute(e){this.attributes.delete(e)}getAttribute(e){return this.attributes.has(e)?this.attributes.get(e):null}hasAttribute(e){return this.attributes.has(e)}get id(){return this.getAttribute("id")??""}set id(e){e==null?this.removeAttribute("id"):this.setAttribute("id",e)}get className(){return this.getAttribute("class")??""}set className(e){e==null?this.removeAttribute("class"):this.setAttribute("class",e)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(e){e==null?this.removeAttribute("for"):this.setAttribute("for",e)}set value(e){e==null?this.removeAttribute("value"):this.setAttribute("value",String(e))}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(e){e?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(e){}get textContent(){return this.childNodes.map(e=>e.textContent??"").join("")}set textContent(e){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,e!=null&&e!==""&&this.appendChild(new o(String(e)))}set innerText(e){this.textContent=e}set innerHTML(e){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=e==null?"":String(e)}cloneNode(e=!1){let r=new s(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,e)for(let n of this.childNodes)r.appendChild(n.cloneNode(!0));return r}};function y(s){return s instanceof i}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server node model — a minimal, serialization-oriented stand-in for the DOM
|
|
3
|
+
* Node/Element API that @fluixi/dom's runtime calls. Under server mode the leaf
|
|
4
|
+
* factories (createNativeElement/createTextNode/createMarker) return these
|
|
5
|
+
* instead of real DOM nodes, so insert/spread/Show/For run unchanged and the
|
|
6
|
+
* result serializes to an HTML string. This is the "universal renderer" seam:
|
|
7
|
+
* our runtime talks to nodes via methods, so we mock exactly those methods
|
|
8
|
+
* (no jsdom). See ./serialize.ts for the string emitter.
|
|
9
|
+
*
|
|
10
|
+
* Only the surface the runtime actually uses is implemented (measured against
|
|
11
|
+
* runtime.ts): the linked tree (parentNode/childNodes/*Sibling + append/insert/
|
|
12
|
+
* remove/replace), attributes, the JSX_PROPERTIES properties (className/value/
|
|
13
|
+
* checked/selected/innerHTML/textContent/innerText/htmlFor/indeterminate),
|
|
14
|
+
* style, classList, and no-op event listeners.
|
|
15
|
+
*/
|
|
16
|
+
import { SERVER_NODE } from './host.js';
|
|
17
|
+
export declare const NODE_ELEMENT = 1;
|
|
18
|
+
export declare const NODE_TEXT = 3;
|
|
19
|
+
export declare const NODE_COMMENT = 8;
|
|
20
|
+
export declare abstract class ServerNode {
|
|
21
|
+
readonly [SERVER_NODE] = true;
|
|
22
|
+
abstract nodeType: number;
|
|
23
|
+
parentNode: ServerElement | null;
|
|
24
|
+
childNodes: ServerNode[];
|
|
25
|
+
get firstChild(): ServerNode | null;
|
|
26
|
+
get lastChild(): ServerNode | null;
|
|
27
|
+
get nextSibling(): ServerNode | null;
|
|
28
|
+
get previousSibling(): ServerNode | null;
|
|
29
|
+
get parentElement(): ServerElement | null;
|
|
30
|
+
appendChild<T extends ServerNode>(child: T): T;
|
|
31
|
+
insertBefore<T extends ServerNode>(child: T, ref: ServerNode | null): T;
|
|
32
|
+
removeChild<T extends ServerNode>(child: T): T;
|
|
33
|
+
replaceChild<T extends ServerNode>(next: ServerNode, old: T): T;
|
|
34
|
+
addEventListener(): void;
|
|
35
|
+
removeEventListener(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare class ServerText extends ServerNode {
|
|
38
|
+
nodeType: number;
|
|
39
|
+
data: string;
|
|
40
|
+
constructor(value: string);
|
|
41
|
+
get nodeValue(): string;
|
|
42
|
+
set nodeValue(v: string);
|
|
43
|
+
get textContent(): string;
|
|
44
|
+
set textContent(v: string);
|
|
45
|
+
cloneNode(): ServerText;
|
|
46
|
+
}
|
|
47
|
+
export declare class ServerComment extends ServerNode {
|
|
48
|
+
nodeType: number;
|
|
49
|
+
data: string;
|
|
50
|
+
constructor(value: string);
|
|
51
|
+
get nodeValue(): string;
|
|
52
|
+
set nodeValue(v: string);
|
|
53
|
+
cloneNode(): ServerComment;
|
|
54
|
+
}
|
|
55
|
+
export declare class ServerStyle {
|
|
56
|
+
cssText: string;
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
setProperty(name: string, value: string): void;
|
|
59
|
+
removeProperty(name: string): void;
|
|
60
|
+
}
|
|
61
|
+
declare class ServerClassList {
|
|
62
|
+
private el;
|
|
63
|
+
constructor(el: ServerElement);
|
|
64
|
+
private list;
|
|
65
|
+
private write;
|
|
66
|
+
add(...names: string[]): void;
|
|
67
|
+
remove(...names: string[]): void;
|
|
68
|
+
contains(name: string): boolean;
|
|
69
|
+
toggle(name: string, force?: boolean): boolean;
|
|
70
|
+
}
|
|
71
|
+
export declare class ServerElement extends ServerNode {
|
|
72
|
+
nodeType: number;
|
|
73
|
+
localName: string;
|
|
74
|
+
tagName: string;
|
|
75
|
+
isSVG: boolean;
|
|
76
|
+
namespaceURI: string | null;
|
|
77
|
+
attributes: Map<string, string>;
|
|
78
|
+
style: ServerStyle;
|
|
79
|
+
classList: ServerClassList;
|
|
80
|
+
/** raw HTML set via innerHTML — emitted verbatim, bypassing childNodes. */
|
|
81
|
+
rawHTML: string | null;
|
|
82
|
+
constructor(tag: string, isSVG?: boolean);
|
|
83
|
+
setAttribute(name: string, value: string): void;
|
|
84
|
+
removeAttribute(name: string): void;
|
|
85
|
+
getAttribute(name: string): string | null;
|
|
86
|
+
hasAttribute(name: string): boolean;
|
|
87
|
+
get id(): string;
|
|
88
|
+
set id(v: string);
|
|
89
|
+
get className(): string;
|
|
90
|
+
set className(v: string);
|
|
91
|
+
get htmlFor(): string;
|
|
92
|
+
set htmlFor(v: string);
|
|
93
|
+
set value(v: any);
|
|
94
|
+
set checked(v: any);
|
|
95
|
+
set selected(v: any);
|
|
96
|
+
set indeterminate(_v: any);
|
|
97
|
+
get textContent(): string;
|
|
98
|
+
set textContent(v: string);
|
|
99
|
+
set innerText(v: string);
|
|
100
|
+
set innerHTML(v: string);
|
|
101
|
+
cloneNode(deep?: boolean): ServerElement;
|
|
102
|
+
}
|
|
103
|
+
export declare function isServerNodeValue(x: any): x is ServerNode;
|
|
104
|
+
export {};
|
|
105
|
+
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../src/lib/dom/server/nodes.ts"],"names":[],"mappings":"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"}
|