reactronic 0.24.118 → 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.
- package/build/dist/source/core/RxNode.d.ts +1 -1
- package/build/dist/source/core/RxNode.js +9 -8
- package/build/dist/source/util/Utils.d.ts +3 -0
- package/build/dist/source/util/Utils.js +46 -0
- package/package.json +1 -1
- package/build/dist/source/core/RxNodeUtils.d.ts +0 -3
- package/build/dist/source/core/RxNodeUtils.js +0 -46
|
@@ -39,7 +39,7 @@ export declare abstract class RxNode<E = unknown> {
|
|
|
39
39
|
static get isFirstUpdate(): boolean;
|
|
40
40
|
static get nodeStamp(): number;
|
|
41
41
|
static triggerUpdate(node: RxNode<any>, triggers: unknown): void;
|
|
42
|
-
static
|
|
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 '
|
|
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';
|
|
@@ -89,8 +89,8 @@ export class RxNode {
|
|
|
89
89
|
triggerUpdateViaSeat(impl.seat);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
static
|
|
93
|
-
|
|
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
|
|
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 => {
|
|
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
|
-
|
|
467
|
+
runUpdateNestedNodesThenDo(undefined, NOP);
|
|
467
468
|
}
|
|
468
469
|
catch (e) {
|
|
469
|
-
|
|
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,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('.acquire') >= 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
|
-
}
|