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.es2022.esm.js
CHANGED
|
@@ -29,7 +29,8 @@ var errors = {
|
|
|
29
29
|
[1 /* ComponentTemplateNotFound */]: (selector) => `Component template cannot be found. selector: ${selector} .`,
|
|
30
30
|
[2 /* ComposablesRequireScope */]: "Use composables in scope. usage: useScope(() => new MyApp()).",
|
|
31
31
|
[3 /* RequiresRefSourceArgument */]: (name2) => `${name2} requires ref source argument`,
|
|
32
|
-
[4 /* ComputedIsReadOnly */]: "computed is readonly."
|
|
32
|
+
[4 /* ComputedIsReadOnly */]: "computed is readonly.",
|
|
33
|
+
[5 /* PersistRequiresKey */]: "persist requires a string key."
|
|
33
34
|
};
|
|
34
35
|
var getError = (type, ...args) => {
|
|
35
36
|
const msg = errors[type];
|
|
@@ -42,8 +43,7 @@ var bindDataSymbol = Symbol(":regor");
|
|
|
42
43
|
// src/cleanup/getBindData.ts
|
|
43
44
|
var getBindData = (node) => {
|
|
44
45
|
const bindData = node[bindDataSymbol];
|
|
45
|
-
if (bindData)
|
|
46
|
-
return bindData;
|
|
46
|
+
if (bindData) return bindData;
|
|
47
47
|
const newBindData = {
|
|
48
48
|
unbinders: [],
|
|
49
49
|
data: {}
|
|
@@ -69,8 +69,7 @@ var pushScope = () => {
|
|
|
69
69
|
};
|
|
70
70
|
var peekScope = (noThrow) => {
|
|
71
71
|
const scope = scopes[scopes.length - 1];
|
|
72
|
-
if (!scope && !noThrow)
|
|
73
|
-
throw getError(2 /* ComposablesRequireScope */);
|
|
72
|
+
if (!scope && !noThrow) throw getError(2 /* ComposablesRequireScope */);
|
|
74
73
|
return scope;
|
|
75
74
|
};
|
|
76
75
|
var popScope = (context) => {
|
|
@@ -85,8 +84,7 @@ var setScope = (context) => {
|
|
|
85
84
|
const existing = data[scopeSymbol];
|
|
86
85
|
if (existing) {
|
|
87
86
|
const cs = peekScope();
|
|
88
|
-
if (existing === cs)
|
|
89
|
-
return;
|
|
87
|
+
if (existing === cs) return;
|
|
90
88
|
cs.onMounted.length > 0 && existing.onMounted.push(...cs.onMounted);
|
|
91
89
|
cs.onUnmounted.length > 0 && existing.onUnmounted.push(...cs.onUnmounted);
|
|
92
90
|
return;
|
|
@@ -117,8 +115,7 @@ var isRef = (value) => {
|
|
|
117
115
|
var observe = (source, observer, init) => {
|
|
118
116
|
if (!isRef(source))
|
|
119
117
|
throw getError(3 /* RequiresRefSourceArgument */, "observe");
|
|
120
|
-
if (init)
|
|
121
|
-
observer(source());
|
|
118
|
+
if (init) observer(source());
|
|
122
119
|
const srefImpl = source;
|
|
123
120
|
const stop = srefImpl(
|
|
124
121
|
void 0,
|
|
@@ -137,8 +134,7 @@ var unbind = (node) => {
|
|
|
137
134
|
const currentElement = queue.shift();
|
|
138
135
|
unbindSingle(currentElement);
|
|
139
136
|
const childNodes = currentElement.childNodes;
|
|
140
|
-
if (!childNodes)
|
|
141
|
-
continue;
|
|
137
|
+
if (!childNodes) continue;
|
|
142
138
|
for (const item of childNodes) {
|
|
143
139
|
queue.push(item);
|
|
144
140
|
}
|
|
@@ -146,8 +142,7 @@ var unbind = (node) => {
|
|
|
146
142
|
};
|
|
147
143
|
var unbindSingle = (node) => {
|
|
148
144
|
const bindData = node[bindDataSymbol];
|
|
149
|
-
if (!bindData)
|
|
150
|
-
return;
|
|
145
|
+
if (!bindData) return;
|
|
151
146
|
for (const unbinder of bindData.unbinders) {
|
|
152
147
|
unbinder();
|
|
153
148
|
}
|
|
@@ -181,12 +176,9 @@ var warning = (type, ...args) => {
|
|
|
181
176
|
const msg = warnings[type];
|
|
182
177
|
const item = isFunction(msg) ? msg.call(warnings, ...args) : msg;
|
|
183
178
|
const handler = warningHandler.warning;
|
|
184
|
-
if (!handler)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
handler(item);
|
|
188
|
-
else
|
|
189
|
-
handler(item, ...item.args);
|
|
179
|
+
if (!handler) return;
|
|
180
|
+
if (isString(item)) handler(item);
|
|
181
|
+
else handler(item, ...item.args);
|
|
190
182
|
};
|
|
191
183
|
var warningHandler = { warning: console.warn };
|
|
192
184
|
|
|
@@ -225,11 +217,9 @@ var getSwitches = (nodes) => {
|
|
|
225
217
|
return [...set];
|
|
226
218
|
};
|
|
227
219
|
var setSwitchOwner = (owner, switchNodes) => {
|
|
228
|
-
if (!hasSwitch())
|
|
229
|
-
return;
|
|
220
|
+
if (!hasSwitch()) return;
|
|
230
221
|
const switches2 = getSwitches(switchNodes);
|
|
231
|
-
if (switches2.length === 0)
|
|
232
|
-
return;
|
|
222
|
+
if (switches2.length === 0) return;
|
|
233
223
|
switches2.forEach(refSwitch);
|
|
234
224
|
addUnbinder(owner, () => {
|
|
235
225
|
switches2.forEach(removeSwitch);
|
|
@@ -285,8 +275,7 @@ var IfBinder = class {
|
|
|
285
275
|
return isIfElement;
|
|
286
276
|
}
|
|
287
277
|
__isProcessedOrMark(el) {
|
|
288
|
-
if (el[ifMarker])
|
|
289
|
-
return true;
|
|
278
|
+
if (el[ifMarker]) return true;
|
|
290
279
|
el[ifMarker] = true;
|
|
291
280
|
findElements(el, this.__ifSelector).forEach(
|
|
292
281
|
(x) => x[ifMarker] = true
|
|
@@ -317,8 +306,7 @@ var IfBinder = class {
|
|
|
317
306
|
removeNode(x);
|
|
318
307
|
});
|
|
319
308
|
el.remove();
|
|
320
|
-
if (type !== "if")
|
|
321
|
-
el[elseMarker] = 1;
|
|
309
|
+
if (type !== "if") el[elseMarker] = 1;
|
|
322
310
|
const commentEnd = document.createComment(
|
|
323
311
|
`__end__ :${type}${expression ?? ""}`
|
|
324
312
|
);
|
|
@@ -331,8 +319,7 @@ var IfBinder = class {
|
|
|
331
319
|
};
|
|
332
320
|
}
|
|
333
321
|
__collectElses(el, refresh) {
|
|
334
|
-
if (!el)
|
|
335
|
-
return [];
|
|
322
|
+
if (!el) return [];
|
|
336
323
|
const nextElement = el.nextElementSibling;
|
|
337
324
|
if (el.hasAttribute(this.__else)) {
|
|
338
325
|
el.removeAttribute(this.__else);
|
|
@@ -354,8 +341,7 @@ var IfBinder = class {
|
|
|
354
341
|
];
|
|
355
342
|
} else {
|
|
356
343
|
const expression = el.getAttribute(this.__elseif);
|
|
357
|
-
if (!expression)
|
|
358
|
-
return [];
|
|
344
|
+
if (!expression) return [];
|
|
359
345
|
el.removeAttribute(this.__elseif);
|
|
360
346
|
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
361
347
|
el,
|
|
@@ -463,8 +449,7 @@ var bindChildNodes = (binder, childNodes) => {
|
|
|
463
449
|
};
|
|
464
450
|
var findElements = (element, selector) => {
|
|
465
451
|
const result = element.querySelectorAll(selector);
|
|
466
|
-
if (element.matches?.(selector))
|
|
467
|
-
return [element, ...result];
|
|
452
|
+
if (element.matches?.(selector)) return [element, ...result];
|
|
468
453
|
return result;
|
|
469
454
|
};
|
|
470
455
|
var isTemplate = (node) => node instanceof HTMLTemplateElement;
|
|
@@ -486,8 +471,7 @@ var defineRefValue = (result, isReadOnly) => {
|
|
|
486
471
|
return result();
|
|
487
472
|
},
|
|
488
473
|
set(value) {
|
|
489
|
-
if (isReadOnly)
|
|
490
|
-
throw new Error("value is readonly.");
|
|
474
|
+
if (isReadOnly) throw new Error("value is readonly.");
|
|
491
475
|
return result(value);
|
|
492
476
|
},
|
|
493
477
|
enumerable: true,
|
|
@@ -495,10 +479,8 @@ var defineRefValue = (result, isReadOnly) => {
|
|
|
495
479
|
});
|
|
496
480
|
};
|
|
497
481
|
var isOptionDynamic = (option, dynamic) => {
|
|
498
|
-
if (!option)
|
|
499
|
-
|
|
500
|
-
if (option.startsWith("["))
|
|
501
|
-
return option.substring(1, option.length - 1);
|
|
482
|
+
if (!option) return false;
|
|
483
|
+
if (option.startsWith("[")) return option.substring(1, option.length - 1);
|
|
502
484
|
const len = dynamic.length;
|
|
503
485
|
if (option.startsWith(dynamic)) {
|
|
504
486
|
return option.substring(len, option.length - len);
|
|
@@ -524,33 +506,28 @@ var cacheStringFunction = (fn) => {
|
|
|
524
506
|
};
|
|
525
507
|
var camelizeRE = /-(\w)/g;
|
|
526
508
|
var camelize = cacheStringFunction((str) => {
|
|
527
|
-
if (!str)
|
|
528
|
-
return str;
|
|
509
|
+
if (!str) return str;
|
|
529
510
|
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
530
511
|
});
|
|
531
512
|
var hyphenateRE = /\B([A-Z])/g;
|
|
532
513
|
var hyphenate = cacheStringFunction((str) => {
|
|
533
|
-
if (!str)
|
|
534
|
-
return str;
|
|
514
|
+
if (!str) return str;
|
|
535
515
|
return str.replace(hyphenateRE, "-$1").toLowerCase();
|
|
536
516
|
});
|
|
537
517
|
var capitalize = cacheStringFunction((str) => {
|
|
538
|
-
if (!str)
|
|
539
|
-
return str;
|
|
518
|
+
if (!str) return str;
|
|
540
519
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
541
520
|
});
|
|
542
521
|
|
|
543
522
|
// src/computed/watchEffect.ts
|
|
544
523
|
var collectedRefs = [];
|
|
545
524
|
var collectRef = (ref2) => {
|
|
546
|
-
if (collectedRefs.length === 0)
|
|
547
|
-
return;
|
|
525
|
+
if (collectedRefs.length === 0) return;
|
|
548
526
|
collectedRefs[collectedRefs.length - 1]?.add(ref2);
|
|
549
527
|
};
|
|
550
528
|
var watchEffect = (effect) => {
|
|
551
|
-
if (!effect)
|
|
552
|
-
|
|
553
|
-
};
|
|
529
|
+
if (!effect) return () => {
|
|
530
|
+
};
|
|
554
531
|
const terminator = { stop: () => {
|
|
555
532
|
} };
|
|
556
533
|
watchEffectInternal(effect, terminator);
|
|
@@ -558,13 +535,11 @@ var watchEffect = (effect) => {
|
|
|
558
535
|
return terminator.stop;
|
|
559
536
|
};
|
|
560
537
|
var watchEffectInternal = (effect, terminator) => {
|
|
561
|
-
if (!effect)
|
|
562
|
-
return;
|
|
538
|
+
if (!effect) return;
|
|
563
539
|
let stopObservingList = [];
|
|
564
540
|
let isStopped = false;
|
|
565
541
|
const stopWatch = () => {
|
|
566
|
-
for (const stop of stopObservingList)
|
|
567
|
-
stop();
|
|
542
|
+
for (const stop of stopObservingList) stop();
|
|
568
543
|
stopObservingList = [];
|
|
569
544
|
isStopped = true;
|
|
570
545
|
};
|
|
@@ -573,8 +548,7 @@ var watchEffectInternal = (effect, terminator) => {
|
|
|
573
548
|
const set = /* @__PURE__ */ new Set();
|
|
574
549
|
collectedRefs.push(set);
|
|
575
550
|
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
576
|
-
if (isStopped)
|
|
577
|
-
return;
|
|
551
|
+
if (isStopped) return;
|
|
578
552
|
for (const r of [...set]) {
|
|
579
553
|
const stopObserving = observe(r, () => {
|
|
580
554
|
stopWatch();
|
|
@@ -614,15 +588,12 @@ var isRaw = (value) => {
|
|
|
614
588
|
|
|
615
589
|
// src/reactivity/trigger.ts
|
|
616
590
|
var trigger = (source, eventSource, isRecursive) => {
|
|
617
|
-
if (!isRef(source))
|
|
618
|
-
return;
|
|
591
|
+
if (!isRef(source)) return;
|
|
619
592
|
const srefImpl = source;
|
|
620
593
|
srefImpl(void 0, eventSource, 1 /* trigger */);
|
|
621
|
-
if (!isRecursive)
|
|
622
|
-
return;
|
|
594
|
+
if (!isRecursive) return;
|
|
623
595
|
const obj = srefImpl();
|
|
624
|
-
if (!obj)
|
|
625
|
-
return;
|
|
596
|
+
if (!obj) return;
|
|
626
597
|
if (isArray(obj) || isSet(obj)) {
|
|
627
598
|
for (const el of obj) {
|
|
628
599
|
trigger(el, eventSource, true);
|
|
@@ -655,8 +626,7 @@ var createProxy = (originalProto, proxyProto, methodsToPatch4) => {
|
|
|
655
626
|
define(proxyProto, method, function mutator(...args) {
|
|
656
627
|
const result = original.apply(this, args);
|
|
657
628
|
const subscribers = this[srefSymbol];
|
|
658
|
-
for (const subscriber of subscribers)
|
|
659
|
-
trigger(subscriber);
|
|
629
|
+
for (const subscriber of subscribers) trigger(subscriber);
|
|
660
630
|
return result;
|
|
661
631
|
});
|
|
662
632
|
});
|
|
@@ -701,17 +671,14 @@ createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
|
701
671
|
// src/reactivity/sref.ts
|
|
702
672
|
var batchCollector = {};
|
|
703
673
|
var sref = (value) => {
|
|
704
|
-
if (isRef(value) || isRaw(value))
|
|
705
|
-
return value;
|
|
674
|
+
if (isRef(value) || isRaw(value)) return value;
|
|
706
675
|
const refObj = {
|
|
707
676
|
auto: true,
|
|
708
677
|
_value: value
|
|
709
678
|
};
|
|
710
679
|
const createProxy2 = (value2) => {
|
|
711
|
-
if (!isObject(value2))
|
|
712
|
-
|
|
713
|
-
if (srefSymbol in value2)
|
|
714
|
-
return true;
|
|
680
|
+
if (!isObject(value2)) return false;
|
|
681
|
+
if (srefSymbol in value2) return true;
|
|
715
682
|
const isAnArray = isArray(value2);
|
|
716
683
|
if (isAnArray) {
|
|
717
684
|
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
@@ -732,24 +699,22 @@ var sref = (value) => {
|
|
|
732
699
|
const isProxy = createProxy2(value);
|
|
733
700
|
const observers = /* @__PURE__ */ new Set();
|
|
734
701
|
const trigger2 = (newValue, eventSource) => {
|
|
735
|
-
if (batchCollector.
|
|
736
|
-
batchCollector.
|
|
702
|
+
if (batchCollector.stack && batchCollector.stack.length) {
|
|
703
|
+
const current = batchCollector.stack[batchCollector.stack.length - 1];
|
|
704
|
+
current.add(srefFunction);
|
|
737
705
|
return;
|
|
738
706
|
}
|
|
739
|
-
if (observers.size === 0)
|
|
740
|
-
return;
|
|
707
|
+
if (observers.size === 0) return;
|
|
741
708
|
silence(() => {
|
|
742
709
|
for (const callback of [...observers.keys()]) {
|
|
743
|
-
if (!observers.has(callback))
|
|
744
|
-
continue;
|
|
710
|
+
if (!observers.has(callback)) continue;
|
|
745
711
|
callback(newValue, eventSource);
|
|
746
712
|
}
|
|
747
713
|
});
|
|
748
714
|
};
|
|
749
715
|
const attachProxyHandle = (value2) => {
|
|
750
716
|
let proxyHandle = value2[srefSymbol];
|
|
751
|
-
if (!proxyHandle)
|
|
752
|
-
value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
717
|
+
if (!proxyHandle) value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
753
718
|
proxyHandle.add(srefFunction);
|
|
754
719
|
};
|
|
755
720
|
const srefFunction = (...args) => {
|
|
@@ -757,15 +722,12 @@ var sref = (value) => {
|
|
|
757
722
|
let newValue = args[0];
|
|
758
723
|
const eventSource = args[1];
|
|
759
724
|
if (0 in args) {
|
|
760
|
-
if (refObj._value === newValue)
|
|
761
|
-
return newValue;
|
|
725
|
+
if (refObj._value === newValue) return newValue;
|
|
762
726
|
if (isRef(newValue)) {
|
|
763
727
|
newValue = newValue();
|
|
764
|
-
if (refObj._value === newValue)
|
|
765
|
-
return newValue;
|
|
728
|
+
if (refObj._value === newValue) return newValue;
|
|
766
729
|
}
|
|
767
|
-
if (createProxy2(newValue))
|
|
768
|
-
attachProxyHandle(newValue);
|
|
730
|
+
if (createProxy2(newValue)) attachProxyHandle(newValue);
|
|
769
731
|
refObj._value = newValue;
|
|
770
732
|
if (refObj.auto) {
|
|
771
733
|
trigger2(newValue, eventSource);
|
|
@@ -780,9 +742,8 @@ var sref = (value) => {
|
|
|
780
742
|
switch (operation) {
|
|
781
743
|
case 0 /* observe */: {
|
|
782
744
|
const observer = args[3];
|
|
783
|
-
if (!observer)
|
|
784
|
-
|
|
785
|
-
};
|
|
745
|
+
if (!observer) return () => {
|
|
746
|
+
};
|
|
786
747
|
const removeObserver = (observer2) => {
|
|
787
748
|
observers.delete(observer2);
|
|
788
749
|
};
|
|
@@ -812,8 +773,7 @@ var sref = (value) => {
|
|
|
812
773
|
};
|
|
813
774
|
srefFunction[srefSymbol] = 1;
|
|
814
775
|
defineRefValue(srefFunction, false);
|
|
815
|
-
if (isProxy)
|
|
816
|
-
attachProxyHandle(value);
|
|
776
|
+
if (isProxy) attachProxyHandle(value);
|
|
817
777
|
return srefFunction;
|
|
818
778
|
};
|
|
819
779
|
|
|
@@ -840,13 +800,11 @@ var MountList = class {
|
|
|
840
800
|
}
|
|
841
801
|
__setValueMap(item) {
|
|
842
802
|
const value = this.__getKey(item.value);
|
|
843
|
-
if (value)
|
|
844
|
-
this.__valueMap.set(value, item);
|
|
803
|
+
if (value !== void 0) this.__valueMap.set(value, item);
|
|
845
804
|
}
|
|
846
805
|
__deleteValueMap(index) {
|
|
847
806
|
const value = this.__getKey(this.__list[index]?.value);
|
|
848
|
-
if (value)
|
|
849
|
-
this.__valueMap.delete(value);
|
|
807
|
+
if (value !== void 0) this.__valueMap.delete(value);
|
|
850
808
|
}
|
|
851
809
|
/**
|
|
852
810
|
* @internal
|
|
@@ -866,8 +824,7 @@ var MountList = class {
|
|
|
866
824
|
}
|
|
867
825
|
__insertAt(index, item) {
|
|
868
826
|
const len = this.__length;
|
|
869
|
-
for (let i = index; i < len; ++i)
|
|
870
|
-
this.__list[i].order = i + 1;
|
|
827
|
+
for (let i = index; i < len; ++i) this.__list[i].order = i + 1;
|
|
871
828
|
item.order = index;
|
|
872
829
|
this.__list.splice(index, 0, item);
|
|
873
830
|
this.__setValueMap(item);
|
|
@@ -885,13 +842,11 @@ var MountList = class {
|
|
|
885
842
|
this.__deleteValueMap(index);
|
|
886
843
|
this.__list.splice(index, 1);
|
|
887
844
|
const len = this.__length;
|
|
888
|
-
for (let i = index; i < len; ++i)
|
|
889
|
-
this.__list[i].order = i;
|
|
845
|
+
for (let i = index; i < len; ++i) this.__list[i].order = i;
|
|
890
846
|
}
|
|
891
847
|
__removeAllAfter(index) {
|
|
892
848
|
const len = this.__length;
|
|
893
|
-
for (let i = index; i < len; ++i)
|
|
894
|
-
this.__deleteValueMap(i);
|
|
849
|
+
for (let i = index; i < len; ++i) this.__deleteValueMap(i);
|
|
895
850
|
this.__list.splice(index);
|
|
896
851
|
}
|
|
897
852
|
__isValueMounted(value) {
|
|
@@ -925,8 +880,7 @@ var ForBinder = class _ForBinder {
|
|
|
925
880
|
return isForElement;
|
|
926
881
|
}
|
|
927
882
|
__isProcessedOrMark(el) {
|
|
928
|
-
if (el[forMarker])
|
|
929
|
-
return true;
|
|
883
|
+
if (el[forMarker]) return true;
|
|
930
884
|
el[forMarker] = true;
|
|
931
885
|
findElements(el, this.__forSelector).forEach(
|
|
932
886
|
(x) => x[forMarker] = true
|
|
@@ -934,8 +888,7 @@ var ForBinder = class _ForBinder {
|
|
|
934
888
|
return false;
|
|
935
889
|
}
|
|
936
890
|
__bindFor(el) {
|
|
937
|
-
if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el))
|
|
938
|
-
return;
|
|
891
|
+
if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el)) return;
|
|
939
892
|
const forPath = el.getAttribute(this.__for);
|
|
940
893
|
if (!forPath) {
|
|
941
894
|
warning(0 /* MissingBindingExpression */, this.__for, el);
|
|
@@ -945,10 +898,8 @@ var ForBinder = class _ForBinder {
|
|
|
945
898
|
this.__bindForToPath(el, forPath);
|
|
946
899
|
}
|
|
947
900
|
__getIterable(obj) {
|
|
948
|
-
if (isNullOrUndefined(obj))
|
|
949
|
-
|
|
950
|
-
if (isFunction(obj))
|
|
951
|
-
obj = obj();
|
|
901
|
+
if (isNullOrUndefined(obj)) return [];
|
|
902
|
+
if (isFunction(obj)) obj = obj();
|
|
952
903
|
if (Symbol.iterator in Object(obj)) {
|
|
953
904
|
return obj;
|
|
954
905
|
}
|
|
@@ -981,8 +932,7 @@ var ForBinder = class _ForBinder {
|
|
|
981
932
|
const areEqual = (a, b) => getKey(a) === getKey(b);
|
|
982
933
|
const nodes = getNodes(el);
|
|
983
934
|
const parent = el.parentNode;
|
|
984
|
-
if (!parent)
|
|
985
|
-
return;
|
|
935
|
+
if (!parent) return;
|
|
986
936
|
const title = `${this.__for} => ${forPath}`;
|
|
987
937
|
const commentBegin = new Comment(`__begin__ ${title}`);
|
|
988
938
|
parent.insertBefore(commentBegin, el);
|
|
@@ -1041,8 +991,7 @@ var ForBinder = class _ForBinder {
|
|
|
1041
991
|
};
|
|
1042
992
|
const updateDom = (newValues) => {
|
|
1043
993
|
let len = mountList.__length;
|
|
1044
|
-
if (isFunction(newValues))
|
|
1045
|
-
newValues = newValues();
|
|
994
|
+
if (isFunction(newValues)) newValues = newValues();
|
|
1046
995
|
const unrefedNewValue = unref(newValues[0]);
|
|
1047
996
|
if (isArray(unrefedNewValue) && unrefedNewValue.length === 0) {
|
|
1048
997
|
unmount(commentBegin, commentEnd);
|
|
@@ -1058,8 +1007,7 @@ var ForBinder = class _ForBinder {
|
|
|
1058
1007
|
const modify = () => {
|
|
1059
1008
|
if (i2 < len) {
|
|
1060
1009
|
const mountItem = mountList.__get(i2++);
|
|
1061
|
-
if (areEqual(mountItem.value, newValue))
|
|
1062
|
-
return;
|
|
1010
|
+
if (areEqual(mountItem.value, newValue)) return;
|
|
1063
1011
|
const newValueMountPosition = mountList.__lookupValueOrderIfMounted(
|
|
1064
1012
|
getKey(newValue)
|
|
1065
1013
|
);
|
|
@@ -1074,8 +1022,7 @@ var ForBinder = class _ForBinder {
|
|
|
1074
1022
|
--len;
|
|
1075
1023
|
if (newValueMountPosition > i2 + 1) {
|
|
1076
1024
|
for (let j2 = i2; j2 < newValueMountPosition - 1 && j2 < len; ) {
|
|
1077
|
-
if (areEqual(mountList.__get(i2).value, newValue))
|
|
1078
|
-
break;
|
|
1025
|
+
if (areEqual(mountList.__get(i2).value, newValue)) break;
|
|
1079
1026
|
++j2;
|
|
1080
1027
|
remove(i2);
|
|
1081
1028
|
mountList.__removeAt(i2);
|
|
@@ -1106,8 +1053,7 @@ var ForBinder = class _ForBinder {
|
|
|
1106
1053
|
}
|
|
1107
1054
|
const j = i2;
|
|
1108
1055
|
len = mountList.__length;
|
|
1109
|
-
while (i2 < len)
|
|
1110
|
-
remove(i2++);
|
|
1056
|
+
while (i2 < len) remove(i2++);
|
|
1111
1057
|
mountList.__removeAllAfter(j);
|
|
1112
1058
|
updateIndexes(firstRemovalOrInsertionIndex);
|
|
1113
1059
|
};
|
|
@@ -1129,19 +1075,16 @@ var ForBinder = class _ForBinder {
|
|
|
1129
1075
|
addUnbinder(commentBegin, unbinder);
|
|
1130
1076
|
observeTailChanges();
|
|
1131
1077
|
}
|
|
1132
|
-
static __forPathRegex = /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+(
|
|
1078
|
+
static __forPathRegex = /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+(.*)\s*$/;
|
|
1133
1079
|
__parseForPath(forPath) {
|
|
1134
1080
|
const matches = _ForBinder.__forPathRegex.exec(forPath);
|
|
1135
|
-
if (!matches)
|
|
1136
|
-
return;
|
|
1081
|
+
if (!matches) return;
|
|
1137
1082
|
const keys = (matches[1] + (matches[2] ?? "")).split(",").map((key) => key.trim());
|
|
1138
1083
|
const indexOfIndex = keys.length > 1 ? keys.length - 1 : -1;
|
|
1139
1084
|
const index = indexOfIndex !== -1 && (keys[indexOfIndex] === "index" || keys[indexOfIndex]?.startsWith("#")) ? keys[indexOfIndex] : "";
|
|
1140
|
-
if (index)
|
|
1141
|
-
keys.splice(indexOfIndex, 1);
|
|
1085
|
+
if (index) keys.splice(indexOfIndex, 1);
|
|
1142
1086
|
const list = matches[3];
|
|
1143
|
-
if (!list || keys.length === 0)
|
|
1144
|
-
return;
|
|
1087
|
+
if (!list || keys.length === 0) return;
|
|
1145
1088
|
const hasDestructuring = /[{[]/.test(forPath);
|
|
1146
1089
|
return {
|
|
1147
1090
|
list,
|
|
@@ -1198,8 +1141,7 @@ var DynamicBinder = class {
|
|
|
1198
1141
|
let expression = el.getAttribute(this.__is);
|
|
1199
1142
|
if (!expression) {
|
|
1200
1143
|
expression = el.getAttribute("is");
|
|
1201
|
-
if (!expression || !expression.startsWith("regor:"))
|
|
1202
|
-
return;
|
|
1144
|
+
if (!expression || !expression.startsWith("regor:")) return;
|
|
1203
1145
|
expression = `'${expression.slice(6)}'`;
|
|
1204
1146
|
el.removeAttribute("is");
|
|
1205
1147
|
}
|
|
@@ -1256,13 +1198,11 @@ var DynamicBinder = class {
|
|
|
1256
1198
|
unmount(commentBegin, commentEnd);
|
|
1257
1199
|
return;
|
|
1258
1200
|
}
|
|
1259
|
-
if (mounted.name === name2)
|
|
1260
|
-
return;
|
|
1201
|
+
if (mounted.name === name2) return;
|
|
1261
1202
|
unmount(commentBegin, commentEnd);
|
|
1262
1203
|
const componentElement = document.createElement(name2);
|
|
1263
1204
|
for (const attr of el.getAttributeNames()) {
|
|
1264
|
-
if (attr === this.__is)
|
|
1265
|
-
continue;
|
|
1205
|
+
if (attr === this.__is) continue;
|
|
1266
1206
|
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1267
1207
|
}
|
|
1268
1208
|
mount2(componentChildNodes, componentElement);
|
|
@@ -1303,8 +1243,7 @@ var propsDirective = {
|
|
|
1303
1243
|
const key = item[0];
|
|
1304
1244
|
const value2 = item[1];
|
|
1305
1245
|
const ctxKey = ctx[key];
|
|
1306
|
-
if (ctxKey === value2)
|
|
1307
|
-
continue;
|
|
1246
|
+
if (ctxKey === value2) continue;
|
|
1308
1247
|
if (isRef(ctxKey)) {
|
|
1309
1248
|
ctxKey(value2);
|
|
1310
1249
|
} else {
|
|
@@ -1334,8 +1273,7 @@ var propsOnceDirective = {
|
|
|
1334
1273
|
const key = item[0];
|
|
1335
1274
|
const value2 = item[1];
|
|
1336
1275
|
const ctxKey = ctx[key];
|
|
1337
|
-
if (ctxKey === value2)
|
|
1338
|
-
continue;
|
|
1276
|
+
if (ctxKey === value2) continue;
|
|
1339
1277
|
if (isRef(ctxKey)) {
|
|
1340
1278
|
ctxKey(value2);
|
|
1341
1279
|
} else {
|
|
@@ -1423,16 +1361,14 @@ var useScope = (context) => {
|
|
|
1423
1361
|
}
|
|
1424
1362
|
};
|
|
1425
1363
|
var isScope = (value) => {
|
|
1426
|
-
if (!isObject(value))
|
|
1427
|
-
return false;
|
|
1364
|
+
if (!isObject(value)) return false;
|
|
1428
1365
|
return scopeSymbol2 in value;
|
|
1429
1366
|
};
|
|
1430
1367
|
|
|
1431
1368
|
// src/reactivity/entangle.ts
|
|
1432
1369
|
var entangle = (r1, r2) => {
|
|
1433
|
-
if (r1 === r2)
|
|
1434
|
-
|
|
1435
|
-
};
|
|
1370
|
+
if (r1 === r2) return () => {
|
|
1371
|
+
};
|
|
1436
1372
|
const stop1 = observe(r1, (v) => r2(v));
|
|
1437
1373
|
const stop2 = observe(r2, (v) => r1(v));
|
|
1438
1374
|
r2(r1());
|
|
@@ -1455,9 +1391,8 @@ var callMounted = (context) => {
|
|
|
1455
1391
|
var singlePropDirective = {
|
|
1456
1392
|
collectRefObj: true,
|
|
1457
1393
|
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
1458
|
-
if (!option)
|
|
1459
|
-
|
|
1460
|
-
};
|
|
1394
|
+
if (!option) return () => {
|
|
1395
|
+
};
|
|
1461
1396
|
const key = camelize(option);
|
|
1462
1397
|
const stopObserving = observe(
|
|
1463
1398
|
parseResult.value,
|
|
@@ -1465,8 +1400,7 @@ var singlePropDirective = {
|
|
|
1465
1400
|
const value = parseResult.refs[0] ?? parseResult.value()[0];
|
|
1466
1401
|
const ctx = parseResult.context;
|
|
1467
1402
|
const ctxKey = ctx[option];
|
|
1468
|
-
if (ctxKey === value)
|
|
1469
|
-
return;
|
|
1403
|
+
if (ctxKey === value) return;
|
|
1470
1404
|
if (isRef(ctxKey)) {
|
|
1471
1405
|
ctxKey(value);
|
|
1472
1406
|
} else {
|
|
@@ -1502,28 +1436,22 @@ var ComponentBinder = class {
|
|
|
1502
1436
|
...[...registeredComponents.keys()].map(hyphenate),
|
|
1503
1437
|
...[...Object.keys(contextComponents)].map(hyphenate)
|
|
1504
1438
|
].join(",");
|
|
1505
|
-
if (isNullOrWhitespace(selector))
|
|
1506
|
-
return;
|
|
1439
|
+
if (isNullOrWhitespace(selector)) return;
|
|
1507
1440
|
const list = element.querySelectorAll(selector);
|
|
1508
1441
|
const components = element.matches?.(selector) ? [element, ...list] : list;
|
|
1509
1442
|
for (const component of components) {
|
|
1510
|
-
if (component.hasAttribute(binder.__pre))
|
|
1511
|
-
continue;
|
|
1443
|
+
if (component.hasAttribute(binder.__pre)) continue;
|
|
1512
1444
|
const parent = component.parentNode;
|
|
1513
|
-
if (!parent)
|
|
1514
|
-
continue;
|
|
1445
|
+
if (!parent) continue;
|
|
1515
1446
|
const nextSibling = component.nextSibling;
|
|
1516
1447
|
const tagName = camelize(component.tagName).toUpperCase();
|
|
1517
1448
|
const contextComponent = contextComponents[tagName];
|
|
1518
1449
|
const registeredComponent = contextComponent ?? registeredComponentsUpperCase.get(tagName);
|
|
1519
|
-
if (!registeredComponent)
|
|
1520
|
-
continue;
|
|
1450
|
+
if (!registeredComponent) continue;
|
|
1521
1451
|
const templateElement = registeredComponent.template;
|
|
1522
|
-
if (!templateElement)
|
|
1523
|
-
continue;
|
|
1452
|
+
if (!templateElement) continue;
|
|
1524
1453
|
const componentParent = component.parentElement;
|
|
1525
|
-
if (!componentParent)
|
|
1526
|
-
continue;
|
|
1454
|
+
if (!componentParent) continue;
|
|
1527
1455
|
const startOfComponent = new Comment(
|
|
1528
1456
|
" begin component: " + component.tagName
|
|
1529
1457
|
);
|
|
@@ -1539,30 +1467,24 @@ var ComponentBinder = class {
|
|
|
1539
1467
|
const hasPropsOnce = component2.hasAttribute(propsOnceName);
|
|
1540
1468
|
parser.__scoped(capturedContext2, () => {
|
|
1541
1469
|
parser.__push(props);
|
|
1542
|
-
if (hasProps)
|
|
1543
|
-
binder.__bind(propsDirective, component2, propsName);
|
|
1470
|
+
if (hasProps) binder.__bind(propsDirective, component2, propsName);
|
|
1544
1471
|
if (hasPropsOnce)
|
|
1545
1472
|
binder.__bind(propsOnceDirective, component2, propsOnceName);
|
|
1546
1473
|
let definedProps = registeredComponent.props;
|
|
1547
|
-
if (!definedProps || definedProps.length === 0)
|
|
1548
|
-
return;
|
|
1474
|
+
if (!definedProps || definedProps.length === 0) return;
|
|
1549
1475
|
definedProps = definedProps.map(camelize);
|
|
1550
1476
|
for (const name2 of definedProps.concat(definedProps.map(hyphenate))) {
|
|
1551
1477
|
const value = component2.getAttribute(name2);
|
|
1552
|
-
if (value === null)
|
|
1553
|
-
continue;
|
|
1478
|
+
if (value === null) continue;
|
|
1554
1479
|
props[camelize(name2)] = value;
|
|
1555
1480
|
component2.removeAttribute(name2);
|
|
1556
1481
|
}
|
|
1557
1482
|
const map = binder.__directiveCollector.__collect(component2, false);
|
|
1558
1483
|
for (const [attrName, item] of map.entries()) {
|
|
1559
1484
|
const [name2, option] = item.__terms;
|
|
1560
|
-
if (!option)
|
|
1561
|
-
|
|
1562
|
-
if (
|
|
1563
|
-
continue;
|
|
1564
|
-
if (name2 !== "." && name2 !== ":" && name2 !== bindName)
|
|
1565
|
-
continue;
|
|
1485
|
+
if (!option) continue;
|
|
1486
|
+
if (!definedProps.includes(camelize(option))) continue;
|
|
1487
|
+
if (name2 !== "." && name2 !== ":" && name2 !== bindName) continue;
|
|
1566
1488
|
binder.__bind(
|
|
1567
1489
|
singlePropDirective,
|
|
1568
1490
|
component2,
|
|
@@ -1592,16 +1514,13 @@ var ComponentBinder = class {
|
|
|
1592
1514
|
for (const [key, propsValue] of Object.entries(props)) {
|
|
1593
1515
|
if (key in componentCtx2) {
|
|
1594
1516
|
const compValue = componentCtx2[key];
|
|
1595
|
-
if (compValue === propsValue)
|
|
1596
|
-
continue;
|
|
1517
|
+
if (compValue === propsValue) continue;
|
|
1597
1518
|
if (head2.entangle && isRef(compValue) && isRef(propsValue)) {
|
|
1598
1519
|
addUnbinder(startOfComponent, entangle(propsValue, compValue));
|
|
1599
1520
|
} else if (isRef(compValue)) {
|
|
1600
1521
|
compValue(propsValue);
|
|
1601
|
-
} else
|
|
1602
|
-
|
|
1603
|
-
} else
|
|
1604
|
-
componentCtx2[key] = propsValue;
|
|
1522
|
+
} else componentCtx2[key] = unref(propsValue);
|
|
1523
|
+
} else componentCtx2[key] = propsValue;
|
|
1605
1524
|
}
|
|
1606
1525
|
head2.onAutoPropsAssigned?.();
|
|
1607
1526
|
}
|
|
@@ -1624,8 +1543,7 @@ var ComponentBinder = class {
|
|
|
1624
1543
|
name2 = slot.getAttributeNames().filter((x) => x.startsWith("#"))[0];
|
|
1625
1544
|
if (isNullOrWhitespace(name2)) {
|
|
1626
1545
|
name2 = "default";
|
|
1627
|
-
} else
|
|
1628
|
-
name2 = name2.substring(1);
|
|
1546
|
+
} else name2 = name2.substring(1);
|
|
1629
1547
|
}
|
|
1630
1548
|
let compTemplate = component.querySelector(
|
|
1631
1549
|
`template[name='${name2}'], template[\\#${name2}]`
|
|
@@ -1636,8 +1554,7 @@ var ComponentBinder = class {
|
|
|
1636
1554
|
compTemplate = null;
|
|
1637
1555
|
}
|
|
1638
1556
|
const createSwitchContext = (childNodes2) => {
|
|
1639
|
-
if (head.disableSwitch)
|
|
1640
|
-
return;
|
|
1557
|
+
if (head.disableSwitch) return;
|
|
1641
1558
|
parser.__scoped(capturedContext, () => {
|
|
1642
1559
|
parser.__push(componentCtx);
|
|
1643
1560
|
const props = getProps(slot, parser.__capture());
|
|
@@ -1646,8 +1563,7 @@ var ComponentBinder = class {
|
|
|
1646
1563
|
const switchContext = parser.__capture();
|
|
1647
1564
|
const id = addSwitch(switchContext);
|
|
1648
1565
|
for (const child of childNodes2) {
|
|
1649
|
-
if (!isElement(child))
|
|
1650
|
-
continue;
|
|
1566
|
+
if (!isElement(child)) continue;
|
|
1651
1567
|
child.setAttribute(rswitch, id);
|
|
1652
1568
|
refSwitch(id);
|
|
1653
1569
|
addUnbinder(child, () => {
|
|
@@ -1680,8 +1596,7 @@ var ComponentBinder = class {
|
|
|
1680
1596
|
}
|
|
1681
1597
|
};
|
|
1682
1598
|
const expandNestedSlots = (node) => {
|
|
1683
|
-
if (!isElement(node))
|
|
1684
|
-
return;
|
|
1599
|
+
if (!isElement(node)) return;
|
|
1685
1600
|
const slots = node.querySelectorAll("slot");
|
|
1686
1601
|
if (isSlot(node)) {
|
|
1687
1602
|
expandSlot(node);
|
|
@@ -1703,8 +1618,7 @@ var ComponentBinder = class {
|
|
|
1703
1618
|
expandSlots();
|
|
1704
1619
|
componentParent.insertBefore(endOfComponent, nextSibling);
|
|
1705
1620
|
const transferAttributesToTheComponentChild = () => {
|
|
1706
|
-
if (!registeredComponent.inheritAttrs)
|
|
1707
|
-
return;
|
|
1621
|
+
if (!registeredComponent.inheritAttrs) return;
|
|
1708
1622
|
let inheritorChildNodes = childNodes.filter(
|
|
1709
1623
|
(x) => x.nodeType === Node.ELEMENT_NODE
|
|
1710
1624
|
);
|
|
@@ -1713,11 +1627,9 @@ var ComponentBinder = class {
|
|
|
1713
1627
|
(x) => x.hasAttribute(this.__inherit)
|
|
1714
1628
|
);
|
|
1715
1629
|
const inheritor = inheritorChildNodes[0];
|
|
1716
|
-
if (!inheritor)
|
|
1717
|
-
return;
|
|
1630
|
+
if (!inheritor) return;
|
|
1718
1631
|
for (const attrName of component.getAttributeNames()) {
|
|
1719
|
-
if (attrName === propsName || attrName === propsOnceName)
|
|
1720
|
-
continue;
|
|
1632
|
+
if (attrName === propsName || attrName === propsOnceName) continue;
|
|
1721
1633
|
const value = component.getAttribute(attrName);
|
|
1722
1634
|
if (attrName === "class") {
|
|
1723
1635
|
inheritor.classList.add(...value.split(" "));
|
|
@@ -1777,12 +1689,10 @@ var DirectiveElement = class {
|
|
|
1777
1689
|
__parse() {
|
|
1778
1690
|
let name2 = this.__name;
|
|
1779
1691
|
const isPropShortcut = name2.startsWith(".");
|
|
1780
|
-
if (isPropShortcut)
|
|
1781
|
-
name2 = ":" + name2.slice(1);
|
|
1692
|
+
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1782
1693
|
const firstFlagIndex = name2.indexOf(".");
|
|
1783
1694
|
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1784
|
-
if (isNullOrWhitespace(terms[0]))
|
|
1785
|
-
terms[0] = isPropShortcut ? "." : name2[0];
|
|
1695
|
+
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1786
1696
|
if (firstFlagIndex >= 0) {
|
|
1787
1697
|
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1788
1698
|
if (flags.includes("camel")) {
|
|
@@ -1804,21 +1714,18 @@ var DirectiveCollector = class {
|
|
|
1804
1714
|
}
|
|
1805
1715
|
__collect(element, isRecursive) {
|
|
1806
1716
|
const map = /* @__PURE__ */ new Map();
|
|
1807
|
-
if (!isHTMLElement(element))
|
|
1808
|
-
return map;
|
|
1717
|
+
if (!isHTMLElement(element)) return map;
|
|
1809
1718
|
const prefixes2 = this.__prefixes;
|
|
1810
1719
|
const processNode = (node) => {
|
|
1811
1720
|
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1812
1721
|
for (const name2 of names) {
|
|
1813
|
-
if (!map.has(name2))
|
|
1814
|
-
map.set(name2, new DirectiveElement(name2));
|
|
1722
|
+
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1815
1723
|
const item = map.get(name2);
|
|
1816
1724
|
item.__elements.push(node);
|
|
1817
1725
|
}
|
|
1818
1726
|
};
|
|
1819
1727
|
processNode(element);
|
|
1820
|
-
if (!isRecursive)
|
|
1821
|
-
return map;
|
|
1728
|
+
if (!isRecursive) return map;
|
|
1822
1729
|
const nodes = element.querySelectorAll("*");
|
|
1823
1730
|
for (const node of nodes) {
|
|
1824
1731
|
processNode(node);
|
|
@@ -1855,15 +1762,12 @@ var Binder = class {
|
|
|
1855
1762
|
__unwrapTemplates(element) {
|
|
1856
1763
|
const templates = isTemplate(element) ? [element] : element.querySelectorAll("template");
|
|
1857
1764
|
for (const template of templates) {
|
|
1858
|
-
if (template.hasAttribute(this.__pre))
|
|
1859
|
-
continue;
|
|
1765
|
+
if (template.hasAttribute(this.__pre)) continue;
|
|
1860
1766
|
const parent = template.parentNode;
|
|
1861
|
-
if (!parent)
|
|
1862
|
-
continue;
|
|
1767
|
+
if (!parent) continue;
|
|
1863
1768
|
const nextSibling = template.nextSibling;
|
|
1864
1769
|
template.remove();
|
|
1865
|
-
if (!template.content)
|
|
1866
|
-
continue;
|
|
1770
|
+
if (!template.content) continue;
|
|
1867
1771
|
const childNodes = [...template.content.childNodes];
|
|
1868
1772
|
for (const child of childNodes) {
|
|
1869
1773
|
parent.insertBefore(child, nextSibling);
|
|
@@ -1874,12 +1778,9 @@ var Binder = class {
|
|
|
1874
1778
|
__bindDefault(element) {
|
|
1875
1779
|
if (element.nodeType !== Node.ELEMENT_NODE || element.hasAttribute(this.__pre))
|
|
1876
1780
|
return;
|
|
1877
|
-
if (this.__ifBinder.__bindAll(element))
|
|
1878
|
-
|
|
1879
|
-
if (this.
|
|
1880
|
-
return;
|
|
1881
|
-
if (this.__dynamicBinder.__bindAll(element))
|
|
1882
|
-
return;
|
|
1781
|
+
if (this.__ifBinder.__bindAll(element)) return;
|
|
1782
|
+
if (this.__forBinder.__bindAll(element)) return;
|
|
1783
|
+
if (this.__dynamicBinder.__bindAll(element)) return;
|
|
1883
1784
|
this.__componentBinder.__bindAll(element);
|
|
1884
1785
|
this.__unwrapTemplates(element);
|
|
1885
1786
|
this.__bindAttributes(element, true);
|
|
@@ -1900,16 +1801,13 @@ var Binder = class {
|
|
|
1900
1801
|
}
|
|
1901
1802
|
}
|
|
1902
1803
|
__bind(config, el, attribute, _noWarning, option, flags) {
|
|
1903
|
-
if (el.hasAttribute(this.__pre))
|
|
1904
|
-
return;
|
|
1804
|
+
if (el.hasAttribute(this.__pre)) return;
|
|
1905
1805
|
const bindExpression = el.getAttribute(attribute);
|
|
1906
1806
|
el.removeAttribute(attribute);
|
|
1907
1807
|
const getParentSwitch = (el2) => {
|
|
1908
1808
|
const switchId = el2.getAttribute(rswitch);
|
|
1909
|
-
if (switchId)
|
|
1910
|
-
|
|
1911
|
-
if (!el2.parentElement)
|
|
1912
|
-
return null;
|
|
1809
|
+
if (switchId) return switchId;
|
|
1810
|
+
if (!el2.parentElement) return null;
|
|
1913
1811
|
return getParentSwitch(el2.parentElement);
|
|
1914
1812
|
};
|
|
1915
1813
|
if (hasSwitch()) {
|
|
@@ -1924,15 +1822,12 @@ var Binder = class {
|
|
|
1924
1822
|
this.__bindToExpression(config, el, bindExpression, option, flags);
|
|
1925
1823
|
}
|
|
1926
1824
|
__handleTeleport(config, el, valueExpression) {
|
|
1927
|
-
if (config !== teleportDirective)
|
|
1928
|
-
|
|
1929
|
-
if (isNullOrWhitespace(valueExpression))
|
|
1930
|
-
return true;
|
|
1825
|
+
if (config !== teleportDirective) return false;
|
|
1826
|
+
if (isNullOrWhitespace(valueExpression)) return true;
|
|
1931
1827
|
const teleportTo = document.querySelector(valueExpression);
|
|
1932
1828
|
if (teleportTo) {
|
|
1933
1829
|
const parent = el.parentElement;
|
|
1934
|
-
if (!parent)
|
|
1935
|
-
return true;
|
|
1830
|
+
if (!parent) return true;
|
|
1936
1831
|
const placeholder = new Comment(`teleported => '${valueExpression}'`);
|
|
1937
1832
|
parent.insertBefore(placeholder, el);
|
|
1938
1833
|
el.teleportedFrom = placeholder;
|
|
@@ -1945,10 +1840,8 @@ var Binder = class {
|
|
|
1945
1840
|
return true;
|
|
1946
1841
|
}
|
|
1947
1842
|
__bindToExpression(config, el, valueExpression, option, flags) {
|
|
1948
|
-
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null)
|
|
1949
|
-
|
|
1950
|
-
if (this.__handleTeleport(config, el, valueExpression))
|
|
1951
|
-
return;
|
|
1843
|
+
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null) return;
|
|
1844
|
+
if (this.__handleTeleport(config, el, valueExpression)) return;
|
|
1952
1845
|
const result = this.__parser.__parse(
|
|
1953
1846
|
valueExpression,
|
|
1954
1847
|
config.isLazy,
|
|
@@ -1992,8 +1885,7 @@ var Binder = class {
|
|
|
1992
1885
|
return previousOption;
|
|
1993
1886
|
};
|
|
1994
1887
|
const observeTailChanges = () => {
|
|
1995
|
-
if (!config.onChange)
|
|
1996
|
-
return;
|
|
1888
|
+
if (!config.onChange) return;
|
|
1997
1889
|
const stopObserving = observe(result.value, (_) => {
|
|
1998
1890
|
const pre = previousValues;
|
|
1999
1891
|
const pre2 = previousOption;
|
|
@@ -2008,8 +1900,7 @@ var Binder = class {
|
|
|
2008
1900
|
stopObserverList.push(stopObserving2);
|
|
2009
1901
|
}
|
|
2010
1902
|
};
|
|
2011
|
-
if (!config.once)
|
|
2012
|
-
observeTailChanges();
|
|
1903
|
+
if (!config.once) observeTailChanges();
|
|
2013
1904
|
if (config.onBind)
|
|
2014
1905
|
stopObserverList.push(
|
|
2015
1906
|
config.onBind(
|
|
@@ -2198,8 +2089,7 @@ var Jsep = class {
|
|
|
2198
2089
|
}
|
|
2199
2090
|
__runHook(hookType, hookCalltype, node) {
|
|
2200
2091
|
const hook = this.__hooks[hookType];
|
|
2201
|
-
if (!hook)
|
|
2202
|
-
return node;
|
|
2092
|
+
if (!hook) return node;
|
|
2203
2093
|
const env = { node };
|
|
2204
2094
|
const hookFn = (f) => {
|
|
2205
2095
|
f.call(this, env);
|
|
@@ -2218,8 +2108,7 @@ var Jsep = class {
|
|
|
2218
2108
|
}
|
|
2219
2109
|
parse() {
|
|
2220
2110
|
const nodes = this.__gobbleExpressions();
|
|
2221
|
-
if (nodes.length === 1)
|
|
2222
|
-
return nodes[0];
|
|
2111
|
+
if (nodes.length === 1) return nodes[0];
|
|
2223
2112
|
return {
|
|
2224
2113
|
type: 0 /* Compound */,
|
|
2225
2114
|
body: nodes
|
|
@@ -2834,8 +2723,7 @@ var Jsep = class {
|
|
|
2834
2723
|
this.__updateBinariesToArrows(env.node);
|
|
2835
2724
|
}
|
|
2836
2725
|
__updateBinariesToArrows(node) {
|
|
2837
|
-
if (!node)
|
|
2838
|
-
return;
|
|
2726
|
+
if (!node) return;
|
|
2839
2727
|
Object.values(node).forEach((val) => {
|
|
2840
2728
|
if (val && typeof val === "object") {
|
|
2841
2729
|
this.__updateBinariesToArrows(val);
|
|
@@ -2854,8 +2742,7 @@ var Jsep = class {
|
|
|
2854
2742
|
}
|
|
2855
2743
|
}
|
|
2856
2744
|
__fixAssignmentOperators(env) {
|
|
2857
|
-
if (env.node)
|
|
2858
|
-
this.__updateBinariesToAssignments(env.node);
|
|
2745
|
+
if (env.node) this.__updateBinariesToAssignments(env.node);
|
|
2859
2746
|
}
|
|
2860
2747
|
__updateBinariesToAssignments(node) {
|
|
2861
2748
|
if (assigmentOperatorsSet.has(node.operator)) {
|
|
@@ -2871,12 +2758,10 @@ var Jsep = class {
|
|
|
2871
2758
|
}
|
|
2872
2759
|
}
|
|
2873
2760
|
__gobbleTaggedTemplateIdentifier(env) {
|
|
2874
|
-
if (!env.node)
|
|
2875
|
-
return;
|
|
2761
|
+
if (!env.node) return;
|
|
2876
2762
|
const type = env.node.type;
|
|
2877
2763
|
const condition = (type === 2 /* Identifier */ || type === 3 /* Member */) && this.__isCode(BTICK_CODE);
|
|
2878
|
-
if (!condition)
|
|
2879
|
-
return;
|
|
2764
|
+
if (!condition) return;
|
|
2880
2765
|
env.node = {
|
|
2881
2766
|
type: 17 /* TaggedTemplateExpression */,
|
|
2882
2767
|
tag: env.node,
|
|
@@ -2884,8 +2769,7 @@ var Jsep = class {
|
|
|
2884
2769
|
};
|
|
2885
2770
|
}
|
|
2886
2771
|
__gobbleTemplateLiteral(env) {
|
|
2887
|
-
if (!this.__isCode(BTICK_CODE))
|
|
2888
|
-
return;
|
|
2772
|
+
if (!this.__isCode(BTICK_CODE)) return;
|
|
2889
2773
|
const node = {
|
|
2890
2774
|
type: 19 /* TemplateLiteral */,
|
|
2891
2775
|
quasis: [],
|
|
@@ -2955,8 +2839,7 @@ var Jsep = class {
|
|
|
2955
2839
|
}
|
|
2956
2840
|
__gobbleNew(env) {
|
|
2957
2841
|
const node = env.node;
|
|
2958
|
-
if (!node || node.operator !== "new" || !node.argument)
|
|
2959
|
-
return;
|
|
2842
|
+
if (!node || node.operator !== "new" || !node.argument) return;
|
|
2960
2843
|
if (!node.argument || ![6 /* Call */, 3 /* Member */].includes(node.argument.type))
|
|
2961
2844
|
throw this.__getError("Expected new function()");
|
|
2962
2845
|
env.node = node.argument;
|
|
@@ -2967,8 +2850,7 @@ var Jsep = class {
|
|
|
2967
2850
|
callNode.type = 20 /* NewExpression */;
|
|
2968
2851
|
}
|
|
2969
2852
|
__gobbleRegexLiteral(env) {
|
|
2970
|
-
if (!this.__isCode(FSLASH_CODE))
|
|
2971
|
-
return;
|
|
2853
|
+
if (!this.__isCode(FSLASH_CODE)) return;
|
|
2972
2854
|
const patternIndex = ++this.__index;
|
|
2973
2855
|
let inCharSet = false;
|
|
2974
2856
|
while (this.__index < this.__expr.length) {
|
|
@@ -3066,8 +2948,7 @@ var evalUnaryOp = {
|
|
|
3066
2948
|
// placed here for type safety, never executed,
|
|
3067
2949
|
};
|
|
3068
2950
|
var spreadArgs = (args) => {
|
|
3069
|
-
if (!args?.some(shouldSpreadArray))
|
|
3070
|
-
return args;
|
|
2951
|
+
if (!args?.some(shouldSpreadArray)) return args;
|
|
3071
2952
|
const result = [];
|
|
3072
2953
|
args.forEach(
|
|
3073
2954
|
(x) => shouldSpreadArray(x) ? result.push(...x) : result.push(x)
|
|
@@ -3076,8 +2957,7 @@ var spreadArgs = (args) => {
|
|
|
3076
2957
|
};
|
|
3077
2958
|
var arrayEvaluator = (...args) => spreadArgs(args);
|
|
3078
2959
|
var createLazyContext = (e, context) => {
|
|
3079
|
-
if (!e)
|
|
3080
|
-
return context;
|
|
2960
|
+
if (!e) return context;
|
|
3081
2961
|
const ctx = Object.create(context ?? {});
|
|
3082
2962
|
ctx.$event = e;
|
|
3083
2963
|
return ctx;
|
|
@@ -3232,22 +3112,17 @@ var RegorEval = class {
|
|
|
3232
3112
|
this.__collectRefObj = !!collectRefObj;
|
|
3233
3113
|
}
|
|
3234
3114
|
__findContext(name2, context) {
|
|
3235
|
-
if (context && name2 in context)
|
|
3236
|
-
return context;
|
|
3115
|
+
if (context && name2 in context) return context;
|
|
3237
3116
|
for (const ctx of this.__contexts) {
|
|
3238
|
-
if (name2 in ctx)
|
|
3239
|
-
return ctx;
|
|
3117
|
+
if (name2 in ctx) return ctx;
|
|
3240
3118
|
}
|
|
3241
3119
|
return void 0;
|
|
3242
3120
|
}
|
|
3243
3121
|
[2 /* Identifier */](expr, _, context) {
|
|
3244
3122
|
const name2 = expr.name;
|
|
3245
|
-
if (name2 === "$root")
|
|
3246
|
-
|
|
3247
|
-
if (name2 === "$
|
|
3248
|
-
return this.__contexts[1];
|
|
3249
|
-
if (name2 === "$ctx")
|
|
3250
|
-
return [...this.__contexts];
|
|
3123
|
+
if (name2 === "$root") return this.__contexts[this.__contexts.length - 1];
|
|
3124
|
+
if (name2 === "$parent") return this.__contexts[1];
|
|
3125
|
+
if (name2 === "$ctx") return [...this.__contexts];
|
|
3251
3126
|
if (context && name2 in context) {
|
|
3252
3127
|
this.__lastEvaluatedValueBeforeUnref = context[name2];
|
|
3253
3128
|
return associateThis(unref(context[name2]), context);
|
|
@@ -3388,8 +3263,7 @@ var RegorEval = class {
|
|
|
3388
3263
|
if (arg.type === 2 /* Identifier */) {
|
|
3389
3264
|
const name2 = arg.name;
|
|
3390
3265
|
const ctx = this.__findContext(name2, context);
|
|
3391
|
-
if (isNullOrUndefined(ctx))
|
|
3392
|
-
return void 0;
|
|
3266
|
+
if (isNullOrUndefined(ctx)) return void 0;
|
|
3393
3267
|
return updater[op](ctx, name2);
|
|
3394
3268
|
}
|
|
3395
3269
|
if (arg.type === 3 /* Member */) {
|
|
@@ -3407,8 +3281,7 @@ var RegorEval = class {
|
|
|
3407
3281
|
if (arg.type === 2 /* Identifier */) {
|
|
3408
3282
|
const name2 = arg.name;
|
|
3409
3283
|
const ctx = this.__findContext(name2, context);
|
|
3410
|
-
if (isNullOrUndefined(ctx))
|
|
3411
|
-
return void 0;
|
|
3284
|
+
if (isNullOrUndefined(ctx)) return void 0;
|
|
3412
3285
|
const value = this.__eval(expr.right, depth, context);
|
|
3413
3286
|
return applyAssigment[op](ctx, name2, value);
|
|
3414
3287
|
}
|
|
@@ -3424,8 +3297,7 @@ var RegorEval = class {
|
|
|
3424
3297
|
}
|
|
3425
3298
|
[14 /* Spread */](expr, depth, context) {
|
|
3426
3299
|
const spreaded = this.__eval(expr.argument, depth, context);
|
|
3427
|
-
if (isArray(spreaded))
|
|
3428
|
-
spreaded.s = spreadElementSymbol;
|
|
3300
|
+
if (isArray(spreaded)) spreaded.s = spreadElementSymbol;
|
|
3429
3301
|
return spreaded;
|
|
3430
3302
|
}
|
|
3431
3303
|
[17 /* TaggedTemplateExpression */](expr, depth, context) {
|
|
@@ -3513,8 +3385,7 @@ var RegorEval = class {
|
|
|
3513
3385
|
}
|
|
3514
3386
|
__transformLazy(depth, context, evaluator, ...args) {
|
|
3515
3387
|
const isLazy = this.__isLazy;
|
|
3516
|
-
if (!isLazy)
|
|
3517
|
-
return this.__transform(depth, context, evaluator, ...args);
|
|
3388
|
+
if (!isLazy) return this.__transform(depth, context, evaluator, ...args);
|
|
3518
3389
|
const evaluatedArgs = args.map(
|
|
3519
3390
|
(arg, i) => arg && (arg.type !== 15 /* Arrow */ && isLazy(i, depth) ? (e) => this.__eval(arg, depth, createLazyContext(e, context)) : this.__eval(arg, depth, context))
|
|
3520
3391
|
);
|
|
@@ -3564,8 +3435,7 @@ var Parser = class {
|
|
|
3564
3435
|
refs: [],
|
|
3565
3436
|
context: this.__contexts[0]
|
|
3566
3437
|
};
|
|
3567
|
-
if (isNullOrWhitespace(expression))
|
|
3568
|
-
return result;
|
|
3438
|
+
if (isNullOrWhitespace(expression)) return result;
|
|
3569
3439
|
const globalContext = this.__config.globalContext;
|
|
3570
3440
|
const refs = [];
|
|
3571
3441
|
const evaluate = (expr, contexts, collectRefs2, context) => {
|
|
@@ -3673,8 +3543,7 @@ function includeBooleanAttr(value) {
|
|
|
3673
3543
|
var attrDirective = {
|
|
3674
3544
|
onChange: (el, values, previousValues, option, previousOption, flags) => {
|
|
3675
3545
|
if (option) {
|
|
3676
|
-
if (flags && flags.includes("camel"))
|
|
3677
|
-
option = camelize(option);
|
|
3546
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3678
3547
|
patchAttribute(el, option, values[0], previousOption);
|
|
3679
3548
|
return;
|
|
3680
3549
|
}
|
|
@@ -3760,25 +3629,22 @@ var patchClass = (el, next, prev) => {
|
|
|
3760
3629
|
if (next && !isClassString) {
|
|
3761
3630
|
if (prev && !isPrevClassString) {
|
|
3762
3631
|
for (const key in prev) {
|
|
3763
|
-
if (!(key in next)) {
|
|
3632
|
+
if (!(key in next) || !next[key]) {
|
|
3764
3633
|
classList.remove(key);
|
|
3765
3634
|
}
|
|
3766
3635
|
}
|
|
3767
3636
|
}
|
|
3768
3637
|
for (const key in next) {
|
|
3769
|
-
if (next[key])
|
|
3770
|
-
classList.add(key);
|
|
3638
|
+
if (next[key]) classList.add(key);
|
|
3771
3639
|
}
|
|
3772
3640
|
} else {
|
|
3773
3641
|
if (isClassString) {
|
|
3774
3642
|
if (prev !== next) {
|
|
3775
|
-
if (isPrevClassString)
|
|
3776
|
-
classList.remove(...prev?.split(","));
|
|
3643
|
+
if (isPrevClassString) classList.remove(...prev?.split(","));
|
|
3777
3644
|
classList.add(...next.split(","));
|
|
3778
3645
|
}
|
|
3779
3646
|
} else if (prev) {
|
|
3780
|
-
if (isPrevClassString)
|
|
3781
|
-
classList.remove(...prev?.split(","));
|
|
3647
|
+
if (isPrevClassString) classList.remove(...prev?.split(","));
|
|
3782
3648
|
}
|
|
3783
3649
|
}
|
|
3784
3650
|
};
|
|
@@ -3787,17 +3653,14 @@ var patchClass = (el, next, prev) => {
|
|
|
3787
3653
|
var htmlDirective = {
|
|
3788
3654
|
onChange: (el, values) => {
|
|
3789
3655
|
const [value, replacer] = values;
|
|
3790
|
-
if (isFunction(replacer))
|
|
3791
|
-
|
|
3792
|
-
else
|
|
3793
|
-
el.innerHTML = value?.toString();
|
|
3656
|
+
if (isFunction(replacer)) replacer(el, value);
|
|
3657
|
+
else el.innerHTML = value?.toString();
|
|
3794
3658
|
}
|
|
3795
3659
|
};
|
|
3796
3660
|
|
|
3797
3661
|
// src/common/looseEqual.ts
|
|
3798
3662
|
function looseCompareArrays(a, b) {
|
|
3799
|
-
if (a.length !== b.length)
|
|
3800
|
-
return false;
|
|
3663
|
+
if (a.length !== b.length) return false;
|
|
3801
3664
|
let equal = true;
|
|
3802
3665
|
for (let i = 0; equal && i < a.length; i++) {
|
|
3803
3666
|
equal = looseEqual(a[i], b[i]);
|
|
@@ -3805,8 +3668,7 @@ function looseCompareArrays(a, b) {
|
|
|
3805
3668
|
return equal;
|
|
3806
3669
|
}
|
|
3807
3670
|
function looseEqual(a, b) {
|
|
3808
|
-
if (a === b)
|
|
3809
|
-
return true;
|
|
3671
|
+
if (a === b) return true;
|
|
3810
3672
|
let aValidType = isDate(a);
|
|
3811
3673
|
let bValidType = isDate(b);
|
|
3812
3674
|
if (aValidType || bValidType) {
|
|
@@ -3912,8 +3774,7 @@ var updateDomElementValue = (el, value) => {
|
|
|
3912
3774
|
}
|
|
3913
3775
|
} else {
|
|
3914
3776
|
if (looseEqual(getValue(option), value)) {
|
|
3915
|
-
if (el.selectedIndex !== i)
|
|
3916
|
-
el.selectedIndex = i;
|
|
3777
|
+
if (el.selectedIndex !== i) el.selectedIndex = i;
|
|
3917
3778
|
return;
|
|
3918
3779
|
}
|
|
3919
3780
|
}
|
|
@@ -3926,10 +3787,8 @@ var updateDomElementValue = (el, value) => {
|
|
|
3926
3787
|
}
|
|
3927
3788
|
};
|
|
3928
3789
|
var getFlags = (flag) => {
|
|
3929
|
-
if (isRef(flag))
|
|
3930
|
-
|
|
3931
|
-
if (isFunction(flag))
|
|
3932
|
-
flag = flag();
|
|
3790
|
+
if (isRef(flag)) flag = flag();
|
|
3791
|
+
if (isFunction(flag)) flag = flag();
|
|
3933
3792
|
if (!flag)
|
|
3934
3793
|
return {
|
|
3935
3794
|
trim: false,
|
|
@@ -3963,7 +3822,7 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
|
|
|
3963
3822
|
const f1 = getFlags(directiveFlags?.join(","));
|
|
3964
3823
|
const f2 = getFlags(parsedValue()[1]);
|
|
3965
3824
|
const flags = {
|
|
3966
|
-
int: f1.int ||
|
|
3825
|
+
int: f1.int || f2.int,
|
|
3967
3826
|
lazy: f1.lazy || f2.lazy,
|
|
3968
3827
|
number: f1.number || f2.number,
|
|
3969
3828
|
trim: f1.trim || f2.trim
|
|
@@ -3995,8 +3854,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
3995
3854
|
const eventType = isLazy ? "change" : "input";
|
|
3996
3855
|
const isNumber = isNumberInput(el);
|
|
3997
3856
|
const trimmer = () => {
|
|
3998
|
-
if (!flags.trim && !getFlags(parsedValue()[1]).trim)
|
|
3999
|
-
return;
|
|
3857
|
+
if (!flags.trim && !getFlags(parsedValue()[1]).trim) return;
|
|
4000
3858
|
el.value = el.value.trim();
|
|
4001
3859
|
};
|
|
4002
3860
|
const onCompositionStart = (e) => {
|
|
@@ -4019,8 +3877,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4019
3877
|
};
|
|
4020
3878
|
const listener = (event) => {
|
|
4021
3879
|
const target = event.target;
|
|
4022
|
-
if (!target || target.composing)
|
|
4023
|
-
return;
|
|
3880
|
+
if (!target || target.composing) return;
|
|
4024
3881
|
let value = target.value;
|
|
4025
3882
|
const flags2 = getFlags(parsedValue()[1]);
|
|
4026
3883
|
if (isNumber || flags2.number || flags2.int) {
|
|
@@ -4031,15 +3888,12 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4031
3888
|
if (endsWithDecimalSeparator) {
|
|
4032
3889
|
value += "0";
|
|
4033
3890
|
value = parseFloat(value);
|
|
4034
|
-
if (isNaN(value))
|
|
4035
|
-
|
|
4036
|
-
else if (modelRef() === value)
|
|
4037
|
-
return;
|
|
3891
|
+
if (isNaN(value)) value = "";
|
|
3892
|
+
else if (modelRef() === value) return;
|
|
4038
3893
|
}
|
|
4039
3894
|
value = parseFloat(value);
|
|
4040
3895
|
}
|
|
4041
|
-
if (isNaN(value))
|
|
4042
|
-
value = "";
|
|
3896
|
+
if (isNaN(value)) value = "";
|
|
4043
3897
|
el.value = value;
|
|
4044
3898
|
} else if (flags2.trim) {
|
|
4045
3899
|
value = value.trim();
|
|
@@ -4096,8 +3950,7 @@ var getCheckboxValue = (el, checked) => {
|
|
|
4096
3950
|
return el[key];
|
|
4097
3951
|
}
|
|
4098
3952
|
const attrKey = checked ? trueValueAttrKey : falseValueAttrKey;
|
|
4099
|
-
if (el.hasAttribute(attrKey))
|
|
4100
|
-
return el.getAttribute(attrKey);
|
|
3953
|
+
if (el.hasAttribute(attrKey)) return el.getAttribute(attrKey);
|
|
4101
3954
|
return checked;
|
|
4102
3955
|
};
|
|
4103
3956
|
var getCheckboxChecked = (el, value) => {
|
|
@@ -4139,8 +3992,7 @@ var handleSelect = (el, modelRef, parsedValue) => {
|
|
|
4139
3992
|
pause(modelRef);
|
|
4140
3993
|
if (isSet(modelValue)) {
|
|
4141
3994
|
modelValue.clear();
|
|
4142
|
-
for (const sel of selectedValue)
|
|
4143
|
-
modelValue.add(sel);
|
|
3995
|
+
for (const sel of selectedValue) modelValue.add(sel);
|
|
4144
3996
|
} else if (isArray(modelValue)) {
|
|
4145
3997
|
modelValue.splice(0);
|
|
4146
3998
|
modelValue.push(...selectedValue);
|
|
@@ -4191,9 +4043,8 @@ var onDirective = {
|
|
|
4191
4043
|
if (dynamicOption) {
|
|
4192
4044
|
const values2 = parseResult.value();
|
|
4193
4045
|
const option2 = unref(dynamicOption.value()[0]);
|
|
4194
|
-
if (!isString(option2))
|
|
4195
|
-
|
|
4196
|
-
};
|
|
4046
|
+
if (!isString(option2)) return () => {
|
|
4047
|
+
};
|
|
4197
4048
|
return attachEventListener(
|
|
4198
4049
|
el,
|
|
4199
4050
|
camelize(option2),
|
|
@@ -4217,18 +4068,15 @@ var onDirective = {
|
|
|
4217
4068
|
const len = values.length;
|
|
4218
4069
|
for (let i = 0; i < len; ++i) {
|
|
4219
4070
|
let next = values[i];
|
|
4220
|
-
if (isFunction(next))
|
|
4221
|
-
next = next();
|
|
4071
|
+
if (isFunction(next)) next = next();
|
|
4222
4072
|
if (isObject(next)) {
|
|
4223
4073
|
for (const item of Object.entries(next)) {
|
|
4224
4074
|
const eventType = item[0];
|
|
4225
4075
|
const method = () => {
|
|
4226
4076
|
let obj = parseResult.value()[i];
|
|
4227
|
-
if (isFunction(obj))
|
|
4228
|
-
obj = obj();
|
|
4077
|
+
if (isFunction(obj)) obj = obj();
|
|
4229
4078
|
obj = obj[eventType];
|
|
4230
|
-
if (isFunction(obj))
|
|
4231
|
-
obj = obj();
|
|
4079
|
+
if (isFunction(obj)) obj = obj();
|
|
4232
4080
|
return obj;
|
|
4233
4081
|
};
|
|
4234
4082
|
const flags2 = next[eventType + "_flags"];
|
|
@@ -4252,22 +4100,17 @@ var getShouldExecuteEvent = (eventType, flags) => {
|
|
|
4252
4100
|
const isAlt = parts.includes("alt");
|
|
4253
4101
|
const isMeta = parts.includes("meta");
|
|
4254
4102
|
const checkModifiers = (e) => {
|
|
4255
|
-
if (isCtrl && !e.ctrlKey)
|
|
4256
|
-
|
|
4257
|
-
if (
|
|
4258
|
-
|
|
4259
|
-
if (isAlt && !e.altKey)
|
|
4260
|
-
return false;
|
|
4261
|
-
if (isMeta && !e.metaKey)
|
|
4262
|
-
return false;
|
|
4103
|
+
if (isCtrl && !e.ctrlKey) return false;
|
|
4104
|
+
if (isShift && !e.shiftKey) return false;
|
|
4105
|
+
if (isAlt && !e.altKey) return false;
|
|
4106
|
+
if (isMeta && !e.metaKey) return false;
|
|
4263
4107
|
return true;
|
|
4264
4108
|
};
|
|
4265
4109
|
if (keyType) {
|
|
4266
4110
|
return [
|
|
4267
4111
|
eventType,
|
|
4268
4112
|
(e) => {
|
|
4269
|
-
if (!checkModifiers(e))
|
|
4270
|
-
return false;
|
|
4113
|
+
if (!checkModifiers(e)) return false;
|
|
4271
4114
|
return e.key.toUpperCase() === keyType.toUpperCase();
|
|
4272
4115
|
}
|
|
4273
4116
|
];
|
|
@@ -4291,15 +4134,11 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4291
4134
|
let shouldExecuteEvent;
|
|
4292
4135
|
[eventType, shouldExecuteEvent] = getShouldExecuteEvent(eventType, flags);
|
|
4293
4136
|
const execute = (e) => {
|
|
4294
|
-
if (!shouldExecuteEvent(e))
|
|
4295
|
-
|
|
4296
|
-
if (!method && eventType === "submit" && flag?.prevent)
|
|
4297
|
-
return;
|
|
4137
|
+
if (!shouldExecuteEvent(e)) return;
|
|
4138
|
+
if (!method && eventType === "submit" && flag?.prevent) return;
|
|
4298
4139
|
let r = method(e);
|
|
4299
|
-
if (isFunction(r))
|
|
4300
|
-
|
|
4301
|
-
if (isFunction(r))
|
|
4302
|
-
r(e);
|
|
4140
|
+
if (isFunction(r)) r = r(e);
|
|
4141
|
+
if (isFunction(r)) r(e);
|
|
4303
4142
|
};
|
|
4304
4143
|
const unbinder = () => {
|
|
4305
4144
|
el.removeEventListener(eventType, listener, options);
|
|
@@ -4310,22 +4149,15 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4310
4149
|
return;
|
|
4311
4150
|
}
|
|
4312
4151
|
try {
|
|
4313
|
-
if (flag.left && e.button !==
|
|
4314
|
-
|
|
4315
|
-
if (flag.
|
|
4316
|
-
|
|
4317
|
-
if (flag.
|
|
4318
|
-
|
|
4319
|
-
if (flag.self && e.target !== el)
|
|
4320
|
-
return;
|
|
4321
|
-
if (flag.stop)
|
|
4322
|
-
e.stopPropagation();
|
|
4323
|
-
if (flag.prevent)
|
|
4324
|
-
e.preventDefault();
|
|
4152
|
+
if (flag.left && e.button !== 0) return;
|
|
4153
|
+
if (flag.middle && e.button !== 1) return;
|
|
4154
|
+
if (flag.right && e.button !== 2) return;
|
|
4155
|
+
if (flag.self && e.target !== el) return;
|
|
4156
|
+
if (flag.stop) e.stopPropagation();
|
|
4157
|
+
if (flag.prevent) e.preventDefault();
|
|
4325
4158
|
execute(e);
|
|
4326
4159
|
} finally {
|
|
4327
|
-
if (flag.once)
|
|
4328
|
-
unbinder();
|
|
4160
|
+
if (flag.once) unbinder();
|
|
4329
4161
|
}
|
|
4330
4162
|
};
|
|
4331
4163
|
el.addEventListener(eventType, listener, options);
|
|
@@ -4336,8 +4168,7 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4336
4168
|
var propDirective = {
|
|
4337
4169
|
onChange: (el, values, _previousValues, option, _previousOption, flags) => {
|
|
4338
4170
|
if (option) {
|
|
4339
|
-
if (flags && flags.includes("camel"))
|
|
4340
|
-
option = camelize(option);
|
|
4171
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
4341
4172
|
patchProp(el, option, values[0]);
|
|
4342
4173
|
return;
|
|
4343
4174
|
}
|
|
@@ -4420,18 +4251,14 @@ var refDirective = {
|
|
|
4420
4251
|
const value = result.value()[0];
|
|
4421
4252
|
const isAnArray = isArray(value);
|
|
4422
4253
|
const sref2 = result.refs[0];
|
|
4423
|
-
if (isAnArray)
|
|
4424
|
-
|
|
4425
|
-
else
|
|
4426
|
-
sref2?.(el);
|
|
4427
|
-
else
|
|
4428
|
-
result.context[expr] = el;
|
|
4254
|
+
if (isAnArray) value.push(el);
|
|
4255
|
+
else if (sref2) sref2?.(el);
|
|
4256
|
+
else result.context[expr] = el;
|
|
4429
4257
|
return () => {
|
|
4430
4258
|
if (isAnArray) {
|
|
4431
4259
|
const i = value.indexOf(el);
|
|
4432
4260
|
i !== -1 && value.splice(i, 1);
|
|
4433
|
-
} else
|
|
4434
|
-
sref2?.(null);
|
|
4261
|
+
} else sref2?.(null);
|
|
4435
4262
|
};
|
|
4436
4263
|
}
|
|
4437
4264
|
};
|
|
@@ -4445,10 +4272,8 @@ var showDirective = {
|
|
|
4445
4272
|
originalDisplay = data._ord = el.style.display;
|
|
4446
4273
|
}
|
|
4447
4274
|
const isVisible = !!values[0];
|
|
4448
|
-
if (isVisible)
|
|
4449
|
-
|
|
4450
|
-
else
|
|
4451
|
-
el.style.display = "none";
|
|
4275
|
+
if (isVisible) el.style.display = originalDisplay;
|
|
4276
|
+
else el.style.display = "none";
|
|
4452
4277
|
}
|
|
4453
4278
|
};
|
|
4454
4279
|
|
|
@@ -4494,8 +4319,7 @@ var patchStyle = (el, next, prev) => {
|
|
|
4494
4319
|
el.removeAttribute("style");
|
|
4495
4320
|
}
|
|
4496
4321
|
const data = getBindData(el).data;
|
|
4497
|
-
if ("_ord" in data)
|
|
4498
|
-
return;
|
|
4322
|
+
if ("_ord" in data) return;
|
|
4499
4323
|
style.display = currentDisplay;
|
|
4500
4324
|
}
|
|
4501
4325
|
};
|
|
@@ -4506,8 +4330,7 @@ function setStyle(style, name2, val) {
|
|
|
4506
4330
|
setStyle(style, name2, v);
|
|
4507
4331
|
});
|
|
4508
4332
|
} else {
|
|
4509
|
-
if (val == null)
|
|
4510
|
-
val = "";
|
|
4333
|
+
if (val == null) val = "";
|
|
4511
4334
|
if (name2.startsWith("--")) {
|
|
4512
4335
|
style.setProperty(name2, val);
|
|
4513
4336
|
} else {
|
|
@@ -4549,11 +4372,9 @@ function autoPrefix(style, rawName) {
|
|
|
4549
4372
|
var flatten = (reference) => {
|
|
4550
4373
|
return flattenContent(unref(reference));
|
|
4551
4374
|
};
|
|
4552
|
-
var flattenContent = (value) => {
|
|
4553
|
-
if (!value)
|
|
4554
|
-
|
|
4555
|
-
if (!isObject(value))
|
|
4556
|
-
return value;
|
|
4375
|
+
var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
|
|
4376
|
+
if (!value) return value;
|
|
4377
|
+
if (!isObject(value)) return value;
|
|
4557
4378
|
if (isArray(value)) {
|
|
4558
4379
|
return value.map(flatten);
|
|
4559
4380
|
}
|
|
@@ -4566,14 +4387,16 @@ var flattenContent = (value) => {
|
|
|
4566
4387
|
}
|
|
4567
4388
|
if (isMap(value)) {
|
|
4568
4389
|
const map = /* @__PURE__ */ new Map();
|
|
4569
|
-
for (const el of
|
|
4390
|
+
for (const el of value) {
|
|
4570
4391
|
map.set(flatten(el[0]), flatten(el[1]));
|
|
4571
4392
|
}
|
|
4572
4393
|
return map;
|
|
4573
4394
|
}
|
|
4395
|
+
if (weakMap.has(value)) return unref(weakMap.get(value));
|
|
4574
4396
|
const result = { ...value };
|
|
4397
|
+
weakMap.set(value, result);
|
|
4575
4398
|
for (const entry of Object.entries(result)) {
|
|
4576
|
-
result[entry[0]] =
|
|
4399
|
+
result[entry[0]] = flattenContent(unref(entry[1]), weakMap);
|
|
4577
4400
|
}
|
|
4578
4401
|
return result;
|
|
4579
4402
|
};
|
|
@@ -4600,8 +4423,7 @@ var isDeepRef = (value) => {
|
|
|
4600
4423
|
|
|
4601
4424
|
// src/reactivity/ref.ts
|
|
4602
4425
|
var ref = (value) => {
|
|
4603
|
-
if (isRaw(value))
|
|
4604
|
-
return value;
|
|
4426
|
+
if (isRaw(value)) return value;
|
|
4605
4427
|
let result;
|
|
4606
4428
|
if (isRef(value)) {
|
|
4607
4429
|
result = value;
|
|
@@ -4616,21 +4438,18 @@ var ref = (value) => {
|
|
|
4616
4438
|
const len = value.length;
|
|
4617
4439
|
for (let i = 0; i < len; ++i) {
|
|
4618
4440
|
const item = value[i];
|
|
4619
|
-
if (isDeepRef(item))
|
|
4620
|
-
continue;
|
|
4441
|
+
if (isDeepRef(item)) continue;
|
|
4621
4442
|
value[i] = ref(item);
|
|
4622
4443
|
}
|
|
4623
4444
|
return result;
|
|
4624
4445
|
}
|
|
4625
|
-
if (!isObject(value))
|
|
4626
|
-
return result;
|
|
4446
|
+
if (!isObject(value)) return result;
|
|
4627
4447
|
for (const item of Object.entries(value)) {
|
|
4628
4448
|
const val = item[1];
|
|
4629
|
-
if (isDeepRef(val))
|
|
4630
|
-
continue;
|
|
4449
|
+
if (isDeepRef(val)) continue;
|
|
4631
4450
|
const key = item[0];
|
|
4632
|
-
if (isSymbol(key))
|
|
4633
|
-
|
|
4451
|
+
if (isSymbol(key)) continue;
|
|
4452
|
+
value[key] = null;
|
|
4634
4453
|
value[key] = ref(val);
|
|
4635
4454
|
}
|
|
4636
4455
|
return result;
|
|
@@ -4763,8 +4582,7 @@ var RegorConfig = class _RegorConfig {
|
|
|
4763
4582
|
|
|
4764
4583
|
// src/bind/interpolation.ts
|
|
4765
4584
|
var interpolate = (element, config) => {
|
|
4766
|
-
if (!element)
|
|
4767
|
-
return;
|
|
4585
|
+
if (!element) return;
|
|
4768
4586
|
const builtInNames = (config ?? RegorConfig.getDefault()).__builtInNames;
|
|
4769
4587
|
for (const textNode of getTextNodes(element, builtInNames.pre)) {
|
|
4770
4588
|
interpolateTextNode(textNode, builtInNames.text);
|
|
@@ -4773,12 +4591,10 @@ var interpolate = (element, config) => {
|
|
|
4773
4591
|
var interpolationRegex = /({{[^]*?}})/g;
|
|
4774
4592
|
var interpolateTextNode = (textNode, textDirective2) => {
|
|
4775
4593
|
const text = textNode.textContent;
|
|
4776
|
-
if (!text)
|
|
4777
|
-
return;
|
|
4594
|
+
if (!text) return;
|
|
4778
4595
|
const mustacheRegex = interpolationRegex;
|
|
4779
4596
|
const parts = text.split(mustacheRegex);
|
|
4780
|
-
if (parts.length <= 1)
|
|
4781
|
-
return;
|
|
4597
|
+
if (parts.length <= 1) return;
|
|
4782
4598
|
if (textNode.parentElement?.childNodes.length === 1 && parts.length === 3) {
|
|
4783
4599
|
const part = parts[1];
|
|
4784
4600
|
if (isNullOrWhitespace(parts[0]) && isNullOrWhitespace(parts[2]) && part.startsWith("{{") && part.endsWith("}}")) {
|
|
@@ -4809,8 +4625,7 @@ var getTextNodes = (node, preDirective) => {
|
|
|
4809
4625
|
textNodes.push(node2);
|
|
4810
4626
|
}
|
|
4811
4627
|
} else {
|
|
4812
|
-
if (node2?.hasAttribute?.(preDirective))
|
|
4813
|
-
return;
|
|
4628
|
+
if (node2?.hasAttribute?.(preDirective)) return;
|
|
4814
4629
|
for (const child of getChildNodes(node2)) {
|
|
4815
4630
|
traverseTextNodes(child);
|
|
4816
4631
|
}
|
|
@@ -4825,10 +4640,8 @@ var svgTags = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-
|
|
|
4825
4640
|
var svgSet = new Set(svgTags.toUpperCase().split(","));
|
|
4826
4641
|
var svgNamespace = "http://www.w3.org/2000/svg";
|
|
4827
4642
|
var appendChild = (parent, el) => {
|
|
4828
|
-
if (isTemplate(parent))
|
|
4829
|
-
|
|
4830
|
-
else
|
|
4831
|
-
parent.appendChild(el);
|
|
4643
|
+
if (isTemplate(parent)) parent.content.appendChild(el);
|
|
4644
|
+
else parent.appendChild(el);
|
|
4832
4645
|
};
|
|
4833
4646
|
var render = (json, parent, isSVG, config) => {
|
|
4834
4647
|
const tag = json.t;
|
|
@@ -4848,8 +4661,7 @@ var render = (json, parent, isSVG, config) => {
|
|
|
4848
4661
|
}
|
|
4849
4662
|
const children = json.c;
|
|
4850
4663
|
if (children) {
|
|
4851
|
-
for (const child of children)
|
|
4852
|
-
render(child, el, isSVG, config);
|
|
4664
|
+
for (const child of children) render(child, el, isSVG, config);
|
|
4853
4665
|
}
|
|
4854
4666
|
appendChild(parent, el);
|
|
4855
4667
|
return;
|
|
@@ -4865,10 +4677,8 @@ var render = (json, parent, isSVG, config) => {
|
|
|
4865
4677
|
node = document.createTextNode(textData);
|
|
4866
4678
|
break;
|
|
4867
4679
|
}
|
|
4868
|
-
if (node)
|
|
4869
|
-
|
|
4870
|
-
else
|
|
4871
|
-
throw new Error("unsupported node type.");
|
|
4680
|
+
if (node) appendChild(parent, node);
|
|
4681
|
+
else throw new Error("unsupported node type.");
|
|
4872
4682
|
}
|
|
4873
4683
|
};
|
|
4874
4684
|
var toFragment = (json, isSVG, config) => {
|
|
@@ -4885,16 +4695,13 @@ var toFragment = (json, isSVG, config) => {
|
|
|
4885
4695
|
};
|
|
4886
4696
|
|
|
4887
4697
|
// src/app/createApp.ts
|
|
4888
|
-
var createApp = (context,
|
|
4889
|
-
if (isString(
|
|
4890
|
-
|
|
4891
|
-
if (isScope(context))
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
if (!
|
|
4895
|
-
throw getError(0 /* AppRootElementMissing */);
|
|
4896
|
-
if (!config)
|
|
4897
|
-
config = RegorConfig.getDefault();
|
|
4698
|
+
var createApp = (context, template = { selector: "#app" }, config) => {
|
|
4699
|
+
if (isString(template))
|
|
4700
|
+
template = { selector: "#app", template };
|
|
4701
|
+
if (isScope(context)) context = context.context;
|
|
4702
|
+
const root = template.element ? template.element : template.selector ? document.querySelector(template.selector) : null;
|
|
4703
|
+
if (!root || !isElement(root)) throw getError(0 /* AppRootElementMissing */);
|
|
4704
|
+
if (!config) config = RegorConfig.getDefault();
|
|
4898
4705
|
const cleanRoot = () => {
|
|
4899
4706
|
for (const child of [...root.childNodes]) {
|
|
4900
4707
|
removeNode(child);
|
|
@@ -4905,22 +4712,21 @@ var createApp = (context, templateOptions = { selector: "#app" }, config) => {
|
|
|
4905
4712
|
root.appendChild(child);
|
|
4906
4713
|
}
|
|
4907
4714
|
};
|
|
4908
|
-
if (
|
|
4909
|
-
const element = document.createRange().createContextualFragment(
|
|
4715
|
+
if (template.template) {
|
|
4716
|
+
const element = document.createRange().createContextualFragment(template.template);
|
|
4910
4717
|
cleanRoot();
|
|
4911
4718
|
appendChildren(element.childNodes);
|
|
4912
|
-
|
|
4913
|
-
} else if (
|
|
4719
|
+
template.element = element;
|
|
4720
|
+
} else if (template.json) {
|
|
4914
4721
|
const element = toFragment(
|
|
4915
|
-
|
|
4916
|
-
|
|
4722
|
+
template.json,
|
|
4723
|
+
template.isSVG,
|
|
4917
4724
|
config
|
|
4918
4725
|
);
|
|
4919
4726
|
cleanRoot();
|
|
4920
4727
|
appendChildren(element.childNodes);
|
|
4921
4728
|
}
|
|
4922
|
-
if (config.useInterpolation)
|
|
4923
|
-
interpolate(root, config);
|
|
4729
|
+
if (config.useInterpolation) interpolate(root, config);
|
|
4924
4730
|
const app = new RegorApp(context, root, config);
|
|
4925
4731
|
app.__bind();
|
|
4926
4732
|
addUnbinder(root, () => {
|
|
@@ -4961,13 +4767,10 @@ var toJsonTemplate = (node) => {
|
|
|
4961
4767
|
return node.map((x) => toJsonTemplate(x));
|
|
4962
4768
|
}
|
|
4963
4769
|
const json = {};
|
|
4964
|
-
if (node.tagName)
|
|
4965
|
-
json.t = node.tagName;
|
|
4770
|
+
if (node.tagName) json.t = node.tagName;
|
|
4966
4771
|
else {
|
|
4967
|
-
if (node.nodeType === Node.COMMENT_NODE)
|
|
4968
|
-
|
|
4969
|
-
if (node.textContent)
|
|
4970
|
-
json.d = node.textContent;
|
|
4772
|
+
if (node.nodeType === Node.COMMENT_NODE) json.n = Node.COMMENT_NODE;
|
|
4773
|
+
if (node.textContent) json.d = node.textContent;
|
|
4971
4774
|
return json;
|
|
4972
4775
|
}
|
|
4973
4776
|
const attrNames = node.getAttributeNames();
|
|
@@ -4986,50 +4789,47 @@ var toJsonTemplate = (node) => {
|
|
|
4986
4789
|
};
|
|
4987
4790
|
|
|
4988
4791
|
// src/app/createComponent.ts
|
|
4989
|
-
var createComponent = (context,
|
|
4990
|
-
if (isArray(options))
|
|
4991
|
-
|
|
4992
|
-
if (isString(templateOptions))
|
|
4993
|
-
templateOptions = { template: templateOptions };
|
|
4792
|
+
var createComponent = (context, template, options = {}) => {
|
|
4793
|
+
if (isArray(options)) options = { props: options };
|
|
4794
|
+
if (isString(template)) template = { template };
|
|
4994
4795
|
let svgHandled = false;
|
|
4995
|
-
if (
|
|
4996
|
-
const element2 =
|
|
4796
|
+
if (template.element) {
|
|
4797
|
+
const element2 = template.element;
|
|
4997
4798
|
element2.remove();
|
|
4998
|
-
|
|
4999
|
-
} else if (
|
|
5000
|
-
const element2 = document.querySelector(
|
|
4799
|
+
template.element = element2;
|
|
4800
|
+
} else if (template.selector) {
|
|
4801
|
+
const element2 = document.querySelector(template.selector);
|
|
5001
4802
|
if (!element2)
|
|
5002
4803
|
throw getError(
|
|
5003
4804
|
1 /* ComponentTemplateNotFound */,
|
|
5004
|
-
|
|
4805
|
+
template.selector
|
|
5005
4806
|
);
|
|
5006
4807
|
element2.remove();
|
|
5007
|
-
|
|
5008
|
-
} else if (
|
|
5009
|
-
const element2 = document.createRange().createContextualFragment(
|
|
5010
|
-
|
|
5011
|
-
} else if (
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
4808
|
+
template.element = element2;
|
|
4809
|
+
} else if (template.template) {
|
|
4810
|
+
const element2 = document.createRange().createContextualFragment(template.template);
|
|
4811
|
+
template.element = element2;
|
|
4812
|
+
} else if (template.json) {
|
|
4813
|
+
template.element = toFragment(
|
|
4814
|
+
template.json,
|
|
4815
|
+
template.isSVG,
|
|
5015
4816
|
options.config
|
|
5016
4817
|
);
|
|
5017
4818
|
svgHandled = true;
|
|
5018
4819
|
}
|
|
5019
|
-
if (!
|
|
5020
|
-
|
|
5021
|
-
if (options.useInterpolation ?? true)
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
const content = templateOptions.element.content;
|
|
4820
|
+
if (!template.element)
|
|
4821
|
+
template.element = document.createDocumentFragment();
|
|
4822
|
+
if (options.useInterpolation ?? true) interpolate(template.element);
|
|
4823
|
+
const element = template.element;
|
|
4824
|
+
if (!svgHandled && ((template.isSVG ?? (isHTMLElement(element) && element.hasAttribute?.("isSVG"))) || isHTMLElement(element) && !!element.querySelector("[isSVG]"))) {
|
|
4825
|
+
const content = template.element.content;
|
|
5026
4826
|
const nodes = content ? [...content.childNodes] : [...element.childNodes];
|
|
5027
4827
|
const json = toJsonTemplate(nodes);
|
|
5028
|
-
|
|
4828
|
+
template.element = toFragment(json, true, options.config);
|
|
5029
4829
|
}
|
|
5030
4830
|
return {
|
|
5031
4831
|
context,
|
|
5032
|
-
template:
|
|
4832
|
+
template: template.element,
|
|
5033
4833
|
inheritAttrs: options.inheritAttrs ?? true,
|
|
5034
4834
|
props: options.props,
|
|
5035
4835
|
defaultName: options.defaultName
|
|
@@ -5043,8 +4843,7 @@ var computed = (compute) => {
|
|
|
5043
4843
|
const result = (...args) => {
|
|
5044
4844
|
if (args.length <= 2 && 0 in args)
|
|
5045
4845
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5046
|
-
if (computer && !status.isStopped)
|
|
5047
|
-
return computer(...args);
|
|
4846
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5048
4847
|
computer = computedOnce(compute, status);
|
|
5049
4848
|
return computer(...args);
|
|
5050
4849
|
};
|
|
@@ -5080,8 +4879,7 @@ var computeMany = (sources, compute) => {
|
|
|
5080
4879
|
const result = (...args) => {
|
|
5081
4880
|
if (args.length <= 2 && 0 in args)
|
|
5082
4881
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5083
|
-
if (computer && !status.isStopped)
|
|
5084
|
-
return computer(...args);
|
|
4882
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5085
4883
|
computer = computeManyOnce(sources, compute, status);
|
|
5086
4884
|
return computer(...args);
|
|
5087
4885
|
};
|
|
@@ -5127,8 +4925,7 @@ var computeRef = (source, compute) => {
|
|
|
5127
4925
|
const result = (...args) => {
|
|
5128
4926
|
if (args.length <= 2 && 0 in args)
|
|
5129
4927
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5130
|
-
if (computer && !status.isStopped)
|
|
5131
|
-
return computer(...args);
|
|
4928
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5132
4929
|
computer = computeRefOnce(source, compute, status);
|
|
5133
4930
|
return computer(...args);
|
|
5134
4931
|
};
|
|
@@ -5169,31 +4966,44 @@ var markRaw = (value) => {
|
|
|
5169
4966
|
|
|
5170
4967
|
// src/misc/persist.ts
|
|
5171
4968
|
var persist = (anyRef, key) => {
|
|
5172
|
-
if (!key)
|
|
5173
|
-
throw new Error("persist requires a string key.");
|
|
4969
|
+
if (!key) throw getError(5 /* PersistRequiresKey */);
|
|
5174
4970
|
const deepRef = isDeepRef(anyRef);
|
|
5175
4971
|
const makeRef = deepRef ? ref : (x) => x;
|
|
5176
4972
|
const store = () => localStorage.setItem(key, JSON.stringify(flatten(anyRef())));
|
|
5177
4973
|
const existing = localStorage.getItem(key);
|
|
5178
4974
|
if (existing != null) {
|
|
5179
|
-
|
|
4975
|
+
try {
|
|
4976
|
+
anyRef(makeRef(JSON.parse(existing)));
|
|
4977
|
+
} catch (e) {
|
|
4978
|
+
warning(
|
|
4979
|
+
6 /* ErrorLog */,
|
|
4980
|
+
`persist: failed to parse data for key ${key}`,
|
|
4981
|
+
e
|
|
4982
|
+
);
|
|
4983
|
+
store();
|
|
4984
|
+
}
|
|
5180
4985
|
} else {
|
|
5181
4986
|
store();
|
|
5182
4987
|
}
|
|
5183
4988
|
const stopObserving = watchEffect(store);
|
|
5184
|
-
onUnmounted(
|
|
4989
|
+
onUnmounted(stopObserving, true);
|
|
5185
4990
|
return anyRef;
|
|
5186
4991
|
};
|
|
5187
4992
|
|
|
5188
4993
|
// src/misc/tagged-html.ts
|
|
5189
4994
|
var html = (templates, ...args) => {
|
|
5190
|
-
let
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
4995
|
+
let result = "";
|
|
4996
|
+
const tpl = templates;
|
|
4997
|
+
const a = args;
|
|
4998
|
+
const tplLen = tpl.length;
|
|
4999
|
+
const argLen = a.length;
|
|
5000
|
+
for (let i = 0; i < tplLen; ++i) {
|
|
5001
|
+
result += tpl[i];
|
|
5002
|
+
if (i < argLen) {
|
|
5003
|
+
result += a[i];
|
|
5004
|
+
}
|
|
5005
|
+
}
|
|
5006
|
+
return result;
|
|
5197
5007
|
};
|
|
5198
5008
|
var raw = html;
|
|
5199
5009
|
|
|
@@ -5206,8 +5016,7 @@ var observeMany = (sources, observer, init) => {
|
|
|
5206
5016
|
for (const source of sources) {
|
|
5207
5017
|
stopObservingList.push(observe(source, callObserver));
|
|
5208
5018
|
}
|
|
5209
|
-
if (init)
|
|
5210
|
-
callObserver();
|
|
5019
|
+
if (init) callObserver();
|
|
5211
5020
|
const stop = () => {
|
|
5212
5021
|
for (const stopObserving of stopObservingList) {
|
|
5213
5022
|
stopObserving();
|
|
@@ -5220,7 +5029,7 @@ var observeMany = (sources, observer, init) => {
|
|
|
5220
5029
|
// src/observer/observerCount.ts
|
|
5221
5030
|
var observerCount = (source) => {
|
|
5222
5031
|
if (!isRef(source))
|
|
5223
|
-
throw getError(3 /* RequiresRefSourceArgument */, "
|
|
5032
|
+
throw getError(3 /* RequiresRefSourceArgument */, "observerCount");
|
|
5224
5033
|
const srefImpl = source;
|
|
5225
5034
|
return srefImpl(void 0, void 0, 2 /* observerCount */);
|
|
5226
5035
|
};
|
|
@@ -5235,14 +5044,19 @@ var batch = (updater) => {
|
|
|
5235
5044
|
}
|
|
5236
5045
|
};
|
|
5237
5046
|
var startBatch = () => {
|
|
5238
|
-
if (!batchCollector.
|
|
5239
|
-
|
|
5047
|
+
if (!batchCollector.stack) batchCollector.stack = [];
|
|
5048
|
+
batchCollector.stack.push(/* @__PURE__ */ new Set());
|
|
5240
5049
|
};
|
|
5241
5050
|
var endBatch = () => {
|
|
5242
|
-
const
|
|
5243
|
-
if (!
|
|
5051
|
+
const stack = batchCollector.stack;
|
|
5052
|
+
if (!stack || stack.length === 0) return;
|
|
5053
|
+
const set = stack.pop();
|
|
5054
|
+
if (stack.length) {
|
|
5055
|
+
const parent = stack[stack.length - 1];
|
|
5056
|
+
for (const ref2 of set) parent.add(ref2);
|
|
5244
5057
|
return;
|
|
5245
|
-
|
|
5058
|
+
}
|
|
5059
|
+
delete batchCollector.stack;
|
|
5246
5060
|
for (const ref2 of set) {
|
|
5247
5061
|
try {
|
|
5248
5062
|
trigger(ref2);
|