reactronic 0.96.26003 → 0.96.26005

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.
@@ -1,7 +1,6 @@
1
1
  export { all, pause, proceedSyncOrAsync } from "./util/Utils.js";
2
2
  export { Uri } from "./util/Uri.js";
3
- export { ReconciliationList } from "./util/ReconciliationList.js";
4
- export type { LinkedItem, ReconciliationListReader } from "./util/ReconciliationList.js";
3
+ export { LinkedList, LinkedItem } from "./util/LinkedList.js";
5
4
  export { SealedArray } from "./util/SealedArray.js";
6
5
  export { SealedMap } from "./util/SealedMap.js";
7
6
  export { SealedSet } from "./util/SealedSet.js";
@@ -1,6 +1,6 @@
1
1
  export { all, pause, proceedSyncOrAsync } from "./util/Utils.js";
2
2
  export { Uri } from "./util/Uri.js";
3
- export { ReconciliationList } from "./util/ReconciliationList.js";
3
+ export { LinkedList, LinkedItem } from "./util/LinkedList.js";
4
4
  export { SealedArray } from "./util/SealedArray.js";
5
5
  export { SealedMap } from "./util/SealedMap.js";
6
6
  export { SealedSet } from "./util/SealedSet.js";
@@ -1,5 +1,5 @@
1
1
  import { LoggingOptions } from "../Logging.js";
2
- import { ReconciliationList, ReconciliationListReader, LinkedItem } from "../util/ReconciliationList.js";
2
+ import { LinkedList, LinkedItem } from "../util/LinkedList.js";
3
3
  import { Priority, Mode } from "../Enums.js";
4
4
  import { ReactivityOptions } from "../Options.js";
5
5
  import { RxObject } from "../core/Mvcc.js";
@@ -11,7 +11,7 @@ export declare function declare<E = void>(driver: ReactiveTreeNodeDriver<E>, dec
11
11
  export declare function declare<E = void>(driver: ReactiveTreeNodeDriver<E>, bodyOrDeclaration?: Script<E> | ReactiveTreeNodeDecl<E>, bodyTask?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationTask?: ScriptAsync<E>, finalization?: Script<E>, signalArgs?: unknown, basis?: ReactiveTreeNodeDecl<E>): ReactiveTreeNode<E>;
12
12
  export declare function derivative<E = void>(declaration?: ReactiveTreeNodeDecl<E>, basis?: ReactiveTreeNodeDecl<E>): ReactiveTreeNodeDecl<E>;
13
13
  export declare function launch<T>(node: ReactiveTreeNode<T>, signalArgs?: unknown): ReactiveTreeNode<T>;
14
- export declare abstract class ReactiveTreeNode<E = unknown> {
14
+ export declare abstract class ReactiveTreeNode<E = unknown> extends LinkedItem<ReactiveTreeNode<E>> {
15
15
  static readonly shortFrameDuration = 16;
16
16
  static readonly longFrameDuration = 300;
17
17
  static frameDuration: number;
@@ -23,8 +23,7 @@ export declare abstract class ReactiveTreeNode<E = unknown> {
23
23
  abstract readonly owner: ReactiveTreeNode;
24
24
  abstract element: E;
25
25
  abstract readonly host: ReactiveTreeNode;
26
- abstract readonly children: ReconciliationListReader<ReactiveTreeNode>;
27
- abstract readonly slot: LinkedItem<ReactiveTreeNode<E>> | undefined;
26
+ abstract readonly children: LinkedList<ReactiveTreeNode>;
28
27
  abstract readonly stamp: number;
29
28
  abstract readonly outer: ReactiveTreeNode;
30
29
  abstract readonly context: ReactiveTreeNodeContext | undefined;
@@ -36,7 +35,7 @@ export declare abstract class ReactiveTreeNode<E = unknown> {
36
35
  abstract configureReactivity(options: Partial<ReactivityOptions>): ReactivityOptions;
37
36
  static get current(): ReactiveTreeNode;
38
37
  static get isFirstBodyBuild(): boolean;
39
- static buildBody(node: ReactiveTreeNode<any>, signalArgs: unknown): void;
38
+ static rebuildBody(node: ReactiveTreeNode<any>, signalArgs: unknown): void;
40
39
  static launchFinalization(node: ReactiveTreeNode<any>): void;
41
40
  static launchNestedNodesThenDo(action: (error: unknown) => void): void;
42
41
  static markAsMounted(node: ReactiveTreeNode<any>, yes: boolean): void;
@@ -66,7 +65,7 @@ export type ReactiveTreeNodeDriver<E = unknown> = {
66
65
  runPreparation(node: ReactiveTreeNode<E>): void;
67
66
  runFinalization(node: ReactiveTreeNode<E>, isLeader: boolean): boolean;
68
67
  runMount(node: ReactiveTreeNode<E>): void;
69
- buildBody(node: ReactiveTreeNode<E>): void | Promise<void>;
68
+ runScript(node: ReactiveTreeNode<E>): void | Promise<void>;
70
69
  declareChild(ownerNode: ReactiveTreeNode<E>, childDriver: ReactiveTreeNodeDriver<any>, childDeclaration?: ReactiveTreeNodeDecl<any>, childBasis?: ReactiveTreeNodeDecl<any>): LinkedItem<ReactiveTreeNode> | undefined;
71
70
  provideHost(node: ReactiveTreeNode<E>): ReactiveTreeNode<E>;
72
71
  };
@@ -82,7 +81,7 @@ export declare abstract class BaseDriver<E = unknown> implements ReactiveTreeNod
82
81
  runPreparation(node: ReactiveTreeNode<E>): void | Promise<void>;
83
82
  runFinalization(node: ReactiveTreeNode<E>, isLeader: boolean): boolean;
84
83
  runMount(node: ReactiveTreeNode<E>): void;
85
- buildBody(node: ReactiveTreeNode<E>): void | Promise<void>;
84
+ runScript(node: ReactiveTreeNode<E>): void | Promise<void>;
86
85
  declareChild(ownerNode: ReactiveTreeNode<E>, childDriver: ReactiveTreeNodeDriver<any>, childDeclaration?: ReactiveTreeNodeDecl<any>, childBasis?: ReactiveTreeNodeDecl<any>): LinkedItem<ReactiveTreeNode> | undefined;
87
86
  provideHost(node: ReactiveTreeNode<E>): ReactiveTreeNode<E>;
88
87
  }
@@ -111,9 +110,8 @@ declare class ReactiveTreeNode$<E = unknown> extends ReactiveTreeNode<E> {
111
110
  readonly level: number;
112
111
  readonly owner: ReactiveTreeNode$;
113
112
  readonly element: E;
114
- host: ReactiveTreeNode$;
115
- readonly children: ReconciliationList<ReactiveTreeNode$>;
116
- slot: LinkedItem<ReactiveTreeNode$<E>> | undefined;
113
+ host: ReactiveTreeNode;
114
+ readonly children: LinkedList<ReactiveTreeNode>;
117
115
  stamp: number;
118
116
  outer: ReactiveTreeNode$;
119
117
  context: ReactiveTreeNodeContext$<any> | undefined;
@@ -128,7 +126,7 @@ declare class ReactiveTreeNode$<E = unknown> extends ReactiveTreeNode<E> {
128
126
  has(mode: Mode): boolean;
129
127
  body(_signalArgs: unknown): void;
130
128
  configureReactivity(options: Partial<ReactivityOptions>): ReactivityOptions;
131
- static get nodeSlot(): LinkedItem<ReactiveTreeNode$>;
129
+ static get node(): ReactiveTreeNode$;
132
130
  static tryUseTreeVariableValue<T extends Object>(variable: ReactiveTreeVariable<T>): T | undefined;
133
131
  static useTreeVariableValue<T extends Object>(variable: ReactiveTreeVariable<T>): T;
134
132
  static setTreeVariableValue<T extends Object>(variable: ReactiveTreeVariable<T>, value: T | undefined): void;
@@ -18,7 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18
18
  };
19
19
  import { misuse } from "../util/Dbg.js";
20
20
  import { Uri } from "../util/Uri.js";
21
- import { ReconciliationList } from "../util/ReconciliationList.js";
21
+ import { LinkedList, LinkedItem, Mark, LinkedSubList } from "../util/LinkedList.js";
22
22
  import { emitLetters, flags, getCallerInfo, proceedSyncOrAsync } from "../util/Utils.js";
23
23
  import { Priority, Mode, Isolation, Reentrance } from "../Enums.js";
24
24
  import { RxObject } from "../core/Mvcc.js";
@@ -36,13 +36,13 @@ export function declare(driver, bodyOrDeclaration, bodyTask, key, mode, preparat
36
36
  else
37
37
  declaration = bodyOrDeclaration !== null && bodyOrDeclaration !== void 0 ? bodyOrDeclaration : {};
38
38
  let effectiveKey = declaration.key;
39
- const owner = gNodeSlot === null || gNodeSlot === void 0 ? void 0 : gNodeSlot.instance;
39
+ const owner = gCurrentNode;
40
40
  if (owner) {
41
41
  let existing = owner.driver.declareChild(owner, driver, declaration, declaration.basis);
42
- const children = owner.children;
43
- existing !== null && existing !== void 0 ? existing : (existing = children.tryReuse(effectiveKey = effectiveKey || generateKey(owner), undefined, "nested elements can be declared inside 'body' only"));
42
+ const renovation = owner.children.renovation;
43
+ existing !== null && existing !== void 0 ? existing : (existing = renovation.tryReaffirm(effectiveKey = effectiveKey || generateKey(owner), undefined, "nested elements can be declared inside 'body' only"));
44
44
  if (existing) {
45
- result = existing.instance;
45
+ result = existing;
46
46
  if (result.driver !== driver && driver !== undefined)
47
47
  throw misuse(`changing element driver is not yet supported: "${result.driver.name}" -> "${driver === null || driver === void 0 ? void 0 : driver.name}"`);
48
48
  const exSignalArgs = result.declaration.signalArgs;
@@ -52,12 +52,11 @@ export function declare(driver, bodyOrDeclaration, bodyTask, key, mode, preparat
52
52
  }
53
53
  else {
54
54
  result = new ReactiveTreeNode$(effectiveKey || generateKey(owner), driver, declaration, owner);
55
- result.slot = children.add(result);
55
+ renovation.thisIsAdded(result);
56
56
  }
57
57
  }
58
58
  else {
59
59
  result = new ReactiveTreeNode$(effectiveKey || generateKey(owner), driver, declaration, owner);
60
- result.slot = ReconciliationList.createItem(result);
61
60
  }
62
61
  return result;
63
62
  }
@@ -69,30 +68,30 @@ export function derivative(declaration, basis) {
69
68
  return declaration;
70
69
  }
71
70
  export function launch(node, signalArgs) {
72
- ReactiveTreeNode.buildBody(node, signalArgs);
71
+ ReactiveTreeNode.rebuildBody(node, signalArgs);
73
72
  return node;
74
73
  }
75
- export class ReactiveTreeNode {
74
+ export class ReactiveTreeNode extends LinkedItem {
76
75
  static get current() {
77
- return ReactiveTreeNode$.nodeSlot.instance;
76
+ return ReactiveTreeNode$.node;
78
77
  }
79
78
  static get isFirstBodyBuild() {
80
79
  return ReactiveTreeNode.current.stamp === 1;
81
80
  }
82
- static buildBody(node, signalArgs) {
81
+ static rebuildBody(node, signalArgs) {
83
82
  const impl = node;
84
83
  const declaration = impl.declaration;
85
84
  if (node.stamp >= Number.MAX_SAFE_INTEGER || !signalsAreEqual(signalArgs, declaration.signalArgs)) {
86
85
  declaration.signalArgs = signalArgs;
87
- buildBodyViaSlot(impl.slot);
86
+ rebuildBodyImpl(impl);
88
87
  }
89
88
  }
90
89
  static launchFinalization(node) {
91
90
  const impl = node;
92
- launchFinalizationViaSlot(impl.slot, true, true);
91
+ launchFinalizationImpl(impl, true, true);
93
92
  }
94
93
  static launchNestedNodesThenDo(action) {
95
- launchNestedNodesThenDoImpl(ReactiveTreeNode$.nodeSlot, undefined, action);
94
+ launchNestedNodesThenDoImpl(ReactiveTreeNode$.node, undefined, action);
96
95
  }
97
96
  static markAsMounted(node, yes) {
98
97
  const n = node;
@@ -103,14 +102,13 @@ export class ReactiveTreeNode {
103
102
  n.stamp = yes ? 0 : Number.MAX_SAFE_INTEGER - 1;
104
103
  }
105
104
  lookupTreeNodeByUri(uri) {
106
- var _a;
107
105
  const t = Uri.parse(uri);
108
106
  if (t.authority !== this.key)
109
107
  throw misuse(`authority '${t.authority}' doesn't match root node key '${this.key}'`);
110
108
  const segments = t.path.split("/");
111
109
  let result = this;
112
110
  for (let i = 1; i < segments.length && result !== undefined; i++)
113
- result = (_a = result.children.lookup(segments[i])) === null || _a === void 0 ? void 0 : _a.instance;
111
+ result = result.children.lookup(segments[i]);
114
112
  return result;
115
113
  }
116
114
  static findMatchingHost(node, match) {
@@ -120,15 +118,15 @@ export class ReactiveTreeNode {
120
118
  return p;
121
119
  }
122
120
  static findMatchingPrevSibling(node, match) {
123
- let p = node.slot.prev;
124
- while (p && !match(p.instance))
121
+ let p = node.prev;
122
+ while (p && !match(p))
125
123
  p = p.prev;
126
- return p === null || p === void 0 ? void 0 : p.instance;
124
+ return p;
127
125
  }
128
126
  static forEachChildRecursively(node, action) {
129
127
  action(node);
130
128
  for (const child of node.children.items())
131
- ReactiveTreeNode.forEachChildRecursively(child.instance, action);
129
+ ReactiveTreeNode.forEachChildRecursively(child, action);
132
130
  }
133
131
  static getDefaultLoggingOptions() {
134
132
  return ReactiveTreeNode$.logging;
@@ -158,8 +156,8 @@ export class BaseDriver {
158
156
  }
159
157
  runMount(node) {
160
158
  }
161
- buildBody(node) {
162
- return invokeBuildBodyUsingBasisChain(node.element, node.declaration);
159
+ runScript(node) {
160
+ return invokeScriptUsingBasisChain(node.element, node.declaration);
163
161
  }
164
162
  declareChild(ownerNode, childDriver, childDeclaration, childBasis) {
165
163
  return undefined;
@@ -196,7 +194,7 @@ export function getModeUsingBasisChain(declaration) {
196
194
  var _a;
197
195
  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);
198
196
  }
199
- function invokeBuildBodyUsingBasisChain(element, declaration) {
197
+ function invokeScriptUsingBasisChain(element, declaration) {
200
198
  let result = undefined;
201
199
  const basis = declaration.basis;
202
200
  const body = declaration.body;
@@ -204,11 +202,11 @@ function invokeBuildBodyUsingBasisChain(element, declaration) {
204
202
  if (body && bodyTask)
205
203
  throw misuse("'body' and 'bodyTask' cannot be defined together");
206
204
  if (body)
207
- result = body.call(element, element, basis ? () => invokeBuildBodyUsingBasisChain(element, basis) : NOP);
205
+ result = body.call(element, element, basis ? () => invokeScriptUsingBasisChain(element, basis) : NOP);
208
206
  else if (bodyTask)
209
- result = bodyTask.call(element, element, basis ? () => invokeBuildBodyUsingBasisChain(element, basis) : NOP_ASYNC);
207
+ result = bodyTask.call(element, element, basis ? () => invokeScriptUsingBasisChain(element, basis) : NOP_ASYNC);
210
208
  else if (basis)
211
- result = invokeBuildBodyUsingBasisChain(element, basis);
209
+ result = invokeScriptUsingBasisChain(element, basis);
212
210
  return result;
213
211
  }
214
212
  function invokePreparationUsingBasisChain(element, declaration) {
@@ -270,8 +268,7 @@ class ReactiveTreeNode$ extends ReactiveTreeNode {
270
268
  }
271
269
  this.element = driver.create(this);
272
270
  this.host = thisAsUnknown;
273
- this.children = new ReconciliationList(getNodeKey, true);
274
- this.slot = undefined;
271
+ this.children = new LinkedList(getNodeKey, true);
275
272
  this.stamp = Number.MAX_SAFE_INTEGER;
276
273
  this.context = undefined;
277
274
  this.numerator = 0;
@@ -292,35 +289,35 @@ class ReactiveTreeNode$ extends ReactiveTreeNode {
292
289
  return result.toString();
293
290
  }
294
291
  get strictOrder() {
295
- return this.children.isStrict;
292
+ return this.children.isStrictOrder;
296
293
  }
297
294
  set strictOrder(value) {
298
- this.children.isStrict = value;
295
+ this.children.isStrictOrder = value;
299
296
  }
300
297
  get isMoved() {
301
- return this.owner.children.isMoved(this.slot);
298
+ return this.mark === Mark.modified;
302
299
  }
303
300
  has(mode) {
304
301
  return flags(getModeUsingBasisChain(this.declaration), mode);
305
302
  }
306
303
  body(_signalArgs) {
307
- buildBodyNow(this.slot);
304
+ runScriptNow(this);
308
305
  }
309
306
  configureReactivity(options) {
310
307
  if (this.stamp < Number.MAX_SAFE_INTEGER - 1 || !this.has(Mode.autonomous))
311
308
  throw misuse("reactronic can be configured only for elements with autonomous mode and only during preparation");
312
309
  return manageReaction(this.body).configure(options);
313
310
  }
314
- static get nodeSlot() {
315
- if (!gNodeSlot)
316
- throw misuse("current element is undefined");
317
- return gNodeSlot;
311
+ static get node() {
312
+ if (!gCurrentNode)
313
+ throw misuse("current node is undefined");
314
+ return gCurrentNode;
318
315
  }
319
316
  static tryUseTreeVariableValue(variable) {
320
317
  var _a, _b;
321
- let node = ReactiveTreeNode$.nodeSlot.instance;
322
- while (((_a = node.context) === null || _a === void 0 ? void 0 : _a.variable) !== variable && node.owner !== node)
323
- node = node.outer.slot.instance;
318
+ let node = ReactiveTreeNode.current;
319
+ while (((_a = node.context) === null || _a === void 0 ? void 0 : _a.value) !== variable && node.owner !== node)
320
+ node = node.outer;
324
321
  return (_b = node.context) === null || _b === void 0 ? void 0 : _b.value;
325
322
  }
326
323
  static useTreeVariableValue(variable) {
@@ -331,7 +328,7 @@ class ReactiveTreeNode$ extends ReactiveTreeNode {
331
328
  return result;
332
329
  }
333
330
  static setTreeVariableValue(variable, value) {
334
- const node = ReactiveTreeNode$.nodeSlot.instance;
331
+ const node = ReactiveTreeNode$.node;
335
332
  const owner = node.owner;
336
333
  const hostCtx = runNonReactive(() => { var _a; return (_a = owner.context) === null || _a === void 0 ? void 0 : _a.value; });
337
334
  if (value && value !== hostCtx) {
@@ -383,42 +380,42 @@ function gatherAuthorityAndPath(node, path, relativeTo) {
383
380
  function getNodeKey(node) {
384
381
  return node.stamp >= 0 ? node.key : undefined;
385
382
  }
386
- function launchNestedNodesThenDoImpl(nodeSlot, error, action) {
387
- runInsideContextOfNode(nodeSlot, () => {
383
+ function launchNestedNodesThenDoImpl(node, error, action) {
384
+ runInsideContextOfNode(node, () => {
388
385
  var _a;
389
- const owner = nodeSlot.instance;
386
+ const owner = node;
390
387
  const children = owner.children;
391
- if (children.isReconciliationInProgress) {
388
+ if (children.isRenovationInProgress) {
392
389
  let promised = undefined;
393
390
  try {
394
- children.endReconciliation(error);
395
- for (const child of children.itemsRemoved(true))
396
- launchFinalizationViaSlot(child, true, true);
391
+ const renovation = children.endRenovation(error);
392
+ for (const child of renovation.lostItems())
393
+ launchFinalizationImpl(child, true, true);
397
394
  if (!error) {
398
- const sequential = children.isStrict;
395
+ const sequential = children.isStrictOrder;
399
396
  let p1 = undefined;
400
397
  let p2 = undefined;
401
398
  let mounting = false;
402
399
  let partition = owner;
403
- for (const child of children.items()) {
400
+ for (const c of children.items()) {
404
401
  if (Transaction.isCanceled)
405
402
  break;
406
- const childNode = child.instance;
407
- const isPart = childNode.driver.isPartition;
403
+ const child = c;
404
+ const isPart = child.driver.isPartition;
408
405
  const host = isPart ? owner : partition;
409
406
  mounting = markToMountIfNecessary(mounting, host, child, children, sequential);
410
- const p = (_a = childNode.priority) !== null && _a !== void 0 ? _a : Priority.realtime;
407
+ const p = (_a = child.priority) !== null && _a !== void 0 ? _a : Priority.realtime;
411
408
  if (p === Priority.realtime)
412
- buildBodyViaSlot(child);
409
+ rebuildBodyImpl(child);
413
410
  else if (p === Priority.normal)
414
411
  p1 = push(child, p1);
415
412
  else
416
413
  p2 = push(child, p2);
417
414
  if (isPart)
418
- partition = childNode;
415
+ partition = child;
419
416
  }
420
417
  if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
421
- promised = startIncrementalNestedBodyBuild(nodeSlot, children, p1, p2).then(() => action(error), e => action(e));
418
+ promised = startIncrementalNestedScriptsRun(node, children, p1, p2).then(() => action(error), e => action(e));
422
419
  }
423
420
  }
424
421
  finally {
@@ -428,32 +425,31 @@ function launchNestedNodesThenDoImpl(nodeSlot, error, action) {
428
425
  }
429
426
  });
430
427
  }
431
- function markToMountIfNecessary(mounting, host, nodeSlot, children, sequential) {
432
- const node = nodeSlot.instance;
428
+ function markToMountIfNecessary(mounting, host, node, children, sequential) {
433
429
  if (node.element.native && !node.has(Mode.external)) {
434
430
  if (mounting || node.host !== host) {
435
- children.markAsMoved(nodeSlot);
431
+ LinkedItem.setStatus$(node, Mark.modified, node.rank);
436
432
  mounting = false;
437
433
  }
438
434
  }
439
- else if (sequential && children.isMoved(nodeSlot))
435
+ else if (sequential && node.mark === Mark.modified)
440
436
  mounting = true;
441
437
  node.host = host;
442
438
  return mounting;
443
439
  }
444
- function startIncrementalNestedBodyBuild(ownerSlot, allChildren, priority1, priority2) {
440
+ function startIncrementalNestedScriptsRun(ownerNode, allChildren, priority1, priority2) {
445
441
  return __awaiter(this, void 0, void 0, function* () {
446
- const stamp = ownerSlot.instance.stamp;
442
+ const stamp = ownerNode.stamp;
447
443
  if (priority1)
448
- yield runNestedBodyBuildIncrementally(ownerSlot, stamp, allChildren, priority1, Priority.normal);
444
+ yield runNestedScriptsIncrementally(ownerNode, stamp, allChildren, priority1, Priority.normal);
449
445
  if (priority2)
450
- yield runNestedBodyBuildIncrementally(ownerSlot, stamp, allChildren, priority2, Priority.background);
446
+ yield runNestedScriptsIncrementally(ownerNode, stamp, allChildren, priority2, Priority.background);
451
447
  });
452
448
  }
453
- function runNestedBodyBuildIncrementally(owner, stamp, allChildren, items, priority) {
449
+ function runNestedScriptsIncrementally(owner, stamp, allChildren, items, priority) {
454
450
  return __awaiter(this, void 0, void 0, function* () {
455
451
  yield Transaction.requestNextFrame();
456
- const node = owner.instance;
452
+ const node = owner;
457
453
  if (!Transaction.isCanceled || !Transaction.isFrameOver(1, ReactiveTreeNode$.shortFrameDuration / 3)) {
458
454
  let outerPriority = ReactiveTreeNode$.currentBodyPriority;
459
455
  ReactiveTreeNode$.currentBodyPriority = priority;
@@ -463,7 +459,7 @@ function runNestedBodyBuildIncrementally(owner, stamp, allChildren, items, prior
463
459
  const frameDurationLimit = priority === Priority.background ? ReactiveTreeNode.shortFrameDuration : Infinity;
464
460
  let frameDuration = Math.min(frameDurationLimit, Math.max(ReactiveTreeNode.frameDuration / 4, ReactiveTreeNode.shortFrameDuration));
465
461
  for (const child of items) {
466
- buildBodyViaSlot(child);
462
+ rebuildBodyImpl(child);
467
463
  if (Transaction.isFrameOver(1, frameDuration)) {
468
464
  ReactiveTreeNode$.currentBodyPriority = outerPriority;
469
465
  yield Transaction.requestNextFrame(0);
@@ -481,8 +477,7 @@ function runNestedBodyBuildIncrementally(owner, stamp, allChildren, items, prior
481
477
  }
482
478
  });
483
479
  }
484
- function buildBodyViaSlot(nodeSlot) {
485
- const node = nodeSlot.instance;
480
+ function rebuildBodyImpl(node) {
486
481
  if (node.stamp >= 0) {
487
482
  if (node.has(Mode.autonomous)) {
488
483
  if (node.stamp === Number.MAX_SAFE_INTEGER) {
@@ -497,9 +492,9 @@ function buildBodyViaSlot(nodeSlot) {
497
492
  runNonReactive(node.body, node.declaration.signalArgs);
498
493
  }
499
494
  else if (node.owner !== node)
500
- buildBodyNow(nodeSlot);
495
+ runScriptNow(node);
501
496
  else
502
- runTransactional(() => buildBodyNow(nodeSlot));
497
+ runTransactional(() => runScriptNow(node));
503
498
  }
504
499
  }
505
500
  function mountOrRemountIfNecessary(node) {
@@ -518,32 +513,30 @@ function mountOrRemountIfNecessary(node) {
518
513
  else if (node.isMoved && !node.has(Mode.external) && node.host !== node)
519
514
  runNonReactive(() => driver.runMount(node));
520
515
  }
521
- function buildBodyNow(nodeSlot) {
522
- const node = nodeSlot.instance;
516
+ function runScriptNow(node) {
523
517
  if (node.stamp >= 0) {
524
518
  let result = undefined;
525
- runInsideContextOfNode(nodeSlot, () => {
519
+ runInsideContextOfNode(node, () => {
526
520
  mountOrRemountIfNecessary(node);
527
521
  if (node.stamp < Number.MAX_SAFE_INTEGER - 1) {
528
522
  try {
529
523
  node.stamp++;
530
524
  node.numerator = 0;
531
- node.children.beginReconciliation();
525
+ node.children.beginRenovation();
532
526
  const driver = node.driver;
533
- result = driver.buildBody(node);
534
- result = proceedSyncOrAsync(result, v => { launchNestedNodesThenDoImpl(nodeSlot, undefined, NOP); return v; }, e => { console.log(e); launchNestedNodesThenDoImpl(nodeSlot, e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
527
+ result = driver.runScript(node);
528
+ result = proceedSyncOrAsync(result, v => { launchNestedNodesThenDoImpl(node, undefined, NOP); return v; }, e => { console.log(e); launchNestedNodesThenDoImpl(node, e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
535
529
  }
536
530
  catch (e) {
537
- launchNestedNodesThenDoImpl(nodeSlot, e, NOP);
538
- console.log(`Reactive node body build failed: ${node.key}`);
531
+ launchNestedNodesThenDoImpl(node, e, NOP);
532
+ console.log(`Reactive node body failed: ${node.key}`);
539
533
  console.log(`${e}`);
540
534
  }
541
535
  }
542
536
  });
543
537
  }
544
538
  }
545
- function launchFinalizationViaSlot(nodeSlot, isLeader, individual) {
546
- const node = nodeSlot.instance;
539
+ function launchFinalizationImpl(node, isLeader, individual) {
547
540
  if (node.stamp >= 0) {
548
541
  const driver = node.driver;
549
542
  if (individual && node.key !== node.declaration.key && !driver.isPartition)
@@ -551,39 +544,34 @@ function launchFinalizationViaSlot(nodeSlot, isLeader, individual) {
551
544
  node.stamp = ~node.stamp;
552
545
  const childrenAreLeaders = runNonReactive(() => driver.runFinalization(node, isLeader));
553
546
  if (node.has(Mode.autonomous)) {
554
- nodeSlot.aux = undefined;
555
- const last = gLastToDispose;
556
- if (last)
557
- gLastToDispose = last.aux = nodeSlot;
558
- else
559
- gFirstToDispose = gLastToDispose = nodeSlot;
560
- if (gFirstToDispose === nodeSlot)
561
- runTransactional({ isolation: Isolation.disjoinForInternalDisposal, hint: `runDisposalLoop(initiator=${nodeSlot.instance.key})` }, () => {
547
+ LinkedItem.link$(gDisposeList, node, undefined);
548
+ if (gDisposeList.first === node)
549
+ runTransactional({ isolation: Isolation.disjoinForInternalDisposal, hint: `runDisposalLoop(initiator=${node.key})` }, () => {
562
550
  void runDisposalLoop().then(NOP, error => console.log(error));
563
551
  });
564
552
  }
565
553
  for (const child of node.children.items())
566
- launchFinalizationViaSlot(child, childrenAreLeaders, false);
554
+ launchFinalizationImpl(child, childrenAreLeaders, false);
567
555
  ReactiveTreeNode$.grandNodeCount--;
568
556
  }
569
557
  }
570
558
  function runDisposalLoop() {
571
559
  return __awaiter(this, void 0, void 0, function* () {
572
560
  yield Transaction.requestNextFrame();
573
- let slot = gFirstToDispose;
574
- while (slot !== undefined) {
561
+ let node = gDisposeList.first;
562
+ while (node !== undefined) {
575
563
  if (Transaction.isFrameOver(500, 5))
576
564
  yield Transaction.requestNextFrame();
577
- disposeRxObject(slot.instance);
578
- slot = slot.aux;
565
+ disposeRxObject(node);
566
+ LinkedItem.link$(undefined, node, undefined);
567
+ node = gDisposeList.first;
579
568
  ReactiveTreeNode$.disposableNodeCount--;
580
569
  }
581
- gFirstToDispose = gLastToDispose = undefined;
582
570
  });
583
571
  }
584
572
  function wrapToRunInside(func) {
585
573
  let wrappedToRunInside;
586
- const outer = gNodeSlot;
574
+ const outer = gCurrentNode;
587
575
  if (outer)
588
576
  wrappedToRunInside = (...args) => {
589
577
  return runInsideContextOfNode(outer, func, ...args);
@@ -592,14 +580,14 @@ function wrapToRunInside(func) {
592
580
  wrappedToRunInside = func;
593
581
  return wrappedToRunInside;
594
582
  }
595
- function runInsideContextOfNode(nodeSlot, func, ...args) {
596
- const outer = gNodeSlot;
583
+ function runInsideContextOfNode(node, func, ...args) {
584
+ const outer = gCurrentNode;
597
585
  try {
598
- gNodeSlot = nodeSlot;
586
+ gCurrentNode = node;
599
587
  return func(...args);
600
588
  }
601
589
  finally {
602
- gNodeSlot = outer;
590
+ gCurrentNode = outer;
603
591
  }
604
592
  }
605
593
  export function signalsAreEqual(a1, a2) {
@@ -653,6 +641,5 @@ function defaultReject(error) {
653
641
  Promise.prototype.then = reactronicDomHookedThen;
654
642
  const NOP = (...args) => { };
655
643
  const NOP_ASYNC = (...args) => __awaiter(void 0, void 0, void 0, function* () { });
656
- let gNodeSlot = undefined;
657
- let gFirstToDispose = undefined;
658
- let gLastToDispose = undefined;
644
+ let gCurrentNode = undefined;
645
+ const gDisposeList = new LinkedSubList();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.96.26003",
3
+ "version": "0.96.26005",
4
4
  "description": "Reactronic - Transactional Reactive State Management",
5
5
  "publisher": "Nezaboodka Software",
6
6
  "license": "Apache-2.0",