reactronic 0.22.101 → 0.22.105
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 +9 -8
- package/build/dist/source/Ref.js +1 -1
- package/build/dist/source/Rx.d.ts +0 -1
- package/build/dist/source/Rx.js +1 -6
- package/build/dist/source/api.d.ts +1 -1
- package/build/dist/source/api.js +1 -2
- package/build/dist/source/impl/Data.d.ts +4 -6
- package/build/dist/source/impl/Data.js +1 -1
- package/build/dist/source/impl/Monitor.js +3 -3
- package/build/dist/source/impl/Operation.d.ts +3 -3
- package/build/dist/source/impl/Operation.js +13 -13
- package/build/dist/source/impl/Snapshot.d.ts +1 -1
- package/build/dist/source/impl/Snapshot.js +4 -4
- package/build/dist/source/impl/Transaction.d.ts +3 -3
- package/build/dist/source/impl/Transaction.js +11 -11
- package/build/dist/source/impl/TransactionJournal.js +3 -3
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -196,7 +196,7 @@ class Component<P> extends React.Component<P> {
|
|
|
196
196
|
@reaction // called immediately in response to changes
|
|
197
197
|
ensureUpToDate(): void {
|
|
198
198
|
if (this.shouldComponentUpdate())
|
|
199
|
-
|
|
199
|
+
Transaction.off(() => this.setState({})) // ask React to re-render
|
|
200
200
|
} // ensureUpToDate is subscribed to render
|
|
201
201
|
|
|
202
202
|
shouldComponentUpdate(): boolean {
|
|
@@ -208,7 +208,7 @@ class Component<P> extends React.Component<P> {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
componentWillUnmount(): void {
|
|
211
|
-
Transaction.
|
|
211
|
+
Transaction.run(null, Rx.dispose, this)
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
```
|
|
@@ -310,7 +310,6 @@ function monitor(value: Monitor | null)
|
|
|
310
310
|
function trace(value: Partial<TraceOptions>)
|
|
311
311
|
|
|
312
312
|
function nonreactive<T>(func: F<T>, ...args: any[]): T
|
|
313
|
-
function nontransactional<T>(func: F<T>, ...args: any[]): T
|
|
314
313
|
function sensitive<T>(sensitivity: Sensitivity, func: F<T>, ...args: any[]): T
|
|
315
314
|
|
|
316
315
|
// Options, ObjectOptions, Kind, Reentrance, Monitor, TraceOptions, ProfilingOptions
|
|
@@ -417,11 +416,13 @@ class Transaction implements Worker {
|
|
|
417
416
|
whenFinished(): Promise<void>
|
|
418
417
|
join<T>(p: Promise<T>): Promise<T>
|
|
419
418
|
|
|
420
|
-
static create(
|
|
421
|
-
static run<T>(
|
|
422
|
-
static
|
|
423
|
-
|
|
424
|
-
static
|
|
419
|
+
static create(options: SnapshotOptions | null): Transaction
|
|
420
|
+
static run<T>(options: SnapshotOptions | null, func: F<T>, ...args: any[]): T
|
|
421
|
+
static off<T>(func: F<T>, ...args: any[]): T
|
|
422
|
+
|
|
423
|
+
static isFrameOver(everyN: number, timeLimit: number): boolean
|
|
424
|
+
static requestNextFrame(sleepTime: number): Promise<void>
|
|
425
|
+
static isCanceled: boolean
|
|
425
426
|
}
|
|
426
427
|
|
|
427
428
|
// Controller
|
package/build/dist/source/Ref.js
CHANGED
|
@@ -57,7 +57,7 @@ class ToggleRef extends Ref {
|
|
|
57
57
|
toggle() {
|
|
58
58
|
const o = this.owner;
|
|
59
59
|
const p = this.name;
|
|
60
|
-
Transaction_1.Transaction.
|
|
60
|
+
Transaction_1.Transaction.run({ hint: `toggle ${o.constructor.name}.${p}` }, () => {
|
|
61
61
|
const v = o[p];
|
|
62
62
|
const isOn = v === this.valueOn || (v instanceof Ref && this.valueOn instanceof Ref &&
|
|
63
63
|
Ref.sameRefs(v, this.valueOn));
|
|
@@ -18,7 +18,6 @@ export declare class Rx {
|
|
|
18
18
|
static setProfilingMode(enabled: boolean, options?: Partial<ProfilingOptions>): void;
|
|
19
19
|
}
|
|
20
20
|
export declare function nonreactive<T>(func: F<T>, ...args: any[]): T;
|
|
21
|
-
export declare function nontransactional<T>(func: F<T>, ...args: any[]): T;
|
|
22
21
|
export declare function sensitive<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
23
22
|
export declare function unobservable(proto: object, prop: PropertyKey): any;
|
|
24
23
|
export declare function transaction(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
package/build/dist/source/Rx.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
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.
|
|
3
|
+
exports.options = exports.cached = exports.reaction = exports.transaction = exports.unobservable = exports.sensitive = 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");
|
|
7
7
|
const Snapshot_1 = require("./impl/Snapshot");
|
|
8
8
|
const Hooks_1 = require("./impl/Hooks");
|
|
9
9
|
const Operation_1 = require("./impl/Operation");
|
|
10
|
-
const Transaction_1 = require("./impl/Transaction");
|
|
11
10
|
class Rx {
|
|
12
11
|
static why(brief = false) { return brief ? Operation_1.OperationController.briefWhy() : Operation_1.OperationController.why(); }
|
|
13
12
|
static getController(method) { return Operation_1.OperationController.of(method); }
|
|
@@ -29,10 +28,6 @@ function nonreactive(func, ...args) {
|
|
|
29
28
|
return Operation_1.OperationController.runWithin(undefined, func, ...args);
|
|
30
29
|
}
|
|
31
30
|
exports.nonreactive = nonreactive;
|
|
32
|
-
function nontransactional(func, ...args) {
|
|
33
|
-
return Operation_1.OperationController.runWithin(undefined, Transaction_1.Transaction.nontransactional, func, ...args);
|
|
34
|
-
}
|
|
35
|
-
exports.nontransactional = nontransactional;
|
|
36
31
|
function sensitive(sensitivity, func, ...args) {
|
|
37
32
|
return Hooks_1.Hooks.sensitive(sensitivity, func, ...args);
|
|
38
33
|
}
|
|
@@ -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 { Rx, nonreactive,
|
|
14
|
+
export { Rx, nonreactive, 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.
|
|
3
|
+
exports.options = exports.cached = exports.reaction = exports.transaction = exports.unobservable = exports.sensitive = 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; } });
|
|
@@ -32,7 +32,6 @@ Object.defineProperty(exports, "TransactionJournal", { enumerable: true, get: fu
|
|
|
32
32
|
var Rx_1 = require("./Rx");
|
|
33
33
|
Object.defineProperty(exports, "Rx", { enumerable: true, get: function () { return Rx_1.Rx; } });
|
|
34
34
|
Object.defineProperty(exports, "nonreactive", { enumerable: true, get: function () { return Rx_1.nonreactive; } });
|
|
35
|
-
Object.defineProperty(exports, "nontransactional", { enumerable: true, get: function () { return Rx_1.nontransactional; } });
|
|
36
35
|
Object.defineProperty(exports, "sensitive", { enumerable: true, get: function () { return Rx_1.sensitive; } });
|
|
37
36
|
Object.defineProperty(exports, "unobservable", { enumerable: true, get: function () { return Rx_1.unobservable; } });
|
|
38
37
|
Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return Rx_1.transaction; } });
|
|
@@ -9,23 +9,21 @@ export declare class Observable {
|
|
|
9
9
|
value: any;
|
|
10
10
|
observers?: Set<Observer>;
|
|
11
11
|
get isOperation(): boolean;
|
|
12
|
-
get
|
|
12
|
+
get originSnapshotId(): number | undefined;
|
|
13
13
|
constructor(value: any);
|
|
14
14
|
}
|
|
15
15
|
export declare type StandaloneMode = boolean | 'isolated';
|
|
16
16
|
export interface Observer {
|
|
17
17
|
readonly order: number;
|
|
18
|
-
readonly observables: Map<Observable,
|
|
18
|
+
readonly observables: Map<Observable, ObservableInfo> | undefined;
|
|
19
19
|
readonly obsoleteSince: number;
|
|
20
20
|
hint(nop?: boolean): string;
|
|
21
21
|
markObsoleteDueTo(observable: Observable, memberName: MemberName, snapshot: AbstractSnapshot, holder: ObjectHolder, outer: string, since: number, reactions: Observer[]): void;
|
|
22
22
|
runIfNotUpToDate(now: boolean, nothrow: boolean): void;
|
|
23
23
|
}
|
|
24
24
|
export declare type MemberName = PropertyKey;
|
|
25
|
-
export interface
|
|
26
|
-
readonly
|
|
27
|
-
readonly snapshot: AbstractSnapshot;
|
|
28
|
-
readonly memberName: MemberName;
|
|
25
|
+
export interface ObservableInfo {
|
|
26
|
+
readonly memberHint: string;
|
|
29
27
|
readonly usageCount: number;
|
|
30
28
|
}
|
|
31
29
|
export declare class ObjectRevision {
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "Meta", { enumerable: true, get: function () { re
|
|
|
8
8
|
class Observable {
|
|
9
9
|
constructor(value) { this.value = value; }
|
|
10
10
|
get isOperation() { return false; }
|
|
11
|
-
get
|
|
11
|
+
get originSnapshotId() { return 0; }
|
|
12
12
|
}
|
|
13
13
|
exports.Observable = Observable;
|
|
14
14
|
class ObjectRevision {
|
|
@@ -35,7 +35,7 @@ class MonitorImpl extends Monitor {
|
|
|
35
35
|
MonitorImpl.deactivate(this, this.internals.deactivationDelay);
|
|
36
36
|
}
|
|
37
37
|
static create(hint, activationDelay, deactivationDelay) {
|
|
38
|
-
return Transaction_1.Transaction.
|
|
38
|
+
return Transaction_1.Transaction.run({ hint: 'Monitor.create' }, MonitorImpl.doCreate, hint, activationDelay, deactivationDelay);
|
|
39
39
|
}
|
|
40
40
|
static enter(mon, worker) {
|
|
41
41
|
mon.enter(worker);
|
|
@@ -53,7 +53,7 @@ class MonitorImpl extends Monitor {
|
|
|
53
53
|
static activate(mon, delay) {
|
|
54
54
|
if (delay >= 0) {
|
|
55
55
|
if (mon.internals.activationTimeout === undefined)
|
|
56
|
-
mon.internals.activationTimeout = setTimeout(() => Transaction_1.Transaction.
|
|
56
|
+
mon.internals.activationTimeout = setTimeout(() => Transaction_1.Transaction.run({ hint: 'Monitor.activate', standalone: 'isolated' }, MonitorImpl.activate, mon, -1), delay);
|
|
57
57
|
}
|
|
58
58
|
else if (mon.counter > 0)
|
|
59
59
|
mon.isActive = true;
|
|
@@ -61,7 +61,7 @@ class MonitorImpl extends Monitor {
|
|
|
61
61
|
static deactivate(mon, delay) {
|
|
62
62
|
if (delay >= 0) {
|
|
63
63
|
clearTimeout(mon.internals.deactivationTimeout);
|
|
64
|
-
mon.internals.deactivationTimeout = setTimeout(() => Transaction_1.Transaction.
|
|
64
|
+
mon.internals.deactivationTimeout = setTimeout(() => Transaction_1.Transaction.run({ hint: 'Monitor.deactivate', standalone: 'isolated' }, MonitorImpl.deactivate, mon, -1), delay);
|
|
65
65
|
}
|
|
66
66
|
else if (mon.counter <= 0) {
|
|
67
67
|
mon.isActive = false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { F } from '../util/Utils';
|
|
2
2
|
import { MemberOptions } from '../Options';
|
|
3
3
|
import { Controller } from '../Controller';
|
|
4
|
-
import { MemberName, ObjectHolder, Observable, Observer,
|
|
4
|
+
import { MemberName, ObjectHolder, Observable, Observer, ObservableInfo, AbstractSnapshot } from './Data';
|
|
5
5
|
import { Transaction } from './Transaction';
|
|
6
6
|
import { OptionsImpl } from './Hooks';
|
|
7
7
|
export declare class OperationController extends Controller<any> {
|
|
@@ -40,7 +40,7 @@ declare class Operation extends Observable implements Observer {
|
|
|
40
40
|
readonly transaction: Transaction;
|
|
41
41
|
readonly controller: OperationController;
|
|
42
42
|
readonly snapshot: AbstractSnapshot;
|
|
43
|
-
observables: Map<Observable,
|
|
43
|
+
observables: Map<Observable, ObservableInfo> | undefined;
|
|
44
44
|
options: OptionsImpl;
|
|
45
45
|
cause: string | undefined;
|
|
46
46
|
args: any[];
|
|
@@ -52,7 +52,7 @@ declare class Operation extends Observable implements Observer {
|
|
|
52
52
|
successor: Operation | undefined;
|
|
53
53
|
constructor(controller: OperationController, snapshot: AbstractSnapshot, prev: Operation | OptionsImpl);
|
|
54
54
|
get isOperation(): boolean;
|
|
55
|
-
get
|
|
55
|
+
get originSnapshotId(): number;
|
|
56
56
|
hint(): string;
|
|
57
57
|
get order(): number;
|
|
58
58
|
get ['#this'](): string;
|
|
@@ -27,7 +27,7 @@ class OperationController extends Controller_1.Controller {
|
|
|
27
27
|
get error() { return this.use().operation.error; }
|
|
28
28
|
get stamp() { return this.use().revision.snapshot.timestamp; }
|
|
29
29
|
get isUpToDate() { return this.use().isUpToDate; }
|
|
30
|
-
markObsolete() { Transaction_1.Transaction.
|
|
30
|
+
markObsolete() { Transaction_1.Transaction.run({ hint: Dbg_1.Dbg.isOn ? `markObsolete(${Snapshot_1.Dump.obj(this.ownHolder, this.memberName)})` : 'markObsolete()' }, OperationController.markObsolete, this); }
|
|
31
31
|
pullLastResult(args) { return this.useOrRun(true, args).value; }
|
|
32
32
|
useOrRun(weak, args) {
|
|
33
33
|
var _a;
|
|
@@ -141,7 +141,7 @@ class OperationController extends Controller_1.Controller {
|
|
|
141
141
|
if (op.controller !== this) {
|
|
142
142
|
const hint = Dbg_1.Dbg.isOn ? `${Snapshot_1.Dump.obj(this.ownHolder, m)}/boot` : 'MethodController/init';
|
|
143
143
|
const standalone = r.snapshot.sealed || r.prev.revision !== Snapshot_1.ROOT_REV;
|
|
144
|
-
op = Transaction_1.Transaction.
|
|
144
|
+
op = Transaction_1.Transaction.run({ hint, standalone, token: this }, () => {
|
|
145
145
|
const h = this.ownHolder;
|
|
146
146
|
let r2 = Snapshot_1.Snapshot.current().getCurrentRevision(h, m);
|
|
147
147
|
let op2 = r2.data[m];
|
|
@@ -164,7 +164,7 @@ class OperationController extends Controller_1.Controller {
|
|
|
164
164
|
const hint = Dbg_1.Dbg.isOn ? `${Snapshot_1.Dump.obj(this.ownHolder, this.memberName)}${args && args.length > 0 && (typeof args[0] === 'number' || typeof args[0] === 'string') ? ` - ${args[0]}` : ''}` : `${Snapshot_1.Dump.obj(this.ownHolder, this.memberName)}`;
|
|
165
165
|
let oc = existing;
|
|
166
166
|
const opts = { hint, standalone, journal: options.journal, trace: options.trace, token };
|
|
167
|
-
const result = Transaction_1.Transaction.
|
|
167
|
+
const result = Transaction_1.Transaction.run(opts, (argsx) => {
|
|
168
168
|
if (!oc.operation.transaction.isCanceled) {
|
|
169
169
|
oc = this.edit();
|
|
170
170
|
if (Dbg_1.Dbg.isOn && Dbg_1.Dbg.trace.operation)
|
|
@@ -216,7 +216,7 @@ class Operation extends Data_1.Observable {
|
|
|
216
216
|
this.successor = undefined;
|
|
217
217
|
}
|
|
218
218
|
get isOperation() { return true; }
|
|
219
|
-
get
|
|
219
|
+
get originSnapshotId() { return this.snapshot.id; }
|
|
220
220
|
hint() { return `${Snapshot_1.Dump.rev2(this.controller.ownHolder, this.snapshot, this.controller.memberName)}`; }
|
|
221
221
|
get order() { return this.options.order; }
|
|
222
222
|
get ['#this']() {
|
|
@@ -415,17 +415,17 @@ class Operation extends Data_1.Observable {
|
|
|
415
415
|
standalone: 'isolated',
|
|
416
416
|
trace: Dbg_1.Dbg.isOn && Dbg_1.Dbg.trace.monitor ? undefined : Dbg_1.Dbg.global
|
|
417
417
|
};
|
|
418
|
-
OperationController.runWithin(undefined, Transaction_1.Transaction.
|
|
418
|
+
OperationController.runWithin(undefined, Transaction_1.Transaction.run, options, Monitor_1.MonitorImpl.enter, mon, this.transaction);
|
|
419
419
|
}
|
|
420
420
|
monitorLeave(mon) {
|
|
421
|
-
Transaction_1.Transaction.
|
|
421
|
+
Transaction_1.Transaction.off(() => {
|
|
422
422
|
const leave = () => {
|
|
423
423
|
const options = {
|
|
424
424
|
hint: 'Monitor.leave',
|
|
425
425
|
standalone: 'isolated',
|
|
426
426
|
trace: Dbg_1.Dbg.isOn && Dbg_1.Dbg.trace.monitor ? undefined : Dbg_1.Dbg.DefaultLevel
|
|
427
427
|
};
|
|
428
|
-
OperationController.runWithin(undefined, Transaction_1.Transaction.
|
|
428
|
+
OperationController.runWithin(undefined, Transaction_1.Transaction.run, options, Monitor_1.MonitorImpl.leave, mon, this.transaction);
|
|
429
429
|
};
|
|
430
430
|
this.transaction.whenFinished().then(leave, leave);
|
|
431
431
|
});
|
|
@@ -510,9 +510,9 @@ class Operation extends Data_1.Observable {
|
|
|
510
510
|
if (curr instanceof Operation) {
|
|
511
511
|
if (curr.snapshot === r.snapshot && curr.observables !== undefined) {
|
|
512
512
|
if (Hooks_1.Hooks.repetitiveUsageWarningThreshold < Number.MAX_SAFE_INTEGER) {
|
|
513
|
-
curr.observables.forEach((
|
|
514
|
-
if (
|
|
515
|
-
Dbg_1.Dbg.log('', '[!]', `${curr.hint()} uses ${
|
|
513
|
+
curr.observables.forEach((info, v) => {
|
|
514
|
+
if (info.usageCount > Hooks_1.Hooks.repetitiveUsageWarningThreshold)
|
|
515
|
+
Dbg_1.Dbg.log('', '[!]', `${curr.hint()} uses ${info.memberHint} ${info.usageCount} times (consider remembering it in a local variable)`, 0, ' *** WARNING ***');
|
|
516
516
|
});
|
|
517
517
|
}
|
|
518
518
|
if (unsubscribe)
|
|
@@ -548,11 +548,11 @@ class Operation extends Data_1.Observable {
|
|
|
548
548
|
}
|
|
549
549
|
unsubscribeFromAllObservables() {
|
|
550
550
|
var _a;
|
|
551
|
-
(_a = this.observables) === null || _a === void 0 ? void 0 : _a.forEach((
|
|
551
|
+
(_a = this.observables) === null || _a === void 0 ? void 0 : _a.forEach((info, value) => {
|
|
552
552
|
var _a;
|
|
553
553
|
value.observers.delete(this);
|
|
554
554
|
if (Dbg_1.Dbg.isOn && (Dbg_1.Dbg.trace.read || ((_a = this.options.trace) === null || _a === void 0 ? void 0 : _a.read)))
|
|
555
|
-
Dbg_1.Dbg.log(Dbg_1.Dbg.trace.transaction && !Snapshot_1.Snapshot.current().sealed ? '║' : ' ', '-', `${this.hint()} is unsubscribed from ${
|
|
555
|
+
Dbg_1.Dbg.log(Dbg_1.Dbg.trace.transaction && !Snapshot_1.Snapshot.current().sealed ? '║' : ' ', '-', `${this.hint()} is unsubscribed from ${info.memberHint}`);
|
|
556
556
|
});
|
|
557
557
|
this.observables = undefined;
|
|
558
558
|
}
|
|
@@ -568,7 +568,7 @@ class Operation extends Data_1.Observable {
|
|
|
568
568
|
if (this.observables !== undefined) {
|
|
569
569
|
if (!observable.observers)
|
|
570
570
|
observable.observers = new Set();
|
|
571
|
-
const info = {
|
|
571
|
+
const info = { memberHint: Snapshot_1.Dump.rev2(h, r.snapshot, m), usageCount: times };
|
|
572
572
|
observable.observers.add(this);
|
|
573
573
|
this.observables.set(observable, info);
|
|
574
574
|
if (Dbg_1.Dbg.isOn && (Dbg_1.Dbg.trace.read || ((_a = this.options.trace) === null || _a === void 0 ? void 0 : _a.read)))
|
|
@@ -49,7 +49,7 @@ export declare class Snapshot implements AbstractSnapshot {
|
|
|
49
49
|
static _init(): void;
|
|
50
50
|
}
|
|
51
51
|
export declare class Dump {
|
|
52
|
-
static obj(h: ObjectHolder | undefined, m?: MemberName | undefined, stamp?: number,
|
|
52
|
+
static obj(h: ObjectHolder | undefined, m?: MemberName | undefined, stamp?: number, snapshotId?: number, originSnapshotId?: number, typeless?: boolean): string;
|
|
53
53
|
static rev2(h: ObjectHolder, s: AbstractSnapshot, m?: MemberName, value?: Observable): string;
|
|
54
54
|
static rev(r: ObjectRevision, m?: MemberName): string;
|
|
55
55
|
static conflicts(conflicts: ObjectRevision[]): string;
|
|
@@ -309,19 +309,19 @@ Snapshot.propagateAllChangesThroughSubscriptions = (snapshot) => { };
|
|
|
309
309
|
Snapshot.revokeAllSubscriptions = (snapshot) => { };
|
|
310
310
|
Snapshot.enqueueReactionsToRun = (reactions) => { };
|
|
311
311
|
class Dump {
|
|
312
|
-
static obj(h, m, stamp,
|
|
312
|
+
static obj(h, m, stamp, snapshotId, originSnapshotId, typeless) {
|
|
313
313
|
const member = m !== undefined ? `.${m.toString()}` : '';
|
|
314
314
|
return h === undefined
|
|
315
315
|
? `root${member}`
|
|
316
|
-
: stamp === undefined ? `${h.hint}${member} #${h.id}` : `${h.hint}${member} #${h.id}t${
|
|
316
|
+
: stamp === undefined ? `${h.hint}${member} #${h.id}` : `${h.hint}${member} #${h.id}t${snapshotId}v${stamp}${originSnapshotId !== undefined && originSnapshotId !== 0 ? `t${originSnapshotId}` : ''}`;
|
|
317
317
|
}
|
|
318
318
|
static rev2(h, s, m, value) {
|
|
319
|
-
return Dump.obj(h, m, s.timestamp, s.id, value === null || value === void 0 ? void 0 : value.
|
|
319
|
+
return Dump.obj(h, m, s.timestamp, s.id, value === null || value === void 0 ? void 0 : value.originSnapshotId);
|
|
320
320
|
}
|
|
321
321
|
static rev(r, m) {
|
|
322
322
|
const h = Data_1.Meta.get(r.data, Data_1.Meta.Holder);
|
|
323
323
|
const value = m !== undefined ? r.data[m] : undefined;
|
|
324
|
-
return Dump.obj(h, m, r.snapshot.timestamp, r.snapshot.id, value === null || value === void 0 ? void 0 : value.
|
|
324
|
+
return Dump.obj(h, m, r.snapshot.timestamp, r.snapshot.id, value === null || value === void 0 ? void 0 : value.originSnapshotId);
|
|
325
325
|
}
|
|
326
326
|
static conflicts(conflicts) {
|
|
327
327
|
return conflicts.map(ours => {
|
|
@@ -21,9 +21,9 @@ export declare abstract class Transaction implements Worker {
|
|
|
21
21
|
abstract readonly isFinished: boolean;
|
|
22
22
|
whenFinished(): Promise<void>;
|
|
23
23
|
static create(options: SnapshotOptions | null): Transaction;
|
|
24
|
-
static run<T>(func: F<T>, ...args: any[]): T;
|
|
25
|
-
static
|
|
26
|
-
static
|
|
24
|
+
static run<T>(options: SnapshotOptions | null, func: F<T>, ...args: any[]): T;
|
|
25
|
+
static standalone<T>(func: F<T>, ...args: any[]): T;
|
|
26
|
+
static off<T>(func: F<T>, ...args: any[]): T;
|
|
27
27
|
static isFrameOver(everyN?: number, timeLimit?: number): boolean;
|
|
28
28
|
static requestNextFrame(sleepTime?: number): Promise<void>;
|
|
29
29
|
static get isCanceled(): boolean;
|
|
@@ -19,9 +19,9 @@ class Transaction {
|
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () { });
|
|
20
20
|
}
|
|
21
21
|
static create(options) { return new TransactionImpl(options); }
|
|
22
|
-
static run(func, ...args) { return TransactionImpl.run(func, ...args); }
|
|
23
|
-
static
|
|
24
|
-
static
|
|
22
|
+
static run(options, func, ...args) { return TransactionImpl.run(options, func, ...args); }
|
|
23
|
+
static standalone(func, ...args) { return TransactionImpl.standalone(func, ...args); }
|
|
24
|
+
static off(func, ...args) { return TransactionImpl.off(func, ...args); }
|
|
25
25
|
static isFrameOver(everyN = 1, timeLimit = 14) { return TransactionImpl.isFrameOver(everyN, timeLimit); }
|
|
26
26
|
static requestNextFrame(sleepTime = 0) { return TransactionImpl.requestNextFrame(sleepTime); }
|
|
27
27
|
static get isCanceled() { return TransactionImpl.current.isCanceled; }
|
|
@@ -115,17 +115,14 @@ class TransactionImpl extends Transaction {
|
|
|
115
115
|
yield this.acquirePromise();
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
|
-
static run(func, ...args) {
|
|
119
|
-
return TransactionImpl.runAs(null, func, ...args);
|
|
120
|
-
}
|
|
121
|
-
static runAs(options, func, ...args) {
|
|
118
|
+
static run(options, func, ...args) {
|
|
122
119
|
const t = TransactionImpl.acquire(options);
|
|
123
120
|
const root = t !== TransactionImpl.curr;
|
|
124
121
|
t.guard();
|
|
125
122
|
let result = t.runImpl(options === null || options === void 0 ? void 0 : options.trace, func, ...args);
|
|
126
123
|
if (root) {
|
|
127
124
|
if (result instanceof Promise) {
|
|
128
|
-
result = TransactionImpl.
|
|
125
|
+
result = TransactionImpl.off(() => {
|
|
129
126
|
return t.wrapToRetry(t.wrapToWaitUntilFinish(result), func, ...args);
|
|
130
127
|
});
|
|
131
128
|
}
|
|
@@ -133,7 +130,10 @@ class TransactionImpl extends Transaction {
|
|
|
133
130
|
}
|
|
134
131
|
return result;
|
|
135
132
|
}
|
|
136
|
-
static
|
|
133
|
+
static standalone(func, ...args) {
|
|
134
|
+
return TransactionImpl.run({ standalone: true }, func, ...args);
|
|
135
|
+
}
|
|
136
|
+
static off(func, ...args) {
|
|
137
137
|
const outer = TransactionImpl.curr;
|
|
138
138
|
try {
|
|
139
139
|
TransactionImpl.curr = TransactionImpl.none;
|
|
@@ -184,7 +184,7 @@ class TransactionImpl extends Transaction {
|
|
|
184
184
|
trace: this.snapshot.options.trace,
|
|
185
185
|
token: this.snapshot.options.token,
|
|
186
186
|
};
|
|
187
|
-
return TransactionImpl.
|
|
187
|
+
return TransactionImpl.run(options, func, ...args);
|
|
188
188
|
}
|
|
189
189
|
else
|
|
190
190
|
throw error;
|
|
@@ -230,7 +230,7 @@ class TransactionImpl extends Transaction {
|
|
|
230
230
|
if (this.sealed && this.pending === 0) {
|
|
231
231
|
const reactions = this.applyOrDiscard();
|
|
232
232
|
TransactionImpl.curr = outer;
|
|
233
|
-
TransactionImpl.
|
|
233
|
+
TransactionImpl.off(Snapshot_1.Snapshot.enqueueReactionsToRun, reactions);
|
|
234
234
|
}
|
|
235
235
|
else
|
|
236
236
|
TransactionImpl.curr = outer;
|
|
@@ -24,7 +24,7 @@ class TransactionJournalImpl extends TransactionJournal {
|
|
|
24
24
|
get canUndo() { return this._items.length > 0 && this._position > 0; }
|
|
25
25
|
get canRedo() { return this._position < this._items.length; }
|
|
26
26
|
remember(p) {
|
|
27
|
-
Transaction_1.Transaction.
|
|
27
|
+
Transaction_1.Transaction.run({ hint: 'TransactionJournal.remember', standalone: 'isolated' }, () => {
|
|
28
28
|
const items = this._items = this._items.toMutable();
|
|
29
29
|
if (items.length >= this._capacity)
|
|
30
30
|
items.shift();
|
|
@@ -35,7 +35,7 @@ class TransactionJournalImpl extends TransactionJournal {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
undo(count = 1) {
|
|
38
|
-
Transaction_1.Transaction.
|
|
38
|
+
Transaction_1.Transaction.run({ hint: 'TransactionJournal.undo', standalone: 'isolated' }, () => {
|
|
39
39
|
let i = this._position - 1;
|
|
40
40
|
while (i >= 0 && count > 0) {
|
|
41
41
|
const patch = this._items[i];
|
|
@@ -46,7 +46,7 @@ class TransactionJournalImpl extends TransactionJournal {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
redo(count = 1) {
|
|
49
|
-
Transaction_1.Transaction.
|
|
49
|
+
Transaction_1.Transaction.run({ hint: 'TransactionJournal.redo', standalone: 'isolated' }, () => {
|
|
50
50
|
let i = this._position;
|
|
51
51
|
while (i < this._items.length && count > 0) {
|
|
52
52
|
const patch = this._items[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactronic",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.105",
|
|
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,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/nezaboodka/reactronic/blob/master/README.md#readme",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "17.0.
|
|
33
|
-
"@types/react": "17.0.
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
35
|
-
"@typescript-eslint/parser": "5.
|
|
32
|
+
"@types/node": "17.0.7",
|
|
33
|
+
"@types/react": "17.0.38",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "5.9.0",
|
|
35
|
+
"@typescript-eslint/parser": "5.9.0",
|
|
36
36
|
"ava": "3.15.0",
|
|
37
|
-
"eslint": "8.
|
|
37
|
+
"eslint": "8.6.0",
|
|
38
38
|
"nyc": "15.1.0",
|
|
39
39
|
"react": "17.0.2",
|
|
40
40
|
"ts-node": "10.4.0",
|