reactronic 0.24.302 → 0.24.303
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/source/core/Changeset.d.ts +1 -1
- package/build/dist/source/core/Changeset.js +3 -1
- package/build/dist/source/core/RxNode.d.ts +0 -1
- package/build/dist/source/core/RxNode.js +44 -43
- package/build/dist/source/core/Transaction.d.ts +1 -1
- package/build/dist/source/core/Transaction.js +20 -11
- package/package.json +1 -1
|
@@ -38,7 +38,7 @@ export declare class Changeset implements AbstractChangeset {
|
|
|
38
38
|
static dispose(obj: any): void;
|
|
39
39
|
static doDispose(ctx: Changeset, h: ObjectHandle): ObjectVersion;
|
|
40
40
|
private isNewObjectVersionRequired;
|
|
41
|
-
acquire(outer: Changeset):
|
|
41
|
+
acquire(outer: Changeset): boolean;
|
|
42
42
|
bumpBy(timestamp: number): void;
|
|
43
43
|
rebase(): ObjectVersion[] | undefined;
|
|
44
44
|
private merge;
|
|
@@ -137,7 +137,8 @@ export class Changeset {
|
|
|
137
137
|
return ov.changeset !== this && !this.sealed;
|
|
138
138
|
}
|
|
139
139
|
acquire(outer) {
|
|
140
|
-
|
|
140
|
+
const result = !this.sealed && this.revision === UNDEFINED_REVISION;
|
|
141
|
+
if (result) {
|
|
141
142
|
const ahead = this.options.token === undefined || outer.revision === UNDEFINED_REVISION;
|
|
142
143
|
this.revision = ahead ? Changeset.stampGen : outer.revision;
|
|
143
144
|
Changeset.pending.push(this);
|
|
@@ -146,6 +147,7 @@ export class Changeset {
|
|
|
146
147
|
if (Log.isOn && Log.opt.transaction)
|
|
147
148
|
Log.write("╔══", `s${this.revision}`, `${this.hint}`);
|
|
148
149
|
}
|
|
150
|
+
return result;
|
|
149
151
|
}
|
|
150
152
|
bumpBy(timestamp) {
|
|
151
153
|
if (timestamp > this.bumper)
|
|
@@ -56,7 +56,6 @@ export declare abstract class RxNode<E = unknown> {
|
|
|
56
56
|
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
57
57
|
}
|
|
58
58
|
export type RxNodeDecl<E = unknown> = {
|
|
59
|
-
isAsync?: boolean;
|
|
60
59
|
script?: Script<E>;
|
|
61
60
|
scriptAsync?: ScriptAsync<E>;
|
|
62
61
|
key?: string;
|
|
@@ -106,7 +106,7 @@ export class RxNode {
|
|
|
106
106
|
triggerDeactivation(impl.seat, true, true);
|
|
107
107
|
}
|
|
108
108
|
static updateNestedNodesThenDo(action) {
|
|
109
|
-
runUpdateNestedNodesThenDo(undefined, action);
|
|
109
|
+
runUpdateNestedNodesThenDo(RxNodeImpl.ownSeat, undefined, action);
|
|
110
110
|
}
|
|
111
111
|
static markAsMounted(node, yes) {
|
|
112
112
|
const n = node;
|
|
@@ -365,49 +365,50 @@ __decorate([
|
|
|
365
365
|
function getNodeKey(node) {
|
|
366
366
|
return node.stamp >= 0 ? node.key : undefined;
|
|
367
367
|
}
|
|
368
|
-
function runUpdateNestedNodesThenDo(error, action) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
368
|
+
function runUpdateNestedNodesThenDo(ownSeat, error, action) {
|
|
369
|
+
runInside(ownSeat, () => {
|
|
370
|
+
var _a;
|
|
371
|
+
const owner = ownSeat.instance;
|
|
372
|
+
const children = owner.children;
|
|
373
|
+
if (children.isMergeInProgress) {
|
|
374
|
+
let promised = undefined;
|
|
375
|
+
try {
|
|
376
|
+
children.endMerge(error);
|
|
377
|
+
for (const child of children.removedItems(true))
|
|
378
|
+
triggerDeactivation(child, true, true);
|
|
379
|
+
if (!error) {
|
|
380
|
+
const sequential = children.isStrict;
|
|
381
|
+
let p1 = undefined;
|
|
382
|
+
let p2 = undefined;
|
|
383
|
+
let mounting = false;
|
|
384
|
+
let partition = owner;
|
|
385
|
+
for (const child of children.items()) {
|
|
386
|
+
if (Transaction.isCanceled)
|
|
387
|
+
break;
|
|
388
|
+
const childNode = child.instance;
|
|
389
|
+
const isPart = childNode.driver.isPartition;
|
|
390
|
+
const host = isPart ? owner : partition;
|
|
391
|
+
mounting = markToMountIfNecessary(mounting, host, child, children, sequential);
|
|
392
|
+
const p = (_a = childNode.priority) !== null && _a !== void 0 ? _a : Priority.realtime;
|
|
393
|
+
if (p === Priority.realtime)
|
|
394
|
+
triggerUpdateViaSeat(child);
|
|
395
|
+
else if (p === Priority.normal)
|
|
396
|
+
p1 = push(child, p1);
|
|
397
|
+
else
|
|
398
|
+
p2 = push(child, p2);
|
|
399
|
+
if (isPart)
|
|
400
|
+
partition = childNode;
|
|
401
|
+
}
|
|
402
|
+
if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
|
|
403
|
+
promised = startIncrementalUpdate(ownSeat, children, p1, p2).then(() => action(error), e => action(e));
|
|
401
404
|
}
|
|
402
|
-
|
|
403
|
-
|
|
405
|
+
}
|
|
406
|
+
finally {
|
|
407
|
+
if (!promised)
|
|
408
|
+
action(error);
|
|
404
409
|
}
|
|
405
410
|
}
|
|
406
|
-
|
|
407
|
-
if (!promised)
|
|
408
|
-
action(error);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
+
});
|
|
411
412
|
}
|
|
412
413
|
function markToMountIfNecessary(mounting, host, seat, children, sequential) {
|
|
413
414
|
const node = seat.instance;
|
|
@@ -510,10 +511,10 @@ function updateNow(seat) {
|
|
|
510
511
|
node.children.beginMerge();
|
|
511
512
|
const driver = node.driver;
|
|
512
513
|
result = driver.update(node);
|
|
513
|
-
result = proceedSyncOrAsync(result, v => { runUpdateNestedNodesThenDo(undefined, NOP); return v; }, e => { console.log(e); runUpdateNestedNodesThenDo(e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
|
|
514
|
+
result = proceedSyncOrAsync(result, v => { runUpdateNestedNodesThenDo(seat, undefined, NOP); return v; }, e => { console.log(e); runUpdateNestedNodesThenDo(seat, e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
|
|
514
515
|
}
|
|
515
516
|
catch (e) {
|
|
516
|
-
runUpdateNestedNodesThenDo(e, NOP);
|
|
517
|
+
runUpdateNestedNodesThenDo(seat, e, NOP);
|
|
517
518
|
console.log(`Update failed: ${node.key}`);
|
|
518
519
|
console.log(`${e}`);
|
|
519
520
|
}
|
|
@@ -62,7 +62,7 @@ export declare class TransactionImpl extends Transaction {
|
|
|
62
62
|
cancel(error: Error, restartAfter?: Worker | null): this;
|
|
63
63
|
get isCanceled(): boolean;
|
|
64
64
|
get isFinished(): boolean;
|
|
65
|
-
whenFinished(): Promise<void>;
|
|
65
|
+
whenFinished(includingParent?: boolean): Promise<void>;
|
|
66
66
|
static run<T>(options: SnapshotOptions | null, func: F<T>, ...args: any[]): T;
|
|
67
67
|
static isolate<T>(func: F<T>, ...args: any[]): T;
|
|
68
68
|
static outside<T>(func: F<T>, ...args: any[]): T;
|
|
@@ -108,9 +108,11 @@ export class TransactionImpl extends Transaction {
|
|
|
108
108
|
get isFinished() {
|
|
109
109
|
return this.sealed && this.pending === 0;
|
|
110
110
|
}
|
|
111
|
-
whenFinished() {
|
|
111
|
+
whenFinished(includingParent) {
|
|
112
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
if (
|
|
113
|
+
if (includingParent && this.parent)
|
|
114
|
+
yield this.parent.whenFinished(includingParent);
|
|
115
|
+
else if (!this.isFinished)
|
|
114
116
|
yield this.acquirePromise();
|
|
115
117
|
});
|
|
116
118
|
}
|
|
@@ -209,6 +211,7 @@ export class TransactionImpl extends Transaction {
|
|
|
209
211
|
runImpl(logging, func, ...args) {
|
|
210
212
|
let result;
|
|
211
213
|
const outer = TransactionImpl.curr;
|
|
214
|
+
const p = this.parent;
|
|
212
215
|
try {
|
|
213
216
|
if (outer === TransactionImpl.none) {
|
|
214
217
|
TransactionImpl.frameStartTime = performance.now();
|
|
@@ -216,7 +219,9 @@ export class TransactionImpl extends Transaction {
|
|
|
216
219
|
}
|
|
217
220
|
TransactionImpl.curr = this;
|
|
218
221
|
this.pending++;
|
|
219
|
-
this.changeset.acquire(outer.changeset);
|
|
222
|
+
const acquired = this.changeset.acquire(outer.changeset);
|
|
223
|
+
if (acquired && p)
|
|
224
|
+
p.run(() => p.pending++);
|
|
220
225
|
result = func(...args);
|
|
221
226
|
if (this.sealed && this.pending === 1) {
|
|
222
227
|
if (!this.canceled)
|
|
@@ -234,6 +239,8 @@ export class TransactionImpl extends Transaction {
|
|
|
234
239
|
this.pending--;
|
|
235
240
|
if (this.sealed && this.pending === 0) {
|
|
236
241
|
const reactive = this.applyOrDiscard();
|
|
242
|
+
if (p)
|
|
243
|
+
p.runImpl(undefined, () => p.pending--);
|
|
237
244
|
TransactionImpl.curr = outer;
|
|
238
245
|
TransactionImpl.outside(Changeset.enqueueReactiveFunctionsToRun, reactive);
|
|
239
246
|
}
|
|
@@ -312,9 +319,17 @@ export class TransactionImpl extends Transaction {
|
|
|
312
319
|
if (Log.opt.transaction)
|
|
313
320
|
Log.write(changeset.timestamp < UNDEFINED_REVISION ? "╚══" : "═══", `s${this.timestamp}`, `${this.hint} - ${error ? "CANCEL" : "APPLY"}(${this.changeset.items.size})${error ? ` - ${error}` : ""}`);
|
|
314
321
|
}
|
|
315
|
-
|
|
322
|
+
let obsolete = changeset.obsolete;
|
|
323
|
+
if (changeset.parent) {
|
|
324
|
+
if (changeset.obsolete.length > 0) {
|
|
325
|
+
for (const o of changeset.obsolete)
|
|
326
|
+
changeset.parent.obsolete.push(o);
|
|
327
|
+
obsolete = [];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else if (!error)
|
|
316
331
|
Changeset.propagateAllChangesThroughSubscriptions(changeset);
|
|
317
|
-
return
|
|
332
|
+
return obsolete;
|
|
318
333
|
}
|
|
319
334
|
applyObjectChanges(h, ov) {
|
|
320
335
|
const parent = this.parent;
|
|
@@ -328,17 +343,11 @@ export class TransactionImpl extends Transaction {
|
|
|
328
343
|
const ovParent = csParent.getEditableObjectVersion(h, Meta.Undefined, undefined);
|
|
329
344
|
if (ov.former.objectVersion.changeset === EMPTY_OBJECT_VERSION.changeset) {
|
|
330
345
|
for (const fk in ov.data) {
|
|
331
|
-
if (fk === Meta.Revision) {
|
|
332
|
-
console.log("(!)");
|
|
333
|
-
}
|
|
334
346
|
TransactionImpl.migrateFieldVersionToAnotherTransaction(h, fk, ov, ovParent, tParent);
|
|
335
347
|
}
|
|
336
348
|
}
|
|
337
349
|
else {
|
|
338
350
|
ov.changes.forEach((o, fk) => {
|
|
339
|
-
if (fk === Meta.Revision) {
|
|
340
|
-
console.log("(!)");
|
|
341
|
-
}
|
|
342
351
|
TransactionImpl.migrateFieldVersionToAnotherTransaction(h, fk, ov, ovParent, tParent);
|
|
343
352
|
});
|
|
344
353
|
}
|