reactronic 0.22.210 → 0.22.300

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.
@@ -1,14 +1,14 @@
1
- import { ObservableObject } from './Hooks';
2
- import { ObjectHolder, ObjectRevision, Patch } from './Data';
3
- export declare type Saver = (patch: Patch) => Promise<void>;
4
- export declare abstract class Journal extends ObservableObject {
1
+ import { SubscribingObject } from './Hooks';
2
+ import { DataHolder, DataRevision, PatchSet } from './Data';
3
+ export declare type Saver = (patch: PatchSet) => Promise<void>;
4
+ export declare abstract class Journal extends SubscribingObject {
5
5
  abstract capacity: number;
6
- abstract readonly edits: ReadonlyArray<Patch>;
7
- abstract readonly unsaved: Patch;
6
+ abstract readonly edits: ReadonlyArray<PatchSet>;
7
+ abstract readonly unsaved: PatchSet;
8
8
  abstract readonly canUndo: boolean;
9
9
  abstract readonly canRedo: boolean;
10
- abstract edited(patch: Patch): void;
11
- abstract saved(patch: Patch): void;
10
+ abstract edited(patch: PatchSet): void;
11
+ abstract saved(patch: PatchSet): void;
12
12
  abstract undo(count?: number): void;
13
13
  abstract redo(count?: number): void;
14
14
  static create(): Journal;
@@ -20,15 +20,15 @@ export declare class JournalImpl extends Journal {
20
20
  private _position;
21
21
  get capacity(): number;
22
22
  set capacity(value: number);
23
- get edits(): ReadonlyArray<Patch>;
24
- get unsaved(): Patch;
23
+ get edits(): ReadonlyArray<PatchSet>;
24
+ get unsaved(): PatchSet;
25
25
  get canUndo(): boolean;
26
26
  get canRedo(): boolean;
27
- edited(p: Patch): void;
28
- saved(patch: Patch): void;
27
+ edited(p: PatchSet): void;
28
+ saved(patch: PatchSet): void;
29
29
  undo(count?: number): void;
30
30
  redo(count?: number): void;
31
- static buildPatch(hint: string, changeset: Map<ObjectHolder, ObjectRevision>): Patch;
32
- static applyPatch(patch: Patch, undoing: boolean): void;
33
- mergePatchToUnsaved(patch: Patch, undoing: boolean): void;
31
+ static buildPatch(hint: string, changeset: Map<DataHolder, DataRevision>): PatchSet;
32
+ static applyPatch(patch: PatchSet, undoing: boolean): void;
33
+ mergePatchToUnsaved(patch: PatchSet, undoing: boolean): void;
34
34
  }
@@ -6,7 +6,7 @@ const Data_1 = require("./Data");
6
6
  const Snapshot_1 = require("./Snapshot");
7
7
  const Transaction_1 = require("./Transaction");
8
8
  const Sealant_1 = require("../util/Sealant");
9
- class Journal extends Hooks_1.ObservableObject {
9
+ class Journal extends Hooks_1.SubscribingObject {
10
10
  static create() { return new JournalImpl(); }
11
11
  }
12
12
  exports.Journal = Journal;
@@ -87,17 +87,17 @@ class JournalImpl extends Journal {
87
87
  }
88
88
  static applyPatch(patch, undoing) {
89
89
  const ctx = Snapshot_1.Snapshot.edit();
90
- patch.objects.forEach((op, obj) => {
90
+ patch.objects.forEach((dp, obj) => {
91
91
  const h = Data_1.Meta.get(obj, Data_1.Meta.Holder);
92
- const data = undoing ? op.former : op.data;
92
+ const data = undoing ? dp.former : dp.data;
93
93
  if (data[Data_1.Meta.Disposed] === undefined) {
94
94
  for (const m in data) {
95
95
  const value = data[m];
96
96
  const r = ctx.getEditableRevision(h, m, value);
97
97
  if (r.snapshot === ctx) {
98
- r.data[m] = new Data_1.Observable(value);
99
- const v = r.former.revision.data[m];
100
- Snapshot_1.Snapshot.markEdited(v, value, v !== value, r, m, h);
98
+ r.data[m] = new Data_1.Subscription(value);
99
+ const existing = r.former.revision.data[m];
100
+ Snapshot_1.Snapshot.markEdited(existing, value, existing !== value, r, m, h);
101
101
  }
102
102
  }
103
103
  }
@@ -107,12 +107,12 @@ class JournalImpl extends Journal {
107
107
  }
108
108
  mergePatchToUnsaved(patch, undoing) {
109
109
  const unsaved = this._unsaved;
110
- patch.objects.forEach((op, obj) => {
110
+ patch.objects.forEach((dp, obj) => {
111
111
  let merged = unsaved.objects.get(obj);
112
112
  if (!merged)
113
113
  unsaved.objects.set(obj, merged = { data: {}, former: {} });
114
- const data = undoing ? op.former : op.data;
115
- const former = undoing ? op.data : op.former;
114
+ const data = undoing ? dp.former : dp.data;
115
+ const former = undoing ? dp.data : dp.former;
116
116
  for (const m in data) {
117
117
  const value = data[m];
118
118
  if (value !== merged.former[m]) {
@@ -131,8 +131,8 @@ class JournalImpl extends Journal {
131
131
  }
132
132
  }
133
133
  exports.JournalImpl = JournalImpl;
134
- function unseal(observable) {
135
- const result = observable.value;
134
+ function unseal(subscription) {
135
+ const result = subscription.content;
136
136
  const createCopy = result === null || result === void 0 ? void 0 : result[Sealant_1.Sealant.CreateCopy];
137
137
  return createCopy !== undefined ? createCopy.call(result) : result;
138
138
  }
@@ -4,7 +4,7 @@ export declare abstract class Meta {
4
4
  static readonly Disposed: unique symbol;
5
5
  static readonly Initial: unique symbol;
6
6
  static readonly Reactions: unique symbol;
7
- static readonly Unobservable: unique symbol;
7
+ static readonly Nonsubscribing: unique symbol;
8
8
  static readonly Undefined: unique symbol;
9
9
  static get<T>(obj: any, sym: symbol): T;
10
10
  static set(obj: any, sym: symbol, value: any): any;
@@ -29,5 +29,5 @@ Meta.Controller = Symbol('rxController');
29
29
  Meta.Disposed = Symbol('rxDisposed');
30
30
  Meta.Initial = Symbol('rxInitial');
31
31
  Meta.Reactions = Symbol('rxReactions');
32
- Meta.Unobservable = Symbol('rxUnobservable');
32
+ Meta.Nonsubscribing = Symbol('rxNonsubscribing');
33
33
  Meta.Undefined = Symbol('rxUndefined');
@@ -1,6 +1,6 @@
1
1
  import { Worker } from '../Worker';
2
- import { ObservableObject } from './Hooks';
3
- export declare abstract class Monitor extends ObservableObject {
2
+ import { SubscribingObject } from './Hooks';
3
+ export declare abstract class Monitor extends SubscribingObject {
4
4
  abstract readonly isActive: boolean;
5
5
  abstract readonly counter: number;
6
6
  abstract readonly workers: ReadonlySet<Worker>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MonitorImpl = exports.Monitor = void 0;
4
4
  const Hooks_1 = require("./Hooks");
5
5
  const Transaction_1 = require("./Transaction");
6
- class Monitor extends Hooks_1.ObservableObject {
6
+ class Monitor extends Hooks_1.SubscribingObject {
7
7
  static create(hint, activationDelay, deactivationDelay, durationResolution) {
8
8
  return MonitorImpl.create(hint, activationDelay, deactivationDelay, durationResolution);
9
9
  }
@@ -1,15 +1,15 @@
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, ObservableInfo, AbstractSnapshot } from './Data';
4
+ import { MemberName, DataHolder, Subscription, Subscriber, SubscriptionInfo, AbstractSnapshot } from './Data';
5
5
  import { Transaction } from './Transaction';
6
6
  import { OptionsImpl } from './Hooks';
7
7
  export declare class OperationController extends Controller<any> {
8
- readonly ownHolder: ObjectHolder;
8
+ readonly ownHolder: DataHolder;
9
9
  readonly memberName: MemberName;
10
10
  configure(options: Partial<MemberOptions>): MemberOptions;
11
11
  get options(): MemberOptions;
12
- get nonreactive(): any;
12
+ get nonsubscribing(): any;
13
13
  get args(): ReadonlyArray<any>;
14
14
  get result(): any;
15
15
  get error(): boolean;
@@ -17,7 +17,7 @@ export declare class OperationController extends Controller<any> {
17
17
  get isUpToDate(): boolean;
18
18
  markObsolete(): void;
19
19
  pullLastResult(args?: any[]): any;
20
- constructor(ownHolder: ObjectHolder, memberName: MemberName);
20
+ constructor(ownHolder: DataHolder, memberName: MemberName);
21
21
  useOrRun(weak: boolean, args: any[] | undefined): Operation;
22
22
  static of(method: F<any>): Controller<any>;
23
23
  static configureImpl(self: OperationController | undefined, options: Partial<MemberOptions>): MemberOptions;
@@ -32,15 +32,15 @@ export declare class OperationController extends Controller<any> {
32
32
  private run;
33
33
  private static markObsolete;
34
34
  }
35
- declare class Operation extends Observable implements Observer {
35
+ declare class Operation extends Subscription implements Subscriber {
36
36
  static current?: Operation;
37
- static queuedReactions: Array<Observer>;
37
+ static queuedReactions: Array<Subscriber>;
38
38
  static deferredReactions: Array<Operation>;
39
39
  readonly margin: number;
40
40
  readonly transaction: Transaction;
41
41
  readonly controller: OperationController;
42
42
  readonly snapshot: AbstractSnapshot;
43
- observables: Map<Observable, ObservableInfo> | undefined;
43
+ subscriptions: Map<Subscription, SubscriptionInfo> | undefined;
44
44
  options: OptionsImpl;
45
45
  cause: string | undefined;
46
46
  args: any[];
@@ -61,7 +61,7 @@ declare class Operation extends Observable implements Observer {
61
61
  dependencies(): string[];
62
62
  wrap<T>(func: F<T>): F<T>;
63
63
  run(proxy: any, args: any[] | undefined): void;
64
- markObsoleteDueTo(observable: Observable, memberName: MemberName, snapshot: AbstractSnapshot, holder: ObjectHolder, outer: string, since: number, reactions: Observer[]): void;
64
+ markObsoleteDueTo(subscription: Subscription, memberName: MemberName, snapshot: AbstractSnapshot, holder: DataHolder, outer: string, since: number, reactions: Subscriber[]): void;
65
65
  runIfNotUpToDate(now: boolean, nothrow: boolean): void;
66
66
  isNotUpToDate(): boolean;
67
67
  reenterOver(head: Operation): this;
@@ -81,7 +81,7 @@ declare class Operation extends Observable implements Observer {
81
81
  private static propagateMemberChangeThroughSubscriptions;
82
82
  private static enqueueReactionsToRun;
83
83
  private static runQueuedReactionsLoop;
84
- private unsubscribeFromAllObservables;
84
+ private unsubscribeFromAllSubscriptions;
85
85
  private subscribeTo;
86
86
  private static canSubscribe;
87
87
  private static createOperation;
@@ -12,7 +12,7 @@ const Hooks_1 = require("./Hooks");
12
12
  const Journal_1 = require("./Journal");
13
13
  const BOOT_ARGS = [];
14
14
  const BOOT_CAUSE = '<boot>';
15
- const ROOT_HOLDER = new Data_1.ObjectHolder(undefined, undefined, Hooks_1.Hooks.proxy, Snapshot_1.ROOT_REV, '<root>');
15
+ const ROOT_HOLDER = new Data_1.DataHolder(undefined, undefined, Hooks_1.Hooks.proxy, Snapshot_1.ROOT_REV, '<root>');
16
16
  class OperationController extends Controller_1.Controller {
17
17
  constructor(ownHolder, memberName) {
18
18
  super();
@@ -21,14 +21,14 @@ class OperationController extends Controller_1.Controller {
21
21
  }
22
22
  configure(options) { return OperationController.configureImpl(this, options); }
23
23
  get options() { return this.peek(undefined).operation.options; }
24
- get nonreactive() { return this.peek(undefined).operation.value; }
24
+ get nonsubscribing() { return this.peek(undefined).operation.content; }
25
25
  get args() { return this.use().operation.args; }
26
- get result() { return this.useOrRun(true, undefined).value; }
26
+ get result() { return this.useOrRun(true, undefined).content; }
27
27
  get error() { return this.use().operation.error; }
28
28
  get stamp() { return this.use().revision.snapshot.timestamp; }
29
29
  get isUpToDate() { return this.use().isUpToDate; }
30
30
  markObsolete() { Transaction_1.Transaction.run({ hint: Dbg_1.Log.isOn ? `markObsolete(${Snapshot_1.Dump.obj(this.ownHolder, this.memberName)})` : 'markObsolete()' }, OperationController.markObsolete, this); }
31
- pullLastResult(args) { return this.useOrRun(true, args).value; }
31
+ pullLastResult(args) { return this.useOrRun(true, args).content; }
32
32
  useOrRun(weak, args) {
33
33
  var _a;
34
34
  let oc = this.peek(args);
@@ -204,14 +204,14 @@ class OperationController extends Controller_1.Controller {
204
204
  }
205
205
  }
206
206
  exports.OperationController = OperationController;
207
- class Operation extends Data_1.Observable {
207
+ class Operation extends Data_1.Subscription {
208
208
  constructor(controller, snapshot, former) {
209
209
  super(undefined);
210
210
  this.margin = Operation.current ? Operation.current.margin + 1 : 1;
211
211
  this.transaction = Transaction_1.Transaction.current;
212
212
  this.controller = controller;
213
213
  this.snapshot = snapshot;
214
- this.observables = new Map();
214
+ this.subscriptions = new Map();
215
215
  if (former instanceof Operation) {
216
216
  this.options = former.options;
217
217
  this.args = former.args;
@@ -274,14 +274,14 @@ class Operation extends Data_1.Observable {
274
274
  else
275
275
  this.result = Promise.reject(this.error);
276
276
  }
277
- markObsoleteDueTo(observable, memberName, snapshot, holder, outer, since, reactions) {
277
+ markObsoleteDueTo(subscription, memberName, snapshot, holder, outer, since, reactions) {
278
278
  var _a, _b, _c;
279
- if (this.observables !== undefined) {
280
- const skip = !observable.isOperation &&
279
+ if (this.subscriptions !== undefined) {
280
+ const skip = !subscription.isOperation &&
281
281
  snapshot === this.snapshot;
282
282
  if (!skip) {
283
- const why = `${Snapshot_1.Dump.rev2(holder, snapshot, memberName, observable)} << ${outer}`;
284
- this.unsubscribeFromAllObservables();
283
+ const why = `${Snapshot_1.Dump.rev2(holder, snapshot, memberName, subscription)} << ${outer}`;
284
+ this.unsubscribeFromAllSubscriptions();
285
285
  this.obsoleteDueTo = why;
286
286
  this.obsoleteSince = since;
287
287
  const isReaction = this.options.kind === Options_1.Kind.Reaction;
@@ -292,11 +292,11 @@ class Operation extends Data_1.Observable {
292
292
  if (isReaction)
293
293
  reactions.push(this);
294
294
  else
295
- (_b = this.observers) === null || _b === void 0 ? void 0 : _b.forEach(c => c.markObsoleteDueTo(this, this.controller.memberName, this.snapshot, this.controller.ownHolder, why, since, reactions));
295
+ (_b = this.subscribers) === null || _b === void 0 ? void 0 : _b.forEach(s => s.markObsoleteDueTo(this, this.controller.memberName, this.snapshot, this.controller.ownHolder, why, since, reactions));
296
296
  const tran = this.transaction;
297
297
  if (tran.snapshot === snapshot) {
298
298
  }
299
- else if (!tran.isFinished && this !== observable)
299
+ else if (!tran.isFinished && this !== subscription)
300
300
  tran.cancel(new Error(`T${tran.id}[${tran.hint}] is canceled due to obsolete ${Snapshot_1.Dump.rev2(holder, snapshot, memberName)} changed by T${snapshot.id}[${snapshot.hint}]`), null);
301
301
  }
302
302
  else if (Dbg_1.Log.isOn && (Dbg_1.Log.opt.obsolete || ((_c = this.options.logging) === null || _c === void 0 ? void 0 : _c.obsolete)))
@@ -390,7 +390,7 @@ class Operation extends Data_1.Observable {
390
390
  leaveOrAsync() {
391
391
  if (this.result instanceof Promise) {
392
392
  this.result = this.result.then(value => {
393
- this.value = value;
393
+ this.content = value;
394
394
  this.leave(false, ' ⚐', '- finished ', ' OK ──┘');
395
395
  return value;
396
396
  }, error => {
@@ -406,7 +406,7 @@ class Operation extends Data_1.Observable {
406
406
  }
407
407
  }
408
408
  else {
409
- this.value = this.result;
409
+ this.content = this.result;
410
410
  this.leave(true, '_/', '- leave');
411
411
  }
412
412
  }
@@ -453,7 +453,7 @@ class Operation extends Data_1.Observable {
453
453
  for (const x of reactions)
454
454
  x.runIfNotUpToDate(true, true);
455
455
  }
456
- static markUsed(observable, r, m, h, kind, weak) {
456
+ static markUsed(subscription, r, m, h, kind, weak) {
457
457
  if (kind !== Options_1.Kind.Transaction) {
458
458
  const op = Operation.current;
459
459
  if (op && op.options.kind !== Options_1.Kind.Transaction &&
@@ -462,8 +462,8 @@ class Operation extends Data_1.Observable {
462
462
  if (ctx !== r.snapshot)
463
463
  ctx.bumpBy(r.snapshot.timestamp);
464
464
  const t = weak ? -1 : ctx.timestamp;
465
- if (!op.subscribeTo(observable, r, m, h, t))
466
- op.markObsoleteDueTo(observable, m, r.snapshot, h, BOOT_CAUSE, ctx.timestamp, ctx.reactions);
465
+ if (!op.subscribeTo(subscription, r, m, h, t))
466
+ op.markObsoleteDueTo(subscription, m, r.snapshot, h, BOOT_CAUSE, ctx.timestamp, ctx.reactions);
467
467
  }
468
468
  }
469
469
  }
@@ -500,13 +500,13 @@ class Operation extends Data_1.Observable {
500
500
  const curr = r.data[m];
501
501
  if (reactions) {
502
502
  const former = r.former.revision.data[m];
503
- if (former !== undefined && former instanceof Data_1.Observable) {
503
+ if (former !== undefined && former instanceof Data_1.Subscription) {
504
504
  const why = `T${r.snapshot.id}[${r.snapshot.hint}]`;
505
505
  if (former instanceof Operation) {
506
506
  if ((former.obsoleteSince === Snapshot_1.MAX_TIMESTAMP || former.obsoleteSince <= 0)) {
507
507
  former.obsoleteDueTo = why;
508
508
  former.obsoleteSince = timestamp;
509
- former.unsubscribeFromAllObservables();
509
+ former.unsubscribeFromAllSubscriptions();
510
510
  }
511
511
  const formerSuccessor = former.successor;
512
512
  if (formerSuccessor !== curr) {
@@ -516,22 +516,22 @@ class Operation extends Data_1.Observable {
516
516
  else
517
517
  former.successor = undefined;
518
518
  }
519
- (_a = former.observers) === null || _a === void 0 ? void 0 : _a.forEach(c => c.markObsoleteDueTo(former, m, r.snapshot, h, why, timestamp, reactions));
519
+ (_a = former.subscribers) === null || _a === void 0 ? void 0 : _a.forEach(s => s.markObsoleteDueTo(former, m, r.snapshot, h, why, timestamp, reactions));
520
520
  }
521
521
  }
522
522
  if (curr instanceof Operation) {
523
- if (curr.snapshot === r.snapshot && curr.observables !== undefined) {
523
+ if (curr.snapshot === r.snapshot && curr.subscriptions !== undefined) {
524
524
  if (Hooks_1.Hooks.repetitiveUsageWarningThreshold < Number.MAX_SAFE_INTEGER) {
525
- curr.observables.forEach((info, v) => {
525
+ curr.subscriptions.forEach((info, v) => {
526
526
  if (info.usageCount > Hooks_1.Hooks.repetitiveUsageWarningThreshold)
527
527
  Dbg_1.Log.write('', '[!]', `${curr.hint()} uses ${info.memberHint} ${info.usageCount} times (consider remembering it in a local variable)`, 0, ' *** WARNING ***');
528
528
  });
529
529
  }
530
530
  if (unsubscribe)
531
- curr.unsubscribeFromAllObservables();
531
+ curr.unsubscribeFromAllSubscriptions();
532
532
  }
533
533
  }
534
- else if (curr instanceof Data_1.Observable && curr.observers) {
534
+ else if (curr instanceof Data_1.Subscription && curr.subscribers) {
535
535
  }
536
536
  }
537
537
  static enqueueReactionsToRun(reactions) {
@@ -552,31 +552,31 @@ class Operation extends Data_1.Observable {
552
552
  }
553
553
  Operation.queuedReactions = [];
554
554
  }
555
- unsubscribeFromAllObservables() {
555
+ unsubscribeFromAllSubscriptions() {
556
556
  var _a;
557
- (_a = this.observables) === null || _a === void 0 ? void 0 : _a.forEach((info, value) => {
557
+ (_a = this.subscriptions) === null || _a === void 0 ? void 0 : _a.forEach((info, value) => {
558
558
  var _a;
559
- value.observers.delete(this);
559
+ value.subscribers.delete(this);
560
560
  if (Dbg_1.Log.isOn && (Dbg_1.Log.opt.read || ((_a = this.options.logging) === null || _a === void 0 ? void 0 : _a.read)))
561
561
  Dbg_1.Log.write(Dbg_1.Log.opt.transaction && !Snapshot_1.Snapshot.current().sealed ? '║' : ' ', '-', `${this.hint()} is unsubscribed from ${info.memberHint}`);
562
562
  });
563
- this.observables = undefined;
563
+ this.subscriptions = undefined;
564
564
  }
565
- subscribeTo(observable, r, m, h, timestamp) {
565
+ subscribeTo(subscription, r, m, h, timestamp) {
566
566
  var _a, _b, _c;
567
- const ok = Operation.canSubscribe(observable, r, m, h, timestamp);
567
+ const ok = Operation.canSubscribe(subscription, r, m, h, timestamp);
568
568
  if (ok) {
569
569
  let times = 0;
570
570
  if (Hooks_1.Hooks.repetitiveUsageWarningThreshold < Number.MAX_SAFE_INTEGER) {
571
- const existing = this.observables.get(observable);
571
+ const existing = this.subscriptions.get(subscription);
572
572
  times = existing ? existing.usageCount + 1 : 1;
573
573
  }
574
- if (this.observables !== undefined) {
575
- if (!observable.observers)
576
- observable.observers = new Set();
574
+ if (this.subscriptions !== undefined) {
575
+ if (!subscription.subscribers)
576
+ subscription.subscribers = new Set();
577
577
  const info = { memberHint: Snapshot_1.Dump.rev2(h, r.snapshot, m), usageCount: times };
578
- observable.observers.add(this);
579
- this.observables.set(observable, info);
578
+ subscription.subscribers.add(this);
579
+ this.subscriptions.set(subscription, info);
580
580
  if (Dbg_1.Log.isOn && (Dbg_1.Log.opt.read || ((_a = this.options.logging) === null || _a === void 0 ? void 0 : _a.read)))
581
581
  Dbg_1.Log.write('║', ' ∞ ', `${this.hint()} is subscribed to ${Snapshot_1.Dump.rev2(h, r.snapshot, m)}${info.usageCount > 1 ? ` (${info.usageCount} times)` : ''}`);
582
582
  }
@@ -589,10 +589,10 @@ class Operation extends Data_1.Observable {
589
589
  }
590
590
  return ok;
591
591
  }
592
- static canSubscribe(observable, r, m, h, timestamp) {
593
- let result = !r.snapshot.sealed || observable === h.head.data[m];
592
+ static canSubscribe(subscription, r, m, h, timestamp) {
593
+ let result = !r.snapshot.sealed || subscription === h.head.data[m];
594
594
  if (result && timestamp !== -1)
595
- result = !(observable instanceof Operation && timestamp >= observable.obsoleteSince);
595
+ result = !(subscription instanceof Operation && timestamp >= subscription.obsoleteSince);
596
596
  return result;
597
597
  }
598
598
  static createOperation(h, m, options) {
@@ -1,5 +1,5 @@
1
1
  import { Kind, SnapshotOptions } from '../Options';
2
- import { AbstractSnapshot, ObjectRevision, MemberName, ObjectHolder, Observable, Observer } from './Data';
2
+ import { AbstractSnapshot, DataRevision, MemberName, DataHolder, Subscription, Subscriber } from './Data';
3
3
  export declare const MAX_TIMESTAMP: number;
4
4
  export declare const UNDEFINED_TIMESTAMP: number;
5
5
  export declare class Snapshot implements AbstractSnapshot {
@@ -9,52 +9,52 @@ export declare class Snapshot implements AbstractSnapshot {
9
9
  private static oldest;
10
10
  static garbageCollectionSummaryInterval: number;
11
11
  static lastGarbageCollectionSummaryTimestamp: number;
12
- static totalObjectHolderCount: number;
13
- static totalObjectRevisionCount: number;
12
+ static totalHolderCount: number;
13
+ static totalRevisionCount: number;
14
14
  readonly id: number;
15
15
  readonly options: SnapshotOptions;
16
16
  get hint(): string;
17
17
  get timestamp(): number;
18
18
  private stamp;
19
19
  private bumper;
20
- changeset: Map<ObjectHolder, ObjectRevision>;
21
- reactions: Observer[];
20
+ changeset: Map<DataHolder, DataRevision>;
21
+ reactions: Subscriber[];
22
22
  sealed: boolean;
23
23
  constructor(options: SnapshotOptions | null);
24
24
  static current: () => Snapshot;
25
25
  static edit: () => Snapshot;
26
- static markUsed: (observable: Observable, r: ObjectRevision, m: MemberName, h: ObjectHolder, kind: Kind, weak: boolean) => void;
27
- static markEdited: (oldValue: any, newValue: any, edited: boolean, r: ObjectRevision, m: MemberName, h: ObjectHolder) => void;
26
+ static markUsed: (subscription: Subscription, r: DataRevision, m: MemberName, h: DataHolder, kind: Kind, weak: boolean) => void;
27
+ static markEdited: (oldValue: any, newValue: any, edited: boolean, r: DataRevision, m: MemberName, h: DataHolder) => void;
28
28
  static isConflicting: (oldValue: any, newValue: any) => boolean;
29
29
  static propagateAllChangesThroughSubscriptions: (snapshot: Snapshot) => void;
30
30
  static revokeAllSubscriptions: (snapshot: Snapshot) => void;
31
- static enqueueReactionsToRun: (reactions: Array<Observer>) => void;
32
- seekRevision(h: ObjectHolder, m: MemberName): ObjectRevision;
33
- getCurrentRevision(h: ObjectHolder, m: MemberName): ObjectRevision;
34
- getEditableRevision(h: ObjectHolder, m: MemberName, value: any, token?: any): ObjectRevision;
31
+ static enqueueReactionsToRun: (reactions: Array<Subscriber>) => void;
32
+ seekRevision(h: DataHolder, m: MemberName): DataRevision;
33
+ getCurrentRevision(h: DataHolder, m: MemberName): DataRevision;
34
+ getEditableRevision(h: DataHolder, m: MemberName, value: any, token?: any): DataRevision;
35
35
  static takeSnapshot<T>(obj: T): T;
36
36
  static dispose(obj: any): void;
37
- static doDispose(ctx: Snapshot, h: ObjectHolder): ObjectRevision;
37
+ static doDispose(ctx: Snapshot, h: DataHolder): DataRevision;
38
38
  private isNewRevisionRequired;
39
39
  acquire(outer: Snapshot): void;
40
40
  bumpBy(timestamp: number): void;
41
- rebase(): ObjectRevision[] | undefined;
41
+ rebase(): DataRevision[] | undefined;
42
42
  private merge;
43
- applyOrDiscard(error?: any): Array<Observer>;
44
- static sealObjectRevision(h: ObjectHolder, r: ObjectRevision): void;
45
- static sealObservable(observable: Observable | symbol, m: MemberName, typeName: string): void;
46
- static freezeObjectRevision(r: ObjectRevision): ObjectRevision;
43
+ applyOrDiscard(error?: any): Array<Subscriber>;
44
+ static sealObjectRevision(h: DataHolder, r: DataRevision): void;
45
+ static sealSubscription(subscription: Subscription | symbol, m: MemberName, typeName: string): void;
46
+ static freezeObjectRevision(r: DataRevision): DataRevision;
47
47
  triggerGarbageCollection(): void;
48
48
  private unlinkHistory;
49
49
  static _init(): void;
50
50
  }
51
51
  export declare class Dump {
52
52
  static valueHint: (value: any, m?: PropertyKey | undefined) => string;
53
- static obj(h: ObjectHolder | undefined, m?: MemberName | undefined, stamp?: number, snapshotId?: number, originSnapshotId?: number, value?: any): string;
54
- static rev2(h: ObjectHolder, s: AbstractSnapshot, m?: MemberName, o?: Observable): string;
55
- static rev(r: ObjectRevision, m?: MemberName): string;
56
- static conflicts(conflicts: ObjectRevision[]): string;
57
- static conflictingMemberHint(m: MemberName, ours: ObjectRevision, theirs: ObjectRevision): string;
53
+ static obj(h: DataHolder | undefined, m?: MemberName | undefined, stamp?: number, snapshotId?: number, originSnapshotId?: number, value?: any): string;
54
+ static rev2(h: DataHolder, s: AbstractSnapshot, m?: MemberName, o?: Subscription): string;
55
+ static rev(r: DataRevision, m?: MemberName): string;
56
+ static conflicts(conflicts: DataRevision[]): string;
57
+ static conflictingMemberHint(m: MemberName, ours: DataRevision, theirs: DataRevision): string;
58
58
  }
59
- export declare const ROOT_REV: ObjectRevision;
59
+ export declare const ROOT_REV: DataRevision;
60
60
  export declare const DefaultSnapshotOptions: SnapshotOptions;
@@ -10,17 +10,17 @@ const SealedSet_1 = require("../util/SealedSet");
10
10
  const Data_1 = require("./Data");
11
11
  exports.MAX_TIMESTAMP = Number.MAX_SAFE_INTEGER;
12
12
  exports.UNDEFINED_TIMESTAMP = exports.MAX_TIMESTAMP - 1;
13
- Object.defineProperty(Data_1.ObjectHolder.prototype, '#this', {
13
+ Object.defineProperty(Data_1.DataHolder.prototype, '#this', {
14
14
  configurable: false, enumerable: false,
15
15
  get() {
16
16
  const result = {};
17
17
  const data = Snapshot.current().getCurrentRevision(this, '#this').data;
18
18
  for (const m in data) {
19
19
  const v = data[m];
20
- if (v instanceof Data_1.Observable)
21
- result[m] = v.value;
22
- else if (v === Data_1.Meta.Unobservable)
23
- result[m] = this.unobservable[m];
20
+ if (v instanceof Data_1.Subscription)
21
+ result[m] = v.content;
22
+ else if (v === Data_1.Meta.Nonsubscribing)
23
+ result[m] = this.data[m];
24
24
  else
25
25
  result[m] = v;
26
26
  }
@@ -64,11 +64,11 @@ class Snapshot {
64
64
  getEditableRevision(h, m, value, token) {
65
65
  let r = this.seekRevision(h, m);
66
66
  const existing = r.data[m];
67
- if (existing !== Data_1.Meta.Unobservable) {
67
+ if (existing !== Data_1.Meta.Nonsubscribing) {
68
68
  if (this.isNewRevisionRequired(h, r, m, existing, value, token)) {
69
69
  const data = Object.assign({}, m === Data_1.Meta.Holder ? value : r.data);
70
70
  Reflect.set(data, Data_1.Meta.Holder, h);
71
- r = new Data_1.ObjectRevision(this, r, data);
71
+ r = new Data_1.DataRevision(this, r, data);
72
72
  this.changeset.set(h, r);
73
73
  h.editing = r;
74
74
  h.editors++;
@@ -99,7 +99,7 @@ class Snapshot {
99
99
  }
100
100
  isNewRevisionRequired(h, r, m, existing, value, token) {
101
101
  if (this.sealed && r.snapshot !== exports.ROOT_REV.snapshot)
102
- throw (0, Dbg_1.misuse)(`observable property ${Dump.obj(h, m)} can only be modified inside transaction`);
102
+ throw (0, Dbg_1.misuse)(`subscribing property ${Dump.obj(h, m)} can only be modified inside transaction`);
103
103
  if (m !== Data_1.Meta.Holder && value !== Data_1.Meta.Holder) {
104
104
  if (r.snapshot !== this || r.former.revision !== exports.ROOT_REV) {
105
105
  if (this.options.token !== undefined && token !== this.options.token)
@@ -193,9 +193,9 @@ class Snapshot {
193
193
  if (!error) {
194
194
  h.head = r;
195
195
  if (Snapshot.garbageCollectionSummaryInterval < Number.MAX_SAFE_INTEGER) {
196
- Snapshot.totalObjectRevisionCount++;
196
+ Snapshot.totalRevisionCount++;
197
197
  if (r.former.revision === exports.ROOT_REV)
198
- Snapshot.totalObjectHolderCount++;
198
+ Snapshot.totalHolderCount++;
199
199
  }
200
200
  }
201
201
  });
@@ -217,20 +217,20 @@ class Snapshot {
217
217
  }
218
218
  static sealObjectRevision(h, r) {
219
219
  if (!r.changes.has(Data_1.Meta.Disposed))
220
- r.changes.forEach((o, m) => Snapshot.sealObservable(r.data[m], m, h.proxy.constructor.name));
220
+ r.changes.forEach((o, m) => Snapshot.sealSubscription(r.data[m], m, h.proxy.constructor.name));
221
221
  else
222
222
  for (const m in r.former.revision.data)
223
223
  r.data[m] = Data_1.Meta.Disposed;
224
224
  if (Dbg_1.Log.isOn)
225
225
  Snapshot.freezeObjectRevision(r);
226
226
  }
227
- static sealObservable(observable, m, typeName) {
228
- if (observable instanceof Data_1.Observable) {
229
- const value = observable.value;
227
+ static sealSubscription(subscription, m, typeName) {
228
+ if (subscription instanceof Data_1.Subscription) {
229
+ const value = subscription.content;
230
230
  if (value !== undefined && value !== null) {
231
231
  const sealedType = Object.getPrototypeOf(value)[Sealant_1.Sealant.SealedType];
232
232
  if (sealedType)
233
- observable.value = Sealant_1.Sealant.seal(value, sealedType, typeName, m);
233
+ subscription.content = Sealant_1.Sealant.seal(value, sealedType, typeName, m);
234
234
  }
235
235
  }
236
236
  }
@@ -254,7 +254,7 @@ class Snapshot {
254
254
  Snapshot.oldest = Snapshot.pending[0];
255
255
  const now = Date.now();
256
256
  if (now - Snapshot.lastGarbageCollectionSummaryTimestamp > Snapshot.garbageCollectionSummaryInterval) {
257
- Dbg_1.Log.write('', '[G]', `Total object/revision count: ${Snapshot.totalObjectHolderCount}/${Snapshot.totalObjectRevisionCount}`);
257
+ Dbg_1.Log.write('', '[G]', `Total object/revision count: ${Snapshot.totalHolderCount}/${Snapshot.totalRevisionCount}`);
258
258
  Snapshot.lastGarbageCollectionSummaryTimestamp = now;
259
259
  }
260
260
  }
@@ -268,9 +268,9 @@ class Snapshot {
268
268
  Dbg_1.Log.write(' ', ' ', `${Dump.rev2(h, r.former.revision.snapshot)} is ready for GC because overwritten by ${Dump.rev2(h, r.snapshot)}`);
269
269
  if (Snapshot.garbageCollectionSummaryInterval < Number.MAX_SAFE_INTEGER) {
270
270
  if (r.former.revision !== exports.ROOT_REV)
271
- Snapshot.totalObjectRevisionCount--;
271
+ Snapshot.totalRevisionCount--;
272
272
  if (r.changes.has(Data_1.Meta.Disposed))
273
- Snapshot.totalObjectHolderCount--;
273
+ Snapshot.totalHolderCount--;
274
274
  }
275
275
  r.former.revision = exports.ROOT_REV;
276
276
  });
@@ -300,8 +300,8 @@ Snapshot.pending = [];
300
300
  Snapshot.oldest = undefined;
301
301
  Snapshot.garbageCollectionSummaryInterval = Number.MAX_SAFE_INTEGER;
302
302
  Snapshot.lastGarbageCollectionSummaryTimestamp = Date.now();
303
- Snapshot.totalObjectHolderCount = 0;
304
- Snapshot.totalObjectRevisionCount = 0;
303
+ Snapshot.totalHolderCount = 0;
304
+ Snapshot.totalRevisionCount = 0;
305
305
  Snapshot.current = Utils_1.UNDEF;
306
306
  Snapshot.edit = Utils_1.UNDEF;
307
307
  Snapshot.markUsed = Utils_1.UNDEF;
@@ -321,7 +321,7 @@ class Dump {
321
321
  }
322
322
  static rev2(h, s, m, o) {
323
323
  var _a;
324
- return Dump.obj(h, m, s.timestamp, s.id, o === null || o === void 0 ? void 0 : o.originSnapshotId, (_a = o === null || o === void 0 ? void 0 : o.value) !== null && _a !== void 0 ? _a : Data_1.Meta.Undefined);
324
+ return Dump.obj(h, m, s.timestamp, s.id, o === null || o === void 0 ? void 0 : o.originSnapshotId, (_a = o === null || o === void 0 ? void 0 : o.content) !== null && _a !== void 0 ? _a : Data_1.Meta.Undefined);
325
325
  }
326
326
  static rev(r, m) {
327
327
  const h = Data_1.Meta.get(r.data, Data_1.Meta.Holder);
@@ -343,7 +343,7 @@ class Dump {
343
343
  }
344
344
  exports.Dump = Dump;
345
345
  Dump.valueHint = (value, m) => '???';
346
- exports.ROOT_REV = new Data_1.ObjectRevision(new Snapshot({ hint: '<root>' }), undefined, {});
346
+ exports.ROOT_REV = new Data_1.DataRevision(new Snapshot({ hint: '<root>' }), undefined, {});
347
347
  exports.DefaultSnapshotOptions = Object.freeze({
348
348
  hint: 'noname',
349
349
  standalone: false,