reactronic 0.93.25021 → 0.93.25026
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/README.md +19 -18
- package/build/dist/source/Options.d.ts +2 -2
- package/build/dist/source/Options.js +2 -2
- package/build/dist/source/ReactiveLoop.js +2 -2
- package/build/dist/source/ReactiveSystem.d.ts +7 -7
- package/build/dist/source/ReactiveSystem.js +10 -10
- package/build/dist/source/Ref.d.ts +1 -1
- package/build/dist/source/Ref.js +4 -4
- package/build/dist/source/api.d.ts +2 -2
- package/build/dist/source/api.js +2 -2
- 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 +32 -32
- package/build/dist/source/core/ReactiveNode.js +10 -10
- package/build/dist/source/core/Transaction.d.ts +2 -2
- package/build/dist/source/core/Transaction.js +37 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,14 +28,15 @@ concepts:
|
|
|
28
28
|
- **Triggering Objects** - a set of objects that store
|
|
29
29
|
data of an application (state) and cause reactions
|
|
30
30
|
upon their changes;
|
|
31
|
-
- **Atomic
|
|
32
|
-
triggering objects in atomic way ("all or
|
|
33
|
-
|
|
31
|
+
- **Atomic Block** - a code block that makes changes
|
|
32
|
+
in triggering objects in atomic way ("all or
|
|
33
|
+
nothing");
|
|
34
|
+
- **Reaction** - a function that is
|
|
34
35
|
(re-)executed in response to changes made in
|
|
35
36
|
triggering objects by atomic actions;
|
|
36
|
-
- **
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
- **Cache** - a function which result is remembered
|
|
38
|
+
and, if becomes obsolete, causes function to
|
|
39
|
+
re-execute on-demand.
|
|
39
40
|
|
|
40
41
|
Demo application built with Reactronic: https://nevod.io/#/playground.
|
|
41
42
|
Source code of the demo: https://gitlab.com/nezaboodka/nevod.web.public/-/blob/master/README.md.
|
|
@@ -57,7 +58,7 @@ class Demo extends TriggeringObject {
|
|
|
57
58
|
this.email = email
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
@
|
|
61
|
+
@reaction
|
|
61
62
|
printContact(): void {
|
|
62
63
|
// depends on `name` and `email` and reacts to their changes
|
|
63
64
|
if (this.email.indexOf('@') >= 0)
|
|
@@ -83,12 +84,12 @@ class Demo extends TriggeringObject {
|
|
|
83
84
|
name: string = 'Nezaboodka Software'
|
|
84
85
|
email: string = 'contact@nezaboodka.com'
|
|
85
86
|
|
|
86
|
-
@
|
|
87
|
+
@cache
|
|
87
88
|
get contact(): string {
|
|
88
89
|
return this.name + ' <' + this.email + '>'
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
@
|
|
92
|
+
@reaction
|
|
92
93
|
printContact(): void {
|
|
93
94
|
if (this.contact !== '')
|
|
94
95
|
Console.log(this.contact)
|
|
@@ -192,7 +193,7 @@ execution.
|
|
|
192
193
|
|
|
193
194
|
``` tsx
|
|
194
195
|
class MyView extends Component<{model: MyModel}> {
|
|
195
|
-
@
|
|
196
|
+
@cache
|
|
196
197
|
render(): React.JSX.Element {
|
|
197
198
|
return (
|
|
198
199
|
<div>
|
|
@@ -206,12 +207,12 @@ class MyView extends Component<{model: MyModel}> {
|
|
|
206
207
|
|
|
207
208
|
``` tsx
|
|
208
209
|
class Component<P> extends React.Component<P> {
|
|
209
|
-
@
|
|
210
|
+
@cache
|
|
210
211
|
render(): React.JSX.Element {
|
|
211
212
|
throw new Error('render method is undefined')
|
|
212
213
|
}
|
|
213
214
|
|
|
214
|
-
@
|
|
215
|
+
@reaction // called in response to changes
|
|
215
216
|
ensureUpToDate(): void {
|
|
216
217
|
if (this.shouldComponentUpdate()) {
|
|
217
218
|
// Ask React to re-render
|
|
@@ -330,12 +331,12 @@ class TriggeringObject { }
|
|
|
330
331
|
function trigger(boolean) // field only
|
|
331
332
|
function trigger(proto, prop) // field only
|
|
332
333
|
function atomic(proto, prop, pd) // method only
|
|
333
|
-
function
|
|
334
|
-
function
|
|
334
|
+
function reaction(proto, prop, pd) // method only
|
|
335
|
+
function cache(proto, prop, pd) // method only
|
|
335
336
|
function options(value: Partial<MemberOptions>): F<any>
|
|
336
337
|
|
|
337
|
-
function
|
|
338
|
-
function
|
|
338
|
+
function runNonReactively<T>(func: F<T>, ...args: any[]): T
|
|
339
|
+
function runSensitively<T>(sensitivity: Sensitivity, func: F<T>, ...args: any[]): T
|
|
339
340
|
|
|
340
341
|
// SnapshotOptions, MemberOptions, Kind, Reentrance, Indicator, LoggingOptions, ProfilingOptions
|
|
341
342
|
|
|
@@ -363,8 +364,8 @@ type MemberOptions = {
|
|
|
363
364
|
enum Kind {
|
|
364
365
|
plain = 0,
|
|
365
366
|
atomic = 1,
|
|
366
|
-
|
|
367
|
-
|
|
367
|
+
reaction = 2,
|
|
368
|
+
cache = 3
|
|
368
369
|
}
|
|
369
370
|
|
|
370
371
|
enum Reentrance {
|
|
@@ -3,8 +3,8 @@ export var Kind;
|
|
|
3
3
|
(function (Kind) {
|
|
4
4
|
Kind[Kind["plain"] = 0] = "plain";
|
|
5
5
|
Kind[Kind["atomic"] = 1] = "atomic";
|
|
6
|
-
Kind[Kind["
|
|
7
|
-
Kind[Kind["
|
|
6
|
+
Kind[Kind["reaction"] = 2] = "reaction";
|
|
7
|
+
Kind[Kind["cache"] = 3] = "cache";
|
|
8
8
|
})(Kind || (Kind = {}));
|
|
9
9
|
export var Reentrance;
|
|
10
10
|
(function (Reentrance) {
|
|
@@ -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)
|
|
@@ -17,14 +17,14 @@ export declare class ReactiveSystem {
|
|
|
17
17
|
static getLoggingHint<T extends object>(obj: T, full?: boolean): string | undefined;
|
|
18
18
|
static setProfilingMode(isOn: boolean, options?: Partial<ProfilingOptions>): void;
|
|
19
19
|
}
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
20
|
+
export declare function runAtomically<T>(func: F<T>, ...args: any[]): T;
|
|
21
|
+
export declare function runAtomically<T>(options: SnapshotOptions, func: F<T>, ...args: any[]): T;
|
|
22
|
+
export declare function runNonReactively<T>(func: F<T>, ...args: any[]): T;
|
|
23
|
+
export declare function runSensitively<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
24
|
+
export declare function runContextually<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
27
|
export declare function atomic(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
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>;
|
|
@@ -22,7 +22,7 @@ export class ReactiveSystem {
|
|
|
22
22
|
static getLoggingHint(obj, full = false) { return ObjectHandle.getHint(obj, full); }
|
|
23
23
|
static setProfilingMode(isOn, options) { Mvcc.setProfilingMode(isOn, options); }
|
|
24
24
|
}
|
|
25
|
-
export function
|
|
25
|
+
export function runAtomically(p1, p2, p3) {
|
|
26
26
|
if (p1 instanceof Function) {
|
|
27
27
|
if (p2 !== undefined)
|
|
28
28
|
return Transaction.run(null, p1, ...p2);
|
|
@@ -36,13 +36,13 @@ export function atomicRun(p1, p2, p3) {
|
|
|
36
36
|
return Transaction.run(p1, p2);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
export function
|
|
39
|
+
export function runNonReactively(func, ...args) {
|
|
40
40
|
return OperationImpl.proceedWithinGivenLaunch(undefined, func, ...args);
|
|
41
41
|
}
|
|
42
|
-
export function
|
|
42
|
+
export function runSensitively(sensitivity, func, ...args) {
|
|
43
43
|
return Mvcc.sensitive(sensitivity, func, ...args);
|
|
44
44
|
}
|
|
45
|
-
export function
|
|
45
|
+
export function runContextually(p) {
|
|
46
46
|
throw new Error("not implemented yet");
|
|
47
47
|
}
|
|
48
48
|
export function trigger(protoOrEnabled, prop) {
|
|
@@ -61,21 +61,21 @@ export function atomic(proto, prop, pd) {
|
|
|
61
61
|
};
|
|
62
62
|
return Mvcc.decorateOperation(true, atomic, opts, proto, prop, pd);
|
|
63
63
|
}
|
|
64
|
-
export function
|
|
64
|
+
export function reaction(proto, prop, pd) {
|
|
65
65
|
const opts = {
|
|
66
|
-
kind: Kind.
|
|
66
|
+
kind: Kind.reaction,
|
|
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
|
-
kind: Kind.
|
|
74
|
+
kind: Kind.cache,
|
|
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);
|
|
@@ -27,7 +27,7 @@ export declare class Ref<T = any> {
|
|
|
27
27
|
constructor(owner: any, name: string, index?: number);
|
|
28
28
|
get variable(): T;
|
|
29
29
|
set variable(value: T);
|
|
30
|
-
|
|
30
|
+
nonReactively(): T;
|
|
31
31
|
observe(): T;
|
|
32
32
|
unobserve(): T;
|
|
33
33
|
static sameRefs(v1: Ref, v2: Ref): boolean;
|
package/build/dist/source/Ref.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runAtomically, runNonReactively } from "./ReactiveSystem.js";
|
|
2
2
|
export function refs(owner) {
|
|
3
3
|
return new Proxy(owner, RefGettingProxy);
|
|
4
4
|
}
|
|
@@ -27,8 +27,8 @@ export class Ref {
|
|
|
27
27
|
else
|
|
28
28
|
this.owner[this.name][this.index] = value;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
return
|
|
30
|
+
nonReactively() {
|
|
31
|
+
return runNonReactively(() => this.variable);
|
|
32
32
|
}
|
|
33
33
|
observe() {
|
|
34
34
|
return this.variable;
|
|
@@ -52,7 +52,7 @@ export class ToggleRef extends Ref {
|
|
|
52
52
|
toggle() {
|
|
53
53
|
const o = this.owner;
|
|
54
54
|
const p = this.name;
|
|
55
|
-
|
|
55
|
+
runAtomically({ hint: `toggle ${o.constructor.name}.${p}` }, () => {
|
|
56
56
|
const v = o[p];
|
|
57
57
|
const isOn = v === this.valueOn || (v instanceof Ref && this.valueOn instanceof Ref &&
|
|
58
58
|
Ref.sameRefs(v, this.valueOn));
|
|
@@ -16,8 +16,8 @@ export { Changeset } from "./core/Changeset.js";
|
|
|
16
16
|
export { Transaction } from "./core/Transaction.js";
|
|
17
17
|
export { Indicator } from "./core/Indicator.js";
|
|
18
18
|
export { Journal } from "./core/Journal.js";
|
|
19
|
-
export {
|
|
20
|
-
export { ReactiveSystem, trigger, atomic,
|
|
19
|
+
export { runAtomically, runNonReactively, runSensitively, runContextually } from "./ReactiveSystem.js";
|
|
20
|
+
export { ReactiveSystem, trigger, atomic, 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
|
@@ -12,7 +12,7 @@ export { Changeset } from "./core/Changeset.js";
|
|
|
12
12
|
export { Transaction } from "./core/Transaction.js";
|
|
13
13
|
export { Indicator } from "./core/Indicator.js";
|
|
14
14
|
export { Journal } from "./core/Journal.js";
|
|
15
|
-
export {
|
|
16
|
-
export { ReactiveSystem, trigger, atomic,
|
|
15
|
+
export { runAtomically, runNonReactively, runSensitively, runContextually } from "./ReactiveSystem.js";
|
|
16
|
+
export { ReactiveSystem, trigger, atomic, 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,25 +287,25 @@ 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 &&
|
|
294
294
|
changeset.id === this.lastEditorChangesetId;
|
|
295
295
|
if (!skip) {
|
|
296
296
|
const why = `${Dump.snapshot2(h, changeset, fk, trigger)} ◀◀ ${outer}`;
|
|
297
|
-
const
|
|
297
|
+
const isReaction = this.options.kind === Kind.reaction;
|
|
298
298
|
this.obsoleteDueTo = why;
|
|
299
299
|
this.obsoleteSince = since;
|
|
300
300
|
if (Log.isOn && (Log.opt.obsolete || ((_a = this.options.logging) === null || _a === void 0 ? void 0 : _a.obsolete)))
|
|
301
|
-
Log.write(Log.opt.transaction && !Changeset.current().sealed ? "║" : " ",
|
|
301
|
+
Log.write(Log.opt.transaction && !Changeset.current().sealed ? "║" : " ", isReaction ? "█" : "▒", isReaction && changeset === EMPTY_OBJECT_VERSION.changeset
|
|
302
302
|
? `${this.hint()} is reactive and will run automatically (order ${this.options.order})`
|
|
303
|
-
: `${this.hint()} is obsolete due to ${Dump.snapshot2(h, changeset, fk)} since s${since}${
|
|
303
|
+
: `${this.hint()} is obsolete due to ${Dump.snapshot2(h, changeset, fk)} since s${since}${isReaction ? ` and will run automatically (order ${this.options.order})` : ""}`);
|
|
304
304
|
this.unsubscribeFromAllTriggers();
|
|
305
|
-
if (
|
|
306
|
-
|
|
305
|
+
if (isReaction)
|
|
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
|
}
|
|
@@ -326,14 +326,14 @@ class Launch extends FieldVersion {
|
|
|
326
326
|
const launch = this.operation.reuseOrRelaunch(false, undefined);
|
|
327
327
|
if (launch.result instanceof Promise)
|
|
328
328
|
launch.result.catch(error => {
|
|
329
|
-
if (launch.options.kind === Kind.
|
|
329
|
+
if (launch.options.kind === Kind.reaction)
|
|
330
330
|
misuse(`reactive function ${launch.hint()} failed and will not run anymore: ${error}`, error);
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
catch (e) {
|
|
334
334
|
if (!nothrow)
|
|
335
335
|
throw e;
|
|
336
|
-
else if (this.options.kind === Kind.
|
|
336
|
+
else if (this.options.kind === Kind.reaction)
|
|
337
337
|
misuse(`reactive ${this.hint()} failed and will not run anymore: ${e}`, e);
|
|
338
338
|
}
|
|
339
339
|
}
|
|
@@ -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)` : ""}`);
|
|
@@ -652,11 +652,11 @@ class Launch extends FieldVersion {
|
|
|
652
652
|
const rx = launch ? launch.operation : new OperationImpl(EMPTY_HANDLE, fk);
|
|
653
653
|
const opts = launch ? launch.options : OptionsImpl.INITIAL;
|
|
654
654
|
initial[fk] = launch = new Launch(Transaction.current, rx, EMPTY_OBJECT_VERSION.changeset, new OptionsImpl(getter, setter, opts, options, implicit), false);
|
|
655
|
-
if (launch.options.kind === Kind.
|
|
655
|
+
if (launch.options.kind === Kind.reaction && launch.options.throttling < Number.MAX_SAFE_INTEGER) {
|
|
656
656
|
const reactive = Meta.acquire(proto, Meta.Reactive);
|
|
657
657
|
reactive[fk] = launch;
|
|
658
658
|
}
|
|
659
|
-
else if (launch.options.kind === Kind.
|
|
659
|
+
else if (launch.options.kind === Kind.reaction && launch.options.throttling >= Number.MAX_SAFE_INTEGER) {
|
|
660
660
|
const reactive = Meta.getFrom(proto, Meta.Reactive);
|
|
661
661
|
delete reactive[fk];
|
|
662
662
|
}
|
|
@@ -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, runAtomically, runNonReactively } from "../ReactiveSystem.js";
|
|
26
26
|
export var Mode;
|
|
27
27
|
(function (Mode) {
|
|
28
28
|
Mode[Mode["default"] = 0] = "default";
|
|
@@ -333,13 +333,13 @@ class ReactiveNodeImpl extends ReactiveNode {
|
|
|
333
333
|
static setNodeVariableValue(variable, value) {
|
|
334
334
|
const node = ReactiveNodeImpl.nodeSlot.instance;
|
|
335
335
|
const owner = node.owner;
|
|
336
|
-
const hostCtx =
|
|
336
|
+
const hostCtx = runNonReactively(() => { var _a; return (_a = owner.context) === null || _a === void 0 ? void 0 : _a.value; });
|
|
337
337
|
if (value && value !== hostCtx) {
|
|
338
338
|
if (hostCtx)
|
|
339
339
|
node.outer = owner;
|
|
340
340
|
else
|
|
341
341
|
node.outer = owner.outer;
|
|
342
|
-
|
|
342
|
+
runAtomically({ isolation: Isolation.joinAsNestedTransaction }, () => {
|
|
343
343
|
const ctx = node.context;
|
|
344
344
|
if (ctx) {
|
|
345
345
|
ctx.variable = variable;
|
|
@@ -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,
|
|
@@ -484,18 +484,18 @@ function triggerScriptRunViaSlot(nodeSlot) {
|
|
|
484
484
|
});
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
|
-
|
|
487
|
+
runNonReactively(node.script, node.declaration.triggers);
|
|
488
488
|
}
|
|
489
489
|
else if (node.owner !== node)
|
|
490
490
|
runScriptNow(nodeSlot);
|
|
491
491
|
else
|
|
492
|
-
|
|
492
|
+
runAtomically(() => runScriptNow(nodeSlot));
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
495
|
function mountOrRemountIfNecessary(node) {
|
|
496
496
|
const driver = node.driver;
|
|
497
497
|
if (node.stamp === Number.MAX_SAFE_INTEGER) {
|
|
498
|
-
|
|
498
|
+
runNonReactively(() => {
|
|
499
499
|
node.stamp = Number.MAX_SAFE_INTEGER - 1;
|
|
500
500
|
driver.runPreparation(node);
|
|
501
501
|
if (!node.has(Mode.manualMount)) {
|
|
@@ -506,7 +506,7 @@ function mountOrRemountIfNecessary(node) {
|
|
|
506
506
|
});
|
|
507
507
|
}
|
|
508
508
|
else if (node.isMoved && !node.has(Mode.manualMount) && node.host !== node)
|
|
509
|
-
|
|
509
|
+
runNonReactively(() => driver.runMount(node));
|
|
510
510
|
}
|
|
511
511
|
function runScriptNow(nodeSlot) {
|
|
512
512
|
const node = nodeSlot.instance;
|
|
@@ -539,7 +539,7 @@ function triggerFinalization(nodeSlot, isLeader, individual) {
|
|
|
539
539
|
if (individual && node.key !== node.declaration.key && !driver.isPartition)
|
|
540
540
|
console.log(`WARNING: it is recommended to assign explicit key for conditional element in order to avoid unexpected side effects: ${node.key}`);
|
|
541
541
|
node.stamp = ~node.stamp;
|
|
542
|
-
const childrenAreLeaders =
|
|
542
|
+
const childrenAreLeaders = runNonReactively(() => driver.runFinalization(node, isLeader));
|
|
543
543
|
if (node.has(Mode.autonomous)) {
|
|
544
544
|
nodeSlot.aux = undefined;
|
|
545
545
|
const last = gLastToDispose;
|
|
@@ -548,7 +548,7 @@ function triggerFinalization(nodeSlot, isLeader, individual) {
|
|
|
548
548
|
else
|
|
549
549
|
gFirstToDispose = gLastToDispose = nodeSlot;
|
|
550
550
|
if (gFirstToDispose === nodeSlot)
|
|
551
|
-
|
|
551
|
+
runAtomically({ isolation: Isolation.disjoinForInternalDisposal, hint: `runDisposalLoop(initiator=${nodeSlot.instance.key})` }, () => {
|
|
552
552
|
void runDisposalLoop().then(NOP, error => console.log(error));
|
|
553
553
|
});
|
|
554
554
|
}
|
|
@@ -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
|
}
|