aoye 0.0.61 → 0.0.63
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/index.d.ts
CHANGED
|
@@ -230,6 +230,10 @@ declare const micro: (cb: () => any) => void;
|
|
|
230
230
|
declare const toRaw: <T>(a: T) => any;
|
|
231
231
|
|
|
232
232
|
declare const deepSignal: <T>(target: T, scope: Scope, deep?: boolean) => any;
|
|
233
|
+
declare const backupSignal: (child: any, parent: any) => void;
|
|
234
|
+
declare const findValidBackup: (child: any, key: any) => any;
|
|
235
|
+
declare const getProxyHasKey: (proxy: any, key: any) => any;
|
|
236
|
+
declare const proxyHasKey: (proxy: any, key: any) => any;
|
|
233
237
|
/**
|
|
234
238
|
* 将 from 响应式对象中 fromKey 对应的 Signal
|
|
235
239
|
* 共享给 to 响应式对象的 toKey
|
|
@@ -246,5 +250,5 @@ declare function effectUt(callback: (...args: ValueDiff[]) => void, depOrOpt?: a
|
|
|
246
250
|
declare function effect(callback: (...args: ValueDiff[]) => void, depOrOpt?: any[] | CustomEffectOpt, opt?: CustomEffectOpt): Effect;
|
|
247
251
|
declare function scope(...args: any[]): any;
|
|
248
252
|
|
|
249
|
-
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 };
|
|
253
|
+
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 };
|
|
250
254
|
export type { CreateScope, CreateTaskProps, CustomEffectOpt, DeepOmitPath, DeepPath, DeepValue, Dispose, Key, Link, MatchValue, Mix, OnClean, OutLink, PRecord, ScheduleTypeStr, SideEffect, SignalNode, SignalType, Task, TaskControlReturn, ValueDiff };
|
package/dist/index.umd.js
CHANGED
|
@@ -941,7 +941,8 @@
|
|
|
941
941
|
const meta = {
|
|
942
942
|
deep,
|
|
943
943
|
scope,
|
|
944
|
-
cells
|
|
944
|
+
cells,
|
|
945
|
+
backup: null
|
|
945
946
|
};
|
|
946
947
|
const shared = createSharedHandler(cells, scope, deep, targetIsMap);
|
|
947
948
|
const specific = targetIsMap ? createMapHandler(cells, scope, deep) : createSetHandler(cells, scope);
|
|
@@ -973,7 +974,8 @@
|
|
|
973
974
|
const meta = {
|
|
974
975
|
deep,
|
|
975
976
|
scope,
|
|
976
|
-
cells
|
|
977
|
+
cells,
|
|
978
|
+
backup: null
|
|
977
979
|
};
|
|
978
980
|
const proxy = new Proxy(target, {
|
|
979
981
|
get(obj, prop, receiver) {
|
|
@@ -983,11 +985,18 @@
|
|
|
983
985
|
case Keys.Meta:
|
|
984
986
|
return meta;
|
|
985
987
|
}
|
|
988
|
+
const hasP = Reflect.has(obj, prop) || cells.has(prop);
|
|
989
|
+
if (!hasP) {
|
|
990
|
+
const backup = findValidBackup(receiver, prop);
|
|
991
|
+
if (backup) {
|
|
992
|
+
return backup[prop];
|
|
993
|
+
}
|
|
994
|
+
}
|
|
986
995
|
if (prop === Symbol.unscopables) return Reflect.get(obj, prop, receiver);
|
|
987
996
|
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
|
|
988
997
|
return Reflect.get(obj, prop, receiver);
|
|
989
998
|
}
|
|
990
|
-
const desc =
|
|
999
|
+
const desc = bobeShared.getPropertyDescriptorInChain(obj, prop);
|
|
991
1000
|
const isGetter = desc && typeof desc.get === 'function';
|
|
992
1001
|
if (isGetter) {
|
|
993
1002
|
return handleGetterAsComputed(obj, prop, receiver, cells, scope);
|
|
@@ -998,7 +1007,7 @@
|
|
|
998
1007
|
if (targetIsArray) {
|
|
999
1008
|
return arrayMethodReWrites[prop] || value;
|
|
1000
1009
|
} else {
|
|
1001
|
-
if (!
|
|
1010
|
+
if (!bobeShared.hasOwn(obj, prop)) {
|
|
1002
1011
|
return value;
|
|
1003
1012
|
}
|
|
1004
1013
|
let s = cells.get(prop);
|
|
@@ -1022,6 +1031,14 @@
|
|
|
1022
1031
|
return s.get();
|
|
1023
1032
|
},
|
|
1024
1033
|
set(obj, prop, value, receiver) {
|
|
1034
|
+
const hasP = Reflect.has(obj, prop) || cells.has(prop);
|
|
1035
|
+
if (!hasP) {
|
|
1036
|
+
const backup = findValidBackup(receiver, prop);
|
|
1037
|
+
if (backup) {
|
|
1038
|
+
backup[prop] = value;
|
|
1039
|
+
return true;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1025
1042
|
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
|
|
1026
1043
|
return Reflect.set(obj, prop, value, receiver);
|
|
1027
1044
|
}
|
|
@@ -1044,7 +1061,7 @@
|
|
|
1044
1061
|
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
|
|
1045
1062
|
return Reflect.deleteProperty(obj, prop);
|
|
1046
1063
|
}
|
|
1047
|
-
if (typeof obj[prop] === 'function' && !
|
|
1064
|
+
if (typeof obj[prop] === 'function' && !bobeShared.hasOwn(obj, prop)) {
|
|
1048
1065
|
return Reflect.deleteProperty(obj, prop);
|
|
1049
1066
|
}
|
|
1050
1067
|
cells.delete(prop);
|
|
@@ -1066,6 +1083,21 @@
|
|
|
1066
1083
|
rawToProxy.set(target, proxy);
|
|
1067
1084
|
return proxy;
|
|
1068
1085
|
};
|
|
1086
|
+
const backupSignal = (child, parent) => {
|
|
1087
|
+
child[Keys.Meta].backup = parent;
|
|
1088
|
+
};
|
|
1089
|
+
const findValidBackup = (child, key) => {
|
|
1090
|
+
let backup = child[Keys.Meta].backup;
|
|
1091
|
+
while (backup) {
|
|
1092
|
+
if (proxyHasKey(backup, key)) {
|
|
1093
|
+
return backup;
|
|
1094
|
+
}
|
|
1095
|
+
backup = backup[Keys.Meta].backup;
|
|
1096
|
+
}
|
|
1097
|
+
return null;
|
|
1098
|
+
};
|
|
1099
|
+
const getProxyHasKey = (proxy, key) => proxyHasKey(proxy, key) ? proxy : findValidBackup(proxy, key);
|
|
1100
|
+
const proxyHasKey = (proxy, key) => Reflect.has(proxy[Keys.Raw], key) || proxy[Keys.Meta].cells.has(key);
|
|
1069
1101
|
const shareSignal = (from, fromPath, to, toPath) => {
|
|
1070
1102
|
try {
|
|
1071
1103
|
const toPaths = toPath.split('.');
|
|
@@ -1356,8 +1388,8 @@
|
|
|
1356
1388
|
...GetMethodConf
|
|
1357
1389
|
}, {
|
|
1358
1390
|
key: 'find',
|
|
1359
|
-
|
|
1360
|
-
|
|
1391
|
+
...GetMethodConf,
|
|
1392
|
+
wrapReturn: true
|
|
1361
1393
|
}, {
|
|
1362
1394
|
key: 'findLast',
|
|
1363
1395
|
...GetMethodConf,
|
|
@@ -1621,6 +1653,7 @@
|
|
|
1621
1653
|
exports.Signal = Signal;
|
|
1622
1654
|
exports.Store = Store;
|
|
1623
1655
|
exports.StoreIgnoreKeys = StoreIgnoreKeys;
|
|
1656
|
+
exports.backupSignal = backupSignal;
|
|
1624
1657
|
exports.batchDeep = batchDeep;
|
|
1625
1658
|
exports.batchEnd = batchEnd;
|
|
1626
1659
|
exports.batchStart = batchStart;
|
|
@@ -1630,7 +1663,9 @@
|
|
|
1630
1663
|
exports.effectUt = effectUt;
|
|
1631
1664
|
exports.execId = execId;
|
|
1632
1665
|
exports.execIdInc = execIdInc;
|
|
1666
|
+
exports.findValidBackup = findValidBackup;
|
|
1633
1667
|
exports.flushMicroEffectManual = flushMicroEffectManual;
|
|
1668
|
+
exports.getProxyHasKey = getProxyHasKey;
|
|
1634
1669
|
exports.getPulling = getPulling;
|
|
1635
1670
|
exports.ide = ide;
|
|
1636
1671
|
exports.isStore = isStore;
|
|
@@ -1638,6 +1673,7 @@
|
|
|
1638
1673
|
exports.micro = micro;
|
|
1639
1674
|
exports.noopEffect = noopEffect;
|
|
1640
1675
|
exports.now = now;
|
|
1676
|
+
exports.proxyHasKey = proxyHasKey;
|
|
1641
1677
|
exports.runWithPulling = runWithPulling;
|
|
1642
1678
|
exports.scope = scope;
|
|
1643
1679
|
exports.setExecId = setExecId;
|