regor 1.2.5 → 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 +774 -712
- package/dist/regor.es2015.cjs.prod.js +4 -4
- package/dist/regor.es2015.esm.js +774 -712
- package/dist/regor.es2015.esm.prod.js +4 -4
- package/dist/regor.es2015.iife.js +774 -712
- package/dist/regor.es2015.iife.prod.js +4 -4
- package/dist/regor.es2019.cjs.js +774 -712
- package/dist/regor.es2019.cjs.prod.js +4 -4
- package/dist/regor.es2019.esm.js +774 -712
- package/dist/regor.es2019.esm.prod.js +4 -4
- package/dist/regor.es2019.iife.js +774 -712
- package/dist/regor.es2019.iife.prod.js +4 -4
- package/dist/regor.es2022.cjs.js +775 -713
- package/dist/regor.es2022.cjs.prod.js +4 -4
- package/dist/regor.es2022.esm.js +775 -713
- package/dist/regor.es2022.esm.prod.js +4 -4
- package/dist/regor.es2022.iife.js +775 -713
- package/dist/regor.es2022.iife.prod.js +4 -4
- package/package.json +1 -1
package/dist/regor.es2015.cjs.js
CHANGED
|
@@ -759,33 +759,6 @@ var propsOnceDirective = {
|
|
|
759
759
|
}
|
|
760
760
|
};
|
|
761
761
|
|
|
762
|
-
// src/directives/single-prop.ts
|
|
763
|
-
var singlePropDirective = {
|
|
764
|
-
collectRefObj: true,
|
|
765
|
-
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
766
|
-
if (!option) return () => {
|
|
767
|
-
};
|
|
768
|
-
const key = camelize(option);
|
|
769
|
-
const stopObserving = observe(
|
|
770
|
-
parseResult.value,
|
|
771
|
-
() => {
|
|
772
|
-
var _a;
|
|
773
|
-
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
774
|
-
const ctx = parseResult.context;
|
|
775
|
-
const ctxKey = ctx[option];
|
|
776
|
-
if (ctxKey === value) return;
|
|
777
|
-
if (isRef(ctxKey)) {
|
|
778
|
-
ctxKey(value);
|
|
779
|
-
} else {
|
|
780
|
-
ctx[key] = value;
|
|
781
|
-
}
|
|
782
|
-
},
|
|
783
|
-
true
|
|
784
|
-
);
|
|
785
|
-
return stopObserving;
|
|
786
|
-
}
|
|
787
|
-
};
|
|
788
|
-
|
|
789
762
|
// src/reactivity/entangle.ts
|
|
790
763
|
var entangle = (r1, r2) => {
|
|
791
764
|
if (r1 === r2) return () => {
|
|
@@ -799,182 +772,561 @@ var entangle = (r1, r2) => {
|
|
|
799
772
|
};
|
|
800
773
|
};
|
|
801
774
|
|
|
802
|
-
// src/
|
|
803
|
-
var
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
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();
|
|
809
825
|
}
|
|
810
|
-
|
|
811
|
-
|
|
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();
|
|
812
835
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
);
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
);
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
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
|
+
|
|
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
|
+
};
|
|
1085
|
+
var singlePropDirective = {
|
|
1086
|
+
collectRefObj: true,
|
|
1087
|
+
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
1088
|
+
if (!option) return () => {
|
|
1089
|
+
};
|
|
1090
|
+
const key = camelize(option);
|
|
1091
|
+
let currentSource;
|
|
1092
|
+
let bridge;
|
|
1093
|
+
let stopEntangle = () => {
|
|
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
|
+
};
|
|
1113
|
+
const stopObserving = observe(
|
|
1114
|
+
parseResult.value,
|
|
1115
|
+
() => {
|
|
1116
|
+
var _a;
|
|
1117
|
+
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
1118
|
+
const ctx = parseResult.context;
|
|
1119
|
+
const ctxKey = ctx[key];
|
|
1120
|
+
if (!isRef(value)) {
|
|
1121
|
+
if (bridge && ctxKey === bridge) {
|
|
1122
|
+
bridge(value);
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
resetSync();
|
|
1126
|
+
if (isRef(ctxKey)) {
|
|
1127
|
+
ctxKey(value);
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
ctx[key] = value;
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
if (isModelBridge(value)) {
|
|
1134
|
+
if (isRef(ctxKey)) {
|
|
1135
|
+
syncRefs(value, ctxKey);
|
|
1136
|
+
} else {
|
|
1137
|
+
ctx[key] = value;
|
|
1138
|
+
}
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
if (!bridge) bridge = createModelBridge(value);
|
|
1142
|
+
ctx[key] = bridge;
|
|
1143
|
+
syncRefs(value, bridge);
|
|
1144
|
+
},
|
|
1145
|
+
true
|
|
1146
|
+
);
|
|
1147
|
+
return () => {
|
|
1148
|
+
stopEntangle();
|
|
1149
|
+
stopObserving();
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
// src/bind/ComponentBinder.ts
|
|
1155
|
+
var ComponentBinder = class {
|
|
1156
|
+
constructor(binder) {
|
|
1157
|
+
__publicField(this, "__binder");
|
|
1158
|
+
__publicField(this, "__inherit");
|
|
1159
|
+
this.__binder = binder;
|
|
1160
|
+
this.__inherit = binder.__config.__builtInNames.inherit;
|
|
1161
|
+
}
|
|
1162
|
+
__bindAll(element) {
|
|
1163
|
+
this.__unwrapComponents(element);
|
|
1164
|
+
}
|
|
1165
|
+
__unwrapComponents(element) {
|
|
1166
|
+
var _a;
|
|
1167
|
+
const binder = this.__binder;
|
|
1168
|
+
const parser = binder.__parser;
|
|
1169
|
+
const registeredComponents = binder.__config.__components;
|
|
1170
|
+
const registeredComponentsUpperCase = binder.__config.__componentsUpperCase;
|
|
1171
|
+
const contextComponents = parser.__getComponents();
|
|
1172
|
+
const contextComponentSelectors = parser.__getComponentSelectors();
|
|
1173
|
+
const selector = [
|
|
1174
|
+
...registeredComponents.keys(),
|
|
1175
|
+
...contextComponentSelectors,
|
|
1176
|
+
...[...registeredComponents.keys()].map(hyphenate),
|
|
1177
|
+
...contextComponentSelectors.map(hyphenate)
|
|
1178
|
+
].join(",");
|
|
1179
|
+
if (isNullOrWhitespace(selector)) return;
|
|
1180
|
+
const list = element.querySelectorAll(selector);
|
|
1181
|
+
const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
|
|
1182
|
+
for (const component of components) {
|
|
1183
|
+
if (component.hasAttribute(binder.__pre)) continue;
|
|
1184
|
+
const parent = component.parentNode;
|
|
1185
|
+
if (!parent) continue;
|
|
1186
|
+
const nextSibling = component.nextSibling;
|
|
1187
|
+
const tagName = camelize(component.tagName).toUpperCase();
|
|
1188
|
+
const contextComponent = contextComponents[tagName];
|
|
1189
|
+
const registeredComponent = contextComponent != null ? contextComponent : registeredComponentsUpperCase.get(tagName);
|
|
1190
|
+
if (!registeredComponent) continue;
|
|
1191
|
+
const templateElement = registeredComponent.template;
|
|
1192
|
+
if (!templateElement) continue;
|
|
1193
|
+
const componentParent = component.parentElement;
|
|
1194
|
+
if (!componentParent) continue;
|
|
1195
|
+
const startOfComponent = new Comment(
|
|
1196
|
+
" begin component: " + component.tagName
|
|
1197
|
+
);
|
|
1198
|
+
const endOfComponent = new Comment(" end component: " + component.tagName);
|
|
1199
|
+
componentParent.insertBefore(startOfComponent, component);
|
|
1200
|
+
component.remove();
|
|
1201
|
+
const propsName = binder.__config.__builtInNames.props;
|
|
1202
|
+
const propsOnceName = binder.__config.__builtInNames.propsOnce;
|
|
1203
|
+
const bindName = binder.__config.__builtInNames.bind;
|
|
1204
|
+
const getProps = (component2, capturedContext2) => {
|
|
1205
|
+
const props = {};
|
|
1206
|
+
const hasProps = component2.hasAttribute(propsName);
|
|
1207
|
+
const hasPropsOnce = component2.hasAttribute(propsOnceName);
|
|
1208
|
+
parser.__scoped(capturedContext2, () => {
|
|
1209
|
+
parser.__push(props);
|
|
1210
|
+
if (hasProps) binder.__bind(propsDirective, component2, propsName);
|
|
1211
|
+
if (hasPropsOnce)
|
|
1212
|
+
binder.__bind(propsOnceDirective, component2, propsOnceName);
|
|
1213
|
+
let definedProps = registeredComponent.props;
|
|
1214
|
+
if (!definedProps || definedProps.length === 0) return;
|
|
1215
|
+
definedProps = definedProps.map(camelize);
|
|
1216
|
+
const definedPropsByLowerCase = new Map(
|
|
1217
|
+
definedProps.map((definedProp) => [
|
|
1218
|
+
definedProp.toLowerCase(),
|
|
1219
|
+
definedProp
|
|
1220
|
+
])
|
|
1221
|
+
);
|
|
1222
|
+
for (const name2 of definedProps.concat(definedProps.map(hyphenate))) {
|
|
1223
|
+
const value = component2.getAttribute(name2);
|
|
1224
|
+
if (value === null) continue;
|
|
1225
|
+
props[camelize(name2)] = value;
|
|
1226
|
+
component2.removeAttribute(name2);
|
|
1227
|
+
}
|
|
1228
|
+
const map = binder.__directiveCollector.__collect(component2, false);
|
|
1229
|
+
for (const [attrName, item] of map.entries()) {
|
|
1230
|
+
const [name2, option] = item.__terms;
|
|
1231
|
+
if (!option) continue;
|
|
1232
|
+
const propName = definedPropsByLowerCase.get(
|
|
1233
|
+
camelize(option).toLowerCase()
|
|
1234
|
+
);
|
|
1235
|
+
if (!propName) continue;
|
|
1236
|
+
if (name2 !== "." && name2 !== ":" && name2 !== bindName) continue;
|
|
1237
|
+
binder.__bind(
|
|
1238
|
+
singlePropDirective,
|
|
1239
|
+
component2,
|
|
1240
|
+
attrName,
|
|
1241
|
+
true,
|
|
1242
|
+
propName,
|
|
1243
|
+
item.__flags
|
|
1244
|
+
);
|
|
1245
|
+
}
|
|
1246
|
+
});
|
|
1247
|
+
return props;
|
|
1248
|
+
};
|
|
1249
|
+
const capturedContext = [...parser.__capture()];
|
|
1250
|
+
const createComponentCtx = () => {
|
|
1251
|
+
var _a2;
|
|
1252
|
+
const props = getProps(component, capturedContext);
|
|
1253
|
+
const head2 = new ComponentHead(
|
|
1254
|
+
props,
|
|
1255
|
+
component,
|
|
1256
|
+
capturedContext,
|
|
1257
|
+
startOfComponent,
|
|
1258
|
+
endOfComponent
|
|
1259
|
+
);
|
|
1260
|
+
const componentCtx2 = useScope(() => {
|
|
1261
|
+
var _a3;
|
|
1262
|
+
return (_a3 = registeredComponent.context(head2)) != null ? _a3 : {};
|
|
1263
|
+
}).context;
|
|
1264
|
+
if (head2.autoProps) {
|
|
1265
|
+
for (const [key, propsValue] of Object.entries(props)) {
|
|
1266
|
+
if (key in componentCtx2) {
|
|
1267
|
+
const compValue = componentCtx2[key];
|
|
1268
|
+
if (compValue === propsValue) continue;
|
|
1269
|
+
if (head2.entangle && isRef(compValue) && isRef(propsValue)) {
|
|
1270
|
+
addUnbinder(startOfComponent, entangle(propsValue, compValue));
|
|
1271
|
+
}
|
|
1272
|
+
} else componentCtx2[key] = propsValue;
|
|
1273
|
+
}
|
|
1274
|
+
(_a2 = head2.onAutoPropsAssigned) == null ? void 0 : _a2.call(head2);
|
|
1275
|
+
}
|
|
1276
|
+
return { componentCtx: componentCtx2, head: head2 };
|
|
1277
|
+
};
|
|
1278
|
+
const { componentCtx, head } = createComponentCtx();
|
|
1279
|
+
const childNodes = [...getChildNodes(templateElement)];
|
|
1280
|
+
const len = childNodes.length;
|
|
1281
|
+
const isEmptyComponent = component.childNodes.length === 0;
|
|
1282
|
+
const expandSlot = (slot) => {
|
|
1283
|
+
const parent2 = slot.parentElement;
|
|
1284
|
+
if (isEmptyComponent) {
|
|
1285
|
+
for (const slotChild of [...slot.childNodes]) {
|
|
1286
|
+
parent2.insertBefore(slotChild, slot);
|
|
1287
|
+
}
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
let name2 = slot.name;
|
|
1291
|
+
if (isNullOrWhitespace(name2)) {
|
|
1292
|
+
name2 = slot.getAttributeNames().filter((x) => x.startsWith("#"))[0];
|
|
1293
|
+
if (isNullOrWhitespace(name2)) {
|
|
1294
|
+
name2 = "default";
|
|
1295
|
+
} else name2 = name2.substring(1);
|
|
1296
|
+
}
|
|
1297
|
+
let compTemplate = component.querySelector(
|
|
1298
|
+
`template[name='${name2}'], template[\\#${name2}]`
|
|
1299
|
+
);
|
|
1300
|
+
if (!compTemplate && name2 === "default") {
|
|
1301
|
+
compTemplate = component.querySelector("template:not([name])");
|
|
1302
|
+
if (compTemplate && compTemplate.getAttributeNames().filter((x) => x.startsWith("#")).length > 0)
|
|
1303
|
+
compTemplate = null;
|
|
1304
|
+
}
|
|
1305
|
+
const createSwitchContext = (childNodes2) => {
|
|
1306
|
+
if (!head.enableSwitch) return;
|
|
1307
|
+
parser.__scoped(capturedContext, () => {
|
|
1308
|
+
parser.__push(componentCtx);
|
|
1309
|
+
const props = getProps(slot, parser.__capture());
|
|
1310
|
+
parser.__scoped(capturedContext, () => {
|
|
1311
|
+
parser.__push(props);
|
|
1312
|
+
const switchContext = parser.__capture();
|
|
1313
|
+
const id = addSwitch(switchContext);
|
|
1314
|
+
for (const child of childNodes2) {
|
|
1315
|
+
if (!isElement(child)) continue;
|
|
1316
|
+
child.setAttribute(rswitch, id);
|
|
1317
|
+
refSwitch(id);
|
|
1318
|
+
addUnbinder(child, () => {
|
|
1319
|
+
removeSwitch(id);
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1323
|
+
});
|
|
1324
|
+
};
|
|
1325
|
+
if (compTemplate) {
|
|
1326
|
+
const childNodes2 = [...getChildNodes(compTemplate)];
|
|
1327
|
+
for (const slotChild of childNodes2) {
|
|
1328
|
+
parent2.insertBefore(slotChild, slot);
|
|
1329
|
+
}
|
|
978
1330
|
createSwitchContext(childNodes2);
|
|
979
1331
|
} else {
|
|
980
1332
|
if (name2 !== "default") {
|
|
@@ -1041,484 +1393,225 @@ var ComponentBinder = class {
|
|
|
1041
1393
|
normalizeAttributeName(attrName, binder.__config),
|
|
1042
1394
|
value
|
|
1043
1395
|
);
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
};
|
|
1047
|
-
const clearUnusedAttributes = () => {
|
|
1048
|
-
for (const attrName of component.getAttributeNames()) {
|
|
1049
|
-
if (!attrName.startsWith("@") && !attrName.startsWith(binder.__config.__builtInNames.on))
|
|
1050
|
-
component.removeAttribute(attrName);
|
|
1051
|
-
}
|
|
1052
|
-
};
|
|
1053
|
-
const bindComponent = () => {
|
|
1054
|
-
transferAttributesToTheComponentChild();
|
|
1055
|
-
clearUnusedAttributes();
|
|
1056
|
-
parser.__push(componentCtx);
|
|
1057
|
-
binder.__bindAttributes(component, false);
|
|
1058
|
-
componentCtx.$emit = head.emit;
|
|
1059
|
-
bindChildNodes(binder, childNodes);
|
|
1060
|
-
addUnbinder(component, () => {
|
|
1061
|
-
callUnmounted(componentCtx);
|
|
1062
|
-
});
|
|
1063
|
-
addUnbinder(startOfComponent, () => {
|
|
1064
|
-
unbind(component);
|
|
1065
|
-
});
|
|
1066
|
-
callMounted(componentCtx);
|
|
1067
|
-
};
|
|
1068
|
-
parser.__scoped(capturedContext, bindComponent);
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
};
|
|
1072
|
-
|
|
1073
|
-
// src/bind/DirectiveCollector.ts
|
|
1074
|
-
var DirectiveElement = class {
|
|
1075
|
-
constructor(name2) {
|
|
1076
|
-
__publicField(this, "__name");
|
|
1077
|
-
// 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
|
|
1078
|
-
/** Contains: `['@', 'submit'], ['r-on', 'click'], ['\\@', '[dynamicKey]']` */
|
|
1079
|
-
__publicField(this, "__terms", []);
|
|
1080
|
-
/** Contains directive flags. ['camel', 'prevent',...] */
|
|
1081
|
-
__publicField(this, "__flags", []);
|
|
1082
|
-
__publicField(this, "__elements", []);
|
|
1083
|
-
this.__name = name2;
|
|
1084
|
-
this.__parse();
|
|
1085
|
-
}
|
|
1086
|
-
__parse() {
|
|
1087
|
-
let name2 = this.__name;
|
|
1088
|
-
const isPropShortcut = name2.startsWith(".");
|
|
1089
|
-
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1090
|
-
const firstFlagIndex = name2.indexOf(".");
|
|
1091
|
-
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1092
|
-
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1093
|
-
if (firstFlagIndex >= 0) {
|
|
1094
|
-
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1095
|
-
if (flags.includes("camel")) {
|
|
1096
|
-
const index = terms.length - 1;
|
|
1097
|
-
terms[index] = camelize(terms[index]);
|
|
1098
|
-
}
|
|
1099
|
-
if (flags.includes("prop")) {
|
|
1100
|
-
terms[0] = ".";
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
};
|
|
1105
|
-
var DirectiveCollector = class {
|
|
1106
|
-
constructor(binder) {
|
|
1107
|
-
__publicField(this, "__binder");
|
|
1108
|
-
__publicField(this, "__prefixes");
|
|
1109
|
-
this.__binder = binder;
|
|
1110
|
-
this.__prefixes = binder.__config.__getPrefixes();
|
|
1111
|
-
}
|
|
1112
|
-
__collect(element, isRecursive) {
|
|
1113
|
-
const map = /* @__PURE__ */ new Map();
|
|
1114
|
-
if (!isHTMLElement(element)) return map;
|
|
1115
|
-
const prefixes2 = this.__prefixes;
|
|
1116
|
-
const processNode = (node) => {
|
|
1117
|
-
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1118
|
-
for (const name2 of names) {
|
|
1119
|
-
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1120
|
-
const item = map.get(name2);
|
|
1121
|
-
item.__elements.push(node);
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
processNode(element);
|
|
1125
|
-
if (!isRecursive) return map;
|
|
1126
|
-
const nodes = element.querySelectorAll("*");
|
|
1127
|
-
for (const node of nodes) {
|
|
1128
|
-
processNode(node);
|
|
1129
|
-
}
|
|
1130
|
-
return map;
|
|
1131
|
-
}
|
|
1132
|
-
};
|
|
1133
|
-
|
|
1134
|
-
// src/bind/DynamicBinder.ts
|
|
1135
|
-
var mount2 = (nodes, parent) => {
|
|
1136
|
-
for (const x of nodes) {
|
|
1137
|
-
const node = x.cloneNode(true);
|
|
1138
|
-
parent.appendChild(node);
|
|
1139
|
-
}
|
|
1140
|
-
};
|
|
1141
|
-
var DynamicBinder = class {
|
|
1142
|
-
constructor(binder) {
|
|
1143
|
-
__publicField(this, "__binder");
|
|
1144
|
-
__publicField(this, "__is");
|
|
1145
|
-
__publicField(this, "__isSelector");
|
|
1146
|
-
this.__binder = binder;
|
|
1147
|
-
this.__is = binder.__config.__builtInNames.is;
|
|
1148
|
-
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1149
|
-
}
|
|
1150
|
-
__bindAll(element) {
|
|
1151
|
-
const isComponentElement = element.hasAttribute(this.__is);
|
|
1152
|
-
const elements = findElements(element, this.__isSelector);
|
|
1153
|
-
for (const el of elements) {
|
|
1154
|
-
this.__bind(el);
|
|
1155
|
-
}
|
|
1156
|
-
return isComponentElement;
|
|
1157
|
-
}
|
|
1158
|
-
__bind(el) {
|
|
1159
|
-
let expression = el.getAttribute(this.__is);
|
|
1160
|
-
if (!expression) {
|
|
1161
|
-
expression = el.getAttribute("is");
|
|
1162
|
-
if (!expression) return;
|
|
1163
|
-
if (!expression.startsWith("regor:")) {
|
|
1164
|
-
if (!expression.startsWith("r-")) return;
|
|
1165
|
-
const staticName = expression.slice(2).trim().toLowerCase();
|
|
1166
|
-
if (!staticName) return;
|
|
1167
|
-
const parent = el.parentNode;
|
|
1168
|
-
if (!parent) return;
|
|
1169
|
-
const nativeElement = document.createElement(staticName);
|
|
1170
|
-
for (const attr of el.getAttributeNames()) {
|
|
1171
|
-
if (attr === "is") continue;
|
|
1172
|
-
nativeElement.setAttribute(attr, el.getAttribute(attr));
|
|
1173
|
-
}
|
|
1174
|
-
while (el.firstChild) nativeElement.appendChild(el.firstChild);
|
|
1175
|
-
parent.insertBefore(nativeElement, el);
|
|
1176
|
-
el.remove();
|
|
1177
|
-
this.__binder.__bindDefault(nativeElement);
|
|
1178
|
-
return;
|
|
1179
|
-
}
|
|
1180
|
-
expression = `'${expression.slice(6)}'`;
|
|
1181
|
-
el.removeAttribute("is");
|
|
1182
|
-
}
|
|
1183
|
-
el.removeAttribute(this.__is);
|
|
1184
|
-
this.__bindToExpression(el, expression);
|
|
1185
|
-
}
|
|
1186
|
-
__createRegion(el, expression) {
|
|
1187
|
-
const nodes = getNodes(el);
|
|
1188
|
-
const parent = el.parentNode;
|
|
1189
|
-
const commentBegin = document.createComment(
|
|
1190
|
-
`__begin__ dynamic ${expression != null ? expression : ""}`
|
|
1191
|
-
);
|
|
1192
|
-
parent.insertBefore(commentBegin, el);
|
|
1193
|
-
setSwitchOwner(commentBegin, nodes);
|
|
1194
|
-
nodes.forEach((x) => {
|
|
1195
|
-
removeNode(x);
|
|
1196
|
-
});
|
|
1197
|
-
el.remove();
|
|
1198
|
-
const commentEnd = document.createComment(
|
|
1199
|
-
`__end__ dynamic ${expression != null ? expression : ""}`
|
|
1200
|
-
);
|
|
1201
|
-
parent.insertBefore(commentEnd, commentBegin.nextSibling);
|
|
1202
|
-
return {
|
|
1203
|
-
nodes,
|
|
1204
|
-
parent,
|
|
1205
|
-
commentBegin,
|
|
1206
|
-
commentEnd
|
|
1207
|
-
};
|
|
1208
|
-
}
|
|
1209
|
-
__bindToExpression(el, expression) {
|
|
1210
|
-
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
1211
|
-
el,
|
|
1212
|
-
` => ${expression} `
|
|
1213
|
-
);
|
|
1214
|
-
const parseResult = this.__binder.__parser.__parse(expression);
|
|
1215
|
-
const value = parseResult.value;
|
|
1216
|
-
const parser = this.__binder.__parser;
|
|
1217
|
-
const capturedContext = parser.__capture();
|
|
1218
|
-
const mounted = { name: "" };
|
|
1219
|
-
const componentChildNodes = isTemplate(el) ? nodes : [...nodes[0].childNodes];
|
|
1220
|
-
const refresh = () => {
|
|
1221
|
-
parser.__scoped(capturedContext, () => {
|
|
1222
|
-
var _a;
|
|
1223
|
-
let name2 = value()[0];
|
|
1224
|
-
if (isObject(name2)) {
|
|
1225
|
-
if (!name2.name) {
|
|
1226
|
-
name2 = (_a = Object.entries(parser.__getComponents()).filter(
|
|
1227
|
-
(x) => x[1] === name2
|
|
1228
|
-
)[0]) == null ? void 0 : _a[0];
|
|
1229
|
-
} else {
|
|
1230
|
-
name2 = name2.name;
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
if (!isString(name2) || isNullOrWhitespace(name2)) {
|
|
1234
|
-
unmount(commentBegin, commentEnd);
|
|
1235
|
-
return;
|
|
1396
|
+
}
|
|
1236
1397
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
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);
|
|
1243
1403
|
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
stopObserverList.push(stopObserving);
|
|
1262
|
-
}
|
|
1263
|
-
};
|
|
1264
|
-
|
|
1265
|
-
// src/computed/watchEffect.ts
|
|
1266
|
-
var collectedRefs = [];
|
|
1267
|
-
var collectRef = (ref2) => {
|
|
1268
|
-
var _a;
|
|
1269
|
-
if (collectedRefs.length === 0) return;
|
|
1270
|
-
(_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
|
|
1271
|
-
};
|
|
1272
|
-
var watchEffect = (effect) => {
|
|
1273
|
-
if (!effect) return () => {
|
|
1274
|
-
};
|
|
1275
|
-
const terminator = { stop: () => {
|
|
1276
|
-
} };
|
|
1277
|
-
watchEffectInternal(effect, terminator);
|
|
1278
|
-
onUnmounted(() => terminator.stop(), true);
|
|
1279
|
-
return terminator.stop;
|
|
1280
|
-
};
|
|
1281
|
-
var watchEffectInternal = (effect, terminator) => {
|
|
1282
|
-
if (!effect) return;
|
|
1283
|
-
let stopObservingList = [];
|
|
1284
|
-
let isStopped = false;
|
|
1285
|
-
const stopWatch = () => {
|
|
1286
|
-
for (const stop of stopObservingList) stop();
|
|
1287
|
-
stopObservingList = [];
|
|
1288
|
-
isStopped = true;
|
|
1289
|
-
};
|
|
1290
|
-
terminator.stop = stopWatch;
|
|
1291
|
-
try {
|
|
1292
|
-
const set = /* @__PURE__ */ new Set();
|
|
1293
|
-
collectedRefs.push(set);
|
|
1294
|
-
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
1295
|
-
if (isStopped) return;
|
|
1296
|
-
for (const r of [...set]) {
|
|
1297
|
-
const stopObserving = observe(r, () => {
|
|
1298
|
-
stopWatch();
|
|
1299
|
-
watchEffect(effect);
|
|
1300
|
-
});
|
|
1301
|
-
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);
|
|
1302
1421
|
}
|
|
1303
|
-
} finally {
|
|
1304
|
-
collectedRefs.pop();
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
var silence = (action) => {
|
|
1308
|
-
const len = collectedRefs.length;
|
|
1309
|
-
const hasPush = len > 0 && collectedRefs[len - 1];
|
|
1310
|
-
try {
|
|
1311
|
-
if (hasPush) collectedRefs.push(null);
|
|
1312
|
-
return action();
|
|
1313
|
-
} finally {
|
|
1314
|
-
if (hasPush) collectedRefs.pop();
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
var collectRefs = (action) => {
|
|
1318
|
-
try {
|
|
1319
|
-
const set = /* @__PURE__ */ new Set();
|
|
1320
|
-
collectedRefs.push(set);
|
|
1321
|
-
const result = action();
|
|
1322
|
-
return { value: result, refs: [...set] };
|
|
1323
|
-
} finally {
|
|
1324
|
-
collectedRefs.pop();
|
|
1325
1422
|
}
|
|
1326
1423
|
};
|
|
1327
1424
|
|
|
1328
|
-
// src/
|
|
1329
|
-
var
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
if (!obj) return;
|
|
1341
|
-
if (isArray(obj) || isSet(obj)) {
|
|
1342
|
-
for (const el of obj) {
|
|
1343
|
-
trigger(el, eventSource, true);
|
|
1344
|
-
}
|
|
1345
|
-
} else if (isMap(obj)) {
|
|
1346
|
-
for (const el of obj) {
|
|
1347
|
-
trigger(el[0], eventSource, true);
|
|
1348
|
-
trigger(el[1], eventSource, true);
|
|
1349
|
-
}
|
|
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();
|
|
1350
1437
|
}
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
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
|
+
}
|
|
1354
1454
|
}
|
|
1355
1455
|
}
|
|
1356
1456
|
};
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
writable: false,
|
|
1382
|
-
enumerable: false,
|
|
1383
|
-
configurable: true
|
|
1384
|
-
});
|
|
1385
|
-
};
|
|
1386
|
-
|
|
1387
|
-
// src/proxies/array-ref.ts
|
|
1388
|
-
var arrayProto = Array.prototype;
|
|
1389
|
-
var proxyArrayProto = Object.create(arrayProto);
|
|
1390
|
-
var methodsToPatch = [
|
|
1391
|
-
"push",
|
|
1392
|
-
"pop",
|
|
1393
|
-
"shift",
|
|
1394
|
-
"unshift",
|
|
1395
|
-
"splice",
|
|
1396
|
-
"sort",
|
|
1397
|
-
"reverse"
|
|
1398
|
-
];
|
|
1399
|
-
createProxy(arrayProto, proxyArrayProto, methodsToPatch);
|
|
1400
|
-
|
|
1401
|
-
// src/proxies/map-ref.ts
|
|
1402
|
-
var mapProto = Map.prototype;
|
|
1403
|
-
var proxyMapProto = Object.create(mapProto);
|
|
1404
|
-
var methodsToPatch2 = ["set", "clear", "delete"];
|
|
1405
|
-
setToStringTag(proxyMapProto, "Map");
|
|
1406
|
-
createProxy(mapProto, proxyMapProto, methodsToPatch2);
|
|
1407
|
-
|
|
1408
|
-
// src/proxies/set-ref.ts
|
|
1409
|
-
var setProto = Set.prototype;
|
|
1410
|
-
var proxySetProto = Object.create(setProto);
|
|
1411
|
-
var methodsToPatch3 = ["add", "clear", "delete"];
|
|
1412
|
-
setToStringTag(proxySetProto, "Set");
|
|
1413
|
-
createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
1414
|
-
|
|
1415
|
-
// src/reactivity/sref.ts
|
|
1416
|
-
var batchCollector = {};
|
|
1417
|
-
var sref = (value) => {
|
|
1418
|
-
if (isRef(value) || isRaw(value)) return value;
|
|
1419
|
-
const refObj = {
|
|
1420
|
-
auto: true,
|
|
1421
|
-
_value: value
|
|
1422
|
-
};
|
|
1423
|
-
const createProxy2 = (value2) => {
|
|
1424
|
-
if (!isObject(value2)) return false;
|
|
1425
|
-
if (srefSymbol in value2) return true;
|
|
1426
|
-
const isAnArray = isArray(value2);
|
|
1427
|
-
if (isAnArray) {
|
|
1428
|
-
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
1429
|
-
return true;
|
|
1430
|
-
}
|
|
1431
|
-
const isASet = isSet(value2);
|
|
1432
|
-
if (isASet) {
|
|
1433
|
-
Object.setPrototypeOf(value2, proxySetProto);
|
|
1434
|
-
return true;
|
|
1435
|
-
}
|
|
1436
|
-
const isAMap = isMap(value2);
|
|
1437
|
-
if (isAMap) {
|
|
1438
|
-
Object.setPrototypeOf(value2, proxyMapProto);
|
|
1439
|
-
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);
|
|
1440
1481
|
}
|
|
1441
|
-
return
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
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);
|
|
1450
1507
|
}
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
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;
|
|
1456
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);
|
|
1457
1548
|
});
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
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
|
+
}
|
|
1473
1584
|
}
|
|
1474
|
-
if (
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
trigger2(newValue, eventSource);
|
|
1585
|
+
if (!isString(name2) || isNullOrWhitespace(name2)) {
|
|
1586
|
+
unmount(commentBegin, commentEnd);
|
|
1587
|
+
return;
|
|
1478
1588
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
};
|
|
1498
|
-
}
|
|
1499
|
-
case 1 /* trigger */: {
|
|
1500
|
-
const eventSource = args[1];
|
|
1501
|
-
const value2 = refObj._value;
|
|
1502
|
-
trigger2(value2, eventSource);
|
|
1503
|
-
break;
|
|
1504
|
-
}
|
|
1505
|
-
case 2 /* observerCount */: {
|
|
1506
|
-
return observers.size;
|
|
1507
|
-
}
|
|
1508
|
-
case 3 /* pause */: {
|
|
1509
|
-
refObj.auto = false;
|
|
1510
|
-
break;
|
|
1511
|
-
}
|
|
1512
|
-
case 4 /* resume */: {
|
|
1513
|
-
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();
|
|
1514
1607
|
}
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1608
|
+
stopObserverList.length = 0;
|
|
1609
|
+
};
|
|
1610
|
+
addUnbinder(commentBegin, unbinder);
|
|
1611
|
+
refresh();
|
|
1612
|
+
const stopObserving = observe(value, refresh);
|
|
1613
|
+
stopObserverList.push(stopObserving);
|
|
1614
|
+
}
|
|
1522
1615
|
};
|
|
1523
1616
|
|
|
1524
1617
|
// src/reactivity/unref.ts
|
|
@@ -2377,21 +2470,21 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
|
|
|
2377
2470
|
number: f1.number || f2.number,
|
|
2378
2471
|
trim: f1.trim || f2.trim
|
|
2379
2472
|
};
|
|
2380
|
-
|
|
2381
|
-
if (!modelRef) {
|
|
2473
|
+
if (!parseResult.refs[0]) {
|
|
2382
2474
|
warning(8 /* ModelRequiresRef */, el);
|
|
2383
2475
|
return () => {
|
|
2384
2476
|
};
|
|
2385
2477
|
}
|
|
2478
|
+
const getModelRef = () => parseResult.refs[0];
|
|
2386
2479
|
const isAnInput = isInput(el);
|
|
2387
2480
|
if (isAnInput && isCheckBox(el)) {
|
|
2388
|
-
return handleCheckBox(el,
|
|
2481
|
+
return handleCheckBox(el, getModelRef);
|
|
2389
2482
|
} else if (isAnInput && isRadio(el)) {
|
|
2390
|
-
return handleRadio(el,
|
|
2483
|
+
return handleRadio(el, getModelRef);
|
|
2391
2484
|
} else if (isAnInput || isTextArea(el)) {
|
|
2392
|
-
return handleInputAndTextArea(el, flags,
|
|
2485
|
+
return handleInputAndTextArea(el, flags, getModelRef, parsedValue);
|
|
2393
2486
|
} else if (isSelect(el)) {
|
|
2394
|
-
return handleSelect(el,
|
|
2487
|
+
return handleSelect(el, getModelRef, parsedValue);
|
|
2395
2488
|
} else {
|
|
2396
2489
|
warning(7 /* ModelNotSupportOnElement */, el);
|
|
2397
2490
|
return () => {
|
|
@@ -2399,7 +2492,7 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
|
|
|
2399
2492
|
}
|
|
2400
2493
|
};
|
|
2401
2494
|
var decimalSeparators = /[.,' ·٫]/;
|
|
2402
|
-
var handleInputAndTextArea = (el, flags,
|
|
2495
|
+
var handleInputAndTextArea = (el, flags, getModelRef, parsedValue) => {
|
|
2403
2496
|
const isLazy = flags.lazy;
|
|
2404
2497
|
const eventType = isLazy ? "change" : "input";
|
|
2405
2498
|
const isNumber = isNumberInput(el);
|
|
@@ -2426,6 +2519,8 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
2426
2519
|
el.removeEventListener("change", onCompositionEnd);
|
|
2427
2520
|
};
|
|
2428
2521
|
const listener = (event) => {
|
|
2522
|
+
const modelRef = getModelRef();
|
|
2523
|
+
if (!modelRef) return;
|
|
2429
2524
|
const target = event.target;
|
|
2430
2525
|
if (!target || target.composing) return;
|
|
2431
2526
|
let value = target.value;
|
|
@@ -2457,12 +2552,14 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
2457
2552
|
el.addEventListener("change", onCompositionEnd);
|
|
2458
2553
|
return unbinder;
|
|
2459
2554
|
};
|
|
2460
|
-
var handleCheckBox = (el,
|
|
2555
|
+
var handleCheckBox = (el, getModelRef) => {
|
|
2461
2556
|
const eventType = "change";
|
|
2462
2557
|
const unbinder = () => {
|
|
2463
2558
|
el.removeEventListener(eventType, listener);
|
|
2464
2559
|
};
|
|
2465
2560
|
const listener = () => {
|
|
2561
|
+
const modelRef = getModelRef();
|
|
2562
|
+
if (!modelRef) return;
|
|
2466
2563
|
const elementValue = getValue(el);
|
|
2467
2564
|
const checked = el.checked;
|
|
2468
2565
|
const modelValue = modelRef();
|
|
@@ -2513,24 +2610,28 @@ var getCheckboxChecked = (el, value) => {
|
|
|
2513
2610
|
return looseEqual(value, el.getAttribute(attrKey));
|
|
2514
2611
|
return looseEqual(value, true);
|
|
2515
2612
|
};
|
|
2516
|
-
var handleRadio = (el,
|
|
2613
|
+
var handleRadio = (el, getModelRef) => {
|
|
2517
2614
|
const eventType = "change";
|
|
2518
2615
|
const unbinder = () => {
|
|
2519
2616
|
el.removeEventListener(eventType, listener);
|
|
2520
2617
|
};
|
|
2521
2618
|
const listener = () => {
|
|
2619
|
+
const modelRef = getModelRef();
|
|
2620
|
+
if (!modelRef) return;
|
|
2522
2621
|
const elementValue = getValue(el);
|
|
2523
2622
|
modelRef(elementValue);
|
|
2524
2623
|
};
|
|
2525
2624
|
el.addEventListener(eventType, listener);
|
|
2526
2625
|
return unbinder;
|
|
2527
2626
|
};
|
|
2528
|
-
var handleSelect = (el,
|
|
2627
|
+
var handleSelect = (el, getModelRef, parsedValue) => {
|
|
2529
2628
|
const eventType = "change";
|
|
2530
2629
|
const unbinder = () => {
|
|
2531
2630
|
el.removeEventListener(eventType, listener);
|
|
2532
2631
|
};
|
|
2533
2632
|
const listener = () => {
|
|
2633
|
+
const modelRef = getModelRef();
|
|
2634
|
+
if (!modelRef) return;
|
|
2534
2635
|
const flags = getFlags(parsedValue()[1]);
|
|
2535
2636
|
const number = flags.number;
|
|
2536
2637
|
const selectedValue = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
@@ -2968,45 +3069,6 @@ var valueDirective = {
|
|
|
2968
3069
|
}
|
|
2969
3070
|
};
|
|
2970
3071
|
|
|
2971
|
-
// src/reactivity/isDeepRef.ts
|
|
2972
|
-
var isDeepRef = (value) => {
|
|
2973
|
-
return (value == null ? void 0 : value[refSymbol]) === 1;
|
|
2974
|
-
};
|
|
2975
|
-
|
|
2976
|
-
// src/reactivity/ref.ts
|
|
2977
|
-
var ref = (value) => {
|
|
2978
|
-
if (isRaw(value)) return value;
|
|
2979
|
-
let result;
|
|
2980
|
-
if (isRef(value)) {
|
|
2981
|
-
result = value;
|
|
2982
|
-
value = result();
|
|
2983
|
-
} else {
|
|
2984
|
-
result = sref(value);
|
|
2985
|
-
}
|
|
2986
|
-
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
2987
|
-
return result;
|
|
2988
|
-
result[refSymbol] = 1;
|
|
2989
|
-
if (isArray(value)) {
|
|
2990
|
-
const len = value.length;
|
|
2991
|
-
for (let i = 0; i < len; ++i) {
|
|
2992
|
-
const item = value[i];
|
|
2993
|
-
if (isDeepRef(item)) continue;
|
|
2994
|
-
value[i] = ref(item);
|
|
2995
|
-
}
|
|
2996
|
-
return result;
|
|
2997
|
-
}
|
|
2998
|
-
if (!isObject(value)) return result;
|
|
2999
|
-
for (const item of Object.entries(value)) {
|
|
3000
|
-
const val = item[1];
|
|
3001
|
-
if (isDeepRef(val)) continue;
|
|
3002
|
-
const key = item[0];
|
|
3003
|
-
if (isSymbol(key)) continue;
|
|
3004
|
-
value[key] = null;
|
|
3005
|
-
value[key] = ref(val);
|
|
3006
|
-
}
|
|
3007
|
-
return result;
|
|
3008
|
-
};
|
|
3009
|
-
|
|
3010
3072
|
// src/app/RegorConfig.ts
|
|
3011
3073
|
var _RegorConfig = class _RegorConfig {
|
|
3012
3074
|
constructor(globalContext) {
|
|
@@ -4798,8 +4860,8 @@ var Parser = class {
|
|
|
4798
4860
|
stopObserverList.push(stopObserving);
|
|
4799
4861
|
}
|
|
4800
4862
|
}
|
|
4801
|
-
value(evaluated.map((x) => x.value));
|
|
4802
4863
|
result.refs = evaluated.map((x) => x.ref);
|
|
4864
|
+
value(evaluated.map((x) => x.value));
|
|
4803
4865
|
};
|
|
4804
4866
|
refresh();
|
|
4805
4867
|
} catch (e) {
|