@kition/kit-editor 0.0.0-stage → 0.1.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/assets/kitEngine.worker-9PIHJagj.js +13020 -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 +93 -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,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drawing the engine tools' overlays (kit editors U8b): the marquee, path and
|
|
3
|
+
* line previews, anchors and handles, labels, measurement pills, highlights and swatches an
|
|
4
|
+
* engine answers with, in document pixels. Kit-editor draws them in Kition's style unless the
|
|
5
|
+
* kit asks otherwise, in two ways that combine:
|
|
6
|
+
*
|
|
7
|
+
* - `overlayStyle`: colours, sizes, shapes, dashes and fonts per overlay kind (`OverlayStyle`),
|
|
8
|
+
* for a kit whose overlays only need a different look;
|
|
9
|
+
* - `drawOverlay`: a hook that draws an overlay itself on the overlay canvas, with the current
|
|
10
|
+
* view transform; it returns `true` when it drew the overlay, and kit-editor draws the rest in
|
|
11
|
+
* the style.
|
|
12
|
+
*/
|
|
13
|
+
import type { RasterDecoration, RasterView } from './rasterViewport.js';
|
|
14
|
+
/** An overlay colour: red, green, blue and alpha, 0 to 255. */
|
|
15
|
+
export type OverlayRgba = [number, number, number, number];
|
|
16
|
+
/** A drawing primitive over the canvas, in document pixels (`kition_kit::tools::ToolOverlay`). */
|
|
17
|
+
export type EngineOverlay = {
|
|
18
|
+
kind: 'marquee';
|
|
19
|
+
x0: number;
|
|
20
|
+
y0: number;
|
|
21
|
+
x1: number;
|
|
22
|
+
y1: number;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'path';
|
|
25
|
+
d: string;
|
|
26
|
+
color: OverlayRgba;
|
|
27
|
+
width: number;
|
|
28
|
+
dashed: boolean;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'line';
|
|
31
|
+
ax: number;
|
|
32
|
+
ay: number;
|
|
33
|
+
bx: number;
|
|
34
|
+
by: number;
|
|
35
|
+
color: OverlayRgba;
|
|
36
|
+
dashed: boolean;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'anchor';
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
color: OverlayRgba;
|
|
42
|
+
filled: boolean;
|
|
43
|
+
size: number;
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'handle';
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
color: OverlayRgba;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'label';
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
text: string;
|
|
54
|
+
color: OverlayRgba;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'measure';
|
|
57
|
+
x: number;
|
|
58
|
+
y: number;
|
|
59
|
+
text: string;
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'highlight';
|
|
62
|
+
quad: [number, number][];
|
|
63
|
+
color: OverlayRgba;
|
|
64
|
+
} | {
|
|
65
|
+
kind: 'swatch';
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
color: OverlayRgba;
|
|
69
|
+
selected: boolean;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* How kit-editor draws engine overlays. Sizes are in screen (CSS) pixels at every zoom; colours
|
|
73
|
+
* are CSS colours. `null` where a colour is allowed means "the overlay's own colour".
|
|
74
|
+
*/
|
|
75
|
+
export type OverlayStyle = {
|
|
76
|
+
/** The tool accent: the marquee's colours and a selected swatch's ring, unless they set theirs. */
|
|
77
|
+
accent: string;
|
|
78
|
+
/** The light colour: unfilled anchors, a swatch's ring, text on a dark pill. */
|
|
79
|
+
surface: string;
|
|
80
|
+
/** The dark colour: the measurement pill, and text on a light pill. */
|
|
81
|
+
ink: string;
|
|
82
|
+
/** The font of labels and pills (CSS `font`). */
|
|
83
|
+
font: string;
|
|
84
|
+
marquee: {
|
|
85
|
+
/** Fill colour (`null`: `accent`), drawn at `fillOpacity`. */
|
|
86
|
+
fill: string | null;
|
|
87
|
+
fillOpacity: number;
|
|
88
|
+
/** Stroke colour (`null`: `accent`). */
|
|
89
|
+
stroke: string | null;
|
|
90
|
+
width: number;
|
|
91
|
+
/** The stroke's dash pattern; `[]` for a solid line. */
|
|
92
|
+
dash: number[];
|
|
93
|
+
/** Whether the stroke lies inside the rectangle (otherwise it is offset half a pixel past it). */
|
|
94
|
+
inside: boolean;
|
|
95
|
+
};
|
|
96
|
+
path: {
|
|
97
|
+
/** The thinnest stroke drawn, whatever the overlay's width. */
|
|
98
|
+
minWidth: number;
|
|
99
|
+
/** The dash pattern of a dashed path. */
|
|
100
|
+
dash: number[];
|
|
101
|
+
};
|
|
102
|
+
line: {
|
|
103
|
+
width: number;
|
|
104
|
+
/** The dash pattern of a dashed line. */
|
|
105
|
+
dash: number[];
|
|
106
|
+
};
|
|
107
|
+
anchor: {
|
|
108
|
+
/** `square` (rounded by `radius`) or `circle`. */
|
|
109
|
+
shape: 'square' | 'circle';
|
|
110
|
+
/** The square's corner radius. */
|
|
111
|
+
radius: number;
|
|
112
|
+
/** The size when the overlay gives none. */
|
|
113
|
+
size: number;
|
|
114
|
+
/** An unfilled anchor's fill (`null`: `surface`); a filled one takes the overlay's colour. */
|
|
115
|
+
fill: string | null;
|
|
116
|
+
/** The ring in the overlay's colour; 0 for none. */
|
|
117
|
+
ringWidth: number;
|
|
118
|
+
};
|
|
119
|
+
handle: {
|
|
120
|
+
radius: number;
|
|
121
|
+
/** The dot's fill (`null`: the overlay's colour). */
|
|
122
|
+
fill: string | null;
|
|
123
|
+
/** The ring in the overlay's colour; 0 for none. */
|
|
124
|
+
ringWidth: number;
|
|
125
|
+
};
|
|
126
|
+
label: {
|
|
127
|
+
font: string | null;
|
|
128
|
+
/** The text's offset from the overlay's point (the text's baseline at `dy`). */
|
|
129
|
+
dx: number;
|
|
130
|
+
dy: number;
|
|
131
|
+
};
|
|
132
|
+
measure: {
|
|
133
|
+
/** Pill colour (`null`: `ink`). */
|
|
134
|
+
fill: string | null;
|
|
135
|
+
/** Text colour (`null`: `surface`, or `ink` on a `surface` pill). */
|
|
136
|
+
color: string | null;
|
|
137
|
+
font: string | null;
|
|
138
|
+
padX: number;
|
|
139
|
+
/** Pill height; `null`: the font's size times 1.2 plus `padY` above and below. */
|
|
140
|
+
height: number | null;
|
|
141
|
+
padY: number;
|
|
142
|
+
radius: number;
|
|
143
|
+
/** The pill's offset from the overlay's point. */
|
|
144
|
+
dx: number;
|
|
145
|
+
dy: number;
|
|
146
|
+
/** Where the point sits on the pill: its left edge (`start`) or its middle (`center`). */
|
|
147
|
+
align: 'start' | 'center';
|
|
148
|
+
};
|
|
149
|
+
swatch: {
|
|
150
|
+
size: number;
|
|
151
|
+
radius: number;
|
|
152
|
+
ringWidth: number;
|
|
153
|
+
/** Ring colour (`null`: `surface`); a selected swatch's (`null`: `accent`). */
|
|
154
|
+
ring: string | null;
|
|
155
|
+
selectedRing: string | null;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
/** A kit's changes to the style: any field of any kind (`{ marquee: { dash: [] } }`). */
|
|
159
|
+
export type OverlayStylePatch = {
|
|
160
|
+
[K in keyof OverlayStyle]?: OverlayStyle[K] extends object ? Partial<OverlayStyle[K]> : OverlayStyle[K];
|
|
161
|
+
};
|
|
162
|
+
/** Kition's overlay style, which every kit gets unless it changes it. */
|
|
163
|
+
export declare const DEFAULT_OVERLAY_STYLE: OverlayStyle;
|
|
164
|
+
/** The default style with a kit's changes. */
|
|
165
|
+
export declare function overlayStyle(patch?: OverlayStylePatch | null): OverlayStyle;
|
|
166
|
+
/** What a kit's `drawOverlay` hook draws with. */
|
|
167
|
+
export type OverlayDrawContext = {
|
|
168
|
+
/** The overlay canvas, in CSS pixels, on its own saved state (line width 1, no dash). */
|
|
169
|
+
context: CanvasRenderingContext2D;
|
|
170
|
+
/** A document point on the canvas. */
|
|
171
|
+
toScreen: (x: number, y: number) => {
|
|
172
|
+
x: number;
|
|
173
|
+
y: number;
|
|
174
|
+
};
|
|
175
|
+
/** The current view: zoom (CSS pixels per document pixel) and the shown pane's offset. */
|
|
176
|
+
view: RasterView;
|
|
177
|
+
/** The style in effect (the default with the kit's `overlayStyle`). */
|
|
178
|
+
style: OverlayStyle;
|
|
179
|
+
/** Every overlay of this frame, in order, and this one's place among them. */
|
|
180
|
+
overlays: readonly EngineOverlay[];
|
|
181
|
+
index: number;
|
|
182
|
+
/** Scratch space shared by one frame's calls (for example labels placed so far); new every frame. */
|
|
183
|
+
frame: Record<string, unknown>;
|
|
184
|
+
/** Draws an overlay (this one when none is given) in `style`. */
|
|
185
|
+
drawDefault: (overlay?: EngineOverlay) => void;
|
|
186
|
+
};
|
|
187
|
+
/** A kit's own drawing of an overlay: `true` when it drew it, otherwise kit-editor draws it in the style. */
|
|
188
|
+
export type OverlayDrawer = (overlay: EngineOverlay, draw: OverlayDrawContext) => boolean | void;
|
|
189
|
+
/** An overlay colour as CSS. */
|
|
190
|
+
export declare function overlayCss([r, g, b, a]: OverlayRgba): string;
|
|
191
|
+
/** Draws one overlay in `style`, on the context's current state. */
|
|
192
|
+
export declare function drawOverlayInStyle(context: CanvasRenderingContext2D, toScreen: (x: number, y: number) => {
|
|
193
|
+
x: number;
|
|
194
|
+
y: number;
|
|
195
|
+
}, view: RasterView, overlay: EngineOverlay, style: OverlayStyle): void;
|
|
196
|
+
/** The decoration that draws `overlays`: each by the kit's `draw` hook, or else in `style`. */
|
|
197
|
+
export declare function drawEngineOverlays(overlays: readonly EngineOverlay[], style?: OverlayStyle, draw?: OverlayDrawer | null): RasterDecoration;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { KitToolMethod } from './kitEngine.js';
|
|
2
|
+
import { type KitTool } from './kitTools.js';
|
|
3
|
+
import type { RasterDecoration } from './rasterViewport.js';
|
|
4
|
+
import { type EngineOverlay, type OverlayDrawer, type OverlayStylePatch } from './engineOverlays.js';
|
|
5
|
+
import { type KitChange } from './useKitDocument.js';
|
|
6
|
+
/**
|
|
7
|
+
* The engine-tools capability (kit editors U8b): kits whose engine
|
|
8
|
+
* owns its tools' state machines (pen, direct selection, type) expose them,
|
|
9
|
+
* and this one bridge runs them. The host sends pointer, key, and text events
|
|
10
|
+
* in document pixels; the engine answers with requests, overlays, and a
|
|
11
|
+
* cursor, and the host draws the overlays: in Kition's style, or in the kit's own
|
|
12
|
+
* (`overlayStyle`, `drawOverlay`; see `engineOverlays.ts`).
|
|
13
|
+
*/
|
|
14
|
+
/** One engine tool; tools sharing a `group` share a slot on the rail. */
|
|
15
|
+
export type EngineToolInfo = {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
shortcut: string | null;
|
|
19
|
+
icon: string;
|
|
20
|
+
group: number;
|
|
21
|
+
};
|
|
22
|
+
/** A drawing primitive over the canvas, in document pixels. */
|
|
23
|
+
type EngineToolOverlay = EngineOverlay;
|
|
24
|
+
/** Something only the host can do. */
|
|
25
|
+
type EngineToolRequest = {
|
|
26
|
+
kind: 'dialog';
|
|
27
|
+
name: string;
|
|
28
|
+
params: unknown;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'switchTool';
|
|
31
|
+
id: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'status';
|
|
34
|
+
text: string;
|
|
35
|
+
};
|
|
36
|
+
export type EngineToolResponse = {
|
|
37
|
+
requests: EngineToolRequest[];
|
|
38
|
+
overlays: EngineToolOverlay[];
|
|
39
|
+
cursor: string;
|
|
40
|
+
busy: boolean;
|
|
41
|
+
wantsText: boolean;
|
|
42
|
+
};
|
|
43
|
+
type ToolCall = <R>(name: KitToolMethod, args?: unknown[], settled?: boolean) => Promise<R | null>;
|
|
44
|
+
type EngineToolsOptions = {
|
|
45
|
+
/** Tools the host runs itself (view tools), by engine id. */
|
|
46
|
+
hostTools?: Record<string, KitTool>;
|
|
47
|
+
/** Engine tools left off the rail. */
|
|
48
|
+
hidden?: ReadonlySet<string>;
|
|
49
|
+
/** The tool selected when the document opens. */
|
|
50
|
+
initial: string;
|
|
51
|
+
/**
|
|
52
|
+
* Whether Escape has something for the tool to cancel now (a selection, a gesture, a shape
|
|
53
|
+
* chosen to draw); read when Escape is pressed. A tool taking text otherwise takes every
|
|
54
|
+
* Escape, so in Focus none would be left to leave it (KitPointer 4.4). Without it, the tool
|
|
55
|
+
* takes Escape whenever it takes text or is busy.
|
|
56
|
+
*/
|
|
57
|
+
escapable?: () => boolean;
|
|
58
|
+
/** A dialog the engine asks for; the editor opens it, or says it cannot. */
|
|
59
|
+
onDialog?: (name: string, params: unknown) => void;
|
|
60
|
+
/**
|
|
61
|
+
* A key pressed while the engine was still answering an earlier event, which turned out not
|
|
62
|
+
* to be typed text: the editor handles it as it would have (a tool shortcut).
|
|
63
|
+
*/
|
|
64
|
+
onDeferredKey?: (key: string, shift: boolean) => void;
|
|
65
|
+
/**
|
|
66
|
+
* The kit's look for the engine's overlays: changes to Kition's style per overlay kind
|
|
67
|
+
* (colours, sizes, shapes, dashes, fonts). Keep it stable (a module constant or memoized):
|
|
68
|
+
* a new object redraws them.
|
|
69
|
+
*/
|
|
70
|
+
overlayStyle?: OverlayStylePatch | null;
|
|
71
|
+
/**
|
|
72
|
+
* Draws an overlay the kit's own way, on the overlay canvas with the current view transform;
|
|
73
|
+
* returns `true` when it drew it, and kit-editor draws the others in `overlayStyle`. Keep it
|
|
74
|
+
* stable, as `overlayStyle`.
|
|
75
|
+
*/
|
|
76
|
+
drawOverlay?: OverlayDrawer | null;
|
|
77
|
+
};
|
|
78
|
+
/** Whether the host's UI configuration refuses a tool, by engine id. */
|
|
79
|
+
type ToolDenied = (id: string) => boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Runs a kit's engine tools in a kit editor: the rail's tools from the engine,
|
|
82
|
+
* the active tool as a canvas tool, its overlays as a canvas decoration, its
|
|
83
|
+
* cursor, and its keys and typed text. `tool` is the document's tool call.
|
|
84
|
+
*
|
|
85
|
+
* A tool the host's UI configuration denies (`tool:<id>` hidden or disabled) is never active:
|
|
86
|
+
* `KitEditorProvider` gives the check (`setDenied`), and choosing the tool, the engine's
|
|
87
|
+
* `switchTool` request, and `options.initial` all refuse it. When the configuration comes to
|
|
88
|
+
* deny the active tool, the first allowed engine tool (outside `options.hidden`) takes its
|
|
89
|
+
* place, or the hand tool when there is none.
|
|
90
|
+
*/
|
|
91
|
+
export declare function useEngineTools(tool: ToolCall, ready: boolean, change: KitChange, options: EngineToolsOptions): {
|
|
92
|
+
tools: EngineToolInfo[];
|
|
93
|
+
active: string;
|
|
94
|
+
select: (id: string) => void;
|
|
95
|
+
setDenied: (check: ToolDenied) => void;
|
|
96
|
+
refresh: () => void;
|
|
97
|
+
viewZoom: (next: number) => void;
|
|
98
|
+
typeText: (text: string) => void;
|
|
99
|
+
canvasTool: KitTool;
|
|
100
|
+
decorate: RasterDecoration | null;
|
|
101
|
+
status: string | null;
|
|
102
|
+
wantsText: boolean;
|
|
103
|
+
keyDown: (event: {
|
|
104
|
+
key: string;
|
|
105
|
+
shiftKey: boolean;
|
|
106
|
+
altKey: boolean;
|
|
107
|
+
metaKey: boolean;
|
|
108
|
+
ctrlKey: boolean;
|
|
109
|
+
}) => boolean;
|
|
110
|
+
toolForKey: (key: string, shift: boolean) => string | null;
|
|
111
|
+
};
|
|
112
|
+
/** The `KeyboardEvent.code` a printable key comes from on a US layout, for replayed keys. */
|
|
113
|
+
export declare function keyCode(key: string): string;
|
|
114
|
+
/** The page's `--kit-primary` (the kit's brand, or the host's), following theme changes; `null` unset. */
|
|
115
|
+
export declare function useThemeAccent(): string | null;
|
|
116
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An agent's draft of the open document (Kit UI protocol section 7d; standard 2.0 A12 to A15): a
|
|
3
|
+
* second engine, in its own worker, on a fork of the document's replica. The agent's `ai/*` calls
|
|
4
|
+
* with `draft: true` run there; the live document stays as it is until the person merges the
|
|
5
|
+
* draft (its changes since the fork, taken into the document as one undo step labelled as the
|
|
6
|
+
* agent's) or discards it. The draft lives in this page only: in a co-edited document it is the
|
|
7
|
+
* person's own, and the room sees nothing of it until it is merged.
|
|
8
|
+
*/
|
|
9
|
+
import type { DraftComparison, DraftInfo, DraftOrigin, DraftSummary } from '@kition/kit-ui-protocol';
|
|
10
|
+
import type { KitEngine } from './kitEngine.js';
|
|
11
|
+
/** What a draft needs from the live document (`useKitDocument`'s `draft`). */
|
|
12
|
+
export type KitDraftHost = {
|
|
13
|
+
/** Starts the draft's engine on a fork of the document; `base` is the version it forked at. */
|
|
14
|
+
open: () => Promise<{
|
|
15
|
+
engine: KitEngine;
|
|
16
|
+
base: ArrayBuffer;
|
|
17
|
+
}>;
|
|
18
|
+
merge: (changes: ArrayBuffer, blobs: ArrayBuffer, origin: DraftOrigin, schema: object | null) => Promise<DraftSummary>;
|
|
19
|
+
compare: (changes: ArrayBuffer, schema: object | null) => Promise<DraftSummary>;
|
|
20
|
+
/** A PNG of the live document (base64), or null when its engine cannot render. */
|
|
21
|
+
preview: (maxSize: number) => Promise<string | null>;
|
|
22
|
+
/** Hears every change of the draft's state (`draft/changed`). */
|
|
23
|
+
changed: (info: DraftInfo) => void;
|
|
24
|
+
};
|
|
25
|
+
/** The whole document as a PNG, at most `maxSize` pixels on its longer side, as base64. */
|
|
26
|
+
export declare function previewPng(engine: KitEngine, maxSize: number): Promise<string>;
|
|
27
|
+
/** The draft of one open document. Calls are answered in the order they are made. */
|
|
28
|
+
export declare class KitDraft {
|
|
29
|
+
private readonly host;
|
|
30
|
+
private current;
|
|
31
|
+
private queue;
|
|
32
|
+
private closed;
|
|
33
|
+
constructor(host: KitDraftHost);
|
|
34
|
+
/** The draft's state now. */
|
|
35
|
+
info(): DraftInfo;
|
|
36
|
+
/** Runs `work` after the calls made before it. */
|
|
37
|
+
private serial;
|
|
38
|
+
private tell;
|
|
39
|
+
private need;
|
|
40
|
+
/**
|
|
41
|
+
* The draft's engine, opened now when `create` and there is none. Work on it moves a ready draft
|
|
42
|
+
* back to the agent (`open`).
|
|
43
|
+
*/
|
|
44
|
+
engine(create: boolean): Promise<KitEngine>;
|
|
45
|
+
/** The agent changed the draft: it is the agent's again, and the host hears the new revision. */
|
|
46
|
+
edited(): void;
|
|
47
|
+
/** The agent asks for review. */
|
|
48
|
+
ready(): Promise<DraftInfo>;
|
|
49
|
+
/** Sends the draft back to the agent. */
|
|
50
|
+
reopen(): Promise<DraftInfo>;
|
|
51
|
+
/** The draft's changes since it was forked, with their blobs. */
|
|
52
|
+
private changes;
|
|
53
|
+
/** The comparison of the draft with the document now: what merging it changes, and both rendered. */
|
|
54
|
+
compare(maxSize: number, schema: object | null): Promise<DraftComparison>;
|
|
55
|
+
/**
|
|
56
|
+
* Takes the draft into the document as one undo step recorded as `origin`, and closes it. Only
|
|
57
|
+
* on the person's explicit approval (the host's to ensure); never a model's call.
|
|
58
|
+
*/
|
|
59
|
+
merge(origin: DraftOrigin, schema: object | null): Promise<{
|
|
60
|
+
merged: boolean;
|
|
61
|
+
summary: DraftSummary;
|
|
62
|
+
}>;
|
|
63
|
+
/** Drops the draft; the document is untouched. */
|
|
64
|
+
discard(): Promise<DraftInfo>;
|
|
65
|
+
private close;
|
|
66
|
+
/** The document's editor is (again) in use: drafts may open. */
|
|
67
|
+
attach(): void;
|
|
68
|
+
/** The document closed: the draft goes with it (drafts are local, section 7d). */
|
|
69
|
+
dispose(): void;
|
|
70
|
+
}
|