@but212/atom-effect 0.29.0 → 0.30.0
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/atom-effect.min.js +1 -1
- package/dist/atom-effect.min.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +222 -115
- package/dist/index.mjs +732 -738
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,56 +1,118 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u = {
|
|
2
|
+
DISPOSED: 1,
|
|
3
|
+
IS_COMPUTED: 2,
|
|
4
|
+
DIRTY: 256,
|
|
5
|
+
RECOMPUTING: 512,
|
|
6
|
+
HAS_ERROR: 1024,
|
|
7
|
+
FORCE_COMPUTE: 2048,
|
|
8
|
+
IDLE: 65536,
|
|
9
|
+
PENDING: 131072,
|
|
10
|
+
RESOLVED: 262144,
|
|
11
|
+
REJECTED: 524288,
|
|
12
|
+
ATOM_SYNC: 16777216,
|
|
13
|
+
ATOM_NOTIFICATION_SCHEDULED: 33554432,
|
|
14
|
+
EFFECT_EXECUTING: 268435456
|
|
15
|
+
}, bt = Object.freeze({
|
|
16
|
+
ASYNC_STATE: u.IDLE | u.PENDING | u.RESOLVED | u.REJECTED,
|
|
17
|
+
COMPUTED_DIRTY_MASK: u.DIRTY | u.RECOMPUTING | u.FORCE_COMPUTE
|
|
18
|
+
}), U = Object.freeze({
|
|
2
19
|
IDLE: "idle",
|
|
3
20
|
PENDING: "pending",
|
|
4
21
|
RESOLVED: "resolved",
|
|
5
22
|
REJECTED: "rejected"
|
|
6
|
-
},
|
|
7
|
-
DISPOSED:
|
|
8
|
-
EXECUTING:
|
|
9
|
-
},
|
|
10
|
-
DISPOSED:
|
|
11
|
-
IS_COMPUTED:
|
|
12
|
-
DIRTY:
|
|
13
|
-
IDLE:
|
|
14
|
-
PENDING:
|
|
15
|
-
RESOLVED:
|
|
16
|
-
REJECTED:
|
|
17
|
-
RECOMPUTING:
|
|
18
|
-
HAS_ERROR:
|
|
19
|
-
FORCE_COMPUTE:
|
|
20
|
-
},
|
|
21
|
-
DISPOSED:
|
|
22
|
-
SYNC:
|
|
23
|
-
NOTIFICATION_SCHEDULED:
|
|
24
|
-
}, C = {
|
|
23
|
+
}), S = Object.freeze({
|
|
24
|
+
DISPOSED: u.DISPOSED,
|
|
25
|
+
EXECUTING: u.EFFECT_EXECUTING
|
|
26
|
+
}), Q = Object.freeze({
|
|
27
|
+
DISPOSED: u.DISPOSED,
|
|
28
|
+
IS_COMPUTED: u.IS_COMPUTED,
|
|
29
|
+
DIRTY: u.DIRTY,
|
|
30
|
+
IDLE: u.IDLE,
|
|
31
|
+
PENDING: u.PENDING,
|
|
32
|
+
RESOLVED: u.RESOLVED,
|
|
33
|
+
REJECTED: u.REJECTED,
|
|
34
|
+
RECOMPUTING: u.RECOMPUTING,
|
|
35
|
+
HAS_ERROR: u.HAS_ERROR,
|
|
36
|
+
FORCE_COMPUTE: u.FORCE_COMPUTE
|
|
37
|
+
}), f = Object.freeze({
|
|
38
|
+
DISPOSED: u.DISPOSED,
|
|
39
|
+
SYNC: u.ATOM_SYNC,
|
|
40
|
+
NOTIFICATION_SCHEDULED: u.ATOM_NOTIFICATION_SCHEDULED
|
|
41
|
+
}), C = Object.freeze({
|
|
25
42
|
MAX_EXECUTIONS_PER_SECOND: 1e3,
|
|
26
43
|
MAX_EXECUTIONS_PER_EFFECT: 100,
|
|
27
44
|
MAX_EXECUTIONS_PER_FLUSH: 1e4,
|
|
28
45
|
MAX_FLUSH_ITERATIONS: 1e3,
|
|
29
46
|
MIN_FLUSH_ITERATIONS: 10,
|
|
30
47
|
BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
|
|
31
|
-
},
|
|
48
|
+
}), k = 1073741823, Y = Object.freeze({
|
|
32
49
|
WARN_INFINITE_LOOP: !0,
|
|
33
|
-
EFFECT_FREQUENCY_WINDOW: 1e3
|
|
34
|
-
|
|
50
|
+
EFFECT_FREQUENCY_WINDOW: 1e3,
|
|
51
|
+
LOOP_THRESHOLD: 100
|
|
52
|
+
}), at = Object.freeze({ MAX_PROMISE_ID: k }), w = Object.freeze({
|
|
35
53
|
UNINITIALIZED: -1,
|
|
36
54
|
MIN: 1
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
}), ot = !1;
|
|
56
|
+
try {
|
|
57
|
+
ot = !!(typeof globalThis < "u" && globalThis.__ATOM_DEBUG__ || typeof sessionStorage < "u" && sessionStorage.getItem("__ATOM_DEBUG__") === "true");
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
var _ = (typeof process < "u" && process.env, typeof __DEV__ < "u" && !!__DEV__ || ot), et = Object.freeze([]), g = class V extends Error {
|
|
61
|
+
constructor(e, s = null, i = !0, n) {
|
|
62
|
+
super(e), this.cause = s, this.recoverable = i, this.code = n, this.name = "AtomError", Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
63
|
+
}
|
|
64
|
+
getChain() {
|
|
65
|
+
if (this.cause === null || this.cause === void 0) return [this];
|
|
66
|
+
const e = [this], s = /* @__PURE__ */ new Set([this]);
|
|
67
|
+
let i = this.cause;
|
|
68
|
+
for (; i != null; ) {
|
|
69
|
+
const n = s.has(i);
|
|
70
|
+
if (e.push(i), n) break;
|
|
71
|
+
if (s.add(i), i instanceof V) i = i.cause;
|
|
72
|
+
else if (i instanceof Error && "cause" in i) i = i.cause;
|
|
73
|
+
else break;
|
|
74
|
+
}
|
|
75
|
+
return e;
|
|
40
76
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
77
|
+
toJSON(e = /* @__PURE__ */ new Set()) {
|
|
78
|
+
if (e.has(this)) return {
|
|
79
|
+
name: this.name,
|
|
80
|
+
message: "[Circular Reference]",
|
|
81
|
+
recoverable: this.recoverable,
|
|
82
|
+
code: this.code
|
|
83
|
+
};
|
|
84
|
+
e.add(this);
|
|
85
|
+
let s = this.cause;
|
|
86
|
+
return this.cause instanceof V ? s = this.cause.toJSON(e) : this.cause instanceof Error && (s = {
|
|
87
|
+
name: this.cause.name,
|
|
88
|
+
message: this.cause.message,
|
|
89
|
+
stack: this.cause.stack,
|
|
90
|
+
cause: this.cause.cause
|
|
91
|
+
}), {
|
|
92
|
+
name: this.name,
|
|
93
|
+
message: this.message,
|
|
94
|
+
code: this.code,
|
|
95
|
+
recoverable: this.recoverable,
|
|
96
|
+
stack: this.stack,
|
|
97
|
+
cause: s
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
static format(e, s, i) {
|
|
101
|
+
return `${e} (${s}): ${i}`;
|
|
102
|
+
}
|
|
103
|
+
}, A = class extends g {
|
|
104
|
+
constructor(...t) {
|
|
105
|
+
super(...t), this.name = "ComputedError";
|
|
44
106
|
}
|
|
45
|
-
},
|
|
46
|
-
constructor(t, s =
|
|
47
|
-
super(t, s,
|
|
107
|
+
}, m = class extends g {
|
|
108
|
+
constructor(t, e = null, s = !1, i) {
|
|
109
|
+
super(t, e, s, i), this.name = "EffectError";
|
|
48
110
|
}
|
|
49
|
-
},
|
|
50
|
-
constructor(t, s =
|
|
51
|
-
super(t, s,
|
|
111
|
+
}, L = class extends g {
|
|
112
|
+
constructor(t, e = null, s = !1, i) {
|
|
113
|
+
super(t, e, s, i), this.name = "SchedulerError";
|
|
52
114
|
}
|
|
53
|
-
},
|
|
115
|
+
}, h = {
|
|
54
116
|
COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
|
|
55
117
|
COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
|
|
56
118
|
COMPUTED_COMPUTATION_FAILED: "Computation execution failed",
|
|
@@ -63,232 +125,209 @@ var y = {
|
|
|
63
125
|
EFFECT_EXECUTION_FAILED: "Effect execution failed",
|
|
64
126
|
EFFECT_CLEANUP_FAILED: "Effect cleanup failed",
|
|
65
127
|
EFFECT_DISPOSED: "Attempted to run disposed effect",
|
|
66
|
-
SCHEDULER_FLUSH_OVERFLOW: (t,
|
|
128
|
+
SCHEDULER_FLUSH_OVERFLOW: (t, e) => `Maximum flush iterations (${t}) exceeded. ${e} jobs dropped. Possible infinite loop.`,
|
|
67
129
|
CALLBACK_ERROR_IN_ERROR_HANDLER: "Exception encountered in onError handler",
|
|
68
130
|
EFFECT_FREQUENCY_LIMIT_EXCEEDED: "Effect executed too frequently within 1 second. Suspected infinite loop.",
|
|
69
131
|
SCHEDULER_CALLBACK_MUST_BE_FUNCTION: "Scheduler callback must be a function",
|
|
70
132
|
SCHEDULER_END_BATCH_WITHOUT_START: "endBatch() called without matching startBatch(). Ignoring.",
|
|
71
133
|
BATCH_CALLBACK_MUST_BE_FUNCTION: "Batch callback must be a function"
|
|
72
134
|
};
|
|
73
|
-
function
|
|
74
|
-
|
|
135
|
+
function O(t, e, s) {
|
|
136
|
+
if (t instanceof g) return new e(g.format(t.name, s, t.message), t, t.recoverable, t.code);
|
|
137
|
+
if (t instanceof Error) {
|
|
138
|
+
const i = t.name || t.constructor.name || "Error";
|
|
139
|
+
return new e(g.format(i, s, t.message), t);
|
|
140
|
+
}
|
|
141
|
+
return new e(g.format("Unexpected error", s, String(t)), t);
|
|
75
142
|
}
|
|
76
|
-
var
|
|
143
|
+
var st = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), ft = /* @__PURE__ */ Symbol("AtomEffect.Id"), it = /* @__PURE__ */ Symbol("AtomEffect.Type"), B = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), Et = "[Atom Effect]", dt = class {
|
|
77
144
|
constructor() {
|
|
78
|
-
this.enabled = !
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
145
|
+
this.enabled = !0, this.warnInfiniteLoop = Y.WARN_INFINITE_LOOP, this._updateCounts = /* @__PURE__ */ new Map(), this._nodeRegistry = /* @__PURE__ */ new Map(), this._threshold = Y.LOOP_THRESHOLD, this._cleanupScheduled = !1, this.warn = (t, e) => {
|
|
146
|
+
this.enabled && t && console.warn(`${Et} ${e}`);
|
|
147
|
+
}, this.registerNode = (t) => {
|
|
148
|
+
this._nodeRegistry.set(t.id, new WeakRef(t));
|
|
149
|
+
}, this.attachDebugInfo = (t, e, s, i) => {
|
|
150
|
+
this.enabled && (Object.defineProperties(t, {
|
|
151
|
+
[st]: {
|
|
152
|
+
value: i ?? `${e}_${s}`,
|
|
153
|
+
configurable: !0
|
|
154
|
+
},
|
|
155
|
+
[ft]: {
|
|
156
|
+
value: s,
|
|
157
|
+
configurable: !0
|
|
158
|
+
},
|
|
159
|
+
[it]: {
|
|
160
|
+
value: e,
|
|
161
|
+
configurable: !0
|
|
162
|
+
}
|
|
163
|
+
}), this.registerNode(t));
|
|
164
|
+
}, this.trackUpdate = (t, e) => {
|
|
165
|
+
if (!this.enabled || !this.warnInfiniteLoop) return;
|
|
166
|
+
const s = this._updateCounts, i = (s.get(t) ?? 0) + 1;
|
|
167
|
+
i > this._threshold ? this.warn(!0, `Infinite loop detected for ${e ?? `dependency ${t}`}. Over ${this._threshold} updates in a single execution scope.`) : s.set(t, i), this._cleanupScheduled || (this._cleanupScheduled = !0, Promise.resolve().then(() => {
|
|
168
|
+
this._updateCounts.clear(), this._cleanupScheduled = !1;
|
|
169
|
+
}));
|
|
170
|
+
}, this.dumpGraph = () => {
|
|
171
|
+
const t = [];
|
|
172
|
+
for (const [e, s] of this._nodeRegistry) {
|
|
173
|
+
const i = s.deref();
|
|
174
|
+
i ? t.push({
|
|
175
|
+
id: e,
|
|
176
|
+
name: this.getDebugName(i),
|
|
177
|
+
type: this.getDebugType(i),
|
|
178
|
+
updateCount: this._updateCounts.get(e) ?? 0
|
|
179
|
+
}) : (this._nodeRegistry.delete(e), this._updateCounts.delete(e));
|
|
180
|
+
}
|
|
181
|
+
return t;
|
|
182
|
+
}, this.getDebugName = (t) => {
|
|
183
|
+
if (t)
|
|
184
|
+
return t[st];
|
|
185
|
+
}, this.getDebugType = (t) => {
|
|
186
|
+
if (t)
|
|
187
|
+
return t[it];
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}, pt = {
|
|
191
|
+
enabled: !1,
|
|
192
|
+
warnInfiniteLoop: !1,
|
|
193
|
+
warn: () => {
|
|
194
|
+
},
|
|
195
|
+
registerNode: () => {
|
|
196
|
+
},
|
|
197
|
+
attachDebugInfo: () => {
|
|
198
|
+
},
|
|
199
|
+
trackUpdate: () => {
|
|
200
|
+
},
|
|
201
|
+
dumpGraph: () => [],
|
|
202
|
+
getDebugName: () => {
|
|
203
|
+
},
|
|
204
|
+
getDebugType: () => {
|
|
205
|
+
}
|
|
206
|
+
}, d = _ ? new dt() : pt, It = 1, Ct = () => It++ | 0, ut = class {
|
|
207
|
+
constructor() {
|
|
208
|
+
this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._actualCount = 0, this._overflow = null, this._freeIndices = null;
|
|
83
209
|
}
|
|
84
|
-
|
|
85
|
-
if (t
|
|
86
|
-
|
|
210
|
+
_rawWrite(t, e) {
|
|
211
|
+
if (t < 4) t === 0 ? this._s0 = e : t === 1 ? this._s1 = e : t === 2 ? this._s2 = e : this._s3 = e;
|
|
212
|
+
else {
|
|
213
|
+
this._overflow === null && (this._overflow = []);
|
|
214
|
+
const s = this._overflow, i = t - 4;
|
|
215
|
+
s[i] = e;
|
|
216
|
+
}
|
|
87
217
|
}
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
return t
|
|
218
|
+
_rawAdd(t) {
|
|
219
|
+
if (this._s0 === null)
|
|
220
|
+
return this._s0 = t, 0;
|
|
221
|
+
if (this._s1 === null)
|
|
222
|
+
return this._s1 = t, 1;
|
|
223
|
+
if (this._s2 === null)
|
|
224
|
+
return this._s2 = t, 2;
|
|
225
|
+
if (this._s3 === null)
|
|
226
|
+
return this._s3 = t, 3;
|
|
227
|
+
this._overflow === null && (this._overflow = []);
|
|
228
|
+
const e = this._overflow, s = this._freeIndices;
|
|
229
|
+
if (s !== null && s.length > 0) {
|
|
230
|
+
const i = s.pop();
|
|
231
|
+
return e[i] = t, i + 4;
|
|
232
|
+
}
|
|
233
|
+
return e.push(t), 4 + e.length - 1;
|
|
91
234
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
235
|
+
_rawSwap(t, e) {
|
|
236
|
+
if (t === e) return;
|
|
237
|
+
const s = this.getAt(t), i = this.getAt(e);
|
|
238
|
+
this._rawWrite(t, i), this._rawWrite(e, s);
|
|
95
239
|
}
|
|
96
240
|
get size() {
|
|
241
|
+
return this._actualCount;
|
|
242
|
+
}
|
|
243
|
+
get physicalSize() {
|
|
97
244
|
return this._count;
|
|
98
245
|
}
|
|
99
246
|
getAt(t) {
|
|
100
|
-
|
|
101
|
-
case 0:
|
|
102
|
-
return this._s0;
|
|
103
|
-
case 1:
|
|
104
|
-
return this._s1;
|
|
105
|
-
case 2:
|
|
106
|
-
return this._s2;
|
|
107
|
-
case 3:
|
|
108
|
-
return this._s3;
|
|
109
|
-
}
|
|
110
|
-
const s = this._overflow;
|
|
111
|
-
if (s !== null) {
|
|
112
|
-
const e = s[t - 4];
|
|
113
|
-
return e === void 0 ? null : e;
|
|
114
|
-
}
|
|
115
|
-
return null;
|
|
247
|
+
return t < 4 ? t === 0 ? this._s0 : t === 1 ? this._s1 : t === 2 ? this._s2 : this._s3 : this._overflow?.[t - 4] ?? null;
|
|
116
248
|
}
|
|
117
|
-
setAt(t,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
break;
|
|
125
|
-
case 2:
|
|
126
|
-
this._s2 = s;
|
|
127
|
-
break;
|
|
128
|
-
case 3:
|
|
129
|
-
this._s3 = s;
|
|
130
|
-
break;
|
|
131
|
-
default:
|
|
132
|
-
this._overflow ??= [], this._overflow[t - 4] = s;
|
|
133
|
-
}
|
|
134
|
-
t >= this._count && (this._count = t + 1);
|
|
249
|
+
setAt(t, e) {
|
|
250
|
+
const s = this.getAt(t);
|
|
251
|
+
s !== e && (this._rawWrite(t, e), s === null ? this._actualCount++ : e === null && this._actualCount--, e !== null && t >= this._count ? this._count = t + 1 : e === null && this._shrinkPhysicalSizeFrom(t));
|
|
252
|
+
}
|
|
253
|
+
_shrinkPhysicalSizeFrom(t) {
|
|
254
|
+
if (t === this._count - 1)
|
|
255
|
+
for (this._count--; this._count > 0 && this.getAt(this._count - 1) == null; ) this._count--;
|
|
135
256
|
}
|
|
136
257
|
truncateFrom(t) {
|
|
137
|
-
|
|
138
|
-
if (t >= s) return;
|
|
139
|
-
if (t <= 3) {
|
|
140
|
-
if (t <= 0) {
|
|
141
|
-
const i = this._s0;
|
|
142
|
-
i != null && (this._onItemRemoved(i), this._s0 = null);
|
|
143
|
-
}
|
|
144
|
-
if (t <= 1) {
|
|
145
|
-
const i = this._s1;
|
|
146
|
-
i != null && (this._onItemRemoved(i), this._s1 = null);
|
|
147
|
-
}
|
|
148
|
-
if (t <= 2) {
|
|
149
|
-
const i = this._s2;
|
|
150
|
-
i != null && (this._onItemRemoved(i), this._s2 = null);
|
|
151
|
-
}
|
|
152
|
-
if (t <= 3) {
|
|
153
|
-
const i = this._s3;
|
|
154
|
-
i != null && (this._onItemRemoved(i), this._s3 = null);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
258
|
+
t <= 3 && (t <= 0 && this._s0 !== null && (this._onItemRemoved(this._s0), this._s0 = null, this._actualCount--), t <= 1 && this._s1 !== null && (this._onItemRemoved(this._s1), this._s1 = null, this._actualCount--), t <= 2 && this._s2 !== null && (this._onItemRemoved(this._s2), this._s2 = null, this._actualCount--), t <= 3 && this._s3 !== null && (this._onItemRemoved(this._s3), this._s3 = null, this._actualCount--));
|
|
157
259
|
const e = this._overflow;
|
|
158
|
-
if (e !== null
|
|
159
|
-
const
|
|
160
|
-
for (let n =
|
|
161
|
-
const
|
|
162
|
-
|
|
260
|
+
if (e !== null) {
|
|
261
|
+
const s = t > 4 ? t - 4 : 0, i = e.length;
|
|
262
|
+
for (let n = s; n < i; n++) {
|
|
263
|
+
const r = e[n];
|
|
264
|
+
r != null && (this._onItemRemoved(r), e[n] = null, this._actualCount--);
|
|
163
265
|
}
|
|
164
|
-
t <= 4 ?
|
|
266
|
+
t <= 4 ? this._overflow = null : e.length = t - 4;
|
|
165
267
|
}
|
|
166
|
-
this.
|
|
268
|
+
this._count = t, this._actualCount < 0 && (this._actualCount = 0), this._freeIndices = null;
|
|
167
269
|
}
|
|
168
270
|
_onItemRemoved(t) {
|
|
169
271
|
}
|
|
170
272
|
add(t) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (this._s1 === null) {
|
|
176
|
-
this._s1 = t, this._count++;
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (this._s2 === null) {
|
|
180
|
-
this._s2 = t, this._count++;
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
if (this._s3 === null) {
|
|
184
|
-
this._s3 = t, this._count++;
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
this._addToOverflow(t);
|
|
188
|
-
}
|
|
189
|
-
_addToOverflow(t) {
|
|
190
|
-
const s = this._overflow;
|
|
191
|
-
if (s === null) this._overflow = [t];
|
|
192
|
-
else {
|
|
193
|
-
const e = this._freeIndices;
|
|
194
|
-
e !== null && e.length > 0 ? s[e.pop()] = t : s.push(t);
|
|
195
|
-
}
|
|
196
|
-
this._count++;
|
|
273
|
+
const e = this._rawAdd(t);
|
|
274
|
+
return e >= this._count && (this._count = e + 1), this._actualCount++, e;
|
|
197
275
|
}
|
|
198
276
|
remove(t) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (this._s1 === t)
|
|
202
|
-
|
|
203
|
-
if (this.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const s = this._overflow;
|
|
208
|
-
if (s == null) return !1;
|
|
209
|
-
for (let e = 0, i = s.length; e < i; e++) if (s[e] === t) {
|
|
210
|
-
s[e] = null, this._count--;
|
|
211
|
-
let r = this._freeIndices;
|
|
212
|
-
return r === null && (r = this._freeIndices = []), r.push(e), !0;
|
|
277
|
+
let e = -1;
|
|
278
|
+
if (this._s0 === t) e = 0;
|
|
279
|
+
else if (this._s1 === t) e = 1;
|
|
280
|
+
else if (this._s2 === t) e = 2;
|
|
281
|
+
else if (this._s3 === t) e = 3;
|
|
282
|
+
else {
|
|
283
|
+
const s = this._overflow;
|
|
284
|
+
s !== null && (e = s.indexOf(t), e !== -1 && (e += 4));
|
|
213
285
|
}
|
|
214
|
-
return !1;
|
|
286
|
+
return e !== -1 ? (this._rawWrite(e, null), this._shrinkPhysicalSizeFrom(e), this._actualCount--, e >= 4 && (this._freeIndices === null && (this._freeIndices = []), this._freeIndices.push(e - 4)), !0) : !1;
|
|
215
287
|
}
|
|
216
288
|
has(t) {
|
|
217
|
-
if (this.
|
|
289
|
+
if (this._actualCount === 0) return !1;
|
|
218
290
|
if (this._s0 === t || this._s1 === t || this._s2 === t || this._s3 === t) return !0;
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
for (let e = 0, i = s.length; e < i; e++) if (s[e] === t) return !0;
|
|
222
|
-
}
|
|
223
|
-
return !1;
|
|
291
|
+
const e = this._overflow;
|
|
292
|
+
return e !== null ? e.indexOf(t) !== -1 : !1;
|
|
224
293
|
}
|
|
225
294
|
forEach(t) {
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const n = this._s2;
|
|
236
|
-
if (n != null && (t(n), ++e === s))
|
|
237
|
-
return;
|
|
238
|
-
const o = this._s3;
|
|
239
|
-
if (o != null && (t(o), ++e === s))
|
|
295
|
+
const e = this._actualCount;
|
|
296
|
+
if (e === 0) return;
|
|
297
|
+
if (e === this._count) {
|
|
298
|
+
this._s0 != null && t(this._s0), this._s1 != null && t(this._s1), this._s2 != null && t(this._s2), this._s3 != null && t(this._s3);
|
|
299
|
+
const n = this._overflow;
|
|
300
|
+
if (n !== null) for (let r = 0, o = n.length; r < o; r++) {
|
|
301
|
+
const c = n[r];
|
|
302
|
+
c != null && t(c);
|
|
303
|
+
}
|
|
240
304
|
return;
|
|
241
|
-
const u = this._overflow;
|
|
242
|
-
if (u != null) for (let l = 0, h = u.length; l < h; l++) {
|
|
243
|
-
const f = u[l];
|
|
244
|
-
if (f != null && (t(f), ++e === s))
|
|
245
|
-
return;
|
|
246
305
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (i != null && (t(i), ++e === s))
|
|
254
|
-
return e;
|
|
255
|
-
const r = this._s1;
|
|
256
|
-
if (r != null && (t(r), ++e === s))
|
|
257
|
-
return e;
|
|
258
|
-
const n = this._s2;
|
|
259
|
-
if (n != null && (t(n), ++e === s))
|
|
260
|
-
return e;
|
|
261
|
-
const o = this._s3;
|
|
262
|
-
if (o != null && (t(o), ++e === s))
|
|
263
|
-
return e;
|
|
264
|
-
const u = this._overflow;
|
|
265
|
-
if (u != null) for (let l = 0, h = u.length; l < h; l++) {
|
|
266
|
-
const f = u[l];
|
|
267
|
-
if (f != null && (t(f), ++e === s))
|
|
268
|
-
return e;
|
|
306
|
+
let s = 0;
|
|
307
|
+
const i = this._count;
|
|
308
|
+
for (let n = 0; n < i; n++) {
|
|
309
|
+
const r = this.getAt(n);
|
|
310
|
+
if (r != null && (t(r), ++s >= e))
|
|
311
|
+
break;
|
|
269
312
|
}
|
|
270
|
-
return e;
|
|
271
313
|
}
|
|
272
314
|
compact() {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
s > e && (t[e] = t.pop(), s--, e++);
|
|
282
|
-
} else e++;
|
|
283
|
-
this._freeIndices = null, s === 0 && (this._overflow = null);
|
|
315
|
+
if (this._actualCount === this._count) return;
|
|
316
|
+
let t = 0;
|
|
317
|
+
const e = this._count;
|
|
318
|
+
for (let s = 0; s < e; s++) {
|
|
319
|
+
const i = this.getAt(s);
|
|
320
|
+
i != null && (s !== t && (this._rawWrite(t, i), this._rawWrite(s, null)), t++);
|
|
321
|
+
}
|
|
322
|
+
this._count = this._actualCount, this._overflow !== null && (t <= 4 ? this._overflow = null : this._overflow.length = t - 4), this._freeIndices = null;
|
|
284
323
|
}
|
|
285
324
|
clear() {
|
|
286
|
-
this._s0 =
|
|
325
|
+
this._s0 = this._s1 = this._s2 = this._s3 = null, this._count = 0, this._actualCount = 0, this._overflow = null, this._freeIndices = null;
|
|
287
326
|
}
|
|
288
327
|
dispose() {
|
|
289
328
|
this.clear();
|
|
290
329
|
}
|
|
291
|
-
},
|
|
330
|
+
}, ht = class extends ut {
|
|
292
331
|
constructor(...t) {
|
|
293
332
|
super(...t), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1;
|
|
294
333
|
}
|
|
@@ -296,383 +335,348 @@ var q = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), lt = /* @__PURE__ */ Sym
|
|
|
296
335
|
this.hasComputeds = !1;
|
|
297
336
|
}
|
|
298
337
|
_onItemRemoved(t) {
|
|
299
|
-
|
|
300
|
-
s && s();
|
|
338
|
+
t.unsub?.();
|
|
301
339
|
}
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
return n.version = t.version, s !== 1 && (this._s1 = this._s0, this._s0 = n), !0;
|
|
318
|
-
}
|
|
319
|
-
case 2:
|
|
320
|
-
if (e > 2) {
|
|
321
|
-
const n = this._s2;
|
|
322
|
-
if (n && n.node === t && n.unsub) {
|
|
323
|
-
if (n.version = t.version, s !== 2) {
|
|
324
|
-
const o = s === 0 ? this._s0 : this._s1;
|
|
325
|
-
s === 0 ? this._s0 = n : this._s1 = n, this._s2 = o;
|
|
326
|
-
}
|
|
327
|
-
return !0;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
case 3:
|
|
331
|
-
if (e > 3) {
|
|
332
|
-
const n = this._s3;
|
|
333
|
-
if (n && n.node === t && n.unsub) {
|
|
334
|
-
if (n.version = t.version, s !== 3) {
|
|
335
|
-
let o;
|
|
336
|
-
s === 0 ? (o = this._s0, this._s0 = n) : s === 1 ? (o = this._s1, this._s1 = n) : (o = this._s2, this._s2 = n), this._s3 = o;
|
|
337
|
-
}
|
|
338
|
-
return !0;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
const r = this._overflow;
|
|
343
|
-
if (r) {
|
|
344
|
-
const n = t.version, o = s > 4 ? s : 4, u = r.length;
|
|
345
|
-
for (let l = o - 4; l < u; l++) {
|
|
346
|
-
const h = r[l];
|
|
347
|
-
if (h && h.node === t && h.unsub)
|
|
348
|
-
return h.version = n, this._swapGeneral(l + 4, s, h), !0;
|
|
349
|
-
}
|
|
340
|
+
setAt(t, e) {
|
|
341
|
+
const s = this.getAt(t);
|
|
342
|
+
super.setAt(t, e), this._map !== null && (s?.unsub && this._map.delete(s.node), e?.unsub && this._map.set(e.node, t));
|
|
343
|
+
}
|
|
344
|
+
claimExisting(t, e) {
|
|
345
|
+
const s = this._count;
|
|
346
|
+
if (s <= e) return !1;
|
|
347
|
+
const i = this.getAt(e);
|
|
348
|
+
if (i && i.node === t && i.unsub)
|
|
349
|
+
return i.version = t.version, !0;
|
|
350
|
+
if (this._map !== null || s - e > this._SCAN_THRESHOLD) return this._claimViaMap(t, e);
|
|
351
|
+
for (let n = e + 1; n < s; n++) {
|
|
352
|
+
const r = this.getAt(n);
|
|
353
|
+
if (r && r.node === t && r.unsub)
|
|
354
|
+
return r.version = t.version, this._rawSwap(n, e), !0;
|
|
350
355
|
}
|
|
351
356
|
return !1;
|
|
352
357
|
}
|
|
353
|
-
_claimViaMap(t,
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
s <= 1 && l?.unsub && e.set(l.node, 1);
|
|
363
|
-
const h = this._s2;
|
|
364
|
-
s <= 2 && h?.unsub && e.set(h.node, 2);
|
|
365
|
-
const f = this._s3;
|
|
366
|
-
s <= 3 && f?.unsub && e.set(f.node, 3);
|
|
367
|
-
}
|
|
368
|
-
const o = this._overflow;
|
|
369
|
-
if (o && n > 4) {
|
|
370
|
-
const u = s > 4 ? s : 4, l = o.length;
|
|
371
|
-
for (let h = u - 4; h < l; h++) {
|
|
372
|
-
const f = o[h];
|
|
373
|
-
f?.unsub && e.set(f.node, h + 4);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
const i = e.get(t);
|
|
378
|
-
if (i === void 0 || i < s) return !1;
|
|
379
|
-
const r = this.getAt(i);
|
|
380
|
-
if (r == null || !r.unsub) return !1;
|
|
381
|
-
if (r.version = t.version, i !== s) {
|
|
382
|
-
let n;
|
|
383
|
-
s === 0 ? n = this._s0 : s === 1 ? n = this._s1 : s === 2 ? n = this._s2 : s === 3 ? n = this._s3 : n = this._overflow[s - 4] ?? null, this.setAt(s, r), this.setAt(i, n), n?.unsub && e.set(n.node, i), e.set(t, s);
|
|
358
|
+
_claimViaMap(t, e) {
|
|
359
|
+
this._map === null && (this._map = this._initMap());
|
|
360
|
+
const s = this._map, i = s.get(t);
|
|
361
|
+
if (i === void 0 || i < e) return !1;
|
|
362
|
+
const n = this.getAt(i);
|
|
363
|
+
if (n == null || !n.unsub) return !1;
|
|
364
|
+
if (n.version = t.version, i !== e) {
|
|
365
|
+
const r = this.getAt(e);
|
|
366
|
+
this._rawSwap(i, e), s.set(t, e), r?.unsub && s.set(r.node, i);
|
|
384
367
|
}
|
|
385
368
|
return !0;
|
|
386
369
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
let
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
else if (t === 2) this._s2 = i;
|
|
393
|
-
else if (t === 3) this._s3 = i;
|
|
394
|
-
else {
|
|
395
|
-
const r = this._overflow;
|
|
396
|
-
r[t - 4] = i;
|
|
370
|
+
_initMap() {
|
|
371
|
+
const t = /* @__PURE__ */ new Map();
|
|
372
|
+
for (let e = 0; e < this._count; e++) {
|
|
373
|
+
const s = this.getAt(e);
|
|
374
|
+
s?.unsub && t.set(s.node, e);
|
|
397
375
|
}
|
|
376
|
+
return t;
|
|
398
377
|
}
|
|
399
|
-
insertNew(t,
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
if (t === 0) this._s0 = s;
|
|
406
|
-
else if (t === 1) this._s1 = s;
|
|
407
|
-
else if (t === 2) this._s2 = s;
|
|
408
|
-
else if (t === 3) this._s3 = s;
|
|
409
|
-
else {
|
|
410
|
-
let i = this._overflow;
|
|
411
|
-
i || (i = [], this._overflow = i), i[t - 4] = s;
|
|
378
|
+
insertNew(t, e) {
|
|
379
|
+
const s = this.getAt(t);
|
|
380
|
+
if (s !== null) {
|
|
381
|
+
const i = this._rawAdd(s);
|
|
382
|
+
i >= this._count && (this._count = i + 1), this._map !== null && s.unsub && this._map.set(s.node, i);
|
|
412
383
|
}
|
|
413
|
-
t >=
|
|
414
|
-
}
|
|
415
|
-
truncateFrom(t) {
|
|
416
|
-
t >= this._count || (super.truncateFrom(t), this._map !== null && (this._map.clear(), this._map = null));
|
|
384
|
+
this._rawWrite(t, e), t >= this._count && (this._count = t + 1), this._actualCount++, this._map !== null && e.unsub && this._map.set(e.node, t);
|
|
417
385
|
}
|
|
418
|
-
|
|
419
|
-
|
|
386
|
+
add(t) {
|
|
387
|
+
const e = super.add(t);
|
|
388
|
+
return this._map !== null && t.unsub && this._map.set(t.node, e), e;
|
|
420
389
|
}
|
|
421
390
|
remove(t) {
|
|
422
|
-
throw new Error("remove()
|
|
391
|
+
throw new Error("remove() prohibited");
|
|
423
392
|
}
|
|
424
393
|
compact() {
|
|
425
394
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
this.node = t, this.version = s, this.unsub = e;
|
|
429
|
-
}
|
|
430
|
-
}, ft = class {
|
|
431
|
-
constructor(t, s) {
|
|
432
|
-
this.fn = t, this.sub = s;
|
|
395
|
+
truncateFrom(t) {
|
|
396
|
+
super.truncateFrom(t), this._map !== null && (this._map = null);
|
|
433
397
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if (e !== void 0) {
|
|
437
|
-
e(t, s);
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
const i = this.sub;
|
|
441
|
-
i !== void 0 && i.execute();
|
|
398
|
+
disposeAll() {
|
|
399
|
+
this.truncateFrom(0), this.hasComputeds = !1;
|
|
442
400
|
}
|
|
443
|
-
},
|
|
401
|
+
}, F = /* @__PURE__ */ Symbol.for("atom-effect/brand"), p = {
|
|
402
|
+
Atom: 1,
|
|
403
|
+
Writable: 2,
|
|
404
|
+
Computed: 4,
|
|
405
|
+
Effect: 8
|
|
406
|
+
};
|
|
407
|
+
function q(t, e) {
|
|
408
|
+
if (!t) return !1;
|
|
409
|
+
const s = typeof t;
|
|
410
|
+
return (s === "object" || s === "function") && !!((t[F] ?? 0) & e);
|
|
411
|
+
}
|
|
412
|
+
function At(t) {
|
|
413
|
+
return q(t, p.Atom);
|
|
414
|
+
}
|
|
415
|
+
function yt(t) {
|
|
416
|
+
return q(t, p.Computed);
|
|
417
|
+
}
|
|
418
|
+
function Rt(t) {
|
|
419
|
+
return q(t, p.Effect);
|
|
420
|
+
}
|
|
421
|
+
function $(t) {
|
|
422
|
+
if (t instanceof Promise) return !0;
|
|
423
|
+
if (!t) return !1;
|
|
424
|
+
const e = typeof t;
|
|
425
|
+
return (e === "object" || e === "function") && typeof t.then == "function";
|
|
426
|
+
}
|
|
427
|
+
var j = class {
|
|
428
|
+
constructor(t, e, s = void 0) {
|
|
429
|
+
this.node = t, this.version = e, this.unsub = s;
|
|
430
|
+
}
|
|
431
|
+
}, gt = class {
|
|
432
|
+
constructor(t = void 0, e = void 0) {
|
|
433
|
+
this.fn = t, this.sub = e;
|
|
434
|
+
}
|
|
435
|
+
notify(t, e) {
|
|
436
|
+
M(() => {
|
|
437
|
+
const s = this.fn;
|
|
438
|
+
s !== void 0 && s(t, e);
|
|
439
|
+
const i = this.sub;
|
|
440
|
+
i !== void 0 && i.execute();
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}, Dt = class {
|
|
444
444
|
constructor() {
|
|
445
445
|
this.current = null;
|
|
446
446
|
}
|
|
447
|
-
run(t,
|
|
448
|
-
if (this.current === t) return
|
|
449
|
-
const
|
|
447
|
+
run(t, e) {
|
|
448
|
+
if (this.current === t) return e();
|
|
449
|
+
const s = this.current;
|
|
450
450
|
this.current = t;
|
|
451
451
|
try {
|
|
452
|
-
|
|
452
|
+
const i = e();
|
|
453
|
+
return _ && d.warn($(i), 'Detected Promise returned within tracking context. Dependencies accessed after "await" will NOT be tracked. Consider using synchronous tracking before the async boundary.'), i;
|
|
453
454
|
} finally {
|
|
454
|
-
this.current =
|
|
455
|
+
this.current = s;
|
|
455
456
|
}
|
|
456
457
|
}
|
|
457
|
-
},
|
|
458
|
-
function
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
461
|
-
|
|
458
|
+
}, l = new Dt();
|
|
459
|
+
function M(t) {
|
|
460
|
+
const e = l, s = e.current;
|
|
461
|
+
if (s === null) return t();
|
|
462
|
+
e.current = null;
|
|
462
463
|
try {
|
|
463
464
|
return t();
|
|
464
465
|
} finally {
|
|
465
|
-
|
|
466
|
+
e.current = s;
|
|
466
467
|
}
|
|
467
468
|
}
|
|
468
|
-
var
|
|
469
|
+
var K = class {
|
|
469
470
|
constructor() {
|
|
470
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch =
|
|
471
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = w.UNINITIALIZED, this._nextEpoch = void 0, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = Ct() & k;
|
|
471
472
|
}
|
|
472
473
|
get isDisposed() {
|
|
473
|
-
return (this.flags &
|
|
474
|
+
return (this.flags & Q.DISPOSED) !== 0;
|
|
474
475
|
}
|
|
475
476
|
get isComputed() {
|
|
476
|
-
return (this.flags &
|
|
477
|
+
return (this.flags & Q.IS_COMPUTED) !== 0;
|
|
477
478
|
}
|
|
478
479
|
get hasError() {
|
|
479
480
|
return !1;
|
|
480
481
|
}
|
|
481
482
|
subscribe(t) {
|
|
482
|
-
const
|
|
483
|
-
if (!
|
|
484
|
-
let
|
|
485
|
-
|
|
483
|
+
const e = typeof t == "function";
|
|
484
|
+
if (!e && (!t || typeof t.execute != "function")) throw O(/* @__PURE__ */ new TypeError("Invalid subscriber"), g, h.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
|
|
485
|
+
let s = this._slots;
|
|
486
|
+
s || (s = new ut(), this._slots = s);
|
|
486
487
|
let i = !1;
|
|
487
|
-
if (
|
|
488
|
-
else if (
|
|
489
|
-
else if (
|
|
490
|
-
else if (
|
|
488
|
+
if (s._s0 != null && (e ? s._s0.fn === t : s._s0.sub === t)) i = !0;
|
|
489
|
+
else if (s._s1 != null && (e ? s._s1.fn === t : s._s1.sub === t)) i = !0;
|
|
490
|
+
else if (s._s2 != null && (e ? s._s2.fn === t : s._s2.sub === t)) i = !0;
|
|
491
|
+
else if (s._s3 != null && (e ? s._s3.fn === t : s._s3.sub === t)) i = !0;
|
|
491
492
|
else {
|
|
492
|
-
const
|
|
493
|
-
if (
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
493
|
+
const r = s._overflow;
|
|
494
|
+
if (r != null) for (let o = 0, c = r.length; o < c; o++) {
|
|
495
|
+
const a = r[o];
|
|
496
|
+
if (a != null && (e ? a.fn === t : a.sub === t)) {
|
|
496
497
|
i = !0;
|
|
497
498
|
break;
|
|
498
499
|
}
|
|
499
500
|
}
|
|
500
501
|
}
|
|
501
502
|
if (i)
|
|
502
|
-
return () => {
|
|
503
|
+
return _ && console.warn(`[atom-effect] Duplicate subscription ignored on node ${this.id}`), () => {
|
|
503
504
|
};
|
|
504
|
-
const
|
|
505
|
-
return
|
|
505
|
+
const n = new gt(e ? t : void 0, e ? void 0 : t);
|
|
506
|
+
return s.add(n), () => this._unsubscribe(n);
|
|
506
507
|
}
|
|
507
508
|
_unsubscribe(t) {
|
|
508
|
-
const
|
|
509
|
-
|
|
509
|
+
const e = this._slots;
|
|
510
|
+
e && (e.remove(t), this._notifying === 0 && e.compact());
|
|
510
511
|
}
|
|
511
512
|
subscriberCount() {
|
|
512
513
|
const t = this._slots;
|
|
513
514
|
return t === null ? 0 : t.size;
|
|
514
515
|
}
|
|
515
|
-
_notifySubscribers(t,
|
|
516
|
-
const
|
|
517
|
-
if (!(
|
|
516
|
+
_notifySubscribers(t, e) {
|
|
517
|
+
const s = this._slots;
|
|
518
|
+
if (!(s === null || s.size === 0)) {
|
|
518
519
|
this._notifying++;
|
|
519
520
|
try {
|
|
520
|
-
let i =
|
|
521
|
+
let i = s._s0;
|
|
521
522
|
if (i != null) try {
|
|
522
|
-
i.notify(t,
|
|
523
|
-
} catch (
|
|
524
|
-
this._logNotifyError(
|
|
523
|
+
i.notify(t, e);
|
|
524
|
+
} catch (r) {
|
|
525
|
+
this._logNotifyError(r);
|
|
525
526
|
}
|
|
526
|
-
if (i =
|
|
527
|
-
i.notify(t,
|
|
528
|
-
} catch (
|
|
529
|
-
this._logNotifyError(
|
|
527
|
+
if (i = s._s1, i != null) try {
|
|
528
|
+
i.notify(t, e);
|
|
529
|
+
} catch (r) {
|
|
530
|
+
this._logNotifyError(r);
|
|
530
531
|
}
|
|
531
|
-
if (i =
|
|
532
|
-
i.notify(t,
|
|
533
|
-
} catch (
|
|
534
|
-
this._logNotifyError(
|
|
532
|
+
if (i = s._s2, i != null) try {
|
|
533
|
+
i.notify(t, e);
|
|
534
|
+
} catch (r) {
|
|
535
|
+
this._logNotifyError(r);
|
|
535
536
|
}
|
|
536
|
-
if (i =
|
|
537
|
-
i.notify(t,
|
|
538
|
-
} catch (
|
|
539
|
-
this._logNotifyError(
|
|
537
|
+
if (i = s._s3, i != null) try {
|
|
538
|
+
i.notify(t, e);
|
|
539
|
+
} catch (r) {
|
|
540
|
+
this._logNotifyError(r);
|
|
540
541
|
}
|
|
541
|
-
const
|
|
542
|
-
if (
|
|
543
|
-
const
|
|
544
|
-
if (
|
|
545
|
-
|
|
546
|
-
} catch (
|
|
547
|
-
this._logNotifyError(
|
|
542
|
+
const n = s._overflow;
|
|
543
|
+
if (n != null) for (let r = 0, o = n.length; r < o; r++) {
|
|
544
|
+
const c = n[r];
|
|
545
|
+
if (c != null) try {
|
|
546
|
+
c.notify(t, e);
|
|
547
|
+
} catch (a) {
|
|
548
|
+
this._logNotifyError(a);
|
|
548
549
|
}
|
|
549
550
|
}
|
|
550
551
|
} finally {
|
|
551
|
-
--this._notifying === 0 &&
|
|
552
|
+
--this._notifying === 0 && s.compact();
|
|
552
553
|
}
|
|
553
554
|
}
|
|
554
555
|
}
|
|
555
556
|
_logNotifyError(t) {
|
|
556
|
-
console.error(
|
|
557
|
+
console.error(O(t, g, h.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
|
|
557
558
|
}
|
|
558
559
|
_isDirty() {
|
|
559
560
|
const t = this._deps;
|
|
560
561
|
if (t === null || t.size === 0) return !1;
|
|
561
|
-
const
|
|
562
|
-
if (
|
|
563
|
-
const
|
|
564
|
-
if (
|
|
562
|
+
const e = this._hotIndex;
|
|
563
|
+
if (e !== -1) {
|
|
564
|
+
const s = t.getAt(e);
|
|
565
|
+
if (s != null && s.node.version !== s.version) return !0;
|
|
565
566
|
}
|
|
566
567
|
return this._deepDirtyCheck();
|
|
567
568
|
}
|
|
568
|
-
},
|
|
569
|
-
function
|
|
570
|
-
const t =
|
|
571
|
-
return
|
|
569
|
+
}, H = 0;
|
|
570
|
+
function J() {
|
|
571
|
+
const t = H + 1 & k;
|
|
572
|
+
return H = t === 0 ? 1 : t, H;
|
|
572
573
|
}
|
|
573
|
-
function
|
|
574
|
-
const
|
|
575
|
-
return
|
|
574
|
+
function W(t) {
|
|
575
|
+
const e = t + 1 & k;
|
|
576
|
+
return e === 0 ? 1 : e;
|
|
576
577
|
}
|
|
577
|
-
var
|
|
578
|
-
function
|
|
579
|
-
return
|
|
578
|
+
var Z = 0, z = !1, ct = 0;
|
|
579
|
+
function St() {
|
|
580
|
+
return ct;
|
|
580
581
|
}
|
|
581
|
-
function
|
|
582
|
-
return
|
|
582
|
+
function nt() {
|
|
583
|
+
return z ? (_ && console.warn("startFlush() called during flush - ignored"), !1) : (z = !0, ct = J(), Z = 0, !0);
|
|
583
584
|
}
|
|
584
|
-
function
|
|
585
|
-
|
|
585
|
+
function rt() {
|
|
586
|
+
z = !1;
|
|
586
587
|
}
|
|
587
|
-
function
|
|
588
|
-
if (!
|
|
589
|
-
const t = ++
|
|
588
|
+
function Tt() {
|
|
589
|
+
if (!z) return 0;
|
|
590
|
+
const t = ++Z;
|
|
590
591
|
if (t <= C.MAX_EXECUTIONS_PER_FLUSH) return t;
|
|
591
592
|
throw new Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${C.MAX_EXECUTIONS_PER_FLUSH}`);
|
|
592
593
|
}
|
|
593
|
-
var
|
|
594
|
+
var mt = class {
|
|
594
595
|
constructor() {
|
|
595
596
|
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = C.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
|
|
596
597
|
}
|
|
597
598
|
get queueSize() {
|
|
598
|
-
return this._size;
|
|
599
|
+
return this._size + this._batchQueueSize;
|
|
599
600
|
}
|
|
600
601
|
get isBatching() {
|
|
601
602
|
return this._batchDepth > 0;
|
|
602
603
|
}
|
|
603
604
|
schedule(t) {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
605
|
+
if (_ && typeof t != "function" && (!t || typeof t.execute != "function"))
|
|
606
|
+
throw new L(h.SCHEDULER_CALLBACK_MUST_BE_FUNCTION);
|
|
607
|
+
const e = this._epoch;
|
|
608
|
+
if (t._nextEpoch === e) return;
|
|
609
|
+
if (t._nextEpoch = e, this._batchDepth > 0 || this._isFlushingSync) {
|
|
607
610
|
this._batchQueue[this._batchQueueSize++] = t;
|
|
608
611
|
return;
|
|
609
612
|
}
|
|
610
|
-
const
|
|
611
|
-
|
|
613
|
+
const s = this._queueBuffer[this._bufferIndex];
|
|
614
|
+
s[this._size++] = t, this._isProcessing || this._flush();
|
|
612
615
|
}
|
|
613
616
|
_flush() {
|
|
614
617
|
this._isProcessing || this._size === 0 || (this._isProcessing = !0, queueMicrotask(this._boundRunLoop));
|
|
615
618
|
}
|
|
616
619
|
_runLoop() {
|
|
617
620
|
try {
|
|
618
|
-
if (this._size === 0) return;
|
|
619
|
-
const t =
|
|
620
|
-
this._drainQueue(), t &&
|
|
621
|
+
if (this._size === 0 && this._batchQueueSize === 0) return;
|
|
622
|
+
const t = nt();
|
|
623
|
+
this._drainQueue(), t && rt();
|
|
621
624
|
} finally {
|
|
622
|
-
this._isProcessing = !1
|
|
625
|
+
this._isProcessing = !1;
|
|
623
626
|
}
|
|
624
627
|
}
|
|
625
628
|
_flushSync() {
|
|
629
|
+
if (this._size === 0 && this._batchQueueSize === 0) return;
|
|
630
|
+
const t = this._isFlushingSync;
|
|
626
631
|
this._isFlushingSync = !0;
|
|
627
|
-
const
|
|
632
|
+
const e = nt();
|
|
628
633
|
try {
|
|
629
634
|
this._mergeBatchQueue(), this._drainQueue();
|
|
630
635
|
} finally {
|
|
631
|
-
this._isFlushingSync =
|
|
636
|
+
this._isFlushingSync = t, e && rt();
|
|
632
637
|
}
|
|
633
638
|
}
|
|
634
639
|
_mergeBatchQueue() {
|
|
635
640
|
const t = this._batchQueueSize;
|
|
636
641
|
if (t === 0) return;
|
|
637
|
-
|
|
642
|
+
this._epoch = this._epoch + 1 | 0;
|
|
643
|
+
const e = this._epoch, s = this._batchQueue, i = this._queueBuffer[this._bufferIndex];
|
|
638
644
|
let n = this._size;
|
|
639
|
-
for (let
|
|
640
|
-
const
|
|
641
|
-
|
|
645
|
+
for (let r = 0; r < t; r++) {
|
|
646
|
+
const o = s[r];
|
|
647
|
+
o._nextEpoch !== e && (o._nextEpoch = e, i[n++] = o), s[r] = void 0;
|
|
642
648
|
}
|
|
643
|
-
this._size = n, this._batchQueueSize = 0,
|
|
649
|
+
this._size = n, this._batchQueueSize = 0, s.length > C.BATCH_QUEUE_SHRINK_THRESHOLD && (s.length = 0);
|
|
644
650
|
}
|
|
645
651
|
_drainQueue() {
|
|
646
652
|
let t = 0;
|
|
647
|
-
for (; this._size > 0; ) {
|
|
653
|
+
for (; this._size > 0 || this._batchQueueSize > 0; ) {
|
|
648
654
|
if (++t > this._maxFlushIterations) {
|
|
649
655
|
this._handleFlushOverflow();
|
|
650
656
|
return;
|
|
651
657
|
}
|
|
652
|
-
this.
|
|
658
|
+
this._batchQueueSize > 0 && this._mergeBatchQueue(), this._size > 0 && this._processQueue();
|
|
653
659
|
}
|
|
654
660
|
}
|
|
655
661
|
_processQueue() {
|
|
656
|
-
const t = this._bufferIndex,
|
|
662
|
+
const t = this._bufferIndex, e = this._queueBuffer[t], s = this._size;
|
|
657
663
|
this._bufferIndex = t ^ 1, this._size = 0, this._epoch = this._epoch + 1 | 0;
|
|
658
|
-
for (let i = 0; i <
|
|
659
|
-
const
|
|
664
|
+
for (let i = 0; i < s; i++) {
|
|
665
|
+
const n = e[i];
|
|
666
|
+
e[i] = void 0;
|
|
660
667
|
try {
|
|
661
|
-
typeof
|
|
662
|
-
} catch (
|
|
663
|
-
console.error(new
|
|
668
|
+
typeof n == "function" ? n() : n.execute();
|
|
669
|
+
} catch (r) {
|
|
670
|
+
console.error(new L("Error occurred during scheduler execution", r));
|
|
664
671
|
}
|
|
665
672
|
}
|
|
666
|
-
s.length = 0;
|
|
667
673
|
}
|
|
668
674
|
_handleFlushOverflow() {
|
|
669
|
-
const t = this._size + this._batchQueueSize
|
|
670
|
-
console.error(new
|
|
671
|
-
const e = this.
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
if (i) try {
|
|
675
|
-
i(t);
|
|
675
|
+
const t = this._size + this._batchQueueSize;
|
|
676
|
+
console.error(new L(h.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, t))), this._size = 0, this._queueBuffer[0].length = 0, this._queueBuffer[1].length = 0, this._batchQueueSize = 0, this._batchQueue.length = 0;
|
|
677
|
+
const e = this.onOverflow;
|
|
678
|
+
if (e) try {
|
|
679
|
+
e(t);
|
|
676
680
|
} catch {
|
|
677
681
|
}
|
|
678
682
|
}
|
|
@@ -680,61 +684,62 @@ var Ct = class {
|
|
|
680
684
|
this._batchDepth++;
|
|
681
685
|
}
|
|
682
686
|
endBatch() {
|
|
683
|
-
|
|
687
|
+
if (this._batchDepth === 0) {
|
|
688
|
+
_ && console.warn(h.SCHEDULER_END_BATCH_WITHOUT_START);
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
--this._batchDepth === 0 && (this._isFlushingSync || this._flushSync());
|
|
684
692
|
}
|
|
685
693
|
setMaxFlushIterations(t) {
|
|
686
|
-
if (t < C.MIN_FLUSH_ITERATIONS) throw new
|
|
694
|
+
if (t < C.MIN_FLUSH_ITERATIONS) throw new L(`Max iterations must be at least ${C.MIN_FLUSH_ITERATIONS}`);
|
|
687
695
|
this._maxFlushIterations = t;
|
|
688
696
|
}
|
|
689
|
-
},
|
|
690
|
-
function
|
|
691
|
-
if (typeof t != "function") throw new TypeError(
|
|
692
|
-
|
|
693
|
-
s.startBatch();
|
|
697
|
+
}, N = new mt();
|
|
698
|
+
function wt(t) {
|
|
699
|
+
if (_ && typeof t != "function") throw new TypeError(h.BATCH_CALLBACK_MUST_BE_FUNCTION);
|
|
700
|
+
N.startBatch();
|
|
694
701
|
try {
|
|
695
702
|
return t();
|
|
696
703
|
} finally {
|
|
697
|
-
|
|
704
|
+
N.endBatch();
|
|
698
705
|
}
|
|
699
706
|
}
|
|
700
|
-
var
|
|
701
|
-
constructor(t,
|
|
702
|
-
super(), this[
|
|
707
|
+
var vt = class extends K {
|
|
708
|
+
constructor(t, e) {
|
|
709
|
+
super(), this[F] = p.Atom | p.Writable, this._value = t, this._equal = e.equal ?? Object.is, e.sync && (this.flags |= f.SYNC), d.attachDebugInfo(this, "atom", this.id, e.name);
|
|
703
710
|
}
|
|
704
711
|
get isNotificationScheduled() {
|
|
705
|
-
return (this.flags &
|
|
712
|
+
return (this.flags & f.NOTIFICATION_SCHEDULED) !== 0;
|
|
706
713
|
}
|
|
707
714
|
get isSync() {
|
|
708
|
-
return (this.flags &
|
|
715
|
+
return (this.flags & f.SYNC) !== 0;
|
|
709
716
|
}
|
|
710
717
|
get value() {
|
|
711
|
-
const t =
|
|
718
|
+
const t = l.current;
|
|
712
719
|
return t?.addDependency(this), this._value;
|
|
713
720
|
}
|
|
714
721
|
set value(t) {
|
|
715
|
-
const
|
|
716
|
-
if (
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
if ((e & a.NOTIFICATION_SCHEDULED) !== 0) return;
|
|
720
|
-
const i = this._slots;
|
|
721
|
-
i == null || i.size === 0 || (this._pendingOldValue = s, this.flags = e | a.NOTIFICATION_SCHEDULED, (e & a.SYNC) !== 0 && !w.isBatching ? this._flushNotifications() : w.schedule(this));
|
|
722
|
+
const e = this._value;
|
|
723
|
+
if (this._equal(e, t) || (this._value = t, this.version = W(this.version), d.trackUpdate(this.id, d.getDebugName(this)), (this.flags & f.NOTIFICATION_SCHEDULED) !== 0)) return;
|
|
724
|
+
const s = this._slots;
|
|
725
|
+
s == null || s.size === 0 || (this._pendingOldValue = e, this.flags |= f.NOTIFICATION_SCHEDULED, (this.flags & f.SYNC) !== 0 && !N.isBatching ? this._notifying === 0 && this._flushNotifications() : N.schedule(this));
|
|
722
726
|
}
|
|
723
727
|
execute() {
|
|
724
728
|
this._flushNotifications();
|
|
725
729
|
}
|
|
726
730
|
_flushNotifications() {
|
|
727
|
-
const t =
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
+
const t = f.NOTIFICATION_SCHEDULED, e = f.DISPOSED, s = f.SYNC;
|
|
732
|
+
for (; (this.flags & (t | e)) === t; ) {
|
|
733
|
+
const i = this._pendingOldValue;
|
|
734
|
+
if (this._pendingOldValue = void 0, this.flags &= ~t, this._equal(this._value, i) || this._notifySubscribers(this._value, i), (this.flags & s) === 0 || N.isBatching) break;
|
|
735
|
+
}
|
|
731
736
|
}
|
|
732
737
|
peek() {
|
|
733
738
|
return this._value;
|
|
734
739
|
}
|
|
735
740
|
dispose() {
|
|
736
741
|
const t = this.flags;
|
|
737
|
-
(t &
|
|
742
|
+
(t & f.DISPOSED) === 0 && (this._slots?.clear(), this.flags = t | f.DISPOSED, this._value = void 0, this._pendingOldValue = void 0, this._equal = Object.is);
|
|
738
743
|
}
|
|
739
744
|
_deepDirtyCheck() {
|
|
740
745
|
return !1;
|
|
@@ -743,25 +748,13 @@ var It = class extends Q {
|
|
|
743
748
|
this.dispose();
|
|
744
749
|
}
|
|
745
750
|
};
|
|
746
|
-
function
|
|
747
|
-
return new
|
|
751
|
+
function Ft(t, e = {}) {
|
|
752
|
+
return new vt(t, e);
|
|
748
753
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
return typeof t == "object" && t !== null && st in t;
|
|
754
|
-
}
|
|
755
|
-
function Ot(t) {
|
|
756
|
-
return typeof t == "object" && t !== null && et in t;
|
|
757
|
-
}
|
|
758
|
-
function nt(t) {
|
|
759
|
-
return typeof t == "object" && t !== null && typeof t.then == "function";
|
|
760
|
-
}
|
|
761
|
-
var { IDLE: p, DIRTY: E, PENDING: S, RESOLVED: d, REJECTED: D, HAS_ERROR: A, RECOMPUTING: N, DISPOSED: M, IS_COMPUTED: O, FORCE_COMPUTE: x } = B, Dt = class extends Q {
|
|
762
|
-
constructor(t, s = {}) {
|
|
763
|
-
if (typeof t != "function") throw new m(c.COMPUTED_MUST_BE_FUNCTION);
|
|
764
|
-
if (super(), this[$] = !0, this[st] = !0, this._error = null, this._promiseId = 0, this._deps = new tt(), this._trackEpoch = b.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = O | E | p, this._equal = s.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in s ? s.defaultValue : L, this._onError = s.onError ?? null, G.attachDebugInfo(this, "computed", this.id), s.lazy === !1) try {
|
|
754
|
+
var { IDLE: D, DIRTY: E, PENDING: v, RESOLVED: I, REJECTED: T, HAS_ERROR: P, RECOMPUTING: y, DISPOSED: G, IS_COMPUTED: R, FORCE_COMPUTE: X } = Q, Ot = class extends K {
|
|
755
|
+
constructor(t, e = {}) {
|
|
756
|
+
if (typeof t != "function") throw new A(h.COMPUTED_MUST_BE_FUNCTION);
|
|
757
|
+
if (super(), this[F] = p.Atom | p.Computed, this._error = null, this._promiseId = 0, this._deps = new ht(), this._trackEpoch = w.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = R | E | D, this._equal = e.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in e ? e.defaultValue : B, this._onError = e.onError ?? null, d.attachDebugInfo(this, "computed", this.id, e.name), e.lazy === !1) try {
|
|
765
758
|
this._recompute();
|
|
766
759
|
} catch {
|
|
767
760
|
}
|
|
@@ -770,39 +763,39 @@ var { IDLE: p, DIRTY: E, PENDING: S, RESOLVED: d, REJECTED: D, HAS_ERROR: A, REC
|
|
|
770
763
|
return (this.flags & E) !== 0;
|
|
771
764
|
}
|
|
772
765
|
get isRejected() {
|
|
773
|
-
return (this.flags &
|
|
766
|
+
return (this.flags & T) !== 0;
|
|
774
767
|
}
|
|
775
768
|
get isRecomputing() {
|
|
776
|
-
return (this.flags &
|
|
769
|
+
return (this.flags & y) !== 0;
|
|
777
770
|
}
|
|
778
771
|
get _hasErrorInternal() {
|
|
779
|
-
return (this.flags &
|
|
772
|
+
return (this.flags & P) !== 0;
|
|
780
773
|
}
|
|
781
774
|
_track() {
|
|
782
|
-
|
|
775
|
+
l.current?.addDependency(this);
|
|
783
776
|
}
|
|
784
777
|
get value() {
|
|
785
|
-
const t =
|
|
778
|
+
const t = l.current;
|
|
786
779
|
t?.addDependency(this);
|
|
787
|
-
let
|
|
788
|
-
if ((
|
|
789
|
-
if ((
|
|
790
|
-
if ((
|
|
791
|
-
const
|
|
792
|
-
if (
|
|
793
|
-
throw new
|
|
780
|
+
let e = this.flags;
|
|
781
|
+
if ((e & (I | E | D)) === I) return this._value;
|
|
782
|
+
if ((e & G) !== 0) throw new A(h.COMPUTED_DISPOSED);
|
|
783
|
+
if ((e & y) !== 0) {
|
|
784
|
+
const n = this._defaultValue;
|
|
785
|
+
if (n !== B) return n;
|
|
786
|
+
throw new A(h.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
794
787
|
}
|
|
795
|
-
if ((
|
|
796
|
-
const
|
|
797
|
-
if ((
|
|
788
|
+
if ((e & (E | D)) !== 0) {
|
|
789
|
+
const n = this._deps;
|
|
790
|
+
if ((e & D) === 0 && (e & X) === 0 && n.size > 0 && !this._isDirty() ? e = this.flags &= ~E : (this._recompute(), e = this.flags), (e & I) !== 0) return this._value;
|
|
798
791
|
}
|
|
799
|
-
const
|
|
800
|
-
if ((
|
|
801
|
-
if (i) return
|
|
802
|
-
throw new
|
|
792
|
+
const s = this._defaultValue, i = s !== B;
|
|
793
|
+
if ((e & v) !== 0) {
|
|
794
|
+
if (i) return s;
|
|
795
|
+
throw new A(h.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
803
796
|
}
|
|
804
|
-
if ((
|
|
805
|
-
if (i) return
|
|
797
|
+
if ((e & T) !== 0) {
|
|
798
|
+
if (i) return s;
|
|
806
799
|
throw this._error;
|
|
807
800
|
}
|
|
808
801
|
return this._value;
|
|
@@ -811,263 +804,266 @@ var { IDLE: p, DIRTY: E, PENDING: S, RESOLVED: d, REJECTED: D, HAS_ERROR: A, REC
|
|
|
811
804
|
return this._value;
|
|
812
805
|
}
|
|
813
806
|
get state() {
|
|
814
|
-
const t =
|
|
807
|
+
const t = l.current;
|
|
815
808
|
t?.addDependency(this);
|
|
816
|
-
const
|
|
817
|
-
return (
|
|
809
|
+
const e = this.flags;
|
|
810
|
+
return (e & I) !== 0 ? U.RESOLVED : (e & v) !== 0 ? U.PENDING : (e & T) !== 0 ? U.REJECTED : U.IDLE;
|
|
818
811
|
}
|
|
819
812
|
get hasError() {
|
|
820
|
-
const t =
|
|
821
|
-
if (t?.addDependency(this), (this.flags & (
|
|
822
|
-
const
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
813
|
+
const t = l.current;
|
|
814
|
+
if (t?.addDependency(this), (this.flags & (T | P)) !== 0) return !0;
|
|
815
|
+
const e = this._deps;
|
|
816
|
+
return e.hasComputeds ? M(() => {
|
|
817
|
+
const s = e.size;
|
|
818
|
+
for (let i = 0; i < s; i++) if (e.getAt(i)?.node.hasError) return !0;
|
|
819
|
+
return !1;
|
|
820
|
+
}) : !1;
|
|
827
821
|
}
|
|
828
822
|
get isValid() {
|
|
829
823
|
return !this.hasError;
|
|
830
824
|
}
|
|
831
825
|
get errors() {
|
|
832
|
-
const t =
|
|
826
|
+
const t = l.current;
|
|
833
827
|
t?.addDependency(this);
|
|
834
|
-
const
|
|
835
|
-
if (!
|
|
836
|
-
return
|
|
828
|
+
const e = this._error, s = this._deps;
|
|
829
|
+
if (!s.hasComputeds)
|
|
830
|
+
return e == null ? et : Object.freeze([e]);
|
|
837
831
|
const i = [];
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
const
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
832
|
+
return e != null && i.push(e), M(() => {
|
|
833
|
+
const n = s.size;
|
|
834
|
+
for (let r = 0; r < n; r++) {
|
|
835
|
+
const o = s.getAt(r)?.node;
|
|
836
|
+
o != null && (o.flags & R) !== 0 && this._accumulateErrors(o, i);
|
|
837
|
+
}
|
|
838
|
+
}), i.length === 0 ? et : Object.freeze(i);
|
|
839
|
+
}
|
|
840
|
+
_accumulateErrors(t, e) {
|
|
841
|
+
const s = t._error;
|
|
842
|
+
s != null && !e.includes(s) && e.push(s);
|
|
843
|
+
const i = t._deps;
|
|
844
|
+
if (!i.hasComputeds) return;
|
|
845
|
+
const n = i.size;
|
|
846
|
+
for (let r = 0; r < n; r++) {
|
|
847
|
+
const o = i.getAt(r)?.node;
|
|
848
|
+
o != null && (o.flags & R) !== 0 && this._accumulateErrors(o, e);
|
|
853
849
|
}
|
|
854
850
|
}
|
|
855
851
|
get lastError() {
|
|
856
|
-
const t =
|
|
852
|
+
const t = l.current;
|
|
857
853
|
return t?.addDependency(this), this._error;
|
|
858
854
|
}
|
|
859
855
|
get isPending() {
|
|
860
|
-
const t =
|
|
861
|
-
return t?.addDependency(this), (this.flags &
|
|
856
|
+
const t = l.current;
|
|
857
|
+
return t?.addDependency(this), (this.flags & v) !== 0;
|
|
862
858
|
}
|
|
863
859
|
get isResolved() {
|
|
864
|
-
const t =
|
|
865
|
-
return t?.addDependency(this), (this.flags &
|
|
860
|
+
const t = l.current;
|
|
861
|
+
return t?.addDependency(this), (this.flags & I) !== 0;
|
|
866
862
|
}
|
|
867
863
|
invalidate() {
|
|
868
|
-
this.flags |=
|
|
864
|
+
this.flags |= X, this._markDirty();
|
|
869
865
|
}
|
|
870
866
|
dispose() {
|
|
871
|
-
(this.flags &
|
|
867
|
+
(this.flags & G) === 0 && (this._deps.disposeAll(), this._slots != null && this._slots.clear(), this.flags = G | E | D, this._error = null, this._value = void 0, this._hotIndex = -1);
|
|
872
868
|
}
|
|
873
869
|
[Symbol.dispose]() {
|
|
874
870
|
this.dispose();
|
|
875
871
|
}
|
|
876
872
|
addDependency(t) {
|
|
877
|
-
const
|
|
878
|
-
if (t._lastSeenEpoch ===
|
|
879
|
-
t._lastSeenEpoch =
|
|
880
|
-
const
|
|
881
|
-
if (
|
|
882
|
-
else if (!i.claimExisting(t,
|
|
883
|
-
const
|
|
884
|
-
i.insertNew(
|
|
873
|
+
const e = this._trackEpoch;
|
|
874
|
+
if (t._lastSeenEpoch === e) return;
|
|
875
|
+
t._lastSeenEpoch = e;
|
|
876
|
+
const s = this._trackCount++, i = this._deps, n = i.getAt(s);
|
|
877
|
+
if (n != null && n.node === t) n.version = t.version;
|
|
878
|
+
else if (!i.claimExisting(t, s)) {
|
|
879
|
+
const r = new j(t, t.version, t.subscribe(this));
|
|
880
|
+
i.insertNew(s, r);
|
|
885
881
|
}
|
|
886
|
-
(t.flags &
|
|
882
|
+
(t.flags & R) !== 0 && (i.hasComputeds = !0);
|
|
887
883
|
}
|
|
888
884
|
_recompute() {
|
|
889
885
|
if (this.isRecomputing) return;
|
|
890
|
-
this.flags = (this.flags |
|
|
886
|
+
this.flags = (this.flags | y) & ~X, this._trackEpoch = J(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
|
|
891
887
|
let t = !1;
|
|
892
888
|
try {
|
|
893
|
-
const
|
|
894
|
-
this._deps.truncateFrom(this._trackCount), t = !0,
|
|
895
|
-
} catch (
|
|
889
|
+
const e = l.run(this, this._fn);
|
|
890
|
+
this._deps.truncateFrom(this._trackCount), t = !0, $(e) ? this._handleAsyncComputation(e) : this._finalizeResolution(e);
|
|
891
|
+
} catch (e) {
|
|
896
892
|
if (!t) try {
|
|
897
893
|
this._deps.truncateFrom(this._trackCount);
|
|
898
|
-
} catch {
|
|
894
|
+
} catch (s) {
|
|
895
|
+
_ && console.warn("[atom-effect] _commitDeps failed during error recovery:", s);
|
|
899
896
|
}
|
|
900
|
-
this._handleError(
|
|
897
|
+
this._handleError(e, h.COMPUTED_COMPUTATION_FAILED, !0);
|
|
901
898
|
} finally {
|
|
902
|
-
this._trackEpoch =
|
|
899
|
+
this._trackEpoch = w.UNINITIALIZED, this._trackCount = 0, this.flags &= ~y;
|
|
903
900
|
}
|
|
904
901
|
}
|
|
905
902
|
_handleAsyncComputation(t) {
|
|
906
|
-
this.flags = (this.flags |
|
|
907
|
-
const
|
|
908
|
-
t.then((
|
|
909
|
-
if (
|
|
903
|
+
this.flags = (this.flags | v) & ~(D | E | I | T), this._notifySubscribers(void 0, void 0), this._promiseId = (this._promiseId + 1) % at.MAX_PROMISE_ID;
|
|
904
|
+
const e = this._promiseId;
|
|
905
|
+
t.then((s) => {
|
|
906
|
+
if (e === this._promiseId) {
|
|
910
907
|
if (this._isDirty()) return this._markDirty();
|
|
911
|
-
this._finalizeResolution(
|
|
908
|
+
this._finalizeResolution(s), this._notifySubscribers(s, void 0);
|
|
912
909
|
}
|
|
913
|
-
}, (
|
|
910
|
+
}, (s) => e === this._promiseId && this._handleError(s, h.COMPUTED_ASYNC_COMPUTATION_FAILED));
|
|
914
911
|
}
|
|
915
|
-
_handleError(t,
|
|
916
|
-
const i =
|
|
917
|
-
if (!
|
|
912
|
+
_handleError(t, e, s = !1) {
|
|
913
|
+
const i = O(t, A, e);
|
|
914
|
+
if ((!this.isRejected || this._error !== i) && (this.version = W(this.version)), this._error = i, this.flags = this.flags & ~(D | E | v | I) | T | P, this._onError) try {
|
|
918
915
|
this._onError(i);
|
|
919
|
-
} catch (
|
|
920
|
-
console.error(
|
|
916
|
+
} catch (n) {
|
|
917
|
+
console.error(h.CALLBACK_ERROR_IN_ERROR_HANDLER, n);
|
|
921
918
|
}
|
|
922
|
-
if (
|
|
923
|
-
this._notifySubscribers(void 0, void 0);
|
|
919
|
+
if (this._notifySubscribers(void 0, void 0), s) throw i;
|
|
924
920
|
}
|
|
925
921
|
_finalizeResolution(t) {
|
|
926
|
-
const
|
|
927
|
-
((
|
|
922
|
+
const e = this.flags;
|
|
923
|
+
((e & I) === 0 || !this._equal(this._value, t)) && (this.version = W(this.version)), this._value = t, this._error = null, this.flags = (e | I) & ~(D | E | v | T | P);
|
|
928
924
|
}
|
|
929
925
|
execute() {
|
|
930
926
|
this._markDirty();
|
|
931
927
|
}
|
|
932
928
|
_markDirty() {
|
|
933
929
|
const t = this.flags;
|
|
934
|
-
(t & (
|
|
930
|
+
(t & (y | E)) === 0 && (this.flags = t | E, d.trackUpdate(this.id, d.getDebugName(this)), this._notifySubscribers(void 0, void 0));
|
|
935
931
|
}
|
|
936
932
|
_deepDirtyCheck() {
|
|
937
|
-
const t = this._deps
|
|
938
|
-
|
|
939
|
-
try {
|
|
933
|
+
const t = this._deps;
|
|
934
|
+
return M(() => {
|
|
940
935
|
const e = t.size;
|
|
941
|
-
for (let
|
|
942
|
-
const
|
|
943
|
-
if (
|
|
944
|
-
const n =
|
|
945
|
-
if ((n.flags &
|
|
936
|
+
for (let s = 0; s < e; s++) {
|
|
937
|
+
const i = t.getAt(s);
|
|
938
|
+
if (i == null) continue;
|
|
939
|
+
const n = i.node;
|
|
940
|
+
if ((n.flags & R) !== 0) try {
|
|
946
941
|
n.value;
|
|
947
942
|
} catch {
|
|
943
|
+
_ && console.warn(`[atom-effect] Dependency #${n.id} threw during dirty check`);
|
|
948
944
|
}
|
|
949
|
-
if (n.version !==
|
|
950
|
-
return this._hotIndex =
|
|
945
|
+
if (n.version !== i.version)
|
|
946
|
+
return this._hotIndex = s, !0;
|
|
951
947
|
}
|
|
952
948
|
return this._hotIndex = -1, !1;
|
|
953
|
-
}
|
|
954
|
-
_.current = s;
|
|
955
|
-
}
|
|
949
|
+
});
|
|
956
950
|
}
|
|
957
951
|
};
|
|
958
|
-
function
|
|
959
|
-
return new
|
|
952
|
+
function Ut(t, e = {}) {
|
|
953
|
+
return new Ot(t, e);
|
|
960
954
|
}
|
|
961
|
-
var
|
|
962
|
-
constructor(t,
|
|
963
|
-
super(), this[
|
|
955
|
+
var Nt = class extends K {
|
|
956
|
+
constructor(t, e = {}) {
|
|
957
|
+
super(), this[F] = p.Effect, this._cleanup = null, this._deps = new ht(), this._currentEpoch = w.UNINITIALIZED, this._lastFlushEpoch = w.UNINITIALIZED, this._fn = t, this._onError = e.onError ?? null, this._sync = e.sync ?? !1, this._maxExecutions = e.maxExecutionsPerSecond ?? C.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = e.maxExecutionsPerFlush ?? C.MAX_EXECUTIONS_PER_EFFECT, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => N.schedule(this), d.attachDebugInfo(this, "effect", this.id, e.name);
|
|
964
958
|
}
|
|
965
959
|
run() {
|
|
966
|
-
if (this.isDisposed) throw new
|
|
960
|
+
if (this.isDisposed) throw new m(h.EFFECT_DISPOSED);
|
|
967
961
|
this.execute(!0);
|
|
968
962
|
}
|
|
969
963
|
dispose() {
|
|
970
|
-
this.isDisposed || (this.flags |=
|
|
964
|
+
this.isDisposed || (this.flags |= S.DISPOSED, this._execCleanup(), this._deps?.disposeAll());
|
|
971
965
|
}
|
|
972
966
|
[Symbol.dispose]() {
|
|
973
967
|
this.dispose();
|
|
974
968
|
}
|
|
975
969
|
addDependency(t) {
|
|
976
|
-
if ((this.flags &
|
|
977
|
-
const
|
|
978
|
-
if (t._lastSeenEpoch ===
|
|
979
|
-
t._lastSeenEpoch =
|
|
980
|
-
const
|
|
981
|
-
let
|
|
982
|
-
switch (
|
|
970
|
+
if ((this.flags & S.EXECUTING) === 0) return;
|
|
971
|
+
const e = this._currentEpoch;
|
|
972
|
+
if (t._lastSeenEpoch === e) return;
|
|
973
|
+
t._lastSeenEpoch = e;
|
|
974
|
+
const s = this._trackCount++, i = this._deps;
|
|
975
|
+
let n;
|
|
976
|
+
switch (s) {
|
|
983
977
|
case 0:
|
|
984
|
-
|
|
978
|
+
n = i._s0;
|
|
985
979
|
break;
|
|
986
980
|
case 1:
|
|
987
|
-
|
|
981
|
+
n = i._s1;
|
|
988
982
|
break;
|
|
989
983
|
case 2:
|
|
990
|
-
|
|
984
|
+
n = i._s2;
|
|
991
985
|
break;
|
|
992
986
|
case 3:
|
|
993
|
-
|
|
987
|
+
n = i._s3;
|
|
994
988
|
break;
|
|
995
989
|
default:
|
|
996
|
-
|
|
990
|
+
n = i.getAt(s);
|
|
997
991
|
}
|
|
998
|
-
|
|
992
|
+
n != null && n.node === t ? n.version = t.version : i.claimExisting(t, s) || this._insertNewDependency(t, s), t.isComputed && (i.hasComputeds = !0);
|
|
999
993
|
}
|
|
1000
|
-
_insertNewDependency(t,
|
|
1001
|
-
let
|
|
994
|
+
_insertNewDependency(t, e) {
|
|
995
|
+
let s;
|
|
1002
996
|
try {
|
|
1003
997
|
const i = t.subscribe(this._notifyCallback);
|
|
1004
|
-
|
|
998
|
+
s = new j(t, t.version, i);
|
|
1005
999
|
} catch (i) {
|
|
1006
|
-
const
|
|
1007
|
-
if (console.error(
|
|
1008
|
-
this._onError(
|
|
1000
|
+
const n = O(i, m, h.EFFECT_EXECUTION_FAILED);
|
|
1001
|
+
if (console.error(n), this._onError) try {
|
|
1002
|
+
this._onError(n);
|
|
1009
1003
|
} catch {
|
|
1010
1004
|
}
|
|
1011
|
-
|
|
1005
|
+
s = new j(t, t.version, void 0);
|
|
1012
1006
|
}
|
|
1013
|
-
this._deps.insertNew(
|
|
1007
|
+
this._deps.insertNew(e, s);
|
|
1014
1008
|
}
|
|
1015
1009
|
execute(t = !1) {
|
|
1016
|
-
const
|
|
1017
|
-
if ((
|
|
1018
|
-
const
|
|
1019
|
-
if (!t &&
|
|
1020
|
-
this._checkInfiniteLoops(), this.flags =
|
|
1010
|
+
const e = this.flags;
|
|
1011
|
+
if ((e & (S.DISPOSED | S.EXECUTING)) !== 0) return;
|
|
1012
|
+
const s = this._deps;
|
|
1013
|
+
if (!t && s.size > 0 && !this._isDirty()) return;
|
|
1014
|
+
this._checkInfiniteLoops(), d.trackUpdate(this.id, d.getDebugName(this)), this.flags = e | S.EXECUTING, this._execCleanup(), this._currentEpoch = J(), this._trackCount = 0, s.prepareTracking(), this._hotIndex = -1;
|
|
1021
1015
|
let i = !1;
|
|
1022
1016
|
try {
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
} catch (
|
|
1017
|
+
const n = l.run(this, this._fn);
|
|
1018
|
+
s.truncateFrom(this._trackCount), i = !0, $(n) ? this._handleAsyncResult(n) : this._cleanup = typeof n == "function" ? n : null;
|
|
1019
|
+
} catch (n) {
|
|
1026
1020
|
if (!i) try {
|
|
1027
|
-
|
|
1028
|
-
} catch {
|
|
1021
|
+
s.truncateFrom(this._trackCount);
|
|
1022
|
+
} catch (r) {
|
|
1023
|
+
_ && console.warn("[atom-effect] _commitDeps failed during error recovery:", r);
|
|
1029
1024
|
}
|
|
1030
|
-
this._handleExecutionError(
|
|
1025
|
+
this._handleExecutionError(n), this._cleanup = null;
|
|
1031
1026
|
} finally {
|
|
1032
|
-
this.flags &= ~
|
|
1027
|
+
this.flags &= ~S.EXECUTING;
|
|
1033
1028
|
}
|
|
1034
1029
|
}
|
|
1035
1030
|
_handleAsyncResult(t) {
|
|
1036
|
-
const
|
|
1037
|
-
t.then((
|
|
1038
|
-
if (
|
|
1039
|
-
if (typeof
|
|
1040
|
-
|
|
1031
|
+
const e = ++this._execId;
|
|
1032
|
+
t.then((s) => {
|
|
1033
|
+
if (e !== this._execId || this.isDisposed) {
|
|
1034
|
+
if (typeof s == "function") try {
|
|
1035
|
+
s();
|
|
1041
1036
|
} catch (i) {
|
|
1042
|
-
this._handleExecutionError(i,
|
|
1037
|
+
this._handleExecutionError(i, h.EFFECT_CLEANUP_FAILED);
|
|
1043
1038
|
}
|
|
1044
1039
|
return;
|
|
1045
1040
|
}
|
|
1046
|
-
typeof
|
|
1047
|
-
}, (
|
|
1041
|
+
typeof s == "function" && (this._cleanup = s);
|
|
1042
|
+
}, (s) => e === this._execId && this._handleExecutionError(s));
|
|
1048
1043
|
}
|
|
1049
1044
|
_deepDirtyCheck() {
|
|
1050
|
-
const t =
|
|
1051
|
-
|
|
1052
|
-
const
|
|
1045
|
+
const t = l.current;
|
|
1046
|
+
l.current = null;
|
|
1047
|
+
const e = this._deps;
|
|
1053
1048
|
try {
|
|
1054
|
-
const
|
|
1055
|
-
for (let i = 0; i <
|
|
1056
|
-
const
|
|
1057
|
-
if (
|
|
1058
|
-
const
|
|
1059
|
-
if (
|
|
1049
|
+
const s = e.size;
|
|
1050
|
+
for (let i = 0; i < s; i++) {
|
|
1051
|
+
const n = e.getAt(i);
|
|
1052
|
+
if (n == null) continue;
|
|
1053
|
+
const r = n.node;
|
|
1054
|
+
if (r.isComputed && this._tryPullComputed(r), r.version !== n.version)
|
|
1060
1055
|
return this._hotIndex = i, !0;
|
|
1061
1056
|
}
|
|
1062
1057
|
return !1;
|
|
1063
1058
|
} finally {
|
|
1064
|
-
|
|
1059
|
+
l.current = t;
|
|
1065
1060
|
}
|
|
1066
1061
|
}
|
|
1067
1062
|
_tryPullComputed(t) {
|
|
1068
1063
|
try {
|
|
1069
1064
|
t.value;
|
|
1070
1065
|
} catch {
|
|
1066
|
+
_ && console.warn(`[atom-effect] Dependency #${t.id} threw during dirty check`);
|
|
1071
1067
|
}
|
|
1072
1068
|
}
|
|
1073
1069
|
_execCleanup() {
|
|
@@ -1076,127 +1072,125 @@ var vt = class extends Q {
|
|
|
1076
1072
|
this._cleanup = null;
|
|
1077
1073
|
try {
|
|
1078
1074
|
t();
|
|
1079
|
-
} catch (
|
|
1080
|
-
this._handleExecutionError(
|
|
1075
|
+
} catch (e) {
|
|
1076
|
+
this._handleExecutionError(e, h.EFFECT_CLEANUP_FAILED);
|
|
1081
1077
|
}
|
|
1082
1078
|
}
|
|
1083
1079
|
}
|
|
1084
1080
|
_checkInfiniteLoops() {
|
|
1085
|
-
const t =
|
|
1086
|
-
this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
1081
|
+
const t = St();
|
|
1082
|
+
this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), Tt() > C.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, _ && this._checkFrequencyLimit();
|
|
1087
1083
|
}
|
|
1088
1084
|
_checkFrequencyLimit() {
|
|
1089
1085
|
if (!Number.isFinite(this._maxExecutions)) return;
|
|
1090
1086
|
const t = Date.now();
|
|
1091
|
-
if (t - this._windowStart >=
|
|
1087
|
+
if (t - this._windowStart >= Y.EFFECT_FREQUENCY_WINDOW) {
|
|
1092
1088
|
this._windowStart = t, this._windowCount = 1;
|
|
1093
1089
|
return;
|
|
1094
1090
|
}
|
|
1095
1091
|
if (++this._windowCount > this._maxExecutions) {
|
|
1096
|
-
const
|
|
1097
|
-
throw this.dispose(), this._handleExecutionError(
|
|
1092
|
+
const e = new m(h.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
|
|
1093
|
+
throw this.dispose(), this._handleExecutionError(e), e;
|
|
1098
1094
|
}
|
|
1099
1095
|
}
|
|
1100
1096
|
get executionCount() {
|
|
1101
1097
|
return this._executionCount;
|
|
1102
1098
|
}
|
|
1103
1099
|
get isExecuting() {
|
|
1104
|
-
return (this.flags &
|
|
1100
|
+
return (this.flags & S.EXECUTING) !== 0;
|
|
1105
1101
|
}
|
|
1106
1102
|
_throwInfiniteLoopError(t) {
|
|
1107
|
-
const
|
|
1108
|
-
throw this.dispose(), console.error(
|
|
1103
|
+
const e = new m(`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Z}`);
|
|
1104
|
+
throw this.dispose(), console.error(e), e;
|
|
1109
1105
|
}
|
|
1110
|
-
_handleExecutionError(t,
|
|
1111
|
-
const
|
|
1112
|
-
if (console.error(
|
|
1113
|
-
this._onError(
|
|
1106
|
+
_handleExecutionError(t, e = h.EFFECT_EXECUTION_FAILED) {
|
|
1107
|
+
const s = O(t, m, e);
|
|
1108
|
+
if (console.error(s), this._onError) try {
|
|
1109
|
+
this._onError(s);
|
|
1114
1110
|
} catch (i) {
|
|
1115
|
-
console.error(
|
|
1111
|
+
console.error(O(i, m, h.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
1116
1112
|
}
|
|
1117
1113
|
}
|
|
1118
1114
|
};
|
|
1119
|
-
function
|
|
1120
|
-
if (typeof t != "function") throw new
|
|
1121
|
-
const
|
|
1122
|
-
return
|
|
1115
|
+
function Lt(t, e = {}) {
|
|
1116
|
+
if (typeof t != "function") throw new m(h.EFFECT_MUST_BE_FUNCTION);
|
|
1117
|
+
const s = new Nt(t, e);
|
|
1118
|
+
return s.execute(), s;
|
|
1123
1119
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
if (
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
return Number.isNaN(h) ? l[r] = u : l[h] = u, l;
|
|
1120
|
+
function lt(t, e, s, i) {
|
|
1121
|
+
if (s === e.length) return i;
|
|
1122
|
+
const n = e[s], r = t != null && typeof t == "object" ? t : {}, o = r[n], c = lt(o, e, s + 1, i);
|
|
1123
|
+
if (Object.is(o, c)) return t;
|
|
1124
|
+
if (Array.isArray(r)) {
|
|
1125
|
+
const a = r.slice(), b = Number.parseInt(n, 10);
|
|
1126
|
+
return Number.isNaN(b) ? a[n] = c : a[b] = c, a;
|
|
1132
1127
|
}
|
|
1133
1128
|
return {
|
|
1134
|
-
...
|
|
1135
|
-
[
|
|
1129
|
+
...r,
|
|
1130
|
+
[n]: c
|
|
1136
1131
|
};
|
|
1137
1132
|
}
|
|
1138
|
-
function
|
|
1139
|
-
let
|
|
1140
|
-
const i =
|
|
1141
|
-
for (let
|
|
1142
|
-
if (
|
|
1143
|
-
|
|
1144
|
-
}
|
|
1145
|
-
return
|
|
1133
|
+
function x(t, e) {
|
|
1134
|
+
let s = t;
|
|
1135
|
+
const i = e.length;
|
|
1136
|
+
for (let n = 0; n < i; n++) {
|
|
1137
|
+
if (s == null) return;
|
|
1138
|
+
s = s[e[n]];
|
|
1139
|
+
}
|
|
1140
|
+
return s;
|
|
1146
1141
|
}
|
|
1147
|
-
function
|
|
1148
|
-
const
|
|
1149
|
-
i.forEach((
|
|
1142
|
+
function _t(t, e) {
|
|
1143
|
+
const s = e.includes(".") ? e.split(".") : [e], i = /* @__PURE__ */ new Set(), n = () => {
|
|
1144
|
+
i.forEach((r) => r()), i.clear();
|
|
1150
1145
|
};
|
|
1151
1146
|
return {
|
|
1152
1147
|
get value() {
|
|
1153
|
-
return
|
|
1148
|
+
return x(t.value, s);
|
|
1154
1149
|
},
|
|
1155
|
-
set value(
|
|
1156
|
-
const o = t.peek(),
|
|
1157
|
-
|
|
1150
|
+
set value(r) {
|
|
1151
|
+
const o = t.peek(), c = lt(o, s, 0, r);
|
|
1152
|
+
c !== o && (t.value = c);
|
|
1158
1153
|
},
|
|
1159
|
-
peek: () =>
|
|
1160
|
-
subscribe(
|
|
1161
|
-
const o = t.subscribe((
|
|
1162
|
-
const
|
|
1163
|
-
Object.is(
|
|
1154
|
+
peek: () => x(t.peek(), s),
|
|
1155
|
+
subscribe(r) {
|
|
1156
|
+
const o = t.subscribe((c, a) => {
|
|
1157
|
+
const b = x(c, s), tt = x(a, s);
|
|
1158
|
+
Object.is(b, tt) || r(b, tt);
|
|
1164
1159
|
});
|
|
1165
1160
|
return i.add(o), () => {
|
|
1166
1161
|
o(), i.delete(o);
|
|
1167
1162
|
};
|
|
1168
1163
|
},
|
|
1169
1164
|
subscriberCount: () => i.size,
|
|
1170
|
-
dispose:
|
|
1171
|
-
[Symbol.dispose]:
|
|
1172
|
-
[
|
|
1173
|
-
[gt]: !0
|
|
1165
|
+
dispose: n,
|
|
1166
|
+
[Symbol.dispose]: n,
|
|
1167
|
+
[F]: p.Atom | p.Writable
|
|
1174
1168
|
};
|
|
1175
1169
|
}
|
|
1176
|
-
var
|
|
1170
|
+
var Pt = (t, e) => _t(t, e), xt = (t) => (e) => _t(t, e);
|
|
1177
1171
|
export {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
v as EffectError,
|
|
1172
|
+
U as AsyncState,
|
|
1173
|
+
g as AtomError,
|
|
1174
|
+
A as ComputedError,
|
|
1175
|
+
Y as DEBUG_CONFIG,
|
|
1176
|
+
m as EffectError,
|
|
1184
1177
|
C as SCHEDULER_CONFIG,
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
At as
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1178
|
+
L as SchedulerError,
|
|
1179
|
+
Ft as atom,
|
|
1180
|
+
_t as atomLens,
|
|
1181
|
+
wt as batch,
|
|
1182
|
+
Pt as composeLens,
|
|
1183
|
+
Ut as computed,
|
|
1184
|
+
Lt as effect,
|
|
1185
|
+
x as getPathValue,
|
|
1186
|
+
N as globalScheduler,
|
|
1187
|
+
At as isAtom,
|
|
1188
|
+
yt as isComputed,
|
|
1189
|
+
Rt as isEffect,
|
|
1190
|
+
xt as lensFor,
|
|
1191
|
+
d as runtimeDebug,
|
|
1192
|
+
lt as setDeepValue,
|
|
1193
|
+
M as untracked
|
|
1200
1194
|
};
|
|
1201
1195
|
|
|
1202
1196
|
//# sourceMappingURL=index.mjs.map
|