reactronic 0.93.25026 → 0.94.25027
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/README.md +32 -32
- package/build/dist/source/Enums.d.ts +32 -0
- package/build/dist/source/Enums.js +37 -0
- package/build/dist/source/OperationEx.d.ts +7 -0
- package/build/dist/source/{ReactiveLoop.js → OperationEx.js} +8 -8
- package/build/dist/source/Options.d.ts +7 -27
- package/build/dist/source/Options.js +0 -24
- package/build/dist/source/Pipe.d.ts +2 -2
- package/build/dist/source/Pipe.js +2 -2
- package/build/dist/source/Ref.js +1 -1
- package/build/dist/source/{ReactiveSystem.d.ts → System.d.ts} +9 -10
- package/build/dist/source/{ReactiveSystem.js → System.js} +20 -15
- package/build/dist/source/api.d.ts +12 -10
- package/build/dist/source/api.js +10 -8
- package/build/dist/source/core/Changeset.d.ts +8 -7
- package/build/dist/source/core/Changeset.js +18 -18
- package/build/dist/source/core/Data.d.ts +6 -6
- package/build/dist/source/core/Data.js +2 -2
- package/build/dist/source/core/Indicator.d.ts +2 -2
- package/build/dist/source/core/Indicator.js +3 -3
- package/build/dist/source/core/Journal.d.ts +2 -2
- package/build/dist/source/core/Journal.js +7 -7
- package/build/dist/source/core/Meta.d.ts +1 -1
- package/build/dist/source/core/Meta.js +1 -1
- package/build/dist/source/core/Mvcc.d.ts +17 -16
- package/build/dist/source/core/Mvcc.js +30 -30
- package/build/dist/source/core/MvccArray.d.ts +3 -3
- package/build/dist/source/core/MvccArray.js +4 -4
- package/build/dist/source/core/MvccMap.d.ts +3 -3
- package/build/dist/source/core/MvccMap.js +4 -4
- package/build/dist/source/core/MvccMergeList.d.ts +2 -2
- package/build/dist/source/core/MvccMergeList.js +2 -2
- package/build/dist/source/core/Operation.d.ts +25 -25
- package/build/dist/source/core/Operation.js +205 -205
- package/build/dist/source/core/Transaction.d.ts +3 -3
- package/build/dist/source/core/Transaction.js +72 -72
- package/build/dist/source/core/Tree.d.ts +26 -0
- package/build/dist/source/core/Tree.js +120 -0
- package/build/dist/source/core/TreeNode.d.ts +117 -0
- package/build/dist/source/core/{ReactiveNode.js → TreeNode.js} +49 -177
- package/package.json +1 -1
- package/build/dist/source/ReactiveLoop.d.ts +0 -7
- package/build/dist/source/core/ReactiveNode.d.ts +0 -107
|
@@ -19,144 +19,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
import { misuse } from "../util/Dbg.js";
|
|
20
20
|
import { MergeList } from "../util/MergeList.js";
|
|
21
21
|
import { emitLetters, getCallerInfo, proceedSyncOrAsync } from "../util/Utils.js";
|
|
22
|
-
import { Isolation, Reentrance } from "../
|
|
23
|
-
import {
|
|
22
|
+
import { Priority, Mode, Isolation, Reentrance } from "../Enums.js";
|
|
23
|
+
import { ObservableObject } from "../core/Mvcc.js";
|
|
24
24
|
import { Transaction } from "../core/Transaction.js";
|
|
25
|
-
import { ReactiveSystem, options,
|
|
26
|
-
export
|
|
27
|
-
(function (Mode) {
|
|
28
|
-
Mode[Mode["default"] = 0] = "default";
|
|
29
|
-
Mode[Mode["autonomous"] = 1] = "autonomous";
|
|
30
|
-
Mode[Mode["manualMount"] = 2] = "manualMount";
|
|
31
|
-
Mode[Mode["rootNode"] = 4] = "rootNode";
|
|
32
|
-
})(Mode || (Mode = {}));
|
|
33
|
-
export var Priority;
|
|
34
|
-
(function (Priority) {
|
|
35
|
-
Priority[Priority["realtime"] = 0] = "realtime";
|
|
36
|
-
Priority[Priority["normal"] = 1] = "normal";
|
|
37
|
-
Priority[Priority["background"] = 2] = "background";
|
|
38
|
-
})(Priority || (Priority = {}));
|
|
39
|
-
export class ReactiveNode {
|
|
40
|
-
static declare(driver, scriptOrDeclaration, scriptAsync, key, mode, preparation, preparationAsync, finalization, triggers, basis) {
|
|
41
|
-
let result;
|
|
42
|
-
let declaration;
|
|
43
|
-
if (scriptOrDeclaration instanceof Function) {
|
|
44
|
-
declaration = {
|
|
45
|
-
script: scriptOrDeclaration, scriptAsync, key, mode,
|
|
46
|
-
preparation, preparationAsync, finalization, triggers, basis,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
else
|
|
50
|
-
declaration = scriptOrDeclaration !== null && scriptOrDeclaration !== void 0 ? scriptOrDeclaration : {};
|
|
51
|
-
let effectiveKey = declaration.key;
|
|
52
|
-
const owner = (getModeUsingBasisChain(declaration) & Mode.rootNode) !== Mode.rootNode ? gNodeSlot === null || gNodeSlot === void 0 ? void 0 : gNodeSlot.instance : undefined;
|
|
53
|
-
if (owner) {
|
|
54
|
-
let existing = owner.driver.declareChild(owner, driver, declaration, declaration.basis);
|
|
55
|
-
const children = owner.children;
|
|
56
|
-
existing !== null && existing !== void 0 ? existing : (existing = children.tryMergeAsExisting(effectiveKey = effectiveKey || generateKey(owner), undefined, "nested elements can be declared inside 'script' only"));
|
|
57
|
-
if (existing) {
|
|
58
|
-
result = existing.instance;
|
|
59
|
-
if (result.driver !== driver && driver !== undefined)
|
|
60
|
-
throw new Error(`changing element driver is not yet supported: "${result.driver.name}" -> "${driver === null || driver === void 0 ? void 0 : driver.name}"`);
|
|
61
|
-
const exTriggers = result.declaration.triggers;
|
|
62
|
-
if (triggersAreEqual(declaration.triggers, exTriggers))
|
|
63
|
-
declaration.triggers = exTriggers;
|
|
64
|
-
result.declaration = declaration;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
result = new ReactiveNodeImpl(effectiveKey || generateKey(owner), driver, declaration, owner);
|
|
68
|
-
result.slot = children.mergeAsAdded(result);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
result = new ReactiveNodeImpl(effectiveKey || "", driver, declaration, owner);
|
|
73
|
-
result.slot = MergeList.createItem(result);
|
|
74
|
-
triggerScriptRunViaSlot(result.slot);
|
|
75
|
-
}
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
static withBasis(declaration, basis) {
|
|
79
|
-
if (declaration)
|
|
80
|
-
declaration.basis = basis;
|
|
81
|
-
else
|
|
82
|
-
declaration = basis !== null && basis !== void 0 ? basis : {};
|
|
83
|
-
return declaration;
|
|
84
|
-
}
|
|
85
|
-
static get isFirstScriptRun() {
|
|
86
|
-
return ReactiveNodeImpl.nodeSlot.instance.stamp === 1;
|
|
87
|
-
}
|
|
88
|
-
static get key() {
|
|
89
|
-
return ReactiveNodeImpl.nodeSlot.instance.key;
|
|
90
|
-
}
|
|
91
|
-
static get stamp() {
|
|
92
|
-
return ReactiveNodeImpl.nodeSlot.instance.stamp;
|
|
93
|
-
}
|
|
94
|
-
static get triggers() {
|
|
95
|
-
return ReactiveNodeImpl.nodeSlot.instance.declaration.triggers;
|
|
96
|
-
}
|
|
97
|
-
static get priority() {
|
|
98
|
-
return ReactiveNodeImpl.nodeSlot.instance.priority;
|
|
99
|
-
}
|
|
100
|
-
static set priority(value) {
|
|
101
|
-
ReactiveNodeImpl.nodeSlot.instance.priority = value;
|
|
102
|
-
}
|
|
103
|
-
static get childrenShuffling() {
|
|
104
|
-
return ReactiveNodeImpl.nodeSlot.instance.childrenShuffling;
|
|
105
|
-
}
|
|
106
|
-
static set childrenShuffling(value) {
|
|
107
|
-
ReactiveNodeImpl.nodeSlot.instance.childrenShuffling = value;
|
|
108
|
-
}
|
|
109
|
-
static triggerScriptRun(node, triggers) {
|
|
110
|
-
const impl = node;
|
|
111
|
-
const declaration = impl.declaration;
|
|
112
|
-
if (!triggersAreEqual(triggers, declaration.triggers)) {
|
|
113
|
-
declaration.triggers = triggers;
|
|
114
|
-
triggerScriptRunViaSlot(impl.slot);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
static triggerFinalization(node) {
|
|
118
|
-
const impl = node;
|
|
119
|
-
triggerFinalization(impl.slot, true, true);
|
|
120
|
-
}
|
|
121
|
-
static runNestedNodeScriptsThenDo(action) {
|
|
122
|
-
runNestedNodeScriptsThenDoImpl(ReactiveNodeImpl.nodeSlot, undefined, action);
|
|
123
|
-
}
|
|
124
|
-
static markAsMounted(node, yes) {
|
|
125
|
-
const n = node;
|
|
126
|
-
if (n.stamp < 0)
|
|
127
|
-
throw new Error("deactivated node cannot be mounted or unmounted");
|
|
128
|
-
if (n.stamp >= Number.MAX_SAFE_INTEGER)
|
|
129
|
-
throw new Error("node must be activated before mounting");
|
|
130
|
-
n.stamp = yes ? 0 : Number.MAX_SAFE_INTEGER - 1;
|
|
131
|
-
}
|
|
132
|
-
static findMatchingHost(node, match) {
|
|
133
|
-
let p = node.host;
|
|
134
|
-
while (p !== p.host && !match(p))
|
|
135
|
-
p = p.host;
|
|
136
|
-
return p;
|
|
137
|
-
}
|
|
138
|
-
static findMatchingPrevSibling(node, match) {
|
|
139
|
-
let p = node.slot.prev;
|
|
140
|
-
while (p && !match(p.instance))
|
|
141
|
-
p = p.prev;
|
|
142
|
-
return p === null || p === void 0 ? void 0 : p.instance;
|
|
143
|
-
}
|
|
144
|
-
static forEachChildRecursively(node, action) {
|
|
145
|
-
action(node);
|
|
146
|
-
for (const child of node.children.items())
|
|
147
|
-
ReactiveNode.forEachChildRecursively(child.instance, action);
|
|
148
|
-
}
|
|
149
|
-
static getDefaultLoggingOptions() {
|
|
150
|
-
return ReactiveNodeImpl.logging;
|
|
151
|
-
}
|
|
152
|
-
static setDefaultLoggingOptions(logging) {
|
|
153
|
-
ReactiveNodeImpl.logging = logging;
|
|
154
|
-
}
|
|
25
|
+
import { ReactiveSystem, options, observable, reactive, runAtomically, runNonReactively, manageReactiveOperation, disposeObservableObject } from "../System.js";
|
|
26
|
+
export class ReactiveTreeNode {
|
|
155
27
|
}
|
|
156
|
-
ReactiveNode.shortFrameDuration = 16;
|
|
157
|
-
ReactiveNode.longFrameDuration = 300;
|
|
158
|
-
ReactiveNode.currentScriptPriority = Priority.realtime;
|
|
159
|
-
ReactiveNode.frameDuration = ReactiveNode.longFrameDuration;
|
|
160
28
|
export class BaseDriver {
|
|
161
29
|
constructor(name, isPartition, initialize) {
|
|
162
30
|
this.name = name;
|
|
@@ -184,21 +52,21 @@ export class BaseDriver {
|
|
|
184
52
|
return node;
|
|
185
53
|
}
|
|
186
54
|
}
|
|
187
|
-
export class
|
|
55
|
+
export class ReactiveTreeVariable {
|
|
188
56
|
constructor(defaultValue) {
|
|
189
57
|
this.defaultValue = defaultValue;
|
|
190
58
|
}
|
|
191
59
|
set value(value) {
|
|
192
|
-
|
|
60
|
+
ReactiveTreeNodeImpl.setNodeVariableValue(this, value);
|
|
193
61
|
}
|
|
194
62
|
get value() {
|
|
195
|
-
return
|
|
63
|
+
return ReactiveTreeNodeImpl.useNodeVariableValue(this);
|
|
196
64
|
}
|
|
197
65
|
get valueOrUndefined() {
|
|
198
|
-
return
|
|
66
|
+
return ReactiveTreeNodeImpl.tryUseNodeVariableValue(this);
|
|
199
67
|
}
|
|
200
68
|
}
|
|
201
|
-
function generateKey(owner) {
|
|
69
|
+
export function generateKey(owner) {
|
|
202
70
|
const n = owner.numerator++;
|
|
203
71
|
const lettered = emitLetters(n);
|
|
204
72
|
let result;
|
|
@@ -250,7 +118,7 @@ function invokeFinalizationUsingBasisChain(element, declaration) {
|
|
|
250
118
|
else if (basis)
|
|
251
119
|
invokeFinalizationUsingBasisChain(element, basis);
|
|
252
120
|
}
|
|
253
|
-
class
|
|
121
|
+
class ReactiveTreeNodeContextImpl extends ObservableObject {
|
|
254
122
|
constructor(variable, value) {
|
|
255
123
|
super();
|
|
256
124
|
this.next = undefined;
|
|
@@ -259,14 +127,14 @@ class ReactiveNodeContextImpl extends TriggeringObject {
|
|
|
259
127
|
}
|
|
260
128
|
}
|
|
261
129
|
__decorate([
|
|
262
|
-
|
|
130
|
+
observable(false),
|
|
263
131
|
__metadata("design:type", Object)
|
|
264
|
-
],
|
|
132
|
+
], ReactiveTreeNodeContextImpl.prototype, "next", void 0);
|
|
265
133
|
__decorate([
|
|
266
|
-
|
|
267
|
-
__metadata("design:type",
|
|
268
|
-
],
|
|
269
|
-
class
|
|
134
|
+
observable(false),
|
|
135
|
+
__metadata("design:type", ReactiveTreeVariable)
|
|
136
|
+
], ReactiveTreeNodeContextImpl.prototype, "variable", void 0);
|
|
137
|
+
class ReactiveTreeNodeImpl extends ReactiveTreeNode {
|
|
270
138
|
constructor(key, driver, declaration, owner) {
|
|
271
139
|
super();
|
|
272
140
|
const thisAsUnknown = this;
|
|
@@ -293,9 +161,9 @@ class ReactiveNodeImpl extends ReactiveNode {
|
|
|
293
161
|
this.numerator = 0;
|
|
294
162
|
this.priority = Priority.realtime;
|
|
295
163
|
this.childrenShuffling = false;
|
|
296
|
-
|
|
164
|
+
ReactiveTreeNodeImpl.grandNodeCount++;
|
|
297
165
|
if (this.has(Mode.autonomous))
|
|
298
|
-
|
|
166
|
+
ReactiveTreeNodeImpl.disposableNodeCount++;
|
|
299
167
|
}
|
|
300
168
|
get strictOrder() { return this.children.isStrict; }
|
|
301
169
|
set strictOrder(value) { this.children.isStrict = value; }
|
|
@@ -309,7 +177,7 @@ class ReactiveNodeImpl extends ReactiveNode {
|
|
|
309
177
|
configureReactronic(options) {
|
|
310
178
|
if (this.stamp < Number.MAX_SAFE_INTEGER - 1 || !this.has(Mode.autonomous))
|
|
311
179
|
throw new Error("reactronic can be configured only for elements with autonomous mode and only during activation");
|
|
312
|
-
return
|
|
180
|
+
return manageReactiveOperation(this.script).configure(options);
|
|
313
181
|
}
|
|
314
182
|
static get nodeSlot() {
|
|
315
183
|
if (!gNodeSlot)
|
|
@@ -318,20 +186,20 @@ class ReactiveNodeImpl extends ReactiveNode {
|
|
|
318
186
|
}
|
|
319
187
|
static tryUseNodeVariableValue(variable) {
|
|
320
188
|
var _a, _b;
|
|
321
|
-
let node =
|
|
189
|
+
let node = ReactiveTreeNodeImpl.nodeSlot.instance;
|
|
322
190
|
while (((_a = node.context) === null || _a === void 0 ? void 0 : _a.variable) !== variable && node.owner !== node)
|
|
323
191
|
node = node.outer.slot.instance;
|
|
324
192
|
return (_b = node.context) === null || _b === void 0 ? void 0 : _b.value;
|
|
325
193
|
}
|
|
326
194
|
static useNodeVariableValue(variable) {
|
|
327
195
|
var _a;
|
|
328
|
-
const result = (_a =
|
|
196
|
+
const result = (_a = ReactiveTreeNodeImpl.tryUseNodeVariableValue(variable)) !== null && _a !== void 0 ? _a : variable.defaultValue;
|
|
329
197
|
if (!result)
|
|
330
198
|
throw new Error("unknown node variable");
|
|
331
199
|
return result;
|
|
332
200
|
}
|
|
333
201
|
static setNodeVariableValue(variable, value) {
|
|
334
|
-
const node =
|
|
202
|
+
const node = ReactiveTreeNodeImpl.nodeSlot.instance;
|
|
335
203
|
const owner = node.owner;
|
|
336
204
|
const hostCtx = runNonReactively(() => { var _a; return (_a = owner.context) === null || _a === void 0 ? void 0 : _a.value; });
|
|
337
205
|
if (value && value !== hostCtx) {
|
|
@@ -346,7 +214,7 @@ class ReactiveNodeImpl extends ReactiveNode {
|
|
|
346
214
|
ctx.value = value;
|
|
347
215
|
}
|
|
348
216
|
else
|
|
349
|
-
node.context = new
|
|
217
|
+
node.context = new ReactiveTreeNodeContextImpl(variable, value);
|
|
350
218
|
});
|
|
351
219
|
}
|
|
352
220
|
else if (hostCtx)
|
|
@@ -355,21 +223,25 @@ class ReactiveNodeImpl extends ReactiveNode {
|
|
|
355
223
|
node.outer = owner.outer;
|
|
356
224
|
}
|
|
357
225
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
226
|
+
ReactiveTreeNodeImpl.logging = undefined;
|
|
227
|
+
ReactiveTreeNodeImpl.grandNodeCount = 0;
|
|
228
|
+
ReactiveTreeNodeImpl.disposableNodeCount = 0;
|
|
229
|
+
ReactiveTreeNodeImpl.shortFrameDuration = 16;
|
|
230
|
+
ReactiveTreeNodeImpl.longFrameDuration = 300;
|
|
231
|
+
ReactiveTreeNodeImpl.currentScriptPriority = Priority.realtime;
|
|
232
|
+
ReactiveTreeNodeImpl.frameDuration = ReactiveTreeNodeImpl.longFrameDuration;
|
|
361
233
|
__decorate([
|
|
362
|
-
|
|
234
|
+
reactive,
|
|
363
235
|
options({
|
|
364
236
|
reentrance: Reentrance.cancelAndWaitPrevious,
|
|
365
237
|
allowObsoleteToFinish: true,
|
|
366
|
-
|
|
238
|
+
observableArgs: true,
|
|
367
239
|
noSideEffects: false,
|
|
368
240
|
}),
|
|
369
241
|
__metadata("design:type", Function),
|
|
370
242
|
__metadata("design:paramtypes", [Object]),
|
|
371
243
|
__metadata("design:returntype", void 0)
|
|
372
|
-
],
|
|
244
|
+
], ReactiveTreeNodeImpl.prototype, "script", null);
|
|
373
245
|
function getNodeKey(node) {
|
|
374
246
|
return node.stamp >= 0 ? node.key : undefined;
|
|
375
247
|
}
|
|
@@ -444,29 +316,29 @@ function runNestedScriptsIncrementally(owner, stamp, allChildren, items, priorit
|
|
|
444
316
|
return __awaiter(this, void 0, void 0, function* () {
|
|
445
317
|
yield Transaction.requestNextFrame();
|
|
446
318
|
const node = owner.instance;
|
|
447
|
-
if (!Transaction.isCanceled || !Transaction.isFrameOver(1,
|
|
448
|
-
let outerPriority =
|
|
449
|
-
|
|
319
|
+
if (!Transaction.isCanceled || !Transaction.isFrameOver(1, ReactiveTreeNodeImpl.shortFrameDuration / 3)) {
|
|
320
|
+
let outerPriority = ReactiveTreeNodeImpl.currentScriptPriority;
|
|
321
|
+
ReactiveTreeNodeImpl.currentScriptPriority = priority;
|
|
450
322
|
try {
|
|
451
323
|
if (node.childrenShuffling)
|
|
452
324
|
shuffle(items);
|
|
453
|
-
const frameDurationLimit = priority === Priority.background ?
|
|
454
|
-
let frameDuration = Math.min(frameDurationLimit, Math.max(
|
|
325
|
+
const frameDurationLimit = priority === Priority.background ? ReactiveTreeNodeImpl.shortFrameDuration : Infinity;
|
|
326
|
+
let frameDuration = Math.min(frameDurationLimit, Math.max(ReactiveTreeNodeImpl.frameDuration / 4, ReactiveTreeNodeImpl.shortFrameDuration));
|
|
455
327
|
for (const child of items) {
|
|
456
328
|
triggerScriptRunViaSlot(child);
|
|
457
329
|
if (Transaction.isFrameOver(1, frameDuration)) {
|
|
458
|
-
|
|
330
|
+
ReactiveTreeNodeImpl.currentScriptPriority = outerPriority;
|
|
459
331
|
yield Transaction.requestNextFrame(0);
|
|
460
|
-
outerPriority =
|
|
461
|
-
|
|
462
|
-
frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit,
|
|
332
|
+
outerPriority = ReactiveTreeNodeImpl.currentScriptPriority;
|
|
333
|
+
ReactiveTreeNodeImpl.currentScriptPriority = priority;
|
|
334
|
+
frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit, ReactiveTreeNodeImpl.frameDuration));
|
|
463
335
|
}
|
|
464
|
-
if (Transaction.isCanceled && Transaction.isFrameOver(1,
|
|
336
|
+
if (Transaction.isCanceled && Transaction.isFrameOver(1, ReactiveTreeNodeImpl.shortFrameDuration / 3))
|
|
465
337
|
break;
|
|
466
338
|
}
|
|
467
339
|
}
|
|
468
340
|
finally {
|
|
469
|
-
|
|
341
|
+
ReactiveTreeNodeImpl.currentScriptPriority = outerPriority;
|
|
470
342
|
}
|
|
471
343
|
}
|
|
472
344
|
});
|
|
@@ -479,7 +351,7 @@ function triggerScriptRunViaSlot(nodeSlot) {
|
|
|
479
351
|
Transaction.outside(() => {
|
|
480
352
|
if (ReactiveSystem.isLogging)
|
|
481
353
|
ReactiveSystem.setLoggingHint(node.element, node.key);
|
|
482
|
-
|
|
354
|
+
manageReactiveOperation(node.script).configure({
|
|
483
355
|
order: node.level,
|
|
484
356
|
});
|
|
485
357
|
});
|
|
@@ -554,7 +426,7 @@ function triggerFinalization(nodeSlot, isLeader, individual) {
|
|
|
554
426
|
}
|
|
555
427
|
for (const child of node.children.items())
|
|
556
428
|
triggerFinalization(child, childrenAreLeaders, false);
|
|
557
|
-
|
|
429
|
+
ReactiveTreeNodeImpl.grandNodeCount--;
|
|
558
430
|
}
|
|
559
431
|
}
|
|
560
432
|
function runDisposalLoop() {
|
|
@@ -564,9 +436,9 @@ function runDisposalLoop() {
|
|
|
564
436
|
while (slot !== undefined) {
|
|
565
437
|
if (Transaction.isFrameOver(500, 5))
|
|
566
438
|
yield Transaction.requestNextFrame();
|
|
567
|
-
|
|
439
|
+
disposeObservableObject(slot.instance);
|
|
568
440
|
slot = slot.aux;
|
|
569
|
-
|
|
441
|
+
ReactiveTreeNodeImpl.disposableNodeCount--;
|
|
570
442
|
}
|
|
571
443
|
gFirstToDispose = gLastToDispose = undefined;
|
|
572
444
|
});
|
|
@@ -592,7 +464,7 @@ function runInsideContextOfNode(nodeSlot, func, ...args) {
|
|
|
592
464
|
gNodeSlot = outer;
|
|
593
465
|
}
|
|
594
466
|
}
|
|
595
|
-
function
|
|
467
|
+
export function observablesAreEqual(a1, a2) {
|
|
596
468
|
let result = a1 === a2;
|
|
597
469
|
if (!result) {
|
|
598
470
|
if (Array.isArray(a1)) {
|
package/package.json
CHANGED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { LoggingOptions } from "../Logging.js";
|
|
2
|
-
import { MergeListReader, MergedItem } from "../util/MergeList.js";
|
|
3
|
-
import { MemberOptions } from "../Options.js";
|
|
4
|
-
export type Script<E> = (el: E, basis: () => void) => void;
|
|
5
|
-
export type ScriptAsync<E> = (el: E, basis: () => Promise<void>) => Promise<void>;
|
|
6
|
-
export type Handler<E = unknown, R = void> = (el: E) => R;
|
|
7
|
-
export declare enum Mode {
|
|
8
|
-
default = 0,
|
|
9
|
-
autonomous = 1,
|
|
10
|
-
manualMount = 2,
|
|
11
|
-
rootNode = 4
|
|
12
|
-
}
|
|
13
|
-
export declare enum Priority {
|
|
14
|
-
realtime = 0,
|
|
15
|
-
normal = 1,
|
|
16
|
-
background = 2
|
|
17
|
-
}
|
|
18
|
-
export declare abstract class ReactiveNode<E = unknown> {
|
|
19
|
-
abstract readonly key: string;
|
|
20
|
-
abstract readonly driver: ReactiveNodeDriver<E>;
|
|
21
|
-
abstract readonly declaration: Readonly<ReactiveNodeDecl<E>>;
|
|
22
|
-
abstract readonly level: number;
|
|
23
|
-
abstract readonly owner: ReactiveNode;
|
|
24
|
-
abstract element: E;
|
|
25
|
-
abstract readonly host: ReactiveNode;
|
|
26
|
-
abstract readonly children: MergeListReader<ReactiveNode>;
|
|
27
|
-
abstract readonly slot: MergedItem<ReactiveNode<E>> | undefined;
|
|
28
|
-
abstract readonly stamp: number;
|
|
29
|
-
abstract readonly outer: ReactiveNode;
|
|
30
|
-
abstract readonly context: ReactiveNodeContext | undefined;
|
|
31
|
-
abstract priority?: Priority;
|
|
32
|
-
abstract childrenShuffling: boolean;
|
|
33
|
-
abstract strictOrder: boolean;
|
|
34
|
-
abstract has(mode: Mode): boolean;
|
|
35
|
-
abstract configureReactronic(options: Partial<MemberOptions>): MemberOptions;
|
|
36
|
-
static readonly shortFrameDuration = 16;
|
|
37
|
-
static readonly longFrameDuration = 300;
|
|
38
|
-
static currentScriptPriority: Priority;
|
|
39
|
-
static frameDuration: number;
|
|
40
|
-
static declare<E = void>(driver: ReactiveNodeDriver<E>, script?: Script<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>, triggers?: unknown, basis?: ReactiveNodeDecl<E>): ReactiveNode<E>;
|
|
41
|
-
static declare<E = void>(driver: ReactiveNodeDriver<E>, declaration?: ReactiveNodeDecl<E>): ReactiveNode<E>;
|
|
42
|
-
static declare<E = void>(driver: ReactiveNodeDriver<E>, scriptOrDeclaration?: Script<E> | ReactiveNodeDecl<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>, triggers?: unknown, basis?: ReactiveNodeDecl<E>): ReactiveNode<E>;
|
|
43
|
-
static withBasis<E = void>(declaration?: ReactiveNodeDecl<E>, basis?: ReactiveNodeDecl<E>): ReactiveNodeDecl<E>;
|
|
44
|
-
static get isFirstScriptRun(): boolean;
|
|
45
|
-
static get key(): string;
|
|
46
|
-
static get stamp(): number;
|
|
47
|
-
static get triggers(): unknown;
|
|
48
|
-
static get priority(): Priority;
|
|
49
|
-
static set priority(value: Priority);
|
|
50
|
-
static get childrenShuffling(): boolean;
|
|
51
|
-
static set childrenShuffling(value: boolean);
|
|
52
|
-
static triggerScriptRun(node: ReactiveNode<any>, triggers: unknown): void;
|
|
53
|
-
static triggerFinalization(node: ReactiveNode<any>): void;
|
|
54
|
-
static runNestedNodeScriptsThenDo(action: (error: unknown) => void): void;
|
|
55
|
-
static markAsMounted(node: ReactiveNode<any>, yes: boolean): void;
|
|
56
|
-
static findMatchingHost<E = unknown, R = unknown>(node: ReactiveNode<E>, match: Handler<ReactiveNode<E>, boolean>): ReactiveNode<R> | undefined;
|
|
57
|
-
static findMatchingPrevSibling<E = unknown, R = unknown>(node: ReactiveNode<E>, match: Handler<ReactiveNode<E>, boolean>): ReactiveNode<R> | undefined;
|
|
58
|
-
static forEachChildRecursively<E = unknown>(node: ReactiveNode<E>, action: Handler<ReactiveNode<E>>): void;
|
|
59
|
-
static getDefaultLoggingOptions(): LoggingOptions | undefined;
|
|
60
|
-
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
61
|
-
}
|
|
62
|
-
export type ReactiveNodeDecl<E = unknown> = {
|
|
63
|
-
script?: Script<E>;
|
|
64
|
-
scriptAsync?: ScriptAsync<E>;
|
|
65
|
-
key?: string;
|
|
66
|
-
mode?: Mode;
|
|
67
|
-
preparation?: Script<E>;
|
|
68
|
-
preparationAsync?: ScriptAsync<E>;
|
|
69
|
-
finalization?: Script<E>;
|
|
70
|
-
triggers?: unknown;
|
|
71
|
-
basis?: ReactiveNodeDecl<E>;
|
|
72
|
-
};
|
|
73
|
-
export type ReactiveNodeDriver<E = unknown> = {
|
|
74
|
-
readonly name: string;
|
|
75
|
-
readonly isPartition: boolean;
|
|
76
|
-
readonly initialize?: Handler<E>;
|
|
77
|
-
create(node: ReactiveNode<E>): E;
|
|
78
|
-
runPreparation(node: ReactiveNode<E>): void;
|
|
79
|
-
runFinalization(node: ReactiveNode<E>, isLeader: boolean): boolean;
|
|
80
|
-
runMount(node: ReactiveNode<E>): void;
|
|
81
|
-
runScript(node: ReactiveNode<E>): void | Promise<void>;
|
|
82
|
-
declareChild(ownerNode: ReactiveNode<E>, childDriver: ReactiveNodeDriver<any>, childDeclaration?: ReactiveNodeDecl<any>, childBasis?: ReactiveNodeDecl<any>): MergedItem<ReactiveNode> | undefined;
|
|
83
|
-
provideHost(node: ReactiveNode<E>): ReactiveNode<E>;
|
|
84
|
-
};
|
|
85
|
-
export type ReactiveNodeContext<T extends Object = Object> = {
|
|
86
|
-
value: T;
|
|
87
|
-
};
|
|
88
|
-
export declare abstract class BaseDriver<E = unknown> implements ReactiveNodeDriver<E> {
|
|
89
|
-
readonly name: string;
|
|
90
|
-
readonly isPartition: boolean;
|
|
91
|
-
readonly initialize?: Handler<E> | undefined;
|
|
92
|
-
constructor(name: string, isPartition: boolean, initialize?: Handler<E> | undefined);
|
|
93
|
-
abstract create(node: ReactiveNode<E>): E;
|
|
94
|
-
runPreparation(node: ReactiveNode<E>): void | Promise<void>;
|
|
95
|
-
runFinalization(node: ReactiveNode<E>, isLeader: boolean): boolean;
|
|
96
|
-
runMount(node: ReactiveNode<E>): void;
|
|
97
|
-
runScript(node: ReactiveNode<E>): void | Promise<void>;
|
|
98
|
-
declareChild(ownerNode: ReactiveNode<E>, childDriver: ReactiveNodeDriver<any>, childDeclaration?: ReactiveNodeDecl<any>, childBasis?: ReactiveNodeDecl<any>): MergedItem<ReactiveNode> | undefined;
|
|
99
|
-
provideHost(node: ReactiveNode<E>): ReactiveNode<E>;
|
|
100
|
-
}
|
|
101
|
-
export declare class ReactiveNodeVariable<T extends Object = Object> {
|
|
102
|
-
readonly defaultValue: T | undefined;
|
|
103
|
-
constructor(defaultValue?: T);
|
|
104
|
-
set value(value: T);
|
|
105
|
-
get value(): T;
|
|
106
|
-
get valueOrUndefined(): T | undefined;
|
|
107
|
-
}
|