regor 1.3.5 → 1.3.7
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/README.md +44 -21
- package/dist/regor.d.ts +42 -24
- package/dist/regor.es2015.cjs.js +741 -390
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +741 -390
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +741 -390
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +741 -390
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +741 -390
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +741 -390
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +732 -378
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +732 -378
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +732 -378
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +1 -1
package/dist/regor.es2019.esm.js
CHANGED
|
@@ -8,8 +8,8 @@ var bindDataSymbol = Symbol(":regor");
|
|
|
8
8
|
// src/cleanup/unbind.ts
|
|
9
9
|
var unbind = (node) => {
|
|
10
10
|
const stack = [node];
|
|
11
|
-
|
|
12
|
-
const currentNode = stack
|
|
11
|
+
for (let i = 0; i < stack.length; ++i) {
|
|
12
|
+
const currentNode = stack[i];
|
|
13
13
|
unbindSingle(currentNode);
|
|
14
14
|
for (let child = currentNode.lastChild; child != null; child = child.previousSibling) {
|
|
15
15
|
stack.push(child);
|
|
@@ -360,6 +360,8 @@ var setSwitchOwner = (owner, switchNodes) => {
|
|
|
360
360
|
};
|
|
361
361
|
|
|
362
362
|
// src/bind/IfBinder.ts
|
|
363
|
+
var noopStopObserving = () => {
|
|
364
|
+
};
|
|
363
365
|
var mount = (nodes, binder, parent, end) => {
|
|
364
366
|
const childNodes = [];
|
|
365
367
|
for (const x of nodes) {
|
|
@@ -484,18 +486,14 @@ var IfBinder = class {
|
|
|
484
486
|
const parseResult = this.__binder.__parser.__parse(expression);
|
|
485
487
|
const value = parseResult.value;
|
|
486
488
|
const remainingElses = this.__collectElses(nextElement, refresh);
|
|
487
|
-
|
|
489
|
+
let stopObserver = noopStopObserving;
|
|
488
490
|
const unbinder = () => {
|
|
489
491
|
parseResult.stop();
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
stopObserverList.length = 0;
|
|
492
|
+
stopObserver();
|
|
493
|
+
stopObserver = noopStopObserving;
|
|
494
494
|
};
|
|
495
495
|
addUnbinder(commentBegin, unbinder);
|
|
496
|
-
|
|
497
|
-
};
|
|
498
|
-
stopObserverList.push(stopObserving);
|
|
496
|
+
stopObserver = parseResult.subscribe(refresh);
|
|
499
497
|
return [
|
|
500
498
|
{
|
|
501
499
|
mount: () => {
|
|
@@ -506,8 +504,9 @@ var IfBinder = class {
|
|
|
506
504
|
},
|
|
507
505
|
isTrue: () => !!value()[0],
|
|
508
506
|
isMounted: false
|
|
509
|
-
}
|
|
510
|
-
|
|
507
|
+
},
|
|
508
|
+
...remainingElses
|
|
509
|
+
];
|
|
511
510
|
}
|
|
512
511
|
}
|
|
513
512
|
__bindToExpression(el, expression) {
|
|
@@ -553,29 +552,31 @@ var IfBinder = class {
|
|
|
553
552
|
});
|
|
554
553
|
};
|
|
555
554
|
const collectedElses = this.__collectElses(nextElement, refresh);
|
|
556
|
-
|
|
555
|
+
let stopObserver = noopStopObserving;
|
|
557
556
|
const unbinder = () => {
|
|
558
557
|
parseResult.stop();
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}
|
|
562
|
-
stopObserverList.length = 0;
|
|
558
|
+
stopObserver();
|
|
559
|
+
stopObserver = noopStopObserving;
|
|
563
560
|
};
|
|
564
561
|
addUnbinder(commentBegin, unbinder);
|
|
565
562
|
refresh();
|
|
566
|
-
|
|
567
|
-
};
|
|
568
|
-
stopObserverList.push(stopObserving);
|
|
563
|
+
stopObserver = parseResult.subscribe(refresh);
|
|
569
564
|
}
|
|
570
565
|
};
|
|
571
566
|
|
|
572
567
|
// src/common/common.ts
|
|
573
568
|
var getNodes = (el) => {
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
569
|
+
const source = isTemplate(el) ? el.content.childNodes : [el];
|
|
570
|
+
const result = [];
|
|
571
|
+
for (let i = 0; i < source.length; ++i) {
|
|
572
|
+
const node = source[i];
|
|
573
|
+
if (node.nodeType === 1) {
|
|
574
|
+
const tagName = node == null ? void 0 : node.tagName;
|
|
575
|
+
if (tagName === "SCRIPT" || tagName === "STYLE") continue;
|
|
576
|
+
}
|
|
577
|
+
result.push(node);
|
|
578
|
+
}
|
|
579
|
+
return result;
|
|
579
580
|
};
|
|
580
581
|
var bindChildNodes = (binder, childNodes) => {
|
|
581
582
|
for (let i = 0; i < childNodes.length; ++i) {
|
|
@@ -673,7 +674,9 @@ var capitalize = cacheStringFunction((str) => {
|
|
|
673
674
|
});
|
|
674
675
|
|
|
675
676
|
// src/directives/teleport.ts
|
|
676
|
-
var teleportDirective = {
|
|
677
|
+
var teleportDirective = {
|
|
678
|
+
mount: () => void 0
|
|
679
|
+
};
|
|
677
680
|
|
|
678
681
|
// src/composition/callMounted.ts
|
|
679
682
|
var callMounted = (context) => {
|
|
@@ -708,12 +711,6 @@ var isScope = (value) => {
|
|
|
708
711
|
return scopeSymbol2 in value;
|
|
709
712
|
};
|
|
710
713
|
|
|
711
|
-
// src/composition/onUnmounted.ts
|
|
712
|
-
var onUnmounted = (onUnmounted2, noThrow) => {
|
|
713
|
-
var _a;
|
|
714
|
-
(_a = peekScope(noThrow)) == null ? void 0 : _a.onUnmounted.push(onUnmounted2);
|
|
715
|
-
};
|
|
716
|
-
|
|
717
714
|
// src/reactivity/refSymbols.ts
|
|
718
715
|
var refSymbol = Symbol("ref");
|
|
719
716
|
var srefSymbol = Symbol("sref");
|
|
@@ -724,6 +721,35 @@ var isRef = (value) => {
|
|
|
724
721
|
return value != null && value[srefSymbol] === 1;
|
|
725
722
|
};
|
|
726
723
|
|
|
724
|
+
// src/directives/context.ts
|
|
725
|
+
var contextDirective = {
|
|
726
|
+
collectRefObj: true,
|
|
727
|
+
mount: ({ parseResult }) => ({
|
|
728
|
+
update: ({ values }) => {
|
|
729
|
+
const ctx = parseResult.context;
|
|
730
|
+
const obj = values[0];
|
|
731
|
+
if (!isObject(obj)) return;
|
|
732
|
+
for (const item of Object.entries(obj)) {
|
|
733
|
+
const key = item[0];
|
|
734
|
+
const nextValue = item[1];
|
|
735
|
+
const ctxKey = ctx[key];
|
|
736
|
+
if (ctxKey === nextValue) continue;
|
|
737
|
+
if (isRef(ctxKey)) {
|
|
738
|
+
ctxKey(nextValue);
|
|
739
|
+
} else {
|
|
740
|
+
ctx[key] = nextValue;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
})
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
// src/composition/onUnmounted.ts
|
|
748
|
+
var onUnmounted = (onUnmounted2, noThrow) => {
|
|
749
|
+
var _a;
|
|
750
|
+
(_a = peekScope(noThrow)) == null ? void 0 : _a.onUnmounted.push(onUnmounted2);
|
|
751
|
+
};
|
|
752
|
+
|
|
727
753
|
// src/observer/observe.ts
|
|
728
754
|
var observe = (source, observer, init, trackUnmount = true) => {
|
|
729
755
|
if (!isRef(source))
|
|
@@ -740,37 +766,6 @@ var observe = (source, observer, init, trackUnmount = true) => {
|
|
|
740
766
|
return stop;
|
|
741
767
|
};
|
|
742
768
|
|
|
743
|
-
// src/directives/context.ts
|
|
744
|
-
var contextDirective = {
|
|
745
|
-
collectRefObj: true,
|
|
746
|
-
onBind: (_, parseResult) => {
|
|
747
|
-
const stopObserving = observe(
|
|
748
|
-
parseResult.value,
|
|
749
|
-
() => {
|
|
750
|
-
const value = parseResult.value();
|
|
751
|
-
const ctx = parseResult.context;
|
|
752
|
-
const obj = value[0];
|
|
753
|
-
if (!isObject(obj)) {
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
for (const item of Object.entries(obj)) {
|
|
757
|
-
const key = item[0];
|
|
758
|
-
const value2 = item[1];
|
|
759
|
-
const ctxKey = ctx[key];
|
|
760
|
-
if (ctxKey === value2) continue;
|
|
761
|
-
if (isRef(ctxKey)) {
|
|
762
|
-
ctxKey(value2);
|
|
763
|
-
} else {
|
|
764
|
-
ctx[key] = value2;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
},
|
|
768
|
-
true
|
|
769
|
-
);
|
|
770
|
-
return stopObserving;
|
|
771
|
-
}
|
|
772
|
-
};
|
|
773
|
-
|
|
774
769
|
// src/reactivity/entangle.ts
|
|
775
770
|
var entangle = (r1, r2) => {
|
|
776
771
|
if (r1 === r2) return () => {
|
|
@@ -1098,8 +1093,8 @@ var createModelBridge = (source) => {
|
|
|
1098
1093
|
};
|
|
1099
1094
|
var singlePropDirective = {
|
|
1100
1095
|
collectRefObj: true,
|
|
1101
|
-
|
|
1102
|
-
if (!option) return noop;
|
|
1096
|
+
mount: ({ parseResult, option }) => {
|
|
1097
|
+
if (typeof option !== "string" || !option) return noop;
|
|
1103
1098
|
const key = camelize(option);
|
|
1104
1099
|
let currentSource;
|
|
1105
1100
|
let bridge;
|
|
@@ -1120,44 +1115,44 @@ var singlePropDirective = {
|
|
|
1120
1115
|
stopEntangle = entangle(source, target);
|
|
1121
1116
|
currentSource = source;
|
|
1122
1117
|
};
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1125
|
-
()
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
if (bridge && ctxKey === bridge) {
|
|
1132
|
-
bridge(value);
|
|
1133
|
-
return;
|
|
1134
|
-
}
|
|
1135
|
-
resetSync();
|
|
1136
|
-
if (isRef(ctxKey)) {
|
|
1137
|
-
ctxKey(value);
|
|
1138
|
-
return;
|
|
1139
|
-
}
|
|
1140
|
-
ctx[key] = value;
|
|
1118
|
+
const apply = () => {
|
|
1119
|
+
var _a;
|
|
1120
|
+
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
1121
|
+
const ctx = parseResult.context;
|
|
1122
|
+
const ctxKey = ctx[key];
|
|
1123
|
+
if (!isRef(value)) {
|
|
1124
|
+
if (bridge && ctxKey === bridge) {
|
|
1125
|
+
bridge(value);
|
|
1141
1126
|
return;
|
|
1142
1127
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
syncRefs(value, ctxKey);
|
|
1147
|
-
} else {
|
|
1148
|
-
ctx[key] = value;
|
|
1149
|
-
}
|
|
1128
|
+
resetSync();
|
|
1129
|
+
if (isRef(ctxKey)) {
|
|
1130
|
+
ctxKey(value);
|
|
1150
1131
|
return;
|
|
1151
1132
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1133
|
+
ctx[key] = value;
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
if (isModelBridge(value)) {
|
|
1137
|
+
if (ctxKey === value) return;
|
|
1138
|
+
if (isRef(ctxKey)) {
|
|
1139
|
+
syncRefs(value, ctxKey);
|
|
1140
|
+
} else {
|
|
1141
|
+
ctx[key] = value;
|
|
1142
|
+
}
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
if (!bridge) bridge = createModelBridge(value);
|
|
1146
|
+
ctx[key] = bridge;
|
|
1147
|
+
syncRefs(value, bridge);
|
|
1148
|
+
};
|
|
1149
|
+
return {
|
|
1150
|
+
update: () => {
|
|
1151
|
+
apply();
|
|
1155
1152
|
},
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
stopEntangle();
|
|
1160
|
-
stopObserving();
|
|
1153
|
+
unmount: () => {
|
|
1154
|
+
stopEntangle();
|
|
1155
|
+
}
|
|
1161
1156
|
};
|
|
1162
1157
|
}
|
|
1163
1158
|
};
|
|
@@ -1178,7 +1173,10 @@ var ComponentBinder = class {
|
|
|
1178
1173
|
__getRegisteredComponentSelector(registeredComponents) {
|
|
1179
1174
|
if (this.__registeredComponentSize !== registeredComponents.size) {
|
|
1180
1175
|
const names = [...registeredComponents.keys()];
|
|
1181
|
-
this.__registeredComponentSelector =
|
|
1176
|
+
this.__registeredComponentSelector = [
|
|
1177
|
+
...names,
|
|
1178
|
+
...names.map(hyphenate)
|
|
1179
|
+
].join(",");
|
|
1182
1180
|
this.__registeredComponentSize = registeredComponents.size;
|
|
1183
1181
|
}
|
|
1184
1182
|
return this.__registeredComponentSelector;
|
|
@@ -1255,7 +1253,10 @@ var ComponentBinder = class {
|
|
|
1255
1253
|
definedProp
|
|
1256
1254
|
])
|
|
1257
1255
|
);
|
|
1258
|
-
for (const name of
|
|
1256
|
+
for (const name of [
|
|
1257
|
+
...definedProps,
|
|
1258
|
+
...definedProps.map(hyphenate)
|
|
1259
|
+
]) {
|
|
1259
1260
|
const value = component2.getAttribute(name);
|
|
1260
1261
|
if (value === null) continue;
|
|
1261
1262
|
props[camelize(name)] = value;
|
|
@@ -1550,18 +1551,17 @@ var DirectiveCollector = class {
|
|
|
1550
1551
|
}
|
|
1551
1552
|
};
|
|
1552
1553
|
const processNode = (node) => {
|
|
1553
|
-
var _a
|
|
1554
|
+
var _a;
|
|
1554
1555
|
const attrs = node.attributes;
|
|
1555
1556
|
if (!attrs || attrs.length === 0) return;
|
|
1556
|
-
const attrsAny = attrs;
|
|
1557
1557
|
for (let i = 0; i < attrs.length; ++i) {
|
|
1558
|
-
const name = (
|
|
1558
|
+
const name = (_a = attrs.item(i)) == null ? void 0 : _a.name;
|
|
1559
1559
|
if (!name) continue;
|
|
1560
1560
|
appendDirective(node, name);
|
|
1561
1561
|
}
|
|
1562
1562
|
};
|
|
1563
1563
|
processNode(element);
|
|
1564
|
-
if (!isRecursive) return map;
|
|
1564
|
+
if (!isRecursive || !element.firstElementChild) return map;
|
|
1565
1565
|
const nodes = element.querySelectorAll("*");
|
|
1566
1566
|
for (const node of nodes) {
|
|
1567
1567
|
processNode(node);
|
|
@@ -1571,6 +1571,8 @@ var DirectiveCollector = class {
|
|
|
1571
1571
|
};
|
|
1572
1572
|
|
|
1573
1573
|
// src/bind/DynamicBinder.ts
|
|
1574
|
+
var noopStopObserving2 = () => {
|
|
1575
|
+
};
|
|
1574
1576
|
var mount2 = (nodes, parent) => {
|
|
1575
1577
|
for (const x of nodes) {
|
|
1576
1578
|
const node = x.cloneNode(true);
|
|
@@ -1686,19 +1688,15 @@ var DynamicBinder = class {
|
|
|
1686
1688
|
mounted.name = name;
|
|
1687
1689
|
});
|
|
1688
1690
|
};
|
|
1689
|
-
|
|
1691
|
+
let stopObserver = noopStopObserving2;
|
|
1690
1692
|
const unbinder = () => {
|
|
1691
1693
|
parseResult.stop();
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
}
|
|
1695
|
-
stopObserverList.length = 0;
|
|
1694
|
+
stopObserver();
|
|
1695
|
+
stopObserver = noopStopObserving2;
|
|
1696
1696
|
};
|
|
1697
1697
|
addUnbinder(commentBegin, unbinder);
|
|
1698
1698
|
refresh();
|
|
1699
|
-
|
|
1700
|
-
};
|
|
1701
|
-
stopObserverList.push(stopObserving);
|
|
1699
|
+
stopObserver = parseResult.subscribe(refresh);
|
|
1702
1700
|
}
|
|
1703
1701
|
};
|
|
1704
1702
|
|
|
@@ -1708,6 +1706,274 @@ var unref = (value) => {
|
|
|
1708
1706
|
return anyValue != null && anyValue[srefSymbol] === 1 ? anyValue() : anyValue;
|
|
1709
1707
|
};
|
|
1710
1708
|
|
|
1709
|
+
// src/directives/html.ts
|
|
1710
|
+
var updateHtml = (el, values) => {
|
|
1711
|
+
const [value, replacer] = values;
|
|
1712
|
+
if (isFunction(replacer)) replacer(el, value);
|
|
1713
|
+
else el.innerHTML = value == null ? void 0 : value.toString();
|
|
1714
|
+
};
|
|
1715
|
+
var htmlDirective = {
|
|
1716
|
+
mount: () => ({
|
|
1717
|
+
update: ({ el, values }) => {
|
|
1718
|
+
updateHtml(el, values);
|
|
1719
|
+
}
|
|
1720
|
+
})
|
|
1721
|
+
};
|
|
1722
|
+
|
|
1723
|
+
// src/bind/ForBinderFastPath.ts
|
|
1724
|
+
var ForBinderFastPath = class _ForBinderFastPath {
|
|
1725
|
+
constructor(bindings) {
|
|
1726
|
+
__publicField(this, "__bindings");
|
|
1727
|
+
this.__bindings = bindings;
|
|
1728
|
+
}
|
|
1729
|
+
static __create(binder, nodes) {
|
|
1730
|
+
var _a, _b;
|
|
1731
|
+
const parser = binder.__parser;
|
|
1732
|
+
const config = binder.__config;
|
|
1733
|
+
const builtInNames = config.__builtInNames;
|
|
1734
|
+
const blockedBuiltIns = /* @__PURE__ */ new Set([
|
|
1735
|
+
builtInNames.for,
|
|
1736
|
+
builtInNames.if,
|
|
1737
|
+
builtInNames.else,
|
|
1738
|
+
builtInNames.elseif,
|
|
1739
|
+
builtInNames.pre
|
|
1740
|
+
]);
|
|
1741
|
+
const directiveMap = config.__directiveMap;
|
|
1742
|
+
const contextComponents = parser.__getComponents();
|
|
1743
|
+
if (Object.keys(contextComponents).length > 0 || config.__componentsUpperCase.size > 0) {
|
|
1744
|
+
return void 0;
|
|
1745
|
+
}
|
|
1746
|
+
const collector = binder.__directiveCollector;
|
|
1747
|
+
const bindings = [];
|
|
1748
|
+
let nodeIndex = 0;
|
|
1749
|
+
const stack = [];
|
|
1750
|
+
for (let i = nodes.length - 1; i >= 0; --i) {
|
|
1751
|
+
stack.push(nodes[i]);
|
|
1752
|
+
}
|
|
1753
|
+
while (stack.length > 0) {
|
|
1754
|
+
const node = stack.pop();
|
|
1755
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1756
|
+
const el = node;
|
|
1757
|
+
if (el.tagName === "TEMPLATE") return void 0;
|
|
1758
|
+
if (el.tagName.includes("-")) return void 0;
|
|
1759
|
+
const tagNameUpper = camelize(el.tagName).toUpperCase();
|
|
1760
|
+
if (config.__componentsUpperCase.has(tagNameUpper) || contextComponents[tagNameUpper]) {
|
|
1761
|
+
return void 0;
|
|
1762
|
+
}
|
|
1763
|
+
const attrs = el.attributes;
|
|
1764
|
+
for (let i = 0; i < attrs.length; ++i) {
|
|
1765
|
+
const attrName = (_a = attrs.item(i)) == null ? void 0 : _a.name;
|
|
1766
|
+
if (!attrName) continue;
|
|
1767
|
+
if (blockedBuiltIns.has(attrName)) return void 0;
|
|
1768
|
+
const { terms, flags } = collector.__parseName(attrName);
|
|
1769
|
+
const [name, option] = terms;
|
|
1770
|
+
const directive = (_b = directiveMap[attrName]) != null ? _b : directiveMap[name];
|
|
1771
|
+
if (!directive) continue;
|
|
1772
|
+
if (directive === htmlDirective) return void 0;
|
|
1773
|
+
bindings.push({
|
|
1774
|
+
nodeIndex,
|
|
1775
|
+
attrName,
|
|
1776
|
+
directive,
|
|
1777
|
+
option,
|
|
1778
|
+
flags
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
++nodeIndex;
|
|
1782
|
+
}
|
|
1783
|
+
const children = node.childNodes;
|
|
1784
|
+
for (let i = children.length - 1; i >= 0; --i) {
|
|
1785
|
+
stack.push(children[i]);
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
if (bindings.length === 0) return void 0;
|
|
1789
|
+
return new _ForBinderFastPath(bindings);
|
|
1790
|
+
}
|
|
1791
|
+
__bind(binder, nodes) {
|
|
1792
|
+
const elements = [];
|
|
1793
|
+
const stack = [];
|
|
1794
|
+
for (let i = nodes.length - 1; i >= 0; --i) {
|
|
1795
|
+
stack.push(nodes[i]);
|
|
1796
|
+
}
|
|
1797
|
+
while (stack.length > 0) {
|
|
1798
|
+
const node = stack.pop();
|
|
1799
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1800
|
+
elements.push(node);
|
|
1801
|
+
}
|
|
1802
|
+
const children = node.childNodes;
|
|
1803
|
+
for (let i = children.length - 1; i >= 0; --i) {
|
|
1804
|
+
stack.push(children[i]);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
for (let i = 0; i < this.__bindings.length; ++i) {
|
|
1808
|
+
const binding = this.__bindings[i];
|
|
1809
|
+
const el = elements[binding.nodeIndex];
|
|
1810
|
+
if (!el) continue;
|
|
1811
|
+
binder.__bind(
|
|
1812
|
+
binding.directive,
|
|
1813
|
+
el,
|
|
1814
|
+
binding.attrName,
|
|
1815
|
+
false,
|
|
1816
|
+
binding.option,
|
|
1817
|
+
binding.flags
|
|
1818
|
+
);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
};
|
|
1822
|
+
|
|
1823
|
+
// src/bind/ForBinderKeyedDiff.ts
|
|
1824
|
+
var moveMountItemBefore = (item, anchor) => {
|
|
1825
|
+
const parent = anchor.parentNode;
|
|
1826
|
+
if (!parent) return;
|
|
1827
|
+
for (let i = 0; i < item.items.length; ++i) {
|
|
1828
|
+
parent.insertBefore(item.items[i], anchor);
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1831
|
+
var getSequence = (arr) => {
|
|
1832
|
+
var _a;
|
|
1833
|
+
const len = arr.length;
|
|
1834
|
+
const p = arr.slice();
|
|
1835
|
+
const result = [];
|
|
1836
|
+
let u;
|
|
1837
|
+
let v;
|
|
1838
|
+
let c;
|
|
1839
|
+
for (let i = 0; i < len; ++i) {
|
|
1840
|
+
const value = arr[i];
|
|
1841
|
+
if (value === 0) continue;
|
|
1842
|
+
const j = result[result.length - 1];
|
|
1843
|
+
if (j === void 0 || arr[j] < value) {
|
|
1844
|
+
p[i] = j != null ? j : -1;
|
|
1845
|
+
result.push(i);
|
|
1846
|
+
continue;
|
|
1847
|
+
}
|
|
1848
|
+
u = 0;
|
|
1849
|
+
v = result.length - 1;
|
|
1850
|
+
while (u < v) {
|
|
1851
|
+
c = u + v >> 1;
|
|
1852
|
+
if (arr[result[c]] < value) u = c + 1;
|
|
1853
|
+
else v = c;
|
|
1854
|
+
}
|
|
1855
|
+
if (value < arr[result[u]]) {
|
|
1856
|
+
if (u > 0) p[i] = result[u - 1];
|
|
1857
|
+
result[u] = i;
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
u = result.length;
|
|
1861
|
+
v = (_a = result[u - 1]) != null ? _a : -1;
|
|
1862
|
+
while (u-- > 0) {
|
|
1863
|
+
result[u] = v;
|
|
1864
|
+
v = p[v];
|
|
1865
|
+
}
|
|
1866
|
+
return result;
|
|
1867
|
+
};
|
|
1868
|
+
var ForBinderKeyedDiff = class {
|
|
1869
|
+
/**
|
|
1870
|
+
* Applies keyed patch and returns the next ordered mount list.
|
|
1871
|
+
* Returns `undefined` when keyed mode is not safe for this update.
|
|
1872
|
+
*/
|
|
1873
|
+
static __patch(options) {
|
|
1874
|
+
const {
|
|
1875
|
+
oldItems,
|
|
1876
|
+
newValues,
|
|
1877
|
+
getKey,
|
|
1878
|
+
isSameValue,
|
|
1879
|
+
mountNewValue,
|
|
1880
|
+
removeMountItem,
|
|
1881
|
+
endAnchor
|
|
1882
|
+
} = options;
|
|
1883
|
+
const oldLen = oldItems.length;
|
|
1884
|
+
const newLen = newValues.length;
|
|
1885
|
+
const newKeys = new Array(newLen);
|
|
1886
|
+
const keySeen = /* @__PURE__ */ new Set();
|
|
1887
|
+
for (let i2 = 0; i2 < newLen; ++i2) {
|
|
1888
|
+
const key = getKey(newValues[i2]);
|
|
1889
|
+
if (key === void 0 || keySeen.has(key)) return void 0;
|
|
1890
|
+
keySeen.add(key);
|
|
1891
|
+
newKeys[i2] = key;
|
|
1892
|
+
}
|
|
1893
|
+
const newMountItems = new Array(newLen);
|
|
1894
|
+
let i = 0;
|
|
1895
|
+
let e1 = oldLen - 1;
|
|
1896
|
+
let e2 = newLen - 1;
|
|
1897
|
+
while (i <= e1 && i <= e2) {
|
|
1898
|
+
const oldItem = oldItems[i];
|
|
1899
|
+
if (getKey(oldItem.value) !== newKeys[i]) break;
|
|
1900
|
+
if (!isSameValue(oldItem.value, newValues[i])) break;
|
|
1901
|
+
oldItem.value = newValues[i];
|
|
1902
|
+
newMountItems[i] = oldItem;
|
|
1903
|
+
++i;
|
|
1904
|
+
}
|
|
1905
|
+
while (i <= e1 && i <= e2) {
|
|
1906
|
+
const oldItem = oldItems[e1];
|
|
1907
|
+
if (getKey(oldItem.value) !== newKeys[e2]) break;
|
|
1908
|
+
if (!isSameValue(oldItem.value, newValues[e2])) break;
|
|
1909
|
+
oldItem.value = newValues[e2];
|
|
1910
|
+
newMountItems[e2] = oldItem;
|
|
1911
|
+
--e1;
|
|
1912
|
+
--e2;
|
|
1913
|
+
}
|
|
1914
|
+
if (i > e1) {
|
|
1915
|
+
for (let k = e2; k >= i; --k) {
|
|
1916
|
+
const anchor = k + 1 < newLen ? newMountItems[k + 1].items[0] : endAnchor;
|
|
1917
|
+
newMountItems[k] = mountNewValue(k, newValues[k], anchor);
|
|
1918
|
+
}
|
|
1919
|
+
return newMountItems;
|
|
1920
|
+
}
|
|
1921
|
+
if (i > e2) {
|
|
1922
|
+
for (let k = i; k <= e1; ++k) removeMountItem(oldItems[k]);
|
|
1923
|
+
return newMountItems;
|
|
1924
|
+
}
|
|
1925
|
+
const s1 = i;
|
|
1926
|
+
const s2 = i;
|
|
1927
|
+
const toBePatched = e2 - s2 + 1;
|
|
1928
|
+
const newIndexToOldIndexMap = new Array(toBePatched).fill(0);
|
|
1929
|
+
const keyToNewIndexMap = /* @__PURE__ */ new Map();
|
|
1930
|
+
for (let k = s2; k <= e2; ++k) {
|
|
1931
|
+
keyToNewIndexMap.set(newKeys[k], k);
|
|
1932
|
+
}
|
|
1933
|
+
let moved = false;
|
|
1934
|
+
let maxNewIndexSoFar = 0;
|
|
1935
|
+
for (let k = s1; k <= e1; ++k) {
|
|
1936
|
+
const oldItem = oldItems[k];
|
|
1937
|
+
const newIndex = keyToNewIndexMap.get(getKey(oldItem.value));
|
|
1938
|
+
if (newIndex === void 0) {
|
|
1939
|
+
removeMountItem(oldItem);
|
|
1940
|
+
continue;
|
|
1941
|
+
}
|
|
1942
|
+
if (!isSameValue(oldItem.value, newValues[newIndex])) {
|
|
1943
|
+
removeMountItem(oldItem);
|
|
1944
|
+
continue;
|
|
1945
|
+
}
|
|
1946
|
+
oldItem.value = newValues[newIndex];
|
|
1947
|
+
newMountItems[newIndex] = oldItem;
|
|
1948
|
+
newIndexToOldIndexMap[newIndex - s2] = k + 1;
|
|
1949
|
+
if (newIndex >= maxNewIndexSoFar) maxNewIndexSoFar = newIndex;
|
|
1950
|
+
else moved = true;
|
|
1951
|
+
}
|
|
1952
|
+
const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : [];
|
|
1953
|
+
let seqIdx = increasingNewIndexSequence.length - 1;
|
|
1954
|
+
for (let k = toBePatched - 1; k >= 0; --k) {
|
|
1955
|
+
const newIndex = s2 + k;
|
|
1956
|
+
const anchor = newIndex + 1 < newLen ? newMountItems[newIndex + 1].items[0] : endAnchor;
|
|
1957
|
+
if (newIndexToOldIndexMap[k] === 0) {
|
|
1958
|
+
newMountItems[newIndex] = mountNewValue(
|
|
1959
|
+
newIndex,
|
|
1960
|
+
newValues[newIndex],
|
|
1961
|
+
anchor
|
|
1962
|
+
);
|
|
1963
|
+
continue;
|
|
1964
|
+
}
|
|
1965
|
+
const item = newMountItems[newIndex];
|
|
1966
|
+
if (!moved) continue;
|
|
1967
|
+
if (seqIdx >= 0 && increasingNewIndexSequence[seqIdx] === k) {
|
|
1968
|
+
--seqIdx;
|
|
1969
|
+
} else if (item) {
|
|
1970
|
+
moveMountItemBefore(item, anchor);
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
return newMountItems;
|
|
1974
|
+
}
|
|
1975
|
+
};
|
|
1976
|
+
|
|
1711
1977
|
// src/bind/MountList.ts
|
|
1712
1978
|
var MountList = class {
|
|
1713
1979
|
constructor(getKey) {
|
|
@@ -1789,6 +2055,8 @@ var MountList = class {
|
|
|
1789
2055
|
// src/bind/ForBinder.ts
|
|
1790
2056
|
var forMarker = Symbol("r-for");
|
|
1791
2057
|
var noIndexRef = (_) => -1;
|
|
2058
|
+
var noopStopObserving3 = () => {
|
|
2059
|
+
};
|
|
1792
2060
|
var _ForBinder = class _ForBinder {
|
|
1793
2061
|
constructor(binder) {
|
|
1794
2062
|
__publicField(this, "__binder");
|
|
@@ -1859,6 +2127,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1859
2127
|
el.removeAttribute(nameKey);
|
|
1860
2128
|
el.removeAttribute(nameKeyBind);
|
|
1861
2129
|
const nodes = getNodes(el);
|
|
2130
|
+
const fastPath = ForBinderFastPath.__create(this.__binder, nodes);
|
|
1862
2131
|
const parent = el.parentNode;
|
|
1863
2132
|
if (!parent) return;
|
|
1864
2133
|
const title = `${this.__for} => ${forPath}`;
|
|
@@ -1878,6 +2147,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1878
2147
|
const rowContexts = singleCapturedContext ? [void 0, capturedContext[0]] : void 0;
|
|
1879
2148
|
const getKey = this.__createKeyGetter(keyExpression);
|
|
1880
2149
|
const areEqual = (a, b) => getKey(a) === getKey(b);
|
|
2150
|
+
const isSameValue = (a, b) => a === b;
|
|
1881
2151
|
const mountNewValue = (i2, newValue, nextSibling) => {
|
|
1882
2152
|
const result = config.createContext(newValue, i2);
|
|
1883
2153
|
const mountItem = MountList.__createItem(result.index, newValue);
|
|
@@ -1891,7 +2161,8 @@ var _ForBinder = class _ForBinder {
|
|
|
1891
2161
|
insertParent.insertBefore(node, nextSibling);
|
|
1892
2162
|
childNodes.push(node);
|
|
1893
2163
|
}
|
|
1894
|
-
|
|
2164
|
+
if (fastPath) fastPath.__bind(binder, childNodes);
|
|
2165
|
+
else bindChildNodes(binder, childNodes);
|
|
1895
2166
|
start = start.nextSibling;
|
|
1896
2167
|
while (start !== nextSibling) {
|
|
1897
2168
|
mountItem.items.push(start);
|
|
@@ -1943,16 +2214,51 @@ var _ForBinder = class _ForBinder {
|
|
|
1943
2214
|
mountList.__removeAllAfter(0);
|
|
1944
2215
|
return;
|
|
1945
2216
|
}
|
|
2217
|
+
const iterableValues = [];
|
|
2218
|
+
for (const value2 of this.__getIterable(newValues[0])) {
|
|
2219
|
+
iterableValues.push(value2);
|
|
2220
|
+
}
|
|
2221
|
+
const patched = ForBinderKeyedDiff.__patch({
|
|
2222
|
+
oldItems: mountList.__list,
|
|
2223
|
+
newValues: iterableValues,
|
|
2224
|
+
getKey,
|
|
2225
|
+
isSameValue,
|
|
2226
|
+
mountNewValue: (index, value2, nextSibling) => mountNewValue(index, value2, nextSibling),
|
|
2227
|
+
removeMountItem: (item) => {
|
|
2228
|
+
for (let k = 0; k < item.items.length; ++k) {
|
|
2229
|
+
removeNode(item.items[k]);
|
|
2230
|
+
}
|
|
2231
|
+
},
|
|
2232
|
+
endAnchor: commentEnd
|
|
2233
|
+
});
|
|
2234
|
+
if (patched) {
|
|
2235
|
+
mountList.__list = patched;
|
|
2236
|
+
mountList.__valueMap.clear();
|
|
2237
|
+
for (let k = 0; k < patched.length; ++k) {
|
|
2238
|
+
const item = patched[k];
|
|
2239
|
+
item.order = k;
|
|
2240
|
+
item.index(k);
|
|
2241
|
+
const key = getKey(item.value);
|
|
2242
|
+
if (key !== void 0) {
|
|
2243
|
+
mountList.__valueMap.set(key, item);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
return;
|
|
2247
|
+
}
|
|
1946
2248
|
let i2 = 0;
|
|
1947
2249
|
let firstRemovalOrInsertionIndex = Number.MAX_SAFE_INTEGER;
|
|
1948
2250
|
const initialLength = len;
|
|
1949
2251
|
const forGrowThreshold = this.__binder.__config.forGrowThreshold;
|
|
1950
2252
|
const shouldGrowList = () => mountList.__length < initialLength + forGrowThreshold;
|
|
1951
|
-
for (const newValue of
|
|
2253
|
+
for (const newValue of iterableValues) {
|
|
1952
2254
|
const modify = () => {
|
|
1953
2255
|
if (i2 < len) {
|
|
1954
2256
|
const mountItem = mountList.__get(i2++);
|
|
1955
|
-
if (areEqual(mountItem.value, newValue))
|
|
2257
|
+
if (areEqual(mountItem.value, newValue)) {
|
|
2258
|
+
if (isSameValue(mountItem.value, newValue)) return;
|
|
2259
|
+
replace(i2 - 1, newValue);
|
|
2260
|
+
return;
|
|
2261
|
+
}
|
|
1956
2262
|
const newValueMountPosition = mountList.__lookupValueOrderIfMounted(
|
|
1957
2263
|
getKey(newValue)
|
|
1958
2264
|
);
|
|
@@ -2002,24 +2308,21 @@ var _ForBinder = class _ForBinder {
|
|
|
2002
2308
|
mountList.__removeAllAfter(j);
|
|
2003
2309
|
updateIndexes(firstRemovalOrInsertionIndex);
|
|
2004
2310
|
};
|
|
2005
|
-
const observeTailChanges = () => {
|
|
2006
|
-
stopObserving = parseResult.subscribe ? parseResult.subscribe(updateDom) : () => {
|
|
2007
|
-
};
|
|
2008
|
-
};
|
|
2009
2311
|
const unbinder = () => {
|
|
2010
2312
|
parseResult.stop();
|
|
2011
2313
|
stopObserving();
|
|
2314
|
+
stopObserving = noopStopObserving3;
|
|
2012
2315
|
};
|
|
2013
2316
|
const parseResult = parser.__parse(config.list);
|
|
2014
2317
|
const value = parseResult.value;
|
|
2015
|
-
let stopObserving;
|
|
2318
|
+
let stopObserving = noopStopObserving3;
|
|
2016
2319
|
let i = 0;
|
|
2017
2320
|
const mountList = new MountList(getKey);
|
|
2018
2321
|
for (const item of this.__getIterable(value()[0])) {
|
|
2019
2322
|
mountList.__push(mountNewValue(i++, item, commentEnd));
|
|
2020
2323
|
}
|
|
2021
2324
|
addUnbinder(commentBegin, unbinder);
|
|
2022
|
-
|
|
2325
|
+
stopObserving = parseResult.subscribe(updateDom);
|
|
2023
2326
|
}
|
|
2024
2327
|
__parseForPath(forPath) {
|
|
2025
2328
|
var _a, _b;
|
|
@@ -2203,105 +2506,111 @@ var Binder = class {
|
|
|
2203
2506
|
return true;
|
|
2204
2507
|
}
|
|
2205
2508
|
__bindToExpression(config, el, valueExpression, option, flags) {
|
|
2206
|
-
var _a;
|
|
2207
2509
|
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null) return;
|
|
2208
2510
|
if (this.__handleTeleport(config, el, valueExpression)) return;
|
|
2209
|
-
const
|
|
2511
|
+
const dynamicOption = this.__parseDynamicOption(option, config.once);
|
|
2512
|
+
const result = this.__parseExpression(config, valueExpression);
|
|
2513
|
+
const stops = this.__createBindStops(result, dynamicOption);
|
|
2514
|
+
addUnbinder(el, stops.stop);
|
|
2515
|
+
const payload = this.__createDirectivePayload(
|
|
2516
|
+
el,
|
|
2517
|
+
valueExpression,
|
|
2518
|
+
result,
|
|
2519
|
+
dynamicOption,
|
|
2520
|
+
option,
|
|
2521
|
+
flags
|
|
2522
|
+
);
|
|
2523
|
+
const mountedUpdate = this.__mountDirective(config, payload, stops);
|
|
2524
|
+
if (!mountedUpdate) return;
|
|
2525
|
+
const emitChange = this.__createEmitter(
|
|
2526
|
+
payload,
|
|
2527
|
+
result,
|
|
2528
|
+
dynamicOption,
|
|
2529
|
+
option,
|
|
2530
|
+
mountedUpdate
|
|
2531
|
+
);
|
|
2532
|
+
emitChange();
|
|
2533
|
+
if (!config.once) {
|
|
2534
|
+
stops.result = result.subscribe(emitChange);
|
|
2535
|
+
if (dynamicOption) {
|
|
2536
|
+
stops.dynamic = dynamicOption.subscribe(emitChange);
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
__parseDynamicOption(option, once) {
|
|
2541
|
+
const dynamicOptionExpression = isOptionDynamic(option, this.__dynamic);
|
|
2542
|
+
if (!dynamicOptionExpression) return void 0;
|
|
2543
|
+
return this.__parser.__parse(
|
|
2544
|
+
camelize(dynamicOptionExpression),
|
|
2545
|
+
void 0,
|
|
2546
|
+
void 0,
|
|
2547
|
+
void 0,
|
|
2548
|
+
once
|
|
2549
|
+
);
|
|
2550
|
+
}
|
|
2551
|
+
__parseExpression(config, valueExpression) {
|
|
2552
|
+
return this.__parser.__parse(
|
|
2210
2553
|
valueExpression,
|
|
2211
2554
|
config.isLazy,
|
|
2212
2555
|
config.isLazyKey,
|
|
2213
2556
|
config.collectRefObj,
|
|
2214
2557
|
config.once
|
|
2215
2558
|
);
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
const
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2559
|
+
}
|
|
2560
|
+
__createBindStops(result, dynamicOption) {
|
|
2561
|
+
const stops = {
|
|
2562
|
+
stop: () => {
|
|
2563
|
+
var _a, _b, _c;
|
|
2564
|
+
result.stop();
|
|
2565
|
+
dynamicOption == null ? void 0 : dynamicOption.stop();
|
|
2566
|
+
(_a = stops.result) == null ? void 0 : _a.call(stops);
|
|
2567
|
+
(_b = stops.dynamic) == null ? void 0 : _b.call(stops);
|
|
2568
|
+
(_c = stops.mounted) == null ? void 0 : _c.call(stops);
|
|
2569
|
+
stops.result = void 0;
|
|
2570
|
+
stops.dynamic = void 0;
|
|
2571
|
+
stops.mounted = void 0;
|
|
2223
2572
|
}
|
|
2224
|
-
stopObserverList.length = 0;
|
|
2225
2573
|
};
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2574
|
+
return stops;
|
|
2575
|
+
}
|
|
2576
|
+
__createDirectivePayload(el, expr, result, dynamicOption, option, flags) {
|
|
2577
|
+
return {
|
|
2578
|
+
el,
|
|
2579
|
+
expr,
|
|
2580
|
+
values: result.value(),
|
|
2581
|
+
previousValues: void 0,
|
|
2582
|
+
option: dynamicOption ? dynamicOption.value()[0] : option,
|
|
2583
|
+
previousOption: void 0,
|
|
2584
|
+
flags,
|
|
2585
|
+
parseResult: result,
|
|
2586
|
+
dynamicOption
|
|
2587
|
+
};
|
|
2588
|
+
}
|
|
2589
|
+
__mountDirective(config, payload, stops) {
|
|
2590
|
+
const mounted = config.mount(payload);
|
|
2591
|
+
if (typeof mounted === "function") {
|
|
2592
|
+
stops.mounted = mounted;
|
|
2593
|
+
return void 0;
|
|
2237
2594
|
}
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
let previousValues = result.value();
|
|
2241
|
-
let previousOption = hasDynamicOption ? dynamicOption.value()[0] : option;
|
|
2242
|
-
if (!config.once && hasOnChange) {
|
|
2243
|
-
const stopObserving = result.subscribe ? result.subscribe(() => {
|
|
2244
|
-
var _a2;
|
|
2245
|
-
const preValues = previousValues;
|
|
2246
|
-
const preOption = previousOption;
|
|
2247
|
-
const nextValues = result.value();
|
|
2248
|
-
const nextOption = hasDynamicOption ? dynamicOpt.value()[0] : option;
|
|
2249
|
-
previousValues = nextValues;
|
|
2250
|
-
previousOption = nextOption;
|
|
2251
|
-
(_a2 = config.onChange) == null ? void 0 : _a2.call(
|
|
2252
|
-
config,
|
|
2253
|
-
el,
|
|
2254
|
-
nextValues,
|
|
2255
|
-
preValues,
|
|
2256
|
-
nextOption,
|
|
2257
|
-
preOption,
|
|
2258
|
-
flags
|
|
2259
|
-
);
|
|
2260
|
-
}) : () => {
|
|
2261
|
-
};
|
|
2262
|
-
stopObserverList.push(stopObserving);
|
|
2263
|
-
if (dynamicOpt) {
|
|
2264
|
-
const stopObserving2 = dynamicOpt.subscribe ? dynamicOpt.subscribe(() => {
|
|
2265
|
-
var _a2;
|
|
2266
|
-
const preOption = previousOption;
|
|
2267
|
-
const nextValues = result.value();
|
|
2268
|
-
const nextOption = dynamicOpt.value()[0];
|
|
2269
|
-
previousValues = nextValues;
|
|
2270
|
-
previousOption = nextOption;
|
|
2271
|
-
(_a2 = config.onChange) == null ? void 0 : _a2.call(
|
|
2272
|
-
config,
|
|
2273
|
-
el,
|
|
2274
|
-
nextValues,
|
|
2275
|
-
preOption,
|
|
2276
|
-
nextOption,
|
|
2277
|
-
preOption,
|
|
2278
|
-
flags
|
|
2279
|
-
);
|
|
2280
|
-
}) : () => {
|
|
2281
|
-
};
|
|
2282
|
-
stopObserverList.push(stopObserving2);
|
|
2283
|
-
}
|
|
2595
|
+
if (mounted == null ? void 0 : mounted.unmount) {
|
|
2596
|
+
stops.mounted = mounted.unmount;
|
|
2284
2597
|
}
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
previousOption,
|
|
2302
|
-
void 0,
|
|
2303
|
-
flags
|
|
2304
|
-
);
|
|
2598
|
+
return mounted == null ? void 0 : mounted.update;
|
|
2599
|
+
}
|
|
2600
|
+
__createEmitter(payload, result, dynamicOption, option, mountedUpdate) {
|
|
2601
|
+
let previousValues;
|
|
2602
|
+
let previousOption;
|
|
2603
|
+
return () => {
|
|
2604
|
+
const nextValues = result.value();
|
|
2605
|
+
const nextOption = dynamicOption ? dynamicOption.value()[0] : option;
|
|
2606
|
+
payload.values = nextValues;
|
|
2607
|
+
payload.previousValues = previousValues;
|
|
2608
|
+
payload.option = nextOption;
|
|
2609
|
+
payload.previousOption = previousOption;
|
|
2610
|
+
previousValues = nextValues;
|
|
2611
|
+
previousOption = nextOption;
|
|
2612
|
+
mountedUpdate(payload);
|
|
2613
|
+
};
|
|
2305
2614
|
}
|
|
2306
2615
|
};
|
|
2307
2616
|
|
|
@@ -2338,39 +2647,51 @@ var booleanAttributes = {
|
|
|
2338
2647
|
function includeBooleanAttr(value) {
|
|
2339
2648
|
return !!value || value === "";
|
|
2340
2649
|
}
|
|
2341
|
-
var
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
if (option)
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
const previousKey = p && key in p ? key : void 0;
|
|
2363
|
-
patchAttribute(el, key, value, previousKey);
|
|
2364
|
-
}
|
|
2365
|
-
} else {
|
|
2366
|
-
const previousKey = previousValues == null ? void 0 : previousValues[i];
|
|
2367
|
-
const key = values[i++];
|
|
2368
|
-
const value = values[i];
|
|
2650
|
+
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
2651
|
+
var _a;
|
|
2652
|
+
if (option) {
|
|
2653
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
2654
|
+
patchAttribute(el, option, values[0], previousOption);
|
|
2655
|
+
return;
|
|
2656
|
+
}
|
|
2657
|
+
const len = values.length;
|
|
2658
|
+
for (let i = 0; i < len; ++i) {
|
|
2659
|
+
const next = values[i];
|
|
2660
|
+
if (isArray(next)) {
|
|
2661
|
+
const previousKey = (_a = previousValues == null ? void 0 : previousValues[i]) == null ? void 0 : _a[0];
|
|
2662
|
+
const key = next[0];
|
|
2663
|
+
const value = next[1];
|
|
2664
|
+
patchAttribute(el, key, value, previousKey);
|
|
2665
|
+
} else if (isObject(next)) {
|
|
2666
|
+
for (const item of Object.entries(next)) {
|
|
2667
|
+
const key = item[0];
|
|
2668
|
+
const value = item[1];
|
|
2669
|
+
const p = previousValues == null ? void 0 : previousValues[i];
|
|
2670
|
+
const previousKey = p && key in p ? key : void 0;
|
|
2369
2671
|
patchAttribute(el, key, value, previousKey);
|
|
2370
2672
|
}
|
|
2673
|
+
} else {
|
|
2674
|
+
const previousKey = previousValues == null ? void 0 : previousValues[i];
|
|
2675
|
+
const key = values[i++];
|
|
2676
|
+
const value = values[i];
|
|
2677
|
+
patchAttribute(el, key, value, previousKey);
|
|
2371
2678
|
}
|
|
2372
2679
|
}
|
|
2373
2680
|
};
|
|
2681
|
+
var attrDirective = {
|
|
2682
|
+
mount: () => ({
|
|
2683
|
+
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
2684
|
+
updateAttr(
|
|
2685
|
+
el,
|
|
2686
|
+
values,
|
|
2687
|
+
previousValues,
|
|
2688
|
+
option,
|
|
2689
|
+
previousOption,
|
|
2690
|
+
flags
|
|
2691
|
+
);
|
|
2692
|
+
}
|
|
2693
|
+
})
|
|
2694
|
+
};
|
|
2374
2695
|
var patchAttribute = (el, key, value, previousKey) => {
|
|
2375
2696
|
if (previousKey && previousKey !== key) {
|
|
2376
2697
|
el.removeAttribute(previousKey);
|
|
@@ -2404,23 +2725,28 @@ var patchAttribute = (el, key, value, previousKey) => {
|
|
|
2404
2725
|
};
|
|
2405
2726
|
|
|
2406
2727
|
// src/directives/class.ts
|
|
2407
|
-
var
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
patchClass(el, next[j], previous == null ? void 0 : previous[j]);
|
|
2417
|
-
}
|
|
2418
|
-
} else {
|
|
2419
|
-
patchClass(el, next, previous);
|
|
2728
|
+
var updateClass = (el, values, previousValues) => {
|
|
2729
|
+
const len = values.length;
|
|
2730
|
+
for (let i = 0; i < len; ++i) {
|
|
2731
|
+
const next = values[i];
|
|
2732
|
+
const previous = previousValues == null ? void 0 : previousValues[i];
|
|
2733
|
+
if (isArray(next)) {
|
|
2734
|
+
const len2 = next.length;
|
|
2735
|
+
for (let j = 0; j < len2; ++j) {
|
|
2736
|
+
patchClass(el, next[j], previous == null ? void 0 : previous[j]);
|
|
2420
2737
|
}
|
|
2738
|
+
} else {
|
|
2739
|
+
patchClass(el, next, previous);
|
|
2421
2740
|
}
|
|
2422
2741
|
}
|
|
2423
2742
|
};
|
|
2743
|
+
var classDirective = {
|
|
2744
|
+
mount: () => ({
|
|
2745
|
+
update: ({ el, values, previousValues }) => {
|
|
2746
|
+
updateClass(el, values, previousValues);
|
|
2747
|
+
}
|
|
2748
|
+
})
|
|
2749
|
+
};
|
|
2424
2750
|
var patchClass = (el, next, prev) => {
|
|
2425
2751
|
const classList = el.classList;
|
|
2426
2752
|
const isClassString = isString(next);
|
|
@@ -2448,15 +2774,6 @@ var patchClass = (el, next, prev) => {
|
|
|
2448
2774
|
}
|
|
2449
2775
|
};
|
|
2450
2776
|
|
|
2451
|
-
// src/directives/html.ts
|
|
2452
|
-
var htmlDirective = {
|
|
2453
|
-
onChange: (el, values) => {
|
|
2454
|
-
const [value, replacer] = values;
|
|
2455
|
-
if (isFunction(replacer)) replacer(el, value);
|
|
2456
|
-
else el.innerHTML = value == null ? void 0 : value.toString();
|
|
2457
|
-
}
|
|
2458
|
-
};
|
|
2459
|
-
|
|
2460
2777
|
// src/common/looseEqual.ts
|
|
2461
2778
|
function looseCompareArrays(a, b) {
|
|
2462
2779
|
if (a.length !== b.length) return false;
|
|
@@ -2529,12 +2846,12 @@ var resume = (source) => {
|
|
|
2529
2846
|
|
|
2530
2847
|
// src/directives/model.ts
|
|
2531
2848
|
var modelDirective = {
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
}
|
|
2849
|
+
mount: ({ el, parseResult, flags }) => ({
|
|
2850
|
+
update: ({ values }) => {
|
|
2851
|
+
updateDomElementValue(el, values[0]);
|
|
2852
|
+
},
|
|
2853
|
+
unmount: attachDOMChangeListener(el, parseResult, flags)
|
|
2854
|
+
})
|
|
2538
2855
|
};
|
|
2539
2856
|
var updateDomElementValue = (el, value) => {
|
|
2540
2857
|
const isAnInput = isInput(el);
|
|
@@ -2840,66 +3157,75 @@ var getFlags2 = (flags) => {
|
|
|
2840
3157
|
}
|
|
2841
3158
|
return result;
|
|
2842
3159
|
};
|
|
3160
|
+
var bindOn = (el, parseResult, option, dynamicOption, flags) => {
|
|
3161
|
+
var _a, _b;
|
|
3162
|
+
if (dynamicOption) {
|
|
3163
|
+
const values2 = parseResult.value();
|
|
3164
|
+
const option2 = unref(dynamicOption.value()[0]);
|
|
3165
|
+
if (!isString(option2)) return () => {
|
|
3166
|
+
};
|
|
3167
|
+
return attachEventListener(
|
|
3168
|
+
el,
|
|
3169
|
+
camelize(option2),
|
|
3170
|
+
() => parseResult.value()[0],
|
|
3171
|
+
(_a = flags == null ? void 0 : flags.join(",")) != null ? _a : values2[1]
|
|
3172
|
+
);
|
|
3173
|
+
} else if (option) {
|
|
3174
|
+
const values2 = parseResult.value();
|
|
3175
|
+
return attachEventListener(
|
|
3176
|
+
el,
|
|
3177
|
+
camelize(option),
|
|
3178
|
+
() => parseResult.value()[0],
|
|
3179
|
+
(_b = flags == null ? void 0 : flags.join(",")) != null ? _b : values2[1]
|
|
3180
|
+
);
|
|
3181
|
+
}
|
|
3182
|
+
const unbinders = [];
|
|
3183
|
+
const unbinder = () => {
|
|
3184
|
+
unbinders.forEach((x) => x());
|
|
3185
|
+
};
|
|
3186
|
+
const values = parseResult.value();
|
|
3187
|
+
const len = values.length;
|
|
3188
|
+
for (let i = 0; i < len; ++i) {
|
|
3189
|
+
let next = values[i];
|
|
3190
|
+
if (isFunction(next)) next = next();
|
|
3191
|
+
if (isObject(next)) {
|
|
3192
|
+
for (const item of Object.entries(next)) {
|
|
3193
|
+
const eventType = item[0];
|
|
3194
|
+
const method = () => {
|
|
3195
|
+
let obj = parseResult.value()[i];
|
|
3196
|
+
if (isFunction(obj)) obj = obj();
|
|
3197
|
+
obj = obj[eventType];
|
|
3198
|
+
if (isFunction(obj)) obj = obj();
|
|
3199
|
+
return obj;
|
|
3200
|
+
};
|
|
3201
|
+
const flags2 = next[eventType + "_flags"];
|
|
3202
|
+
unbinders.push(attachEventListener(el, eventType, method, flags2));
|
|
3203
|
+
}
|
|
3204
|
+
} else {
|
|
3205
|
+
warning(2 /* BindingRequiresObjectExpressions */, "r-on", el);
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
return unbinder;
|
|
3209
|
+
};
|
|
2843
3210
|
var onDirective = {
|
|
2844
3211
|
isLazy: (i, d) => d === -1 && i % 2 === 0,
|
|
2845
3212
|
isLazyKey: (key, d) => d === 0 && !key.endsWith("_flags"),
|
|
2846
3213
|
once: false,
|
|
2847
3214
|
collectRefObj: true,
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
el,
|
|
2857
|
-
camelize(option2),
|
|
2858
|
-
() => parseResult.value()[0],
|
|
2859
|
-
(_a = flags == null ? void 0 : flags.join(",")) != null ? _a : values2[1]
|
|
2860
|
-
);
|
|
2861
|
-
} else if (option) {
|
|
2862
|
-
const values2 = parseResult.value();
|
|
2863
|
-
return attachEventListener(
|
|
2864
|
-
el,
|
|
2865
|
-
camelize(option),
|
|
2866
|
-
() => parseResult.value()[0],
|
|
2867
|
-
(_b = flags == null ? void 0 : flags.join(",")) != null ? _b : values2[1]
|
|
2868
|
-
);
|
|
2869
|
-
}
|
|
2870
|
-
const unbinders = [];
|
|
2871
|
-
const unbinder = () => {
|
|
2872
|
-
unbinders.forEach((x) => x());
|
|
2873
|
-
};
|
|
2874
|
-
const values = parseResult.value();
|
|
2875
|
-
const len = values.length;
|
|
2876
|
-
for (let i = 0; i < len; ++i) {
|
|
2877
|
-
let next = values[i];
|
|
2878
|
-
if (isFunction(next)) next = next();
|
|
2879
|
-
if (isObject(next)) {
|
|
2880
|
-
for (const item of Object.entries(next)) {
|
|
2881
|
-
const eventType = item[0];
|
|
2882
|
-
const method = () => {
|
|
2883
|
-
let obj = parseResult.value()[i];
|
|
2884
|
-
if (isFunction(obj)) obj = obj();
|
|
2885
|
-
obj = obj[eventType];
|
|
2886
|
-
if (isFunction(obj)) obj = obj();
|
|
2887
|
-
return obj;
|
|
2888
|
-
};
|
|
2889
|
-
const flags2 = next[eventType + "_flags"];
|
|
2890
|
-
unbinders.push(attachEventListener(el, eventType, method, flags2));
|
|
2891
|
-
}
|
|
2892
|
-
} else {
|
|
2893
|
-
warning(2 /* BindingRequiresObjectExpressions */, "r-on", el);
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
return unbinder;
|
|
3215
|
+
mount: ({ el, parseResult, option, dynamicOption, flags }) => {
|
|
3216
|
+
return bindOn(
|
|
3217
|
+
el,
|
|
3218
|
+
parseResult,
|
|
3219
|
+
option,
|
|
3220
|
+
dynamicOption,
|
|
3221
|
+
flags
|
|
3222
|
+
);
|
|
2897
3223
|
}
|
|
2898
3224
|
};
|
|
2899
3225
|
var getShouldExecuteEvent = (eventType, flags) => {
|
|
2900
3226
|
if (eventType.startsWith("keydown") || eventType.startsWith("keyup") || eventType.startsWith("keypress")) {
|
|
2901
3227
|
flags != null ? flags : flags = "";
|
|
2902
|
-
const parts = eventType.split(".")
|
|
3228
|
+
const parts = [...eventType.split("."), ...flags.split(",")];
|
|
2903
3229
|
eventType = parts[0];
|
|
2904
3230
|
const keyType = parts[1];
|
|
2905
3231
|
const isCtrl = parts.includes("ctrl");
|
|
@@ -2972,34 +3298,39 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
2972
3298
|
};
|
|
2973
3299
|
|
|
2974
3300
|
// src/directives/prop.ts
|
|
2975
|
-
var
|
|
2976
|
-
|
|
2977
|
-
if (option)
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
const value = item[1];
|
|
2993
|
-
patchProp(el, key, value);
|
|
2994
|
-
}
|
|
2995
|
-
} else {
|
|
2996
|
-
const key = values[i++];
|
|
2997
|
-
const value = values[i];
|
|
3301
|
+
var updatePropBinding = (el, values, option, flags) => {
|
|
3302
|
+
if (option) {
|
|
3303
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3304
|
+
patchProp(el, option, values[0]);
|
|
3305
|
+
return;
|
|
3306
|
+
}
|
|
3307
|
+
const len = values.length;
|
|
3308
|
+
for (let i = 0; i < len; ++i) {
|
|
3309
|
+
const next = values[i];
|
|
3310
|
+
if (isArray(next)) {
|
|
3311
|
+
const key = next[0];
|
|
3312
|
+
const value = next[1];
|
|
3313
|
+
patchProp(el, key, value);
|
|
3314
|
+
} else if (isObject(next)) {
|
|
3315
|
+
for (const item of Object.entries(next)) {
|
|
3316
|
+
const key = item[0];
|
|
3317
|
+
const value = item[1];
|
|
2998
3318
|
patchProp(el, key, value);
|
|
2999
3319
|
}
|
|
3320
|
+
} else {
|
|
3321
|
+
const key = values[i++];
|
|
3322
|
+
const value = values[i];
|
|
3323
|
+
patchProp(el, key, value);
|
|
3000
3324
|
}
|
|
3001
3325
|
}
|
|
3002
3326
|
};
|
|
3327
|
+
var propDirective = {
|
|
3328
|
+
mount: () => ({
|
|
3329
|
+
update: ({ el, values, option, flags }) => {
|
|
3330
|
+
updatePropBinding(el, values, option, flags);
|
|
3331
|
+
}
|
|
3332
|
+
})
|
|
3333
|
+
};
|
|
3003
3334
|
function includeBooleanAttr2(value) {
|
|
3004
3335
|
return !!value || value === "";
|
|
3005
3336
|
}
|
|
@@ -3054,7 +3385,8 @@ var patchProp = (el, key, value) => {
|
|
|
3054
3385
|
// src/directives/ref.ts
|
|
3055
3386
|
var refDirective = {
|
|
3056
3387
|
once: true,
|
|
3057
|
-
|
|
3388
|
+
mount: ({ el, parseResult, expr }) => {
|
|
3389
|
+
const result = parseResult;
|
|
3058
3390
|
const value = result.value()[0];
|
|
3059
3391
|
const isAnArray = isArray(value);
|
|
3060
3392
|
const sref2 = result.refs[0];
|
|
@@ -3071,37 +3403,47 @@ var refDirective = {
|
|
|
3071
3403
|
};
|
|
3072
3404
|
|
|
3073
3405
|
// src/directives/show.ts
|
|
3406
|
+
var updateShow = (el, values) => {
|
|
3407
|
+
const data = getBindData(el).data;
|
|
3408
|
+
let originalDisplay = data._ord;
|
|
3409
|
+
if (isUndefined(originalDisplay)) {
|
|
3410
|
+
originalDisplay = data._ord = el.style.display;
|
|
3411
|
+
}
|
|
3412
|
+
const isVisible = !!values[0];
|
|
3413
|
+
if (isVisible) el.style.display = originalDisplay;
|
|
3414
|
+
else el.style.display = "none";
|
|
3415
|
+
};
|
|
3074
3416
|
var showDirective = {
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
if (isUndefined(originalDisplay)) {
|
|
3079
|
-
originalDisplay = data._ord = el.style.display;
|
|
3417
|
+
mount: () => ({
|
|
3418
|
+
update: ({ el, values }) => {
|
|
3419
|
+
updateShow(el, values);
|
|
3080
3420
|
}
|
|
3081
|
-
|
|
3082
|
-
if (isVisible) el.style.display = originalDisplay;
|
|
3083
|
-
else el.style.display = "none";
|
|
3084
|
-
}
|
|
3421
|
+
})
|
|
3085
3422
|
};
|
|
3086
3423
|
|
|
3087
3424
|
// src/directives/style.ts
|
|
3088
|
-
var
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
patchStyle(el, next[j], previous == null ? void 0 : previous[j]);
|
|
3098
|
-
}
|
|
3099
|
-
} else {
|
|
3100
|
-
patchStyle(el, next, previous);
|
|
3425
|
+
var updateStyle = (el, values, previousValues) => {
|
|
3426
|
+
const len = values.length;
|
|
3427
|
+
for (let i = 0; i < len; ++i) {
|
|
3428
|
+
const next = values[i];
|
|
3429
|
+
const previous = previousValues == null ? void 0 : previousValues[i];
|
|
3430
|
+
if (isArray(next)) {
|
|
3431
|
+
const len2 = next.length;
|
|
3432
|
+
for (let j = 0; j < len2; ++j) {
|
|
3433
|
+
patchStyle(el, next[j], previous == null ? void 0 : previous[j]);
|
|
3101
3434
|
}
|
|
3435
|
+
} else {
|
|
3436
|
+
patchStyle(el, next, previous);
|
|
3102
3437
|
}
|
|
3103
3438
|
}
|
|
3104
3439
|
};
|
|
3440
|
+
var styleDirective = {
|
|
3441
|
+
mount: () => ({
|
|
3442
|
+
update: ({ el, values, previousValues }) => {
|
|
3443
|
+
updateStyle(el, values, previousValues);
|
|
3444
|
+
}
|
|
3445
|
+
})
|
|
3446
|
+
};
|
|
3105
3447
|
var patchStyle = (el, next, prev) => {
|
|
3106
3448
|
const style = el.style;
|
|
3107
3449
|
const isCssString = isString(next);
|
|
@@ -3209,19 +3551,26 @@ var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
|
|
|
3209
3551
|
};
|
|
3210
3552
|
|
|
3211
3553
|
// src/directives/text.ts
|
|
3554
|
+
var updateText = (el, values) => {
|
|
3555
|
+
var _a;
|
|
3556
|
+
const value = values[0];
|
|
3557
|
+
el.textContent = isSet(value) ? JSON.stringify(flatten([...value])) : isMap(value) ? JSON.stringify(flatten([...value])) : isObject(value) ? JSON.stringify(flatten(value)) : (_a = value == null ? void 0 : value.toString()) != null ? _a : "";
|
|
3558
|
+
};
|
|
3212
3559
|
var textDirective = {
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
}
|
|
3560
|
+
mount: () => ({
|
|
3561
|
+
update: ({ el, values }) => {
|
|
3562
|
+
updateText(el, values);
|
|
3563
|
+
}
|
|
3564
|
+
})
|
|
3218
3565
|
};
|
|
3219
3566
|
|
|
3220
3567
|
// src/directives/value.ts
|
|
3221
3568
|
var valueDirective = {
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3569
|
+
mount: () => ({
|
|
3570
|
+
update: ({ el, values }) => {
|
|
3571
|
+
patchProp(el, "value", values[0]);
|
|
3572
|
+
}
|
|
3573
|
+
})
|
|
3225
3574
|
};
|
|
3226
3575
|
|
|
3227
3576
|
// src/app/RegorConfig.ts
|
|
@@ -5037,6 +5386,7 @@ var regorEval = (expr, contexts, globalContext, isLazy, isLazyKey, context, coll
|
|
|
5037
5386
|
|
|
5038
5387
|
// src/parser/Parser.ts
|
|
5039
5388
|
var astCache = {};
|
|
5389
|
+
var isComponentMap = (value) => !!value;
|
|
5040
5390
|
var Parser = class {
|
|
5041
5391
|
constructor(contexts, config) {
|
|
5042
5392
|
__publicField(this, "__contexts");
|
|
@@ -5049,7 +5399,7 @@ var Parser = class {
|
|
|
5049
5399
|
this.__contexts = [context, ...this.__contexts];
|
|
5050
5400
|
}
|
|
5051
5401
|
__getComponents() {
|
|
5052
|
-
const obj = this.__contexts.map((x) => x.components).filter(
|
|
5402
|
+
const obj = this.__contexts.map((x) => x.components).filter(isComponentMap).reverse().reduce((p, c) => {
|
|
5053
5403
|
for (const [key, value] of Object.entries(c)) {
|
|
5054
5404
|
p[key.toUpperCase()] = value;
|
|
5055
5405
|
}
|
|
@@ -5060,7 +5410,7 @@ var Parser = class {
|
|
|
5060
5410
|
__getComponentSelectors() {
|
|
5061
5411
|
const selectors = [];
|
|
5062
5412
|
const seen = /* @__PURE__ */ new Set();
|
|
5063
|
-
const componentsList = this.__contexts.map((x) => x.components).filter(
|
|
5413
|
+
const componentsList = this.__contexts.map((x) => x.components).filter(isComponentMap).reverse();
|
|
5064
5414
|
for (const components of componentsList) {
|
|
5065
5415
|
for (const key of Object.keys(components)) {
|
|
5066
5416
|
if (seen.has(key)) continue;
|
|
@@ -5072,12 +5422,12 @@ var Parser = class {
|
|
|
5072
5422
|
}
|
|
5073
5423
|
__parse(expression, isLazy, isLazyKey, collectRefObj, once) {
|
|
5074
5424
|
var _a;
|
|
5075
|
-
|
|
5425
|
+
let currentValues = [];
|
|
5076
5426
|
const stopObserverList = [];
|
|
5077
5427
|
const subscribers = /* @__PURE__ */ new Set();
|
|
5078
5428
|
const clearObservers = () => {
|
|
5079
|
-
for (
|
|
5080
|
-
|
|
5429
|
+
for (let i = 0; i < stopObserverList.length; ++i) {
|
|
5430
|
+
stopObserverList[i]();
|
|
5081
5431
|
}
|
|
5082
5432
|
stopObserverList.length = 0;
|
|
5083
5433
|
};
|
|
@@ -5087,13 +5437,13 @@ var Parser = class {
|
|
|
5087
5437
|
};
|
|
5088
5438
|
const subscribe = (observer, init) => {
|
|
5089
5439
|
subscribers.add(observer);
|
|
5090
|
-
if (init) observer(
|
|
5440
|
+
if (init) observer(currentValues);
|
|
5091
5441
|
return () => {
|
|
5092
5442
|
subscribers.delete(observer);
|
|
5093
5443
|
};
|
|
5094
5444
|
};
|
|
5095
5445
|
const result = {
|
|
5096
|
-
value,
|
|
5446
|
+
value: () => currentValues,
|
|
5097
5447
|
stop: unbinder,
|
|
5098
5448
|
subscribe,
|
|
5099
5449
|
refs: [],
|
|
@@ -5114,7 +5464,7 @@ var Parser = class {
|
|
|
5114
5464
|
context,
|
|
5115
5465
|
collectRefObj
|
|
5116
5466
|
);
|
|
5117
|
-
if (collectRefs2) refs.push(...r.refs);
|
|
5467
|
+
if (collectRefs2 && r.refs.length > 0) refs.push(...r.refs);
|
|
5118
5468
|
return { value: r.value, refs: r.refs, ref: r.ref };
|
|
5119
5469
|
} catch (e) {
|
|
5120
5470
|
warning(6 /* ErrorLog */, `evaluation error: ${expression}`, e);
|
|
@@ -5127,36 +5477,37 @@ var Parser = class {
|
|
|
5127
5477
|
const contexts = this.__contexts.slice();
|
|
5128
5478
|
const elements = ast.elements;
|
|
5129
5479
|
const len = elements.length;
|
|
5480
|
+
const expressionRefs = new Array(len);
|
|
5481
|
+
result.refs = expressionRefs;
|
|
5130
5482
|
const refresh = () => {
|
|
5131
5483
|
refs.length = 0;
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5484
|
+
if (!once) {
|
|
5485
|
+
uniqueRefs.clear();
|
|
5486
|
+
clearObservers();
|
|
5487
|
+
}
|
|
5488
|
+
const nextValues = new Array(len);
|
|
5136
5489
|
for (let i = 0; i < len; ++i) {
|
|
5137
5490
|
const expr = elements[i];
|
|
5138
5491
|
if (isLazy == null ? void 0 : isLazy(i, -1)) {
|
|
5139
|
-
|
|
5492
|
+
nextValues[i] = (e) => evaluate(expr, contexts, false, { $event: e }).value;
|
|
5140
5493
|
continue;
|
|
5141
5494
|
}
|
|
5142
5495
|
const evaluated = evaluate(expr, contexts, true);
|
|
5143
|
-
|
|
5496
|
+
nextValues[i] = evaluated.value;
|
|
5144
5497
|
expressionRefs[i] = evaluated.ref;
|
|
5145
5498
|
}
|
|
5146
5499
|
if (!once) {
|
|
5147
5500
|
for (const r of refs) {
|
|
5148
5501
|
if (uniqueRefs.has(r)) continue;
|
|
5149
5502
|
uniqueRefs.add(r);
|
|
5150
|
-
|
|
5151
|
-
stopObserverList.push(stopObserving);
|
|
5503
|
+
stopObserverList.push(observe(r, refresh));
|
|
5152
5504
|
}
|
|
5153
5505
|
}
|
|
5154
|
-
|
|
5155
|
-
value(values);
|
|
5506
|
+
currentValues = nextValues;
|
|
5156
5507
|
if (subscribers.size !== 0) {
|
|
5157
5508
|
for (const subscriber of subscribers) {
|
|
5158
5509
|
if (!subscribers.has(subscriber)) continue;
|
|
5159
|
-
subscriber(
|
|
5510
|
+
subscriber(currentValues);
|
|
5160
5511
|
}
|
|
5161
5512
|
}
|
|
5162
5513
|
};
|
|
@@ -5470,8 +5821,8 @@ var toJsonTemplate = (node) => {
|
|
|
5470
5821
|
return json;
|
|
5471
5822
|
};
|
|
5472
5823
|
|
|
5473
|
-
// src/app/
|
|
5474
|
-
var
|
|
5824
|
+
// src/app/defineComponent.ts
|
|
5825
|
+
var defineComponent = (template, options = {}) => {
|
|
5475
5826
|
var _a, _b, _c, _d, _e, _f;
|
|
5476
5827
|
if (isArray(options)) options = { props: options };
|
|
5477
5828
|
if (isString(template)) template = { template };
|
|
@@ -5776,7 +6127,7 @@ export {
|
|
|
5776
6127
|
computeRef,
|
|
5777
6128
|
computed,
|
|
5778
6129
|
createApp,
|
|
5779
|
-
|
|
6130
|
+
defineComponent,
|
|
5780
6131
|
drainUnbind,
|
|
5781
6132
|
endBatch,
|
|
5782
6133
|
entangle,
|