@office-open/core 0.9.6 → 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.
@@ -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-4hjRdzMU.mjs";
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.6",
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.6"
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 };