@file-viewer/core 3.2.2 → 3.3.1
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 +26 -15
- package/README.md +47 -41
- package/README.zh-CN.md +175 -0
- package/dist/assets.d.ts +2 -2
- package/dist/assets.js +5 -1
- package/dist/browser/controller.d.ts +2 -1
- package/dist/browser/controller.js +156 -32
- package/dist/browser/source-feedback.d.ts +4 -0
- package/dist/browser/source-feedback.js +40 -0
- package/dist/browser/toolbar-focus.d.ts +2 -0
- package/dist/browser/toolbar-focus.js +46 -0
- 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 +479 -1
- package/dist/contracts/xml.d.ts +11 -0
- package/dist/export.d.ts +10 -3
- package/dist/export.js +9 -2
- package/dist/exportDocument.d.ts +12 -1
- package/dist/exportDocument.js +31 -2
- 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/imageHandTool.d.ts +3 -0
- package/dist/features/document/imageHandTool.js +141 -0
- 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 +1 -1
- package/dist/features/document/zoom.js +3 -3
- package/dist/features/document/zoomGestures.d.ts +2 -2
- package/dist/features/document/zoomGestures.js +2 -0
- package/dist/features/printMask.d.ts +1 -1
- package/dist/features/printMaskDesigner.d.ts +6 -2
- package/dist/features/printMaskDesigner.js +11 -2
- package/dist/features/printMaskLoader.d.ts +7 -1
- package/dist/features/printMaskLoader.js +7 -1
- package/dist/features/watermark.d.ts +1 -1
- package/dist/headless.d.ts +29 -29
- package/dist/headless.js +21 -16
- package/dist/i18n/messages.d.ts +1 -1
- package/dist/i18n/messages.de.d.ts +5 -1
- package/dist/i18n/messages.de.js +4 -0
- package/dist/i18n/messages.ja.d.ts +6 -1
- package/dist/i18n/messages.ja.js +5 -0
- package/dist/i18n/messages.js +2 -2
- package/dist/index.d.ts +77 -75
- package/dist/index.js +39 -37
- package/dist/lifecycle/facade.d.ts +4 -4
- package/dist/lifecycle/facade.js +2 -2
- package/dist/lifecycle/operations.d.ts +6 -4
- package/dist/lifecycle/operations.js +21 -4
- package/dist/output/canvasImage.d.ts +2 -1
- package/dist/output/canvasImage.js +4 -1
- package/dist/output/export.d.ts +3 -1
- package/dist/output/export.js +12 -0
- package/dist/output/printLayout.d.ts +5 -0
- package/dist/output/printLayout.js +4 -0
- package/dist/output/snapshotDownload.d.ts +2 -1
- package/dist/output/snapshotDownload.js +3 -2
- package/dist/platform/assets.d.ts +9 -2
- package/dist/platform/assets.js +15 -1
- package/dist/platform/copiedAssets.d.ts +1 -0
- package/dist/platform/copiedAssets.js +2 -1
- package/dist/presentation/colorScheme.d.ts +3 -0
- package/dist/presentation/colorScheme.js +40 -0
- 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 +14 -1
- package/dist/registry/capabilities.js +15 -2
- package/dist/registry/formats.d.ts +1 -1
- package/dist/registry/formats.generated.d.ts +1 -0
- package/dist/registry/formats.generated.js +1 -0
- package/dist/registry/formats.js +2 -2
- package/dist/registry/registry.d.ts +15 -1
- package/dist/registry/registry.js +10 -2
- package/dist/renderers/image.d.ts +1 -1
- package/dist/renderers/image.js +13 -7
- package/dist/renderers/index.d.ts +1 -1
- package/dist/renderers/index.js +11 -5
- package/dist/rendering/dispatcher.d.ts +6 -1
- package/dist/rendering/dispatcher.js +3 -3
- package/dist/rendering/handler.d.ts +13 -3
- package/dist/rendering/handler.js +21 -9
- package/dist/security/svgResources.d.ts +10 -0
- package/dist/security/svgResources.js +12 -0
- package/dist/source/index.d.ts +3 -3
- package/dist/source/index.js +1 -1
- package/dist/source/loading.d.ts +12 -7
- package/dist/source/loading.js +22 -17
- package/dist/source/precheck.d.ts +13 -1
- package/dist/source/precheck.js +9 -2
- package/dist/source/textEncoding.d.ts +18 -0
- package/dist/source/textEncoding.js +15 -0
- package/dist/viewer/createViewer.d.ts +1 -1
- package/dist/viewer/createViewer.js +30 -17
- package/dist/viewer/loading.d.ts +6 -2
- package/dist/viewer/loading.js +9 -1
- package/dist/viewer/operations.d.ts +3 -3
- package/dist/viewer/operations.js +14 -6
- package/dist/viewer/state.d.ts +6 -2
- package/dist/viewer/state.js +8 -3
- package/package.json +14 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildFileViewerWatermarkSvg, normalizeFileViewerWatermark } from
|
|
1
|
+
import { buildFileViewerWatermarkSvg, normalizeFileViewerWatermark } from '../features/watermark.js';
|
|
2
2
|
const loadImage = (document, source) => new Promise((resolve, reject) => {
|
|
3
3
|
const image = document.createElement('img');
|
|
4
4
|
const timer = setTimeout(() => finish(new Error('Image export resource timed out.')), 30000);
|
|
@@ -15,6 +15,7 @@ const loadImage = (document, source) => new Promise((resolve, reject) => {
|
|
|
15
15
|
image.onerror = () => finish(new Error('Unable to render the export watermark.'));
|
|
16
16
|
image.src = source;
|
|
17
17
|
});
|
|
18
|
+
/** Encodes a detached snapshot without mutating the renderer or omitting its watermark. */
|
|
18
19
|
export async function createFileViewerCanvasImageBlob(snapshot, format, watermark, pixelRatio = 1) {
|
|
19
20
|
if (!['png', 'jpeg'].includes(format))
|
|
20
21
|
throw new Error('Unsupported image export format.');
|
|
@@ -37,6 +38,8 @@ export async function createFileViewerCanvasImageBlob(snapshot, format, watermar
|
|
|
37
38
|
let normalized = normalizeFileViewerWatermark(watermark);
|
|
38
39
|
if (normalized) {
|
|
39
40
|
if (normalized.image) {
|
|
41
|
+
// SVG image documents do not load nested remote images. Inline the configured
|
|
42
|
+
// watermark first; an unreadable/tainted image must fail, never disappear.
|
|
40
43
|
const image = await loadImage(document, normalized.image);
|
|
41
44
|
const tile = document.createElement('canvas');
|
|
42
45
|
tile.width = image.naturalWidth;
|
package/dist/output/export.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { FileRenderExportAdapter, FileRenderExportOptions } from
|
|
1
|
+
import type { FileRenderExportAdapter, FileRenderExportOptions } from '../contracts/types.js';
|
|
2
|
+
/** Lightweight export helpers that remain on the normal viewer path. */
|
|
2
3
|
export declare const triggerFileViewerBlobDownload: (blob: Blob, name: string) => void;
|
|
3
4
|
export declare const triggerFileViewerUrlDownload: (url: string, name: string) => void;
|
|
4
5
|
export declare const replaceFileViewerCanvasWithImages: (source: HTMLElement, clone: HTMLElement) => void;
|
|
5
6
|
export declare const waitForFileViewerNextPaint: (targetWindow?: Partial<Pick<Window, "requestAnimationFrame" | "cancelAnimationFrame" | "setTimeout" | "clearTimeout">>) => Promise<void>;
|
|
6
7
|
export declare const waitForFileViewerImages: (root: ParentNode | null | undefined) => Promise<void>;
|
|
8
|
+
/** Rewrite ephemeral blob URLs into portable data URLs for export and print. */
|
|
7
9
|
export declare const inlineFileViewerBlobUrlsInHtml: (html: string) => Promise<string>;
|
|
8
10
|
export declare const waitForFileViewerPrintWindowReady: (printWindow: Window) => Promise<void>;
|
|
9
11
|
export declare const resolveFileViewerPrintStyle: (adapter: FileRenderExportAdapter | null, options: FileRenderExportOptions) => Promise<string>;
|
package/dist/output/export.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Lightweight export helpers that remain on the normal viewer path. */
|
|
1
2
|
export const triggerFileViewerBlobDownload = (blob, name) => {
|
|
2
3
|
const objectUrl = URL.createObjectURL(blob);
|
|
3
4
|
const link = document.createElement('a');
|
|
@@ -19,6 +20,9 @@ export const triggerFileViewerUrlDownload = (url, name) => {
|
|
|
19
20
|
link.click();
|
|
20
21
|
link.remove();
|
|
21
22
|
};
|
|
23
|
+
// Copy only presentation properties. The bitmap's pixel dimensions may be
|
|
24
|
+
// several times larger than its CSS box, and canvas-only selectors will no
|
|
25
|
+
// longer match after replacing the node with an image.
|
|
22
26
|
const CANVAS_PRESENTATION_PROPERTIES = [
|
|
23
27
|
'display', 'position', 'top', 'right', 'bottom', 'left', 'box-sizing',
|
|
24
28
|
'width', 'height', 'min-width', 'min-height', 'max-width', 'max-height',
|
|
@@ -52,6 +56,7 @@ export const replaceFileViewerCanvasWithImages = (source, clone) => {
|
|
|
52
56
|
image.style.setProperty(property, value, canvas.style.getPropertyPriority(property));
|
|
53
57
|
}
|
|
54
58
|
}
|
|
59
|
+
// Detached canvases have no used style; keep their normal intrinsic size.
|
|
55
60
|
if (!image.style.width || image.style.width === 'auto')
|
|
56
61
|
image.style.width = `${sourceCanvas.width}px`;
|
|
57
62
|
if (!image.style.height || image.style.height === 'auto')
|
|
@@ -59,6 +64,7 @@ export const replaceFileViewerCanvasWithImages = (source, clone) => {
|
|
|
59
64
|
canvas.replaceWith(image);
|
|
60
65
|
}
|
|
61
66
|
catch {
|
|
67
|
+
// A canvas tainted by cross-origin resources cannot be exported.
|
|
62
68
|
}
|
|
63
69
|
});
|
|
64
70
|
};
|
|
@@ -82,6 +88,7 @@ export const waitForFileViewerNextPaint = (targetWindow) => {
|
|
|
82
88
|
(_a = currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.cancelAnimationFrame) === null || _a === void 0 ? void 0 : _a.call(currentWindow, frame);
|
|
83
89
|
resolve();
|
|
84
90
|
};
|
|
91
|
+
// Background tabs and hidden print hosts may never run animation frames.
|
|
85
92
|
timeout = schedule(finish, (currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.requestAnimationFrame) ? 250 : 0);
|
|
86
93
|
if (finished || !(currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.requestAnimationFrame))
|
|
87
94
|
return;
|
|
@@ -116,6 +123,7 @@ const waitForImage = (image, timeoutMs) => {
|
|
|
116
123
|
image.removeEventListener('error', finish);
|
|
117
124
|
resolve();
|
|
118
125
|
};
|
|
126
|
+
// Start the timeout before decode(): a stalled decode must not bypass it.
|
|
119
127
|
const timeout = setTimeout(finish, timeoutMs);
|
|
120
128
|
image.addEventListener('load', finish, { once: true });
|
|
121
129
|
image.addEventListener('error', finish, { once: true });
|
|
@@ -124,6 +132,7 @@ const waitForImage = (image, timeoutMs) => {
|
|
|
124
132
|
else if (typeof image.decode === 'function') {
|
|
125
133
|
try {
|
|
126
134
|
image.decode().then(finish, () => {
|
|
135
|
+
// An error/load event may already have fired before decode rejects.
|
|
127
136
|
if (image.complete)
|
|
128
137
|
finish();
|
|
129
138
|
});
|
|
@@ -146,6 +155,7 @@ const waitForFonts = async (documentRef, timeoutMs) => {
|
|
|
146
155
|
]);
|
|
147
156
|
}
|
|
148
157
|
catch {
|
|
158
|
+
// A failed optional font should not prevent the browser's fallback print.
|
|
149
159
|
}
|
|
150
160
|
finally {
|
|
151
161
|
if (timeout !== undefined)
|
|
@@ -181,6 +191,7 @@ const blobToDataUrl = async (blob) => {
|
|
|
181
191
|
});
|
|
182
192
|
}
|
|
183
193
|
catch {
|
|
194
|
+
// Fall through to ArrayBuffer encoding for Node / incomplete FileReader shims.
|
|
184
195
|
}
|
|
185
196
|
}
|
|
186
197
|
return bytesToDataUrl(await blob.arrayBuffer(), blob.type || 'application/octet-stream');
|
|
@@ -189,6 +200,7 @@ const collectBlobUrls = (html) => {
|
|
|
189
200
|
const matches = html.match(/blob:[^\s"'<>)\\]+/g) || [];
|
|
190
201
|
return Array.from(new Set(matches));
|
|
191
202
|
};
|
|
203
|
+
/** Rewrite ephemeral blob URLs into portable data URLs for export and print. */
|
|
192
204
|
export const inlineFileViewerBlobUrlsInHtml = async (html) => {
|
|
193
205
|
if (!html.includes('blob:') || typeof fetch !== 'function') {
|
|
194
206
|
return html;
|
|
@@ -7,10 +7,15 @@ export interface ApplyPrintPageSizeOptions {
|
|
|
7
7
|
}
|
|
8
8
|
export interface BuildPrintPageStyleOptions extends PrintPageSize {
|
|
9
9
|
selector: string;
|
|
10
|
+
/** Per-page CSS pixel sizes, matched by data-viewer-print-page-index (fixed layout only). */
|
|
10
11
|
pages?: readonly PrintPageSize[];
|
|
11
12
|
heightMode?: 'fixed' | 'min';
|
|
12
13
|
}
|
|
13
14
|
export declare const formatCssPixels: (value: number) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Browser print helper. DOM measurement belongs in the core browser layer
|
|
17
|
+
* because it depends on CSS layout and HTMLElement.
|
|
18
|
+
*/
|
|
14
19
|
export declare const getElementPrintPageSize: (element: HTMLElement, fallback?: Partial<PrintPageSize>) => PrintPageSize;
|
|
15
20
|
export declare const applyPrintPageSize: (element: HTMLElement, size: PrintPageSize, options?: ApplyPrintPageSizeOptions) => void;
|
|
16
21
|
export declare const buildPrintPageStyle: ({ selector, width, height, heightMode, pages, }: BuildPrintPageStyleOptions) => string;
|
|
@@ -11,6 +11,10 @@ const readPositiveCssNumber = (value) => {
|
|
|
11
11
|
const parsed = Number.parseFloat(value);
|
|
12
12
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Browser print helper. DOM measurement belongs in the core browser layer
|
|
16
|
+
* because it depends on CSS layout and HTMLElement.
|
|
17
|
+
*/
|
|
14
18
|
export const getElementPrintPageSize = (element, fallback = {}) => {
|
|
15
19
|
var _a;
|
|
16
20
|
const style = (_a = element.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(element);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { FileRenderContext, FileViewerOptions } from
|
|
1
|
+
import type { FileRenderContext, FileViewerOptions } from '../contracts/types.js';
|
|
2
2
|
export declare const isFileViewerSnapshotDownloadPermitted: (options?: FileViewerOptions) => boolean;
|
|
3
|
+
/** Renderer-local downloads still use the owning viewer's hooks and request version. */
|
|
3
4
|
export declare const createFileViewerSnapshotDownload: ({ getOptions, isCurrent, beforeDownload }: {
|
|
4
5
|
getOptions: () => FileViewerOptions | undefined;
|
|
5
6
|
isCurrent: () => boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { isFileViewerToolbarOperationPermitted } from
|
|
2
|
-
import { triggerFileViewerBlobDownload } from
|
|
1
|
+
import { isFileViewerToolbarOperationPermitted } from '../lifecycle/operations.js';
|
|
2
|
+
import { triggerFileViewerBlobDownload } from './export.js';
|
|
3
3
|
export const isFileViewerSnapshotDownloadPermitted = (options) => isFileViewerToolbarOperationPermitted(options === null || options === void 0 ? void 0 : options.toolbar, 'download') &&
|
|
4
4
|
isFileViewerToolbarOperationPermitted(options === null || options === void 0 ? void 0 : options.toolbar, 'export-html');
|
|
5
|
+
/** Renderer-local downloads still use the owning viewer's hooks and request version. */
|
|
5
6
|
export const createFileViewerSnapshotDownload = ({ getOptions, isCurrent, beforeDownload }) => async (create) => {
|
|
6
7
|
var _a, _b;
|
|
7
8
|
const allowed = () => isCurrent() && isFileViewerSnapshotDownloadPermitted(getOptions());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerArchiveOptions, FileViewerCadOptions, FileViewerChmOptions, FileViewerDataOptions, FileViewerDesignOptions, FileViewerDocxOptions, FileViewerDrawingOptions, FileViewerIworkOptions, FileViewerHangulOptions, FileViewerModelOptions, FileViewerOptions, FileViewerPdfOptions, FileViewerPresentationOptions, FileViewerSpreadsheetOptions, FileViewerTypstOptions, FileViewerWordPerfectOptions } from
|
|
1
|
+
import type { FileViewerArchiveOptions, FileViewerCadOptions, FileViewerChmOptions, FileViewerDataOptions, FileViewerDesignOptions, FileViewerDocxOptions, FileViewerDrawingOptions, FileViewerIworkOptions, FileViewerHangulOptions, FileViewerModelOptions, FileViewerOptions, FileViewerPdfOptions, FileViewerPresentationOptions, FileViewerSpreadsheetOptions, FileViewerTypstOptions, FileViewerWordPerfectOptions } from '../contracts/types.js';
|
|
2
2
|
export declare const DEFAULT_FILE_VIEWER_ARCHIVE_WORKER_PATH = "vendor/libarchive/worker-bundle.js";
|
|
3
3
|
export declare const DEFAULT_FILE_VIEWER_ARCHIVE_WASM_PATH = "vendor/libarchive/libarchive.wasm";
|
|
4
4
|
export declare const DEFAULT_FILE_VIEWER_CHM_WORKER_PATH = "vendor/chm/chm.worker.js";
|
|
@@ -9,7 +9,7 @@ export declare const DEFAULT_FILE_VIEWER_CHM_WASM_PATH = "vendor/chm/chm_wasm_bg
|
|
|
9
9
|
export declare const DEFAULT_FILE_VIEWER_CHM_WASM_PACKAGE_PATH = "@file-viewer/renderer-chm/wasm/chm_wasm_bg.wasm";
|
|
10
10
|
export declare const DEFAULT_FILE_VIEWER_DOCX_WORKER_PATH = "vendor/docx/docx.worker.js";
|
|
11
11
|
export declare const DEFAULT_FILE_VIEWER_DOCX_WORKER_JSZIP_PATH = "vendor/docx/jszip.min.js";
|
|
12
|
-
export declare const DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION = "0.3.
|
|
12
|
+
export declare const DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION = "0.3.39";
|
|
13
13
|
export declare const DEFAULT_FILE_VIEWER_PRESENTATION_WORKER_PATH = "vendor/pptx/pptx.worker.js";
|
|
14
14
|
export declare const DEFAULT_FILE_VIEWER_PPT_RUNTIME_PATH = "vendor/ppt";
|
|
15
15
|
export declare const DEFAULT_FILE_VIEWER_PPT_RUNTIME_VERSION = "0.3.6";
|
|
@@ -127,6 +127,13 @@ export interface ResolveFileViewerAssetUrlOptions {
|
|
|
127
127
|
export declare const normalizeFileViewerAssetBaseUrl: (baseUrl?: string | URL | null) => string | undefined;
|
|
128
128
|
export declare const setDefaultFileViewerAssetBaseUrl: (baseUrl?: string | URL | null) => void;
|
|
129
129
|
export declare const resetDefaultFileViewerAssetBaseUrl: () => void;
|
|
130
|
+
/**
|
|
131
|
+
* Resolves the stable public base for runtime assets without reading
|
|
132
|
+
* bundler-specific environment metadata or webpack public-path variables.
|
|
133
|
+
* Explicit HTML `<base>` configuration stays authoritative; for SPA fallback
|
|
134
|
+
* routes, emitted Vite/Webpack/UMI entry scripts reveal the deployment root
|
|
135
|
+
* more reliably than the route-derived page URL.
|
|
136
|
+
*/
|
|
130
137
|
export declare const resolveFileViewerRuntimeAssetBaseUrl: (documentRef: Document) => string;
|
|
131
138
|
export declare const getDefaultFileViewerAssetBaseUrl: (documentRef?: Document | null) => string | undefined;
|
|
132
139
|
export interface ResolvedFileViewerCadAssetUrls {
|
package/dist/platform/assets.js
CHANGED
|
@@ -8,7 +8,7 @@ export const DEFAULT_FILE_VIEWER_CHM_WASM_PATH = 'vendor/chm/chm_wasm_bg.wasm';
|
|
|
8
8
|
export const DEFAULT_FILE_VIEWER_CHM_WASM_PACKAGE_PATH = '@file-viewer/renderer-chm/wasm/chm_wasm_bg.wasm';
|
|
9
9
|
export const DEFAULT_FILE_VIEWER_DOCX_WORKER_PATH = 'vendor/docx/docx.worker.js';
|
|
10
10
|
export const DEFAULT_FILE_VIEWER_DOCX_WORKER_JSZIP_PATH = 'vendor/docx/jszip.min.js';
|
|
11
|
-
export const DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION = '0.3.
|
|
11
|
+
export const DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION = '0.3.39';
|
|
12
12
|
export const DEFAULT_FILE_VIEWER_PRESENTATION_WORKER_PATH = 'vendor/pptx/pptx.worker.js';
|
|
13
13
|
export const DEFAULT_FILE_VIEWER_PPT_RUNTIME_PATH = 'vendor/ppt';
|
|
14
14
|
export const DEFAULT_FILE_VIEWER_PPT_RUNTIME_VERSION = '0.3.6';
|
|
@@ -45,6 +45,8 @@ export const DEFAULT_FILE_VIEWER_CAD_LIBREDWG_WASM_PATH = `${DEFAULT_FILE_VIEWER
|
|
|
45
45
|
export const DEFAULT_FILE_VIEWER_TYPST_COMPILER_WASM_URL = 'wasm/typst/typst_ts_web_compiler_bg.wasm';
|
|
46
46
|
export const DEFAULT_FILE_VIEWER_TYPST_RENDERER_WASM_URL = 'wasm/typst/typst_ts_renderer_bg.wasm';
|
|
47
47
|
export const DEFAULT_FILE_VIEWER_TYPST_FONT_ASSETS_URL = 'wasm/typst/fonts/';
|
|
48
|
+
// Compatibility aliases kept for older imports. They intentionally resolve to
|
|
49
|
+
// local viewer assets; the preview runtime must not fall back to a public CDN.
|
|
48
50
|
export const FALLBACK_FILE_VIEWER_TYPST_COMPILER_WASM_URL = DEFAULT_FILE_VIEWER_TYPST_COMPILER_WASM_URL;
|
|
49
51
|
export const FALLBACK_FILE_VIEWER_TYPST_RENDERER_WASM_URL = DEFAULT_FILE_VIEWER_TYPST_RENDERER_WASM_URL;
|
|
50
52
|
export const DEFAULT_FILE_VIEWER_TYPST_COMPILER_WASM_PACKAGE_PATH = '@myriaddreamin/typst-ts-web-compiler/pkg/typst_ts_web_compiler_bg.wasm';
|
|
@@ -171,6 +173,9 @@ const resolveFileViewerScriptAssetBaseCandidate = (script, documentBaseUrl, inde
|
|
|
171
173
|
score += 8;
|
|
172
174
|
}
|
|
173
175
|
if (documentPathname.startsWith(candidateUrl.pathname)) {
|
|
176
|
+
// Prefer the deepest candidate that is still an ancestor of the SPA
|
|
177
|
+
// route. This avoids stripping an earlier deployment segment named
|
|
178
|
+
// `assets` when the emitted suffix is actually `static/js`.
|
|
174
179
|
score += 16 + pathDepth(candidateUrl.pathname) / 4;
|
|
175
180
|
}
|
|
176
181
|
if (script.type === 'module') {
|
|
@@ -225,6 +230,13 @@ const resolveFileViewerScriptAssetBaseCandidate = (script, documentBaseUrl, inde
|
|
|
225
230
|
return [];
|
|
226
231
|
}
|
|
227
232
|
};
|
|
233
|
+
/**
|
|
234
|
+
* Resolves the stable public base for runtime assets without reading
|
|
235
|
+
* bundler-specific environment metadata or webpack public-path variables.
|
|
236
|
+
* Explicit HTML `<base>` configuration stays authoritative; for SPA fallback
|
|
237
|
+
* routes, emitted Vite/Webpack/UMI entry scripts reveal the deployment root
|
|
238
|
+
* more reliably than the route-derived page URL.
|
|
239
|
+
*/
|
|
228
240
|
export const resolveFileViewerRuntimeAssetBaseUrl = (documentRef) => {
|
|
229
241
|
var _a;
|
|
230
242
|
const documentBaseUrl = documentRef.baseURI || documentRef.URL || 'file:///';
|
|
@@ -251,6 +263,8 @@ export const getDefaultFileViewerAssetBaseUrl = (documentRef) => {
|
|
|
251
263
|
if (configuredFileViewerAssetBaseUrl !== automaticFileViewerAssetBaseUrl) {
|
|
252
264
|
return configuredFileViewerAssetBaseUrl;
|
|
253
265
|
}
|
|
266
|
+
// Core remains environment-neutral: callers that want automatic browser
|
|
267
|
+
// inference pass their owning Document explicitly.
|
|
254
268
|
return documentRef ? resolveFileViewerRuntimeAssetBaseUrl(documentRef) : undefined;
|
|
255
269
|
};
|
|
256
270
|
const createDesignThirdPartyAssets = (rendererId, includeContainerXmlLicenses = false) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFileViewerRendererAssetManifest, resolveFileViewerRuntimeAssetBaseUrl } from
|
|
1
|
+
import { getFileViewerRendererAssetManifest, resolveFileViewerRuntimeAssetBaseUrl } from './assets.js';
|
|
2
2
|
const manifests = new WeakMap();
|
|
3
3
|
const MAX_MANIFEST_BYTES = 1024 * 1024;
|
|
4
4
|
const readManifest = async (url, signal) => {
|
|
@@ -56,6 +56,7 @@ const readManifest = async (url, signal) => {
|
|
|
56
56
|
signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', abort);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
+
/** Finds assets copied by the standard CLI without trusting a SPA fallback or arbitrary manifest URLs. */
|
|
59
60
|
export async function resolveFileViewerCopiedAssetUrl(documentRef, rendererId, assetId, signal) {
|
|
60
61
|
var _a, _b, _c;
|
|
61
62
|
const asset = (_a = getFileViewerRendererAssetManifest(rendererId)) === null || _a === void 0 ? void 0 : _a.assets.find((item) => item.id === assetId);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FileViewerResolvedThemeMode, FileViewerThemeMode } from '../contracts/types.js';
|
|
2
|
+
/** Observe the owning viewer, including hosts across a shadow boundary. */
|
|
3
|
+
export declare const observeFileViewerColorScheme: (target: HTMLElement, fallback: FileViewerThemeMode | undefined, apply: (theme: FileViewerResolvedThemeMode) => void) => () => void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { resolveFileViewerColorScheme } from '../config/options.js';
|
|
2
|
+
/** Observe the owning viewer, including hosts across a shadow boundary. */
|
|
3
|
+
export const observeFileViewerColorScheme = (target, fallback, apply) => {
|
|
4
|
+
var _a;
|
|
5
|
+
const view = target.ownerDocument.defaultView;
|
|
6
|
+
const media = (_a = view === null || view === void 0 ? void 0 : view.matchMedia) === null || _a === void 0 ? void 0 : _a.call(view, '(prefers-color-scheme: dark)');
|
|
7
|
+
const ancestors = [];
|
|
8
|
+
let element = target;
|
|
9
|
+
while (element) {
|
|
10
|
+
ancestors.push(element);
|
|
11
|
+
const root = element.getRootNode();
|
|
12
|
+
element = element.parentElement || root.host || null;
|
|
13
|
+
}
|
|
14
|
+
let current;
|
|
15
|
+
const update = () => {
|
|
16
|
+
var _a;
|
|
17
|
+
const inherited = ancestors
|
|
18
|
+
.map((node) => node.getAttribute('data-viewer-theme'))
|
|
19
|
+
.find((value) => value === 'light' || value === 'dark' || value === 'system');
|
|
20
|
+
const next = resolveFileViewerColorScheme(inherited || fallback, (_a = media === null || media === void 0 ? void 0 : media.matches) !== null && _a !== void 0 ? _a : false);
|
|
21
|
+
if (next !== current) {
|
|
22
|
+
current = next;
|
|
23
|
+
apply(next);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const observer = (view === null || view === void 0 ? void 0 : view.MutationObserver) ? new view.MutationObserver(update) : undefined;
|
|
27
|
+
ancestors.forEach((node) => observer === null || observer === void 0 ? void 0 : observer.observe(node, { attributes: true, attributeFilter: ['data-viewer-theme'] }));
|
|
28
|
+
if (media === null || media === void 0 ? void 0 : media.addEventListener)
|
|
29
|
+
media.addEventListener('change', update);
|
|
30
|
+
else
|
|
31
|
+
media === null || media === void 0 ? void 0 : media.addListener(update);
|
|
32
|
+
update();
|
|
33
|
+
return () => {
|
|
34
|
+
observer === null || observer === void 0 ? void 0 : observer.disconnect();
|
|
35
|
+
if (media === null || media === void 0 ? void 0 : media.removeEventListener)
|
|
36
|
+
media.removeEventListener('change', update);
|
|
37
|
+
else
|
|
38
|
+
media === null || media === void 0 ? void 0 : media.removeListener(update);
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerFileRef, FileViewerOptions, FileViewerThemeMode, FileViewerToolbarOptions, FileViewerUiDensity } from
|
|
1
|
+
import type { FileViewerFileRef, FileViewerOptions, FileViewerThemeMode, FileViewerToolbarOptions, FileViewerUiDensity } from '../contracts/types.js';
|
|
2
2
|
export interface ResolveFileViewerPresentationStateInput {
|
|
3
3
|
filename?: string;
|
|
4
4
|
file?: FileViewerFileRef;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { normalizeFileViewerToolbar } from
|
|
2
|
-
import { normalizeFileViewerTheme, resolveFileViewerUiDensity } from
|
|
3
|
-
import { getExtension, resolveFileViewerSourceFilename } from
|
|
1
|
+
import { normalizeFileViewerToolbar } from '../lifecycle/operations.js';
|
|
2
|
+
import { normalizeFileViewerTheme, resolveFileViewerUiDensity } from '../config/options.js';
|
|
3
|
+
import { getExtension, resolveFileViewerSourceFilename } from '../source/index.js';
|
|
4
4
|
export const resolveFileViewerPresentationState = ({ filename, file, url, options, }) => {
|
|
5
5
|
const displayFilename = resolveFileViewerSourceFilename({
|
|
6
6
|
filename,
|
package/dist/print-mask.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { openFileViewerPrintMaskDesigner, } from
|
|
2
|
-
export type { FileViewerPrintMaskDesignerResult, OpenFileViewerPrintMaskDesignerOptions, } from
|
|
1
|
+
export { openFileViewerPrintMaskDesigner, } from './features/printMaskDesigner.js';
|
|
2
|
+
export type { FileViewerPrintMaskDesignerResult, OpenFileViewerPrintMaskDesignerOptions, } from './features/printMaskDesigner.js';
|
package/dist/print-mask.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { openFileViewerPrintMaskDesigner, } from
|
|
1
|
+
export { openFileViewerPrintMaskDesigner, } from './features/printMaskDesigner.js';
|
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
import type { FileRenderExportAdapter, FileViewerOperationAvailability, FileViewerZoomState, RendererDefinition, RendererSession } from
|
|
1
|
+
import type { FileRenderExportAdapter, FileViewerOperationAvailability, FileViewerZoomState, RendererDefinition, RendererSession } from '../contracts/types.js';
|
|
2
2
|
export declare const DEFAULT_OPERATION_AVAILABILITY: FileViewerOperationAvailability;
|
|
3
3
|
export declare const getRendererAvailability: (renderer: RendererDefinition | undefined, session?: RendererSession | null) => FileViewerOperationAvailability;
|
|
4
4
|
export declare const applyFileViewerZoomAvailability: (availability: FileViewerOperationAvailability, zoomState: FileViewerZoomState) => FileViewerOperationAvailability;
|
|
5
5
|
export declare const createUnsupportedAvailability: (extension: string) => FileViewerOperationAvailability;
|
|
6
|
+
/**
|
|
7
|
+
* 这些格式只有专属适配器准备好后才展示打印。
|
|
8
|
+
*
|
|
9
|
+
* 它们的在线预览常依赖分页引擎、虚拟渲染或 Worker 生命周期,直接克隆
|
|
10
|
+
* DOM 很容易只得到当前页或当前视口。
|
|
11
|
+
*/
|
|
6
12
|
export declare const ADAPTER_PRINT_REQUIRED_EXTENSIONS: readonly ["docx", "docm", "dotx", "dotm", "doc", "dot", "ppt", "pdf", "typ", "typst"];
|
|
13
|
+
/**
|
|
14
|
+
* 这些格式的预览结果是完整 DOM / SVG / Canvas 截图,解除滚动容器裁切后
|
|
15
|
+
* 可以稳定进入浏览器打印流程。
|
|
16
|
+
*/
|
|
7
17
|
export declare const DOM_PRINTABLE_EXTENSIONS: readonly ["pptx", "pptm", "potx", "potm", "ppsx", "ppsm", "ofd", "dxf", "dwg", "dwf", "dwfx", "xps", "excalidraw", "drawio", "dio", "mermaid", "mmd", "plantuml", "puml", "umd", "md", "markdown", "olb", "dra", ...("markdown" | "webp" | "jpeg" | "png" | "pdf" | "xyz" | "wasm" | "chm" | "typst" | "xd" | "fla" | "js" | "html" | "svg" | "rb" | "docx" | "docm" | "dotx" | "dotm" | "doc" | "dot" | "ppt" | "pot" | "pptx" | "pptm" | "potx" | "potm" | "ppsx" | "ppsm" | "rtf" | "odt" | "odp" | "xlsx" | "xltx" | "xlsm" | "xlsb" | "xls" | "xlt" | "xla" | "xlam" | "xltm" | "csv" | "tsv" | "ods" | "fods" | "pages" | "numbers" | "key" | "wpd" | "wp" | "wp5" | "wp6" | "dbf" | "ofd" | "hwp" | "hwpx" | "typ" | "zip" | "zipx" | "7z" | "rar" | "tar" | "gz" | "gzip" | "tgz" | "bz2" | "bzip2" | "tbz" | "tbz2" | "xz" | "txz" | "lzma" | "zst" | "tzst" | "cab" | "ar" | "cpio" | "iso" | "xar" | "lha" | "lzh" | "jar" | "war" | "ear" | "apk" | "cbz" | "cbr" | "eml" | "msg" | "mbox" | "olb" | "dra" | "gds" | "oas" | "oasis" | "dxf" | "dwg" | "dwf" | "dwfx" | "xps" | "glb" | "gltf" | "obj" | "stl" | "ply" | "fbx" | "dae" | "3ds" | "3mf" | "amf" | "usd" | "usda" | "usdc" | "usdz" | "kmz" | "step" | "stp" | "iges" | "igs" | "ifc" | "3dm" | "brep" | "pcd" | "wrl" | "vrml" | "vtk" | "vtp" | "geojson" | "kml" | "gpx" | "shp" | "excalidraw" | "drawio" | "dio" | "mermaid" | "mmd" | "plantuml" | "puml" | "bpmn" | "xmind" | "epub" | "fb2" | "umd" | "gif" | "jpg" | "bmp" | "tiff" | "tif" | "avif" | "ico" | "heic" | "heif" | "jxl" | "dicom" | "dcm" | "p7m" | "p7s" | "p7c" | "p7b" | "pkcs7" | "cms" | "cmsc" | "tsd" | "tst" | "tsq" | "tsr" | "asics" | "scs" | "asice" | "sce" | "ers" | "asc" | "sig" | "pgp" | "gpg" | "jws" | "md" | "txt" | "lrc" | "json" | "mjs" | "cjs" | "css" | "java" | "py" | "htm" | "jsx" | "ts" | "tsx" | "xml" | "log" | "vue" | "yaml" | "yml" | "ini" | "sh" | "bash" | "sql" | "go" | "rs" | "php" | "c" | "cpp" | "cc" | "h" | "hpp" | "cs" | "diff" | "patch" | "bundle" | "bdl" | "jsonc" | "json5" | "ipynb" | "toml" | "proto" | "hcl" | "tex" | "gv" | "http" | "react" | "swift" | "kt" | "mp4" | "webm" | "m3u8" | "mp3" | "mpeg" | "wav" | "ogg" | "oga" | "opus" | "m4a" | "aac" | "flac" | "weba" | "midi" | "mid" | "psb" | "pdd" | "psdt" | "psd" | "ait" | "ai" | "idml" | "icml" | "idms" | "inx" | "xfl" | "indd" | "indt" | "ps" | "eps" | "ase" | "aco" | "abr" | "csh" | "pat" | "grd" | "asl" | "ttf" | "otf" | "woff" | "woff2" | "sqlite" | "parquet" | "avro" | "webarchive" | "bin" | "hex" | "elf" | "exe" | "dll" | "class" | "macho")[]];
|
|
18
|
+
/**
|
|
19
|
+
* 这些格式默认不展示打印按钮,避免导出半截内容。
|
|
20
|
+
*/
|
|
8
21
|
export declare const NON_PRINTABLE_EXTENSIONS: readonly ["xlsx", "xltx", "xlsm", "xlsb", "xls", "xlt", "xltm", "csv", "tsv", "ods", "fods", "numbers", ...("markdown" | "webp" | "jpeg" | "png" | "pdf" | "xyz" | "wasm" | "chm" | "typst" | "xd" | "fla" | "js" | "html" | "svg" | "rb" | "docx" | "docm" | "dotx" | "dotm" | "doc" | "dot" | "ppt" | "pot" | "pptx" | "pptm" | "potx" | "potm" | "ppsx" | "ppsm" | "rtf" | "odt" | "odp" | "xlsx" | "xltx" | "xlsm" | "xlsb" | "xls" | "xlt" | "xla" | "xlam" | "xltm" | "csv" | "tsv" | "ods" | "fods" | "pages" | "numbers" | "key" | "wpd" | "wp" | "wp5" | "wp6" | "dbf" | "ofd" | "hwp" | "hwpx" | "typ" | "zip" | "zipx" | "7z" | "rar" | "tar" | "gz" | "gzip" | "tgz" | "bz2" | "bzip2" | "tbz" | "tbz2" | "xz" | "txz" | "lzma" | "zst" | "tzst" | "cab" | "ar" | "cpio" | "iso" | "xar" | "lha" | "lzh" | "jar" | "war" | "ear" | "apk" | "cbz" | "cbr" | "eml" | "msg" | "mbox" | "olb" | "dra" | "gds" | "oas" | "oasis" | "dxf" | "dwg" | "dwf" | "dwfx" | "xps" | "glb" | "gltf" | "obj" | "stl" | "ply" | "fbx" | "dae" | "3ds" | "3mf" | "amf" | "usd" | "usda" | "usdc" | "usdz" | "kmz" | "step" | "stp" | "iges" | "igs" | "ifc" | "3dm" | "brep" | "pcd" | "wrl" | "vrml" | "vtk" | "vtp" | "geojson" | "kml" | "gpx" | "shp" | "excalidraw" | "drawio" | "dio" | "mermaid" | "mmd" | "plantuml" | "puml" | "bpmn" | "xmind" | "epub" | "fb2" | "umd" | "gif" | "jpg" | "bmp" | "tiff" | "tif" | "avif" | "ico" | "heic" | "heif" | "jxl" | "dicom" | "dcm" | "p7m" | "p7s" | "p7c" | "p7b" | "pkcs7" | "cms" | "cmsc" | "tsd" | "tst" | "tsq" | "tsr" | "asics" | "scs" | "asice" | "sce" | "ers" | "asc" | "sig" | "pgp" | "gpg" | "jws" | "md" | "txt" | "lrc" | "json" | "mjs" | "cjs" | "css" | "java" | "py" | "htm" | "jsx" | "ts" | "tsx" | "xml" | "log" | "vue" | "yaml" | "yml" | "ini" | "sh" | "bash" | "sql" | "go" | "rs" | "php" | "c" | "cpp" | "cc" | "h" | "hpp" | "cs" | "diff" | "patch" | "bundle" | "bdl" | "jsonc" | "json5" | "ipynb" | "toml" | "proto" | "hcl" | "tex" | "gv" | "http" | "react" | "swift" | "kt" | "mp4" | "webm" | "m3u8" | "mp3" | "mpeg" | "wav" | "ogg" | "oga" | "opus" | "m4a" | "aac" | "flac" | "weba" | "midi" | "mid" | "psb" | "pdd" | "psdt" | "psd" | "ait" | "ai" | "idml" | "icml" | "idms" | "inx" | "xfl" | "indd" | "indt" | "ps" | "eps" | "ase" | "aco" | "abr" | "csh" | "pat" | "grd" | "asl" | "ttf" | "otf" | "woff" | "woff2" | "sqlite" | "parquet" | "avro" | "webarchive" | "bin" | "hex" | "elf" | "exe" | "dll" | "class" | "macho")[]];
|
|
9
22
|
export declare const needsDedicatedPrintAdapter: (extension: string) => boolean;
|
|
10
23
|
export declare const isDomPrintableExtension: (extension: string) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ARCHIVE_EXTENSIONS, IMAGE_EXTENSIONS, MODEL_EXTENSIONS, TEXT_EXTENSIONS } from
|
|
2
|
-
import { normalizeFileExtension } from
|
|
1
|
+
import { ARCHIVE_EXTENSIONS, IMAGE_EXTENSIONS, MODEL_EXTENSIONS, TEXT_EXTENSIONS } from './formats.js';
|
|
2
|
+
import { normalizeFileExtension } from '../source/index.js';
|
|
3
3
|
export const DEFAULT_OPERATION_AVAILABILITY = Object.freeze({
|
|
4
4
|
download: false,
|
|
5
5
|
print: false,
|
|
@@ -45,9 +45,19 @@ export const createUnsupportedAvailability = (extension) => ({
|
|
|
45
45
|
...DEFAULT_OPERATION_AVAILABILITY,
|
|
46
46
|
download: normalizeFileExtension(extension).length > 0,
|
|
47
47
|
});
|
|
48
|
+
/**
|
|
49
|
+
* 这些格式只有专属适配器准备好后才展示打印。
|
|
50
|
+
*
|
|
51
|
+
* 它们的在线预览常依赖分页引擎、虚拟渲染或 Worker 生命周期,直接克隆
|
|
52
|
+
* DOM 很容易只得到当前页或当前视口。
|
|
53
|
+
*/
|
|
48
54
|
export const ADAPTER_PRINT_REQUIRED_EXTENSIONS = [
|
|
49
55
|
'docx', 'docm', 'dotx', 'dotm', 'doc', 'dot', 'ppt', 'pdf', 'typ', 'typst',
|
|
50
56
|
];
|
|
57
|
+
/**
|
|
58
|
+
* 这些格式的预览结果是完整 DOM / SVG / Canvas 截图,解除滚动容器裁切后
|
|
59
|
+
* 可以稳定进入浏览器打印流程。
|
|
60
|
+
*/
|
|
51
61
|
export const DOM_PRINTABLE_EXTENSIONS = [
|
|
52
62
|
'pptx', 'pptm', 'potx', 'potm', 'ppsx', 'ppsm', 'ofd', 'dxf', 'dwg', 'dwf', 'dwfx', 'xps',
|
|
53
63
|
'excalidraw', 'drawio', 'dio', 'mermaid', 'mmd', 'plantuml', 'puml', 'umd', 'md', 'markdown',
|
|
@@ -55,6 +65,9 @@ export const DOM_PRINTABLE_EXTENSIONS = [
|
|
|
55
65
|
...TEXT_EXTENSIONS,
|
|
56
66
|
...IMAGE_EXTENSIONS,
|
|
57
67
|
];
|
|
68
|
+
/**
|
|
69
|
+
* 这些格式默认不展示打印按钮,避免导出半截内容。
|
|
70
|
+
*/
|
|
58
71
|
export const NON_PRINTABLE_EXTENSIONS = [
|
|
59
72
|
'xlsx', 'xltx', 'xlsm', 'xlsb', 'xls', 'xlt', 'xltm', 'csv', 'tsv', 'ods', 'fods', 'numbers',
|
|
60
73
|
...ARCHIVE_EXTENSIONS,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DEFAULT_REGISTERED_EXTENSIONS, DEFAULT_RENDERER_DEFINITIONS, DEFAULT_STABLE_SUPPORTED_EXTENSIONS, DEFAULT_SUPPORTED_EXTENSIONS, } from
|
|
1
|
+
export { DEFAULT_REGISTERED_EXTENSIONS, DEFAULT_RENDERER_DEFINITIONS, DEFAULT_STABLE_SUPPORTED_EXTENSIONS, DEFAULT_SUPPORTED_EXTENSIONS, } from './formats.generated.js';
|
|
2
2
|
export declare const ARCHIVE_EXTENSIONS: readonly ("markdown" | "webp" | "jpeg" | "png" | "pdf" | "xyz" | "wasm" | "chm" | "typst" | "xd" | "fla" | "js" | "html" | "svg" | "rb" | "docx" | "docm" | "dotx" | "dotm" | "doc" | "dot" | "ppt" | "pot" | "pptx" | "pptm" | "potx" | "potm" | "ppsx" | "ppsm" | "rtf" | "odt" | "odp" | "xlsx" | "xltx" | "xlsm" | "xlsb" | "xls" | "xlt" | "xla" | "xlam" | "xltm" | "csv" | "tsv" | "ods" | "fods" | "pages" | "numbers" | "key" | "wpd" | "wp" | "wp5" | "wp6" | "dbf" | "ofd" | "hwp" | "hwpx" | "typ" | "zip" | "zipx" | "7z" | "rar" | "tar" | "gz" | "gzip" | "tgz" | "bz2" | "bzip2" | "tbz" | "tbz2" | "xz" | "txz" | "lzma" | "zst" | "tzst" | "cab" | "ar" | "cpio" | "iso" | "xar" | "lha" | "lzh" | "jar" | "war" | "ear" | "apk" | "cbz" | "cbr" | "eml" | "msg" | "mbox" | "olb" | "dra" | "gds" | "oas" | "oasis" | "dxf" | "dwg" | "dwf" | "dwfx" | "xps" | "glb" | "gltf" | "obj" | "stl" | "ply" | "fbx" | "dae" | "3ds" | "3mf" | "amf" | "usd" | "usda" | "usdc" | "usdz" | "kmz" | "step" | "stp" | "iges" | "igs" | "ifc" | "3dm" | "brep" | "pcd" | "wrl" | "vrml" | "vtk" | "vtp" | "geojson" | "kml" | "gpx" | "shp" | "excalidraw" | "drawio" | "dio" | "mermaid" | "mmd" | "plantuml" | "puml" | "bpmn" | "xmind" | "epub" | "fb2" | "umd" | "gif" | "jpg" | "bmp" | "tiff" | "tif" | "avif" | "ico" | "heic" | "heif" | "jxl" | "dicom" | "dcm" | "p7m" | "p7s" | "p7c" | "p7b" | "pkcs7" | "cms" | "cmsc" | "tsd" | "tst" | "tsq" | "tsr" | "asics" | "scs" | "asice" | "sce" | "ers" | "asc" | "sig" | "pgp" | "gpg" | "jws" | "md" | "txt" | "lrc" | "json" | "mjs" | "cjs" | "css" | "java" | "py" | "htm" | "jsx" | "ts" | "tsx" | "xml" | "log" | "vue" | "yaml" | "yml" | "ini" | "sh" | "bash" | "sql" | "go" | "rs" | "php" | "c" | "cpp" | "cc" | "h" | "hpp" | "cs" | "diff" | "patch" | "bundle" | "bdl" | "jsonc" | "json5" | "ipynb" | "toml" | "proto" | "hcl" | "tex" | "gv" | "http" | "react" | "swift" | "kt" | "mp4" | "webm" | "m3u8" | "mp3" | "mpeg" | "wav" | "ogg" | "oga" | "opus" | "m4a" | "aac" | "flac" | "weba" | "midi" | "mid" | "psb" | "pdd" | "psdt" | "psd" | "ait" | "ai" | "idml" | "icml" | "idms" | "inx" | "xfl" | "indd" | "indt" | "ps" | "eps" | "ase" | "aco" | "abr" | "csh" | "pat" | "grd" | "asl" | "ttf" | "otf" | "woff" | "woff2" | "sqlite" | "parquet" | "avro" | "webarchive" | "bin" | "hex" | "elf" | "exe" | "dll" | "class" | "macho")[];
|
|
3
3
|
export declare const MODEL_EXTENSIONS: readonly ("markdown" | "webp" | "jpeg" | "png" | "pdf" | "xyz" | "wasm" | "chm" | "typst" | "xd" | "fla" | "js" | "html" | "svg" | "rb" | "docx" | "docm" | "dotx" | "dotm" | "doc" | "dot" | "ppt" | "pot" | "pptx" | "pptm" | "potx" | "potm" | "ppsx" | "ppsm" | "rtf" | "odt" | "odp" | "xlsx" | "xltx" | "xlsm" | "xlsb" | "xls" | "xlt" | "xla" | "xlam" | "xltm" | "csv" | "tsv" | "ods" | "fods" | "pages" | "numbers" | "key" | "wpd" | "wp" | "wp5" | "wp6" | "dbf" | "ofd" | "hwp" | "hwpx" | "typ" | "zip" | "zipx" | "7z" | "rar" | "tar" | "gz" | "gzip" | "tgz" | "bz2" | "bzip2" | "tbz" | "tbz2" | "xz" | "txz" | "lzma" | "zst" | "tzst" | "cab" | "ar" | "cpio" | "iso" | "xar" | "lha" | "lzh" | "jar" | "war" | "ear" | "apk" | "cbz" | "cbr" | "eml" | "msg" | "mbox" | "olb" | "dra" | "gds" | "oas" | "oasis" | "dxf" | "dwg" | "dwf" | "dwfx" | "xps" | "glb" | "gltf" | "obj" | "stl" | "ply" | "fbx" | "dae" | "3ds" | "3mf" | "amf" | "usd" | "usda" | "usdc" | "usdz" | "kmz" | "step" | "stp" | "iges" | "igs" | "ifc" | "3dm" | "brep" | "pcd" | "wrl" | "vrml" | "vtk" | "vtp" | "geojson" | "kml" | "gpx" | "shp" | "excalidraw" | "drawio" | "dio" | "mermaid" | "mmd" | "plantuml" | "puml" | "bpmn" | "xmind" | "epub" | "fb2" | "umd" | "gif" | "jpg" | "bmp" | "tiff" | "tif" | "avif" | "ico" | "heic" | "heif" | "jxl" | "dicom" | "dcm" | "p7m" | "p7s" | "p7c" | "p7b" | "pkcs7" | "cms" | "cmsc" | "tsd" | "tst" | "tsq" | "tsr" | "asics" | "scs" | "asice" | "sce" | "ers" | "asc" | "sig" | "pgp" | "gpg" | "jws" | "md" | "txt" | "lrc" | "json" | "mjs" | "cjs" | "css" | "java" | "py" | "htm" | "jsx" | "ts" | "tsx" | "xml" | "log" | "vue" | "yaml" | "yml" | "ini" | "sh" | "bash" | "sql" | "go" | "rs" | "php" | "c" | "cpp" | "cc" | "h" | "hpp" | "cs" | "diff" | "patch" | "bundle" | "bdl" | "jsonc" | "json5" | "ipynb" | "toml" | "proto" | "hcl" | "tex" | "gv" | "http" | "react" | "swift" | "kt" | "mp4" | "webm" | "m3u8" | "mp3" | "mpeg" | "wav" | "ogg" | "oga" | "opus" | "m4a" | "aac" | "flac" | "weba" | "midi" | "mid" | "psb" | "pdd" | "psdt" | "psd" | "ait" | "ai" | "idml" | "icml" | "idms" | "inx" | "xfl" | "indd" | "indt" | "ps" | "eps" | "ase" | "aco" | "abr" | "csh" | "pat" | "grd" | "asl" | "ttf" | "otf" | "woff" | "woff2" | "sqlite" | "parquet" | "avro" | "webarchive" | "bin" | "hex" | "elf" | "exe" | "dll" | "class" | "macho")[];
|
|
4
4
|
export declare const TEXT_EXTENSIONS: readonly ("markdown" | "webp" | "jpeg" | "png" | "pdf" | "xyz" | "wasm" | "chm" | "typst" | "xd" | "fla" | "js" | "html" | "svg" | "rb" | "docx" | "docm" | "dotx" | "dotm" | "doc" | "dot" | "ppt" | "pot" | "pptx" | "pptm" | "potx" | "potm" | "ppsx" | "ppsm" | "rtf" | "odt" | "odp" | "xlsx" | "xltx" | "xlsm" | "xlsb" | "xls" | "xlt" | "xla" | "xlam" | "xltm" | "csv" | "tsv" | "ods" | "fods" | "pages" | "numbers" | "key" | "wpd" | "wp" | "wp5" | "wp6" | "dbf" | "ofd" | "hwp" | "hwpx" | "typ" | "zip" | "zipx" | "7z" | "rar" | "tar" | "gz" | "gzip" | "tgz" | "bz2" | "bzip2" | "tbz" | "tbz2" | "xz" | "txz" | "lzma" | "zst" | "tzst" | "cab" | "ar" | "cpio" | "iso" | "xar" | "lha" | "lzh" | "jar" | "war" | "ear" | "apk" | "cbz" | "cbr" | "eml" | "msg" | "mbox" | "olb" | "dra" | "gds" | "oas" | "oasis" | "dxf" | "dwg" | "dwf" | "dwfx" | "xps" | "glb" | "gltf" | "obj" | "stl" | "ply" | "fbx" | "dae" | "3ds" | "3mf" | "amf" | "usd" | "usda" | "usdc" | "usdz" | "kmz" | "step" | "stp" | "iges" | "igs" | "ifc" | "3dm" | "brep" | "pcd" | "wrl" | "vrml" | "vtk" | "vtp" | "geojson" | "kml" | "gpx" | "shp" | "excalidraw" | "drawio" | "dio" | "mermaid" | "mmd" | "plantuml" | "puml" | "bpmn" | "xmind" | "epub" | "fb2" | "umd" | "gif" | "jpg" | "bmp" | "tiff" | "tif" | "avif" | "ico" | "heic" | "heif" | "jxl" | "dicom" | "dcm" | "p7m" | "p7s" | "p7c" | "p7b" | "pkcs7" | "cms" | "cmsc" | "tsd" | "tst" | "tsq" | "tsr" | "asics" | "scs" | "asice" | "sce" | "ers" | "asc" | "sig" | "pgp" | "gpg" | "jws" | "md" | "txt" | "lrc" | "json" | "mjs" | "cjs" | "css" | "java" | "py" | "htm" | "jsx" | "ts" | "tsx" | "xml" | "log" | "vue" | "yaml" | "yml" | "ini" | "sh" | "bash" | "sql" | "go" | "rs" | "php" | "c" | "cpp" | "cc" | "h" | "hpp" | "cs" | "diff" | "patch" | "bundle" | "bdl" | "jsonc" | "json5" | "ipynb" | "toml" | "proto" | "hcl" | "tex" | "gv" | "http" | "react" | "swift" | "kt" | "mp4" | "webm" | "m3u8" | "mp3" | "mpeg" | "wav" | "ogg" | "oga" | "opus" | "m4a" | "aac" | "flac" | "weba" | "midi" | "mid" | "psb" | "pdd" | "psdt" | "psd" | "ait" | "ai" | "idml" | "icml" | "idms" | "inx" | "xfl" | "indd" | "indt" | "ps" | "eps" | "ase" | "aco" | "abr" | "csh" | "pat" | "grd" | "asl" | "ttf" | "otf" | "woff" | "woff2" | "sqlite" | "parquet" | "avro" | "webarchive" | "bin" | "hex" | "elf" | "exe" | "dll" | "class" | "macho")[];
|
|
@@ -900,4 +900,5 @@ export declare const DEFAULT_RENDERER_DEFINITIONS: readonly [{
|
|
|
900
900
|
}];
|
|
901
901
|
export declare const DEFAULT_REGISTERED_EXTENSIONS: readonly ("markdown" | "webp" | "jpeg" | "png" | "pdf" | "xyz" | "wasm" | "chm" | "typst" | "xd" | "fla" | "js" | "html" | "svg" | "rb" | "docx" | "docm" | "dotx" | "dotm" | "doc" | "dot" | "ppt" | "pot" | "pptx" | "pptm" | "potx" | "potm" | "ppsx" | "ppsm" | "rtf" | "odt" | "odp" | "xlsx" | "xltx" | "xlsm" | "xlsb" | "xls" | "xlt" | "xla" | "xlam" | "xltm" | "csv" | "tsv" | "ods" | "fods" | "pages" | "numbers" | "key" | "wpd" | "wp" | "wp5" | "wp6" | "dbf" | "ofd" | "hwp" | "hwpx" | "typ" | "zip" | "zipx" | "7z" | "rar" | "tar" | "gz" | "gzip" | "tgz" | "bz2" | "bzip2" | "tbz" | "tbz2" | "xz" | "txz" | "lzma" | "zst" | "tzst" | "cab" | "ar" | "cpio" | "iso" | "xar" | "lha" | "lzh" | "jar" | "war" | "ear" | "apk" | "cbz" | "cbr" | "eml" | "msg" | "mbox" | "olb" | "dra" | "gds" | "oas" | "oasis" | "dxf" | "dwg" | "dwf" | "dwfx" | "xps" | "glb" | "gltf" | "obj" | "stl" | "ply" | "fbx" | "dae" | "3ds" | "3mf" | "amf" | "usd" | "usda" | "usdc" | "usdz" | "kmz" | "step" | "stp" | "iges" | "igs" | "ifc" | "3dm" | "brep" | "pcd" | "wrl" | "vrml" | "vtk" | "vtp" | "geojson" | "kml" | "gpx" | "shp" | "excalidraw" | "drawio" | "dio" | "mermaid" | "mmd" | "plantuml" | "puml" | "bpmn" | "xmind" | "epub" | "fb2" | "umd" | "gif" | "jpg" | "bmp" | "tiff" | "tif" | "avif" | "ico" | "heic" | "heif" | "jxl" | "dicom" | "dcm" | "p7m" | "p7s" | "p7c" | "p7b" | "pkcs7" | "cms" | "cmsc" | "tsd" | "tst" | "tsq" | "tsr" | "asics" | "scs" | "asice" | "sce" | "ers" | "asc" | "sig" | "pgp" | "gpg" | "jws" | "md" | "txt" | "lrc" | "json" | "mjs" | "cjs" | "css" | "java" | "py" | "htm" | "jsx" | "ts" | "tsx" | "xml" | "log" | "vue" | "yaml" | "yml" | "ini" | "sh" | "bash" | "sql" | "go" | "rs" | "php" | "c" | "cpp" | "cc" | "h" | "hpp" | "cs" | "diff" | "patch" | "bundle" | "bdl" | "jsonc" | "json5" | "ipynb" | "toml" | "proto" | "hcl" | "tex" | "gv" | "http" | "react" | "swift" | "kt" | "mp4" | "webm" | "m3u8" | "mp3" | "mpeg" | "wav" | "ogg" | "oga" | "opus" | "m4a" | "aac" | "flac" | "weba" | "midi" | "mid" | "psb" | "pdd" | "psdt" | "psd" | "ait" | "ai" | "idml" | "icml" | "idms" | "inx" | "xfl" | "indd" | "indt" | "ps" | "eps" | "ase" | "aco" | "abr" | "csh" | "pat" | "grd" | "asl" | "ttf" | "otf" | "woff" | "woff2" | "sqlite" | "parquet" | "avro" | "webarchive" | "bin" | "hex" | "elf" | "exe" | "dll" | "class" | "macho")[];
|
|
902
902
|
export declare const DEFAULT_STABLE_SUPPORTED_EXTENSIONS: readonly ("markdown" | "webp" | "jpeg" | "png" | "pdf" | "xyz" | "wasm" | "chm" | "typst" | "js" | "html" | "svg" | "rb" | "docx" | "docm" | "dotx" | "dotm" | "doc" | "dot" | "ppt" | "pot" | "pptx" | "pptm" | "potx" | "potm" | "ppsx" | "ppsm" | "rtf" | "odt" | "odp" | "xlsx" | "xltx" | "xlsm" | "xlsb" | "xls" | "xlt" | "xla" | "xlam" | "xltm" | "csv" | "tsv" | "ods" | "fods" | "pages" | "numbers" | "key" | "wpd" | "wp" | "wp5" | "wp6" | "dbf" | "ofd" | "hwp" | "hwpx" | "typ" | "zip" | "zipx" | "7z" | "rar" | "tar" | "gz" | "gzip" | "tgz" | "bz2" | "bzip2" | "tbz" | "tbz2" | "xz" | "txz" | "lzma" | "zst" | "tzst" | "cab" | "ar" | "cpio" | "iso" | "xar" | "lha" | "lzh" | "jar" | "war" | "ear" | "apk" | "cbz" | "cbr" | "eml" | "msg" | "mbox" | "olb" | "dra" | "gds" | "oas" | "oasis" | "dxf" | "dwg" | "dwf" | "dwfx" | "xps" | "glb" | "gltf" | "obj" | "stl" | "ply" | "fbx" | "dae" | "3ds" | "3mf" | "amf" | "usd" | "usda" | "usdc" | "usdz" | "kmz" | "step" | "stp" | "iges" | "igs" | "ifc" | "3dm" | "brep" | "pcd" | "wrl" | "vrml" | "vtk" | "vtp" | "geojson" | "kml" | "gpx" | "shp" | "excalidraw" | "drawio" | "dio" | "mermaid" | "mmd" | "plantuml" | "puml" | "xmind" | "epub" | "fb2" | "umd" | "gif" | "jpg" | "bmp" | "tiff" | "tif" | "avif" | "ico" | "heic" | "heif" | "jxl" | "md" | "txt" | "lrc" | "json" | "mjs" | "cjs" | "css" | "java" | "py" | "htm" | "jsx" | "ts" | "tsx" | "xml" | "log" | "vue" | "yaml" | "yml" | "ini" | "sh" | "bash" | "sql" | "go" | "rs" | "php" | "c" | "cpp" | "cc" | "h" | "hpp" | "cs" | "diff" | "patch" | "bundle" | "bdl" | "jsonc" | "json5" | "ipynb" | "toml" | "proto" | "hcl" | "tex" | "gv" | "http" | "react" | "swift" | "kt" | "mp4" | "webm" | "m3u8" | "mp3" | "mpeg" | "wav" | "ogg" | "oga" | "opus" | "m4a" | "aac" | "flac" | "weba" | "midi" | "mid" | "psd" | "ai" | "eps" | "ase" | "aco" | "ttf" | "otf" | "woff" | "woff2" | "sqlite" | "parquet" | "avro" | "webarchive")[];
|
|
903
|
+
/** @deprecated Use DEFAULT_REGISTERED_EXTENSIONS when the experimental/stable distinction matters. */
|
|
903
904
|
export declare const DEFAULT_SUPPORTED_EXTENSIONS: readonly ("markdown" | "webp" | "jpeg" | "png" | "pdf" | "xyz" | "wasm" | "chm" | "typst" | "xd" | "fla" | "js" | "html" | "svg" | "rb" | "docx" | "docm" | "dotx" | "dotm" | "doc" | "dot" | "ppt" | "pot" | "pptx" | "pptm" | "potx" | "potm" | "ppsx" | "ppsm" | "rtf" | "odt" | "odp" | "xlsx" | "xltx" | "xlsm" | "xlsb" | "xls" | "xlt" | "xla" | "xlam" | "xltm" | "csv" | "tsv" | "ods" | "fods" | "pages" | "numbers" | "key" | "wpd" | "wp" | "wp5" | "wp6" | "dbf" | "ofd" | "hwp" | "hwpx" | "typ" | "zip" | "zipx" | "7z" | "rar" | "tar" | "gz" | "gzip" | "tgz" | "bz2" | "bzip2" | "tbz" | "tbz2" | "xz" | "txz" | "lzma" | "zst" | "tzst" | "cab" | "ar" | "cpio" | "iso" | "xar" | "lha" | "lzh" | "jar" | "war" | "ear" | "apk" | "cbz" | "cbr" | "eml" | "msg" | "mbox" | "olb" | "dra" | "gds" | "oas" | "oasis" | "dxf" | "dwg" | "dwf" | "dwfx" | "xps" | "glb" | "gltf" | "obj" | "stl" | "ply" | "fbx" | "dae" | "3ds" | "3mf" | "amf" | "usd" | "usda" | "usdc" | "usdz" | "kmz" | "step" | "stp" | "iges" | "igs" | "ifc" | "3dm" | "brep" | "pcd" | "wrl" | "vrml" | "vtk" | "vtp" | "geojson" | "kml" | "gpx" | "shp" | "excalidraw" | "drawio" | "dio" | "mermaid" | "mmd" | "plantuml" | "puml" | "bpmn" | "xmind" | "epub" | "fb2" | "umd" | "gif" | "jpg" | "bmp" | "tiff" | "tif" | "avif" | "ico" | "heic" | "heif" | "jxl" | "dicom" | "dcm" | "p7m" | "p7s" | "p7c" | "p7b" | "pkcs7" | "cms" | "cmsc" | "tsd" | "tst" | "tsq" | "tsr" | "asics" | "scs" | "asice" | "sce" | "ers" | "asc" | "sig" | "pgp" | "gpg" | "jws" | "md" | "txt" | "lrc" | "json" | "mjs" | "cjs" | "css" | "java" | "py" | "htm" | "jsx" | "ts" | "tsx" | "xml" | "log" | "vue" | "yaml" | "yml" | "ini" | "sh" | "bash" | "sql" | "go" | "rs" | "php" | "c" | "cpp" | "cc" | "h" | "hpp" | "cs" | "diff" | "patch" | "bundle" | "bdl" | "jsonc" | "json5" | "ipynb" | "toml" | "proto" | "hcl" | "tex" | "gv" | "http" | "react" | "swift" | "kt" | "mp4" | "webm" | "m3u8" | "mp3" | "mpeg" | "wav" | "ogg" | "oga" | "opus" | "m4a" | "aac" | "flac" | "weba" | "midi" | "mid" | "psb" | "pdd" | "psdt" | "psd" | "ait" | "ai" | "idml" | "icml" | "idms" | "inx" | "xfl" | "indd" | "indt" | "ps" | "eps" | "ase" | "aco" | "abr" | "csh" | "pat" | "grd" | "asl" | "ttf" | "otf" | "woff" | "woff2" | "sqlite" | "parquet" | "avro" | "webarchive" | "bin" | "hex" | "elf" | "exe" | "dll" | "class" | "macho")[];
|
|
@@ -1656,4 +1656,5 @@ export const DEFAULT_REGISTERED_EXTENSIONS = Object.freeze(Array.from(new Set(DE
|
|
|
1656
1656
|
export const DEFAULT_STABLE_SUPPORTED_EXTENSIONS = Object.freeze(Array.from(new Set(DEFAULT_RENDERER_DEFINITIONS
|
|
1657
1657
|
.filter(definition => definition.status === 'stable')
|
|
1658
1658
|
.flatMap(definition => definition.extensions))).sort());
|
|
1659
|
+
/** @deprecated Use DEFAULT_REGISTERED_EXTENSIONS when the experimental/stable distinction matters. */
|
|
1659
1660
|
export const DEFAULT_SUPPORTED_EXTENSIONS = DEFAULT_REGISTERED_EXTENSIONS;
|
package/dist/registry/formats.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { DEFAULT_REGISTERED_EXTENSIONS, DEFAULT_RENDERER_DEFINITIONS, DEFAULT_STABLE_SUPPORTED_EXTENSIONS, DEFAULT_SUPPORTED_EXTENSIONS, } from
|
|
2
|
-
import { DEFAULT_RENDERER_DEFINITIONS } from
|
|
1
|
+
export { DEFAULT_REGISTERED_EXTENSIONS, DEFAULT_RENDERER_DEFINITIONS, DEFAULT_STABLE_SUPPORTED_EXTENSIONS, DEFAULT_SUPPORTED_EXTENSIONS, } from './formats.generated.js';
|
|
2
|
+
import { DEFAULT_RENDERER_DEFINITIONS } from './formats.generated.js';
|
|
3
3
|
const extensionsFor = (rendererId) => {
|
|
4
4
|
var _a, _b;
|
|
5
5
|
return Object.freeze([...((_b = (_a = DEFAULT_RENDERER_DEFINITIONS.find(definition => definition.id === rendererId)) === null || _a === void 0 ? void 0 : _a.extensions) !== null && _b !== void 0 ? _b : [])]);
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import type { FileViewerRendererHandlerRegistration, FileViewerRendererPluginInput, FileViewerRendererPlugin, FileViewerRendererPresetInput, FileViewerRendererPresetName, RendererDefinition, RendererRegistry } from
|
|
1
|
+
import type { FileViewerRendererHandlerRegistration, FileViewerRendererPluginInput, FileViewerRendererPlugin, FileViewerRendererPresetInput, FileViewerRendererPresetName, RendererDefinition, RendererRegistry } from '../contracts/types.js';
|
|
2
2
|
export interface RegisterFileViewerAutoRendererPresetOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Stable key used to replace an existing auto preset registration.
|
|
5
|
+
*/
|
|
3
6
|
id?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Package name is useful for diagnostics and gives generated integrations a
|
|
9
|
+
* deterministic id even when the preset input is an array.
|
|
10
|
+
*/
|
|
4
11
|
packageName?: string;
|
|
5
12
|
}
|
|
6
13
|
export interface FileViewerAutoRendererPresetEntry<Handler = unknown> {
|
|
@@ -32,5 +39,12 @@ export declare const listFileViewerAutoRendererPresetEntries: <Handler = unknown
|
|
|
32
39
|
export declare const findFileViewerAutoRendererPreset: <Handler = unknown>(id: FileViewerRendererPresetName | string) => FileViewerRendererPluginInput<Handler> | undefined;
|
|
33
40
|
export declare const getFileViewerAutoRendererPresetVersion: () => number;
|
|
34
41
|
export declare const hasFileViewerRendererPresetName: (input?: FileViewerRendererPresetInput | null) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Normalizes `options.preset` / `options.presets` into renderer plugin inputs.
|
|
44
|
+
*
|
|
45
|
+
* Passing a preset object is the most portable integration style because it
|
|
46
|
+
* works in any bundler. String selectors intentionally only resolve presets
|
|
47
|
+
* that are already registered by a side-effect import or by build tooling.
|
|
48
|
+
*/
|
|
35
49
|
export declare const resolveFileViewerRendererPresetInputs: <Handler = unknown>(input?: FileViewerRendererPresetInput<Handler> | null) => FileViewerRendererPluginInput<Handler>[];
|
|
36
50
|
export declare const installFileViewerRendererPlugins: <Handler = unknown>({ registry, plugins, registerHandler, }: InstallFileViewerRendererPluginsOptions<Handler>) => Promise<RendererRegistry>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DEFAULT_RENDERER_DEFINITIONS } from
|
|
2
|
-
import { getExtension, normalizeFileExtension, normalizeFilename } from
|
|
1
|
+
import { DEFAULT_RENDERER_DEFINITIONS } from './formats.js';
|
|
2
|
+
import { getExtension, normalizeFileExtension, normalizeFilename } from '../source/index.js';
|
|
3
3
|
const autoRendererBucketKey = '__flyfish_file_viewer_auto_renderer_presets__';
|
|
4
4
|
const getAutoRendererBucket = () => {
|
|
5
5
|
const host = globalThis;
|
|
@@ -217,6 +217,7 @@ const createRendererDefinitionInstallPlan = (registry, definitions) => {
|
|
|
217
217
|
...regularDefinitions,
|
|
218
218
|
...enhancerDefinitions,
|
|
219
219
|
];
|
|
220
|
+
// Validate the complete ownership transition before mutating the caller's registry.
|
|
220
221
|
const validationRegistry = createRendererRegistry(registry.list());
|
|
221
222
|
plannedDefinitions.forEach(definition => validationRegistry.register(definition));
|
|
222
223
|
return { definitions: plannedDefinitions };
|
|
@@ -327,6 +328,13 @@ export const hasFileViewerRendererPresetName = (input) => {
|
|
|
327
328
|
}
|
|
328
329
|
return false;
|
|
329
330
|
};
|
|
331
|
+
/**
|
|
332
|
+
* Normalizes `options.preset` / `options.presets` into renderer plugin inputs.
|
|
333
|
+
*
|
|
334
|
+
* Passing a preset object is the most portable integration style because it
|
|
335
|
+
* works in any bundler. String selectors intentionally only resolve presets
|
|
336
|
+
* that are already registered by a side-effect import or by build tooling.
|
|
337
|
+
*/
|
|
330
338
|
export const resolveFileViewerRendererPresetInputs = (input) => {
|
|
331
339
|
if (!input) {
|
|
332
340
|
return [];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { FileRenderContext, FileViewerRenderedInstance } from
|
|
1
|
+
import type { FileRenderContext, FileViewerRenderedInstance } from '../contracts/types.js';
|
|
2
2
|
export default function renderImage(buffer: ArrayBuffer, target: HTMLDivElement, type?: string, context?: FileRenderContext): Promise<FileViewerRenderedInstance>;
|