@file-viewer/core 3.3.0 → 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 +14 -14
- package/README.md +14 -14
- package/README.zh-CN.md +4 -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 +109 -26
- package/dist/browser/source-feedback.d.ts +4 -0
- package/dist/browser/source-feedback.js +40 -0
- package/dist/browser/toolbar-focus.d.ts +1 -0
- package/dist/browser/toolbar-focus.js +3 -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 +470 -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 +2 -0
- package/dist/features/document/imageHandTool.js +5 -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 +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 -77
- package/dist/index.js +39 -39
- package/dist/lifecycle/facade.d.ts +4 -4
- package/dist/lifecycle/facade.js +2 -2
- package/dist/lifecycle/operations.d.ts +5 -4
- package/dist/lifecycle/operations.js +10 -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 +8 -1
- package/dist/platform/assets.js +14 -0
- package/dist/platform/copiedAssets.d.ts +1 -0
- package/dist/platform/copiedAssets.js +2 -1
- package/dist/presentation/colorScheme.d.ts +2 -1
- package/dist/presentation/colorScheme.js +2 -1
- 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 +7 -5
- 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 +4 -4
- package/dist/source/loading.js +7 -4
- 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 +28 -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 +5 -3
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encoding used by `auto` when the bytes carry no BOM, do not look like
|
|
3
|
+
* UTF-16, and are not valid UTF-8. GB18030 keeps the historical behavior.
|
|
4
|
+
*/
|
|
1
5
|
export const DEFAULT_FILE_VIEWER_TEXT_FALLBACK_ENCODING = 'gb18030';
|
|
2
6
|
const SINGLE_BYTE_ENCODING_ALIASES = new Map([
|
|
3
7
|
['iso-8859-1', 'iso-8859-1'],
|
|
@@ -72,6 +76,8 @@ const normalizeFallbackEncoding = (fallbackEncoding) => {
|
|
|
72
76
|
const isContinuationByte = (value) => {
|
|
73
77
|
return value !== undefined && value >= 0x80 && value <= 0xbf;
|
|
74
78
|
};
|
|
79
|
+
// Validate bytes directly because older WebViews can accept the fatal option
|
|
80
|
+
// while still replacing malformed input. That would hide the GB18030 fallback.
|
|
75
81
|
export const isValidFileViewerUtf8 = (bytes) => {
|
|
76
82
|
for (let index = 0; index < bytes.length;) {
|
|
77
83
|
const first = bytes[index];
|
|
@@ -152,6 +158,15 @@ const inferBomlessUtf16 = (bytes) => {
|
|
|
152
158
|
}
|
|
153
159
|
return null;
|
|
154
160
|
};
|
|
161
|
+
/**
|
|
162
|
+
* Picks the decoder for a text buffer.
|
|
163
|
+
*
|
|
164
|
+
* `encoding` other than `auto` is used as-is. In `auto` mode the order is:
|
|
165
|
+
* BOM, UTF-16 byte structure, strict UTF-8, then `fallbackEncoding`. The
|
|
166
|
+
* fallback defaults to GB18030; pass `windows-1252`, `windows-1251`, or
|
|
167
|
+
* another supported label for Latin, Cyrillic, or Central European legacy
|
|
168
|
+
* files, which are otherwise misread as CJK text.
|
|
169
|
+
*/
|
|
155
170
|
export const resolveFileViewerTextEncoding = (bytes, encoding = 'auto', fallbackEncoding = DEFAULT_FILE_VIEWER_TEXT_FALLBACK_ENCODING) => {
|
|
156
171
|
const normalized = normalizeEncoding(encoding);
|
|
157
172
|
if (normalized !== 'auto') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerEventHandler, FileViewerInstance, FileViewerOptions, FileViewerRenderPurpose, RendererRegistry } from
|
|
1
|
+
import type { FileViewerEventHandler, FileViewerInstance, FileViewerOptions, FileViewerRenderPurpose, RendererRegistry } from '../contracts/types.js';
|
|
2
2
|
export interface CreateViewerOptions {
|
|
3
3
|
registry?: RendererRegistry;
|
|
4
4
|
options?: FileViewerOptions;
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
1
|
+
// Imperative viewer composition root.
|
|
2
|
+
//
|
|
3
|
+
// `createViewer` wires source normalization, lifecycle hooks, renderer
|
|
4
|
+
// sessions, document features, watermarking, and public operations into a
|
|
5
|
+
// framework-neutral controller. Framework packages should wrap this API instead
|
|
6
|
+
// of reimplementing the orchestration.
|
|
7
|
+
import { createEmptyFileViewerSearchState, } from '../features/document/model.js';
|
|
8
|
+
import { createFileViewerDocumentFeatureControllerActionHandlers, } from '../features/document/events.js';
|
|
9
|
+
import { createFileViewerZoomController } from '../features/document/zoom.js';
|
|
10
|
+
import { createFileViewerViewStateController } from '../features/document/viewState.js';
|
|
11
|
+
import { createFileViewerFitController, hasFileViewerExplicitInitialViewState, } from '../features/document/fit.js';
|
|
12
|
+
import { DEFAULT_FILE_VIEWER_DOWNLOAD_FILENAME, DEFAULT_FILE_VIEWER_EXPORT_FILENAME, DEFAULT_FILE_VIEWER_PREVIEW_TITLE, createFileViewerOriginalSourceStateFromNormalizedSource, executeFileViewerDownloadOperation, executeFileViewerExportHtmlOperation, executeFileViewerPrintOperation, resolveFileViewerDisplayFilename, resolveFileViewerOperationFilename, } from './operations.js';
|
|
13
|
+
import { openFileViewerPrintMaskDesignerAsync } from '../features/printMaskLoader.js';
|
|
14
|
+
import { applyFileViewerZoomAvailability, createUnsupportedAvailability, getRendererAvailability, } from '../registry/capabilities.js';
|
|
15
|
+
import { buildFileViewerLifecycleContextFromNormalizedSource, buildFileViewerOperationContext, runFileViewerBeforeOperation, runFileViewerLifecycleHook, } from '../lifecycle/operations.js';
|
|
16
|
+
import { collectFileViewerRendererPlugins, createRendererRegistry, getFileViewerAutoRendererPresetVersion, hasFileViewerRendererPresetName, installFileViewerRendererPlugins, listFileViewerAutoRendererPresets, resolveFileViewerRendererPresetInputs, resolveFileViewerRendererDefinition, } from '../registry/registry.js';
|
|
17
|
+
import { createFileRenderHandlerLoader, applyFileViewerRenderSurfaceState, createFileViewerRenderSurfaceState, createFileViewerRenderSurface, removeFileViewerRenderTarget, syncFileViewerRenderSurfaceBackground, } from '../rendering/handler.js';
|
|
18
|
+
import { createFileViewerCoreRendererRegistry } from '../renderers/index.js';
|
|
19
|
+
import { createFileViewerRequestScope } from '../source/loading.js';
|
|
20
|
+
import { normalizeSource } from '../source/index.js';
|
|
21
|
+
import { buildFileViewerWatermarkInlineStyle } from '../features/watermark.js';
|
|
22
|
+
import { createFileViewerSnapshotDownload } from '../output/snapshotDownload.js';
|
|
23
|
+
import { createFileViewerErrorState, createFileViewerUnsupportedState } from './state.js';
|
|
18
24
|
const emitLifecycle = async (options, onEvent, phase, source, version, startedAt, reason) => {
|
|
19
25
|
const now = Date.now();
|
|
20
26
|
const context = buildFileViewerLifecycleContextFromNormalizedSource({
|
|
@@ -384,6 +390,9 @@ export const createViewer = (container, createOptions = {}) => {
|
|
|
384
390
|
registry,
|
|
385
391
|
options: {
|
|
386
392
|
...inheritedOptions,
|
|
393
|
+
// The parent already resolved its renderer assembly into `registry`.
|
|
394
|
+
// Reuse that exact registry without reinstalling presets or mutating a
|
|
395
|
+
// shared registry while an attachment is open.
|
|
387
396
|
autoRenderers: false,
|
|
388
397
|
rendererMode: 'extend',
|
|
389
398
|
renderers: undefined,
|
|
@@ -677,6 +686,8 @@ export const createViewer = (container, createOptions = {}) => {
|
|
|
677
686
|
zoomController.refreshProvider();
|
|
678
687
|
viewStateController.refreshProvider();
|
|
679
688
|
const finishStaleLoad = async () => {
|
|
689
|
+
// unload/replace may already have disposed this session. Clear only
|
|
690
|
+
// the session still owned by this load, preserving a replacement.
|
|
680
691
|
if (renderSurfaceState.session === session && currentRenderTarget === targetHost) {
|
|
681
692
|
await destroyCurrent('replace');
|
|
682
693
|
}
|
package/dist/viewer/loading.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type FileViewerI18nInput } from
|
|
2
|
-
import type { FileViewerStateTheme } from
|
|
1
|
+
import { type FileViewerI18nInput } from '../i18n/messages.js';
|
|
2
|
+
import type { FileViewerStateTheme } from '../contracts/types.js';
|
|
3
3
|
export type FileViewerLoadingTheme = FileViewerStateTheme;
|
|
4
4
|
export interface FileViewerLoadingState {
|
|
5
5
|
loading: boolean;
|
|
@@ -51,4 +51,8 @@ export declare const syncFileViewerLoadingControllerState: <Target extends Mutab
|
|
|
51
51
|
export declare const runFileViewerLoadingControllerAction: <Target extends MutableFileViewerLoadingState>(target: Target, action: () => FileViewerLoadingState) => Target;
|
|
52
52
|
export declare const runFileViewerLoadingExtensionSync: <Target extends MutableFileViewerLoadingState>({ target, controller, extension, }: RunFileViewerLoadingExtensionSyncInput<Target>) => Target;
|
|
53
53
|
export declare const createFileViewerLoadingControllerActionHandlers: <Target extends MutableFileViewerLoadingState>(target: Target, controller: FileViewerLoadingController) => FileViewerLoadingControllerActionHandlers;
|
|
54
|
+
/**
|
|
55
|
+
* 统一管理加载、错误、文案和主题色。
|
|
56
|
+
* wrapper 只负责把这个加载状态映射到各自框架的响应式系统。
|
|
57
|
+
*/
|
|
54
58
|
export declare const createFileViewerLoadingController: (extend?: string, initialI18n?: FileViewerI18nInput) => FileViewerLoadingController;
|
package/dist/viewer/loading.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { translateFileViewerMessage, } from
|
|
1
|
+
import { translateFileViewerMessage, } from '../i18n/messages.js';
|
|
2
2
|
export const FALLBACK_FILE_VIEWER_LOADING_THEME = {
|
|
3
3
|
accent: '#5f6f82',
|
|
4
4
|
soft: 'rgba(95, 111, 130, 0.12)',
|
|
@@ -418,6 +418,10 @@ const FILE_VIEWER_LOADING_COPY_KEYS = {
|
|
|
418
418
|
flac: { label: 'loading.audio.label', hint: 'loading.audio.hint' },
|
|
419
419
|
weba: { label: 'loading.audio.label', hint: 'loading.audio.hint' },
|
|
420
420
|
};
|
|
421
|
+
/**
|
|
422
|
+
* 根据扩展名返回统一的加载主题。
|
|
423
|
+
* 这样不同预览器可以复用同一套视觉语义,避免颜色、图标和文案各写一份。
|
|
424
|
+
*/
|
|
421
425
|
const localizeFileViewerLoadingTheme = (theme, extend = '', i18n) => {
|
|
422
426
|
const normalized = extend.trim().toLowerCase();
|
|
423
427
|
const keys = FILE_VIEWER_LOADING_COPY_KEYS[normalized] || {
|
|
@@ -507,6 +511,10 @@ export const createFileViewerLoadingControllerActionHandlers = (target, controll
|
|
|
507
511
|
},
|
|
508
512
|
};
|
|
509
513
|
};
|
|
514
|
+
/**
|
|
515
|
+
* 统一管理加载、错误、文案和主题色。
|
|
516
|
+
* wrapper 只负责把这个加载状态映射到各自框架的响应式系统。
|
|
517
|
+
*/
|
|
510
518
|
export const createFileViewerLoadingController = (extend = '', initialI18n) => {
|
|
511
519
|
let currentExtend = extend;
|
|
512
520
|
let currentI18n = initialI18n;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { FileViewerErrorMessageFormatter } from
|
|
2
|
-
import { type FileViewerI18nInput } from
|
|
3
|
-
import type { FileRenderExportAdapter, FileViewerDownloadOptions, FileViewerExportHtmlOptions, FileViewerOperationType, FileViewerPrintOptions, NormalizedFileViewerSource } from
|
|
1
|
+
import type { FileViewerErrorMessageFormatter } from './state.js';
|
|
2
|
+
import { type FileViewerI18nInput } from '../i18n/messages.js';
|
|
3
|
+
import type { FileRenderExportAdapter, FileViewerDownloadOptions, FileViewerExportHtmlOptions, FileViewerOperationType, FileViewerPrintOptions, NormalizedFileViewerSource } from '../contracts/types.js';
|
|
4
4
|
export interface FileViewerOriginalSourceState {
|
|
5
5
|
buffer?: ArrayBuffer | null;
|
|
6
6
|
file?: File | Blob | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { triggerFileViewerBlobDownload, triggerFileViewerUrlDownload, waitForFileViewerPrintWindowReady, } from
|
|
2
|
-
import { DEFAULT_FILE_VIEWER_SOURCE_FILENAME } from
|
|
3
|
-
import { translateFileViewerMessage, } from
|
|
1
|
+
import { triggerFileViewerBlobDownload, triggerFileViewerUrlDownload, waitForFileViewerPrintWindowReady, } from '../output/export.js';
|
|
2
|
+
import { DEFAULT_FILE_VIEWER_SOURCE_FILENAME } from '../source/index.js';
|
|
3
|
+
import { translateFileViewerMessage, } from '../i18n/messages.js';
|
|
4
4
|
export const DEFAULT_FILE_VIEWER_PREVIEW_TITLE = 'file-viewer-preview';
|
|
5
5
|
export const DEFAULT_FILE_VIEWER_EXPORT_FILENAME = 'preview';
|
|
6
6
|
export const DEFAULT_FILE_VIEWER_DOWNLOAD_FILENAME = DEFAULT_FILE_VIEWER_SOURCE_FILENAME;
|
|
@@ -65,7 +65,7 @@ const buildRenderedHtmlDocumentFromOperation = async (mode, { source, title, fil
|
|
|
65
65
|
if (!source) {
|
|
66
66
|
throw new Error(translateFileViewerMessage(i18n, 'error.noExportContent'));
|
|
67
67
|
}
|
|
68
|
-
const { buildFileViewerRenderedHtmlDocument } = await import(
|
|
68
|
+
const { buildFileViewerRenderedHtmlDocument } = await import('../export.js');
|
|
69
69
|
return buildFileViewerRenderedHtmlDocument({
|
|
70
70
|
source,
|
|
71
71
|
mode,
|
|
@@ -82,7 +82,7 @@ const buildRenderedDomDocumentFromOperation = async ({ source, title, filename,
|
|
|
82
82
|
if (!source) {
|
|
83
83
|
throw new Error(translateFileViewerMessage(i18n, 'error.noExportContent'));
|
|
84
84
|
}
|
|
85
|
-
const { buildFileViewerRenderedDomDocument } = await import(
|
|
85
|
+
const { buildFileViewerRenderedDomDocument } = await import('../export.js');
|
|
86
86
|
return buildFileViewerRenderedDomDocument({
|
|
87
87
|
source,
|
|
88
88
|
mode: 'print',
|
|
@@ -157,6 +157,11 @@ export const executeFileViewerDownloadOperation = async ({ source, filename, bef
|
|
|
157
157
|
source,
|
|
158
158
|
fallback: DEFAULT_FILE_VIEWER_DOWNLOAD_FILENAME,
|
|
159
159
|
});
|
|
160
|
+
// PDF.js transfers ArrayBuffer-backed data to its worker. After a successful
|
|
161
|
+
// render the original buffer can therefore be detached (byteLength === 0),
|
|
162
|
+
// while the File or URL retained by the viewer is still the complete source.
|
|
163
|
+
// Preserve the existing buffer-first contract for non-empty buffers, but do
|
|
164
|
+
// not turn a detached buffer into a zero-byte download.
|
|
160
165
|
if (source.buffer &&
|
|
161
166
|
(source.buffer.byteLength > 0 || (!source.file && !source.url))) {
|
|
162
167
|
triggerFileViewerBlobDownload(new Blob([source.buffer], { type: source.mimeType || ((_a = source.file) === null || _a === void 0 ? void 0 : _a.type) || 'application/octet-stream' }), resolvedFilename);
|
|
@@ -170,6 +175,8 @@ export const executeFileViewerDownloadOperation = async ({ source, filename, bef
|
|
|
170
175
|
triggerFileViewerUrlDownload(source.url, resolvedFilename);
|
|
171
176
|
return true;
|
|
172
177
|
}
|
|
178
|
+
// Empty local files are valid sources. These final fallbacks preserve their
|
|
179
|
+
// intentional zero-byte downloads when no complete File or URL is available.
|
|
173
180
|
if (source.file) {
|
|
174
181
|
triggerFileViewerBlobDownload(source.file, resolvedFilename);
|
|
175
182
|
return true;
|
|
@@ -203,6 +210,7 @@ export const executeFileViewerPrintOperation = async ({ autoPrint = true, before
|
|
|
203
210
|
if (beforeResult === false) {
|
|
204
211
|
return false;
|
|
205
212
|
}
|
|
213
|
+
// Preserve the browser's transient user activation while the snapshot is built.
|
|
206
214
|
const ownsPrintWindow = !printWindow;
|
|
207
215
|
const targetWindow = printWindow ||
|
|
208
216
|
(openWindow === null || openWindow === void 0 ? void 0 : openWindow()) ||
|
|
@@ -340,7 +348,7 @@ export const createFileViewerOperationActionHandlers = ({ getBuffer, getFile, ge
|
|
|
340
348
|
if (!source) {
|
|
341
349
|
throw new Error(translateFileViewerMessage(resolveI18n(), 'error.noExportContent'));
|
|
342
350
|
}
|
|
343
|
-
const { openFileViewerPrintMaskDesignerAsync } = await import(
|
|
351
|
+
const { openFileViewerPrintMaskDesignerAsync } = await import('../features/printMaskLoader.js');
|
|
344
352
|
const adapter = (_a = getAdapter === null || getAdapter === void 0 ? void 0 : getAdapter()) !== null && _a !== void 0 ? _a : null;
|
|
345
353
|
const result = await openFileViewerPrintMaskDesignerAsync({
|
|
346
354
|
root: source,
|
package/dist/viewer/state.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { type FileViewerI18nInput } from
|
|
2
|
-
import type { FileViewerRendererCategory, FileViewerStateDescriptor, FileViewerStateTheme } from
|
|
1
|
+
import { type FileViewerI18nInput } from '../i18n/messages.js';
|
|
2
|
+
import type { FileViewerRendererCategory, FileViewerStateDescriptor, FileViewerStateTheme } from '../contracts/types.js';
|
|
3
3
|
export type FileViewerErrorMessageFormatter = (prefix: string, error: unknown, i18n?: FileViewerI18nInput) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Renderers can attach a localized, user-safe explanation without replacing
|
|
6
|
+
* the original error object that hosts use for diagnostics and recovery.
|
|
7
|
+
*/
|
|
4
8
|
export declare const FILE_VIEWER_ERROR_MESSAGE: "fileViewerErrorMessage";
|
|
5
9
|
export interface FileViewerErrorMessageCarrier {
|
|
6
10
|
[FILE_VIEWER_ERROR_MESSAGE]?: string;
|
package/dist/viewer/state.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { normalizeFileExtension } from
|
|
2
|
-
import { DEFAULT_RENDERER_DEFINITIONS } from
|
|
3
|
-
import { resolveFileViewerLocale, translateFileViewerMessage, } from
|
|
1
|
+
import { normalizeFileExtension } from '../source/index.js';
|
|
2
|
+
import { DEFAULT_RENDERER_DEFINITIONS } from '../registry/formats.js';
|
|
3
|
+
import { resolveFileViewerLocale, translateFileViewerMessage, } from '../i18n/messages.js';
|
|
4
|
+
/**
|
|
5
|
+
* Renderers can attach a localized, user-safe explanation without replacing
|
|
6
|
+
* the original error object that hosts use for diagnostics and recovery.
|
|
7
|
+
*/
|
|
4
8
|
export const FILE_VIEWER_ERROR_MESSAGE = 'fileViewerErrorMessage';
|
|
5
9
|
export const attachFileViewerErrorMessage = (error, message) => {
|
|
6
10
|
const normalizedMessage = message.trim();
|
|
@@ -16,6 +20,7 @@ export const attachFileViewerErrorMessage = (error, message) => {
|
|
|
16
20
|
return error;
|
|
17
21
|
}
|
|
18
22
|
catch {
|
|
23
|
+
// Frozen cross-realm errors retain their original value as the cause below.
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
const presented = new Error(normalizedMessage);
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/core",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "Framework-neutral
|
|
6
|
+
"description": "Framework-neutral TypeScript APIs for browser-side file preview, renderer presets, search, zoom, page navigation, print and export.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"file-viewer",
|
|
9
9
|
"document-preview",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"type": "individual",
|
|
37
37
|
"url": "https://dev.flyfish.group/donate?source=npm"
|
|
38
38
|
},
|
|
39
|
-
"homepage": "https://
|
|
39
|
+
"homepage": "https://github.com/flyfish-dev/file-viewer#readme",
|
|
40
40
|
"main": "./dist/index.js",
|
|
41
41
|
"module": "./dist/index.js",
|
|
42
42
|
"types": "./dist/index.d.ts",
|
|
@@ -84,6 +84,8 @@
|
|
|
84
84
|
"dist/browser.js",
|
|
85
85
|
"dist/browser/controller.d.ts",
|
|
86
86
|
"dist/browser/controller.js",
|
|
87
|
+
"dist/browser/source-feedback.d.ts",
|
|
88
|
+
"dist/browser/source-feedback.js",
|
|
87
89
|
"dist/browser/toolbar-focus.d.ts",
|
|
88
90
|
"dist/browser/toolbar-focus.js",
|
|
89
91
|
"dist/config/options.d.ts",
|