reactronic 0.22.104 → 0.22.108
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/api.d.ts +1 -1
- package/build/dist/source/impl/Data.d.ts +5 -7
- package/build/dist/source/impl/Data.js +1 -1
- package/build/dist/source/impl/Operation.d.ts +3 -3
- package/build/dist/source/impl/Operation.js +7 -7
- package/build/dist/source/impl/Snapshot.d.ts +2 -2
- package/build/dist/source/impl/Snapshot.js +14 -12
- package/build/dist/source/impl/Transaction.js +2 -2
- package/package.json +6 -6
|
@@ -2,7 +2,7 @@ export { all, pause } from './util/Utils';
|
|
|
2
2
|
export { SealedArray } from './util/SealedArray';
|
|
3
3
|
export { SealedMap } from './util/SealedMap';
|
|
4
4
|
export { SealedSet } from './util/SealedSet';
|
|
5
|
-
export { MemberOptions, Kind, Reentrance, TraceOptions, ProfilingOptions, TraceLevel } from './Options';
|
|
5
|
+
export { MemberOptions, SnapshotOptions, Kind, Reentrance, TraceOptions, ProfilingOptions, TraceLevel } from './Options';
|
|
6
6
|
export { Worker } from './Worker';
|
|
7
7
|
export { Controller } from './Controller';
|
|
8
8
|
export { Ref, ToggleRef, BoolOnly, GivenTypeOnly } from './Ref';
|
|
@@ -9,23 +9,21 @@ export declare class Observable {
|
|
|
9
9
|
value: any;
|
|
10
10
|
observers?: Set<Observer>;
|
|
11
11
|
get isOperation(): boolean;
|
|
12
|
-
get
|
|
12
|
+
get originSnapshotId(): number | undefined;
|
|
13
13
|
constructor(value: any);
|
|
14
14
|
}
|
|
15
|
-
export declare type StandaloneMode = boolean | 'isolated';
|
|
15
|
+
export declare type StandaloneMode = boolean | 'isolated' | 'disposal';
|
|
16
16
|
export interface Observer {
|
|
17
17
|
readonly order: number;
|
|
18
|
-
readonly observables: Map<Observable,
|
|
18
|
+
readonly observables: Map<Observable, ObservableInfo> | undefined;
|
|
19
19
|
readonly obsoleteSince: number;
|
|
20
20
|
hint(nop?: boolean): string;
|
|
21
21
|
markObsoleteDueTo(observable: Observable, memberName: MemberName, snapshot: AbstractSnapshot, holder: ObjectHolder, outer: string, since: number, reactions: Observer[]): void;
|
|
22
22
|
runIfNotUpToDate(now: boolean, nothrow: boolean): void;
|
|
23
23
|
}
|
|
24
24
|
export declare type MemberName = PropertyKey;
|
|
25
|
-
export interface
|
|
26
|
-
readonly
|
|
27
|
-
readonly snapshot: AbstractSnapshot;
|
|
28
|
-
readonly memberName: MemberName;
|
|
25
|
+
export interface ObservableInfo {
|
|
26
|
+
readonly memberHint: string;
|
|
29
27
|
readonly usageCount: number;
|
|
30
28
|
}
|
|
31
29
|
export declare class ObjectRevision {
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "Meta", { enumerable: true, get: function () { re
|
|
|
8
8
|
class Observable {
|
|
9
9
|
constructor(value) { this.value = value; }
|
|
10
10
|
get isOperation() { return false; }
|
|
11
|
-
get
|
|
11
|
+
get originSnapshotId() { return 0; }
|
|
12
12
|
}
|
|
13
13
|
exports.Observable = Observable;
|
|
14
14
|
class ObjectRevision {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { F } from '../util/Utils';
|
|
2
2
|
import { MemberOptions } from '../Options';
|
|
3
3
|
import { Controller } from '../Controller';
|
|
4
|
-
import { MemberName, ObjectHolder, Observable, Observer,
|
|
4
|
+
import { MemberName, ObjectHolder, Observable, Observer, ObservableInfo, AbstractSnapshot } from './Data';
|
|
5
5
|
import { Transaction } from './Transaction';
|
|
6
6
|
import { OptionsImpl } from './Hooks';
|
|
7
7
|
export declare class OperationController extends Controller<any> {
|
|
@@ -40,7 +40,7 @@ declare class Operation extends Observable implements Observer {
|
|
|
40
40
|
readonly transaction: Transaction;
|
|
41
41
|
readonly controller: OperationController;
|
|
42
42
|
readonly snapshot: AbstractSnapshot;
|
|
43
|
-
observables: Map<Observable,
|
|
43
|
+
observables: Map<Observable, ObservableInfo> | undefined;
|
|
44
44
|
options: OptionsImpl;
|
|
45
45
|
cause: string | undefined;
|
|
46
46
|
args: any[];
|
|
@@ -52,7 +52,7 @@ declare class Operation extends Observable implements Observer {
|
|
|
52
52
|
successor: Operation | undefined;
|
|
53
53
|
constructor(controller: OperationController, snapshot: AbstractSnapshot, prev: Operation | OptionsImpl);
|
|
54
54
|
get isOperation(): boolean;
|
|
55
|
-
get
|
|
55
|
+
get originSnapshotId(): number;
|
|
56
56
|
hint(): string;
|
|
57
57
|
get order(): number;
|
|
58
58
|
get ['#this'](): string;
|
|
@@ -216,7 +216,7 @@ class Operation extends Data_1.Observable {
|
|
|
216
216
|
this.successor = undefined;
|
|
217
217
|
}
|
|
218
218
|
get isOperation() { return true; }
|
|
219
|
-
get
|
|
219
|
+
get originSnapshotId() { return this.snapshot.id; }
|
|
220
220
|
hint() { return `${Snapshot_1.Dump.rev2(this.controller.ownHolder, this.snapshot, this.controller.memberName)}`; }
|
|
221
221
|
get order() { return this.options.order; }
|
|
222
222
|
get ['#this']() {
|
|
@@ -510,9 +510,9 @@ class Operation extends Data_1.Observable {
|
|
|
510
510
|
if (curr instanceof Operation) {
|
|
511
511
|
if (curr.snapshot === r.snapshot && curr.observables !== undefined) {
|
|
512
512
|
if (Hooks_1.Hooks.repetitiveUsageWarningThreshold < Number.MAX_SAFE_INTEGER) {
|
|
513
|
-
curr.observables.forEach((
|
|
514
|
-
if (
|
|
515
|
-
Dbg_1.Dbg.log('', '[!]', `${curr.hint()} uses ${
|
|
513
|
+
curr.observables.forEach((info, v) => {
|
|
514
|
+
if (info.usageCount > Hooks_1.Hooks.repetitiveUsageWarningThreshold)
|
|
515
|
+
Dbg_1.Dbg.log('', '[!]', `${curr.hint()} uses ${info.memberHint} ${info.usageCount} times (consider remembering it in a local variable)`, 0, ' *** WARNING ***');
|
|
516
516
|
});
|
|
517
517
|
}
|
|
518
518
|
if (unsubscribe)
|
|
@@ -548,11 +548,11 @@ class Operation extends Data_1.Observable {
|
|
|
548
548
|
}
|
|
549
549
|
unsubscribeFromAllObservables() {
|
|
550
550
|
var _a;
|
|
551
|
-
(_a = this.observables) === null || _a === void 0 ? void 0 : _a.forEach((
|
|
551
|
+
(_a = this.observables) === null || _a === void 0 ? void 0 : _a.forEach((info, value) => {
|
|
552
552
|
var _a;
|
|
553
553
|
value.observers.delete(this);
|
|
554
554
|
if (Dbg_1.Dbg.isOn && (Dbg_1.Dbg.trace.read || ((_a = this.options.trace) === null || _a === void 0 ? void 0 : _a.read)))
|
|
555
|
-
Dbg_1.Dbg.log(Dbg_1.Dbg.trace.transaction && !Snapshot_1.Snapshot.current().sealed ? '║' : ' ', '-', `${this.hint()} is unsubscribed from ${
|
|
555
|
+
Dbg_1.Dbg.log(Dbg_1.Dbg.trace.transaction && !Snapshot_1.Snapshot.current().sealed ? '║' : ' ', '-', `${this.hint()} is unsubscribed from ${info.memberHint}`);
|
|
556
556
|
});
|
|
557
557
|
this.observables = undefined;
|
|
558
558
|
}
|
|
@@ -568,7 +568,7 @@ class Operation extends Data_1.Observable {
|
|
|
568
568
|
if (this.observables !== undefined) {
|
|
569
569
|
if (!observable.observers)
|
|
570
570
|
observable.observers = new Set();
|
|
571
|
-
const info = {
|
|
571
|
+
const info = { memberHint: Snapshot_1.Dump.rev2(h, r.snapshot, m), usageCount: times };
|
|
572
572
|
observable.observers.add(this);
|
|
573
573
|
this.observables.set(observable, info);
|
|
574
574
|
if (Dbg_1.Dbg.isOn && (Dbg_1.Dbg.trace.read || ((_a = this.options.trace) === null || _a === void 0 ? void 0 : _a.read)))
|
|
@@ -39,7 +39,7 @@ export declare class Snapshot implements AbstractSnapshot {
|
|
|
39
39
|
acquire(outer: Snapshot): void;
|
|
40
40
|
bumpBy(timestamp: number): void;
|
|
41
41
|
rebase(): ObjectRevision[] | undefined;
|
|
42
|
-
private
|
|
42
|
+
private merge;
|
|
43
43
|
applyOrDiscard(error?: any): Array<Observer>;
|
|
44
44
|
static sealObjectRevision(h: ObjectHolder, r: ObjectRevision): void;
|
|
45
45
|
static sealObservable(observable: Observable | symbol, m: MemberName, typeName: string): void;
|
|
@@ -49,7 +49,7 @@ export declare class Snapshot implements AbstractSnapshot {
|
|
|
49
49
|
static _init(): void;
|
|
50
50
|
}
|
|
51
51
|
export declare class Dump {
|
|
52
|
-
static obj(h: ObjectHolder | undefined, m?: MemberName | undefined, stamp?: number,
|
|
52
|
+
static obj(h: ObjectHolder | undefined, m?: MemberName | undefined, stamp?: number, snapshotId?: number, originSnapshotId?: number, typeless?: boolean): string;
|
|
53
53
|
static rev2(h: ObjectHolder, s: AbstractSnapshot, m?: MemberName, value?: Observable): string;
|
|
54
54
|
static rev(r: ObjectRevision, m?: MemberName): string;
|
|
55
55
|
static conflicts(conflicts: ObjectRevision[]): string;
|
|
@@ -130,7 +130,7 @@ class Snapshot {
|
|
|
130
130
|
if (this.changeset.size > 0) {
|
|
131
131
|
this.changeset.forEach((r, h) => {
|
|
132
132
|
if (r.prev.revision !== h.head) {
|
|
133
|
-
const merged =
|
|
133
|
+
const merged = this.merge(h, r);
|
|
134
134
|
if (r.conflicts.size > 0) {
|
|
135
135
|
if (!conflicts)
|
|
136
136
|
conflicts = [];
|
|
@@ -154,19 +154,21 @@ class Snapshot {
|
|
|
154
154
|
}
|
|
155
155
|
return conflicts;
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
merge(h, ours) {
|
|
158
158
|
let counter = 0;
|
|
159
159
|
const head = h.head;
|
|
160
|
-
const
|
|
160
|
+
const headDisposed = head.changes.has(Data_1.Meta.Disposed);
|
|
161
161
|
const merged = Object.assign({}, head.data);
|
|
162
162
|
ours.changes.forEach((o, m) => {
|
|
163
163
|
counter++;
|
|
164
164
|
merged[m] = ours.data[m];
|
|
165
|
-
if (
|
|
166
|
-
if (
|
|
167
|
-
if (
|
|
168
|
-
Dbg_1.Dbg.
|
|
169
|
-
|
|
165
|
+
if (headDisposed || m === Data_1.Meta.Disposed) {
|
|
166
|
+
if (headDisposed !== (m === Data_1.Meta.Disposed)) {
|
|
167
|
+
if (headDisposed || this.options.standalone !== 'disposal') {
|
|
168
|
+
if (Dbg_1.Dbg.isOn && Dbg_1.Dbg.trace.change)
|
|
169
|
+
Dbg_1.Dbg.log('║╠', '', `${Dump.rev2(h, ours.snapshot, m)} <> ${Dump.rev2(h, head.snapshot, m)}`, 0, ' *** CONFLICT ***');
|
|
170
|
+
ours.conflicts.set(m, head);
|
|
171
|
+
}
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
else {
|
|
@@ -309,19 +311,19 @@ Snapshot.propagateAllChangesThroughSubscriptions = (snapshot) => { };
|
|
|
309
311
|
Snapshot.revokeAllSubscriptions = (snapshot) => { };
|
|
310
312
|
Snapshot.enqueueReactionsToRun = (reactions) => { };
|
|
311
313
|
class Dump {
|
|
312
|
-
static obj(h, m, stamp,
|
|
314
|
+
static obj(h, m, stamp, snapshotId, originSnapshotId, typeless) {
|
|
313
315
|
const member = m !== undefined ? `.${m.toString()}` : '';
|
|
314
316
|
return h === undefined
|
|
315
317
|
? `root${member}`
|
|
316
|
-
: stamp === undefined ? `${h.hint}${member} #${h.id}` : `${h.hint}${member} #${h.id}t${
|
|
318
|
+
: stamp === undefined ? `${h.hint}${member} #${h.id}` : `${h.hint}${member} #${h.id}t${snapshotId}v${stamp}${originSnapshotId !== undefined && originSnapshotId !== 0 ? `t${originSnapshotId}` : ''}`;
|
|
317
319
|
}
|
|
318
320
|
static rev2(h, s, m, value) {
|
|
319
|
-
return Dump.obj(h, m, s.timestamp, s.id, value === null || value === void 0 ? void 0 : value.
|
|
321
|
+
return Dump.obj(h, m, s.timestamp, s.id, value === null || value === void 0 ? void 0 : value.originSnapshotId);
|
|
320
322
|
}
|
|
321
323
|
static rev(r, m) {
|
|
322
324
|
const h = Data_1.Meta.get(r.data, Data_1.Meta.Holder);
|
|
323
325
|
const value = m !== undefined ? r.data[m] : undefined;
|
|
324
|
-
return Dump.obj(h, m, r.snapshot.timestamp, r.snapshot.id, value === null || value === void 0 ? void 0 : value.
|
|
326
|
+
return Dump.obj(h, m, r.snapshot.timestamp, r.snapshot.id, value === null || value === void 0 ? void 0 : value.originSnapshotId);
|
|
325
327
|
}
|
|
326
328
|
static conflicts(conflicts) {
|
|
327
329
|
return conflicts.map(ours => {
|
|
@@ -22,7 +22,7 @@ class Transaction {
|
|
|
22
22
|
static run(options, func, ...args) { return TransactionImpl.run(options, func, ...args); }
|
|
23
23
|
static standalone(func, ...args) { return TransactionImpl.standalone(func, ...args); }
|
|
24
24
|
static off(func, ...args) { return TransactionImpl.off(func, ...args); }
|
|
25
|
-
static isFrameOver(everyN = 1, timeLimit =
|
|
25
|
+
static isFrameOver(everyN = 1, timeLimit = 10) { return TransactionImpl.isFrameOver(everyN, timeLimit); }
|
|
26
26
|
static requestNextFrame(sleepTime = 0) { return TransactionImpl.requestNextFrame(sleepTime); }
|
|
27
27
|
static get isCanceled() { return TransactionImpl.current.isCanceled; }
|
|
28
28
|
}
|
|
@@ -143,7 +143,7 @@ class TransactionImpl extends Transaction {
|
|
|
143
143
|
TransactionImpl.curr = outer;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
static isFrameOver(everyN = 1, timeLimit =
|
|
146
|
+
static isFrameOver(everyN = 1, timeLimit = 10) {
|
|
147
147
|
TransactionImpl.frameOverCounter++;
|
|
148
148
|
let result = TransactionImpl.frameOverCounter % everyN === 0;
|
|
149
149
|
if (result) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactronic",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.108",
|
|
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,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/nezaboodka/reactronic/blob/master/README.md#readme",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "17.0.
|
|
33
|
-
"@types/react": "17.0.
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
35
|
-
"@typescript-eslint/parser": "5.
|
|
32
|
+
"@types/node": "17.0.7",
|
|
33
|
+
"@types/react": "17.0.38",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "5.9.0",
|
|
35
|
+
"@typescript-eslint/parser": "5.9.0",
|
|
36
36
|
"ava": "3.15.0",
|
|
37
|
-
"eslint": "8.
|
|
37
|
+
"eslint": "8.6.0",
|
|
38
38
|
"nyc": "15.1.0",
|
|
39
39
|
"react": "17.0.2",
|
|
40
40
|
"ts-node": "10.4.0",
|