@kitionstage/sdk 0.0.0-stage → 0.5.2-stage.13

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 (259) hide show
  1. package/README.md +73 -2
  2. package/dist/LICENSE +177 -0
  3. package/dist/THIRD_PARTY_NOTICES +28 -0
  4. package/dist/lib/assets/kitEngine.worker-3iMvwtlI.js +12732 -0
  5. package/dist/lib/assets/loro_wasm_bg-Gulzks_0.wasm +0 -0
  6. package/dist/lib/chunks/batch-BWpAyHvP.js +789 -0
  7. package/dist/lib/chunks/canonical-BIWfVCL-.js +87 -0
  8. package/dist/lib/chunks/envelope-D6MGY-ZN.js +61 -0
  9. package/dist/lib/chunks/replica-D8w3I4sn.js +2472 -0
  10. package/dist/lib/chunks/runtime-BVJHE1Pg.js +997 -0
  11. package/dist/lib/chunks/session-BqXC9a1-.js +281 -0
  12. package/dist/lib/chunks/toolIds-BCeSGHpV.js +821 -0
  13. package/dist/lib/chunks/workspaceTree-Destqupf.js +23 -0
  14. package/dist/lib/convergence/index.js +1035 -0
  15. package/dist/lib/convergence/node.js +8 -0
  16. package/dist/lib/embed-server/callbacks.js +37 -0
  17. package/dist/lib/embed-server/cli.js +19 -0
  18. package/dist/lib/embed-server/index.js +272 -0
  19. package/dist/lib/extensions/index.js +439 -0
  20. package/dist/lib/extensions/panel.html +208 -0
  21. package/dist/lib/extensions/runtime.js +198 -0
  22. package/dist/lib/extensions/sandbox.html +35 -0
  23. package/dist/lib/kdm/index.js +437 -0
  24. package/dist/lib/kit-dev-host/checkUiIds.mjs +44 -0
  25. package/dist/lib/kit-dev-host/index.js +308 -0
  26. package/dist/lib/kit-dev-host/lineRow.mjs +47 -0
  27. package/dist/lib/kit-dev-host/modeSmoke.mjs +178 -0
  28. package/dist/lib/kit-editor/index.js +6481 -0
  29. package/dist/lib/kit-editor/styles.css +807 -0
  30. package/dist/lib/kit-editor/workspaceTree.js +1 -0
  31. package/dist/lib/kit-engine/index.js +7 -0
  32. package/dist/lib/kit-host/index.js +530 -0
  33. package/dist/lib/kit-ui-protocol/index.js +336 -0
  34. package/dist/lib/node-only/embed-server-callbacks.js +2 -0
  35. package/dist/lib/node-only/embed-server.js +2 -0
  36. package/dist/lib/sync/index.js +1008 -0
  37. package/dist/lib/sync/openToken.js +201 -0
  38. package/dist/lib/sync/replicaVersions.js +51 -0
  39. package/dist/standalone/chunks/batch-CAGYk6m4.js +789 -0
  40. package/dist/standalone/chunks/client-B9xkOcvf.js +772 -0
  41. package/dist/standalone/chunks/collab-CTQZ9h7J.js +1022 -0
  42. package/dist/standalone/chunks/comment-Ds9t8xSE.js +94 -0
  43. package/dist/standalone/chunks/comments-uVDS8Wxp.js +41 -0
  44. package/dist/standalone/chunks/document-B5MMuYyN.js +324 -0
  45. package/dist/standalone/chunks/envelope-GX4Cynkx.js +7612 -0
  46. package/dist/standalone/chunks/index-BEgEEnhU.js +287 -0
  47. package/dist/standalone/chunks/index-EEl8hGbP.js +1967 -0
  48. package/dist/standalone/chunks/kits-Cp51mDlw.js +9 -0
  49. package/dist/standalone/chunks/replica-Di2iCPiD.js +3281 -0
  50. package/dist/standalone/chunks/replicaVersions-C3rJxnk9.js +50 -0
  51. package/dist/standalone/chunks/touched-T9jKJjxn.js +78 -0
  52. package/dist/standalone/index.js +12 -0
  53. package/dist/standalone/script/index.js +339 -0
  54. package/dist/standalone/script/kits/board.js +5 -0
  55. package/dist/standalone/script/kits/cad.js +5 -0
  56. package/dist/standalone/script/kits/design.js +5 -0
  57. package/dist/standalone/script/kits/doc.js +5 -0
  58. package/dist/standalone/script/kits/film.js +5 -0
  59. package/dist/standalone/script/kits/html.js +5 -0
  60. package/dist/standalone/script/kits/index.js +38 -0
  61. package/dist/standalone/script/kits/layout.js +5 -0
  62. package/dist/standalone/script/kits/motion.js +5 -0
  63. package/dist/standalone/script/kits/note.js +5 -0
  64. package/dist/standalone/script/kits/pdf.js +5 -0
  65. package/dist/standalone/script/kits/photo.js +5 -0
  66. package/dist/standalone/script/kits/scene.js +5 -0
  67. package/dist/standalone/script/kits/sheet.js +5 -0
  68. package/dist/standalone/script/kits/slide.js +5 -0
  69. package/dist/standalone/script/kits/table.js +5 -0
  70. package/dist/standalone/script/kits/vector.js +5 -0
  71. package/dist/standalone/script/node.js +401 -0
  72. package/dist/standalone/script/proxy.js +254 -0
  73. package/dist/types/convergence/src/adapter.d.ts +131 -0
  74. package/dist/types/convergence/src/engine.d.ts +66 -0
  75. package/dist/types/convergence/src/index.d.ts +21 -0
  76. package/dist/types/convergence/src/net.d.ts +52 -0
  77. package/dist/types/convergence/src/node.d.ts +6 -0
  78. package/dist/types/convergence/src/report.d.ts +56 -0
  79. package/dist/types/convergence/src/rng.d.ts +12 -0
  80. package/dist/types/convergence/src/scenarios.d.ts +15 -0
  81. package/dist/types/convergence/src/state.d.ts +67 -0
  82. package/dist/types/embed/src/agent.d.ts +88 -0
  83. package/dist/types/embed/src/blobs.d.ts +2 -0
  84. package/dist/types/embed/src/collab.d.ts +250 -0
  85. package/dist/types/embed/src/comments.d.ts +30 -0
  86. package/dist/types/embed/src/errors.d.ts +24 -0
  87. package/dist/types/embed/src/handlers.d.ts +92 -0
  88. package/dist/types/embed/src/index.d.ts +20 -0
  89. package/dist/types/embed/src/mount.d.ts +39 -0
  90. package/dist/types/embed/src/replicaStore.d.ts +3 -0
  91. package/dist/types/embed/src/rooms.d.ts +40 -0
  92. package/dist/types/embed/src/schemas.d.ts +7 -0
  93. package/dist/types/embed/src/syncClients.d.ts +28 -0
  94. package/dist/types/embed/src/theme.d.ts +7 -0
  95. package/dist/types/embed/src/types.d.ts +596 -0
  96. package/dist/types/embed/src/ui.d.ts +33 -0
  97. package/dist/types/embed/src/version.d.ts +2 -0
  98. package/dist/types/embed-server/src/callbacks.d.ts +30 -0
  99. package/dist/types/embed-server/src/cli.d.ts +1 -0
  100. package/dist/types/embed-server/src/index.d.ts +19 -0
  101. package/dist/types/embed-server/src/page.d.ts +15 -0
  102. package/dist/types/embed-server/src/server.d.ts +39 -0
  103. package/dist/types/embed-server/src/session.d.ts +22 -0
  104. package/dist/types/extensions/src/gate.d.ts +17 -0
  105. package/dist/types/extensions/src/generated/runtime.d.ts +8 -0
  106. package/dist/types/extensions/src/host.d.ts +135 -0
  107. package/dist/types/extensions/src/index.d.ts +13 -0
  108. package/dist/types/extensions/src/manifest.d.ts +82 -0
  109. package/dist/types/extensions/src/protocol.d.ts +159 -0
  110. package/dist/types/extensions/src/rpc.d.ts +52 -0
  111. package/dist/types/extensions/src/runtime/document.d.ts +40 -0
  112. package/dist/types/extensions/src/runtime/index.d.ts +10 -0
  113. package/dist/types/extensions/src/runtime/panel.d.ts +19 -0
  114. package/dist/types/extensions/src/runtime/runtime.d.ts +54 -0
  115. package/dist/types/extensions/src/runtime/worker.d.ts +1 -0
  116. package/dist/types/extensions/src/sandbox.d.ts +41 -0
  117. package/dist/types/kdm/src/args.d.ts +12 -0
  118. package/dist/types/kdm/src/batch.d.ts +118 -0
  119. package/dist/types/kdm/src/canonical.d.ts +25 -0
  120. package/dist/types/kdm/src/comment.d.ts +114 -0
  121. package/dist/types/kdm/src/diff.d.ts +125 -0
  122. package/dist/types/kdm/src/envelope.d.ts +27 -0
  123. package/dist/types/kdm/src/errors.d.ts +28 -0
  124. package/dist/types/kdm/src/footprint.d.ts +21 -0
  125. package/dist/types/kdm/src/ids.d.ts +57 -0
  126. package/dist/types/kdm/src/index.d.ts +18 -0
  127. package/dist/types/kdm/src/marks.d.ts +32 -0
  128. package/dist/types/kdm/src/op.d.ts +124 -0
  129. package/dist/types/kdm/src/origin.d.ts +41 -0
  130. package/dist/types/kdm/src/overlay.d.ts +92 -0
  131. package/dist/types/kdm/src/projection.d.ts +29 -0
  132. package/dist/types/kdm/src/read.d.ts +90 -0
  133. package/dist/types/kdm/src/replica.d.ts +403 -0
  134. package/dist/types/kdm/src/schema.d.ts +185 -0
  135. package/dist/types/kdm/src/testing.d.ts +28 -0
  136. package/dist/types/kdm/src/toolIds.d.ts +61 -0
  137. package/dist/types/kdm/src/touched.d.ts +24 -0
  138. package/dist/types/kdm/src/tx.d.ts +215 -0
  139. package/dist/types/kdm/src/value.d.ts +23 -0
  140. package/dist/types/kit-dev-host/src/checkNoPaths.d.ts +19 -0
  141. package/dist/types/kit-dev-host/src/checkUiIds.d.mts +2 -0
  142. package/dist/types/kit-dev-host/src/index.d.ts +179 -0
  143. package/dist/types/kit-dev-host/src/lineRow.d.mts +14 -0
  144. package/dist/types/kit-dev-host/src/memoryFiles.d.ts +15 -0
  145. package/dist/types/kit-dev-host/src/modeSmoke.d.mts +8 -0
  146. package/dist/types/kit-editor/src/CommandDialog.d.ts +22 -0
  147. package/dist/types/kit-editor/src/CommentsPanel.d.ts +45 -0
  148. package/dist/types/kit-editor/src/CustomizeDialog.d.ts +32 -0
  149. package/dist/types/kit-editor/src/HostButtons.d.ts +11 -0
  150. package/dist/types/kit-editor/src/RenderFailure.d.ts +7 -0
  151. package/dist/types/kit-editor/src/TextSink.d.ts +6 -0
  152. package/dist/types/kit-editor/src/brand.d.ts +2 -0
  153. package/dist/types/kit-editor/src/catalogMenus.d.ts +27 -0
  154. package/dist/types/kit-editor/src/chart.d.ts +138 -0
  155. package/dist/types/kit-editor/src/conflicts.d.ts +12 -0
  156. package/dist/types/kit-editor/src/drawing.d.ts +83 -0
  157. package/dist/types/kit-editor/src/editor.d.ts +544 -0
  158. package/dist/types/kit-editor/src/engine/KitCanvas.d.ts +70 -0
  159. package/dist/types/kit-editor/src/engine/backdrop.d.ts +32 -0
  160. package/dist/types/kit-editor/src/engine/createKitFile.d.ts +12 -0
  161. package/dist/types/kit-editor/src/engine/decorations.d.ts +14 -0
  162. package/dist/types/kit-editor/src/engine/engineOverlays.d.ts +197 -0
  163. package/dist/types/kit-editor/src/engine/engineTools.d.ts +116 -0
  164. package/dist/types/kit-editor/src/engine/kitDraft.d.ts +70 -0
  165. package/dist/types/kit-editor/src/engine/kitEngine.d.ts +390 -0
  166. package/dist/types/kit-editor/src/engine/kitEngine.worker.d.ts +30 -0
  167. package/dist/types/kit-editor/src/engine/kitHost.d.ts +41 -0
  168. package/dist/types/kit-editor/src/engine/kitModel.d.ts +32 -0
  169. package/dist/types/kit-editor/src/engine/kitModelRunner.d.ts +99 -0
  170. package/dist/types/kit-editor/src/engine/kitModule.d.ts +185 -0
  171. package/dist/types/kit-editor/src/engine/kitShortcuts.d.ts +32 -0
  172. package/dist/types/kit-editor/src/engine/kitTools.d.ts +79 -0
  173. package/dist/types/kit-editor/src/engine/lazyFonts.d.ts +34 -0
  174. package/dist/types/kit-editor/src/engine/lentFiles.d.ts +29 -0
  175. package/dist/types/kit-editor/src/engine/rasterViewport.d.ts +178 -0
  176. package/dist/types/kit-editor/src/engine/readOnly.d.ts +78 -0
  177. package/dist/types/kit-editor/src/engine/refusal.d.ts +39 -0
  178. package/dist/types/kit-editor/src/engine/replica.d.ts +23 -0
  179. package/dist/types/kit-editor/src/engine/useKitDocument.d.ts +154 -0
  180. package/dist/types/kit-editor/src/engine/workerRelay.d.ts +62 -0
  181. package/dist/types/kit-editor/src/files.d.ts +74 -0
  182. package/dist/types/kit-editor/src/frame/EditorFrame.d.ts +74 -0
  183. package/dist/types/kit-editor/src/frame/FocusBar.d.ts +10 -0
  184. package/dist/types/kit-editor/src/frame/MenuNodes.d.ts +20 -0
  185. package/dist/types/kit-editor/src/frame/MenuRibbon.d.ts +8 -0
  186. package/dist/types/kit-editor/src/frame/ModeButton.d.ts +7 -0
  187. package/dist/types/kit-editor/src/frame/menus.d.ts +64 -0
  188. package/dist/types/kit-editor/src/frame/modes.d.ts +51 -0
  189. package/dist/types/kit-editor/src/frame/useFrameLayout.d.ts +34 -0
  190. package/dist/types/kit-editor/src/host.d.ts +127 -0
  191. package/dist/types/kit-editor/src/index.d.ts +85 -0
  192. package/dist/types/kit-editor/src/ink.d.ts +26 -0
  193. package/dist/types/kit-editor/src/lease.d.ts +53 -0
  194. package/dist/types/kit-editor/src/oneInFlight.d.ts +7 -0
  195. package/dist/types/kit-editor/src/phrases.d.ts +25 -0
  196. package/dist/types/kit-editor/src/presence.d.ts +79 -0
  197. package/dist/types/kit-editor/src/strings.d.ts +6 -0
  198. package/dist/types/kit-editor/src/toolIcons.d.ts +32 -0
  199. package/dist/types/kit-editor/src/uiCatalog.d.ts +59 -0
  200. package/dist/types/kit-editor/src/uiConfig.d.ts +53 -0
  201. package/dist/types/kit-editor/src/uiContext.d.ts +65 -0
  202. package/dist/types/kit-editor/src/uiStore.d.ts +20 -0
  203. package/dist/types/kit-editor/src/useCommentAnchors.d.ts +29 -0
  204. package/dist/types/kit-editor/src/useKitSession.d.ts +115 -0
  205. package/dist/types/kit-editor/src/workspaceTree.d.ts +5 -0
  206. package/dist/types/kit-engine/src/contract.d.ts +154 -0
  207. package/dist/types/kit-engine/src/index.d.ts +2 -0
  208. package/dist/types/kit-engine/src/session.d.ts +133 -0
  209. package/dist/types/kit-host/src/files.d.ts +163 -0
  210. package/dist/types/kit-host/src/index.d.ts +315 -0
  211. package/dist/types/kit-ui-protocol/src/index.d.ts +1145 -0
  212. package/dist/types/loro-crdt.d.ts +9 -0
  213. package/dist/types/script/kits/board.d.ts +534 -0
  214. package/dist/types/script/kits/cad.d.ts +2937 -0
  215. package/dist/types/script/kits/design.d.ts +3213 -0
  216. package/dist/types/script/kits/doc.d.ts +2575 -0
  217. package/dist/types/script/kits/film.d.ts +4067 -0
  218. package/dist/types/script/kits/html.d.ts +38 -0
  219. package/dist/types/script/kits/index.d.ts +20 -0
  220. package/dist/types/script/kits/layout.d.ts +3483 -0
  221. package/dist/types/script/kits/motion.d.ts +4826 -0
  222. package/dist/types/script/kits/note.d.ts +631 -0
  223. package/dist/types/script/kits/pdf.d.ts +829 -0
  224. package/dist/types/script/kits/photo.d.ts +7574 -0
  225. package/dist/types/script/kits/scene.d.ts +2962 -0
  226. package/dist/types/script/kits/sheet.d.ts +2419 -0
  227. package/dist/types/script/kits/slide.d.ts +1894 -0
  228. package/dist/types/script/kits/table.d.ts +654 -0
  229. package/dist/types/script/kits/vector.d.ts +5167 -0
  230. package/dist/types/script/src/agentRelay.d.ts +48 -0
  231. package/dist/types/script/src/capabilities.d.ts +21 -0
  232. package/dist/types/script/src/document.d.ts +87 -0
  233. package/dist/types/script/src/drafts.d.ts +141 -0
  234. package/dist/types/script/src/exchange.d.ts +30 -0
  235. package/dist/types/script/src/headless.d.ts +190 -0
  236. package/dist/types/script/src/index.d.ts +15 -0
  237. package/dist/types/script/src/kitModel.d.ts +17 -0
  238. package/dist/types/script/src/kits.d.ts +8 -0
  239. package/dist/types/script/src/node.d.ts +42 -0
  240. package/dist/types/script/src/port.d.ts +89 -0
  241. package/dist/types/script/src/proxy.d.ts +132 -0
  242. package/dist/types/script/src/room.d.ts +162 -0
  243. package/dist/types/script/src/sources.d.ts +73 -0
  244. package/dist/types/sync/src/backoff.d.ts +9 -0
  245. package/dist/types/sync/src/blobSection.d.ts +23 -0
  246. package/dist/types/sync/src/capabilities.d.ts +20 -0
  247. package/dist/types/sync/src/client.d.ts +253 -0
  248. package/dist/types/sync/src/framing.d.ts +35 -0
  249. package/dist/types/sync/src/hash.d.ts +2 -0
  250. package/dist/types/sync/src/index.d.ts +19 -0
  251. package/dist/types/sync/src/leases.d.ts +82 -0
  252. package/dist/types/sync/src/openToken.d.ts +104 -0
  253. package/dist/types/sync/src/protocol.d.ts +484 -0
  254. package/dist/types/sync/src/relay.d.ts +52 -0
  255. package/dist/types/sync/src/replicaVersions.d.ts +17 -0
  256. package/dist/types/sync/src/saveMachine.d.ts +83 -0
  257. package/dist/types/sync/src/saveRun.d.ts +52 -0
  258. package/dist/types/sync/src/transport.d.ts +19 -0
  259. package/package.json +229 -4
@@ -0,0 +1,54 @@
1
+ import type { Notice } from '../protocol.js';
2
+ import { RpcPeer, type PortLike } from '../rpc.js';
3
+ import { ExtensionDocument } from './document.js';
4
+ /** A command handler; what it answers goes back to the host. */
5
+ export type CommandHandler = () => unknown | Promise<unknown>;
6
+ /** One open panel, as the extension's worker sees it: messages to it, and its requests. */
7
+ export type PanelConnection = {
8
+ /** The panel's id (`contributes.panels[].id`). */
9
+ readonly id: string;
10
+ /** This panel's session: a panel shown twice has two. */
11
+ readonly session: string;
12
+ /** Sends `message` to the panel (`kitionPanel.onMessage` there). */
13
+ post(message: unknown): void;
14
+ /** Answers the panel's `kitionPanel.request(message)`; what `handler` answers goes back. */
15
+ onRequest(handler: (message: unknown) => unknown): void;
16
+ /** Runs `listener` when the panel closes; answers a disposer. */
17
+ onClose(listener: () => void): () => void;
18
+ };
19
+ /** Called when a panel of this extension opens on the document; may answer a disposer. */
20
+ export type PanelHandler = (panel: PanelConnection) => unknown;
21
+ /** What `activate(ctx)` (and a script's default export) gets. */
22
+ export type ExtensionContext = {
23
+ extension: {
24
+ id: string;
25
+ name: string;
26
+ version: string;
27
+ permissions: string[];
28
+ };
29
+ /** The document this activation is for. */
30
+ document: ExtensionDocument;
31
+ commands: {
32
+ /** Handles a command the manifest contributes; answers a disposer. */
33
+ register(id: string, handler: CommandHandler): () => void;
34
+ };
35
+ panels: {
36
+ /** Serves a panel the manifest contributes each time it opens on this document; answers a disposer. */
37
+ register(id: string, handler: PanelHandler): () => void;
38
+ };
39
+ /** Shows a message to the person. */
40
+ notify(notice: Notice | string, options?: Omit<Notice, 'title'>): void;
41
+ /** Disposers run when the extension is deactivated on this document. */
42
+ subscriptions: Array<() => void>;
43
+ };
44
+ /** The module an extension's entry is. */
45
+ export type ExtensionModule = {
46
+ activate?: (ctx: ExtensionContext) => unknown;
47
+ deactivate?: (ctx: ExtensionContext) => unknown;
48
+ default?: unknown;
49
+ run?: unknown;
50
+ };
51
+ /** Loads an extension's module from its source. The worker imports a blob URL of it. */
52
+ export type ModuleLoader = (source: string) => Promise<ExtensionModule>;
53
+ /** Serves the host on `port` until it closes; answers the channel. */
54
+ export declare function startRuntime(port: PortLike, load: ModuleLoader): RpcPeer;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ import type { ExtensionHost, SandboxFactory } from './host.js';
2
+ export type IframeSandboxOptions = {
3
+ /** Where the host serves the sandbox page. */
4
+ url: string;
5
+ /** Where the hidden frames go (`document.body` by default). */
6
+ container?: HTMLElement;
7
+ /** How long the page may take to load (ms). */
8
+ loadTimeoutMs?: number;
9
+ };
10
+ export declare function iframeSandbox(options: IframeSandboxOptions): SandboxFactory;
11
+ export type PanelFrameOptions = {
12
+ /** Where the host serves the panel page (`sandbox/panel.html`, `PANEL_HTML`). */
13
+ url: string;
14
+ /** Where the panel's frame goes; it fills it. */
15
+ container: HTMLElement;
16
+ /** CSS custom properties for the panel (the host's theme), as `--name: value`. */
17
+ theme?: Record<string, string>;
18
+ /** The host's language, for the panel's `lang`. */
19
+ locale?: string;
20
+ /** How long the page may take to load (ms). */
21
+ loadTimeoutMs?: number;
22
+ /** The frame loaded another page (the panel navigated): it has been removed. */
23
+ onNavigated?: () => void;
24
+ };
25
+ /** A panel shown in a frame. */
26
+ export type PanelFrame = {
27
+ frame: HTMLIFrameElement;
28
+ dispose: () => void;
29
+ };
30
+ /**
31
+ * Shows a contributed panel of an extension for a document in a visible `sandbox="allow-scripts"`
32
+ * frame (an opaque origin, like the extension's worker) loaded from the host's copy of the panel
33
+ * page, with the extension's own `connect-src`. The panel and the extension's worker talk over a
34
+ * `MessageChannel` of their own. A frame that loads another page is removed: a panel never leaves
35
+ * its page (the host's `frame-src` keeps it from loading another origin's).
36
+ */
37
+ export declare function openPanelFrame(host: Pick<ExtensionHost, 'panelContent' | 'openPanel'>, target: {
38
+ documentId: string;
39
+ extension: string;
40
+ panel: string;
41
+ }, options: PanelFrameOptions): Promise<PanelFrame>;
@@ -0,0 +1,12 @@
1
+ /** A short, safe description of a value for a message (a symbol cannot be put in a template). */
2
+ export declare function describe(value: unknown): string;
3
+ /** Checks that `value` (named `what` in the message) is a string. */
4
+ export declare function checkString(what: string, value: unknown): asserts value is string;
5
+ /** Checks an index or count: a whole number from 0 (`out-of-range` otherwise). */
6
+ export declare function checkIndex(what: string, value: unknown): asserts value is number;
7
+ /** Checks that `value` is a plain object (prototype `Object.prototype` or `null`) without symbol keys. */
8
+ export declare function checkRecord(what: string, value: unknown): asserts value is Record<string, unknown>;
9
+ /** The form of an object id a host chooses (generated ids are UUID v7, which also match). */
10
+ export declare const OBJECT_ID_PATTERN = "[A-Za-z0-9][A-Za-z0-9:_-]{0,127}";
11
+ /** Checks the syntax of an id a host gives to a new object of type `ty` (`invalid-value` otherwise). */
12
+ export declare function checkObjectIdSyntax(ty: string, id: string): void;
@@ -0,0 +1,118 @@
1
+ import type { ObjectId } from './ids.js';
2
+ import { type Origin } from './origin.js';
3
+ import type { Replica } from './replica.js';
4
+ import { type Schema, type TypeDef } from './schema.js';
5
+ import type { Tx } from './tx.js';
6
+ import { type ProjectedObject } from './projection.js';
7
+ export declare const OBJECT_MODEL_CAPABILITY = "KitObjectModel 1.0";
8
+ export type BatchErrorCode = 'invalid-op' | 'not-found' | 'invalid-value' | 'read-only' | 'command-failed';
9
+ export declare class BatchError extends Error {
10
+ readonly code: BatchErrorCode;
11
+ readonly index: number | null;
12
+ constructor(code: BatchErrorCode, index: number | null, message: string);
13
+ toJSON(): {
14
+ code: BatchErrorCode;
15
+ index: number | null;
16
+ message: string;
17
+ };
18
+ }
19
+ export type BatchOp = {
20
+ op: string;
21
+ [key: string]: unknown;
22
+ };
23
+ export type BatchLoad = {
24
+ target: string;
25
+ fields?: string[];
26
+ };
27
+ export type BatchRequest = {
28
+ origin?: Origin | null;
29
+ ops?: BatchOp[];
30
+ load?: BatchLoad[];
31
+ objects?: boolean;
32
+ };
33
+ export type LoadedObject = {
34
+ id: string;
35
+ type: string;
36
+ fields: Record<string, unknown>;
37
+ projected?: boolean;
38
+ at?: ProjectedObject['at'];
39
+ };
40
+ export type BatchResult = {
41
+ refs: Record<string, string>;
42
+ results: unknown[];
43
+ loaded: LoadedObject[];
44
+ objects?: Array<{
45
+ id: string;
46
+ type: string;
47
+ }>;
48
+ };
49
+ /** What a batch runs against: a replica that takes transactions, and a kit that runs commands. */
50
+ export interface BatchTarget {
51
+ projectedObjects?(): ProjectedObject[] | Promise<ProjectedObject[]>;
52
+ /** The replica reads come from, current with the document. */
53
+ replica(): Replica | Promise<Replica>;
54
+ /** Runs `write` as one transaction with `origin`; nothing changes when it throws. */
55
+ transact(origin: Origin, write: (tx: Tx) => void): void | Promise<void>;
56
+ /** Runs a kit command as `origin`; answers its result. */
57
+ command(id: string, params: unknown, origin: Origin): unknown | Promise<unknown>;
58
+ commandAt?(id: string, params: unknown, context: {
59
+ on?: unknown;
60
+ part?: unknown;
61
+ time?: unknown;
62
+ }, origin: Origin): unknown | Promise<unknown>;
63
+ readOnly?: () => boolean;
64
+ }
65
+ /** A `Replica` as a `BatchTarget` without commands. */
66
+ export declare function replicaTarget(replica: Replica): BatchTarget;
67
+ /** The origin of a batch: `extension`/`script` when absent; only `person`, `agent`, and `extension`. */
68
+ export declare function batchOrigin(value: unknown): Origin;
69
+ /** `value` with every string equal to a bound reference replaced by its id. */
70
+ export declare function resolveValues(value: unknown, refs: ReadonlyMap<string, ObjectId>): unknown;
71
+ /** The root object: the first object of the schema's root type. */
72
+ export declare const rootId: (replica: Replica) => ObjectId | null;
73
+ /** Runs a batch request against `target`; answers `{ refs, results, loaded }`. */
74
+ export declare function runBatch(target: BatchTarget, request: BatchRequest): Promise<BatchResult>;
75
+ /** One field as `load` answers it. */
76
+ export declare function readField(replica: Replica, id: ObjectId, ty: string, name: string): unknown;
77
+ /** The schema as `model/describe` answers it, without the commands (the kit adds them). */
78
+ export declare function describeModel(replica: Replica): {
79
+ capability: string;
80
+ kit: string;
81
+ schemaVersion: number;
82
+ root: string;
83
+ rootId: string | null;
84
+ types: Record<string, {
85
+ fields: Record<string, Record<string, unknown>>;
86
+ projected?: true;
87
+ projectedOps?: TypeDef["projectedOps"];
88
+ batchOps?: TypeDef["batchOps"];
89
+ creation?: TypeDef["creation"];
90
+ readOnly?: true;
91
+ batchIndependent?: true;
92
+ moveConsequences?: string[];
93
+ structuralConsequences?: TypeDef["structuralConsequences"];
94
+ readOnlyWhen?: {
95
+ field: string;
96
+ values: string[];
97
+ };
98
+ toolId?: {
99
+ field: string;
100
+ prefix: string;
101
+ parent?: string;
102
+ };
103
+ pathName?: string;
104
+ label?: string;
105
+ text?: string;
106
+ derived?: Record<string, {
107
+ description?: string;
108
+ premiseOnly?: boolean;
109
+ onDemand?: boolean;
110
+ }>;
111
+ }>;
112
+ };
113
+ /**
114
+ * The schema a kit's `model/describe` answer describes (Rust's `kition_kits::drafts::schema_of`),
115
+ * for a reader that has no other. The description names a text field's marks by key (OM1), not
116
+ * their definitions (M4c): each expands after here, which only editing a marked text reads.
117
+ */
118
+ export declare function schemaOfDescription(description: object): Schema;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The canonical JSON form shared by every KDM implementation: object keys sorted, compact, and
3
+ * numbers written as the Rust crate writes them (`serde_json`), so the same state is the same text.
4
+ */
5
+ /**
6
+ * Sets `key` of `target` as an own enumerable property, also when the key is `__proto__` (which
7
+ * plain assignment would turn into a prototype change, losing the key).
8
+ */
9
+ export declare function setKey(target: Record<string, unknown>, key: string, value: unknown): void;
10
+ /**
11
+ * A deep copy with object keys sorted, for values handed to callers. Not itself the canonical
12
+ * form: only `canonicalText` is (JavaScript cannot express the Rust number forms as values).
13
+ */
14
+ export declare function canonical(value: unknown): unknown;
15
+ /** Rust sorts keys by their UTF-8 bytes; for UTF-16 strings that is code point order, not code unit order. */
16
+ export declare function compareKeys(a: string, b: string): number;
17
+ /**
18
+ * A number as `serde_json` writes it after the Rust `canonical`: whole numbers within ±2^53 as
19
+ * integers, other numbers in the shortest form that round-trips, in decimal notation when the
20
+ * decimal point falls within 16 digits of the start (`9100000000000000.0`, `0.00001`) and in
21
+ * exponent notation otherwise (`1e+16`, `1e-6`, `1.5e+300`).
22
+ */
23
+ export declare function formatNumber(value: number): string;
24
+ /** The canonical text of a value: equal to the Rust `canonical(value).to_string()`. */
25
+ export declare function canonicalText(value: unknown): string;
@@ -0,0 +1,114 @@
1
+ import type { ObjectId } from './ids.js';
2
+ import type { Replica } from './replica.js';
3
+ import type { Tx } from './tx.js';
4
+ export declare const COMMENT_THREAD_TYPE = "CommentThread";
5
+ export declare const COMMENT_TYPE = "Comment";
6
+ /** The `CommentThread` type's definition, as a kit adds it to its schema's `types`. */
7
+ export declare const COMMENT_THREAD_TYPE_DEF: {
8
+ readonly fields: {
9
+ readonly anchor: {
10
+ readonly kind: "json";
11
+ };
12
+ readonly resolved: {
13
+ readonly kind: "boolean";
14
+ readonly optional: true;
15
+ };
16
+ readonly comments: {
17
+ readonly kind: "list";
18
+ readonly of: "Comment";
19
+ };
20
+ };
21
+ readonly batchOps: {
22
+ readonly '*': {
23
+ readonly direct: true;
24
+ };
25
+ };
26
+ };
27
+ /** The `Comment` type's definition, as a kit adds it to its schema's `types`. */
28
+ export declare const COMMENT_TYPE_DEF: {
29
+ readonly fields: {
30
+ readonly author: {
31
+ readonly kind: "string";
32
+ };
33
+ readonly name: {
34
+ readonly kind: "string";
35
+ readonly optional: true;
36
+ };
37
+ readonly body: {
38
+ readonly kind: "text";
39
+ };
40
+ readonly created: {
41
+ readonly kind: "string";
42
+ };
43
+ };
44
+ readonly batchOps: {
45
+ readonly '*': {
46
+ readonly direct: true;
47
+ };
48
+ };
49
+ };
50
+ /** Whether `ty` is one of the comment types: the only types a commenter's change may touch. */
51
+ export declare function isCommentType(ty: string): boolean;
52
+ /**
53
+ * Where a thread is anchored: an object, and optionally a field of it and a range in that field
54
+ * (character offsets in a `text` field when the thread was made; `quote` is the text the range held
55
+ * then, so an editor can find it again after edits around it). Kits may add keys of their own.
56
+ */
57
+ export type CommentAnchor = {
58
+ object: string;
59
+ field?: string;
60
+ range?: {
61
+ start: number;
62
+ end: number;
63
+ };
64
+ quote?: string;
65
+ [key: string]: unknown;
66
+ };
67
+ /** A comment to write. `created` is ISO 8601 UTC (`new Date().toISOString()`). */
68
+ export type NewComment = {
69
+ author: string;
70
+ name?: string;
71
+ body: string;
72
+ created: string;
73
+ };
74
+ export type Comment = {
75
+ id: ObjectId;
76
+ author: string;
77
+ name?: string;
78
+ body: string;
79
+ created: string;
80
+ };
81
+ export type CommentThread = {
82
+ id: ObjectId;
83
+ anchor: CommentAnchor | null;
84
+ resolved: boolean;
85
+ comments: Comment[];
86
+ };
87
+ /** Opens a thread at `anchor` with its first comment. */
88
+ export declare function addThread(tx: Tx, anchor: CommentAnchor, comment: NewComment): {
89
+ thread: ObjectId;
90
+ comment: ObjectId;
91
+ };
92
+ /** Adds `comment` at the end of `thread`. */
93
+ export declare function reply(tx: Tx, thread: ObjectId, comment: NewComment): ObjectId;
94
+ /** Resolves `thread` (or opens it again). */
95
+ export declare function setResolved(tx: Tx, thread: ObjectId, resolved: boolean): void;
96
+ /** Deletes one comment of `thread`; deleting its last comment deletes the thread. */
97
+ export declare function deleteComment(tx: Tx, thread: ObjectId, comment: ObjectId): void;
98
+ /** Deletes `thread` and its comments. */
99
+ export declare function deleteThread(tx: Tx, thread: ObjectId): void;
100
+ /**
101
+ * The document's comment threads, oldest first (by their first comment's `created`, then id), with
102
+ * their live comments in order. Empty for a schema without the comment types.
103
+ */
104
+ export declare function commentThreads(replica: Replica): CommentThread[];
105
+ /**
106
+ * Where a range anchor's text is now: its `range` while the text there still reads `quote`,
107
+ * otherwise the occurrence of `quote` nearest the old start, or `null` when the quote is gone (the
108
+ * thread then shows without a place in the text). An anchor without a range or quote answers its
109
+ * range as is.
110
+ */
111
+ export declare function relocateAnchorRange(anchor: CommentAnchor, text: string): {
112
+ start: number;
113
+ end: number;
114
+ } | null;
@@ -0,0 +1,125 @@
1
+ import { type Schema } from './schema.js';
2
+ import { ToolIds } from './toolIds.js';
3
+ /** Where an object sits: the object whose list or tree field holds it (a tree node's parent object, or the tree's owner for a root), that field, and its index among its siblings. */
4
+ export type Position = {
5
+ parent: string;
6
+ field: string;
7
+ index: number;
8
+ };
9
+ /** One field a change changed: its value before and after, as `shownValue` gives them. */
10
+ export type TextSpan = {
11
+ offset: number;
12
+ removed: string;
13
+ inserted: string;
14
+ removedLength: number;
15
+ insertedLength: number;
16
+ before: string;
17
+ after: string;
18
+ complete: boolean;
19
+ };
20
+ export type FieldEdit = {
21
+ field: string;
22
+ before: unknown;
23
+ after: unknown;
24
+ named?: string;
25
+ span?: TextSpan;
26
+ spansTruncated?: boolean;
27
+ };
28
+ /**
29
+ * One object in a `StateDiff`: its id, its type, and the fields concerned (sorted). A created
30
+ * object also gives `values` (list and tree fields left out) and `at`, where a list or tree holds
31
+ * it; a deleted one `at`, where a list or tree held it; a changed one gives `edits`.
32
+ */
33
+ export type ObjectChange = {
34
+ id: string;
35
+ type: string;
36
+ fields: string[];
37
+ values?: Record<string, unknown>;
38
+ at?: Position;
39
+ edits?: FieldEdit[];
40
+ };
41
+ /** An object whose place in a list or tree changed; `from` or `to` is `null` where no changed list holds it. */
42
+ export type Move = {
43
+ id: string;
44
+ type: string;
45
+ from: Position | null;
46
+ to: Position | null;
47
+ };
48
+ /** A text-like field (a `text` field, or a string) a draft changed, as plain text before and after. */
49
+ export type TextChange = {
50
+ id: string;
51
+ field: string;
52
+ before: string;
53
+ after: string;
54
+ };
55
+ /**
56
+ * What changed between two states, each list sorted by object id (then field): `created` objects
57
+ * only `after` has (`fields`: those holding a value), `changed` objects whose fields differ,
58
+ * `moved` objects whose place in a list or tree changed (also in `changed` when their fields did),
59
+ * `deleted` objects only `before` has (`at`: where a list or tree held them), and `texts`, the full text of changed text-like fields, which
60
+ * only a draft's comparison has. `footprint` states a shift of many objects once
61
+ * (`withFootprint`, which agent tools apply to the change sets they answer); a diff never fills it.
62
+ */
63
+ export type StateDiff = {
64
+ created: ObjectChange[];
65
+ changed: ObjectChange[];
66
+ moved: Move[];
67
+ deleted: ObjectChange[];
68
+ texts?: TextChange[];
69
+ footprint?: unknown;
70
+ };
71
+ /** The most characters a text value of a change shows; a longer one is an excerpt with its length. */
72
+ export declare const EXCERPT_CHARS = 80;
73
+ /** One bounded replacement, in Unicode scalar offsets, matching Rust's `text_span`. */
74
+ export declare function textSpan(before: string, after: string): TextSpan | undefined;
75
+ /** Add bounded spans before translating tool ids. At most 64 KiB of span JSON per change. */
76
+ export declare function withTextSpans(diff: StateDiff, before: unknown, after: unknown): StateDiff;
77
+ type Json = Record<string, unknown>;
78
+ /** A field's value as a change shows it: a text as an excerpt when long, a blob as `{ size }`, anything else as it is. */
79
+ export declare function shownValue(value: unknown, start: number): unknown;
80
+ /** Private journal values for historical coverage; never include these in public receipts. */
81
+ export declare function withDeletedBasis(diff: StateDiff, schema: Schema): Omit<StateDiff, 'deleted'> & {
82
+ deleted: Array<ObjectChange & {
83
+ $was?: Json;
84
+ }>;
85
+ };
86
+ /** At most how many edits a `json` value's change is told in, down to its changed leaves (`withLeafEdits`); more, and it is told whole. */
87
+ export declare const LEAF_EDITS = 16;
88
+ /**
89
+ * As the Rust `StateDiff::with_leaf_edits`: a changed `map` field that owns no objects
90
+ * told by key (`attrs.stretch`), a `json` value and each key's value down to its changed leaves
91
+ * when that is at most `LEAF_EDITS` edits and fewer bytes than the value whole; each edit's path
92
+ * stands in `fields` for the field. Apply it before `diffWithToolIds`.
93
+ */
94
+ export declare function withLeafEdits(diff: StateDiff, schema: Schema): StateDiff;
95
+ /**
96
+ * As the Rust `diff_objects`: the difference of the objects `ids` (sorted) between two sides, each
97
+ * the canonical objects it has among them; `typeOfId` answers an object's type on either side.
98
+ * @internal
99
+ */
100
+ export declare function diffObjects(ids: string[], old: Json, next: Json, typeOfId: (id: string) => string | null, fullTexts: boolean): StateDiff;
101
+ /** The difference `before → after` of two canonical states (`Replica.stateJson`): a draft's comparison, with `texts`. */
102
+ export declare function diffStates(before: unknown, after: unknown): StateDiff;
103
+ /** Private guard history: complete text and marks, capped at 1 MiB per field and 4 MiB total. */
104
+ export declare function withTextBasis(diff: StateDiff, schema: Schema, before: unknown, after: unknown): StateDiff & {
105
+ $text?: Record<string, Json>;
106
+ };
107
+ /** Whether a `StateDiff` holds no object change. */
108
+ export declare const diffIsEmpty: (diff: StateDiff) => boolean;
109
+ /**
110
+ * As the Rust `StateDiff::with_tool_ids`: the difference with objects named as the tool interface
111
+ * names them (rule OM9): created, changed and moved objects by their tool ids in `after`, deleted
112
+ * ones by theirs in `before`; positions' parents (`from` in `before`, `to` and `at` in `after`) and
113
+ * the value of a `ref` field (the id it holds) the same way; each list sorted again by id.
114
+ *
115
+ * An object without a tool id of its own that a nearer object with one holds (`ToolIds.attributed`)
116
+ * is told as an edit of that object at the path from it: a changed field `{ field: '<path>.f',
117
+ * before, after }`; created `{ field: '<path>', before: null, after: <values> }`; deleted `{ field:
118
+ * '<path>', before: <values>, after: null }`; moved `{ field: '<path of its list>', before: '<path
119
+ * before>', after: '<path after>' }` (`null` on the side another holder has); inside an object the
120
+ * same change created, its values join that object's `values` at their paths; inside one it deleted,
121
+ * it is left out. A position whose parent is such an object names its holder and the path to the
122
+ * field, and a ref to one reads `<tool id>.<path>`.
123
+ */
124
+ export declare function diffWithToolIds(diff: StateDiff, schema: Schema, before: ToolIds, after: ToolIds): StateDiff;
125
+ export {};
@@ -0,0 +1,27 @@
1
+ /** Versions, and the envelope every byte string a replica exports carries. */
2
+ import type { VersionVector } from '../../loro-crdt.js';
3
+ /** A replica's version: the set of changes it contains. Exchanged to ask for what is missing. */
4
+ export declare class Version {
5
+ /** Each peer's counter, sorted by peer: compares structurally. */
6
+ private readonly counters;
7
+ private constructor();
8
+ static empty(): Version;
9
+ static decode(bytes: Uint8Array): Version;
10
+ /** @internal */
11
+ static fromEngine(vv: VersionVector): Version;
12
+ /** @internal */
13
+ toEngine(): VersionVector;
14
+ encode(): Uint8Array;
15
+ /**
16
+ * Whether every change in `other` is in this version. Versions are partially ordered: of two
17
+ * replicas that changed concurrently, neither version includes the other.
18
+ */
19
+ includes(other: Version): boolean;
20
+ equals(other: Version): boolean;
21
+ }
22
+ export declare function wrap(docId: Uint8Array, bytes: Uint8Array): Uint8Array;
23
+ export declare function open(bytes: Uint8Array): {
24
+ docId: Uint8Array;
25
+ engine: Uint8Array;
26
+ };
27
+ export declare const sameBytes: (a: Uint8Array, b: Uint8Array) => boolean;
@@ -0,0 +1,28 @@
1
+ /** Every failure of the KDM, with the same reasons as the variants of the Rust `KdmError`. */
2
+ export type KdmErrorReason = 'schema' | 'unknown-type' | 'unknown-field' | 'invalid-value' | 'not-found' | 'cycle' | 'out-of-range' | 'wrong-document' | 'newer-schema' | 'history-missing' | 'encoding' | 'engine';
3
+ /** Bad input is a `KdmError`, never another exception. Messages read like the Rust ones. */
4
+ export declare class KdmError extends Error {
5
+ readonly reason: KdmErrorReason;
6
+ constructor(reason: KdmErrorReason, message: string);
7
+ }
8
+ /** Constructors with the Rust `KdmError` display texts. */
9
+ export declare const errors: {
10
+ schema: (message: string) => KdmError;
11
+ unknownType: (ty: string) => KdmError;
12
+ /** As the Rust `Schema::unknown_field`: the type's fields, and that a field is one name, not a path. */
13
+ unknownField: (ty: string, field: string, known?: readonly string[]) => KdmError;
14
+ invalidValue: (ty: string, field: string, reason: string) => KdmError;
15
+ notFound: (what: string) => KdmError;
16
+ cycle: () => KdmError;
17
+ outOfRange: (index: number, len: number) => KdmError;
18
+ wrongDocument: (expected: string, found: string) => KdmError;
19
+ /** The document's minimum schema version (rule M20) is newer than the reader's schema. */
20
+ newerSchema: (found: number, reads: number) => KdmError;
21
+ /**
22
+ * A shallow replica (standard 2.0 rule M16a) was asked for history before its root: changes that
23
+ * depend on it, or a version older than it. The server keeps that history.
24
+ */
25
+ historyMissing: (message: string) => KdmError;
26
+ encoding: (message: string) => KdmError;
27
+ engine: (message: string) => KdmError;
28
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A change set's `footprint`, as kition-kdm's `footprint.rs`: a shift of many objects
3
+ * stated once. When at least `FOOTPRINT_MIN_RUN` objects one after another in one list had one
4
+ * numeric field changed by the same amount and nothing else changed in them, their entries are
5
+ * replaced by `{ parent, field, from, count, shift: { field, by } }` (`from` and `count`: the run's
6
+ * indexes in the list after the change). A parent's entry that says only that its list changed
7
+ * (`fields: ["clips"]`, no edits) is dropped when the footprint, or a created, deleted or moved
8
+ * object of that list, already says what happened. Objects whose every change is a shift, the same
9
+ * shifts for at least `FOOTPRINT_MIN_RUN` of them, in no such run are stated by their ids
10
+ *: `{ ids, edits: [{ field, by }] }`. `shift.by` is a number (whole when both values
11
+ * are), or for whole numbers written as strings a string. Both answer the same for
12
+ * `crates/kition-kdm/tests/fixtures/footprint.json`.
13
+ */
14
+ type Json = Record<string, unknown>;
15
+ /** The fewest objects one footprint entry stands for. */
16
+ export declare const FOOTPRINT_MIN_RUN = 4;
17
+ /** The lists a change set changed, which its footprint may name, each once, in order (as the Rust `footprint::lists`). */
18
+ export declare function footprintLists(changes: Json): Array<[string, string]>;
19
+ /** `changes` with its footprint (as the Rust `footprint::with_footprint`); `itemsOf` answers a list's items after the change. */
20
+ export declare function withFootprint(changes: Json, itemsOfList: (parent: string, field: string) => string[] | null): Json;
21
+ export {};
@@ -0,0 +1,57 @@
1
+ /** The stable identity of one object in a document, unique across all replicas. */
2
+ export type ObjectId = string;
3
+ /** The hyphenated lowercase form of 16 UUID bytes. */
4
+ export declare function uuidFromBytes(bytes: Uint8Array): string;
5
+ /** The 16 bytes of a UUID in any form the Rust `uuid` crate parses; anything else is an `encoding` error. */
6
+ export declare function uuidToBytes(text: string): Uint8Array;
7
+ /** A UUID v7: 48-bit Unix milliseconds, version and variant bits, the rest random. */
8
+ export declare function uuidV7(now?: number): string;
9
+ /** A new object id. UUID v7: unique without coordination and roughly creation-ordered. */
10
+ export declare const newObjectId: () => ObjectId;
11
+ /** A new document id: a document's durable identity, never changed by renaming or moving its file. */
12
+ export declare const newDocId: () => string;
13
+ /** Checks an actor id: an unsigned 64-bit integer other than the reserved 2^64 - 1. */
14
+ export declare function checkActor(actor: bigint): bigint;
15
+ /** A fresh actor for one writable replica session; the top bit is clear because the engine reserves 2^64 - 1. */
16
+ export declare function randomActor(): bigint;
17
+ /** What a handle names: an engine node, or the `index`-th node created by transaction `tx`, resolved once that commits. */
18
+ interface NodeState {
19
+ id: string | null;
20
+ readonly pending?: {
21
+ readonly tx: number;
22
+ readonly index: number;
23
+ };
24
+ }
25
+ /**
26
+ * A node of a tree field. Valid in the replica that returned it and in every replica that has
27
+ * the change that created it.
28
+ *
29
+ * A node created inside a transaction has no engine id until the transaction commits; its handle
30
+ * resolves then. Handles compare (`equals`) by resolved node; two unresolved handles are equal only
31
+ * if they are the same handle. A handle from a failed transaction never resolves, and using it is
32
+ * a `not-found` error. Handles cannot be constructed or changed outside the KDM.
33
+ */
34
+ export declare class NodeRef {
35
+ /** The engine's id of the node once it exists in the document; `null` before. Read-only. */
36
+ readonly id: string | null;
37
+ /** @internal */
38
+ constructor(token: symbol, state: NodeState);
39
+ equals(other: NodeRef): boolean;
40
+ }
41
+ /** @internal A handle of a node in the document. */
42
+ export declare const committedNode: (id: string) => NodeRef;
43
+ /** @internal A handle of the `index`-th node transaction `tx` creates. */
44
+ export declare const pendingNode: (tx: number, index: number) => NodeRef;
45
+ /** @internal What a handle names, or `undefined` for an object the KDM did not make. */
46
+ export declare const nodeState: (node: NodeRef) => Readonly<NodeState> | undefined;
47
+ /** @internal Resolves a pending handle once, when its transaction applies. */
48
+ export declare function resolveNode(node: NodeRef, id: string): void;
49
+ /** One node of a tree field, as `Replica.tree` and `Tx.tree` list it. */
50
+ export interface TreeEntry {
51
+ node: NodeRef;
52
+ /** The object the node names. */
53
+ object: ObjectId;
54
+ /** `null` for a root. */
55
+ parent: NodeRef | null;
56
+ }
57
+ export {};
@@ -0,0 +1,18 @@
1
+ export { BatchError, batchOrigin, describeModel, OBJECT_MODEL_CAPABILITY, readField, replicaTarget, resolveValues, rootId, runBatch, schemaOfDescription, type BatchErrorCode, type BatchLoad, type BatchOp, type BatchRequest, type BatchResult, type BatchTarget, type LoadedObject, } from './batch.js';
2
+ export { canonicalText } from './canonical.js';
3
+ export { addThread, COMMENT_THREAD_TYPE, COMMENT_THREAD_TYPE_DEF, COMMENT_TYPE, COMMENT_TYPE_DEF, commentThreads, deleteComment, deleteThread, isCommentType, relocateAnchorRange, reply, setResolved, type Comment, type CommentAnchor, type CommentThread, type NewComment, } from './comment.js';
4
+ export { ChangeAudit, touchesOnlyComments, type Touched } from './touched.js';
5
+ export { diffIsEmpty, diffStates, diffWithToolIds, EXCERPT_CHARS, LEAF_EDITS, withLeafEdits, withDeletedBasis, withTextBasis, withTextSpans, textSpan, type TextSpan, type FieldEdit, type Move, type ObjectChange, type Position, type StateDiff, type TextChange } from './diff.js';
6
+ export { KdmError, type KdmErrorReason } from './errors.js';
7
+ export { footprintLists, FOOTPRINT_MIN_RUN, withFootprint } from './footprint.js';
8
+ export { newDocId, newObjectId, NodeRef, randomActor, uuidFromBytes, uuidToBytes, uuidV7, type ObjectId, type TreeEntry } from './ids.js';
9
+ export { agent, decodeCommit, decodeOrigin, encodeCommit, encodeOrigin, person, system, undoScopeOf, type Origin, type OriginKind, type UndoScope } from './origin.js';
10
+ export { open as openEnvelope, Version } from './envelope.js';
11
+ export type { TextRun } from './marks.js';
12
+ export { Replica, type TextDelta, type UndoTouch } from './replica.js';
13
+ export { checkValue, fieldDef, hasMarks, hasToolIds, isContainer, KDM_VERSION, objectReadOnly, parseSchema, typeDef, type Expand, type FieldDef, type FieldKind, type MarkDef, type ReadOnlyWhen, type Schema, type ToolIdDef, type TypeDef } from './schema.js';
14
+ export { ToolIds, type Unresolved } from './toolIds.js';
15
+ export { ProjectionView, hasProjections, type ProjectedObject } from './projection.js';
16
+ export { Network, Rng } from './testing.js';
17
+ export { Tx } from './tx.js';
18
+ export type { JsonValue } from './value.js';