reactronic 0.95.25046 → 0.95.25048
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 +6 -6
- package/build/dist/source/OperationEx.d.ts +2 -2
- package/build/dist/source/OperationEx.js +2 -2
- package/build/dist/source/Pipe.d.ts +2 -2
- package/build/dist/source/Pipe.js +2 -2
- package/build/dist/source/System.d.ts +1 -1
- package/build/dist/source/System.js +1 -1
- package/build/dist/source/api.d.ts +4 -4
- package/build/dist/source/api.js +4 -4
- package/build/dist/source/core/Indicator.d.ts +2 -2
- package/build/dist/source/core/Indicator.js +2 -2
- package/build/dist/source/core/Journal.d.ts +2 -2
- package/build/dist/source/core/Journal.js +2 -2
- package/build/dist/source/core/Mvcc.d.ts +2 -2
- package/build/dist/source/core/Mvcc.js +6 -6
- package/build/dist/source/core/MvccArray.d.ts +1 -1
- package/build/dist/source/core/MvccArray.js +1 -1
- package/build/dist/source/core/MvccMap.d.ts +1 -1
- package/build/dist/source/core/MvccMap.js +1 -1
- package/build/dist/source/core/MvccReconciliationList.d.ts +2 -2
- package/build/dist/source/core/MvccReconciliationList.js +2 -2
- package/build/dist/source/core/Operation.js +1 -1
- package/build/dist/source/core/TreeNode.d.ts +8 -8
- package/build/dist/source/core/TreeNode.js +16 -16
- package/build/dist/source/util/LinkedList.d.ts +3 -2
- package/build/dist/source/util/LinkedList.js +15 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ Quick introduction and detailed description is below.
|
|
|
48
48
|
Here is an example of transactional reactive code:
|
|
49
49
|
|
|
50
50
|
``` typescript
|
|
51
|
-
class Demo extends
|
|
51
|
+
class Demo extends RxObject {
|
|
52
52
|
name: string = 'Nezaboodka Software'
|
|
53
53
|
email: string = 'contact@nezaboodka.com'
|
|
54
54
|
|
|
@@ -115,7 +115,7 @@ to track access to their properties, both on reads and
|
|
|
115
115
|
writes.
|
|
116
116
|
|
|
117
117
|
``` typescript
|
|
118
|
-
class MyModel extends
|
|
118
|
+
class MyModel extends RxObject {
|
|
119
119
|
url: string = "https://github.com/nezaboodka/reactronic"
|
|
120
120
|
content: string = "transactional reactive state management"
|
|
121
121
|
timestamp: Date = Date.now()
|
|
@@ -123,7 +123,7 @@ class MyModel extends SignallingObject {
|
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
In the example above, the class `MyModel` is based on
|
|
126
|
-
Reactronic's `
|
|
126
|
+
Reactronic's `RxObject` class and all its
|
|
127
127
|
properties `url`, `content`, and `timestamp` are hooked.
|
|
128
128
|
|
|
129
129
|
## Transactional Function
|
|
@@ -136,7 +136,7 @@ provide transparent atomicity (by implicit context
|
|
|
136
136
|
switching and isolation).
|
|
137
137
|
|
|
138
138
|
``` typescript
|
|
139
|
-
class MyModel extends
|
|
139
|
+
class MyModel extends RxObject {
|
|
140
140
|
// ...
|
|
141
141
|
@transaction
|
|
142
142
|
async load(url: string): Promise<void> {
|
|
@@ -232,7 +232,7 @@ class Component<P> extends React.Component<P> {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
componentWillUnmount(): void {
|
|
235
|
-
runTransactional(
|
|
235
|
+
runTransactional(disposeRxObject, this)
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
```
|
|
@@ -325,7 +325,7 @@ NPM: `npm install reactronic`
|
|
|
325
325
|
// Classes
|
|
326
326
|
|
|
327
327
|
class TxObject { } // transactional object
|
|
328
|
-
class
|
|
328
|
+
class RxObject { } // reactive object
|
|
329
329
|
|
|
330
330
|
// Decorators & Operators
|
|
331
331
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { F } from "./util/Utils.js";
|
|
2
|
-
import {
|
|
3
|
-
export declare class ReactionEx<T> extends
|
|
2
|
+
import { RxObject } from "./core/Mvcc.js";
|
|
3
|
+
export declare class ReactionEx<T> extends RxObject {
|
|
4
4
|
protected operation: F<T>;
|
|
5
5
|
constructor(operation: F<T>);
|
|
6
6
|
protected launch(): T;
|
|
@@ -7,9 +7,9 @@ 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 {
|
|
10
|
+
import { RxObject } from "./core/Mvcc.js";
|
|
11
11
|
import { reaction } from "./System.js";
|
|
12
|
-
export class ReactionEx extends
|
|
12
|
+
export class ReactionEx extends RxObject {
|
|
13
13
|
constructor(operation) {
|
|
14
14
|
super();
|
|
15
15
|
this.operation = operation;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare abstract class Pipe<T> extends
|
|
1
|
+
import { RxObject } from "./core/Mvcc.js";
|
|
2
|
+
export declare abstract class Pipe<T> extends RxObject {
|
|
3
3
|
abstract readonly capacity: number;
|
|
4
4
|
abstract readonly count: number;
|
|
5
5
|
abstract put(...items: T[]): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { misuse } from "./util/Dbg.js";
|
|
2
|
-
import {
|
|
3
|
-
export class Pipe extends
|
|
2
|
+
import { RxObject } from "./core/Mvcc.js";
|
|
3
|
+
export class Pipe extends RxObject {
|
|
4
4
|
static create(hint, capacity) { throw misuse("not implemented"); }
|
|
5
5
|
}
|
|
@@ -20,7 +20,7 @@ export declare function runSensitive<T>(sensitivity: boolean, func: F<T>, ...arg
|
|
|
20
20
|
export declare function runContextual<T>(p: Promise<T>): Promise<T>;
|
|
21
21
|
export declare function manageReaction<T>(method: F<T>): Reaction<T>;
|
|
22
22
|
export declare function configureCurrentReaction(options: Partial<ReactivityOptions>): ReactivityOptions;
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function disposeRxObject(obj: any): void;
|
|
24
24
|
export declare function signal(enabled: boolean): (proto: object, prop: PropertyKey) => any;
|
|
25
25
|
export declare function signal<T>(proto: object, prop: PropertyKey): any;
|
|
26
26
|
export declare function transaction(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
@@ -47,7 +47,7 @@ export function manageReaction(method) {
|
|
|
47
47
|
export function configureCurrentReaction(options) {
|
|
48
48
|
return ReactionImpl.configureImpl(undefined, options);
|
|
49
49
|
}
|
|
50
|
-
export function
|
|
50
|
+
export function disposeRxObject(obj) {
|
|
51
51
|
Changeset.dispose(obj);
|
|
52
52
|
}
|
|
53
53
|
export function signal(protoOrEnabled, prop) {
|
|
@@ -11,14 +11,14 @@ export type { Reaction, ReactivityOptions, SnapshotOptions, LoggingOptions, Prof
|
|
|
11
11
|
export type { Worker } from "./Worker.js";
|
|
12
12
|
export { Ref, ToggleRef, refs, toggleRefs, customToggleRefs } from "./Ref.js";
|
|
13
13
|
export type { BoolOnly, GivenTypeOnly } from "./Ref.js";
|
|
14
|
-
export { TxObject,
|
|
15
|
-
export { TxArray,
|
|
16
|
-
export { TxMap,
|
|
14
|
+
export { TxObject, RxObject } from "./core/Mvcc.js";
|
|
15
|
+
export { TxArray, RxArray } from "./core/MvccArray.js";
|
|
16
|
+
export { TxMap, RxMap } from "./core/MvccMap.js";
|
|
17
17
|
export { Changeset } from "./core/Changeset.js";
|
|
18
18
|
export { Transaction } from "./core/Transaction.js";
|
|
19
19
|
export { Indicator } from "./core/Indicator.js";
|
|
20
20
|
export { Journal } from "./core/Journal.js";
|
|
21
|
-
export { runTransactional, runNonReactive, runSensitive, runContextual, manageReaction, configureCurrentReaction,
|
|
21
|
+
export { runTransactional, runNonReactive, runSensitive, runContextual, manageReaction, configureCurrentReaction, disposeRxObject } from "./System.js";
|
|
22
22
|
export { ReactiveSystem, signal, transaction, reaction, cache, options } from "./System.js";
|
|
23
23
|
export { ReactionEx } from "./OperationEx.js";
|
|
24
24
|
export { declare, derivative, launch, ReactiveTreeNode, BaseDriver, ReactiveTreeVariable } from "./core/TreeNode.js";
|
package/build/dist/source/api.js
CHANGED
|
@@ -7,14 +7,14 @@ export { SealedSet } from "./util/SealedSet.js";
|
|
|
7
7
|
export { LoggingLevel } from "./Options.js";
|
|
8
8
|
export { Mode, Priority, Kind, Reentrance, Isolation } from "./Enums.js";
|
|
9
9
|
export { Ref, ToggleRef, refs, toggleRefs, customToggleRefs } from "./Ref.js";
|
|
10
|
-
export { TxObject,
|
|
11
|
-
export { TxArray,
|
|
12
|
-
export { TxMap,
|
|
10
|
+
export { TxObject, RxObject } from "./core/Mvcc.js";
|
|
11
|
+
export { TxArray, RxArray } from "./core/MvccArray.js";
|
|
12
|
+
export { TxMap, RxMap } from "./core/MvccMap.js";
|
|
13
13
|
export { Changeset } from "./core/Changeset.js";
|
|
14
14
|
export { Transaction } from "./core/Transaction.js";
|
|
15
15
|
export { Indicator } from "./core/Indicator.js";
|
|
16
16
|
export { Journal } from "./core/Journal.js";
|
|
17
|
-
export { runTransactional, runNonReactive, runSensitive, runContextual, manageReaction, configureCurrentReaction,
|
|
17
|
+
export { runTransactional, runNonReactive, runSensitive, runContextual, manageReaction, configureCurrentReaction, disposeRxObject } from "./System.js";
|
|
18
18
|
export { ReactiveSystem, signal, transaction, reaction, cache, options } from "./System.js";
|
|
19
19
|
export { ReactionEx } from "./OperationEx.js";
|
|
20
20
|
export { declare, derivative, launch, ReactiveTreeNode, BaseDriver, ReactiveTreeVariable } from "./core/TreeNode.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Worker } from "../Worker.js";
|
|
2
|
-
import {
|
|
3
|
-
export declare abstract class Indicator extends
|
|
2
|
+
import { RxObject } from "./Mvcc.js";
|
|
3
|
+
export declare abstract class Indicator extends RxObject {
|
|
4
4
|
abstract readonly isBusy: boolean;
|
|
5
5
|
abstract readonly counter: number;
|
|
6
6
|
abstract readonly workers: ReadonlySet<Worker>;
|
|
@@ -8,9 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { Isolation } from "../Enums.js";
|
|
11
|
-
import {
|
|
11
|
+
import { RxObject, Mvcc } from "./Mvcc.js";
|
|
12
12
|
import { Transaction } from "./Transaction.js";
|
|
13
|
-
export class Indicator extends
|
|
13
|
+
export class Indicator extends RxObject {
|
|
14
14
|
static create(hint, activationDelay, deactivationDelay, durationResolution) {
|
|
15
15
|
return IndicatorImpl.createImpl(hint, activationDelay, deactivationDelay, durationResolution);
|
|
16
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RxObject } from "./Mvcc.js";
|
|
2
2
|
import { ObjectHandle, ObjectVersion, PatchSet } from "./Data.js";
|
|
3
3
|
export type Saver = (patch: PatchSet) => Promise<void>;
|
|
4
|
-
export declare abstract class Journal extends
|
|
4
|
+
export declare abstract class Journal extends RxObject {
|
|
5
5
|
abstract capacity: number;
|
|
6
6
|
abstract readonly edits: ReadonlyArray<PatchSet>;
|
|
7
7
|
abstract readonly unsaved: PatchSet;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { misuse } from "../util/Dbg.js";
|
|
2
2
|
import { Isolation } from "../Enums.js";
|
|
3
|
-
import {
|
|
3
|
+
import { RxObject } from "./Mvcc.js";
|
|
4
4
|
import { Meta, ContentFootprint } from "./Data.js";
|
|
5
5
|
import { Changeset, EMPTY_OBJECT_VERSION } from "./Changeset.js";
|
|
6
6
|
import { Transaction } from "./Transaction.js";
|
|
7
7
|
import { Sealant } from "../util/Sealant.js";
|
|
8
|
-
export class Journal extends
|
|
8
|
+
export class Journal extends RxObject {
|
|
9
9
|
static create() { return new JournalImpl(); }
|
|
10
10
|
}
|
|
11
11
|
export class JournalImpl extends Journal {
|
|
@@ -12,7 +12,7 @@ export declare abstract class MvccObject {
|
|
|
12
12
|
export declare abstract class TxObject extends MvccObject {
|
|
13
13
|
constructor();
|
|
14
14
|
}
|
|
15
|
-
export declare abstract class
|
|
15
|
+
export declare abstract class RxObject extends MvccObject {
|
|
16
16
|
constructor();
|
|
17
17
|
}
|
|
18
18
|
export declare class OptionsImpl implements ReactivityOptions {
|
|
@@ -39,7 +39,7 @@ export declare class Mvcc implements ProxyHandler<ObjectHandle> {
|
|
|
39
39
|
static asyncActionDurationWarningThreshold: number;
|
|
40
40
|
static sensitivity: boolean;
|
|
41
41
|
static readonly tx: Mvcc;
|
|
42
|
-
static readonly
|
|
42
|
+
static readonly rx: Mvcc;
|
|
43
43
|
readonly isSignal: boolean;
|
|
44
44
|
constructor(isSignal: boolean);
|
|
45
45
|
getPrototypeOf(h: ObjectHandle): object | null;
|
|
@@ -20,7 +20,7 @@ export class TxObject extends MvccObject {
|
|
|
20
20
|
super(false);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
export class
|
|
23
|
+
export class RxObject extends MvccObject {
|
|
24
24
|
constructor() {
|
|
25
25
|
super(true);
|
|
26
26
|
}
|
|
@@ -125,11 +125,11 @@ export class Mvcc {
|
|
|
125
125
|
Meta.acquire(proto, Meta.Initial)[fk] = new ContentFootprint(undefined, 0);
|
|
126
126
|
const get = function () {
|
|
127
127
|
const h = Mvcc.acquireHandle(this);
|
|
128
|
-
return Mvcc.
|
|
128
|
+
return Mvcc.rx.get(h, fk, this);
|
|
129
129
|
};
|
|
130
130
|
const set = function (value) {
|
|
131
131
|
const h = Mvcc.acquireHandle(this);
|
|
132
|
-
return Mvcc.
|
|
132
|
+
return Mvcc.rx.set(h, fk, value, this);
|
|
133
133
|
};
|
|
134
134
|
const enumerable = true;
|
|
135
135
|
const configurable = false;
|
|
@@ -178,7 +178,7 @@ export class Mvcc {
|
|
|
178
178
|
throw misuse("only objects can be signalling");
|
|
179
179
|
const initial = Meta.getFrom(Object.getPrototypeOf(obj), Meta.Initial);
|
|
180
180
|
const ov = new ObjectVersion(EMPTY_OBJECT_VERSION.changeset, EMPTY_OBJECT_VERSION, Object.assign({}, initial));
|
|
181
|
-
h = new ObjectHandle(obj, obj, Mvcc.
|
|
181
|
+
h = new ObjectHandle(obj, obj, Mvcc.rx, ov, obj.constructor.name);
|
|
182
182
|
Meta.set(ov.data, Meta.Handle, h);
|
|
183
183
|
Meta.set(obj, Meta.Handle, h);
|
|
184
184
|
Meta.set(ov.data, Meta.Revision, new ContentFootprint(1, 0));
|
|
@@ -187,7 +187,7 @@ export class Mvcc {
|
|
|
187
187
|
}
|
|
188
188
|
static createHandleForMvccObject(proto, data, blank, hint, isSignal) {
|
|
189
189
|
const ctx = Changeset.edit();
|
|
190
|
-
const mvcc = isSignal ? Mvcc.
|
|
190
|
+
const mvcc = isSignal ? Mvcc.rx : Mvcc.tx;
|
|
191
191
|
const h = new ObjectHandle(data, undefined, mvcc, EMPTY_OBJECT_VERSION, hint);
|
|
192
192
|
ctx.getEditableObjectVersion(h, Meta.Handle, blank);
|
|
193
193
|
if (!Mvcc.reactivityAutoStartDisabled)
|
|
@@ -237,7 +237,7 @@ Mvcc.mainThreadBlockingWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
|
237
237
|
Mvcc.asyncActionDurationWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
238
238
|
Mvcc.sensitivity = false;
|
|
239
239
|
Mvcc.tx = new Mvcc(false);
|
|
240
|
-
Mvcc.
|
|
240
|
+
Mvcc.rx = new Mvcc(true);
|
|
241
241
|
Mvcc.createOperationDescriptor = function (h, fk, options) {
|
|
242
242
|
throw misuse("this implementation of createOperationDescriptor should never be called");
|
|
243
243
|
};
|
|
@@ -53,7 +53,7 @@ export declare class TxArray<T> extends MvccArray<T> {
|
|
|
53
53
|
constructor(arrayLength?: number);
|
|
54
54
|
constructor(...items: T[]);
|
|
55
55
|
}
|
|
56
|
-
export declare class
|
|
56
|
+
export declare class RxArray<T> extends MvccArray<T> {
|
|
57
57
|
constructor();
|
|
58
58
|
constructor(arrayLength: number);
|
|
59
59
|
constructor(arrayLength?: number);
|
|
@@ -19,7 +19,7 @@ export declare class TxMap<K, V> extends MvccMap<K, V> {
|
|
|
19
19
|
constructor();
|
|
20
20
|
constructor(iterable?: Iterable<readonly [K, V]> | null);
|
|
21
21
|
}
|
|
22
|
-
export declare class
|
|
22
|
+
export declare class RxMap<K, V> extends MvccMap<K, V> {
|
|
23
23
|
constructor();
|
|
24
24
|
constructor(iterable?: Iterable<readonly [K, V]> | null);
|
|
25
25
|
}
|
|
@@ -28,7 +28,7 @@ export class TxMap extends MvccMap {
|
|
|
28
28
|
super(false, args !== undefined ? new Map(args) : new Map());
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
export class
|
|
31
|
+
export class RxMap extends MvccMap {
|
|
32
32
|
constructor(args) {
|
|
33
33
|
super(true, args !== undefined ? new Map(args) : new Map());
|
|
34
34
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReconciliationList, LinkedItem, ReconciliationListReader } from "../util/ReconciliationList.js";
|
|
2
|
-
import {
|
|
3
|
-
export declare abstract class
|
|
2
|
+
import { RxObject } from "./Mvcc.js";
|
|
3
|
+
export declare abstract class RxReconciliationList<T> extends RxObject implements ReconciliationListReader<T> {
|
|
4
4
|
protected abstract impl: ReconciliationList<T>;
|
|
5
5
|
get isStrict(): boolean;
|
|
6
6
|
get count(): number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export class
|
|
1
|
+
import { RxObject } from "./Mvcc.js";
|
|
2
|
+
export class RxReconciliationList extends RxObject {
|
|
3
3
|
get isStrict() { return this.impl.isStrict; }
|
|
4
4
|
get count() { return this.impl.count; }
|
|
5
5
|
get countOfAdded() { return this.impl.countOfAdded; }
|
|
@@ -8,7 +8,7 @@ import { Mvcc, OptionsImpl } from "./Mvcc.js";
|
|
|
8
8
|
import { JournalImpl } from "./Journal.js";
|
|
9
9
|
const BOOT_ARGS = [];
|
|
10
10
|
const BOOT_CAUSE = "<boot>";
|
|
11
|
-
const EMPTY_HANDLE = new ObjectHandle(undefined, undefined, Mvcc.
|
|
11
|
+
const EMPTY_HANDLE = new ObjectHandle(undefined, undefined, Mvcc.rx, EMPTY_OBJECT_VERSION, "<boot>");
|
|
12
12
|
export class ReactionImpl {
|
|
13
13
|
configure(options) { return ReactionImpl.configureImpl(this, options); }
|
|
14
14
|
get options() { return this.peek(undefined).footprint.options; }
|
|
@@ -2,15 +2,15 @@ import { LoggingOptions } from "../Logging.js";
|
|
|
2
2
|
import { ReconciliationList, ReconciliationListReader, LinkedItem } from "../util/ReconciliationList.js";
|
|
3
3
|
import { Priority, Mode } from "../Enums.js";
|
|
4
4
|
import { ReactivityOptions } from "../Options.js";
|
|
5
|
-
import {
|
|
5
|
+
import { RxObject } from "../core/Mvcc.js";
|
|
6
6
|
export type Script<E> = (this: E, o: E, basis: () => void) => void;
|
|
7
7
|
export type ScriptAsync<E> = (this: E, o: E, basis: () => Promise<void>) => Promise<void>;
|
|
8
8
|
export type Handler<E = unknown, R = void> = (o: E) => R;
|
|
9
|
-
export declare function declare<E = void>(driver: ReactiveTreeNodeDriver<E>, script?: Script<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>,
|
|
9
|
+
export declare function declare<E = void>(driver: ReactiveTreeNodeDriver<E>, script?: Script<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>, signalArgs?: unknown, basis?: ReactiveTreeNodeDecl<E>): ReactiveTreeNode<E>;
|
|
10
10
|
export declare function declare<E = void>(driver: ReactiveTreeNodeDriver<E>, declaration?: ReactiveTreeNodeDecl<E>): ReactiveTreeNode<E>;
|
|
11
|
-
export declare function declare<E = void>(driver: ReactiveTreeNodeDriver<E>, scriptOrDeclaration?: Script<E> | ReactiveTreeNodeDecl<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>,
|
|
11
|
+
export declare function declare<E = void>(driver: ReactiveTreeNodeDriver<E>, scriptOrDeclaration?: Script<E> | ReactiveTreeNodeDecl<E>, scriptAsync?: ScriptAsync<E>, key?: string, mode?: Mode, preparation?: Script<E>, preparationAsync?: ScriptAsync<E>, finalization?: Script<E>, signalArgs?: unknown, basis?: ReactiveTreeNodeDecl<E>): ReactiveTreeNode<E>;
|
|
12
12
|
export declare function derivative<E = void>(declaration?: ReactiveTreeNodeDecl<E>, basis?: ReactiveTreeNodeDecl<E>): ReactiveTreeNodeDecl<E>;
|
|
13
|
-
export declare function launch<T>(node: ReactiveTreeNode<T>,
|
|
13
|
+
export declare function launch<T>(node: ReactiveTreeNode<T>, signalArgs?: unknown): ReactiveTreeNode<T>;
|
|
14
14
|
export declare abstract class ReactiveTreeNode<E = unknown> {
|
|
15
15
|
static readonly shortFrameDuration = 16;
|
|
16
16
|
static readonly longFrameDuration = 300;
|
|
@@ -36,7 +36,7 @@ export declare abstract class ReactiveTreeNode<E = unknown> {
|
|
|
36
36
|
abstract configureReactivity(options: Partial<ReactivityOptions>): ReactivityOptions;
|
|
37
37
|
static get current(): ReactiveTreeNode;
|
|
38
38
|
static get isFirstScriptRun(): boolean;
|
|
39
|
-
static launchScript(node: ReactiveTreeNode<any>,
|
|
39
|
+
static launchScript(node: ReactiveTreeNode<any>, signalArgs: unknown): void;
|
|
40
40
|
static launchFinalization(node: ReactiveTreeNode<any>): void;
|
|
41
41
|
static launchNestedNodesThenDo(action: (error: unknown) => void): void;
|
|
42
42
|
static markAsMounted(node: ReactiveTreeNode<any>, yes: boolean): void;
|
|
@@ -55,7 +55,7 @@ export type ReactiveTreeNodeDecl<E = unknown> = {
|
|
|
55
55
|
preparation?: Script<E>;
|
|
56
56
|
preparationAsync?: ScriptAsync<E>;
|
|
57
57
|
finalization?: Script<E>;
|
|
58
|
-
|
|
58
|
+
signalArgs?: unknown;
|
|
59
59
|
basis?: ReactiveTreeNodeDecl<E>;
|
|
60
60
|
};
|
|
61
61
|
export type ReactiveTreeNodeDriver<E = unknown> = {
|
|
@@ -95,7 +95,7 @@ export declare class ReactiveTreeVariable<T extends Object = Object> {
|
|
|
95
95
|
}
|
|
96
96
|
export declare function generateKey(owner?: ReactiveTreeNode$): string;
|
|
97
97
|
export declare function getModeUsingBasisChain(declaration?: ReactiveTreeNodeDecl<any>): Mode;
|
|
98
|
-
declare class ReactiveTreeNodeContext$<T extends Object = Object> extends
|
|
98
|
+
declare class ReactiveTreeNodeContext$<T extends Object = Object> extends RxObject implements ReactiveTreeNodeContext<T> {
|
|
99
99
|
next: ReactiveTreeNodeContext$<object> | undefined;
|
|
100
100
|
variable: ReactiveTreeVariable<T>;
|
|
101
101
|
value: T;
|
|
@@ -126,7 +126,7 @@ declare class ReactiveTreeNode$<E = unknown> extends ReactiveTreeNode<E> {
|
|
|
126
126
|
set strictOrder(value: boolean);
|
|
127
127
|
get isMoved(): boolean;
|
|
128
128
|
has(mode: Mode): boolean;
|
|
129
|
-
script(
|
|
129
|
+
script(_signalArgs: unknown): void;
|
|
130
130
|
configureReactivity(options: Partial<ReactivityOptions>): ReactivityOptions;
|
|
131
131
|
static get nodeSlot(): LinkedItem<ReactiveTreeNode$>;
|
|
132
132
|
static tryUseTreeVariableValue<T extends Object>(variable: ReactiveTreeVariable<T>): T | undefined;
|
|
@@ -21,16 +21,16 @@ import { Uri } from "../util/Uri.js";
|
|
|
21
21
|
import { ReconciliationList } from "../util/ReconciliationList.js";
|
|
22
22
|
import { emitLetters, flags, getCallerInfo, proceedSyncOrAsync } from "../util/Utils.js";
|
|
23
23
|
import { Priority, Mode, Isolation, Reentrance } from "../Enums.js";
|
|
24
|
-
import {
|
|
24
|
+
import { RxObject } from "../core/Mvcc.js";
|
|
25
25
|
import { Transaction } from "../core/Transaction.js";
|
|
26
|
-
import { ReactiveSystem, options, signal, reaction, runTransactional, runNonReactive, manageReaction,
|
|
27
|
-
export function declare(driver, scriptOrDeclaration, scriptAsync, key, mode, preparation, preparationAsync, finalization,
|
|
26
|
+
import { ReactiveSystem, options, signal, reaction, runTransactional, runNonReactive, manageReaction, disposeRxObject } from "../System.js";
|
|
27
|
+
export function declare(driver, scriptOrDeclaration, scriptAsync, key, mode, preparation, preparationAsync, finalization, signalArgs, basis) {
|
|
28
28
|
let result;
|
|
29
29
|
let declaration;
|
|
30
30
|
if (scriptOrDeclaration instanceof Function) {
|
|
31
31
|
declaration = {
|
|
32
32
|
script: scriptOrDeclaration, scriptAsync, key, mode,
|
|
33
|
-
preparation, preparationAsync, finalization,
|
|
33
|
+
preparation, preparationAsync, finalization, signalArgs, basis,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
else
|
|
@@ -45,9 +45,9 @@ export function declare(driver, scriptOrDeclaration, scriptAsync, key, mode, pre
|
|
|
45
45
|
result = existing.instance;
|
|
46
46
|
if (result.driver !== driver && driver !== undefined)
|
|
47
47
|
throw misuse(`changing element driver is not yet supported: "${result.driver.name}" -> "${driver === null || driver === void 0 ? void 0 : driver.name}"`);
|
|
48
|
-
const
|
|
49
|
-
if (signalsAreEqual(declaration.
|
|
50
|
-
declaration.
|
|
48
|
+
const exSignalArgs = result.declaration.signalArgs;
|
|
49
|
+
if (signalsAreEqual(declaration.signalArgs, exSignalArgs))
|
|
50
|
+
declaration.signalArgs = exSignalArgs;
|
|
51
51
|
result.declaration = declaration;
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
@@ -68,8 +68,8 @@ export function derivative(declaration, basis) {
|
|
|
68
68
|
declaration = basis !== null && basis !== void 0 ? basis : {};
|
|
69
69
|
return declaration;
|
|
70
70
|
}
|
|
71
|
-
export function launch(node,
|
|
72
|
-
ReactiveTreeNode.launchScript(node,
|
|
71
|
+
export function launch(node, signalArgs) {
|
|
72
|
+
ReactiveTreeNode.launchScript(node, signalArgs);
|
|
73
73
|
return node;
|
|
74
74
|
}
|
|
75
75
|
export class ReactiveTreeNode {
|
|
@@ -79,11 +79,11 @@ export class ReactiveTreeNode {
|
|
|
79
79
|
static get isFirstScriptRun() {
|
|
80
80
|
return ReactiveTreeNode.current.stamp === 1;
|
|
81
81
|
}
|
|
82
|
-
static launchScript(node,
|
|
82
|
+
static launchScript(node, signalArgs) {
|
|
83
83
|
const impl = node;
|
|
84
84
|
const declaration = impl.declaration;
|
|
85
|
-
if (node.stamp >= Number.MAX_SAFE_INTEGER || !signalsAreEqual(
|
|
86
|
-
declaration.
|
|
85
|
+
if (node.stamp >= Number.MAX_SAFE_INTEGER || !signalsAreEqual(signalArgs, declaration.signalArgs)) {
|
|
86
|
+
declaration.signalArgs = signalArgs;
|
|
87
87
|
launchScriptViaSlot(impl.slot);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -234,7 +234,7 @@ function invokeFinalizationUsingBasisChain(element, declaration) {
|
|
|
234
234
|
else if (basis)
|
|
235
235
|
invokeFinalizationUsingBasisChain(element, basis);
|
|
236
236
|
}
|
|
237
|
-
class ReactiveTreeNodeContext$ extends
|
|
237
|
+
class ReactiveTreeNodeContext$ extends RxObject {
|
|
238
238
|
constructor(variable, value) {
|
|
239
239
|
super();
|
|
240
240
|
this.next = undefined;
|
|
@@ -303,7 +303,7 @@ class ReactiveTreeNode$ extends ReactiveTreeNode {
|
|
|
303
303
|
has(mode) {
|
|
304
304
|
return flags(getModeUsingBasisChain(this.declaration), mode);
|
|
305
305
|
}
|
|
306
|
-
script(
|
|
306
|
+
script(_signalArgs) {
|
|
307
307
|
runScriptNow(this.slot);
|
|
308
308
|
}
|
|
309
309
|
configureReactivity(options) {
|
|
@@ -494,7 +494,7 @@ function launchScriptViaSlot(nodeSlot) {
|
|
|
494
494
|
});
|
|
495
495
|
});
|
|
496
496
|
}
|
|
497
|
-
runNonReactive(node.script, node.declaration.
|
|
497
|
+
runNonReactive(node.script, node.declaration.signalArgs);
|
|
498
498
|
}
|
|
499
499
|
else if (node.owner !== node)
|
|
500
500
|
runScriptNow(nodeSlot);
|
|
@@ -574,7 +574,7 @@ function runDisposalLoop() {
|
|
|
574
574
|
while (slot !== undefined) {
|
|
575
575
|
if (Transaction.isFrameOver(500, 5))
|
|
576
576
|
yield Transaction.requestNextFrame();
|
|
577
|
-
|
|
577
|
+
disposeRxObject(slot.instance);
|
|
578
578
|
slot = slot.aux;
|
|
579
579
|
ReactiveTreeNode$.disposableNodeCount--;
|
|
580
580
|
}
|
|
@@ -5,10 +5,11 @@ export declare class LinkedList<T extends LinkedItem<T>> {
|
|
|
5
5
|
private isStrictOrder$;
|
|
6
6
|
private map;
|
|
7
7
|
items$: LinkedSubList<T>;
|
|
8
|
-
private renovation
|
|
8
|
+
private renovation$;
|
|
9
9
|
constructor(keyExtractor: KeyExtractor<T>, isStrictOrder?: boolean);
|
|
10
10
|
get isStrictOrder(): boolean;
|
|
11
11
|
set isStrictOrder(value: boolean);
|
|
12
|
+
get renovation(): LinkedListRenovation<T>;
|
|
12
13
|
get isRenovationInProgress(): boolean;
|
|
13
14
|
get count(): number;
|
|
14
15
|
items(): Generator<T>;
|
|
@@ -17,7 +18,7 @@ export declare class LinkedList<T extends LinkedItem<T>> {
|
|
|
17
18
|
move(item: T, before: T | undefined): void;
|
|
18
19
|
remove(item: T): void;
|
|
19
20
|
beginRenovation(diff?: Array<T>): LinkedListRenovation<T>;
|
|
20
|
-
endRenovation(error?: unknown):
|
|
21
|
+
endRenovation(error?: unknown): LinkedListRenovation<T>;
|
|
21
22
|
static move$<T extends LinkedItem<T>>(list: LinkedList<T>, item: T, before: T | undefined): void;
|
|
22
23
|
static remove$<T extends LinkedItem<T>>(list: LinkedList<T>, item: T): void;
|
|
23
24
|
static removeKey$<T extends LinkedItem<T>>(list: LinkedList<T>, key: string | undefined): void;
|
|
@@ -5,20 +5,26 @@ export class LinkedList {
|
|
|
5
5
|
this.isStrictOrder$ = isStrictOrder;
|
|
6
6
|
this.map = new Map();
|
|
7
7
|
this.items$ = new LinkedSubList();
|
|
8
|
-
this.renovation = undefined;
|
|
8
|
+
this.renovation$ = undefined;
|
|
9
9
|
}
|
|
10
10
|
get isStrictOrder() { return this.isStrictOrder$; }
|
|
11
11
|
set isStrictOrder(value) {
|
|
12
|
-
if (this.renovation !== undefined)
|
|
12
|
+
if (this.renovation$ !== undefined)
|
|
13
13
|
throw misuse("cannot change strict mode in the middle of renovation");
|
|
14
14
|
this.isStrictOrder$ = value;
|
|
15
15
|
}
|
|
16
|
+
get renovation() {
|
|
17
|
+
const r = this.renovation$;
|
|
18
|
+
if (r === undefined)
|
|
19
|
+
throw misuse("renovation is not in progress");
|
|
20
|
+
return r;
|
|
21
|
+
}
|
|
16
22
|
get isRenovationInProgress() {
|
|
17
|
-
return this.renovation !== undefined;
|
|
23
|
+
return this.renovation$ !== undefined;
|
|
18
24
|
}
|
|
19
25
|
get count() {
|
|
20
26
|
var _a, _b;
|
|
21
|
-
return this.items$.count + ((_b = (_a = this.renovation) === null || _a === void 0 ? void 0 : _a.lostItemCount) !== null && _b !== void 0 ? _b : 0);
|
|
27
|
+
return this.items$.count + ((_b = (_a = this.renovation$) === null || _a === void 0 ? void 0 : _a.lostItemCount) !== null && _b !== void 0 ? _b : 0);
|
|
22
28
|
}
|
|
23
29
|
items() {
|
|
24
30
|
return this.items$.items();
|
|
@@ -48,16 +54,16 @@ export class LinkedList {
|
|
|
48
54
|
LinkedList.remove$(this, item);
|
|
49
55
|
}
|
|
50
56
|
beginRenovation(diff) {
|
|
51
|
-
if (this.renovation !== undefined)
|
|
57
|
+
if (this.renovation$ !== undefined)
|
|
52
58
|
throw misuse("renovation is in progress already");
|
|
53
59
|
const former = this.items$;
|
|
54
60
|
const renovation = new LinkedListRenovation(this, former, diff);
|
|
55
61
|
this.items$ = new LinkedSubList();
|
|
56
|
-
this.renovation = renovation;
|
|
62
|
+
this.renovation$ = renovation;
|
|
57
63
|
return renovation;
|
|
58
64
|
}
|
|
59
65
|
endRenovation(error) {
|
|
60
|
-
const renovation = this.renovation
|
|
66
|
+
const renovation = this.renovation$;
|
|
61
67
|
if (renovation === undefined)
|
|
62
68
|
throw misuse("renovation is ended already");
|
|
63
69
|
const items = this.items$;
|
|
@@ -77,7 +83,8 @@ export class LinkedList {
|
|
|
77
83
|
LinkedItem.setStatus$(x, Mark.prolonged, items.count);
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
|
-
this.renovation = undefined;
|
|
86
|
+
this.renovation$ = undefined;
|
|
87
|
+
return renovation;
|
|
81
88
|
}
|
|
82
89
|
static move$(list, item, before) {
|
|
83
90
|
LinkedItem.link$(list.items$, item, before);
|