essor 0.0.6-beta.10 → 0.0.6-beta.13
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/essor.cjs.js +28 -28
- package/dist/essor.cjs.js.map +1 -1
- package/dist/essor.d.cts +6 -5
- package/dist/essor.d.ts +6 -5
- package/dist/essor.dev.cjs.js +195 -24
- package/dist/essor.dev.esm.js +195 -24
- package/dist/essor.esm.js +3 -3
- package/dist/essor.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/essor.dev.esm.js
CHANGED
|
@@ -16,7 +16,7 @@ var __spreadValues = (a, b) => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
// src/version.ts
|
|
19
|
-
var __essor_version = "0.0.6-beta.
|
|
19
|
+
var __essor_version = "0.0.6-beta.12";
|
|
20
20
|
|
|
21
21
|
// ../shared/dist/essor-shared.js
|
|
22
22
|
var isObject = (val) => val !== null && typeof val === "object";
|
|
@@ -35,9 +35,7 @@ var isPrimitive = (val) => ["string", "number", "boolean", "symbol", "undefined"
|
|
|
35
35
|
function coerceArray(data) {
|
|
36
36
|
return Array.isArray(data) ? data.flat() : [data];
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
return !Object.is(value, oldValue);
|
|
40
|
-
}
|
|
38
|
+
var hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue);
|
|
41
39
|
var noop = Function.prototype;
|
|
42
40
|
function startsWith(str, searchString) {
|
|
43
41
|
return str.indexOf(searchString) === 0;
|
|
@@ -210,7 +208,7 @@ var Signal = class {
|
|
|
210
208
|
return this._value;
|
|
211
209
|
}
|
|
212
210
|
set value(newValue) {
|
|
213
|
-
if (this._value
|
|
211
|
+
if (hasChanged(newValue, this._value)) {
|
|
214
212
|
this._value = newValue;
|
|
215
213
|
trigger(this, "value");
|
|
216
214
|
}
|
|
@@ -245,7 +243,7 @@ var Computed = class {
|
|
|
245
243
|
}
|
|
246
244
|
run() {
|
|
247
245
|
const newValue = this.fn();
|
|
248
|
-
if (newValue
|
|
246
|
+
if (hasChanged(newValue, this._value)) {
|
|
249
247
|
this._value = newValue;
|
|
250
248
|
this._deps.forEach((effect) => effect());
|
|
251
249
|
}
|
|
@@ -278,12 +276,12 @@ function useEffect(fn) {
|
|
|
278
276
|
activeEffect = null;
|
|
279
277
|
};
|
|
280
278
|
}
|
|
281
|
-
function
|
|
279
|
+
function isExclude(key, exclude) {
|
|
282
280
|
return Array.isArray(exclude) ? exclude.includes(key) : isFunction(exclude) ? exclude(key) : false;
|
|
283
281
|
}
|
|
284
282
|
function signalObject(initialValues, exclude) {
|
|
285
283
|
const signals = Object.entries(initialValues).reduce((acc, [key, value]) => {
|
|
286
|
-
acc[key] =
|
|
284
|
+
acc[key] = isExclude(key, exclude) || isSignal(value) ? value : useSignal(value);
|
|
287
285
|
return acc;
|
|
288
286
|
}, {});
|
|
289
287
|
return signals;
|
|
@@ -298,7 +296,7 @@ function unSignal(signal, exclude) {
|
|
|
298
296
|
}
|
|
299
297
|
if (isObject(signal)) {
|
|
300
298
|
return Object.entries(signal).reduce((acc, [key, value]) => {
|
|
301
|
-
if (
|
|
299
|
+
if (isExclude(key, exclude)) {
|
|
302
300
|
acc[key] = value;
|
|
303
301
|
} else {
|
|
304
302
|
acc[key] = isSignal(value) ? value.peek() : value;
|
|
@@ -319,7 +317,7 @@ function unReactive(obj) {
|
|
|
319
317
|
return Object.assign({}, obj);
|
|
320
318
|
}
|
|
321
319
|
var reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
322
|
-
function useReactive(initialValue) {
|
|
320
|
+
function useReactive(initialValue, exclude) {
|
|
323
321
|
if (!isObject(initialValue)) {
|
|
324
322
|
return initialValue;
|
|
325
323
|
}
|
|
@@ -334,6 +332,9 @@ function useReactive(initialValue) {
|
|
|
334
332
|
if (key === REACTIVE_MARKER) return true;
|
|
335
333
|
const getValue = Reflect.get(target, key, receiver);
|
|
336
334
|
const value = isSignal(getValue) ? getValue.value : getValue;
|
|
335
|
+
if (isExclude(key, exclude)) {
|
|
336
|
+
return value;
|
|
337
|
+
}
|
|
337
338
|
track(target, key);
|
|
338
339
|
if (isObject(value)) {
|
|
339
340
|
return useReactive(value);
|
|
@@ -341,6 +342,10 @@ function useReactive(initialValue) {
|
|
|
341
342
|
return value;
|
|
342
343
|
},
|
|
343
344
|
set(target, key, value, receiver) {
|
|
345
|
+
if (isExclude(key, exclude)) {
|
|
346
|
+
Reflect.set(target, key, value, receiver);
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
344
349
|
let oldValue = Reflect.get(target, key, receiver);
|
|
345
350
|
if (isSignal(oldValue)) {
|
|
346
351
|
oldValue = oldValue.value;
|
|
@@ -567,7 +572,7 @@ var _ComponentNode = class _ComponentNode {
|
|
|
567
572
|
return (_b = (_a = this.rootNode) == null ? void 0 : _a.mount(parent, before)) != null ? _b : [];
|
|
568
573
|
}
|
|
569
574
|
_ComponentNode.ref = this;
|
|
570
|
-
this.rootNode = this.template(useReactive(this.proxyProps));
|
|
575
|
+
this.rootNode = this.template(useReactive(this.proxyProps, ["children"]));
|
|
571
576
|
_ComponentNode.ref = null;
|
|
572
577
|
this.mounted = true;
|
|
573
578
|
const mountedNode = (_d = (_c = this.rootNode) == null ? void 0 : _c.mount(parent, before)) != null ? _d : [];
|
|
@@ -607,7 +612,7 @@ var _ComponentNode = class _ComponentNode {
|
|
|
607
612
|
const newValue = (_e = (_d = this.proxyProps)[key]) != null ? _e : _d[key] = useSignal(prop);
|
|
608
613
|
const track2 = this.getNodeTrack(key);
|
|
609
614
|
track2.cleanup = useEffect(() => {
|
|
610
|
-
newValue.value = prop;
|
|
615
|
+
newValue.value = isFunction(prop) ? prop() : prop;
|
|
611
616
|
});
|
|
612
617
|
}
|
|
613
618
|
}
|
|
@@ -619,8 +624,14 @@ _ComponentNode.context = {};
|
|
|
619
624
|
var ComponentNode = _ComponentNode;
|
|
620
625
|
|
|
621
626
|
// src/template/template.ts
|
|
622
|
-
function h(
|
|
623
|
-
|
|
627
|
+
function h(_template, props, key) {
|
|
628
|
+
if (isHtmlTagName(_template)) {
|
|
629
|
+
_template = template(convertToHtmlTag(_template));
|
|
630
|
+
props = {
|
|
631
|
+
1: props
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
return isFunction(_template) ? new ComponentNode(_template, props, key) : new TemplateNode(_template, props, key);
|
|
624
635
|
}
|
|
625
636
|
function isJsxElement(node) {
|
|
626
637
|
return node instanceof ComponentNode || node instanceof TemplateNode;
|
|
@@ -751,6 +762,173 @@ function addEventListener(node, eventName, handler) {
|
|
|
751
762
|
node.addEventListener(eventName, handler);
|
|
752
763
|
return () => node.removeEventListener(eventName, handler);
|
|
753
764
|
}
|
|
765
|
+
var selfClosingTags = [
|
|
766
|
+
"area",
|
|
767
|
+
"base",
|
|
768
|
+
"br",
|
|
769
|
+
"col",
|
|
770
|
+
"embed",
|
|
771
|
+
"hr",
|
|
772
|
+
"img",
|
|
773
|
+
"input",
|
|
774
|
+
"link",
|
|
775
|
+
"meta",
|
|
776
|
+
"param",
|
|
777
|
+
"source",
|
|
778
|
+
"track",
|
|
779
|
+
"wbr"
|
|
780
|
+
];
|
|
781
|
+
function convertToHtmlTag(tag) {
|
|
782
|
+
if (selfClosingTags.includes(tag)) {
|
|
783
|
+
return `<${tag}/>`;
|
|
784
|
+
} else {
|
|
785
|
+
return `<${tag}></${tag}>`;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
var htmlTags = [
|
|
789
|
+
"a",
|
|
790
|
+
"abbr",
|
|
791
|
+
"acronym",
|
|
792
|
+
"address",
|
|
793
|
+
"applet",
|
|
794
|
+
"area",
|
|
795
|
+
"article",
|
|
796
|
+
"aside",
|
|
797
|
+
"audio",
|
|
798
|
+
"b",
|
|
799
|
+
"base",
|
|
800
|
+
"basefont",
|
|
801
|
+
"bdi",
|
|
802
|
+
"bdo",
|
|
803
|
+
"bgsound",
|
|
804
|
+
"big",
|
|
805
|
+
"blink",
|
|
806
|
+
"blockquote",
|
|
807
|
+
"body",
|
|
808
|
+
"br",
|
|
809
|
+
"button",
|
|
810
|
+
"canvas",
|
|
811
|
+
"caption",
|
|
812
|
+
"center",
|
|
813
|
+
"cite",
|
|
814
|
+
"code",
|
|
815
|
+
"col",
|
|
816
|
+
"colgroup",
|
|
817
|
+
"command",
|
|
818
|
+
"content",
|
|
819
|
+
"data",
|
|
820
|
+
"datalist",
|
|
821
|
+
"dd",
|
|
822
|
+
"del",
|
|
823
|
+
"details",
|
|
824
|
+
"dfn",
|
|
825
|
+
"dialog",
|
|
826
|
+
"dir",
|
|
827
|
+
"div",
|
|
828
|
+
"dl",
|
|
829
|
+
"dt",
|
|
830
|
+
"em",
|
|
831
|
+
"embed",
|
|
832
|
+
"fieldset",
|
|
833
|
+
"figcaption",
|
|
834
|
+
"figure",
|
|
835
|
+
"font",
|
|
836
|
+
"footer",
|
|
837
|
+
"form",
|
|
838
|
+
"frame",
|
|
839
|
+
"frameset",
|
|
840
|
+
"h1",
|
|
841
|
+
"h2",
|
|
842
|
+
"h3",
|
|
843
|
+
"h4",
|
|
844
|
+
"h5",
|
|
845
|
+
"h6",
|
|
846
|
+
"head",
|
|
847
|
+
"header",
|
|
848
|
+
"hgroup",
|
|
849
|
+
"hr",
|
|
850
|
+
"html",
|
|
851
|
+
"i",
|
|
852
|
+
"iframe",
|
|
853
|
+
"image",
|
|
854
|
+
"img",
|
|
855
|
+
"input",
|
|
856
|
+
"ins",
|
|
857
|
+
"kbd",
|
|
858
|
+
"keygen",
|
|
859
|
+
"label",
|
|
860
|
+
"legend",
|
|
861
|
+
"li",
|
|
862
|
+
"link",
|
|
863
|
+
"listing",
|
|
864
|
+
"main",
|
|
865
|
+
"map",
|
|
866
|
+
"mark",
|
|
867
|
+
"marquee",
|
|
868
|
+
"menu",
|
|
869
|
+
"menuitem",
|
|
870
|
+
"meta",
|
|
871
|
+
"meter",
|
|
872
|
+
"nav",
|
|
873
|
+
"nobr",
|
|
874
|
+
"noframes",
|
|
875
|
+
"noscript",
|
|
876
|
+
"object",
|
|
877
|
+
"ol",
|
|
878
|
+
"optgroup",
|
|
879
|
+
"option",
|
|
880
|
+
"output",
|
|
881
|
+
"p",
|
|
882
|
+
"param",
|
|
883
|
+
"picture",
|
|
884
|
+
"plaintext",
|
|
885
|
+
"pre",
|
|
886
|
+
"progress",
|
|
887
|
+
"q",
|
|
888
|
+
"rb",
|
|
889
|
+
"rp",
|
|
890
|
+
"rt",
|
|
891
|
+
"rtc",
|
|
892
|
+
"ruby",
|
|
893
|
+
"s",
|
|
894
|
+
"samp",
|
|
895
|
+
"script",
|
|
896
|
+
"section",
|
|
897
|
+
"select",
|
|
898
|
+
"shadow",
|
|
899
|
+
"small",
|
|
900
|
+
"source",
|
|
901
|
+
"spacer",
|
|
902
|
+
"span",
|
|
903
|
+
"strike",
|
|
904
|
+
"strong",
|
|
905
|
+
"style",
|
|
906
|
+
"sub",
|
|
907
|
+
"summary",
|
|
908
|
+
"sup",
|
|
909
|
+
"table",
|
|
910
|
+
"tbody",
|
|
911
|
+
"td",
|
|
912
|
+
"template",
|
|
913
|
+
"textarea",
|
|
914
|
+
"tfoot",
|
|
915
|
+
"th",
|
|
916
|
+
"thead",
|
|
917
|
+
"time",
|
|
918
|
+
"title",
|
|
919
|
+
"tr",
|
|
920
|
+
"track",
|
|
921
|
+
"tt",
|
|
922
|
+
"u",
|
|
923
|
+
"ul",
|
|
924
|
+
"var",
|
|
925
|
+
"video",
|
|
926
|
+
"wbr",
|
|
927
|
+
"xmp"
|
|
928
|
+
];
|
|
929
|
+
function isHtmlTagName(str) {
|
|
930
|
+
return htmlTags.includes(str);
|
|
931
|
+
}
|
|
754
932
|
|
|
755
933
|
// src/template/patch.ts
|
|
756
934
|
function patchChildren(parent, childrenMap, nextChildren, before) {
|
|
@@ -975,11 +1153,8 @@ var TemplateNode = class _TemplateNode {
|
|
|
975
1153
|
const track2 = this.getNodeTrack(trackKey, true, isRoot);
|
|
976
1154
|
patchChild(track2, node, props.children, null);
|
|
977
1155
|
} else {
|
|
978
|
-
props.children.forEach((item, index) => {
|
|
1156
|
+
props.children.filter(Boolean).forEach((item, index) => {
|
|
979
1157
|
var _a;
|
|
980
|
-
if (!item) {
|
|
981
|
-
return;
|
|
982
|
-
}
|
|
983
1158
|
const [child, path] = isArray(item) ? item : [item, null];
|
|
984
1159
|
const before = isNil(path) ? null : (_a = this.treeMap.get(path)) != null ? _a : null;
|
|
985
1160
|
const trackKey = `${key}:${attr}:${index}`;
|
|
@@ -1002,10 +1177,7 @@ var TemplateNode = class _TemplateNode {
|
|
|
1002
1177
|
const track2 = this.getNodeTrack(`${key}:${attr}`);
|
|
1003
1178
|
const val = props[attr];
|
|
1004
1179
|
const triggerValue = isSignal(val) ? val : useSignal(val);
|
|
1005
|
-
|
|
1006
|
-
triggerValue.value = isSignal(val) ? val.value : val;
|
|
1007
|
-
patchAttribute(track2, node, attr, triggerValue.value);
|
|
1008
|
-
});
|
|
1180
|
+
patchAttribute(track2, node, attr, triggerValue.value);
|
|
1009
1181
|
let cleanupBind;
|
|
1010
1182
|
const updateKey = `update${capitalizeFirstLetter(attr)}`;
|
|
1011
1183
|
if (props[updateKey]) {
|
|
@@ -1014,7 +1186,6 @@ var TemplateNode = class _TemplateNode {
|
|
|
1014
1186
|
});
|
|
1015
1187
|
}
|
|
1016
1188
|
track2.cleanup = () => {
|
|
1017
|
-
cleanup && cleanup();
|
|
1018
1189
|
cleanupBind && cleanupBind();
|
|
1019
1190
|
};
|
|
1020
1191
|
}
|
|
@@ -1062,7 +1233,7 @@ function onDestroy(cb) {
|
|
|
1062
1233
|
}
|
|
1063
1234
|
function throwIfOutsideComponent(hook) {
|
|
1064
1235
|
if (!ComponentNode.ref) {
|
|
1065
|
-
|
|
1236
|
+
console.error(
|
|
1066
1237
|
`"${hook}" can only be called within the component function body
|
|
1067
1238
|
and cannot be used in asynchronous or deferred calls.`
|
|
1068
1239
|
);
|
package/dist/essor.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var ke=Object.defineProperty;var ue=Object.getOwnPropertySymbols;var Ce=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable;var le=(e,t,n)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))Ce.call(t,n)&&le(e,n,t[n]);if(ue)for(var n of ue(t))we.call(t,n)&&le(e,n,t[n]);return e};var fe="0.0.6-beta.9";var S=e=>e!==null&&typeof e=="object";var O=Array.isArray;function Me(e){return e===null}function pe(e){return e==null}var h=e=>typeof e=="function";function B(e){return e===!1||e===null||e===void 0||e===""}var K=e=>["string","number","boolean","symbol","undefined"].includes(typeof e)||Me(e);function D(e){return Array.isArray(e)?e.flat():[e]}function de(e,t){return !Object.is(e,t)}var me=Function.prototype;function v(e,t){return e.indexOf(t)===0}function C(e,t=new WeakMap){if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);if(e instanceof Map){let r=new Map;return t.set(e,r),e.forEach((i,s)=>{r.set(C(s,t),C(i,t));}),r}if(e instanceof Set){let r=new Set;return t.set(e,r),e.forEach(i=>{r.add(C(i,t));}),r}let n=Array.isArray(e)?[]:{};t.set(e,n);let o=Object.keys(e);for(let r of o)n[r]=C(e[r],t);return n}function A(e,t,n=new WeakMap){if(K(e)&&K(t))return e===t;if(e===t)return !0;if(e==null||t==null||typeof e!="object"||typeof t!="object"||e.constructor!==t.constructor)return !1;if(n.has(e))return n.get(e)===t;if(n.set(e,t),Array.isArray(e)){if(e.length!==t.length)return !1;for(let[i,s]of e.entries())if(!A(s,t[i],n))return !1;return !0}if(e instanceof Map){if(e.size!==t.size)return !1;for(let[i,s]of e)if(!t.has(i)||!A(s,t.get(i),n))return !1;return !0}if(e instanceof Set){if(e.size!==t.size)return !1;let i=Array.from(e).sort(),s=Array.from(t).sort();for(let[a,c]of i.entries())if(!A(c,s[a],n))return !1;return !0}let o=Object.keys(e),r=new Set(Object.keys(t));if(o.length!==r.size)return !1;for(let i of o)if(!r.has(i)||!A(e[i],t[i],n))return !1;return !0}var he=e=>e.replaceAll(/[A-Z]+/g,(t,n)=>`${n>0?"-":""}${t.toLocaleLowerCase()}`);var ye=e=>e.charAt(0).toUpperCase()+e.slice(1);var q=Array.isArray;var E=null,F=null,Z=new Set,Q=new WeakMap,Y=new Set;function $(e,t){let n=Q.get(e);n||(n=new Map,Q.set(e,n));let o=n.get(t);o||(o=new Set,n.set(t,o)),E&&o.add(E),F&&Z.add(F);}function H(e,t){Z.size>0&&Z.forEach(r=>r.run());let n=Q.get(e);if(!n)return;let o=n.get(t);o&&o.forEach(r=>Y.has(r)&&r());}var I=class{constructor(t){this._value=t;}valueOf(){return $(this,"value"),this._value}toString(){return $(this,"value"),String(this._value)}toJSON(){return this._value}get value(){return $(this,"value"),this._value}set value(t){this._value!==t&&(this._value=t,H(this,"value"));}peek(){return this._value}update(){H(this,"value");}};function j(e){return p(e)?e:new I(e)}function p(e){return e instanceof I}var J=class{constructor(t){this.fn=t;this._deps=new Set;let n=F;F=this,this._value=this.fn(),F=n;}peek(){return this._value}run(){let t=this.fn();t!==this._value&&(this._value=t,this._deps.forEach(n=>n()));}get value(){return E&&this._deps.add(E),$(this,"_value"),this._value}};function ee(e){return new J(e)}function V(e){return e instanceof J}function N(e){function t(){let n=E;E=t,e(),E=n;}return Y.add(t),t(),()=>{Y.delete(t),E=null;}}function ge(e,t){return Array.isArray(t)?t.includes(e):h(t)?t(e):!1}function te(e,t){return Object.entries(e).reduce((o,[r,i])=>(o[r]=ge(r,t)||p(i)?i:j(i),o),{})}function Te(e,t){return e?p(e)?e.peek():q(e)?e.map(n=>Te(n,t)):S(e)?Object.entries(e).reduce((n,[o,r])=>(ge(o,t)?n[o]=r:n[o]=p(r)?r.peek():r,n),{}):e:{}}var ve=Symbol("useReactive");function R(e){return e&&e[ve]===!0}function Ae(e){return R(e)?Object.assign({},e):e}var U=new WeakMap;function L(e){if(!S(e)||R(e))return e;if(U.has(e))return U.get(e);let t={get(o,r,i){if(r===ve)return !0;let s=Reflect.get(o,r,i),a=p(s)?s.value:s;return $(o,r),S(a)?L(a):a},set(o,r,i,s){let a=Reflect.get(o,r,s);p(a)&&(a=a.value),p(i)&&(i=i.value);let c=Reflect.set(o,r,i,s);return de(i,a)&&H(o,r),c},deleteProperty(o,r){let i=Reflect.get(o,r),s=Reflect.deleteProperty(o,r);return i!==void 0&&H(o,r),s}},n=new Proxy(e,t);return U.set(e,n),n}function ne(e,...t){console.warn.apply(console,[`[Essor warn]: ${e}`].concat(t));}function Oe(e,t,n){return je(e,t,n)}function je(e,t,n){let o,r=n==null?void 0:n.deep;if(p(e)||V(e)?o=()=>e.value:R(e)?o=()=>M({},e):O(e)?o=()=>e.map(c=>p(c)||V(c)?c.value:R(c)?M({},c):h(c)?c():ne("Invalid source",c)):h(e)?o=e:(ne("Invalid source type",e),o=me),t&&r){let c=o;o=()=>W(c());}let i,s=()=>{let c=C(o());A(c,i)||(t&&t(c,i),i=K(c)?c:C(c));},a=N(s);return n!=null&&n.immediate&&s(),a}function W(e,t=new Set){return !S(e)||t.has(e)||(t.add(e),O(e)?e.forEach(n=>W(n,t)):e instanceof Map?e.forEach((n,o)=>{W(o,t),W(n,t);}):e instanceof Set?e.forEach(n=>W(n,t)):Object.keys(e).forEach(n=>{W(e[n],t);})),e}var G=0,oe=new Map;function Re(e){let{state:t,getters:n,actions:o}=e,r=M({},t!=null?t:{}),i=L(t!=null?t:{}),s=[],a=[],l=M({state:i},{patch$(u){Object.assign(i,u),s.forEach(f=>f(i)),a.forEach(f=>f(i));},subscribe$(u){s.push(u);},unsubscribe$(u){let f=s.indexOf(u);f!==-1&&s.splice(f,1);},onAction$(u){a.push(u);},reset$(){Object.assign(i,r);}});for(let u in n){let f=n[u];f&&(l[u]=ee(f.bind(i,i)));}for(let u in o){let f=o[u];f&&(l[u]=f.bind(i));}return oe.set(G,l),++G,l}function Le(e){return function(){return oe.has(G)?oe.get(G):Re(e)}}var b=class b{constructor(t,n,o){this.template=t;this.props=n;this.key=o;this.proxyProps={};this.context={};this.emitter=new Set;this.mounted=!1;this.rootNode=null;this.hooks={mounted:new Set,destroy:new Set};this.trackMap=new Map;this.proxyProps=te(n,r=>v(r,"on")||v(r,"update"));}addEventListener(){}removeEventListener(){}get firstChild(){var t,n;return (n=(t=this.rootNode)==null?void 0:t.firstChild)!=null?n:null}get isConnected(){var t,n;return (n=(t=this.rootNode)==null?void 0:t.isConnected)!=null?n:!1}addHook(t,n){var o;(o=this.hooks[t])==null||o.add(n);}getContext(t){return b.context[t]}setContext(t,n){b.context[t]=n;}inheritNode(t){this.context=t.context,this.hooks=t.hooks,Object.assign(this.proxyProps,t.proxyProps),this.rootNode=t.rootNode,this.trackMap=t.trackMap;let n=this.props;this.props=t.props,this.patchProps(n);}unmount(){var t;this.hooks.destroy.forEach(n=>n()),Object.values(this.hooks).forEach(n=>n.clear()),(t=this.rootNode)==null||t.unmount(),this.rootNode=null,this.proxyProps={},this.mounted=!1,this.emitter.forEach(n=>n()),b.context={};}mount(t,n){var r,i,s,a;if(!h(this.template))throw new Error("Template must be a function");if(this.isConnected)return (i=(r=this.rootNode)==null?void 0:r.mount(t,n))!=null?i:[];b.ref=this,this.rootNode=this.template(L(this.proxyProps)),b.ref=null,this.mounted=!0;let o=(a=(s=this.rootNode)==null?void 0:s.mount(t,n))!=null?a:[];return this.hooks.mounted.forEach(c=>c()),this.patchProps(this.props),o}getNodeTrack(t,n){let o=this.trackMap.get(t);return o||(o={cleanup:()=>{}},this.trackMap.set(t,o)),n||o.cleanup(),o}patchProps(t){var n,o,r,i,s;for(let[a,c]of Object.entries(t))if(v(a,"on")&&((n=this.rootNode)!=null&&n.nodes)){let l=a.slice(2).toLowerCase(),u=c,f=g(this.rootNode.nodes[0],l,u);this.emitter.add(f);}else if(a==="ref")p(c)?t[a].value=(o=this.rootNode)==null?void 0:o.nodes[0]:h(c)&&t[a]((r=this.rootNode)==null?void 0:r.nodes[0]);else if(v(a,"update"))t[a]=p(c)?c.value:c;else {let l=(s=(i=this.proxyProps)[a])!=null?s:i[a]=j(c),u=this.getNodeTrack(a);u.cleanup=N(()=>{l.value=c;});}this.props=t;}};b.ref=null,b.context={};var y=b;function We(e,t,n){return h(e)?new y(e,t,n):new P(e,t,n)}function T(e){return e instanceof y||e instanceof P}function Pe(e){let t=document.createElement("template");return t.innerHTML=e,t}function _e(e){return e.children}function re(e){if(T(e)||e instanceof Node)return e;let t=B(e)?"":String(e);return document.createTextNode(t)}function x(e,t,n=null){let o=T(n)?n.firstChild:n;T(t)?t.mount(e,o):o?o.before(t):e.append(t);}function w(e){T(e)?e.unmount():e.parentNode&&e.remove();}function ie(e,t,n){x(e,t,n),w(n);}function se(e,t,n){if(t==="class"){typeof n=="string"?e.className=n:Array.isArray(n)?e.className=n.join(" "):n&&typeof n=="object"&&(e.className=Object.entries(n).reduce((o,[r,i])=>o+(i?` ${r}`:""),"").trim());return}if(t==="style"){if(typeof n=="string")e.style.cssText=n;else if(n&&typeof n=="object"){let o=n;Object.keys(o).forEach(r=>{e.style.setProperty(he(r),String(o[r]));});}return}B(n)?e.removeAttribute(t):n===!0?e.setAttribute(t,""):e.setAttribute(t,String(n));}function Ne(e,t){if(e instanceof HTMLInputElement){if(e.type==="checkbox")return g(e,"change",()=>{t(!!e.checked);});if(e.type==="date")return g(e,"change",()=>{t(e.value?e.value:"");});if(e.type==="file")return g(e,"change",()=>{e.files&&t(e.files);});if(e.type==="number")return g(e,"input",()=>{let n=Number.parseFloat(e.value);t(Number.isNaN(n)?"":String(n));});if(e.type==="radio")return g(e,"change",()=>{t(e.checked?e.value:"");});if(e.type==="text")return g(e,"input",()=>{t(e.value);})}if(e instanceof HTMLSelectElement)return g(e,"change",()=>{t(e.value);});if(e instanceof HTMLTextAreaElement)return g(e,"input",()=>{t(e.value);})}var xe=Promise.resolve();function Fe(e){return e?xe.then(e):xe}function g(e,t,n){return e.addEventListener(t,n),()=>e.removeEventListener(t,n)}function be(e,t,n,o){let r=new Map,i=t.values(),s=e.childNodes.length;if(t.size>0&&n.length===0){if(s===t.size+(o?1:0)){let l=e;l.innerHTML="",o&&x(e,o);}else {let l=document.createRange(),u=i.next().value,f=T(u)?u.firstChild:u;l.setStartBefore(f),o?l.setEndBefore(o):l.setEndAfter(e),l.deleteContents();}return t.forEach(l=>{T(l)&&l.unmount();}),r}let a=[],c=Ke(n);for(let[l,u]of n.entries()){let f=i.next().value,k=z(f,l);for(;f&&!c.has(k);)w(f),t.delete(k),f=i.next().value,k=z(f,l);let _=z(u,l),ae=t.get(_);if(ae&&(u=$e(e,ae,u)),f)if(f){let ce=document.createComment("");x(e,ce,f),a.push([ce,u]);}else x(e,u,o);else x(e,u,o);r.set(_,u);}return a.forEach(([l,u])=>ie(e,u,l)),t.forEach((l,u)=>{l.isConnected&&!r.has(u)&&w(l);}),r}function $e(e,t,n){return t===n?t:T(t)&&T(n)&&t.template===n.template?(n.inheritNode(t),n):t instanceof Text&&n instanceof Text?(t.textContent!==n.textContent&&(t.textContent=n.textContent),t):(ie(e,n,t),n)}function Ke(e){let t=new Map;for(let[n,o]of e.entries()){let r=z(o,n);t.set(r,o);}return t}function z(e,t){let n=e instanceof Element?e.id:void 0,o=n===""?void 0:n;return o!=null?o:`_$${t}$`}var P=class e{constructor(t,n,o){this.template=t;this.props=n;this.key=o;this.treeMap=new Map;this.mounted=!1;this.nodes=[];this.provides={};this.trackMap=new Map;this.parent=null;}get firstChild(){var t;return (t=this.nodes[0])!=null?t:null}get isConnected(){return this.mounted}addEventListener(){}removeEventListener(){}unmount(){this.trackMap.forEach(t=>{var n,o;(n=t.cleanup)==null||n.call(t),(o=t.lastNodes)==null||o.forEach(r=>{t.isRoot?w(r):r instanceof e&&r.unmount();});}),this.trackMap.clear(),this.treeMap.clear(),this.nodes.forEach(t=>w(t)),this.nodes=[],this.mounted=!1;}mount(t,n){var i;if(this.parent=t,this.isConnected)return this.nodes.forEach(s=>x(t,s,n)),this.nodes;let o=this.template.content.cloneNode(!0),r=o.firstChild;return (i=r==null?void 0:r.hasAttribute)!=null&&i.call(r,"_svg_")&&(r.remove(),r==null||r.childNodes.forEach(s=>{o.append(s);})),this.nodes=Array.from(o.childNodes),this.mapNodeTree(t,o),x(t,o,n),this.patchNodes(this.props),this.mounted=!0,this.nodes}mapNodeTree(t,n){let o=1;this.treeMap.set(0,t);let r=i=>{i.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&this.treeMap.set(o++,i);let s=i.firstChild;for(;s;)r(s),s=s.nextSibling;};r(n);}patchNodes(t){for(let n in t){let o=Number(n),r=this.treeMap.get(o);if(r){let i=this.props[n];this.patchNode(n,r,i,o===0);}}this.props=t;}getNodeTrack(t,n,o){var i;let r=this.trackMap.get(t);return r||(r={cleanup:()=>{}},n&&(r.lastNodes=new Map),o&&(r.isRoot=!0),this.trackMap.set(t,r)),(i=r.cleanup)==null||i.call(r),r}inheritNode(t){this.mounted=t.mounted,this.nodes=t.nodes,this.trackMap=t.trackMap,this.treeMap=t.treeMap;let n=this.props;this.props=t.props,this.patchNodes(n);}patchNode(t,n,o,r){for(let i in o)if(i==="children"&&o.children)if(O(o.children))o.children.forEach((s,a)=>{var _;if(!s)return;let[c,l]=O(s)?s:[s,null],u=pe(l)?null:(_=this.treeMap.get(l))!=null?_:null,f=`${t}:${i}:${a}`,k=this.getNodeTrack(f,!0,r);Se(k,n,c,u);});else {let s=`${t}:${i}:0`,a=this.getNodeTrack(s,!0,r);Se(a,n,o.children,null);}else if(i==="ref")p(o[i])?o[i].value=n:h(o[i])&&o[i](n);else if(v(i,"on")){let s=i.slice(2).toLocaleLowerCase(),a=this.getNodeTrack(`${t}:${i}`),c=o[i];a.cleanup=g(n,s,c);}else if(!v(i,"update")){let s=this.getNodeTrack(`${t}:${i}`),a=o[i],c=p(a)?a:j(a),l=N(()=>{c.value=p(a)?a.value:a,He(s,n,i,c.value);}),u,f=`update${ye(i)}`;o[f]&&(u=Ne(n,k=>{o[f](k);})),s.cleanup=()=>{l&&l(),u&&u();};}}};function He(e,t,n,o){let r=t;r.setAttribute&&(h(o)?e.cleanup=N(()=>{se(r,n,o());}):se(r,n,o));}function Se(e,t,n,o){h(n)?e.cleanup=N(()=>{let r=D(n()).map(re);e.lastNodes=be(t,e.lastNodes,r,o);}):D(n).forEach((r,i)=>{let s=re(r);e.lastNodes.set(String(i),s),x(t,s,o);});}function Ie(e){var t;X("onMounted"),(t=y.ref)==null||t.addHook("mounted",e);}function Je(e){var t;X("onDestroy"),(t=y.ref)==null||t.addHook("destroy",e);}function X(e){if(!y.ref)throw new Error(`"${e}" can only be called within the component function body
|
|
2
|
-
and cannot be used in asynchronous or deferred calls.`)}function
|
|
1
|
+
var Me=Object.defineProperty;var fe=Object.getOwnPropertySymbols;var Ae=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable;var pe=(e,t,n)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))Ae.call(t,n)&&pe(e,n,t[n]);if(fe)for(var n of fe(t))Oe.call(t,n)&&pe(e,n,t[n]);return e};var de="0.0.6-beta.12";var N=e=>e!==null&&typeof e=="object";var A=Array.isArray;function je(e){return e===null}function me(e){return e==null}var p=e=>typeof e=="function";function q(e){return e===!1||e===null||e===void 0||e===""}var F=e=>["string","number","boolean","symbol","undefined"].includes(typeof e)||je(e);function U(e){return Array.isArray(e)?e.flat():[e]}var K=(e,t)=>e!==t&&(e===e||t===t),he=Function.prototype;function b(e,t){return e.indexOf(t)===0}function k(e,t=new WeakMap){if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);if(e instanceof Map){let o=new Map;return t.set(e,o),e.forEach((i,s)=>{o.set(k(s,t),k(i,t));}),o}if(e instanceof Set){let o=new Set;return t.set(e,o),e.forEach(i=>{o.add(k(i,t));}),o}let n=Array.isArray(e)?[]:{};t.set(e,n);let r=Object.keys(e);for(let o of r)n[o]=k(e[o],t);return n}function M(e,t,n=new WeakMap){if(F(e)&&F(t))return e===t;if(e===t)return !0;if(e==null||t==null||typeof e!="object"||typeof t!="object"||e.constructor!==t.constructor)return !1;if(n.has(e))return n.get(e)===t;if(n.set(e,t),Array.isArray(e)){if(e.length!==t.length)return !1;for(let[i,s]of e.entries())if(!M(s,t[i],n))return !1;return !0}if(e instanceof Map){if(e.size!==t.size)return !1;for(let[i,s]of e)if(!t.has(i)||!M(s,t.get(i),n))return !1;return !0}if(e instanceof Set){if(e.size!==t.size)return !1;let i=Array.from(e).sort(),s=Array.from(t).sort();for(let[c,a]of i.entries())if(!M(a,s[c],n))return !1;return !0}let r=Object.keys(e),o=new Set(Object.keys(t));if(r.length!==o.size)return !1;for(let i of r)if(!o.has(i)||!M(e[i],t[i],n))return !1;return !0}var ye=e=>e.replaceAll(/[A-Z]+/g,(t,n)=>`${n>0?"-":""}${t.toLocaleLowerCase()}`);var ge=e=>e.charAt(0).toUpperCase()+e.slice(1);var Z=Array.isArray;var S=null,_=null,Y=new Set,ee=new WeakMap,te=new Set;function $(e,t){let n=ee.get(e);n||(n=new Map,ee.set(e,n));let r=n.get(t);r||(r=new Set,n.set(t,r)),S&&r.add(S),_&&Y.add(_);}function I(e,t){Y.size>0&&Y.forEach(o=>o.run());let n=ee.get(e);if(!n)return;let r=n.get(t);r&&r.forEach(o=>te.has(o)&&o());}var J=class{constructor(t){this._value=t;}valueOf(){return $(this,"value"),this._value}toString(){return $(this,"value"),String(this._value)}toJSON(){return this._value}get value(){return $(this,"value"),this._value}set value(t){K(t,this._value)&&(this._value=t,I(this,"value"));}peek(){return this._value}update(){I(this,"value");}};function O(e){return h(e)?e:new J(e)}function h(e){return e instanceof J}var G=class{constructor(t){this.fn=t;this._deps=new Set;let n=_;_=this,this._value=this.fn(),_=n;}peek(){return this._value}run(){let t=this.fn();K(t,this._value)&&(this._value=t,this._deps.forEach(n=>n()));}get value(){return S&&this._deps.add(S),$(this,"_value"),this._value}};function ne(e){return new G(e)}function z(e){return e instanceof G}function E(e){function t(){let n=S;S=t,e(),S=n;}return te.add(t),t(),()=>{te.delete(t),S=null;}}function V(e,t){return Array.isArray(t)?t.includes(e):p(t)?t(e):!1}function re(e,t){return Object.entries(e).reduce((r,[o,i])=>(r[o]=V(o,t)||h(i)?i:O(i),r),{})}function Te(e,t){return e?h(e)?e.peek():Z(e)?e.map(n=>Te(n,t)):N(e)?Object.entries(e).reduce((n,[r,o])=>(V(r,t)?n[r]=o:n[r]=h(o)?o.peek():o,n),{}):e:{}}var be=Symbol("useReactive");function j(e){return e&&e[be]===!0}function Re(e){return j(e)?Object.assign({},e):e}var Q=new WeakMap;function R(e,t){if(!N(e)||j(e))return e;if(Q.has(e))return Q.get(e);let n={get(o,i,s){if(i===be)return !0;let c=Reflect.get(o,i,s),a=h(c)?c.value:c;return V(i,t)?a:($(o,i),N(a)?R(a):a)},set(o,i,s,c){if(V(i,t))return Reflect.set(o,i,s,c),!0;let a=Reflect.get(o,i,c);h(a)&&(a=a.value),h(s)&&(s=s.value);let l=Reflect.set(o,i,s,c);return K(s,a)&&I(o,i),l},deleteProperty(o,i){let s=Reflect.get(o,i),c=Reflect.deleteProperty(o,i);return s!==void 0&&I(o,i),c}},r=new Proxy(e,n);return Q.set(e,r),r}function oe(e,...t){console.warn.apply(console,[`[Essor warn]: ${e}`].concat(t));}function Le(e,t,n){return We(e,t,n)}function We(e,t,n){let r,o=n==null?void 0:n.deep;if(h(e)||z(e)?r=()=>e.value:j(e)?r=()=>w({},e):A(e)?r=()=>e.map(a=>h(a)||z(a)?a.value:j(a)?w({},a):p(a)?a():oe("Invalid source",a)):p(e)?r=e:(oe("Invalid source type",e),r=he),t&&o){let a=r;r=()=>L(a());}let i,s=()=>{let a=k(r());M(a,i)||(t&&t(a,i),i=F(a)?a:k(a));},c=E(s);return n!=null&&n.immediate&&s(),c}function L(e,t=new Set){return !N(e)||t.has(e)||(t.add(e),A(e)?e.forEach(n=>L(n,t)):e instanceof Map?e.forEach((n,r)=>{L(r,t),L(n,t);}):e instanceof Set?e.forEach(n=>L(n,t)):Object.keys(e).forEach(n=>{L(e[n],t);})),e}var X=0,ie=new Map;function Pe(e){let{state:t,getters:n,actions:r}=e,o=w({},t!=null?t:{}),i=R(t!=null?t:{}),s=[],c=[],l=w({state:i},{patch$(u){Object.assign(i,u),s.forEach(f=>f(i)),c.forEach(f=>f(i));},subscribe$(u){s.push(u);},unsubscribe$(u){let f=s.indexOf(u);f!==-1&&s.splice(f,1);},onAction$(u){c.push(u);},reset$(){Object.assign(i,o);}});for(let u in n){let f=n[u];f&&(l[u]=ne(f.bind(i,i)));}for(let u in r){let f=r[u];f&&(l[u]=f.bind(i));}return ie.set(X,l),++X,l}function He(e){return function(){return ie.has(X)?ie.get(X):Pe(e)}}var v=class v{constructor(t,n,r){this.template=t;this.props=n;this.key=r;this.proxyProps={};this.context={};this.emitter=new Set;this.mounted=!1;this.rootNode=null;this.hooks={mounted:new Set,destroy:new Set};this.trackMap=new Map;this.proxyProps=re(n,o=>b(o,"on")||b(o,"update"));}addEventListener(){}removeEventListener(){}get firstChild(){var t,n;return (n=(t=this.rootNode)==null?void 0:t.firstChild)!=null?n:null}get isConnected(){var t,n;return (n=(t=this.rootNode)==null?void 0:t.isConnected)!=null?n:!1}addHook(t,n){var r;(r=this.hooks[t])==null||r.add(n);}getContext(t){return v.context[t]}setContext(t,n){v.context[t]=n;}inheritNode(t){this.context=t.context,this.hooks=t.hooks,Object.assign(this.proxyProps,t.proxyProps),this.rootNode=t.rootNode,this.trackMap=t.trackMap;let n=this.props;this.props=t.props,this.patchProps(n);}unmount(){var t;this.hooks.destroy.forEach(n=>n()),Object.values(this.hooks).forEach(n=>n.clear()),(t=this.rootNode)==null||t.unmount(),this.rootNode=null,this.proxyProps={},this.mounted=!1,this.emitter.forEach(n=>n()),v.context={};}mount(t,n){var o,i,s,c;if(!p(this.template))throw new Error("Template must be a function");if(this.isConnected)return (i=(o=this.rootNode)==null?void 0:o.mount(t,n))!=null?i:[];v.ref=this,this.rootNode=this.template(R(this.proxyProps,["children"])),v.ref=null,this.mounted=!0;let r=(c=(s=this.rootNode)==null?void 0:s.mount(t,n))!=null?c:[];return this.hooks.mounted.forEach(a=>a()),this.patchProps(this.props),r}getNodeTrack(t,n){let r=this.trackMap.get(t);return r||(r={cleanup:()=>{}},this.trackMap.set(t,r)),n||r.cleanup(),r}patchProps(t){var n,r,o,i,s;for(let[c,a]of Object.entries(t))if(b(c,"on")&&((n=this.rootNode)!=null&&n.nodes)){let l=c.slice(2).toLowerCase(),u=a,f=g(this.rootNode.nodes[0],l,u);this.emitter.add(f);}else if(c==="ref")h(a)?t[c].value=(r=this.rootNode)==null?void 0:r.nodes[0]:p(a)&&t[c]((o=this.rootNode)==null?void 0:o.nodes[0]);else if(b(c,"update"))t[c]=h(a)?a.value:a;else {let l=(s=(i=this.proxyProps)[c])!=null?s:i[c]=O(a),u=this.getNodeTrack(c);u.cleanup=E(()=>{l.value=p(a)?a():a;});}this.props=t;}};v.ref=null,v.context={};var y=v;function _e(e,t,n){return Ne(e)&&(e=xe(ve(e)),t={1:t}),p(e)?new y(e,t,n):new W(e,t,n)}function T(e){return e instanceof y||e instanceof W}function xe(e){let t=document.createElement("template");return t.innerHTML=e,t}function $e(e){return e.children}function se(e){if(T(e)||e instanceof Node)return e;let t=q(e)?"":String(e);return document.createTextNode(t)}function x(e,t,n=null){let r=T(n)?n.firstChild:n;T(t)?t.mount(e,r):r?r.before(t):e.append(t);}function C(e){T(e)?e.unmount():e.parentNode&&e.remove();}function ae(e,t,n){x(e,t,n),C(n);}function ce(e,t,n){if(t==="class"){typeof n=="string"?e.className=n:Array.isArray(n)?e.className=n.join(" "):n&&typeof n=="object"&&(e.className=Object.entries(n).reduce((r,[o,i])=>r+(i?` ${o}`:""),"").trim());return}if(t==="style"){if(typeof n=="string")e.style.cssText=n;else if(n&&typeof n=="object"){let r=n;Object.keys(r).forEach(o=>{e.style.setProperty(ye(o),String(r[o]));});}return}q(n)?e.removeAttribute(t):n===!0?e.setAttribute(t,""):e.setAttribute(t,String(n));}function Ee(e,t){if(e instanceof HTMLInputElement){if(e.type==="checkbox")return g(e,"change",()=>{t(!!e.checked);});if(e.type==="date")return g(e,"change",()=>{t(e.value?e.value:"");});if(e.type==="file")return g(e,"change",()=>{e.files&&t(e.files);});if(e.type==="number")return g(e,"input",()=>{let n=Number.parseFloat(e.value);t(Number.isNaN(n)?"":String(n));});if(e.type==="radio")return g(e,"change",()=>{t(e.checked?e.value:"");});if(e.type==="text")return g(e,"input",()=>{t(e.value);})}if(e instanceof HTMLSelectElement)return g(e,"change",()=>{t(e.value);});if(e instanceof HTMLTextAreaElement)return g(e,"input",()=>{t(e.value);})}var Se=Promise.resolve();function Fe(e){return e?Se.then(e):Se}function g(e,t,n){return e.addEventListener(t,n),()=>e.removeEventListener(t,n)}var Ke=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"];function ve(e){return Ke.includes(e)?`<${e}/>`:`<${e}></${e}>`}var Ie=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","bgsound","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","command","content","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","image","img","input","ins","kbd","keygen","label","legend","li","link","listing","main","map","mark","marquee","menu","menuitem","meta","meter","nav","nobr","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","plaintext","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xmp"];function Ne(e){return Ie.includes(e)}function ke(e,t,n,r){let o=new Map,i=t.values(),s=e.childNodes.length;if(t.size>0&&n.length===0){if(s===t.size+(r?1:0)){let l=e;l.innerHTML="",r&&x(e,r);}else {let l=document.createRange(),u=i.next().value,f=T(u)?u.firstChild:u;l.setStartBefore(f),r?l.setEndBefore(r):l.setEndAfter(e),l.deleteContents();}return t.forEach(l=>{T(l)&&l.unmount();}),o}let c=[],a=Ge(n);for(let[l,u]of n.entries()){let f=i.next().value,P=B(f,l);for(;f&&!a.has(P);)C(f),t.delete(P),f=i.next().value,P=B(f,l);let H=B(u,l),ue=t.get(H);if(ue&&(u=Je(e,ue,u)),f)if(f){let le=document.createComment("");x(e,le,f),c.push([le,u]);}else x(e,u,r);else x(e,u,r);o.set(H,u);}return c.forEach(([l,u])=>ae(e,u,l)),t.forEach((l,u)=>{l.isConnected&&!o.has(u)&&C(l);}),o}function Je(e,t,n){return t===n?t:T(t)&&T(n)&&t.template===n.template?(n.inheritNode(t),n):t instanceof Text&&n instanceof Text?(t.textContent!==n.textContent&&(t.textContent=n.textContent),t):(ae(e,n,t),n)}function Ge(e){let t=new Map;for(let[n,r]of e.entries()){let o=B(r,n);t.set(o,r);}return t}function B(e,t){let n=e instanceof Element?e.id:void 0,r=n===""?void 0:n;return r!=null?r:`_$${t}$`}var W=class e{constructor(t,n,r){this.template=t;this.props=n;this.key=r;this.treeMap=new Map;this.mounted=!1;this.nodes=[];this.provides={};this.trackMap=new Map;this.parent=null;}get firstChild(){var t;return (t=this.nodes[0])!=null?t:null}get isConnected(){return this.mounted}addEventListener(){}removeEventListener(){}unmount(){this.trackMap.forEach(t=>{var n,r;(n=t.cleanup)==null||n.call(t),(r=t.lastNodes)==null||r.forEach(o=>{t.isRoot?C(o):o instanceof e&&o.unmount();});}),this.trackMap.clear(),this.treeMap.clear(),this.nodes.forEach(t=>C(t)),this.nodes=[],this.mounted=!1;}mount(t,n){var i;if(this.parent=t,this.isConnected)return this.nodes.forEach(s=>x(t,s,n)),this.nodes;let r=this.template.content.cloneNode(!0),o=r.firstChild;return (i=o==null?void 0:o.hasAttribute)!=null&&i.call(o,"_svg_")&&(o.remove(),o==null||o.childNodes.forEach(s=>{r.append(s);})),this.nodes=Array.from(r.childNodes),this.mapNodeTree(t,r),x(t,r,n),this.patchNodes(this.props),this.mounted=!0,this.nodes}mapNodeTree(t,n){let r=1;this.treeMap.set(0,t);let o=i=>{i.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&this.treeMap.set(r++,i);let s=i.firstChild;for(;s;)o(s),s=s.nextSibling;};o(n);}patchNodes(t){for(let n in t){let r=Number(n),o=this.treeMap.get(r);if(o){let i=this.props[n];this.patchNode(n,o,i,r===0);}}this.props=t;}getNodeTrack(t,n,r){var i;let o=this.trackMap.get(t);return o||(o={cleanup:()=>{}},n&&(o.lastNodes=new Map),r&&(o.isRoot=!0),this.trackMap.set(t,o)),(i=o.cleanup)==null||i.call(o),o}inheritNode(t){this.mounted=t.mounted,this.nodes=t.nodes,this.trackMap=t.trackMap,this.treeMap=t.treeMap;let n=this.props;this.props=t.props,this.patchNodes(n);}patchNode(t,n,r,o){for(let i in r)if(i==="children"&&r.children)if(A(r.children))r.children.filter(Boolean).forEach((s,c)=>{var H;let[a,l]=A(s)?s:[s,null],u=me(l)?null:(H=this.treeMap.get(l))!=null?H:null,f=`${t}:${i}:${c}`,P=this.getNodeTrack(f,!0,o);Ce(P,n,a,u);});else {let s=`${t}:${i}:0`,c=this.getNodeTrack(s,!0,o);Ce(c,n,r.children,null);}else if(i==="ref")h(r[i])?r[i].value=n:p(r[i])&&r[i](n);else if(b(i,"on")){let s=i.slice(2).toLocaleLowerCase(),c=this.getNodeTrack(`${t}:${i}`),a=r[i];c.cleanup=g(n,s,a);}else if(!b(i,"update")){let s=this.getNodeTrack(`${t}:${i}`),c=r[i],a=h(c)?c:O(c);Ve(s,n,i,a.value);let l,u=`update${ge(i)}`;r[u]&&(l=Ee(n,f=>{r[u](f);})),s.cleanup=()=>{l&&l();};}}};function Ve(e,t,n,r){let o=t;o.setAttribute&&(p(r)?e.cleanup=E(()=>{ce(o,n,r());}):ce(o,n,r));}function Ce(e,t,n,r){p(n)?e.cleanup=E(()=>{let o=U(n()).map(se);e.lastNodes=ke(t,e.lastNodes,o,r);}):U(n).forEach((o,i)=>{let s=se(o);e.lastNodes.set(String(i),s),x(t,s,r);});}function ze(e){var t;D("onMounted"),(t=y.ref)==null||t.addHook("mounted",e);}function Xe(e){var t;D("onDestroy"),(t=y.ref)==null||t.addHook("destroy",e);}function D(e){y.ref||console.error(`"${e}" can only be called within the component function body
|
|
2
|
+
and cannot be used in asynchronous or deferred calls.`);}function Be(e,t){var n;D("useProvide"),(n=y.ref)==null||n.setContext(e,t);}function De(e,t){var n;return D("useInject"),((n=y.ref)==null?void 0:n.getContext(e))||t}function qe(){let e=null;return new Proxy({},{get(t,n){return n==="__is_ref"?!0:e},set(t,n,r){return e=r,!0}})}function kn(e=[]){return e.reduce((t,n,r)=>(t[r+1]={template:n},t),{})}function Ue(e){return Object.entries(e).map(([t,n])=>`${t}=${JSON.stringify(n)}`).join(" ")}function we(e,t){if(p(e))return e(t);let n={},r={};return N(e)&&Object.entries(e).forEach(([o,i])=>{let s=t[o];s&&(Object.keys(s).forEach(c=>{b(c,"on")&&p(s[c])&&delete s[c];}),s.children&&(s.children.forEach(([c,a])=>{n[a]=[...n[a]||[],c];}),delete s.children)),r[o]={template:i.template,prop:s};}),Object.entries(r).map(([o,{template:i,prop:s}])=>{let c=i;return s&&(c+=` ${Ue(s)}`),n[o]&&(c+=n[o].map(a=>we(a,s)).join("")),c}).join("")}function Cn(e,t){return we(e,t)}function wn(e,t){t.innerHTML="",e.mount(t);}globalThis&&(globalThis.__essor_version=de);
|
|
3
3
|
|
|
4
|
-
export { y as ComponentNode,
|
|
4
|
+
export { y as ComponentNode, $e as Fragment, W as TemplateNode, de as __essor_version, He as createStore, _e as h, z as isComputed, T as isJsxElement, j as isReactive, h as isSignal, Fe as nextTick, Xe as onDestroy, ze as onMount, Cn as renderToString, re as signalObject, wn as ssgRender, we as ssr, kn as ssrtmpl, xe as template, Re as unReactive, Te as unSignal, ne as useComputed, E as useEffect, De as useInject, Be as useProvide, R as useReactive, qe as useRef, O as useSignal, Le as useWatch };
|
|
5
5
|
//# sourceMappingURL=out.js.map
|
|
6
6
|
//# sourceMappingURL=essor.esm.js.map
|