reactronic 0.92.25010 → 0.92.25012

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,5 +1,5 @@
1
1
  import { ObservableObject } from "./core/Mvcc.js";
2
- export declare class Clock extends ObservableObject {
2
+ export declare class RealTimeClock extends ObservableObject {
3
3
  hour: number;
4
4
  minute: number;
5
5
  second: number;
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { ObservableObject } from "./core/Mvcc.js";
11
11
  import { atomic, reactive } from "./ReactiveSystem.js";
12
- export class Clock extends ObservableObject {
12
+ export class RealTimeClock extends ObservableObject {
13
13
  constructor(interval = 1000) {
14
14
  super();
15
15
  this.hour = 0;
@@ -50,16 +50,16 @@ __decorate([
50
50
  __metadata("design:type", Function),
51
51
  __metadata("design:paramtypes", [Boolean]),
52
52
  __metadata("design:returntype", void 0)
53
- ], Clock.prototype, "pause", null);
53
+ ], RealTimeClock.prototype, "pause", null);
54
54
  __decorate([
55
55
  atomic,
56
56
  __metadata("design:type", Function),
57
57
  __metadata("design:paramtypes", []),
58
58
  __metadata("design:returntype", void 0)
59
- ], Clock.prototype, "tick", null);
59
+ ], RealTimeClock.prototype, "tick", null);
60
60
  __decorate([
61
61
  reactive,
62
62
  __metadata("design:type", Function),
63
63
  __metadata("design:paramtypes", []),
64
64
  __metadata("design:returntype", void 0)
65
- ], Clock.prototype, "activate", null);
65
+ ], RealTimeClock.prototype, "activate", null);
@@ -21,4 +21,4 @@ export { ReactiveSystem, observable, unobservable, atomic, reactive, cached, opt
21
21
  export { ReactiveLoop } from "./ReactiveLoop.js";
22
22
  export { ReactiveNode, Mode, Priority, BaseDriver, ReactiveNodeVariable } from "./core/ReactiveNode.js";
23
23
  export type { Script, ScriptAsync, Handler, ReactiveNodeDecl, ReactiveNodeDriver, ReactiveNodeContext } from "./core/ReactiveNode.js";
24
- export { Clock } from "./Clock.js";
24
+ export { RealTimeClock } from "./RealTimeClock.js";
@@ -16,4 +16,4 @@ export { atomicRun, nonReactiveRun, sensitiveRun, contextualRun } from "./Reacti
16
16
  export { ReactiveSystem, observable, unobservable, atomic, reactive, cached, options } from "./ReactiveSystem.js";
17
17
  export { ReactiveLoop } from "./ReactiveLoop.js";
18
18
  export { ReactiveNode, Mode, Priority, BaseDriver, ReactiveNodeVariable } from "./core/ReactiveNode.js";
19
- export { Clock } from "./Clock.js";
19
+ export { RealTimeClock } from "./RealTimeClock.js";
@@ -35,13 +35,13 @@ export declare abstract class ReactiveNode<E = unknown> {
35
35
  abstract configureReactronic(options: Partial<MemberOptions>): MemberOptions;
36
36
  static readonly shortFrameDuration = 16;
37
37
  static readonly longFrameDuration = 300;
38
- static currentUpdatePriority: Priority;
38
+ static currentScriptPriority: Priority;
39
39
  static frameDuration: number;
40
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
41
  static declare<E = void>(driver: ReactiveNodeDriver<E>, declaration?: ReactiveNodeDecl<E>): ReactiveNode<E>;
42
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
43
  static withBasis<E = void>(declaration?: ReactiveNodeDecl<E>, basis?: ReactiveNodeDecl<E>): ReactiveNodeDecl<E>;
44
- static get isFirstUpdate(): boolean;
44
+ static get isFirstScriptRun(): boolean;
45
45
  static get key(): string;
46
46
  static get stamp(): number;
47
47
  static get triggers(): unknown;
@@ -49,9 +49,9 @@ export declare abstract class ReactiveNode<E = unknown> {
49
49
  static set priority(value: Priority);
50
50
  static get childrenShuffling(): boolean;
51
51
  static set childrenShuffling(value: boolean);
52
- static triggerUpdate(node: ReactiveNode<any>, triggers: unknown): void;
52
+ static triggerScriptRun(node: ReactiveNode<any>, triggers: unknown): void;
53
53
  static triggerFinalization(node: ReactiveNode<any>): void;
54
- static updateNestedNodesThenDo(action: (error: unknown) => void): void;
54
+ static runNestedNodeScriptsThenDo(action: (error: unknown) => void): void;
55
55
  static markAsMounted(node: ReactiveNode<any>, yes: boolean): void;
56
56
  static findMatchingHost<E = unknown, R = unknown>(node: ReactiveNode<E>, match: Handler<ReactiveNode<E>, boolean>): ReactiveNode<R> | undefined;
57
57
  static findMatchingPrevSibling<E = unknown, R = unknown>(node: ReactiveNode<E>, match: Handler<ReactiveNode<E>, boolean>): ReactiveNode<R> | undefined;
@@ -71,7 +71,7 @@ export class ReactiveNode {
71
71
  else {
72
72
  result = new ReactiveNodeImpl(effectiveKey || "", driver, declaration, owner);
73
73
  result.slot = MergeList.createItem(result);
74
- triggerUpdateViaSlot(result.slot);
74
+ triggerScriptRunViaSlot(result.slot);
75
75
  }
76
76
  return result;
77
77
  }
@@ -82,7 +82,7 @@ export class ReactiveNode {
82
82
  declaration = basis !== null && basis !== void 0 ? basis : {};
83
83
  return declaration;
84
84
  }
85
- static get isFirstUpdate() {
85
+ static get isFirstScriptRun() {
86
86
  return ReactiveNodeImpl.ownSlot.instance.stamp === 1;
87
87
  }
88
88
  static get key() {
@@ -106,20 +106,20 @@ export class ReactiveNode {
106
106
  static set childrenShuffling(value) {
107
107
  ReactiveNodeImpl.ownSlot.instance.childrenShuffling = value;
108
108
  }
109
- static triggerUpdate(node, triggers) {
109
+ static triggerScriptRun(node, triggers) {
110
110
  const impl = node;
111
111
  const declaration = impl.declaration;
112
112
  if (!triggersAreEqual(triggers, declaration.triggers)) {
113
113
  declaration.triggers = triggers;
114
- triggerUpdateViaSlot(impl.slot);
114
+ triggerScriptRunViaSlot(impl.slot);
115
115
  }
116
116
  }
117
117
  static triggerFinalization(node) {
118
118
  const impl = node;
119
119
  triggerFinalization(impl.slot, true, true);
120
120
  }
121
- static updateNestedNodesThenDo(action) {
122
- runUpdateNestedNodesThenDo(ReactiveNodeImpl.ownSlot, undefined, action);
121
+ static runNestedNodeScriptsThenDo(action) {
122
+ runNestedNodeScriptsThenDoImpl(ReactiveNodeImpl.ownSlot, undefined, action);
123
123
  }
124
124
  static markAsMounted(node, yes) {
125
125
  const n = node;
@@ -155,7 +155,7 @@ export class ReactiveNode {
155
155
  }
156
156
  ReactiveNode.shortFrameDuration = 16;
157
157
  ReactiveNode.longFrameDuration = 300;
158
- ReactiveNode.currentUpdatePriority = Priority.realtime;
158
+ ReactiveNode.currentScriptPriority = Priority.realtime;
159
159
  ReactiveNode.frameDuration = ReactiveNode.longFrameDuration;
160
160
  export class BaseDriver {
161
161
  constructor(name, isPartition, initialize) {
@@ -303,13 +303,13 @@ class ReactiveNodeImpl extends ReactiveNode {
303
303
  has(mode) {
304
304
  return (getModeUsingBasisChain(this.declaration) & mode) === mode;
305
305
  }
306
- update(_triggers) {
307
- updateNow(this.slot);
306
+ script(_triggers) {
307
+ runScriptNow(this.slot);
308
308
  }
309
309
  configureReactronic(options) {
310
310
  if (this.stamp < Number.MAX_SAFE_INTEGER - 1 || !this.has(Mode.autonomous))
311
311
  throw new Error("reactronic can be configured only for elements with autonomous mode and only during activation");
312
- return ReactiveSystem.getOperation(this.update).configure(options);
312
+ return ReactiveSystem.getOperation(this.script).configure(options);
313
313
  }
314
314
  static get ownSlot() {
315
315
  if (!gOwnSlot)
@@ -369,11 +369,11 @@ __decorate([
369
369
  __metadata("design:type", Function),
370
370
  __metadata("design:paramtypes", [Object]),
371
371
  __metadata("design:returntype", void 0)
372
- ], ReactiveNodeImpl.prototype, "update", null);
372
+ ], ReactiveNodeImpl.prototype, "script", null);
373
373
  function getNodeKey(node) {
374
374
  return node.stamp >= 0 ? node.key : undefined;
375
375
  }
376
- function runUpdateNestedNodesThenDo(ownSlot, error, action) {
376
+ function runNestedNodeScriptsThenDoImpl(ownSlot, error, action) {
377
377
  runInside(ownSlot, () => {
378
378
  var _a;
379
379
  const owner = ownSlot.instance;
@@ -399,7 +399,7 @@ function runUpdateNestedNodesThenDo(ownSlot, error, action) {
399
399
  mounting = markToMountIfNecessary(mounting, host, child, children, sequential);
400
400
  const p = (_a = childNode.priority) !== null && _a !== void 0 ? _a : Priority.realtime;
401
401
  if (p === Priority.realtime)
402
- triggerUpdateViaSlot(child);
402
+ triggerScriptRunViaSlot(child);
403
403
  else if (p === Priority.normal)
404
404
  p1 = push(child, p1);
405
405
  else
@@ -408,7 +408,7 @@ function runUpdateNestedNodesThenDo(ownSlot, error, action) {
408
408
  partition = childNode;
409
409
  }
410
410
  if (!Transaction.isCanceled && (p1 !== undefined || p2 !== undefined))
411
- promised = startIncrementalUpdate(ownSlot, children, p1, p2).then(() => action(error), e => action(e));
411
+ promised = startIncrementalNestedScriptsRun(ownSlot, children, p1, p2).then(() => action(error), e => action(e));
412
412
  }
413
413
  }
414
414
  finally {
@@ -431,34 +431,34 @@ function markToMountIfNecessary(mounting, host, slot, children, sequential) {
431
431
  node.host = host;
432
432
  return mounting;
433
433
  }
434
- function startIncrementalUpdate(ownerSlot, allChildren, priority1, priority2) {
434
+ function startIncrementalNestedScriptsRun(ownerSlot, allChildren, priority1, priority2) {
435
435
  return __awaiter(this, void 0, void 0, function* () {
436
436
  const stamp = ownerSlot.instance.stamp;
437
437
  if (priority1)
438
- yield updateIncrementally(ownerSlot, stamp, allChildren, priority1, Priority.normal);
438
+ yield runNestedScriptsIncrementally(ownerSlot, stamp, allChildren, priority1, Priority.normal);
439
439
  if (priority2)
440
- yield updateIncrementally(ownerSlot, stamp, allChildren, priority2, Priority.background);
440
+ yield runNestedScriptsIncrementally(ownerSlot, stamp, allChildren, priority2, Priority.background);
441
441
  });
442
442
  }
443
- function updateIncrementally(owner, stamp, allChildren, items, priority) {
443
+ function runNestedScriptsIncrementally(owner, stamp, allChildren, items, priority) {
444
444
  return __awaiter(this, void 0, void 0, function* () {
445
445
  yield Transaction.requestNextFrame();
446
446
  const node = owner.instance;
447
447
  if (!Transaction.isCanceled || !Transaction.isFrameOver(1, ReactiveNode.shortFrameDuration / 3)) {
448
- let outerPriority = ReactiveNode.currentUpdatePriority;
449
- ReactiveNode.currentUpdatePriority = priority;
448
+ let outerPriority = ReactiveNode.currentScriptPriority;
449
+ ReactiveNode.currentScriptPriority = priority;
450
450
  try {
451
451
  if (node.childrenShuffling)
452
452
  shuffle(items);
453
453
  const frameDurationLimit = priority === Priority.background ? ReactiveNode.shortFrameDuration : Infinity;
454
454
  let frameDuration = Math.min(frameDurationLimit, Math.max(ReactiveNode.frameDuration / 4, ReactiveNode.shortFrameDuration));
455
455
  for (const child of items) {
456
- triggerUpdateViaSlot(child);
456
+ triggerScriptRunViaSlot(child);
457
457
  if (Transaction.isFrameOver(1, frameDuration)) {
458
- ReactiveNode.currentUpdatePriority = outerPriority;
458
+ ReactiveNode.currentScriptPriority = outerPriority;
459
459
  yield Transaction.requestNextFrame(0);
460
- outerPriority = ReactiveNode.currentUpdatePriority;
461
- ReactiveNode.currentUpdatePriority = priority;
460
+ outerPriority = ReactiveNode.currentScriptPriority;
461
+ ReactiveNode.currentScriptPriority = priority;
462
462
  frameDuration = Math.min(4 * frameDuration, Math.min(frameDurationLimit, ReactiveNode.frameDuration));
463
463
  }
464
464
  if (Transaction.isCanceled && Transaction.isFrameOver(1, ReactiveNode.shortFrameDuration / 3))
@@ -466,12 +466,12 @@ function updateIncrementally(owner, stamp, allChildren, items, priority) {
466
466
  }
467
467
  }
468
468
  finally {
469
- ReactiveNode.currentUpdatePriority = outerPriority;
469
+ ReactiveNode.currentScriptPriority = outerPriority;
470
470
  }
471
471
  }
472
472
  });
473
473
  }
474
- function triggerUpdateViaSlot(slot) {
474
+ function triggerScriptRunViaSlot(slot) {
475
475
  const node = slot.instance;
476
476
  if (node.stamp >= 0) {
477
477
  if (node.has(Mode.autonomous)) {
@@ -479,15 +479,15 @@ function triggerUpdateViaSlot(slot) {
479
479
  Transaction.outside(() => {
480
480
  if (ReactiveSystem.isLogging)
481
481
  ReactiveSystem.setLoggingHint(node.element, node.key);
482
- ReactiveSystem.getOperation(node.update).configure({
482
+ ReactiveSystem.getOperation(node.script).configure({
483
483
  order: node.level,
484
484
  });
485
485
  });
486
486
  }
487
- nonReactiveRun(node.update, node.declaration.triggers);
487
+ nonReactiveRun(node.script, node.declaration.triggers);
488
488
  }
489
489
  else
490
- updateNow(slot);
490
+ runScriptNow(slot);
491
491
  }
492
492
  }
493
493
  function mountOrRemountIfNecessary(node) {
@@ -506,7 +506,7 @@ function mountOrRemountIfNecessary(node) {
506
506
  else if (node.isMoved && !node.has(Mode.manualMount) && node.host !== node)
507
507
  nonReactiveRun(() => driver.runMount(node));
508
508
  }
509
- function updateNow(slot) {
509
+ function runScriptNow(slot) {
510
510
  const node = slot.instance;
511
511
  if (node.stamp >= 0) {
512
512
  let result = undefined;
@@ -519,11 +519,11 @@ function updateNow(slot) {
519
519
  node.children.beginMerge();
520
520
  const driver = node.driver;
521
521
  result = driver.runScript(node);
522
- result = proceedSyncOrAsync(result, v => { runUpdateNestedNodesThenDo(slot, undefined, NOP); return v; }, e => { console.log(e); runUpdateNestedNodesThenDo(slot, e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
522
+ result = proceedSyncOrAsync(result, v => { runNestedNodeScriptsThenDoImpl(slot, undefined, NOP); return v; }, e => { console.log(e); runNestedNodeScriptsThenDoImpl(slot, e !== null && e !== void 0 ? e : new Error("unknown error"), NOP); });
523
523
  }
524
524
  catch (e) {
525
- runUpdateNestedNodesThenDo(slot, e, NOP);
526
- console.log(`Update failed: ${node.key}`);
525
+ runNestedNodeScriptsThenDoImpl(slot, e, NOP);
526
+ console.log(`Reactive node script failed: ${node.key}`);
527
527
  console.log(`${e}`);
528
528
  }
529
529
  }
@@ -85,7 +85,7 @@ export function getCallerInfo(prefix) {
85
85
  i = i >= 0 ? i + 2 : 5;
86
86
  let caller = extractFunctionAndLocation(lines[i]);
87
87
  let location = caller;
88
- if (caller.func.endsWith(".update")) {
88
+ if (caller.func.endsWith(".script")) {
89
89
  i = i - 1;
90
90
  caller = extractFunctionAndLocation(lines[i]);
91
91
  location = extractFunctionAndLocation(lines[i + 1]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.92.25010",
3
+ "version": "0.92.25012",
4
4
  "description": "Reactronic - Transactional Reactive State Management",
5
5
  "publisher": "Nezaboodka Software",
6
6
  "license": "Apache-2.0",