reactronic 0.92.25012 → 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.
|
@@ -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";
|
|
@@ -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;
|
|
@@ -83,28 +83,28 @@ export class ReactiveNode {
|
|
|
83
83
|
return declaration;
|
|
84
84
|
}
|
|
85
85
|
static get isFirstScriptRun() {
|
|
86
|
-
return ReactiveNodeImpl.
|
|
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
109
|
static triggerScriptRun(node, triggers) {
|
|
110
110
|
const impl = node;
|
|
@@ -119,7 +119,7 @@ export class ReactiveNode {
|
|
|
119
119
|
triggerFinalization(impl.slot, true, true);
|
|
120
120
|
}
|
|
121
121
|
static runNestedNodeScriptsThenDo(action) {
|
|
122
|
-
runNestedNodeScriptsThenDoImpl(ReactiveNodeImpl.
|
|
122
|
+
runNestedNodeScriptsThenDoImpl(ReactiveNodeImpl.nodeSlot, undefined, action);
|
|
123
123
|
}
|
|
124
124
|
static markAsMounted(node, yes) {
|
|
125
125
|
const n = node;
|
|
@@ -311,14 +311,14 @@ class ReactiveNodeImpl extends ReactiveNode {
|
|
|
311
311
|
throw new Error("reactronic can be configured only for elements with autonomous mode and only during activation");
|
|
312
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) {
|
|
@@ -373,10 +373,10 @@ __decorate([
|
|
|
373
373
|
function getNodeKey(node) {
|
|
374
374
|
return node.stamp >= 0 ? node.key : undefined;
|
|
375
375
|
}
|
|
376
|
-
function runNestedNodeScriptsThenDoImpl(
|
|
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;
|
|
@@ -408,7 +408,7 @@ function runNestedNodeScriptsThenDoImpl(ownSlot, error, action) {
|
|
|
408
408
|
partition = childNode;
|
|
409
409
|
}
|
|
410
410
|
if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
|
|
411
|
-
promised = startIncrementalNestedScriptsRun(
|
|
411
|
+
promised = startIncrementalNestedScriptsRun(nodeSlot, children, p1, p2).then(() => action(error), e => action(e));
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
finally {
|
|
@@ -418,15 +418,15 @@ function runNestedNodeScriptsThenDoImpl(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;
|
|
@@ -471,8 +471,8 @@ function runNestedScriptsIncrementally(owner, stamp, allChildren, items, priorit
|
|
|
471
471
|
}
|
|
472
472
|
});
|
|
473
473
|
}
|
|
474
|
-
function triggerScriptRunViaSlot(
|
|
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) {
|
|
@@ -486,8 +486,10 @@ function triggerScriptRunViaSlot(slot) {
|
|
|
486
486
|
}
|
|
487
487
|
nonReactiveRun(node.script, node.declaration.triggers);
|
|
488
488
|
}
|
|
489
|
+
else if (node.owner !== node)
|
|
490
|
+
runScriptNow(nodeSlot);
|
|
489
491
|
else
|
|
490
|
-
runScriptNow(
|
|
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 runScriptNow(
|
|
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,10 +521,10 @@ function runScriptNow(slot) {
|
|
|
519
521
|
node.children.beginMerge();
|
|
520
522
|
const driver = node.driver;
|
|
521
523
|
result = driver.runScript(node);
|
|
522
|
-
result = proceedSyncOrAsync(result, v => { runNestedNodeScriptsThenDoImpl(
|
|
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
|
-
runNestedNodeScriptsThenDoImpl(
|
|
527
|
+
runNestedNodeScriptsThenDoImpl(nodeSlot, e, NOP);
|
|
526
528
|
console.log(`Reactive node script failed: ${node.key}`);
|
|
527
529
|
console.log(`${e}`);
|
|
528
530
|
}
|
|
@@ -530,8 +532,8 @@ function runScriptNow(slot) {
|
|
|
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;
|
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);
|