ooxml.js 2.4.1 → 2.5.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 (138) hide show
  1. package/README.md +15 -2
  2. package/dist/codec.cjs +28 -0
  3. package/dist/codec.d.cts +72 -0
  4. package/dist/codec.d.ts +72 -0
  5. package/dist/codec.js +24 -0
  6. package/dist/compact.cjs +162 -0
  7. package/dist/compact.d.cts +70 -0
  8. package/dist/compact.d.ts +70 -0
  9. package/dist/compact.js +152 -0
  10. package/dist/image/sniff.cjs +28 -0
  11. package/dist/image/sniff.d.cts +5 -0
  12. package/dist/image/sniff.d.ts +5 -0
  13. package/dist/image/sniff.js +27 -0
  14. package/dist/index.cjs +83 -3025
  15. package/dist/index.d.cts +22 -527
  16. package/dist/index.d.ts +22 -527
  17. package/dist/index.js +22 -2964
  18. package/dist/model/node.cjs +67 -0
  19. package/dist/model/node.d.cts +2 -0
  20. package/dist/model/node.d.ts +2 -0
  21. package/dist/model/node.js +58 -0
  22. package/dist/model/package.cjs +19 -0
  23. package/dist/model/package.d.cts +2 -0
  24. package/dist/model/package.d.ts +2 -0
  25. package/dist/model/package.js +15 -0
  26. package/dist/node-CkBWRjNR.d.cts +83 -0
  27. package/dist/node-CkBWRjNR.d.ts +83 -0
  28. package/dist/package-BUojjTXf.d.ts +114 -0
  29. package/dist/package-L24lkba-.d.cts +114 -0
  30. package/dist/package-io/read.cjs +33 -0
  31. package/dist/package-io/read.d.cts +5 -0
  32. package/dist/package-io/read.d.ts +5 -0
  33. package/dist/package-io/read.js +32 -0
  34. package/dist/package-io/write.cjs +18 -0
  35. package/dist/package-io/write.d.cts +5 -0
  36. package/dist/package-io/write.d.ts +5 -0
  37. package/dist/package-io/write.js +17 -0
  38. package/dist/typed/docx/read.cjs +332 -0
  39. package/dist/typed/docx/read.d.cts +52 -0
  40. package/dist/typed/docx/read.d.ts +52 -0
  41. package/dist/typed/docx/read.js +328 -0
  42. package/dist/typed/docx/styles.cjs +148 -0
  43. package/dist/typed/docx/styles.d.cts +29 -0
  44. package/dist/typed/docx/styles.d.ts +29 -0
  45. package/dist/typed/docx/styles.js +146 -0
  46. package/dist/typed/pptx/inherit.cjs +96 -0
  47. package/dist/typed/pptx/inherit.d.cts +30 -0
  48. package/dist/typed/pptx/inherit.d.ts +30 -0
  49. package/dist/typed/pptx/inherit.js +90 -0
  50. package/dist/typed/pptx/read.cjs +364 -0
  51. package/dist/typed/pptx/read.d.cts +44 -0
  52. package/dist/typed/pptx/read.d.ts +44 -0
  53. package/dist/typed/pptx/read.js +362 -0
  54. package/dist/typed/shared/color.cjs +85 -0
  55. package/dist/typed/shared/color.d.cts +9 -0
  56. package/dist/typed/shared/color.d.ts +9 -0
  57. package/dist/typed/shared/color.js +84 -0
  58. package/dist/typed/shared/drawingml.cjs +191 -0
  59. package/dist/typed/shared/drawingml.d.cts +40 -0
  60. package/dist/typed/shared/drawingml.d.ts +40 -0
  61. package/dist/typed/shared/drawingml.js +180 -0
  62. package/dist/typed/shared/metadata.cjs +44 -0
  63. package/dist/typed/shared/metadata.d.cts +16 -0
  64. package/dist/typed/shared/metadata.d.ts +16 -0
  65. package/dist/typed/shared/metadata.js +42 -0
  66. package/dist/typed/shared/source-path.cjs +18 -0
  67. package/dist/typed/shared/source-path.d.cts +5 -0
  68. package/dist/typed/shared/source-path.d.ts +5 -0
  69. package/dist/typed/shared/source-path.js +17 -0
  70. package/dist/typed/shared/units.cjs +55 -0
  71. package/dist/typed/shared/units.d.cts +20 -0
  72. package/dist/typed/shared/units.d.ts +20 -0
  73. package/dist/typed/shared/units.js +38 -0
  74. package/dist/typed/util.cjs +85 -0
  75. package/dist/typed/util.d.cts +18 -0
  76. package/dist/typed/util.d.ts +18 -0
  77. package/dist/typed/util.js +77 -0
  78. package/dist/typed/xlsx/a1.cjs +64 -0
  79. package/dist/typed/xlsx/a1.d.cts +19 -0
  80. package/dist/typed/xlsx/a1.d.ts +19 -0
  81. package/dist/typed/xlsx/a1.js +58 -0
  82. package/dist/typed/xlsx/build.cjs +456 -0
  83. package/dist/typed/xlsx/build.d.cts +6 -0
  84. package/dist/typed/xlsx/build.d.ts +6 -0
  85. package/dist/typed/xlsx/build.js +455 -0
  86. package/dist/typed/xlsx/content.cjs +257 -0
  87. package/dist/typed/xlsx/content.d.cts +6 -0
  88. package/dist/typed/xlsx/content.d.ts +6 -0
  89. package/dist/typed/xlsx/content.js +256 -0
  90. package/dist/typed/xlsx/defined-names.cjs +90 -0
  91. package/dist/typed/xlsx/defined-names.d.cts +20 -0
  92. package/dist/typed/xlsx/defined-names.d.ts +20 -0
  93. package/dist/typed/xlsx/defined-names.js +83 -0
  94. package/dist/typed/xlsx/print-settings.cjs +116 -0
  95. package/dist/typed/xlsx/print-settings.d.cts +8 -0
  96. package/dist/typed/xlsx/print-settings.d.ts +8 -0
  97. package/dist/typed/xlsx/print-settings.js +114 -0
  98. package/dist/typed/xlsx/shared-strings.cjs +35 -0
  99. package/dist/typed/xlsx/shared-strings.d.cts +12 -0
  100. package/dist/typed/xlsx/shared-strings.d.ts +12 -0
  101. package/dist/typed/xlsx/shared-strings.js +33 -0
  102. package/dist/typed/xlsx/units.cjs +21 -0
  103. package/dist/typed/xlsx/units.d.cts +8 -0
  104. package/dist/typed/xlsx/units.d.ts +8 -0
  105. package/dist/typed/xlsx/units.js +16 -0
  106. package/dist/typed/xlsx/util.cjs +53 -0
  107. package/dist/typed/xlsx/util.d.cts +10 -0
  108. package/dist/typed/xlsx/util.d.ts +10 -0
  109. package/dist/typed/xlsx/util.js +47 -0
  110. package/dist/typed/xlsx.cjs +140 -0
  111. package/dist/typed/xlsx.d.cts +43 -0
  112. package/dist/typed/xlsx.d.ts +43 -0
  113. package/dist/typed/xlsx.js +135 -0
  114. package/dist/util/base64.cjs +48 -0
  115. package/dist/util/base64.d.cts +5 -0
  116. package/dist/util/base64.d.ts +5 -0
  117. package/dist/util/base64.js +46 -0
  118. package/dist/xml/build.cjs +46 -0
  119. package/dist/xml/build.d.cts +5 -0
  120. package/dist/xml/build.d.ts +5 -0
  121. package/dist/xml/build.js +46 -0
  122. package/dist/xml/entities.cjs +7 -0
  123. package/dist/xml/entities.d.cts +4 -0
  124. package/dist/xml/entities.d.ts +4 -0
  125. package/dist/xml/entities.js +6 -0
  126. package/dist/xml/fragment.cjs +22 -0
  127. package/dist/xml/fragment.d.cts +6 -0
  128. package/dist/xml/fragment.d.ts +6 -0
  129. package/dist/xml/fragment.js +20 -0
  130. package/dist/xml/parse.cjs +88 -0
  131. package/dist/xml/parse.d.cts +5 -0
  132. package/dist/xml/parse.d.ts +5 -0
  133. package/dist/xml/parse.js +88 -0
  134. package/dist/zip.cjs +12 -0
  135. package/dist/zip.d.cts +5 -0
  136. package/dist/zip.d.ts +5 -0
  137. package/dist/zip.js +10 -0
  138. package/package.json +9 -1
@@ -0,0 +1,146 @@
1
+ import { attr, childrenWithTag, elementsWithTag } from "../util.js";
2
+ import { halfPointsToPt, lineUnitsToMultiplier, twipsToPt } from "../shared/units.js";
3
+ import { rgbHexToColor } from "document-schema.js";
4
+ //#region src/typed/docx/styles.ts
5
+ function mergeParagraphLayer(base, layer) {
6
+ return {
7
+ alignment: layer.alignment ?? base.alignment,
8
+ spacingBeforePt: layer.spacingBeforePt ?? base.spacingBeforePt,
9
+ spacingAfterPt: layer.spacingAfterPt ?? base.spacingAfterPt,
10
+ lineSpacing: layer.lineSpacing ?? base.lineSpacing,
11
+ indentLeftPt: layer.indentLeftPt ?? base.indentLeftPt,
12
+ indentFirstLinePt: layer.indentFirstLinePt ?? base.indentFirstLinePt
13
+ };
14
+ }
15
+ function mergeRunLayer(base, layer) {
16
+ return {
17
+ bold: layer.bold ?? base.bold,
18
+ italic: layer.italic ?? base.italic,
19
+ underline: layer.underline ?? base.underline,
20
+ strike: layer.strike ?? base.strike,
21
+ fontFamily: layer.fontFamily ?? base.fontFamily,
22
+ sizePt: layer.sizePt ?? base.sizePt,
23
+ color: layer.color ?? base.color
24
+ };
25
+ }
26
+ function readToggle(el) {
27
+ if (el === void 0) return;
28
+ const val = attr(el, "w:val");
29
+ return val === void 0 || val !== "0" && val !== "false" && val !== "off";
30
+ }
31
+ function readUnderline(u) {
32
+ if (u === void 0) return;
33
+ const val = attr(u, "w:val");
34
+ return val !== void 0 && val !== "none";
35
+ }
36
+ function readRunColor(colorEl) {
37
+ if (colorEl === void 0) return;
38
+ const val = attr(colorEl, "w:val");
39
+ return val === void 0 || val === "auto" ? void 0 : rgbHexToColor(val);
40
+ }
41
+ function readRunFontFamily(rFonts, theme) {
42
+ if (rFonts === void 0) return;
43
+ const ascii = attr(rFonts, "w:ascii");
44
+ if (ascii !== void 0) return ascii;
45
+ const asciiTheme = attr(rFonts, "w:asciiTheme");
46
+ if (asciiTheme === "majorHAnsi" || asciiTheme === "majorAscii") return theme.majorFont;
47
+ if (asciiTheme === "minorHAnsi" || asciiTheme === "minorAscii") return theme.minorFont;
48
+ }
49
+ function readRunPropertiesLayer(rPr, theme) {
50
+ if (rPr === void 0) return {};
51
+ const sz = childrenWithTag(rPr, "w:sz")[0];
52
+ const szVal = sz === void 0 ? void 0 : attr(sz, "w:val");
53
+ return {
54
+ bold: readToggle(childrenWithTag(rPr, "w:b")[0]),
55
+ italic: readToggle(childrenWithTag(rPr, "w:i")[0]),
56
+ underline: readUnderline(childrenWithTag(rPr, "w:u")[0]),
57
+ strike: readToggle(childrenWithTag(rPr, "w:strike")[0]),
58
+ fontFamily: readRunFontFamily(childrenWithTag(rPr, "w:rFonts")[0], theme),
59
+ sizePt: szVal === void 0 ? void 0 : halfPointsToPt(Number(szVal)),
60
+ color: readRunColor(childrenWithTag(rPr, "w:color")[0])
61
+ };
62
+ }
63
+ function readAlignment(jc) {
64
+ const val = jc === void 0 ? void 0 : attr(jc, "w:val");
65
+ if (val === "left" || val === "start") return "left";
66
+ if (val === "center") return "center";
67
+ if (val === "right" || val === "end") return "right";
68
+ if (val === "both" || val === "distribute") return "justify";
69
+ }
70
+ function readParagraphPropertiesLayer(pPr) {
71
+ if (pPr === void 0) return {};
72
+ const spacing = childrenWithTag(pPr, "w:spacing")[0];
73
+ const before = spacing === void 0 ? void 0 : attr(spacing, "w:before");
74
+ const after = spacing === void 0 ? void 0 : attr(spacing, "w:after");
75
+ const line = spacing === void 0 ? void 0 : attr(spacing, "w:line");
76
+ const lineRule = spacing === void 0 ? void 0 : attr(spacing, "w:lineRule");
77
+ const ind = childrenWithTag(pPr, "w:ind")[0];
78
+ const left = ind === void 0 ? void 0 : attr(ind, "w:left") ?? attr(ind, "w:start");
79
+ const firstLine = ind === void 0 ? void 0 : attr(ind, "w:firstLine");
80
+ const hanging = ind === void 0 ? void 0 : attr(ind, "w:hanging");
81
+ return {
82
+ alignment: readAlignment(childrenWithTag(pPr, "w:jc")[0]),
83
+ spacingBeforePt: before === void 0 ? void 0 : twipsToPt(Number(before)),
84
+ spacingAfterPt: after === void 0 ? void 0 : twipsToPt(Number(after)),
85
+ lineSpacing: line === void 0 || lineRule === "exact" || lineRule === "atLeast" ? void 0 : lineUnitsToMultiplier(Number(line)),
86
+ indentLeftPt: left === void 0 ? void 0 : twipsToPt(Number(left)),
87
+ indentFirstLinePt: firstLine !== void 0 ? twipsToPt(Number(firstLine)) : hanging !== void 0 ? -twipsToPt(Number(hanging)) : void 0
88
+ };
89
+ }
90
+ function findStyle(stylesRoot, styleId, type) {
91
+ return elementsWithTag([stylesRoot], "w:style").find((s) => attr(s, "w:type") === type && attr(s, "w:styleId") === styleId);
92
+ }
93
+ function findDefaultStyle(stylesRoot, type) {
94
+ return elementsWithTag([stylesRoot], "w:style").find((s) => attr(s, "w:type") === type && attr(s, "w:default") === "1");
95
+ }
96
+ function resolveBasedOnChain(stylesRoot, styleId, type) {
97
+ const chain = [];
98
+ const visited = /* @__PURE__ */ new Set();
99
+ let currentId = styleId;
100
+ while (currentId !== void 0 && !visited.has(currentId)) {
101
+ visited.add(currentId);
102
+ const style = findStyle(stylesRoot, currentId, type);
103
+ if (style === void 0) break;
104
+ chain.unshift(style);
105
+ const basedOn = childrenWithTag(style, "w:basedOn")[0];
106
+ currentId = basedOn === void 0 ? void 0 : attr(basedOn, "w:val");
107
+ }
108
+ return chain;
109
+ }
110
+ function docDefaultsElement(stylesRoot, wrapperTag, innerTag) {
111
+ const docDefaults = stylesRoot === void 0 ? void 0 : childrenWithTag(stylesRoot, "w:docDefaults")[0];
112
+ const wrapper = docDefaults === void 0 ? void 0 : childrenWithTag(docDefaults, wrapperTag)[0];
113
+ return wrapper === void 0 ? void 0 : childrenWithTag(wrapper, innerTag)[0];
114
+ }
115
+ function resolveParagraphProperties(paragraph, context) {
116
+ const pPr = childrenWithTag(paragraph, "w:pPr")[0];
117
+ const pStyleEl = pPr === void 0 ? void 0 : childrenWithTag(pPr, "w:pStyle")[0];
118
+ const styleId = pStyleEl === void 0 ? void 0 : attr(pStyleEl, "w:val");
119
+ let resolved = readParagraphPropertiesLayer(docDefaultsElement(context.stylesRoot, "w:pPrDefault", "w:pPr"));
120
+ if (context.stylesRoot !== void 0) {
121
+ const defaultStyle = findDefaultStyle(context.stylesRoot, "paragraph");
122
+ if (defaultStyle !== void 0) resolved = mergeParagraphLayer(resolved, readParagraphPropertiesLayer(childrenWithTag(defaultStyle, "w:pPr")[0]));
123
+ if (styleId !== void 0) for (const style of resolveBasedOnChain(context.stylesRoot, styleId, "paragraph")) resolved = mergeParagraphLayer(resolved, readParagraphPropertiesLayer(childrenWithTag(style, "w:pPr")[0]));
124
+ }
125
+ return mergeParagraphLayer(resolved, readParagraphPropertiesLayer(pPr));
126
+ }
127
+ function resolveRunProperties(run, paragraph, context) {
128
+ const pPr = childrenWithTag(paragraph, "w:pPr")[0];
129
+ const pStyleEl = pPr === void 0 ? void 0 : childrenWithTag(pPr, "w:pStyle")[0];
130
+ const pStyleId = pStyleEl === void 0 ? void 0 : attr(pStyleEl, "w:val");
131
+ let resolved = readRunPropertiesLayer(docDefaultsElement(context.stylesRoot, "w:rPrDefault", "w:rPr"), context.theme);
132
+ if (context.stylesRoot !== void 0) {
133
+ const defaultStyle = findDefaultStyle(context.stylesRoot, "paragraph");
134
+ if (defaultStyle !== void 0) resolved = mergeRunLayer(resolved, readRunPropertiesLayer(childrenWithTag(defaultStyle, "w:rPr")[0], context.theme));
135
+ if (pStyleId !== void 0) for (const style of resolveBasedOnChain(context.stylesRoot, pStyleId, "paragraph")) resolved = mergeRunLayer(resolved, readRunPropertiesLayer(childrenWithTag(style, "w:rPr")[0], context.theme));
136
+ }
137
+ const paragraphMarkRPr = pPr === void 0 ? void 0 : childrenWithTag(pPr, "w:rPr")[0];
138
+ resolved = mergeRunLayer(resolved, readRunPropertiesLayer(paragraphMarkRPr, context.theme));
139
+ const rPr = childrenWithTag(run, "w:rPr")[0];
140
+ const rStyleEl = rPr === void 0 ? void 0 : childrenWithTag(rPr, "w:rStyle")[0];
141
+ const rStyleId = rStyleEl === void 0 ? void 0 : attr(rStyleEl, "w:val");
142
+ if (context.stylesRoot !== void 0 && rStyleId !== void 0) for (const style of resolveBasedOnChain(context.stylesRoot, rStyleId, "character")) resolved = mergeRunLayer(resolved, readRunPropertiesLayer(childrenWithTag(style, "w:rPr")[0], context.theme));
143
+ return mergeRunLayer(resolved, readRunPropertiesLayer(rPr, context.theme));
144
+ }
145
+ //#endregion
146
+ export { resolveParagraphProperties, resolveRunProperties };
@@ -0,0 +1,96 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_typed_util = require("../util.cjs");
3
+ const require_typed_shared_units = require("../shared/units.cjs");
4
+ const require_typed_shared_drawingml = require("../shared/drawingml.cjs");
5
+ //#region src/typed/pptx/inherit.ts
6
+ const SLIDE_LAYOUT_REL_SUFFIX = "/slideLayout";
7
+ const SLIDE_MASTER_REL_SUFFIX = "/slideMaster";
8
+ const THEME_REL_SUFFIX = "/theme";
9
+ function findRelTarget(pkg, partPath, typeSuffix) {
10
+ for (const rel of require_typed_util.resolveRelationships(pkg, partPath).values()) if (rel.type.endsWith(typeSuffix)) return rel.target;
11
+ }
12
+ function resolveSlideInheritance(pkg, slidePath) {
13
+ const layoutPath = findRelTarget(pkg, slidePath, SLIDE_LAYOUT_REL_SUFFIX);
14
+ const layoutRoot = layoutPath === void 0 ? void 0 : require_typed_util.rootElement(pkg.parts[layoutPath]);
15
+ const masterPath = layoutPath === void 0 ? void 0 : findRelTarget(pkg, layoutPath, SLIDE_MASTER_REL_SUFFIX);
16
+ const masterRoot = masterPath === void 0 ? void 0 : require_typed_util.rootElement(pkg.parts[masterPath]);
17
+ const themePath = masterPath === void 0 ? void 0 : findRelTarget(pkg, masterPath, THEME_REL_SUFFIX);
18
+ const themeRoot = themePath === void 0 ? void 0 : require_typed_util.rootElement(pkg.parts[themePath]);
19
+ return {
20
+ layoutRoot,
21
+ masterRoot,
22
+ theme: themeRoot === void 0 ? require_typed_shared_drawingml.EMPTY_THEME : require_typed_shared_drawingml.readTheme(themeRoot),
23
+ colorMap: require_typed_shared_drawingml.readColorMap(masterRoot === void 0 ? void 0 : require_typed_util.childrenWithTag(masterRoot, "p:clrMap")[0])
24
+ };
25
+ }
26
+ const TYPE_NORMALIZATION = /* @__PURE__ */ new Map([["ctrTitle", "title"], ["subTitle", "body"]]);
27
+ function normalizePlaceholderType(type) {
28
+ return type === void 0 ? void 0 : TYPE_NORMALIZATION.get(type) ?? type;
29
+ }
30
+ function readPlaceholderKey(shape) {
31
+ const ph = require_typed_util.elementsWithTag([shape], "p:ph")[0];
32
+ return ph === void 0 ? void 0 : {
33
+ type: require_typed_util.attr(ph, "type"),
34
+ idx: require_typed_util.attr(ph, "idx")
35
+ };
36
+ }
37
+ function shapesOf(root) {
38
+ return root === void 0 ? [] : require_typed_util.elementsWithTag([root], "p:sp");
39
+ }
40
+ function findMatchingPlaceholder(root, key) {
41
+ const shapes = shapesOf(root);
42
+ if (key.idx !== void 0) {
43
+ const byIdx = shapes.find((shape) => readPlaceholderKey(shape)?.idx === key.idx);
44
+ if (byIdx !== void 0) return byIdx;
45
+ }
46
+ const normalizedTarget = normalizePlaceholderType(key.type);
47
+ if (normalizedTarget === void 0) return;
48
+ return shapes.find((shape) => normalizePlaceholderType(readPlaceholderKey(shape)?.type) === normalizedTarget);
49
+ }
50
+ function shapeXfrm(shape) {
51
+ if (shape === void 0) return;
52
+ const spPr = require_typed_util.childrenWithTag(shape, "p:spPr")[0];
53
+ return spPr === void 0 ? void 0 : require_typed_shared_drawingml.readXfrm(require_typed_util.childrenWithTag(spPr, "a:xfrm")[0]);
54
+ }
55
+ function resolvePlaceholderXfrm(key, context) {
56
+ return shapeXfrm(findMatchingPlaceholder(context.layoutRoot, key)) ?? shapeXfrm(findMatchingPlaceholder(context.masterRoot, key));
57
+ }
58
+ function readRunPropertiesFromElement(rPr, context) {
59
+ const sz = require_typed_util.attr(rPr, "sz");
60
+ const latin = require_typed_util.childrenWithTag(rPr, "a:latin")[0];
61
+ const typeface = latin === void 0 ? void 0 : require_typed_util.attr(latin, "typeface");
62
+ const solidFill = require_typed_util.childrenWithTag(rPr, "a:solidFill")[0];
63
+ const bold = require_typed_util.attr(rPr, "b");
64
+ const italic = require_typed_util.attr(rPr, "i");
65
+ return {
66
+ fontFamily: typeface === void 0 ? void 0 : require_typed_shared_drawingml.resolveThemeFontReference(typeface, context.theme),
67
+ sizePt: sz === void 0 ? void 0 : require_typed_shared_units.drawingMlFontSizeToPt(Number(sz)),
68
+ bold: bold === void 0 ? void 0 : bold === "1",
69
+ italic: italic === void 0 ? void 0 : italic === "1",
70
+ color: require_typed_shared_drawingml.readSolidFillColor(solidFill, context.colorMap, context.theme)
71
+ };
72
+ }
73
+ function txStyleTagFor(placeholderType) {
74
+ const normalized = normalizePlaceholderType(placeholderType);
75
+ if (normalized === "title") return "p:titleStyle";
76
+ if (normalized === "body") return "p:bodyStyle";
77
+ return "p:otherStyle";
78
+ }
79
+ function levelTag(level) {
80
+ return `a:lvl${Math.min(Math.max(level, 0), 8) + 1}pPr`;
81
+ }
82
+ function resolveDefaultRunProperties(placeholderType, level, context) {
83
+ if (context.masterRoot === void 0) return {};
84
+ const txStyles = require_typed_util.childrenWithTag(context.masterRoot, "p:txStyles")[0];
85
+ const styleEl = txStyles === void 0 ? void 0 : require_typed_util.childrenWithTag(txStyles, txStyleTagFor(placeholderType))[0];
86
+ const lvlPPr = styleEl === void 0 ? void 0 : require_typed_util.childrenWithTag(styleEl, levelTag(level))[0];
87
+ const defRPr = lvlPPr === void 0 ? void 0 : require_typed_util.childrenWithTag(lvlPPr, "a:defRPr")[0];
88
+ return defRPr === void 0 ? {} : readRunPropertiesFromElement(defRPr, context);
89
+ }
90
+ //#endregion
91
+ exports.findMatchingPlaceholder = findMatchingPlaceholder;
92
+ exports.readPlaceholderKey = readPlaceholderKey;
93
+ exports.readRunPropertiesFromElement = readRunPropertiesFromElement;
94
+ exports.resolveDefaultRunProperties = resolveDefaultRunProperties;
95
+ exports.resolvePlaceholderXfrm = resolvePlaceholderXfrm;
96
+ exports.resolveSlideInheritance = resolveSlideInheritance;
@@ -0,0 +1,30 @@
1
+ import { l as XmlElement } from "../../node-CkBWRjNR.cjs";
2
+ import { r as Package } from "../../package-L24lkba-.cjs";
3
+ import { DrawingTheme, DrawingXfrm } from "../shared/drawingml.cjs";
4
+ import { Color } from "document-schema.js";
5
+ //#region src/typed/pptx/inherit.d.ts
6
+ interface SlideInheritanceContext {
7
+ readonly layoutRoot: XmlElement | undefined;
8
+ readonly masterRoot: XmlElement | undefined;
9
+ readonly theme: DrawingTheme;
10
+ readonly colorMap: ReadonlyMap<string, string>;
11
+ }
12
+ declare function resolveSlideInheritance(pkg: Package, slidePath: string): SlideInheritanceContext;
13
+ interface PlaceholderKey {
14
+ readonly type: string | undefined;
15
+ readonly idx: string | undefined;
16
+ }
17
+ declare function readPlaceholderKey(shape: XmlElement): PlaceholderKey | undefined;
18
+ declare function findMatchingPlaceholder(root: XmlElement | undefined, key: PlaceholderKey): XmlElement | undefined;
19
+ declare function resolvePlaceholderXfrm(key: PlaceholderKey, context: SlideInheritanceContext): DrawingXfrm | undefined;
20
+ interface DefaultRunProperties {
21
+ readonly fontFamily?: string;
22
+ readonly sizePt?: number;
23
+ readonly bold?: boolean;
24
+ readonly italic?: boolean;
25
+ readonly color?: Color;
26
+ }
27
+ declare function readRunPropertiesFromElement(rPr: XmlElement, context: SlideInheritanceContext): DefaultRunProperties;
28
+ declare function resolveDefaultRunProperties(placeholderType: string | undefined, level: number, context: SlideInheritanceContext): DefaultRunProperties;
29
+ //#endregion
30
+ export { DefaultRunProperties, PlaceholderKey, SlideInheritanceContext, findMatchingPlaceholder, readPlaceholderKey, readRunPropertiesFromElement, resolveDefaultRunProperties, resolvePlaceholderXfrm, resolveSlideInheritance };
@@ -0,0 +1,30 @@
1
+ import { l as XmlElement } from "../../node-CkBWRjNR.js";
2
+ import { r as Package } from "../../package-BUojjTXf.js";
3
+ import { DrawingTheme, DrawingXfrm } from "../shared/drawingml.js";
4
+ import { Color } from "document-schema.js";
5
+ //#region src/typed/pptx/inherit.d.ts
6
+ interface SlideInheritanceContext {
7
+ readonly layoutRoot: XmlElement | undefined;
8
+ readonly masterRoot: XmlElement | undefined;
9
+ readonly theme: DrawingTheme;
10
+ readonly colorMap: ReadonlyMap<string, string>;
11
+ }
12
+ declare function resolveSlideInheritance(pkg: Package, slidePath: string): SlideInheritanceContext;
13
+ interface PlaceholderKey {
14
+ readonly type: string | undefined;
15
+ readonly idx: string | undefined;
16
+ }
17
+ declare function readPlaceholderKey(shape: XmlElement): PlaceholderKey | undefined;
18
+ declare function findMatchingPlaceholder(root: XmlElement | undefined, key: PlaceholderKey): XmlElement | undefined;
19
+ declare function resolvePlaceholderXfrm(key: PlaceholderKey, context: SlideInheritanceContext): DrawingXfrm | undefined;
20
+ interface DefaultRunProperties {
21
+ readonly fontFamily?: string;
22
+ readonly sizePt?: number;
23
+ readonly bold?: boolean;
24
+ readonly italic?: boolean;
25
+ readonly color?: Color;
26
+ }
27
+ declare function readRunPropertiesFromElement(rPr: XmlElement, context: SlideInheritanceContext): DefaultRunProperties;
28
+ declare function resolveDefaultRunProperties(placeholderType: string | undefined, level: number, context: SlideInheritanceContext): DefaultRunProperties;
29
+ //#endregion
30
+ export { DefaultRunProperties, PlaceholderKey, SlideInheritanceContext, findMatchingPlaceholder, readPlaceholderKey, readRunPropertiesFromElement, resolveDefaultRunProperties, resolvePlaceholderXfrm, resolveSlideInheritance };
@@ -0,0 +1,90 @@
1
+ import { attr, childrenWithTag, elementsWithTag, resolveRelationships, rootElement } from "../util.js";
2
+ import { drawingMlFontSizeToPt } from "../shared/units.js";
3
+ import { EMPTY_THEME, readColorMap, readSolidFillColor, readTheme, readXfrm, resolveThemeFontReference } from "../shared/drawingml.js";
4
+ //#region src/typed/pptx/inherit.ts
5
+ const SLIDE_LAYOUT_REL_SUFFIX = "/slideLayout";
6
+ const SLIDE_MASTER_REL_SUFFIX = "/slideMaster";
7
+ const THEME_REL_SUFFIX = "/theme";
8
+ function findRelTarget(pkg, partPath, typeSuffix) {
9
+ for (const rel of resolveRelationships(pkg, partPath).values()) if (rel.type.endsWith(typeSuffix)) return rel.target;
10
+ }
11
+ function resolveSlideInheritance(pkg, slidePath) {
12
+ const layoutPath = findRelTarget(pkg, slidePath, SLIDE_LAYOUT_REL_SUFFIX);
13
+ const layoutRoot = layoutPath === void 0 ? void 0 : rootElement(pkg.parts[layoutPath]);
14
+ const masterPath = layoutPath === void 0 ? void 0 : findRelTarget(pkg, layoutPath, SLIDE_MASTER_REL_SUFFIX);
15
+ const masterRoot = masterPath === void 0 ? void 0 : rootElement(pkg.parts[masterPath]);
16
+ const themePath = masterPath === void 0 ? void 0 : findRelTarget(pkg, masterPath, THEME_REL_SUFFIX);
17
+ const themeRoot = themePath === void 0 ? void 0 : rootElement(pkg.parts[themePath]);
18
+ return {
19
+ layoutRoot,
20
+ masterRoot,
21
+ theme: themeRoot === void 0 ? EMPTY_THEME : readTheme(themeRoot),
22
+ colorMap: readColorMap(masterRoot === void 0 ? void 0 : childrenWithTag(masterRoot, "p:clrMap")[0])
23
+ };
24
+ }
25
+ const TYPE_NORMALIZATION = /* @__PURE__ */ new Map([["ctrTitle", "title"], ["subTitle", "body"]]);
26
+ function normalizePlaceholderType(type) {
27
+ return type === void 0 ? void 0 : TYPE_NORMALIZATION.get(type) ?? type;
28
+ }
29
+ function readPlaceholderKey(shape) {
30
+ const ph = elementsWithTag([shape], "p:ph")[0];
31
+ return ph === void 0 ? void 0 : {
32
+ type: attr(ph, "type"),
33
+ idx: attr(ph, "idx")
34
+ };
35
+ }
36
+ function shapesOf(root) {
37
+ return root === void 0 ? [] : elementsWithTag([root], "p:sp");
38
+ }
39
+ function findMatchingPlaceholder(root, key) {
40
+ const shapes = shapesOf(root);
41
+ if (key.idx !== void 0) {
42
+ const byIdx = shapes.find((shape) => readPlaceholderKey(shape)?.idx === key.idx);
43
+ if (byIdx !== void 0) return byIdx;
44
+ }
45
+ const normalizedTarget = normalizePlaceholderType(key.type);
46
+ if (normalizedTarget === void 0) return;
47
+ return shapes.find((shape) => normalizePlaceholderType(readPlaceholderKey(shape)?.type) === normalizedTarget);
48
+ }
49
+ function shapeXfrm(shape) {
50
+ if (shape === void 0) return;
51
+ const spPr = childrenWithTag(shape, "p:spPr")[0];
52
+ return spPr === void 0 ? void 0 : readXfrm(childrenWithTag(spPr, "a:xfrm")[0]);
53
+ }
54
+ function resolvePlaceholderXfrm(key, context) {
55
+ return shapeXfrm(findMatchingPlaceholder(context.layoutRoot, key)) ?? shapeXfrm(findMatchingPlaceholder(context.masterRoot, key));
56
+ }
57
+ function readRunPropertiesFromElement(rPr, context) {
58
+ const sz = attr(rPr, "sz");
59
+ const latin = childrenWithTag(rPr, "a:latin")[0];
60
+ const typeface = latin === void 0 ? void 0 : attr(latin, "typeface");
61
+ const solidFill = childrenWithTag(rPr, "a:solidFill")[0];
62
+ const bold = attr(rPr, "b");
63
+ const italic = attr(rPr, "i");
64
+ return {
65
+ fontFamily: typeface === void 0 ? void 0 : resolveThemeFontReference(typeface, context.theme),
66
+ sizePt: sz === void 0 ? void 0 : drawingMlFontSizeToPt(Number(sz)),
67
+ bold: bold === void 0 ? void 0 : bold === "1",
68
+ italic: italic === void 0 ? void 0 : italic === "1",
69
+ color: readSolidFillColor(solidFill, context.colorMap, context.theme)
70
+ };
71
+ }
72
+ function txStyleTagFor(placeholderType) {
73
+ const normalized = normalizePlaceholderType(placeholderType);
74
+ if (normalized === "title") return "p:titleStyle";
75
+ if (normalized === "body") return "p:bodyStyle";
76
+ return "p:otherStyle";
77
+ }
78
+ function levelTag(level) {
79
+ return `a:lvl${Math.min(Math.max(level, 0), 8) + 1}pPr`;
80
+ }
81
+ function resolveDefaultRunProperties(placeholderType, level, context) {
82
+ if (context.masterRoot === void 0) return {};
83
+ const txStyles = childrenWithTag(context.masterRoot, "p:txStyles")[0];
84
+ const styleEl = txStyles === void 0 ? void 0 : childrenWithTag(txStyles, txStyleTagFor(placeholderType))[0];
85
+ const lvlPPr = styleEl === void 0 ? void 0 : childrenWithTag(styleEl, levelTag(level))[0];
86
+ const defRPr = lvlPPr === void 0 ? void 0 : childrenWithTag(lvlPPr, "a:defRPr")[0];
87
+ return defRPr === void 0 ? {} : readRunPropertiesFromElement(defRPr, context);
88
+ }
89
+ //#endregion
90
+ export { findMatchingPlaceholder, readPlaceholderKey, readRunPropertiesFromElement, resolveDefaultRunProperties, resolvePlaceholderXfrm, resolveSlideInheritance };