@zeus-js/signal 0.1.1-beta.1 → 0.1.1-beta.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.
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./dist/diagnostics.prod.cjs')
5
+ } else {
6
+ module.exports = require('./dist/diagnostics.cjs')
7
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * signal v0.1.1-beta.2
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ Object.defineProperties(exports, {
7
+ __esModule: { value: true },
8
+ [Symbol.toStringTag]: { value: "Module" }
9
+ });
10
+ let _zeus_js_signal_internal = require("@zeus-js/signal/internal");
11
+ exports.createRuntimeDiagnosticsSession = _zeus_js_signal_internal.createRuntimeDiagnosticsSession;
@@ -0,0 +1 @@
1
+ export { RuntimeDiagnosticsSession, RuntimeDiagnosticsSnapshot, createRuntimeDiagnosticsSession } from '@zeus-js/signal/internal';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * signal v0.1.1-beta.2
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ import { createRuntimeDiagnosticsSession } from "@zeus-js/signal/internal";
7
+ export { createRuntimeDiagnosticsSession };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * signal v0.1.1-beta.2
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ Object.defineProperties(exports, {
7
+ __esModule: { value: true },
8
+ [Symbol.toStringTag]: { value: "Module" }
9
+ });
10
+ let _zeus_js_signal_internal = require("@zeus-js/signal/internal");
11
+ exports.createRuntimeDiagnosticsSession = _zeus_js_signal_internal.createRuntimeDiagnosticsSession;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * signal v0.1.1-beta.2
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ import { createRuntimeDiagnosticsSession } from "@zeus-js/signal/internal";
7
+ export { createRuntimeDiagnosticsSession };
package/dist/internal.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * signal v0.1.1-beta.1
2
+ * signal v0.1.1-beta.2
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -32,6 +32,57 @@ let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
32
32
  return ReactiveFlags;
33
33
  }({});
34
34
  //#endregion
35
+ //#region packages/core/signal/src/runtime-diagnostics.ts
36
+ let activeRuntimeDiagnostics;
37
+ function runWithRuntimeDiagnostics(diagnostics, fn) {
38
+ if (!(diagnostics === null || diagnostics === void 0 ? void 0 : diagnostics[0])) return fn();
39
+ const previous = activeRuntimeDiagnostics;
40
+ activeRuntimeDiagnostics = diagnostics;
41
+ try {
42
+ return fn();
43
+ } finally {
44
+ activeRuntimeDiagnostics = (previous === null || previous === void 0 ? void 0 : previous[0]) ? previous : void 0;
45
+ }
46
+ }
47
+ function createRuntimeDiagnosticsSession() {
48
+ const diagnostics = [
49
+ true,
50
+ 0,
51
+ 0,
52
+ 0,
53
+ 0,
54
+ 0,
55
+ 0,
56
+ 0,
57
+ (run) => () => runWithRuntimeDiagnostics(diagnostics, run),
58
+ (run) => (fn) => runWithRuntimeDiagnostics(diagnostics, () => run(fn))
59
+ ];
60
+ return {
61
+ run(fn) {
62
+ return runWithRuntimeDiagnostics(diagnostics, fn);
63
+ },
64
+ snapshot() {
65
+ const allocationsCreated = diagnostics[1] + diagnostics[3] + diagnostics[4] + diagnostics[6] + diagnostics[7];
66
+ const allocationsDisposed = diagnostics[2] + diagnostics[5];
67
+ return {
68
+ effectsCreated: diagnostics[1],
69
+ effectsDisposed: diagnostics[2],
70
+ proxiesCreated: diagnostics[3],
71
+ scopesCreated: diagnostics[4],
72
+ scopesDisposed: diagnostics[5],
73
+ refsCreated: diagnostics[6],
74
+ memosCreated: diagnostics[7],
75
+ allocationsCreated,
76
+ allocationsDisposed
77
+ };
78
+ },
79
+ dispose() {
80
+ diagnostics[0] = false;
81
+ if (activeRuntimeDiagnostics === diagnostics) activeRuntimeDiagnostics = void 0;
82
+ }
83
+ };
84
+ }
85
+ //#endregion
35
86
  //#region packages/core/signal/src/warning.ts
36
87
  function warn(msg, ...args) {
37
88
  console.warn(`[Zeus warn] ${msg}`, ...args);
@@ -49,12 +100,27 @@ var EffectScope = class {
49
100
  this._isPaused = false;
50
101
  this._warnOnRun = true;
51
102
  this.__v_skip = true;
103
+ const diagnostics = activeRuntimeDiagnostics;
104
+ if (diagnostics) {
105
+ diagnostics[4]++;
106
+ this.run = diagnostics[9](this.run.bind(this));
107
+ const stop = this.stop.bind(this);
108
+ this.stop = (fromParent) => {
109
+ const active = this._active;
110
+ try {
111
+ stop(fromParent);
112
+ } finally {
113
+ if (active && !this._active && diagnostics[0]) diagnostics[5]++;
114
+ }
115
+ };
116
+ }
52
117
  if (!detached && activeEffectScope) if (activeEffectScope.active) {
53
118
  this.parent = activeEffectScope;
54
119
  this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
55
120
  } else {
56
121
  this._active = false;
57
122
  this._warnOnRun = false;
123
+ if (diagnostics) diagnostics[5]++;
58
124
  }
59
125
  }
60
126
  get active() {
@@ -203,9 +269,23 @@ var ReactiveEffect = class {
203
269
  this.next = void 0;
204
270
  this.cleanups = void 0;
205
271
  this.scheduler = void 0;
272
+ const diagnostics = activeRuntimeDiagnostics;
273
+ if (diagnostics) {
274
+ diagnostics[1]++;
275
+ this.run = diagnostics[8](this.run.bind(this));
276
+ const stop = this.stop.bind(this);
277
+ this.stop = () => {
278
+ const active = !!(this.flags & 1);
279
+ stop();
280
+ if (active && !(this.flags & 1) && diagnostics[0]) diagnostics[2]++;
281
+ };
282
+ }
206
283
  this.scope = activeEffectScope;
207
284
  if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
208
- else this.flags &= -2;
285
+ else {
286
+ this.flags &= -2;
287
+ if (diagnostics) diagnostics[2]++;
288
+ }
209
289
  }
210
290
  pause() {
211
291
  this.flags |= 64;
@@ -748,6 +828,8 @@ var ComputedRefImpl = class {
748
828
  this.flags = 16;
749
829
  this.globalVersion = globalVersion - 1;
750
830
  this.next = void 0;
831
+ const diagnostics = activeRuntimeDiagnostics;
832
+ if (diagnostics) diagnostics[7]++;
751
833
  this["__v_isReadonly"] = !setter;
752
834
  this.isSSR = isSSR;
753
835
  }
@@ -1329,6 +1411,8 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1329
1411
  if (existingProxy) return existingProxy;
1330
1412
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1331
1413
  proxyMap.set(target, proxy);
1414
+ const diagnostics = activeRuntimeDiagnostics;
1415
+ if (diagnostics) diagnostics[3]++;
1332
1416
  return proxy;
1333
1417
  }
1334
1418
  /**
@@ -1457,6 +1541,8 @@ var RefImpl = class {
1457
1541
  this.dep = new Dep();
1458
1542
  this[_ReactiveFlags$IS_REF] = true;
1459
1543
  this[_ReactiveFlags$IS_SHA] = false;
1544
+ const diagnostics = activeRuntimeDiagnostics;
1545
+ if (diagnostics) diagnostics[6]++;
1460
1546
  this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
1461
1547
  this._value = isShallow ? value : toReactive(value);
1462
1548
  this["__v_isShallow"] = isShallow;
@@ -1755,6 +1841,7 @@ exports.computed = computed;
1755
1841
  exports.createEffect = createEffect;
1756
1842
  exports.createMemo = createMemo;
1757
1843
  exports.createRoot = createRoot;
1844
+ exports.createRuntimeDiagnosticsSession = createRuntimeDiagnosticsSession;
1758
1845
  exports.createSignal = createSignal;
1759
1846
  exports.effect = effect;
1760
1847
  exports.effectScope = effectScope;
@@ -349,4 +349,23 @@ export declare function onWatcherCleanup(cleanupFn: () => void, failSilently?: b
349
349
  export declare function watch(source: WatchSource | WatchSource[] | WatchEffect | object, cb?: WatchCallback | null, options?: WatchOptions): WatchHandle;
350
350
  export declare function traverse(value: unknown, depth?: number, seen?: Map<unknown, number>): unknown;
351
351
 
352
+ export interface RuntimeDiagnosticsSnapshot {
353
+ effectsCreated: number;
354
+ effectsDisposed: number;
355
+ proxiesCreated: number;
356
+ scopesCreated: number;
357
+ scopesDisposed: number;
358
+ refsCreated: number;
359
+ memosCreated: number;
360
+ allocationsCreated: number;
361
+ allocationsDisposed: number;
362
+ }
363
+ export interface RuntimeDiagnosticsSession {
364
+ run<T extends () => unknown>(fn: SynchronousCallback<T>): ReturnType<T>;
365
+ snapshot(): Readonly<RuntimeDiagnosticsSnapshot>;
366
+ dispose(): void;
367
+ }
368
+ type SynchronousCallback<T extends () => unknown> = T & (Extract<ReturnType<T>, PromiseLike<unknown>> extends never ? unknown : never);
369
+ export declare function createRuntimeDiagnosticsSession(): RuntimeDiagnosticsSession;
370
+
352
371
  export { EffectScope as Scope, effectScope as scope, };
package/dist/internal.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * signal v0.1.1-beta.1
2
+ * signal v0.1.1-beta.2
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -28,6 +28,57 @@ let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
28
28
  return ReactiveFlags;
29
29
  }({});
30
30
  //#endregion
31
+ //#region packages/core/signal/src/runtime-diagnostics.ts
32
+ let activeRuntimeDiagnostics;
33
+ function runWithRuntimeDiagnostics(diagnostics, fn) {
34
+ if (!(diagnostics === null || diagnostics === void 0 ? void 0 : diagnostics[0])) return fn();
35
+ const previous = activeRuntimeDiagnostics;
36
+ activeRuntimeDiagnostics = diagnostics;
37
+ try {
38
+ return fn();
39
+ } finally {
40
+ activeRuntimeDiagnostics = (previous === null || previous === void 0 ? void 0 : previous[0]) ? previous : void 0;
41
+ }
42
+ }
43
+ function createRuntimeDiagnosticsSession() {
44
+ const diagnostics = [
45
+ true,
46
+ 0,
47
+ 0,
48
+ 0,
49
+ 0,
50
+ 0,
51
+ 0,
52
+ 0,
53
+ (run) => () => runWithRuntimeDiagnostics(diagnostics, run),
54
+ (run) => (fn) => runWithRuntimeDiagnostics(diagnostics, () => run(fn))
55
+ ];
56
+ return {
57
+ run(fn) {
58
+ return runWithRuntimeDiagnostics(diagnostics, fn);
59
+ },
60
+ snapshot() {
61
+ const allocationsCreated = diagnostics[1] + diagnostics[3] + diagnostics[4] + diagnostics[6] + diagnostics[7];
62
+ const allocationsDisposed = diagnostics[2] + diagnostics[5];
63
+ return {
64
+ effectsCreated: diagnostics[1],
65
+ effectsDisposed: diagnostics[2],
66
+ proxiesCreated: diagnostics[3],
67
+ scopesCreated: diagnostics[4],
68
+ scopesDisposed: diagnostics[5],
69
+ refsCreated: diagnostics[6],
70
+ memosCreated: diagnostics[7],
71
+ allocationsCreated,
72
+ allocationsDisposed
73
+ };
74
+ },
75
+ dispose() {
76
+ diagnostics[0] = false;
77
+ if (activeRuntimeDiagnostics === diagnostics) activeRuntimeDiagnostics = void 0;
78
+ }
79
+ };
80
+ }
81
+ //#endregion
31
82
  //#region packages/core/signal/src/warning.ts
32
83
  function warn(msg, ...args) {
33
84
  console.warn(`[Zeus warn] ${msg}`, ...args);
@@ -45,12 +96,27 @@ var EffectScope = class {
45
96
  this._isPaused = false;
46
97
  this._warnOnRun = true;
47
98
  this.__v_skip = true;
99
+ const diagnostics = activeRuntimeDiagnostics;
100
+ if (diagnostics) {
101
+ diagnostics[4]++;
102
+ this.run = diagnostics[9](this.run.bind(this));
103
+ const stop = this.stop.bind(this);
104
+ this.stop = (fromParent) => {
105
+ const active = this._active;
106
+ try {
107
+ stop(fromParent);
108
+ } finally {
109
+ if (active && !this._active && diagnostics[0]) diagnostics[5]++;
110
+ }
111
+ };
112
+ }
48
113
  if (!detached && activeEffectScope) if (activeEffectScope.active) {
49
114
  this.parent = activeEffectScope;
50
115
  this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
51
116
  } else {
52
117
  this._active = false;
53
118
  this._warnOnRun = false;
119
+ if (diagnostics) diagnostics[5]++;
54
120
  }
55
121
  }
56
122
  get active() {
@@ -199,9 +265,23 @@ var ReactiveEffect = class {
199
265
  this.next = void 0;
200
266
  this.cleanups = void 0;
201
267
  this.scheduler = void 0;
268
+ const diagnostics = activeRuntimeDiagnostics;
269
+ if (diagnostics) {
270
+ diagnostics[1]++;
271
+ this.run = diagnostics[8](this.run.bind(this));
272
+ const stop = this.stop.bind(this);
273
+ this.stop = () => {
274
+ const active = !!(this.flags & 1);
275
+ stop();
276
+ if (active && !(this.flags & 1) && diagnostics[0]) diagnostics[2]++;
277
+ };
278
+ }
202
279
  this.scope = activeEffectScope;
203
280
  if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
204
- else this.flags &= -2;
281
+ else {
282
+ this.flags &= -2;
283
+ if (diagnostics) diagnostics[2]++;
284
+ }
205
285
  }
206
286
  pause() {
207
287
  this.flags |= 64;
@@ -744,6 +824,8 @@ var ComputedRefImpl = class {
744
824
  this.flags = 16;
745
825
  this.globalVersion = globalVersion - 1;
746
826
  this.next = void 0;
827
+ const diagnostics = activeRuntimeDiagnostics;
828
+ if (diagnostics) diagnostics[7]++;
747
829
  this["__v_isReadonly"] = !setter;
748
830
  this.isSSR = isSSR;
749
831
  }
@@ -1325,6 +1407,8 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1325
1407
  if (existingProxy) return existingProxy;
1326
1408
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1327
1409
  proxyMap.set(target, proxy);
1410
+ const diagnostics = activeRuntimeDiagnostics;
1411
+ if (diagnostics) diagnostics[3]++;
1328
1412
  return proxy;
1329
1413
  }
1330
1414
  /**
@@ -1453,6 +1537,8 @@ var RefImpl = class {
1453
1537
  this.dep = new Dep();
1454
1538
  this[_ReactiveFlags$IS_REF] = true;
1455
1539
  this[_ReactiveFlags$IS_SHA] = false;
1540
+ const diagnostics = activeRuntimeDiagnostics;
1541
+ if (diagnostics) diagnostics[6]++;
1456
1542
  this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
1457
1543
  this._value = isShallow ? value : toReactive(value);
1458
1544
  this["__v_isShallow"] = isShallow;
@@ -1736,4 +1822,4 @@ function traverse(value, depth = Infinity, seen) {
1736
1822
  return value;
1737
1823
  }
1738
1824
  //#endregion
1739
- export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, batch, computed, createEffect, createMemo, createRoot, createSignal, effect, effectScope, effectScope as scope, enableTracking, flushJobs, getCurrentEffect, getCurrentScope, getCurrentWatcher, isValueState, nextTick, onCleanup, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, queueJob, reactiveReadArray, resetTracking, shallowReadArray, shallowState, state, stop, track, traverse, trigger, untrack, watch };
1825
+ export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, batch, computed, createEffect, createMemo, createRoot, createRuntimeDiagnosticsSession, createSignal, effect, effectScope, effectScope as scope, enableTracking, flushJobs, getCurrentEffect, getCurrentScope, getCurrentWatcher, isValueState, nextTick, onCleanup, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, queueJob, reactiveReadArray, resetTracking, shallowReadArray, shallowState, state, stop, track, traverse, trigger, untrack, watch };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * signal v0.1.1-beta.1
2
+ * signal v0.1.1-beta.2
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -32,6 +32,57 @@ let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
32
32
  return ReactiveFlags;
33
33
  }({});
34
34
  //#endregion
35
+ //#region packages/core/signal/src/runtime-diagnostics.ts
36
+ let activeRuntimeDiagnostics;
37
+ function runWithRuntimeDiagnostics(diagnostics, fn) {
38
+ if (!(diagnostics === null || diagnostics === void 0 ? void 0 : diagnostics[0])) return fn();
39
+ const previous = activeRuntimeDiagnostics;
40
+ activeRuntimeDiagnostics = diagnostics;
41
+ try {
42
+ return fn();
43
+ } finally {
44
+ activeRuntimeDiagnostics = (previous === null || previous === void 0 ? void 0 : previous[0]) ? previous : void 0;
45
+ }
46
+ }
47
+ function createRuntimeDiagnosticsSession() {
48
+ const diagnostics = [
49
+ true,
50
+ 0,
51
+ 0,
52
+ 0,
53
+ 0,
54
+ 0,
55
+ 0,
56
+ 0,
57
+ (run) => () => runWithRuntimeDiagnostics(diagnostics, run),
58
+ (run) => (fn) => runWithRuntimeDiagnostics(diagnostics, () => run(fn))
59
+ ];
60
+ return {
61
+ run(fn) {
62
+ return runWithRuntimeDiagnostics(diagnostics, fn);
63
+ },
64
+ snapshot() {
65
+ const allocationsCreated = diagnostics[1] + diagnostics[3] + diagnostics[4] + diagnostics[6] + diagnostics[7];
66
+ const allocationsDisposed = diagnostics[2] + diagnostics[5];
67
+ return {
68
+ effectsCreated: diagnostics[1],
69
+ effectsDisposed: diagnostics[2],
70
+ proxiesCreated: diagnostics[3],
71
+ scopesCreated: diagnostics[4],
72
+ scopesDisposed: diagnostics[5],
73
+ refsCreated: diagnostics[6],
74
+ memosCreated: diagnostics[7],
75
+ allocationsCreated,
76
+ allocationsDisposed
77
+ };
78
+ },
79
+ dispose() {
80
+ diagnostics[0] = false;
81
+ if (activeRuntimeDiagnostics === diagnostics) activeRuntimeDiagnostics = void 0;
82
+ }
83
+ };
84
+ }
85
+ //#endregion
35
86
  //#region packages/core/signal/src/effectScope.ts
36
87
  let activeEffectScope;
37
88
  var EffectScope = class {
@@ -44,12 +95,27 @@ var EffectScope = class {
44
95
  this._isPaused = false;
45
96
  this._warnOnRun = true;
46
97
  this.__v_skip = true;
98
+ const diagnostics = activeRuntimeDiagnostics;
99
+ if (diagnostics) {
100
+ diagnostics[4]++;
101
+ this.run = diagnostics[9](this.run.bind(this));
102
+ const stop = this.stop.bind(this);
103
+ this.stop = (fromParent) => {
104
+ const active = this._active;
105
+ try {
106
+ stop(fromParent);
107
+ } finally {
108
+ if (active && !this._active && diagnostics[0]) diagnostics[5]++;
109
+ }
110
+ };
111
+ }
47
112
  if (!detached && activeEffectScope) if (activeEffectScope.active) {
48
113
  this.parent = activeEffectScope;
49
114
  this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
50
115
  } else {
51
116
  this._active = false;
52
117
  this._warnOnRun = false;
118
+ if (diagnostics) diagnostics[5]++;
53
119
  }
54
120
  }
55
121
  get active() {
@@ -197,9 +263,23 @@ var ReactiveEffect = class {
197
263
  this.next = void 0;
198
264
  this.cleanups = void 0;
199
265
  this.scheduler = void 0;
266
+ const diagnostics = activeRuntimeDiagnostics;
267
+ if (diagnostics) {
268
+ diagnostics[1]++;
269
+ this.run = diagnostics[8](this.run.bind(this));
270
+ const stop = this.stop.bind(this);
271
+ this.stop = () => {
272
+ const active = !!(this.flags & 1);
273
+ stop();
274
+ if (active && !(this.flags & 1) && diagnostics[0]) diagnostics[2]++;
275
+ };
276
+ }
200
277
  this.scope = activeEffectScope;
201
278
  if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
202
- else this.flags &= -2;
279
+ else {
280
+ this.flags &= -2;
281
+ if (diagnostics) diagnostics[2]++;
282
+ }
203
283
  }
204
284
  pause() {
205
285
  this.flags |= 64;
@@ -725,6 +805,8 @@ var ComputedRefImpl = class {
725
805
  this.flags = 16;
726
806
  this.globalVersion = globalVersion - 1;
727
807
  this.next = void 0;
808
+ const diagnostics = activeRuntimeDiagnostics;
809
+ if (diagnostics) diagnostics[7]++;
728
810
  this["__v_isReadonly"] = !setter;
729
811
  this.isSSR = isSSR;
730
812
  }
@@ -1277,6 +1359,8 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1277
1359
  if (existingProxy) return existingProxy;
1278
1360
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1279
1361
  proxyMap.set(target, proxy);
1362
+ const diagnostics = activeRuntimeDiagnostics;
1363
+ if (diagnostics) diagnostics[3]++;
1280
1364
  return proxy;
1281
1365
  }
1282
1366
  /**
@@ -1405,6 +1489,8 @@ var RefImpl = class {
1405
1489
  this.dep = new Dep();
1406
1490
  this[_ReactiveFlags$IS_REF] = true;
1407
1491
  this[_ReactiveFlags$IS_SHA] = false;
1492
+ const diagnostics = activeRuntimeDiagnostics;
1493
+ if (diagnostics) diagnostics[6]++;
1408
1494
  this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
1409
1495
  this._value = isShallow ? value : toReactive(value);
1410
1496
  this["__v_isShallow"] = isShallow;
@@ -1684,6 +1770,7 @@ exports.computed = computed;
1684
1770
  exports.createEffect = createEffect;
1685
1771
  exports.createMemo = createMemo;
1686
1772
  exports.createRoot = createRoot;
1773
+ exports.createRuntimeDiagnosticsSession = createRuntimeDiagnosticsSession;
1687
1774
  exports.createSignal = createSignal;
1688
1775
  exports.effect = effect;
1689
1776
  exports.effectScope = effectScope;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * signal v0.1.1-beta.1
2
+ * signal v0.1.1-beta.2
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -28,6 +28,57 @@ let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
28
28
  return ReactiveFlags;
29
29
  }({});
30
30
  //#endregion
31
+ //#region packages/core/signal/src/runtime-diagnostics.ts
32
+ let activeRuntimeDiagnostics;
33
+ function runWithRuntimeDiagnostics(diagnostics, fn) {
34
+ if (!(diagnostics === null || diagnostics === void 0 ? void 0 : diagnostics[0])) return fn();
35
+ const previous = activeRuntimeDiagnostics;
36
+ activeRuntimeDiagnostics = diagnostics;
37
+ try {
38
+ return fn();
39
+ } finally {
40
+ activeRuntimeDiagnostics = (previous === null || previous === void 0 ? void 0 : previous[0]) ? previous : void 0;
41
+ }
42
+ }
43
+ function createRuntimeDiagnosticsSession() {
44
+ const diagnostics = [
45
+ true,
46
+ 0,
47
+ 0,
48
+ 0,
49
+ 0,
50
+ 0,
51
+ 0,
52
+ 0,
53
+ (run) => () => runWithRuntimeDiagnostics(diagnostics, run),
54
+ (run) => (fn) => runWithRuntimeDiagnostics(diagnostics, () => run(fn))
55
+ ];
56
+ return {
57
+ run(fn) {
58
+ return runWithRuntimeDiagnostics(diagnostics, fn);
59
+ },
60
+ snapshot() {
61
+ const allocationsCreated = diagnostics[1] + diagnostics[3] + diagnostics[4] + diagnostics[6] + diagnostics[7];
62
+ const allocationsDisposed = diagnostics[2] + diagnostics[5];
63
+ return {
64
+ effectsCreated: diagnostics[1],
65
+ effectsDisposed: diagnostics[2],
66
+ proxiesCreated: diagnostics[3],
67
+ scopesCreated: diagnostics[4],
68
+ scopesDisposed: diagnostics[5],
69
+ refsCreated: diagnostics[6],
70
+ memosCreated: diagnostics[7],
71
+ allocationsCreated,
72
+ allocationsDisposed
73
+ };
74
+ },
75
+ dispose() {
76
+ diagnostics[0] = false;
77
+ if (activeRuntimeDiagnostics === diagnostics) activeRuntimeDiagnostics = void 0;
78
+ }
79
+ };
80
+ }
81
+ //#endregion
31
82
  //#region packages/core/signal/src/warning.ts
32
83
  function warn(msg, ...args) {
33
84
  console.warn(`[Zeus warn] ${msg}`, ...args);
@@ -45,12 +96,27 @@ var EffectScope = class {
45
96
  this._isPaused = false;
46
97
  this._warnOnRun = true;
47
98
  this.__v_skip = true;
99
+ const diagnostics = activeRuntimeDiagnostics;
100
+ if (diagnostics) {
101
+ diagnostics[4]++;
102
+ this.run = diagnostics[9](this.run.bind(this));
103
+ const stop = this.stop.bind(this);
104
+ this.stop = (fromParent) => {
105
+ const active = this._active;
106
+ try {
107
+ stop(fromParent);
108
+ } finally {
109
+ if (active && !this._active && diagnostics[0]) diagnostics[5]++;
110
+ }
111
+ };
112
+ }
48
113
  if (!detached && activeEffectScope) if (activeEffectScope.active) {
49
114
  this.parent = activeEffectScope;
50
115
  this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
51
116
  } else {
52
117
  this._active = false;
53
118
  this._warnOnRun = false;
119
+ if (diagnostics) diagnostics[5]++;
54
120
  }
55
121
  }
56
122
  get active() {
@@ -199,9 +265,23 @@ var ReactiveEffect = class {
199
265
  this.next = void 0;
200
266
  this.cleanups = void 0;
201
267
  this.scheduler = void 0;
268
+ const diagnostics = activeRuntimeDiagnostics;
269
+ if (diagnostics) {
270
+ diagnostics[1]++;
271
+ this.run = diagnostics[8](this.run.bind(this));
272
+ const stop = this.stop.bind(this);
273
+ this.stop = () => {
274
+ const active = !!(this.flags & 1);
275
+ stop();
276
+ if (active && !(this.flags & 1) && diagnostics[0]) diagnostics[2]++;
277
+ };
278
+ }
202
279
  this.scope = activeEffectScope;
203
280
  if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
204
- else this.flags &= -2;
281
+ else {
282
+ this.flags &= -2;
283
+ if (diagnostics) diagnostics[2]++;
284
+ }
205
285
  }
206
286
  pause() {
207
287
  this.flags |= 64;
@@ -744,6 +824,8 @@ var ComputedRefImpl = class {
744
824
  this.flags = 16;
745
825
  this.globalVersion = globalVersion - 1;
746
826
  this.next = void 0;
827
+ const diagnostics = activeRuntimeDiagnostics;
828
+ if (diagnostics) diagnostics[7]++;
747
829
  this["__v_isReadonly"] = !setter;
748
830
  this.isSSR = isSSR;
749
831
  }
@@ -1325,6 +1407,8 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1325
1407
  if (existingProxy) return existingProxy;
1326
1408
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1327
1409
  proxyMap.set(target, proxy);
1410
+ const diagnostics = activeRuntimeDiagnostics;
1411
+ if (diagnostics) diagnostics[3]++;
1328
1412
  return proxy;
1329
1413
  }
1330
1414
  /**
@@ -1453,6 +1537,8 @@ var RefImpl = class {
1453
1537
  this.dep = new Dep();
1454
1538
  this[_ReactiveFlags$IS_REF] = true;
1455
1539
  this[_ReactiveFlags$IS_SHA] = false;
1540
+ const diagnostics = activeRuntimeDiagnostics;
1541
+ if (diagnostics) diagnostics[6]++;
1456
1542
  this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
1457
1543
  this._value = isShallow ? value : toReactive(value);
1458
1544
  this["__v_isShallow"] = isShallow;
@@ -1736,4 +1822,4 @@ function traverse(value, depth = Infinity, seen) {
1736
1822
  return value;
1737
1823
  }
1738
1824
  //#endregion
1739
- export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, batch, computed, createEffect, createMemo, createRoot, createSignal, effect, effectScope, effectScope as scope, enableTracking, flushJobs, getCurrentEffect, getCurrentScope, getCurrentWatcher, isValueState, nextTick, onCleanup, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, queueJob, reactiveReadArray, resetTracking, shallowReadArray, shallowState, state, stop, track, traverse, trigger, untrack, watch };
1825
+ export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, batch, computed, createEffect, createMemo, createRoot, createRuntimeDiagnosticsSession, createSignal, effect, effectScope, effectScope as scope, enableTracking, flushJobs, getCurrentEffect, getCurrentScope, getCurrentWatcher, isValueState, nextTick, onCleanup, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, queueJob, reactiveReadArray, resetTracking, shallowReadArray, shallowState, state, stop, track, traverse, trigger, untrack, watch };
package/dist/signal.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * signal v0.1.1-beta.1
2
+ * signal v0.1.1-beta.2
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * signal v0.1.1-beta.1
2
+ * signal v0.1.1-beta.2
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * signal v0.1.1-beta.1
2
+ * signal v0.1.1-beta.2
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * signal v0.1.1-beta.1
2
+ * signal v0.1.1-beta.2
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * signal v0.1.1-beta.1
2
+ * signal v0.1.1-beta.2
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zeus-js/signal",
3
3
  "type": "module",
4
- "version": "0.1.1-beta.1",
4
+ "version": "0.1.1-beta.2",
5
5
  "description": "@zeus-js/signal",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -33,16 +33,26 @@
33
33
  "development": "./dist/internal.cjs",
34
34
  "default": "./internal.cjs"
35
35
  }
36
+ },
37
+ "./diagnostics": {
38
+ "types": "./dist/diagnostics.d.ts",
39
+ "import": "./dist/diagnostics.js",
40
+ "require": {
41
+ "production": "./dist/diagnostics.prod.cjs",
42
+ "development": "./dist/diagnostics.cjs",
43
+ "default": "./diagnostics.cjs"
44
+ }
36
45
  }
37
46
  },
38
47
  "files": [
39
48
  "index.cjs",
40
49
  "internal.cjs",
50
+ "diagnostics.cjs",
41
51
  "dist"
42
52
  ],
43
53
  "dependencies": {
44
54
  "alien-signals": "^3.2.1",
45
- "@zeus-js/shared": "0.1.1-beta.1"
55
+ "@zeus-js/shared": "0.1.1-beta.2"
46
56
  },
47
57
  "author": "Baicie",
48
58
  "bugs": {
@@ -63,6 +73,10 @@
63
73
  {
64
74
  "entry": "internal.ts",
65
75
  "output": "dist/internal.js"
76
+ },
77
+ {
78
+ "entry": "diagnostics.ts",
79
+ "output": "dist/diagnostics.js"
66
80
  }
67
81
  ]
68
82
  },