reactronic 0.24.502 → 0.91.25002

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.
@@ -37,9 +37,9 @@ export declare abstract class ReactiveNode<E = unknown> {
37
37
  static readonly longFrameDuration = 300;
38
38
  static currentUpdatePriority: Priority;
39
39
  static frameDuration: number;
40
- static declare<E = void>(driver: ReactiveNodeDriver<E>, content?: Script<E>, contentAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>, triggers?: unknown, basis?: ReactiveNodeDecl<E>): ReactiveNode<E>;
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
- static declare<E = void>(driver: ReactiveNodeDriver<E>, contentOrDeclaration?: Script<E> | ReactiveNodeDecl<E>, contentAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>, triggers?: unknown, basis?: 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
43
  static withBasis<E = void>(declaration?: ReactiveNodeDecl<E>, basis?: ReactiveNodeDecl<E>): ReactiveNodeDecl<E>;
44
44
  static get isFirstUpdate(): boolean;
45
45
  static get key(): string;
@@ -60,8 +60,8 @@ export declare abstract class ReactiveNode<E = unknown> {
60
60
  static setDefaultLoggingOptions(logging?: LoggingOptions): void;
61
61
  }
62
62
  export type ReactiveNodeDecl<E = unknown> = {
63
- content?: Script<E>;
64
- contentAsync?: ScriptAsync<E>;
63
+ script?: Script<E>;
64
+ scriptAsync?: ScriptAsync<E>;
65
65
  key?: string;
66
66
  mode?: Mode;
67
67
  preparation?: Script<E>;
@@ -75,11 +75,11 @@ export type ReactiveNodeDriver<E = unknown> = {
75
75
  readonly isPartition: boolean;
76
76
  readonly initialize?: Handler<E>;
77
77
  create(node: ReactiveNode<E>): E;
78
- prepare(node: ReactiveNode<E>): void;
79
- finalize(node: ReactiveNode<E>, isLeader: boolean): boolean;
80
- mount(node: ReactiveNode<E>): void;
81
- update(node: ReactiveNode<E>): void | Promise<void>;
82
- child(ownerNode: ReactiveNode<E>, childDriver: ReactiveNodeDriver<any>, childDeclaration?: ReactiveNodeDecl<any>, childBasis?: ReactiveNodeDecl<any>): MergedItem<ReactiveNode> | undefined;
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
83
  provideHost(node: ReactiveNode<E>): ReactiveNode<E>;
84
84
  };
85
85
  export type ReactiveNodeContext<T extends Object = Object> = {
@@ -91,11 +91,11 @@ export declare abstract class BaseDriver<E = unknown> implements ReactiveNodeDri
91
91
  readonly initialize?: Handler<E> | undefined;
92
92
  constructor(name: string, isPartition: boolean, initialize?: Handler<E> | undefined);
93
93
  abstract create(node: ReactiveNode<E>): E;
94
- prepare(node: ReactiveNode<E>): void | Promise<void>;
95
- finalize(node: ReactiveNode<E>, isLeader: boolean): boolean;
96
- mount(node: ReactiveNode<E>): void;
97
- update(node: ReactiveNode<E>): void | Promise<void>;
98
- child(ownerNode: ReactiveNode<E>, childDriver: ReactiveNodeDriver<any>, childDeclaration?: ReactiveNodeDecl<any>, childBasis?: ReactiveNodeDecl<any>): MergedItem<ReactiveNode> | undefined;
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
99
  provideHost(node: ReactiveNode<E>): ReactiveNode<E>;
100
100
  }
101
101
  export declare class ReactiveNodeVariable<T extends Object = Object> {
@@ -37,23 +37,23 @@ export var Priority;
37
37
  Priority[Priority["background"] = 2] = "background";
38
38
  })(Priority || (Priority = {}));
39
39
  export class ReactiveNode {
40
- static declare(driver, contentOrDeclaration, contentAsync, key, mode, preparation, preparationAsync, finalization, triggers, basis) {
40
+ static declare(driver, scriptOrDeclaration, scriptAsync, key, mode, preparation, preparationAsync, finalization, triggers, basis) {
41
41
  let result;
42
42
  let declaration;
43
- if (contentOrDeclaration instanceof Function) {
43
+ if (scriptOrDeclaration instanceof Function) {
44
44
  declaration = {
45
- content: contentOrDeclaration, contentAsync, key, mode,
45
+ script: scriptOrDeclaration, scriptAsync, key, mode,
46
46
  preparation, preparationAsync, finalization, triggers, basis,
47
47
  };
48
48
  }
49
49
  else
50
- declaration = contentOrDeclaration !== null && contentOrDeclaration !== void 0 ? contentOrDeclaration : {};
50
+ declaration = scriptOrDeclaration !== null && scriptOrDeclaration !== void 0 ? scriptOrDeclaration : {};
51
51
  let effectiveKey = declaration.key;
52
52
  const owner = (getModeUsingBasisChain(declaration) & Mode.rootNode) !== Mode.rootNode ? gOwnSlot === null || gOwnSlot === void 0 ? void 0 : gOwnSlot.instance : undefined;
53
53
  if (owner) {
54
- let existing = owner.driver.child(owner, driver, declaration, declaration.basis);
54
+ let existing = owner.driver.declareChild(owner, driver, declaration, declaration.basis);
55
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 content script only"));
56
+ existing !== null && existing !== void 0 ? existing : (existing = children.tryMergeAsExisting(effectiveKey = effectiveKey || generateKey(owner), undefined, "nested elements can be declared inside 'script' only"));
57
57
  if (existing) {
58
58
  result = existing.instance;
59
59
  if (result.driver !== driver && driver !== undefined)
@@ -163,21 +163,21 @@ export class BaseDriver {
163
163
  this.isPartition = isPartition;
164
164
  this.initialize = initialize;
165
165
  }
166
- prepare(node) {
166
+ runPreparation(node) {
167
167
  var _a;
168
168
  (_a = this.initialize) === null || _a === void 0 ? void 0 : _a.call(this, node.element);
169
169
  return invokePreparationUsingBasisChain(node.element, node.declaration);
170
170
  }
171
- finalize(node, isLeader) {
171
+ runFinalization(node, isLeader) {
172
172
  invokeFinalizationUsingBasisChain(node.element, node.declaration);
173
173
  return isLeader;
174
174
  }
175
- mount(node) {
175
+ runMount(node) {
176
176
  }
177
- update(node) {
178
- return invokeContentUsingBasisChain(node.element, node.declaration);
177
+ runScript(node) {
178
+ return invokeScriptUsingBasisChain(node.element, node.declaration);
179
179
  }
180
- child(ownerNode, childDriver, childDeclaration, childBasis) {
180
+ declareChild(ownerNode, childDriver, childDeclaration, childBasis) {
181
181
  return undefined;
182
182
  }
183
183
  provideHost(node) {
@@ -212,19 +212,19 @@ function getModeUsingBasisChain(declaration) {
212
212
  var _a;
213
213
  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);
214
214
  }
215
- function invokeContentUsingBasisChain(element, declaration) {
215
+ function invokeScriptUsingBasisChain(element, declaration) {
216
216
  let result = undefined;
217
217
  const basis = declaration.basis;
218
- const content = declaration.content;
219
- const contentAsync = declaration.contentAsync;
220
- if (content && contentAsync)
221
- throw misuse("'content' and 'contentAsync' cannot be defined together");
222
- if (content)
223
- result = content(element, basis ? () => invokeContentUsingBasisChain(element, basis) : NOP);
224
- else if (contentAsync)
225
- result = contentAsync(element, basis ? () => invokeContentUsingBasisChain(element, basis) : NOP_ASYNC);
218
+ const script = declaration.script;
219
+ const scriptAsync = declaration.scriptAsync;
220
+ if (script && scriptAsync)
221
+ throw misuse("'script' and 'scriptAsync' cannot be defined together");
222
+ if (script)
223
+ result = script(element, basis ? () => invokeScriptUsingBasisChain(element, basis) : NOP);
224
+ else if (scriptAsync)
225
+ result = scriptAsync(element, basis ? () => invokeScriptUsingBasisChain(element, basis) : NOP_ASYNC);
226
226
  else if (basis)
227
- result = invokeContentUsingBasisChain(element, basis);
227
+ result = invokeScriptUsingBasisChain(element, basis);
228
228
  return result;
229
229
  }
230
230
  function invokePreparationUsingBasisChain(element, declaration) {
@@ -495,16 +495,16 @@ function mountOrRemountIfNecessary(node) {
495
495
  if (node.stamp === Number.MAX_SAFE_INTEGER) {
496
496
  unobs(() => {
497
497
  node.stamp = Number.MAX_SAFE_INTEGER - 1;
498
- driver.prepare(node);
498
+ driver.runPreparation(node);
499
499
  if (!node.has(Mode.manualMount)) {
500
500
  node.stamp = 0;
501
501
  if (node.host !== node)
502
- driver.mount(node);
502
+ driver.runMount(node);
503
503
  }
504
504
  });
505
505
  }
506
506
  else if (node.isMoved && !node.has(Mode.manualMount) && node.host !== node)
507
- unobs(() => driver.mount(node));
507
+ unobs(() => driver.runMount(node));
508
508
  }
509
509
  function updateNow(slot) {
510
510
  const node = slot.instance;
@@ -518,7 +518,7 @@ function updateNow(slot) {
518
518
  node.numerator = 0;
519
519
  node.children.beginMerge();
520
520
  const driver = node.driver;
521
- result = driver.update(node);
521
+ result = driver.runScript(node);
522
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); });
523
523
  }
524
524
  catch (e) {
@@ -537,7 +537,7 @@ function triggerFinalization(slot, isLeader, individual) {
537
537
  if (individual && node.key !== node.declaration.key && !driver.isPartition)
538
538
  console.log(`WARNING: it is recommended to assign explicit key for conditional element in order to avoid unexpected side effects: ${node.key}`);
539
539
  node.stamp = ~node.stamp;
540
- const childrenAreLeaders = unobs(() => driver.finalize(node, isLeader));
540
+ const childrenAreLeaders = unobs(() => driver.runFinalization(node, isLeader));
541
541
  if (node.has(Mode.autonomous)) {
542
542
  slot.aux = undefined;
543
543
  const last = gLastToDispose;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.24.502",
3
+ "version": "0.91.25002",
4
4
  "description": "Reactronic - Transactional Reactive State Management",
5
5
  "publisher": "Nezaboodka Software",
6
6
  "license": "Apache-2.0",
@@ -31,14 +31,14 @@
31
31
  },
32
32
  "homepage": "https://github.com/nezaboodka/reactronic/blob/master/README.md#readme",
33
33
  "devDependencies": {
34
- "@types/node": "22.8.6",
35
- "@types/react": "18.3.12",
36
- "@typescript-eslint/eslint-plugin": "8.12.2",
37
- "@typescript-eslint/parser": "8.12.2",
34
+ "@types/node": "22.13.0",
35
+ "@types/react": "19.0.8",
36
+ "@typescript-eslint/eslint-plugin": "8.22.0",
37
+ "@typescript-eslint/parser": "8.22.0",
38
38
  "ava": "6.2.0",
39
- "c8": "10.1.2",
40
- "eslint": "9.14.0",
41
- "react": "18.3.1",
39
+ "c8": "10.1.3",
40
+ "eslint": "9.19.0",
41
+ "react": "19.0.0",
42
42
  "ts-node": "10.9.2",
43
43
  "typescript": "5.5.4"
44
44
  },