@fluixi/dom 1.0.0-alpha.55 → 1.0.0-alpha.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/dom.cjs +1 -1
- package/dist/cdn/dom.global.js +1 -1
- package/dist/cdn/dom.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/dom/hydration.cjs +1 -1
- package/dist/lib/dom/hydration.d.ts.map +1 -1
- package/dist/lib/dom/hydration.js +13 -3
- package/dist/lib/dom/hydration.mjs +1 -1
- package/dist/lib/dom/index.cjs +1 -1
- package/dist/lib/dom/index.mjs +1 -1
- package/dist/lib/dom/island.cjs +1 -1
- package/dist/lib/dom/island.mjs +1 -1
- package/dist/lib/dom/runtime.cjs +1 -1
- package/dist/lib/dom/runtime.d.ts +15 -2
- package/dist/lib/dom/runtime.d.ts.map +1 -1
- package/dist/lib/dom/runtime.js +119 -43
- package/dist/lib/dom/runtime.mjs +1 -1
- package/dist/lib/flow/class-map.d.ts +3 -6
- package/dist/lib/flow/class-map.d.ts.map +1 -1
- package/dist/lib/flow/class-map.js +3 -6
- package/dist/lib/flow/index.cjs +1 -1
- package/dist/lib/flow/index.mjs +1 -1
- package/dist/lib/flow/portal.cjs +1 -1
- package/dist/lib/flow/portal.mjs +1 -1
- package/dist/lib/flow/style-map.d.ts +3 -6
- package/dist/lib/flow/style-map.d.ts.map +1 -1
- package/dist/lib/flow/style-map.js +3 -6
- package/dist/lib/html.cjs +1 -0
- package/dist/lib/html.d.ts +25 -0
- package/dist/lib/html.d.ts.map +1 -0
- package/dist/lib/html.js +20 -0
- package/dist/lib/html.mjs +1 -0
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +4 -5
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/shared/types.cjs +1 -1
- package/dist/lib/shared/types.d.ts +1 -1
- package/dist/lib/shared/types.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +5 -7
package/dist/lib/dom/runtime.js
CHANGED
|
@@ -161,10 +161,13 @@ export function isDelegatedEvent(name) {
|
|
|
161
161
|
export function isFunction(value) {
|
|
162
162
|
return typeof value === 'function';
|
|
163
163
|
}
|
|
164
|
-
function createTextNode(value) {
|
|
164
|
+
function createTextNode(value, anchor = false) {
|
|
165
165
|
if (isServer)
|
|
166
166
|
return getServerNodes().createText(value);
|
|
167
|
-
|
|
167
|
+
// Anchors/placeholders (insert markers) are client-only insertion points — the server
|
|
168
|
+
// serialized nothing for them, so they must never adopt a server text node. Only real
|
|
169
|
+
// content goes through the hydration walker.
|
|
170
|
+
if (hydration.active && !anchor) {
|
|
168
171
|
const node = getHydrationWalker()?.hydrateText(value);
|
|
169
172
|
if (node)
|
|
170
173
|
return node;
|
|
@@ -349,7 +352,7 @@ export function insert(parent, accessor, marker, init) {
|
|
|
349
352
|
return () => null;
|
|
350
353
|
}
|
|
351
354
|
if (marker !== undefined && !marker) {
|
|
352
|
-
marker = createTextNode('');
|
|
355
|
+
marker = createTextNode('', true);
|
|
353
356
|
parent.appendChild(marker);
|
|
354
357
|
}
|
|
355
358
|
let current = init ?? null;
|
|
@@ -383,7 +386,7 @@ export function insertExpression(parent, value, marker, current, componentCache)
|
|
|
383
386
|
}
|
|
384
387
|
// Handle promises
|
|
385
388
|
if (isPromise(value)) {
|
|
386
|
-
const placeholder = createTextNode('');
|
|
389
|
+
const placeholder = createTextNode('', true);
|
|
387
390
|
if (Array.isArray(current)) {
|
|
388
391
|
if (current.length > 0) {
|
|
389
392
|
parent.replaceChild(placeholder, current[0]);
|
|
@@ -509,9 +512,6 @@ export function insertExpression(parent, value, marker, current, componentCache)
|
|
|
509
512
|
}
|
|
510
513
|
if (t === 'object' && value !== null && typeof value === 'object') {
|
|
511
514
|
const objValue = value;
|
|
512
|
-
if ('_$litType$' in objValue || '_$litDirective$' in objValue) {
|
|
513
|
-
return insertExpression(parent, renderLitToNodes(value), marker, current);
|
|
514
|
-
}
|
|
515
515
|
if ('type' in objValue && 'props' in objValue) {
|
|
516
516
|
const jsxValue = objValue;
|
|
517
517
|
if (typeof jsxValue.type === 'function') {
|
|
@@ -592,7 +592,7 @@ reactiveSlots) {
|
|
|
592
592
|
// in place instead of re-rendering the enclosing subtree. Only the synchronous array
|
|
593
593
|
// path collects slots; async/promise resolutions fall back to the inline read below.
|
|
594
594
|
if (reactiveSlots) {
|
|
595
|
-
const slot = createTextNode('');
|
|
595
|
+
const slot = createTextNode('', true);
|
|
596
596
|
result.push(slot);
|
|
597
597
|
reactiveSlots.push({ marker: slot, sig: resolved });
|
|
598
598
|
continue;
|
|
@@ -623,7 +623,7 @@ reactiveSlots) {
|
|
|
623
623
|
continue;
|
|
624
624
|
}
|
|
625
625
|
if (isPromise(item)) {
|
|
626
|
-
const placeholder = createTextNode('');
|
|
626
|
+
const placeholder = createTextNode('', true);
|
|
627
627
|
result.push(placeholder);
|
|
628
628
|
item
|
|
629
629
|
.then((resolved) => {
|
|
@@ -649,14 +649,6 @@ reactiveSlots) {
|
|
|
649
649
|
result.push(item);
|
|
650
650
|
continue;
|
|
651
651
|
}
|
|
652
|
-
if (typeof item === 'object' &&
|
|
653
|
-
item !== null &&
|
|
654
|
-
('_$litType$' in item || '_$litDirective$' in item)) {
|
|
655
|
-
const nodes = renderLitToNodes(item);
|
|
656
|
-
for (const node of nodes)
|
|
657
|
-
result.push(node);
|
|
658
|
-
continue;
|
|
659
|
-
}
|
|
660
652
|
if (typeof item === 'object' &&
|
|
661
653
|
item !== null &&
|
|
662
654
|
'type' in item &&
|
|
@@ -833,6 +825,53 @@ export function setProperty(element, name, value) {
|
|
|
833
825
|
else
|
|
834
826
|
element[name] = value;
|
|
835
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* Apply `use:` custom directives. `value` is an array of `[directive, accessor?]`
|
|
830
|
+
* pairs (the compiler's normalized shape); each directive is called
|
|
831
|
+
* `directive(element, accessor)`. A bare function or single pair is tolerated so
|
|
832
|
+
* the runtime is usable directly too.
|
|
833
|
+
*/
|
|
834
|
+
/**
|
|
835
|
+
* Attach a NATIVE event listener (bypassing delegation) for `on:name` /
|
|
836
|
+
* `@name.capture` bindings. `value` is a handler or `[handler, options]` where
|
|
837
|
+
* options is an `AddEventListenerOptions` (`{ capture, once, passive }`).
|
|
838
|
+
* Returns a disposer that removes the listener.
|
|
839
|
+
*/
|
|
840
|
+
export function addNativeEventListener(element, name, value) {
|
|
841
|
+
let handler = value;
|
|
842
|
+
let options;
|
|
843
|
+
if (Array.isArray(value)) {
|
|
844
|
+
handler = value[0];
|
|
845
|
+
options = value[1];
|
|
846
|
+
}
|
|
847
|
+
if (typeof handler !== 'function')
|
|
848
|
+
return () => { };
|
|
849
|
+
element.addEventListener(name, handler, options);
|
|
850
|
+
return () => element.removeEventListener(name, handler, options);
|
|
851
|
+
}
|
|
852
|
+
export function applyUse(element, value) {
|
|
853
|
+
const call = (dir, accessor) => {
|
|
854
|
+
if (typeof dir === 'function')
|
|
855
|
+
dir(element, accessor ?? (() => undefined));
|
|
856
|
+
};
|
|
857
|
+
if (typeof value === 'function') {
|
|
858
|
+
call(value);
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
if (!Array.isArray(value))
|
|
862
|
+
return;
|
|
863
|
+
// A single [fn, accessor] pair, or an array of such pairs.
|
|
864
|
+
if (typeof value[0] === 'function') {
|
|
865
|
+
call(value[0], value[1]);
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
for (const pair of value) {
|
|
869
|
+
if (Array.isArray(pair))
|
|
870
|
+
call(pair[0], pair[1]);
|
|
871
|
+
else
|
|
872
|
+
call(pair);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
836
875
|
export function setDynamicAttribute(element, name, accessor, isSVG = false) {
|
|
837
876
|
if (typeof accessor !== 'function') {
|
|
838
877
|
setAttribute(element, name, accessor, isSVG);
|
|
@@ -853,6 +892,18 @@ export function setDynamicProperty(element, name, accessor) {
|
|
|
853
892
|
setProperty(element, name, value);
|
|
854
893
|
});
|
|
855
894
|
}
|
|
895
|
+
// Boolean attribute (`bool:name`): truthy renders the empty string, falsy removes it.
|
|
896
|
+
// setAttribute already does that for true/false, so coerce with !!.
|
|
897
|
+
export function setDynamicBoolAttribute(element, name, accessor) {
|
|
898
|
+
if (typeof accessor !== 'function') {
|
|
899
|
+
setAttribute(element, name, !!accessor);
|
|
900
|
+
return () => { };
|
|
901
|
+
}
|
|
902
|
+
return createRenderEffect(() => {
|
|
903
|
+
const value = accessor();
|
|
904
|
+
setAttribute(element, name, !!value);
|
|
905
|
+
});
|
|
906
|
+
}
|
|
856
907
|
/**
|
|
857
908
|
* Set className. Accepts string | string[] | Record<string,boolean> | null.
|
|
858
909
|
*/
|
|
@@ -973,6 +1024,36 @@ export function spread(options) {
|
|
|
973
1024
|
handleRef(value, element);
|
|
974
1025
|
continue;
|
|
975
1026
|
}
|
|
1027
|
+
// Custom directives: `use=${dir}` / `use:name` / `use:name=${opts}`. The
|
|
1028
|
+
// compiler normalizes to an array of [directive, accessor?] pairs; each is
|
|
1029
|
+
// called with the element (accessor optional). Directives register their own
|
|
1030
|
+
// onCleanup, so run them in the current reactive owner.
|
|
1031
|
+
if (key === 'use') {
|
|
1032
|
+
applyUse(element, value);
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
// Native event binding: `on:click` / `@click.capture` / `@input.passive`.
|
|
1036
|
+
// Value is a handler or `[handler, options]`. Uses addEventListener (bypasses
|
|
1037
|
+
// delegation) so capture/once/passive work. Must precede the `on`-delegated
|
|
1038
|
+
// branch below (both start with "on").
|
|
1039
|
+
if (key.startsWith('on:')) {
|
|
1040
|
+
disposers.push(addNativeEventListener(element, key.slice(3), value));
|
|
1041
|
+
continue;
|
|
1042
|
+
}
|
|
1043
|
+
// Forced bindings: prop:x always assigns the property, attr:x always sets the
|
|
1044
|
+
// attribute, bool:x toggles a boolean attribute — skipping the heuristic below.
|
|
1045
|
+
if (key.startsWith('prop:')) {
|
|
1046
|
+
disposers.push(setDynamicProperty(element, key.slice(5), value));
|
|
1047
|
+
continue;
|
|
1048
|
+
}
|
|
1049
|
+
if (key.startsWith('attr:')) {
|
|
1050
|
+
disposers.push(setDynamicAttribute(element, key.slice(5), value, elementIsSVG));
|
|
1051
|
+
continue;
|
|
1052
|
+
}
|
|
1053
|
+
if (key.startsWith('bool:')) {
|
|
1054
|
+
disposers.push(setDynamicBoolAttribute(element, key.slice(5), value));
|
|
1055
|
+
continue;
|
|
1056
|
+
}
|
|
976
1057
|
if (key === 'class' || key === 'className') {
|
|
977
1058
|
if (typeof value === 'function') {
|
|
978
1059
|
disposers.push(createRenderEffect(() => setClassName(element, value())));
|
|
@@ -1044,6 +1125,27 @@ export function applyProps(element, props, isSVG = false) {
|
|
|
1044
1125
|
}
|
|
1045
1126
|
if (key === 'children')
|
|
1046
1127
|
continue;
|
|
1128
|
+
if (key === 'use') {
|
|
1129
|
+
applyUse(element, val);
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
if (key.startsWith('on:')) {
|
|
1133
|
+
addNativeEventListener(element, key.slice(3), val);
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
// Forced bindings — see spread().
|
|
1137
|
+
if (key.startsWith('prop:')) {
|
|
1138
|
+
setDynamicProperty(element, key.slice(5), val);
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
if (key.startsWith('attr:')) {
|
|
1142
|
+
setDynamicAttribute(element, key.slice(5), val, isSVG);
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
if (key.startsWith('bool:')) {
|
|
1146
|
+
setDynamicBoolAttribute(element, key.slice(5), val);
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1047
1149
|
if (key.startsWith('on') && key.length > 2) {
|
|
1048
1150
|
const name = key.slice(2).toLowerCase();
|
|
1049
1151
|
if (typeof val === 'function') {
|
|
@@ -1292,32 +1394,6 @@ export function handleRef(ref, element) {
|
|
|
1292
1394
|
ref.current = element;
|
|
1293
1395
|
}
|
|
1294
1396
|
// ============================================================================
|
|
1295
|
-
// Lit integration
|
|
1296
|
-
// ============================================================================
|
|
1297
|
-
let litRenderFn = null;
|
|
1298
|
-
export function registerLitRender(render) {
|
|
1299
|
-
litRenderFn = render;
|
|
1300
|
-
}
|
|
1301
|
-
export function renderLitToNodes(template) {
|
|
1302
|
-
const nodes = [];
|
|
1303
|
-
if (!litRenderFn) {
|
|
1304
|
-
console.warn('Lit render not registered. Call registerLitRender first.');
|
|
1305
|
-
return nodes;
|
|
1306
|
-
}
|
|
1307
|
-
try {
|
|
1308
|
-
const tempContainer = document.createElement('div');
|
|
1309
|
-
litRenderFn(template, tempContainer);
|
|
1310
|
-
while (tempContainer.firstChild) {
|
|
1311
|
-
nodes.push(tempContainer.firstChild);
|
|
1312
|
-
tempContainer.removeChild(tempContainer.firstChild);
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
catch (e) {
|
|
1316
|
-
console.warn('Could not render Lit template:', e);
|
|
1317
|
-
}
|
|
1318
|
-
return nodes;
|
|
1319
|
-
}
|
|
1320
|
-
// ============================================================================
|
|
1321
1397
|
// Portal
|
|
1322
1398
|
// ============================================================================
|
|
1323
1399
|
export function createPortal(children, element, props) {
|
package/dist/lib/dom/runtime.mjs
CHANGED
|
@@ -1 +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};
|
|
1
|
+
import{isSignal as y}from"@fluixi/reactive/signal";var H="http://www.w3.org/2000/svg";function re(e){return e.localName.includes("-")}function $(e,t,n,o=!1){if(n==null){e.removeAttribute(t);return}if(re(e)){e[t]=n;return}w(e,t,n,o)}var _=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function w(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 me=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function h(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as Y,createEffect as S,createRenderEffect as g,createRoot as fe,onCleanup as T,readChildren as le}from"@fluixi/reactive/signal";var v=typeof document>"u";var D=Symbol.for("fluixi.server-node"),q=null;function F(){if(!q)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return q}function A(e){return e!=null&&e[D]===!0?!0:typeof Node<"u"&&e instanceof Node}function G(e){return e!=null&&e[D]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function X(e){return e!=null&&e[D]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var x={active:!1,cursor:null,parents:[]},se=null;function W(){return se}function I(e,t){return x.active&&t.parentNode===e}function J(e){let t=x.parents.lastIndexOf(e);t!==-1&&(x.parents.length=t),x.cursor=e.nextSibling}function ae(e){let t=[];for(;e&&e.nodeType===1;){let n=e.tagName.toLowerCase();if(e.id){n+=`#${e.id}`,t.unshift(n);break}e.getAttribute("data-id")&&(n+=`[data-id="${e.getAttribute("data-id")}"]`);let o=0,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 ue(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 Me(e){return ue(ae(e))}var Oe=()=>"xxyxxxxxxy-4xx8".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),ce={};var z=new Map,C=new Set,R=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function Z(e){if(!v)for(let t of e)C.has(t)||R.has(t)||(C.add(t),document.addEventListener(t,de))}function de(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 pe(e,t,n){if(e[`$$${t}`]=n,R.has(t)){let o=`__fx_${t}`;if(!e[o]){let f=l=>{e[`$$${t}`]?.(l)};e.addEventListener(t,f),e[o]=f}return}C.has(t)||Z([t])}function U(e,t){delete e[`$$${t}`];let n=`__fx_${t}`,o=e[n];o&&(e.removeEventListener(t,o),delete e[n])}function Re(e){return!R.has(e)}function je(e){return typeof e=="function"}function b(e,t=!1){if(v)return F().createText(e);if(x.active&&!t){let n=W()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}function He(e,t=!1){if(v)return F().createElement(e,t);if(x.active){let n=W()?.hydrateElement(e);if(n)return n}return t?document.createElementNS(H,e):document.createElement(e)}function $e(e,t=!1){let n=z.get(e);if(n)return n;let o=document.createElement("template");return t?o.innerHTML=`<svg>${e}</svg>`:o.innerHTML=e,z.set(e,o),o}function _e(e,t=!1){let n=e.content.cloneNode(!0);return t?n.firstChild:n}function ye(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?ye(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}function De(e){return typeof e!="function"?null:e._name||e.name||"anonymous"}function Fe(e){if(y(e)||h(e)||typeof e!="function")return e;let t=e();for(;typeof t=="function"&&!y(t)&&!h(t);)t=t();return t}var E=0,ge=200;function he(e,t,n,o,f){let l=o,s=new Map;return g(()=>{let i;if(h(e)&&!y(e)){if(!s.has(e)){E++;try{let r=e();s.set(e,r)}finally{E--}}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(h(i)){if(!s.has(i)){let a=i;E++;try{let u=a();s.set(a,u)}finally{E--}}i=s.get(i)}else if(y(i))i=i();else if(i=i(),typeof i!="function"||!y(i)&&!h(i))break}E++;try{l=P(t,i,n,l,s),f(l)}finally{E--}})}function Q(e,t,n,o){if(E>ge)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=b("",!0),e.appendChild(n));let f=o??null;if(typeof t!="function"){E++;try{f=P(e,t,n,null)}finally{E--}return()=>f}let l=he(t,e,n,f,s=>{f=s});return()=>(l?.(),f)}function P(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=b("",!0);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&&P(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=b(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&&X(o))return o.data=t,o;let s=b(t);return o&&o.parentNode===e?e.replaceChild(s,o):I(e,s)||p(e,s,n),s}if(A(t))return I(e,t)?(J(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=[];m(t,s,e,n,!0,f,r);let a=xe(e,i,s,n);for(let u of r){let c=Q(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("type"in s&&"props"in s){let i=s;if(typeof i.type=="function"){let r=i.type(i.props||{});return P(e,r,n,o)}}}return N(e,o,n)}function m(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)&&!h(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let a;for(h(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)&&!h(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=b("",!0);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)?m(u,t,n,o,f,l):m([u],t,n,o,f,l);continue}continue}Array.isArray(a)?m(a,t,n,o,f,l,s):m([a],t,n,o,f,l,s);continue}if(L(r)){let a=b("",!0);t.push(a),r.then(u=>{if(a.parentNode){let c=[];if(m([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)){m(r,t,n,o,f,l,s);continue}if(A(r)){t.push(r);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)?m(u,t,n,o,!1,l):m([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(b(a));continue}t.push(b(String(r)))}}}}function xe(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,j=1;for(;++d<l&&d<s&&!(!u.has(t[d])||u.get(t[d])!==c+j);)j++;if(j>c-r){let ie=t[i];for(;r<c;)p(e,n[r++],ie)}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){x.active&&t.parentNode===e||(n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t))}function k(e,t,n){n==null?delete e[t]:e[t]=n}function ee(e,t,n){let o=n,f;return Array.isArray(n)&&(o=n[0],f=n[1]),typeof o!="function"?()=>{}:(e.addEventListener(t,o,f),()=>e.removeEventListener(t,o,f))}function te(e,t){let n=(o,f)=>{typeof o=="function"&&o(e,f??(()=>{}))};if(typeof t=="function"){n(t);return}if(Array.isArray(t)){if(typeof t[0]=="function"){n(t[0],t[1]);return}for(let o of t)Array.isArray(o)?n(o[0],o[1]):n(o)}}function V(e,t,n,o=!1){return typeof n!="function"?(w(e,t,n,o),()=>{}):g(()=>{let f=typeof n=="function"?n():n;w(e,t,f,o)})}function K(e,t,n){return typeof n!="function"?(k(e,t,n),()=>{}):g(()=>{let o=typeof n=="function"?n():n;k(e,t,o)})}function ne(e,t,n){return typeof n!="function"?(w(e,t,!!n),()=>{}):g(()=>{let o=n();w(e,t,!!o)})}function M(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){S(()=>{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 O(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(g(()=>{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 B(e,t){let n=t;for(;typeof n=="function";)n=n();if(n==null){e.removeAttribute("style");return}if(typeof n=="string"){e.style.cssText=n;return}if(typeof n=="object")for(let o in n){let f=n[o];f==null?e.style[o]="":e.style[o]=f}}function We(e){let{element:t,props:n,prevProps:o=ce,isSVG:f=!1,skipChildren:l=!1}=e;if(!t||!G(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===H,i=[];for(let r in n){if(l&&r==="children")continue;let a=n[r],u=o[r];if(a!==u){if(r==="ref"){oe(a,t);continue}if(r==="use"){te(t,a);continue}if(r.startsWith("on:")){i.push(ee(t,r.slice(3),a));continue}if(r.startsWith("prop:")){i.push(K(t,r.slice(5),a));continue}if(r.startsWith("attr:")){i.push(V(t,r.slice(5),a,s));continue}if(r.startsWith("bool:")){i.push(ne(t,r.slice(5),a));continue}if(r==="class"||r==="className"){typeof a=="function"?i.push(g(()=>M(t,a()))):M(t,a);continue}if(r==="classList"){typeof a=="function"?i.push(g(()=>O(t,a()))):O(t,a,i);continue}if(r==="style"){typeof a=="function"?i.push(g(()=>B(t,a()))):B(t,a);continue}if(r.startsWith("on")){let c=r.slice(2).toLowerCase();u&&U(t,c),a&&pe(t,c,a);continue}_.has(r)||!s&&r in t?i.push(K(t,r,a)):i.push(V(t,r,a,s))}}for(let r in o)if(!(r in n))if(r.startsWith("on")){let a=r.slice(2).toLowerCase();U(t,a)}else _.has(r)?k(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"){oe(f,e);continue}if(o!=="children"){if(o==="use"){te(e,f);continue}if(o.startsWith("on:")){ee(e,o.slice(3),f);continue}if(o.startsWith("prop:")){K(e,o.slice(5),f);continue}if(o.startsWith("attr:")){V(e,o.slice(5),f,n);continue}if(o.startsWith("bool:")){ne(e,o.slice(5),f);continue}if(o.startsWith("on")&&o.length>2){let l=o.slice(2).toLowerCase();if(typeof f=="function")if(R.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,C.has(l)||Z([l]);continue}if(o==="class"||o==="className"){M(e,f);continue}if(o==="classList"){typeof f=="function"?g(()=>O(e,f())):O(e,f);continue}if(o==="style"){B(e,f);continue}if(o==="innerHTML"){if(typeof f=="function"){let l=S(()=>{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=S(()=>{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=S(()=>{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=S(()=>{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=S(()=>{let s=f();for(;typeof s=="function"&&s.length===0;)s=s();$(e,o,s,n)});T(()=>{l()})}else $(e,o,f,n)}}}function ke(...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 oe(e,t){if(e){if(A(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)}}function Ke(e,t,n){let o=t||document.body,f=le(()=>e),l=[];return Y(()=>{let s=g(()=>{let i=f();Array.isArray(i)?(i.forEach(r=>o.appendChild(r)),l.push(()=>{i.forEach(r=>{r.parentNode===o&&o.removeChild(r)})})):A(i)&&(o.appendChild(i),l.push(()=>{i.parentNode===o&&o.removeChild(i)}))});l.push(s),T(()=>{l.forEach(i=>i())})}),null}function Be(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 Ge(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 fe(s=>{Y(()=>{x.active||(t.textContent=""),Q(t,e)}),f=s}),()=>{f?.(),o?.(),l.forEach(s=>s()),t.textContent=""}}export{pe as addDelegatedEventListener,ee as addNativeEventListener,Ie as applyProps,te as applyUse,N as cleanChildren,_e as cloneTemplate,He as createNativeElement,Ke as createPortal,$e as createTemplate,Z as delegateEvents,Ge as escapeHTML,De as fnName,Oe as generateID,Me as getStableElementId,oe as handleRef,Q as insert,P as insertExpression,Xe as isAccessor,Re as isDelegatedEvent,je as isFunction,Be as isNativeElement,L as isPromise,qe as isSVGElement,Fe as iterateFn,ye as makeArrayFlat,ke as mergeProps,U as removeDelegatedEventListener,Je as render,O as setClassList,M as setClassName,V as setDynamicAttribute,ne as setDynamicBoolAttribute,K as setDynamicProperty,k as setProperty,B as setStyle,Ve as splitProps,We as spread};
|
|
@@ -16,12 +16,9 @@ export type ClassMapInput = Record<string, ClassCondition> | Accessor<Record<str
|
|
|
16
16
|
* class string. The memo re-evaluates whenever any reactive dependency
|
|
17
17
|
* inside the map changes.
|
|
18
18
|
*
|
|
19
|
-
* Works in both JSX and
|
|
20
|
-
* - JSX:
|
|
21
|
-
* -
|
|
22
|
-
*
|
|
23
|
-
* For lit-html the `processValues` helper detects the memo (via `$SIGNAL`)
|
|
24
|
-
* and wraps it with `litrx` automatically.
|
|
19
|
+
* Works in both JSX and html`` templates without renderer-specific code:
|
|
20
|
+
* - JSX: `<div class={classMap({ active: isActive })} />`
|
|
21
|
+
* - html: `class=${classMap({ active: isActive })}`
|
|
25
22
|
*
|
|
26
23
|
* @example
|
|
27
24
|
* // Static
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/class-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,IAAI,GACJ,SAAS,GACT,QAAQ,CAAC,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,GACpC,CAAC,MAAM,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAC9B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,GACxC,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAE3C
|
|
1
|
+
{"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/class-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,IAAI,GACJ,SAAS,GACT,QAAQ,CAAC,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,GACpC,CAAC,MAAM,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAC9B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,GACxC,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAkB/D"}
|
|
@@ -6,12 +6,9 @@ import { createMemo } from '@fluixi/reactive/signal';
|
|
|
6
6
|
* class string. The memo re-evaluates whenever any reactive dependency
|
|
7
7
|
* inside the map changes.
|
|
8
8
|
*
|
|
9
|
-
* Works in both JSX and
|
|
10
|
-
* - JSX:
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
* For lit-html the `processValues` helper detects the memo (via `$SIGNAL`)
|
|
14
|
-
* and wraps it with `litrx` automatically.
|
|
9
|
+
* Works in both JSX and html`` templates without renderer-specific code:
|
|
10
|
+
* - JSX: `<div class={classMap({ active: isActive })} />`
|
|
11
|
+
* - html: `class=${classMap({ active: isActive })}`
|
|
15
12
|
*
|
|
16
13
|
* @example
|
|
17
14
|
* // Static
|
package/dist/lib/flow/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var he=(e,n)=>{for(var t in n)j(e,t,{get:n[t],enumerable:!0})},me=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of ye(n))!pe.call(e,a)&&a!==t&&j(e,a,{get:()=>n[a],enumerable:!(o=de(n,a))||o.enumerable});return e};var xe=e=>me(j({},"__esModule",{value:!0}),e);var Ee={};he(Ee,{Dynamic:()=>J,ErrorBoundary:()=>se,For:()=>V,Index:()=>B,Match:()=>z,Portal:()=>ie,Show:()=>I,Switch:()=>G,classMap:()=>ae,indexArray:()=>w.indexArray,keyArray:()=>w.keyArray,mapArray:()=>w.mapArray,styleMap:()=>le});module.exports=xe(Ee);var N=require("@fluixi/reactive/signal");function U(e){return typeof e=="function"?e:(()=>e)}function x(e){return()=>{let n=e();return typeof n=="function"?n():n}}function H(e){return e!=null&&e!==!1}function O(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function I(e){let n=x(()=>e.when),t=(0,N.createMemo)(n,void 0),o=(0,N.createMemo)(t,void 0);return(0,N.createMemo)(()=>{if(o()){let s=e.children;return typeof s=="function"&&!O(s)?typeof t=="function"?(0,N.untrack)(()=>(0,N.untrack)(t)?s(t()):e.fallback):s(t):s}return e.fallback},void 0,{name:"show"})}var v=require("@fluixi/reactive/signal");var g={active:!1,cursor:null,parents:[]},ge=null;function K(){return ge}function $(e,n){return g.active&&n.parentNode===e}function F(e){let n=g.parents.lastIndexOf(e);n!==-1&&(g.parents.length=n),g.cursor=e.nextSibling}function P(e){if(!g.active||e==null)return;let n=Array.isArray(e)?e[e.length-1]:e;n&&typeof n.nodeType=="number"&&F(n)}function V(e){let n=x(()=>e.each),t=()=>e.fallback??null,o=(a,s)=>{let f=e.children,i=Array.isArray(f)?f.map(r=>typeof r=="function"?r(a,s):r):typeof f=="function"?f(a,s):f;return P(i),i};return e.by?(0,v.keyArray)(n,e.by,(a,s)=>o(a,s),{fallback:t}):(0,v.mapArray)(n,(a,s)=>o(a,s),{fallback:t})}var W=require("@fluixi/reactive/signal");function B(e){let n=x(()=>e.each);return(0,W.indexArray)(n,(t,o)=>{let a=e.children(t,o);return P(a),a},{fallback:()=>e.fallback??null})}var w=require("@fluixi/reactive/signal");var q=require("@fluixi/reactive/signal");var _=Symbol("match");function z(e){return{[_]:!0,when:x(()=>e.when),children:e.children}}function G(e){let n=Array.isArray(e.children)?e.children:[e.children];return(0,q.createMemo)(()=>{for(let t of n){let o=t,a=0;for(;typeof o=="function"&&!o[_]&&a++<10;)o=o();if(!o||typeof o!="object"||o[_]!==!0)continue;let s=o.when();if(H(s))return typeof o.children=="function"?o.children(s):o.children}return e.fallback??null})}var X=require("@fluixi/reactive/signal");function J(e){let n=U(e.component),{component:t,...o}=e;return(0,X.createMemo)(()=>{let a=n();return a==null?null:typeof a=="string"?{tag:a,props:o}:a(o)})}var R=require("@fluixi/reactive/signal");var p=require("@fluixi/reactive/signal");function A(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}var b=require("@fluixi/reactive/signal");var Z=typeof document>"u";var Q=Symbol.for("fluixi.server-node"),Y=null;function ee(){if(!Y)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return Y}function C(e){return e!=null&&e[Q]===!0?!0:typeof Node<"u"&&e instanceof Node}function ne(e){return e!=null&&e[Q]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}function T(e){if(Z)return ee().createText(e);if(g.active){let n=K()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}var m=0,Te=200;function be(e,n,t,o,a){let s=o,f=new Map;return(0,b.createRenderEffect)(()=>{let i;if(A(e)&&!(0,p.isSignal)(e)){if(!f.has(e)){m++;try{let r=e();f.set(e,r)}finally{m--}}for(i=f.get(e);typeof i=="function"&&(0,p.isSignal)(i);)i=i()}else for(i=e();typeof i=="function"&&(0,p.isSignal)(i);)i=i();{let r=0;for(;typeof i=="function"&&r++<50;)if(A(i)){if(!f.has(i)){let c=i;m++;try{let l=c();f.set(c,l)}finally{m--}}i=f.get(i)}else if((0,p.isSignal)(i))i=i();else if(i=i(),typeof i!="function"||!(0,p.isSignal)(i)&&!A(i))break}m++;try{s=S(n,i,t,s,f),a(s)}finally{m--}})}function D(e,n,t,o){if(m>Te)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=T(""),e.appendChild(t));let a=o??null;if(typeof n!="function"){m++;try{a=S(e,n,t,null)}finally{m--}return()=>a}let s=be(n,e,t,a,f=>{a=f});return()=>(s?.(),a)}function S(e,n,t,o,a){if(n==null||typeof n=="boolean")return E(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return E(e,o,t);if(M(n)){let f=T("");return Array.isArray(o)?o.length>0?(e.replaceChild(f,o[0]),E(e,o.slice(1),t)):y(e,f,t):o?e.replaceChild(f,o):y(e,f,t),n.then(i=>{f.parentNode===e&&S(e,i,f.nextSibling,f)}).catch(i=>{console.error("Error resolving promise in insertExpression:",i)}),f}let s=typeof n;if(s==="string"||s==="number"){if(s==="number"&&(n=String(n)),Array.isArray(o)){if(o.length===0){let i=T(n);return y(e,i,t),i}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=E(e,o,t)}if(o&&ne(o))return o.data=n,o;let f=T(n);return o&&o.parentNode===e?e.replaceChild(f,o):$(e,f)||y(e,f,t),f}if(C(n))return $(e,n)?(F(n),n):Array.isArray(o)?(o.length===0?y(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),E(e,o.slice(1),t)):y(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):y(e,n,t)):y(e,n,t),n);if(Array.isArray(n)){let f=[],i=Array.isArray(o)?o:o?[o]:[],r=[];h(n,f,e,t,!0,a,r);let c=Ne(e,i,f,t);for(let l of r){let u=D(e,l.sig,l.marker);(0,b.onCleanup)(()=>{E(e,u()),l.marker.parentNode===e&&e.removeChild(l.marker)})}return c}if(s==="object"&&n!==null&&typeof n=="object"){let f=n;if("_$litType$"in f||"_$litDirective$"in f)return S(e,re(n),t,o);if("type"in f&&"props"in f){let i=f;if(typeof i.type=="function"){let r=i.type(i.props||{});return S(e,r,t,o)}}}return E(e,o,t)}function h(e,n,t,o,a=!0,s,f){for(let i=0;i<e.length;i++){let r=e[i];if(!(r==null||typeof r=="boolean")){for(;typeof r=="function"&&!M(r)&&!(0,p.isSignal)(r)&&!A(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let c;for(A(r)&&!(0,p.isSignal)(r)?(s||(s=new Map),s.has(r)||s.set(r,r()),c=s.get(r)):c=r();typeof c=="function"&&!M(c)&&!(0,p.isSignal)(c)&&!A(c);)s||(s=new Map),s.has(c)||s.set(c,c()),c=s.get(c);if(c==null||typeof c=="boolean")continue;if(typeof c=="function"){if((0,p.isSignal)(c)){if(f){let u=T("");n.push(u),f.push({marker:u,sig:c});continue}let l=c();for(;typeof l=="function"&&(0,p.isSignal)(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?h(l,n,t,o,a,s):h([l],n,t,o,a,s);continue}continue}Array.isArray(c)?h(c,n,t,o,a,s,f):h([c],n,t,o,a,s,f);continue}if(M(r)){let c=T("");n.push(c),r.then(l=>{if(c.parentNode){let u=[];if(h([l],u,c.parentNode,void 0,!1,s),u.length>0){c.parentNode.replaceChild(u[0],c);for(let d=1;d<u.length;d++)c.parentNode?.insertBefore(u[d],u[d-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(r)){h(r,n,t,o,a,s,f);continue}if(C(r)){n.push(r);continue}if(typeof r=="object"&&r!==null&&("_$litType$"in r||"_$litDirective$"in r)){let c=re(r);for(let l of c)n.push(l);continue}if(typeof r=="object"&&r!==null&&"type"in r&&"props"in r){let c=r;if(typeof c.type=="function"){let l=c.type(c.props||{});Array.isArray(l)?h(l,n,t,o,!1,s):h([l],n,t,o,!1,s);continue}}if(typeof r=="string"||typeof r=="number"){let c=String(r);if(c.trim()===""&&c!==" ")continue;n.push(T(c));continue}n.push(T(String(r)))}}}}function Ne(e,n,t,o){for(let u=0;u<t.length;u++)t[u].parentNode!==null&&t[u].parentNode!==e&&(t=t.slice(),t[u]=t[u].cloneNode(!0));let a=t.length,s=n.length,f=a,i=0,r=0,c=s>0?n[s-1].nextSibling??void 0:o,l=null;for(;i<s||r<f;){if(n[i]===t[r]){i++,r++;continue}for(;s>i&&f>r&&n[s-1]===t[f-1];)s--,f--;if(s===i){let u=f<a?r?t[r-1].nextSibling??void 0:t[f-r]:c;for(;r<f;)y(e,t[r++],u)}else if(f===r)for(;i<s;)(!l||!l.has(n[i]))&&n[i].parentNode===e&&e.removeChild(n[i]),i++;else if(n[i]===t[f-1]&&t[r]===n[s-1]){let u=n[--s].nextSibling;y(e,t[r++],n[i++].nextSibling),y(e,t[--f],u),n[s]=n[i-1]}else{if(!l){l=new Map;let d=r;for(;d<f;)l.set(t[d],d++)}let u=l.get(n[i]);if(u!=null)if(r<u&&u<f){let d=i,L=1;for(;++d<s&&d<f&&!(!l.has(n[d])||l.get(n[d])!==u+L);)L++;if(L>u-r){let ue=n[i];for(;r<u;)y(e,t[r++],ue)}else n[i].parentNode===e?e.replaceChild(t[r++],n[i++]):(y(e,t[r++],c),i++)}else i++;else n[i].parentNode===e&&e.removeChild(n[i]),i++}}return t}function E(e,n,t){if(n)if(Array.isArray(n))for(let o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function y(e,n,t){g.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function oe(e,n){if(e){if(C(e)){let t=n,o=e;if(!t)return;typeof t=="function"?t(o):typeof t=="object"&&"current"in t&&(t.current=o);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}}var te=null;function re(e){let n=[];if(!te)return console.warn("Lit render not registered. Call registerLitRender first."),n;try{let t=document.createElement("div");for(te(e,t);t.firstChild;)n.push(t.firstChild),t.removeChild(t.firstChild)}catch(t){console.warn("Could not render Lit template:",t)}return n}function M(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function ie(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,t,o;return(0,R.createRoot)(a=>{t=a,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),D(o,e.children)&&oe(e.ref,o)}),(0,R.onCleanup)(()=>{t(),o.remove()}),null}var k=require("@fluixi/reactive/signal");function se(e){let[n,t]=(0,k.createSignal)(null),o=()=>t(null);return(0,k.createMemo)(()=>{let a=n();if(a!==null)return typeof e.fallback=="function"?e.fallback(a,o):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(s){return t(s),typeof e.fallback=="function"?e.fallback(s,o):e.fallback}})}var fe=require("@fluixi/reactive/signal");function ae(e){return(0,fe.createMemo)(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;(typeof a=="function"?a():a)&&t.push(o)}return t.join(" ")})}var ce=require("@fluixi/reactive/signal");function Ae(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function le(e){return(0,ce.createMemo)(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;let s=typeof a=="function"?a():a;s!=null&&t.push(`${Ae(o)}: ${s}`)}return t.join("; ")})}
|
|
1
|
+
"use strict";var j=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var ye=(e,n)=>{for(var t in n)j(e,t,{get:n[t],enumerable:!0})},pe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of ue(n))!de.call(e,a)&&a!==t&&j(e,a,{get:()=>n[a],enumerable:!(o=le(n,a))||o.enumerable});return e};var he=e=>pe(j({},"__esModule",{value:!0}),e);var Ne={};ye(Ne,{Dynamic:()=>J,ErrorBoundary:()=>re,For:()=>K,Index:()=>B,Match:()=>z,Portal:()=>oe,Show:()=>I,Switch:()=>G,classMap:()=>se,indexArray:()=>w.indexArray,keyArray:()=>w.keyArray,mapArray:()=>w.mapArray,styleMap:()=>ae});module.exports=he(Ne);var N=require("@fluixi/reactive/signal");function U(e){return typeof e=="function"?e:(()=>e)}function x(e){return()=>{let n=e();return typeof n=="function"?n():n}}function H(e){return e!=null&&e!==!1}function O(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function I(e){let n=x(()=>e.when),t=(0,N.createMemo)(n,void 0),o=(0,N.createMemo)(t,void 0);return(0,N.createMemo)(()=>{if(o()){let s=e.children;return typeof s=="function"&&!O(s)?typeof t=="function"?(0,N.untrack)(()=>(0,N.untrack)(t)?s(t()):e.fallback):s(t):s}return e.fallback},void 0,{name:"show"})}var S=require("@fluixi/reactive/signal");var g={active:!1,cursor:null,parents:[]},me=null;function W(){return me}function F(e,n){return g.active&&n.parentNode===e}function _(e){let n=g.parents.lastIndexOf(e);n!==-1&&(g.parents.length=n),g.cursor=e.nextSibling}function P(e){if(!g.active||e==null)return;let n=Array.isArray(e)?e[e.length-1]:e;n&&typeof n.nodeType=="number"&&_(n)}function K(e){let n=x(()=>e.each),t=()=>e.fallback??null,o=(a,s)=>{let f=e.children,r=Array.isArray(f)?f.map(i=>typeof i=="function"?i(a,s):i):typeof f=="function"?f(a,s):f;return P(r),r};return e.by?(0,S.keyArray)(n,e.by,(a,s)=>o(a,s),{fallback:t}):(0,S.mapArray)(n,(a,s)=>o(a,s),{fallback:t})}var V=require("@fluixi/reactive/signal");function B(e){let n=x(()=>e.each);return(0,V.indexArray)(n,(t,o)=>{let a=e.children(t,o);return P(a),a},{fallback:()=>e.fallback??null})}var w=require("@fluixi/reactive/signal");var q=require("@fluixi/reactive/signal");var $=Symbol("match");function z(e){return{[$]:!0,when:x(()=>e.when),children:e.children}}function G(e){let n=Array.isArray(e.children)?e.children:[e.children];return(0,q.createMemo)(()=>{for(let t of n){let o=t,a=0;for(;typeof o=="function"&&!o[$]&&a++<10;)o=o();if(!o||typeof o!="object"||o[$]!==!0)continue;let s=o.when();if(H(s))return typeof o.children=="function"?o.children(s):o.children}return e.fallback??null})}var X=require("@fluixi/reactive/signal");function J(e){let n=U(e.component),{component:t,...o}=e;return(0,X.createMemo)(()=>{let a=n();return a==null?null:typeof a=="string"?{tag:a,props:o}:a(o)})}var R=require("@fluixi/reactive/signal");var p=require("@fluixi/reactive/signal");function A(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}var T=require("@fluixi/reactive/signal");var Z=typeof document>"u";var Q=Symbol.for("fluixi.server-node"),Y=null;function ee(){if(!Y)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return Y}function v(e){return e!=null&&e[Q]===!0?!0:typeof Node<"u"&&e instanceof Node}function ne(e){return e!=null&&e[Q]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}function b(e,n=!1){if(Z)return ee().createText(e);if(g.active&&!n){let t=W()?.hydrateText(e);if(t)return t}return document.createTextNode(e)}var m=0,xe=200;function ge(e,n,t,o,a){let s=o,f=new Map;return(0,T.createRenderEffect)(()=>{let r;if(A(e)&&!(0,p.isSignal)(e)){if(!f.has(e)){m++;try{let i=e();f.set(e,i)}finally{m--}}for(r=f.get(e);typeof r=="function"&&(0,p.isSignal)(r);)r=r()}else for(r=e();typeof r=="function"&&(0,p.isSignal)(r);)r=r();{let i=0;for(;typeof r=="function"&&i++<50;)if(A(r)){if(!f.has(r)){let c=r;m++;try{let l=c();f.set(c,l)}finally{m--}}r=f.get(r)}else if((0,p.isSignal)(r))r=r();else if(r=r(),typeof r!="function"||!(0,p.isSignal)(r)&&!A(r))break}m++;try{s=C(n,r,t,s,f),a(s)}finally{m--}})}function D(e,n,t,o){if(m>xe)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=b("",!0),e.appendChild(t));let a=o??null;if(typeof n!="function"){m++;try{a=C(e,n,t,null)}finally{m--}return()=>a}let s=ge(n,e,t,a,f=>{a=f});return()=>(s?.(),a)}function C(e,n,t,o,a){if(n==null||typeof n=="boolean")return E(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return E(e,o,t);if(M(n)){let f=b("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(f,o[0]),E(e,o.slice(1),t)):y(e,f,t):o?e.replaceChild(f,o):y(e,f,t),n.then(r=>{f.parentNode===e&&C(e,r,f.nextSibling,f)}).catch(r=>{console.error("Error resolving promise in insertExpression:",r)}),f}let s=typeof n;if(s==="string"||s==="number"){if(s==="number"&&(n=String(n)),Array.isArray(o)){if(o.length===0){let r=b(n);return y(e,r,t),r}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=E(e,o,t)}if(o&&ne(o))return o.data=n,o;let f=b(n);return o&&o.parentNode===e?e.replaceChild(f,o):F(e,f)||y(e,f,t),f}if(v(n))return F(e,n)?(_(n),n):Array.isArray(o)?(o.length===0?y(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),E(e,o.slice(1),t)):y(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):y(e,n,t)):y(e,n,t),n);if(Array.isArray(n)){let f=[],r=Array.isArray(o)?o:o?[o]:[],i=[];h(n,f,e,t,!0,a,i);let c=be(e,r,f,t);for(let l of i){let u=D(e,l.sig,l.marker);(0,T.onCleanup)(()=>{E(e,u()),l.marker.parentNode===e&&e.removeChild(l.marker)})}return c}if(s==="object"&&n!==null&&typeof n=="object"){let f=n;if("type"in f&&"props"in f){let r=f;if(typeof r.type=="function"){let i=r.type(r.props||{});return C(e,i,t,o)}}}return E(e,o,t)}function h(e,n,t,o,a=!0,s,f){for(let r=0;r<e.length;r++){let i=e[r];if(!(i==null||typeof i=="boolean")){for(;typeof i=="function"&&!M(i)&&!(0,p.isSignal)(i)&&!A(i)&&(i=i(),!(i==null||typeof i=="boolean")););if(!(i==null||typeof i=="boolean")){if(typeof i=="function"){let c;for(A(i)&&!(0,p.isSignal)(i)?(s||(s=new Map),s.has(i)||s.set(i,i()),c=s.get(i)):c=i();typeof c=="function"&&!M(c)&&!(0,p.isSignal)(c)&&!A(c);)s||(s=new Map),s.has(c)||s.set(c,c()),c=s.get(c);if(c==null||typeof c=="boolean")continue;if(typeof c=="function"){if((0,p.isSignal)(c)){if(f){let u=b("",!0);n.push(u),f.push({marker:u,sig:c});continue}let l=c();for(;typeof l=="function"&&(0,p.isSignal)(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?h(l,n,t,o,a,s):h([l],n,t,o,a,s);continue}continue}Array.isArray(c)?h(c,n,t,o,a,s,f):h([c],n,t,o,a,s,f);continue}if(M(i)){let c=b("",!0);n.push(c),i.then(l=>{if(c.parentNode){let u=[];if(h([l],u,c.parentNode,void 0,!1,s),u.length>0){c.parentNode.replaceChild(u[0],c);for(let d=1;d<u.length;d++)c.parentNode?.insertBefore(u[d],u[d-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(i)){h(i,n,t,o,a,s,f);continue}if(v(i)){n.push(i);continue}if(typeof i=="object"&&i!==null&&"type"in i&&"props"in i){let c=i;if(typeof c.type=="function"){let l=c.type(c.props||{});Array.isArray(l)?h(l,n,t,o,!1,s):h([l],n,t,o,!1,s);continue}}if(typeof i=="string"||typeof i=="number"){let c=String(i);if(c.trim()===""&&c!==" ")continue;n.push(b(c));continue}n.push(b(String(i)))}}}}function be(e,n,t,o){for(let u=0;u<t.length;u++)t[u].parentNode!==null&&t[u].parentNode!==e&&(t=t.slice(),t[u]=t[u].cloneNode(!0));let a=t.length,s=n.length,f=a,r=0,i=0,c=s>0?n[s-1].nextSibling??void 0:o,l=null;for(;r<s||i<f;){if(n[r]===t[i]){r++,i++;continue}for(;s>r&&f>i&&n[s-1]===t[f-1];)s--,f--;if(s===r){let u=f<a?i?t[i-1].nextSibling??void 0:t[f-i]:c;for(;i<f;)y(e,t[i++],u)}else if(f===i)for(;r<s;)(!l||!l.has(n[r]))&&n[r].parentNode===e&&e.removeChild(n[r]),r++;else if(n[r]===t[f-1]&&t[i]===n[s-1]){let u=n[--s].nextSibling;y(e,t[i++],n[r++].nextSibling),y(e,t[--f],u),n[s]=n[r-1]}else{if(!l){l=new Map;let d=i;for(;d<f;)l.set(t[d],d++)}let u=l.get(n[r]);if(u!=null)if(i<u&&u<f){let d=r,L=1;for(;++d<s&&d<f&&!(!l.has(n[d])||l.get(n[d])!==u+L);)L++;if(L>u-i){let ce=n[r];for(;i<u;)y(e,t[i++],ce)}else n[r].parentNode===e?e.replaceChild(t[i++],n[r++]):(y(e,t[i++],c),r++)}else r++;else n[r].parentNode===e&&e.removeChild(n[r]),r++}}return t}function E(e,n,t){if(n)if(Array.isArray(n))for(let o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function y(e,n,t){g.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function te(e,n){if(e){if(v(e)){let t=n,o=e;if(!t)return;typeof t=="function"?t(o):typeof t=="object"&&"current"in t&&(t.current=o);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}}function M(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function oe(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,t,o;return(0,R.createRoot)(a=>{t=a,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),D(o,e.children)&&te(e.ref,o)}),(0,R.onCleanup)(()=>{t(),o.remove()}),null}var k=require("@fluixi/reactive/signal");function re(e){let[n,t]=(0,k.createSignal)(null),o=()=>t(null);return(0,k.createMemo)(()=>{let a=n();if(a!==null)return typeof e.fallback=="function"?e.fallback(a,o):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(s){return t(s),typeof e.fallback=="function"?e.fallback(s,o):e.fallback}})}var ie=require("@fluixi/reactive/signal");function se(e){return(0,ie.createMemo)(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;(typeof a=="function"?a():a)&&t.push(o)}return t.join(" ")})}var fe=require("@fluixi/reactive/signal");function Te(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function ae(e){return(0,fe.createMemo)(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;let s=typeof a=="function"?a():a;s!=null&&t.push(`${Te(o)}: ${s}`)}return t.join("; ")})}
|
package/dist/lib/flow/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as v,untrack as F}from"@fluixi/reactive/signal";function L(e){return typeof e=="function"?e:(()=>e)}function x(e){return()=>{let n=e();return typeof n=="function"?n():n}}function j(e){return e!=null&&e!==!1}function $(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function q(e){let n=x(()=>e.when),t=v(n,void 0),o=v(t,void 0);return v(()=>{if(o()){let s=e.children;return typeof s=="function"&&!$(s)?typeof t=="function"?F(()=>F(t)?s(t()):e.fallback):s(t):s}return e.fallback},void 0,{name:"show"})}import{mapArray as G,keyArray as X}from"@fluixi/reactive/signal";var g={active:!1,cursor:null,parents:[]},z=null;function _(){return z}function C(e,n){return g.active&&n.parentNode===e}function M(e){let n=g.parents.lastIndexOf(e);n!==-1&&(g.parents.length=n),g.cursor=e.nextSibling}function E(e){if(!g.active||e==null)return;let n=Array.isArray(e)?e[e.length-1]:e;n&&typeof n.nodeType=="number"&&M(n)}function J(e){let n=x(()=>e.each),t=()=>e.fallback??null,o=(a,s)=>{let f=e.children,i=Array.isArray(f)?f.map(r=>typeof r=="function"?r(a,s):r):typeof f=="function"?f(a,s):f;return E(i),i};return e.by?X(n,e.by,(a,s)=>o(a,s),{fallback:t}):G(n,(a,s)=>o(a,s),{fallback:t})}import{indexArray as Y}from"@fluixi/reactive/signal";function Z(e){let n=x(()=>e.each);return Y(n,(t,o)=>{let a=e.children(t,o);return E(a),a},{fallback:()=>e.fallback??null})}import{mapArray as Pn,keyArray as vn,indexArray as Cn}from"@fluixi/reactive/signal";import{createMemo as Q}from"@fluixi/reactive/signal";var R=Symbol("match");function ee(e){return{[R]:!0,when:x(()=>e.when),children:e.children}}function ne(e){let n=Array.isArray(e.children)?e.children:[e.children];return Q(()=>{for(let t of n){let o=t,a=0;for(;typeof o=="function"&&!o[R]&&a++<10;)o=o();if(!o||typeof o!="object"||o[R]!==!0)continue;let s=o.when();if(j(s))return typeof o.children=="function"?o.children(s):o.children}return e.fallback??null})}import{createMemo as te}from"@fluixi/reactive/signal";function oe(e){let n=L(e.component),{component:t,...o}=e;return te(()=>{let a=n();return a==null?null:typeof a=="string"?{tag:a,props:o}:a(o)})}import{createRoot as ce,onCleanup as le}from"@fluixi/reactive/signal";import{isSignal as p}from"@fluixi/reactive/signal";function b(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as Ze,createEffect as Qe,createRenderEffect as re,createRoot as en,onCleanup as ie,readChildren as nn}from"@fluixi/reactive/signal";var U=typeof document>"u";var H=Symbol.for("fluixi.server-node"),D=null;function O(){if(!D)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return D}function w(e){return e!=null&&e[H]===!0?!0:typeof Node<"u"&&e instanceof Node}function I(e){return e!=null&&e[H]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}function T(e){if(U)return O().createText(e);if(g.active){let n=_()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}var m=0,se=200;function fe(e,n,t,o,a){let s=o,f=new Map;return re(()=>{let i;if(b(e)&&!p(e)){if(!f.has(e)){m++;try{let r=e();f.set(e,r)}finally{m--}}for(i=f.get(e);typeof i=="function"&&p(i);)i=i()}else for(i=e();typeof i=="function"&&p(i);)i=i();{let r=0;for(;typeof i=="function"&&r++<50;)if(b(i)){if(!f.has(i)){let c=i;m++;try{let l=c();f.set(c,l)}finally{m--}}i=f.get(i)}else if(p(i))i=i();else if(i=i(),typeof i!="function"||!p(i)&&!b(i))break}m++;try{s=A(n,i,t,s,f),a(s)}finally{m--}})}function k(e,n,t,o){if(m>se)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=T(""),e.appendChild(t));let a=o??null;if(typeof n!="function"){m++;try{a=A(e,n,t,null)}finally{m--}return()=>a}let s=fe(n,e,t,a,f=>{a=f});return()=>(s?.(),a)}function A(e,n,t,o,a){if(n==null||typeof n=="boolean")return N(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return N(e,o,t);if(S(n)){let f=T("");return Array.isArray(o)?o.length>0?(e.replaceChild(f,o[0]),N(e,o.slice(1),t)):y(e,f,t):o?e.replaceChild(f,o):y(e,f,t),n.then(i=>{f.parentNode===e&&A(e,i,f.nextSibling,f)}).catch(i=>{console.error("Error resolving promise in insertExpression:",i)}),f}let s=typeof n;if(s==="string"||s==="number"){if(s==="number"&&(n=String(n)),Array.isArray(o)){if(o.length===0){let i=T(n);return y(e,i,t),i}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=N(e,o,t)}if(o&&I(o))return o.data=n,o;let f=T(n);return o&&o.parentNode===e?e.replaceChild(f,o):C(e,f)||y(e,f,t),f}if(w(n))return C(e,n)?(M(n),n):Array.isArray(o)?(o.length===0?y(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),N(e,o.slice(1),t)):y(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):y(e,n,t)):y(e,n,t),n);if(Array.isArray(n)){let f=[],i=Array.isArray(o)?o:o?[o]:[],r=[];h(n,f,e,t,!0,a,r);let c=ae(e,i,f,t);for(let l of r){let u=k(e,l.sig,l.marker);ie(()=>{N(e,u()),l.marker.parentNode===e&&e.removeChild(l.marker)})}return c}if(s==="object"&&n!==null&&typeof n=="object"){let f=n;if("_$litType$"in f||"_$litDirective$"in f)return A(e,W(n),t,o);if("type"in f&&"props"in f){let i=f;if(typeof i.type=="function"){let r=i.type(i.props||{});return A(e,r,t,o)}}}return N(e,o,t)}function h(e,n,t,o,a=!0,s,f){for(let i=0;i<e.length;i++){let r=e[i];if(!(r==null||typeof r=="boolean")){for(;typeof r=="function"&&!S(r)&&!p(r)&&!b(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let c;for(b(r)&&!p(r)?(s||(s=new Map),s.has(r)||s.set(r,r()),c=s.get(r)):c=r();typeof c=="function"&&!S(c)&&!p(c)&&!b(c);)s||(s=new Map),s.has(c)||s.set(c,c()),c=s.get(c);if(c==null||typeof c=="boolean")continue;if(typeof c=="function"){if(p(c)){if(f){let u=T("");n.push(u),f.push({marker:u,sig:c});continue}let l=c();for(;typeof l=="function"&&p(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?h(l,n,t,o,a,s):h([l],n,t,o,a,s);continue}continue}Array.isArray(c)?h(c,n,t,o,a,s,f):h([c],n,t,o,a,s,f);continue}if(S(r)){let c=T("");n.push(c),r.then(l=>{if(c.parentNode){let u=[];if(h([l],u,c.parentNode,void 0,!1,s),u.length>0){c.parentNode.replaceChild(u[0],c);for(let d=1;d<u.length;d++)c.parentNode?.insertBefore(u[d],u[d-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(r)){h(r,n,t,o,a,s,f);continue}if(w(r)){n.push(r);continue}if(typeof r=="object"&&r!==null&&("_$litType$"in r||"_$litDirective$"in r)){let c=W(r);for(let l of c)n.push(l);continue}if(typeof r=="object"&&r!==null&&"type"in r&&"props"in r){let c=r;if(typeof c.type=="function"){let l=c.type(c.props||{});Array.isArray(l)?h(l,n,t,o,!1,s):h([l],n,t,o,!1,s);continue}}if(typeof r=="string"||typeof r=="number"){let c=String(r);if(c.trim()===""&&c!==" ")continue;n.push(T(c));continue}n.push(T(String(r)))}}}}function ae(e,n,t,o){for(let u=0;u<t.length;u++)t[u].parentNode!==null&&t[u].parentNode!==e&&(t=t.slice(),t[u]=t[u].cloneNode(!0));let a=t.length,s=n.length,f=a,i=0,r=0,c=s>0?n[s-1].nextSibling??void 0:o,l=null;for(;i<s||r<f;){if(n[i]===t[r]){i++,r++;continue}for(;s>i&&f>r&&n[s-1]===t[f-1];)s--,f--;if(s===i){let u=f<a?r?t[r-1].nextSibling??void 0:t[f-r]:c;for(;r<f;)y(e,t[r++],u)}else if(f===r)for(;i<s;)(!l||!l.has(n[i]))&&n[i].parentNode===e&&e.removeChild(n[i]),i++;else if(n[i]===t[f-1]&&t[r]===n[s-1]){let u=n[--s].nextSibling;y(e,t[r++],n[i++].nextSibling),y(e,t[--f],u),n[s]=n[i-1]}else{if(!l){l=new Map;let d=r;for(;d<f;)l.set(t[d],d++)}let u=l.get(n[i]);if(u!=null)if(r<u&&u<f){let d=i,P=1;for(;++d<s&&d<f&&!(!l.has(n[d])||l.get(n[d])!==u+P);)P++;if(P>u-r){let B=n[i];for(;r<u;)y(e,t[r++],B)}else n[i].parentNode===e?e.replaceChild(t[r++],n[i++]):(y(e,t[r++],c),i++)}else i++;else n[i].parentNode===e&&e.removeChild(n[i]),i++}}return t}function N(e,n,t){if(n)if(Array.isArray(n))for(let o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function y(e,n,t){g.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function V(e,n){if(e){if(w(e)){let t=n,o=e;if(!t)return;typeof t=="function"?t(o):typeof t=="object"&&"current"in t&&(t.current=o);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}}var K=null;function W(e){let n=[];if(!K)return console.warn("Lit render not registered. Call registerLitRender first."),n;try{let t=document.createElement("div");for(K(e,t);t.firstChild;)n.push(t.firstChild),t.removeChild(t.firstChild)}catch(t){console.warn("Could not render Lit template:",t)}return n}function S(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function ue(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,t,o;return ce(a=>{t=a,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),k(o,e.children)&&V(e.ref,o)}),le(()=>{t(),o.remove()}),null}import{createMemo as de,createSignal as ye}from"@fluixi/reactive/signal";function pe(e){let[n,t]=ye(null),o=()=>t(null);return de(()=>{let a=n();if(a!==null)return typeof e.fallback=="function"?e.fallback(a,o):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(s){return t(s),typeof e.fallback=="function"?e.fallback(s,o):e.fallback}})}import{createMemo as he}from"@fluixi/reactive/signal";function me(e){return he(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;(typeof a=="function"?a():a)&&t.push(o)}return t.join(" ")})}import{createMemo as xe}from"@fluixi/reactive/signal";function ge(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function Te(e){return xe(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;let s=typeof a=="function"?a():a;s!=null&&t.push(`${ge(o)}: ${s}`)}return t.join("; ")})}export{oe as Dynamic,pe as ErrorBoundary,J as For,Z as Index,ee as Match,ue as Portal,q as Show,ne as Switch,me as classMap,Cn as indexArray,vn as keyArray,Pn as mapArray,Te as styleMap};
|
|
1
|
+
import{createMemo as v,untrack as _}from"@fluixi/reactive/signal";function L(e){return typeof e=="function"?e:(()=>e)}function x(e){return()=>{let n=e();return typeof n=="function"?n():n}}function j(e){return e!=null&&e!==!1}function F(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function V(e){let n=x(()=>e.when),t=v(n,void 0),o=v(t,void 0);return v(()=>{if(o()){let s=e.children;return typeof s=="function"&&!F(s)?typeof t=="function"?_(()=>_(t)?s(t()):e.fallback):s(t):s}return e.fallback},void 0,{name:"show"})}import{mapArray as q,keyArray as z}from"@fluixi/reactive/signal";var g={active:!1,cursor:null,parents:[]},B=null;function $(){return B}function M(e,n){return g.active&&n.parentNode===e}function C(e){let n=g.parents.lastIndexOf(e);n!==-1&&(g.parents.length=n),g.cursor=e.nextSibling}function A(e){if(!g.active||e==null)return;let n=Array.isArray(e)?e[e.length-1]:e;n&&typeof n.nodeType=="number"&&C(n)}function G(e){let n=x(()=>e.each),t=()=>e.fallback??null,o=(a,s)=>{let f=e.children,r=Array.isArray(f)?f.map(i=>typeof i=="function"?i(a,s):i):typeof f=="function"?f(a,s):f;return A(r),r};return e.by?z(n,e.by,(a,s)=>o(a,s),{fallback:t}):q(n,(a,s)=>o(a,s),{fallback:t})}import{indexArray as X}from"@fluixi/reactive/signal";function J(e){let n=x(()=>e.each);return X(n,(t,o)=>{let a=e.children(t,o);return A(a),a},{fallback:()=>e.fallback??null})}import{mapArray as wn,keyArray as Pn,indexArray as Sn}from"@fluixi/reactive/signal";import{createMemo as Y}from"@fluixi/reactive/signal";var R=Symbol("match");function Z(e){return{[R]:!0,when:x(()=>e.when),children:e.children}}function Q(e){let n=Array.isArray(e.children)?e.children:[e.children];return Y(()=>{for(let t of n){let o=t,a=0;for(;typeof o=="function"&&!o[R]&&a++<10;)o=o();if(!o||typeof o!="object"||o[R]!==!0)continue;let s=o.when();if(j(s))return typeof o.children=="function"?o.children(s):o.children}return e.fallback??null})}import{createMemo as ee}from"@fluixi/reactive/signal";function ne(e){let n=L(e.component),{component:t,...o}=e;return ee(()=>{let a=n();return a==null?null:typeof a=="string"?{tag:a,props:o}:a(o)})}import{createRoot as fe,onCleanup as ae}from"@fluixi/reactive/signal";import{isSignal as p}from"@fluixi/reactive/signal";function T(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as Je,createEffect as Ye,createRenderEffect as te,createRoot as Ze,onCleanup as oe,readChildren as Qe}from"@fluixi/reactive/signal";var U=typeof document>"u";var H=Symbol.for("fluixi.server-node"),D=null;function O(){if(!D)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return D}function E(e){return e!=null&&e[H]===!0?!0:typeof Node<"u"&&e instanceof Node}function I(e){return e!=null&&e[H]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}function b(e,n=!1){if(U)return O().createText(e);if(g.active&&!n){let t=$()?.hydrateText(e);if(t)return t}return document.createTextNode(e)}var m=0,re=200;function ie(e,n,t,o,a){let s=o,f=new Map;return te(()=>{let r;if(T(e)&&!p(e)){if(!f.has(e)){m++;try{let i=e();f.set(e,i)}finally{m--}}for(r=f.get(e);typeof r=="function"&&p(r);)r=r()}else for(r=e();typeof r=="function"&&p(r);)r=r();{let i=0;for(;typeof r=="function"&&i++<50;)if(T(r)){if(!f.has(r)){let c=r;m++;try{let l=c();f.set(c,l)}finally{m--}}r=f.get(r)}else if(p(r))r=r();else if(r=r(),typeof r!="function"||!p(r)&&!T(r))break}m++;try{s=P(n,r,t,s,f),a(s)}finally{m--}})}function k(e,n,t,o){if(m>re)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=b("",!0),e.appendChild(t));let a=o??null;if(typeof n!="function"){m++;try{a=P(e,n,t,null)}finally{m--}return()=>a}let s=ie(n,e,t,a,f=>{a=f});return()=>(s?.(),a)}function P(e,n,t,o,a){if(n==null||typeof n=="boolean")return N(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return N(e,o,t);if(w(n)){let f=b("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(f,o[0]),N(e,o.slice(1),t)):y(e,f,t):o?e.replaceChild(f,o):y(e,f,t),n.then(r=>{f.parentNode===e&&P(e,r,f.nextSibling,f)}).catch(r=>{console.error("Error resolving promise in insertExpression:",r)}),f}let s=typeof n;if(s==="string"||s==="number"){if(s==="number"&&(n=String(n)),Array.isArray(o)){if(o.length===0){let r=b(n);return y(e,r,t),r}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=N(e,o,t)}if(o&&I(o))return o.data=n,o;let f=b(n);return o&&o.parentNode===e?e.replaceChild(f,o):M(e,f)||y(e,f,t),f}if(E(n))return M(e,n)?(C(n),n):Array.isArray(o)?(o.length===0?y(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),N(e,o.slice(1),t)):y(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):y(e,n,t)):y(e,n,t),n);if(Array.isArray(n)){let f=[],r=Array.isArray(o)?o:o?[o]:[],i=[];h(n,f,e,t,!0,a,i);let c=se(e,r,f,t);for(let l of i){let u=k(e,l.sig,l.marker);oe(()=>{N(e,u()),l.marker.parentNode===e&&e.removeChild(l.marker)})}return c}if(s==="object"&&n!==null&&typeof n=="object"){let f=n;if("type"in f&&"props"in f){let r=f;if(typeof r.type=="function"){let i=r.type(r.props||{});return P(e,i,t,o)}}}return N(e,o,t)}function h(e,n,t,o,a=!0,s,f){for(let r=0;r<e.length;r++){let i=e[r];if(!(i==null||typeof i=="boolean")){for(;typeof i=="function"&&!w(i)&&!p(i)&&!T(i)&&(i=i(),!(i==null||typeof i=="boolean")););if(!(i==null||typeof i=="boolean")){if(typeof i=="function"){let c;for(T(i)&&!p(i)?(s||(s=new Map),s.has(i)||s.set(i,i()),c=s.get(i)):c=i();typeof c=="function"&&!w(c)&&!p(c)&&!T(c);)s||(s=new Map),s.has(c)||s.set(c,c()),c=s.get(c);if(c==null||typeof c=="boolean")continue;if(typeof c=="function"){if(p(c)){if(f){let u=b("",!0);n.push(u),f.push({marker:u,sig:c});continue}let l=c();for(;typeof l=="function"&&p(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?h(l,n,t,o,a,s):h([l],n,t,o,a,s);continue}continue}Array.isArray(c)?h(c,n,t,o,a,s,f):h([c],n,t,o,a,s,f);continue}if(w(i)){let c=b("",!0);n.push(c),i.then(l=>{if(c.parentNode){let u=[];if(h([l],u,c.parentNode,void 0,!1,s),u.length>0){c.parentNode.replaceChild(u[0],c);for(let d=1;d<u.length;d++)c.parentNode?.insertBefore(u[d],u[d-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(i)){h(i,n,t,o,a,s,f);continue}if(E(i)){n.push(i);continue}if(typeof i=="object"&&i!==null&&"type"in i&&"props"in i){let c=i;if(typeof c.type=="function"){let l=c.type(c.props||{});Array.isArray(l)?h(l,n,t,o,!1,s):h([l],n,t,o,!1,s);continue}}if(typeof i=="string"||typeof i=="number"){let c=String(i);if(c.trim()===""&&c!==" ")continue;n.push(b(c));continue}n.push(b(String(i)))}}}}function se(e,n,t,o){for(let u=0;u<t.length;u++)t[u].parentNode!==null&&t[u].parentNode!==e&&(t=t.slice(),t[u]=t[u].cloneNode(!0));let a=t.length,s=n.length,f=a,r=0,i=0,c=s>0?n[s-1].nextSibling??void 0:o,l=null;for(;r<s||i<f;){if(n[r]===t[i]){r++,i++;continue}for(;s>r&&f>i&&n[s-1]===t[f-1];)s--,f--;if(s===r){let u=f<a?i?t[i-1].nextSibling??void 0:t[f-i]:c;for(;i<f;)y(e,t[i++],u)}else if(f===i)for(;r<s;)(!l||!l.has(n[r]))&&n[r].parentNode===e&&e.removeChild(n[r]),r++;else if(n[r]===t[f-1]&&t[i]===n[s-1]){let u=n[--s].nextSibling;y(e,t[i++],n[r++].nextSibling),y(e,t[--f],u),n[s]=n[r-1]}else{if(!l){l=new Map;let d=i;for(;d<f;)l.set(t[d],d++)}let u=l.get(n[r]);if(u!=null)if(i<u&&u<f){let d=r,S=1;for(;++d<s&&d<f&&!(!l.has(n[d])||l.get(n[d])!==u+S);)S++;if(S>u-i){let K=n[r];for(;i<u;)y(e,t[i++],K)}else n[r].parentNode===e?e.replaceChild(t[i++],n[r++]):(y(e,t[i++],c),r++)}else r++;else n[r].parentNode===e&&e.removeChild(n[r]),r++}}return t}function N(e,n,t){if(n)if(Array.isArray(n))for(let o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function y(e,n,t){g.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function W(e,n){if(e){if(E(e)){let t=n,o=e;if(!t)return;typeof t=="function"?t(o):typeof t=="object"&&"current"in t&&(t.current=o);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}}function w(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function ce(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,t,o;return fe(a=>{t=a,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),k(o,e.children)&&W(e.ref,o)}),ae(()=>{t(),o.remove()}),null}import{createMemo as le,createSignal as ue}from"@fluixi/reactive/signal";function de(e){let[n,t]=ue(null),o=()=>t(null);return le(()=>{let a=n();if(a!==null)return typeof e.fallback=="function"?e.fallback(a,o):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(s){return t(s),typeof e.fallback=="function"?e.fallback(s,o):e.fallback}})}import{createMemo as ye}from"@fluixi/reactive/signal";function pe(e){return ye(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;(typeof a=="function"?a():a)&&t.push(o)}return t.join(" ")})}import{createMemo as he}from"@fluixi/reactive/signal";function me(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function xe(e){return he(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;let s=typeof a=="function"?a():a;s!=null&&t.push(`${me(o)}: ${s}`)}return t.join("; ")})}export{ne as Dynamic,de as ErrorBoundary,G as For,J as Index,Z as Match,ce as Portal,V as Show,Q as Switch,pe as classMap,Sn as indexArray,Pn as keyArray,wn as mapArray,xe as styleMap};
|
package/dist/lib/flow/portal.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var
|
|
1
|
+
"use strict";var v=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var K=(e,n)=>{for(var t in n)v(e,t,{get:n[t],enumerable:!0})},B=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of W(n))!I.call(e,c)&&c!==t&&v(e,c,{get:()=>n[c],enumerable:!(o=O(n,c))||o.enumerable});return e};var V=e=>B(v({},"__esModule",{value:!0}),e);var Y={};K(Y,{Portal:()=>J});module.exports=V(Y);var S=require("@fluixi/reactive/signal");var p=require("@fluixi/reactive/signal");function m(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}var N=require("@fluixi/reactive/signal");var R=typeof document>"u";var _=Symbol.for("fluixi.server-node"),M=null;function H(){if(!M)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return M}function T(e){return e!=null&&e[_]===!0?!0:typeof Node<"u"&&e instanceof Node}function D(e){return e!=null&&e[_]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var E={active:!1,cursor:null,parents:[]},q=null;function $(){return q}function C(e,n){return E.active&&n.parentNode===e}function j(e){let n=E.parents.lastIndexOf(e);n!==-1&&(E.parents.length=n),E.cursor=e.nextSibling}function g(e,n=!1){if(R)return H().createText(e);if(E.active&&!n){let t=$()?.hydrateText(e);if(t)return t}return document.createTextNode(e)}var x=0,U=200;function G(e,n,t,o,c){let f=o,s=new Map;return(0,N.createRenderEffect)(()=>{let i;if(m(e)&&!(0,p.isSignal)(e)){if(!s.has(e)){x++;try{let r=e();s.set(e,r)}finally{x--}}for(i=s.get(e);typeof i=="function"&&(0,p.isSignal)(i);)i=i()}else for(i=e();typeof i=="function"&&(0,p.isSignal)(i);)i=i();{let r=0;for(;typeof i=="function"&&r++<50;)if(m(i)){if(!s.has(i)){let u=i;x++;try{let l=u();s.set(u,l)}finally{x--}}i=s.get(i)}else if((0,p.isSignal)(i))i=i();else if(i=i(),typeof i!="function"||!(0,p.isSignal)(i)&&!m(i))break}x++;try{f=w(n,i,t,f,s),c(f)}finally{x--}})}function L(e,n,t,o){if(x>U)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=g("",!0),e.appendChild(t));let c=o??null;if(typeof n!="function"){x++;try{c=w(e,n,t,null)}finally{x--}return()=>c}let f=G(n,e,t,c,s=>{c=s});return()=>(f?.(),c)}function w(e,n,t,o,c){if(n==null||typeof n=="boolean")return b(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return b(e,o,t);if(A(n)){let s=g("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(s,o[0]),b(e,o.slice(1),t)):y(e,s,t):o?e.replaceChild(s,o):y(e,s,t),n.then(i=>{s.parentNode===e&&w(e,i,s.nextSibling,s)}).catch(i=>{console.error("Error resolving promise in insertExpression:",i)}),s}let f=typeof n;if(f==="string"||f==="number"){if(f==="number"&&(n=String(n)),Array.isArray(o)){if(o.length===0){let i=g(n);return y(e,i,t),i}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=b(e,o,t)}if(o&&D(o))return o.data=n,o;let s=g(n);return o&&o.parentNode===e?e.replaceChild(s,o):C(e,s)||y(e,s,t),s}if(T(n))return C(e,n)?(j(n),n):Array.isArray(o)?(o.length===0?y(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),b(e,o.slice(1),t)):y(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):y(e,n,t)):y(e,n,t),n);if(Array.isArray(n)){let s=[],i=Array.isArray(o)?o:o?[o]:[],r=[];h(n,s,e,t,!0,c,r);let u=X(e,i,s,t);for(let l of r){let a=L(e,l.sig,l.marker);(0,N.onCleanup)(()=>{b(e,a()),l.marker.parentNode===e&&e.removeChild(l.marker)})}return u}if(f==="object"&&n!==null&&typeof n=="object"){let s=n;if("type"in s&&"props"in s){let i=s;if(typeof i.type=="function"){let r=i.type(i.props||{});return w(e,r,t,o)}}}return b(e,o,t)}function h(e,n,t,o,c=!0,f,s){for(let i=0;i<e.length;i++){let r=e[i];if(!(r==null||typeof r=="boolean")){for(;typeof r=="function"&&!A(r)&&!(0,p.isSignal)(r)&&!m(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let u;for(m(r)&&!(0,p.isSignal)(r)?(f||(f=new Map),f.has(r)||f.set(r,r()),u=f.get(r)):u=r();typeof u=="function"&&!A(u)&&!(0,p.isSignal)(u)&&!m(u);)f||(f=new Map),f.has(u)||f.set(u,u()),u=f.get(u);if(u==null||typeof u=="boolean")continue;if(typeof u=="function"){if((0,p.isSignal)(u)){if(s){let a=g("",!0);n.push(a),s.push({marker:a,sig:u});continue}let l=u();for(;typeof l=="function"&&(0,p.isSignal)(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?h(l,n,t,o,c,f):h([l],n,t,o,c,f);continue}continue}Array.isArray(u)?h(u,n,t,o,c,f,s):h([u],n,t,o,c,f,s);continue}if(A(r)){let u=g("",!0);n.push(u),r.then(l=>{if(u.parentNode){let a=[];if(h([l],a,u.parentNode,void 0,!1,f),a.length>0){u.parentNode.replaceChild(a[0],u);for(let d=1;d<a.length;d++)u.parentNode?.insertBefore(a[d],a[d-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(r)){h(r,n,t,o,c,f,s);continue}if(T(r)){n.push(r);continue}if(typeof r=="object"&&r!==null&&"type"in r&&"props"in r){let u=r;if(typeof u.type=="function"){let l=u.type(u.props||{});Array.isArray(l)?h(l,n,t,o,!1,f):h([l],n,t,o,!1,f);continue}}if(typeof r=="string"||typeof r=="number"){let u=String(r);if(u.trim()===""&&u!==" ")continue;n.push(g(u));continue}n.push(g(String(r)))}}}}function X(e,n,t,o){for(let a=0;a<t.length;a++)t[a].parentNode!==null&&t[a].parentNode!==e&&(t=t.slice(),t[a]=t[a].cloneNode(!0));let c=t.length,f=n.length,s=c,i=0,r=0,u=f>0?n[f-1].nextSibling??void 0:o,l=null;for(;i<f||r<s;){if(n[i]===t[r]){i++,r++;continue}for(;f>i&&s>r&&n[f-1]===t[s-1];)f--,s--;if(f===i){let a=s<c?r?t[r-1].nextSibling??void 0:t[s-r]:u;for(;r<s;)y(e,t[r++],a)}else if(s===r)for(;i<f;)(!l||!l.has(n[i]))&&n[i].parentNode===e&&e.removeChild(n[i]),i++;else if(n[i]===t[s-1]&&t[r]===n[f-1]){let a=n[--f].nextSibling;y(e,t[r++],n[i++].nextSibling),y(e,t[--s],a),n[f]=n[i-1]}else{if(!l){l=new Map;let d=r;for(;d<s;)l.set(t[d],d++)}let a=l.get(n[i]);if(a!=null)if(r<a&&a<s){let d=i,P=1;for(;++d<f&&d<s&&!(!l.has(n[d])||l.get(n[d])!==a+P);)P++;if(P>a-r){let F=n[i];for(;r<a;)y(e,t[r++],F)}else n[i].parentNode===e?e.replaceChild(t[r++],n[i++]):(y(e,t[r++],u),i++)}else i++;else n[i].parentNode===e&&e.removeChild(n[i]),i++}}return t}function b(e,n,t){if(n)if(Array.isArray(n))for(let o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function y(e,n,t){E.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function k(e,n){if(e){if(T(e)){let t=n,o=e;if(!t)return;typeof t=="function"?t(o):typeof t=="object"&&"current"in t&&(t.current=o);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}}function A(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function J(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,t,o;return(0,S.createRoot)(c=>{t=c,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),L(o,e.children)&&k(e.ref,o)}),(0,S.onCleanup)(()=>{t(),o.remove()}),null}
|
package/dist/lib/flow/portal.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRoot as
|
|
1
|
+
import{createRoot as K,onCleanup as B}from"@fluixi/reactive/signal";import{isSignal as p}from"@fluixi/reactive/signal";function N(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as z,createEffect as Q,createRenderEffect as k,createRoot as Z,onCleanup as F,readChildren as ee}from"@fluixi/reactive/signal";var C=typeof document>"u";var L=Symbol.for("fluixi.server-node"),v=null;function M(){if(!v)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return v}function b(e){return e!=null&&e[L]===!0?!0:typeof Node<"u"&&e instanceof Node}function R(e){return e!=null&&e[L]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var m={active:!1,cursor:null,parents:[]},j=null;function _(){return j}function S(e,n){return m.active&&n.parentNode===e}function H(e){let n=m.parents.lastIndexOf(e);n!==-1&&(m.parents.length=n),m.cursor=e.nextSibling}function g(e,n=!1){if(C)return M().createText(e);if(m.active&&!n){let t=_()?.hydrateText(e);if(t)return t}return document.createTextNode(e)}var x=0,O=200;function W(e,n,t,o,c){let f=o,s=new Map;return k(()=>{let i;if(N(e)&&!p(e)){if(!s.has(e)){x++;try{let r=e();s.set(e,r)}finally{x--}}for(i=s.get(e);typeof i=="function"&&p(i);)i=i()}else for(i=e();typeof i=="function"&&p(i);)i=i();{let r=0;for(;typeof i=="function"&&r++<50;)if(N(i)){if(!s.has(i)){let u=i;x++;try{let l=u();s.set(u,l)}finally{x--}}i=s.get(i)}else if(p(i))i=i();else if(i=i(),typeof i!="function"||!p(i)&&!N(i))break}x++;try{f=A(n,i,t,f,s),c(f)}finally{x--}})}function P(e,n,t,o){if(x>O)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=g("",!0),e.appendChild(t));let c=o??null;if(typeof n!="function"){x++;try{c=A(e,n,t,null)}finally{x--}return()=>c}let f=W(n,e,t,c,s=>{c=s});return()=>(f?.(),c)}function A(e,n,t,o,c){if(n==null||typeof n=="boolean")return E(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return E(e,o,t);if(T(n)){let s=g("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(s,o[0]),E(e,o.slice(1),t)):y(e,s,t):o?e.replaceChild(s,o):y(e,s,t),n.then(i=>{s.parentNode===e&&A(e,i,s.nextSibling,s)}).catch(i=>{console.error("Error resolving promise in insertExpression:",i)}),s}let f=typeof n;if(f==="string"||f==="number"){if(f==="number"&&(n=String(n)),Array.isArray(o)){if(o.length===0){let i=g(n);return y(e,i,t),i}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=E(e,o,t)}if(o&&R(o))return o.data=n,o;let s=g(n);return o&&o.parentNode===e?e.replaceChild(s,o):S(e,s)||y(e,s,t),s}if(b(n))return S(e,n)?(H(n),n):Array.isArray(o)?(o.length===0?y(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),E(e,o.slice(1),t)):y(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):y(e,n,t)):y(e,n,t),n);if(Array.isArray(n)){let s=[],i=Array.isArray(o)?o:o?[o]:[],r=[];h(n,s,e,t,!0,c,r);let u=I(e,i,s,t);for(let l of r){let a=P(e,l.sig,l.marker);F(()=>{E(e,a()),l.marker.parentNode===e&&e.removeChild(l.marker)})}return u}if(f==="object"&&n!==null&&typeof n=="object"){let s=n;if("type"in s&&"props"in s){let i=s;if(typeof i.type=="function"){let r=i.type(i.props||{});return A(e,r,t,o)}}}return E(e,o,t)}function h(e,n,t,o,c=!0,f,s){for(let i=0;i<e.length;i++){let r=e[i];if(!(r==null||typeof r=="boolean")){for(;typeof r=="function"&&!T(r)&&!p(r)&&!N(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let u;for(N(r)&&!p(r)?(f||(f=new Map),f.has(r)||f.set(r,r()),u=f.get(r)):u=r();typeof u=="function"&&!T(u)&&!p(u)&&!N(u);)f||(f=new Map),f.has(u)||f.set(u,u()),u=f.get(u);if(u==null||typeof u=="boolean")continue;if(typeof u=="function"){if(p(u)){if(s){let a=g("",!0);n.push(a),s.push({marker:a,sig:u});continue}let l=u();for(;typeof l=="function"&&p(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?h(l,n,t,o,c,f):h([l],n,t,o,c,f);continue}continue}Array.isArray(u)?h(u,n,t,o,c,f,s):h([u],n,t,o,c,f,s);continue}if(T(r)){let u=g("",!0);n.push(u),r.then(l=>{if(u.parentNode){let a=[];if(h([l],a,u.parentNode,void 0,!1,f),a.length>0){u.parentNode.replaceChild(a[0],u);for(let d=1;d<a.length;d++)u.parentNode?.insertBefore(a[d],a[d-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(r)){h(r,n,t,o,c,f,s);continue}if(b(r)){n.push(r);continue}if(typeof r=="object"&&r!==null&&"type"in r&&"props"in r){let u=r;if(typeof u.type=="function"){let l=u.type(u.props||{});Array.isArray(l)?h(l,n,t,o,!1,f):h([l],n,t,o,!1,f);continue}}if(typeof r=="string"||typeof r=="number"){let u=String(r);if(u.trim()===""&&u!==" ")continue;n.push(g(u));continue}n.push(g(String(r)))}}}}function I(e,n,t,o){for(let a=0;a<t.length;a++)t[a].parentNode!==null&&t[a].parentNode!==e&&(t=t.slice(),t[a]=t[a].cloneNode(!0));let c=t.length,f=n.length,s=c,i=0,r=0,u=f>0?n[f-1].nextSibling??void 0:o,l=null;for(;i<f||r<s;){if(n[i]===t[r]){i++,r++;continue}for(;f>i&&s>r&&n[f-1]===t[s-1];)f--,s--;if(f===i){let a=s<c?r?t[r-1].nextSibling??void 0:t[s-r]:u;for(;r<s;)y(e,t[r++],a)}else if(s===r)for(;i<f;)(!l||!l.has(n[i]))&&n[i].parentNode===e&&e.removeChild(n[i]),i++;else if(n[i]===t[s-1]&&t[r]===n[f-1]){let a=n[--f].nextSibling;y(e,t[r++],n[i++].nextSibling),y(e,t[--s],a),n[f]=n[i-1]}else{if(!l){l=new Map;let d=r;for(;d<s;)l.set(t[d],d++)}let a=l.get(n[i]);if(a!=null)if(r<a&&a<s){let d=i,w=1;for(;++d<f&&d<s&&!(!l.has(n[d])||l.get(n[d])!==a+w);)w++;if(w>a-r){let $=n[i];for(;r<a;)y(e,t[r++],$)}else n[i].parentNode===e?e.replaceChild(t[r++],n[i++]):(y(e,t[r++],u),i++)}else i++;else n[i].parentNode===e&&e.removeChild(n[i]),i++}}return t}function E(e,n,t){if(n)if(Array.isArray(n))for(let o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function y(e,n,t){m.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function D(e,n){if(e){if(b(e)){let t=n,o=e;if(!t)return;typeof t=="function"?t(o):typeof t=="object"&&"current"in t&&(t.current=o);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}}function T(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function fe(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,t,o;return K(c=>{t=c,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),P(o,e.children)&&D(e.ref,o)}),B(()=>{t(),o.remove()}),null}export{fe as Portal};
|