reactronic 0.22.310 → 0.22.313
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 +1 -1
- 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 +3 -3
- package/build/dist/source/impl/Changeset.js +96 -99
- package/build/dist/source/impl/Data.js +10 -17
- package/build/dist/source/impl/Hooks.d.ts +1 -0
- package/build/dist/source/impl/Hooks.js +59 -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.d.ts +1 -1
- package/build/dist/source/impl/Monitor.js +15 -16
- 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 +5 -5
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
exports.MAX_REVISION = Number.MAX_SAFE_INTEGER;
|
|
12
|
-
exports.UNDEFINED_REVISION = exports.MAX_REVISION - 1;
|
|
13
|
-
Object.defineProperty(Data_1.ObjectHandle.prototype, '#this', {
|
|
1
|
+
import { Utils, UNDEF } from '../util/Utils';
|
|
2
|
+
import { Log, misuse } from '../util/Dbg';
|
|
3
|
+
import { Sealant } from '../util/Sealant';
|
|
4
|
+
import { SealedArray } from '../util/SealedArray';
|
|
5
|
+
import { SealedMap } from '../util/SealedMap';
|
|
6
|
+
import { SealedSet } from '../util/SealedSet';
|
|
7
|
+
import { ObjectSnapshot, ObjectHandle, Subscription, Meta } from './Data';
|
|
8
|
+
export const MAX_REVISION = Number.MAX_SAFE_INTEGER;
|
|
9
|
+
export const UNDEFINED_REVISION = MAX_REVISION - 1;
|
|
10
|
+
Object.defineProperty(ObjectHandle.prototype, '#this', {
|
|
14
11
|
configurable: false, enumerable: false,
|
|
15
12
|
get() {
|
|
16
13
|
const result = {};
|
|
17
|
-
const data = Changeset.current().
|
|
14
|
+
const data = Changeset.current().getObjectSnapshot(this, '#this').data;
|
|
18
15
|
for (const m in data) {
|
|
19
16
|
const v = data[m];
|
|
20
|
-
if (v instanceof
|
|
17
|
+
if (v instanceof Subscription)
|
|
21
18
|
result[m] = v.content;
|
|
22
|
-
else if (v ===
|
|
19
|
+
else if (v === Meta.Nonreactive)
|
|
23
20
|
result[m] = this.data[m];
|
|
24
21
|
else
|
|
25
22
|
result[m] = v;
|
|
@@ -28,12 +25,12 @@ Object.defineProperty(Data_1.ObjectHandle.prototype, '#this', {
|
|
|
28
25
|
},
|
|
29
26
|
});
|
|
30
27
|
const EMPTY_ARRAY = Object.freeze([]);
|
|
31
|
-
const EMPTY_MAP =
|
|
32
|
-
class Changeset {
|
|
28
|
+
const EMPTY_MAP = Utils.freezeMap(new Map());
|
|
29
|
+
export class Changeset {
|
|
33
30
|
constructor(options) {
|
|
34
31
|
this.id = ++Changeset.idGen;
|
|
35
|
-
this.options = options !== null && options !== void 0 ? options :
|
|
36
|
-
this.revision =
|
|
32
|
+
this.options = options !== null && options !== void 0 ? options : DefaultSnapshotOptions;
|
|
33
|
+
this.revision = UNDEFINED_REVISION;
|
|
37
34
|
this.bumper = 100;
|
|
38
35
|
this.items = new Map();
|
|
39
36
|
this.reactions = [];
|
|
@@ -41,7 +38,7 @@ class Changeset {
|
|
|
41
38
|
}
|
|
42
39
|
get hint() { var _a; return (_a = this.options.hint) !== null && _a !== void 0 ? _a : 'noname'; }
|
|
43
40
|
get timestamp() { return this.revision; }
|
|
44
|
-
|
|
41
|
+
lookupObjectSnapshot(h, m) {
|
|
45
42
|
let os = h.editing;
|
|
46
43
|
if (os && os.changeset !== this) {
|
|
47
44
|
os = this.items.get(h);
|
|
@@ -50,76 +47,78 @@ class Changeset {
|
|
|
50
47
|
}
|
|
51
48
|
if (!os) {
|
|
52
49
|
os = h.head;
|
|
53
|
-
while (os !==
|
|
50
|
+
while (os !== EMPTY_SNAPSHOT && os.changeset.timestamp > this.timestamp)
|
|
54
51
|
os = os.former.snapshot;
|
|
55
52
|
}
|
|
56
53
|
return os;
|
|
57
54
|
}
|
|
58
|
-
|
|
59
|
-
const r = this.
|
|
60
|
-
if (r ===
|
|
61
|
-
throw
|
|
55
|
+
getObjectSnapshot(h, m) {
|
|
56
|
+
const r = this.lookupObjectSnapshot(h, m);
|
|
57
|
+
if (r === EMPTY_SNAPSHOT)
|
|
58
|
+
throw misuse(`cannot use data from a transaction started after the current one T${this.id}[${this.hint}]: ${Dump.obj(h, m)} (head is T${h.head.changeset.id}[${h.head.changeset.hint}]${h.editing ? `, uncommitted T${h.editing.changeset.id}[${h.editing.changeset.hint}]` : ''})`);
|
|
62
59
|
return r;
|
|
63
60
|
}
|
|
64
|
-
|
|
65
|
-
let os = this.
|
|
61
|
+
getEditableObjectSnapshot(h, m, value, token) {
|
|
62
|
+
let os = this.lookupObjectSnapshot(h, m);
|
|
66
63
|
const existing = os.data[m];
|
|
67
|
-
if (existing !==
|
|
64
|
+
if (existing !== Meta.Nonreactive) {
|
|
68
65
|
if (this.isNewSnapshotRequired(h, os, m, existing, value, token)) {
|
|
69
66
|
this.bumpBy(os.changeset.timestamp);
|
|
70
|
-
const revision = m ===
|
|
71
|
-
const data = Object.assign({}, m ===
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
os = new
|
|
67
|
+
const revision = m === Meta.Handle ? 1 : os.revision + 1;
|
|
68
|
+
const data = Object.assign({}, m === Meta.Handle ? value : os.data);
|
|
69
|
+
Meta.set(data, Meta.Handle, h);
|
|
70
|
+
Meta.set(data, Meta.Revision, new Subscription(revision));
|
|
71
|
+
os = new ObjectSnapshot(this, os, data);
|
|
75
72
|
this.items.set(h, os);
|
|
76
73
|
h.editing = os;
|
|
77
74
|
h.editors++;
|
|
78
|
-
if (
|
|
79
|
-
|
|
75
|
+
if (Log.isOn && Log.opt.write)
|
|
76
|
+
Log.write('║', ' ⎘⎘', `${Dump.obj(h)} - new snapshot is created (revision ${revision})`);
|
|
80
77
|
}
|
|
81
78
|
}
|
|
82
79
|
else
|
|
83
|
-
os =
|
|
80
|
+
os = EMPTY_SNAPSHOT;
|
|
84
81
|
return os;
|
|
85
82
|
}
|
|
86
83
|
static takeSnapshot(obj) {
|
|
87
|
-
return obj[
|
|
84
|
+
return obj[Meta.Handle]['#this'];
|
|
88
85
|
}
|
|
89
86
|
static dispose(obj) {
|
|
90
87
|
const ctx = Changeset.edit();
|
|
91
|
-
const h =
|
|
88
|
+
const h = Meta.get(obj, Meta.Handle);
|
|
92
89
|
if (h !== undefined)
|
|
93
90
|
Changeset.doDispose(ctx, h);
|
|
94
91
|
}
|
|
95
92
|
static doDispose(ctx, h) {
|
|
96
|
-
const os = ctx.
|
|
97
|
-
if (os !==
|
|
93
|
+
const os = ctx.getEditableObjectSnapshot(h, Meta.Revision, Meta.Undefined);
|
|
94
|
+
if (os !== EMPTY_SNAPSHOT)
|
|
98
95
|
os.disposed = true;
|
|
99
96
|
return os;
|
|
100
97
|
}
|
|
101
98
|
isNewSnapshotRequired(h, os, m, existing, value, token) {
|
|
102
|
-
if (this.sealed && os.changeset !==
|
|
103
|
-
throw
|
|
104
|
-
if (m !==
|
|
105
|
-
if (
|
|
106
|
-
if (
|
|
107
|
-
|
|
99
|
+
if (this.sealed && os.changeset !== EMPTY_SNAPSHOT.changeset)
|
|
100
|
+
throw misuse(`reactive property ${Dump.obj(h, m)} can only be modified inside transaction`);
|
|
101
|
+
if (m !== Meta.Handle) {
|
|
102
|
+
if (value !== Meta.Handle) {
|
|
103
|
+
if (os.changeset !== this || os.former.snapshot !== EMPTY_SNAPSHOT) {
|
|
104
|
+
if (this.options.token !== undefined && token !== this.options.token)
|
|
105
|
+
throw misuse(`${this.hint} should not have side effects (trying to change ${Dump.snapshot(os, m)})`);
|
|
106
|
+
}
|
|
108
107
|
}
|
|
109
|
-
if (os ===
|
|
110
|
-
throw
|
|
108
|
+
if (os === EMPTY_SNAPSHOT)
|
|
109
|
+
throw misuse(`cannot use data from a transaction started after the current one T${this.id}[${this.hint}]: ${Dump.snapshot(os, m)} (head is T${h.head.changeset.id}[${h.head.changeset.hint}]${h.editing ? `, uncommitted T${h.editing.changeset.id}[${h.editing.changeset.hint}]` : ''})`);
|
|
111
110
|
}
|
|
112
111
|
return os.changeset !== this && !this.sealed;
|
|
113
112
|
}
|
|
114
113
|
acquire(outer) {
|
|
115
|
-
if (!this.sealed && this.revision ===
|
|
116
|
-
const ahead = this.options.token === undefined || outer.revision ===
|
|
114
|
+
if (!this.sealed && this.revision === UNDEFINED_REVISION) {
|
|
115
|
+
const ahead = this.options.token === undefined || outer.revision === UNDEFINED_REVISION;
|
|
117
116
|
this.revision = ahead ? Changeset.stampGen : outer.revision;
|
|
118
117
|
Changeset.pending.push(this);
|
|
119
118
|
if (Changeset.oldest === undefined)
|
|
120
119
|
Changeset.oldest = this;
|
|
121
|
-
if (
|
|
122
|
-
|
|
120
|
+
if (Log.isOn && Log.opt.transaction)
|
|
121
|
+
Log.write('╔══', `v${this.revision}`, `${this.hint}`);
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
124
|
bumpBy(timestamp) {
|
|
@@ -137,8 +136,8 @@ class Changeset {
|
|
|
137
136
|
conflicts = [];
|
|
138
137
|
conflicts.push(os);
|
|
139
138
|
}
|
|
140
|
-
if (
|
|
141
|
-
|
|
139
|
+
if (Log.isOn && Log.opt.transaction)
|
|
140
|
+
Log.write('╠╝', '', `${Dump.snapshot2(h, os.changeset)} is merged with ${Dump.snapshot2(h, h.head.changeset)} among ${merged} properties with ${os.conflicts.size} conflicts.`);
|
|
142
141
|
}
|
|
143
142
|
});
|
|
144
143
|
if (this.options.token === undefined) {
|
|
@@ -167,8 +166,8 @@ class Changeset {
|
|
|
167
166
|
if (headDisposed || oursDisposed) {
|
|
168
167
|
if (headDisposed !== oursDisposed) {
|
|
169
168
|
if (headDisposed || this.options.standalone !== 'disposal') {
|
|
170
|
-
if (
|
|
171
|
-
|
|
169
|
+
if (Log.isOn && Log.opt.change)
|
|
170
|
+
Log.write('║╠', '', `${Dump.snapshot2(h, ours.changeset, m)} <> ${Dump.snapshot2(h, head.changeset, m)}`, 0, ' *** CONFLICT ***');
|
|
172
171
|
ours.conflicts.set(m, head);
|
|
173
172
|
}
|
|
174
173
|
}
|
|
@@ -177,11 +176,11 @@ class Changeset {
|
|
|
177
176
|
const conflict = Changeset.isConflicting(head.data[m], ours.former.snapshot.data[m]);
|
|
178
177
|
if (conflict)
|
|
179
178
|
ours.conflicts.set(m, head);
|
|
180
|
-
if (
|
|
181
|
-
|
|
179
|
+
if (Log.isOn && Log.opt.change)
|
|
180
|
+
Log.write('║╠', '', `${Dump.snapshot2(h, ours.changeset, m)} ${conflict ? '<>' : '=='} ${Dump.snapshot2(h, head.changeset, m)}`, 0, conflict ? ' *** CONFLICT ***' : undefined);
|
|
182
181
|
}
|
|
183
182
|
});
|
|
184
|
-
|
|
183
|
+
Utils.copyAllMembers(merged, ours.data);
|
|
185
184
|
ours.former.snapshot = head;
|
|
186
185
|
return counter;
|
|
187
186
|
}
|
|
@@ -196,22 +195,22 @@ class Changeset {
|
|
|
196
195
|
h.head = os;
|
|
197
196
|
if (Changeset.garbageCollectionSummaryInterval < Number.MAX_SAFE_INTEGER) {
|
|
198
197
|
Changeset.totalObjectSnapshotCount++;
|
|
199
|
-
if (os.former.snapshot ===
|
|
198
|
+
if (os.former.snapshot === EMPTY_SNAPSHOT)
|
|
200
199
|
Changeset.totalObjectHandleCount++;
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
202
|
});
|
|
204
|
-
if (
|
|
205
|
-
if (
|
|
203
|
+
if (Log.isOn) {
|
|
204
|
+
if (Log.opt.change && !error) {
|
|
206
205
|
this.items.forEach((os, h) => {
|
|
207
206
|
const members = [];
|
|
208
207
|
os.changes.forEach((o, m) => members.push(m.toString()));
|
|
209
208
|
const s = members.join(', ');
|
|
210
|
-
|
|
209
|
+
Log.write('║', '√', `${Dump.snapshot2(h, os.changeset)} (${s}) is ${os.former.snapshot === EMPTY_SNAPSHOT ? 'constructed' : `applied on top of ${Dump.snapshot2(h, os.former.snapshot.changeset)}`}`);
|
|
211
210
|
});
|
|
212
211
|
}
|
|
213
|
-
if (
|
|
214
|
-
|
|
212
|
+
if (Log.opt.transaction)
|
|
213
|
+
Log.write(this.revision < UNDEFINED_REVISION ? '╚══' : '═══', `v${this.revision}`, `${this.hint} - ${error ? 'CANCEL' : 'APPLY'}(${this.items.size})${error ? ` - ${error}` : ''}`);
|
|
215
214
|
}
|
|
216
215
|
if (!error)
|
|
217
216
|
Changeset.propagateAllChangesThroughSubscriptions(this);
|
|
@@ -222,24 +221,24 @@ class Changeset {
|
|
|
222
221
|
os.changes.forEach((o, m) => Changeset.sealSubscription(os.data[m], m, h.proxy.constructor.name));
|
|
223
222
|
else
|
|
224
223
|
for (const m in os.former.snapshot.data)
|
|
225
|
-
os.data[m] =
|
|
226
|
-
if (
|
|
224
|
+
os.data[m] = Meta.Undefined;
|
|
225
|
+
if (Log.isOn)
|
|
227
226
|
Changeset.freezeObjectSnapshot(os);
|
|
228
227
|
}
|
|
229
228
|
static sealSubscription(subscription, m, typeName) {
|
|
230
|
-
if (subscription instanceof
|
|
229
|
+
if (subscription instanceof Subscription) {
|
|
231
230
|
const value = subscription.content;
|
|
232
231
|
if (value !== undefined && value !== null) {
|
|
233
|
-
const sealedType = Object.getPrototypeOf(value)[
|
|
232
|
+
const sealedType = Object.getPrototypeOf(value)[Sealant.SealedType];
|
|
234
233
|
if (sealedType)
|
|
235
|
-
subscription.content =
|
|
234
|
+
subscription.content = Sealant.seal(value, sealedType, typeName, m);
|
|
236
235
|
}
|
|
237
236
|
}
|
|
238
237
|
}
|
|
239
238
|
static freezeObjectSnapshot(os) {
|
|
240
239
|
Object.freeze(os.data);
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
Utils.freezeSet(os.changes);
|
|
241
|
+
Utils.freezeMap(os.conflicts);
|
|
243
242
|
return os;
|
|
244
243
|
}
|
|
245
244
|
triggerGarbageCollection() {
|
|
@@ -256,46 +255,45 @@ class Changeset {
|
|
|
256
255
|
Changeset.oldest = Changeset.pending[0];
|
|
257
256
|
const now = Date.now();
|
|
258
257
|
if (now - Changeset.lastGarbageCollectionSummaryTimestamp > Changeset.garbageCollectionSummaryInterval) {
|
|
259
|
-
|
|
258
|
+
Log.write('', '[G]', `Total object/snapshot count: ${Changeset.totalObjectHandleCount}/${Changeset.totalObjectSnapshotCount}`);
|
|
260
259
|
Changeset.lastGarbageCollectionSummaryTimestamp = now;
|
|
261
260
|
}
|
|
262
261
|
}
|
|
263
262
|
}
|
|
264
263
|
}
|
|
265
264
|
unlinkHistory() {
|
|
266
|
-
if (
|
|
267
|
-
|
|
265
|
+
if (Log.isOn && Log.opt.gc)
|
|
266
|
+
Log.write('', '[G]', `Dismiss history below v${this.revision}t${this.id} (${this.hint})`);
|
|
268
267
|
this.items.forEach((os, h) => {
|
|
269
|
-
if (
|
|
270
|
-
|
|
268
|
+
if (Log.isOn && Log.opt.gc && os.former.snapshot !== EMPTY_SNAPSHOT)
|
|
269
|
+
Log.write(' ', ' ', `${Dump.snapshot2(h, os.former.snapshot.changeset)} is ready for GC because overwritten by ${Dump.snapshot2(h, os.changeset)}`);
|
|
271
270
|
if (Changeset.garbageCollectionSummaryInterval < Number.MAX_SAFE_INTEGER) {
|
|
272
|
-
if (os.former.snapshot !==
|
|
271
|
+
if (os.former.snapshot !== EMPTY_SNAPSHOT)
|
|
273
272
|
Changeset.totalObjectSnapshotCount--;
|
|
274
273
|
if (os.disposed)
|
|
275
274
|
Changeset.totalObjectHandleCount--;
|
|
276
275
|
}
|
|
277
|
-
os.former.snapshot =
|
|
276
|
+
os.former.snapshot = EMPTY_SNAPSHOT;
|
|
278
277
|
});
|
|
279
278
|
this.items = EMPTY_MAP;
|
|
280
279
|
this.reactions = EMPTY_ARRAY;
|
|
281
|
-
if (
|
|
280
|
+
if (Log.isOn)
|
|
282
281
|
Object.freeze(this);
|
|
283
282
|
}
|
|
284
283
|
static _init() {
|
|
285
|
-
const boot =
|
|
284
|
+
const boot = EMPTY_SNAPSHOT.changeset;
|
|
286
285
|
boot.acquire(boot);
|
|
287
286
|
boot.applyOrDiscard();
|
|
288
287
|
boot.triggerGarbageCollection();
|
|
289
|
-
Changeset.freezeObjectSnapshot(
|
|
288
|
+
Changeset.freezeObjectSnapshot(EMPTY_SNAPSHOT);
|
|
290
289
|
Changeset.idGen = 100;
|
|
291
290
|
Changeset.stampGen = 101;
|
|
292
291
|
Changeset.oldest = undefined;
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
292
|
+
SealedArray.prototype;
|
|
293
|
+
SealedMap.prototype;
|
|
294
|
+
SealedSet.prototype;
|
|
296
295
|
}
|
|
297
296
|
}
|
|
298
|
-
exports.Changeset = Changeset;
|
|
299
297
|
Changeset.idGen = -1;
|
|
300
298
|
Changeset.stampGen = 1;
|
|
301
299
|
Changeset.pending = [];
|
|
@@ -304,20 +302,20 @@ Changeset.garbageCollectionSummaryInterval = Number.MAX_SAFE_INTEGER;
|
|
|
304
302
|
Changeset.lastGarbageCollectionSummaryTimestamp = Date.now();
|
|
305
303
|
Changeset.totalObjectHandleCount = 0;
|
|
306
304
|
Changeset.totalObjectSnapshotCount = 0;
|
|
307
|
-
Changeset.current =
|
|
308
|
-
Changeset.edit =
|
|
309
|
-
Changeset.markUsed =
|
|
310
|
-
Changeset.markEdited =
|
|
311
|
-
Changeset.isConflicting =
|
|
305
|
+
Changeset.current = UNDEF;
|
|
306
|
+
Changeset.edit = UNDEF;
|
|
307
|
+
Changeset.markUsed = UNDEF;
|
|
308
|
+
Changeset.markEdited = UNDEF;
|
|
309
|
+
Changeset.isConflicting = UNDEF;
|
|
312
310
|
Changeset.propagateAllChangesThroughSubscriptions = (changeset) => { };
|
|
313
311
|
Changeset.revokeAllSubscriptions = (changeset) => { };
|
|
314
312
|
Changeset.enqueueReactionsToRun = (reactions) => { };
|
|
315
|
-
class Dump {
|
|
313
|
+
export class Dump {
|
|
316
314
|
static obj(h, m, stamp, snapshotId, originSnapshotId, value) {
|
|
317
315
|
const member = m !== undefined ? `.${m.toString()}` : '';
|
|
318
316
|
let result;
|
|
319
317
|
if (h !== undefined) {
|
|
320
|
-
const v = value !== undefined && value !==
|
|
318
|
+
const v = value !== undefined && value !== Meta.Undefined ? `[=${Dump.valueHint(value)}]` : '';
|
|
321
319
|
if (stamp === undefined)
|
|
322
320
|
result = `${h.hint}${member}${v} #${h.id}`;
|
|
323
321
|
else
|
|
@@ -329,10 +327,10 @@ class Dump {
|
|
|
329
327
|
}
|
|
330
328
|
static snapshot2(h, s, m, o) {
|
|
331
329
|
var _a;
|
|
332
|
-
return Dump.obj(h, m, s.timestamp, s.id, o === null || o === void 0 ? void 0 : o.originSnapshotId, (_a = o === null || o === void 0 ? void 0 : o.content) !== null && _a !== void 0 ? _a :
|
|
330
|
+
return Dump.obj(h, m, s.timestamp, s.id, o === null || o === void 0 ? void 0 : o.originSnapshotId, (_a = o === null || o === void 0 ? void 0 : o.content) !== null && _a !== void 0 ? _a : Meta.Undefined);
|
|
333
331
|
}
|
|
334
332
|
static snapshot(os, m) {
|
|
335
|
-
const h =
|
|
333
|
+
const h = Meta.get(os.data, Meta.Handle);
|
|
336
334
|
const value = m !== undefined ? os.data[m] : undefined;
|
|
337
335
|
return Dump.obj(h, m, os.changeset.timestamp, os.changeset.id, value === null || value === void 0 ? void 0 : value.originSnapshotId);
|
|
338
336
|
}
|
|
@@ -349,10 +347,9 @@ class Dump {
|
|
|
349
347
|
return `${theirs.changeset.hint} (${Dump.snapshot(theirs, m)})`;
|
|
350
348
|
}
|
|
351
349
|
}
|
|
352
|
-
exports.Dump = Dump;
|
|
353
350
|
Dump.valueHint = (value, m) => '???';
|
|
354
|
-
|
|
355
|
-
|
|
351
|
+
export const EMPTY_SNAPSHOT = new ObjectSnapshot(new Changeset({ hint: '<empty>' }), undefined, {});
|
|
352
|
+
export const DefaultSnapshotOptions = Object.freeze({
|
|
356
353
|
hint: 'noname',
|
|
357
354
|
standalone: false,
|
|
358
355
|
journal: undefined,
|
|
@@ -1,38 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Meta_1 = require("./Meta");
|
|
6
|
-
var Meta_2 = require("./Meta");
|
|
7
|
-
Object.defineProperty(exports, "Meta", { enumerable: true, get: function () { return Meta_2.Meta; } });
|
|
8
|
-
class Subscription {
|
|
1
|
+
import { Log } from '../util/Dbg';
|
|
2
|
+
import { Meta } from './Meta';
|
|
3
|
+
export { Meta } from './Meta';
|
|
4
|
+
export class Subscription {
|
|
9
5
|
constructor(content) { this.content = content; }
|
|
10
6
|
get isOperation() { return false; }
|
|
11
7
|
get originSnapshotId() { return 0; }
|
|
12
8
|
}
|
|
13
|
-
|
|
14
|
-
class ObjectSnapshot {
|
|
9
|
+
export class ObjectSnapshot {
|
|
15
10
|
constructor(changeset, former, data) {
|
|
16
11
|
this.changeset = changeset;
|
|
17
12
|
this.former = { snapshot: former || this };
|
|
18
13
|
this.data = data;
|
|
19
14
|
this.changes = new Set();
|
|
20
15
|
this.conflicts = new Map();
|
|
21
|
-
if (
|
|
16
|
+
if (Log.isOn)
|
|
22
17
|
Object.freeze(this);
|
|
23
18
|
}
|
|
24
19
|
get revision() {
|
|
25
|
-
return this.data[
|
|
20
|
+
return this.data[Meta.Revision].content;
|
|
26
21
|
}
|
|
27
22
|
get disposed() { return this.revision < 0; }
|
|
28
23
|
set disposed(value) {
|
|
29
24
|
const rev = this.revision;
|
|
30
25
|
if (rev < 0 !== value)
|
|
31
|
-
this.data[
|
|
26
|
+
this.data[Meta.Revision].content = ~rev;
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
|
-
|
|
35
|
-
class ObjectHandle {
|
|
29
|
+
export class ObjectHandle {
|
|
36
30
|
constructor(data, proxy, handler, head, hint) {
|
|
37
31
|
this.id = ++ObjectHandle.generator;
|
|
38
32
|
this.data = data;
|
|
@@ -43,9 +37,8 @@ class ObjectHandle {
|
|
|
43
37
|
this.hint = hint;
|
|
44
38
|
}
|
|
45
39
|
static getHint(obj, full) {
|
|
46
|
-
const h =
|
|
40
|
+
const h = Meta.get(obj, Meta.Handle);
|
|
47
41
|
return h !== undefined ? (full ? `${h.hint}#${h.id}` : h.hint) : undefined;
|
|
48
42
|
}
|
|
49
43
|
}
|
|
50
|
-
exports.ObjectHandle = ObjectHandle;
|
|
51
44
|
ObjectHandle.generator = 19;
|
|
@@ -91,6 +91,7 @@ export declare class Hooks implements ProxyHandler<ObjectHandle> {
|
|
|
91
91
|
static setProfilingMode(isOn: boolean, options?: Partial<ProfilingOptions>): void;
|
|
92
92
|
static sensitive<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
93
93
|
static setHint<T>(obj: T, hint: string | undefined): T;
|
|
94
|
+
static getHint<T>(obj: T): string;
|
|
94
95
|
static createOperation: (h: ObjectHandle, m: MemberName, options: OptionsImpl) => F<any>;
|
|
95
96
|
static rememberOperationOptions: (proto: any, m: MemberName, getter: Function | undefined, setter: Function | undefined, enumerable: boolean, configurable: boolean, options: Partial<MemberOptions>, implicit: boolean) => OptionsImpl;
|
|
96
97
|
}
|