@file-viewer/renderer-iwork 0.0.2 → 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.
@@ -0,0 +1,2 @@
1
+ import type { IworkParseLimits } from './model.js';
2
+ export declare const DEFAULT_IWORK_PARSE_LIMITS: IworkParseLimits;
package/dist/limits.js ADDED
@@ -0,0 +1,7 @@
1
+ export const DEFAULT_IWORK_PARSE_LIMITS = {
2
+ maxUncompressedBytes: 256 * 1024 * 1024,
3
+ maxCompressionRatio: 200,
4
+ maxObjects: 250000,
5
+ maxImagePixels: 80000000,
6
+ maxNestingDepth: 128,
7
+ };
@@ -0,0 +1,122 @@
1
+ export type IworkKind = 'pages' | 'numbers' | 'keynote';
2
+ export type IworkGeneration = 'iwork-09' | 'iwork-2013-plus';
3
+ export interface IworkTextBlock {
4
+ id: string;
5
+ text: string;
6
+ zIndex?: number;
7
+ x: number;
8
+ y: number;
9
+ width: number;
10
+ height: number;
11
+ fontSize?: number;
12
+ fontFamily?: string;
13
+ color?: string;
14
+ bold?: boolean;
15
+ italic?: boolean;
16
+ align?: 'left' | 'center' | 'right';
17
+ verticalAlign?: 'top' | 'middle' | 'bottom';
18
+ letterSpacing?: number;
19
+ lineHeight?: number;
20
+ padding?: {
21
+ top: number;
22
+ right: number;
23
+ bottom: number;
24
+ left: number;
25
+ };
26
+ paragraphs?: IworkTextParagraph[];
27
+ }
28
+ export interface IworkTextRun {
29
+ text: string;
30
+ color?: string;
31
+ bold?: boolean;
32
+ italic?: boolean;
33
+ }
34
+ export interface IworkTextParagraph {
35
+ runs: IworkTextRun[];
36
+ bullet?: boolean;
37
+ color?: string;
38
+ bold?: boolean;
39
+ italic?: boolean;
40
+ spaceBefore?: number;
41
+ spaceAfter?: number;
42
+ }
43
+ export interface IworkTable {
44
+ id: string;
45
+ zIndex?: number;
46
+ x: number;
47
+ y: number;
48
+ width?: number;
49
+ height?: number;
50
+ rows: string[][];
51
+ columnWidths?: number[];
52
+ rowHeights?: number[];
53
+ merges?: Array<{
54
+ row: number;
55
+ col: number;
56
+ rowspan: number;
57
+ colspan: number;
58
+ }>;
59
+ headerRows?: number;
60
+ headerColumns?: number;
61
+ fontSize?: number;
62
+ fontFamily?: string;
63
+ headerRowBackground?: string;
64
+ headerColumnBackground?: string;
65
+ borderColor?: string;
66
+ }
67
+ export interface IworkChartSeries {
68
+ name: string;
69
+ values: number[];
70
+ }
71
+ export interface IworkChartData {
72
+ type: 'bar' | 'line';
73
+ categories: string[];
74
+ series: IworkChartSeries[];
75
+ }
76
+ export interface IworkVisualObject {
77
+ id: string;
78
+ kind: 'shape' | 'image' | 'chart' | 'table' | 'media';
79
+ zIndex?: number;
80
+ x: number;
81
+ y: number;
82
+ width: number;
83
+ height: number;
84
+ angle?: number;
85
+ text?: string;
86
+ mimeType?: string;
87
+ bytes?: Uint8Array;
88
+ chart?: IworkChartData;
89
+ }
90
+ export interface IworkScene {
91
+ id: string;
92
+ name: string;
93
+ width: number;
94
+ height: number;
95
+ blocks: IworkTextBlock[];
96
+ tables: IworkTable[];
97
+ objects: IworkVisualObject[];
98
+ notes: string[];
99
+ }
100
+ export interface IworkEmbeddedPreview {
101
+ name: string;
102
+ mimeType: string;
103
+ bytes: Uint8Array;
104
+ }
105
+ export interface IworkDocument {
106
+ kind: IworkKind;
107
+ generation: IworkGeneration;
108
+ title: string;
109
+ scenes: IworkScene[];
110
+ preview?: IworkEmbeddedPreview;
111
+ diagnostics: string[];
112
+ limits: string[];
113
+ objectCount: number;
114
+ limitedPreview: boolean;
115
+ }
116
+ export interface IworkParseLimits {
117
+ maxUncompressedBytes: number;
118
+ maxCompressionRatio: number;
119
+ maxObjects: number;
120
+ maxImagePixels: number;
121
+ maxNestingDepth: number;
122
+ }
package/dist/model.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/parser.d.ts CHANGED
@@ -1,2 +1,17 @@
1
- export { DEFAULT_IWORK_PARSE_LIMITS, IworkContainerMismatchError, decompressIwaFile, inspectIworkContainer, parseIworkDocument, } from 'iwork-viewer';
2
- export type { IworkDocument, IworkEmbeddedPreview, IworkGeneration, IworkKind, IworkParseLimits, IworkScene, IworkTable, IworkTextBlock, IworkVisualObject, } from 'iwork-viewer';
1
+ import JSZip from 'jszip';
2
+ import type { IworkDocument, IworkGeneration, IworkParseLimits } from './model.js';
3
+ export { IworkContainerMismatchError } from './errors.js';
4
+ export { DEFAULT_IWORK_PARSE_LIMITS } from './limits.js';
5
+ type XmlParserFactory = () => Pick<DOMParser, 'parseFromString'>;
6
+ export declare const inspectIworkContainer: (buffer: ArrayBuffer, limits?: Partial<IworkParseLimits>) => Promise<{
7
+ zip: JSZip;
8
+ generation: IworkGeneration;
9
+ limits: {
10
+ maxUncompressedBytes: number;
11
+ maxCompressionRatio: number;
12
+ maxObjects: number;
13
+ maxImagePixels: number;
14
+ maxNestingDepth: number;
15
+ };
16
+ }>;
17
+ export declare const parseIworkDocument: (buffer: ArrayBuffer, type?: string, limits?: Partial<IworkParseLimits>, createParser?: XmlParserFactory) => Promise<IworkDocument>;