reactronic 0.24.306 → 0.24.308

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.
@@ -36,7 +36,10 @@ export declare abstract class RxNode<E = unknown> {
36
36
  static readonly longFrameDuration = 300;
37
37
  static currentUpdatePriority: Priority;
38
38
  static frameDuration: number;
39
- static declare<E = void>(driver: RxNodeDriver<E>, declaration?: RxNodeDecl<E>, basis?: RxNodeDecl<E>): RxNode<E>;
39
+ static declare<E = void>(driver: RxNodeDriver<E>, script?: Script<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, creation?: Script<E>, creationAsync?: ScriptAsync<E>, destruction?: Script<E>, triggers?: unknown, basis?: RxNodeDecl<E>): RxNode<E>;
40
+ static declare<E = void>(driver: RxNodeDriver<E>, declaration?: RxNodeDecl<E>): RxNode<E>;
41
+ static declare<E = void>(driver: RxNodeDriver<E>, scriptOrDeclaration?: Script<E> | RxNodeDecl<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, creation?: Script<E>, creationAsync?: ScriptAsync<E>, destruction?: Script<E>, triggers?: unknown, basis?: RxNodeDecl<E>): RxNode<E>;
42
+ static rebased<E = void>(declaration?: RxNodeDecl<E>, basis?: RxNodeDecl<E>): RxNodeDecl<E>;
40
43
  static get isFirstUpdate(): boolean;
41
44
  static get key(): string;
42
45
  static get stamp(): number;
@@ -36,18 +36,23 @@ export var Priority;
36
36
  Priority[Priority["background"] = 2] = "background";
37
37
  })(Priority || (Priority = {}));
38
38
  export class RxNode {
39
- static declare(driver, declaration, basis) {
39
+ static declare(driver, scriptOrDeclaration, scriptAsync, key, mode, creation, creationAsync, destruction, triggers, basis) {
40
40
  let result;
41
- if (declaration)
42
- declaration.basis = basis;
41
+ let declaration;
42
+ if (scriptOrDeclaration instanceof Function) {
43
+ declaration = {
44
+ script: scriptOrDeclaration, scriptAsync, key, mode,
45
+ creation, creationAsync, destruction, triggers, basis,
46
+ };
47
+ }
43
48
  else
44
- declaration = basis !== null && basis !== void 0 ? basis : {};
45
- let key = declaration.key;
49
+ declaration = scriptOrDeclaration !== null && scriptOrDeclaration !== void 0 ? scriptOrDeclaration : {};
50
+ let effectiveKey = declaration.key;
46
51
  const owner = gOwnSeat === null || gOwnSeat === void 0 ? void 0 : gOwnSeat.instance;
47
52
  if (owner) {
48
- let existing = owner.driver.child(owner, driver, declaration, basis);
53
+ let existing = owner.driver.child(owner, driver, declaration, declaration.basis);
49
54
  const children = owner.children;
50
- existing !== null && existing !== void 0 ? existing : (existing = children.tryMergeAsExisting(key = key || generateKey(owner), undefined, "nested elements can be declared inside update function only"));
55
+ existing !== null && existing !== void 0 ? existing : (existing = children.tryMergeAsExisting(effectiveKey = effectiveKey || generateKey(owner), undefined, "nested elements can be declared inside update function only"));
51
56
  if (existing) {
52
57
  result = existing.instance;
53
58
  if (result.driver !== driver && driver !== undefined)
@@ -58,17 +63,24 @@ export class RxNode {
58
63
  result.declaration = declaration;
59
64
  }
60
65
  else {
61
- result = new RxNodeImpl(key || generateKey(owner), driver, declaration, owner);
66
+ result = new RxNodeImpl(effectiveKey || generateKey(owner), driver, declaration, owner);
62
67
  result.seat = children.mergeAsAdded(result);
63
68
  }
64
69
  }
65
70
  else {
66
- result = new RxNodeImpl(key || "", driver, declaration, owner);
71
+ result = new RxNodeImpl(effectiveKey || "", driver, declaration, owner);
67
72
  result.seat = MergeList.createItem(result);
68
73
  triggerUpdateViaSeat(result.seat);
69
74
  }
70
75
  return result;
71
76
  }
77
+ static rebased(declaration, basis) {
78
+ if (declaration)
79
+ declaration.basis = basis;
80
+ else
81
+ declaration = basis !== null && basis !== void 0 ? basis : {};
82
+ return declaration;
83
+ }
72
84
  static get isFirstUpdate() {
73
85
  return RxNodeImpl.ownSeat.instance.stamp === 1;
74
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.24.306",
3
+ "version": "0.24.308",
4
4
  "description": "Reactronic - Transactional Reactive State Management",
5
5
  "publisher": "Nezaboodka Software",
6
6
  "license": "Apache-2.0",