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.esm.js
CHANGED
|
@@ -696,33 +696,6 @@ var propsOnceDirective = {
|
|
|
696
696
|
}
|
|
697
697
|
};
|
|
698
698
|
|
|
699
|
-
// src/directives/single-prop.ts
|
|
700
|
-
var singlePropDirective = {
|
|
701
|
-
collectRefObj: true,
|
|
702
|
-
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
703
|
-
if (!option) return () => {
|
|
704
|
-
};
|
|
705
|
-
const key = camelize(option);
|
|
706
|
-
const stopObserving = observe(
|
|
707
|
-
parseResult.value,
|
|
708
|
-
() => {
|
|
709
|
-
var _a;
|
|
710
|
-
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
711
|
-
const ctx = parseResult.context;
|
|
712
|
-
const ctxKey = ctx[option];
|
|
713
|
-
if (ctxKey === value) return;
|
|
714
|
-
if (isRef(ctxKey)) {
|
|
715
|
-
ctxKey(value);
|
|
716
|
-
} else {
|
|
717
|
-
ctx[key] = value;
|
|
718
|
-
}
|
|
719
|
-
},
|
|
720
|
-
true
|
|
721
|
-
);
|
|
722
|
-
return stopObserving;
|
|
723
|
-
}
|
|
724
|
-
};
|
|
725
|
-
|
|
726
699
|
// src/reactivity/entangle.ts
|
|
727
700
|
var entangle = (r1, r2) => {
|
|
728
701
|
if (r1 === r2) return () => {
|
|
@@ -736,182 +709,561 @@ var entangle = (r1, r2) => {
|
|
|
736
709
|
};
|
|
737
710
|
};
|
|
738
711
|
|
|
739
|
-
// src/
|
|
740
|
-
var
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
712
|
+
// src/misc/isRaw.ts
|
|
713
|
+
var isRaw = (value) => {
|
|
714
|
+
return !!value && value[rawSymbol] === 1;
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
// src/reactivity/isDeepRef.ts
|
|
718
|
+
var isDeepRef = (value) => {
|
|
719
|
+
return (value == null ? void 0 : value[refSymbol]) === 1;
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
// src/computed/watchEffect.ts
|
|
723
|
+
var collectedRefs = [];
|
|
724
|
+
var collectRef = (ref2) => {
|
|
725
|
+
var _a;
|
|
726
|
+
if (collectedRefs.length === 0) return;
|
|
727
|
+
(_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
|
|
728
|
+
};
|
|
729
|
+
var watchEffect = (effect) => {
|
|
730
|
+
if (!effect) return () => {
|
|
731
|
+
};
|
|
732
|
+
const terminator = { stop: () => {
|
|
733
|
+
} };
|
|
734
|
+
watchEffectInternal(effect, terminator);
|
|
735
|
+
onUnmounted(() => terminator.stop(), true);
|
|
736
|
+
return terminator.stop;
|
|
737
|
+
};
|
|
738
|
+
var watchEffectInternal = (effect, terminator) => {
|
|
739
|
+
if (!effect) return;
|
|
740
|
+
let stopObservingList = [];
|
|
741
|
+
let isStopped = false;
|
|
742
|
+
const stopWatch = () => {
|
|
743
|
+
for (const stop of stopObservingList) stop();
|
|
744
|
+
stopObservingList = [];
|
|
745
|
+
isStopped = true;
|
|
746
|
+
};
|
|
747
|
+
terminator.stop = stopWatch;
|
|
748
|
+
try {
|
|
749
|
+
const set = /* @__PURE__ */ new Set();
|
|
750
|
+
collectedRefs.push(set);
|
|
751
|
+
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
752
|
+
if (isStopped) return;
|
|
753
|
+
for (const r of [...set]) {
|
|
754
|
+
const stopObserving = observe(r, () => {
|
|
755
|
+
stopWatch();
|
|
756
|
+
watchEffect(effect);
|
|
757
|
+
});
|
|
758
|
+
stopObservingList.push(stopObserving);
|
|
759
|
+
}
|
|
760
|
+
} finally {
|
|
761
|
+
collectedRefs.pop();
|
|
746
762
|
}
|
|
747
|
-
|
|
748
|
-
|
|
763
|
+
};
|
|
764
|
+
var silence = (action) => {
|
|
765
|
+
const len = collectedRefs.length;
|
|
766
|
+
const hasPush = len > 0 && collectedRefs[len - 1];
|
|
767
|
+
try {
|
|
768
|
+
if (hasPush) collectedRefs.push(null);
|
|
769
|
+
return action();
|
|
770
|
+
} finally {
|
|
771
|
+
if (hasPush) collectedRefs.pop();
|
|
749
772
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
const
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
);
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
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
|
-
|
|
773
|
+
};
|
|
774
|
+
var collectRefs = (action) => {
|
|
775
|
+
try {
|
|
776
|
+
const set = /* @__PURE__ */ new Set();
|
|
777
|
+
collectedRefs.push(set);
|
|
778
|
+
const result = action();
|
|
779
|
+
return { value: result, refs: [...set] };
|
|
780
|
+
} finally {
|
|
781
|
+
collectedRefs.pop();
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
// src/reactivity/trigger.ts
|
|
786
|
+
var trigger = (source, eventSource, isRecursive) => {
|
|
787
|
+
if (!isRef(source)) return;
|
|
788
|
+
const srefImpl = source;
|
|
789
|
+
srefImpl(void 0, eventSource, 1 /* trigger */);
|
|
790
|
+
if (!isRecursive) return;
|
|
791
|
+
const obj = srefImpl();
|
|
792
|
+
if (!obj) return;
|
|
793
|
+
if (isArray(obj) || isSet(obj)) {
|
|
794
|
+
for (const el of obj) {
|
|
795
|
+
trigger(el, eventSource, true);
|
|
796
|
+
}
|
|
797
|
+
} else if (isMap(obj)) {
|
|
798
|
+
for (const el of obj) {
|
|
799
|
+
trigger(el[0], eventSource, true);
|
|
800
|
+
trigger(el[1], eventSource, true);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
if (isObject(obj)) {
|
|
804
|
+
for (const k in obj) {
|
|
805
|
+
trigger(obj[k], eventSource, true);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
// src/proxies/proxy.ts
|
|
811
|
+
function define(obj, key, val) {
|
|
812
|
+
Object.defineProperty(obj, key, {
|
|
813
|
+
value: val,
|
|
814
|
+
enumerable: false,
|
|
815
|
+
writable: true,
|
|
816
|
+
configurable: true
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
var createProxy = (originalProto, proxyProto, methodsToPatch4) => {
|
|
820
|
+
methodsToPatch4.forEach(function(method) {
|
|
821
|
+
const original = originalProto[method];
|
|
822
|
+
define(proxyProto, method, function mutator(...args) {
|
|
823
|
+
const result = original.apply(this, args);
|
|
824
|
+
const subscribers = this[srefSymbol];
|
|
825
|
+
for (const subscriber of subscribers) trigger(subscriber);
|
|
826
|
+
return result;
|
|
827
|
+
});
|
|
828
|
+
});
|
|
829
|
+
};
|
|
830
|
+
var setToStringTag = (proxyProto, tag) => {
|
|
831
|
+
Object.defineProperty(proxyProto, Symbol.toStringTag, {
|
|
832
|
+
value: tag,
|
|
833
|
+
writable: false,
|
|
834
|
+
enumerable: false,
|
|
835
|
+
configurable: true
|
|
836
|
+
});
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
// src/proxies/array-ref.ts
|
|
840
|
+
var arrayProto = Array.prototype;
|
|
841
|
+
var proxyArrayProto = Object.create(arrayProto);
|
|
842
|
+
var methodsToPatch = [
|
|
843
|
+
"push",
|
|
844
|
+
"pop",
|
|
845
|
+
"shift",
|
|
846
|
+
"unshift",
|
|
847
|
+
"splice",
|
|
848
|
+
"sort",
|
|
849
|
+
"reverse"
|
|
850
|
+
];
|
|
851
|
+
createProxy(arrayProto, proxyArrayProto, methodsToPatch);
|
|
852
|
+
|
|
853
|
+
// src/proxies/map-ref.ts
|
|
854
|
+
var mapProto = Map.prototype;
|
|
855
|
+
var proxyMapProto = Object.create(mapProto);
|
|
856
|
+
var methodsToPatch2 = ["set", "clear", "delete"];
|
|
857
|
+
setToStringTag(proxyMapProto, "Map");
|
|
858
|
+
createProxy(mapProto, proxyMapProto, methodsToPatch2);
|
|
859
|
+
|
|
860
|
+
// src/proxies/set-ref.ts
|
|
861
|
+
var setProto = Set.prototype;
|
|
862
|
+
var proxySetProto = Object.create(setProto);
|
|
863
|
+
var methodsToPatch3 = ["add", "clear", "delete"];
|
|
864
|
+
setToStringTag(proxySetProto, "Set");
|
|
865
|
+
createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
866
|
+
|
|
867
|
+
// src/reactivity/sref.ts
|
|
868
|
+
var batchCollector = {};
|
|
869
|
+
var sref = (value) => {
|
|
870
|
+
if (isRef(value) || isRaw(value)) return value;
|
|
871
|
+
const refObj = {
|
|
872
|
+
auto: true,
|
|
873
|
+
_value: value
|
|
874
|
+
};
|
|
875
|
+
const createProxy2 = (value2) => {
|
|
876
|
+
if (!isObject(value2)) return false;
|
|
877
|
+
if (srefSymbol in value2) return true;
|
|
878
|
+
const isAnArray = isArray(value2);
|
|
879
|
+
if (isAnArray) {
|
|
880
|
+
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
881
|
+
return true;
|
|
882
|
+
}
|
|
883
|
+
const isASet = isSet(value2);
|
|
884
|
+
if (isASet) {
|
|
885
|
+
Object.setPrototypeOf(value2, proxySetProto);
|
|
886
|
+
return true;
|
|
887
|
+
}
|
|
888
|
+
const isAMap = isMap(value2);
|
|
889
|
+
if (isAMap) {
|
|
890
|
+
Object.setPrototypeOf(value2, proxyMapProto);
|
|
891
|
+
return true;
|
|
892
|
+
}
|
|
893
|
+
return false;
|
|
894
|
+
};
|
|
895
|
+
const isProxy = createProxy2(value);
|
|
896
|
+
const observers = /* @__PURE__ */ new Set();
|
|
897
|
+
const trigger2 = (newValue, eventSource) => {
|
|
898
|
+
if (batchCollector.stack && batchCollector.stack.length) {
|
|
899
|
+
const current = batchCollector.stack[batchCollector.stack.length - 1];
|
|
900
|
+
current.add(srefFunction);
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
if (observers.size === 0) return;
|
|
904
|
+
silence(() => {
|
|
905
|
+
for (const callback of [...observers.keys()]) {
|
|
906
|
+
if (!observers.has(callback)) continue;
|
|
907
|
+
callback(newValue, eventSource);
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
};
|
|
911
|
+
const attachProxyHandle = (value2) => {
|
|
912
|
+
let proxyHandle = value2[srefSymbol];
|
|
913
|
+
if (!proxyHandle) value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
|
|
914
|
+
proxyHandle.add(srefFunction);
|
|
915
|
+
};
|
|
916
|
+
const srefFunction = (...args) => {
|
|
917
|
+
if (!(2 in args)) {
|
|
918
|
+
let newValue = args[0];
|
|
919
|
+
const eventSource = args[1];
|
|
920
|
+
if (0 in args) {
|
|
921
|
+
if (refObj._value === newValue) return newValue;
|
|
922
|
+
if (isRef(newValue)) {
|
|
923
|
+
newValue = newValue();
|
|
924
|
+
if (refObj._value === newValue) return newValue;
|
|
925
|
+
}
|
|
926
|
+
if (createProxy2(newValue)) attachProxyHandle(newValue);
|
|
927
|
+
refObj._value = newValue;
|
|
928
|
+
if (refObj.auto) {
|
|
929
|
+
trigger2(newValue, eventSource);
|
|
930
|
+
}
|
|
931
|
+
return refObj._value;
|
|
932
|
+
} else {
|
|
933
|
+
collectRef(srefFunction);
|
|
934
|
+
}
|
|
935
|
+
return refObj._value;
|
|
936
|
+
}
|
|
937
|
+
const operation = args[2];
|
|
938
|
+
switch (operation) {
|
|
939
|
+
case 0 /* observe */: {
|
|
940
|
+
const observer = args[3];
|
|
941
|
+
if (!observer) return () => {
|
|
942
|
+
};
|
|
943
|
+
const removeObserver = (observer2) => {
|
|
944
|
+
observers.delete(observer2);
|
|
945
|
+
};
|
|
946
|
+
observers.add(observer);
|
|
947
|
+
return () => {
|
|
948
|
+
removeObserver(observer);
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
case 1 /* trigger */: {
|
|
952
|
+
const eventSource = args[1];
|
|
953
|
+
const value2 = refObj._value;
|
|
954
|
+
trigger2(value2, eventSource);
|
|
955
|
+
break;
|
|
956
|
+
}
|
|
957
|
+
case 2 /* observerCount */: {
|
|
958
|
+
return observers.size;
|
|
959
|
+
}
|
|
960
|
+
case 3 /* pause */: {
|
|
961
|
+
refObj.auto = false;
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
case 4 /* resume */: {
|
|
965
|
+
refObj.auto = true;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
return refObj._value;
|
|
969
|
+
};
|
|
970
|
+
srefFunction[srefSymbol] = 1;
|
|
971
|
+
defineRefValue(srefFunction, false);
|
|
972
|
+
if (isProxy) attachProxyHandle(value);
|
|
973
|
+
return srefFunction;
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
// src/reactivity/ref.ts
|
|
977
|
+
var ref = (value) => {
|
|
978
|
+
if (isRaw(value)) return value;
|
|
979
|
+
let result;
|
|
980
|
+
if (isRef(value)) {
|
|
981
|
+
result = value;
|
|
982
|
+
value = result();
|
|
983
|
+
} else {
|
|
984
|
+
result = sref(value);
|
|
985
|
+
}
|
|
986
|
+
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
987
|
+
return result;
|
|
988
|
+
result[refSymbol] = 1;
|
|
989
|
+
if (isArray(value)) {
|
|
990
|
+
const len = value.length;
|
|
991
|
+
for (let i = 0; i < len; ++i) {
|
|
992
|
+
const item = value[i];
|
|
993
|
+
if (isDeepRef(item)) continue;
|
|
994
|
+
value[i] = ref(item);
|
|
995
|
+
}
|
|
996
|
+
return result;
|
|
997
|
+
}
|
|
998
|
+
if (!isObject(value)) return result;
|
|
999
|
+
for (const item of Object.entries(value)) {
|
|
1000
|
+
const val = item[1];
|
|
1001
|
+
if (isDeepRef(val)) continue;
|
|
1002
|
+
const key = item[0];
|
|
1003
|
+
if (isSymbol(key)) continue;
|
|
1004
|
+
value[key] = null;
|
|
1005
|
+
value[key] = ref(val);
|
|
1006
|
+
}
|
|
1007
|
+
return result;
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
// src/directives/single-prop.ts
|
|
1011
|
+
var modelBridgeSymbol = Symbol("modelBridge");
|
|
1012
|
+
var isModelBridge = (value) => !!(value == null ? void 0 : value[modelBridgeSymbol]);
|
|
1013
|
+
var markModelBridge = (value) => {
|
|
1014
|
+
;
|
|
1015
|
+
value[modelBridgeSymbol] = 1;
|
|
1016
|
+
};
|
|
1017
|
+
var createModelBridge = (source) => {
|
|
1018
|
+
const bridge = ref(source());
|
|
1019
|
+
markModelBridge(bridge);
|
|
1020
|
+
return bridge;
|
|
1021
|
+
};
|
|
1022
|
+
var singlePropDirective = {
|
|
1023
|
+
collectRefObj: true,
|
|
1024
|
+
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
1025
|
+
if (!option) return () => {
|
|
1026
|
+
};
|
|
1027
|
+
const key = camelize(option);
|
|
1028
|
+
let currentSource;
|
|
1029
|
+
let bridge;
|
|
1030
|
+
let stopEntangle = () => {
|
|
1031
|
+
};
|
|
1032
|
+
const resetSync = () => {
|
|
1033
|
+
stopEntangle();
|
|
1034
|
+
stopEntangle = () => {
|
|
1035
|
+
};
|
|
1036
|
+
currentSource = void 0;
|
|
1037
|
+
bridge = void 0;
|
|
1038
|
+
};
|
|
1039
|
+
const clearEntangle = () => {
|
|
1040
|
+
stopEntangle();
|
|
1041
|
+
stopEntangle = () => {
|
|
1042
|
+
};
|
|
1043
|
+
};
|
|
1044
|
+
const syncRefs = (source, target) => {
|
|
1045
|
+
if (currentSource === source) return;
|
|
1046
|
+
clearEntangle();
|
|
1047
|
+
stopEntangle = entangle(source, target);
|
|
1048
|
+
currentSource = source;
|
|
1049
|
+
};
|
|
1050
|
+
const stopObserving = observe(
|
|
1051
|
+
parseResult.value,
|
|
1052
|
+
() => {
|
|
1053
|
+
var _a;
|
|
1054
|
+
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
1055
|
+
const ctx = parseResult.context;
|
|
1056
|
+
const ctxKey = ctx[key];
|
|
1057
|
+
if (!isRef(value)) {
|
|
1058
|
+
if (bridge && ctxKey === bridge) {
|
|
1059
|
+
bridge(value);
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
resetSync();
|
|
1063
|
+
if (isRef(ctxKey)) {
|
|
1064
|
+
ctxKey(value);
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
ctx[key] = value;
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
if (isModelBridge(value)) {
|
|
1071
|
+
if (isRef(ctxKey)) {
|
|
1072
|
+
syncRefs(value, ctxKey);
|
|
1073
|
+
} else {
|
|
1074
|
+
ctx[key] = value;
|
|
1075
|
+
}
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
if (!bridge) bridge = createModelBridge(value);
|
|
1079
|
+
ctx[key] = bridge;
|
|
1080
|
+
syncRefs(value, bridge);
|
|
1081
|
+
},
|
|
1082
|
+
true
|
|
1083
|
+
);
|
|
1084
|
+
return () => {
|
|
1085
|
+
stopEntangle();
|
|
1086
|
+
stopObserving();
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
|
|
1091
|
+
// src/bind/ComponentBinder.ts
|
|
1092
|
+
var ComponentBinder = class {
|
|
1093
|
+
constructor(binder) {
|
|
1094
|
+
__publicField(this, "__binder");
|
|
1095
|
+
__publicField(this, "__inherit");
|
|
1096
|
+
this.__binder = binder;
|
|
1097
|
+
this.__inherit = binder.__config.__builtInNames.inherit;
|
|
1098
|
+
}
|
|
1099
|
+
__bindAll(element) {
|
|
1100
|
+
this.__unwrapComponents(element);
|
|
1101
|
+
}
|
|
1102
|
+
__unwrapComponents(element) {
|
|
1103
|
+
var _a;
|
|
1104
|
+
const binder = this.__binder;
|
|
1105
|
+
const parser = binder.__parser;
|
|
1106
|
+
const registeredComponents = binder.__config.__components;
|
|
1107
|
+
const registeredComponentsUpperCase = binder.__config.__componentsUpperCase;
|
|
1108
|
+
const contextComponents = parser.__getComponents();
|
|
1109
|
+
const contextComponentSelectors = parser.__getComponentSelectors();
|
|
1110
|
+
const selector = [
|
|
1111
|
+
...registeredComponents.keys(),
|
|
1112
|
+
...contextComponentSelectors,
|
|
1113
|
+
...[...registeredComponents.keys()].map(hyphenate),
|
|
1114
|
+
...contextComponentSelectors.map(hyphenate)
|
|
1115
|
+
].join(",");
|
|
1116
|
+
if (isNullOrWhitespace(selector)) return;
|
|
1117
|
+
const list = element.querySelectorAll(selector);
|
|
1118
|
+
const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
|
|
1119
|
+
for (const component of components) {
|
|
1120
|
+
if (component.hasAttribute(binder.__pre)) continue;
|
|
1121
|
+
const parent = component.parentNode;
|
|
1122
|
+
if (!parent) continue;
|
|
1123
|
+
const nextSibling = component.nextSibling;
|
|
1124
|
+
const tagName = camelize(component.tagName).toUpperCase();
|
|
1125
|
+
const contextComponent = contextComponents[tagName];
|
|
1126
|
+
const registeredComponent = contextComponent != null ? contextComponent : registeredComponentsUpperCase.get(tagName);
|
|
1127
|
+
if (!registeredComponent) continue;
|
|
1128
|
+
const templateElement = registeredComponent.template;
|
|
1129
|
+
if (!templateElement) continue;
|
|
1130
|
+
const componentParent = component.parentElement;
|
|
1131
|
+
if (!componentParent) continue;
|
|
1132
|
+
const startOfComponent = new Comment(
|
|
1133
|
+
" begin component: " + component.tagName
|
|
1134
|
+
);
|
|
1135
|
+
const endOfComponent = new Comment(" end component: " + component.tagName);
|
|
1136
|
+
componentParent.insertBefore(startOfComponent, component);
|
|
1137
|
+
component.remove();
|
|
1138
|
+
const propsName = binder.__config.__builtInNames.props;
|
|
1139
|
+
const propsOnceName = binder.__config.__builtInNames.propsOnce;
|
|
1140
|
+
const bindName = binder.__config.__builtInNames.bind;
|
|
1141
|
+
const getProps = (component2, capturedContext2) => {
|
|
1142
|
+
const props = {};
|
|
1143
|
+
const hasProps = component2.hasAttribute(propsName);
|
|
1144
|
+
const hasPropsOnce = component2.hasAttribute(propsOnceName);
|
|
1145
|
+
parser.__scoped(capturedContext2, () => {
|
|
1146
|
+
parser.__push(props);
|
|
1147
|
+
if (hasProps) binder.__bind(propsDirective, component2, propsName);
|
|
1148
|
+
if (hasPropsOnce)
|
|
1149
|
+
binder.__bind(propsOnceDirective, component2, propsOnceName);
|
|
1150
|
+
let definedProps = registeredComponent.props;
|
|
1151
|
+
if (!definedProps || definedProps.length === 0) return;
|
|
1152
|
+
definedProps = definedProps.map(camelize);
|
|
1153
|
+
const definedPropsByLowerCase = new Map(
|
|
1154
|
+
definedProps.map((definedProp) => [
|
|
1155
|
+
definedProp.toLowerCase(),
|
|
1156
|
+
definedProp
|
|
1157
|
+
])
|
|
1158
|
+
);
|
|
1159
|
+
for (const name2 of definedProps.concat(definedProps.map(hyphenate))) {
|
|
1160
|
+
const value = component2.getAttribute(name2);
|
|
1161
|
+
if (value === null) continue;
|
|
1162
|
+
props[camelize(name2)] = value;
|
|
1163
|
+
component2.removeAttribute(name2);
|
|
1164
|
+
}
|
|
1165
|
+
const map = binder.__directiveCollector.__collect(component2, false);
|
|
1166
|
+
for (const [attrName, item] of map.entries()) {
|
|
1167
|
+
const [name2, option] = item.__terms;
|
|
1168
|
+
if (!option) continue;
|
|
1169
|
+
const propName = definedPropsByLowerCase.get(
|
|
1170
|
+
camelize(option).toLowerCase()
|
|
1171
|
+
);
|
|
1172
|
+
if (!propName) continue;
|
|
1173
|
+
if (name2 !== "." && name2 !== ":" && name2 !== bindName) continue;
|
|
1174
|
+
binder.__bind(
|
|
1175
|
+
singlePropDirective,
|
|
1176
|
+
component2,
|
|
1177
|
+
attrName,
|
|
1178
|
+
true,
|
|
1179
|
+
propName,
|
|
1180
|
+
item.__flags
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
return props;
|
|
1185
|
+
};
|
|
1186
|
+
const capturedContext = [...parser.__capture()];
|
|
1187
|
+
const createComponentCtx = () => {
|
|
1188
|
+
var _a2;
|
|
1189
|
+
const props = getProps(component, capturedContext);
|
|
1190
|
+
const head2 = new ComponentHead(
|
|
1191
|
+
props,
|
|
1192
|
+
component,
|
|
1193
|
+
capturedContext,
|
|
1194
|
+
startOfComponent,
|
|
1195
|
+
endOfComponent
|
|
1196
|
+
);
|
|
1197
|
+
const componentCtx2 = useScope(() => {
|
|
1198
|
+
var _a3;
|
|
1199
|
+
return (_a3 = registeredComponent.context(head2)) != null ? _a3 : {};
|
|
1200
|
+
}).context;
|
|
1201
|
+
if (head2.autoProps) {
|
|
1202
|
+
for (const [key, propsValue] of Object.entries(props)) {
|
|
1203
|
+
if (key in componentCtx2) {
|
|
1204
|
+
const compValue = componentCtx2[key];
|
|
1205
|
+
if (compValue === propsValue) continue;
|
|
1206
|
+
if (head2.entangle && isRef(compValue) && isRef(propsValue)) {
|
|
1207
|
+
addUnbinder(startOfComponent, entangle(propsValue, compValue));
|
|
1208
|
+
}
|
|
1209
|
+
} else componentCtx2[key] = propsValue;
|
|
1210
|
+
}
|
|
1211
|
+
(_a2 = head2.onAutoPropsAssigned) == null ? void 0 : _a2.call(head2);
|
|
1212
|
+
}
|
|
1213
|
+
return { componentCtx: componentCtx2, head: head2 };
|
|
1214
|
+
};
|
|
1215
|
+
const { componentCtx, head } = createComponentCtx();
|
|
1216
|
+
const childNodes = [...getChildNodes(templateElement)];
|
|
1217
|
+
const len = childNodes.length;
|
|
1218
|
+
const isEmptyComponent = component.childNodes.length === 0;
|
|
1219
|
+
const expandSlot = (slot) => {
|
|
1220
|
+
const parent2 = slot.parentElement;
|
|
1221
|
+
if (isEmptyComponent) {
|
|
1222
|
+
for (const slotChild of [...slot.childNodes]) {
|
|
1223
|
+
parent2.insertBefore(slotChild, slot);
|
|
1224
|
+
}
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
let name2 = slot.name;
|
|
1228
|
+
if (isNullOrWhitespace(name2)) {
|
|
1229
|
+
name2 = slot.getAttributeNames().filter((x) => x.startsWith("#"))[0];
|
|
1230
|
+
if (isNullOrWhitespace(name2)) {
|
|
1231
|
+
name2 = "default";
|
|
1232
|
+
} else name2 = name2.substring(1);
|
|
1233
|
+
}
|
|
1234
|
+
let compTemplate = component.querySelector(
|
|
1235
|
+
`template[name='${name2}'], template[\\#${name2}]`
|
|
1236
|
+
);
|
|
1237
|
+
if (!compTemplate && name2 === "default") {
|
|
1238
|
+
compTemplate = component.querySelector("template:not([name])");
|
|
1239
|
+
if (compTemplate && compTemplate.getAttributeNames().filter((x) => x.startsWith("#")).length > 0)
|
|
1240
|
+
compTemplate = null;
|
|
1241
|
+
}
|
|
1242
|
+
const createSwitchContext = (childNodes2) => {
|
|
1243
|
+
if (!head.enableSwitch) return;
|
|
1244
|
+
parser.__scoped(capturedContext, () => {
|
|
1245
|
+
parser.__push(componentCtx);
|
|
1246
|
+
const props = getProps(slot, parser.__capture());
|
|
1247
|
+
parser.__scoped(capturedContext, () => {
|
|
1248
|
+
parser.__push(props);
|
|
1249
|
+
const switchContext = parser.__capture();
|
|
1250
|
+
const id = addSwitch(switchContext);
|
|
1251
|
+
for (const child of childNodes2) {
|
|
1252
|
+
if (!isElement(child)) continue;
|
|
1253
|
+
child.setAttribute(rswitch, id);
|
|
1254
|
+
refSwitch(id);
|
|
1255
|
+
addUnbinder(child, () => {
|
|
1256
|
+
removeSwitch(id);
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
});
|
|
1261
|
+
};
|
|
1262
|
+
if (compTemplate) {
|
|
1263
|
+
const childNodes2 = [...getChildNodes(compTemplate)];
|
|
1264
|
+
for (const slotChild of childNodes2) {
|
|
1265
|
+
parent2.insertBefore(slotChild, slot);
|
|
1266
|
+
}
|
|
915
1267
|
createSwitchContext(childNodes2);
|
|
916
1268
|
} else {
|
|
917
1269
|
if (name2 !== "default") {
|
|
@@ -978,484 +1330,225 @@ var ComponentBinder = class {
|
|
|
978
1330
|
normalizeAttributeName(attrName, binder.__config),
|
|
979
1331
|
value
|
|
980
1332
|
);
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
const clearUnusedAttributes = () => {
|
|
985
|
-
for (const attrName of component.getAttributeNames()) {
|
|
986
|
-
if (!attrName.startsWith("@") && !attrName.startsWith(binder.__config.__builtInNames.on))
|
|
987
|
-
component.removeAttribute(attrName);
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
const bindComponent = () => {
|
|
991
|
-
transferAttributesToTheComponentChild();
|
|
992
|
-
clearUnusedAttributes();
|
|
993
|
-
parser.__push(componentCtx);
|
|
994
|
-
binder.__bindAttributes(component, false);
|
|
995
|
-
componentCtx.$emit = head.emit;
|
|
996
|
-
bindChildNodes(binder, childNodes);
|
|
997
|
-
addUnbinder(component, () => {
|
|
998
|
-
callUnmounted(componentCtx);
|
|
999
|
-
});
|
|
1000
|
-
addUnbinder(startOfComponent, () => {
|
|
1001
|
-
unbind(component);
|
|
1002
|
-
});
|
|
1003
|
-
callMounted(componentCtx);
|
|
1004
|
-
};
|
|
1005
|
-
parser.__scoped(capturedContext, bindComponent);
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
};
|
|
1009
|
-
|
|
1010
|
-
// src/bind/DirectiveCollector.ts
|
|
1011
|
-
var DirectiveElement = class {
|
|
1012
|
-
constructor(name2) {
|
|
1013
|
-
__publicField(this, "__name");
|
|
1014
|
-
// 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
|
|
1015
|
-
/** Contains: `['@', 'submit'], ['r-on', 'click'], ['\\@', '[dynamicKey]']` */
|
|
1016
|
-
__publicField(this, "__terms", []);
|
|
1017
|
-
/** Contains directive flags. ['camel', 'prevent',...] */
|
|
1018
|
-
__publicField(this, "__flags", []);
|
|
1019
|
-
__publicField(this, "__elements", []);
|
|
1020
|
-
this.__name = name2;
|
|
1021
|
-
this.__parse();
|
|
1022
|
-
}
|
|
1023
|
-
__parse() {
|
|
1024
|
-
let name2 = this.__name;
|
|
1025
|
-
const isPropShortcut = name2.startsWith(".");
|
|
1026
|
-
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1027
|
-
const firstFlagIndex = name2.indexOf(".");
|
|
1028
|
-
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1029
|
-
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1030
|
-
if (firstFlagIndex >= 0) {
|
|
1031
|
-
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1032
|
-
if (flags.includes("camel")) {
|
|
1033
|
-
const index = terms.length - 1;
|
|
1034
|
-
terms[index] = camelize(terms[index]);
|
|
1035
|
-
}
|
|
1036
|
-
if (flags.includes("prop")) {
|
|
1037
|
-
terms[0] = ".";
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1042
|
-
var DirectiveCollector = class {
|
|
1043
|
-
constructor(binder) {
|
|
1044
|
-
__publicField(this, "__binder");
|
|
1045
|
-
__publicField(this, "__prefixes");
|
|
1046
|
-
this.__binder = binder;
|
|
1047
|
-
this.__prefixes = binder.__config.__getPrefixes();
|
|
1048
|
-
}
|
|
1049
|
-
__collect(element, isRecursive) {
|
|
1050
|
-
const map = /* @__PURE__ */ new Map();
|
|
1051
|
-
if (!isHTMLElement(element)) return map;
|
|
1052
|
-
const prefixes2 = this.__prefixes;
|
|
1053
|
-
const processNode = (node) => {
|
|
1054
|
-
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1055
|
-
for (const name2 of names) {
|
|
1056
|
-
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1057
|
-
const item = map.get(name2);
|
|
1058
|
-
item.__elements.push(node);
|
|
1059
|
-
}
|
|
1060
|
-
};
|
|
1061
|
-
processNode(element);
|
|
1062
|
-
if (!isRecursive) return map;
|
|
1063
|
-
const nodes = element.querySelectorAll("*");
|
|
1064
|
-
for (const node of nodes) {
|
|
1065
|
-
processNode(node);
|
|
1066
|
-
}
|
|
1067
|
-
return map;
|
|
1068
|
-
}
|
|
1069
|
-
};
|
|
1070
|
-
|
|
1071
|
-
// src/bind/DynamicBinder.ts
|
|
1072
|
-
var mount2 = (nodes, parent) => {
|
|
1073
|
-
for (const x of nodes) {
|
|
1074
|
-
const node = x.cloneNode(true);
|
|
1075
|
-
parent.appendChild(node);
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
var DynamicBinder = class {
|
|
1079
|
-
constructor(binder) {
|
|
1080
|
-
__publicField(this, "__binder");
|
|
1081
|
-
__publicField(this, "__is");
|
|
1082
|
-
__publicField(this, "__isSelector");
|
|
1083
|
-
this.__binder = binder;
|
|
1084
|
-
this.__is = binder.__config.__builtInNames.is;
|
|
1085
|
-
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1086
|
-
}
|
|
1087
|
-
__bindAll(element) {
|
|
1088
|
-
const isComponentElement = element.hasAttribute(this.__is);
|
|
1089
|
-
const elements = findElements(element, this.__isSelector);
|
|
1090
|
-
for (const el of elements) {
|
|
1091
|
-
this.__bind(el);
|
|
1092
|
-
}
|
|
1093
|
-
return isComponentElement;
|
|
1094
|
-
}
|
|
1095
|
-
__bind(el) {
|
|
1096
|
-
let expression = el.getAttribute(this.__is);
|
|
1097
|
-
if (!expression) {
|
|
1098
|
-
expression = el.getAttribute("is");
|
|
1099
|
-
if (!expression) return;
|
|
1100
|
-
if (!expression.startsWith("regor:")) {
|
|
1101
|
-
if (!expression.startsWith("r-")) return;
|
|
1102
|
-
const staticName = expression.slice(2).trim().toLowerCase();
|
|
1103
|
-
if (!staticName) return;
|
|
1104
|
-
const parent = el.parentNode;
|
|
1105
|
-
if (!parent) return;
|
|
1106
|
-
const nativeElement = document.createElement(staticName);
|
|
1107
|
-
for (const attr of el.getAttributeNames()) {
|
|
1108
|
-
if (attr === "is") continue;
|
|
1109
|
-
nativeElement.setAttribute(attr, el.getAttribute(attr));
|
|
1110
|
-
}
|
|
1111
|
-
while (el.firstChild) nativeElement.appendChild(el.firstChild);
|
|
1112
|
-
parent.insertBefore(nativeElement, el);
|
|
1113
|
-
el.remove();
|
|
1114
|
-
this.__binder.__bindDefault(nativeElement);
|
|
1115
|
-
return;
|
|
1116
|
-
}
|
|
1117
|
-
expression = `'${expression.slice(6)}'`;
|
|
1118
|
-
el.removeAttribute("is");
|
|
1119
|
-
}
|
|
1120
|
-
el.removeAttribute(this.__is);
|
|
1121
|
-
this.__bindToExpression(el, expression);
|
|
1122
|
-
}
|
|
1123
|
-
__createRegion(el, expression) {
|
|
1124
|
-
const nodes = getNodes(el);
|
|
1125
|
-
const parent = el.parentNode;
|
|
1126
|
-
const commentBegin = document.createComment(
|
|
1127
|
-
`__begin__ dynamic ${expression != null ? expression : ""}`
|
|
1128
|
-
);
|
|
1129
|
-
parent.insertBefore(commentBegin, el);
|
|
1130
|
-
setSwitchOwner(commentBegin, nodes);
|
|
1131
|
-
nodes.forEach((x) => {
|
|
1132
|
-
removeNode(x);
|
|
1133
|
-
});
|
|
1134
|
-
el.remove();
|
|
1135
|
-
const commentEnd = document.createComment(
|
|
1136
|
-
`__end__ dynamic ${expression != null ? expression : ""}`
|
|
1137
|
-
);
|
|
1138
|
-
parent.insertBefore(commentEnd, commentBegin.nextSibling);
|
|
1139
|
-
return {
|
|
1140
|
-
nodes,
|
|
1141
|
-
parent,
|
|
1142
|
-
commentBegin,
|
|
1143
|
-
commentEnd
|
|
1144
|
-
};
|
|
1145
|
-
}
|
|
1146
|
-
__bindToExpression(el, expression) {
|
|
1147
|
-
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
1148
|
-
el,
|
|
1149
|
-
` => ${expression} `
|
|
1150
|
-
);
|
|
1151
|
-
const parseResult = this.__binder.__parser.__parse(expression);
|
|
1152
|
-
const value = parseResult.value;
|
|
1153
|
-
const parser = this.__binder.__parser;
|
|
1154
|
-
const capturedContext = parser.__capture();
|
|
1155
|
-
const mounted = { name: "" };
|
|
1156
|
-
const componentChildNodes = isTemplate(el) ? nodes : [...nodes[0].childNodes];
|
|
1157
|
-
const refresh = () => {
|
|
1158
|
-
parser.__scoped(capturedContext, () => {
|
|
1159
|
-
var _a;
|
|
1160
|
-
let name2 = value()[0];
|
|
1161
|
-
if (isObject(name2)) {
|
|
1162
|
-
if (!name2.name) {
|
|
1163
|
-
name2 = (_a = Object.entries(parser.__getComponents()).filter(
|
|
1164
|
-
(x) => x[1] === name2
|
|
1165
|
-
)[0]) == null ? void 0 : _a[0];
|
|
1166
|
-
} else {
|
|
1167
|
-
name2 = name2.name;
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
if (!isString(name2) || isNullOrWhitespace(name2)) {
|
|
1171
|
-
unmount(commentBegin, commentEnd);
|
|
1172
|
-
return;
|
|
1333
|
+
}
|
|
1173
1334
|
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1335
|
+
};
|
|
1336
|
+
const clearUnusedAttributes = () => {
|
|
1337
|
+
for (const attrName of component.getAttributeNames()) {
|
|
1338
|
+
if (!attrName.startsWith("@") && !attrName.startsWith(binder.__config.__builtInNames.on))
|
|
1339
|
+
component.removeAttribute(attrName);
|
|
1180
1340
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
stopObserverList.push(stopObserving);
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
|
|
1202
|
-
// src/computed/watchEffect.ts
|
|
1203
|
-
var collectedRefs = [];
|
|
1204
|
-
var collectRef = (ref2) => {
|
|
1205
|
-
var _a;
|
|
1206
|
-
if (collectedRefs.length === 0) return;
|
|
1207
|
-
(_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
|
|
1208
|
-
};
|
|
1209
|
-
var watchEffect = (effect) => {
|
|
1210
|
-
if (!effect) return () => {
|
|
1211
|
-
};
|
|
1212
|
-
const terminator = { stop: () => {
|
|
1213
|
-
} };
|
|
1214
|
-
watchEffectInternal(effect, terminator);
|
|
1215
|
-
onUnmounted(() => terminator.stop(), true);
|
|
1216
|
-
return terminator.stop;
|
|
1217
|
-
};
|
|
1218
|
-
var watchEffectInternal = (effect, terminator) => {
|
|
1219
|
-
if (!effect) return;
|
|
1220
|
-
let stopObservingList = [];
|
|
1221
|
-
let isStopped = false;
|
|
1222
|
-
const stopWatch = () => {
|
|
1223
|
-
for (const stop of stopObservingList) stop();
|
|
1224
|
-
stopObservingList = [];
|
|
1225
|
-
isStopped = true;
|
|
1226
|
-
};
|
|
1227
|
-
terminator.stop = stopWatch;
|
|
1228
|
-
try {
|
|
1229
|
-
const set = /* @__PURE__ */ new Set();
|
|
1230
|
-
collectedRefs.push(set);
|
|
1231
|
-
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
1232
|
-
if (isStopped) return;
|
|
1233
|
-
for (const r of [...set]) {
|
|
1234
|
-
const stopObserving = observe(r, () => {
|
|
1235
|
-
stopWatch();
|
|
1236
|
-
watchEffect(effect);
|
|
1237
|
-
});
|
|
1238
|
-
stopObservingList.push(stopObserving);
|
|
1341
|
+
};
|
|
1342
|
+
const bindComponent = () => {
|
|
1343
|
+
transferAttributesToTheComponentChild();
|
|
1344
|
+
clearUnusedAttributes();
|
|
1345
|
+
parser.__push(componentCtx);
|
|
1346
|
+
binder.__bindAttributes(component, false);
|
|
1347
|
+
componentCtx.$emit = head.emit;
|
|
1348
|
+
bindChildNodes(binder, childNodes);
|
|
1349
|
+
addUnbinder(component, () => {
|
|
1350
|
+
callUnmounted(componentCtx);
|
|
1351
|
+
});
|
|
1352
|
+
addUnbinder(startOfComponent, () => {
|
|
1353
|
+
unbind(component);
|
|
1354
|
+
});
|
|
1355
|
+
callMounted(componentCtx);
|
|
1356
|
+
};
|
|
1357
|
+
parser.__scoped(capturedContext, bindComponent);
|
|
1239
1358
|
}
|
|
1240
|
-
} finally {
|
|
1241
|
-
collectedRefs.pop();
|
|
1242
|
-
}
|
|
1243
|
-
};
|
|
1244
|
-
var silence = (action) => {
|
|
1245
|
-
const len = collectedRefs.length;
|
|
1246
|
-
const hasPush = len > 0 && collectedRefs[len - 1];
|
|
1247
|
-
try {
|
|
1248
|
-
if (hasPush) collectedRefs.push(null);
|
|
1249
|
-
return action();
|
|
1250
|
-
} finally {
|
|
1251
|
-
if (hasPush) collectedRefs.pop();
|
|
1252
|
-
}
|
|
1253
|
-
};
|
|
1254
|
-
var collectRefs = (action) => {
|
|
1255
|
-
try {
|
|
1256
|
-
const set = /* @__PURE__ */ new Set();
|
|
1257
|
-
collectedRefs.push(set);
|
|
1258
|
-
const result = action();
|
|
1259
|
-
return { value: result, refs: [...set] };
|
|
1260
|
-
} finally {
|
|
1261
|
-
collectedRefs.pop();
|
|
1262
1359
|
}
|
|
1263
1360
|
};
|
|
1264
1361
|
|
|
1265
|
-
// src/
|
|
1266
|
-
var
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
if (!obj) return;
|
|
1278
|
-
if (isArray(obj) || isSet(obj)) {
|
|
1279
|
-
for (const el of obj) {
|
|
1280
|
-
trigger(el, eventSource, true);
|
|
1281
|
-
}
|
|
1282
|
-
} else if (isMap(obj)) {
|
|
1283
|
-
for (const el of obj) {
|
|
1284
|
-
trigger(el[0], eventSource, true);
|
|
1285
|
-
trigger(el[1], eventSource, true);
|
|
1286
|
-
}
|
|
1362
|
+
// src/bind/DirectiveCollector.ts
|
|
1363
|
+
var DirectiveElement = class {
|
|
1364
|
+
constructor(name2) {
|
|
1365
|
+
__publicField(this, "__name");
|
|
1366
|
+
// 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
|
|
1367
|
+
/** Contains: `['@', 'submit'], ['r-on', 'click'], ['\\@', '[dynamicKey]']` */
|
|
1368
|
+
__publicField(this, "__terms", []);
|
|
1369
|
+
/** Contains directive flags. ['camel', 'prevent',...] */
|
|
1370
|
+
__publicField(this, "__flags", []);
|
|
1371
|
+
__publicField(this, "__elements", []);
|
|
1372
|
+
this.__name = name2;
|
|
1373
|
+
this.__parse();
|
|
1287
1374
|
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1375
|
+
__parse() {
|
|
1376
|
+
let name2 = this.__name;
|
|
1377
|
+
const isPropShortcut = name2.startsWith(".");
|
|
1378
|
+
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1379
|
+
const firstFlagIndex = name2.indexOf(".");
|
|
1380
|
+
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1381
|
+
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1382
|
+
if (firstFlagIndex >= 0) {
|
|
1383
|
+
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1384
|
+
if (flags.includes("camel")) {
|
|
1385
|
+
const index = terms.length - 1;
|
|
1386
|
+
terms[index] = camelize(terms[index]);
|
|
1387
|
+
}
|
|
1388
|
+
if (flags.includes("prop")) {
|
|
1389
|
+
terms[0] = ".";
|
|
1390
|
+
}
|
|
1291
1391
|
}
|
|
1292
1392
|
}
|
|
1293
1393
|
};
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
writable: false,
|
|
1319
|
-
enumerable: false,
|
|
1320
|
-
configurable: true
|
|
1321
|
-
});
|
|
1322
|
-
};
|
|
1323
|
-
|
|
1324
|
-
// src/proxies/array-ref.ts
|
|
1325
|
-
var arrayProto = Array.prototype;
|
|
1326
|
-
var proxyArrayProto = Object.create(arrayProto);
|
|
1327
|
-
var methodsToPatch = [
|
|
1328
|
-
"push",
|
|
1329
|
-
"pop",
|
|
1330
|
-
"shift",
|
|
1331
|
-
"unshift",
|
|
1332
|
-
"splice",
|
|
1333
|
-
"sort",
|
|
1334
|
-
"reverse"
|
|
1335
|
-
];
|
|
1336
|
-
createProxy(arrayProto, proxyArrayProto, methodsToPatch);
|
|
1337
|
-
|
|
1338
|
-
// src/proxies/map-ref.ts
|
|
1339
|
-
var mapProto = Map.prototype;
|
|
1340
|
-
var proxyMapProto = Object.create(mapProto);
|
|
1341
|
-
var methodsToPatch2 = ["set", "clear", "delete"];
|
|
1342
|
-
setToStringTag(proxyMapProto, "Map");
|
|
1343
|
-
createProxy(mapProto, proxyMapProto, methodsToPatch2);
|
|
1344
|
-
|
|
1345
|
-
// src/proxies/set-ref.ts
|
|
1346
|
-
var setProto = Set.prototype;
|
|
1347
|
-
var proxySetProto = Object.create(setProto);
|
|
1348
|
-
var methodsToPatch3 = ["add", "clear", "delete"];
|
|
1349
|
-
setToStringTag(proxySetProto, "Set");
|
|
1350
|
-
createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
1351
|
-
|
|
1352
|
-
// src/reactivity/sref.ts
|
|
1353
|
-
var batchCollector = {};
|
|
1354
|
-
var sref = (value) => {
|
|
1355
|
-
if (isRef(value) || isRaw(value)) return value;
|
|
1356
|
-
const refObj = {
|
|
1357
|
-
auto: true,
|
|
1358
|
-
_value: value
|
|
1359
|
-
};
|
|
1360
|
-
const createProxy2 = (value2) => {
|
|
1361
|
-
if (!isObject(value2)) return false;
|
|
1362
|
-
if (srefSymbol in value2) return true;
|
|
1363
|
-
const isAnArray = isArray(value2);
|
|
1364
|
-
if (isAnArray) {
|
|
1365
|
-
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
1366
|
-
return true;
|
|
1367
|
-
}
|
|
1368
|
-
const isASet = isSet(value2);
|
|
1369
|
-
if (isASet) {
|
|
1370
|
-
Object.setPrototypeOf(value2, proxySetProto);
|
|
1371
|
-
return true;
|
|
1372
|
-
}
|
|
1373
|
-
const isAMap = isMap(value2);
|
|
1374
|
-
if (isAMap) {
|
|
1375
|
-
Object.setPrototypeOf(value2, proxyMapProto);
|
|
1376
|
-
return true;
|
|
1394
|
+
var DirectiveCollector = class {
|
|
1395
|
+
constructor(binder) {
|
|
1396
|
+
__publicField(this, "__binder");
|
|
1397
|
+
__publicField(this, "__prefixes");
|
|
1398
|
+
this.__binder = binder;
|
|
1399
|
+
this.__prefixes = binder.__config.__getPrefixes();
|
|
1400
|
+
}
|
|
1401
|
+
__collect(element, isRecursive) {
|
|
1402
|
+
const map = /* @__PURE__ */ new Map();
|
|
1403
|
+
if (!isHTMLElement(element)) return map;
|
|
1404
|
+
const prefixes2 = this.__prefixes;
|
|
1405
|
+
const processNode = (node) => {
|
|
1406
|
+
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1407
|
+
for (const name2 of names) {
|
|
1408
|
+
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1409
|
+
const item = map.get(name2);
|
|
1410
|
+
item.__elements.push(node);
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
processNode(element);
|
|
1414
|
+
if (!isRecursive) return map;
|
|
1415
|
+
const nodes = element.querySelectorAll("*");
|
|
1416
|
+
for (const node of nodes) {
|
|
1417
|
+
processNode(node);
|
|
1377
1418
|
}
|
|
1378
|
-
return
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1419
|
+
return map;
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
|
|
1423
|
+
// src/bind/DynamicBinder.ts
|
|
1424
|
+
var mount2 = (nodes, parent) => {
|
|
1425
|
+
for (const x of nodes) {
|
|
1426
|
+
const node = x.cloneNode(true);
|
|
1427
|
+
parent.appendChild(node);
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
var DynamicBinder = class {
|
|
1431
|
+
constructor(binder) {
|
|
1432
|
+
__publicField(this, "__binder");
|
|
1433
|
+
__publicField(this, "__is");
|
|
1434
|
+
__publicField(this, "__isSelector");
|
|
1435
|
+
this.__binder = binder;
|
|
1436
|
+
this.__is = binder.__config.__builtInNames.is;
|
|
1437
|
+
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1438
|
+
}
|
|
1439
|
+
__bindAll(element) {
|
|
1440
|
+
const isComponentElement = element.hasAttribute(this.__is);
|
|
1441
|
+
const elements = findElements(element, this.__isSelector);
|
|
1442
|
+
for (const el of elements) {
|
|
1443
|
+
this.__bind(el);
|
|
1387
1444
|
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1445
|
+
return isComponentElement;
|
|
1446
|
+
}
|
|
1447
|
+
__bind(el) {
|
|
1448
|
+
let expression = el.getAttribute(this.__is);
|
|
1449
|
+
if (!expression) {
|
|
1450
|
+
expression = el.getAttribute("is");
|
|
1451
|
+
if (!expression) return;
|
|
1452
|
+
if (!expression.startsWith("regor:")) {
|
|
1453
|
+
if (!expression.startsWith("r-")) return;
|
|
1454
|
+
const staticName = expression.slice(2).trim().toLowerCase();
|
|
1455
|
+
if (!staticName) return;
|
|
1456
|
+
const parent = el.parentNode;
|
|
1457
|
+
if (!parent) return;
|
|
1458
|
+
const nativeElement = document.createElement(staticName);
|
|
1459
|
+
for (const attr of el.getAttributeNames()) {
|
|
1460
|
+
if (attr === "is") continue;
|
|
1461
|
+
nativeElement.setAttribute(attr, el.getAttribute(attr));
|
|
1462
|
+
}
|
|
1463
|
+
while (el.firstChild) nativeElement.appendChild(el.firstChild);
|
|
1464
|
+
parent.insertBefore(nativeElement, el);
|
|
1465
|
+
el.remove();
|
|
1466
|
+
this.__binder.__bindDefault(nativeElement);
|
|
1467
|
+
return;
|
|
1393
1468
|
}
|
|
1469
|
+
expression = `'${expression.slice(6)}'`;
|
|
1470
|
+
el.removeAttribute("is");
|
|
1471
|
+
}
|
|
1472
|
+
el.removeAttribute(this.__is);
|
|
1473
|
+
this.__bindToExpression(el, expression);
|
|
1474
|
+
}
|
|
1475
|
+
__createRegion(el, expression) {
|
|
1476
|
+
const nodes = getNodes(el);
|
|
1477
|
+
const parent = el.parentNode;
|
|
1478
|
+
const commentBegin = document.createComment(
|
|
1479
|
+
`__begin__ dynamic ${expression != null ? expression : ""}`
|
|
1480
|
+
);
|
|
1481
|
+
parent.insertBefore(commentBegin, el);
|
|
1482
|
+
setSwitchOwner(commentBegin, nodes);
|
|
1483
|
+
nodes.forEach((x) => {
|
|
1484
|
+
removeNode(x);
|
|
1394
1485
|
});
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1486
|
+
el.remove();
|
|
1487
|
+
const commentEnd = document.createComment(
|
|
1488
|
+
`__end__ dynamic ${expression != null ? expression : ""}`
|
|
1489
|
+
);
|
|
1490
|
+
parent.insertBefore(commentEnd, commentBegin.nextSibling);
|
|
1491
|
+
return {
|
|
1492
|
+
nodes,
|
|
1493
|
+
parent,
|
|
1494
|
+
commentBegin,
|
|
1495
|
+
commentEnd
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
__bindToExpression(el, expression) {
|
|
1499
|
+
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
1500
|
+
el,
|
|
1501
|
+
` => ${expression} `
|
|
1502
|
+
);
|
|
1503
|
+
const parseResult = this.__binder.__parser.__parse(expression);
|
|
1504
|
+
const value = parseResult.value;
|
|
1505
|
+
const parser = this.__binder.__parser;
|
|
1506
|
+
const capturedContext = parser.__capture();
|
|
1507
|
+
const mounted = { name: "" };
|
|
1508
|
+
const componentChildNodes = isTemplate(el) ? nodes : [...nodes[0].childNodes];
|
|
1509
|
+
const refresh = () => {
|
|
1510
|
+
parser.__scoped(capturedContext, () => {
|
|
1511
|
+
var _a;
|
|
1512
|
+
let name2 = value()[0];
|
|
1513
|
+
if (isObject(name2)) {
|
|
1514
|
+
if (!name2.name) {
|
|
1515
|
+
name2 = (_a = Object.entries(parser.__getComponents()).filter(
|
|
1516
|
+
(x) => x[1] === name2
|
|
1517
|
+
)[0]) == null ? void 0 : _a[0];
|
|
1518
|
+
} else {
|
|
1519
|
+
name2 = name2.name;
|
|
1520
|
+
}
|
|
1410
1521
|
}
|
|
1411
|
-
if (
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
trigger2(newValue, eventSource);
|
|
1522
|
+
if (!isString(name2) || isNullOrWhitespace(name2)) {
|
|
1523
|
+
unmount(commentBegin, commentEnd);
|
|
1524
|
+
return;
|
|
1415
1525
|
}
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
};
|
|
1435
|
-
}
|
|
1436
|
-
case 1 /* trigger */: {
|
|
1437
|
-
const eventSource = args[1];
|
|
1438
|
-
const value2 = refObj._value;
|
|
1439
|
-
trigger2(value2, eventSource);
|
|
1440
|
-
break;
|
|
1441
|
-
}
|
|
1442
|
-
case 2 /* observerCount */: {
|
|
1443
|
-
return observers.size;
|
|
1444
|
-
}
|
|
1445
|
-
case 3 /* pause */: {
|
|
1446
|
-
refObj.auto = false;
|
|
1447
|
-
break;
|
|
1448
|
-
}
|
|
1449
|
-
case 4 /* resume */: {
|
|
1450
|
-
refObj.auto = true;
|
|
1526
|
+
if (mounted.name === name2) return;
|
|
1527
|
+
unmount(commentBegin, commentEnd);
|
|
1528
|
+
const componentElement = document.createElement(name2);
|
|
1529
|
+
for (const attr of el.getAttributeNames()) {
|
|
1530
|
+
if (attr === this.__is) continue;
|
|
1531
|
+
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1532
|
+
}
|
|
1533
|
+
mount2(componentChildNodes, componentElement);
|
|
1534
|
+
parent.insertBefore(componentElement, commentEnd);
|
|
1535
|
+
this.__binder.__bindDefault(componentElement);
|
|
1536
|
+
mounted.name = name2;
|
|
1537
|
+
});
|
|
1538
|
+
};
|
|
1539
|
+
const stopObserverList = [];
|
|
1540
|
+
const unbinder = () => {
|
|
1541
|
+
parseResult.stop();
|
|
1542
|
+
for (const stopObserver of stopObserverList) {
|
|
1543
|
+
stopObserver();
|
|
1451
1544
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1545
|
+
stopObserverList.length = 0;
|
|
1546
|
+
};
|
|
1547
|
+
addUnbinder(commentBegin, unbinder);
|
|
1548
|
+
refresh();
|
|
1549
|
+
const stopObserving = observe(value, refresh);
|
|
1550
|
+
stopObserverList.push(stopObserving);
|
|
1551
|
+
}
|
|
1459
1552
|
};
|
|
1460
1553
|
|
|
1461
1554
|
// src/reactivity/unref.ts
|
|
@@ -2314,21 +2407,21 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
|
|
|
2314
2407
|
number: f1.number || f2.number,
|
|
2315
2408
|
trim: f1.trim || f2.trim
|
|
2316
2409
|
};
|
|
2317
|
-
|
|
2318
|
-
if (!modelRef) {
|
|
2410
|
+
if (!parseResult.refs[0]) {
|
|
2319
2411
|
warning(8 /* ModelRequiresRef */, el);
|
|
2320
2412
|
return () => {
|
|
2321
2413
|
};
|
|
2322
2414
|
}
|
|
2415
|
+
const getModelRef = () => parseResult.refs[0];
|
|
2323
2416
|
const isAnInput = isInput(el);
|
|
2324
2417
|
if (isAnInput && isCheckBox(el)) {
|
|
2325
|
-
return handleCheckBox(el,
|
|
2418
|
+
return handleCheckBox(el, getModelRef);
|
|
2326
2419
|
} else if (isAnInput && isRadio(el)) {
|
|
2327
|
-
return handleRadio(el,
|
|
2420
|
+
return handleRadio(el, getModelRef);
|
|
2328
2421
|
} else if (isAnInput || isTextArea(el)) {
|
|
2329
|
-
return handleInputAndTextArea(el, flags,
|
|
2422
|
+
return handleInputAndTextArea(el, flags, getModelRef, parsedValue);
|
|
2330
2423
|
} else if (isSelect(el)) {
|
|
2331
|
-
return handleSelect(el,
|
|
2424
|
+
return handleSelect(el, getModelRef, parsedValue);
|
|
2332
2425
|
} else {
|
|
2333
2426
|
warning(7 /* ModelNotSupportOnElement */, el);
|
|
2334
2427
|
return () => {
|
|
@@ -2336,7 +2429,7 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
|
|
|
2336
2429
|
}
|
|
2337
2430
|
};
|
|
2338
2431
|
var decimalSeparators = /[.,' ·٫]/;
|
|
2339
|
-
var handleInputAndTextArea = (el, flags,
|
|
2432
|
+
var handleInputAndTextArea = (el, flags, getModelRef, parsedValue) => {
|
|
2340
2433
|
const isLazy = flags.lazy;
|
|
2341
2434
|
const eventType = isLazy ? "change" : "input";
|
|
2342
2435
|
const isNumber = isNumberInput(el);
|
|
@@ -2363,6 +2456,8 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
2363
2456
|
el.removeEventListener("change", onCompositionEnd);
|
|
2364
2457
|
};
|
|
2365
2458
|
const listener = (event) => {
|
|
2459
|
+
const modelRef = getModelRef();
|
|
2460
|
+
if (!modelRef) return;
|
|
2366
2461
|
const target = event.target;
|
|
2367
2462
|
if (!target || target.composing) return;
|
|
2368
2463
|
let value = target.value;
|
|
@@ -2394,12 +2489,14 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
|
|
|
2394
2489
|
el.addEventListener("change", onCompositionEnd);
|
|
2395
2490
|
return unbinder;
|
|
2396
2491
|
};
|
|
2397
|
-
var handleCheckBox = (el,
|
|
2492
|
+
var handleCheckBox = (el, getModelRef) => {
|
|
2398
2493
|
const eventType = "change";
|
|
2399
2494
|
const unbinder = () => {
|
|
2400
2495
|
el.removeEventListener(eventType, listener);
|
|
2401
2496
|
};
|
|
2402
2497
|
const listener = () => {
|
|
2498
|
+
const modelRef = getModelRef();
|
|
2499
|
+
if (!modelRef) return;
|
|
2403
2500
|
const elementValue = getValue(el);
|
|
2404
2501
|
const checked = el.checked;
|
|
2405
2502
|
const modelValue = modelRef();
|
|
@@ -2450,24 +2547,28 @@ var getCheckboxChecked = (el, value) => {
|
|
|
2450
2547
|
return looseEqual(value, el.getAttribute(attrKey));
|
|
2451
2548
|
return looseEqual(value, true);
|
|
2452
2549
|
};
|
|
2453
|
-
var handleRadio = (el,
|
|
2550
|
+
var handleRadio = (el, getModelRef) => {
|
|
2454
2551
|
const eventType = "change";
|
|
2455
2552
|
const unbinder = () => {
|
|
2456
2553
|
el.removeEventListener(eventType, listener);
|
|
2457
2554
|
};
|
|
2458
2555
|
const listener = () => {
|
|
2556
|
+
const modelRef = getModelRef();
|
|
2557
|
+
if (!modelRef) return;
|
|
2459
2558
|
const elementValue = getValue(el);
|
|
2460
2559
|
modelRef(elementValue);
|
|
2461
2560
|
};
|
|
2462
2561
|
el.addEventListener(eventType, listener);
|
|
2463
2562
|
return unbinder;
|
|
2464
2563
|
};
|
|
2465
|
-
var handleSelect = (el,
|
|
2564
|
+
var handleSelect = (el, getModelRef, parsedValue) => {
|
|
2466
2565
|
const eventType = "change";
|
|
2467
2566
|
const unbinder = () => {
|
|
2468
2567
|
el.removeEventListener(eventType, listener);
|
|
2469
2568
|
};
|
|
2470
2569
|
const listener = () => {
|
|
2570
|
+
const modelRef = getModelRef();
|
|
2571
|
+
if (!modelRef) return;
|
|
2471
2572
|
const flags = getFlags(parsedValue()[1]);
|
|
2472
2573
|
const number = flags.number;
|
|
2473
2574
|
const selectedValue = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
@@ -2905,45 +3006,6 @@ var valueDirective = {
|
|
|
2905
3006
|
}
|
|
2906
3007
|
};
|
|
2907
3008
|
|
|
2908
|
-
// src/reactivity/isDeepRef.ts
|
|
2909
|
-
var isDeepRef = (value) => {
|
|
2910
|
-
return (value == null ? void 0 : value[refSymbol]) === 1;
|
|
2911
|
-
};
|
|
2912
|
-
|
|
2913
|
-
// src/reactivity/ref.ts
|
|
2914
|
-
var ref = (value) => {
|
|
2915
|
-
if (isRaw(value)) return value;
|
|
2916
|
-
let result;
|
|
2917
|
-
if (isRef(value)) {
|
|
2918
|
-
result = value;
|
|
2919
|
-
value = result();
|
|
2920
|
-
} else {
|
|
2921
|
-
result = sref(value);
|
|
2922
|
-
}
|
|
2923
|
-
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
2924
|
-
return result;
|
|
2925
|
-
result[refSymbol] = 1;
|
|
2926
|
-
if (isArray(value)) {
|
|
2927
|
-
const len = value.length;
|
|
2928
|
-
for (let i = 0; i < len; ++i) {
|
|
2929
|
-
const item = value[i];
|
|
2930
|
-
if (isDeepRef(item)) continue;
|
|
2931
|
-
value[i] = ref(item);
|
|
2932
|
-
}
|
|
2933
|
-
return result;
|
|
2934
|
-
}
|
|
2935
|
-
if (!isObject(value)) return result;
|
|
2936
|
-
for (const item of Object.entries(value)) {
|
|
2937
|
-
const val = item[1];
|
|
2938
|
-
if (isDeepRef(val)) continue;
|
|
2939
|
-
const key = item[0];
|
|
2940
|
-
if (isSymbol(key)) continue;
|
|
2941
|
-
value[key] = null;
|
|
2942
|
-
value[key] = ref(val);
|
|
2943
|
-
}
|
|
2944
|
-
return result;
|
|
2945
|
-
};
|
|
2946
|
-
|
|
2947
3009
|
// src/app/RegorConfig.ts
|
|
2948
3010
|
var _RegorConfig = class _RegorConfig {
|
|
2949
3011
|
constructor(globalContext) {
|
|
@@ -4735,8 +4797,8 @@ var Parser = class {
|
|
|
4735
4797
|
stopObserverList.push(stopObserving);
|
|
4736
4798
|
}
|
|
4737
4799
|
}
|
|
4738
|
-
value(evaluated.map((x) => x.value));
|
|
4739
4800
|
result.refs = evaluated.map((x) => x.ref);
|
|
4801
|
+
value(evaluated.map((x) => x.value));
|
|
4740
4802
|
};
|
|
4741
4803
|
refresh();
|
|
4742
4804
|
} catch (e) {
|