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.es2019.cjs.js
CHANGED
|
@@ -742,33 +742,6 @@ var propsOnceDirective = {
|
|
|
742
742
|
}
|
|
743
743
|
};
|
|
744
744
|
|
|
745
|
-
// src/directives/single-prop.ts
|
|
746
|
-
var singlePropDirective = {
|
|
747
|
-
collectRefObj: true,
|
|
748
|
-
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
749
|
-
if (!option) return () => {
|
|
750
|
-
};
|
|
751
|
-
const key = camelize(option);
|
|
752
|
-
const stopObserving = observe(
|
|
753
|
-
parseResult.value,
|
|
754
|
-
() => {
|
|
755
|
-
var _a;
|
|
756
|
-
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
757
|
-
const ctx = parseResult.context;
|
|
758
|
-
const ctxKey = ctx[option];
|
|
759
|
-
if (ctxKey === value) return;
|
|
760
|
-
if (isRef(ctxKey)) {
|
|
761
|
-
ctxKey(value);
|
|
762
|
-
} else {
|
|
763
|
-
ctx[key] = value;
|
|
764
|
-
}
|
|
765
|
-
},
|
|
766
|
-
true
|
|
767
|
-
);
|
|
768
|
-
return stopObserving;
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
|
-
|
|
772
745
|
// src/reactivity/entangle.ts
|
|
773
746
|
var entangle = (r1, r2) => {
|
|
774
747
|
if (r1 === r2) return () => {
|
|
@@ -782,182 +755,561 @@ var entangle = (r1, r2) => {
|
|
|
782
755
|
};
|
|
783
756
|
};
|
|
784
757
|
|
|
785
|
-
// src/
|
|
786
|
-
var
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
758
|
+
// src/misc/isRaw.ts
|
|
759
|
+
var isRaw = (value) => {
|
|
760
|
+
return !!value && value[rawSymbol] === 1;
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
// src/reactivity/isDeepRef.ts
|
|
764
|
+
var isDeepRef = (value) => {
|
|
765
|
+
return (value == null ? void 0 : value[refSymbol]) === 1;
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
// src/computed/watchEffect.ts
|
|
769
|
+
var collectedRefs = [];
|
|
770
|
+
var collectRef = (ref2) => {
|
|
771
|
+
var _a;
|
|
772
|
+
if (collectedRefs.length === 0) return;
|
|
773
|
+
(_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
|
|
774
|
+
};
|
|
775
|
+
var watchEffect = (effect) => {
|
|
776
|
+
if (!effect) return () => {
|
|
777
|
+
};
|
|
778
|
+
const terminator = { stop: () => {
|
|
779
|
+
} };
|
|
780
|
+
watchEffectInternal(effect, terminator);
|
|
781
|
+
onUnmounted(() => terminator.stop(), true);
|
|
782
|
+
return terminator.stop;
|
|
783
|
+
};
|
|
784
|
+
var watchEffectInternal = (effect, terminator) => {
|
|
785
|
+
if (!effect) return;
|
|
786
|
+
let stopObservingList = [];
|
|
787
|
+
let isStopped = false;
|
|
788
|
+
const stopWatch = () => {
|
|
789
|
+
for (const stop of stopObservingList) stop();
|
|
790
|
+
stopObservingList = [];
|
|
791
|
+
isStopped = true;
|
|
792
|
+
};
|
|
793
|
+
terminator.stop = stopWatch;
|
|
794
|
+
try {
|
|
795
|
+
const set = /* @__PURE__ */ new Set();
|
|
796
|
+
collectedRefs.push(set);
|
|
797
|
+
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
798
|
+
if (isStopped) return;
|
|
799
|
+
for (const r of [...set]) {
|
|
800
|
+
const stopObserving = observe(r, () => {
|
|
801
|
+
stopWatch();
|
|
802
|
+
watchEffect(effect);
|
|
803
|
+
});
|
|
804
|
+
stopObservingList.push(stopObserving);
|
|
805
|
+
}
|
|
806
|
+
} finally {
|
|
807
|
+
collectedRefs.pop();
|
|
792
808
|
}
|
|
793
|
-
|
|
794
|
-
|
|
809
|
+
};
|
|
810
|
+
var silence = (action) => {
|
|
811
|
+
const len = collectedRefs.length;
|
|
812
|
+
const hasPush = len > 0 && collectedRefs[len - 1];
|
|
813
|
+
try {
|
|
814
|
+
if (hasPush) collectedRefs.push(null);
|
|
815
|
+
return action();
|
|
816
|
+
} finally {
|
|
817
|
+
if (hasPush) collectedRefs.pop();
|
|
795
818
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
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
|
-
|
|
819
|
+
};
|
|
820
|
+
var collectRefs = (action) => {
|
|
821
|
+
try {
|
|
822
|
+
const set = /* @__PURE__ */ new Set();
|
|
823
|
+
collectedRefs.push(set);
|
|
824
|
+
const result = action();
|
|
825
|
+
return { value: result, refs: [...set] };
|
|
826
|
+
} finally {
|
|
827
|
+
collectedRefs.pop();
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
// src/reactivity/trigger.ts
|
|
832
|
+
var trigger = (source, eventSource, isRecursive) => {
|
|
833
|
+
if (!isRef(source)) return;
|
|
834
|
+
const srefImpl = source;
|
|
835
|
+
srefImpl(void 0, eventSource, 1 /* trigger */);
|
|
836
|
+
if (!isRecursive) return;
|
|
837
|
+
const obj = srefImpl();
|
|
838
|
+
if (!obj) return;
|
|
839
|
+
if (isArray(obj) || isSet(obj)) {
|
|
840
|
+
for (const el of obj) {
|
|
841
|
+
trigger(el, eventSource, true);
|
|
842
|
+
}
|
|
843
|
+
} else if (isMap(obj)) {
|
|
844
|
+
for (const el of obj) {
|
|
845
|
+
trigger(el[0], eventSource, true);
|
|
846
|
+
trigger(el[1], eventSource, true);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
if (isObject(obj)) {
|
|
850
|
+
for (const k in obj) {
|
|
851
|
+
trigger(obj[k], eventSource, true);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
// src/proxies/proxy.ts
|
|
857
|
+
function define(obj, key, val) {
|
|
858
|
+
Object.defineProperty(obj, key, {
|
|
859
|
+
value: val,
|
|
860
|
+
enumerable: false,
|
|
861
|
+
writable: true,
|
|
862
|
+
configurable: true
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
var createProxy = (originalProto, proxyProto, methodsToPatch4) => {
|
|
866
|
+
methodsToPatch4.forEach(function(method) {
|
|
867
|
+
const original = originalProto[method];
|
|
868
|
+
define(proxyProto, method, function mutator(...args) {
|
|
869
|
+
const result = original.apply(this, args);
|
|
870
|
+
const subscribers = this[srefSymbol];
|
|
871
|
+
for (const subscriber of subscribers) trigger(subscriber);
|
|
872
|
+
return result;
|
|
873
|
+
});
|
|
874
|
+
});
|
|
875
|
+
};
|
|
876
|
+
var setToStringTag = (proxyProto, tag) => {
|
|
877
|
+
Object.defineProperty(proxyProto, Symbol.toStringTag, {
|
|
878
|
+
value: tag,
|
|
879
|
+
writable: false,
|
|
880
|
+
enumerable: false,
|
|
881
|
+
configurable: true
|
|
882
|
+
});
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
// src/proxies/array-ref.ts
|
|
886
|
+
var arrayProto = Array.prototype;
|
|
887
|
+
var proxyArrayProto = Object.create(arrayProto);
|
|
888
|
+
var methodsToPatch = [
|
|
889
|
+
"push",
|
|
890
|
+
"pop",
|
|
891
|
+
"shift",
|
|
892
|
+
"unshift",
|
|
893
|
+
"splice",
|
|
894
|
+
"sort",
|
|
895
|
+
"reverse"
|
|
896
|
+
];
|
|
897
|
+
createProxy(arrayProto, proxyArrayProto, methodsToPatch);
|
|
898
|
+
|
|
899
|
+
// src/proxies/map-ref.ts
|
|
900
|
+
var mapProto = Map.prototype;
|
|
901
|
+
var proxyMapProto = Object.create(mapProto);
|
|
902
|
+
var methodsToPatch2 = ["set", "clear", "delete"];
|
|
903
|
+
setToStringTag(proxyMapProto, "Map");
|
|
904
|
+
createProxy(mapProto, proxyMapProto, methodsToPatch2);
|
|
905
|
+
|
|
906
|
+
// src/proxies/set-ref.ts
|
|
907
|
+
var setProto = Set.prototype;
|
|
908
|
+
var proxySetProto = Object.create(setProto);
|
|
909
|
+
var methodsToPatch3 = ["add", "clear", "delete"];
|
|
910
|
+
setToStringTag(proxySetProto, "Set");
|
|
911
|
+
createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
912
|
+
|
|
913
|
+
// src/reactivity/sref.ts
|
|
914
|
+
var batchCollector = {};
|
|
915
|
+
var sref = (value) => {
|
|
916
|
+
if (isRef(value) || isRaw(value)) return value;
|
|
917
|
+
const refObj = {
|
|
918
|
+
auto: true,
|
|
919
|
+
_value: value
|
|
920
|
+
};
|
|
921
|
+
const createProxy2 = (value2) => {
|
|
922
|
+
if (!isObject(value2)) return false;
|
|
923
|
+
if (srefSymbol in value2) return true;
|
|
924
|
+
const isAnArray = isArray(value2);
|
|
925
|
+
if (isAnArray) {
|
|
926
|
+
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
929
|
+
const isASet = isSet(value2);
|
|
930
|
+
if (isASet) {
|
|
931
|
+
Object.setPrototypeOf(value2, proxySetProto);
|
|
932
|
+
return true;
|
|
933
|
+
}
|
|
934
|
+
const isAMap = isMap(value2);
|
|
935
|
+
if (isAMap) {
|
|
936
|
+
Object.setPrototypeOf(value2, proxyMapProto);
|
|
937
|
+
return true;
|
|
938
|
+
}
|
|
939
|
+
return false;
|
|
940
|
+
};
|
|
941
|
+
const isProxy = createProxy2(value);
|
|
942
|
+
const observers = /* @__PURE__ */ new Set();
|
|
943
|
+
const trigger2 = (newValue, eventSource) => {
|
|
944
|
+
if (batchCollector.stack && batchCollector.stack.length) {
|
|
945
|
+
const current = batchCollector.stack[batchCollector.stack.length - 1];
|
|
946
|
+
current.add(srefFunction);
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
if (observers.size === 0) return;
|
|
950
|
+
silence(() => {
|
|
951
|
+
for (const callback of [...observers.keys()]) {
|
|
952
|
+
if (!observers.has(callback)) continue;
|
|
953
|
+
callback(newValue, eventSource);
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
};
|
|
957
|
+
const attachProxyHandle = (value2) => {
|
|
958
|
+
let proxyHandle = value2[srefSymbol];
|
|
959
|
+
if (!proxyHandle) value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
960
|
+
proxyHandle.add(srefFunction);
|
|
961
|
+
};
|
|
962
|
+
const srefFunction = (...args) => {
|
|
963
|
+
if (!(2 in args)) {
|
|
964
|
+
let newValue = args[0];
|
|
965
|
+
const eventSource = args[1];
|
|
966
|
+
if (0 in args) {
|
|
967
|
+
if (refObj._value === newValue) return newValue;
|
|
968
|
+
if (isRef(newValue)) {
|
|
969
|
+
newValue = newValue();
|
|
970
|
+
if (refObj._value === newValue) return newValue;
|
|
971
|
+
}
|
|
972
|
+
if (createProxy2(newValue)) attachProxyHandle(newValue);
|
|
973
|
+
refObj._value = newValue;
|
|
974
|
+
if (refObj.auto) {
|
|
975
|
+
trigger2(newValue, eventSource);
|
|
976
|
+
}
|
|
977
|
+
return refObj._value;
|
|
978
|
+
} else {
|
|
979
|
+
collectRef(srefFunction);
|
|
980
|
+
}
|
|
981
|
+
return refObj._value;
|
|
982
|
+
}
|
|
983
|
+
const operation = args[2];
|
|
984
|
+
switch (operation) {
|
|
985
|
+
case 0 /* observe */: {
|
|
986
|
+
const observer = args[3];
|
|
987
|
+
if (!observer) return () => {
|
|
988
|
+
};
|
|
989
|
+
const removeObserver = (observer2) => {
|
|
990
|
+
observers.delete(observer2);
|
|
991
|
+
};
|
|
992
|
+
observers.add(observer);
|
|
993
|
+
return () => {
|
|
994
|
+
removeObserver(observer);
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
case 1 /* trigger */: {
|
|
998
|
+
const eventSource = args[1];
|
|
999
|
+
const value2 = refObj._value;
|
|
1000
|
+
trigger2(value2, eventSource);
|
|
1001
|
+
break;
|
|
1002
|
+
}
|
|
1003
|
+
case 2 /* observerCount */: {
|
|
1004
|
+
return observers.size;
|
|
1005
|
+
}
|
|
1006
|
+
case 3 /* pause */: {
|
|
1007
|
+
refObj.auto = false;
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
case 4 /* resume */: {
|
|
1011
|
+
refObj.auto = true;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
return refObj._value;
|
|
1015
|
+
};
|
|
1016
|
+
srefFunction[srefSymbol] = 1;
|
|
1017
|
+
defineRefValue(srefFunction, false);
|
|
1018
|
+
if (isProxy) attachProxyHandle(value);
|
|
1019
|
+
return srefFunction;
|
|
1020
|
+
};
|
|
1021
|
+
|
|
1022
|
+
// src/reactivity/ref.ts
|
|
1023
|
+
var ref = (value) => {
|
|
1024
|
+
if (isRaw(value)) return value;
|
|
1025
|
+
let result;
|
|
1026
|
+
if (isRef(value)) {
|
|
1027
|
+
result = value;
|
|
1028
|
+
value = result();
|
|
1029
|
+
} else {
|
|
1030
|
+
result = sref(value);
|
|
1031
|
+
}
|
|
1032
|
+
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
1033
|
+
return result;
|
|
1034
|
+
result[refSymbol] = 1;
|
|
1035
|
+
if (isArray(value)) {
|
|
1036
|
+
const len = value.length;
|
|
1037
|
+
for (let i = 0; i < len; ++i) {
|
|
1038
|
+
const item = value[i];
|
|
1039
|
+
if (isDeepRef(item)) continue;
|
|
1040
|
+
value[i] = ref(item);
|
|
1041
|
+
}
|
|
1042
|
+
return result;
|
|
1043
|
+
}
|
|
1044
|
+
if (!isObject(value)) return result;
|
|
1045
|
+
for (const item of Object.entries(value)) {
|
|
1046
|
+
const val = item[1];
|
|
1047
|
+
if (isDeepRef(val)) continue;
|
|
1048
|
+
const key = item[0];
|
|
1049
|
+
if (isSymbol(key)) continue;
|
|
1050
|
+
value[key] = null;
|
|
1051
|
+
value[key] = ref(val);
|
|
1052
|
+
}
|
|
1053
|
+
return result;
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
// src/directives/single-prop.ts
|
|
1057
|
+
var modelBridgeSymbol = Symbol("modelBridge");
|
|
1058
|
+
var isModelBridge = (value) => !!(value == null ? void 0 : value[modelBridgeSymbol]);
|
|
1059
|
+
var markModelBridge = (value) => {
|
|
1060
|
+
;
|
|
1061
|
+
value[modelBridgeSymbol] = 1;
|
|
1062
|
+
};
|
|
1063
|
+
var createModelBridge = (source) => {
|
|
1064
|
+
const bridge = ref(source());
|
|
1065
|
+
markModelBridge(bridge);
|
|
1066
|
+
return bridge;
|
|
1067
|
+
};
|
|
1068
|
+
var singlePropDirective = {
|
|
1069
|
+
collectRefObj: true,
|
|
1070
|
+
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
1071
|
+
if (!option) return () => {
|
|
1072
|
+
};
|
|
1073
|
+
const key = camelize(option);
|
|
1074
|
+
let currentSource;
|
|
1075
|
+
let bridge;
|
|
1076
|
+
let stopEntangle = () => {
|
|
1077
|
+
};
|
|
1078
|
+
const resetSync = () => {
|
|
1079
|
+
stopEntangle();
|
|
1080
|
+
stopEntangle = () => {
|
|
1081
|
+
};
|
|
1082
|
+
currentSource = void 0;
|
|
1083
|
+
bridge = void 0;
|
|
1084
|
+
};
|
|
1085
|
+
const clearEntangle = () => {
|
|
1086
|
+
stopEntangle();
|
|
1087
|
+
stopEntangle = () => {
|
|
1088
|
+
};
|
|
1089
|
+
};
|
|
1090
|
+
const syncRefs = (source, target) => {
|
|
1091
|
+
if (currentSource === source) return;
|
|
1092
|
+
clearEntangle();
|
|
1093
|
+
stopEntangle = entangle(source, target);
|
|
1094
|
+
currentSource = source;
|
|
1095
|
+
};
|
|
1096
|
+
const stopObserving = observe(
|
|
1097
|
+
parseResult.value,
|
|
1098
|
+
() => {
|
|
1099
|
+
var _a;
|
|
1100
|
+
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
1101
|
+
const ctx = parseResult.context;
|
|
1102
|
+
const ctxKey = ctx[key];
|
|
1103
|
+
if (!isRef(value)) {
|
|
1104
|
+
if (bridge && ctxKey === bridge) {
|
|
1105
|
+
bridge(value);
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
resetSync();
|
|
1109
|
+
if (isRef(ctxKey)) {
|
|
1110
|
+
ctxKey(value);
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
ctx[key] = value;
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
if (isModelBridge(value)) {
|
|
1117
|
+
if (isRef(ctxKey)) {
|
|
1118
|
+
syncRefs(value, ctxKey);
|
|
1119
|
+
} else {
|
|
1120
|
+
ctx[key] = value;
|
|
1121
|
+
}
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
if (!bridge) bridge = createModelBridge(value);
|
|
1125
|
+
ctx[key] = bridge;
|
|
1126
|
+
syncRefs(value, bridge);
|
|
1127
|
+
},
|
|
1128
|
+
true
|
|
1129
|
+
);
|
|
1130
|
+
return () => {
|
|
1131
|
+
stopEntangle();
|
|
1132
|
+
stopObserving();
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
// src/bind/ComponentBinder.ts
|
|
1138
|
+
var ComponentBinder = class {
|
|
1139
|
+
constructor(binder) {
|
|
1140
|
+
__publicField(this, "__binder");
|
|
1141
|
+
__publicField(this, "__inherit");
|
|
1142
|
+
this.__binder = binder;
|
|
1143
|
+
this.__inherit = binder.__config.__builtInNames.inherit;
|
|
1144
|
+
}
|
|
1145
|
+
__bindAll(element) {
|
|
1146
|
+
this.__unwrapComponents(element);
|
|
1147
|
+
}
|
|
1148
|
+
__unwrapComponents(element) {
|
|
1149
|
+
var _a;
|
|
1150
|
+
const binder = this.__binder;
|
|
1151
|
+
const parser = binder.__parser;
|
|
1152
|
+
const registeredComponents = binder.__config.__components;
|
|
1153
|
+
const registeredComponentsUpperCase = binder.__config.__componentsUpperCase;
|
|
1154
|
+
const contextComponents = parser.__getComponents();
|
|
1155
|
+
const contextComponentSelectors = parser.__getComponentSelectors();
|
|
1156
|
+
const selector = [
|
|
1157
|
+
...registeredComponents.keys(),
|
|
1158
|
+
...contextComponentSelectors,
|
|
1159
|
+
...[...registeredComponents.keys()].map(hyphenate),
|
|
1160
|
+
...contextComponentSelectors.map(hyphenate)
|
|
1161
|
+
].join(",");
|
|
1162
|
+
if (isNullOrWhitespace(selector)) return;
|
|
1163
|
+
const list = element.querySelectorAll(selector);
|
|
1164
|
+
const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
|
|
1165
|
+
for (const component of components) {
|
|
1166
|
+
if (component.hasAttribute(binder.__pre)) continue;
|
|
1167
|
+
const parent = component.parentNode;
|
|
1168
|
+
if (!parent) continue;
|
|
1169
|
+
const nextSibling = component.nextSibling;
|
|
1170
|
+
const tagName = camelize(component.tagName).toUpperCase();
|
|
1171
|
+
const contextComponent = contextComponents[tagName];
|
|
1172
|
+
const registeredComponent = contextComponent != null ? contextComponent : registeredComponentsUpperCase.get(tagName);
|
|
1173
|
+
if (!registeredComponent) continue;
|
|
1174
|
+
const templateElement = registeredComponent.template;
|
|
1175
|
+
if (!templateElement) continue;
|
|
1176
|
+
const componentParent = component.parentElement;
|
|
1177
|
+
if (!componentParent) continue;
|
|
1178
|
+
const startOfComponent = new Comment(
|
|
1179
|
+
" begin component: " + component.tagName
|
|
1180
|
+
);
|
|
1181
|
+
const endOfComponent = new Comment(" end component: " + component.tagName);
|
|
1182
|
+
componentParent.insertBefore(startOfComponent, component);
|
|
1183
|
+
component.remove();
|
|
1184
|
+
const propsName = binder.__config.__builtInNames.props;
|
|
1185
|
+
const propsOnceName = binder.__config.__builtInNames.propsOnce;
|
|
1186
|
+
const bindName = binder.__config.__builtInNames.bind;
|
|
1187
|
+
const getProps = (component2, capturedContext2) => {
|
|
1188
|
+
const props = {};
|
|
1189
|
+
const hasProps = component2.hasAttribute(propsName);
|
|
1190
|
+
const hasPropsOnce = component2.hasAttribute(propsOnceName);
|
|
1191
|
+
parser.__scoped(capturedContext2, () => {
|
|
1192
|
+
parser.__push(props);
|
|
1193
|
+
if (hasProps) binder.__bind(propsDirective, component2, propsName);
|
|
1194
|
+
if (hasPropsOnce)
|
|
1195
|
+
binder.__bind(propsOnceDirective, component2, propsOnceName);
|
|
1196
|
+
let definedProps = registeredComponent.props;
|
|
1197
|
+
if (!definedProps || definedProps.length === 0) return;
|
|
1198
|
+
definedProps = definedProps.map(camelize);
|
|
1199
|
+
const definedPropsByLowerCase = new Map(
|
|
1200
|
+
definedProps.map((definedProp) => [
|
|
1201
|
+
definedProp.toLowerCase(),
|
|
1202
|
+
definedProp
|
|
1203
|
+
])
|
|
1204
|
+
);
|
|
1205
|
+
for (const name2 of definedProps.concat(definedProps.map(hyphenate))) {
|
|
1206
|
+
const value = component2.getAttribute(name2);
|
|
1207
|
+
if (value === null) continue;
|
|
1208
|
+
props[camelize(name2)] = value;
|
|
1209
|
+
component2.removeAttribute(name2);
|
|
1210
|
+
}
|
|
1211
|
+
const map = binder.__directiveCollector.__collect(component2, false);
|
|
1212
|
+
for (const [attrName, item] of map.entries()) {
|
|
1213
|
+
const [name2, option] = item.__terms;
|
|
1214
|
+
if (!option) continue;
|
|
1215
|
+
const propName = definedPropsByLowerCase.get(
|
|
1216
|
+
camelize(option).toLowerCase()
|
|
1217
|
+
);
|
|
1218
|
+
if (!propName) continue;
|
|
1219
|
+
if (name2 !== "." && name2 !== ":" && name2 !== bindName) continue;
|
|
1220
|
+
binder.__bind(
|
|
1221
|
+
singlePropDirective,
|
|
1222
|
+
component2,
|
|
1223
|
+
attrName,
|
|
1224
|
+
true,
|
|
1225
|
+
propName,
|
|
1226
|
+
item.__flags
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
return props;
|
|
1231
|
+
};
|
|
1232
|
+
const capturedContext = [...parser.__capture()];
|
|
1233
|
+
const createComponentCtx = () => {
|
|
1234
|
+
var _a2;
|
|
1235
|
+
const props = getProps(component, capturedContext);
|
|
1236
|
+
const head2 = new ComponentHead(
|
|
1237
|
+
props,
|
|
1238
|
+
component,
|
|
1239
|
+
capturedContext,
|
|
1240
|
+
startOfComponent,
|
|
1241
|
+
endOfComponent
|
|
1242
|
+
);
|
|
1243
|
+
const componentCtx2 = useScope(() => {
|
|
1244
|
+
var _a3;
|
|
1245
|
+
return (_a3 = registeredComponent.context(head2)) != null ? _a3 : {};
|
|
1246
|
+
}).context;
|
|
1247
|
+
if (head2.autoProps) {
|
|
1248
|
+
for (const [key, propsValue] of Object.entries(props)) {
|
|
1249
|
+
if (key in componentCtx2) {
|
|
1250
|
+
const compValue = componentCtx2[key];
|
|
1251
|
+
if (compValue === propsValue) continue;
|
|
1252
|
+
if (head2.entangle && isRef(compValue) && isRef(propsValue)) {
|
|
1253
|
+
addUnbinder(startOfComponent, entangle(propsValue, compValue));
|
|
1254
|
+
}
|
|
1255
|
+
} else componentCtx2[key] = propsValue;
|
|
1256
|
+
}
|
|
1257
|
+
(_a2 = head2.onAutoPropsAssigned) == null ? void 0 : _a2.call(head2);
|
|
1258
|
+
}
|
|
1259
|
+
return { componentCtx: componentCtx2, head: head2 };
|
|
1260
|
+
};
|
|
1261
|
+
const { componentCtx, head } = createComponentCtx();
|
|
1262
|
+
const childNodes = [...getChildNodes(templateElement)];
|
|
1263
|
+
const len = childNodes.length;
|
|
1264
|
+
const isEmptyComponent = component.childNodes.length === 0;
|
|
1265
|
+
const expandSlot = (slot) => {
|
|
1266
|
+
const parent2 = slot.parentElement;
|
|
1267
|
+
if (isEmptyComponent) {
|
|
1268
|
+
for (const slotChild of [...slot.childNodes]) {
|
|
1269
|
+
parent2.insertBefore(slotChild, slot);
|
|
1270
|
+
}
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
let name2 = slot.name;
|
|
1274
|
+
if (isNullOrWhitespace(name2)) {
|
|
1275
|
+
name2 = slot.getAttributeNames().filter((x) => x.startsWith("#"))[0];
|
|
1276
|
+
if (isNullOrWhitespace(name2)) {
|
|
1277
|
+
name2 = "default";
|
|
1278
|
+
} else name2 = name2.substring(1);
|
|
1279
|
+
}
|
|
1280
|
+
let compTemplate = component.querySelector(
|
|
1281
|
+
`template[name='${name2}'], template[\\#${name2}]`
|
|
1282
|
+
);
|
|
1283
|
+
if (!compTemplate && name2 === "default") {
|
|
1284
|
+
compTemplate = component.querySelector("template:not([name])");
|
|
1285
|
+
if (compTemplate && compTemplate.getAttributeNames().filter((x) => x.startsWith("#")).length > 0)
|
|
1286
|
+
compTemplate = null;
|
|
1287
|
+
}
|
|
1288
|
+
const createSwitchContext = (childNodes2) => {
|
|
1289
|
+
if (!head.enableSwitch) return;
|
|
1290
|
+
parser.__scoped(capturedContext, () => {
|
|
1291
|
+
parser.__push(componentCtx);
|
|
1292
|
+
const props = getProps(slot, parser.__capture());
|
|
1293
|
+
parser.__scoped(capturedContext, () => {
|
|
1294
|
+
parser.__push(props);
|
|
1295
|
+
const switchContext = parser.__capture();
|
|
1296
|
+
const id = addSwitch(switchContext);
|
|
1297
|
+
for (const child of childNodes2) {
|
|
1298
|
+
if (!isElement(child)) continue;
|
|
1299
|
+
child.setAttribute(rswitch, id);
|
|
1300
|
+
refSwitch(id);
|
|
1301
|
+
addUnbinder(child, () => {
|
|
1302
|
+
removeSwitch(id);
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
});
|
|
1307
|
+
};
|
|
1308
|
+
if (compTemplate) {
|
|
1309
|
+
const childNodes2 = [...getChildNodes(compTemplate)];
|
|
1310
|
+
for (const slotChild of childNodes2) {
|
|
1311
|
+
parent2.insertBefore(slotChild, slot);
|
|
1312
|
+
}
|
|
961
1313
|
createSwitchContext(childNodes2);
|
|
962
1314
|
} else {
|
|
963
1315
|
if (name2 !== "default") {
|
|
@@ -1024,484 +1376,225 @@ var ComponentBinder = class {
|
|
|
1024
1376
|
normalizeAttributeName(attrName, binder.__config),
|
|
1025
1377
|
value
|
|
1026
1378
|
);
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
};
|
|
1030
|
-
const clearUnusedAttributes = () => {
|
|
1031
|
-
for (const attrName of component.getAttributeNames()) {
|
|
1032
|
-
if (!attrName.startsWith("@") && !attrName.startsWith(binder.__config.__builtInNames.on))
|
|
1033
|
-
component.removeAttribute(attrName);
|
|
1034
|
-
}
|
|
1035
|
-
};
|
|
1036
|
-
const bindComponent = () => {
|
|
1037
|
-
transferAttributesToTheComponentChild();
|
|
1038
|
-
clearUnusedAttributes();
|
|
1039
|
-
parser.__push(componentCtx);
|
|
1040
|
-
binder.__bindAttributes(component, false);
|
|
1041
|
-
componentCtx.$emit = head.emit;
|
|
1042
|
-
bindChildNodes(binder, childNodes);
|
|
1043
|
-
addUnbinder(component, () => {
|
|
1044
|
-
callUnmounted(componentCtx);
|
|
1045
|
-
});
|
|
1046
|
-
addUnbinder(startOfComponent, () => {
|
|
1047
|
-
unbind(component);
|
|
1048
|
-
});
|
|
1049
|
-
callMounted(componentCtx);
|
|
1050
|
-
};
|
|
1051
|
-
parser.__scoped(capturedContext, bindComponent);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
};
|
|
1055
|
-
|
|
1056
|
-
// src/bind/DirectiveCollector.ts
|
|
1057
|
-
var DirectiveElement = class {
|
|
1058
|
-
constructor(name2) {
|
|
1059
|
-
__publicField(this, "__name");
|
|
1060
|
-
// 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
|
|
1061
|
-
/** Contains: `['@', 'submit'], ['r-on', 'click'], ['\\@', '[dynamicKey]']` */
|
|
1062
|
-
__publicField(this, "__terms", []);
|
|
1063
|
-
/** Contains directive flags. ['camel', 'prevent',...] */
|
|
1064
|
-
__publicField(this, "__flags", []);
|
|
1065
|
-
__publicField(this, "__elements", []);
|
|
1066
|
-
this.__name = name2;
|
|
1067
|
-
this.__parse();
|
|
1068
|
-
}
|
|
1069
|
-
__parse() {
|
|
1070
|
-
let name2 = this.__name;
|
|
1071
|
-
const isPropShortcut = name2.startsWith(".");
|
|
1072
|
-
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1073
|
-
const firstFlagIndex = name2.indexOf(".");
|
|
1074
|
-
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1075
|
-
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1076
|
-
if (firstFlagIndex >= 0) {
|
|
1077
|
-
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1078
|
-
if (flags.includes("camel")) {
|
|
1079
|
-
const index = terms.length - 1;
|
|
1080
|
-
terms[index] = camelize(terms[index]);
|
|
1081
|
-
}
|
|
1082
|
-
if (flags.includes("prop")) {
|
|
1083
|
-
terms[0] = ".";
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
var DirectiveCollector = class {
|
|
1089
|
-
constructor(binder) {
|
|
1090
|
-
__publicField(this, "__binder");
|
|
1091
|
-
__publicField(this, "__prefixes");
|
|
1092
|
-
this.__binder = binder;
|
|
1093
|
-
this.__prefixes = binder.__config.__getPrefixes();
|
|
1094
|
-
}
|
|
1095
|
-
__collect(element, isRecursive) {
|
|
1096
|
-
const map = /* @__PURE__ */ new Map();
|
|
1097
|
-
if (!isHTMLElement(element)) return map;
|
|
1098
|
-
const prefixes2 = this.__prefixes;
|
|
1099
|
-
const processNode = (node) => {
|
|
1100
|
-
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1101
|
-
for (const name2 of names) {
|
|
1102
|
-
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1103
|
-
const item = map.get(name2);
|
|
1104
|
-
item.__elements.push(node);
|
|
1105
|
-
}
|
|
1106
|
-
};
|
|
1107
|
-
processNode(element);
|
|
1108
|
-
if (!isRecursive) return map;
|
|
1109
|
-
const nodes = element.querySelectorAll("*");
|
|
1110
|
-
for (const node of nodes) {
|
|
1111
|
-
processNode(node);
|
|
1112
|
-
}
|
|
1113
|
-
return map;
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1116
|
-
|
|
1117
|
-
// src/bind/DynamicBinder.ts
|
|
1118
|
-
var mount2 = (nodes, parent) => {
|
|
1119
|
-
for (const x of nodes) {
|
|
1120
|
-
const node = x.cloneNode(true);
|
|
1121
|
-
parent.appendChild(node);
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
var DynamicBinder = class {
|
|
1125
|
-
constructor(binder) {
|
|
1126
|
-
__publicField(this, "__binder");
|
|
1127
|
-
__publicField(this, "__is");
|
|
1128
|
-
__publicField(this, "__isSelector");
|
|
1129
|
-
this.__binder = binder;
|
|
1130
|
-
this.__is = binder.__config.__builtInNames.is;
|
|
1131
|
-
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1132
|
-
}
|
|
1133
|
-
__bindAll(element) {
|
|
1134
|
-
const isComponentElement = element.hasAttribute(this.__is);
|
|
1135
|
-
const elements = findElements(element, this.__isSelector);
|
|
1136
|
-
for (const el of elements) {
|
|
1137
|
-
this.__bind(el);
|
|
1138
|
-
}
|
|
1139
|
-
return isComponentElement;
|
|
1140
|
-
}
|
|
1141
|
-
__bind(el) {
|
|
1142
|
-
let expression = el.getAttribute(this.__is);
|
|
1143
|
-
if (!expression) {
|
|
1144
|
-
expression = el.getAttribute("is");
|
|
1145
|
-
if (!expression) return;
|
|
1146
|
-
if (!expression.startsWith("regor:")) {
|
|
1147
|
-
if (!expression.startsWith("r-")) return;
|
|
1148
|
-
const staticName = expression.slice(2).trim().toLowerCase();
|
|
1149
|
-
if (!staticName) return;
|
|
1150
|
-
const parent = el.parentNode;
|
|
1151
|
-
if (!parent) return;
|
|
1152
|
-
const nativeElement = document.createElement(staticName);
|
|
1153
|
-
for (const attr of el.getAttributeNames()) {
|
|
1154
|
-
if (attr === "is") continue;
|
|
1155
|
-
nativeElement.setAttribute(attr, el.getAttribute(attr));
|
|
1156
|
-
}
|
|
1157
|
-
while (el.firstChild) nativeElement.appendChild(el.firstChild);
|
|
1158
|
-
parent.insertBefore(nativeElement, el);
|
|
1159
|
-
el.remove();
|
|
1160
|
-
this.__binder.__bindDefault(nativeElement);
|
|
1161
|
-
return;
|
|
1162
|
-
}
|
|
1163
|
-
expression = `'${expression.slice(6)}'`;
|
|
1164
|
-
el.removeAttribute("is");
|
|
1165
|
-
}
|
|
1166
|
-
el.removeAttribute(this.__is);
|
|
1167
|
-
this.__bindToExpression(el, expression);
|
|
1168
|
-
}
|
|
1169
|
-
__createRegion(el, expression) {
|
|
1170
|
-
const nodes = getNodes(el);
|
|
1171
|
-
const parent = el.parentNode;
|
|
1172
|
-
const commentBegin = document.createComment(
|
|
1173
|
-
`__begin__ dynamic ${expression != null ? expression : ""}`
|
|
1174
|
-
);
|
|
1175
|
-
parent.insertBefore(commentBegin, el);
|
|
1176
|
-
setSwitchOwner(commentBegin, nodes);
|
|
1177
|
-
nodes.forEach((x) => {
|
|
1178
|
-
removeNode(x);
|
|
1179
|
-
});
|
|
1180
|
-
el.remove();
|
|
1181
|
-
const commentEnd = document.createComment(
|
|
1182
|
-
`__end__ dynamic ${expression != null ? expression : ""}`
|
|
1183
|
-
);
|
|
1184
|
-
parent.insertBefore(commentEnd, commentBegin.nextSibling);
|
|
1185
|
-
return {
|
|
1186
|
-
nodes,
|
|
1187
|
-
parent,
|
|
1188
|
-
commentBegin,
|
|
1189
|
-
commentEnd
|
|
1190
|
-
};
|
|
1191
|
-
}
|
|
1192
|
-
__bindToExpression(el, expression) {
|
|
1193
|
-
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
1194
|
-
el,
|
|
1195
|
-
` => ${expression} `
|
|
1196
|
-
);
|
|
1197
|
-
const parseResult = this.__binder.__parser.__parse(expression);
|
|
1198
|
-
const value = parseResult.value;
|
|
1199
|
-
const parser = this.__binder.__parser;
|
|
1200
|
-
const capturedContext = parser.__capture();
|
|
1201
|
-
const mounted = { name: "" };
|
|
1202
|
-
const componentChildNodes = isTemplate(el) ? nodes : [...nodes[0].childNodes];
|
|
1203
|
-
const refresh = () => {
|
|
1204
|
-
parser.__scoped(capturedContext, () => {
|
|
1205
|
-
var _a;
|
|
1206
|
-
let name2 = value()[0];
|
|
1207
|
-
if (isObject(name2)) {
|
|
1208
|
-
if (!name2.name) {
|
|
1209
|
-
name2 = (_a = Object.entries(parser.__getComponents()).filter(
|
|
1210
|
-
(x) => x[1] === name2
|
|
1211
|
-
)[0]) == null ? void 0 : _a[0];
|
|
1212
|
-
} else {
|
|
1213
|
-
name2 = name2.name;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
if (!isString(name2) || isNullOrWhitespace(name2)) {
|
|
1217
|
-
unmount(commentBegin, commentEnd);
|
|
1218
|
-
return;
|
|
1379
|
+
}
|
|
1219
1380
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
const
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1381
|
+
};
|
|
1382
|
+
const clearUnusedAttributes = () => {
|
|
1383
|
+
for (const attrName of component.getAttributeNames()) {
|
|
1384
|
+
if (!attrName.startsWith("@") && !attrName.startsWith(binder.__config.__builtInNames.on))
|
|
1385
|
+
component.removeAttribute(attrName);
|
|
1226
1386
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
stopObserverList.push(stopObserving);
|
|
1245
|
-
}
|
|
1246
|
-
};
|
|
1247
|
-
|
|
1248
|
-
// src/computed/watchEffect.ts
|
|
1249
|
-
var collectedRefs = [];
|
|
1250
|
-
var collectRef = (ref2) => {
|
|
1251
|
-
var _a;
|
|
1252
|
-
if (collectedRefs.length === 0) return;
|
|
1253
|
-
(_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
|
|
1254
|
-
};
|
|
1255
|
-
var watchEffect = (effect) => {
|
|
1256
|
-
if (!effect) return () => {
|
|
1257
|
-
};
|
|
1258
|
-
const terminator = { stop: () => {
|
|
1259
|
-
} };
|
|
1260
|
-
watchEffectInternal(effect, terminator);
|
|
1261
|
-
onUnmounted(() => terminator.stop(), true);
|
|
1262
|
-
return terminator.stop;
|
|
1263
|
-
};
|
|
1264
|
-
var watchEffectInternal = (effect, terminator) => {
|
|
1265
|
-
if (!effect) return;
|
|
1266
|
-
let stopObservingList = [];
|
|
1267
|
-
let isStopped = false;
|
|
1268
|
-
const stopWatch = () => {
|
|
1269
|
-
for (const stop of stopObservingList) stop();
|
|
1270
|
-
stopObservingList = [];
|
|
1271
|
-
isStopped = true;
|
|
1272
|
-
};
|
|
1273
|
-
terminator.stop = stopWatch;
|
|
1274
|
-
try {
|
|
1275
|
-
const set = /* @__PURE__ */ new Set();
|
|
1276
|
-
collectedRefs.push(set);
|
|
1277
|
-
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
1278
|
-
if (isStopped) return;
|
|
1279
|
-
for (const r of [...set]) {
|
|
1280
|
-
const stopObserving = observe(r, () => {
|
|
1281
|
-
stopWatch();
|
|
1282
|
-
watchEffect(effect);
|
|
1283
|
-
});
|
|
1284
|
-
stopObservingList.push(stopObserving);
|
|
1387
|
+
};
|
|
1388
|
+
const bindComponent = () => {
|
|
1389
|
+
transferAttributesToTheComponentChild();
|
|
1390
|
+
clearUnusedAttributes();
|
|
1391
|
+
parser.__push(componentCtx);
|
|
1392
|
+
binder.__bindAttributes(component, false);
|
|
1393
|
+
componentCtx.$emit = head.emit;
|
|
1394
|
+
bindChildNodes(binder, childNodes);
|
|
1395
|
+
addUnbinder(component, () => {
|
|
1396
|
+
callUnmounted(componentCtx);
|
|
1397
|
+
});
|
|
1398
|
+
addUnbinder(startOfComponent, () => {
|
|
1399
|
+
unbind(component);
|
|
1400
|
+
});
|
|
1401
|
+
callMounted(componentCtx);
|
|
1402
|
+
};
|
|
1403
|
+
parser.__scoped(capturedContext, bindComponent);
|
|
1285
1404
|
}
|
|
1286
|
-
} finally {
|
|
1287
|
-
collectedRefs.pop();
|
|
1288
|
-
}
|
|
1289
|
-
};
|
|
1290
|
-
var silence = (action) => {
|
|
1291
|
-
const len = collectedRefs.length;
|
|
1292
|
-
const hasPush = len > 0 && collectedRefs[len - 1];
|
|
1293
|
-
try {
|
|
1294
|
-
if (hasPush) collectedRefs.push(null);
|
|
1295
|
-
return action();
|
|
1296
|
-
} finally {
|
|
1297
|
-
if (hasPush) collectedRefs.pop();
|
|
1298
|
-
}
|
|
1299
|
-
};
|
|
1300
|
-
var collectRefs = (action) => {
|
|
1301
|
-
try {
|
|
1302
|
-
const set = /* @__PURE__ */ new Set();
|
|
1303
|
-
collectedRefs.push(set);
|
|
1304
|
-
const result = action();
|
|
1305
|
-
return { value: result, refs: [...set] };
|
|
1306
|
-
} finally {
|
|
1307
|
-
collectedRefs.pop();
|
|
1308
1405
|
}
|
|
1309
1406
|
};
|
|
1310
1407
|
|
|
1311
|
-
// src/
|
|
1312
|
-
var
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
if (!obj) return;
|
|
1324
|
-
if (isArray(obj) || isSet(obj)) {
|
|
1325
|
-
for (const el of obj) {
|
|
1326
|
-
trigger(el, eventSource, true);
|
|
1327
|
-
}
|
|
1328
|
-
} else if (isMap(obj)) {
|
|
1329
|
-
for (const el of obj) {
|
|
1330
|
-
trigger(el[0], eventSource, true);
|
|
1331
|
-
trigger(el[1], eventSource, true);
|
|
1332
|
-
}
|
|
1408
|
+
// src/bind/DirectiveCollector.ts
|
|
1409
|
+
var DirectiveElement = class {
|
|
1410
|
+
constructor(name2) {
|
|
1411
|
+
__publicField(this, "__name");
|
|
1412
|
+
// 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
|
|
1413
|
+
/** Contains: `['@', 'submit'], ['r-on', 'click'], ['\\@', '[dynamicKey]']` */
|
|
1414
|
+
__publicField(this, "__terms", []);
|
|
1415
|
+
/** Contains directive flags. ['camel', 'prevent',...] */
|
|
1416
|
+
__publicField(this, "__flags", []);
|
|
1417
|
+
__publicField(this, "__elements", []);
|
|
1418
|
+
this.__name = name2;
|
|
1419
|
+
this.__parse();
|
|
1333
1420
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1421
|
+
__parse() {
|
|
1422
|
+
let name2 = this.__name;
|
|
1423
|
+
const isPropShortcut = name2.startsWith(".");
|
|
1424
|
+
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1425
|
+
const firstFlagIndex = name2.indexOf(".");
|
|
1426
|
+
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1427
|
+
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1428
|
+
if (firstFlagIndex >= 0) {
|
|
1429
|
+
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1430
|
+
if (flags.includes("camel")) {
|
|
1431
|
+
const index = terms.length - 1;
|
|
1432
|
+
terms[index] = camelize(terms[index]);
|
|
1433
|
+
}
|
|
1434
|
+
if (flags.includes("prop")) {
|
|
1435
|
+
terms[0] = ".";
|
|
1436
|
+
}
|
|
1337
1437
|
}
|
|
1338
1438
|
}
|
|
1339
1439
|
};
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
writable: false,
|
|
1365
|
-
enumerable: false,
|
|
1366
|
-
configurable: true
|
|
1367
|
-
});
|
|
1368
|
-
};
|
|
1369
|
-
|
|
1370
|
-
// src/proxies/array-ref.ts
|
|
1371
|
-
var arrayProto = Array.prototype;
|
|
1372
|
-
var proxyArrayProto = Object.create(arrayProto);
|
|
1373
|
-
var methodsToPatch = [
|
|
1374
|
-
"push",
|
|
1375
|
-
"pop",
|
|
1376
|
-
"shift",
|
|
1377
|
-
"unshift",
|
|
1378
|
-
"splice",
|
|
1379
|
-
"sort",
|
|
1380
|
-
"reverse"
|
|
1381
|
-
];
|
|
1382
|
-
createProxy(arrayProto, proxyArrayProto, methodsToPatch);
|
|
1383
|
-
|
|
1384
|
-
// src/proxies/map-ref.ts
|
|
1385
|
-
var mapProto = Map.prototype;
|
|
1386
|
-
var proxyMapProto = Object.create(mapProto);
|
|
1387
|
-
var methodsToPatch2 = ["set", "clear", "delete"];
|
|
1388
|
-
setToStringTag(proxyMapProto, "Map");
|
|
1389
|
-
createProxy(mapProto, proxyMapProto, methodsToPatch2);
|
|
1390
|
-
|
|
1391
|
-
// src/proxies/set-ref.ts
|
|
1392
|
-
var setProto = Set.prototype;
|
|
1393
|
-
var proxySetProto = Object.create(setProto);
|
|
1394
|
-
var methodsToPatch3 = ["add", "clear", "delete"];
|
|
1395
|
-
setToStringTag(proxySetProto, "Set");
|
|
1396
|
-
createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
1397
|
-
|
|
1398
|
-
// src/reactivity/sref.ts
|
|
1399
|
-
var batchCollector = {};
|
|
1400
|
-
var sref = (value) => {
|
|
1401
|
-
if (isRef(value) || isRaw(value)) return value;
|
|
1402
|
-
const refObj = {
|
|
1403
|
-
auto: true,
|
|
1404
|
-
_value: value
|
|
1405
|
-
};
|
|
1406
|
-
const createProxy2 = (value2) => {
|
|
1407
|
-
if (!isObject(value2)) return false;
|
|
1408
|
-
if (srefSymbol in value2) return true;
|
|
1409
|
-
const isAnArray = isArray(value2);
|
|
1410
|
-
if (isAnArray) {
|
|
1411
|
-
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
1412
|
-
return true;
|
|
1413
|
-
}
|
|
1414
|
-
const isASet = isSet(value2);
|
|
1415
|
-
if (isASet) {
|
|
1416
|
-
Object.setPrototypeOf(value2, proxySetProto);
|
|
1417
|
-
return true;
|
|
1418
|
-
}
|
|
1419
|
-
const isAMap = isMap(value2);
|
|
1420
|
-
if (isAMap) {
|
|
1421
|
-
Object.setPrototypeOf(value2, proxyMapProto);
|
|
1422
|
-
return true;
|
|
1440
|
+
var DirectiveCollector = class {
|
|
1441
|
+
constructor(binder) {
|
|
1442
|
+
__publicField(this, "__binder");
|
|
1443
|
+
__publicField(this, "__prefixes");
|
|
1444
|
+
this.__binder = binder;
|
|
1445
|
+
this.__prefixes = binder.__config.__getPrefixes();
|
|
1446
|
+
}
|
|
1447
|
+
__collect(element, isRecursive) {
|
|
1448
|
+
const map = /* @__PURE__ */ new Map();
|
|
1449
|
+
if (!isHTMLElement(element)) return map;
|
|
1450
|
+
const prefixes2 = this.__prefixes;
|
|
1451
|
+
const processNode = (node) => {
|
|
1452
|
+
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1453
|
+
for (const name2 of names) {
|
|
1454
|
+
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1455
|
+
const item = map.get(name2);
|
|
1456
|
+
item.__elements.push(node);
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
processNode(element);
|
|
1460
|
+
if (!isRecursive) return map;
|
|
1461
|
+
const nodes = element.querySelectorAll("*");
|
|
1462
|
+
for (const node of nodes) {
|
|
1463
|
+
processNode(node);
|
|
1423
1464
|
}
|
|
1424
|
-
return
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1465
|
+
return map;
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
|
|
1469
|
+
// src/bind/DynamicBinder.ts
|
|
1470
|
+
var mount2 = (nodes, parent) => {
|
|
1471
|
+
for (const x of nodes) {
|
|
1472
|
+
const node = x.cloneNode(true);
|
|
1473
|
+
parent.appendChild(node);
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
var DynamicBinder = class {
|
|
1477
|
+
constructor(binder) {
|
|
1478
|
+
__publicField(this, "__binder");
|
|
1479
|
+
__publicField(this, "__is");
|
|
1480
|
+
__publicField(this, "__isSelector");
|
|
1481
|
+
this.__binder = binder;
|
|
1482
|
+
this.__is = binder.__config.__builtInNames.is;
|
|
1483
|
+
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1484
|
+
}
|
|
1485
|
+
__bindAll(element) {
|
|
1486
|
+
const isComponentElement = element.hasAttribute(this.__is);
|
|
1487
|
+
const elements = findElements(element, this.__isSelector);
|
|
1488
|
+
for (const el of elements) {
|
|
1489
|
+
this.__bind(el);
|
|
1433
1490
|
}
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1491
|
+
return isComponentElement;
|
|
1492
|
+
}
|
|
1493
|
+
__bind(el) {
|
|
1494
|
+
let expression = el.getAttribute(this.__is);
|
|
1495
|
+
if (!expression) {
|
|
1496
|
+
expression = el.getAttribute("is");
|
|
1497
|
+
if (!expression) return;
|
|
1498
|
+
if (!expression.startsWith("regor:")) {
|
|
1499
|
+
if (!expression.startsWith("r-")) return;
|
|
1500
|
+
const staticName = expression.slice(2).trim().toLowerCase();
|
|
1501
|
+
if (!staticName) return;
|
|
1502
|
+
const parent = el.parentNode;
|
|
1503
|
+
if (!parent) return;
|
|
1504
|
+
const nativeElement = document.createElement(staticName);
|
|
1505
|
+
for (const attr of el.getAttributeNames()) {
|
|
1506
|
+
if (attr === "is") continue;
|
|
1507
|
+
nativeElement.setAttribute(attr, el.getAttribute(attr));
|
|
1508
|
+
}
|
|
1509
|
+
while (el.firstChild) nativeElement.appendChild(el.firstChild);
|
|
1510
|
+
parent.insertBefore(nativeElement, el);
|
|
1511
|
+
el.remove();
|
|
1512
|
+
this.__binder.__bindDefault(nativeElement);
|
|
1513
|
+
return;
|
|
1439
1514
|
}
|
|
1515
|
+
expression = `'${expression.slice(6)}'`;
|
|
1516
|
+
el.removeAttribute("is");
|
|
1517
|
+
}
|
|
1518
|
+
el.removeAttribute(this.__is);
|
|
1519
|
+
this.__bindToExpression(el, expression);
|
|
1520
|
+
}
|
|
1521
|
+
__createRegion(el, expression) {
|
|
1522
|
+
const nodes = getNodes(el);
|
|
1523
|
+
const parent = el.parentNode;
|
|
1524
|
+
const commentBegin = document.createComment(
|
|
1525
|
+
`__begin__ dynamic ${expression != null ? expression : ""}`
|
|
1526
|
+
);
|
|
1527
|
+
parent.insertBefore(commentBegin, el);
|
|
1528
|
+
setSwitchOwner(commentBegin, nodes);
|
|
1529
|
+
nodes.forEach((x) => {
|
|
1530
|
+
removeNode(x);
|
|
1440
1531
|
});
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1532
|
+
el.remove();
|
|
1533
|
+
const commentEnd = document.createComment(
|
|
1534
|
+
`__end__ dynamic ${expression != null ? expression : ""}`
|
|
1535
|
+
);
|
|
1536
|
+
parent.insertBefore(commentEnd, commentBegin.nextSibling);
|
|
1537
|
+
return {
|
|
1538
|
+
nodes,
|
|
1539
|
+
parent,
|
|
1540
|
+
commentBegin,
|
|
1541
|
+
commentEnd
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
__bindToExpression(el, expression) {
|
|
1545
|
+
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
1546
|
+
el,
|
|
1547
|
+
` => ${expression} `
|
|
1548
|
+
);
|
|
1549
|
+
const parseResult = this.__binder.__parser.__parse(expression);
|
|
1550
|
+
const value = parseResult.value;
|
|
1551
|
+
const parser = this.__binder.__parser;
|
|
1552
|
+
const capturedContext = parser.__capture();
|
|
1553
|
+
const mounted = { name: "" };
|
|
1554
|
+
const componentChildNodes = isTemplate(el) ? nodes : [...nodes[0].childNodes];
|
|
1555
|
+
const refresh = () => {
|
|
1556
|
+
parser.__scoped(capturedContext, () => {
|
|
1557
|
+
var _a;
|
|
1558
|
+
let name2 = value()[0];
|
|
1559
|
+
if (isObject(name2)) {
|
|
1560
|
+
if (!name2.name) {
|
|
1561
|
+
name2 = (_a = Object.entries(parser.__getComponents()).filter(
|
|
1562
|
+
(x) => x[1] === name2
|
|
1563
|
+
)[0]) == null ? void 0 : _a[0];
|
|
1564
|
+
} else {
|
|
1565
|
+
name2 = name2.name;
|
|
1566
|
+
}
|
|
1456
1567
|
}
|
|
1457
|
-
if (
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
trigger2(newValue, eventSource);
|
|
1568
|
+
if (!isString(name2) || isNullOrWhitespace(name2)) {
|
|
1569
|
+
unmount(commentBegin, commentEnd);
|
|
1570
|
+
return;
|
|
1461
1571
|
}
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
};
|
|
1481
|
-
}
|
|
1482
|
-
case 1 /* trigger */: {
|
|
1483
|
-
const eventSource = args[1];
|
|
1484
|
-
const value2 = refObj._value;
|
|
1485
|
-
trigger2(value2, eventSource);
|
|
1486
|
-
break;
|
|
1487
|
-
}
|
|
1488
|
-
case 2 /* observerCount */: {
|
|
1489
|
-
return observers.size;
|
|
1490
|
-
}
|
|
1491
|
-
case 3 /* pause */: {
|
|
1492
|
-
refObj.auto = false;
|
|
1493
|
-
break;
|
|
1494
|
-
}
|
|
1495
|
-
case 4 /* resume */: {
|
|
1496
|
-
refObj.auto = true;
|
|
1572
|
+
if (mounted.name === name2) return;
|
|
1573
|
+
unmount(commentBegin, commentEnd);
|
|
1574
|
+
const componentElement = document.createElement(name2);
|
|
1575
|
+
for (const attr of el.getAttributeNames()) {
|
|
1576
|
+
if (attr === this.__is) continue;
|
|
1577
|
+
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1578
|
+
}
|
|
1579
|
+
mount2(componentChildNodes, componentElement);
|
|
1580
|
+
parent.insertBefore(componentElement, commentEnd);
|
|
1581
|
+
this.__binder.__bindDefault(componentElement);
|
|
1582
|
+
mounted.name = name2;
|
|
1583
|
+
});
|
|
1584
|
+
};
|
|
1585
|
+
const stopObserverList = [];
|
|
1586
|
+
const unbinder = () => {
|
|
1587
|
+
parseResult.stop();
|
|
1588
|
+
for (const stopObserver of stopObserverList) {
|
|
1589
|
+
stopObserver();
|
|
1497
1590
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1591
|
+
stopObserverList.length = 0;
|
|
1592
|
+
};
|
|
1593
|
+
addUnbinder(commentBegin, unbinder);
|
|
1594
|
+
refresh();
|
|
1595
|
+
const stopObserving = observe(value, refresh);
|
|
1596
|
+
stopObserverList.push(stopObserving);
|
|
1597
|
+
}
|
|
1505
1598
|
};
|
|
1506
1599
|
|
|
1507
1600
|
// src/reactivity/unref.ts
|
|
@@ -2360,21 +2453,21 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
|
|
|
2360
2453
|
number: f1.number || f2.number,
|
|
2361
2454
|
trim: f1.trim || f2.trim
|
|
2362
2455
|
};
|
|
2363
|
-
|
|
2364
|
-
if (!modelRef) {
|
|
2456
|
+
if (!parseResult.refs[0]) {
|
|
2365
2457
|
warning(8 /* ModelRequiresRef */, el);
|
|
2366
2458
|
return () => {
|
|
2367
2459
|
};
|
|
2368
2460
|
}
|
|
2461
|
+
const getModelRef = () => parseResult.refs[0];
|
|
2369
2462
|
const isAnInput = isInput(el);
|
|
2370
2463
|
if (isAnInput && isCheckBox(el)) {
|
|
2371
|
-
return handleCheckBox(el,
|
|
2464
|
+
return handleCheckBox(el, getModelRef);
|
|
2372
2465
|
} else if (isAnInput && isRadio(el)) {
|
|
2373
|
-
return handleRadio(el,
|
|
2466
|
+
return handleRadio(el, getModelRef);
|
|
2374
2467
|
} else if (isAnInput || isTextArea(el)) {
|
|
2375
|
-
return handleInputAndTextArea(el, flags,
|
|
2468
|
+
return handleInputAndTextArea(el, flags, getModelRef, parsedValue);
|
|
2376
2469
|
} else if (isSelect(el)) {
|
|
2377
|
-
return handleSelect(el,
|
|
2470
|
+
return handleSelect(el, getModelRef, parsedValue);
|
|
2378
2471
|
} else {
|
|
2379
2472
|
warning(7 /* ModelNotSupportOnElement */, el);
|
|
2380
2473
|
return () => {
|
|
@@ -2382,7 +2475,7 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
|
|
|
2382
2475
|
}
|
|
2383
2476
|
};
|
|
2384
2477
|
var decimalSeparators = /[.,' ·٫]/;
|
|
2385
|
-
var handleInputAndTextArea = (el, flags,
|
|
2478
|
+
var handleInputAndTextArea = (el, flags, getModelRef, parsedValue) => {
|
|
2386
2479
|
const isLazy = flags.lazy;
|
|
2387
2480
|
const eventType = isLazy ? "change" : "input";
|
|
2388
2481
|
const isNumber = isNumberInput(el);
|
|
@@ -2409,6 +2502,8 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
2409
2502
|
el.removeEventListener("change", onCompositionEnd);
|
|
2410
2503
|
};
|
|
2411
2504
|
const listener = (event) => {
|
|
2505
|
+
const modelRef = getModelRef();
|
|
2506
|
+
if (!modelRef) return;
|
|
2412
2507
|
const target = event.target;
|
|
2413
2508
|
if (!target || target.composing) return;
|
|
2414
2509
|
let value = target.value;
|
|
@@ -2440,12 +2535,14 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
2440
2535
|
el.addEventListener("change", onCompositionEnd);
|
|
2441
2536
|
return unbinder;
|
|
2442
2537
|
};
|
|
2443
|
-
var handleCheckBox = (el,
|
|
2538
|
+
var handleCheckBox = (el, getModelRef) => {
|
|
2444
2539
|
const eventType = "change";
|
|
2445
2540
|
const unbinder = () => {
|
|
2446
2541
|
el.removeEventListener(eventType, listener);
|
|
2447
2542
|
};
|
|
2448
2543
|
const listener = () => {
|
|
2544
|
+
const modelRef = getModelRef();
|
|
2545
|
+
if (!modelRef) return;
|
|
2449
2546
|
const elementValue = getValue(el);
|
|
2450
2547
|
const checked = el.checked;
|
|
2451
2548
|
const modelValue = modelRef();
|
|
@@ -2496,24 +2593,28 @@ var getCheckboxChecked = (el, value) => {
|
|
|
2496
2593
|
return looseEqual(value, el.getAttribute(attrKey));
|
|
2497
2594
|
return looseEqual(value, true);
|
|
2498
2595
|
};
|
|
2499
|
-
var handleRadio = (el,
|
|
2596
|
+
var handleRadio = (el, getModelRef) => {
|
|
2500
2597
|
const eventType = "change";
|
|
2501
2598
|
const unbinder = () => {
|
|
2502
2599
|
el.removeEventListener(eventType, listener);
|
|
2503
2600
|
};
|
|
2504
2601
|
const listener = () => {
|
|
2602
|
+
const modelRef = getModelRef();
|
|
2603
|
+
if (!modelRef) return;
|
|
2505
2604
|
const elementValue = getValue(el);
|
|
2506
2605
|
modelRef(elementValue);
|
|
2507
2606
|
};
|
|
2508
2607
|
el.addEventListener(eventType, listener);
|
|
2509
2608
|
return unbinder;
|
|
2510
2609
|
};
|
|
2511
|
-
var handleSelect = (el,
|
|
2610
|
+
var handleSelect = (el, getModelRef, parsedValue) => {
|
|
2512
2611
|
const eventType = "change";
|
|
2513
2612
|
const unbinder = () => {
|
|
2514
2613
|
el.removeEventListener(eventType, listener);
|
|
2515
2614
|
};
|
|
2516
2615
|
const listener = () => {
|
|
2616
|
+
const modelRef = getModelRef();
|
|
2617
|
+
if (!modelRef) return;
|
|
2517
2618
|
const flags = getFlags(parsedValue()[1]);
|
|
2518
2619
|
const number = flags.number;
|
|
2519
2620
|
const selectedValue = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
@@ -2951,45 +3052,6 @@ var valueDirective = {
|
|
|
2951
3052
|
}
|
|
2952
3053
|
};
|
|
2953
3054
|
|
|
2954
|
-
// src/reactivity/isDeepRef.ts
|
|
2955
|
-
var isDeepRef = (value) => {
|
|
2956
|
-
return (value == null ? void 0 : value[refSymbol]) === 1;
|
|
2957
|
-
};
|
|
2958
|
-
|
|
2959
|
-
// src/reactivity/ref.ts
|
|
2960
|
-
var ref = (value) => {
|
|
2961
|
-
if (isRaw(value)) return value;
|
|
2962
|
-
let result;
|
|
2963
|
-
if (isRef(value)) {
|
|
2964
|
-
result = value;
|
|
2965
|
-
value = result();
|
|
2966
|
-
} else {
|
|
2967
|
-
result = sref(value);
|
|
2968
|
-
}
|
|
2969
|
-
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
2970
|
-
return result;
|
|
2971
|
-
result[refSymbol] = 1;
|
|
2972
|
-
if (isArray(value)) {
|
|
2973
|
-
const len = value.length;
|
|
2974
|
-
for (let i = 0; i < len; ++i) {
|
|
2975
|
-
const item = value[i];
|
|
2976
|
-
if (isDeepRef(item)) continue;
|
|
2977
|
-
value[i] = ref(item);
|
|
2978
|
-
}
|
|
2979
|
-
return result;
|
|
2980
|
-
}
|
|
2981
|
-
if (!isObject(value)) return result;
|
|
2982
|
-
for (const item of Object.entries(value)) {
|
|
2983
|
-
const val = item[1];
|
|
2984
|
-
if (isDeepRef(val)) continue;
|
|
2985
|
-
const key = item[0];
|
|
2986
|
-
if (isSymbol(key)) continue;
|
|
2987
|
-
value[key] = null;
|
|
2988
|
-
value[key] = ref(val);
|
|
2989
|
-
}
|
|
2990
|
-
return result;
|
|
2991
|
-
};
|
|
2992
|
-
|
|
2993
3055
|
// src/app/RegorConfig.ts
|
|
2994
3056
|
var _RegorConfig = class _RegorConfig {
|
|
2995
3057
|
constructor(globalContext) {
|
|
@@ -4781,8 +4843,8 @@ var Parser = class {
|
|
|
4781
4843
|
stopObserverList.push(stopObserving);
|
|
4782
4844
|
}
|
|
4783
4845
|
}
|
|
4784
|
-
value(evaluated.map((x) => x.value));
|
|
4785
4846
|
result.refs = evaluated.map((x) => x.ref);
|
|
4847
|
+
value(evaluated.map((x) => x.value));
|
|
4786
4848
|
};
|
|
4787
4849
|
refresh();
|
|
4788
4850
|
} catch (e) {
|