reactronic 0.21.514 → 0.21.515

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.
@@ -34,8 +34,3 @@ export declare enum Reentrance {
34
34
  OverwritePrevious = -3,
35
35
  RunSideBySide = -4
36
36
  }
37
- export declare enum Sensitivity {
38
- ReactOnFinalDifferenceOnly = 0,
39
- ReactOnFinalAndIntermediateDifference = 1,
40
- ReactEvenOnSameValueAssignment = 2
41
- }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Sensitivity = exports.Reentrance = exports.Kind = exports.TraceLevel = void 0;
3
+ exports.Reentrance = exports.Kind = exports.TraceLevel = void 0;
4
4
  var Trace_1 = require("./Trace");
5
5
  Object.defineProperty(exports, "TraceLevel", { enumerable: true, get: function () { return Trace_1.TraceLevel; } });
6
6
  var Kind;
@@ -19,9 +19,3 @@ var Reentrance;
19
19
  Reentrance[Reentrance["OverwritePrevious"] = -3] = "OverwritePrevious";
20
20
  Reentrance[Reentrance["RunSideBySide"] = -4] = "RunSideBySide";
21
21
  })(Reentrance = exports.Reentrance || (exports.Reentrance = {}));
22
- var Sensitivity;
23
- (function (Sensitivity) {
24
- Sensitivity[Sensitivity["ReactOnFinalDifferenceOnly"] = 0] = "ReactOnFinalDifferenceOnly";
25
- Sensitivity[Sensitivity["ReactOnFinalAndIntermediateDifference"] = 1] = "ReactOnFinalAndIntermediateDifference";
26
- Sensitivity[Sensitivity["ReactEvenOnSameValueAssignment"] = 2] = "ReactEvenOnSameValueAssignment";
27
- })(Sensitivity = exports.Sensitivity || (exports.Sensitivity = {}));
@@ -1,6 +1,6 @@
1
1
  import { F } from './util/Utils';
2
2
  import { Controller } from './Controller';
3
- import { MemberOptions, TraceOptions, ProfilingOptions, Sensitivity } from './Options';
3
+ import { MemberOptions, TraceOptions, ProfilingOptions } from './Options';
4
4
  export declare class Reactronic {
5
5
  static why(brief?: boolean): string;
6
6
  static getController<T>(method: F<T>): Controller<T>;
@@ -19,7 +19,7 @@ export declare class Reactronic {
19
19
  }
20
20
  export declare function nonreactive<T>(func: F<T>, ...args: any[]): T;
21
21
  export declare function standalone<T>(func: F<T>, ...args: any[]): T;
22
- export declare function sensitive<T>(sensitivity: Sensitivity, func: F<T>, ...args: any[]): T;
22
+ export declare function sensitive<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
23
23
  export declare function unobservable(proto: object, prop: PropertyKey): any;
24
24
  export declare function transaction(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
25
25
  export declare function reaction(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
@@ -2,7 +2,7 @@ export { all, sleep } from './util/Utils';
2
2
  export { SealedArray } from './util/SealedArray';
3
3
  export { SealedMap } from './util/SealedMap';
4
4
  export { SealedSet } from './util/SealedSet';
5
- export { MemberOptions, Kind, Reentrance, Sensitivity, TraceOptions, ProfilingOptions, TraceLevel } from './Options';
5
+ export { MemberOptions, Kind, Reentrance, TraceOptions, ProfilingOptions, TraceLevel } from './Options';
6
6
  export { Worker } from './Worker';
7
7
  export { Controller } from './Controller';
8
8
  export { Ref, ToggleRef, BoolOnly, GivenTypeOnly } from './Ref';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.options = exports.cached = exports.reaction = exports.transaction = exports.unobservable = exports.sensitive = exports.standalone = exports.nonreactive = exports.Reactronic = exports.TransactionJournal = exports.Monitor = exports.Transaction = exports.Snapshot = exports.ObservableObject = exports.ToggleRef = exports.Ref = exports.Controller = exports.TraceLevel = exports.Sensitivity = exports.Reentrance = exports.Kind = exports.SealedSet = exports.SealedMap = exports.SealedArray = exports.sleep = exports.all = void 0;
3
+ exports.options = exports.cached = exports.reaction = exports.transaction = exports.unobservable = exports.sensitive = exports.standalone = exports.nonreactive = exports.Reactronic = exports.TransactionJournal = exports.Monitor = exports.Transaction = exports.Snapshot = exports.ObservableObject = exports.ToggleRef = exports.Ref = exports.Controller = exports.TraceLevel = exports.Reentrance = exports.Kind = exports.SealedSet = exports.SealedMap = exports.SealedArray = exports.sleep = exports.all = void 0;
4
4
  var Utils_1 = require("./util/Utils");
5
5
  Object.defineProperty(exports, "all", { enumerable: true, get: function () { return Utils_1.all; } });
6
6
  Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return Utils_1.sleep; } });
@@ -13,7 +13,6 @@ Object.defineProperty(exports, "SealedSet", { enumerable: true, get: function ()
13
13
  var Options_1 = require("./Options");
14
14
  Object.defineProperty(exports, "Kind", { enumerable: true, get: function () { return Options_1.Kind; } });
15
15
  Object.defineProperty(exports, "Reentrance", { enumerable: true, get: function () { return Options_1.Reentrance; } });
16
- Object.defineProperty(exports, "Sensitivity", { enumerable: true, get: function () { return Options_1.Sensitivity; } });
17
16
  Object.defineProperty(exports, "TraceLevel", { enumerable: true, get: function () { return Options_1.TraceLevel; } });
18
17
  var Controller_1 = require("./Controller");
19
18
  Object.defineProperty(exports, "Controller", { enumerable: true, get: function () { return Controller_1.Controller; } });
@@ -1,5 +1,5 @@
1
1
  import { F } from '../util/Utils';
2
- import { MemberOptions, Kind, Reentrance, Sensitivity } from '../Options';
2
+ import { MemberOptions, Kind, Reentrance } from '../Options';
3
3
  import { TraceOptions, ProfilingOptions } from '../Trace';
4
4
  import { MemberName, ObjectHolder } from './Data';
5
5
  import { TransactionJournal } from './TransactionJournal';
@@ -28,7 +28,7 @@ export declare class Hooks implements ProxyHandler<ObjectHolder> {
28
28
  static repetitiveUsageWarningThreshold: number;
29
29
  static mainThreadBlockingWarningThreshold: number;
30
30
  static asyncActionDurationWarningThreshold: number;
31
- static sensitivity: Sensitivity;
31
+ static sensitivity: boolean;
32
32
  static readonly proxy: Hooks;
33
33
  getPrototypeOf(h: ObjectHolder): object | null;
34
34
  get(h: ObjectHolder, m: MemberName, receiver: any): any;
@@ -42,7 +42,7 @@ export declare class Hooks implements ProxyHandler<ObjectHolder> {
42
42
  static acquireObjectHolder(obj: any): ObjectHolder;
43
43
  static createObjectHolder(unobservable: any, blank: any, hint: string): ObjectHolder;
44
44
  static setProfilingMode(enabled: boolean, options?: Partial<ProfilingOptions>): void;
45
- static sensitive<T>(sensitivity: Sensitivity, func: F<T>, ...args: any[]): T;
45
+ static sensitive<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
46
46
  static setHint<T>(obj: T, hint: string | undefined): T;
47
47
  static createControllerAndGetHook: (h: ObjectHolder, m: MemberName, options: OptionsImpl) => F<any>;
48
48
  static rememberOperationOptions: (proto: any, m: MemberName, getter: Function | undefined, setter: Function | undefined, enumerable: boolean, configurable: boolean, options: Partial<MemberOptions>, implicit: boolean) => OptionsImpl;
@@ -78,24 +78,16 @@ class Hooks {
78
78
  set(h, m, value, receiver) {
79
79
  const r = Snapshot_1.Snapshot.edit().getEditableRevision(h, m, value);
80
80
  if (r !== Snapshot_1.ROOT_REV) {
81
- const curr = r.data[m];
81
+ let curr = r.data[m];
82
82
  if (curr !== undefined || (r.prev.revision.snapshot === Snapshot_1.ROOT_REV.snapshot && m in h.unobservable === false)) {
83
- const prev = r.prev.revision.data[m];
84
- let edited = prev === undefined || prev.value !== value ||
85
- Hooks.sensitivity === Options_1.Sensitivity.ReactEvenOnSameValueAssignment;
86
- if (edited) {
87
- if (prev === curr)
88
- r.data[m] = new Data_1.Observable(value);
89
- else
90
- curr.value = value;
83
+ if (curr === undefined || r.prev.revision.data[m] === curr) {
84
+ curr = r.data[m] = new Data_1.Observable(value);
85
+ Snapshot_1.Snapshot.markEdited(value, true, r, m, h);
91
86
  }
92
- else if (prev !== curr) {
93
- if (Hooks.sensitivity === Options_1.Sensitivity.ReactOnFinalDifferenceOnly)
94
- r.data[m] = prev;
95
- else
96
- edited = true;
87
+ else if (curr.value !== value || Hooks.sensitivity) {
88
+ curr.value = value;
89
+ Snapshot_1.Snapshot.markEdited(value, true, r, m, h);
97
90
  }
98
- Snapshot_1.Snapshot.markEdited(value, edited, r, m, h);
99
91
  }
100
92
  else
101
93
  Reflect.set(h.unobservable, m, value, receiver);
@@ -233,7 +225,7 @@ Hooks.reactionsAutoStartDisabled = false;
233
225
  Hooks.repetitiveUsageWarningThreshold = Number.MAX_SAFE_INTEGER;
234
226
  Hooks.mainThreadBlockingWarningThreshold = Number.MAX_SAFE_INTEGER;
235
227
  Hooks.asyncActionDurationWarningThreshold = Number.MAX_SAFE_INTEGER;
236
- Hooks.sensitivity = Options_1.Sensitivity.ReactOnFinalDifferenceOnly;
228
+ Hooks.sensitivity = false;
237
229
  Hooks.proxy = new Hooks();
238
230
  Hooks.createControllerAndGetHook = function (h, m, options) {
239
231
  throw (0, Dbg_1.misuse)('createControllerAndGetHook should never be called');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.21.514",
3
+ "version": "0.21.515",
4
4
  "description": "Reactronic - Transactional Reactive State Management",
5
5
  "main": "build/dist/source/api.js",
6
6
  "types": "build/dist/source/api.d.ts",