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.es2015.esm.js
CHANGED
|
@@ -46,8 +46,8 @@ var bindDataSymbol = Symbol(":regor");
|
|
|
46
46
|
// src/cleanup/unbind.ts
|
|
47
47
|
var unbind = (node) => {
|
|
48
48
|
const stack = [node];
|
|
49
|
-
|
|
50
|
-
const currentNode = stack
|
|
49
|
+
for (let i = 0; i < stack.length; ++i) {
|
|
50
|
+
const currentNode = stack[i];
|
|
51
51
|
unbindSingle(currentNode);
|
|
52
52
|
for (let child = currentNode.lastChild; child != null; child = child.previousSibling) {
|
|
53
53
|
stack.push(child);
|
|
@@ -398,6 +398,8 @@ var setSwitchOwner = (owner, switchNodes) => {
|
|
|
398
398
|
};
|
|
399
399
|
|
|
400
400
|
// src/bind/IfBinder.ts
|
|
401
|
+
var noopStopObserving = () => {
|
|
402
|
+
};
|
|
401
403
|
var mount = (nodes, binder, parent, end) => {
|
|
402
404
|
const childNodes = [];
|
|
403
405
|
for (const x of nodes) {
|
|
@@ -522,18 +524,14 @@ var IfBinder = class {
|
|
|
522
524
|
const parseResult = this.__binder.__parser.__parse(expression);
|
|
523
525
|
const value = parseResult.value;
|
|
524
526
|
const remainingElses = this.__collectElses(nextElement, refresh);
|
|
525
|
-
|
|
527
|
+
let stopObserver = noopStopObserving;
|
|
526
528
|
const unbinder = () => {
|
|
527
529
|
parseResult.stop();
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
stopObserverList.length = 0;
|
|
530
|
+
stopObserver();
|
|
531
|
+
stopObserver = noopStopObserving;
|
|
532
532
|
};
|
|
533
533
|
addUnbinder(commentBegin, unbinder);
|
|
534
|
-
|
|
535
|
-
};
|
|
536
|
-
stopObserverList.push(stopObserving);
|
|
534
|
+
stopObserver = parseResult.subscribe(refresh);
|
|
537
535
|
return [
|
|
538
536
|
{
|
|
539
537
|
mount: () => {
|
|
@@ -544,8 +542,9 @@ var IfBinder = class {
|
|
|
544
542
|
},
|
|
545
543
|
isTrue: () => !!value()[0],
|
|
546
544
|
isMounted: false
|
|
547
|
-
}
|
|
548
|
-
|
|
545
|
+
},
|
|
546
|
+
...remainingElses
|
|
547
|
+
];
|
|
549
548
|
}
|
|
550
549
|
}
|
|
551
550
|
__bindToExpression(el, expression) {
|
|
@@ -591,29 +590,31 @@ var IfBinder = class {
|
|
|
591
590
|
});
|
|
592
591
|
};
|
|
593
592
|
const collectedElses = this.__collectElses(nextElement, refresh);
|
|
594
|
-
|
|
593
|
+
let stopObserver = noopStopObserving;
|
|
595
594
|
const unbinder = () => {
|
|
596
595
|
parseResult.stop();
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
}
|
|
600
|
-
stopObserverList.length = 0;
|
|
596
|
+
stopObserver();
|
|
597
|
+
stopObserver = noopStopObserving;
|
|
601
598
|
};
|
|
602
599
|
addUnbinder(commentBegin, unbinder);
|
|
603
600
|
refresh();
|
|
604
|
-
|
|
605
|
-
};
|
|
606
|
-
stopObserverList.push(stopObserving);
|
|
601
|
+
stopObserver = parseResult.subscribe(refresh);
|
|
607
602
|
}
|
|
608
603
|
};
|
|
609
604
|
|
|
610
605
|
// src/common/common.ts
|
|
611
606
|
var getNodes = (el) => {
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
607
|
+
const source = isTemplate(el) ? el.content.childNodes : [el];
|
|
608
|
+
const result = [];
|
|
609
|
+
for (let i = 0; i < source.length; ++i) {
|
|
610
|
+
const node = source[i];
|
|
611
|
+
if (node.nodeType === 1) {
|
|
612
|
+
const tagName = node == null ? void 0 : node.tagName;
|
|
613
|
+
if (tagName === "SCRIPT" || tagName === "STYLE") continue;
|
|
614
|
+
}
|
|
615
|
+
result.push(node);
|
|
616
|
+
}
|
|
617
|
+
return result;
|
|
617
618
|
};
|
|
618
619
|
var bindChildNodes = (binder, childNodes) => {
|
|
619
620
|
for (let i = 0; i < childNodes.length; ++i) {
|
|
@@ -711,7 +712,9 @@ var capitalize = cacheStringFunction((str) => {
|
|
|
711
712
|
});
|
|
712
713
|
|
|
713
714
|
// src/directives/teleport.ts
|
|
714
|
-
var teleportDirective = {
|
|
715
|
+
var teleportDirective = {
|
|
716
|
+
mount: () => void 0
|
|
717
|
+
};
|
|
715
718
|
|
|
716
719
|
// src/composition/callMounted.ts
|
|
717
720
|
var callMounted = (context) => {
|
|
@@ -746,12 +749,6 @@ var isScope = (value) => {
|
|
|
746
749
|
return scopeSymbol2 in value;
|
|
747
750
|
};
|
|
748
751
|
|
|
749
|
-
// src/composition/onUnmounted.ts
|
|
750
|
-
var onUnmounted = (onUnmounted2, noThrow) => {
|
|
751
|
-
var _a;
|
|
752
|
-
(_a = peekScope(noThrow)) == null ? void 0 : _a.onUnmounted.push(onUnmounted2);
|
|
753
|
-
};
|
|
754
|
-
|
|
755
752
|
// src/reactivity/refSymbols.ts
|
|
756
753
|
var refSymbol = Symbol("ref");
|
|
757
754
|
var srefSymbol = Symbol("sref");
|
|
@@ -762,6 +759,35 @@ var isRef = (value) => {
|
|
|
762
759
|
return value != null && value[srefSymbol] === 1;
|
|
763
760
|
};
|
|
764
761
|
|
|
762
|
+
// src/directives/context.ts
|
|
763
|
+
var contextDirective = {
|
|
764
|
+
collectRefObj: true,
|
|
765
|
+
mount: ({ parseResult }) => ({
|
|
766
|
+
update: ({ values }) => {
|
|
767
|
+
const ctx = parseResult.context;
|
|
768
|
+
const obj = values[0];
|
|
769
|
+
if (!isObject(obj)) return;
|
|
770
|
+
for (const item of Object.entries(obj)) {
|
|
771
|
+
const key = item[0];
|
|
772
|
+
const nextValue = item[1];
|
|
773
|
+
const ctxKey = ctx[key];
|
|
774
|
+
if (ctxKey === nextValue) continue;
|
|
775
|
+
if (isRef(ctxKey)) {
|
|
776
|
+
ctxKey(nextValue);
|
|
777
|
+
} else {
|
|
778
|
+
ctx[key] = nextValue;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
})
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
// src/composition/onUnmounted.ts
|
|
786
|
+
var onUnmounted = (onUnmounted2, noThrow) => {
|
|
787
|
+
var _a;
|
|
788
|
+
(_a = peekScope(noThrow)) == null ? void 0 : _a.onUnmounted.push(onUnmounted2);
|
|
789
|
+
};
|
|
790
|
+
|
|
765
791
|
// src/observer/observe.ts
|
|
766
792
|
var observe = (source, observer, init, trackUnmount = true) => {
|
|
767
793
|
if (!isRef(source))
|
|
@@ -778,37 +804,6 @@ var observe = (source, observer, init, trackUnmount = true) => {
|
|
|
778
804
|
return stop;
|
|
779
805
|
};
|
|
780
806
|
|
|
781
|
-
// src/directives/context.ts
|
|
782
|
-
var contextDirective = {
|
|
783
|
-
collectRefObj: true,
|
|
784
|
-
onBind: (_, parseResult) => {
|
|
785
|
-
const stopObserving = observe(
|
|
786
|
-
parseResult.value,
|
|
787
|
-
() => {
|
|
788
|
-
const value = parseResult.value();
|
|
789
|
-
const ctx = parseResult.context;
|
|
790
|
-
const obj = value[0];
|
|
791
|
-
if (!isObject(obj)) {
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
for (const item of Object.entries(obj)) {
|
|
795
|
-
const key = item[0];
|
|
796
|
-
const value2 = item[1];
|
|
797
|
-
const ctxKey = ctx[key];
|
|
798
|
-
if (ctxKey === value2) continue;
|
|
799
|
-
if (isRef(ctxKey)) {
|
|
800
|
-
ctxKey(value2);
|
|
801
|
-
} else {
|
|
802
|
-
ctx[key] = value2;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
},
|
|
806
|
-
true
|
|
807
|
-
);
|
|
808
|
-
return stopObserving;
|
|
809
|
-
}
|
|
810
|
-
};
|
|
811
|
-
|
|
812
807
|
// src/reactivity/entangle.ts
|
|
813
808
|
var entangle = (r1, r2) => {
|
|
814
809
|
if (r1 === r2) return () => {
|
|
@@ -1136,8 +1131,8 @@ var createModelBridge = (source) => {
|
|
|
1136
1131
|
};
|
|
1137
1132
|
var singlePropDirective = {
|
|
1138
1133
|
collectRefObj: true,
|
|
1139
|
-
|
|
1140
|
-
if (!option) return noop;
|
|
1134
|
+
mount: ({ parseResult, option }) => {
|
|
1135
|
+
if (typeof option !== "string" || !option) return noop;
|
|
1141
1136
|
const key = camelize(option);
|
|
1142
1137
|
let currentSource;
|
|
1143
1138
|
let bridge;
|
|
@@ -1158,44 +1153,44 @@ var singlePropDirective = {
|
|
|
1158
1153
|
stopEntangle = entangle(source, target);
|
|
1159
1154
|
currentSource = source;
|
|
1160
1155
|
};
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1163
|
-
()
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
if (bridge && ctxKey === bridge) {
|
|
1170
|
-
bridge(value);
|
|
1171
|
-
return;
|
|
1172
|
-
}
|
|
1173
|
-
resetSync();
|
|
1174
|
-
if (isRef(ctxKey)) {
|
|
1175
|
-
ctxKey(value);
|
|
1176
|
-
return;
|
|
1177
|
-
}
|
|
1178
|
-
ctx[key] = value;
|
|
1156
|
+
const apply = () => {
|
|
1157
|
+
var _a;
|
|
1158
|
+
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
1159
|
+
const ctx = parseResult.context;
|
|
1160
|
+
const ctxKey = ctx[key];
|
|
1161
|
+
if (!isRef(value)) {
|
|
1162
|
+
if (bridge && ctxKey === bridge) {
|
|
1163
|
+
bridge(value);
|
|
1179
1164
|
return;
|
|
1180
1165
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
syncRefs(value, ctxKey);
|
|
1185
|
-
} else {
|
|
1186
|
-
ctx[key] = value;
|
|
1187
|
-
}
|
|
1166
|
+
resetSync();
|
|
1167
|
+
if (isRef(ctxKey)) {
|
|
1168
|
+
ctxKey(value);
|
|
1188
1169
|
return;
|
|
1189
1170
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1171
|
+
ctx[key] = value;
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
if (isModelBridge(value)) {
|
|
1175
|
+
if (ctxKey === value) return;
|
|
1176
|
+
if (isRef(ctxKey)) {
|
|
1177
|
+
syncRefs(value, ctxKey);
|
|
1178
|
+
} else {
|
|
1179
|
+
ctx[key] = value;
|
|
1180
|
+
}
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
if (!bridge) bridge = createModelBridge(value);
|
|
1184
|
+
ctx[key] = bridge;
|
|
1185
|
+
syncRefs(value, bridge);
|
|
1186
|
+
};
|
|
1187
|
+
return {
|
|
1188
|
+
update: () => {
|
|
1189
|
+
apply();
|
|
1193
1190
|
},
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
stopEntangle();
|
|
1198
|
-
stopObserving();
|
|
1191
|
+
unmount: () => {
|
|
1192
|
+
stopEntangle();
|
|
1193
|
+
}
|
|
1199
1194
|
};
|
|
1200
1195
|
}
|
|
1201
1196
|
};
|
|
@@ -1216,7 +1211,10 @@ var ComponentBinder = class {
|
|
|
1216
1211
|
__getRegisteredComponentSelector(registeredComponents) {
|
|
1217
1212
|
if (this.__registeredComponentSize !== registeredComponents.size) {
|
|
1218
1213
|
const names = [...registeredComponents.keys()];
|
|
1219
|
-
this.__registeredComponentSelector =
|
|
1214
|
+
this.__registeredComponentSelector = [
|
|
1215
|
+
...names,
|
|
1216
|
+
...names.map(hyphenate)
|
|
1217
|
+
].join(",");
|
|
1220
1218
|
this.__registeredComponentSize = registeredComponents.size;
|
|
1221
1219
|
}
|
|
1222
1220
|
return this.__registeredComponentSelector;
|
|
@@ -1293,7 +1291,10 @@ var ComponentBinder = class {
|
|
|
1293
1291
|
definedProp
|
|
1294
1292
|
])
|
|
1295
1293
|
);
|
|
1296
|
-
for (const name of
|
|
1294
|
+
for (const name of [
|
|
1295
|
+
...definedProps,
|
|
1296
|
+
...definedProps.map(hyphenate)
|
|
1297
|
+
]) {
|
|
1297
1298
|
const value = component2.getAttribute(name);
|
|
1298
1299
|
if (value === null) continue;
|
|
1299
1300
|
props[camelize(name)] = value;
|
|
@@ -1588,18 +1589,17 @@ var DirectiveCollector = class {
|
|
|
1588
1589
|
}
|
|
1589
1590
|
};
|
|
1590
1591
|
const processNode = (node) => {
|
|
1591
|
-
var _a
|
|
1592
|
+
var _a;
|
|
1592
1593
|
const attrs = node.attributes;
|
|
1593
1594
|
if (!attrs || attrs.length === 0) return;
|
|
1594
|
-
const attrsAny = attrs;
|
|
1595
1595
|
for (let i = 0; i < attrs.length; ++i) {
|
|
1596
|
-
const name = (
|
|
1596
|
+
const name = (_a = attrs.item(i)) == null ? void 0 : _a.name;
|
|
1597
1597
|
if (!name) continue;
|
|
1598
1598
|
appendDirective(node, name);
|
|
1599
1599
|
}
|
|
1600
1600
|
};
|
|
1601
1601
|
processNode(element);
|
|
1602
|
-
if (!isRecursive) return map;
|
|
1602
|
+
if (!isRecursive || !element.firstElementChild) return map;
|
|
1603
1603
|
const nodes = element.querySelectorAll("*");
|
|
1604
1604
|
for (const node of nodes) {
|
|
1605
1605
|
processNode(node);
|
|
@@ -1609,6 +1609,8 @@ var DirectiveCollector = class {
|
|
|
1609
1609
|
};
|
|
1610
1610
|
|
|
1611
1611
|
// src/bind/DynamicBinder.ts
|
|
1612
|
+
var noopStopObserving2 = () => {
|
|
1613
|
+
};
|
|
1612
1614
|
var mount2 = (nodes, parent) => {
|
|
1613
1615
|
for (const x of nodes) {
|
|
1614
1616
|
const node = x.cloneNode(true);
|
|
@@ -1724,19 +1726,15 @@ var DynamicBinder = class {
|
|
|
1724
1726
|
mounted.name = name;
|
|
1725
1727
|
});
|
|
1726
1728
|
};
|
|
1727
|
-
|
|
1729
|
+
let stopObserver = noopStopObserving2;
|
|
1728
1730
|
const unbinder = () => {
|
|
1729
1731
|
parseResult.stop();
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
}
|
|
1733
|
-
stopObserverList.length = 0;
|
|
1732
|
+
stopObserver();
|
|
1733
|
+
stopObserver = noopStopObserving2;
|
|
1734
1734
|
};
|
|
1735
1735
|
addUnbinder(commentBegin, unbinder);
|
|
1736
1736
|
refresh();
|
|
1737
|
-
|
|
1738
|
-
};
|
|
1739
|
-
stopObserverList.push(stopObserving);
|
|
1737
|
+
stopObserver = parseResult.subscribe(refresh);
|
|
1740
1738
|
}
|
|
1741
1739
|
};
|
|
1742
1740
|
|
|
@@ -1746,6 +1744,274 @@ var unref = (value) => {
|
|
|
1746
1744
|
return anyValue != null && anyValue[srefSymbol] === 1 ? anyValue() : anyValue;
|
|
1747
1745
|
};
|
|
1748
1746
|
|
|
1747
|
+
// src/directives/html.ts
|
|
1748
|
+
var updateHtml = (el, values) => {
|
|
1749
|
+
const [value, replacer] = values;
|
|
1750
|
+
if (isFunction(replacer)) replacer(el, value);
|
|
1751
|
+
else el.innerHTML = value == null ? void 0 : value.toString();
|
|
1752
|
+
};
|
|
1753
|
+
var htmlDirective = {
|
|
1754
|
+
mount: () => ({
|
|
1755
|
+
update: ({ el, values }) => {
|
|
1756
|
+
updateHtml(el, values);
|
|
1757
|
+
}
|
|
1758
|
+
})
|
|
1759
|
+
};
|
|
1760
|
+
|
|
1761
|
+
// src/bind/ForBinderFastPath.ts
|
|
1762
|
+
var ForBinderFastPath = class _ForBinderFastPath {
|
|
1763
|
+
constructor(bindings) {
|
|
1764
|
+
__publicField(this, "__bindings");
|
|
1765
|
+
this.__bindings = bindings;
|
|
1766
|
+
}
|
|
1767
|
+
static __create(binder, nodes) {
|
|
1768
|
+
var _a, _b;
|
|
1769
|
+
const parser = binder.__parser;
|
|
1770
|
+
const config = binder.__config;
|
|
1771
|
+
const builtInNames = config.__builtInNames;
|
|
1772
|
+
const blockedBuiltIns = /* @__PURE__ */ new Set([
|
|
1773
|
+
builtInNames.for,
|
|
1774
|
+
builtInNames.if,
|
|
1775
|
+
builtInNames.else,
|
|
1776
|
+
builtInNames.elseif,
|
|
1777
|
+
builtInNames.pre
|
|
1778
|
+
]);
|
|
1779
|
+
const directiveMap = config.__directiveMap;
|
|
1780
|
+
const contextComponents = parser.__getComponents();
|
|
1781
|
+
if (Object.keys(contextComponents).length > 0 || config.__componentsUpperCase.size > 0) {
|
|
1782
|
+
return void 0;
|
|
1783
|
+
}
|
|
1784
|
+
const collector = binder.__directiveCollector;
|
|
1785
|
+
const bindings = [];
|
|
1786
|
+
let nodeIndex = 0;
|
|
1787
|
+
const stack = [];
|
|
1788
|
+
for (let i = nodes.length - 1; i >= 0; --i) {
|
|
1789
|
+
stack.push(nodes[i]);
|
|
1790
|
+
}
|
|
1791
|
+
while (stack.length > 0) {
|
|
1792
|
+
const node = stack.pop();
|
|
1793
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1794
|
+
const el = node;
|
|
1795
|
+
if (el.tagName === "TEMPLATE") return void 0;
|
|
1796
|
+
if (el.tagName.includes("-")) return void 0;
|
|
1797
|
+
const tagNameUpper = camelize(el.tagName).toUpperCase();
|
|
1798
|
+
if (config.__componentsUpperCase.has(tagNameUpper) || contextComponents[tagNameUpper]) {
|
|
1799
|
+
return void 0;
|
|
1800
|
+
}
|
|
1801
|
+
const attrs = el.attributes;
|
|
1802
|
+
for (let i = 0; i < attrs.length; ++i) {
|
|
1803
|
+
const attrName = (_a = attrs.item(i)) == null ? void 0 : _a.name;
|
|
1804
|
+
if (!attrName) continue;
|
|
1805
|
+
if (blockedBuiltIns.has(attrName)) return void 0;
|
|
1806
|
+
const { terms, flags } = collector.__parseName(attrName);
|
|
1807
|
+
const [name, option] = terms;
|
|
1808
|
+
const directive = (_b = directiveMap[attrName]) != null ? _b : directiveMap[name];
|
|
1809
|
+
if (!directive) continue;
|
|
1810
|
+
if (directive === htmlDirective) return void 0;
|
|
1811
|
+
bindings.push({
|
|
1812
|
+
nodeIndex,
|
|
1813
|
+
attrName,
|
|
1814
|
+
directive,
|
|
1815
|
+
option,
|
|
1816
|
+
flags
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
++nodeIndex;
|
|
1820
|
+
}
|
|
1821
|
+
const children = node.childNodes;
|
|
1822
|
+
for (let i = children.length - 1; i >= 0; --i) {
|
|
1823
|
+
stack.push(children[i]);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
if (bindings.length === 0) return void 0;
|
|
1827
|
+
return new _ForBinderFastPath(bindings);
|
|
1828
|
+
}
|
|
1829
|
+
__bind(binder, nodes) {
|
|
1830
|
+
const elements = [];
|
|
1831
|
+
const stack = [];
|
|
1832
|
+
for (let i = nodes.length - 1; i >= 0; --i) {
|
|
1833
|
+
stack.push(nodes[i]);
|
|
1834
|
+
}
|
|
1835
|
+
while (stack.length > 0) {
|
|
1836
|
+
const node = stack.pop();
|
|
1837
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1838
|
+
elements.push(node);
|
|
1839
|
+
}
|
|
1840
|
+
const children = node.childNodes;
|
|
1841
|
+
for (let i = children.length - 1; i >= 0; --i) {
|
|
1842
|
+
stack.push(children[i]);
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
for (let i = 0; i < this.__bindings.length; ++i) {
|
|
1846
|
+
const binding = this.__bindings[i];
|
|
1847
|
+
const el = elements[binding.nodeIndex];
|
|
1848
|
+
if (!el) continue;
|
|
1849
|
+
binder.__bind(
|
|
1850
|
+
binding.directive,
|
|
1851
|
+
el,
|
|
1852
|
+
binding.attrName,
|
|
1853
|
+
false,
|
|
1854
|
+
binding.option,
|
|
1855
|
+
binding.flags
|
|
1856
|
+
);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
|
|
1861
|
+
// src/bind/ForBinderKeyedDiff.ts
|
|
1862
|
+
var moveMountItemBefore = (item, anchor) => {
|
|
1863
|
+
const parent = anchor.parentNode;
|
|
1864
|
+
if (!parent) return;
|
|
1865
|
+
for (let i = 0; i < item.items.length; ++i) {
|
|
1866
|
+
parent.insertBefore(item.items[i], anchor);
|
|
1867
|
+
}
|
|
1868
|
+
};
|
|
1869
|
+
var getSequence = (arr) => {
|
|
1870
|
+
var _a;
|
|
1871
|
+
const len = arr.length;
|
|
1872
|
+
const p = arr.slice();
|
|
1873
|
+
const result = [];
|
|
1874
|
+
let u;
|
|
1875
|
+
let v;
|
|
1876
|
+
let c;
|
|
1877
|
+
for (let i = 0; i < len; ++i) {
|
|
1878
|
+
const value = arr[i];
|
|
1879
|
+
if (value === 0) continue;
|
|
1880
|
+
const j = result[result.length - 1];
|
|
1881
|
+
if (j === void 0 || arr[j] < value) {
|
|
1882
|
+
p[i] = j != null ? j : -1;
|
|
1883
|
+
result.push(i);
|
|
1884
|
+
continue;
|
|
1885
|
+
}
|
|
1886
|
+
u = 0;
|
|
1887
|
+
v = result.length - 1;
|
|
1888
|
+
while (u < v) {
|
|
1889
|
+
c = u + v >> 1;
|
|
1890
|
+
if (arr[result[c]] < value) u = c + 1;
|
|
1891
|
+
else v = c;
|
|
1892
|
+
}
|
|
1893
|
+
if (value < arr[result[u]]) {
|
|
1894
|
+
if (u > 0) p[i] = result[u - 1];
|
|
1895
|
+
result[u] = i;
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
u = result.length;
|
|
1899
|
+
v = (_a = result[u - 1]) != null ? _a : -1;
|
|
1900
|
+
while (u-- > 0) {
|
|
1901
|
+
result[u] = v;
|
|
1902
|
+
v = p[v];
|
|
1903
|
+
}
|
|
1904
|
+
return result;
|
|
1905
|
+
};
|
|
1906
|
+
var ForBinderKeyedDiff = class {
|
|
1907
|
+
/**
|
|
1908
|
+
* Applies keyed patch and returns the next ordered mount list.
|
|
1909
|
+
* Returns `undefined` when keyed mode is not safe for this update.
|
|
1910
|
+
*/
|
|
1911
|
+
static __patch(options) {
|
|
1912
|
+
const {
|
|
1913
|
+
oldItems,
|
|
1914
|
+
newValues,
|
|
1915
|
+
getKey,
|
|
1916
|
+
isSameValue,
|
|
1917
|
+
mountNewValue,
|
|
1918
|
+
removeMountItem,
|
|
1919
|
+
endAnchor
|
|
1920
|
+
} = options;
|
|
1921
|
+
const oldLen = oldItems.length;
|
|
1922
|
+
const newLen = newValues.length;
|
|
1923
|
+
const newKeys = new Array(newLen);
|
|
1924
|
+
const keySeen = /* @__PURE__ */ new Set();
|
|
1925
|
+
for (let i2 = 0; i2 < newLen; ++i2) {
|
|
1926
|
+
const key = getKey(newValues[i2]);
|
|
1927
|
+
if (key === void 0 || keySeen.has(key)) return void 0;
|
|
1928
|
+
keySeen.add(key);
|
|
1929
|
+
newKeys[i2] = key;
|
|
1930
|
+
}
|
|
1931
|
+
const newMountItems = new Array(newLen);
|
|
1932
|
+
let i = 0;
|
|
1933
|
+
let e1 = oldLen - 1;
|
|
1934
|
+
let e2 = newLen - 1;
|
|
1935
|
+
while (i <= e1 && i <= e2) {
|
|
1936
|
+
const oldItem = oldItems[i];
|
|
1937
|
+
if (getKey(oldItem.value) !== newKeys[i]) break;
|
|
1938
|
+
if (!isSameValue(oldItem.value, newValues[i])) break;
|
|
1939
|
+
oldItem.value = newValues[i];
|
|
1940
|
+
newMountItems[i] = oldItem;
|
|
1941
|
+
++i;
|
|
1942
|
+
}
|
|
1943
|
+
while (i <= e1 && i <= e2) {
|
|
1944
|
+
const oldItem = oldItems[e1];
|
|
1945
|
+
if (getKey(oldItem.value) !== newKeys[e2]) break;
|
|
1946
|
+
if (!isSameValue(oldItem.value, newValues[e2])) break;
|
|
1947
|
+
oldItem.value = newValues[e2];
|
|
1948
|
+
newMountItems[e2] = oldItem;
|
|
1949
|
+
--e1;
|
|
1950
|
+
--e2;
|
|
1951
|
+
}
|
|
1952
|
+
if (i > e1) {
|
|
1953
|
+
for (let k = e2; k >= i; --k) {
|
|
1954
|
+
const anchor = k + 1 < newLen ? newMountItems[k + 1].items[0] : endAnchor;
|
|
1955
|
+
newMountItems[k] = mountNewValue(k, newValues[k], anchor);
|
|
1956
|
+
}
|
|
1957
|
+
return newMountItems;
|
|
1958
|
+
}
|
|
1959
|
+
if (i > e2) {
|
|
1960
|
+
for (let k = i; k <= e1; ++k) removeMountItem(oldItems[k]);
|
|
1961
|
+
return newMountItems;
|
|
1962
|
+
}
|
|
1963
|
+
const s1 = i;
|
|
1964
|
+
const s2 = i;
|
|
1965
|
+
const toBePatched = e2 - s2 + 1;
|
|
1966
|
+
const newIndexToOldIndexMap = new Array(toBePatched).fill(0);
|
|
1967
|
+
const keyToNewIndexMap = /* @__PURE__ */ new Map();
|
|
1968
|
+
for (let k = s2; k <= e2; ++k) {
|
|
1969
|
+
keyToNewIndexMap.set(newKeys[k], k);
|
|
1970
|
+
}
|
|
1971
|
+
let moved = false;
|
|
1972
|
+
let maxNewIndexSoFar = 0;
|
|
1973
|
+
for (let k = s1; k <= e1; ++k) {
|
|
1974
|
+
const oldItem = oldItems[k];
|
|
1975
|
+
const newIndex = keyToNewIndexMap.get(getKey(oldItem.value));
|
|
1976
|
+
if (newIndex === void 0) {
|
|
1977
|
+
removeMountItem(oldItem);
|
|
1978
|
+
continue;
|
|
1979
|
+
}
|
|
1980
|
+
if (!isSameValue(oldItem.value, newValues[newIndex])) {
|
|
1981
|
+
removeMountItem(oldItem);
|
|
1982
|
+
continue;
|
|
1983
|
+
}
|
|
1984
|
+
oldItem.value = newValues[newIndex];
|
|
1985
|
+
newMountItems[newIndex] = oldItem;
|
|
1986
|
+
newIndexToOldIndexMap[newIndex - s2] = k + 1;
|
|
1987
|
+
if (newIndex >= maxNewIndexSoFar) maxNewIndexSoFar = newIndex;
|
|
1988
|
+
else moved = true;
|
|
1989
|
+
}
|
|
1990
|
+
const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : [];
|
|
1991
|
+
let seqIdx = increasingNewIndexSequence.length - 1;
|
|
1992
|
+
for (let k = toBePatched - 1; k >= 0; --k) {
|
|
1993
|
+
const newIndex = s2 + k;
|
|
1994
|
+
const anchor = newIndex + 1 < newLen ? newMountItems[newIndex + 1].items[0] : endAnchor;
|
|
1995
|
+
if (newIndexToOldIndexMap[k] === 0) {
|
|
1996
|
+
newMountItems[newIndex] = mountNewValue(
|
|
1997
|
+
newIndex,
|
|
1998
|
+
newValues[newIndex],
|
|
1999
|
+
anchor
|
|
2000
|
+
);
|
|
2001
|
+
continue;
|
|
2002
|
+
}
|
|
2003
|
+
const item = newMountItems[newIndex];
|
|
2004
|
+
if (!moved) continue;
|
|
2005
|
+
if (seqIdx >= 0 && increasingNewIndexSequence[seqIdx] === k) {
|
|
2006
|
+
--seqIdx;
|
|
2007
|
+
} else if (item) {
|
|
2008
|
+
moveMountItemBefore(item, anchor);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
return newMountItems;
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
|
|
1749
2015
|
// src/bind/MountList.ts
|
|
1750
2016
|
var MountList = class {
|
|
1751
2017
|
constructor(getKey) {
|
|
@@ -1827,6 +2093,8 @@ var MountList = class {
|
|
|
1827
2093
|
// src/bind/ForBinder.ts
|
|
1828
2094
|
var forMarker = Symbol("r-for");
|
|
1829
2095
|
var noIndexRef = (_) => -1;
|
|
2096
|
+
var noopStopObserving3 = () => {
|
|
2097
|
+
};
|
|
1830
2098
|
var _ForBinder = class _ForBinder {
|
|
1831
2099
|
constructor(binder) {
|
|
1832
2100
|
__publicField(this, "__binder");
|
|
@@ -1897,6 +2165,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1897
2165
|
el.removeAttribute(nameKey);
|
|
1898
2166
|
el.removeAttribute(nameKeyBind);
|
|
1899
2167
|
const nodes = getNodes(el);
|
|
2168
|
+
const fastPath = ForBinderFastPath.__create(this.__binder, nodes);
|
|
1900
2169
|
const parent = el.parentNode;
|
|
1901
2170
|
if (!parent) return;
|
|
1902
2171
|
const title = `${this.__for} => ${forPath}`;
|
|
@@ -1916,6 +2185,7 @@ var _ForBinder = class _ForBinder {
|
|
|
1916
2185
|
const rowContexts = singleCapturedContext ? [void 0, capturedContext[0]] : void 0;
|
|
1917
2186
|
const getKey = this.__createKeyGetter(keyExpression);
|
|
1918
2187
|
const areEqual = (a, b) => getKey(a) === getKey(b);
|
|
2188
|
+
const isSameValue = (a, b) => a === b;
|
|
1919
2189
|
const mountNewValue = (i2, newValue, nextSibling) => {
|
|
1920
2190
|
const result = config.createContext(newValue, i2);
|
|
1921
2191
|
const mountItem = MountList.__createItem(result.index, newValue);
|
|
@@ -1929,7 +2199,8 @@ var _ForBinder = class _ForBinder {
|
|
|
1929
2199
|
insertParent.insertBefore(node, nextSibling);
|
|
1930
2200
|
childNodes.push(node);
|
|
1931
2201
|
}
|
|
1932
|
-
|
|
2202
|
+
if (fastPath) fastPath.__bind(binder, childNodes);
|
|
2203
|
+
else bindChildNodes(binder, childNodes);
|
|
1933
2204
|
start = start.nextSibling;
|
|
1934
2205
|
while (start !== nextSibling) {
|
|
1935
2206
|
mountItem.items.push(start);
|
|
@@ -1981,16 +2252,51 @@ var _ForBinder = class _ForBinder {
|
|
|
1981
2252
|
mountList.__removeAllAfter(0);
|
|
1982
2253
|
return;
|
|
1983
2254
|
}
|
|
2255
|
+
const iterableValues = [];
|
|
2256
|
+
for (const value2 of this.__getIterable(newValues[0])) {
|
|
2257
|
+
iterableValues.push(value2);
|
|
2258
|
+
}
|
|
2259
|
+
const patched = ForBinderKeyedDiff.__patch({
|
|
2260
|
+
oldItems: mountList.__list,
|
|
2261
|
+
newValues: iterableValues,
|
|
2262
|
+
getKey,
|
|
2263
|
+
isSameValue,
|
|
2264
|
+
mountNewValue: (index, value2, nextSibling) => mountNewValue(index, value2, nextSibling),
|
|
2265
|
+
removeMountItem: (item) => {
|
|
2266
|
+
for (let k = 0; k < item.items.length; ++k) {
|
|
2267
|
+
removeNode(item.items[k]);
|
|
2268
|
+
}
|
|
2269
|
+
},
|
|
2270
|
+
endAnchor: commentEnd
|
|
2271
|
+
});
|
|
2272
|
+
if (patched) {
|
|
2273
|
+
mountList.__list = patched;
|
|
2274
|
+
mountList.__valueMap.clear();
|
|
2275
|
+
for (let k = 0; k < patched.length; ++k) {
|
|
2276
|
+
const item = patched[k];
|
|
2277
|
+
item.order = k;
|
|
2278
|
+
item.index(k);
|
|
2279
|
+
const key = getKey(item.value);
|
|
2280
|
+
if (key !== void 0) {
|
|
2281
|
+
mountList.__valueMap.set(key, item);
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
1984
2286
|
let i2 = 0;
|
|
1985
2287
|
let firstRemovalOrInsertionIndex = Number.MAX_SAFE_INTEGER;
|
|
1986
2288
|
const initialLength = len;
|
|
1987
2289
|
const forGrowThreshold = this.__binder.__config.forGrowThreshold;
|
|
1988
2290
|
const shouldGrowList = () => mountList.__length < initialLength + forGrowThreshold;
|
|
1989
|
-
for (const newValue of
|
|
2291
|
+
for (const newValue of iterableValues) {
|
|
1990
2292
|
const modify = () => {
|
|
1991
2293
|
if (i2 < len) {
|
|
1992
2294
|
const mountItem = mountList.__get(i2++);
|
|
1993
|
-
if (areEqual(mountItem.value, newValue))
|
|
2295
|
+
if (areEqual(mountItem.value, newValue)) {
|
|
2296
|
+
if (isSameValue(mountItem.value, newValue)) return;
|
|
2297
|
+
replace(i2 - 1, newValue);
|
|
2298
|
+
return;
|
|
2299
|
+
}
|
|
1994
2300
|
const newValueMountPosition = mountList.__lookupValueOrderIfMounted(
|
|
1995
2301
|
getKey(newValue)
|
|
1996
2302
|
);
|
|
@@ -2040,24 +2346,21 @@ var _ForBinder = class _ForBinder {
|
|
|
2040
2346
|
mountList.__removeAllAfter(j);
|
|
2041
2347
|
updateIndexes(firstRemovalOrInsertionIndex);
|
|
2042
2348
|
};
|
|
2043
|
-
const observeTailChanges = () => {
|
|
2044
|
-
stopObserving = parseResult.subscribe ? parseResult.subscribe(updateDom) : () => {
|
|
2045
|
-
};
|
|
2046
|
-
};
|
|
2047
2349
|
const unbinder = () => {
|
|
2048
2350
|
parseResult.stop();
|
|
2049
2351
|
stopObserving();
|
|
2352
|
+
stopObserving = noopStopObserving3;
|
|
2050
2353
|
};
|
|
2051
2354
|
const parseResult = parser.__parse(config.list);
|
|
2052
2355
|
const value = parseResult.value;
|
|
2053
|
-
let stopObserving;
|
|
2356
|
+
let stopObserving = noopStopObserving3;
|
|
2054
2357
|
let i = 0;
|
|
2055
2358
|
const mountList = new MountList(getKey);
|
|
2056
2359
|
for (const item of this.__getIterable(value()[0])) {
|
|
2057
2360
|
mountList.__push(mountNewValue(i++, item, commentEnd));
|
|
2058
2361
|
}
|
|
2059
2362
|
addUnbinder(commentBegin, unbinder);
|
|
2060
|
-
|
|
2363
|
+
stopObserving = parseResult.subscribe(updateDom);
|
|
2061
2364
|
}
|
|
2062
2365
|
__parseForPath(forPath) {
|
|
2063
2366
|
var _a, _b;
|
|
@@ -2241,105 +2544,111 @@ var Binder = class {
|
|
|
2241
2544
|
return true;
|
|
2242
2545
|
}
|
|
2243
2546
|
__bindToExpression(config, el, valueExpression, option, flags) {
|
|
2244
|
-
var _a;
|
|
2245
2547
|
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null) return;
|
|
2246
2548
|
if (this.__handleTeleport(config, el, valueExpression)) return;
|
|
2247
|
-
const
|
|
2549
|
+
const dynamicOption = this.__parseDynamicOption(option, config.once);
|
|
2550
|
+
const result = this.__parseExpression(config, valueExpression);
|
|
2551
|
+
const stops = this.__createBindStops(result, dynamicOption);
|
|
2552
|
+
addUnbinder(el, stops.stop);
|
|
2553
|
+
const payload = this.__createDirectivePayload(
|
|
2554
|
+
el,
|
|
2555
|
+
valueExpression,
|
|
2556
|
+
result,
|
|
2557
|
+
dynamicOption,
|
|
2558
|
+
option,
|
|
2559
|
+
flags
|
|
2560
|
+
);
|
|
2561
|
+
const mountedUpdate = this.__mountDirective(config, payload, stops);
|
|
2562
|
+
if (!mountedUpdate) return;
|
|
2563
|
+
const emitChange = this.__createEmitter(
|
|
2564
|
+
payload,
|
|
2565
|
+
result,
|
|
2566
|
+
dynamicOption,
|
|
2567
|
+
option,
|
|
2568
|
+
mountedUpdate
|
|
2569
|
+
);
|
|
2570
|
+
emitChange();
|
|
2571
|
+
if (!config.once) {
|
|
2572
|
+
stops.result = result.subscribe(emitChange);
|
|
2573
|
+
if (dynamicOption) {
|
|
2574
|
+
stops.dynamic = dynamicOption.subscribe(emitChange);
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
__parseDynamicOption(option, once) {
|
|
2579
|
+
const dynamicOptionExpression = isOptionDynamic(option, this.__dynamic);
|
|
2580
|
+
if (!dynamicOptionExpression) return void 0;
|
|
2581
|
+
return this.__parser.__parse(
|
|
2582
|
+
camelize(dynamicOptionExpression),
|
|
2583
|
+
void 0,
|
|
2584
|
+
void 0,
|
|
2585
|
+
void 0,
|
|
2586
|
+
once
|
|
2587
|
+
);
|
|
2588
|
+
}
|
|
2589
|
+
__parseExpression(config, valueExpression) {
|
|
2590
|
+
return this.__parser.__parse(
|
|
2248
2591
|
valueExpression,
|
|
2249
2592
|
config.isLazy,
|
|
2250
2593
|
config.isLazyKey,
|
|
2251
2594
|
config.collectRefObj,
|
|
2252
2595
|
config.once
|
|
2253
2596
|
);
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
const
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2597
|
+
}
|
|
2598
|
+
__createBindStops(result, dynamicOption) {
|
|
2599
|
+
const stops = {
|
|
2600
|
+
stop: () => {
|
|
2601
|
+
var _a, _b, _c;
|
|
2602
|
+
result.stop();
|
|
2603
|
+
dynamicOption == null ? void 0 : dynamicOption.stop();
|
|
2604
|
+
(_a = stops.result) == null ? void 0 : _a.call(stops);
|
|
2605
|
+
(_b = stops.dynamic) == null ? void 0 : _b.call(stops);
|
|
2606
|
+
(_c = stops.mounted) == null ? void 0 : _c.call(stops);
|
|
2607
|
+
stops.result = void 0;
|
|
2608
|
+
stops.dynamic = void 0;
|
|
2609
|
+
stops.mounted = void 0;
|
|
2261
2610
|
}
|
|
2262
|
-
stopObserverList.length = 0;
|
|
2263
2611
|
};
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2612
|
+
return stops;
|
|
2613
|
+
}
|
|
2614
|
+
__createDirectivePayload(el, expr, result, dynamicOption, option, flags) {
|
|
2615
|
+
return {
|
|
2616
|
+
el,
|
|
2617
|
+
expr,
|
|
2618
|
+
values: result.value(),
|
|
2619
|
+
previousValues: void 0,
|
|
2620
|
+
option: dynamicOption ? dynamicOption.value()[0] : option,
|
|
2621
|
+
previousOption: void 0,
|
|
2622
|
+
flags,
|
|
2623
|
+
parseResult: result,
|
|
2624
|
+
dynamicOption
|
|
2625
|
+
};
|
|
2626
|
+
}
|
|
2627
|
+
__mountDirective(config, payload, stops) {
|
|
2628
|
+
const mounted = config.mount(payload);
|
|
2629
|
+
if (typeof mounted === "function") {
|
|
2630
|
+
stops.mounted = mounted;
|
|
2631
|
+
return void 0;
|
|
2275
2632
|
}
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
let previousValues = result.value();
|
|
2279
|
-
let previousOption = hasDynamicOption ? dynamicOption.value()[0] : option;
|
|
2280
|
-
if (!config.once && hasOnChange) {
|
|
2281
|
-
const stopObserving = result.subscribe ? result.subscribe(() => {
|
|
2282
|
-
var _a2;
|
|
2283
|
-
const preValues = previousValues;
|
|
2284
|
-
const preOption = previousOption;
|
|
2285
|
-
const nextValues = result.value();
|
|
2286
|
-
const nextOption = hasDynamicOption ? dynamicOpt.value()[0] : option;
|
|
2287
|
-
previousValues = nextValues;
|
|
2288
|
-
previousOption = nextOption;
|
|
2289
|
-
(_a2 = config.onChange) == null ? void 0 : _a2.call(
|
|
2290
|
-
config,
|
|
2291
|
-
el,
|
|
2292
|
-
nextValues,
|
|
2293
|
-
preValues,
|
|
2294
|
-
nextOption,
|
|
2295
|
-
preOption,
|
|
2296
|
-
flags
|
|
2297
|
-
);
|
|
2298
|
-
}) : () => {
|
|
2299
|
-
};
|
|
2300
|
-
stopObserverList.push(stopObserving);
|
|
2301
|
-
if (dynamicOpt) {
|
|
2302
|
-
const stopObserving2 = dynamicOpt.subscribe ? dynamicOpt.subscribe(() => {
|
|
2303
|
-
var _a2;
|
|
2304
|
-
const preOption = previousOption;
|
|
2305
|
-
const nextValues = result.value();
|
|
2306
|
-
const nextOption = dynamicOpt.value()[0];
|
|
2307
|
-
previousValues = nextValues;
|
|
2308
|
-
previousOption = nextOption;
|
|
2309
|
-
(_a2 = config.onChange) == null ? void 0 : _a2.call(
|
|
2310
|
-
config,
|
|
2311
|
-
el,
|
|
2312
|
-
nextValues,
|
|
2313
|
-
preOption,
|
|
2314
|
-
nextOption,
|
|
2315
|
-
preOption,
|
|
2316
|
-
flags
|
|
2317
|
-
);
|
|
2318
|
-
}) : () => {
|
|
2319
|
-
};
|
|
2320
|
-
stopObserverList.push(stopObserving2);
|
|
2321
|
-
}
|
|
2633
|
+
if (mounted == null ? void 0 : mounted.unmount) {
|
|
2634
|
+
stops.mounted = mounted.unmount;
|
|
2322
2635
|
}
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
previousOption,
|
|
2340
|
-
void 0,
|
|
2341
|
-
flags
|
|
2342
|
-
);
|
|
2636
|
+
return mounted == null ? void 0 : mounted.update;
|
|
2637
|
+
}
|
|
2638
|
+
__createEmitter(payload, result, dynamicOption, option, mountedUpdate) {
|
|
2639
|
+
let previousValues;
|
|
2640
|
+
let previousOption;
|
|
2641
|
+
return () => {
|
|
2642
|
+
const nextValues = result.value();
|
|
2643
|
+
const nextOption = dynamicOption ? dynamicOption.value()[0] : option;
|
|
2644
|
+
payload.values = nextValues;
|
|
2645
|
+
payload.previousValues = previousValues;
|
|
2646
|
+
payload.option = nextOption;
|
|
2647
|
+
payload.previousOption = previousOption;
|
|
2648
|
+
previousValues = nextValues;
|
|
2649
|
+
previousOption = nextOption;
|
|
2650
|
+
mountedUpdate(payload);
|
|
2651
|
+
};
|
|
2343
2652
|
}
|
|
2344
2653
|
};
|
|
2345
2654
|
|
|
@@ -2376,39 +2685,51 @@ var booleanAttributes = {
|
|
|
2376
2685
|
function includeBooleanAttr(value) {
|
|
2377
2686
|
return !!value || value === "";
|
|
2378
2687
|
}
|
|
2379
|
-
var
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
if (option)
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
const previousKey = p && key in p ? key : void 0;
|
|
2401
|
-
patchAttribute(el, key, value, previousKey);
|
|
2402
|
-
}
|
|
2403
|
-
} else {
|
|
2404
|
-
const previousKey = previousValues == null ? void 0 : previousValues[i];
|
|
2405
|
-
const key = values[i++];
|
|
2406
|
-
const value = values[i];
|
|
2688
|
+
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
2689
|
+
var _a;
|
|
2690
|
+
if (option) {
|
|
2691
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
2692
|
+
patchAttribute(el, option, values[0], previousOption);
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
const len = values.length;
|
|
2696
|
+
for (let i = 0; i < len; ++i) {
|
|
2697
|
+
const next = values[i];
|
|
2698
|
+
if (isArray(next)) {
|
|
2699
|
+
const previousKey = (_a = previousValues == null ? void 0 : previousValues[i]) == null ? void 0 : _a[0];
|
|
2700
|
+
const key = next[0];
|
|
2701
|
+
const value = next[1];
|
|
2702
|
+
patchAttribute(el, key, value, previousKey);
|
|
2703
|
+
} else if (isObject(next)) {
|
|
2704
|
+
for (const item of Object.entries(next)) {
|
|
2705
|
+
const key = item[0];
|
|
2706
|
+
const value = item[1];
|
|
2707
|
+
const p = previousValues == null ? void 0 : previousValues[i];
|
|
2708
|
+
const previousKey = p && key in p ? key : void 0;
|
|
2407
2709
|
patchAttribute(el, key, value, previousKey);
|
|
2408
2710
|
}
|
|
2711
|
+
} else {
|
|
2712
|
+
const previousKey = previousValues == null ? void 0 : previousValues[i];
|
|
2713
|
+
const key = values[i++];
|
|
2714
|
+
const value = values[i];
|
|
2715
|
+
patchAttribute(el, key, value, previousKey);
|
|
2409
2716
|
}
|
|
2410
2717
|
}
|
|
2411
2718
|
};
|
|
2719
|
+
var attrDirective = {
|
|
2720
|
+
mount: () => ({
|
|
2721
|
+
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
2722
|
+
updateAttr(
|
|
2723
|
+
el,
|
|
2724
|
+
values,
|
|
2725
|
+
previousValues,
|
|
2726
|
+
option,
|
|
2727
|
+
previousOption,
|
|
2728
|
+
flags
|
|
2729
|
+
);
|
|
2730
|
+
}
|
|
2731
|
+
})
|
|
2732
|
+
};
|
|
2412
2733
|
var patchAttribute = (el, key, value, previousKey) => {
|
|
2413
2734
|
if (previousKey && previousKey !== key) {
|
|
2414
2735
|
el.removeAttribute(previousKey);
|
|
@@ -2442,23 +2763,28 @@ var patchAttribute = (el, key, value, previousKey) => {
|
|
|
2442
2763
|
};
|
|
2443
2764
|
|
|
2444
2765
|
// src/directives/class.ts
|
|
2445
|
-
var
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
patchClass(el, next[j], previous == null ? void 0 : previous[j]);
|
|
2455
|
-
}
|
|
2456
|
-
} else {
|
|
2457
|
-
patchClass(el, next, previous);
|
|
2766
|
+
var updateClass = (el, values, previousValues) => {
|
|
2767
|
+
const len = values.length;
|
|
2768
|
+
for (let i = 0; i < len; ++i) {
|
|
2769
|
+
const next = values[i];
|
|
2770
|
+
const previous = previousValues == null ? void 0 : previousValues[i];
|
|
2771
|
+
if (isArray(next)) {
|
|
2772
|
+
const len2 = next.length;
|
|
2773
|
+
for (let j = 0; j < len2; ++j) {
|
|
2774
|
+
patchClass(el, next[j], previous == null ? void 0 : previous[j]);
|
|
2458
2775
|
}
|
|
2776
|
+
} else {
|
|
2777
|
+
patchClass(el, next, previous);
|
|
2459
2778
|
}
|
|
2460
2779
|
}
|
|
2461
2780
|
};
|
|
2781
|
+
var classDirective = {
|
|
2782
|
+
mount: () => ({
|
|
2783
|
+
update: ({ el, values, previousValues }) => {
|
|
2784
|
+
updateClass(el, values, previousValues);
|
|
2785
|
+
}
|
|
2786
|
+
})
|
|
2787
|
+
};
|
|
2462
2788
|
var patchClass = (el, next, prev) => {
|
|
2463
2789
|
const classList = el.classList;
|
|
2464
2790
|
const isClassString = isString(next);
|
|
@@ -2486,15 +2812,6 @@ var patchClass = (el, next, prev) => {
|
|
|
2486
2812
|
}
|
|
2487
2813
|
};
|
|
2488
2814
|
|
|
2489
|
-
// src/directives/html.ts
|
|
2490
|
-
var htmlDirective = {
|
|
2491
|
-
onChange: (el, values) => {
|
|
2492
|
-
const [value, replacer] = values;
|
|
2493
|
-
if (isFunction(replacer)) replacer(el, value);
|
|
2494
|
-
else el.innerHTML = value == null ? void 0 : value.toString();
|
|
2495
|
-
}
|
|
2496
|
-
};
|
|
2497
|
-
|
|
2498
2815
|
// src/common/looseEqual.ts
|
|
2499
2816
|
function looseCompareArrays(a, b) {
|
|
2500
2817
|
if (a.length !== b.length) return false;
|
|
@@ -2567,12 +2884,12 @@ var resume = (source) => {
|
|
|
2567
2884
|
|
|
2568
2885
|
// src/directives/model.ts
|
|
2569
2886
|
var modelDirective = {
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
}
|
|
2887
|
+
mount: ({ el, parseResult, flags }) => ({
|
|
2888
|
+
update: ({ values }) => {
|
|
2889
|
+
updateDomElementValue(el, values[0]);
|
|
2890
|
+
},
|
|
2891
|
+
unmount: attachDOMChangeListener(el, parseResult, flags)
|
|
2892
|
+
})
|
|
2576
2893
|
};
|
|
2577
2894
|
var updateDomElementValue = (el, value) => {
|
|
2578
2895
|
const isAnInput = isInput(el);
|
|
@@ -2878,66 +3195,75 @@ var getFlags2 = (flags) => {
|
|
|
2878
3195
|
}
|
|
2879
3196
|
return result;
|
|
2880
3197
|
};
|
|
3198
|
+
var bindOn = (el, parseResult, option, dynamicOption, flags) => {
|
|
3199
|
+
var _a, _b;
|
|
3200
|
+
if (dynamicOption) {
|
|
3201
|
+
const values2 = parseResult.value();
|
|
3202
|
+
const option2 = unref(dynamicOption.value()[0]);
|
|
3203
|
+
if (!isString(option2)) return () => {
|
|
3204
|
+
};
|
|
3205
|
+
return attachEventListener(
|
|
3206
|
+
el,
|
|
3207
|
+
camelize(option2),
|
|
3208
|
+
() => parseResult.value()[0],
|
|
3209
|
+
(_a = flags == null ? void 0 : flags.join(",")) != null ? _a : values2[1]
|
|
3210
|
+
);
|
|
3211
|
+
} else if (option) {
|
|
3212
|
+
const values2 = parseResult.value();
|
|
3213
|
+
return attachEventListener(
|
|
3214
|
+
el,
|
|
3215
|
+
camelize(option),
|
|
3216
|
+
() => parseResult.value()[0],
|
|
3217
|
+
(_b = flags == null ? void 0 : flags.join(",")) != null ? _b : values2[1]
|
|
3218
|
+
);
|
|
3219
|
+
}
|
|
3220
|
+
const unbinders = [];
|
|
3221
|
+
const unbinder = () => {
|
|
3222
|
+
unbinders.forEach((x) => x());
|
|
3223
|
+
};
|
|
3224
|
+
const values = parseResult.value();
|
|
3225
|
+
const len = values.length;
|
|
3226
|
+
for (let i = 0; i < len; ++i) {
|
|
3227
|
+
let next = values[i];
|
|
3228
|
+
if (isFunction(next)) next = next();
|
|
3229
|
+
if (isObject(next)) {
|
|
3230
|
+
for (const item of Object.entries(next)) {
|
|
3231
|
+
const eventType = item[0];
|
|
3232
|
+
const method = () => {
|
|
3233
|
+
let obj = parseResult.value()[i];
|
|
3234
|
+
if (isFunction(obj)) obj = obj();
|
|
3235
|
+
obj = obj[eventType];
|
|
3236
|
+
if (isFunction(obj)) obj = obj();
|
|
3237
|
+
return obj;
|
|
3238
|
+
};
|
|
3239
|
+
const flags2 = next[eventType + "_flags"];
|
|
3240
|
+
unbinders.push(attachEventListener(el, eventType, method, flags2));
|
|
3241
|
+
}
|
|
3242
|
+
} else {
|
|
3243
|
+
warning(2 /* BindingRequiresObjectExpressions */, "r-on", el);
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
return unbinder;
|
|
3247
|
+
};
|
|
2881
3248
|
var onDirective = {
|
|
2882
3249
|
isLazy: (i, d) => d === -1 && i % 2 === 0,
|
|
2883
3250
|
isLazyKey: (key, d) => d === 0 && !key.endsWith("_flags"),
|
|
2884
3251
|
once: false,
|
|
2885
3252
|
collectRefObj: true,
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
el,
|
|
2895
|
-
camelize(option2),
|
|
2896
|
-
() => parseResult.value()[0],
|
|
2897
|
-
(_a = flags == null ? void 0 : flags.join(",")) != null ? _a : values2[1]
|
|
2898
|
-
);
|
|
2899
|
-
} else if (option) {
|
|
2900
|
-
const values2 = parseResult.value();
|
|
2901
|
-
return attachEventListener(
|
|
2902
|
-
el,
|
|
2903
|
-
camelize(option),
|
|
2904
|
-
() => parseResult.value()[0],
|
|
2905
|
-
(_b = flags == null ? void 0 : flags.join(",")) != null ? _b : values2[1]
|
|
2906
|
-
);
|
|
2907
|
-
}
|
|
2908
|
-
const unbinders = [];
|
|
2909
|
-
const unbinder = () => {
|
|
2910
|
-
unbinders.forEach((x) => x());
|
|
2911
|
-
};
|
|
2912
|
-
const values = parseResult.value();
|
|
2913
|
-
const len = values.length;
|
|
2914
|
-
for (let i = 0; i < len; ++i) {
|
|
2915
|
-
let next = values[i];
|
|
2916
|
-
if (isFunction(next)) next = next();
|
|
2917
|
-
if (isObject(next)) {
|
|
2918
|
-
for (const item of Object.entries(next)) {
|
|
2919
|
-
const eventType = item[0];
|
|
2920
|
-
const method = () => {
|
|
2921
|
-
let obj = parseResult.value()[i];
|
|
2922
|
-
if (isFunction(obj)) obj = obj();
|
|
2923
|
-
obj = obj[eventType];
|
|
2924
|
-
if (isFunction(obj)) obj = obj();
|
|
2925
|
-
return obj;
|
|
2926
|
-
};
|
|
2927
|
-
const flags2 = next[eventType + "_flags"];
|
|
2928
|
-
unbinders.push(attachEventListener(el, eventType, method, flags2));
|
|
2929
|
-
}
|
|
2930
|
-
} else {
|
|
2931
|
-
warning(2 /* BindingRequiresObjectExpressions */, "r-on", el);
|
|
2932
|
-
}
|
|
2933
|
-
}
|
|
2934
|
-
return unbinder;
|
|
3253
|
+
mount: ({ el, parseResult, option, dynamicOption, flags }) => {
|
|
3254
|
+
return bindOn(
|
|
3255
|
+
el,
|
|
3256
|
+
parseResult,
|
|
3257
|
+
option,
|
|
3258
|
+
dynamicOption,
|
|
3259
|
+
flags
|
|
3260
|
+
);
|
|
2935
3261
|
}
|
|
2936
3262
|
};
|
|
2937
3263
|
var getShouldExecuteEvent = (eventType, flags) => {
|
|
2938
3264
|
if (eventType.startsWith("keydown") || eventType.startsWith("keyup") || eventType.startsWith("keypress")) {
|
|
2939
3265
|
flags != null ? flags : flags = "";
|
|
2940
|
-
const parts = eventType.split(".")
|
|
3266
|
+
const parts = [...eventType.split("."), ...flags.split(",")];
|
|
2941
3267
|
eventType = parts[0];
|
|
2942
3268
|
const keyType = parts[1];
|
|
2943
3269
|
const isCtrl = parts.includes("ctrl");
|
|
@@ -3010,34 +3336,39 @@ var attachEventListener = (el, eventType, method, flags) => {
|
|
|
3010
3336
|
};
|
|
3011
3337
|
|
|
3012
3338
|
// src/directives/prop.ts
|
|
3013
|
-
var
|
|
3014
|
-
|
|
3015
|
-
if (option)
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
const value = item[1];
|
|
3031
|
-
patchProp(el, key, value);
|
|
3032
|
-
}
|
|
3033
|
-
} else {
|
|
3034
|
-
const key = values[i++];
|
|
3035
|
-
const value = values[i];
|
|
3339
|
+
var updatePropBinding = (el, values, option, flags) => {
|
|
3340
|
+
if (option) {
|
|
3341
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3342
|
+
patchProp(el, option, values[0]);
|
|
3343
|
+
return;
|
|
3344
|
+
}
|
|
3345
|
+
const len = values.length;
|
|
3346
|
+
for (let i = 0; i < len; ++i) {
|
|
3347
|
+
const next = values[i];
|
|
3348
|
+
if (isArray(next)) {
|
|
3349
|
+
const key = next[0];
|
|
3350
|
+
const value = next[1];
|
|
3351
|
+
patchProp(el, key, value);
|
|
3352
|
+
} else if (isObject(next)) {
|
|
3353
|
+
for (const item of Object.entries(next)) {
|
|
3354
|
+
const key = item[0];
|
|
3355
|
+
const value = item[1];
|
|
3036
3356
|
patchProp(el, key, value);
|
|
3037
3357
|
}
|
|
3358
|
+
} else {
|
|
3359
|
+
const key = values[i++];
|
|
3360
|
+
const value = values[i];
|
|
3361
|
+
patchProp(el, key, value);
|
|
3038
3362
|
}
|
|
3039
3363
|
}
|
|
3040
3364
|
};
|
|
3365
|
+
var propDirective = {
|
|
3366
|
+
mount: () => ({
|
|
3367
|
+
update: ({ el, values, option, flags }) => {
|
|
3368
|
+
updatePropBinding(el, values, option, flags);
|
|
3369
|
+
}
|
|
3370
|
+
})
|
|
3371
|
+
};
|
|
3041
3372
|
function includeBooleanAttr2(value) {
|
|
3042
3373
|
return !!value || value === "";
|
|
3043
3374
|
}
|
|
@@ -3092,7 +3423,8 @@ var patchProp = (el, key, value) => {
|
|
|
3092
3423
|
// src/directives/ref.ts
|
|
3093
3424
|
var refDirective = {
|
|
3094
3425
|
once: true,
|
|
3095
|
-
|
|
3426
|
+
mount: ({ el, parseResult, expr }) => {
|
|
3427
|
+
const result = parseResult;
|
|
3096
3428
|
const value = result.value()[0];
|
|
3097
3429
|
const isAnArray = isArray(value);
|
|
3098
3430
|
const sref2 = result.refs[0];
|
|
@@ -3109,37 +3441,47 @@ var refDirective = {
|
|
|
3109
3441
|
};
|
|
3110
3442
|
|
|
3111
3443
|
// src/directives/show.ts
|
|
3444
|
+
var updateShow = (el, values) => {
|
|
3445
|
+
const data = getBindData(el).data;
|
|
3446
|
+
let originalDisplay = data._ord;
|
|
3447
|
+
if (isUndefined(originalDisplay)) {
|
|
3448
|
+
originalDisplay = data._ord = el.style.display;
|
|
3449
|
+
}
|
|
3450
|
+
const isVisible = !!values[0];
|
|
3451
|
+
if (isVisible) el.style.display = originalDisplay;
|
|
3452
|
+
else el.style.display = "none";
|
|
3453
|
+
};
|
|
3112
3454
|
var showDirective = {
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
if (isUndefined(originalDisplay)) {
|
|
3117
|
-
originalDisplay = data._ord = el.style.display;
|
|
3455
|
+
mount: () => ({
|
|
3456
|
+
update: ({ el, values }) => {
|
|
3457
|
+
updateShow(el, values);
|
|
3118
3458
|
}
|
|
3119
|
-
|
|
3120
|
-
if (isVisible) el.style.display = originalDisplay;
|
|
3121
|
-
else el.style.display = "none";
|
|
3122
|
-
}
|
|
3459
|
+
})
|
|
3123
3460
|
};
|
|
3124
3461
|
|
|
3125
3462
|
// src/directives/style.ts
|
|
3126
|
-
var
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
patchStyle(el, next[j], previous == null ? void 0 : previous[j]);
|
|
3136
|
-
}
|
|
3137
|
-
} else {
|
|
3138
|
-
patchStyle(el, next, previous);
|
|
3463
|
+
var updateStyle = (el, values, previousValues) => {
|
|
3464
|
+
const len = values.length;
|
|
3465
|
+
for (let i = 0; i < len; ++i) {
|
|
3466
|
+
const next = values[i];
|
|
3467
|
+
const previous = previousValues == null ? void 0 : previousValues[i];
|
|
3468
|
+
if (isArray(next)) {
|
|
3469
|
+
const len2 = next.length;
|
|
3470
|
+
for (let j = 0; j < len2; ++j) {
|
|
3471
|
+
patchStyle(el, next[j], previous == null ? void 0 : previous[j]);
|
|
3139
3472
|
}
|
|
3473
|
+
} else {
|
|
3474
|
+
patchStyle(el, next, previous);
|
|
3140
3475
|
}
|
|
3141
3476
|
}
|
|
3142
3477
|
};
|
|
3478
|
+
var styleDirective = {
|
|
3479
|
+
mount: () => ({
|
|
3480
|
+
update: ({ el, values, previousValues }) => {
|
|
3481
|
+
updateStyle(el, values, previousValues);
|
|
3482
|
+
}
|
|
3483
|
+
})
|
|
3484
|
+
};
|
|
3143
3485
|
var patchStyle = (el, next, prev) => {
|
|
3144
3486
|
const style = el.style;
|
|
3145
3487
|
const isCssString = isString(next);
|
|
@@ -3247,19 +3589,26 @@ var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
|
|
|
3247
3589
|
};
|
|
3248
3590
|
|
|
3249
3591
|
// src/directives/text.ts
|
|
3592
|
+
var updateText = (el, values) => {
|
|
3593
|
+
var _a;
|
|
3594
|
+
const value = values[0];
|
|
3595
|
+
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 : "";
|
|
3596
|
+
};
|
|
3250
3597
|
var textDirective = {
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
}
|
|
3598
|
+
mount: () => ({
|
|
3599
|
+
update: ({ el, values }) => {
|
|
3600
|
+
updateText(el, values);
|
|
3601
|
+
}
|
|
3602
|
+
})
|
|
3256
3603
|
};
|
|
3257
3604
|
|
|
3258
3605
|
// src/directives/value.ts
|
|
3259
3606
|
var valueDirective = {
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3607
|
+
mount: () => ({
|
|
3608
|
+
update: ({ el, values }) => {
|
|
3609
|
+
patchProp(el, "value", values[0]);
|
|
3610
|
+
}
|
|
3611
|
+
})
|
|
3263
3612
|
};
|
|
3264
3613
|
|
|
3265
3614
|
// src/app/RegorConfig.ts
|
|
@@ -5075,6 +5424,7 @@ var regorEval = (expr, contexts, globalContext, isLazy, isLazyKey, context, coll
|
|
|
5075
5424
|
|
|
5076
5425
|
// src/parser/Parser.ts
|
|
5077
5426
|
var astCache = {};
|
|
5427
|
+
var isComponentMap = (value) => !!value;
|
|
5078
5428
|
var Parser = class {
|
|
5079
5429
|
constructor(contexts, config) {
|
|
5080
5430
|
__publicField(this, "__contexts");
|
|
@@ -5087,7 +5437,7 @@ var Parser = class {
|
|
|
5087
5437
|
this.__contexts = [context, ...this.__contexts];
|
|
5088
5438
|
}
|
|
5089
5439
|
__getComponents() {
|
|
5090
|
-
const obj = this.__contexts.map((x) => x.components).filter(
|
|
5440
|
+
const obj = this.__contexts.map((x) => x.components).filter(isComponentMap).reverse().reduce((p, c) => {
|
|
5091
5441
|
for (const [key, value] of Object.entries(c)) {
|
|
5092
5442
|
p[key.toUpperCase()] = value;
|
|
5093
5443
|
}
|
|
@@ -5098,7 +5448,7 @@ var Parser = class {
|
|
|
5098
5448
|
__getComponentSelectors() {
|
|
5099
5449
|
const selectors = [];
|
|
5100
5450
|
const seen = /* @__PURE__ */ new Set();
|
|
5101
|
-
const componentsList = this.__contexts.map((x) => x.components).filter(
|
|
5451
|
+
const componentsList = this.__contexts.map((x) => x.components).filter(isComponentMap).reverse();
|
|
5102
5452
|
for (const components of componentsList) {
|
|
5103
5453
|
for (const key of Object.keys(components)) {
|
|
5104
5454
|
if (seen.has(key)) continue;
|
|
@@ -5110,12 +5460,12 @@ var Parser = class {
|
|
|
5110
5460
|
}
|
|
5111
5461
|
__parse(expression, isLazy, isLazyKey, collectRefObj, once) {
|
|
5112
5462
|
var _a;
|
|
5113
|
-
|
|
5463
|
+
let currentValues = [];
|
|
5114
5464
|
const stopObserverList = [];
|
|
5115
5465
|
const subscribers = /* @__PURE__ */ new Set();
|
|
5116
5466
|
const clearObservers = () => {
|
|
5117
|
-
for (
|
|
5118
|
-
|
|
5467
|
+
for (let i = 0; i < stopObserverList.length; ++i) {
|
|
5468
|
+
stopObserverList[i]();
|
|
5119
5469
|
}
|
|
5120
5470
|
stopObserverList.length = 0;
|
|
5121
5471
|
};
|
|
@@ -5125,13 +5475,13 @@ var Parser = class {
|
|
|
5125
5475
|
};
|
|
5126
5476
|
const subscribe = (observer, init) => {
|
|
5127
5477
|
subscribers.add(observer);
|
|
5128
|
-
if (init) observer(
|
|
5478
|
+
if (init) observer(currentValues);
|
|
5129
5479
|
return () => {
|
|
5130
5480
|
subscribers.delete(observer);
|
|
5131
5481
|
};
|
|
5132
5482
|
};
|
|
5133
5483
|
const result = {
|
|
5134
|
-
value,
|
|
5484
|
+
value: () => currentValues,
|
|
5135
5485
|
stop: unbinder,
|
|
5136
5486
|
subscribe,
|
|
5137
5487
|
refs: [],
|
|
@@ -5152,7 +5502,7 @@ var Parser = class {
|
|
|
5152
5502
|
context,
|
|
5153
5503
|
collectRefObj
|
|
5154
5504
|
);
|
|
5155
|
-
if (collectRefs2) refs.push(...r.refs);
|
|
5505
|
+
if (collectRefs2 && r.refs.length > 0) refs.push(...r.refs);
|
|
5156
5506
|
return { value: r.value, refs: r.refs, ref: r.ref };
|
|
5157
5507
|
} catch (e) {
|
|
5158
5508
|
warning(6 /* ErrorLog */, `evaluation error: ${expression}`, e);
|
|
@@ -5165,36 +5515,37 @@ var Parser = class {
|
|
|
5165
5515
|
const contexts = this.__contexts.slice();
|
|
5166
5516
|
const elements = ast.elements;
|
|
5167
5517
|
const len = elements.length;
|
|
5518
|
+
const expressionRefs = new Array(len);
|
|
5519
|
+
result.refs = expressionRefs;
|
|
5168
5520
|
const refresh = () => {
|
|
5169
5521
|
refs.length = 0;
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5522
|
+
if (!once) {
|
|
5523
|
+
uniqueRefs.clear();
|
|
5524
|
+
clearObservers();
|
|
5525
|
+
}
|
|
5526
|
+
const nextValues = new Array(len);
|
|
5174
5527
|
for (let i = 0; i < len; ++i) {
|
|
5175
5528
|
const expr = elements[i];
|
|
5176
5529
|
if (isLazy == null ? void 0 : isLazy(i, -1)) {
|
|
5177
|
-
|
|
5530
|
+
nextValues[i] = (e) => evaluate(expr, contexts, false, { $event: e }).value;
|
|
5178
5531
|
continue;
|
|
5179
5532
|
}
|
|
5180
5533
|
const evaluated = evaluate(expr, contexts, true);
|
|
5181
|
-
|
|
5534
|
+
nextValues[i] = evaluated.value;
|
|
5182
5535
|
expressionRefs[i] = evaluated.ref;
|
|
5183
5536
|
}
|
|
5184
5537
|
if (!once) {
|
|
5185
5538
|
for (const r of refs) {
|
|
5186
5539
|
if (uniqueRefs.has(r)) continue;
|
|
5187
5540
|
uniqueRefs.add(r);
|
|
5188
|
-
|
|
5189
|
-
stopObserverList.push(stopObserving);
|
|
5541
|
+
stopObserverList.push(observe(r, refresh));
|
|
5190
5542
|
}
|
|
5191
5543
|
}
|
|
5192
|
-
|
|
5193
|
-
value(values);
|
|
5544
|
+
currentValues = nextValues;
|
|
5194
5545
|
if (subscribers.size !== 0) {
|
|
5195
5546
|
for (const subscriber of subscribers) {
|
|
5196
5547
|
if (!subscribers.has(subscriber)) continue;
|
|
5197
|
-
subscriber(
|
|
5548
|
+
subscriber(currentValues);
|
|
5198
5549
|
}
|
|
5199
5550
|
}
|
|
5200
5551
|
};
|
|
@@ -5508,8 +5859,8 @@ var toJsonTemplate = (node) => {
|
|
|
5508
5859
|
return json;
|
|
5509
5860
|
};
|
|
5510
5861
|
|
|
5511
|
-
// src/app/
|
|
5512
|
-
var
|
|
5862
|
+
// src/app/defineComponent.ts
|
|
5863
|
+
var defineComponent = (template, options = {}) => {
|
|
5513
5864
|
var _a, _b, _c, _d, _e, _f;
|
|
5514
5865
|
if (isArray(options)) options = { props: options };
|
|
5515
5866
|
if (isString(template)) template = { template };
|
|
@@ -5814,7 +6165,7 @@ export {
|
|
|
5814
6165
|
computeRef,
|
|
5815
6166
|
computed,
|
|
5816
6167
|
createApp,
|
|
5817
|
-
|
|
6168
|
+
defineComponent,
|
|
5818
6169
|
drainUnbind,
|
|
5819
6170
|
endBatch,
|
|
5820
6171
|
entangle,
|