@office-open/core 0.8.0 → 0.9.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.
- package/README.md +32 -60
- package/dist/chart/index.d.mts +2 -2
- package/dist/chart/index.mjs +2 -2
- package/dist/chart-DNpai28f.mjs +365 -0
- package/dist/descriptor/index.d.mts +2 -0
- package/dist/descriptor/index.mjs +2 -0
- package/dist/descriptor-DKmR7pw-.mjs +282 -0
- package/dist/drawingml/index.d.mts +2 -2
- package/dist/drawingml/index.mjs +2 -2
- package/dist/index-BI-1SKm5.d.mts +153 -0
- package/dist/{index-Cj2Yf5mk.d.mts → index-DByjp6ug.d.mts} +10 -7
- package/dist/index-DNH2sizc.d.mts +137 -0
- package/dist/{index-C-DvIxek.d.mts → index-RWXzxibP.d.mts} +1420 -1866
- package/dist/{index-D0N5Bw2M.d.mts → index-eu1aFQCm.d.mts} +39 -28
- package/dist/index.d.mts +7 -538
- package/dist/index.mjs +7 -2077
- package/dist/smartart/index.d.mts +2 -2
- package/dist/smartart/index.mjs +2 -2
- package/dist/{smartart-BAhTD2yA.mjs → smartart-DCY-Vdv7.mjs} +120 -204
- package/dist/src-CU2AFKyt.mjs +7413 -0
- package/dist/theme/index.d.mts +2 -2
- package/dist/theme/index.mjs +2 -2
- package/dist/{theme-DmJXjgQs.mjs → theme-CiNzdl-9.mjs} +117 -22
- package/dist/{values.d.mts → util/values.d.mts} +1 -1
- package/dist/{values.mjs → util/values.mjs} +1 -1
- package/dist/{values-zMCu5EoQ.mjs → values-CVIZcTRw.mjs} +2 -2
- package/dist/{values-COjPGYkS.d.mts → values-Dqj8cbcy.d.mts} +1 -1
- package/package.json +12 -7
- package/dist/chart-BtEtdK2K.mjs +0 -1266
- package/dist/drawingml-anlfMLLZ.mjs +0 -7132
- package/dist/index-Bh6s66Up.d.mts +0 -381
- package/dist/index-CoTp4wVf.d.mts +0 -202
- package/dist/xml-components-DEU24Y1T.mjs +0 -322
package/dist/theme/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { type ColorSchemeOptions, DEFAULT_COLORS,
|
|
1
|
+
import { a as ColorSchemeOptions, i as createThemeXml, n as DEFAULT_COLORS, o as FontSchemeOptions, r as buildThemeXml, s as ThemeOptions, t as themeDesc } from "../index-DByjp6ug.mjs";
|
|
2
|
+
export { type ColorSchemeOptions, DEFAULT_COLORS, type FontSchemeOptions, type ThemeOptions, buildThemeXml, createThemeXml, themeDesc };
|
package/dist/theme/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
export { DEFAULT_COLORS,
|
|
1
|
+
import { i as DEFAULT_COLORS, n as createThemeXml, r as buildThemeXml, t as themeDesc } from "../theme-CiNzdl-9.mjs";
|
|
2
|
+
export { DEFAULT_COLORS, buildThemeXml, createThemeXml, themeDesc };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findChild } from "@office-open/xml";
|
|
2
2
|
//#region src/theme/default-colors.ts
|
|
3
3
|
/** Office 2016+ default theme colors (hex without #). */
|
|
4
4
|
const DEFAULT_COLORS = {
|
|
@@ -41,10 +41,10 @@ function buildThemeXml(options) {
|
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/theme/default-theme.ts
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Theme XML generation — pure function with caching.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* Replaces the DefaultTheme class with a functionally equivalent
|
|
47
|
+
* pure function. Caches by serialized options key.
|
|
48
48
|
*
|
|
49
49
|
* @module
|
|
50
50
|
*/
|
|
@@ -55,26 +55,121 @@ function themeKey(o) {
|
|
|
55
55
|
const f = o.fonts;
|
|
56
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
57
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Generate theme XML string from options.
|
|
60
|
+
* Returns cached default when no options provided.
|
|
61
|
+
*/
|
|
62
|
+
function createThemeXml(options) {
|
|
63
|
+
if (!options) return DEFAULT_XML;
|
|
64
|
+
const key = themeKey(options);
|
|
65
|
+
const cached = customCache.get(key);
|
|
66
|
+
if (cached) return cached;
|
|
67
|
+
const built = buildThemeXml(options);
|
|
68
|
+
customCache.set(key, built);
|
|
69
|
+
return built;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/theme/theme-descriptors.ts
|
|
73
|
+
/**
|
|
74
|
+
* Theme descriptors — bidirectional mapping between ThemeOptions and theme XML.
|
|
75
|
+
*
|
|
76
|
+
* @module
|
|
77
|
+
*/
|
|
78
|
+
/** Color scheme XML tag → ThemeOptions.colors key mapping. */
|
|
79
|
+
const COLOR_TAGS = [
|
|
80
|
+
{
|
|
81
|
+
tag: "a:dk1",
|
|
82
|
+
key: "dark1"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
tag: "a:lt1",
|
|
86
|
+
key: "light1"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
tag: "a:dk2",
|
|
90
|
+
key: "dark2"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
tag: "a:lt2",
|
|
94
|
+
key: "light2"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
tag: "a:accent1",
|
|
98
|
+
key: "accent1"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
tag: "a:accent2",
|
|
102
|
+
key: "accent2"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
tag: "a:accent3",
|
|
106
|
+
key: "accent3"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
tag: "a:accent4",
|
|
110
|
+
key: "accent4"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
tag: "a:accent5",
|
|
114
|
+
key: "accent5"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
tag: "a:accent6",
|
|
118
|
+
key: "accent6"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
tag: "a:hlink",
|
|
122
|
+
key: "hyperlink"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
tag: "a:folHlink",
|
|
126
|
+
key: "followedHyperlink"
|
|
127
|
+
}
|
|
128
|
+
];
|
|
129
|
+
/** Read the hex color value from a color element (a:dk1/a:lt1 may be sysClr or srgbClr). */
|
|
130
|
+
function readColorValue(el) {
|
|
131
|
+
if (!el) return void 0;
|
|
132
|
+
const srgb = findChild(el, "a:srgbClr");
|
|
133
|
+
if (srgb) return String(srgb.attributes?.["val"] ?? "");
|
|
134
|
+
const sysClr = findChild(el, "a:sysClr");
|
|
135
|
+
if (sysClr) return String(sysClr.attributes?.["lastClr"] ?? "");
|
|
136
|
+
}
|
|
137
|
+
const themeDesc = {
|
|
138
|
+
kind: "custom",
|
|
139
|
+
stringify(opts, _ctx) {
|
|
140
|
+
return buildThemeXml(opts);
|
|
141
|
+
},
|
|
142
|
+
parse(el, _ctx) {
|
|
143
|
+
const result = {};
|
|
144
|
+
const name = el.attributes?.["name"];
|
|
145
|
+
if (name) result.name = String(name);
|
|
146
|
+
const themeElements = findChild(el, "a:themeElements");
|
|
147
|
+
const clrScheme = themeElements ? findChild(themeElements, "a:clrScheme") : void 0;
|
|
148
|
+
if (clrScheme) {
|
|
149
|
+
const colors = {};
|
|
150
|
+
for (const { tag, key } of COLOR_TAGS) {
|
|
151
|
+
const value = readColorValue(findChild(clrScheme, tag));
|
|
152
|
+
if (value) colors[key] = value;
|
|
153
|
+
}
|
|
154
|
+
if (Object.keys(colors).length > 0) result.colors = colors;
|
|
65
155
|
}
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
156
|
+
const fontScheme = themeElements ? findChild(themeElements, "a:fontScheme") : void 0;
|
|
157
|
+
if (fontScheme) {
|
|
158
|
+
const majorFontEl = findChild(fontScheme, "a:majorFont");
|
|
159
|
+
const minorFontEl = findChild(fontScheme, "a:minorFont");
|
|
160
|
+
const majorLatin = majorFontEl ? findChild(majorFontEl, "a:latin") : void 0;
|
|
161
|
+
const minorLatin = minorFontEl ? findChild(minorFontEl, "a:latin") : void 0;
|
|
162
|
+
const majorTypeface = majorLatin?.attributes?.["typeface"];
|
|
163
|
+
const minorTypeface = minorLatin?.attributes?.["typeface"];
|
|
164
|
+
if (majorTypeface || minorTypeface) {
|
|
165
|
+
const fonts = {};
|
|
166
|
+
if (majorTypeface) fonts.majorFont = String(majorTypeface);
|
|
167
|
+
if (minorTypeface) fonts.minorFont = String(minorTypeface);
|
|
168
|
+
result.fonts = fonts;
|
|
169
|
+
}
|
|
73
170
|
}
|
|
74
|
-
|
|
75
|
-
toXml(_context) {
|
|
76
|
-
return this.xml;
|
|
171
|
+
return result;
|
|
77
172
|
}
|
|
78
173
|
};
|
|
79
174
|
//#endregion
|
|
80
|
-
export {
|
|
175
|
+
export { DEFAULT_COLORS as i, createThemeXml as n, buildThemeXml as r, themeDesc as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "
|
|
1
|
+
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "../values-Dqj8cbcy.mjs";
|
|
2
2
|
export { Percentage, PositivePercentage, PositiveUniversalMeasure, RelativeMeasure, ThemeColor, ThemeFont, UniversalMeasure, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber };
|
|
@@ -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 "
|
|
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-CVIZcTRw.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
|
-
//#region src/values.ts
|
|
1
|
+
//#region src/util/values.ts
|
|
2
2
|
/**
|
|
3
3
|
* Validates and converts a number to an integer (decimal number).
|
|
4
4
|
*
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@office-open/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Shared OOXML infrastructure — XML components, validators, converters, charts, and SmartArt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"core",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Demo Macro",
|
|
19
19
|
"email": "abc@imst.xyz",
|
|
20
|
-
"url": "https://
|
|
20
|
+
"url": "https://www.demomacro.com/"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"types": "./dist/index.d.mts",
|
|
35
35
|
"import": "./dist/index.mjs"
|
|
36
36
|
},
|
|
37
|
-
"./values": {
|
|
38
|
-
"types": "./dist/values.d.mts",
|
|
39
|
-
"import": "./dist/values.mjs"
|
|
37
|
+
"./util/values": {
|
|
38
|
+
"types": "./dist/util/values.d.mts",
|
|
39
|
+
"import": "./dist/util/values.mjs"
|
|
40
40
|
},
|
|
41
41
|
"./smartart": {
|
|
42
42
|
"types": "./dist/smartart/index.d.mts",
|
|
@@ -50,6 +50,10 @@
|
|
|
50
50
|
"types": "./dist/drawingml/index.d.mts",
|
|
51
51
|
"import": "./dist/drawingml/index.mjs"
|
|
52
52
|
},
|
|
53
|
+
"./descriptor": {
|
|
54
|
+
"types": "./dist/descriptor/index.d.mts",
|
|
55
|
+
"import": "./dist/descriptor/index.mjs"
|
|
56
|
+
},
|
|
53
57
|
"./patch": {
|
|
54
58
|
"types": "./dist/patch/index.d.mts",
|
|
55
59
|
"import": "./dist/patch/index.mjs"
|
|
@@ -64,12 +68,13 @@
|
|
|
64
68
|
"hash.js": "1.1.7",
|
|
65
69
|
"nanoid": "5.1.11",
|
|
66
70
|
"undio": "0.2.0",
|
|
67
|
-
"@office-open/xml": "0.
|
|
71
|
+
"@office-open/xml": "0.9.0"
|
|
68
72
|
},
|
|
69
73
|
"scripts": {
|
|
70
74
|
"dev": "basis build --stub",
|
|
71
75
|
"build": "vp pack",
|
|
72
76
|
"test": "vp test run",
|
|
73
|
-
"check": "vp check --fix"
|
|
77
|
+
"check": "vp check --fix",
|
|
78
|
+
"bench": "vp test bench"
|
|
74
79
|
}
|
|
75
80
|
}
|