reactronic 0.96.26020 → 0.96.26021

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,6 +1,6 @@
1
1
  export type Worker = {
2
2
  readonly id: number;
3
- readonly hint: string;
3
+ readonly name: string;
4
4
  readonly isCanceled: boolean;
5
5
  readonly isFinished: boolean;
6
6
  cancel(error: Error, restartAfter?: Worker | null): void;
@@ -15,7 +15,7 @@ export declare class Changeset implements AbstractChangeset {
15
15
  readonly id: number;
16
16
  readonly options: SnapshotOptions;
17
17
  readonly parent?: Changeset;
18
- get hint(): string;
18
+ get name(): string;
19
19
  get timestamp(): number;
20
20
  private revision;
21
21
  private bumper;
@@ -23,6 +23,7 @@ export declare class Changeset implements AbstractChangeset {
23
23
  obsolete: OperationFootprint[];
24
24
  sealed: boolean;
25
25
  constructor(options: SnapshotOptions | null, parent?: Changeset);
26
+ get caption(): string;
26
27
  static current: () => Changeset;
27
28
  static edit: () => Changeset;
28
29
  static markUsed: (cf: ContentFootprint, ov: ObjectVersion, fk: FieldKey, h: ObjectHandle, kind: Kind, weak: boolean) => void;
@@ -28,7 +28,7 @@ Object.defineProperty(ObjectHandle.prototype, "#this#", {
28
28
  const EMPTY_ARRAY = Object.freeze([]);
29
29
  const EMPTY_MAP = Utils.freezeMap(new Map());
30
30
  export class Changeset {
31
- get hint() { var _a; return (_a = this.options.hint) !== null && _a !== void 0 ? _a : "noname"; }
31
+ get name() { var _a; return (_a = this.options.hint) !== null && _a !== void 0 ? _a : "noname"; }
32
32
  get timestamp() { return this.revision; }
33
33
  constructor(options, parent) {
34
34
  this.id = ++Changeset.idGen;
@@ -40,6 +40,10 @@ export class Changeset {
40
40
  this.obsolete = [];
41
41
  this.sealed = false;
42
42
  }
43
+ get caption() {
44
+ const p = this.parent;
45
+ return `T${this.id}${p ? `^${p.id}` : ""}[${this.name}]`;
46
+ }
43
47
  lookupObjectVersion(h, fk, editing) {
44
48
  let ov = h.editing;
45
49
  if (ov && ov.changeset !== this) {
@@ -64,7 +68,7 @@ export class Changeset {
64
68
  getObjectVersion(h, fk) {
65
69
  const r = this.lookupObjectVersion(h, fk, false);
66
70
  if (r === EMPTY_OBJECT_VERSION)
67
- throw misuse(`${Dump.obj(h, fk)} is not yet available for T${this.id}[${this.hint}] because ${h.editing ? `T${h.editing.changeset.id}[${h.editing.changeset.hint}]` : ""} is not yet applied (last applied T${h.applied.changeset.id}[${h.applied.changeset.hint}])`);
71
+ throw misuse(`${Dump.obj(h, fk)} is not yet available for ${this.caption} because ${h.editing ? h.editing.changeset.caption : ""} is not yet applied (last applied ${h.applied.changeset.caption})`);
68
72
  return r;
69
73
  }
70
74
  getEditableObjectVersion(h, fk, value, token) {
@@ -130,7 +134,7 @@ export class Changeset {
130
134
  if (value !== Meta.Handle) {
131
135
  if (ov.changeset !== this || ov.former.objectVersion !== EMPTY_OBJECT_VERSION) {
132
136
  if (this.options.token !== undefined && token !== this.options.token)
133
- throw misuse(`${this.hint} should not have side effects (trying to change ${Dump.snapshot(ov, fk)})`);
137
+ throw misuse(`${this.name} should not have side effects (trying to change ${Dump.snapshot(ov, fk)})`);
134
138
  }
135
139
  }
136
140
  }
@@ -145,7 +149,7 @@ export class Changeset {
145
149
  if (Changeset.oldest === undefined)
146
150
  Changeset.oldest = this;
147
151
  if (Log.isOn && Log.opt.transaction)
148
- Log.write("╔══", `s${this.revision}`, `${this.hint}`);
152
+ Log.write("╔══", `s${this.revision}`, `${this.name}`);
149
153
  }
150
154
  return result;
151
155
  }
@@ -272,7 +276,7 @@ export class Changeset {
272
276
  }
273
277
  unlinkHistory() {
274
278
  if (Log.isOn && Log.opt.gc)
275
- Log.write("", "[G]", `Dismiss history below t${this.id}s${this.revision} (${this.hint})`);
279
+ Log.write("", "[G]", `Dismiss history below t${this.id}s${this.revision} (${this.name})`);
276
280
  this.items.forEach((ov, h) => {
277
281
  if (Log.isOn && Log.opt.gc && ov.former.objectVersion !== EMPTY_OBJECT_VERSION)
278
282
  Log.write(" ", " ", `${Dump.snapshot2(h, ov.former.objectVersion.changeset)} is ready for GC because overwritten by ${Dump.snapshot2(h, ov.changeset)}`);
@@ -353,7 +357,7 @@ export class Dump {
353
357
  }).join(", ");
354
358
  }
355
359
  static conflictingMemberHint(fk, ours, theirs) {
356
- return `${theirs.changeset.hint} (${Dump.snapshot(theirs, fk)})`;
360
+ return `${theirs.changeset.name} (${Dump.snapshot(theirs, fk)})`;
357
361
  }
358
362
  }
359
363
  Dump.valueHint = (value) => "???";
@@ -1,7 +1,8 @@
1
1
  export { Meta } from "./Meta.js";
2
2
  export type AbstractChangeset = {
3
3
  readonly id: number;
4
- readonly hint: string;
4
+ readonly name: string;
5
+ readonly caption: string;
5
6
  readonly timestamp: number;
6
7
  readonly sealed: boolean;
7
8
  };
@@ -41,7 +41,7 @@ export class ReactionImpl {
41
41
  }
42
42
  else if (Log.isOn && Log.opt.operation && (opts.logging === undefined ||
43
43
  opts.logging.operation === undefined || opts.logging.operation === true))
44
- Log.write(Transaction.current.isFinished ? "" : "║", " (=)", `${Dump.snapshot2(ror.footprint.descriptor.ownerHandle, ror.changeset, this.fieldKey)} result is reused from T${ror.footprint.transaction.id}[${ror.footprint.transaction.hint}]`);
44
+ Log.write(Transaction.current.isFinished ? "" : "║", " (=)", `${Dump.snapshot2(ror.footprint.descriptor.ownerHandle, ror.changeset, this.fieldKey)} result is reused from ${ror.footprint.transaction.caption}`);
45
45
  const t = ror.footprint;
46
46
  Changeset.markUsed(t, ror.objectVersion, this.fieldKey, this.ownerHandle, t.options.kind, weak);
47
47
  return t;
@@ -254,7 +254,7 @@ class OperationFootprintImpl extends ContentFootprint {
254
254
  else if (this.descriptor.options.kind === Kind.transaction)
255
255
  cause = " ◀◀ operation";
256
256
  else
257
- cause = ` ◀◀ T${this.changeset.id}[${this.changeset.hint}]`;
257
+ cause = ` ◀◀ ${this.changeset.caption}`;
258
258
  return `${this.hint()}${cause}`;
259
259
  }
260
260
  briefWhy() {
@@ -310,7 +310,7 @@ class OperationFootprintImpl extends ContentFootprint {
310
310
  if (tran.changeset === changeset) {
311
311
  }
312
312
  else if (!tran.isFinished && this !== footprint && !this.options.allowObsoleteToFinish)
313
- tran.cancel(new Error(`T${tran.id}[${tran.hint}] is canceled due to obsolete ${Dump.snapshot2(h, changeset, fk)} changed by T${changeset.id}[${changeset.hint}]`), null);
313
+ tran.cancel(new Error(`${tran.caption} is canceled due to obsolete ${Dump.snapshot2(h, changeset, fk)} changed by ${changeset.caption}`), null);
314
314
  }
315
315
  else if (Log.isOn && (Log.opt.obsolete || ((_c = this.options.logging) === null || _c === void 0 ? void 0 : _c.obsolete)))
316
316
  Log.write(" ", "x", `${this.hint()} is not obsolete due to its own change to ${Dump.snapshot2(h, changeset, fk, footprint)}`);
@@ -359,20 +359,20 @@ class OperationFootprintImpl extends ContentFootprint {
359
359
  case Reentrance.preventWithError:
360
360
  if (!opponent.transaction.isCanceled)
361
361
  throw misuse(`${head.hint()} (${head.why()}) is not reentrant over ${opponent.hint()} (${opponent.why()})`);
362
- error = new Error(`T${this.transaction.id}[${this.transaction.hint}] is on hold/PreventWithError due to canceled T${opponent.transaction.id}[${opponent.transaction.hint}]`);
362
+ error = new Error(`${this.transaction.caption} is on hold/PreventWithError due to canceled ${opponent.transaction.caption}`);
363
363
  this.transaction.cancel(error, opponent.transaction);
364
364
  break;
365
365
  case Reentrance.waitAndRestart:
366
- error = new Error(`T${this.transaction.id}[${this.transaction.hint}] is on hold/WaitAndRestart due to active T${opponent.transaction.id}[${opponent.transaction.hint}]`);
366
+ error = new Error(`${this.transaction.caption} is on hold/WaitAndRestart due to active ${opponent.transaction.caption}`);
367
367
  this.transaction.cancel(error, opponent.transaction);
368
368
  break;
369
369
  case Reentrance.cancelAndWaitPrevious:
370
- error = new Error(`T${this.transaction.id}[${this.transaction.hint}] is on hold/CancelAndWaitPrevious due to active T${opponent.transaction.id}[${opponent.transaction.hint}]`);
370
+ error = new Error(`${this.transaction.caption} is on hold/CancelAndWaitPrevious due to active ${opponent.transaction.caption}`);
371
371
  this.transaction.cancel(error, opponent.transaction);
372
- opponent.transaction.cancel(new Error(`T${opponent.transaction.id}[${opponent.transaction.hint}] is canceled due to re-entering T${this.transaction.id}[${this.transaction.hint}]`), null);
372
+ opponent.transaction.cancel(new Error(`${opponent.transaction.caption} is canceled due to re-entering ${this.transaction.caption}`), null);
373
373
  break;
374
374
  case Reentrance.cancelPrevious:
375
- opponent.transaction.cancel(new Error(`T${opponent.transaction.id}[${opponent.transaction.hint}] is canceled due to re-entering T${this.transaction.id}[${this.transaction.hint}]`), null);
375
+ opponent.transaction.cancel(new Error(`${opponent.transaction.caption} is canceled due to re-entering ${this.transaction.caption}`), null);
376
376
  break;
377
377
  case Reentrance.runSideBySide:
378
378
  break;
@@ -513,7 +513,7 @@ class OperationFootprintImpl extends ContentFootprint {
513
513
  OperationFootprintImpl.propagateFieldChangeToListeners(true, since, ov, fk, h, obsolete);
514
514
  });
515
515
  obsolete.sort(compareReactionsByOrder);
516
- (_a = changeset.options.journal) === null || _a === void 0 ? void 0 : _a.edited(JournalImpl.buildPatch(changeset.hint, changeset.items));
516
+ (_a = changeset.options.journal) === null || _a === void 0 ? void 0 : _a.edited(JournalImpl.buildPatch(changeset.name, changeset.items));
517
517
  }
518
518
  static discardAllListeners(changeset) {
519
519
  changeset.items.forEach((ov, h) => {
@@ -527,7 +527,7 @@ class OperationFootprintImpl extends ContentFootprint {
527
527
  if (collector !== undefined) {
528
528
  const former = ov.former.objectVersion.data[fk];
529
529
  if (former !== undefined && former instanceof ContentFootprint) {
530
- const why = `T${ov.changeset.id}[${ov.changeset.hint}]`;
530
+ const why = ov.changeset.caption;
531
531
  if (former instanceof OperationFootprintImpl) {
532
532
  if ((former.obsoleteSince === MAX_REVISION || former.obsoleteSince <= 0)) {
533
533
  former.obsoleteDueTo = why;
@@ -537,7 +537,7 @@ class OperationFootprintImpl extends ContentFootprint {
537
537
  const formerSuccessor = former.successor;
538
538
  if (formerSuccessor !== curr) {
539
539
  if (formerSuccessor && !formerSuccessor.transaction.isFinished)
540
- formerSuccessor.transaction.cancel(new Error(`T${formerSuccessor.transaction.id}[${formerSuccessor.transaction.hint}] is canceled by T${ov.changeset.id}[${ov.changeset.hint}] and will not run anymore`), null);
540
+ formerSuccessor.transaction.cancel(new Error(`${formerSuccessor.transaction.caption} is canceled by ${ov.changeset.caption} and will not run anymore`), null);
541
541
  }
542
542
  else
543
543
  former.successor = undefined;
@@ -721,7 +721,8 @@ function valueHint(value) {
721
721
  }
722
722
  function getMergedLoggingOptions(local) {
723
723
  const t = Transaction.current;
724
- let res = Log.merge(t.options.logging, t.id > 1 ? 31 + t.id % 6 : 37, t.id > 1 ? `T${t.id}` : `-${Changeset.idGen.toString().replace(/[0-9]/g, "-")}`, Log.global);
724
+ const p = t.parent;
725
+ let res = Log.merge(t.options.logging, t.id > 1 ? 31 + t.id % 6 : 37, t.id > 1 ? `T${t.id}${p ? `^${p.id}` : ""}` : `-${Changeset.idGen.toString().replace(/[0-9]/g, "-")}`, Log.global);
725
726
  res = Log.merge({ margin1: t.margin }, undefined, undefined, res);
726
727
  if (OperationFootprintImpl.current)
727
728
  res = Log.merge({ margin2: OperationFootprintImpl.current.margin }, undefined, undefined, res);
@@ -6,7 +6,8 @@ import { Changeset } from "./Changeset.js";
6
6
  export declare abstract class Transaction implements Worker {
7
7
  static get current(): Transaction;
8
8
  abstract readonly id: number;
9
- abstract readonly hint: string;
9
+ abstract readonly name: string;
10
+ abstract readonly caption: string;
10
11
  abstract readonly options: SnapshotOptions;
11
12
  abstract readonly timestamp: number;
12
13
  abstract readonly error: Error | undefined;
@@ -49,7 +50,8 @@ export declare class TransactionImpl extends Transaction {
49
50
  constructor(options: SnapshotOptions | null, parent?: TransactionImpl);
50
51
  static get curr(): TransactionImpl;
51
52
  get id(): number;
52
- get hint(): string;
53
+ get name(): string;
54
+ get caption(): string;
53
55
  get options(): SnapshotOptions;
54
56
  get timestamp(): number;
55
57
  get error(): Error | undefined;
@@ -41,7 +41,8 @@ export class TransactionImpl extends Transaction {
41
41
  }
42
42
  static get curr() { return TransactionImpl.gCurr; }
43
43
  get id() { return this.changeset.id; }
44
- get hint() { return this.changeset.hint; }
44
+ get name() { return this.changeset.name; }
45
+ get caption() { return this.changeset.caption; }
45
46
  get options() { return this.changeset.options; }
46
47
  get timestamp() { return this.changeset.timestamp; }
47
48
  get error() { return this.canceled; }
@@ -54,7 +55,7 @@ export class TransactionImpl extends Transaction {
54
55
  try {
55
56
  TransactionImpl.isInspectionMode = true;
56
57
  if (Log.isOn && Log.opt.transaction)
57
- Log.write(" ", " ", `T${this.id}[${this.hint}] is being inspected by T${TransactionImpl.gCurr.id}[${TransactionImpl.gCurr.hint}]`);
58
+ Log.write(" ", " ", `${this.caption} is being inspected by ${TransactionImpl.gCurr.caption}`);
58
59
  return this.runImpl(undefined, func, ...args);
59
60
  }
60
61
  finally {
@@ -186,7 +187,7 @@ export class TransactionImpl extends Transaction {
186
187
  if (this.after) {
187
188
  yield this.after.whenFinished();
188
189
  const options = {
189
- hint: `${this.hint} - restart after T${this.after.id}`,
190
+ hint: `${this.name} - restart after T${this.after.id}`,
190
191
  isolation: this.options.isolation === Isolation.joinToCurrentTransaction ? Isolation.disjoinFromOuterTransaction : this.options.isolation,
191
192
  logging: this.changeset.options.logging,
192
193
  token: this.changeset.options.token,
@@ -256,7 +257,7 @@ export class TransactionImpl extends Transaction {
256
257
  if (Log.isOn && Log.opt.transaction) {
257
258
  Log.write("║", " [!]", `${error.message}`, undefined, " *** CANCEL ***");
258
259
  if (after && after !== TransactionImpl.none)
259
- Log.write("║", " [!]", `T${t.id}[${t.hint}] will be restarted${t !== after ? ` after T${after.id}[${after.hint}]` : ""}`);
260
+ Log.write("║", " [!]", `${t.caption} will be restarted${t !== after ? ` after ${after.caption}` : ""}`);
260
261
  }
261
262
  Changeset.discardAllListeners(t.changeset);
262
263
  }
@@ -268,7 +269,7 @@ export class TransactionImpl extends Transaction {
268
269
  this.tryResolveConflicts(conflicts);
269
270
  }
270
271
  tryResolveConflicts(conflicts) {
271
- throw error(`T${this.id}[${this.hint}] conflicts with: ${Dump.conflicts(conflicts)}`, undefined);
272
+ throw error(`${this.caption} conflicts with: ${Dump.conflicts(conflicts)}`, undefined);
272
273
  }
273
274
  applyOrDiscard() {
274
275
  let obsolete;
@@ -317,7 +318,7 @@ export class TransactionImpl extends Transaction {
317
318
  });
318
319
  }
319
320
  if (Log.opt.transaction)
320
- Log.write(changeset.timestamp < UNDEFINED_REVISION ? "╚══" : "═══", `s${this.timestamp}`, `${this.hint} - ${error ? "CANCEL" : "APPLY"}(${this.changeset.items.size})${error ? ` - ${error}` : ""}`);
321
+ Log.write(changeset.timestamp < UNDEFINED_REVISION ? "╚══" : "═══", `s${this.timestamp}`, `${this.name} - ${error ? "CANCEL" : "APPLY"}(${this.changeset.items.size})${error ? ` - ${error}` : ""}`);
321
322
  }
322
323
  let obsolete = changeset.obsolete;
323
324
  if (changeset.parent) {
@@ -491,7 +491,7 @@ function rebuildBodyImpl(node) {
491
491
  if (node.stamp === Number.MAX_SAFE_INTEGER) {
492
492
  Transaction.outside(() => {
493
493
  if (ReactiveSystem.isLogging)
494
- ReactiveSystem.setLoggingHint(node.element, node.key);
494
+ ReactiveSystem.setLoggingHint(node, node.key);
495
495
  manageReaction(node.body).configure({
496
496
  order: node.level,
497
497
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.96.26020",
3
+ "version": "0.96.26021",
4
4
  "description": "Reactronic - Transactional Reactive State Management",
5
5
  "publisher": "Nezaboodka Software",
6
6
  "license": "Apache-2.0",