reactronic 0.93.25026 → 0.94.25028

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.
Files changed (43) hide show
  1. package/README.md +32 -32
  2. package/build/dist/source/Enums.d.ts +32 -0
  3. package/build/dist/source/Enums.js +37 -0
  4. package/build/dist/source/OperationEx.d.ts +7 -0
  5. package/build/dist/source/{ReactiveLoop.js → OperationEx.js} +8 -8
  6. package/build/dist/source/Options.d.ts +7 -27
  7. package/build/dist/source/Options.js +0 -24
  8. package/build/dist/source/Pipe.d.ts +2 -2
  9. package/build/dist/source/Pipe.js +2 -2
  10. package/build/dist/source/Ref.js +1 -1
  11. package/build/dist/source/{ReactiveSystem.d.ts → System.d.ts} +9 -10
  12. package/build/dist/source/{ReactiveSystem.js → System.js} +20 -15
  13. package/build/dist/source/api.d.ts +12 -10
  14. package/build/dist/source/api.js +10 -8
  15. package/build/dist/source/core/Changeset.d.ts +8 -7
  16. package/build/dist/source/core/Changeset.js +18 -18
  17. package/build/dist/source/core/Data.d.ts +6 -6
  18. package/build/dist/source/core/Data.js +2 -2
  19. package/build/dist/source/core/Indicator.d.ts +2 -2
  20. package/build/dist/source/core/Indicator.js +3 -3
  21. package/build/dist/source/core/Journal.d.ts +2 -2
  22. package/build/dist/source/core/Journal.js +7 -7
  23. package/build/dist/source/core/Meta.d.ts +1 -1
  24. package/build/dist/source/core/Meta.js +1 -1
  25. package/build/dist/source/core/Mvcc.d.ts +17 -16
  26. package/build/dist/source/core/Mvcc.js +30 -30
  27. package/build/dist/source/core/MvccArray.d.ts +3 -3
  28. package/build/dist/source/core/MvccArray.js +4 -4
  29. package/build/dist/source/core/MvccMap.d.ts +3 -3
  30. package/build/dist/source/core/MvccMap.js +4 -4
  31. package/build/dist/source/core/MvccMergeList.d.ts +2 -2
  32. package/build/dist/source/core/MvccMergeList.js +2 -2
  33. package/build/dist/source/core/Operation.d.ts +25 -25
  34. package/build/dist/source/core/Operation.js +205 -205
  35. package/build/dist/source/core/Transaction.d.ts +3 -3
  36. package/build/dist/source/core/Transaction.js +72 -72
  37. package/build/dist/source/core/Tree.d.ts +19 -0
  38. package/build/dist/source/core/Tree.js +99 -0
  39. package/build/dist/source/core/TreeNode.d.ts +124 -0
  40. package/build/dist/source/core/{ReactiveNode.js → TreeNode.js} +56 -163
  41. package/package.json +1 -1
  42. package/build/dist/source/ReactiveLoop.d.ts +0 -7
  43. package/build/dist/source/core/ReactiveNode.d.ts +0 -107
@@ -19,144 +19,33 @@ 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 "../Options.js";
23
- import { TriggeringObject } from "../core/Mvcc.js";
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, trigger, reaction, runAtomically, runNonReactively } from "../ReactiveSystem.js";
26
- export var Mode;
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
- }
25
+ import { ReactiveSystem, options, observable, reactive, runAtomically, runNonReactively, manageReactiveOperation, disposeObservableObject } from "../System.js";
26
+ export class ReactiveTreeNode {
88
27
  static get key() {
89
- return ReactiveNodeImpl.nodeSlot.instance.key;
28
+ return ReactiveTreeNodeImpl.nodeSlot.instance.key;
90
29
  }
91
30
  static get stamp() {
92
- return ReactiveNodeImpl.nodeSlot.instance.stamp;
31
+ return ReactiveTreeNodeImpl.nodeSlot.instance.stamp;
93
32
  }
94
33
  static get triggers() {
95
- return ReactiveNodeImpl.nodeSlot.instance.declaration.triggers;
34
+ return ReactiveTreeNodeImpl.nodeSlot.instance.declaration.triggers;
96
35
  }
97
36
  static get priority() {
98
- return ReactiveNodeImpl.nodeSlot.instance.priority;
37
+ return ReactiveTreeNodeImpl.nodeSlot.instance.priority;
99
38
  }
100
39
  static set priority(value) {
101
- ReactiveNodeImpl.nodeSlot.instance.priority = value;
40
+ ReactiveTreeNodeImpl.nodeSlot.instance.priority = value;
102
41
  }
103
42
  static get childrenShuffling() {
104
- return ReactiveNodeImpl.nodeSlot.instance.childrenShuffling;
43
+ return ReactiveTreeNodeImpl.nodeSlot.instance.childrenShuffling;
105
44
  }
106
45
  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;
46
+ ReactiveTreeNodeImpl.nodeSlot.instance.childrenShuffling = value;
154
47
  }
155
48
  }
156
- ReactiveNode.shortFrameDuration = 16;
157
- ReactiveNode.longFrameDuration = 300;
158
- ReactiveNode.currentScriptPriority = Priority.realtime;
159
- ReactiveNode.frameDuration = ReactiveNode.longFrameDuration;
160
49
  export class BaseDriver {
161
50
  constructor(name, isPartition, initialize) {
162
51
  this.name = name;
@@ -184,21 +73,21 @@ export class BaseDriver {
184
73
  return node;
185
74
  }
186
75
  }
187
- export class ReactiveNodeVariable {
76
+ export class ReactiveTreeVariable {
188
77
  constructor(defaultValue) {
189
78
  this.defaultValue = defaultValue;
190
79
  }
191
80
  set value(value) {
192
- ReactiveNodeImpl.setNodeVariableValue(this, value);
81
+ ReactiveTreeNodeImpl.setNodeVariableValue(this, value);
193
82
  }
194
83
  get value() {
195
- return ReactiveNodeImpl.useNodeVariableValue(this);
84
+ return ReactiveTreeNodeImpl.useNodeVariableValue(this);
196
85
  }
197
86
  get valueOrUndefined() {
198
- return ReactiveNodeImpl.tryUseNodeVariableValue(this);
87
+ return ReactiveTreeNodeImpl.tryUseNodeVariableValue(this);
199
88
  }
200
89
  }
201
- function generateKey(owner) {
90
+ export function generateKey(owner) {
202
91
  const n = owner.numerator++;
203
92
  const lettered = emitLetters(n);
204
93
  let result;
@@ -250,7 +139,7 @@ function invokeFinalizationUsingBasisChain(element, declaration) {
250
139
  else if (basis)
251
140
  invokeFinalizationUsingBasisChain(element, basis);
252
141
  }
253
- class ReactiveNodeContextImpl extends TriggeringObject {
142
+ class ReactiveTreeNodeContextImpl extends ObservableObject {
254
143
  constructor(variable, value) {
255
144
  super();
256
145
  this.next = undefined;
@@ -259,14 +148,14 @@ class ReactiveNodeContextImpl extends TriggeringObject {
259
148
  }
260
149
  }
261
150
  __decorate([
262
- trigger(false),
151
+ observable(false),
263
152
  __metadata("design:type", Object)
264
- ], ReactiveNodeContextImpl.prototype, "next", void 0);
153
+ ], ReactiveTreeNodeContextImpl.prototype, "next", void 0);
265
154
  __decorate([
266
- trigger(false),
267
- __metadata("design:type", ReactiveNodeVariable)
268
- ], ReactiveNodeContextImpl.prototype, "variable", void 0);
269
- class ReactiveNodeImpl extends ReactiveNode {
155
+ observable(false),
156
+ __metadata("design:type", ReactiveTreeVariable)
157
+ ], ReactiveTreeNodeContextImpl.prototype, "variable", void 0);
158
+ class ReactiveTreeNodeImpl extends ReactiveTreeNode {
270
159
  constructor(key, driver, declaration, owner) {
271
160
  super();
272
161
  const thisAsUnknown = this;
@@ -293,9 +182,9 @@ class ReactiveNodeImpl extends ReactiveNode {
293
182
  this.numerator = 0;
294
183
  this.priority = Priority.realtime;
295
184
  this.childrenShuffling = false;
296
- ReactiveNodeImpl.grandNodeCount++;
185
+ ReactiveTreeNodeImpl.grandNodeCount++;
297
186
  if (this.has(Mode.autonomous))
298
- ReactiveNodeImpl.disposableNodeCount++;
187
+ ReactiveTreeNodeImpl.disposableNodeCount++;
299
188
  }
300
189
  get strictOrder() { return this.children.isStrict; }
301
190
  set strictOrder(value) { this.children.isStrict = value; }
@@ -309,7 +198,7 @@ class ReactiveNodeImpl extends ReactiveNode {
309
198
  configureReactronic(options) {
310
199
  if (this.stamp < Number.MAX_SAFE_INTEGER - 1 || !this.has(Mode.autonomous))
311
200
  throw new Error("reactronic can be configured only for elements with autonomous mode and only during activation");
312
- return ReactiveSystem.getOperation(this.script).configure(options);
201
+ return manageReactiveOperation(this.script).configure(options);
313
202
  }
314
203
  static get nodeSlot() {
315
204
  if (!gNodeSlot)
@@ -318,20 +207,20 @@ class ReactiveNodeImpl extends ReactiveNode {
318
207
  }
319
208
  static tryUseNodeVariableValue(variable) {
320
209
  var _a, _b;
321
- let node = ReactiveNodeImpl.nodeSlot.instance;
210
+ let node = ReactiveTreeNodeImpl.nodeSlot.instance;
322
211
  while (((_a = node.context) === null || _a === void 0 ? void 0 : _a.variable) !== variable && node.owner !== node)
323
212
  node = node.outer.slot.instance;
324
213
  return (_b = node.context) === null || _b === void 0 ? void 0 : _b.value;
325
214
  }
326
215
  static useNodeVariableValue(variable) {
327
216
  var _a;
328
- const result = (_a = ReactiveNodeImpl.tryUseNodeVariableValue(variable)) !== null && _a !== void 0 ? _a : variable.defaultValue;
217
+ const result = (_a = ReactiveTreeNodeImpl.tryUseNodeVariableValue(variable)) !== null && _a !== void 0 ? _a : variable.defaultValue;
329
218
  if (!result)
330
219
  throw new Error("unknown node variable");
331
220
  return result;
332
221
  }
333
222
  static setNodeVariableValue(variable, value) {
334
- const node = ReactiveNodeImpl.nodeSlot.instance;
223
+ const node = ReactiveTreeNodeImpl.nodeSlot.instance;
335
224
  const owner = node.owner;
336
225
  const hostCtx = runNonReactively(() => { var _a; return (_a = owner.context) === null || _a === void 0 ? void 0 : _a.value; });
337
226
  if (value && value !== hostCtx) {
@@ -346,7 +235,7 @@ class ReactiveNodeImpl extends ReactiveNode {
346
235
  ctx.value = value;
347
236
  }
348
237
  else
349
- node.context = new ReactiveNodeContextImpl(variable, value);
238
+ node.context = new ReactiveTreeNodeContextImpl(variable, value);
350
239
  });
351
240
  }
352
241
  else if (hostCtx)
@@ -355,21 +244,25 @@ class ReactiveNodeImpl extends ReactiveNode {
355
244
  node.outer = owner.outer;
356
245
  }
357
246
  }
358
- ReactiveNodeImpl.logging = undefined;
359
- ReactiveNodeImpl.grandNodeCount = 0;
360
- ReactiveNodeImpl.disposableNodeCount = 0;
247
+ ReactiveTreeNodeImpl.logging = undefined;
248
+ ReactiveTreeNodeImpl.grandNodeCount = 0;
249
+ ReactiveTreeNodeImpl.disposableNodeCount = 0;
250
+ ReactiveTreeNodeImpl.shortFrameDuration = 16;
251
+ ReactiveTreeNodeImpl.longFrameDuration = 300;
252
+ ReactiveTreeNodeImpl.currentScriptPriority = Priority.realtime;
253
+ ReactiveTreeNodeImpl.frameDuration = ReactiveTreeNodeImpl.longFrameDuration;
361
254
  __decorate([
362
- reaction,
255
+ reactive,
363
256
  options({
364
257
  reentrance: Reentrance.cancelAndWaitPrevious,
365
258
  allowObsoleteToFinish: true,
366
- triggeringArgs: true,
259
+ observableArgs: true,
367
260
  noSideEffects: false,
368
261
  }),
369
262
  __metadata("design:type", Function),
370
263
  __metadata("design:paramtypes", [Object]),
371
264
  __metadata("design:returntype", void 0)
372
- ], ReactiveNodeImpl.prototype, "script", null);
265
+ ], ReactiveTreeNodeImpl.prototype, "script", null);
373
266
  function getNodeKey(node) {
374
267
  return node.stamp >= 0 ? node.key : undefined;
375
268
  }
@@ -444,29 +337,29 @@ function runNestedScriptsIncrementally(owner, stamp, allChildren, items, priorit
444
337
  return __awaiter(this, void 0, void 0, function* () {
445
338
  yield Transaction.requestNextFrame();
446
339
  const node = owner.instance;
447
- if (!Transaction.isCanceled || !Transaction.isFrameOver(1, ReactiveNode.shortFrameDuration / 3)) {
448
- let outerPriority = ReactiveNode.currentScriptPriority;
449
- ReactiveNode.currentScriptPriority = priority;
340
+ if (!Transaction.isCanceled || !Transaction.isFrameOver(1, ReactiveTreeNodeImpl.shortFrameDuration / 3)) {
341
+ let outerPriority = ReactiveTreeNodeImpl.currentScriptPriority;
342
+ ReactiveTreeNodeImpl.currentScriptPriority = priority;
450
343
  try {
451
344
  if (node.childrenShuffling)
452
345
  shuffle(items);
453
- const frameDurationLimit = priority === Priority.background ? ReactiveNode.shortFrameDuration : Infinity;
454
- let frameDuration = Math.min(frameDurationLimit, Math.max(ReactiveNode.frameDuration / 4, ReactiveNode.shortFrameDuration));
346
+ const frameDurationLimit = priority === Priority.background ? ReactiveTreeNodeImpl.shortFrameDuration : Infinity;
347
+ let frameDuration = Math.min(frameDurationLimit, Math.max(ReactiveTreeNodeImpl.frameDuration / 4, ReactiveTreeNodeImpl.shortFrameDuration));
455
348
  for (const child of items) {
456
349
  triggerScriptRunViaSlot(child);
457
350
  if (Transaction.isFrameOver(1, frameDuration)) {
458
- ReactiveNode.currentScriptPriority = outerPriority;
351
+ ReactiveTreeNodeImpl.currentScriptPriority = outerPriority;
459
352
  yield Transaction.requestNextFrame(0);
460
- outerPriority = ReactiveNode.currentScriptPriority;
461
- ReactiveNode.currentScriptPriority = priority;
462
- frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit, ReactiveNode.frameDuration));
353
+ outerPriority = ReactiveTreeNodeImpl.currentScriptPriority;
354
+ ReactiveTreeNodeImpl.currentScriptPriority = priority;
355
+ frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit, ReactiveTreeNodeImpl.frameDuration));
463
356
  }
464
- if (Transaction.isCanceled && Transaction.isFrameOver(1, ReactiveNode.shortFrameDuration / 3))
357
+ if (Transaction.isCanceled && Transaction.isFrameOver(1, ReactiveTreeNodeImpl.shortFrameDuration / 3))
465
358
  break;
466
359
  }
467
360
  }
468
361
  finally {
469
- ReactiveNode.currentScriptPriority = outerPriority;
362
+ ReactiveTreeNodeImpl.currentScriptPriority = outerPriority;
470
363
  }
471
364
  }
472
365
  });
@@ -479,7 +372,7 @@ function triggerScriptRunViaSlot(nodeSlot) {
479
372
  Transaction.outside(() => {
480
373
  if (ReactiveSystem.isLogging)
481
374
  ReactiveSystem.setLoggingHint(node.element, node.key);
482
- ReactiveSystem.getOperation(node.script).configure({
375
+ manageReactiveOperation(node.script).configure({
483
376
  order: node.level,
484
377
  });
485
378
  });
@@ -554,7 +447,7 @@ function triggerFinalization(nodeSlot, isLeader, individual) {
554
447
  }
555
448
  for (const child of node.children.items())
556
449
  triggerFinalization(child, childrenAreLeaders, false);
557
- ReactiveNodeImpl.grandNodeCount--;
450
+ ReactiveTreeNodeImpl.grandNodeCount--;
558
451
  }
559
452
  }
560
453
  function runDisposalLoop() {
@@ -564,9 +457,9 @@ function runDisposalLoop() {
564
457
  while (slot !== undefined) {
565
458
  if (Transaction.isFrameOver(500, 5))
566
459
  yield Transaction.requestNextFrame();
567
- ReactiveSystem.dispose(slot.instance);
460
+ disposeObservableObject(slot.instance);
568
461
  slot = slot.aux;
569
- ReactiveNodeImpl.disposableNodeCount--;
462
+ ReactiveTreeNodeImpl.disposableNodeCount--;
570
463
  }
571
464
  gFirstToDispose = gLastToDispose = undefined;
572
465
  });
@@ -592,7 +485,7 @@ function runInsideContextOfNode(nodeSlot, func, ...args) {
592
485
  gNodeSlot = outer;
593
486
  }
594
487
  }
595
- function triggersAreEqual(a1, a2) {
488
+ export function observablesAreEqual(a1, a2) {
596
489
  let result = a1 === a2;
597
490
  if (!result) {
598
491
  if (Array.isArray(a1)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.93.25026",
3
+ "version": "0.94.25028",
4
4
  "description": "Reactronic - Transactional Reactive State Management",
5
5
  "publisher": "Nezaboodka Software",
6
6
  "license": "Apache-2.0",
@@ -1,7 +0,0 @@
1
- import { F } from "./util/Utils.js";
2
- import { TriggeringObject } from "./core/Mvcc.js";
3
- export declare class ReactiveLoop<T> extends TriggeringObject {
4
- protected reactiveFunction: F<T>;
5
- constructor(reactiveFunction: F<T>);
6
- protected launch(): T;
7
- }
@@ -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
- }