reactronic 0.22.310 → 0.22.311

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
14
  const data = Changeset.current().getRelevantSnapshot(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 = [];
@@ -50,76 +47,76 @@ 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
55
  getRelevantSnapshot(h, m) {
59
56
  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})`);
57
+ if (r === EMPTY_SNAPSHOT)
58
+ throw misuse(`object ${Dump.obj(h)} doesn't exist in snapshot v${this.revision} (${this.hint})`);
62
59
  return r;
63
60
  }
64
61
  getEditableSnapshot(h, m, value, token) {
65
62
  let os = this.seekSnapshot(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.getEditableSnapshot(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) {
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 && value !== Meta.Handle) {
102
+ if (os.changeset !== this || os.former.snapshot !== EMPTY_SNAPSHOT) {
106
103
  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)})`);
104
+ throw misuse(`${this.hint} should not have side effects (trying to change ${Dump.snapshot(os, m)})`);
108
105
  }
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})`);
106
+ if (os === EMPTY_SNAPSHOT)
107
+ throw misuse(`member ${Dump.snapshot(os, m)} doesn't exist in snapshot v${this.revision} (${this.hint})`);
111
108
  }
112
109
  return os.changeset !== this && !this.sealed;
113
110
  }
114
111
  acquire(outer) {
115
- if (!this.sealed && this.revision === exports.UNDEFINED_REVISION) {
116
- const ahead = this.options.token === undefined || outer.revision === exports.UNDEFINED_REVISION;
112
+ if (!this.sealed && this.revision === UNDEFINED_REVISION) {
113
+ const ahead = this.options.token === undefined || outer.revision === UNDEFINED_REVISION;
117
114
  this.revision = ahead ? Changeset.stampGen : outer.revision;
118
115
  Changeset.pending.push(this);
119
116
  if (Changeset.oldest === undefined)
120
117
  Changeset.oldest = this;
121
- if (Dbg_1.Log.isOn && Dbg_1.Log.opt.transaction)
122
- Dbg_1.Log.write('╔══', `v${this.revision}`, `${this.hint}`);
118
+ if (Log.isOn && Log.opt.transaction)
119
+ Log.write('╔══', `v${this.revision}`, `${this.hint}`);
123
120
  }
124
121
  }
125
122
  bumpBy(timestamp) {
@@ -137,8 +134,8 @@ class Changeset {
137
134
  conflicts = [];
138
135
  conflicts.push(os);
139
136
  }
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.`);
137
+ if (Log.isOn && Log.opt.transaction)
138
+ 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
139
  }
143
140
  });
144
141
  if (this.options.token === undefined) {
@@ -167,8 +164,8 @@ class Changeset {
167
164
  if (headDisposed || oursDisposed) {
168
165
  if (headDisposed !== oursDisposed) {
169
166
  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 ***');
167
+ if (Log.isOn && Log.opt.change)
168
+ Log.write('║╠', '', `${Dump.snapshot2(h, ours.changeset, m)} <> ${Dump.snapshot2(h, head.changeset, m)}`, 0, ' *** CONFLICT ***');
172
169
  ours.conflicts.set(m, head);
173
170
  }
174
171
  }
@@ -177,11 +174,11 @@ class Changeset {
177
174
  const conflict = Changeset.isConflicting(head.data[m], ours.former.snapshot.data[m]);
178
175
  if (conflict)
179
176
  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);
177
+ if (Log.isOn && Log.opt.change)
178
+ Log.write('║╠', '', `${Dump.snapshot2(h, ours.changeset, m)} ${conflict ? '<>' : '=='} ${Dump.snapshot2(h, head.changeset, m)}`, 0, conflict ? ' *** CONFLICT ***' : undefined);
182
179
  }
183
180
  });
184
- Utils_1.Utils.copyAllMembers(merged, ours.data);
181
+ Utils.copyAllMembers(merged, ours.data);
185
182
  ours.former.snapshot = head;
186
183
  return counter;
187
184
  }
@@ -196,22 +193,22 @@ class Changeset {
196
193
  h.head = os;
197
194
  if (Changeset.garbageCollectionSummaryInterval < Number.MAX_SAFE_INTEGER) {
198
195
  Changeset.totalObjectSnapshotCount++;
199
- if (os.former.snapshot === exports.EMPTY_SNAPSHOT)
196
+ if (os.former.snapshot === EMPTY_SNAPSHOT)
200
197
  Changeset.totalObjectHandleCount++;
201
198
  }
202
199
  }
203
200
  });
204
- if (Dbg_1.Log.isOn) {
205
- if (Dbg_1.Log.opt.change && !error) {
201
+ if (Log.isOn) {
202
+ if (Log.opt.change && !error) {
206
203
  this.items.forEach((os, h) => {
207
204
  const members = [];
208
205
  os.changes.forEach((o, m) => members.push(m.toString()));
209
206
  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)}`}`);
207
+ 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
208
  });
212
209
  }
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}` : ''}`);
210
+ if (Log.opt.transaction)
211
+ Log.write(this.revision < UNDEFINED_REVISION ? '╚══' : '═══', `v${this.revision}`, `${this.hint} - ${error ? 'CANCEL' : 'APPLY'}(${this.items.size})${error ? ` - ${error}` : ''}`);
215
212
  }
216
213
  if (!error)
217
214
  Changeset.propagateAllChangesThroughSubscriptions(this);
@@ -222,24 +219,24 @@ class Changeset {
222
219
  os.changes.forEach((o, m) => Changeset.sealSubscription(os.data[m], m, h.proxy.constructor.name));
223
220
  else
224
221
  for (const m in os.former.snapshot.data)
225
- os.data[m] = Data_1.Meta.Undefined;
226
- if (Dbg_1.Log.isOn)
222
+ os.data[m] = Meta.Undefined;
223
+ if (Log.isOn)
227
224
  Changeset.freezeObjectSnapshot(os);
228
225
  }
229
226
  static sealSubscription(subscription, m, typeName) {
230
- if (subscription instanceof Data_1.Subscription) {
227
+ if (subscription instanceof Subscription) {
231
228
  const value = subscription.content;
232
229
  if (value !== undefined && value !== null) {
233
- const sealedType = Object.getPrototypeOf(value)[Sealant_1.Sealant.SealedType];
230
+ const sealedType = Object.getPrototypeOf(value)[Sealant.SealedType];
234
231
  if (sealedType)
235
- subscription.content = Sealant_1.Sealant.seal(value, sealedType, typeName, m);
232
+ subscription.content = Sealant.seal(value, sealedType, typeName, m);
236
233
  }
237
234
  }
238
235
  }
239
236
  static freezeObjectSnapshot(os) {
240
237
  Object.freeze(os.data);
241
- Utils_1.Utils.freezeSet(os.changes);
242
- Utils_1.Utils.freezeMap(os.conflicts);
238
+ Utils.freezeSet(os.changes);
239
+ Utils.freezeMap(os.conflicts);
243
240
  return os;
244
241
  }
245
242
  triggerGarbageCollection() {
@@ -256,46 +253,45 @@ class Changeset {
256
253
  Changeset.oldest = Changeset.pending[0];
257
254
  const now = Date.now();
258
255
  if (now - Changeset.lastGarbageCollectionSummaryTimestamp > Changeset.garbageCollectionSummaryInterval) {
259
- Dbg_1.Log.write('', '[G]', `Total object/snapshot count: ${Changeset.totalObjectHandleCount}/${Changeset.totalObjectSnapshotCount}`);
256
+ Log.write('', '[G]', `Total object/snapshot count: ${Changeset.totalObjectHandleCount}/${Changeset.totalObjectSnapshotCount}`);
260
257
  Changeset.lastGarbageCollectionSummaryTimestamp = now;
261
258
  }
262
259
  }
263
260
  }
264
261
  }
265
262
  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})`);
263
+ if (Log.isOn && Log.opt.gc)
264
+ Log.write('', '[G]', `Dismiss history below v${this.revision}t${this.id} (${this.hint})`);
268
265
  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)}`);
266
+ if (Log.isOn && Log.opt.gc && os.former.snapshot !== EMPTY_SNAPSHOT)
267
+ Log.write(' ', ' ', `${Dump.snapshot2(h, os.former.snapshot.changeset)} is ready for GC because overwritten by ${Dump.snapshot2(h, os.changeset)}`);
271
268
  if (Changeset.garbageCollectionSummaryInterval < Number.MAX_SAFE_INTEGER) {
272
- if (os.former.snapshot !== exports.EMPTY_SNAPSHOT)
269
+ if (os.former.snapshot !== EMPTY_SNAPSHOT)
273
270
  Changeset.totalObjectSnapshotCount--;
274
271
  if (os.disposed)
275
272
  Changeset.totalObjectHandleCount--;
276
273
  }
277
- os.former.snapshot = exports.EMPTY_SNAPSHOT;
274
+ os.former.snapshot = EMPTY_SNAPSHOT;
278
275
  });
279
276
  this.items = EMPTY_MAP;
280
277
  this.reactions = EMPTY_ARRAY;
281
- if (Dbg_1.Log.isOn)
278
+ if (Log.isOn)
282
279
  Object.freeze(this);
283
280
  }
284
281
  static _init() {
285
- const boot = exports.EMPTY_SNAPSHOT.changeset;
282
+ const boot = EMPTY_SNAPSHOT.changeset;
286
283
  boot.acquire(boot);
287
284
  boot.applyOrDiscard();
288
285
  boot.triggerGarbageCollection();
289
- Changeset.freezeObjectSnapshot(exports.EMPTY_SNAPSHOT);
286
+ Changeset.freezeObjectSnapshot(EMPTY_SNAPSHOT);
290
287
  Changeset.idGen = 100;
291
288
  Changeset.stampGen = 101;
292
289
  Changeset.oldest = undefined;
293
- SealedArray_1.SealedArray.prototype;
294
- SealedMap_1.SealedMap.prototype;
295
- SealedSet_1.SealedSet.prototype;
290
+ SealedArray.prototype;
291
+ SealedMap.prototype;
292
+ SealedSet.prototype;
296
293
  }
297
294
  }
298
- exports.Changeset = Changeset;
299
295
  Changeset.idGen = -1;
300
296
  Changeset.stampGen = 1;
301
297
  Changeset.pending = [];
@@ -304,20 +300,20 @@ Changeset.garbageCollectionSummaryInterval = Number.MAX_SAFE_INTEGER;
304
300
  Changeset.lastGarbageCollectionSummaryTimestamp = Date.now();
305
301
  Changeset.totalObjectHandleCount = 0;
306
302
  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;
303
+ Changeset.current = UNDEF;
304
+ Changeset.edit = UNDEF;
305
+ Changeset.markUsed = UNDEF;
306
+ Changeset.markEdited = UNDEF;
307
+ Changeset.isConflicting = UNDEF;
312
308
  Changeset.propagateAllChangesThroughSubscriptions = (changeset) => { };
313
309
  Changeset.revokeAllSubscriptions = (changeset) => { };
314
310
  Changeset.enqueueReactionsToRun = (reactions) => { };
315
- class Dump {
311
+ export class Dump {
316
312
  static obj(h, m, stamp, snapshotId, originSnapshotId, value) {
317
313
  const member = m !== undefined ? `.${m.toString()}` : '';
318
314
  let result;
319
315
  if (h !== undefined) {
320
- const v = value !== undefined && value !== Data_1.Meta.Undefined ? `[=${Dump.valueHint(value)}]` : '';
316
+ const v = value !== undefined && value !== Meta.Undefined ? `[=${Dump.valueHint(value)}]` : '';
321
317
  if (stamp === undefined)
322
318
  result = `${h.hint}${member}${v} #${h.id}`;
323
319
  else
@@ -329,10 +325,10 @@ class Dump {
329
325
  }
330
326
  static snapshot2(h, s, m, o) {
331
327
  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);
328
+ 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
329
  }
334
330
  static snapshot(os, m) {
335
- const h = Data_1.Meta.get(os.data, Data_1.Meta.Handle);
331
+ const h = Meta.get(os.data, Meta.Handle);
336
332
  const value = m !== undefined ? os.data[m] : undefined;
337
333
  return Dump.obj(h, m, os.changeset.timestamp, os.changeset.id, value === null || value === void 0 ? void 0 : value.originSnapshotId);
338
334
  }
@@ -349,10 +345,9 @@ class Dump {
349
345
  return `${theirs.changeset.hint} (${Dump.snapshot(theirs, m)})`;
350
346
  }
351
347
  }
352
- exports.Dump = Dump;
353
348
  Dump.valueHint = (value, m) => '???';
354
- exports.EMPTY_SNAPSHOT = new Data_1.ObjectSnapshot(new Changeset({ hint: '<empty>' }), undefined, {});
355
- exports.DefaultSnapshotOptions = Object.freeze({
349
+ export const EMPTY_SNAPSHOT = new ObjectSnapshot(new Changeset({ hint: '<empty>' }), undefined, {});
350
+ export const DefaultSnapshotOptions = Object.freeze({
356
351
  hint: 'noname',
357
352
  standalone: false,
358
353
  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;