aoye 0.0.16 → 0.0.18

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 CHANGED
@@ -434,7 +434,7 @@ class Line {
434
434
  for (const key in head) {
435
435
  head[key] = null;
436
436
  }
437
- if (line && v2.scope && v1.scope !== v2.scope && !(v1.state & State.IsScope)) {
437
+ if (line && v2.scope && v1.scope !== v2.scope && (v1.state & State.IsScope) === 0) {
438
438
  const first = v2.scope.outLink;
439
439
  if (!first) {
440
440
  v2.scope.outLink = line;
@@ -602,7 +602,7 @@ function dispose() {
602
602
  dfs(upstream, {
603
603
  isUp: true,
604
604
  begin: ({ node }) => {
605
- if (!(node.state & State.IsScope) || node.state & ScopeAbort) return true;
605
+ if ((node.state & State.IsScope) === 0 || node.state & ScopeAbort) return true;
606
606
  },
607
607
  complete: ({ node: scope, notGoDeep }) => {
608
608
  const shouldAbort = !notGoDeep;
@@ -721,11 +721,12 @@ const markDeep = (signal) => {
721
721
  }
722
722
  };
723
723
  const pullingPostprocess = (node) => {
724
- node.state &= ~State.Pulling;
725
- if (node.state & State.PullingUnknown) {
726
- node.state &= ~State.PullingUnknown;
727
- node.state |= State.Unknown;
724
+ let s = node.state;
725
+ s &= ~State.Pulling;
726
+ if (s & State.PullingUnknown) {
727
+ s = s & ~State.PullingUnknown | State.Unknown;
728
728
  }
729
+ node.state = s;
729
730
  };
730
731
  const _Signal = class _Signal {
731
732
  constructor(nextValue, customPull) {
@@ -774,7 +775,7 @@ const _Signal = class _Signal {
774
775
  if (this !== downstream && // 1. 外部支持 link
775
776
  shouldLink && // 2. 有下游
776
777
  downstream && // 3. 下游是 watcher,不链接非 scope
777
- (!(downstream.state & State.LinkScopeOnly) || isScope)) {
778
+ ((downstream.state & State.LinkScopeOnly) === 0 || isScope)) {
778
779
  Line.link(this, downstream);
779
780
  }
780
781
  try {
@@ -813,7 +814,7 @@ const _Signal = class _Signal {
813
814
  dfs(signal, {
814
815
  isUp: true,
815
816
  begin: ({ node }) => {
816
- if (node.state & (State.Pulling | State.Dirty) || !(node.state & DirtyState) || node.isDisabled()) {
817
+ if (node.state & (State.Pulling | State.Dirty) || (node.state & DirtyState) === 0 || node.isDisabled()) {
817
818
  return true;
818
819
  }
819
820
  node.state |= State.Pulling;
@@ -857,7 +858,7 @@ const _Signal = class _Signal {
857
858
  const downstream = G.PullingSignal;
858
859
  if (this !== downstream && // 2. 有下游
859
860
  downstream && // 3. 下游是 watcher 不是 watch,或 是watcher 但 当前是 scope
860
- (!(downstream.state & State.LinkScopeOnly) || this.state & State.IsScope)) {
861
+ ((downstream.state & State.LinkScopeOnly) === 0 || this.state & State.IsScope)) {
861
862
  Line.link(this, downstream);
862
863
  }
863
864
  return this.value;
@@ -933,7 +934,8 @@ const deepSignal = (target, scope, deep = true) => {
933
934
  var _a;
934
935
  const isObj = typeof target === "object" && target !== null;
935
936
  if (!isObj || target[Keys.Raw]) return target;
936
- if (rawToProxy.has(target)) return rawToProxy.get(target);
937
+ const p = rawToProxy.get(target);
938
+ if (p) return p;
937
939
  const cells = /* @__PURE__ */ new Map();
938
940
  const targetIsArray = Array.isArray(target);
939
941
  const targetIsStore = Boolean((_a = target.constructor) == null ? void 0 : _a[IsStore]);
@@ -968,11 +970,12 @@ const deepSignal = (target, scope, deep = true) => {
968
970
  return value;
969
971
  }
970
972
  }
971
- if (cells.has(prop)) {
972
- return cells.get(prop).v;
973
+ let s = cells.get(prop);
974
+ if (s) {
975
+ return s.v;
973
976
  }
974
977
  const wrappedValue = deep ? deepSignal(value, scope) : value;
975
- const s = Signal.create(wrappedValue, {
978
+ s = Signal.create(wrappedValue, {
976
979
  scheduler: Scheduler.Sync,
977
980
  isScope: false,
978
981
  scope
@@ -986,8 +989,8 @@ const deepSignal = (target, scope, deep = true) => {
986
989
  }
987
990
  batch.start();
988
991
  const success = Reflect.set(obj, prop, value, receiver);
989
- if (cells.has(prop)) {
990
- const cell = cells.get(prop);
992
+ const cell = cells.get(prop);
993
+ if (cell) {
991
994
  cell.v = deep ? deepSignal(value, scope) : value;
992
995
  }
993
996
  if (targetIsArray) {
@@ -1003,9 +1006,7 @@ const deepSignal = (target, scope, deep = true) => {
1003
1006
  if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop) || typeof obj[prop] === "function") {
1004
1007
  return Reflect.deleteProperty(obj, prop);
1005
1008
  }
1006
- if (cells.has(prop)) {
1007
- cells.delete(prop);
1008
- }
1009
+ cells.delete(prop);
1009
1010
  triggerIter(obj, prop, void 0, proxy);
1010
1011
  return Reflect.deleteProperty(obj, prop);
1011
1012
  },
@@ -1056,10 +1057,11 @@ function isIgnoreKey(ignores, key) {
1056
1057
  return ignores.some((it) => typeof it === "string" && key.startsWith(it));
1057
1058
  }
1058
1059
  function handleGetterAsComputed(obj, prop, receiver, cells, scope) {
1059
- if (cells.has(prop)) {
1060
- return cells.get(prop).v;
1060
+ let s = cells.get(prop);
1061
+ if (s) {
1062
+ return s.v;
1061
1063
  }
1062
- const s = Signal.create(null, {
1064
+ s = Signal.create(null, {
1063
1065
  customPull: () => Reflect.get(obj, prop, receiver),
1064
1066
  scheduler: Scheduler.Sync,
1065
1067
  isScope: false,
@@ -1102,8 +1104,9 @@ const arrayMethodReWrites = {};
1102
1104
  args[0] = value[Keys.Raw];
1103
1105
  result = fn.call(that, ...args);
1104
1106
  }
1105
- if (rawToProxy.has(value)) {
1106
- args[0] = rawToProxy.get(value);
1107
+ const p = rawToProxy.get(value);
1108
+ if (p) {
1109
+ args[0] = p;
1107
1110
  result = fn.call(that, ...args);
1108
1111
  }
1109
1112
  }
@@ -1540,6 +1543,7 @@ exports.TaskQueue = TaskQueue;
1540
1543
  exports.batch = batch;
1541
1544
  exports.clean = clean;
1542
1545
  exports.customEffect = customEffect;
1546
+ exports.deepSignal = deepSignal;
1543
1547
  exports.effect = effect;
1544
1548
  exports.getPulling = getPulling;
1545
1549
  exports.isScope = isScope;