@zeus-js/signal 0.1.1-beta.0 → 0.1.1-beta.10

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.10
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.10
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.10
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.10
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.0
2
+ * signal v0.1.1-beta.10
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() {
@@ -190,6 +256,10 @@ let EffectFlags = /* @__PURE__ */ function(EffectFlags) {
190
256
  EffectFlags[EffectFlags["DIRTY"] = 16] = "DIRTY";
191
257
  EffectFlags[EffectFlags["ALLOW_RECURSE"] = 32] = "ALLOW_RECURSE";
192
258
  EffectFlags[EffectFlags["PAUSED"] = 64] = "PAUSED";
259
+ /**
260
+ * ComputedRef has evaluated, or a ReactiveEffect has tracked a computed
261
+ * dependency. This is sticky so dirty checks remain available when needed.
262
+ */
193
263
  EffectFlags[EffectFlags["EVALUATED"] = 128] = "EVALUATED";
194
264
  return EffectFlags;
195
265
  }({});
@@ -203,9 +273,23 @@ var ReactiveEffect = class {
203
273
  this.next = void 0;
204
274
  this.cleanups = void 0;
205
275
  this.scheduler = void 0;
276
+ const diagnostics = activeRuntimeDiagnostics;
277
+ if (diagnostics) {
278
+ diagnostics[1]++;
279
+ this.run = diagnostics[8](this.run.bind(this));
280
+ const stop = this.stop.bind(this);
281
+ this.stop = () => {
282
+ const active = !!(this.flags & 1);
283
+ stop();
284
+ if (active && !(this.flags & 1) && diagnostics[0]) diagnostics[2]++;
285
+ };
286
+ }
206
287
  this.scope = activeEffectScope;
207
288
  if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
208
- else this.flags &= -2;
289
+ else {
290
+ this.flags &= -2;
291
+ if (diagnostics) diagnostics[2]++;
292
+ }
209
293
  }
210
294
  pause() {
211
295
  this.flags |= 64;
@@ -257,7 +341,8 @@ var ReactiveEffect = class {
257
341
  trigger() {
258
342
  if (this.flags & 64) pausedQueueEffects.add(this);
259
343
  else if (this.scheduler) this.scheduler();
260
- else this.runIfDirty();
344
+ else if (this.flags & 128) this.runIfDirty();
345
+ else this.run();
261
346
  }
262
347
  /**
263
348
  * @internal
@@ -583,6 +668,7 @@ var Dep = class {
583
668
  }
584
669
  track(debugInfo) {
585
670
  if (!activeSub || !shouldTrack || activeSub === this.computed) return;
671
+ if (this.computed) activeSub.flags |= 128;
586
672
  let link = this.activeLink;
587
673
  if (link === void 0 || link.sub !== activeSub) {
588
674
  link = this.activeLink = new Link(activeSub, this);
@@ -748,6 +834,8 @@ var ComputedRefImpl = class {
748
834
  this.flags = 16;
749
835
  this.globalVersion = globalVersion - 1;
750
836
  this.next = void 0;
837
+ const diagnostics = activeRuntimeDiagnostics;
838
+ if (diagnostics) diagnostics[7]++;
751
839
  this["__v_isReadonly"] = !setter;
752
840
  this.isSSR = isSSR;
753
841
  }
@@ -1329,6 +1417,8 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1329
1417
  if (existingProxy) return existingProxy;
1330
1418
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1331
1419
  proxyMap.set(target, proxy);
1420
+ const diagnostics = activeRuntimeDiagnostics;
1421
+ if (diagnostics) diagnostics[3]++;
1332
1422
  return proxy;
1333
1423
  }
1334
1424
  /**
@@ -1457,6 +1547,8 @@ var RefImpl = class {
1457
1547
  this.dep = new Dep();
1458
1548
  this[_ReactiveFlags$IS_REF] = true;
1459
1549
  this[_ReactiveFlags$IS_SHA] = false;
1550
+ const diagnostics = activeRuntimeDiagnostics;
1551
+ if (diagnostics) diagnostics[6]++;
1460
1552
  this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
1461
1553
  this._value = isShallow ? value : toReactive(value);
1462
1554
  this["__v_isShallow"] = isShallow;
@@ -1526,6 +1618,9 @@ function state(value) {
1526
1618
  if (arguments.length === 0) return /* @__PURE__ */ ref();
1527
1619
  return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
1528
1620
  }
1621
+ function shallowState(value) {
1622
+ return arguments.length === 0 ? /* @__PURE__ */ shallowRef() : /* @__PURE__ */ shallowRef(value);
1623
+ }
1529
1624
  function isValueState(value) {
1530
1625
  if (!value || typeof value !== "object") return false;
1531
1626
  const obj = value;
@@ -1752,6 +1847,7 @@ exports.computed = computed;
1752
1847
  exports.createEffect = createEffect;
1753
1848
  exports.createMemo = createMemo;
1754
1849
  exports.createRoot = createRoot;
1850
+ exports.createRuntimeDiagnosticsSession = createRuntimeDiagnosticsSession;
1755
1851
  exports.createSignal = createSignal;
1756
1852
  exports.effect = effect;
1757
1853
  exports.effectScope = effectScope;
@@ -1772,6 +1868,7 @@ exports.reactiveReadArray = reactiveReadArray;
1772
1868
  exports.resetTracking = resetTracking;
1773
1869
  exports.scope = effectScope;
1774
1870
  exports.shallowReadArray = shallowReadArray;
1871
+ exports.shallowState = shallowState;
1775
1872
  exports.state = state;
1776
1873
  exports.stop = stop;
1777
1874
  exports.track = track;
@@ -95,6 +95,10 @@ export declare enum EffectFlags {
95
95
  DIRTY = 16,
96
96
  ALLOW_RECURSE = 32,
97
97
  PAUSED = 64,
98
+ /**
99
+ * ComputedRef has evaluated, or a ReactiveEffect has tracked a computed
100
+ * dependency. This is sticky so dirty checks remain available when needed.
101
+ */
98
102
  EVALUATED = 128
99
103
  }
100
104
  /**
@@ -186,6 +190,8 @@ export declare function state<T extends ValueStateInput>(value: T): ValueState<T
186
190
  export declare function state<T extends ProxyableInput>(value: T): Reactive<T>;
187
191
  export declare function state<T>(value: T): ValueState<T>;
188
192
  export declare function state<T = undefined>(): ValueState<T | undefined>;
193
+ export declare function shallowState<T>(value: T): ValueState<T>;
194
+ export declare function shallowState<T = undefined>(): ValueState<T | undefined>;
189
195
  export declare function isValueState<T = unknown>(value: unknown): value is ValueState<T>;
190
196
 
191
197
  declare const RefSymbol: unique symbol;
@@ -347,4 +353,23 @@ export declare function onWatcherCleanup(cleanupFn: () => void, failSilently?: b
347
353
  export declare function watch(source: WatchSource | WatchSource[] | WatchEffect | object, cb?: WatchCallback | null, options?: WatchOptions): WatchHandle;
348
354
  export declare function traverse(value: unknown, depth?: number, seen?: Map<unknown, number>): unknown;
349
355
 
356
+ export interface RuntimeDiagnosticsSnapshot {
357
+ effectsCreated: number;
358
+ effectsDisposed: number;
359
+ proxiesCreated: number;
360
+ scopesCreated: number;
361
+ scopesDisposed: number;
362
+ refsCreated: number;
363
+ memosCreated: number;
364
+ allocationsCreated: number;
365
+ allocationsDisposed: number;
366
+ }
367
+ export interface RuntimeDiagnosticsSession {
368
+ run<T extends () => unknown>(fn: SynchronousCallback<T>): ReturnType<T>;
369
+ snapshot(): Readonly<RuntimeDiagnosticsSnapshot>;
370
+ dispose(): void;
371
+ }
372
+ type SynchronousCallback<T extends () => unknown> = T & (Extract<ReturnType<T>, PromiseLike<unknown>> extends never ? unknown : never);
373
+ export declare function createRuntimeDiagnosticsSession(): RuntimeDiagnosticsSession;
374
+
350
375
  export { EffectScope as Scope, effectScope as scope, };
package/dist/internal.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * signal v0.1.1-beta.0
2
+ * signal v0.1.1-beta.10
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() {
@@ -186,6 +252,10 @@ let EffectFlags = /* @__PURE__ */ function(EffectFlags) {
186
252
  EffectFlags[EffectFlags["DIRTY"] = 16] = "DIRTY";
187
253
  EffectFlags[EffectFlags["ALLOW_RECURSE"] = 32] = "ALLOW_RECURSE";
188
254
  EffectFlags[EffectFlags["PAUSED"] = 64] = "PAUSED";
255
+ /**
256
+ * ComputedRef has evaluated, or a ReactiveEffect has tracked a computed
257
+ * dependency. This is sticky so dirty checks remain available when needed.
258
+ */
189
259
  EffectFlags[EffectFlags["EVALUATED"] = 128] = "EVALUATED";
190
260
  return EffectFlags;
191
261
  }({});
@@ -199,9 +269,23 @@ var ReactiveEffect = class {
199
269
  this.next = void 0;
200
270
  this.cleanups = void 0;
201
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
+ }
202
283
  this.scope = activeEffectScope;
203
284
  if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
204
- else this.flags &= -2;
285
+ else {
286
+ this.flags &= -2;
287
+ if (diagnostics) diagnostics[2]++;
288
+ }
205
289
  }
206
290
  pause() {
207
291
  this.flags |= 64;
@@ -253,7 +337,8 @@ var ReactiveEffect = class {
253
337
  trigger() {
254
338
  if (this.flags & 64) pausedQueueEffects.add(this);
255
339
  else if (this.scheduler) this.scheduler();
256
- else this.runIfDirty();
340
+ else if (this.flags & 128) this.runIfDirty();
341
+ else this.run();
257
342
  }
258
343
  /**
259
344
  * @internal
@@ -579,6 +664,7 @@ var Dep = class {
579
664
  }
580
665
  track(debugInfo) {
581
666
  if (!activeSub || !shouldTrack || activeSub === this.computed) return;
667
+ if (this.computed) activeSub.flags |= 128;
582
668
  let link = this.activeLink;
583
669
  if (link === void 0 || link.sub !== activeSub) {
584
670
  link = this.activeLink = new Link(activeSub, this);
@@ -744,6 +830,8 @@ var ComputedRefImpl = class {
744
830
  this.flags = 16;
745
831
  this.globalVersion = globalVersion - 1;
746
832
  this.next = void 0;
833
+ const diagnostics = activeRuntimeDiagnostics;
834
+ if (diagnostics) diagnostics[7]++;
747
835
  this["__v_isReadonly"] = !setter;
748
836
  this.isSSR = isSSR;
749
837
  }
@@ -1325,6 +1413,8 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1325
1413
  if (existingProxy) return existingProxy;
1326
1414
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1327
1415
  proxyMap.set(target, proxy);
1416
+ const diagnostics = activeRuntimeDiagnostics;
1417
+ if (diagnostics) diagnostics[3]++;
1328
1418
  return proxy;
1329
1419
  }
1330
1420
  /**
@@ -1453,6 +1543,8 @@ var RefImpl = class {
1453
1543
  this.dep = new Dep();
1454
1544
  this[_ReactiveFlags$IS_REF] = true;
1455
1545
  this[_ReactiveFlags$IS_SHA] = false;
1546
+ const diagnostics = activeRuntimeDiagnostics;
1547
+ if (diagnostics) diagnostics[6]++;
1456
1548
  this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
1457
1549
  this._value = isShallow ? value : toReactive(value);
1458
1550
  this["__v_isShallow"] = isShallow;
@@ -1522,6 +1614,9 @@ function state(value) {
1522
1614
  if (arguments.length === 0) return /* @__PURE__ */ ref();
1523
1615
  return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
1524
1616
  }
1617
+ function shallowState(value) {
1618
+ return arguments.length === 0 ? /* @__PURE__ */ shallowRef() : /* @__PURE__ */ shallowRef(value);
1619
+ }
1525
1620
  function isValueState(value) {
1526
1621
  if (!value || typeof value !== "object") return false;
1527
1622
  const obj = value;
@@ -1733,4 +1828,4 @@ function traverse(value, depth = Infinity, seen) {
1733
1828
  return value;
1734
1829
  }
1735
1830
  //#endregion
1736
- 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, state, stop, track, traverse, trigger, untrack, watch };
1831
+ 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.0
2
+ * signal v0.1.1-beta.10
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() {
@@ -184,6 +250,10 @@ let EffectFlags = /* @__PURE__ */ function(EffectFlags) {
184
250
  EffectFlags[EffectFlags["DIRTY"] = 16] = "DIRTY";
185
251
  EffectFlags[EffectFlags["ALLOW_RECURSE"] = 32] = "ALLOW_RECURSE";
186
252
  EffectFlags[EffectFlags["PAUSED"] = 64] = "PAUSED";
253
+ /**
254
+ * ComputedRef has evaluated, or a ReactiveEffect has tracked a computed
255
+ * dependency. This is sticky so dirty checks remain available when needed.
256
+ */
187
257
  EffectFlags[EffectFlags["EVALUATED"] = 128] = "EVALUATED";
188
258
  return EffectFlags;
189
259
  }({});
@@ -197,9 +267,23 @@ var ReactiveEffect = class {
197
267
  this.next = void 0;
198
268
  this.cleanups = void 0;
199
269
  this.scheduler = void 0;
270
+ const diagnostics = activeRuntimeDiagnostics;
271
+ if (diagnostics) {
272
+ diagnostics[1]++;
273
+ this.run = diagnostics[8](this.run.bind(this));
274
+ const stop = this.stop.bind(this);
275
+ this.stop = () => {
276
+ const active = !!(this.flags & 1);
277
+ stop();
278
+ if (active && !(this.flags & 1) && diagnostics[0]) diagnostics[2]++;
279
+ };
280
+ }
200
281
  this.scope = activeEffectScope;
201
282
  if (activeEffectScope) if (activeEffectScope.active) activeEffectScope.effects.push(this);
202
- else this.flags &= -2;
283
+ else {
284
+ this.flags &= -2;
285
+ if (diagnostics) diagnostics[2]++;
286
+ }
203
287
  }
204
288
  pause() {
205
289
  this.flags |= 64;
@@ -250,7 +334,8 @@ var ReactiveEffect = class {
250
334
  trigger() {
251
335
  if (this.flags & 64) pausedQueueEffects.add(this);
252
336
  else if (this.scheduler) this.scheduler();
253
- else this.runIfDirty();
337
+ else if (this.flags & 128) this.runIfDirty();
338
+ else this.run();
254
339
  }
255
340
  /**
256
341
  * @internal
@@ -574,6 +659,7 @@ var Dep = class {
574
659
  }
575
660
  track(debugInfo) {
576
661
  if (!activeSub || !shouldTrack || activeSub === this.computed) return;
662
+ if (this.computed) activeSub.flags |= 128;
577
663
  let link = this.activeLink;
578
664
  if (link === void 0 || link.sub !== activeSub) {
579
665
  link = this.activeLink = new Link(activeSub, this);
@@ -725,6 +811,8 @@ var ComputedRefImpl = class {
725
811
  this.flags = 16;
726
812
  this.globalVersion = globalVersion - 1;
727
813
  this.next = void 0;
814
+ const diagnostics = activeRuntimeDiagnostics;
815
+ if (diagnostics) diagnostics[7]++;
728
816
  this["__v_isReadonly"] = !setter;
729
817
  this.isSSR = isSSR;
730
818
  }
@@ -1277,6 +1365,8 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1277
1365
  if (existingProxy) return existingProxy;
1278
1366
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1279
1367
  proxyMap.set(target, proxy);
1368
+ const diagnostics = activeRuntimeDiagnostics;
1369
+ if (diagnostics) diagnostics[3]++;
1280
1370
  return proxy;
1281
1371
  }
1282
1372
  /**
@@ -1405,6 +1495,8 @@ var RefImpl = class {
1405
1495
  this.dep = new Dep();
1406
1496
  this[_ReactiveFlags$IS_REF] = true;
1407
1497
  this[_ReactiveFlags$IS_SHA] = false;
1498
+ const diagnostics = activeRuntimeDiagnostics;
1499
+ if (diagnostics) diagnostics[6]++;
1408
1500
  this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
1409
1501
  this._value = isShallow ? value : toReactive(value);
1410
1502
  this["__v_isShallow"] = isShallow;
@@ -1464,6 +1556,9 @@ function state(value) {
1464
1556
  if (arguments.length === 0) return /* @__PURE__ */ ref();
1465
1557
  return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
1466
1558
  }
1559
+ function shallowState(value) {
1560
+ return arguments.length === 0 ? /* @__PURE__ */ shallowRef() : /* @__PURE__ */ shallowRef(value);
1561
+ }
1467
1562
  function isValueState(value) {
1468
1563
  if (!value || typeof value !== "object") return false;
1469
1564
  const obj = value;
@@ -1681,6 +1776,7 @@ exports.computed = computed;
1681
1776
  exports.createEffect = createEffect;
1682
1777
  exports.createMemo = createMemo;
1683
1778
  exports.createRoot = createRoot;
1779
+ exports.createRuntimeDiagnosticsSession = createRuntimeDiagnosticsSession;
1684
1780
  exports.createSignal = createSignal;
1685
1781
  exports.effect = effect;
1686
1782
  exports.effectScope = effectScope;
@@ -1701,6 +1797,7 @@ exports.reactiveReadArray = reactiveReadArray;
1701
1797
  exports.resetTracking = resetTracking;
1702
1798
  exports.scope = effectScope;
1703
1799
  exports.shallowReadArray = shallowReadArray;
1800
+ exports.shallowState = shallowState;
1704
1801
  exports.state = state;
1705
1802
  exports.stop = stop;
1706
1803
  exports.track = track;