@kitionstage/sdk 0.0.0-stage → 0.5.2-stage.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 (258) hide show
  1. package/README.md +69 -2
  2. package/dist/LICENSE +177 -0
  3. package/dist/THIRD_PARTY_NOTICES +28 -0
  4. package/dist/lib/assets/kitEngine.worker-9haDiVHZ.js +13220 -0
  5. package/dist/lib/chunks/batch-BWpAyHvP.js +789 -0
  6. package/dist/lib/chunks/canonical-BIWfVCL-.js +87 -0
  7. package/dist/lib/chunks/envelope-D6MGY-ZN.js +61 -0
  8. package/dist/lib/chunks/replica-D8w3I4sn.js +2472 -0
  9. package/dist/lib/chunks/runtime-BVJHE1Pg.js +997 -0
  10. package/dist/lib/chunks/session-BqXC9a1-.js +281 -0
  11. package/dist/lib/chunks/toolIds-BCeSGHpV.js +821 -0
  12. package/dist/lib/chunks/workspaceTree-Destqupf.js +23 -0
  13. package/dist/lib/convergence/index.js +1035 -0
  14. package/dist/lib/convergence/node.js +8 -0
  15. package/dist/lib/embed-server/callbacks.js +37 -0
  16. package/dist/lib/embed-server/cli.js +19 -0
  17. package/dist/lib/embed-server/index.js +272 -0
  18. package/dist/lib/extensions/index.js +439 -0
  19. package/dist/lib/extensions/panel.html +208 -0
  20. package/dist/lib/extensions/runtime.js +198 -0
  21. package/dist/lib/extensions/sandbox.html +35 -0
  22. package/dist/lib/kdm/index.js +437 -0
  23. package/dist/lib/kit-dev-host/checkUiIds.mjs +44 -0
  24. package/dist/lib/kit-dev-host/index.js +308 -0
  25. package/dist/lib/kit-dev-host/lineRow.mjs +47 -0
  26. package/dist/lib/kit-dev-host/modeSmoke.mjs +178 -0
  27. package/dist/lib/kit-editor/index.js +6489 -0
  28. package/dist/lib/kit-editor/styles.css +807 -0
  29. package/dist/lib/kit-editor/workspaceTree.js +1 -0
  30. package/dist/lib/kit-engine/index.js +7 -0
  31. package/dist/lib/kit-host/index.js +530 -0
  32. package/dist/lib/kit-ui-protocol/index.js +336 -0
  33. package/dist/lib/node-only/embed-server-callbacks.js +2 -0
  34. package/dist/lib/node-only/embed-server.js +2 -0
  35. package/dist/lib/sync/index.js +1008 -0
  36. package/dist/lib/sync/openToken.js +201 -0
  37. package/dist/lib/sync/replicaVersions.js +51 -0
  38. package/dist/standalone/chunks/batch-CAGYk6m4.js +789 -0
  39. package/dist/standalone/chunks/client-B9xkOcvf.js +772 -0
  40. package/dist/standalone/chunks/collab-B5TbpTyO.js +1022 -0
  41. package/dist/standalone/chunks/comment-Ds9t8xSE.js +94 -0
  42. package/dist/standalone/chunks/comments-uVDS8Wxp.js +41 -0
  43. package/dist/standalone/chunks/document-CuIGSDsY.js +324 -0
  44. package/dist/standalone/chunks/envelope-GX4Cynkx.js +7612 -0
  45. package/dist/standalone/chunks/index-BEgEEnhU.js +287 -0
  46. package/dist/standalone/chunks/index-Blc_B6iX.js +1967 -0
  47. package/dist/standalone/chunks/kits-Cp51mDlw.js +9 -0
  48. package/dist/standalone/chunks/replica-Di2iCPiD.js +3281 -0
  49. package/dist/standalone/chunks/replicaVersions-C3rJxnk9.js +50 -0
  50. package/dist/standalone/chunks/touched-T9jKJjxn.js +78 -0
  51. package/dist/standalone/index.js +12 -0
  52. package/dist/standalone/script/index.js +339 -0
  53. package/dist/standalone/script/kits/board.js +5 -0
  54. package/dist/standalone/script/kits/cad.js +5 -0
  55. package/dist/standalone/script/kits/design.js +5 -0
  56. package/dist/standalone/script/kits/doc.js +5 -0
  57. package/dist/standalone/script/kits/film.js +5 -0
  58. package/dist/standalone/script/kits/html.js +5 -0
  59. package/dist/standalone/script/kits/index.js +38 -0
  60. package/dist/standalone/script/kits/layout.js +5 -0
  61. package/dist/standalone/script/kits/motion.js +5 -0
  62. package/dist/standalone/script/kits/note.js +5 -0
  63. package/dist/standalone/script/kits/pdf.js +5 -0
  64. package/dist/standalone/script/kits/photo.js +5 -0
  65. package/dist/standalone/script/kits/scene.js +5 -0
  66. package/dist/standalone/script/kits/sheet.js +5 -0
  67. package/dist/standalone/script/kits/slide.js +5 -0
  68. package/dist/standalone/script/kits/table.js +5 -0
  69. package/dist/standalone/script/kits/vector.js +5 -0
  70. package/dist/standalone/script/node.js +401 -0
  71. package/dist/standalone/script/proxy.js +254 -0
  72. package/dist/types/convergence/src/adapter.d.ts +131 -0
  73. package/dist/types/convergence/src/engine.d.ts +66 -0
  74. package/dist/types/convergence/src/index.d.ts +21 -0
  75. package/dist/types/convergence/src/net.d.ts +52 -0
  76. package/dist/types/convergence/src/node.d.ts +6 -0
  77. package/dist/types/convergence/src/report.d.ts +56 -0
  78. package/dist/types/convergence/src/rng.d.ts +12 -0
  79. package/dist/types/convergence/src/scenarios.d.ts +15 -0
  80. package/dist/types/convergence/src/state.d.ts +67 -0
  81. package/dist/types/embed/src/agent.d.ts +88 -0
  82. package/dist/types/embed/src/blobs.d.ts +2 -0
  83. package/dist/types/embed/src/collab.d.ts +250 -0
  84. package/dist/types/embed/src/comments.d.ts +30 -0
  85. package/dist/types/embed/src/errors.d.ts +24 -0
  86. package/dist/types/embed/src/handlers.d.ts +92 -0
  87. package/dist/types/embed/src/index.d.ts +20 -0
  88. package/dist/types/embed/src/mount.d.ts +39 -0
  89. package/dist/types/embed/src/replicaStore.d.ts +3 -0
  90. package/dist/types/embed/src/rooms.d.ts +40 -0
  91. package/dist/types/embed/src/schemas.d.ts +7 -0
  92. package/dist/types/embed/src/syncClients.d.ts +28 -0
  93. package/dist/types/embed/src/theme.d.ts +7 -0
  94. package/dist/types/embed/src/types.d.ts +596 -0
  95. package/dist/types/embed/src/ui.d.ts +33 -0
  96. package/dist/types/embed/src/version.d.ts +2 -0
  97. package/dist/types/embed-server/src/callbacks.d.ts +30 -0
  98. package/dist/types/embed-server/src/cli.d.ts +1 -0
  99. package/dist/types/embed-server/src/index.d.ts +19 -0
  100. package/dist/types/embed-server/src/page.d.ts +15 -0
  101. package/dist/types/embed-server/src/server.d.ts +39 -0
  102. package/dist/types/embed-server/src/session.d.ts +22 -0
  103. package/dist/types/extensions/src/gate.d.ts +17 -0
  104. package/dist/types/extensions/src/generated/runtime.d.ts +8 -0
  105. package/dist/types/extensions/src/host.d.ts +135 -0
  106. package/dist/types/extensions/src/index.d.ts +13 -0
  107. package/dist/types/extensions/src/manifest.d.ts +82 -0
  108. package/dist/types/extensions/src/protocol.d.ts +159 -0
  109. package/dist/types/extensions/src/rpc.d.ts +52 -0
  110. package/dist/types/extensions/src/runtime/document.d.ts +40 -0
  111. package/dist/types/extensions/src/runtime/index.d.ts +10 -0
  112. package/dist/types/extensions/src/runtime/panel.d.ts +19 -0
  113. package/dist/types/extensions/src/runtime/runtime.d.ts +54 -0
  114. package/dist/types/extensions/src/runtime/worker.d.ts +1 -0
  115. package/dist/types/extensions/src/sandbox.d.ts +41 -0
  116. package/dist/types/kdm/src/args.d.ts +12 -0
  117. package/dist/types/kdm/src/batch.d.ts +118 -0
  118. package/dist/types/kdm/src/canonical.d.ts +25 -0
  119. package/dist/types/kdm/src/comment.d.ts +114 -0
  120. package/dist/types/kdm/src/diff.d.ts +125 -0
  121. package/dist/types/kdm/src/envelope.d.ts +27 -0
  122. package/dist/types/kdm/src/errors.d.ts +28 -0
  123. package/dist/types/kdm/src/footprint.d.ts +21 -0
  124. package/dist/types/kdm/src/ids.d.ts +57 -0
  125. package/dist/types/kdm/src/index.d.ts +18 -0
  126. package/dist/types/kdm/src/marks.d.ts +32 -0
  127. package/dist/types/kdm/src/op.d.ts +124 -0
  128. package/dist/types/kdm/src/origin.d.ts +41 -0
  129. package/dist/types/kdm/src/overlay.d.ts +92 -0
  130. package/dist/types/kdm/src/projection.d.ts +29 -0
  131. package/dist/types/kdm/src/read.d.ts +90 -0
  132. package/dist/types/kdm/src/replica.d.ts +403 -0
  133. package/dist/types/kdm/src/schema.d.ts +185 -0
  134. package/dist/types/kdm/src/testing.d.ts +28 -0
  135. package/dist/types/kdm/src/toolIds.d.ts +61 -0
  136. package/dist/types/kdm/src/touched.d.ts +24 -0
  137. package/dist/types/kdm/src/tx.d.ts +215 -0
  138. package/dist/types/kdm/src/value.d.ts +23 -0
  139. package/dist/types/kit-dev-host/src/checkNoPaths.d.ts +19 -0
  140. package/dist/types/kit-dev-host/src/checkUiIds.d.mts +2 -0
  141. package/dist/types/kit-dev-host/src/index.d.ts +179 -0
  142. package/dist/types/kit-dev-host/src/lineRow.d.mts +14 -0
  143. package/dist/types/kit-dev-host/src/memoryFiles.d.ts +15 -0
  144. package/dist/types/kit-dev-host/src/modeSmoke.d.mts +8 -0
  145. package/dist/types/kit-editor/src/CommandDialog.d.ts +22 -0
  146. package/dist/types/kit-editor/src/CommentsPanel.d.ts +45 -0
  147. package/dist/types/kit-editor/src/CustomizeDialog.d.ts +32 -0
  148. package/dist/types/kit-editor/src/HostButtons.d.ts +11 -0
  149. package/dist/types/kit-editor/src/RenderFailure.d.ts +7 -0
  150. package/dist/types/kit-editor/src/TextSink.d.ts +6 -0
  151. package/dist/types/kit-editor/src/brand.d.ts +2 -0
  152. package/dist/types/kit-editor/src/catalogMenus.d.ts +27 -0
  153. package/dist/types/kit-editor/src/chart.d.ts +138 -0
  154. package/dist/types/kit-editor/src/conflicts.d.ts +12 -0
  155. package/dist/types/kit-editor/src/drawing.d.ts +83 -0
  156. package/dist/types/kit-editor/src/editor.d.ts +544 -0
  157. package/dist/types/kit-editor/src/engine/KitCanvas.d.ts +70 -0
  158. package/dist/types/kit-editor/src/engine/backdrop.d.ts +32 -0
  159. package/dist/types/kit-editor/src/engine/createKitFile.d.ts +12 -0
  160. package/dist/types/kit-editor/src/engine/decorations.d.ts +14 -0
  161. package/dist/types/kit-editor/src/engine/engineOverlays.d.ts +197 -0
  162. package/dist/types/kit-editor/src/engine/engineTools.d.ts +116 -0
  163. package/dist/types/kit-editor/src/engine/kitDraft.d.ts +70 -0
  164. package/dist/types/kit-editor/src/engine/kitEngine.d.ts +390 -0
  165. package/dist/types/kit-editor/src/engine/kitEngine.worker.d.ts +30 -0
  166. package/dist/types/kit-editor/src/engine/kitHost.d.ts +41 -0
  167. package/dist/types/kit-editor/src/engine/kitModel.d.ts +32 -0
  168. package/dist/types/kit-editor/src/engine/kitModelRunner.d.ts +99 -0
  169. package/dist/types/kit-editor/src/engine/kitModule.d.ts +185 -0
  170. package/dist/types/kit-editor/src/engine/kitShortcuts.d.ts +32 -0
  171. package/dist/types/kit-editor/src/engine/kitTools.d.ts +79 -0
  172. package/dist/types/kit-editor/src/engine/lazyFonts.d.ts +34 -0
  173. package/dist/types/kit-editor/src/engine/lentFiles.d.ts +29 -0
  174. package/dist/types/kit-editor/src/engine/rasterViewport.d.ts +178 -0
  175. package/dist/types/kit-editor/src/engine/readOnly.d.ts +78 -0
  176. package/dist/types/kit-editor/src/engine/refusal.d.ts +39 -0
  177. package/dist/types/kit-editor/src/engine/replica.d.ts +23 -0
  178. package/dist/types/kit-editor/src/engine/useKitDocument.d.ts +154 -0
  179. package/dist/types/kit-editor/src/engine/workerRelay.d.ts +62 -0
  180. package/dist/types/kit-editor/src/files.d.ts +74 -0
  181. package/dist/types/kit-editor/src/frame/EditorFrame.d.ts +74 -0
  182. package/dist/types/kit-editor/src/frame/FocusBar.d.ts +10 -0
  183. package/dist/types/kit-editor/src/frame/MenuNodes.d.ts +20 -0
  184. package/dist/types/kit-editor/src/frame/MenuRibbon.d.ts +8 -0
  185. package/dist/types/kit-editor/src/frame/ModeButton.d.ts +7 -0
  186. package/dist/types/kit-editor/src/frame/menus.d.ts +64 -0
  187. package/dist/types/kit-editor/src/frame/modes.d.ts +51 -0
  188. package/dist/types/kit-editor/src/frame/useFrameLayout.d.ts +34 -0
  189. package/dist/types/kit-editor/src/host.d.ts +127 -0
  190. package/dist/types/kit-editor/src/index.d.ts +85 -0
  191. package/dist/types/kit-editor/src/ink.d.ts +26 -0
  192. package/dist/types/kit-editor/src/lease.d.ts +53 -0
  193. package/dist/types/kit-editor/src/oneInFlight.d.ts +7 -0
  194. package/dist/types/kit-editor/src/phrases.d.ts +25 -0
  195. package/dist/types/kit-editor/src/presence.d.ts +79 -0
  196. package/dist/types/kit-editor/src/strings.d.ts +6 -0
  197. package/dist/types/kit-editor/src/toolIcons.d.ts +32 -0
  198. package/dist/types/kit-editor/src/uiCatalog.d.ts +59 -0
  199. package/dist/types/kit-editor/src/uiConfig.d.ts +53 -0
  200. package/dist/types/kit-editor/src/uiContext.d.ts +65 -0
  201. package/dist/types/kit-editor/src/uiStore.d.ts +20 -0
  202. package/dist/types/kit-editor/src/useCommentAnchors.d.ts +29 -0
  203. package/dist/types/kit-editor/src/useKitSession.d.ts +115 -0
  204. package/dist/types/kit-editor/src/workspaceTree.d.ts +5 -0
  205. package/dist/types/kit-engine/src/contract.d.ts +154 -0
  206. package/dist/types/kit-engine/src/index.d.ts +2 -0
  207. package/dist/types/kit-engine/src/session.d.ts +133 -0
  208. package/dist/types/kit-host/src/files.d.ts +163 -0
  209. package/dist/types/kit-host/src/index.d.ts +315 -0
  210. package/dist/types/kit-ui-protocol/src/index.d.ts +1145 -0
  211. package/dist/types/loro-crdt.d.ts +9 -0
  212. package/dist/types/script/kits/board.d.ts +534 -0
  213. package/dist/types/script/kits/cad.d.ts +2937 -0
  214. package/dist/types/script/kits/design.d.ts +3213 -0
  215. package/dist/types/script/kits/doc.d.ts +2575 -0
  216. package/dist/types/script/kits/film.d.ts +4067 -0
  217. package/dist/types/script/kits/html.d.ts +38 -0
  218. package/dist/types/script/kits/index.d.ts +20 -0
  219. package/dist/types/script/kits/layout.d.ts +3483 -0
  220. package/dist/types/script/kits/motion.d.ts +4826 -0
  221. package/dist/types/script/kits/note.d.ts +631 -0
  222. package/dist/types/script/kits/pdf.d.ts +829 -0
  223. package/dist/types/script/kits/photo.d.ts +7574 -0
  224. package/dist/types/script/kits/scene.d.ts +2962 -0
  225. package/dist/types/script/kits/sheet.d.ts +2419 -0
  226. package/dist/types/script/kits/slide.d.ts +1894 -0
  227. package/dist/types/script/kits/table.d.ts +654 -0
  228. package/dist/types/script/kits/vector.d.ts +5167 -0
  229. package/dist/types/script/src/agentRelay.d.ts +48 -0
  230. package/dist/types/script/src/capabilities.d.ts +21 -0
  231. package/dist/types/script/src/document.d.ts +87 -0
  232. package/dist/types/script/src/drafts.d.ts +141 -0
  233. package/dist/types/script/src/exchange.d.ts +30 -0
  234. package/dist/types/script/src/headless.d.ts +190 -0
  235. package/dist/types/script/src/index.d.ts +15 -0
  236. package/dist/types/script/src/kitModel.d.ts +17 -0
  237. package/dist/types/script/src/kits.d.ts +8 -0
  238. package/dist/types/script/src/node.d.ts +42 -0
  239. package/dist/types/script/src/port.d.ts +89 -0
  240. package/dist/types/script/src/proxy.d.ts +132 -0
  241. package/dist/types/script/src/room.d.ts +162 -0
  242. package/dist/types/script/src/sources.d.ts +73 -0
  243. package/dist/types/sync/src/backoff.d.ts +9 -0
  244. package/dist/types/sync/src/blobSection.d.ts +23 -0
  245. package/dist/types/sync/src/capabilities.d.ts +20 -0
  246. package/dist/types/sync/src/client.d.ts +253 -0
  247. package/dist/types/sync/src/framing.d.ts +35 -0
  248. package/dist/types/sync/src/hash.d.ts +2 -0
  249. package/dist/types/sync/src/index.d.ts +19 -0
  250. package/dist/types/sync/src/leases.d.ts +82 -0
  251. package/dist/types/sync/src/openToken.d.ts +104 -0
  252. package/dist/types/sync/src/protocol.d.ts +484 -0
  253. package/dist/types/sync/src/relay.d.ts +52 -0
  254. package/dist/types/sync/src/replicaVersions.d.ts +17 -0
  255. package/dist/types/sync/src/saveMachine.d.ts +83 -0
  256. package/dist/types/sync/src/saveRun.d.ts +52 -0
  257. package/dist/types/sync/src/transport.d.ts +19 -0
  258. package/package.json +229 -4
@@ -0,0 +1,336 @@
1
+ const F = "kition-kit-ui/1", d = (t) => typeof t == "object" && t !== null && t.kitionKitUi === 1;
2
+ function U(t) {
3
+ return d(t) && typeof t.protocol == "string";
4
+ }
5
+ function G(t) {
6
+ return d(t) && typeof t.ready == "string" && typeof t.id == "string";
7
+ }
8
+ function V(t) {
9
+ return d(t) && typeof t.hello == "string";
10
+ }
11
+ function E(t) {
12
+ if (!t || typeof t != "object" || Array.isArray(t)) return null;
13
+ const e = t, r = {};
14
+ for (const n of ["objectId", "path", "sheet", "cell", "blockId"])
15
+ typeof e[n] == "string" && e[n] && (r[n] = e[n]);
16
+ for (const n of ["page", "slide"])
17
+ Number.isInteger(e[n]) && e[n] >= 1 && (r[n] = e[n]);
18
+ return typeof e.time == "number" && Number.isFinite(e.time) && e.time >= 0 && (r.time = e.time), Array.isArray(e.heading) && e.heading.length && e.heading.every((n) => typeof n == "string") && (r.heading = [...e.heading]), Object.keys(r).length ? r : null;
19
+ }
20
+ const A = 256;
21
+ function R(t) {
22
+ if (t == null) return { download: !0, export: !0, share: !0 };
23
+ const e = typeof t == "object" && !Array.isArray(t) ? t : {};
24
+ return { download: e.download === !0, export: e.export === !0, share: e.share === !0 };
25
+ }
26
+ const _ = /[\u0000-\u001f\u007f-\u009f]/;
27
+ function $(t) {
28
+ const e = t && typeof t == "object" ? t.text : void 0;
29
+ if (typeof e != "string") return null;
30
+ const r = e.trim();
31
+ return !r || r.length > A || _.test(r) ? null : { text: r };
32
+ }
33
+ const D = /^[A-Za-z0-9._-]{1,64}$/, X = "host", z = "invalid-params", W = "held", I = 256, a = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
34
+ function S(t) {
35
+ if (!a(t)) return null;
36
+ const { object: e, field: r, offset: n } = t;
37
+ return typeof e == "string" && typeof r == "string" && typeof n == "number" && Number.isInteger(n) && n >= 0 ? { object: e, field: r, offset: n } : null;
38
+ }
39
+ function O(t) {
40
+ if (!a(t)) return null;
41
+ const e = Array.isArray(t.selection) ? t.selection.filter((s) => typeof s == "string").slice(0, I) : [], r = S(t.caret), n = a(t.viewport) ? t.viewport : null;
42
+ return { selection: e, ...r ? { caret: r } : {}, ...n ? { viewport: n } : {} };
43
+ }
44
+ function Y(t) {
45
+ return Array.isArray(t) ? t.flatMap((e) => {
46
+ const r = O(e);
47
+ return !r || !a(e) || typeof e.principal != "string" || typeof e.name != "string" ? [] : [{ principal: e.principal, name: e.name, color: typeof e.color == "string" ? e.color : "", ...r }];
48
+ }) : [];
49
+ }
50
+ function Z(t) {
51
+ if (!t || typeof t != "object") return null;
52
+ const { reads: e, newestAuthor: r } = t;
53
+ return !Number.isSafeInteger(e) || !Number.isSafeInteger(r) || r <= e || e < 0 ? null : { reads: e, newestAuthor: r };
54
+ }
55
+ const J = "fh_", b = ["file-not-granted", "not-allowed", "no-gesture", "already-committed", "conflict", "unsaved-edits", "quota", "unsupported", "io-error"];
56
+ function Q(t) {
57
+ if (!(t instanceof c) || t.code !== -32e3 || typeof t.data != "object" || t.data === null) return null;
58
+ const e = t.data.reason;
59
+ return b.includes(e) ? e : null;
60
+ }
61
+ const w = ["ai-field", "rewrite"], N = /^[a-z][a-z0-9-]{0,62}$/;
62
+ function v(t, e) {
63
+ if (typeof t != "string") return !1;
64
+ if (w.includes(t)) return !0;
65
+ if (!e) return !1;
66
+ const r = e.startsWith("kit.") ? e.slice(4) : e;
67
+ return t.startsWith(`${r}.`) && N.test(t.slice(r.length + 1));
68
+ }
69
+ const L = ["unavailable", "not-allowed", "quota", "refused", "too-large", "timeout", "failed"], ee = "action:", T = ["not-allowed", "no-gesture", "not-found", "failed"], te = "service:", j = ["file.pick", "image.insert", "people.mention", "people.notify", "share.open", "file.rename", "file.saveAs", "access.request", "editor.close", "comment.create"], ne = ["not-allowed", "no-gesture", "cancelled", "not-found", "failed"];
70
+ function re(t, e) {
71
+ const r = e.readOnly !== !0, n = r || e.comments?.canComment === !0, s = R(e.permissions);
72
+ switch (t) {
73
+ case "comment.create":
74
+ case "people.mention":
75
+ case "people.notify":
76
+ return n;
77
+ case "file.pick":
78
+ case "image.insert":
79
+ case "file.rename":
80
+ return r;
81
+ case "file.saveAs":
82
+ return s.download || s.export;
83
+ case "share.open":
84
+ return s.share;
85
+ case "access.request":
86
+ case "editor.close":
87
+ return !0;
88
+ }
89
+ }
90
+ const h = 2e3, k = 256, C = 256, P = 500, M = /[\u0000-\u001f\u007f-\u009f]/, x = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/, g = /[\u202a-\u202e\u2066-\u2069\u200e\u200f\u061c]/, f = (t) => !M.test(t) && !g.test(t), p = (t) => !x.test(t) && !g.test(t);
91
+ function y(t) {
92
+ if (!t || typeof t != "object" || Array.isArray(t)) return null;
93
+ const e = t, r = Array.isArray(e.ids) ? e.ids.filter((o) => typeof o == "string" && o.length > 0 && o.length <= 256 && f(o)) : [];
94
+ if (!r.length || r.length > C || r.length !== e.ids.length) return null;
95
+ const n = { ids: r }, s = e.range;
96
+ if (s !== void 0) {
97
+ const { start: o, end: i } = s ?? {};
98
+ if (!Number.isSafeInteger(o) || !Number.isSafeInteger(i) || o < 0 || i < o) return null;
99
+ n.range = { start: o, end: i };
100
+ }
101
+ for (const o of ["quote", "label"]) {
102
+ const i = e[o];
103
+ if (i !== void 0) {
104
+ if (typeof i != "string" || i.length > P || !(o === "label" ? f(i) : p(i))) return null;
105
+ n[o] = i;
106
+ }
107
+ }
108
+ if (e.page !== void 0) {
109
+ if (!Number.isSafeInteger(e.page) || e.page < 0) return null;
110
+ n.page = e.page;
111
+ }
112
+ return n;
113
+ }
114
+ function oe(t) {
115
+ const e = t;
116
+ if (!e || typeof e != "object" || !j.includes(e.service)) return null;
117
+ const r = e.service, n = e.params ?? {};
118
+ if (typeof n != "object" || Array.isArray(n)) return null;
119
+ const s = (o, i = 256, l = !1) => n[o] === void 0 || typeof n[o] == "string" && n[o].length <= i && (l ? p : f)(n[o]);
120
+ switch (r) {
121
+ case "file.pick":
122
+ return typeof n.purpose == "string" && Array.isArray(n.accept) && n.accept.every((o) => typeof o == "string") ? { service: r, params: n } : null;
123
+ case "image.insert":
124
+ return n.accept === void 0 || Array.isArray(n.accept) && n.accept.every((o) => typeof o == "string") ? { service: r, params: n } : null;
125
+ case "people.mention":
126
+ return typeof n.query == "string" && n.query.length <= 256 && f(n.query) && (n.limit === void 0 || Number.isSafeInteger(n.limit) && n.limit > 0 && n.limit <= 100) ? { service: r, params: n } : null;
127
+ case "people.notify": {
128
+ const o = n.people;
129
+ if (!(Array.isArray(o) && o.length > 0 && o.length <= k && o.every((u) => typeof u == "string" && u.length > 0 && u.length <= 256 && f(u)) && typeof n.message == "string" && n.message.length <= h && p(n.message))) return null;
130
+ if (n.anchor === void 0) return { service: r, params: n };
131
+ const l = y(n.anchor);
132
+ return l ? { service: r, params: { ...n, anchor: l } } : null;
133
+ }
134
+ case "share.open":
135
+ case "editor.close":
136
+ return { service: r, params: {} };
137
+ case "file.rename":
138
+ return s("name") ? { service: r, params: n } : null;
139
+ case "file.saveAs":
140
+ return n.bytes instanceof ArrayBuffer && s("name") && s("format", 32) ? { service: r, params: n } : null;
141
+ case "access.request":
142
+ return n.perm === "edit" || n.perm === "comment" ? { service: r, params: n } : null;
143
+ case "comment.create": {
144
+ const o = y(n.anchor);
145
+ return o && s("text", h, !0) ? { service: r, params: { ...n, anchor: o } } : null;
146
+ }
147
+ }
148
+ }
149
+ const H = ["not-found", "no-gesture", "no-kit", "not-allowed"], q = ["https:", "http:", "mailto:"];
150
+ function se(t) {
151
+ if (typeof t != "string" || !t) return !1;
152
+ try {
153
+ return q.includes(new URL(t).protocol);
154
+ } catch {
155
+ return !1;
156
+ }
157
+ }
158
+ function K(t) {
159
+ if (!a(t)) return null;
160
+ const e = {};
161
+ for (const r of ["path", "name", "docId"])
162
+ typeof t[r] == "string" && t[r] && (e[r] = t[r]);
163
+ return Object.keys(e).length ? e : null;
164
+ }
165
+ function ie(t) {
166
+ if (!a(t)) return null;
167
+ const e = K(t.link);
168
+ if (!e) return null;
169
+ const r = E(t.view), n = a(t.create) ? typeof t.create.kit == "string" && t.create.kit ? { kit: t.create.kit } : {} : null;
170
+ return { link: e, ...r ? { view: r } : {}, placement: t.placement === "beside" ? "beside" : "tab", ...n ? { create: n } : {} };
171
+ }
172
+ function ce(t) {
173
+ if (!a(t) || typeof t.purpose != "string" || !Array.isArray(t.accept)) return null;
174
+ const e = [];
175
+ for (const r of t.accept) {
176
+ if (typeof r != "string" || !/^[A-Za-z0-9][A-Za-z0-9_-]{0,15}$/.test(r)) return null;
177
+ e.includes(r.toLowerCase()) || e.push(r.toLowerCase());
178
+ }
179
+ return !e.length || e.length > 64 ? null : { purpose: t.purpose.slice(0, 200), accept: e, multiple: t.multiple === !0 };
180
+ }
181
+ function ae(t, e) {
182
+ const r = (i) => i.replace(/\\/g, "/").split("/").filter((l) => l && l !== "."), n = r(t).slice(0, -1), s = r(e);
183
+ let o = 0;
184
+ for (; o < n.length && o < s.length - 1 && n[o] === s[o]; ) o += 1;
185
+ return [...n.slice(o).map(() => ".."), ...s.slice(o)].join("/");
186
+ }
187
+ function le(t) {
188
+ if (!(t instanceof c) || t.code !== -32e3 || typeof t.data != "object" || t.data === null) return null;
189
+ const e = t.data.reason;
190
+ return H.includes(e) ? e : null;
191
+ }
192
+ const fe = ["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml", "image/avif"], B = ["not-allowed", "unsupported", "quota", "io-error", "read-only"];
193
+ function ue(t) {
194
+ if (typeof t != "string" || !t) return !1;
195
+ try {
196
+ return ["https:", "http:"].includes(new URL(t).protocol);
197
+ } catch {
198
+ return !1;
199
+ }
200
+ }
201
+ function pe(t) {
202
+ if (!(t instanceof c) || t.code !== -32e3 || typeof t.data != "object" || t.data === null) return null;
203
+ const e = t.data.reason;
204
+ return B.includes(e) ? e : null;
205
+ }
206
+ function de(t) {
207
+ if (!(t instanceof c) || t.code !== -32e3 || typeof t.data != "object" || t.data === null) return null;
208
+ const e = t.data.reason;
209
+ return L.includes(e) || T.includes(e) ? e : null;
210
+ }
211
+ class c extends Error {
212
+ constructor(e, r, n) {
213
+ super(r), this.code = e, this.data = n;
214
+ }
215
+ }
216
+ function m(t, e = [], r = 0) {
217
+ if (t instanceof ArrayBuffer) e.push(t);
218
+ else if (ArrayBuffer.isView(t) && t.buffer instanceof ArrayBuffer) e.push(t.buffer);
219
+ else if (t && typeof t == "object" && r < 4) for (const n of Object.values(t)) m(n, e, r + 1);
220
+ return e;
221
+ }
222
+ class he {
223
+ constructor(e, r) {
224
+ this.port = e, this.prefix = r, e.onmessage = (n) => void this.receive(n.data), e.start();
225
+ }
226
+ next = 1;
227
+ pending = /* @__PURE__ */ new Map();
228
+ handlers = /* @__PURE__ */ new Map();
229
+ listeners = /* @__PURE__ */ new Map();
230
+ closed = !1;
231
+ /** Answers requests for `method`; a thrown error becomes a JSON-RPC error. */
232
+ handle(e, r) {
233
+ this.handlers.set(e, r);
234
+ }
235
+ on(e, r) {
236
+ let n = this.listeners.get(e);
237
+ return n || this.listeners.set(e, n = /* @__PURE__ */ new Set()), n.add(r), () => n.delete(r);
238
+ }
239
+ /** `transfer` hands the params' ArrayBuffers over instead of copying them (the sender loses them). */
240
+ request(e, r, n = {}) {
241
+ if (this.closed) return Promise.reject(new c(-32e3, "the connection is closed"));
242
+ const s = `${this.prefix}${this.next++}`;
243
+ return new Promise((o, i) => {
244
+ this.pending.set(s, { resolve: o, reject: i }), this.post({ jsonrpc: "2.0", id: s, method: e, params: r }, n.transfer);
245
+ });
246
+ }
247
+ notify(e, r) {
248
+ this.closed || this.post({ jsonrpc: "2.0", method: e, params: r });
249
+ }
250
+ close() {
251
+ this.closed = !0;
252
+ for (const e of this.pending.values()) e.reject(new c(-32e3, "the connection is closed"));
253
+ this.pending.clear(), this.port.close();
254
+ }
255
+ post(e, r = !1) {
256
+ this.port.postMessage(e, r ? m(e.params ?? e.result) : []);
257
+ }
258
+ async receive(e) {
259
+ if (!e || e.jsonrpc !== "2.0") return;
260
+ if (e.method && e.id !== void 0) {
261
+ const n = this.handlers.get(e.method);
262
+ if (!n) return this.post({ jsonrpc: "2.0", id: e.id, error: { code: -32601, message: `${e.method} is not supported` } });
263
+ try {
264
+ const s = await n(e.params);
265
+ this.post({ jsonrpc: "2.0", id: e.id, result: s === void 0 ? {} : s });
266
+ } catch (s) {
267
+ const o = s instanceof c ? s : new c(-32e3, s instanceof Error ? s.message : String(s));
268
+ this.post({ jsonrpc: "2.0", id: e.id, error: { code: o.code, message: o.message, data: o.data } });
269
+ }
270
+ return;
271
+ }
272
+ if (e.method) {
273
+ for (const n of this.listeners.get(e.method) ?? []) n(e.params);
274
+ return;
275
+ }
276
+ if (e.id === void 0) return;
277
+ const r = this.pending.get(e.id);
278
+ r && (this.pending.delete(e.id), e.error ? r.reject(new c(e.error.code, e.error.message, e.error.data)) : r.resolve(e.result));
279
+ }
280
+ }
281
+ function ye(t, e, r) {
282
+ const n = t.split("+"), s = n.pop() ?? "", o = new Set(n);
283
+ return (r ? e.metaKey : e.ctrlKey) === o.has("Cmd") && e.shiftKey === o.has("Shift") && e.altKey === o.has("Alt") && e.key.toLowerCase() === s.toLowerCase();
284
+ }
285
+ export {
286
+ T as ACTION_ERROR_REASONS,
287
+ C as ANCHOR_IDS_LIMIT,
288
+ P as ANCHOR_TEXT_LIMIT,
289
+ B as FETCH_IMAGE_ERROR_REASONS,
290
+ fe as FETCH_IMAGE_TYPES,
291
+ b as FILE_ERROR_REASONS,
292
+ J as FILE_HANDLE_PREFIX,
293
+ L as GENERATE_ERROR_REASONS,
294
+ w as GENERATE_PURPOSES,
295
+ ee as HOST_ACTION_CAPABILITY_PREFIX,
296
+ X as HOST_ORIGIN_LABEL,
297
+ j as HOST_SERVICES,
298
+ te as HOST_SERVICE_CAPABILITY_PREFIX,
299
+ z as INVALID_PARAMS_REASON,
300
+ F as KIT_UI_PROTOCOL,
301
+ he as KitPeer,
302
+ c as KitRpcError,
303
+ W as LEASE_HELD_REASON,
304
+ H as OPEN_ERROR_REASONS,
305
+ q as OPEN_URL_SCHEMES,
306
+ D as ORIGIN_LABEL,
307
+ I as PRESENCE_SELECTION_LIMIT,
308
+ ne as SERVICE_ERROR_REASONS,
309
+ h as SERVICE_MESSAGE_LIMIT,
310
+ k as SERVICE_PEOPLE_LIMIT,
311
+ A as WATERMARK_TEXT_LIMIT,
312
+ pe as fetchImageErrorReason,
313
+ Q as fileErrorReason,
314
+ de as hostRequestErrorReason,
315
+ ue as isFetchableUrl,
316
+ v as isGeneratePurpose,
317
+ U as isHandshake,
318
+ V as isHello,
319
+ se as isOpenableUrl,
320
+ G as isReady,
321
+ ae as linkPathFrom,
322
+ ye as matchesShortcut,
323
+ le as openErrorReason,
324
+ y as parseCommentAnchor,
325
+ R as parseDocumentPermissions,
326
+ E as parseKitView,
327
+ K as parseLinkRef,
328
+ ce as parseLinksPickParams,
329
+ ie as parseOpenParams,
330
+ Y as parsePeers,
331
+ O as parsePresence,
332
+ Z as parseSchemaReport,
333
+ oe as parseServiceParams,
334
+ $ as parseWatermark,
335
+ re as serviceAllowed
336
+ };
@@ -0,0 +1,2 @@
1
+ // @kition/sdk/embed/server/callbacks is for Node only; this is what other conditions (a browser bundle) get.
2
+ throw new Error("@kition/sdk/embed/server/callbacks runs in Node only: import it on your server; a page imports @kition/sdk/embed")
@@ -0,0 +1,2 @@
1
+ // @kition/sdk/embed/server is for Node only; this is what other conditions (a browser bundle) get.
2
+ throw new Error("@kition/sdk/embed/server runs in Node only: import it on your server; a page imports @kition/sdk/embed")