regor 1.0.9 → 1.1.1
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.cjs.js
CHANGED
|
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
ComponentHead: () => ComponentHead,
|
|
24
24
|
RegorConfig: () => RegorConfig,
|
|
25
25
|
addUnbinder: () => addUnbinder,
|
|
@@ -62,7 +62,7 @@ __export(src_exports, {
|
|
|
62
62
|
warningHandler: () => warningHandler,
|
|
63
63
|
watchEffect: () => watchEffect
|
|
64
64
|
});
|
|
65
|
-
module.exports = __toCommonJS(
|
|
65
|
+
module.exports = __toCommonJS(index_exports);
|
|
66
66
|
|
|
67
67
|
// src/common/is-what.ts
|
|
68
68
|
var isFunction = (value) => {
|
|
@@ -95,7 +95,8 @@ var errors = {
|
|
|
95
95
|
[1 /* ComponentTemplateNotFound */]: (selector) => `Component template cannot be found. selector: ${selector} .`,
|
|
96
96
|
[2 /* ComposablesRequireScope */]: "Use composables in scope. usage: useScope(() => new MyApp()).",
|
|
97
97
|
[3 /* RequiresRefSourceArgument */]: (name2) => `${name2} requires ref source argument`,
|
|
98
|
-
[4 /* ComputedIsReadOnly */]: "computed is readonly."
|
|
98
|
+
[4 /* ComputedIsReadOnly */]: "computed is readonly.",
|
|
99
|
+
[5 /* PersistRequiresKey */]: "persist requires a string key."
|
|
99
100
|
};
|
|
100
101
|
var getError = (type, ...args) => {
|
|
101
102
|
const msg = errors[type];
|
|
@@ -108,8 +109,7 @@ var bindDataSymbol = Symbol(":regor");
|
|
|
108
109
|
// src/cleanup/getBindData.ts
|
|
109
110
|
var getBindData = (node) => {
|
|
110
111
|
const bindData = node[bindDataSymbol];
|
|
111
|
-
if (bindData)
|
|
112
|
-
return bindData;
|
|
112
|
+
if (bindData) return bindData;
|
|
113
113
|
const newBindData = {
|
|
114
114
|
unbinders: [],
|
|
115
115
|
data: {}
|
|
@@ -135,8 +135,7 @@ var pushScope = () => {
|
|
|
135
135
|
};
|
|
136
136
|
var peekScope = (noThrow) => {
|
|
137
137
|
const scope = scopes[scopes.length - 1];
|
|
138
|
-
if (!scope && !noThrow)
|
|
139
|
-
throw getError(2 /* ComposablesRequireScope */);
|
|
138
|
+
if (!scope && !noThrow) throw getError(2 /* ComposablesRequireScope */);
|
|
140
139
|
return scope;
|
|
141
140
|
};
|
|
142
141
|
var popScope = (context) => {
|
|
@@ -151,8 +150,7 @@ var setScope = (context) => {
|
|
|
151
150
|
const existing = data[scopeSymbol];
|
|
152
151
|
if (existing) {
|
|
153
152
|
const cs = peekScope();
|
|
154
|
-
if (existing === cs)
|
|
155
|
-
return;
|
|
153
|
+
if (existing === cs) return;
|
|
156
154
|
cs.onMounted.length > 0 && existing.onMounted.push(...cs.onMounted);
|
|
157
155
|
cs.onUnmounted.length > 0 && existing.onUnmounted.push(...cs.onUnmounted);
|
|
158
156
|
return;
|
|
@@ -183,8 +181,7 @@ var isRef = (value) => {
|
|
|
183
181
|
var observe = (source, observer, init) => {
|
|
184
182
|
if (!isRef(source))
|
|
185
183
|
throw getError(3 /* RequiresRefSourceArgument */, "observe");
|
|
186
|
-
if (init)
|
|
187
|
-
observer(source());
|
|
184
|
+
if (init) observer(source());
|
|
188
185
|
const srefImpl = source;
|
|
189
186
|
const stop = srefImpl(
|
|
190
187
|
void 0,
|
|
@@ -203,8 +200,7 @@ var unbind = (node) => {
|
|
|
203
200
|
const currentElement = queue.shift();
|
|
204
201
|
unbindSingle(currentElement);
|
|
205
202
|
const childNodes = currentElement.childNodes;
|
|
206
|
-
if (!childNodes)
|
|
207
|
-
continue;
|
|
203
|
+
if (!childNodes) continue;
|
|
208
204
|
for (const item of childNodes) {
|
|
209
205
|
queue.push(item);
|
|
210
206
|
}
|
|
@@ -212,8 +208,7 @@ var unbind = (node) => {
|
|
|
212
208
|
};
|
|
213
209
|
var unbindSingle = (node) => {
|
|
214
210
|
const bindData = node[bindDataSymbol];
|
|
215
|
-
if (!bindData)
|
|
216
|
-
return;
|
|
211
|
+
if (!bindData) return;
|
|
217
212
|
for (const unbinder of bindData.unbinders) {
|
|
218
213
|
unbinder();
|
|
219
214
|
}
|
|
@@ -247,12 +242,9 @@ var warning = (type, ...args) => {
|
|
|
247
242
|
const msg = warnings[type];
|
|
248
243
|
const item = isFunction(msg) ? msg.call(warnings, ...args) : msg;
|
|
249
244
|
const handler = warningHandler.warning;
|
|
250
|
-
if (!handler)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
handler(item);
|
|
254
|
-
else
|
|
255
|
-
handler(item, ...item.args);
|
|
245
|
+
if (!handler) return;
|
|
246
|
+
if (isString(item)) handler(item);
|
|
247
|
+
else handler(item, ...item.args);
|
|
256
248
|
};
|
|
257
249
|
var warningHandler = { warning: console.warn };
|
|
258
250
|
|
|
@@ -291,11 +283,9 @@ var getSwitches = (nodes) => {
|
|
|
291
283
|
return [...set];
|
|
292
284
|
};
|
|
293
285
|
var setSwitchOwner = (owner, switchNodes) => {
|
|
294
|
-
if (!hasSwitch())
|
|
295
|
-
return;
|
|
286
|
+
if (!hasSwitch()) return;
|
|
296
287
|
const switches2 = getSwitches(switchNodes);
|
|
297
|
-
if (switches2.length === 0)
|
|
298
|
-
return;
|
|
288
|
+
if (switches2.length === 0) return;
|
|
299
289
|
switches2.forEach(refSwitch);
|
|
300
290
|
addUnbinder(owner, () => {
|
|
301
291
|
switches2.forEach(removeSwitch);
|
|
@@ -351,8 +341,7 @@ var IfBinder = class {
|
|
|
351
341
|
return isIfElement;
|
|
352
342
|
}
|
|
353
343
|
__isProcessedOrMark(el) {
|
|
354
|
-
if (el[ifMarker])
|
|
355
|
-
return true;
|
|
344
|
+
if (el[ifMarker]) return true;
|
|
356
345
|
el[ifMarker] = true;
|
|
357
346
|
findElements(el, this.__ifSelector).forEach(
|
|
358
347
|
(x) => x[ifMarker] = true
|
|
@@ -383,8 +372,7 @@ var IfBinder = class {
|
|
|
383
372
|
removeNode(x);
|
|
384
373
|
});
|
|
385
374
|
el.remove();
|
|
386
|
-
if (type !== "if")
|
|
387
|
-
el[elseMarker] = 1;
|
|
375
|
+
if (type !== "if") el[elseMarker] = 1;
|
|
388
376
|
const commentEnd = document.createComment(
|
|
389
377
|
`__end__ :${type}${expression ?? ""}`
|
|
390
378
|
);
|
|
@@ -397,8 +385,7 @@ var IfBinder = class {
|
|
|
397
385
|
};
|
|
398
386
|
}
|
|
399
387
|
__collectElses(el, refresh) {
|
|
400
|
-
if (!el)
|
|
401
|
-
return [];
|
|
388
|
+
if (!el) return [];
|
|
402
389
|
const nextElement = el.nextElementSibling;
|
|
403
390
|
if (el.hasAttribute(this.__else)) {
|
|
404
391
|
el.removeAttribute(this.__else);
|
|
@@ -420,8 +407,7 @@ var IfBinder = class {
|
|
|
420
407
|
];
|
|
421
408
|
} else {
|
|
422
409
|
const expression = el.getAttribute(this.__elseif);
|
|
423
|
-
if (!expression)
|
|
424
|
-
return [];
|
|
410
|
+
if (!expression) return [];
|
|
425
411
|
el.removeAttribute(this.__elseif);
|
|
426
412
|
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
427
413
|
el,
|
|
@@ -529,8 +515,7 @@ var bindChildNodes = (binder, childNodes) => {
|
|
|
529
515
|
};
|
|
530
516
|
var findElements = (element, selector) => {
|
|
531
517
|
const result = element.querySelectorAll(selector);
|
|
532
|
-
if (element.matches?.(selector))
|
|
533
|
-
return [element, ...result];
|
|
518
|
+
if (element.matches?.(selector)) return [element, ...result];
|
|
534
519
|
return result;
|
|
535
520
|
};
|
|
536
521
|
var isTemplate = (node) => node instanceof HTMLTemplateElement;
|
|
@@ -552,8 +537,7 @@ var defineRefValue = (result, isReadOnly) => {
|
|
|
552
537
|
return result();
|
|
553
538
|
},
|
|
554
539
|
set(value) {
|
|
555
|
-
if (isReadOnly)
|
|
556
|
-
throw new Error("value is readonly.");
|
|
540
|
+
if (isReadOnly) throw new Error("value is readonly.");
|
|
557
541
|
return result(value);
|
|
558
542
|
},
|
|
559
543
|
enumerable: true,
|
|
@@ -561,10 +545,8 @@ var defineRefValue = (result, isReadOnly) => {
|
|
|
561
545
|
});
|
|
562
546
|
};
|
|
563
547
|
var isOptionDynamic = (option, dynamic) => {
|
|
564
|
-
if (!option)
|
|
565
|
-
|
|
566
|
-
if (option.startsWith("["))
|
|
567
|
-
return option.substring(1, option.length - 1);
|
|
548
|
+
if (!option) return false;
|
|
549
|
+
if (option.startsWith("[")) return option.substring(1, option.length - 1);
|
|
568
550
|
const len = dynamic.length;
|
|
569
551
|
if (option.startsWith(dynamic)) {
|
|
570
552
|
return option.substring(len, option.length - len);
|
|
@@ -590,33 +572,28 @@ var cacheStringFunction = (fn) => {
|
|
|
590
572
|
};
|
|
591
573
|
var camelizeRE = /-(\w)/g;
|
|
592
574
|
var camelize = cacheStringFunction((str) => {
|
|
593
|
-
if (!str)
|
|
594
|
-
return str;
|
|
575
|
+
if (!str) return str;
|
|
595
576
|
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
596
577
|
});
|
|
597
578
|
var hyphenateRE = /\B([A-Z])/g;
|
|
598
579
|
var hyphenate = cacheStringFunction((str) => {
|
|
599
|
-
if (!str)
|
|
600
|
-
return str;
|
|
580
|
+
if (!str) return str;
|
|
601
581
|
return str.replace(hyphenateRE, "-$1").toLowerCase();
|
|
602
582
|
});
|
|
603
583
|
var capitalize = cacheStringFunction((str) => {
|
|
604
|
-
if (!str)
|
|
605
|
-
return str;
|
|
584
|
+
if (!str) return str;
|
|
606
585
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
607
586
|
});
|
|
608
587
|
|
|
609
588
|
// src/computed/watchEffect.ts
|
|
610
589
|
var collectedRefs = [];
|
|
611
590
|
var collectRef = (ref2) => {
|
|
612
|
-
if (collectedRefs.length === 0)
|
|
613
|
-
return;
|
|
591
|
+
if (collectedRefs.length === 0) return;
|
|
614
592
|
collectedRefs[collectedRefs.length - 1]?.add(ref2);
|
|
615
593
|
};
|
|
616
594
|
var watchEffect = (effect) => {
|
|
617
|
-
if (!effect)
|
|
618
|
-
|
|
619
|
-
};
|
|
595
|
+
if (!effect) return () => {
|
|
596
|
+
};
|
|
620
597
|
const terminator = { stop: () => {
|
|
621
598
|
} };
|
|
622
599
|
watchEffectInternal(effect, terminator);
|
|
@@ -624,13 +601,11 @@ var watchEffect = (effect) => {
|
|
|
624
601
|
return terminator.stop;
|
|
625
602
|
};
|
|
626
603
|
var watchEffectInternal = (effect, terminator) => {
|
|
627
|
-
if (!effect)
|
|
628
|
-
return;
|
|
604
|
+
if (!effect) return;
|
|
629
605
|
let stopObservingList = [];
|
|
630
606
|
let isStopped = false;
|
|
631
607
|
const stopWatch = () => {
|
|
632
|
-
for (const stop of stopObservingList)
|
|
633
|
-
stop();
|
|
608
|
+
for (const stop of stopObservingList) stop();
|
|
634
609
|
stopObservingList = [];
|
|
635
610
|
isStopped = true;
|
|
636
611
|
};
|
|
@@ -639,8 +614,7 @@ var watchEffectInternal = (effect, terminator) => {
|
|
|
639
614
|
const set = /* @__PURE__ */ new Set();
|
|
640
615
|
collectedRefs.push(set);
|
|
641
616
|
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
642
|
-
if (isStopped)
|
|
643
|
-
return;
|
|
617
|
+
if (isStopped) return;
|
|
644
618
|
for (const r of [...set]) {
|
|
645
619
|
const stopObserving = observe(r, () => {
|
|
646
620
|
stopWatch();
|
|
@@ -680,15 +654,12 @@ var isRaw = (value) => {
|
|
|
680
654
|
|
|
681
655
|
// src/reactivity/trigger.ts
|
|
682
656
|
var trigger = (source, eventSource, isRecursive) => {
|
|
683
|
-
if (!isRef(source))
|
|
684
|
-
return;
|
|
657
|
+
if (!isRef(source)) return;
|
|
685
658
|
const srefImpl = source;
|
|
686
659
|
srefImpl(void 0, eventSource, 1 /* trigger */);
|
|
687
|
-
if (!isRecursive)
|
|
688
|
-
return;
|
|
660
|
+
if (!isRecursive) return;
|
|
689
661
|
const obj = srefImpl();
|
|
690
|
-
if (!obj)
|
|
691
|
-
return;
|
|
662
|
+
if (!obj) return;
|
|
692
663
|
if (isArray(obj) || isSet(obj)) {
|
|
693
664
|
for (const el of obj) {
|
|
694
665
|
trigger(el, eventSource, true);
|
|
@@ -721,8 +692,7 @@ var createProxy = (originalProto, proxyProto, methodsToPatch4) => {
|
|
|
721
692
|
define(proxyProto, method, function mutator(...args) {
|
|
722
693
|
const result = original.apply(this, args);
|
|
723
694
|
const subscribers = this[srefSymbol];
|
|
724
|
-
for (const subscriber of subscribers)
|
|
725
|
-
trigger(subscriber);
|
|
695
|
+
for (const subscriber of subscribers) trigger(subscriber);
|
|
726
696
|
return result;
|
|
727
697
|
});
|
|
728
698
|
});
|
|
@@ -767,17 +737,14 @@ createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
|
767
737
|
// src/reactivity/sref.ts
|
|
768
738
|
var batchCollector = {};
|
|
769
739
|
var sref = (value) => {
|
|
770
|
-
if (isRef(value) || isRaw(value))
|
|
771
|
-
return value;
|
|
740
|
+
if (isRef(value) || isRaw(value)) return value;
|
|
772
741
|
const refObj = {
|
|
773
742
|
auto: true,
|
|
774
743
|
_value: value
|
|
775
744
|
};
|
|
776
745
|
const createProxy2 = (value2) => {
|
|
777
|
-
if (!isObject(value2))
|
|
778
|
-
|
|
779
|
-
if (srefSymbol in value2)
|
|
780
|
-
return true;
|
|
746
|
+
if (!isObject(value2)) return false;
|
|
747
|
+
if (srefSymbol in value2) return true;
|
|
781
748
|
const isAnArray = isArray(value2);
|
|
782
749
|
if (isAnArray) {
|
|
783
750
|
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
@@ -798,24 +765,22 @@ var sref = (value) => {
|
|
|
798
765
|
const isProxy = createProxy2(value);
|
|
799
766
|
const observers = /* @__PURE__ */ new Set();
|
|
800
767
|
const trigger2 = (newValue, eventSource) => {
|
|
801
|
-
if (batchCollector.
|
|
802
|
-
batchCollector.
|
|
768
|
+
if (batchCollector.stack && batchCollector.stack.length) {
|
|
769
|
+
const current = batchCollector.stack[batchCollector.stack.length - 1];
|
|
770
|
+
current.add(srefFunction);
|
|
803
771
|
return;
|
|
804
772
|
}
|
|
805
|
-
if (observers.size === 0)
|
|
806
|
-
return;
|
|
773
|
+
if (observers.size === 0) return;
|
|
807
774
|
silence(() => {
|
|
808
775
|
for (const callback of [...observers.keys()]) {
|
|
809
|
-
if (!observers.has(callback))
|
|
810
|
-
continue;
|
|
776
|
+
if (!observers.has(callback)) continue;
|
|
811
777
|
callback(newValue, eventSource);
|
|
812
778
|
}
|
|
813
779
|
});
|
|
814
780
|
};
|
|
815
781
|
const attachProxyHandle = (value2) => {
|
|
816
782
|
let proxyHandle = value2[srefSymbol];
|
|
817
|
-
if (!proxyHandle)
|
|
818
|
-
value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
783
|
+
if (!proxyHandle) value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
819
784
|
proxyHandle.add(srefFunction);
|
|
820
785
|
};
|
|
821
786
|
const srefFunction = (...args) => {
|
|
@@ -823,15 +788,12 @@ var sref = (value) => {
|
|
|
823
788
|
let newValue = args[0];
|
|
824
789
|
const eventSource = args[1];
|
|
825
790
|
if (0 in args) {
|
|
826
|
-
if (refObj._value === newValue)
|
|
827
|
-
return newValue;
|
|
791
|
+
if (refObj._value === newValue) return newValue;
|
|
828
792
|
if (isRef(newValue)) {
|
|
829
793
|
newValue = newValue();
|
|
830
|
-
if (refObj._value === newValue)
|
|
831
|
-
return newValue;
|
|
794
|
+
if (refObj._value === newValue) return newValue;
|
|
832
795
|
}
|
|
833
|
-
if (createProxy2(newValue))
|
|
834
|
-
attachProxyHandle(newValue);
|
|
796
|
+
if (createProxy2(newValue)) attachProxyHandle(newValue);
|
|
835
797
|
refObj._value = newValue;
|
|
836
798
|
if (refObj.auto) {
|
|
837
799
|
trigger2(newValue, eventSource);
|
|
@@ -846,9 +808,8 @@ var sref = (value) => {
|
|
|
846
808
|
switch (operation) {
|
|
847
809
|
case 0 /* observe */: {
|
|
848
810
|
const observer = args[3];
|
|
849
|
-
if (!observer)
|
|
850
|
-
|
|
851
|
-
};
|
|
811
|
+
if (!observer) return () => {
|
|
812
|
+
};
|
|
852
813
|
const removeObserver = (observer2) => {
|
|
853
814
|
observers.delete(observer2);
|
|
854
815
|
};
|
|
@@ -878,8 +839,7 @@ var sref = (value) => {
|
|
|
878
839
|
};
|
|
879
840
|
srefFunction[srefSymbol] = 1;
|
|
880
841
|
defineRefValue(srefFunction, false);
|
|
881
|
-
if (isProxy)
|
|
882
|
-
attachProxyHandle(value);
|
|
842
|
+
if (isProxy) attachProxyHandle(value);
|
|
883
843
|
return srefFunction;
|
|
884
844
|
};
|
|
885
845
|
|
|
@@ -906,13 +866,11 @@ var MountList = class {
|
|
|
906
866
|
}
|
|
907
867
|
__setValueMap(item) {
|
|
908
868
|
const value = this.__getKey(item.value);
|
|
909
|
-
if (value)
|
|
910
|
-
this.__valueMap.set(value, item);
|
|
869
|
+
if (value !== void 0) this.__valueMap.set(value, item);
|
|
911
870
|
}
|
|
912
871
|
__deleteValueMap(index) {
|
|
913
872
|
const value = this.__getKey(this.__list[index]?.value);
|
|
914
|
-
if (value)
|
|
915
|
-
this.__valueMap.delete(value);
|
|
873
|
+
if (value !== void 0) this.__valueMap.delete(value);
|
|
916
874
|
}
|
|
917
875
|
/**
|
|
918
876
|
* @internal
|
|
@@ -932,8 +890,7 @@ var MountList = class {
|
|
|
932
890
|
}
|
|
933
891
|
__insertAt(index, item) {
|
|
934
892
|
const len = this.__length;
|
|
935
|
-
for (let i = index; i < len; ++i)
|
|
936
|
-
this.__list[i].order = i + 1;
|
|
893
|
+
for (let i = index; i < len; ++i) this.__list[i].order = i + 1;
|
|
937
894
|
item.order = index;
|
|
938
895
|
this.__list.splice(index, 0, item);
|
|
939
896
|
this.__setValueMap(item);
|
|
@@ -951,13 +908,11 @@ var MountList = class {
|
|
|
951
908
|
this.__deleteValueMap(index);
|
|
952
909
|
this.__list.splice(index, 1);
|
|
953
910
|
const len = this.__length;
|
|
954
|
-
for (let i = index; i < len; ++i)
|
|
955
|
-
this.__list[i].order = i;
|
|
911
|
+
for (let i = index; i < len; ++i) this.__list[i].order = i;
|
|
956
912
|
}
|
|
957
913
|
__removeAllAfter(index) {
|
|
958
914
|
const len = this.__length;
|
|
959
|
-
for (let i = index; i < len; ++i)
|
|
960
|
-
this.__deleteValueMap(i);
|
|
915
|
+
for (let i = index; i < len; ++i) this.__deleteValueMap(i);
|
|
961
916
|
this.__list.splice(index);
|
|
962
917
|
}
|
|
963
918
|
__isValueMounted(value) {
|
|
@@ -991,8 +946,7 @@ var ForBinder = class _ForBinder {
|
|
|
991
946
|
return isForElement;
|
|
992
947
|
}
|
|
993
948
|
__isProcessedOrMark(el) {
|
|
994
|
-
if (el[forMarker])
|
|
995
|
-
return true;
|
|
949
|
+
if (el[forMarker]) return true;
|
|
996
950
|
el[forMarker] = true;
|
|
997
951
|
findElements(el, this.__forSelector).forEach(
|
|
998
952
|
(x) => x[forMarker] = true
|
|
@@ -1000,8 +954,7 @@ var ForBinder = class _ForBinder {
|
|
|
1000
954
|
return false;
|
|
1001
955
|
}
|
|
1002
956
|
__bindFor(el) {
|
|
1003
|
-
if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el))
|
|
1004
|
-
return;
|
|
957
|
+
if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el)) return;
|
|
1005
958
|
const forPath = el.getAttribute(this.__for);
|
|
1006
959
|
if (!forPath) {
|
|
1007
960
|
warning(0 /* MissingBindingExpression */, this.__for, el);
|
|
@@ -1011,10 +964,8 @@ var ForBinder = class _ForBinder {
|
|
|
1011
964
|
this.__bindForToPath(el, forPath);
|
|
1012
965
|
}
|
|
1013
966
|
__getIterable(obj) {
|
|
1014
|
-
if (isNullOrUndefined(obj))
|
|
1015
|
-
|
|
1016
|
-
if (isFunction(obj))
|
|
1017
|
-
obj = obj();
|
|
967
|
+
if (isNullOrUndefined(obj)) return [];
|
|
968
|
+
if (isFunction(obj)) obj = obj();
|
|
1018
969
|
if (Symbol.iterator in Object(obj)) {
|
|
1019
970
|
return obj;
|
|
1020
971
|
}
|
|
@@ -1047,8 +998,7 @@ var ForBinder = class _ForBinder {
|
|
|
1047
998
|
const areEqual = (a, b) => getKey(a) === getKey(b);
|
|
1048
999
|
const nodes = getNodes(el);
|
|
1049
1000
|
const parent = el.parentNode;
|
|
1050
|
-
if (!parent)
|
|
1051
|
-
return;
|
|
1001
|
+
if (!parent) return;
|
|
1052
1002
|
const title = `${this.__for} => ${forPath}`;
|
|
1053
1003
|
const commentBegin = new Comment(`__begin__ ${title}`);
|
|
1054
1004
|
parent.insertBefore(commentBegin, el);
|
|
@@ -1107,8 +1057,7 @@ var ForBinder = class _ForBinder {
|
|
|
1107
1057
|
};
|
|
1108
1058
|
const updateDom = (newValues) => {
|
|
1109
1059
|
let len = mountList.__length;
|
|
1110
|
-
if (isFunction(newValues))
|
|
1111
|
-
newValues = newValues();
|
|
1060
|
+
if (isFunction(newValues)) newValues = newValues();
|
|
1112
1061
|
const unrefedNewValue = unref(newValues[0]);
|
|
1113
1062
|
if (isArray(unrefedNewValue) && unrefedNewValue.length === 0) {
|
|
1114
1063
|
unmount(commentBegin, commentEnd);
|
|
@@ -1124,8 +1073,7 @@ var ForBinder = class _ForBinder {
|
|
|
1124
1073
|
const modify = () => {
|
|
1125
1074
|
if (i2 < len) {
|
|
1126
1075
|
const mountItem = mountList.__get(i2++);
|
|
1127
|
-
if (areEqual(mountItem.value, newValue))
|
|
1128
|
-
return;
|
|
1076
|
+
if (areEqual(mountItem.value, newValue)) return;
|
|
1129
1077
|
const newValueMountPosition = mountList.__lookupValueOrderIfMounted(
|
|
1130
1078
|
getKey(newValue)
|
|
1131
1079
|
);
|
|
@@ -1140,8 +1088,7 @@ var ForBinder = class _ForBinder {
|
|
|
1140
1088
|
--len;
|
|
1141
1089
|
if (newValueMountPosition > i2 + 1) {
|
|
1142
1090
|
for (let j2 = i2; j2 < newValueMountPosition - 1 && j2 < len; ) {
|
|
1143
|
-
if (areEqual(mountList.__get(i2).value, newValue))
|
|
1144
|
-
break;
|
|
1091
|
+
if (areEqual(mountList.__get(i2).value, newValue)) break;
|
|
1145
1092
|
++j2;
|
|
1146
1093
|
remove(i2);
|
|
1147
1094
|
mountList.__removeAt(i2);
|
|
@@ -1172,8 +1119,7 @@ var ForBinder = class _ForBinder {
|
|
|
1172
1119
|
}
|
|
1173
1120
|
const j = i2;
|
|
1174
1121
|
len = mountList.__length;
|
|
1175
|
-
while (i2 < len)
|
|
1176
|
-
remove(i2++);
|
|
1122
|
+
while (i2 < len) remove(i2++);
|
|
1177
1123
|
mountList.__removeAllAfter(j);
|
|
1178
1124
|
updateIndexes(firstRemovalOrInsertionIndex);
|
|
1179
1125
|
};
|
|
@@ -1195,19 +1141,16 @@ var ForBinder = class _ForBinder {
|
|
|
1195
1141
|
addUnbinder(commentBegin, unbinder);
|
|
1196
1142
|
observeTailChanges();
|
|
1197
1143
|
}
|
|
1198
|
-
static __forPathRegex = /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+(
|
|
1144
|
+
static __forPathRegex = /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+(.*)\s*$/;
|
|
1199
1145
|
__parseForPath(forPath) {
|
|
1200
1146
|
const matches = _ForBinder.__forPathRegex.exec(forPath);
|
|
1201
|
-
if (!matches)
|
|
1202
|
-
return;
|
|
1147
|
+
if (!matches) return;
|
|
1203
1148
|
const keys = (matches[1] + (matches[2] ?? "")).split(",").map((key) => key.trim());
|
|
1204
1149
|
const indexOfIndex = keys.length > 1 ? keys.length - 1 : -1;
|
|
1205
1150
|
const index = indexOfIndex !== -1 && (keys[indexOfIndex] === "index" || keys[indexOfIndex]?.startsWith("#")) ? keys[indexOfIndex] : "";
|
|
1206
|
-
if (index)
|
|
1207
|
-
keys.splice(indexOfIndex, 1);
|
|
1151
|
+
if (index) keys.splice(indexOfIndex, 1);
|
|
1208
1152
|
const list = matches[3];
|
|
1209
|
-
if (!list || keys.length === 0)
|
|
1210
|
-
return;
|
|
1153
|
+
if (!list || keys.length === 0) return;
|
|
1211
1154
|
const hasDestructuring = /[{[]/.test(forPath);
|
|
1212
1155
|
return {
|
|
1213
1156
|
list,
|
|
@@ -1264,8 +1207,7 @@ var DynamicBinder = class {
|
|
|
1264
1207
|
let expression = el.getAttribute(this.__is);
|
|
1265
1208
|
if (!expression) {
|
|
1266
1209
|
expression = el.getAttribute("is");
|
|
1267
|
-
if (!expression || !expression.startsWith("regor:"))
|
|
1268
|
-
return;
|
|
1210
|
+
if (!expression || !expression.startsWith("regor:")) return;
|
|
1269
1211
|
expression = `'${expression.slice(6)}'`;
|
|
1270
1212
|
el.removeAttribute("is");
|
|
1271
1213
|
}
|
|
@@ -1322,13 +1264,11 @@ var DynamicBinder = class {
|
|
|
1322
1264
|
unmount(commentBegin, commentEnd);
|
|
1323
1265
|
return;
|
|
1324
1266
|
}
|
|
1325
|
-
if (mounted.name === name2)
|
|
1326
|
-
return;
|
|
1267
|
+
if (mounted.name === name2) return;
|
|
1327
1268
|
unmount(commentBegin, commentEnd);
|
|
1328
1269
|
const componentElement = document.createElement(name2);
|
|
1329
1270
|
for (const attr of el.getAttributeNames()) {
|
|
1330
|
-
if (attr === this.__is)
|
|
1331
|
-
continue;
|
|
1271
|
+
if (attr === this.__is) continue;
|
|
1332
1272
|
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1333
1273
|
}
|
|
1334
1274
|
mount2(componentChildNodes, componentElement);
|
|
@@ -1369,8 +1309,7 @@ var propsDirective = {
|
|
|
1369
1309
|
const key = item[0];
|
|
1370
1310
|
const value2 = item[1];
|
|
1371
1311
|
const ctxKey = ctx[key];
|
|
1372
|
-
if (ctxKey === value2)
|
|
1373
|
-
continue;
|
|
1312
|
+
if (ctxKey === value2) continue;
|
|
1374
1313
|
if (isRef(ctxKey)) {
|
|
1375
1314
|
ctxKey(value2);
|
|
1376
1315
|
} else {
|
|
@@ -1400,8 +1339,7 @@ var propsOnceDirective = {
|
|
|
1400
1339
|
const key = item[0];
|
|
1401
1340
|
const value2 = item[1];
|
|
1402
1341
|
const ctxKey = ctx[key];
|
|
1403
|
-
if (ctxKey === value2)
|
|
1404
|
-
continue;
|
|
1342
|
+
if (ctxKey === value2) continue;
|
|
1405
1343
|
if (isRef(ctxKey)) {
|
|
1406
1344
|
ctxKey(value2);
|
|
1407
1345
|
} else {
|
|
@@ -1489,16 +1427,14 @@ var useScope = (context) => {
|
|
|
1489
1427
|
}
|
|
1490
1428
|
};
|
|
1491
1429
|
var isScope = (value) => {
|
|
1492
|
-
if (!isObject(value))
|
|
1493
|
-
return false;
|
|
1430
|
+
if (!isObject(value)) return false;
|
|
1494
1431
|
return scopeSymbol2 in value;
|
|
1495
1432
|
};
|
|
1496
1433
|
|
|
1497
1434
|
// src/reactivity/entangle.ts
|
|
1498
1435
|
var entangle = (r1, r2) => {
|
|
1499
|
-
if (r1 === r2)
|
|
1500
|
-
|
|
1501
|
-
};
|
|
1436
|
+
if (r1 === r2) return () => {
|
|
1437
|
+
};
|
|
1502
1438
|
const stop1 = observe(r1, (v) => r2(v));
|
|
1503
1439
|
const stop2 = observe(r2, (v) => r1(v));
|
|
1504
1440
|
r2(r1());
|
|
@@ -1521,9 +1457,8 @@ var callMounted = (context) => {
|
|
|
1521
1457
|
var singlePropDirective = {
|
|
1522
1458
|
collectRefObj: true,
|
|
1523
1459
|
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
1524
|
-
if (!option)
|
|
1525
|
-
|
|
1526
|
-
};
|
|
1460
|
+
if (!option) return () => {
|
|
1461
|
+
};
|
|
1527
1462
|
const key = camelize(option);
|
|
1528
1463
|
const stopObserving = observe(
|
|
1529
1464
|
parseResult.value,
|
|
@@ -1531,8 +1466,7 @@ var singlePropDirective = {
|
|
|
1531
1466
|
const value = parseResult.refs[0] ?? parseResult.value()[0];
|
|
1532
1467
|
const ctx = parseResult.context;
|
|
1533
1468
|
const ctxKey = ctx[option];
|
|
1534
|
-
if (ctxKey === value)
|
|
1535
|
-
return;
|
|
1469
|
+
if (ctxKey === value) return;
|
|
1536
1470
|
if (isRef(ctxKey)) {
|
|
1537
1471
|
ctxKey(value);
|
|
1538
1472
|
} else {
|
|
@@ -1568,28 +1502,22 @@ var ComponentBinder = class {
|
|
|
1568
1502
|
...[...registeredComponents.keys()].map(hyphenate),
|
|
1569
1503
|
...[...Object.keys(contextComponents)].map(hyphenate)
|
|
1570
1504
|
].join(",");
|
|
1571
|
-
if (isNullOrWhitespace(selector))
|
|
1572
|
-
return;
|
|
1505
|
+
if (isNullOrWhitespace(selector)) return;
|
|
1573
1506
|
const list = element.querySelectorAll(selector);
|
|
1574
1507
|
const components = element.matches?.(selector) ? [element, ...list] : list;
|
|
1575
1508
|
for (const component of components) {
|
|
1576
|
-
if (component.hasAttribute(binder.__pre))
|
|
1577
|
-
continue;
|
|
1509
|
+
if (component.hasAttribute(binder.__pre)) continue;
|
|
1578
1510
|
const parent = component.parentNode;
|
|
1579
|
-
if (!parent)
|
|
1580
|
-
continue;
|
|
1511
|
+
if (!parent) continue;
|
|
1581
1512
|
const nextSibling = component.nextSibling;
|
|
1582
1513
|
const tagName = camelize(component.tagName).toUpperCase();
|
|
1583
1514
|
const contextComponent = contextComponents[tagName];
|
|
1584
1515
|
const registeredComponent = contextComponent ?? registeredComponentsUpperCase.get(tagName);
|
|
1585
|
-
if (!registeredComponent)
|
|
1586
|
-
continue;
|
|
1516
|
+
if (!registeredComponent) continue;
|
|
1587
1517
|
const templateElement = registeredComponent.template;
|
|
1588
|
-
if (!templateElement)
|
|
1589
|
-
continue;
|
|
1518
|
+
if (!templateElement) continue;
|
|
1590
1519
|
const componentParent = component.parentElement;
|
|
1591
|
-
if (!componentParent)
|
|
1592
|
-
continue;
|
|
1520
|
+
if (!componentParent) continue;
|
|
1593
1521
|
const startOfComponent = new Comment(
|
|
1594
1522
|
" begin component: " + component.tagName
|
|
1595
1523
|
);
|
|
@@ -1605,30 +1533,24 @@ var ComponentBinder = class {
|
|
|
1605
1533
|
const hasPropsOnce = component2.hasAttribute(propsOnceName);
|
|
1606
1534
|
parser.__scoped(capturedContext2, () => {
|
|
1607
1535
|
parser.__push(props);
|
|
1608
|
-
if (hasProps)
|
|
1609
|
-
binder.__bind(propsDirective, component2, propsName);
|
|
1536
|
+
if (hasProps) binder.__bind(propsDirective, component2, propsName);
|
|
1610
1537
|
if (hasPropsOnce)
|
|
1611
1538
|
binder.__bind(propsOnceDirective, component2, propsOnceName);
|
|
1612
1539
|
let definedProps = registeredComponent.props;
|
|
1613
|
-
if (!definedProps || definedProps.length === 0)
|
|
1614
|
-
return;
|
|
1540
|
+
if (!definedProps || definedProps.length === 0) return;
|
|
1615
1541
|
definedProps = definedProps.map(camelize);
|
|
1616
1542
|
for (const name2 of definedProps.concat(definedProps.map(hyphenate))) {
|
|
1617
1543
|
const value = component2.getAttribute(name2);
|
|
1618
|
-
if (value === null)
|
|
1619
|
-
continue;
|
|
1544
|
+
if (value === null) continue;
|
|
1620
1545
|
props[camelize(name2)] = value;
|
|
1621
1546
|
component2.removeAttribute(name2);
|
|
1622
1547
|
}
|
|
1623
1548
|
const map = binder.__directiveCollector.__collect(component2, false);
|
|
1624
1549
|
for (const [attrName, item] of map.entries()) {
|
|
1625
1550
|
const [name2, option] = item.__terms;
|
|
1626
|
-
if (!option)
|
|
1627
|
-
|
|
1628
|
-
if (
|
|
1629
|
-
continue;
|
|
1630
|
-
if (name2 !== "." && name2 !== ":" && name2 !== bindName)
|
|
1631
|
-
continue;
|
|
1551
|
+
if (!option) continue;
|
|
1552
|
+
if (!definedProps.includes(camelize(option))) continue;
|
|
1553
|
+
if (name2 !== "." && name2 !== ":" && name2 !== bindName) continue;
|
|
1632
1554
|
binder.__bind(
|
|
1633
1555
|
singlePropDirective,
|
|
1634
1556
|
component2,
|
|
@@ -1658,16 +1580,13 @@ var ComponentBinder = class {
|
|
|
1658
1580
|
for (const [key, propsValue] of Object.entries(props)) {
|
|
1659
1581
|
if (key in componentCtx2) {
|
|
1660
1582
|
const compValue = componentCtx2[key];
|
|
1661
|
-
if (compValue === propsValue)
|
|
1662
|
-
continue;
|
|
1583
|
+
if (compValue === propsValue) continue;
|
|
1663
1584
|
if (head2.entangle && isRef(compValue) && isRef(propsValue)) {
|
|
1664
1585
|
addUnbinder(startOfComponent, entangle(propsValue, compValue));
|
|
1665
1586
|
} else if (isRef(compValue)) {
|
|
1666
1587
|
compValue(propsValue);
|
|
1667
|
-
} else
|
|
1668
|
-
|
|
1669
|
-
} else
|
|
1670
|
-
componentCtx2[key] = propsValue;
|
|
1588
|
+
} else componentCtx2[key] = unref(propsValue);
|
|
1589
|
+
} else componentCtx2[key] = propsValue;
|
|
1671
1590
|
}
|
|
1672
1591
|
head2.onAutoPropsAssigned?.();
|
|
1673
1592
|
}
|
|
@@ -1690,8 +1609,7 @@ var ComponentBinder = class {
|
|
|
1690
1609
|
name2 = slot.getAttributeNames().filter((x) => x.startsWith("#"))[0];
|
|
1691
1610
|
if (isNullOrWhitespace(name2)) {
|
|
1692
1611
|
name2 = "default";
|
|
1693
|
-
} else
|
|
1694
|
-
name2 = name2.substring(1);
|
|
1612
|
+
} else name2 = name2.substring(1);
|
|
1695
1613
|
}
|
|
1696
1614
|
let compTemplate = component.querySelector(
|
|
1697
1615
|
`template[name='${name2}'], template[\\#${name2}]`
|
|
@@ -1702,8 +1620,7 @@ var ComponentBinder = class {
|
|
|
1702
1620
|
compTemplate = null;
|
|
1703
1621
|
}
|
|
1704
1622
|
const createSwitchContext = (childNodes2) => {
|
|
1705
|
-
if (head.disableSwitch)
|
|
1706
|
-
return;
|
|
1623
|
+
if (head.disableSwitch) return;
|
|
1707
1624
|
parser.__scoped(capturedContext, () => {
|
|
1708
1625
|
parser.__push(componentCtx);
|
|
1709
1626
|
const props = getProps(slot, parser.__capture());
|
|
@@ -1712,8 +1629,7 @@ var ComponentBinder = class {
|
|
|
1712
1629
|
const switchContext = parser.__capture();
|
|
1713
1630
|
const id = addSwitch(switchContext);
|
|
1714
1631
|
for (const child of childNodes2) {
|
|
1715
|
-
if (!isElement(child))
|
|
1716
|
-
continue;
|
|
1632
|
+
if (!isElement(child)) continue;
|
|
1717
1633
|
child.setAttribute(rswitch, id);
|
|
1718
1634
|
refSwitch(id);
|
|
1719
1635
|
addUnbinder(child, () => {
|
|
@@ -1746,8 +1662,7 @@ var ComponentBinder = class {
|
|
|
1746
1662
|
}
|
|
1747
1663
|
};
|
|
1748
1664
|
const expandNestedSlots = (node) => {
|
|
1749
|
-
if (!isElement(node))
|
|
1750
|
-
return;
|
|
1665
|
+
if (!isElement(node)) return;
|
|
1751
1666
|
const slots = node.querySelectorAll("slot");
|
|
1752
1667
|
if (isSlot(node)) {
|
|
1753
1668
|
expandSlot(node);
|
|
@@ -1769,8 +1684,7 @@ var ComponentBinder = class {
|
|
|
1769
1684
|
expandSlots();
|
|
1770
1685
|
componentParent.insertBefore(endOfComponent, nextSibling);
|
|
1771
1686
|
const transferAttributesToTheComponentChild = () => {
|
|
1772
|
-
if (!registeredComponent.inheritAttrs)
|
|
1773
|
-
return;
|
|
1687
|
+
if (!registeredComponent.inheritAttrs) return;
|
|
1774
1688
|
let inheritorChildNodes = childNodes.filter(
|
|
1775
1689
|
(x) => x.nodeType === Node.ELEMENT_NODE
|
|
1776
1690
|
);
|
|
@@ -1779,11 +1693,9 @@ var ComponentBinder = class {
|
|
|
1779
1693
|
(x) => x.hasAttribute(this.__inherit)
|
|
1780
1694
|
);
|
|
1781
1695
|
const inheritor = inheritorChildNodes[0];
|
|
1782
|
-
if (!inheritor)
|
|
1783
|
-
return;
|
|
1696
|
+
if (!inheritor) return;
|
|
1784
1697
|
for (const attrName of component.getAttributeNames()) {
|
|
1785
|
-
if (attrName === propsName || attrName === propsOnceName)
|
|
1786
|
-
continue;
|
|
1698
|
+
if (attrName === propsName || attrName === propsOnceName) continue;
|
|
1787
1699
|
const value = component.getAttribute(attrName);
|
|
1788
1700
|
if (attrName === "class") {
|
|
1789
1701
|
inheritor.classList.add(...value.split(" "));
|
|
@@ -1843,12 +1755,10 @@ var DirectiveElement = class {
|
|
|
1843
1755
|
__parse() {
|
|
1844
1756
|
let name2 = this.__name;
|
|
1845
1757
|
const isPropShortcut = name2.startsWith(".");
|
|
1846
|
-
if (isPropShortcut)
|
|
1847
|
-
name2 = ":" + name2.slice(1);
|
|
1758
|
+
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1848
1759
|
const firstFlagIndex = name2.indexOf(".");
|
|
1849
1760
|
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1850
|
-
if (isNullOrWhitespace(terms[0]))
|
|
1851
|
-
terms[0] = isPropShortcut ? "." : name2[0];
|
|
1761
|
+
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1852
1762
|
if (firstFlagIndex >= 0) {
|
|
1853
1763
|
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1854
1764
|
if (flags.includes("camel")) {
|
|
@@ -1870,21 +1780,18 @@ var DirectiveCollector = class {
|
|
|
1870
1780
|
}
|
|
1871
1781
|
__collect(element, isRecursive) {
|
|
1872
1782
|
const map = /* @__PURE__ */ new Map();
|
|
1873
|
-
if (!isHTMLElement(element))
|
|
1874
|
-
return map;
|
|
1783
|
+
if (!isHTMLElement(element)) return map;
|
|
1875
1784
|
const prefixes2 = this.__prefixes;
|
|
1876
1785
|
const processNode = (node) => {
|
|
1877
1786
|
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1878
1787
|
for (const name2 of names) {
|
|
1879
|
-
if (!map.has(name2))
|
|
1880
|
-
map.set(name2, new DirectiveElement(name2));
|
|
1788
|
+
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1881
1789
|
const item = map.get(name2);
|
|
1882
1790
|
item.__elements.push(node);
|
|
1883
1791
|
}
|
|
1884
1792
|
};
|
|
1885
1793
|
processNode(element);
|
|
1886
|
-
if (!isRecursive)
|
|
1887
|
-
return map;
|
|
1794
|
+
if (!isRecursive) return map;
|
|
1888
1795
|
const nodes = element.querySelectorAll("*");
|
|
1889
1796
|
for (const node of nodes) {
|
|
1890
1797
|
processNode(node);
|
|
@@ -1921,15 +1828,12 @@ var Binder = class {
|
|
|
1921
1828
|
__unwrapTemplates(element) {
|
|
1922
1829
|
const templates = isTemplate(element) ? [element] : element.querySelectorAll("template");
|
|
1923
1830
|
for (const template of templates) {
|
|
1924
|
-
if (template.hasAttribute(this.__pre))
|
|
1925
|
-
continue;
|
|
1831
|
+
if (template.hasAttribute(this.__pre)) continue;
|
|
1926
1832
|
const parent = template.parentNode;
|
|
1927
|
-
if (!parent)
|
|
1928
|
-
continue;
|
|
1833
|
+
if (!parent) continue;
|
|
1929
1834
|
const nextSibling = template.nextSibling;
|
|
1930
1835
|
template.remove();
|
|
1931
|
-
if (!template.content)
|
|
1932
|
-
continue;
|
|
1836
|
+
if (!template.content) continue;
|
|
1933
1837
|
const childNodes = [...template.content.childNodes];
|
|
1934
1838
|
for (const child of childNodes) {
|
|
1935
1839
|
parent.insertBefore(child, nextSibling);
|
|
@@ -1940,12 +1844,9 @@ var Binder = class {
|
|
|
1940
1844
|
__bindDefault(element) {
|
|
1941
1845
|
if (element.nodeType !== Node.ELEMENT_NODE || element.hasAttribute(this.__pre))
|
|
1942
1846
|
return;
|
|
1943
|
-
if (this.__ifBinder.__bindAll(element))
|
|
1944
|
-
|
|
1945
|
-
if (this.
|
|
1946
|
-
return;
|
|
1947
|
-
if (this.__dynamicBinder.__bindAll(element))
|
|
1948
|
-
return;
|
|
1847
|
+
if (this.__ifBinder.__bindAll(element)) return;
|
|
1848
|
+
if (this.__forBinder.__bindAll(element)) return;
|
|
1849
|
+
if (this.__dynamicBinder.__bindAll(element)) return;
|
|
1949
1850
|
this.__componentBinder.__bindAll(element);
|
|
1950
1851
|
this.__unwrapTemplates(element);
|
|
1951
1852
|
this.__bindAttributes(element, true);
|
|
@@ -1966,16 +1867,13 @@ var Binder = class {
|
|
|
1966
1867
|
}
|
|
1967
1868
|
}
|
|
1968
1869
|
__bind(config, el, attribute, _noWarning, option, flags) {
|
|
1969
|
-
if (el.hasAttribute(this.__pre))
|
|
1970
|
-
return;
|
|
1870
|
+
if (el.hasAttribute(this.__pre)) return;
|
|
1971
1871
|
const bindExpression = el.getAttribute(attribute);
|
|
1972
1872
|
el.removeAttribute(attribute);
|
|
1973
1873
|
const getParentSwitch = (el2) => {
|
|
1974
1874
|
const switchId = el2.getAttribute(rswitch);
|
|
1975
|
-
if (switchId)
|
|
1976
|
-
|
|
1977
|
-
if (!el2.parentElement)
|
|
1978
|
-
return null;
|
|
1875
|
+
if (switchId) return switchId;
|
|
1876
|
+
if (!el2.parentElement) return null;
|
|
1979
1877
|
return getParentSwitch(el2.parentElement);
|
|
1980
1878
|
};
|
|
1981
1879
|
if (hasSwitch()) {
|
|
@@ -1990,15 +1888,12 @@ var Binder = class {
|
|
|
1990
1888
|
this.__bindToExpression(config, el, bindExpression, option, flags);
|
|
1991
1889
|
}
|
|
1992
1890
|
__handleTeleport(config, el, valueExpression) {
|
|
1993
|
-
if (config !== teleportDirective)
|
|
1994
|
-
|
|
1995
|
-
if (isNullOrWhitespace(valueExpression))
|
|
1996
|
-
return true;
|
|
1891
|
+
if (config !== teleportDirective) return false;
|
|
1892
|
+
if (isNullOrWhitespace(valueExpression)) return true;
|
|
1997
1893
|
const teleportTo = document.querySelector(valueExpression);
|
|
1998
1894
|
if (teleportTo) {
|
|
1999
1895
|
const parent = el.parentElement;
|
|
2000
|
-
if (!parent)
|
|
2001
|
-
return true;
|
|
1896
|
+
if (!parent) return true;
|
|
2002
1897
|
const placeholder = new Comment(`teleported => '${valueExpression}'`);
|
|
2003
1898
|
parent.insertBefore(placeholder, el);
|
|
2004
1899
|
el.teleportedFrom = placeholder;
|
|
@@ -2011,10 +1906,8 @@ var Binder = class {
|
|
|
2011
1906
|
return true;
|
|
2012
1907
|
}
|
|
2013
1908
|
__bindToExpression(config, el, valueExpression, option, flags) {
|
|
2014
|
-
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null)
|
|
2015
|
-
|
|
2016
|
-
if (this.__handleTeleport(config, el, valueExpression))
|
|
2017
|
-
return;
|
|
1909
|
+
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null) return;
|
|
1910
|
+
if (this.__handleTeleport(config, el, valueExpression)) return;
|
|
2018
1911
|
const result = this.__parser.__parse(
|
|
2019
1912
|
valueExpression,
|
|
2020
1913
|
config.isLazy,
|
|
@@ -2058,8 +1951,7 @@ var Binder = class {
|
|
|
2058
1951
|
return previousOption;
|
|
2059
1952
|
};
|
|
2060
1953
|
const observeTailChanges = () => {
|
|
2061
|
-
if (!config.onChange)
|
|
2062
|
-
return;
|
|
1954
|
+
if (!config.onChange) return;
|
|
2063
1955
|
const stopObserving = observe(result.value, (_) => {
|
|
2064
1956
|
const pre = previousValues;
|
|
2065
1957
|
const pre2 = previousOption;
|
|
@@ -2074,8 +1966,7 @@ var Binder = class {
|
|
|
2074
1966
|
stopObserverList.push(stopObserving2);
|
|
2075
1967
|
}
|
|
2076
1968
|
};
|
|
2077
|
-
if (!config.once)
|
|
2078
|
-
observeTailChanges();
|
|
1969
|
+
if (!config.once) observeTailChanges();
|
|
2079
1970
|
if (config.onBind)
|
|
2080
1971
|
stopObserverList.push(
|
|
2081
1972
|
config.onBind(
|
|
@@ -2264,8 +2155,7 @@ var Jsep = class {
|
|
|
2264
2155
|
}
|
|
2265
2156
|
__runHook(hookType, hookCalltype, node) {
|
|
2266
2157
|
const hook = this.__hooks[hookType];
|
|
2267
|
-
if (!hook)
|
|
2268
|
-
return node;
|
|
2158
|
+
if (!hook) return node;
|
|
2269
2159
|
const env = { node };
|
|
2270
2160
|
const hookFn = (f) => {
|
|
2271
2161
|
f.call(this, env);
|
|
@@ -2284,8 +2174,7 @@ var Jsep = class {
|
|
|
2284
2174
|
}
|
|
2285
2175
|
parse() {
|
|
2286
2176
|
const nodes = this.__gobbleExpressions();
|
|
2287
|
-
if (nodes.length === 1)
|
|
2288
|
-
return nodes[0];
|
|
2177
|
+
if (nodes.length === 1) return nodes[0];
|
|
2289
2178
|
return {
|
|
2290
2179
|
type: 0 /* Compound */,
|
|
2291
2180
|
body: nodes
|
|
@@ -2900,8 +2789,7 @@ var Jsep = class {
|
|
|
2900
2789
|
this.__updateBinariesToArrows(env.node);
|
|
2901
2790
|
}
|
|
2902
2791
|
__updateBinariesToArrows(node) {
|
|
2903
|
-
if (!node)
|
|
2904
|
-
return;
|
|
2792
|
+
if (!node) return;
|
|
2905
2793
|
Object.values(node).forEach((val) => {
|
|
2906
2794
|
if (val && typeof val === "object") {
|
|
2907
2795
|
this.__updateBinariesToArrows(val);
|
|
@@ -2920,8 +2808,7 @@ var Jsep = class {
|
|
|
2920
2808
|
}
|
|
2921
2809
|
}
|
|
2922
2810
|
__fixAssignmentOperators(env) {
|
|
2923
|
-
if (env.node)
|
|
2924
|
-
this.__updateBinariesToAssignments(env.node);
|
|
2811
|
+
if (env.node) this.__updateBinariesToAssignments(env.node);
|
|
2925
2812
|
}
|
|
2926
2813
|
__updateBinariesToAssignments(node) {
|
|
2927
2814
|
if (assigmentOperatorsSet.has(node.operator)) {
|
|
@@ -2937,12 +2824,10 @@ var Jsep = class {
|
|
|
2937
2824
|
}
|
|
2938
2825
|
}
|
|
2939
2826
|
__gobbleTaggedTemplateIdentifier(env) {
|
|
2940
|
-
if (!env.node)
|
|
2941
|
-
return;
|
|
2827
|
+
if (!env.node) return;
|
|
2942
2828
|
const type = env.node.type;
|
|
2943
2829
|
const condition = (type === 2 /* Identifier */ || type === 3 /* Member */) && this.__isCode(BTICK_CODE);
|
|
2944
|
-
if (!condition)
|
|
2945
|
-
return;
|
|
2830
|
+
if (!condition) return;
|
|
2946
2831
|
env.node = {
|
|
2947
2832
|
type: 17 /* TaggedTemplateExpression */,
|
|
2948
2833
|
tag: env.node,
|
|
@@ -2950,8 +2835,7 @@ var Jsep = class {
|
|
|
2950
2835
|
};
|
|
2951
2836
|
}
|
|
2952
2837
|
__gobbleTemplateLiteral(env) {
|
|
2953
|
-
if (!this.__isCode(BTICK_CODE))
|
|
2954
|
-
return;
|
|
2838
|
+
if (!this.__isCode(BTICK_CODE)) return;
|
|
2955
2839
|
const node = {
|
|
2956
2840
|
type: 19 /* TemplateLiteral */,
|
|
2957
2841
|
quasis: [],
|
|
@@ -3021,8 +2905,7 @@ var Jsep = class {
|
|
|
3021
2905
|
}
|
|
3022
2906
|
__gobbleNew(env) {
|
|
3023
2907
|
const node = env.node;
|
|
3024
|
-
if (!node || node.operator !== "new" || !node.argument)
|
|
3025
|
-
return;
|
|
2908
|
+
if (!node || node.operator !== "new" || !node.argument) return;
|
|
3026
2909
|
if (!node.argument || ![6 /* Call */, 3 /* Member */].includes(node.argument.type))
|
|
3027
2910
|
throw this.__getError("Expected new function()");
|
|
3028
2911
|
env.node = node.argument;
|
|
@@ -3033,8 +2916,7 @@ var Jsep = class {
|
|
|
3033
2916
|
callNode.type = 20 /* NewExpression */;
|
|
3034
2917
|
}
|
|
3035
2918
|
__gobbleRegexLiteral(env) {
|
|
3036
|
-
if (!this.__isCode(FSLASH_CODE))
|
|
3037
|
-
return;
|
|
2919
|
+
if (!this.__isCode(FSLASH_CODE)) return;
|
|
3038
2920
|
const patternIndex = ++this.__index;
|
|
3039
2921
|
let inCharSet = false;
|
|
3040
2922
|
while (this.__index < this.__expr.length) {
|
|
@@ -3132,8 +3014,7 @@ var evalUnaryOp = {
|
|
|
3132
3014
|
// placed here for type safety, never executed,
|
|
3133
3015
|
};
|
|
3134
3016
|
var spreadArgs = (args) => {
|
|
3135
|
-
if (!args?.some(shouldSpreadArray))
|
|
3136
|
-
return args;
|
|
3017
|
+
if (!args?.some(shouldSpreadArray)) return args;
|
|
3137
3018
|
const result = [];
|
|
3138
3019
|
args.forEach(
|
|
3139
3020
|
(x) => shouldSpreadArray(x) ? result.push(...x) : result.push(x)
|
|
@@ -3142,8 +3023,7 @@ var spreadArgs = (args) => {
|
|
|
3142
3023
|
};
|
|
3143
3024
|
var arrayEvaluator = (...args) => spreadArgs(args);
|
|
3144
3025
|
var createLazyContext = (e, context) => {
|
|
3145
|
-
if (!e)
|
|
3146
|
-
return context;
|
|
3026
|
+
if (!e) return context;
|
|
3147
3027
|
const ctx = Object.create(context ?? {});
|
|
3148
3028
|
ctx.$event = e;
|
|
3149
3029
|
return ctx;
|
|
@@ -3298,22 +3178,17 @@ var RegorEval = class {
|
|
|
3298
3178
|
this.__collectRefObj = !!collectRefObj;
|
|
3299
3179
|
}
|
|
3300
3180
|
__findContext(name2, context) {
|
|
3301
|
-
if (context && name2 in context)
|
|
3302
|
-
return context;
|
|
3181
|
+
if (context && name2 in context) return context;
|
|
3303
3182
|
for (const ctx of this.__contexts) {
|
|
3304
|
-
if (name2 in ctx)
|
|
3305
|
-
return ctx;
|
|
3183
|
+
if (name2 in ctx) return ctx;
|
|
3306
3184
|
}
|
|
3307
3185
|
return void 0;
|
|
3308
3186
|
}
|
|
3309
3187
|
[2 /* Identifier */](expr, _, context) {
|
|
3310
3188
|
const name2 = expr.name;
|
|
3311
|
-
if (name2 === "$root")
|
|
3312
|
-
|
|
3313
|
-
if (name2 === "$
|
|
3314
|
-
return this.__contexts[1];
|
|
3315
|
-
if (name2 === "$ctx")
|
|
3316
|
-
return [...this.__contexts];
|
|
3189
|
+
if (name2 === "$root") return this.__contexts[this.__contexts.length - 1];
|
|
3190
|
+
if (name2 === "$parent") return this.__contexts[1];
|
|
3191
|
+
if (name2 === "$ctx") return [...this.__contexts];
|
|
3317
3192
|
if (context && name2 in context) {
|
|
3318
3193
|
this.__lastEvaluatedValueBeforeUnref = context[name2];
|
|
3319
3194
|
return associateThis(unref(context[name2]), context);
|
|
@@ -3454,8 +3329,7 @@ var RegorEval = class {
|
|
|
3454
3329
|
if (arg.type === 2 /* Identifier */) {
|
|
3455
3330
|
const name2 = arg.name;
|
|
3456
3331
|
const ctx = this.__findContext(name2, context);
|
|
3457
|
-
if (isNullOrUndefined(ctx))
|
|
3458
|
-
return void 0;
|
|
3332
|
+
if (isNullOrUndefined(ctx)) return void 0;
|
|
3459
3333
|
return updater[op](ctx, name2);
|
|
3460
3334
|
}
|
|
3461
3335
|
if (arg.type === 3 /* Member */) {
|
|
@@ -3473,8 +3347,7 @@ var RegorEval = class {
|
|
|
3473
3347
|
if (arg.type === 2 /* Identifier */) {
|
|
3474
3348
|
const name2 = arg.name;
|
|
3475
3349
|
const ctx = this.__findContext(name2, context);
|
|
3476
|
-
if (isNullOrUndefined(ctx))
|
|
3477
|
-
return void 0;
|
|
3350
|
+
if (isNullOrUndefined(ctx)) return void 0;
|
|
3478
3351
|
const value = this.__eval(expr.right, depth, context);
|
|
3479
3352
|
return applyAssigment[op](ctx, name2, value);
|
|
3480
3353
|
}
|
|
@@ -3490,8 +3363,7 @@ var RegorEval = class {
|
|
|
3490
3363
|
}
|
|
3491
3364
|
[14 /* Spread */](expr, depth, context) {
|
|
3492
3365
|
const spreaded = this.__eval(expr.argument, depth, context);
|
|
3493
|
-
if (isArray(spreaded))
|
|
3494
|
-
spreaded.s = spreadElementSymbol;
|
|
3366
|
+
if (isArray(spreaded)) spreaded.s = spreadElementSymbol;
|
|
3495
3367
|
return spreaded;
|
|
3496
3368
|
}
|
|
3497
3369
|
[17 /* TaggedTemplateExpression */](expr, depth, context) {
|
|
@@ -3579,8 +3451,7 @@ var RegorEval = class {
|
|
|
3579
3451
|
}
|
|
3580
3452
|
__transformLazy(depth, context, evaluator, ...args) {
|
|
3581
3453
|
const isLazy = this.__isLazy;
|
|
3582
|
-
if (!isLazy)
|
|
3583
|
-
return this.__transform(depth, context, evaluator, ...args);
|
|
3454
|
+
if (!isLazy) return this.__transform(depth, context, evaluator, ...args);
|
|
3584
3455
|
const evaluatedArgs = args.map(
|
|
3585
3456
|
(arg, i) => arg && (arg.type !== 15 /* Arrow */ && isLazy(i, depth) ? (e) => this.__eval(arg, depth, createLazyContext(e, context)) : this.__eval(arg, depth, context))
|
|
3586
3457
|
);
|
|
@@ -3630,8 +3501,7 @@ var Parser = class {
|
|
|
3630
3501
|
refs: [],
|
|
3631
3502
|
context: this.__contexts[0]
|
|
3632
3503
|
};
|
|
3633
|
-
if (isNullOrWhitespace(expression))
|
|
3634
|
-
return result;
|
|
3504
|
+
if (isNullOrWhitespace(expression)) return result;
|
|
3635
3505
|
const globalContext = this.__config.globalContext;
|
|
3636
3506
|
const refs = [];
|
|
3637
3507
|
const evaluate = (expr, contexts, collectRefs2, context) => {
|
|
@@ -3739,8 +3609,7 @@ function includeBooleanAttr(value) {
|
|
|
3739
3609
|
var attrDirective = {
|
|
3740
3610
|
onChange: (el, values, previousValues, option, previousOption, flags) => {
|
|
3741
3611
|
if (option) {
|
|
3742
|
-
if (flags && flags.includes("camel"))
|
|
3743
|
-
option = camelize(option);
|
|
3612
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3744
3613
|
patchAttribute(el, option, values[0], previousOption);
|
|
3745
3614
|
return;
|
|
3746
3615
|
}
|
|
@@ -3826,25 +3695,22 @@ var patchClass = (el, next, prev) => {
|
|
|
3826
3695
|
if (next && !isClassString) {
|
|
3827
3696
|
if (prev && !isPrevClassString) {
|
|
3828
3697
|
for (const key in prev) {
|
|
3829
|
-
if (!(key in next)) {
|
|
3698
|
+
if (!(key in next) || !next[key]) {
|
|
3830
3699
|
classList.remove(key);
|
|
3831
3700
|
}
|
|
3832
3701
|
}
|
|
3833
3702
|
}
|
|
3834
3703
|
for (const key in next) {
|
|
3835
|
-
if (next[key])
|
|
3836
|
-
classList.add(key);
|
|
3704
|
+
if (next[key]) classList.add(key);
|
|
3837
3705
|
}
|
|
3838
3706
|
} else {
|
|
3839
3707
|
if (isClassString) {
|
|
3840
3708
|
if (prev !== next) {
|
|
3841
|
-
if (isPrevClassString)
|
|
3842
|
-
classList.remove(...prev?.split(","));
|
|
3709
|
+
if (isPrevClassString) classList.remove(...prev?.split(","));
|
|
3843
3710
|
classList.add(...next.split(","));
|
|
3844
3711
|
}
|
|
3845
3712
|
} else if (prev) {
|
|
3846
|
-
if (isPrevClassString)
|
|
3847
|
-
classList.remove(...prev?.split(","));
|
|
3713
|
+
if (isPrevClassString) classList.remove(...prev?.split(","));
|
|
3848
3714
|
}
|
|
3849
3715
|
}
|
|
3850
3716
|
};
|
|
@@ -3853,17 +3719,14 @@ var patchClass = (el, next, prev) => {
|
|
|
3853
3719
|
var htmlDirective = {
|
|
3854
3720
|
onChange: (el, values) => {
|
|
3855
3721
|
const [value, replacer] = values;
|
|
3856
|
-
if (isFunction(replacer))
|
|
3857
|
-
|
|
3858
|
-
else
|
|
3859
|
-
el.innerHTML = value?.toString();
|
|
3722
|
+
if (isFunction(replacer)) replacer(el, value);
|
|
3723
|
+
else el.innerHTML = value?.toString();
|
|
3860
3724
|
}
|
|
3861
3725
|
};
|
|
3862
3726
|
|
|
3863
3727
|
// src/common/looseEqual.ts
|
|
3864
3728
|
function looseCompareArrays(a, b) {
|
|
3865
|
-
if (a.length !== b.length)
|
|
3866
|
-
return false;
|
|
3729
|
+
if (a.length !== b.length) return false;
|
|
3867
3730
|
let equal = true;
|
|
3868
3731
|
for (let i = 0; equal && i < a.length; i++) {
|
|
3869
3732
|
equal = looseEqual(a[i], b[i]);
|
|
@@ -3871,8 +3734,7 @@ function looseCompareArrays(a, b) {
|
|
|
3871
3734
|
return equal;
|
|
3872
3735
|
}
|
|
3873
3736
|
function looseEqual(a, b) {
|
|
3874
|
-
if (a === b)
|
|
3875
|
-
return true;
|
|
3737
|
+
if (a === b) return true;
|
|
3876
3738
|
let aValidType = isDate(a);
|
|
3877
3739
|
let bValidType = isDate(b);
|
|
3878
3740
|
if (aValidType || bValidType) {
|
|
@@ -3978,8 +3840,7 @@ var updateDomElementValue = (el, value) => {
|
|
|
3978
3840
|
}
|
|
3979
3841
|
} else {
|
|
3980
3842
|
if (looseEqual(getValue(option), value)) {
|
|
3981
|
-
if (el.selectedIndex !== i)
|
|
3982
|
-
el.selectedIndex = i;
|
|
3843
|
+
if (el.selectedIndex !== i) el.selectedIndex = i;
|
|
3983
3844
|
return;
|
|
3984
3845
|
}
|
|
3985
3846
|
}
|
|
@@ -3992,10 +3853,8 @@ var updateDomElementValue = (el, value) => {
|
|
|
3992
3853
|
}
|
|
3993
3854
|
};
|
|
3994
3855
|
var getFlags = (flag) => {
|
|
3995
|
-
if (isRef(flag))
|
|
3996
|
-
|
|
3997
|
-
if (isFunction(flag))
|
|
3998
|
-
flag = flag();
|
|
3856
|
+
if (isRef(flag)) flag = flag();
|
|
3857
|
+
if (isFunction(flag)) flag = flag();
|
|
3999
3858
|
if (!flag)
|
|
4000
3859
|
return {
|
|
4001
3860
|
trim: false,
|
|
@@ -4029,7 +3888,7 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
|
|
|
4029
3888
|
const f1 = getFlags(directiveFlags?.join(","));
|
|
4030
3889
|
const f2 = getFlags(parsedValue()[1]);
|
|
4031
3890
|
const flags = {
|
|
4032
|
-
int: f1.int ||
|
|
3891
|
+
int: f1.int || f2.int,
|
|
4033
3892
|
lazy: f1.lazy || f2.lazy,
|
|
4034
3893
|
number: f1.number || f2.number,
|
|
4035
3894
|
trim: f1.trim || f2.trim
|
|
@@ -4061,8 +3920,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4061
3920
|
const eventType = isLazy ? "change" : "input";
|
|
4062
3921
|
const isNumber = isNumberInput(el);
|
|
4063
3922
|
const trimmer = () => {
|
|
4064
|
-
if (!flags.trim && !getFlags(parsedValue()[1]).trim)
|
|
4065
|
-
return;
|
|
3923
|
+
if (!flags.trim && !getFlags(parsedValue()[1]).trim) return;
|
|
4066
3924
|
el.value = el.value.trim();
|
|
4067
3925
|
};
|
|
4068
3926
|
const onCompositionStart = (e) => {
|
|
@@ -4085,8 +3943,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4085
3943
|
};
|
|
4086
3944
|
const listener = (event) => {
|
|
4087
3945
|
const target = event.target;
|
|
4088
|
-
if (!target || target.composing)
|
|
4089
|
-
return;
|
|
3946
|
+
if (!target || target.composing) return;
|
|
4090
3947
|
let value = target.value;
|
|
4091
3948
|
const flags2 = getFlags(parsedValue()[1]);
|
|
4092
3949
|
if (isNumber || flags2.number || flags2.int) {
|
|
@@ -4097,15 +3954,12 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4097
3954
|
if (endsWithDecimalSeparator) {
|
|
4098
3955
|
value += "0";
|
|
4099
3956
|
value = parseFloat(value);
|
|
4100
|
-
if (isNaN(value))
|
|
4101
|
-
|
|
4102
|
-
else if (modelRef() === value)
|
|
4103
|
-
return;
|
|
3957
|
+
if (isNaN(value)) value = "";
|
|
3958
|
+
else if (modelRef() === value) return;
|
|
4104
3959
|
}
|
|
4105
3960
|
value = parseFloat(value);
|
|
4106
3961
|
}
|
|
4107
|
-
if (isNaN(value))
|
|
4108
|
-
value = "";
|
|
3962
|
+
if (isNaN(value)) value = "";
|
|
4109
3963
|
el.value = value;
|
|
4110
3964
|
} else if (flags2.trim) {
|
|
4111
3965
|
value = value.trim();
|
|
@@ -4162,8 +4016,7 @@ var getCheckboxValue = (el, checked) => {
|
|
|
4162
4016
|
return el[key];
|
|
4163
4017
|
}
|
|
4164
4018
|
const attrKey = checked ? trueValueAttrKey : falseValueAttrKey;
|
|
4165
|
-
if (el.hasAttribute(attrKey))
|
|
4166
|
-
return el.getAttribute(attrKey);
|
|
4019
|
+
if (el.hasAttribute(attrKey)) return el.getAttribute(attrKey);
|
|
4167
4020
|
return checked;
|
|
4168
4021
|
};
|
|
4169
4022
|
var getCheckboxChecked = (el, value) => {
|
|
@@ -4205,8 +4058,7 @@ var handleSelect = (el, modelRef, parsedValue) => {
|
|
|
4205
4058
|
pause(modelRef);
|
|
4206
4059
|
if (isSet(modelValue)) {
|
|
4207
4060
|
modelValue.clear();
|
|
4208
|
-
for (const sel of selectedValue)
|
|
4209
|
-
modelValue.add(sel);
|
|
4061
|
+
for (const sel of selectedValue) modelValue.add(sel);
|
|
4210
4062
|
} else if (isArray(modelValue)) {
|
|
4211
4063
|
modelValue.splice(0);
|
|
4212
4064
|
modelValue.push(...selectedValue);
|
|
@@ -4257,9 +4109,8 @@ var onDirective = {
|
|
|
4257
4109
|
if (dynamicOption) {
|
|
4258
4110
|
const values2 = parseResult.value();
|
|
4259
4111
|
const option2 = unref(dynamicOption.value()[0]);
|
|
4260
|
-
if (!isString(option2))
|
|
4261
|
-
|
|
4262
|
-
};
|
|
4112
|
+
if (!isString(option2)) return () => {
|
|
4113
|
+
};
|
|
4263
4114
|
return attachEventListener(
|
|
4264
4115
|
el,
|
|
4265
4116
|
camelize(option2),
|
|
@@ -4283,18 +4134,15 @@ var onDirective = {
|
|
|
4283
4134
|
const len = values.length;
|
|
4284
4135
|
for (let i = 0; i < len; ++i) {
|
|
4285
4136
|
let next = values[i];
|
|
4286
|
-
if (isFunction(next))
|
|
4287
|
-
next = next();
|
|
4137
|
+
if (isFunction(next)) next = next();
|
|
4288
4138
|
if (isObject(next)) {
|
|
4289
4139
|
for (const item of Object.entries(next)) {
|
|
4290
4140
|
const eventType = item[0];
|
|
4291
4141
|
const method = () => {
|
|
4292
4142
|
let obj = parseResult.value()[i];
|
|
4293
|
-
if (isFunction(obj))
|
|
4294
|
-
obj = obj();
|
|
4143
|
+
if (isFunction(obj)) obj = obj();
|
|
4295
4144
|
obj = obj[eventType];
|
|
4296
|
-
if (isFunction(obj))
|
|
4297
|
-
obj = obj();
|
|
4145
|
+
if (isFunction(obj)) obj = obj();
|
|
4298
4146
|
return obj;
|
|
4299
4147
|
};
|
|
4300
4148
|
const flags2 = next[eventType + "_flags"];
|
|
@@ -4318,22 +4166,17 @@ var getShouldExecuteEvent = (eventType, flags) => {
|
|
|
4318
4166
|
const isAlt = parts.includes("alt");
|
|
4319
4167
|
const isMeta = parts.includes("meta");
|
|
4320
4168
|
const checkModifiers = (e) => {
|
|
4321
|
-
if (isCtrl && !e.ctrlKey)
|
|
4322
|
-
|
|
4323
|
-
if (
|
|
4324
|
-
|
|
4325
|
-
if (isAlt && !e.altKey)
|
|
4326
|
-
return false;
|
|
4327
|
-
if (isMeta && !e.metaKey)
|
|
4328
|
-
return false;
|
|
4169
|
+
if (isCtrl && !e.ctrlKey) return false;
|
|
4170
|
+
if (isShift && !e.shiftKey) return false;
|
|
4171
|
+
if (isAlt && !e.altKey) return false;
|
|
4172
|
+
if (isMeta && !e.metaKey) return false;
|
|
4329
4173
|
return true;
|
|
4330
4174
|
};
|
|
4331
4175
|
if (keyType) {
|
|
4332
4176
|
return [
|
|
4333
4177
|
eventType,
|
|
4334
4178
|
(e) => {
|
|
4335
|
-
if (!checkModifiers(e))
|
|
4336
|
-
return false;
|
|
4179
|
+
if (!checkModifiers(e)) return false;
|
|
4337
4180
|
return e.key.toUpperCase() === keyType.toUpperCase();
|
|
4338
4181
|
}
|
|
4339
4182
|
];
|
|
@@ -4357,15 +4200,11 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4357
4200
|
let shouldExecuteEvent;
|
|
4358
4201
|
[eventType, shouldExecuteEvent] = getShouldExecuteEvent(eventType, flags);
|
|
4359
4202
|
const execute = (e) => {
|
|
4360
|
-
if (!shouldExecuteEvent(e))
|
|
4361
|
-
|
|
4362
|
-
if (!method && eventType === "submit" && flag?.prevent)
|
|
4363
|
-
return;
|
|
4203
|
+
if (!shouldExecuteEvent(e)) return;
|
|
4204
|
+
if (!method && eventType === "submit" && flag?.prevent) return;
|
|
4364
4205
|
let r = method(e);
|
|
4365
|
-
if (isFunction(r))
|
|
4366
|
-
|
|
4367
|
-
if (isFunction(r))
|
|
4368
|
-
r(e);
|
|
4206
|
+
if (isFunction(r)) r = r(e);
|
|
4207
|
+
if (isFunction(r)) r(e);
|
|
4369
4208
|
};
|
|
4370
4209
|
const unbinder = () => {
|
|
4371
4210
|
el.removeEventListener(eventType, listener, options);
|
|
@@ -4376,22 +4215,15 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4376
4215
|
return;
|
|
4377
4216
|
}
|
|
4378
4217
|
try {
|
|
4379
|
-
if (flag.left && e.button !==
|
|
4380
|
-
|
|
4381
|
-
if (flag.
|
|
4382
|
-
|
|
4383
|
-
if (flag.
|
|
4384
|
-
|
|
4385
|
-
if (flag.self && e.target !== el)
|
|
4386
|
-
return;
|
|
4387
|
-
if (flag.stop)
|
|
4388
|
-
e.stopPropagation();
|
|
4389
|
-
if (flag.prevent)
|
|
4390
|
-
e.preventDefault();
|
|
4218
|
+
if (flag.left && e.button !== 0) return;
|
|
4219
|
+
if (flag.middle && e.button !== 1) return;
|
|
4220
|
+
if (flag.right && e.button !== 2) return;
|
|
4221
|
+
if (flag.self && e.target !== el) return;
|
|
4222
|
+
if (flag.stop) e.stopPropagation();
|
|
4223
|
+
if (flag.prevent) e.preventDefault();
|
|
4391
4224
|
execute(e);
|
|
4392
4225
|
} finally {
|
|
4393
|
-
if (flag.once)
|
|
4394
|
-
unbinder();
|
|
4226
|
+
if (flag.once) unbinder();
|
|
4395
4227
|
}
|
|
4396
4228
|
};
|
|
4397
4229
|
el.addEventListener(eventType, listener, options);
|
|
@@ -4402,8 +4234,7 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4402
4234
|
var propDirective = {
|
|
4403
4235
|
onChange: (el, values, _previousValues, option, _previousOption, flags) => {
|
|
4404
4236
|
if (option) {
|
|
4405
|
-
if (flags && flags.includes("camel"))
|
|
4406
|
-
option = camelize(option);
|
|
4237
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
4407
4238
|
patchProp(el, option, values[0]);
|
|
4408
4239
|
return;
|
|
4409
4240
|
}
|
|
@@ -4486,18 +4317,14 @@ var refDirective = {
|
|
|
4486
4317
|
const value = result.value()[0];
|
|
4487
4318
|
const isAnArray = isArray(value);
|
|
4488
4319
|
const sref2 = result.refs[0];
|
|
4489
|
-
if (isAnArray)
|
|
4490
|
-
|
|
4491
|
-
else
|
|
4492
|
-
sref2?.(el);
|
|
4493
|
-
else
|
|
4494
|
-
result.context[expr] = el;
|
|
4320
|
+
if (isAnArray) value.push(el);
|
|
4321
|
+
else if (sref2) sref2?.(el);
|
|
4322
|
+
else result.context[expr] = el;
|
|
4495
4323
|
return () => {
|
|
4496
4324
|
if (isAnArray) {
|
|
4497
4325
|
const i = value.indexOf(el);
|
|
4498
4326
|
i !== -1 && value.splice(i, 1);
|
|
4499
|
-
} else
|
|
4500
|
-
sref2?.(null);
|
|
4327
|
+
} else sref2?.(null);
|
|
4501
4328
|
};
|
|
4502
4329
|
}
|
|
4503
4330
|
};
|
|
@@ -4511,10 +4338,8 @@ var showDirective = {
|
|
|
4511
4338
|
originalDisplay = data._ord = el.style.display;
|
|
4512
4339
|
}
|
|
4513
4340
|
const isVisible = !!values[0];
|
|
4514
|
-
if (isVisible)
|
|
4515
|
-
|
|
4516
|
-
else
|
|
4517
|
-
el.style.display = "none";
|
|
4341
|
+
if (isVisible) el.style.display = originalDisplay;
|
|
4342
|
+
else el.style.display = "none";
|
|
4518
4343
|
}
|
|
4519
4344
|
};
|
|
4520
4345
|
|
|
@@ -4560,8 +4385,7 @@ var patchStyle = (el, next, prev) => {
|
|
|
4560
4385
|
el.removeAttribute("style");
|
|
4561
4386
|
}
|
|
4562
4387
|
const data = getBindData(el).data;
|
|
4563
|
-
if ("_ord" in data)
|
|
4564
|
-
return;
|
|
4388
|
+
if ("_ord" in data) return;
|
|
4565
4389
|
style.display = currentDisplay;
|
|
4566
4390
|
}
|
|
4567
4391
|
};
|
|
@@ -4572,8 +4396,7 @@ function setStyle(style, name2, val) {
|
|
|
4572
4396
|
setStyle(style, name2, v);
|
|
4573
4397
|
});
|
|
4574
4398
|
} else {
|
|
4575
|
-
if (val == null)
|
|
4576
|
-
val = "";
|
|
4399
|
+
if (val == null) val = "";
|
|
4577
4400
|
if (name2.startsWith("--")) {
|
|
4578
4401
|
style.setProperty(name2, val);
|
|
4579
4402
|
} else {
|
|
@@ -4615,11 +4438,9 @@ function autoPrefix(style, rawName) {
|
|
|
4615
4438
|
var flatten = (reference) => {
|
|
4616
4439
|
return flattenContent(unref(reference));
|
|
4617
4440
|
};
|
|
4618
|
-
var flattenContent = (value) => {
|
|
4619
|
-
if (!value)
|
|
4620
|
-
|
|
4621
|
-
if (!isObject(value))
|
|
4622
|
-
return value;
|
|
4441
|
+
var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
|
|
4442
|
+
if (!value) return value;
|
|
4443
|
+
if (!isObject(value)) return value;
|
|
4623
4444
|
if (isArray(value)) {
|
|
4624
4445
|
return value.map(flatten);
|
|
4625
4446
|
}
|
|
@@ -4632,14 +4453,16 @@ var flattenContent = (value) => {
|
|
|
4632
4453
|
}
|
|
4633
4454
|
if (isMap(value)) {
|
|
4634
4455
|
const map = /* @__PURE__ */ new Map();
|
|
4635
|
-
for (const el of
|
|
4456
|
+
for (const el of value) {
|
|
4636
4457
|
map.set(flatten(el[0]), flatten(el[1]));
|
|
4637
4458
|
}
|
|
4638
4459
|
return map;
|
|
4639
4460
|
}
|
|
4461
|
+
if (weakMap.has(value)) return unref(weakMap.get(value));
|
|
4640
4462
|
const result = { ...value };
|
|
4463
|
+
weakMap.set(value, result);
|
|
4641
4464
|
for (const entry of Object.entries(result)) {
|
|
4642
|
-
result[entry[0]] =
|
|
4465
|
+
result[entry[0]] = flattenContent(unref(entry[1]), weakMap);
|
|
4643
4466
|
}
|
|
4644
4467
|
return result;
|
|
4645
4468
|
};
|
|
@@ -4666,8 +4489,7 @@ var isDeepRef = (value) => {
|
|
|
4666
4489
|
|
|
4667
4490
|
// src/reactivity/ref.ts
|
|
4668
4491
|
var ref = (value) => {
|
|
4669
|
-
if (isRaw(value))
|
|
4670
|
-
return value;
|
|
4492
|
+
if (isRaw(value)) return value;
|
|
4671
4493
|
let result;
|
|
4672
4494
|
if (isRef(value)) {
|
|
4673
4495
|
result = value;
|
|
@@ -4682,21 +4504,18 @@ var ref = (value) => {
|
|
|
4682
4504
|
const len = value.length;
|
|
4683
4505
|
for (let i = 0; i < len; ++i) {
|
|
4684
4506
|
const item = value[i];
|
|
4685
|
-
if (isDeepRef(item))
|
|
4686
|
-
continue;
|
|
4507
|
+
if (isDeepRef(item)) continue;
|
|
4687
4508
|
value[i] = ref(item);
|
|
4688
4509
|
}
|
|
4689
4510
|
return result;
|
|
4690
4511
|
}
|
|
4691
|
-
if (!isObject(value))
|
|
4692
|
-
return result;
|
|
4512
|
+
if (!isObject(value)) return result;
|
|
4693
4513
|
for (const item of Object.entries(value)) {
|
|
4694
4514
|
const val = item[1];
|
|
4695
|
-
if (isDeepRef(val))
|
|
4696
|
-
continue;
|
|
4515
|
+
if (isDeepRef(val)) continue;
|
|
4697
4516
|
const key = item[0];
|
|
4698
|
-
if (isSymbol(key))
|
|
4699
|
-
|
|
4517
|
+
if (isSymbol(key)) continue;
|
|
4518
|
+
value[key] = null;
|
|
4700
4519
|
value[key] = ref(val);
|
|
4701
4520
|
}
|
|
4702
4521
|
return result;
|
|
@@ -4829,8 +4648,7 @@ var RegorConfig = class _RegorConfig {
|
|
|
4829
4648
|
|
|
4830
4649
|
// src/bind/interpolation.ts
|
|
4831
4650
|
var interpolate = (element, config) => {
|
|
4832
|
-
if (!element)
|
|
4833
|
-
return;
|
|
4651
|
+
if (!element) return;
|
|
4834
4652
|
const builtInNames = (config ?? RegorConfig.getDefault()).__builtInNames;
|
|
4835
4653
|
for (const textNode of getTextNodes(element, builtInNames.pre)) {
|
|
4836
4654
|
interpolateTextNode(textNode, builtInNames.text);
|
|
@@ -4839,12 +4657,10 @@ var interpolate = (element, config) => {
|
|
|
4839
4657
|
var interpolationRegex = /({{[^]*?}})/g;
|
|
4840
4658
|
var interpolateTextNode = (textNode, textDirective2) => {
|
|
4841
4659
|
const text = textNode.textContent;
|
|
4842
|
-
if (!text)
|
|
4843
|
-
return;
|
|
4660
|
+
if (!text) return;
|
|
4844
4661
|
const mustacheRegex = interpolationRegex;
|
|
4845
4662
|
const parts = text.split(mustacheRegex);
|
|
4846
|
-
if (parts.length <= 1)
|
|
4847
|
-
return;
|
|
4663
|
+
if (parts.length <= 1) return;
|
|
4848
4664
|
if (textNode.parentElement?.childNodes.length === 1 && parts.length === 3) {
|
|
4849
4665
|
const part = parts[1];
|
|
4850
4666
|
if (isNullOrWhitespace(parts[0]) && isNullOrWhitespace(parts[2]) && part.startsWith("{{") && part.endsWith("}}")) {
|
|
@@ -4875,8 +4691,7 @@ var getTextNodes = (node, preDirective) => {
|
|
|
4875
4691
|
textNodes.push(node2);
|
|
4876
4692
|
}
|
|
4877
4693
|
} else {
|
|
4878
|
-
if (node2?.hasAttribute?.(preDirective))
|
|
4879
|
-
return;
|
|
4694
|
+
if (node2?.hasAttribute?.(preDirective)) return;
|
|
4880
4695
|
for (const child of getChildNodes(node2)) {
|
|
4881
4696
|
traverseTextNodes(child);
|
|
4882
4697
|
}
|
|
@@ -4891,10 +4706,8 @@ var svgTags = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-
|
|
|
4891
4706
|
var svgSet = new Set(svgTags.toUpperCase().split(","));
|
|
4892
4707
|
var svgNamespace = "http://www.w3.org/2000/svg";
|
|
4893
4708
|
var appendChild = (parent, el) => {
|
|
4894
|
-
if (isTemplate(parent))
|
|
4895
|
-
|
|
4896
|
-
else
|
|
4897
|
-
parent.appendChild(el);
|
|
4709
|
+
if (isTemplate(parent)) parent.content.appendChild(el);
|
|
4710
|
+
else parent.appendChild(el);
|
|
4898
4711
|
};
|
|
4899
4712
|
var render = (json, parent, isSVG, config) => {
|
|
4900
4713
|
const tag = json.t;
|
|
@@ -4914,8 +4727,7 @@ var render = (json, parent, isSVG, config) => {
|
|
|
4914
4727
|
}
|
|
4915
4728
|
const children = json.c;
|
|
4916
4729
|
if (children) {
|
|
4917
|
-
for (const child of children)
|
|
4918
|
-
render(child, el, isSVG, config);
|
|
4730
|
+
for (const child of children) render(child, el, isSVG, config);
|
|
4919
4731
|
}
|
|
4920
4732
|
appendChild(parent, el);
|
|
4921
4733
|
return;
|
|
@@ -4931,10 +4743,8 @@ var render = (json, parent, isSVG, config) => {
|
|
|
4931
4743
|
node = document.createTextNode(textData);
|
|
4932
4744
|
break;
|
|
4933
4745
|
}
|
|
4934
|
-
if (node)
|
|
4935
|
-
|
|
4936
|
-
else
|
|
4937
|
-
throw new Error("unsupported node type.");
|
|
4746
|
+
if (node) appendChild(parent, node);
|
|
4747
|
+
else throw new Error("unsupported node type.");
|
|
4938
4748
|
}
|
|
4939
4749
|
};
|
|
4940
4750
|
var toFragment = (json, isSVG, config) => {
|
|
@@ -4951,16 +4761,13 @@ var toFragment = (json, isSVG, config) => {
|
|
|
4951
4761
|
};
|
|
4952
4762
|
|
|
4953
4763
|
// src/app/createApp.ts
|
|
4954
|
-
var createApp = (context,
|
|
4955
|
-
if (isString(
|
|
4956
|
-
|
|
4957
|
-
if (isScope(context))
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
if (!
|
|
4961
|
-
throw getError(0 /* AppRootElementMissing */);
|
|
4962
|
-
if (!config)
|
|
4963
|
-
config = RegorConfig.getDefault();
|
|
4764
|
+
var createApp = (context, template = { selector: "#app" }, config) => {
|
|
4765
|
+
if (isString(template))
|
|
4766
|
+
template = { selector: "#app", template };
|
|
4767
|
+
if (isScope(context)) context = context.context;
|
|
4768
|
+
const root = template.element ? template.element : template.selector ? document.querySelector(template.selector) : null;
|
|
4769
|
+
if (!root || !isElement(root)) throw getError(0 /* AppRootElementMissing */);
|
|
4770
|
+
if (!config) config = RegorConfig.getDefault();
|
|
4964
4771
|
const cleanRoot = () => {
|
|
4965
4772
|
for (const child of [...root.childNodes]) {
|
|
4966
4773
|
removeNode(child);
|
|
@@ -4971,22 +4778,21 @@ var createApp = (context, templateOptions = { selector: "#app" }, config) => {
|
|
|
4971
4778
|
root.appendChild(child);
|
|
4972
4779
|
}
|
|
4973
4780
|
};
|
|
4974
|
-
if (
|
|
4975
|
-
const element = document.createRange().createContextualFragment(
|
|
4781
|
+
if (template.template) {
|
|
4782
|
+
const element = document.createRange().createContextualFragment(template.template);
|
|
4976
4783
|
cleanRoot();
|
|
4977
4784
|
appendChildren(element.childNodes);
|
|
4978
|
-
|
|
4979
|
-
} else if (
|
|
4785
|
+
template.element = element;
|
|
4786
|
+
} else if (template.json) {
|
|
4980
4787
|
const element = toFragment(
|
|
4981
|
-
|
|
4982
|
-
|
|
4788
|
+
template.json,
|
|
4789
|
+
template.isSVG,
|
|
4983
4790
|
config
|
|
4984
4791
|
);
|
|
4985
4792
|
cleanRoot();
|
|
4986
4793
|
appendChildren(element.childNodes);
|
|
4987
4794
|
}
|
|
4988
|
-
if (config.useInterpolation)
|
|
4989
|
-
interpolate(root, config);
|
|
4795
|
+
if (config.useInterpolation) interpolate(root, config);
|
|
4990
4796
|
const app = new RegorApp(context, root, config);
|
|
4991
4797
|
app.__bind();
|
|
4992
4798
|
addUnbinder(root, () => {
|
|
@@ -5027,13 +4833,10 @@ var toJsonTemplate = (node) => {
|
|
|
5027
4833
|
return node.map((x) => toJsonTemplate(x));
|
|
5028
4834
|
}
|
|
5029
4835
|
const json = {};
|
|
5030
|
-
if (node.tagName)
|
|
5031
|
-
json.t = node.tagName;
|
|
4836
|
+
if (node.tagName) json.t = node.tagName;
|
|
5032
4837
|
else {
|
|
5033
|
-
if (node.nodeType === Node.COMMENT_NODE)
|
|
5034
|
-
|
|
5035
|
-
if (node.textContent)
|
|
5036
|
-
json.d = node.textContent;
|
|
4838
|
+
if (node.nodeType === Node.COMMENT_NODE) json.n = Node.COMMENT_NODE;
|
|
4839
|
+
if (node.textContent) json.d = node.textContent;
|
|
5037
4840
|
return json;
|
|
5038
4841
|
}
|
|
5039
4842
|
const attrNames = node.getAttributeNames();
|
|
@@ -5052,50 +4855,47 @@ var toJsonTemplate = (node) => {
|
|
|
5052
4855
|
};
|
|
5053
4856
|
|
|
5054
4857
|
// src/app/createComponent.ts
|
|
5055
|
-
var createComponent = (context,
|
|
5056
|
-
if (isArray(options))
|
|
5057
|
-
|
|
5058
|
-
if (isString(templateOptions))
|
|
5059
|
-
templateOptions = { template: templateOptions };
|
|
4858
|
+
var createComponent = (context, template, options = {}) => {
|
|
4859
|
+
if (isArray(options)) options = { props: options };
|
|
4860
|
+
if (isString(template)) template = { template };
|
|
5060
4861
|
let svgHandled = false;
|
|
5061
|
-
if (
|
|
5062
|
-
const element2 =
|
|
4862
|
+
if (template.element) {
|
|
4863
|
+
const element2 = template.element;
|
|
5063
4864
|
element2.remove();
|
|
5064
|
-
|
|
5065
|
-
} else if (
|
|
5066
|
-
const element2 = document.querySelector(
|
|
4865
|
+
template.element = element2;
|
|
4866
|
+
} else if (template.selector) {
|
|
4867
|
+
const element2 = document.querySelector(template.selector);
|
|
5067
4868
|
if (!element2)
|
|
5068
4869
|
throw getError(
|
|
5069
4870
|
1 /* ComponentTemplateNotFound */,
|
|
5070
|
-
|
|
4871
|
+
template.selector
|
|
5071
4872
|
);
|
|
5072
4873
|
element2.remove();
|
|
5073
|
-
|
|
5074
|
-
} else if (
|
|
5075
|
-
const element2 = document.createRange().createContextualFragment(
|
|
5076
|
-
|
|
5077
|
-
} else if (
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
4874
|
+
template.element = element2;
|
|
4875
|
+
} else if (template.template) {
|
|
4876
|
+
const element2 = document.createRange().createContextualFragment(template.template);
|
|
4877
|
+
template.element = element2;
|
|
4878
|
+
} else if (template.json) {
|
|
4879
|
+
template.element = toFragment(
|
|
4880
|
+
template.json,
|
|
4881
|
+
template.isSVG,
|
|
5081
4882
|
options.config
|
|
5082
4883
|
);
|
|
5083
4884
|
svgHandled = true;
|
|
5084
4885
|
}
|
|
5085
|
-
if (!
|
|
5086
|
-
|
|
5087
|
-
if (options.useInterpolation ?? true)
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
const content = templateOptions.element.content;
|
|
4886
|
+
if (!template.element)
|
|
4887
|
+
template.element = document.createDocumentFragment();
|
|
4888
|
+
if (options.useInterpolation ?? true) interpolate(template.element);
|
|
4889
|
+
const element = template.element;
|
|
4890
|
+
if (!svgHandled && ((template.isSVG ?? (isHTMLElement(element) && element.hasAttribute?.("isSVG"))) || isHTMLElement(element) && !!element.querySelector("[isSVG]"))) {
|
|
4891
|
+
const content = template.element.content;
|
|
5092
4892
|
const nodes = content ? [...content.childNodes] : [...element.childNodes];
|
|
5093
4893
|
const json = toJsonTemplate(nodes);
|
|
5094
|
-
|
|
4894
|
+
template.element = toFragment(json, true, options.config);
|
|
5095
4895
|
}
|
|
5096
4896
|
return {
|
|
5097
4897
|
context,
|
|
5098
|
-
template:
|
|
4898
|
+
template: template.element,
|
|
5099
4899
|
inheritAttrs: options.inheritAttrs ?? true,
|
|
5100
4900
|
props: options.props,
|
|
5101
4901
|
defaultName: options.defaultName
|
|
@@ -5109,8 +4909,7 @@ var computed = (compute) => {
|
|
|
5109
4909
|
const result = (...args) => {
|
|
5110
4910
|
if (args.length <= 2 && 0 in args)
|
|
5111
4911
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5112
|
-
if (computer && !status.isStopped)
|
|
5113
|
-
return computer(...args);
|
|
4912
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5114
4913
|
computer = computedOnce(compute, status);
|
|
5115
4914
|
return computer(...args);
|
|
5116
4915
|
};
|
|
@@ -5146,8 +4945,7 @@ var computeMany = (sources, compute) => {
|
|
|
5146
4945
|
const result = (...args) => {
|
|
5147
4946
|
if (args.length <= 2 && 0 in args)
|
|
5148
4947
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5149
|
-
if (computer && !status.isStopped)
|
|
5150
|
-
return computer(...args);
|
|
4948
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5151
4949
|
computer = computeManyOnce(sources, compute, status);
|
|
5152
4950
|
return computer(...args);
|
|
5153
4951
|
};
|
|
@@ -5193,8 +4991,7 @@ var computeRef = (source, compute) => {
|
|
|
5193
4991
|
const result = (...args) => {
|
|
5194
4992
|
if (args.length <= 2 && 0 in args)
|
|
5195
4993
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5196
|
-
if (computer && !status.isStopped)
|
|
5197
|
-
return computer(...args);
|
|
4994
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5198
4995
|
computer = computeRefOnce(source, compute, status);
|
|
5199
4996
|
return computer(...args);
|
|
5200
4997
|
};
|
|
@@ -5235,31 +5032,44 @@ var markRaw = (value) => {
|
|
|
5235
5032
|
|
|
5236
5033
|
// src/misc/persist.ts
|
|
5237
5034
|
var persist = (anyRef, key) => {
|
|
5238
|
-
if (!key)
|
|
5239
|
-
throw new Error("persist requires a string key.");
|
|
5035
|
+
if (!key) throw getError(5 /* PersistRequiresKey */);
|
|
5240
5036
|
const deepRef = isDeepRef(anyRef);
|
|
5241
5037
|
const makeRef = deepRef ? ref : (x) => x;
|
|
5242
5038
|
const store = () => localStorage.setItem(key, JSON.stringify(flatten(anyRef())));
|
|
5243
5039
|
const existing = localStorage.getItem(key);
|
|
5244
5040
|
if (existing != null) {
|
|
5245
|
-
|
|
5041
|
+
try {
|
|
5042
|
+
anyRef(makeRef(JSON.parse(existing)));
|
|
5043
|
+
} catch (e) {
|
|
5044
|
+
warning(
|
|
5045
|
+
6 /* ErrorLog */,
|
|
5046
|
+
`persist: failed to parse data for key ${key}`,
|
|
5047
|
+
e
|
|
5048
|
+
);
|
|
5049
|
+
store();
|
|
5050
|
+
}
|
|
5246
5051
|
} else {
|
|
5247
5052
|
store();
|
|
5248
5053
|
}
|
|
5249
5054
|
const stopObserving = watchEffect(store);
|
|
5250
|
-
onUnmounted(
|
|
5055
|
+
onUnmounted(stopObserving, true);
|
|
5251
5056
|
return anyRef;
|
|
5252
5057
|
};
|
|
5253
5058
|
|
|
5254
5059
|
// src/misc/tagged-html.ts
|
|
5255
5060
|
var html = (templates, ...args) => {
|
|
5256
|
-
let
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5061
|
+
let result = "";
|
|
5062
|
+
const tpl = templates;
|
|
5063
|
+
const a = args;
|
|
5064
|
+
const tplLen = tpl.length;
|
|
5065
|
+
const argLen = a.length;
|
|
5066
|
+
for (let i = 0; i < tplLen; ++i) {
|
|
5067
|
+
result += tpl[i];
|
|
5068
|
+
if (i < argLen) {
|
|
5069
|
+
result += a[i];
|
|
5070
|
+
}
|
|
5071
|
+
}
|
|
5072
|
+
return result;
|
|
5263
5073
|
};
|
|
5264
5074
|
var raw = html;
|
|
5265
5075
|
|
|
@@ -5272,8 +5082,7 @@ var observeMany = (sources, observer, init) => {
|
|
|
5272
5082
|
for (const source of sources) {
|
|
5273
5083
|
stopObservingList.push(observe(source, callObserver));
|
|
5274
5084
|
}
|
|
5275
|
-
if (init)
|
|
5276
|
-
callObserver();
|
|
5085
|
+
if (init) callObserver();
|
|
5277
5086
|
const stop = () => {
|
|
5278
5087
|
for (const stopObserving of stopObservingList) {
|
|
5279
5088
|
stopObserving();
|
|
@@ -5286,7 +5095,7 @@ var observeMany = (sources, observer, init) => {
|
|
|
5286
5095
|
// src/observer/observerCount.ts
|
|
5287
5096
|
var observerCount = (source) => {
|
|
5288
5097
|
if (!isRef(source))
|
|
5289
|
-
throw getError(3 /* RequiresRefSourceArgument */, "
|
|
5098
|
+
throw getError(3 /* RequiresRefSourceArgument */, "observerCount");
|
|
5290
5099
|
const srefImpl = source;
|
|
5291
5100
|
return srefImpl(void 0, void 0, 2 /* observerCount */);
|
|
5292
5101
|
};
|
|
@@ -5301,14 +5110,19 @@ var batch = (updater) => {
|
|
|
5301
5110
|
}
|
|
5302
5111
|
};
|
|
5303
5112
|
var startBatch = () => {
|
|
5304
|
-
if (!batchCollector.
|
|
5305
|
-
|
|
5113
|
+
if (!batchCollector.stack) batchCollector.stack = [];
|
|
5114
|
+
batchCollector.stack.push(/* @__PURE__ */ new Set());
|
|
5306
5115
|
};
|
|
5307
5116
|
var endBatch = () => {
|
|
5308
|
-
const
|
|
5309
|
-
if (!
|
|
5117
|
+
const stack = batchCollector.stack;
|
|
5118
|
+
if (!stack || stack.length === 0) return;
|
|
5119
|
+
const set = stack.pop();
|
|
5120
|
+
if (stack.length) {
|
|
5121
|
+
const parent = stack[stack.length - 1];
|
|
5122
|
+
for (const ref2 of set) parent.add(ref2);
|
|
5310
5123
|
return;
|
|
5311
|
-
|
|
5124
|
+
}
|
|
5125
|
+
delete batchCollector.stack;
|
|
5312
5126
|
for (const ref2 of set) {
|
|
5313
5127
|
try {
|
|
5314
5128
|
trigger(ref2);
|