reactronic 0.24.123 → 0.24.125
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/README.md +5 -5
- package/build/dist/source/Clock.d.ts +1 -1
- package/build/dist/source/Clock.js +2 -2
- package/build/dist/source/Logging.d.ts +4 -4
- package/build/dist/source/Logging.js +6 -6
- package/build/dist/source/Options.d.ts +12 -12
- package/build/dist/source/Options.js +1 -1
- package/build/dist/source/Pipe.d.ts +1 -1
- package/build/dist/source/Pipe.js +2 -2
- package/build/dist/source/Reaction.d.ts +2 -2
- package/build/dist/source/Reaction.js +2 -2
- package/build/dist/source/Ref.js +4 -4
- package/build/dist/source/RxSystem.d.ts +2 -2
- package/build/dist/source/RxSystem.js +7 -7
- package/build/dist/source/Worker.d.ts +3 -3
- package/build/dist/source/api.d.ts +23 -23
- package/build/dist/source/api.js +18 -18
- package/build/dist/source/core/Changeset.d.ts +2 -2
- package/build/dist/source/core/Changeset.js +33 -33
- package/build/dist/source/core/Data.d.ts +11 -11
- package/build/dist/source/core/Data.js +3 -3
- package/build/dist/source/core/Journal.d.ts +2 -2
- package/build/dist/source/core/Journal.js +12 -12
- package/build/dist/source/core/Meta.js +7 -7
- package/build/dist/source/core/Monitor.d.ts +2 -2
- package/build/dist/source/core/Monitor.js +6 -6
- package/build/dist/source/core/Mvcc.d.ts +6 -6
- package/build/dist/source/core/Mvcc.js +8 -8
- package/build/dist/source/core/MvccArray.d.ts +1 -1
- package/build/dist/source/core/MvccArray.js +2 -2
- package/build/dist/source/core/MvccMap.d.ts +1 -1
- package/build/dist/source/core/MvccMap.js +2 -2
- package/build/dist/source/core/MvccMergeList.d.ts +2 -2
- package/build/dist/source/core/MvccMergeList.js +1 -1
- package/build/dist/source/core/Reaction.d.ts +6 -6
- package/build/dist/source/core/Reaction.js +59 -59
- package/build/dist/source/core/RxNode.d.ts +9 -9
- package/build/dist/source/core/RxNode.js +15 -15
- package/build/dist/source/core/Transaction.d.ts +4 -4
- package/build/dist/source/core/Transaction.js +13 -13
- package/build/dist/source/util/Dbg.d.ts +1 -1
- package/build/dist/source/util/Dbg.js +11 -11
- package/build/dist/source/util/MergeList.d.ts +4 -4
- package/build/dist/source/util/MergeList.js +5 -5
- package/build/dist/source/util/Sealant.d.ts +4 -4
- package/build/dist/source/util/Sealant.js +5 -5
- package/build/dist/source/util/SealedArray.d.ts +1 -1
- package/build/dist/source/util/SealedArray.js +2 -2
- package/build/dist/source/util/SealedMap.d.ts +1 -1
- package/build/dist/source/util/SealedMap.js +2 -2
- package/build/dist/source/util/SealedSet.d.ts +1 -1
- package/build/dist/source/util/SealedSet.js +2 -2
- package/build/dist/source/util/Utils.js +14 -14
- package/package.json +4 -4
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export function error(message, dump) {
|
|
2
2
|
if (Log.isOn && Log.opt.error)
|
|
3
|
-
Log.write(
|
|
3
|
+
Log.write("█", " ███", message, undefined, " *** ERROR ***", dump);
|
|
4
4
|
return new Error(message);
|
|
5
5
|
}
|
|
6
6
|
export function misuse(message, dump) {
|
|
7
7
|
const error = new Error(message);
|
|
8
|
-
Log.write(
|
|
8
|
+
Log.write(" ", " ███", message, undefined, " *** ERROR / MISUSE ***", dump !== null && dump !== void 0 ? dump : error);
|
|
9
9
|
return error;
|
|
10
10
|
}
|
|
11
11
|
export function fatal(error) {
|
|
12
|
-
Log.write(
|
|
12
|
+
Log.write(" ", " ███", error.message, undefined, " *** FATAL ***", error);
|
|
13
13
|
return error;
|
|
14
14
|
}
|
|
15
15
|
export class Log {
|
|
@@ -18,12 +18,12 @@ export class Log {
|
|
|
18
18
|
Log.global = options || Log.DefaultLevel;
|
|
19
19
|
if (isOn) {
|
|
20
20
|
const t = Log.global;
|
|
21
|
-
const o = Object.keys(Log.global).filter(x => t[x] === true).join(
|
|
22
|
-
Log.write(
|
|
23
|
-
Log.write(
|
|
21
|
+
const o = Object.keys(Log.global).filter(x => t[x] === true).join(", ");
|
|
22
|
+
Log.write("", "", `Reactronic logging is turned on: ${o}`);
|
|
23
|
+
Log.write("", "", "Member-level logging can be configured with @options({ logging: ... }) decorator");
|
|
24
24
|
}
|
|
25
25
|
else if (Log.isOn)
|
|
26
|
-
Log.write(
|
|
26
|
+
Log.write("", "", "Reactronic logging is turned off");
|
|
27
27
|
Log.isOn = isOn;
|
|
28
28
|
}
|
|
29
29
|
static write(bar, tran, message, ms = 0, highlight = undefined, dump) {
|
|
@@ -31,11 +31,11 @@ export class Log {
|
|
|
31
31
|
}
|
|
32
32
|
static writeAs(options, bar, tran, message, ms = 0, highlight = undefined, dump) {
|
|
33
33
|
const t = Log.getMergedLoggingOptions(options);
|
|
34
|
-
const margin1 =
|
|
35
|
-
const margin2 =
|
|
34
|
+
const margin1 = " ".repeat(t.margin1 >= 0 ? t.margin1 : 0);
|
|
35
|
+
const margin2 = " ".repeat(t.margin2);
|
|
36
36
|
const enabled = (options && options.enabled !== undefined) ? options.enabled : t.enabled;
|
|
37
37
|
if (enabled) {
|
|
38
|
-
console.log(
|
|
38
|
+
console.log("\x1b[37m%s\x1b[0m \x1b[" + t.color + "m%s %s%s\x1b[0m \x1b[" + t.color + "m%s%s\x1b[0m \x1b[" + t.color + "m%s\x1b[0m%s", "", t.prefix, t.transaction ? margin1 : "", t.transaction ? bar : bar.replace(/./g, " "), margin2, tran, message, (highlight !== undefined ? `${highlight}` : "") + (ms > 2 ? ` [ ${ms}ms ]` : ""));
|
|
39
39
|
if (dump)
|
|
40
40
|
console.log(dump);
|
|
41
41
|
}
|
|
@@ -80,7 +80,7 @@ Log.DefaultLevel = {
|
|
|
80
80
|
obsolete: false,
|
|
81
81
|
gc: false,
|
|
82
82
|
color: 37,
|
|
83
|
-
prefix:
|
|
83
|
+
prefix: "",
|
|
84
84
|
margin1: 0,
|
|
85
85
|
margin2: 0,
|
|
86
86
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type GetMergeItemKey<T = unknown> = (item: T) => string | undefined;
|
|
2
|
-
export
|
|
2
|
+
export type MergeListReader<T> = {
|
|
3
3
|
readonly isStrict: boolean;
|
|
4
4
|
readonly count: number;
|
|
5
5
|
readonly addedCount: number;
|
|
@@ -21,12 +21,12 @@ export interface MergeListReader<T> {
|
|
|
21
21
|
isMoved(item: MergedItem<T>): boolean;
|
|
22
22
|
isRemoved(item: MergedItem<T>): boolean;
|
|
23
23
|
isActual(item: MergedItem<T>): boolean;
|
|
24
|
-
}
|
|
25
|
-
export
|
|
24
|
+
};
|
|
25
|
+
export type MergedItem<T> = {
|
|
26
26
|
readonly instance: T;
|
|
27
27
|
readonly prev?: MergedItem<T>;
|
|
28
28
|
aux?: MergedItem<T>;
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
30
|
export declare class MergeList<T> implements MergeListReader<T> {
|
|
31
31
|
readonly getKey: GetMergeItemKey<T>;
|
|
32
32
|
private strict;
|
|
@@ -13,7 +13,7 @@ export class MergeList {
|
|
|
13
13
|
get isStrict() { return this.strict; }
|
|
14
14
|
set isStrict(value) {
|
|
15
15
|
if (this.isMergeInProgress && this.current.count > 0)
|
|
16
|
-
throw new Error(
|
|
16
|
+
throw new Error("cannot change strict mode in the middle of merge");
|
|
17
17
|
this.strict = value;
|
|
18
18
|
}
|
|
19
19
|
get count() {
|
|
@@ -46,7 +46,7 @@ export class MergeList {
|
|
|
46
46
|
tryMergeAsExisting(key, resolution, error) {
|
|
47
47
|
const tag = this.tag;
|
|
48
48
|
if (tag < 0)
|
|
49
|
-
throw new Error(error !== null && error !== void 0 ? error :
|
|
49
|
+
throw new Error(error !== null && error !== void 0 ? error : "merge is not in progress");
|
|
50
50
|
let item = this.strictNextItem;
|
|
51
51
|
if (key !== (item ? this.getKey(item.instance) : undefined))
|
|
52
52
|
item = this.lookup(key);
|
|
@@ -96,11 +96,11 @@ export class MergeList {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
move(item, after) {
|
|
99
|
-
throw new Error(
|
|
99
|
+
throw new Error("not implemented");
|
|
100
100
|
}
|
|
101
101
|
beginMerge() {
|
|
102
102
|
if (this.isMergeInProgress)
|
|
103
|
-
throw new Error(
|
|
103
|
+
throw new Error("merge is in progress already");
|
|
104
104
|
this.tag = ~this.tag + 1;
|
|
105
105
|
this.strictNextItem = this.current.first;
|
|
106
106
|
this.removed.grab(this.current, false);
|
|
@@ -108,7 +108,7 @@ export class MergeList {
|
|
|
108
108
|
}
|
|
109
109
|
endMerge(error) {
|
|
110
110
|
if (!this.isMergeInProgress)
|
|
111
|
-
throw new Error(
|
|
111
|
+
throw new Error("merge is ended already");
|
|
112
112
|
this.tag = ~this.tag;
|
|
113
113
|
if (error === undefined) {
|
|
114
114
|
const currentCount = this.current.count;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Sealable<T> = {
|
|
2
2
|
toMutable(): T;
|
|
3
3
|
[Sealant.SealedType]: object;
|
|
4
|
-
}
|
|
5
|
-
export
|
|
4
|
+
};
|
|
5
|
+
export type Sealed<T> = {
|
|
6
6
|
[Sealant.CreateCopy]?: () => T;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
export declare abstract class Sealant {
|
|
9
9
|
static readonly SealedType: unique symbol;
|
|
10
10
|
static readonly CreateCopy: unique symbol;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Log, misuse } from
|
|
1
|
+
import { Log, misuse } from "./Dbg.js";
|
|
2
2
|
export class Sealant {
|
|
3
3
|
static seal(collection, sealedType, typeName, member) {
|
|
4
4
|
let result = collection;
|
|
@@ -6,7 +6,7 @@ export class Sealant {
|
|
|
6
6
|
if (createCopy)
|
|
7
7
|
result = createCopy.call(result);
|
|
8
8
|
if (Log.isOn && Log.opt.write)
|
|
9
|
-
Log.write(
|
|
9
|
+
Log.write("║", " ", `${typeName}.${member.toString()} - collection is sealed`);
|
|
10
10
|
Object.setPrototypeOf(result, sealedType);
|
|
11
11
|
Object.freeze(result);
|
|
12
12
|
return result;
|
|
@@ -19,8 +19,8 @@ export class Sealant {
|
|
|
19
19
|
return collection;
|
|
20
20
|
}
|
|
21
21
|
static error(collection) {
|
|
22
|
-
return misuse(
|
|
22
|
+
return misuse("use toMutable to create mutable copy of sealed collection");
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
Sealant.SealedType = Symbol(
|
|
26
|
-
Sealant.CreateCopy = Symbol(
|
|
25
|
+
Sealant.SealedType = Symbol("rxSealedType");
|
|
26
|
+
Sealant.CreateCopy = Symbol("rxCreateCopy");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Sealant } from
|
|
1
|
+
import { Sealant } from "./Sealant.js";
|
|
2
2
|
export class SealedArray extends Array {
|
|
3
3
|
pop() { throw Sealant.error(this); }
|
|
4
4
|
push(...items) { throw Sealant.error(this); }
|
|
@@ -12,7 +12,7 @@ export class SealedArray extends Array {
|
|
|
12
12
|
return result;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
Object.defineProperty(Array.prototype,
|
|
15
|
+
Object.defineProperty(Array.prototype, "toMutable", {
|
|
16
16
|
configurable: false, enumerable: false,
|
|
17
17
|
value() {
|
|
18
18
|
return Sealant.toMutable(this);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Sealant } from
|
|
1
|
+
import { Sealant } from "./Sealant.js";
|
|
2
2
|
export class SealedMap extends Map {
|
|
3
3
|
clear() { throw Sealant.error(this); }
|
|
4
4
|
delete(key) { throw Sealant.error(this); }
|
|
5
5
|
set(key, value) { throw Sealant.error(this); }
|
|
6
6
|
[Sealant.CreateCopy]() { return new Map(this.entries()); }
|
|
7
7
|
}
|
|
8
|
-
Object.defineProperty(Map.prototype,
|
|
8
|
+
Object.defineProperty(Map.prototype, "toMutable", {
|
|
9
9
|
configurable: false, enumerable: false,
|
|
10
10
|
value() {
|
|
11
11
|
return Sealant.toMutable(this);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Sealant } from
|
|
1
|
+
import { Sealant } from "./Sealant.js";
|
|
2
2
|
export class SealedSet extends Set {
|
|
3
3
|
add(value) { throw Sealant.error(this); }
|
|
4
4
|
clear() { throw Sealant.error(this); }
|
|
5
5
|
delete(value) { throw Sealant.error(this); }
|
|
6
6
|
[Sealant.CreateCopy]() { return new Set(this.values()); }
|
|
7
7
|
}
|
|
8
|
-
Object.defineProperty(Set.prototype,
|
|
8
|
+
Object.defineProperty(Set.prototype, "toMutable", {
|
|
9
9
|
configurable: false, enumerable: false,
|
|
10
10
|
value() {
|
|
11
11
|
return Sealant.toMutable(this);
|
|
@@ -11,9 +11,9 @@ export class Utils {
|
|
|
11
11
|
static freezeSet(obj) {
|
|
12
12
|
if (obj instanceof Set) {
|
|
13
13
|
const pd = { configurable: false, enumerable: false, get: UNDEF, set: UNDEF };
|
|
14
|
-
Object.defineProperty(obj,
|
|
15
|
-
Object.defineProperty(obj,
|
|
16
|
-
Object.defineProperty(obj,
|
|
14
|
+
Object.defineProperty(obj, "add", pd);
|
|
15
|
+
Object.defineProperty(obj, "delete", pd);
|
|
16
|
+
Object.defineProperty(obj, "clear", pd);
|
|
17
17
|
Object.freeze(obj);
|
|
18
18
|
}
|
|
19
19
|
return obj;
|
|
@@ -21,9 +21,9 @@ export class Utils {
|
|
|
21
21
|
static freezeMap(obj) {
|
|
22
22
|
if (obj instanceof Map) {
|
|
23
23
|
const pd = { configurable: false, enumerable: false, get: UNDEF, set: UNDEF };
|
|
24
|
-
Object.defineProperty(obj,
|
|
25
|
-
Object.defineProperty(obj,
|
|
26
|
-
Object.defineProperty(obj,
|
|
24
|
+
Object.defineProperty(obj, "set", pd);
|
|
25
|
+
Object.defineProperty(obj, "delete", pd);
|
|
26
|
+
Object.defineProperty(obj, "clear", pd);
|
|
27
27
|
Object.freeze(obj);
|
|
28
28
|
}
|
|
29
29
|
return obj;
|
|
@@ -37,7 +37,7 @@ export class Utils {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
export function UNDEF(...args) {
|
|
40
|
-
throw new Error(
|
|
40
|
+
throw new Error("this method should never be called");
|
|
41
41
|
}
|
|
42
42
|
export function all(promises) {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -56,7 +56,7 @@ export function pause(timeout) {
|
|
|
56
56
|
export function emitLetters(n) {
|
|
57
57
|
if (n < 0)
|
|
58
58
|
throw new Error(`emitLetters: argument (${n}) should not be negative or zero`);
|
|
59
|
-
let result =
|
|
59
|
+
let result = "";
|
|
60
60
|
while (n >= 0) {
|
|
61
61
|
const r = n % 26;
|
|
62
62
|
n = Math.floor(n / 26) - 1;
|
|
@@ -70,14 +70,14 @@ export function objectHasMember(obj, member) {
|
|
|
70
70
|
export function getCallerInfo(prefix) {
|
|
71
71
|
const restore = Error.stackTraceLimit = 20;
|
|
72
72
|
const error = new Error();
|
|
73
|
-
const stack = error.stack ||
|
|
73
|
+
const stack = error.stack || "";
|
|
74
74
|
Error.stackTraceLimit = restore;
|
|
75
|
-
const lines = stack.split(
|
|
76
|
-
let i = lines.findIndex(x => x.indexOf(
|
|
75
|
+
const lines = stack.split("\n");
|
|
76
|
+
let i = lines.findIndex(x => x.indexOf(".acquire") >= 0);
|
|
77
77
|
i = i >= 0 ? i + 2 : 5;
|
|
78
78
|
let caller = extractFunctionAndLocation(lines[i]);
|
|
79
79
|
let location = caller;
|
|
80
|
-
if (caller.func.endsWith(
|
|
80
|
+
if (caller.func.endsWith(".update")) {
|
|
81
81
|
i = i - 1;
|
|
82
82
|
caller = extractFunctionAndLocation(lines[i]);
|
|
83
83
|
location = extractFunctionAndLocation(lines[i + 1]);
|
|
@@ -95,7 +95,7 @@ export function getCallerInfo(prefix) {
|
|
|
95
95
|
function extractFunctionAndLocation(s) {
|
|
96
96
|
const match = s.match(/(?:\s*at\s+)?(?:(\S+)\s\()?(?:.*?)([^\/\(\):]+)(?:(:|\d)*\)?)$/);
|
|
97
97
|
return {
|
|
98
|
-
func: (match === null || match === void 0 ? void 0 : match[1]) ||
|
|
99
|
-
file: (match === null || match === void 0 ? void 0 : match[2]) ||
|
|
98
|
+
func: (match === null || match === void 0 ? void 0 : match[1]) || "",
|
|
99
|
+
file: (match === null || match === void 0 ? void 0 : match[2]) || "",
|
|
100
100
|
};
|
|
101
101
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactronic",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.125",
|
|
4
4
|
"description": "Reactronic - Transactional Reactive State Management",
|
|
5
5
|
"publisher": "Nezaboodka Software",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"typescript": "5.2.2"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
|
-
"build": "eslint source
|
|
47
|
-
"fix": "eslint --fix source
|
|
48
|
-
"pack": "eslint source
|
|
46
|
+
"build": "eslint source/**.ts test/**.test.ts react/**.tsx && tsc",
|
|
47
|
+
"fix": "eslint --fix source/**.ts test/**.ts react/**.tsx",
|
|
48
|
+
"pack": "eslint source/**.ts test/**.test.ts react/**.tsx && tsc --sourceMap false --removeComments true",
|
|
49
49
|
"test": "ava",
|
|
50
50
|
"cover": "c8 ava && open build/coverage/index.html"
|
|
51
51
|
}
|