@file-viewer/core 3.1.1 → 3.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.en.md +3 -121
- package/README.md +3 -126
- package/dist/assets.d.ts +2 -2
- package/dist/assets.js +1 -5
- package/dist/browser/controller.d.ts +1 -2
- package/dist/browser/controller.js +2 -34
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/config/options.d.ts +1 -1
- package/dist/contracts/types.d.ts +30 -416
- package/dist/contracts/xml.d.ts +48 -0
- package/dist/contracts/xml.js +1 -0
- package/dist/export.d.ts +3 -10
- package/dist/export.js +2 -9
- package/dist/exportDocument.d.ts +1 -12
- package/dist/exportDocument.js +7 -31
- package/dist/features/document/dom/anchors.d.ts +1 -1
- package/dist/features/document/dom/index.d.ts +5 -5
- package/dist/features/document/dom/index.js +3 -3
- package/dist/features/document/dom/providers.d.ts +1 -1
- package/dist/features/document/events.d.ts +2 -2
- package/dist/features/document/events.js +3 -3
- package/dist/features/document/fit.d.ts +1 -1
- package/dist/features/document/fit.js +1 -1
- package/dist/features/document/model.d.ts +1 -1
- package/dist/features/document/search.d.ts +1 -1
- package/dist/features/document/search.js +2 -2
- package/dist/features/document/viewState.d.ts +1 -1
- package/dist/features/document/viewState.js +2 -2
- package/dist/features/document/zoom.d.ts +3 -2
- package/dist/features/document/zoom.js +19 -3
- package/dist/features/document/zoomGestures.d.ts +11 -0
- package/dist/features/document/zoomGestures.js +111 -0
- package/dist/features/printMask.d.ts +1 -1
- package/dist/features/printMaskDesigner.d.ts +2 -6
- package/dist/features/printMaskDesigner.js +2 -11
- package/dist/features/printMaskLoader.d.ts +1 -7
- package/dist/features/printMaskLoader.js +1 -7
- package/dist/features/watermark.d.ts +1 -1
- package/dist/headless.d.ts +29 -29
- package/dist/headless.js +16 -21
- package/dist/i18n/messages.d.ts +1 -1
- package/dist/i18n/messages.de.d.ts +1 -5
- package/dist/i18n/messages.de.js +0 -4
- package/dist/i18n/messages.ja.d.ts +1 -6
- package/dist/i18n/messages.ja.js +0 -5
- package/dist/i18n/messages.js +2 -2
- package/dist/index.d.ts +74 -73
- package/dist/index.js +37 -37
- package/dist/lifecycle/facade.d.ts +4 -4
- package/dist/lifecycle/facade.js +2 -2
- package/dist/lifecycle/operations.d.ts +4 -4
- package/dist/lifecycle/operations.js +4 -9
- package/dist/output/canvasImage.d.ts +1 -2
- package/dist/output/canvasImage.js +1 -4
- package/dist/output/export.d.ts +2 -4
- package/dist/output/export.js +133 -81
- package/dist/output/printLayout.d.ts +2 -5
- package/dist/output/printLayout.js +37 -9
- package/dist/output/snapshotDownload.d.ts +1 -2
- package/dist/output/snapshotDownload.js +2 -3
- package/dist/platform/assets.d.ts +9 -16
- package/dist/platform/assets.js +60 -17
- package/dist/platform/copiedAssets.d.ts +0 -1
- package/dist/platform/copiedAssets.js +1 -2
- package/dist/presentation/state.d.ts +1 -1
- package/dist/presentation/state.js +3 -3
- package/dist/print-mask.d.ts +2 -2
- package/dist/print-mask.js +1 -1
- package/dist/registry/capabilities.d.ts +3 -16
- package/dist/registry/capabilities.js +2 -15
- package/dist/registry/formats.d.ts +5 -5
- package/dist/registry/formats.generated.d.ts +26 -8
- package/dist/registry/formats.generated.js +36 -4
- package/dist/registry/formats.js +2 -2
- package/dist/registry/registry.d.ts +6 -15
- package/dist/registry/registry.js +24 -10
- package/dist/renderers/image.d.ts +1 -1
- package/dist/renderers/image.js +26 -5
- package/dist/renderers/index.d.ts +30 -11
- package/dist/renderers/index.js +5 -11
- package/dist/rendering/dispatcher.d.ts +1 -6
- package/dist/rendering/dispatcher.js +3 -3
- package/dist/rendering/handler.d.ts +10 -15
- package/dist/rendering/handler.js +20 -27
- package/dist/security/svgResources.d.ts +0 -10
- package/dist/security/svgResources.js +2 -11
- package/dist/source/index.d.ts +3 -3
- package/dist/source/index.js +1 -1
- package/dist/source/loading.d.ts +56 -15
- package/dist/source/loading.js +177 -87
- package/dist/source/precheck.d.ts +1 -13
- package/dist/source/precheck.js +2 -9
- package/dist/source/textEncoding.d.ts +6 -3
- package/dist/source/textEncoding.js +58 -8
- package/dist/viewer/createViewer.d.ts +1 -1
- package/dist/viewer/createViewer.js +103 -33
- package/dist/viewer/loading.d.ts +2 -6
- package/dist/viewer/loading.js +1 -9
- package/dist/viewer/operations.d.ts +3 -3
- package/dist/viewer/operations.js +6 -14
- package/dist/viewer/state.d.ts +2 -6
- package/dist/viewer/state.js +3 -8
- package/package.json +127 -19
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FileViewerXmlOptions } from "./xml.js";
|
|
1
2
|
export type FileViewerSourceKind = 'file' | 'url' | 'buffer' | 'empty';
|
|
2
3
|
export type FileViewerThemeMode = 'light' | 'dark' | 'system';
|
|
3
4
|
export type FileViewerResolvedThemeMode = Exclude<FileViewerThemeMode, 'system'>;
|
|
@@ -49,13 +50,9 @@ export interface FileViewerToolbarOptions {
|
|
|
49
50
|
exportHtml?: boolean;
|
|
50
51
|
zoom?: boolean;
|
|
51
52
|
search?: boolean;
|
|
52
|
-
/** Shows a manual light/dark mode toggle without changing the host page theme. */
|
|
53
53
|
theme?: boolean;
|
|
54
|
-
/** Built-in toolbar group order. Missing entries keep their default relative order. */
|
|
55
54
|
order?: FileViewerToolbarItem[];
|
|
56
|
-
/** Controls which built-in toolbar actions are displayed without disabling controller APIs. */
|
|
57
55
|
items?: FileViewerToolbarActionMap;
|
|
58
|
-
/** Hard operation permission map. False values block both built-in toolbar and public API calls. */
|
|
59
56
|
permissions?: FileViewerToolbarActionMap;
|
|
60
57
|
position?: FileViewerToolbarPosition;
|
|
61
58
|
beforeOperation?: FileViewerBeforeOperation;
|
|
@@ -74,10 +71,6 @@ export interface FileViewerArchiveEntryActionContext {
|
|
|
74
71
|
}
|
|
75
72
|
export type FileViewerArchiveEntryActionPolicy = boolean | ((entry: FileViewerArchiveEntryActionContext) => boolean);
|
|
76
73
|
export interface FileViewerArchiveEntryActionsOptions {
|
|
77
|
-
/**
|
|
78
|
-
* Controls the download button for files opened from inside an archive.
|
|
79
|
-
* The viewer-level original-file download remains controlled by toolbar options.
|
|
80
|
-
*/
|
|
81
74
|
download?: FileViewerArchiveEntryActionPolicy;
|
|
82
75
|
}
|
|
83
76
|
export interface FileViewerArchiveOptions {
|
|
@@ -88,40 +81,20 @@ export interface FileViewerArchiveOptions {
|
|
|
88
81
|
maxArchiveSize?: number;
|
|
89
82
|
maxEntryPreviewSize?: number;
|
|
90
83
|
entryActions?: FileViewerArchiveEntryActionsOptions;
|
|
91
|
-
/**
|
|
92
|
-
* Optional archive password. It is used for the first encrypted archive
|
|
93
|
-
* attempt; if it is wrong, the built-in password dialog or requestPassword
|
|
94
|
-
* callback can still ask the user for a replacement.
|
|
95
|
-
*/
|
|
96
84
|
password?: string;
|
|
97
|
-
/**
|
|
98
|
-
* Custom password request hook for encrypted archives. Return a string to
|
|
99
|
-
* continue, or null/undefined to cancel and surface a friendly error.
|
|
100
|
-
*/
|
|
101
85
|
requestPassword?: (context: FileViewerArchivePasswordRequestContext) => string | null | undefined | Promise<string | null | undefined>;
|
|
102
86
|
}
|
|
103
87
|
export interface FileViewerChmOptions {
|
|
104
|
-
/** Self-hosted module Worker that owns all untrusted CHM parsing and decompression. */
|
|
105
88
|
workerUrl?: string | URL;
|
|
106
|
-
/** Self-hosted wasm-bindgen JavaScript module loaded by the CHM Worker. */
|
|
107
89
|
wasmModuleUrl?: string | URL;
|
|
108
|
-
/** Self-hosted Rust WebAssembly binary loaded by the CHM Worker. */
|
|
109
90
|
wasmUrl?: string | URL;
|
|
110
|
-
/** Maximum time for an individual Worker request. Defaults to 60 seconds. */
|
|
111
91
|
workerTimeoutMs?: number;
|
|
112
|
-
/** Maximum accepted CHM input size. Defaults to 320 MiB. */
|
|
113
92
|
maxArchiveBytes?: number;
|
|
114
|
-
/** Maximum number of virtual files accepted from one CHM. Defaults to 50,000. */
|
|
115
93
|
maxEntries?: number;
|
|
116
|
-
/** Maximum uncompressed size of one virtual file. Defaults to 32 MiB. */
|
|
117
94
|
maxEntryBytes?: number;
|
|
118
|
-
/** Maximum total unique decoded content exposed by the parser. Defaults to 512 MiB. */
|
|
119
95
|
maxTotalDecompressedBytes?: number;
|
|
120
|
-
/** Maximum HTML topic size. Defaults to 16 MiB. */
|
|
121
96
|
maxHtmlBytes?: number;
|
|
122
|
-
/** Maximum topic count scanned by the built-in search. Defaults to 10,000. */
|
|
123
97
|
maxSearchTopics?: number;
|
|
124
|
-
/** Maximum built-in search result count. Defaults to 200. */
|
|
125
98
|
maxSearchResults?: number;
|
|
126
99
|
}
|
|
127
100
|
export type FileViewerArchivePasswordRequestReason = 'encrypted' | 'invalid-password' | 'read-failed' | 'extract-failed';
|
|
@@ -133,84 +106,49 @@ export interface FileViewerArchivePasswordRequestContext {
|
|
|
133
106
|
error?: unknown;
|
|
134
107
|
}
|
|
135
108
|
export interface FileViewerPdfOptions {
|
|
109
|
+
handTool?: boolean;
|
|
136
110
|
toolbar?: boolean;
|
|
137
111
|
navigation?: boolean;
|
|
138
112
|
defaultNavigationVisible?: boolean;
|
|
139
113
|
thumbnails?: boolean;
|
|
140
114
|
rotation?: number;
|
|
141
|
-
/**
|
|
142
|
-
* Highlights and focuses one or more PDF regions after the document loads.
|
|
143
|
-
* Use `pixel` with `sourceWidth` / `sourceHeight` for OCR coordinates, or
|
|
144
|
-
* `pdf-point` for native PDF coordinates. Page numbers are one-based.
|
|
145
|
-
*/
|
|
146
115
|
bbox?: FileViewerPdfBoundingBox | readonly FileViewerPdfBoundingBox[];
|
|
147
|
-
/**
|
|
148
|
-
* Initial PDF view position. Prefer the top-level `initialViewState` when the
|
|
149
|
-
* same state should be passed through framework-neutral viewer APIs.
|
|
150
|
-
*/
|
|
151
116
|
initialViewState?: FileViewerViewState;
|
|
152
117
|
streaming?: boolean | 'same-origin';
|
|
153
118
|
rangeChunkSize?: number;
|
|
154
119
|
withCredentials?: boolean;
|
|
155
|
-
/**
|
|
156
|
-
* Base URL for the self-hosted PDF worker, cMaps, WASM, standard fonts, and
|
|
157
|
-
* CJK fallback fonts. Useful for SPA routes whose document URL is deeper
|
|
158
|
-
* than the deployment public path, for example `/workspace/c/`.
|
|
159
|
-
*/
|
|
160
120
|
assetBaseUrl?: string | URL;
|
|
161
121
|
workerUrl?: string;
|
|
162
122
|
cMapUrl?: string;
|
|
163
123
|
wasmUrl?: string;
|
|
164
124
|
standardFontDataUrl?: string;
|
|
165
|
-
/**
|
|
166
|
-
* Enables the self-hosted CJK fallback used when a PDF references a font
|
|
167
|
-
* such as Microsoft YaHei without embedding the font data. Defaults to true.
|
|
168
|
-
*/
|
|
169
125
|
cjkFontFallback?: boolean;
|
|
170
|
-
/**
|
|
171
|
-
* Repairs malformed Identity-H/V CJK fonts that omit ToUnicode when the PDF
|
|
172
|
-
* also embeds a usable same-family TrueType cmap. Defaults to true. The
|
|
173
|
-
* repair is applied only to the in-memory preview and never changes the
|
|
174
|
-
* original file used by download operations.
|
|
175
|
-
*/
|
|
176
126
|
identityFontRepair?: boolean;
|
|
177
|
-
/**
|
|
178
|
-
* Directory containing `noto-sans-sc.css`, its `files/` font shards, and
|
|
179
|
-
* the bundled font license. The path is resolved against the document base.
|
|
180
|
-
*/
|
|
181
127
|
cjkFontFallbackPath?: string;
|
|
182
128
|
}
|
|
183
129
|
export type FileViewerPdfBoundingBoxUnit = 'ratio' | 'percent' | 'pixel' | 'pdf-point';
|
|
184
130
|
export type FileViewerPdfBoundingBoxOrigin = 'top-left' | 'bottom-left';
|
|
185
131
|
export interface FileViewerPdfBoundingBox {
|
|
186
132
|
id?: string;
|
|
187
|
-
/** One-based PDF page number. Defaults to the current page, then page 1. */
|
|
188
133
|
page?: number;
|
|
189
134
|
x: number;
|
|
190
135
|
y: number;
|
|
191
136
|
width: number;
|
|
192
137
|
height: number;
|
|
193
|
-
/** Defaults to `pdf-point`. */
|
|
194
138
|
unit?: FileViewerPdfBoundingBoxUnit;
|
|
195
|
-
/** Defaults to `bottom-left` for PDF points and `top-left` otherwise. */
|
|
196
139
|
origin?: FileViewerPdfBoundingBoxOrigin;
|
|
197
|
-
/** Required when `unit` is `pixel`; this is the OCR/source image width. */
|
|
198
140
|
sourceWidth?: number;
|
|
199
|
-
/** Required when `unit` is `pixel`; this is the OCR/source image height. */
|
|
200
141
|
sourceHeight?: number;
|
|
201
|
-
/** CSS color used for the outline and translucent fill. */
|
|
202
142
|
color?: string;
|
|
203
|
-
/** Optional accessible description for the highlighted region. */
|
|
204
143
|
label?: string;
|
|
205
144
|
}
|
|
206
145
|
export interface FileViewerDocxOptions {
|
|
207
|
-
|
|
146
|
+
exposeDisplayTargets?: boolean;
|
|
208
147
|
reviewMode?: 'all' | 'final' | 'original';
|
|
209
148
|
worker?: boolean;
|
|
210
149
|
workerUrl?: string;
|
|
211
150
|
workerJsZipUrl?: string;
|
|
212
151
|
progressive?: boolean;
|
|
213
|
-
/** 默认 false,使用连续流式阅读;设为 true 时才启用 DOCX 页式预览。 */
|
|
214
152
|
visualPagination?: boolean;
|
|
215
153
|
workerTimeout?: number;
|
|
216
154
|
renderPageBatchSize?: number;
|
|
@@ -223,41 +161,27 @@ export interface FileViewerDocxOptions {
|
|
|
223
161
|
updatePageReferences?: boolean;
|
|
224
162
|
hideWebHiddenContent?: boolean;
|
|
225
163
|
ignoreLastRenderedPageBreak?: boolean;
|
|
226
|
-
|
|
164
|
+
renderAltChunks?: boolean;
|
|
227
165
|
externalLinkPolicy?: 'allow' | 'block';
|
|
228
|
-
/** Linked DOC/DOCX/RTF image resources are blocked by default; embedded images remain available. */
|
|
229
166
|
externalResourcePolicy?: 'allow' | 'block';
|
|
230
|
-
/** Overrides automatic DOCX dark rendering derived from the viewer theme. */
|
|
231
167
|
darkMode?: boolean;
|
|
232
168
|
}
|
|
233
169
|
export interface FileViewerSpreadsheetOptions {
|
|
234
170
|
worker?: boolean | 'auto';
|
|
235
171
|
workerUrl?: string;
|
|
236
|
-
/** `worker: 'auto'` 时,大于该字节数的表格自动使用静态 Worker,默认 1MB。 */
|
|
237
172
|
workerAutoThreshold?: number;
|
|
238
|
-
/**
|
|
239
|
-
* CSV / TSV 文本编码。默认 `auto`:优先 UTF-8 BOM 和严格 UTF-8,
|
|
240
|
-
* 否则使用浏览器内置 GB18030 解码器(同时覆盖 GBK)。
|
|
241
|
-
*/
|
|
242
173
|
textEncoding?: 'auto' | 'utf-8' | 'gbk' | 'gb18030';
|
|
243
|
-
/** 允许用户在 Excel / CSV / ODS 预览中拖拽表头边界调整列宽,默认关闭以保持历史行为。 */
|
|
244
174
|
resizableColumns?: boolean;
|
|
245
|
-
/** 允许用户在 Excel / CSV / ODS 预览中拖拽行头边界调整行高,默认关闭以保持历史行为。 */
|
|
246
175
|
resizableRows?: boolean;
|
|
176
|
+
fillViewport?: boolean;
|
|
247
177
|
}
|
|
248
178
|
export interface FileViewerPresentationOptions {
|
|
249
|
-
/** PPTX/OpenXML Worker URL. This is independent from the binary-PPT Worker. */
|
|
250
179
|
workerUrl?: string | URL;
|
|
251
180
|
workerType?: WorkerType;
|
|
252
|
-
/** Optional self-hosted native WASM URL used only by the PowerPoint 97–2003 renderer. */
|
|
253
181
|
pptWasmUrl?: string | URL;
|
|
254
|
-
/** Optional self-hosted CJK font-pack URL used only by the PowerPoint 97–2003 renderer. */
|
|
255
182
|
pptFontUrl?: string | URL;
|
|
256
|
-
/** Optional module Worker URL used only by the PowerPoint 97–2003 renderer. */
|
|
257
183
|
pptWorkerUrl?: string | URL;
|
|
258
|
-
/** Selects the binary-PPT Worker path. Defaults to `auto`. */
|
|
259
184
|
pptWorker?: boolean | 'auto';
|
|
260
|
-
/** Controls the binary-PPT bounded IndexedDB frame cache. */
|
|
261
185
|
pptCache?: false | {
|
|
262
186
|
enabled?: boolean;
|
|
263
187
|
dbName?: string;
|
|
@@ -265,63 +189,36 @@ export interface FileViewerPresentationOptions {
|
|
|
265
189
|
maxEntries?: number;
|
|
266
190
|
maxEntryBytes?: number;
|
|
267
191
|
};
|
|
268
|
-
/** Render and retain only binary-PPT slides near the viewport. Defaults to true. */
|
|
269
192
|
pptVirtualize?: boolean;
|
|
270
|
-
/** IntersectionObserver overscan for binary-PPT virtualization. Defaults to `150% 0px`. */
|
|
271
193
|
pptVirtualRootMargin?: string;
|
|
272
|
-
/** Delay before an offscreen binary-PPT canvas is cached and released. Defaults to 1200ms. */
|
|
273
194
|
pptReleaseDelayMs?: number;
|
|
274
|
-
/**
|
|
275
|
-
* Optional ESM entry override for `@file-viewer/ppt`.
|
|
276
|
-
* Full packages and the CDN/IIFE distribution provide a packaged default.
|
|
277
|
-
*/
|
|
278
195
|
pptModuleUrl?: string | URL;
|
|
279
196
|
}
|
|
280
197
|
export type FileViewerIworkEmbeddedPreviewMode = 'never' | 'loading' | 'fallback';
|
|
281
198
|
export interface FileViewerIworkOptions {
|
|
282
|
-
/** Self-hosted module Worker used for ZIP, Snappy, IWA/Protobuf and iWork '09 XML parsing. */
|
|
283
199
|
workerUrl?: string | URL;
|
|
284
|
-
/** Defaults to true. Disable only in environments without Worker support. */
|
|
285
200
|
useWorker?: boolean;
|
|
286
|
-
/** Maximum parse time before the Worker is terminated. Defaults to 60 seconds. */
|
|
287
201
|
workerTimeoutMs?: number;
|
|
288
|
-
/** Maximum total bytes produced while inflating the outer container and Index.zip. Defaults to 256 MiB. */
|
|
289
202
|
maxUncompressedBytes?: number;
|
|
290
|
-
/** Maximum accepted ZIP compression ratio for a single entry. Defaults to 200. */
|
|
291
203
|
maxCompressionRatio?: number;
|
|
292
|
-
/** Maximum decoded IWA archive/object count. Defaults to 250,000. */
|
|
293
204
|
maxObjects?: number;
|
|
294
|
-
/** Maximum decoded image pixels for one media resource. Defaults to 80 megapixels. */
|
|
295
205
|
maxImagePixels?: number;
|
|
296
|
-
/** Maximum normalized scene/object nesting depth. Defaults to 128. */
|
|
297
206
|
maxNestingDepth?: number;
|
|
298
|
-
/** Embedded Quick Look images are loading placeholders or explicit parse-failure fallbacks, never fidelity evidence. */
|
|
299
207
|
embeddedPreview?: FileViewerIworkEmbeddedPreviewMode;
|
|
300
208
|
}
|
|
301
209
|
export interface FileViewerWordPerfectOptions {
|
|
302
|
-
/** Self-hosted Worker that owns WordPerfect signature detection and parsing. */
|
|
303
210
|
workerUrl?: string | URL;
|
|
304
|
-
/** Self-hosted libwpd/librevenge WebAssembly module. */
|
|
305
211
|
wasmUrl?: string | URL;
|
|
306
|
-
/** Defaults to true. */
|
|
307
212
|
useWorker?: boolean;
|
|
308
|
-
/** Maximum parser time before the Worker is terminated. Defaults to 60 seconds. */
|
|
309
213
|
workerTimeoutMs?: number;
|
|
310
214
|
}
|
|
311
215
|
export interface FileViewerHangulOptions {
|
|
312
|
-
/** Self-hosted module Worker used for bounded HWP v5 CFB and HWPX ZIP/XML parsing. */
|
|
313
216
|
workerUrl?: string | URL;
|
|
314
|
-
/** Defaults to true. Disable only in environments without Worker support. */
|
|
315
217
|
useWorker?: boolean;
|
|
316
|
-
/** Maximum parser time before the Worker is terminated. Defaults to 60 seconds. */
|
|
317
218
|
workerTimeoutMs?: number;
|
|
318
|
-
/** Maximum total uncompressed HWPX entry bytes or individual HWP stream bytes. Defaults to 256 MiB. */
|
|
319
219
|
maxUncompressedBytes?: number;
|
|
320
|
-
/** Maximum accepted HWPX ZIP compression ratio for a single entry. Defaults to 200. */
|
|
321
220
|
maxCompressionRatio?: number;
|
|
322
|
-
/** Maximum HWPX ZIP entry count. Defaults to 25,000. */
|
|
323
221
|
maxEntries?: number;
|
|
324
|
-
/** Maximum HWP record count decoded across one stream. Defaults to 250,000. */
|
|
325
222
|
maxRecords?: number;
|
|
326
223
|
}
|
|
327
224
|
export type FileRenderExportMode = 'export' | 'print';
|
|
@@ -338,13 +235,9 @@ export interface FileViewerThumbnailCaptureOptions {
|
|
|
338
235
|
signal?: AbortSignal;
|
|
339
236
|
}
|
|
340
237
|
export interface FileRenderThumbnailAdapter {
|
|
341
|
-
/** Prepare lazy content immediately before capture. */
|
|
342
238
|
beforeCapture?: (options: FileViewerThumbnailCaptureOptions) => void | Promise<void>;
|
|
343
|
-
/** Identifies a capture result that comes from packaged metadata rather than rendered content. */
|
|
344
239
|
captureSource?: 'embedded' | 'rendered';
|
|
345
|
-
/** A renderer-native fast path. Returning null delegates to the DOM fallback. */
|
|
346
240
|
capture?: (options: FileViewerThumbnailCaptureOptions) => Blob | null | Promise<Blob | null>;
|
|
347
|
-
/** The first page/slide/sheet/cover element used by the DOM fallback. */
|
|
348
241
|
getTarget?: (options: FileViewerThumbnailCaptureOptions) => Element | null | Promise<Element | null>;
|
|
349
242
|
}
|
|
350
243
|
export interface FileRenderExportOptions {
|
|
@@ -356,7 +249,6 @@ export interface FileRenderExportAdapter {
|
|
|
356
249
|
exportHtml?: boolean;
|
|
357
250
|
includeDocumentStyles?: boolean;
|
|
358
251
|
beforeSnapshot?: () => Promise<void> | void;
|
|
359
|
-
/** Live page surfaces used by the interactive print-mask designer. */
|
|
360
252
|
getPrintMaskPages?: () => readonly HTMLElement[];
|
|
361
253
|
printStyle?: string | ((options: FileRenderExportOptions) => Promise<string> | string);
|
|
362
254
|
toHtml?: (options: FileRenderExportOptions) => Promise<string> | string;
|
|
@@ -365,15 +257,13 @@ export interface FileRenderContext {
|
|
|
365
257
|
filename?: string;
|
|
366
258
|
url?: string;
|
|
367
259
|
streamUrl?: string;
|
|
368
|
-
|
|
369
|
-
sourceFile?: File;
|
|
260
|
+
sourceFile?: File | Blob;
|
|
370
261
|
signal?: AbortSignal;
|
|
371
262
|
options?: FileViewerOptions;
|
|
372
263
|
surface?: RenderSurface;
|
|
373
264
|
registerExportAdapter?: (adapter: FileRenderExportAdapter | null) => void;
|
|
374
265
|
registerThumbnailAdapter?: (adapter: FileRenderThumbnailAdapter | null) => void;
|
|
375
266
|
renderPurpose?: FileViewerRenderPurpose;
|
|
376
|
-
/** Derived-image download, guarded by the owning viewer's permissions, hooks and request version. */
|
|
377
267
|
requestSnapshotDownload?: (create: (watermark: FileViewerOptions['watermark']) => Promise<{
|
|
378
268
|
blob: Blob;
|
|
379
269
|
filename: string;
|
|
@@ -386,13 +276,6 @@ export interface FileRenderHandlerComposite<Rendered = unknown, Target extends H
|
|
|
386
276
|
accepts: Array<string>;
|
|
387
277
|
handler: FileRenderHandler<Rendered, Target>;
|
|
388
278
|
}
|
|
389
|
-
/**
|
|
390
|
-
* Framework-neutral instance returned by a renderer after it mounts content.
|
|
391
|
-
*
|
|
392
|
-
* Vue, React legacy, Web Components or imperative renderers may expose different
|
|
393
|
-
* teardown names, but wrappers can share this single contract when bridging old
|
|
394
|
-
* renderer handlers into the core registry.
|
|
395
|
-
*/
|
|
396
279
|
export type FileViewerRenderedInstance = {
|
|
397
280
|
$el?: Node;
|
|
398
281
|
unmount: () => void | Promise<void>;
|
|
@@ -411,15 +294,10 @@ export interface FileViewerTypstOptions {
|
|
|
411
294
|
}
|
|
412
295
|
export type FileViewerModelLinearUnit = 'millimeter' | 'centimeter' | 'meter' | 'inch' | 'foot';
|
|
413
296
|
export interface FileViewerModelOptions {
|
|
414
|
-
/** Self-hosted worker that keeps STEP/IGES/BREP tessellation off the UI thread. */
|
|
415
297
|
workerUrl?: string;
|
|
416
|
-
/** Self-hosted occt-import-js runtime loaded by the classic worker. */
|
|
417
298
|
runtimeUrl?: string;
|
|
418
|
-
/** Self-hosted OpenCascade WebAssembly module used by the model renderer. */
|
|
419
299
|
wasmUrl?: string;
|
|
420
|
-
/** Disable only when Worker is unavailable or a host deliberately accepts main-thread parsing. */
|
|
421
300
|
useWorker?: boolean;
|
|
422
|
-
/** Maximum time allowed for geometry-kernel initialization and tessellation. Defaults to 120 seconds. */
|
|
423
301
|
workerTimeoutMs?: number;
|
|
424
302
|
linearUnit?: FileViewerModelLinearUnit;
|
|
425
303
|
linearDeflectionType?: 'bounding_box_ratio' | 'absolute_value';
|
|
@@ -429,21 +307,14 @@ export interface FileViewerModelOptions {
|
|
|
429
307
|
export interface FileViewerDataOptions {
|
|
430
308
|
sqlWasmUrl?: string;
|
|
431
309
|
}
|
|
432
|
-
/** Limits for the explicit, read-only binary inspector renderer. */
|
|
433
310
|
export interface FileViewerBinaryInspectorOptions {
|
|
434
|
-
/** Whole-input ceiling before the renderer copies bytes into its Worker. Defaults to 16 MiB. */
|
|
435
311
|
maxFileBytes?: number;
|
|
436
|
-
/** Maximum time allowed for one structure-template pass. Defaults to 5 seconds. */
|
|
437
312
|
maxParseMilliseconds?: number;
|
|
438
|
-
/** Maximum structure nodes returned from the Worker. Defaults to 512. */
|
|
439
313
|
maxStructureNodes?: number;
|
|
440
|
-
/** Maximum structure-tree nesting depth. Defaults to 16. */
|
|
441
314
|
maxStructureDepth?: number;
|
|
442
|
-
/** Maximum decoded string bytes in one displayed field. Defaults to 4 KiB. */
|
|
443
315
|
maxStringBytes?: number;
|
|
444
316
|
}
|
|
445
317
|
export type FileViewerIllustratorMode = 'auto' | 'pdf' | 'native';
|
|
446
|
-
/** Resource budgets forwarded to the standalone illustrator-pgf Worker. */
|
|
447
318
|
export interface FileViewerIllustratorLimits {
|
|
448
319
|
maxFileBytes: number;
|
|
449
320
|
maxDecodedBytes: number;
|
|
@@ -481,85 +352,45 @@ export interface FileViewerIllustratorResourceResolver {
|
|
|
481
352
|
resolve(reference: FileViewerIllustratorResourceReference, signal: AbortSignal): Promise<ArrayBuffer | null>;
|
|
482
353
|
}
|
|
483
354
|
export interface FileViewerDesignOptions {
|
|
484
|
-
/** Illustrator routing: PDF-compatible surface, native PGF scene, or safe automatic fallback. */
|
|
485
355
|
illustratorMode?: FileViewerIllustratorMode;
|
|
486
|
-
/** Self-hosted module Worker that runs the standalone illustrator-pgf parser and renderer. */
|
|
487
356
|
illustratorWorkerUrl?: string | URL;
|
|
488
|
-
/** Resource budgets forwarded to illustrator-pgf. Defaults to the SDK's bounded limits. */
|
|
489
357
|
illustratorLimits?: Partial<FileViewerIllustratorLimits>;
|
|
490
|
-
/** Optional host font resolver used only by the native Illustrator session. */
|
|
491
358
|
illustratorFontResolver?: FileViewerIllustratorFontResolver;
|
|
492
|
-
/** Optional host linked/embedded resource resolver used only by the native Illustrator session. */
|
|
493
359
|
illustratorResourceResolver?: FileViewerIllustratorResourceResolver;
|
|
494
|
-
/** Self-hosted module Worker used for heavy Adobe document parsing and pixel synthesis. */
|
|
495
360
|
workerUrl?: string | URL;
|
|
496
|
-
/** Self-hosted module Worker used for bounded FLA/XFL, XD, INDD/INDT, ICML/IDMS/INX, ASE, and ACO parsing. */
|
|
497
361
|
containerWorkerUrl?: string | URL;
|
|
498
|
-
/** Self-hosted module Worker used for ABR/CSH/PAT/GRD/ASL resource parsing. */
|
|
499
362
|
adobeResourceWorkerUrl?: string | URL;
|
|
500
|
-
/** Self-hosted module Worker that runs the bounded EPS/PostScript interpreter. */
|
|
501
363
|
postscriptWorkerUrl?: string | URL;
|
|
502
|
-
/** Self-hosted, license-safe Stet WebAssembly binary used only inside the PostScript Worker. */
|
|
503
364
|
postscriptWasmUrl?: string | URL;
|
|
504
|
-
/** Defaults to true. Disable only when Worker is unavailable. */
|
|
505
365
|
useWorker?: boolean;
|
|
506
|
-
/** Maximum parser time before the Worker is terminated. Defaults to 60 seconds. */
|
|
507
366
|
workerTimeoutMs?: number;
|
|
508
|
-
/** Base EPS/PostScript rasterization density. Defaults to 96 DPI. */
|
|
509
367
|
postscriptRenderDpi?: number;
|
|
510
|
-
/** Maximum pages produced by one EPS/PostScript program. Defaults to 100. */
|
|
511
368
|
postscriptMaxPages?: number;
|
|
512
|
-
/** Maximum source width or height reported by a PostScript page. Defaults to 100,000 units. */
|
|
513
369
|
postscriptMaxSourceDimension?: number;
|
|
514
|
-
/** Maximum PostScript virtual-machine allocation. Defaults to 256 MiB. */
|
|
515
370
|
postscriptMaxVmBytes?: number;
|
|
516
|
-
/** Maximum PostScript print working set across visible, cached, transient, and print RGBA canvases. Defaults to 128 MiB. */
|
|
517
371
|
postscriptMaxPrintBytes?: number;
|
|
518
|
-
/** Self-hosted module Worker used by the high-fidelity IDML page renderer. */
|
|
519
372
|
idmlWorkerUrl?: string | URL;
|
|
520
|
-
/** Self-hosted @paged-media/introspect-wasm binary used only inside the IDML Worker. */
|
|
521
373
|
idmlWasmUrl?: string | URL;
|
|
522
|
-
/** Base rasterization density for IDML pages. Defaults to 96 DPI. */
|
|
523
374
|
idmlRenderDpi?: number;
|
|
524
|
-
/** Maximum IDML ZIP entry count. Defaults to 20,000. */
|
|
525
375
|
idmlMaxEntries?: number;
|
|
526
|
-
/** Maximum total expanded bytes declared by an IDML package. Defaults to 512 MiB. */
|
|
527
376
|
idmlMaxExpandedBytes?: number;
|
|
528
|
-
/** Maximum IDML page count exposed by the renderer. Defaults to 500. */
|
|
529
377
|
idmlMaxPages?: number;
|
|
530
|
-
/** Maximum frame count exposed by the IDML page tree. Defaults to 100,000. */
|
|
531
378
|
idmlMaxFrames?: number;
|
|
532
|
-
/** Maximum IDML print working set across visible, cached, transient, and print RGBA canvases. Defaults to 128 MiB. */
|
|
533
379
|
idmlMaxPrintBytes?: number;
|
|
534
|
-
/** Maximum structured result returned for ICML/IDMS/INX parsing. Defaults to 24 MiB and is hard-capped at 64 MiB. */
|
|
535
380
|
indesignExchangeMaxResultBytes?: number;
|
|
536
|
-
/** Maximum geometry points retained for one ICML/IDMS/INX page item. Defaults to 4,096 and is hard-capped at 16,384. */
|
|
537
381
|
indesignExchangeMaxPointsPerItem?: number;
|
|
538
|
-
/** Maximum DOM/SVG nodes materialized for one active ICML/IDMS/INX panel. Defaults to 8,000 and is hard-capped at 20,000. */
|
|
539
382
|
indesignExchangeMaxDomNodesPerPanel?: number;
|
|
540
|
-
/** Maximum accepted Photoshop source size. Defaults to 128 MiB. */
|
|
541
383
|
maxFileBytes?: number;
|
|
542
|
-
/** Maximum document canvas area. Defaults to 16 megapixels. */
|
|
543
384
|
maxCanvasPixels?: number;
|
|
544
|
-
/** Maximum width or height accepted for a browser canvas. Defaults to 16,384 pixels. */
|
|
545
385
|
maxCanvasDimension?: number;
|
|
546
|
-
/** Maximum decoded layer count. Defaults to 2,000. */
|
|
547
386
|
maxLayers?: number;
|
|
548
|
-
/** Maximum group nesting depth. Defaults to 64. */
|
|
549
387
|
maxNestingDepth?: number;
|
|
550
|
-
/** Maximum area decoded for one interactive layer. Defaults to 16 megapixels. */
|
|
551
388
|
maxLayerPixels?: number;
|
|
552
|
-
/** Maximum transferred RGBA bytes for one result. Defaults to 128 MiB. */
|
|
553
389
|
maxDecodedBytes?: number;
|
|
554
|
-
/** Maximum retained interactive layer canvas bytes. Defaults to 64 MiB. */
|
|
555
390
|
maxLayerCacheBytes?: number;
|
|
556
|
-
/** Maximum colors, brushes, shapes, pages, or other resource records. Defaults to 4,096. */
|
|
557
391
|
maxResourceItems?: number;
|
|
558
|
-
/** Maximum UTF-16 code units accepted for one resource name. Defaults to 4,096. */
|
|
559
392
|
maxResourceNameCodeUnits?: number;
|
|
560
|
-
/** Maximum total pixels decoded for one resource preview collection. Defaults to 16 megapixels. */
|
|
561
393
|
maxResourcePreviewPixels?: number;
|
|
562
|
-
/** Safety and inventory limits for XD UCF/ZIP containers and saved raster previews. */
|
|
563
394
|
xd?: {
|
|
564
395
|
maxFileBytes?: number;
|
|
565
396
|
maxEntries?: number;
|
|
@@ -585,7 +416,6 @@ export interface FileViewerDesignOptions {
|
|
|
585
416
|
maxReportedResources?: number;
|
|
586
417
|
maxReportedArtboards?: number;
|
|
587
418
|
};
|
|
588
|
-
/** Safety and bounded first-frame reconstruction limits for modern ZIP/XFL-based Animate FLA files. */
|
|
589
419
|
fla?: {
|
|
590
420
|
maxFileBytes?: number;
|
|
591
421
|
maxEntries?: number;
|
|
@@ -618,7 +448,6 @@ export interface FileViewerDesignOptions {
|
|
|
618
448
|
maxPreviewPixels?: number;
|
|
619
449
|
maxSymbolDepth?: number;
|
|
620
450
|
};
|
|
621
|
-
/** Safety limits for native INDD/INDT master-page, contiguous-object, XMP, and thumbnail reads. */
|
|
622
451
|
inDesign?: {
|
|
623
452
|
maxFileBytes?: number;
|
|
624
453
|
maxDatabasePages?: number;
|
|
@@ -634,29 +463,10 @@ export interface FileViewerDesignOptions {
|
|
|
634
463
|
export type FileViewerGeoBasemapPreset = 'none' | 'offline' | 'openfreemap' | 'openfreemap-liberty' | 'openfreemap-bright' | 'openfreemap-positron' | 'openfreemap-dark' | 'openfreemap-fiord' | 'osm-raster' | 'tianditu-vector' | 'tianditu-imagery' | 'tianditu-terrain';
|
|
635
464
|
export type FileViewerTiandituMapStyle = 'vector' | 'imagery' | 'terrain';
|
|
636
465
|
export interface FileViewerGeoBasemapOptions {
|
|
637
|
-
/**
|
|
638
|
-
* `raster` uses XYZ/TMS image tiles. `vector-style` uses a MapLibre style
|
|
639
|
-
* object or URL, which is the best path for OpenFreeMap/OpenMapTiles stacks.
|
|
640
|
-
* `tianditu` builds the official base and annotation raster layers from the
|
|
641
|
-
* caller-provided Tianditu token.
|
|
642
|
-
*/
|
|
643
466
|
type?: 'raster' | 'vector-style' | 'tianditu';
|
|
644
|
-
/**
|
|
645
|
-
* Raster XYZ/TMS tile template, for example `/tiles/{z}/{x}/{y}.png`.
|
|
646
|
-
*/
|
|
647
467
|
tileUrl?: string | string[];
|
|
648
|
-
/**
|
|
649
|
-
* MapLibre style JSON URL. Can point to a public source, an intranet mirror,
|
|
650
|
-
* or an offline static file distributed with the viewer.
|
|
651
|
-
*/
|
|
652
468
|
styleUrl?: string;
|
|
653
|
-
/**
|
|
654
|
-
* Inline MapLibre style object for fully offline deployments.
|
|
655
|
-
*/
|
|
656
469
|
style?: Record<string, unknown>;
|
|
657
|
-
/**
|
|
658
|
-
* Human-readable label shown in the geo preview details panel.
|
|
659
|
-
*/
|
|
660
470
|
label?: string;
|
|
661
471
|
attribution?: string;
|
|
662
472
|
tileSize?: number;
|
|
@@ -664,86 +474,23 @@ export interface FileViewerGeoBasemapOptions {
|
|
|
664
474
|
maxZoom?: number;
|
|
665
475
|
scheme?: 'xyz' | 'tms';
|
|
666
476
|
rasterOpacity?: number;
|
|
667
|
-
/** Tianditu API token. Required when `type` is `tianditu`. */
|
|
668
477
|
token?: string;
|
|
669
|
-
/** Tianditu map family. Defaults to `vector`. */
|
|
670
478
|
mapStyle?: FileViewerTiandituMapStyle;
|
|
671
|
-
/** Include the matching Tianditu annotation layer. Defaults to true. */
|
|
672
479
|
labels?: boolean;
|
|
673
480
|
}
|
|
674
481
|
export interface FileViewerGeoOptions {
|
|
675
|
-
/**
|
|
676
|
-
* Source coordinate reference system. GeoJSON normally uses WGS84, but many
|
|
677
|
-
* business exports carry Web Mercator, GCJ-02, BD-09, or legacy CRS metadata.
|
|
678
|
-
*
|
|
679
|
-
* Accepts values such as `EPSG:4326`, `EPSG:3857`, `CRS:84`, `GCJ02`,
|
|
680
|
-
* `BD09`, or a proj4 definition string.
|
|
681
|
-
*/
|
|
682
482
|
projection?: string;
|
|
683
|
-
/**
|
|
684
|
-
* Convenience raster tile URL. The renderer stays offline by default; setting
|
|
685
|
-
* this property opts into a raster basemap without requiring a full MapLibre
|
|
686
|
-
* style. Use `basemap` when you need a named preset or vector style URL.
|
|
687
|
-
*/
|
|
688
483
|
tileUrl?: string | string[];
|
|
689
|
-
/**
|
|
690
|
-
* Basemap configuration. Defaults to an offline empty MapLibre style.
|
|
691
|
-
*
|
|
692
|
-
* Built-in presets are opt-in: `openfreemap-liberty` uses the public
|
|
693
|
-
* OpenFreeMap MapLibre style, and `osm-raster` uses the public OSM raster
|
|
694
|
-
* tiles for light usage or demos. Production systems should prefer a
|
|
695
|
-
* self-hosted or intranet style/tile URL.
|
|
696
|
-
*/
|
|
697
484
|
basemap?: false | FileViewerGeoBasemapPreset | FileViewerGeoBasemapOptions;
|
|
698
|
-
/**
|
|
699
|
-
* Tianditu API token used by the `tianditu-*` presets. The viewer never
|
|
700
|
-
* supplies or persists a token; obtain one for the deployment's own domain.
|
|
701
|
-
*/
|
|
702
485
|
tiandituToken?: string;
|
|
703
|
-
/**
|
|
704
|
-
* Defaults to true. When no CRS is declared and coordinates exceed longitude
|
|
705
|
-
* or latitude ranges, the geo renderer treats Web Mercator-sized values as
|
|
706
|
-
* EPSG:3857 before rendering.
|
|
707
|
-
*/
|
|
708
486
|
inferProjection?: boolean;
|
|
709
|
-
/**
|
|
710
|
-
* Defaults to true. Disable only for environments without reliable WebGL,
|
|
711
|
-
* where the SVG fallback is preferred.
|
|
712
|
-
*/
|
|
713
487
|
preferMapEngine?: boolean;
|
|
714
|
-
/**
|
|
715
|
-
* Padding in CSS pixels when fitting the dataset bounds in the map viewport.
|
|
716
|
-
*/
|
|
717
488
|
fitPadding?: number;
|
|
718
489
|
}
|
|
719
490
|
export interface FileViewerDrawingOptions {
|
|
720
|
-
/**
|
|
721
|
-
* Self-hosted diagrams.net viewer script.
|
|
722
|
-
*
|
|
723
|
-
* The default points to the optional viewer asset copied under
|
|
724
|
-
* `vendor/drawio/viewer-static.min.js`. It is only requested when
|
|
725
|
-
* `preferOfficial` is explicitly enabled and never reaches public
|
|
726
|
-
* diagrams.net hosts.
|
|
727
|
-
*/
|
|
728
491
|
viewerScriptUrl?: string;
|
|
729
|
-
/**
|
|
730
|
-
* Defaults to false so untrusted diagrams use the inert built-in SVG path.
|
|
731
|
-
* Set to true only to opt into the separately delivered diagrams.net viewer
|
|
732
|
-
* runtime. It runs in a no-same-origin iframe with a restrictive CSP.
|
|
733
|
-
*/
|
|
734
492
|
preferOfficial?: boolean;
|
|
735
|
-
/**
|
|
736
|
-
* PlantUML SVG endpoint. When omitted, the renderer stays fully offline and
|
|
737
|
-
* shows an SVG source preview. When provided, the renderer appends the
|
|
738
|
-
* encoded PlantUML payload to this base URL. Self-host this endpoint for
|
|
739
|
-
* intranet preview.
|
|
740
|
-
*
|
|
741
|
-
* Example: `/plantuml/svg/`.
|
|
742
|
-
*/
|
|
743
493
|
plantumlServerUrl?: string;
|
|
744
|
-
/**
|
|
745
|
-
* Request timeout for server-rendered PlantUML SVG.
|
|
746
|
-
*/
|
|
747
494
|
plantumlTimeoutMs?: number;
|
|
748
495
|
}
|
|
749
496
|
export type FileViewerCadRenderer = 'auto' | 'webgl' | 'canvas2d';
|
|
@@ -758,32 +505,19 @@ export interface FileViewerCadOptions {
|
|
|
758
505
|
useWorker?: boolean;
|
|
759
506
|
workerTimeoutMs?: number;
|
|
760
507
|
renderer?: FileViewerCadRenderer;
|
|
761
|
-
/** Initial CAD color policy. `monochrome` applies one plot color without mutating source data. */
|
|
762
508
|
colorMode?: FileViewerCadColorMode;
|
|
763
|
-
/** CSS color used by monochrome mode. Defaults to black (#000000). */
|
|
764
509
|
monochromeColor?: string;
|
|
765
|
-
/** Shows the CAD toolbar color-mode toggle. Defaults to true. */
|
|
766
510
|
showColorModeToggle?: boolean;
|
|
767
|
-
/** Show native PNG/JPEG snapshot downloads. Download/export permissions still apply. */
|
|
768
511
|
showImageExport?: boolean;
|
|
769
512
|
preferDwgWasm?: boolean;
|
|
770
513
|
includePaperSpace?: boolean;
|
|
771
514
|
maxInsertDepth?: number;
|
|
772
515
|
keepRaw?: boolean;
|
|
773
516
|
preloadDwg?: boolean;
|
|
774
|
-
/**
|
|
775
|
-
* `best` fits the first view to visible drawing geometry and ignores common
|
|
776
|
-
* CAD outliers such as paper-space frames or far-away markers. `native`
|
|
777
|
-
* preserves the raw bounds reported by the underlying CAD renderer.
|
|
778
|
-
*/
|
|
779
517
|
fitMode?: FileViewerCadFitMode;
|
|
780
|
-
/**
|
|
781
|
-
* Fraction of the CAD viewport used by fit-to-view. Defaults to 0.92.
|
|
782
|
-
*/
|
|
783
518
|
fitPadding?: number;
|
|
784
519
|
dwfPreferWebgl?: boolean;
|
|
785
520
|
dwfPreferWasm?: boolean;
|
|
786
|
-
/** Explicit DWF background override; otherwise follows the current color mode. */
|
|
787
521
|
dwfBackground?: string;
|
|
788
522
|
dwfMaxDevicePixelRatio?: number;
|
|
789
523
|
dwfMaxCanvasPixels?: number;
|
|
@@ -794,19 +528,12 @@ export interface FileViewerCadOptions {
|
|
|
794
528
|
dwfMaxOverviewStrokeCssPx?: number;
|
|
795
529
|
dwfMinTextCssPx?: number;
|
|
796
530
|
dwfMinFilledAreaCssPx?: number;
|
|
797
|
-
/** Default background is dark for source colors and white for monochrome. Explicit colors are retained. */
|
|
798
531
|
canvasOptions?: Record<string, unknown>;
|
|
799
532
|
}
|
|
800
533
|
export type FileViewerRendererMode = 'extend' | 'replace';
|
|
801
534
|
export type FileViewerBuiltinRendererPreset = 'all' | 'lite' | 'none';
|
|
802
535
|
export type FileViewerRendererPresetName = 'all' | 'lite' | 'standard' | 'office' | 'engineering';
|
|
803
536
|
export interface FileViewerAutoRendererOptions {
|
|
804
|
-
/**
|
|
805
|
-
* Uses renderer presets registered by build tooling or preset side-effect imports.
|
|
806
|
-
*
|
|
807
|
-
* Defaults to true in `extend` mode and false in `replace` mode so applications
|
|
808
|
-
* can keep a strict hand-picked renderer registry when needed.
|
|
809
|
-
*/
|
|
810
537
|
enabled?: boolean;
|
|
811
538
|
}
|
|
812
539
|
export interface FileViewerSearchOptions {
|
|
@@ -826,69 +553,23 @@ export interface FileViewerAiOptions {
|
|
|
826
553
|
chunkOverlap?: number;
|
|
827
554
|
}
|
|
828
555
|
export interface FileViewerTextOptions {
|
|
829
|
-
/** Initial HTML/HTM view. Preview is static, sandboxed, and offline; defaults to preview. */
|
|
830
556
|
htmlView?: 'preview' | 'source';
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
* then strict UTF-8, with GB18030 (including GBK) as the final fallback.
|
|
834
|
-
*/
|
|
835
|
-
encoding?: 'auto' | 'utf-8' | 'utf-16le' | 'utf-16be' | 'gbk' | 'gb18030';
|
|
836
|
-
/**
|
|
837
|
-
* Shows the renderer-local source metadata toolbar (file type, indexing
|
|
838
|
-
* status, and line count). Defaults to true. This does not control the
|
|
839
|
-
* viewer-level operation toolbar.
|
|
840
|
-
*/
|
|
557
|
+
encoding?: 'auto' | 'utf-8' | 'utf-16le' | 'utf-16be' | 'gbk' | 'gb18030' | 'iso-8859-1' | 'iso-8859-2' | 'iso-8859-15' | 'windows-1250' | 'windows-1251' | 'windows-1252';
|
|
558
|
+
fallbackEncoding?: 'utf-8' | 'gbk' | 'gb18030' | 'iso-8859-1' | 'iso-8859-2' | 'iso-8859-15' | 'windows-1250' | 'windows-1251' | 'windows-1252';
|
|
841
559
|
toolbar?: boolean;
|
|
842
|
-
/**
|
|
843
|
-
* Shows a non-selectable, screen-reader-hidden line-number gutter for code and text.
|
|
844
|
-
* Defaults to false for regular files. The virtual large-text view keeps its
|
|
845
|
-
* historical visible gutter when this option is omitted; pass false to hide it.
|
|
846
|
-
*/
|
|
847
560
|
lineNumbers?: boolean;
|
|
848
|
-
/**
|
|
849
|
-
* Visually wraps long logical lines without inserting source newlines. Defaults to false.
|
|
850
|
-
* Wrapped continuation rows remain associated with their original line number.
|
|
851
|
-
*/
|
|
852
561
|
wrapLongLines?: boolean;
|
|
853
|
-
/**
|
|
854
|
-
* Formats supported structured text with lazily loaded Prettier plugins for display only.
|
|
855
|
-
* Defaults to false; malformed, unsupported, or oversized inputs keep their original source.
|
|
856
|
-
*/
|
|
857
562
|
prettyPrint?: boolean;
|
|
858
|
-
/**
|
|
859
|
-
* Maximum decoded UTF-8 source bytes eligible for Prettier. Defaults to the effective
|
|
860
|
-
* `virtualizeAboveBytes` value, or 512 KiB when that option is omitted.
|
|
861
|
-
*/
|
|
862
563
|
prettyPrintMaxBytes?: number;
|
|
863
|
-
/** Switches text and code to bounded virtual rendering above this byte size. Defaults to 512 KiB. */
|
|
864
564
|
virtualizeAboveBytes?: number;
|
|
865
|
-
/**
|
|
866
|
-
* Opts Markdown into source-mode virtual rendering above this byte size.
|
|
867
|
-
* Markdown stays in its rendered reading view by default; set this only when
|
|
868
|
-
* an application prefers bounded source inspection for exceptionally large files.
|
|
869
|
-
*/
|
|
870
565
|
markdownVirtualizeAboveBytes?: number;
|
|
871
|
-
|
|
566
|
+
markdownHighlight?: boolean;
|
|
872
567
|
maxRenderedLineBytes?: number;
|
|
873
|
-
/** Extra logical lines mounted above and below the visible viewport. Defaults to 12. */
|
|
874
568
|
virtualOverscanLines?: number;
|
|
875
569
|
}
|
|
876
570
|
export type FileViewerUiDensity = 'comfortable' | 'compact';
|
|
877
571
|
export interface FileViewerUiOptions {
|
|
878
|
-
/**
|
|
879
|
-
* Controls spacing density for viewer chrome such as toolbars, headers,
|
|
880
|
-
* archive lists, badges, search inputs, and compact action clusters.
|
|
881
|
-
*/
|
|
882
572
|
density?: FileViewerUiDensity;
|
|
883
|
-
/**
|
|
884
|
-
* Overrides the workspace behind rendered pages, slides, and other preview
|
|
885
|
-
* content. Pass any valid CSS background value (for example `transparent`)
|
|
886
|
-
* to let the host application provide an immersive surface. Omit this value,
|
|
887
|
-
* or pass `auto`, to keep each renderer's light/dark default.
|
|
888
|
-
*
|
|
889
|
-
* This does not change document pages, slide canvases, spreadsheet cells, or
|
|
890
|
-
* other file-authored backgrounds.
|
|
891
|
-
*/
|
|
892
573
|
surfaceBackground?: string;
|
|
893
574
|
}
|
|
894
575
|
export interface FileViewerDiagnostic {
|
|
@@ -899,71 +580,18 @@ export interface FileViewerDiagnostic {
|
|
|
899
580
|
}
|
|
900
581
|
export interface FileViewerOptions {
|
|
901
582
|
theme?: FileViewerThemeMode;
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
* explicitly only for legacy integrations that require deep class overrides.
|
|
907
|
-
*/
|
|
583
|
+
zoomGestures?: boolean | {
|
|
584
|
+
wheel?: boolean;
|
|
585
|
+
pinch?: boolean;
|
|
586
|
+
};
|
|
908
587
|
styleIsolation?: FileViewerStyleIsolation;
|
|
909
|
-
/**
|
|
910
|
-
* Viewer UI language. `auto` follows the browser language and resolves the
|
|
911
|
-
* built-in Chinese, English, Japanese, and German locales before falling
|
|
912
|
-
* back to `en-US`.
|
|
913
|
-
*/
|
|
914
588
|
locale?: FileViewerLocale;
|
|
915
|
-
/**
|
|
916
|
-
* Optional custom copy for built-in viewer UI. Use `i18n.messages` when you
|
|
917
|
-
* also want to keep locale and messages grouped together.
|
|
918
|
-
*/
|
|
919
589
|
messages?: FileViewerMessages;
|
|
920
590
|
i18n?: FileViewerI18nOptions;
|
|
921
|
-
/**
|
|
922
|
-
* Controls how explicit renderer packages or presets are merged into this
|
|
923
|
-
* viewer instance.
|
|
924
|
-
*
|
|
925
|
-
* `extend` mode keeps the configured built-in baseline and appends explicit
|
|
926
|
-
* renderers. `replace` mode starts from an empty registry, so `preset` or
|
|
927
|
-
* `renderers` fully define the active capability set.
|
|
928
|
-
*/
|
|
929
591
|
rendererMode?: FileViewerRendererMode;
|
|
930
|
-
/**
|
|
931
|
-
* Advanced baseline switch for built-in browser renderers.
|
|
932
|
-
*
|
|
933
|
-
* Most applications can ignore this option and use `preset` / `renderers`
|
|
934
|
-
* with `rendererMode:'replace'`. Keep it for compatibility or very strict
|
|
935
|
-
* registry control: `all` preserves the historical full baseline, `lite`
|
|
936
|
-
* keeps only low-cost web-native previewers, and `none` starts from an empty
|
|
937
|
-
* built-in baseline while still allowing explicit renderer assembly.
|
|
938
|
-
*/
|
|
939
592
|
builtinRenderers?: FileViewerBuiltinRendererPreset;
|
|
940
|
-
/**
|
|
941
|
-
* Enables renderer presets that were auto-registered by `@file-viewer/vite-plugin`
|
|
942
|
-
* or by explicitly importing a preset package. Set to false when a product wants
|
|
943
|
-
* total manual control through `renderers`.
|
|
944
|
-
*/
|
|
945
593
|
autoRenderers?: boolean | FileViewerAutoRendererOptions;
|
|
946
|
-
/**
|
|
947
|
-
* Product-shaped renderer preset or preset list installed into this viewer
|
|
948
|
-
* instance.
|
|
949
|
-
*
|
|
950
|
-
* This is the bundler-neutral path for Webpack, Rspack, Rollup, Umi,
|
|
951
|
-
* legacy script builds, and any environment that should not depend on the
|
|
952
|
-
* Vite virtual module. Import one or more preset packages and pass them here:
|
|
953
|
-
*
|
|
954
|
-
* `const officePreset = await import(theInstalledOfficePresetPackage)`
|
|
955
|
-
* `options: { preset: officePreset.default }`
|
|
956
|
-
* `options: { preset: [officePreset.default, engineeringPreset.default] }`
|
|
957
|
-
*
|
|
958
|
-
* The string form (`'office'`, `'all'`, etc.) selects a preset that has
|
|
959
|
-
* already been registered by a preset side-effect import or by
|
|
960
|
-
* `@file-viewer/vite-plugin`.
|
|
961
|
-
*/
|
|
962
594
|
preset?: FileViewerRendererPresetInput;
|
|
963
|
-
/**
|
|
964
|
-
* @deprecated Use `preset: [officePreset, engineeringPreset]` instead. This
|
|
965
|
-
* alias is kept only for compatibility with early 2.x integration drafts.
|
|
966
|
-
*/
|
|
967
595
|
presets?: FileViewerRendererPresetInput;
|
|
968
596
|
renderers?: FileViewerRendererPluginInput;
|
|
969
597
|
watermark?: boolean | FileViewerWatermarkOptions;
|
|
@@ -972,19 +600,7 @@ export interface FileViewerOptions {
|
|
|
972
600
|
search?: boolean | FileViewerSearchOptions;
|
|
973
601
|
ai?: boolean | FileViewerAiOptions;
|
|
974
602
|
text?: FileViewerTextOptions;
|
|
975
|
-
/**
|
|
976
|
-
* Explicit content fitting strategy. When omitted, each renderer keeps its
|
|
977
|
-
* historical first-screen behavior for backward compatibility.
|
|
978
|
-
*/
|
|
979
603
|
fit?: FileViewerFitMode | FileViewerFitOptions;
|
|
980
|
-
/**
|
|
981
|
-
* Initial renderer view position used after the document becomes ready.
|
|
982
|
-
*
|
|
983
|
-
* Renderers apply the fields they understand. All standard renderer paths
|
|
984
|
-
* expose at least renderer / zoom / scroll snapshots through the generic
|
|
985
|
-
* provider; high-interaction renderers such as PDF, XMind, Geo, 3D, and CAD
|
|
986
|
-
* add page, navigation, canvas, map, camera, or native view details.
|
|
987
|
-
*/
|
|
988
604
|
initialViewState?: FileViewerViewState;
|
|
989
605
|
archive?: FileViewerArchiveOptions;
|
|
990
606
|
chm?: FileViewerChmOptions;
|
|
@@ -992,15 +608,18 @@ export interface FileViewerOptions {
|
|
|
992
608
|
docx?: FileViewerDocxOptions;
|
|
993
609
|
presentation?: FileViewerPresentationOptions;
|
|
994
610
|
spreadsheet?: FileViewerSpreadsheetOptions;
|
|
611
|
+
image?: {
|
|
612
|
+
rotation?: boolean;
|
|
613
|
+
};
|
|
995
614
|
iwork?: FileViewerIworkOptions;
|
|
996
615
|
wordPerfect?: FileViewerWordPerfectOptions;
|
|
997
616
|
hangul?: FileViewerHangulOptions;
|
|
998
|
-
/** Receives non-fatal routing, fallback, and capability diagnostics. */
|
|
999
617
|
onDiagnostic?: (diagnostic: FileViewerDiagnostic) => void;
|
|
1000
618
|
typst?: FileViewerTypstOptions;
|
|
1001
619
|
geo?: FileViewerGeoOptions;
|
|
1002
620
|
data?: FileViewerDataOptions;
|
|
1003
621
|
binary?: FileViewerBinaryInspectorOptions;
|
|
622
|
+
xml?: FileViewerXmlOptions;
|
|
1004
623
|
design?: FileViewerDesignOptions;
|
|
1005
624
|
drawing?: FileViewerDrawingOptions;
|
|
1006
625
|
cad?: FileViewerCadOptions;
|
|
@@ -1261,31 +880,22 @@ export interface FileViewerExportHtmlOptions {
|
|
|
1261
880
|
title?: string;
|
|
1262
881
|
watermarkInlineStyle?: string;
|
|
1263
882
|
}
|
|
1264
|
-
/** Normalized print-mask rectangle in percent of the rendered content box. */
|
|
1265
883
|
export interface FileViewerPrintMaskRegion {
|
|
1266
884
|
left: number;
|
|
1267
885
|
top: number;
|
|
1268
886
|
width: number;
|
|
1269
887
|
height: number;
|
|
1270
|
-
/** Zero-based rendered page index. Omitted regions retain legacy whole-document coordinates. */
|
|
1271
888
|
pageIndex?: number;
|
|
1272
889
|
}
|
|
1273
|
-
/** Page-aware image placed above rendered content for printing, such as a seal or signature. */
|
|
1274
890
|
export interface FileViewerPrintStamp extends FileViewerPrintMaskRegion {
|
|
1275
|
-
/** Image URL. Uploaded stamps are converted to a local data URL by the designer. */
|
|
1276
891
|
src: string;
|
|
1277
|
-
/** Image opacity from 0 to 1. Defaults to 1. */
|
|
1278
892
|
opacity?: number;
|
|
1279
|
-
/** Clockwise rotation in degrees. Defaults to 0. */
|
|
1280
893
|
rotate?: number;
|
|
1281
894
|
alt?: string;
|
|
1282
895
|
}
|
|
1283
896
|
export interface FileViewerPrintMaskOptions {
|
|
1284
|
-
/** Solid black cover blocks, matching common OFD/business redaction UX. */
|
|
1285
897
|
regions?: FileViewerPrintMaskRegion[];
|
|
1286
|
-
/** Image overlays, including locally uploaded seals and signatures. */
|
|
1287
898
|
stamps?: FileViewerPrintStamp[];
|
|
1288
|
-
/** Fill color for print masks. Defaults to opaque black. */
|
|
1289
899
|
color?: string;
|
|
1290
900
|
}
|
|
1291
901
|
export interface FileViewerPrintOptions {
|
|
@@ -1294,7 +904,6 @@ export interface FileViewerPrintOptions {
|
|
|
1294
904
|
printWindow?: Window | null;
|
|
1295
905
|
title?: string;
|
|
1296
906
|
watermarkInlineStyle?: string;
|
|
1297
|
-
/** Optional print-time cover masks applied above content and below watermark. */
|
|
1298
907
|
mask?: FileViewerPrintMaskOptions | null;
|
|
1299
908
|
}
|
|
1300
909
|
export interface FileViewerSource {
|
|
@@ -1329,23 +938,30 @@ export interface RendererCapability {
|
|
|
1329
938
|
}
|
|
1330
939
|
export type FileViewerFormatSupportLevel = 'high-fidelity' | 'structured' | 'basic' | 'experimental';
|
|
1331
940
|
export type FileViewerFormatStatus = 'stable' | 'experimental';
|
|
941
|
+
export interface RendererSourceTypeProbeInput {
|
|
942
|
+
filename: string;
|
|
943
|
+
extension: string;
|
|
944
|
+
url?: string;
|
|
945
|
+
file?: File | Blob;
|
|
946
|
+
buffer?: ArrayBuffer;
|
|
947
|
+
mimeType?: string;
|
|
948
|
+
signal?: AbortSignal;
|
|
949
|
+
}
|
|
950
|
+
export type RendererSourceTypeProbe = (input: RendererSourceTypeProbeInput) => string | false | null | undefined | Promise<string | false | null | undefined>;
|
|
1332
951
|
export interface RendererDefinition {
|
|
1333
952
|
id: string;
|
|
1334
953
|
label: string;
|
|
1335
954
|
category: FileViewerRendererCategory;
|
|
1336
955
|
extensions: readonly string[];
|
|
956
|
+
filenamePatterns?: readonly string[];
|
|
957
|
+
sourceAccess?: 'buffer' | 'stream-preferred';
|
|
958
|
+
resolveSourceType?: RendererSourceTypeProbe;
|
|
1337
959
|
async?: boolean;
|
|
1338
|
-
/** Product-level fidelity contract generated from ecosystem/format-catalog.json. */
|
|
1339
960
|
supportLevel?: FileViewerFormatSupportLevel;
|
|
1340
|
-
/** Experimental formats are routable but are excluded from stable support counts. */
|
|
1341
961
|
status?: FileViewerFormatStatus;
|
|
1342
|
-
/** Owning on-demand renderer package. */
|
|
1343
962
|
packageName?: string;
|
|
1344
|
-
/** Presets that assemble this renderer. */
|
|
1345
963
|
presets?: readonly FileViewerRendererPresetName[];
|
|
1346
|
-
/** Existing renderer whose fallback extensions this specialist replaces when installed. */
|
|
1347
964
|
enhancesRendererId?: string;
|
|
1348
|
-
/** Extensions transferred from enhancesRendererId to this specialist when installed. */
|
|
1349
965
|
enhancesExtensions?: readonly string[];
|
|
1350
966
|
containerVersions?: readonly string[];
|
|
1351
967
|
knownLimits?: readonly string[];
|
|
@@ -1419,7 +1035,6 @@ export interface FileViewerLoadOptions {
|
|
|
1419
1035
|
}
|
|
1420
1036
|
export interface FileViewerInstance {
|
|
1421
1037
|
readonly container: HTMLElement;
|
|
1422
|
-
/** Installs configured renderer plugins without loading a document. */
|
|
1423
1038
|
prepare?(): Promise<void>;
|
|
1424
1039
|
load(source: FileViewerSource, options?: FileViewerLoadOptions): Promise<RendererSession | null>;
|
|
1425
1040
|
unload?(reason?: FileViewerLifecycleContext['reason']): Promise<void>;
|
|
@@ -1435,7 +1050,6 @@ export interface FileViewerInstance {
|
|
|
1435
1050
|
download(options?: FileViewerDownloadOptions): Promise<void>;
|
|
1436
1051
|
exportHtml(options?: FileViewerExportHtmlOptions): Promise<string>;
|
|
1437
1052
|
print(options?: FileViewerPrintOptions): Promise<void>;
|
|
1438
|
-
/** Open the async print-mask designer, then print with the chosen covers. */
|
|
1439
1053
|
printWithMask(options?: FileViewerPrintOptions): Promise<void>;
|
|
1440
1054
|
zoomIn(): Promise<FileViewerZoomState>;
|
|
1441
1055
|
zoomOut(): Promise<FileViewerZoomState>;
|