@mengine/medeo-client 1.3.1-alpha.4 → 1.3.1-alpha.5

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/dist/index.d.ts CHANGED
@@ -405,8 +405,7 @@ declare class ManualSyncDoc {
405
405
  * Fetches the snapshot up front rather than starting empty and converging: the
406
406
  * agent's first act is to read the document, so there is no useful state before
407
407
  * the snapshot lands. This also fails fast and loudly on a document that does
408
- * not exist, instead of `MengineDocSession.waitForContent()`'s behavior of
409
- * waiting forever for content that will never arrive.
408
+ * not exist or whose first snapshot is incomplete or invalid.
410
409
  */
411
410
  static open(options: ManualSyncDocOptions): Promise<ManualSyncDoc>;
412
411
  /** Current document read model (authoritative shape). */
package/dist/index.js CHANGED
@@ -2035,17 +2035,24 @@ var ManualSyncDoc = class ManualSyncDoc {
2035
2035
  * Fetches the snapshot up front rather than starting empty and converging: the
2036
2036
  * agent's first act is to read the document, so there is no useful state before
2037
2037
  * the snapshot lands. This also fails fast and loudly on a document that does
2038
- * not exist, instead of `MengineDocSession.waitForContent()`'s behavior of
2039
- * waiting forever for content that will never arrive.
2038
+ * not exist or whose first snapshot is incomplete or invalid.
2040
2039
  */
2041
2040
  static async open(options) {
2042
- const doc = new LoroDoc();
2043
- if (options.peerId != null) doc.setPeerId(options.peerId);
2044
2041
  const response = await options.client.fetchSnapshot();
2045
- doc.import(base64ToBytes(response.snapshot));
2046
- const manualSyncDoc = new ManualSyncDoc(options.client, doc);
2047
- manualSyncDoc.watermark = manualSyncDoc.serverVVFrom(response.version.server_vv) ?? doc.oplogVersion();
2048
- return manualSyncDoc;
2042
+ const doc = new LoroDoc();
2043
+ let manualSyncDoc;
2044
+ try {
2045
+ if (options.peerId != null) doc.setPeerId(options.peerId);
2046
+ if (doc.import(base64ToBytes(response.snapshot)).pending != null) throw new Error("Initial mengine snapshot has missing dependencies");
2047
+ manualSyncDoc = new ManualSyncDoc(options.client, doc);
2048
+ assertValidVideoDocument(manualSyncDoc.snapshot());
2049
+ manualSyncDoc.watermark = manualSyncDoc.serverVVFrom(response.version.server_vv) ?? doc.oplogVersion();
2050
+ return manualSyncDoc;
2051
+ } catch (error) {
2052
+ manualSyncDoc?.adapter.dispose();
2053
+ doc.free();
2054
+ throw error;
2055
+ }
2049
2056
  }
2050
2057
  /** Current document read model (authoritative shape). */
2051
2058
  snapshot() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mengine/medeo-client",
3
- "version": "1.3.1-alpha.4",
3
+ "version": "1.3.1-alpha.5",
4
4
  "license": "UNLICENSED",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,9 +25,9 @@
25
25
  "dependencies": {
26
26
  "loro-mirror": "^2.2.0",
27
27
  "zod": "^4.4.3",
28
- "@mengine/storage": "1.3.1-alpha.4",
29
- "@mengine/sync": "1.3.1-alpha.4",
30
- "@mengine/utils": "1.3.1-alpha.4"
28
+ "@mengine/storage": "1.3.1-alpha.5",
29
+ "@mengine/sync": "1.3.1-alpha.5",
30
+ "@mengine/utils": "1.3.1-alpha.5"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^25.9.1",