reactronic 0.22.312 → 0.22.313

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.
@@ -91,6 +91,7 @@ export declare class Hooks implements ProxyHandler<ObjectHandle> {
91
91
  static setProfilingMode(isOn: boolean, options?: Partial<ProfilingOptions>): void;
92
92
  static sensitive<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
93
93
  static setHint<T>(obj: T, hint: string | undefined): T;
94
+ static getHint<T>(obj: T): string;
94
95
  static createOperation: (h: ObjectHandle, m: MemberName, options: OptionsImpl) => F<any>;
95
96
  static rememberOperationOptions: (proto: any, m: MemberName, getter: Function | undefined, setter: Function | undefined, enumerable: boolean, configurable: boolean, options: Partial<MemberOptions>, implicit: boolean) => OptionsImpl;
96
97
  }
@@ -282,6 +282,10 @@ export class Hooks {
282
282
  }
283
283
  return obj;
284
284
  }
285
+ static getHint(obj) {
286
+ const h = Hooks.acquireHandle(obj);
287
+ return h.hint;
288
+ }
285
289
  }
286
290
  Hooks.reactionsAutoStartDisabled = false;
287
291
  Hooks.repetitiveUsageWarningThreshold = Number.MAX_SAFE_INTEGER;
@@ -12,7 +12,7 @@ export declare class MonitorImpl extends Monitor {
12
12
  counter: number;
13
13
  workers: Set<Worker>;
14
14
  duration: number;
15
- internals: {
15
+ readonly internals: {
16
16
  started: number;
17
17
  activationDelay: number;
18
18
  activationTimeout: undefined;
@@ -51,7 +51,8 @@ export class MonitorImpl extends Monitor {
51
51
  return m;
52
52
  }
53
53
  static activate(mon, delay) {
54
- if (mon.internals.started === 0) {
54
+ const active = mon.counter > 0;
55
+ if (mon.internals.started === 0 && active) {
55
56
  mon.duration = 0;
56
57
  mon.internals.started = performance.now();
57
58
  MonitorImpl.tick(mon);
@@ -60,7 +61,7 @@ export class MonitorImpl extends Monitor {
60
61
  if (mon.internals.activationTimeout === undefined)
61
62
  mon.internals.activationTimeout = setTimeout(() => Transaction.run({ hint: 'Monitor.activate', standalone: 'isolated' }, MonitorImpl.activate, mon, -1), delay);
62
63
  }
63
- else if (mon.counter > 0)
64
+ else if (active)
64
65
  mon.isActive = true;
65
66
  }
66
67
  static deactivate(mon, delay) {
@@ -80,7 +81,7 @@ export class MonitorImpl extends Monitor {
80
81
  }
81
82
  static tick(mon) {
82
83
  if (mon.internals.started !== 0) {
83
- Transaction.run(null, () => {
84
+ Transaction.run(MONITOR_TICK_OPTIONS, () => {
84
85
  const resolution = mon.internals.durationResolution;
85
86
  mon.duration = Math.round(resolution * (performance.now() - mon.internals.started)) / resolution;
86
87
  });
@@ -90,3 +91,6 @@ export class MonitorImpl extends Monitor {
90
91
  }
91
92
  }
92
93
  }
94
+ const MONITOR_TICK_OPTIONS = Object.freeze({
95
+ hint: 'Monitor.tick',
96
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.22.312",
3
+ "version": "0.22.313",
4
4
  "description": "Reactronic - Transactional Reactive State Management",
5
5
  "type": "module",
6
6
  "main": "build/dist/source/api.js",