@office-open/core 0.9.7 → 0.9.8
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/dist/chart/index.d.mts +1 -1
- package/dist/descriptor/index.d.mts +2 -2
- package/dist/descriptor/index.mjs +2 -2
- package/dist/descriptor-TtMXoZgS.mjs +443 -0
- package/dist/drawingml/index.d.mts +2 -2
- package/dist/drawingml/index.mjs +2 -2
- package/dist/{index-DMw7eid7.d.mts → index-BEQ12eyX.d.mts} +42 -42
- package/dist/{index-CDYC3mxJ.d.mts → index-CeVhA1an.d.mts} +871 -262
- package/dist/{index-eu1aFQCm.d.mts → index-CsQP7Cl4.d.mts} +36 -36
- package/dist/{index-DmPBJwSk.d.mts → index-DYy8l709.d.mts} +34 -34
- package/dist/index-L82O3q6V.d.mts +170 -0
- package/dist/{index-4hjRdzMU.d.mts → index-vEeWkbm5.d.mts} +20 -20
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +3 -3
- package/dist/patch/index.d.mts +1 -1
- package/dist/smartart/index.d.mts +1 -1
- package/dist/{src-DlZssiRY.mjs → src-CSka9ln4.mjs} +985 -145
- package/dist/theme/index.d.mts +1 -1
- package/package.json +2 -2
- package/dist/descriptor-DcQm32dg.mjs +0 -71
- package/dist/index-C4r2WLEy.d.mts +0 -73
package/dist/theme/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
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-vEeWkbm5.mjs";
|
|
2
2
|
export { type ColorSchemeOptions, DEFAULT_COLORS, type FontSchemeOptions, type ThemeOptions, buildThemeXml, createThemeXml, themeDesc };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@office-open/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"description": "Shared OOXML infrastructure — XML components, validators, converters, charts, and SmartArt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"core",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@noble/hashes": "2.2.0",
|
|
68
68
|
"fflate": "0.8.3",
|
|
69
|
-
"@office-open/xml": "0.9.
|
|
69
|
+
"@office-open/xml": "0.9.8"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"dev": "basis build --stub",
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
//#region src/descriptor/runtime.ts
|
|
2
|
-
/**
|
|
3
|
-
* Serialize an Options object to an XML string using its descriptor.
|
|
4
|
-
* Returns `undefined` when an optional element should be omitted.
|
|
5
|
-
*/
|
|
6
|
-
function stringify(desc, value, ctx) {
|
|
7
|
-
return desc.stringify(value, ctx);
|
|
8
|
-
}
|
|
9
|
-
/** Parse an XML Element into an Options object using its descriptor. */
|
|
10
|
-
function parse(desc, el, ctx) {
|
|
11
|
-
return desc.parse(el, ctx);
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/descriptor/helpers.ts
|
|
15
|
-
/**
|
|
16
|
-
* OOXML-specific encode/decode helpers for descriptors.
|
|
17
|
-
*
|
|
18
|
-
* XML traversal helpers (findChild, etc.) are in @office-open/xml utils.
|
|
19
|
-
* This file only contains OOXML value encoding/decoding.
|
|
20
|
-
*
|
|
21
|
-
* @module
|
|
22
|
-
*/
|
|
23
|
-
/** Encode boolean for CT_OnOff: true → omit val, false → "0". */
|
|
24
|
-
const boolEncode = (v) => {
|
|
25
|
-
if (v === void 0) return void 0;
|
|
26
|
-
return v ? void 0 : "0";
|
|
27
|
-
};
|
|
28
|
-
/** Decode CT_OnOff: absent or "true"/"1" → true, "0"/"false" → false. */
|
|
29
|
-
const boolDecode = (raw) => raw !== "0" && raw !== "false";
|
|
30
|
-
/** Create an enum encoder from a JS↔XML mapping. */
|
|
31
|
-
const enumEncode = (map) => (v) => {
|
|
32
|
-
if (v === void 0) return void 0;
|
|
33
|
-
return map[v] ?? v;
|
|
34
|
-
};
|
|
35
|
-
/** Create an enum decoder from a JS↔XML mapping (inverted). */
|
|
36
|
-
const enumDecode = (map) => {
|
|
37
|
-
const inv = invertRecord(map);
|
|
38
|
-
return (raw) => inv[raw] ?? raw;
|
|
39
|
-
};
|
|
40
|
-
function invertRecord(map) {
|
|
41
|
-
const result = {};
|
|
42
|
-
for (const key of Object.keys(map)) result[map[key]] = key;
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/descriptor/registry.ts
|
|
47
|
-
var DescriptorRegistry = class DescriptorRegistry {
|
|
48
|
-
static _map = /* @__PURE__ */ new Map();
|
|
49
|
-
/** Register a descriptor with its XML tag. */
|
|
50
|
-
static register(tag, desc) {
|
|
51
|
-
DescriptorRegistry._map.set(tag, desc);
|
|
52
|
-
}
|
|
53
|
-
/** Look up a descriptor by XML tag. */
|
|
54
|
-
static get(tag) {
|
|
55
|
-
return DescriptorRegistry._map.get(tag);
|
|
56
|
-
}
|
|
57
|
-
/** Get all registered tags. */
|
|
58
|
-
static tags() {
|
|
59
|
-
return new Set(DescriptorRegistry._map.keys());
|
|
60
|
-
}
|
|
61
|
-
/** Check if a tag is registered. */
|
|
62
|
-
static has(tag) {
|
|
63
|
-
return DescriptorRegistry._map.has(tag);
|
|
64
|
-
}
|
|
65
|
-
/** Get the number of registered descriptors. */
|
|
66
|
-
static get size() {
|
|
67
|
-
return DescriptorRegistry._map.size;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
//#endregion
|
|
71
|
-
export { enumEncode as a, enumDecode as i, boolDecode as n, parse as o, boolEncode as r, stringify as s, DescriptorRegistry as t };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Element } from "@office-open/xml";
|
|
2
|
-
|
|
3
|
-
//#region src/descriptor/context.d.ts
|
|
4
|
-
/** Context passed during stringify (write path). */
|
|
5
|
-
interface WriteContext {
|
|
6
|
-
/** Register a relationship and return its rId. */
|
|
7
|
-
addRelationship(type: string, target: string, mode?: string): string;
|
|
8
|
-
/** Add a media file and return its reference. */
|
|
9
|
-
addMedia(data: Uint8Array, type: string): string;
|
|
10
|
-
}
|
|
11
|
-
/** Context passed during parse (parse path). */
|
|
12
|
-
interface ReadContext {
|
|
13
|
-
/** Resolve a relationship rId to its target path. */
|
|
14
|
-
resolveRelationship(rId: string): string | undefined;
|
|
15
|
-
/** Get a parsed XML part by path. */
|
|
16
|
-
getPart(path: string): Element | undefined;
|
|
17
|
-
/** Get raw binary data (images, media, etc.) by path. */
|
|
18
|
-
getRaw(path: string): Uint8Array | undefined;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/descriptor/types.d.ts
|
|
22
|
-
/** Custom descriptor — hand-written stringify/parse for an OOXML part. */
|
|
23
|
-
interface CustomDescriptor<T, Ctx = WriteContext> {
|
|
24
|
-
readonly kind: "custom";
|
|
25
|
-
stringify(value: T, ctx: Ctx): string | undefined;
|
|
26
|
-
parse(el: Element, ctx: ReadContext): T;
|
|
27
|
-
}
|
|
28
|
-
/** Alias for "any descriptor" — retained for call-site readability. */
|
|
29
|
-
type Descriptor<T> = CustomDescriptor<T>;
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/descriptor/runtime.d.ts
|
|
32
|
-
/**
|
|
33
|
-
* Serialize an Options object to an XML string using its descriptor.
|
|
34
|
-
* Returns `undefined` when an optional element should be omitted.
|
|
35
|
-
*/
|
|
36
|
-
declare function stringify$1<T>(desc: CustomDescriptor<T>, value: T, ctx: WriteContext): string | undefined;
|
|
37
|
-
/** Parse an XML Element into an Options object using its descriptor. */
|
|
38
|
-
declare function parse<T>(desc: CustomDescriptor<T>, el: Element, ctx: ReadContext): T;
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/descriptor/helpers.d.ts
|
|
41
|
-
/**
|
|
42
|
-
* OOXML-specific encode/decode helpers for descriptors.
|
|
43
|
-
*
|
|
44
|
-
* XML traversal helpers (findChild, etc.) are in @office-open/xml utils.
|
|
45
|
-
* This file only contains OOXML value encoding/decoding.
|
|
46
|
-
*
|
|
47
|
-
* @module
|
|
48
|
-
*/
|
|
49
|
-
/** Encode boolean for CT_OnOff: true → omit val, false → "0". */
|
|
50
|
-
declare const boolEncode: (v: boolean | undefined) => string | undefined;
|
|
51
|
-
/** Decode CT_OnOff: absent or "true"/"1" → true, "0"/"false" → false. */
|
|
52
|
-
declare const boolDecode: (raw: string) => boolean;
|
|
53
|
-
/** Create an enum encoder from a JS↔XML mapping. */
|
|
54
|
-
declare const enumEncode: (map: Record<string, string>) => (v: string | undefined) => string | undefined;
|
|
55
|
-
/** Create an enum decoder from a JS↔XML mapping (inverted). */
|
|
56
|
-
declare const enumDecode: (map: Record<string, string>) => (raw: string) => string;
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/descriptor/registry.d.ts
|
|
59
|
-
declare class DescriptorRegistry {
|
|
60
|
-
private static readonly _map;
|
|
61
|
-
/** Register a descriptor with its XML tag. */
|
|
62
|
-
static register(tag: string, desc: Descriptor<any>): void;
|
|
63
|
-
/** Look up a descriptor by XML tag. */
|
|
64
|
-
static get(tag: string): Descriptor<any> | undefined;
|
|
65
|
-
/** Get all registered tags. */
|
|
66
|
-
static tags(): ReadonlySet<string>;
|
|
67
|
-
/** Check if a tag is registered. */
|
|
68
|
-
static has(tag: string): boolean;
|
|
69
|
-
/** Get the number of registered descriptors. */
|
|
70
|
-
static get size(): number;
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
export { enumEncode as a, CustomDescriptor as c, WriteContext as d, enumDecode as i, Descriptor as l, boolDecode as n, parse as o, boolEncode as r, stringify$1 as s, DescriptorRegistry as t, ReadContext as u };
|