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.es2019.cjs.js
CHANGED
|
@@ -17,14 +17,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var __publicField = (obj, key, value) =>
|
|
21
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
20
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
21
|
|
|
25
22
|
// src/index.ts
|
|
26
|
-
var
|
|
27
|
-
__export(
|
|
23
|
+
var index_exports = {};
|
|
24
|
+
__export(index_exports, {
|
|
28
25
|
ComponentHead: () => ComponentHead,
|
|
29
26
|
RegorConfig: () => RegorConfig,
|
|
30
27
|
addUnbinder: () => addUnbinder,
|
|
@@ -67,7 +64,7 @@ __export(src_exports, {
|
|
|
67
64
|
warningHandler: () => warningHandler,
|
|
68
65
|
watchEffect: () => watchEffect
|
|
69
66
|
});
|
|
70
|
-
module.exports = __toCommonJS(
|
|
67
|
+
module.exports = __toCommonJS(index_exports);
|
|
71
68
|
|
|
72
69
|
// src/common/is-what.ts
|
|
73
70
|
var isFunction = (value) => {
|
|
@@ -100,7 +97,8 @@ var errors = {
|
|
|
100
97
|
[1 /* ComponentTemplateNotFound */]: (selector) => `Component template cannot be found. selector: ${selector} .`,
|
|
101
98
|
[2 /* ComposablesRequireScope */]: "Use composables in scope. usage: useScope(() => new MyApp()).",
|
|
102
99
|
[3 /* RequiresRefSourceArgument */]: (name2) => `${name2} requires ref source argument`,
|
|
103
|
-
[4 /* ComputedIsReadOnly */]: "computed is readonly."
|
|
100
|
+
[4 /* ComputedIsReadOnly */]: "computed is readonly.",
|
|
101
|
+
[5 /* PersistRequiresKey */]: "persist requires a string key."
|
|
104
102
|
};
|
|
105
103
|
var getError = (type, ...args) => {
|
|
106
104
|
const msg = errors[type];
|
|
@@ -113,8 +111,7 @@ var bindDataSymbol = Symbol(":regor");
|
|
|
113
111
|
// src/cleanup/getBindData.ts
|
|
114
112
|
var getBindData = (node) => {
|
|
115
113
|
const bindData = node[bindDataSymbol];
|
|
116
|
-
if (bindData)
|
|
117
|
-
return bindData;
|
|
114
|
+
if (bindData) return bindData;
|
|
118
115
|
const newBindData = {
|
|
119
116
|
unbinders: [],
|
|
120
117
|
data: {}
|
|
@@ -140,8 +137,7 @@ var pushScope = () => {
|
|
|
140
137
|
};
|
|
141
138
|
var peekScope = (noThrow) => {
|
|
142
139
|
const scope = scopes[scopes.length - 1];
|
|
143
|
-
if (!scope && !noThrow)
|
|
144
|
-
throw getError(2 /* ComposablesRequireScope */);
|
|
140
|
+
if (!scope && !noThrow) throw getError(2 /* ComposablesRequireScope */);
|
|
145
141
|
return scope;
|
|
146
142
|
};
|
|
147
143
|
var popScope = (context) => {
|
|
@@ -156,8 +152,7 @@ var setScope = (context) => {
|
|
|
156
152
|
const existing = data[scopeSymbol];
|
|
157
153
|
if (existing) {
|
|
158
154
|
const cs = peekScope();
|
|
159
|
-
if (existing === cs)
|
|
160
|
-
return;
|
|
155
|
+
if (existing === cs) return;
|
|
161
156
|
cs.onMounted.length > 0 && existing.onMounted.push(...cs.onMounted);
|
|
162
157
|
cs.onUnmounted.length > 0 && existing.onUnmounted.push(...cs.onUnmounted);
|
|
163
158
|
return;
|
|
@@ -189,8 +184,7 @@ var isRef = (value) => {
|
|
|
189
184
|
var observe = (source, observer, init) => {
|
|
190
185
|
if (!isRef(source))
|
|
191
186
|
throw getError(3 /* RequiresRefSourceArgument */, "observe");
|
|
192
|
-
if (init)
|
|
193
|
-
observer(source());
|
|
187
|
+
if (init) observer(source());
|
|
194
188
|
const srefImpl = source;
|
|
195
189
|
const stop = srefImpl(
|
|
196
190
|
void 0,
|
|
@@ -209,8 +203,7 @@ var unbind = (node) => {
|
|
|
209
203
|
const currentElement = queue.shift();
|
|
210
204
|
unbindSingle(currentElement);
|
|
211
205
|
const childNodes = currentElement.childNodes;
|
|
212
|
-
if (!childNodes)
|
|
213
|
-
continue;
|
|
206
|
+
if (!childNodes) continue;
|
|
214
207
|
for (const item of childNodes) {
|
|
215
208
|
queue.push(item);
|
|
216
209
|
}
|
|
@@ -218,8 +211,7 @@ var unbind = (node) => {
|
|
|
218
211
|
};
|
|
219
212
|
var unbindSingle = (node) => {
|
|
220
213
|
const bindData = node[bindDataSymbol];
|
|
221
|
-
if (!bindData)
|
|
222
|
-
return;
|
|
214
|
+
if (!bindData) return;
|
|
223
215
|
for (const unbinder of bindData.unbinders) {
|
|
224
216
|
unbinder();
|
|
225
217
|
}
|
|
@@ -253,12 +245,9 @@ var warning = (type, ...args) => {
|
|
|
253
245
|
const msg = warnings[type];
|
|
254
246
|
const item = isFunction(msg) ? msg.call(warnings, ...args) : msg;
|
|
255
247
|
const handler = warningHandler.warning;
|
|
256
|
-
if (!handler)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
handler(item);
|
|
260
|
-
else
|
|
261
|
-
handler(item, ...item.args);
|
|
248
|
+
if (!handler) return;
|
|
249
|
+
if (isString(item)) handler(item);
|
|
250
|
+
else handler(item, ...item.args);
|
|
262
251
|
};
|
|
263
252
|
var warningHandler = { warning: console.warn };
|
|
264
253
|
|
|
@@ -297,11 +286,9 @@ var getSwitches = (nodes) => {
|
|
|
297
286
|
return [...set];
|
|
298
287
|
};
|
|
299
288
|
var setSwitchOwner = (owner, switchNodes) => {
|
|
300
|
-
if (!hasSwitch())
|
|
301
|
-
return;
|
|
289
|
+
if (!hasSwitch()) return;
|
|
302
290
|
const switches2 = getSwitches(switchNodes);
|
|
303
|
-
if (switches2.length === 0)
|
|
304
|
-
return;
|
|
291
|
+
if (switches2.length === 0) return;
|
|
305
292
|
switches2.forEach(refSwitch);
|
|
306
293
|
addUnbinder(owner, () => {
|
|
307
294
|
switches2.forEach(removeSwitch);
|
|
@@ -357,8 +344,7 @@ var IfBinder = class {
|
|
|
357
344
|
return isIfElement;
|
|
358
345
|
}
|
|
359
346
|
__isProcessedOrMark(el) {
|
|
360
|
-
if (el[ifMarker])
|
|
361
|
-
return true;
|
|
347
|
+
if (el[ifMarker]) return true;
|
|
362
348
|
el[ifMarker] = true;
|
|
363
349
|
findElements(el, this.__ifSelector).forEach(
|
|
364
350
|
(x) => x[ifMarker] = true
|
|
@@ -389,8 +375,7 @@ var IfBinder = class {
|
|
|
389
375
|
removeNode(x);
|
|
390
376
|
});
|
|
391
377
|
el.remove();
|
|
392
|
-
if (type !== "if")
|
|
393
|
-
el[elseMarker] = 1;
|
|
378
|
+
if (type !== "if") el[elseMarker] = 1;
|
|
394
379
|
const commentEnd = document.createComment(
|
|
395
380
|
`__end__ :${type}${expression != null ? expression : ""}`
|
|
396
381
|
);
|
|
@@ -403,8 +388,7 @@ var IfBinder = class {
|
|
|
403
388
|
};
|
|
404
389
|
}
|
|
405
390
|
__collectElses(el, refresh) {
|
|
406
|
-
if (!el)
|
|
407
|
-
return [];
|
|
391
|
+
if (!el) return [];
|
|
408
392
|
const nextElement = el.nextElementSibling;
|
|
409
393
|
if (el.hasAttribute(this.__else)) {
|
|
410
394
|
el.removeAttribute(this.__else);
|
|
@@ -426,8 +410,7 @@ var IfBinder = class {
|
|
|
426
410
|
];
|
|
427
411
|
} else {
|
|
428
412
|
const expression = el.getAttribute(this.__elseif);
|
|
429
|
-
if (!expression)
|
|
430
|
-
return [];
|
|
413
|
+
if (!expression) return [];
|
|
431
414
|
el.removeAttribute(this.__elseif);
|
|
432
415
|
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
433
416
|
el,
|
|
@@ -536,8 +519,7 @@ var bindChildNodes = (binder, childNodes) => {
|
|
|
536
519
|
var findElements = (element, selector) => {
|
|
537
520
|
var _a;
|
|
538
521
|
const result = element.querySelectorAll(selector);
|
|
539
|
-
if ((_a = element.matches) == null ? void 0 : _a.call(element, selector))
|
|
540
|
-
return [element, ...result];
|
|
522
|
+
if ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) return [element, ...result];
|
|
541
523
|
return result;
|
|
542
524
|
};
|
|
543
525
|
var isTemplate = (node) => node instanceof HTMLTemplateElement;
|
|
@@ -559,8 +541,7 @@ var defineRefValue = (result, isReadOnly) => {
|
|
|
559
541
|
return result();
|
|
560
542
|
},
|
|
561
543
|
set(value) {
|
|
562
|
-
if (isReadOnly)
|
|
563
|
-
throw new Error("value is readonly.");
|
|
544
|
+
if (isReadOnly) throw new Error("value is readonly.");
|
|
564
545
|
return result(value);
|
|
565
546
|
},
|
|
566
547
|
enumerable: true,
|
|
@@ -568,10 +549,8 @@ var defineRefValue = (result, isReadOnly) => {
|
|
|
568
549
|
});
|
|
569
550
|
};
|
|
570
551
|
var isOptionDynamic = (option, dynamic) => {
|
|
571
|
-
if (!option)
|
|
572
|
-
|
|
573
|
-
if (option.startsWith("["))
|
|
574
|
-
return option.substring(1, option.length - 1);
|
|
552
|
+
if (!option) return false;
|
|
553
|
+
if (option.startsWith("[")) return option.substring(1, option.length - 1);
|
|
575
554
|
const len = dynamic.length;
|
|
576
555
|
if (option.startsWith(dynamic)) {
|
|
577
556
|
return option.substring(len, option.length - len);
|
|
@@ -597,19 +576,16 @@ var cacheStringFunction = (fn) => {
|
|
|
597
576
|
};
|
|
598
577
|
var camelizeRE = /-(\w)/g;
|
|
599
578
|
var camelize = cacheStringFunction((str) => {
|
|
600
|
-
if (!str)
|
|
601
|
-
return str;
|
|
579
|
+
if (!str) return str;
|
|
602
580
|
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
603
581
|
});
|
|
604
582
|
var hyphenateRE = /\B([A-Z])/g;
|
|
605
583
|
var hyphenate = cacheStringFunction((str) => {
|
|
606
|
-
if (!str)
|
|
607
|
-
return str;
|
|
584
|
+
if (!str) return str;
|
|
608
585
|
return str.replace(hyphenateRE, "-$1").toLowerCase();
|
|
609
586
|
});
|
|
610
587
|
var capitalize = cacheStringFunction((str) => {
|
|
611
|
-
if (!str)
|
|
612
|
-
return str;
|
|
588
|
+
if (!str) return str;
|
|
613
589
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
614
590
|
});
|
|
615
591
|
|
|
@@ -617,14 +593,12 @@ var capitalize = cacheStringFunction((str) => {
|
|
|
617
593
|
var collectedRefs = [];
|
|
618
594
|
var collectRef = (ref2) => {
|
|
619
595
|
var _a;
|
|
620
|
-
if (collectedRefs.length === 0)
|
|
621
|
-
return;
|
|
596
|
+
if (collectedRefs.length === 0) return;
|
|
622
597
|
(_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
|
|
623
598
|
};
|
|
624
599
|
var watchEffect = (effect) => {
|
|
625
|
-
if (!effect)
|
|
626
|
-
|
|
627
|
-
};
|
|
600
|
+
if (!effect) return () => {
|
|
601
|
+
};
|
|
628
602
|
const terminator = { stop: () => {
|
|
629
603
|
} };
|
|
630
604
|
watchEffectInternal(effect, terminator);
|
|
@@ -632,13 +606,11 @@ var watchEffect = (effect) => {
|
|
|
632
606
|
return terminator.stop;
|
|
633
607
|
};
|
|
634
608
|
var watchEffectInternal = (effect, terminator) => {
|
|
635
|
-
if (!effect)
|
|
636
|
-
return;
|
|
609
|
+
if (!effect) return;
|
|
637
610
|
let stopObservingList = [];
|
|
638
611
|
let isStopped = false;
|
|
639
612
|
const stopWatch = () => {
|
|
640
|
-
for (const stop of stopObservingList)
|
|
641
|
-
stop();
|
|
613
|
+
for (const stop of stopObservingList) stop();
|
|
642
614
|
stopObservingList = [];
|
|
643
615
|
isStopped = true;
|
|
644
616
|
};
|
|
@@ -647,8 +619,7 @@ var watchEffectInternal = (effect, terminator) => {
|
|
|
647
619
|
const set = /* @__PURE__ */ new Set();
|
|
648
620
|
collectedRefs.push(set);
|
|
649
621
|
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
650
|
-
if (isStopped)
|
|
651
|
-
return;
|
|
622
|
+
if (isStopped) return;
|
|
652
623
|
for (const r of [...set]) {
|
|
653
624
|
const stopObserving = observe(r, () => {
|
|
654
625
|
stopWatch();
|
|
@@ -688,15 +659,12 @@ var isRaw = (value) => {
|
|
|
688
659
|
|
|
689
660
|
// src/reactivity/trigger.ts
|
|
690
661
|
var trigger = (source, eventSource, isRecursive) => {
|
|
691
|
-
if (!isRef(source))
|
|
692
|
-
return;
|
|
662
|
+
if (!isRef(source)) return;
|
|
693
663
|
const srefImpl = source;
|
|
694
664
|
srefImpl(void 0, eventSource, 1 /* trigger */);
|
|
695
|
-
if (!isRecursive)
|
|
696
|
-
return;
|
|
665
|
+
if (!isRecursive) return;
|
|
697
666
|
const obj = srefImpl();
|
|
698
|
-
if (!obj)
|
|
699
|
-
return;
|
|
667
|
+
if (!obj) return;
|
|
700
668
|
if (isArray(obj) || isSet(obj)) {
|
|
701
669
|
for (const el of obj) {
|
|
702
670
|
trigger(el, eventSource, true);
|
|
@@ -729,8 +697,7 @@ var createProxy = (originalProto, proxyProto, methodsToPatch4) => {
|
|
|
729
697
|
define(proxyProto, method, function mutator(...args) {
|
|
730
698
|
const result = original.apply(this, args);
|
|
731
699
|
const subscribers = this[srefSymbol];
|
|
732
|
-
for (const subscriber of subscribers)
|
|
733
|
-
trigger(subscriber);
|
|
700
|
+
for (const subscriber of subscribers) trigger(subscriber);
|
|
734
701
|
return result;
|
|
735
702
|
});
|
|
736
703
|
});
|
|
@@ -775,17 +742,14 @@ createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
|
775
742
|
// src/reactivity/sref.ts
|
|
776
743
|
var batchCollector = {};
|
|
777
744
|
var sref = (value) => {
|
|
778
|
-
if (isRef(value) || isRaw(value))
|
|
779
|
-
return value;
|
|
745
|
+
if (isRef(value) || isRaw(value)) return value;
|
|
780
746
|
const refObj = {
|
|
781
747
|
auto: true,
|
|
782
748
|
_value: value
|
|
783
749
|
};
|
|
784
750
|
const createProxy2 = (value2) => {
|
|
785
|
-
if (!isObject(value2))
|
|
786
|
-
|
|
787
|
-
if (srefSymbol in value2)
|
|
788
|
-
return true;
|
|
751
|
+
if (!isObject(value2)) return false;
|
|
752
|
+
if (srefSymbol in value2) return true;
|
|
789
753
|
const isAnArray = isArray(value2);
|
|
790
754
|
if (isAnArray) {
|
|
791
755
|
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
@@ -806,24 +770,22 @@ var sref = (value) => {
|
|
|
806
770
|
const isProxy = createProxy2(value);
|
|
807
771
|
const observers = /* @__PURE__ */ new Set();
|
|
808
772
|
const trigger2 = (newValue, eventSource) => {
|
|
809
|
-
if (batchCollector.
|
|
810
|
-
batchCollector.
|
|
773
|
+
if (batchCollector.stack && batchCollector.stack.length) {
|
|
774
|
+
const current = batchCollector.stack[batchCollector.stack.length - 1];
|
|
775
|
+
current.add(srefFunction);
|
|
811
776
|
return;
|
|
812
777
|
}
|
|
813
|
-
if (observers.size === 0)
|
|
814
|
-
return;
|
|
778
|
+
if (observers.size === 0) return;
|
|
815
779
|
silence(() => {
|
|
816
780
|
for (const callback of [...observers.keys()]) {
|
|
817
|
-
if (!observers.has(callback))
|
|
818
|
-
continue;
|
|
781
|
+
if (!observers.has(callback)) continue;
|
|
819
782
|
callback(newValue, eventSource);
|
|
820
783
|
}
|
|
821
784
|
});
|
|
822
785
|
};
|
|
823
786
|
const attachProxyHandle = (value2) => {
|
|
824
787
|
let proxyHandle = value2[srefSymbol];
|
|
825
|
-
if (!proxyHandle)
|
|
826
|
-
value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
788
|
+
if (!proxyHandle) value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
827
789
|
proxyHandle.add(srefFunction);
|
|
828
790
|
};
|
|
829
791
|
const srefFunction = (...args) => {
|
|
@@ -831,15 +793,12 @@ var sref = (value) => {
|
|
|
831
793
|
let newValue = args[0];
|
|
832
794
|
const eventSource = args[1];
|
|
833
795
|
if (0 in args) {
|
|
834
|
-
if (refObj._value === newValue)
|
|
835
|
-
return newValue;
|
|
796
|
+
if (refObj._value === newValue) return newValue;
|
|
836
797
|
if (isRef(newValue)) {
|
|
837
798
|
newValue = newValue();
|
|
838
|
-
if (refObj._value === newValue)
|
|
839
|
-
return newValue;
|
|
799
|
+
if (refObj._value === newValue) return newValue;
|
|
840
800
|
}
|
|
841
|
-
if (createProxy2(newValue))
|
|
842
|
-
attachProxyHandle(newValue);
|
|
801
|
+
if (createProxy2(newValue)) attachProxyHandle(newValue);
|
|
843
802
|
refObj._value = newValue;
|
|
844
803
|
if (refObj.auto) {
|
|
845
804
|
trigger2(newValue, eventSource);
|
|
@@ -854,9 +813,8 @@ var sref = (value) => {
|
|
|
854
813
|
switch (operation) {
|
|
855
814
|
case 0 /* observe */: {
|
|
856
815
|
const observer = args[3];
|
|
857
|
-
if (!observer)
|
|
858
|
-
|
|
859
|
-
};
|
|
816
|
+
if (!observer) return () => {
|
|
817
|
+
};
|
|
860
818
|
const removeObserver = (observer2) => {
|
|
861
819
|
observers.delete(observer2);
|
|
862
820
|
};
|
|
@@ -886,8 +844,7 @@ var sref = (value) => {
|
|
|
886
844
|
};
|
|
887
845
|
srefFunction[srefSymbol] = 1;
|
|
888
846
|
defineRefValue(srefFunction, false);
|
|
889
|
-
if (isProxy)
|
|
890
|
-
attachProxyHandle(value);
|
|
847
|
+
if (isProxy) attachProxyHandle(value);
|
|
891
848
|
return srefFunction;
|
|
892
849
|
};
|
|
893
850
|
|
|
@@ -914,14 +871,12 @@ var MountList = class {
|
|
|
914
871
|
}
|
|
915
872
|
__setValueMap(item) {
|
|
916
873
|
const value = this.__getKey(item.value);
|
|
917
|
-
if (value)
|
|
918
|
-
this.__valueMap.set(value, item);
|
|
874
|
+
if (value !== void 0) this.__valueMap.set(value, item);
|
|
919
875
|
}
|
|
920
876
|
__deleteValueMap(index) {
|
|
921
877
|
var _a;
|
|
922
878
|
const value = this.__getKey((_a = this.__list[index]) == null ? void 0 : _a.value);
|
|
923
|
-
if (value)
|
|
924
|
-
this.__valueMap.delete(value);
|
|
879
|
+
if (value !== void 0) this.__valueMap.delete(value);
|
|
925
880
|
}
|
|
926
881
|
/**
|
|
927
882
|
* @internal
|
|
@@ -941,8 +896,7 @@ var MountList = class {
|
|
|
941
896
|
}
|
|
942
897
|
__insertAt(index, item) {
|
|
943
898
|
const len = this.__length;
|
|
944
|
-
for (let i = index; i < len; ++i)
|
|
945
|
-
this.__list[i].order = i + 1;
|
|
899
|
+
for (let i = index; i < len; ++i) this.__list[i].order = i + 1;
|
|
946
900
|
item.order = index;
|
|
947
901
|
this.__list.splice(index, 0, item);
|
|
948
902
|
this.__setValueMap(item);
|
|
@@ -960,13 +914,11 @@ var MountList = class {
|
|
|
960
914
|
this.__deleteValueMap(index);
|
|
961
915
|
this.__list.splice(index, 1);
|
|
962
916
|
const len = this.__length;
|
|
963
|
-
for (let i = index; i < len; ++i)
|
|
964
|
-
this.__list[i].order = i;
|
|
917
|
+
for (let i = index; i < len; ++i) this.__list[i].order = i;
|
|
965
918
|
}
|
|
966
919
|
__removeAllAfter(index) {
|
|
967
920
|
const len = this.__length;
|
|
968
|
-
for (let i = index; i < len; ++i)
|
|
969
|
-
this.__deleteValueMap(i);
|
|
921
|
+
for (let i = index; i < len; ++i) this.__deleteValueMap(i);
|
|
970
922
|
this.__list.splice(index);
|
|
971
923
|
}
|
|
972
924
|
__isValueMounted(value) {
|
|
@@ -1001,8 +953,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1001
953
|
return isForElement;
|
|
1002
954
|
}
|
|
1003
955
|
__isProcessedOrMark(el) {
|
|
1004
|
-
if (el[forMarker])
|
|
1005
|
-
return true;
|
|
956
|
+
if (el[forMarker]) return true;
|
|
1006
957
|
el[forMarker] = true;
|
|
1007
958
|
findElements(el, this.__forSelector).forEach(
|
|
1008
959
|
(x) => x[forMarker] = true
|
|
@@ -1010,8 +961,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1010
961
|
return false;
|
|
1011
962
|
}
|
|
1012
963
|
__bindFor(el) {
|
|
1013
|
-
if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el))
|
|
1014
|
-
return;
|
|
964
|
+
if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el)) return;
|
|
1015
965
|
const forPath = el.getAttribute(this.__for);
|
|
1016
966
|
if (!forPath) {
|
|
1017
967
|
warning(0 /* MissingBindingExpression */, this.__for, el);
|
|
@@ -1021,10 +971,8 @@ var _ForBinder = class _ForBinder {
|
|
|
1021
971
|
this.__bindForToPath(el, forPath);
|
|
1022
972
|
}
|
|
1023
973
|
__getIterable(obj) {
|
|
1024
|
-
if (isNullOrUndefined(obj))
|
|
1025
|
-
|
|
1026
|
-
if (isFunction(obj))
|
|
1027
|
-
obj = obj();
|
|
974
|
+
if (isNullOrUndefined(obj)) return [];
|
|
975
|
+
if (isFunction(obj)) obj = obj();
|
|
1028
976
|
if (Symbol.iterator in Object(obj)) {
|
|
1029
977
|
return obj;
|
|
1030
978
|
}
|
|
@@ -1061,8 +1009,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1061
1009
|
const areEqual = (a, b) => getKey(a) === getKey(b);
|
|
1062
1010
|
const nodes = getNodes(el);
|
|
1063
1011
|
const parent = el.parentNode;
|
|
1064
|
-
if (!parent)
|
|
1065
|
-
return;
|
|
1012
|
+
if (!parent) return;
|
|
1066
1013
|
const title = `${this.__for} => ${forPath}`;
|
|
1067
1014
|
const commentBegin = new Comment(`__begin__ ${title}`);
|
|
1068
1015
|
parent.insertBefore(commentBegin, el);
|
|
@@ -1121,8 +1068,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1121
1068
|
};
|
|
1122
1069
|
const updateDom = (newValues) => {
|
|
1123
1070
|
let len = mountList.__length;
|
|
1124
|
-
if (isFunction(newValues))
|
|
1125
|
-
newValues = newValues();
|
|
1071
|
+
if (isFunction(newValues)) newValues = newValues();
|
|
1126
1072
|
const unrefedNewValue = unref(newValues[0]);
|
|
1127
1073
|
if (isArray(unrefedNewValue) && unrefedNewValue.length === 0) {
|
|
1128
1074
|
unmount(commentBegin, commentEnd);
|
|
@@ -1138,8 +1084,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1138
1084
|
const modify = () => {
|
|
1139
1085
|
if (i2 < len) {
|
|
1140
1086
|
const mountItem = mountList.__get(i2++);
|
|
1141
|
-
if (areEqual(mountItem.value, newValue))
|
|
1142
|
-
return;
|
|
1087
|
+
if (areEqual(mountItem.value, newValue)) return;
|
|
1143
1088
|
const newValueMountPosition = mountList.__lookupValueOrderIfMounted(
|
|
1144
1089
|
getKey(newValue)
|
|
1145
1090
|
);
|
|
@@ -1154,8 +1099,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1154
1099
|
--len;
|
|
1155
1100
|
if (newValueMountPosition > i2 + 1) {
|
|
1156
1101
|
for (let j2 = i2; j2 < newValueMountPosition - 1 && j2 < len; ) {
|
|
1157
|
-
if (areEqual(mountList.__get(i2).value, newValue))
|
|
1158
|
-
break;
|
|
1102
|
+
if (areEqual(mountList.__get(i2).value, newValue)) break;
|
|
1159
1103
|
++j2;
|
|
1160
1104
|
remove(i2);
|
|
1161
1105
|
mountList.__removeAt(i2);
|
|
@@ -1186,8 +1130,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1186
1130
|
}
|
|
1187
1131
|
const j = i2;
|
|
1188
1132
|
len = mountList.__length;
|
|
1189
|
-
while (i2 < len)
|
|
1190
|
-
remove(i2++);
|
|
1133
|
+
while (i2 < len) remove(i2++);
|
|
1191
1134
|
mountList.__removeAllAfter(j);
|
|
1192
1135
|
updateIndexes(firstRemovalOrInsertionIndex);
|
|
1193
1136
|
};
|
|
@@ -1212,16 +1155,13 @@ var _ForBinder = class _ForBinder {
|
|
|
1212
1155
|
__parseForPath(forPath) {
|
|
1213
1156
|
var _a, _b;
|
|
1214
1157
|
const matches = _ForBinder.__forPathRegex.exec(forPath);
|
|
1215
|
-
if (!matches)
|
|
1216
|
-
return;
|
|
1158
|
+
if (!matches) return;
|
|
1217
1159
|
const keys = (matches[1] + ((_a = matches[2]) != null ? _a : "")).split(",").map((key) => key.trim());
|
|
1218
1160
|
const indexOfIndex = keys.length > 1 ? keys.length - 1 : -1;
|
|
1219
1161
|
const index = indexOfIndex !== -1 && (keys[indexOfIndex] === "index" || ((_b = keys[indexOfIndex]) == null ? void 0 : _b.startsWith("#"))) ? keys[indexOfIndex] : "";
|
|
1220
|
-
if (index)
|
|
1221
|
-
keys.splice(indexOfIndex, 1);
|
|
1162
|
+
if (index) keys.splice(indexOfIndex, 1);
|
|
1222
1163
|
const list = matches[3];
|
|
1223
|
-
if (!list || keys.length === 0)
|
|
1224
|
-
return;
|
|
1164
|
+
if (!list || keys.length === 0) return;
|
|
1225
1165
|
const hasDestructuring = /[{[]/.test(forPath);
|
|
1226
1166
|
return {
|
|
1227
1167
|
list,
|
|
@@ -1249,7 +1189,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1249
1189
|
};
|
|
1250
1190
|
}
|
|
1251
1191
|
};
|
|
1252
|
-
__publicField(_ForBinder, "__forPathRegex", /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+(
|
|
1192
|
+
__publicField(_ForBinder, "__forPathRegex", /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+(.*)\s*$/);
|
|
1253
1193
|
var ForBinder = _ForBinder;
|
|
1254
1194
|
|
|
1255
1195
|
// src/bind/DynamicBinder.ts
|
|
@@ -1280,8 +1220,7 @@ var DynamicBinder = class {
|
|
|
1280
1220
|
let expression = el.getAttribute(this.__is);
|
|
1281
1221
|
if (!expression) {
|
|
1282
1222
|
expression = el.getAttribute("is");
|
|
1283
|
-
if (!expression || !expression.startsWith("regor:"))
|
|
1284
|
-
return;
|
|
1223
|
+
if (!expression || !expression.startsWith("regor:")) return;
|
|
1285
1224
|
expression = `'${expression.slice(6)}'`;
|
|
1286
1225
|
el.removeAttribute("is");
|
|
1287
1226
|
}
|
|
@@ -1339,13 +1278,11 @@ var DynamicBinder = class {
|
|
|
1339
1278
|
unmount(commentBegin, commentEnd);
|
|
1340
1279
|
return;
|
|
1341
1280
|
}
|
|
1342
|
-
if (mounted.name === name2)
|
|
1343
|
-
return;
|
|
1281
|
+
if (mounted.name === name2) return;
|
|
1344
1282
|
unmount(commentBegin, commentEnd);
|
|
1345
1283
|
const componentElement = document.createElement(name2);
|
|
1346
1284
|
for (const attr of el.getAttributeNames()) {
|
|
1347
|
-
if (attr === this.__is)
|
|
1348
|
-
continue;
|
|
1285
|
+
if (attr === this.__is) continue;
|
|
1349
1286
|
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1350
1287
|
}
|
|
1351
1288
|
mount2(componentChildNodes, componentElement);
|
|
@@ -1386,8 +1323,7 @@ var propsDirective = {
|
|
|
1386
1323
|
const key = item[0];
|
|
1387
1324
|
const value2 = item[1];
|
|
1388
1325
|
const ctxKey = ctx[key];
|
|
1389
|
-
if (ctxKey === value2)
|
|
1390
|
-
continue;
|
|
1326
|
+
if (ctxKey === value2) continue;
|
|
1391
1327
|
if (isRef(ctxKey)) {
|
|
1392
1328
|
ctxKey(value2);
|
|
1393
1329
|
} else {
|
|
@@ -1417,8 +1353,7 @@ var propsOnceDirective = {
|
|
|
1417
1353
|
const key = item[0];
|
|
1418
1354
|
const value2 = item[1];
|
|
1419
1355
|
const ctxKey = ctx[key];
|
|
1420
|
-
if (ctxKey === value2)
|
|
1421
|
-
continue;
|
|
1356
|
+
if (ctxKey === value2) continue;
|
|
1422
1357
|
if (isRef(ctxKey)) {
|
|
1423
1358
|
ctxKey(value2);
|
|
1424
1359
|
} else {
|
|
@@ -1507,16 +1442,14 @@ var useScope = (context) => {
|
|
|
1507
1442
|
}
|
|
1508
1443
|
};
|
|
1509
1444
|
var isScope = (value) => {
|
|
1510
|
-
if (!isObject(value))
|
|
1511
|
-
return false;
|
|
1445
|
+
if (!isObject(value)) return false;
|
|
1512
1446
|
return scopeSymbol2 in value;
|
|
1513
1447
|
};
|
|
1514
1448
|
|
|
1515
1449
|
// src/reactivity/entangle.ts
|
|
1516
1450
|
var entangle = (r1, r2) => {
|
|
1517
|
-
if (r1 === r2)
|
|
1518
|
-
|
|
1519
|
-
};
|
|
1451
|
+
if (r1 === r2) return () => {
|
|
1452
|
+
};
|
|
1520
1453
|
const stop1 = observe(r1, (v) => r2(v));
|
|
1521
1454
|
const stop2 = observe(r2, (v) => r1(v));
|
|
1522
1455
|
r2(r1());
|
|
@@ -1540,9 +1473,8 @@ var callMounted = (context) => {
|
|
|
1540
1473
|
var singlePropDirective = {
|
|
1541
1474
|
collectRefObj: true,
|
|
1542
1475
|
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
1543
|
-
if (!option)
|
|
1544
|
-
|
|
1545
|
-
};
|
|
1476
|
+
if (!option) return () => {
|
|
1477
|
+
};
|
|
1546
1478
|
const key = camelize(option);
|
|
1547
1479
|
const stopObserving = observe(
|
|
1548
1480
|
parseResult.value,
|
|
@@ -1551,8 +1483,7 @@ var singlePropDirective = {
|
|
|
1551
1483
|
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
1552
1484
|
const ctx = parseResult.context;
|
|
1553
1485
|
const ctxKey = ctx[option];
|
|
1554
|
-
if (ctxKey === value)
|
|
1555
|
-
return;
|
|
1486
|
+
if (ctxKey === value) return;
|
|
1556
1487
|
if (isRef(ctxKey)) {
|
|
1557
1488
|
ctxKey(value);
|
|
1558
1489
|
} else {
|
|
@@ -1589,28 +1520,22 @@ var ComponentBinder = class {
|
|
|
1589
1520
|
...[...registeredComponents.keys()].map(hyphenate),
|
|
1590
1521
|
...[...Object.keys(contextComponents)].map(hyphenate)
|
|
1591
1522
|
].join(",");
|
|
1592
|
-
if (isNullOrWhitespace(selector))
|
|
1593
|
-
return;
|
|
1523
|
+
if (isNullOrWhitespace(selector)) return;
|
|
1594
1524
|
const list = element.querySelectorAll(selector);
|
|
1595
1525
|
const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
|
|
1596
1526
|
for (const component of components) {
|
|
1597
|
-
if (component.hasAttribute(binder.__pre))
|
|
1598
|
-
continue;
|
|
1527
|
+
if (component.hasAttribute(binder.__pre)) continue;
|
|
1599
1528
|
const parent = component.parentNode;
|
|
1600
|
-
if (!parent)
|
|
1601
|
-
continue;
|
|
1529
|
+
if (!parent) continue;
|
|
1602
1530
|
const nextSibling = component.nextSibling;
|
|
1603
1531
|
const tagName = camelize(component.tagName).toUpperCase();
|
|
1604
1532
|
const contextComponent = contextComponents[tagName];
|
|
1605
1533
|
const registeredComponent = contextComponent != null ? contextComponent : registeredComponentsUpperCase.get(tagName);
|
|
1606
|
-
if (!registeredComponent)
|
|
1607
|
-
continue;
|
|
1534
|
+
if (!registeredComponent) continue;
|
|
1608
1535
|
const templateElement = registeredComponent.template;
|
|
1609
|
-
if (!templateElement)
|
|
1610
|
-
continue;
|
|
1536
|
+
if (!templateElement) continue;
|
|
1611
1537
|
const componentParent = component.parentElement;
|
|
1612
|
-
if (!componentParent)
|
|
1613
|
-
continue;
|
|
1538
|
+
if (!componentParent) continue;
|
|
1614
1539
|
const startOfComponent = new Comment(
|
|
1615
1540
|
" begin component: " + component.tagName
|
|
1616
1541
|
);
|
|
@@ -1626,30 +1551,24 @@ var ComponentBinder = class {
|
|
|
1626
1551
|
const hasPropsOnce = component2.hasAttribute(propsOnceName);
|
|
1627
1552
|
parser.__scoped(capturedContext2, () => {
|
|
1628
1553
|
parser.__push(props);
|
|
1629
|
-
if (hasProps)
|
|
1630
|
-
binder.__bind(propsDirective, component2, propsName);
|
|
1554
|
+
if (hasProps) binder.__bind(propsDirective, component2, propsName);
|
|
1631
1555
|
if (hasPropsOnce)
|
|
1632
1556
|
binder.__bind(propsOnceDirective, component2, propsOnceName);
|
|
1633
1557
|
let definedProps = registeredComponent.props;
|
|
1634
|
-
if (!definedProps || definedProps.length === 0)
|
|
1635
|
-
return;
|
|
1558
|
+
if (!definedProps || definedProps.length === 0) return;
|
|
1636
1559
|
definedProps = definedProps.map(camelize);
|
|
1637
1560
|
for (const name2 of definedProps.concat(definedProps.map(hyphenate))) {
|
|
1638
1561
|
const value = component2.getAttribute(name2);
|
|
1639
|
-
if (value === null)
|
|
1640
|
-
continue;
|
|
1562
|
+
if (value === null) continue;
|
|
1641
1563
|
props[camelize(name2)] = value;
|
|
1642
1564
|
component2.removeAttribute(name2);
|
|
1643
1565
|
}
|
|
1644
1566
|
const map = binder.__directiveCollector.__collect(component2, false);
|
|
1645
1567
|
for (const [attrName, item] of map.entries()) {
|
|
1646
1568
|
const [name2, option] = item.__terms;
|
|
1647
|
-
if (!option)
|
|
1648
|
-
|
|
1649
|
-
if (
|
|
1650
|
-
continue;
|
|
1651
|
-
if (name2 !== "." && name2 !== ":" && name2 !== bindName)
|
|
1652
|
-
continue;
|
|
1569
|
+
if (!option) continue;
|
|
1570
|
+
if (!definedProps.includes(camelize(option))) continue;
|
|
1571
|
+
if (name2 !== "." && name2 !== ":" && name2 !== bindName) continue;
|
|
1653
1572
|
binder.__bind(
|
|
1654
1573
|
singlePropDirective,
|
|
1655
1574
|
component2,
|
|
@@ -1681,16 +1600,13 @@ var ComponentBinder = class {
|
|
|
1681
1600
|
for (const [key, propsValue] of Object.entries(props)) {
|
|
1682
1601
|
if (key in componentCtx2) {
|
|
1683
1602
|
const compValue = componentCtx2[key];
|
|
1684
|
-
if (compValue === propsValue)
|
|
1685
|
-
continue;
|
|
1603
|
+
if (compValue === propsValue) continue;
|
|
1686
1604
|
if (head2.entangle && isRef(compValue) && isRef(propsValue)) {
|
|
1687
1605
|
addUnbinder(startOfComponent, entangle(propsValue, compValue));
|
|
1688
1606
|
} else if (isRef(compValue)) {
|
|
1689
1607
|
compValue(propsValue);
|
|
1690
|
-
} else
|
|
1691
|
-
|
|
1692
|
-
} else
|
|
1693
|
-
componentCtx2[key] = propsValue;
|
|
1608
|
+
} else componentCtx2[key] = unref(propsValue);
|
|
1609
|
+
} else componentCtx2[key] = propsValue;
|
|
1694
1610
|
}
|
|
1695
1611
|
(_a2 = head2.onAutoPropsAssigned) == null ? void 0 : _a2.call(head2);
|
|
1696
1612
|
}
|
|
@@ -1713,8 +1629,7 @@ var ComponentBinder = class {
|
|
|
1713
1629
|
name2 = slot.getAttributeNames().filter((x) => x.startsWith("#"))[0];
|
|
1714
1630
|
if (isNullOrWhitespace(name2)) {
|
|
1715
1631
|
name2 = "default";
|
|
1716
|
-
} else
|
|
1717
|
-
name2 = name2.substring(1);
|
|
1632
|
+
} else name2 = name2.substring(1);
|
|
1718
1633
|
}
|
|
1719
1634
|
let compTemplate = component.querySelector(
|
|
1720
1635
|
`template[name='${name2}'], template[\\#${name2}]`
|
|
@@ -1725,8 +1640,7 @@ var ComponentBinder = class {
|
|
|
1725
1640
|
compTemplate = null;
|
|
1726
1641
|
}
|
|
1727
1642
|
const createSwitchContext = (childNodes2) => {
|
|
1728
|
-
if (head.disableSwitch)
|
|
1729
|
-
return;
|
|
1643
|
+
if (head.disableSwitch) return;
|
|
1730
1644
|
parser.__scoped(capturedContext, () => {
|
|
1731
1645
|
parser.__push(componentCtx);
|
|
1732
1646
|
const props = getProps(slot, parser.__capture());
|
|
@@ -1735,8 +1649,7 @@ var ComponentBinder = class {
|
|
|
1735
1649
|
const switchContext = parser.__capture();
|
|
1736
1650
|
const id = addSwitch(switchContext);
|
|
1737
1651
|
for (const child of childNodes2) {
|
|
1738
|
-
if (!isElement(child))
|
|
1739
|
-
continue;
|
|
1652
|
+
if (!isElement(child)) continue;
|
|
1740
1653
|
child.setAttribute(rswitch, id);
|
|
1741
1654
|
refSwitch(id);
|
|
1742
1655
|
addUnbinder(child, () => {
|
|
@@ -1769,8 +1682,7 @@ var ComponentBinder = class {
|
|
|
1769
1682
|
}
|
|
1770
1683
|
};
|
|
1771
1684
|
const expandNestedSlots = (node) => {
|
|
1772
|
-
if (!isElement(node))
|
|
1773
|
-
return;
|
|
1685
|
+
if (!isElement(node)) return;
|
|
1774
1686
|
const slots = node.querySelectorAll("slot");
|
|
1775
1687
|
if (isSlot(node)) {
|
|
1776
1688
|
expandSlot(node);
|
|
@@ -1792,8 +1704,7 @@ var ComponentBinder = class {
|
|
|
1792
1704
|
expandSlots();
|
|
1793
1705
|
componentParent.insertBefore(endOfComponent, nextSibling);
|
|
1794
1706
|
const transferAttributesToTheComponentChild = () => {
|
|
1795
|
-
if (!registeredComponent.inheritAttrs)
|
|
1796
|
-
return;
|
|
1707
|
+
if (!registeredComponent.inheritAttrs) return;
|
|
1797
1708
|
let inheritorChildNodes = childNodes.filter(
|
|
1798
1709
|
(x) => x.nodeType === Node.ELEMENT_NODE
|
|
1799
1710
|
);
|
|
@@ -1802,11 +1713,9 @@ var ComponentBinder = class {
|
|
|
1802
1713
|
(x) => x.hasAttribute(this.__inherit)
|
|
1803
1714
|
);
|
|
1804
1715
|
const inheritor = inheritorChildNodes[0];
|
|
1805
|
-
if (!inheritor)
|
|
1806
|
-
return;
|
|
1716
|
+
if (!inheritor) return;
|
|
1807
1717
|
for (const attrName of component.getAttributeNames()) {
|
|
1808
|
-
if (attrName === propsName || attrName === propsOnceName)
|
|
1809
|
-
continue;
|
|
1718
|
+
if (attrName === propsName || attrName === propsOnceName) continue;
|
|
1810
1719
|
const value = component.getAttribute(attrName);
|
|
1811
1720
|
if (attrName === "class") {
|
|
1812
1721
|
inheritor.classList.add(...value.split(" "));
|
|
@@ -1866,12 +1775,10 @@ var DirectiveElement = class {
|
|
|
1866
1775
|
__parse() {
|
|
1867
1776
|
let name2 = this.__name;
|
|
1868
1777
|
const isPropShortcut = name2.startsWith(".");
|
|
1869
|
-
if (isPropShortcut)
|
|
1870
|
-
name2 = ":" + name2.slice(1);
|
|
1778
|
+
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1871
1779
|
const firstFlagIndex = name2.indexOf(".");
|
|
1872
1780
|
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1873
|
-
if (isNullOrWhitespace(terms[0]))
|
|
1874
|
-
terms[0] = isPropShortcut ? "." : name2[0];
|
|
1781
|
+
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1875
1782
|
if (firstFlagIndex >= 0) {
|
|
1876
1783
|
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1877
1784
|
if (flags.includes("camel")) {
|
|
@@ -1893,21 +1800,18 @@ var DirectiveCollector = class {
|
|
|
1893
1800
|
}
|
|
1894
1801
|
__collect(element, isRecursive) {
|
|
1895
1802
|
const map = /* @__PURE__ */ new Map();
|
|
1896
|
-
if (!isHTMLElement(element))
|
|
1897
|
-
return map;
|
|
1803
|
+
if (!isHTMLElement(element)) return map;
|
|
1898
1804
|
const prefixes2 = this.__prefixes;
|
|
1899
1805
|
const processNode = (node) => {
|
|
1900
1806
|
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1901
1807
|
for (const name2 of names) {
|
|
1902
|
-
if (!map.has(name2))
|
|
1903
|
-
map.set(name2, new DirectiveElement(name2));
|
|
1808
|
+
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1904
1809
|
const item = map.get(name2);
|
|
1905
1810
|
item.__elements.push(node);
|
|
1906
1811
|
}
|
|
1907
1812
|
};
|
|
1908
1813
|
processNode(element);
|
|
1909
|
-
if (!isRecursive)
|
|
1910
|
-
return map;
|
|
1814
|
+
if (!isRecursive) return map;
|
|
1911
1815
|
const nodes = element.querySelectorAll("*");
|
|
1912
1816
|
for (const node of nodes) {
|
|
1913
1817
|
processNode(node);
|
|
@@ -1944,15 +1848,12 @@ var Binder = class {
|
|
|
1944
1848
|
__unwrapTemplates(element) {
|
|
1945
1849
|
const templates = isTemplate(element) ? [element] : element.querySelectorAll("template");
|
|
1946
1850
|
for (const template of templates) {
|
|
1947
|
-
if (template.hasAttribute(this.__pre))
|
|
1948
|
-
continue;
|
|
1851
|
+
if (template.hasAttribute(this.__pre)) continue;
|
|
1949
1852
|
const parent = template.parentNode;
|
|
1950
|
-
if (!parent)
|
|
1951
|
-
continue;
|
|
1853
|
+
if (!parent) continue;
|
|
1952
1854
|
const nextSibling = template.nextSibling;
|
|
1953
1855
|
template.remove();
|
|
1954
|
-
if (!template.content)
|
|
1955
|
-
continue;
|
|
1856
|
+
if (!template.content) continue;
|
|
1956
1857
|
const childNodes = [...template.content.childNodes];
|
|
1957
1858
|
for (const child of childNodes) {
|
|
1958
1859
|
parent.insertBefore(child, nextSibling);
|
|
@@ -1963,12 +1864,9 @@ var Binder = class {
|
|
|
1963
1864
|
__bindDefault(element) {
|
|
1964
1865
|
if (element.nodeType !== Node.ELEMENT_NODE || element.hasAttribute(this.__pre))
|
|
1965
1866
|
return;
|
|
1966
|
-
if (this.__ifBinder.__bindAll(element))
|
|
1967
|
-
|
|
1968
|
-
if (this.
|
|
1969
|
-
return;
|
|
1970
|
-
if (this.__dynamicBinder.__bindAll(element))
|
|
1971
|
-
return;
|
|
1867
|
+
if (this.__ifBinder.__bindAll(element)) return;
|
|
1868
|
+
if (this.__forBinder.__bindAll(element)) return;
|
|
1869
|
+
if (this.__dynamicBinder.__bindAll(element)) return;
|
|
1972
1870
|
this.__componentBinder.__bindAll(element);
|
|
1973
1871
|
this.__unwrapTemplates(element);
|
|
1974
1872
|
this.__bindAttributes(element, true);
|
|
@@ -1990,16 +1888,13 @@ var Binder = class {
|
|
|
1990
1888
|
}
|
|
1991
1889
|
}
|
|
1992
1890
|
__bind(config, el, attribute, _noWarning, option, flags) {
|
|
1993
|
-
if (el.hasAttribute(this.__pre))
|
|
1994
|
-
return;
|
|
1891
|
+
if (el.hasAttribute(this.__pre)) return;
|
|
1995
1892
|
const bindExpression = el.getAttribute(attribute);
|
|
1996
1893
|
el.removeAttribute(attribute);
|
|
1997
1894
|
const getParentSwitch = (el2) => {
|
|
1998
1895
|
const switchId = el2.getAttribute(rswitch);
|
|
1999
|
-
if (switchId)
|
|
2000
|
-
|
|
2001
|
-
if (!el2.parentElement)
|
|
2002
|
-
return null;
|
|
1896
|
+
if (switchId) return switchId;
|
|
1897
|
+
if (!el2.parentElement) return null;
|
|
2003
1898
|
return getParentSwitch(el2.parentElement);
|
|
2004
1899
|
};
|
|
2005
1900
|
if (hasSwitch()) {
|
|
@@ -2014,15 +1909,12 @@ var Binder = class {
|
|
|
2014
1909
|
this.__bindToExpression(config, el, bindExpression, option, flags);
|
|
2015
1910
|
}
|
|
2016
1911
|
__handleTeleport(config, el, valueExpression) {
|
|
2017
|
-
if (config !== teleportDirective)
|
|
2018
|
-
|
|
2019
|
-
if (isNullOrWhitespace(valueExpression))
|
|
2020
|
-
return true;
|
|
1912
|
+
if (config !== teleportDirective) return false;
|
|
1913
|
+
if (isNullOrWhitespace(valueExpression)) return true;
|
|
2021
1914
|
const teleportTo = document.querySelector(valueExpression);
|
|
2022
1915
|
if (teleportTo) {
|
|
2023
1916
|
const parent = el.parentElement;
|
|
2024
|
-
if (!parent)
|
|
2025
|
-
return true;
|
|
1917
|
+
if (!parent) return true;
|
|
2026
1918
|
const placeholder = new Comment(`teleported => '${valueExpression}'`);
|
|
2027
1919
|
parent.insertBefore(placeholder, el);
|
|
2028
1920
|
el.teleportedFrom = placeholder;
|
|
@@ -2036,10 +1928,8 @@ var Binder = class {
|
|
|
2036
1928
|
}
|
|
2037
1929
|
__bindToExpression(config, el, valueExpression, option, flags) {
|
|
2038
1930
|
var _a;
|
|
2039
|
-
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null)
|
|
2040
|
-
|
|
2041
|
-
if (this.__handleTeleport(config, el, valueExpression))
|
|
2042
|
-
return;
|
|
1931
|
+
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null) return;
|
|
1932
|
+
if (this.__handleTeleport(config, el, valueExpression)) return;
|
|
2043
1933
|
const result = this.__parser.__parse(
|
|
2044
1934
|
valueExpression,
|
|
2045
1935
|
config.isLazy,
|
|
@@ -2083,8 +1973,7 @@ var Binder = class {
|
|
|
2083
1973
|
return previousOption;
|
|
2084
1974
|
};
|
|
2085
1975
|
const observeTailChanges = () => {
|
|
2086
|
-
if (!config.onChange)
|
|
2087
|
-
return;
|
|
1976
|
+
if (!config.onChange) return;
|
|
2088
1977
|
const stopObserving = observe(result.value, (_) => {
|
|
2089
1978
|
var _a2;
|
|
2090
1979
|
const pre = previousValues;
|
|
@@ -2101,8 +1990,7 @@ var Binder = class {
|
|
|
2101
1990
|
stopObserverList.push(stopObserving2);
|
|
2102
1991
|
}
|
|
2103
1992
|
};
|
|
2104
|
-
if (!config.once)
|
|
2105
|
-
observeTailChanges();
|
|
1993
|
+
if (!config.once) observeTailChanges();
|
|
2106
1994
|
if (config.onBind)
|
|
2107
1995
|
stopObserverList.push(
|
|
2108
1996
|
config.onBind(
|
|
@@ -2292,8 +2180,7 @@ var Jsep = class {
|
|
|
2292
2180
|
}
|
|
2293
2181
|
__runHook(hookType, hookCalltype, node) {
|
|
2294
2182
|
const hook = this.__hooks[hookType];
|
|
2295
|
-
if (!hook)
|
|
2296
|
-
return node;
|
|
2183
|
+
if (!hook) return node;
|
|
2297
2184
|
const env = { node };
|
|
2298
2185
|
const hookFn = (f) => {
|
|
2299
2186
|
f.call(this, env);
|
|
@@ -2312,8 +2199,7 @@ var Jsep = class {
|
|
|
2312
2199
|
}
|
|
2313
2200
|
parse() {
|
|
2314
2201
|
const nodes = this.__gobbleExpressions();
|
|
2315
|
-
if (nodes.length === 1)
|
|
2316
|
-
return nodes[0];
|
|
2202
|
+
if (nodes.length === 1) return nodes[0];
|
|
2317
2203
|
return {
|
|
2318
2204
|
type: 0 /* Compound */,
|
|
2319
2205
|
body: nodes
|
|
@@ -2929,8 +2815,7 @@ var Jsep = class {
|
|
|
2929
2815
|
this.__updateBinariesToArrows(env.node);
|
|
2930
2816
|
}
|
|
2931
2817
|
__updateBinariesToArrows(node) {
|
|
2932
|
-
if (!node)
|
|
2933
|
-
return;
|
|
2818
|
+
if (!node) return;
|
|
2934
2819
|
Object.values(node).forEach((val) => {
|
|
2935
2820
|
if (val && typeof val === "object") {
|
|
2936
2821
|
this.__updateBinariesToArrows(val);
|
|
@@ -2949,8 +2834,7 @@ var Jsep = class {
|
|
|
2949
2834
|
}
|
|
2950
2835
|
}
|
|
2951
2836
|
__fixAssignmentOperators(env) {
|
|
2952
|
-
if (env.node)
|
|
2953
|
-
this.__updateBinariesToAssignments(env.node);
|
|
2837
|
+
if (env.node) this.__updateBinariesToAssignments(env.node);
|
|
2954
2838
|
}
|
|
2955
2839
|
__updateBinariesToAssignments(node) {
|
|
2956
2840
|
if (assigmentOperatorsSet.has(node.operator)) {
|
|
@@ -2966,12 +2850,10 @@ var Jsep = class {
|
|
|
2966
2850
|
}
|
|
2967
2851
|
}
|
|
2968
2852
|
__gobbleTaggedTemplateIdentifier(env) {
|
|
2969
|
-
if (!env.node)
|
|
2970
|
-
return;
|
|
2853
|
+
if (!env.node) return;
|
|
2971
2854
|
const type = env.node.type;
|
|
2972
2855
|
const condition = (type === 2 /* Identifier */ || type === 3 /* Member */) && this.__isCode(BTICK_CODE);
|
|
2973
|
-
if (!condition)
|
|
2974
|
-
return;
|
|
2856
|
+
if (!condition) return;
|
|
2975
2857
|
env.node = {
|
|
2976
2858
|
type: 17 /* TaggedTemplateExpression */,
|
|
2977
2859
|
tag: env.node,
|
|
@@ -2979,8 +2861,7 @@ var Jsep = class {
|
|
|
2979
2861
|
};
|
|
2980
2862
|
}
|
|
2981
2863
|
__gobbleTemplateLiteral(env) {
|
|
2982
|
-
if (!this.__isCode(BTICK_CODE))
|
|
2983
|
-
return;
|
|
2864
|
+
if (!this.__isCode(BTICK_CODE)) return;
|
|
2984
2865
|
const node = {
|
|
2985
2866
|
type: 19 /* TemplateLiteral */,
|
|
2986
2867
|
quasis: [],
|
|
@@ -3051,8 +2932,7 @@ var Jsep = class {
|
|
|
3051
2932
|
__gobbleNew(env) {
|
|
3052
2933
|
var _a;
|
|
3053
2934
|
const node = env.node;
|
|
3054
|
-
if (!node || node.operator !== "new" || !node.argument)
|
|
3055
|
-
return;
|
|
2935
|
+
if (!node || node.operator !== "new" || !node.argument) return;
|
|
3056
2936
|
if (!node.argument || ![6 /* Call */, 3 /* Member */].includes(node.argument.type))
|
|
3057
2937
|
throw this.__getError("Expected new function()");
|
|
3058
2938
|
env.node = node.argument;
|
|
@@ -3063,8 +2943,7 @@ var Jsep = class {
|
|
|
3063
2943
|
callNode.type = 20 /* NewExpression */;
|
|
3064
2944
|
}
|
|
3065
2945
|
__gobbleRegexLiteral(env) {
|
|
3066
|
-
if (!this.__isCode(FSLASH_CODE))
|
|
3067
|
-
return;
|
|
2946
|
+
if (!this.__isCode(FSLASH_CODE)) return;
|
|
3068
2947
|
const patternIndex = ++this.__index;
|
|
3069
2948
|
let inCharSet = false;
|
|
3070
2949
|
while (this.__index < this.__expr.length) {
|
|
@@ -3165,8 +3044,7 @@ var evalUnaryOp = {
|
|
|
3165
3044
|
// placed here for type safety, never executed,
|
|
3166
3045
|
};
|
|
3167
3046
|
var spreadArgs = (args) => {
|
|
3168
|
-
if (!(args == null ? void 0 : args.some(shouldSpreadArray)))
|
|
3169
|
-
return args;
|
|
3047
|
+
if (!(args == null ? void 0 : args.some(shouldSpreadArray))) return args;
|
|
3170
3048
|
const result = [];
|
|
3171
3049
|
args.forEach(
|
|
3172
3050
|
(x) => shouldSpreadArray(x) ? result.push(...x) : result.push(x)
|
|
@@ -3175,8 +3053,7 @@ var spreadArgs = (args) => {
|
|
|
3175
3053
|
};
|
|
3176
3054
|
var arrayEvaluator = (...args) => spreadArgs(args);
|
|
3177
3055
|
var createLazyContext = (e, context) => {
|
|
3178
|
-
if (!e)
|
|
3179
|
-
return context;
|
|
3056
|
+
if (!e) return context;
|
|
3180
3057
|
const ctx = Object.create(context != null ? context : {});
|
|
3181
3058
|
ctx.$event = e;
|
|
3182
3059
|
return ctx;
|
|
@@ -3331,22 +3208,17 @@ var RegorEval = class {
|
|
|
3331
3208
|
this.__collectRefObj = !!collectRefObj;
|
|
3332
3209
|
}
|
|
3333
3210
|
__findContext(name2, context) {
|
|
3334
|
-
if (context && name2 in context)
|
|
3335
|
-
return context;
|
|
3211
|
+
if (context && name2 in context) return context;
|
|
3336
3212
|
for (const ctx of this.__contexts) {
|
|
3337
|
-
if (name2 in ctx)
|
|
3338
|
-
return ctx;
|
|
3213
|
+
if (name2 in ctx) return ctx;
|
|
3339
3214
|
}
|
|
3340
3215
|
return void 0;
|
|
3341
3216
|
}
|
|
3342
3217
|
[2 /* Identifier */](expr, _, context) {
|
|
3343
3218
|
const name2 = expr.name;
|
|
3344
|
-
if (name2 === "$root")
|
|
3345
|
-
|
|
3346
|
-
if (name2 === "$
|
|
3347
|
-
return this.__contexts[1];
|
|
3348
|
-
if (name2 === "$ctx")
|
|
3349
|
-
return [...this.__contexts];
|
|
3219
|
+
if (name2 === "$root") return this.__contexts[this.__contexts.length - 1];
|
|
3220
|
+
if (name2 === "$parent") return this.__contexts[1];
|
|
3221
|
+
if (name2 === "$ctx") return [...this.__contexts];
|
|
3350
3222
|
if (context && name2 in context) {
|
|
3351
3223
|
this.__lastEvaluatedValueBeforeUnref = context[name2];
|
|
3352
3224
|
return associateThis(unref(context[name2]), context);
|
|
@@ -3488,8 +3360,7 @@ var RegorEval = class {
|
|
|
3488
3360
|
if (arg.type === 2 /* Identifier */) {
|
|
3489
3361
|
const name2 = arg.name;
|
|
3490
3362
|
const ctx = this.__findContext(name2, context);
|
|
3491
|
-
if (isNullOrUndefined(ctx))
|
|
3492
|
-
return void 0;
|
|
3363
|
+
if (isNullOrUndefined(ctx)) return void 0;
|
|
3493
3364
|
return updater[op](ctx, name2);
|
|
3494
3365
|
}
|
|
3495
3366
|
if (arg.type === 3 /* Member */) {
|
|
@@ -3507,8 +3378,7 @@ var RegorEval = class {
|
|
|
3507
3378
|
if (arg.type === 2 /* Identifier */) {
|
|
3508
3379
|
const name2 = arg.name;
|
|
3509
3380
|
const ctx = this.__findContext(name2, context);
|
|
3510
|
-
if (isNullOrUndefined(ctx))
|
|
3511
|
-
return void 0;
|
|
3381
|
+
if (isNullOrUndefined(ctx)) return void 0;
|
|
3512
3382
|
const value = this.__eval(expr.right, depth, context);
|
|
3513
3383
|
return applyAssigment[op](ctx, name2, value);
|
|
3514
3384
|
}
|
|
@@ -3524,8 +3394,7 @@ var RegorEval = class {
|
|
|
3524
3394
|
}
|
|
3525
3395
|
[14 /* Spread */](expr, depth, context) {
|
|
3526
3396
|
const spreaded = this.__eval(expr.argument, depth, context);
|
|
3527
|
-
if (isArray(spreaded))
|
|
3528
|
-
spreaded.s = spreadElementSymbol;
|
|
3397
|
+
if (isArray(spreaded)) spreaded.s = spreadElementSymbol;
|
|
3529
3398
|
return spreaded;
|
|
3530
3399
|
}
|
|
3531
3400
|
[17 /* TaggedTemplateExpression */](expr, depth, context) {
|
|
@@ -3613,8 +3482,7 @@ var RegorEval = class {
|
|
|
3613
3482
|
}
|
|
3614
3483
|
__transformLazy(depth, context, evaluator, ...args) {
|
|
3615
3484
|
const isLazy = this.__isLazy;
|
|
3616
|
-
if (!isLazy)
|
|
3617
|
-
return this.__transform(depth, context, evaluator, ...args);
|
|
3485
|
+
if (!isLazy) return this.__transform(depth, context, evaluator, ...args);
|
|
3618
3486
|
const evaluatedArgs = args.map(
|
|
3619
3487
|
(arg, i) => arg && (arg.type !== 15 /* Arrow */ && isLazy(i, depth) ? (e) => this.__eval(arg, depth, createLazyContext(e, context)) : this.__eval(arg, depth, context))
|
|
3620
3488
|
);
|
|
@@ -3666,8 +3534,7 @@ var Parser = class {
|
|
|
3666
3534
|
refs: [],
|
|
3667
3535
|
context: this.__contexts[0]
|
|
3668
3536
|
};
|
|
3669
|
-
if (isNullOrWhitespace(expression))
|
|
3670
|
-
return result;
|
|
3537
|
+
if (isNullOrWhitespace(expression)) return result;
|
|
3671
3538
|
const globalContext = this.__config.globalContext;
|
|
3672
3539
|
const refs = [];
|
|
3673
3540
|
const evaluate = (expr, contexts, collectRefs2, context) => {
|
|
@@ -3776,8 +3643,7 @@ var attrDirective = {
|
|
|
3776
3643
|
onChange: (el, values, previousValues, option, previousOption, flags) => {
|
|
3777
3644
|
var _a;
|
|
3778
3645
|
if (option) {
|
|
3779
|
-
if (flags && flags.includes("camel"))
|
|
3780
|
-
option = camelize(option);
|
|
3646
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3781
3647
|
patchAttribute(el, option, values[0], previousOption);
|
|
3782
3648
|
return;
|
|
3783
3649
|
}
|
|
@@ -3863,25 +3729,22 @@ var patchClass = (el, next, prev) => {
|
|
|
3863
3729
|
if (next && !isClassString) {
|
|
3864
3730
|
if (prev && !isPrevClassString) {
|
|
3865
3731
|
for (const key in prev) {
|
|
3866
|
-
if (!(key in next)) {
|
|
3732
|
+
if (!(key in next) || !next[key]) {
|
|
3867
3733
|
classList.remove(key);
|
|
3868
3734
|
}
|
|
3869
3735
|
}
|
|
3870
3736
|
}
|
|
3871
3737
|
for (const key in next) {
|
|
3872
|
-
if (next[key])
|
|
3873
|
-
classList.add(key);
|
|
3738
|
+
if (next[key]) classList.add(key);
|
|
3874
3739
|
}
|
|
3875
3740
|
} else {
|
|
3876
3741
|
if (isClassString) {
|
|
3877
3742
|
if (prev !== next) {
|
|
3878
|
-
if (isPrevClassString)
|
|
3879
|
-
classList.remove(...prev == null ? void 0 : prev.split(","));
|
|
3743
|
+
if (isPrevClassString) classList.remove(...prev == null ? void 0 : prev.split(","));
|
|
3880
3744
|
classList.add(...next.split(","));
|
|
3881
3745
|
}
|
|
3882
3746
|
} else if (prev) {
|
|
3883
|
-
if (isPrevClassString)
|
|
3884
|
-
classList.remove(...prev == null ? void 0 : prev.split(","));
|
|
3747
|
+
if (isPrevClassString) classList.remove(...prev == null ? void 0 : prev.split(","));
|
|
3885
3748
|
}
|
|
3886
3749
|
}
|
|
3887
3750
|
};
|
|
@@ -3890,17 +3753,14 @@ var patchClass = (el, next, prev) => {
|
|
|
3890
3753
|
var htmlDirective = {
|
|
3891
3754
|
onChange: (el, values) => {
|
|
3892
3755
|
const [value, replacer] = values;
|
|
3893
|
-
if (isFunction(replacer))
|
|
3894
|
-
|
|
3895
|
-
else
|
|
3896
|
-
el.innerHTML = value == null ? void 0 : value.toString();
|
|
3756
|
+
if (isFunction(replacer)) replacer(el, value);
|
|
3757
|
+
else el.innerHTML = value == null ? void 0 : value.toString();
|
|
3897
3758
|
}
|
|
3898
3759
|
};
|
|
3899
3760
|
|
|
3900
3761
|
// src/common/looseEqual.ts
|
|
3901
3762
|
function looseCompareArrays(a, b) {
|
|
3902
|
-
if (a.length !== b.length)
|
|
3903
|
-
return false;
|
|
3763
|
+
if (a.length !== b.length) return false;
|
|
3904
3764
|
let equal = true;
|
|
3905
3765
|
for (let i = 0; equal && i < a.length; i++) {
|
|
3906
3766
|
equal = looseEqual(a[i], b[i]);
|
|
@@ -3908,8 +3768,7 @@ function looseCompareArrays(a, b) {
|
|
|
3908
3768
|
return equal;
|
|
3909
3769
|
}
|
|
3910
3770
|
function looseEqual(a, b) {
|
|
3911
|
-
if (a === b)
|
|
3912
|
-
return true;
|
|
3771
|
+
if (a === b) return true;
|
|
3913
3772
|
let aValidType = isDate(a);
|
|
3914
3773
|
let bValidType = isDate(b);
|
|
3915
3774
|
if (aValidType || bValidType) {
|
|
@@ -4015,8 +3874,7 @@ var updateDomElementValue = (el, value) => {
|
|
|
4015
3874
|
}
|
|
4016
3875
|
} else {
|
|
4017
3876
|
if (looseEqual(getValue(option), value)) {
|
|
4018
|
-
if (el.selectedIndex !== i)
|
|
4019
|
-
el.selectedIndex = i;
|
|
3877
|
+
if (el.selectedIndex !== i) el.selectedIndex = i;
|
|
4020
3878
|
return;
|
|
4021
3879
|
}
|
|
4022
3880
|
}
|
|
@@ -4029,10 +3887,8 @@ var updateDomElementValue = (el, value) => {
|
|
|
4029
3887
|
}
|
|
4030
3888
|
};
|
|
4031
3889
|
var getFlags = (flag) => {
|
|
4032
|
-
if (isRef(flag))
|
|
4033
|
-
|
|
4034
|
-
if (isFunction(flag))
|
|
4035
|
-
flag = flag();
|
|
3890
|
+
if (isRef(flag)) flag = flag();
|
|
3891
|
+
if (isFunction(flag)) flag = flag();
|
|
4036
3892
|
if (!flag)
|
|
4037
3893
|
return {
|
|
4038
3894
|
trim: false,
|
|
@@ -4066,7 +3922,7 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
|
|
|
4066
3922
|
const f1 = getFlags(directiveFlags == null ? void 0 : directiveFlags.join(","));
|
|
4067
3923
|
const f2 = getFlags(parsedValue()[1]);
|
|
4068
3924
|
const flags = {
|
|
4069
|
-
int: f1.int ||
|
|
3925
|
+
int: f1.int || f2.int,
|
|
4070
3926
|
lazy: f1.lazy || f2.lazy,
|
|
4071
3927
|
number: f1.number || f2.number,
|
|
4072
3928
|
trim: f1.trim || f2.trim
|
|
@@ -4098,8 +3954,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4098
3954
|
const eventType = isLazy ? "change" : "input";
|
|
4099
3955
|
const isNumber = isNumberInput(el);
|
|
4100
3956
|
const trimmer = () => {
|
|
4101
|
-
if (!flags.trim && !getFlags(parsedValue()[1]).trim)
|
|
4102
|
-
return;
|
|
3957
|
+
if (!flags.trim && !getFlags(parsedValue()[1]).trim) return;
|
|
4103
3958
|
el.value = el.value.trim();
|
|
4104
3959
|
};
|
|
4105
3960
|
const onCompositionStart = (e) => {
|
|
@@ -4122,8 +3977,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4122
3977
|
};
|
|
4123
3978
|
const listener = (event) => {
|
|
4124
3979
|
const target = event.target;
|
|
4125
|
-
if (!target || target.composing)
|
|
4126
|
-
return;
|
|
3980
|
+
if (!target || target.composing) return;
|
|
4127
3981
|
let value = target.value;
|
|
4128
3982
|
const flags2 = getFlags(parsedValue()[1]);
|
|
4129
3983
|
if (isNumber || flags2.number || flags2.int) {
|
|
@@ -4134,15 +3988,12 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
4134
3988
|
if (endsWithDecimalSeparator) {
|
|
4135
3989
|
value += "0";
|
|
4136
3990
|
value = parseFloat(value);
|
|
4137
|
-
if (isNaN(value))
|
|
4138
|
-
|
|
4139
|
-
else if (modelRef() === value)
|
|
4140
|
-
return;
|
|
3991
|
+
if (isNaN(value)) value = "";
|
|
3992
|
+
else if (modelRef() === value) return;
|
|
4141
3993
|
}
|
|
4142
3994
|
value = parseFloat(value);
|
|
4143
3995
|
}
|
|
4144
|
-
if (isNaN(value))
|
|
4145
|
-
value = "";
|
|
3996
|
+
if (isNaN(value)) value = "";
|
|
4146
3997
|
el.value = value;
|
|
4147
3998
|
} else if (flags2.trim) {
|
|
4148
3999
|
value = value.trim();
|
|
@@ -4199,8 +4050,7 @@ var getCheckboxValue = (el, checked) => {
|
|
|
4199
4050
|
return el[key];
|
|
4200
4051
|
}
|
|
4201
4052
|
const attrKey = checked ? trueValueAttrKey : falseValueAttrKey;
|
|
4202
|
-
if (el.hasAttribute(attrKey))
|
|
4203
|
-
return el.getAttribute(attrKey);
|
|
4053
|
+
if (el.hasAttribute(attrKey)) return el.getAttribute(attrKey);
|
|
4204
4054
|
return checked;
|
|
4205
4055
|
};
|
|
4206
4056
|
var getCheckboxChecked = (el, value) => {
|
|
@@ -4242,8 +4092,7 @@ var handleSelect = (el, modelRef, parsedValue) => {
|
|
|
4242
4092
|
pause(modelRef);
|
|
4243
4093
|
if (isSet(modelValue)) {
|
|
4244
4094
|
modelValue.clear();
|
|
4245
|
-
for (const sel of selectedValue)
|
|
4246
|
-
modelValue.add(sel);
|
|
4095
|
+
for (const sel of selectedValue) modelValue.add(sel);
|
|
4247
4096
|
} else if (isArray(modelValue)) {
|
|
4248
4097
|
modelValue.splice(0);
|
|
4249
4098
|
modelValue.push(...selectedValue);
|
|
@@ -4295,9 +4144,8 @@ var onDirective = {
|
|
|
4295
4144
|
if (dynamicOption) {
|
|
4296
4145
|
const values2 = parseResult.value();
|
|
4297
4146
|
const option2 = unref(dynamicOption.value()[0]);
|
|
4298
|
-
if (!isString(option2))
|
|
4299
|
-
|
|
4300
|
-
};
|
|
4147
|
+
if (!isString(option2)) return () => {
|
|
4148
|
+
};
|
|
4301
4149
|
return attachEventListener(
|
|
4302
4150
|
el,
|
|
4303
4151
|
camelize(option2),
|
|
@@ -4321,18 +4169,15 @@ var onDirective = {
|
|
|
4321
4169
|
const len = values.length;
|
|
4322
4170
|
for (let i = 0; i < len; ++i) {
|
|
4323
4171
|
let next = values[i];
|
|
4324
|
-
if (isFunction(next))
|
|
4325
|
-
next = next();
|
|
4172
|
+
if (isFunction(next)) next = next();
|
|
4326
4173
|
if (isObject(next)) {
|
|
4327
4174
|
for (const item of Object.entries(next)) {
|
|
4328
4175
|
const eventType = item[0];
|
|
4329
4176
|
const method = () => {
|
|
4330
4177
|
let obj = parseResult.value()[i];
|
|
4331
|
-
if (isFunction(obj))
|
|
4332
|
-
obj = obj();
|
|
4178
|
+
if (isFunction(obj)) obj = obj();
|
|
4333
4179
|
obj = obj[eventType];
|
|
4334
|
-
if (isFunction(obj))
|
|
4335
|
-
obj = obj();
|
|
4180
|
+
if (isFunction(obj)) obj = obj();
|
|
4336
4181
|
return obj;
|
|
4337
4182
|
};
|
|
4338
4183
|
const flags2 = next[eventType + "_flags"];
|
|
@@ -4356,22 +4201,17 @@ var getShouldExecuteEvent = (eventType, flags) => {
|
|
|
4356
4201
|
const isAlt = parts.includes("alt");
|
|
4357
4202
|
const isMeta = parts.includes("meta");
|
|
4358
4203
|
const checkModifiers = (e) => {
|
|
4359
|
-
if (isCtrl && !e.ctrlKey)
|
|
4360
|
-
|
|
4361
|
-
if (
|
|
4362
|
-
|
|
4363
|
-
if (isAlt && !e.altKey)
|
|
4364
|
-
return false;
|
|
4365
|
-
if (isMeta && !e.metaKey)
|
|
4366
|
-
return false;
|
|
4204
|
+
if (isCtrl && !e.ctrlKey) return false;
|
|
4205
|
+
if (isShift && !e.shiftKey) return false;
|
|
4206
|
+
if (isAlt && !e.altKey) return false;
|
|
4207
|
+
if (isMeta && !e.metaKey) return false;
|
|
4367
4208
|
return true;
|
|
4368
4209
|
};
|
|
4369
4210
|
if (keyType) {
|
|
4370
4211
|
return [
|
|
4371
4212
|
eventType,
|
|
4372
4213
|
(e) => {
|
|
4373
|
-
if (!checkModifiers(e))
|
|
4374
|
-
return false;
|
|
4214
|
+
if (!checkModifiers(e)) return false;
|
|
4375
4215
|
return e.key.toUpperCase() === keyType.toUpperCase();
|
|
4376
4216
|
}
|
|
4377
4217
|
];
|
|
@@ -4395,15 +4235,11 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4395
4235
|
let shouldExecuteEvent;
|
|
4396
4236
|
[eventType, shouldExecuteEvent] = getShouldExecuteEvent(eventType, flags);
|
|
4397
4237
|
const execute = (e) => {
|
|
4398
|
-
if (!shouldExecuteEvent(e))
|
|
4399
|
-
|
|
4400
|
-
if (!method && eventType === "submit" && (flag == null ? void 0 : flag.prevent))
|
|
4401
|
-
return;
|
|
4238
|
+
if (!shouldExecuteEvent(e)) return;
|
|
4239
|
+
if (!method && eventType === "submit" && (flag == null ? void 0 : flag.prevent)) return;
|
|
4402
4240
|
let r = method(e);
|
|
4403
|
-
if (isFunction(r))
|
|
4404
|
-
|
|
4405
|
-
if (isFunction(r))
|
|
4406
|
-
r(e);
|
|
4241
|
+
if (isFunction(r)) r = r(e);
|
|
4242
|
+
if (isFunction(r)) r(e);
|
|
4407
4243
|
};
|
|
4408
4244
|
const unbinder = () => {
|
|
4409
4245
|
el.removeEventListener(eventType, listener, options);
|
|
@@ -4414,22 +4250,15 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4414
4250
|
return;
|
|
4415
4251
|
}
|
|
4416
4252
|
try {
|
|
4417
|
-
if (flag.left && e.button !==
|
|
4418
|
-
|
|
4419
|
-
if (flag.
|
|
4420
|
-
|
|
4421
|
-
if (flag.
|
|
4422
|
-
|
|
4423
|
-
if (flag.self && e.target !== el)
|
|
4424
|
-
return;
|
|
4425
|
-
if (flag.stop)
|
|
4426
|
-
e.stopPropagation();
|
|
4427
|
-
if (flag.prevent)
|
|
4428
|
-
e.preventDefault();
|
|
4253
|
+
if (flag.left && e.button !== 0) return;
|
|
4254
|
+
if (flag.middle && e.button !== 1) return;
|
|
4255
|
+
if (flag.right && e.button !== 2) return;
|
|
4256
|
+
if (flag.self && e.target !== el) return;
|
|
4257
|
+
if (flag.stop) e.stopPropagation();
|
|
4258
|
+
if (flag.prevent) e.preventDefault();
|
|
4429
4259
|
execute(e);
|
|
4430
4260
|
} finally {
|
|
4431
|
-
if (flag.once)
|
|
4432
|
-
unbinder();
|
|
4261
|
+
if (flag.once) unbinder();
|
|
4433
4262
|
}
|
|
4434
4263
|
};
|
|
4435
4264
|
el.addEventListener(eventType, listener, options);
|
|
@@ -4440,8 +4269,7 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
4440
4269
|
var propDirective = {
|
|
4441
4270
|
onChange: (el, values, _previousValues, option, _previousOption, flags) => {
|
|
4442
4271
|
if (option) {
|
|
4443
|
-
if (flags && flags.includes("camel"))
|
|
4444
|
-
option = camelize(option);
|
|
4272
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
4445
4273
|
patchProp(el, option, values[0]);
|
|
4446
4274
|
return;
|
|
4447
4275
|
}
|
|
@@ -4524,18 +4352,14 @@ var refDirective = {
|
|
|
4524
4352
|
const value = result.value()[0];
|
|
4525
4353
|
const isAnArray = isArray(value);
|
|
4526
4354
|
const sref2 = result.refs[0];
|
|
4527
|
-
if (isAnArray)
|
|
4528
|
-
|
|
4529
|
-
else
|
|
4530
|
-
sref2 == null ? void 0 : sref2(el);
|
|
4531
|
-
else
|
|
4532
|
-
result.context[expr] = el;
|
|
4355
|
+
if (isAnArray) value.push(el);
|
|
4356
|
+
else if (sref2) sref2 == null ? void 0 : sref2(el);
|
|
4357
|
+
else result.context[expr] = el;
|
|
4533
4358
|
return () => {
|
|
4534
4359
|
if (isAnArray) {
|
|
4535
4360
|
const i = value.indexOf(el);
|
|
4536
4361
|
i !== -1 && value.splice(i, 1);
|
|
4537
|
-
} else
|
|
4538
|
-
sref2 == null ? void 0 : sref2(null);
|
|
4362
|
+
} else sref2 == null ? void 0 : sref2(null);
|
|
4539
4363
|
};
|
|
4540
4364
|
}
|
|
4541
4365
|
};
|
|
@@ -4549,10 +4373,8 @@ var showDirective = {
|
|
|
4549
4373
|
originalDisplay = data._ord = el.style.display;
|
|
4550
4374
|
}
|
|
4551
4375
|
const isVisible = !!values[0];
|
|
4552
|
-
if (isVisible)
|
|
4553
|
-
|
|
4554
|
-
else
|
|
4555
|
-
el.style.display = "none";
|
|
4376
|
+
if (isVisible) el.style.display = originalDisplay;
|
|
4377
|
+
else el.style.display = "none";
|
|
4556
4378
|
}
|
|
4557
4379
|
};
|
|
4558
4380
|
|
|
@@ -4598,8 +4420,7 @@ var patchStyle = (el, next, prev) => {
|
|
|
4598
4420
|
el.removeAttribute("style");
|
|
4599
4421
|
}
|
|
4600
4422
|
const data = getBindData(el).data;
|
|
4601
|
-
if ("_ord" in data)
|
|
4602
|
-
return;
|
|
4423
|
+
if ("_ord" in data) return;
|
|
4603
4424
|
style.display = currentDisplay;
|
|
4604
4425
|
}
|
|
4605
4426
|
};
|
|
@@ -4610,8 +4431,7 @@ function setStyle(style, name2, val) {
|
|
|
4610
4431
|
setStyle(style, name2, v);
|
|
4611
4432
|
});
|
|
4612
4433
|
} else {
|
|
4613
|
-
if (val == null)
|
|
4614
|
-
val = "";
|
|
4434
|
+
if (val == null) val = "";
|
|
4615
4435
|
if (name2.startsWith("--")) {
|
|
4616
4436
|
style.setProperty(name2, val);
|
|
4617
4437
|
} else {
|
|
@@ -4653,11 +4473,9 @@ function autoPrefix(style, rawName) {
|
|
|
4653
4473
|
var flatten = (reference) => {
|
|
4654
4474
|
return flattenContent(unref(reference));
|
|
4655
4475
|
};
|
|
4656
|
-
var flattenContent = (value) => {
|
|
4657
|
-
if (!value)
|
|
4658
|
-
|
|
4659
|
-
if (!isObject(value))
|
|
4660
|
-
return value;
|
|
4476
|
+
var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
|
|
4477
|
+
if (!value) return value;
|
|
4478
|
+
if (!isObject(value)) return value;
|
|
4661
4479
|
if (isArray(value)) {
|
|
4662
4480
|
return value.map(flatten);
|
|
4663
4481
|
}
|
|
@@ -4670,14 +4488,16 @@ var flattenContent = (value) => {
|
|
|
4670
4488
|
}
|
|
4671
4489
|
if (isMap(value)) {
|
|
4672
4490
|
const map = /* @__PURE__ */ new Map();
|
|
4673
|
-
for (const el of
|
|
4491
|
+
for (const el of value) {
|
|
4674
4492
|
map.set(flatten(el[0]), flatten(el[1]));
|
|
4675
4493
|
}
|
|
4676
4494
|
return map;
|
|
4677
4495
|
}
|
|
4496
|
+
if (weakMap.has(value)) return unref(weakMap.get(value));
|
|
4678
4497
|
const result = { ...value };
|
|
4498
|
+
weakMap.set(value, result);
|
|
4679
4499
|
for (const entry of Object.entries(result)) {
|
|
4680
|
-
result[entry[0]] =
|
|
4500
|
+
result[entry[0]] = flattenContent(unref(entry[1]), weakMap);
|
|
4681
4501
|
}
|
|
4682
4502
|
return result;
|
|
4683
4503
|
};
|
|
@@ -4705,8 +4525,7 @@ var isDeepRef = (value) => {
|
|
|
4705
4525
|
|
|
4706
4526
|
// src/reactivity/ref.ts
|
|
4707
4527
|
var ref = (value) => {
|
|
4708
|
-
if (isRaw(value))
|
|
4709
|
-
return value;
|
|
4528
|
+
if (isRaw(value)) return value;
|
|
4710
4529
|
let result;
|
|
4711
4530
|
if (isRef(value)) {
|
|
4712
4531
|
result = value;
|
|
@@ -4721,21 +4540,18 @@ var ref = (value) => {
|
|
|
4721
4540
|
const len = value.length;
|
|
4722
4541
|
for (let i = 0; i < len; ++i) {
|
|
4723
4542
|
const item = value[i];
|
|
4724
|
-
if (isDeepRef(item))
|
|
4725
|
-
continue;
|
|
4543
|
+
if (isDeepRef(item)) continue;
|
|
4726
4544
|
value[i] = ref(item);
|
|
4727
4545
|
}
|
|
4728
4546
|
return result;
|
|
4729
4547
|
}
|
|
4730
|
-
if (!isObject(value))
|
|
4731
|
-
return result;
|
|
4548
|
+
if (!isObject(value)) return result;
|
|
4732
4549
|
for (const item of Object.entries(value)) {
|
|
4733
4550
|
const val = item[1];
|
|
4734
|
-
if (isDeepRef(val))
|
|
4735
|
-
continue;
|
|
4551
|
+
if (isDeepRef(val)) continue;
|
|
4736
4552
|
const key = item[0];
|
|
4737
|
-
if (isSymbol(key))
|
|
4738
|
-
|
|
4553
|
+
if (isSymbol(key)) continue;
|
|
4554
|
+
value[key] = null;
|
|
4739
4555
|
value[key] = ref(val);
|
|
4740
4556
|
}
|
|
4741
4557
|
return result;
|
|
@@ -4870,8 +4686,7 @@ var RegorConfig = _RegorConfig;
|
|
|
4870
4686
|
|
|
4871
4687
|
// src/bind/interpolation.ts
|
|
4872
4688
|
var interpolate = (element, config) => {
|
|
4873
|
-
if (!element)
|
|
4874
|
-
return;
|
|
4689
|
+
if (!element) return;
|
|
4875
4690
|
const builtInNames = (config != null ? config : RegorConfig.getDefault()).__builtInNames;
|
|
4876
4691
|
for (const textNode of getTextNodes(element, builtInNames.pre)) {
|
|
4877
4692
|
interpolateTextNode(textNode, builtInNames.text);
|
|
@@ -4881,12 +4696,10 @@ var interpolationRegex = /({{[^]*?}})/g;
|
|
|
4881
4696
|
var interpolateTextNode = (textNode, textDirective2) => {
|
|
4882
4697
|
var _a;
|
|
4883
4698
|
const text = textNode.textContent;
|
|
4884
|
-
if (!text)
|
|
4885
|
-
return;
|
|
4699
|
+
if (!text) return;
|
|
4886
4700
|
const mustacheRegex = interpolationRegex;
|
|
4887
4701
|
const parts = text.split(mustacheRegex);
|
|
4888
|
-
if (parts.length <= 1)
|
|
4889
|
-
return;
|
|
4702
|
+
if (parts.length <= 1) return;
|
|
4890
4703
|
if (((_a = textNode.parentElement) == null ? void 0 : _a.childNodes.length) === 1 && parts.length === 3) {
|
|
4891
4704
|
const part = parts[1];
|
|
4892
4705
|
if (isNullOrWhitespace(parts[0]) && isNullOrWhitespace(parts[2]) && part.startsWith("{{") && part.endsWith("}}")) {
|
|
@@ -4918,8 +4731,7 @@ var getTextNodes = (node, preDirective) => {
|
|
|
4918
4731
|
textNodes.push(node2);
|
|
4919
4732
|
}
|
|
4920
4733
|
} else {
|
|
4921
|
-
if ((_b = node2 == null ? void 0 : node2.hasAttribute) == null ? void 0 : _b.call(node2, preDirective))
|
|
4922
|
-
return;
|
|
4734
|
+
if ((_b = node2 == null ? void 0 : node2.hasAttribute) == null ? void 0 : _b.call(node2, preDirective)) return;
|
|
4923
4735
|
for (const child of getChildNodes(node2)) {
|
|
4924
4736
|
traverseTextNodes(child);
|
|
4925
4737
|
}
|
|
@@ -4934,10 +4746,8 @@ var svgTags = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-
|
|
|
4934
4746
|
var svgSet = new Set(svgTags.toUpperCase().split(","));
|
|
4935
4747
|
var svgNamespace = "http://www.w3.org/2000/svg";
|
|
4936
4748
|
var appendChild = (parent, el) => {
|
|
4937
|
-
if (isTemplate(parent))
|
|
4938
|
-
|
|
4939
|
-
else
|
|
4940
|
-
parent.appendChild(el);
|
|
4749
|
+
if (isTemplate(parent)) parent.content.appendChild(el);
|
|
4750
|
+
else parent.appendChild(el);
|
|
4941
4751
|
};
|
|
4942
4752
|
var render = (json, parent, isSVG, config) => {
|
|
4943
4753
|
var _a;
|
|
@@ -4958,8 +4768,7 @@ var render = (json, parent, isSVG, config) => {
|
|
|
4958
4768
|
}
|
|
4959
4769
|
const children = json.c;
|
|
4960
4770
|
if (children) {
|
|
4961
|
-
for (const child of children)
|
|
4962
|
-
render(child, el, isSVG, config);
|
|
4771
|
+
for (const child of children) render(child, el, isSVG, config);
|
|
4963
4772
|
}
|
|
4964
4773
|
appendChild(parent, el);
|
|
4965
4774
|
return;
|
|
@@ -4975,10 +4784,8 @@ var render = (json, parent, isSVG, config) => {
|
|
|
4975
4784
|
node = document.createTextNode(textData);
|
|
4976
4785
|
break;
|
|
4977
4786
|
}
|
|
4978
|
-
if (node)
|
|
4979
|
-
|
|
4980
|
-
else
|
|
4981
|
-
throw new Error("unsupported node type.");
|
|
4787
|
+
if (node) appendChild(parent, node);
|
|
4788
|
+
else throw new Error("unsupported node type.");
|
|
4982
4789
|
}
|
|
4983
4790
|
};
|
|
4984
4791
|
var toFragment = (json, isSVG, config) => {
|
|
@@ -4995,16 +4802,13 @@ var toFragment = (json, isSVG, config) => {
|
|
|
4995
4802
|
};
|
|
4996
4803
|
|
|
4997
4804
|
// src/app/createApp.ts
|
|
4998
|
-
var createApp = (context,
|
|
4999
|
-
if (isString(
|
|
5000
|
-
|
|
5001
|
-
if (isScope(context))
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
if (!
|
|
5005
|
-
throw getError(0 /* AppRootElementMissing */);
|
|
5006
|
-
if (!config)
|
|
5007
|
-
config = RegorConfig.getDefault();
|
|
4805
|
+
var createApp = (context, template = { selector: "#app" }, config) => {
|
|
4806
|
+
if (isString(template))
|
|
4807
|
+
template = { selector: "#app", template };
|
|
4808
|
+
if (isScope(context)) context = context.context;
|
|
4809
|
+
const root = template.element ? template.element : template.selector ? document.querySelector(template.selector) : null;
|
|
4810
|
+
if (!root || !isElement(root)) throw getError(0 /* AppRootElementMissing */);
|
|
4811
|
+
if (!config) config = RegorConfig.getDefault();
|
|
5008
4812
|
const cleanRoot = () => {
|
|
5009
4813
|
for (const child of [...root.childNodes]) {
|
|
5010
4814
|
removeNode(child);
|
|
@@ -5015,22 +4819,21 @@ var createApp = (context, templateOptions = { selector: "#app" }, config) => {
|
|
|
5015
4819
|
root.appendChild(child);
|
|
5016
4820
|
}
|
|
5017
4821
|
};
|
|
5018
|
-
if (
|
|
5019
|
-
const element = document.createRange().createContextualFragment(
|
|
4822
|
+
if (template.template) {
|
|
4823
|
+
const element = document.createRange().createContextualFragment(template.template);
|
|
5020
4824
|
cleanRoot();
|
|
5021
4825
|
appendChildren(element.childNodes);
|
|
5022
|
-
|
|
5023
|
-
} else if (
|
|
4826
|
+
template.element = element;
|
|
4827
|
+
} else if (template.json) {
|
|
5024
4828
|
const element = toFragment(
|
|
5025
|
-
|
|
5026
|
-
|
|
4829
|
+
template.json,
|
|
4830
|
+
template.isSVG,
|
|
5027
4831
|
config
|
|
5028
4832
|
);
|
|
5029
4833
|
cleanRoot();
|
|
5030
4834
|
appendChildren(element.childNodes);
|
|
5031
4835
|
}
|
|
5032
|
-
if (config.useInterpolation)
|
|
5033
|
-
interpolate(root, config);
|
|
4836
|
+
if (config.useInterpolation) interpolate(root, config);
|
|
5034
4837
|
const app = new RegorApp(context, root, config);
|
|
5035
4838
|
app.__bind();
|
|
5036
4839
|
addUnbinder(root, () => {
|
|
@@ -5071,13 +4874,10 @@ var toJsonTemplate = (node) => {
|
|
|
5071
4874
|
return node.map((x) => toJsonTemplate(x));
|
|
5072
4875
|
}
|
|
5073
4876
|
const json = {};
|
|
5074
|
-
if (node.tagName)
|
|
5075
|
-
json.t = node.tagName;
|
|
4877
|
+
if (node.tagName) json.t = node.tagName;
|
|
5076
4878
|
else {
|
|
5077
|
-
if (node.nodeType === Node.COMMENT_NODE)
|
|
5078
|
-
|
|
5079
|
-
if (node.textContent)
|
|
5080
|
-
json.d = node.textContent;
|
|
4879
|
+
if (node.nodeType === Node.COMMENT_NODE) json.n = Node.COMMENT_NODE;
|
|
4880
|
+
if (node.textContent) json.d = node.textContent;
|
|
5081
4881
|
return json;
|
|
5082
4882
|
}
|
|
5083
4883
|
const attrNames = node.getAttributeNames();
|
|
@@ -5096,51 +4896,48 @@ var toJsonTemplate = (node) => {
|
|
|
5096
4896
|
};
|
|
5097
4897
|
|
|
5098
4898
|
// src/app/createComponent.ts
|
|
5099
|
-
var createComponent = (context,
|
|
4899
|
+
var createComponent = (context, template, options = {}) => {
|
|
5100
4900
|
var _a, _b, _c, _d;
|
|
5101
|
-
if (isArray(options))
|
|
5102
|
-
|
|
5103
|
-
if (isString(templateOptions))
|
|
5104
|
-
templateOptions = { template: templateOptions };
|
|
4901
|
+
if (isArray(options)) options = { props: options };
|
|
4902
|
+
if (isString(template)) template = { template };
|
|
5105
4903
|
let svgHandled = false;
|
|
5106
|
-
if (
|
|
5107
|
-
const element2 =
|
|
4904
|
+
if (template.element) {
|
|
4905
|
+
const element2 = template.element;
|
|
5108
4906
|
element2.remove();
|
|
5109
|
-
|
|
5110
|
-
} else if (
|
|
5111
|
-
const element2 = document.querySelector(
|
|
4907
|
+
template.element = element2;
|
|
4908
|
+
} else if (template.selector) {
|
|
4909
|
+
const element2 = document.querySelector(template.selector);
|
|
5112
4910
|
if (!element2)
|
|
5113
4911
|
throw getError(
|
|
5114
4912
|
1 /* ComponentTemplateNotFound */,
|
|
5115
|
-
|
|
4913
|
+
template.selector
|
|
5116
4914
|
);
|
|
5117
4915
|
element2.remove();
|
|
5118
|
-
|
|
5119
|
-
} else if (
|
|
5120
|
-
const element2 = document.createRange().createContextualFragment(
|
|
5121
|
-
|
|
5122
|
-
} else if (
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
4916
|
+
template.element = element2;
|
|
4917
|
+
} else if (template.template) {
|
|
4918
|
+
const element2 = document.createRange().createContextualFragment(template.template);
|
|
4919
|
+
template.element = element2;
|
|
4920
|
+
} else if (template.json) {
|
|
4921
|
+
template.element = toFragment(
|
|
4922
|
+
template.json,
|
|
4923
|
+
template.isSVG,
|
|
5126
4924
|
options.config
|
|
5127
4925
|
);
|
|
5128
4926
|
svgHandled = true;
|
|
5129
4927
|
}
|
|
5130
|
-
if (!
|
|
5131
|
-
|
|
5132
|
-
if ((_a = options.useInterpolation) != null ? _a : true)
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
const content = templateOptions.element.content;
|
|
4928
|
+
if (!template.element)
|
|
4929
|
+
template.element = document.createDocumentFragment();
|
|
4930
|
+
if ((_a = options.useInterpolation) != null ? _a : true) interpolate(template.element);
|
|
4931
|
+
const element = template.element;
|
|
4932
|
+
if (!svgHandled && (((_c = template.isSVG) != null ? _c : isHTMLElement(element) && ((_b = element.hasAttribute) == null ? void 0 : _b.call(element, "isSVG"))) || isHTMLElement(element) && !!element.querySelector("[isSVG]"))) {
|
|
4933
|
+
const content = template.element.content;
|
|
5137
4934
|
const nodes = content ? [...content.childNodes] : [...element.childNodes];
|
|
5138
4935
|
const json = toJsonTemplate(nodes);
|
|
5139
|
-
|
|
4936
|
+
template.element = toFragment(json, true, options.config);
|
|
5140
4937
|
}
|
|
5141
4938
|
return {
|
|
5142
4939
|
context,
|
|
5143
|
-
template:
|
|
4940
|
+
template: template.element,
|
|
5144
4941
|
inheritAttrs: (_d = options.inheritAttrs) != null ? _d : true,
|
|
5145
4942
|
props: options.props,
|
|
5146
4943
|
defaultName: options.defaultName
|
|
@@ -5154,8 +4951,7 @@ var computed = (compute) => {
|
|
|
5154
4951
|
const result = (...args) => {
|
|
5155
4952
|
if (args.length <= 2 && 0 in args)
|
|
5156
4953
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5157
|
-
if (computer && !status.isStopped)
|
|
5158
|
-
return computer(...args);
|
|
4954
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5159
4955
|
computer = computedOnce(compute, status);
|
|
5160
4956
|
return computer(...args);
|
|
5161
4957
|
};
|
|
@@ -5195,8 +4991,7 @@ var computeMany = (sources, compute) => {
|
|
|
5195
4991
|
const result = (...args) => {
|
|
5196
4992
|
if (args.length <= 2 && 0 in args)
|
|
5197
4993
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5198
|
-
if (computer && !status.isStopped)
|
|
5199
|
-
return computer(...args);
|
|
4994
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5200
4995
|
computer = computeManyOnce(sources, compute, status);
|
|
5201
4996
|
return computer(...args);
|
|
5202
4997
|
};
|
|
@@ -5246,8 +5041,7 @@ var computeRef = (source, compute) => {
|
|
|
5246
5041
|
const result = (...args) => {
|
|
5247
5042
|
if (args.length <= 2 && 0 in args)
|
|
5248
5043
|
throw getError(4 /* ComputedIsReadOnly */);
|
|
5249
|
-
if (computer && !status.isStopped)
|
|
5250
|
-
return computer(...args);
|
|
5044
|
+
if (computer && !status.isStopped) return computer(...args);
|
|
5251
5045
|
computer = computeRefOnce(source, compute, status);
|
|
5252
5046
|
return computer(...args);
|
|
5253
5047
|
};
|
|
@@ -5292,31 +5086,44 @@ var markRaw = (value) => {
|
|
|
5292
5086
|
|
|
5293
5087
|
// src/misc/persist.ts
|
|
5294
5088
|
var persist = (anyRef, key) => {
|
|
5295
|
-
if (!key)
|
|
5296
|
-
throw new Error("persist requires a string key.");
|
|
5089
|
+
if (!key) throw getError(5 /* PersistRequiresKey */);
|
|
5297
5090
|
const deepRef = isDeepRef(anyRef);
|
|
5298
5091
|
const makeRef = deepRef ? ref : (x) => x;
|
|
5299
5092
|
const store = () => localStorage.setItem(key, JSON.stringify(flatten(anyRef())));
|
|
5300
5093
|
const existing = localStorage.getItem(key);
|
|
5301
5094
|
if (existing != null) {
|
|
5302
|
-
|
|
5095
|
+
try {
|
|
5096
|
+
anyRef(makeRef(JSON.parse(existing)));
|
|
5097
|
+
} catch (e) {
|
|
5098
|
+
warning(
|
|
5099
|
+
6 /* ErrorLog */,
|
|
5100
|
+
`persist: failed to parse data for key ${key}`,
|
|
5101
|
+
e
|
|
5102
|
+
);
|
|
5103
|
+
store();
|
|
5104
|
+
}
|
|
5303
5105
|
} else {
|
|
5304
5106
|
store();
|
|
5305
5107
|
}
|
|
5306
5108
|
const stopObserving = watchEffect(store);
|
|
5307
|
-
onUnmounted(
|
|
5109
|
+
onUnmounted(stopObserving, true);
|
|
5308
5110
|
return anyRef;
|
|
5309
5111
|
};
|
|
5310
5112
|
|
|
5311
5113
|
// src/misc/tagged-html.ts
|
|
5312
5114
|
var html = (templates, ...args) => {
|
|
5313
|
-
let
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5115
|
+
let result = "";
|
|
5116
|
+
const tpl = templates;
|
|
5117
|
+
const a = args;
|
|
5118
|
+
const tplLen = tpl.length;
|
|
5119
|
+
const argLen = a.length;
|
|
5120
|
+
for (let i = 0; i < tplLen; ++i) {
|
|
5121
|
+
result += tpl[i];
|
|
5122
|
+
if (i < argLen) {
|
|
5123
|
+
result += a[i];
|
|
5124
|
+
}
|
|
5125
|
+
}
|
|
5126
|
+
return result;
|
|
5320
5127
|
};
|
|
5321
5128
|
var raw = html;
|
|
5322
5129
|
|
|
@@ -5329,8 +5136,7 @@ var observeMany = (sources, observer, init) => {
|
|
|
5329
5136
|
for (const source of sources) {
|
|
5330
5137
|
stopObservingList.push(observe(source, callObserver));
|
|
5331
5138
|
}
|
|
5332
|
-
if (init)
|
|
5333
|
-
callObserver();
|
|
5139
|
+
if (init) callObserver();
|
|
5334
5140
|
const stop = () => {
|
|
5335
5141
|
for (const stopObserving of stopObservingList) {
|
|
5336
5142
|
stopObserving();
|
|
@@ -5343,7 +5149,7 @@ var observeMany = (sources, observer, init) => {
|
|
|
5343
5149
|
// src/observer/observerCount.ts
|
|
5344
5150
|
var observerCount = (source) => {
|
|
5345
5151
|
if (!isRef(source))
|
|
5346
|
-
throw getError(3 /* RequiresRefSourceArgument */, "
|
|
5152
|
+
throw getError(3 /* RequiresRefSourceArgument */, "observerCount");
|
|
5347
5153
|
const srefImpl = source;
|
|
5348
5154
|
return srefImpl(void 0, void 0, 2 /* observerCount */);
|
|
5349
5155
|
};
|
|
@@ -5358,14 +5164,19 @@ var batch = (updater) => {
|
|
|
5358
5164
|
}
|
|
5359
5165
|
};
|
|
5360
5166
|
var startBatch = () => {
|
|
5361
|
-
if (!batchCollector.
|
|
5362
|
-
|
|
5167
|
+
if (!batchCollector.stack) batchCollector.stack = [];
|
|
5168
|
+
batchCollector.stack.push(/* @__PURE__ */ new Set());
|
|
5363
5169
|
};
|
|
5364
5170
|
var endBatch = () => {
|
|
5365
|
-
const
|
|
5366
|
-
if (!
|
|
5171
|
+
const stack = batchCollector.stack;
|
|
5172
|
+
if (!stack || stack.length === 0) return;
|
|
5173
|
+
const set = stack.pop();
|
|
5174
|
+
if (stack.length) {
|
|
5175
|
+
const parent = stack[stack.length - 1];
|
|
5176
|
+
for (const ref2 of set) parent.add(ref2);
|
|
5367
5177
|
return;
|
|
5368
|
-
|
|
5178
|
+
}
|
|
5179
|
+
delete batchCollector.stack;
|
|
5369
5180
|
for (const ref2 of set) {
|
|
5370
5181
|
try {
|
|
5371
5182
|
trigger(ref2);
|