@hiai-gg/docsmint 2.1.1 → 2.1.3

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 CHANGED
@@ -84,6 +84,10 @@ is a separate listing.
84
84
  - **Choose how you run it.** Use [managed DocsMint](https://docsmint.com) or
85
85
  self-host the application, database, search, queues, and files.
86
86
 
87
+ ## Document version patch 2.1.3
88
+
89
+ Preview and restore historical content without reloading the editor. See [2.1.3 release notes](docs/release/v2.1.3-notes.md).
90
+
87
91
  ## Security patch 2.1.1
88
92
 
89
93
  Bun 1.4.4, SvelteKit/Vite and Better Auth patch refreshes preserve the existing MCP/REST contract. See [2.1.1 release notes](docs/release/v2.1.1-notes.md) and the [security report](docs/security/2026-11-02-security-refresh.md).
@@ -212793,11 +212793,37 @@ function materializeYDoc(doc) {
212793
212793
  // ../../backend/src/lib/collaboration-room-key.ts
212794
212794
  function createYjsRoomKey(input) {
212795
212795
  const scope = input.workspaceId ? `workspace:${input.workspaceId}` : `user:${input.userId}`;
212796
- return `${scope}:document:${input.documentId}`;
212796
+ const base = `${scope}:document:${input.documentId}`;
212797
+ return input.restoreVersionId ? `${base}:restore:${input.restoreVersionId}` : base;
212797
212798
  }
212798
212799
 
212799
212800
  // ../../backend/src/api/routes/collaboration.ts
212800
212801
  init_config();
212802
+
212803
+ // ../../backend/src/lib/document-body.ts
212804
+ init_schema2();
212805
+ init_drizzle_orm();
212806
+ import { isDeepStrictEqual } from "util";
212807
+ function sameDocumentBody(left, right) {
212808
+ return (left.content ?? "") === (right.content ?? "") && isDeepStrictEqual(left.contentJson ?? null, right.contentJson ?? null);
212809
+ }
212810
+ function resolveDocumentBody(current, patch) {
212811
+ const content = patch.content ?? current.content;
212812
+ const contentJson = patch.contentJson !== undefined ? patch.contentJson : (content ?? "") === (current.content ?? "") ? current.contentJson : null;
212813
+ return { content, contentJson };
212814
+ }
212815
+ function latestDocumentRestore(documentId) {
212816
+ return sql`(
212817
+ SELECT ${versions.id}
212818
+ FROM ${versions}
212819
+ WHERE ${versions.documentId} = ${documentId}
212820
+ AND ${versions.restoredFrom} IS NOT NULL
212821
+ ORDER BY ${versions.createdAt} DESC, ${versions.id} DESC
212822
+ LIMIT 1
212823
+ )`;
212824
+ }
212825
+
212826
+ // ../../backend/src/api/routes/collaboration.ts
212801
212827
  init_logger3();
212802
212828
 
212803
212829
  // ../../node_modules/.bun/y-protocols@1.0.7+48ebd0cf55a3d4ab/node_modules/y-protocols/sync.js
@@ -212969,11 +212995,13 @@ async function loadRoom(key, seed, persist) {
212969
212995
  doc,
212970
212996
  awareness,
212971
212997
  clients: 0,
212998
+ hasUpdates: false,
212972
212999
  listeners: new Set,
212973
213000
  persist,
212974
213001
  saveInterval: setInterval(() => void saveRoom(room), SAVE_INTERVAL_MS)
212975
213002
  };
212976
213003
  doc.on("update", (update, origin) => {
213004
+ room.hasUpdates = true;
212977
213005
  for (const listener of room.listeners)
212978
213006
  listener(update, origin);
212979
213007
  if (origin !== REMOTE_REDIS_ORIGIN) {
@@ -213025,7 +213053,7 @@ async function releaseYjsRoom(room) {
213025
213053
  clearTimeout(managed.persistTimer);
213026
213054
  await Promise.allSettled([
213027
213055
  saveRoom(managed),
213028
- managed.persist?.(managed.doc)
213056
+ managed.hasUpdates ? managed.persist?.(managed.doc) : undefined
213029
213057
  ]);
213030
213058
  await getSub().unsubscribe(`${CHANNEL_PREFIX}${managed.key}`);
213031
213059
  managed.awareness.destroy();
@@ -213139,7 +213167,8 @@ async function authorizeDocument2(ws, documentId) {
213139
213167
  title: documents.title,
213140
213168
  content: documents.content,
213141
213169
  contentJson: documents.contentJson,
213142
- categoryId: documents.categoryId
213170
+ categoryId: documents.categoryId,
213171
+ restoreVersionId: latestDocumentRestore(documentId)
213143
213172
  }).from(documents).where(and(eq(documents.id, documentId), tenantOwnerCondition(documents.ownerId, documents.workspaceId, access.ctx), isNull(documents.deletedAt), ...access.restricted ? [
213144
213173
  access.categoryId ? effectiveDocumentCategoryCondition(documents.categoryId, documents.folderId, access.ctx, access.categoryId) : sql`false`
213145
213174
  ] : [])).limit(1));
@@ -213161,27 +213190,50 @@ collaborationRoutes.ws("/api/ws/collab/:documentId", {
213161
213190
  const roomKey = createYjsRoomKey({
213162
213191
  documentId,
213163
213192
  userId: access.userId,
213164
- workspaceId: access.ctx.workspaceId
213193
+ workspaceId: access.ctx.workspaceId,
213194
+ restoreVersionId: document2.restoreVersionId
213165
213195
  });
213166
213196
  const persist = async (doc) => {
213167
213197
  const materialized = materializeYDoc(doc);
213168
- await withTenant(access.ctx, async (tx) => {
213198
+ const revision = await withTenant(access.ctx, async (tx) => {
213199
+ const [current] = await tx.select({
213200
+ title: documents.title,
213201
+ content: documents.content,
213202
+ contentJson: documents.contentJson
213203
+ }).from(documents).where(and(eq(documents.id, documentId), tenantOwnerCondition(documents.ownerId, documents.workspaceId, access.ctx), isNull(documents.deletedAt), ...access.restricted ? [
213204
+ access.categoryId ? effectiveDocumentCategoryCondition(documents.categoryId, documents.folderId, access.ctx, access.categoryId) : sql`false`
213205
+ ] : [])).for("update").limit(1);
213206
+ if (!current)
213207
+ return null;
213208
+ const [generation] = await tx.select({ id: latestDocumentRestore(documentId) }).from(documents).where(eq(documents.id, documentId)).limit(1);
213209
+ if (generation?.id !== document2.restoreVersionId)
213210
+ return false;
213211
+ if (sameDocumentBody(current, materialized))
213212
+ return null;
213213
+ const revision = contentHash(current.title, materialized.content);
213169
213214
  await tx.insert(versions).values({
213170
213215
  documentId,
213171
213216
  workspaceId: access.ctx.workspaceId,
213172
- content: materialized.content,
213173
- contentJson: materialized.contentJson,
213217
+ content: current.content ?? "",
213218
+ contentJson: current.contentJson,
213174
213219
  createdBy: access.userId
213175
213220
  });
213176
213221
  await tx.update(documents).set({
213177
213222
  content: materialized.content,
213178
213223
  contentJson: materialized.contentJson,
213179
- contentHash: contentHash(document2.title, materialized.content),
213224
+ contentHash: revision,
213180
213225
  updatedAt: new Date
213181
- }).where(and(eq(documents.id, documentId), tenantOwnerCondition(documents.ownerId, documents.workspaceId, access.ctx), isNull(documents.deletedAt), ...access.restricted ? [
213182
- access.categoryId ? effectiveDocumentCategoryCondition(documents.categoryId, documents.folderId, access.ctx, access.categoryId) : sql`false`
213183
- ] : []));
213226
+ }).where(eq(documents.id, documentId));
213227
+ return revision;
213184
213228
  });
213229
+ if (revision === false) {
213230
+ for (const peer of roomSockets.get(roomKey) ?? []) {
213231
+ peer.close(4009, "Document version changed. Keep your draft and reopen the document.");
213232
+ }
213233
+ return;
213234
+ }
213235
+ if (revision === null)
213236
+ return;
213185
213237
  await Promise.all([
213186
213238
  invalidateDocCache(documentId),
213187
213239
  invalidateDocListCache(access.userId, access.ctx.workspaceId)
@@ -213189,7 +213241,7 @@ collaborationRoutes.ws("/api/ws/collab/:documentId", {
213189
213241
  enqueueReembed([
213190
213242
  {
213191
213243
  id: documentId,
213192
- revision: contentHash(document2.title, materialized.content)
213244
+ revision
213193
213245
  }
213194
213246
  ], access.ctx.workspaceId, { reason: "content", refreshMode: "incremental" });
213195
213247
  };
@@ -213276,6 +213328,7 @@ collaborationRoutes.ws("/api/ws/collab/:documentId", {
213276
213328
  init_dist_es11();
213277
213329
  init_schema2();
213278
213330
  init_drizzle_orm();
213331
+ import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
213279
213332
  init_zod();
213280
213333
 
213281
213334
  // ../../backend/src/lib/audit.ts
@@ -213548,7 +213601,7 @@ async function maybePruneVersions(documentId) {
213548
213601
  if (count <= retention)
213549
213602
  return;
213550
213603
  const toDelete = count - retention;
213551
- const staleVersions = await tx.select({ id: versions.id }).from(versions).where(and(eq(versions.documentId, documentId), eq(versions.isSnapshot, false))).orderBy(asc(versions.createdAt), asc(versions.id)).limit(toDelete);
213604
+ const staleVersions = await tx.select({ id: versions.id }).from(versions).where(and(eq(versions.documentId, documentId), eq(versions.isSnapshot, false), sql`${versions.id} IS DISTINCT FROM ${latestDocumentRestore(documentId)}`)).orderBy(asc(versions.createdAt), asc(versions.id)).limit(toDelete);
213552
213605
  if (staleVersions.length > 0) {
213553
213606
  const ids = staleVersions.map((v) => v.id);
213554
213607
  await tx.delete(versions).where(inArray(versions.id, ids));
@@ -214742,6 +214795,8 @@ var documentRoutes = new Elysia({ prefix: "/api" }).get("/documents", async ({ q
214742
214795
  contentJson: documents.contentJson,
214743
214796
  folderId: documents.folderId,
214744
214797
  categoryId: documents.categoryId,
214798
+ metadata: documents.metadata,
214799
+ visibility: documents.visibility,
214745
214800
  contentHash: documents.contentHash,
214746
214801
  updatedAt: documents.updatedAt
214747
214802
  }).from(documents).where(and(eq(documents.id, params.id), tenantOwnerCondition(documents.ownerId, documents.workspaceId, ctx), isNull(documents.deletedAt), ...access.restricted ? [
@@ -214784,22 +214839,28 @@ var documentRoutes = new Elysia({ prefix: "/api" }).get("/documents", async ({ q
214784
214839
  return { forbidden: true };
214785
214840
  }
214786
214841
  }
214787
- await tx.insert(versions).values({
214788
- documentId: params.id,
214789
- content: existing?.content ?? "",
214790
- contentJson: existing?.contentJson,
214791
- createdBy: userId
214792
- });
214793
- const resolvedDocJson = body.data.contentJson;
214842
+ const nextBody = resolveDocumentBody(existing, body.data);
214843
+ const bodyChanged = !sameDocumentBody(existing, nextBody);
214844
+ const metadataChanged = body.data.title !== undefined && body.data.title !== existing.title || body.data.folderId !== undefined && body.data.folderId !== existing.folderId || body.data.categoryId !== undefined && body.data.categoryId !== existing.categoryId || body.data.visibility !== undefined && body.data.visibility !== existing.visibility || body.data.metadata !== undefined && !isDeepStrictEqual2(body.data.metadata, existing.metadata);
214845
+ if (!bodyChanged && !metadataChanged) {
214846
+ const [unchanged] = await tx.select().from(documents).where(eq(documents.id, params.id)).limit(1);
214847
+ return { unchanged };
214848
+ }
214849
+ if (bodyChanged) {
214850
+ await tx.insert(versions).values({
214851
+ documentId: params.id,
214852
+ content: existing.content ?? "",
214853
+ contentJson: existing.contentJson,
214854
+ createdBy: userId
214855
+ });
214856
+ }
214794
214857
  const currentContentRevision = body.data.title !== undefined || body.data.content !== undefined ? contentHash(body.data.title ?? existing.title, body.data.content ?? existing.content ?? "") : undefined;
214795
214858
  const [updated] = await tx.update(documents).set({
214796
214859
  ...body.data.title !== undefined && { title: body.data.title },
214797
214860
  ...body.data.content !== undefined && {
214798
214861
  content: body.data.content
214799
214862
  },
214800
- ...resolvedDocJson !== undefined && {
214801
- contentJson: resolvedDocJson
214802
- },
214863
+ ...bodyChanged && { contentJson: nextBody.contentJson },
214803
214864
  ...body.data.metadata !== undefined && {
214804
214865
  metadata: body.data.metadata
214805
214866
  },
@@ -214825,7 +214886,8 @@ var documentRoutes = new Elysia({ prefix: "/api" }).get("/documents", async ({ q
214825
214886
  existing,
214826
214887
  folderChanged,
214827
214888
  categoryChanged,
214828
- operationId: impact?.operationId
214889
+ operationId: impact?.operationId,
214890
+ bodyChanged
214829
214891
  };
214830
214892
  });
214831
214893
  if (!result) {
@@ -214845,8 +214907,19 @@ var documentRoutes = new Elysia({ prefix: "/api" }).get("/documents", async ({ q
214845
214907
  serverVersion: result.serverVersion
214846
214908
  };
214847
214909
  }
214848
- const { updated, existing, folderChanged, categoryChanged, operationId } = result;
214849
- maybePruneVersions(params.id).catch((err) => logger3.error({ err, docId: params.id }, "Background prune failed"));
214910
+ if ("unchanged" in result)
214911
+ return result.unchanged;
214912
+ const {
214913
+ updated,
214914
+ existing,
214915
+ folderChanged,
214916
+ categoryChanged,
214917
+ operationId,
214918
+ bodyChanged
214919
+ } = result;
214920
+ if (bodyChanged) {
214921
+ maybePruneVersions(params.id).catch((err) => logger3.error({ err, docId: params.id }, "Background prune failed"));
214922
+ }
214850
214923
  let shouldReembed = folderChanged || categoryChanged;
214851
214924
  if (!shouldReembed && (body.data.content !== undefined || body.data.title !== undefined)) {
214852
214925
  const titleToHash = body.data.title ?? existing?.title ?? "";
@@ -235637,7 +235710,7 @@ function registerDocsmintMcpCapabilities(server, client, workspaceRouting, decor
235637
235710
  registerPromptsAndResources(server, client);
235638
235711
  }
235639
235712
  function createDocsmintMcpServer(options = {}) {
235640
- const server = new DocsMintMcpServer({ name: "docsmint", version: "2.1.1" });
235713
+ const server = new DocsMintMcpServer({ name: "docsmint", version: "2.1.3" });
235641
235714
  const client = options.docsClient ? createMcpDocsClient(options.docsClient, options.requestContext) : options.client ?? createMcpDocsClient(createDefaultDocsClient(), options.requestContext);
235642
235715
  registerDocsmintMcpCapabilities(server, client, options.workspaceRouting, options.decorateResult);
235643
235716
  return server;
@@ -239357,16 +239430,13 @@ var versionRoutes = new Elysia({
239357
239430
  }
239358
239431
  const userId = ctx.userId;
239359
239432
  try {
239360
- const updated = await withTenant(ctx, async (tx) => {
239361
- const docRows = await tx.select({
239362
- id: documents.id,
239363
- content: documents.content,
239364
- contentJson: documents.contentJson
239365
- }).from(documents).where(and(eq(documents.id, params.id), tenantOwnerCondition(documents.ownerId, documents.workspaceId, ctx))).limit(1);
239366
- if (docRows.length === 0) {
239433
+ const result = await withTenant(ctx, async (tx) => {
239434
+ const access = authorization.access;
239435
+ const [doc] = await tx.select().from(documents).where(and(eq(documents.id, params.id), tenantOwnerCondition(documents.ownerId, documents.workspaceId, ctx), isNull(documents.deletedAt), ...access.restricted ? [
239436
+ access.categoryId ? effectiveDocumentCategoryCondition(documents.categoryId, documents.folderId, ctx, access.categoryId) : sql`false`
239437
+ ] : [])).for("update").limit(1);
239438
+ if (!doc)
239367
239439
  return null;
239368
- }
239369
- const doc = docRows[0];
239370
239440
  const versionRows = await tx.select({
239371
239441
  id: versions.id,
239372
239442
  content: versions.content,
@@ -239376,31 +239446,45 @@ var versionRoutes = new Elysia({
239376
239446
  if (!target) {
239377
239447
  return null;
239378
239448
  }
239379
- const docId = doc?.id;
239380
- await tx.insert(versions).values({
239381
- documentId: docId,
239382
- content: doc?.content ?? "",
239383
- contentJson: doc?.contentJson,
239384
- createdBy: userId
239385
- });
239449
+ if (sameDocumentBody(doc, target))
239450
+ return { updated: doc, changed: false };
239451
+ const docId = doc.id;
239452
+ const [backup] = await tx.select({ id: versions.id }).from(versions).where(and(eq(versions.documentId, docId), eq(versions.content, doc.content ?? ""), sql`${versions.contentJson} IS NOT DISTINCT FROM ${doc.contentJson == null ? null : JSON.stringify(doc.contentJson)}::jsonb`)).limit(1);
239453
+ if (!backup) {
239454
+ await tx.insert(versions).values({
239455
+ documentId: docId,
239456
+ content: doc.content ?? "",
239457
+ contentJson: doc.contentJson,
239458
+ createdBy: userId
239459
+ });
239460
+ }
239386
239461
  const [row] = await tx.update(documents).set({
239387
239462
  content: target.content,
239388
239463
  contentJson: target.contentJson,
239389
- updatedAt: new Date
239464
+ contentHash: contentHash(doc.title, target.content),
239465
+ updatedAt: new Date(Math.max(Date.now(), doc.updatedAt.getTime() + 1))
239390
239466
  }).where(and(eq(documents.id, docId), tenantOwnerCondition(documents.ownerId, documents.workspaceId, ctx))).returning();
239391
239467
  await tx.insert(versions).values({
239392
239468
  documentId: docId,
239393
239469
  content: target.content,
239394
239470
  contentJson: target.contentJson,
239395
239471
  createdBy: userId,
239396
- restoredFrom: target.id
239472
+ restoredFrom: target.id,
239473
+ createdAt: sql`clock_timestamp()`
239397
239474
  });
239398
- return row ?? null;
239475
+ return row ? { updated: row, changed: true } : null;
239399
239476
  });
239400
- if (!updated) {
239477
+ if (!result) {
239401
239478
  set.status = 404;
239402
239479
  return { error: "Document not found" };
239403
239480
  }
239481
+ const { updated, changed } = result;
239482
+ if (!changed)
239483
+ return updated;
239484
+ await Promise.all([
239485
+ invalidateDocCache(params.id),
239486
+ invalidateDocListCache(userId, ctx.workspaceId)
239487
+ ]);
239404
239488
  enqueueReembed([
239405
239489
  {
239406
239490
  id: params.id,
@@ -242218,7 +242302,7 @@ var swaggerConfig = {
242218
242302
  },
242219
242303
  info: {
242220
242304
  title: "DocsMint API",
242221
- version: "2.1.1",
242305
+ version: "2.1.3",
242222
242306
  description: "Self-hosted AI-native knowledge workspace and installable PWA with hybrid search, GraphRAG, REST, SDK, CLI, and MCP access for people and AI agents.",
242223
242307
  contact: { name: "HiAi-gg", url: "https://github.com/HiAi-gg/docsmint" },
242224
242308
  license: {
@@ -2672,6 +2672,13 @@ function osUsername() {
2672
2672
  }
2673
2673
  }
2674
2674
 
2675
+ // ../../backend/src/lib/collaboration-room-key.ts
2676
+ function createYjsRoomKey(input) {
2677
+ const scope = input.workspaceId ? `workspace:${input.workspaceId}` : `user:${input.userId}`;
2678
+ const base = `${scope}:document:${input.documentId}`;
2679
+ return input.restoreVersionId ? `${base}:restore:${input.restoreVersionId}` : base;
2680
+ }
2681
+
2675
2682
  // ../../backend/src/lib/account-runtime-cleanup-core.ts
2676
2683
  var YJS_DOCUMENT_PREFIX = "yjs:doc:";
2677
2684
  var DOCUMENT_LIST_CACHE_PREFIX = "hiai-docs:cache:docs:list:";
@@ -2797,7 +2804,16 @@ function createAccountRuntimeCleanupWithDependencies(dependencies) {
2797
2804
  }
2798
2805
  cacheSnapshot(actorUserId, snapshot);
2799
2806
  }
2800
- const deleted = await deleteExactKeys(dependencies.redis, snapshot.map((document) => `${YJS_DOCUMENT_PREFIX}${document.documentId}`), signal);
2807
+ let deleted = await deleteExactKeys(dependencies.redis, snapshot.map((document) => `${YJS_DOCUMENT_PREFIX}${document.documentId}`), signal);
2808
+ for (const document of snapshot) {
2809
+ const roomKey = YJS_DOCUMENT_PREFIX + createYjsRoomKey({
2810
+ documentId: document.documentId,
2811
+ userId: actorUserId,
2812
+ workspaceId: document.workspaceId ?? undefined
2813
+ });
2814
+ deleted += await deleteExactKeys(dependencies.redis, [roomKey], signal);
2815
+ deleted += await deleteNamespacePattern(dependencies.redis, `${escapeRedisGlob(roomKey)}:restore:*`, signal);
2816
+ }
2801
2817
  throwIfAborted(signal);
2802
2818
  return deleted;
2803
2819
  } finally {
@@ -2896,28 +2896,25 @@ function Mi(e, t) {
2896
2896
  let r = K.prop(t, "onUpdate", 3, (e) => {}), i = K.prop(t, "editable", 3, !0), a = K.prop(t, "collaboration", 3, null), o = K.prop(t, "documentId", 3, ""), s = K.prop(t, "documentUpdatedAt", 3, ""), c = K.prop(t, "toolbarExtensions", 3, null), l = K.prop(t, "editorActions", 19, () => []), u = K.prop(t, "minimalToolbar", 3, !1), d = null, f = K.state(null), p = K.state(!1), m = !1, h = K.state(!1), g = "", _ = 0;
2897
2897
  function v(e) {
2898
2898
  if (a()?.doc || t.contentJson || !Si(n())) return;
2899
- let i = n(), c = o(), l = s(), u = `${c}:${l}:${i.length}:${i.slice(0, 64)}`;
2900
- if (g === u) return;
2901
- g = u;
2902
- let d = ++_;
2899
+ let r = n(), i = o(), c = s(), l = `${i}:${c}:${r.length}:${r.slice(0, 64)}`;
2900
+ if (g === l) return;
2901
+ g = l;
2902
+ let u = ++_;
2903
2903
  K.set(h, !0);
2904
- let p = async () => {
2904
+ let d = async () => {
2905
2905
  try {
2906
- let t = c && l ? await Ti(c, l) : null;
2907
- if (d !== _ || K.get(f) !== e) return;
2908
- let n = t ?? Dt(kt(i));
2909
- e.commands.setContent(n, { emitUpdate: !1 }), r()({
2910
- markdown: i,
2911
- json: n
2912
- }), !t && c && l && Ei(c, l, n);
2906
+ let a = i && c ? await Ti(i, c) : null;
2907
+ if (u !== _ || K.get(f) !== e || n() !== r || t.contentJson) return;
2908
+ let o = a ?? Dt(kt(r));
2909
+ e.commands.setContent(o, { emitUpdate: !1 }), !a && i && c && Ei(i, c, o);
2913
2910
  } catch (e) {
2914
- d === _ && console.warn("HiAiEditor: deferred markdown parsing failed", e);
2911
+ u === _ && console.warn("HiAiEditor: deferred markdown parsing failed", e);
2915
2912
  } finally {
2916
- d === _ && K.set(h, !1);
2913
+ u === _ && K.set(h, !1);
2917
2914
  }
2918
2915
  };
2919
2916
  requestAnimationFrame(() => {
2920
- setTimeout(() => void p(), 0);
2917
+ setTimeout(() => void d(), 0);
2921
2918
  });
2922
2919
  }
2923
2920
  function y() {
@@ -3026,41 +3023,45 @@ function Mi(e, t) {
3026
3023
  n && /^(https?:|mailto:|tel:)/i.test(n) && (e.preventDefault(), window.open(n, "_blank", "noopener,noreferrer"));
3027
3024
  }
3028
3025
  var S = ji(), C = K.child(S), ee = (e) => {
3029
- var n = Oi(), r = K.first_child(n);
3030
- bi(r, {
3031
- get editor() {
3032
- return K.get(f);
3033
- },
3034
- get documentId() {
3035
- return o();
3036
- },
3037
- get toolbarExtensions() {
3038
- return c();
3039
- },
3040
- get editorActions() {
3041
- return l();
3042
- },
3043
- get editorActionContext() {
3044
- return t.editorActionContext;
3045
- },
3046
- get minimal() {
3047
- return u();
3048
- }
3026
+ var n = Oi(), r = K.first_child(n), a = (e) => {
3027
+ bi(e, {
3028
+ get editor() {
3029
+ return K.get(f);
3030
+ },
3031
+ get documentId() {
3032
+ return o();
3033
+ },
3034
+ get toolbarExtensions() {
3035
+ return c();
3036
+ },
3037
+ get editorActions() {
3038
+ return l();
3039
+ },
3040
+ get editorActionContext() {
3041
+ return t.editorActionContext;
3042
+ },
3043
+ get minimal() {
3044
+ return u();
3045
+ }
3046
+ });
3047
+ };
3048
+ K.if(r, (e) => {
3049
+ i() && e(a);
3049
3050
  });
3050
- var i = K.sibling(r, 2);
3051
- let a;
3052
- var s = K.child(i), d = (e) => {
3051
+ var s = K.sibling(r, 2);
3052
+ let d;
3053
+ var p = K.child(s), m = (e) => {
3053
3054
  var t = Di();
3054
3055
  K.append(e, t);
3055
3056
  };
3056
- K.if(s, (e) => {
3057
- K.get(h) && e(d);
3057
+ K.if(p, (e) => {
3058
+ K.get(h) && e(m);
3058
3059
  });
3059
- var p = K.sibling(s, 2);
3060
- _e(p, { get editor() {
3060
+ var g = K.sibling(p, 2);
3061
+ _e(g, { get editor() {
3061
3062
  return K.get(f);
3062
- } }), K.reset(i), K.template_effect(() => {
3063
- a = K.set_class(i, 1, "editor-content svelte-9hjz5q", null, a, { "deferred-loading": K.get(h) }), K.set_attribute(i, "aria-busy", K.get(h));
3063
+ } }), K.reset(s), K.template_effect(() => {
3064
+ d = K.set_class(s, 1, "editor-content svelte-9hjz5q", null, d, { "deferred-loading": K.get(h) }), K.set_attribute(s, "aria-busy", K.get(h));
3064
3065
  }), K.append(e, n);
3065
3066
  }, w = (e) => {
3066
3067
  var t = Ai(), n = K.child(t);
@@ -282,7 +282,9 @@ function ue(e, t, n, r) {
282
282
  connect: !0,
283
283
  params: a.params
284
284
  });
285
- o.on("sync", (e) => {}), o.on("status", (e) => {}), o.on("connection-close", () => {});
285
+ o.on("sync", (e) => {}), o.on("status", (e) => {}), o.on("connection-close", (e) => {
286
+ e?.code === 4009 && o.disconnect();
287
+ });
286
288
  let s = n;
287
289
  s && i.on("update", s);
288
290
  let c = {
@@ -1,4 +1,4 @@
1
- import { t as e } from "../../HiAiEditor-BQERr-cd.js";
1
+ import { t as e } from "../../HiAiEditor-BHz46Iqd.js";
2
2
  import "svelte/internal/disclose-version";
3
3
  import * as t from "svelte/internal/client";
4
4
  // src/lib/components/editor/CompactEditor.svelte
@@ -1 +1 @@
1
- export { t as DocsmintDocumentEditorHost } from "../../HiAiEditor-BQERr-cd.js";
1
+ export { t as DocsmintDocumentEditorHost } from "../../HiAiEditor-BHz46Iqd.js";