reactronic 0.94.25031 → 0.94.25032
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/Enums.d.ts +1 -2
- package/build/dist/source/Enums.js +1 -2
- package/build/dist/source/api.d.ts +1 -1
- package/build/dist/source/api.js +1 -1
- package/build/dist/source/core/TreeNode.d.ts +3 -2
- package/build/dist/source/core/TreeNode.js +21 -18
- package/build/dist/source/util/Utils.d.ts +1 -0
- package/build/dist/source/util/Utils.js +3 -0
- package/package.json +1 -1
|
@@ -2,8 +2,7 @@ export var Mode;
|
|
|
2
2
|
(function (Mode) {
|
|
3
3
|
Mode[Mode["default"] = 0] = "default";
|
|
4
4
|
Mode[Mode["autonomous"] = 1] = "autonomous";
|
|
5
|
-
Mode[Mode["
|
|
6
|
-
Mode[Mode["rootNode"] = 4] = "rootNode";
|
|
5
|
+
Mode[Mode["external"] = 2] = "external";
|
|
7
6
|
})(Mode || (Mode = {}));
|
|
8
7
|
export var Priority;
|
|
9
8
|
(function (Priority) {
|
|
@@ -21,5 +21,5 @@ export { Journal } from "./core/Journal.js";
|
|
|
21
21
|
export { runAtomically, runNonReactively, runSensitively, runContextually, manageReactiveOperation, configureCurrentReactiveOperation, disposeObservableObject } from "./System.js";
|
|
22
22
|
export { ReactiveSystem, observable, atomic, reactive, cached, options } from "./System.js";
|
|
23
23
|
export { ReactiveOperationEx } from "./OperationEx.js";
|
|
24
|
-
export { ReactiveTreeNode, BaseDriver, ReactiveTreeVariable } from "./core/TreeNode.js";
|
|
24
|
+
export { launch, ReactiveTreeNode, BaseDriver, ReactiveTreeVariable } from "./core/TreeNode.js";
|
|
25
25
|
export type { Script, ScriptAsync, Handler, ReactiveTreeNodeDecl, ReactiveTreeNodeDriver, ReactiveTreeNodeContext } from "./core/TreeNode.js";
|
package/build/dist/source/api.js
CHANGED
|
@@ -17,4 +17,4 @@ export { Journal } from "./core/Journal.js";
|
|
|
17
17
|
export { runAtomically, runNonReactively, runSensitively, runContextually, manageReactiveOperation, configureCurrentReactiveOperation, disposeObservableObject } from "./System.js";
|
|
18
18
|
export { ReactiveSystem, observable, atomic, reactive, cached, options } from "./System.js";
|
|
19
19
|
export { ReactiveOperationEx } from "./OperationEx.js";
|
|
20
|
-
export { ReactiveTreeNode, BaseDriver, ReactiveTreeVariable } from "./core/TreeNode.js";
|
|
20
|
+
export { launch, ReactiveTreeNode, BaseDriver, ReactiveTreeVariable } from "./core/TreeNode.js";
|
|
@@ -6,6 +6,7 @@ import { ObservableObject } from "../core/Mvcc.js";
|
|
|
6
6
|
export type Script<E> = (el: E, basis: () => void) => void;
|
|
7
7
|
export type ScriptAsync<E> = (el: E, basis: () => Promise<void>) => Promise<void>;
|
|
8
8
|
export type Handler<E = unknown, R = void> = (el: E) => R;
|
|
9
|
+
export declare function launch<T>(node: ReactiveTreeNode<T>, triggers?: unknown): ReactiveTreeNode<T>;
|
|
9
10
|
export declare abstract class ReactiveTreeNode<E = unknown> {
|
|
10
11
|
static readonly shortFrameDuration = 16;
|
|
11
12
|
static readonly longFrameDuration = 300;
|
|
@@ -35,8 +36,8 @@ export declare abstract class ReactiveTreeNode<E = unknown> {
|
|
|
35
36
|
static declare<E = void>(driver: ReactiveTreeNodeDriver<E>, declaration?: ReactiveTreeNodeDecl<E>): ReactiveTreeNode<E>;
|
|
36
37
|
static declare<E = void>(driver: ReactiveTreeNodeDriver<E>, scriptOrDeclaration?: Script<E> | ReactiveTreeNodeDecl<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>, triggers?: unknown, basis?: ReactiveTreeNodeDecl<E>): ReactiveTreeNode<E>;
|
|
37
38
|
static withBasis<E = void>(declaration?: ReactiveTreeNodeDecl<E>, basis?: ReactiveTreeNodeDecl<E>): ReactiveTreeNodeDecl<E>;
|
|
38
|
-
static
|
|
39
|
-
static
|
|
39
|
+
static launchScript(node: ReactiveTreeNode<any>, triggers: unknown): void;
|
|
40
|
+
static launchFinalization(node: ReactiveTreeNode<any>): void;
|
|
40
41
|
static runNestedNodeScriptsThenDo(action: (error: unknown) => void): void;
|
|
41
42
|
static markAsMounted(node: ReactiveTreeNode<any>, yes: boolean): void;
|
|
42
43
|
lookupTreeNodeByUri<E = unknown>(uri: string): ReactiveTreeNode<E> | undefined;
|
|
@@ -19,11 +19,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
import { misuse } from "../util/Dbg.js";
|
|
20
20
|
import { Uri } from "../util/Uri.js";
|
|
21
21
|
import { MergeList } from "../util/MergeList.js";
|
|
22
|
-
import { emitLetters, getCallerInfo, proceedSyncOrAsync } from "../util/Utils.js";
|
|
22
|
+
import { emitLetters, flags, getCallerInfo, proceedSyncOrAsync } from "../util/Utils.js";
|
|
23
23
|
import { Priority, Mode, Isolation, Reentrance } from "../Enums.js";
|
|
24
24
|
import { ObservableObject } from "../core/Mvcc.js";
|
|
25
25
|
import { Transaction } from "../core/Transaction.js";
|
|
26
26
|
import { ReactiveSystem, options, observable, reactive, runAtomically, runNonReactively, manageReactiveOperation, disposeObservableObject } from "../System.js";
|
|
27
|
+
export function launch(node, triggers) {
|
|
28
|
+
ReactiveTreeNode.launchScript(node, triggers);
|
|
29
|
+
return node;
|
|
30
|
+
}
|
|
27
31
|
export class ReactiveTreeNode {
|
|
28
32
|
static get current() {
|
|
29
33
|
return ReactiveTreeNodeImpl.nodeSlot.instance;
|
|
@@ -43,7 +47,7 @@ export class ReactiveTreeNode {
|
|
|
43
47
|
else
|
|
44
48
|
declaration = scriptOrDeclaration !== null && scriptOrDeclaration !== void 0 ? scriptOrDeclaration : {};
|
|
45
49
|
let effectiveKey = declaration.key;
|
|
46
|
-
const owner =
|
|
50
|
+
const owner = gNodeSlot === null || gNodeSlot === void 0 ? void 0 : gNodeSlot.instance;
|
|
47
51
|
if (owner) {
|
|
48
52
|
let existing = owner.driver.declareChild(owner, driver, declaration, declaration.basis);
|
|
49
53
|
const children = owner.children;
|
|
@@ -65,7 +69,6 @@ export class ReactiveTreeNode {
|
|
|
65
69
|
else {
|
|
66
70
|
result = new ReactiveTreeNodeImpl(effectiveKey || generateKey(owner), driver, declaration, owner);
|
|
67
71
|
result.slot = MergeList.createItem(result);
|
|
68
|
-
triggerScriptRunViaSlot(result.slot);
|
|
69
72
|
}
|
|
70
73
|
return result;
|
|
71
74
|
}
|
|
@@ -76,17 +79,17 @@ export class ReactiveTreeNode {
|
|
|
76
79
|
declaration = basis !== null && basis !== void 0 ? basis : {};
|
|
77
80
|
return declaration;
|
|
78
81
|
}
|
|
79
|
-
static
|
|
82
|
+
static launchScript(node, triggers) {
|
|
80
83
|
const impl = node;
|
|
81
84
|
const declaration = impl.declaration;
|
|
82
|
-
if (!observablesAreEqual(triggers, declaration.triggers)) {
|
|
85
|
+
if (node.stamp >= Number.MAX_SAFE_INTEGER || !observablesAreEqual(triggers, declaration.triggers)) {
|
|
83
86
|
declaration.triggers = triggers;
|
|
84
|
-
|
|
87
|
+
launchScriptViaSlot(impl.slot);
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
|
-
static
|
|
90
|
+
static launchFinalization(node) {
|
|
88
91
|
const impl = node;
|
|
89
|
-
|
|
92
|
+
launchFinalization(impl.slot, true, true);
|
|
90
93
|
}
|
|
91
94
|
static runNestedNodeScriptsThenDo(action) {
|
|
92
95
|
runNestedNodeScriptsThenDoImpl(ReactiveTreeNodeImpl.nodeSlot, undefined, action);
|
|
@@ -298,7 +301,7 @@ class ReactiveTreeNodeImpl extends ReactiveTreeNode {
|
|
|
298
301
|
return this.owner.children.isMoved(this.slot);
|
|
299
302
|
}
|
|
300
303
|
has(mode) {
|
|
301
|
-
return (getModeUsingBasisChain(this.declaration)
|
|
304
|
+
return flags(getModeUsingBasisChain(this.declaration), mode);
|
|
302
305
|
}
|
|
303
306
|
script(_triggers) {
|
|
304
307
|
runScriptNow(this.slot);
|
|
@@ -390,7 +393,7 @@ function runNestedNodeScriptsThenDoImpl(nodeSlot, error, action) {
|
|
|
390
393
|
try {
|
|
391
394
|
children.endMerge(error);
|
|
392
395
|
for (const child of children.removedItems(true))
|
|
393
|
-
|
|
396
|
+
launchFinalization(child, true, true);
|
|
394
397
|
if (!error) {
|
|
395
398
|
const sequential = children.isStrict;
|
|
396
399
|
let p1 = undefined;
|
|
@@ -406,7 +409,7 @@ function runNestedNodeScriptsThenDoImpl(nodeSlot, error, action) {
|
|
|
406
409
|
mounting = markToMountIfNecessary(mounting, host, child, children, sequential);
|
|
407
410
|
const p = (_a = childNode.priority) !== null && _a !== void 0 ? _a : Priority.realtime;
|
|
408
411
|
if (p === Priority.realtime)
|
|
409
|
-
|
|
412
|
+
launchScriptViaSlot(child);
|
|
410
413
|
else if (p === Priority.normal)
|
|
411
414
|
p1 = push(child, p1);
|
|
412
415
|
else
|
|
@@ -427,7 +430,7 @@ function runNestedNodeScriptsThenDoImpl(nodeSlot, error, action) {
|
|
|
427
430
|
}
|
|
428
431
|
function markToMountIfNecessary(mounting, host, nodeSlot, children, sequential) {
|
|
429
432
|
const node = nodeSlot.instance;
|
|
430
|
-
if (node.element.native && !node.has(Mode.
|
|
433
|
+
if (node.element.native && !node.has(Mode.external)) {
|
|
431
434
|
if (mounting || node.host !== host) {
|
|
432
435
|
children.markAsMoved(nodeSlot);
|
|
433
436
|
mounting = false;
|
|
@@ -460,7 +463,7 @@ function runNestedScriptsIncrementally(owner, stamp, allChildren, items, priorit
|
|
|
460
463
|
const frameDurationLimit = priority === Priority.background ? ReactiveTreeNode.shortFrameDuration : Infinity;
|
|
461
464
|
let frameDuration = Math.min(frameDurationLimit, Math.max(ReactiveTreeNode.frameDuration / 4, ReactiveTreeNode.shortFrameDuration));
|
|
462
465
|
for (const child of items) {
|
|
463
|
-
|
|
466
|
+
launchScriptViaSlot(child);
|
|
464
467
|
if (Transaction.isFrameOver(1, frameDuration)) {
|
|
465
468
|
ReactiveTreeNodeImpl.currentScriptPriority = outerPriority;
|
|
466
469
|
yield Transaction.requestNextFrame(0);
|
|
@@ -478,7 +481,7 @@ function runNestedScriptsIncrementally(owner, stamp, allChildren, items, priorit
|
|
|
478
481
|
}
|
|
479
482
|
});
|
|
480
483
|
}
|
|
481
|
-
function
|
|
484
|
+
function launchScriptViaSlot(nodeSlot) {
|
|
482
485
|
const node = nodeSlot.instance;
|
|
483
486
|
if (node.stamp >= 0) {
|
|
484
487
|
if (node.has(Mode.autonomous)) {
|
|
@@ -505,14 +508,14 @@ function mountOrRemountIfNecessary(node) {
|
|
|
505
508
|
runNonReactively(() => {
|
|
506
509
|
node.stamp = Number.MAX_SAFE_INTEGER - 1;
|
|
507
510
|
driver.runPreparation(node);
|
|
508
|
-
if (!node.has(Mode.
|
|
511
|
+
if (!node.has(Mode.external)) {
|
|
509
512
|
node.stamp = 0;
|
|
510
513
|
if (node.host !== node)
|
|
511
514
|
driver.runMount(node);
|
|
512
515
|
}
|
|
513
516
|
});
|
|
514
517
|
}
|
|
515
|
-
else if (node.isMoved && !node.has(Mode.
|
|
518
|
+
else if (node.isMoved && !node.has(Mode.external) && node.host !== node)
|
|
516
519
|
runNonReactively(() => driver.runMount(node));
|
|
517
520
|
}
|
|
518
521
|
function runScriptNow(nodeSlot) {
|
|
@@ -539,7 +542,7 @@ function runScriptNow(nodeSlot) {
|
|
|
539
542
|
});
|
|
540
543
|
}
|
|
541
544
|
}
|
|
542
|
-
function
|
|
545
|
+
function launchFinalization(nodeSlot, isLeader, individual) {
|
|
543
546
|
const node = nodeSlot.instance;
|
|
544
547
|
if (node.stamp >= 0) {
|
|
545
548
|
const driver = node.driver;
|
|
@@ -560,7 +563,7 @@ function triggerFinalization(nodeSlot, isLeader, individual) {
|
|
|
560
563
|
});
|
|
561
564
|
}
|
|
562
565
|
for (const child of node.children.items())
|
|
563
|
-
|
|
566
|
+
launchFinalization(child, childrenAreLeaders, false);
|
|
564
567
|
ReactiveTreeNodeImpl.grandNodeCount--;
|
|
565
568
|
}
|
|
566
569
|
}
|
|
@@ -4,6 +4,7 @@ export declare class Utils {
|
|
|
4
4
|
static freezeMap<K, V>(obj?: Map<K, V>): Map<K, V> | undefined;
|
|
5
5
|
static copyAllMembers(source: any, target: any): any;
|
|
6
6
|
}
|
|
7
|
+
export declare function flags(value: number, flags: number): boolean;
|
|
7
8
|
export declare function UNDEF(...args: any[]): never;
|
|
8
9
|
export declare function all(promises: Array<Promise<any>>): Promise<any[]>;
|
|
9
10
|
export declare function pause<T>(timeout: number): Promise<T>;
|