@file-viewer/core 3.1.2 → 3.2.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.
Files changed (103) hide show
  1. package/README.en.md +3 -121
  2. package/README.md +3 -126
  3. package/dist/assets.d.ts +2 -2
  4. package/dist/assets.js +1 -5
  5. package/dist/browser/controller.d.ts +1 -2
  6. package/dist/browser/controller.js +2 -34
  7. package/dist/browser.d.ts +2 -2
  8. package/dist/browser.js +2 -2
  9. package/dist/config/options.d.ts +1 -1
  10. package/dist/contracts/types.d.ts +26 -423
  11. package/dist/contracts/xml.d.ts +0 -11
  12. package/dist/export.d.ts +3 -10
  13. package/dist/export.js +2 -9
  14. package/dist/exportDocument.d.ts +1 -12
  15. package/dist/exportDocument.js +7 -31
  16. package/dist/features/document/dom/anchors.d.ts +1 -1
  17. package/dist/features/document/dom/index.d.ts +5 -5
  18. package/dist/features/document/dom/index.js +3 -3
  19. package/dist/features/document/dom/providers.d.ts +1 -1
  20. package/dist/features/document/events.d.ts +2 -2
  21. package/dist/features/document/events.js +3 -3
  22. package/dist/features/document/fit.d.ts +1 -1
  23. package/dist/features/document/fit.js +1 -1
  24. package/dist/features/document/model.d.ts +1 -1
  25. package/dist/features/document/search.d.ts +1 -1
  26. package/dist/features/document/search.js +2 -2
  27. package/dist/features/document/viewState.d.ts +1 -1
  28. package/dist/features/document/viewState.js +2 -2
  29. package/dist/features/document/zoom.d.ts +3 -2
  30. package/dist/features/document/zoom.js +19 -3
  31. package/dist/features/document/zoomGestures.d.ts +11 -0
  32. package/dist/features/document/zoomGestures.js +111 -0
  33. package/dist/features/printMask.d.ts +1 -1
  34. package/dist/features/printMaskDesigner.d.ts +2 -6
  35. package/dist/features/printMaskDesigner.js +2 -11
  36. package/dist/features/printMaskLoader.d.ts +1 -7
  37. package/dist/features/printMaskLoader.js +1 -7
  38. package/dist/features/watermark.d.ts +1 -1
  39. package/dist/headless.d.ts +29 -29
  40. package/dist/headless.js +16 -21
  41. package/dist/i18n/messages.d.ts +1 -1
  42. package/dist/i18n/messages.de.d.ts +1 -5
  43. package/dist/i18n/messages.de.js +0 -4
  44. package/dist/i18n/messages.ja.d.ts +1 -6
  45. package/dist/i18n/messages.ja.js +0 -5
  46. package/dist/i18n/messages.js +2 -2
  47. package/dist/index.d.ts +74 -74
  48. package/dist/index.js +37 -37
  49. package/dist/lifecycle/facade.d.ts +4 -4
  50. package/dist/lifecycle/facade.js +2 -2
  51. package/dist/lifecycle/operations.d.ts +4 -4
  52. package/dist/lifecycle/operations.js +4 -9
  53. package/dist/output/canvasImage.d.ts +1 -2
  54. package/dist/output/canvasImage.js +1 -4
  55. package/dist/output/export.d.ts +2 -4
  56. package/dist/output/export.js +133 -81
  57. package/dist/output/printLayout.d.ts +2 -5
  58. package/dist/output/printLayout.js +37 -9
  59. package/dist/output/snapshotDownload.d.ts +1 -2
  60. package/dist/output/snapshotDownload.js +2 -3
  61. package/dist/platform/assets.d.ts +9 -16
  62. package/dist/platform/assets.js +60 -17
  63. package/dist/platform/copiedAssets.d.ts +0 -1
  64. package/dist/platform/copiedAssets.js +1 -2
  65. package/dist/presentation/state.d.ts +1 -1
  66. package/dist/presentation/state.js +3 -3
  67. package/dist/print-mask.d.ts +2 -2
  68. package/dist/print-mask.js +1 -1
  69. package/dist/registry/capabilities.d.ts +3 -16
  70. package/dist/registry/capabilities.js +2 -15
  71. package/dist/registry/formats.d.ts +5 -5
  72. package/dist/registry/formats.generated.d.ts +7 -8
  73. package/dist/registry/formats.generated.js +7 -4
  74. package/dist/registry/formats.js +2 -2
  75. package/dist/registry/registry.d.ts +6 -15
  76. package/dist/registry/registry.js +24 -10
  77. package/dist/renderers/image.d.ts +1 -1
  78. package/dist/renderers/image.js +26 -5
  79. package/dist/renderers/index.d.ts +11 -11
  80. package/dist/renderers/index.js +5 -11
  81. package/dist/rendering/dispatcher.d.ts +1 -6
  82. package/dist/rendering/dispatcher.js +3 -3
  83. package/dist/rendering/handler.d.ts +10 -15
  84. package/dist/rendering/handler.js +20 -27
  85. package/dist/security/svgResources.d.ts +0 -10
  86. package/dist/security/svgResources.js +2 -11
  87. package/dist/source/index.d.ts +3 -3
  88. package/dist/source/index.js +1 -1
  89. package/dist/source/loading.d.ts +56 -15
  90. package/dist/source/loading.js +177 -87
  91. package/dist/source/precheck.d.ts +1 -13
  92. package/dist/source/precheck.js +2 -9
  93. package/dist/source/textEncoding.d.ts +6 -3
  94. package/dist/source/textEncoding.js +58 -8
  95. package/dist/viewer/createViewer.d.ts +1 -1
  96. package/dist/viewer/createViewer.js +103 -33
  97. package/dist/viewer/loading.d.ts +2 -6
  98. package/dist/viewer/loading.js +1 -9
  99. package/dist/viewer/operations.d.ts +3 -3
  100. package/dist/viewer/operations.js +6 -14
  101. package/dist/viewer/state.d.ts +2 -6
  102. package/dist/viewer/state.js +3 -8
  103. package/package.json +127 -19
package/README.en.md CHANGED
@@ -1,125 +1,7 @@
1
1
  # @file-viewer/core
2
2
 
3
- Framework-neutral TypeScript foundation for Flyfish File Viewer.
3
+ Runtime package version 3.2.1.
4
4
 
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.
5
+ Usage and API documentation: https://doc.file-viewer.app/
6
6
 
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
-
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
-
11
- Current framework-neutral browser renderers still inside core are limited to the low-cost image path. Spreadsheet rendering has moved to `@file-viewer/renderer-spreadsheet`; CAD rendering has moved to `@file-viewer/renderer-cad`; Typst rendering has moved to `@file-viewer/renderer-typst`; OFD rendering has moved to `@file-viewer/renderer-ofd`; PDF rendering has moved to `@file-viewer/renderer-pdf`; archive rendering has moved to `@file-viewer/renderer-archive`; email rendering has moved to `@file-viewer/renderer-email`; EPUB and UMD ebook rendering has moved to `@file-viewer/renderer-epub`; 3D model rendering has moved to `@file-viewer/renderer-3d`; Draw.io, Excalidraw, Mermaid, and PlantUML rendering has moved to `@file-viewer/renderer-drawing`; audio, video, HLS, and MIDI rendering has moved to `@file-viewer/renderer-media`; code, text, Markdown, patch, and git bundle rendering has moved to `@file-viewer/renderer-text`; Word DOCX/DOC/RTF/ODT rendering has moved to `@file-viewer/renderer-word`; PowerPoint rendering has moved to `@file-viewer/renderer-presentation`; XMind rendering has moved to `@file-viewer/renderer-mindmap`; geospatial rendering has moved to `@file-viewer/renderer-geo`; data asset rendering has moved to `@file-viewer/renderer-data`; EDA rendering and parsing has moved to `@file-viewer/renderer-eda`. Core-only installs now avoid direct OFD, PDF, Word, Spreadsheet, PPTX, CAD, Typst, XMind, Geo, media, 3D, drawing, archive, email, EPUB, UMD, data asset, EDA, `ofd-xml-parser`, `jszip`, `pdfjs-dist`, `styled-exceljs`, `e-virt-table`, `tinycolor2`, `@flyfish-dev/cad-viewer`, `@myriaddreamin/*`, `highlight.js`, `marked`, `diff2html`, `pako`, `mermaid`, `plantuml-encoder`, `@panzoom/panzoom`, `hls.js`, `@tonejs/midi`, `three`, `@excalidraw/excalidraw`, `roughjs`, `libarchive.js`, `postal-mime`, `@kenjiuno/msgreader`, `epubjs`, `ag-psd`, `sql.js`, `hyparquet`, `avsc`, and `cfb` engine dependencies.
12
-
13
- ```bash
14
- npm install @file-viewer/core
15
- ```
16
-
17
- ## Preflight Before Rendering
18
-
19
- `precheckFileViewerSource()` does not create a viewer or load a heavy renderer. It checks whether the extension is available and validates known PDF, OpenXML / OpenDocument, legacy OLE Office, and RTF signatures or package parts. `valid: null` explicitly means capability-only detection, not a full parse; the real renderer remains the final authority for malformed content.
20
-
21
- ```ts
22
- import { precheckFileViewerSource } from '@file-viewer/core/headless'
23
-
24
- const result = await precheckFileViewerSource(file, {
25
- // Restrict this to the extensions actually installed by this product.
26
- supportedExtensions: ['pdf', 'docx', 'xlsx', 'pptx']
27
- })
28
-
29
- if (!result.previewable) {
30
- console.warn(result.reason, result.missingParts)
31
- }
32
- ```
33
-
34
- ## Entry points
35
-
36
- Use `@file-viewer/core/headless` when a component package, server-side helper, or build script only needs framework-neutral contracts: format support, source normalization, renderer capability metadata, lifecycle/operation context, option normalization, state helpers, and static asset resolution. This entry intentionally does not expose the DOM viewer engine or browser renderers.
37
-
38
- ```ts
39
- import {
40
- DEFAULT_SUPPORTED_EXTENSIONS,
41
- normalizeSource,
42
- resolveFileViewerRendererAssets
43
- } from '@file-viewer/core/headless'
44
-
45
- const source = normalizeSource({ url: '/files/report.pdf' })
46
- const pdfAssets = resolveFileViewerRendererAssets('pdf', {
47
- baseUrl: '/file-viewer/'
48
- })
49
- ```
50
-
51
- 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.
52
-
53
- ```ts
54
- import {
55
- createViewer,
56
- coreBrowserRendererHandlers
57
- } from '@file-viewer/core/browser'
58
-
59
- const viewer = createViewer(document.querySelector('#viewer')!, {
60
- options: {
61
- toolbar: true,
62
- styleIsolation: 'shadow'
63
- }
64
- })
65
-
66
- await viewer.load({ url: '/files/report.pdf' })
67
- ```
68
-
69
- HTML document builders live in the opt-in export entry so ordinary previews do
70
- not download the sanitizer. The viewer's `exportHtml()` and `print()` methods
71
- load this entry only when invoked. For v3, migrate direct builder imports from
72
- the package root to the explicit subpath:
73
-
74
- ```ts
75
- import {
76
- buildExportHtmlDocument,
77
- buildFileViewerRenderedHtmlDocument
78
- } from '@file-viewer/core/export'
79
- ```
80
-
81
- The deprecated Vue 3 template re-exports are asynchronous in v3 to preserve
82
- this lazy boundary, so legacy calls must use `await buildExportHtmlDocument(...)`
83
- or `await collectDocumentStyles()`. Direct imports from the `export` subpath
84
- keep their documented return types.
85
-
86
- `options.styleIsolation` accepts `auto`, `shadow`, `scoped`, or `none`. Use `shadow` when a custom host or framework wrapper needs a ShadowRoot-backed render surface. Core passes the resolved `surface` to renderer `load(context)`, so custom renderers should inject styles into `context.surface.shadowRoot` or the renderer container instead of `document.head`, and should mount overlays inside the same isolated surface when possible.
87
-
88
- The root `@file-viewer/core` entry remains the normal browser-compatible entry. New component packages should prefer the narrowest explicit entry point they need: `headless` for contracts and build-time helpers, `browser` for real browser preview, and `export` for sanitized standalone HTML documents.
89
-
90
- ```ts
91
- import {
92
- listFileViewerRendererAssetManifests,
93
- resolveFileViewerRendererAssets
94
- } from '@file-viewer/core'
95
-
96
- const manifests = listFileViewerRendererAssetManifests()
97
- const archiveAssets = resolveFileViewerRendererAssets('archive', {
98
- baseUrl: '/file-viewer/'
99
- })
100
- ```
101
-
102
- For non-Vite hosts or custom static directories, configure one runtime asset
103
- base before loading a file. Renderer-specific URLs still take priority. The
104
- Vite plugin sets this automatically from `copyAssets.baseDir`.
105
-
106
- ```ts
107
- import { setDefaultFileViewerAssetBaseUrl } from '@file-viewer/core'
108
-
109
- setDefaultFileViewerAssetBaseUrl('/tenant/static/file-viewer/')
110
- ```
111
-
112
- The manifest API lets wrappers and deployment scripts discover archive, DOCX, Spreadsheet, CAD, Typst, and data-asset worker/WASM resources from the same core contract instead of hard-coding per-framework paths. Spreadsheet assets remain part of the shared deployment contract for `@file-viewer/renderer-spreadsheet`; CAD assets remain part of the shared deployment contract for `@file-viewer/renderer-cad`; archive assets remain part of the shared deployment contract for `@file-viewer/renderer-archive`; DOCX assets remain part of the shared deployment contract for `@file-viewer/renderer-word`; SQLite WASM asset resolution remains in core so `@file-viewer/renderer-data` and deployment tools share one stable offline path.
113
-
114
- Official documentation: https://doc.file-viewer.app/
115
-
116
- Online demo: https://demo.file-viewer.app/
117
-
118
- Public source repositories:
119
-
120
- - GitHub: https://github.com/flyfish-dev/file-viewer-core
121
- - Gitee: https://gitee.com/flyfish-dev/file-viewer-core
122
-
123
- The GitHub/Gitee repositories are distributed public source packages. The private Gitea aggregate remains useful for the complete workspace, release automation, integration history, sponsorship, and priority support.
124
-
125
- License: Apache-2.0. For second development or commercial use, keep clear Flyfish Viewer attribution and contribute shared compatibility improvements where possible.
7
+ The package's own license is Apache-2.0. Included third-party notices apply to their respective components.
package/README.md CHANGED
@@ -1,130 +1,7 @@
1
1
  # @file-viewer/core
2
2
 
3
- Framework-neutral TypeScript foundation for Flyfish File Viewer.
3
+ Runtime package version 3.2.1.
4
4
 
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.
5
+ Usage and API documentation: https://doc.file-viewer.app/
6
6
 
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
-
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
-
11
- Current framework-neutral browser renderers still inside core are limited to the low-cost image path. Spreadsheet rendering has moved to `@file-viewer/renderer-spreadsheet`; CAD rendering has moved to `@file-viewer/renderer-cad`; Typst rendering has moved to `@file-viewer/renderer-typst`; OFD rendering has moved to `@file-viewer/renderer-ofd`; PDF rendering has moved to `@file-viewer/renderer-pdf`; archive rendering has moved to `@file-viewer/renderer-archive`; email rendering has moved to `@file-viewer/renderer-email`; EPUB and UMD ebook rendering has moved to `@file-viewer/renderer-epub`; 3D model rendering has moved to `@file-viewer/renderer-3d`; Draw.io, Excalidraw, Mermaid, and PlantUML rendering has moved to `@file-viewer/renderer-drawing`; audio, video, HLS and MIDI rendering has moved to `@file-viewer/renderer-media`; code, text, Markdown, patch and git bundle rendering has moved to `@file-viewer/renderer-text`; Word DOCX/DOC/RTF/ODT rendering has moved to `@file-viewer/renderer-word`; PowerPoint rendering has moved to `@file-viewer/renderer-presentation`; XMind rendering has moved to `@file-viewer/renderer-mindmap`; geospatial rendering has moved to `@file-viewer/renderer-geo`; data asset rendering has moved to `@file-viewer/renderer-data`; EDA rendering and parsing has moved to `@file-viewer/renderer-eda`. Core-only installs now avoid direct OFD, PDF, Word, Spreadsheet, PPTX, CAD, Typst, XMind, Geo, media, 3D, drawing, archive, email, EPUB, UMD, data asset, EDA, `ofd-xml-parser`, `jszip`, `pdfjs-dist`, `styled-exceljs`, `e-virt-table`, `tinycolor2`, `@flyfish-dev/cad-viewer`, `@myriaddreamin/*`, `highlight.js`, `marked`, `diff2html`, `pako`, `mermaid`, `plantuml-encoder`, `@panzoom/panzoom`, `hls.js`, `@tonejs/midi`, `three`, `@excalidraw/excalidraw`, `roughjs`, `libarchive.js`, `postal-mime`, `@kenjiuno/msgreader`, `epubjs`, `ag-psd`, `sql.js`, `hyparquet`, `avsc` and `cfb` engine dependencies.
12
-
13
- ```bash
14
- npm install @file-viewer/core
15
- ```
16
-
17
- ## 渲染前预检
18
-
19
- `precheckFileViewerSource()` 不会创建 viewer,也不会加载重型 renderer。它先检查当前扩展名是否在能力范围内,并对 PDF、OpenXML / OpenDocument、旧版 OLE Office、RTF 等格式执行签名或包结构检查。`valid: null` 明确表示该格式只有能力检查、没有做完整解析;真实 renderer 仍是畸形文件的最终判断者。
20
-
21
- ```ts
22
- import { precheckFileViewerSource } from '@file-viewer/core/headless'
23
-
24
- const result = await precheckFileViewerSource(file, {
25
- // 可传当前产品实际安装的扩展名列表,避免把未装 preset 的格式报成可预览
26
- supportedExtensions: ['pdf', 'docx', 'xlsx', 'pptx']
27
- })
28
-
29
- if (!result.previewable) {
30
- console.warn(result.reason, result.missingParts)
31
- }
32
- ```
33
-
34
- ## Entry points
35
-
36
- Use `@file-viewer/core/headless` when a component package, server-side helper or build script only needs framework-neutral contracts: format support, source normalization, renderer capability metadata, lifecycle/operation context, option normalization, state helpers and static asset resolution. This entry intentionally does not expose the DOM viewer engine or browser renderers.
37
-
38
- ```ts
39
- import {
40
- DEFAULT_SUPPORTED_EXTENSIONS,
41
- normalizeSource,
42
- resolveFileViewerRendererAssets
43
- } from '@file-viewer/core/headless'
44
-
45
- const source = normalizeSource({ url: '/files/report.pdf' })
46
- const pdfAssets = resolveFileViewerRendererAssets('pdf', {
47
- baseUrl: '/file-viewer/'
48
- })
49
- ```
50
-
51
- 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.
52
-
53
- ```ts
54
- import {
55
- createViewer,
56
- coreBrowserRendererHandlers
57
- } from '@file-viewer/core/browser'
58
-
59
- const viewer = createViewer(document.querySelector('#viewer')!, {
60
- options: {
61
- toolbar: true,
62
- styleIsolation: 'shadow'
63
- }
64
- })
65
-
66
- await viewer.load({ url: '/files/report.pdf' })
67
- ```
68
-
69
- HTML document builders live in the opt-in export entry so ordinary previews do
70
- not download the sanitizer. The viewer's `exportHtml()` and `print()` methods
71
- load this entry only when invoked. For v3, migrate direct builder imports from
72
- the package root to the explicit subpath:
73
-
74
- ```ts
75
- import {
76
- buildExportHtmlDocument,
77
- buildFileViewerRenderedHtmlDocument
78
- } from '@file-viewer/core/export'
79
- ```
80
-
81
- Vue 3 模板中已弃用的兼容导出在 v3 中改为异步,以保持这条懒加载边界;
82
- 旧调用需要使用 `await buildExportHtmlDocument(...)` 或
83
- `await collectDocumentStyles()`。直接从 `export` 子路径导入时,返回类型仍
84
- 按该子路径的 API 文档保持不变。
85
-
86
- `options.styleIsolation` accepts `auto`, `shadow`, `scoped`, or `none`. Use `shadow` when a custom host or framework wrapper needs a ShadowRoot-backed render surface. Core passes the resolved `surface` to renderer `load(context)`, so custom renderers should inject styles into `context.surface.shadowRoot` or the renderer container instead of `document.head`, and should mount overlays inside the same isolated surface when possible.
87
-
88
- The root `@file-viewer/core` entry remains the normal browser-compatible entry. New component packages should prefer the narrowest explicit entry point they need: `headless` for contracts and build-time helpers, `browser` for real browser preview, and `export` for sanitized standalone HTML documents.
89
-
90
- ```ts
91
- import {
92
- listFileViewerRendererAssetManifests,
93
- resolveFileViewerRendererAssets
94
- } from '@file-viewer/core'
95
-
96
- const manifests = listFileViewerRendererAssetManifests()
97
- const cadAssets = resolveFileViewerRendererAssets('cad', {
98
- baseUrl: '/file-viewer/',
99
- options: {
100
- cad: {
101
- wasmPath: '/file-viewer/wasm/cad/'
102
- }
103
- }
104
- })
105
- ```
106
-
107
- For non-Vite hosts or custom static directories, configure one runtime asset
108
- base before loading a file. Renderer-specific URLs still take priority. The
109
- Vite plugin sets this automatically from `copyAssets.baseDir`.
110
-
111
- ```ts
112
- import { setDefaultFileViewerAssetBaseUrl } from '@file-viewer/core'
113
-
114
- setDefaultFileViewerAssetBaseUrl('/tenant/static/file-viewer/')
115
- ```
116
-
117
- The manifest API lets wrappers and deployment scripts discover archive, DOCX, Spreadsheet, CAD, Typst and data-asset worker/WASM resources from the same core contract instead of hard-coding per-framework paths. Spreadsheet assets remain part of the shared deployment contract for `@file-viewer/renderer-spreadsheet`; CAD assets remain part of the shared deployment contract for `@file-viewer/renderer-cad`; archive assets remain part of the shared deployment contract for `@file-viewer/renderer-archive`; DOCX assets remain part of the shared deployment contract for `@file-viewer/renderer-word`; SQLite WASM asset resolution remains in core so `@file-viewer/renderer-data` and deployment tools share one stable offline path.
118
-
119
- Official documentation: https://doc.file-viewer.app/
120
-
121
- Online demo: https://demo.file-viewer.app/
122
-
123
- Public source repositories:
124
-
125
- - GitHub: https://github.com/flyfish-dev/file-viewer-core
126
- - Gitee: https://gitee.com/flyfish-dev/file-viewer-core
127
-
128
- The GitHub/Gitee repositories are distributed public source packages. The private Gitea aggregate remains useful for the complete workspace, release automation, integration history, sponsorship, and priority support.
129
-
130
- License: Apache-2.0. For second development or commercial use, keep clear Flyfish Viewer attribution and contribute shared compatibility improvements where possible.
7
+ The package's own license is Apache-2.0. Included third-party notices apply to their respective components.
package/dist/assets.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './platform/assets';
2
- export type * from './platform/assets';
1
+ export * from "./platform/assets.js";
2
+ export type * from "./platform/assets.js";
package/dist/assets.js CHANGED
@@ -1,5 +1 @@
1
- // Public subpath facade for `@file-viewer/core/assets`.
2
- //
3
- // Asset resolution belongs to the platform layer, but this root-level file is
4
- // intentionally kept as the stable package export declared in package.json.
5
- export * from './platform/assets.js';
1
+ export * from "./platform/assets.js";
@@ -1,4 +1,4 @@
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';
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.js";
2
2
  export type FileRef = FileViewerFileRef;
3
3
  export type ViewerWatermarkOptions = FileViewerWatermarkOptions;
4
4
  export type ViewerToolbarPosition = FileViewerToolbarPosition;
@@ -34,7 +34,6 @@ export interface ViewerState {
34
34
  search: FileViewerSearchState | null;
35
35
  zoom: FileViewerZoomState | null;
36
36
  location: FileViewerDocumentAnchor | null;
37
- /** Added in 2.2; optional so existing state fixtures remain source-compatible. */
38
37
  viewState?: FileViewerViewState | null;
39
38
  }
40
39
  export type ViewerStateListener = (state: ViewerState, event?: ViewerEvent) => void;
@@ -1,5 +1,5 @@
1
- import { appendFileViewerStyle, applyFileViewerZoomAvailability, createViewer, isFileViewerShadowRoot, normalizeFileViewerUiDensity, normalizeFileViewerTheme, normalizeFileViewerStyleIsolation, syncFileViewerRenderSurfaceBackground, } from '../index.js';
2
- import { DEFAULT_FILE_VIEWER_SOURCE_FILENAME, createFileViewerTranslator, getExtension, normalizeFileViewerSourceUrl, hasVisibleFileViewerToolbarActions, isFileViewerZoomButtonDisabled, normalizeFileViewerToolbar, normalizeFilename, readFileViewerBuffer, resolveFileViewerSourceFilename, resolveFileViewerColorScheme, resolveFileViewerToolbarOrder, resolveFileViewerToolbarPosition, resolveVisibleFileViewerToolbar, toggleFileViewerColorScheme, wrapFileViewerFileRef, } from '../index.js';
1
+ import { appendFileViewerStyle, applyFileViewerZoomAvailability, createViewer, isFileViewerShadowRoot, normalizeFileViewerUiDensity, normalizeFileViewerTheme, normalizeFileViewerStyleIsolation, syncFileViewerRenderSurfaceBackground, } from "../index.js";
2
+ import { DEFAULT_FILE_VIEWER_SOURCE_FILENAME, createFileViewerTranslator, getExtension, normalizeFileViewerSourceUrl, hasVisibleFileViewerToolbarActions, isFileViewerZoomButtonDisabled, normalizeFileViewerToolbar, normalizeFilename, readFileViewerBuffer, resolveFileViewerSourceFilename, resolveFileViewerColorScheme, resolveFileViewerToolbarOrder, resolveFileViewerToolbarPosition, resolveVisibleFileViewerToolbar, toggleFileViewerColorScheme, wrapFileViewerFileRef, } from "../index.js";
3
3
  const isBrowser = () => typeof window !== 'undefined' && typeof document !== 'undefined';
4
4
  const hasSource = (options = {}) => {
5
5
  return !!(options.url || options.file || options.buffer);
@@ -13,8 +13,6 @@ const toViewerSourceInput = (options = {}) => ({
13
13
  type: options.type,
14
14
  size: options.size,
15
15
  });
16
- // These options feed renderer selection or rendering itself. Viewer chrome,
17
- // fitting, watermark, and operation callbacks update in place instead.
18
16
  const RENDER_AFFECTING_VIEWER_OPTION_KEYS = [
19
17
  'theme',
20
18
  'rendererMode',
@@ -301,9 +299,6 @@ const DEFAULT_TOOLBAR_ZOOM_STATE = {
301
299
  canZoomOut: false,
302
300
  canReset: false,
303
301
  };
304
- // A ShadowRoot cannot be detached. Track the exact roots created on viewer
305
- // hosts so a later light-DOM remount can expose its children through a slot,
306
- // without mistaking and clearing a ShadowRoot owned by the host application.
307
302
  const ownedViewerShadowRoots = new WeakMap();
308
303
  const WEB_VIEWER_STYLE = `
309
304
  :host,.file-viewer-web-shell{display:block;width:100%;height:100%;min-width:0;min-height:0;contain:content;--file-viewer-bg:transparent;--file-viewer-content-bg:transparent;--file-viewer-text:#172033;--file-viewer-muted:#607282;--file-viewer-font:14px/1.45 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;--file-viewer-border:rgba(20,35,53,.08);--file-viewer-toolbar-bg:rgba(255,255,255,.92);--file-viewer-toolbar-border:rgba(20,35,53,.06);--file-viewer-toolbar-shadow:0 18px 44px rgba(15,23,42,.16);--file-viewer-toolbar-radius:999px;--file-viewer-toolbar-gap:6px;--file-viewer-toolbar-min-height:45px;--file-viewer-toolbar-padding:6px 10px;--file-viewer-toolbar-floating-min-height:42px;--file-viewer-toolbar-floating-padding:6px;--file-viewer-toolbar-floating-offset:16px;--file-viewer-group-bg:rgba(20,35,53,.035);--file-viewer-group-border:rgba(20,35,53,.08);--file-viewer-group-gap:2px;--file-viewer-group-padding:2px;--file-viewer-button-color:#40546a;--file-viewer-button-hover-bg:rgba(33,163,102,.1);--file-viewer-button-hover-color:#16774c;--file-viewer-button-disabled-color:#aab5c0;--file-viewer-button-radius:8px;--file-viewer-button-min-width:42px;--file-viewer-button-height:30px;--file-viewer-button-padding:0 10px;--file-viewer-icon-button-size:30px;--file-viewer-zoom-meter-min-width:48px;--file-viewer-zoom-meter-padding:0 8px;--file-viewer-floating-button-min-width:48px;--file-viewer-floating-button-height:32px;--file-viewer-floating-icon-button-size:32px;--file-viewer-floating-zoom-meter-min-width:54px;--file-viewer-search-input-height:30px;--file-viewer-search-input-padding:0 10px;--file-viewer-search-button-min-width:32px;--file-viewer-search-button-padding:0 8px;--file-viewer-search-count-min-width:42px;--file-viewer-floating-search-input-height:32px;--file-viewer-focus-ring:rgba(31,157,103,.22);--file-viewer-z-toolbar:20;--file-viewer-z-floating-toolbar:30}
@@ -404,26 +399,14 @@ export const mountViewer = (container, initialOptions = {}, coreOptions = {}) =>
404
399
  }
405
400
  else if (shouldUseShadowRoot && canAttachShadowRoot) {
406
401
  try {
407
- // The viewer owns this root even when its host already lives inside a
408
- // customer's ShadowRoot. Reusing the ancestor would let that component's
409
- // resets override the toolbar and would make our :host rules mutate the
410
- // customer's outer custom element.
411
- // Delegated focus makes Safari taps on renderer controls focus the first
412
- // toolbar input instead, triggering keyboard zoom and viewport scrolling.
413
402
  renderRoot = container.attachShadow({ mode: 'open' });
414
403
  ownedViewerShadowRoots.set(container, renderRoot);
415
404
  }
416
405
  catch {
417
- // Some HTMLElement subclasses cannot host Shadow DOM, and a closed root
418
- // is intentionally invisible through `shadowRoot`. Keep the legacy
419
- // scoped path usable instead of surfacing a raw NotSupportedError.
420
406
  renderRoot = container;
421
407
  }
422
408
  }
423
409
  else if (existingHostShadowRoot && !hasOwnedHostShadowRoot) {
424
- // The application owns this root. Preserve every existing child and mount
425
- // the viewer in a dedicated boundary. Shadow mode gets a nested root so
426
- // customer resets in the outer component cannot reach the viewer.
427
410
  mountBoundary = documentRef.createElement('div');
428
411
  mountBoundary.dataset.fileViewerMountBoundary = 'true';
429
412
  existingHostShadowRoot.appendChild(mountBoundary);
@@ -440,9 +423,6 @@ export const mountViewer = (container, initialOptions = {}, coreOptions = {}) =>
440
423
  }
441
424
  }
442
425
  else if (!shouldUseShadowRoot && hasOwnedHostShadowRoot && existingHostShadowRoot) {
443
- // Light-DOM children of a shadow host are not painted unless the root has
444
- // a slot. Keep the immutable owned root, but project the real light-DOM
445
- // viewer so host selectors and legacy deep overrides work as documented.
446
426
  const slot = documentRef.createElement('slot');
447
427
  slot.dataset.fileViewerLightDomSlot = 'true';
448
428
  existingHostShadowRoot.replaceChildren(slot);
@@ -450,9 +430,6 @@ export const mountViewer = (container, initialOptions = {}, coreOptions = {}) =>
450
430
  }
451
431
  renderRoot.replaceChildren();
452
432
  const styleHandle = appendFileViewerStyle(renderRoot, WEB_VIEWER_STYLE, {
453
- // Adopt only into a root owned by the viewer. Adopting into an ancestor
454
- // ShadowRoot would leak toolbar selectors and apply :host rules to the
455
- // customer's custom element.
456
433
  adoptedStyleSheet: isFileViewerShadowRoot(renderRoot),
457
434
  });
458
435
  const shell = documentRef.createElement('div');
@@ -654,12 +631,6 @@ export const mountViewer = (container, initialOptions = {}, coreOptions = {}) =>
654
631
  group.appendChild(createReadonlyMeter(documentRef, zoomState.label, 'file-viewer-web-zoom-meter'));
655
632
  }
656
633
  if (availability.zoomReset) {
657
- // Placed before the zoom-in button (not after) so that toggling this
658
- // button's visibility never shifts the zoom-in button's position: the
659
- // toolbar group is right-aligned, and both icon buttons share the same
660
- // width, so inserting "1:1" after "+" would make it land exactly on
661
- // top of the previous "+" position, turning a repeated zoom-in click
662
- // into an accidental reset (see GitHub issue #88).
663
634
  const button = createButton(documentRef, '1:1', 'file-viewer-web-icon-button', () => controller === null || controller === void 0 ? void 0 : controller.resetZoom());
664
635
  button.title = t('toolbar.zoomReset');
665
636
  button.setAttribute('aria-label', t('toolbar.zoomReset'));
@@ -918,9 +889,6 @@ export const mountViewer = (container, initialOptions = {}, coreOptions = {}) =>
918
889
  }
919
890
  };
920
891
  if (currentSource) {
921
- // The initial declarative source has no caller awaiting it. State changes
922
- // and the visible error surface remain authoritative without a global
923
- // unhandled-rejection event for an expected rendering failure.
924
892
  void loadSource(currentSource).catch(() => undefined);
925
893
  }
926
894
  controller = {
package/dist/browser.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './index';
2
- export * from './browser/controller';
1
+ export * from "./index.js";
2
+ export * from "./browser/controller.js";
package/dist/browser.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './index.js';
2
- export * from './browser/controller.js';
1
+ export * from "./index.js";
2
+ export * from "./browser/controller.js";
@@ -1,4 +1,4 @@
1
- import type { FileViewerArchiveOptions, FileViewerCadOptions, FileViewerOptions, FileViewerResolvedThemeMode, FileViewerThemeMode, FileViewerToolbarOptions, FileViewerUiDensity } from '../contracts/types';
1
+ import type { FileViewerArchiveOptions, FileViewerCadOptions, FileViewerOptions, FileViewerResolvedThemeMode, FileViewerThemeMode, FileViewerToolbarOptions, FileViewerUiDensity } from "../contracts/types.js";
2
2
  export type FileViewerSerializableToolbarOptions = Omit<FileViewerToolbarOptions, 'beforeOperation' | 'beforeDownload' | 'beforePrint' | 'beforeExportHtml'>;
3
3
  export type FileViewerSerializableCadOptions = Omit<FileViewerCadOptions, 'workerUrl'> & {
4
4
  workerUrl?: string;