reamkit 1.23.0 → 1.24.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.
Files changed (57) hide show
  1. package/dist/esm/core/bmp.d.ts +33 -0
  2. package/dist/esm/core/bmp.js +276 -0
  3. package/dist/esm/core/document-model/types.d.ts +37 -0
  4. package/dist/esm/core/drawingml/chart-geometry.js +3 -2
  5. package/dist/esm/core/drawingml/diagram/colors.d.ts +52 -0
  6. package/dist/esm/core/drawingml/diagram/colors.js +125 -0
  7. package/dist/esm/core/drawingml/diagram/data-model.d.ts +47 -0
  8. package/dist/esm/core/drawingml/diagram/data-model.js +119 -0
  9. package/dist/esm/core/drawingml/diagram/layout-engine.d.ts +46 -0
  10. package/dist/esm/core/drawingml/diagram/layout-engine.js +948 -0
  11. package/dist/esm/core/drawingml/diagram/run.d.ts +37 -0
  12. package/dist/esm/core/drawingml/diagram/run.js +50 -0
  13. package/dist/esm/core/drawingml/diagram/to-drawing.d.ts +16 -0
  14. package/dist/esm/core/drawingml/diagram/to-drawing.js +86 -0
  15. package/dist/esm/core/drawingml/preset-geometry.js +116 -6
  16. package/dist/esm/core/drawingml/text-warp.d.ts +58 -0
  17. package/dist/esm/core/drawingml/text-warp.js +355 -0
  18. package/dist/esm/core/drawingml/theme-parser.js +9 -3
  19. package/dist/esm/core/font/measure.d.ts +12 -0
  20. package/dist/esm/core/font/measure.js +36 -0
  21. package/dist/esm/core/images.d.ts +30 -2
  22. package/dist/esm/core/images.js +121 -5
  23. package/dist/esm/core/metafile/emf.js +144 -16
  24. package/dist/esm/core/metafile/picture.d.ts +49 -0
  25. package/dist/esm/core/metafile/picture.js +70 -1
  26. package/dist/esm/core/metafile/wmf.js +53 -4
  27. package/dist/esm/core/ole/escher-blip.js +11 -1
  28. package/dist/esm/excel/print-model.js +2 -2
  29. package/dist/esm/excel/sheet-drawing.js +1 -1
  30. package/dist/esm/excel/sheet-to-flow.js +16 -2
  31. package/dist/esm/html/html-writer.js +2 -1
  32. package/dist/esm/layout/page-doc.d.ts +35 -0
  33. package/dist/esm/layout/page-doc.js +14 -1
  34. package/dist/esm/layout/styled-layout.js +176 -15
  35. package/dist/esm/pdf/shading.js +8 -6
  36. package/dist/esm/pdf/styled-page-emitter.js +42 -3
  37. package/dist/esm/pdf/vector-graphics.js +1 -1
  38. package/dist/esm/pdf-reader/image-decode.js +1 -1
  39. package/dist/esm/pptx/ppt/ppt-reader.js +95 -27
  40. package/dist/esm/pptx/ppt/ppt-text.d.ts +41 -0
  41. package/dist/esm/pptx/ppt/ppt-text.js +327 -37
  42. package/dist/esm/pptx/pptx-reader.js +90 -10
  43. package/dist/esm/pptx/slide-parser.d.ts +4 -1
  44. package/dist/esm/pptx/slide-parser.js +99 -13
  45. package/dist/esm/pptx/sp-helpers.d.ts +7 -3
  46. package/dist/esm/pptx/sp-helpers.js +45 -7
  47. package/dist/esm/pptx/table-style.d.ts +7 -0
  48. package/dist/esm/pptx/table-style.js +59 -7
  49. package/dist/esm/svg/svg-writer.js +1 -0
  50. package/dist/esm/word/document-parser.d.ts +4 -1
  51. package/dist/esm/word/document-parser.js +4 -1
  52. package/dist/esm/word/docx-reader.js +26 -13
  53. package/dist/esm/word/docx-writer.js +4 -0
  54. package/dist/esm/word/drawing-parser.d.ts +20 -0
  55. package/dist/esm/word/drawing-parser.js +37 -4
  56. package/dist/esm/word/table-parser.js +3 -0
  57. package/package.json +1 -1
@@ -0,0 +1,119 @@
1
+ import { poAttr, poChildren, poIs, poText } from "../../po-helpers.js";
2
+ //#region src/core/drawingml/diagram/data-model.ts
3
+ /**
4
+ * The data part as the layout engine asks about it: the point tree recovered
5
+ * from the connection list, plus the transition points that go with each edge.
6
+ */
7
+ var DiagramData = class {
8
+ byId = /* @__PURE__ */ new Map();
9
+ kids = /* @__PURE__ */ new Map();
10
+ /** The document point every layout starts from. */
11
+ root;
12
+ /** §21.4.2.4 `dgm:bg` — the fill painted behind the whole diagram. */
13
+ background;
14
+ constructor(tree) {
15
+ const model = findDescendant(tree, "dgm:dataModel");
16
+ this.background = model ? poChildren(model).find((c) => poIs(c, "dgm:bg")) : void 0;
17
+ const ptLst = model ? poChildren(model).find((c) => poIs(c, "dgm:ptLst")) : void 0;
18
+ for (const pt of ptLst ? poChildren(ptLst) : []) {
19
+ if (!poIs(pt, "dgm:pt")) continue;
20
+ const id = poAttr(pt, "modelId");
21
+ if (id === void 0) continue;
22
+ const kids = poChildren(pt);
23
+ this.byId.set(id, {
24
+ id,
25
+ type: poAttr(pt, "type") ?? "node",
26
+ ...pick(kids, "dgm:t", "text"),
27
+ ...pick(kids, "dgm:spPr", "spPr"),
28
+ ...pick(kids, "dgm:prSet", "prSet")
29
+ });
30
+ }
31
+ const cxnLst = model ? poChildren(model).find((c) => poIs(c, "dgm:cxnLst")) : void 0;
32
+ for (const cxn of cxnLst ? poChildren(cxnLst) : []) {
33
+ if (!poIs(cxn, "dgm:cxn")) continue;
34
+ if ((poAttr(cxn, "type") ?? "parOf") !== "parOf") continue;
35
+ const parent = poAttr(cxn, "srcId");
36
+ const child = poAttr(cxn, "destId");
37
+ if (parent === void 0 || child === void 0) continue;
38
+ const list = this.kids.get(parent) ?? [];
39
+ list.push({
40
+ parent,
41
+ child,
42
+ ord: Number(poAttr(cxn, "srcOrd") ?? "0"),
43
+ ...opt("sibTransId", poAttr(cxn, "sibTransId")),
44
+ ...opt("parTransId", poAttr(cxn, "parTransId"))
45
+ });
46
+ this.kids.set(parent, list);
47
+ }
48
+ for (const list of this.kids.values()) list.sort((a, b) => a.ord - b.ord);
49
+ this.root = [...this.byId.values()].find((p) => p.type === "doc");
50
+ }
51
+ /** The point with this id, if the model holds one. */
52
+ point(id) {
53
+ return this.byId.get(id);
54
+ }
55
+ /**
56
+ * The children of a point, in the order the connections give them.
57
+ *
58
+ * @param id The parent's model id.
59
+ * @param ptType Which kind of child to return — `node` skips the
60
+ * transitions, `sibTrans` returns them instead.
61
+ */
62
+ children(id, ptType = "node") {
63
+ const out = [];
64
+ for (const edge of this.kids.get(id) ?? []) {
65
+ const wanted = ptType === "node" ? edge.child : ptType === "sibTrans" ? edge.sibTransId : edge.parTransId;
66
+ const pt = wanted === void 0 ? void 0 : this.byId.get(wanted);
67
+ if (pt && (ptType !== "node" || pt.type !== "parTrans" && pt.type !== "sibTrans")) out.push(pt);
68
+ }
69
+ return out;
70
+ }
71
+ /**
72
+ * How many generations of `node` points the model holds below its root.
73
+ *
74
+ * §21.4.3.3 — a layout branches on this (`func="maxDepth" op="gte" val="2"`):
75
+ * the same part lays a chevron out as one box when the nodes have no
76
+ * children and as a labelled box over a body when they do.
77
+ */
78
+ get depth() {
79
+ const walk = (id, seen) => {
80
+ if (seen.has(id)) return 0;
81
+ seen.add(id);
82
+ let best = 0;
83
+ for (const kid of this.children(id, "node")) best = Math.max(best, walk(kid.id, seen));
84
+ return best + 1;
85
+ };
86
+ return this.root ? walk(this.root.id, /* @__PURE__ */ new Set()) - 1 : 0;
87
+ }
88
+ /** The plain text of a point's `dgm:t`, paragraphs joined by newlines. */
89
+ static textOf(pt) {
90
+ if (!pt?.text) return "";
91
+ const lines = [];
92
+ for (const p of poChildren(pt.text)) {
93
+ if (!poIs(p, "a:p")) continue;
94
+ let line = "";
95
+ for (const r of poChildren(p)) if (poIs(r, "a:br")) {
96
+ lines.push(line);
97
+ line = "";
98
+ } else if (poIs(r, "a:r")) line += poText(poChildren(r).find((c) => poIs(c, "a:t")));
99
+ lines.push(line);
100
+ }
101
+ return lines.join("\n");
102
+ }
103
+ };
104
+ function pick(kids, tag, as) {
105
+ const found = kids.find((c) => poIs(c, tag));
106
+ return found ? { [as]: found } : {};
107
+ }
108
+ function opt(name, v) {
109
+ return v === void 0 || v === "" ? {} : { [name]: v };
110
+ }
111
+ function findDescendant(tree, tag) {
112
+ for (const node of tree) {
113
+ if (poIs(node, tag)) return node;
114
+ const found = findDescendant(poChildren(node), tag);
115
+ if (found) return found;
116
+ }
117
+ }
118
+ //#endregion
119
+ export { DiagramData };
@@ -0,0 +1,46 @@
1
+ import { PoNode } from '../../po-helpers.js';
2
+ import { DiagramData, DiagramPoint } from './data-model.js';
3
+ /** One box the engine laid out, in the diagram's own frame (EMU). */
4
+ export interface LaidNode {
5
+ readonly point: DiagramPoint;
6
+ readonly shapeType: string;
7
+ /** The layout node's `styleLbl` — which run of colours the box takes. */
8
+ readonly styleLbl?: string;
9
+ /** The box's place among its siblings, which is where in that run it is. */
10
+ readonly index: number;
11
+ /** The point size the layout states for the box's text, when it states one. */
12
+ readonly fontSizePt?: number;
13
+ /** Whether the `tx` algorithm asks for the text to be bulleted. */
14
+ readonly bulleted?: boolean;
15
+ /**
16
+ * §21.4.3.9 `dgm:shape@hideGeom` — the box reserves its room but its outline
17
+ * is never drawn. The picture lists put an invisible spacer above each node.
18
+ */
19
+ readonly hideGeom?: boolean;
20
+ /** §21.4.3.2 `txAnchorVert` — where in its box the `tx` algorithm sits text. */
21
+ readonly anchor?: string;
22
+ /** §21.4.3.2 `parTxLTRAlign` — how the layout ranges a node's own label. */
23
+ readonly align?: string;
24
+ /**
25
+ * §21.4.3.5 `dgm:shape@rot` — how far the box's geometry is turned, in
26
+ * 60 000ths of a degree clockwise. The cycle-matrix layout builds its disc
27
+ * out of one quarter-wedge stated four times at 0°, 90°, 180° and 270°.
28
+ */
29
+ readonly rotation60k?: number;
30
+ readonly x: number;
31
+ readonly y: number;
32
+ readonly cx: number;
33
+ readonly cy: number;
34
+ }
35
+ /**
36
+ * Lay a diagram out from its data and layout parts.
37
+ *
38
+ * @param layout The parsed `layout1.xml` tree.
39
+ * @param data The parsed data part.
40
+ * @param cx The frame's width in EMU, as the drawing states it.
41
+ * @param cy The frame's height in EMU.
42
+ * @returns The boxes to draw, or an empty list when the layout uses an
43
+ * algorithm this slice does not run — the caller then reports the
44
+ * diagram as a loss exactly as before.
45
+ */
46
+ export declare function layoutDiagram(layout: ReadonlyArray<PoNode>, data: DiagramData, cx: number, cy: number): Array<LaidNode>;