reactronic 0.23.110 → 0.23.112
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 +3 -3
- package/build/dist/source/Options.d.ts +11 -0
- package/build/dist/source/{Buffer.d.ts → Pipe.d.ts} +2 -2
- package/build/dist/source/{Buffer.js → Pipe.js} +1 -1
- package/build/dist/source/Reaction.d.ts +2 -13
- package/build/dist/source/Reaction.js +3 -1
- package/build/dist/source/Ref.d.ts +1 -1
- package/build/dist/source/Ref.js +3 -3
- package/build/dist/source/Rx.d.ts +3 -4
- package/build/dist/source/Rx.js +2 -2
- package/build/dist/source/api.d.ts +2 -3
- package/build/dist/source/api.js +1 -1
- package/build/dist/source/impl/Changeset.d.ts +4 -4
- package/build/dist/source/impl/Changeset.js +6 -6
- package/build/dist/source/impl/Data.d.ts +3 -3
- package/build/dist/source/impl/Data.js +1 -1
- package/build/dist/source/impl/Journal.js +2 -2
- package/build/dist/source/impl/Mvcc.js +6 -6
- package/build/dist/source/impl/Reaction.d.ts +6 -7
- package/build/dist/source/impl/Reaction.js +5 -5
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -303,7 +303,7 @@ function reactive(proto, prop, pd) // method only
|
|
|
303
303
|
function cached(proto, prop, pd) // method only
|
|
304
304
|
function options(value: Partial<MemberOptions>): F<any>
|
|
305
305
|
|
|
306
|
-
function
|
|
306
|
+
function unobs<T>(func: F<T>, ...args: any[]): T
|
|
307
307
|
function sensitive<T>(sensitivity: Sensitivity, func: F<T>, ...args: any[]): T
|
|
308
308
|
|
|
309
309
|
// SnapshotOptions, MemberOptions, Kind, Reentrance, Monitor, LoggingOptions, ProfilingOptions
|
|
@@ -462,7 +462,7 @@ class Reactronic {
|
|
|
462
462
|
// function cached(proto, prop, pd) // method only
|
|
463
463
|
// function options(value: Partial<MemberOptions>): F<any>
|
|
464
464
|
|
|
465
|
-
// function
|
|
465
|
+
// function unobs<T>(func: F<T>, ...args: any[]): T
|
|
466
466
|
// function sensitive<T>(sensitivity: Sensitivity, func: F<T>, ...args: any[]): T
|
|
467
467
|
|
|
468
468
|
// SnapshotOptions, MemberOptions, Kind, Reentrance, Monitor, LoggingOptions, ProfilingOptions
|
|
@@ -561,7 +561,7 @@ class Reactronic {
|
|
|
561
561
|
охраняемый типом код: Целое
|
|
562
562
|
охраняемая типом подсказка: Текст
|
|
563
563
|
|
|
564
|
-
|
|
564
|
+
|
|
565
565
|
исполнить<Т>(ф: Ф<Т>, арг: Элементы<Нечто>): Т
|
|
566
566
|
wrap<T>(func: F<T>): F<T>
|
|
567
567
|
зафиксировать()
|
|
@@ -37,3 +37,14 @@ export declare enum Reentrance {
|
|
|
37
37
|
OverwritePrevious = -3,
|
|
38
38
|
RunSideBySide = -4
|
|
39
39
|
}
|
|
40
|
+
export interface AbstractReaction<T> {
|
|
41
|
+
readonly options: MemberOptions;
|
|
42
|
+
readonly args: ReadonlyArray<any>;
|
|
43
|
+
readonly result: T;
|
|
44
|
+
readonly error: any;
|
|
45
|
+
readonly stamp: number;
|
|
46
|
+
readonly isUpToDate: boolean;
|
|
47
|
+
configure(options: Partial<MemberOptions>): MemberOptions;
|
|
48
|
+
markObsolete(): void;
|
|
49
|
+
pullLastResult(args?: any[]): T | undefined;
|
|
50
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ObservableObject } from './impl/Mvcc.js';
|
|
2
|
-
export declare abstract class
|
|
2
|
+
export declare abstract class Pipe<T> extends ObservableObject {
|
|
3
3
|
abstract readonly capacity: number;
|
|
4
4
|
abstract readonly count: number;
|
|
5
5
|
abstract put(...items: T[]): void;
|
|
6
6
|
abstract take(count: number): T[];
|
|
7
|
-
static create<T>(hint?: string, capacity?: number):
|
|
7
|
+
static create<T>(hint?: string, capacity?: number): Pipe<T>;
|
|
8
8
|
}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { F } from './util/Utils.js';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
readonly options: MemberOptions;
|
|
5
|
-
readonly args: ReadonlyArray<any>;
|
|
6
|
-
readonly result: T;
|
|
7
|
-
readonly error: any;
|
|
8
|
-
readonly stamp: number;
|
|
9
|
-
readonly isUpToDate: boolean;
|
|
10
|
-
configure(options: Partial<MemberOptions>): MemberOptions;
|
|
11
|
-
markObsolete(): void;
|
|
12
|
-
pullLastResult(args?: any[]): T | undefined;
|
|
13
|
-
}
|
|
14
|
-
export declare class Reaction<T> {
|
|
2
|
+
import { ObservableObject } from './impl/Mvcc.js';
|
|
3
|
+
export declare class Reaction<T> extends ObservableObject {
|
|
15
4
|
protected action: F<T>;
|
|
16
5
|
constructor(action: F<T>);
|
|
17
6
|
protected launch(): T;
|
|
@@ -7,9 +7,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
+
import { ObservableObject } from './impl/Mvcc.js';
|
|
10
11
|
import { reactive } from './Rx.js';
|
|
11
|
-
export class Reaction {
|
|
12
|
+
export class Reaction extends ObservableObject {
|
|
12
13
|
constructor(action) {
|
|
14
|
+
super();
|
|
13
15
|
this.action = action;
|
|
14
16
|
}
|
|
15
17
|
launch() {
|
|
@@ -27,7 +27,7 @@ export declare class Ref<T = any> {
|
|
|
27
27
|
constructor(owner: any, name: string, index?: number);
|
|
28
28
|
get variable(): T;
|
|
29
29
|
set variable(value: T);
|
|
30
|
-
|
|
30
|
+
unobs(): T;
|
|
31
31
|
observe(): T;
|
|
32
32
|
unobserve(): T;
|
|
33
33
|
static sameRefs(v1: Ref, v2: Ref): boolean;
|
package/build/dist/source/Ref.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transaction } from './impl/Transaction.js';
|
|
2
|
-
import {
|
|
2
|
+
import { unobs } from './Rx.js';
|
|
3
3
|
export function refs(owner) {
|
|
4
4
|
return new Proxy(owner, RefGettingProxy);
|
|
5
5
|
}
|
|
@@ -28,8 +28,8 @@ export class Ref {
|
|
|
28
28
|
else
|
|
29
29
|
this.owner[this.name][this.index] = value;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
return
|
|
31
|
+
unobs() {
|
|
32
|
+
return unobs(() => this.variable);
|
|
33
33
|
}
|
|
34
34
|
observe() {
|
|
35
35
|
return this.variable;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { F } from './util/Utils.js';
|
|
2
|
-
import { AbstractReaction } from './
|
|
3
|
-
import { MemberOptions, LoggingOptions, ProfilingOptions } from './Options.js';
|
|
2
|
+
import { AbstractReaction, MemberOptions, LoggingOptions, ProfilingOptions } from './Options.js';
|
|
4
3
|
export declare class Rx {
|
|
5
4
|
static why(brief?: boolean): string;
|
|
6
5
|
static getReaction<T>(method: F<T>): AbstractReaction<T>;
|
|
@@ -19,10 +18,10 @@ export declare class Rx {
|
|
|
19
18
|
static setProfilingMode(isOn: boolean, options?: Partial<ProfilingOptions>): void;
|
|
20
19
|
}
|
|
21
20
|
export declare function transaction<T>(action: F<T>, ...args: any[]): T;
|
|
22
|
-
export declare function
|
|
21
|
+
export declare function unobs<T>(func: F<T>, ...args: any[]): T;
|
|
23
22
|
export declare function sensitive<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
24
23
|
export declare function raw(proto: object, prop: PropertyKey): any;
|
|
25
|
-
export declare function
|
|
24
|
+
export declare function obs(proto: object, prop: PropertyKey): any;
|
|
26
25
|
export declare function transactional(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
27
26
|
export declare function reactive(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
28
27
|
export declare function cached(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
package/build/dist/source/Rx.js
CHANGED
|
@@ -25,7 +25,7 @@ export class Rx {
|
|
|
25
25
|
export function transaction(action, ...args) {
|
|
26
26
|
return Transaction.run(null, action, ...args);
|
|
27
27
|
}
|
|
28
|
-
export function
|
|
28
|
+
export function unobs(func, ...args) {
|
|
29
29
|
return ReactionImpl.proceedWithinGivenLaunch(undefined, func, ...args);
|
|
30
30
|
}
|
|
31
31
|
export function sensitive(sensitivity, func, ...args) {
|
|
@@ -34,7 +34,7 @@ export function sensitive(sensitivity, func, ...args) {
|
|
|
34
34
|
export function raw(proto, prop) {
|
|
35
35
|
return Mvcc.decorateData(false, proto, prop);
|
|
36
36
|
}
|
|
37
|
-
export function
|
|
37
|
+
export function obs(proto, prop) {
|
|
38
38
|
return Mvcc.decorateData(true, proto, prop);
|
|
39
39
|
}
|
|
40
40
|
export function transactional(proto, prop, pd) {
|
|
@@ -5,9 +5,8 @@ export { SealedArray } from './util/SealedArray.js';
|
|
|
5
5
|
export { SealedMap } from './util/SealedMap.js';
|
|
6
6
|
export { SealedSet } from './util/SealedSet.js';
|
|
7
7
|
export { Kind, Reentrance, LoggingLevel } from './Options.js';
|
|
8
|
-
export type { MemberOptions, SnapshotOptions, LoggingOptions, ProfilingOptions } from './Options.js';
|
|
8
|
+
export type { AbstractReaction, MemberOptions, SnapshotOptions, LoggingOptions, ProfilingOptions } from './Options.js';
|
|
9
9
|
export type { Worker } from './Worker.js';
|
|
10
|
-
export type { AbstractReaction } from './Reaction.js';
|
|
11
10
|
export { Ref, ToggleRef, refs, toggleRefs, customToggleRefs } from './Ref.js';
|
|
12
11
|
export type { BoolOnly, GivenTypeOnly } from './Ref.js';
|
|
13
12
|
export { TransactionalObject, ObservableObject } from './impl/Mvcc.js';
|
|
@@ -17,5 +16,5 @@ export { Changeset } from './impl/Changeset.js';
|
|
|
17
16
|
export { Transaction } from './impl/Transaction.js';
|
|
18
17
|
export { Monitor } from './impl/Monitor.js';
|
|
19
18
|
export { Journal } from './impl/Journal.js';
|
|
20
|
-
export { Rx, raw,
|
|
19
|
+
export { Rx, raw, obs, transactional, reactive, cached, transaction, unobs, sensitive, options } from './Rx.js';
|
|
21
20
|
export { Clock } from './Clock.js';
|
package/build/dist/source/api.js
CHANGED
|
@@ -12,5 +12,5 @@ export { Changeset } from './impl/Changeset.js';
|
|
|
12
12
|
export { Transaction } from './impl/Transaction.js';
|
|
13
13
|
export { Monitor } from './impl/Monitor.js';
|
|
14
14
|
export { Journal } from './impl/Journal.js';
|
|
15
|
-
export { Rx, raw,
|
|
15
|
+
export { Rx, raw, obs, transactional, reactive, cached, transaction, unobs, sensitive, options } from './Rx.js';
|
|
16
16
|
export { Clock } from './Clock.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Kind, SnapshotOptions } from '../Options.js';
|
|
2
|
-
import { AbstractChangeset, ObjectSnapshot, MemberName, ObjectHandle,
|
|
2
|
+
import { AbstractChangeset, ObjectSnapshot, MemberName, ObjectHandle, ValueSnapshot, Observer } from './Data.js';
|
|
3
3
|
export declare const MAX_REVISION: number;
|
|
4
4
|
export declare const UNDEFINED_REVISION: number;
|
|
5
5
|
export declare class Changeset implements AbstractChangeset {
|
|
@@ -23,7 +23,7 @@ export declare class Changeset implements AbstractChangeset {
|
|
|
23
23
|
constructor(options: SnapshotOptions | null);
|
|
24
24
|
static current: () => Changeset;
|
|
25
25
|
static edit: () => Changeset;
|
|
26
|
-
static markUsed: (observable:
|
|
26
|
+
static markUsed: (observable: ValueSnapshot, os: ObjectSnapshot, m: MemberName, h: ObjectHandle, kind: Kind, weak: boolean) => void;
|
|
27
27
|
static markEdited: (oldValue: any, newValue: any, edited: boolean, os: ObjectSnapshot, m: MemberName, h: ObjectHandle) => void;
|
|
28
28
|
static isConflicting: (oldValue: any, newValue: any) => boolean;
|
|
29
29
|
static propagateAllChangesThroughSubscriptions: (changeset: Changeset) => void;
|
|
@@ -42,7 +42,7 @@ export declare class Changeset implements AbstractChangeset {
|
|
|
42
42
|
private merge;
|
|
43
43
|
applyOrDiscard(error?: any): Array<Observer>;
|
|
44
44
|
static sealObjectSnapshot(h: ObjectHandle, os: ObjectSnapshot): void;
|
|
45
|
-
static
|
|
45
|
+
static sealValueSnapshot(o: ValueSnapshot | symbol, m: MemberName, typeName: string): void;
|
|
46
46
|
static freezeObjectSnapshot(os: ObjectSnapshot): ObjectSnapshot;
|
|
47
47
|
triggerGarbageCollection(): void;
|
|
48
48
|
private unlinkHistory;
|
|
@@ -51,7 +51,7 @@ export declare class Changeset implements AbstractChangeset {
|
|
|
51
51
|
export declare class Dump {
|
|
52
52
|
static valueHint: (value: any) => string;
|
|
53
53
|
static obj(h: ObjectHandle | undefined, m?: MemberName | undefined, stamp?: number, snapshotId?: number, originSnapshotId?: number, value?: any): string;
|
|
54
|
-
static snapshot2(h: ObjectHandle, s: AbstractChangeset, m?: MemberName, o?:
|
|
54
|
+
static snapshot2(h: ObjectHandle, s: AbstractChangeset, m?: MemberName, o?: ValueSnapshot): string;
|
|
55
55
|
static snapshot(os: ObjectSnapshot, m?: MemberName): string;
|
|
56
56
|
static conflicts(conflicts: ObjectSnapshot[]): string;
|
|
57
57
|
static conflictingMemberHint(m: MemberName, ours: ObjectSnapshot, theirs: ObjectSnapshot): string;
|
|
@@ -4,7 +4,7 @@ import { Sealant } from '../util/Sealant.js';
|
|
|
4
4
|
import { SealedArray } from '../util/SealedArray.js';
|
|
5
5
|
import { SealedMap } from '../util/SealedMap.js';
|
|
6
6
|
import { SealedSet } from '../util/SealedSet.js';
|
|
7
|
-
import { ObjectSnapshot, ObjectHandle,
|
|
7
|
+
import { ObjectSnapshot, ObjectHandle, ValueSnapshot, Meta } from './Data.js';
|
|
8
8
|
export const MAX_REVISION = Number.MAX_SAFE_INTEGER;
|
|
9
9
|
export const UNDEFINED_REVISION = MAX_REVISION - 1;
|
|
10
10
|
Object.defineProperty(ObjectHandle.prototype, '#this#', {
|
|
@@ -14,7 +14,7 @@ Object.defineProperty(ObjectHandle.prototype, '#this#', {
|
|
|
14
14
|
const data = Changeset.current().getObjectSnapshot(this, '#this#').data;
|
|
15
15
|
for (const m in data) {
|
|
16
16
|
const v = data[m];
|
|
17
|
-
if (v instanceof
|
|
17
|
+
if (v instanceof ValueSnapshot)
|
|
18
18
|
result[m] = v.content;
|
|
19
19
|
else if (v === Meta.Raw)
|
|
20
20
|
result[m] = this.data[m];
|
|
@@ -67,7 +67,7 @@ export class Changeset {
|
|
|
67
67
|
const revision = m === Meta.Handle ? 1 : os.revision + 1;
|
|
68
68
|
const data = Object.assign({}, m === Meta.Handle ? value : os.data);
|
|
69
69
|
Meta.set(data, Meta.Handle, h);
|
|
70
|
-
Meta.set(data, Meta.Revision, new
|
|
70
|
+
Meta.set(data, Meta.Revision, new ValueSnapshot(revision));
|
|
71
71
|
os = new ObjectSnapshot(this, os, data);
|
|
72
72
|
this.items.set(h, os);
|
|
73
73
|
h.editing = os;
|
|
@@ -218,15 +218,15 @@ export class Changeset {
|
|
|
218
218
|
}
|
|
219
219
|
static sealObjectSnapshot(h, os) {
|
|
220
220
|
if (!os.disposed)
|
|
221
|
-
os.changes.forEach((o, m) => Changeset.
|
|
221
|
+
os.changes.forEach((o, m) => Changeset.sealValueSnapshot(os.data[m], m, h.proxy.constructor.name));
|
|
222
222
|
else
|
|
223
223
|
for (const m in os.former.snapshot.data)
|
|
224
224
|
os.data[m] = Meta.Undefined;
|
|
225
225
|
if (Log.isOn)
|
|
226
226
|
Changeset.freezeObjectSnapshot(os);
|
|
227
227
|
}
|
|
228
|
-
static
|
|
229
|
-
if (o instanceof
|
|
228
|
+
static sealValueSnapshot(o, m, typeName) {
|
|
229
|
+
if (o instanceof ValueSnapshot) {
|
|
230
230
|
const value = o.content;
|
|
231
231
|
if (value !== undefined && value !== null) {
|
|
232
232
|
const sealedType = Object.getPrototypeOf(value)[Sealant.SealedType];
|
|
@@ -5,7 +5,7 @@ export interface AbstractChangeset {
|
|
|
5
5
|
readonly timestamp: number;
|
|
6
6
|
readonly sealed: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class ValueSnapshot<T = any> {
|
|
9
9
|
content: T;
|
|
10
10
|
observers?: Set<Observer>;
|
|
11
11
|
get isOperation(): boolean;
|
|
@@ -15,10 +15,10 @@ export declare class MvccValue<T = any> {
|
|
|
15
15
|
export type SeparationMode = boolean | 'isolated' | 'disposal';
|
|
16
16
|
export interface Observer {
|
|
17
17
|
readonly order: number;
|
|
18
|
-
readonly observables: Map<
|
|
18
|
+
readonly observables: Map<ValueSnapshot, Subscription> | undefined;
|
|
19
19
|
readonly obsoleteSince: number;
|
|
20
20
|
hint(nop?: boolean): string;
|
|
21
|
-
markObsoleteDueTo(observable:
|
|
21
|
+
markObsoleteDueTo(observable: ValueSnapshot, m: MemberName, changeset: AbstractChangeset, h: ObjectHandle, outer: string, since: number, reactive: Array<Observer>): void;
|
|
22
22
|
relaunchIfNotUpToDate(now: boolean, nothrow: boolean): void;
|
|
23
23
|
}
|
|
24
24
|
export type MemberName = PropertyKey;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Log } from '../util/Dbg.js';
|
|
2
2
|
import { Meta } from './Meta.js';
|
|
3
3
|
export { Meta } from './Meta.js';
|
|
4
|
-
export class
|
|
4
|
+
export class ValueSnapshot {
|
|
5
5
|
get isOperation() { return false; }
|
|
6
6
|
get originSnapshotId() { return 0; }
|
|
7
7
|
constructor(content) { this.content = content; }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ObservableObject } from './Mvcc.js';
|
|
2
|
-
import { Meta,
|
|
2
|
+
import { Meta, ValueSnapshot } from './Data.js';
|
|
3
3
|
import { Changeset, EMPTY_SNAPSHOT } from './Changeset.js';
|
|
4
4
|
import { Transaction } from './Transaction.js';
|
|
5
5
|
import { Sealant } from '../util/Sealant.js';
|
|
@@ -99,7 +99,7 @@ export class JournalImpl extends Journal {
|
|
|
99
99
|
const value = undoing ? vp.formerValue : vp.freshValue;
|
|
100
100
|
const os = ctx.getEditableObjectSnapshot(h, m, value);
|
|
101
101
|
if (os.changeset === ctx) {
|
|
102
|
-
os.data[m] = new
|
|
102
|
+
os.data[m] = new ValueSnapshot(value);
|
|
103
103
|
const existing = os.former.snapshot.data[m];
|
|
104
104
|
Changeset.markEdited(existing, value, existing !== value, os, m, h);
|
|
105
105
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UNDEF } from '../util/Utils.js';
|
|
2
2
|
import { Log, misuse } from '../util/Dbg.js';
|
|
3
3
|
import { Kind, Reentrance } from '../Options.js';
|
|
4
|
-
import { ObjectSnapshot, ObjectHandle,
|
|
4
|
+
import { ObjectSnapshot, ObjectHandle, ValueSnapshot, Meta } from './Data.js';
|
|
5
5
|
import { Changeset, Dump, EMPTY_SNAPSHOT } from './Changeset.js';
|
|
6
6
|
export class MvccObject {
|
|
7
7
|
constructor(observable) {
|
|
@@ -72,7 +72,7 @@ export class Mvcc {
|
|
|
72
72
|
const cs = Changeset.current();
|
|
73
73
|
const os = cs.getObjectSnapshot(h, m);
|
|
74
74
|
result = os.data[m];
|
|
75
|
-
if (result instanceof
|
|
75
|
+
if (result instanceof ValueSnapshot && !result.isOperation) {
|
|
76
76
|
if (this.isObservable)
|
|
77
77
|
Changeset.markUsed(result, os, m, h, Kind.Plain, false);
|
|
78
78
|
result = result.content;
|
|
@@ -92,7 +92,7 @@ export class Mvcc {
|
|
|
92
92
|
if (curr === undefined || curr.content !== value || Mvcc.sensitivity) {
|
|
93
93
|
const existing = curr === null || curr === void 0 ? void 0 : curr.content;
|
|
94
94
|
if (os.former.snapshot.data[m] === curr) {
|
|
95
|
-
curr = os.data[m] = new
|
|
95
|
+
curr = os.data[m] = new ValueSnapshot(value);
|
|
96
96
|
Changeset.markEdited(existing, value, true, os, m, h);
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
@@ -130,14 +130,14 @@ export class Mvcc {
|
|
|
130
130
|
const result = [];
|
|
131
131
|
for (const m of Object.getOwnPropertyNames(os.data)) {
|
|
132
132
|
const value = os.data[m];
|
|
133
|
-
if (!(value instanceof
|
|
133
|
+
if (!(value instanceof ValueSnapshot) || !value.isOperation)
|
|
134
134
|
result.push(m);
|
|
135
135
|
}
|
|
136
136
|
return result;
|
|
137
137
|
}
|
|
138
138
|
static decorateData(isObservable, proto, member) {
|
|
139
139
|
if (isObservable) {
|
|
140
|
-
Meta.acquire(proto, Meta.Initial)[member] = new
|
|
140
|
+
Meta.acquire(proto, Meta.Initial)[member] = new ValueSnapshot(undefined);
|
|
141
141
|
const get = function () {
|
|
142
142
|
const h = Mvcc.acquireHandle(this);
|
|
143
143
|
return Mvcc.observable.get(h, member, this);
|
|
@@ -196,7 +196,7 @@ export class Mvcc {
|
|
|
196
196
|
h = new ObjectHandle(obj, obj, Mvcc.observable, os, obj.constructor.name);
|
|
197
197
|
Meta.set(os.data, Meta.Handle, h);
|
|
198
198
|
Meta.set(obj, Meta.Handle, h);
|
|
199
|
-
Meta.set(os.data, Meta.Revision, new
|
|
199
|
+
Meta.set(os.data, Meta.Revision, new ValueSnapshot(1));
|
|
200
200
|
}
|
|
201
201
|
return h;
|
|
202
202
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { F } from '../util/Utils.js';
|
|
2
|
-
import { MemberOptions } from '../Options.js';
|
|
3
|
-
import {
|
|
4
|
-
import { MemberName, ObjectHandle, MvccValue, Observer, Subscription, AbstractChangeset } from './Data.js';
|
|
2
|
+
import { AbstractReaction, MemberOptions } from '../Options.js';
|
|
3
|
+
import { MemberName, ObjectHandle, ValueSnapshot, Observer, Subscription, AbstractChangeset } from './Data.js';
|
|
5
4
|
import { Transaction } from './Transaction.js';
|
|
6
5
|
import { OptionsImpl } from './Mvcc.js';
|
|
7
6
|
export declare class ReactionImpl implements AbstractReaction<any> {
|
|
@@ -9,7 +8,7 @@ export declare class ReactionImpl implements AbstractReaction<any> {
|
|
|
9
8
|
readonly memberName: MemberName;
|
|
10
9
|
configure(options: Partial<MemberOptions>): MemberOptions;
|
|
11
10
|
get options(): MemberOptions;
|
|
12
|
-
get
|
|
11
|
+
get unobs(): any;
|
|
13
12
|
get args(): ReadonlyArray<any>;
|
|
14
13
|
get result(): any;
|
|
15
14
|
get error(): boolean;
|
|
@@ -32,7 +31,7 @@ export declare class ReactionImpl implements AbstractReaction<any> {
|
|
|
32
31
|
private relaunch;
|
|
33
32
|
private static markObsolete;
|
|
34
33
|
}
|
|
35
|
-
declare class Launch extends
|
|
34
|
+
declare class Launch extends ValueSnapshot implements Observer {
|
|
36
35
|
static current?: Launch;
|
|
37
36
|
static queuedReactiveFunctions: Array<Observer>;
|
|
38
37
|
static deferredReactiveFunctions: Array<Launch>;
|
|
@@ -40,7 +39,7 @@ declare class Launch extends MvccValue implements Observer {
|
|
|
40
39
|
readonly transaction: Transaction;
|
|
41
40
|
readonly reaction: ReactionImpl;
|
|
42
41
|
readonly changeset: AbstractChangeset;
|
|
43
|
-
observables: Map<
|
|
42
|
+
observables: Map<ValueSnapshot, Subscription> | undefined;
|
|
44
43
|
options: OptionsImpl;
|
|
45
44
|
cause: string | undefined;
|
|
46
45
|
args: any[];
|
|
@@ -61,7 +60,7 @@ declare class Launch extends MvccValue implements Observer {
|
|
|
61
60
|
dependencies(): string[];
|
|
62
61
|
wrap<T>(func: F<T>): F<T>;
|
|
63
62
|
proceed(proxy: any, args: any[] | undefined): void;
|
|
64
|
-
markObsoleteDueTo(observable:
|
|
63
|
+
markObsoleteDueTo(observable: ValueSnapshot, m: MemberName, changeset: AbstractChangeset, h: ObjectHandle, outer: string, since: number, obsolete: Observer[]): void;
|
|
65
64
|
relaunchIfNotUpToDate(now: boolean, nothrow: boolean): void;
|
|
66
65
|
isNotUpToDate(): boolean;
|
|
67
66
|
reenterOver(head: Launch): this;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Log, misuse } from '../util/Dbg.js';
|
|
2
2
|
import { Kind, Reentrance } from '../Options.js';
|
|
3
|
-
import { ObjectHandle,
|
|
3
|
+
import { ObjectHandle, ValueSnapshot, Meta } from './Data.js';
|
|
4
4
|
import { Changeset, Dump, EMPTY_SNAPSHOT, MAX_REVISION } from './Changeset.js';
|
|
5
5
|
import { Transaction } from './Transaction.js';
|
|
6
6
|
import { MonitorImpl } from './Monitor.js';
|
|
@@ -12,7 +12,7 @@ const EMPTY_HANDLE = new ObjectHandle(undefined, undefined, Mvcc.observable, EMP
|
|
|
12
12
|
export class ReactionImpl {
|
|
13
13
|
configure(options) { return ReactionImpl.configureImpl(this, options); }
|
|
14
14
|
get options() { return this.peek(undefined).launch.options; }
|
|
15
|
-
get
|
|
15
|
+
get unobs() { return this.peek(undefined).launch.content; }
|
|
16
16
|
get args() { return this.use().launch.args; }
|
|
17
17
|
get result() { return this.reuseOrRelaunch(true, undefined).content; }
|
|
18
18
|
get error() { return this.use().launch.error; }
|
|
@@ -197,7 +197,7 @@ export class ReactionImpl {
|
|
|
197
197
|
ror.launch.markObsoleteDueTo(ror.launch, self.memberName, EMPTY_SNAPSHOT.changeset, EMPTY_HANDLE, BOOT_CAUSE, ctx.timestamp, ctx.obsolete);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
class Launch extends
|
|
200
|
+
class Launch extends ValueSnapshot {
|
|
201
201
|
constructor(reaction, changeset, former) {
|
|
202
202
|
super(undefined);
|
|
203
203
|
this.margin = Launch.current ? Launch.current.margin + 1 : 1;
|
|
@@ -497,7 +497,7 @@ class Launch extends MvccValue {
|
|
|
497
497
|
const curr = os.data[m];
|
|
498
498
|
if (obsolete !== undefined) {
|
|
499
499
|
const former = os.former.snapshot.data[m];
|
|
500
|
-
if (former !== undefined && former instanceof
|
|
500
|
+
if (former !== undefined && former instanceof ValueSnapshot) {
|
|
501
501
|
const why = `T${os.changeset.id}[${os.changeset.hint}]`;
|
|
502
502
|
if (former instanceof Launch) {
|
|
503
503
|
if ((former.obsoleteSince === MAX_REVISION || former.obsoleteSince <= 0)) {
|
|
@@ -528,7 +528,7 @@ class Launch extends MvccValue {
|
|
|
528
528
|
curr.unsubscribeFromAllObservables();
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
|
-
else if (curr instanceof
|
|
531
|
+
else if (curr instanceof ValueSnapshot && curr.observers) {
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
534
|
static enqueueReactiveFunctionsToRun(reactive) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactronic",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.112",
|
|
4
4
|
"description": "Reactronic - Transactional Reactive State Management",
|
|
5
5
|
"publisher": "Nezaboodka Software",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/nezaboodka/reactronic/blob/master/README.md#readme",
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "20.
|
|
35
|
-
"@types/react": "18.2.
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
37
|
-
"@typescript-eslint/parser": "6.
|
|
34
|
+
"@types/node": "20.10.0",
|
|
35
|
+
"@types/react": "18.2.39",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "6.13.1",
|
|
37
|
+
"@typescript-eslint/parser": "6.13.1",
|
|
38
38
|
"ava": "5.3.1",
|
|
39
39
|
"c8": "8.0.1",
|
|
40
|
-
"eslint": "8.
|
|
40
|
+
"eslint": "8.54.0",
|
|
41
41
|
"react": "18.2.0",
|
|
42
42
|
"ts-node": "10.9.1",
|
|
43
43
|
"typescript": "5.2.2"
|