@json-to-office/core-pptx 1.2.0 → 1.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.
@@ -10,7 +10,7 @@
10
10
  * `pattern-fills` because a backend can plausibly have one and not the other,
11
11
  * while `rich-text` covers multi-run bodies as a single indivisible ability.
12
12
  */
13
- export declare const PPTX_FEATURES: readonly ["masters", "placeholders", "rich-text", "complex-bullet-glyphs", "text", "shapes", "images", "svg", "image-crop", "image-rounding", "tables", "table-merged-cells", "table-insets", "table-rounded-corners", "table-auto-page", "charts", "solid-fills", "gradient-fills", "pattern-fills", "image-fills", "lines", "shadows", "backgrounds", "speaker-notes", "hidden-slides", "transitions", "external-links", "internal-links", "text-hyperlinks", "element-hyperlinks", "rotation", "image-transform", "flip-horizontal", "flip-vertical", "groups", "proofing-language", "rtl"];
13
+ export declare const PPTX_FEATURES: readonly ["masters", "placeholders", "rich-text", "complex-bullet-glyphs", "text", "shapes", "images", "svg", "image-crop", "image-rounding", "tables", "table-merged-cells", "table-insets", "table-rounded-corners", "table-auto-page", "charts", "chart-bar-style", "chart-pie-style", "chart-line-style", "chart-radar-style", "chart-data-labels", "chart-data-border", "chart-axis-scale", "chart-axis-visibility", "chart-axis-style", "chart-text-style", "solid-fills", "gradient-fills", "pattern-fills", "image-fills", "lines", "shadows", "backgrounds", "speaker-notes", "hidden-slides", "transitions", "external-links", "internal-links", "text-hyperlinks", "element-hyperlinks", "rotation", "image-transform", "flip-horizontal", "flip-vertical", "groups", "proofing-language", "rtl"];
14
14
  export type PptxFeature = (typeof PPTX_FEATURES)[number];
15
15
  /** Every feature, for an adapter that claims the full surface. */
16
16
  export declare const ALL_PPTX_FEATURES: ReadonlySet<PptxFeature>;
@@ -1 +1 @@
1
- {"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/ir/features.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,aAAa,gkBAgGhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,kEAAkE;AAClE,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,WAAW,CAEtD,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,WAAW,CAEjE"}
1
+ {"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/ir/features.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,aAAa,8wBAiIhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,kEAAkE;AAClE,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,WAAW,CAEtD,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,WAAW,CAEjE"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Packaging a native chart's missing half, for PPTX.
3
+ *
4
+ * The repairs themselves are format-neutral and live in `chart-parts` in
5
+ * `@json-to-office/shared/rendering`; a `c:chartSpace` is DrawingML and the
6
+ * docx sibling of this file makes the same edits. What differs is how much is
7
+ * missing. `@office-open/pptx` hands its whole options object to
8
+ * `chartSpaceDesc`, so the chart title and the legend position survive the trip
9
+ * — verified against the package — where the docx sibling loses both. Every
10
+ * other repair is needed on this side too: the cell references, the series
11
+ * colours, the axis titles, the bar grouping and `c:externalData`. The shared
12
+ * splice guards each on what the XML actually lacks, so the same function does
13
+ * both jobs without writing anything twice.
14
+ *
15
+ * What is genuinely pptx's own is the packaging. The backend writes
16
+ * `ppt/charts/chartN.xml` and nothing else: no rels part, no workbook, no
17
+ * content-type override for one. Two conventions have to be matched exactly:
18
+ *
19
+ * - The workbook is `ppt/embeddings/Microsoft_Excel_Worksheet{N}.xlsx`, which
20
+ * is what pptxgenjs writes, so a deck's two backends produce packages of the
21
+ * same shape.
22
+ * - `canonicalizeChartIds` in `finalizePackage` renumbers chart parts to 1..n
23
+ * and rewrites `Microsoft_Excel_Worksheet{N}.xlsx` references through the
24
+ * *same* index map. So the workbook's number must match the chart part it
25
+ * belongs to, and this pass must run before finalization — otherwise the
26
+ * rename walks a reference that is not there yet.
27
+ */
28
+ import JSZip from 'jszip';
29
+ import type { PptxIrChartElement } from '../../ir/types';
30
+ /**
31
+ * Give every chart in the package the cell references, colours and workbook the
32
+ * backend leaves out.
33
+ *
34
+ * Parts are matched to IR elements by content rather than by position: the
35
+ * emitter fills its array while *building* the backend's options object and the
36
+ * backend numbers its parts while *stringifying* that object, and the two walks
37
+ * need not agree. Pairing by position is what handed docx charts another
38
+ * chart's workbook.
39
+ */
40
+ export declare function spliceChartParts(zip: JSZip, charts: readonly PptxIrChartElement[]): Promise<void>;
41
+ //# sourceMappingURL=chartParts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chartParts.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/chartParts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,OAAO,KAAK,EAEV,kBAAkB,EAGnB,MAAM,gBAAgB,CAAC;AA6KxB;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,KAAK,EACV,MAAM,EAAE,SAAS,kBAAkB,EAAE,GACpC,OAAO,CAAC,IAAI,CAAC,CAiCf"}
@@ -11,7 +11,7 @@
11
11
  * anything this module cannot express has already been rejected before it is
12
12
  * called. Reaching a `throw` here is a bug, not a user error.
13
13
  */
14
- import type { PptxIrBackground, PptxIrElement, PptxIrFill, PptxIrResource, PptxIrTextBodyStyle, PptxIrTextRun } from '../../ir/types';
14
+ import type { PptxIrBackground, PptxIrElement, PptxIrFill, PptxIrResource, PptxIrChartElement, PptxIrTextBodyStyle, PptxIrTextRun } from '../../ir/types';
15
15
  type Opts = Record<string, unknown>;
16
16
  export type ResourceLookup = ReadonlyMap<string, PptxIrResource>;
17
17
  export interface OfficeOpenEmitContext {
@@ -27,6 +27,15 @@ export interface OfficeOpenEmitContext {
27
27
  * on its input.
28
28
  */
29
29
  nextId: () => number;
30
+ /**
31
+ * Charts, in the order they were emitted.
32
+ *
33
+ * The post-generation splice reads this to give each chart part the cell
34
+ * references and series colours the backend leaves out. Matched to parts by
35
+ * content rather than by this order — see `chart-parts` in
36
+ * `@json-to-office/shared/rendering`.
37
+ */
38
+ charts?: PptxIrChartElement[];
30
39
  }
31
40
  export declare function fill(value: PptxIrFill, ctx: OfficeOpenEmitContext): unknown;
32
41
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EACV,gBAAgB,EAEhB,aAAa,EACb,UAAU,EAMV,cAAc,EAKd,mBAAmB,EAEnB,aAAa,EAEd,MAAM,gBAAgB,CAAC;AAExB,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEjE,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,cAAc,CAAC;IAC1B,qEAAqE;IACrE,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/C;;;;;;;OAOG;IACH,MAAM,EAAE,MAAM,MAAM,CAAC;CACtB;AAuFD,wBAAgB,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAmC3E;AAwED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,SAAS,aAAa,EAAE,EAC9B,KAAK,EAAE,mBAAmB,GAAG,SAAS,GACrC,IAAI,CA2BN;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@@ -11,7 +11,7 @@
11
11
  * the compiler reject the document before any bytes exist, instead of shipping
12
12
  * a deck with content quietly missing.
13
13
  */
14
- import type { PptxIR } from '../../ir/types';
14
+ import type { PptxIR, PptxIrChartElement } from '../../ir/types';
15
15
  import type { PptxRenderer, PptxRendererId } from '../types';
16
16
  export declare const OFFICE_OPEN_PPTX_RENDERER_ID: PptxRendererId;
17
17
  export declare function createOfficeOpenPptxRenderer(): Promise<PptxRenderer>;
@@ -21,5 +21,5 @@ export declare function createOfficeOpenPptxRenderer(): Promise<PptxRenderer>;
21
21
  * Exported for tests: asserting on this object is far cheaper, and far more
22
22
  * legible, than unzipping a package.
23
23
  */
24
- export declare function buildPresentationOptions(ir: PptxIR): Promise<Record<string, unknown>>;
24
+ export declare function buildPresentationOptions(ir: PptxIR, charts?: PptxIrChartElement[]): Promise<Record<string, unknown>>;
25
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGhF,eAAO,MAAM,4BAA4B,EAAE,cAA8B,CAAC;AA6E1E,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,YAAY,CAAC,CAqC1E;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAoDlC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,OAAO,KAAK,EACV,MAAM,EACN,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGhF,eAAO,MAAM,4BAA4B,EAAE,cAA8B,CAAC;AAsF1E,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,YAAY,CAAC,CAqD1E;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,kBAAkB,EAAO,GAChC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqDlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/pptxgenjs/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,KAAK,EACV,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,eAAO,MAAM,qBAAqB,EAAE,cAA4B,CAAC;AAqBjE,wBAAgB,uBAAuB,IAAI,YAAY,CAoBtD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,eAAe,EAC9B,QAAQ,CAAC,EAAE,eAAe,EAAE,GAC3B,SAAS,CAoCX"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/pptxgenjs/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,KAAK,EACV,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,eAAO,MAAM,qBAAqB,EAAE,cAA4B,CAAC;AA6BjE,wBAAgB,uBAAuB,IAAI,YAAY,CAoBtD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,eAAe,EAC9B,QAAQ,CAAC,EAAE,eAAe,EAAE,GAC3B,SAAS,CAoCX"}