reactronic 0.22.102 → 0.22.103
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 +8 -6
- package/build/dist/source/Ref.js +1 -1
- package/build/dist/source/impl/Monitor.js +3 -3
- package/build/dist/source/impl/Operation.js +5 -5
- package/build/dist/source/impl/Transaction.d.ts +2 -2
- package/build/dist/source/impl/Transaction.js +7 -7
- package/build/dist/source/impl/TransactionJournal.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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
|
```
|
|
@@ -417,11 +417,13 @@ class Transaction implements Worker {
|
|
|
417
417
|
whenFinished(): Promise<void>
|
|
418
418
|
join<T>(p: Promise<T>): Promise<T>
|
|
419
419
|
|
|
420
|
-
static create(
|
|
421
|
-
static run<T>(
|
|
422
|
-
static
|
|
423
|
-
|
|
424
|
-
static
|
|
420
|
+
static create(options: SnapshotOptions | null): Transaction
|
|
421
|
+
static run<T>(options: SnapshotOptions | null, func: F<T>, ...args: any[]): T
|
|
422
|
+
static off<T>(func: F<T>, ...args: any[]): T
|
|
423
|
+
|
|
424
|
+
static isFrameOver(everyN: number, timeLimit: number): boolean
|
|
425
|
+
static requestNextFrame(sleepTime: number): Promise<void>
|
|
426
|
+
static isCanceled: boolean
|
|
425
427
|
}
|
|
426
428
|
|
|
427
429
|
// 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));
|
|
@@ -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;
|
|
@@ -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)
|
|
@@ -415,7 +415,7 @@ 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
421
|
Transaction_1.Transaction.off(() => {
|
|
@@ -425,7 +425,7 @@ class Operation extends Data_1.Observable {
|
|
|
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
|
});
|
|
@@ -21,8 +21,8 @@ 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
|
|
24
|
+
static run<T>(options: SnapshotOptions | null, func: F<T>, ...args: any[]): T;
|
|
25
|
+
static standalone<T>(func: F<T>, ...args: any[]): T;
|
|
26
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>;
|
|
@@ -19,8 +19,8 @@ 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
|
|
22
|
+
static run(options, func, ...args) { return TransactionImpl.run(options, func, ...args); }
|
|
23
|
+
static standalone(func, ...args) { return TransactionImpl.standalone(func, ...args); }
|
|
24
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); }
|
|
@@ -115,10 +115,7 @@ 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();
|
|
@@ -133,6 +130,9 @@ class TransactionImpl extends Transaction {
|
|
|
133
130
|
}
|
|
134
131
|
return result;
|
|
135
132
|
}
|
|
133
|
+
static standalone(func, ...args) {
|
|
134
|
+
return TransactionImpl.run({ standalone: true }, func, ...args);
|
|
135
|
+
}
|
|
136
136
|
static off(func, ...args) {
|
|
137
137
|
const outer = TransactionImpl.curr;
|
|
138
138
|
try {
|
|
@@ -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;
|
|
@@ -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];
|