reactronic 0.96.26019 → 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.
- package/build/dist/source/Enums.d.ts +1 -1
- package/build/dist/source/Enums.js +1 -1
- package/build/dist/source/Worker.d.ts +1 -1
- package/build/dist/source/core/Changeset.d.ts +2 -1
- package/build/dist/source/core/Changeset.js +10 -6
- package/build/dist/source/core/Data.d.ts +2 -1
- package/build/dist/source/core/Operation.js +13 -12
- package/build/dist/source/core/Transaction.d.ts +4 -2
- package/build/dist/source/core/Transaction.js +7 -6
- package/build/dist/source/core/TreeNode.js +2 -2
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ export var Mode;
|
|
|
2
2
|
(function (Mode) {
|
|
3
3
|
Mode[Mode["default"] = 0] = "default";
|
|
4
4
|
Mode[Mode["primitive"] = 1] = "primitive";
|
|
5
|
-
Mode[Mode["
|
|
5
|
+
Mode[Mode["fragment"] = 2] = "fragment";
|
|
6
6
|
Mode[Mode["external"] = 4] = "external";
|
|
7
7
|
})(Mode || (Mode = {}));
|
|
8
8
|
export var Priority;
|
|
@@ -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
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
360
|
+
return `${theirs.changeset.name} (${Dump.snapshot(theirs, fk)})`;
|
|
357
361
|
}
|
|
358
362
|
}
|
|
359
363
|
Dump.valueHint = (value) => "???";
|
|
@@ -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
|
|
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 = ` ◀◀
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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.
|
|
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 =
|
|
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(
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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(" ", " ",
|
|
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.
|
|
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("║", " [!]",
|
|
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(
|
|
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.
|
|
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) {
|
|
@@ -434,7 +434,7 @@ function launchNestedNodesThenDoImpl(node, error, action) {
|
|
|
434
434
|
function markToMountIfNecessary(mounting, host, node, children, sequential) {
|
|
435
435
|
if (node.declaration.unmounted)
|
|
436
436
|
host = node;
|
|
437
|
-
if (!node.hasAny(Mode.
|
|
437
|
+
if (!node.hasAny(Mode.fragment | Mode.external)) {
|
|
438
438
|
if (mounting || node.host !== host) {
|
|
439
439
|
LinkedItem.setStatus$(node, Mark.moved, node.rank);
|
|
440
440
|
mounting = false;
|
|
@@ -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
|
|
494
|
+
ReactiveSystem.setLoggingHint(node, node.key);
|
|
495
495
|
manageReaction(node.body).configure({
|
|
496
496
|
order: node.level,
|
|
497
497
|
});
|