@p10node/office-engine 0.0.0 → 0.1.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 (124) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -1
  3. package/dist/DocViewer-kfAVEXOO.js +10533 -0
  4. package/dist/DocViewer-kfAVEXOO.js.map +1 -0
  5. package/dist/THIRD_PARTY_LICENSES.txt +79 -0
  6. package/dist/assets/worker-DbLPJnSo.js.map +1 -0
  7. package/dist/collab-BzN1ZI-z.js +1984 -0
  8. package/dist/collab-BzN1ZI-z.js.map +1 -0
  9. package/dist/collab.js +2 -0
  10. package/dist/core.js +2 -0
  11. package/dist/default-worker-f546VALp.js +9196 -0
  12. package/dist/default-worker-f546VALp.js.map +1 -0
  13. package/dist/embed.js +91 -0
  14. package/dist/embed.js.map +1 -0
  15. package/dist/index.js +5 -0
  16. package/dist/office-engine.embed.js +81 -0
  17. package/dist/office-engine.worker.js +9092 -0
  18. package/dist/types/collab/codec.d.ts +3 -0
  19. package/dist/types/collab/docx.d.ts +166 -0
  20. package/dist/types/collab/hosts.d.ts +24 -0
  21. package/dist/types/collab/hub.d.ts +41 -0
  22. package/dist/types/collab/index.d.ts +43 -0
  23. package/dist/types/collab/pptx-ops.d.ts +60 -0
  24. package/dist/types/collab/pptx-worker.d.ts +35 -0
  25. package/dist/types/collab/pptx.d.ts +47 -0
  26. package/dist/types/collab/protocol.d.ts +76 -0
  27. package/dist/types/collab/react.d.ts +23 -0
  28. package/dist/types/collab/session.d.ts +115 -0
  29. package/dist/types/collab/transport.d.ts +47 -0
  30. package/dist/types/collab/xlsx-ops.d.ts +72 -0
  31. package/dist/types/collab/xlsx-worker.d.ts +29 -0
  32. package/dist/types/collab/xlsx.d.ts +51 -0
  33. package/dist/types/core/color.d.ts +25 -0
  34. package/dist/types/core/convert.d.ts +29 -0
  35. package/dist/types/core/default-worker.d.ts +1 -0
  36. package/dist/types/core/docx/numbering.d.ts +33 -0
  37. package/dist/types/core/docx/parser.d.ts +126 -0
  38. package/dist/types/core/docx/spec.d.ts +4 -0
  39. package/dist/types/core/docx/styles.d.ts +63 -0
  40. package/dist/types/core/docx/types.d.ts +325 -0
  41. package/dist/types/core/docx/writer.d.ts +35 -0
  42. package/dist/types/core/fonts.d.ts +1 -0
  43. package/dist/types/core/index.d.ts +15 -0
  44. package/dist/types/core/opc.d.ts +56 -0
  45. package/dist/types/core/pptx/edit.d.ts +10 -0
  46. package/dist/types/core/pptx/parser.d.ts +52 -0
  47. package/dist/types/core/pptx/types.d.ts +238 -0
  48. package/dist/types/core/raw.d.ts +40 -0
  49. package/dist/types/core/source.d.ts +65 -0
  50. package/dist/types/core/theme.d.ts +11 -0
  51. package/dist/types/core/units.d.ts +7 -0
  52. package/dist/types/core/worker/client.d.ts +48 -0
  53. package/dist/types/core/worker/engine.d.ts +27 -0
  54. package/dist/types/core/worker/protocol.d.ts +112 -0
  55. package/dist/types/core/worker/worker.d.ts +1 -0
  56. package/dist/types/core/xlsx/calc.d.ts +31 -0
  57. package/dist/types/core/xlsx/editor.d.ts +95 -0
  58. package/dist/types/core/xlsx/formula/assist.d.ts +35 -0
  59. package/dist/types/core/xlsx/formula/catalog.d.ts +14 -0
  60. package/dist/types/core/xlsx/formula/dates.d.ts +23 -0
  61. package/dist/types/core/xlsx/formula/evaluate.d.ts +33 -0
  62. package/dist/types/core/xlsx/formula/fn-date.d.ts +2 -0
  63. package/dist/types/core/xlsx/formula/fn-logic.d.ts +3 -0
  64. package/dist/types/core/xlsx/formula/fn-lookup.d.ts +3 -0
  65. package/dist/types/core/xlsx/formula/fn-math.d.ts +3 -0
  66. package/dist/types/core/xlsx/formula/fn-stats.d.ts +3 -0
  67. package/dist/types/core/xlsx/formula/fn-text.d.ts +3 -0
  68. package/dist/types/core/xlsx/formula/fn.d.ts +64 -0
  69. package/dist/types/core/xlsx/formula/format.d.ts +5 -0
  70. package/dist/types/core/xlsx/formula/functions.d.ts +4 -0
  71. package/dist/types/core/xlsx/formula/index.d.ts +17 -0
  72. package/dist/types/core/xlsx/formula/lexer.d.ts +54 -0
  73. package/dist/types/core/xlsx/formula/parser.d.ts +53 -0
  74. package/dist/types/core/xlsx/formula/refs.d.ts +23 -0
  75. package/dist/types/core/xlsx/formula/transform.d.ts +21 -0
  76. package/dist/types/core/xlsx/formula/types.d.ts +59 -0
  77. package/dist/types/core/xlsx/formula/values.d.ts +49 -0
  78. package/dist/types/core/xlsx/numfmt.d.ts +11 -0
  79. package/dist/types/core/xlsx/structure.d.ts +31 -0
  80. package/dist/types/core/xlsx/styles.d.ts +17 -0
  81. package/dist/types/core/xlsx/types.d.ts +193 -0
  82. package/dist/types/core/xlsx/workbook.d.ts +94 -0
  83. package/dist/types/core/xml.d.ts +80 -0
  84. package/dist/types/core/zip.d.ts +35 -0
  85. package/dist/types/core/zipwrite.d.ts +11 -0
  86. package/dist/types/embed.d.ts +30 -0
  87. package/dist/types/index.d.ts +19 -0
  88. package/dist/types/react/DocViewer.d.ts +61 -0
  89. package/dist/types/react/common/ContextMenu.d.ts +21 -0
  90. package/dist/types/react/common/Dialog.d.ts +35 -0
  91. package/dist/types/react/common/Slots.d.ts +38 -0
  92. package/dist/types/react/common/Status.d.ts +6 -0
  93. package/dist/types/react/common/ZoomControl.d.ts +6 -0
  94. package/dist/types/react/common/hooks.d.ts +20 -0
  95. package/dist/types/react/docx/DocxEditor.d.ts +172 -0
  96. package/dist/types/react/docx/DocxToolbar.d.ts +19 -0
  97. package/dist/types/react/docx/DocxView.d.ts +8 -0
  98. package/dist/types/react/docx/FindBar.d.ts +22 -0
  99. package/dist/types/react/docx/html.d.ts +8 -0
  100. package/dist/types/react/docx/render.d.ts +24 -0
  101. package/dist/types/react/docx/tables.d.ts +20 -0
  102. package/dist/types/react/edit/Toolbar.d.ts +134 -0
  103. package/dist/types/react/edit/input.d.ts +81 -0
  104. package/dist/types/react/edit/rich.d.ts +40 -0
  105. package/dist/types/react/file/DetailsDialog.d.ts +7 -0
  106. package/dist/types/react/file/FileMenu.d.ts +48 -0
  107. package/dist/types/react/file/importFile.d.ts +10 -0
  108. package/dist/types/react/file/print.d.ts +16 -0
  109. package/dist/types/react/file/text.d.ts +10 -0
  110. package/dist/types/react/injectStyles.d.ts +4 -0
  111. package/dist/types/react/pptx/PptxEditor.d.ts +95 -0
  112. package/dist/types/react/pptx/PptxToolbar.d.ts +36 -0
  113. package/dist/types/react/pptx/PptxView.d.ts +24 -0
  114. package/dist/types/react/pptx/Presenter.d.ts +9 -0
  115. package/dist/types/react/pptx/Slide.d.ts +28 -0
  116. package/dist/types/react/pptx/geometry.d.ts +5 -0
  117. package/dist/types/react/useDocument.d.ts +11 -0
  118. package/dist/types/react/xlsx/XlsxToolbar.d.ts +27 -0
  119. package/dist/types/react/xlsx/XlsxView.d.ts +18 -0
  120. package/dist/types/react/xlsx/axis.d.ts +19 -0
  121. package/dist/types/react/xlsx/print.d.ts +17 -0
  122. package/dist/xlsx-ops-CsjNpMI0.js +244 -0
  123. package/dist/xlsx-ops-CsjNpMI0.js.map +1 -0
  124. package/package.json +75 -2
@@ -0,0 +1,325 @@
1
+ /** All lengths in points unless stated otherwise. */
2
+ export interface RunStyle {
3
+ b?: boolean;
4
+ i?: boolean;
5
+ /** underline kind ('single', 'double', …) or 'none' */
6
+ u?: string;
7
+ strike?: boolean;
8
+ dstrike?: boolean;
9
+ color?: string;
10
+ sz?: number;
11
+ font?: string;
12
+ hl?: string;
13
+ shd?: string;
14
+ va?: 'sup' | 'sub';
15
+ caps?: boolean;
16
+ smallCaps?: boolean;
17
+ vanish?: boolean;
18
+ spacing?: number;
19
+ }
20
+ export interface Border {
21
+ w: number;
22
+ style: string;
23
+ color: string;
24
+ }
25
+ export interface ParaStyle {
26
+ align?: 'left' | 'center' | 'right' | 'justify';
27
+ indL?: number;
28
+ indR?: number;
29
+ /** positive: first line indent; negative: hanging */
30
+ indFirst?: number;
31
+ before?: number;
32
+ after?: number;
33
+ line?: number;
34
+ lineRule?: 'auto' | 'exact' | 'atLeast';
35
+ shd?: string;
36
+ bTop?: Border;
37
+ bBottom?: Border;
38
+ bLeft?: Border;
39
+ bRight?: Border;
40
+ keepNext?: boolean;
41
+ pageBreakBefore?: boolean;
42
+ outline?: number;
43
+ contextual?: boolean;
44
+ }
45
+ /** [paragraph id, run ordinal] of the source run in the original XML */
46
+ export type SrcRef = [number, number];
47
+ /** Direct formatting changed by the user (written back as explicit run properties). */
48
+ export interface RunSet {
49
+ b?: boolean;
50
+ i?: boolean;
51
+ u?: string;
52
+ strike?: boolean;
53
+ color?: string | null;
54
+ sz?: number;
55
+ /** raw font name */
56
+ font?: string;
57
+ hl?: string | null;
58
+ va?: 'sup' | 'sub' | null;
59
+ }
60
+ /**
61
+ * Inline content. Tabs and line breaks are carried as '\t' / '\n' inside text.
62
+ * Everything that isn't 'text' counts as one character when editing.
63
+ */
64
+ export type Inline = {
65
+ t: 'text';
66
+ text: string;
67
+ s: RunStyle;
68
+ href?: string;
69
+ lk?: string;
70
+ src?: SrcRef;
71
+ d?: RunSet;
72
+ } | {
73
+ t: 'img';
74
+ target: string;
75
+ w: number;
76
+ h: number;
77
+ alt?: string;
78
+ href?: string;
79
+ src?: SrcRef;
80
+ rid?: string;
81
+ resized?: boolean;
82
+ /** alt text changed by the user */
83
+ altSet?: boolean;
84
+ /** picture replaced (rid points to the new image part) */
85
+ repl?: boolean;
86
+ } | {
87
+ t: 'field';
88
+ kind: 'PAGE' | 'NUMPAGES';
89
+ s: RunStyle;
90
+ src?: SrcRef;
91
+ } | {
92
+ t: 'box';
93
+ w: number;
94
+ h: number;
95
+ blocks: Block[];
96
+ fill?: string;
97
+ border?: string;
98
+ src?: SrcRef;
99
+ } | {
100
+ t: 'shape';
101
+ w: number;
102
+ h: number;
103
+ label?: string;
104
+ src?: SrcRef;
105
+ } | {
106
+ t: 'ref';
107
+ text: string;
108
+ s: RunStyle;
109
+ src?: SrcRef;
110
+ };
111
+ export interface ListMarker {
112
+ text: string;
113
+ s: RunStyle;
114
+ /** marker followed by tab (default) */
115
+ tab: boolean;
116
+ }
117
+ export interface Paragraph {
118
+ t: 'p';
119
+ ps: ParaStyle;
120
+ runs: Inline[];
121
+ marker?: ListMarker;
122
+ /** font size of the paragraph mark, for empty paragraph height */
123
+ markSz?: number;
124
+ markFont?: string;
125
+ /** explicit page break before this paragraph (from w:br type=page or pageBreakBefore) */
126
+ pb?: boolean;
127
+ /** paragraph id (editable paragraphs only); split parts share it */
128
+ pid?: number;
129
+ /** read-only (inside fields spanning paragraphs, text boxes, nested tables…) */
130
+ ro?: boolean;
131
+ /** paragraph style id */
132
+ sid?: string;
133
+ /** list kind + level when numbered */
134
+ lst?: 'bullet' | 'number';
135
+ ilvl?: number;
136
+ /** template paragraph (original pid) */
137
+ from?: number;
138
+ /** original paragraphs whose bookmarks/comments this one carries */
139
+ orig?: number[];
140
+ /** paragraph-level changes */
141
+ pd?: ParaDirty;
142
+ /** changed since load */
143
+ edited?: boolean;
144
+ /** keeps the template's section break */
145
+ keepSect?: boolean;
146
+ /** render version (bumped to force DOM rebuild after IME composition) */
147
+ ver?: number;
148
+ /** formatting for text typed into this (empty) paragraph */
149
+ caret?: Inline;
150
+ }
151
+ export interface ParaDirty {
152
+ style?: string;
153
+ align?: 'left' | 'center' | 'right' | 'justify';
154
+ list?: 'bullet' | 'number' | 'none';
155
+ ilvl?: number;
156
+ indL?: number;
157
+ /** line spacing multiple (1, 1.15, 1.5, 2…) */
158
+ line?: number;
159
+ /** spacing before / after in pt */
160
+ before?: number;
161
+ after?: number;
162
+ pageBreak?: boolean;
163
+ }
164
+ export type SpecRun = {
165
+ text: string;
166
+ src?: SrcRef;
167
+ set?: RunSet;
168
+ lk?: string;
169
+ } | {
170
+ obj: 'copy';
171
+ src: SrcRef;
172
+ size?: [number, number];
173
+ alt?: string;
174
+ rid?: string;
175
+ } | {
176
+ obj: 'image';
177
+ rid: string;
178
+ w: number;
179
+ h: number;
180
+ name?: string;
181
+ alt?: string;
182
+ } | {
183
+ obj: 'field';
184
+ kind: 'PAGE' | 'NUMPAGES';
185
+ set?: RunSet;
186
+ };
187
+ export interface ParaSpec {
188
+ pid: number;
189
+ from: number;
190
+ orig?: number[];
191
+ pd?: ParaDirty;
192
+ /** page-break separated parts */
193
+ parts: SpecRun[][];
194
+ pristine?: boolean;
195
+ keepSect?: boolean;
196
+ }
197
+ export interface CellSpec {
198
+ src?: [number, number];
199
+ colSpan: number;
200
+ rowSpan: number;
201
+ paras: ParaSpec[];
202
+ shd?: string;
203
+ }
204
+ export interface TableSpec {
205
+ tid: number;
206
+ item?: number;
207
+ cols: number[];
208
+ rows: {
209
+ src?: number;
210
+ cells: CellSpec[];
211
+ }[];
212
+ }
213
+ export interface TableOp {
214
+ tid: number;
215
+ item?: number;
216
+ /** paragraph the (new) table follows */
217
+ anchor?: number;
218
+ /** null deletes the table */
219
+ spec: TableSpec | null;
220
+ }
221
+ export interface EditOp {
222
+ anchor: number;
223
+ list: ParaSpec[];
224
+ remove?: number[];
225
+ /** return re-converted blocks (needed after style/list changes) */
226
+ want?: boolean;
227
+ }
228
+ export interface EditResult {
229
+ blocks: Record<number, Block[]>;
230
+ markers: Record<number, {
231
+ text: string;
232
+ s: RunStyle;
233
+ tab: boolean;
234
+ lst?: 'bullet' | 'number';
235
+ } | null>;
236
+ }
237
+ /** built-in paragraph styles the picker always offers (created on first use when missing) */
238
+ export type CanonStyle = 'normal' | 'title' | 'subtitle' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
239
+ export interface StyleInfo {
240
+ id: string;
241
+ name: string;
242
+ next?: string;
243
+ canon?: CanonStyle;
244
+ /** heading level 0-8 (outline) */
245
+ outline?: number;
246
+ /** run look of the style, for the style picker */
247
+ preview?: {
248
+ b?: boolean;
249
+ i?: boolean;
250
+ color?: string;
251
+ sz?: number;
252
+ font?: string;
253
+ };
254
+ }
255
+ export interface CellBorders {
256
+ t?: string;
257
+ r?: string;
258
+ b?: string;
259
+ l?: string;
260
+ }
261
+ export interface TableCell {
262
+ blocks: Block[];
263
+ /** [row, tc] index in the original table XML (template for cell properties) */
264
+ src?: [number, number];
265
+ colSpan: number;
266
+ rowSpan: number;
267
+ w?: number;
268
+ shd?: string;
269
+ vAlign?: 'top' | 'middle' | 'bottom';
270
+ borders: CellBorders;
271
+ pad: [number, number, number, number];
272
+ }
273
+ export interface TableRow {
274
+ cells: TableCell[];
275
+ /** original row index */
276
+ src?: number;
277
+ h?: number;
278
+ exact?: boolean;
279
+ header?: boolean;
280
+ }
281
+ export interface Table {
282
+ t: 'tbl';
283
+ /** body item index of an original top-level table */
284
+ item?: number;
285
+ /** set once the table is regenerated by the editor (new or structurally changed) */
286
+ tid?: number;
287
+ cols: number[];
288
+ rows: TableRow[];
289
+ align?: 'left' | 'center' | 'right';
290
+ indL?: number;
291
+ w?: number;
292
+ }
293
+ export interface PageSetup {
294
+ w: number;
295
+ h: number;
296
+ mt: number;
297
+ mr: number;
298
+ mb: number;
299
+ ml: number;
300
+ header: number;
301
+ footer: number;
302
+ }
303
+ export interface SectionBreak {
304
+ t: 'sect';
305
+ page: PageSetup;
306
+ /** 'nextPage' | 'continuous' | 'evenPage' | 'oddPage' */
307
+ kind: string;
308
+ }
309
+ export type Block = Paragraph | Table | SectionBreak;
310
+ export interface DocxMeta {
311
+ page: PageSetup;
312
+ /** quick paragraph styles for the style picker */
313
+ styles?: StyleInfo[];
314
+ header?: Block[];
315
+ footer?: Block[];
316
+ firstHeader?: Block[];
317
+ firstFooter?: Block[];
318
+ titlePg?: boolean;
319
+ /** body default font (CSS) and size */
320
+ font?: string;
321
+ sz?: number;
322
+ /** final page setup known (end of document reached) */
323
+ final?: boolean;
324
+ }
325
+ export declare const DEFAULT_PAGE: PageSetup;
@@ -0,0 +1,35 @@
1
+ import { type RChild, type RNode } from '../raw';
2
+ import type { DocxDocument, GenRun } from './parser';
3
+ import type { CanonStyle, EditOp, EditResult, ParaSpec, StyleInfo, TableOp, TableSpec } from './types';
4
+ export declare const DOCX_MIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
5
+ interface ParaLoc {
6
+ node: RNode;
7
+ list: RChild[];
8
+ index: number;
9
+ }
10
+ /** Paragraphs of a body item in the same preorder the converter uses. */
11
+ export declare function collectParasRaw(nodes: RChild[]): ParaLoc[];
12
+ export declare function collectRunsRaw(p: RNode): RNode[];
13
+ export declare function origPara(doc: DocxDocument, pid: number): RNode | undefined;
14
+ /** Id of a built-in paragraph style (Title, Heading 1…), added to styles.xml when the document lacks it. */
15
+ export declare function ensureStyle(doc: DocxDocument, kind: CanonStyle): Promise<{
16
+ id: string;
17
+ styles: StyleInfo[];
18
+ }>;
19
+ export declare function genParagraph(doc: DocxDocument, spec: ParaSpec): Promise<{
20
+ xml: string;
21
+ map: GenRun[];
22
+ }>;
23
+ export declare function applyEdit(doc: DocxDocument, op: EditOp): Promise<EditResult>;
24
+ /** Adds an image part to the document; returns its relationship id and part path. */
25
+ export declare function addImage(doc: DocxDocument, bytes: Uint8Array, ext: string): Promise<{
26
+ rid: string;
27
+ path: string;
28
+ }>;
29
+ /** External hyperlink relationship; returns the run link key ('r:rIdN'). */
30
+ export declare function addLink(doc: DocxDocument, url: string): Promise<string>;
31
+ /** Regenerates a whole table from the editor model, reusing original row/cell properties. */
32
+ export declare function genTable(doc: DocxDocument, spec: TableSpec): Promise<string>;
33
+ export declare function applyTable(doc: DocxDocument, op: TableOp): Promise<void>;
34
+ export declare function saveDocx(doc: DocxDocument): Promise<Blob>;
35
+ export {};
@@ -0,0 +1 @@
1
+ export declare function cssFont(name: string | undefined): string | undefined;
@@ -0,0 +1,15 @@
1
+ import './default-worker';
2
+ export * from './source';
3
+ export { ZipArchive } from './zip';
4
+ export { SaxParser, TreeBuilder, parseXml, parseXmlStream, type XEl, type SaxHandler } from './xml';
5
+ export { OpcPackage, type DocKind } from './opc';
6
+ export { DocxDocument } from './docx/parser';
7
+ export type * from './docx/types';
8
+ export { XlsxWorkbook, colName, colIndex } from './xlsx/workbook';
9
+ export { formatValue, formatGeneral, serialToDate } from './xlsx/numfmt';
10
+ export type * from './xlsx/types';
11
+ export { PptxPresentation } from './pptx/parser';
12
+ export type * from './pptx/types';
13
+ export { Engine } from './worker/engine';
14
+ export { DocumentClient, setDefaultWorker, type OpenOptions } from './worker/client';
15
+ export type { Events, Methods, OpenResult } from './worker/protocol';
@@ -0,0 +1,56 @@
1
+ import { ZipArchive } from './zip';
2
+ import { type PartData } from './zipwrite';
3
+ import { type XEl } from './xml';
4
+ export type DocKind = 'docx' | 'xlsx' | 'pptx';
5
+ export interface Rel {
6
+ id: string;
7
+ type: string;
8
+ target: string;
9
+ external: boolean;
10
+ }
11
+ export type Rels = Map<string, Rel>;
12
+ export declare function mimeOf(path: string): string;
13
+ /** Browser-renderable image? (EMF/WMF/TIFF are not.) */
14
+ export declare function isWebImage(path: string): boolean;
15
+ export declare function dirOf(part: string): string;
16
+ export declare function resolvePath(baseDir: string, target: string): string;
17
+ /** Inverse of resolvePath: target of `abs` relative to directory `fromDir`. */
18
+ export declare function relativeTarget(fromDir: string, abs: string): string;
19
+ export declare function relsPathFor(part: string): string;
20
+ export declare class OpcPackage {
21
+ readonly zip: ZipArchive;
22
+ private relsCache;
23
+ private xmlCache;
24
+ private contentTypes?;
25
+ /** edited parts: normalized path → { path, data } (data null = deleted) */
26
+ private changes;
27
+ constructor(zip: ZipArchive);
28
+ has(path: string): boolean;
29
+ get dirty(): boolean;
30
+ /** Current text of a part (edited version if any). */
31
+ text(path: string): Promise<string>;
32
+ /** Decompressed stream of the current version of a part (edited parts included). */
33
+ stream(path: string, onRaw?: (consumed: number, total: number) => void): Promise<ReadableStream<Uint8Array>>;
34
+ setPart(path: string, data: PartData | null): void;
35
+ /** Builds the edited package; unchanged entries are copied without recompression. */
36
+ save(type: string): Promise<Blob>;
37
+ /** Adds a relationship from `part` to `target` (absolute part path); returns its id. */
38
+ addRel(part: string, type: string, target: string, external?: boolean): Promise<string>;
39
+ removeRelsTo(part: string, target: string): Promise<void>;
40
+ /** Ensures a <Default Extension=…> entry exists (for new media types). */
41
+ ensureDefaultType(ext: string, contentType: string): Promise<void>;
42
+ /** Free part name like `word/media/image7.png`. */
43
+ freeName(dir: string, base: string, ext: string): string;
44
+ setContentType(partName: string, contentType: string | null): Promise<void>;
45
+ /** Parsed XML part (cached). Missing parts resolve to undefined. */
46
+ xml(path: string, cache?: boolean): Promise<XEl | undefined>;
47
+ rels(part: string): Promise<Rels>;
48
+ contentType(path: string): Promise<string | undefined>;
49
+ blob(path: string): Promise<Blob>;
50
+ mainPart(): Promise<{
51
+ path: string;
52
+ kind: DocKind;
53
+ }>;
54
+ }
55
+ export declare function relOfType(rels: Rels, suffix: string): Rel | undefined;
56
+ export declare function relsOfType(rels: Rels, suffix: string): Rel[];
@@ -0,0 +1,10 @@
1
+ import type { PptxPresentation } from './parser';
2
+ import type { PresentationMeta, ShapeOp, SlideModel, SlideOp } from './types';
3
+ /** undoes / redoes the last shape edit; returns the slide index and its new model */
4
+ export declare function undoShapes(pres: PptxPresentation, redo?: boolean): Promise<{
5
+ index: number;
6
+ model: SlideModel;
7
+ } | null>;
8
+ export declare function addSlideImage(pres: PptxPresentation, index: number, bytes: Uint8Array, ext: string): Promise<string>;
9
+ export declare function shapeOps(pres: PptxPresentation, index: number, ops: ShapeOp[]): Promise<SlideModel>;
10
+ export declare function slideOp(pres: PptxPresentation, op: SlideOp): Promise<PresentationMeta>;
@@ -0,0 +1,52 @@
1
+ import { OpcPackage } from '../opc';
2
+ import { type XEl } from '../xml';
3
+ import type { PParaSpec, PresentationMeta, SlideModel } from './types';
4
+ export declare const PPTX_MIME = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
5
+ interface GenPara {
6
+ k?: number;
7
+ runs: ([number, number] | undefined)[];
8
+ }
9
+ export declare class PptxPresentation {
10
+ readonly pkg: OpcPackage;
11
+ readonly mainPath: string;
12
+ private defaultTextStyle;
13
+ private masters;
14
+ private layouts;
15
+ private tableStyles?;
16
+ readonly meta: PresentationMeta;
17
+ private constructor();
18
+ static open(pkg: OpcPackage, mainPath: string): Promise<PptxPresentation>;
19
+ private part;
20
+ private master;
21
+ private layout;
22
+ private getTableStyles;
23
+ slide(index: number): Promise<SlideModel>;
24
+ get defaults(): XEl | undefined;
25
+ private genMaps;
26
+ /** structural edits (shapes, slides) */
27
+ touched: boolean;
28
+ /** shape edits (slide XML before / after) for undo; text edits drop the entries of their slide */
29
+ undoStack: {
30
+ path: string;
31
+ before: string;
32
+ after: string;
33
+ }[];
34
+ redoStack: {
35
+ path: string;
36
+ before: string;
37
+ after: string;
38
+ }[];
39
+ private originals;
40
+ private lateShapes;
41
+ /**
42
+ * Takes the slide XML that text edits use as template (their run references point into it).
43
+ * Done lazily on the first text edit; collaboration takes it up front so every client uses the same.
44
+ */
45
+ keepOriginal(path: string): Promise<void>;
46
+ genMap(path: string, sid: number): GenPara[] | undefined;
47
+ get dirty(): boolean;
48
+ /** Rewrites the paragraphs of shape `sid` on slide `index` and returns the re-rendered slide. */
49
+ setText(index: number, sid: number, paras: PParaSpec[]): Promise<SlideModel>;
50
+ save(): Promise<Blob>;
51
+ }
52
+ export {};