reactronic 0.93.25025 → 0.94.25027
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 +41 -40
- package/build/dist/source/Enums.d.ts +32 -0
- package/build/dist/source/Enums.js +37 -0
- package/build/dist/source/OperationEx.d.ts +7 -0
- package/build/dist/source/{ReactiveLoop.js → OperationEx.js} +8 -8
- package/build/dist/source/Options.d.ts +7 -27
- package/build/dist/source/Options.js +0 -24
- package/build/dist/source/Pipe.d.ts +2 -2
- package/build/dist/source/Pipe.js +2 -2
- package/build/dist/source/Ref.d.ts +1 -1
- package/build/dist/source/Ref.js +4 -4
- package/build/dist/source/System.d.ts +29 -0
- package/build/dist/source/{ReactiveSystem.js → System.js} +24 -19
- package/build/dist/source/api.d.ts +12 -10
- package/build/dist/source/api.js +10 -8
- package/build/dist/source/core/Changeset.d.ts +8 -7
- package/build/dist/source/core/Changeset.js +18 -18
- package/build/dist/source/core/Data.d.ts +6 -6
- package/build/dist/source/core/Data.js +2 -2
- package/build/dist/source/core/Indicator.d.ts +2 -2
- package/build/dist/source/core/Indicator.js +3 -3
- package/build/dist/source/core/Journal.d.ts +2 -2
- package/build/dist/source/core/Journal.js +7 -7
- package/build/dist/source/core/Meta.d.ts +1 -1
- package/build/dist/source/core/Meta.js +1 -1
- package/build/dist/source/core/Mvcc.d.ts +17 -16
- package/build/dist/source/core/Mvcc.js +30 -30
- package/build/dist/source/core/MvccArray.d.ts +3 -3
- package/build/dist/source/core/MvccArray.js +4 -4
- package/build/dist/source/core/MvccMap.d.ts +3 -3
- package/build/dist/source/core/MvccMap.js +4 -4
- package/build/dist/source/core/MvccMergeList.d.ts +2 -2
- package/build/dist/source/core/MvccMergeList.js +2 -2
- package/build/dist/source/core/Operation.d.ts +25 -25
- package/build/dist/source/core/Operation.js +200 -200
- package/build/dist/source/core/Transaction.d.ts +3 -3
- package/build/dist/source/core/Transaction.js +72 -72
- package/build/dist/source/core/Tree.d.ts +26 -0
- package/build/dist/source/core/Tree.js +120 -0
- package/build/dist/source/core/TreeNode.d.ts +117 -0
- package/build/dist/source/core/{ReactiveNode.js → TreeNode.js} +57 -185
- package/package.json +1 -1
- package/build/dist/source/ReactiveLoop.d.ts +0 -7
- package/build/dist/source/ReactiveSystem.d.ts +0 -30
- package/build/dist/source/core/ReactiveNode.d.ts +0 -107
package/README.md
CHANGED
|
@@ -20,22 +20,23 @@ corresponding visual components for (re)rendering. All
|
|
|
20
20
|
that is done in automatic, seamless, and fine-grained
|
|
21
21
|
way. Reactronic **takes full care of tracking dependencies**
|
|
22
22
|
between visual components (reactive functions) and
|
|
23
|
-
application state (
|
|
23
|
+
application state (observable objects).
|
|
24
24
|
|
|
25
25
|
Transactional reactivity is based on four fundamental
|
|
26
26
|
concepts:
|
|
27
27
|
|
|
28
|
-
- **
|
|
28
|
+
- **Observable Objects** - a set of objects that store
|
|
29
29
|
data of an application (state) and cause reactions
|
|
30
30
|
upon their changes;
|
|
31
|
-
- **Atomic
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
- **Atomic Block** - a code block that makes changes
|
|
32
|
+
in observable objects in atomic way ("all or
|
|
33
|
+
nothing");
|
|
34
|
+
- **Reaction** - a function that is
|
|
34
35
|
(re-)executed in response to changes made in
|
|
35
|
-
|
|
36
|
-
- **
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
observable objects by atomic actions;
|
|
37
|
+
- **Cache** - a function which result is remembered
|
|
38
|
+
and, if becomes obsolete, causes function to
|
|
39
|
+
re-execute on-demand.
|
|
39
40
|
|
|
40
41
|
Demo application built with Reactronic: https://nevod.io/#/playground.
|
|
41
42
|
Source code of the demo: https://gitlab.com/nezaboodka/nevod.web.public/-/blob/master/README.md.
|
|
@@ -47,7 +48,7 @@ Quick introduction and detailed description is below.
|
|
|
47
48
|
Here is an example of transactional reactive code:
|
|
48
49
|
|
|
49
50
|
``` typescript
|
|
50
|
-
class Demo extends
|
|
51
|
+
class Demo extends ObservableObject {
|
|
51
52
|
name: string = 'Nezaboodka Software'
|
|
52
53
|
email: string = 'contact@nezaboodka.com'
|
|
53
54
|
|
|
@@ -67,7 +68,7 @@ class Demo extends TriggeringObject {
|
|
|
67
68
|
}
|
|
68
69
|
```
|
|
69
70
|
|
|
70
|
-
In the example above, `Demo` is
|
|
71
|
+
In the example above, `Demo` is an observable object,
|
|
71
72
|
meaning that access to its fields are seamlessly tracked
|
|
72
73
|
to determine dependent reactive and cached functions.
|
|
73
74
|
Reactive function `printContact` reads `name` and `email`
|
|
@@ -79,11 +80,11 @@ Here is an example of a cached result that is
|
|
|
79
80
|
(re-)computed on-demand:
|
|
80
81
|
|
|
81
82
|
``` typescript
|
|
82
|
-
class Demo extends
|
|
83
|
+
class Demo extends ObservableObject {
|
|
83
84
|
name: string = 'Nezaboodka Software'
|
|
84
85
|
email: string = 'contact@nezaboodka.com'
|
|
85
86
|
|
|
86
|
-
@
|
|
87
|
+
@cached
|
|
87
88
|
get contact(): string {
|
|
88
89
|
return this.name + ' <' + this.email + '>'
|
|
89
90
|
}
|
|
@@ -106,15 +107,15 @@ thus causing execution of depending reactive function
|
|
|
106
107
|
`printContact` runs it reads `contact` and causes its
|
|
107
108
|
re-computation.
|
|
108
109
|
|
|
109
|
-
##
|
|
110
|
+
## Observable Objects
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
Observable objects are aimed to store data of
|
|
112
113
|
an application. All such objects are transparently hooked
|
|
113
114
|
to track access to their properties, both on reads and
|
|
114
115
|
writes.
|
|
115
116
|
|
|
116
117
|
``` typescript
|
|
117
|
-
class MyModel extends
|
|
118
|
+
class MyModel extends ObservableObject {
|
|
118
119
|
url: string = "https://github.com/nezaboodka/reactronic"
|
|
119
120
|
content: string = "transactional reactive state management"
|
|
120
121
|
timestamp: Date = Date.now()
|
|
@@ -122,19 +123,19 @@ class MyModel extends TriggeringObject {
|
|
|
122
123
|
```
|
|
123
124
|
|
|
124
125
|
In the example above, the class `MyModel` is based on
|
|
125
|
-
Reactronic's `
|
|
126
|
+
Reactronic's `ObservableObject` class and all its
|
|
126
127
|
properties `url`, `content`, and `timestamp` are hooked.
|
|
127
128
|
|
|
128
129
|
## Atomic Function
|
|
129
130
|
|
|
130
|
-
Atomic function makes changes in
|
|
131
|
+
Atomic function makes changes in observable objects
|
|
131
132
|
in atomic (transactional) way, thus provoking execution
|
|
132
133
|
of dependent reactive and cached functions. Atomic
|
|
133
134
|
function is instrumented with hooks to provide transparent atomicity
|
|
134
135
|
(by implicit context switching and isolation).
|
|
135
136
|
|
|
136
137
|
``` typescript
|
|
137
|
-
class MyModel extends
|
|
138
|
+
class MyModel extends ObservableObject {
|
|
138
139
|
// ...
|
|
139
140
|
@atomic
|
|
140
141
|
async load(url: string): Promise<void> {
|
|
@@ -181,18 +182,18 @@ chain of asynchronous operations is fully completed.
|
|
|
181
182
|
## Reactive & Cached Functions
|
|
182
183
|
|
|
183
184
|
Reactive function is automatically and immediately called
|
|
184
|
-
in response to changes in
|
|
185
|
+
in response to changes in observable objects made by
|
|
185
186
|
atomic functions. Cached function is called on-demand to
|
|
186
187
|
renew the result if it was marked as obsolete due to
|
|
187
188
|
changes made by an atomic functions. Reactive and cached
|
|
188
189
|
functions are instrumented with hooks to seamlessly
|
|
189
|
-
subscribe to those
|
|
190
|
+
subscribe to those observable objects and other cached
|
|
190
191
|
functions (dependencies), which are used during their
|
|
191
192
|
execution.
|
|
192
193
|
|
|
193
194
|
``` tsx
|
|
194
195
|
class MyView extends Component<{model: MyModel}> {
|
|
195
|
-
@
|
|
196
|
+
@cached
|
|
196
197
|
render(): React.JSX.Element {
|
|
197
198
|
return (
|
|
198
199
|
<div>
|
|
@@ -206,7 +207,7 @@ class MyView extends Component<{model: MyModel}> {
|
|
|
206
207
|
|
|
207
208
|
``` tsx
|
|
208
209
|
class Component<P> extends React.Component<P> {
|
|
209
|
-
@
|
|
210
|
+
@cached
|
|
210
211
|
render(): React.JSX.Element {
|
|
211
212
|
throw new Error('render method is undefined')
|
|
212
213
|
}
|
|
@@ -220,7 +221,7 @@ class Component<P> extends React.Component<P> {
|
|
|
220
221
|
} // EnsureUpToDate is subscribed to render
|
|
221
222
|
|
|
222
223
|
shouldComponentUpdate(): boolean {
|
|
223
|
-
const r = ReactiveSystem.
|
|
224
|
+
const r = ReactiveSystem.getDescriptor(this.render)
|
|
224
225
|
return !r.isUpToDate
|
|
225
226
|
}
|
|
226
227
|
|
|
@@ -249,14 +250,14 @@ cached value.
|
|
|
249
250
|
|
|
250
251
|
In general case, all reactive and cached functions
|
|
251
252
|
are automatically and immediately marked as obsolete
|
|
252
|
-
when changes are made in those
|
|
253
|
+
when changes are made in those observable objects and
|
|
253
254
|
other cached results that were used during their
|
|
254
255
|
execution. And once marked, the functions are
|
|
255
256
|
automatically executed again, either immediately (for
|
|
256
257
|
reactive functions) or on-demand (for cached functions).
|
|
257
258
|
|
|
258
259
|
Reactronic takes full care of tracking dependencies
|
|
259
|
-
between all the
|
|
260
|
+
between all the observable objects and reactive/cached
|
|
260
261
|
functions. With Reactronic, you no longer need to create
|
|
261
262
|
data change events in one set of objects, subscribe to
|
|
262
263
|
these events in other objects, and manually maintain
|
|
@@ -322,22 +323,22 @@ NPM: `npm install reactronic`
|
|
|
322
323
|
|
|
323
324
|
// Classes
|
|
324
325
|
|
|
325
|
-
class
|
|
326
|
-
class
|
|
326
|
+
class AtomicObject { }
|
|
327
|
+
class ObservableObject { }
|
|
327
328
|
|
|
328
329
|
// Decorators & Operators
|
|
329
330
|
|
|
330
|
-
function
|
|
331
|
-
function
|
|
331
|
+
function observable(boolean) // field only
|
|
332
|
+
function observable(proto, prop) // field only
|
|
332
333
|
function atomic(proto, prop, pd) // method only
|
|
333
|
-
function
|
|
334
|
-
function
|
|
335
|
-
function options(value: Partial<
|
|
334
|
+
function reaction(proto, prop, pd) // method only
|
|
335
|
+
function cache(proto, prop, pd) // method only
|
|
336
|
+
function options(value: Partial<ReactivityOptions>): F<any>
|
|
336
337
|
|
|
337
|
-
function
|
|
338
|
-
function
|
|
338
|
+
function runNonReactively<T>(func: F<T>, ...args: any[]): T
|
|
339
|
+
function runSensitively<T>(sensitivity: Sensitivity, func: F<T>, ...args: any[]): T
|
|
339
340
|
|
|
340
|
-
// SnapshotOptions,
|
|
341
|
+
// SnapshotOptions, ReactivityOptions, Kind, Reentrance, Indicator, LoggingOptions, ProfilingOptions
|
|
341
342
|
|
|
342
343
|
export type SnapshotOptions = {
|
|
343
344
|
readonly hint?: string
|
|
@@ -347,12 +348,12 @@ export type SnapshotOptions = {
|
|
|
347
348
|
readonly token?: any
|
|
348
349
|
}
|
|
349
350
|
|
|
350
|
-
type
|
|
351
|
+
type ReactivityOptions = {
|
|
351
352
|
readonly kind: Kind
|
|
352
353
|
readonly isolation: Isolation
|
|
353
354
|
readonly order: number
|
|
354
355
|
readonly noSideEffects: boolean
|
|
355
|
-
readonly
|
|
356
|
+
readonly observableArgs: boolean
|
|
356
357
|
readonly throttling: number // milliseconds, -1 is immediately, Number.MAX_SAFE_INTEGER is never
|
|
357
358
|
readonly reentrance: Reentrance
|
|
358
359
|
readonly journal: Journal | undefined
|
|
@@ -363,8 +364,8 @@ type MemberOptions = {
|
|
|
363
364
|
enum Kind {
|
|
364
365
|
plain = 0,
|
|
365
366
|
atomic = 1,
|
|
366
|
-
|
|
367
|
-
|
|
367
|
+
reaction = 2,
|
|
368
|
+
cache = 3
|
|
368
369
|
}
|
|
369
370
|
|
|
370
371
|
enum Reentrance {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare enum Mode {
|
|
2
|
+
default = 0,
|
|
3
|
+
autonomous = 1,
|
|
4
|
+
manualMount = 2,
|
|
5
|
+
rootNode = 4
|
|
6
|
+
}
|
|
7
|
+
export declare enum Priority {
|
|
8
|
+
realtime = 0,
|
|
9
|
+
normal = 1,
|
|
10
|
+
background = 2
|
|
11
|
+
}
|
|
12
|
+
export declare enum Kind {
|
|
13
|
+
plain = 0,
|
|
14
|
+
atomic = 1,
|
|
15
|
+
reactive = 2,
|
|
16
|
+
cached = 3
|
|
17
|
+
}
|
|
18
|
+
export declare enum Reentrance {
|
|
19
|
+
preventWithError = 1,
|
|
20
|
+
waitAndRestart = 0,
|
|
21
|
+
cancelPrevious = -1,
|
|
22
|
+
cancelAndWaitPrevious = -2,
|
|
23
|
+
overwritePrevious = -3,
|
|
24
|
+
runSideBySide = -4
|
|
25
|
+
}
|
|
26
|
+
export declare enum Isolation {
|
|
27
|
+
joinToCurrentTransaction = 0,
|
|
28
|
+
joinAsNestedTransaction = 1,
|
|
29
|
+
disjoinFromOuterTransaction = 2,
|
|
30
|
+
disjoinFromOuterAndInnerTransactions = 3,
|
|
31
|
+
disjoinForInternalDisposal = 4
|
|
32
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export var Mode;
|
|
2
|
+
(function (Mode) {
|
|
3
|
+
Mode[Mode["default"] = 0] = "default";
|
|
4
|
+
Mode[Mode["autonomous"] = 1] = "autonomous";
|
|
5
|
+
Mode[Mode["manualMount"] = 2] = "manualMount";
|
|
6
|
+
Mode[Mode["rootNode"] = 4] = "rootNode";
|
|
7
|
+
})(Mode || (Mode = {}));
|
|
8
|
+
export var Priority;
|
|
9
|
+
(function (Priority) {
|
|
10
|
+
Priority[Priority["realtime"] = 0] = "realtime";
|
|
11
|
+
Priority[Priority["normal"] = 1] = "normal";
|
|
12
|
+
Priority[Priority["background"] = 2] = "background";
|
|
13
|
+
})(Priority || (Priority = {}));
|
|
14
|
+
export var Kind;
|
|
15
|
+
(function (Kind) {
|
|
16
|
+
Kind[Kind["plain"] = 0] = "plain";
|
|
17
|
+
Kind[Kind["atomic"] = 1] = "atomic";
|
|
18
|
+
Kind[Kind["reactive"] = 2] = "reactive";
|
|
19
|
+
Kind[Kind["cached"] = 3] = "cached";
|
|
20
|
+
})(Kind || (Kind = {}));
|
|
21
|
+
export var Reentrance;
|
|
22
|
+
(function (Reentrance) {
|
|
23
|
+
Reentrance[Reentrance["preventWithError"] = 1] = "preventWithError";
|
|
24
|
+
Reentrance[Reentrance["waitAndRestart"] = 0] = "waitAndRestart";
|
|
25
|
+
Reentrance[Reentrance["cancelPrevious"] = -1] = "cancelPrevious";
|
|
26
|
+
Reentrance[Reentrance["cancelAndWaitPrevious"] = -2] = "cancelAndWaitPrevious";
|
|
27
|
+
Reentrance[Reentrance["overwritePrevious"] = -3] = "overwritePrevious";
|
|
28
|
+
Reentrance[Reentrance["runSideBySide"] = -4] = "runSideBySide";
|
|
29
|
+
})(Reentrance || (Reentrance = {}));
|
|
30
|
+
export var Isolation;
|
|
31
|
+
(function (Isolation) {
|
|
32
|
+
Isolation[Isolation["joinToCurrentTransaction"] = 0] = "joinToCurrentTransaction";
|
|
33
|
+
Isolation[Isolation["joinAsNestedTransaction"] = 1] = "joinAsNestedTransaction";
|
|
34
|
+
Isolation[Isolation["disjoinFromOuterTransaction"] = 2] = "disjoinFromOuterTransaction";
|
|
35
|
+
Isolation[Isolation["disjoinFromOuterAndInnerTransactions"] = 3] = "disjoinFromOuterAndInnerTransactions";
|
|
36
|
+
Isolation[Isolation["disjoinForInternalDisposal"] = 4] = "disjoinForInternalDisposal";
|
|
37
|
+
})(Isolation || (Isolation = {}));
|
|
@@ -7,20 +7,20 @@ 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 {
|
|
11
|
-
import {
|
|
12
|
-
export class
|
|
13
|
-
constructor(
|
|
10
|
+
import { ObservableObject } from "./core/Mvcc.js";
|
|
11
|
+
import { reactive } from "./System.js";
|
|
12
|
+
export class ReactiveOperationEx extends ObservableObject {
|
|
13
|
+
constructor(operation) {
|
|
14
14
|
super();
|
|
15
|
-
this.
|
|
15
|
+
this.operation = operation;
|
|
16
16
|
}
|
|
17
17
|
launch() {
|
|
18
|
-
return this.
|
|
18
|
+
return this.operation();
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
__decorate([
|
|
22
|
-
|
|
22
|
+
reactive,
|
|
23
23
|
__metadata("design:type", Function),
|
|
24
24
|
__metadata("design:paramtypes", []),
|
|
25
25
|
__metadata("design:returntype", Object)
|
|
26
|
-
],
|
|
26
|
+
], ReactiveOperationEx.prototype, "launch", null);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LoggingOptions } from "./Logging.js";
|
|
2
2
|
export { LoggingLevel } from "./Logging.js";
|
|
3
|
+
import { Kind, Reentrance, Isolation } from "./Enums.js";
|
|
3
4
|
export type { LoggingOptions, ProfilingOptions } from "./Logging.js";
|
|
4
5
|
import { Journal } from "./core/Journal.js";
|
|
5
6
|
import { Indicator } from "./core/Indicator.js";
|
|
@@ -10,12 +11,12 @@ export type SnapshotOptions = {
|
|
|
10
11
|
readonly logging?: Partial<LoggingOptions>;
|
|
11
12
|
readonly token?: any;
|
|
12
13
|
};
|
|
13
|
-
export type
|
|
14
|
+
export type ReactivityOptions = {
|
|
14
15
|
readonly kind: Kind;
|
|
15
16
|
readonly isolation: Isolation;
|
|
16
17
|
readonly order: number;
|
|
17
18
|
readonly noSideEffects: boolean;
|
|
18
|
-
readonly
|
|
19
|
+
readonly observableArgs: boolean;
|
|
19
20
|
readonly throttling: number;
|
|
20
21
|
readonly reentrance: Reentrance;
|
|
21
22
|
readonly allowObsoleteToFinish: boolean;
|
|
@@ -23,35 +24,14 @@ export type MemberOptions = {
|
|
|
23
24
|
readonly indicator: Indicator | null;
|
|
24
25
|
readonly logging?: Partial<LoggingOptions>;
|
|
25
26
|
};
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
atomic = 1,
|
|
29
|
-
reactive = 2,
|
|
30
|
-
cached = 3
|
|
31
|
-
}
|
|
32
|
-
export declare enum Reentrance {
|
|
33
|
-
preventWithError = 1,
|
|
34
|
-
waitAndRestart = 0,
|
|
35
|
-
cancelPrevious = -1,
|
|
36
|
-
cancelAndWaitPrevious = -2,
|
|
37
|
-
overwritePrevious = -3,
|
|
38
|
-
runSideBySide = -4
|
|
39
|
-
}
|
|
40
|
-
export declare enum Isolation {
|
|
41
|
-
joinToCurrentTransaction = 0,
|
|
42
|
-
joinAsNestedTransaction = 1,
|
|
43
|
-
disjoinFromOuterTransaction = 2,
|
|
44
|
-
disjoinFromOuterAndInnerTransactions = 3,
|
|
45
|
-
disjoinForInternalDisposal = 4
|
|
46
|
-
}
|
|
47
|
-
export type Operation<T> = {
|
|
48
|
-
readonly options: MemberOptions;
|
|
27
|
+
export type ReactiveOperation<T> = {
|
|
28
|
+
readonly options: ReactivityOptions;
|
|
49
29
|
readonly args: ReadonlyArray<any>;
|
|
50
30
|
readonly result: T;
|
|
51
31
|
readonly error: any;
|
|
52
32
|
readonly stamp: number;
|
|
53
33
|
readonly isReusable: boolean;
|
|
54
|
-
configure(options: Partial<
|
|
34
|
+
configure(options: Partial<ReactivityOptions>): ReactivityOptions;
|
|
55
35
|
markObsolete(): void;
|
|
56
|
-
pullLastResult(args?: any[]):
|
|
36
|
+
pullLastResult(args?: any[]): any;
|
|
57
37
|
};
|
|
@@ -1,25 +1 @@
|
|
|
1
1
|
export { LoggingLevel } from "./Logging.js";
|
|
2
|
-
export var Kind;
|
|
3
|
-
(function (Kind) {
|
|
4
|
-
Kind[Kind["plain"] = 0] = "plain";
|
|
5
|
-
Kind[Kind["atomic"] = 1] = "atomic";
|
|
6
|
-
Kind[Kind["reactive"] = 2] = "reactive";
|
|
7
|
-
Kind[Kind["cached"] = 3] = "cached";
|
|
8
|
-
})(Kind || (Kind = {}));
|
|
9
|
-
export var Reentrance;
|
|
10
|
-
(function (Reentrance) {
|
|
11
|
-
Reentrance[Reentrance["preventWithError"] = 1] = "preventWithError";
|
|
12
|
-
Reentrance[Reentrance["waitAndRestart"] = 0] = "waitAndRestart";
|
|
13
|
-
Reentrance[Reentrance["cancelPrevious"] = -1] = "cancelPrevious";
|
|
14
|
-
Reentrance[Reentrance["cancelAndWaitPrevious"] = -2] = "cancelAndWaitPrevious";
|
|
15
|
-
Reentrance[Reentrance["overwritePrevious"] = -3] = "overwritePrevious";
|
|
16
|
-
Reentrance[Reentrance["runSideBySide"] = -4] = "runSideBySide";
|
|
17
|
-
})(Reentrance || (Reentrance = {}));
|
|
18
|
-
export var Isolation;
|
|
19
|
-
(function (Isolation) {
|
|
20
|
-
Isolation[Isolation["joinToCurrentTransaction"] = 0] = "joinToCurrentTransaction";
|
|
21
|
-
Isolation[Isolation["joinAsNestedTransaction"] = 1] = "joinAsNestedTransaction";
|
|
22
|
-
Isolation[Isolation["disjoinFromOuterTransaction"] = 2] = "disjoinFromOuterTransaction";
|
|
23
|
-
Isolation[Isolation["disjoinFromOuterAndInnerTransactions"] = 3] = "disjoinFromOuterAndInnerTransactions";
|
|
24
|
-
Isolation[Isolation["disjoinForInternalDisposal"] = 4] = "disjoinForInternalDisposal";
|
|
25
|
-
})(Isolation || (Isolation = {}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare abstract class Pipe<T> extends
|
|
1
|
+
import { ObservableObject } from "./core/Mvcc.js";
|
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export class Pipe extends
|
|
1
|
+
import { ObservableObject } from "./core/Mvcc.js";
|
|
2
|
+
export class Pipe extends ObservableObject {
|
|
3
3
|
static create(hint, capacity) { throw new Error("not implemented"); }
|
|
4
4
|
}
|
|
@@ -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
|
+
nonReactively(): 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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runAtomically, runNonReactively } from "./System.js";
|
|
2
2
|
export function refs(owner) {
|
|
3
3
|
return new Proxy(owner, RefGettingProxy);
|
|
4
4
|
}
|
|
@@ -27,8 +27,8 @@ export class Ref {
|
|
|
27
27
|
else
|
|
28
28
|
this.owner[this.name][this.index] = value;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
return
|
|
30
|
+
nonReactively() {
|
|
31
|
+
return runNonReactively(() => this.variable);
|
|
32
32
|
}
|
|
33
33
|
observe() {
|
|
34
34
|
return this.variable;
|
|
@@ -52,7 +52,7 @@ export class ToggleRef extends Ref {
|
|
|
52
52
|
toggle() {
|
|
53
53
|
const o = this.owner;
|
|
54
54
|
const p = this.name;
|
|
55
|
-
|
|
55
|
+
runAtomically({ hint: `toggle ${o.constructor.name}.${p}` }, () => {
|
|
56
56
|
const v = o[p];
|
|
57
57
|
const isOn = v === this.valueOn || (v instanceof Ref && this.valueOn instanceof Ref &&
|
|
58
58
|
Ref.sameRefs(v, this.valueOn));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { F } from "./util/Utils.js";
|
|
2
|
+
import { ReactiveOperation, ReactivityOptions, LoggingOptions, ProfilingOptions, SnapshotOptions } from "./Options.js";
|
|
3
|
+
export declare class ReactiveSystem {
|
|
4
|
+
static why(brief?: boolean): string;
|
|
5
|
+
static getRevisionOf(obj: any): number;
|
|
6
|
+
static takeSnapshot<T>(obj: T): T;
|
|
7
|
+
static get reactivityAutoStartDisabled(): boolean;
|
|
8
|
+
static set reactivityAutoStartDisabled(value: boolean);
|
|
9
|
+
static get isLogging(): boolean;
|
|
10
|
+
static get loggingOptions(): LoggingOptions;
|
|
11
|
+
static setLoggingMode(isOn: boolean, options?: LoggingOptions): void;
|
|
12
|
+
static setLoggingHint<T extends object>(obj: T, name: string | undefined): void;
|
|
13
|
+
static getLoggingHint<T extends object>(obj: T, full?: boolean): string | undefined;
|
|
14
|
+
static setProfilingMode(isOn: boolean, options?: Partial<ProfilingOptions>): void;
|
|
15
|
+
}
|
|
16
|
+
export declare function runAtomically<T>(func: F<T>, ...args: any[]): T;
|
|
17
|
+
export declare function runAtomically<T>(options: SnapshotOptions, func: F<T>, ...args: any[]): T;
|
|
18
|
+
export declare function runNonReactively<T>(func: F<T>, ...args: any[]): T;
|
|
19
|
+
export declare function runSensitively<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
20
|
+
export declare function runContextually<T>(p: Promise<T>): Promise<T>;
|
|
21
|
+
export declare function manageReactiveOperation<T>(method: F<T>): ReactiveOperation<T>;
|
|
22
|
+
export declare function configureCurrentReactiveOperation(options: Partial<ReactivityOptions>): ReactivityOptions;
|
|
23
|
+
export declare function disposeObservableObject(obj: any): void;
|
|
24
|
+
export declare function observable(enabled: boolean): (proto: object, prop: PropertyKey) => any;
|
|
25
|
+
export declare function observable<T>(proto: object, prop: PropertyKey): any;
|
|
26
|
+
export declare function atomic(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
27
|
+
export declare function reactive(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
28
|
+
export declare function cached(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
29
|
+
export declare function options(value: Partial<ReactivityOptions>): F<any>;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { Log } from "./util/Dbg.js";
|
|
2
|
-
import { Kind, Isolation } from "./
|
|
2
|
+
import { Kind, Isolation } from "./Enums.js";
|
|
3
3
|
import { Meta, ObjectHandle } from "./core/Data.js";
|
|
4
4
|
import { Changeset } from "./core/Changeset.js";
|
|
5
5
|
import { Mvcc } from "./core/Mvcc.js";
|
|
6
6
|
import { Transaction } from "./core/Transaction.js";
|
|
7
|
-
import {
|
|
7
|
+
import { ReactiveOperationImpl } from "./core/Operation.js";
|
|
8
8
|
export class ReactiveSystem {
|
|
9
|
-
static why(brief = false) { return brief ?
|
|
10
|
-
static getOperation(method) { return OperationImpl.getControllerOf(method); }
|
|
11
|
-
static pullLastResult(method, args) { return ReactiveSystem.getOperation(method).pullLastResult(args); }
|
|
12
|
-
static configureCurrentOperation(options) { return OperationImpl.configureImpl(undefined, options); }
|
|
9
|
+
static why(brief = false) { return brief ? ReactiveOperationImpl.briefWhy() : ReactiveOperationImpl.why(); }
|
|
13
10
|
static getRevisionOf(obj) { return obj[Meta.Revision]; }
|
|
14
11
|
static takeSnapshot(obj) { return Changeset.takeSnapshot(obj); }
|
|
15
|
-
static dispose(obj) { Changeset.dispose(obj); }
|
|
16
12
|
static get reactivityAutoStartDisabled() { return Mvcc.reactivityAutoStartDisabled; }
|
|
17
13
|
static set reactivityAutoStartDisabled(value) { Mvcc.reactivityAutoStartDisabled = value; }
|
|
18
14
|
static get isLogging() { return Log.isOn; }
|
|
@@ -22,7 +18,7 @@ export class ReactiveSystem {
|
|
|
22
18
|
static getLoggingHint(obj, full = false) { return ObjectHandle.getHint(obj, full); }
|
|
23
19
|
static setProfilingMode(isOn, options) { Mvcc.setProfilingMode(isOn, options); }
|
|
24
20
|
}
|
|
25
|
-
export function
|
|
21
|
+
export function runAtomically(p1, p2, p3) {
|
|
26
22
|
if (p1 instanceof Function) {
|
|
27
23
|
if (p2 !== undefined)
|
|
28
24
|
return Transaction.run(null, p1, ...p2);
|
|
@@ -36,16 +32,25 @@ export function atomicRun(p1, p2, p3) {
|
|
|
36
32
|
return Transaction.run(p1, p2);
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
|
-
export function
|
|
40
|
-
return
|
|
35
|
+
export function runNonReactively(func, ...args) {
|
|
36
|
+
return ReactiveOperationImpl.proceedWithinGivenLaunch(undefined, func, ...args);
|
|
41
37
|
}
|
|
42
|
-
export function
|
|
38
|
+
export function runSensitively(sensitivity, func, ...args) {
|
|
43
39
|
return Mvcc.sensitive(sensitivity, func, ...args);
|
|
44
40
|
}
|
|
45
|
-
export function
|
|
41
|
+
export function runContextually(p) {
|
|
46
42
|
throw new Error("not implemented yet");
|
|
47
43
|
}
|
|
48
|
-
export function
|
|
44
|
+
export function manageReactiveOperation(method) {
|
|
45
|
+
return ReactiveOperationImpl.manageReactiveOperation(method);
|
|
46
|
+
}
|
|
47
|
+
export function configureCurrentReactiveOperation(options) {
|
|
48
|
+
return ReactiveOperationImpl.configureImpl(undefined, options);
|
|
49
|
+
}
|
|
50
|
+
export function disposeObservableObject(obj) {
|
|
51
|
+
Changeset.dispose(obj);
|
|
52
|
+
}
|
|
53
|
+
export function observable(protoOrEnabled, prop) {
|
|
49
54
|
if (typeof (protoOrEnabled) === "boolean") {
|
|
50
55
|
return (proto, prop) => {
|
|
51
56
|
return Mvcc.decorateData(protoOrEnabled, proto, prop);
|
|
@@ -54,28 +59,28 @@ export function trigger(protoOrEnabled, prop) {
|
|
|
54
59
|
else
|
|
55
60
|
return Mvcc.decorateData(true, protoOrEnabled, prop);
|
|
56
61
|
}
|
|
57
|
-
export function
|
|
62
|
+
export function atomic(proto, prop, pd) {
|
|
58
63
|
const opts = {
|
|
59
64
|
kind: Kind.atomic,
|
|
60
65
|
isolation: Isolation.joinToCurrentTransaction,
|
|
61
66
|
};
|
|
62
|
-
return Mvcc.decorateOperation(true,
|
|
67
|
+
return Mvcc.decorateOperation(true, atomic, opts, proto, prop, pd);
|
|
63
68
|
}
|
|
64
|
-
export function
|
|
69
|
+
export function reactive(proto, prop, pd) {
|
|
65
70
|
const opts = {
|
|
66
71
|
kind: Kind.reactive,
|
|
67
72
|
isolation: Isolation.joinAsNestedTransaction,
|
|
68
73
|
throttling: -1,
|
|
69
74
|
};
|
|
70
|
-
return Mvcc.decorateOperation(true,
|
|
75
|
+
return Mvcc.decorateOperation(true, reactive, opts, proto, prop, pd);
|
|
71
76
|
}
|
|
72
|
-
export function
|
|
77
|
+
export function cached(proto, prop, pd) {
|
|
73
78
|
const opts = {
|
|
74
79
|
kind: Kind.cached,
|
|
75
80
|
isolation: Isolation.joinToCurrentTransaction,
|
|
76
81
|
noSideEffects: true,
|
|
77
82
|
};
|
|
78
|
-
return Mvcc.decorateOperation(true,
|
|
83
|
+
return Mvcc.decorateOperation(true, cached, opts, proto, prop, pd);
|
|
79
84
|
}
|
|
80
85
|
export function options(value) {
|
|
81
86
|
return Mvcc.decorateOperationParametrized(options, value);
|
|
@@ -4,20 +4,22 @@ export type { MergedItem, MergeListReader } from "./util/MergeList.js";
|
|
|
4
4
|
export { SealedArray } from "./util/SealedArray.js";
|
|
5
5
|
export { SealedMap } from "./util/SealedMap.js";
|
|
6
6
|
export { SealedSet } from "./util/SealedSet.js";
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
7
|
+
export { LoggingLevel } from "./Options.js";
|
|
8
|
+
export { Mode, Priority, Kind, Reentrance, Isolation } from "./Enums.js";
|
|
9
|
+
export type { ReactiveOperation, ReactivityOptions, SnapshotOptions, LoggingOptions, ProfilingOptions } from "./Options.js";
|
|
9
10
|
export type { Worker } from "./Worker.js";
|
|
10
11
|
export { Ref, ToggleRef, refs, toggleRefs, customToggleRefs } from "./Ref.js";
|
|
11
12
|
export type { BoolOnly, GivenTypeOnly } from "./Ref.js";
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
13
|
+
export { AtomicObject, ObservableObject } from "./core/Mvcc.js";
|
|
14
|
+
export { AtomicArray, ObservableArray } from "./core/MvccArray.js";
|
|
15
|
+
export { AtomicMap, ObservableMap } from "./core/MvccMap.js";
|
|
15
16
|
export { Changeset } from "./core/Changeset.js";
|
|
16
17
|
export { Transaction } from "./core/Transaction.js";
|
|
17
18
|
export { Indicator } from "./core/Indicator.js";
|
|
18
19
|
export { Journal } from "./core/Journal.js";
|
|
19
|
-
export {
|
|
20
|
-
export { ReactiveSystem,
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export
|
|
20
|
+
export { runAtomically, runNonReactively, runSensitively, runContextually, manageReactiveOperation, configureCurrentReactiveOperation, disposeObservableObject } from "./System.js";
|
|
21
|
+
export { ReactiveSystem, observable, atomic, reactive, cached, options } from "./System.js";
|
|
22
|
+
export { ReactiveOperationEx } from "./OperationEx.js";
|
|
23
|
+
export { ReactiveTreeNode, BaseDriver, ReactiveTreeVariable } from "./core/TreeNode.js";
|
|
24
|
+
export { ReactiveTree } from "./core/Tree.js";
|
|
25
|
+
export type { Script, ScriptAsync, Handler, ReactiveTreeNodeDecl, ReactiveTreeNodeDriver, ReactiveTreeNodeContext } from "./core/TreeNode.js";
|