reactronic 0.24.274 → 0.24.275
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.
|
@@ -19,5 +19,5 @@ export { Journal } from "./core/Journal.js";
|
|
|
19
19
|
export { RxSystem, raw, obs, transactional, reactive, cached, transaction, unobs, sensitive, options } from "./RxSystem.js";
|
|
20
20
|
export { Reaction } from "./Reaction.js";
|
|
21
21
|
export { RxNode, Mode, Priority, BaseDriver, RxNodeVariable } from "./core/RxNode.js";
|
|
22
|
-
export type {
|
|
22
|
+
export type { Script, ScriptAsync, Handler, RxNodeDecl, RxNodeDriver, RxNodeContext } from "./core/RxNode.js";
|
|
23
23
|
export { Clock } from "./Clock.js";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { LoggingOptions } from "../Logging.js";
|
|
2
2
|
import { MergeListReader, MergedItem } from "../util/MergeList.js";
|
|
3
3
|
import { MemberOptions } from "../Options.js";
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
4
|
+
export type Script<T> = (el: T, basis: () => void) => void;
|
|
5
|
+
export type ScriptAsync<T> = (el: T, basis: () => Promise<void>) => Promise<void>;
|
|
6
|
+
export type Handler<T = unknown, R = void> = (el: T) => R;
|
|
6
7
|
export declare enum Mode {
|
|
7
8
|
default = 0,
|
|
8
9
|
independentUpdate = 1,
|
|
@@ -35,7 +36,7 @@ export declare abstract class RxNode<E = unknown> {
|
|
|
35
36
|
static readonly longFrameDuration = 300;
|
|
36
37
|
static currentUpdatePriority: Priority;
|
|
37
38
|
static frameDuration: number;
|
|
38
|
-
static declare<E = void>(driver: RxNodeDriver<E>, declaration?: RxNodeDecl<E>,
|
|
39
|
+
static declare<E = void>(driver: RxNodeDriver<E>, declaration?: RxNodeDecl<E>, basis?: RxNodeDecl<E>): RxNode<E>;
|
|
39
40
|
static get isFirstUpdate(): boolean;
|
|
40
41
|
static get key(): string;
|
|
41
42
|
static get stamp(): number;
|
|
@@ -48,31 +49,32 @@ export declare abstract class RxNode<E = unknown> {
|
|
|
48
49
|
static triggerDeactivation(node: RxNode<any>): void;
|
|
49
50
|
static updateNestedNodesThenDo(action: (error: unknown) => void): void;
|
|
50
51
|
static markAsMounted(node: RxNode<any>, yes: boolean): void;
|
|
51
|
-
static findMatchingHost<E = unknown, R = unknown>(node: RxNode<E>, match:
|
|
52
|
-
static findMatchingPrevSibling<E = unknown, R = unknown>(node: RxNode<E>, match:
|
|
53
|
-
static forEachChildRecursively<E = unknown>(node: RxNode<E>, action:
|
|
52
|
+
static findMatchingHost<E = unknown, R = unknown>(node: RxNode<E>, match: Handler<RxNode<E>, boolean>): RxNode<R> | undefined;
|
|
53
|
+
static findMatchingPrevSibling<E = unknown, R = unknown>(node: RxNode<E>, match: Handler<RxNode<E>, boolean>): RxNode<R> | undefined;
|
|
54
|
+
static forEachChildRecursively<E = unknown>(node: RxNode<E>, action: Handler<RxNode<E>>): void;
|
|
54
55
|
static getDefaultLoggingOptions(): LoggingOptions | undefined;
|
|
55
56
|
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
56
57
|
}
|
|
57
58
|
export type RxNodeDecl<E = unknown> = {
|
|
58
|
-
script?:
|
|
59
|
+
script?: Script<E>;
|
|
60
|
+
scriptAsync?: ScriptAsync<E>;
|
|
59
61
|
key?: string;
|
|
60
62
|
mode?: Mode;
|
|
61
|
-
creation?:
|
|
62
|
-
destruction?:
|
|
63
|
+
creation?: Script<E>;
|
|
64
|
+
destruction?: Script<E>;
|
|
63
65
|
triggers?: unknown;
|
|
64
|
-
|
|
66
|
+
basis?: RxNodeDecl<E>;
|
|
65
67
|
};
|
|
66
68
|
export type RxNodeDriver<E = unknown> = {
|
|
67
69
|
readonly name: string;
|
|
68
70
|
readonly isPartition: boolean;
|
|
69
|
-
readonly
|
|
71
|
+
readonly initialize?: Handler<E>;
|
|
70
72
|
allocate(node: RxNode<E>): E;
|
|
71
73
|
create(node: RxNode<E>): void;
|
|
72
74
|
destroy(node: RxNode<E>, isLeader: boolean): boolean;
|
|
73
75
|
mount(node: RxNode<E>): void;
|
|
74
76
|
update(node: RxNode<E>): void | Promise<void>;
|
|
75
|
-
child(ownerNode: RxNode<E>, childDriver: RxNodeDriver<any>, childDeclaration?: RxNodeDecl<any>,
|
|
77
|
+
child(ownerNode: RxNode<E>, childDriver: RxNodeDriver<any>, childDeclaration?: RxNodeDecl<any>, childBasis?: RxNodeDecl<any>): MergedItem<RxNode> | undefined;
|
|
76
78
|
getHost(node: RxNode<E>): RxNode<E>;
|
|
77
79
|
};
|
|
78
80
|
export type RxNodeContext<T extends Object = Object> = {
|
|
@@ -81,14 +83,14 @@ export type RxNodeContext<T extends Object = Object> = {
|
|
|
81
83
|
export declare abstract class BaseDriver<E = unknown> implements RxNodeDriver<E> {
|
|
82
84
|
readonly name: string;
|
|
83
85
|
readonly isPartition: boolean;
|
|
84
|
-
readonly
|
|
85
|
-
constructor(name: string, isPartition: boolean,
|
|
86
|
+
readonly initialize?: Handler<E, void> | undefined;
|
|
87
|
+
constructor(name: string, isPartition: boolean, initialize?: Handler<E, void> | undefined);
|
|
86
88
|
abstract allocate(node: RxNode<E>): E;
|
|
87
89
|
create(node: RxNode<E>): void;
|
|
88
90
|
destroy(node: RxNode<E>, isLeader: boolean): boolean;
|
|
89
91
|
mount(node: RxNode<E>): void;
|
|
90
92
|
update(node: RxNode<E>): void | Promise<void>;
|
|
91
|
-
child(ownerNode: RxNode<E>, childDriver: RxNodeDriver<any>, childDeclaration?: RxNodeDecl<any>,
|
|
93
|
+
child(ownerNode: RxNode<E>, childDriver: RxNodeDriver<any>, childDeclaration?: RxNodeDecl<any>, childBasis?: RxNodeDecl<any>): MergedItem<RxNode> | undefined;
|
|
92
94
|
getHost(node: RxNode<E>): RxNode<E>;
|
|
93
95
|
}
|
|
94
96
|
export declare class RxNodeVariable<T extends Object = Object> {
|
|
@@ -35,16 +35,16 @@ export var Priority;
|
|
|
35
35
|
Priority[Priority["background"] = 2] = "background";
|
|
36
36
|
})(Priority || (Priority = {}));
|
|
37
37
|
export class RxNode {
|
|
38
|
-
static declare(driver, declaration,
|
|
38
|
+
static declare(driver, declaration, basis) {
|
|
39
39
|
let result;
|
|
40
40
|
if (declaration)
|
|
41
|
-
declaration.
|
|
41
|
+
declaration.basis = basis;
|
|
42
42
|
else
|
|
43
|
-
declaration =
|
|
43
|
+
declaration = basis !== null && basis !== void 0 ? basis : {};
|
|
44
44
|
let key = declaration.key;
|
|
45
45
|
const owner = gOwnSeat === null || gOwnSeat === void 0 ? void 0 : gOwnSeat.instance;
|
|
46
46
|
if (owner) {
|
|
47
|
-
let existing = owner.driver.child(owner, driver, declaration,
|
|
47
|
+
let existing = owner.driver.child(owner, driver, declaration, basis);
|
|
48
48
|
const children = owner.children;
|
|
49
49
|
existing !== null && existing !== void 0 ? existing : (existing = children.tryMergeAsExisting(key = key || generateKey(owner), undefined, "nested elements can be declared inside update function only"));
|
|
50
50
|
if (existing) {
|
|
@@ -144,26 +144,26 @@ RxNode.longFrameDuration = 300;
|
|
|
144
144
|
RxNode.currentUpdatePriority = Priority.realtime;
|
|
145
145
|
RxNode.frameDuration = RxNode.longFrameDuration;
|
|
146
146
|
export class BaseDriver {
|
|
147
|
-
constructor(name, isPartition,
|
|
147
|
+
constructor(name, isPartition, initialize) {
|
|
148
148
|
this.name = name;
|
|
149
149
|
this.isPartition = isPartition;
|
|
150
|
-
this.
|
|
150
|
+
this.initialize = initialize;
|
|
151
151
|
}
|
|
152
152
|
create(node) {
|
|
153
153
|
var _a;
|
|
154
|
-
(_a = this.
|
|
155
|
-
|
|
154
|
+
(_a = this.initialize) === null || _a === void 0 ? void 0 : _a.call(this, node.element);
|
|
155
|
+
invokeCreationUsingBasisChain(node.element, node.declaration);
|
|
156
156
|
}
|
|
157
157
|
destroy(node, isLeader) {
|
|
158
|
-
|
|
158
|
+
invokeDestructionUsingBasisChain(node.element, node.declaration);
|
|
159
159
|
return isLeader;
|
|
160
160
|
}
|
|
161
161
|
mount(node) {
|
|
162
162
|
}
|
|
163
163
|
update(node) {
|
|
164
|
-
|
|
164
|
+
invokeScriptUsingBasisChain(node.element, node.declaration);
|
|
165
165
|
}
|
|
166
|
-
child(ownerNode, childDriver, childDeclaration,
|
|
166
|
+
child(ownerNode, childDriver, childDeclaration, childBasis) {
|
|
167
167
|
return undefined;
|
|
168
168
|
}
|
|
169
169
|
getHost(node) {
|
|
@@ -194,33 +194,33 @@ function generateKey(owner) {
|
|
|
194
194
|
result = `·${lettered}`;
|
|
195
195
|
return result;
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function getModeUsingBasisChain(declaration) {
|
|
198
198
|
var _a;
|
|
199
|
-
return (_a = declaration === null || declaration === void 0 ? void 0 : declaration.mode) !== null && _a !== void 0 ? _a : ((declaration === null || declaration === void 0 ? void 0 : declaration.
|
|
199
|
+
return (_a = declaration === null || declaration === void 0 ? void 0 : declaration.mode) !== null && _a !== void 0 ? _a : ((declaration === null || declaration === void 0 ? void 0 : declaration.basis) ? getModeUsingBasisChain(declaration === null || declaration === void 0 ? void 0 : declaration.basis) : Mode.default);
|
|
200
200
|
}
|
|
201
|
-
function
|
|
202
|
-
const
|
|
203
|
-
const creation = declaration.creation;
|
|
204
|
-
if (creation)
|
|
205
|
-
creation(element, preset ? () => invokeOnCreateViaPresetChain(element, preset) : NOP);
|
|
206
|
-
else if (preset)
|
|
207
|
-
invokeOnCreateViaPresetChain(element, preset);
|
|
208
|
-
}
|
|
209
|
-
function invokeScriptViaPresetChain(element, declaration) {
|
|
210
|
-
const preset = declaration.preset;
|
|
201
|
+
function invokeScriptUsingBasisChain(element, declaration) {
|
|
202
|
+
const basis = declaration.basis;
|
|
211
203
|
const script = declaration.script;
|
|
212
204
|
if (script)
|
|
213
|
-
script(element,
|
|
214
|
-
else if (
|
|
215
|
-
|
|
205
|
+
script(element, basis ? () => invokeScriptUsingBasisChain(element, basis) : NOP);
|
|
206
|
+
else if (basis)
|
|
207
|
+
invokeScriptUsingBasisChain(element, basis);
|
|
208
|
+
}
|
|
209
|
+
function invokeCreationUsingBasisChain(element, declaration) {
|
|
210
|
+
const basis = declaration.basis;
|
|
211
|
+
const creation = declaration.creation;
|
|
212
|
+
if (creation)
|
|
213
|
+
creation(element, basis ? () => invokeCreationUsingBasisChain(element, basis) : NOP);
|
|
214
|
+
else if (basis)
|
|
215
|
+
invokeCreationUsingBasisChain(element, basis);
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
const
|
|
217
|
+
function invokeDestructionUsingBasisChain(element, declaration) {
|
|
218
|
+
const basis = declaration.basis;
|
|
219
219
|
const destruction = declaration.destruction;
|
|
220
220
|
if (destruction)
|
|
221
|
-
destruction(element,
|
|
222
|
-
else if (
|
|
223
|
-
|
|
221
|
+
destruction(element, basis ? () => invokeDestructionUsingBasisChain(element, basis) : NOP);
|
|
222
|
+
else if (basis)
|
|
223
|
+
invokeDestructionUsingBasisChain(element, basis);
|
|
224
224
|
}
|
|
225
225
|
class RxNodeContextImpl extends ObservableObject {
|
|
226
226
|
constructor(variable, value) {
|
|
@@ -273,7 +273,7 @@ class RxNodeImpl extends RxNode {
|
|
|
273
273
|
set strictOrder(value) { this.children.isStrict = value; }
|
|
274
274
|
get isMoved() { return this.owner.children.isMoved(this.seat); }
|
|
275
275
|
has(mode) {
|
|
276
|
-
return (
|
|
276
|
+
return (getModeUsingBasisChain(this.declaration) & mode) === mode;
|
|
277
277
|
}
|
|
278
278
|
update(_triggers) {
|
|
279
279
|
updateNow(this.seat);
|