@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,413 @@
1
+ /**
2
+ * Host-neutral discovery of DrawingML diagram instances from a package graph.
3
+ *
4
+ * @remarks
5
+ * Locates the four diagram parts (content types / relationship types from
6
+ * ECMA-376 Part 1 §14.2.3–14.2.6 and Part 4 §12.2.3–12.2.6) and binds them via
7
+ * `dgm:relIds` (`CT_RelIds`) and/or outbound diagram relationships from a common
8
+ * source part. Layout parts are never shared across instances (§14.2.5).
9
+ *
10
+ * This module does not import PPT/Word/Excel product types. Callers supply a
11
+ * {@link DiagramPackageGraph} (parts + relationships).
12
+ *
13
+ * @public
14
+ */
15
+ var __values = (this && this.__values) || function (o) {
16
+ var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
17
+ if (m) return m.call(o);
18
+ return {
19
+ next: function () {
20
+ if (o && i >= o.length) o = void 0;
21
+ return { value: o && o[i++], done: !o };
22
+ }
23
+ };
24
+ };
25
+ var __read = (this && this.__read) || function (o, n) {
26
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
27
+ if (!m) return o;
28
+ var i = m.call(o), r, ar = [], e;
29
+ try {
30
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
31
+ }
32
+ catch (error) { e = { error: error }; }
33
+ finally {
34
+ try {
35
+ if (r && !r.done && (m = i["return"])) m.call(i);
36
+ }
37
+ finally { if (e) throw e.error; }
38
+ }
39
+ return ar;
40
+ };
41
+ var __spread = (this && this.__spread) || function () {
42
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
43
+ return ar;
44
+ };
45
+ import { DiagramPartError } from './errors';
46
+ import { DIAGRAM_COLORS_CONTENT_TYPE, DIAGRAM_COLORS_RELATIONSHIP_TYPE, DIAGRAM_DATA_CONTENT_TYPE, DIAGRAM_DATA_RELATIONSHIP_TYPE, DIAGRAM_LAYOUT_CONTENT_TYPE, DIAGRAM_LAYOUT_RELATIONSHIP_TYPE, DIAGRAM_QUICK_STYLE_RELATIONSHIP_TYPE, DIAGRAM_STYLE_CONTENT_TYPE } from './namespaces';
47
+ import { parseDiagramColors } from './parse-colors';
48
+ import { parseDiagramData } from './parse-data';
49
+ import { parseDiagramLayout } from './parse-layout';
50
+ import { findDiagramRelIds } from './parse-rel-ids';
51
+ import { parseDiagramStyle } from './parse-style';
52
+ /** Normalize package part names for map keys (leading `/`, no trailing `/`). */
53
+ export function normalizePartName(name) {
54
+ var n = name.trim().replace(/\\/g, '/');
55
+ if (n.length === 0) {
56
+ return '/';
57
+ }
58
+ if (!n.startsWith('/')) {
59
+ n = "/" + n;
60
+ }
61
+ if (n.length > 1 && n.endsWith('/')) {
62
+ n = n.slice(0, -1);
63
+ }
64
+ return n;
65
+ }
66
+ function buildPartMap(parts) {
67
+ var e_1, _a;
68
+ var map = new Map();
69
+ try {
70
+ for (var parts_1 = __values(parts), parts_1_1 = parts_1.next(); !parts_1_1.done; parts_1_1 = parts_1.next()) {
71
+ var part = parts_1_1.value;
72
+ map.set(normalizePartName(part.name), part);
73
+ }
74
+ }
75
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
76
+ finally {
77
+ try {
78
+ if (parts_1_1 && !parts_1_1.done && (_a = parts_1.return)) _a.call(parts_1);
79
+ }
80
+ finally { if (e_1) throw e_1.error; }
81
+ }
82
+ return map;
83
+ }
84
+ function relationshipsFromSource(relationships, source) {
85
+ var src = normalizePartName(source);
86
+ return relationships.filter(function (r) { return normalizePartName(r.source) === src; });
87
+ }
88
+ function resolveTarget(rels, relId) {
89
+ var e_2, _a;
90
+ try {
91
+ for (var rels_1 = __values(rels), rels_1_1 = rels_1.next(); !rels_1_1.done; rels_1_1 = rels_1.next()) {
92
+ var r = rels_1_1.value;
93
+ if (r.id === relId) {
94
+ return normalizePartName(r.target);
95
+ }
96
+ }
97
+ }
98
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
99
+ finally {
100
+ try {
101
+ if (rels_1_1 && !rels_1_1.done && (_a = rels_1.return)) _a.call(rels_1);
102
+ }
103
+ finally { if (e_2) throw e_2.error; }
104
+ }
105
+ return undefined;
106
+ }
107
+ function requirePart(map, name, role) {
108
+ var part = map.get(normalizePartName(name));
109
+ if (part === undefined) {
110
+ throw new DiagramPartError("Diagram " + role + " part not found: " + name);
111
+ }
112
+ return part;
113
+ }
114
+ function parseFourParts(map, names) {
115
+ var dataPart = requirePart(map, names.data, 'data');
116
+ var layoutPart = requirePart(map, names.layout, 'layout');
117
+ var colorsPart = requirePart(map, names.colors, 'colors');
118
+ var stylePart = requirePart(map, names.style, 'style');
119
+ if (dataPart.contentType !== DIAGRAM_DATA_CONTENT_TYPE) {
120
+ throw new DiagramPartError("Expected diagram data content type for " + names.data + ", got " + dataPart.contentType);
121
+ }
122
+ if (layoutPart.contentType !== DIAGRAM_LAYOUT_CONTENT_TYPE) {
123
+ throw new DiagramPartError("Expected diagram layout content type for " + names.layout + ", got " + layoutPart.contentType);
124
+ }
125
+ if (colorsPart.contentType !== DIAGRAM_COLORS_CONTENT_TYPE) {
126
+ throw new DiagramPartError("Expected diagram colors content type for " + names.colors + ", got " + colorsPart.contentType);
127
+ }
128
+ if (stylePart.contentType !== DIAGRAM_STYLE_CONTENT_TYPE) {
129
+ throw new DiagramPartError("Expected diagram style content type for " + names.style + ", got " + stylePart.contentType);
130
+ }
131
+ return {
132
+ data: parseDiagramData(dataPart.xml),
133
+ layout: parseDiagramLayout(layoutPart.xml),
134
+ colors: parseDiagramColors(colorsPart.xml),
135
+ style: parseDiagramStyle(stylePart.xml)
136
+ };
137
+ }
138
+ function instanceFromBinding(map, sourcePartName, relIds, names) {
139
+ var parsed = parseFourParts(map, names);
140
+ var id = normalizePartName(names.data);
141
+ return {
142
+ id: id,
143
+ data: parsed.data,
144
+ layout: parsed.layout,
145
+ colors: parsed.colors,
146
+ style: parsed.style,
147
+ relIds: {
148
+ dm: relIds.dm,
149
+ lo: relIds.lo,
150
+ qs: relIds.qs,
151
+ cs: relIds.cs
152
+ },
153
+ partNames: {
154
+ data: normalizePartName(names.data),
155
+ layout: normalizePartName(names.layout),
156
+ colors: normalizePartName(names.colors),
157
+ style: normalizePartName(names.style)
158
+ },
159
+ sourcePartName: sourcePartName.length > 0 ? normalizePartName(sourcePartName) : ''
160
+ };
161
+ }
162
+ function tryBindRelIds(map, sourceRels, sourcePartName, relIds) {
163
+ var data = resolveTarget(sourceRels, relIds.dm);
164
+ var layout = resolveTarget(sourceRels, relIds.lo);
165
+ var style = resolveTarget(sourceRels, relIds.qs);
166
+ var colors = resolveTarget(sourceRels, relIds.cs);
167
+ if (data === undefined || layout === undefined || style === undefined || colors === undefined) {
168
+ return undefined;
169
+ }
170
+ try {
171
+ return instanceFromBinding(map, sourcePartName, relIds, {
172
+ data: data,
173
+ layout: layout,
174
+ colors: colors,
175
+ style: style
176
+ });
177
+ }
178
+ catch (_a) {
179
+ // Orphan/partial graph: missing part or wrong content type — skip for enumerate.
180
+ return undefined;
181
+ }
182
+ }
183
+ /**
184
+ * Groups outbound diagram relationship types from one source into part names.
185
+ *
186
+ * @returns Names + synthetic relIds when exactly one of each role is present.
187
+ */
188
+ function clusterFromSourceRels(sourceRels) {
189
+ var dataRels = sourceRels.filter(function (r) { return r.type === DIAGRAM_DATA_RELATIONSHIP_TYPE; });
190
+ var layoutRels = sourceRels.filter(function (r) { return r.type === DIAGRAM_LAYOUT_RELATIONSHIP_TYPE; });
191
+ var styleRels = sourceRels.filter(function (r) { return r.type === DIAGRAM_QUICK_STYLE_RELATIONSHIP_TYPE; });
192
+ var colorsRels = sourceRels.filter(function (r) { return r.type === DIAGRAM_COLORS_RELATIONSHIP_TYPE; });
193
+ if (dataRels.length !== 1 || layoutRels.length !== 1 || styleRels.length !== 1 || colorsRels.length !== 1) {
194
+ return undefined;
195
+ }
196
+ var dataRel = dataRels[0];
197
+ var layoutRel = layoutRels[0];
198
+ var styleRel = styleRels[0];
199
+ var colorsRel = colorsRels[0];
200
+ if (dataRel === undefined || layoutRel === undefined || styleRel === undefined || colorsRel === undefined) {
201
+ return undefined;
202
+ }
203
+ return {
204
+ relIds: {
205
+ dm: dataRel.id,
206
+ lo: layoutRel.id,
207
+ qs: styleRel.id,
208
+ cs: colorsRel.id
209
+ },
210
+ names: {
211
+ data: normalizePartName(dataRel.target),
212
+ layout: normalizePartName(layoutRel.target),
213
+ colors: normalizePartName(colorsRel.target),
214
+ style: normalizePartName(styleRel.target)
215
+ }
216
+ };
217
+ }
218
+ /**
219
+ * Lists diagram instances discoverable from the package graph.
220
+ *
221
+ * @remarks
222
+ * Discovery order:
223
+ * 1. Complete `dgm:relIds` hooks in part XML (incomplete hooks skipped —
224
+ * preserve-on-load).
225
+ * 2. Source parts with exactly one outbound relationship of each diagram type
226
+ * (when not already covered by a relIds binding).
227
+ *
228
+ * Layout part names used by more than one instance violate Part 1 §14.2.5;
229
+ * each binding is still returned so callers can detect the clash.
230
+ *
231
+ * Partial graphs (missing target part, wrong content type, incomplete relIds)
232
+ * do not throw; they simply omit that candidate. Explicit {@link parseDiagramRelIds}
233
+ * and mutate APIs throw instead.
234
+ *
235
+ * @param graph - Host-neutral parts + relationships.
236
+ * @returns Instances in stable order (first by source part name, then data part name).
237
+ *
238
+ * @public
239
+ */
240
+ export function enumerateDiagramInstances(graph) {
241
+ var e_3, _a, e_4, _b, e_5, _c, e_6, _d;
242
+ var map = buildPartMap(graph.parts);
243
+ var byId = new Map();
244
+ try {
245
+ // Path 1: relIds in part XML.
246
+ for (var _e = __values(graph.parts), _f = _e.next(); !_f.done; _f = _e.next()) {
247
+ var part = _f.value;
248
+ var sourceName = normalizePartName(part.name);
249
+ var hooks = void 0;
250
+ try {
251
+ hooks = findDiagramRelIds(part.xml);
252
+ }
253
+ catch (_g) {
254
+ // Malformed host XML — skip this part for discovery.
255
+ continue;
256
+ }
257
+ if (hooks.length === 0) {
258
+ continue;
259
+ }
260
+ var sourceRels = relationshipsFromSource(graph.relationships, sourceName);
261
+ try {
262
+ for (var hooks_1 = __values(hooks), hooks_1_1 = hooks_1.next(); !hooks_1_1.done; hooks_1_1 = hooks_1.next()) {
263
+ var relIds = hooks_1_1.value;
264
+ var inst = tryBindRelIds(map, sourceRels, sourceName, relIds);
265
+ if (inst !== undefined && !byId.has(inst.id)) {
266
+ byId.set(inst.id, inst);
267
+ }
268
+ }
269
+ }
270
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
271
+ finally {
272
+ try {
273
+ if (hooks_1_1 && !hooks_1_1.done && (_b = hooks_1.return)) _b.call(hooks_1);
274
+ }
275
+ finally { if (e_4) throw e_4.error; }
276
+ }
277
+ }
278
+ }
279
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
280
+ finally {
281
+ try {
282
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
283
+ }
284
+ finally { if (e_3) throw e_3.error; }
285
+ }
286
+ // Path 2: relationship clustering by source (exactly one of each role).
287
+ var sources = new Set();
288
+ try {
289
+ for (var _h = __values(graph.relationships), _j = _h.next(); !_j.done; _j = _h.next()) {
290
+ var rel = _j.value;
291
+ if (rel.type === DIAGRAM_DATA_RELATIONSHIP_TYPE || rel.type === DIAGRAM_LAYOUT_RELATIONSHIP_TYPE || rel.type === DIAGRAM_QUICK_STYLE_RELATIONSHIP_TYPE || rel.type === DIAGRAM_COLORS_RELATIONSHIP_TYPE) {
292
+ sources.add(normalizePartName(rel.source));
293
+ }
294
+ }
295
+ }
296
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
297
+ finally {
298
+ try {
299
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
300
+ }
301
+ finally { if (e_5) throw e_5.error; }
302
+ }
303
+ try {
304
+ for (var sources_1 = __values(sources), sources_1_1 = sources_1.next(); !sources_1_1.done; sources_1_1 = sources_1.next()) {
305
+ var sourceName = sources_1_1.value;
306
+ var sourceRels = relationshipsFromSource(graph.relationships, sourceName);
307
+ var clustered = clusterFromSourceRels(sourceRels);
308
+ if (clustered === undefined) {
309
+ continue;
310
+ }
311
+ try {
312
+ var inst = instanceFromBinding(map, sourceName, clustered.relIds, clustered.names);
313
+ if (!byId.has(inst.id)) {
314
+ byId.set(inst.id, inst);
315
+ }
316
+ }
317
+ catch (_k) {
318
+ // Partial graph — skip.
319
+ }
320
+ }
321
+ }
322
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
323
+ finally {
324
+ try {
325
+ if (sources_1_1 && !sources_1_1.done && (_d = sources_1.return)) _d.call(sources_1);
326
+ }
327
+ finally { if (e_6) throw e_6.error; }
328
+ }
329
+ var list = __spread(byId.values());
330
+ list.sort(function (a, b) {
331
+ var s = a.sourcePartName.localeCompare(b.sourcePartName);
332
+ if (s !== 0) {
333
+ return s;
334
+ }
335
+ return a.id.localeCompare(b.id);
336
+ });
337
+ return list;
338
+ }
339
+ /**
340
+ * Resolves a single diagram instance from the package graph.
341
+ *
342
+ * @param graph - Host-neutral parts + relationships.
343
+ * @param options - Match by {@link GetDiagramInstanceOptions.id} and/or
344
+ * `dataPartName` (normalized). At least one matcher is required.
345
+ * @returns The instance, or `undefined` when not found.
346
+ * @throws {DiagramPartError} When no matcher is provided.
347
+ *
348
+ * @public
349
+ */
350
+ export function getDiagramInstance(graph, options) {
351
+ var e_7, _a;
352
+ var idOpt = (options.id == null ? void 0 : options.id.trim());
353
+ var dataOpt = (options.dataPartName == null ? void 0 : options.dataPartName.trim());
354
+ if ((idOpt === undefined || idOpt.length === 0) && (dataOpt === undefined || dataOpt.length === 0)) {
355
+ throw new DiagramPartError('getDiagramInstance requires options.id and/or options.dataPartName');
356
+ }
357
+ var wantId = idOpt !== undefined && idOpt.length > 0 ? normalizePartName(idOpt) : undefined;
358
+ var wantData = dataOpt !== undefined && dataOpt.length > 0 ? normalizePartName(dataOpt) : undefined;
359
+ var all = enumerateDiagramInstances(graph);
360
+ try {
361
+ for (var all_1 = __values(all), all_1_1 = all_1.next(); !all_1_1.done; all_1_1 = all_1.next()) {
362
+ var inst = all_1_1.value;
363
+ if (wantId !== undefined && inst.id !== wantId) {
364
+ continue;
365
+ }
366
+ if (wantData !== undefined && inst.partNames.data !== wantData) {
367
+ continue;
368
+ }
369
+ return inst;
370
+ }
371
+ }
372
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
373
+ finally {
374
+ try {
375
+ if (all_1_1 && !all_1_1.done && (_a = all_1.return)) _a.call(all_1);
376
+ }
377
+ finally { if (e_7) throw e_7.error; }
378
+ }
379
+ return undefined;
380
+ }
381
+ /**
382
+ * Lists package parts whose content type is one of the four diagram types.
383
+ *
384
+ * @param graph - Host-neutral package graph.
385
+ * @returns Matching parts in input order (names normalized on the returned copies).
386
+ *
387
+ * @public
388
+ */
389
+ export function listDiagramParts(graph) {
390
+ var e_8, _a;
391
+ var types = new Set([DIAGRAM_DATA_CONTENT_TYPE, DIAGRAM_LAYOUT_CONTENT_TYPE, DIAGRAM_COLORS_CONTENT_TYPE, DIAGRAM_STYLE_CONTENT_TYPE]);
392
+ var out = [];
393
+ try {
394
+ for (var _b = __values(graph.parts), _c = _b.next(); !_c.done; _c = _b.next()) {
395
+ var part = _c.value;
396
+ if (types.has(part.contentType)) {
397
+ out.push({
398
+ name: normalizePartName(part.name),
399
+ contentType: part.contentType,
400
+ xml: part.xml
401
+ });
402
+ }
403
+ }
404
+ }
405
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
406
+ finally {
407
+ try {
408
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
409
+ }
410
+ finally { if (e_8) throw e_8.error; }
411
+ }
412
+ return out;
413
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Parse Diagram Colors part (`dgm:colorsDef` / `CT_ColorTransform`).
3
+ *
4
+ * @remarks
5
+ * Citations: Transitional `dml-diagram.xsd` (`CT_ColorTransform`);
6
+ * ECMA-376 Part 1 §14.2.3. v1: optional `uniqueId` + opaque root preserve.
7
+ *
8
+ * @public
9
+ */
10
+ import { DiagramColorsPart } from './types';
11
+ /**
12
+ * Parses a Diagram Colors part XML document into a {@link DiagramColorsPart}.
13
+ *
14
+ * @param xml - UTF-8 XML for a single `dgm:colorsDef` root.
15
+ * @throws {DiagramPartError} Malformed XML or wrong root element.
16
+ *
17
+ * @public
18
+ */
19
+ export declare function parseDiagramColors(xml: string): DiagramColorsPart;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Parse Diagram Colors part (`dgm:colorsDef` / `CT_ColorTransform`).
3
+ *
4
+ * @remarks
5
+ * Citations: Transitional `dml-diagram.xsd` (`CT_ColorTransform`);
6
+ * ECMA-376 Part 1 §14.2.3. v1: optional `uniqueId` + opaque root preserve.
7
+ *
8
+ * @public
9
+ */
10
+ var __assign = (this && this.__assign) || function () {
11
+ __assign = Object.assign || function(t) {
12
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
13
+ s = arguments[i];
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
15
+ t[p] = s[p];
16
+ }
17
+ return t;
18
+ };
19
+ return __assign.apply(this, arguments);
20
+ };
21
+ import { cloneElement, getAttribute, parseDiagramXml } from './diagram-xml';
22
+ import { DiagramPartError } from './errors';
23
+ import { DIAGRAM_NAMESPACE } from './namespaces';
24
+ /**
25
+ * Parses a Diagram Colors part XML document into a {@link DiagramColorsPart}.
26
+ *
27
+ * @param xml - UTF-8 XML for a single `dgm:colorsDef` root.
28
+ * @throws {DiagramPartError} Malformed XML or wrong root element.
29
+ *
30
+ * @public
31
+ */
32
+ export function parseDiagramColors(xml) {
33
+ var root = parseDiagramXml(xml);
34
+ if (root.localName !== 'colorsDef' || root.namespaceUri !== DIAGRAM_NAMESPACE) {
35
+ throw new DiagramPartError("Expected dgm:colorsDef root, got " + root.qName + " in ns \"" + root.namespaceUri + "\"");
36
+ }
37
+ var uniqueId = getAttribute(root, 'uniqueId');
38
+ return __assign({ kind: 'diagramColors' }, (uniqueId !== undefined ? { uniqueId: uniqueId } : {}), { root: cloneElement(root) });
39
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Parse Diagram Data part (`dgm:dataModel` / `CT_DataModel`).
3
+ *
4
+ * @remarks
5
+ * Citations: Transitional `dml-diagram.xsd` (`CT_DataModel`, `CT_Pt`, `ST_PtType`,
6
+ * `CT_Cxn`); ECMA-376 Part 1 §14.2.4. Required `ptLst`; optional `cxnLst` /
7
+ * `bg` / `whole` / `extLst` preserved on the root element.
8
+ *
9
+ * @public
10
+ */
11
+ import { DiagramDataPart } from './types';
12
+ /**
13
+ * Parses a Diagram Data part XML document into a {@link DiagramDataPart}.
14
+ *
15
+ * @param xml - UTF-8 XML for a single `dgm:dataModel` root.
16
+ * @returns Modeled points/connections plus full root for preserve serialize.
17
+ * @throws {DiagramPartError} Malformed XML, wrong root, or missing `ptLst`.
18
+ *
19
+ * @public
20
+ */
21
+ export declare function parseDiagramData(xml: string): DiagramDataPart;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Parse Diagram Data part (`dgm:dataModel` / `CT_DataModel`).
3
+ *
4
+ * @remarks
5
+ * Citations: Transitional `dml-diagram.xsd` (`CT_DataModel`, `CT_Pt`, `ST_PtType`,
6
+ * `CT_Cxn`); ECMA-376 Part 1 §14.2.4. Required `ptLst`; optional `cxnLst` /
7
+ * `bg` / `whole` / `extLst` preserved on the root element.
8
+ *
9
+ * @public
10
+ */
11
+ var __assign = (this && this.__assign) || function () {
12
+ __assign = Object.assign || function(t) {
13
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
14
+ s = arguments[i];
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
16
+ t[p] = s[p];
17
+ }
18
+ return t;
19
+ };
20
+ return __assign.apply(this, arguments);
21
+ };
22
+ var __values = (this && this.__values) || function (o) {
23
+ var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
24
+ if (m) return m.call(o);
25
+ return {
26
+ next: function () {
27
+ if (o && i >= o.length) o = void 0;
28
+ return { value: o && o[i++], done: !o };
29
+ }
30
+ };
31
+ };
32
+ import { cloneElement, findChild, findChildren, getAttribute, parseDiagramXml, } from './diagram-xml';
33
+ import { DiagramPartError } from './errors';
34
+ import { DIAGRAM_NAMESPACE } from './namespaces';
35
+ import { DiagramPointType, } from './types';
36
+ var POINT_TYPES = new Set((function (_o) { return Object.keys(_o).map(function (k) { return _o[k]; }); })(DiagramPointType));
37
+ function parsePoint(el) {
38
+ var modelId = getAttribute(el, 'modelId');
39
+ if (modelId === undefined || modelId.length === 0) {
40
+ throw new DiagramPartError('dgm:pt requires modelId');
41
+ }
42
+ var typeRaw = getAttribute(el, 'type');
43
+ var typeAttributePresent = typeRaw !== undefined;
44
+ var type = DiagramPointType.Node;
45
+ if (typeRaw !== undefined) {
46
+ if (!POINT_TYPES.has(typeRaw)) {
47
+ throw new DiagramPartError("dgm:pt has unsupported type \"" + typeRaw + "\"");
48
+ }
49
+ type = typeRaw;
50
+ }
51
+ var connectionId = getAttribute(el, 'cxnId');
52
+ var textBody = findChild(el, 't', DIAGRAM_NAMESPACE);
53
+ var point = __assign({ modelId: modelId,
54
+ type: type,
55
+ typeAttributePresent: typeAttributePresent }, (connectionId !== undefined ? { connectionId: connectionId } : {}), (textBody !== undefined ? { textBody: cloneElement(textBody) } : {}), { element: cloneElement(el) });
56
+ return point;
57
+ }
58
+ function parseConnection(el) {
59
+ var modelId = getAttribute(el, 'modelId');
60
+ var sourceId = getAttribute(el, 'srcId');
61
+ var destinationId = getAttribute(el, 'destId');
62
+ if (modelId === undefined || modelId.length === 0) {
63
+ throw new DiagramPartError('dgm:cxn requires modelId');
64
+ }
65
+ if (sourceId === undefined || sourceId.length === 0) {
66
+ throw new DiagramPartError('dgm:cxn requires srcId');
67
+ }
68
+ if (destinationId === undefined || destinationId.length === 0) {
69
+ throw new DiagramPartError('dgm:cxn requires destId');
70
+ }
71
+ return {
72
+ modelId: modelId,
73
+ sourceId: sourceId,
74
+ destinationId: destinationId,
75
+ element: cloneElement(el),
76
+ };
77
+ }
78
+ /**
79
+ * Parses a Diagram Data part XML document into a {@link DiagramDataPart}.
80
+ *
81
+ * @param xml - UTF-8 XML for a single `dgm:dataModel` root.
82
+ * @returns Modeled points/connections plus full root for preserve serialize.
83
+ * @throws {DiagramPartError} Malformed XML, wrong root, or missing `ptLst`.
84
+ *
85
+ * @public
86
+ */
87
+ export function parseDiagramData(xml) {
88
+ var e_1, _a;
89
+ var root = parseDiagramXml(xml);
90
+ if (root.localName !== 'dataModel' || root.namespaceUri !== DIAGRAM_NAMESPACE) {
91
+ throw new DiagramPartError("Expected dgm:dataModel root, got " + root.qName + " in ns \"" + root.namespaceUri + "\"");
92
+ }
93
+ var ptLst = findChild(root, 'ptLst', DIAGRAM_NAMESPACE);
94
+ if (ptLst === undefined) {
95
+ throw new DiagramPartError('dgm:dataModel requires dgm:ptLst');
96
+ }
97
+ var points = findChildren(ptLst, 'pt', DIAGRAM_NAMESPACE).map(parsePoint);
98
+ var connections = [];
99
+ var cxnLst = findChild(root, 'cxnLst', DIAGRAM_NAMESPACE);
100
+ if (cxnLst !== undefined) {
101
+ try {
102
+ for (var _b = __values(findChildren(cxnLst, 'cxn', DIAGRAM_NAMESPACE)), _c = _b.next(); !_c.done; _c = _b.next()) {
103
+ var cxn = _c.value;
104
+ connections.push(parseConnection(cxn));
105
+ }
106
+ }
107
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
108
+ finally {
109
+ try {
110
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
111
+ }
112
+ finally { if (e_1) throw e_1.error; }
113
+ }
114
+ }
115
+ return {
116
+ kind: 'diagramData',
117
+ points: points,
118
+ connections: connections,
119
+ root: cloneElement(root),
120
+ };
121
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Parse Diagram Layout Definition part (`dgm:layoutDef` / `CT_DiagramDefinition`).
3
+ *
4
+ * @remarks
5
+ * Citations: Transitional `dml-diagram.xsd` (`CT_DiagramDefinition`);
6
+ * ECMA-376 Part 1 §14.2.5. v1: optional `uniqueId` + opaque root preserve.
7
+ * Layout parts are not shared across diagrams (Part 1 §14.2.5).
8
+ *
9
+ * @public
10
+ */
11
+ import { DiagramLayoutPart } from './types';
12
+ /**
13
+ * Parses a Diagram Layout Definition part XML document into a {@link DiagramLayoutPart}.
14
+ *
15
+ * @param xml - UTF-8 XML for a single `dgm:layoutDef` root.
16
+ * @throws {DiagramPartError} Malformed XML or wrong root element.
17
+ *
18
+ * @public
19
+ */
20
+ export declare function parseDiagramLayout(xml: string): DiagramLayoutPart;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Parse Diagram Layout Definition part (`dgm:layoutDef` / `CT_DiagramDefinition`).
3
+ *
4
+ * @remarks
5
+ * Citations: Transitional `dml-diagram.xsd` (`CT_DiagramDefinition`);
6
+ * ECMA-376 Part 1 §14.2.5. v1: optional `uniqueId` + opaque root preserve.
7
+ * Layout parts are not shared across diagrams (Part 1 §14.2.5).
8
+ *
9
+ * @public
10
+ */
11
+ var __assign = (this && this.__assign) || function () {
12
+ __assign = Object.assign || function(t) {
13
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
14
+ s = arguments[i];
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
16
+ t[p] = s[p];
17
+ }
18
+ return t;
19
+ };
20
+ return __assign.apply(this, arguments);
21
+ };
22
+ import { cloneElement, getAttribute, parseDiagramXml } from './diagram-xml';
23
+ import { DiagramPartError } from './errors';
24
+ import { DIAGRAM_NAMESPACE } from './namespaces';
25
+ /**
26
+ * Parses a Diagram Layout Definition part XML document into a {@link DiagramLayoutPart}.
27
+ *
28
+ * @param xml - UTF-8 XML for a single `dgm:layoutDef` root.
29
+ * @throws {DiagramPartError} Malformed XML or wrong root element.
30
+ *
31
+ * @public
32
+ */
33
+ export function parseDiagramLayout(xml) {
34
+ var root = parseDiagramXml(xml);
35
+ if (root.localName !== 'layoutDef' || root.namespaceUri !== DIAGRAM_NAMESPACE) {
36
+ throw new DiagramPartError("Expected dgm:layoutDef root, got " + root.qName + " in ns \"" + root.namespaceUri + "\"");
37
+ }
38
+ var uniqueId = getAttribute(root, 'uniqueId');
39
+ return __assign({ kind: 'diagramLayout' }, (uniqueId !== undefined ? { uniqueId: uniqueId } : {}), { root: cloneElement(root) });
40
+ }