reactronic 0.24.116 → 0.24.118
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 +2 -3
- package/build/dist/source/api.js +1 -2
- package/build/dist/source/core/RxNode.d.ts +88 -0
- package/build/dist/source/{tree/RxTree.js → core/RxNode.js} +30 -19
- package/build/dist/source/{tree → core}/RxNodeUtils.js +1 -1
- package/package.json +1 -1
- package/build/dist/source/tree/RxNode.d.ts +0 -55
- package/build/dist/source/tree/RxNode.js +0 -12
- package/build/dist/source/tree/RxTree.d.ts +0 -36
- /package/build/dist/source/{tree → core}/RxNodeUtils.d.ts +0 -0
|
@@ -17,7 +17,6 @@ export { Transaction } from './core/Transaction.js';
|
|
|
17
17
|
export { Monitor } from './core/Monitor.js';
|
|
18
18
|
export { Journal } from './core/Journal.js';
|
|
19
19
|
export { RxSystem, raw, obs, transactional, reactive, cached, transaction, unobs, sensitive, options } from './RxSystem.js';
|
|
20
|
-
export { Mode, Priority } from './
|
|
21
|
-
export type { Delegate, SimpleDelegate,
|
|
22
|
-
export { RxTree, BaseDriver, RxNodeVariable } from './tree/RxTree.js';
|
|
20
|
+
export { RxNode, Mode, Priority, BaseDriver, RxNodeVariable } from './core/RxNode.js';
|
|
21
|
+
export type { Delegate, SimpleDelegate, RxNodeDecl, RxNodeDriver, RxNodeContext } from './core/RxNode.js';
|
|
23
22
|
export { Clock } from './Clock.js';
|
package/build/dist/source/api.js
CHANGED
|
@@ -13,6 +13,5 @@ export { Transaction } from './core/Transaction.js';
|
|
|
13
13
|
export { Monitor } from './core/Monitor.js';
|
|
14
14
|
export { Journal } from './core/Journal.js';
|
|
15
15
|
export { RxSystem, raw, obs, transactional, reactive, cached, transaction, unobs, sensitive, options } from './RxSystem.js';
|
|
16
|
-
export { Mode, Priority } from './
|
|
17
|
-
export { RxTree, BaseDriver, RxNodeVariable } from './tree/RxTree.js';
|
|
16
|
+
export { RxNode, Mode, Priority, BaseDriver, RxNodeVariable } from './core/RxNode.js';
|
|
18
17
|
export { Clock } from './Clock.js';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { LoggingOptions } from '../Logging.js';
|
|
2
|
+
import { MergeListReader, MergedItem } from '../util/MergeList.js';
|
|
3
|
+
import { MemberOptions } from '../Options.js';
|
|
4
|
+
export type Delegate<T> = (element: T, base: () => void) => void;
|
|
5
|
+
export type SimpleDelegate<T = unknown, R = void> = (element: T) => R;
|
|
6
|
+
export declare enum Mode {
|
|
7
|
+
Default = 0,
|
|
8
|
+
IndependentUpdate = 1,
|
|
9
|
+
ManualMount = 2
|
|
10
|
+
}
|
|
11
|
+
export declare const enum Priority {
|
|
12
|
+
Realtime = 0,
|
|
13
|
+
Normal = 1,
|
|
14
|
+
Background = 2
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class RxNode<E = unknown> {
|
|
17
|
+
abstract readonly key: string;
|
|
18
|
+
abstract readonly driver: RxNodeDriver<E>;
|
|
19
|
+
abstract readonly declaration: Readonly<RxNodeDecl<E>>;
|
|
20
|
+
abstract readonly level: number;
|
|
21
|
+
abstract readonly owner: RxNode;
|
|
22
|
+
abstract element: E;
|
|
23
|
+
abstract readonly host: RxNode;
|
|
24
|
+
abstract readonly children: MergeListReader<RxNode>;
|
|
25
|
+
abstract readonly seat: MergedItem<RxNode<E>> | undefined;
|
|
26
|
+
abstract readonly stamp: number;
|
|
27
|
+
abstract readonly outer: RxNode;
|
|
28
|
+
abstract readonly context: RxNodeContext | undefined;
|
|
29
|
+
abstract priority?: Priority;
|
|
30
|
+
abstract childrenShuffling: boolean;
|
|
31
|
+
abstract strictOrder: boolean;
|
|
32
|
+
abstract has(mode: Mode): boolean;
|
|
33
|
+
abstract configureReactronic(options: Partial<MemberOptions>): MemberOptions;
|
|
34
|
+
static readonly shortFrameDuration = 16;
|
|
35
|
+
static readonly longFrameDuration = 300;
|
|
36
|
+
static currentUpdatePriority: Priority;
|
|
37
|
+
static frameDuration: number;
|
|
38
|
+
static acquire<E = void>(driver: RxNodeDriver<E>, declaration?: RxNodeDecl<E>, preset?: RxNodeDecl<E>): RxNode<E>;
|
|
39
|
+
static get isFirstUpdate(): boolean;
|
|
40
|
+
static get nodeStamp(): number;
|
|
41
|
+
static triggerUpdate(node: RxNode<any>, triggers: unknown): void;
|
|
42
|
+
static updateNestedTreesThenDo(action: (error: unknown) => void): void;
|
|
43
|
+
static findMatchingHost<E = unknown, R = unknown>(node: RxNode<E>, match: SimpleDelegate<RxNode<E>, boolean>): RxNode<R> | undefined;
|
|
44
|
+
static findMatchingPrevSibling<E = unknown, R = unknown>(node: RxNode<E>, match: SimpleDelegate<RxNode<E>, boolean>): RxNode<R> | undefined;
|
|
45
|
+
static forEachChildRecursively<E = unknown>(node: RxNode<E>, action: SimpleDelegate<RxNode<E>>): void;
|
|
46
|
+
static getDefaultLoggingOptions(): LoggingOptions | undefined;
|
|
47
|
+
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
48
|
+
}
|
|
49
|
+
export interface RxNodeDecl<E = unknown> {
|
|
50
|
+
preset?: RxNodeDecl<E>;
|
|
51
|
+
key?: string;
|
|
52
|
+
mode?: Mode;
|
|
53
|
+
triggers?: unknown;
|
|
54
|
+
initialize?: Delegate<E>;
|
|
55
|
+
update?: Delegate<E>;
|
|
56
|
+
finalize?: Delegate<E>;
|
|
57
|
+
}
|
|
58
|
+
export interface RxNodeDriver<E = unknown> {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly isPartitionSeparator: boolean;
|
|
61
|
+
readonly predefine?: SimpleDelegate<E>;
|
|
62
|
+
allocate(node: RxNode<E>): E;
|
|
63
|
+
initialize(node: RxNode<E>): void;
|
|
64
|
+
mount(node: RxNode<E>): void;
|
|
65
|
+
update(node: RxNode<E>): void | Promise<void>;
|
|
66
|
+
finalize(node: RxNode<E>, isLeader: boolean): boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface RxNodeContext<T extends Object = Object> {
|
|
69
|
+
value: T;
|
|
70
|
+
}
|
|
71
|
+
export declare abstract class BaseDriver<E = unknown> implements RxNodeDriver<E> {
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly isPartitionSeparator: boolean;
|
|
74
|
+
readonly predefine?: SimpleDelegate<E, void> | undefined;
|
|
75
|
+
constructor(name: string, isPartitionSeparator: boolean, predefine?: SimpleDelegate<E, void> | undefined);
|
|
76
|
+
abstract allocate(node: RxNode<E>): E;
|
|
77
|
+
initialize(node: RxNode<E>): void;
|
|
78
|
+
mount(node: RxNode<E>): void;
|
|
79
|
+
update(node: RxNode<E>): void | Promise<void>;
|
|
80
|
+
finalize(node: RxNode<E>, isLeader: boolean): boolean;
|
|
81
|
+
}
|
|
82
|
+
export declare class RxNodeVariable<T extends Object = Object> {
|
|
83
|
+
readonly defaultValue: T | undefined;
|
|
84
|
+
constructor(defaultValue?: T);
|
|
85
|
+
set value(value: T);
|
|
86
|
+
get value(): T;
|
|
87
|
+
get valueOrUndefined(): T | undefined;
|
|
88
|
+
}
|
|
@@ -22,9 +22,20 @@ import { Reentrance } from '../Options.js';
|
|
|
22
22
|
import { ObservableObject } from '../core/Mvcc.js';
|
|
23
23
|
import { Transaction } from '../core/Transaction.js';
|
|
24
24
|
import { RxSystem, options, raw, reactive, unobs } from '../RxSystem.js';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
export var Mode;
|
|
26
|
+
(function (Mode) {
|
|
27
|
+
Mode[Mode["Default"] = 0] = "Default";
|
|
28
|
+
Mode[Mode["IndependentUpdate"] = 1] = "IndependentUpdate";
|
|
29
|
+
Mode[Mode["ManualMount"] = 2] = "ManualMount";
|
|
30
|
+
})(Mode || (Mode = {}));
|
|
31
|
+
export var Priority;
|
|
32
|
+
(function (Priority) {
|
|
33
|
+
Priority[Priority["Realtime"] = 0] = "Realtime";
|
|
34
|
+
Priority[Priority["Normal"] = 1] = "Normal";
|
|
35
|
+
Priority[Priority["Background"] = 2] = "Background";
|
|
36
|
+
})(Priority || (Priority = {}));
|
|
37
|
+
export class RxNode {
|
|
38
|
+
static acquire(driver, declaration, preset) {
|
|
28
39
|
var _a;
|
|
29
40
|
let result;
|
|
30
41
|
if (declaration)
|
|
@@ -96,7 +107,7 @@ export class RxTree {
|
|
|
96
107
|
static forEachChildRecursively(node, action) {
|
|
97
108
|
action(node);
|
|
98
109
|
for (const child of node.children.items())
|
|
99
|
-
|
|
110
|
+
RxNode.forEachChildRecursively(child.instance, action);
|
|
100
111
|
}
|
|
101
112
|
static getDefaultLoggingOptions() {
|
|
102
113
|
return RxNodeImpl.logging;
|
|
@@ -105,10 +116,10 @@ export class RxTree {
|
|
|
105
116
|
RxNodeImpl.logging = logging;
|
|
106
117
|
}
|
|
107
118
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
RxNode.shortFrameDuration = 16;
|
|
120
|
+
RxNode.longFrameDuration = 300;
|
|
121
|
+
RxNode.currentUpdatePriority = Priority.Realtime;
|
|
122
|
+
RxNode.frameDuration = RxNode.longFrameDuration;
|
|
112
123
|
export class BaseDriver {
|
|
113
124
|
constructor(name, isPartitionSeparator, predefine) {
|
|
114
125
|
this.name = name;
|
|
@@ -373,29 +384,29 @@ function updateIncrementally(owner, stamp, allChildren, items, priority) {
|
|
|
373
384
|
return __awaiter(this, void 0, void 0, function* () {
|
|
374
385
|
yield Transaction.requestNextFrame();
|
|
375
386
|
const node = owner.instance;
|
|
376
|
-
if (!Transaction.isCanceled || !Transaction.isFrameOver(1,
|
|
377
|
-
let outerPriority =
|
|
378
|
-
|
|
387
|
+
if (!Transaction.isCanceled || !Transaction.isFrameOver(1, RxNode.shortFrameDuration / 3)) {
|
|
388
|
+
let outerPriority = RxNode.currentUpdatePriority;
|
|
389
|
+
RxNode.currentUpdatePriority = priority;
|
|
379
390
|
try {
|
|
380
391
|
if (node.childrenShuffling)
|
|
381
392
|
shuffle(items);
|
|
382
|
-
const frameDurationLimit = priority === Priority.Background ?
|
|
383
|
-
let frameDuration = Math.min(frameDurationLimit, Math.max(
|
|
393
|
+
const frameDurationLimit = priority === Priority.Background ? RxNode.shortFrameDuration : Infinity;
|
|
394
|
+
let frameDuration = Math.min(frameDurationLimit, Math.max(RxNode.frameDuration / 4, RxNode.shortFrameDuration));
|
|
384
395
|
for (const child of items) {
|
|
385
396
|
triggerUpdateViaSeat(child);
|
|
386
397
|
if (Transaction.isFrameOver(1, frameDuration)) {
|
|
387
|
-
|
|
398
|
+
RxNode.currentUpdatePriority = outerPriority;
|
|
388
399
|
yield Transaction.requestNextFrame(0);
|
|
389
|
-
outerPriority =
|
|
390
|
-
|
|
391
|
-
frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit,
|
|
400
|
+
outerPriority = RxNode.currentUpdatePriority;
|
|
401
|
+
RxNode.currentUpdatePriority = priority;
|
|
402
|
+
frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit, RxNode.frameDuration));
|
|
392
403
|
}
|
|
393
|
-
if (Transaction.isCanceled && Transaction.isFrameOver(1,
|
|
404
|
+
if (Transaction.isCanceled && Transaction.isFrameOver(1, RxNode.shortFrameDuration / 3))
|
|
394
405
|
break;
|
|
395
406
|
}
|
|
396
407
|
}
|
|
397
408
|
finally {
|
|
398
|
-
|
|
409
|
+
RxNode.currentUpdatePriority = outerPriority;
|
|
399
410
|
}
|
|
400
411
|
}
|
|
401
412
|
});
|
|
@@ -18,7 +18,7 @@ export function getCallerInfo(prefix) {
|
|
|
18
18
|
const stack = error.stack || '';
|
|
19
19
|
Error.stackTraceLimit = restore;
|
|
20
20
|
const lines = stack.split('\n');
|
|
21
|
-
let i = lines.findIndex(x => x.indexOf('.
|
|
21
|
+
let i = lines.findIndex(x => x.indexOf('.acquire') >= 0);
|
|
22
22
|
i = i >= 0 ? i + 2 : 5;
|
|
23
23
|
let caller = extractFunctionAndLocation(lines[i]);
|
|
24
24
|
let location = caller;
|
package/package.json
CHANGED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { MergeListReader, MergedItem } from '../util/MergeList.js';
|
|
2
|
-
import { MemberOptions } from '../Options.js';
|
|
3
|
-
export type Delegate<T> = (element: T, base: () => void) => void;
|
|
4
|
-
export type SimpleDelegate<T = unknown, R = void> = (element: T) => R;
|
|
5
|
-
export declare enum Mode {
|
|
6
|
-
Default = 0,
|
|
7
|
-
IndependentUpdate = 1,
|
|
8
|
-
ManualMount = 2
|
|
9
|
-
}
|
|
10
|
-
export declare const enum Priority {
|
|
11
|
-
Realtime = 0,
|
|
12
|
-
Normal = 1,
|
|
13
|
-
Background = 2
|
|
14
|
-
}
|
|
15
|
-
export interface RxNode<E = unknown> {
|
|
16
|
-
readonly key: string;
|
|
17
|
-
readonly driver: RxNodeDriver<E>;
|
|
18
|
-
readonly declaration: Readonly<RxNodeDecl<E>>;
|
|
19
|
-
readonly level: number;
|
|
20
|
-
readonly owner: RxNode;
|
|
21
|
-
element: E;
|
|
22
|
-
readonly host: RxNode;
|
|
23
|
-
readonly children: MergeListReader<RxNode>;
|
|
24
|
-
readonly seat: MergedItem<RxNode<E>> | undefined;
|
|
25
|
-
readonly stamp: number;
|
|
26
|
-
readonly outer: RxNode;
|
|
27
|
-
readonly context: RxNodeContext | undefined;
|
|
28
|
-
priority?: Priority;
|
|
29
|
-
childrenShuffling: boolean;
|
|
30
|
-
strictOrder: boolean;
|
|
31
|
-
has(mode: Mode): boolean;
|
|
32
|
-
configureReactronic(options: Partial<MemberOptions>): MemberOptions;
|
|
33
|
-
}
|
|
34
|
-
export interface RxNodeDecl<E = unknown> {
|
|
35
|
-
preset?: RxNodeDecl<E>;
|
|
36
|
-
key?: string;
|
|
37
|
-
mode?: Mode;
|
|
38
|
-
triggers?: unknown;
|
|
39
|
-
initialize?: Delegate<E>;
|
|
40
|
-
update?: Delegate<E>;
|
|
41
|
-
finalize?: Delegate<E>;
|
|
42
|
-
}
|
|
43
|
-
export interface RxNodeDriver<E = unknown> {
|
|
44
|
-
readonly name: string;
|
|
45
|
-
readonly isPartitionSeparator: boolean;
|
|
46
|
-
readonly predefine?: SimpleDelegate<E>;
|
|
47
|
-
allocate(node: RxNode<E>): E;
|
|
48
|
-
initialize(node: RxNode<E>): void;
|
|
49
|
-
mount(node: RxNode<E>): void;
|
|
50
|
-
update(node: RxNode<E>): void | Promise<void>;
|
|
51
|
-
finalize(node: RxNode<E>, isLeader: boolean): boolean;
|
|
52
|
-
}
|
|
53
|
-
export interface RxNodeContext<T extends Object = Object> {
|
|
54
|
-
value: T;
|
|
55
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export var Mode;
|
|
2
|
-
(function (Mode) {
|
|
3
|
-
Mode[Mode["Default"] = 0] = "Default";
|
|
4
|
-
Mode[Mode["IndependentUpdate"] = 1] = "IndependentUpdate";
|
|
5
|
-
Mode[Mode["ManualMount"] = 2] = "ManualMount";
|
|
6
|
-
})(Mode || (Mode = {}));
|
|
7
|
-
export var Priority;
|
|
8
|
-
(function (Priority) {
|
|
9
|
-
Priority[Priority["Realtime"] = 0] = "Realtime";
|
|
10
|
-
Priority[Priority["Normal"] = 1] = "Normal";
|
|
11
|
-
Priority[Priority["Background"] = 2] = "Background";
|
|
12
|
-
})(Priority || (Priority = {}));
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { LoggingOptions } from '../Logging.js';
|
|
2
|
-
import { Priority, RxNodeDecl, RxNodeDriver, SimpleDelegate, RxNode } from './RxNode.js';
|
|
3
|
-
export declare class RxTree {
|
|
4
|
-
static readonly shortFrameDuration = 16;
|
|
5
|
-
static readonly longFrameDuration = 300;
|
|
6
|
-
static currentUpdatePriority: Priority;
|
|
7
|
-
static frameDuration: number;
|
|
8
|
-
static declare<E = void>(driver: RxNodeDriver<E>, declaration?: RxNodeDecl<E>, preset?: RxNodeDecl<E>): RxNode<E>;
|
|
9
|
-
static get isFirstUpdate(): boolean;
|
|
10
|
-
static get nodeStamp(): number;
|
|
11
|
-
static triggerUpdate(node: RxNode<any>, triggers: unknown): void;
|
|
12
|
-
static updateNestedTreesThenDo(action: (error: unknown) => void): void;
|
|
13
|
-
static findMatchingHost<E = unknown, R = unknown>(node: RxNode<E>, match: SimpleDelegate<RxNode<E>, boolean>): RxNode<R> | undefined;
|
|
14
|
-
static findMatchingPrevSibling<E = unknown, R = unknown>(node: RxNode<E>, match: SimpleDelegate<RxNode<E>, boolean>): RxNode<R> | undefined;
|
|
15
|
-
static forEachChildRecursively<E = unknown>(node: RxNode<E>, action: SimpleDelegate<RxNode<E>>): void;
|
|
16
|
-
static getDefaultLoggingOptions(): LoggingOptions | undefined;
|
|
17
|
-
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
18
|
-
}
|
|
19
|
-
export declare abstract class BaseDriver<E = unknown> implements RxNodeDriver<E> {
|
|
20
|
-
readonly name: string;
|
|
21
|
-
readonly isPartitionSeparator: boolean;
|
|
22
|
-
readonly predefine?: SimpleDelegate<E> | undefined;
|
|
23
|
-
constructor(name: string, isPartitionSeparator: boolean, predefine?: SimpleDelegate<E> | undefined);
|
|
24
|
-
abstract allocate(node: RxNode<E>): E;
|
|
25
|
-
initialize(node: RxNode<E>): void;
|
|
26
|
-
mount(node: RxNode<E>): void;
|
|
27
|
-
update(node: RxNode<E>): void | Promise<void>;
|
|
28
|
-
finalize(node: RxNode<E>, isLeader: boolean): boolean;
|
|
29
|
-
}
|
|
30
|
-
export declare class RxNodeVariable<T extends Object = Object> {
|
|
31
|
-
readonly defaultValue: T | undefined;
|
|
32
|
-
constructor(defaultValue?: T);
|
|
33
|
-
set value(value: T);
|
|
34
|
-
get value(): T;
|
|
35
|
-
get valueOrUndefined(): T | undefined;
|
|
36
|
-
}
|
|
File without changes
|