reactronic 0.92.25011 → 0.92.25012
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.
|
@@ -35,13 +35,13 @@ export declare abstract class ReactiveNode<E = unknown> {
|
|
|
35
35
|
abstract configureReactronic(options: Partial<MemberOptions>): MemberOptions;
|
|
36
36
|
static readonly shortFrameDuration = 16;
|
|
37
37
|
static readonly longFrameDuration = 300;
|
|
38
|
-
static
|
|
38
|
+
static currentScriptPriority: Priority;
|
|
39
39
|
static frameDuration: number;
|
|
40
40
|
static declare<E = void>(driver: ReactiveNodeDriver<E>, script?: Script<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>, triggers?: unknown, basis?: ReactiveNodeDecl<E>): ReactiveNode<E>;
|
|
41
41
|
static declare<E = void>(driver: ReactiveNodeDriver<E>, declaration?: ReactiveNodeDecl<E>): ReactiveNode<E>;
|
|
42
42
|
static declare<E = void>(driver: ReactiveNodeDriver<E>, scriptOrDeclaration?: Script<E> | ReactiveNodeDecl<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>, triggers?: unknown, basis?: ReactiveNodeDecl<E>): ReactiveNode<E>;
|
|
43
43
|
static withBasis<E = void>(declaration?: ReactiveNodeDecl<E>, basis?: ReactiveNodeDecl<E>): ReactiveNodeDecl<E>;
|
|
44
|
-
static get
|
|
44
|
+
static get isFirstScriptRun(): boolean;
|
|
45
45
|
static get key(): string;
|
|
46
46
|
static get stamp(): number;
|
|
47
47
|
static get triggers(): unknown;
|
|
@@ -49,9 +49,9 @@ export declare abstract class ReactiveNode<E = unknown> {
|
|
|
49
49
|
static set priority(value: Priority);
|
|
50
50
|
static get childrenShuffling(): boolean;
|
|
51
51
|
static set childrenShuffling(value: boolean);
|
|
52
|
-
static
|
|
52
|
+
static triggerScriptRun(node: ReactiveNode<any>, triggers: unknown): void;
|
|
53
53
|
static triggerFinalization(node: ReactiveNode<any>): void;
|
|
54
|
-
static
|
|
54
|
+
static runNestedNodeScriptsThenDo(action: (error: unknown) => void): void;
|
|
55
55
|
static markAsMounted(node: ReactiveNode<any>, yes: boolean): void;
|
|
56
56
|
static findMatchingHost<E = unknown, R = unknown>(node: ReactiveNode<E>, match: Handler<ReactiveNode<E>, boolean>): ReactiveNode<R> | undefined;
|
|
57
57
|
static findMatchingPrevSibling<E = unknown, R = unknown>(node: ReactiveNode<E>, match: Handler<ReactiveNode<E>, boolean>): ReactiveNode<R> | undefined;
|
|
@@ -71,7 +71,7 @@ export class ReactiveNode {
|
|
|
71
71
|
else {
|
|
72
72
|
result = new ReactiveNodeImpl(effectiveKey || "", driver, declaration, owner);
|
|
73
73
|
result.slot = MergeList.createItem(result);
|
|
74
|
-
|
|
74
|
+
triggerScriptRunViaSlot(result.slot);
|
|
75
75
|
}
|
|
76
76
|
return result;
|
|
77
77
|
}
|
|
@@ -82,7 +82,7 @@ export class ReactiveNode {
|
|
|
82
82
|
declaration = basis !== null && basis !== void 0 ? basis : {};
|
|
83
83
|
return declaration;
|
|
84
84
|
}
|
|
85
|
-
static get
|
|
85
|
+
static get isFirstScriptRun() {
|
|
86
86
|
return ReactiveNodeImpl.ownSlot.instance.stamp === 1;
|
|
87
87
|
}
|
|
88
88
|
static get key() {
|
|
@@ -106,20 +106,20 @@ export class ReactiveNode {
|
|
|
106
106
|
static set childrenShuffling(value) {
|
|
107
107
|
ReactiveNodeImpl.ownSlot.instance.childrenShuffling = value;
|
|
108
108
|
}
|
|
109
|
-
static
|
|
109
|
+
static triggerScriptRun(node, triggers) {
|
|
110
110
|
const impl = node;
|
|
111
111
|
const declaration = impl.declaration;
|
|
112
112
|
if (!triggersAreEqual(triggers, declaration.triggers)) {
|
|
113
113
|
declaration.triggers = triggers;
|
|
114
|
-
|
|
114
|
+
triggerScriptRunViaSlot(impl.slot);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
static triggerFinalization(node) {
|
|
118
118
|
const impl = node;
|
|
119
119
|
triggerFinalization(impl.slot, true, true);
|
|
120
120
|
}
|
|
121
|
-
static
|
|
122
|
-
|
|
121
|
+
static runNestedNodeScriptsThenDo(action) {
|
|
122
|
+
runNestedNodeScriptsThenDoImpl(ReactiveNodeImpl.ownSlot, undefined, action);
|
|
123
123
|
}
|
|
124
124
|
static markAsMounted(node, yes) {
|
|
125
125
|
const n = node;
|
|
@@ -155,7 +155,7 @@ export class ReactiveNode {
|
|
|
155
155
|
}
|
|
156
156
|
ReactiveNode.shortFrameDuration = 16;
|
|
157
157
|
ReactiveNode.longFrameDuration = 300;
|
|
158
|
-
ReactiveNode.
|
|
158
|
+
ReactiveNode.currentScriptPriority = Priority.realtime;
|
|
159
159
|
ReactiveNode.frameDuration = ReactiveNode.longFrameDuration;
|
|
160
160
|
export class BaseDriver {
|
|
161
161
|
constructor(name, isPartition, initialize) {
|
|
@@ -303,13 +303,13 @@ class ReactiveNodeImpl extends ReactiveNode {
|
|
|
303
303
|
has(mode) {
|
|
304
304
|
return (getModeUsingBasisChain(this.declaration) & mode) === mode;
|
|
305
305
|
}
|
|
306
|
-
|
|
307
|
-
|
|
306
|
+
script(_triggers) {
|
|
307
|
+
runScriptNow(this.slot);
|
|
308
308
|
}
|
|
309
309
|
configureReactronic(options) {
|
|
310
310
|
if (this.stamp < Number.MAX_SAFE_INTEGER - 1 || !this.has(Mode.autonomous))
|
|
311
311
|
throw new Error("reactronic can be configured only for elements with autonomous mode and only during activation");
|
|
312
|
-
return ReactiveSystem.getOperation(this.
|
|
312
|
+
return ReactiveSystem.getOperation(this.script).configure(options);
|
|
313
313
|
}
|
|
314
314
|
static get ownSlot() {
|
|
315
315
|
if (!gOwnSlot)
|
|
@@ -369,11 +369,11 @@ __decorate([
|
|
|
369
369
|
__metadata("design:type", Function),
|
|
370
370
|
__metadata("design:paramtypes", [Object]),
|
|
371
371
|
__metadata("design:returntype", void 0)
|
|
372
|
-
], ReactiveNodeImpl.prototype, "
|
|
372
|
+
], ReactiveNodeImpl.prototype, "script", null);
|
|
373
373
|
function getNodeKey(node) {
|
|
374
374
|
return node.stamp >= 0 ? node.key : undefined;
|
|
375
375
|
}
|
|
376
|
-
function
|
|
376
|
+
function runNestedNodeScriptsThenDoImpl(ownSlot, error, action) {
|
|
377
377
|
runInside(ownSlot, () => {
|
|
378
378
|
var _a;
|
|
379
379
|
const owner = ownSlot.instance;
|
|
@@ -399,7 +399,7 @@ function runUpdateNestedNodesThenDo(ownSlot, error, action) {
|
|
|
399
399
|
mounting = markToMountIfNecessary(mounting, host, child, children, sequential);
|
|
400
400
|
const p = (_a = childNode.priority) !== null && _a !== void 0 ? _a : Priority.realtime;
|
|
401
401
|
if (p === Priority.realtime)
|
|
402
|
-
|
|
402
|
+
triggerScriptRunViaSlot(child);
|
|
403
403
|
else if (p === Priority.normal)
|
|
404
404
|
p1 = push(child, p1);
|
|
405
405
|
else
|
|
@@ -408,7 +408,7 @@ function runUpdateNestedNodesThenDo(ownSlot, error, action) {
|
|
|
408
408
|
partition = childNode;
|
|
409
409
|
}
|
|
410
410
|
if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
|
|
411
|
-
promised =
|
|
411
|
+
promised = startIncrementalNestedScriptsRun(ownSlot, children, p1, p2).then(() => action(error), e => action(e));
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
finally {
|
|
@@ -431,34 +431,34 @@ function markToMountIfNecessary(mounting, host, slot, children, sequential) {
|
|
|
431
431
|
node.host = host;
|
|
432
432
|
return mounting;
|
|
433
433
|
}
|
|
434
|
-
function
|
|
434
|
+
function startIncrementalNestedScriptsRun(ownerSlot, allChildren, priority1, priority2) {
|
|
435
435
|
return __awaiter(this, void 0, void 0, function* () {
|
|
436
436
|
const stamp = ownerSlot.instance.stamp;
|
|
437
437
|
if (priority1)
|
|
438
|
-
yield
|
|
438
|
+
yield runNestedScriptsIncrementally(ownerSlot, stamp, allChildren, priority1, Priority.normal);
|
|
439
439
|
if (priority2)
|
|
440
|
-
yield
|
|
440
|
+
yield runNestedScriptsIncrementally(ownerSlot, stamp, allChildren, priority2, Priority.background);
|
|
441
441
|
});
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function runNestedScriptsIncrementally(owner, stamp, allChildren, items, priority) {
|
|
444
444
|
return __awaiter(this, void 0, void 0, function* () {
|
|
445
445
|
yield Transaction.requestNextFrame();
|
|
446
446
|
const node = owner.instance;
|
|
447
447
|
if (!Transaction.isCanceled || !Transaction.isFrameOver(1, ReactiveNode.shortFrameDuration / 3)) {
|
|
448
|
-
let outerPriority = ReactiveNode.
|
|
449
|
-
ReactiveNode.
|
|
448
|
+
let outerPriority = ReactiveNode.currentScriptPriority;
|
|
449
|
+
ReactiveNode.currentScriptPriority = priority;
|
|
450
450
|
try {
|
|
451
451
|
if (node.childrenShuffling)
|
|
452
452
|
shuffle(items);
|
|
453
453
|
const frameDurationLimit = priority === Priority.background ? ReactiveNode.shortFrameDuration : Infinity;
|
|
454
454
|
let frameDuration = Math.min(frameDurationLimit, Math.max(ReactiveNode.frameDuration / 4, ReactiveNode.shortFrameDuration));
|
|
455
455
|
for (const child of items) {
|
|
456
|
-
|
|
456
|
+
triggerScriptRunViaSlot(child);
|
|
457
457
|
if (Transaction.isFrameOver(1, frameDuration)) {
|
|
458
|
-
ReactiveNode.
|
|
458
|
+
ReactiveNode.currentScriptPriority = outerPriority;
|
|
459
459
|
yield Transaction.requestNextFrame(0);
|
|
460
|
-
outerPriority = ReactiveNode.
|
|
461
|
-
ReactiveNode.
|
|
460
|
+
outerPriority = ReactiveNode.currentScriptPriority;
|
|
461
|
+
ReactiveNode.currentScriptPriority = priority;
|
|
462
462
|
frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit, ReactiveNode.frameDuration));
|
|
463
463
|
}
|
|
464
464
|
if (Transaction.isCanceled && Transaction.isFrameOver(1, ReactiveNode.shortFrameDuration / 3))
|
|
@@ -466,12 +466,12 @@ function updateIncrementally(owner, stamp, allChildren, items, priority) {
|
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
468
|
finally {
|
|
469
|
-
ReactiveNode.
|
|
469
|
+
ReactiveNode.currentScriptPriority = outerPriority;
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
472
|
});
|
|
473
473
|
}
|
|
474
|
-
function
|
|
474
|
+
function triggerScriptRunViaSlot(slot) {
|
|
475
475
|
const node = slot.instance;
|
|
476
476
|
if (node.stamp >= 0) {
|
|
477
477
|
if (node.has(Mode.autonomous)) {
|
|
@@ -479,15 +479,15 @@ function triggerUpdateViaSlot(slot) {
|
|
|
479
479
|
Transaction.outside(() => {
|
|
480
480
|
if (ReactiveSystem.isLogging)
|
|
481
481
|
ReactiveSystem.setLoggingHint(node.element, node.key);
|
|
482
|
-
ReactiveSystem.getOperation(node.
|
|
482
|
+
ReactiveSystem.getOperation(node.script).configure({
|
|
483
483
|
order: node.level,
|
|
484
484
|
});
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
|
-
nonReactiveRun(node.
|
|
487
|
+
nonReactiveRun(node.script, node.declaration.triggers);
|
|
488
488
|
}
|
|
489
489
|
else
|
|
490
|
-
|
|
490
|
+
runScriptNow(slot);
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
function mountOrRemountIfNecessary(node) {
|
|
@@ -506,7 +506,7 @@ function mountOrRemountIfNecessary(node) {
|
|
|
506
506
|
else if (node.isMoved && !node.has(Mode.manualMount) && node.host !== node)
|
|
507
507
|
nonReactiveRun(() => driver.runMount(node));
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function runScriptNow(slot) {
|
|
510
510
|
const node = slot.instance;
|
|
511
511
|
if (node.stamp >= 0) {
|
|
512
512
|
let result = undefined;
|
|
@@ -519,11 +519,11 @@ function updateNow(slot) {
|
|
|
519
519
|
node.children.beginMerge();
|
|
520
520
|
const driver = node.driver;
|
|
521
521
|
result = driver.runScript(node);
|
|
522
|
-
result = proceedSyncOrAsync(result, v => {
|
|
522
|
+
result = proceedSyncOrAsync(result, v => { runNestedNodeScriptsThenDoImpl(slot, undefined, NOP); return v; }, e => { console.log(e); runNestedNodeScriptsThenDoImpl(slot, e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
|
|
523
523
|
}
|
|
524
524
|
catch (e) {
|
|
525
|
-
|
|
526
|
-
console.log(`
|
|
525
|
+
runNestedNodeScriptsThenDoImpl(slot, e, NOP);
|
|
526
|
+
console.log(`Reactive node script failed: ${node.key}`);
|
|
527
527
|
console.log(`${e}`);
|
|
528
528
|
}
|
|
529
529
|
}
|
|
@@ -85,7 +85,7 @@ export function getCallerInfo(prefix) {
|
|
|
85
85
|
i = i >= 0 ? i + 2 : 5;
|
|
86
86
|
let caller = extractFunctionAndLocation(lines[i]);
|
|
87
87
|
let location = caller;
|
|
88
|
-
if (caller.func.endsWith(".
|
|
88
|
+
if (caller.func.endsWith(".script")) {
|
|
89
89
|
i = i - 1;
|
|
90
90
|
caller = extractFunctionAndLocation(lines[i]);
|
|
91
91
|
location = extractFunctionAndLocation(lines[i + 1]);
|