@file-viewer/core 2.2.2 → 2.2.4
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 +2 -2
- package/README.md +2 -2
- package/dist/browser/controller.d.ts +137 -0
- package/dist/browser/controller.js +967 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +1 -0
- package/dist/contracts/types.d.ts +5 -4
- package/dist/features/printMaskDesigner.js +9 -4
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js +2 -2
- package/dist/i18n/messages.d.ts +4 -2
- package/dist/i18n/messages.ja.d.ts +7 -0
- package/dist/i18n/messages.ja.js +429 -0
- package/dist/i18n/messages.js +41 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/lifecycle/operations.d.ts +6 -4
- package/dist/lifecycle/operations.js +12 -5
- package/dist/platform/assets.d.ts +8 -5
- package/dist/platform/assets.js +67 -13
- package/dist/rendering/handler.js +12 -5
- package/dist/viewer/state.js +19 -7
- package/package.json +4 -4
package/README.en.md
CHANGED
|
@@ -4,7 +4,7 @@ Framework-neutral TypeScript foundation for Flyfish File Viewer.
|
|
|
4
4
|
|
|
5
5
|
This package is the migration base for the next architecture: one pure TypeScript core package with internal `headless`, `browser`, and `renderers` layers, plus multiple native standard component packages for Vue, React, pure JavaScript, jQuery, and Svelte. Core owns the shared format matrix, source detection, renderer protocol, capability calculation, lifecycle context, operation guards, operation/event/search/location/zoom/print/export contracts, heavy renderer asset manifests, option normalization, pure state models, and framework-neutral browser rendering engine.
|
|
6
6
|
|
|
7
|
-
Browser execution belongs inside core only when it remains framework-neutral TypeScript. DOM mounting, `HTMLElement` traversal, search highlights, zoom provider discovery, print windows, download triggers, Canvas, Worker, and WASM renderers must not depend on Vue, React, Svelte, or any component package. Framework component packages keep their own
|
|
7
|
+
Browser execution belongs inside core only when it remains framework-neutral TypeScript. DOM mounting, the standard browser shell and toolbar, `HTMLElement` traversal, search highlights, zoom provider discovery, print windows, download triggers, Canvas, Worker, and WASM renderers must not depend on Vue, React, Svelte, or any component package. Framework component packages keep their own component lifecycle, public type surface, compatibility defaults, and ecosystem interaction layer while depending on `@file-viewer/core` as the only shared base.
|
|
8
8
|
|
|
9
9
|
`@file-viewer/core` is the only shared foundation package. It owns the headless contracts plus browser/renderers layers for the direct `createViewer(container, options)` engine, renderer registry, DOM provider registry, print layout helpers, browser asset resolution, and framework-neutral DOM/Canvas/Worker/WASM rendering contracts. Core source is public; the private Gitea aggregate remains available for the complete workspace, unified release automation, sponsorship, and priority support.
|
|
10
10
|
|
|
@@ -31,7 +31,7 @@ const pdfAssets = resolveFileViewerRendererAssets('pdf', {
|
|
|
31
31
|
})
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Use `@file-viewer/core/browser` when a native component package or pure browser integration needs the direct DOM engine, renderer registry, search/zoom providers, print/export adapters, and framework-neutral Canvas/Worker/WASM renderers.
|
|
34
|
+
Use `@file-viewer/core/browser` when a native component package or pure browser integration needs the shared browser shell and toolbar, direct DOM engine, renderer registry, search/zoom providers, print/export adapters, and framework-neutral Canvas/Worker/WASM renderers.
|
|
35
35
|
|
|
36
36
|
```ts
|
|
37
37
|
import {
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Framework-neutral TypeScript foundation for Flyfish File Viewer.
|
|
|
4
4
|
|
|
5
5
|
This package is the migration base for the next architecture: one pure TypeScript core package with internal `headless`, `browser`, and `renderers` layers, plus multiple native standard component packages for Vue, React, pure JavaScript, jQuery and Svelte. Core owns the shared format matrix, source detection, renderer protocol, capability calculation, lifecycle context, operation/event/search/location/zoom/print/export contracts, heavy renderer asset manifests, option normalization, pure state models, and framework-neutral browser rendering engine.
|
|
6
6
|
|
|
7
|
-
Browser execution belongs inside core only when it remains framework-neutral TypeScript. DOM mounting, `HTMLElement` traversal, search highlights, zoom provider discovery, print windows, download triggers, Canvas, Worker and WASM renderers must not depend on Vue, React, Svelte or any component package. Framework component packages keep their own
|
|
7
|
+
Browser execution belongs inside core only when it remains framework-neutral TypeScript. DOM mounting, the standard browser shell and toolbar, `HTMLElement` traversal, search highlights, zoom provider discovery, print windows, download triggers, Canvas, Worker and WASM renderers must not depend on Vue, React, Svelte or any component package. Framework component packages keep their own component lifecycle, public type surface, compatibility defaults, and ecosystem interaction layer while depending on `@file-viewer/core` as the only shared base.
|
|
8
8
|
|
|
9
9
|
`@file-viewer/core` is the only shared foundation package. It owns the headless contracts plus browser/renderers layers for the direct `createViewer(container, options)` engine, renderer registry, DOM provider registry, print layout helpers, browser asset resolution, and framework-neutral DOM/Canvas/Worker/WASM rendering contracts. Core source is public; the private Gitea aggregate remains available for the complete workspace, unified release automation, sponsorship, and priority support.
|
|
10
10
|
|
|
@@ -31,7 +31,7 @@ const pdfAssets = resolveFileViewerRendererAssets('pdf', {
|
|
|
31
31
|
})
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Use `@file-viewer/core/browser` when a native component package or a pure browser integration needs the direct DOM engine, renderer registry, search/zoom providers, print/export adapters and framework-neutral Canvas/Worker/WASM renderers.
|
|
34
|
+
Use `@file-viewer/core/browser` when a native component package or a pure browser integration needs the shared browser shell and toolbar, direct DOM engine, renderer registry, search/zoom providers, print/export adapters and framework-neutral Canvas/Worker/WASM renderers.
|
|
35
35
|
|
|
36
36
|
```ts
|
|
37
37
|
import {
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type FileViewerAiOptions, type FileViewerApplyViewStateOptions, type FileViewerArchiveOptions, type FileViewerCadOptions, type FileViewerDocxOptions, type FileViewerDocumentAnchor, type FileViewerDocumentChunk, type FileViewerEvent, type FileViewerEventHandler, type FileViewerEventType, type FileViewerFileRef, type FileViewerFitMode, type FileViewerFitOptions, type FileViewerFitResult, type FileViewerInstance, type FileViewerLifecycleContext, type FileViewerOperationAvailability, type FileViewerOptions, type FileViewerPdfOptions, type FileViewerPresentationOptions, type FileViewerSpreadsheetOptions, type FileViewerPublicApi, type FileViewerSearchOptions, type FileViewerSearchState, type FileViewerThemeMode, type FileViewerToolbarOptions, type FileViewerToolbarPosition, type FileViewerTypstOptions, type FileViewerUiDensity, type FileViewerUiOptions, type FileViewerViewState, type FileViewerWatermarkOptions, type FileViewerPrintOptions, type FileViewerZoomState, type RendererRegistry } from '../index';
|
|
2
|
+
export type FileRef = FileViewerFileRef;
|
|
3
|
+
export type ViewerWatermarkOptions = FileViewerWatermarkOptions;
|
|
4
|
+
export type ViewerToolbarPosition = FileViewerToolbarPosition;
|
|
5
|
+
export type ViewerToolbarOptions = FileViewerToolbarOptions;
|
|
6
|
+
export type ViewerArchiveOptions = FileViewerArchiveOptions;
|
|
7
|
+
export type ViewerPdfOptions = FileViewerPdfOptions;
|
|
8
|
+
export type ViewerPresentationOptions = FileViewerPresentationOptions;
|
|
9
|
+
export type ViewerSpreadsheetOptions = FileViewerSpreadsheetOptions;
|
|
10
|
+
export type ViewerDocxOptions = FileViewerDocxOptions;
|
|
11
|
+
export type ViewerTypstOptions = FileViewerTypstOptions;
|
|
12
|
+
export type ViewerCadOptions = FileViewerCadOptions;
|
|
13
|
+
export type ViewerSearchOptions = FileViewerSearchOptions;
|
|
14
|
+
export type ViewerAiOptions = FileViewerAiOptions;
|
|
15
|
+
export type ViewerFitMode = FileViewerFitMode;
|
|
16
|
+
export type ViewerFitOptions = FileViewerFitOptions;
|
|
17
|
+
export type ViewerFitResult = FileViewerFitResult;
|
|
18
|
+
export type ViewerViewState = FileViewerViewState;
|
|
19
|
+
export type ViewerApplyViewStateOptions = FileViewerApplyViewStateOptions;
|
|
20
|
+
export type ViewerThemeMode = FileViewerThemeMode;
|
|
21
|
+
export type ViewerUiDensity = FileViewerUiDensity;
|
|
22
|
+
export type ViewerUiOptions = FileViewerUiOptions;
|
|
23
|
+
export type ViewerOptions = FileViewerOptions;
|
|
24
|
+
export type ViewerEventType = FileViewerEventType;
|
|
25
|
+
export type ViewerEvent = FileViewerEvent;
|
|
26
|
+
export type ViewerEventHandler = FileViewerEventHandler;
|
|
27
|
+
export interface ViewerState {
|
|
28
|
+
loading: boolean;
|
|
29
|
+
ready: boolean;
|
|
30
|
+
error: unknown | null;
|
|
31
|
+
lastEvent: ViewerEvent | null;
|
|
32
|
+
lifecycle: FileViewerLifecycleContext | null;
|
|
33
|
+
availability: FileViewerOperationAvailability | null;
|
|
34
|
+
search: FileViewerSearchState | null;
|
|
35
|
+
zoom: FileViewerZoomState | null;
|
|
36
|
+
location: FileViewerDocumentAnchor | null;
|
|
37
|
+
/** Added in 2.2; optional so existing state fixtures remain source-compatible. */
|
|
38
|
+
viewState?: FileViewerViewState | null;
|
|
39
|
+
}
|
|
40
|
+
export type ViewerStateListener = (state: ViewerState, event?: ViewerEvent) => void;
|
|
41
|
+
export interface ViewerMountOptions {
|
|
42
|
+
url?: string;
|
|
43
|
+
file?: FileRef;
|
|
44
|
+
buffer?: ArrayBuffer;
|
|
45
|
+
name?: string;
|
|
46
|
+
filename?: string;
|
|
47
|
+
type?: string;
|
|
48
|
+
size?: number;
|
|
49
|
+
options?: ViewerOptions;
|
|
50
|
+
onEvent?: ViewerEventHandler;
|
|
51
|
+
onStateChange?: ViewerStateListener;
|
|
52
|
+
}
|
|
53
|
+
export interface ViewerSourceInput {
|
|
54
|
+
url?: string;
|
|
55
|
+
file?: FileRef;
|
|
56
|
+
buffer?: ArrayBuffer;
|
|
57
|
+
filename?: string;
|
|
58
|
+
name?: string;
|
|
59
|
+
type?: string;
|
|
60
|
+
size?: number;
|
|
61
|
+
}
|
|
62
|
+
export interface ViewerFetchInput {
|
|
63
|
+
url: string;
|
|
64
|
+
signal?: AbortSignal;
|
|
65
|
+
source: ViewerSourceInput;
|
|
66
|
+
}
|
|
67
|
+
export type ViewerFetchFile = (input: ViewerFetchInput) => Promise<FileRef | null | undefined>;
|
|
68
|
+
export interface ViewerCoreOptions {
|
|
69
|
+
registry?: RendererRegistry;
|
|
70
|
+
fetchFile?: ViewerFetchFile;
|
|
71
|
+
onError?: (error: unknown, source: ViewerSourceInput) => void;
|
|
72
|
+
}
|
|
73
|
+
export interface ViewerController {
|
|
74
|
+
readonly container: HTMLElement;
|
|
75
|
+
load(options: ViewerMountOptions): Promise<void>;
|
|
76
|
+
update(options?: ViewerMountOptions): Promise<void>;
|
|
77
|
+
reload(): Promise<void>;
|
|
78
|
+
destroy(): void;
|
|
79
|
+
getApi(): FileViewerPublicApi | FileViewerInstance | null;
|
|
80
|
+
downloadOriginalFile(): Promise<void>;
|
|
81
|
+
printRenderedHtml(options?: FileViewerPrintOptions): Promise<void>;
|
|
82
|
+
printWithMask(options?: FileViewerPrintOptions): Promise<void>;
|
|
83
|
+
exportRenderedHtml(): Promise<void>;
|
|
84
|
+
zoomIn(): Promise<FileViewerZoomState | null>;
|
|
85
|
+
zoomOut(): Promise<FileViewerZoomState | null>;
|
|
86
|
+
resetZoom(): Promise<FileViewerZoomState | null>;
|
|
87
|
+
fitToView(fit?: FileViewerFitMode | FileViewerFitOptions): Promise<FileViewerFitResult | null>;
|
|
88
|
+
getViewState(): FileViewerViewState | null;
|
|
89
|
+
applyViewState(state: FileViewerViewState, options?: FileViewerApplyViewStateOptions): Promise<FileViewerViewState | null>;
|
|
90
|
+
searchDocument(query: string): Promise<FileViewerSearchState | null>;
|
|
91
|
+
clearDocumentSearch(): Promise<FileViewerSearchState | null>;
|
|
92
|
+
nextSearchResult(): Promise<FileViewerSearchState | null>;
|
|
93
|
+
previousSearchResult(): Promise<FileViewerSearchState | null>;
|
|
94
|
+
collectDocumentAnchors(): Promise<FileViewerDocumentAnchor[]>;
|
|
95
|
+
scrollToAnchor(anchor: FileViewerDocumentAnchor | string): Promise<boolean>;
|
|
96
|
+
scrollToLine(line: number): Promise<boolean>;
|
|
97
|
+
getDocumentTextChunks(): FileViewerDocumentChunk[];
|
|
98
|
+
getOperationAvailability(): FileViewerOperationAvailability | null;
|
|
99
|
+
getZoomState(): FileViewerZoomState | null;
|
|
100
|
+
getSearchState(): FileViewerSearchState | null;
|
|
101
|
+
getState(): ViewerState;
|
|
102
|
+
subscribe(listener: ViewerStateListener): () => void;
|
|
103
|
+
}
|
|
104
|
+
export type ViewerControllerAccessor = () => ViewerController | null;
|
|
105
|
+
export interface ViewerControllerHandle {
|
|
106
|
+
load(options: ViewerMountOptions): Promise<void>;
|
|
107
|
+
update(options?: ViewerMountOptions): Promise<void>;
|
|
108
|
+
reload(): Promise<void>;
|
|
109
|
+
destroy(): void;
|
|
110
|
+
getController(): ViewerController | null;
|
|
111
|
+
getApi(): FileViewerPublicApi | FileViewerInstance | null;
|
|
112
|
+
downloadOriginalFile(): Promise<void>;
|
|
113
|
+
printRenderedHtml(options?: FileViewerPrintOptions): Promise<void>;
|
|
114
|
+
printWithMask(options?: FileViewerPrintOptions): Promise<void>;
|
|
115
|
+
exportRenderedHtml(): Promise<void>;
|
|
116
|
+
zoomIn(): Promise<FileViewerZoomState | null>;
|
|
117
|
+
zoomOut(): Promise<FileViewerZoomState | null>;
|
|
118
|
+
resetZoom(): Promise<FileViewerZoomState | null>;
|
|
119
|
+
fitToView(fit?: FileViewerFitMode | FileViewerFitOptions): Promise<FileViewerFitResult | null>;
|
|
120
|
+
getViewState(): FileViewerViewState | null;
|
|
121
|
+
applyViewState(state: FileViewerViewState, options?: FileViewerApplyViewStateOptions): Promise<FileViewerViewState | null>;
|
|
122
|
+
searchDocument(query: string): Promise<FileViewerSearchState | null>;
|
|
123
|
+
clearDocumentSearch(): Promise<FileViewerSearchState | null>;
|
|
124
|
+
nextSearchResult(): Promise<FileViewerSearchState | null>;
|
|
125
|
+
previousSearchResult(): Promise<FileViewerSearchState | null>;
|
|
126
|
+
collectDocumentAnchors(): Promise<FileViewerDocumentAnchor[]>;
|
|
127
|
+
scrollToAnchor(anchor: FileViewerDocumentAnchor | string): Promise<boolean>;
|
|
128
|
+
scrollToLine(line: number): Promise<boolean>;
|
|
129
|
+
getDocumentTextChunks(): FileViewerDocumentChunk[];
|
|
130
|
+
getOperationAvailability(): FileViewerOperationAvailability | null;
|
|
131
|
+
getZoomState(): FileViewerZoomState | null;
|
|
132
|
+
getSearchState(): FileViewerSearchState | null;
|
|
133
|
+
getState(): ViewerState | null;
|
|
134
|
+
subscribe(listener: ViewerStateListener): () => void;
|
|
135
|
+
}
|
|
136
|
+
export declare const createViewerControllerHandle: (getController: ViewerControllerAccessor, dispose: () => void) => ViewerControllerHandle;
|
|
137
|
+
export declare const mountViewer: (container: HTMLElement, initialOptions?: ViewerMountOptions, coreOptions?: ViewerCoreOptions) => ViewerController;
|