reactronic 0.21.528 → 0.21.602
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 +2 -2
- package/build/dist/source/Ref.d.ts +2 -2
- package/build/dist/source/Ref.js +2 -2
- package/build/dist/source/{Reactronic.d.ts → Rx.d.ts} +1 -1
- package/build/dist/source/{Reactronic.js → Rx.js} +4 -4
- package/build/dist/source/api.d.ts +1 -1
- package/build/dist/source/api.js +11 -11
- package/build/dist/source/impl/Data.d.ts +1 -1
- package/build/dist/source/impl/Data.js +1 -1
- package/build/dist/source/impl/Operation.d.ts +2 -1
- package/build/dist/source/impl/Operation.js +34 -22
- package/build/dist/source/impl/Snapshot.d.ts +4 -4
- package/build/dist/source/impl/Snapshot.js +9 -6
- package/build/dist/source/impl/Transaction.js +5 -3
- package/build/dist/source/util/Utils.d.ts +2 -2
- package/build/dist/source/util/Utils.js +2 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -200,7 +200,7 @@ class Component<P> extends React.Component<P> {
|
|
|
200
200
|
} // ensureUpToDate is subscribed to render
|
|
201
201
|
|
|
202
202
|
shouldComponentUpdate(): boolean {
|
|
203
|
-
return !
|
|
203
|
+
return !Rx.getController(this.render).isUpToDate
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
componentDidMount(): void {
|
|
@@ -208,7 +208,7 @@ class Component<P> extends React.Component<P> {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
componentWillUnmount(): void {
|
|
211
|
-
standalone(
|
|
211
|
+
standalone(Rx.dispose, this)
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
```
|
|
@@ -14,10 +14,10 @@ export declare class Ref<T = any> {
|
|
|
14
14
|
nonreactiveValue(): T;
|
|
15
15
|
observe(): T;
|
|
16
16
|
unobserve(): T;
|
|
17
|
-
static to<O =
|
|
17
|
+
static to<O extends object = object>(owner: O): {
|
|
18
18
|
readonly [P in keyof O]-?: Ref<O[P]>;
|
|
19
19
|
};
|
|
20
|
-
static toToggle<O =
|
|
20
|
+
static toToggle<O extends object = object>(owner: O): {
|
|
21
21
|
readonly [P in keyof BoolOnly<O>]: ToggleRef<O[P]>;
|
|
22
22
|
};
|
|
23
23
|
static toCustomToggle<T, O extends object = any>(owner: O, value1: T, value2: T): {
|
package/build/dist/source/Ref.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ToggleRef = exports.Ref = void 0;
|
|
4
4
|
const Transaction_1 = require("./impl/Transaction");
|
|
5
|
-
const
|
|
5
|
+
const Rx_1 = require("./Rx");
|
|
6
6
|
class Ref {
|
|
7
7
|
constructor(owner, name, index = -1) {
|
|
8
8
|
this.owner = owner;
|
|
@@ -22,7 +22,7 @@ class Ref {
|
|
|
22
22
|
this.owner[this.name][this.index] = value;
|
|
23
23
|
}
|
|
24
24
|
nonreactiveValue() {
|
|
25
|
-
return (0,
|
|
25
|
+
return (0, Rx_1.nonreactive)(() => this.value);
|
|
26
26
|
}
|
|
27
27
|
observe() {
|
|
28
28
|
return this.value;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { F } from './util/Utils';
|
|
2
2
|
import { Controller } from './Controller';
|
|
3
3
|
import { MemberOptions, TraceOptions, ProfilingOptions } from './Options';
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class Rx {
|
|
5
5
|
static why(brief?: boolean): string;
|
|
6
6
|
static getController<T>(method: F<T>): Controller<T>;
|
|
7
7
|
static pullLastResult<T>(method: F<Promise<T>>, args?: any[]): T | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.options = exports.cached = exports.reaction = exports.transaction = exports.unobservable = exports.sensitive = exports.standalone = exports.nonreactive = exports.
|
|
3
|
+
exports.options = exports.cached = exports.reaction = exports.transaction = exports.unobservable = exports.sensitive = exports.standalone = exports.nonreactive = exports.Rx = void 0;
|
|
4
4
|
const Dbg_1 = require("./util/Dbg");
|
|
5
5
|
const Options_1 = require("./Options");
|
|
6
6
|
const Data_1 = require("./impl/Data");
|
|
@@ -8,10 +8,10 @@ const Snapshot_1 = require("./impl/Snapshot");
|
|
|
8
8
|
const Hooks_1 = require("./impl/Hooks");
|
|
9
9
|
const Operation_1 = require("./impl/Operation");
|
|
10
10
|
const Transaction_1 = require("./impl/Transaction");
|
|
11
|
-
class
|
|
11
|
+
class Rx {
|
|
12
12
|
static why(brief = false) { return brief ? Operation_1.OperationController.briefWhy() : Operation_1.OperationController.why(); }
|
|
13
13
|
static getController(method) { return Operation_1.OperationController.of(method); }
|
|
14
|
-
static pullLastResult(method, args) { return
|
|
14
|
+
static pullLastResult(method, args) { return Rx.getController(method).pullLastResult(args); }
|
|
15
15
|
static configureCurrentOperation(options) { return Operation_1.OperationController.configureImpl(undefined, options); }
|
|
16
16
|
static takeSnapshot(obj) { return Snapshot_1.Snapshot.takeSnapshot(obj); }
|
|
17
17
|
static dispose(obj) { Snapshot_1.Snapshot.dispose(obj); }
|
|
@@ -24,7 +24,7 @@ class Reactronic {
|
|
|
24
24
|
static getTraceHint(obj, full = false) { return Data_1.ObjectHolder.getHint(obj, full); }
|
|
25
25
|
static setProfilingMode(enabled, options) { Hooks_1.Hooks.setProfilingMode(enabled, options); }
|
|
26
26
|
}
|
|
27
|
-
exports.
|
|
27
|
+
exports.Rx = Rx;
|
|
28
28
|
function nonreactive(func, ...args) {
|
|
29
29
|
return Operation_1.OperationController.runWithin(undefined, func, ...args);
|
|
30
30
|
}
|
|
@@ -11,4 +11,4 @@ export { Snapshot } from './impl/Snapshot';
|
|
|
11
11
|
export { Transaction } from './impl/Transaction';
|
|
12
12
|
export { Monitor } from './impl/Monitor';
|
|
13
13
|
export { TransactionJournal } from './impl/TransactionJournal';
|
|
14
|
-
export {
|
|
14
|
+
export { Rx, nonreactive, standalone, sensitive, unobservable, transaction, reaction, cached, options } from './Rx';
|
package/build/dist/source/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.options = exports.cached = exports.reaction = exports.transaction = exports.unobservable = exports.sensitive = exports.standalone = exports.nonreactive = exports.
|
|
3
|
+
exports.options = exports.cached = exports.reaction = exports.transaction = exports.unobservable = exports.sensitive = exports.standalone = exports.nonreactive = exports.Rx = exports.TransactionJournal = exports.Monitor = exports.Transaction = exports.Snapshot = exports.ObservableObject = exports.ToggleRef = exports.Ref = exports.Controller = exports.TraceLevel = exports.Reentrance = exports.Kind = exports.SealedSet = exports.SealedMap = exports.SealedArray = exports.pause = exports.all = void 0;
|
|
4
4
|
var Utils_1 = require("./util/Utils");
|
|
5
5
|
Object.defineProperty(exports, "all", { enumerable: true, get: function () { return Utils_1.all; } });
|
|
6
6
|
Object.defineProperty(exports, "pause", { enumerable: true, get: function () { return Utils_1.pause; } });
|
|
@@ -29,13 +29,13 @@ var Monitor_1 = require("./impl/Monitor");
|
|
|
29
29
|
Object.defineProperty(exports, "Monitor", { enumerable: true, get: function () { return Monitor_1.Monitor; } });
|
|
30
30
|
var TransactionJournal_1 = require("./impl/TransactionJournal");
|
|
31
31
|
Object.defineProperty(exports, "TransactionJournal", { enumerable: true, get: function () { return TransactionJournal_1.TransactionJournal; } });
|
|
32
|
-
var
|
|
33
|
-
Object.defineProperty(exports, "
|
|
34
|
-
Object.defineProperty(exports, "nonreactive", { enumerable: true, get: function () { return
|
|
35
|
-
Object.defineProperty(exports, "standalone", { enumerable: true, get: function () { return
|
|
36
|
-
Object.defineProperty(exports, "sensitive", { enumerable: true, get: function () { return
|
|
37
|
-
Object.defineProperty(exports, "unobservable", { enumerable: true, get: function () { return
|
|
38
|
-
Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return
|
|
39
|
-
Object.defineProperty(exports, "reaction", { enumerable: true, get: function () { return
|
|
40
|
-
Object.defineProperty(exports, "cached", { enumerable: true, get: function () { return
|
|
41
|
-
Object.defineProperty(exports, "options", { enumerable: true, get: function () { return
|
|
32
|
+
var Rx_1 = require("./Rx");
|
|
33
|
+
Object.defineProperty(exports, "Rx", { enumerable: true, get: function () { return Rx_1.Rx; } });
|
|
34
|
+
Object.defineProperty(exports, "nonreactive", { enumerable: true, get: function () { return Rx_1.nonreactive; } });
|
|
35
|
+
Object.defineProperty(exports, "standalone", { enumerable: true, get: function () { return Rx_1.standalone; } });
|
|
36
|
+
Object.defineProperty(exports, "sensitive", { enumerable: true, get: function () { return Rx_1.sensitive; } });
|
|
37
|
+
Object.defineProperty(exports, "unobservable", { enumerable: true, get: function () { return Rx_1.unobservable; } });
|
|
38
|
+
Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return Rx_1.transaction; } });
|
|
39
|
+
Object.defineProperty(exports, "reaction", { enumerable: true, get: function () { return Rx_1.reaction; } });
|
|
40
|
+
Object.defineProperty(exports, "cached", { enumerable: true, get: function () { return Rx_1.cached; } });
|
|
41
|
+
Object.defineProperty(exports, "options", { enumerable: true, get: function () { return Rx_1.options; } });
|
|
@@ -33,7 +33,7 @@ export declare class ObjectRevision {
|
|
|
33
33
|
revision: ObjectRevision;
|
|
34
34
|
};
|
|
35
35
|
readonly data: any;
|
|
36
|
-
readonly changes:
|
|
36
|
+
readonly changes: Set<MemberName>;
|
|
37
37
|
readonly conflicts: Map<MemberName, ObjectRevision>;
|
|
38
38
|
constructor(snapshot: AbstractSnapshot, prev: ObjectRevision | undefined, data: object);
|
|
39
39
|
}
|
|
@@ -79,7 +79,8 @@ declare class Operation extends Observable implements Observer {
|
|
|
79
79
|
private static propagateAllChangesThroughSubscriptions;
|
|
80
80
|
private static revokeAllSubscriptions;
|
|
81
81
|
private static propagateMemberChangeThroughSubscriptions;
|
|
82
|
-
private static
|
|
82
|
+
private static enqueueReactionsToRun;
|
|
83
|
+
private static runQueuedReactionsLoop;
|
|
83
84
|
private unsubscribeFromAllObservables;
|
|
84
85
|
private subscribeTo;
|
|
85
86
|
private static canSubscribe;
|
|
@@ -102,7 +102,7 @@ class OperationController extends Controller_1.Controller {
|
|
|
102
102
|
}
|
|
103
103
|
static dependencies() {
|
|
104
104
|
const op = Operation.current;
|
|
105
|
-
return op ? op.dependencies() : ['
|
|
105
|
+
return op ? op.dependencies() : ['Rx.dependencies should be called from inside of reactive method'];
|
|
106
106
|
}
|
|
107
107
|
peek(args) {
|
|
108
108
|
const ctx = Snapshot_1.Snapshot.current();
|
|
@@ -269,7 +269,10 @@ class Operation extends Data_1.Observable {
|
|
|
269
269
|
markObsoleteDueTo(observable, cause, since, reactions) {
|
|
270
270
|
var _a, _b, _c;
|
|
271
271
|
if (this.observables !== undefined) {
|
|
272
|
-
|
|
272
|
+
const skip = !observable.isOperation &&
|
|
273
|
+
cause.revision.snapshot === this.revision.snapshot &&
|
|
274
|
+
cause.revision.changes.has(cause.memberName);
|
|
275
|
+
if (!skip) {
|
|
273
276
|
this.unsubscribeFromAllObservables();
|
|
274
277
|
this.obsoleteDueTo = cause;
|
|
275
278
|
this.obsoleteSince = since;
|
|
@@ -407,6 +410,7 @@ class Operation extends Data_1.Observable {
|
|
|
407
410
|
Dbg_1.Dbg.log('║', `${op}`, `${this.hint()} ${message}`, ms, highlight);
|
|
408
411
|
if (ms > (main ? Hooks_1.Hooks.mainThreadBlockingWarningThreshold : Hooks_1.Hooks.asyncActionDurationWarningThreshold))
|
|
409
412
|
Dbg_1.Dbg.log('', '[!]', this.why(), ms, main ? ' *** main thread is too busy ***' : ' *** async is too long ***');
|
|
413
|
+
this.cause = undefined;
|
|
410
414
|
if (this.options.monitor)
|
|
411
415
|
this.monitorLeave(this.options.monitor);
|
|
412
416
|
}
|
|
@@ -456,7 +460,7 @@ class Operation extends Data_1.Observable {
|
|
|
456
460
|
}
|
|
457
461
|
}
|
|
458
462
|
static markEdited(oldValue, newValue, edited, r, m, h) {
|
|
459
|
-
edited ? r.changes.
|
|
463
|
+
edited ? r.changes.add(m) : r.changes.delete(m);
|
|
460
464
|
if (Dbg_1.Dbg.isOn && Dbg_1.Dbg.trace.write)
|
|
461
465
|
edited ? Dbg_1.Dbg.log('║', ' ✎', `${Snapshot_1.Dump.rev(r, m)} is changed from ${valueHint(oldValue, m)} to ${valueHint(newValue, m)}`) : Dbg_1.Dbg.log('║', ' ✎', `${Snapshot_1.Dump.rev(r, m)} is changed from ${valueHint(oldValue, m)} to ${valueHint(newValue, m)}`, undefined, ' (same as previous)');
|
|
462
466
|
}
|
|
@@ -483,21 +487,26 @@ class Operation extends Data_1.Observable {
|
|
|
483
487
|
static revokeAllSubscriptions(snapshot) {
|
|
484
488
|
snapshot.changeset.forEach((r, h) => r.changes.forEach((o, m) => Operation.propagateMemberChangeThroughSubscriptions(true, snapshot.timestamp, r, m, h, undefined)));
|
|
485
489
|
}
|
|
486
|
-
static propagateMemberChangeThroughSubscriptions(
|
|
490
|
+
static propagateMemberChangeThroughSubscriptions(unsubscribe, timestamp, r, m, h, reactions) {
|
|
487
491
|
var _a;
|
|
492
|
+
const curr = r.data[m];
|
|
488
493
|
if (reactions) {
|
|
489
494
|
const prev = r.prev.revision.data[m];
|
|
490
495
|
if (prev !== undefined && prev instanceof Data_1.Observable) {
|
|
491
496
|
const cause = { revision: r, memberName: m, usageCount: 0 };
|
|
492
|
-
if (prev instanceof Operation
|
|
493
|
-
prev.
|
|
494
|
-
|
|
495
|
-
|
|
497
|
+
if (prev instanceof Operation) {
|
|
498
|
+
if ((prev.obsoleteSince === Snapshot_1.MAX_TIMESTAMP || prev.obsoleteSince <= 0)) {
|
|
499
|
+
prev.obsoleteDueTo = cause;
|
|
500
|
+
prev.obsoleteSince = timestamp;
|
|
501
|
+
prev.unsubscribeFromAllObservables();
|
|
502
|
+
}
|
|
503
|
+
const opponent = prev.successor;
|
|
504
|
+
if (opponent !== curr && opponent && !opponent.transaction.isFinished)
|
|
505
|
+
opponent.transaction.cancel(new Error(`T${opponent.transaction.id}[${opponent.transaction.hint}] is canceled by T${r.snapshot.id}[${r.snapshot.hint}] and will not run anymore`), null);
|
|
496
506
|
}
|
|
497
507
|
(_a = prev.observers) === null || _a === void 0 ? void 0 : _a.forEach(c => c.markObsoleteDueTo(prev, cause, timestamp, reactions));
|
|
498
508
|
}
|
|
499
509
|
}
|
|
500
|
-
const curr = r.data[m];
|
|
501
510
|
if (curr instanceof Operation) {
|
|
502
511
|
if (curr.revision === r && curr.observables !== undefined) {
|
|
503
512
|
if (Hooks_1.Hooks.repetitiveUsageWarningThreshold < Number.MAX_SAFE_INTEGER) {
|
|
@@ -506,7 +515,7 @@ class Operation extends Data_1.Observable {
|
|
|
506
515
|
Dbg_1.Dbg.log('', '[!]', `${curr.hint()} uses ${Snapshot_1.Dump.rev(hint.revision, hint.memberName)} ${hint.usageCount} times (consider remembering it in a local variable)`, 0, ' *** WARNING ***');
|
|
507
516
|
});
|
|
508
517
|
}
|
|
509
|
-
if (
|
|
518
|
+
if (unsubscribe)
|
|
510
519
|
curr.unsubscribeFromAllObservables();
|
|
511
520
|
}
|
|
512
521
|
}
|
|
@@ -519,20 +528,23 @@ class Operation extends Data_1.Observable {
|
|
|
519
528
|
curr.observers = undefined;
|
|
520
529
|
}
|
|
521
530
|
}
|
|
522
|
-
static
|
|
531
|
+
static enqueueReactionsToRun(reactions) {
|
|
523
532
|
const queue = Operation.queuedReactions;
|
|
524
|
-
const
|
|
525
|
-
for (const r of
|
|
533
|
+
const isReactionLoopRequired = queue.length === 0;
|
|
534
|
+
for (const r of reactions)
|
|
526
535
|
queue.push(r);
|
|
527
|
-
if (
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
536
|
+
if (isReactionLoopRequired)
|
|
537
|
+
OperationController.runWithin(undefined, Operation.runQueuedReactionsLoop);
|
|
538
|
+
}
|
|
539
|
+
static runQueuedReactionsLoop() {
|
|
540
|
+
const queue = Operation.queuedReactions;
|
|
541
|
+
let i = 0;
|
|
542
|
+
while (i < queue.length) {
|
|
543
|
+
const reaction = queue[i];
|
|
544
|
+
reaction.runIfNotUpToDate(false, true);
|
|
545
|
+
i++;
|
|
535
546
|
}
|
|
547
|
+
Operation.queuedReactions = [];
|
|
536
548
|
}
|
|
537
549
|
unsubscribeFromAllObservables() {
|
|
538
550
|
var _a;
|
|
@@ -610,7 +622,7 @@ class Operation extends Data_1.Observable {
|
|
|
610
622
|
Snapshot_1.Snapshot.isConflicting = Operation.isConflicting;
|
|
611
623
|
Snapshot_1.Snapshot.propagateAllChangesThroughSubscriptions = Operation.propagateAllChangesThroughSubscriptions;
|
|
612
624
|
Snapshot_1.Snapshot.revokeAllSubscriptions = Operation.revokeAllSubscriptions;
|
|
613
|
-
Snapshot_1.Snapshot.
|
|
625
|
+
Snapshot_1.Snapshot.enqueueReactionsToRun = Operation.enqueueReactionsToRun;
|
|
614
626
|
Hooks_1.Hooks.createControllerAndGetHook = Operation.createControllerAndGetHook;
|
|
615
627
|
Hooks_1.Hooks.rememberOperationOptions = Operation.rememberOperationOptions;
|
|
616
628
|
Promise.prototype.then = reactronicHookedThen;
|
|
@@ -17,8 +17,8 @@ export declare class Snapshot implements AbstractSnapshot {
|
|
|
17
17
|
get timestamp(): number;
|
|
18
18
|
private stamp;
|
|
19
19
|
private bumper;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
changeset: Map<ObjectHolder, ObjectRevision>;
|
|
21
|
+
reactions: Observer[];
|
|
22
22
|
sealed: boolean;
|
|
23
23
|
constructor(options: SnapshotOptions | null);
|
|
24
24
|
static current: () => Snapshot;
|
|
@@ -28,7 +28,7 @@ export declare class Snapshot implements AbstractSnapshot {
|
|
|
28
28
|
static isConflicting: (oldValue: any, newValue: any) => boolean;
|
|
29
29
|
static propagateAllChangesThroughSubscriptions: (snapshot: Snapshot) => void;
|
|
30
30
|
static revokeAllSubscriptions: (snapshot: Snapshot) => void;
|
|
31
|
-
static
|
|
31
|
+
static enqueueReactionsToRun: (reactions: Array<Observer>) => void;
|
|
32
32
|
seekRevision(h: ObjectHolder, m: MemberName): ObjectRevision;
|
|
33
33
|
getCurrentRevision(h: ObjectHolder, m: MemberName): ObjectRevision;
|
|
34
34
|
getEditableRevision(h: ObjectHolder, m: MemberName, value: any, token?: any): ObjectRevision;
|
|
@@ -40,7 +40,7 @@ export declare class Snapshot implements AbstractSnapshot {
|
|
|
40
40
|
bumpBy(timestamp: number): void;
|
|
41
41
|
rebase(): ObjectRevision[] | undefined;
|
|
42
42
|
private static merge;
|
|
43
|
-
applyOrDiscard(error?: any):
|
|
43
|
+
applyOrDiscard(error?: any): Array<Observer>;
|
|
44
44
|
static sealObjectRevision(h: ObjectHolder, r: ObjectRevision): void;
|
|
45
45
|
static sealObservable(observable: Observable | symbol, m: MemberName, typeName: string): void;
|
|
46
46
|
collectGarbage(): void;
|
|
@@ -27,6 +27,8 @@ Object.defineProperty(Data_1.ObjectHolder.prototype, '#this', {
|
|
|
27
27
|
return result;
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
|
+
const EMPTY_ARRAY = Object.freeze([]);
|
|
31
|
+
const EMPTY_MAP = Utils_1.Utils.freezeMap(new Map());
|
|
30
32
|
class Snapshot {
|
|
31
33
|
constructor(options) {
|
|
32
34
|
this.id = ++Snapshot.idGen;
|
|
@@ -208,6 +210,7 @@ class Snapshot {
|
|
|
208
210
|
}
|
|
209
211
|
if (!error)
|
|
210
212
|
Snapshot.propagateAllChangesThroughSubscriptions(this);
|
|
213
|
+
return this.reactions;
|
|
211
214
|
}
|
|
212
215
|
static sealObjectRevision(h, r) {
|
|
213
216
|
if (!r.changes.has(Data_1.Meta.Disposed))
|
|
@@ -229,6 +232,8 @@ class Snapshot {
|
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
collectGarbage() {
|
|
235
|
+
this.changeset = EMPTY_MAP;
|
|
236
|
+
this.reactions = EMPTY_ARRAY;
|
|
232
237
|
if (Dbg_1.Dbg.isOn) {
|
|
233
238
|
Utils_1.Utils.freezeMap(this.changeset);
|
|
234
239
|
Object.freeze(this.reactions);
|
|
@@ -238,7 +243,7 @@ class Snapshot {
|
|
|
238
243
|
}
|
|
239
244
|
static freezeObjectRevision(r) {
|
|
240
245
|
Object.freeze(r.data);
|
|
241
|
-
Utils_1.Utils.
|
|
246
|
+
Utils_1.Utils.freezeSet(r.changes);
|
|
242
247
|
Utils_1.Utils.freezeMap(r.conflicts);
|
|
243
248
|
return r;
|
|
244
249
|
}
|
|
@@ -269,12 +274,10 @@ class Snapshot {
|
|
|
269
274
|
if (Dbg_1.Dbg.isOn && Dbg_1.Dbg.trace.gc && r.prev.revision !== exports.ROOT_REV)
|
|
270
275
|
Dbg_1.Dbg.log(' ', ' ', `${Dump.rev(r.prev.revision)} is ready for GC because overwritten by ${Dump.rev(r)}`);
|
|
271
276
|
if (Snapshot.garbageCollectionSummaryInterval < Number.MAX_SAFE_INTEGER) {
|
|
272
|
-
if (r.prev.revision !== exports.ROOT_REV)
|
|
277
|
+
if (r.prev.revision !== exports.ROOT_REV)
|
|
273
278
|
Snapshot.totalObjectRevisionCount--;
|
|
274
|
-
|
|
275
|
-
if (r.changes.has(Data_1.Meta.Disposed)) {
|
|
279
|
+
if (r.changes.has(Data_1.Meta.Disposed))
|
|
276
280
|
Snapshot.totalObjectHolderCount--;
|
|
277
|
-
}
|
|
278
281
|
}
|
|
279
282
|
r.prev.revision = exports.ROOT_REV;
|
|
280
283
|
});
|
|
@@ -309,7 +312,7 @@ Snapshot.markEdited = Utils_1.UNDEF;
|
|
|
309
312
|
Snapshot.isConflicting = Utils_1.UNDEF;
|
|
310
313
|
Snapshot.propagateAllChangesThroughSubscriptions = (snapshot) => { };
|
|
311
314
|
Snapshot.revokeAllSubscriptions = (snapshot) => { };
|
|
312
|
-
Snapshot.
|
|
315
|
+
Snapshot.enqueueReactionsToRun = (reactions) => { };
|
|
313
316
|
class Dump {
|
|
314
317
|
static obj(h, m, stamp, op, xop, typeless) {
|
|
315
318
|
const member = m !== undefined ? `.${m.toString()}` : '';
|
|
@@ -228,9 +228,9 @@ class TransactionImpl extends Transaction {
|
|
|
228
228
|
finally {
|
|
229
229
|
this.pending--;
|
|
230
230
|
if (this.sealed && this.pending === 0) {
|
|
231
|
-
this.applyOrDiscard();
|
|
231
|
+
const reactions = this.applyOrDiscard();
|
|
232
232
|
TransactionImpl.curr = outer;
|
|
233
|
-
TransactionImpl.standalone(Snapshot_1.Snapshot.
|
|
233
|
+
TransactionImpl.standalone(Snapshot_1.Snapshot.enqueueReactionsToRun, reactions);
|
|
234
234
|
}
|
|
235
235
|
else
|
|
236
236
|
TransactionImpl.curr = outer;
|
|
@@ -259,10 +259,11 @@ class TransactionImpl extends Transaction {
|
|
|
259
259
|
throw (0, Dbg_1.error)(`T${this.id}[${this.hint}] conflicts with: ${Snapshot_1.Dump.conflicts(conflicts)}`, undefined);
|
|
260
260
|
}
|
|
261
261
|
applyOrDiscard() {
|
|
262
|
+
let reactions;
|
|
262
263
|
try {
|
|
263
264
|
if (Dbg_1.Dbg.isOn && Dbg_1.Dbg.trace.change)
|
|
264
265
|
Dbg_1.Dbg.log('╠═', '', '', undefined, 'changes');
|
|
265
|
-
this.snapshot.applyOrDiscard(this.canceled);
|
|
266
|
+
reactions = this.snapshot.applyOrDiscard(this.canceled);
|
|
266
267
|
this.snapshot.collectGarbage();
|
|
267
268
|
if (this.promise) {
|
|
268
269
|
if (this.canceled && !this.after)
|
|
@@ -277,6 +278,7 @@ class TransactionImpl extends Transaction {
|
|
|
277
278
|
(0, Dbg_1.fatal)(e);
|
|
278
279
|
throw e;
|
|
279
280
|
}
|
|
281
|
+
return reactions;
|
|
280
282
|
}
|
|
281
283
|
acquirePromise() {
|
|
282
284
|
if (!this.promise) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare type F<T> = (...args: any[]) => T;
|
|
2
2
|
export declare class Utils {
|
|
3
|
-
static freezeSet<T>(obj?: Set<T>):
|
|
4
|
-
static freezeMap<K, V>(obj?: Map<K, V>):
|
|
3
|
+
static freezeSet<T>(obj?: Set<T>): Set<T> | undefined;
|
|
4
|
+
static freezeMap<K, V>(obj?: Map<K, V>): Map<K, V> | undefined;
|
|
5
5
|
static copyAllMembers(source: any, target: any): any;
|
|
6
6
|
}
|
|
7
7
|
export declare function UNDEF(...args: any[]): never;
|
|
@@ -19,6 +19,7 @@ class Utils {
|
|
|
19
19
|
Object.defineProperty(obj, 'clear', pd);
|
|
20
20
|
Object.freeze(obj);
|
|
21
21
|
}
|
|
22
|
+
return obj;
|
|
22
23
|
}
|
|
23
24
|
static freezeMap(obj) {
|
|
24
25
|
if (obj instanceof Map) {
|
|
@@ -28,6 +29,7 @@ class Utils {
|
|
|
28
29
|
Object.defineProperty(obj, 'clear', pd);
|
|
29
30
|
Object.freeze(obj);
|
|
30
31
|
}
|
|
32
|
+
return obj;
|
|
31
33
|
}
|
|
32
34
|
static copyAllMembers(source, target) {
|
|
33
35
|
for (const m of Object.getOwnPropertyNames(source))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactronic",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.602",
|
|
4
4
|
"description": "Reactronic - Transactional Reactive State Management",
|
|
5
5
|
"main": "build/dist/source/api.js",
|
|
6
6
|
"types": "build/dist/source/api.d.ts",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/nezaboodka/reactronic/blob/master/README.md#readme",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "
|
|
32
|
+
"@types/node": "17.0.0",
|
|
33
33
|
"@types/react": "17.0.37",
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
35
|
-
"@typescript-eslint/parser": "5.
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "5.7.0",
|
|
35
|
+
"@typescript-eslint/parser": "5.7.0",
|
|
36
36
|
"ava": "3.15.0",
|
|
37
|
-
"eslint": "8.
|
|
37
|
+
"eslint": "8.4.1",
|
|
38
38
|
"nyc": "15.1.0",
|
|
39
39
|
"react": "17.0.2",
|
|
40
40
|
"ts-node": "10.4.0",
|
|
41
41
|
"tsconfig-paths": "3.12.0",
|
|
42
|
-
"typescript": "4.4
|
|
42
|
+
"typescript": "4.5.4"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "eslint source/**/*.ts test/**/*.ts react/**/*.tsx && tsc",
|