@office-open/core 0.8.1 → 0.9.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 (35) hide show
  1. package/README.md +32 -60
  2. package/dist/chart/index.d.mts +2 -2
  3. package/dist/chart/index.mjs +2 -2
  4. package/dist/chart-DNpai28f.mjs +365 -0
  5. package/dist/descriptor/index.d.mts +2 -0
  6. package/dist/descriptor/index.mjs +2 -0
  7. package/dist/descriptor-57JUzfpG.mjs +282 -0
  8. package/dist/drawingml/index.d.mts +2 -2
  9. package/dist/drawingml/index.mjs +2 -2
  10. package/dist/{index-Cj2Yf5mk.d.mts → index-BKotL3AP.d.mts} +10 -7
  11. package/dist/{index-DEvpdl1o.d.mts → index-BqJRDf5H.d.mts} +1423 -1837
  12. package/dist/index-D81RV9Vc.d.mts +153 -0
  13. package/dist/{index-BCUfgp9A.d.mts → index-DmPBJwSk.d.mts} +2 -2
  14. package/dist/{index-D0N5Bw2M.d.mts → index-eu1aFQCm.d.mts} +39 -28
  15. package/dist/index-xXbaecaB.d.mts +137 -0
  16. package/dist/index.d.mts +8 -558
  17. package/dist/index.mjs +7 -2091
  18. package/dist/patch/index.d.mts +1 -1
  19. package/dist/smartart/index.d.mts +2 -2
  20. package/dist/smartart/index.mjs +2 -2
  21. package/dist/{smartart-9ZpWgmIy.mjs → smartart-DCY-Vdv7.mjs} +120 -204
  22. package/dist/src-DPuDEZYF.mjs +7477 -0
  23. package/dist/theme/index.d.mts +2 -2
  24. package/dist/theme/index.mjs +2 -2
  25. package/dist/{theme-FWD_20fH.mjs → theme-CiNzdl-9.mjs} +117 -22
  26. package/dist/{values.d.mts → util/values.d.mts} +1 -1
  27. package/dist/{values.mjs → util/values.mjs} +1 -1
  28. package/dist/{values-BOWpTgBE.mjs → values-CVIZcTRw.mjs} +1 -1
  29. package/dist/{values-COjPGYkS.d.mts → values-Dqj8cbcy.d.mts} +1 -1
  30. package/package.json +13 -10
  31. package/dist/chart-CigYrDhf.mjs +0 -1242
  32. package/dist/drawingml-B-2eEHAF.mjs +0 -7109
  33. package/dist/index-Bh6s66Up.d.mts +0 -381
  34. package/dist/index-CoTp4wVf.d.mts +0 -202
  35. package/dist/xml-components-BuFdDxHN.mjs +0 -322
@@ -0,0 +1,153 @@
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
+ /** Element descriptor — declarative XML mapping. */
23
+ interface ElementDescriptor<T> {
24
+ readonly kind: "element";
25
+ readonly tag: string;
26
+ readonly attrs?: readonly AttrSpec<T>[];
27
+ readonly content?: readonly ContentSpec<T>[];
28
+ }
29
+ /** Custom descriptor — for complex logic that doesn't fit the declarative model. */
30
+ interface CustomDescriptor<T, Ctx = WriteContext> {
31
+ readonly kind: "custom";
32
+ stringify(value: T, ctx: Ctx): string | undefined;
33
+ parse(el: Element, ctx: ReadContext): T;
34
+ }
35
+ /** Union type for all descriptors. */
36
+ type Descriptor<T> = ElementDescriptor<T> | CustomDescriptor<T>;
37
+ interface AttrSpec<T> {
38
+ /** Property key in the Options object. */
39
+ readonly key: keyof T & string;
40
+ /** XML attribute name (e.g. "w:val"). */
41
+ readonly xmlName: string;
42
+ /** Default value — omitted during stringify when equal. */
43
+ readonly default?: unknown;
44
+ /** Encode a JS value to an XML attribute string. Return undefined to skip. */
45
+ readonly encode?: (v: any) => string | undefined;
46
+ /** Decode an XML attribute string to a JS value. */
47
+ readonly decode?: (raw: string) => any;
48
+ }
49
+ /** Single child element mapped to a property. */
50
+ interface ChildSpec<T> {
51
+ readonly kind: "child";
52
+ readonly key: keyof T & string;
53
+ readonly tag: string;
54
+ readonly desc: Descriptor<any>;
55
+ }
56
+ /** Multiple child elements of the same tag mapped to an array property. */
57
+ interface ChildrenSpec<T> {
58
+ readonly kind: "children";
59
+ readonly key: keyof T & string;
60
+ readonly tag: string;
61
+ readonly desc: Descriptor<any>;
62
+ }
63
+ /** Union child — one of several possible child elements. */
64
+ interface UnionSpec<T> {
65
+ readonly kind: "union";
66
+ readonly key: keyof T & string;
67
+ readonly variants: readonly UnionVariant[];
68
+ }
69
+ /** Text content mapped to a property. */
70
+ interface TextSpec<T> {
71
+ readonly kind: "text";
72
+ readonly key: keyof T & string;
73
+ }
74
+ interface UnionVariant {
75
+ readonly tag: string;
76
+ readonly match: (opts: any) => boolean;
77
+ readonly desc: Descriptor<any>;
78
+ }
79
+ /** Discriminated union of all content spec types. */
80
+ type ContentSpec<T> = ChildSpec<T> | ChildrenSpec<T> | UnionSpec<T> | TextSpec<T> | CustomDescriptor<T>;
81
+ //#endregion
82
+ //#region src/descriptor/builder.d.ts
83
+ declare function element$1<T extends object>(tag: string): DescriptorBuilder<T>;
84
+ declare class DescriptorBuilder<T extends object> {
85
+ private readonly _tag;
86
+ private readonly _attrs;
87
+ private readonly _content;
88
+ constructor(tag: string);
89
+ /** Add an attribute mapping. */
90
+ attr(key: keyof T & string, xmlName: string, opts?: {
91
+ readonly default?: unknown;
92
+ readonly encode?: (v: any) => string | undefined;
93
+ readonly decode?: (raw: string) => any;
94
+ }): this;
95
+ /** Add a single child element mapping. */
96
+ child(key: keyof T & string, tag: string, desc: ChildSpec<T>["desc"]): this;
97
+ /** Add a repeating child element mapping. */
98
+ children(key: keyof T & string, tag: string, desc: ChildrenSpec<T>["desc"]): this;
99
+ /** Add a union (one-of-several) child mapping. */
100
+ union(key: keyof T & string, variants: readonly UnionVariant[]): this;
101
+ /** Add a text content mapping. */
102
+ text(key: keyof T & string): this;
103
+ /** Add a custom content handler. */
104
+ custom(spec: CustomDescriptor<T>): this;
105
+ /** Build the immutable ElementDescriptor. */
106
+ build(): ElementDescriptor<T>;
107
+ }
108
+ //#endregion
109
+ //#region src/descriptor/runtime.d.ts
110
+ /**
111
+ * Serialize an Options object to an XML string using its descriptor.
112
+ * Returns `undefined` when an optional element should be omitted.
113
+ */
114
+ declare function stringify<T>(desc: Descriptor<T>, value: T, ctx: WriteContext): string | undefined;
115
+ /**
116
+ * Parse an XML Element into an Options object using its descriptor.
117
+ */
118
+ declare function parse<T>(desc: Descriptor<T>, el: Element, ctx: ReadContext): T;
119
+ //#endregion
120
+ //#region src/descriptor/helpers.d.ts
121
+ /**
122
+ * OOXML-specific encode/decode helpers for descriptors.
123
+ *
124
+ * XML traversal helpers (findChild, etc.) are in @office-open/xml utils.
125
+ * This file only contains OOXML value encoding/decoding.
126
+ *
127
+ * @module
128
+ */
129
+ /** Encode boolean for CT_OnOff: true → omit val, false → "0". */
130
+ declare const boolEncode: (v: boolean | undefined) => string | undefined;
131
+ /** Decode CT_OnOff: absent or "true"/"1" → true, "0"/"false" → false. */
132
+ declare const boolDecode: (raw: string) => boolean;
133
+ /** Create an enum encoder from a JS↔XML mapping. */
134
+ declare const enumEncode: (map: Record<string, string>) => (v: string | undefined) => string | undefined;
135
+ /** Create an enum decoder from a JS↔XML mapping (inverted). */
136
+ declare const enumDecode: (map: Record<string, string>) => (raw: string) => string;
137
+ //#endregion
138
+ //#region src/descriptor/registry.d.ts
139
+ declare class DescriptorRegistry {
140
+ private static readonly _map;
141
+ /** Register a descriptor with its XML tag. */
142
+ static register(tag: string, desc: Descriptor<any>): void;
143
+ /** Look up a descriptor by XML tag. */
144
+ static get(tag: string): Descriptor<any> | undefined;
145
+ /** Get all registered tags. */
146
+ static tags(): ReadonlySet<string>;
147
+ /** Check if a tag is registered. */
148
+ static has(tag: string): boolean;
149
+ /** Get the number of registered descriptors. */
150
+ static get size(): number;
151
+ }
152
+ //#endregion
153
+ export { TextSpec as _, enumEncode as a, ReadContext as b, DescriptorBuilder as c, ChildSpec as d, ChildrenSpec as f, ElementDescriptor as g, Descriptor as h, enumDecode as i, element$1 as l, CustomDescriptor as m, boolDecode as n, parse as o, ContentSpec as p, boolEncode as r, stringify as s, DescriptorRegistry as t, AttrSpec as u, UnionSpec as v, WriteContext as x, UnionVariant as y };
@@ -51,7 +51,7 @@ interface ElementWrapper {
51
51
  }
52
52
  interface RenderedParagraphNode {
53
53
  readonly text: string;
54
- readonly runs: readonly IRenderedRunNode[];
54
+ readonly runs: readonly RenderedRunNode[];
55
55
  readonly index: number;
56
56
  readonly pathToParagraph: readonly number[];
57
57
  }
@@ -63,7 +63,7 @@ type IParts = {
63
63
  readonly text: string;
64
64
  readonly index: number;
65
65
  } & StartAndEnd;
66
- type IRenderedRunNode = {
66
+ type RenderedRunNode = {
67
67
  readonly text: string;
68
68
  readonly parts: readonly IParts[];
69
69
  readonly index: number;
@@ -1,5 +1,3 @@
1
- import { b as XmlComponent } from "./index-CoTp4wVf.mjs";
2
-
3
1
  //#region src/smartart/categories.d.ts
4
2
  /** Layout ID → OOXML category type */
5
3
  declare const LAYOUT_CATEGORIES: Record<string, string>;
@@ -30,19 +28,30 @@ declare const DEFAULT_DRAWING_XML: string;
30
28
  //#endregion
31
29
  //#region src/smartart/data-model/connection.d.ts
32
30
  /**
33
- * dgm:cxn — SmartArt data model connection (edge).
31
+ * dgm:cxn — SmartArt data model connection (edge) XML stringifier.
34
32
  */
35
- declare class Connection extends XmlComponent {
36
- constructor(modelId: string, srcId: string, destId: string, type?: string, srcOrd?: number, destOrd?: number, parTransId?: string, sibTransId?: string, presId?: string);
37
- }
33
+ declare function stringifyConnection(opts: {
34
+ modelId: string | number;
35
+ srcId: string | number;
36
+ destId: string | number;
37
+ type?: string;
38
+ srcOrd?: number;
39
+ destOrd?: number;
40
+ parTransId?: string;
41
+ sibTransId?: string;
42
+ presId?: string;
43
+ }): string;
38
44
  //#endregion
39
45
  //#region src/smartart/data-model/data-model.d.ts
40
46
  /**
41
- * CT_DataModel — the complete data model for a SmartArt diagram.
47
+ * CT_DataModel XML stringifier assembles complete SmartArt data model XML.
48
+ *
49
+ * @module
42
50
  */
43
- declare class DataModel extends XmlComponent {
44
- constructor(points: readonly XmlComponent[], connections: readonly Connection[]);
45
- }
51
+ /**
52
+ * Build the complete dgm:dataModel XML from pre-serialized point and connection strings.
53
+ */
54
+ declare function stringifyDataModel(points: readonly string[], connections: readonly string[]): string;
46
55
  //#endregion
47
56
  //#region src/smartart/data-model/point.d.ts
48
57
  interface PointPropertySetOptions {
@@ -82,34 +91,35 @@ interface PointPropertySetOptions {
82
91
  readonly colorStyleCategoryId?: string;
83
92
  }
84
93
  /**
85
- * dgm:pt — SmartArt data model point (node).
94
+ * dgm:pt — SmartArt data model point (node) XML stringifier.
86
95
  */
87
- declare class Point extends XmlComponent {
88
- constructor(modelId: string, text: string, type?: string, propertySet?: PointPropertySetOptions);
89
- }
96
+ declare function stringifyPoint(modelId: string | number, text: string, type?: string, propertySet?: PointPropertySetOptions): string;
90
97
  /**
91
- * Transition point (parTrans or sibTrans) no text body, references a connection.
98
+ * dgm:pt — transition point (parTrans or sibTrans) XML stringifier.
92
99
  */
93
- declare class TransPoint extends XmlComponent {
94
- constructor(modelId: string, type: string, cxnId: string);
95
- }
100
+ declare function stringifyTransPoint(modelId: string, type: string, cxnId: string): string;
96
101
  //#endregion
97
102
  //#region src/smartart/smartart-collection.d.ts
103
+ /**
104
+ * SmartArt data and collection for document generation.
105
+ *
106
+ * @module
107
+ */
98
108
  interface SmartArtData {
99
- readonly key: string;
100
- readonly dataModel: DataModel;
101
- readonly layout: string;
102
- readonly style: string;
103
- readonly color: string;
109
+ key: string;
110
+ dataModelXml: string;
111
+ layout: string;
112
+ style: string;
113
+ color: string;
104
114
  }
105
115
  /**
106
116
  * Manages SmartArt parts in a document.
107
117
  */
108
118
  declare class SmartArtCollection {
109
- private readonly map;
119
+ private map;
110
120
  constructor();
111
121
  addSmartArt(key: string, data: SmartArtData): void;
112
- get array(): readonly SmartArtData[];
122
+ get array(): SmartArtData[];
113
123
  }
114
124
  //#endregion
115
125
  //#region src/smartart/tree-to-model.d.ts
@@ -118,8 +128,9 @@ interface TreeNode {
118
128
  readonly children?: readonly TreeNode[];
119
129
  }
120
130
  /**
121
- * Creates a DataModel from tree nodes with layout/style/color settings.
131
+ * Creates SmartArt data model XML from tree nodes with layout/style/color settings.
132
+ * Returns the XML string body (no XML declaration).
122
133
  */
123
- declare const createDataModel: (nodes: readonly TreeNode[], layout?: string, style?: string, color?: string) => DataModel;
134
+ declare const createDataModel: (nodes: readonly TreeNode[], layout?: string, style?: string, color?: string) => string;
124
135
  //#endregion
125
- export { Point as a, DataModel as c, getColorXml as d, getLayoutXml as f, STYLE_CATEGORIES as g, LAYOUT_CATEGORIES as h, SmartArtData as i, Connection as l, COLOR_CATEGORIES as m, createDataModel as n, PointPropertySetOptions as o, getStyleXml as p, SmartArtCollection as r, TransPoint as s, TreeNode as t, DEFAULT_DRAWING_XML as u };
136
+ export { PointPropertySetOptions as a, stringifyDataModel as c, getColorXml as d, getLayoutXml as f, STYLE_CATEGORIES as g, LAYOUT_CATEGORIES as h, SmartArtData as i, stringifyConnection as l, COLOR_CATEGORIES as m, createDataModel as n, stringifyPoint as o, getStyleXml as p, SmartArtCollection as r, stringifyTransPoint as s, TreeNode as t, DEFAULT_DRAWING_XML as u };
@@ -0,0 +1,137 @@
1
+ import { m as CustomDescriptor } from "./index-D81RV9Vc.mjs";
2
+
3
+ //#region src/chart/chart-collection.d.ts
4
+ /**
5
+ * Chart data and collection for document generation.
6
+ *
7
+ * @module
8
+ */
9
+ interface ChartData {
10
+ key: string;
11
+ chartSpaceXml: string;
12
+ }
13
+ declare class ChartCollection {
14
+ private map;
15
+ constructor();
16
+ addChart(key: string, chartData: ChartData): void;
17
+ get array(): ChartData[];
18
+ }
19
+ //#endregion
20
+ //#region src/chart/types.d.ts
21
+ /**
22
+ * Chart type definitions — interfaces and constants.
23
+ *
24
+ * Class implementations have been removed; all chart XML generation
25
+ * goes through chart-descriptors.ts (stringify/parse path).
26
+ *
27
+ * @module
28
+ */
29
+ interface BubbleSeriesData {
30
+ readonly name: string;
31
+ readonly xValues: readonly number[];
32
+ readonly yValues: readonly number[];
33
+ readonly bubbleSize: readonly number[];
34
+ }
35
+ declare const TrendlineType: {
36
+ readonly EXP: "exp";
37
+ readonly LINEAR: "linear";
38
+ readonly LOG: "log";
39
+ readonly MOVING_AVG: "movingAvg";
40
+ readonly POLY: "poly";
41
+ readonly POWER: "power";
42
+ };
43
+ type TrendlineType = (typeof TrendlineType)[keyof typeof TrendlineType];
44
+ interface TrendlineOptions {
45
+ readonly type?: TrendlineType;
46
+ readonly name?: string;
47
+ readonly order?: number;
48
+ readonly period?: number;
49
+ readonly forward?: number;
50
+ readonly backward?: number;
51
+ readonly intercept?: number;
52
+ readonly dispRSqr?: boolean;
53
+ readonly dispEq?: boolean;
54
+ }
55
+ declare const ErrorBarDirection: {
56
+ readonly BOTH: "both";
57
+ readonly X: "x";
58
+ readonly Y: "y";
59
+ };
60
+ type ErrorBarDirection = (typeof ErrorBarDirection)[keyof typeof ErrorBarDirection];
61
+ declare const ErrorBarType: {
62
+ readonly BOTH: "both";
63
+ readonly MINUS: "minus";
64
+ readonly PLUS: "plus";
65
+ };
66
+ type ErrorBarType = (typeof ErrorBarType)[keyof typeof ErrorBarType];
67
+ declare const ErrorValueType: {
68
+ readonly CUST: "cust";
69
+ readonly FIXED: "fixedVal";
70
+ readonly PERCENTAGE: "percentage";
71
+ readonly STD_DEV: "stdDev";
72
+ readonly STD_ERR: "stdErr";
73
+ };
74
+ type ErrorValueType = (typeof ErrorValueType)[keyof typeof ErrorValueType];
75
+ interface ErrorBarOptions {
76
+ readonly direction?: ErrorBarDirection;
77
+ readonly barType?: ErrorBarType;
78
+ readonly valueType?: ErrorValueType;
79
+ readonly value?: number;
80
+ }
81
+ declare const DataLabelPosition: {
82
+ readonly BEST_FIT: "bestFit";
83
+ readonly B: "b";
84
+ readonly CTRL: "ctr";
85
+ readonly IN_BASE: "inBase";
86
+ readonly IN_END: "inEnd";
87
+ readonly L: "l";
88
+ readonly OUT_END: "outEnd";
89
+ readonly R: "r";
90
+ readonly T: "t";
91
+ };
92
+ type DataLabelPosition = (typeof DataLabelPosition)[keyof typeof DataLabelPosition];
93
+ interface DataLabelsOptions {
94
+ readonly position?: DataLabelPosition;
95
+ readonly showVal?: boolean;
96
+ readonly showCatName?: boolean;
97
+ readonly showSerName?: boolean;
98
+ readonly showPercent?: boolean;
99
+ readonly showBubbleSize?: boolean;
100
+ readonly showLeaderLines?: boolean;
101
+ }
102
+ interface ChartSeriesData {
103
+ readonly name: string;
104
+ readonly values: readonly number[];
105
+ readonly trendlines?: readonly TrendlineOptions[];
106
+ readonly errorBars?: ErrorBarOptions;
107
+ readonly dataLabels?: DataLabelsOptions;
108
+ }
109
+ type ChartType = "column" | "bar" | "line" | "pie" | "area" | "scatter" | "bubble" | "doughnut" | "radar" | "stock" | "surface";
110
+ type AxisChartType = Exclude<ChartType, "bubble">;
111
+ interface ChartSpaceOptions {
112
+ readonly title?: string;
113
+ readonly type: ChartType;
114
+ readonly categories?: readonly string[];
115
+ readonly series: readonly ChartSeriesData[] | readonly BubbleSeriesData[];
116
+ readonly showLegend?: boolean;
117
+ readonly style?: number;
118
+ readonly threeD?: boolean;
119
+ }
120
+ declare const TimeUnit: {
121
+ readonly DAYS: "days";
122
+ readonly MONTHS: "months";
123
+ readonly YEARS: "years";
124
+ };
125
+ type TimeUnit = (typeof TimeUnit)[keyof typeof TimeUnit];
126
+ interface View3DOptions {
127
+ readonly rotX?: number;
128
+ readonly rotY?: number;
129
+ readonly depthPercent?: number;
130
+ readonly rAngAx?: boolean;
131
+ readonly perspective?: number;
132
+ }
133
+ //#endregion
134
+ //#region src/chart/chart-descriptors.d.ts
135
+ declare const chartSpaceDesc: CustomDescriptor<ChartSpaceOptions>;
136
+ //#endregion
137
+ export { ChartCollection as _, ChartSpaceOptions as a, DataLabelsOptions as c, ErrorBarType as d, ErrorValueType as f, View3DOptions as g, TrendlineType as h, ChartSeriesData as i, ErrorBarDirection as l, TrendlineOptions as m, AxisChartType as n, ChartType as o, TimeUnit as p, BubbleSeriesData as r, DataLabelPosition as s, chartSpaceDesc as t, ErrorBarOptions as u, ChartData as v };