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