@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.
- package/README.md +73 -2
- package/dist/LICENSE +177 -0
- package/dist/THIRD_PARTY_NOTICES +28 -0
- package/dist/lib/assets/kitEngine.worker-3iMvwtlI.js +12732 -0
- package/dist/lib/assets/loro_wasm_bg-Gulzks_0.wasm +0 -0
- package/dist/lib/chunks/batch-BWpAyHvP.js +789 -0
- package/dist/lib/chunks/canonical-BIWfVCL-.js +87 -0
- package/dist/lib/chunks/envelope-D6MGY-ZN.js +61 -0
- package/dist/lib/chunks/replica-D8w3I4sn.js +2472 -0
- package/dist/lib/chunks/runtime-BVJHE1Pg.js +997 -0
- package/dist/lib/chunks/session-BqXC9a1-.js +281 -0
- package/dist/lib/chunks/toolIds-BCeSGHpV.js +821 -0
- package/dist/lib/chunks/workspaceTree-Destqupf.js +23 -0
- package/dist/lib/convergence/index.js +1035 -0
- package/dist/lib/convergence/node.js +8 -0
- package/dist/lib/embed-server/callbacks.js +37 -0
- package/dist/lib/embed-server/cli.js +19 -0
- package/dist/lib/embed-server/index.js +272 -0
- package/dist/lib/extensions/index.js +439 -0
- package/dist/lib/extensions/panel.html +208 -0
- package/dist/lib/extensions/runtime.js +198 -0
- package/dist/lib/extensions/sandbox.html +35 -0
- package/dist/lib/kdm/index.js +437 -0
- package/dist/lib/kit-dev-host/checkUiIds.mjs +44 -0
- package/dist/lib/kit-dev-host/index.js +308 -0
- package/dist/lib/kit-dev-host/lineRow.mjs +47 -0
- package/dist/lib/kit-dev-host/modeSmoke.mjs +178 -0
- package/dist/lib/kit-editor/index.js +6481 -0
- package/dist/lib/kit-editor/styles.css +807 -0
- package/dist/lib/kit-editor/workspaceTree.js +1 -0
- package/dist/lib/kit-engine/index.js +7 -0
- package/dist/lib/kit-host/index.js +530 -0
- package/dist/lib/kit-ui-protocol/index.js +336 -0
- package/dist/lib/node-only/embed-server-callbacks.js +2 -0
- package/dist/lib/node-only/embed-server.js +2 -0
- package/dist/lib/sync/index.js +1008 -0
- package/dist/lib/sync/openToken.js +201 -0
- package/dist/lib/sync/replicaVersions.js +51 -0
- package/dist/standalone/chunks/batch-CAGYk6m4.js +789 -0
- package/dist/standalone/chunks/client-B9xkOcvf.js +772 -0
- package/dist/standalone/chunks/collab-CTQZ9h7J.js +1022 -0
- package/dist/standalone/chunks/comment-Ds9t8xSE.js +94 -0
- package/dist/standalone/chunks/comments-uVDS8Wxp.js +41 -0
- package/dist/standalone/chunks/document-B5MMuYyN.js +324 -0
- package/dist/standalone/chunks/envelope-GX4Cynkx.js +7612 -0
- package/dist/standalone/chunks/index-BEgEEnhU.js +287 -0
- package/dist/standalone/chunks/index-EEl8hGbP.js +1967 -0
- package/dist/standalone/chunks/kits-Cp51mDlw.js +9 -0
- package/dist/standalone/chunks/replica-Di2iCPiD.js +3281 -0
- package/dist/standalone/chunks/replicaVersions-C3rJxnk9.js +50 -0
- package/dist/standalone/chunks/touched-T9jKJjxn.js +78 -0
- package/dist/standalone/index.js +12 -0
- package/dist/standalone/script/index.js +339 -0
- package/dist/standalone/script/kits/board.js +5 -0
- package/dist/standalone/script/kits/cad.js +5 -0
- package/dist/standalone/script/kits/design.js +5 -0
- package/dist/standalone/script/kits/doc.js +5 -0
- package/dist/standalone/script/kits/film.js +5 -0
- package/dist/standalone/script/kits/html.js +5 -0
- package/dist/standalone/script/kits/index.js +38 -0
- package/dist/standalone/script/kits/layout.js +5 -0
- package/dist/standalone/script/kits/motion.js +5 -0
- package/dist/standalone/script/kits/note.js +5 -0
- package/dist/standalone/script/kits/pdf.js +5 -0
- package/dist/standalone/script/kits/photo.js +5 -0
- package/dist/standalone/script/kits/scene.js +5 -0
- package/dist/standalone/script/kits/sheet.js +5 -0
- package/dist/standalone/script/kits/slide.js +5 -0
- package/dist/standalone/script/kits/table.js +5 -0
- package/dist/standalone/script/kits/vector.js +5 -0
- package/dist/standalone/script/node.js +401 -0
- package/dist/standalone/script/proxy.js +254 -0
- package/dist/types/convergence/src/adapter.d.ts +131 -0
- package/dist/types/convergence/src/engine.d.ts +66 -0
- package/dist/types/convergence/src/index.d.ts +21 -0
- package/dist/types/convergence/src/net.d.ts +52 -0
- package/dist/types/convergence/src/node.d.ts +6 -0
- package/dist/types/convergence/src/report.d.ts +56 -0
- package/dist/types/convergence/src/rng.d.ts +12 -0
- package/dist/types/convergence/src/scenarios.d.ts +15 -0
- package/dist/types/convergence/src/state.d.ts +67 -0
- package/dist/types/embed/src/agent.d.ts +88 -0
- package/dist/types/embed/src/blobs.d.ts +2 -0
- package/dist/types/embed/src/collab.d.ts +250 -0
- package/dist/types/embed/src/comments.d.ts +30 -0
- package/dist/types/embed/src/errors.d.ts +24 -0
- package/dist/types/embed/src/handlers.d.ts +92 -0
- package/dist/types/embed/src/index.d.ts +20 -0
- package/dist/types/embed/src/mount.d.ts +39 -0
- package/dist/types/embed/src/replicaStore.d.ts +3 -0
- package/dist/types/embed/src/rooms.d.ts +40 -0
- package/dist/types/embed/src/schemas.d.ts +7 -0
- package/dist/types/embed/src/syncClients.d.ts +28 -0
- package/dist/types/embed/src/theme.d.ts +7 -0
- package/dist/types/embed/src/types.d.ts +596 -0
- package/dist/types/embed/src/ui.d.ts +33 -0
- package/dist/types/embed/src/version.d.ts +2 -0
- package/dist/types/embed-server/src/callbacks.d.ts +30 -0
- package/dist/types/embed-server/src/cli.d.ts +1 -0
- package/dist/types/embed-server/src/index.d.ts +19 -0
- package/dist/types/embed-server/src/page.d.ts +15 -0
- package/dist/types/embed-server/src/server.d.ts +39 -0
- package/dist/types/embed-server/src/session.d.ts +22 -0
- package/dist/types/extensions/src/gate.d.ts +17 -0
- package/dist/types/extensions/src/generated/runtime.d.ts +8 -0
- package/dist/types/extensions/src/host.d.ts +135 -0
- package/dist/types/extensions/src/index.d.ts +13 -0
- package/dist/types/extensions/src/manifest.d.ts +82 -0
- package/dist/types/extensions/src/protocol.d.ts +159 -0
- package/dist/types/extensions/src/rpc.d.ts +52 -0
- package/dist/types/extensions/src/runtime/document.d.ts +40 -0
- package/dist/types/extensions/src/runtime/index.d.ts +10 -0
- package/dist/types/extensions/src/runtime/panel.d.ts +19 -0
- package/dist/types/extensions/src/runtime/runtime.d.ts +54 -0
- package/dist/types/extensions/src/runtime/worker.d.ts +1 -0
- package/dist/types/extensions/src/sandbox.d.ts +41 -0
- package/dist/types/kdm/src/args.d.ts +12 -0
- package/dist/types/kdm/src/batch.d.ts +118 -0
- package/dist/types/kdm/src/canonical.d.ts +25 -0
- package/dist/types/kdm/src/comment.d.ts +114 -0
- package/dist/types/kdm/src/diff.d.ts +125 -0
- package/dist/types/kdm/src/envelope.d.ts +27 -0
- package/dist/types/kdm/src/errors.d.ts +28 -0
- package/dist/types/kdm/src/footprint.d.ts +21 -0
- package/dist/types/kdm/src/ids.d.ts +57 -0
- package/dist/types/kdm/src/index.d.ts +18 -0
- package/dist/types/kdm/src/marks.d.ts +32 -0
- package/dist/types/kdm/src/op.d.ts +124 -0
- package/dist/types/kdm/src/origin.d.ts +41 -0
- package/dist/types/kdm/src/overlay.d.ts +92 -0
- package/dist/types/kdm/src/projection.d.ts +29 -0
- package/dist/types/kdm/src/read.d.ts +90 -0
- package/dist/types/kdm/src/replica.d.ts +403 -0
- package/dist/types/kdm/src/schema.d.ts +185 -0
- package/dist/types/kdm/src/testing.d.ts +28 -0
- package/dist/types/kdm/src/toolIds.d.ts +61 -0
- package/dist/types/kdm/src/touched.d.ts +24 -0
- package/dist/types/kdm/src/tx.d.ts +215 -0
- package/dist/types/kdm/src/value.d.ts +23 -0
- package/dist/types/kit-dev-host/src/checkNoPaths.d.ts +19 -0
- package/dist/types/kit-dev-host/src/checkUiIds.d.mts +2 -0
- package/dist/types/kit-dev-host/src/index.d.ts +179 -0
- package/dist/types/kit-dev-host/src/lineRow.d.mts +14 -0
- package/dist/types/kit-dev-host/src/memoryFiles.d.ts +15 -0
- package/dist/types/kit-dev-host/src/modeSmoke.d.mts +8 -0
- package/dist/types/kit-editor/src/CommandDialog.d.ts +22 -0
- package/dist/types/kit-editor/src/CommentsPanel.d.ts +45 -0
- package/dist/types/kit-editor/src/CustomizeDialog.d.ts +32 -0
- package/dist/types/kit-editor/src/HostButtons.d.ts +11 -0
- package/dist/types/kit-editor/src/RenderFailure.d.ts +7 -0
- package/dist/types/kit-editor/src/TextSink.d.ts +6 -0
- package/dist/types/kit-editor/src/brand.d.ts +2 -0
- package/dist/types/kit-editor/src/catalogMenus.d.ts +27 -0
- package/dist/types/kit-editor/src/chart.d.ts +138 -0
- package/dist/types/kit-editor/src/conflicts.d.ts +12 -0
- package/dist/types/kit-editor/src/drawing.d.ts +83 -0
- package/dist/types/kit-editor/src/editor.d.ts +544 -0
- package/dist/types/kit-editor/src/engine/KitCanvas.d.ts +70 -0
- package/dist/types/kit-editor/src/engine/backdrop.d.ts +32 -0
- package/dist/types/kit-editor/src/engine/createKitFile.d.ts +12 -0
- package/dist/types/kit-editor/src/engine/decorations.d.ts +14 -0
- package/dist/types/kit-editor/src/engine/engineOverlays.d.ts +197 -0
- package/dist/types/kit-editor/src/engine/engineTools.d.ts +116 -0
- package/dist/types/kit-editor/src/engine/kitDraft.d.ts +70 -0
- package/dist/types/kit-editor/src/engine/kitEngine.d.ts +390 -0
- package/dist/types/kit-editor/src/engine/kitEngine.worker.d.ts +30 -0
- package/dist/types/kit-editor/src/engine/kitHost.d.ts +41 -0
- package/dist/types/kit-editor/src/engine/kitModel.d.ts +32 -0
- package/dist/types/kit-editor/src/engine/kitModelRunner.d.ts +99 -0
- package/dist/types/kit-editor/src/engine/kitModule.d.ts +185 -0
- package/dist/types/kit-editor/src/engine/kitShortcuts.d.ts +32 -0
- package/dist/types/kit-editor/src/engine/kitTools.d.ts +79 -0
- package/dist/types/kit-editor/src/engine/lazyFonts.d.ts +34 -0
- package/dist/types/kit-editor/src/engine/lentFiles.d.ts +29 -0
- package/dist/types/kit-editor/src/engine/rasterViewport.d.ts +178 -0
- package/dist/types/kit-editor/src/engine/readOnly.d.ts +78 -0
- package/dist/types/kit-editor/src/engine/refusal.d.ts +39 -0
- package/dist/types/kit-editor/src/engine/replica.d.ts +23 -0
- package/dist/types/kit-editor/src/engine/useKitDocument.d.ts +154 -0
- package/dist/types/kit-editor/src/engine/workerRelay.d.ts +62 -0
- package/dist/types/kit-editor/src/files.d.ts +74 -0
- package/dist/types/kit-editor/src/frame/EditorFrame.d.ts +74 -0
- package/dist/types/kit-editor/src/frame/FocusBar.d.ts +10 -0
- package/dist/types/kit-editor/src/frame/MenuNodes.d.ts +20 -0
- package/dist/types/kit-editor/src/frame/MenuRibbon.d.ts +8 -0
- package/dist/types/kit-editor/src/frame/ModeButton.d.ts +7 -0
- package/dist/types/kit-editor/src/frame/menus.d.ts +64 -0
- package/dist/types/kit-editor/src/frame/modes.d.ts +51 -0
- package/dist/types/kit-editor/src/frame/useFrameLayout.d.ts +34 -0
- package/dist/types/kit-editor/src/host.d.ts +127 -0
- package/dist/types/kit-editor/src/index.d.ts +85 -0
- package/dist/types/kit-editor/src/ink.d.ts +26 -0
- package/dist/types/kit-editor/src/lease.d.ts +53 -0
- package/dist/types/kit-editor/src/oneInFlight.d.ts +7 -0
- package/dist/types/kit-editor/src/phrases.d.ts +25 -0
- package/dist/types/kit-editor/src/presence.d.ts +79 -0
- package/dist/types/kit-editor/src/strings.d.ts +6 -0
- package/dist/types/kit-editor/src/toolIcons.d.ts +32 -0
- package/dist/types/kit-editor/src/uiCatalog.d.ts +59 -0
- package/dist/types/kit-editor/src/uiConfig.d.ts +53 -0
- package/dist/types/kit-editor/src/uiContext.d.ts +65 -0
- package/dist/types/kit-editor/src/uiStore.d.ts +20 -0
- package/dist/types/kit-editor/src/useCommentAnchors.d.ts +29 -0
- package/dist/types/kit-editor/src/useKitSession.d.ts +115 -0
- package/dist/types/kit-editor/src/workspaceTree.d.ts +5 -0
- package/dist/types/kit-engine/src/contract.d.ts +154 -0
- package/dist/types/kit-engine/src/index.d.ts +2 -0
- package/dist/types/kit-engine/src/session.d.ts +133 -0
- package/dist/types/kit-host/src/files.d.ts +163 -0
- package/dist/types/kit-host/src/index.d.ts +315 -0
- package/dist/types/kit-ui-protocol/src/index.d.ts +1145 -0
- package/dist/types/loro-crdt.d.ts +9 -0
- package/dist/types/script/kits/board.d.ts +534 -0
- package/dist/types/script/kits/cad.d.ts +2937 -0
- package/dist/types/script/kits/design.d.ts +3213 -0
- package/dist/types/script/kits/doc.d.ts +2575 -0
- package/dist/types/script/kits/film.d.ts +4067 -0
- package/dist/types/script/kits/html.d.ts +38 -0
- package/dist/types/script/kits/index.d.ts +20 -0
- package/dist/types/script/kits/layout.d.ts +3483 -0
- package/dist/types/script/kits/motion.d.ts +4826 -0
- package/dist/types/script/kits/note.d.ts +631 -0
- package/dist/types/script/kits/pdf.d.ts +829 -0
- package/dist/types/script/kits/photo.d.ts +7574 -0
- package/dist/types/script/kits/scene.d.ts +2962 -0
- package/dist/types/script/kits/sheet.d.ts +2419 -0
- package/dist/types/script/kits/slide.d.ts +1894 -0
- package/dist/types/script/kits/table.d.ts +654 -0
- package/dist/types/script/kits/vector.d.ts +5167 -0
- package/dist/types/script/src/agentRelay.d.ts +48 -0
- package/dist/types/script/src/capabilities.d.ts +21 -0
- package/dist/types/script/src/document.d.ts +87 -0
- package/dist/types/script/src/drafts.d.ts +141 -0
- package/dist/types/script/src/exchange.d.ts +30 -0
- package/dist/types/script/src/headless.d.ts +190 -0
- package/dist/types/script/src/index.d.ts +15 -0
- package/dist/types/script/src/kitModel.d.ts +17 -0
- package/dist/types/script/src/kits.d.ts +8 -0
- package/dist/types/script/src/node.d.ts +42 -0
- package/dist/types/script/src/port.d.ts +89 -0
- package/dist/types/script/src/proxy.d.ts +132 -0
- package/dist/types/script/src/room.d.ts +162 -0
- package/dist/types/script/src/sources.d.ts +73 -0
- package/dist/types/sync/src/backoff.d.ts +9 -0
- package/dist/types/sync/src/blobSection.d.ts +23 -0
- package/dist/types/sync/src/capabilities.d.ts +20 -0
- package/dist/types/sync/src/client.d.ts +253 -0
- package/dist/types/sync/src/framing.d.ts +35 -0
- package/dist/types/sync/src/hash.d.ts +2 -0
- package/dist/types/sync/src/index.d.ts +19 -0
- package/dist/types/sync/src/leases.d.ts +82 -0
- package/dist/types/sync/src/openToken.d.ts +104 -0
- package/dist/types/sync/src/protocol.d.ts +484 -0
- package/dist/types/sync/src/relay.d.ts +52 -0
- package/dist/types/sync/src/replicaVersions.d.ts +17 -0
- package/dist/types/sync/src/saveMachine.d.ts +83 -0
- package/dist/types/sync/src/saveRun.d.ts +52 -0
- package/dist/types/sync/src/transport.d.ts +19 -0
- package/package.json +229 -4
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public shapes of `@kition/sdk/embed` (`KitEmbed 1.3`, with EM25's opening and EM28): what an
|
|
3
|
+
* integrator passes to `KitionEmbed.mount`, the providers it implements, and the editor it gets
|
|
4
|
+
* back. Every member a later version added is optional, so a `KitEmbed 1.0` page works unchanged.
|
|
5
|
+
*/
|
|
6
|
+
import type { CommentAnchor, Origin } from '../../kdm/src/index.js';
|
|
7
|
+
import type { AgentPort, AgentPortOptions } from './agent.js';
|
|
8
|
+
import type { AiRunResult, DraftComparison, DraftInfo, DraftSummary, KitCommentAnchor, KitConflict, KitDiagnostic, KitHostService, KitHostServices, KitLease, KitLinkRef, KitNotifications, KitSchemaReport, KitShownThread, KitTheme, KitUiConfig, KitUiHostButton, KitView, StoredReplica } from '../../kit-ui-protocol/src/index.js';
|
|
9
|
+
import type { ConnectionState, Presence, Role, SaveAuthor, SaveState, SaveTrigger } from '../../sync/src/index.js';
|
|
10
|
+
import type { OpenTokenKey } from '../../sync/src/openToken.js';
|
|
11
|
+
import type { ModelDocument } from '../../script/src/document.js';
|
|
12
|
+
import type { CommandMap, ModelObject } from '../../script/src/proxy.js';
|
|
13
|
+
import type { EmbedConflictError } from './errors.js';
|
|
14
|
+
export type { AgentPort, AgentPortOptions, AgentRelayTransport, AgentTool, AgentErrorCode, JsonRpcMessage } from './agent.js';
|
|
15
|
+
export type { CommandMap, CommentAnchor, DraftComparison, DraftInfo, DraftSummary, KitLease, KitLinkRef, KitUiHostButton, KitView, ModelDocument, ModelObject, Origin, Presence, Role, StoredReplica };
|
|
16
|
+
/** The kit package to show: its id (`kit.json` `id`) and the base URL it is served from. */
|
|
17
|
+
export type EmbedKit = {
|
|
18
|
+
id: string;
|
|
19
|
+
/** The kit package's base URL (`https://kits.example.com/slide-ui/`); its origin is the editor's. */
|
|
20
|
+
url: string;
|
|
21
|
+
/** The UI entry inside the package; `index.html` by default. */
|
|
22
|
+
entry?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The kit's KDM schema (`@kition/sdk/script/kits/<kit>`'s descriptor `schema`), for reviewing drafts
|
|
25
|
+
* and the agent's object-model calls when the kit's engine does not describe its own. When not
|
|
26
|
+
* given, the package's own `model/schema.json` is read, else `@kition/sdk/script`'s generated kit's
|
|
27
|
+
* (`KitEmbed 1.3`).
|
|
28
|
+
*/
|
|
29
|
+
schema?: object;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The document: the integrator's id for it, and the file name the kit sees (its format comes from
|
|
33
|
+
* it). `name` may be left out when the storage answers `info`, which then names the file.
|
|
34
|
+
*/
|
|
35
|
+
export type EmbedFile = {
|
|
36
|
+
id: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
};
|
|
39
|
+
/** A file as the storage reads it: its bytes and a version that changes with every write. */
|
|
40
|
+
export type StoredFile = {
|
|
41
|
+
bytes: ArrayBuffer | Uint8Array;
|
|
42
|
+
version: string;
|
|
43
|
+
};
|
|
44
|
+
/** What `StorageProvider.info` tells of a file without reading it (`KitEmbed 1.1`). */
|
|
45
|
+
export type FileInfo = {
|
|
46
|
+
name: string;
|
|
47
|
+
version: string;
|
|
48
|
+
size?: number;
|
|
49
|
+
mime?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Blobs by their content hash (lowercase hex SHA-256), as a kit's replica references them
|
|
53
|
+
* (`KitEmbed 1.1`). With one, the replica's blobs (pictures, media) are kept here instead of
|
|
54
|
+
* inside the stored replica (`storage.replica`, or this browser's IndexedDB).
|
|
55
|
+
*/
|
|
56
|
+
export type BlobStore = {
|
|
57
|
+
/** The blob's bytes, or `null` when the store does not hold it. */
|
|
58
|
+
read: (hash: string) => Promise<ArrayBuffer | Uint8Array | null>;
|
|
59
|
+
/** Keeps the blob; a store that already holds the hash may skip it. */
|
|
60
|
+
write: (hash: string, bytes: Uint8Array) => Promise<void>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Where the integrator keeps documents. Versions are opaque, non-empty strings that change on
|
|
64
|
+
* every write; the editor passes back the one it last saw, so a write over someone else's is
|
|
65
|
+
* refused (`EmbedConflictError`) rather than lost.
|
|
66
|
+
*/
|
|
67
|
+
export type StorageProvider = {
|
|
68
|
+
read: (fileId: string) => Promise<StoredFile>;
|
|
69
|
+
/**
|
|
70
|
+
* The file's current version without its bytes (a cheap change check); `null` if it is gone.
|
|
71
|
+
* Optional when `info` is given, whose `version` then answers it.
|
|
72
|
+
*/
|
|
73
|
+
stamp?: (fileId: string) => Promise<string | null>;
|
|
74
|
+
/** The file's name, version, and optionally size and type, without its bytes; `null` if it is gone (`KitEmbed 1.1`). */
|
|
75
|
+
info?: (fileId: string) => Promise<FileInfo | null>;
|
|
76
|
+
/**
|
|
77
|
+
* Replaces the file; throws `EmbedConflictError` when its version is no longer `expectedVersion`.
|
|
78
|
+
* In a managed room (KitCollab 1.4) `save` says what the version holds: store one version with
|
|
79
|
+
* these authors (managed-collab.md SV1), and refuse it as a conflict when `docKey` is not the
|
|
80
|
+
* file's current generation (SV3).
|
|
81
|
+
*/
|
|
82
|
+
write: (fileId: string, bytes: Uint8Array, options: {
|
|
83
|
+
expectedVersion: string | null;
|
|
84
|
+
save?: EmbedSaveInfo;
|
|
85
|
+
}) => Promise<{
|
|
86
|
+
version: string;
|
|
87
|
+
}>;
|
|
88
|
+
/** Makes a new file (an export, a saved copy); without it, the kit's exports are refused. */
|
|
89
|
+
create?: (name: string, bytes: Uint8Array) => Promise<{
|
|
90
|
+
fileId: string;
|
|
91
|
+
name?: string;
|
|
92
|
+
version?: string;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Keeps the document's replica next to its file (Kit UI protocol capability `replica`). Without
|
|
96
|
+
* it, a collaboration session keeps it in this browser's IndexedDB, keyed by the file id; a
|
|
97
|
+
* single-user editor needs none.
|
|
98
|
+
*/
|
|
99
|
+
replica?: ReplicaStore;
|
|
100
|
+
/** Keeps the editor's collaboration records; `localStorage` (`kition.embed.rooms.v1`) by default. */
|
|
101
|
+
state?: EmbedState;
|
|
102
|
+
/** Keeps the replica's blobs by hash (`KitEmbed 1.1`); without it they stay inside the stored replica. */
|
|
103
|
+
blob?: BlobStore;
|
|
104
|
+
/**
|
|
105
|
+
* The URL the files the document links (media, linked pictures, fonts) are read from in ranges
|
|
106
|
+
* (`KitEmbed 1.1`, Kit UI protocol `document.lend`): the kit reads `<url>/<path>` with `Range`
|
|
107
|
+
* requests from its own origin, so the server answers CORS for it and the kit origin's
|
|
108
|
+
* `connect-src` lists it. `null` or absent: the kit is lent no files.
|
|
109
|
+
*/
|
|
110
|
+
lend?: (fileId: string) => string | URL | null | Promise<string | URL | null>;
|
|
111
|
+
/**
|
|
112
|
+
* The file a link in `fromFileId`'s document names, as the page resolves it (`KitEmbed 1.5`,
|
|
113
|
+
* EM25), or `null` when it names none. With `open`, the kit offers opening linked files
|
|
114
|
+
* (capability `open-file`); the embed asks only from a person's gesture in the kit (OP1).
|
|
115
|
+
*/
|
|
116
|
+
resolveLink?: (fromFileId: string, link: KitLinkRef) => Promise<ResolvedLink | null>;
|
|
117
|
+
/** Opens the file in the page's own UI, at `view` when given (EM25, OP2, OP3); `opened: false` when the person cancelled. */
|
|
118
|
+
open?: (fileId: string, view?: KitView) => Promise<{
|
|
119
|
+
opened: boolean;
|
|
120
|
+
}>;
|
|
121
|
+
/**
|
|
122
|
+
* Opens a web address in the system's browser or mail client once the person confirmed it with
|
|
123
|
+
* the full address shown (EM25, OP8); `opened: false` when they declined. The kit offers it
|
|
124
|
+
* (capability `open-url`); the embed passes only `https:`, `http:`, and `mailto:` addresses from
|
|
125
|
+
* a person's gesture (OP6, OP7).
|
|
126
|
+
*/
|
|
127
|
+
openUrl?: (url: string) => Promise<{
|
|
128
|
+
opened: boolean;
|
|
129
|
+
}>;
|
|
130
|
+
};
|
|
131
|
+
/** `StorageProvider.resolveLink`: the linked file; `path` is relative to the linking file, as the page names it. */
|
|
132
|
+
export type ResolvedLink = {
|
|
133
|
+
fileId: string;
|
|
134
|
+
name: string;
|
|
135
|
+
kitId: string | null;
|
|
136
|
+
version: string | null;
|
|
137
|
+
path: string;
|
|
138
|
+
};
|
|
139
|
+
export type ReplicaStore = {
|
|
140
|
+
read: (fileId: string) => Promise<StoredReplica | null>;
|
|
141
|
+
write: (fileId: string, replica: StoredReplica) => Promise<void>;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* What one save of a managed room writes (KitCollab 1.4, managed-collab.md section 3): what started
|
|
145
|
+
* it, the room's change it holds, everyone whose changes are in it since the last version (from
|
|
146
|
+
* the sync server's log), the room's file generation, and the sync server's signed `receipt` of
|
|
147
|
+
* all that (`ksr1.`, I6). The host MUST verify the receipt and take the authors, `seq` and
|
|
148
|
+
* generation from it; `authors` here are for showing only, since a page could change them.
|
|
149
|
+
*/
|
|
150
|
+
export type EmbedSaveInfo = {
|
|
151
|
+
trigger: SaveTrigger;
|
|
152
|
+
seq: number;
|
|
153
|
+
authors: SaveAuthor[];
|
|
154
|
+
docKey: string;
|
|
155
|
+
docId: string;
|
|
156
|
+
receipt: string;
|
|
157
|
+
};
|
|
158
|
+
/** A small key-value store for JSON values. */
|
|
159
|
+
export type EmbedState = {
|
|
160
|
+
get: (key: string) => unknown | Promise<unknown>;
|
|
161
|
+
set: (key: string, value: unknown) => void | Promise<void>;
|
|
162
|
+
};
|
|
163
|
+
export type EmbedUser = {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
avatar?: string;
|
|
167
|
+
};
|
|
168
|
+
/** What a person may do with a document: edit it, only comment on it, or only view it. */
|
|
169
|
+
export type PermissionMode = 'edit' | 'comment' | 'view';
|
|
170
|
+
/** Who the person is, and (`KitEmbed 1.1`) who others are and what the person may do. */
|
|
171
|
+
export type IdentityProvider = {
|
|
172
|
+
/**
|
|
173
|
+
* A token for the sync server, asked for on every connection, so it can be refreshed. Needed
|
|
174
|
+
* with `collaboration`.
|
|
175
|
+
*/
|
|
176
|
+
token?: () => string | Promise<string>;
|
|
177
|
+
/** The person, for the presence others see and as the author of their comments. Needed with `collaboration`. */
|
|
178
|
+
user?: () => EmbedUser | Promise<EmbedUser>;
|
|
179
|
+
/**
|
|
180
|
+
* Other people by id, for their names and avatars in `presence` and `comments` (`KitEmbed
|
|
181
|
+
* 1.1`). Answers the ones it knows; each id is asked for once per editor.
|
|
182
|
+
*/
|
|
183
|
+
users?: (ids: string[]) => EmbedUser[] | Promise<EmbedUser[]>;
|
|
184
|
+
/**
|
|
185
|
+
* What the person may do with the file, asked for each time the editor opens it (`KitEmbed
|
|
186
|
+
* 1.1`). The stricter of it and the `permissions` option applies.
|
|
187
|
+
*/
|
|
188
|
+
permissions?: (fileId: string) => {
|
|
189
|
+
mode: PermissionMode;
|
|
190
|
+
} | Promise<{
|
|
191
|
+
mode: PermissionMode;
|
|
192
|
+
}>;
|
|
193
|
+
};
|
|
194
|
+
export type EmbedCollaboration = {
|
|
195
|
+
/** The sync server's WebSocket URL (`wss://…/v1/sync`). */
|
|
196
|
+
server: string;
|
|
197
|
+
/**
|
|
198
|
+
* The room to join: a document id or a share link. One editor per page co-edits a document; a
|
|
199
|
+
* second one fails `ready()` with `EmbedError` `document-open`. Omitted: the document's own room, made
|
|
200
|
+
* the first time (`editor.collab.shareLink` then answers links to it).
|
|
201
|
+
*/
|
|
202
|
+
room?: string;
|
|
203
|
+
/**
|
|
204
|
+
* The editor co-edits through an open token only (KitCollab 1.4): `ready()` fails when the
|
|
205
|
+
* identity provider answers any other token. Every editor asks for its token before it
|
|
206
|
+
* connects either way, and an open-token editor never shares another editor's connection.
|
|
207
|
+
*/
|
|
208
|
+
open?: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Hosts' public keys to verify open tokens with in the page too (KitCollab 1.4, OT2): an editor
|
|
211
|
+
* whose token does not verify does not open. Without them the sync server alone verifies it.
|
|
212
|
+
*/
|
|
213
|
+
openKeys?: OpenTokenKey[];
|
|
214
|
+
/** The Kition Server id open tokens must name (`aud`, I2); needed with `openKeys`. */
|
|
215
|
+
openAudience?: string;
|
|
216
|
+
/** How often a managed room autosaves while it has unsaved changes, in milliseconds (default 30 000; SV2). */
|
|
217
|
+
autosaveMs?: number;
|
|
218
|
+
};
|
|
219
|
+
/** `colorScheme` and the `--kit-*` tokens to change; the rest keep their defaults for the scheme. */
|
|
220
|
+
export type EmbedTheme = {
|
|
221
|
+
colorScheme: 'light' | 'dark';
|
|
222
|
+
tokens?: Record<string, string>;
|
|
223
|
+
brand?: KitTheme['brand'];
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* `view` opens the document read-only; `comment` (`KitEmbed 1.1`) also read-only for its content,
|
|
227
|
+
* while the person still writes comment threads (Kit UI protocol `document.comments`).
|
|
228
|
+
*/
|
|
229
|
+
export type EmbedPermissions = {
|
|
230
|
+
mode: PermissionMode;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* The editor's interface as the page wants it (`KitEmbed 1.1`): the Kit UI protocol's UI
|
|
234
|
+
* configuration (`hide`, `disable`, `add`, `personal`, section 9), and two shorthands over it.
|
|
235
|
+
*/
|
|
236
|
+
export type EmbedUi = KitUiConfig & {
|
|
237
|
+
/** `none` hides the kit's ribbon tabs (`tab:*`); `full`, the default, hides nothing. */
|
|
238
|
+
toolbar?: 'full' | 'none';
|
|
239
|
+
/**
|
|
240
|
+
* The only panels to show, by `panel:` id or by name (`comments` is `panel:comments`); the kit's
|
|
241
|
+
* other panels are hidden once it has opened. Absent: every panel.
|
|
242
|
+
*/
|
|
243
|
+
panels?: string[];
|
|
244
|
+
/**
|
|
245
|
+
* Keeps what the person hid themselves (Kit UI protocol `host/customize`): with it, the kit offers
|
|
246
|
+
* "Customize interface…", and the page passes the hides back as `personal` on later mounts.
|
|
247
|
+
*/
|
|
248
|
+
customize?: (personal: {
|
|
249
|
+
hide: string[];
|
|
250
|
+
}) => void | Promise<void>;
|
|
251
|
+
};
|
|
252
|
+
export type EmbedOptions = {
|
|
253
|
+
kit: EmbedKit;
|
|
254
|
+
file: EmbedFile;
|
|
255
|
+
storage: StorageProvider;
|
|
256
|
+
/**
|
|
257
|
+
* Needed only with `collaboration`. Editors co-editing through the same server share the page's
|
|
258
|
+
* one connection to it, opened with the first editor's identity: the first identity wins.
|
|
259
|
+
*/
|
|
260
|
+
identity?: IdentityProvider;
|
|
261
|
+
/** Omitted: single-user. */
|
|
262
|
+
collaboration?: EmbedCollaboration;
|
|
263
|
+
/** A BCP 47 tag; the browser's language by default. */
|
|
264
|
+
locale?: string;
|
|
265
|
+
theme?: EmbedTheme;
|
|
266
|
+
permissions?: EmbedPermissions;
|
|
267
|
+
/** What the kit's editor shows and allows (`KitEmbed 1.1`); everything by default. */
|
|
268
|
+
ui?: EmbedUi;
|
|
269
|
+
/** How long the kit may take to open the document; two minutes by default. */
|
|
270
|
+
timeoutMs?: number;
|
|
271
|
+
/**
|
|
272
|
+
* Lets the page edit the document through the object model (`@kition/sdk/script`'s
|
|
273
|
+
* `openDocument(editor)`): the kit keeps a replica, in memory when `storage` has no `replica`
|
|
274
|
+
* store and the editor does not co-edit.
|
|
275
|
+
*/
|
|
276
|
+
model?: boolean;
|
|
277
|
+
/**
|
|
278
|
+
* What the kit lets the person take out of the document and the watermark it draws (Kit UI
|
|
279
|
+
* `document.permissions`, `document.watermark`), for a page that decided them
|
|
280
|
+
* itself (the embed server, from its open token). A managed room's open token decides
|
|
281
|
+
* them instead.
|
|
282
|
+
*/
|
|
283
|
+
display?: EmbedDisplay;
|
|
284
|
+
/**
|
|
285
|
+
* The page's own shortcuts (`KitEmbed 1.6`, EM28), as `Cmd+S`: the kit forwards them instead of
|
|
286
|
+
* handling them, heard as the `shortcut` event. Listing `Cmd+S` leaves saving to the page
|
|
287
|
+
* (`editor.save()`). None by default.
|
|
288
|
+
*/
|
|
289
|
+
shortcuts?: string[];
|
|
290
|
+
/**
|
|
291
|
+
* The page's host services by id (`KitEmbed 1.7`, EM29; Kit UI protocol section 7k), offered to
|
|
292
|
+
* the kit when the document's permissions allow each (UI-V4). Params arrive checked. A handler
|
|
293
|
+
* refuses by throwing an error whose `reason` is one of `SERVICE_ERROR_REASONS`; any other error
|
|
294
|
+
* answers `failed`.
|
|
295
|
+
*/
|
|
296
|
+
services?: EmbedServices;
|
|
297
|
+
/**
|
|
298
|
+
* The page keeps the document's comment threads itself and the kit anchors them (`KitEmbed 1.7`,
|
|
299
|
+
* EM30, capability `comment-anchors`): new threads arrive as the `comment.create` service,
|
|
300
|
+
* `editor.comments.show` marks them, and `activated` hears the person click a marker.
|
|
301
|
+
*/
|
|
302
|
+
comments?: {
|
|
303
|
+
activated: (threadId: string) => void;
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
/** `EmbedOptions.services`: one handler per host service the page serves. */
|
|
307
|
+
export type EmbedServices = {
|
|
308
|
+
[S in KitHostService]?: (params: KitHostServices[S][0]) => KitHostServices[S][1] | Promise<KitHostServices[S][1]>;
|
|
309
|
+
};
|
|
310
|
+
/** A thread the page keeps, as the kit marks it (`editor.comments.show`). */
|
|
311
|
+
export type EmbedShownThread = KitShownThread;
|
|
312
|
+
/** Where a comment thread is in the document, as the kit reports it (Kit UI protocol section 7k). */
|
|
313
|
+
export type EmbedCommentAnchor = KitCommentAnchor;
|
|
314
|
+
/** The `shortcut` event: a key of `EmbedOptions.shortcuts` pressed in the kit (Kit UI protocol `host/shortcut`). */
|
|
315
|
+
export type EmbedShortcut = KitNotifications['host/shortcut'];
|
|
316
|
+
/** `EmbedOptions.display`: absent members leave the kit's defaults (everything allowed, no watermark). */
|
|
317
|
+
export type EmbedDisplay = {
|
|
318
|
+
permissions?: {
|
|
319
|
+
download: boolean;
|
|
320
|
+
export: boolean;
|
|
321
|
+
share: boolean;
|
|
322
|
+
};
|
|
323
|
+
watermark?: {
|
|
324
|
+
text: string;
|
|
325
|
+
} | null;
|
|
326
|
+
};
|
|
327
|
+
/** `off`: no collaboration; otherwise the sync connection's state. */
|
|
328
|
+
export type CollabStatus = ConnectionState | 'off';
|
|
329
|
+
export type CollabState = {
|
|
330
|
+
status: CollabStatus;
|
|
331
|
+
/** The room's document id, once known. */
|
|
332
|
+
docId: string | null;
|
|
333
|
+
/** This person's role in the room, once joined. */
|
|
334
|
+
role: Role | null;
|
|
335
|
+
/** The room's save state, in a managed room (KitCollab 1.4, managed-collab.md section 3); absent otherwise. */
|
|
336
|
+
save?: SaveState | null;
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* A change of the document, and who made it: the person, the agent, or (`KitEmbed 1.8`, EM31) the
|
|
340
|
+
* page itself through `commands.run` with `origin: 'system'`, with the `originLabel` it gave
|
|
341
|
+
* (`host` when it gave none).
|
|
342
|
+
*/
|
|
343
|
+
export type DocumentChange = {
|
|
344
|
+
dirty: boolean;
|
|
345
|
+
revision: number;
|
|
346
|
+
title: string;
|
|
347
|
+
} & ({
|
|
348
|
+
by: 'person' | 'agent';
|
|
349
|
+
} | {
|
|
350
|
+
by: 'system';
|
|
351
|
+
originLabel: string;
|
|
352
|
+
});
|
|
353
|
+
/**
|
|
354
|
+
* `commands.run`'s options. `save: true` saves afterwards. `origin: 'system'` (`KitEmbed 1.8`,
|
|
355
|
+
* EM31) runs the command as the page's own change on the person's behalf (a sync feature writing
|
|
356
|
+
* into the open document), as Kit Process Protocol's `commands.execute` with origin `system` does on
|
|
357
|
+
* a closed one: no undo step in any history, and the editor says the app made it. `originLabel`
|
|
358
|
+
* names the page's feature (`emailsync`: 1 to 64 letters, digits, `.`, `_`, `-`; `host` when
|
|
359
|
+
* absent). Without `origin` the command runs as the agent's step.
|
|
360
|
+
*/
|
|
361
|
+
export type EmbedRunOptions = {
|
|
362
|
+
save?: boolean;
|
|
363
|
+
origin?: 'system';
|
|
364
|
+
originLabel?: string;
|
|
365
|
+
};
|
|
366
|
+
/** A person in the room, with their name and avatar from `identity.users` when it knows them. */
|
|
367
|
+
export type EmbedPresence = Presence & {
|
|
368
|
+
user?: EmbedUser;
|
|
369
|
+
};
|
|
370
|
+
/** One comment of a thread; `user` is its author as `identity.users` names them. */
|
|
371
|
+
export type EmbedComment = {
|
|
372
|
+
id: string;
|
|
373
|
+
author: string;
|
|
374
|
+
name?: string;
|
|
375
|
+
body: string;
|
|
376
|
+
created: string;
|
|
377
|
+
user?: EmbedUser;
|
|
378
|
+
};
|
|
379
|
+
/** A comment thread of the document (KitModel rule M23). */
|
|
380
|
+
export type EmbedCommentThread = {
|
|
381
|
+
id: string;
|
|
382
|
+
anchor: CommentAnchor | null;
|
|
383
|
+
resolved: boolean;
|
|
384
|
+
comments: EmbedComment[];
|
|
385
|
+
};
|
|
386
|
+
/** The document's leases now, and which were taken and given up since the last report. */
|
|
387
|
+
export type EmbedLeases = {
|
|
388
|
+
leases: KitLease[];
|
|
389
|
+
held: KitLease[];
|
|
390
|
+
released: KitLease[];
|
|
391
|
+
};
|
|
392
|
+
/** One of the page's own buttons (`ui.add`) was pressed in the kit (Kit UI protocol `ui/action`). */
|
|
393
|
+
export type EmbedAction = {
|
|
394
|
+
id: string;
|
|
395
|
+
document: {
|
|
396
|
+
path: string;
|
|
397
|
+
dirty: boolean;
|
|
398
|
+
revision: number;
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
export type EmbedEvents = {
|
|
402
|
+
/** The document was written to the storage. */
|
|
403
|
+
saved: {
|
|
404
|
+
version: string;
|
|
405
|
+
};
|
|
406
|
+
/** The document changed (an edit, an undo, a save). */
|
|
407
|
+
changed: DocumentChange;
|
|
408
|
+
/** Something failed after the editor opened (a collaboration step, the kit reopening). */
|
|
409
|
+
error: Error;
|
|
410
|
+
collab: CollabState;
|
|
411
|
+
/** The people in the room, this person included. */
|
|
412
|
+
presence: EmbedPresence[];
|
|
413
|
+
/** A save was refused because the file changed elsewhere since it was read (nothing was overwritten). */
|
|
414
|
+
conflict: EmbedConflictError;
|
|
415
|
+
/** A message the kit asks the page to show (Kit UI protocol `host/notify`). */
|
|
416
|
+
notify: EmbedNotice;
|
|
417
|
+
/**
|
|
418
|
+
* The document's unresolved conflict objects (Kit UI protocol `document/conflicts`): merges the
|
|
419
|
+
* kit could not resolve by itself, kept in the document until someone resolves them.
|
|
420
|
+
*/
|
|
421
|
+
mergeConflicts: KitConflict[];
|
|
422
|
+
/**
|
|
423
|
+
* A newer version of the kit edited the document (Kit UI protocol `document/schema`, KitModel
|
|
424
|
+
* rule M5a): `reads` is the schema version this kit reads, `newestAuthor` the newer
|
|
425
|
+
* one. The editor keeps working; tell the person and offer the newer kit.
|
|
426
|
+
*/
|
|
427
|
+
newerKit: KitSchemaReport;
|
|
428
|
+
/**
|
|
429
|
+
* The document's comment threads, oldest first, whenever they change (`KitEmbed 1.1`), first
|
|
430
|
+
* when a listener is added. Heard only from an editor that keeps a replica (`model`,
|
|
431
|
+
* `storage.replica`, or collaboration) of a kit that keeps comments.
|
|
432
|
+
*/
|
|
433
|
+
comments: EmbedCommentThread[];
|
|
434
|
+
/** The room's leases changed: someone took or gave up a scope (`KitEmbed 1.1`, co-editing only). */
|
|
435
|
+
leases: EmbedLeases;
|
|
436
|
+
/** The agent's draft opened, changed, became ready, or closed (`KitEmbed 1.1`, Kit UI protocol `draft/changed`); review it with `editor.draft` (`KitEmbed 1.3`). */
|
|
437
|
+
draft: DraftInfo;
|
|
438
|
+
/** One of the page's own buttons (`ui.add`) was pressed (`KitEmbed 1.1`). */
|
|
439
|
+
action: EmbedAction;
|
|
440
|
+
/** The person changed what they hide (`KitEmbed 1.1`, with `ui.customize`). */
|
|
441
|
+
customize: {
|
|
442
|
+
hide: string[];
|
|
443
|
+
};
|
|
444
|
+
/** One of the page's shortcuts (`EmbedOptions.shortcuts`) was pressed in the kit (`KitEmbed 1.6`). */
|
|
445
|
+
shortcut: EmbedShortcut;
|
|
446
|
+
};
|
|
447
|
+
/** The agent's draft as the page reviews it (`editor.draft`, `KitEmbed 1.3`). */
|
|
448
|
+
export type EmbedDraft = {
|
|
449
|
+
/** `none`, `open` (the agent works on it), or `ready` (the agent asked for review). */
|
|
450
|
+
state: () => Promise<DraftInfo>;
|
|
451
|
+
/** What merging would change (`summary`), and both sides rendered (`before`, `after`: base64 PNGs or `null`). */
|
|
452
|
+
compare: (options?: {
|
|
453
|
+
maxSize?: number;
|
|
454
|
+
}) => Promise<DraftComparison>;
|
|
455
|
+
/** Takes the draft into the document as one undo step of the agent's (`origin`), then closes it. */
|
|
456
|
+
merge: (options?: {
|
|
457
|
+
label?: string;
|
|
458
|
+
}) => Promise<{
|
|
459
|
+
merged: boolean;
|
|
460
|
+
summary: DraftSummary;
|
|
461
|
+
}>;
|
|
462
|
+
/** Closes the draft and leaves the document as it is. */
|
|
463
|
+
discard: () => Promise<DraftInfo>;
|
|
464
|
+
};
|
|
465
|
+
export type EmbedNotice = {
|
|
466
|
+
level: 'info' | 'success' | 'warning' | 'error';
|
|
467
|
+
message: string;
|
|
468
|
+
description?: string;
|
|
469
|
+
};
|
|
470
|
+
/** The `ModelPort` of `@kition/sdk/script`, given by an editor without depending on it. */
|
|
471
|
+
export type EmbedModelPort = {
|
|
472
|
+
readonly kitId: string;
|
|
473
|
+
exportChanges: (since: Uint8Array) => Promise<Uint8Array>;
|
|
474
|
+
importChanges: (changes: Uint8Array) => Promise<void>;
|
|
475
|
+
command: (id: string, params: unknown) => Promise<unknown>;
|
|
476
|
+
commands: () => Promise<EmbedCommand[]>;
|
|
477
|
+
readOnly: () => boolean;
|
|
478
|
+
onChanged: (listener: (version: Uint8Array | null) => void) => () => void;
|
|
479
|
+
/** The editor's events `@kition/sdk/script` reports on its documents: `saved`, `conflict`, and `presence` when it co-edits. */
|
|
480
|
+
events: ReadonlyArray<'saved' | 'presence' | 'conflict'>;
|
|
481
|
+
on: (event: 'saved' | 'presence' | 'conflict' | 'selection', listener: (value: never) => void) => () => void;
|
|
482
|
+
/**
|
|
483
|
+
* The object model answered by the kit itself, when its editor lists the `model` capability:
|
|
484
|
+
* each batch is then one undo step of the person's history. A refused batch rejects with an
|
|
485
|
+
* error whose `data` is `{ code, index, message }`.
|
|
486
|
+
*/
|
|
487
|
+
model?: {
|
|
488
|
+
describe: (schema: object) => Promise<Record<string, unknown>>;
|
|
489
|
+
batch: (request: {
|
|
490
|
+
origin?: unknown;
|
|
491
|
+
ops?: Array<Record<string, unknown>>;
|
|
492
|
+
load?: Array<Record<string, unknown>>;
|
|
493
|
+
}, schema: object) => Promise<{
|
|
494
|
+
refs: Record<string, string>;
|
|
495
|
+
results: unknown[];
|
|
496
|
+
loaded: Array<{
|
|
497
|
+
id: string;
|
|
498
|
+
type: string;
|
|
499
|
+
fields: Record<string, unknown>;
|
|
500
|
+
}>;
|
|
501
|
+
version: Uint8Array | null;
|
|
502
|
+
}>;
|
|
503
|
+
};
|
|
504
|
+
};
|
|
505
|
+
export type EmbedCommand = {
|
|
506
|
+
id: string;
|
|
507
|
+
title: string;
|
|
508
|
+
description?: string;
|
|
509
|
+
enabled: boolean;
|
|
510
|
+
schema?: unknown;
|
|
511
|
+
};
|
|
512
|
+
/** A kit's object-model typings as `@kition/sdk/script/kits/<kit>` exports them (`noteKit`): its id and schema. */
|
|
513
|
+
export type EmbedKitTypings = {
|
|
514
|
+
id: string;
|
|
515
|
+
schema: object;
|
|
516
|
+
};
|
|
517
|
+
export type EmbedEditor = {
|
|
518
|
+
/** Resolves when the kit has rendered the document; rejects when it could not open it. */
|
|
519
|
+
ready: () => Promise<void>;
|
|
520
|
+
/** Saves as the kit's own Save does; `saved` is false when there was nothing to write. */
|
|
521
|
+
save: () => Promise<{
|
|
522
|
+
saved: boolean;
|
|
523
|
+
version: string | null;
|
|
524
|
+
}>;
|
|
525
|
+
on: <E extends keyof EmbedEvents>(event: E, listener: (value: EmbedEvents[E]) => void) => () => void;
|
|
526
|
+
setTheme: (theme: EmbedTheme) => void;
|
|
527
|
+
setLocale: (locale: string) => void;
|
|
528
|
+
collab: {
|
|
529
|
+
readonly state: CollabState;
|
|
530
|
+
/** A link to the room granting `role`, to hand to someone else. */
|
|
531
|
+
shareLink: (role?: 'editor' | 'viewer') => Promise<string>;
|
|
532
|
+
};
|
|
533
|
+
/** The kit's commands (its Kit AI bridge), until the document object model arrives. */
|
|
534
|
+
commands: {
|
|
535
|
+
list: (query?: string) => Promise<EmbedCommand[]>;
|
|
536
|
+
run: (id: string, params?: Record<string, unknown>, options?: EmbedRunOptions) => Promise<AiRunResult['completed'][number]>;
|
|
537
|
+
};
|
|
538
|
+
/**
|
|
539
|
+
* The document's replica version (its KDM version's bytes), or `null` when the kit keeps no
|
|
540
|
+
* replica (a single-user editor without `storage.replica`). Two editors co-editing a document
|
|
541
|
+
* hold the same changes when their versions name the same changes.
|
|
542
|
+
*/
|
|
543
|
+
replicaVersion: () => Promise<Uint8Array | null>;
|
|
544
|
+
/**
|
|
545
|
+
* The document as the object model reaches it (`@kition/sdk/script`: `openDocument(editor)` calls
|
|
546
|
+
* this): its replica's changes and the kit's commands. Needs a replica (`model`, `storage.replica`,
|
|
547
|
+
* or collaboration).
|
|
548
|
+
*/
|
|
549
|
+
modelPort: () => EmbedModelPort;
|
|
550
|
+
/**
|
|
551
|
+
* The document as `@kition/sdk/script`'s object model (`KitEmbed 1.1`): `openDocument` over
|
|
552
|
+
* `modelPort()` in one call, with the object model bundled in this package. `kit` is the kit's
|
|
553
|
+
* typings (`noteKit` of `@kition/sdk/script/kits/note`, whose root type is `Note`); they must be this
|
|
554
|
+
* editor's kit's. Needs a replica, as `modelPort` does.
|
|
555
|
+
*/
|
|
556
|
+
document: <Root extends ModelObject = ModelObject, C extends CommandMap = CommandMap>(kit: EmbedKitTypings, options?: {
|
|
557
|
+
origin?: Origin;
|
|
558
|
+
}) => Promise<ModelDocument<Root, C>>;
|
|
559
|
+
/** Replaces the `ui` option: what the kit's editor shows and allows (`KitEmbed 1.1`). */
|
|
560
|
+
configure: (ui: EmbedUi) => void;
|
|
561
|
+
/** What the person may do now: the stricter of the options, the identity, and the room's role (`KitEmbed 1.1`). */
|
|
562
|
+
readonly mode: PermissionMode;
|
|
563
|
+
/**
|
|
564
|
+
* The kit's diagnostics on the open document (`KitEmbed 1.2`, KHP A21 and A22, KitAgent A23, `document/check`), errors
|
|
565
|
+
* first; none from a kit that does not check.
|
|
566
|
+
*/
|
|
567
|
+
check: (options?: {
|
|
568
|
+
draft?: boolean;
|
|
569
|
+
}) => Promise<KitDiagnostic[]>;
|
|
570
|
+
/**
|
|
571
|
+
* The agent's draft of the document (`KitEmbed 1.3`, Kit UI protocol section 7d), for the
|
|
572
|
+
* person to review: the page shows `compare()` and calls `merge()` or `discard()` only on the
|
|
573
|
+
* person's explicit action (a Merge or Discard button), never from an agent's or a model's
|
|
574
|
+
* output (UI-D1). A kit without drafts answers `state: 'none'` and refuses the rest
|
|
575
|
+
* (`EmbedError` `unsupported`); a person who may not edit cannot merge or discard (`read-only`).
|
|
576
|
+
*/
|
|
577
|
+
draft: EmbedDraft;
|
|
578
|
+
/**
|
|
579
|
+
* The open document as an MCP server for the integrator's agent (`KitEmbed 1.3`): the kit tools
|
|
580
|
+
* of `kition-kits-mcp` (`<prefix>_inspect`, `_run`, `_check`, …) on this editor. The page
|
|
581
|
+
* relays its messages to its server (`relayAgentPort`). The agent's edits go to a draft unless
|
|
582
|
+
* `options.draft` is `false`; it can ask for review but never merge.
|
|
583
|
+
*/
|
|
584
|
+
agentPort: (options?: AgentPortOptions) => AgentPort;
|
|
585
|
+
/**
|
|
586
|
+
* Comment threads the page keeps (`KitEmbed 1.7`, EM30), with the `comments` option: `show` gives
|
|
587
|
+
* the kit the whole list to mark (sent again to a kit opened again); `locate` answers whether the
|
|
588
|
+
* kit finds each anchor now (all `false` from a kit without `comment-anchors`).
|
|
589
|
+
*/
|
|
590
|
+
comments: {
|
|
591
|
+
show: (threads: EmbedShownThread[]) => void;
|
|
592
|
+
locate: (anchors: EmbedCommentAnchor[]) => Promise<boolean[]>;
|
|
593
|
+
};
|
|
594
|
+
/** Closes the editor and removes its frame; unsaved edits are dropped. */
|
|
595
|
+
destroy: () => void;
|
|
596
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page's `ui` option as the Kit UI protocol's UI configuration (section 9), what a person may
|
|
3
|
+
* do as one mode, and the people the page names (`KitEmbed 1.1`).
|
|
4
|
+
*/
|
|
5
|
+
import type { KitUiConfig, KitUiElement } from '../../kit-ui-protocol/src/index.js';
|
|
6
|
+
import type { EmbedComment, EmbedCommentThread, EmbedPresence, EmbedUi, EmbedUser, IdentityProvider, PermissionMode, Presence } from './types.js';
|
|
7
|
+
/** The stricter of the modes given; `edit` when none is. */
|
|
8
|
+
export declare function strictestMode(...modes: Array<PermissionMode | null | undefined>): PermissionMode;
|
|
9
|
+
/**
|
|
10
|
+
* The configuration the kit is sent: the protocol's members of `ui` as they are, `toolbar: 'none'`
|
|
11
|
+
* as hidden ribbon tabs, the panels `panels` leaves out (once the kit has listed its elements),
|
|
12
|
+
* and the person's own hides (`personal`, the latest `host/customize`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function kitUiConfig(ui: EmbedUi | undefined, elements: KitUiElement[] | null, personal: {
|
|
15
|
+
hide?: string[];
|
|
16
|
+
} | null): KitUiConfig | undefined;
|
|
17
|
+
/** Names people by id through `identity.users`, asking for each id once. */
|
|
18
|
+
export declare class People {
|
|
19
|
+
private readonly identity;
|
|
20
|
+
private readonly known;
|
|
21
|
+
constructor(identity: IdentityProvider | undefined);
|
|
22
|
+
get serves(): boolean;
|
|
23
|
+
/** The people `identity.users` knows among `ids`. */
|
|
24
|
+
lookup(ids: string[]): Promise<Map<string, EmbedUser>>;
|
|
25
|
+
/** The room's peers with the page's names and avatars for them: by the user their presence names, else their principal. */
|
|
26
|
+
presence(peers: Presence[]): Promise<EmbedPresence[]>;
|
|
27
|
+
/** The threads with each comment's author as the page names them. */
|
|
28
|
+
threads(threads: Array<Omit<EmbedCommentThread, 'comments'> & {
|
|
29
|
+
comments: EmbedComment[];
|
|
30
|
+
}>): Promise<EmbedCommentThread[]>;
|
|
31
|
+
}
|
|
32
|
+
/** Peers with `user`: as `users` names them, else as their own presence does. */
|
|
33
|
+
export declare function namePeers(peers: Presence[], users: Map<string, EmbedUser>): EmbedPresence[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const SIGNATURE_HEADER = "x-kition-signature";
|
|
2
|
+
export declare const TIMESTAMP_HEADER = "x-kition-timestamp";
|
|
3
|
+
export declare const SUBJECT_HEADER = "x-kition-subject";
|
|
4
|
+
export declare const DOC_KEY_HEADER = "x-kition-doc-key";
|
|
5
|
+
export declare const VERSION_HEADER = "x-kition-version";
|
|
6
|
+
export declare const NAME_HEADER = "x-kition-name";
|
|
7
|
+
/** How far a callback's timestamp may be from the verifier's clock, seconds. */
|
|
8
|
+
export declare const CALLBACK_SKEW_SECS = 300;
|
|
9
|
+
/** The signature of one callback. */
|
|
10
|
+
export declare function signCallback(secret: string, method: string, path: string, timestamp: number, body?: Uint8Array | null): string;
|
|
11
|
+
/** The headers a callback carries: its signature, timestamp, the person, and the file generation. */
|
|
12
|
+
export declare function callbackHeaders(secret: string, method: string, path: string, body: Uint8Array | null, who: {
|
|
13
|
+
subject: string;
|
|
14
|
+
docKey: string;
|
|
15
|
+
}, now?: number): {
|
|
16
|
+
"x-kition-timestamp": string;
|
|
17
|
+
"x-kition-signature": string;
|
|
18
|
+
"x-kition-subject": string;
|
|
19
|
+
"x-kition-doc-key": string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Whether a request the integrator received is the embed server's: its signature matches and
|
|
23
|
+
* its timestamp is within `CALLBACK_SKEW_SECS` of `now`. `headers` are lower-cased names.
|
|
24
|
+
*/
|
|
25
|
+
export declare function verifyCallback(secret: string, request: {
|
|
26
|
+
method: string;
|
|
27
|
+
path: string;
|
|
28
|
+
headers: Record<string, string | string[] | undefined>;
|
|
29
|
+
body?: Uint8Array | null;
|
|
30
|
+
}, now?: number): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|