@file-viewer/renderer-iwork 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.
Files changed (2) hide show
  1. package/dist/parser.js +21 -0
  2. package/package.json +2 -2
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.3.0",
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.",
@@ -82,7 +82,7 @@
82
82
  "THIRD_PARTY_NOTICES.md"
83
83
  ],
84
84
  "dependencies": {
85
- "@file-viewer/core": "3.3.0",
85
+ "@file-viewer/core": "3.3.1",
86
86
  "@xmldom/xmldom": "^0.9.12",
87
87
  "jszip": "3.10.2",
88
88
  "keynote-archives": "2.0.1",