@vobs/devtools 1.2.0 → 1.2.2
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.cjs +108 -347
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +70 -318
- package/dist/index.js.map +1 -1
- package/package.json +9 -5
package/dist/index.js
CHANGED
|
@@ -1,283 +1,24 @@
|
|
|
1
|
-
import 'axios';
|
|
2
|
-
|
|
3
1
|
var __defProp = Object.defineProperty;
|
|
4
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
3
|
|
|
6
|
-
// packages/reactivity/src/debug.ts
|
|
7
|
-
var activeDebugHooks = null;
|
|
8
|
-
var signalNames = /* @__PURE__ */ new WeakMap();
|
|
9
|
-
function setDebugHooks(hooks) {
|
|
10
|
-
const previous = activeDebugHooks;
|
|
11
|
-
activeDebugHooks = hooks;
|
|
12
|
-
return previous;
|
|
13
|
-
}
|
|
14
|
-
__name(setDebugHooks, "setDebugHooks");
|
|
15
|
-
function getDebugHooks() {
|
|
16
|
-
return activeDebugHooks;
|
|
17
|
-
}
|
|
18
|
-
__name(getDebugHooks, "getDebugHooks");
|
|
19
|
-
function hasDebugHooks() {
|
|
20
|
-
return activeDebugHooks !== null;
|
|
21
|
-
}
|
|
22
|
-
__name(hasDebugHooks, "hasDebugHooks");
|
|
23
|
-
function getSignalDebugName(signal) {
|
|
24
|
-
return signalNames.get(signal);
|
|
25
|
-
}
|
|
26
|
-
__name(getSignalDebugName, "getSignalDebugName");
|
|
27
|
-
function invokeDebug(name, ...args) {
|
|
28
|
-
const callback = activeDebugHooks?.[name];
|
|
29
|
-
if (!callback) return;
|
|
30
|
-
try {
|
|
31
|
-
callback(...args);
|
|
32
|
-
} catch {
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
__name(invokeDebug, "invokeDebug");
|
|
36
|
-
|
|
37
|
-
// packages/reactivity/src/owner.ts
|
|
38
|
-
var ownerNames = /* @__PURE__ */ new WeakMap();
|
|
39
|
-
function getOwnerDebugName(owner) {
|
|
40
|
-
return ownerNames.get(owner);
|
|
41
|
-
}
|
|
42
|
-
__name(getOwnerDebugName, "getOwnerDebugName");
|
|
43
|
-
function untrack(fn) {
|
|
44
|
-
try {
|
|
45
|
-
return fn();
|
|
46
|
-
} finally {
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
__name(untrack, "untrack");
|
|
50
|
-
|
|
51
|
-
// packages/reactivity/src/scheduler.ts
|
|
52
|
-
var _Scheduler = class _Scheduler {
|
|
53
|
-
constructor() {
|
|
54
|
-
this.dirtyEffects = /* @__PURE__ */ new Set();
|
|
55
|
-
this.lowPriorityEffects = /* @__PURE__ */ new Set();
|
|
56
|
-
// flush 不可重入(flushing 标志保证),缓冲数组可在轮次间安全复用,避免每轮分配。
|
|
57
|
-
this.normalBuffer = [];
|
|
58
|
-
this.lowBuffer = [];
|
|
59
|
-
this.flushing = false;
|
|
60
|
-
this.scheduled = false;
|
|
61
|
-
this.batchDepth = 0;
|
|
62
|
-
}
|
|
63
|
-
schedule(effect2) {
|
|
64
|
-
if (effect2.disposed) return;
|
|
65
|
-
this.dirtyEffects.add(effect2);
|
|
66
|
-
this.lowPriorityEffects.delete(effect2);
|
|
67
|
-
this.ensureScheduled();
|
|
68
|
-
}
|
|
69
|
-
/** Queue an effect behind normal updates while preserving deterministic order. */
|
|
70
|
-
scheduleLow(effect2) {
|
|
71
|
-
if (effect2.disposed) return;
|
|
72
|
-
if (!this.dirtyEffects.has(effect2)) this.lowPriorityEffects.add(effect2);
|
|
73
|
-
this.ensureScheduled();
|
|
74
|
-
}
|
|
75
|
-
ensureScheduled() {
|
|
76
|
-
if (this.batchDepth === 0 && !this.flushing && !this.scheduled) {
|
|
77
|
-
this.scheduled = true;
|
|
78
|
-
queueMicrotask(() => {
|
|
79
|
-
this.scheduled = false;
|
|
80
|
-
this.flush();
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
remove(effect2) {
|
|
85
|
-
this.dirtyEffects.delete(effect2);
|
|
86
|
-
this.lowPriorityEffects.delete(effect2);
|
|
87
|
-
}
|
|
88
|
-
batch(fn) {
|
|
89
|
-
this.batchDepth++;
|
|
90
|
-
try {
|
|
91
|
-
return fn();
|
|
92
|
-
} finally {
|
|
93
|
-
this.batchDepth--;
|
|
94
|
-
if (this.batchDepth === 0) this.flush();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
flush() {
|
|
98
|
-
if (this.flushing || this.batchDepth > 0) return;
|
|
99
|
-
this.flushing = true;
|
|
100
|
-
const debugEnabled = hasDebugHooks();
|
|
101
|
-
if (debugEnabled) invokeDebug("flushStart");
|
|
102
|
-
let rounds = 0;
|
|
103
|
-
let firstError;
|
|
104
|
-
let hasError = false;
|
|
105
|
-
try {
|
|
106
|
-
while (this.dirtyEffects.size > 0 || this.lowPriorityEffects.size > 0) {
|
|
107
|
-
if (++rounds > 100) {
|
|
108
|
-
this.dirtyEffects.clear();
|
|
109
|
-
this.lowPriorityEffects.clear();
|
|
110
|
-
throw new Error("Vobs: \u54CD\u5E94\u5F0F\u66F4\u65B0\u8D85\u8FC7 100 \u8F6E\uFF0C\u53EF\u80FD\u5B58\u5728\u5FAA\u73AF\u4F9D\u8D56");
|
|
111
|
-
}
|
|
112
|
-
this.collectRunnable(this.dirtyEffects, this.normalBuffer);
|
|
113
|
-
this.collectRunnable(this.lowPriorityEffects, this.lowBuffer);
|
|
114
|
-
sortEffects(this.normalBuffer);
|
|
115
|
-
sortEffects(this.lowBuffer);
|
|
116
|
-
for (const effect2 of this.normalBuffer) {
|
|
117
|
-
try {
|
|
118
|
-
effect2.run();
|
|
119
|
-
} catch (error) {
|
|
120
|
-
if (!hasError) {
|
|
121
|
-
firstError = error;
|
|
122
|
-
hasError = true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
for (const effect2 of this.lowBuffer) {
|
|
127
|
-
try {
|
|
128
|
-
effect2.run();
|
|
129
|
-
} catch (error) {
|
|
130
|
-
if (!hasError) {
|
|
131
|
-
firstError = error;
|
|
132
|
-
hasError = true;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
this.normalBuffer.length = 0;
|
|
137
|
-
this.lowBuffer.length = 0;
|
|
138
|
-
}
|
|
139
|
-
} finally {
|
|
140
|
-
this.normalBuffer.length = 0;
|
|
141
|
-
this.lowBuffer.length = 0;
|
|
142
|
-
this.flushing = false;
|
|
143
|
-
if (debugEnabled) invokeDebug("flushEnd");
|
|
144
|
-
}
|
|
145
|
-
if (hasError) throw firstError;
|
|
146
|
-
}
|
|
147
|
-
/** 收集未 disposed 的 effect 并清空源集合;run() 期间新调度的 effect 留给下一轮。 */
|
|
148
|
-
collectRunnable(source, target) {
|
|
149
|
-
for (const effect2 of source) {
|
|
150
|
-
if (!effect2.disposed) target.push(effect2);
|
|
151
|
-
}
|
|
152
|
-
source.clear();
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
__name(_Scheduler, "Scheduler");
|
|
156
|
-
function sortEffects(effects) {
|
|
157
|
-
if (effects.length > 1) {
|
|
158
|
-
effects.sort((a, b) => b.depth - a.depth || a.order - b.order);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
__name(sortEffects, "sortEffects");
|
|
162
|
-
|
|
163
|
-
// packages/runtime/src/debug.ts
|
|
164
|
-
var activeRuntimeDebugHooks = null;
|
|
165
|
-
var activeRuntimeDebugContext = null;
|
|
166
|
-
function setRuntimeDebugHooks(hooks) {
|
|
167
|
-
const previous = activeRuntimeDebugHooks;
|
|
168
|
-
activeRuntimeDebugHooks = hooks;
|
|
169
|
-
return previous;
|
|
170
|
-
}
|
|
171
|
-
__name(setRuntimeDebugHooks, "setRuntimeDebugHooks");
|
|
172
|
-
function getRuntimeDebugHooks() {
|
|
173
|
-
return activeRuntimeDebugHooks;
|
|
174
|
-
}
|
|
175
|
-
__name(getRuntimeDebugHooks, "getRuntimeDebugHooks");
|
|
176
|
-
function getRuntimeDebugContext() {
|
|
177
|
-
return activeRuntimeDebugContext;
|
|
178
|
-
}
|
|
179
|
-
__name(getRuntimeDebugContext, "getRuntimeDebugContext");
|
|
180
|
-
|
|
181
|
-
// packages/runtime/src/hmr.ts
|
|
182
|
-
var globalTarget = globalThis;
|
|
183
|
-
var hmrGlobal = globalTarget.__VOBS_HMR__ ?? { modules: /* @__PURE__ */ new Map() };
|
|
184
|
-
globalTarget.__VOBS_HMR__ = hmrGlobal;
|
|
185
|
-
|
|
186
|
-
// packages/runtime/src/error.ts
|
|
187
|
-
var _VobsError = class _VobsError extends Error {
|
|
188
|
-
constructor(options) {
|
|
189
|
-
super(options.message);
|
|
190
|
-
this.name = "VobsError";
|
|
191
|
-
this.code = options.code;
|
|
192
|
-
this.severity = options.severity ?? "error";
|
|
193
|
-
this.layer = options.layer ?? "runtime";
|
|
194
|
-
this.cause = options.cause;
|
|
195
|
-
this.fix = options.fix;
|
|
196
|
-
this.location = options.location;
|
|
197
|
-
this.trace = options.trace;
|
|
198
|
-
this.example = options.example;
|
|
199
|
-
this.docs = options.docs;
|
|
200
|
-
this.codeFrame = options.codeFrame;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
__name(_VobsError, "VobsError");
|
|
204
|
-
var VobsError = _VobsError;
|
|
205
|
-
function isVobsError(value) {
|
|
206
|
-
return value instanceof VobsError || Boolean(value && typeof value === "object" && typeof value.code === "string" && typeof value.message === "string" && typeof value.layer === "string");
|
|
207
|
-
}
|
|
208
|
-
__name(isVobsError, "isVobsError");
|
|
209
|
-
function normalizeVobsError(value, defaults = {}) {
|
|
210
|
-
if (value instanceof VobsError) return value;
|
|
211
|
-
if (value instanceof Error) {
|
|
212
|
-
const metadata = value;
|
|
213
|
-
const code = defaults.code ?? (typeof metadata.vobsCode === "string" ? metadata.vobsCode : void 0);
|
|
214
|
-
if (code) defineErrorMetadata(value, "code", code);
|
|
215
|
-
defineErrorMetadata(value, "severity", defaults.severity ?? "error");
|
|
216
|
-
defineErrorMetadata(value, "layer", defaults.layer ?? "runtime");
|
|
217
|
-
const fix = defaults.fix ?? (typeof metadata.vobsHint === "string" ? metadata.vobsHint : void 0);
|
|
218
|
-
if (fix) defineErrorMetadata(value, "fix", fix);
|
|
219
|
-
const source = metadata.vobsSource;
|
|
220
|
-
if (source && typeof source === "object" && typeof source.file === "string" && typeof source.line === "number" && typeof source.column === "number") {
|
|
221
|
-
defineErrorMetadata(value, "location", source);
|
|
222
|
-
}
|
|
223
|
-
return value;
|
|
224
|
-
}
|
|
225
|
-
if (isVobsError(value)) {
|
|
226
|
-
const candidate = value;
|
|
227
|
-
return new VobsError({
|
|
228
|
-
code: candidate.code,
|
|
229
|
-
message: candidate.message,
|
|
230
|
-
severity: candidate.severity ?? defaults.severity,
|
|
231
|
-
layer: candidate.layer ?? defaults.layer,
|
|
232
|
-
cause: candidate.cause,
|
|
233
|
-
fix: candidate.fix ?? defaults.fix,
|
|
234
|
-
location: candidate.location,
|
|
235
|
-
trace: candidate.trace,
|
|
236
|
-
example: candidate.example,
|
|
237
|
-
docs: candidate.docs,
|
|
238
|
-
codeFrame: candidate.codeFrame
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
const message = String(value);
|
|
242
|
-
return new VobsError({
|
|
243
|
-
code: defaults.code ?? "VOBS_UNKNOWN",
|
|
244
|
-
message,
|
|
245
|
-
severity: defaults.severity ?? "error",
|
|
246
|
-
layer: defaults.layer ?? "runtime",
|
|
247
|
-
cause: void 0,
|
|
248
|
-
fix: defaults.fix
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
__name(normalizeVobsError, "normalizeVobsError");
|
|
252
|
-
function defineErrorMetadata(target, key, value) {
|
|
253
|
-
if (key in target) return;
|
|
254
|
-
try {
|
|
255
|
-
Object.defineProperty(target, key, { configurable: true, enumerable: false, value, writable: true });
|
|
256
|
-
} catch {
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
__name(defineErrorMetadata, "defineErrorMetadata");
|
|
260
|
-
|
|
261
|
-
// packages/vobs/src/app.ts
|
|
262
|
-
function createInjectionKey(description) {
|
|
263
|
-
return Symbol(description);
|
|
264
|
-
}
|
|
265
|
-
__name(createInjectionKey, "createInjectionKey");
|
|
266
|
-
|
|
267
|
-
// packages/http/src/debug.ts
|
|
268
|
-
var activeHTTPDebugHooks = null;
|
|
269
|
-
function setHTTPDebugHooks(hooks) {
|
|
270
|
-
const previous = activeHTTPDebugHooks;
|
|
271
|
-
activeHTTPDebugHooks = hooks;
|
|
272
|
-
return previous;
|
|
273
|
-
}
|
|
274
|
-
__name(setHTTPDebugHooks, "setHTTPDebugHooks");
|
|
275
|
-
function getHTTPDebugHooks() {
|
|
276
|
-
return activeHTTPDebugHooks;
|
|
277
|
-
}
|
|
278
|
-
__name(getHTTPDebugHooks, "getHTTPDebugHooks");
|
|
279
|
-
|
|
280
4
|
// packages/devtools/src/index.ts
|
|
5
|
+
import {
|
|
6
|
+
getDebugHooks,
|
|
7
|
+
getOwnerDebugName,
|
|
8
|
+
getSignalDebugName,
|
|
9
|
+
setDebugHooks,
|
|
10
|
+
untrack
|
|
11
|
+
} from "@vobs/reactivity";
|
|
12
|
+
import {
|
|
13
|
+
getRuntimeDebugHooks,
|
|
14
|
+
getRuntimeDebugContext,
|
|
15
|
+
setRuntimeDebugHooks
|
|
16
|
+
} from "@vobs/runtime";
|
|
17
|
+
import { normalizeVobsError } from "@vobs/runtime";
|
|
18
|
+
import {
|
|
19
|
+
getHTTPDebugHooks,
|
|
20
|
+
setHTTPDebugHooks
|
|
21
|
+
} from "@vobs/http";
|
|
281
22
|
var DEVTOOLS_REACTIVITY_EVENTS = [
|
|
282
23
|
"owner-created",
|
|
283
24
|
"owner-named",
|
|
@@ -538,15 +279,15 @@ function createDevTools(options = {}) {
|
|
|
538
279
|
return record;
|
|
539
280
|
}
|
|
540
281
|
__name(ensureSignal, "ensureSignal");
|
|
541
|
-
function ensureEffect(
|
|
542
|
-
const existingId = effectIds.get(
|
|
282
|
+
function ensureEffect(effect, owner = null) {
|
|
283
|
+
const existingId = effectIds.get(effect);
|
|
543
284
|
if (existingId) {
|
|
544
285
|
const existing = effects.get(existingId);
|
|
545
286
|
if (existing) return existing;
|
|
546
287
|
}
|
|
547
288
|
const id = `effect-${nextId++}`;
|
|
548
289
|
const record = {
|
|
549
|
-
effect
|
|
290
|
+
effect,
|
|
550
291
|
id,
|
|
551
292
|
ownerId: owner ? ensureOwner(owner).id : null,
|
|
552
293
|
status: "dirty",
|
|
@@ -558,9 +299,9 @@ function createDevTools(options = {}) {
|
|
|
558
299
|
lastError: void 0,
|
|
559
300
|
lastDomUpdates: 0,
|
|
560
301
|
runningSince: null,
|
|
561
|
-
disposed:
|
|
302
|
+
disposed: effect.disposed
|
|
562
303
|
};
|
|
563
|
-
effectIds.set(
|
|
304
|
+
effectIds.set(effect, id);
|
|
564
305
|
effects.set(id, record);
|
|
565
306
|
return record;
|
|
566
307
|
}
|
|
@@ -576,7 +317,7 @@ function createDevTools(options = {}) {
|
|
|
576
317
|
return `${from}->${to}`;
|
|
577
318
|
}
|
|
578
319
|
__name(edgeKey, "edgeKey");
|
|
579
|
-
function
|
|
320
|
+
function trackDependency(dependency, subscriber) {
|
|
580
321
|
const source = ensureDependencySignal(dependency);
|
|
581
322
|
if (!source) return;
|
|
582
323
|
const memoId = memoSignalIds.get(subscriber);
|
|
@@ -590,7 +331,7 @@ function createDevTools(options = {}) {
|
|
|
590
331
|
type
|
|
591
332
|
});
|
|
592
333
|
}
|
|
593
|
-
__name(
|
|
334
|
+
__name(trackDependency, "trackDependency");
|
|
594
335
|
function collectEffectIds(signalId) {
|
|
595
336
|
const effectsForSignal = /* @__PURE__ */ new Set();
|
|
596
337
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -600,8 +341,8 @@ function createDevTools(options = {}) {
|
|
|
600
341
|
for (const edge of edges.values()) {
|
|
601
342
|
if (edge.from !== sourceId) continue;
|
|
602
343
|
if (effects.has(edge.to)) {
|
|
603
|
-
const
|
|
604
|
-
if (
|
|
344
|
+
const effect = effects.get(edge.to);
|
|
345
|
+
if (effect && !isInternalEffect(effect)) effectsForSignal.add(edge.to);
|
|
605
346
|
} else visit(edge.to);
|
|
606
347
|
}
|
|
607
348
|
}, "visit");
|
|
@@ -696,8 +437,8 @@ function createDevTools(options = {}) {
|
|
|
696
437
|
signals.delete(id);
|
|
697
438
|
}
|
|
698
439
|
}
|
|
699
|
-
for (const [id,
|
|
700
|
-
if (
|
|
440
|
+
for (const [id, effect] of effects) {
|
|
441
|
+
if (effect.ownerId === record.id) {
|
|
701
442
|
removedIds.add(id);
|
|
702
443
|
effects.delete(id);
|
|
703
444
|
}
|
|
@@ -712,15 +453,15 @@ function createDevTools(options = {}) {
|
|
|
712
453
|
}
|
|
713
454
|
__name(debugComponentName, "debugComponentName");
|
|
714
455
|
function buildComponentNode(record, activeIds) {
|
|
715
|
-
const componentEffects = [...effects.values()].filter((
|
|
716
|
-
const componentEffectIds = new Set(componentEffects.map((
|
|
717
|
-
const componentUpdates = updates.filter((update) => update.effects.some((
|
|
456
|
+
const componentEffects = [...effects.values()].filter((effect) => !effect.disposed && effect.ownerId === record.id);
|
|
457
|
+
const componentEffectIds = new Set(componentEffects.map((effect) => effect.id));
|
|
458
|
+
const componentUpdates = updates.filter((update) => update.effects.some((effect) => componentEffectIds.has(effect.effectId)));
|
|
718
459
|
return {
|
|
719
460
|
id: record.id,
|
|
720
461
|
name: record.name,
|
|
721
462
|
ownerId: record.id,
|
|
722
463
|
signals: [...signals.values()].filter((signal) => !signal.disposed && signal.ownerId === record.id).map((signal) => signal.id),
|
|
723
|
-
effects: componentEffects.map((
|
|
464
|
+
effects: componentEffects.map((effect) => effect.id),
|
|
724
465
|
recentUpdates: componentUpdates.slice(-10).map((update) => update.id),
|
|
725
466
|
domUpdates: componentUpdates.reduce((count, update) => count + update.domUpdates.length, 0),
|
|
726
467
|
children: [...owners.values()].filter((child) => !child.disposed && child.parentId === record.id && activeIds.has(child.id)).map((child) => buildComponentNode(child, activeIds)),
|
|
@@ -831,6 +572,10 @@ function createDevTools(options = {}) {
|
|
|
831
572
|
let pending = pendingUpdates.find((item) => item.signal.signal === signal);
|
|
832
573
|
if (pending) {
|
|
833
574
|
pending.nextValue = nextValue;
|
|
575
|
+
const context = getRuntimeDebugContext();
|
|
576
|
+
if (context?.route) pending.context = { ...pending.context, route: context.route };
|
|
577
|
+
if (context?.navigationId !== void 0) pending.context = { ...pending.context, navigationId: context.navigationId };
|
|
578
|
+
if (context?.dataRequestId !== void 0) pending.context.requestIds.add(context.dataRequestId);
|
|
834
579
|
} else {
|
|
835
580
|
pending = {
|
|
836
581
|
id: `update-${nextId++}`,
|
|
@@ -848,7 +593,7 @@ function createDevTools(options = {}) {
|
|
|
848
593
|
route: getRuntimeDebugContext()?.route,
|
|
849
594
|
navigationId: getRuntimeDebugContext()?.navigationId,
|
|
850
595
|
requestIds: new Set(
|
|
851
|
-
[]
|
|
596
|
+
getRuntimeDebugContext()?.dataRequestId === void 0 ? [] : [getRuntimeDebugContext().dataRequestId]
|
|
852
597
|
)
|
|
853
598
|
}
|
|
854
599
|
};
|
|
@@ -874,26 +619,26 @@ function createDevTools(options = {}) {
|
|
|
874
619
|
cleanupSignalRecord(record);
|
|
875
620
|
},
|
|
876
621
|
dependencyTracked(dependency, subscriber) {
|
|
877
|
-
|
|
622
|
+
trackDependency(dependency, subscriber);
|
|
878
623
|
},
|
|
879
624
|
dependencyUntracked(dependency, subscriber) {
|
|
880
625
|
untrackDependency(dependency, subscriber);
|
|
881
626
|
},
|
|
882
|
-
effectCreated(
|
|
883
|
-
const record = ensureEffect(
|
|
627
|
+
effectCreated(effect, owner) {
|
|
628
|
+
const record = ensureEffect(effect, owner);
|
|
884
629
|
if (isInternalEffect(record)) return;
|
|
885
630
|
recordLifecycle("effect-created", record.id, effectInfo(record).name, record.ownerId ?? void 0);
|
|
886
631
|
emit("effect-created", effectInfo(record));
|
|
887
632
|
},
|
|
888
|
-
effectInvalidated(
|
|
889
|
-
const record = ensureEffect(
|
|
633
|
+
effectInvalidated(effect) {
|
|
634
|
+
const record = ensureEffect(effect);
|
|
890
635
|
if (isInternalEffect(record)) return;
|
|
891
636
|
record.status = "dirty";
|
|
892
637
|
recordLifecycle("effect-invalidated", record.id, effectInfo(record).name, record.ownerId ?? void 0);
|
|
893
638
|
emit("effect-invalidated", effectInfo(record));
|
|
894
639
|
},
|
|
895
|
-
effectRunStart(
|
|
896
|
-
const record = ensureEffect(
|
|
640
|
+
effectRunStart(effect) {
|
|
641
|
+
const record = ensureEffect(effect);
|
|
897
642
|
if (isInternalEffect(record)) return;
|
|
898
643
|
record.status = "running";
|
|
899
644
|
record.runningSince = now();
|
|
@@ -901,8 +646,8 @@ function createDevTools(options = {}) {
|
|
|
901
646
|
recordLifecycle("effect-run-start", record.id, effectInfo(record).name, record.ownerId ?? void 0);
|
|
902
647
|
emit("effect-run-start", effectInfo(record));
|
|
903
648
|
},
|
|
904
|
-
effectRunEnd(
|
|
905
|
-
const record = ensureEffect(
|
|
649
|
+
effectRunEnd(effect, error, handled = false) {
|
|
650
|
+
const record = ensureEffect(effect);
|
|
906
651
|
if (isInternalEffect(record)) return;
|
|
907
652
|
const end = now();
|
|
908
653
|
const duration = record.runningSince === null ? 0 : Math.max(0, end - record.runningSince);
|
|
@@ -953,8 +698,8 @@ function createDevTools(options = {}) {
|
|
|
953
698
|
recordLifecycle("effect-run", record.id, effectInfo(record).name, record.ownerId ?? void 0, runStatus);
|
|
954
699
|
emit("effect-run", execution);
|
|
955
700
|
},
|
|
956
|
-
effectDisposed(
|
|
957
|
-
const record = ensureEffect(
|
|
701
|
+
effectDisposed(effect) {
|
|
702
|
+
const record = ensureEffect(effect);
|
|
958
703
|
const internal = isInternalEffect(record);
|
|
959
704
|
record.disposed = true;
|
|
960
705
|
record.status = "idle";
|
|
@@ -983,8 +728,8 @@ function createDevTools(options = {}) {
|
|
|
983
728
|
const runtimeHooks = {
|
|
984
729
|
domMutation(mutation) {
|
|
985
730
|
if (!activeEffectId) return;
|
|
986
|
-
const
|
|
987
|
-
if (!
|
|
731
|
+
const effect = effects.get(activeEffectId);
|
|
732
|
+
if (!effect || isInternalEffect(effect)) return;
|
|
988
733
|
const safeMutation = {
|
|
989
734
|
...mutation,
|
|
990
735
|
previousValue: privacy.redactDomValues ? privacy.replacement : serializeForDevTools(mutation.previousValue, /* @__PURE__ */ new Set(), 0, privacy),
|
|
@@ -1276,7 +1021,7 @@ function createDevTools(options = {}) {
|
|
|
1276
1021
|
return [...edges.values()].filter((edge) => edge.to === subscriberId);
|
|
1277
1022
|
},
|
|
1278
1023
|
getEffects() {
|
|
1279
|
-
return [...effects.values()].filter((
|
|
1024
|
+
return [...effects.values()].filter((effect) => !effect.disposed && !isInternalEffect(effect)).map(effectInfo);
|
|
1280
1025
|
},
|
|
1281
1026
|
getUpdates() {
|
|
1282
1027
|
return updates.slice();
|
|
@@ -1307,15 +1052,15 @@ function createDevTools(options = {}) {
|
|
|
1307
1052
|
status: update.status
|
|
1308
1053
|
});
|
|
1309
1054
|
}
|
|
1310
|
-
for (const
|
|
1311
|
-
if (
|
|
1055
|
+
for (const effect of effects.values()) {
|
|
1056
|
+
if (effect.disposed || isInternalEffect(effect) || effect.lastDuration <= 0) continue;
|
|
1312
1057
|
entries.push({
|
|
1313
1058
|
kind: "effect",
|
|
1314
|
-
id:
|
|
1315
|
-
label: effectInfo(
|
|
1316
|
-
duration:
|
|
1317
|
-
timestamp:
|
|
1318
|
-
status:
|
|
1059
|
+
id: effect.id,
|
|
1060
|
+
label: effectInfo(effect).name,
|
|
1061
|
+
duration: effect.lastDuration,
|
|
1062
|
+
timestamp: effect.lastExecutionTime,
|
|
1063
|
+
status: effect.lastRunStatus ?? effect.status
|
|
1319
1064
|
});
|
|
1320
1065
|
}
|
|
1321
1066
|
for (const request of networkRequests.values()) {
|
|
@@ -1361,7 +1106,7 @@ function createDevTools(options = {}) {
|
|
|
1361
1106
|
},
|
|
1362
1107
|
getPerformanceMetrics() {
|
|
1363
1108
|
const total = updateDurations.reduce((sum, duration) => sum + duration, 0);
|
|
1364
|
-
const effectDurations = [...effects.values()].filter((
|
|
1109
|
+
const effectDurations = [...effects.values()].filter((effect) => !effect.disposed).map((effect) => effect.lastDuration).filter((duration) => duration > 0);
|
|
1365
1110
|
const requestDurations = [...networkRequests.values()].map((request) => request.duration ?? 0).filter((duration) => duration > 0);
|
|
1366
1111
|
return {
|
|
1367
1112
|
updateCount,
|
|
@@ -1378,7 +1123,7 @@ function createDevTools(options = {}) {
|
|
|
1378
1123
|
takeMemorySnapshot() {
|
|
1379
1124
|
return {
|
|
1380
1125
|
signalCount: [...signals.values()].filter((signal) => !signal.disposed && !isInternalSignal(signal)).length,
|
|
1381
|
-
effectCount: [...effects.values()].filter((
|
|
1126
|
+
effectCount: [...effects.values()].filter((effect) => !effect.disposed && !isInternalEffect(effect)).length,
|
|
1382
1127
|
ownerCount: [...owners.values()].filter((owner) => !owner.disposed && !isInternalOwnerId(owner.id)).length,
|
|
1383
1128
|
dependencyEdgeCount: edges.size,
|
|
1384
1129
|
leakedOwners: [...owners.values()].filter((owner) => owner.disposed).length
|
|
@@ -1831,7 +1576,14 @@ function serializeForDevTools(value, seen = /* @__PURE__ */ new Set(), depth = 0
|
|
|
1831
1576
|
}
|
|
1832
1577
|
}
|
|
1833
1578
|
__name(serializeForDevTools, "serializeForDevTools");
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1579
|
+
export {
|
|
1580
|
+
DEVTOOLS_EVENTS,
|
|
1581
|
+
DEVTOOLS_REACTIVITY_EVENTS,
|
|
1582
|
+
connectDevTools,
|
|
1583
|
+
createDevTools,
|
|
1584
|
+
devtoolsPlugin,
|
|
1585
|
+
disableDevTools,
|
|
1586
|
+
enableDevTools,
|
|
1587
|
+
getDevTools
|
|
1588
|
+
};
|
|
1837
1589
|
//# sourceMappingURL=index.js.map
|