@office-open/core 0.7.1 → 0.8.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.
- package/README.md +20 -11
- package/dist/chart/index.d.mts +2 -2
- package/dist/chart/index.mjs +2 -2
- package/dist/{chart-ChqlyVeb.mjs → chart-CigYrDhf.mjs} +177 -32
- package/dist/drawingml/index.d.mts +2 -2
- package/dist/drawingml/index.mjs +2 -2
- package/dist/{drawingml-DQlhouyh.mjs → drawingml-B-2eEHAF.mjs} +2954 -2
- package/dist/{index-C4Wm3RBo.d.mts → index-Bh6s66Up.d.mts} +163 -2
- package/dist/index-Cj2Yf5mk.d.mts +52 -0
- package/dist/{index-Borh69Zs.d.mts → index-CoTp4wVf.d.mts} +1 -17
- package/dist/{index-f_Izh2dj.d.mts → index-D0N5Bw2M.d.mts} +44 -6
- package/dist/{index-C0lMGS9A.d.mts → index-DEvpdl1o.d.mts} +1610 -2
- package/dist/index.d.mts +59 -12
- package/dist/index.mjs +81 -19
- package/dist/smartart/index.d.mts +2 -2
- package/dist/smartart/index.mjs +1 -1
- package/dist/{smartart-Cx1qa6k_.mjs → smartart-9ZpWgmIy.mjs} +63 -8
- package/dist/theme/index.d.mts +2 -0
- package/dist/theme/index.mjs +2 -0
- package/dist/theme-FWD_20fH.mjs +80 -0
- package/dist/{values-zMCu5EoQ.mjs → values-BOWpTgBE.mjs} +1 -1
- package/dist/values.mjs +1 -1
- package/dist/{xml-components-xJkfJ6ff.mjs → xml-components-BuFdDxHN.mjs} +2 -33
- package/package.json +11 -3
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { b as BaseXmlComponent } from "./xml-components-BuFdDxHN.mjs";
|
|
2
|
+
//#region src/theme/default-colors.ts
|
|
3
|
+
/** Office 2016+ default theme colors (hex without #). */
|
|
4
|
+
const DEFAULT_COLORS = {
|
|
5
|
+
dark1: "000000",
|
|
6
|
+
light1: "FFFFFF",
|
|
7
|
+
dark2: "44546A",
|
|
8
|
+
light2: "E7E6E6",
|
|
9
|
+
accent1: "4472C4",
|
|
10
|
+
accent2: "ED7D31",
|
|
11
|
+
accent3: "A5A5A5",
|
|
12
|
+
accent4: "FFC000",
|
|
13
|
+
accent5: "5B9BD5",
|
|
14
|
+
accent6: "70AD47",
|
|
15
|
+
hyperlink: "0563C1",
|
|
16
|
+
followedHyperlink: "954F72"
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/theme/build-theme-xml.ts
|
|
20
|
+
/**
|
|
21
|
+
* Build theme XML string — pure function, no side effects.
|
|
22
|
+
*
|
|
23
|
+
* fmtScheme uses the complete Office version (gradFill, outerShdw, bgFillStyleLst)
|
|
24
|
+
* matching what Excel generates.
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
27
|
+
*/
|
|
28
|
+
function buildThemeXml(options) {
|
|
29
|
+
const name = options?.name ?? "Office Theme";
|
|
30
|
+
const c = {
|
|
31
|
+
...DEFAULT_COLORS,
|
|
32
|
+
...options?.colors
|
|
33
|
+
};
|
|
34
|
+
const f = options?.fonts;
|
|
35
|
+
const majorFont = f?.majorFont ?? "Calibri Light";
|
|
36
|
+
const minorFont = f?.minorFont ?? "Calibri";
|
|
37
|
+
const majorFontAsian = f?.majorFontAsian ?? "";
|
|
38
|
+
const minorFontAsian = f?.minorFontAsian ?? "";
|
|
39
|
+
return `<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="${name}"><a:themeElements><a:clrScheme name="${name}"><a:dk1>${options?.colors?.dark1 !== void 0 ? `<a:srgbClr val="${c.dark1}"/>` : `<a:sysClr val="windowText" lastClr="000000"/>`}</a:dk1><a:lt1>${options?.colors?.light1 !== void 0 ? `<a:srgbClr val="${c.light1}"/>` : `<a:sysClr val="window" lastClr="FFFFFF"/>`}</a:lt1><a:dk2><a:srgbClr val="${c.dark2}"/></a:dk2><a:lt2><a:srgbClr val="${c.light2}"/></a:lt2><a:accent1><a:srgbClr val="${c.accent1}"/></a:accent1><a:accent2><a:srgbClr val="${c.accent2}"/></a:accent2><a:accent3><a:srgbClr val="${c.accent3}"/></a:accent3><a:accent4><a:srgbClr val="${c.accent4}"/></a:accent4><a:accent5><a:srgbClr val="${c.accent5}"/></a:accent5><a:accent6><a:srgbClr val="${c.accent6}"/></a:accent6><a:hlink><a:srgbClr val="${c.hyperlink}"/></a:hlink><a:folHlink><a:srgbClr val="${c.followedHyperlink}"/></a:folHlink></a:clrScheme><a:fontScheme name="${name}"><a:majorFont><a:latin typeface="${majorFont}" panose="020F0302020204030204"/><a:ea typeface="${majorFontAsian}"/><a:cs typeface=""/></a:majorFont><a:minorFont><a:latin typeface="${minorFont}" panose="020F0502020204030204"/><a:ea typeface="${minorFontAsian}"/><a:cs typeface=""/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="110000"/><a:satMod val="105000"/><a:tint val="67000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="103000"/><a:tint val="73000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="109000"/><a:tint val="81000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="102000"/><a:satMod val="103000"/><a:tint val="94000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="100000"/><a:satMod val="110000"/><a:shade val="100000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="99000"/><a:satMod val="120000"/><a:shade val="78000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="63000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"><a:tint val="95000"/><a:satMod val="170000"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="102000"/><a:satMod val="150000"/><a:tint val="93000"/><a:shade val="98000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="103000"/><a:satMod val="130000"/><a:tint val="98000"/><a:shade val="90000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:satMod val="120000"/><a:shade val="63000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>`;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/theme/default-theme.ts
|
|
43
|
+
/**
|
|
44
|
+
* DefaultTheme — cached theme XML component.
|
|
45
|
+
*
|
|
46
|
+
* - No-arg constructor returns module-level pre-computed constant (zero allocation).
|
|
47
|
+
* - With options, builds XML string and caches by key.
|
|
48
|
+
*
|
|
49
|
+
* @module
|
|
50
|
+
*/
|
|
51
|
+
const DEFAULT_XML = buildThemeXml();
|
|
52
|
+
const customCache = /* @__PURE__ */ new Map();
|
|
53
|
+
function themeKey(o) {
|
|
54
|
+
const c = o.colors;
|
|
55
|
+
const f = o.fonts;
|
|
56
|
+
return `n${o.name ?? ""}c${c?.dark1 ?? ""}${c?.light1 ?? ""}${c?.dark2 ?? ""}${c?.light2 ?? ""}${c?.accent1 ?? ""}${c?.accent2 ?? ""}${c?.accent3 ?? ""}${c?.accent4 ?? ""}${c?.accent5 ?? ""}${c?.accent6 ?? ""}${c?.hyperlink ?? ""}${c?.followedHyperlink ?? ""}f${f?.majorFont ?? ""}${f?.minorFont ?? ""}${f?.majorFontAsian ?? ""}${f?.minorFontAsian ?? ""}`;
|
|
57
|
+
}
|
|
58
|
+
var DefaultTheme = class extends BaseXmlComponent {
|
|
59
|
+
xml;
|
|
60
|
+
constructor(options) {
|
|
61
|
+
super("a:theme");
|
|
62
|
+
if (!options) {
|
|
63
|
+
this.xml = DEFAULT_XML;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const key = themeKey(options);
|
|
67
|
+
const cached = customCache.get(key);
|
|
68
|
+
if (cached) this.xml = cached;
|
|
69
|
+
else {
|
|
70
|
+
const built = buildThemeXml(options);
|
|
71
|
+
customCache.set(key, built);
|
|
72
|
+
this.xml = built;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
toXml(_context) {
|
|
76
|
+
return this.xml;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
export { buildThemeXml as n, DEFAULT_COLORS as r, DefaultTheme as t };
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
const decimalNumber = (val) => {
|
|
18
|
-
if (
|
|
18
|
+
if (!Number.isFinite(val)) throw new Error(`Invalid value '${val}' specified. Must be a finite number.`);
|
|
19
19
|
return Math.floor(val);
|
|
20
20
|
};
|
|
21
21
|
/**
|
package/dist/values.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as twipsMeasureValue, a as eighthPointMeasureValue, b as unsignedDecimalNumber, c as hpsMeasureValue, d as percentageValue, f as pointMeasureValue, g as signedTwipsMeasureValue, h as signedHpsMeasureValue, i as decimalNumber, l as longHexNumber, m as shortHexNumber, n as ThemeFont, o as hexBinary, p as positiveUniversalMeasureValue, r as dateTimeValue, s as hexColorValue, t as ThemeColor, u as measurementOrPercentValue, v as uCharHexNumber, y as universalMeasureValue } from "./values-
|
|
1
|
+
import { _ as twipsMeasureValue, a as eighthPointMeasureValue, b as unsignedDecimalNumber, c as hpsMeasureValue, d as percentageValue, f as pointMeasureValue, g as signedTwipsMeasureValue, h as signedHpsMeasureValue, i as decimalNumber, l as longHexNumber, m as shortHexNumber, n as ThemeFont, o as hexBinary, p as positiveUniversalMeasureValue, r as dateTimeValue, s as hexColorValue, t as ThemeColor, u as measurementOrPercentValue, v as uCharHexNumber, y as universalMeasureValue } from "./values-BOWpTgBE.mjs";
|
|
2
2
|
export { ThemeColor, ThemeFont, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as hpsMeasureValue } from "./values-
|
|
1
|
+
import { c as hpsMeasureValue } from "./values-BOWpTgBE.mjs";
|
|
2
2
|
import { escapeXml, xml, xml2js } from "@office-open/xml";
|
|
3
3
|
//#region src/xml-components/base.ts
|
|
4
4
|
/**
|
|
@@ -11,10 +11,6 @@ var BaseXmlComponent = class {
|
|
|
11
11
|
this.rootKey = rootKey;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated Use `toXml()` instead.
|
|
15
|
-
*/
|
|
16
|
-
prepForXml(_context) {}
|
|
17
|
-
/**
|
|
18
14
|
* Direct XML serialization. Override in subclasses for zero-allocation output.
|
|
19
15
|
*/
|
|
20
16
|
toXml(_context) {
|
|
@@ -57,19 +53,6 @@ var XmlComponent = class extends BaseXmlComponent {
|
|
|
57
53
|
this.root = [];
|
|
58
54
|
}
|
|
59
55
|
/**
|
|
60
|
-
* @deprecated Use `toXml()` instead.
|
|
61
|
-
*/
|
|
62
|
-
prepForXml(context) {
|
|
63
|
-
context.stack.push(this);
|
|
64
|
-
const children = [];
|
|
65
|
-
for (const comp of this.root) if (comp instanceof BaseXmlComponent) {
|
|
66
|
-
const prepared = comp.prepForXml(context);
|
|
67
|
-
if (prepared !== void 0) children.push(prepared);
|
|
68
|
-
} else children.push(comp);
|
|
69
|
-
context.stack.pop();
|
|
70
|
-
return { [this.rootKey]: children.length ? children.length === 1 && children[0] && typeof children[0] === "object" && "_attr" in children[0] ? children[0] : children : EMPTY_OBJECT };
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
56
|
* Direct XML serialization — traverses `root` and calls `toXml()` on
|
|
74
57
|
* each child, concatenating the results into a single string.
|
|
75
58
|
*/
|
|
@@ -113,7 +96,7 @@ var XmlComponent = class extends BaseXmlComponent {
|
|
|
113
96
|
return body.length === 0 ? `<${this.rootKey}${attrStr}/>` : `<${this.rootKey}${attrStr}>${body}</${this.rootKey}>`;
|
|
114
97
|
}
|
|
115
98
|
/**
|
|
116
|
-
* @
|
|
99
|
+
* @internal
|
|
117
100
|
*/
|
|
118
101
|
addChildElement(child) {
|
|
119
102
|
this.root.push(child);
|
|
@@ -130,14 +113,6 @@ var IgnoreIfEmptyXmlComponent = class extends XmlComponent {
|
|
|
130
113
|
this.includeIfEmpty = includeIfEmpty;
|
|
131
114
|
}
|
|
132
115
|
/**
|
|
133
|
-
* @deprecated Use `toXml()` instead.
|
|
134
|
-
*/
|
|
135
|
-
prepForXml(context) {
|
|
136
|
-
if (this.includeIfEmpty) return super.prepForXml(context);
|
|
137
|
-
const result = super.prepForXml(context);
|
|
138
|
-
return result && result[this.rootKey] === EMPTY_OBJECT ? void 0 : result;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
116
|
* Suppress empty elements — super.toXml() produces a self-closing tag
|
|
142
117
|
* (`<tag/>`) when there are no child elements; IgnoreIfEmpty returns ""
|
|
143
118
|
* in that case. Child components that already override toXml() (e.g.
|
|
@@ -323,12 +298,6 @@ var ImportedRootElementAttributes = class extends XmlComponent {
|
|
|
323
298
|
this._attr = _attr;
|
|
324
299
|
if (_attr) this.root.push({ _attr });
|
|
325
300
|
}
|
|
326
|
-
/**
|
|
327
|
-
* @deprecated Use `toXml()` instead.
|
|
328
|
-
*/
|
|
329
|
-
prepForXml(_context) {
|
|
330
|
-
return { _attr: this._attr };
|
|
331
|
-
}
|
|
332
301
|
toXml(_context) {
|
|
333
302
|
return "";
|
|
334
303
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@office-open/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shared OOXML infrastructure
|
|
3
|
+
"version": "0.8.1",
|
|
4
|
+
"description": "Shared OOXML infrastructure — XML components, validators, converters, charts, and SmartArt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"core",
|
|
7
7
|
"office-open",
|
|
@@ -49,6 +49,14 @@
|
|
|
49
49
|
"./drawingml": {
|
|
50
50
|
"types": "./dist/drawingml/index.d.mts",
|
|
51
51
|
"import": "./dist/drawingml/index.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./patch": {
|
|
54
|
+
"types": "./dist/patch/index.d.mts",
|
|
55
|
+
"import": "./dist/patch/index.mjs"
|
|
56
|
+
},
|
|
57
|
+
"./theme": {
|
|
58
|
+
"types": "./dist/theme/index.d.mts",
|
|
59
|
+
"import": "./dist/theme/index.mjs"
|
|
52
60
|
}
|
|
53
61
|
},
|
|
54
62
|
"dependencies": {
|
|
@@ -56,7 +64,7 @@
|
|
|
56
64
|
"hash.js": "1.1.7",
|
|
57
65
|
"nanoid": "5.1.11",
|
|
58
66
|
"undio": "0.2.0",
|
|
59
|
-
"@office-open/xml": "0.
|
|
67
|
+
"@office-open/xml": "0.8.1"
|
|
60
68
|
},
|
|
61
69
|
"scripts": {
|
|
62
70
|
"dev": "basis build --stub",
|