@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,89 @@
|
|
|
1
|
+
import type { BatchRequest, BatchResult, Origin, ProjectedObject } from '../../kdm/src/index.js';
|
|
2
|
+
/** One kit command as a kit's catalogue lists it. */
|
|
3
|
+
export type KitCommandInfo = {
|
|
4
|
+
id: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
menu?: string[] | null;
|
|
7
|
+
shortcut?: string | null;
|
|
8
|
+
params?: string | null;
|
|
9
|
+
/** What the command does, when to choose it, and what it changes or answers (KitCommand::description). */
|
|
10
|
+
description?: string;
|
|
11
|
+
schema?: unknown;
|
|
12
|
+
/** What the command answers, as one `ValueSchemaSpec` (KHP A1 `output.schema`). */
|
|
13
|
+
outputSchema?: unknown;
|
|
14
|
+
mutates?: boolean;
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** The document was written to its file or storage: the storage's new version, or the file it went to. */
|
|
18
|
+
export type SavedEvent = {
|
|
19
|
+
version: string | null;
|
|
20
|
+
uri?: string;
|
|
21
|
+
};
|
|
22
|
+
/** The people in the document's collaboration room, this person included, as the host knows them. */
|
|
23
|
+
export type PresenceEvent = {
|
|
24
|
+
peers: ReadonlyArray<Record<string, unknown>>;
|
|
25
|
+
};
|
|
26
|
+
/** A save was refused because the file changed elsewhere since it was read: nothing was overwritten. */
|
|
27
|
+
export type ConflictEvent = {
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
/** The objects the person selected in the kit's editor, as KDM object ids. */
|
|
31
|
+
export type SelectionEvent = {
|
|
32
|
+
ids: string[];
|
|
33
|
+
};
|
|
34
|
+
/** The document events a source reports besides `changed`, and what each carries. */
|
|
35
|
+
export type DocumentEvents = {
|
|
36
|
+
saved: SavedEvent;
|
|
37
|
+
presence: PresenceEvent;
|
|
38
|
+
conflict: ConflictEvent;
|
|
39
|
+
selection: SelectionEvent;
|
|
40
|
+
};
|
|
41
|
+
export type DocumentEventName = keyof DocumentEvents;
|
|
42
|
+
/** The events a source reports: which (`events`), and how to hear one (`on`). */
|
|
43
|
+
export interface DocumentEventSource {
|
|
44
|
+
/** The events of `DocumentEvents` this source reports; any other is never heard. */
|
|
45
|
+
readonly events?: readonly DocumentEventName[];
|
|
46
|
+
/** Hears one of `events`; answers an unsubscribe. */
|
|
47
|
+
on?<E extends DocumentEventName>(event: E, listener: (value: DocumentEvents[E]) => void): () => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A contract 2 document as the object model reaches it: the engine's change exchange and its
|
|
51
|
+
* commands. Every kit editor (`KitConnection` with the `replica` capability), every kit engine
|
|
52
|
+
* (`exportChanges`, `importChanges`, `executeAs`), and an `@kition/sdk/embed` editor give one.
|
|
53
|
+
*/
|
|
54
|
+
export interface ModelPort extends DocumentEventSource {
|
|
55
|
+
readonly kitId: string;
|
|
56
|
+
/** The engine's changes since the encoded version `since`; empty bytes ask for every change. */
|
|
57
|
+
exportChanges(since: Uint8Array): Promise<Uint8Array>;
|
|
58
|
+
/** Hands the engine changes made elsewhere; it takes them as a collaborator's. */
|
|
59
|
+
importChanges(changes: Uint8Array): Promise<void>;
|
|
60
|
+
/** Runs a command; answers its result. */
|
|
61
|
+
command(id: string, params: unknown, origin: Origin): Promise<unknown>;
|
|
62
|
+
commands(): Promise<KitCommandInfo[]>;
|
|
63
|
+
/** Whether the document refuses edits. */
|
|
64
|
+
readOnly?(): boolean;
|
|
65
|
+
/** Hears the engine's replica move (its version when known). */
|
|
66
|
+
onChanged?(listener: (version: Uint8Array | null) => void): () => void;
|
|
67
|
+
/**
|
|
68
|
+
* The objects the kit derives from the document instead of storing them (schema types marked
|
|
69
|
+
* `projected`), as the kit reads them now. A batch on a schema that declares such types needs it.
|
|
70
|
+
*/
|
|
71
|
+
projectedObjects?(): Promise<ProjectedObject[]>;
|
|
72
|
+
/**
|
|
73
|
+
* The object model answered by the kit itself (the Kit UI capability `model`), when it does: a
|
|
74
|
+
* batch is then one undo step of the person's history. `openDocument` prefers it to running
|
|
75
|
+
* the batch on its own replica.
|
|
76
|
+
*/
|
|
77
|
+
model?: KitModel;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A kit's own `model/describe` and `model/batch`. `schema` is the kit's KDM schema, for a kit
|
|
81
|
+
* whose engine does not describe its own. A refused batch rejects with a `BatchError`.
|
|
82
|
+
*/
|
|
83
|
+
export interface KitModel {
|
|
84
|
+
describe(schema: object): Promise<Record<string, unknown>>;
|
|
85
|
+
/** `version` is the kit's replica version after the batch, when it has one. */
|
|
86
|
+
batch(request: BatchRequest, schema: object): Promise<BatchResult & {
|
|
87
|
+
version?: Uint8Array | null;
|
|
88
|
+
}>;
|
|
89
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxies and `sync()` (Office.js's request context): property writes and commands are queued as
|
|
3
|
+
* operations, reads are queued with `load`, and `sync()` sends them as one `model/batch`.
|
|
4
|
+
*/
|
|
5
|
+
import type { BatchRequest, BatchResult, Origin, Schema } from '../../kdm/src/index.js';
|
|
6
|
+
/** Reading a property that no `load` + `sync()` has fetched. */
|
|
7
|
+
export declare class PropertyNotLoadedError extends Error {
|
|
8
|
+
constructor(type: string, field: string);
|
|
9
|
+
}
|
|
10
|
+
/** Reading what only exists after the next `sync()` (a new object's id, a command's result). */
|
|
11
|
+
export declare class NotSyncedError extends Error {
|
|
12
|
+
constructor(what: string);
|
|
13
|
+
}
|
|
14
|
+
/** Every object proxy has these members besides its fields. */
|
|
15
|
+
export interface ModelObject {
|
|
16
|
+
/** The object's id; for an object created in this batch, known after `sync()`. */
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly type: string;
|
|
19
|
+
/** Queues a read of `fields` (all fields when omitted) for the next `sync()`. */
|
|
20
|
+
load(fields?: string[]): this;
|
|
21
|
+
/** Queues the object's deletion; it also leaves every list that holds it. */
|
|
22
|
+
delete(): void;
|
|
23
|
+
/** Whether `field` has been loaded. */
|
|
24
|
+
isLoaded(field: string): boolean;
|
|
25
|
+
/** The loaded fields as plain JSON. */
|
|
26
|
+
toJSON(): Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
/** A list field: an ordered collection of objects of one type. */
|
|
29
|
+
export interface ModelList<T extends ModelObject = ModelObject, F = Record<string, unknown>> {
|
|
30
|
+
/** Queues a new object at the end (or `at`); answers its proxy. */
|
|
31
|
+
add(fields?: F, options?: {
|
|
32
|
+
at?: number;
|
|
33
|
+
}): T;
|
|
34
|
+
/** Queues inserting an existing object. */
|
|
35
|
+
insert(index: number, item: T | string): void;
|
|
36
|
+
move(from: number, to: number): void;
|
|
37
|
+
remove(index: number): void;
|
|
38
|
+
/** Queues a read of the list. */
|
|
39
|
+
load(): this;
|
|
40
|
+
/** The items after `load()` + `sync()`. */
|
|
41
|
+
readonly items: T[];
|
|
42
|
+
readonly length: number;
|
|
43
|
+
at(index: number): T;
|
|
44
|
+
}
|
|
45
|
+
/** A node of a loaded tree field: an object and its parent (`null`: a root), in pre-order. */
|
|
46
|
+
export interface ModelTreeNode<T extends ModelObject = ModelObject> {
|
|
47
|
+
readonly object: T;
|
|
48
|
+
readonly parent: T | null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A tree field: objects of one type in a hierarchy, each node naming one object. A new node is
|
|
52
|
+
* the last child of its parent; deleting an object (`delete()`) leaves the tree with it, and is
|
|
53
|
+
* refused while it has children there.
|
|
54
|
+
*/
|
|
55
|
+
export interface ModelTree<T extends ModelObject = ModelObject, F = Record<string, unknown>> {
|
|
56
|
+
/** Queues a new object as the last child of `parent` (a root when omitted); answers its proxy. */
|
|
57
|
+
add(fields?: F, options?: {
|
|
58
|
+
parent?: T | string | null;
|
|
59
|
+
}): T;
|
|
60
|
+
/** Queues adding an existing object that is not in the tree yet. */
|
|
61
|
+
insert(item: T | string, options?: {
|
|
62
|
+
parent?: T | string | null;
|
|
63
|
+
}): void;
|
|
64
|
+
/** Queues moving an object, with its subtree, to be the last child of `parent` (`null`: a root). */
|
|
65
|
+
move(item: T | string, parent: T | string | null): void;
|
|
66
|
+
/** Queues a read of the tree. */
|
|
67
|
+
load(): this;
|
|
68
|
+
/** The nodes after `load()` + `sync()`, in pre-order (each parent before its children). */
|
|
69
|
+
readonly nodes: Array<ModelTreeNode<T>>;
|
|
70
|
+
/** The children of `parent` (the roots when omitted), after `load()` + `sync()`. */
|
|
71
|
+
children(parent?: T | string | null): T[];
|
|
72
|
+
}
|
|
73
|
+
/** A text field. Positions count Unicode scalar values. */
|
|
74
|
+
export interface ModelText {
|
|
75
|
+
insert(index: number, text: string): void;
|
|
76
|
+
delete(index: number, count: number): void;
|
|
77
|
+
set(text: string): void;
|
|
78
|
+
mark(start: number, end: number, key: string, value: unknown): void;
|
|
79
|
+
unmark(start: number, end: number, key: string): void;
|
|
80
|
+
load(): this;
|
|
81
|
+
/** The text after `load()` + `sync()`: a string, or its runs when the field has marks. */
|
|
82
|
+
readonly value: string | Array<{
|
|
83
|
+
insert: string;
|
|
84
|
+
attributes?: Record<string, unknown>;
|
|
85
|
+
}>;
|
|
86
|
+
toString(): string;
|
|
87
|
+
}
|
|
88
|
+
/** A map field: string keys to JSON values. */
|
|
89
|
+
export interface ModelMap<V = unknown> {
|
|
90
|
+
set(key: string, value: V): void;
|
|
91
|
+
delete(key: string): void;
|
|
92
|
+
load(): this;
|
|
93
|
+
get(key: string): V | undefined;
|
|
94
|
+
readonly value: Record<string, V>;
|
|
95
|
+
}
|
|
96
|
+
/** A queued command's result, after `sync()`. */
|
|
97
|
+
export interface CommandResult<T = unknown> {
|
|
98
|
+
readonly value: T;
|
|
99
|
+
}
|
|
100
|
+
export type CommandMap = Record<string, unknown>;
|
|
101
|
+
/** The request context of `ModelDocument.run`: queue reads and writes, then `sync()`. */
|
|
102
|
+
export declare class RequestContext<Root extends ModelObject = ModelObject, C extends CommandMap = CommandMap> {
|
|
103
|
+
private readonly schema;
|
|
104
|
+
private readonly send;
|
|
105
|
+
private readonly origin?;
|
|
106
|
+
private ops;
|
|
107
|
+
private loads;
|
|
108
|
+
private created;
|
|
109
|
+
private pending;
|
|
110
|
+
private proxies;
|
|
111
|
+
private refs;
|
|
112
|
+
/** The document's root object. */
|
|
113
|
+
readonly root: Root;
|
|
114
|
+
readonly commands: {
|
|
115
|
+
/** Queues a command; its result is read after `sync()`. */
|
|
116
|
+
run: <K extends keyof C & string>(id: K, params?: C[K]) => CommandResult;
|
|
117
|
+
};
|
|
118
|
+
constructor(schema: Schema, send: (request: BatchRequest) => Promise<BatchResult>, origin?: Origin | undefined);
|
|
119
|
+
/** A proxy of an existing object of type `type`. */
|
|
120
|
+
object<T extends ModelObject = ModelObject>(id: string, type: string): T;
|
|
121
|
+
/** Whether operations or reads wait for `sync()`. */
|
|
122
|
+
get queued(): boolean;
|
|
123
|
+
/** Sends the queued operations and reads as one batch, then fills the loaded proxies. */
|
|
124
|
+
sync(): Promise<void>;
|
|
125
|
+
private fill;
|
|
126
|
+
private byState;
|
|
127
|
+
private proxyOf;
|
|
128
|
+
private push;
|
|
129
|
+
private field;
|
|
130
|
+
private proxy;
|
|
131
|
+
private container;
|
|
132
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The object model over the sync protocol (`kition-sync/1`, Kition platform docs/platform/reference/sync-protocol.md): a document in
|
|
3
|
+
* a server room, with no kit and no page. `openRoom` joins the room with a `SyncClient`, keeps a
|
|
4
|
+
* KDM replica of it here (from the room's snapshot and changes), and runs each batch on that
|
|
5
|
+
* replica: a run of model operations becomes one change, which the room must take (`changes/push`)
|
|
6
|
+
* before the replica keeps it. Changes other members push come in as `changes/pull` and fire
|
|
7
|
+
* `changed`.
|
|
8
|
+
*
|
|
9
|
+
* Commands need the kit's engine. A server that runs kits headless (it lists `headless`, protocol
|
|
10
|
+
* 1.7) runs each `command` operation as `agent/run`, and the batch goes on once the change the
|
|
11
|
+
* command made has arrived; any other server refuses commands (`command-failed`).
|
|
12
|
+
*
|
|
13
|
+
* The room's role decides what a batch may do: a `viewer`'s batches only read (`read-only`), a
|
|
14
|
+
* `commenter`'s may change only `CommentThread` and `Comment` objects (rule M23), refused here
|
|
15
|
+
* before they reach the server.
|
|
16
|
+
*/
|
|
17
|
+
import { type BatchRequest, type BatchResult, type Origin, type Schema } from '../../kdm/src/index.js';
|
|
18
|
+
import { SyncClient, type ClientInfo, type HelloResult, type Presence, type Principal, type Role, type SyncTransport, type TransportFactory } from '../../sync/src/index.js';
|
|
19
|
+
import { ModelDocument, type ModelBackend } from './document.js';
|
|
20
|
+
import type { ModelDescription } from './exchange.js';
|
|
21
|
+
import type { DocumentEventSource, KitCommandInfo } from './port.js';
|
|
22
|
+
import type { CommandMap, ModelObject } from './proxy.js';
|
|
23
|
+
export type RoomOptions = {
|
|
24
|
+
/**
|
|
25
|
+
* The sync server: its WebSocket endpoint (`wss://sync.kition.ai/v1/sync`), or its `http(s)://`
|
|
26
|
+
* address, whose root stands for `/v1/sync` (Kition Server's endpoint).
|
|
27
|
+
*/
|
|
28
|
+
server: string;
|
|
29
|
+
/** The person's token for `sync/hello`. */
|
|
30
|
+
token?: string;
|
|
31
|
+
/** Answers a token on every connection attempt (reconnects too), for a short-lived token. */
|
|
32
|
+
tokenProvider?: () => string | Promise<string>;
|
|
33
|
+
/** The room's document id, for a room this person is already a member of. */
|
|
34
|
+
docId?: string;
|
|
35
|
+
/** A share link to the room (`room/open`); it names the room's kit too. */
|
|
36
|
+
shareLink?: string;
|
|
37
|
+
/** The room's kit id; required with `docId`, checked against the room's with `shareLink`. */
|
|
38
|
+
kit?: string;
|
|
39
|
+
/** The kit's schema; by default the one registered for the kit's id (`registerKit`, `@kition/sdk/script/kits`). */
|
|
40
|
+
schema?: Schema | object;
|
|
41
|
+
/** The origin every batch carries; `extension`/`script` by default. */
|
|
42
|
+
origin?: Origin;
|
|
43
|
+
/** Who this client is in `sync/hello`. */
|
|
44
|
+
client?: ClientInfo;
|
|
45
|
+
/** The connection; by default the global `WebSocket` (a page, Node 22 and later). */
|
|
46
|
+
createTransport?: TransportFactory;
|
|
47
|
+
/** How long a command waits for the change the server's agent made (milliseconds; 30 000). */
|
|
48
|
+
commandTimeout?: number;
|
|
49
|
+
/** Hears what goes wrong outside a batch (a change from the room that does not import); `console.error` by default. */
|
|
50
|
+
onError?: (error: unknown) => void;
|
|
51
|
+
};
|
|
52
|
+
/** A WebSocket as a `SyncTransport` (binary frames as `ArrayBuffer`s). */
|
|
53
|
+
export declare function webSocketTransport(url: string): SyncTransport;
|
|
54
|
+
/** The WebSocket endpoint for `server`: a `ws(s)://` URL as it is, an `http(s)://` one with `/v1/sync` for an empty path. */
|
|
55
|
+
export declare function syncEndpoint(server: string): string;
|
|
56
|
+
/** The live state of one joined room, and the object model's backend over it. */
|
|
57
|
+
declare class Room implements ModelBackend, DocumentEventSource {
|
|
58
|
+
readonly sync: SyncClient;
|
|
59
|
+
readonly docId: string;
|
|
60
|
+
readonly kitId: string;
|
|
61
|
+
private readonly hello;
|
|
62
|
+
private readonly options;
|
|
63
|
+
readonly events: readonly ["presence"];
|
|
64
|
+
readonly schema: Schema;
|
|
65
|
+
private replica;
|
|
66
|
+
private early;
|
|
67
|
+
private readonly actor;
|
|
68
|
+
private queue;
|
|
69
|
+
private listeners;
|
|
70
|
+
private roleListeners;
|
|
71
|
+
private waiters;
|
|
72
|
+
private unsubscribes;
|
|
73
|
+
/** The highest room `seq` this replica has every change up to. */
|
|
74
|
+
private seen;
|
|
75
|
+
/** The replica's version after this handle's last batch. */
|
|
76
|
+
private own;
|
|
77
|
+
role: Role | null;
|
|
78
|
+
presence: Presence[];
|
|
79
|
+
/** Removed from the room by its owner (`room/access`): the handle reads what it has, and writes nothing. */
|
|
80
|
+
removed: boolean;
|
|
81
|
+
/** Left the room (`close`). */
|
|
82
|
+
left: boolean;
|
|
83
|
+
constructor(sync: SyncClient, docId: string, kitId: string, schema: Schema | object, hello: HelloResult, options: RoomOptions);
|
|
84
|
+
/** Joins the room and loads its document. */
|
|
85
|
+
join(): Promise<void>;
|
|
86
|
+
private receive;
|
|
87
|
+
private reach;
|
|
88
|
+
/** Settles once this replica holds the room's change `seq`. */
|
|
89
|
+
private arrived;
|
|
90
|
+
private loaded;
|
|
91
|
+
/** What the server lists in `sync/hello`: protocol features and capability sets. */
|
|
92
|
+
get capabilities(): readonly string[];
|
|
93
|
+
/** Whether the server runs the room's kit commands (`agent/run`). */
|
|
94
|
+
get runsCommands(): boolean;
|
|
95
|
+
private target;
|
|
96
|
+
private serial;
|
|
97
|
+
batch(request: BatchRequest): Promise<BatchResult>;
|
|
98
|
+
describe(): Promise<ModelDescription>;
|
|
99
|
+
/** The kit's catalogue does not travel over the sync protocol: a room lists no commands. */
|
|
100
|
+
commands(): Promise<KitCommandInfo[]>;
|
|
101
|
+
/** The document's version after this handle's last batch (`changed` from the room is told apart by it). */
|
|
102
|
+
version(): Uint8Array | null;
|
|
103
|
+
onChanged(listener: (version: Uint8Array | null) => void): () => void;
|
|
104
|
+
onRole(listener: (role: Role | null) => void): () => void;
|
|
105
|
+
on: NonNullable<DocumentEventSource['on']>;
|
|
106
|
+
/** The room's document as it stands here, as one snapshot. */
|
|
107
|
+
snapshot(): Uint8Array;
|
|
108
|
+
leave(): void;
|
|
109
|
+
}
|
|
110
|
+
/** A document in a server room, opened for scripting (`openRoom`). */
|
|
111
|
+
export declare class RoomDocument<Root extends ModelObject = ModelObject, C extends CommandMap = CommandMap> extends ModelDocument<Root, C> {
|
|
112
|
+
private readonly room;
|
|
113
|
+
private readonly ownsClient;
|
|
114
|
+
constructor(room: Room, origin: Origin | undefined, ownsClient: boolean);
|
|
115
|
+
/** The room's document id. */
|
|
116
|
+
get docId(): string;
|
|
117
|
+
/** This person's role in the room (`null` once removed from it). */
|
|
118
|
+
get role(): Role | null;
|
|
119
|
+
/** Who the server says this person is. */
|
|
120
|
+
get principal(): Principal | undefined;
|
|
121
|
+
/** The people in the room, as last heard. */
|
|
122
|
+
get peers(): readonly Presence[];
|
|
123
|
+
/** Whether the server runs kit commands for this room (`agent/run`); without, a `command` operation is refused. */
|
|
124
|
+
get runsCommands(): boolean;
|
|
125
|
+
/** What the server lists in `sync/hello` (test one with `supports(set, doc.capabilities)`). */
|
|
126
|
+
get capabilities(): readonly string[];
|
|
127
|
+
/** The sync client the room is joined with (presence, leases, previews, history). */
|
|
128
|
+
get sync(): SyncClient;
|
|
129
|
+
/** Hears this person's role change; `null`: they were removed, and the handle only reads what it has. */
|
|
130
|
+
onRole(listener: (role: Role | null) => void): () => void;
|
|
131
|
+
/** The room's document as this handle holds it, as a KDM snapshot. */
|
|
132
|
+
snapshot(): Uint8Array;
|
|
133
|
+
/** Leaves the room and, when `openRoom` made the connection, closes it. */
|
|
134
|
+
close(): void;
|
|
135
|
+
}
|
|
136
|
+
export type CreateRoomOptions = Pick<RoomOptions, 'server' | 'token' | 'tokenProvider' | 'schema' | 'client' | 'createTransport'> & {
|
|
137
|
+
/** The document's kit id. */
|
|
138
|
+
kit: string;
|
|
139
|
+
/** The room's name, as its members see it. */
|
|
140
|
+
name: string;
|
|
141
|
+
/**
|
|
142
|
+
* The document as a KDM snapshot or a full change export (a kit engine's `exportChanges` from
|
|
143
|
+
* nothing): a full document, or a copy made as a new document (`copyAsNewDocument`); a shallow
|
|
144
|
+
* replica truncated later is refused before anything reaches the server.
|
|
145
|
+
*/
|
|
146
|
+
document: Uint8Array;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Shares a document as a new room on a sync server (`room/create`, Kition Cloud: a Pro account):
|
|
150
|
+
* answers its `docId` and an editing share link. The person creating it is the room's owner.
|
|
151
|
+
*/
|
|
152
|
+
export declare function createRoom(options: CreateRoomOptions): Promise<{
|
|
153
|
+
docId: string;
|
|
154
|
+
shareLink: string;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Opens a document in a sync server's room for scripting: `{ server, token | tokenProvider,
|
|
158
|
+
* docId | shareLink, kit }`. Answers once the room is joined and its document loaded; `close()`
|
|
159
|
+
* leaves the room.
|
|
160
|
+
*/
|
|
161
|
+
export declare function openRoom<Root extends ModelObject = ModelObject, C extends CommandMap = CommandMap>(options: RoomOptions): Promise<RoomDocument<Root, C>>;
|
|
162
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { DocumentEventSource, ModelPort } from './port.js';
|
|
2
|
+
export declare function isModelPort(value: unknown): value is ModelPort;
|
|
3
|
+
/** The parts of a `KitConnection` (`@kition/sdk/host`) the object model uses. */
|
|
4
|
+
export type ConnectionLike = {
|
|
5
|
+
kit: {
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
capabilities: string[];
|
|
9
|
+
ai: {
|
|
10
|
+
commands: (query: string) => Promise<Array<Record<string, unknown>>>;
|
|
11
|
+
run: (steps: Array<{
|
|
12
|
+
command: string;
|
|
13
|
+
params?: Record<string, unknown>;
|
|
14
|
+
}>, save: boolean) => Promise<{
|
|
15
|
+
completed: Array<{
|
|
16
|
+
result: unknown;
|
|
17
|
+
}>;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
replica: {
|
|
21
|
+
exportChanges: (since: ArrayBuffer) => Promise<{
|
|
22
|
+
changes: ArrayBuffer;
|
|
23
|
+
blobs: ArrayBuffer;
|
|
24
|
+
}>;
|
|
25
|
+
importChanges: (changes: ArrayBuffer, blobs: ArrayBuffer) => Promise<unknown>;
|
|
26
|
+
onChanged: (listener: (version: ArrayBuffer) => void) => () => void;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Hears the kit's `presence/set` (Kit UI protocol section 7e): what the person selected, as KDM
|
|
30
|
+
* object ids. With it, the document fires `selection`.
|
|
31
|
+
*/
|
|
32
|
+
onPresence?: (listener: (presence: {
|
|
33
|
+
selection: string[];
|
|
34
|
+
}) => void) => () => void;
|
|
35
|
+
/** The kit's own object model (capability `model`). */
|
|
36
|
+
model?: {
|
|
37
|
+
describe: (schema?: object) => Promise<Record<string, unknown>>;
|
|
38
|
+
batch: (params: Record<string, unknown>) => Promise<{
|
|
39
|
+
refs: Record<string, string>;
|
|
40
|
+
results: unknown[];
|
|
41
|
+
loaded: Array<{
|
|
42
|
+
id: string;
|
|
43
|
+
type: string;
|
|
44
|
+
fields: Record<string, unknown>;
|
|
45
|
+
}>;
|
|
46
|
+
version?: ArrayBuffer | null;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* A kit editor in a frame (Kit UI protocol): changes through `replica/export` and `replica/import`,
|
|
52
|
+
* commands through the Kit AI bridge (`ai/run`, which the kit records as the agent's).
|
|
53
|
+
*/
|
|
54
|
+
export declare function portFromConnection(connection: ConnectionLike, options?: {
|
|
55
|
+
readOnly?: () => boolean;
|
|
56
|
+
}): ModelPort;
|
|
57
|
+
/** The members of a kit engine's class (`kition-kit`'s `export_kit_document!` and contract 2) the object model uses. */
|
|
58
|
+
export type EngineLike = {
|
|
59
|
+
exportChanges: (since: Uint8Array) => Uint8Array;
|
|
60
|
+
importChanges: (changes: Uint8Array) => unknown;
|
|
61
|
+
execute: (command: string, params: string) => string;
|
|
62
|
+
executeAs?: (command: string, params: string, origin: string) => string;
|
|
63
|
+
commands: () => string;
|
|
64
|
+
/** Reads what the engine derives from its document; `premiseRead('projected', '{}')` lists its projected objects. */
|
|
65
|
+
premiseRead?: (method: string, params: string) => string;
|
|
66
|
+
};
|
|
67
|
+
/** A kit engine in this process (Node, a worker): commands run as the batch's origin when it has `executeAs`. */
|
|
68
|
+
export declare function portFromEngine(engine: EngineLike, kitId: string, options?: {
|
|
69
|
+
readOnly?: () => boolean;
|
|
70
|
+
onChanged?: ModelPort['onChanged'];
|
|
71
|
+
} & DocumentEventSource): ModelPort;
|
|
72
|
+
/** An editor of `@kition/sdk/embed` (it gives its own port), a `KitConnection`, or an engine. */
|
|
73
|
+
export declare function portFromSource(source: unknown, kit?: string): Promise<ModelPort>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reconnect backoff: 1 s for the first attempt, doubling per further attempt, capped at 30 s,
|
|
3
|
+
* with equal jitter (half fixed, half random) so many clients reconnecting at once do not all
|
|
4
|
+
* retry on the same tick.
|
|
5
|
+
*/
|
|
6
|
+
export declare const BACKOFF_BASE_MS = 1000;
|
|
7
|
+
export declare const BACKOFF_CAP_MS = 30000;
|
|
8
|
+
/** `attempt` is 0 for the first reconnect try after a disconnect. `random` returns `[0, 1)`. */
|
|
9
|
+
export declare function backoffDelay(attempt: number, random?: () => number): number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The blobs a kit's replica exports alongside its changes (Kit UI protocol `replica/export`), and
|
|
3
|
+
* how a receiving side finds the blobs a pushed change needs.
|
|
4
|
+
*
|
|
5
|
+
* A blob section is `(64-hex SHA-256 as ASCII, u64 little-endian length, bytes)*`.
|
|
6
|
+
*
|
|
7
|
+
* The sync server relays KDM change bytes only, never a blob list, so the side that imports a
|
|
8
|
+
* change finds its blobs in the change itself: a replica references a blob by its hash, which a
|
|
9
|
+
* KDM change export (Loro updates) carries as plain text. Every 64-hex run in the bytes is a
|
|
10
|
+
* candidate; the server answers which of them it holds (`blob/has`), and those are fetched. A
|
|
11
|
+
* candidate the server does not hold is not a blob (or a blob no one uploaded), and is skipped.
|
|
12
|
+
*/
|
|
13
|
+
export type BlobEntry = {
|
|
14
|
+
hash: string;
|
|
15
|
+
data: Uint8Array;
|
|
16
|
+
};
|
|
17
|
+
export declare function decodeBlobSection(bytes: Uint8Array): BlobEntry[];
|
|
18
|
+
export declare function encodeBlobSection(entries: readonly BlobEntry[]): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Every lowercase 64-hex string in `bytes` that could be a blob hash: each 64-character window of
|
|
21
|
+
* every run of hex characters, since a hash may sit next to other hex text.
|
|
22
|
+
*/
|
|
23
|
+
export declare function blobHashCandidates(bytes: Uint8Array): string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability sets in `sync/hello` (Kition platform `docs/platform/index.md` section 3, rule CS2): next to its protocol
|
|
3
|
+
* capabilities (`leases`, `headless`), a server lists the versioned capability sets it serves for
|
|
4
|
+
* the principal, such as `"KitModel 1.0"` and `"KitCollab 1.1"`. A set is `Name major.minor`; a
|
|
5
|
+
* minor version only adds members, so `Name a.b` serves a request for `Name a.c` when `c` is at
|
|
6
|
+
* most `b`. Scripts test for a set, never for a server product or its version.
|
|
7
|
+
*/
|
|
8
|
+
/** `Name major.minor` as its parts; `null` for anything else (a protocol capability). */
|
|
9
|
+
export declare function parseCapabilitySet(set: string): {
|
|
10
|
+
name: string;
|
|
11
|
+
major: number;
|
|
12
|
+
minor: number;
|
|
13
|
+
} | null;
|
|
14
|
+
/** The capability sets among `capabilities` (what `sync/hello` lists), in their order. */
|
|
15
|
+
export declare function capabilitySetsOf(capabilities: readonly string[]): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Whether `sets` serve `required` (such as `'KitCollab 1.0'`): a set of the same name and major
|
|
18
|
+
* version with at least its minor version. A malformed name is never served.
|
|
19
|
+
*/
|
|
20
|
+
export declare function servesCapabilitySet(required: string, sets: readonly string[]): boolean;
|