reactronic 0.22.309 → 0.22.312
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/LICENSE +202 -21
- package/README.md +3 -4
- package/build/dist/source/Buffer.js +2 -6
- package/build/dist/source/Controller.js +1 -5
- package/build/dist/source/Logging.js +1 -4
- package/build/dist/source/Options.js +5 -9
- package/build/dist/source/Ref.js +6 -11
- package/build/dist/source/Rx.js +46 -57
- package/build/dist/source/Worker.js +1 -2
- package/build/dist/source/api.js +13 -42
- package/build/dist/source/impl/Changeset.d.ts +4 -4
- package/build/dist/source/impl/Changeset.js +96 -99
- package/build/dist/source/impl/Data.js +10 -17
- package/build/dist/source/impl/Hooks.js +55 -63
- package/build/dist/source/impl/Journal.js +23 -28
- package/build/dist/source/impl/Meta.js +1 -5
- package/build/dist/source/impl/Monitor.js +9 -14
- package/build/dist/source/impl/Operation.js +151 -157
- package/build/dist/source/impl/Transaction.js +28 -32
- package/build/dist/source/util/Dbg.js +4 -11
- package/build/dist/source/util/Sealant.js +5 -9
- package/build/dist/source/util/SealedArray.js +10 -14
- package/build/dist/source/util/SealedMap.js +8 -12
- package/build/dist/source/util/SealedSet.js +8 -12
- package/build/dist/source/util/Utils.js +4 -11
- package/package.json +14 -14
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const Data_1 = require("./Data");
|
|
9
|
-
const Changeset_1 = require("./Changeset");
|
|
10
|
-
class ReactiveObject {
|
|
1
|
+
import { UNDEF } from '../util/Utils';
|
|
2
|
+
import { Sealant } from '../util/Sealant';
|
|
3
|
+
import { Log, misuse } from '../util/Dbg';
|
|
4
|
+
import { Kind, Reentrance } from '../Options';
|
|
5
|
+
import { ObjectSnapshot, ObjectHandle, Subscription, Meta } from './Data';
|
|
6
|
+
import { Changeset, Dump, EMPTY_SNAPSHOT } from './Changeset';
|
|
7
|
+
export class ReactiveObject {
|
|
11
8
|
constructor() {
|
|
12
9
|
const proto = new.target.prototype;
|
|
13
|
-
const initial =
|
|
10
|
+
const initial = Meta.getFrom(proto, Meta.Initial);
|
|
14
11
|
const h = Hooks.createHandleForReactiveObject(proto, this, initial, new.target.name);
|
|
15
12
|
return h.proxy;
|
|
16
13
|
}
|
|
17
14
|
[Symbol.toStringTag]() {
|
|
18
|
-
const h =
|
|
19
|
-
return
|
|
15
|
+
const h = Meta.get(this, Meta.Handle);
|
|
16
|
+
return Dump.obj(h);
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
class ReactiveArray extends ReactiveObject {
|
|
19
|
+
export class ReactiveArray extends ReactiveObject {
|
|
24
20
|
constructor() {
|
|
25
21
|
super(...arguments);
|
|
26
22
|
this.a = new Array();
|
|
@@ -54,14 +50,13 @@ class ReactiveArray extends ReactiveObject {
|
|
|
54
50
|
keys() { return this.a.keys(); }
|
|
55
51
|
values() { return this.a.values(); }
|
|
56
52
|
get mutable() {
|
|
57
|
-
const createCopy = this.a[
|
|
53
|
+
const createCopy = this.a[Sealant.CreateCopy];
|
|
58
54
|
if (createCopy)
|
|
59
55
|
return this.a = createCopy.call(this.a);
|
|
60
56
|
return this.a;
|
|
61
57
|
}
|
|
62
58
|
}
|
|
63
|
-
|
|
64
|
-
class ReactiveMap extends ReactiveObject {
|
|
59
|
+
export class ReactiveMap extends ReactiveObject {
|
|
65
60
|
constructor() {
|
|
66
61
|
super(...arguments);
|
|
67
62
|
this.m = new Map();
|
|
@@ -77,26 +72,25 @@ class ReactiveMap extends ReactiveObject {
|
|
|
77
72
|
keys() { return this.m.keys(); }
|
|
78
73
|
values() { return this.m.values(); }
|
|
79
74
|
get mutable() {
|
|
80
|
-
const createCopy = this.m[
|
|
75
|
+
const createCopy = this.m[Sealant.CreateCopy];
|
|
81
76
|
if (createCopy)
|
|
82
77
|
return this.m = createCopy.call(this.m);
|
|
83
78
|
return this.m;
|
|
84
79
|
}
|
|
85
80
|
}
|
|
86
|
-
exports.ReactiveMap = ReactiveMap;
|
|
87
81
|
const DEFAULT_OPTIONS = Object.freeze({
|
|
88
|
-
kind:
|
|
82
|
+
kind: Kind.Plain,
|
|
89
83
|
standalone: false,
|
|
90
84
|
order: 0,
|
|
91
85
|
noSideEffects: false,
|
|
92
86
|
triggeringArgs: false,
|
|
93
87
|
throttling: Number.MAX_SAFE_INTEGER,
|
|
94
|
-
reentrance:
|
|
88
|
+
reentrance: Reentrance.PreventWithError,
|
|
95
89
|
journal: undefined,
|
|
96
90
|
monitor: null,
|
|
97
91
|
logging: undefined,
|
|
98
92
|
});
|
|
99
|
-
class OptionsImpl {
|
|
93
|
+
export class OptionsImpl {
|
|
100
94
|
constructor(getter, setter, existing, patch, implicit) {
|
|
101
95
|
this.getter = getter !== undefined ? getter : existing.getter;
|
|
102
96
|
this.setter = setter !== undefined ? setter : existing.setter;
|
|
@@ -110,27 +104,26 @@ class OptionsImpl {
|
|
|
110
104
|
this.journal = merge(DEFAULT_OPTIONS.journal, existing.journal, patch.journal, implicit);
|
|
111
105
|
this.monitor = merge(DEFAULT_OPTIONS.monitor, existing.monitor, patch.monitor, implicit);
|
|
112
106
|
this.logging = merge(DEFAULT_OPTIONS.logging, existing.logging, patch.logging, implicit);
|
|
113
|
-
if (
|
|
107
|
+
if (Log.isOn)
|
|
114
108
|
Object.freeze(this);
|
|
115
109
|
}
|
|
116
110
|
}
|
|
117
|
-
|
|
118
|
-
OptionsImpl.INITIAL = Object.freeze(new OptionsImpl(Utils_1.UNDEF, Utils_1.UNDEF, Object.assign({ getter: Utils_1.UNDEF, setter: Utils_1.UNDEF }, DEFAULT_OPTIONS), {}, false));
|
|
111
|
+
OptionsImpl.INITIAL = Object.freeze(new OptionsImpl(UNDEF, UNDEF, Object.assign({ getter: UNDEF, setter: UNDEF }, DEFAULT_OPTIONS), {}, false));
|
|
119
112
|
function merge(def, existing, patch, implicit) {
|
|
120
113
|
return patch !== undefined && (existing === def || !implicit) ? patch : existing;
|
|
121
114
|
}
|
|
122
|
-
class Hooks {
|
|
115
|
+
export class Hooks {
|
|
123
116
|
getPrototypeOf(h) {
|
|
124
117
|
return Reflect.getPrototypeOf(h.data);
|
|
125
118
|
}
|
|
126
119
|
get(h, m, receiver) {
|
|
127
120
|
let result;
|
|
128
|
-
if (m !==
|
|
129
|
-
const cs =
|
|
130
|
-
const os = cs.
|
|
121
|
+
if (m !== Meta.Handle) {
|
|
122
|
+
const cs = Changeset.current();
|
|
123
|
+
const os = cs.getObjectSnapshot(h, m);
|
|
131
124
|
result = os.data[m];
|
|
132
|
-
if (result instanceof
|
|
133
|
-
|
|
125
|
+
if (result instanceof Subscription && !result.isOperation) {
|
|
126
|
+
Changeset.markUsed(result, os, m, h, Kind.Plain, false);
|
|
134
127
|
result = result.content;
|
|
135
128
|
}
|
|
136
129
|
else
|
|
@@ -141,19 +134,19 @@ class Hooks {
|
|
|
141
134
|
return result;
|
|
142
135
|
}
|
|
143
136
|
set(h, m, value, receiver) {
|
|
144
|
-
const os =
|
|
145
|
-
if (os !==
|
|
137
|
+
const os = Changeset.edit().getEditableObjectSnapshot(h, m, value);
|
|
138
|
+
if (os !== EMPTY_SNAPSHOT) {
|
|
146
139
|
let curr = os.data[m];
|
|
147
|
-
if (curr !== undefined || (os.former.snapshot.changeset ===
|
|
140
|
+
if (curr !== undefined || (os.former.snapshot.changeset === EMPTY_SNAPSHOT.changeset && (m in h.data) === false)) {
|
|
148
141
|
if (curr === undefined || curr.content !== value || Hooks.sensitivity) {
|
|
149
142
|
const existing = curr === null || curr === void 0 ? void 0 : curr.content;
|
|
150
143
|
if (os.former.snapshot.data[m] === curr) {
|
|
151
|
-
curr = os.data[m] = new
|
|
152
|
-
|
|
144
|
+
curr = os.data[m] = new Subscription(value);
|
|
145
|
+
Changeset.markEdited(existing, value, true, os, m, h);
|
|
153
146
|
}
|
|
154
147
|
else {
|
|
155
148
|
curr.content = value;
|
|
156
|
-
|
|
149
|
+
Changeset.markEdited(existing, value, true, os, m, h);
|
|
157
150
|
}
|
|
158
151
|
}
|
|
159
152
|
}
|
|
@@ -165,22 +158,22 @@ class Hooks {
|
|
|
165
158
|
return true;
|
|
166
159
|
}
|
|
167
160
|
has(h, m) {
|
|
168
|
-
const os =
|
|
161
|
+
const os = Changeset.current().getObjectSnapshot(h, m);
|
|
169
162
|
return m in os.data || m in h.data;
|
|
170
163
|
}
|
|
171
164
|
getOwnPropertyDescriptor(h, m) {
|
|
172
|
-
const os =
|
|
165
|
+
const os = Changeset.current().getObjectSnapshot(h, m);
|
|
173
166
|
const pd = Reflect.getOwnPropertyDescriptor(os.data, m);
|
|
174
167
|
if (pd)
|
|
175
168
|
pd.configurable = pd.writable = true;
|
|
176
169
|
return pd;
|
|
177
170
|
}
|
|
178
171
|
ownKeys(h) {
|
|
179
|
-
const os =
|
|
172
|
+
const os = Changeset.current().getObjectSnapshot(h, Meta.Handle);
|
|
180
173
|
const result = [];
|
|
181
174
|
for (const m of Object.getOwnPropertyNames(os.data)) {
|
|
182
175
|
const value = os.data[m];
|
|
183
|
-
if (!(value instanceof
|
|
176
|
+
if (!(value instanceof Subscription) || !value.isOperation)
|
|
184
177
|
result.push(m);
|
|
185
178
|
}
|
|
186
179
|
return result;
|
|
@@ -200,7 +193,7 @@ class Hooks {
|
|
|
200
193
|
return Object.defineProperty(proto, m, { get, set, enumerable, configurable });
|
|
201
194
|
}
|
|
202
195
|
else
|
|
203
|
-
|
|
196
|
+
Meta.acquire(proto, Meta.Initial)[m] = Meta.Nonreactive;
|
|
204
197
|
}
|
|
205
198
|
static decorateOperation(implicit, decorator, options, proto, member, pd) {
|
|
206
199
|
var _a, _b, _c, _d;
|
|
@@ -218,7 +211,7 @@ class Hooks {
|
|
|
218
211
|
};
|
|
219
212
|
return Object.defineProperty(proto, member, { get: bootstrap, enumerable, configurable: true });
|
|
220
213
|
}
|
|
221
|
-
else if (opts.setter ===
|
|
214
|
+
else if (opts.setter === UNDEF) {
|
|
222
215
|
const bootstrap = function () {
|
|
223
216
|
const h = Hooks.acquireHandle(this);
|
|
224
217
|
const operation = Hooks.createOperation(h, member, opts);
|
|
@@ -228,7 +221,7 @@ class Hooks {
|
|
|
228
221
|
return Object.defineProperty(proto, member, { get: bootstrap, enumerable, configurable: true });
|
|
229
222
|
}
|
|
230
223
|
else
|
|
231
|
-
throw
|
|
224
|
+
throw misuse(`${proto.constructor.name}.${member.toString()} has setter and cannot be decorated with @${decorator.name}`);
|
|
232
225
|
}
|
|
233
226
|
static decorateOperationParametrized(decorator, options) {
|
|
234
227
|
return function (proto, prop, pd) {
|
|
@@ -236,26 +229,26 @@ class Hooks {
|
|
|
236
229
|
};
|
|
237
230
|
}
|
|
238
231
|
static acquireHandle(obj) {
|
|
239
|
-
let h = obj[
|
|
232
|
+
let h = obj[Meta.Handle];
|
|
240
233
|
if (!h) {
|
|
241
234
|
if (obj !== Object(obj) || Array.isArray(obj))
|
|
242
|
-
throw
|
|
243
|
-
const initial =
|
|
244
|
-
const os = new
|
|
245
|
-
h = new
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
235
|
+
throw misuse('only objects can be reactive');
|
|
236
|
+
const initial = Meta.getFrom(Object.getPrototypeOf(obj), Meta.Initial);
|
|
237
|
+
const os = new ObjectSnapshot(EMPTY_SNAPSHOT.changeset, EMPTY_SNAPSHOT, Object.assign({}, initial));
|
|
238
|
+
h = new ObjectHandle(obj, obj, Hooks.handler, os, obj.constructor.name);
|
|
239
|
+
Meta.set(os.data, Meta.Handle, h);
|
|
240
|
+
Meta.set(obj, Meta.Handle, h);
|
|
241
|
+
Meta.set(os.data, Meta.Revision, new Subscription(1));
|
|
249
242
|
}
|
|
250
243
|
return h;
|
|
251
244
|
}
|
|
252
245
|
static createHandleForReactiveObject(proto, data, blank, hint) {
|
|
253
|
-
const ctx =
|
|
254
|
-
const h = new
|
|
255
|
-
ctx.
|
|
246
|
+
const ctx = Changeset.edit();
|
|
247
|
+
const h = new ObjectHandle(data, undefined, Hooks.handler, EMPTY_SNAPSHOT, hint);
|
|
248
|
+
ctx.getEditableObjectSnapshot(h, Meta.Handle, blank);
|
|
256
249
|
if (!Hooks.reactionsAutoStartDisabled)
|
|
257
|
-
for (const m in
|
|
258
|
-
h.proxy[m][
|
|
250
|
+
for (const m in Meta.getFrom(proto, Meta.Reactions))
|
|
251
|
+
h.proxy[m][Meta.Controller].markObsolete();
|
|
259
252
|
return h;
|
|
260
253
|
}
|
|
261
254
|
static setProfilingMode(isOn, options) {
|
|
@@ -263,13 +256,13 @@ class Hooks {
|
|
|
263
256
|
Hooks.repetitiveUsageWarningThreshold = options && options.repetitiveUsageWarningThreshold !== undefined ? options.repetitiveUsageWarningThreshold : 10;
|
|
264
257
|
Hooks.mainThreadBlockingWarningThreshold = options && options.mainThreadBlockingWarningThreshold !== undefined ? options.mainThreadBlockingWarningThreshold : 14;
|
|
265
258
|
Hooks.asyncActionDurationWarningThreshold = options && options.asyncActionDurationWarningThreshold !== undefined ? options.asyncActionDurationWarningThreshold : 300;
|
|
266
|
-
|
|
259
|
+
Changeset.garbageCollectionSummaryInterval = options && options.garbageCollectionSummaryInterval !== undefined ? options.garbageCollectionSummaryInterval : 100;
|
|
267
260
|
}
|
|
268
261
|
else {
|
|
269
262
|
Hooks.repetitiveUsageWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
270
263
|
Hooks.mainThreadBlockingWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
271
264
|
Hooks.asyncActionDurationWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
272
|
-
|
|
265
|
+
Changeset.garbageCollectionSummaryInterval = Number.MAX_SAFE_INTEGER;
|
|
273
266
|
}
|
|
274
267
|
}
|
|
275
268
|
static sensitive(sensitivity, func, ...args) {
|
|
@@ -290,7 +283,6 @@ class Hooks {
|
|
|
290
283
|
return obj;
|
|
291
284
|
}
|
|
292
285
|
}
|
|
293
|
-
exports.Hooks = Hooks;
|
|
294
286
|
Hooks.reactionsAutoStartDisabled = false;
|
|
295
287
|
Hooks.repetitiveUsageWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
296
288
|
Hooks.mainThreadBlockingWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
@@ -298,10 +290,10 @@ Hooks.asyncActionDurationWarningThreshold = Number.MAX_SAFE_INTEGER;
|
|
|
298
290
|
Hooks.sensitivity = false;
|
|
299
291
|
Hooks.handler = new Hooks();
|
|
300
292
|
Hooks.createOperation = function (h, m, options) {
|
|
301
|
-
throw
|
|
293
|
+
throw misuse('createOperation should never be called');
|
|
302
294
|
};
|
|
303
295
|
Hooks.rememberOperationOptions = function (proto, m, getter, setter, enumerable, configurable, options, implicit) {
|
|
304
|
-
throw
|
|
296
|
+
throw misuse('rememberOperationOptions should never be called');
|
|
305
297
|
};
|
|
306
298
|
const EMPTY_PROP_DESCRIPTOR = {
|
|
307
299
|
configurable: true,
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const Transaction_1 = require("./Transaction");
|
|
8
|
-
const Sealant_1 = require("../util/Sealant");
|
|
9
|
-
class Journal extends Hooks_1.ReactiveObject {
|
|
1
|
+
import { ReactiveObject } from './Hooks';
|
|
2
|
+
import { Meta, Subscription } from './Data';
|
|
3
|
+
import { Changeset, EMPTY_SNAPSHOT } from './Changeset';
|
|
4
|
+
import { Transaction } from './Transaction';
|
|
5
|
+
import { Sealant } from '../util/Sealant';
|
|
6
|
+
export class Journal extends ReactiveObject {
|
|
10
7
|
static create() { return new JournalImpl(); }
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
class JournalImpl extends Journal {
|
|
9
|
+
export class JournalImpl extends Journal {
|
|
14
10
|
constructor() {
|
|
15
11
|
super(...arguments);
|
|
16
12
|
this._capacity = 5;
|
|
@@ -26,7 +22,7 @@ class JournalImpl extends Journal {
|
|
|
26
22
|
get canUndo() { return this._edits.length > 0 && this._position > 0; }
|
|
27
23
|
get canRedo() { return this._position < this._edits.length; }
|
|
28
24
|
edited(p) {
|
|
29
|
-
|
|
25
|
+
Transaction.run({ hint: 'EditJournal.edited', standalone: 'isolated' }, () => {
|
|
30
26
|
const items = this._edits = this._edits.toMutable();
|
|
31
27
|
if (items.length >= this._capacity)
|
|
32
28
|
items.shift();
|
|
@@ -44,7 +40,7 @@ class JournalImpl extends Journal {
|
|
|
44
40
|
throw new Error('not implemented');
|
|
45
41
|
}
|
|
46
42
|
undo(count = 1) {
|
|
47
|
-
|
|
43
|
+
Transaction.run({ hint: 'Journal.undo', standalone: 'isolated' }, () => {
|
|
48
44
|
let i = this._position - 1;
|
|
49
45
|
while (i >= 0 && count > 0) {
|
|
50
46
|
const patch = this._edits[i];
|
|
@@ -56,7 +52,7 @@ class JournalImpl extends Journal {
|
|
|
56
52
|
});
|
|
57
53
|
}
|
|
58
54
|
redo(count = 1) {
|
|
59
|
-
|
|
55
|
+
Transaction.run({ hint: 'Journal.redo', standalone: 'isolated' }, () => {
|
|
60
56
|
let i = this._position;
|
|
61
57
|
while (i < this._edits.length && count > 0) {
|
|
62
58
|
const patch = this._edits[i];
|
|
@@ -71,7 +67,7 @@ class JournalImpl extends Journal {
|
|
|
71
67
|
const patch = new Map();
|
|
72
68
|
items.forEach((os, h) => {
|
|
73
69
|
const op = new Map();
|
|
74
|
-
const former = os.former.snapshot !==
|
|
70
|
+
const former = os.former.snapshot !== EMPTY_SNAPSHOT ? os.former.snapshot.data : undefined;
|
|
75
71
|
os.changes.forEach(m => {
|
|
76
72
|
const vp = {
|
|
77
73
|
memberName: m, patchKind: 'update',
|
|
@@ -83,34 +79,34 @@ class JournalImpl extends Journal {
|
|
|
83
79
|
});
|
|
84
80
|
if (!former) {
|
|
85
81
|
const vp = {
|
|
86
|
-
memberName:
|
|
87
|
-
freshValue:
|
|
82
|
+
memberName: Meta.Revision, patchKind: 'remove',
|
|
83
|
+
freshValue: Meta.Undefined, formerValue: undefined,
|
|
88
84
|
};
|
|
89
|
-
op.set(
|
|
85
|
+
op.set(Meta.Revision, vp);
|
|
90
86
|
}
|
|
91
87
|
patch.set(h.proxy, op);
|
|
92
88
|
});
|
|
93
89
|
return patch;
|
|
94
90
|
}
|
|
95
91
|
static applyPatch(patch, undoing) {
|
|
96
|
-
const ctx =
|
|
92
|
+
const ctx = Changeset.edit();
|
|
97
93
|
patch.forEach((op, obj) => {
|
|
98
|
-
const h =
|
|
99
|
-
const rev = op.get(
|
|
100
|
-
const disposed = rev && (undoing ? rev.formerValue : rev.freshValue) ===
|
|
94
|
+
const h = Meta.get(obj, Meta.Handle);
|
|
95
|
+
const rev = op.get(Meta.Revision);
|
|
96
|
+
const disposed = rev && (undoing ? rev.formerValue : rev.freshValue) === Meta.Undefined;
|
|
101
97
|
if (!disposed) {
|
|
102
98
|
op.forEach((vp, m) => {
|
|
103
99
|
const value = undoing ? vp.formerValue : vp.freshValue;
|
|
104
|
-
const os = ctx.
|
|
100
|
+
const os = ctx.getEditableObjectSnapshot(h, m, value);
|
|
105
101
|
if (os.changeset === ctx) {
|
|
106
|
-
os.data[m] = new
|
|
102
|
+
os.data[m] = new Subscription(value);
|
|
107
103
|
const existing = os.former.snapshot.data[m];
|
|
108
|
-
|
|
104
|
+
Changeset.markEdited(existing, value, existing !== value, os, m, h);
|
|
109
105
|
}
|
|
110
106
|
});
|
|
111
107
|
}
|
|
112
108
|
else
|
|
113
|
-
|
|
109
|
+
Changeset.doDispose(ctx, h);
|
|
114
110
|
});
|
|
115
111
|
}
|
|
116
112
|
mergePatchToUnsaved(patch, undoing) {
|
|
@@ -141,9 +137,8 @@ class JournalImpl extends Journal {
|
|
|
141
137
|
});
|
|
142
138
|
}
|
|
143
139
|
}
|
|
144
|
-
exports.JournalImpl = JournalImpl;
|
|
145
140
|
function unseal(subscription) {
|
|
146
141
|
const result = subscription.content;
|
|
147
|
-
const createCopy = result === null || result === void 0 ? void 0 : result[
|
|
142
|
+
const createCopy = result === null || result === void 0 ? void 0 : result[Sealant.CreateCopy];
|
|
148
143
|
return createCopy !== undefined ? createCopy.call(result) : result;
|
|
149
144
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Meta = void 0;
|
|
4
1
|
const EMPTY_META = Object.freeze({});
|
|
5
|
-
class Meta {
|
|
2
|
+
export class Meta {
|
|
6
3
|
static get(obj, sym) {
|
|
7
4
|
return obj[sym];
|
|
8
5
|
}
|
|
@@ -23,7 +20,6 @@ class Meta {
|
|
|
23
20
|
return (_a = proto[sym]) !== null && _a !== void 0 ? _a : EMPTY_META;
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
|
-
exports.Meta = Meta;
|
|
27
23
|
Meta.Handle = Symbol('rx-handle');
|
|
28
24
|
Meta.Revision = Symbol('rx-revision');
|
|
29
25
|
Meta.Controller = Symbol('rx-controller');
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Hooks_1 = require("./Hooks");
|
|
5
|
-
const Transaction_1 = require("./Transaction");
|
|
6
|
-
class Monitor extends Hooks_1.ReactiveObject {
|
|
1
|
+
import { ReactiveObject, Hooks } from './Hooks';
|
|
2
|
+
import { Transaction } from './Transaction';
|
|
3
|
+
export class Monitor extends ReactiveObject {
|
|
7
4
|
static create(hint, activationDelay, deactivationDelay, durationResolution) {
|
|
8
5
|
return MonitorImpl.create(hint, activationDelay, deactivationDelay, durationResolution);
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
class MonitorImpl extends Monitor {
|
|
8
|
+
export class MonitorImpl extends Monitor {
|
|
13
9
|
constructor() {
|
|
14
10
|
super(...arguments);
|
|
15
11
|
this.isActive = false;
|
|
@@ -38,7 +34,7 @@ class MonitorImpl extends Monitor {
|
|
|
38
34
|
MonitorImpl.deactivate(this, this.internals.deactivationDelay);
|
|
39
35
|
}
|
|
40
36
|
static create(hint, activationDelay, deactivationDelay, durationResolution) {
|
|
41
|
-
return
|
|
37
|
+
return Transaction.run({ hint: 'Monitor.create' }, MonitorImpl.doCreate, hint, activationDelay, deactivationDelay, durationResolution);
|
|
42
38
|
}
|
|
43
39
|
static enter(mon, worker) {
|
|
44
40
|
mon.enter(worker);
|
|
@@ -48,7 +44,7 @@ class MonitorImpl extends Monitor {
|
|
|
48
44
|
}
|
|
49
45
|
static doCreate(hint, activationDelay, deactivationDelay, durationResolution) {
|
|
50
46
|
const m = new MonitorImpl();
|
|
51
|
-
|
|
47
|
+
Hooks.setHint(m, hint);
|
|
52
48
|
m.internals.activationDelay = activationDelay;
|
|
53
49
|
m.internals.deactivationDelay = deactivationDelay;
|
|
54
50
|
m.internals.durationResolution = durationResolution;
|
|
@@ -62,7 +58,7 @@ class MonitorImpl extends Monitor {
|
|
|
62
58
|
}
|
|
63
59
|
if (delay >= 0) {
|
|
64
60
|
if (mon.internals.activationTimeout === undefined)
|
|
65
|
-
mon.internals.activationTimeout = setTimeout(() =>
|
|
61
|
+
mon.internals.activationTimeout = setTimeout(() => Transaction.run({ hint: 'Monitor.activate', standalone: 'isolated' }, MonitorImpl.activate, mon, -1), delay);
|
|
66
62
|
}
|
|
67
63
|
else if (mon.counter > 0)
|
|
68
64
|
mon.isActive = true;
|
|
@@ -70,7 +66,7 @@ class MonitorImpl extends Monitor {
|
|
|
70
66
|
static deactivate(mon, delay) {
|
|
71
67
|
if (delay >= 0) {
|
|
72
68
|
clearTimeout(mon.internals.deactivationTimeout);
|
|
73
|
-
mon.internals.deactivationTimeout = setTimeout(() =>
|
|
69
|
+
mon.internals.deactivationTimeout = setTimeout(() => Transaction.run({ hint: 'Monitor.deactivate', standalone: 'isolated' }, MonitorImpl.deactivate, mon, -1), delay);
|
|
74
70
|
}
|
|
75
71
|
else if (mon.counter <= 0) {
|
|
76
72
|
mon.isActive = false;
|
|
@@ -84,7 +80,7 @@ class MonitorImpl extends Monitor {
|
|
|
84
80
|
}
|
|
85
81
|
static tick(mon) {
|
|
86
82
|
if (mon.internals.started !== 0) {
|
|
87
|
-
|
|
83
|
+
Transaction.run(null, () => {
|
|
88
84
|
const resolution = mon.internals.durationResolution;
|
|
89
85
|
mon.duration = Math.round(resolution * (performance.now() - mon.internals.started)) / resolution;
|
|
90
86
|
});
|
|
@@ -94,4 +90,3 @@ class MonitorImpl extends Monitor {
|
|
|
94
90
|
}
|
|
95
91
|
}
|
|
96
92
|
}
|
|
97
|
-
exports.MonitorImpl = MonitorImpl;
|