reactronic 0.24.115 → 0.24.117
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/tree/RxTree.d.ts +56 -4
- package/build/dist/source/tree/RxTree.js +30 -20
- package/package.json +1 -1
- package/build/dist/source/tree/RxNode.d.ts +0 -55
- package/build/dist/source/tree/RxNode.js +0 -12
|
@@ -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 './tree/
|
|
21
|
-
export type { Delegate, SimpleDelegate,
|
|
22
|
-
export { RxTree, BaseDriver, RxNodeVariable } from './tree/RxTree.js';
|
|
20
|
+
export { RxNode, Mode, Priority, BaseDriver, RxNodeVariable } from './tree/RxTree.js';
|
|
21
|
+
export type { Delegate, SimpleDelegate, RxNodeDecl, RxNodeDriver, RxNodeContext } from './tree/RxTree.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 './tree/
|
|
17
|
-
export { RxTree, BaseDriver, RxNodeVariable } from './tree/RxTree.js';
|
|
16
|
+
export { RxNode, Mode, Priority, BaseDriver, RxNodeVariable } from './tree/RxTree.js';
|
|
18
17
|
export { Clock } from './Clock.js';
|
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import { LoggingOptions } from '../Logging.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
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;
|
|
4
34
|
static readonly shortFrameDuration = 16;
|
|
5
35
|
static readonly longFrameDuration = 300;
|
|
6
36
|
static currentUpdatePriority: Priority;
|
|
@@ -16,11 +46,33 @@ export declare class RxTree {
|
|
|
16
46
|
static getDefaultLoggingOptions(): LoggingOptions | undefined;
|
|
17
47
|
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
18
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
|
+
}
|
|
19
71
|
export declare abstract class BaseDriver<E = unknown> implements RxNodeDriver<E> {
|
|
20
72
|
readonly name: string;
|
|
21
73
|
readonly isPartitionSeparator: boolean;
|
|
22
|
-
readonly predefine?: SimpleDelegate<E> | undefined;
|
|
23
|
-
constructor(name: string, isPartitionSeparator: boolean, predefine?: SimpleDelegate<E> | undefined);
|
|
74
|
+
readonly predefine?: SimpleDelegate<E, void> | undefined;
|
|
75
|
+
constructor(name: string, isPartitionSeparator: boolean, predefine?: SimpleDelegate<E, void> | undefined);
|
|
24
76
|
abstract allocate(node: RxNode<E>): E;
|
|
25
77
|
initialize(node: RxNode<E>): void;
|
|
26
78
|
mount(node: RxNode<E>): void;
|
|
@@ -22,8 +22,19 @@ 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
|
-
|
|
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 {
|
|
27
38
|
static declare(driver, declaration, preset) {
|
|
28
39
|
var _a;
|
|
29
40
|
let result;
|
|
@@ -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
|
});
|
|
@@ -438,7 +449,6 @@ function mountOrRemountIfNecessary(node) {
|
|
|
438
449
|
}
|
|
439
450
|
function updateNow(seat) {
|
|
440
451
|
const node = seat.instance;
|
|
441
|
-
const el = node.element;
|
|
442
452
|
if (node.stamp >= 0) {
|
|
443
453
|
let result = undefined;
|
|
444
454
|
runInside(seat, () => {
|
|
@@ -449,7 +459,7 @@ function updateNow(seat) {
|
|
|
449
459
|
node.numerator = 0;
|
|
450
460
|
node.children.beginMerge();
|
|
451
461
|
const driver = node.driver;
|
|
452
|
-
result = driver.update(
|
|
462
|
+
result = driver.update(node);
|
|
453
463
|
if (result instanceof Promise)
|
|
454
464
|
result.then(v => { runUpdateNestedTreesThenDo(undefined, NOP); return v; }, e => { console.log(e); runUpdateNestedTreesThenDo(e !== null && e !== void 0 ? e : new Error('unknown error'), NOP); });
|
|
455
465
|
else
|
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 = {}));
|