@file-viewer/renderer-iwork 3.2.2 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @file-viewer/renderer-iwork
2
2
 
3
+ [English](https://github.com/flyfish-dev/file-viewer/blob/main/packages/renderers/iwork/README.md) · [简体中文](https://github.com/flyfish-dev/file-viewer/blob/main/packages/renderers/iwork/README.zh-CN.md)
4
+
3
5
  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
6
 
5
7
  `.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,5 +1,7 @@
1
1
  # @file-viewer/renderer-iwork
2
2
 
3
- Apple `.pages/.numbers/.key` 离线 renderer。支持现代 IWA 容器和 iWork ’09 XML/APXL 容器检测与解析,所有重解析在 module Worker 中执行。动画、转场和 Numbers 公式重算不执行;内嵌 Quick Look 预览只用于加载或明确的失败降级,不计入高保真证据。
3
+ [English](https://github.com/flyfish-dev/file-viewer/blob/main/packages/renderers/iwork/README.md) · [简体中文](https://github.com/flyfish-dev/file-viewer/blob/main/packages/renderers/iwork/README.zh-CN.md)
4
4
 
5
- `.pages`、`.numbers`、`.key` 已达到 stable 高保真代码门禁:’09、2013+ 与当前版本真实 fixture 均通过结构断言、真实浏览器 smoke 和 Apple 原生导出的固定字体像素差门禁。只有 typed 场景解析失败并进入通用 IWA 兜底时才标记为有限预览;实际公开发布状态以 npm、Release 和生产域名验收为准。
5
+ 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.
6
+
7
+ `.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.
@@ -0,0 +1,7 @@
1
+ # @file-viewer/renderer-iwork
2
+
3
+ [English](https://github.com/flyfish-dev/file-viewer/blob/main/packages/renderers/iwork/README.md) · [简体中文](https://github.com/flyfish-dev/file-viewer/blob/main/packages/renderers/iwork/README.zh-CN.md)
4
+
5
+ Apple `.pages/.numbers/.key` 离线 renderer。支持现代 IWA 容器和 iWork ’09 XML/APXL 容器检测与解析,所有重解析在 module Worker 中执行。动画、转场和 Numbers 公式重算不执行;内嵌 Quick Look 预览只用于加载或明确的失败降级,不计入高保真证据。
6
+
7
+ `.pages`、`.numbers`、`.key` 已达到 stable 高保真代码门禁:’09、2013+ 与当前版本真实 fixture 均通过结构断言、真实浏览器 smoke 和 Apple 原生导出的固定字体像素差门禁。只有 typed 场景解析失败并进入通用 IWA 兜底时才标记为有限预览;实际公开发布状态以 npm、Release 和生产域名验收为准。
package/dist/parser.js CHANGED
@@ -6,6 +6,10 @@ import * as keynoteArchivesNamespace from 'keynote-archives';
6
6
  import { IworkContainerMismatchError } from './errors.js';
7
7
  import { DEFAULT_IWORK_PARSE_LIMITS } from './limits.js';
8
8
  import { decompressIwaFile } from './snappy.js';
9
+ // keynote-archives 2.x publishes CommonJS only. A named ESM import happens to
10
+ // work in the workspace build, but fails when a cold Vite project consumes the
11
+ // published renderer. Resolve the CommonJS namespace once and keep the parser
12
+ // independent of the bundler's named-export interop policy.
9
13
  const keynoteArchivesModule = ('default' in keynoteArchivesNamespace && keynoteArchivesNamespace.default
10
14
  ? keynoteArchivesNamespace.default
11
15
  : keynoteArchivesNamespace);
@@ -429,6 +433,11 @@ const legacySceneDimensions = (root, kind, tables) => {
429
433
  const legacyPagesValues = (scene, root) => {
430
434
  if (scene !== root)
431
435
  return legacyText(scene);
436
+ // Pages '09 embeds complete section prototypes in the document root. Those
437
+ // prototypes are editing templates, not visible document content. Reading
438
+ // every <p> from the root made an empty Apple document render pages of
439
+ // overlapping template text. Only the body storage outside a prototype is
440
+ // the document's live word-processing flow.
432
441
  return descendants(root, ['text-storage'])
433
442
  .filter(storage => attribute(storage, 'sf:kind', 'kind') === 'body')
434
443
  .filter(storage => !hasAncestor(storage, ['prototype'], root))
@@ -462,6 +471,9 @@ const parseLegacy = async (zip, kind, limits, createParser) => {
462
471
  throw new Error('iWork scene count exceeds the configured safety limit.');
463
472
  const scenes = sceneElements.map((scene, index) => {
464
473
  var _a;
474
+ // Numbers workspaces contain implementation layer names such as
475
+ // LSWorkspaceCommentLayer. They are not document text and must not leak
476
+ // into search or export. Cell text is represented by the table model.
465
477
  const values = kind === 'numbers' ? [] : kind === 'pages' ? legacyPagesValues(scene, root) : legacyText(scene);
466
478
  const notes = kind === 'keynote' ? descendants(scene, ['notes', 'speaker-notes']).map(nodeText).filter(Boolean) : [];
467
479
  const tables = legacyTables(scene, limits).map(table => {
@@ -470,6 +482,10 @@ const parseLegacy = async (zip, kind, limits, createParser) => {
470
482
  ...table,
471
483
  x: table.x + 71,
472
484
  y: table.y + 71,
485
+ // Numbers '09 stores the usable row content height. Apple includes the
486
+ // half-point grid stroke for every rendered row when calculating the
487
+ // table frame. Preserve that distinction so dense legacy sheets do not
488
+ // progressively drift vertically from the native export.
473
489
  height: table.height == null ? table.height : table.height + table.rows.length * 0.5,
474
490
  rowHeights: (_a = table.rowHeights) === null || _a === void 0 ? void 0 : _a.map(height => height + 0.5),
475
491
  headerRows: Math.min(1, table.rows.length),
@@ -787,6 +803,9 @@ const resolveTextStyle = (objects, id, visited = new Set()) => {
787
803
  ...(typeof character.bold === 'boolean' ? { bold: character.bold } : {}),
788
804
  ...(typeof character.italic === 'boolean' ? { italic: character.italic } : {}),
789
805
  ...(Number.isFinite(character.tracking) ? { letterSpacing: Number(character.tracking) } : {}),
806
+ // Apple stores proportional line spacing relative to its font metrics.
807
+ // CSS line-height uses the full em box, which is about 0.2 larger for the
808
+ // Helvetica Neue metrics used by current Keynote documents.
790
809
  ...(Number.isFinite(lineHeight) && lineHeight > 0 ? { lineHeight: lineHeight < 1 ? lineHeight + 0.2 : lineHeight } : {}),
791
810
  ...(Number.isFinite(paragraph.alignment) ? { align: paragraphAlignment(paragraph.alignment) } : {}),
792
811
  };
@@ -985,6 +1004,8 @@ const decodeKeynoteFrame = (frame) => {
985
1004
  messages.push({ info: { type: Number(info.type) }, data: messageType.fromBinary(payload) });
986
1005
  }
987
1006
  catch {
1007
+ // Newer Keynote releases can add fields or message variants. Other typed
1008
+ // messages in the same frame remain useful, so isolate this one payload.
988
1009
  }
989
1010
  }
990
1011
  objects.push({ identifier: archive.identifier, messages });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@file-viewer/renderer-iwork",
3
- "version": "3.2.2",
3
+ "version": "3.3.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Offline Apple Pages, Numbers and Keynote renderer for modern IWA and iWork '09 containers.",
@@ -78,10 +78,11 @@
78
78
  "LICENSE",
79
79
  "README.en.md",
80
80
  "README.md",
81
+ "README.zh-CN.md",
81
82
  "THIRD_PARTY_NOTICES.md"
82
83
  ],
83
84
  "dependencies": {
84
- "@file-viewer/core": "3.2.2",
85
+ "@file-viewer/core": "3.3.1",
85
86
  "@xmldom/xmldom": "^0.9.12",
86
87
  "jszip": "3.10.2",
87
88
  "keynote-archives": "2.0.1",