@kition/kit-editor 0.0.0-stage → 0.2.0
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 +103 -2
- package/dist/LICENSE +177 -0
- package/dist/THIRD_PARTY_NOTICES +28 -0
- package/dist/assets/kitEngine.worker-Bb4qhbsX.js +13038 -0
- package/dist/chunks/workspaceTree-CpJ2i9hy.js +23 -0
- package/dist/index.js +6434 -0
- package/dist/styles.css +807 -0
- package/dist/types/src/CommandDialog.d.ts +22 -0
- package/dist/types/src/CommentsPanel.d.ts +45 -0
- package/dist/types/src/CustomizeDialog.d.ts +32 -0
- package/dist/types/src/HostButtons.d.ts +11 -0
- package/dist/types/src/RenderFailure.d.ts +7 -0
- package/dist/types/src/TextSink.d.ts +6 -0
- package/dist/types/src/brand.d.ts +2 -0
- package/dist/types/src/catalogMenus.d.ts +27 -0
- package/dist/types/src/chart.d.ts +138 -0
- package/dist/types/src/conflicts.d.ts +12 -0
- package/dist/types/src/drawing.d.ts +83 -0
- package/dist/types/src/editor.d.ts +544 -0
- package/dist/types/src/engine/KitCanvas.d.ts +70 -0
- package/dist/types/src/engine/createKitFile.d.ts +12 -0
- package/dist/types/src/engine/decorations.d.ts +14 -0
- package/dist/types/src/engine/engineOverlays.d.ts +197 -0
- package/dist/types/src/engine/engineTools.d.ts +116 -0
- package/dist/types/src/engine/kitDraft.d.ts +70 -0
- package/dist/types/src/engine/kitEngine.d.ts +370 -0
- package/dist/types/src/engine/kitEngine.worker.d.ts +30 -0
- package/dist/types/src/engine/kitHost.d.ts +41 -0
- package/dist/types/src/engine/kitModel.d.ts +32 -0
- package/dist/types/src/engine/kitModelRunner.d.ts +99 -0
- package/dist/types/src/engine/kitModule.d.ts +173 -0
- package/dist/types/src/engine/kitShortcuts.d.ts +32 -0
- package/dist/types/src/engine/kitTools.d.ts +79 -0
- package/dist/types/src/engine/lentFiles.d.ts +29 -0
- package/dist/types/src/engine/rasterViewport.d.ts +178 -0
- package/dist/types/src/engine/readOnly.d.ts +78 -0
- package/dist/types/src/engine/refusal.d.ts +39 -0
- package/dist/types/src/engine/replica.d.ts +23 -0
- package/dist/types/src/engine/useKitDocument.d.ts +154 -0
- package/dist/types/src/engine/workerRelay.d.ts +62 -0
- package/dist/types/src/files.d.ts +74 -0
- package/dist/types/src/frame/EditorFrame.d.ts +74 -0
- package/dist/types/src/frame/FocusBar.d.ts +10 -0
- package/dist/types/src/frame/MenuNodes.d.ts +20 -0
- package/dist/types/src/frame/MenuRibbon.d.ts +8 -0
- package/dist/types/src/frame/ModeButton.d.ts +7 -0
- package/dist/types/src/frame/menus.d.ts +64 -0
- package/dist/types/src/frame/modes.d.ts +51 -0
- package/dist/types/src/frame/useFrameLayout.d.ts +34 -0
- package/dist/types/src/host.d.ts +127 -0
- package/dist/types/src/index.d.ts +84 -0
- package/dist/types/src/ink.d.ts +26 -0
- package/dist/types/src/lease.d.ts +53 -0
- package/dist/types/src/oneInFlight.d.ts +7 -0
- package/dist/types/src/phrases.d.ts +25 -0
- package/dist/types/src/presence.d.ts +79 -0
- package/dist/types/src/strings.d.ts +6 -0
- package/dist/types/src/toolIcons.d.ts +32 -0
- package/dist/types/src/uiCatalog.d.ts +59 -0
- package/dist/types/src/uiConfig.d.ts +53 -0
- package/dist/types/src/uiContext.d.ts +65 -0
- package/dist/types/src/uiStore.d.ts +20 -0
- package/dist/types/src/useCommentAnchors.d.ts +29 -0
- package/dist/types/src/useKitSession.d.ts +115 -0
- package/dist/types/src/workspaceTree.d.ts +5 -0
- package/dist/workspaceTree.js +1 -0
- package/package.json +43 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The editor's live UI configuration (protocol section 9): the host's, replaced by `ui/configure`,
|
|
3
|
+
* and the person's hides, applied at once and kept by the host (`host/customize`).
|
|
4
|
+
*/
|
|
5
|
+
import type { KitNotifications } from '@kition/kit-ui-protocol';
|
|
6
|
+
import type { UiConfig } from './uiConfig.js';
|
|
7
|
+
export type UiStore = {
|
|
8
|
+
get: () => UiConfig;
|
|
9
|
+
/** For `useSyncExternalStore`. */
|
|
10
|
+
subscribe: (listener: () => void) => () => void;
|
|
11
|
+
/** Replaces the host's configuration. While a personal change is being kept, it stays over the host's. */
|
|
12
|
+
replace: (config: UiConfig) => void;
|
|
13
|
+
/** Whether the host keeps what the person hides (capability `customize`). */
|
|
14
|
+
customizable: boolean;
|
|
15
|
+
/** Sets the person's hides; rejects when the host could not keep them (they still apply). */
|
|
16
|
+
setPersonal: (hide: string[]) => Promise<void>;
|
|
17
|
+
/** A host button was pressed (`ui/action`). */
|
|
18
|
+
action: (params: KitNotifications['ui/action']) => void;
|
|
19
|
+
};
|
|
20
|
+
export declare function createUiStore(initial: UiConfig, customize: ((hide: string[]) => Promise<void>) | null, action: (params: KitNotifications['ui/action']) => void): UiStore;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CommentAnchor, CommentThread } from '@kition/kdm';
|
|
2
|
+
export type CommentMarkerRect = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
export type CommentMarker = {
|
|
9
|
+
thread: string;
|
|
10
|
+
anchor: CommentAnchor;
|
|
11
|
+
rect: CommentMarkerRect;
|
|
12
|
+
resolved: boolean;
|
|
13
|
+
count: number;
|
|
14
|
+
active: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type CommentAnchorsOptions = {
|
|
17
|
+
threads: CommentThread[];
|
|
18
|
+
/** Where `anchor` is now, in the kit's own coordinates; `null` when it is not shown. */
|
|
19
|
+
locate: (anchor: CommentAnchor) => CommentMarkerRect | null;
|
|
20
|
+
/** Markers for resolved threads too (default: only open ones). */
|
|
21
|
+
showResolved?: boolean;
|
|
22
|
+
activeThread?: string | null;
|
|
23
|
+
/** Changes whenever what `locate` answers may have changed (a document revision, the zoom). */
|
|
24
|
+
revision?: unknown;
|
|
25
|
+
};
|
|
26
|
+
/** The markers to draw, in the threads' order. */
|
|
27
|
+
export declare function commentMarkers({ threads, locate, showResolved, activeThread }: CommentAnchorsOptions): CommentMarker[];
|
|
28
|
+
/** `commentMarkers`, kept while its inputs (and `revision`) stay the same. */
|
|
29
|
+
export declare function useCommentAnchors(options: CommentAnchorsOptions): CommentMarker[];
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { KitRpcError, type DocumentChangeBy, type KitLease } from '@kition/kit-ui-protocol';
|
|
2
|
+
import type { Origin } from '@kition/kdm';
|
|
3
|
+
import type { HostConnection } from './host.js';
|
|
4
|
+
import type { KitEngine, KitEngineInfo } from './engine/kitEngine.js';
|
|
5
|
+
import type { KitCommand, KitModuleManifest } from './engine/kitModule.js';
|
|
6
|
+
import { type KitDocumentOptions, type KitRunOptions } from './engine/useKitDocument.js';
|
|
7
|
+
import type { RasterRect } from './engine/rasterViewport.js';
|
|
8
|
+
import type { DraftSummary } from '@kition/kit-ui-protocol';
|
|
9
|
+
import { type KitLeases } from './lease.js';
|
|
10
|
+
/** The error a command refused because the document is read-only answers with. `step` names the `ai/run` step. */
|
|
11
|
+
export declare function readOnlyRefusal(command: string, step?: number): KitRpcError;
|
|
12
|
+
/** Who made the document's last change, when it was not the person: the editor's status line says so. */
|
|
13
|
+
export type KitEditedBy = Exclude<DocumentChangeBy, {
|
|
14
|
+
by: 'person';
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Opens the host's document in `manifest`'s engine. `describe` turns `inspect()` into what the
|
|
18
|
+
* editor shows. Answers the host's `ui/initialize` once open, and serves `ai/*`.
|
|
19
|
+
*/
|
|
20
|
+
/** A kit's own choices for its session. */
|
|
21
|
+
export type KitSessionOptions = {
|
|
22
|
+
/**
|
|
23
|
+
* An `ai/run` step that moves neither the engine's revision nor its `inspect()` (an agent
|
|
24
|
+
* selecting) refreshes the editor without repainting the canvas (`KitRunOptions.skipUnchangedPaint`).
|
|
25
|
+
* Off by default: a kit opts in when its engine paints nothing that neither of them shows.
|
|
26
|
+
*/
|
|
27
|
+
agentSkipsUnchangedPaint?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The lease (Kit UI protocol section 7b) an `ai/run` step on the live document must hold, for a
|
|
30
|
+
* kit some of whose commands need one (a PDF's full rewrite takes the whole document, `*`):
|
|
31
|
+
* asked before each step with its command and params, answering the scope, or `null` or `''`
|
|
32
|
+
* for none (a kit with an engine extra such as `leaseScope` asks its engine). The session takes
|
|
33
|
+
* the lease through the host before the step and releases it when the step ends. A step whose
|
|
34
|
+
* lease another session holds is not run: `ai/run` fails at it with reason `held` and the
|
|
35
|
+
* person sees a notice; with a kit that asks, a step that edits without a lease of its own is
|
|
36
|
+
* refused the same way while another session holds the whole document (`*`). Not asked when
|
|
37
|
+
* the host serves no leases (nobody to coordinate with) or for the agent's draft, which is
|
|
38
|
+
* never shared until the person merges it. An error asking counts as no lease.
|
|
39
|
+
*/
|
|
40
|
+
agentLeaseScope?: (command: string, params: Record<string, unknown>, engine: KitEngine) => string | null | Promise<string | null>;
|
|
41
|
+
/** One renewal's length for an agent step's lease (milliseconds, `host/leaseAcquire`'s `ttl`); the host's own by default. */
|
|
42
|
+
agentLeaseTtl?: number;
|
|
43
|
+
/** The kit's engine merges the file into an older stored replica when it opens (`KitDocumentOptions.replicaMergesFile`). */
|
|
44
|
+
replicaMergesFile?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Takes a change of the file on disk into the open document while it has no unsaved edits
|
|
47
|
+
* (`KitDocumentOptions.followFile`); without it, or when it answers `false`, the document reopens.
|
|
48
|
+
*/
|
|
49
|
+
followFile?: KitDocumentOptions['followFile'];
|
|
50
|
+
/**
|
|
51
|
+
* The person merged the agent's draft (`draft/merge`, section 7d): it is in the document as
|
|
52
|
+
* one step of the person's Undo (KitModel 1.1 M12a). A kit that keeps its own undo history
|
|
53
|
+
* records the step here. Called once the merge took changes in, before the host's answer.
|
|
54
|
+
*/
|
|
55
|
+
draftMerged?: (merged: {
|
|
56
|
+
summary: DraftSummary;
|
|
57
|
+
}) => void;
|
|
58
|
+
};
|
|
59
|
+
/** The error an `ai/run` step answers when another session holds the lease it needs (`data.reason` `held`). */
|
|
60
|
+
export declare function leaseHeldRefusal(command: string, step: number, scope: string, holder: KitLease['holder'] | null): KitRpcError;
|
|
61
|
+
/**
|
|
62
|
+
* Runs one agent step under the lease `scope` needs (none when empty): a lease another session
|
|
63
|
+
* holds refuses it before anything runs (`refuse` answers the error to throw), and the step's own
|
|
64
|
+
* lease is released when it ends, however it ends. Without a scope, a step that edits is refused
|
|
65
|
+
* while another session holds the whole document.
|
|
66
|
+
*/
|
|
67
|
+
export declare function withAgentLease<T>(leases: KitLeases, scope: string, mutates: boolean, ttl: number | undefined, step: () => Promise<T>, refuse: (scope: string, holder: KitLease['holder'] | null) => Error): Promise<T>;
|
|
68
|
+
export declare function useKitSession<T>(host: HostConnection, manifest: KitModuleManifest, describe: (info: KitEngineInfo) => T, options?: KitSessionOptions): {
|
|
69
|
+
run: (command: string, params?: Record<string, unknown>, damage?: RasterRect | null, options?: KitRunOptions) => Promise<string | null>;
|
|
70
|
+
editedBy: KitEditedBy | null;
|
|
71
|
+
comments: ReadonlySet<string>;
|
|
72
|
+
path: string;
|
|
73
|
+
manifest: KitModuleManifest;
|
|
74
|
+
doc: KitEngine | null;
|
|
75
|
+
info: KitEngineInfo | null;
|
|
76
|
+
state: T | null;
|
|
77
|
+
change: import(".").KitChange;
|
|
78
|
+
repaints: import(".").KitRepaints;
|
|
79
|
+
dirty: boolean;
|
|
80
|
+
failure: string | null;
|
|
81
|
+
openMs: number | null;
|
|
82
|
+
saving: boolean;
|
|
83
|
+
conflict: boolean;
|
|
84
|
+
tool: <R>(name: import("./engine/kitEngine.js").KitToolMethod, args?: unknown[], settled?: boolean) => Promise<R | null>;
|
|
85
|
+
commands: () => Promise<never[] | KitCommand[]>;
|
|
86
|
+
disabledCommands: () => Promise<string[] | never[]>;
|
|
87
|
+
save: () => Promise<void>;
|
|
88
|
+
replica: {
|
|
89
|
+
version: () => Promise<ArrayBuffer>;
|
|
90
|
+
exportChanges: (since: ArrayBuffer) => Promise<{
|
|
91
|
+
changes: ArrayBuffer;
|
|
92
|
+
blobs: ArrayBuffer;
|
|
93
|
+
}>;
|
|
94
|
+
importChanges: (changes: ArrayBuffer, blobs: ArrayBuffer) => Promise<unknown>;
|
|
95
|
+
docId: () => Promise<string | null>;
|
|
96
|
+
};
|
|
97
|
+
model: {
|
|
98
|
+
describe: (schema: object | null) => Promise<Record<string, unknown>>;
|
|
99
|
+
version: () => Promise<string>;
|
|
100
|
+
changes: (since: string, schema: object | null) => Promise<import("./engine/kitEngine.js").KitModelChanges>;
|
|
101
|
+
batch: (request: Record<string, unknown>, schema: object | null) => Promise<import("@kition/kit-ui-protocol").ModelBatchResult>;
|
|
102
|
+
};
|
|
103
|
+
draft: {
|
|
104
|
+
open: () => Promise<{
|
|
105
|
+
engine: KitEngine;
|
|
106
|
+
base: ArrayBuffer;
|
|
107
|
+
}>;
|
|
108
|
+
merge: (changes: ArrayBuffer, blobs: ArrayBuffer, origin: Origin, schema: object | null) => Promise<DraftSummary>;
|
|
109
|
+
compare: (changes: ArrayBuffer, schema: object | null) => Promise<DraftSummary>;
|
|
110
|
+
};
|
|
111
|
+
reopen: () => void;
|
|
112
|
+
keepMine: () => Promise<void>;
|
|
113
|
+
checkFile: (isCurrent?: () => boolean) => Promise<void>;
|
|
114
|
+
holdFile: (stamp: string) => Promise<void>;
|
|
115
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@kition/tessera-ui/workspaceTree";
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kition/kit-editor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Build a kit's embedded editor: host connection, document session, engine canvas and tools, and shared components styled by the host's theme (Kit UI protocol).",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/types/src/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./styles.css": "./dist/styles.css",
|
|
13
|
+
"./workspaceTree": {
|
|
14
|
+
"types": "./dist/types/src/workspaceTree.d.ts",
|
|
15
|
+
"import": "./dist/workspaceTree.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@kition/kit-engine": "^0.2.0",
|
|
23
|
+
"@kition/tessera-ui": "^0.1.0",
|
|
24
|
+
"@kition/tessera-icons": "^0.1.0",
|
|
25
|
+
"@kition/tessera-tokens": "^0.1.0",
|
|
26
|
+
"@kition/kdm": "0.2.0",
|
|
27
|
+
"@kition/kit-ui-protocol": "0.2.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": ">=19",
|
|
31
|
+
"react-dom": ">=19"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/KitionAI/kition-sdk.git",
|
|
36
|
+
"directory": "packages/kit-editor"
|
|
37
|
+
},
|
|
38
|
+
"types": "./dist/types/src/index.d.ts",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"main": "./dist/index.js",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "node ../../tools/build-package.mjs"
|
|
45
|
+
}
|
|
6
46
|
}
|