regor 1.2.6 → 1.2.8
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 +550 -512
- package/dist/regor.es2015.cjs.prod.js +4 -4
- package/dist/regor.es2015.esm.js +550 -512
- package/dist/regor.es2015.esm.prod.js +4 -4
- package/dist/regor.es2015.iife.js +550 -512
- package/dist/regor.es2015.iife.prod.js +4 -4
- package/dist/regor.es2019.cjs.js +550 -512
- package/dist/regor.es2019.cjs.prod.js +4 -4
- package/dist/regor.es2019.esm.js +550 -512
- package/dist/regor.es2019.esm.prod.js +4 -4
- package/dist/regor.es2019.iife.js +550 -512
- package/dist/regor.es2019.iife.prod.js +4 -4
- package/dist/regor.es2022.cjs.js +546 -508
- package/dist/regor.es2022.cjs.prod.js +4 -4
- package/dist/regor.es2022.esm.js +546 -508
- package/dist/regor.es2022.esm.prod.js +4 -4
- package/dist/regor.es2022.iife.js +546 -508
- package/dist/regor.es2022.iife.prod.js +4 -4
- package/package.json +1 -1
package/dist/regor.es2015.esm.js
CHANGED
|
@@ -709,15 +709,344 @@ var entangle = (r1, r2) => {
|
|
|
709
709
|
};
|
|
710
710
|
};
|
|
711
711
|
|
|
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();
|
|
762
|
+
}
|
|
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();
|
|
772
|
+
}
|
|
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
|
+
|
|
712
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
|
+
};
|
|
713
1022
|
var singlePropDirective = {
|
|
714
1023
|
collectRefObj: true,
|
|
715
1024
|
onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
|
|
716
1025
|
if (!option) return () => {
|
|
717
1026
|
};
|
|
718
1027
|
const key = camelize(option);
|
|
1028
|
+
let currentSource;
|
|
1029
|
+
let bridge;
|
|
719
1030
|
let stopEntangle = () => {
|
|
720
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
|
+
};
|
|
721
1050
|
const stopObserving = observe(
|
|
722
1051
|
parseResult.value,
|
|
723
1052
|
() => {
|
|
@@ -725,24 +1054,31 @@ var singlePropDirective = {
|
|
|
725
1054
|
const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
|
|
726
1055
|
const ctx = parseResult.context;
|
|
727
1056
|
const ctxKey = ctx[key];
|
|
728
|
-
if (
|
|
729
|
-
|
|
1057
|
+
if (!isRef(value)) {
|
|
1058
|
+
if (bridge && ctxKey === bridge) {
|
|
1059
|
+
bridge(value);
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
resetSync();
|
|
730
1063
|
if (isRef(ctxKey)) {
|
|
731
|
-
|
|
732
|
-
stopEntangle = entangle(value, ctxKey);
|
|
1064
|
+
ctxKey(value);
|
|
733
1065
|
return;
|
|
734
1066
|
}
|
|
735
1067
|
ctx[key] = value;
|
|
736
1068
|
return;
|
|
737
1069
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
1070
|
+
if (isModelBridge(value)) {
|
|
1071
|
+
if (ctxKey === value) return;
|
|
1072
|
+
if (isRef(ctxKey)) {
|
|
1073
|
+
syncRefs(value, ctxKey);
|
|
1074
|
+
} else {
|
|
1075
|
+
ctx[key] = value;
|
|
1076
|
+
}
|
|
743
1077
|
return;
|
|
744
1078
|
}
|
|
745
|
-
|
|
1079
|
+
if (!bridge) bridge = createModelBridge(value);
|
|
1080
|
+
ctx[key] = bridge;
|
|
1081
|
+
syncRefs(value, bridge);
|
|
746
1082
|
},
|
|
747
1083
|
true
|
|
748
1084
|
);
|
|
@@ -993,486 +1329,227 @@ var ComponentBinder = class {
|
|
|
993
1329
|
} else {
|
|
994
1330
|
inheritor.setAttribute(
|
|
995
1331
|
normalizeAttributeName(attrName, binder.__config),
|
|
996
|
-
value
|
|
997
|
-
);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
};
|
|
1001
|
-
const clearUnusedAttributes = () => {
|
|
1002
|
-
for (const attrName of component.getAttributeNames()) {
|
|
1003
|
-
if (!attrName.startsWith("@") && !attrName.startsWith(binder.__config.__builtInNames.on))
|
|
1004
|
-
component.removeAttribute(attrName);
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
|
-
const bindComponent = () => {
|
|
1008
|
-
transferAttributesToTheComponentChild();
|
|
1009
|
-
clearUnusedAttributes();
|
|
1010
|
-
parser.__push(componentCtx);
|
|
1011
|
-
binder.__bindAttributes(component, false);
|
|
1012
|
-
componentCtx.$emit = head.emit;
|
|
1013
|
-
bindChildNodes(binder, childNodes);
|
|
1014
|
-
addUnbinder(component, () => {
|
|
1015
|
-
callUnmounted(componentCtx);
|
|
1016
|
-
});
|
|
1017
|
-
addUnbinder(startOfComponent, () => {
|
|
1018
|
-
unbind(component);
|
|
1019
|
-
});
|
|
1020
|
-
callMounted(componentCtx);
|
|
1021
|
-
};
|
|
1022
|
-
parser.__scoped(capturedContext, bindComponent);
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
};
|
|
1026
|
-
|
|
1027
|
-
// src/bind/DirectiveCollector.ts
|
|
1028
|
-
var DirectiveElement = class {
|
|
1029
|
-
constructor(name2) {
|
|
1030
|
-
__publicField(this, "__name");
|
|
1031
|
-
// 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
|
|
1032
|
-
/** Contains: `['@', 'submit'], ['r-on', 'click'], ['\\@', '[dynamicKey]']` */
|
|
1033
|
-
__publicField(this, "__terms", []);
|
|
1034
|
-
/** Contains directive flags. ['camel', 'prevent',...] */
|
|
1035
|
-
__publicField(this, "__flags", []);
|
|
1036
|
-
__publicField(this, "__elements", []);
|
|
1037
|
-
this.__name = name2;
|
|
1038
|
-
this.__parse();
|
|
1039
|
-
}
|
|
1040
|
-
__parse() {
|
|
1041
|
-
let name2 = this.__name;
|
|
1042
|
-
const isPropShortcut = name2.startsWith(".");
|
|
1043
|
-
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1044
|
-
const firstFlagIndex = name2.indexOf(".");
|
|
1045
|
-
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1046
|
-
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1047
|
-
if (firstFlagIndex >= 0) {
|
|
1048
|
-
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1049
|
-
if (flags.includes("camel")) {
|
|
1050
|
-
const index = terms.length - 1;
|
|
1051
|
-
terms[index] = camelize(terms[index]);
|
|
1052
|
-
}
|
|
1053
|
-
if (flags.includes("prop")) {
|
|
1054
|
-
terms[0] = ".";
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
};
|
|
1059
|
-
var DirectiveCollector = class {
|
|
1060
|
-
constructor(binder) {
|
|
1061
|
-
__publicField(this, "__binder");
|
|
1062
|
-
__publicField(this, "__prefixes");
|
|
1063
|
-
this.__binder = binder;
|
|
1064
|
-
this.__prefixes = binder.__config.__getPrefixes();
|
|
1065
|
-
}
|
|
1066
|
-
__collect(element, isRecursive) {
|
|
1067
|
-
const map = /* @__PURE__ */ new Map();
|
|
1068
|
-
if (!isHTMLElement(element)) return map;
|
|
1069
|
-
const prefixes2 = this.__prefixes;
|
|
1070
|
-
const processNode = (node) => {
|
|
1071
|
-
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1072
|
-
for (const name2 of names) {
|
|
1073
|
-
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1074
|
-
const item = map.get(name2);
|
|
1075
|
-
item.__elements.push(node);
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
processNode(element);
|
|
1079
|
-
if (!isRecursive) return map;
|
|
1080
|
-
const nodes = element.querySelectorAll("*");
|
|
1081
|
-
for (const node of nodes) {
|
|
1082
|
-
processNode(node);
|
|
1083
|
-
}
|
|
1084
|
-
return map;
|
|
1085
|
-
}
|
|
1086
|
-
};
|
|
1087
|
-
|
|
1088
|
-
// src/bind/DynamicBinder.ts
|
|
1089
|
-
var mount2 = (nodes, parent) => {
|
|
1090
|
-
for (const x of nodes) {
|
|
1091
|
-
const node = x.cloneNode(true);
|
|
1092
|
-
parent.appendChild(node);
|
|
1093
|
-
}
|
|
1094
|
-
};
|
|
1095
|
-
var DynamicBinder = class {
|
|
1096
|
-
constructor(binder) {
|
|
1097
|
-
__publicField(this, "__binder");
|
|
1098
|
-
__publicField(this, "__is");
|
|
1099
|
-
__publicField(this, "__isSelector");
|
|
1100
|
-
this.__binder = binder;
|
|
1101
|
-
this.__is = binder.__config.__builtInNames.is;
|
|
1102
|
-
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1103
|
-
}
|
|
1104
|
-
__bindAll(element) {
|
|
1105
|
-
const isComponentElement = element.hasAttribute(this.__is);
|
|
1106
|
-
const elements = findElements(element, this.__isSelector);
|
|
1107
|
-
for (const el of elements) {
|
|
1108
|
-
this.__bind(el);
|
|
1109
|
-
}
|
|
1110
|
-
return isComponentElement;
|
|
1111
|
-
}
|
|
1112
|
-
__bind(el) {
|
|
1113
|
-
let expression = el.getAttribute(this.__is);
|
|
1114
|
-
if (!expression) {
|
|
1115
|
-
expression = el.getAttribute("is");
|
|
1116
|
-
if (!expression) return;
|
|
1117
|
-
if (!expression.startsWith("regor:")) {
|
|
1118
|
-
if (!expression.startsWith("r-")) return;
|
|
1119
|
-
const staticName = expression.slice(2).trim().toLowerCase();
|
|
1120
|
-
if (!staticName) return;
|
|
1121
|
-
const parent = el.parentNode;
|
|
1122
|
-
if (!parent) return;
|
|
1123
|
-
const nativeElement = document.createElement(staticName);
|
|
1124
|
-
for (const attr of el.getAttributeNames()) {
|
|
1125
|
-
if (attr === "is") continue;
|
|
1126
|
-
nativeElement.setAttribute(attr, el.getAttribute(attr));
|
|
1127
|
-
}
|
|
1128
|
-
while (el.firstChild) nativeElement.appendChild(el.firstChild);
|
|
1129
|
-
parent.insertBefore(nativeElement, el);
|
|
1130
|
-
el.remove();
|
|
1131
|
-
this.__binder.__bindDefault(nativeElement);
|
|
1132
|
-
return;
|
|
1133
|
-
}
|
|
1134
|
-
expression = `'${expression.slice(6)}'`;
|
|
1135
|
-
el.removeAttribute("is");
|
|
1136
|
-
}
|
|
1137
|
-
el.removeAttribute(this.__is);
|
|
1138
|
-
this.__bindToExpression(el, expression);
|
|
1139
|
-
}
|
|
1140
|
-
__createRegion(el, expression) {
|
|
1141
|
-
const nodes = getNodes(el);
|
|
1142
|
-
const parent = el.parentNode;
|
|
1143
|
-
const commentBegin = document.createComment(
|
|
1144
|
-
`__begin__ dynamic ${expression != null ? expression : ""}`
|
|
1145
|
-
);
|
|
1146
|
-
parent.insertBefore(commentBegin, el);
|
|
1147
|
-
setSwitchOwner(commentBegin, nodes);
|
|
1148
|
-
nodes.forEach((x) => {
|
|
1149
|
-
removeNode(x);
|
|
1150
|
-
});
|
|
1151
|
-
el.remove();
|
|
1152
|
-
const commentEnd = document.createComment(
|
|
1153
|
-
`__end__ dynamic ${expression != null ? expression : ""}`
|
|
1154
|
-
);
|
|
1155
|
-
parent.insertBefore(commentEnd, commentBegin.nextSibling);
|
|
1156
|
-
return {
|
|
1157
|
-
nodes,
|
|
1158
|
-
parent,
|
|
1159
|
-
commentBegin,
|
|
1160
|
-
commentEnd
|
|
1161
|
-
};
|
|
1162
|
-
}
|
|
1163
|
-
__bindToExpression(el, expression) {
|
|
1164
|
-
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
1165
|
-
el,
|
|
1166
|
-
` => ${expression} `
|
|
1167
|
-
);
|
|
1168
|
-
const parseResult = this.__binder.__parser.__parse(expression);
|
|
1169
|
-
const value = parseResult.value;
|
|
1170
|
-
const parser = this.__binder.__parser;
|
|
1171
|
-
const capturedContext = parser.__capture();
|
|
1172
|
-
const mounted = { name: "" };
|
|
1173
|
-
const componentChildNodes = isTemplate(el) ? nodes : [...nodes[0].childNodes];
|
|
1174
|
-
const refresh = () => {
|
|
1175
|
-
parser.__scoped(capturedContext, () => {
|
|
1176
|
-
var _a;
|
|
1177
|
-
let name2 = value()[0];
|
|
1178
|
-
if (isObject(name2)) {
|
|
1179
|
-
if (!name2.name) {
|
|
1180
|
-
name2 = (_a = Object.entries(parser.__getComponents()).filter(
|
|
1181
|
-
(x) => x[1] === name2
|
|
1182
|
-
)[0]) == null ? void 0 : _a[0];
|
|
1183
|
-
} else {
|
|
1184
|
-
name2 = name2.name;
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
if (!isString(name2) || isNullOrWhitespace(name2)) {
|
|
1188
|
-
unmount(commentBegin, commentEnd);
|
|
1189
|
-
return;
|
|
1332
|
+
value
|
|
1333
|
+
);
|
|
1334
|
+
}
|
|
1190
1335
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1336
|
+
};
|
|
1337
|
+
const clearUnusedAttributes = () => {
|
|
1338
|
+
for (const attrName of component.getAttributeNames()) {
|
|
1339
|
+
if (!attrName.startsWith("@") && !attrName.startsWith(binder.__config.__builtInNames.on))
|
|
1340
|
+
component.removeAttribute(attrName);
|
|
1197
1341
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
stopObserverList.push(stopObserving);
|
|
1216
|
-
}
|
|
1217
|
-
};
|
|
1218
|
-
|
|
1219
|
-
// src/computed/watchEffect.ts
|
|
1220
|
-
var collectedRefs = [];
|
|
1221
|
-
var collectRef = (ref2) => {
|
|
1222
|
-
var _a;
|
|
1223
|
-
if (collectedRefs.length === 0) return;
|
|
1224
|
-
(_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
|
|
1225
|
-
};
|
|
1226
|
-
var watchEffect = (effect) => {
|
|
1227
|
-
if (!effect) return () => {
|
|
1228
|
-
};
|
|
1229
|
-
const terminator = { stop: () => {
|
|
1230
|
-
} };
|
|
1231
|
-
watchEffectInternal(effect, terminator);
|
|
1232
|
-
onUnmounted(() => terminator.stop(), true);
|
|
1233
|
-
return terminator.stop;
|
|
1234
|
-
};
|
|
1235
|
-
var watchEffectInternal = (effect, terminator) => {
|
|
1236
|
-
if (!effect) return;
|
|
1237
|
-
let stopObservingList = [];
|
|
1238
|
-
let isStopped = false;
|
|
1239
|
-
const stopWatch = () => {
|
|
1240
|
-
for (const stop of stopObservingList) stop();
|
|
1241
|
-
stopObservingList = [];
|
|
1242
|
-
isStopped = true;
|
|
1243
|
-
};
|
|
1244
|
-
terminator.stop = stopWatch;
|
|
1245
|
-
try {
|
|
1246
|
-
const set = /* @__PURE__ */ new Set();
|
|
1247
|
-
collectedRefs.push(set);
|
|
1248
|
-
effect((onCleanup) => stopObservingList.push(onCleanup));
|
|
1249
|
-
if (isStopped) return;
|
|
1250
|
-
for (const r of [...set]) {
|
|
1251
|
-
const stopObserving = observe(r, () => {
|
|
1252
|
-
stopWatch();
|
|
1253
|
-
watchEffect(effect);
|
|
1254
|
-
});
|
|
1255
|
-
stopObservingList.push(stopObserving);
|
|
1342
|
+
};
|
|
1343
|
+
const bindComponent = () => {
|
|
1344
|
+
transferAttributesToTheComponentChild();
|
|
1345
|
+
clearUnusedAttributes();
|
|
1346
|
+
parser.__push(componentCtx);
|
|
1347
|
+
binder.__bindAttributes(component, false);
|
|
1348
|
+
componentCtx.$emit = head.emit;
|
|
1349
|
+
bindChildNodes(binder, childNodes);
|
|
1350
|
+
addUnbinder(component, () => {
|
|
1351
|
+
callUnmounted(componentCtx);
|
|
1352
|
+
});
|
|
1353
|
+
addUnbinder(startOfComponent, () => {
|
|
1354
|
+
unbind(component);
|
|
1355
|
+
});
|
|
1356
|
+
callMounted(componentCtx);
|
|
1357
|
+
};
|
|
1358
|
+
parser.__scoped(capturedContext, bindComponent);
|
|
1256
1359
|
}
|
|
1257
|
-
} finally {
|
|
1258
|
-
collectedRefs.pop();
|
|
1259
|
-
}
|
|
1260
|
-
};
|
|
1261
|
-
var silence = (action) => {
|
|
1262
|
-
const len = collectedRefs.length;
|
|
1263
|
-
const hasPush = len > 0 && collectedRefs[len - 1];
|
|
1264
|
-
try {
|
|
1265
|
-
if (hasPush) collectedRefs.push(null);
|
|
1266
|
-
return action();
|
|
1267
|
-
} finally {
|
|
1268
|
-
if (hasPush) collectedRefs.pop();
|
|
1269
|
-
}
|
|
1270
|
-
};
|
|
1271
|
-
var collectRefs = (action) => {
|
|
1272
|
-
try {
|
|
1273
|
-
const set = /* @__PURE__ */ new Set();
|
|
1274
|
-
collectedRefs.push(set);
|
|
1275
|
-
const result = action();
|
|
1276
|
-
return { value: result, refs: [...set] };
|
|
1277
|
-
} finally {
|
|
1278
|
-
collectedRefs.pop();
|
|
1279
1360
|
}
|
|
1280
1361
|
};
|
|
1281
1362
|
|
|
1282
|
-
// src/
|
|
1283
|
-
var
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
if (!obj) return;
|
|
1295
|
-
if (isArray(obj) || isSet(obj)) {
|
|
1296
|
-
for (const el of obj) {
|
|
1297
|
-
trigger(el, eventSource, true);
|
|
1298
|
-
}
|
|
1299
|
-
} else if (isMap(obj)) {
|
|
1300
|
-
for (const el of obj) {
|
|
1301
|
-
trigger(el[0], eventSource, true);
|
|
1302
|
-
trigger(el[1], eventSource, true);
|
|
1303
|
-
}
|
|
1363
|
+
// src/bind/DirectiveCollector.ts
|
|
1364
|
+
var DirectiveElement = class {
|
|
1365
|
+
constructor(name2) {
|
|
1366
|
+
__publicField(this, "__name");
|
|
1367
|
+
// 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
|
|
1368
|
+
/** Contains: `['@', 'submit'], ['r-on', 'click'], ['\\@', '[dynamicKey]']` */
|
|
1369
|
+
__publicField(this, "__terms", []);
|
|
1370
|
+
/** Contains directive flags. ['camel', 'prevent',...] */
|
|
1371
|
+
__publicField(this, "__flags", []);
|
|
1372
|
+
__publicField(this, "__elements", []);
|
|
1373
|
+
this.__name = name2;
|
|
1374
|
+
this.__parse();
|
|
1304
1375
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1376
|
+
__parse() {
|
|
1377
|
+
let name2 = this.__name;
|
|
1378
|
+
const isPropShortcut = name2.startsWith(".");
|
|
1379
|
+
if (isPropShortcut) name2 = ":" + name2.slice(1);
|
|
1380
|
+
const firstFlagIndex = name2.indexOf(".");
|
|
1381
|
+
const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
|
|
1382
|
+
if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
|
|
1383
|
+
if (firstFlagIndex >= 0) {
|
|
1384
|
+
const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
|
|
1385
|
+
if (flags.includes("camel")) {
|
|
1386
|
+
const index = terms.length - 1;
|
|
1387
|
+
terms[index] = camelize(terms[index]);
|
|
1388
|
+
}
|
|
1389
|
+
if (flags.includes("prop")) {
|
|
1390
|
+
terms[0] = ".";
|
|
1391
|
+
}
|
|
1308
1392
|
}
|
|
1309
1393
|
}
|
|
1310
1394
|
};
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
writable: false,
|
|
1336
|
-
enumerable: false,
|
|
1337
|
-
configurable: true
|
|
1338
|
-
});
|
|
1339
|
-
};
|
|
1340
|
-
|
|
1341
|
-
// src/proxies/array-ref.ts
|
|
1342
|
-
var arrayProto = Array.prototype;
|
|
1343
|
-
var proxyArrayProto = Object.create(arrayProto);
|
|
1344
|
-
var methodsToPatch = [
|
|
1345
|
-
"push",
|
|
1346
|
-
"pop",
|
|
1347
|
-
"shift",
|
|
1348
|
-
"unshift",
|
|
1349
|
-
"splice",
|
|
1350
|
-
"sort",
|
|
1351
|
-
"reverse"
|
|
1352
|
-
];
|
|
1353
|
-
createProxy(arrayProto, proxyArrayProto, methodsToPatch);
|
|
1354
|
-
|
|
1355
|
-
// src/proxies/map-ref.ts
|
|
1356
|
-
var mapProto = Map.prototype;
|
|
1357
|
-
var proxyMapProto = Object.create(mapProto);
|
|
1358
|
-
var methodsToPatch2 = ["set", "clear", "delete"];
|
|
1359
|
-
setToStringTag(proxyMapProto, "Map");
|
|
1360
|
-
createProxy(mapProto, proxyMapProto, methodsToPatch2);
|
|
1361
|
-
|
|
1362
|
-
// src/proxies/set-ref.ts
|
|
1363
|
-
var setProto = Set.prototype;
|
|
1364
|
-
var proxySetProto = Object.create(setProto);
|
|
1365
|
-
var methodsToPatch3 = ["add", "clear", "delete"];
|
|
1366
|
-
setToStringTag(proxySetProto, "Set");
|
|
1367
|
-
createProxy(setProto, proxySetProto, methodsToPatch3);
|
|
1368
|
-
|
|
1369
|
-
// src/reactivity/sref.ts
|
|
1370
|
-
var batchCollector = {};
|
|
1371
|
-
var sref = (value) => {
|
|
1372
|
-
if (isRef(value) || isRaw(value)) return value;
|
|
1373
|
-
const refObj = {
|
|
1374
|
-
auto: true,
|
|
1375
|
-
_value: value
|
|
1376
|
-
};
|
|
1377
|
-
const createProxy2 = (value2) => {
|
|
1378
|
-
if (!isObject(value2)) return false;
|
|
1379
|
-
if (srefSymbol in value2) return true;
|
|
1380
|
-
const isAnArray = isArray(value2);
|
|
1381
|
-
if (isAnArray) {
|
|
1382
|
-
Object.setPrototypeOf(value2, proxyArrayProto);
|
|
1383
|
-
return true;
|
|
1384
|
-
}
|
|
1385
|
-
const isASet = isSet(value2);
|
|
1386
|
-
if (isASet) {
|
|
1387
|
-
Object.setPrototypeOf(value2, proxySetProto);
|
|
1388
|
-
return true;
|
|
1389
|
-
}
|
|
1390
|
-
const isAMap = isMap(value2);
|
|
1391
|
-
if (isAMap) {
|
|
1392
|
-
Object.setPrototypeOf(value2, proxyMapProto);
|
|
1393
|
-
return true;
|
|
1395
|
+
var DirectiveCollector = class {
|
|
1396
|
+
constructor(binder) {
|
|
1397
|
+
__publicField(this, "__binder");
|
|
1398
|
+
__publicField(this, "__prefixes");
|
|
1399
|
+
this.__binder = binder;
|
|
1400
|
+
this.__prefixes = binder.__config.__getPrefixes();
|
|
1401
|
+
}
|
|
1402
|
+
__collect(element, isRecursive) {
|
|
1403
|
+
const map = /* @__PURE__ */ new Map();
|
|
1404
|
+
if (!isHTMLElement(element)) return map;
|
|
1405
|
+
const prefixes2 = this.__prefixes;
|
|
1406
|
+
const processNode = (node) => {
|
|
1407
|
+
const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
|
|
1408
|
+
for (const name2 of names) {
|
|
1409
|
+
if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
|
|
1410
|
+
const item = map.get(name2);
|
|
1411
|
+
item.__elements.push(node);
|
|
1412
|
+
}
|
|
1413
|
+
};
|
|
1414
|
+
processNode(element);
|
|
1415
|
+
if (!isRecursive) return map;
|
|
1416
|
+
const nodes = element.querySelectorAll("*");
|
|
1417
|
+
for (const node of nodes) {
|
|
1418
|
+
processNode(node);
|
|
1394
1419
|
}
|
|
1395
|
-
return
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1420
|
+
return map;
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
// src/bind/DynamicBinder.ts
|
|
1425
|
+
var mount2 = (nodes, parent) => {
|
|
1426
|
+
for (const x of nodes) {
|
|
1427
|
+
const node = x.cloneNode(true);
|
|
1428
|
+
parent.appendChild(node);
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
var DynamicBinder = class {
|
|
1432
|
+
constructor(binder) {
|
|
1433
|
+
__publicField(this, "__binder");
|
|
1434
|
+
__publicField(this, "__is");
|
|
1435
|
+
__publicField(this, "__isSelector");
|
|
1436
|
+
this.__binder = binder;
|
|
1437
|
+
this.__is = binder.__config.__builtInNames.is;
|
|
1438
|
+
this.__isSelector = toSelector(this.__is) + ", [is]";
|
|
1439
|
+
}
|
|
1440
|
+
__bindAll(element) {
|
|
1441
|
+
const isComponentElement = element.hasAttribute(this.__is);
|
|
1442
|
+
const elements = findElements(element, this.__isSelector);
|
|
1443
|
+
for (const el of elements) {
|
|
1444
|
+
this.__bind(el);
|
|
1404
1445
|
}
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1446
|
+
return isComponentElement;
|
|
1447
|
+
}
|
|
1448
|
+
__bind(el) {
|
|
1449
|
+
let expression = el.getAttribute(this.__is);
|
|
1450
|
+
if (!expression) {
|
|
1451
|
+
expression = el.getAttribute("is");
|
|
1452
|
+
if (!expression) return;
|
|
1453
|
+
if (!expression.startsWith("regor:")) {
|
|
1454
|
+
if (!expression.startsWith("r-")) return;
|
|
1455
|
+
const staticName = expression.slice(2).trim().toLowerCase();
|
|
1456
|
+
if (!staticName) return;
|
|
1457
|
+
const parent = el.parentNode;
|
|
1458
|
+
if (!parent) return;
|
|
1459
|
+
const nativeElement = document.createElement(staticName);
|
|
1460
|
+
for (const attr of el.getAttributeNames()) {
|
|
1461
|
+
if (attr === "is") continue;
|
|
1462
|
+
nativeElement.setAttribute(attr, el.getAttribute(attr));
|
|
1463
|
+
}
|
|
1464
|
+
while (el.firstChild) nativeElement.appendChild(el.firstChild);
|
|
1465
|
+
parent.insertBefore(nativeElement, el);
|
|
1466
|
+
el.remove();
|
|
1467
|
+
this.__binder.__bindDefault(nativeElement);
|
|
1468
|
+
return;
|
|
1410
1469
|
}
|
|
1470
|
+
expression = `'${expression.slice(6)}'`;
|
|
1471
|
+
el.removeAttribute("is");
|
|
1472
|
+
}
|
|
1473
|
+
el.removeAttribute(this.__is);
|
|
1474
|
+
this.__bindToExpression(el, expression);
|
|
1475
|
+
}
|
|
1476
|
+
__createRegion(el, expression) {
|
|
1477
|
+
const nodes = getNodes(el);
|
|
1478
|
+
const parent = el.parentNode;
|
|
1479
|
+
const commentBegin = document.createComment(
|
|
1480
|
+
`__begin__ dynamic ${expression != null ? expression : ""}`
|
|
1481
|
+
);
|
|
1482
|
+
parent.insertBefore(commentBegin, el);
|
|
1483
|
+
setSwitchOwner(commentBegin, nodes);
|
|
1484
|
+
nodes.forEach((x) => {
|
|
1485
|
+
removeNode(x);
|
|
1411
1486
|
});
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1487
|
+
el.remove();
|
|
1488
|
+
const commentEnd = document.createComment(
|
|
1489
|
+
`__end__ dynamic ${expression != null ? expression : ""}`
|
|
1490
|
+
);
|
|
1491
|
+
parent.insertBefore(commentEnd, commentBegin.nextSibling);
|
|
1492
|
+
return {
|
|
1493
|
+
nodes,
|
|
1494
|
+
parent,
|
|
1495
|
+
commentBegin,
|
|
1496
|
+
commentEnd
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
__bindToExpression(el, expression) {
|
|
1500
|
+
const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
|
|
1501
|
+
el,
|
|
1502
|
+
` => ${expression} `
|
|
1503
|
+
);
|
|
1504
|
+
const parseResult = this.__binder.__parser.__parse(expression);
|
|
1505
|
+
const value = parseResult.value;
|
|
1506
|
+
const parser = this.__binder.__parser;
|
|
1507
|
+
const capturedContext = parser.__capture();
|
|
1508
|
+
const mounted = { name: "" };
|
|
1509
|
+
const componentChildNodes = isTemplate(el) ? nodes : [...nodes[0].childNodes];
|
|
1510
|
+
const refresh = () => {
|
|
1511
|
+
parser.__scoped(capturedContext, () => {
|
|
1512
|
+
var _a;
|
|
1513
|
+
let name2 = value()[0];
|
|
1514
|
+
if (isObject(name2)) {
|
|
1515
|
+
if (!name2.name) {
|
|
1516
|
+
name2 = (_a = Object.entries(parser.__getComponents()).filter(
|
|
1517
|
+
(x) => x[1] === name2
|
|
1518
|
+
)[0]) == null ? void 0 : _a[0];
|
|
1519
|
+
} else {
|
|
1520
|
+
name2 = name2.name;
|
|
1521
|
+
}
|
|
1427
1522
|
}
|
|
1428
|
-
if (
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
trigger2(newValue, eventSource);
|
|
1523
|
+
if (!isString(name2) || isNullOrWhitespace(name2)) {
|
|
1524
|
+
unmount(commentBegin, commentEnd);
|
|
1525
|
+
return;
|
|
1432
1526
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
};
|
|
1452
|
-
}
|
|
1453
|
-
case 1 /* trigger */: {
|
|
1454
|
-
const eventSource = args[1];
|
|
1455
|
-
const value2 = refObj._value;
|
|
1456
|
-
trigger2(value2, eventSource);
|
|
1457
|
-
break;
|
|
1458
|
-
}
|
|
1459
|
-
case 2 /* observerCount */: {
|
|
1460
|
-
return observers.size;
|
|
1461
|
-
}
|
|
1462
|
-
case 3 /* pause */: {
|
|
1463
|
-
refObj.auto = false;
|
|
1464
|
-
break;
|
|
1465
|
-
}
|
|
1466
|
-
case 4 /* resume */: {
|
|
1467
|
-
refObj.auto = true;
|
|
1527
|
+
if (mounted.name === name2) return;
|
|
1528
|
+
unmount(commentBegin, commentEnd);
|
|
1529
|
+
const componentElement = document.createElement(name2);
|
|
1530
|
+
for (const attr of el.getAttributeNames()) {
|
|
1531
|
+
if (attr === this.__is) continue;
|
|
1532
|
+
componentElement.setAttribute(attr, el.getAttribute(attr));
|
|
1533
|
+
}
|
|
1534
|
+
mount2(componentChildNodes, componentElement);
|
|
1535
|
+
parent.insertBefore(componentElement, commentEnd);
|
|
1536
|
+
this.__binder.__bindDefault(componentElement);
|
|
1537
|
+
mounted.name = name2;
|
|
1538
|
+
});
|
|
1539
|
+
};
|
|
1540
|
+
const stopObserverList = [];
|
|
1541
|
+
const unbinder = () => {
|
|
1542
|
+
parseResult.stop();
|
|
1543
|
+
for (const stopObserver of stopObserverList) {
|
|
1544
|
+
stopObserver();
|
|
1468
1545
|
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1546
|
+
stopObserverList.length = 0;
|
|
1547
|
+
};
|
|
1548
|
+
addUnbinder(commentBegin, unbinder);
|
|
1549
|
+
refresh();
|
|
1550
|
+
const stopObserving = observe(value, refresh);
|
|
1551
|
+
stopObserverList.push(stopObserving);
|
|
1552
|
+
}
|
|
1476
1553
|
};
|
|
1477
1554
|
|
|
1478
1555
|
// src/reactivity/unref.ts
|
|
@@ -2930,45 +3007,6 @@ var valueDirective = {
|
|
|
2930
3007
|
}
|
|
2931
3008
|
};
|
|
2932
3009
|
|
|
2933
|
-
// src/reactivity/isDeepRef.ts
|
|
2934
|
-
var isDeepRef = (value) => {
|
|
2935
|
-
return (value == null ? void 0 : value[refSymbol]) === 1;
|
|
2936
|
-
};
|
|
2937
|
-
|
|
2938
|
-
// src/reactivity/ref.ts
|
|
2939
|
-
var ref = (value) => {
|
|
2940
|
-
if (isRaw(value)) return value;
|
|
2941
|
-
let result;
|
|
2942
|
-
if (isRef(value)) {
|
|
2943
|
-
result = value;
|
|
2944
|
-
value = result();
|
|
2945
|
-
} else {
|
|
2946
|
-
result = sref(value);
|
|
2947
|
-
}
|
|
2948
|
-
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
2949
|
-
return result;
|
|
2950
|
-
result[refSymbol] = 1;
|
|
2951
|
-
if (isArray(value)) {
|
|
2952
|
-
const len = value.length;
|
|
2953
|
-
for (let i = 0; i < len; ++i) {
|
|
2954
|
-
const item = value[i];
|
|
2955
|
-
if (isDeepRef(item)) continue;
|
|
2956
|
-
value[i] = ref(item);
|
|
2957
|
-
}
|
|
2958
|
-
return result;
|
|
2959
|
-
}
|
|
2960
|
-
if (!isObject(value)) return result;
|
|
2961
|
-
for (const item of Object.entries(value)) {
|
|
2962
|
-
const val = item[1];
|
|
2963
|
-
if (isDeepRef(val)) continue;
|
|
2964
|
-
const key = item[0];
|
|
2965
|
-
if (isSymbol(key)) continue;
|
|
2966
|
-
value[key] = null;
|
|
2967
|
-
value[key] = ref(val);
|
|
2968
|
-
}
|
|
2969
|
-
return result;
|
|
2970
|
-
};
|
|
2971
|
-
|
|
2972
3010
|
// src/app/RegorConfig.ts
|
|
2973
3011
|
var _RegorConfig = class _RegorConfig {
|
|
2974
3012
|
constructor(globalContext) {
|