reactronic 0.93.25026 → 0.94.25028
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 +32 -32
- 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.js +1 -1
- package/build/dist/source/{ReactiveSystem.d.ts → System.d.ts} +9 -10
- package/build/dist/source/{ReactiveSystem.js → System.js} +20 -15
- 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 +205 -205
- 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 +19 -0
- package/build/dist/source/core/Tree.js +99 -0
- package/build/dist/source/core/TreeNode.d.ts +124 -0
- package/build/dist/source/core/{ReactiveNode.js → TreeNode.js} +56 -163
- package/package.json +1 -1
- package/build/dist/source/ReactiveLoop.d.ts +0 -7
- package/build/dist/source/core/ReactiveNode.d.ts +0 -107
package/README.md
CHANGED
|
@@ -20,20 +20,20 @@ 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
31
|
- **Atomic Block** - a code block that makes changes
|
|
32
|
-
in
|
|
32
|
+
in observable objects in atomic way ("all or
|
|
33
33
|
nothing");
|
|
34
34
|
- **Reaction** - a function that is
|
|
35
35
|
(re-)executed in response to changes made in
|
|
36
|
-
|
|
36
|
+
observable objects by atomic actions;
|
|
37
37
|
- **Cache** - a function which result is remembered
|
|
38
38
|
and, if becomes obsolete, causes function to
|
|
39
39
|
re-execute on-demand.
|
|
@@ -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 ObservableObject {
|
|
52
52
|
name: string = 'Nezaboodka Software'
|
|
53
53
|
email: string = 'contact@nezaboodka.com'
|
|
54
54
|
|
|
@@ -58,7 +58,7 @@ class Demo extends TriggeringObject {
|
|
|
58
58
|
this.email = email
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
@
|
|
61
|
+
@reactive
|
|
62
62
|
printContact(): void {
|
|
63
63
|
// depends on `name` and `email` and reacts to their changes
|
|
64
64
|
if (this.email.indexOf('@') >= 0)
|
|
@@ -68,7 +68,7 @@ class Demo extends TriggeringObject {
|
|
|
68
68
|
}
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
In the example above, `Demo` is
|
|
71
|
+
In the example above, `Demo` is an observable object,
|
|
72
72
|
meaning that access to its fields are seamlessly tracked
|
|
73
73
|
to determine dependent reactive and cached functions.
|
|
74
74
|
Reactive function `printContact` reads `name` and `email`
|
|
@@ -80,16 +80,16 @@ Here is an example of a cached result that is
|
|
|
80
80
|
(re-)computed on-demand:
|
|
81
81
|
|
|
82
82
|
``` typescript
|
|
83
|
-
class Demo extends
|
|
83
|
+
class Demo extends ObservableObject {
|
|
84
84
|
name: string = 'Nezaboodka Software'
|
|
85
85
|
email: string = 'contact@nezaboodka.com'
|
|
86
86
|
|
|
87
|
-
@
|
|
87
|
+
@cached
|
|
88
88
|
get contact(): string {
|
|
89
89
|
return this.name + ' <' + this.email + '>'
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
@
|
|
92
|
+
@reactive
|
|
93
93
|
printContact(): void {
|
|
94
94
|
if (this.contact !== '')
|
|
95
95
|
Console.log(this.contact)
|
|
@@ -107,15 +107,15 @@ thus causing execution of depending reactive function
|
|
|
107
107
|
`printContact` runs it reads `contact` and causes its
|
|
108
108
|
re-computation.
|
|
109
109
|
|
|
110
|
-
##
|
|
110
|
+
## Observable Objects
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
Observable objects are aimed to store data of
|
|
113
113
|
an application. All such objects are transparently hooked
|
|
114
114
|
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 ObservableObject {
|
|
119
119
|
url: string = "https://github.com/nezaboodka/reactronic"
|
|
120
120
|
content: string = "transactional reactive state management"
|
|
121
121
|
timestamp: Date = Date.now()
|
|
@@ -123,19 +123,19 @@ class MyModel extends TriggeringObject {
|
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
In the example above, the class `MyModel` is based on
|
|
126
|
-
Reactronic's `
|
|
126
|
+
Reactronic's `ObservableObject` class and all its
|
|
127
127
|
properties `url`, `content`, and `timestamp` are hooked.
|
|
128
128
|
|
|
129
129
|
## Atomic Function
|
|
130
130
|
|
|
131
|
-
Atomic function makes changes in
|
|
131
|
+
Atomic function makes changes in observable objects
|
|
132
132
|
in atomic (transactional) way, thus provoking execution
|
|
133
133
|
of dependent reactive and cached functions. Atomic
|
|
134
134
|
function is instrumented with hooks to provide transparent atomicity
|
|
135
135
|
(by implicit context switching and isolation).
|
|
136
136
|
|
|
137
137
|
``` typescript
|
|
138
|
-
class MyModel extends
|
|
138
|
+
class MyModel extends ObservableObject {
|
|
139
139
|
// ...
|
|
140
140
|
@atomic
|
|
141
141
|
async load(url: string): Promise<void> {
|
|
@@ -182,18 +182,18 @@ chain of asynchronous operations is fully completed.
|
|
|
182
182
|
## Reactive & Cached Functions
|
|
183
183
|
|
|
184
184
|
Reactive function is automatically and immediately called
|
|
185
|
-
in response to changes in
|
|
185
|
+
in response to changes in observable objects made by
|
|
186
186
|
atomic functions. Cached function is called on-demand to
|
|
187
187
|
renew the result if it was marked as obsolete due to
|
|
188
188
|
changes made by an atomic functions. Reactive and cached
|
|
189
189
|
functions are instrumented with hooks to seamlessly
|
|
190
|
-
subscribe to those
|
|
190
|
+
subscribe to those observable objects and other cached
|
|
191
191
|
functions (dependencies), which are used during their
|
|
192
192
|
execution.
|
|
193
193
|
|
|
194
194
|
``` tsx
|
|
195
195
|
class MyView extends Component<{model: MyModel}> {
|
|
196
|
-
@
|
|
196
|
+
@cached
|
|
197
197
|
render(): React.JSX.Element {
|
|
198
198
|
return (
|
|
199
199
|
<div>
|
|
@@ -207,12 +207,12 @@ class MyView extends Component<{model: MyModel}> {
|
|
|
207
207
|
|
|
208
208
|
``` tsx
|
|
209
209
|
class Component<P> extends React.Component<P> {
|
|
210
|
-
@
|
|
210
|
+
@cached
|
|
211
211
|
render(): React.JSX.Element {
|
|
212
212
|
throw new Error('render method is undefined')
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
@
|
|
215
|
+
@reactive // called in response to changes
|
|
216
216
|
ensureUpToDate(): void {
|
|
217
217
|
if (this.shouldComponentUpdate()) {
|
|
218
218
|
// Ask React to re-render
|
|
@@ -221,7 +221,7 @@ class Component<P> extends React.Component<P> {
|
|
|
221
221
|
} // EnsureUpToDate is subscribed to render
|
|
222
222
|
|
|
223
223
|
shouldComponentUpdate(): boolean {
|
|
224
|
-
const r = ReactiveSystem.
|
|
224
|
+
const r = ReactiveSystem.getDescriptor(this.render)
|
|
225
225
|
return !r.isUpToDate
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -250,14 +250,14 @@ cached value.
|
|
|
250
250
|
|
|
251
251
|
In general case, all reactive and cached functions
|
|
252
252
|
are automatically and immediately marked as obsolete
|
|
253
|
-
when changes are made in those
|
|
253
|
+
when changes are made in those observable objects and
|
|
254
254
|
other cached results that were used during their
|
|
255
255
|
execution. And once marked, the functions are
|
|
256
256
|
automatically executed again, either immediately (for
|
|
257
257
|
reactive functions) or on-demand (for cached functions).
|
|
258
258
|
|
|
259
259
|
Reactronic takes full care of tracking dependencies
|
|
260
|
-
between all the
|
|
260
|
+
between all the observable objects and reactive/cached
|
|
261
261
|
functions. With Reactronic, you no longer need to create
|
|
262
262
|
data change events in one set of objects, subscribe to
|
|
263
263
|
these events in other objects, and manually maintain
|
|
@@ -323,22 +323,22 @@ NPM: `npm install reactronic`
|
|
|
323
323
|
|
|
324
324
|
// Classes
|
|
325
325
|
|
|
326
|
-
class
|
|
327
|
-
class
|
|
326
|
+
class AtomicObject { }
|
|
327
|
+
class ObservableObject { }
|
|
328
328
|
|
|
329
329
|
// Decorators & Operators
|
|
330
330
|
|
|
331
|
-
function
|
|
332
|
-
function
|
|
331
|
+
function observable(boolean) // field only
|
|
332
|
+
function observable(proto, prop) // field only
|
|
333
333
|
function atomic(proto, prop, pd) // method only
|
|
334
334
|
function reaction(proto, prop, pd) // method only
|
|
335
335
|
function cache(proto, prop, pd) // method only
|
|
336
|
-
function options(value: Partial<
|
|
336
|
+
function options(value: Partial<ReactivityOptions>): F<any>
|
|
337
337
|
|
|
338
338
|
function runNonReactively<T>(func: F<T>, ...args: any[]): T
|
|
339
339
|
function runSensitively<T>(sensitivity: Sensitivity, func: F<T>, ...args: any[]): T
|
|
340
340
|
|
|
341
|
-
// SnapshotOptions,
|
|
341
|
+
// SnapshotOptions, ReactivityOptions, Kind, Reentrance, Indicator, LoggingOptions, ProfilingOptions
|
|
342
342
|
|
|
343
343
|
export type SnapshotOptions = {
|
|
344
344
|
readonly hint?: string
|
|
@@ -348,12 +348,12 @@ export type SnapshotOptions = {
|
|
|
348
348
|
readonly token?: any
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
type
|
|
351
|
+
type ReactivityOptions = {
|
|
352
352
|
readonly kind: Kind
|
|
353
353
|
readonly isolation: Isolation
|
|
354
354
|
readonly order: number
|
|
355
355
|
readonly noSideEffects: boolean
|
|
356
|
-
readonly
|
|
356
|
+
readonly observableArgs: boolean
|
|
357
357
|
readonly throttling: number // milliseconds, -1 is immediately, Number.MAX_SAFE_INTEGER is never
|
|
358
358
|
readonly reentrance: Reentrance
|
|
359
359
|
readonly journal: Journal | undefined
|
|
@@ -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
|
-
reaction = 2,
|
|
30
|
-
cache = 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["reaction"] = 2] = "reaction";
|
|
7
|
-
Kind[Kind["cache"] = 3] = "cache";
|
|
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
|
}
|
package/build/dist/source/Ref.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { F } from "./util/Utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ReactiveOperation, ReactivityOptions, LoggingOptions, ProfilingOptions, SnapshotOptions } from "./Options.js";
|
|
3
3
|
export declare class ReactiveSystem {
|
|
4
4
|
static why(brief?: boolean): string;
|
|
5
|
-
static getOperation<T>(method: F<T>): Operation<T>;
|
|
6
|
-
static pullLastResult<T>(method: F<Promise<T>>, args?: any[]): T | undefined;
|
|
7
|
-
static configureCurrentOperation(options: Partial<MemberOptions>): MemberOptions;
|
|
8
5
|
static getRevisionOf(obj: any): number;
|
|
9
6
|
static takeSnapshot<T>(obj: T): T;
|
|
10
|
-
static dispose(obj: any): void;
|
|
11
7
|
static get reactivityAutoStartDisabled(): boolean;
|
|
12
8
|
static set reactivityAutoStartDisabled(value: boolean);
|
|
13
9
|
static get isLogging(): boolean;
|
|
@@ -22,9 +18,12 @@ export declare function runAtomically<T>(options: SnapshotOptions, func: F<T>, .
|
|
|
22
18
|
export declare function runNonReactively<T>(func: F<T>, ...args: any[]): T;
|
|
23
19
|
export declare function runSensitively<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
24
20
|
export declare function runContextually<T>(p: Promise<T>): Promise<T>;
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
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;
|
|
27
26
|
export declare function atomic(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function options(value: Partial<
|
|
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; }
|
|
@@ -37,7 +33,7 @@ export function runAtomically(p1, p2, p3) {
|
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
export function runNonReactively(func, ...args) {
|
|
40
|
-
return
|
|
36
|
+
return ReactiveOperationImpl.proceedWithinGivenLaunch(undefined, func, ...args);
|
|
41
37
|
}
|
|
42
38
|
export function runSensitively(sensitivity, func, ...args) {
|
|
43
39
|
return Mvcc.sensitive(sensitivity, func, ...args);
|
|
@@ -45,7 +41,16 @@ export function runSensitively(sensitivity, func, ...args) {
|
|
|
45
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);
|
|
@@ -61,21 +66,21 @@ export function atomic(proto, prop, pd) {
|
|
|
61
66
|
};
|
|
62
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
|
-
kind: Kind.
|
|
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
|
-
kind: Kind.
|
|
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 { runAtomically, runNonReactively, runSensitively, runContextually } from "./
|
|
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";
|
package/build/dist/source/api.js
CHANGED
|
@@ -3,16 +3,18 @@ export { MergeList } from "./util/MergeList.js";
|
|
|
3
3
|
export { SealedArray } from "./util/SealedArray.js";
|
|
4
4
|
export { SealedMap } from "./util/SealedMap.js";
|
|
5
5
|
export { SealedSet } from "./util/SealedSet.js";
|
|
6
|
-
export {
|
|
6
|
+
export { LoggingLevel } from "./Options.js";
|
|
7
|
+
export { Mode, Priority, Kind, Reentrance, Isolation } from "./Enums.js";
|
|
7
8
|
export { Ref, ToggleRef, refs, toggleRefs, customToggleRefs } from "./Ref.js";
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
9
|
+
export { AtomicObject, ObservableObject } from "./core/Mvcc.js";
|
|
10
|
+
export { AtomicArray, ObservableArray } from "./core/MvccArray.js";
|
|
11
|
+
export { AtomicMap, ObservableMap } from "./core/MvccMap.js";
|
|
11
12
|
export { Changeset } from "./core/Changeset.js";
|
|
12
13
|
export { Transaction } from "./core/Transaction.js";
|
|
13
14
|
export { Indicator } from "./core/Indicator.js";
|
|
14
15
|
export { Journal } from "./core/Journal.js";
|
|
15
|
-
export { runAtomically, runNonReactively, runSensitively, runContextually } from "./
|
|
16
|
-
export { ReactiveSystem,
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
16
|
+
export { runAtomically, runNonReactively, runSensitively, runContextually, manageReactiveOperation, configureCurrentReactiveOperation, disposeObservableObject } from "./System.js";
|
|
17
|
+
export { ReactiveSystem, observable, atomic, reactive, cached, options } from "./System.js";
|
|
18
|
+
export { ReactiveOperationEx } from "./OperationEx.js";
|
|
19
|
+
export { ReactiveTreeNode, BaseDriver, ReactiveTreeVariable } from "./core/TreeNode.js";
|
|
20
|
+
export { ReactiveTree } from "./core/Tree.js";
|