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
|
@@ -32,7 +32,7 @@ var Regor = (() => {
|
|
|
32
32
|
computeRef: () => computeRef,
|
|
33
33
|
computed: () => computed,
|
|
34
34
|
createApp: () => createApp,
|
|
35
|
-
|
|
35
|
+
defineComponent: () => defineComponent,
|
|
36
36
|
drainUnbind: () => drainUnbind,
|
|
37
37
|
endBatch: () => endBatch,
|
|
38
38
|
entangle: () => entangle,
|
|
@@ -73,8 +73,8 @@ var Regor = (() => {
|
|
|
73
73
|
// src/cleanup/unbind.ts
|
|
74
74
|
var unbind = (node) => {
|
|
75
75
|
const stack = [node];
|
|
76
|
-
|
|
77
|
-
const currentNode = stack
|
|
76
|
+
for (let i = 0; i < stack.length; ++i) {
|
|
77
|
+
const currentNode = stack[i];
|
|
78
78
|
unbindSingle(currentNode);
|
|
79
79
|
for (let child = currentNode.lastChild; child != null; child = child.previousSibling) {
|
|
80
80
|
stack.push(child);
|
|
@@ -425,6 +425,8 @@ var Regor = (() => {
|
|
|
425
425
|
};
|
|
426
426
|
|
|
427
427
|
// src/bind/IfBinder.ts
|
|
428
|
+
var noopStopObserving = () => {
|
|
429
|
+
};
|
|
428
430
|
var mount = (nodes, binder, parent, end) => {
|
|
429
431
|
const childNodes = [];
|
|
430
432
|
for (const x of nodes) {
|
|
@@ -549,18 +551,14 @@ var Regor = (() => {
|
|
|
549
551
|
const parseResult = this.__binder.__parser.__parse(expression);
|
|
550
552
|
const value = parseResult.value;
|
|
551
553
|
const remainingElses = this.__collectElses(nextElement, refresh);
|
|
552
|
-
|
|
554
|
+
let stopObserver = noopStopObserving;
|
|
553
555
|
const unbinder = () => {
|
|
554
556
|
parseResult.stop();
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
stopObserverList.length = 0;
|
|
557
|
+
stopObserver();
|
|
558
|
+
stopObserver = noopStopObserving;
|
|
559
559
|
};
|
|
560
560
|
addUnbinder(commentBegin, unbinder);
|
|
561
|
-
|
|
562
|
-
};
|
|
563
|
-
stopObserverList.push(stopObserving);
|
|
561
|
+
stopObserver = parseResult.subscribe(refresh);
|
|
564
562
|
return [
|
|
565
563
|
{
|
|
566
564
|
mount: () => {
|
|
@@ -571,8 +569,9 @@ var Regor = (() => {
|
|
|
571
569
|
},
|
|
572
570
|
isTrue: () => !!value()[0],
|
|
573
571
|
isMounted: false
|
|
574
|
-
}
|
|
575
|
-
|
|
572
|
+
},
|
|
573
|
+
...remainingElses
|
|
574
|
+
];
|
|
576
575
|
}
|
|
577
576
|
}
|
|
578
577
|
__bindToExpression(el, expression) {
|
|
@@ -618,29 +617,31 @@ var Regor = (() => {
|
|
|
618
617
|
});
|
|
619
618
|
};
|
|
620
619
|
const collectedElses = this.__collectElses(nextElement, refresh);
|
|
621
|
-
|
|
620
|
+
let stopObserver = noopStopObserving;
|
|
622
621
|
const unbinder = () => {
|
|
623
622
|
parseResult.stop();
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
}
|
|
627
|
-
stopObserverList.length = 0;
|
|
623
|
+
stopObserver();
|
|
624
|
+
stopObserver = noopStopObserving;
|
|
628
625
|
};
|
|
629
626
|
addUnbinder(commentBegin, unbinder);
|
|
630
627
|
refresh();
|
|
631
|
-
|
|
632
|
-
};
|
|
633
|
-
stopObserverList.push(stopObserving);
|
|
628
|
+
stopObserver = parseResult.subscribe(refresh);
|
|
634
629
|
}
|
|
635
630
|
};
|
|
636
631
|
|
|
637
632
|
// src/common/common.ts
|
|
638
633
|
var getNodes = (el) => {
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
634
|
+
const source = isTemplate(el) ? el.content.childNodes : [el];
|
|
635
|
+
const result = [];
|
|
636
|
+
for (let i = 0; i < source.length; ++i) {
|
|
637
|
+
const node = source[i];
|
|
638
|
+
if (node.nodeType === 1) {
|
|
639
|
+
const tagName = node == null ? void 0 : node.tagName;
|
|
640
|
+
if (tagName === "SCRIPT" || tagName === "STYLE") continue;
|
|
641
|
+
}
|
|
642
|
+
result.push(node);
|
|
643
|
+
}
|
|
644
|
+
return result;
|
|
644
645
|
};
|
|
645
646
|
var bindChildNodes = (binder, childNodes) => {
|
|
646
647
|
for (let i = 0; i < childNodes.length; ++i) {
|
|
@@ -738,7 +739,9 @@ var Regor = (() => {
|
|
|
738
739
|
});
|
|
739
740
|
|
|
740
741
|
// src/directives/teleport.ts
|
|
741
|
-
var teleportDirective = {
|
|
742
|
+
var teleportDirective = {
|
|
743
|
+
mount: () => void 0
|
|
744
|
+
};
|
|
742
745
|
|
|
743
746
|
// src/composition/callMounted.ts
|
|
744
747
|
var callMounted = (context) => {
|
|
@@ -773,12 +776,6 @@ var Regor = (() => {
|
|
|
773
776
|
return scopeSymbol2 in value;
|
|
774
777
|
};
|
|
775
778
|
|
|
776
|
-
// src/composition/onUnmounted.ts
|
|
777
|
-
var onUnmounted = (onUnmounted2, noThrow) => {
|
|
778
|
-
var _a;
|
|
779
|
-
(_a = peekScope(noThrow)) == null ? void 0 : _a.onUnmounted.push(onUnmounted2);
|
|
780
|
-
};
|
|
781
|
-
|
|
782
779
|
// src/reactivity/refSymbols.ts
|
|
783
780
|
var refSymbol = Symbol("ref");
|
|
784
781
|
var srefSymbol = Symbol("sref");
|
|
@@ -789,6 +786,35 @@ var Regor = (() => {
|
|
|
789
786
|
return value != null && value[srefSymbol] === 1;
|
|
790
787
|
};
|
|
791
788
|
|
|
789
|
+
// src/directives/context.ts
|
|
790
|
+
var contextDirective = {
|
|
791
|
+
collectRefObj: true,
|
|
792
|
+
mount: ({ parseResult }) => ({
|
|
793
|
+
update: ({ values }) => {
|
|
794
|
+
const ctx = parseResult.context;
|
|
795
|
+
const obj = values[0];
|
|
796
|
+
if (!isObject(obj)) return;
|
|
797
|
+
for (const item of Object.entries(obj)) {
|
|
798
|
+
const key = item[0];
|
|
799
|
+
const nextValue = item[1];
|
|
800
|
+
const ctxKey = ctx[key];
|
|
801
|
+
if (ctxKey === nextValue) continue;
|
|
802
|
+
if (isRef(ctxKey)) {
|
|
803
|
+
ctxKey(nextValue);
|
|
804
|
+
} else {
|
|
805
|
+
ctx[key] = nextValue;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
})
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
// src/composition/onUnmounted.ts
|
|
813
|
+
var onUnmounted = (onUnmounted2, noThrow) => {
|
|
814
|
+
var _a;
|
|
815
|
+
(_a = peekScope(noThrow)) == null ? void 0 : _a.onUnmounted.push(onUnmounted2);
|
|
816
|
+
};
|
|
817
|
+
|
|
792
818
|
// src/observer/observe.ts
|
|
793
819
|
var observe = (source, observer, init, trackUnmount = true) => {
|
|
794
820
|
if (!isRef(source))
|
|
@@ -805,37 +831,6 @@ var Regor = (() => {
|
|
|
805
831
|
return stop;
|
|
806
832
|
};
|
|
807
833
|
|
|
808
|
-
// src/directives/context.ts
|
|
809
|
-
var contextDirective = {
|
|
810
|
-
collectRefObj: true,
|
|
811
|
-
onBind: (_, parseResult) => {
|
|
812
|
-
const stopObserving = observe(
|
|
813
|
-
parseResult.value,
|
|
814
|
-
() => {
|
|
815
|
-
const value = parseResult.value();
|
|
816
|
-
const ctx = parseResult.context;
|
|
817
|
-
const obj = value[0];
|
|
818
|
-
if (!isObject(obj)) {
|
|
819
|
-
return;
|
|
820
|
-
}
|
|
821
|
-
for (const item of Object.entries(obj)) {
|
|
822
|
-
const key = item[0];
|
|
823
|
-
const value2 = item[1];
|
|
824
|
-
const ctxKey = ctx[key];
|
|
825
|
-
if (ctxKey === value2) continue;
|
|
826
|
-
if (isRef(ctxKey)) {
|
|
827
|
-
ctxKey(value2);
|
|
828
|
-
} else {
|
|
829
|
-
ctx[key] = value2;
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
},
|
|
833
|
-
true
|
|
834
|
-
);
|
|
835
|
-
return stopObserving;
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
|
|
839
834
|
// src/reactivity/entangle.ts
|
|
840
835
|
var entangle = (r1, r2) => {
|
|
841
836
|
if (r1 === r2) return () => {
|
|
@@ -1163,8 +1158,8 @@ var Regor = (() => {
|
|
|
1163
1158
|
};
|
|
1164
1159
|
var singlePropDirective = {
|
|
1165
1160
|
collectRefObj: true,
|
|
1166
|
-
|
|
1167
|
-
if (!option) return noop;
|
|
1161
|
+
mount: ({ parseResult, option }) => {
|
|
1162
|
+
if (typeof option !== "string" || !option) return noop;
|
|
1168
1163
|
const key = camelize(option);
|
|
1169
1164
|
let currentSource;
|
|
1170
1165
|
let bridge;
|
|
@@ -1185,44 +1180,44 @@ var Regor = (() => {
|
|
|
1185
1180
|
stopEntangle = entangle(source, target);
|
|
1186
1181
|
currentSource = source;
|
|
1187
1182
|
};
|
|
1188
|
-
const
|
|
1189
|
-
|
|
1190
|
-
()
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
if (bridge && ctxKey === bridge) {
|
|
1197
|
-
bridge(value);
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
resetSync();
|
|
1201
|
-
if (isRef(ctxKey)) {
|
|
1202
|
-
ctxKey(value);
|
|
1203
|
-
return;
|
|
1204
|
-
}
|
|
1205
|
-
ctx[key] = value;
|
|
1183
|
+
const apply = () => {
|
|
1184
|
+
var _a;
|
|
1185
|
+
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
1186
|
+
const ctx = parseResult.context;
|
|
1187
|
+
const ctxKey = ctx[key];
|
|
1188
|
+
if (!isRef(value)) {
|
|
1189
|
+
if (bridge && ctxKey === bridge) {
|
|
1190
|
+
bridge(value);
|
|
1206
1191
|
return;
|
|
1207
1192
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
syncRefs(value, ctxKey);
|
|
1212
|
-
} else {
|
|
1213
|
-
ctx[key] = value;
|
|
1214
|
-
}
|
|
1193
|
+
resetSync();
|
|
1194
|
+
if (isRef(ctxKey)) {
|
|
1195
|
+
ctxKey(value);
|
|
1215
1196
|
return;
|
|
1216
1197
|
}
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1198
|
+
ctx[key] = value;
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
if (isModelBridge(value)) {
|
|
1202
|
+
if (ctxKey === value) return;
|
|
1203
|
+
if (isRef(ctxKey)) {
|
|
1204
|
+
syncRefs(value, ctxKey);
|
|
1205
|
+
} else {
|
|
1206
|
+
ctx[key] = value;
|
|
1207
|
+
}
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
if (!bridge) bridge = createModelBridge(value);
|
|
1211
|
+
ctx[key] = bridge;
|
|
1212
|
+
syncRefs(value, bridge);
|
|
1213
|
+
};
|
|
1214
|
+
return {
|
|
1215
|
+
update: () => {
|
|
1216
|
+
apply();
|
|
1220
1217
|
},
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
stopEntangle();
|
|
1225
|
-
stopObserving();
|
|
1218
|
+
unmount: () => {
|
|
1219
|
+
stopEntangle();
|
|
1220
|
+
}
|
|
1226
1221
|
};
|
|
1227
1222
|
}
|
|
1228
1223
|
};
|
|
@@ -1243,7 +1238,10 @@ var Regor = (() => {
|
|
|
1243
1238
|
__getRegisteredComponentSelector(registeredComponents) {
|
|
1244
1239
|
if (this.__registeredComponentSize !== registeredComponents.size) {
|
|
1245
1240
|
const names = [...registeredComponents.keys()];
|
|
1246
|
-
this.__registeredComponentSelector =
|
|
1241
|
+
this.__registeredComponentSelector = [
|
|
1242
|
+
...names,
|
|
1243
|
+
...names.map(hyphenate)
|
|
1244
|
+
].join(",");
|
|
1247
1245
|
this.__registeredComponentSize = registeredComponents.size;
|
|
1248
1246
|
}
|
|
1249
1247
|
return this.__registeredComponentSelector;
|
|
@@ -1320,7 +1318,10 @@ var Regor = (() => {
|
|
|
1320
1318
|
definedProp
|
|
1321
1319
|
])
|
|
1322
1320
|
);
|
|
1323
|
-
for (const name of
|
|
1321
|
+
for (const name of [
|
|
1322
|
+
...definedProps,
|
|
1323
|
+
...definedProps.map(hyphenate)
|
|
1324
|
+
]) {
|
|
1324
1325
|
const value = component2.getAttribute(name);
|
|
1325
1326
|
if (value === null) continue;
|
|
1326
1327
|
props[camelize(name)] = value;
|
|
@@ -1615,18 +1616,17 @@ var Regor = (() => {
|
|
|
1615
1616
|
}
|
|
1616
1617
|
};
|
|
1617
1618
|
const processNode = (node) => {
|
|
1618
|
-
var _a
|
|
1619
|
+
var _a;
|
|
1619
1620
|
const attrs = node.attributes;
|
|
1620
1621
|
if (!attrs || attrs.length === 0) return;
|
|
1621
|
-
const attrsAny = attrs;
|
|
1622
1622
|
for (let i = 0; i < attrs.length; ++i) {
|
|
1623
|
-
const name = (
|
|
1623
|
+
const name = (_a = attrs.item(i)) == null ? void 0 : _a.name;
|
|
1624
1624
|
if (!name) continue;
|
|
1625
1625
|
appendDirective(node, name);
|
|
1626
1626
|
}
|
|
1627
1627
|
};
|
|
1628
1628
|
processNode(element);
|
|
1629
|
-
if (!isRecursive) return map;
|
|
1629
|
+
if (!isRecursive || !element.firstElementChild) return map;
|
|
1630
1630
|
const nodes = element.querySelectorAll("*");
|
|
1631
1631
|
for (const node of nodes) {
|
|
1632
1632
|
processNode(node);
|
|
@@ -1636,6 +1636,8 @@ var Regor = (() => {
|
|
|
1636
1636
|
};
|
|
1637
1637
|
|
|
1638
1638
|
// src/bind/DynamicBinder.ts
|
|
1639
|
+
var noopStopObserving2 = () => {
|
|
1640
|
+
};
|
|
1639
1641
|
var mount2 = (nodes, parent) => {
|
|
1640
1642
|
for (const x of nodes) {
|
|
1641
1643
|
const node = x.cloneNode(true);
|
|
@@ -1751,19 +1753,15 @@ var Regor = (() => {
|
|
|
1751
1753
|
mounted.name = name;
|
|
1752
1754
|
});
|
|
1753
1755
|
};
|
|
1754
|
-
|
|
1756
|
+
let stopObserver = noopStopObserving2;
|
|
1755
1757
|
const unbinder = () => {
|
|
1756
1758
|
parseResult.stop();
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
}
|
|
1760
|
-
stopObserverList.length = 0;
|
|
1759
|
+
stopObserver();
|
|
1760
|
+
stopObserver = noopStopObserving2;
|
|
1761
1761
|
};
|
|
1762
1762
|
addUnbinder(commentBegin, unbinder);
|
|
1763
1763
|
refresh();
|
|
1764
|
-
|
|
1765
|
-
};
|
|
1766
|
-
stopObserverList.push(stopObserving);
|
|
1764
|
+
stopObserver = parseResult.subscribe(refresh);
|
|
1767
1765
|
}
|
|
1768
1766
|
};
|
|
1769
1767
|
|
|
@@ -1773,6 +1771,274 @@ var Regor = (() => {
|
|
|
1773
1771
|
return anyValue != null && anyValue[srefSymbol] === 1 ? anyValue() : anyValue;
|
|
1774
1772
|
};
|
|
1775
1773
|
|
|
1774
|
+
// src/directives/html.ts
|
|
1775
|
+
var updateHtml = (el, values) => {
|
|
1776
|
+
const [value, replacer] = values;
|
|
1777
|
+
if (isFunction(replacer)) replacer(el, value);
|
|
1778
|
+
else el.innerHTML = value == null ? void 0 : value.toString();
|
|
1779
|
+
};
|
|
1780
|
+
var htmlDirective = {
|
|
1781
|
+
mount: () => ({
|
|
1782
|
+
update: ({ el, values }) => {
|
|
1783
|
+
updateHtml(el, values);
|
|
1784
|
+
}
|
|
1785
|
+
})
|
|
1786
|
+
};
|
|
1787
|
+
|
|
1788
|
+
// src/bind/ForBinderFastPath.ts
|
|
1789
|
+
var ForBinderFastPath = class _ForBinderFastPath {
|
|
1790
|
+
constructor(bindings) {
|
|
1791
|
+
__publicField(this, "__bindings");
|
|
1792
|
+
this.__bindings = bindings;
|
|
1793
|
+
}
|
|
1794
|
+
static __create(binder, nodes) {
|
|
1795
|
+
var _a, _b;
|
|
1796
|
+
const parser = binder.__parser;
|
|
1797
|
+
const config = binder.__config;
|
|
1798
|
+
const builtInNames = config.__builtInNames;
|
|
1799
|
+
const blockedBuiltIns = /* @__PURE__ */ new Set([
|
|
1800
|
+
builtInNames.for,
|
|
1801
|
+
builtInNames.if,
|
|
1802
|
+
builtInNames.else,
|
|
1803
|
+
builtInNames.elseif,
|
|
1804
|
+
builtInNames.pre
|
|
1805
|
+
]);
|
|
1806
|
+
const directiveMap = config.__directiveMap;
|
|
1807
|
+
const contextComponents = parser.__getComponents();
|
|
1808
|
+
if (Object.keys(contextComponents).length > 0 || config.__componentsUpperCase.size > 0) {
|
|
1809
|
+
return void 0;
|
|
1810
|
+
}
|
|
1811
|
+
const collector = binder.__directiveCollector;
|
|
1812
|
+
const bindings = [];
|
|
1813
|
+
let nodeIndex = 0;
|
|
1814
|
+
const stack = [];
|
|
1815
|
+
for (let i = nodes.length - 1; i >= 0; --i) {
|
|
1816
|
+
stack.push(nodes[i]);
|
|
1817
|
+
}
|
|
1818
|
+
while (stack.length > 0) {
|
|
1819
|
+
const node = stack.pop();
|
|
1820
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1821
|
+
const el = node;
|
|
1822
|
+
if (el.tagName === "TEMPLATE") return void 0;
|
|
1823
|
+
if (el.tagName.includes("-")) return void 0;
|
|
1824
|
+
const tagNameUpper = camelize(el.tagName).toUpperCase();
|
|
1825
|
+
if (config.__componentsUpperCase.has(tagNameUpper) || contextComponents[tagNameUpper]) {
|
|
1826
|
+
return void 0;
|
|
1827
|
+
}
|
|
1828
|
+
const attrs = el.attributes;
|
|
1829
|
+
for (let i = 0; i < attrs.length; ++i) {
|
|
1830
|
+
const attrName = (_a = attrs.item(i)) == null ? void 0 : _a.name;
|
|
1831
|
+
if (!attrName) continue;
|
|
1832
|
+
if (blockedBuiltIns.has(attrName)) return void 0;
|
|
1833
|
+
const { terms, flags } = collector.__parseName(attrName);
|
|
1834
|
+
const [name, option] = terms;
|
|
1835
|
+
const directive = (_b = directiveMap[attrName]) != null ? _b : directiveMap[name];
|
|
1836
|
+
if (!directive) continue;
|
|
1837
|
+
if (directive === htmlDirective) return void 0;
|
|
1838
|
+
bindings.push({
|
|
1839
|
+
nodeIndex,
|
|
1840
|
+
attrName,
|
|
1841
|
+
directive,
|
|
1842
|
+
option,
|
|
1843
|
+
flags
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
++nodeIndex;
|
|
1847
|
+
}
|
|
1848
|
+
const children = node.childNodes;
|
|
1849
|
+
for (let i = children.length - 1; i >= 0; --i) {
|
|
1850
|
+
stack.push(children[i]);
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
if (bindings.length === 0) return void 0;
|
|
1854
|
+
return new _ForBinderFastPath(bindings);
|
|
1855
|
+
}
|
|
1856
|
+
__bind(binder, nodes) {
|
|
1857
|
+
const elements = [];
|
|
1858
|
+
const stack = [];
|
|
1859
|
+
for (let i = nodes.length - 1; i >= 0; --i) {
|
|
1860
|
+
stack.push(nodes[i]);
|
|
1861
|
+
}
|
|
1862
|
+
while (stack.length > 0) {
|
|
1863
|
+
const node = stack.pop();
|
|
1864
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1865
|
+
elements.push(node);
|
|
1866
|
+
}
|
|
1867
|
+
const children = node.childNodes;
|
|
1868
|
+
for (let i = children.length - 1; i >= 0; --i) {
|
|
1869
|
+
stack.push(children[i]);
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
for (let i = 0; i < this.__bindings.length; ++i) {
|
|
1873
|
+
const binding = this.__bindings[i];
|
|
1874
|
+
const el = elements[binding.nodeIndex];
|
|
1875
|
+
if (!el) continue;
|
|
1876
|
+
binder.__bind(
|
|
1877
|
+
binding.directive,
|
|
1878
|
+
el,
|
|
1879
|
+
binding.attrName,
|
|
1880
|
+
false,
|
|
1881
|
+
binding.option,
|
|
1882
|
+
binding.flags
|
|
1883
|
+
);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
};
|
|
1887
|
+
|
|
1888
|
+
// src/bind/ForBinderKeyedDiff.ts
|
|
1889
|
+
var moveMountItemBefore = (item, anchor) => {
|
|
1890
|
+
const parent = anchor.parentNode;
|
|
1891
|
+
if (!parent) return;
|
|
1892
|
+
for (let i = 0; i < item.items.length; ++i) {
|
|
1893
|
+
parent.insertBefore(item.items[i], anchor);
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
var getSequence = (arr) => {
|
|
1897
|
+
var _a;
|
|
1898
|
+
const len = arr.length;
|
|
1899
|
+
const p = arr.slice();
|
|
1900
|
+
const result = [];
|
|
1901
|
+
let u;
|
|
1902
|
+
let v;
|
|
1903
|
+
let c;
|
|
1904
|
+
for (let i = 0; i < len; ++i) {
|
|
1905
|
+
const value = arr[i];
|
|
1906
|
+
if (value === 0) continue;
|
|
1907
|
+
const j = result[result.length - 1];
|
|
1908
|
+
if (j === void 0 || arr[j] < value) {
|
|
1909
|
+
p[i] = j != null ? j : -1;
|
|
1910
|
+
result.push(i);
|
|
1911
|
+
continue;
|
|
1912
|
+
}
|
|
1913
|
+
u = 0;
|
|
1914
|
+
v = result.length - 1;
|
|
1915
|
+
while (u < v) {
|
|
1916
|
+
c = u + v >> 1;
|
|
1917
|
+
if (arr[result[c]] < value) u = c + 1;
|
|
1918
|
+
else v = c;
|
|
1919
|
+
}
|
|
1920
|
+
if (value < arr[result[u]]) {
|
|
1921
|
+
if (u > 0) p[i] = result[u - 1];
|
|
1922
|
+
result[u] = i;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
u = result.length;
|
|
1926
|
+
v = (_a = result[u - 1]) != null ? _a : -1;
|
|
1927
|
+
while (u-- > 0) {
|
|
1928
|
+
result[u] = v;
|
|
1929
|
+
v = p[v];
|
|
1930
|
+
}
|
|
1931
|
+
return result;
|
|
1932
|
+
};
|
|
1933
|
+
var ForBinderKeyedDiff = class {
|
|
1934
|
+
/**
|
|
1935
|
+
* Applies keyed patch and returns the next ordered mount list.
|
|
1936
|
+
* Returns `undefined` when keyed mode is not safe for this update.
|
|
1937
|
+
*/
|
|
1938
|
+
static __patch(options) {
|
|
1939
|
+
const {
|
|
1940
|
+
oldItems,
|
|
1941
|
+
newValues,
|
|
1942
|
+
getKey,
|
|
1943
|
+
isSameValue,
|
|
1944
|
+
mountNewValue,
|
|
1945
|
+
removeMountItem,
|
|
1946
|
+
endAnchor
|
|
1947
|
+
} = options;
|
|
1948
|
+
const oldLen = oldItems.length;
|
|
1949
|
+
const newLen = newValues.length;
|
|
1950
|
+
const newKeys = new Array(newLen);
|
|
1951
|
+
const keySeen = /* @__PURE__ */ new Set();
|
|
1952
|
+
for (let i2 = 0; i2 < newLen; ++i2) {
|
|
1953
|
+
const key = getKey(newValues[i2]);
|
|
1954
|
+
if (key === void 0 || keySeen.has(key)) return void 0;
|
|
1955
|
+
keySeen.add(key);
|
|
1956
|
+
newKeys[i2] = key;
|
|
1957
|
+
}
|
|
1958
|
+
const newMountItems = new Array(newLen);
|
|
1959
|
+
let i = 0;
|
|
1960
|
+
let e1 = oldLen - 1;
|
|
1961
|
+
let e2 = newLen - 1;
|
|
1962
|
+
while (i <= e1 && i <= e2) {
|
|
1963
|
+
const oldItem = oldItems[i];
|
|
1964
|
+
if (getKey(oldItem.value) !== newKeys[i]) break;
|
|
1965
|
+
if (!isSameValue(oldItem.value, newValues[i])) break;
|
|
1966
|
+
oldItem.value = newValues[i];
|
|
1967
|
+
newMountItems[i] = oldItem;
|
|
1968
|
+
++i;
|
|
1969
|
+
}
|
|
1970
|
+
while (i <= e1 && i <= e2) {
|
|
1971
|
+
const oldItem = oldItems[e1];
|
|
1972
|
+
if (getKey(oldItem.value) !== newKeys[e2]) break;
|
|
1973
|
+
if (!isSameValue(oldItem.value, newValues[e2])) break;
|
|
1974
|
+
oldItem.value = newValues[e2];
|
|
1975
|
+
newMountItems[e2] = oldItem;
|
|
1976
|
+
--e1;
|
|
1977
|
+
--e2;
|
|
1978
|
+
}
|
|
1979
|
+
if (i > e1) {
|
|
1980
|
+
for (let k = e2; k >= i; --k) {
|
|
1981
|
+
const anchor = k + 1 < newLen ? newMountItems[k + 1].items[0] : endAnchor;
|
|
1982
|
+
newMountItems[k] = mountNewValue(k, newValues[k], anchor);
|
|
1983
|
+
}
|
|
1984
|
+
return newMountItems;
|
|
1985
|
+
}
|
|
1986
|
+
if (i > e2) {
|
|
1987
|
+
for (let k = i; k <= e1; ++k) removeMountItem(oldItems[k]);
|
|
1988
|
+
return newMountItems;
|
|
1989
|
+
}
|
|
1990
|
+
const s1 = i;
|
|
1991
|
+
const s2 = i;
|
|
1992
|
+
const toBePatched = e2 - s2 + 1;
|
|
1993
|
+
const newIndexToOldIndexMap = new Array(toBePatched).fill(0);
|
|
1994
|
+
const keyToNewIndexMap = /* @__PURE__ */ new Map();
|
|
1995
|
+
for (let k = s2; k <= e2; ++k) {
|
|
1996
|
+
keyToNewIndexMap.set(newKeys[k], k);
|
|
1997
|
+
}
|
|
1998
|
+
let moved = false;
|
|
1999
|
+
let maxNewIndexSoFar = 0;
|
|
2000
|
+
for (let k = s1; k <= e1; ++k) {
|
|
2001
|
+
const oldItem = oldItems[k];
|
|
2002
|
+
const newIndex = keyToNewIndexMap.get(getKey(oldItem.value));
|
|
2003
|
+
if (newIndex === void 0) {
|
|
2004
|
+
removeMountItem(oldItem);
|
|
2005
|
+
continue;
|
|
2006
|
+
}
|
|
2007
|
+
if (!isSameValue(oldItem.value, newValues[newIndex])) {
|
|
2008
|
+
removeMountItem(oldItem);
|
|
2009
|
+
continue;
|
|
2010
|
+
}
|
|
2011
|
+
oldItem.value = newValues[newIndex];
|
|
2012
|
+
newMountItems[newIndex] = oldItem;
|
|
2013
|
+
newIndexToOldIndexMap[newIndex - s2] = k + 1;
|
|
2014
|
+
if (newIndex >= maxNewIndexSoFar) maxNewIndexSoFar = newIndex;
|
|
2015
|
+
else moved = true;
|
|
2016
|
+
}
|
|
2017
|
+
const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : [];
|
|
2018
|
+
let seqIdx = increasingNewIndexSequence.length - 1;
|
|
2019
|
+
for (let k = toBePatched - 1; k >= 0; --k) {
|
|
2020
|
+
const newIndex = s2 + k;
|
|
2021
|
+
const anchor = newIndex + 1 < newLen ? newMountItems[newIndex + 1].items[0] : endAnchor;
|
|
2022
|
+
if (newIndexToOldIndexMap[k] === 0) {
|
|
2023
|
+
newMountItems[newIndex] = mountNewValue(
|
|
2024
|
+
newIndex,
|
|
2025
|
+
newValues[newIndex],
|
|
2026
|
+
anchor
|
|
2027
|
+
);
|
|
2028
|
+
continue;
|
|
2029
|
+
}
|
|
2030
|
+
const item = newMountItems[newIndex];
|
|
2031
|
+
if (!moved) continue;
|
|
2032
|
+
if (seqIdx >= 0 && increasingNewIndexSequence[seqIdx] === k) {
|
|
2033
|
+
--seqIdx;
|
|
2034
|
+
} else if (item) {
|
|
2035
|
+
moveMountItemBefore(item, anchor);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
return newMountItems;
|
|
2039
|
+
}
|
|
2040
|
+
};
|
|
2041
|
+
|
|
1776
2042
|
// src/bind/MountList.ts
|
|
1777
2043
|
var MountList = class {
|
|
1778
2044
|
constructor(getKey) {
|
|
@@ -1854,6 +2120,8 @@ var Regor = (() => {
|
|
|
1854
2120
|
// src/bind/ForBinder.ts
|
|
1855
2121
|
var forMarker = Symbol("r-for");
|
|
1856
2122
|
var noIndexRef = (_) => -1;
|
|
2123
|
+
var noopStopObserving3 = () => {
|
|
2124
|
+
};
|
|
1857
2125
|
var _ForBinder = class _ForBinder {
|
|
1858
2126
|
constructor(binder) {
|
|
1859
2127
|
__publicField(this, "__binder");
|
|
@@ -1924,6 +2192,7 @@ var Regor = (() => {
|
|
|
1924
2192
|
el.removeAttribute(nameKey);
|
|
1925
2193
|
el.removeAttribute(nameKeyBind);
|
|
1926
2194
|
const nodes = getNodes(el);
|
|
2195
|
+
const fastPath = ForBinderFastPath.__create(this.__binder, nodes);
|
|
1927
2196
|
const parent = el.parentNode;
|
|
1928
2197
|
if (!parent) return;
|
|
1929
2198
|
const title = `${this.__for} => ${forPath}`;
|
|
@@ -1943,6 +2212,7 @@ var Regor = (() => {
|
|
|
1943
2212
|
const rowContexts = singleCapturedContext ? [void 0, capturedContext[0]] : void 0;
|
|
1944
2213
|
const getKey = this.__createKeyGetter(keyExpression);
|
|
1945
2214
|
const areEqual = (a, b) => getKey(a) === getKey(b);
|
|
2215
|
+
const isSameValue = (a, b) => a === b;
|
|
1946
2216
|
const mountNewValue = (i2, newValue, nextSibling) => {
|
|
1947
2217
|
const result = config.createContext(newValue, i2);
|
|
1948
2218
|
const mountItem = MountList.__createItem(result.index, newValue);
|
|
@@ -1956,7 +2226,8 @@ var Regor = (() => {
|
|
|
1956
2226
|
insertParent.insertBefore(node, nextSibling);
|
|
1957
2227
|
childNodes.push(node);
|
|
1958
2228
|
}
|
|
1959
|
-
|
|
2229
|
+
if (fastPath) fastPath.__bind(binder, childNodes);
|
|
2230
|
+
else bindChildNodes(binder, childNodes);
|
|
1960
2231
|
start = start.nextSibling;
|
|
1961
2232
|
while (start !== nextSibling) {
|
|
1962
2233
|
mountItem.items.push(start);
|
|
@@ -2008,16 +2279,51 @@ var Regor = (() => {
|
|
|
2008
2279
|
mountList.__removeAllAfter(0);
|
|
2009
2280
|
return;
|
|
2010
2281
|
}
|
|
2282
|
+
const iterableValues = [];
|
|
2283
|
+
for (const value2 of this.__getIterable(newValues[0])) {
|
|
2284
|
+
iterableValues.push(value2);
|
|
2285
|
+
}
|
|
2286
|
+
const patched = ForBinderKeyedDiff.__patch({
|
|
2287
|
+
oldItems: mountList.__list,
|
|
2288
|
+
newValues: iterableValues,
|
|
2289
|
+
getKey,
|
|
2290
|
+
isSameValue,
|
|
2291
|
+
mountNewValue: (index, value2, nextSibling) => mountNewValue(index, value2, nextSibling),
|
|
2292
|
+
removeMountItem: (item) => {
|
|
2293
|
+
for (let k = 0; k < item.items.length; ++k) {
|
|
2294
|
+
removeNode(item.items[k]);
|
|
2295
|
+
}
|
|
2296
|
+
},
|
|
2297
|
+
endAnchor: commentEnd
|
|
2298
|
+
});
|
|
2299
|
+
if (patched) {
|
|
2300
|
+
mountList.__list = patched;
|
|
2301
|
+
mountList.__valueMap.clear();
|
|
2302
|
+
for (let k = 0; k < patched.length; ++k) {
|
|
2303
|
+
const item = patched[k];
|
|
2304
|
+
item.order = k;
|
|
2305
|
+
item.index(k);
|
|
2306
|
+
const key = getKey(item.value);
|
|
2307
|
+
if (key !== void 0) {
|
|
2308
|
+
mountList.__valueMap.set(key, item);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2011
2313
|
let i2 = 0;
|
|
2012
2314
|
let firstRemovalOrInsertionIndex = Number.MAX_SAFE_INTEGER;
|
|
2013
2315
|
const initialLength = len;
|
|
2014
2316
|
const forGrowThreshold = this.__binder.__config.forGrowThreshold;
|
|
2015
2317
|
const shouldGrowList = () => mountList.__length < initialLength + forGrowThreshold;
|
|
2016
|
-
for (const newValue of
|
|
2318
|
+
for (const newValue of iterableValues) {
|
|
2017
2319
|
const modify = () => {
|
|
2018
2320
|
if (i2 < len) {
|
|
2019
2321
|
const mountItem = mountList.__get(i2++);
|
|
2020
|
-
if (areEqual(mountItem.value, newValue))
|
|
2322
|
+
if (areEqual(mountItem.value, newValue)) {
|
|
2323
|
+
if (isSameValue(mountItem.value, newValue)) return;
|
|
2324
|
+
replace(i2 - 1, newValue);
|
|
2325
|
+
return;
|
|
2326
|
+
}
|
|
2021
2327
|
const newValueMountPosition = mountList.__lookupValueOrderIfMounted(
|
|
2022
2328
|
getKey(newValue)
|
|
2023
2329
|
);
|
|
@@ -2067,24 +2373,21 @@ var Regor = (() => {
|
|
|
2067
2373
|
mountList.__removeAllAfter(j);
|
|
2068
2374
|
updateIndexes(firstRemovalOrInsertionIndex);
|
|
2069
2375
|
};
|
|
2070
|
-
const observeTailChanges = () => {
|
|
2071
|
-
stopObserving = parseResult.subscribe ? parseResult.subscribe(updateDom) : () => {
|
|
2072
|
-
};
|
|
2073
|
-
};
|
|
2074
2376
|
const unbinder = () => {
|
|
2075
2377
|
parseResult.stop();
|
|
2076
2378
|
stopObserving();
|
|
2379
|
+
stopObserving = noopStopObserving3;
|
|
2077
2380
|
};
|
|
2078
2381
|
const parseResult = parser.__parse(config.list);
|
|
2079
2382
|
const value = parseResult.value;
|
|
2080
|
-
let stopObserving;
|
|
2383
|
+
let stopObserving = noopStopObserving3;
|
|
2081
2384
|
let i = 0;
|
|
2082
2385
|
const mountList = new MountList(getKey);
|
|
2083
2386
|
for (const item of this.__getIterable(value()[0])) {
|
|
2084
2387
|
mountList.__push(mountNewValue(i++, item, commentEnd));
|
|
2085
2388
|
}
|
|
2086
2389
|
addUnbinder(commentBegin, unbinder);
|
|
2087
|
-
|
|
2390
|
+
stopObserving = parseResult.subscribe(updateDom);
|
|
2088
2391
|
}
|
|
2089
2392
|
__parseForPath(forPath) {
|
|
2090
2393
|
var _a, _b;
|
|
@@ -2268,105 +2571,111 @@ var Regor = (() => {
|
|
|
2268
2571
|
return true;
|
|
2269
2572
|
}
|
|
2270
2573
|
__bindToExpression(config, el, valueExpression, option, flags) {
|
|
2271
|
-
var _a;
|
|
2272
2574
|
if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null) return;
|
|
2273
2575
|
if (this.__handleTeleport(config, el, valueExpression)) return;
|
|
2274
|
-
const
|
|
2576
|
+
const dynamicOption = this.__parseDynamicOption(option, config.once);
|
|
2577
|
+
const result = this.__parseExpression(config, valueExpression);
|
|
2578
|
+
const stops = this.__createBindStops(result, dynamicOption);
|
|
2579
|
+
addUnbinder(el, stops.stop);
|
|
2580
|
+
const payload = this.__createDirectivePayload(
|
|
2581
|
+
el,
|
|
2582
|
+
valueExpression,
|
|
2583
|
+
result,
|
|
2584
|
+
dynamicOption,
|
|
2585
|
+
option,
|
|
2586
|
+
flags
|
|
2587
|
+
);
|
|
2588
|
+
const mountedUpdate = this.__mountDirective(config, payload, stops);
|
|
2589
|
+
if (!mountedUpdate) return;
|
|
2590
|
+
const emitChange = this.__createEmitter(
|
|
2591
|
+
payload,
|
|
2592
|
+
result,
|
|
2593
|
+
dynamicOption,
|
|
2594
|
+
option,
|
|
2595
|
+
mountedUpdate
|
|
2596
|
+
);
|
|
2597
|
+
emitChange();
|
|
2598
|
+
if (!config.once) {
|
|
2599
|
+
stops.result = result.subscribe(emitChange);
|
|
2600
|
+
if (dynamicOption) {
|
|
2601
|
+
stops.dynamic = dynamicOption.subscribe(emitChange);
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
__parseDynamicOption(option, once) {
|
|
2606
|
+
const dynamicOptionExpression = isOptionDynamic(option, this.__dynamic);
|
|
2607
|
+
if (!dynamicOptionExpression) return void 0;
|
|
2608
|
+
return this.__parser.__parse(
|
|
2609
|
+
camelize(dynamicOptionExpression),
|
|
2610
|
+
void 0,
|
|
2611
|
+
void 0,
|
|
2612
|
+
void 0,
|
|
2613
|
+
once
|
|
2614
|
+
);
|
|
2615
|
+
}
|
|
2616
|
+
__parseExpression(config, valueExpression) {
|
|
2617
|
+
return this.__parser.__parse(
|
|
2275
2618
|
valueExpression,
|
|
2276
2619
|
config.isLazy,
|
|
2277
2620
|
config.isLazyKey,
|
|
2278
2621
|
config.collectRefObj,
|
|
2279
2622
|
config.once
|
|
2280
2623
|
);
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
const
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2624
|
+
}
|
|
2625
|
+
__createBindStops(result, dynamicOption) {
|
|
2626
|
+
const stops = {
|
|
2627
|
+
stop: () => {
|
|
2628
|
+
var _a, _b, _c;
|
|
2629
|
+
result.stop();
|
|
2630
|
+
dynamicOption == null ? void 0 : dynamicOption.stop();
|
|
2631
|
+
(_a = stops.result) == null ? void 0 : _a.call(stops);
|
|
2632
|
+
(_b = stops.dynamic) == null ? void 0 : _b.call(stops);
|
|
2633
|
+
(_c = stops.mounted) == null ? void 0 : _c.call(stops);
|
|
2634
|
+
stops.result = void 0;
|
|
2635
|
+
stops.dynamic = void 0;
|
|
2636
|
+
stops.mounted = void 0;
|
|
2288
2637
|
}
|
|
2289
|
-
stopObserverList.length = 0;
|
|
2290
2638
|
};
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2639
|
+
return stops;
|
|
2640
|
+
}
|
|
2641
|
+
__createDirectivePayload(el, expr, result, dynamicOption, option, flags) {
|
|
2642
|
+
return {
|
|
2643
|
+
el,
|
|
2644
|
+
expr,
|
|
2645
|
+
values: result.value(),
|
|
2646
|
+
previousValues: void 0,
|
|
2647
|
+
option: dynamicOption ? dynamicOption.value()[0] : option,
|
|
2648
|
+
previousOption: void 0,
|
|
2649
|
+
flags,
|
|
2650
|
+
parseResult: result,
|
|
2651
|
+
dynamicOption
|
|
2652
|
+
};
|
|
2653
|
+
}
|
|
2654
|
+
__mountDirective(config, payload, stops) {
|
|
2655
|
+
const mounted = config.mount(payload);
|
|
2656
|
+
if (typeof mounted === "function") {
|
|
2657
|
+
stops.mounted = mounted;
|
|
2658
|
+
return void 0;
|
|
2302
2659
|
}
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
let previousValues = result.value();
|
|
2306
|
-
let previousOption = hasDynamicOption ? dynamicOption.value()[0] : option;
|
|
2307
|
-
if (!config.once && hasOnChange) {
|
|
2308
|
-
const stopObserving = result.subscribe ? result.subscribe(() => {
|
|
2309
|
-
var _a2;
|
|
2310
|
-
const preValues = previousValues;
|
|
2311
|
-
const preOption = previousOption;
|
|
2312
|
-
const nextValues = result.value();
|
|
2313
|
-
const nextOption = hasDynamicOption ? dynamicOpt.value()[0] : option;
|
|
2314
|
-
previousValues = nextValues;
|
|
2315
|
-
previousOption = nextOption;
|
|
2316
|
-
(_a2 = config.onChange) == null ? void 0 : _a2.call(
|
|
2317
|
-
config,
|
|
2318
|
-
el,
|
|
2319
|
-
nextValues,
|
|
2320
|
-
preValues,
|
|
2321
|
-
nextOption,
|
|
2322
|
-
preOption,
|
|
2323
|
-
flags
|
|
2324
|
-
);
|
|
2325
|
-
}) : () => {
|
|
2326
|
-
};
|
|
2327
|
-
stopObserverList.push(stopObserving);
|
|
2328
|
-
if (dynamicOpt) {
|
|
2329
|
-
const stopObserving2 = dynamicOpt.subscribe ? dynamicOpt.subscribe(() => {
|
|
2330
|
-
var _a2;
|
|
2331
|
-
const preOption = previousOption;
|
|
2332
|
-
const nextValues = result.value();
|
|
2333
|
-
const nextOption = dynamicOpt.value()[0];
|
|
2334
|
-
previousValues = nextValues;
|
|
2335
|
-
previousOption = nextOption;
|
|
2336
|
-
(_a2 = config.onChange) == null ? void 0 : _a2.call(
|
|
2337
|
-
config,
|
|
2338
|
-
el,
|
|
2339
|
-
nextValues,
|
|
2340
|
-
preOption,
|
|
2341
|
-
nextOption,
|
|
2342
|
-
preOption,
|
|
2343
|
-
flags
|
|
2344
|
-
);
|
|
2345
|
-
}) : () => {
|
|
2346
|
-
};
|
|
2347
|
-
stopObserverList.push(stopObserving2);
|
|
2348
|
-
}
|
|
2660
|
+
if (mounted == null ? void 0 : mounted.unmount) {
|
|
2661
|
+
stops.mounted = mounted.unmount;
|
|
2349
2662
|
}
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
previousOption,
|
|
2367
|
-
void 0,
|
|
2368
|
-
flags
|
|
2369
|
-
);
|
|
2663
|
+
return mounted == null ? void 0 : mounted.update;
|
|
2664
|
+
}
|
|
2665
|
+
__createEmitter(payload, result, dynamicOption, option, mountedUpdate) {
|
|
2666
|
+
let previousValues;
|
|
2667
|
+
let previousOption;
|
|
2668
|
+
return () => {
|
|
2669
|
+
const nextValues = result.value();
|
|
2670
|
+
const nextOption = dynamicOption ? dynamicOption.value()[0] : option;
|
|
2671
|
+
payload.values = nextValues;
|
|
2672
|
+
payload.previousValues = previousValues;
|
|
2673
|
+
payload.option = nextOption;
|
|
2674
|
+
payload.previousOption = previousOption;
|
|
2675
|
+
previousValues = nextValues;
|
|
2676
|
+
previousOption = nextOption;
|
|
2677
|
+
mountedUpdate(payload);
|
|
2678
|
+
};
|
|
2370
2679
|
}
|
|
2371
2680
|
};
|
|
2372
2681
|
|
|
@@ -2403,39 +2712,51 @@ var Regor = (() => {
|
|
|
2403
2712
|
function includeBooleanAttr(value) {
|
|
2404
2713
|
return !!value || value === "";
|
|
2405
2714
|
}
|
|
2406
|
-
var
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
if (option)
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
const previousKey = p && key in p ? key : void 0;
|
|
2428
|
-
patchAttribute(el, key, value, previousKey);
|
|
2429
|
-
}
|
|
2430
|
-
} else {
|
|
2431
|
-
const previousKey = previousValues == null ? void 0 : previousValues[i];
|
|
2432
|
-
const key = values[i++];
|
|
2433
|
-
const value = values[i];
|
|
2715
|
+
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
2716
|
+
var _a;
|
|
2717
|
+
if (option) {
|
|
2718
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
2719
|
+
patchAttribute(el, option, values[0], previousOption);
|
|
2720
|
+
return;
|
|
2721
|
+
}
|
|
2722
|
+
const len = values.length;
|
|
2723
|
+
for (let i = 0; i < len; ++i) {
|
|
2724
|
+
const next = values[i];
|
|
2725
|
+
if (isArray(next)) {
|
|
2726
|
+
const previousKey = (_a = previousValues == null ? void 0 : previousValues[i]) == null ? void 0 : _a[0];
|
|
2727
|
+
const key = next[0];
|
|
2728
|
+
const value = next[1];
|
|
2729
|
+
patchAttribute(el, key, value, previousKey);
|
|
2730
|
+
} else if (isObject(next)) {
|
|
2731
|
+
for (const item of Object.entries(next)) {
|
|
2732
|
+
const key = item[0];
|
|
2733
|
+
const value = item[1];
|
|
2734
|
+
const p = previousValues == null ? void 0 : previousValues[i];
|
|
2735
|
+
const previousKey = p && key in p ? key : void 0;
|
|
2434
2736
|
patchAttribute(el, key, value, previousKey);
|
|
2435
2737
|
}
|
|
2738
|
+
} else {
|
|
2739
|
+
const previousKey = previousValues == null ? void 0 : previousValues[i];
|
|
2740
|
+
const key = values[i++];
|
|
2741
|
+
const value = values[i];
|
|
2742
|
+
patchAttribute(el, key, value, previousKey);
|
|
2436
2743
|
}
|
|
2437
2744
|
}
|
|
2438
2745
|
};
|
|
2746
|
+
var attrDirective = {
|
|
2747
|
+
mount: () => ({
|
|
2748
|
+
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
2749
|
+
updateAttr(
|
|
2750
|
+
el,
|
|
2751
|
+
values,
|
|
2752
|
+
previousValues,
|
|
2753
|
+
option,
|
|
2754
|
+
previousOption,
|
|
2755
|
+
flags
|
|
2756
|
+
);
|
|
2757
|
+
}
|
|
2758
|
+
})
|
|
2759
|
+
};
|
|
2439
2760
|
var patchAttribute = (el, key, value, previousKey) => {
|
|
2440
2761
|
if (previousKey && previousKey !== key) {
|
|
2441
2762
|
el.removeAttribute(previousKey);
|
|
@@ -2469,23 +2790,28 @@ var Regor = (() => {
|
|
|
2469
2790
|
};
|
|
2470
2791
|
|
|
2471
2792
|
// src/directives/class.ts
|
|
2472
|
-
var
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
patchClass(el, next[j], previous == null ? void 0 : previous[j]);
|
|
2482
|
-
}
|
|
2483
|
-
} else {
|
|
2484
|
-
patchClass(el, next, previous);
|
|
2793
|
+
var updateClass = (el, values, previousValues) => {
|
|
2794
|
+
const len = values.length;
|
|
2795
|
+
for (let i = 0; i < len; ++i) {
|
|
2796
|
+
const next = values[i];
|
|
2797
|
+
const previous = previousValues == null ? void 0 : previousValues[i];
|
|
2798
|
+
if (isArray(next)) {
|
|
2799
|
+
const len2 = next.length;
|
|
2800
|
+
for (let j = 0; j < len2; ++j) {
|
|
2801
|
+
patchClass(el, next[j], previous == null ? void 0 : previous[j]);
|
|
2485
2802
|
}
|
|
2803
|
+
} else {
|
|
2804
|
+
patchClass(el, next, previous);
|
|
2486
2805
|
}
|
|
2487
2806
|
}
|
|
2488
2807
|
};
|
|
2808
|
+
var classDirective = {
|
|
2809
|
+
mount: () => ({
|
|
2810
|
+
update: ({ el, values, previousValues }) => {
|
|
2811
|
+
updateClass(el, values, previousValues);
|
|
2812
|
+
}
|
|
2813
|
+
})
|
|
2814
|
+
};
|
|
2489
2815
|
var patchClass = (el, next, prev) => {
|
|
2490
2816
|
const classList = el.classList;
|
|
2491
2817
|
const isClassString = isString(next);
|
|
@@ -2513,15 +2839,6 @@ var Regor = (() => {
|
|
|
2513
2839
|
}
|
|
2514
2840
|
};
|
|
2515
2841
|
|
|
2516
|
-
// src/directives/html.ts
|
|
2517
|
-
var htmlDirective = {
|
|
2518
|
-
onChange: (el, values) => {
|
|
2519
|
-
const [value, replacer] = values;
|
|
2520
|
-
if (isFunction(replacer)) replacer(el, value);
|
|
2521
|
-
else el.innerHTML = value == null ? void 0 : value.toString();
|
|
2522
|
-
}
|
|
2523
|
-
};
|
|
2524
|
-
|
|
2525
2842
|
// src/common/looseEqual.ts
|
|
2526
2843
|
function looseCompareArrays(a, b) {
|
|
2527
2844
|
if (a.length !== b.length) return false;
|
|
@@ -2594,12 +2911,12 @@ var Regor = (() => {
|
|
|
2594
2911
|
|
|
2595
2912
|
// src/directives/model.ts
|
|
2596
2913
|
var modelDirective = {
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
}
|
|
2914
|
+
mount: ({ el, parseResult, flags }) => ({
|
|
2915
|
+
update: ({ values }) => {
|
|
2916
|
+
updateDomElementValue(el, values[0]);
|
|
2917
|
+
},
|
|
2918
|
+
unmount: attachDOMChangeListener(el, parseResult, flags)
|
|
2919
|
+
})
|
|
2603
2920
|
};
|
|
2604
2921
|
var updateDomElementValue = (el, value) => {
|
|
2605
2922
|
const isAnInput = isInput(el);
|
|
@@ -2905,66 +3222,75 @@ var Regor = (() => {
|
|
|
2905
3222
|
}
|
|
2906
3223
|
return result;
|
|
2907
3224
|
};
|
|
3225
|
+
var bindOn = (el, parseResult, option, dynamicOption, flags) => {
|
|
3226
|
+
var _a, _b;
|
|
3227
|
+
if (dynamicOption) {
|
|
3228
|
+
const values2 = parseResult.value();
|
|
3229
|
+
const option2 = unref(dynamicOption.value()[0]);
|
|
3230
|
+
if (!isString(option2)) return () => {
|
|
3231
|
+
};
|
|
3232
|
+
return attachEventListener(
|
|
3233
|
+
el,
|
|
3234
|
+
camelize(option2),
|
|
3235
|
+
() => parseResult.value()[0],
|
|
3236
|
+
(_a = flags == null ? void 0 : flags.join(",")) != null ? _a : values2[1]
|
|
3237
|
+
);
|
|
3238
|
+
} else if (option) {
|
|
3239
|
+
const values2 = parseResult.value();
|
|
3240
|
+
return attachEventListener(
|
|
3241
|
+
el,
|
|
3242
|
+
camelize(option),
|
|
3243
|
+
() => parseResult.value()[0],
|
|
3244
|
+
(_b = flags == null ? void 0 : flags.join(",")) != null ? _b : values2[1]
|
|
3245
|
+
);
|
|
3246
|
+
}
|
|
3247
|
+
const unbinders = [];
|
|
3248
|
+
const unbinder = () => {
|
|
3249
|
+
unbinders.forEach((x) => x());
|
|
3250
|
+
};
|
|
3251
|
+
const values = parseResult.value();
|
|
3252
|
+
const len = values.length;
|
|
3253
|
+
for (let i = 0; i < len; ++i) {
|
|
3254
|
+
let next = values[i];
|
|
3255
|
+
if (isFunction(next)) next = next();
|
|
3256
|
+
if (isObject(next)) {
|
|
3257
|
+
for (const item of Object.entries(next)) {
|
|
3258
|
+
const eventType = item[0];
|
|
3259
|
+
const method = () => {
|
|
3260
|
+
let obj = parseResult.value()[i];
|
|
3261
|
+
if (isFunction(obj)) obj = obj();
|
|
3262
|
+
obj = obj[eventType];
|
|
3263
|
+
if (isFunction(obj)) obj = obj();
|
|
3264
|
+
return obj;
|
|
3265
|
+
};
|
|
3266
|
+
const flags2 = next[eventType + "_flags"];
|
|
3267
|
+
unbinders.push(attachEventListener(el, eventType, method, flags2));
|
|
3268
|
+
}
|
|
3269
|
+
} else {
|
|
3270
|
+
warning(2 /* BindingRequiresObjectExpressions */, "r-on", el);
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
return unbinder;
|
|
3274
|
+
};
|
|
2908
3275
|
var onDirective = {
|
|
2909
3276
|
isLazy: (i, d) => d === -1 && i % 2 === 0,
|
|
2910
3277
|
isLazyKey: (key, d) => d === 0 && !key.endsWith("_flags"),
|
|
2911
3278
|
once: false,
|
|
2912
3279
|
collectRefObj: true,
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
el,
|
|
2922
|
-
camelize(option2),
|
|
2923
|
-
() => parseResult.value()[0],
|
|
2924
|
-
(_a = flags == null ? void 0 : flags.join(",")) != null ? _a : values2[1]
|
|
2925
|
-
);
|
|
2926
|
-
} else if (option) {
|
|
2927
|
-
const values2 = parseResult.value();
|
|
2928
|
-
return attachEventListener(
|
|
2929
|
-
el,
|
|
2930
|
-
camelize(option),
|
|
2931
|
-
() => parseResult.value()[0],
|
|
2932
|
-
(_b = flags == null ? void 0 : flags.join(",")) != null ? _b : values2[1]
|
|
2933
|
-
);
|
|
2934
|
-
}
|
|
2935
|
-
const unbinders = [];
|
|
2936
|
-
const unbinder = () => {
|
|
2937
|
-
unbinders.forEach((x) => x());
|
|
2938
|
-
};
|
|
2939
|
-
const values = parseResult.value();
|
|
2940
|
-
const len = values.length;
|
|
2941
|
-
for (let i = 0; i < len; ++i) {
|
|
2942
|
-
let next = values[i];
|
|
2943
|
-
if (isFunction(next)) next = next();
|
|
2944
|
-
if (isObject(next)) {
|
|
2945
|
-
for (const item of Object.entries(next)) {
|
|
2946
|
-
const eventType = item[0];
|
|
2947
|
-
const method = () => {
|
|
2948
|
-
let obj = parseResult.value()[i];
|
|
2949
|
-
if (isFunction(obj)) obj = obj();
|
|
2950
|
-
obj = obj[eventType];
|
|
2951
|
-
if (isFunction(obj)) obj = obj();
|
|
2952
|
-
return obj;
|
|
2953
|
-
};
|
|
2954
|
-
const flags2 = next[eventType + "_flags"];
|
|
2955
|
-
unbinders.push(attachEventListener(el, eventType, method, flags2));
|
|
2956
|
-
}
|
|
2957
|
-
} else {
|
|
2958
|
-
warning(2 /* BindingRequiresObjectExpressions */, "r-on", el);
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
return unbinder;
|
|
3280
|
+
mount: ({ el, parseResult, option, dynamicOption, flags }) => {
|
|
3281
|
+
return bindOn(
|
|
3282
|
+
el,
|
|
3283
|
+
parseResult,
|
|
3284
|
+
option,
|
|
3285
|
+
dynamicOption,
|
|
3286
|
+
flags
|
|
3287
|
+
);
|
|
2962
3288
|
}
|
|
2963
3289
|
};
|
|
2964
3290
|
var getShouldExecuteEvent = (eventType, flags) => {
|
|
2965
3291
|
if (eventType.startsWith("keydown") || eventType.startsWith("keyup") || eventType.startsWith("keypress")) {
|
|
2966
3292
|
flags != null ? flags : flags = "";
|
|
2967
|
-
const parts = eventType.split(".")
|
|
3293
|
+
const parts = [...eventType.split("."), ...flags.split(",")];
|
|
2968
3294
|
eventType = parts[0];
|
|
2969
3295
|
const keyType = parts[1];
|
|
2970
3296
|
const isCtrl = parts.includes("ctrl");
|
|
@@ -3037,34 +3363,39 @@ var Regor = (() => {
|
|
|
3037
3363
|
};
|
|
3038
3364
|
|
|
3039
3365
|
// src/directives/prop.ts
|
|
3040
|
-
var
|
|
3041
|
-
|
|
3042
|
-
if (option)
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
const value = item[1];
|
|
3058
|
-
patchProp(el, key, value);
|
|
3059
|
-
}
|
|
3060
|
-
} else {
|
|
3061
|
-
const key = values[i++];
|
|
3062
|
-
const value = values[i];
|
|
3366
|
+
var updatePropBinding = (el, values, option, flags) => {
|
|
3367
|
+
if (option) {
|
|
3368
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3369
|
+
patchProp(el, option, values[0]);
|
|
3370
|
+
return;
|
|
3371
|
+
}
|
|
3372
|
+
const len = values.length;
|
|
3373
|
+
for (let i = 0; i < len; ++i) {
|
|
3374
|
+
const next = values[i];
|
|
3375
|
+
if (isArray(next)) {
|
|
3376
|
+
const key = next[0];
|
|
3377
|
+
const value = next[1];
|
|
3378
|
+
patchProp(el, key, value);
|
|
3379
|
+
} else if (isObject(next)) {
|
|
3380
|
+
for (const item of Object.entries(next)) {
|
|
3381
|
+
const key = item[0];
|
|
3382
|
+
const value = item[1];
|
|
3063
3383
|
patchProp(el, key, value);
|
|
3064
3384
|
}
|
|
3385
|
+
} else {
|
|
3386
|
+
const key = values[i++];
|
|
3387
|
+
const value = values[i];
|
|
3388
|
+
patchProp(el, key, value);
|
|
3065
3389
|
}
|
|
3066
3390
|
}
|
|
3067
3391
|
};
|
|
3392
|
+
var propDirective = {
|
|
3393
|
+
mount: () => ({
|
|
3394
|
+
update: ({ el, values, option, flags }) => {
|
|
3395
|
+
updatePropBinding(el, values, option, flags);
|
|
3396
|
+
}
|
|
3397
|
+
})
|
|
3398
|
+
};
|
|
3068
3399
|
function includeBooleanAttr2(value) {
|
|
3069
3400
|
return !!value || value === "";
|
|
3070
3401
|
}
|
|
@@ -3119,7 +3450,8 @@ var Regor = (() => {
|
|
|
3119
3450
|
// src/directives/ref.ts
|
|
3120
3451
|
var refDirective = {
|
|
3121
3452
|
once: true,
|
|
3122
|
-
|
|
3453
|
+
mount: ({ el, parseResult, expr }) => {
|
|
3454
|
+
const result = parseResult;
|
|
3123
3455
|
const value = result.value()[0];
|
|
3124
3456
|
const isAnArray = isArray(value);
|
|
3125
3457
|
const sref2 = result.refs[0];
|
|
@@ -3136,37 +3468,47 @@ var Regor = (() => {
|
|
|
3136
3468
|
};
|
|
3137
3469
|
|
|
3138
3470
|
// src/directives/show.ts
|
|
3471
|
+
var updateShow = (el, values) => {
|
|
3472
|
+
const data = getBindData(el).data;
|
|
3473
|
+
let originalDisplay = data._ord;
|
|
3474
|
+
if (isUndefined(originalDisplay)) {
|
|
3475
|
+
originalDisplay = data._ord = el.style.display;
|
|
3476
|
+
}
|
|
3477
|
+
const isVisible = !!values[0];
|
|
3478
|
+
if (isVisible) el.style.display = originalDisplay;
|
|
3479
|
+
else el.style.display = "none";
|
|
3480
|
+
};
|
|
3139
3481
|
var showDirective = {
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
if (isUndefined(originalDisplay)) {
|
|
3144
|
-
originalDisplay = data._ord = el.style.display;
|
|
3482
|
+
mount: () => ({
|
|
3483
|
+
update: ({ el, values }) => {
|
|
3484
|
+
updateShow(el, values);
|
|
3145
3485
|
}
|
|
3146
|
-
|
|
3147
|
-
if (isVisible) el.style.display = originalDisplay;
|
|
3148
|
-
else el.style.display = "none";
|
|
3149
|
-
}
|
|
3486
|
+
})
|
|
3150
3487
|
};
|
|
3151
3488
|
|
|
3152
3489
|
// src/directives/style.ts
|
|
3153
|
-
var
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
patchStyle(el, next[j], previous == null ? void 0 : previous[j]);
|
|
3163
|
-
}
|
|
3164
|
-
} else {
|
|
3165
|
-
patchStyle(el, next, previous);
|
|
3490
|
+
var updateStyle = (el, values, previousValues) => {
|
|
3491
|
+
const len = values.length;
|
|
3492
|
+
for (let i = 0; i < len; ++i) {
|
|
3493
|
+
const next = values[i];
|
|
3494
|
+
const previous = previousValues == null ? void 0 : previousValues[i];
|
|
3495
|
+
if (isArray(next)) {
|
|
3496
|
+
const len2 = next.length;
|
|
3497
|
+
for (let j = 0; j < len2; ++j) {
|
|
3498
|
+
patchStyle(el, next[j], previous == null ? void 0 : previous[j]);
|
|
3166
3499
|
}
|
|
3500
|
+
} else {
|
|
3501
|
+
patchStyle(el, next, previous);
|
|
3167
3502
|
}
|
|
3168
3503
|
}
|
|
3169
3504
|
};
|
|
3505
|
+
var styleDirective = {
|
|
3506
|
+
mount: () => ({
|
|
3507
|
+
update: ({ el, values, previousValues }) => {
|
|
3508
|
+
updateStyle(el, values, previousValues);
|
|
3509
|
+
}
|
|
3510
|
+
})
|
|
3511
|
+
};
|
|
3170
3512
|
var patchStyle = (el, next, prev) => {
|
|
3171
3513
|
const style = el.style;
|
|
3172
3514
|
const isCssString = isString(next);
|
|
@@ -3274,19 +3616,26 @@ var Regor = (() => {
|
|
|
3274
3616
|
};
|
|
3275
3617
|
|
|
3276
3618
|
// src/directives/text.ts
|
|
3619
|
+
var updateText = (el, values) => {
|
|
3620
|
+
var _a;
|
|
3621
|
+
const value = values[0];
|
|
3622
|
+
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 : "";
|
|
3623
|
+
};
|
|
3277
3624
|
var textDirective = {
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
}
|
|
3625
|
+
mount: () => ({
|
|
3626
|
+
update: ({ el, values }) => {
|
|
3627
|
+
updateText(el, values);
|
|
3628
|
+
}
|
|
3629
|
+
})
|
|
3283
3630
|
};
|
|
3284
3631
|
|
|
3285
3632
|
// src/directives/value.ts
|
|
3286
3633
|
var valueDirective = {
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3634
|
+
mount: () => ({
|
|
3635
|
+
update: ({ el, values }) => {
|
|
3636
|
+
patchProp(el, "value", values[0]);
|
|
3637
|
+
}
|
|
3638
|
+
})
|
|
3290
3639
|
};
|
|
3291
3640
|
|
|
3292
3641
|
// src/app/RegorConfig.ts
|
|
@@ -5102,6 +5451,7 @@ var Regor = (() => {
|
|
|
5102
5451
|
|
|
5103
5452
|
// src/parser/Parser.ts
|
|
5104
5453
|
var astCache = {};
|
|
5454
|
+
var isComponentMap = (value) => !!value;
|
|
5105
5455
|
var Parser = class {
|
|
5106
5456
|
constructor(contexts, config) {
|
|
5107
5457
|
__publicField(this, "__contexts");
|
|
@@ -5114,7 +5464,7 @@ var Regor = (() => {
|
|
|
5114
5464
|
this.__contexts = [context, ...this.__contexts];
|
|
5115
5465
|
}
|
|
5116
5466
|
__getComponents() {
|
|
5117
|
-
const obj = this.__contexts.map((x) => x.components).filter(
|
|
5467
|
+
const obj = this.__contexts.map((x) => x.components).filter(isComponentMap).reverse().reduce((p, c) => {
|
|
5118
5468
|
for (const [key, value] of Object.entries(c)) {
|
|
5119
5469
|
p[key.toUpperCase()] = value;
|
|
5120
5470
|
}
|
|
@@ -5125,7 +5475,7 @@ var Regor = (() => {
|
|
|
5125
5475
|
__getComponentSelectors() {
|
|
5126
5476
|
const selectors = [];
|
|
5127
5477
|
const seen = /* @__PURE__ */ new Set();
|
|
5128
|
-
const componentsList = this.__contexts.map((x) => x.components).filter(
|
|
5478
|
+
const componentsList = this.__contexts.map((x) => x.components).filter(isComponentMap).reverse();
|
|
5129
5479
|
for (const components of componentsList) {
|
|
5130
5480
|
for (const key of Object.keys(components)) {
|
|
5131
5481
|
if (seen.has(key)) continue;
|
|
@@ -5137,12 +5487,12 @@ var Regor = (() => {
|
|
|
5137
5487
|
}
|
|
5138
5488
|
__parse(expression, isLazy, isLazyKey, collectRefObj, once) {
|
|
5139
5489
|
var _a;
|
|
5140
|
-
|
|
5490
|
+
let currentValues = [];
|
|
5141
5491
|
const stopObserverList = [];
|
|
5142
5492
|
const subscribers = /* @__PURE__ */ new Set();
|
|
5143
5493
|
const clearObservers = () => {
|
|
5144
|
-
for (
|
|
5145
|
-
|
|
5494
|
+
for (let i = 0; i < stopObserverList.length; ++i) {
|
|
5495
|
+
stopObserverList[i]();
|
|
5146
5496
|
}
|
|
5147
5497
|
stopObserverList.length = 0;
|
|
5148
5498
|
};
|
|
@@ -5152,13 +5502,13 @@ var Regor = (() => {
|
|
|
5152
5502
|
};
|
|
5153
5503
|
const subscribe = (observer, init) => {
|
|
5154
5504
|
subscribers.add(observer);
|
|
5155
|
-
if (init) observer(
|
|
5505
|
+
if (init) observer(currentValues);
|
|
5156
5506
|
return () => {
|
|
5157
5507
|
subscribers.delete(observer);
|
|
5158
5508
|
};
|
|
5159
5509
|
};
|
|
5160
5510
|
const result = {
|
|
5161
|
-
value,
|
|
5511
|
+
value: () => currentValues,
|
|
5162
5512
|
stop: unbinder,
|
|
5163
5513
|
subscribe,
|
|
5164
5514
|
refs: [],
|
|
@@ -5179,7 +5529,7 @@ var Regor = (() => {
|
|
|
5179
5529
|
context,
|
|
5180
5530
|
collectRefObj
|
|
5181
5531
|
);
|
|
5182
|
-
if (collectRefs2) refs.push(...r.refs);
|
|
5532
|
+
if (collectRefs2 && r.refs.length > 0) refs.push(...r.refs);
|
|
5183
5533
|
return { value: r.value, refs: r.refs, ref: r.ref };
|
|
5184
5534
|
} catch (e) {
|
|
5185
5535
|
warning(6 /* ErrorLog */, `evaluation error: ${expression}`, e);
|
|
@@ -5192,36 +5542,37 @@ var Regor = (() => {
|
|
|
5192
5542
|
const contexts = this.__contexts.slice();
|
|
5193
5543
|
const elements = ast.elements;
|
|
5194
5544
|
const len = elements.length;
|
|
5545
|
+
const expressionRefs = new Array(len);
|
|
5546
|
+
result.refs = expressionRefs;
|
|
5195
5547
|
const refresh = () => {
|
|
5196
5548
|
refs.length = 0;
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5549
|
+
if (!once) {
|
|
5550
|
+
uniqueRefs.clear();
|
|
5551
|
+
clearObservers();
|
|
5552
|
+
}
|
|
5553
|
+
const nextValues = new Array(len);
|
|
5201
5554
|
for (let i = 0; i < len; ++i) {
|
|
5202
5555
|
const expr = elements[i];
|
|
5203
5556
|
if (isLazy == null ? void 0 : isLazy(i, -1)) {
|
|
5204
|
-
|
|
5557
|
+
nextValues[i] = (e) => evaluate(expr, contexts, false, { $event: e }).value;
|
|
5205
5558
|
continue;
|
|
5206
5559
|
}
|
|
5207
5560
|
const evaluated = evaluate(expr, contexts, true);
|
|
5208
|
-
|
|
5561
|
+
nextValues[i] = evaluated.value;
|
|
5209
5562
|
expressionRefs[i] = evaluated.ref;
|
|
5210
5563
|
}
|
|
5211
5564
|
if (!once) {
|
|
5212
5565
|
for (const r of refs) {
|
|
5213
5566
|
if (uniqueRefs.has(r)) continue;
|
|
5214
5567
|
uniqueRefs.add(r);
|
|
5215
|
-
|
|
5216
|
-
stopObserverList.push(stopObserving);
|
|
5568
|
+
stopObserverList.push(observe(r, refresh));
|
|
5217
5569
|
}
|
|
5218
5570
|
}
|
|
5219
|
-
|
|
5220
|
-
value(values);
|
|
5571
|
+
currentValues = nextValues;
|
|
5221
5572
|
if (subscribers.size !== 0) {
|
|
5222
5573
|
for (const subscriber of subscribers) {
|
|
5223
5574
|
if (!subscribers.has(subscriber)) continue;
|
|
5224
|
-
subscriber(
|
|
5575
|
+
subscriber(currentValues);
|
|
5225
5576
|
}
|
|
5226
5577
|
}
|
|
5227
5578
|
};
|
|
@@ -5535,8 +5886,8 @@ var Regor = (() => {
|
|
|
5535
5886
|
return json;
|
|
5536
5887
|
};
|
|
5537
5888
|
|
|
5538
|
-
// src/app/
|
|
5539
|
-
var
|
|
5889
|
+
// src/app/defineComponent.ts
|
|
5890
|
+
var defineComponent = (template, options = {}) => {
|
|
5540
5891
|
var _a, _b, _c, _d, _e, _f;
|
|
5541
5892
|
if (isArray(options)) options = { props: options };
|
|
5542
5893
|
if (isString(template)) template = { template };
|