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