@dxos/echo-pipeline 0.4.10-main.b3cf40d → 0.4.10-main.bb9f1bf

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.
Files changed (74) hide show
  1. package/dist/lib/browser/{chunk-RTEEJ723.mjs → chunk-KMWJLYEQ.mjs} +77 -57
  2. package/dist/lib/browser/chunk-KMWJLYEQ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +344 -246
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +10 -2
  7. package/dist/lib/browser/testing/index.mjs.map +4 -4
  8. package/dist/lib/node/{chunk-7VZVCCNF.cjs → chunk-YZA42CKA.cjs} +82 -62
  9. package/dist/lib/node/chunk-YZA42CKA.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +367 -270
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +20 -13
  14. package/dist/lib/node/testing/index.cjs.map +4 -4
  15. package/dist/types/src/automerge/automerge-doc-loader.d.ts +2 -0
  16. package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +1 -1
  17. package/dist/types/src/automerge/automerge-host.d.ts +21 -18
  18. package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
  19. package/dist/types/src/automerge/automerge-repo.test.d.ts +2 -0
  20. package/dist/types/src/automerge/automerge-repo.test.d.ts.map +1 -0
  21. package/dist/types/src/automerge/index.d.ts +2 -0
  22. package/dist/types/src/automerge/index.d.ts.map +1 -1
  23. package/dist/types/src/automerge/level.test.d.ts +2 -0
  24. package/dist/types/src/automerge/level.test.d.ts.map +1 -0
  25. package/dist/types/src/automerge/leveldb-storage-adapter.d.ts +30 -0
  26. package/dist/types/src/automerge/leveldb-storage-adapter.d.ts.map +1 -0
  27. package/dist/types/src/automerge/local-host-network-adapter.d.ts +8 -1
  28. package/dist/types/src/automerge/local-host-network-adapter.d.ts.map +1 -1
  29. package/dist/types/src/automerge/migrations.d.ts +7 -0
  30. package/dist/types/src/automerge/migrations.d.ts.map +1 -0
  31. package/dist/types/src/automerge/reference.d.ts +15 -0
  32. package/dist/types/src/automerge/reference.d.ts.map +1 -0
  33. package/dist/types/src/automerge/storage-adapter.test.d.ts +2 -0
  34. package/dist/types/src/automerge/storage-adapter.test.d.ts.map +1 -0
  35. package/dist/types/src/automerge/types.d.ts +8 -2
  36. package/dist/types/src/automerge/types.d.ts.map +1 -1
  37. package/dist/types/src/metadata/metadata-store.d.ts +2 -1
  38. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  39. package/dist/types/src/space/control-pipeline.d.ts +3 -1
  40. package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
  41. package/dist/types/src/space/space-manager.d.ts +3 -1
  42. package/dist/types/src/space/space-manager.d.ts.map +1 -1
  43. package/dist/types/src/space/space.d.ts +6 -9
  44. package/dist/types/src/space/space.d.ts.map +1 -1
  45. package/dist/types/src/testing/index.d.ts +1 -0
  46. package/dist/types/src/testing/index.d.ts.map +1 -1
  47. package/dist/types/src/testing/level.d.ts +3 -0
  48. package/dist/types/src/testing/level.d.ts.map +1 -0
  49. package/dist/types/src/testing/test-agent-builder.d.ts +2 -2
  50. package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
  51. package/package.json +33 -30
  52. package/src/automerge/automerge-doc-loader.ts +6 -0
  53. package/src/automerge/automerge-host.test.ts +22 -8
  54. package/src/automerge/automerge-host.ts +66 -118
  55. package/src/automerge/automerge-repo.test.ts +29 -0
  56. package/src/automerge/index.ts +2 -0
  57. package/src/automerge/level.test.ts +82 -0
  58. package/src/automerge/leveldb-storage-adapter.ts +117 -0
  59. package/src/automerge/local-host-network-adapter.ts +19 -13
  60. package/src/automerge/migrations.ts +41 -0
  61. package/src/automerge/reference.ts +31 -0
  62. package/src/automerge/storage-adapter.test.ts +90 -0
  63. package/src/automerge/types.ts +8 -5
  64. package/src/db-host/data-service.ts +1 -1
  65. package/src/metadata/metadata-store.ts +17 -8
  66. package/src/space/control-pipeline.ts +11 -1
  67. package/src/space/space-manager.ts +4 -0
  68. package/src/space/space.test.ts +7 -7
  69. package/src/space/space.ts +17 -22
  70. package/src/testing/index.ts +1 -0
  71. package/src/testing/level.ts +11 -0
  72. package/src/testing/test-agent-builder.ts +1 -0
  73. package/dist/lib/browser/chunk-RTEEJ723.mjs.map +0 -7
  74. package/dist/lib/node/chunk-7VZVCCNF.cjs.map +0 -7
@@ -18,168 +18,169 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var node_exports = {};
20
20
  __export(node_exports, {
21
- AuthExtension: () => import_chunk_7VZVCCNF.AuthExtension,
22
- AuthStatus: () => import_chunk_7VZVCCNF.AuthStatus,
21
+ AuthExtension: () => import_chunk_YZA42CKA.AuthExtension,
22
+ AuthStatus: () => import_chunk_YZA42CKA.AuthStatus,
23
23
  AutomergeDocumentLoaderImpl: () => AutomergeDocumentLoaderImpl,
24
24
  AutomergeHost: () => AutomergeHost,
25
25
  AutomergeStorageAdapter: () => AutomergeStorageAdapter,
26
- DataServiceImpl: () => import_chunk_7VZVCCNF.DataServiceImpl,
26
+ DataServiceImpl: () => import_chunk_YZA42CKA.DataServiceImpl,
27
+ LevelDBStorageAdapter: () => LevelDBStorageAdapter,
27
28
  LocalHostNetworkAdapter: () => LocalHostNetworkAdapter,
28
- MOCK_AUTH_PROVIDER: () => import_chunk_7VZVCCNF.MOCK_AUTH_PROVIDER,
29
- MOCK_AUTH_VERIFIER: () => import_chunk_7VZVCCNF.MOCK_AUTH_VERIFIER,
29
+ MOCK_AUTH_PROVIDER: () => import_chunk_YZA42CKA.MOCK_AUTH_PROVIDER,
30
+ MOCK_AUTH_VERIFIER: () => import_chunk_YZA42CKA.MOCK_AUTH_VERIFIER,
30
31
  MeshNetworkAdapter: () => MeshNetworkAdapter,
31
- MetadataStore: () => import_chunk_7VZVCCNF.MetadataStore,
32
- Pipeline: () => import_chunk_7VZVCCNF.Pipeline,
33
- SnapshotManager: () => import_chunk_7VZVCCNF.SnapshotManager,
34
- SnapshotStore: () => import_chunk_7VZVCCNF.SnapshotStore,
35
- Space: () => import_chunk_7VZVCCNF.Space,
36
- SpaceManager: () => import_chunk_7VZVCCNF.SpaceManager,
37
- SpaceProtocol: () => import_chunk_7VZVCCNF.SpaceProtocol,
38
- SpaceProtocolSession: () => import_chunk_7VZVCCNF.SpaceProtocolSession,
39
- TimeframeClock: () => import_chunk_7VZVCCNF.TimeframeClock,
40
- codec: () => import_chunk_7VZVCCNF.codec,
41
- createMappedFeedWriter: () => import_chunk_7VZVCCNF.createMappedFeedWriter,
32
+ MetadataStore: () => import_chunk_YZA42CKA.MetadataStore,
33
+ Pipeline: () => import_chunk_YZA42CKA.Pipeline,
34
+ REFERENCE_TYPE_TAG: () => REFERENCE_TYPE_TAG,
35
+ SnapshotManager: () => import_chunk_YZA42CKA.SnapshotManager,
36
+ SnapshotStore: () => import_chunk_YZA42CKA.SnapshotStore,
37
+ Space: () => import_chunk_YZA42CKA.Space,
38
+ SpaceManager: () => import_chunk_YZA42CKA.SpaceManager,
39
+ SpaceProtocol: () => import_chunk_YZA42CKA.SpaceProtocol,
40
+ SpaceProtocolSession: () => import_chunk_YZA42CKA.SpaceProtocolSession,
41
+ TimeframeClock: () => import_chunk_YZA42CKA.TimeframeClock,
42
+ codec: () => import_chunk_YZA42CKA.codec,
43
+ createMappedFeedWriter: () => import_chunk_YZA42CKA.createMappedFeedWriter,
44
+ decodeReference: () => decodeReference,
45
+ encodeReference: () => encodeReference,
46
+ encodingOptions: () => encodingOptions,
42
47
  getSpaceKeyFromDoc: () => getSpaceKeyFromDoc,
43
- mapFeedIndexesToTimeframe: () => import_chunk_7VZVCCNF.mapFeedIndexesToTimeframe,
44
- mapTimeframeToFeedIndexes: () => import_chunk_7VZVCCNF.mapTimeframeToFeedIndexes,
45
- startAfter: () => import_chunk_7VZVCCNF.startAfter,
46
- valueEncoding: () => import_chunk_7VZVCCNF.valueEncoding
48
+ hasInvitationExpired: () => import_chunk_YZA42CKA.hasInvitationExpired,
49
+ isEncodedReferenceObject: () => isEncodedReferenceObject,
50
+ mapFeedIndexesToTimeframe: () => import_chunk_YZA42CKA.mapFeedIndexesToTimeframe,
51
+ mapTimeframeToFeedIndexes: () => import_chunk_YZA42CKA.mapTimeframeToFeedIndexes,
52
+ startAfter: () => import_chunk_YZA42CKA.startAfter,
53
+ valueEncoding: () => import_chunk_YZA42CKA.valueEncoding
47
54
  });
48
55
  module.exports = __toCommonJS(node_exports);
49
- var import_chunk_7VZVCCNF = require("./chunk-7VZVCCNF.cjs");
56
+ var import_chunk_YZA42CKA = require("./chunk-YZA42CKA.cjs");
57
+ var import_async = require("@dxos/async");
50
58
  var import_automerge = require("@dxos/automerge/automerge");
51
59
  var import_automerge_repo = require("@dxos/automerge/automerge-repo");
52
- var import_automerge_repo_storage_indexeddb = require("@dxos/automerge/automerge-repo-storage-indexeddb");
53
60
  var import_context = require("@dxos/context");
54
61
  var import_keys = require("@dxos/keys");
55
62
  var import_log = require("@dxos/log");
56
- var import_protocols = require("@dxos/protocols");
57
- var import_random_access_storage = require("@dxos/random-access-storage");
58
63
  var import_tracing = require("@dxos/tracing");
59
64
  var import_util = require("@dxos/util");
60
- var import_util2 = require("@dxos/util");
61
- var import_async = require("@dxos/async");
65
+ var import_context2 = require("@dxos/context");
66
+ var import_async2 = require("@dxos/async");
62
67
  var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
63
68
  var import_codec_protobuf = require("@dxos/codec-protobuf");
64
69
  var import_invariant = require("@dxos/invariant");
65
- var import_log2 = require("@dxos/log");
66
- var import_async2 = require("@dxos/async");
70
+ var import_async3 = require("@dxos/async");
67
71
  var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
68
72
  var import_invariant2 = require("@dxos/invariant");
69
- var import_log3 = require("@dxos/log");
73
+ var import_log2 = require("@dxos/log");
70
74
  var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
71
- var import_async3 = require("@dxos/async");
72
- var import_context2 = require("@dxos/context");
75
+ var import_automerge_repo_storage_indexeddb = require("@dxos/automerge/automerge-repo-storage-indexeddb");
76
+ var import_log3 = require("@dxos/log");
77
+ var import_random_access_storage = require("@dxos/random-access-storage");
78
+ var import_util2 = require("@dxos/util");
79
+ var import_async4 = require("@dxos/async");
80
+ var import_context3 = require("@dxos/context");
73
81
  var import_debug = require("@dxos/debug");
74
82
  var import_invariant3 = require("@dxos/invariant");
75
83
  var import_log4 = require("@dxos/log");
76
- var AutomergeStorageAdapter = class {
77
- constructor(_directory) {
78
- this._directory = _directory;
79
- this._state = "opened";
84
+ var import_echo_schema = require("@dxos/echo-schema");
85
+ var LevelDBStorageAdapter = class extends import_context2.Resource {
86
+ constructor(_params) {
87
+ super();
88
+ this._params = _params;
80
89
  }
81
- async load(key) {
82
- if (this._state !== "opened") {
83
- return void 0;
84
- }
85
- const filename = this._getFilename(key);
86
- const file = this._directory.getOrCreateFile(filename);
87
- const { size } = await file.stat();
88
- if (!size || size === 0) {
89
- return void 0;
90
+ async load(keyArray) {
91
+ try {
92
+ if (this._lifecycleState !== import_context2.LifecycleState.OPEN) {
93
+ return void 0;
94
+ }
95
+ return await this._params.db.get(keyArray, {
96
+ ...encodingOptions
97
+ });
98
+ } catch (err) {
99
+ if (isLevelDbNotFoundError(err)) {
100
+ return void 0;
101
+ }
102
+ throw err;
90
103
  }
91
- const buffer = await file.read(0, size);
92
- return (0, import_util2.bufferToArray)(buffer);
93
104
  }
94
- async save(key, data) {
95
- if (this._state !== "opened") {
105
+ async save(keyArray, binary) {
106
+ if (this._lifecycleState !== import_context2.LifecycleState.OPEN) {
96
107
  return void 0;
97
108
  }
98
- const filename = this._getFilename(key);
99
- const file = this._directory.getOrCreateFile(filename);
100
- await file.write(0, (0, import_util2.arrayToBuffer)(data));
101
- await file.truncate?.(data.length);
102
- await file.flush?.();
109
+ const batch = this._params.db.batch();
110
+ await this._params.callbacks?.beforeSave?.({
111
+ path: keyArray,
112
+ batch
113
+ });
114
+ batch.put(keyArray, Buffer.from(binary), {
115
+ ...encodingOptions
116
+ });
117
+ await batch.write();
118
+ await this._params.callbacks?.afterSave?.(keyArray);
103
119
  }
104
- async remove(key) {
105
- if (this._state !== "opened") {
120
+ async remove(keyArray) {
121
+ if (this._lifecycleState !== import_context2.LifecycleState.OPEN) {
106
122
  return void 0;
107
123
  }
108
- const filename = this._getFilename(key);
109
- const file = this._directory.getOrCreateFile(filename);
110
- await file.destroy();
124
+ await this._params.db.del(keyArray, {
125
+ ...encodingOptions
126
+ });
111
127
  }
112
128
  async loadRange(keyPrefix) {
113
- if (this._state !== "opened") {
129
+ if (this._lifecycleState !== import_context2.LifecycleState.OPEN) {
114
130
  return [];
115
131
  }
116
- const filename = this._getFilename(keyPrefix);
117
- const entries = await this._directory.list();
118
- return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
119
- const file = this._directory.getOrCreateFile(entry);
120
- const { size } = await file.stat();
121
- const buffer = await file.read(0, size);
122
- return {
123
- key: this._getKeyFromFilename(entry),
124
- data: (0, import_util2.bufferToArray)(buffer)
125
- };
126
- }));
132
+ const result = [];
133
+ for await (const [key, value] of this._params.db.iterator({
134
+ gte: keyPrefix,
135
+ lte: [
136
+ ...keyPrefix,
137
+ "\uFFFF"
138
+ ],
139
+ ...encodingOptions
140
+ })) {
141
+ result.push({
142
+ key,
143
+ data: value
144
+ });
145
+ }
146
+ return result;
127
147
  }
128
148
  async removeRange(keyPrefix) {
129
- if (this._state !== "opened") {
149
+ if (this._lifecycleState !== import_context2.LifecycleState.OPEN) {
130
150
  return void 0;
131
151
  }
132
- const filename = this._getFilename(keyPrefix);
133
- const entries = await this._directory.list();
134
- await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
135
- const file = this._directory.getOrCreateFile(entry);
136
- await file.destroy();
137
- }));
138
- }
139
- async close() {
140
- this._state = "closed";
141
- }
142
- _getFilename(key) {
143
- return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
144
- }
145
- _getKeyFromFilename(filename) {
146
- return filename.split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"));
147
- }
148
- };
149
- var AutomergeStorageWrapper = class {
150
- constructor({ storage, callbacks }) {
151
- this._storage = storage;
152
- this._callbacks = callbacks;
153
- }
154
- async load(key) {
155
- return this._storage.load(key);
156
- }
157
- async save(key, value) {
158
- await this._callbacks.beforeSave?.(key);
159
- await this._storage.save(key, value);
160
- await this._callbacks.afterSave?.(key);
161
- }
162
- async remove(key) {
163
- return this._storage.remove(key);
164
- }
165
- async loadRange(keyPrefix) {
166
- return this._storage.loadRange(keyPrefix);
167
- }
168
- async removeRange(keyPrefix) {
169
- return this._storage.removeRange(keyPrefix);
170
- }
171
- async close() {
172
- if (this._storage instanceof AutomergeStorageAdapter) {
173
- return this._storage.close();
152
+ const batch = this._params.db.batch();
153
+ for await (const [key] of this._params.db.iterator({
154
+ gte: keyPrefix,
155
+ lte: [
156
+ ...keyPrefix,
157
+ "\uFFFF"
158
+ ],
159
+ ...encodingOptions
160
+ })) {
161
+ batch.del(key, {
162
+ ...encodingOptions
163
+ });
174
164
  }
165
+ await batch.write();
175
166
  }
176
167
  };
168
+ var keyEncoder = {
169
+ encode: (key) => Buffer.from(key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-")),
170
+ decode: (key) => Buffer.from(key).toString().split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"))
171
+ };
172
+ var encodingOptions = {
173
+ keyEncoding: keyEncoder,
174
+ valueEncoding: "buffer"
175
+ };
176
+ var isLevelDbNotFoundError = (err) => err.code === "LEVEL_NOT_FOUND";
177
177
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/local-host-network-adapter.ts";
178
178
  var LocalHostNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
179
179
  constructor() {
180
180
  super(...arguments);
181
181
  this._peers = /* @__PURE__ */ new Map();
182
- this._connected = new import_async.Trigger();
182
+ this._connected = new import_async2.Trigger();
183
+ this._isConnected = false;
183
184
  }
184
185
  /**
185
186
  * Emits `ready` event. That signals to `Repo` that it can start using the adapter.
@@ -189,15 +190,21 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo2.NetworkAdapte
189
190
  network: this
190
191
  });
191
192
  }
193
+ /**
194
+ * Called by `Repo` to connect to the network.
195
+ *
196
+ * @param peerId Our peer Id.
197
+ */
192
198
  connect(peerId) {
193
199
  this.peerId = peerId;
200
+ this._isConnected = true;
194
201
  this._connected.wake();
195
202
  }
196
203
  send(message) {
197
204
  const peer = this._peers.get(message.targetId);
198
205
  (0, import_invariant.invariant)(peer, "Peer not found.", {
199
206
  F: __dxlog_file,
200
- L: 45,
207
+ L: 51,
201
208
  S: this,
202
209
  A: [
203
210
  "peer",
@@ -212,12 +219,17 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo2.NetworkAdapte
212
219
  }
213
220
  disconnect() {
214
221
  }
222
+ async whenConnected() {
223
+ await this._connected.wait({
224
+ timeout: 1e4
225
+ });
226
+ }
215
227
  syncRepo({ id, syncMessage }) {
216
228
  const peerId = this._getPeerId(id);
217
229
  return new import_codec_protobuf.Stream(({ next, close }) => {
218
230
  (0, import_invariant.invariant)(!this._peers.has(peerId), "Peer already connected.", {
219
231
  F: __dxlog_file,
220
- L: 63,
232
+ L: 73,
221
233
  S: this,
222
234
  A: [
223
235
  "!this._peers.has(peerId)",
@@ -239,35 +251,47 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo2.NetworkAdapte
239
251
  });
240
252
  }
241
253
  });
242
- this._connected.wait({
243
- timeout: 1e3
244
- }).then(() => {
245
- this.emit("peer-candidate", {
246
- peerMetadata: {},
247
- peerId
248
- });
249
- }).catch((err) => import_log2.log.catch(err, void 0, {
254
+ (0, import_invariant.invariant)(this._isConnected, void 0, {
250
255
  F: __dxlog_file,
251
- L: 88,
256
+ L: 90,
252
257
  S: this,
253
- C: (f, a) => f(...a)
254
- }));
258
+ A: [
259
+ "this._isConnected",
260
+ ""
261
+ ]
262
+ });
263
+ this.emit("peer-candidate", {
264
+ peerMetadata: {},
265
+ peerId
266
+ });
255
267
  });
256
268
  }
257
269
  async sendSyncMessage({ id, syncMessage }) {
258
- await this._connected.wait({
259
- timeout: 1e3
270
+ (0, import_invariant.invariant)(this._isConnected, void 0, {
271
+ F: __dxlog_file,
272
+ L: 99,
273
+ S: this,
274
+ A: [
275
+ "this._isConnected",
276
+ ""
277
+ ]
260
278
  });
261
279
  const message = import_automerge_repo2.cbor.decode(syncMessage);
262
280
  this.emit("message", message);
263
281
  }
264
282
  async getHostInfo() {
265
- await this._connected.wait({
266
- timeout: 1e3
283
+ (0, import_invariant.invariant)(this._isConnected, void 0, {
284
+ F: __dxlog_file,
285
+ L: 105,
286
+ S: this,
287
+ A: [
288
+ "this._isConnected",
289
+ ""
290
+ ]
267
291
  });
268
292
  (0, import_invariant.invariant)(this.peerId, "Peer id not set.", {
269
293
  F: __dxlog_file,
270
- L: 100,
294
+ L: 106,
271
295
  S: this,
272
296
  A: [
273
297
  "this.peerId",
@@ -287,7 +311,7 @@ var MeshNetworkAdapter = class extends import_automerge_repo3.NetworkAdapter {
287
311
  constructor() {
288
312
  super(...arguments);
289
313
  this._extensions = /* @__PURE__ */ new Map();
290
- this._connected = new import_async2.Trigger();
314
+ this._connected = new import_async3.Trigger();
291
315
  }
292
316
  /**
293
317
  * Emits `ready` event. That signals to `Repo` that it can start using the adapter.
@@ -315,7 +339,7 @@ var MeshNetworkAdapter = class extends import_automerge_repo3.NetworkAdapter {
315
339
  });
316
340
  extension.sendSyncMessage({
317
341
  payload: import_automerge_repo3.cbor.encode(message)
318
- }).catch((err) => import_log3.log.catch(err, void 0, {
342
+ }).catch((err) => import_log2.log.catch(err, void 0, {
319
343
  F: __dxlog_file2,
320
344
  L: 39,
321
345
  S: this,
@@ -340,7 +364,7 @@ var MeshNetworkAdapter = class extends import_automerge_repo3.NetworkAdapter {
340
364
  }, {
341
365
  onStartReplication: async (info, remotePeerId) => {
342
366
  await this._connected.wait();
343
- (0, import_log3.log)("onStartReplication", {
367
+ (0, import_log2.log)("onStartReplication", {
344
368
  id: info.id,
345
369
  thisPeerId: this.peerId,
346
370
  remotePeerId: remotePeerId.toHex()
@@ -353,7 +377,7 @@ var MeshNetworkAdapter = class extends import_automerge_repo3.NetworkAdapter {
353
377
  if (!this._extensions.has(info.id)) {
354
378
  peerInfo = info;
355
379
  this._extensions.set(info.id, extension);
356
- (0, import_log3.log)("peer-candidate", {
380
+ (0, import_log2.log)("peer-candidate", {
357
381
  id: info.id,
358
382
  thisPeerId: this.peerId,
359
383
  remotePeerId: remotePeerId.toHex()
@@ -392,6 +416,108 @@ var MeshNetworkAdapter = class extends import_automerge_repo3.NetworkAdapter {
392
416
  return extension;
393
417
  }
394
418
  };
419
+ var AutomergeStorageAdapter = class {
420
+ constructor(_directory) {
421
+ this._directory = _directory;
422
+ this._state = "opened";
423
+ }
424
+ async load(key) {
425
+ if (this._state !== "opened") {
426
+ return void 0;
427
+ }
428
+ const filename = this._getFilename(key);
429
+ const file = this._directory.getOrCreateFile(filename);
430
+ const { size } = await file.stat();
431
+ if (!size || size === 0) {
432
+ return void 0;
433
+ }
434
+ const buffer = await file.read(0, size);
435
+ return (0, import_util2.bufferToArray)(buffer);
436
+ }
437
+ async save(key, data) {
438
+ if (this._state !== "opened") {
439
+ return void 0;
440
+ }
441
+ const filename = this._getFilename(key);
442
+ const file = this._directory.getOrCreateFile(filename);
443
+ await file.write(0, (0, import_util2.arrayToBuffer)(data));
444
+ await file.truncate?.(data.length);
445
+ await file.flush?.();
446
+ }
447
+ async remove(key) {
448
+ if (this._state !== "opened") {
449
+ return void 0;
450
+ }
451
+ const filename = this._getFilename(key);
452
+ const file = this._directory.getOrCreateFile(filename);
453
+ await file.destroy();
454
+ }
455
+ async loadRange(keyPrefix) {
456
+ if (this._state !== "opened") {
457
+ return [];
458
+ }
459
+ const filename = this._getFilename(keyPrefix);
460
+ const entries = await this._directory.list();
461
+ return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
462
+ const file = this._directory.getOrCreateFile(entry);
463
+ const { size } = await file.stat();
464
+ const buffer = await file.read(0, size);
465
+ return {
466
+ key: this._getKeyFromFilename(entry),
467
+ data: (0, import_util2.bufferToArray)(buffer)
468
+ };
469
+ }));
470
+ }
471
+ async removeRange(keyPrefix) {
472
+ if (this._state !== "opened") {
473
+ return void 0;
474
+ }
475
+ const filename = this._getFilename(keyPrefix);
476
+ const entries = await this._directory.list();
477
+ await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
478
+ const file = this._directory.getOrCreateFile(entry);
479
+ await file.destroy();
480
+ }));
481
+ }
482
+ async close() {
483
+ this._state = "closed";
484
+ }
485
+ _getFilename(key) {
486
+ return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
487
+ }
488
+ _getKeyFromFilename(filename) {
489
+ return filename.split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"));
490
+ }
491
+ };
492
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/migrations.ts";
493
+ var levelMigration = async ({ db, directory }) => {
494
+ const isNewLevel = !await db.iterator({
495
+ ...encodingOptions
496
+ }).next();
497
+ if (!isNewLevel) {
498
+ return;
499
+ }
500
+ const oldStorageAdapter = directory.type === import_random_access_storage.StorageType.IDB ? new import_automerge_repo_storage_indexeddb.IndexedDBStorageAdapter(directory.path, "data") : new AutomergeStorageAdapter(directory);
501
+ const chunks = await oldStorageAdapter.loadRange([]);
502
+ if (chunks.length === 0) {
503
+ return;
504
+ }
505
+ const batch = db.batch();
506
+ import_log3.log.info("found chunks on old storage adapter", {
507
+ chunks: chunks.length
508
+ }, {
509
+ F: __dxlog_file3,
510
+ L: 36,
511
+ S: void 0,
512
+ C: (f, a) => f(...a)
513
+ });
514
+ for (const { key, data } of await oldStorageAdapter.loadRange([])) {
515
+ data && batch.put(key, data, {
516
+ ...encodingOptions
517
+ });
518
+ }
519
+ await batch.write();
520
+ };
395
521
  function _ts_decorate(decorators, target, key, desc) {
396
522
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
397
523
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -402,26 +528,29 @@ function _ts_decorate(decorators, target, key, desc) {
402
528
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
403
529
  return c > 3 && r && Object.defineProperty(target, key, r), r;
404
530
  }
405
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
531
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
406
532
  var AutomergeHost = class {
407
- constructor({ directory, metadata }) {
533
+ constructor({ directory, db, storageCallbacks }) {
408
534
  this._ctx = new import_context.Context();
409
535
  this._authorizedDevices = new import_util.ComplexMap(import_keys.PublicKey.hash);
410
- this._updatingMetadata = /* @__PURE__ */ new Map();
411
536
  this._requestedDocs = /* @__PURE__ */ new Set();
412
- this._metadata = metadata;
413
- this._meshNetwork = new MeshNetworkAdapter();
414
- this._clientNetwork = new LocalHostNetworkAdapter();
415
- this._storage = new AutomergeStorageWrapper({
416
- storage: (
417
- // TODO(mykola): Delete specific handling of IDB storage.
418
- directory.type === import_random_access_storage.StorageType.IDB ? new import_automerge_repo_storage_indexeddb.IndexedDBStorageAdapter(directory.path, "data") : new AutomergeStorageAdapter(directory)
419
- ),
420
- callbacks: {
421
- beforeSave: (params) => this._beforeSave(params)
422
- }
537
+ this._directory = directory;
538
+ this._db = db;
539
+ this._storageCallbacks = storageCallbacks;
540
+ }
541
+ async open() {
542
+ this._directory && await levelMigration({
543
+ db: this._db,
544
+ directory: this._directory
423
545
  });
546
+ this._storage = new LevelDBStorageAdapter({
547
+ db: this._db,
548
+ callbacks: this._storageCallbacks
549
+ });
550
+ await this._storage.open?.();
424
551
  this._peerId = `host-${import_keys.PublicKey.random().toHex()}`;
552
+ this._meshNetwork = new MeshNetworkAdapter();
553
+ this._clientNetwork = new LocalHostNetworkAdapter();
425
554
  this._repo = new import_automerge_repo.Repo({
426
555
  peerId: this._peerId,
427
556
  network: [
@@ -446,8 +575,8 @@ var AutomergeHost = class {
446
575
  documentId,
447
576
  isRequested
448
577
  }, {
449
- F: __dxlog_file3,
450
- L: 96,
578
+ F: __dxlog_file4,
579
+ L: 100,
451
580
  S: this,
452
581
  C: (f, a) => f(...a)
453
582
  });
@@ -460,8 +589,8 @@ var AutomergeHost = class {
460
589
  peerId,
461
590
  documentId
462
591
  }, {
463
- F: __dxlog_file3,
464
- L: 103,
592
+ F: __dxlog_file4,
593
+ L: 107,
465
594
  S: this,
466
595
  C: (f, a) => f(...a)
467
596
  });
@@ -474,8 +603,8 @@ var AutomergeHost = class {
474
603
  peerId,
475
604
  documentId
476
605
  }, {
477
- F: __dxlog_file3,
478
- L: 112,
606
+ F: __dxlog_file4,
607
+ L: 116,
479
608
  S: this,
480
609
  C: (f, a) => f(...a)
481
610
  });
@@ -491,16 +620,16 @@ var AutomergeHost = class {
491
620
  spaceKey,
492
621
  isAuthorized
493
622
  }, {
494
- F: __dxlog_file3,
495
- L: 118,
623
+ F: __dxlog_file4,
624
+ L: 122,
496
625
  S: this,
497
626
  C: (f, a) => f(...a)
498
627
  });
499
628
  return isAuthorized;
500
629
  } catch (err) {
501
630
  import_log.log.catch(err, void 0, {
502
- F: __dxlog_file3,
503
- L: 128,
631
+ F: __dxlog_file4,
632
+ L: 132,
504
633
  S: this,
505
634
  C: (f, a) => f(...a)
506
635
  });
@@ -510,69 +639,22 @@ var AutomergeHost = class {
510
639
  });
511
640
  this._clientNetwork.ready();
512
641
  this._meshNetwork.ready();
513
- {
514
- const listener = ({ handle }) => this._onDocument(handle);
515
- this._repo.on("document", listener);
516
- this._ctx.onDispose(() => {
517
- this._repo.off("document", listener);
518
- });
519
- }
642
+ await this._clientNetwork.whenConnected();
643
+ }
644
+ async close() {
645
+ await this._storage.close?.();
646
+ await this._clientNetwork.close();
647
+ await this._ctx.dispose();
520
648
  }
521
649
  get repo() {
522
650
  return this._repo;
523
651
  }
524
- async _beforeSave(path) {
525
- const id = path[0];
526
- if (this._updatingMetadata.has(id)) {
527
- return this._updatingMetadata.get(id);
528
- }
529
- }
530
- _onDocument(handle) {
531
- const listener = (event) => this._onUpdate(event);
532
- handle.on("change", listener);
533
- this._ctx.onDispose(() => {
534
- handle.off("change", listener);
535
- });
536
- }
537
- _onUpdate(event) {
538
- if (this._metadata == null) {
539
- return;
540
- }
541
- const objectIds = getInlineChanges(event);
542
- if (objectIds.length === 0) {
543
- return;
544
- }
545
- const heads = (0, import_automerge.getHeads)(event.doc);
546
- const lastAvailableHash = heads.join("");
547
- if (!lastAvailableHash) {
548
- return;
549
- }
550
- const encodedIds = objectIds.map((objectId) => import_protocols.idCodec.encode({
551
- documentId: event.handle.documentId,
552
- objectId
553
- }));
554
- const idToLastHash = new Map(encodedIds.map((id) => [
555
- id,
556
- lastAvailableHash
557
- ]));
558
- const markingDirtyPromise = this._metadata.markDirty(idToLastHash).then(() => {
559
- this._updatingMetadata.delete(event.handle.documentId);
560
- }).catch((err) => {
561
- this._ctx.disposed && import_log.log.catch(err, void 0, {
562
- F: __dxlog_file3,
563
- L: 188,
564
- S: this,
565
- C: (f, a) => f(...a)
566
- });
567
- });
568
- this._updatingMetadata.set(event.handle.documentId, markingDirtyPromise);
569
- }
570
652
  _automergeDocs() {
571
653
  return (0, import_util.mapValues)(this._repo.handles, (handle) => ({
572
654
  state: handle.state,
573
655
  hasDoc: !!handle.docSync(),
574
656
  heads: handle.docSync() ? import_automerge.next.getHeads(handle.docSync()) : null,
575
- data: handle.docSync()?.doc && (0, import_util.mapValues)(handle.docSync()?.doc, (value, key) => {
657
+ data: handle.docSync() && (0, import_util.mapValues)(handle.docSync(), (value, key) => {
576
658
  try {
577
659
  switch (key) {
578
660
  case "access":
@@ -592,14 +674,25 @@ var AutomergeHost = class {
592
674
  _automergePeers() {
593
675
  return this._repo.peers;
594
676
  }
595
- async close() {
596
- await this._storage.close();
597
- await this._clientNetwork.close();
598
- await this._ctx.dispose();
599
- }
600
677
  //
601
678
  // Methods for client-services.
602
679
  //
680
+ async flush({ documentIds }) {
681
+ await Promise.all(documentIds?.map((id) => this._repo.find(id).whenReady()) ?? []);
682
+ try {
683
+ await (0, import_async.asyncTimeout)(this._repo.flush(documentIds), 500);
684
+ } catch (err) {
685
+ import_log.log.warn("flush error", {
686
+ documentIds,
687
+ err
688
+ }, {
689
+ F: __dxlog_file4,
690
+ L: 196,
691
+ S: this,
692
+ C: (f, a) => f(...a)
693
+ });
694
+ }
695
+ }
603
696
  syncRepo(request) {
604
697
  return this._clientNetwork.syncRepo(request);
605
698
  }
@@ -620,8 +713,8 @@ var AutomergeHost = class {
620
713
  spaceKey,
621
714
  deviceKey
622
715
  }, {
623
- F: __dxlog_file3,
624
- L: 255,
716
+ F: __dxlog_file4,
717
+ L: 221,
625
718
  S: this,
626
719
  C: (f, a) => f(...a)
627
720
  });
@@ -644,24 +737,6 @@ _ts_decorate([
644
737
  AutomergeHost = _ts_decorate([
645
738
  import_tracing.trace.resource()
646
739
  ], AutomergeHost);
647
- var getInlineChanges = (event) => {
648
- const inlineChangedObjectIds = /* @__PURE__ */ new Set();
649
- for (const { path } of event.patches) {
650
- if (path.length < 2) {
651
- continue;
652
- }
653
- switch (path[0]) {
654
- case "objects":
655
- if (path.length >= 2) {
656
- inlineChangedObjectIds.add(path[1]);
657
- }
658
- break;
659
- }
660
- }
661
- return [
662
- ...inlineChangedObjectIds
663
- ];
664
- };
665
740
  var getSpaceKeyFromDoc = (doc) => {
666
741
  const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
667
742
  if (rawSpaceKey == null) {
@@ -669,7 +744,7 @@ var getSpaceKeyFromDoc = (doc) => {
669
744
  }
670
745
  return String(rawSpaceKey);
671
746
  };
672
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
747
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
673
748
  var AutomergeDocumentLoaderImpl = class {
674
749
  constructor(_spaceKey, _repo) {
675
750
  this._spaceKey = _spaceKey;
@@ -677,7 +752,12 @@ var AutomergeDocumentLoaderImpl = class {
677
752
  this._spaceRootDocHandle = null;
678
753
  this._objectDocumentHandles = /* @__PURE__ */ new Map();
679
754
  this._objectsPendingDocumentLoad = /* @__PURE__ */ new Set();
680
- this.onObjectDocumentLoaded = new import_async3.Event();
755
+ this.onObjectDocumentLoaded = new import_async4.Event();
756
+ }
757
+ getAllHandles() {
758
+ return [
759
+ ...new Set(this._objectDocumentHandles.values())
760
+ ];
681
761
  }
682
762
  async loadSpaceRootDocHandle(ctx, spaceState) {
683
763
  if (this._spaceRootDocHandle != null) {
@@ -687,8 +767,8 @@ var AutomergeDocumentLoaderImpl = class {
687
767
  import_log4.log.error("Database opened with no rootUrl", {
688
768
  spaceKey: this._spaceKey
689
769
  }, {
690
- F: __dxlog_file4,
691
- L: 60,
770
+ F: __dxlog_file5,
771
+ L: 66,
692
772
  S: this,
693
773
  C: (f, a) => f(...a)
694
774
  });
@@ -697,8 +777,8 @@ var AutomergeDocumentLoaderImpl = class {
697
777
  const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
698
778
  const doc = existingDocHandle.docSync();
699
779
  (0, import_invariant3.invariant)(doc, void 0, {
700
- F: __dxlog_file4,
701
- L: 65,
780
+ F: __dxlog_file5,
781
+ L: 71,
702
782
  S: this,
703
783
  A: [
704
784
  "doc",
@@ -713,8 +793,8 @@ var AutomergeDocumentLoaderImpl = class {
713
793
  }
714
794
  loadObjectDocument(objectId) {
715
795
  (0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
716
- F: __dxlog_file4,
717
- L: 74,
796
+ F: __dxlog_file5,
797
+ L: 80,
718
798
  S: this,
719
799
  A: [
720
800
  "this._spaceRootDocHandle",
@@ -726,8 +806,8 @@ var AutomergeDocumentLoaderImpl = class {
726
806
  }
727
807
  const spaceRootDoc = this._spaceRootDocHandle.docSync();
728
808
  (0, import_invariant3.invariant)(spaceRootDoc, void 0, {
729
- F: __dxlog_file4,
730
- L: 79,
809
+ F: __dxlog_file5,
810
+ L: 85,
731
811
  S: this,
732
812
  A: [
733
813
  "spaceRootDoc",
@@ -740,8 +820,8 @@ var AutomergeDocumentLoaderImpl = class {
740
820
  import_log4.log.info("loading delayed until object links are initialized", {
741
821
  objectId
742
822
  }, {
743
- F: __dxlog_file4,
744
- L: 83,
823
+ F: __dxlog_file5,
824
+ L: 89,
745
825
  S: this,
746
826
  C: (f, a) => f(...a)
747
827
  });
@@ -761,8 +841,8 @@ var AutomergeDocumentLoaderImpl = class {
761
841
  }
762
842
  getSpaceRootDocHandle() {
763
843
  (0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
764
- F: __dxlog_file4,
765
- L: 101,
844
+ F: __dxlog_file5,
845
+ L: 107,
766
846
  S: this,
767
847
  A: [
768
848
  "this._spaceRootDocHandle",
@@ -773,8 +853,8 @@ var AutomergeDocumentLoaderImpl = class {
773
853
  }
774
854
  createDocumentForObject(objectId) {
775
855
  (0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
776
- F: __dxlog_file4,
777
- L: 106,
856
+ F: __dxlog_file5,
857
+ L: 112,
778
858
  S: this,
779
859
  A: [
780
860
  "this._spaceRootDocHandle",
@@ -816,8 +896,8 @@ var AutomergeDocumentLoaderImpl = class {
816
896
  ...logMeta,
817
897
  actualDocumentUrl: objectDocumentHandle.url
818
898
  }, {
819
- F: __dxlog_file4,
820
- L: 136,
899
+ F: __dxlog_file5,
900
+ L: 142,
821
901
  S: this,
822
902
  C: (f, a) => f(...a)
823
903
  });
@@ -825,8 +905,8 @@ var AutomergeDocumentLoaderImpl = class {
825
905
  }
826
906
  if (objectDocumentHandle?.url === automergeUrl) {
827
907
  import_log4.log.warn("object document was already loaded", logMeta, {
828
- F: __dxlog_file4,
829
- L: 143,
908
+ F: __dxlog_file5,
909
+ L: 149,
830
910
  S: this,
831
911
  C: (f, a) => f(...a)
832
912
  });
@@ -834,8 +914,8 @@ var AutomergeDocumentLoaderImpl = class {
834
914
  }
835
915
  const handle = this._repo.find(automergeUrl);
836
916
  import_log4.log.debug("document loading triggered", logMeta, {
837
- F: __dxlog_file4,
838
- L: 147,
917
+ F: __dxlog_file5,
918
+ L: 153,
839
919
  S: this,
840
920
  C: (f, a) => f(...a)
841
921
  });
@@ -848,7 +928,7 @@ var AutomergeDocumentLoaderImpl = class {
848
928
  while (true) {
849
929
  try {
850
930
  await (0, import_debug.warnAfterTimeout)(5e3, "Automerge root doc load timeout (AutomergeDb)", async () => {
851
- await (0, import_context2.cancelWithContext)(ctx, docHandle.whenReady());
931
+ await (0, import_context3.cancelWithContext)(ctx, docHandle.whenReady());
852
932
  });
853
933
  break;
854
934
  } catch (err) {
@@ -857,8 +937,8 @@ var AutomergeDocumentLoaderImpl = class {
857
937
  id: docHandle.documentId,
858
938
  state: docHandle.state
859
939
  }, {
860
- F: __dxlog_file4,
861
- L: 163,
940
+ F: __dxlog_file5,
941
+ L: 169,
862
942
  S: this,
863
943
  C: (f, a) => f(...a)
864
944
  });
@@ -899,8 +979,8 @@ var AutomergeDocumentLoaderImpl = class {
899
979
  };
900
980
  if (this.onObjectDocumentLoaded.listenerCount() === 0) {
901
981
  import_log4.log.info("document loaded after all listeners were removed", logMeta, {
902
- F: __dxlog_file4,
903
- L: 199,
982
+ F: __dxlog_file5,
983
+ L: 205,
904
984
  S: this,
905
985
  C: (f, a) => f(...a)
906
986
  });
@@ -909,8 +989,8 @@ var AutomergeDocumentLoaderImpl = class {
909
989
  const objectDocHandle = this._objectDocumentHandles.get(objectId);
910
990
  if (objectDocHandle?.url !== handle.url) {
911
991
  import_log4.log.warn("object was rebound while a document was loading, discarding handle", logMeta, {
912
- F: __dxlog_file4,
913
- L: 204,
992
+ F: __dxlog_file5,
993
+ L: 210,
914
994
  S: this,
915
995
  C: (f, a) => f(...a)
916
996
  });
@@ -928,8 +1008,8 @@ var AutomergeDocumentLoaderImpl = class {
928
1008
  retryLoading: shouldRetryLoading,
929
1009
  err
930
1010
  }, {
931
- F: __dxlog_file4,
932
- L: 210,
1011
+ F: __dxlog_file5,
1012
+ L: 216,
933
1013
  S: this,
934
1014
  C: (f, a) => f(...a)
935
1015
  });
@@ -939,6 +1019,16 @@ var AutomergeDocumentLoaderImpl = class {
939
1019
  }
940
1020
  }
941
1021
  };
1022
+ var REFERENCE_TYPE_TAG = "dxos.echo.model.document.Reference";
1023
+ var encodeReference = (reference) => ({
1024
+ "@type": REFERENCE_TYPE_TAG,
1025
+ // NOTE: Automerge do not support undefined values, so we need to use null instead.
1026
+ itemId: reference.itemId ?? null,
1027
+ protocol: reference.protocol ?? null,
1028
+ host: reference.host ?? null
1029
+ });
1030
+ var decodeReference = (value) => new import_echo_schema.Reference(value.itemId, value.protocol ?? void 0, value.host ?? void 0);
1031
+ var isEncodedReferenceObject = (value) => typeof value === "object" && value !== null && value["@type"] === REFERENCE_TYPE_TAG;
942
1032
  // Annotate the CommonJS export names for ESM import in node:
943
1033
  0 && (module.exports = {
944
1034
  AuthExtension,
@@ -947,12 +1037,14 @@ var AutomergeDocumentLoaderImpl = class {
947
1037
  AutomergeHost,
948
1038
  AutomergeStorageAdapter,
949
1039
  DataServiceImpl,
1040
+ LevelDBStorageAdapter,
950
1041
  LocalHostNetworkAdapter,
951
1042
  MOCK_AUTH_PROVIDER,
952
1043
  MOCK_AUTH_VERIFIER,
953
1044
  MeshNetworkAdapter,
954
1045
  MetadataStore,
955
1046
  Pipeline,
1047
+ REFERENCE_TYPE_TAG,
956
1048
  SnapshotManager,
957
1049
  SnapshotStore,
958
1050
  Space,
@@ -962,7 +1054,12 @@ var AutomergeDocumentLoaderImpl = class {
962
1054
  TimeframeClock,
963
1055
  codec,
964
1056
  createMappedFeedWriter,
1057
+ decodeReference,
1058
+ encodeReference,
1059
+ encodingOptions,
965
1060
  getSpaceKeyFromDoc,
1061
+ hasInvitationExpired,
1062
+ isEncodedReferenceObject,
966
1063
  mapFeedIndexesToTimeframe,
967
1064
  mapTimeframeToFeedIndexes,
968
1065
  startAfter,