aoye 0.0.61 → 0.0.62
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/aoye.cjs.js +43 -7
- package/dist/aoye.cjs.js.map +1 -1
- package/dist/aoye.esm.js +41 -9
- package/dist/aoye.esm.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.umd.js +43 -7
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/aoye.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isNatureNumStr } from 'bobe-shared';
|
|
1
|
+
import { hasOwn, getPropertyDescriptorInChain, isNatureNumStr } from 'bobe-shared';
|
|
2
2
|
|
|
3
3
|
let _execId = 0;
|
|
4
4
|
let currentExecId = 0;
|
|
@@ -937,7 +937,8 @@ const deepSignal = (target, scope, deep = true) => {
|
|
|
937
937
|
const meta = {
|
|
938
938
|
deep,
|
|
939
939
|
scope,
|
|
940
|
-
cells
|
|
940
|
+
cells,
|
|
941
|
+
backup: null
|
|
941
942
|
};
|
|
942
943
|
const shared = createSharedHandler(cells, scope, deep, targetIsMap);
|
|
943
944
|
const specific = targetIsMap ? createMapHandler(cells, scope, deep) : createSetHandler(cells, scope);
|
|
@@ -969,7 +970,8 @@ const deepSignal = (target, scope, deep = true) => {
|
|
|
969
970
|
const meta = {
|
|
970
971
|
deep,
|
|
971
972
|
scope,
|
|
972
|
-
cells
|
|
973
|
+
cells,
|
|
974
|
+
backup: null
|
|
973
975
|
};
|
|
974
976
|
const proxy = new Proxy(target, {
|
|
975
977
|
get(obj, prop, receiver) {
|
|
@@ -979,11 +981,18 @@ const deepSignal = (target, scope, deep = true) => {
|
|
|
979
981
|
case Keys.Meta:
|
|
980
982
|
return meta;
|
|
981
983
|
}
|
|
984
|
+
const hasP = Reflect.has(obj, prop) || cells.has(prop);
|
|
985
|
+
if (!hasP) {
|
|
986
|
+
const backup = findValidBackup(receiver, prop);
|
|
987
|
+
if (backup) {
|
|
988
|
+
return backup[prop];
|
|
989
|
+
}
|
|
990
|
+
}
|
|
982
991
|
if (prop === Symbol.unscopables) return Reflect.get(obj, prop, receiver);
|
|
983
992
|
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
|
|
984
993
|
return Reflect.get(obj, prop, receiver);
|
|
985
994
|
}
|
|
986
|
-
const desc =
|
|
995
|
+
const desc = getPropertyDescriptorInChain(obj, prop);
|
|
987
996
|
const isGetter = desc && typeof desc.get === 'function';
|
|
988
997
|
if (isGetter) {
|
|
989
998
|
return handleGetterAsComputed(obj, prop, receiver, cells, scope);
|
|
@@ -994,7 +1003,7 @@ const deepSignal = (target, scope, deep = true) => {
|
|
|
994
1003
|
if (targetIsArray) {
|
|
995
1004
|
return arrayMethodReWrites[prop] || value;
|
|
996
1005
|
} else {
|
|
997
|
-
if (!
|
|
1006
|
+
if (!hasOwn(obj, prop)) {
|
|
998
1007
|
return value;
|
|
999
1008
|
}
|
|
1000
1009
|
let s = cells.get(prop);
|
|
@@ -1018,6 +1027,14 @@ const deepSignal = (target, scope, deep = true) => {
|
|
|
1018
1027
|
return s.get();
|
|
1019
1028
|
},
|
|
1020
1029
|
set(obj, prop, value, receiver) {
|
|
1030
|
+
const hasP = Reflect.has(obj, prop) || cells.has(prop);
|
|
1031
|
+
if (!hasP) {
|
|
1032
|
+
const backup = findValidBackup(receiver, prop);
|
|
1033
|
+
if (backup) {
|
|
1034
|
+
backup[prop] = value;
|
|
1035
|
+
return true;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1021
1038
|
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
|
|
1022
1039
|
return Reflect.set(obj, prop, value, receiver);
|
|
1023
1040
|
}
|
|
@@ -1040,7 +1057,7 @@ const deepSignal = (target, scope, deep = true) => {
|
|
|
1040
1057
|
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
|
|
1041
1058
|
return Reflect.deleteProperty(obj, prop);
|
|
1042
1059
|
}
|
|
1043
|
-
if (typeof obj[prop] === 'function' && !
|
|
1060
|
+
if (typeof obj[prop] === 'function' && !hasOwn(obj, prop)) {
|
|
1044
1061
|
return Reflect.deleteProperty(obj, prop);
|
|
1045
1062
|
}
|
|
1046
1063
|
cells.delete(prop);
|
|
@@ -1062,6 +1079,21 @@ const deepSignal = (target, scope, deep = true) => {
|
|
|
1062
1079
|
rawToProxy.set(target, proxy);
|
|
1063
1080
|
return proxy;
|
|
1064
1081
|
};
|
|
1082
|
+
const backupSignal = (child, parent) => {
|
|
1083
|
+
child[Keys.Meta].backup = parent;
|
|
1084
|
+
};
|
|
1085
|
+
const findValidBackup = (child, key) => {
|
|
1086
|
+
let backup = child[Keys.Meta].backup;
|
|
1087
|
+
while (backup) {
|
|
1088
|
+
if (proxyHasKey(backup, key)) {
|
|
1089
|
+
return backup;
|
|
1090
|
+
}
|
|
1091
|
+
backup = backup[Keys.Meta].backup;
|
|
1092
|
+
}
|
|
1093
|
+
return null;
|
|
1094
|
+
};
|
|
1095
|
+
const getProxyHasKey = (proxy, key) => proxyHasKey(proxy, key) ? proxy : findValidBackup(proxy, key);
|
|
1096
|
+
const proxyHasKey = (proxy, key) => Reflect.has(proxy[Keys.Raw], key) || proxy[Keys.Meta].cells.has(key);
|
|
1065
1097
|
const shareSignal = (from, fromPath, to, toPath) => {
|
|
1066
1098
|
try {
|
|
1067
1099
|
const toPaths = toPath.split('.');
|
|
@@ -1352,8 +1384,8 @@ const GetMethodConf = {
|
|
|
1352
1384
|
...GetMethodConf
|
|
1353
1385
|
}, {
|
|
1354
1386
|
key: 'find',
|
|
1355
|
-
|
|
1356
|
-
|
|
1387
|
+
...GetMethodConf,
|
|
1388
|
+
wrapReturn: true
|
|
1357
1389
|
}, {
|
|
1358
1390
|
key: 'findLast',
|
|
1359
1391
|
...GetMethodConf,
|
|
@@ -1604,5 +1636,5 @@ function scope(...args) {
|
|
|
1604
1636
|
return run;
|
|
1605
1637
|
}
|
|
1606
1638
|
|
|
1607
|
-
export { $, Computed, Effect, EffectStrType2Enum, IsStore, Keys, NoopEffect, ScheduleStatus, ScheduleType, Scope, Signal, Store, StoreIgnoreKeys, batchDeep, batchEnd, batchStart, clean, deepSignal, effect, effectUt, execId, execIdInc, flushMicroEffectManual, getPulling, ide, isStore, macro, micro, noopEffect, now, runWithPulling, scope, setExecId, setPulling, shareSignal, toRaw };
|
|
1639
|
+
export { $, Computed, Effect, EffectStrType2Enum, IsStore, Keys, NoopEffect, ScheduleStatus, ScheduleType, Scope, Signal, Store, StoreIgnoreKeys, backupSignal, batchDeep, batchEnd, batchStart, clean, deepSignal, effect, effectUt, execId, execIdInc, findValidBackup, flushMicroEffectManual, getProxyHasKey, getPulling, ide, isStore, macro, micro, noopEffect, now, proxyHasKey, runWithPulling, scope, setExecId, setPulling, shareSignal, toRaw };
|
|
1608
1640
|
//# sourceMappingURL=aoye.esm.js.map
|