reactronic 0.93.25021 → 0.93.25025
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/ReactiveLoop.js +2 -2
- package/build/dist/source/ReactiveSystem.d.ts +3 -3
- package/build/dist/source/ReactiveSystem.js +6 -6
- package/build/dist/source/api.d.ts +1 -1
- package/build/dist/source/api.js +1 -1
- package/build/dist/source/core/Changeset.d.ts +3 -3
- package/build/dist/source/core/Changeset.js +1 -1
- package/build/dist/source/core/Data.d.ts +3 -3
- package/build/dist/source/core/MvccArray.d.ts +5 -5
- package/build/dist/source/core/Operation.d.ts +6 -6
- package/build/dist/source/core/Operation.js +24 -24
- package/build/dist/source/core/ReactiveNode.js +2 -2
- package/build/dist/source/core/Transaction.d.ts +2 -2
- package/build/dist/source/core/Transaction.js +37 -37
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { TriggeringObject } from "./core/Mvcc.js";
|
|
11
|
-
import {
|
|
11
|
+
import { reaction } from "./ReactiveSystem.js";
|
|
12
12
|
export class ReactiveLoop extends TriggeringObject {
|
|
13
13
|
constructor(reactiveFunction) {
|
|
14
14
|
super();
|
|
@@ -19,7 +19,7 @@ export class ReactiveLoop extends TriggeringObject {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
__decorate([
|
|
22
|
-
|
|
22
|
+
reaction,
|
|
23
23
|
__metadata("design:type", Function),
|
|
24
24
|
__metadata("design:paramtypes", []),
|
|
25
25
|
__metadata("design:returntype", Object)
|
|
@@ -24,7 +24,7 @@ export declare function sensitiveRun<T>(sensitivity: boolean, func: F<T>, ...arg
|
|
|
24
24
|
export declare function contextualRun<T>(p: Promise<T>): Promise<T>;
|
|
25
25
|
export declare function trigger(enabled: boolean): (proto: object, prop: PropertyKey) => any;
|
|
26
26
|
export declare function trigger<T>(proto: object, prop: PropertyKey): any;
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
27
|
+
export declare function atomicBlock(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
28
|
+
export declare function reaction(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
29
|
+
export declare function cache(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
30
30
|
export declare function options(value: Partial<MemberOptions>): F<any>;
|
|
@@ -54,28 +54,28 @@ export function trigger(protoOrEnabled, prop) {
|
|
|
54
54
|
else
|
|
55
55
|
return Mvcc.decorateData(true, protoOrEnabled, prop);
|
|
56
56
|
}
|
|
57
|
-
export function
|
|
57
|
+
export function atomicBlock(proto, prop, pd) {
|
|
58
58
|
const opts = {
|
|
59
59
|
kind: Kind.atomic,
|
|
60
60
|
isolation: Isolation.joinToCurrentTransaction,
|
|
61
61
|
};
|
|
62
|
-
return Mvcc.decorateOperation(true,
|
|
62
|
+
return Mvcc.decorateOperation(true, atomicBlock, opts, proto, prop, pd);
|
|
63
63
|
}
|
|
64
|
-
export function
|
|
64
|
+
export function reaction(proto, prop, pd) {
|
|
65
65
|
const opts = {
|
|
66
66
|
kind: Kind.reactive,
|
|
67
67
|
isolation: Isolation.joinAsNestedTransaction,
|
|
68
68
|
throttling: -1,
|
|
69
69
|
};
|
|
70
|
-
return Mvcc.decorateOperation(true,
|
|
70
|
+
return Mvcc.decorateOperation(true, reaction, opts, proto, prop, pd);
|
|
71
71
|
}
|
|
72
|
-
export function
|
|
72
|
+
export function cache(proto, prop, pd) {
|
|
73
73
|
const opts = {
|
|
74
74
|
kind: Kind.cached,
|
|
75
75
|
isolation: Isolation.joinToCurrentTransaction,
|
|
76
76
|
noSideEffects: true,
|
|
77
77
|
};
|
|
78
|
-
return Mvcc.decorateOperation(true,
|
|
78
|
+
return Mvcc.decorateOperation(true, cache, opts, proto, prop, pd);
|
|
79
79
|
}
|
|
80
80
|
export function options(value) {
|
|
81
81
|
return Mvcc.decorateOperationParametrized(options, value);
|
|
@@ -17,7 +17,7 @@ export { Transaction } from "./core/Transaction.js";
|
|
|
17
17
|
export { Indicator } from "./core/Indicator.js";
|
|
18
18
|
export { Journal } from "./core/Journal.js";
|
|
19
19
|
export { atomicRun, nonReactiveRun, sensitiveRun, contextualRun } from "./ReactiveSystem.js";
|
|
20
|
-
export { ReactiveSystem, trigger,
|
|
20
|
+
export { ReactiveSystem, trigger, atomicBlock, reaction, cache, options } from "./ReactiveSystem.js";
|
|
21
21
|
export { ReactiveLoop } from "./ReactiveLoop.js";
|
|
22
22
|
export { ReactiveNode, Mode, Priority, BaseDriver, ReactiveNodeVariable } from "./core/ReactiveNode.js";
|
|
23
23
|
export type { Script, ScriptAsync, Handler, ReactiveNodeDecl, ReactiveNodeDriver, ReactiveNodeContext } from "./core/ReactiveNode.js";
|
package/build/dist/source/api.js
CHANGED
|
@@ -13,6 +13,6 @@ export { Transaction } from "./core/Transaction.js";
|
|
|
13
13
|
export { Indicator } from "./core/Indicator.js";
|
|
14
14
|
export { Journal } from "./core/Journal.js";
|
|
15
15
|
export { atomicRun, nonReactiveRun, sensitiveRun, contextualRun } from "./ReactiveSystem.js";
|
|
16
|
-
export { ReactiveSystem, trigger,
|
|
16
|
+
export { ReactiveSystem, trigger, atomicBlock, reaction, cache, options } from "./ReactiveSystem.js";
|
|
17
17
|
export { ReactiveLoop } from "./ReactiveLoop.js";
|
|
18
18
|
export { ReactiveNode, Mode, Priority, BaseDriver, ReactiveNodeVariable } from "./core/ReactiveNode.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Kind, SnapshotOptions } from "../Options.js";
|
|
2
|
-
import { AbstractChangeset, ObjectVersion, FieldKey, ObjectHandle, FieldVersion,
|
|
2
|
+
import { AbstractChangeset, ObjectVersion, FieldKey, ObjectHandle, FieldVersion, Reaction } from "./Data.js";
|
|
3
3
|
export declare const MAX_REVISION: number;
|
|
4
4
|
export declare const UNDEFINED_REVISION: number;
|
|
5
5
|
export declare class Changeset implements AbstractChangeset {
|
|
@@ -19,7 +19,7 @@ export declare class Changeset implements AbstractChangeset {
|
|
|
19
19
|
private revision;
|
|
20
20
|
private bumper;
|
|
21
21
|
items: Map<ObjectHandle, ObjectVersion>;
|
|
22
|
-
obsolete:
|
|
22
|
+
obsolete: Reaction[];
|
|
23
23
|
sealed: boolean;
|
|
24
24
|
constructor(options: SnapshotOptions | null, parent?: Changeset);
|
|
25
25
|
static current: () => Changeset;
|
|
@@ -32,7 +32,7 @@ export declare class Changeset implements AbstractChangeset {
|
|
|
32
32
|
};
|
|
33
33
|
static propagateAllChangesThroughSubscriptions: (changeset: Changeset) => void;
|
|
34
34
|
static revokeAllSubscriptions: (changeset: Changeset) => void;
|
|
35
|
-
static
|
|
35
|
+
static enqueueReactionsToRun: (reactions: Array<Reaction>) => void;
|
|
36
36
|
lookupObjectVersion(h: ObjectHandle, fk: FieldKey, editing: boolean): ObjectVersion;
|
|
37
37
|
getObjectVersion(h: ObjectHandle, fk: FieldKey): ObjectVersion;
|
|
38
38
|
getEditableObjectVersion(h: ObjectHandle, fk: FieldKey, value: any, token?: any): ObjectVersion;
|
|
@@ -318,7 +318,7 @@ Changeset.markEdited = UNDEF;
|
|
|
318
318
|
Changeset.tryResolveConflict = UNDEF;
|
|
319
319
|
Changeset.propagateAllChangesThroughSubscriptions = (changeset) => { };
|
|
320
320
|
Changeset.revokeAllSubscriptions = (changeset) => { };
|
|
321
|
-
Changeset.
|
|
321
|
+
Changeset.enqueueReactionsToRun = (reactions) => { };
|
|
322
322
|
export class Dump {
|
|
323
323
|
static obj(h, fk, stamp, changesetId, lastEditorChangesetId, value) {
|
|
324
324
|
const member = fk !== undefined ? `.${fk.toString()}` : "";
|
|
@@ -7,17 +7,17 @@ export type AbstractChangeset = {
|
|
|
7
7
|
};
|
|
8
8
|
export declare class FieldVersion<T = any> {
|
|
9
9
|
content: T;
|
|
10
|
-
|
|
10
|
+
reactions?: Set<Reaction>;
|
|
11
11
|
lastEditorChangesetId: number;
|
|
12
12
|
get isLaunch(): boolean;
|
|
13
13
|
constructor(content: T, lastEditorChangesetId: number);
|
|
14
14
|
}
|
|
15
|
-
export type
|
|
15
|
+
export type Reaction = {
|
|
16
16
|
readonly order: number;
|
|
17
17
|
readonly triggers: Map<FieldVersion, Subscription> | undefined;
|
|
18
18
|
readonly obsoleteSince: number;
|
|
19
19
|
hint(nop?: boolean): string;
|
|
20
|
-
markObsoleteDueTo(trigger: FieldVersion, fk: FieldKey, changeset: AbstractChangeset, h: ObjectHandle, outer: string, since: number,
|
|
20
|
+
markObsoleteDueTo(trigger: FieldVersion, fk: FieldKey, changeset: AbstractChangeset, h: ObjectHandle, outer: string, since: number, collector: Array<Reaction>): void;
|
|
21
21
|
relaunchIfNotUpToDate(now: boolean, nothrow: boolean): void;
|
|
22
22
|
};
|
|
23
23
|
export type FieldKey = PropertyKey;
|
|
@@ -23,12 +23,12 @@ export declare class MvccArray<T> extends MvccObject {
|
|
|
23
23
|
includes(searchElement: T, fromIndex?: number): boolean;
|
|
24
24
|
indexOf(searchElement: T, fromIndex?: number): number;
|
|
25
25
|
lastIndexOf(searchElement: T, fromIndex?: number): number;
|
|
26
|
-
every(predicate: (value: T, index: number, array: T[]) =>
|
|
26
|
+
every(predicate: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
|
|
27
27
|
every<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[];
|
|
28
|
-
some(predicate: (value: T, index: number, array: T[]) =>
|
|
28
|
+
some(predicate: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
|
|
29
29
|
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
|
|
30
30
|
map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[];
|
|
31
|
-
filter(predicate: (value: T, index: number, array: T[]) =>
|
|
31
|
+
filter(predicate: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[];
|
|
32
32
|
filter<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[];
|
|
33
33
|
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
|
|
34
34
|
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
|
|
@@ -36,9 +36,9 @@ export declare class MvccArray<T> extends MvccObject {
|
|
|
36
36
|
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
|
|
37
37
|
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
|
|
38
38
|
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
|
|
39
|
-
find(predicate: (value: T, index: number, obj: T[]) =>
|
|
39
|
+
find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined;
|
|
40
40
|
find<S extends T>(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined;
|
|
41
|
-
findIndex(predicate: (value: T, index: number, obj: T[]) =>
|
|
41
|
+
findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number;
|
|
42
42
|
fill(value: T, start?: number, end?: number): this;
|
|
43
43
|
copyWithin(target: number, start: number, end?: number): this;
|
|
44
44
|
[Symbol.iterator](): IterableIterator<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { F } from "../util/Utils.js";
|
|
2
2
|
import { Operation, MemberOptions } from "../Options.js";
|
|
3
|
-
import { FieldKey, ObjectHandle, FieldVersion,
|
|
3
|
+
import { FieldKey, ObjectHandle, FieldVersion, Reaction, Subscription, AbstractChangeset } from "./Data.js";
|
|
4
4
|
import { Transaction } from "./Transaction.js";
|
|
5
5
|
import { OptionsImpl } from "./Mvcc.js";
|
|
6
6
|
export declare class OperationImpl implements Operation<any> {
|
|
@@ -31,9 +31,9 @@ export declare class OperationImpl implements Operation<any> {
|
|
|
31
31
|
private relaunch;
|
|
32
32
|
private static markObsolete;
|
|
33
33
|
}
|
|
34
|
-
declare class Launch extends FieldVersion implements
|
|
34
|
+
declare class Launch extends FieldVersion implements Reaction {
|
|
35
35
|
static current?: Launch;
|
|
36
|
-
static
|
|
36
|
+
static queuedReactions: Array<Reaction>;
|
|
37
37
|
static deferredReactiveOperations: Array<Launch>;
|
|
38
38
|
readonly margin: number;
|
|
39
39
|
readonly transaction: Transaction;
|
|
@@ -60,7 +60,7 @@ declare class Launch extends FieldVersion implements Observer {
|
|
|
60
60
|
dependencies(): string[];
|
|
61
61
|
wrap<T>(func: F<T>): F<T>;
|
|
62
62
|
proceed(proxy: any, args: any[] | undefined): void;
|
|
63
|
-
markObsoleteDueTo(trigger: FieldVersion, fk: FieldKey, changeset: AbstractChangeset, h: ObjectHandle, outer: string, since: number,
|
|
63
|
+
markObsoleteDueTo(trigger: FieldVersion, fk: FieldKey, changeset: AbstractChangeset, h: ObjectHandle, outer: string, since: number, collector: Reaction[]): void;
|
|
64
64
|
relaunchIfNotUpToDate(now: boolean, nothrow: boolean): void;
|
|
65
65
|
isNotUpToDate(): boolean;
|
|
66
66
|
reenterOver(head: Launch): this;
|
|
@@ -78,9 +78,9 @@ declare class Launch extends FieldVersion implements Observer {
|
|
|
78
78
|
private static propagateAllChangesThroughSubscriptions;
|
|
79
79
|
private static revokeAllSubscriptions;
|
|
80
80
|
private static propagateFieldChangeThroughSubscriptions;
|
|
81
|
-
private static
|
|
81
|
+
private static enqueueReactionsToRun;
|
|
82
82
|
private static migrateFieldVersion;
|
|
83
|
-
private static
|
|
83
|
+
private static processQueuedReactions;
|
|
84
84
|
private unsubscribeFromAllTriggers;
|
|
85
85
|
private subscribeTo;
|
|
86
86
|
private static canSubscribeTo;
|
|
@@ -287,7 +287,7 @@ class Launch extends FieldVersion {
|
|
|
287
287
|
else
|
|
288
288
|
this.result = Promise.reject(this.error);
|
|
289
289
|
}
|
|
290
|
-
markObsoleteDueTo(trigger, fk, changeset, h, outer, since,
|
|
290
|
+
markObsoleteDueTo(trigger, fk, changeset, h, outer, since, collector) {
|
|
291
291
|
var _a, _b, _c;
|
|
292
292
|
if (this.triggers !== undefined) {
|
|
293
293
|
const skip = !trigger.isLaunch &&
|
|
@@ -303,9 +303,9 @@ class Launch extends FieldVersion {
|
|
|
303
303
|
: `${this.hint()} is obsolete due to ${Dump.snapshot2(h, changeset, fk)} since s${since}${isReactive ? ` and will run automatically (order ${this.options.order})` : ""}`);
|
|
304
304
|
this.unsubscribeFromAllTriggers();
|
|
305
305
|
if (isReactive)
|
|
306
|
-
|
|
306
|
+
collector.push(this);
|
|
307
307
|
else
|
|
308
|
-
(_b = this.
|
|
308
|
+
(_b = this.reactions) === null || _b === void 0 ? void 0 : _b.forEach(s => s.markObsoleteDueTo(this, this.operation.fieldKey, this.changeset, this.operation.ownerHandle, why, since, collector));
|
|
309
309
|
const tran = this.transaction;
|
|
310
310
|
if (tran.changeset === changeset) {
|
|
311
311
|
}
|
|
@@ -514,7 +514,7 @@ class Launch extends FieldVersion {
|
|
|
514
514
|
for (const fk in ov.former.objectVersion.data)
|
|
515
515
|
Launch.propagateFieldChangeThroughSubscriptions(true, since, ov, fk, h, obsolete);
|
|
516
516
|
});
|
|
517
|
-
obsolete.sort(
|
|
517
|
+
obsolete.sort(compareReactionsByOrder);
|
|
518
518
|
(_a = changeset.options.journal) === null || _a === void 0 ? void 0 : _a.edited(JournalImpl.buildPatch(changeset.hint, changeset.items));
|
|
519
519
|
}
|
|
520
520
|
static revokeAllSubscriptions(changeset) {
|
|
@@ -523,10 +523,10 @@ class Launch extends FieldVersion {
|
|
|
523
523
|
ov.changes.forEach((o, fk) => Launch.propagateFieldChangeThroughSubscriptions(true, changeset.timestamp, ov, fk, h, undefined));
|
|
524
524
|
});
|
|
525
525
|
}
|
|
526
|
-
static propagateFieldChangeThroughSubscriptions(unsubscribe, timestamp, ov, fk, h,
|
|
526
|
+
static propagateFieldChangeThroughSubscriptions(unsubscribe, timestamp, ov, fk, h, collector) {
|
|
527
527
|
var _a;
|
|
528
528
|
const curr = ov.data[fk];
|
|
529
|
-
if (
|
|
529
|
+
if (collector !== undefined) {
|
|
530
530
|
const former = ov.former.objectVersion.data[fk];
|
|
531
531
|
if (former !== undefined && former instanceof FieldVersion) {
|
|
532
532
|
const why = `T${ov.changeset.id}[${ov.changeset.hint}]`;
|
|
@@ -544,9 +544,9 @@ class Launch extends FieldVersion {
|
|
|
544
544
|
else
|
|
545
545
|
former.successor = undefined;
|
|
546
546
|
}
|
|
547
|
-
(_a = former.
|
|
547
|
+
(_a = former.reactions) === null || _a === void 0 ? void 0 : _a.forEach(s => {
|
|
548
548
|
const t = s.transaction;
|
|
549
|
-
const o = t.isFinished ?
|
|
549
|
+
const o = t.isFinished ? collector : t.changeset.obsolete;
|
|
550
550
|
return s.markObsoleteDueTo(former, fk, ov.changeset, h, why, timestamp, o);
|
|
551
551
|
});
|
|
552
552
|
}
|
|
@@ -563,16 +563,16 @@ class Launch extends FieldVersion {
|
|
|
563
563
|
curr.unsubscribeFromAllTriggers();
|
|
564
564
|
}
|
|
565
565
|
}
|
|
566
|
-
else if (curr instanceof FieldVersion && curr.
|
|
566
|
+
else if (curr instanceof FieldVersion && curr.reactions) {
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
|
-
static
|
|
570
|
-
const queue = Launch.
|
|
569
|
+
static enqueueReactionsToRun(reactions) {
|
|
570
|
+
const queue = Launch.queuedReactions;
|
|
571
571
|
const isKickOff = queue.length === 0;
|
|
572
|
-
for (const r of
|
|
572
|
+
for (const r of reactions)
|
|
573
573
|
queue.push(r);
|
|
574
574
|
if (isKickOff)
|
|
575
|
-
OperationImpl.proceedWithinGivenLaunch(undefined, Launch.
|
|
575
|
+
OperationImpl.proceedWithinGivenLaunch(undefined, Launch.processQueuedReactions);
|
|
576
576
|
}
|
|
577
577
|
static migrateFieldVersion(fv, target) {
|
|
578
578
|
let result;
|
|
@@ -582,21 +582,21 @@ class Launch extends FieldVersion {
|
|
|
582
582
|
result = new FieldVersion(fv.content, fv.lastEditorChangesetId);
|
|
583
583
|
return result;
|
|
584
584
|
}
|
|
585
|
-
static
|
|
586
|
-
const queue = Launch.
|
|
585
|
+
static processQueuedReactions() {
|
|
586
|
+
const queue = Launch.queuedReactions;
|
|
587
587
|
let i = 0;
|
|
588
588
|
while (i < queue.length) {
|
|
589
589
|
const reactive = queue[i];
|
|
590
590
|
reactive.relaunchIfNotUpToDate(false, true);
|
|
591
591
|
i++;
|
|
592
592
|
}
|
|
593
|
-
Launch.
|
|
593
|
+
Launch.queuedReactions = [];
|
|
594
594
|
}
|
|
595
595
|
unsubscribeFromAllTriggers() {
|
|
596
596
|
var _a;
|
|
597
597
|
(_a = this.triggers) === null || _a === void 0 ? void 0 : _a.forEach((info, value) => {
|
|
598
598
|
var _a;
|
|
599
|
-
value.
|
|
599
|
+
value.reactions.delete(this);
|
|
600
600
|
if (Log.isOn && (Log.opt.read || ((_a = this.options.logging) === null || _a === void 0 ? void 0 : _a.read)))
|
|
601
601
|
Log.write(Log.opt.transaction && !Changeset.current().sealed ? "║" : " ", "-", `${this.hint()} is unsubscribed from ${info.memberHint}`);
|
|
602
602
|
});
|
|
@@ -613,10 +613,10 @@ class Launch extends FieldVersion {
|
|
|
613
613
|
times = existing ? existing.usageCount + 1 : 1;
|
|
614
614
|
}
|
|
615
615
|
if (this.triggers !== undefined) {
|
|
616
|
-
if (!trigger.
|
|
617
|
-
trigger.
|
|
616
|
+
if (!trigger.reactions)
|
|
617
|
+
trigger.reactions = new Set();
|
|
618
618
|
const subscription = { memberHint: Dump.snapshot2(h, ov.changeset, fk), usageCount: times };
|
|
619
|
-
trigger.
|
|
619
|
+
trigger.reactions.add(this);
|
|
620
620
|
this.triggers.set(trigger, subscription);
|
|
621
621
|
if (Log.isOn && (Log.opt.read || ((_a = this.options.logging) === null || _a === void 0 ? void 0 : _a.read)))
|
|
622
622
|
Log.write("║", " ∞", `${this.hint()} is subscribed to ${Dump.snapshot2(h, ov.changeset, fk, trigger)}${subscription.usageCount > 1 ? ` (${subscription.usageCount} times)` : ""}`);
|
|
@@ -671,7 +671,7 @@ class Launch extends FieldVersion {
|
|
|
671
671
|
Changeset.tryResolveConflict = Launch.tryResolveConflict;
|
|
672
672
|
Changeset.propagateAllChangesThroughSubscriptions = Launch.propagateAllChangesThroughSubscriptions;
|
|
673
673
|
Changeset.revokeAllSubscriptions = Launch.revokeAllSubscriptions;
|
|
674
|
-
Changeset.
|
|
674
|
+
Changeset.enqueueReactionsToRun = Launch.enqueueReactionsToRun;
|
|
675
675
|
TransactionImpl.migrateFieldVersion = Launch.migrateFieldVersion;
|
|
676
676
|
Mvcc.createOperation = Launch.createOperation;
|
|
677
677
|
Mvcc.rememberOperationOptions = Launch.rememberOperationOptions;
|
|
@@ -699,7 +699,7 @@ class Launch extends FieldVersion {
|
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
701
|
Launch.current = undefined;
|
|
702
|
-
Launch.
|
|
702
|
+
Launch.queuedReactions = [];
|
|
703
703
|
Launch.deferredReactiveOperations = [];
|
|
704
704
|
function valueHint(value) {
|
|
705
705
|
let result = "";
|
|
@@ -749,8 +749,8 @@ function reactronicHookedThen(resolve, reject) {
|
|
|
749
749
|
}
|
|
750
750
|
return ORIGINAL_PROMISE_THEN.call(this, resolve, reject);
|
|
751
751
|
}
|
|
752
|
-
function
|
|
753
|
-
return
|
|
752
|
+
function compareReactionsByOrder(r1, r2) {
|
|
753
|
+
return r1.order - r2.order;
|
|
754
754
|
}
|
|
755
755
|
export function resolveReturn(value) {
|
|
756
756
|
return value;
|
|
@@ -22,7 +22,7 @@ import { emitLetters, getCallerInfo, proceedSyncOrAsync } from "../util/Utils.js
|
|
|
22
22
|
import { Isolation, Reentrance } from "../Options.js";
|
|
23
23
|
import { TriggeringObject } from "../core/Mvcc.js";
|
|
24
24
|
import { Transaction } from "../core/Transaction.js";
|
|
25
|
-
import { ReactiveSystem, options, trigger,
|
|
25
|
+
import { ReactiveSystem, options, trigger, reaction, atomicRun, nonReactiveRun } from "../ReactiveSystem.js";
|
|
26
26
|
export var Mode;
|
|
27
27
|
(function (Mode) {
|
|
28
28
|
Mode[Mode["default"] = 0] = "default";
|
|
@@ -359,7 +359,7 @@ ReactiveNodeImpl.logging = undefined;
|
|
|
359
359
|
ReactiveNodeImpl.grandNodeCount = 0;
|
|
360
360
|
ReactiveNodeImpl.disposableNodeCount = 0;
|
|
361
361
|
__decorate([
|
|
362
|
-
|
|
362
|
+
reaction,
|
|
363
363
|
options({
|
|
364
364
|
reentrance: Reentrance.cancelAndWaitPrevious,
|
|
365
365
|
allowObsoleteToFinish: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { F } from "../util/Utils.js";
|
|
2
2
|
import { Worker } from "../Worker.js";
|
|
3
3
|
import { SnapshotOptions } from "../Options.js";
|
|
4
|
-
import { ObjectHandle, ObjectVersion,
|
|
4
|
+
import { ObjectHandle, ObjectVersion, Reaction, FieldVersion, FieldKey } from "./Data.js";
|
|
5
5
|
import { Changeset } from "./Changeset.js";
|
|
6
6
|
export declare abstract class Transaction implements Worker {
|
|
7
7
|
static get current(): Transaction;
|
|
@@ -78,7 +78,7 @@ export declare class TransactionImpl extends Transaction {
|
|
|
78
78
|
private checkForConflicts;
|
|
79
79
|
private tryResolveConflicts;
|
|
80
80
|
private applyOrDiscard;
|
|
81
|
-
applyOrDiscardChangeset(): Array<
|
|
81
|
+
applyOrDiscardChangeset(): Array<Reaction>;
|
|
82
82
|
applyObjectChanges(h: ObjectHandle, ov: ObjectVersion): void;
|
|
83
83
|
static migrateObjectChangesToAnotherTransaction(h: ObjectHandle, ov: ObjectVersion, tParent: Transaction): void;
|
|
84
84
|
static migrateFieldVersionToAnotherTransaction(h: ObjectHandle, fk: FieldKey, ov: ObjectVersion, ovParent: ObjectVersion, tParent: Transaction): void;
|
|
@@ -238,11 +238,11 @@ export class TransactionImpl extends Transaction {
|
|
|
238
238
|
finally {
|
|
239
239
|
this.pending--;
|
|
240
240
|
if (this.sealed && this.pending === 0) {
|
|
241
|
-
const
|
|
241
|
+
const obsolete = this.applyOrDiscard();
|
|
242
242
|
if (p)
|
|
243
243
|
p.runImpl(undefined, () => p.pending--);
|
|
244
244
|
TransactionImpl.gCurr = outer;
|
|
245
|
-
TransactionImpl.outside(Changeset.
|
|
245
|
+
TransactionImpl.outside(Changeset.enqueueReactionsToRun, obsolete);
|
|
246
246
|
}
|
|
247
247
|
else
|
|
248
248
|
TransactionImpl.gCurr = outer;
|
|
@@ -271,12 +271,12 @@ export class TransactionImpl extends Transaction {
|
|
|
271
271
|
throw error(`T${this.id}[${this.hint}] conflicts with: ${Dump.conflicts(conflicts)}`, undefined);
|
|
272
272
|
}
|
|
273
273
|
applyOrDiscard() {
|
|
274
|
-
let
|
|
274
|
+
let obsolete;
|
|
275
275
|
try {
|
|
276
276
|
if (Log.isOn && Log.opt.change)
|
|
277
277
|
Log.write("╠═", "", "", undefined, "changes");
|
|
278
278
|
this.changeset.seal();
|
|
279
|
-
|
|
279
|
+
obsolete = this.applyOrDiscardChangeset();
|
|
280
280
|
this.changeset.triggerGarbageCollection();
|
|
281
281
|
if (this.promise) {
|
|
282
282
|
if (this.canceled && !this.after)
|
|
@@ -291,7 +291,7 @@ export class TransactionImpl extends Transaction {
|
|
|
291
291
|
fatal(e);
|
|
292
292
|
throw e;
|
|
293
293
|
}
|
|
294
|
-
return
|
|
294
|
+
return obsolete;
|
|
295
295
|
}
|
|
296
296
|
applyOrDiscardChangeset() {
|
|
297
297
|
const error = this.canceled;
|
|
@@ -359,39 +359,39 @@ export class TransactionImpl extends Transaction {
|
|
|
359
359
|
if (fv.isLaunch) {
|
|
360
360
|
const migrated = TransactionImpl.migrateFieldVersion(fv, tParent);
|
|
361
361
|
if (ovParent.former.objectVersion.data[fk] !== fvParent) {
|
|
362
|
-
let
|
|
363
|
-
if (
|
|
364
|
-
const
|
|
365
|
-
|
|
362
|
+
let reactions = fvParent.reactions;
|
|
363
|
+
if (reactions) {
|
|
364
|
+
const migratedReactions = migrated.reactions = new Set();
|
|
365
|
+
reactions.forEach(o => {
|
|
366
366
|
const conformingTriggers = o.triggers;
|
|
367
367
|
const sub = conformingTriggers.get(fvParent);
|
|
368
368
|
conformingTriggers.delete(fvParent);
|
|
369
369
|
conformingTriggers.set(migrated, sub);
|
|
370
|
-
|
|
370
|
+
migratedReactions.add(o);
|
|
371
371
|
});
|
|
372
|
-
fvParent.
|
|
372
|
+
fvParent.reactions = undefined;
|
|
373
373
|
}
|
|
374
|
-
|
|
375
|
-
if (
|
|
376
|
-
let
|
|
377
|
-
if (
|
|
378
|
-
|
|
379
|
-
|
|
374
|
+
reactions = fv.reactions;
|
|
375
|
+
if (reactions) {
|
|
376
|
+
let migratedReactions = migrated.reactions;
|
|
377
|
+
if (migratedReactions === undefined)
|
|
378
|
+
migratedReactions = migrated.reactions = new Set();
|
|
379
|
+
reactions.forEach(o => {
|
|
380
380
|
const conformingTriggers = o.triggers;
|
|
381
381
|
const sub = conformingTriggers.get(fv);
|
|
382
382
|
conformingTriggers.delete(fv);
|
|
383
383
|
conformingTriggers.set(migrated, sub);
|
|
384
|
-
|
|
384
|
+
migratedReactions.add(o);
|
|
385
385
|
});
|
|
386
|
-
fv.
|
|
386
|
+
fv.reactions = undefined;
|
|
387
387
|
}
|
|
388
388
|
const triggers = fv.triggers;
|
|
389
389
|
const migratedTriggers = migrated.triggers;
|
|
390
390
|
if (triggers) {
|
|
391
391
|
triggers.forEach((s, o) => {
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
const conformingReactions = o.reactions;
|
|
393
|
+
conformingReactions.delete(fv);
|
|
394
|
+
conformingReactions.add(migrated);
|
|
395
395
|
migratedTriggers.set(o, s);
|
|
396
396
|
});
|
|
397
397
|
triggers.clear();
|
|
@@ -399,25 +399,25 @@ export class TransactionImpl extends Transaction {
|
|
|
399
399
|
ovParent.data[fk] = migrated;
|
|
400
400
|
}
|
|
401
401
|
else {
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
const
|
|
405
|
-
|
|
402
|
+
const reactions = fv.reactions;
|
|
403
|
+
if (reactions) {
|
|
404
|
+
const migratedReactions = migrated.reactions = new Set();
|
|
405
|
+
reactions.forEach(o => {
|
|
406
406
|
const conformingTriggers = o.triggers;
|
|
407
407
|
const sub = conformingTriggers.get(fv);
|
|
408
408
|
conformingTriggers.delete(fv);
|
|
409
409
|
conformingTriggers.set(migrated, sub);
|
|
410
|
-
|
|
410
|
+
migratedReactions.add(o);
|
|
411
411
|
});
|
|
412
|
-
fv.
|
|
412
|
+
fv.reactions = undefined;
|
|
413
413
|
}
|
|
414
414
|
const triggers = fv.triggers;
|
|
415
415
|
const migratedTriggers = migrated.triggers;
|
|
416
416
|
if (triggers) {
|
|
417
417
|
triggers.forEach((s, o) => {
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
418
|
+
const conformingReactions = o.reactions;
|
|
419
|
+
conformingReactions.delete(fv);
|
|
420
|
+
conformingReactions.add(migrated);
|
|
421
421
|
migratedTriggers.set(o, s);
|
|
422
422
|
});
|
|
423
423
|
triggers.clear();
|
|
@@ -431,16 +431,16 @@ export class TransactionImpl extends Transaction {
|
|
|
431
431
|
const parentContent = fvParent === null || fvParent === void 0 ? void 0 : fvParent.content;
|
|
432
432
|
if (ovParent.former.objectVersion.data[fk] !== fvParent) {
|
|
433
433
|
fvParent.content = fv.content;
|
|
434
|
-
const
|
|
435
|
-
if (
|
|
436
|
-
if (fvParent.
|
|
437
|
-
fvParent.
|
|
438
|
-
|
|
434
|
+
const reactions = fv.reactions;
|
|
435
|
+
if (reactions) {
|
|
436
|
+
if (fvParent.reactions === undefined)
|
|
437
|
+
fvParent.reactions = new Set();
|
|
438
|
+
reactions.forEach(o => {
|
|
439
439
|
const conformingTriggers = o.triggers;
|
|
440
440
|
const sub = conformingTriggers.get(fv);
|
|
441
441
|
conformingTriggers.delete(fv);
|
|
442
442
|
conformingTriggers.set(fvParent, sub);
|
|
443
|
-
fvParent.
|
|
443
|
+
fvParent.reactions.add(o);
|
|
444
444
|
});
|
|
445
445
|
}
|
|
446
446
|
}
|