aoye 0.0.21 → 0.0.23

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/index.umd.js CHANGED
@@ -4,7 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Aoye = {}, global.BobeShared));
5
5
  })(this, (function (exports, bobeShared) { 'use strict';
6
6
 
7
- const rawToProxy = /* @__PURE__ */ new WeakMap();
7
+ const rawToProxy = /* @__PURE__ */new WeakMap();
8
8
  new bobeShared.BaseEvent();
9
9
  const G = {
10
10
  /** 原子 signal 更新次数 */
@@ -16,7 +16,7 @@
16
16
  /** 表示当前处于 pull 递归中 */
17
17
  PullingRecurseDeep: 0
18
18
  };
19
- var State = /* @__PURE__ */ ((State2) => {
19
+ var State = /* @__PURE__ */(State2 => {
20
20
  State2[State2["Clean"] = 0] = "Clean";
21
21
  State2[State2["LinkScopeOnly"] = 256] = "LinkScopeOnly";
22
22
  State2[State2["ScopeAbort"] = 128] = "ScopeAbort";
@@ -37,7 +37,12 @@
37
37
  const getLeft = (x, max) => leakI(x * 2 + 1, max);
38
38
  const getRight = (x, max) => leakI(x * 2 + 2, max);
39
39
  const getParent = (x, max) => leakI(x - 1 >>> 1, max);
40
- const exchange = (arr, i, j) => [arr[i], arr[j]] = [arr[j], arr[i]];
40
+ const exchange = (arr, i, j) => {
41
+ var _ref = [arr[j], arr[i]];
42
+ arr[i] = _ref[0];
43
+ arr[j] = _ref[1];
44
+ return _ref;
45
+ };
41
46
  class PriorityQueue {
42
47
  // 构造函数接受一个compare函数
43
48
  // compare返回的-1, 0, 1决定元素是否优先被去除
@@ -89,11 +94,11 @@
89
94
  this.goUp(this.arr, current, len);
90
95
  }
91
96
  add(...items) {
92
- items.forEach((it) => this._add(it));
97
+ items.forEach(it => this._add(it));
93
98
  }
94
99
  // 去除头元素并返回
95
100
  poll() {
96
- const { arr } = this;
101
+ const arr = this.arr;
97
102
  const len = this.size();
98
103
  if (len <= 2) {
99
104
  return arr.shift();
@@ -113,7 +118,7 @@
113
118
  return this.arr.length;
114
119
  }
115
120
  logTree() {
116
- const { arr } = this;
121
+ const arr = this.arr;
117
122
  let i = 0;
118
123
  let j = 1;
119
124
  let level = 0;
@@ -127,7 +132,7 @@
127
132
  const last = Math.pow(2, matrix.length - 1);
128
133
  const arrStr = JSON.stringify(last);
129
134
  const halfLen = arrStr.length >>> 1;
130
- matrix.forEach((it) => {
135
+ matrix.forEach(it => {
131
136
  const str = JSON.stringify(it);
132
137
  const halfIt = str.length >>> 1;
133
138
  console.log(str.padStart(halfLen + halfIt, " "));
@@ -136,22 +141,6 @@
136
141
  }
137
142
  }
138
143
 
139
- var __defProp$3 = Object.defineProperty;
140
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
141
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
142
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
143
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
144
- var __spreadValues$3 = (a, b) => {
145
- for (var prop in b || (b = {}))
146
- if (__hasOwnProp$4.call(b, prop))
147
- __defNormalProp$3(a, prop, b[prop]);
148
- if (__getOwnPropSymbols$4)
149
- for (var prop of __getOwnPropSymbols$4(b)) {
150
- if (__propIsEnum$4.call(b, prop))
151
- __defNormalProp$3(a, prop, b[prop]);
152
- }
153
- return a;
154
- };
155
144
  const DefaultTaskControlReturn = {
156
145
  finished: true,
157
146
  startNewCallbackAble: true
@@ -162,13 +151,17 @@
162
151
  this.aIsUrgent = aIsUrgent;
163
152
  this.isScheduling = false;
164
153
  }
165
- static create({ callbackAble, aIsUrgent }) {
154
+ static create({
155
+ callbackAble,
156
+ aIsUrgent
157
+ }) {
166
158
  const queue = new TaskQueue(callbackAble, aIsUrgent);
167
159
  queue.taskQueue = new PriorityQueue(aIsUrgent);
168
160
  return queue;
169
161
  }
170
162
  pushTask(task) {
171
- const { taskQueue, isScheduling } = this;
163
+ const taskQueue = this.taskQueue,
164
+ isScheduling = this.isScheduling;
172
165
  taskQueue._add(task);
173
166
  if (!isScheduling) {
174
167
  this.callbackAble(this.scheduleTask.bind(this));
@@ -176,11 +169,14 @@
176
169
  }
177
170
  }
178
171
  scheduleTask() {
179
- const { taskQueue } = this;
172
+ const taskQueue = this.taskQueue;
180
173
  const fn = taskQueue.peek();
181
174
  if (!fn) return this.isScheduling = false;
182
175
  let info = fn() || {};
183
- info = __spreadValues$3(__spreadValues$3({}, DefaultTaskControlReturn), info);
176
+ info = {
177
+ ...DefaultTaskControlReturn,
178
+ ...info
179
+ };
184
180
  if (info.finished) {
185
181
  taskQueue.poll();
186
182
  if (taskQueue.size() === 0) {
@@ -195,20 +191,21 @@
195
191
  }
196
192
  }
197
193
 
198
- var Keys = /* @__PURE__ */ ((Keys2) => {
194
+ var Keys = /* @__PURE__ */(Keys2 => {
199
195
  Keys2["Iterator"] = "__AOYE_ITERATOR";
200
196
  Keys2["Raw"] = "__AOYE_RAW";
201
197
  Keys2["Meta"] = "__AOYE_META";
202
198
  return Keys2;
203
199
  })(Keys || {});
204
- const IsStore = /* @__PURE__ */ Symbol("__AOYE_IS_STORE"), StoreIgnoreKeys = /* @__PURE__ */ Symbol("__AOYE_IGNORE_KEYS");
200
+ const IsStore = /* @__PURE__ */Symbol("__AOYE_IS_STORE"),
201
+ StoreIgnoreKeys = /* @__PURE__ */Symbol("__AOYE_IGNORE_KEYS");
205
202
 
206
203
  let channel = globalThis.MessageChannel ? new MessageChannel() : null;
207
204
  if (globalThis.MessageChannel) {
208
205
  channel = new MessageChannel();
209
206
  }
210
207
  let msgId = 0;
211
- const macro = (fn) => {
208
+ const macro = fn => {
212
209
  if (!channel) {
213
210
  setTimeout(fn);
214
211
  }
@@ -223,10 +220,10 @@
223
220
  channel.port1.postMessage(msgId++);
224
221
  };
225
222
  const p = Promise.resolve();
226
- const micro = (cb) => {
223
+ const micro = cb => {
227
224
  p.then(cb);
228
225
  };
229
- const toRaw = (a) => {
226
+ const toRaw = a => {
230
227
  if (typeof a === "object" && a !== null && a[Keys.Raw]) {
231
228
  return toRaw(a[Keys.Raw]);
232
229
  }
@@ -241,25 +238,31 @@
241
238
  /** 记录 Set 或 BatchSet 产生的最后一个 Effect */
242
239
  this.lastEffectItem = null;
243
240
  }
241
+ static {
242
+ this.Sync = "__Sync_";
243
+ }
244
+ static {
245
+ this.Layout = "__Layout_";
246
+ }
247
+ static {
248
+ this.Micro = "__Micro_";
249
+ }
250
+ static {
251
+ this.Macro = "__Macro_";
252
+ }
244
253
  endSet() {
245
- var _a;
246
254
  if (!this.firstEffectItem) return;
247
255
  const subQueue = this.effectQueue.subRef(this.firstEffectItem, this.lastEffectItem);
248
256
  this.firstEffectItem = null;
249
257
  this.lastEffectItem = null;
250
- (_a = this.onOneSetEffectsAdded) == null ? void 0 : _a.call(this, subQueue, this.effectQueue);
258
+ this.onOneSetEffectsAdded?.(subQueue, this.effectQueue);
251
259
  }
252
260
  addEffect(effect) {
253
- var _a;
254
261
  const item = this.effectQueue.push(effect);
255
- (_a = this.onEffectAdded) == null ? void 0 : _a.call(this, effect, item, this.effectQueue);
262
+ this.onEffectAdded?.(effect, item, this.effectQueue);
256
263
  return item;
257
264
  }
258
265
  }
259
- Scheduler.Sync = "__Sync_";
260
- Scheduler.Layout = "__Layout_";
261
- Scheduler.Micro = "__Micro_";
262
- Scheduler.Macro = "__Macro_";
263
266
  class SyncScheduler extends Scheduler {
264
267
  onOneSetEffectsAdded(subQueue, queue) {
265
268
  subQueue.forEach((effect, item) => {
@@ -271,7 +274,10 @@
271
274
  class MicroScheduler extends Scheduler {
272
275
  constructor() {
273
276
  super(...arguments);
274
- this.taskQueue = TaskQueue.create({ callbackAble: micro, aIsUrgent: (a, b) => a.time < b.time });
277
+ this.taskQueue = TaskQueue.create({
278
+ callbackAble: micro,
279
+ aIsUrgent: (a, b) => a.time < b.time
280
+ });
275
281
  }
276
282
  onOneSetEffectsAdded(subQueue, queue) {
277
283
  const task = () => {
@@ -291,7 +297,10 @@
291
297
  class MacroScheduler extends Scheduler {
292
298
  constructor() {
293
299
  super(...arguments);
294
- this.taskQueue = TaskQueue.create({ callbackAble: macro, aIsUrgent: (a, b) => a.time < b.time });
300
+ this.taskQueue = TaskQueue.create({
301
+ callbackAble: macro,
302
+ aIsUrgent: (a, b) => a.time < b.time
303
+ });
295
304
  }
296
305
  onOneSetEffectsAdded(subQueue, queue) {
297
306
  const task = () => {
@@ -307,7 +316,10 @@
307
316
  class LayoutScheduler extends Scheduler {
308
317
  constructor() {
309
318
  super(...arguments);
310
- this.taskQueue = TaskQueue.create({ callbackAble: macro, aIsUrgent: (a, b) => a.time < b.time });
319
+ this.taskQueue = TaskQueue.create({
320
+ callbackAble: macro,
321
+ aIsUrgent: (a, b) => a.time < b.time
322
+ });
311
323
  }
312
324
  onOneSetEffectsAdded(subQueue, queue) {
313
325
  const task = () => {
@@ -329,74 +341,6 @@
329
341
  globalThis["sche"] = _scheduler[Scheduler.Sync];
330
342
  const registerScheduler = (key, Ctor) => _scheduler[key] = new Ctor();
331
343
 
332
- var __defProp$2 = Object.defineProperty;
333
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
334
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
335
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
336
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
337
- var __spreadValues$2 = (a, b) => {
338
- for (var prop in b || (b = {}))
339
- if (__hasOwnProp$3.call(b, prop))
340
- __defNormalProp$2(a, prop, b[prop]);
341
- if (__getOwnPropSymbols$3)
342
- for (var prop of __getOwnPropSymbols$3(b)) {
343
- if (__propIsEnum$3.call(b, prop))
344
- __defNormalProp$2(a, prop, b[prop]);
345
- }
346
- return a;
347
- };
348
- const DefaultDFSOpt = {
349
- isUp: false,
350
- begin: null,
351
- complete: null,
352
- breakStack: [],
353
- breakLine: null,
354
- breakNode: null
355
- };
356
- function dfs(root, opt = {}) {
357
- const { isUp, begin, complete, breakStack: lineStack, breakLine } = __spreadValues$2(__spreadValues$2({}, DefaultDFSOpt), opt);
358
- let node = opt.breakNode || root;
359
- let line = breakLine;
360
- const listKey = isUp ? "recStart" : "emitStart";
361
- const nodeKey = isUp ? "upstream" : "downstream";
362
- const nextLineKey = isUp ? "nextRecLine" : "nextEmitLine";
363
- const reverseNodeKey = isUp ? "downstream" : "upstream";
364
- while (1) {
365
- let notGoDeep = begin == null ? void 0 : begin({
366
- node,
367
- lineFromUp: line,
368
- walkedLine: lineStack
369
- });
370
- lineStack.push(line);
371
- line = node[listKey];
372
- if (line && !notGoDeep) {
373
- const firstChild = line[nodeKey];
374
- node = firstChild;
375
- continue;
376
- }
377
- while (1) {
378
- const noGoSibling = complete == null ? void 0 : complete({
379
- node,
380
- lineToDeep: line,
381
- walkedLine: lineStack,
382
- notGoDeep
383
- });
384
- line = lineStack.pop();
385
- if (node === root) {
386
- return;
387
- }
388
- notGoDeep = false;
389
- const nextLine = line[nextLineKey];
390
- if (!noGoSibling && nextLine) {
391
- line = nextLine;
392
- node = nextLine[nodeKey];
393
- break;
394
- }
395
- node = line[reverseNodeKey];
396
- }
397
- }
398
- }
399
-
400
344
  class Line {
401
345
  constructor() {
402
346
  /** 上游顶点 */
@@ -416,9 +360,17 @@
416
360
  this.nextOutLink = null;
417
361
  }
418
362
  static link(v1, v2) {
419
- let { emitEnd } = v1, { recEnd, recStart } = v2, noRecEnd = !recEnd, head = { nextRecLine: recStart }, line;
363
+ let emitEnd = v1.emitEnd,
364
+ recEnd = v2.recEnd,
365
+ recStart = v2.recStart,
366
+ noRecEnd = !recEnd,
367
+ head = {
368
+ nextRecLine: recStart
369
+ },
370
+ line;
420
371
  recEnd = recEnd || head;
421
- const { nextRecLine } = recEnd || {};
372
+ const _ref = recEnd || {},
373
+ nextRecLine = _ref.nextRecLine;
422
374
  if (!nextRecLine) {
423
375
  line = new Line();
424
376
  Line.emit_line(v1, line);
@@ -449,7 +401,14 @@
449
401
  }
450
402
  }
451
403
  static unlink(line) {
452
- let { prevEmitLine, nextEmitLine, prevRecLine, nextRecLine, upstream, downstream, nextOutLink, prevOutLink } = line;
404
+ let prevEmitLine = line.prevEmitLine,
405
+ nextEmitLine = line.nextEmitLine,
406
+ prevRecLine = line.prevRecLine,
407
+ nextRecLine = line.nextRecLine,
408
+ upstream = line.upstream,
409
+ downstream = line.downstream,
410
+ nextOutLink = line.nextOutLink,
411
+ prevOutLink = line.prevOutLink;
453
412
  line.prevEmitLine = null;
454
413
  line.nextEmitLine = null;
455
414
  line.prevRecLine = null;
@@ -570,24 +529,46 @@
570
529
  }
571
530
  function unlinkSingleRefedNode(delRoot) {
572
531
  let toUnlink;
573
- dfs(delRoot, {
574
- isUp: true,
575
- begin: ({ node }) => {
576
- doUnlink(toUnlink);
577
- toUnlink = null;
578
- if (node.emitStart !== node.emitEnd) {
579
- return true;
580
- }
581
- },
582
- complete: ({ node, notGoDeep }) => {
532
+ let node = delRoot,
533
+ i = -1,
534
+ parent;
535
+ const stack = [];
536
+ outer: do {
537
+ let noGoDeep = false;
538
+ doUnlink(toUnlink);
539
+ toUnlink = null;
540
+ noGoDeep = node.emitStart !== node.emitEnd;
541
+ const recStart = node.recStart;
542
+ if (recStart && !noGoDeep) {
543
+ stack[++i] = recStart;
544
+ parent = node;
545
+ node = recStart.upstream;
546
+ continue;
547
+ }
548
+ while (true) {
583
549
  doUnlink(toUnlink);
584
550
  toUnlink = null;
585
- const isSingleRefed = !notGoDeep;
586
- if (isSingleRefed) {
551
+ if (!noGoDeep) {
587
552
  toUnlink = node.emitStart;
588
553
  }
554
+ noGoDeep = false;
555
+ if (i === -1) {
556
+ break outer;
557
+ }
558
+ const backLine = stack[i];
559
+ const nextLine = backLine.nextRecLine;
560
+ if (nextLine) {
561
+ node = nextLine.upstream;
562
+ stack[i] = nextLine;
563
+ break;
564
+ } else {
565
+ node = parent;
566
+ if (--i !== -1) {
567
+ parent = stack[i].downstream;
568
+ }
569
+ }
589
570
  }
590
- });
571
+ } while (true);
591
572
  doUnlink(toUnlink);
592
573
  }
593
574
  function doUnlink(line) {
@@ -602,18 +583,41 @@
602
583
  const memoNext = toDel.nextRecLine;
603
584
  const upstream = toDel.upstream;
604
585
  if (upstream.state & State.IsScope) {
605
- dfs(upstream, {
606
- isUp: true,
607
- begin: ({ node }) => {
608
- if ((node.state & State.IsScope) === 0 || node.state & ScopeAbort) return true;
609
- },
610
- complete: ({ node: scope, notGoDeep }) => {
611
- const shouldAbort = !notGoDeep;
612
- if (shouldAbort) {
613
- releaseScope(scope);
586
+ let node = upstream,
587
+ i = -1,
588
+ parent;
589
+ const stack = [];
590
+ outer: do {
591
+ let noGoDeep = (node.state & State.IsScope) === 0 || node.state & ScopeAbort;
592
+ const recStart = node.recStart;
593
+ if (recStart && !noGoDeep) {
594
+ stack[++i] = recStart;
595
+ parent = node;
596
+ node = recStart.upstream;
597
+ continue;
598
+ }
599
+ while (true) {
600
+ if (!noGoDeep) {
601
+ releaseScope(node);
602
+ }
603
+ noGoDeep = false;
604
+ if (i === -1) {
605
+ break outer;
606
+ }
607
+ const backLine = stack[i];
608
+ const nextLine = backLine.nextRecLine;
609
+ if (nextLine) {
610
+ node = nextLine.upstream;
611
+ stack[i] = nextLine;
612
+ break;
613
+ } else {
614
+ node = parent;
615
+ if (--i !== -1) {
616
+ parent = stack[i].downstream;
617
+ }
614
618
  }
615
619
  }
616
- });
620
+ } while (true);
617
621
  } else {
618
622
  unlinkSingleLine(toDel);
619
623
  }
@@ -623,7 +627,6 @@
623
627
  doUnlink(this.emitStart);
624
628
  }
625
629
  function releaseScope(scope) {
626
- var _a;
627
630
  let outLink = scope.outLink;
628
631
  while (outLink) {
629
632
  const memoNext = outLink.nextOutLink;
@@ -631,7 +634,7 @@
631
634
  outLink = memoNext;
632
635
  }
633
636
  scope.state |= State.ScopeAbort;
634
- (_a = scope.clean) == null ? void 0 : _a.call(scope);
637
+ scope.clean?.();
635
638
  scope.clean = null;
636
639
  }
637
640
  function clean(cb) {
@@ -651,82 +654,65 @@
651
654
  G.PullingSignal = pulling;
652
655
  }
653
656
 
654
- class Batch {
655
- constructor() {
656
- this.deep = 0;
657
- }
658
- start() {
659
- this.deep++;
660
- }
661
- end() {
662
- this.deep--;
663
- if (this.deep !== 0) return;
664
- for (const key in _scheduler) {
665
- const instance = _scheduler[key];
666
- instance.endSet();
667
- }
668
- }
669
- inBatch() {
670
- return this.deep > 0;
671
- }
672
- }
673
- const batch = new Batch();
674
-
675
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
676
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
677
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
678
- var __objRest = (source, exclude) => {
679
- var target = {};
680
- for (var prop in source)
681
- if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
682
- target[prop] = source[prop];
683
- if (source != null && __getOwnPropSymbols$2)
684
- for (var prop of __getOwnPropSymbols$2(source)) {
685
- if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
686
- target[prop] = source[prop];
687
- }
688
- return target;
689
- };
690
- const markDeep = (signal) => {
691
- let level = 0, updatedSchedulers = /* @__PURE__ */ new Set();
692
- dfs(signal, {
693
- isUp: false,
694
- begin: ({ node }) => {
695
- if (node.isDisabled()) {
696
- return true;
697
- }
698
- const inPullingArea = node.state & State.Pulling;
699
- const Unknown = inPullingArea ? State.PullingUnknown : State.Unknown;
700
- const isEffect = level > 0;
701
- const isLeaf = !node.emitStart || node.emitStart.downstream === node.scope;
657
+ const markDeep = root => {
658
+ let node = root,
659
+ i = -1,
660
+ parent;
661
+ const stack = [];
662
+ outer: do {
663
+ let noGoDeep = false;
664
+ const state = node.state,
665
+ emitStart = node.emitStart,
666
+ scheduler = node.scheduler;
667
+ if (node.scope && node.scope.state & State.ScopeAbort ||
668
+ // scope 节点,且处于 ready 状态,不需要重复执行
669
+ node.state & ScopeExecuted) {
670
+ noGoDeep = true;
671
+ } else {
672
+ const inPullingArea = state & State.Pulling;
673
+ const isEffect = parent !== void 0;
674
+ const isLeaf = !emitStart || emitStart.downstream === node.scope;
702
675
  if (isEffect) {
703
- node.state |= Unknown;
676
+ node.state |= inPullingArea ? State.PullingUnknown : State.Unknown;
704
677
  } else if (!isLeaf) {
705
678
  node.state |= State.Dirty;
706
679
  }
707
- if (isLeaf && isEffect && !inPullingArea) {
708
- const key = node.scheduler;
709
- const instance = _scheduler[key];
710
- const item = instance.addEffect(node);
711
- if (!instance.firstEffectItem) {
712
- instance.firstEffectItem = item;
680
+ if (isLeaf) {
681
+ noGoDeep = true;
682
+ if (isEffect && !inPullingArea) {
683
+ const instance = _scheduler[scheduler];
684
+ const item = instance.addEffect(node);
685
+ instance.firstEffectItem ??= item;
686
+ instance.lastEffectItem = item;
713
687
  }
714
- instance.lastEffectItem = item;
715
- updatedSchedulers.add(key);
716
688
  }
717
- level++;
718
- if (isLeaf) {
719
- return true;
689
+ }
690
+ if (emitStart && !noGoDeep) {
691
+ stack[++i] = emitStart;
692
+ parent = node;
693
+ node = emitStart.downstream;
694
+ noGoDeep = false;
695
+ continue;
696
+ }
697
+ while (true) {
698
+ if (i === -1) {
699
+ break outer;
700
+ }
701
+ const backLine = stack[i];
702
+ const nextLine = backLine.nextEmitLine;
703
+ if (nextLine) {
704
+ node = nextLine.downstream;
705
+ stack[i] = nextLine;
706
+ break;
707
+ }
708
+ node = parent;
709
+ if (--i !== -1) {
710
+ parent = stack[i].upstream;
720
711
  }
721
712
  }
722
- });
723
- if (batch.inBatch()) return;
724
- for (const key in _scheduler) {
725
- const instance = _scheduler[key];
726
- instance.endSet();
727
- }
713
+ } while (true);
728
714
  };
729
- const pullingPostprocess = (node) => {
715
+ const pullingPostprocess = node => {
730
716
  let s = node.state;
731
717
  s &= ~State.Pulling;
732
718
  if (s & State.PullingUnknown) {
@@ -734,7 +720,7 @@
734
720
  }
735
721
  node.state = s;
736
722
  };
737
- const _Signal = class _Signal {
723
+ class Signal {
738
724
  constructor(nextValue, customPull) {
739
725
  this.nextValue = nextValue;
740
726
  this.customPull = customPull;
@@ -754,9 +740,17 @@
754
740
  /** 记录当前 effect 中 clean */
755
741
  this.clean = null;
756
742
  }
757
- static create(nextValue, _a) {
758
- var _b = _a, { customPull, isScope, scope, immediate } = _b, rest = __objRest(_b, ["customPull", "isScope", "scope", "immediate"]);
759
- const s = new _Signal(nextValue, customPull);
743
+ static {
744
+ this.Pulling = null;
745
+ }
746
+ static create(nextValue, {
747
+ customPull,
748
+ isScope,
749
+ scope,
750
+ immediate,
751
+ ...rest
752
+ }) {
753
+ const s = new Signal(nextValue, customPull);
760
754
  s.pull = s.customPull || s.DEFAULT_PULL;
761
755
  Object.assign(s, rest);
762
756
  if (isScope) {
@@ -774,10 +768,9 @@
774
768
  * 递归拉取负责建立以来链
775
769
  */
776
770
  pullRecurse(shouldLink = true) {
777
- var _a, _b;
778
771
  G.PullingRecurseDeep++;
779
772
  const downstream = G.PullingSignal;
780
- this.linkWhenPull(downstream);
773
+ this.linkWhenPull(downstream, shouldLink);
781
774
  try {
782
775
  if (this.version === G.version) {
783
776
  return this.value;
@@ -785,7 +778,7 @@
785
778
  if (this.pull !== this.DEFAULT_PULL) this.recEnd = null;
786
779
  this.state |= State.Pulling;
787
780
  G.PullingSignal = this;
788
- (_a = this.clean) == null ? void 0 : _a.call(this);
781
+ this.clean?.();
789
782
  this.clean = null;
790
783
  let v = this.pull();
791
784
  if (this.state & State.IsScope && typeof v === "function") {
@@ -802,52 +795,63 @@
802
795
  } finally {
803
796
  this.pull = this.customPull || this.DEFAULT_PULL;
804
797
  pullingPostprocess(this);
805
- const toDel = (_b = this.recEnd) == null ? void 0 : _b.nextRecLine;
798
+ const toDel = this.recEnd?.nextRecLine;
806
799
  unlinkRecWithScope(toDel);
807
800
  G.PullingSignal = downstream;
808
801
  G.PullingRecurseDeep--;
809
802
  }
810
803
  }
811
- linkWhenPull(downstream) {
804
+ linkWhenPull(downstream, shouldLink) {
812
805
  const isScope = this.state & State.IsScope;
813
- if (this !== downstream && // 2. 有下游
814
- downstream && // 3. 下游是 watcher 不是 watch,或 是watcher 但 当前是 scope
815
- ((downstream.state & State.LinkScopeOnly) === 0 || isScope) && /**4. scope 只能被一个下游节点管理,就是初始化它的那个下游节点
816
- * 发生在 outEffect(() => scope(() => innerEffect(), null))
817
- * 虽然通过 scope innerEffect 被管理,
818
- * 如果 innerEffect 在 outEffect 中被再次触发,就导致其被 outEffect 管理,
819
- * outEffect 后续重新触发, 则导致 innerEffect 被销毁
820
- */
821
- (!isScope || !this.emitStart)) {
806
+ if (
807
+ // 2. 有下游
808
+ downstream && shouldLink && (
809
+ // 3. 下游是 watcher 不是 watch,或 是watcher 但 当前是 scope
810
+ (downstream.state & State.LinkScopeOnly) === 0 || isScope) && (
811
+ /**4. scope 只能被一个下游节点管理,就是初始化它的那个下游节点
812
+ * 发生在 outEffect(() => scope(() => innerEffect(), null))
813
+ * 虽然通过 scope 让 innerEffect 被管理,
814
+ * 如果 innerEffect 在 outEffect 中被再次触发,就导致其被 outEffect 管理,
815
+ * 若 outEffect 后续重新触发, 则导致 innerEffect 被销毁
816
+ */
817
+ !isScope || !this.emitStart)) {
822
818
  Line.link(this, downstream);
823
819
  }
824
820
  }
825
821
  pullDeep() {
826
822
  const signal = this;
827
823
  if (signal.state & DirtyState) {
828
- dfs(signal, {
829
- isUp: true,
830
- begin: ({ node }) => {
831
- if (node.state & (State.Pulling | State.Dirty) || (node.state & DirtyState) === 0 || node.isDisabled()) {
832
- return true;
833
- }
824
+ let node = signal,
825
+ i = -1,
826
+ parent;
827
+ const stack = [];
828
+ outer: do {
829
+ let noGoDeep = false;
830
+ if (node.state & (State.Pulling | State.Dirty) || (node.state & DirtyState) === 0 || node.isDisabled()) {
831
+ noGoDeep = true;
832
+ } else {
834
833
  node.state |= State.Pulling;
835
- },
836
- complete: ({ node, notGoDeep: cleanOrDirty, walkedLine }) => {
834
+ }
835
+ const recStart = node.recStart;
836
+ if (recStart && !noGoDeep) {
837
+ stack[++i] = recStart;
838
+ parent = node;
839
+ node = recStart.upstream;
840
+ continue;
841
+ }
842
+ while (true) {
837
843
  const isDirty = node.state & State.Dirty;
838
- let currentClean = cleanOrDirty && !isDirty;
839
- if (cleanOrDirty && node.state & State.Pulling) {
844
+ let currentClean = noGoDeep && !isDirty;
845
+ if (noGoDeep && node.state & State.Pulling) {
840
846
  currentClean = true;
841
847
  }
842
848
  let noGoSibling = false;
843
- const last = walkedLine[walkedLine.length - 1];
844
- const downstream2 = last == null ? void 0 : last.downstream;
849
+ const downstream2 = parent;
850
+ const isEmitter = node.pull === node.DEFAULT_PULL;
845
851
  if (currentClean) ; else if (isDirty) {
846
- if (node.pull === node.DEFAULT_PULL && node.value !== node.nextValue) {
852
+ if (isEmitter && node.value !== node.nextValue) {
847
853
  node.markDownStreamsDirty();
848
854
  node.state &= ~State.Dirty;
849
- node.state &= ~State.Pulling;
850
- return;
851
855
  } else {
852
856
  const prevPulling = G.PullingSignal;
853
857
  G.PullingSignal = downstream2;
@@ -863,14 +867,31 @@
863
867
  } else if (node.state & State.Unknown) {
864
868
  node.state &= ~State.Unknown;
865
869
  }
866
- node.version = G.version;
870
+ if (!isEmitter) {
871
+ node.version = G.version;
872
+ }
867
873
  pullingPostprocess(node);
868
- return noGoSibling;
874
+ noGoDeep = false;
875
+ if (i === -1) {
876
+ break outer;
877
+ }
878
+ const backLine = stack[i];
879
+ const nextLine = backLine.nextRecLine;
880
+ if (!noGoSibling && nextLine) {
881
+ node = nextLine.upstream;
882
+ stack[i] = nextLine;
883
+ break;
884
+ } else {
885
+ node = parent;
886
+ if (--i !== -1) {
887
+ parent = stack[i].downstream;
888
+ }
889
+ }
869
890
  }
870
- });
891
+ } while (true);
871
892
  }
872
893
  const downstream = G.PullingSignal;
873
- this.linkWhenPull(downstream);
894
+ this.linkWhenPull(downstream, true);
874
895
  return this.value;
875
896
  }
876
897
  get v() {
@@ -904,7 +925,18 @@
904
925
  this.nextValue = v;
905
926
  this.pull = this.DEFAULT_PULL;
906
927
  G.version++;
907
- markDeep(this);
928
+ if (this.emitStart) {
929
+ markDeep(this);
930
+ if (batchDeep === 0) {
931
+ this.scheduleEffect();
932
+ }
933
+ }
934
+ }
935
+ scheduleEffect() {
936
+ for (const key in _scheduler) {
937
+ const instance = _scheduler[key];
938
+ instance.endSet();
939
+ }
908
940
  }
909
941
  /** 返回值为 true 表示已处理 */
910
942
  runIfDirty() {
@@ -913,42 +945,32 @@
913
945
  isDisabled() {
914
946
  return (
915
947
  // scope 被取消
916
- this.scope && this.scope.state & State.ScopeAbort || // 是 scope 节点,且处于 ready 状态,不需要重复执行
917
- this.state & State.IsScope && this.state & ScopeExecuted
948
+ this.scope && this.scope.state & State.ScopeAbort ||
949
+ // scope 节点,且处于 ready 状态,不需要重复执行
950
+ this.state & ScopeExecuted
918
951
  );
919
952
  }
920
- };
921
- _Signal.Pulling = null;
922
- let Signal = _Signal;
953
+ }
954
+ let batchDeep = 0;
955
+ function batchStart() {
956
+ batchDeep++;
957
+ }
958
+ function batchEnd() {
959
+ if (--batchDeep) return;
960
+ for (const key in _scheduler) {
961
+ const instance = _scheduler[key];
962
+ instance.endSet();
963
+ }
964
+ }
923
965
 
924
- var __defProp$1 = Object.defineProperty;
925
- var __defProps = Object.defineProperties;
926
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
927
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
928
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
929
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
930
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
931
- var __spreadValues$1 = (a, b) => {
932
- for (var prop in b || (b = {}))
933
- if (__hasOwnProp$1.call(b, prop))
934
- __defNormalProp$1(a, prop, b[prop]);
935
- if (__getOwnPropSymbols$1)
936
- for (var prop of __getOwnPropSymbols$1(b)) {
937
- if (__propIsEnum$1.call(b, prop))
938
- __defNormalProp$1(a, prop, b[prop]);
939
- }
940
- return a;
941
- };
942
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
943
966
  const deepSignal = (target, scope, deep = true) => {
944
- var _a;
945
967
  const isObj = typeof target === "object" && target !== null;
946
968
  if (!isObj || target[Keys.Raw]) return target;
947
969
  const p = rawToProxy.get(target);
948
970
  if (p) return p;
949
- const cells = /* @__PURE__ */ new Map();
971
+ const cells = /* @__PURE__ */new Map();
950
972
  const targetIsArray = Array.isArray(target);
951
- const targetIsStore = Boolean((_a = target.constructor) == null ? void 0 : _a[IsStore]);
973
+ const targetIsStore = Boolean(target.constructor?.[IsStore]);
952
974
  const meta = {
953
975
  deep,
954
976
  scope,
@@ -997,7 +1019,7 @@
997
1019
  if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop) || typeof value === "function") {
998
1020
  return Reflect.set(obj, prop, value, receiver);
999
1021
  }
1000
- batch.start();
1022
+ batchStart();
1001
1023
  const success = Reflect.set(obj, prop, value, receiver);
1002
1024
  const cell = cells.get(prop);
1003
1025
  if (cell) {
@@ -1008,7 +1030,7 @@
1008
1030
  } else {
1009
1031
  triggerIter(obj, prop, value, receiver);
1010
1032
  }
1011
- batch.end();
1033
+ batchEnd();
1012
1034
  return success;
1013
1035
  },
1014
1036
  // 【核心修改】拦截 delete 操作
@@ -1037,10 +1059,14 @@
1037
1059
  const toPaths = toPath.split(".");
1038
1060
  const formPaths = Array.isArray(fromPath) ? fromPath : fromPath.split(".");
1039
1061
  runWithPulling(() => {
1040
- const { target: fromTarget, key: fromKey } = getTargetAndKey(from, formPaths);
1062
+ const _getTargetAndKey = getTargetAndKey(from, formPaths),
1063
+ fromTarget = _getTargetAndKey.target,
1064
+ fromKey = _getTargetAndKey.key;
1041
1065
  const val = fromTarget[fromKey];
1042
1066
  const fromSignal = fromTarget[Keys.Meta].cells.get(fromKey);
1043
- const { target: toTarget, key: toKey } = getTargetAndKey(to, toPaths);
1067
+ const _getTargetAndKey2 = getTargetAndKey(to, toPaths),
1068
+ toTarget = _getTargetAndKey2.target,
1069
+ toKey = _getTargetAndKey2.key;
1044
1070
  toTarget[Keys.Meta].cells.set(toKey, fromSignal);
1045
1071
  toTarget[Keys.Raw][toKey] = val;
1046
1072
  }, null);
@@ -1059,13 +1085,16 @@
1059
1085
  target = target[key];
1060
1086
  }
1061
1087
  }
1062
- return { target, key };
1088
+ return {
1089
+ target,
1090
+ key
1091
+ };
1063
1092
  }
1064
1093
  function isIgnoreKey(ignores, key) {
1065
1094
  if (typeof key !== "string") {
1066
1095
  return ignores.includes(key);
1067
1096
  }
1068
- return ignores.some((it) => typeof it === "string" && key.startsWith(it));
1097
+ return ignores.some(it => typeof it === "string" && key.startsWith(it));
1069
1098
  }
1070
1099
  function handleGetterAsComputed(obj, prop, receiver, cells, scope) {
1071
1100
  let s = cells.get(prop);
@@ -1094,18 +1123,18 @@
1094
1123
  }
1095
1124
  }
1096
1125
  const arrayMethodReWrites = {};
1097
- ["pop", "push", "shift", "splice", "unshift", "copyWithin", "reverse", "fill"].forEach((key) => {
1098
- arrayMethodReWrites[key] = function(...args) {
1099
- batch.start();
1126
+ ["pop", "push", "shift", "splice", "unshift", "copyWithin", "reverse", "fill"].forEach(key => {
1127
+ arrayMethodReWrites[key] = function (...args) {
1128
+ batchStart();
1100
1129
  const fn = Array.prototype[key];
1101
1130
  const res = runWithPulling(() => fn.call(this, ...args), null);
1102
1131
  this[Keys.Iterator] = (this[Keys.Raw][Keys.Iterator] || 0) + 1;
1103
- batch.end();
1132
+ batchEnd();
1104
1133
  return res;
1105
1134
  };
1106
1135
  });
1107
- ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
1108
- arrayMethodReWrites[key] = function(...args) {
1136
+ ["includes", "indexOf", "lastIndexOf"].forEach(key => {
1137
+ arrayMethodReWrites[key] = function (...args) {
1109
1138
  const fn = Array.prototype[key];
1110
1139
  const that = toRaw(this);
1111
1140
  let result = fn.call(that, ...args);
@@ -1125,14 +1154,15 @@
1125
1154
  return result;
1126
1155
  };
1127
1156
  });
1128
- [Symbol.iterator, "values", "entries"].forEach((key) => {
1157
+ [Symbol.iterator, "values", "entries"].forEach(key => {
1129
1158
  const isEntries = key === "entries";
1130
- arrayMethodReWrites[key] = function(...args) {
1159
+ arrayMethodReWrites[key] = function (...args) {
1131
1160
  const fn = Array.prototype[key];
1132
1161
  const rawArray = toRaw(this);
1133
1162
  const iter = fn.call(rawArray, ...args);
1134
1163
  const meta = this[Keys.Meta];
1135
- const { deep: isDeep, scope } = meta;
1164
+ const isDeep = meta.deep,
1165
+ scope = meta.scope;
1136
1166
  if (isDeep) {
1137
1167
  const rawNext = iter.next.bind(iter);
1138
1168
  iter.next = () => {
@@ -1151,9 +1181,10 @@
1151
1181
  return iter;
1152
1182
  };
1153
1183
  });
1154
- arrayMethodReWrites.filter = function(callback, thisArg) {
1184
+ arrayMethodReWrites.filter = function (callback, thisArg) {
1155
1185
  const meta = this[Keys.Meta];
1156
- const { deep: isDeep, scope } = meta;
1186
+ const isDeep = meta.deep,
1187
+ scope = meta.scope;
1157
1188
  const that = toRaw(this);
1158
1189
  const result = [];
1159
1190
  let resultIndex = 0;
@@ -1170,9 +1201,10 @@
1170
1201
  this[Keys.Iterator];
1171
1202
  return result;
1172
1203
  };
1173
- arrayMethodReWrites.slice = function(start, end) {
1204
+ arrayMethodReWrites.slice = function (start, end) {
1174
1205
  const meta = this[Keys.Meta];
1175
- const { deep: isDeep, scope } = meta;
1206
+ const isDeep = meta.deep,
1207
+ scope = meta.scope;
1176
1208
  const that = toRaw(this);
1177
1209
  const len = that.length;
1178
1210
  let k = start || 0;
@@ -1197,9 +1229,10 @@
1197
1229
  this[Keys.Iterator];
1198
1230
  return result;
1199
1231
  };
1200
- arrayMethodReWrites.toReversed = function() {
1232
+ arrayMethodReWrites.toReversed = function () {
1201
1233
  const meta = this[Keys.Meta];
1202
- const { deep: isDeep, scope } = meta;
1234
+ const isDeep = meta.deep,
1235
+ scope = meta.scope;
1203
1236
  const that = toRaw(this);
1204
1237
  const len = that.length;
1205
1238
  const result = new Array(len);
@@ -1211,9 +1244,10 @@
1211
1244
  this[Keys.Iterator];
1212
1245
  return result;
1213
1246
  };
1214
- arrayMethodReWrites.toSpliced = function(start, deleteCount, ...items) {
1247
+ arrayMethodReWrites.toSpliced = function (start, deleteCount, ...items) {
1215
1248
  const meta = this[Keys.Meta];
1216
- const { deep: isDeep, scope } = meta;
1249
+ const isDeep = meta.deep,
1250
+ scope = meta.scope;
1217
1251
  const that = toRaw(this);
1218
1252
  const len = that.length;
1219
1253
  let relativeStart = start >> 0;
@@ -1244,9 +1278,10 @@
1244
1278
  this[Keys.Iterator];
1245
1279
  return result;
1246
1280
  };
1247
- arrayMethodReWrites.with = function(index, value) {
1281
+ arrayMethodReWrites.with = function (index, value) {
1248
1282
  const meta = this[Keys.Meta];
1249
- const { deep: isDeep, scope } = meta;
1283
+ const isDeep = meta.deep,
1284
+ scope = meta.scope;
1250
1285
  const that = toRaw(this);
1251
1286
  const len = that.length;
1252
1287
  let relativeIndex = Number(index) || 0;
@@ -1265,9 +1300,10 @@
1265
1300
  this[Keys.Iterator];
1266
1301
  return result;
1267
1302
  };
1268
- arrayMethodReWrites.concat = function(...items) {
1303
+ arrayMethodReWrites.concat = function (...items) {
1269
1304
  const meta = this[Keys.Meta];
1270
- const { deep: isDeep, scope } = meta;
1305
+ const isDeep = meta.deep,
1306
+ scope = meta.scope;
1271
1307
  const that = toRaw(this);
1272
1308
  const selfLen = that.length;
1273
1309
  let totalLength = selfLen;
@@ -1307,49 +1343,50 @@
1307
1343
  wrapReturn: false,
1308
1344
  wrapArgs: 1
1309
1345
  };
1310
- [
1311
- __spreadValues$1({
1312
- key: "every"
1313
- }, GetMethodConf),
1314
- __spreadValues$1({
1315
- key: "find",
1316
- wrapReturn: true
1317
- }, GetMethodConf),
1318
- __spreadProps(__spreadValues$1({
1319
- key: "findLast"
1320
- }, GetMethodConf), {
1321
- wrapReturn: true
1322
- }),
1323
- __spreadValues$1({
1324
- key: "findIndex"
1325
- }, GetMethodConf),
1326
- __spreadValues$1({
1327
- key: "findLastIndex"
1328
- }, GetMethodConf),
1329
- __spreadValues$1({
1330
- key: "forEach"
1331
- }, GetMethodConf),
1332
- __spreadValues$1({
1333
- key: "map"
1334
- }, GetMethodConf),
1335
- __spreadValues$1({
1336
- key: "some"
1337
- }, GetMethodConf),
1338
- __spreadProps(__spreadValues$1({
1339
- key: "reduce"
1340
- }, GetMethodConf), {
1341
- wrapArgs: 2
1342
- }),
1343
- __spreadProps(__spreadValues$1({
1344
- key: "reduceRight"
1345
- }, GetMethodConf), {
1346
- wrapArgs: 2
1347
- })
1348
- ].forEach(({ key, wrapReturn, wrapArgs }) => {
1349
- arrayMethodReWrites[key] = function(...args) {
1346
+ [{
1347
+ key: "every",
1348
+ ...GetMethodConf
1349
+ }, {
1350
+ key: "find",
1351
+ wrapReturn: true,
1352
+ ...GetMethodConf
1353
+ }, {
1354
+ key: "findLast",
1355
+ ...GetMethodConf,
1356
+ wrapReturn: true
1357
+ }, {
1358
+ key: "findIndex",
1359
+ ...GetMethodConf
1360
+ }, {
1361
+ key: "findLastIndex",
1362
+ ...GetMethodConf
1363
+ }, {
1364
+ key: "forEach",
1365
+ ...GetMethodConf
1366
+ }, {
1367
+ key: "map",
1368
+ ...GetMethodConf
1369
+ }, {
1370
+ key: "some",
1371
+ ...GetMethodConf
1372
+ }, {
1373
+ key: "reduce",
1374
+ ...GetMethodConf,
1375
+ wrapArgs: 2
1376
+ }, {
1377
+ key: "reduceRight",
1378
+ ...GetMethodConf,
1379
+ wrapArgs: 2
1380
+ }].forEach(({
1381
+ key,
1382
+ wrapReturn,
1383
+ wrapArgs
1384
+ }) => {
1385
+ arrayMethodReWrites[key] = function (...args) {
1350
1386
  const meta = this[Keys.Meta];
1351
1387
  const fn = Array.prototype[key];
1352
- const { deep: isDeep, scope } = meta;
1388
+ const isDeep = meta.deep,
1389
+ scope = meta.scope;
1353
1390
  const that = toRaw(this);
1354
1391
  warpCallbackArgs(isDeep, args, scope, wrapArgs);
1355
1392
  let result = fn.call(that, ...args);
@@ -1360,18 +1397,19 @@
1360
1397
  return result;
1361
1398
  };
1362
1399
  });
1363
- arrayMethodReWrites.toSorted = function(...args) {
1400
+ arrayMethodReWrites.toSorted = function (...args) {
1364
1401
  const fn = Array.prototype["toSorted"];
1365
1402
  const meta = this[Keys.Meta];
1366
- const { deep: isDeep, scope } = meta;
1403
+ const isDeep = meta.deep,
1404
+ scope = meta.scope;
1367
1405
  const that = toRaw(this);
1368
1406
  warpCallbackArgs(isDeep, args, scope, 3);
1369
1407
  let result = fn.call(that, ...args);
1370
1408
  this[Keys.Iterator];
1371
- return isDeep ? result.map((it) => deepSignal(it, scope)) : result;
1409
+ return isDeep ? result.map(it => deepSignal(it, scope)) : result;
1372
1410
  };
1373
- ["join", "toString", "toLocaleString"].forEach((key) => {
1374
- arrayMethodReWrites[key] = function(...args) {
1411
+ ["join", "toString", "toLocaleString"].forEach(key => {
1412
+ arrayMethodReWrites[key] = function (...args) {
1375
1413
  const fn = Array.prototype[key];
1376
1414
  const that = toRaw(this);
1377
1415
  const result = fn.call(that, ...args);
@@ -1381,7 +1419,7 @@
1381
1419
  });
1382
1420
  function warpCallbackArgs(isDeep, args, scope, wrapArgs = 1) {
1383
1421
  const callback = args[0];
1384
- const wrapCb = function(...cbArgs) {
1422
+ const wrapCb = function (...cbArgs) {
1385
1423
  if (isDeep) {
1386
1424
  if (wrapArgs & 1) cbArgs[0] = deepSignal(cbArgs[0], scope);
1387
1425
  if (wrapArgs & 2) cbArgs[1] = deepSignal(cbArgs[1], scope);
@@ -1400,6 +1438,15 @@
1400
1438
  _Store.Current = proxy;
1401
1439
  return proxy;
1402
1440
  }
1441
+ static {
1442
+ this[_b] = true;
1443
+ }
1444
+ static {
1445
+ this[_a] = ["ui", "raw"];
1446
+ }
1447
+ static {
1448
+ this.Current = null;
1449
+ }
1403
1450
  static new(keyMap = {}, staticMap = {}) {
1404
1451
  const parentStore = _Store.Current;
1405
1452
  const child = new this();
@@ -1428,27 +1475,8 @@
1428
1475
  this.parent = null;
1429
1476
  }
1430
1477
  };
1431
- _Store[_b] = true;
1432
- _Store[_a] = ["ui", "raw"];
1433
- _Store.Current = null;
1434
1478
  let Store = _Store;
1435
1479
 
1436
- var __defProp = Object.defineProperty;
1437
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1438
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1439
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
1440
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1441
- var __spreadValues = (a, b) => {
1442
- for (var prop in b || (b = {}))
1443
- if (__hasOwnProp.call(b, prop))
1444
- __defNormalProp(a, prop, b[prop]);
1445
- if (__getOwnPropSymbols)
1446
- for (var prop of __getOwnPropSymbols(b)) {
1447
- if (__propIsEnum.call(b, prop))
1448
- __defNormalProp(a, prop, b[prop]);
1449
- }
1450
- return a;
1451
- };
1452
1480
  const DefaultCustomSignalOpt = {
1453
1481
  /** 三种模式
1454
1482
  * 1. auto: 根据值类型自动判断 默认
@@ -1462,7 +1490,10 @@
1462
1490
  ({
1463
1491
  scheduler: Scheduler.Sync});
1464
1492
  const $ = (init, opt = {}) => {
1465
- opt = __spreadValues(__spreadValues({}, DefaultCustomSignalOpt), opt);
1493
+ opt = {
1494
+ ...DefaultCustomSignalOpt,
1495
+ ...opt
1496
+ };
1466
1497
  let intiValue, customPull;
1467
1498
  if (typeof init === "function") {
1468
1499
  intiValue = null;
@@ -1480,15 +1511,15 @@
1480
1511
  return s;
1481
1512
  };
1482
1513
  const effect = (customPull, depOrOpt, opt) => {
1483
- var _a;
1484
1514
  const hasDep = Array.isArray(depOrOpt);
1485
1515
  opt = hasDep ? opt || {} : depOrOpt || {};
1486
1516
  if (!hasDep) {
1487
- const s2 = Signal.create(null, __spreadValues({
1517
+ const s2 = Signal.create(null, {
1488
1518
  customPull,
1489
1519
  scheduler: Scheduler.Sync,
1490
- isScope: true
1491
- }, opt));
1520
+ isScope: true,
1521
+ ...opt
1522
+ });
1492
1523
  s2.v;
1493
1524
  const bound2 = dispose.bind(s2);
1494
1525
  bound2.ins = s2;
@@ -1496,9 +1527,14 @@
1496
1527
  }
1497
1528
  let mounted = false;
1498
1529
  const deps = depOrOpt;
1499
- const immediate = deps.length === 0 ? true : (_a = opt.immediate) != null ? _a : true;
1500
- const vs = Array.from({ length: deps.length }, () => ({ old: null, val: null }));
1501
- const s = Signal.create(null, __spreadValues({
1530
+ const immediate = deps.length === 0 ? true : opt.immediate ?? true;
1531
+ const vs = Array.from({
1532
+ length: deps.length
1533
+ }, () => ({
1534
+ old: null,
1535
+ val: null
1536
+ }));
1537
+ const s = Signal.create(null, {
1502
1538
  customPull() {
1503
1539
  for (let i = 0; i < deps.length; i++) {
1504
1540
  const value = deps[i].v;
@@ -1513,8 +1549,9 @@
1513
1549
  mounted = true;
1514
1550
  },
1515
1551
  scheduler: Scheduler.Sync,
1516
- isScope: true
1517
- }, opt));
1552
+ isScope: true,
1553
+ ...opt
1554
+ });
1518
1555
  s.v;
1519
1556
  const bound = dispose.bind(s);
1520
1557
  bound.ins = s;
@@ -1540,15 +1577,18 @@
1540
1577
  bound.ins = s;
1541
1578
  return bound;
1542
1579
  };
1543
- const customEffect = (opt) => {
1544
- return ((init, innerOpt = {}) => {
1545
- return effect(init, __spreadValues(__spreadValues({}, opt), innerOpt));
1546
- });
1580
+ const customEffect = opt => {
1581
+ return (init, innerOpt = {}) => {
1582
+ return effect(init, {
1583
+ ...opt,
1584
+ ...innerOpt
1585
+ });
1586
+ };
1547
1587
  };
1548
- const isSignal = (value) => {
1588
+ const isSignal = value => {
1549
1589
  return value instanceof Signal;
1550
1590
  };
1551
- const isScope = (value) => {
1591
+ const isScope = value => {
1552
1592
  return value instanceof Signal;
1553
1593
  };
1554
1594
 
@@ -1560,7 +1600,8 @@
1560
1600
  exports.Store = Store;
1561
1601
  exports.StoreIgnoreKeys = StoreIgnoreKeys;
1562
1602
  exports.TaskQueue = TaskQueue;
1563
- exports.batch = batch;
1603
+ exports.batchEnd = batchEnd;
1604
+ exports.batchStart = batchStart;
1564
1605
  exports.clean = clean;
1565
1606
  exports.customEffect = customEffect;
1566
1607
  exports.deepSignal = deepSignal;