reactronic 0.21.517 → 0.21.521
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 +1 -1
- package/build/dist/source/Ref.d.ts +3 -3
- package/build/dist/source/Ref.js +8 -8
- package/build/dist/source/Trace.d.ts +3 -3
- package/build/dist/source/Trace.js +3 -3
- package/build/dist/source/api.d.ts +1 -1
- package/build/dist/source/api.js +2 -2
- package/build/dist/source/impl/Transaction.d.ts +3 -0
- package/build/dist/source/impl/Transaction.js +22 -0
- package/build/dist/source/util/Utils.d.ts +1 -1
- package/build/dist/source/util/Utils.js +3 -3
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://circleci.com/gh/nezaboodka/reactronic)
|
|
7
7
|

|
|
8
8
|

|
|
9
|
-
[](https://gitlab.com/nezaboodka/nevod.
|
|
9
|
+
[](https://gitlab.com/nezaboodka/nevod.website/-/blob/master/README.md)
|
|
10
10
|
|
|
11
11
|
# **Reactronic** - Transactional Reactive State Management
|
|
12
12
|
|
|
@@ -27,8 +27,8 @@ export declare class Ref<T = any> {
|
|
|
27
27
|
static similarRefs(v1: Ref, v2: Ref): boolean;
|
|
28
28
|
}
|
|
29
29
|
export declare class ToggleRef<T = boolean> extends Ref<T> {
|
|
30
|
-
readonly
|
|
31
|
-
readonly
|
|
32
|
-
constructor(owner: any, name: string,
|
|
30
|
+
readonly valueOn: T;
|
|
31
|
+
readonly valueOff: T;
|
|
32
|
+
constructor(owner: any, name: string, valueOn: T, valueOff: T);
|
|
33
33
|
toggle(): void;
|
|
34
34
|
}
|
package/build/dist/source/Ref.js
CHANGED
|
@@ -49,22 +49,22 @@ class Ref {
|
|
|
49
49
|
}
|
|
50
50
|
exports.Ref = Ref;
|
|
51
51
|
class ToggleRef extends Ref {
|
|
52
|
-
constructor(owner, name,
|
|
52
|
+
constructor(owner, name, valueOn, valueOff) {
|
|
53
53
|
super(owner, name);
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
54
|
+
this.valueOn = valueOn;
|
|
55
|
+
this.valueOff = valueOff;
|
|
56
56
|
}
|
|
57
57
|
toggle() {
|
|
58
58
|
const o = this.owner;
|
|
59
59
|
const p = this.name;
|
|
60
60
|
Transaction_1.Transaction.runAs({ hint: `toggle ${o.constructor.name}.${p}` }, () => {
|
|
61
61
|
const v = o[p];
|
|
62
|
-
const
|
|
63
|
-
Ref.sameRefs(v, this.
|
|
64
|
-
if (!
|
|
65
|
-
o[p] = this.
|
|
62
|
+
const isOn = v === this.valueOn || (v instanceof Ref && this.valueOn instanceof Ref &&
|
|
63
|
+
Ref.sameRefs(v, this.valueOn));
|
|
64
|
+
if (!isOn)
|
|
65
|
+
o[p] = this.valueOn;
|
|
66
66
|
else
|
|
67
|
-
o[p] = this.
|
|
67
|
+
o[p] = this.valueOff;
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -24,10 +24,10 @@ export interface ProfilingOptions {
|
|
|
24
24
|
}
|
|
25
25
|
export declare const TraceLevel: {
|
|
26
26
|
Error: TraceOptions;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
Transactions: TraceOptions;
|
|
28
|
+
Operations: TraceOptions;
|
|
29
29
|
Debug: TraceOptions;
|
|
30
|
-
|
|
30
|
+
Silent: TraceOptions;
|
|
31
31
|
};
|
|
32
32
|
declare global {
|
|
33
33
|
interface Window {
|
|
@@ -20,7 +20,7 @@ exports.TraceLevel = {
|
|
|
20
20
|
margin1: 0,
|
|
21
21
|
margin2: 0,
|
|
22
22
|
},
|
|
23
|
-
|
|
23
|
+
Transactions: {
|
|
24
24
|
silent: false,
|
|
25
25
|
transaction: true,
|
|
26
26
|
operation: false,
|
|
@@ -38,7 +38,7 @@ exports.TraceLevel = {
|
|
|
38
38
|
margin1: 0,
|
|
39
39
|
margin2: 0,
|
|
40
40
|
},
|
|
41
|
-
|
|
41
|
+
Operations: {
|
|
42
42
|
silent: false,
|
|
43
43
|
transaction: true,
|
|
44
44
|
operation: true,
|
|
@@ -74,7 +74,7 @@ exports.TraceLevel = {
|
|
|
74
74
|
margin1: 0,
|
|
75
75
|
margin2: 0,
|
|
76
76
|
},
|
|
77
|
-
|
|
77
|
+
Silent: {
|
|
78
78
|
silent: true,
|
|
79
79
|
transaction: false,
|
|
80
80
|
operation: false,
|
package/build/dist/source/api.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.options = exports.cached = exports.reaction = exports.transaction = exports.unobservable = exports.sensitive = exports.standalone = exports.nonreactive = exports.Reactronic = exports.TransactionJournal = exports.Monitor = exports.Transaction = exports.Snapshot = exports.ObservableObject = exports.ToggleRef = exports.Ref = exports.Controller = exports.TraceLevel = exports.Reentrance = exports.Kind = exports.SealedSet = exports.SealedMap = exports.SealedArray = exports.
|
|
3
|
+
exports.options = exports.cached = exports.reaction = exports.transaction = exports.unobservable = exports.sensitive = exports.standalone = exports.nonreactive = exports.Reactronic = exports.TransactionJournal = exports.Monitor = exports.Transaction = exports.Snapshot = exports.ObservableObject = exports.ToggleRef = exports.Ref = exports.Controller = exports.TraceLevel = exports.Reentrance = exports.Kind = exports.SealedSet = exports.SealedMap = exports.SealedArray = exports.pause = exports.all = void 0;
|
|
4
4
|
var Utils_1 = require("./util/Utils");
|
|
5
5
|
Object.defineProperty(exports, "all", { enumerable: true, get: function () { return Utils_1.all; } });
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "pause", { enumerable: true, get: function () { return Utils_1.pause; } });
|
|
7
7
|
var SealedArray_1 = require("./util/SealedArray");
|
|
8
8
|
Object.defineProperty(exports, "SealedArray", { enumerable: true, get: function () { return SealedArray_1.SealedArray; } });
|
|
9
9
|
var SealedMap_1 = require("./util/SealedMap");
|
|
@@ -24,4 +24,7 @@ export declare abstract class Transaction implements Worker {
|
|
|
24
24
|
static run<T>(func: F<T>, ...args: any[]): T;
|
|
25
25
|
static runAs<T>(options: SnapshotOptions | null, func: F<T>, ...args: any[]): T;
|
|
26
26
|
static standalone<T>(func: F<T>, ...args: any[]): T;
|
|
27
|
+
static isTimeOver(everyN?: number): boolean;
|
|
28
|
+
static requestMoreTime(): Promise<void>;
|
|
29
|
+
static get isCanceled(): boolean;
|
|
27
30
|
}
|
|
@@ -22,6 +22,9 @@ class Transaction {
|
|
|
22
22
|
static run(func, ...args) { return TransactionImpl.run(func, ...args); }
|
|
23
23
|
static runAs(options, func, ...args) { return TransactionImpl.runAs(options, func, ...args); }
|
|
24
24
|
static standalone(func, ...args) { return TransactionImpl.standalone(func, ...args); }
|
|
25
|
+
static isTimeOver(everyN = 1) { return TransactionImpl.isTimeOver(everyN); }
|
|
26
|
+
static requestMoreTime() { return TransactionImpl.requestMoreTime(); }
|
|
27
|
+
static get isCanceled() { return TransactionImpl.current.isCanceled; }
|
|
25
28
|
}
|
|
26
29
|
exports.Transaction = Transaction;
|
|
27
30
|
class TransactionImpl extends Transaction {
|
|
@@ -139,6 +142,18 @@ class TransactionImpl extends Transaction {
|
|
|
139
142
|
TransactionImpl.curr = outer;
|
|
140
143
|
}
|
|
141
144
|
}
|
|
145
|
+
static isTimeOver(everyN = 1) {
|
|
146
|
+
TransactionImpl.checkCount++;
|
|
147
|
+
let result = TransactionImpl.checkCount % everyN !== 0;
|
|
148
|
+
if (result) {
|
|
149
|
+
const ms = performance.now() - TransactionImpl.startTime;
|
|
150
|
+
result = ms > TransactionImpl.durationLimit;
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
static requestMoreTime(sleepTime = 0) {
|
|
155
|
+
return (0, Utils_1.pause)(sleepTime);
|
|
156
|
+
}
|
|
142
157
|
static acquire(options) {
|
|
143
158
|
return (options === null || options === void 0 ? void 0 : options.standalone) || TransactionImpl.curr.isFinished
|
|
144
159
|
? new TransactionImpl(options)
|
|
@@ -187,6 +202,10 @@ class TransactionImpl extends Transaction {
|
|
|
187
202
|
let result;
|
|
188
203
|
const outer = TransactionImpl.curr;
|
|
189
204
|
try {
|
|
205
|
+
if (outer === TransactionImpl.none) {
|
|
206
|
+
TransactionImpl.startTime = performance.now();
|
|
207
|
+
TransactionImpl.checkCount = 0;
|
|
208
|
+
}
|
|
190
209
|
TransactionImpl.curr = this;
|
|
191
210
|
this.pending++;
|
|
192
211
|
this.snapshot.acquire(outer.snapshot);
|
|
@@ -287,4 +306,7 @@ class TransactionImpl extends Transaction {
|
|
|
287
306
|
TransactionImpl.none = new TransactionImpl({ hint: '<none>' });
|
|
288
307
|
TransactionImpl.curr = TransactionImpl.none;
|
|
289
308
|
TransactionImpl.inspection = false;
|
|
309
|
+
TransactionImpl.startTime = 0;
|
|
310
|
+
TransactionImpl.durationLimit = 14;
|
|
311
|
+
TransactionImpl.checkCount = 0;
|
|
290
312
|
TransactionImpl._init();
|
|
@@ -6,4 +6,4 @@ export declare class Utils {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function UNDEF(...args: any[]): never;
|
|
8
8
|
export declare function all(promises: Array<Promise<any>>): Promise<any[]>;
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function pause<T>(timeout: number): Promise<T>;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.pause = exports.all = exports.UNDEF = exports.Utils = void 0;
|
|
13
13
|
class Utils {
|
|
14
14
|
static freezeSet(obj) {
|
|
15
15
|
if (obj instanceof Set) {
|
|
@@ -52,9 +52,9 @@ function all(promises) {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
exports.all = all;
|
|
55
|
-
function
|
|
55
|
+
function pause(timeout) {
|
|
56
56
|
return new Promise(function (resolve) {
|
|
57
57
|
setTimeout(resolve.bind(null, () => resolve), timeout);
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
exports.
|
|
60
|
+
exports.pause = pause;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactronic",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.521",
|
|
4
4
|
"description": "Reactronic - Transactional Reactive State Management",
|
|
5
5
|
"main": "build/dist/source/api.js",
|
|
6
6
|
"types": "build/dist/source/api.d.ts",
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/nezaboodka/reactronic/blob/master/README.md#readme",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "16.
|
|
33
|
-
"@types/react": "17.0.
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "
|
|
35
|
-
"@typescript-eslint/parser": "
|
|
32
|
+
"@types/node": "16.11.11",
|
|
33
|
+
"@types/react": "17.0.37",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "5.5.0",
|
|
35
|
+
"@typescript-eslint/parser": "5.5.0",
|
|
36
36
|
"ava": "3.15.0",
|
|
37
|
-
"eslint": "
|
|
37
|
+
"eslint": "8.3.0",
|
|
38
38
|
"nyc": "15.1.0",
|
|
39
39
|
"react": "17.0.2",
|
|
40
|
-
"ts-node": "10.
|
|
41
|
-
"tsconfig-paths": "3.
|
|
40
|
+
"ts-node": "10.4.0",
|
|
41
|
+
"tsconfig-paths": "3.12.0",
|
|
42
42
|
"typescript": "4.4.3"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|