@syncfusion/ej2-office-common 35.1.37

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 (147) hide show
  1. package/.eslintrc.json +263 -0
  2. package/.prettierrc.json +5 -0
  3. package/README.md +167 -0
  4. package/api-extractor.json +35 -0
  5. package/core.js +4 -0
  6. package/dist/ej2-office-common.umd.min.js +11 -0
  7. package/dist/ej2-office-common.umd.min.js.map +1 -0
  8. package/dist/es6/ej2-office-common.es2015.js +6585 -0
  9. package/dist/es6/ej2-office-common.es2015.js.map +1 -0
  10. package/dist/es6/ej2-office-common.es5.js +7955 -0
  11. package/dist/es6/ej2-office-common.es5.js.map +1 -0
  12. package/dist/global/ej2-office-common.min.js +11 -0
  13. package/dist/global/ej2-office-common.min.js.map +1 -0
  14. package/dist/global/index.d.ts +14 -0
  15. package/encryption.js +4 -0
  16. package/features.js +4 -0
  17. package/global.json +6 -0
  18. package/index.js +4 -0
  19. package/license +10 -0
  20. package/nuget.config +7 -0
  21. package/package.json +23 -0
  22. package/src/all.d.ts +41 -0
  23. package/src/all.js +38 -0
  24. package/src/core/index.d.ts +6 -0
  25. package/src/core/index.js +6 -0
  26. package/src/core/xml/index.d.ts +7 -0
  27. package/src/core/xml/index.js +6 -0
  28. package/src/core/xml/model.d.ts +71 -0
  29. package/src/core/xml/model.js +20 -0
  30. package/src/encryption/agile-constants.d.ts +61 -0
  31. package/src/encryption/agile-constants.js +71 -0
  32. package/src/encryption/agile-encryption-info.d.ts +46 -0
  33. package/src/encryption/agile-encryption-info.js +333 -0
  34. package/src/encryption/agile-password.d.ts +8 -0
  35. package/src/encryption/agile-password.js +58 -0
  36. package/src/encryption/cfb-reader.d.ts +11 -0
  37. package/src/encryption/cfb-reader.js +345 -0
  38. package/src/encryption/crypto-primitives.d.ts +74 -0
  39. package/src/encryption/crypto-primitives.js +302 -0
  40. package/src/encryption/decrypt-encrypted-package.d.ts +16 -0
  41. package/src/encryption/decrypt-encrypted-package.js +138 -0
  42. package/src/encryption/encryption-info-xml.d.ts +21 -0
  43. package/src/encryption/encryption-info-xml.js +282 -0
  44. package/src/encryption/errors.d.ts +66 -0
  45. package/src/encryption/errors.js +124 -0
  46. package/src/encryption/index.d.ts +35 -0
  47. package/src/encryption/index.js +100 -0
  48. package/src/features/diagrams/constants.d.ts +83 -0
  49. package/src/features/diagrams/constants.js +101 -0
  50. package/src/features/diagrams/diagram-data-model.d.ts +148 -0
  51. package/src/features/diagrams/diagram-data-model.js +446 -0
  52. package/src/features/diagrams/diagram-parsers.d.ts +28 -0
  53. package/src/features/diagrams/diagram-parsers.js +182 -0
  54. package/src/features/diagrams/diagram-serializers.d.ts +20 -0
  55. package/src/features/diagrams/diagram-serializers.js +110 -0
  56. package/src/features/diagrams/diagram-views.d.ts +60 -0
  57. package/src/features/diagrams/diagram-views.js +213 -0
  58. package/src/features/diagrams/element-tree.d.ts +55 -0
  59. package/src/features/diagrams/element-tree.js +197 -0
  60. package/src/features/diagrams/errors.d.ts +17 -0
  61. package/src/features/diagrams/errors.js +59 -0
  62. package/src/features/diagrams/index.d.ts +17 -0
  63. package/src/features/diagrams/index.js +17 -0
  64. package/src/features/diagrams/smart-art-catalog.d.ts +107 -0
  65. package/src/features/diagrams/smart-art-catalog.js +422 -0
  66. package/src/features/diagrams/smart-art-diagram.d.ts +96 -0
  67. package/src/features/diagrams/smart-art-diagram.js +258 -0
  68. package/src/features/index.d.ts +11 -0
  69. package/src/features/index.js +11 -0
  70. package/src/features/ink/constants.d.ts +54 -0
  71. package/src/features/ink/constants.js +54 -0
  72. package/src/features/ink/index.d.ts +18 -0
  73. package/src/features/ink/index.js +15 -0
  74. package/src/features/ink/ink-effects.d.ts +35 -0
  75. package/src/features/ink/ink-effects.js +45 -0
  76. package/src/features/ink/ink-model.d.ts +237 -0
  77. package/src/features/ink/ink-model.js +406 -0
  78. package/src/features/ink/ink-parser.d.ts +59 -0
  79. package/src/features/ink/ink-parser.js +671 -0
  80. package/src/features/ink/ink-serializer.d.ts +16 -0
  81. package/src/features/ink/ink-serializer.js +281 -0
  82. package/src/features/ink/ink-units.d.ts +33 -0
  83. package/src/features/ink/ink-units.js +92 -0
  84. package/src/features/ink/ink-xml.d.ts +26 -0
  85. package/src/features/ink/ink-xml.js +165 -0
  86. package/src/features/ink/trace-codec.d.ts +127 -0
  87. package/src/features/ink/trace-codec.js +266 -0
  88. package/src/features/mathml/constants.d.ts +47 -0
  89. package/src/features/mathml/constants.js +47 -0
  90. package/src/features/mathml/errors.d.ts +50 -0
  91. package/src/features/mathml/errors.js +69 -0
  92. package/src/features/mathml/index.d.ts +30 -0
  93. package/src/features/mathml/index.js +22 -0
  94. package/src/features/mathml/math-factory.d.ts +26 -0
  95. package/src/features/mathml/math-factory.js +568 -0
  96. package/src/features/mathml/model/controls.d.ts +896 -0
  97. package/src/features/mathml/model/controls.js +1541 -0
  98. package/src/features/mathml/model/enums.d.ts +153 -0
  99. package/src/features/mathml/model/enums.js +133 -0
  100. package/src/features/mathml/model/math-element.d.ts +173 -0
  101. package/src/features/mathml/model/math-element.js +315 -0
  102. package/src/features/mathml/model/roots.d.ts +82 -0
  103. package/src/features/mathml/model/roots.js +177 -0
  104. package/src/features/mathml/openxml.d.ts +56 -0
  105. package/src/features/mathml/openxml.js +87 -0
  106. package/src/features/mathml/parse/math-parser.d.ts +43 -0
  107. package/src/features/mathml/parse/math-parser.js +636 -0
  108. package/src/features/mathml/serialize/math-serializer.d.ts +34 -0
  109. package/src/features/mathml/serialize/math-serializer.js +749 -0
  110. package/src/features/smart-art/diagram-xml.d.ts +63 -0
  111. package/src/features/smart-art/diagram-xml.js +459 -0
  112. package/src/features/smart-art/errors.d.ts +24 -0
  113. package/src/features/smart-art/errors.js +47 -0
  114. package/src/features/smart-art/index.d.ts +26 -0
  115. package/src/features/smart-art/index.js +26 -0
  116. package/src/features/smart-art/minimal-samples.d.ts +18 -0
  117. package/src/features/smart-art/minimal-samples.js +40 -0
  118. package/src/features/smart-art/mutators.d.ts +60 -0
  119. package/src/features/smart-art/mutators.js +566 -0
  120. package/src/features/smart-art/namespaces.d.ts +153 -0
  121. package/src/features/smart-art/namespaces.js +163 -0
  122. package/src/features/smart-art/package-graph.d.ts +61 -0
  123. package/src/features/smart-art/package-graph.js +413 -0
  124. package/src/features/smart-art/parse-colors.d.ts +19 -0
  125. package/src/features/smart-art/parse-colors.js +39 -0
  126. package/src/features/smart-art/parse-data.d.ts +21 -0
  127. package/src/features/smart-art/parse-data.js +121 -0
  128. package/src/features/smart-art/parse-layout.d.ts +20 -0
  129. package/src/features/smart-art/parse-layout.js +40 -0
  130. package/src/features/smart-art/parse-rel-ids.d.ts +71 -0
  131. package/src/features/smart-art/parse-rel-ids.js +233 -0
  132. package/src/features/smart-art/parse-style.d.ts +19 -0
  133. package/src/features/smart-art/parse-style.js +39 -0
  134. package/src/features/smart-art/point-text.d.ts +80 -0
  135. package/src/features/smart-art/point-text.js +424 -0
  136. package/src/features/smart-art/register.d.ts +33 -0
  137. package/src/features/smart-art/register.js +95 -0
  138. package/src/features/smart-art/serialize.d.ts +40 -0
  139. package/src/features/smart-art/serialize.js +48 -0
  140. package/src/features/smart-art/types.d.ts +403 -0
  141. package/src/features/smart-art/types.js +28 -0
  142. package/src/global.js +1 -0
  143. package/src/index.d.ts +21 -0
  144. package/src/index.js +22 -0
  145. package/tsconfig.build.json +13 -0
  146. package/tsconfig.harness.json +32 -0
  147. package/tslint.json +111 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Feature-local XML tree for DrawingML diagram parts.
3
+ *
4
+ * @remarks
5
+ * Encryption's EncryptionInfo parser drops text nodes and is unsuitable for
6
+ * `dgm:pt/dgm:t` text bodies. This helper keeps element children **and** text,
7
+ * rejects DTD/entity expansion, and applies nesting/attribute/text limits.
8
+ * Namespace URI is authoritative; prefixes are preserved for stable serialize.
9
+ *
10
+ * @private
11
+ */
12
+ /** Attribute on a diagram XML element. */
13
+ export interface DiagramXmlAttribute {
14
+ readonly prefix: string;
15
+ readonly localName: string;
16
+ readonly namespaceUri: string;
17
+ readonly value: string;
18
+ /** Original `name` or `prefix:name` as written in source. */
19
+ readonly qName: string;
20
+ }
21
+ /** Element node. */
22
+ export interface DiagramXmlElement {
23
+ readonly kind: 'element';
24
+ readonly prefix: string;
25
+ readonly localName: string;
26
+ readonly namespaceUri: string;
27
+ readonly qName: string;
28
+ readonly attributes: ReadonlyArray<DiagramXmlAttribute>;
29
+ readonly children: ReadonlyArray<DiagramXmlNode>;
30
+ }
31
+ /** Text node (significant or whitespace). */
32
+ export interface DiagramXmlText {
33
+ readonly kind: 'text';
34
+ readonly value: string;
35
+ }
36
+ export declare type DiagramXmlNode = DiagramXmlElement | DiagramXmlText;
37
+ export interface DiagramXmlParseLimits {
38
+ readonly maxDepth?: number;
39
+ readonly maxAttributesPerElement?: number;
40
+ readonly maxTextNodeLength?: number;
41
+ }
42
+ /**
43
+ * Parses a single-root diagram part XML document.
44
+ *
45
+ * @throws {DiagramPartError} Malformed XML or missing root.
46
+ */
47
+ export declare function parseDiagramXml(xmlText: string, limits?: DiagramXmlParseLimits): DiagramXmlElement;
48
+ /**
49
+ * Serializes a diagram XML element tree to a UTF-8 XML document string.
50
+ */
51
+ export declare function serializeDiagramXml(root: DiagramXmlElement, withDecl?: boolean): string;
52
+ /** Returns unprefixed or namespace-aware attribute value. */
53
+ export declare function getAttribute(el: DiagramXmlElement, localName: string, namespaceUri?: string): string | undefined;
54
+ /** Element children only (skips text). */
55
+ export declare function elementChildren(el: DiagramXmlElement): ReadonlyArray<DiagramXmlElement>;
56
+ /** First child element with local name + namespace. */
57
+ export declare function findChild(el: DiagramXmlElement, localName: string, namespaceUri: string): DiagramXmlElement | undefined;
58
+ /** All child elements with local name + namespace. */
59
+ export declare function findChildren(el: DiagramXmlElement, localName: string, namespaceUri: string): ReadonlyArray<DiagramXmlElement>;
60
+ /**
61
+ * Deep-clones an element tree (for immutable public part wrappers).
62
+ */
63
+ export declare function cloneElement(el: DiagramXmlElement): DiagramXmlElement;
@@ -0,0 +1,459 @@
1
+ /**
2
+ * Feature-local XML tree for DrawingML diagram parts.
3
+ *
4
+ * @remarks
5
+ * Encryption's EncryptionInfo parser drops text nodes and is unsuitable for
6
+ * `dgm:pt/dgm:t` text bodies. This helper keeps element children **and** text,
7
+ * rejects DTD/entity expansion, and applies nesting/attribute/text limits.
8
+ * Namespace URI is authoritative; prefixes are preserved for stable serialize.
9
+ *
10
+ * @private
11
+ */
12
+ var __assign = (this && this.__assign) || function () {
13
+ __assign = Object.assign || function(t) {
14
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
15
+ s = arguments[i];
16
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
17
+ t[p] = s[p];
18
+ }
19
+ return t;
20
+ };
21
+ return __assign.apply(this, arguments);
22
+ };
23
+ var __read = (this && this.__read) || function (o, n) {
24
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
25
+ if (!m) return o;
26
+ var i = m.call(o), r, ar = [], e;
27
+ try {
28
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
29
+ }
30
+ catch (error) { e = { error: error }; }
31
+ finally {
32
+ try {
33
+ if (r && !r.done && (m = i["return"])) m.call(i);
34
+ }
35
+ finally { if (e) throw e.error; }
36
+ }
37
+ return ar;
38
+ };
39
+ var __spread = (this && this.__spread) || function () {
40
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
41
+ return ar;
42
+ };
43
+ var __values = (this && this.__values) || function (o) {
44
+ var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
45
+ if (m) return m.call(o);
46
+ return {
47
+ next: function () {
48
+ if (o && i >= o.length) o = void 0;
49
+ return { value: o && o[i++], done: !o };
50
+ }
51
+ };
52
+ };
53
+ import { DiagramPartError } from './errors';
54
+ var DEFAULT_MAX_DEPTH = 256;
55
+ var DEFAULT_MAX_ATTRS = 4096;
56
+ var DEFAULT_MAX_TEXT = 32 * 1024 * 1024;
57
+ var XMLNS_NS = 'http://www.w3.org/2000/xmlns/';
58
+ var XML_NS = 'http://www.w3.org/XML/1998/namespace';
59
+ /**
60
+ * Parses a single-root diagram part XML document.
61
+ *
62
+ * @throws {DiagramPartError} Malformed XML or missing root.
63
+ */
64
+ export function parseDiagramXml(xmlText, limits) {
65
+ if (limits === void 0) { limits = {}; }
66
+ if (/<!DOCTYPE/i.test(xmlText) || /<!ENTITY/i.test(xmlText)) {
67
+ throw new DiagramPartError('Diagram XML must not contain DTD or entities');
68
+ }
69
+ var maxDepth = (limits.maxDepth != null ? limits.maxDepth : DEFAULT_MAX_DEPTH);
70
+ var maxAttrs = (limits.maxAttributesPerElement != null ? limits.maxAttributesPerElement : DEFAULT_MAX_ATTRS);
71
+ var maxText = (limits.maxTextNodeLength != null ? limits.maxTextNodeLength : DEFAULT_MAX_TEXT);
72
+ var i = 0;
73
+ var length = xmlText.length;
74
+ var skipWs = function () {
75
+ while (i < length) {
76
+ var c = xmlText.charCodeAt(i);
77
+ if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d) {
78
+ i += 1;
79
+ }
80
+ else {
81
+ break;
82
+ }
83
+ }
84
+ };
85
+ var peek = function () { return (i < length ? xmlText.charAt(i) : ''); };
86
+ var startsWith = function (s) { return xmlText.startsWith(s, i); };
87
+ var readName = function () {
88
+ var start = i;
89
+ while (i < length) {
90
+ var c = xmlText.charAt(i);
91
+ if (/[A-Za-z0-9:_.-]/.test(c)) {
92
+ i += 1;
93
+ }
94
+ else {
95
+ break;
96
+ }
97
+ }
98
+ if (i === start) {
99
+ throw new DiagramPartError('Diagram XML is invalid: expected name');
100
+ }
101
+ return xmlText.slice(start, i);
102
+ };
103
+ var decodeEntities = function (raw) {
104
+ return raw
105
+ .replace(/&lt;/g, '<')
106
+ .replace(/&gt;/g, '>')
107
+ .replace(/&quot;/g, '"')
108
+ .replace(/&apos;/g, "'")
109
+ .replace(/&amp;/g, '&');
110
+ };
111
+ var readAttrValue = function () {
112
+ var quote = peek();
113
+ if (quote !== '"' && quote !== "'") {
114
+ throw new DiagramPartError('Diagram XML is invalid: attribute value');
115
+ }
116
+ i += 1;
117
+ var start = i;
118
+ while (i < length && xmlText[i] !== quote) {
119
+ i += 1;
120
+ if (i - start > maxText) {
121
+ throw new DiagramPartError('Diagram XML text/attribute exceeds limit');
122
+ }
123
+ }
124
+ if (i >= length) {
125
+ throw new DiagramPartError('Diagram XML is invalid: unclosed attribute');
126
+ }
127
+ var value = xmlText.slice(start, i);
128
+ i += 1;
129
+ return decodeEntities(value);
130
+ };
131
+ var resolveQName = function (qName, nsStack, isAttr) {
132
+ var colon = qName.indexOf(':');
133
+ var prefix = colon === -1 ? '' : qName.slice(0, colon);
134
+ var localName = colon === -1 ? qName : qName.slice(colon + 1);
135
+ if (prefix === 'xmlns') {
136
+ return { prefix: prefix, localName: localName, namespaceUri: XMLNS_NS };
137
+ }
138
+ if (isAttr && prefix === '') {
139
+ if (localName === 'xmlns') {
140
+ return { prefix: '', localName: 'xmlns', namespaceUri: XMLNS_NS };
141
+ }
142
+ return { prefix: '', localName: localName, namespaceUri: '' };
143
+ }
144
+ if (prefix === 'xml') {
145
+ return { prefix: prefix, localName: localName, namespaceUri: XML_NS };
146
+ }
147
+ for (var s = nsStack.length - 1; s >= 0; s--) {
148
+ var frameAt = nsStack[s];
149
+ if (frameAt === undefined) {
150
+ continue;
151
+ }
152
+ var uri = frameAt.get(prefix);
153
+ if (uri !== undefined) {
154
+ return { prefix: prefix, localName: localName, namespaceUri: uri };
155
+ }
156
+ }
157
+ return { prefix: prefix, localName: localName, namespaceUri: '' };
158
+ };
159
+ var parseElement = function (nsStack, depth) {
160
+ if (depth > maxDepth) {
161
+ throw new DiagramPartError('Diagram XML nesting depth exceeds limit');
162
+ }
163
+ if (peek() !== '<') {
164
+ throw new DiagramPartError('Diagram XML is invalid: expected element');
165
+ }
166
+ i += 1;
167
+ if (peek() === '/') {
168
+ throw new DiagramPartError('Diagram XML is invalid: unexpected end tag');
169
+ }
170
+ var rawName = readName();
171
+ var frame = new Map();
172
+ var pendingAttrs = [];
173
+ skipWs();
174
+ while (peek() !== '>' && peek() !== '/' && i < length) {
175
+ var attrQName = readName();
176
+ skipWs();
177
+ if (peek() !== '=') {
178
+ throw new DiagramPartError('Diagram XML is invalid: expected = after attribute name');
179
+ }
180
+ i += 1;
181
+ skipWs();
182
+ var value = readAttrValue();
183
+ pendingAttrs.push({ qName: attrQName, value: value });
184
+ if (attrQName === 'xmlns') {
185
+ frame.set('', value);
186
+ }
187
+ else if (attrQName.startsWith('xmlns:')) {
188
+ frame.set(attrQName.slice(6), value);
189
+ }
190
+ skipWs();
191
+ if (pendingAttrs.length > maxAttrs) {
192
+ throw new DiagramPartError('Diagram XML attribute count exceeds limit');
193
+ }
194
+ }
195
+ var childStack = __spread(nsStack, [frame]);
196
+ var nameResolved = resolveQName(rawName, childStack, false);
197
+ var attributes = pendingAttrs.map(function (a) {
198
+ var r = resolveQName(a.qName, childStack, true);
199
+ return {
200
+ prefix: r.prefix,
201
+ localName: r.localName,
202
+ namespaceUri: r.namespaceUri,
203
+ value: a.value,
204
+ qName: a.qName,
205
+ };
206
+ });
207
+ var selfClosing = false;
208
+ if (startsWith('/>')) {
209
+ i += 2;
210
+ selfClosing = true;
211
+ }
212
+ else if (peek() === '>') {
213
+ i += 1;
214
+ }
215
+ else {
216
+ throw new DiagramPartError('Diagram XML is invalid: malformed start tag');
217
+ }
218
+ var children = [];
219
+ if (!selfClosing) {
220
+ for (;;) {
221
+ if (i >= length) {
222
+ throw new DiagramPartError('Diagram XML is invalid: unclosed element');
223
+ }
224
+ if (startsWith('</')) {
225
+ i += 2;
226
+ var endName = readName();
227
+ skipWs();
228
+ if (peek() !== '>') {
229
+ throw new DiagramPartError('Diagram XML is invalid: malformed end tag');
230
+ }
231
+ i += 1;
232
+ if (endName !== rawName) {
233
+ throw new DiagramPartError("Diagram XML is invalid: end tag " + endName + " does not match " + rawName);
234
+ }
235
+ break;
236
+ }
237
+ if (startsWith('<!--')) {
238
+ var end = xmlText.indexOf('-->', i + 4);
239
+ if (end < 0) {
240
+ throw new DiagramPartError('Diagram XML is invalid: unclosed comment');
241
+ }
242
+ i = end + 3;
243
+ continue;
244
+ }
245
+ if (startsWith('<?')) {
246
+ var end = xmlText.indexOf('?>', i + 2);
247
+ if (end < 0) {
248
+ throw new DiagramPartError('Diagram XML is invalid: unclosed processing instruction');
249
+ }
250
+ i = end + 2;
251
+ continue;
252
+ }
253
+ if (startsWith('<![CDATA[')) {
254
+ var end = xmlText.indexOf(']]>', i + 9);
255
+ if (end < 0) {
256
+ throw new DiagramPartError('Diagram XML is invalid: unclosed CDATA');
257
+ }
258
+ var text = xmlText.slice(i + 9, end);
259
+ if (text.length > maxText) {
260
+ throw new DiagramPartError('Diagram XML text exceeds limit');
261
+ }
262
+ children.push({ kind: 'text', value: text });
263
+ i = end + 3;
264
+ continue;
265
+ }
266
+ if (peek() === '<') {
267
+ children.push(parseElement(childStack, depth + 1));
268
+ continue;
269
+ }
270
+ var textStart = i;
271
+ while (i < length && xmlText[i] !== '<') {
272
+ i += 1;
273
+ if (i - textStart > maxText) {
274
+ throw new DiagramPartError('Diagram XML text exceeds limit');
275
+ }
276
+ }
277
+ var rawText = xmlText.slice(textStart, i);
278
+ if (rawText.length > 0) {
279
+ children.push({ kind: 'text', value: decodeEntities(rawText) });
280
+ }
281
+ }
282
+ }
283
+ return { kind: 'element',
284
+ prefix: nameResolved.prefix,
285
+ localName: nameResolved.localName,
286
+ namespaceUri: nameResolved.namespaceUri,
287
+ qName: rawName,
288
+ attributes: attributes,
289
+ children: children,
290
+ };
291
+ };
292
+ skipWs();
293
+ if (startsWith('\uFEFF')) {
294
+ i += 1;
295
+ skipWs();
296
+ }
297
+ while (startsWith('<?') || startsWith('<!--')) {
298
+ if (startsWith('<?')) {
299
+ var end = xmlText.indexOf('?>', i + 2);
300
+ if (end < 0) {
301
+ throw new DiagramPartError('Diagram XML is invalid: unclosed declaration');
302
+ }
303
+ i = end + 2;
304
+ }
305
+ else {
306
+ var end = xmlText.indexOf('-->', i + 4);
307
+ if (end < 0) {
308
+ throw new DiagramPartError('Diagram XML is invalid: unclosed comment');
309
+ }
310
+ i = end + 3;
311
+ }
312
+ skipWs();
313
+ }
314
+ var root = parseElement([new Map()], 1);
315
+ skipWs();
316
+ if (i < length) {
317
+ throw new DiagramPartError('Diagram XML is invalid: trailing content');
318
+ }
319
+ return root;
320
+ }
321
+ var escapeText = function (value) {
322
+ return value
323
+ .replace(/&/g, '&amp;')
324
+ .replace(/</g, '&lt;')
325
+ .replace(/>/g, '&gt;');
326
+ };
327
+ var escapeAttr = function (value) {
328
+ return escapeText(value).replace(/"/g, '&quot;');
329
+ };
330
+ /**
331
+ * Serializes a diagram XML element tree to a UTF-8 XML document string.
332
+ */
333
+ export function serializeDiagramXml(root, withDecl) {
334
+ if (withDecl === void 0) { withDecl = true; }
335
+ var body = serializeNode(root);
336
+ return withDecl ? "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + body : body;
337
+ }
338
+ function serializeNode(node) {
339
+ var e_1, _a;
340
+ if (node.kind === 'text') {
341
+ return escapeText(node.value);
342
+ }
343
+ var attrParts = [];
344
+ try {
345
+ for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) {
346
+ var a = _c.value;
347
+ attrParts.push(a.qName + "=\"" + escapeAttr(a.value) + "\"");
348
+ }
349
+ }
350
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
351
+ finally {
352
+ try {
353
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
354
+ }
355
+ finally { if (e_1) throw e_1.error; }
356
+ }
357
+ var attrStr = attrParts.length > 0 ? " " + attrParts.join(' ') : '';
358
+ if (node.children.length === 0) {
359
+ return "<" + node.qName + attrStr + "/>";
360
+ }
361
+ var inner = node.children.map(serializeNode).join('');
362
+ return "<" + node.qName + attrStr + ">" + inner + "</" + node.qName + ">";
363
+ }
364
+ /** Returns unprefixed or namespace-aware attribute value. */
365
+ export function getAttribute(el, localName, namespaceUri) {
366
+ if (namespaceUri === void 0) { namespaceUri = ''; }
367
+ var e_2, _a;
368
+ try {
369
+ for (var _b = __values(el.attributes), _c = _b.next(); !_c.done; _c = _b.next()) {
370
+ var a = _c.value;
371
+ if (a.localName === localName && a.namespaceUri === namespaceUri) {
372
+ return a.value;
373
+ }
374
+ }
375
+ }
376
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
377
+ finally {
378
+ try {
379
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
380
+ }
381
+ finally { if (e_2) throw e_2.error; }
382
+ }
383
+ return undefined;
384
+ }
385
+ /** Element children only (skips text). */
386
+ export function elementChildren(el) {
387
+ var e_3, _a;
388
+ var out = [];
389
+ try {
390
+ for (var _b = __values(el.children), _c = _b.next(); !_c.done; _c = _b.next()) {
391
+ var c = _c.value;
392
+ if (c.kind === 'element') {
393
+ out.push(c);
394
+ }
395
+ }
396
+ }
397
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
398
+ finally {
399
+ try {
400
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
401
+ }
402
+ finally { if (e_3) throw e_3.error; }
403
+ }
404
+ return out;
405
+ }
406
+ /** First child element with local name + namespace. */
407
+ export function findChild(el, localName, namespaceUri) {
408
+ var e_4, _a;
409
+ try {
410
+ for (var _b = __values(el.children), _c = _b.next(); !_c.done; _c = _b.next()) {
411
+ var c = _c.value;
412
+ if (c.kind === 'element' && c.localName === localName && c.namespaceUri === namespaceUri) {
413
+ return c;
414
+ }
415
+ }
416
+ }
417
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
418
+ finally {
419
+ try {
420
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
421
+ }
422
+ finally { if (e_4) throw e_4.error; }
423
+ }
424
+ return undefined;
425
+ }
426
+ /** All child elements with local name + namespace. */
427
+ export function findChildren(el, localName, namespaceUri) {
428
+ var e_5, _a;
429
+ var out = [];
430
+ try {
431
+ for (var _b = __values(el.children), _c = _b.next(); !_c.done; _c = _b.next()) {
432
+ var c = _c.value;
433
+ if (c.kind === 'element' && c.localName === localName && c.namespaceUri === namespaceUri) {
434
+ out.push(c);
435
+ }
436
+ }
437
+ }
438
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
439
+ finally {
440
+ try {
441
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
442
+ }
443
+ finally { if (e_5) throw e_5.error; }
444
+ }
445
+ return out;
446
+ }
447
+ /**
448
+ * Deep-clones an element tree (for immutable public part wrappers).
449
+ */
450
+ export function cloneElement(el) {
451
+ return { kind: 'element',
452
+ prefix: el.prefix,
453
+ localName: el.localName,
454
+ namespaceUri: el.namespaceUri,
455
+ qName: el.qName,
456
+ attributes: el.attributes.map(function (a) { return (__assign({}, a)); }),
457
+ children: el.children.map(function (c) { return (c.kind === 'text' ? __assign({}, c) : cloneElement(c)); }),
458
+ };
459
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Errors for DrawingML diagram (SmartArt) part parse and serialize.
3
+ *
4
+ * @remarks
5
+ * Explicit part APIs throw when required schema structure is absent (e.g. missing
6
+ * `ptLst` on `dataModel`). Package-level opaque preserve of unknown parts is a
7
+ * separate path and does not use these errors for unmodeled content.
8
+ *
9
+ * @public
10
+ */
11
+ /**
12
+ * Thrown when diagram part XML cannot be parsed or fails a required schema check
13
+ * for an explicit SmartArt API call.
14
+ *
15
+ * @public
16
+ */
17
+ export declare class DiagramPartError extends Error {
18
+ /**
19
+ * Creates a diagram part error.
20
+ *
21
+ * @param message - Human-readable description (no secrets).
22
+ */
23
+ constructor(message: string);
24
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Errors for DrawingML diagram (SmartArt) part parse and serialize.
3
+ *
4
+ * @remarks
5
+ * Explicit part APIs throw when required schema structure is absent (e.g. missing
6
+ * `ptLst` on `dataModel`). Package-level opaque preserve of unknown parts is a
7
+ * separate path and does not use these errors for unmodeled content.
8
+ *
9
+ * @public
10
+ */
11
+ var __extends = (this && this.__extends) || (function () {
12
+ var extendStatics = function (d, b) {
13
+ extendStatics = Object.setPrototypeOf ||
14
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16
+ return extendStatics(d, b);
17
+ };
18
+ return function (d, b) {
19
+ extendStatics(d, b);
20
+ function __() { this.constructor = d; }
21
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22
+ };
23
+ })();
24
+ /**
25
+ * Thrown when diagram part XML cannot be parsed or fails a required schema check
26
+ * for an explicit SmartArt API call.
27
+ *
28
+ * @public
29
+ */
30
+ var DiagramPartError = /** @class */ (function (_super) {
31
+ __extends(DiagramPartError, _super);
32
+ /**
33
+ * Creates a diagram part error.
34
+ *
35
+ * @param message - Human-readable description (no secrets).
36
+ */
37
+ function DiagramPartError(message) {
38
+ var _newTarget = this.constructor;
39
+ var _this = _super.call(this, message) || this;
40
+ _this.name = 'DiagramPartError';
41
+ // ES5 / AMD emit: restore prototype so `instanceof DiagramPartError` works in browsers.
42
+ Object.setPrototypeOf(_this, _newTarget.prototype);
43
+ return _this;
44
+ }
45
+ return DiagramPartError;
46
+ }(Error));
47
+ export { DiagramPartError };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Optional SmartArt / DrawingML diagram common layer.
3
+ *
4
+ * @remarks
5
+ * Host-neutral package constants, part parse/serialize, and content-type handlers
6
+ * shared by PowerPoint, Word, and Excel consumers. This module must not export
7
+ * slide, document-body, worksheet, or other host product types.
8
+ *
9
+ * Mapping: `docs/ooxml-mapping/smart-art.md`
10
+ * Requirement: `docs/requirements/smart-art-shared-common.md`
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ export { DIAGRAM_COLORS_CONTENT_TYPE, DIAGRAM_COLORS_RELATIONSHIP_TYPE, DIAGRAM_CONTENT_TYPES, DIAGRAM_DATA_CONTENT_TYPE, DIAGRAM_DATA_RELATIONSHIP_TYPE, DIAGRAM_GRAPHIC_DATA_URI, DIAGRAM_LAYOUT_CONTENT_TYPE, DIAGRAM_LAYOUT_RELATIONSHIP_TYPE, DIAGRAM_NAMESPACE, DIAGRAM_QUICK_STYLE_RELATIONSHIP_TYPE, DIAGRAM_RELATIONSHIP_TYPES, DIAGRAM_STYLE_CONTENT_TYPE, DRAWINGML_MAIN_NAMESPACE, OFFICE_DOCUMENT_RELATIONSHIPS_NAMESPACE, OFFICE_IMAGE_RELATIONSHIP_TYPE, } from './namespaces';
15
+ export { DiagramPartError } from './errors';
16
+ export { DiagramPointType, CreateDiagramInstanceOptions, CreateDiagramInstanceResult, CreateDiagramInstanceSeeds, DiagramColorsPart, DiagramConnection, DiagramDataPart, DiagramGraphicHook, DiagramInstance, DiagramLayoutPart, DiagramPackageGraph, DiagramPackagePart, DiagramPackageRelationship, DiagramPartHandler, DiagramPartNames, DiagramPoint, DiagramRelIds, DiagramStylePart, GetDiagramInstanceOptions, RemoveDiagramInstanceOptions, RemoveDiagramInstanceResult, } from './types';
17
+ export { parseDiagramData } from './parse-data';
18
+ export { parseDiagramColors } from './parse-colors';
19
+ export { parseDiagramLayout } from './parse-layout';
20
+ export { parseDiagramStyle } from './parse-style';
21
+ export { findDiagramRelIds, parseDiagramRelIds } from './parse-rel-ids';
22
+ export { serializeDiagramColors, serializeDiagramData, serializeDiagramLayout, serializeDiagramStyle, } from './serialize';
23
+ export { enumerateDiagramInstances, getDiagramInstance, listDiagramParts, normalizePartName, } from './package-graph';
24
+ export { createDiagramInstance, removeDiagramInstance } from './mutators';
25
+ export { diagramPoint, diagramPointText, listDiagramConnections, listDiagramPoints, withDiagramPointText, } from './point-text';
26
+ export { getDiagramPartHandler, registerSmartArtFeature } from './register';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Optional SmartArt / DrawingML diagram common layer.
3
+ *
4
+ * @remarks
5
+ * Host-neutral package constants, part parse/serialize, and content-type handlers
6
+ * shared by PowerPoint, Word, and Excel consumers. This module must not export
7
+ * slide, document-body, worksheet, or other host product types.
8
+ *
9
+ * Mapping: `docs/ooxml-mapping/smart-art.md`
10
+ * Requirement: `docs/requirements/smart-art-shared-common.md`
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ export { DIAGRAM_COLORS_CONTENT_TYPE, DIAGRAM_COLORS_RELATIONSHIP_TYPE, DIAGRAM_CONTENT_TYPES, DIAGRAM_DATA_CONTENT_TYPE, DIAGRAM_DATA_RELATIONSHIP_TYPE, DIAGRAM_GRAPHIC_DATA_URI, DIAGRAM_LAYOUT_CONTENT_TYPE, DIAGRAM_LAYOUT_RELATIONSHIP_TYPE, DIAGRAM_NAMESPACE, DIAGRAM_QUICK_STYLE_RELATIONSHIP_TYPE, DIAGRAM_RELATIONSHIP_TYPES, DIAGRAM_STYLE_CONTENT_TYPE, DRAWINGML_MAIN_NAMESPACE, OFFICE_DOCUMENT_RELATIONSHIPS_NAMESPACE, OFFICE_IMAGE_RELATIONSHIP_TYPE, } from './namespaces';
15
+ export { DiagramPartError } from './errors';
16
+ export { DiagramPointType, } from './types';
17
+ export { parseDiagramData } from './parse-data';
18
+ export { parseDiagramColors } from './parse-colors';
19
+ export { parseDiagramLayout } from './parse-layout';
20
+ export { parseDiagramStyle } from './parse-style';
21
+ export { findDiagramRelIds, parseDiagramRelIds } from './parse-rel-ids';
22
+ export { serializeDiagramColors, serializeDiagramData, serializeDiagramLayout, serializeDiagramStyle, } from './serialize';
23
+ export { enumerateDiagramInstances, getDiagramInstance, listDiagramParts, normalizePartName, } from './package-graph';
24
+ export { createDiagramInstance, removeDiagramInstance } from './mutators';
25
+ export { diagramPoint, diagramPointText, listDiagramConnections, listDiagramPoints, withDiagramPointText, } from './point-text';
26
+ export { getDiagramPartHandler, registerSmartArtFeature } from './register';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Built-in minimal diagram part XML seeds for {@link createDiagramInstance}.
3
+ *
4
+ * @remarks
5
+ * Documented sample only — not a layout catalog. Roots match Transitional
6
+ * `dml-diagram.xsd` (`dataModel`, `layoutDef`, `colorsDef`, `styleDef`).
7
+ * ECMA-376 Part 1 §14.2.3–14.2.6.
8
+ *
9
+ * @private
10
+ */
11
+ /** Minimal `dgm:dataModel` with required `ptLst` (doc + one node). */
12
+ export declare const MINIMAL_DIAGRAM_DATA_XML: string;
13
+ /** Minimal `dgm:layoutDef` with title/desc. */
14
+ export declare const MINIMAL_DIAGRAM_LAYOUT_XML: string;
15
+ /** Minimal `dgm:colorsDef`. */
16
+ export declare const MINIMAL_DIAGRAM_COLORS_XML: string;
17
+ /** Minimal `dgm:styleDef`. */
18
+ export declare const MINIMAL_DIAGRAM_STYLE_XML: string;