@file-viewer/renderer-iwork 0.0.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,160 +1,7 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction, and
10
- distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
- owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all other entities
16
- that control, are controlled by, or are under common control with that entity.
17
- For the purposes of this definition, "control" means (i) the power, direct or
18
- indirect, to cause the direction or management of such entity, whether by
19
- contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
- outstanding shares, or (iii) beneficial ownership of such entity.
21
-
22
- "You" (or "Your") shall mean an individual or Legal Entity exercising
23
- permissions granted by this License.
24
-
25
- "Source" form shall mean the preferred form for making modifications, including
26
- but not limited to software source code, documentation source, and configuration
27
- files.
28
-
29
- "Object" form shall mean any form resulting from mechanical transformation or
30
- translation of a Source form, including but not limited to compiled object code,
31
- generated documentation, and conversions to other media types.
32
-
33
- "Work" shall mean the work of authorship, whether in Source or Object form,
34
- made available under the License, as indicated by a copyright notice that is
35
- included in or attached to the work.
36
-
37
- "Derivative Works" shall mean any work, whether in Source or Object form, that
38
- is based on (or derived from) the Work and for which the editorial revisions,
39
- annotations, elaborations, or other modifications represent, as a whole, an
40
- original work of authorship. For the purposes of this License, Derivative Works
41
- shall not include works that remain separable from, or merely link (or bind by
42
- name) to the interfaces of, the Work and Derivative Works thereof.
43
-
44
- "Contribution" shall mean any work of authorship, including the original version
45
- of the Work and any modifications or additions to that Work or Derivative Works
46
- thereof, that is intentionally submitted to Licensor for inclusion in the Work by
47
- the copyright owner or by an individual or Legal Entity authorized to submit on
48
- behalf of the copyright owner. For the purposes of this definition, "submitted"
49
- means any form of electronic, verbal, or written communication sent to the
50
- Licensor or its representatives, including but not limited to communication on
51
- electronic mailing lists, source code control systems, and issue tracking systems
52
- that are managed by, or on behalf of, the Licensor for the purpose of discussing
53
- and improving the Work, but excluding communication that is conspicuously marked
54
- or otherwise designated in writing by the copyright owner as "Not a
55
- Contribution."
56
-
57
- "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
- of whom a Contribution has been received by Licensor and subsequently
59
- incorporated within the Work.
60
-
61
- 2. Grant of Copyright License. Subject to the terms and conditions of this
62
- License, each Contributor hereby grants to You a perpetual, worldwide,
63
- non-exclusive, no-charge, royalty-free, irrevocable copyright license to
64
- reproduce, prepare Derivative Works of, publicly display, publicly perform,
65
- sublicense, and distribute the Work and such Derivative Works in Source or
66
- Object form.
67
-
68
- 3. Grant of Patent License. Subject to the terms and conditions of this License,
69
- each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
70
- no-charge, royalty-free, irrevocable (except as stated in this section) patent
71
- license to make, have made, use, offer to sell, sell, import, and otherwise
72
- transfer the Work, where such license applies only to those patent claims
73
- licensable by such Contributor that are necessarily infringed by their
74
- Contribution(s) alone or by combination of their Contribution(s) with the Work to
75
- which such Contribution(s) was submitted. If You institute patent litigation
76
- against any entity (including a cross-claim or counterclaim in a lawsuit)
77
- alleging that the Work or a Contribution incorporated within the Work
78
- constitutes direct or contributory patent infringement, then any patent licenses
79
- granted to You under this License for that Work shall terminate as of the date
80
- such litigation is filed.
81
-
82
- 4. Redistribution. You may reproduce and distribute copies of the Work or
83
- Derivative Works thereof in any medium, with or without modifications, and in
84
- Source or Object form, provided that You meet the following conditions:
85
-
86
- (a) You must give any other recipients of the Work or Derivative Works a copy of
87
- this License; and
88
-
89
- (b) You must cause any modified files to carry prominent notices stating that
90
- You changed the files; and
91
-
92
- (c) You must retain, in the Source form of any Derivative Works that You
93
- distribute, all copyright, patent, trademark, and attribution notices from the
94
- Source form of the Work, excluding those notices that do not pertain to any part
95
- of the Derivative Works; and
96
-
97
- (d) If the Work includes a "NOTICE" text file as part of its distribution, then
98
- any Derivative Works that You distribute must include a readable copy of the
99
- attribution notices contained within such NOTICE file, excluding those notices
100
- that do not pertain to any part of the Derivative Works, in at least one of the
101
- following places: within a NOTICE text file distributed as part of the Derivative
102
- Works; within the Source form or documentation, if provided along with the
103
- Derivative Works; or, within a display generated by the Derivative Works, if and
104
- wherever such third-party notices normally appear. The contents of the NOTICE
105
- file are for informational purposes only and do not modify the License. You may
106
- add Your own attribution notices within Derivative Works that You distribute,
107
- alongside or as an addendum to the NOTICE text from the Work, provided that such
108
- additional attribution notices cannot be construed as modifying the License.
109
-
110
- You may add Your own copyright statement to Your modifications and may provide
111
- additional or different license terms and conditions for use, reproduction, or
112
- distribution of Your modifications, or for any such Derivative Works as a whole,
113
- provided Your use, reproduction, and distribution of the Work otherwise complies
114
- with the conditions stated in this License.
115
-
116
- 5. Submission of Contributions. Unless You explicitly state otherwise, any
117
- Contribution intentionally submitted for inclusion in the Work by You to the
118
- Licensor shall be under the terms and conditions of this License, without any
119
- additional terms or conditions. Notwithstanding the above, nothing herein shall
120
- supersede or modify the terms of any separate license agreement you may have
121
- executed with Licensor regarding such Contributions.
122
-
123
- 6. Trademarks. This License does not grant permission to use the trade names,
124
- trademarks, service marks, or product names of the Licensor, except as required
125
- for reasonable and customary use in describing the origin of the Work and
126
- reproducing the content of the NOTICE file.
127
-
128
- 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
129
- writing, Licensor provides the Work (and each Contributor provides its
130
- Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
131
- KIND, either express or implied, including, without limitation, any warranties or
132
- conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
133
- PARTICULAR PURPOSE. You are solely responsible for determining the
134
- appropriateness of using or redistributing the Work and assume any risks
135
- associated with Your exercise of permissions under this License.
136
-
137
- 8. Limitation of Liability. In no event and under no legal theory, whether in
138
- tort (including negligence), contract, or otherwise, unless required by
139
- applicable law (such as deliberate and grossly negligent acts) or agreed to in
140
- writing, shall any Contributor be liable to You for damages, including any
141
- direct, indirect, special, incidental, or consequential damages of any character
142
- arising as a result of this License or out of the use or inability to use the
143
- Work (including but not limited to damages for loss of goodwill, work stoppage,
144
- computer failure or malfunction, or any and all other commercial damages or
145
- losses), even if such Contributor has been advised of the possibility of such
146
- damages.
147
-
148
- 9. Accepting Warranty or Additional Liability. While redistributing the Work or
149
- Derivative Works thereof, You may choose to offer, and charge a fee for,
150
- acceptance of support, warranty, indemnity, or other liability obligations and/or
151
- rights consistent with this License. However, in accepting such obligations, You
152
- may act only on Your own behalf and on Your sole responsibility, not on behalf of
153
- any other Contributor, and only if You agree to indemnify, defend, and hold each
154
- Contributor harmless for any liability incurred by, or claims asserted against,
155
- such Contributor by reason of your accepting any such warranty or additional
156
- liability.
157
-
158
- END OF TERMS AND CONDITIONS
1
+ Apache License 2.0
159
2
 
160
3
  Copyright 2026 Yu Wang
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6
+ this file except in compliance with the License. You may obtain a copy at
7
+ https://www.apache.org/licenses/LICENSE-2.0
package/README.en.md CHANGED
@@ -1,18 +1,5 @@
1
1
  # @file-viewer/renderer-iwork
2
2
 
3
- The thin File Viewer adapter for `iwork-viewer`. Parsing and scene rendering live in the standalone package; this package only connects format registration, Worker paths, zoom, export, and thumbnail contracts.
3
+ Offline Apple `.pages/.numbers/.key` renderer for modern IWA and iWork '09 XML/APXL containers. Heavy parsing runs in a module Worker. Animations, transitions, and Numbers formula recalculation are not executed. Embedded Quick Look previews are loading/failure fallbacks and never count as fidelity evidence.
4
4
 
5
- ```bash
6
- pnpm add @file-viewer/core @file-viewer/renderer-iwork@0.0.1
7
- ```
8
-
9
- ```ts
10
- import iworkRenderer from '@file-viewer/renderer-iwork'
11
-
12
- const viewer = createFileViewer({
13
- container,
14
- options: { renderers: [iworkRenderer] },
15
- })
16
- ```
17
-
18
- Supports `.pages`, `.numbers`, and `.key`, while loading the standalone `iwork-viewer` Worker on demand. See [GitHub](https://github.com/flyfish-dev/iwork-viewer) for details.
5
+ `.pages`, `.numbers`, and `.key` meet the stable high-fidelity code gates. Real '09, 2013+, and current-version fixtures pass structural assertions, real-browser smoke, and fixed-font pixel-diff gates against Apple-native exports. Only the generic IWA fallback is labeled as a limited preview; npm, Release, and production-domain checks remain the authority for public release status.
package/README.md CHANGED
@@ -1,18 +1,5 @@
1
1
  # @file-viewer/renderer-iwork
2
2
 
3
- `iwork-viewer` File Viewer 薄适配包。解析与场景渲染由独立包提供;本包只连接格式注册、Worker 路径、缩放、导出和缩略图契约。
3
+ Apple `.pages/.numbers/.key` 离线 renderer。支持现代 IWA 容器和 iWork ’09 XML/APXL 容器检测与解析,所有重解析在 module Worker 中执行。动画、转场和 Numbers 公式重算不执行;内嵌 Quick Look 预览只用于加载或明确的失败降级,不计入高保真证据。
4
4
 
5
- ```bash
6
- pnpm add @file-viewer/core @file-viewer/renderer-iwork@0.0.1
7
- ```
8
-
9
- ```ts
10
- import iworkRenderer from '@file-viewer/renderer-iwork'
11
-
12
- const viewer = createFileViewer({
13
- container,
14
- options: { renderers: [iworkRenderer] },
15
- })
16
- ```
17
-
18
- 支持 `.pages`、`.numbers`、`.key`,并按需加载独立 `iwork-viewer` Worker。完整说明见 [GitHub](https://github.com/flyfish-dev/iwork-viewer)。
5
+ `.pages`、`.numbers`、`.key` 已达到 stable 高保真代码门禁:’09、2013+ 与当前版本真实 fixture 均通过结构断言、真实浏览器 smoke 和 Apple 原生导出的固定字体像素差门禁。只有 typed 场景解析失败并进入通用 IWA 兜底时才标记为有限预览;实际公开发布状态以 npm、Release 和生产域名验收为准。
@@ -0,0 +1,6 @@
1
+ # Third-party notices
2
+
3
+ - The IWA Snappy framing implementation follows the public Apple iWork notes and the Apache-2.0 SheetJS implementation. No Xberg runtime code is embedded.
4
+ - `keynote-archives` 2.0.1 supplies MIT-licensed generated Protobuf message definitions for typed Keynote and shared iWork object decoding. File Viewer applies its own bounded Snappy framing and tolerant archive parser around those definitions.
5
+ - `styled-exceljs` is used for the modern Numbers saved-value workbook path under its published license.
6
+ - `JSZip`, `pako`, and `@xmldom/xmldom` are loaded inside the on-demand iWork renderer/Worker chunk.
@@ -0,0 +1,4 @@
1
+ export declare class IworkContainerMismatchError extends Error {
2
+ readonly actualRendererId: string;
3
+ constructor(actualRendererId: string, message: string);
4
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,7 @@
1
+ export class IworkContainerMismatchError extends Error {
2
+ constructor(actualRendererId, message) {
3
+ super(message);
4
+ this.name = 'IworkContainerMismatchError';
5
+ this.actualRendererId = actualRendererId;
6
+ }
7
+ }
package/dist/index.d.ts CHANGED
@@ -2,4 +2,20 @@ import { type FileRenderHandler, type FileViewerRenderedInstance, type FileViewe
2
2
  export declare const pagesRendererDefinition: RendererDefinition, numbersRendererDefinition: RendererDefinition, keynoteRendererDefinition: RendererDefinition;
3
3
  export declare const renderFileViewerIwork: FileRenderHandler<FileViewerRenderedInstance, HTMLDivElement>;
4
4
  export declare const iworkRenderer: FileViewerRendererPlugin<FileRenderHandler<FileViewerRenderedInstance, HTMLDivElement>>;
5
+ export { IworkContainerMismatchError } from './errors.js';
6
+ export { DEFAULT_IWORK_PARSE_LIMITS } from './limits.js';
7
+ export declare const inspectIworkContainer: (...args: Parameters<typeof import("./parser.js")["inspectIworkContainer"]>) => Promise<{
8
+ zip: import("jszip");
9
+ generation: import("./model.js").IworkGeneration;
10
+ limits: {
11
+ maxUncompressedBytes: number;
12
+ maxCompressionRatio: number;
13
+ maxObjects: number;
14
+ maxImagePixels: number;
15
+ maxNestingDepth: number;
16
+ };
17
+ }>;
18
+ export declare const parseIworkDocument: (...args: Parameters<typeof import("./parser.js")["parseIworkDocument"]>) => Promise<import("./model.js").IworkDocument>;
19
+ export { decompressIwaFile } from './snappy.js';
20
+ export type { IworkDocument, IworkEmbeddedPreview, IworkGeneration, IworkKind, IworkParseLimits, IworkScene, IworkTable, IworkTextBlock, IworkVisualObject, } from './model.js';
5
21
  export default iworkRenderer;
package/dist/index.js CHANGED
@@ -1,79 +1,24 @@
1
- import { DEFAULT_RENDERER_DEFINITIONS, registerFileViewerZoomProvider, resolveFileViewerIworkWorkerUrl, unregisterFileViewerZoomProvider, } from '@file-viewer/core';
2
- import { renderIworkDocument, } from 'iwork-viewer';
1
+ import { DEFAULT_RENDERER_DEFINITIONS, } from '@file-viewer/core';
3
2
  const definitions = ['apple-pages', 'apple-numbers', 'apple-keynote'].map(id => DEFAULT_RENDERER_DEFINITIONS.find(definition => definition.id === id));
4
- if (definitions.some(definition => !definition)) {
5
- throw new Error('@file-viewer/renderer-iwork could not locate the shared Pages, Numbers, and Keynote definitions.');
6
- }
3
+ if (definitions.some(definition => !definition))
4
+ throw new Error('@file-viewer/renderer-iwork could not locate all shared iWork definitions.');
7
5
  export const [pagesRendererDefinition, numbersRendererDefinition, keynoteRendererDefinition] = definitions;
8
- const toStandaloneFitMode = (mode) => mode === 'auto' ? 'width' : mode;
9
- export const renderFileViewerIwork = async (buffer, target, type, context) => {
10
- var _a, _b, _c;
11
- const options = (_a = context === null || context === void 0 ? void 0 : context.options) === null || _a === void 0 ? void 0 : _a.iwork;
12
- const viewer = await renderIworkDocument(buffer, target, type, {
13
- ...options,
14
- workerUrl: resolveFileViewerIworkWorkerUrl(options, typeof document === 'undefined' ? undefined : document.baseURI),
15
- signal: context === null || context === void 0 ? void 0 : context.signal,
16
- });
17
- const fit = (request) => {
18
- const state = viewer.fit(toStandaloneFitMode(request.mode), {
19
- width: request.viewportWidth,
20
- height: request.viewportHeight,
21
- });
22
- return state
23
- ? {
24
- applied: true,
25
- mode: request.mode,
26
- resize: request.resize,
27
- scale: state.scale,
28
- source: request.source,
29
- provider: 'zoom',
30
- }
31
- : {
32
- applied: false,
33
- mode: request.mode,
34
- resize: request.resize,
35
- source: request.source,
36
- reason: 'unmeasurable',
37
- provider: 'zoom',
38
- };
39
- };
40
- registerFileViewerZoomProvider(target, {
41
- zoomIn: viewer.zoomIn,
42
- zoomOut: viewer.zoomOut,
43
- resetZoom: viewer.resetZoom,
44
- setZoom: viewer.setZoom,
45
- fit,
46
- getState: viewer.getZoomState,
47
- });
48
- (_b = context === null || context === void 0 ? void 0 : context.registerExportAdapter) === null || _b === void 0 ? void 0 : _b.call(context, {
49
- includeDocumentStyles: false,
50
- getPrintMaskPages: viewer.getPrintPages,
51
- printStyle: viewer.printStyle,
52
- toHtml: viewer.toHtml,
53
- });
54
- (_c = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _c === void 0 ? void 0 : _c.call(context, {
55
- captureSource: viewer.captureSource,
56
- capture: viewer.captureSource === 'embedded' ? viewer.captureEmbeddedPreview : undefined,
57
- getTarget: viewer.getThumbnailTarget,
58
- });
59
- return {
60
- $el: target,
61
- unmount() {
62
- var _a, _b;
63
- unregisterFileViewerZoomProvider(target);
64
- (_a = context === null || context === void 0 ? void 0 : context.registerExportAdapter) === null || _a === void 0 ? void 0 : _a.call(context, null);
65
- (_b = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _b === void 0 ? void 0 : _b.call(context, null);
66
- viewer.destroy();
67
- },
68
- };
69
- };
6
+ export const renderFileViewerIwork = (buffer, target, type, context) => import('./iwork.js').then(({ default: renderIwork }) => renderIwork(buffer, target, type, context));
70
7
  export const iworkRenderer = {
71
8
  id: 'file-viewer-renderer-iwork',
72
- label: 'File Viewer Apple iWork renderer',
9
+ label: 'Flyfish File Viewer Apple iWork renderer',
73
10
  definitions: definitions,
74
- handlers: definitions.map(definition => ({
75
- rendererId: definition.id,
76
- handler: renderFileViewerIwork,
77
- })),
11
+ handlers: definitions.map(definition => ({ rendererId: definition.id, handler: renderFileViewerIwork })),
12
+ };
13
+ export { IworkContainerMismatchError } from './errors.js';
14
+ export { DEFAULT_IWORK_PARSE_LIMITS } from './limits.js';
15
+ export const inspectIworkContainer = async (...args) => {
16
+ const parser = await import('./iwork.parser.js');
17
+ return parser.inspectIworkContainer(...args);
18
+ };
19
+ export const parseIworkDocument = async (...args) => {
20
+ const parser = await import('./iwork.parser.js');
21
+ return parser.parseIworkDocument(...args);
78
22
  };
23
+ export { decompressIwaFile } from './snappy.js';
79
24
  export default iworkRenderer;
@@ -0,0 +1,2 @@
1
+ import { type FileRenderContext, type FileViewerRenderedInstance } from '@file-viewer/core';
2
+ export default function renderIwork(buffer: ArrayBuffer, target: HTMLDivElement, type?: string, context?: FileRenderContext): Promise<FileViewerRenderedInstance>;