regor 1.2.6 → 1.2.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/dist/regor.es2015.cjs.js +549 -512
- package/dist/regor.es2015.cjs.prod.js +4 -4
- package/dist/regor.es2015.esm.js +549 -512
- package/dist/regor.es2015.esm.prod.js +4 -4
- package/dist/regor.es2015.iife.js +549 -512
- package/dist/regor.es2015.iife.prod.js +4 -4
- package/dist/regor.es2019.cjs.js +549 -512
- package/dist/regor.es2019.cjs.prod.js +4 -4
- package/dist/regor.es2019.esm.js +549 -512
- package/dist/regor.es2019.esm.prod.js +4 -4
- package/dist/regor.es2019.iife.js +549 -512
- package/dist/regor.es2019.iife.prod.js +4 -4
- package/dist/regor.es2022.cjs.js +545 -508
- package/dist/regor.es2022.cjs.prod.js +4 -4
- package/dist/regor.es2022.esm.js +545 -508
- package/dist/regor.es2022.esm.prod.js +4 -4
- package/dist/regor.es2022.iife.js +545 -508
- package/dist/regor.es2022.iife.prod.js +4 -4
- package/package.json +1 -1
package/dist/regor.es2015.cjs.js
CHANGED
|
@@ -772,15 +772,344 @@ var entangle = (r1, r2) => {
|
|
|
772
772
|
};
|
|
773
773
|
};
|
|
774
774
|
|
|
775
|
+
// src/misc/isRaw.ts
|
|
776
|
+
var isRaw = (value) => {
|
|
777
|
+
return !!value && value[rawSymbol] === 1;
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
// src/reactivity/isDeepRef.ts
|
|
781
|
+
var isDeepRef = (value) => {
|
|
782
|
+
return (value == null ? void 0 : value[refSymbol]) === 1;
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
// src/computed/watchEffect.ts
|
|
786
|
+
var collectedRefs = [];
|
|
787
|
+
var collectRef = (ref2) => {
|
|
788
|
+
var _a;
|
|
789
|
+
if (collectedRefs.length === 0) return;
|
|
790
|
+
(_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
|
|
791
|
+
};
|
|
792
|
+
var watchEffect = (effect) => {
|
|
793
|
+
if (!effect) return () => {
|
|
794
|
+
};
|
|
795
|
+
const terminator = { stop: () => {
|
|
796
|
+
} };
|
|
797
|
+
watchEffectInternal(effect, terminator);
|
|
798
|
+
onUnmounted(() => terminator.stop(), true);
|
|
799
|
+
return terminator.stop;
|
|
800
|
+
};
|
|
801
|
+
var watchEffectInternal = (effect, terminator) => {
|
|
802
|
+
if (!effect) return;
|
|
803
|
+
let stopObservingList = [];
|
|
804
|
+
let isStopped = false;
|
|
805
|
+
const stopWatch = () => {
|
|
806
|
+
for (const stop of stopObservingList) stop();
|
|
807
|
+
stopObservingList = [];
|
|
808
|
+
isStopped = true;
|
|
809
|
+
};
|
|
810
|
+
terminator.stop = stopWatch;
|
|
811
|
+
try {
|
|
812
|
+
const set = /* @__PURE__ */ new Set();
|
|
813
|
+
collectedRefs.push(set);
|
|
814
|
+
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
815
|
+
if (isStopped) return;
|
|
816
|
+
for (const r of [...set]) {
|
|
817
|
+
const stopObserving = observe(r, () => {
|
|
818
|
+
stopWatch();
|
|
819
|
+
watchEffect(effect);
|
|
820
|
+
});
|
|
821
|
+
stopObservingList.push(stopObserving);
|
|
822
|
+
}
|
|
823
|
+
} finally {
|
|
824
|
+
collectedRefs.pop();
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
var silence = (action) => {
|
|
828
|
+
const len = collectedRefs.length;
|
|
829
|
+
const hasPush = len > 0 && collectedRefs[len - 1];
|
|
830
|
+
try {
|
|
831
|
+
if (hasPush) collectedRefs.push(null);
|
|
832
|
+
return action();
|
|
833
|
+
} finally {
|
|
834
|
+
if (hasPush) collectedRefs.pop();
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
var collectRefs = (action) => {
|
|
838
|
+
try {
|
|
839
|
+
const set = /* @__PURE__ */ new Set();
|
|
840
|
+
collectedRefs.push(set);
|
|
841
|
+
const result = action();
|
|
842
|
+
return { value: result, refs: [...set] };
|
|
843
|
+
} finally {
|
|
844
|
+
collectedRefs.pop();
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
// src/reactivity/trigger.ts
|
|
849
|
+
var trigger = (source, eventSource, isRecursive) => {
|
|
850
|
+
if (!isRef(source)) return;
|
|
851
|
+
const srefImpl = source;
|
|
852
|
+
srefImpl(void 0, eventSource, 1 /* trigger */);
|
|
853
|
+
if (!isRecursive) return;
|
|
854
|
+
const obj = srefImpl();
|
|
855
|
+
if (!obj) return;
|
|
856
|
+
if (isArray(obj) || isSet(obj)) {
|
|
857
|
+
for (const el of obj) {
|
|
858
|
+
trigger(el, eventSource, true);
|
|
859
|
+
}
|
|
860
|
+
} else if (isMap(obj)) {
|
|
861
|
+
for (const el of obj) {
|
|
862
|
+
trigger(el[0], eventSource, true);
|
|
863
|
+
trigger(el[1], eventSource, true);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
if (isObject(obj)) {
|
|
867
|
+
for (const k in obj) {
|
|
868
|
+
trigger(obj[k], eventSource, true);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
// src/proxies/proxy.ts
|
|
874
|
+
function define(obj, key, val) {
|
|
875
|
+
Object.defineProperty(obj, key, {
|
|
876
|
+
value: val,
|
|
877
|
+
enumerable: false,
|
|
878
|
+
writable: true,
|
|
879
|
+
configurable: true
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
var createProxy = (originalProto, proxyProto, methodsToPatch4) => {
|
|
883
|
+
methodsToPatch4.forEach(function(method) {
|
|
884
|
+
const original = originalProto[method];
|
|
885
|
+
define(proxyProto, method, function mutator(...args) {
|
|
886
|
+
const result = original.apply(this, args);
|
|
887
|
+
const subscribers = this[srefSymbol];
|
|
888
|
+
for (const subscriber of subscribers) trigger(subscriber);
|
|
889
|
+
return result;
|
|
890
|
+
});
|
|
891
|
+
});
|
|
892
|
+
};
|
|
893
|
+
var setToStringTag = (proxyProto, tag) => {
|
|
894
|
+
Object.defineProperty(proxyProto, Symbol.toStringTag, {
|
|
895
|
+
value: tag,
|
|
896
|
+
writable: false,
|
|
897
|
+
enumerable: false,
|
|
898
|
+
configurable: true
|
|
899
|
+
});
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
// src/proxies/array-ref.ts
|
|
903
|
+
var arrayProto = Array.prototype;
|
|
904
|
+
var proxyArrayProto = Object.create(arrayProto);
|
|
905
|
+
var methodsToPatch = [
|
|
906
|
+
"push",
|
|
907
|
+
"pop",
|
|
908
|
+
"shift",
|
|
909
|
+
"unshift",
|
|
910
|
+
"splice",
|
|
911
|
+
"sort",
|
|
912
|
+
"reverse"
|
|
913
|
+
];
|
|
914
|
+
createProxy(arrayProto, proxyArrayProto, methodsToPatch);
|
|
915
|
+
|
|
916
|
+
// src/proxies/map-ref.ts
|
|
917
|
+
var mapProto = Map.prototype;
|
|
918
|
+
var proxyMapProto = Object.create(mapProto);
|
|
919
|
+
var methodsToPatch2 = ["set", "clear", "delete"];
|
|
920
|
+
setToStringTag(proxyMapProto, "Map");
|
|
921
|
+
createProxy(mapProto, proxyMapProto, methodsToPatch2);
|
|
922
|
+
|
|
923
|
+
// src/proxies/set-ref.ts
|
|
924
|
+
var setProto = Set.prototype;
|
|
925
|
+
var proxySetProto = Object.create(setProto);
|
|
926
|
+
var methodsToPatch3 = ["add", "clear", "delete"];
|
|
927
|
+
setToStringTag(proxySetProto, "Set");
|
|
928
|
+
createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
929
|
+
|
|
930
|
+
// src/reactivity/sref.ts
|
|
931
|
+
var batchCollector = {};
|
|
932
|
+
var sref = (value) => {
|
|
933
|
+
if (isRef(value) || isRaw(value)) return value;
|
|
934
|
+
const refObj = {
|
|
935
|
+
auto: true,
|
|
936
|
+
_value: value
|
|
937
|
+
};
|
|
938
|
+
const createProxy2 = (value2) => {
|
|
939
|
+
if (!isObject(value2)) return false;
|
|
940
|
+
if (srefSymbol in value2) return true;
|
|
941
|
+
const isAnArray = isArray(value2);
|
|
942
|
+
if (isAnArray) {
|
|
943
|
+
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
944
|
+
return true;
|
|
945
|
+
}
|
|
946
|
+
const isASet = isSet(value2);
|
|
947
|
+
if (isASet) {
|
|
948
|
+
Object.setPrototypeOf(value2, proxySetProto);
|
|
949
|
+
return true;
|
|
950
|
+
}
|
|
951
|
+
const isAMap = isMap(value2);
|
|
952
|
+
if (isAMap) {
|
|
953
|
+
Object.setPrototypeOf(value2, proxyMapProto);
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
return false;
|
|
957
|
+
};
|
|
958
|
+
const isProxy = createProxy2(value);
|
|
959
|
+
const observers = /* @__PURE__ */ new Set();
|
|
960
|
+
const trigger2 = (newValue, eventSource) => {
|
|
961
|
+
if (batchCollector.stack && batchCollector.stack.length) {
|
|
962
|
+
const current = batchCollector.stack[batchCollector.stack.length - 1];
|
|
963
|
+
current.add(srefFunction);
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
if (observers.size === 0) return;
|
|
967
|
+
silence(() => {
|
|
968
|
+
for (const callback of [...observers.keys()]) {
|
|
969
|
+
if (!observers.has(callback)) continue;
|
|
970
|
+
callback(newValue, eventSource);
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
};
|
|
974
|
+
const attachProxyHandle = (value2) => {
|
|
975
|
+
let proxyHandle = value2[srefSymbol];
|
|
976
|
+
if (!proxyHandle) value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
977
|
+
proxyHandle.add(srefFunction);
|
|
978
|
+
};
|
|
979
|
+
const srefFunction = (...args) => {
|
|
980
|
+
if (!(2 in args)) {
|
|
981
|
+
let newValue = args[0];
|
|
982
|
+
const eventSource = args[1];
|
|
983
|
+
if (0 in args) {
|
|
984
|
+
if (refObj._value === newValue) return newValue;
|
|
985
|
+
if (isRef(newValue)) {
|
|
986
|
+
newValue = newValue();
|
|
987
|
+
if (refObj._value === newValue) return newValue;
|
|
988
|
+
}
|
|
989
|
+
if (createProxy2(newValue)) attachProxyHandle(newValue);
|
|
990
|
+
refObj._value = newValue;
|
|
991
|
+
if (refObj.auto) {
|
|
992
|
+
trigger2(newValue, eventSource);
|
|
993
|
+
}
|
|
994
|
+
return refObj._value;
|
|
995
|
+
} else {
|
|
996
|
+
collectRef(srefFunction);
|
|
997
|
+
}
|
|
998
|
+
return refObj._value;
|
|
999
|
+
}
|
|
1000
|
+
const operation = args[2];
|
|
1001
|
+
switch (operation) {
|
|
1002
|
+
case 0 /* observe */: {
|
|
1003
|
+
const observer = args[3];
|
|
1004
|
+
if (!observer) return () => {
|
|
1005
|
+
};
|
|
1006
|
+
const removeObserver = (observer2) => {
|
|
1007
|
+
observers.delete(observer2);
|
|
1008
|
+
};
|
|
1009
|
+
observers.add(observer);
|
|
1010
|
+
return () => {
|
|
1011
|
+
removeObserver(observer);
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
case 1 /* trigger */: {
|
|
1015
|
+
const eventSource = args[1];
|
|
1016
|
+
const value2 = refObj._value;
|
|
1017
|
+
trigger2(value2, eventSource);
|
|
1018
|
+
break;
|
|
1019
|
+
}
|
|
1020
|
+
case 2 /* observerCount */: {
|
|
1021
|
+
return observers.size;
|
|
1022
|
+
}
|
|
1023
|
+
case 3 /* pause */: {
|
|
1024
|
+
refObj.auto = false;
|
|
1025
|
+
break;
|
|
1026
|
+
}
|
|
1027
|
+
case 4 /* resume */: {
|
|
1028
|
+
refObj.auto = true;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return refObj._value;
|
|
1032
|
+
};
|
|
1033
|
+
srefFunction[srefSymbol] = 1;
|
|
1034
|
+
defineRefValue(srefFunction, false);
|
|
1035
|
+
if (isProxy) attachProxyHandle(value);
|
|
1036
|
+
return srefFunction;
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
// src/reactivity/ref.ts
|
|
1040
|
+
var ref = (value) => {
|
|
1041
|
+
if (isRaw(value)) return value;
|
|
1042
|
+
let result;
|
|
1043
|
+
if (isRef(value)) {
|
|
1044
|
+
result = value;
|
|
1045
|
+
value = result();
|
|
1046
|
+
} else {
|
|
1047
|
+
result = sref(value);
|
|
1048
|
+
}
|
|
1049
|
+
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
1050
|
+
return result;
|
|
1051
|
+
result[refSymbol] = 1;
|
|
1052
|
+
if (isArray(value)) {
|
|
1053
|
+
const len = value.length;
|
|
1054
|
+
for (let i = 0; i < len; ++i) {
|
|
1055
|
+
const item = value[i];
|
|
1056
|
+
if (isDeepRef(item)) continue;
|
|
1057
|
+
value[i] = ref(item);
|
|
1058
|
+
}
|
|
1059
|
+
return result;
|
|
1060
|
+
}
|
|
1061
|
+
if (!isObject(value)) return result;
|
|
1062
|
+
for (const item of Object.entries(value)) {
|
|
1063
|
+
const val = item[1];
|
|
1064
|
+
if (isDeepRef(val)) continue;
|
|
1065
|
+
const key = item[0];
|
|
1066
|
+
if (isSymbol(key)) continue;
|
|
1067
|
+
value[key] = null;
|
|
1068
|
+
value[key] = ref(val);
|
|
1069
|
+
}
|
|
1070
|
+
return result;
|
|
1071
|
+
};
|
|
1072
|
+
|
|
775
1073
|
// src/directives/single-prop.ts
|
|
1074
|
+
var modelBridgeSymbol = Symbol("modelBridge");
|
|
1075
|
+
var isModelBridge = (value) => !!(value == null ? void 0 : value[modelBridgeSymbol]);
|
|
1076
|
+
var markModelBridge = (value) => {
|
|
1077
|
+
;
|
|
1078
|
+
value[modelBridgeSymbol] = 1;
|
|
1079
|
+
};
|
|
1080
|
+
var createModelBridge = (source) => {
|
|
1081
|
+
const bridge = ref(source());
|
|
1082
|
+
markModelBridge(bridge);
|
|
1083
|
+
return bridge;
|
|
1084
|
+
};
|
|
776
1085
|
var singlePropDirective = {
|
|
777
1086
|
collectRefObj: true,
|
|
778
1087
|
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
779
1088
|
if (!option) return () => {
|
|
780
1089
|
};
|
|
781
1090
|
const key = camelize(option);
|
|
1091
|
+
let currentSource;
|
|
1092
|
+
let bridge;
|
|
782
1093
|
let stopEntangle = () => {
|
|
783
1094
|
};
|
|
1095
|
+
const resetSync = () => {
|
|
1096
|
+
stopEntangle();
|
|
1097
|
+
stopEntangle = () => {
|
|
1098
|
+
};
|
|
1099
|
+
currentSource = void 0;
|
|
1100
|
+
bridge = void 0;
|
|
1101
|
+
};
|
|
1102
|
+
const clearEntangle = () => {
|
|
1103
|
+
stopEntangle();
|
|
1104
|
+
stopEntangle = () => {
|
|
1105
|
+
};
|
|
1106
|
+
};
|
|
1107
|
+
const syncRefs = (source, target) => {
|
|
1108
|
+
if (currentSource === source) return;
|
|
1109
|
+
clearEntangle();
|
|
1110
|
+
stopEntangle = entangle(source, target);
|
|
1111
|
+
currentSource = source;
|
|
1112
|
+
};
|
|
784
1113
|
const stopObserving = observe(
|
|
785
1114
|
parseResult.value,
|
|
786
1115
|
() => {
|
|
@@ -788,24 +1117,30 @@ var singlePropDirective = {
|
|
|
788
1117
|
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
789
1118
|
const ctx = parseResult.context;
|
|
790
1119
|
const ctxKey = ctx[key];
|
|
791
|
-
if (
|
|
792
|
-
|
|
1120
|
+
if (!isRef(value)) {
|
|
1121
|
+
if (bridge && ctxKey === bridge) {
|
|
1122
|
+
bridge(value);
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
resetSync();
|
|
793
1126
|
if (isRef(ctxKey)) {
|
|
794
|
-
|
|
795
|
-
stopEntangle = entangle(value, ctxKey);
|
|
1127
|
+
ctxKey(value);
|
|
796
1128
|
return;
|
|
797
1129
|
}
|
|
798
1130
|
ctx[key] = value;
|
|
799
1131
|
return;
|
|
800
1132
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
1133
|
+
if (isModelBridge(value)) {
|
|
1134
|
+
if (isRef(ctxKey)) {
|
|
1135
|
+
syncRefs(value, ctxKey);
|
|
1136
|
+
} else {
|
|
1137
|
+
ctx[key] = value;
|
|
1138
|
+
}
|
|
806
1139
|
return;
|
|
807
1140
|
}
|
|
808
|
-
|
|
1141
|
+
if (!bridge) bridge = createModelBridge(value);
|
|
1142
|
+
ctx[key] = bridge;
|
|
1143
|
+
syncRefs(value, bridge);
|
|
809
1144
|
},
|
|
810
1145
|
true
|
|
811
1146
|
);
|
|
@@ -1056,486 +1391,227 @@ var ComponentBinder = class {
|
|
|
1056
1391
|
} else {
|
|
1057
1392
|
inheritor.setAttribute(
|
|
1058
1393
|
normalizeAttributeName(attrName, binder.__config),
|
|
1059
|
-
value
|
|
1060
|
-
);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
};
|
|
1064
|
-
const clearUnusedAttributes = () => {
|
|
1065
|
-
for (const attrName of component.getAttributeNames()) {
|
|
1066
|
-
if (!attrName.startsWith("@") && !attrName.startsWith(binder.__config.__builtInNames.on))
|
|
1067
|
-
component.removeAttribute(attrName);
|
|
1068
|
-
}
|
|
1069
|
-
};
|
|
1070
|
-
const bindComponent = () => {
|
|
1071
|
-
transferAttributesToTheComponentChild();
|
|
1072
|
-
clearUnusedAttributes();
|
|
1073
|
-
parser.__push(componentCtx);
|
|
1074
|
-
binder.__bindAttributes(component, false);
|
|
1075
|
-
componentCtx.$emit = head.emit;
|
|
1076
|
-
bindChildNodes(binder, childNodes);
|
|
1077
|
-
addUnbinder(component, () => {
|
|
1078
|
-
callUnmounted(componentCtx);
|
|
1079
|
-
});
|
|
1080
|
-
addUnbinder(startOfComponent, () => {
|
|
1081
|
-
unbind(component);
|
|
1082
|
-
});
|
|
1083
|
-
callMounted(componentCtx);
|
|
1084
|
-
};
|
|
1085
|
-
parser.__scoped(capturedContext, bindComponent);
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
|
|
1090
|
-
// src/bind/DirectiveCollector.ts
|
|
1091
|
-
var DirectiveElement = class {
|
|
1092
|
-
constructor(name2) {
|
|
1093
|
-
__publicField(this, "__name");
|
|
1094
|
-
// r-on @click @submit r-on:click.prevent @submit.prevent @[event-name].self.camel :src :className.prop .class-name.camel r-if r-for key
|
|
1095
|
-
/** Contains: `['@', 'submit'], ['r-on', 'click'], ['\\@', '[dynamicKey]']` */
|
|
1096
|
-
__publicField(this, "__terms", []);
|
|
1097
|
-
/** Contains directive flags. ['camel', 'prevent',...] */
|
|
1098
|
-
__publicField(this, "__flags", []);
|
|
1099
|
-
__publicField(this, "__elements", []);
|
|
1100
|
-
this.__name = name2;
|
|
1101
|
-
this.__parse();
|
|
1102
|
-
}
|
|
1103
|
-
__parse() {
|
|
1104
|
-
let name2 = this.__name;
|
|
1105
|
-
const isPropShortcut = name2.startsWith(".");
|
|
1106
|
-
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1107
|
-
const firstFlagIndex = name2.indexOf(".");
|
|
1108
|
-
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1109
|
-
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1110
|
-
if (firstFlagIndex >= 0) {
|
|
1111
|
-
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1112
|
-
if (flags.includes("camel")) {
|
|
1113
|
-
const index = terms.length - 1;
|
|
1114
|
-
terms[index] = camelize(terms[index]);
|
|
1115
|
-
}
|
|
1116
|
-
if (flags.includes("prop")) {
|
|
1117
|
-
terms[0] = ".";
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
};
|
|
1122
|
-
var DirectiveCollector = class {
|
|
1123
|
-
constructor(binder) {
|
|
1124
|
-
__publicField(this, "__binder");
|
|
1125
|
-
__publicField(this, "__prefixes");
|
|
1126
|
-
this.__binder = binder;
|
|
1127
|
-
this.__prefixes = binder.__config.__getPrefixes();
|
|
1128
|
-
}
|
|
1129
|
-
__collect(element, isRecursive) {
|
|
1130
|
-
const map = /* @__PURE__ */ new Map();
|
|
1131
|
-
if (!isHTMLElement(element)) return map;
|
|
1132
|
-
const prefixes2 = this.__prefixes;
|
|
1133
|
-
const processNode = (node) => {
|
|
1134
|
-
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1135
|
-
for (const name2 of names) {
|
|
1136
|
-
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1137
|
-
const item = map.get(name2);
|
|
1138
|
-
item.__elements.push(node);
|
|
1139
|
-
}
|
|
1140
|
-
};
|
|
1141
|
-
processNode(element);
|
|
1142
|
-
if (!isRecursive) return map;
|
|
1143
|
-
const nodes = element.querySelectorAll("*");
|
|
1144
|
-
for (const node of nodes) {
|
|
1145
|
-
processNode(node);
|
|
1146
|
-
}
|
|
1147
|
-
return map;
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
|
|
1151
|
-
// src/bind/DynamicBinder.ts
|
|
1152
|
-
var mount2 = (nodes, parent) => {
|
|
1153
|
-
for (const x of nodes) {
|
|
1154
|
-
const node = x.cloneNode(true);
|
|
1155
|
-
parent.appendChild(node);
|
|
1156
|
-
}
|
|
1157
|
-
};
|
|
1158
|
-
var DynamicBinder = class {
|
|
1159
|
-
constructor(binder) {
|
|
1160
|
-
__publicField(this, "__binder");
|
|
1161
|
-
__publicField(this, "__is");
|
|
1162
|
-
__publicField(this, "__isSelector");
|
|
1163
|
-
this.__binder = binder;
|
|
1164
|
-
this.__is = binder.__config.__builtInNames.is;
|
|
1165
|
-
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1166
|
-
}
|
|
1167
|
-
__bindAll(element) {
|
|
1168
|
-
const isComponentElement = element.hasAttribute(this.__is);
|
|
1169
|
-
const elements = findElements(element, this.__isSelector);
|
|
1170
|
-
for (const el of elements) {
|
|
1171
|
-
this.__bind(el);
|
|
1172
|
-
}
|
|
1173
|
-
return isComponentElement;
|
|
1174
|
-
}
|
|
1175
|
-
__bind(el) {
|
|
1176
|
-
let expression = el.getAttribute(this.__is);
|
|
1177
|
-
if (!expression) {
|
|
1178
|
-
expression = el.getAttribute("is");
|
|
1179
|
-
if (!expression) return;
|
|
1180
|
-
if (!expression.startsWith("regor:")) {
|
|
1181
|
-
if (!expression.startsWith("r-")) return;
|
|
1182
|
-
const staticName = expression.slice(2).trim().toLowerCase();
|
|
1183
|
-
if (!staticName) return;
|
|
1184
|
-
const parent = el.parentNode;
|
|
1185
|
-
if (!parent) return;
|
|
1186
|
-
const nativeElement = document.createElement(staticName);
|
|
1187
|
-
for (const attr of el.getAttributeNames()) {
|
|
1188
|
-
if (attr === "is") continue;
|
|
1189
|
-
nativeElement.setAttribute(attr, el.getAttribute(attr));
|
|
1190
|
-
}
|
|
1191
|
-
while (el.firstChild) nativeElement.appendChild(el.firstChild);
|
|
1192
|
-
parent.insertBefore(nativeElement, el);
|
|
1193
|
-
el.remove();
|
|
1194
|
-
this.__binder.__bindDefault(nativeElement);
|
|
1195
|
-
return;
|
|
1196
|
-
}
|
|
1197
|
-
expression = `'${expression.slice(6)}'`;
|
|
1198
|
-
el.removeAttribute("is");
|
|
1199
|
-
}
|
|
1200
|
-
el.removeAttribute(this.__is);
|
|
1201
|
-
this.__bindToExpression(el, expression);
|
|
1202
|
-
}
|
|
1203
|
-
__createRegion(el, expression) {
|
|
1204
|
-
const nodes = getNodes(el);
|
|
1205
|
-
const parent = el.parentNode;
|
|
1206
|
-
const commentBegin = document.createComment(
|
|
1207
|
-
`__begin__ dynamic ${expression != null ? expression : ""}`
|
|
1208
|
-
);
|
|
1209
|
-
parent.insertBefore(commentBegin, el);
|
|
1210
|
-
setSwitchOwner(commentBegin, nodes);
|
|
1211
|
-
nodes.forEach((x) => {
|
|
1212
|
-
removeNode(x);
|
|
1213
|
-
});
|
|
1214
|
-
el.remove();
|
|
1215
|
-
const commentEnd = document.createComment(
|
|
1216
|
-
`__end__ dynamic ${expression != null ? expression : ""}`
|
|
1217
|
-
);
|
|
1218
|
-
parent.insertBefore(commentEnd, commentBegin.nextSibling);
|
|
1219
|
-
return {
|
|
1220
|
-
nodes,
|
|
1221
|
-
parent,
|
|
1222
|
-
commentBegin,
|
|
1223
|
-
commentEnd
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
__bindToExpression(el, expression) {
|
|
1227
|
-
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
1228
|
-
el,
|
|
1229
|
-
` => ${expression} `
|
|
1230
|
-
);
|
|
1231
|
-
const parseResult = this.__binder.__parser.__parse(expression);
|
|
1232
|
-
const value = parseResult.value;
|
|
1233
|
-
const parser = this.__binder.__parser;
|
|
1234
|
-
const capturedContext = parser.__capture();
|
|
1235
|
-
const mounted = { name: "" };
|
|
1236
|
-
const componentChildNodes = isTemplate(el) ? nodes : [...nodes[0].childNodes];
|
|
1237
|
-
const refresh = () => {
|
|
1238
|
-
parser.__scoped(capturedContext, () => {
|
|
1239
|
-
var _a;
|
|
1240
|
-
let name2 = value()[0];
|
|
1241
|
-
if (isObject(name2)) {
|
|
1242
|
-
if (!name2.name) {
|
|
1243
|
-
name2 = (_a = Object.entries(parser.__getComponents()).filter(
|
|
1244
|
-
(x) => x[1] === name2
|
|
1245
|
-
)[0]) == null ? void 0 : _a[0];
|
|
1246
|
-
} else {
|
|
1247
|
-
name2 = name2.name;
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
if (!isString(name2) || isNullOrWhitespace(name2)) {
|
|
1251
|
-
unmount(commentBegin, commentEnd);
|
|
1252
|
-
return;
|
|
1394
|
+
value
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1253
1397
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1398
|
+
};
|
|
1399
|
+
const clearUnusedAttributes = () => {
|
|
1400
|
+
for (const attrName of component.getAttributeNames()) {
|
|
1401
|
+
if (!attrName.startsWith("@") && !attrName.startsWith(binder.__config.__builtInNames.on))
|
|
1402
|
+
component.removeAttribute(attrName);
|
|
1260
1403
|
}
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
stopObserverList.push(stopObserving);
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
|
-
|
|
1282
|
-
// src/computed/watchEffect.ts
|
|
1283
|
-
var collectedRefs = [];
|
|
1284
|
-
var collectRef = (ref2) => {
|
|
1285
|
-
var _a;
|
|
1286
|
-
if (collectedRefs.length === 0) return;
|
|
1287
|
-
(_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
|
|
1288
|
-
};
|
|
1289
|
-
var watchEffect = (effect) => {
|
|
1290
|
-
if (!effect) return () => {
|
|
1291
|
-
};
|
|
1292
|
-
const terminator = { stop: () => {
|
|
1293
|
-
} };
|
|
1294
|
-
watchEffectInternal(effect, terminator);
|
|
1295
|
-
onUnmounted(() => terminator.stop(), true);
|
|
1296
|
-
return terminator.stop;
|
|
1297
|
-
};
|
|
1298
|
-
var watchEffectInternal = (effect, terminator) => {
|
|
1299
|
-
if (!effect) return;
|
|
1300
|
-
let stopObservingList = [];
|
|
1301
|
-
let isStopped = false;
|
|
1302
|
-
const stopWatch = () => {
|
|
1303
|
-
for (const stop of stopObservingList) stop();
|
|
1304
|
-
stopObservingList = [];
|
|
1305
|
-
isStopped = true;
|
|
1306
|
-
};
|
|
1307
|
-
terminator.stop = stopWatch;
|
|
1308
|
-
try {
|
|
1309
|
-
const set = /* @__PURE__ */ new Set();
|
|
1310
|
-
collectedRefs.push(set);
|
|
1311
|
-
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
1312
|
-
if (isStopped) return;
|
|
1313
|
-
for (const r of [...set]) {
|
|
1314
|
-
const stopObserving = observe(r, () => {
|
|
1315
|
-
stopWatch();
|
|
1316
|
-
watchEffect(effect);
|
|
1317
|
-
});
|
|
1318
|
-
stopObservingList.push(stopObserving);
|
|
1404
|
+
};
|
|
1405
|
+
const bindComponent = () => {
|
|
1406
|
+
transferAttributesToTheComponentChild();
|
|
1407
|
+
clearUnusedAttributes();
|
|
1408
|
+
parser.__push(componentCtx);
|
|
1409
|
+
binder.__bindAttributes(component, false);
|
|
1410
|
+
componentCtx.$emit = head.emit;
|
|
1411
|
+
bindChildNodes(binder, childNodes);
|
|
1412
|
+
addUnbinder(component, () => {
|
|
1413
|
+
callUnmounted(componentCtx);
|
|
1414
|
+
});
|
|
1415
|
+
addUnbinder(startOfComponent, () => {
|
|
1416
|
+
unbind(component);
|
|
1417
|
+
});
|
|
1418
|
+
callMounted(componentCtx);
|
|
1419
|
+
};
|
|
1420
|
+
parser.__scoped(capturedContext, bindComponent);
|
|
1319
1421
|
}
|
|
1320
|
-
} finally {
|
|
1321
|
-
collectedRefs.pop();
|
|
1322
|
-
}
|
|
1323
|
-
};
|
|
1324
|
-
var silence = (action) => {
|
|
1325
|
-
const len = collectedRefs.length;
|
|
1326
|
-
const hasPush = len > 0 && collectedRefs[len - 1];
|
|
1327
|
-
try {
|
|
1328
|
-
if (hasPush) collectedRefs.push(null);
|
|
1329
|
-
return action();
|
|
1330
|
-
} finally {
|
|
1331
|
-
if (hasPush) collectedRefs.pop();
|
|
1332
|
-
}
|
|
1333
|
-
};
|
|
1334
|
-
var collectRefs = (action) => {
|
|
1335
|
-
try {
|
|
1336
|
-
const set = /* @__PURE__ */ new Set();
|
|
1337
|
-
collectedRefs.push(set);
|
|
1338
|
-
const result = action();
|
|
1339
|
-
return { value: result, refs: [...set] };
|
|
1340
|
-
} finally {
|
|
1341
|
-
collectedRefs.pop();
|
|
1342
1422
|
}
|
|
1343
1423
|
};
|
|
1344
1424
|
|
|
1345
|
-
// src/
|
|
1346
|
-
var
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
if (!obj) return;
|
|
1358
|
-
if (isArray(obj) || isSet(obj)) {
|
|
1359
|
-
for (const el of obj) {
|
|
1360
|
-
trigger(el, eventSource, true);
|
|
1361
|
-
}
|
|
1362
|
-
} else if (isMap(obj)) {
|
|
1363
|
-
for (const el of obj) {
|
|
1364
|
-
trigger(el[0], eventSource, true);
|
|
1365
|
-
trigger(el[1], eventSource, true);
|
|
1366
|
-
}
|
|
1425
|
+
// src/bind/DirectiveCollector.ts
|
|
1426
|
+
var DirectiveElement = class {
|
|
1427
|
+
constructor(name2) {
|
|
1428
|
+
__publicField(this, "__name");
|
|
1429
|
+
// r-on @click @submit r-on:click.prevent @submit.prevent @[event-name].self.camel :src :className.prop .class-name.camel r-if r-for key
|
|
1430
|
+
/** Contains: `['@', 'submit'], ['r-on', 'click'], ['\\@', '[dynamicKey]']` */
|
|
1431
|
+
__publicField(this, "__terms", []);
|
|
1432
|
+
/** Contains directive flags. ['camel', 'prevent',...] */
|
|
1433
|
+
__publicField(this, "__flags", []);
|
|
1434
|
+
__publicField(this, "__elements", []);
|
|
1435
|
+
this.__name = name2;
|
|
1436
|
+
this.__parse();
|
|
1367
1437
|
}
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1438
|
+
__parse() {
|
|
1439
|
+
let name2 = this.__name;
|
|
1440
|
+
const isPropShortcut = name2.startsWith(".");
|
|
1441
|
+
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1442
|
+
const firstFlagIndex = name2.indexOf(".");
|
|
1443
|
+
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1444
|
+
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1445
|
+
if (firstFlagIndex >= 0) {
|
|
1446
|
+
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1447
|
+
if (flags.includes("camel")) {
|
|
1448
|
+
const index = terms.length - 1;
|
|
1449
|
+
terms[index] = camelize(terms[index]);
|
|
1450
|
+
}
|
|
1451
|
+
if (flags.includes("prop")) {
|
|
1452
|
+
terms[0] = ".";
|
|
1453
|
+
}
|
|
1371
1454
|
}
|
|
1372
1455
|
}
|
|
1373
1456
|
};
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
writable: false,
|
|
1399
|
-
enumerable: false,
|
|
1400
|
-
configurable: true
|
|
1401
|
-
});
|
|
1402
|
-
};
|
|
1403
|
-
|
|
1404
|
-
// src/proxies/array-ref.ts
|
|
1405
|
-
var arrayProto = Array.prototype;
|
|
1406
|
-
var proxyArrayProto = Object.create(arrayProto);
|
|
1407
|
-
var methodsToPatch = [
|
|
1408
|
-
"push",
|
|
1409
|
-
"pop",
|
|
1410
|
-
"shift",
|
|
1411
|
-
"unshift",
|
|
1412
|
-
"splice",
|
|
1413
|
-
"sort",
|
|
1414
|
-
"reverse"
|
|
1415
|
-
];
|
|
1416
|
-
createProxy(arrayProto, proxyArrayProto, methodsToPatch);
|
|
1417
|
-
|
|
1418
|
-
// src/proxies/map-ref.ts
|
|
1419
|
-
var mapProto = Map.prototype;
|
|
1420
|
-
var proxyMapProto = Object.create(mapProto);
|
|
1421
|
-
var methodsToPatch2 = ["set", "clear", "delete"];
|
|
1422
|
-
setToStringTag(proxyMapProto, "Map");
|
|
1423
|
-
createProxy(mapProto, proxyMapProto, methodsToPatch2);
|
|
1424
|
-
|
|
1425
|
-
// src/proxies/set-ref.ts
|
|
1426
|
-
var setProto = Set.prototype;
|
|
1427
|
-
var proxySetProto = Object.create(setProto);
|
|
1428
|
-
var methodsToPatch3 = ["add", "clear", "delete"];
|
|
1429
|
-
setToStringTag(proxySetProto, "Set");
|
|
1430
|
-
createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
1431
|
-
|
|
1432
|
-
// src/reactivity/sref.ts
|
|
1433
|
-
var batchCollector = {};
|
|
1434
|
-
var sref = (value) => {
|
|
1435
|
-
if (isRef(value) || isRaw(value)) return value;
|
|
1436
|
-
const refObj = {
|
|
1437
|
-
auto: true,
|
|
1438
|
-
_value: value
|
|
1439
|
-
};
|
|
1440
|
-
const createProxy2 = (value2) => {
|
|
1441
|
-
if (!isObject(value2)) return false;
|
|
1442
|
-
if (srefSymbol in value2) return true;
|
|
1443
|
-
const isAnArray = isArray(value2);
|
|
1444
|
-
if (isAnArray) {
|
|
1445
|
-
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
1446
|
-
return true;
|
|
1447
|
-
}
|
|
1448
|
-
const isASet = isSet(value2);
|
|
1449
|
-
if (isASet) {
|
|
1450
|
-
Object.setPrototypeOf(value2, proxySetProto);
|
|
1451
|
-
return true;
|
|
1452
|
-
}
|
|
1453
|
-
const isAMap = isMap(value2);
|
|
1454
|
-
if (isAMap) {
|
|
1455
|
-
Object.setPrototypeOf(value2, proxyMapProto);
|
|
1456
|
-
return true;
|
|
1457
|
+
var DirectiveCollector = class {
|
|
1458
|
+
constructor(binder) {
|
|
1459
|
+
__publicField(this, "__binder");
|
|
1460
|
+
__publicField(this, "__prefixes");
|
|
1461
|
+
this.__binder = binder;
|
|
1462
|
+
this.__prefixes = binder.__config.__getPrefixes();
|
|
1463
|
+
}
|
|
1464
|
+
__collect(element, isRecursive) {
|
|
1465
|
+
const map = /* @__PURE__ */ new Map();
|
|
1466
|
+
if (!isHTMLElement(element)) return map;
|
|
1467
|
+
const prefixes2 = this.__prefixes;
|
|
1468
|
+
const processNode = (node) => {
|
|
1469
|
+
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1470
|
+
for (const name2 of names) {
|
|
1471
|
+
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1472
|
+
const item = map.get(name2);
|
|
1473
|
+
item.__elements.push(node);
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
processNode(element);
|
|
1477
|
+
if (!isRecursive) return map;
|
|
1478
|
+
const nodes = element.querySelectorAll("*");
|
|
1479
|
+
for (const node of nodes) {
|
|
1480
|
+
processNode(node);
|
|
1457
1481
|
}
|
|
1458
|
-
return
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1482
|
+
return map;
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
// src/bind/DynamicBinder.ts
|
|
1487
|
+
var mount2 = (nodes, parent) => {
|
|
1488
|
+
for (const x of nodes) {
|
|
1489
|
+
const node = x.cloneNode(true);
|
|
1490
|
+
parent.appendChild(node);
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
var DynamicBinder = class {
|
|
1494
|
+
constructor(binder) {
|
|
1495
|
+
__publicField(this, "__binder");
|
|
1496
|
+
__publicField(this, "__is");
|
|
1497
|
+
__publicField(this, "__isSelector");
|
|
1498
|
+
this.__binder = binder;
|
|
1499
|
+
this.__is = binder.__config.__builtInNames.is;
|
|
1500
|
+
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1501
|
+
}
|
|
1502
|
+
__bindAll(element) {
|
|
1503
|
+
const isComponentElement = element.hasAttribute(this.__is);
|
|
1504
|
+
const elements = findElements(element, this.__isSelector);
|
|
1505
|
+
for (const el of elements) {
|
|
1506
|
+
this.__bind(el);
|
|
1467
1507
|
}
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1508
|
+
return isComponentElement;
|
|
1509
|
+
}
|
|
1510
|
+
__bind(el) {
|
|
1511
|
+
let expression = el.getAttribute(this.__is);
|
|
1512
|
+
if (!expression) {
|
|
1513
|
+
expression = el.getAttribute("is");
|
|
1514
|
+
if (!expression) return;
|
|
1515
|
+
if (!expression.startsWith("regor:")) {
|
|
1516
|
+
if (!expression.startsWith("r-")) return;
|
|
1517
|
+
const staticName = expression.slice(2).trim().toLowerCase();
|
|
1518
|
+
if (!staticName) return;
|
|
1519
|
+
const parent = el.parentNode;
|
|
1520
|
+
if (!parent) return;
|
|
1521
|
+
const nativeElement = document.createElement(staticName);
|
|
1522
|
+
for (const attr of el.getAttributeNames()) {
|
|
1523
|
+
if (attr === "is") continue;
|
|
1524
|
+
nativeElement.setAttribute(attr, el.getAttribute(attr));
|
|
1525
|
+
}
|
|
1526
|
+
while (el.firstChild) nativeElement.appendChild(el.firstChild);
|
|
1527
|
+
parent.insertBefore(nativeElement, el);
|
|
1528
|
+
el.remove();
|
|
1529
|
+
this.__binder.__bindDefault(nativeElement);
|
|
1530
|
+
return;
|
|
1473
1531
|
}
|
|
1532
|
+
expression = `'${expression.slice(6)}'`;
|
|
1533
|
+
el.removeAttribute("is");
|
|
1534
|
+
}
|
|
1535
|
+
el.removeAttribute(this.__is);
|
|
1536
|
+
this.__bindToExpression(el, expression);
|
|
1537
|
+
}
|
|
1538
|
+
__createRegion(el, expression) {
|
|
1539
|
+
const nodes = getNodes(el);
|
|
1540
|
+
const parent = el.parentNode;
|
|
1541
|
+
const commentBegin = document.createComment(
|
|
1542
|
+
`__begin__ dynamic ${expression != null ? expression : ""}`
|
|
1543
|
+
);
|
|
1544
|
+
parent.insertBefore(commentBegin, el);
|
|
1545
|
+
setSwitchOwner(commentBegin, nodes);
|
|
1546
|
+
nodes.forEach((x) => {
|
|
1547
|
+
removeNode(x);
|
|
1474
1548
|
});
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1549
|
+
el.remove();
|
|
1550
|
+
const commentEnd = document.createComment(
|
|
1551
|
+
`__end__ dynamic ${expression != null ? expression : ""}`
|
|
1552
|
+
);
|
|
1553
|
+
parent.insertBefore(commentEnd, commentBegin.nextSibling);
|
|
1554
|
+
return {
|
|
1555
|
+
nodes,
|
|
1556
|
+
parent,
|
|
1557
|
+
commentBegin,
|
|
1558
|
+
commentEnd
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
__bindToExpression(el, expression) {
|
|
1562
|
+
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
1563
|
+
el,
|
|
1564
|
+
` => ${expression} `
|
|
1565
|
+
);
|
|
1566
|
+
const parseResult = this.__binder.__parser.__parse(expression);
|
|
1567
|
+
const value = parseResult.value;
|
|
1568
|
+
const parser = this.__binder.__parser;
|
|
1569
|
+
const capturedContext = parser.__capture();
|
|
1570
|
+
const mounted = { name: "" };
|
|
1571
|
+
const componentChildNodes = isTemplate(el) ? nodes : [...nodes[0].childNodes];
|
|
1572
|
+
const refresh = () => {
|
|
1573
|
+
parser.__scoped(capturedContext, () => {
|
|
1574
|
+
var _a;
|
|
1575
|
+
let name2 = value()[0];
|
|
1576
|
+
if (isObject(name2)) {
|
|
1577
|
+
if (!name2.name) {
|
|
1578
|
+
name2 = (_a = Object.entries(parser.__getComponents()).filter(
|
|
1579
|
+
(x) => x[1] === name2
|
|
1580
|
+
)[0]) == null ? void 0 : _a[0];
|
|
1581
|
+
} else {
|
|
1582
|
+
name2 = name2.name;
|
|
1583
|
+
}
|
|
1490
1584
|
}
|
|
1491
|
-
if (
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
trigger2(newValue, eventSource);
|
|
1585
|
+
if (!isString(name2) || isNullOrWhitespace(name2)) {
|
|
1586
|
+
unmount(commentBegin, commentEnd);
|
|
1587
|
+
return;
|
|
1495
1588
|
}
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
};
|
|
1515
|
-
}
|
|
1516
|
-
case 1 /* trigger */: {
|
|
1517
|
-
const eventSource = args[1];
|
|
1518
|
-
const value2 = refObj._value;
|
|
1519
|
-
trigger2(value2, eventSource);
|
|
1520
|
-
break;
|
|
1521
|
-
}
|
|
1522
|
-
case 2 /* observerCount */: {
|
|
1523
|
-
return observers.size;
|
|
1524
|
-
}
|
|
1525
|
-
case 3 /* pause */: {
|
|
1526
|
-
refObj.auto = false;
|
|
1527
|
-
break;
|
|
1528
|
-
}
|
|
1529
|
-
case 4 /* resume */: {
|
|
1530
|
-
refObj.auto = true;
|
|
1589
|
+
if (mounted.name === name2) return;
|
|
1590
|
+
unmount(commentBegin, commentEnd);
|
|
1591
|
+
const componentElement = document.createElement(name2);
|
|
1592
|
+
for (const attr of el.getAttributeNames()) {
|
|
1593
|
+
if (attr === this.__is) continue;
|
|
1594
|
+
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1595
|
+
}
|
|
1596
|
+
mount2(componentChildNodes, componentElement);
|
|
1597
|
+
parent.insertBefore(componentElement, commentEnd);
|
|
1598
|
+
this.__binder.__bindDefault(componentElement);
|
|
1599
|
+
mounted.name = name2;
|
|
1600
|
+
});
|
|
1601
|
+
};
|
|
1602
|
+
const stopObserverList = [];
|
|
1603
|
+
const unbinder = () => {
|
|
1604
|
+
parseResult.stop();
|
|
1605
|
+
for (const stopObserver of stopObserverList) {
|
|
1606
|
+
stopObserver();
|
|
1531
1607
|
}
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1608
|
+
stopObserverList.length = 0;
|
|
1609
|
+
};
|
|
1610
|
+
addUnbinder(commentBegin, unbinder);
|
|
1611
|
+
refresh();
|
|
1612
|
+
const stopObserving = observe(value, refresh);
|
|
1613
|
+
stopObserverList.push(stopObserving);
|
|
1614
|
+
}
|
|
1539
1615
|
};
|
|
1540
1616
|
|
|
1541
1617
|
// src/reactivity/unref.ts
|
|
@@ -2993,45 +3069,6 @@ var valueDirective = {
|
|
|
2993
3069
|
}
|
|
2994
3070
|
};
|
|
2995
3071
|
|
|
2996
|
-
// src/reactivity/isDeepRef.ts
|
|
2997
|
-
var isDeepRef = (value) => {
|
|
2998
|
-
return (value == null ? void 0 : value[refSymbol]) === 1;
|
|
2999
|
-
};
|
|
3000
|
-
|
|
3001
|
-
// src/reactivity/ref.ts
|
|
3002
|
-
var ref = (value) => {
|
|
3003
|
-
if (isRaw(value)) return value;
|
|
3004
|
-
let result;
|
|
3005
|
-
if (isRef(value)) {
|
|
3006
|
-
result = value;
|
|
3007
|
-
value = result();
|
|
3008
|
-
} else {
|
|
3009
|
-
result = sref(value);
|
|
3010
|
-
}
|
|
3011
|
-
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
3012
|
-
return result;
|
|
3013
|
-
result[refSymbol] = 1;
|
|
3014
|
-
if (isArray(value)) {
|
|
3015
|
-
const len = value.length;
|
|
3016
|
-
for (let i = 0; i < len; ++i) {
|
|
3017
|
-
const item = value[i];
|
|
3018
|
-
if (isDeepRef(item)) continue;
|
|
3019
|
-
value[i] = ref(item);
|
|
3020
|
-
}
|
|
3021
|
-
return result;
|
|
3022
|
-
}
|
|
3023
|
-
if (!isObject(value)) return result;
|
|
3024
|
-
for (const item of Object.entries(value)) {
|
|
3025
|
-
const val = item[1];
|
|
3026
|
-
if (isDeepRef(val)) continue;
|
|
3027
|
-
const key = item[0];
|
|
3028
|
-
if (isSymbol(key)) continue;
|
|
3029
|
-
value[key] = null;
|
|
3030
|
-
value[key] = ref(val);
|
|
3031
|
-
}
|
|
3032
|
-
return result;
|
|
3033
|
-
};
|
|
3034
|
-
|
|
3035
3072
|
// src/app/RegorConfig.ts
|
|
3036
3073
|
var _RegorConfig = class _RegorConfig {
|
|
3037
3074
|
constructor(globalContext) {
|