@hiai-gg/docsmint 0.4.9 → 0.5.1

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 (142) hide show
  1. package/backend/src/lib/api-key-facade.ts +1 -0
  2. package/dist/backend/index.js +38379 -18500
  3. package/dist/backend-api-key-facade.js +23 -0
  4. package/dist/client.js +2 -7
  5. package/dist/frontend/{CategoryDialog-CxVyaBV5.js → CategoryDialog-DmlX0Z97.js} +109 -108
  6. package/dist/frontend/ConfirmDialog-DgMTQBq4.js +134 -0
  7. package/dist/frontend/{CreateSnapshotDialog-BDgFTeFn.js → CreateSnapshotDialog-CXW4sCuf.js} +29 -29
  8. package/dist/frontend/DatePicker-D6E-EEtZ.js +340 -0
  9. package/dist/frontend/{DeleteDialog-CvAr2WPu.js → DeleteDialog-8k6JYWCx.js} +3 -3
  10. package/dist/frontend/{FolderNode--l1g8bcL.js → FolderNode-D3rN3yLV.js} +8 -8
  11. package/dist/frontend/{FolderTreeSelector-CyB8y2Sm.js → FolderTreeSelector-BMB1MS9N.js} +3 -3
  12. package/dist/frontend/{Icon-CooFj4Ee.js → Icon-Db-o32_E.js} +1 -1
  13. package/dist/frontend/{SettingsDialog-BB7h7GWw.js → SettingsDialog-DEx1eEZm.js} +290 -290
  14. package/dist/frontend/ShareDialog-uEf8Ks02.js +166 -0
  15. package/dist/frontend/Sidebar-BthP-jOS.js +2043 -0
  16. package/dist/frontend/TagCreateDialog-Bb0-Vtzh.js +261 -0
  17. package/dist/frontend/api/attachments.js +1 -1
  18. package/dist/frontend/api/categories.d.ts +3 -3
  19. package/dist/frontend/api/categories.js +1 -1
  20. package/dist/frontend/api/documents.js +1 -1
  21. package/dist/frontend/api/share.js +1 -1
  22. package/dist/frontend/api/tags.js +1 -1
  23. package/dist/frontend/{api-keys-CpkrA8rD.js → api-keys-DIwAdYkg.js} +10 -10
  24. package/dist/frontend/app-shell.d.ts +5 -1
  25. package/dist/frontend/app-shell.js +83 -72
  26. package/dist/frontend/{attachments-BuILSs56.js → attachments-C2DBzU-r.js} +13 -13
  27. package/dist/frontend/{camera-iKXDOOWT.js → camera-CzCxBOpc.js} +2 -2
  28. package/dist/frontend/{categories-Drnns7N6.js → categories-X7gK8azc.js} +0 -2
  29. package/dist/frontend/{check-D-UuvBuh.js → check-BIi-Ghti.js} +2 -2
  30. package/dist/frontend/{chevron-down-CiPtYyFh.js → chevron-down-C2ft7XUV.js} +2 -2
  31. package/dist/frontend/{circle-check-tSPE1V6t.js → circle-check-BrqfiQH1.js} +2 -2
  32. package/dist/frontend/{clock-DJHbHZb8.js → clock-Dz86E4Kz.js} +2 -2
  33. package/dist/frontend/collaboration.d.ts +4 -2
  34. package/dist/frontend/collaboration.js +114 -89
  35. package/dist/frontend/components/category-dialog.js +1 -1
  36. package/dist/frontend/components/create-snapshot-dialog.js +1 -1
  37. package/dist/frontend/components/delete-dialog.js +1 -1
  38. package/dist/frontend/components/editor/document-editor.js +1203 -1190
  39. package/dist/frontend/components/editor/document-title.js +2 -2
  40. package/dist/frontend/components/editor/markdown-toggle.js +4 -4
  41. package/dist/frontend/components/folder-node.js +1 -1
  42. package/dist/frontend/components/folder-tree-selector.js +1 -1
  43. package/dist/frontend/components/save-as-dialog.js +145 -144
  44. package/dist/frontend/components/settings.js +1 -1
  45. package/dist/frontend/components/share-dialog.js +1 -1
  46. package/dist/frontend/components/sidebar.js +1 -1
  47. package/dist/frontend/components/tag-create-dialog.js +1 -1
  48. package/dist/frontend/components/version-history.js +34 -34
  49. package/dist/frontend/{confirm-dialog-C4jTRbiS.js → confirm-dialog-CzmoZw3a.js} +20 -20
  50. package/dist/frontend/{copy-GppwRMjX.js → copy-CvCh4ZVt.js} +2 -2
  51. package/dist/frontend/dashboard.js +1133 -1087
  52. package/dist/frontend/{dialog-Bevp9mmM.js → dialog-Ce79C9fd.js} +1 -1
  53. package/dist/frontend/{dist-C3857Spp.js → dist-DQa_OHOa.js} +2 -2
  54. package/dist/frontend/{documents-Bc7b_MSZ.js → documents-CwCs1rA7.js} +52 -12
  55. package/dist/frontend/{dropdown-menu-CRSby3e9.js → dropdown-menu-CJ_7V3N0.js} +45 -45
  56. package/dist/frontend/{floating-layer-anchor-BDs7vO-M.js → floating-layer-anchor-S5RSefGN.js} +1 -1
  57. package/dist/frontend/{folder-DeWhnD7O.js → folder-Cx60MRpi.js} +3 -3
  58. package/dist/frontend/i18n.js +3 -3
  59. package/dist/frontend/{messages-C5Q890i2.js → messages-DIovIZrK.js} +46 -44
  60. package/dist/frontend/{rotate-ccw-B4Q7brmV.js → rotate-ccw-ta4NosZ0.js} +2 -2
  61. package/dist/frontend/{route-context-BqQQ5c4i.js → route-context-DYQlUfzL.js} +14 -11
  62. package/dist/frontend/search.js +431 -415
  63. package/dist/frontend/{select-value-GXwx90Pr.js → select-value-JCAp2PmU.js} +466 -466
  64. package/dist/frontend/{share-Cu7SSJuJ.js → share-D7JtkC85.js} +2 -2
  65. package/dist/frontend/{tag-HxRazVN_.js → tag-DhVFHMcV.js} +3 -3
  66. package/dist/frontend/{tag-store.svelte-CG7RrlDT.js → tag-store.svelte-ogVCMCbv.js} +1 -1
  67. package/dist/frontend/{tags-CtCV0Djo.js → tags-BdCaMGfj.js} +18 -18
  68. package/dist/frontend/{x-CzBsnJ2x.js → x-cfdlccjs.js} +2 -2
  69. package/dist/frontend-ssr/api/attachments.js +1 -1
  70. package/dist/frontend-ssr/api/categories.js +1 -1
  71. package/dist/frontend-ssr/api/documents.js +1 -1
  72. package/dist/frontend-ssr/api/share.js +1 -1
  73. package/dist/frontend-ssr/api/tags.js +1 -1
  74. package/dist/frontend-ssr/app-shell.js +30 -26
  75. package/dist/frontend-ssr/assets/{CategoryDialog-BcGW8-Kf.js → CategoryDialog-DDu37Oub.js} +13 -11
  76. package/dist/frontend-ssr/assets/ConfirmDialog-BhAelejz.js +131 -0
  77. package/dist/frontend-ssr/assets/{CreateSnapshotDialog-1bROJ-Rn.js → CreateSnapshotDialog-DNAjd4eD.js} +2 -2
  78. package/dist/frontend-ssr/assets/{DatePicker-B1ML8OVz.js → DatePicker-Cp6Qmgdb.js} +17 -29
  79. package/dist/frontend-ssr/assets/{DeleteDialog-tBYaP0L3.js → DeleteDialog-DG9Lm38J.js} +2 -2
  80. package/dist/frontend-ssr/assets/{FolderNode-CpHrpOED.js → FolderNode-CrLWqHJH.js} +5 -5
  81. package/dist/frontend-ssr/assets/{FolderTreeSelector-DZNZ2oI6.js → FolderTreeSelector-Bxi8EqMm.js} +8 -12
  82. package/dist/frontend-ssr/assets/{Icon-B0Zqppjo.js → Icon-QwirKi9Y.js} +16 -28
  83. package/dist/frontend-ssr/assets/{SettingsDialog-C2SMWJL8.js → SettingsDialog-BymUxBgg.js} +20 -27
  84. package/dist/frontend-ssr/assets/{ShareDialog-vMvJLRfn.js → ShareDialog-B82t8oJi.js} +4 -2
  85. package/dist/frontend-ssr/assets/{Sidebar-DKqmwreh.js → Sidebar-CI8YKbrY.js} +55 -57
  86. package/dist/frontend-ssr/assets/{TagCreateDialog-B0DPEfmQ.js → TagCreateDialog-B7wDbVqG.js} +7 -5
  87. package/dist/frontend-ssr/assets/{api-keys-DFqX39MT.js → api-keys-DIbclwj5.js} +10 -10
  88. package/dist/frontend-ssr/assets/{attachments-CWBxE3Vz.js → attachments-CXgatN0B.js} +9 -9
  89. package/dist/frontend-ssr/assets/{camera-CdxscTw-.js → camera-D6s20LDi.js} +6 -10
  90. package/dist/frontend-ssr/assets/{categories-CTCtdv7V.js → categories-av9xjeg5.js} +0 -2
  91. package/dist/frontend-ssr/assets/{chevron-down-CSSNGNh_.js → chevron-down-CvqKATjM.js} +6 -10
  92. package/dist/frontend-ssr/assets/{chevron-right-B4p7Sk6X.js → chevron-right-DKD7WXjz.js} +6 -10
  93. package/dist/frontend-ssr/assets/{circle-check-CI1v4vYh.js → circle-check-CPS9dKEo.js} +6 -10
  94. package/dist/frontend-ssr/assets/{clock-IL-eX2di.js → clock-CzsE58TH.js} +6 -10
  95. package/dist/frontend-ssr/assets/{confirm-dialog-BCthVwUY.js → confirm-dialog-B3C0WeMn.js} +20 -32
  96. package/dist/frontend-ssr/assets/{copy-CjV57nGQ.js → copy-DkkCPkBL.js} +6 -10
  97. package/dist/frontend-ssr/assets/{documents-PObdTOiT.js → documents-CZ-wQohy.js} +58 -12
  98. package/dist/frontend-ssr/assets/{dropdown-menu-Bj5rbqbB.js → dropdown-menu-Dn_vQq9b.js} +7 -11
  99. package/dist/frontend-ssr/assets/{floating-layer-anchor-CYIE8Oj6.js → floating-layer-anchor-BIAu-252.js} +1 -1
  100. package/dist/frontend-ssr/assets/{folder-DChhG7qN.js → folder-DYIE-XPP.js} +6 -10
  101. package/dist/frontend-ssr/assets/{loader-circle-DZsrZ-er.js → loader-circle-CIEWGyfP.js} +6 -10
  102. package/dist/frontend-ssr/assets/{messages-CvqpZNJe.js → messages-D-auzk9H.js} +23 -1
  103. package/dist/frontend-ssr/assets/{rotate-ccw-BlgWwaiq.js → rotate-ccw-dJSqPyTd.js} +6 -10
  104. package/dist/frontend-ssr/assets/{route-context-uca_b2Px.js → route-context-BPRerEtZ.js} +11 -8
  105. package/dist/frontend-ssr/assets/{select-value-6Lk0ToYd.js → select-value-DBhbkNcc.js} +1 -1
  106. package/dist/frontend-ssr/assets/{share-BTBJelxA.js → share-qTqvd6Lu.js} +2 -2
  107. package/dist/frontend-ssr/assets/{tag-GZEuGWk1.js → tag-BmiVU_Ej.js} +11 -19
  108. package/dist/frontend-ssr/assets/{tag-store.svelte-DvgUduhd.js → tag-store.svelte-BM1lUI_P.js} +1 -1
  109. package/dist/frontend-ssr/assets/{tags-BId2wdYd.js → tags-BQsI_6OW.js} +12 -12
  110. package/dist/frontend-ssr/collaboration.js +37 -12
  111. package/dist/frontend-ssr/components/category-dialog.js +1 -1
  112. package/dist/frontend-ssr/components/create-snapshot-dialog.js +1 -1
  113. package/dist/frontend-ssr/components/delete-dialog.js +1 -1
  114. package/dist/frontend-ssr/components/editor/document-editor.js +143 -207
  115. package/dist/frontend-ssr/components/editor/document-title.js +1 -1
  116. package/dist/frontend-ssr/components/editor/markdown-toggle.js +2 -2
  117. package/dist/frontend-ssr/components/folder-node.js +1 -1
  118. package/dist/frontend-ssr/components/folder-tree-selector.js +1 -1
  119. package/dist/frontend-ssr/components/save-as-dialog.js +8 -6
  120. package/dist/frontend-ssr/components/settings.js +1 -1
  121. package/dist/frontend-ssr/components/share-dialog.js +1 -1
  122. package/dist/frontend-ssr/components/sidebar.js +1 -1
  123. package/dist/frontend-ssr/components/tag-create-dialog.js +1 -1
  124. package/dist/frontend-ssr/components/version-history.js +19 -27
  125. package/dist/frontend-ssr/dashboard.js +344 -185
  126. package/dist/frontend-ssr/i18n.js +1 -1
  127. package/dist/frontend-ssr/search.js +16 -20
  128. package/dist/index.d.ts +1 -1
  129. package/dist/index.js +1 -1
  130. package/dist/types.d.ts +1 -3
  131. package/dist/workspace.d.ts +0 -2
  132. package/dist/workspace.js +0 -2
  133. package/package.json +1 -1
  134. package/packages/cli/src/index.ts +1 -1
  135. package/packages/db/src/with-tenant.ts +2 -0
  136. package/packages/mcp-server/src/index.ts +1 -1
  137. package/dist/frontend/ConfirmDialog-NFGXRa3E.js +0 -214
  138. package/dist/frontend/DatePicker-BZRBluzF.js +0 -256
  139. package/dist/frontend/ShareDialog-BUOkYSlw.js +0 -165
  140. package/dist/frontend/Sidebar-fbtYC3qs.js +0 -2037
  141. package/dist/frontend/TagCreateDialog-B9YZBNHi.js +0 -260
  142. package/dist/frontend-ssr/assets/ConfirmDialog-DjMFKc0V.js +0 -420
@@ -1,7 +1,7 @@
1
1
  import { n as e } from "./client-GbtOH90i.js";
2
2
  //#region src/lib/api/attachments.ts
3
3
  var t = 25 * 1024 * 1024;
4
- function n(t, n) {
4
+ function n(t, n, r) {
5
5
  return e(`/api/documents/${t}/attachments/presign`, {
6
6
  method: "POST",
7
7
  body: {
@@ -9,9 +9,9 @@ function n(t, n) {
9
9
  contentType: n.type,
10
10
  size: n.size
11
11
  }
12
- });
12
+ }, r);
13
13
  }
14
- function r(t, n, r) {
14
+ function r(t, n, r, i) {
15
15
  return e(`/api/documents/${t}/attachments/confirm`, {
16
16
  method: "POST",
17
17
  body: {
@@ -20,25 +20,25 @@ function r(t, n, r) {
20
20
  contentType: r.type,
21
21
  size: r.size
22
22
  }
23
- });
23
+ }, i);
24
24
  }
25
- async function i(e, t) {
26
- let i = await n(e, t), a = new AbortController(), o = setTimeout(() => a.abort(), 5 * 6e4), s;
25
+ async function i(e, t, i) {
26
+ let a = await n(e, t, i), o = new AbortController(), s = setTimeout(() => o.abort(), 5 * 6e4), c;
27
27
  try {
28
- s = await fetch(i.url, {
28
+ c = await fetch(a.url, {
29
29
  method: "PUT",
30
30
  body: t,
31
31
  headers: { "Content-Type": t.type },
32
- signal: a.signal
32
+ signal: o.signal
33
33
  });
34
34
  } finally {
35
- clearTimeout(o);
35
+ clearTimeout(s);
36
36
  }
37
- if (!s.ok) throw Error(`Storage upload failed: ${s.status} ${s.statusText}`);
38
- return r(e, i.key, t);
37
+ if (!c.ok) throw Error(`Storage upload failed: ${c.status} ${c.statusText}`);
38
+ return r(e, a.key, t, i);
39
39
  }
40
- function a(t) {
41
- return e(`/api/documents/${t}/attachments`);
40
+ function a(t, n) {
41
+ return e(`/api/documents/${t}/attachments`, {}, n);
42
42
  }
43
43
  function o(e) {
44
44
  return e.type.startsWith("image/");
@@ -1,8 +1,8 @@
1
- import { t as e } from "./Icon-CooFj4Ee.js";
1
+ import { t as e } from "./Icon-Db-o32_E.js";
2
2
  import "svelte/internal/disclose-version";
3
3
  import * as t from "svelte/internal/client";
4
4
  import "svelte/internal/flags/legacy";
5
- //#region ../node_modules/.bun/lucide-svelte@1.0.1+ff5f301bb2db9a0d/node_modules/lucide-svelte/dist/icons/camera.svelte
5
+ //#region ../node_modules/.bun/lucide-svelte@0.577.0+ff5f301bb2db9a0d/node_modules/lucide-svelte/dist/icons/camera.svelte
6
6
  function n(n, r) {
7
7
  let i = t.legacy_rest_props(r, [
8
8
  "children",
@@ -6,7 +6,6 @@ var o = n({
6
6
  apiMode: a([
7
7
  "unavailable",
8
8
  "global",
9
- "general",
10
9
  "category"
11
10
  ]).optional(),
12
11
  apiPermissionRead: r().optional(),
@@ -18,7 +17,6 @@ var o = n({
18
17
  apiMode: a([
19
18
  "unavailable",
20
19
  "global",
21
- "general",
22
20
  "category"
23
21
  ]).optional(),
24
22
  apiPermissionRead: r().optional(),
@@ -1,8 +1,8 @@
1
- import { t as e } from "./Icon-CooFj4Ee.js";
1
+ import { t as e } from "./Icon-Db-o32_E.js";
2
2
  import "svelte/internal/disclose-version";
3
3
  import * as t from "svelte/internal/client";
4
4
  import "svelte/internal/flags/legacy";
5
- //#region ../node_modules/.bun/lucide-svelte@1.0.1+ff5f301bb2db9a0d/node_modules/lucide-svelte/dist/icons/check.svelte
5
+ //#region ../node_modules/.bun/lucide-svelte@0.577.0+ff5f301bb2db9a0d/node_modules/lucide-svelte/dist/icons/check.svelte
6
6
  function n(n, r) {
7
7
  let i = t.legacy_rest_props(r, [
8
8
  "children",
@@ -1,8 +1,8 @@
1
- import { t as e } from "./Icon-CooFj4Ee.js";
1
+ import { t as e } from "./Icon-Db-o32_E.js";
2
2
  import "svelte/internal/disclose-version";
3
3
  import * as t from "svelte/internal/client";
4
4
  import "svelte/internal/flags/legacy";
5
- //#region ../node_modules/.bun/lucide-svelte@1.0.1+ff5f301bb2db9a0d/node_modules/lucide-svelte/dist/icons/chevron-down.svelte
5
+ //#region ../node_modules/.bun/lucide-svelte@0.577.0+ff5f301bb2db9a0d/node_modules/lucide-svelte/dist/icons/chevron-down.svelte
6
6
  function n(n, r) {
7
7
  let i = t.legacy_rest_props(r, [
8
8
  "children",
@@ -1,8 +1,8 @@
1
- import { t as e } from "./Icon-CooFj4Ee.js";
1
+ import { t as e } from "./Icon-Db-o32_E.js";
2
2
  import "svelte/internal/disclose-version";
3
3
  import * as t from "svelte/internal/client";
4
4
  import "svelte/internal/flags/legacy";
5
- //#region ../node_modules/.bun/lucide-svelte@1.0.1+ff5f301bb2db9a0d/node_modules/lucide-svelte/dist/icons/circle-check.svelte
5
+ //#region ../node_modules/.bun/lucide-svelte@0.577.0+ff5f301bb2db9a0d/node_modules/lucide-svelte/dist/icons/circle-check.svelte
6
6
  function n(n, r) {
7
7
  let i = t.legacy_rest_props(r, [
8
8
  "children",
@@ -1,8 +1,8 @@
1
- import { t as e } from "./Icon-CooFj4Ee.js";
1
+ import { t as e } from "./Icon-Db-o32_E.js";
2
2
  import "svelte/internal/disclose-version";
3
3
  import * as t from "svelte/internal/client";
4
4
  import "svelte/internal/flags/legacy";
5
- //#region ../node_modules/.bun/lucide-svelte@1.0.1+ff5f301bb2db9a0d/node_modules/lucide-svelte/dist/icons/clock.svelte
5
+ //#region ../node_modules/.bun/lucide-svelte@0.577.0+ff5f301bb2db9a0d/node_modules/lucide-svelte/dist/icons/clock.svelte
6
6
  function n(n, r) {
7
7
  let i = t.legacy_rest_props(r, [
8
8
  "children",
@@ -1,6 +1,8 @@
1
1
  import type { WebsocketProvider } from "y-websocket";
2
2
  import type * as Y from "yjs";
3
3
  export interface CollaborationSession { provider: WebsocketProvider; doc: Y.Doc; destroy(): void; }
4
- export declare function startCollaboration(documentId: string, accessToken: string, onUpdate?: (update: Uint8Array) => void): CollaborationSession;
5
- export declare function stopCollaboration(): void;
4
+ export interface DocsmintRealtimeConnection { serverUrl: string; roomName: string; params?: Record<string, string>; }
5
+ export interface DocsmintRealtimeAdapter { resolveRealtimeConnection(input: { documentId: string; accessToken?: string }): DocsmintRealtimeConnection; }
6
+ export declare function startCollaboration(documentId: string, accessToken?: string, onUpdate?: (update: Uint8Array) => void, realtime?: DocsmintRealtimeAdapter): CollaborationSession;
7
+ export declare function stopCollaboration(session?: CollaborationSession): void;
6
8
  export declare function getActiveSession(): CollaborationSession | null;
@@ -1,127 +1,127 @@
1
- import { $ as e, E as t, G as n, I as r, J as i, K as a, Q as o, R as s, T as c, V as l, W as u, X as d, Z as f, at as p, c as m, dt as h, ft as g, g as _, i as v, it as y, lt as b, mt as ee, n as x, nt as S, ot as C, q as w, r as T, rt as E, t as D, ut as O, z as k } from "./awareness-snQ3RD9f.js";
1
+ import { $ as e, E as t, G as n, I as r, J as i, K as a, Q as o, R as s, T as c, V as l, W as u, X as d, Z as f, at as p, c as m, dt as h, ft as g, g as _, i as v, it as y, lt as b, mt as x, n as S, nt as C, ot as w, q as T, r as E, rt as D, t as O, ut as k, z as A } from "./awareness-snQ3RD9f.js";
2
2
  //#region ../node_modules/.bun/lib0@0.2.117/node_modules/lib0/broadcastchannel.js
3
- var A = /* @__PURE__ */ new Map(), j = class {
3
+ var j = /* @__PURE__ */ new Map(), M = class {
4
4
  constructor(e) {
5
5
  this.room = e, this.onmessage = null, this._onChange = (t) => t.key === e && this.onmessage !== null && this.onmessage({ data: s(t.newValue || "") }), a(this._onChange);
6
6
  }
7
7
  postMessage(e) {
8
- w.setItem(this.room, k(r(e)));
8
+ T.setItem(this.room, A(r(e)));
9
9
  }
10
10
  close() {
11
11
  n(this._onChange);
12
12
  }
13
- }, te = typeof BroadcastChannel > "u" ? j : BroadcastChannel, M = (e) => ee(A, e, () => {
14
- let t = g(), n = new te(e);
13
+ }, ee = typeof BroadcastChannel > "u" ? M : BroadcastChannel, N = (e) => x(j, e, () => {
14
+ let t = g(), n = new ee(e);
15
15
  return n.onmessage = (e) => t.forEach((t) => t(e.data, "broadcastchannel")), {
16
16
  bc: n,
17
17
  subs: t
18
18
  };
19
- }), N = (e, t) => (M(e).subs.add(t), t), P = (e, t) => {
20
- let n = M(e), r = n.subs.delete(t);
21
- return r && n.subs.size === 0 && (n.bc.close(), A.delete(e)), r;
22
- }, F = (e, t, n = null) => {
23
- let r = M(e);
19
+ }), P = (e, t) => (N(e).subs.add(t), t), F = (e, t) => {
20
+ let n = N(e), r = n.subs.delete(t);
21
+ return r && n.subs.size === 0 && (n.bc.close(), j.delete(e)), r;
22
+ }, I = (e, t, n = null) => {
23
+ let r = N(e);
24
24
  r.bc.postMessage(t), r.subs.forEach((e) => e(t, n));
25
- }, I = (e, n) => {
26
- p(e, 0), C(e, t(n));
27
- }, L = (e, t, n) => {
28
- p(e, 1), C(e, c(t, n));
29
- }, R = (t, n, r) => L(n, r, e(t)), z = (t, n, r, i) => {
25
+ }, L = (e, n) => {
26
+ p(e, 0), w(e, t(n));
27
+ }, R = (e, t, n) => {
28
+ p(e, 1), w(e, c(t, n));
29
+ }, z = (t, n, r) => R(n, r, e(t)), B = (t, n, r, i) => {
30
30
  try {
31
31
  _(n, e(t), r);
32
32
  } catch (e) {
33
33
  i?.(e), console.error("Caught error while handling a Yjs update", e);
34
34
  }
35
- }, B = (e, t) => {
36
- p(e, 2), C(e, t);
37
- }, V = z, H = (e, t, n, r, i) => {
35
+ }, V = (e, t) => {
36
+ p(e, 2), w(e, t);
37
+ }, H = B, U = (e, t, n, r, i) => {
38
38
  let a = o(e);
39
39
  switch (a) {
40
40
  case 0:
41
- R(e, t, n);
41
+ z(e, t, n);
42
42
  break;
43
43
  case 1:
44
- z(e, n, r, i);
44
+ B(e, n, r, i);
45
45
  break;
46
46
  case 2:
47
- V(e, n, r, i);
47
+ H(e, n, r, i);
48
48
  break;
49
49
  default: throw Error("Unknown message type");
50
50
  }
51
51
  return a;
52
- }, U = (e, t, n) => {
52
+ }, W = (e, t, n) => {
53
53
  switch (o(e)) {
54
54
  case 0: n(t, f(e));
55
55
  }
56
- }, W = (e) => u(e, (e, t) => `${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&"), G = [];
57
- G[0] = (e, t, n, r, i) => {
56
+ }, G = (e) => u(e, (e, t) => `${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&"), K = [];
57
+ K[0] = (e, t, n, r, i) => {
58
58
  p(e, 0);
59
- let a = H(t, e, n.doc, n);
59
+ let a = U(t, e, n.doc, n);
60
60
  r && a === 1 && !n.synced && (n.synced = !0);
61
- }, G[3] = (e, t, n, r, i) => {
62
- p(e, 1), C(e, T(n.awareness, Array.from(n.awareness.getStates().keys())));
63
- }, G[1] = (t, n, r, i, a) => {
64
- x(r.awareness, e(n), r);
65
- }, G[2] = (e, t, n, r, i) => {
66
- U(t, n.doc, (e, t) => q(n, t));
61
+ }, K[3] = (e, t, n, r, i) => {
62
+ p(e, 1), w(e, E(n.awareness, Array.from(n.awareness.getStates().keys())));
63
+ }, K[1] = (t, n, r, i, a) => {
64
+ S(r.awareness, e(n), r);
65
+ }, K[2] = (e, t, n, r, i) => {
66
+ W(t, n.doc, (e, t) => J(n, t));
67
67
  };
68
- var K = 3e4, q = (e, t) => console.warn(`Permission denied to access ${e.url}.\n${t}`), J = (e, t, n) => {
69
- let r = d(t), i = S(), a = o(r), s = e.messageHandlers[a];
68
+ var q = 3e4, J = (e, t) => console.warn(`Permission denied to access ${e.url}.\n${t}`), Y = (e, t, n) => {
69
+ let r = d(t), i = C(), a = o(r), s = e.messageHandlers[a];
70
70
  return s ? s(i, r, e, n, a) : console.error("Unable to compute message"), i;
71
- }, Y = (e, t, n) => {
72
- t === e.ws && (e.emit("connection-close", [n, e]), e.ws = null, t.close(), e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1, v(e.awareness, Array.from(e.awareness.getStates().keys()).filter((t) => t !== e.doc.clientID), e), e.emit("status", [{ status: "disconnected" }])) : e.wsUnsuccessfulReconnects++, setTimeout(X, b(O(2, e.wsUnsuccessfulReconnects) * 100, e.maxBackoffTime), e));
73
- }, X = (e) => {
71
+ }, X = (e, t, n) => {
72
+ t === e.ws && (e.emit("connection-close", [n, e]), e.ws = null, t.close(), e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1, v(e.awareness, Array.from(e.awareness.getStates().keys()).filter((t) => t !== e.doc.clientID), e), e.emit("status", [{ status: "disconnected" }])) : e.wsUnsuccessfulReconnects++, setTimeout(Z, b(k(2, e.wsUnsuccessfulReconnects) * 100, e.maxBackoffTime), e));
73
+ }, Z = (e) => {
74
74
  if (e.shouldConnect && e.ws === null) {
75
75
  let t = new e._WS(e.url, e.protocols);
76
76
  t.binaryType = "arraybuffer", e.ws = t, e.wsconnecting = !0, e.wsconnected = !1, e.synced = !1, t.onmessage = (n) => {
77
77
  e.wsLastMessageReceived = i();
78
- let r = J(e, new Uint8Array(n.data), !0);
79
- E(r) > 1 && t.send(y(r));
78
+ let r = Y(e, new Uint8Array(n.data), !0);
79
+ D(r) > 1 && t.send(y(r));
80
80
  }, t.onerror = (t) => {
81
81
  e.emit("connection-error", [t, e]);
82
82
  }, t.onclose = (n) => {
83
- Y(e, t, n);
83
+ X(e, t, n);
84
84
  }, t.onopen = () => {
85
85
  e.wsLastMessageReceived = i(), e.wsconnecting = !1, e.wsconnected = !0, e.wsUnsuccessfulReconnects = 0, e.emit("status", [{ status: "connected" }]);
86
- let n = S();
87
- if (p(n, 0), I(n, e.doc), t.send(y(n)), e.awareness.getLocalState() !== null) {
88
- let n = S();
89
- p(n, 1), C(n, T(e.awareness, [e.doc.clientID])), t.send(y(n));
86
+ let n = C();
87
+ if (p(n, 0), L(n, e.doc), t.send(y(n)), e.awareness.getLocalState() !== null) {
88
+ let n = C();
89
+ p(n, 1), w(n, E(e.awareness, [e.doc.clientID])), t.send(y(n));
90
90
  }
91
91
  }, e.emit("status", [{ status: "connecting" }]);
92
92
  }
93
- }, Z = (e, t) => {
93
+ }, Q = (e, t) => {
94
94
  let n = e.ws;
95
- e.wsconnected && n && n.readyState === n.OPEN && n.send(t), e.bcconnected && F(e.bcChannel, t, e);
96
- }, ne = class extends h {
97
- constructor(e, t, n, { connect: r = !0, awareness: a = new D(n), params: o = {}, protocols: s = [], WebSocketPolyfill: c = WebSocket, resyncInterval: u = -1, maxBackoffTime: d = 2500, disableBc: f = !1 } = {}) {
95
+ e.wsconnected && n && n.readyState === n.OPEN && n.send(t), e.bcconnected && I(e.bcChannel, t, e);
96
+ }, te = class extends h {
97
+ constructor(e, t, n, { connect: r = !0, awareness: a = new O(n), params: o = {}, protocols: s = [], WebSocketPolyfill: c = WebSocket, resyncInterval: u = -1, maxBackoffTime: d = 2500, disableBc: f = !1 } = {}) {
98
98
  for (super(); e[e.length - 1] === "/";) e = e.slice(0, e.length - 1);
99
- this.serverUrl = e, this.bcChannel = e + "/" + t, this.maxBackoffTime = d, this.params = o, this.protocols = s, this.roomname = t, this.doc = n, this._WS = c, this.awareness = a, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = f, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = G.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = r, this._resyncInterval = 0, u > 0 && (this._resyncInterval = setInterval(() => {
99
+ this.serverUrl = e, this.bcChannel = e + "/" + t, this.maxBackoffTime = d, this.params = o, this.protocols = s, this.roomname = t, this.doc = n, this._WS = c, this.awareness = a, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = f, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = K.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = r, this._resyncInterval = 0, u > 0 && (this._resyncInterval = setInterval(() => {
100
100
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
101
- let e = S();
102
- p(e, 0), I(e, n), this.ws.send(y(e));
101
+ let e = C();
102
+ p(e, 0), L(e, n), this.ws.send(y(e));
103
103
  }
104
104
  }, u)), this._bcSubscriber = (e, t) => {
105
105
  if (t !== this) {
106
- let t = J(this, new Uint8Array(e), !1);
107
- E(t) > 1 && F(this.bcChannel, y(t), this);
106
+ let t = Y(this, new Uint8Array(e), !1);
107
+ D(t) > 1 && I(this.bcChannel, y(t), this);
108
108
  }
109
109
  }, this._updateHandler = (e, t) => {
110
110
  if (t !== this) {
111
- let t = S();
112
- p(t, 0), B(t, e), Z(this, y(t));
111
+ let t = C();
112
+ p(t, 0), V(t, e), Q(this, y(t));
113
113
  }
114
114
  }, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: e, updated: t, removed: n }, r) => {
115
- let i = e.concat(t).concat(n), o = S();
116
- p(o, 1), C(o, T(a, i)), Z(this, y(o));
115
+ let i = e.concat(t).concat(n), o = C();
116
+ p(o, 1), w(o, E(a, i)), Q(this, y(o));
117
117
  }, this._exitHandler = () => {
118
118
  v(this.awareness, [n.clientID], "app closed");
119
119
  }, l && typeof process < "u" && process.on("exit", this._exitHandler), a.on("update", this._awarenessUpdateHandler), this._checkInterval = setInterval(() => {
120
- this.wsconnected && K < i() - this.wsLastMessageReceived && Y(this, this.ws, null);
121
- }, K / 10), r && this.connect();
120
+ this.wsconnected && q < i() - this.wsLastMessageReceived && X(this, this.ws, null);
121
+ }, q / 10), r && this.connect();
122
122
  }
123
123
  get url() {
124
- let e = W(this.params);
124
+ let e = G(this.params);
125
125
  return this.serverUrl + "/" + this.roomname + (e.length === 0 ? "" : "?" + e);
126
126
  }
127
127
  get synced() {
@@ -135,48 +135,73 @@ var K = 3e4, q = (e, t) => console.warn(`Permission denied to access ${e.url}.\n
135
135
  }
136
136
  connectBc() {
137
137
  if (this.disableBc) return;
138
- this.bcconnected ||= (N(this.bcChannel, this._bcSubscriber), !0);
139
- let e = S();
140
- p(e, 0), I(e, this.doc), F(this.bcChannel, y(e), this);
141
- let t = S();
142
- p(t, 0), L(t, this.doc), F(this.bcChannel, y(t), this);
143
- let n = S();
144
- p(n, 3), F(this.bcChannel, y(n), this);
145
- let r = S();
146
- p(r, 1), C(r, T(this.awareness, [this.doc.clientID])), F(this.bcChannel, y(r), this);
138
+ this.bcconnected ||= (P(this.bcChannel, this._bcSubscriber), !0);
139
+ let e = C();
140
+ p(e, 0), L(e, this.doc), I(this.bcChannel, y(e), this);
141
+ let t = C();
142
+ p(t, 0), R(t, this.doc), I(this.bcChannel, y(t), this);
143
+ let n = C();
144
+ p(n, 3), I(this.bcChannel, y(n), this);
145
+ let r = C();
146
+ p(r, 1), w(r, E(this.awareness, [this.doc.clientID])), I(this.bcChannel, y(r), this);
147
147
  }
148
148
  disconnectBc() {
149
- let e = S();
150
- p(e, 1), C(e, T(this.awareness, [this.doc.clientID], /* @__PURE__ */ new Map())), Z(this, y(e)), this.bcconnected &&= (P(this.bcChannel, this._bcSubscriber), !1);
149
+ let e = C();
150
+ p(e, 1), w(e, E(this.awareness, [this.doc.clientID], /* @__PURE__ */ new Map())), Q(this, y(e)), this.bcconnected &&= (F(this.bcChannel, this._bcSubscriber), !1);
151
151
  }
152
152
  disconnect() {
153
- this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && Y(this, this.ws, null);
153
+ this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && X(this, this.ws, null);
154
154
  }
155
155
  connect() {
156
- this.shouldConnect = !0, !this.wsconnected && this.ws === null && (X(this), this.connectBc());
156
+ this.shouldConnect = !0, !this.wsconnected && this.ws === null && (Z(this), this.connectBc());
157
157
  }
158
- }, Q = null;
159
- function re(e, t, n) {
160
- $();
161
- let r = new m(), i = new ne(`${window.location.protocol === "https:" ? "wss:" : "ws:"}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ""}/api/ws/collab/${e}?token=${encodeURIComponent(t)}`, e, r, {
158
+ };
159
+ //#endregion
160
+ //#region src/lib/realtime.ts
161
+ function ne(e, t, n, r) {
162
+ return {
163
+ serverUrl: `${n === "https:" ? "wss:" : "ws:"}//${r}/api/ws/collab`,
164
+ roomName: e,
165
+ params: t ? { token: t } : void 0
166
+ };
167
+ }
168
+ function re(e, t, n, r, i) {
169
+ return i?.resolveRealtimeConnection({
170
+ documentId: e,
171
+ accessToken: t
172
+ }) ?? ne(e, t, n, r);
173
+ }
174
+ //#endregion
175
+ //#region src/lib/collaboration.ts
176
+ var $ = /* @__PURE__ */ new Set();
177
+ function ie(e, t, n, r) {
178
+ let i = new m(), a = re(e, t, window.location.protocol, window.location.host, r), o = new te(a.serverUrl, a.roomName, i, {
162
179
  connect: !0,
163
- params: { token: t }
180
+ params: a.params
164
181
  });
165
- i.on("sync", (e) => {}), i.on("status", (e) => {}), i.on("connection-close", () => {});
166
- let a = n;
167
- return a && r.on("update", a), Q = {
168
- provider: i,
169
- doc: r,
182
+ o.on("sync", (e) => {}), o.on("status", (e) => {}), o.on("connection-close", () => {});
183
+ let s = n;
184
+ s && i.on("update", s);
185
+ let c = {
186
+ provider: o,
187
+ doc: i,
170
188
  destroy: () => {
171
- a && r.off("update", a), i.disconnect(), i.destroy(), r.destroy();
189
+ s && i.off("update", s), o.disconnect(), o.destroy(), i.destroy();
172
190
  }
173
- }, Q;
191
+ }, l = c.destroy;
192
+ return c.destroy = () => {
193
+ $.delete(c) && l();
194
+ }, $.add(c), c;
174
195
  }
175
- function $() {
176
- Q &&= (Q.destroy(), null);
196
+ function ae(e) {
197
+ if (e) {
198
+ e.destroy();
199
+ return;
200
+ }
201
+ for (let e of [...$]) e.destroy();
177
202
  }
178
- function ie() {
179
- return Q;
203
+ function oe() {
204
+ return [...$].at(-1) ?? null;
180
205
  }
181
206
  //#endregion
182
- export { ie as getActiveSession, re as startCollaboration, $ as stopCollaboration };
207
+ export { oe as getActiveSession, ie as startCollaboration, ae as stopCollaboration };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../CategoryDialog-CxVyaBV5.js";
1
+ import { t as e } from "../CategoryDialog-DmlX0Z97.js";
2
2
  export { e as CategoryDialog };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../CreateSnapshotDialog-BDgFTeFn.js";
1
+ import { t as e } from "../CreateSnapshotDialog-CXW4sCuf.js";
2
2
  export { e as CreateSnapshotDialog };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../DeleteDialog-CvAr2WPu.js";
1
+ import { t as e } from "../DeleteDialog-8k6JYWCx.js";
2
2
  export { e as DeleteDialog };