reactronic 0.22.205 → 0.22.300
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 +24 -24
- package/build/dist/source/Buffer.d.ts +2 -2
- package/build/dist/source/Buffer.js +1 -1
- package/build/dist/source/Options.d.ts +3 -3
- package/build/dist/source/Ref.d.ts +1 -1
- package/build/dist/source/Ref.js +2 -2
- package/build/dist/source/Rx.d.ts +2 -2
- package/build/dist/source/Rx.js +6 -6
- package/build/dist/source/api.d.ts +3 -3
- package/build/dist/source/api.js +6 -6
- package/build/dist/source/impl/Data.d.ts +22 -27
- package/build/dist/source/impl/Data.js +14 -14
- package/build/dist/source/impl/Hooks.d.ts +15 -15
- package/build/dist/source/impl/Hooks.js +35 -35
- package/build/dist/source/impl/Journal.d.ts +34 -0
- package/build/dist/source/impl/Journal.js +138 -0
- package/build/dist/source/impl/Meta.d.ts +1 -1
- package/build/dist/source/impl/Meta.js +1 -1
- package/build/dist/source/impl/Monitor.d.ts +2 -2
- package/build/dist/source/impl/Monitor.js +1 -1
- package/build/dist/source/impl/Operation.d.ts +10 -10
- package/build/dist/source/impl/Operation.js +62 -68
- package/build/dist/source/impl/Snapshot.d.ts +23 -23
- package/build/dist/source/impl/Snapshot.js +34 -34
- package/package.json +1 -1
- package/build/dist/source/impl/EditJournal.d.ts +0 -37
- package/build/dist/source/impl/EditJournal.js +0 -130
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Hooks = exports.OptionsImpl = exports.
|
|
3
|
+
exports.Hooks = exports.OptionsImpl = exports.SubscribingObject = void 0;
|
|
4
4
|
const Utils_1 = require("../util/Utils");
|
|
5
5
|
const Dbg_1 = require("../util/Dbg");
|
|
6
6
|
const Options_1 = require("../Options");
|
|
7
7
|
const Data_1 = require("./Data");
|
|
8
8
|
const Snapshot_1 = require("./Snapshot");
|
|
9
|
-
class
|
|
9
|
+
class SubscribingObject {
|
|
10
10
|
constructor() {
|
|
11
11
|
const proto = new.target.prototype;
|
|
12
12
|
const initial = Data_1.Meta.getFrom(proto, Data_1.Meta.Initial);
|
|
13
|
-
const h = Hooks.
|
|
13
|
+
const h = Hooks.createDataHolderForSubscribingObject(proto, this, initial, new.target.name);
|
|
14
14
|
return h.proxy;
|
|
15
15
|
}
|
|
16
16
|
[Symbol.toStringTag]() {
|
|
@@ -18,7 +18,7 @@ class ObservableObject {
|
|
|
18
18
|
return Snapshot_1.Dump.obj(h);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
exports.
|
|
21
|
+
exports.SubscribingObject = SubscribingObject;
|
|
22
22
|
const DEFAULT_OPTIONS = Object.freeze({
|
|
23
23
|
kind: Options_1.Kind.Plain,
|
|
24
24
|
standalone: false,
|
|
@@ -56,49 +56,49 @@ function merge(def, existing, patch, implicit) {
|
|
|
56
56
|
}
|
|
57
57
|
class Hooks {
|
|
58
58
|
getPrototypeOf(h) {
|
|
59
|
-
return Reflect.getPrototypeOf(h.
|
|
59
|
+
return Reflect.getPrototypeOf(h.data);
|
|
60
60
|
}
|
|
61
61
|
get(h, m, receiver) {
|
|
62
62
|
let result;
|
|
63
63
|
const r = Snapshot_1.Snapshot.current().getCurrentRevision(h, m);
|
|
64
64
|
result = r.data[m];
|
|
65
|
-
if (result instanceof Data_1.
|
|
65
|
+
if (result instanceof Data_1.Subscription && !result.isOperation) {
|
|
66
66
|
Snapshot_1.Snapshot.markUsed(result, r, m, h, Options_1.Kind.Plain, false);
|
|
67
|
-
result = result.
|
|
67
|
+
result = result.content;
|
|
68
68
|
}
|
|
69
69
|
else if (m === Data_1.Meta.Holder) {
|
|
70
70
|
}
|
|
71
71
|
else
|
|
72
|
-
result = Reflect.get(h.
|
|
72
|
+
result = Reflect.get(h.data, m, receiver);
|
|
73
73
|
return result;
|
|
74
74
|
}
|
|
75
75
|
set(h, m, value, receiver) {
|
|
76
76
|
const r = Snapshot_1.Snapshot.edit().getEditableRevision(h, m, value);
|
|
77
77
|
if (r !== Snapshot_1.ROOT_REV) {
|
|
78
78
|
let curr = r.data[m];
|
|
79
|
-
if (curr !== undefined || (r.
|
|
80
|
-
if (curr === undefined || curr.
|
|
81
|
-
const
|
|
82
|
-
if (r.
|
|
83
|
-
curr = r.data[m] = new Data_1.
|
|
84
|
-
Snapshot_1.Snapshot.markEdited(
|
|
79
|
+
if (curr !== undefined || (r.former.revision.snapshot === Snapshot_1.ROOT_REV.snapshot && (m in h.data) === false)) {
|
|
80
|
+
if (curr === undefined || curr.content !== value || Hooks.sensitivity) {
|
|
81
|
+
const existing = curr === null || curr === void 0 ? void 0 : curr.content;
|
|
82
|
+
if (r.former.revision.data[m] === curr) {
|
|
83
|
+
curr = r.data[m] = new Data_1.Subscription(value);
|
|
84
|
+
Snapshot_1.Snapshot.markEdited(existing, value, true, r, m, h);
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
87
|
-
curr.
|
|
88
|
-
Snapshot_1.Snapshot.markEdited(
|
|
87
|
+
curr.content = value;
|
|
88
|
+
Snapshot_1.Snapshot.markEdited(existing, value, true, r, m, h);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
else
|
|
93
|
-
Reflect.set(h.
|
|
93
|
+
Reflect.set(h.data, m, value, receiver);
|
|
94
94
|
}
|
|
95
95
|
else
|
|
96
|
-
h.
|
|
96
|
+
h.data[m] = value;
|
|
97
97
|
return true;
|
|
98
98
|
}
|
|
99
99
|
has(h, m) {
|
|
100
100
|
const r = Snapshot_1.Snapshot.current().getCurrentRevision(h, m);
|
|
101
|
-
return m in r.data || m in h.
|
|
101
|
+
return m in r.data || m in h.data;
|
|
102
102
|
}
|
|
103
103
|
getOwnPropertyDescriptor(h, m) {
|
|
104
104
|
const r = Snapshot_1.Snapshot.current().getCurrentRevision(h, m);
|
|
@@ -112,19 +112,19 @@ class Hooks {
|
|
|
112
112
|
const result = [];
|
|
113
113
|
for (const m of Object.getOwnPropertyNames(r.data)) {
|
|
114
114
|
const value = r.data[m];
|
|
115
|
-
if (!(value instanceof Data_1.
|
|
115
|
+
if (!(value instanceof Data_1.Subscription) || !value.isOperation)
|
|
116
116
|
result.push(m);
|
|
117
117
|
}
|
|
118
118
|
return result;
|
|
119
119
|
}
|
|
120
|
-
static decorateData(
|
|
121
|
-
if (
|
|
120
|
+
static decorateData(subscribing, proto, m) {
|
|
121
|
+
if (subscribing) {
|
|
122
122
|
const get = function () {
|
|
123
|
-
const h = Hooks.
|
|
123
|
+
const h = Hooks.acquireDataHolder(this);
|
|
124
124
|
return Hooks.proxy.get(h, m, this);
|
|
125
125
|
};
|
|
126
126
|
const set = function (value) {
|
|
127
|
-
const h = Hooks.
|
|
127
|
+
const h = Hooks.acquireDataHolder(this);
|
|
128
128
|
return Hooks.proxy.set(h, m, value, this);
|
|
129
129
|
};
|
|
130
130
|
const enumerable = true;
|
|
@@ -132,7 +132,7 @@ class Hooks {
|
|
|
132
132
|
return Object.defineProperty(proto, m, { get, set, enumerable, configurable });
|
|
133
133
|
}
|
|
134
134
|
else
|
|
135
|
-
Data_1.Meta.acquire(proto, Data_1.Meta.Initial)[m] = Data_1.Meta.
|
|
135
|
+
Data_1.Meta.acquire(proto, Data_1.Meta.Initial)[m] = Data_1.Meta.Nonsubscribing;
|
|
136
136
|
}
|
|
137
137
|
static decorateOperation(implicit, decorator, options, proto, member, pd) {
|
|
138
138
|
var _a, _b, _c, _d;
|
|
@@ -143,18 +143,18 @@ class Hooks {
|
|
|
143
143
|
const opts = Hooks.rememberOperationOptions(proto, member, (_c = pd.value) !== null && _c !== void 0 ? _c : pd.get, (_d = pd.value) !== null && _d !== void 0 ? _d : pd.set, true, configurable, options, implicit);
|
|
144
144
|
if (opts.getter === opts.setter) {
|
|
145
145
|
const bootstrap = function () {
|
|
146
|
-
const h = Hooks.
|
|
146
|
+
const h = Hooks.acquireDataHolder(this);
|
|
147
147
|
const operation = Hooks.createOperation(h, member, opts);
|
|
148
|
-
Object.defineProperty(h.
|
|
148
|
+
Object.defineProperty(h.data, member, { value: operation, enumerable, configurable });
|
|
149
149
|
return operation;
|
|
150
150
|
};
|
|
151
151
|
return Object.defineProperty(proto, member, { get: bootstrap, enumerable, configurable: true });
|
|
152
152
|
}
|
|
153
153
|
else if (opts.setter === Utils_1.UNDEF) {
|
|
154
154
|
const bootstrap = function () {
|
|
155
|
-
const h = Hooks.
|
|
155
|
+
const h = Hooks.acquireDataHolder(this);
|
|
156
156
|
const operation = Hooks.createOperation(h, member, opts);
|
|
157
|
-
Object.defineProperty(h.
|
|
157
|
+
Object.defineProperty(h.data, member, { get: operation, enumerable, configurable });
|
|
158
158
|
return operation.call(this);
|
|
159
159
|
};
|
|
160
160
|
return Object.defineProperty(proto, member, { get: bootstrap, enumerable, configurable: true });
|
|
@@ -167,22 +167,22 @@ class Hooks {
|
|
|
167
167
|
return Hooks.decorateOperation(false, decorator, options, proto, prop, pd);
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
|
-
static
|
|
170
|
+
static acquireDataHolder(obj) {
|
|
171
171
|
let h = obj[Data_1.Meta.Holder];
|
|
172
172
|
if (!h) {
|
|
173
173
|
if (obj !== Object(obj) || Array.isArray(obj))
|
|
174
174
|
throw (0, Dbg_1.misuse)('only objects can be reactive');
|
|
175
175
|
const initial = Data_1.Meta.getFrom(Object.getPrototypeOf(obj), Data_1.Meta.Initial);
|
|
176
|
-
const rev = new Data_1.
|
|
176
|
+
const rev = new Data_1.DataRevision(Snapshot_1.ROOT_REV.snapshot, Snapshot_1.ROOT_REV, Object.assign({}, initial));
|
|
177
177
|
Data_1.Meta.set(rev.data, Data_1.Meta.Holder, h);
|
|
178
|
-
h = new Data_1.
|
|
178
|
+
h = new Data_1.DataHolder(obj, obj, Hooks.proxy, rev, obj.constructor.name);
|
|
179
179
|
Data_1.Meta.set(obj, Data_1.Meta.Holder, h);
|
|
180
180
|
}
|
|
181
181
|
return h;
|
|
182
182
|
}
|
|
183
|
-
static
|
|
183
|
+
static createDataHolderForSubscribingObject(proto, data, blank, hint) {
|
|
184
184
|
const ctx = Snapshot_1.Snapshot.edit();
|
|
185
|
-
const h = new Data_1.
|
|
185
|
+
const h = new Data_1.DataHolder(data, undefined, Hooks.proxy, Snapshot_1.ROOT_REV, hint);
|
|
186
186
|
ctx.getEditableRevision(h, Data_1.Meta.Holder, blank);
|
|
187
187
|
if (!Hooks.reactionsAutoStartDisabled)
|
|
188
188
|
for (const m in Data_1.Meta.getFrom(proto, Data_1.Meta.Reactions))
|
|
@@ -215,7 +215,7 @@ class Hooks {
|
|
|
215
215
|
}
|
|
216
216
|
static setHint(obj, hint) {
|
|
217
217
|
if (hint) {
|
|
218
|
-
const h = Hooks.
|
|
218
|
+
const h = Hooks.acquireDataHolder(obj);
|
|
219
219
|
h.hint = hint;
|
|
220
220
|
}
|
|
221
221
|
return obj;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SubscribingObject } from './Hooks';
|
|
2
|
+
import { DataHolder, DataRevision, PatchSet } from './Data';
|
|
3
|
+
export declare type Saver = (patch: PatchSet) => Promise<void>;
|
|
4
|
+
export declare abstract class Journal extends SubscribingObject {
|
|
5
|
+
abstract capacity: number;
|
|
6
|
+
abstract readonly edits: ReadonlyArray<PatchSet>;
|
|
7
|
+
abstract readonly unsaved: PatchSet;
|
|
8
|
+
abstract readonly canUndo: boolean;
|
|
9
|
+
abstract readonly canRedo: boolean;
|
|
10
|
+
abstract edited(patch: PatchSet): void;
|
|
11
|
+
abstract saved(patch: PatchSet): void;
|
|
12
|
+
abstract undo(count?: number): void;
|
|
13
|
+
abstract redo(count?: number): void;
|
|
14
|
+
static create(): Journal;
|
|
15
|
+
}
|
|
16
|
+
export declare class JournalImpl extends Journal {
|
|
17
|
+
private _capacity;
|
|
18
|
+
private _edits;
|
|
19
|
+
private _unsaved;
|
|
20
|
+
private _position;
|
|
21
|
+
get capacity(): number;
|
|
22
|
+
set capacity(value: number);
|
|
23
|
+
get edits(): ReadonlyArray<PatchSet>;
|
|
24
|
+
get unsaved(): PatchSet;
|
|
25
|
+
get canUndo(): boolean;
|
|
26
|
+
get canRedo(): boolean;
|
|
27
|
+
edited(p: PatchSet): void;
|
|
28
|
+
saved(patch: PatchSet): void;
|
|
29
|
+
undo(count?: number): void;
|
|
30
|
+
redo(count?: number): void;
|
|
31
|
+
static buildPatch(hint: string, changeset: Map<DataHolder, DataRevision>): PatchSet;
|
|
32
|
+
static applyPatch(patch: PatchSet, undoing: boolean): void;
|
|
33
|
+
mergePatchToUnsaved(patch: PatchSet, undoing: boolean): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JournalImpl = exports.Journal = void 0;
|
|
4
|
+
const Hooks_1 = require("./Hooks");
|
|
5
|
+
const Data_1 = require("./Data");
|
|
6
|
+
const Snapshot_1 = require("./Snapshot");
|
|
7
|
+
const Transaction_1 = require("./Transaction");
|
|
8
|
+
const Sealant_1 = require("../util/Sealant");
|
|
9
|
+
class Journal extends Hooks_1.SubscribingObject {
|
|
10
|
+
static create() { return new JournalImpl(); }
|
|
11
|
+
}
|
|
12
|
+
exports.Journal = Journal;
|
|
13
|
+
class JournalImpl extends Journal {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this._capacity = 5;
|
|
17
|
+
this._edits = [];
|
|
18
|
+
this._unsaved = { hint: 'unsaved', objects: new Map() };
|
|
19
|
+
this._position = 0;
|
|
20
|
+
}
|
|
21
|
+
get capacity() { return this._capacity; }
|
|
22
|
+
set capacity(value) { this._capacity = value; if (value < this._edits.length)
|
|
23
|
+
this._edits.splice(0, this._edits.length - value); }
|
|
24
|
+
get edits() { return this._edits; }
|
|
25
|
+
get unsaved() { return this._unsaved; }
|
|
26
|
+
get canUndo() { return this._edits.length > 0 && this._position > 0; }
|
|
27
|
+
get canRedo() { return this._position < this._edits.length; }
|
|
28
|
+
edited(p) {
|
|
29
|
+
Transaction_1.Transaction.run({ hint: 'EditJournal.edited', standalone: 'isolated' }, () => {
|
|
30
|
+
const items = this._edits = this._edits.toMutable();
|
|
31
|
+
if (items.length >= this._capacity)
|
|
32
|
+
items.shift();
|
|
33
|
+
else
|
|
34
|
+
items.splice(this._position);
|
|
35
|
+
this.mergePatchToUnsaved(p, false);
|
|
36
|
+
items.push(p);
|
|
37
|
+
this._position = items.length;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
saved(patch) {
|
|
41
|
+
if (this._unsaved === patch)
|
|
42
|
+
this._unsaved = { hint: 'unsaved', objects: new Map() };
|
|
43
|
+
else
|
|
44
|
+
throw new Error('not implemented');
|
|
45
|
+
}
|
|
46
|
+
undo(count = 1) {
|
|
47
|
+
Transaction_1.Transaction.run({ hint: 'Journal.undo', standalone: 'isolated' }, () => {
|
|
48
|
+
let i = this._position - 1;
|
|
49
|
+
while (i >= 0 && count > 0) {
|
|
50
|
+
const patch = this._edits[i];
|
|
51
|
+
JournalImpl.applyPatch(patch, true);
|
|
52
|
+
this.mergePatchToUnsaved(patch, true);
|
|
53
|
+
i--, count--;
|
|
54
|
+
}
|
|
55
|
+
this._position = i + 1;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
redo(count = 1) {
|
|
59
|
+
Transaction_1.Transaction.run({ hint: 'Journal.redo', standalone: 'isolated' }, () => {
|
|
60
|
+
let i = this._position;
|
|
61
|
+
while (i < this._edits.length && count > 0) {
|
|
62
|
+
const patch = this._edits[i];
|
|
63
|
+
JournalImpl.applyPatch(patch, false);
|
|
64
|
+
this.mergePatchToUnsaved(patch, false);
|
|
65
|
+
i++, count--;
|
|
66
|
+
}
|
|
67
|
+
this._position = i;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
static buildPatch(hint, changeset) {
|
|
71
|
+
const patch = { hint, objects: new Map() };
|
|
72
|
+
changeset.forEach((r, h) => {
|
|
73
|
+
const op = { data: {}, former: {} };
|
|
74
|
+
const former = r.former.revision !== Snapshot_1.ROOT_REV ? r.former.revision.data : undefined;
|
|
75
|
+
r.changes.forEach(m => {
|
|
76
|
+
op.data[m] = unseal(r.data[m]);
|
|
77
|
+
if (former)
|
|
78
|
+
op.former[m] = unseal(former[m]);
|
|
79
|
+
});
|
|
80
|
+
if (!former) {
|
|
81
|
+
delete op.data[Data_1.Meta.Disposed];
|
|
82
|
+
op.former[Data_1.Meta.Disposed] = Data_1.Meta.Disposed;
|
|
83
|
+
}
|
|
84
|
+
patch.objects.set(h.proxy, op);
|
|
85
|
+
});
|
|
86
|
+
return patch;
|
|
87
|
+
}
|
|
88
|
+
static applyPatch(patch, undoing) {
|
|
89
|
+
const ctx = Snapshot_1.Snapshot.edit();
|
|
90
|
+
patch.objects.forEach((dp, obj) => {
|
|
91
|
+
const h = Data_1.Meta.get(obj, Data_1.Meta.Holder);
|
|
92
|
+
const data = undoing ? dp.former : dp.data;
|
|
93
|
+
if (data[Data_1.Meta.Disposed] === undefined) {
|
|
94
|
+
for (const m in data) {
|
|
95
|
+
const value = data[m];
|
|
96
|
+
const r = ctx.getEditableRevision(h, m, value);
|
|
97
|
+
if (r.snapshot === ctx) {
|
|
98
|
+
r.data[m] = new Data_1.Subscription(value);
|
|
99
|
+
const existing = r.former.revision.data[m];
|
|
100
|
+
Snapshot_1.Snapshot.markEdited(existing, value, existing !== value, r, m, h);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else
|
|
105
|
+
Snapshot_1.Snapshot.doDispose(ctx, h);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
mergePatchToUnsaved(patch, undoing) {
|
|
109
|
+
const unsaved = this._unsaved;
|
|
110
|
+
patch.objects.forEach((dp, obj) => {
|
|
111
|
+
let merged = unsaved.objects.get(obj);
|
|
112
|
+
if (!merged)
|
|
113
|
+
unsaved.objects.set(obj, merged = { data: {}, former: {} });
|
|
114
|
+
const data = undoing ? dp.former : dp.data;
|
|
115
|
+
const former = undoing ? dp.data : dp.former;
|
|
116
|
+
for (const m in data) {
|
|
117
|
+
const value = data[m];
|
|
118
|
+
if (value !== merged.former[m]) {
|
|
119
|
+
merged.data[m] = value;
|
|
120
|
+
if (m in merged.former === false)
|
|
121
|
+
merged.former[m] = former[m];
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
delete merged.data[m];
|
|
125
|
+
delete merged.former[m];
|
|
126
|
+
if (Object.keys(merged.data).length === 0)
|
|
127
|
+
unsaved.objects.delete(obj);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.JournalImpl = JournalImpl;
|
|
134
|
+
function unseal(subscription) {
|
|
135
|
+
const result = subscription.content;
|
|
136
|
+
const createCopy = result === null || result === void 0 ? void 0 : result[Sealant_1.Sealant.CreateCopy];
|
|
137
|
+
return createCopy !== undefined ? createCopy.call(result) : result;
|
|
138
|
+
}
|
|
@@ -4,7 +4,7 @@ export declare abstract class Meta {
|
|
|
4
4
|
static readonly Disposed: unique symbol;
|
|
5
5
|
static readonly Initial: unique symbol;
|
|
6
6
|
static readonly Reactions: unique symbol;
|
|
7
|
-
static readonly
|
|
7
|
+
static readonly Nonsubscribing: unique symbol;
|
|
8
8
|
static readonly Undefined: unique symbol;
|
|
9
9
|
static get<T>(obj: any, sym: symbol): T;
|
|
10
10
|
static set(obj: any, sym: symbol, value: any): any;
|
|
@@ -29,5 +29,5 @@ Meta.Controller = Symbol('rxController');
|
|
|
29
29
|
Meta.Disposed = Symbol('rxDisposed');
|
|
30
30
|
Meta.Initial = Symbol('rxInitial');
|
|
31
31
|
Meta.Reactions = Symbol('rxReactions');
|
|
32
|
-
Meta.
|
|
32
|
+
Meta.Nonsubscribing = Symbol('rxNonsubscribing');
|
|
33
33
|
Meta.Undefined = Symbol('rxUndefined');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Worker } from '../Worker';
|
|
2
|
-
import {
|
|
3
|
-
export declare abstract class Monitor extends
|
|
2
|
+
import { SubscribingObject } from './Hooks';
|
|
3
|
+
export declare abstract class Monitor extends SubscribingObject {
|
|
4
4
|
abstract readonly isActive: boolean;
|
|
5
5
|
abstract readonly counter: number;
|
|
6
6
|
abstract readonly workers: ReadonlySet<Worker>;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MonitorImpl = exports.Monitor = void 0;
|
|
4
4
|
const Hooks_1 = require("./Hooks");
|
|
5
5
|
const Transaction_1 = require("./Transaction");
|
|
6
|
-
class Monitor extends Hooks_1.
|
|
6
|
+
class Monitor extends Hooks_1.SubscribingObject {
|
|
7
7
|
static create(hint, activationDelay, deactivationDelay, durationResolution) {
|
|
8
8
|
return MonitorImpl.create(hint, activationDelay, deactivationDelay, durationResolution);
|
|
9
9
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { F } from '../util/Utils';
|
|
2
2
|
import { MemberOptions } from '../Options';
|
|
3
3
|
import { Controller } from '../Controller';
|
|
4
|
-
import { MemberName,
|
|
4
|
+
import { MemberName, DataHolder, Subscription, Subscriber, SubscriptionInfo, AbstractSnapshot } from './Data';
|
|
5
5
|
import { Transaction } from './Transaction';
|
|
6
6
|
import { OptionsImpl } from './Hooks';
|
|
7
7
|
export declare class OperationController extends Controller<any> {
|
|
8
|
-
readonly ownHolder:
|
|
8
|
+
readonly ownHolder: DataHolder;
|
|
9
9
|
readonly memberName: MemberName;
|
|
10
10
|
configure(options: Partial<MemberOptions>): MemberOptions;
|
|
11
11
|
get options(): MemberOptions;
|
|
12
|
-
get
|
|
12
|
+
get nonsubscribing(): any;
|
|
13
13
|
get args(): ReadonlyArray<any>;
|
|
14
14
|
get result(): any;
|
|
15
15
|
get error(): boolean;
|
|
@@ -17,7 +17,7 @@ export declare class OperationController extends Controller<any> {
|
|
|
17
17
|
get isUpToDate(): boolean;
|
|
18
18
|
markObsolete(): void;
|
|
19
19
|
pullLastResult(args?: any[]): any;
|
|
20
|
-
constructor(ownHolder:
|
|
20
|
+
constructor(ownHolder: DataHolder, memberName: MemberName);
|
|
21
21
|
useOrRun(weak: boolean, args: any[] | undefined): Operation;
|
|
22
22
|
static of(method: F<any>): Controller<any>;
|
|
23
23
|
static configureImpl(self: OperationController | undefined, options: Partial<MemberOptions>): MemberOptions;
|
|
@@ -32,15 +32,15 @@ export declare class OperationController extends Controller<any> {
|
|
|
32
32
|
private run;
|
|
33
33
|
private static markObsolete;
|
|
34
34
|
}
|
|
35
|
-
declare class Operation extends
|
|
35
|
+
declare class Operation extends Subscription implements Subscriber {
|
|
36
36
|
static current?: Operation;
|
|
37
|
-
static queuedReactions: Array<
|
|
37
|
+
static queuedReactions: Array<Subscriber>;
|
|
38
38
|
static deferredReactions: Array<Operation>;
|
|
39
39
|
readonly margin: number;
|
|
40
40
|
readonly transaction: Transaction;
|
|
41
41
|
readonly controller: OperationController;
|
|
42
42
|
readonly snapshot: AbstractSnapshot;
|
|
43
|
-
|
|
43
|
+
subscriptions: Map<Subscription, SubscriptionInfo> | undefined;
|
|
44
44
|
options: OptionsImpl;
|
|
45
45
|
cause: string | undefined;
|
|
46
46
|
args: any[];
|
|
@@ -50,7 +50,7 @@ declare class Operation extends Observable implements Observer {
|
|
|
50
50
|
obsoleteDueTo: string | undefined;
|
|
51
51
|
obsoleteSince: number;
|
|
52
52
|
successor: Operation | undefined;
|
|
53
|
-
constructor(controller: OperationController, snapshot: AbstractSnapshot,
|
|
53
|
+
constructor(controller: OperationController, snapshot: AbstractSnapshot, former: Operation | OptionsImpl);
|
|
54
54
|
get isOperation(): boolean;
|
|
55
55
|
get originSnapshotId(): number;
|
|
56
56
|
hint(): string;
|
|
@@ -61,7 +61,7 @@ declare class Operation extends Observable implements Observer {
|
|
|
61
61
|
dependencies(): string[];
|
|
62
62
|
wrap<T>(func: F<T>): F<T>;
|
|
63
63
|
run(proxy: any, args: any[] | undefined): void;
|
|
64
|
-
markObsoleteDueTo(
|
|
64
|
+
markObsoleteDueTo(subscription: Subscription, memberName: MemberName, snapshot: AbstractSnapshot, holder: DataHolder, outer: string, since: number, reactions: Subscriber[]): void;
|
|
65
65
|
runIfNotUpToDate(now: boolean, nothrow: boolean): void;
|
|
66
66
|
isNotUpToDate(): boolean;
|
|
67
67
|
reenterOver(head: Operation): this;
|
|
@@ -81,7 +81,7 @@ declare class Operation extends Observable implements Observer {
|
|
|
81
81
|
private static propagateMemberChangeThroughSubscriptions;
|
|
82
82
|
private static enqueueReactionsToRun;
|
|
83
83
|
private static runQueuedReactionsLoop;
|
|
84
|
-
private
|
|
84
|
+
private unsubscribeFromAllSubscriptions;
|
|
85
85
|
private subscribeTo;
|
|
86
86
|
private static canSubscribe;
|
|
87
87
|
private static createOperation;
|