reactronic 0.22.104 → 0.22.105

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.
@@ -9,23 +9,21 @@ export declare class Observable {
9
9
  value: any;
10
10
  observers?: Set<Observer>;
11
11
  get isOperation(): boolean;
12
- get selfSnapshotId(): number | undefined;
12
+ get originSnapshotId(): number | undefined;
13
13
  constructor(value: any);
14
14
  }
15
15
  export declare type StandaloneMode = boolean | 'isolated';
16
16
  export interface Observer {
17
17
  readonly order: number;
18
- readonly observables: Map<Observable, MemberInfo> | undefined;
18
+ readonly observables: Map<Observable, ObservableInfo> | undefined;
19
19
  readonly obsoleteSince: number;
20
20
  hint(nop?: boolean): string;
21
21
  markObsoleteDueTo(observable: Observable, memberName: MemberName, snapshot: AbstractSnapshot, holder: ObjectHolder, outer: string, since: number, reactions: Observer[]): void;
22
22
  runIfNotUpToDate(now: boolean, nothrow: boolean): void;
23
23
  }
24
24
  export declare type MemberName = PropertyKey;
25
- export interface MemberInfo {
26
- readonly holder: ObjectHolder;
27
- readonly snapshot: AbstractSnapshot;
28
- readonly memberName: MemberName;
25
+ export interface ObservableInfo {
26
+ readonly memberHint: string;
29
27
  readonly usageCount: number;
30
28
  }
31
29
  export declare class ObjectRevision {
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "Meta", { enumerable: true, get: function () { re
8
8
  class Observable {
9
9
  constructor(value) { this.value = value; }
10
10
  get isOperation() { return false; }
11
- get selfSnapshotId() { return 0; }
11
+ get originSnapshotId() { return 0; }
12
12
  }
13
13
  exports.Observable = Observable;
14
14
  class ObjectRevision {
@@ -1,7 +1,7 @@
1
1
  import { F } from '../util/Utils';
2
2
  import { MemberOptions } from '../Options';
3
3
  import { Controller } from '../Controller';
4
- import { MemberName, ObjectHolder, Observable, Observer, MemberInfo, AbstractSnapshot } from './Data';
4
+ import { MemberName, ObjectHolder, Observable, Observer, ObservableInfo, AbstractSnapshot } from './Data';
5
5
  import { Transaction } from './Transaction';
6
6
  import { OptionsImpl } from './Hooks';
7
7
  export declare class OperationController extends Controller<any> {
@@ -40,7 +40,7 @@ declare class Operation extends Observable implements Observer {
40
40
  readonly transaction: Transaction;
41
41
  readonly controller: OperationController;
42
42
  readonly snapshot: AbstractSnapshot;
43
- observables: Map<Observable, MemberInfo> | undefined;
43
+ observables: Map<Observable, ObservableInfo> | undefined;
44
44
  options: OptionsImpl;
45
45
  cause: string | undefined;
46
46
  args: any[];
@@ -52,7 +52,7 @@ declare class Operation extends Observable implements Observer {
52
52
  successor: Operation | undefined;
53
53
  constructor(controller: OperationController, snapshot: AbstractSnapshot, prev: Operation | OptionsImpl);
54
54
  get isOperation(): boolean;
55
- get selfSnapshotId(): number;
55
+ get originSnapshotId(): number;
56
56
  hint(): string;
57
57
  get order(): number;
58
58
  get ['#this'](): string;
@@ -216,7 +216,7 @@ class Operation extends Data_1.Observable {
216
216
  this.successor = undefined;
217
217
  }
218
218
  get isOperation() { return true; }
219
- get selfSnapshotId() { return this.snapshot.id; }
219
+ get originSnapshotId() { return this.snapshot.id; }
220
220
  hint() { return `${Snapshot_1.Dump.rev2(this.controller.ownHolder, this.snapshot, this.controller.memberName)}`; }
221
221
  get order() { return this.options.order; }
222
222
  get ['#this']() {
@@ -510,9 +510,9 @@ class Operation extends Data_1.Observable {
510
510
  if (curr instanceof Operation) {
511
511
  if (curr.snapshot === r.snapshot && curr.observables !== undefined) {
512
512
  if (Hooks_1.Hooks.repetitiveUsageWarningThreshold < Number.MAX_SAFE_INTEGER) {
513
- curr.observables.forEach((hint, v) => {
514
- if (hint.usageCount > Hooks_1.Hooks.repetitiveUsageWarningThreshold)
515
- Dbg_1.Dbg.log('', '[!]', `${curr.hint()} uses ${Snapshot_1.Dump.rev2(hint.holder, hint.snapshot, hint.memberName)} ${hint.usageCount} times (consider remembering it in a local variable)`, 0, ' *** WARNING ***');
513
+ curr.observables.forEach((info, v) => {
514
+ if (info.usageCount > Hooks_1.Hooks.repetitiveUsageWarningThreshold)
515
+ Dbg_1.Dbg.log('', '[!]', `${curr.hint()} uses ${info.memberHint} ${info.usageCount} times (consider remembering it in a local variable)`, 0, ' *** WARNING ***');
516
516
  });
517
517
  }
518
518
  if (unsubscribe)
@@ -548,11 +548,11 @@ class Operation extends Data_1.Observable {
548
548
  }
549
549
  unsubscribeFromAllObservables() {
550
550
  var _a;
551
- (_a = this.observables) === null || _a === void 0 ? void 0 : _a.forEach((hint, value) => {
551
+ (_a = this.observables) === null || _a === void 0 ? void 0 : _a.forEach((info, value) => {
552
552
  var _a;
553
553
  value.observers.delete(this);
554
554
  if (Dbg_1.Dbg.isOn && (Dbg_1.Dbg.trace.read || ((_a = this.options.trace) === null || _a === void 0 ? void 0 : _a.read)))
555
- Dbg_1.Dbg.log(Dbg_1.Dbg.trace.transaction && !Snapshot_1.Snapshot.current().sealed ? '║' : ' ', '-', `${this.hint()} is unsubscribed from ${Snapshot_1.Dump.rev2(hint.holder, hint.snapshot, hint.memberName)}`);
555
+ Dbg_1.Dbg.log(Dbg_1.Dbg.trace.transaction && !Snapshot_1.Snapshot.current().sealed ? '║' : ' ', '-', `${this.hint()} is unsubscribed from ${info.memberHint}`);
556
556
  });
557
557
  this.observables = undefined;
558
558
  }
@@ -568,7 +568,7 @@ class Operation extends Data_1.Observable {
568
568
  if (this.observables !== undefined) {
569
569
  if (!observable.observers)
570
570
  observable.observers = new Set();
571
- const info = { holder: h, snapshot: r.snapshot, memberName: m, usageCount: times };
571
+ const info = { memberHint: Snapshot_1.Dump.rev2(h, r.snapshot, m), usageCount: times };
572
572
  observable.observers.add(this);
573
573
  this.observables.set(observable, info);
574
574
  if (Dbg_1.Dbg.isOn && (Dbg_1.Dbg.trace.read || ((_a = this.options.trace) === null || _a === void 0 ? void 0 : _a.read)))
@@ -49,7 +49,7 @@ export declare class Snapshot implements AbstractSnapshot {
49
49
  static _init(): void;
50
50
  }
51
51
  export declare class Dump {
52
- static obj(h: ObjectHolder | undefined, m?: MemberName | undefined, stamp?: number, op?: number, xop?: number, typeless?: boolean): string;
52
+ static obj(h: ObjectHolder | undefined, m?: MemberName | undefined, stamp?: number, snapshotId?: number, originSnapshotId?: number, typeless?: boolean): string;
53
53
  static rev2(h: ObjectHolder, s: AbstractSnapshot, m?: MemberName, value?: Observable): string;
54
54
  static rev(r: ObjectRevision, m?: MemberName): string;
55
55
  static conflicts(conflicts: ObjectRevision[]): string;
@@ -309,19 +309,19 @@ Snapshot.propagateAllChangesThroughSubscriptions = (snapshot) => { };
309
309
  Snapshot.revokeAllSubscriptions = (snapshot) => { };
310
310
  Snapshot.enqueueReactionsToRun = (reactions) => { };
311
311
  class Dump {
312
- static obj(h, m, stamp, op, xop, typeless) {
312
+ static obj(h, m, stamp, snapshotId, originSnapshotId, typeless) {
313
313
  const member = m !== undefined ? `.${m.toString()}` : '';
314
314
  return h === undefined
315
315
  ? `root${member}`
316
- : stamp === undefined ? `${h.hint}${member} #${h.id}` : `${h.hint}${member} #${h.id}t${op}v${stamp}${xop !== undefined && xop !== 0 ? `t${xop}` : ''}`;
316
+ : stamp === undefined ? `${h.hint}${member} #${h.id}` : `${h.hint}${member} #${h.id}t${snapshotId}v${stamp}${originSnapshotId !== undefined && originSnapshotId !== 0 ? `t${originSnapshotId}` : ''}`;
317
317
  }
318
318
  static rev2(h, s, m, value) {
319
- return Dump.obj(h, m, s.timestamp, s.id, value === null || value === void 0 ? void 0 : value.selfSnapshotId);
319
+ return Dump.obj(h, m, s.timestamp, s.id, value === null || value === void 0 ? void 0 : value.originSnapshotId);
320
320
  }
321
321
  static rev(r, m) {
322
322
  const h = Data_1.Meta.get(r.data, Data_1.Meta.Holder);
323
323
  const value = m !== undefined ? r.data[m] : undefined;
324
- return Dump.obj(h, m, r.snapshot.timestamp, r.snapshot.id, value === null || value === void 0 ? void 0 : value.selfSnapshotId);
324
+ return Dump.obj(h, m, r.snapshot.timestamp, r.snapshot.id, value === null || value === void 0 ? void 0 : value.originSnapshotId);
325
325
  }
326
326
  static conflicts(conflicts) {
327
327
  return conflicts.map(ours => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.22.104",
3
+ "version": "0.22.105",
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",
@@ -29,12 +29,12 @@
29
29
  },
30
30
  "homepage": "https://github.com/nezaboodka/reactronic/blob/master/README.md#readme",
31
31
  "devDependencies": {
32
- "@types/node": "17.0.0",
33
- "@types/react": "17.0.37",
34
- "@typescript-eslint/eslint-plugin": "5.7.0",
35
- "@typescript-eslint/parser": "5.7.0",
32
+ "@types/node": "17.0.7",
33
+ "@types/react": "17.0.38",
34
+ "@typescript-eslint/eslint-plugin": "5.9.0",
35
+ "@typescript-eslint/parser": "5.9.0",
36
36
  "ava": "3.15.0",
37
- "eslint": "8.4.1",
37
+ "eslint": "8.6.0",
38
38
  "nyc": "15.1.0",
39
39
  "react": "17.0.2",
40
40
  "ts-node": "10.4.0",