@sqsoffice/slide 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/LICENSE +202 -0
- package/README.md +81 -2
- package/dist/THIRD-PARTY-NOTICES.txt +19871 -0
- package/dist/api-CLyi4j4N.js +4030 -0
- package/dist/api.js +1 -0
- package/dist/assets/engine/files-worker.js +1 -0
- package/dist/assets/engine/host-artifact-jgAXg8CH.js +1 -0
- package/dist/assets/engine/host-load-wasm-DyYR5qIL.js +1 -0
- package/dist/assets/engine/host-manifest.json +42 -0
- package/dist/assets/engine/host-pdf-import-BOPMPpUS.js +1 -0
- package/dist/assets/engine/host.js +1 -0
- package/dist/assets/engine/manifest.json +66 -0
- package/dist/assets/engine/office_web.js +1491 -0
- package/dist/assets/engine/office_web_bg.wasm +4 -0
- package/dist/assets/engine/worker.js +1 -0
- package/dist/assets/fonts/source-han-sans/2.005/LICENSE.txt +96 -0
- package/dist/assets/fonts/source-han-sans/2.005/SourceHanSansCN-Bold.otf +0 -0
- package/dist/assets/fonts/source-han-sans/2.005/SourceHanSansCN-Regular.otf +0 -0
- package/dist/assets/fonts/source-han-sans/2.005/manifest.json +20 -0
- package/dist/index.js +835 -0
- package/dist/package-manifest.json +181 -0
- package/dist/style.css +2 -0
- package/dist/types/app/lib/automation/protocol.d.ts +25 -0
- package/dist/types/app/lib/engine/client.d.ts +129 -0
- package/dist/types/app/lib/engine/docx.d.ts +67 -0
- package/dist/types/app/lib/engine/grid.d.ts +330 -0
- package/dist/types/app/lib/engine/image.d.ts +15 -0
- package/dist/types/app/lib/engine/markdown.d.ts +220 -0
- package/dist/types/app/lib/engine/pdf-import.d.ts +18 -0
- package/dist/types/app/lib/engine/pdf-ocr.d.ts +70 -0
- package/dist/types/app/lib/engine/pdf-output.d.ts +22 -0
- package/dist/types/app/lib/engine/pdf.d.ts +191 -0
- package/dist/types/app/lib/engine/presentation-clipboard.d.ts +26 -0
- package/dist/types/app/lib/engine/presentation-media.d.ts +156 -0
- package/dist/types/app/lib/engine/presentation.d.ts +145 -0
- package/dist/types/app/lib/engine/printing.d.ts +91 -0
- package/dist/types/app/lib/engine/protocol.d.ts +233 -0
- package/dist/types/app/lib/engine/script.d.ts +46 -0
- package/dist/types/app/lib/engine/sheet-clipboard.d.ts +42 -0
- package/dist/types/app/lib/engine/sheet-validation.d.ts +19 -0
- package/dist/types/app/lib/engine/view.d.ts +186 -0
- package/dist/types/app/lib/files/session.d.ts +114 -0
- package/dist/types/app/lib/files/storage.d.ts +20 -0
- package/dist/types/packages/slide/api.d.ts +4 -0
- package/dist/types/packages/slide/index.d.ts +5 -0
- package/dist/types/sdk/types.d.ts +59 -0
- package/package.json +40 -3
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { TextInput, TextSelection, ViewRequest, ViewResult } from './view';
|
|
2
|
+
import type { ScriptReplay, ScriptRequest, ScriptResult } from './script';
|
|
3
|
+
import type { McpRequest, McpResult } from '../automation/protocol';
|
|
4
|
+
import type { SourceInput, SourceInputResult, SourceSelectionHistory } from './markdown';
|
|
5
|
+
import type { SheetClipboardRequest, SheetClipboardResult } from './sheet-clipboard';
|
|
6
|
+
import type { PresentationClipboardRequest, PresentationClipboardResult } from './presentation-clipboard';
|
|
7
|
+
import type { SheetValidationPolicy, SheetValidationReport } from './sheet-validation';
|
|
8
|
+
import type { PdfImportRequest, PdfImportResult } from './pdf-import';
|
|
9
|
+
export type Json = null | boolean | number | string | Json[] | {
|
|
10
|
+
[key: string]: Json;
|
|
11
|
+
};
|
|
12
|
+
export type Command = {
|
|
13
|
+
kind: string;
|
|
14
|
+
[key: string]: Json;
|
|
15
|
+
};
|
|
16
|
+
export type CommandResponse = {
|
|
17
|
+
kind: 'read';
|
|
18
|
+
revision: number;
|
|
19
|
+
value: Json;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'error';
|
|
22
|
+
code: string;
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
export interface CalculationEnvironment {
|
|
26
|
+
seconds: string;
|
|
27
|
+
nanos: number;
|
|
28
|
+
offset: number;
|
|
29
|
+
seed: string;
|
|
30
|
+
activeCell?: {
|
|
31
|
+
sheet: number;
|
|
32
|
+
row: number;
|
|
33
|
+
column: number;
|
|
34
|
+
};
|
|
35
|
+
locale?: 'zh-CN' | 'en-US' | 'de-DE' | 'en-GB' | 'fr-FR';
|
|
36
|
+
validationPolicy?: SheetValidationPolicy;
|
|
37
|
+
}
|
|
38
|
+
export interface ArtifactManifest {
|
|
39
|
+
kind: 'manifest';
|
|
40
|
+
revision: number;
|
|
41
|
+
format: 'docx' | 'sds' | 'xlsx' | 'sxs' | 'pptx' | 'pdf' | 'markdown' | 'text' | 'svg' | 'image';
|
|
42
|
+
main: string;
|
|
43
|
+
files: {
|
|
44
|
+
relative_path: string;
|
|
45
|
+
role: 'main' | 'raw' | 'asset';
|
|
46
|
+
bytes: number;
|
|
47
|
+
sha256: string;
|
|
48
|
+
}[];
|
|
49
|
+
report: Json;
|
|
50
|
+
}
|
|
51
|
+
export interface SaveReceipt {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
manifest: ArtifactManifest;
|
|
55
|
+
}
|
|
56
|
+
export interface PreparedSave extends SaveReceipt {
|
|
57
|
+
files: ArrayBuffer[];
|
|
58
|
+
}
|
|
59
|
+
export type ExportFormat = 'docx' | 'sds' | 'xlsx' | 'sxs' | 'pptx' | 'pdf' | 'markdown' | 'markdown_bundle' | 'text' | 'html' | 'original' | 'png';
|
|
60
|
+
export interface CopyExport {
|
|
61
|
+
bytes: ArrayBuffer;
|
|
62
|
+
report: Json;
|
|
63
|
+
}
|
|
64
|
+
export type HistoryAction = 'undo' | 'redo';
|
|
65
|
+
export type ReplayEntry = {
|
|
66
|
+
environment: CalculationEnvironment;
|
|
67
|
+
revision: number;
|
|
68
|
+
validationConfirmed?: boolean;
|
|
69
|
+
} & ({
|
|
70
|
+
kind: 'command';
|
|
71
|
+
command: Command;
|
|
72
|
+
sourceSelection?: SourceSelectionHistory;
|
|
73
|
+
} | {
|
|
74
|
+
kind: 'history';
|
|
75
|
+
action: HistoryAction;
|
|
76
|
+
} | {
|
|
77
|
+
kind: 'save';
|
|
78
|
+
receipt: SaveReceipt;
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'script';
|
|
81
|
+
replay: ScriptReplay;
|
|
82
|
+
} | {
|
|
83
|
+
kind: 'pdf_import';
|
|
84
|
+
request: PdfImportRequest;
|
|
85
|
+
} | {
|
|
86
|
+
kind: 'sheet_clipboard';
|
|
87
|
+
request: Exclude<SheetClipboardRequest, {
|
|
88
|
+
action: 'inspect';
|
|
89
|
+
}>;
|
|
90
|
+
} | {
|
|
91
|
+
kind: 'presentation_clipboard';
|
|
92
|
+
request: Exclude<PresentationClipboardRequest, {
|
|
93
|
+
action: 'inspect';
|
|
94
|
+
}>;
|
|
95
|
+
});
|
|
96
|
+
/** Explicitly bump this when confirmed operations cannot be replayed compatibly. */
|
|
97
|
+
export declare const ENGINE_REPLAY_VERSION: number;
|
|
98
|
+
export declare const ENGINE_PROTOCOL_VERSION: number;
|
|
99
|
+
export type Operation = {
|
|
100
|
+
kind: 'open';
|
|
101
|
+
name: string;
|
|
102
|
+
bytes: ArrayBuffer;
|
|
103
|
+
password?: string;
|
|
104
|
+
} | {
|
|
105
|
+
kind: 'command';
|
|
106
|
+
command: Command;
|
|
107
|
+
} | {
|
|
108
|
+
kind: 'view';
|
|
109
|
+
request: ViewRequest;
|
|
110
|
+
} | {
|
|
111
|
+
kind: 'input';
|
|
112
|
+
input: TextInput | SourceInput;
|
|
113
|
+
} | {
|
|
114
|
+
kind: 'script';
|
|
115
|
+
request: ScriptRequest;
|
|
116
|
+
} | {
|
|
117
|
+
kind: 'mcp';
|
|
118
|
+
request: McpRequest;
|
|
119
|
+
} | {
|
|
120
|
+
kind: 'history';
|
|
121
|
+
action: HistoryAction;
|
|
122
|
+
} | {
|
|
123
|
+
kind: 'sheet_clipboard';
|
|
124
|
+
request: SheetClipboardRequest;
|
|
125
|
+
} | {
|
|
126
|
+
kind: 'presentation_clipboard';
|
|
127
|
+
request: PresentationClipboardRequest;
|
|
128
|
+
} | {
|
|
129
|
+
kind: 'pdf_import';
|
|
130
|
+
request: PdfImportRequest;
|
|
131
|
+
} | {
|
|
132
|
+
kind: 'export';
|
|
133
|
+
} | {
|
|
134
|
+
kind: 'export_copy';
|
|
135
|
+
format: ExportFormat;
|
|
136
|
+
} | {
|
|
137
|
+
kind: 'prepare_save';
|
|
138
|
+
id: string;
|
|
139
|
+
name: string;
|
|
140
|
+
} | {
|
|
141
|
+
kind: 'commit_save';
|
|
142
|
+
receipt: SaveReceipt;
|
|
143
|
+
} | {
|
|
144
|
+
kind: 'read_save';
|
|
145
|
+
receipt: SaveReceipt;
|
|
146
|
+
} | {
|
|
147
|
+
kind: 'discard_save';
|
|
148
|
+
id: string;
|
|
149
|
+
};
|
|
150
|
+
export interface Correlation {
|
|
151
|
+
id: number;
|
|
152
|
+
generation: number;
|
|
153
|
+
revision: number;
|
|
154
|
+
}
|
|
155
|
+
export type WorkerInput = (Correlation & {
|
|
156
|
+
kind: 'run';
|
|
157
|
+
operation: Operation;
|
|
158
|
+
cancellation?: SharedArrayBuffer;
|
|
159
|
+
environment: CalculationEnvironment;
|
|
160
|
+
}) | (Correlation & {
|
|
161
|
+
kind: 'accept' | 'discard';
|
|
162
|
+
confirmValidation?: boolean;
|
|
163
|
+
}) | {
|
|
164
|
+
kind: 'restore';
|
|
165
|
+
generation: number;
|
|
166
|
+
source?: {
|
|
167
|
+
name: string;
|
|
168
|
+
bytes: ArrayBuffer;
|
|
169
|
+
};
|
|
170
|
+
entries: ReplayEntry[];
|
|
171
|
+
revision: number;
|
|
172
|
+
save?: {
|
|
173
|
+
receipt: SaveReceipt;
|
|
174
|
+
environment: CalculationEnvironment;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
export type WorkerOutput = {
|
|
178
|
+
kind: 'ready';
|
|
179
|
+
engine: string;
|
|
180
|
+
protocolVersion: number;
|
|
181
|
+
replayVersion: number;
|
|
182
|
+
} | {
|
|
183
|
+
kind: 'restored';
|
|
184
|
+
generation: number;
|
|
185
|
+
revision: number;
|
|
186
|
+
} | {
|
|
187
|
+
kind: 'fatal';
|
|
188
|
+
code: string;
|
|
189
|
+
message: string;
|
|
190
|
+
} | (Correlation & {
|
|
191
|
+
kind: 'running';
|
|
192
|
+
}) | (Correlation & {
|
|
193
|
+
kind: 'prepared';
|
|
194
|
+
response?: CommandResponse;
|
|
195
|
+
bytes?: ArrayBuffer;
|
|
196
|
+
copyExport?: CopyExport;
|
|
197
|
+
save?: PreparedSave;
|
|
198
|
+
view?: ViewResult;
|
|
199
|
+
input?: {
|
|
200
|
+
command: Command | null;
|
|
201
|
+
selection: TextSelection | SourceInputResult;
|
|
202
|
+
sourceSelection?: SourceSelectionHistory;
|
|
203
|
+
warnings?: string[];
|
|
204
|
+
};
|
|
205
|
+
script?: ScriptResult;
|
|
206
|
+
mcp?: McpResult;
|
|
207
|
+
clipboard?: SheetClipboardResult;
|
|
208
|
+
presentationClipboard?: PresentationClipboardResult;
|
|
209
|
+
pdfImport?: PdfImportResult;
|
|
210
|
+
calculationEnvironment?: CalculationEnvironment;
|
|
211
|
+
validation?: SheetValidationReport;
|
|
212
|
+
error?: {
|
|
213
|
+
code: string;
|
|
214
|
+
message: string;
|
|
215
|
+
};
|
|
216
|
+
calculated: boolean;
|
|
217
|
+
}) | (Correlation & {
|
|
218
|
+
kind: 'committed' | 'discarded';
|
|
219
|
+
calculated: boolean;
|
|
220
|
+
recoveryAllowed?: boolean;
|
|
221
|
+
response?: CommandResponse;
|
|
222
|
+
});
|
|
223
|
+
export declare const ENGINE_LIMITS: {
|
|
224
|
+
readonly sourceBytes: number;
|
|
225
|
+
readonly commandBytes: number;
|
|
226
|
+
readonly queuedTasks: 32;
|
|
227
|
+
readonly queuedBytes: number;
|
|
228
|
+
readonly replayEntries: 1024;
|
|
229
|
+
readonly replayBytes: number;
|
|
230
|
+
readonly artifactBytes: number;
|
|
231
|
+
readonly cancelGraceMs: 400;
|
|
232
|
+
};
|
|
233
|
+
export declare function isWrite(command: Command): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Command, CommandResponse, Json } from './protocol';
|
|
2
|
+
export interface ScriptPermissions {
|
|
3
|
+
read: boolean;
|
|
4
|
+
write: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface ScriptRequest {
|
|
7
|
+
source: string;
|
|
8
|
+
permissions: ScriptPermissions;
|
|
9
|
+
limits?: {
|
|
10
|
+
maxSourceBytes?: number;
|
|
11
|
+
maxDurationMs?: number;
|
|
12
|
+
maxMemoryBytes?: number;
|
|
13
|
+
maxStackBytes?: number;
|
|
14
|
+
maxCalls?: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface ScriptOutcome {
|
|
18
|
+
result: Json | null;
|
|
19
|
+
failure: {
|
|
20
|
+
kind: 'exception' | 'stopped' | 'timed_out' | 'limit_exceeded' | 'engine';
|
|
21
|
+
message: string;
|
|
22
|
+
line: number | null;
|
|
23
|
+
column: number | null;
|
|
24
|
+
stack: string | null;
|
|
25
|
+
} | null;
|
|
26
|
+
saved: string[];
|
|
27
|
+
calls: number;
|
|
28
|
+
elapsed: {
|
|
29
|
+
secs: number;
|
|
30
|
+
nanos: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface ScriptReplay {
|
|
34
|
+
commands: Command[];
|
|
35
|
+
/** Original active sheet/range for deterministic replay of unqualified A1 commands. */
|
|
36
|
+
selection?: Json;
|
|
37
|
+
}
|
|
38
|
+
export interface ScriptResult {
|
|
39
|
+
response: CommandResponse;
|
|
40
|
+
outcome: ScriptOutcome;
|
|
41
|
+
logs: {
|
|
42
|
+
level: 'log' | 'info' | 'warn' | 'error';
|
|
43
|
+
text: string;
|
|
44
|
+
}[];
|
|
45
|
+
replay: ScriptReplay | null;
|
|
46
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Clipboard contents live in the Rust session; requests only identify an immutable capture. */
|
|
2
|
+
export type SheetClipboardRequest = {
|
|
3
|
+
action: 'inspect';
|
|
4
|
+
} | {
|
|
5
|
+
action: 'capture';
|
|
6
|
+
id: string;
|
|
7
|
+
source: {
|
|
8
|
+
sheet_id: number;
|
|
9
|
+
range: string;
|
|
10
|
+
};
|
|
11
|
+
cut: boolean;
|
|
12
|
+
} | {
|
|
13
|
+
action: 'paste';
|
|
14
|
+
id: string;
|
|
15
|
+
destination: {
|
|
16
|
+
sheet_id: number;
|
|
17
|
+
range: string;
|
|
18
|
+
};
|
|
19
|
+
mode?: 'all' | 'values' | 'formulas' | 'formats' | 'column_widths';
|
|
20
|
+
transpose?: boolean;
|
|
21
|
+
skip_blanks?: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
action: 'paste_external';
|
|
24
|
+
id: string;
|
|
25
|
+
destination: {
|
|
26
|
+
sheet_id: number;
|
|
27
|
+
range: string;
|
|
28
|
+
};
|
|
29
|
+
text: string;
|
|
30
|
+
html?: string;
|
|
31
|
+
mode?: 'all' | 'values' | 'formulas' | 'formats' | 'column_widths';
|
|
32
|
+
transpose?: boolean;
|
|
33
|
+
skip_blanks?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export interface SheetClipboardResult {
|
|
36
|
+
id: string;
|
|
37
|
+
rows: number;
|
|
38
|
+
columns: number;
|
|
39
|
+
text?: string;
|
|
40
|
+
html?: string;
|
|
41
|
+
cut?: boolean;
|
|
42
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type SheetValidationPolicy = 'rules' | 'reject' | 'prompt' | 'allow';
|
|
2
|
+
export interface SheetValidationViolation {
|
|
3
|
+
sheet_id: number;
|
|
4
|
+
cell: string;
|
|
5
|
+
rule_id: number;
|
|
6
|
+
title: string;
|
|
7
|
+
message: string;
|
|
8
|
+
alert: 'stop' | 'warning' | 'information';
|
|
9
|
+
show_error: boolean;
|
|
10
|
+
unsupported: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SheetValidationReport {
|
|
13
|
+
total: number;
|
|
14
|
+
enforced_total: number;
|
|
15
|
+
can_override: boolean;
|
|
16
|
+
unsupported: boolean;
|
|
17
|
+
violations: SheetValidationViolation[];
|
|
18
|
+
}
|
|
19
|
+
export type SheetValidationHandler = (report: SheetValidationReport, signal: AbortSignal) => Promise<boolean>;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/** Read-only view data, always bound to the document revision in EngineResult. */
|
|
2
|
+
import type { GridViewRequest, GridViewResult } from './grid';
|
|
3
|
+
import type { DocxCommand, DocxContext } from './docx';
|
|
4
|
+
import type { Json } from './protocol';
|
|
5
|
+
import type { SourceViewRequest, SourceViewResult } from './markdown';
|
|
6
|
+
import type { ImageViewRequest, ImageInfo } from './image';
|
|
7
|
+
import type { PresentationViewRequest, PresentationViewResult } from './presentation';
|
|
8
|
+
import type { PdfViewRequest, PdfViewResult } from './pdf';
|
|
9
|
+
import type { PdfOcrViewRequest, PdfOcrViewResult } from './pdf-ocr';
|
|
10
|
+
import type { PdfOutputViewRequest, PdfOutputViewResult } from './pdf-output';
|
|
11
|
+
import type { PrintViewRequest, PrintViewResult } from './printing';
|
|
12
|
+
import type { PresentationMediaViewRequest, PresentationMediaViewResult } from './presentation-media';
|
|
13
|
+
export interface TextPosition {
|
|
14
|
+
block: string;
|
|
15
|
+
byte_offset: number;
|
|
16
|
+
}
|
|
17
|
+
export interface TextSelection {
|
|
18
|
+
anchor: TextPosition;
|
|
19
|
+
focus: TextPosition;
|
|
20
|
+
following_paragraphs?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface PageInfo {
|
|
23
|
+
index: number;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
missing_glyphs?: boolean;
|
|
27
|
+
section?: number;
|
|
28
|
+
}
|
|
29
|
+
export type TextReviewMode = 'markup' | 'final' | 'original';
|
|
30
|
+
export interface TextReviewState {
|
|
31
|
+
revision: number;
|
|
32
|
+
view_epoch: number;
|
|
33
|
+
review_mode: TextReviewMode;
|
|
34
|
+
read_only: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface TextPageGuides {
|
|
37
|
+
page: number;
|
|
38
|
+
ruler: {
|
|
39
|
+
left: number;
|
|
40
|
+
right: number;
|
|
41
|
+
};
|
|
42
|
+
marks: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
label: string;
|
|
48
|
+
after: boolean;
|
|
49
|
+
}[];
|
|
50
|
+
}
|
|
51
|
+
export interface DocumentLayout {
|
|
52
|
+
revision: number;
|
|
53
|
+
font_epoch: number;
|
|
54
|
+
reset_from: number | null;
|
|
55
|
+
pages: PageInfo[];
|
|
56
|
+
known_pages: number;
|
|
57
|
+
complete: boolean;
|
|
58
|
+
first_caret: TextPosition | null;
|
|
59
|
+
substituted_fonts: string[];
|
|
60
|
+
font_warnings?: string[];
|
|
61
|
+
story?: TextStory;
|
|
62
|
+
view_epoch?: number;
|
|
63
|
+
review_mode?: TextReviewMode;
|
|
64
|
+
read_only?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface TextStory {
|
|
67
|
+
slot: string;
|
|
68
|
+
section: number;
|
|
69
|
+
page: number;
|
|
70
|
+
}
|
|
71
|
+
export interface PageSemantics {
|
|
72
|
+
page: number;
|
|
73
|
+
blocks: {
|
|
74
|
+
id: string;
|
|
75
|
+
role: 'paragraph' | 'heading' | 'list_item' | 'image' | 'formula';
|
|
76
|
+
text: string;
|
|
77
|
+
level?: number;
|
|
78
|
+
alt?: string;
|
|
79
|
+
selection: TextSelection;
|
|
80
|
+
}[];
|
|
81
|
+
truncated: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface ViewRect {
|
|
84
|
+
page: number;
|
|
85
|
+
x: number;
|
|
86
|
+
y: number;
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
}
|
|
90
|
+
export interface SelectionGeometry {
|
|
91
|
+
selection: TextSelection;
|
|
92
|
+
text?: string | null;
|
|
93
|
+
context?: DocxContext;
|
|
94
|
+
format_brush?: Json;
|
|
95
|
+
html?: string;
|
|
96
|
+
story?: TextStory;
|
|
97
|
+
semantics?: PageSemantics;
|
|
98
|
+
guides?: TextPageGuides;
|
|
99
|
+
format?: {
|
|
100
|
+
bold: boolean;
|
|
101
|
+
italic: boolean;
|
|
102
|
+
underline: boolean;
|
|
103
|
+
font_size_half_points?: number | null;
|
|
104
|
+
font?: string;
|
|
105
|
+
};
|
|
106
|
+
rects: ViewRect[];
|
|
107
|
+
caret?: ViewRect | null;
|
|
108
|
+
caret_page?: number;
|
|
109
|
+
}
|
|
110
|
+
export interface TileRequest {
|
|
111
|
+
page: number;
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
width: number;
|
|
115
|
+
height: number;
|
|
116
|
+
scale: number;
|
|
117
|
+
}
|
|
118
|
+
export interface RenderedTile {
|
|
119
|
+
width: number;
|
|
120
|
+
height: number;
|
|
121
|
+
pixels: ArrayBuffer;
|
|
122
|
+
}
|
|
123
|
+
export interface TextInput {
|
|
124
|
+
action: 'insert_text' | 'paste_text' | 'delete_backward' | 'delete_forward' | 'delete_word_backward' | 'delete_word_forward' | 'insert_paragraph' | 'insert_soft_break' | 'insert_page_break' | 'tab' | 'move' | 'select_all' | 'toggle_bold' | 'toggle_italic' | 'toggle_underline' | 'set_font_size' | 'command' | 'object_commands' | 'paste_html' | 'find' | 'story' | 'page_numbers' | 'update_toc';
|
|
125
|
+
selection: TextSelection;
|
|
126
|
+
text?: string;
|
|
127
|
+
direction?: 'left' | 'right' | 'up' | 'down' | 'word_left' | 'word_right' | 'home' | 'end' | 'story_start' | 'story_end' | 'paragraph_up' | 'paragraph_down' | 'page_up' | 'page_down';
|
|
128
|
+
extend?: boolean;
|
|
129
|
+
reverse?: boolean;
|
|
130
|
+
literal?: boolean;
|
|
131
|
+
half_points?: number;
|
|
132
|
+
command?: DocxCommand;
|
|
133
|
+
commands?: DocxCommand[];
|
|
134
|
+
merge_format?: boolean;
|
|
135
|
+
match_case?: boolean;
|
|
136
|
+
index?: number;
|
|
137
|
+
story?: 'body' | 'header' | 'footer' | 'first_header' | 'first_footer' | 'even_header' | 'even_footer';
|
|
138
|
+
page?: number;
|
|
139
|
+
section?: number;
|
|
140
|
+
mode?: 'insert' | 'remove';
|
|
141
|
+
header?: boolean;
|
|
142
|
+
alignment?: 'left' | 'center' | 'right' | 'inside' | 'outside';
|
|
143
|
+
target?: string;
|
|
144
|
+
anchor?: string;
|
|
145
|
+
levels?: number;
|
|
146
|
+
}
|
|
147
|
+
export type ViewRequest = GridViewRequest | SourceViewRequest | ImageViewRequest | PresentationViewRequest | PresentationMediaViewRequest | PdfViewRequest | PdfOcrViewRequest | PdfOutputViewRequest | PrintViewRequest | {
|
|
148
|
+
kind: 'text_review';
|
|
149
|
+
mode?: TextReviewMode;
|
|
150
|
+
} | {
|
|
151
|
+
kind: 'text_objects';
|
|
152
|
+
request: Record<string, Json>;
|
|
153
|
+
} | {
|
|
154
|
+
kind: 'text_statistics';
|
|
155
|
+
includeStories?: boolean;
|
|
156
|
+
selection?: TextSelection;
|
|
157
|
+
reviewMode?: TextReviewMode;
|
|
158
|
+
} | {
|
|
159
|
+
kind: 'layout';
|
|
160
|
+
pageBudget: number;
|
|
161
|
+
reviewMode?: TextReviewMode;
|
|
162
|
+
} | {
|
|
163
|
+
kind: 'tile';
|
|
164
|
+
tile: TileRequest;
|
|
165
|
+
reviewMode?: TextReviewMode;
|
|
166
|
+
} | {
|
|
167
|
+
kind: 'hit';
|
|
168
|
+
page: number;
|
|
169
|
+
x: number;
|
|
170
|
+
y: number;
|
|
171
|
+
reviewMode?: TextReviewMode;
|
|
172
|
+
} | {
|
|
173
|
+
kind: 'selection';
|
|
174
|
+
page: number;
|
|
175
|
+
selection: TextSelection;
|
|
176
|
+
includeHtml?: boolean;
|
|
177
|
+
includeSemantics?: boolean;
|
|
178
|
+
includeGuides?: boolean;
|
|
179
|
+
reviewMode?: TextReviewMode;
|
|
180
|
+
};
|
|
181
|
+
export interface HitResult {
|
|
182
|
+
revision: number;
|
|
183
|
+
caret: TextPosition | null;
|
|
184
|
+
selection?: TextSelection;
|
|
185
|
+
}
|
|
186
|
+
export type ViewResult = Json | TextReviewState | PdfViewResult | PdfOcrViewResult | PdfOutputViewResult | PrintViewResult | DocumentLayout | RenderedTile | HitResult | SelectionGeometry | GridViewResult | SourceViewResult | ImageInfo | PresentationViewResult | PresentationMediaViewResult;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { BrowserEngine, type EngineEvent, type EngineResult, type TaskOptions } from '../engine/client';
|
|
2
|
+
import { type Command, type CommandResponse, type HistoryAction, type Json, type ExportFormat } from '../engine/protocol';
|
|
3
|
+
import type { BrowserFileHandle } from './storage';
|
|
4
|
+
import type { TextInput, TextSelection, ViewRequest, ViewResult } from '../engine/view';
|
|
5
|
+
import type { ScriptRequest, ScriptResult } from '../engine/script';
|
|
6
|
+
import type { McpRequest, McpResult } from '../automation/protocol';
|
|
7
|
+
import type { SourceInput, SourceSelection } from '../engine/markdown';
|
|
8
|
+
import type { SheetClipboardRequest, SheetClipboardResult } from '../engine/sheet-clipboard';
|
|
9
|
+
import type { PresentationClipboardRequest, PresentationClipboardResult } from '../engine/presentation-clipboard';
|
|
10
|
+
import type { SheetValidationHandler, SheetValidationPolicy } from '../engine/sheet-validation';
|
|
11
|
+
type SavePhase = 'idle' | 'permission' | 'preparing' | 'writing' | 'confirming' | 'cancelling' | 'pending';
|
|
12
|
+
export interface FileSessionState {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
dirty: boolean;
|
|
16
|
+
inputPending: boolean;
|
|
17
|
+
revision: number;
|
|
18
|
+
canUndo?: boolean;
|
|
19
|
+
canRedo?: boolean;
|
|
20
|
+
sourceFormat?: string;
|
|
21
|
+
canSaveSource?: boolean;
|
|
22
|
+
importReport?: Json;
|
|
23
|
+
recoveryAllowed?: boolean;
|
|
24
|
+
savePhase: SavePhase;
|
|
25
|
+
saveError?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Optional host restrictions are applied before work enters the document Worker. */
|
|
28
|
+
export interface FileSessionAccess {
|
|
29
|
+
readOnly: boolean;
|
|
30
|
+
checkFile(name: string): void;
|
|
31
|
+
checkCommand(command: Command): void;
|
|
32
|
+
checkView(request: ViewRequest): void;
|
|
33
|
+
}
|
|
34
|
+
export interface BrowserFileSessionOptions {
|
|
35
|
+
assetBase?: string;
|
|
36
|
+
access?: FileSessionAccess;
|
|
37
|
+
}
|
|
38
|
+
/** Browser permissions/publication stay outside the Rust document and its history. */
|
|
39
|
+
export declare class BrowserFileSession {
|
|
40
|
+
private validationHandler?;
|
|
41
|
+
requestPassword?: (name: string, retry: boolean) => Promise<string | undefined>;
|
|
42
|
+
confirmDiscard?: (name: string) => Promise<boolean>;
|
|
43
|
+
private engine;
|
|
44
|
+
readonly assetBase: string;
|
|
45
|
+
private readonly access?;
|
|
46
|
+
private detachEngine?;
|
|
47
|
+
private listeners;
|
|
48
|
+
private lifecycle;
|
|
49
|
+
private handle?;
|
|
50
|
+
private baseline?;
|
|
51
|
+
private publication?;
|
|
52
|
+
private fileAction;
|
|
53
|
+
private deferFilePublication;
|
|
54
|
+
private deferredFileEvent?;
|
|
55
|
+
private selection;
|
|
56
|
+
private detachSelection?;
|
|
57
|
+
private closed;
|
|
58
|
+
private value;
|
|
59
|
+
beforeFileChange?: () => Promise<void>;
|
|
60
|
+
whenIdle(): Promise<void>;
|
|
61
|
+
constructor(options?: BrowserFileSessionOptions);
|
|
62
|
+
get state(): Readonly<FileSessionState>;
|
|
63
|
+
get changingFile(): boolean;
|
|
64
|
+
/** UI input has not reached the engine yet and must still prevent accidental navigation. */
|
|
65
|
+
setInputPending(pending: boolean, documentId: string): void;
|
|
66
|
+
cancelOpen(): void;
|
|
67
|
+
subscribe(listener: (state: FileSessionState, event?: EngineEvent) => void): () => void;
|
|
68
|
+
private emit;
|
|
69
|
+
private attach;
|
|
70
|
+
private check;
|
|
71
|
+
private checkChanging;
|
|
72
|
+
private checkWritable;
|
|
73
|
+
private beginSelection;
|
|
74
|
+
private checkSelection;
|
|
75
|
+
private status;
|
|
76
|
+
command(command: Command, options?: TaskOptions): Promise<EngineResult<CommandResponse>>;
|
|
77
|
+
history(action: HistoryAction, options?: TaskOptions): Promise<EngineResult<CommandResponse>>;
|
|
78
|
+
sheetClipboard(request: SheetClipboardRequest, options?: TaskOptions): Promise<EngineResult<SheetClipboardResult>>;
|
|
79
|
+
get inputLocale(): NonNullable<"zh-CN" | "en-US" | "de-DE" | "en-GB" | "fr-FR" | undefined>;
|
|
80
|
+
importPdfPages(request: import('../engine/pdf-import').PdfImportRequest, options?: TaskOptions): Promise<EngineResult<import('../engine/pdf-import').PdfImportResult>>;
|
|
81
|
+
presentationClipboard(request: PresentationClipboardRequest, options?: TaskOptions): Promise<EngineResult<PresentationClipboardResult>>;
|
|
82
|
+
setInputLocale(locale: Parameters<BrowserEngine['setInputLocale']>[0]): void;
|
|
83
|
+
get validationPolicy(): SheetValidationPolicy;
|
|
84
|
+
setValidationPolicy(policy: SheetValidationPolicy): void;
|
|
85
|
+
setValidationHandler(handler?: SheetValidationHandler): void;
|
|
86
|
+
view<T extends ViewResult>(request: ViewRequest, options?: TaskOptions): Promise<EngineResult<T>>;
|
|
87
|
+
input<T extends TextSelection | SourceSelection = TextSelection>(input: TextInput | SourceInput, options?: TaskOptions): Promise<EngineResult<T>>;
|
|
88
|
+
openFile(file: File, handle?: BrowserFileHandle): Promise<void>;
|
|
89
|
+
runScript(request: ScriptRequest, options?: TaskOptions): Promise<EngineResult<ScriptResult>>;
|
|
90
|
+
runMcp(request: McpRequest, options?: TaskOptions): Promise<EngineResult<McpResult>>;
|
|
91
|
+
authenticatePdf(password: string): Promise<void>;
|
|
92
|
+
private openSelectedFile;
|
|
93
|
+
pickFile(beforeOpen?: () => Promise<void>): Promise<void>;
|
|
94
|
+
openDrop(data: DataTransfer, signal?: AbortSignal): Promise<void>;
|
|
95
|
+
openDirectory(files: File[], signal?: AbortSignal): Promise<void>;
|
|
96
|
+
pickDirectory(signal?: AbortSignal): Promise<void>;
|
|
97
|
+
/** Acquire browser permission in the user's click before flushing queued UI input. */
|
|
98
|
+
pickSaveTarget(): Promise<BrowserFileHandle>;
|
|
99
|
+
save(target?: BrowserFileHandle, signal?: AbortSignal): Promise<{
|
|
100
|
+
published: boolean;
|
|
101
|
+
confirmed: boolean;
|
|
102
|
+
}>;
|
|
103
|
+
private confirm;
|
|
104
|
+
resumeSave(): Promise<void>;
|
|
105
|
+
recover(): Promise<void>;
|
|
106
|
+
cancelPendingSave(): Promise<void>;
|
|
107
|
+
downloadCopy(): Promise<void>;
|
|
108
|
+
downloadExportCopy(format: ExportFormat): Promise<Json>;
|
|
109
|
+
bindLifecycle(target?: Window): () => void;
|
|
110
|
+
close(options?: {
|
|
111
|
+
discard?: boolean;
|
|
112
|
+
}): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Browser-granted file handles and in-memory save publication metadata. */
|
|
2
|
+
export interface BrowserFileHandle extends FileSystemFileHandle {
|
|
3
|
+
queryPermission?(descriptor: {
|
|
4
|
+
mode: 'read' | 'readwrite';
|
|
5
|
+
}): Promise<PermissionState>;
|
|
6
|
+
requestPermission?(descriptor: {
|
|
7
|
+
mode: 'read' | 'readwrite';
|
|
8
|
+
}): Promise<PermissionState>;
|
|
9
|
+
}
|
|
10
|
+
export interface FileFingerprint {
|
|
11
|
+
bytes: number;
|
|
12
|
+
modified: number;
|
|
13
|
+
sha256: string;
|
|
14
|
+
}
|
|
15
|
+
export interface FilePublication {
|
|
16
|
+
stage: 'prepared' | 'published';
|
|
17
|
+
handle: BrowserFileHandle;
|
|
18
|
+
before: FileFingerprint;
|
|
19
|
+
after?: FileFingerprint;
|
|
20
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MountOptions, MountedOffice } from '../../sdk/types';
|
|
2
|
+
export * from './api';
|
|
3
|
+
export type { MountOptions, MountedOffice } from '../../sdk/types';
|
|
4
|
+
/** Mount into an empty element with an explicit height. */
|
|
5
|
+
export declare function mount(container: Element | string, options?: MountOptions): Promise<MountedOffice<'slide'>>;
|