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.
@@ -1,25 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultSnapshotOptions = exports.EMPTY_SNAPSHOT = exports.Dump = exports.Changeset = exports.UNDEFINED_REVISION = exports.MAX_REVISION = void 0;
4
- const Utils_1 = require("../util/Utils");
5
- const Dbg_1 = require("../util/Dbg");
6
- const Sealant_1 = require("../util/Sealant");
7
- const SealedArray_1 = require("../util/SealedArray");
8
- const SealedMap_1 = require("../util/SealedMap");
9
- const SealedSet_1 = require("../util/SealedSet");
10
- const Data_1 = require("./Data");
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().getRelevantSnapshot(this, '#this').data;
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 Data_1.Subscription)
17
+ if (v instanceof Subscription)
21
18
  result[m] = v.content;
22
- else if (v === Data_1.Meta.Nonreactive)
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 = Utils_1.Utils.freezeMap(new 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 : exports.DefaultSnapshotOptions;
36
- this.revision = exports.UNDEFINED_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
- seekSnapshot(h, m) {
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 !== exports.EMPTY_SNAPSHOT && os.changeset.timestamp > this.timestamp)
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
- getRelevantSnapshot(h, m) {
59
- const r = this.seekSnapshot(h, m);
60
- if (r === exports.EMPTY_SNAPSHOT)
61
- throw (0, Dbg_1.misuse)(`object ${Dump.obj(h)} doesn't exist in snapshot v${this.revision} (${this.hint})`);
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
- getEditableSnapshot(h, m, value, token) {
65
- let os = this.seekSnapshot(h, m);
61
+ getEditableObjectSnapshot(h, m, value, token) {
62
+ let os = this.lookupObjectSnapshot(h, m);
66
63
  const existing = os.data[m];
67
- if (existing !== Data_1.Meta.Nonreactive) {
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 === Data_1.Meta.Handle ? 1 : os.revision + 1;
71
- const data = Object.assign({}, m === Data_1.Meta.Handle ? value : os.data);
72
- Data_1.Meta.set(data, Data_1.Meta.Handle, h);
73
- Data_1.Meta.set(data, Data_1.Meta.Revision, new Data_1.Subscription(revision));
74
- os = new Data_1.ObjectSnapshot(this, os, data);
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 (Dbg_1.Log.isOn && Dbg_1.Log.opt.write)
79
- Dbg_1.Log.write('║', ' ⎘⎘', `${Dump.obj(h)} - new snapshot is created (revision ${revision})`);
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 = exports.EMPTY_SNAPSHOT;
80
+ os = EMPTY_SNAPSHOT;
84
81
  return os;
85
82
  }
86
83
  static takeSnapshot(obj) {
87
- return obj[Data_1.Meta.Handle]['#this'];
84
+ return obj[Meta.Handle]['#this'];
88
85
  }
89
86
  static dispose(obj) {
90
87
  const ctx = Changeset.edit();
91
- const h = Data_1.Meta.get(obj, Data_1.Meta.Handle);
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.getEditableSnapshot(h, Data_1.Meta.Revision, Data_1.Meta.Undefined);
97
- if (os !== exports.EMPTY_SNAPSHOT)
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 !== exports.EMPTY_SNAPSHOT.changeset)
103
- throw (0, Dbg_1.misuse)(`reactive property ${Dump.obj(h, m)} can only be modified inside transaction`);
104
- if (m !== Data_1.Meta.Handle && value !== Data_1.Meta.Handle) {
105
- if (os.changeset !== this || os.former.snapshot !== exports.EMPTY_SNAPSHOT) {
106
- if (this.options.token !== undefined && token !== this.options.token)
107
- throw (0, Dbg_1.misuse)(`${this.hint} should not have side effects (trying to change ${Dump.snapshot(os, m)})`);
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 === exports.EMPTY_SNAPSHOT)
110
- throw (0, Dbg_1.misuse)(`member ${Dump.snapshot(os, m)} doesn't exist in snapshot v${this.revision} (${this.hint})`);
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 === exports.UNDEFINED_REVISION) {
116
- const ahead = this.options.token === undefined || outer.revision === exports.UNDEFINED_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 (Dbg_1.Log.isOn && Dbg_1.Log.opt.transaction)
122
- Dbg_1.Log.write('╔══', `v${this.revision}`, `${this.hint}`);
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 (Dbg_1.Log.isOn && Dbg_1.Log.opt.transaction)
141
- Dbg_1.Log.write('╠╝', '', `${Dump.snapshot2(h, os.changeset)} is merged with ${Dump.snapshot2(h, h.head.changeset)} among ${merged} properties with ${os.conflicts.size} conflicts.`);
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 (Dbg_1.Log.isOn && Dbg_1.Log.opt.change)
171
- Dbg_1.Log.write('║╠', '', `${Dump.snapshot2(h, ours.changeset, m)} <> ${Dump.snapshot2(h, head.changeset, m)}`, 0, ' *** CONFLICT ***');
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 (Dbg_1.Log.isOn && Dbg_1.Log.opt.change)
181
- Dbg_1.Log.write('║╠', '', `${Dump.snapshot2(h, ours.changeset, m)} ${conflict ? '<>' : '=='} ${Dump.snapshot2(h, head.changeset, m)}`, 0, conflict ? ' *** CONFLICT ***' : undefined);
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
- Utils_1.Utils.copyAllMembers(merged, ours.data);
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 === exports.EMPTY_SNAPSHOT)
198
+ if (os.former.snapshot === EMPTY_SNAPSHOT)
200
199
  Changeset.totalObjectHandleCount++;
201
200
  }
202
201
  }
203
202
  });
204
- if (Dbg_1.Log.isOn) {
205
- if (Dbg_1.Log.opt.change && !error) {
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
- Dbg_1.Log.write('║', '√', `${Dump.snapshot2(h, os.changeset)} (${s}) is ${os.former.snapshot === exports.EMPTY_SNAPSHOT ? 'constructed' : `applied on top of ${Dump.snapshot2(h, os.former.snapshot.changeset)}`}`);
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 (Dbg_1.Log.opt.transaction)
214
- Dbg_1.Log.write(this.revision < exports.UNDEFINED_REVISION ? '╚══' : '═══', `v${this.revision}`, `${this.hint} - ${error ? 'CANCEL' : 'APPLY'}(${this.items.size})${error ? ` - ${error}` : ''}`);
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] = Data_1.Meta.Undefined;
226
- if (Dbg_1.Log.isOn)
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 Data_1.Subscription) {
229
+ if (subscription instanceof Subscription) {
231
230
  const value = subscription.content;
232
231
  if (value !== undefined && value !== null) {
233
- const sealedType = Object.getPrototypeOf(value)[Sealant_1.Sealant.SealedType];
232
+ const sealedType = Object.getPrototypeOf(value)[Sealant.SealedType];
234
233
  if (sealedType)
235
- subscription.content = Sealant_1.Sealant.seal(value, sealedType, typeName, m);
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
- Utils_1.Utils.freezeSet(os.changes);
242
- Utils_1.Utils.freezeMap(os.conflicts);
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
- Dbg_1.Log.write('', '[G]', `Total object/snapshot count: ${Changeset.totalObjectHandleCount}/${Changeset.totalObjectSnapshotCount}`);
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 (Dbg_1.Log.isOn && Dbg_1.Log.opt.gc)
267
- Dbg_1.Log.write('', '[G]', `Dismiss history below v${this.revision}t${this.id} (${this.hint})`);
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 (Dbg_1.Log.isOn && Dbg_1.Log.opt.gc && os.former.snapshot !== exports.EMPTY_SNAPSHOT)
270
- Dbg_1.Log.write(' ', ' ', `${Dump.snapshot2(h, os.former.snapshot.changeset)} is ready for GC because overwritten by ${Dump.snapshot2(h, os.changeset)}`);
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 !== exports.EMPTY_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 = exports.EMPTY_SNAPSHOT;
276
+ os.former.snapshot = EMPTY_SNAPSHOT;
278
277
  });
279
278
  this.items = EMPTY_MAP;
280
279
  this.reactions = EMPTY_ARRAY;
281
- if (Dbg_1.Log.isOn)
280
+ if (Log.isOn)
282
281
  Object.freeze(this);
283
282
  }
284
283
  static _init() {
285
- const boot = exports.EMPTY_SNAPSHOT.changeset;
284
+ const boot = EMPTY_SNAPSHOT.changeset;
286
285
  boot.acquire(boot);
287
286
  boot.applyOrDiscard();
288
287
  boot.triggerGarbageCollection();
289
- Changeset.freezeObjectSnapshot(exports.EMPTY_SNAPSHOT);
288
+ Changeset.freezeObjectSnapshot(EMPTY_SNAPSHOT);
290
289
  Changeset.idGen = 100;
291
290
  Changeset.stampGen = 101;
292
291
  Changeset.oldest = undefined;
293
- SealedArray_1.SealedArray.prototype;
294
- SealedMap_1.SealedMap.prototype;
295
- SealedSet_1.SealedSet.prototype;
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 = Utils_1.UNDEF;
308
- Changeset.edit = Utils_1.UNDEF;
309
- Changeset.markUsed = Utils_1.UNDEF;
310
- Changeset.markEdited = Utils_1.UNDEF;
311
- Changeset.isConflicting = Utils_1.UNDEF;
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 !== Data_1.Meta.Undefined ? `[=${Dump.valueHint(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 : Data_1.Meta.Undefined);
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 = Data_1.Meta.get(os.data, Data_1.Meta.Handle);
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
- exports.EMPTY_SNAPSHOT = new Data_1.ObjectSnapshot(new Changeset({ hint: '<empty>' }), undefined, {});
355
- exports.DefaultSnapshotOptions = Object.freeze({
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObjectHandle = exports.ObjectSnapshot = exports.Subscription = exports.Meta = void 0;
4
- const Dbg_1 = require("../util/Dbg");
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
- exports.Subscription = Subscription;
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 (Dbg_1.Log.isOn)
16
+ if (Log.isOn)
22
17
  Object.freeze(this);
23
18
  }
24
19
  get revision() {
25
- return this.data[Meta_1.Meta.Revision].content;
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[Meta_1.Meta.Revision].content = ~rev;
26
+ this.data[Meta.Revision].content = ~rev;
32
27
  }
33
28
  }
34
- exports.ObjectSnapshot = ObjectSnapshot;
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 = Meta_1.Meta.get(obj, Meta_1.Meta.Handle);
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;