reactronic 0.92.25011 → 0.92.25013
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/api.d.ts +0 -1
- package/build/dist/source/api.js +0 -1
- package/build/dist/source/core/ReactiveNode.d.ts +4 -4
- package/build/dist/source/core/ReactiveNode.js +72 -70
- package/build/dist/source/util/Utils.js +1 -1
- package/package.json +1 -1
- package/build/dist/source/RealTimeClock.d.ts +0 -14
- package/build/dist/source/RealTimeClock.js +0 -65
|
@@ -21,4 +21,3 @@ export { ReactiveSystem, observable, unobservable, atomic, reactive, cached, opt
|
|
|
21
21
|
export { ReactiveLoop } from "./ReactiveLoop.js";
|
|
22
22
|
export { ReactiveNode, Mode, Priority, BaseDriver, ReactiveNodeVariable } from "./core/ReactiveNode.js";
|
|
23
23
|
export type { Script, ScriptAsync, Handler, ReactiveNodeDecl, ReactiveNodeDriver, ReactiveNodeContext } from "./core/ReactiveNode.js";
|
|
24
|
-
export { RealTimeClock } from "./RealTimeClock.js";
|
package/build/dist/source/api.js
CHANGED
|
@@ -16,4 +16,3 @@ export { atomicRun, nonReactiveRun, sensitiveRun, contextualRun } from "./Reacti
|
|
|
16
16
|
export { ReactiveSystem, observable, unobservable, atomic, reactive, cached, options } from "./ReactiveSystem.js";
|
|
17
17
|
export { ReactiveLoop } from "./ReactiveLoop.js";
|
|
18
18
|
export { ReactiveNode, Mode, Priority, BaseDriver, ReactiveNodeVariable } from "./core/ReactiveNode.js";
|
|
19
|
-
export { RealTimeClock } from "./RealTimeClock.js";
|
|
@@ -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;
|
|
@@ -49,7 +49,7 @@ export class ReactiveNode {
|
|
|
49
49
|
else
|
|
50
50
|
declaration = scriptOrDeclaration !== null && scriptOrDeclaration !== void 0 ? scriptOrDeclaration : {};
|
|
51
51
|
let effectiveKey = declaration.key;
|
|
52
|
-
const owner = (getModeUsingBasisChain(declaration) & Mode.rootNode) !== Mode.rootNode ?
|
|
52
|
+
const owner = (getModeUsingBasisChain(declaration) & Mode.rootNode) !== Mode.rootNode ? gNodeSlot === null || gNodeSlot === void 0 ? void 0 : gNodeSlot.instance : undefined;
|
|
53
53
|
if (owner) {
|
|
54
54
|
let existing = owner.driver.declareChild(owner, driver, declaration, declaration.basis);
|
|
55
55
|
const children = owner.children;
|
|
@@ -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,44 +82,44 @@ export class ReactiveNode {
|
|
|
82
82
|
declaration = basis !== null && basis !== void 0 ? basis : {};
|
|
83
83
|
return declaration;
|
|
84
84
|
}
|
|
85
|
-
static get
|
|
86
|
-
return ReactiveNodeImpl.
|
|
85
|
+
static get isFirstScriptRun() {
|
|
86
|
+
return ReactiveNodeImpl.nodeSlot.instance.stamp === 1;
|
|
87
87
|
}
|
|
88
88
|
static get key() {
|
|
89
|
-
return ReactiveNodeImpl.
|
|
89
|
+
return ReactiveNodeImpl.nodeSlot.instance.key;
|
|
90
90
|
}
|
|
91
91
|
static get stamp() {
|
|
92
|
-
return ReactiveNodeImpl.
|
|
92
|
+
return ReactiveNodeImpl.nodeSlot.instance.stamp;
|
|
93
93
|
}
|
|
94
94
|
static get triggers() {
|
|
95
|
-
return ReactiveNodeImpl.
|
|
95
|
+
return ReactiveNodeImpl.nodeSlot.instance.declaration.triggers;
|
|
96
96
|
}
|
|
97
97
|
static get priority() {
|
|
98
|
-
return ReactiveNodeImpl.
|
|
98
|
+
return ReactiveNodeImpl.nodeSlot.instance.priority;
|
|
99
99
|
}
|
|
100
100
|
static set priority(value) {
|
|
101
|
-
ReactiveNodeImpl.
|
|
101
|
+
ReactiveNodeImpl.nodeSlot.instance.priority = value;
|
|
102
102
|
}
|
|
103
103
|
static get childrenShuffling() {
|
|
104
|
-
return ReactiveNodeImpl.
|
|
104
|
+
return ReactiveNodeImpl.nodeSlot.instance.childrenShuffling;
|
|
105
105
|
}
|
|
106
106
|
static set childrenShuffling(value) {
|
|
107
|
-
ReactiveNodeImpl.
|
|
107
|
+
ReactiveNodeImpl.nodeSlot.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.nodeSlot, 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,22 +303,22 @@ 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
|
-
static get
|
|
315
|
-
if (!
|
|
314
|
+
static get nodeSlot() {
|
|
315
|
+
if (!gNodeSlot)
|
|
316
316
|
throw new Error("current element is undefined");
|
|
317
|
-
return
|
|
317
|
+
return gNodeSlot;
|
|
318
318
|
}
|
|
319
319
|
static tryUseNodeVariableValue(variable) {
|
|
320
320
|
var _a, _b;
|
|
321
|
-
let node = ReactiveNodeImpl.
|
|
321
|
+
let node = ReactiveNodeImpl.nodeSlot.instance;
|
|
322
322
|
while (((_a = node.context) === null || _a === void 0 ? void 0 : _a.variable) !== variable && node.owner !== node)
|
|
323
323
|
node = node.outer.slot.instance;
|
|
324
324
|
return (_b = node.context) === null || _b === void 0 ? void 0 : _b.value;
|
|
@@ -331,7 +331,7 @@ class ReactiveNodeImpl extends ReactiveNode {
|
|
|
331
331
|
return result;
|
|
332
332
|
}
|
|
333
333
|
static setNodeVariableValue(variable, value) {
|
|
334
|
-
const node = ReactiveNodeImpl.
|
|
334
|
+
const node = ReactiveNodeImpl.nodeSlot.instance;
|
|
335
335
|
const owner = node.owner;
|
|
336
336
|
const hostCtx = nonReactiveRun(() => { var _a; return (_a = owner.context) === null || _a === void 0 ? void 0 : _a.value; });
|
|
337
337
|
if (value && value !== hostCtx) {
|
|
@@ -369,14 +369,14 @@ __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
|
|
377
|
-
|
|
376
|
+
function runNestedNodeScriptsThenDoImpl(nodeSlot, error, action) {
|
|
377
|
+
runInsideContextOfNode(nodeSlot, () => {
|
|
378
378
|
var _a;
|
|
379
|
-
const owner =
|
|
379
|
+
const owner = nodeSlot.instance;
|
|
380
380
|
const children = owner.children;
|
|
381
381
|
if (children.isMergeInProgress) {
|
|
382
382
|
let promised = undefined;
|
|
@@ -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(nodeSlot, children, p1, p2).then(() => action(error), e => action(e));
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
finally {
|
|
@@ -418,47 +418,47 @@ function runUpdateNestedNodesThenDo(ownSlot, error, action) {
|
|
|
418
418
|
}
|
|
419
419
|
});
|
|
420
420
|
}
|
|
421
|
-
function markToMountIfNecessary(mounting, host,
|
|
422
|
-
const node =
|
|
421
|
+
function markToMountIfNecessary(mounting, host, nodeSlot, children, sequential) {
|
|
422
|
+
const node = nodeSlot.instance;
|
|
423
423
|
if (node.element.native && !node.has(Mode.manualMount)) {
|
|
424
424
|
if (mounting || node.host !== host) {
|
|
425
|
-
children.markAsMoved(
|
|
425
|
+
children.markAsMoved(nodeSlot);
|
|
426
426
|
mounting = false;
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
|
-
else if (sequential && children.isMoved(
|
|
429
|
+
else if (sequential && children.isMoved(nodeSlot))
|
|
430
430
|
mounting = true;
|
|
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,28 +466,30 @@ 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
|
|
475
|
-
const node =
|
|
474
|
+
function triggerScriptRunViaSlot(nodeSlot) {
|
|
475
|
+
const node = nodeSlot.instance;
|
|
476
476
|
if (node.stamp >= 0) {
|
|
477
477
|
if (node.has(Mode.autonomous)) {
|
|
478
478
|
if (node.stamp === Number.MAX_SAFE_INTEGER) {
|
|
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
|
+
else if (node.owner !== node)
|
|
490
|
+
runScriptNow(nodeSlot);
|
|
489
491
|
else
|
|
490
|
-
|
|
492
|
+
atomicRun(() => runScriptNow(nodeSlot));
|
|
491
493
|
}
|
|
492
494
|
}
|
|
493
495
|
function mountOrRemountIfNecessary(node) {
|
|
@@ -506,11 +508,11 @@ function mountOrRemountIfNecessary(node) {
|
|
|
506
508
|
else if (node.isMoved && !node.has(Mode.manualMount) && node.host !== node)
|
|
507
509
|
nonReactiveRun(() => driver.runMount(node));
|
|
508
510
|
}
|
|
509
|
-
function
|
|
510
|
-
const node =
|
|
511
|
+
function runScriptNow(nodeSlot) {
|
|
512
|
+
const node = nodeSlot.instance;
|
|
511
513
|
if (node.stamp >= 0) {
|
|
512
514
|
let result = undefined;
|
|
513
|
-
|
|
515
|
+
runInsideContextOfNode(nodeSlot, () => {
|
|
514
516
|
mountOrRemountIfNecessary(node);
|
|
515
517
|
if (node.stamp < Number.MAX_SAFE_INTEGER - 1) {
|
|
516
518
|
try {
|
|
@@ -519,19 +521,19 @@ function updateNow(slot) {
|
|
|
519
521
|
node.children.beginMerge();
|
|
520
522
|
const driver = node.driver;
|
|
521
523
|
result = driver.runScript(node);
|
|
522
|
-
result = proceedSyncOrAsync(result, v => {
|
|
524
|
+
result = proceedSyncOrAsync(result, v => { runNestedNodeScriptsThenDoImpl(nodeSlot, undefined, NOP); return v; }, e => { console.log(e); runNestedNodeScriptsThenDoImpl(nodeSlot, e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
|
|
523
525
|
}
|
|
524
526
|
catch (e) {
|
|
525
|
-
|
|
526
|
-
console.log(`
|
|
527
|
+
runNestedNodeScriptsThenDoImpl(nodeSlot, e, NOP);
|
|
528
|
+
console.log(`Reactive node script failed: ${node.key}`);
|
|
527
529
|
console.log(`${e}`);
|
|
528
530
|
}
|
|
529
531
|
}
|
|
530
532
|
});
|
|
531
533
|
}
|
|
532
534
|
}
|
|
533
|
-
function triggerFinalization(
|
|
534
|
-
const node =
|
|
535
|
+
function triggerFinalization(nodeSlot, isLeader, individual) {
|
|
536
|
+
const node = nodeSlot.instance;
|
|
535
537
|
if (node.stamp >= 0) {
|
|
536
538
|
const driver = node.driver;
|
|
537
539
|
if (individual && node.key !== node.declaration.key && !driver.isPartition)
|
|
@@ -539,14 +541,14 @@ function triggerFinalization(slot, isLeader, individual) {
|
|
|
539
541
|
node.stamp = ~node.stamp;
|
|
540
542
|
const childrenAreLeaders = nonReactiveRun(() => driver.runFinalization(node, isLeader));
|
|
541
543
|
if (node.has(Mode.autonomous)) {
|
|
542
|
-
|
|
544
|
+
nodeSlot.aux = undefined;
|
|
543
545
|
const last = gLastToDispose;
|
|
544
546
|
if (last)
|
|
545
|
-
gLastToDispose = last.aux =
|
|
547
|
+
gLastToDispose = last.aux = nodeSlot;
|
|
546
548
|
else
|
|
547
|
-
gFirstToDispose = gLastToDispose =
|
|
548
|
-
if (gFirstToDispose ===
|
|
549
|
-
atomicRun({ isolation: Isolation.disjoinForInternalDisposal, hint: `runDisposalLoop(initiator=${
|
|
549
|
+
gFirstToDispose = gLastToDispose = nodeSlot;
|
|
550
|
+
if (gFirstToDispose === nodeSlot)
|
|
551
|
+
atomicRun({ isolation: Isolation.disjoinForInternalDisposal, hint: `runDisposalLoop(initiator=${nodeSlot.instance.key})` }, () => {
|
|
550
552
|
void runDisposalLoop().then(NOP, error => console.log(error));
|
|
551
553
|
});
|
|
552
554
|
}
|
|
@@ -571,23 +573,23 @@ function runDisposalLoop() {
|
|
|
571
573
|
}
|
|
572
574
|
function wrapToRunInside(func) {
|
|
573
575
|
let wrappedToRunInside;
|
|
574
|
-
const outer =
|
|
576
|
+
const outer = gNodeSlot;
|
|
575
577
|
if (outer)
|
|
576
578
|
wrappedToRunInside = (...args) => {
|
|
577
|
-
return
|
|
579
|
+
return runInsideContextOfNode(outer, func, ...args);
|
|
578
580
|
};
|
|
579
581
|
else
|
|
580
582
|
wrappedToRunInside = func;
|
|
581
583
|
return wrappedToRunInside;
|
|
582
584
|
}
|
|
583
|
-
function
|
|
584
|
-
const outer =
|
|
585
|
+
function runInsideContextOfNode(nodeSlot, func, ...args) {
|
|
586
|
+
const outer = gNodeSlot;
|
|
585
587
|
try {
|
|
586
|
-
|
|
588
|
+
gNodeSlot = nodeSlot;
|
|
587
589
|
return func(...args);
|
|
588
590
|
}
|
|
589
591
|
finally {
|
|
590
|
-
|
|
592
|
+
gNodeSlot = outer;
|
|
591
593
|
}
|
|
592
594
|
}
|
|
593
595
|
function triggersAreEqual(a1, a2) {
|
|
@@ -641,6 +643,6 @@ function defaultReject(error) {
|
|
|
641
643
|
Promise.prototype.then = reactronicDomHookedThen;
|
|
642
644
|
const NOP = (...args) => { };
|
|
643
645
|
const NOP_ASYNC = (...args) => __awaiter(void 0, void 0, void 0, function* () { });
|
|
644
|
-
let
|
|
646
|
+
let gNodeSlot = undefined;
|
|
645
647
|
let gFirstToDispose = undefined;
|
|
646
648
|
let gLastToDispose = undefined;
|
|
@@ -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]);
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ObservableObject } from "./core/Mvcc.js";
|
|
2
|
-
export declare class RealTimeClock extends ObservableObject {
|
|
3
|
-
hour: number;
|
|
4
|
-
minute: number;
|
|
5
|
-
second: number;
|
|
6
|
-
ms: number;
|
|
7
|
-
interval: number;
|
|
8
|
-
paused: boolean;
|
|
9
|
-
constructor(interval?: number);
|
|
10
|
-
pause(value?: boolean): void;
|
|
11
|
-
private tick;
|
|
12
|
-
protected activate(): void;
|
|
13
|
-
private put;
|
|
14
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { ObservableObject } from "./core/Mvcc.js";
|
|
11
|
-
import { atomic, reactive } from "./ReactiveSystem.js";
|
|
12
|
-
export class RealTimeClock extends ObservableObject {
|
|
13
|
-
constructor(interval = 1000) {
|
|
14
|
-
super();
|
|
15
|
-
this.hour = 0;
|
|
16
|
-
this.minute = 0;
|
|
17
|
-
this.second = 0;
|
|
18
|
-
this.ms = 0;
|
|
19
|
-
this.interval = 0;
|
|
20
|
-
this.paused = false;
|
|
21
|
-
this.interval = interval;
|
|
22
|
-
this.put(new Date());
|
|
23
|
-
}
|
|
24
|
-
pause(value = true) {
|
|
25
|
-
this.paused = value;
|
|
26
|
-
}
|
|
27
|
-
tick() {
|
|
28
|
-
let calibration = 0;
|
|
29
|
-
try {
|
|
30
|
-
const now = new Date();
|
|
31
|
-
this.put(now);
|
|
32
|
-
calibration = now.getTime() % this.interval;
|
|
33
|
-
}
|
|
34
|
-
finally {
|
|
35
|
-
setTimeout(() => this.tick(), this.interval - calibration);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
activate() {
|
|
39
|
-
this.tick();
|
|
40
|
-
}
|
|
41
|
-
put(time) {
|
|
42
|
-
this.hour = time.getHours();
|
|
43
|
-
this.minute = time.getMinutes();
|
|
44
|
-
this.second = time.getSeconds();
|
|
45
|
-
this.ms = time.getMilliseconds();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
__decorate([
|
|
49
|
-
atomic,
|
|
50
|
-
__metadata("design:type", Function),
|
|
51
|
-
__metadata("design:paramtypes", [Boolean]),
|
|
52
|
-
__metadata("design:returntype", void 0)
|
|
53
|
-
], RealTimeClock.prototype, "pause", null);
|
|
54
|
-
__decorate([
|
|
55
|
-
atomic,
|
|
56
|
-
__metadata("design:type", Function),
|
|
57
|
-
__metadata("design:paramtypes", []),
|
|
58
|
-
__metadata("design:returntype", void 0)
|
|
59
|
-
], RealTimeClock.prototype, "tick", null);
|
|
60
|
-
__decorate([
|
|
61
|
-
reactive,
|
|
62
|
-
__metadata("design:type", Function),
|
|
63
|
-
__metadata("design:paramtypes", []),
|
|
64
|
-
__metadata("design:returntype", void 0)
|
|
65
|
-
], RealTimeClock.prototype, "activate", null);
|