regor 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +244 -239
- package/dist/regor.d.ts +14 -9
- package/dist/regor.es2015.cjs.js +299 -488
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +296 -485
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +299 -488
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +299 -488
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +296 -485
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +299 -488
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +298 -484
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +295 -481
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +298 -484
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +45 -51
package/dist/regor.es2019.esm.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
4
|
|
|
8
5
|
// src/common/is-what.ts
|
|
9
6
|
var isFunction = (value) => {
|
|
@@ -36,7 +33,8 @@ var errors = {
|
|
|
36
33
|
[1 /* ComponentTemplateNotFound */]: (selector) => `Component template cannot be found. selector: ${selector} .`,
|
|
37
34
|
[2 /* ComposablesRequireScope */]: "Use composables in scope. usage: useScope(() => new MyApp()).",
|
|
38
35
|
[3 /* RequiresRefSourceArgument */]: (name2) => `${name2} requires ref source argument`,
|
|
39
|
-
[4 /* ComputedIsReadOnly */]: "computed is readonly."
|
|
36
|
+
[4 /* ComputedIsReadOnly */]: "computed is readonly.",
|
|
37
|
+
[5 /* PersistRequiresKey */]: "persist requires a string key."
|
|
40
38
|
};
|
|
41
39
|
var getError = (type, ...args) => {
|
|
42
40
|
const msg = errors[type];
|
|
@@ -49,8 +47,7 @@ var bindDataSymbol = Symbol(":regor");
|
|
|
49
47
|
// src/cleanup/getBindData.ts
|
|
50
48
|
var getBindData = (node) => {
|
|
51
49
|
const bindData = node[bindDataSymbol];
|
|
52
|
-
if (bindData)
|
|
53
|
-
return bindData;
|
|
50
|
+
if (bindData) return bindData;
|
|
54
51
|
const newBindData = {
|
|
55
52
|
unbinders: [],
|
|
56
53
|
data: {}
|
|
@@ -76,8 +73,7 @@ var pushScope = () => {
|
|
|
76
73
|
};
|
|
77
74
|
var peekScope = (noThrow) => {
|
|
78
75
|
const scope = scopes[scopes.length - 1];
|
|
79
|
-
if (!scope && !noThrow)
|
|
80
|
-
throw getError(2 /* ComposablesRequireScope */);
|
|
76
|
+
if (!scope && !noThrow) throw getError(2 /* ComposablesRequireScope */);
|
|
81
77
|
return scope;
|
|
82
78
|
};
|
|
83
79
|
var popScope = (context) => {
|
|
@@ -92,8 +88,7 @@ var setScope = (context) => {
|
|
|
92
88
|
const existing = data[scopeSymbol];
|
|
93
89
|
if (existing) {
|
|
94
90
|
const cs = peekScope();
|
|
95
|
-
if (existing === cs)
|
|
96
|
-
return;
|
|
91
|
+
if (existing === cs) return;
|
|
97
92
|
cs.onMounted.length > 0 && existing.onMounted.push(...cs.onMounted);
|
|
98
93
|
cs.onUnmounted.length > 0 && existing.onUnmounted.push(...cs.onUnmounted);
|
|
99
94
|
return;
|
|
@@ -125,8 +120,7 @@ var isRef = (value) => {
|
|
|
125
120
|
var observe = (source, observer, init) => {
|
|
126
121
|
if (!isRef(source))
|
|
127
122
|
throw getError(3 /* RequiresRefSourceArgument */, "observe");
|
|
128
|
-
if (init)
|
|
129
|
-
observer(source());
|
|
123
|
+
if (init) observer(source());
|
|
130
124
|
const srefImpl = source;
|
|
131
125
|
const stop = srefImpl(
|
|
132
126
|
void 0,
|
|
@@ -145,8 +139,7 @@ var unbind = (node) => {
|
|
|
145
139
|
const currentElement = queue.shift();
|
|
146
140
|
unbindSingle(currentElement);
|
|
147
141
|
const childNodes = currentElement.childNodes;
|
|
148
|
-
if (!childNodes)
|
|
149
|
-
continue;
|
|
142
|
+
if (!childNodes) continue;
|
|
150
143
|
for (const item of childNodes) {
|
|
151
144
|
queue.push(item);
|
|
152
145
|
}
|
|
@@ -154,8 +147,7 @@ var unbind = (node) => {
|
|
|
154
147
|
};
|
|
155
148
|
var unbindSingle = (node) => {
|
|
156
149
|
const bindData = node[bindDataSymbol];
|
|
157
|
-
if (!bindData)
|
|
158
|
-
return;
|
|
150
|
+
if (!bindData) return;
|
|
159
151
|
for (const unbinder of bindData.unbinders) {
|
|
160
152
|
unbinder();
|
|
161
153
|
}
|
|
@@ -189,12 +181,9 @@ var warning = (type, ...args) => {
|
|
|
189
181
|
const msg = warnings[type];
|
|
190
182
|
const item = isFunction(msg) ? msg.call(warnings, ...args) : msg;
|
|
191
183
|
const handler = warningHandler.warning;
|
|
192
|
-
if (!handler)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
handler(item);
|
|
196
|
-
else
|
|
197
|
-
handler(item, ...item.args);
|
|
184
|
+
if (!handler) return;
|
|
185
|
+
if (isString(item)) handler(item);
|
|
186
|
+
else handler(item, ...item.args);
|
|
198
187
|
};
|
|
199
188
|
var warningHandler = { warning: console.warn };
|
|
200
189
|
|
|
@@ -233,11 +222,9 @@ var getSwitches = (nodes) => {
|
|
|
233
222
|
return [...set];
|
|
234
223
|
};
|
|
235
224
|
var setSwitchOwner = (owner, switchNodes) => {
|
|
236
|
-
if (!hasSwitch())
|
|
237
|
-
return;
|
|
225
|
+
if (!hasSwitch()) return;
|
|
238
226
|
const switches2 = getSwitches(switchNodes);
|
|
239
|
-
if (switches2.length === 0)
|
|
240
|
-
return;
|
|
227
|
+
if (switches2.length === 0) return;
|
|
241
228
|
switches2.forEach(refSwitch);
|
|
242
229
|
addUnbinder(owner, () => {
|
|
243
230
|
switches2.forEach(removeSwitch);
|
|
@@ -293,8 +280,7 @@ var IfBinder = class {
|
|
|
293
280
|
return isIfElement;
|
|
294
281
|
}
|
|
295
282
|
__isProcessedOrMark(el) {
|
|
296
|
-
if (el[ifMarker])
|
|
297
|
-
return true;
|
|
283
|
+
if (el[ifMarker]) return true;
|
|
298
284
|
el[ifMarker] = true;
|
|
299
285
|
findElements(el, this.__ifSelector).forEach(
|
|
300
286
|
(x) => x[ifMarker] = true
|
|
@@ -325,8 +311,7 @@ var IfBinder = class {
|
|
|
325
311
|
removeNode(x);
|
|
326
312
|
});
|
|
327
313
|
el.remove();
|
|
328
|
-
if (type !== "if")
|
|
329
|
-
el[elseMarker] = 1;
|
|
314
|
+
if (type !== "if") el[elseMarker] = 1;
|
|
330
315
|
const commentEnd = document.createComment(
|
|
331
316
|
`__end__ :${type}${expression != null ? expression : ""}`
|
|
332
317
|
);
|
|
@@ -339,8 +324,7 @@ var IfBinder = class {
|
|
|
339
324
|
};
|
|
340
325
|
}
|
|
341
326
|
__collectElses(el, refresh) {
|
|
342
|
-
if (!el)
|
|
343
|
-
return [];
|
|
327
|
+
if (!el) return [];
|
|
344
328
|
const nextElement = el.nextElementSibling;
|
|
345
329
|
if (el.hasAttribute(this.__else)) {
|
|
346
330
|
el.removeAttribute(this.__else);
|
|
@@ -362,8 +346,7 @@ var IfBinder = class {
|
|
|
362
346
|
];
|
|
363
347
|
} else {
|
|
364
348
|
const expression = el.getAttribute(this.__elseif);
|
|
365
|
-
if (!expression)
|
|
366
|
-
return [];
|
|
349
|
+
if (!expression) return [];
|
|
367
350
|
el.removeAttribute(this.__elseif);
|
|
368
351
|
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
369
352
|
el,
|
|
@@ -472,8 +455,7 @@ var bindChildNodes = (binder, childNodes) => {
|
|
|
472
455
|
var findElements = (element, selector) => {
|
|
473
456
|
var _a;
|
|
474
457
|
const result = element.querySelectorAll(selector);
|
|
475
|
-
if ((_a = element.matches) == null ? void 0 : _a.call(element, selector))
|
|
476
|
-
return [element, ...result];
|
|
458
|
+
if ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) return [element, ...result];
|
|
477
459
|
return result;
|
|
478
460
|
};
|
|
479
461
|
var isTemplate = (node) => node instanceof HTMLTemplateElement;
|
|
@@ -495,8 +477,7 @@ var defineRefValue = (result, isReadOnly) => {
|
|
|
495
477
|
return result();
|
|
496
478
|
},
|
|
497
479
|
set(value) {
|
|
498
|
-
if (isReadOnly)
|
|
499
|
-
throw new Error("value is readonly.");
|
|
480
|
+
if (isReadOnly) throw new Error("value is readonly.");
|
|
500
481
|
return result(value);
|
|
501
482
|
},
|
|
502
483
|
enumerable: true,
|
|
@@ -504,10 +485,8 @@ var defineRefValue = (result, isReadOnly) => {
|
|
|
504
485
|
});
|
|
505
486
|
};
|
|
506
487
|
var isOptionDynamic = (option, dynamic) => {
|
|
507
|
-
if (!option)
|
|
508
|
-
|
|
509
|
-
if (option.startsWith("["))
|
|
510
|
-
return option.substring(1, option.length - 1);
|
|
488
|
+
if (!option) return false;
|
|
489
|
+
if (option.startsWith("[")) return option.substring(1, option.length - 1);
|
|
511
490
|
const len = dynamic.length;
|
|
512
491
|
if (option.startsWith(dynamic)) {
|
|
513
492
|
return option.substring(len, option.length - len);
|
|
@@ -533,19 +512,16 @@ var cacheStringFunction = (fn) => {
|
|
|
533
512
|
};
|
|
534
513
|
var camelizeRE = /-(\w)/g;
|
|
535
514
|
var camelize = cacheStringFunction((str) => {
|
|
536
|
-
if (!str)
|
|
537
|
-
return str;
|
|
515
|
+
if (!str) return str;
|
|
538
516
|
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
539
517
|
});
|
|
540
518
|
var hyphenateRE = /\B([A-Z])/g;
|
|
541
519
|
var hyphenate = cacheStringFunction((str) => {
|
|
542
|
-
if (!str)
|
|
543
|
-
return str;
|
|
520
|
+
if (!str) return str;
|
|
544
521
|
return str.replace(hyphenateRE, "-$1").toLowerCase();
|
|
545
522
|
});
|
|
546
523
|
var capitalize = cacheStringFunction((str) => {
|
|
547
|
-
if (!str)
|
|
548
|
-
return str;
|
|
524
|
+
if (!str) return str;
|
|
549
525
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
550
526
|
});
|
|
551
527
|
|
|
@@ -553,14 +529,12 @@ var capitalize = cacheStringFunction((str) => {
|
|
|
553
529
|
var collectedRefs = [];
|
|
554
530
|
var collectRef = (ref2) => {
|
|
555
531
|
var _a;
|
|
556
|
-
if (collectedRefs.length === 0)
|
|
557
|
-
return;
|
|
532
|
+
if (collectedRefs.length === 0) return;
|
|
558
533
|
(_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
|
|
559
534
|
};
|
|
560
535
|
var watchEffect = (effect) => {
|
|
561
|
-
if (!effect)
|
|
562
|
-
|
|
563
|
-
};
|
|
536
|
+
if (!effect) return () => {
|
|
537
|
+
};
|
|
564
538
|
const terminator = { stop: () => {
|
|
565
539
|
} };
|
|
566
540
|
watchEffectInternal(effect, terminator);
|
|
@@ -568,13 +542,11 @@ var watchEffect = (effect) => {
|
|
|
568
542
|
return terminator.stop;
|
|
569
543
|
};
|
|
570
544
|
var watchEffectInternal = (effect, terminator) => {
|
|
571
|
-
if (!effect)
|
|
572
|
-
return;
|
|
545
|
+
if (!effect) return;
|
|
573
546
|
let stopObservingList = [];
|
|
574
547
|
let isStopped = false;
|
|
575
548
|
const stopWatch = () => {
|
|
576
|
-
for (const stop of stopObservingList)
|
|
577
|
-
stop();
|
|
549
|
+
for (const stop of stopObservingList) stop();
|
|
578
550
|
stopObservingList = [];
|
|
579
551
|
isStopped = true;
|
|
580
552
|
};
|
|
@@ -583,8 +555,7 @@ var watchEffectInternal = (effect, terminator) => {
|
|
|
583
555
|
const set = /* @__PURE__ */ new Set();
|
|
584
556
|
collectedRefs.push(set);
|
|
585
557
|
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
586
|
-
if (isStopped)
|
|
587
|
-
return;
|
|
558
|
+
if (isStopped) return;
|
|
588
559
|
for (const r of [...set]) {
|
|
589
560
|
const stopObserving = observe(r, () => {
|
|
590
561
|
stopWatch();
|
|
@@ -624,15 +595,12 @@ var isRaw = (value) => {
|
|
|
624
595
|
|
|
625
596
|
// src/reactivity/trigger.ts
|
|
626
597
|
var trigger = (source, eventSource, isRecursive) => {
|
|
627
|
-
if (!isRef(source))
|
|
628
|
-
return;
|
|
598
|
+
if (!isRef(source)) return;
|
|
629
599
|
const srefImpl = source;
|
|
630
600
|
srefImpl(void 0, eventSource, 1 /* trigger */);
|
|
631
|
-
if (!isRecursive)
|
|
632
|
-
return;
|
|
601
|
+
if (!isRecursive) return;
|
|
633
602
|
const obj = srefImpl();
|
|
634
|
-
if (!obj)
|
|
635
|
-
return;
|
|
603
|
+
if (!obj) return;
|
|
636
604
|
if (isArray(obj) || isSet(obj)) {
|
|
637
605
|
for (const el of obj) {
|
|
638
606
|
trigger(el, eventSource, true);
|
|
@@ -665,8 +633,7 @@ var createProxy = (originalProto, proxyProto, methodsToPatch4) => {
|
|
|
665
633
|
define(proxyProto, method, function mutator(...args) {
|
|
666
634
|
const result = original.apply(this, args);
|
|
667
635
|
const subscribers = this[srefSymbol];
|
|
668
|
-
for (const subscriber of subscribers)
|
|
669
|
-
trigger(subscriber);
|
|
636
|
+
for (const subscriber of subscribers) trigger(subscriber);
|
|
670
637
|
return result;
|
|
671
638
|
});
|
|
672
639
|
});
|
|
@@ -711,17 +678,14 @@ createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
|
711
678
|
// src/reactivity/sref.ts
|
|
712
679
|
var batchCollector = {};
|
|
713
680
|
var sref = (value) => {
|
|
714
|
-
if (isRef(value) || isRaw(value))
|
|
715
|
-
return value;
|
|
681
|
+
if (isRef(value) || isRaw(value)) return value;
|
|
716
682
|
const refObj = {
|
|
717
683
|
auto: true,
|
|
718
684
|
_value: value
|
|
719
685
|
};
|
|
720
686
|
const createProxy2 = (value2) => {
|
|
721
|
-
if (!isObject(value2))
|
|
722
|
-
|
|
723
|
-
if (srefSymbol in value2)
|
|
724
|
-
return true;
|
|
687
|
+
if (!isObject(value2)) return false;
|
|
688
|
+
if (srefSymbol in value2) return true;
|
|
725
689
|
const isAnArray = isArray(value2);
|
|
726
690
|
if (isAnArray) {
|
|
727
691
|
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
@@ -742,24 +706,22 @@ var sref = (value) => {
|
|
|
742
706
|
const isProxy = createProxy2(value);
|
|
743
707
|
const observers = /* @__PURE__ */ new Set();
|
|
744
708
|
const trigger2 = (newValue, eventSource) => {
|
|
745
|
-
if (batchCollector.
|
|
746
|
-
batchCollector.
|
|
709
|
+
if (batchCollector.stack && batchCollector.stack.length) {
|
|
710
|
+
const current = batchCollector.stack[batchCollector.stack.length - 1];
|
|
711
|
+
current.add(srefFunction);
|
|
747
712
|
return;
|
|
748
713
|
}
|
|
749
|
-
if (observers.size === 0)
|
|
750
|
-
return;
|
|
714
|
+
if (observers.size === 0) return;
|
|
751
715
|
silence(() => {
|
|
752
716
|
for (const callback of [...observers.keys()]) {
|
|
753
|
-
if (!observers.has(callback))
|
|
754
|
-
continue;
|
|
717
|
+
if (!observers.has(callback)) continue;
|
|
755
718
|
callback(newValue, eventSource);
|
|
756
719
|
}
|
|
757
720
|
});
|
|
758
721
|
};
|
|
759
722
|
const attachProxyHandle = (value2) => {
|
|
760
723
|
let proxyHandle = value2[srefSymbol];
|
|
761
|
-
if (!proxyHandle)
|
|
762
|
-
value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
724
|
+
if (!proxyHandle) value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
763
725
|
proxyHandle.add(srefFunction);
|
|
764
726
|
};
|
|
765
727
|
const srefFunction = (...args) => {
|
|
@@ -767,15 +729,12 @@ var sref = (value) => {
|
|
|
767
729
|
let newValue = args[0];
|
|
768
730
|
const eventSource = args[1];
|
|
769
731
|
if (0 in args) {
|
|
770
|
-
if (refObj._value === newValue)
|
|
771
|
-
return newValue;
|
|
732
|
+
if (refObj._value === newValue) return newValue;
|
|
772
733
|
if (isRef(newValue)) {
|
|
773
734
|
newValue = newValue();
|
|
774
|
-
if (refObj._value === newValue)
|
|
775
|
-
return newValue;
|
|
735
|
+
if (refObj._value === newValue) return newValue;
|
|
776
736
|
}
|
|
777
|
-
if (createProxy2(newValue))
|
|
778
|
-
attachProxyHandle(newValue);
|
|
737
|
+
if (createProxy2(newValue)) attachProxyHandle(newValue);
|
|
779
738
|
refObj._value = newValue;
|
|
780
739
|
if (refObj.auto) {
|
|
781
740
|
trigger2(newValue, eventSource);
|
|
@@ -790,9 +749,8 @@ var sref = (value) => {
|
|
|
790
749
|
switch (operation) {
|
|
791
750
|
case 0 /* observe */: {
|
|
792
751
|
const observer = args[3];
|
|
793
|
-
if (!observer)
|
|
794
|
-
|
|
795
|
-
};
|
|
752
|
+
if (!observer) return () => {
|
|
753
|
+
};
|
|
796
754
|
const removeObserver = (observer2) => {
|
|
797
755
|
observers.delete(observer2);
|
|
798
756
|
};
|
|
@@ -822,8 +780,7 @@ var sref = (value) => {
|
|
|
822
780
|
};
|
|
823
781
|
srefFunction[srefSymbol] = 1;
|
|
824
782
|
defineRefValue(srefFunction, false);
|
|
825
|
-
if (isProxy)
|
|
826
|
-
attachProxyHandle(value);
|
|
783
|
+
if (isProxy) attachProxyHandle(value);
|
|
827
784
|
return srefFunction;
|
|
828
785
|
};
|
|
829
786
|
|
|
@@ -850,14 +807,12 @@ var MountList = class {
|
|
|
850
807
|
}
|
|
851
808
|
__setValueMap(item) {
|
|
852
809
|
const value = this.__getKey(item.value);
|
|
853
|
-
if (value)
|
|
854
|
-
this.__valueMap.set(value, item);
|
|
810
|
+
if (value !== void 0) this.__valueMap.set(value, item);
|
|
855
811
|
}
|
|
856
812
|
__deleteValueMap(index) {
|
|
857
813
|
var _a;
|
|
858
814
|
const value = this.__getKey((_a = this.__list[index]) == null ? void 0 : _a.value);
|
|
859
|
-
if (value)
|
|
860
|
-
this.__valueMap.delete(value);
|
|
815
|
+
if (value !== void 0) this.__valueMap.delete(value);
|
|
861
816
|
}
|
|
862
817
|
/**
|
|
863
818
|
* @internal
|
|
@@ -877,8 +832,7 @@ var MountList = class {
|
|
|
877
832
|
}
|
|
878
833
|
__insertAt(index, item) {
|
|
879
834
|
const len = this.__length;
|
|
880
|
-
for (let i = index; i < len; ++i)
|
|
881
|
-
this.__list[i].order = i + 1;
|
|
835
|
+
for (let i = index; i < len; ++i) this.__list[i].order = i + 1;
|
|
882
836
|
item.order = index;
|
|
883
837
|
this.__list.splice(index, 0, item);
|
|
884
838
|
this.__setValueMap(item);
|
|
@@ -896,13 +850,11 @@ var MountList = class {
|
|
|
896
850
|
this.__deleteValueMap(index);
|
|
897
851
|
this.__list.splice(index, 1);
|
|
898
852
|
const len = this.__length;
|
|
899
|
-
for (let i = index; i < len; ++i)
|
|
900
|
-
this.__list[i].order = i;
|
|
853
|
+
for (let i = index; i < len; ++i) this.__list[i].order = i;
|
|
901
854
|
}
|
|
902
855
|
__removeAllAfter(index) {
|
|
903
856
|
const len = this.__length;
|
|
904
|
-
for (let i = index; i < len; ++i)
|
|
905
|
-
this.__deleteValueMap(i);
|
|
857
|
+
for (let i = index; i < len; ++i) this.__deleteValueMap(i);
|
|
906
858
|
this.__list.splice(index);
|
|
907
859
|
}
|
|
908
860
|
__isValueMounted(value) {
|
|
@@ -937,8 +889,7 @@ var _ForBinder = class _ForBinder {
|
|
|
937
889
|
return isForElement;
|
|
938
890
|
}
|
|
939
891
|
__isProcessedOrMark(el) {
|
|
940
|
-
if (el[forMarker])
|
|
941
|
-
return true;
|
|
892
|
+
if (el[forMarker]) return true;
|
|
942
893
|
el[forMarker] = true;
|
|
943
894
|
findElements(el, this.__forSelector).forEach(
|
|
944
895
|
(x) => x[forMarker] = true
|
|
@@ -946,8 +897,7 @@ var _ForBinder = class _ForBinder {
|
|
|
946
897
|
return false;
|
|
947
898
|
}
|
|
948
899
|
__bindFor(el) {
|
|
949
|
-
if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el))
|
|
950
|
-
return;
|
|
900
|
+
if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el)) return;
|
|
951
901
|
const forPath = el.getAttribute(this.__for);
|
|
952
902
|
if (!forPath) {
|
|
953
903
|
warning(0 /* MissingBindingExpression */, this.__for, el);
|
|
@@ -957,10 +907,8 @@ var _ForBinder = class _ForBinder {
|
|
|
957
907
|
this.__bindForToPath(el, forPath);
|
|
958
908
|
}
|
|
959
909
|
__getIterable(obj) {
|
|
960
|
-
if (isNullOrUndefined(obj))
|
|
961
|
-
|
|
962
|
-
if (isFunction(obj))
|
|
963
|
-
obj = obj();
|
|
910
|
+
if (isNullOrUndefined(obj)) return [];
|
|
911
|
+
if (isFunction(obj)) obj = obj();
|
|
964
912
|
if (Symbol.iterator in Object(obj)) {
|
|
965
913
|
return obj;
|
|
966
914
|
}
|
|
@@ -997,8 +945,7 @@ var _ForBinder = class _ForBinder {
|
|
|
997
945
|
const areEqual = (a, b) => getKey(a) === getKey(b);
|
|
998
946
|
const nodes = getNodes(el);
|
|
999
947
|
const parent = el.parentNode;
|
|
1000
|
-
if (!parent)
|
|
1001
|
-
return;
|
|
948
|
+
if (!parent) return;
|
|
1002
949
|
const title = `${this.__for} => ${forPath}`;
|
|
1003
950
|
const commentBegin = new Comment(`__begin__ ${title}`);
|
|
1004
951
|
parent.insertBefore(commentBegin, el);
|
|
@@ -1057,8 +1004,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1057
1004
|
};
|
|
1058
1005
|
const updateDom = (newValues) => {
|
|
1059
1006
|
let len = mountList.__length;
|
|
1060
|
-
if (isFunction(newValues))
|
|
1061
|
-
newValues = newValues();
|
|
1007
|
+
if (isFunction(newValues)) newValues = newValues();
|
|
1062
1008
|
const unrefedNewValue = unref(newValues[0]);
|
|
1063
1009
|
if (isArray(unrefedNewValue) && unrefedNewValue.length === 0) {
|
|
1064
1010
|
unmount(commentBegin, commentEnd);
|
|
@@ -1074,8 +1020,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1074
1020
|
const modify = () => {
|
|
1075
1021
|
if (i2 < len) {
|
|
1076
1022
|
const mountItem = mountList.__get(i2++);
|
|
1077
|
-
if (areEqual(mountItem.value, newValue))
|
|
1078
|
-
return;
|
|
1023
|
+
if (areEqual(mountItem.value, newValue)) return;
|
|
1079
1024
|
const newValueMountPosition = mountList.__lookupValueOrderIfMounted(
|
|
1080
1025
|
getKey(newValue)
|
|
1081
1026
|
);
|
|
@@ -1090,8 +1035,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1090
1035
|
--len;
|
|
1091
1036
|
if (newValueMountPosition > i2 + 1) {
|
|
1092
1037
|
for (let j2 = i2; j2 < newValueMountPosition - 1 && j2 < len; ) {
|
|
1093
|
-
if (areEqual(mountList.__get(i2).value, newValue))
|
|
1094
|
-
break;
|
|
1038
|
+
if (areEqual(mountList.__get(i2).value, newValue)) break;
|
|
1095
1039
|
++j2;
|
|
1096
1040
|
remove(i2);
|
|
1097
1041
|
mountList.__removeAt(i2);
|
|
@@ -1122,8 +1066,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1122
1066
|
}
|
|
1123
1067
|
const j = i2;
|
|
1124
1068
|
len = mountList.__length;
|
|
1125
|
-
while (i2 < len)
|
|
1126
|
-
remove(i2++);
|
|
1069
|
+
while (i2 < len) remove(i2++);
|
|
1127
1070
|
mountList.__removeAllAfter(j);
|
|
1128
1071
|
updateIndexes(firstRemovalOrInsertionIndex);
|
|
1129
1072
|
};
|
|
@@ -1148,16 +1091,13 @@ var _ForBinder = class _ForBinder {
|
|
|
1148
1091
|
__parseForPath(forPath) {
|
|
1149
1092
|
var _a, _b;
|
|
1150
1093
|
const matches = _ForBinder.__forPathRegex.exec(forPath);
|
|
1151
|
-
if (!matches)
|
|
1152
|
-
return;
|
|
1094
|
+
if (!matches) return;
|
|
1153
1095
|
const keys = (matches[1] + ((_a = matches[2]) != null ? _a : "")).split(",").map((key) => key.trim());
|
|
1154
1096
|
const indexOfIndex = keys.length > 1 ? keys.length - 1 : -1;
|
|
1155
1097
|
const index = indexOfIndex !== -1 && (keys[indexOfIndex] === "index" || ((_b = keys[indexOfIndex]) == null ? void 0 : _b.startsWith("#"))) ? keys[indexOfIndex] : "";
|
|
1156
|
-
if (index)
|
|
1157
|
-
keys.splice(indexOfIndex, 1);
|
|
1098
|
+
if (index) keys.splice(indexOfIndex, 1);
|
|
1158
1099
|
const list = matches[3];
|
|
1159
|
-
if (!list || keys.length === 0)
|
|
1160
|
-
return;
|
|
1100
|
+
if (!list || keys.length === 0) return;
|
|
1161
1101
|
const hasDestructuring = /[{[]/.test(forPath);
|
|
1162
1102
|
return {
|
|
1163
1103
|
list,
|
|
@@ -1185,7 +1125,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1185
1125
|
};
|
|
1186
1126
|
}
|
|
1187
1127
|
};
|
|
1188
|
-
__publicField(_ForBinder, "__forPathRegex", /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+(
|
|
1128
|
+
__publicField(_ForBinder, "__forPathRegex", /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+(.*)\s*$/);
|
|
1189
1129
|
var ForBinder = _ForBinder;
|
|
1190
1130
|
|
|
1191
1131
|
// src/bind/DynamicBinder.ts
|
|
@@ -1216,8 +1156,7 @@ var DynamicBinder = class {
|
|
|
1216
1156
|
let expression = el.getAttribute(this.__is);
|
|
1217
1157
|
if (!expression) {
|
|
1218
1158
|
expression = el.getAttribute("is");
|
|
1219
|
-
if (!expression || !expression.startsWith("regor:"))
|
|
1220
|
-
return;
|
|
1159
|
+
if (!expression || !expression.startsWith("regor:")) return;
|
|
1221
1160
|
expression = `'${expression.slice(6)}'`;
|
|
1222
1161
|
el.removeAttribute("is");
|
|
1223
1162
|
}
|
|
@@ -1275,13 +1214,11 @@ var DynamicBinder = class {
|
|
|
1275
1214
|
unmount(commentBegin, commentEnd);
|
|
1276
1215
|
return;
|
|
1277
1216
|
}
|
|
1278
|
-
if (mounted.name === name2)
|
|
1279
|
-
return;
|
|
1217
|
+
if (mounted.name === name2) return;
|
|
1280
1218
|
unmount(commentBegin, commentEnd);
|
|
1281
1219
|
const componentElement = document.createElement(name2);
|
|
1282
1220
|
for (const attr of el.getAttributeNames()) {
|
|
1283
|
-
if (attr === this.__is)
|
|
1284
|
-
continue;
|
|
1221
|
+
if (attr === this.__is) continue;
|
|
1285
1222
|
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1286
1223
|
}
|
|
1287
1224
|
mount2(componentChildNodes, componentElement);
|
|
@@ -1322,8 +1259,7 @@ var propsDirective = {
|
|
|
1322
1259
|
const key = item[0];
|
|
1323
1260
|
const value2 = item[1];
|
|
1324
1261
|
const ctxKey = ctx[key];
|
|
1325
|
-
if (ctxKey === value2)
|
|
1326
|
-
continue;
|
|
1262
|
+
if (ctxKey === value2) continue;
|
|
1327
1263
|
if (isRef(ctxKey)) {
|
|
1328
1264
|
ctxKey(value2);
|
|
1329
1265
|
} else {
|
|
@@ -1353,8 +1289,7 @@ var propsOnceDirective = {
|
|
|
1353
1289
|
const key = item[0];
|
|
1354
1290
|
const value2 = item[1];
|
|
1355
1291
|
const ctxKey = ctx[key];
|
|
1356
|
-
if (ctxKey === value2)
|
|
1357
|
-
continue;
|
|
1292
|
+
if (ctxKey === value2) continue;
|
|
1358
1293
|
if (isRef(ctxKey)) {
|
|
1359
1294
|
ctxKey(value2);
|
|
1360
1295
|
} else {
|
|
@@ -1443,16 +1378,14 @@ var useScope = (context) => {
|
|
|
1443
1378
|
}
|
|
1444
1379
|
};
|
|
1445
1380
|
var isScope = (value) => {
|
|
1446
|
-
if (!isObject(value))
|
|
1447
|
-
return false;
|
|
1381
|
+
if (!isObject(value)) return false;
|
|
1448
1382
|
return scopeSymbol2 in value;
|
|
1449
1383
|
};
|
|
1450
1384
|
|
|
1451
1385
|
// src/reactivity/entangle.ts
|
|
1452
1386
|
var entangle = (r1, r2) => {
|
|
1453
|
-
if (r1 === r2)
|
|
1454
|
-
|
|
1455
|
-
};
|
|
1387
|
+
if (r1 === r2) return () => {
|
|
1388
|
+
};
|
|
1456
1389
|
const stop1 = observe(r1, (v) => r2(v));
|
|
1457
1390
|
const stop2 = observe(r2, (v) => r1(v));
|
|
1458
1391
|
r2(r1());
|
|
@@ -1476,9 +1409,8 @@ var callMounted = (context) => {
|
|
|
1476
1409
|
var singlePropDirective = {
|
|
1477
1410
|
collectRefObj: true,
|
|
1478
1411
|
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
1479
|
-
if (!option)
|
|
1480
|
-
|
|
1481
|
-
};
|
|
1412
|
+
if (!option) return () => {
|
|
1413
|
+
};
|
|
1482
1414
|
const key = camelize(option);
|
|
1483
1415
|
const stopObserving = observe(
|
|
1484
1416
|
parseResult.value,
|
|
@@ -1487,8 +1419,7 @@ var singlePropDirective = {
|
|
|
1487
1419
|
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
1488
1420
|
const ctx = parseResult.context;
|
|
1489
1421
|
const ctxKey = ctx[option];
|
|
1490
|
-
if (ctxKey === value)
|
|
1491
|
-
return;
|
|
1422
|
+
if (ctxKey === value) return;
|
|
1492
1423
|
if (isRef(ctxKey)) {
|
|
1493
1424
|
ctxKey(value);
|
|
1494
1425
|
} else {
|
|
@@ -1525,28 +1456,22 @@ var ComponentBinder = class {
|
|
|
1525
1456
|
...[...registeredComponents.keys()].map(hyphenate),
|
|
1526
1457
|
...[...Object.keys(contextComponents)].map(hyphenate)
|
|
1527
1458
|
].join(",");
|
|
1528
|
-
if (isNullOrWhitespace(selector))
|
|
1529
|
-
return;
|
|
1459
|
+
if (isNullOrWhitespace(selector)) return;
|
|
1530
1460
|
const list = element.querySelectorAll(selector);
|
|
1531
1461
|
const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
|
|
1532
1462
|
for (const component of components) {
|
|
1533
|
-
if (component.hasAttribute(binder.__pre))
|
|
1534
|
-
continue;
|
|
1463
|
+
if (component.hasAttribute(binder.__pre)) continue;
|
|
1535
1464
|
const parent = component.parentNode;
|
|
1536
|
-
if (!parent)
|
|
1537
|
-
continue;
|
|
1465
|
+
if (!parent) continue;
|
|
1538
1466
|
const nextSibling = component.nextSibling;
|
|
1539
1467
|
const tagName = camelize(component.tagName).toUpperCase();
|
|
1540
1468
|
const contextComponent = contextComponents[tagName];
|
|
1541
1469
|
const registeredComponent = contextComponent != null ? contextComponent : registeredComponentsUpperCase.get(tagName);
|
|
1542
|
-
if (!registeredComponent)
|
|
1543
|
-
continue;
|
|
1470
|
+
if (!registeredComponent) continue;
|
|
1544
1471
|
const templateElement = registeredComponent.template;
|
|
1545
|
-
if (!templateElement)
|
|
1546
|
-
continue;
|
|
1472
|
+
if (!templateElement) continue;
|
|
1547
1473
|
const componentParent = component.parentElement;
|
|
1548
|
-
if (!componentParent)
|
|
1549
|
-
continue;
|
|
1474
|
+
if (!componentParent) continue;
|
|
1550
1475
|
const startOfComponent = new Comment(
|
|
1551
1476
|
" begin component: " + component.tagName
|
|
1552
1477
|
);
|
|
@@ -1562,30 +1487,24 @@ var ComponentBinder = class {
|
|
|
1562
1487
|
const hasPropsOnce = component2.hasAttribute(propsOnceName);
|
|
1563
1488
|
parser.__scoped(capturedContext2, () => {
|
|
1564
1489
|
parser.__push(props);
|
|
1565
|
-
if (hasProps)
|
|
1566
|
-
binder.__bind(propsDirective, component2, propsName);
|
|
1490
|
+
if (hasProps) binder.__bind(propsDirective, component2, propsName);
|
|
1567
1491
|
if (hasPropsOnce)
|
|
1568
1492
|
binder.__bind(propsOnceDirective, component2, propsOnceName);
|
|
1569
1493
|
let definedProps = registeredComponent.props;
|
|
1570
|
-
if (!definedProps || definedProps.length === 0)
|
|
1571
|
-
return;
|
|
1494
|
+
if (!definedProps || definedProps.length === 0) return;
|
|
1572
1495
|
definedProps = definedProps.map(camelize);
|
|
1573
1496
|
for (const name2 of definedProps.concat(definedProps.map(hyphenate))) {
|
|
1574
1497
|
const value = component2.getAttribute(name2);
|
|
1575
|
-
if (value === null)
|
|
1576
|
-
continue;
|
|
1498
|
+
if (value === null) continue;
|
|
1577
1499
|
props[camelize(name2)] = value;
|
|
1578
1500
|
component2.removeAttribute(name2);
|
|
1579
1501
|
}
|
|
1580
1502
|
const map = binder.__directiveCollector.__collect(component2, false);
|
|
1581
1503
|
for (const [attrName, item] of map.entries()) {
|
|
1582
1504
|
const [name2, option] = item.__terms;
|
|
1583
|
-
if (!option)
|
|
1584
|
-
|
|
1585
|
-
if (
|
|
1586
|
-
continue;
|
|
1587
|
-
if (name2 !== "." && name2 !== ":" && name2 !== bindName)
|
|
1588
|
-
continue;
|
|
1505
|
+
if (!option) continue;
|
|
1506
|
+
if (!definedProps.includes(camelize(option))) continue;
|
|
1507
|
+
if (name2 !== "." && name2 !== ":" && name2 !== bindName) continue;
|
|
1589
1508
|
binder.__bind(
|
|
1590
1509
|
singlePropDirective,
|
|
1591
1510
|
component2,
|
|
@@ -1617,16 +1536,13 @@ var ComponentBinder = class {
|
|
|
1617
1536
|
for (const [key, propsValue] of Object.entries(props)) {
|
|
1618
1537
|
if (key in componentCtx2) {
|
|
1619
1538
|
const compValue = componentCtx2[key];
|
|
1620
|
-
if (compValue === propsValue)
|
|
1621
|
-
continue;
|
|
1539
|
+
if (compValue === propsValue) continue;
|
|
1622
1540
|
if (head2.entangle && isRef(compValue) && isRef(propsValue)) {
|
|
1623
1541
|
addUnbinder(startOfComponent, entangle(propsValue, compValue));
|
|
1624
1542
|
} else if (isRef(compValue)) {
|
|
1625
1543
|
compValue(propsValue);
|
|
1626
|
-
} else
|
|
1627
|
-
|
|
1628
|
-
} else
|
|
1629
|
-
componentCtx2[key] = propsValue;
|
|
1544
|
+
} else componentCtx2[key] = unref(propsValue);
|
|
1545
|
+
} else componentCtx2[key] = propsValue;
|
|
1630
1546
|
}
|
|
1631
1547
|
(_a2 = head2.onAutoPropsAssigned) == null ? void 0 : _a2.call(head2);
|
|
1632
1548
|
}
|
|
@@ -1649,8 +1565,7 @@ var ComponentBinder = class {
|
|
|
1649
1565
|
name2 = slot.getAttributeNames().filter((x) => x.startsWith("#"))[0];
|
|
1650
1566
|
if (isNullOrWhitespace(name2)) {
|
|
1651
1567
|
name2 = "default";
|
|
1652
|
-
} else
|
|
1653
|
-
name2 = name2.substring(1);
|
|
1568
|
+
} else name2 = name2.substring(1);
|
|
1654
1569
|
}
|
|
1655
1570
|
let compTemplate = component.querySelector(
|
|
1656
1571
|
`template[name='${name2}'], template[\\#${name2}]`
|
|
@@ -1661,8 +1576,7 @@ var ComponentBinder = class {
|
|
|
1661
1576
|
compTemplate = null;
|
|
1662
1577
|
}
|
|
1663
1578
|
const createSwitchContext = (childNodes2) => {
|
|
1664
|
-
if (head.disableSwitch)
|
|
1665
|
-
return;
|
|
1579
|
+
if (head.disableSwitch) return;
|
|
1666
1580
|
parser.__scoped(capturedContext, () => {
|
|
1667
1581
|
parser.__push(componentCtx);
|
|
1668
1582
|
const props = getProps(slot, parser.__capture());
|
|
@@ -1671,8 +1585,7 @@ var ComponentBinder = class {
|
|
|
1671
1585
|
const switchContext = parser.__capture();
|
|
1672
1586
|
const id = addSwitch(switchContext);
|
|
1673
1587
|
for (const child of childNodes2) {
|
|
1674
|
-
if (!isElement(child))
|
|
1675
|
-
continue;
|
|
1588
|
+
if (!isElement(child)) continue;
|
|
1676
1589
|
child.setAttribute(rswitch, id);
|
|
1677
1590
|
refSwitch(id);
|
|
1678
1591
|
addUnbinder(child, () => {
|
|
@@ -1705,8 +1618,7 @@ var ComponentBinder = class {
|
|
|
1705
1618
|
}
|
|
1706
1619
|
};
|
|
1707
1620
|
const expandNestedSlots = (node) => {
|
|
1708
|
-
if (!isElement(node))
|
|
1709
|
-
return;
|
|
1621
|
+
if (!isElement(node)) return;
|
|
1710
1622
|
const slots = node.querySelectorAll("slot");
|
|
1711
1623
|
if (isSlot(node)) {
|
|
1712
1624
|
expandSlot(node);
|
|
@@ -1728,8 +1640,7 @@ var ComponentBinder = class {
|
|
|
1728
1640
|
expandSlots();
|
|
1729
1641
|
componentParent.insertBefore(endOfComponent, nextSibling);
|
|
1730
1642
|
const transferAttributesToTheComponentChild = () => {
|
|
1731
|
-
if (!registeredComponent.inheritAttrs)
|
|
1732
|
-
return;
|
|
1643
|
+
if (!registeredComponent.inheritAttrs) return;
|
|
1733
1644
|
let inheritorChildNodes = childNodes.filter(
|
|
1734
1645
|
(x) => x.nodeType === Node.ELEMENT_NODE
|
|
1735
1646
|
);
|
|
@@ -1738,11 +1649,9 @@ var ComponentBinder = class {
|
|
|
1738
1649
|
(x) => x.hasAttribute(this.__inherit)
|
|
1739
1650
|
);
|
|
1740
1651
|
const inheritor = inheritorChildNodes[0];
|
|
1741
|
-
if (!inheritor)
|
|
1742
|
-
return;
|
|
1652
|
+
if (!inheritor) return;
|
|
1743
1653
|
for (const attrName of component.getAttributeNames()) {
|
|
1744
|
-
if (attrName === propsName || attrName === propsOnceName)
|
|
1745
|
-
continue;
|
|
1654
|
+
if (attrName === propsName || attrName === propsOnceName) continue;
|
|
1746
1655
|
const value = component.getAttribute(attrName);
|
|
1747
1656
|
if (attrName === "class") {
|
|
1748
1657
|
inheritor.classList.add(...value.split(" "));
|
|
@@ -1802,12 +1711,10 @@ var DirectiveElement = class {
|
|
|
1802
1711
|
__parse() {
|
|
1803
1712
|
let name2 = this.__name;
|
|
1804
1713
|
const isPropShortcut = name2.startsWith(".");
|
|
1805
|
-
if (isPropShortcut)
|
|
1806
|
-
name2 = ":" + name2.slice(1);
|
|
1714
|
+
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1807
1715
|
const firstFlagIndex = name2.indexOf(".");
|
|
1808
1716
|
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1809
|
-
if (isNullOrWhitespace(terms[0]))
|
|
1810
|
-
terms[0] = isPropShortcut ? "." : name2[0];
|
|
1717
|
+
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1811
1718
|
if (firstFlagIndex >= 0) {
|
|
1812
1719
|
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1813
1720
|
if (flags.includes("camel")) {
|
|
@@ -1829,21 +1736,18 @@ var DirectiveCollector = class {
|
|
|
1829
1736
|
}
|
|
1830
1737
|
__collect(element, isRecursive) {
|
|
1831
1738
|
const map = /* @__PURE__ */ new Map();
|
|
1832
|
-
if (!isHTMLElement(element))
|
|
1833
|
-
return map;
|
|
1739
|
+
if (!isHTMLElement(element)) return map;
|
|
1834
1740
|
const prefixes2 = this.__prefixes;
|
|
1835
1741
|
const processNode = (node) => {
|
|
1836
1742
|
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1837
1743
|
for (const name2 of names) {
|
|
1838
|
-
if (!map.has(name2))
|
|
1839
|
-
map.set(name2, new DirectiveElement(name2));
|
|
1744
|
+
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1840
1745
|
const item = map.get(name2);
|
|
1841
1746
|
item.__elements.push(node);
|
|
1842
1747
|
}
|
|
1843
1748
|
};
|
|
1844
1749
|
processNode(element);
|
|
1845
|
-
if (!isRecursive)
|
|
1846
|
-
return map;
|
|
1750
|
+
if (!isRecursive) return map;
|
|
1847
1751
|
const nodes = element.querySelectorAll("*");
|
|
1848
1752
|
for (const node of nodes) {
|
|
1849
1753
|
processNode(node);
|
|
@@ -1880,15 +1784,12 @@ var Binder = class {
|
|
|
1880
1784
|
__unwrapTemplates(element) {
|
|
1881
1785
|
const templates = isTemplate(element) ? [element] : element.querySelectorAll("template");
|
|
1882
1786
|
for (const template of templates) {
|
|
1883
|
-
if (template.hasAttribute(this.__pre))
|
|
1884
|
-
continue;
|
|
1787
|
+
if (template.hasAttribute(this.__pre)) continue;
|
|
1885
1788
|
const parent = template.parentNode;
|
|
1886
|
-
if (!parent)
|
|
1887
|
-
continue;
|
|
1789
|
+
if (!parent) continue;
|
|
1888
1790
|
const nextSibling = template.nextSibling;
|
|
1889
1791
|
template.remove();
|
|
1890
|
-
if (!template.content)
|
|
1891
|
-
continue;
|
|
1792
|
+
if (!template.content) continue;
|
|
1892
1793
|
const childNodes = [...template.content.childNodes];
|
|
1893
1794
|
for (const child of childNodes) {
|
|
1894
1795
|
parent.insertBefore(child, nextSibling);
|
|
@@ -1899,12 +1800,9 @@ var Binder = class {
|
|
|
1899
1800
|
__bindDefault(element) {
|
|
1900
1801
|
if (element.nodeType !== Node.ELEMENT_NODE || element.hasAttribute(this.__pre))
|
|
1901
1802
|
return;
|
|
1902
|
-
if (this.__ifBinder.__bindAll(element))
|
|
1903
|
-
|
|
1904
|
-
if (this.
|
|
1905
|
-
return;
|
|
1906
|
-
if (this.__dynamicBinder.__bindAll(element))
|
|
1907
|
-
return;
|
|
1803
|
+
if (this.__ifBinder.__bindAll(element)) return;
|
|
1804
|
+
if (this.__forBinder.__bindAll(element)) return;
|
|
1805
|
+
if (this.__dynamicBinder.__bindAll(element)) return;
|
|
1908
1806
|
this.__componentBinder.__bindAll(element);
|
|
1909
1807
|
this.__unwrapTemplates(element);
|
|
1910
1808
|
this.__bindAttributes(element, true);
|
|
@@ -1926,16 +1824,13 @@ var Binder = class {
|
|
|
1926
1824
|
}
|
|
1927
1825
|
}
|
|
1928
1826
|
__bind(config, el, attribute, _noWarning, option, flags) {
|
|
1929
|
-
if (el.hasAttribute(this.__pre))
|
|
1930
|
-
return;
|
|
1827
|
+
if (el.hasAttribute(this.__pre)) return;
|
|
1931
1828
|
const bindExpression = el.getAttribute(attribute);
|
|
1932
1829
|
el.removeAttribute(attribute);
|
|
1933
1830
|
const getParentSwitch = (el2) => {
|
|
1934
1831
|
const switchId = el2.getAttribute(rswitch);
|
|
1935
|
-
if (switchId)
|
|
1936
|
-
|
|
1937
|
-
if (!el2.parentElement)
|
|
1938
|
-
return null;
|
|
1832
|
+
if (switchId) return switchId;
|
|
1833
|
+
if (!el2.parentElement) return null;
|
|
1939
1834
|
return getParentSwitch(el2.parentElement);
|
|
1940
1835
|
};
|
|
1941
1836
|
if (hasSwitch()) {
|
|
@@ -1950,15 +1845,12 @@ var Binder = class {
|
|
|
1950
1845
|
this.__bindToExpression(config, el, bindExpression, option, flags);
|
|
1951
1846
|
}
|
|
1952
1847
|
__handleTeleport(config, el, valueExpression) {
|
|
1953
|
-
if (config !== teleportDirective)
|
|
1954
|
-
|
|
1955
|
-
if (isNullOrWhitespace(valueExpression))
|
|
1956
|
-
return true;
|
|
1848
|
+
if (config !== teleportDirective) return false;
|
|
1849
|
+
if (isNullOrWhitespace(valueExpression)) return true;
|
|
1957
1850
|
const teleportTo = document.querySelector(valueExpression);
|
|
1958
1851
|
if (teleportTo) {
|
|
1959
1852
|
const parent = el.parentElement;
|
|
1960
|
-
if (!parent)
|
|
1961
|
-
return true;
|
|
1853
|
+
if (!parent) return true;
|
|
1962
1854
|
const placeholder = new Comment(`teleported => '${valueExpression}'`);
|
|
1963
1855
|
parent.insertBefore(placeholder, el);
|
|
1964
1856
|
el.teleportedFrom = placeholder;
|
|
@@ -1972,10 +1864,8 @@ var Binder = class {
|
|
|
1972
1864
|
}
|
|
1973
1865
|
__bindToExpression(config, el, valueExpression, option, flags) {
|
|
1974
1866
|
var _a;
|
|
1975
|
-
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null)
|
|
1976
|
-
|
|
1977
|
-
if (this.__handleTeleport(config, el, valueExpression))
|
|
1978
|
-
return;
|
|
1867
|
+
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null) return;
|
|
1868
|
+
if (this.__handleTeleport(config, el, valueExpression)) return;
|
|
1979
1869
|
const result = this.__parser.__parse(
|
|
1980
1870
|
valueExpression,
|
|
1981
1871
|
config.isLazy,
|
|
@@ -2019,8 +1909,7 @@ var Binder = class {
|
|
|
2019
1909
|
return previousOption;
|
|
2020
1910
|
};
|
|
2021
1911
|
const observeTailChanges = () => {
|
|
2022
|
-
if (!config.onChange)
|
|
2023
|
-
return;
|
|
1912
|
+
if (!config.onChange) return;
|
|
2024
1913
|
const stopObserving = observe(result.value, (_) => {
|
|
2025
1914
|
var _a2;
|
|
2026
1915
|
const pre = previousValues;
|
|
@@ -2037,8 +1926,7 @@ var Binder = class {
|
|
|
2037
1926
|
stopObserverList.push(stopObserving2);
|
|
2038
1927
|
}
|
|
2039
1928
|
};
|
|
2040
|
-
if (!config.once)
|
|
2041
|
-
observeTailChanges();
|
|
1929
|
+
if (!config.once) observeTailChanges();
|
|
2042
1930
|
if (config.onBind)
|
|
2043
1931
|
stopObserverList.push(
|
|
2044
1932
|
config.onBind(
|
|
@@ -2228,8 +2116,7 @@ var Jsep = class {
|
|
|
2228
2116
|
}
|
|
2229
2117
|
__runHook(hookType, hookCalltype, node) {
|
|
2230
2118
|
const hook = this.__hooks[hookType];
|
|
2231
|
-
if (!hook)
|
|
2232
|
-
return node;
|
|
2119
|
+
if (!hook) return node;
|
|
2233
2120
|
const env = { node };
|
|
2234
2121
|
const hookFn = (f) => {
|
|
2235
2122
|
f.call(this, env);
|
|
@@ -2248,8 +2135,7 @@ var Jsep = class {
|
|
|
2248
2135
|
}
|
|
2249
2136
|
parse() {
|
|
2250
2137
|
const nodes = this.__gobbleExpressions();
|
|
2251
|
-
if (nodes.length === 1)
|
|
2252
|
-
return nodes[0];
|
|
2138
|
+
if (nodes.length === 1) return nodes[0];
|
|
2253
2139
|
return {
|
|
2254
2140
|
type: 0 /* Compound */,
|
|
2255
2141
|
body: nodes
|
|
@@ -2865,8 +2751,7 @@ var Jsep = class {
|
|
|
2865
2751
|
this.__updateBinariesToArrows(env.node);
|
|
2866
2752
|
}
|
|
2867
2753
|
__updateBinariesToArrows(node) {
|
|
2868
|
-
if (!node)
|
|
2869
|
-
return;
|
|
2754
|
+
if (!node) return;
|
|
2870
2755
|
Object.values(node).forEach((val) => {
|
|
2871
2756
|
if (val && typeof val === "object") {
|
|
2872
2757
|
this.__updateBinariesToArrows(val);
|
|
@@ -2885,8 +2770,7 @@ var Jsep = class {
|
|
|
2885
2770
|
}
|
|
2886
2771
|
}
|
|
2887
2772
|
__fixAssignmentOperators(env) {
|
|
2888
|
-
if (env.node)
|
|
2889
|
-
this.__updateBinariesToAssignments(env.node);
|
|
2773
|
+
if (env.node) this.__updateBinariesToAssignments(env.node);
|
|
2890
2774
|
}
|
|
2891
2775
|
__updateBinariesToAssignments(node) {
|
|
2892
2776
|
if (assigmentOperatorsSet.has(node.operator)) {
|
|
@@ -2902,12 +2786,10 @@ var Jsep = class {
|
|
|
2902
2786
|
}
|
|
2903
2787
|
}
|
|
2904
2788
|
__gobbleTaggedTemplateIdentifier(env) {
|
|
2905
|
-
if (!env.node)
|
|
2906
|
-
return;
|
|
2789
|
+
if (!env.node) return;
|
|
2907
2790
|
const type = env.node.type;
|
|
2908
2791
|
const condition = (type === 2 /* Identifier */ || type === 3 /* Member */) && this.__isCode(BTICK_CODE);
|
|
2909
|
-
if (!condition)
|
|
2910
|
-
return;
|
|
2792
|
+
if (!condition) return;
|
|
2911
2793
|
env.node = {
|
|
2912
2794
|
type: 17 /* TaggedTemplateExpression */,
|
|
2913
2795
|
tag: env.node,
|
|
@@ -2915,8 +2797,7 @@ var Jsep = class {
|
|
|
2915
2797
|
};
|
|
2916
2798
|
}
|
|
2917
2799
|
__gobbleTemplateLiteral(env) {
|
|
2918
|
-
if (!this.__isCode(BTICK_CODE))
|
|
2919
|
-
return;
|
|
2800
|
+
if (!this.__isCode(BTICK_CODE)) return;
|
|
2920
2801
|
const node = {
|
|
2921
2802
|
type: 19 /* TemplateLiteral */,
|
|
2922
2803
|
quasis: [],
|
|
@@ -2987,8 +2868,7 @@ var Jsep = class {
|
|
|
2987
2868
|
__gobbleNew(env) {
|
|
2988
2869
|
var _a;
|
|
2989
2870
|
const node = env.node;
|
|
2990
|
-
if (!node || node.operator !== "new" || !node.argument)
|
|
2991
|
-
return;
|
|
2871
|
+
if (!node || node.operator !== "new" || !node.argument) return;
|
|
2992
2872
|
if (!node.argument || ![6 /* Call */, 3 /* Member */].includes(node.argument.type))
|
|
2993
2873
|
throw this.__getError("Expected new function()");
|
|
2994
2874
|
env.node = node.argument;
|
|
@@ -2999,8 +2879,7 @@ var Jsep = class {
|
|
|
2999
2879
|
callNode.type = 20 /* NewExpression */;
|
|
3000
2880
|
}
|
|
3001
2881
|
__gobbleRegexLiteral(env) {
|
|
3002
|
-
if (!this.__isCode(FSLASH_CODE))
|
|
3003
|
-
return;
|
|
2882
|
+
if (!this.__isCode(FSLASH_CODE)) return;
|
|
3004
2883
|
const patternIndex = ++this.__index;
|
|
3005
2884
|
let inCharSet = false;
|
|
3006
2885
|
while (this.__index < this.__expr.length) {
|
|
@@ -3101,8 +2980,7 @@ var evalUnaryOp = {
|
|
|
3101
2980
|
// placed here for type safety, never executed,
|
|
3102
2981
|
};
|
|
3103
2982
|
var spreadArgs = (args) => {
|
|
3104
|
-
if (!(args == null ? void 0 : args.some(shouldSpreadArray)))
|
|
3105
|
-
return args;
|
|
2983
|
+
if (!(args == null ? void 0 : args.some(shouldSpreadArray))) return args;
|
|
3106
2984
|
const result = [];
|
|
3107
2985
|
args.forEach(
|
|
3108
2986
|
(x) => shouldSpreadArray(x) ? result.push(...x) : result.push(x)
|
|
@@ -3111,8 +2989,7 @@ var spreadArgs = (args) => {
|
|
|
3111
2989
|
};
|
|
3112
2990
|
var arrayEvaluator = (...args) => spreadArgs(args);
|
|
3113
2991
|
var createLazyContext = (e, context) => {
|
|
3114
|
-
if (!e)
|
|
3115
|
-
return context;
|
|
2992
|
+
if (!e) return context;
|
|
3116
2993
|
const ctx = Object.create(context != null ? context : {});
|
|
3117
2994
|
ctx.$event = e;
|
|
3118
2995
|
return ctx;
|
|
@@ -3267,22 +3144,17 @@ var RegorEval = class {
|
|
|
3267
3144
|
this.__collectRefObj = !!collectRefObj;
|
|
3268
3145
|
}
|
|
3269
3146
|
__findContext(name2, context) {
|
|
3270
|
-
if (context && name2 in context)
|
|
3271
|
-
return context;
|
|
3147
|
+
if (context && name2 in context) return context;
|
|
3272
3148
|
for (const ctx of this.__contexts) {
|
|
3273
|
-
if (name2 in ctx)
|
|
3274
|
-
return ctx;
|
|
3149
|
+
if (name2 in ctx) return ctx;
|
|
3275
3150
|
}
|
|
3276
3151
|
return void 0;
|
|
3277
3152
|
}
|
|
3278
3153
|
[2 /* Identifier */](expr, _, context) {
|
|
3279
3154
|
const name2 = expr.name;
|
|
3280
|
-
if (name2 === "$root")
|
|
3281
|
-
|
|
3282
|
-
if (name2 === "$
|
|
3283
|
-
return this.__contexts[1];
|
|
3284
|
-
if (name2 === "$ctx")
|
|
3285
|
-
return [...this.__contexts];
|
|
3155
|
+
if (name2 === "$root") return this.__contexts[this.__contexts.length - 1];
|
|
3156
|
+
if (name2 === "$parent") return this.__contexts[1];
|
|
3157
|
+
if (name2 === "$ctx") return [...this.__contexts];
|
|
3286
3158
|
if (context && name2 in context) {
|
|
3287
3159
|
this.__lastEvaluatedValueBeforeUnref = context[name2];
|
|
3288
3160
|
return associateThis(unref(context[name2]), context);
|
|
@@ -3424,8 +3296,7 @@ var RegorEval = class {
|
|
|
3424
3296
|
if (arg.type === 2 /* Identifier */) {
|
|
3425
3297
|
const name2 = arg.name;
|
|
3426
3298
|
const ctx = this.__findContext(name2, context);
|
|
3427
|
-
if (isNullOrUndefined(ctx))
|
|
3428
|
-
return void 0;
|
|
3299
|
+
if (isNullOrUndefined(ctx)) return void 0;
|
|
3429
3300
|
return updater[op](ctx, name2);
|
|
3430
3301
|
}
|
|
3431
3302
|
if (arg.type === 3 /* Member */) {
|
|
@@ -3443,8 +3314,7 @@ var RegorEval = class {
|
|
|
3443
3314
|
if (arg.type === 2 /* Identifier */) {
|
|
3444
3315
|
const name2 = arg.name;
|
|
3445
3316
|
const ctx = this.__findContext(name2, context);
|
|
3446
|
-
if (isNullOrUndefined(ctx))
|
|
3447
|
-
return void 0;
|
|
3317
|
+
if (isNullOrUndefined(ctx)) return void 0;
|
|
3448
3318
|
const value = this.__eval(expr.right, depth, context);
|
|
3449
3319
|
return applyAssigment[op](ctx, name2, value);
|
|
3450
3320
|
}
|
|
@@ -3460,8 +3330,7 @@ var RegorEval = class {
|
|
|
3460
3330
|
}
|
|
3461
3331
|
[14 /* Spread */](expr, depth, context) {
|
|
3462
3332
|
const spreaded = this.__eval(expr.argument, depth, context);
|
|
3463
|
-
if (isArray(spreaded))
|
|
3464
|
-
spreaded.s = spreadElementSymbol;
|
|
3333
|
+
if (isArray(spreaded)) spreaded.s = spreadElementSymbol;
|
|
3465
3334
|
return spreaded;
|
|
3466
3335
|
}
|
|
3467
3336
|
[17 /* TaggedTemplateExpression */](expr, depth, context) {
|
|
@@ -3549,8 +3418,7 @@ var RegorEval = class {
|
|
|
3549
3418
|
}
|
|
3550
3419
|
__transformLazy(depth, context, evaluator, ...args) {
|
|
3551
3420
|
const isLazy = this.__isLazy;
|
|
3552
|
-
if (!isLazy)
|
|
3553
|
-
return this.__transform(depth, context, evaluator, ...args);
|
|
3421
|
+
if (!isLazy) return this.__transform(depth, context, evaluator, ...args);
|
|
3554
3422
|
const evaluatedArgs = args.map(
|
|
3555
3423
|
(arg, i) => arg && (arg.type !== 15 /* Arrow */ && isLazy(i, depth) ? (e) => this.__eval(arg, depth, createLazyContext(e, context)) : this.__eval(arg, depth, context))
|
|
3556
3424
|
);
|
|
@@ -3602,8 +3470,7 @@ var Parser = class {
|
|
|
3602
3470
|
refs: [],
|
|
3603
3471
|
context: this.__contexts[0]
|
|
3604
3472
|
};
|
|
3605
|
-
if (isNullOrWhitespace(expression))
|
|
3606
|
-
return result;
|
|
3473
|
+
if (isNullOrWhitespace(expression)) return result;
|
|
3607
3474
|
const globalContext = this.__config.globalContext;
|
|
3608
3475
|
const refs = [];
|
|
3609
3476
|
const evaluate = (expr, contexts, collectRefs2, context) => {
|
|
@@ -3712,8 +3579,7 @@ var attrDirective = {
|
|
|
3712
3579
|
onChange: (el, values, previousValues, option, previousOption, flags) => {
|
|
3713
3580
|
var _a;
|
|
3714
3581
|
if (option) {
|
|
3715
|
-
if (flags && flags.includes("camel"))
|
|
3716
|
-
option = camelize(option);
|
|
3582
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3717
3583
|
patchAttribute(el, option, values[0], previousOption);
|
|
3718
3584
|
return;
|
|
3719
3585
|
}
|
|
@@ -3799,25 +3665,22 @@ var patchClass = (el, next, prev) => {
|
|
|
3799
3665
|
if (next && !isClassString) {
|
|
3800
3666
|
if (prev && !isPrevClassString) {
|
|
3801
3667
|
for (const key in prev) {
|
|
3802
|
-
if (!(key in next)) {
|
|
3668
|
+
if (!(key in next) || !next[key]) {
|
|
3803
3669
|
classList.remove(key);
|
|
3804
3670
|
}
|
|
3805
3671
|
}
|
|
3806
3672
|
}
|
|
3807
3673
|
for (const key in next) {
|
|
3808
|
-
if (next[key])
|
|
3809
|
-
classList.add(key);
|
|
3674
|
+
if (next[key]) classList.add(key);
|
|
3810
3675
|
}
|
|
3811
3676
|
} else {
|
|
3812
3677
|
if (isClassString) {
|
|
3813
3678
|
if (prev !== next) {
|
|
3814
|
-
if (isPrevClassString)
|
|
3815
|
-
classList.remove(...prev == null ? void 0 : prev.split(","));
|
|
3679
|
+
if (isPrevClassString) classList.remove(...prev == null ? void 0 : prev.split(","));
|
|
3816
3680
|
classList.add(...next.split(","));
|
|
3817
3681
|
}
|
|
3818
3682
|
} else if (prev) {
|
|
3819
|
-
if (isPrevClassString)
|
|
3820
|
-
classList.remove(...prev == null ? void 0 : prev.split(","));
|
|
3683
|
+
if (isPrevClassString) classList.remove(...prev == null ? void 0 : prev.split(","));
|
|
3821
3684
|
}
|
|
3822
3685
|
}
|
|
3823
3686
|
};
|
|
@@ -3826,17 +3689,14 @@ var patchClass = (el, next, prev) => {
|
|
|
3826
3689
|
var htmlDirective = {
|
|
3827
3690
|
onChange: (el, values) => {
|
|
3828
3691
|
const [value, replacer] = values;
|
|
3829
|
-
if (isFunction(replacer))
|
|
3830
|
-
|
|
3831
|
-
else
|
|
3832
|
-
el.innerHTML = value == null ? void 0 : value.toString();
|
|
3692
|
+
if (isFunction(replacer)) replacer(el, value);
|
|
3693
|
+
else el.innerHTML = value == null ? void 0 : value.toString();
|
|
3833
3694
|
}
|
|
3834
3695
|
};
|
|
3835
3696
|
|
|
3836
3697
|
// src/common/looseEqual.ts
|
|
3837
3698
|
function looseCompareArrays(a, b) {
|
|
3838
|
-
if (a.length !== b.length)
|
|
3839
|
-
return false;
|
|
3699
|
+
if (a.length !== b.length) return false;
|
|
3840
3700
|
let equal = true;
|
|
3841
3701
|
for (let i = 0; equal && i < a.length; i++) {
|
|
3842
3702
|
equal = looseEqual(a[i], b[i]);
|
|
@@ -3844,8 +3704,7 @@ function looseCompareArrays(a, b) {
|
|
|
3844
3704
|
return equal;
|
|
3845
3705
|
}
|
|
3846
3706
|
function looseEqual(a, b) {
|
|
3847
|
-
if (a === b)
|
|
3848
|
-
return true;
|
|
3707
|
+
if (a === b) return true;
|
|
3849
3708
|
let aValidType = isDate(a);
|
|
3850
3709
|
let bValidType = isDate(b);
|
|
3851
3710
|
if (aValidType || bValidType) {
|
|
@@ -3951,8 +3810,7 @@ var updateDomElementValue = (el, value) => {
|
|
|
3951
3810
|
}
|
|
3952
3811
|
} else {
|
|
3953
3812
|
if (looseEqual(getValue(option), value)) {
|
|
3954
|
-
if (el.selectedIndex !== i)
|
|
3955
|
-
el.selectedIndex = i;
|
|
3813
|
+
if (el.selectedIndex !== i) el.selectedIndex = i;
|
|
3956
3814
|
return;
|
|
3957
3815
|
}
|
|
3958
3816
|
}
|
|
@@ -3965,10 +3823,8 @@ var updateDomElementValue = (el, value) => {
|
|
|
3965
3823
|
}
|
|
3966
3824
|
};
|
|
3967
3825
|
var getFlags = (flag) => {
|
|
3968
|
-
if (isRef(flag))
|
|
3969
|
-
|
|
3970
|
-
if (isFunction(flag))
|
|
3971
|
-
flag = flag();
|
|
3826
|
+
if (isRef(flag)) flag = flag();
|
|
3827
|
+
if (isFunction(flag)) flag = flag();
|
|
3972
3828
|
if (!flag)
|
|
3973
3829
|
return {
|
|
3974
3830
|
trim: false,
|
|
@@ -4002,7 +3858,7 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
|
|
|
4002
3858
|
const f1 = getFlags(directiveFlags == null ? void 0 : directiveFlags.join(","));
|
|
4003
3859
|
const f2 = getFlags(parsedValue()[1]);
|
|
4004
3860
|
const flags = {
|
|
4005
|
-
int: f1.int ||
|
|
3861
|
+
int: f1.int || f2.int,
|
|
4006
3862
|
lazy: f1.lazy || f2.lazy,
|
|
4007
3863
|
number: f1.number || f2.number,
|
|
4008
3864
|
trim: f1.trim || f2.trim
|
|
@@ -4034,8 +3890,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4034
3890
|
const eventType = isLazy ? "change" : "input";
|
|
4035
3891
|
const isNumber = isNumberInput(el);
|
|
4036
3892
|
const trimmer = () => {
|
|
4037
|
-
if (!flags.trim && !getFlags(parsedValue()[1]).trim)
|
|
4038
|
-
return;
|
|
3893
|
+
if (!flags.trim && !getFlags(parsedValue()[1]).trim) return;
|
|
4039
3894
|
el.value = el.value.trim();
|
|
4040
3895
|
};
|
|
4041
3896
|
const onCompositionStart = (e) => {
|
|
@@ -4058,8 +3913,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4058
3913
|
};
|
|
4059
3914
|
const listener = (event) => {
|
|
4060
3915
|
const target = event.target;
|
|
4061
|
-
if (!target || target.composing)
|
|
4062
|
-
return;
|
|
3916
|
+
if (!target || target.composing) return;
|
|
4063
3917
|
let value = target.value;
|
|
4064
3918
|
const flags2 = getFlags(parsedValue()[1]);
|
|
4065
3919
|
if (isNumber || flags2.number || flags2.int) {
|
|
@@ -4070,15 +3924,12 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4070
3924
|
if (endsWithDecimalSeparator) {
|
|
4071
3925
|
value += "0";
|
|
4072
3926
|
value = parseFloat(value);
|
|
4073
|
-
if (isNaN(value))
|
|
4074
|
-
|
|
4075
|
-
else if (modelRef() === value)
|
|
4076
|
-
return;
|
|
3927
|
+
if (isNaN(value)) value = "";
|
|
3928
|
+
else if (modelRef() === value) return;
|
|
4077
3929
|
}
|
|
4078
3930
|
value = parseFloat(value);
|
|
4079
3931
|
}
|
|
4080
|
-
if (isNaN(value))
|
|
4081
|
-
value = "";
|
|
3932
|
+
if (isNaN(value)) value = "";
|
|
4082
3933
|
el.value = value;
|
|
4083
3934
|
} else if (flags2.trim) {
|
|
4084
3935
|
value = value.trim();
|
|
@@ -4135,8 +3986,7 @@ var getCheckboxValue = (el, checked) => {
|
|
|
4135
3986
|
return el[key];
|
|
4136
3987
|
}
|
|
4137
3988
|
const attrKey = checked ? trueValueAttrKey : falseValueAttrKey;
|
|
4138
|
-
if (el.hasAttribute(attrKey))
|
|
4139
|
-
return el.getAttribute(attrKey);
|
|
3989
|
+
if (el.hasAttribute(attrKey)) return el.getAttribute(attrKey);
|
|
4140
3990
|
return checked;
|
|
4141
3991
|
};
|
|
4142
3992
|
var getCheckboxChecked = (el, value) => {
|
|
@@ -4178,8 +4028,7 @@ var handleSelect = (el, modelRef, parsedValue) => {
|
|
|
4178
4028
|
pause(modelRef);
|
|
4179
4029
|
if (isSet(modelValue)) {
|
|
4180
4030
|
modelValue.clear();
|
|
4181
|
-
for (const sel of selectedValue)
|
|
4182
|
-
modelValue.add(sel);
|
|
4031
|
+
for (const sel of selectedValue) modelValue.add(sel);
|
|
4183
4032
|
} else if (isArray(modelValue)) {
|
|
4184
4033
|
modelValue.splice(0);
|
|
4185
4034
|
modelValue.push(...selectedValue);
|
|
@@ -4231,9 +4080,8 @@ var onDirective = {
|
|
|
4231
4080
|
if (dynamicOption) {
|
|
4232
4081
|
const values2 = parseResult.value();
|
|
4233
4082
|
const option2 = unref(dynamicOption.value()[0]);
|
|
4234
|
-
if (!isString(option2))
|
|
4235
|
-
|
|
4236
|
-
};
|
|
4083
|
+
if (!isString(option2)) return () => {
|
|
4084
|
+
};
|
|
4237
4085
|
return attachEventListener(
|
|
4238
4086
|
el,
|
|
4239
4087
|
camelize(option2),
|
|
@@ -4257,18 +4105,15 @@ var onDirective = {
|
|
|
4257
4105
|
const len = values.length;
|
|
4258
4106
|
for (let i = 0; i < len; ++i) {
|
|
4259
4107
|
let next = values[i];
|
|
4260
|
-
if (isFunction(next))
|
|
4261
|
-
next = next();
|
|
4108
|
+
if (isFunction(next)) next = next();
|
|
4262
4109
|
if (isObject(next)) {
|
|
4263
4110
|
for (const item of Object.entries(next)) {
|
|
4264
4111
|
const eventType = item[0];
|
|
4265
4112
|
const method = () => {
|
|
4266
4113
|
let obj = parseResult.value()[i];
|
|
4267
|
-
if (isFunction(obj))
|
|
4268
|
-
obj = obj();
|
|
4114
|
+
if (isFunction(obj)) obj = obj();
|
|
4269
4115
|
obj = obj[eventType];
|
|
4270
|
-
if (isFunction(obj))
|
|
4271
|
-
obj = obj();
|
|
4116
|
+
if (isFunction(obj)) obj = obj();
|
|
4272
4117
|
return obj;
|
|
4273
4118
|
};
|
|
4274
4119
|
const flags2 = next[eventType + "_flags"];
|
|
@@ -4292,22 +4137,17 @@ var getShouldExecuteEvent = (eventType, flags) => {
|
|
|
4292
4137
|
const isAlt = parts.includes("alt");
|
|
4293
4138
|
const isMeta = parts.includes("meta");
|
|
4294
4139
|
const checkModifiers = (e) => {
|
|
4295
|
-
if (isCtrl && !e.ctrlKey)
|
|
4296
|
-
|
|
4297
|
-
if (
|
|
4298
|
-
|
|
4299
|
-
if (isAlt && !e.altKey)
|
|
4300
|
-
return false;
|
|
4301
|
-
if (isMeta && !e.metaKey)
|
|
4302
|
-
return false;
|
|
4140
|
+
if (isCtrl && !e.ctrlKey) return false;
|
|
4141
|
+
if (isShift && !e.shiftKey) return false;
|
|
4142
|
+
if (isAlt && !e.altKey) return false;
|
|
4143
|
+
if (isMeta && !e.metaKey) return false;
|
|
4303
4144
|
return true;
|
|
4304
4145
|
};
|
|
4305
4146
|
if (keyType) {
|
|
4306
4147
|
return [
|
|
4307
4148
|
eventType,
|
|
4308
4149
|
(e) => {
|
|
4309
|
-
if (!checkModifiers(e))
|
|
4310
|
-
return false;
|
|
4150
|
+
if (!checkModifiers(e)) return false;
|
|
4311
4151
|
return e.key.toUpperCase() === keyType.toUpperCase();
|
|
4312
4152
|
}
|
|
4313
4153
|
];
|
|
@@ -4331,15 +4171,11 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4331
4171
|
let shouldExecuteEvent;
|
|
4332
4172
|
[eventType, shouldExecuteEvent] = getShouldExecuteEvent(eventType, flags);
|
|
4333
4173
|
const execute = (e) => {
|
|
4334
|
-
if (!shouldExecuteEvent(e))
|
|
4335
|
-
|
|
4336
|
-
if (!method && eventType === "submit" && (flag == null ? void 0 : flag.prevent))
|
|
4337
|
-
return;
|
|
4174
|
+
if (!shouldExecuteEvent(e)) return;
|
|
4175
|
+
if (!method && eventType === "submit" && (flag == null ? void 0 : flag.prevent)) return;
|
|
4338
4176
|
let r = method(e);
|
|
4339
|
-
if (isFunction(r))
|
|
4340
|
-
|
|
4341
|
-
if (isFunction(r))
|
|
4342
|
-
r(e);
|
|
4177
|
+
if (isFunction(r)) r = r(e);
|
|
4178
|
+
if (isFunction(r)) r(e);
|
|
4343
4179
|
};
|
|
4344
4180
|
const unbinder = () => {
|
|
4345
4181
|
el.removeEventListener(eventType, listener, options);
|
|
@@ -4350,22 +4186,15 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4350
4186
|
return;
|
|
4351
4187
|
}
|
|
4352
4188
|
try {
|
|
4353
|
-
if (flag.left && e.button !==
|
|
4354
|
-
|
|
4355
|
-
if (flag.
|
|
4356
|
-
|
|
4357
|
-
if (flag.
|
|
4358
|
-
|
|
4359
|
-
if (flag.self && e.target !== el)
|
|
4360
|
-
return;
|
|
4361
|
-
if (flag.stop)
|
|
4362
|
-
e.stopPropagation();
|
|
4363
|
-
if (flag.prevent)
|
|
4364
|
-
e.preventDefault();
|
|
4189
|
+
if (flag.left && e.button !== 0) return;
|
|
4190
|
+
if (flag.middle && e.button !== 1) return;
|
|
4191
|
+
if (flag.right && e.button !== 2) return;
|
|
4192
|
+
if (flag.self && e.target !== el) return;
|
|
4193
|
+
if (flag.stop) e.stopPropagation();
|
|
4194
|
+
if (flag.prevent) e.preventDefault();
|
|
4365
4195
|
execute(e);
|
|
4366
4196
|
} finally {
|
|
4367
|
-
if (flag.once)
|
|
4368
|
-
unbinder();
|
|
4197
|
+
if (flag.once) unbinder();
|
|
4369
4198
|
}
|
|
4370
4199
|
};
|
|
4371
4200
|
el.addEventListener(eventType, listener, options);
|
|
@@ -4376,8 +4205,7 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4376
4205
|
var propDirective = {
|
|
4377
4206
|
onChange: (el, values, _previousValues, option, _previousOption, flags) => {
|
|
4378
4207
|
if (option) {
|
|
4379
|
-
if (flags && flags.includes("camel"))
|
|
4380
|
-
option = camelize(option);
|
|
4208
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
4381
4209
|
patchProp(el, option, values[0]);
|
|
4382
4210
|
return;
|
|
4383
4211
|
}
|
|
@@ -4460,18 +4288,14 @@ var refDirective = {
|
|
|
4460
4288
|
const value = result.value()[0];
|
|
4461
4289
|
const isAnArray = isArray(value);
|
|
4462
4290
|
const sref2 = result.refs[0];
|
|
4463
|
-
if (isAnArray)
|
|
4464
|
-
|
|
4465
|
-
else
|
|
4466
|
-
sref2 == null ? void 0 : sref2(el);
|
|
4467
|
-
else
|
|
4468
|
-
result.context[expr] = el;
|
|
4291
|
+
if (isAnArray) value.push(el);
|
|
4292
|
+
else if (sref2) sref2 == null ? void 0 : sref2(el);
|
|
4293
|
+
else result.context[expr] = el;
|
|
4469
4294
|
return () => {
|
|
4470
4295
|
if (isAnArray) {
|
|
4471
4296
|
const i = value.indexOf(el);
|
|
4472
4297
|
i !== -1 && value.splice(i, 1);
|
|
4473
|
-
} else
|
|
4474
|
-
sref2 == null ? void 0 : sref2(null);
|
|
4298
|
+
} else sref2 == null ? void 0 : sref2(null);
|
|
4475
4299
|
};
|
|
4476
4300
|
}
|
|
4477
4301
|
};
|
|
@@ -4485,10 +4309,8 @@ var showDirective = {
|
|
|
4485
4309
|
originalDisplay = data._ord = el.style.display;
|
|
4486
4310
|
}
|
|
4487
4311
|
const isVisible = !!values[0];
|
|
4488
|
-
if (isVisible)
|
|
4489
|
-
|
|
4490
|
-
else
|
|
4491
|
-
el.style.display = "none";
|
|
4312
|
+
if (isVisible) el.style.display = originalDisplay;
|
|
4313
|
+
else el.style.display = "none";
|
|
4492
4314
|
}
|
|
4493
4315
|
};
|
|
4494
4316
|
|
|
@@ -4534,8 +4356,7 @@ var patchStyle = (el, next, prev) => {
|
|
|
4534
4356
|
el.removeAttribute("style");
|
|
4535
4357
|
}
|
|
4536
4358
|
const data = getBindData(el).data;
|
|
4537
|
-
if ("_ord" in data)
|
|
4538
|
-
return;
|
|
4359
|
+
if ("_ord" in data) return;
|
|
4539
4360
|
style.display = currentDisplay;
|
|
4540
4361
|
}
|
|
4541
4362
|
};
|
|
@@ -4546,8 +4367,7 @@ function setStyle(style, name2, val) {
|
|
|
4546
4367
|
setStyle(style, name2, v);
|
|
4547
4368
|
});
|
|
4548
4369
|
} else {
|
|
4549
|
-
if (val == null)
|
|
4550
|
-
val = "";
|
|
4370
|
+
if (val == null) val = "";
|
|
4551
4371
|
if (name2.startsWith("--")) {
|
|
4552
4372
|
style.setProperty(name2, val);
|
|
4553
4373
|
} else {
|
|
@@ -4589,11 +4409,9 @@ function autoPrefix(style, rawName) {
|
|
|
4589
4409
|
var flatten = (reference) => {
|
|
4590
4410
|
return flattenContent(unref(reference));
|
|
4591
4411
|
};
|
|
4592
|
-
var flattenContent = (value) => {
|
|
4593
|
-
if (!value)
|
|
4594
|
-
|
|
4595
|
-
if (!isObject(value))
|
|
4596
|
-
return value;
|
|
4412
|
+
var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
|
|
4413
|
+
if (!value) return value;
|
|
4414
|
+
if (!isObject(value)) return value;
|
|
4597
4415
|
if (isArray(value)) {
|
|
4598
4416
|
return value.map(flatten);
|
|
4599
4417
|
}
|
|
@@ -4606,14 +4424,16 @@ var flattenContent = (value) => {
|
|
|
4606
4424
|
}
|
|
4607
4425
|
if (isMap(value)) {
|
|
4608
4426
|
const map = /* @__PURE__ */ new Map();
|
|
4609
|
-
for (const el of
|
|
4427
|
+
for (const el of value) {
|
|
4610
4428
|
map.set(flatten(el[0]), flatten(el[1]));
|
|
4611
4429
|
}
|
|
4612
4430
|
return map;
|
|
4613
4431
|
}
|
|
4432
|
+
if (weakMap.has(value)) return unref(weakMap.get(value));
|
|
4614
4433
|
const result = { ...value };
|
|
4434
|
+
weakMap.set(value, result);
|
|
4615
4435
|
for (const entry of Object.entries(result)) {
|
|
4616
|
-
result[entry[0]] =
|
|
4436
|
+
result[entry[0]] = flattenContent(unref(entry[1]), weakMap);
|
|
4617
4437
|
}
|
|
4618
4438
|
return result;
|
|
4619
4439
|
};
|
|
@@ -4641,8 +4461,7 @@ var isDeepRef = (value) => {
|
|
|
4641
4461
|
|
|
4642
4462
|
// src/reactivity/ref.ts
|
|
4643
4463
|
var ref = (value) => {
|
|
4644
|
-
if (isRaw(value))
|
|
4645
|
-
return value;
|
|
4464
|
+
if (isRaw(value)) return value;
|
|
4646
4465
|
let result;
|
|
4647
4466
|
if (isRef(value)) {
|
|
4648
4467
|
result = value;
|
|
@@ -4657,21 +4476,18 @@ var ref = (value) => {
|
|
|
4657
4476
|
const len = value.length;
|
|
4658
4477
|
for (let i = 0; i < len; ++i) {
|
|
4659
4478
|
const item = value[i];
|
|
4660
|
-
if (isDeepRef(item))
|
|
4661
|
-
continue;
|
|
4479
|
+
if (isDeepRef(item)) continue;
|
|
4662
4480
|
value[i] = ref(item);
|
|
4663
4481
|
}
|
|
4664
4482
|
return result;
|
|
4665
4483
|
}
|
|
4666
|
-
if (!isObject(value))
|
|
4667
|
-
return result;
|
|
4484
|
+
if (!isObject(value)) return result;
|
|
4668
4485
|
for (const item of Object.entries(value)) {
|
|
4669
4486
|
const val = item[1];
|
|
4670
|
-
if (isDeepRef(val))
|
|
4671
|
-
continue;
|
|
4487
|
+
if (isDeepRef(val)) continue;
|
|
4672
4488
|
const key = item[0];
|
|
4673
|
-
if (isSymbol(key))
|
|
4674
|
-
|
|
4489
|
+
if (isSymbol(key)) continue;
|
|
4490
|
+
value[key] = null;
|
|
4675
4491
|
value[key] = ref(val);
|
|
4676
4492
|
}
|
|
4677
4493
|
return result;
|
|
@@ -4806,8 +4622,7 @@ var RegorConfig = _RegorConfig;
|
|
|
4806
4622
|
|
|
4807
4623
|
// src/bind/interpolation.ts
|
|
4808
4624
|
var interpolate = (element, config) => {
|
|
4809
|
-
if (!element)
|
|
4810
|
-
return;
|
|
4625
|
+
if (!element) return;
|
|
4811
4626
|
const builtInNames = (config != null ? config : RegorConfig.getDefault()).__builtInNames;
|
|
4812
4627
|
for (const textNode of getTextNodes(element, builtInNames.pre)) {
|
|
4813
4628
|
interpolateTextNode(textNode, builtInNames.text);
|
|
@@ -4817,12 +4632,10 @@ var interpolationRegex = /({{[^]*?}})/g;
|
|
|
4817
4632
|
var interpolateTextNode = (textNode, textDirective2) => {
|
|
4818
4633
|
var _a;
|
|
4819
4634
|
const text = textNode.textContent;
|
|
4820
|
-
if (!text)
|
|
4821
|
-
return;
|
|
4635
|
+
if (!text) return;
|
|
4822
4636
|
const mustacheRegex = interpolationRegex;
|
|
4823
4637
|
const parts = text.split(mustacheRegex);
|
|
4824
|
-
if (parts.length <= 1)
|
|
4825
|
-
return;
|
|
4638
|
+
if (parts.length <= 1) return;
|
|
4826
4639
|
if (((_a = textNode.parentElement) == null ? void 0 : _a.childNodes.length) === 1 && parts.length === 3) {
|
|
4827
4640
|
const part = parts[1];
|
|
4828
4641
|
if (isNullOrWhitespace(parts[0]) && isNullOrWhitespace(parts[2]) && part.startsWith("{{") && part.endsWith("}}")) {
|
|
@@ -4854,8 +4667,7 @@ var getTextNodes = (node, preDirective) => {
|
|
|
4854
4667
|
textNodes.push(node2);
|
|
4855
4668
|
}
|
|
4856
4669
|
} else {
|
|
4857
|
-
if ((_b = node2 == null ? void 0 : node2.hasAttribute) == null ? void 0 : _b.call(node2, preDirective))
|
|
4858
|
-
return;
|
|
4670
|
+
if ((_b = node2 == null ? void 0 : node2.hasAttribute) == null ? void 0 : _b.call(node2, preDirective)) return;
|
|
4859
4671
|
for (const child of getChildNodes(node2)) {
|
|
4860
4672
|
traverseTextNodes(child);
|
|
4861
4673
|
}
|
|
@@ -4870,10 +4682,8 @@ var svgTags = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-
|
|
|
4870
4682
|
var svgSet = new Set(svgTags.toUpperCase().split(","));
|
|
4871
4683
|
var svgNamespace = "http://www.w3.org/2000/svg";
|
|
4872
4684
|
var appendChild = (parent, el) => {
|
|
4873
|
-
if (isTemplate(parent))
|
|
4874
|
-
|
|
4875
|
-
else
|
|
4876
|
-
parent.appendChild(el);
|
|
4685
|
+
if (isTemplate(parent)) parent.content.appendChild(el);
|
|
4686
|
+
else parent.appendChild(el);
|
|
4877
4687
|
};
|
|
4878
4688
|
var render = (json, parent, isSVG, config) => {
|
|
4879
4689
|
var _a;
|
|
@@ -4894,8 +4704,7 @@ var render = (json, parent, isSVG, config) => {
|
|
|
4894
4704
|
}
|
|
4895
4705
|
const children = json.c;
|
|
4896
4706
|
if (children) {
|
|
4897
|
-
for (const child of children)
|
|
4898
|
-
render(child, el, isSVG, config);
|
|
4707
|
+
for (const child of children) render(child, el, isSVG, config);
|
|
4899
4708
|
}
|
|
4900
4709
|
appendChild(parent, el);
|
|
4901
4710
|
return;
|
|
@@ -4911,10 +4720,8 @@ var render = (json, parent, isSVG, config) => {
|
|
|
4911
4720
|
node = document.createTextNode(textData);
|
|
4912
4721
|
break;
|
|
4913
4722
|
}
|
|
4914
|
-
if (node)
|
|
4915
|
-
|
|
4916
|
-
else
|
|
4917
|
-
throw new Error("unsupported node type.");
|
|
4723
|
+
if (node) appendChild(parent, node);
|
|
4724
|
+
else throw new Error("unsupported node type.");
|
|
4918
4725
|
}
|
|
4919
4726
|
};
|
|
4920
4727
|
var toFragment = (json, isSVG, config) => {
|
|
@@ -4931,16 +4738,13 @@ var toFragment = (json, isSVG, config) => {
|
|
|
4931
4738
|
};
|
|
4932
4739
|
|
|
4933
4740
|
// src/app/createApp.ts
|
|
4934
|
-
var createApp = (context,
|
|
4935
|
-
if (isString(
|
|
4936
|
-
|
|
4937
|
-
if (isScope(context))
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
if (!
|
|
4941
|
-
throw getError(0 /* AppRootElementMissing */);
|
|
4942
|
-
if (!config)
|
|
4943
|
-
config = RegorConfig.getDefault();
|
|
4741
|
+
var createApp = (context, template = { selector: "#app" }, config) => {
|
|
4742
|
+
if (isString(template))
|
|
4743
|
+
template = { selector: "#app", template };
|
|
4744
|
+
if (isScope(context)) context = context.context;
|
|
4745
|
+
const root = template.element ? template.element : template.selector ? document.querySelector(template.selector) : null;
|
|
4746
|
+
if (!root || !isElement(root)) throw getError(0 /* AppRootElementMissing */);
|
|
4747
|
+
if (!config) config = RegorConfig.getDefault();
|
|
4944
4748
|
const cleanRoot = () => {
|
|
4945
4749
|
for (const child of [...root.childNodes]) {
|
|
4946
4750
|
removeNode(child);
|
|
@@ -4951,22 +4755,21 @@ var createApp = (context, templateOptions = { selector: "#app" }, config) => {
|
|
|
4951
4755
|
root.appendChild(child);
|
|
4952
4756
|
}
|
|
4953
4757
|
};
|
|
4954
|
-
if (
|
|
4955
|
-
const element = document.createRange().createContextualFragment(
|
|
4758
|
+
if (template.template) {
|
|
4759
|
+
const element = document.createRange().createContextualFragment(template.template);
|
|
4956
4760
|
cleanRoot();
|
|
4957
4761
|
appendChildren(element.childNodes);
|
|
4958
|
-
|
|
4959
|
-
} else if (
|
|
4762
|
+
template.element = element;
|
|
4763
|
+
} else if (template.json) {
|
|
4960
4764
|
const element = toFragment(
|
|
4961
|
-
|
|
4962
|
-
|
|
4765
|
+
template.json,
|
|
4766
|
+
template.isSVG,
|
|
4963
4767
|
config
|
|
4964
4768
|
);
|
|
4965
4769
|
cleanRoot();
|
|
4966
4770
|
appendChildren(element.childNodes);
|
|
4967
4771
|
}
|
|
4968
|
-
if (config.useInterpolation)
|
|
4969
|
-
interpolate(root, config);
|
|
4772
|
+
if (config.useInterpolation) interpolate(root, config);
|
|
4970
4773
|
const app = new RegorApp(context, root, config);
|
|
4971
4774
|
app.__bind();
|
|
4972
4775
|
addUnbinder(root, () => {
|
|
@@ -5007,13 +4810,10 @@ var toJsonTemplate = (node) => {
|
|
|
5007
4810
|
return node.map((x) => toJsonTemplate(x));
|
|
5008
4811
|
}
|
|
5009
4812
|
const json = {};
|
|
5010
|
-
if (node.tagName)
|
|
5011
|
-
json.t = node.tagName;
|
|
4813
|
+
if (node.tagName) json.t = node.tagName;
|
|
5012
4814
|
else {
|
|
5013
|
-
if (node.nodeType === Node.COMMENT_NODE)
|
|
5014
|
-
|
|
5015
|
-
if (node.textContent)
|
|
5016
|
-
json.d = node.textContent;
|
|
4815
|
+
if (node.nodeType === Node.COMMENT_NODE) json.n = Node.COMMENT_NODE;
|
|
4816
|
+
if (node.textContent) json.d = node.textContent;
|
|
5017
4817
|
return json;
|
|
5018
4818
|
}
|
|
5019
4819
|
const attrNames = node.getAttributeNames();
|
|
@@ -5032,51 +4832,48 @@ var toJsonTemplate = (node) => {
|
|
|
5032
4832
|
};
|
|
5033
4833
|
|
|
5034
4834
|
// src/app/createComponent.ts
|
|
5035
|
-
var createComponent = (context,
|
|
4835
|
+
var createComponent = (context, template, options = {}) => {
|
|
5036
4836
|
var _a, _b, _c, _d;
|
|
5037
|
-
if (isArray(options))
|
|
5038
|
-
|
|
5039
|
-
if (isString(templateOptions))
|
|
5040
|
-
templateOptions = { template: templateOptions };
|
|
4837
|
+
if (isArray(options)) options = { props: options };
|
|
4838
|
+
if (isString(template)) template = { template };
|
|
5041
4839
|
let svgHandled = false;
|
|
5042
|
-
if (
|
|
5043
|
-
const element2 =
|
|
4840
|
+
if (template.element) {
|
|
4841
|
+
const element2 = template.element;
|
|
5044
4842
|
element2.remove();
|
|
5045
|
-
|
|
5046
|
-
} else if (
|
|
5047
|
-
const element2 = document.querySelector(
|
|
4843
|
+
template.element = element2;
|
|
4844
|
+
} else if (template.selector) {
|
|
4845
|
+
const element2 = document.querySelector(template.selector);
|
|
5048
4846
|
if (!element2)
|
|
5049
4847
|
throw getError(
|
|
5050
4848
|
1 /* ComponentTemplateNotFound */,
|
|
5051
|
-
|
|
4849
|
+
template.selector
|
|
5052
4850
|
);
|
|
5053
4851
|
element2.remove();
|
|
5054
|
-
|
|
5055
|
-
} else if (
|
|
5056
|
-
const element2 = document.createRange().createContextualFragment(
|
|
5057
|
-
|
|
5058
|
-
} else if (
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
4852
|
+
template.element = element2;
|
|
4853
|
+
} else if (template.template) {
|
|
4854
|
+
const element2 = document.createRange().createContextualFragment(template.template);
|
|
4855
|
+
template.element = element2;
|
|
4856
|
+
} else if (template.json) {
|
|
4857
|
+
template.element = toFragment(
|
|
4858
|
+
template.json,
|
|
4859
|
+
template.isSVG,
|
|
5062
4860
|
options.config
|
|
5063
4861
|
);
|
|
5064
4862
|
svgHandled = true;
|
|
5065
4863
|
}
|
|
5066
|
-
if (!
|
|
5067
|
-
|
|
5068
|
-
if ((_a = options.useInterpolation) != null ? _a : true)
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
const content = templateOptions.element.content;
|
|
4864
|
+
if (!template.element)
|
|
4865
|
+
template.element = document.createDocumentFragment();
|
|
4866
|
+
if ((_a = options.useInterpolation) != null ? _a : true) interpolate(template.element);
|
|
4867
|
+
const element = template.element;
|
|
4868
|
+
if (!svgHandled && (((_c = template.isSVG) != null ? _c : isHTMLElement(element) && ((_b = element.hasAttribute) == null ? void 0 : _b.call(element, "isSVG"))) || isHTMLElement(element) && !!element.querySelector("[isSVG]"))) {
|
|
4869
|
+
const content = template.element.content;
|
|
5073
4870
|
const nodes = content ? [...content.childNodes] : [...element.childNodes];
|
|
5074
4871
|
const json = toJsonTemplate(nodes);
|
|
5075
|
-
|
|
4872
|
+
template.element = toFragment(json, true, options.config);
|
|
5076
4873
|
}
|
|
5077
4874
|
return {
|
|
5078
4875
|
context,
|
|
5079
|
-
template:
|
|
4876
|
+
template: template.element,
|
|
5080
4877
|
inheritAttrs: (_d = options.inheritAttrs) != null ? _d : true,
|
|
5081
4878
|
props: options.props,
|
|
5082
4879
|
defaultName: options.defaultName
|
|
@@ -5090,8 +4887,7 @@ var computed = (compute) => {
|
|
|
5090
4887
|
const result = (...args) => {
|
|
5091
4888
|
if (args.length <= 2 && 0 in args)
|
|
5092
4889
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5093
|
-
if (computer && !status.isStopped)
|
|
5094
|
-
return computer(...args);
|
|
4890
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5095
4891
|
computer = computedOnce(compute, status);
|
|
5096
4892
|
return computer(...args);
|
|
5097
4893
|
};
|
|
@@ -5131,8 +4927,7 @@ var computeMany = (sources, compute) => {
|
|
|
5131
4927
|
const result = (...args) => {
|
|
5132
4928
|
if (args.length <= 2 && 0 in args)
|
|
5133
4929
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5134
|
-
if (computer && !status.isStopped)
|
|
5135
|
-
return computer(...args);
|
|
4930
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5136
4931
|
computer = computeManyOnce(sources, compute, status);
|
|
5137
4932
|
return computer(...args);
|
|
5138
4933
|
};
|
|
@@ -5182,8 +4977,7 @@ var computeRef = (source, compute) => {
|
|
|
5182
4977
|
const result = (...args) => {
|
|
5183
4978
|
if (args.length <= 2 && 0 in args)
|
|
5184
4979
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5185
|
-
if (computer && !status.isStopped)
|
|
5186
|
-
return computer(...args);
|
|
4980
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5187
4981
|
computer = computeRefOnce(source, compute, status);
|
|
5188
4982
|
return computer(...args);
|
|
5189
4983
|
};
|
|
@@ -5228,31 +5022,44 @@ var markRaw = (value) => {
|
|
|
5228
5022
|
|
|
5229
5023
|
// src/misc/persist.ts
|
|
5230
5024
|
var persist = (anyRef, key) => {
|
|
5231
|
-
if (!key)
|
|
5232
|
-
throw new Error("persist requires a string key.");
|
|
5025
|
+
if (!key) throw getError(5 /* PersistRequiresKey */);
|
|
5233
5026
|
const deepRef = isDeepRef(anyRef);
|
|
5234
5027
|
const makeRef = deepRef ? ref : (x) => x;
|
|
5235
5028
|
const store = () => localStorage.setItem(key, JSON.stringify(flatten(anyRef())));
|
|
5236
5029
|
const existing = localStorage.getItem(key);
|
|
5237
5030
|
if (existing != null) {
|
|
5238
|
-
|
|
5031
|
+
try {
|
|
5032
|
+
anyRef(makeRef(JSON.parse(existing)));
|
|
5033
|
+
} catch (e) {
|
|
5034
|
+
warning(
|
|
5035
|
+
6 /* ErrorLog */,
|
|
5036
|
+
`persist: failed to parse data for key ${key}`,
|
|
5037
|
+
e
|
|
5038
|
+
);
|
|
5039
|
+
store();
|
|
5040
|
+
}
|
|
5239
5041
|
} else {
|
|
5240
5042
|
store();
|
|
5241
5043
|
}
|
|
5242
5044
|
const stopObserving = watchEffect(store);
|
|
5243
|
-
onUnmounted(
|
|
5045
|
+
onUnmounted(stopObserving, true);
|
|
5244
5046
|
return anyRef;
|
|
5245
5047
|
};
|
|
5246
5048
|
|
|
5247
5049
|
// src/misc/tagged-html.ts
|
|
5248
5050
|
var html = (templates, ...args) => {
|
|
5249
|
-
let
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5051
|
+
let result = "";
|
|
5052
|
+
const tpl = templates;
|
|
5053
|
+
const a = args;
|
|
5054
|
+
const tplLen = tpl.length;
|
|
5055
|
+
const argLen = a.length;
|
|
5056
|
+
for (let i = 0; i < tplLen; ++i) {
|
|
5057
|
+
result += tpl[i];
|
|
5058
|
+
if (i < argLen) {
|
|
5059
|
+
result += a[i];
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5062
|
+
return result;
|
|
5256
5063
|
};
|
|
5257
5064
|
var raw = html;
|
|
5258
5065
|
|
|
@@ -5265,8 +5072,7 @@ var observeMany = (sources, observer, init) => {
|
|
|
5265
5072
|
for (const source of sources) {
|
|
5266
5073
|
stopObservingList.push(observe(source, callObserver));
|
|
5267
5074
|
}
|
|
5268
|
-
if (init)
|
|
5269
|
-
callObserver();
|
|
5075
|
+
if (init) callObserver();
|
|
5270
5076
|
const stop = () => {
|
|
5271
5077
|
for (const stopObserving of stopObservingList) {
|
|
5272
5078
|
stopObserving();
|
|
@@ -5279,7 +5085,7 @@ var observeMany = (sources, observer, init) => {
|
|
|
5279
5085
|
// src/observer/observerCount.ts
|
|
5280
5086
|
var observerCount = (source) => {
|
|
5281
5087
|
if (!isRef(source))
|
|
5282
|
-
throw getError(3 /* RequiresRefSourceArgument */, "
|
|
5088
|
+
throw getError(3 /* RequiresRefSourceArgument */, "observerCount");
|
|
5283
5089
|
const srefImpl = source;
|
|
5284
5090
|
return srefImpl(void 0, void 0, 2 /* observerCount */);
|
|
5285
5091
|
};
|
|
@@ -5294,14 +5100,19 @@ var batch = (updater) => {
|
|
|
5294
5100
|
}
|
|
5295
5101
|
};
|
|
5296
5102
|
var startBatch = () => {
|
|
5297
|
-
if (!batchCollector.
|
|
5298
|
-
|
|
5103
|
+
if (!batchCollector.stack) batchCollector.stack = [];
|
|
5104
|
+
batchCollector.stack.push(/* @__PURE__ */ new Set());
|
|
5299
5105
|
};
|
|
5300
5106
|
var endBatch = () => {
|
|
5301
|
-
const
|
|
5302
|
-
if (!
|
|
5107
|
+
const stack = batchCollector.stack;
|
|
5108
|
+
if (!stack || stack.length === 0) return;
|
|
5109
|
+
const set = stack.pop();
|
|
5110
|
+
if (stack.length) {
|
|
5111
|
+
const parent = stack[stack.length - 1];
|
|
5112
|
+
for (const ref2 of set) parent.add(ref2);
|
|
5303
5113
|
return;
|
|
5304
|
-
|
|
5114
|
+
}
|
|
5115
|
+
delete batchCollector.stack;
|
|
5305
5116
|
for (const ref2 of set) {
|
|
5306
5117
|
try {
|
|
5307
5118
|
trigger(ref2);
|