reactronic 0.24.117 → 0.24.119

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.
@@ -17,6 +17,6 @@ export { Transaction } from './core/Transaction.js';
17
17
  export { Monitor } from './core/Monitor.js';
18
18
  export { Journal } from './core/Journal.js';
19
19
  export { RxSystem, raw, obs, transactional, reactive, cached, transaction, unobs, sensitive, options } from './RxSystem.js';
20
- export { RxNode, Mode, Priority, BaseDriver, RxNodeVariable } from './tree/RxTree.js';
21
- export type { Delegate, SimpleDelegate, RxNodeDecl, RxNodeDriver, RxNodeContext } from './tree/RxTree.js';
20
+ export { RxNode, Mode, Priority, BaseDriver, RxNodeVariable } from './core/RxNode.js';
21
+ export type { Delegate, SimpleDelegate, RxNodeDecl, RxNodeDriver, RxNodeContext } from './core/RxNode.js';
22
22
  export { Clock } from './Clock.js';
@@ -13,5 +13,5 @@ export { Transaction } from './core/Transaction.js';
13
13
  export { Monitor } from './core/Monitor.js';
14
14
  export { Journal } from './core/Journal.js';
15
15
  export { RxSystem, raw, obs, transactional, reactive, cached, transaction, unobs, sensitive, options } from './RxSystem.js';
16
- export { RxNode, Mode, Priority, BaseDriver, RxNodeVariable } from './tree/RxTree.js';
16
+ export { RxNode, Mode, Priority, BaseDriver, RxNodeVariable } from './core/RxNode.js';
17
17
  export { Clock } from './Clock.js';
@@ -35,11 +35,11 @@ export declare abstract class RxNode<E = unknown> {
35
35
  static readonly longFrameDuration = 300;
36
36
  static currentUpdatePriority: Priority;
37
37
  static frameDuration: number;
38
- static declare<E = void>(driver: RxNodeDriver<E>, declaration?: RxNodeDecl<E>, preset?: RxNodeDecl<E>): RxNode<E>;
38
+ static acquire<E = void>(driver: RxNodeDriver<E>, declaration?: RxNodeDecl<E>, preset?: RxNodeDecl<E>): RxNode<E>;
39
39
  static get isFirstUpdate(): boolean;
40
40
  static get nodeStamp(): number;
41
41
  static triggerUpdate(node: RxNode<any>, triggers: unknown): void;
42
- static updateNestedTreesThenDo(action: (error: unknown) => void): void;
42
+ static updateNestedNodesThenDo(action: (error: unknown) => void): void;
43
43
  static findMatchingHost<E = unknown, R = unknown>(node: RxNode<E>, match: SimpleDelegate<RxNode<E>, boolean>): RxNode<R> | undefined;
44
44
  static findMatchingPrevSibling<E = unknown, R = unknown>(node: RxNode<E>, match: SimpleDelegate<RxNode<E>, boolean>): RxNode<R> | undefined;
45
45
  static forEachChildRecursively<E = unknown>(node: RxNode<E>, action: SimpleDelegate<RxNode<E>>): void;
@@ -17,7 +17,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  });
18
18
  };
19
19
  import { MergeList } from '../util/MergeList.js';
20
- import { emitLetters, getCallerInfo } from './RxNodeUtils.js';
20
+ import { emitLetters, getCallerInfo } from '../util/Utils.js';
21
21
  import { Reentrance } from '../Options.js';
22
22
  import { ObservableObject } from '../core/Mvcc.js';
23
23
  import { Transaction } from '../core/Transaction.js';
@@ -35,7 +35,7 @@ export var Priority;
35
35
  Priority[Priority["Background"] = 2] = "Background";
36
36
  })(Priority || (Priority = {}));
37
37
  export class RxNode {
38
- static declare(driver, declaration, preset) {
38
+ static acquire(driver, declaration, preset) {
39
39
  var _a;
40
40
  let result;
41
41
  if (declaration)
@@ -89,8 +89,8 @@ export class RxNode {
89
89
  triggerUpdateViaSeat(impl.seat);
90
90
  }
91
91
  }
92
- static updateNestedTreesThenDo(action) {
93
- runUpdateNestedTreesThenDo(undefined, action);
92
+ static updateNestedNodesThenDo(action) {
93
+ runUpdateNestedNodesThenDo(undefined, action);
94
94
  }
95
95
  static findMatchingHost(node, match) {
96
96
  let p = node.host;
@@ -209,8 +209,9 @@ __decorate([
209
209
  raw,
210
210
  __metadata("design:type", RxNodeVariable)
211
211
  ], RxNodeContextImpl.prototype, "variable", void 0);
212
- class RxNodeImpl {
212
+ class RxNodeImpl extends RxNode {
213
213
  constructor(key, driver, declaration, owner) {
214
+ super();
214
215
  const thisAsUnknown = this;
215
216
  this.key = key;
216
217
  this.driver = driver;
@@ -314,7 +315,7 @@ __decorate([
314
315
  function getNodeKey(node) {
315
316
  return node.stamp >= 0 ? node.key : undefined;
316
317
  }
317
- function runUpdateNestedTreesThenDo(error, action) {
318
+ function runUpdateNestedNodesThenDo(error, action) {
318
319
  var _a;
319
320
  const curr = RxNodeImpl.current;
320
321
  const owner = curr.instance;
@@ -461,12 +462,12 @@ function updateNow(seat) {
461
462
  const driver = node.driver;
462
463
  result = driver.update(node);
463
464
  if (result instanceof Promise)
464
- result.then(v => { runUpdateNestedTreesThenDo(undefined, NOP); return v; }, e => { console.log(e); runUpdateNestedTreesThenDo(e !== null && e !== void 0 ? e : new Error('unknown error'), NOP); });
465
+ result.then(v => { runUpdateNestedNodesThenDo(undefined, NOP); return v; }, e => { console.log(e); runUpdateNestedNodesThenDo(e !== null && e !== void 0 ? e : new Error('unknown error'), NOP); });
465
466
  else
466
- runUpdateNestedTreesThenDo(undefined, NOP);
467
+ runUpdateNestedNodesThenDo(undefined, NOP);
467
468
  }
468
469
  catch (e) {
469
- runUpdateNestedTreesThenDo(e, NOP);
470
+ runUpdateNestedNodesThenDo(e, NOP);
470
471
  console.log(`Update failed: ${node.key}`);
471
472
  console.log(`${e}`);
472
473
  }
@@ -7,3 +7,6 @@ export declare class Utils {
7
7
  export declare function UNDEF(...args: any[]): never;
8
8
  export declare function all(promises: Array<Promise<any>>): Promise<any[]>;
9
9
  export declare function pause<T>(timeout: number): Promise<T>;
10
+ export declare function emitLetters(n: number): string;
11
+ export declare function objectHasMember<T>(obj: any, member: string): obj is T;
12
+ export declare function getCallerInfo(prefix: string): string;
@@ -53,3 +53,49 @@ export function pause(timeout) {
53
53
  setTimeout(resolve.bind(null, () => resolve), timeout);
54
54
  });
55
55
  }
56
+ export function emitLetters(n) {
57
+ if (n < 0)
58
+ throw new Error(`emitLetters: argument (${n}) should not be negative or zero`);
59
+ let result = '';
60
+ while (n >= 0) {
61
+ const r = n % 26;
62
+ n = Math.floor(n / 26) - 1;
63
+ result = String.fromCharCode(65 + r) + result;
64
+ }
65
+ return result;
66
+ }
67
+ export function objectHasMember(obj, member) {
68
+ return obj === Object(obj) && !Array.isArray(obj) && member in obj;
69
+ }
70
+ export function getCallerInfo(prefix) {
71
+ const restore = Error.stackTraceLimit = 20;
72
+ const error = new Error();
73
+ const stack = error.stack || '';
74
+ Error.stackTraceLimit = restore;
75
+ const lines = stack.split('\n');
76
+ let i = lines.findIndex(x => x.indexOf('.acquire') >= 0);
77
+ i = i >= 0 ? i + 2 : 5;
78
+ let caller = extractFunctionAndLocation(lines[i]);
79
+ let location = caller;
80
+ if (caller.func.endsWith('.update')) {
81
+ i = i - 1;
82
+ caller = extractFunctionAndLocation(lines[i]);
83
+ location = extractFunctionAndLocation(lines[i + 1]);
84
+ }
85
+ else {
86
+ while (!caller.func && i > 0) {
87
+ i = i - 1;
88
+ caller = extractFunctionAndLocation(lines[i]);
89
+ }
90
+ location = extractFunctionAndLocation(lines[i + 1]);
91
+ }
92
+ const result = `${prefix}·${caller.func}@${location.file}`;
93
+ return result;
94
+ }
95
+ function extractFunctionAndLocation(s) {
96
+ const match = s.match(/(?:\s*at\s+)?(?:(\S+)\s\()?(?:.*?)([^\/\(\):]+)(?:(:|\d)*\)?)$/);
97
+ return {
98
+ func: (match === null || match === void 0 ? void 0 : match[1]) || '',
99
+ file: (match === null || match === void 0 ? void 0 : match[2]) || '',
100
+ };
101
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactronic",
3
- "version": "0.24.117",
3
+ "version": "0.24.119",
4
4
  "description": "Reactronic - Transactional Reactive State Management",
5
5
  "publisher": "Nezaboodka Software",
6
6
  "license": "Apache-2.0",
@@ -1,3 +0,0 @@
1
- export declare function emitLetters(n: number): string;
2
- export declare function objectHasMember<T>(obj: any, member: string): obj is T;
3
- export declare function getCallerInfo(prefix: string): string;
@@ -1,46 +0,0 @@
1
- export function emitLetters(n) {
2
- if (n < 0)
3
- throw new Error(`emitLetters: argument (${n}) should not be negative or zero`);
4
- let result = '';
5
- while (n >= 0) {
6
- const r = n % 26;
7
- n = Math.floor(n / 26) - 1;
8
- result = String.fromCharCode(65 + r) + result;
9
- }
10
- return result;
11
- }
12
- export function objectHasMember(obj, member) {
13
- return obj === Object(obj) && !Array.isArray(obj) && member in obj;
14
- }
15
- export function getCallerInfo(prefix) {
16
- const restore = Error.stackTraceLimit = 20;
17
- const error = new Error();
18
- const stack = error.stack || '';
19
- Error.stackTraceLimit = restore;
20
- const lines = stack.split('\n');
21
- let i = lines.findIndex(x => x.indexOf('.declare') >= 0);
22
- i = i >= 0 ? i + 2 : 5;
23
- let caller = extractFunctionAndLocation(lines[i]);
24
- let location = caller;
25
- if (caller.func.endsWith('.update')) {
26
- i = i - 1;
27
- caller = extractFunctionAndLocation(lines[i]);
28
- location = extractFunctionAndLocation(lines[i + 1]);
29
- }
30
- else {
31
- while (!caller.func && i > 0) {
32
- i = i - 1;
33
- caller = extractFunctionAndLocation(lines[i]);
34
- }
35
- location = extractFunctionAndLocation(lines[i + 1]);
36
- }
37
- const result = `${prefix}·${caller.func}@${location.file}`;
38
- return result;
39
- }
40
- function extractFunctionAndLocation(s) {
41
- const match = s.match(/(?:\s*at\s+)?(?:(\S+)\s\()?(?:.*?)([^\/\(\):]+)(?:(:|\d)*\)?)$/);
42
- return {
43
- func: (match === null || match === void 0 ? void 0 : match[1]) || '',
44
- file: (match === null || match === void 0 ? void 0 : match[2]) || '',
45
- };
46
- }