@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,446 @@
1
+ /**
2
+ * DiagramDataModel — CT_DataModel view/API.
3
+ *
4
+ * Citations:
5
+ * - dml-diagram.xsd CT_DataModel, CT_Pt, CT_Cxn, ST_PtType, ST_CxnType, ST_ModelId
6
+ * - Requirement docs/requirements/smart-art-diagrams.md §12 (maintenance API)
7
+ * - ECMA-376 DrawingML diagram data part
8
+ */
9
+ var __values = (this && this.__values) || function (o) {
10
+ var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
11
+ if (m) return m.call(o);
12
+ return {
13
+ next: function () {
14
+ if (o && i >= o.length) o = void 0;
15
+ return { value: o && o[i++], done: !o };
16
+ }
17
+ };
18
+ };
19
+ var __read = (this && this.__read) || function (o, n) {
20
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
21
+ if (!m) return o;
22
+ var i = m.call(o), r, ar = [], e;
23
+ try {
24
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
25
+ }
26
+ catch (error) { e = { error: error }; }
27
+ finally {
28
+ try {
29
+ if (r && !r.done && (m = i["return"])) m.call(i);
30
+ }
31
+ finally { if (e) throw e.error; }
32
+ }
33
+ return ar;
34
+ };
35
+ var __spread = (this && this.__spread) || function () {
36
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
37
+ return ar;
38
+ };
39
+ var _a;
40
+ import { MAX_DIAGRAM_CONNECTIONS, MAX_DIAGRAM_POINTS } from './constants';
41
+ import { cloneElement } from './element-tree';
42
+ import { DiagramModelError } from './errors';
43
+ var DIAGRAM_DATA_MODEL_BRAND = Symbol.for('@syncfusion/ej2-office-common.DiagramDataModel');
44
+ function cloneBody(body) {
45
+ if (body == null)
46
+ return null;
47
+ return cloneElement(body);
48
+ }
49
+ function normalizePoint(p) {
50
+ return {
51
+ modelId: p.modelId,
52
+ type: p.type != null ? p.type : 'node',
53
+ cxnId: p.cxnId != null ? p.cxnId : '0',
54
+ body: cloneBody(p.body)
55
+ };
56
+ }
57
+ function normalizeConnection(c) {
58
+ return {
59
+ modelId: c.modelId,
60
+ type: c.type != null ? c.type : 'parOf',
61
+ srcId: c.srcId,
62
+ destId: c.destId,
63
+ srcOrd: c.srcOrd,
64
+ destOrd: c.destOrd,
65
+ parTransId: c.parTransId != null ? c.parTransId : '0',
66
+ sibTransId: c.sibTransId != null ? c.sibTransId : '0',
67
+ presId: c.presId != null ? c.presId : '',
68
+ body: cloneBody(c.body)
69
+ };
70
+ }
71
+ /**
72
+ * Mutable CT_DataModel graph.
73
+ * Identity: `instanceof DiagramDataModel` and brand symbol.
74
+ */
75
+ var DiagramDataModel = /** @class */ (function () {
76
+ function DiagramDataModel(init) {
77
+ var e_1, _a, e_2, _b;
78
+ if (init === void 0) { init = {}; }
79
+ this[_a] = true;
80
+ this._points = [];
81
+ this._connections = [];
82
+ this._dirty = false;
83
+ /** Optional original part bytes when loaded clean (D14). */
84
+ this._originalBytes = null;
85
+ var points = init.points != null ? init.points : [];
86
+ var connections = init.connections != null ? init.connections : [];
87
+ if (points.length > MAX_DIAGRAM_POINTS) {
88
+ throw new DiagramModelError('limit_exceeded', "Point count " + String(points.length) + " exceeds MAX_DIAGRAM_POINTS (" + String(MAX_DIAGRAM_POINTS) + ").");
89
+ }
90
+ if (connections.length > MAX_DIAGRAM_CONNECTIONS) {
91
+ throw new DiagramModelError('limit_exceeded', "Connection count " + String(connections.length) + " exceeds MAX_DIAGRAM_CONNECTIONS (" + String(MAX_DIAGRAM_CONNECTIONS) + ").");
92
+ }
93
+ try {
94
+ for (var points_1 = __values(points), points_1_1 = points_1.next(); !points_1_1.done; points_1_1 = points_1.next()) {
95
+ var p = points_1_1.value;
96
+ this._points.push(normalizePoint(p));
97
+ }
98
+ }
99
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
100
+ finally {
101
+ try {
102
+ if (points_1_1 && !points_1_1.done && (_a = points_1.return)) _a.call(points_1);
103
+ }
104
+ finally { if (e_1) throw e_1.error; }
105
+ }
106
+ try {
107
+ for (var connections_1 = __values(connections), connections_1_1 = connections_1.next(); !connections_1_1.done; connections_1_1 = connections_1.next()) {
108
+ var c = connections_1_1.value;
109
+ this._connections.push(normalizeConnection(c));
110
+ }
111
+ }
112
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
113
+ finally {
114
+ try {
115
+ if (connections_1_1 && !connections_1_1.done && (_b = connections_1.return)) _b.call(connections_1);
116
+ }
117
+ finally { if (e_2) throw e_2.error; }
118
+ }
119
+ this._background = cloneBody(init.background);
120
+ this._whole = cloneBody(init.whole);
121
+ this._extLst = cloneBody(init.extLst);
122
+ }
123
+ Object.defineProperty(DiagramDataModel.prototype, "dirty", {
124
+ get: function () {
125
+ return this._dirty;
126
+ },
127
+ enumerable: true,
128
+ configurable: true
129
+ });
130
+ /** Mark dirty and drop original bytes (must reserialize). */
131
+ DiagramDataModel.prototype.markDirty = function () {
132
+ this._dirty = true;
133
+ this._originalBytes = null;
134
+ };
135
+ /** Clear dirty after successful apply; optionally stash bytes. */
136
+ DiagramDataModel.prototype.clearDirty = function (originalBytes) {
137
+ this._dirty = false;
138
+ this._originalBytes = originalBytes != null ? originalBytes : null;
139
+ };
140
+ Object.defineProperty(DiagramDataModel.prototype, "originalBytes", {
141
+ get: function () {
142
+ return this._originalBytes;
143
+ },
144
+ enumerable: true,
145
+ configurable: true
146
+ });
147
+ DiagramDataModel.prototype.setOriginalBytes = function (bytes) {
148
+ this._originalBytes = bytes;
149
+ };
150
+ Object.defineProperty(DiagramDataModel.prototype, "points", {
151
+ get: function () {
152
+ return this._points;
153
+ },
154
+ enumerable: true,
155
+ configurable: true
156
+ });
157
+ Object.defineProperty(DiagramDataModel.prototype, "connections", {
158
+ get: function () {
159
+ return this._connections;
160
+ },
161
+ enumerable: true,
162
+ configurable: true
163
+ });
164
+ Object.defineProperty(DiagramDataModel.prototype, "background", {
165
+ get: function () {
166
+ return this._background;
167
+ },
168
+ set: function (value) {
169
+ this._background = cloneBody(value);
170
+ this.markDirty();
171
+ },
172
+ enumerable: true,
173
+ configurable: true
174
+ });
175
+ Object.defineProperty(DiagramDataModel.prototype, "whole", {
176
+ get: function () {
177
+ return this._whole;
178
+ },
179
+ set: function (value) {
180
+ this._whole = cloneBody(value);
181
+ this.markDirty();
182
+ },
183
+ enumerable: true,
184
+ configurable: true
185
+ });
186
+ Object.defineProperty(DiagramDataModel.prototype, "extLst", {
187
+ get: function () {
188
+ return this._extLst;
189
+ },
190
+ set: function (value) {
191
+ this._extLst = cloneBody(value);
192
+ this.markDirty();
193
+ },
194
+ enumerable: true,
195
+ configurable: true
196
+ });
197
+ DiagramDataModel.prototype.pointCount = function () {
198
+ return this._points.length;
199
+ };
200
+ DiagramDataModel.prototype.connectionCount = function () {
201
+ return this._connections.length;
202
+ };
203
+ DiagramDataModel.prototype.getPoint = function (modelId) {
204
+ return this._points.find(function (p) { return p.modelId === modelId; });
205
+ };
206
+ DiagramDataModel.prototype.getConnection = function (modelId) {
207
+ return this._connections.find(function (c) { return c.modelId === modelId; });
208
+ };
209
+ /**
210
+ * Document point (`type=doc`) if present — typically the root of the logical tree.
211
+ */
212
+ DiagramDataModel.prototype.documentPoint = function () {
213
+ return this._points.find(function (p) { return p.type === 'doc'; });
214
+ };
215
+ /**
216
+ * Child node points under `parentId` via parOf connections, ordered by srcOrd.
217
+ * Requirement §12 hierarchy helpers.
218
+ */
219
+ DiagramDataModel.prototype.childrenOf = function (parentId) {
220
+ var e_3, _a;
221
+ var links = this._connections.filter(function (c) { return c.type === 'parOf' && c.srcId === parentId; }).slice().sort(function (a, b) { return a.srcOrd - b.srcOrd; });
222
+ var out = [];
223
+ try {
224
+ for (var links_1 = __values(links), links_1_1 = links_1.next(); !links_1_1.done; links_1_1 = links_1.next()) {
225
+ var link = links_1_1.value;
226
+ var pt = this.getPoint(link.destId);
227
+ if (pt)
228
+ out.push(pt);
229
+ }
230
+ }
231
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
232
+ finally {
233
+ try {
234
+ if (links_1_1 && !links_1_1.done && (_a = links_1.return)) _a.call(links_1);
235
+ }
236
+ finally { if (e_3) throw e_3.error; }
237
+ }
238
+ return out;
239
+ };
240
+ /** Parent via reverse parOf (first match). */
241
+ DiagramDataModel.prototype.parentOf = function (nodeId) {
242
+ var link = this._connections.find(function (c) { return c.type === 'parOf' && c.destId === nodeId; });
243
+ if (!link)
244
+ return undefined;
245
+ return this.getPoint(link.srcId);
246
+ };
247
+ /**
248
+ * Replace text content of the point's `t` (dgm:t / a:t shape) body fragment.
249
+ * If no body/`t` exists, creates a minimal text body hook for the serializer.
250
+ * Requirement §12 setNodeText.
251
+ */
252
+ DiagramDataModel.prototype.setNodeText = function (modelId, value) {
253
+ var pt = this.getPoint(modelId);
254
+ if (!pt) {
255
+ throw new DiagramModelError('unknown_point', "No point with modelId=" + modelId + ".");
256
+ }
257
+ // Store text as a synthetic body element `t` with a text child.
258
+ // Parsers preserve full dgm:t trees when present; this API replaces/creates.
259
+ pt.body = { kind: 'element',
260
+ localName: 't',
261
+ namespaceUri: null,
262
+ attributes: [],
263
+ children: [{ kind: 'text', text: value
264
+ }]
265
+ };
266
+ this.markDirty();
267
+ };
268
+ /** Read text from point body (`t` localName preferred). */
269
+ DiagramDataModel.prototype.getNodeText = function (modelId) {
270
+ var e_4, _a;
271
+ var pt = this.getPoint(modelId);
272
+ if (!(pt == null ? void 0 : pt.body))
273
+ return undefined;
274
+ if (pt.body.localName === 't') {
275
+ return pt.body.children.map(function (c) { return c.kind === 'text' ? c.text : ''; }).join('');
276
+ }
277
+ // Search first t descendant.
278
+ var stack = [pt.body];
279
+ while (stack.length > 0) {
280
+ var n = stack.pop();
281
+ if (n === undefined)
282
+ break;
283
+ if (n.localName === 't') {
284
+ return n.children.map(function (c) { return c.kind === 'text' ? c.text : ''; }).join('');
285
+ }
286
+ try {
287
+ for (var _b = __values(n.children), _c = _b.next(); !_c.done; _c = _b.next()) {
288
+ var c = _c.value;
289
+ if (c.kind === 'element')
290
+ stack.push(c);
291
+ }
292
+ }
293
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
294
+ finally {
295
+ try {
296
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
297
+ }
298
+ finally { if (e_4) throw e_4.error; }
299
+ }
300
+ }
301
+ return undefined;
302
+ };
303
+ DiagramDataModel.prototype.addPoint = function (props) {
304
+ if (this._points.length >= MAX_DIAGRAM_POINTS) {
305
+ throw new DiagramModelError('limit_exceeded', "Cannot add point: MAX_DIAGRAM_POINTS (" + String(MAX_DIAGRAM_POINTS) + ") reached.");
306
+ }
307
+ if (this._points.some(function (p) { return p.modelId === props.modelId; })) {
308
+ throw new DiagramModelError('inconsistent_graph', "Duplicate point modelId=" + props.modelId + ".");
309
+ }
310
+ var pt = normalizePoint(props);
311
+ this._points.push(pt);
312
+ this.markDirty();
313
+ return pt;
314
+ };
315
+ DiagramDataModel.prototype.addConnection = function (props) {
316
+ if (this._connections.length >= MAX_DIAGRAM_CONNECTIONS) {
317
+ throw new DiagramModelError('limit_exceeded', "Cannot add connection: MAX_DIAGRAM_CONNECTIONS (" + String(MAX_DIAGRAM_CONNECTIONS) + ") reached.");
318
+ }
319
+ if (this._connections.some(function (c) { return c.modelId === props.modelId; })) {
320
+ throw new DiagramModelError('inconsistent_graph', "Duplicate connection modelId=" + props.modelId + ".");
321
+ }
322
+ var cxn = normalizeConnection(props);
323
+ this._connections.push(cxn);
324
+ this.markDirty();
325
+ return cxn;
326
+ };
327
+ /**
328
+ * Append a child node under parent via parOf.
329
+ * Creates point + connection; assigns next srcOrd.
330
+ */
331
+ DiagramDataModel.prototype.appendChild = function (parentId, child, connectionModelId) {
332
+ if (!this.getPoint(parentId)) {
333
+ throw new DiagramModelError('unknown_point', "Parent modelId=" + parentId + " not found.");
334
+ }
335
+ var siblings = this._connections.filter(function (c) { return c.type === 'parOf' && c.srcId === parentId; });
336
+ var nextOrd = siblings.length === 0 ? 0 : Math.max.apply(Math, __spread(siblings.map(function (s) { return s.srcOrd; }))) + 1;
337
+ var point = this.addPoint(child);
338
+ var connection = this.addConnection({
339
+ modelId: connectionModelId,
340
+ type: 'parOf',
341
+ srcId: parentId,
342
+ destId: child.modelId,
343
+ srcOrd: nextOrd,
344
+ destOrd: 0
345
+ });
346
+ return {
347
+ point: point,
348
+ connection: connection
349
+ };
350
+ };
351
+ /**
352
+ * Remove a node and its incident connections (and optionally subtree).
353
+ * When `recursive` is true, removes descendants via parOf.
354
+ */
355
+ DiagramDataModel.prototype.removeNode = function (modelId, recursive) {
356
+ var _this = this;
357
+ if (recursive === void 0) { recursive = true; }
358
+ if (!this.getPoint(modelId)) {
359
+ throw new DiagramModelError('unknown_point', "No point with modelId=" + modelId + ".");
360
+ }
361
+ var toRemove = new Set();
362
+ var visit = function (id) {
363
+ var e_5, _a;
364
+ if (toRemove.has(id))
365
+ return;
366
+ toRemove.add(id);
367
+ if (!recursive)
368
+ return;
369
+ try {
370
+ for (var _b = __values(_this._connections), _c = _b.next(); !_c.done; _c = _b.next()) {
371
+ var c = _c.value;
372
+ if (c.type === 'parOf' && c.srcId === id)
373
+ visit(c.destId);
374
+ }
375
+ }
376
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
377
+ finally {
378
+ try {
379
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
380
+ }
381
+ finally { if (e_5) throw e_5.error; }
382
+ }
383
+ };
384
+ visit(modelId);
385
+ for (var i = this._connections.length - 1; i >= 0; i--) {
386
+ var c = this._connections[i];
387
+ if (c === undefined)
388
+ continue;
389
+ if (toRemove.has(c.srcId) || toRemove.has(c.destId) || toRemove.has(c.modelId)) {
390
+ this._connections.splice(i, 1);
391
+ }
392
+ }
393
+ for (var i = this._points.length - 1; i >= 0; i--) {
394
+ var p = this._points[i];
395
+ if (p !== undefined && toRemove.has(p.modelId)) {
396
+ this._points.splice(i, 1);
397
+ }
398
+ }
399
+ this.markDirty();
400
+ };
401
+ /**
402
+ * Deep clone of the model (new instance, dirty=false unless copyDirty).
403
+ */
404
+ DiagramDataModel.prototype.clone = function (options) {
405
+ var m = new DiagramDataModel({
406
+ points: this._points.map(function (p) { return ({
407
+ modelId: p.modelId,
408
+ type: p.type,
409
+ cxnId: p.cxnId,
410
+ body: p.body
411
+ }); }),
412
+ connections: this._connections.map(function (c) { return ({
413
+ modelId: c.modelId,
414
+ type: c.type,
415
+ srcId: c.srcId,
416
+ destId: c.destId,
417
+ srcOrd: c.srcOrd,
418
+ destOrd: c.destOrd,
419
+ parTransId: c.parTransId,
420
+ sibTransId: c.sibTransId,
421
+ presId: c.presId,
422
+ body: c.body
423
+ }); }),
424
+ background: this._background,
425
+ whole: this._whole,
426
+ extLst: this._extLst
427
+ });
428
+ if ((options == null ? void 0 : options.copyDirty) && this._dirty) {
429
+ m.markDirty();
430
+ }
431
+ else if (this._originalBytes && !this._dirty) {
432
+ m.setOriginalBytes(this._originalBytes);
433
+ m.clearDirty(this._originalBytes);
434
+ }
435
+ return m;
436
+ };
437
+ return DiagramDataModel;
438
+ }());
439
+ export { DiagramDataModel };
440
+ _a = DIAGRAM_DATA_MODEL_BRAND;
441
+ /**
442
+ * @private
443
+ */
444
+ export function isDiagramDataModel(value) {
445
+ return value instanceof DiagramDataModel;
446
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Parsers: ElementTree → diagram models/views.
3
+ * NEVER invent markup; preserve unknown children under body/extLst.
4
+ *
5
+ * Citations: dml-diagram.xsd CT_DataModel/CT_Pt/CT_Cxn/CT_RelIds,
6
+ * CT_DiagramDefinition, CT_StyleDefinition, CT_ColorTransform;
7
+ * [MS-ODRAWXML] drawing root.
8
+ */
9
+ import { DiagramDataModel } from './diagram-data-model';
10
+ import { DiagramColors, DiagramDrawing, DiagramLayout, DiagramQuickStyle } from './diagram-views';
11
+ import { ElementNode } from './element-tree';
12
+ /**
13
+ * Parse CT_DataModel (`dgm:dataModel`).
14
+ * dml-diagram.xsd CT_DataModel: ptLst, cxnLst, bg, whole, extLst.
15
+ */
16
+ export declare function parseDiagramData(tree: ElementNode): DiagramDataModel;
17
+ /** Parse CT_DiagramDefinition (`dgm:layoutDef`). */
18
+ export declare function parseDiagramLayout(tree: ElementNode): DiagramLayout;
19
+ /** Parse CT_StyleDefinition (`dgm:styleDef`). */
20
+ export declare function parseDiagramQuickStyle(tree: ElementNode): DiagramQuickStyle;
21
+ /** Parse CT_ColorTransform (`dgm:colorsDef`). */
22
+ export declare function parseDiagramColors(tree: ElementNode): DiagramColors;
23
+ /**
24
+ * Parse Microsoft diagram drawing root.
25
+ * Accepts `dsp:drawing` or any element in DSP_NAMESPACE; also tolerates
26
+ * unknown root when namespace matches MS drawing content (preserve tree).
27
+ */
28
+ export declare function parseDiagramDrawing(tree: ElementNode): DiagramDrawing;
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Parsers: ElementTree → diagram models/views.
3
+ * NEVER invent markup; preserve unknown children under body/extLst.
4
+ *
5
+ * Citations: dml-diagram.xsd CT_DataModel/CT_Pt/CT_Cxn/CT_RelIds,
6
+ * CT_DiagramDefinition, CT_StyleDefinition, CT_ColorTransform;
7
+ * [MS-ODRAWXML] drawing root.
8
+ */
9
+ import { isANamespace, isDgmNamespace, MAX_DIAGRAM_CONNECTIONS, MAX_DIAGRAM_POINTS } from './constants';
10
+ import { DiagramDataModel } from './diagram-data-model';
11
+ import { DiagramColors, DiagramDrawing, DiagramLayout, DiagramQuickStyle } from './diagram-views';
12
+ import { cloneElement, findChild, findChildren, getAttr } from './element-tree';
13
+ import { DiagramParseError } from './errors';
14
+ var PT_TYPES = new Set(['node', 'asst', 'doc', 'pres', 'parTrans', 'sibTrans']);
15
+ var CXN_TYPES = new Set(['parOf', 'presOf', 'presParOf', 'unknownRelationship']);
16
+ function requireDgmRoot(tree, localName) {
17
+ if (!isDgmNamespace(tree.namespaceUri) || tree.localName !== localName) {
18
+ throw new DiagramParseError('invalid_root', "Expected dgm:" + localName + " root, got {" + (tree.namespaceUri != null ? tree.namespaceUri : 'null') + "}" + tree.localName + ".");
19
+ }
20
+ }
21
+ function parsePointType(raw) {
22
+ if (raw == null || raw === '')
23
+ return 'node';
24
+ if (!PT_TYPES.has(raw)) {
25
+ // Preserve unknown as node with body? Prefer strict enum — map unknown to node
26
+ // but keep attribute via body is not needed; XSD enumeration — accept known only.
27
+ return 'node';
28
+ }
29
+ return raw;
30
+ }
31
+ function parseCxnType(raw) {
32
+ // XSD default parOf
33
+ if (raw == null || raw === '')
34
+ return 'parOf';
35
+ if (!CXN_TYPES.has(raw))
36
+ return 'parOf';
37
+ return raw;
38
+ }
39
+ function parseOrd(raw, attrName) {
40
+ if (raw == null || raw === '') {
41
+ throw new DiagramParseError('missing_required', "Connection missing required attribute " + attrName + ".");
42
+ }
43
+ var n = Number(raw);
44
+ if (!Number.isFinite(n)) {
45
+ throw new DiagramParseError('invalid_attribute', "Connection " + attrName + " is not a number: " + raw);
46
+ }
47
+ return n;
48
+ }
49
+ /**
50
+ * Wrap remaining element children as a synthetic body root when multiple,
51
+ * or single child as body, so round-trip can re-emit them under pt/cxn.
52
+ */
53
+ function bodyFromRemainder(children) {
54
+ if (children.length === 0)
55
+ return null;
56
+ var first = children[0];
57
+ if (children.length === 1 && first !== undefined)
58
+ return cloneElement(first);
59
+ return { kind: 'element',
60
+ localName: '_body',
61
+ namespaceUri: null,
62
+ attributes: [],
63
+ children: children.map(function (c) { return cloneElement(c); })
64
+ };
65
+ }
66
+ function parsePt(el) {
67
+ var modelId = getAttr(el, 'modelId');
68
+ if (modelId == null || modelId === '') {
69
+ throw new DiagramParseError('missing_required', 'dgm:pt missing required modelId.');
70
+ }
71
+ var type = parsePointType(getAttr(el, 'type'));
72
+ var cxnId = function () {
73
+ var _nc = getAttr(el, 'cxnId');
74
+ return _nc != null ? _nc : '0';
75
+ }();
76
+ // Known child names kept under body as full subtrees (prSet, spPr, t, extLst, unknown).
77
+ var kids = el.children.filter(function (c) { return c.kind === 'element'; });
78
+ return {
79
+ modelId: modelId,
80
+ type: type,
81
+ cxnId: cxnId,
82
+ body: bodyFromRemainder(kids)
83
+ };
84
+ }
85
+ function parseCxn(el) {
86
+ var modelId = getAttr(el, 'modelId');
87
+ if (modelId == null || modelId === '') {
88
+ throw new DiagramParseError('missing_required', 'dgm:cxn missing required modelId.');
89
+ }
90
+ var srcId = getAttr(el, 'srcId');
91
+ var destId = getAttr(el, 'destId');
92
+ if (srcId == null || srcId === '' || destId == null || destId === '') {
93
+ throw new DiagramParseError('missing_required', "dgm:cxn modelId=" + modelId + " missing srcId/destId.");
94
+ }
95
+ var kids = el.children.filter(function (c) { return c.kind === 'element'; });
96
+ return {
97
+ modelId: modelId,
98
+ type: parseCxnType(getAttr(el, 'type')),
99
+ srcId: srcId,
100
+ destId: destId,
101
+ srcOrd: parseOrd(getAttr(el, 'srcOrd'), 'srcOrd'),
102
+ destOrd: parseOrd(getAttr(el, 'destOrd'), 'destOrd'),
103
+ parTransId: function () {
104
+ var _nc = getAttr(el, 'parTransId');
105
+ return _nc != null ? _nc : '0';
106
+ }(),
107
+ sibTransId: function () {
108
+ var _nc = getAttr(el, 'sibTransId');
109
+ return _nc != null ? _nc : '0';
110
+ }(),
111
+ presId: function () {
112
+ var _nc = getAttr(el, 'presId');
113
+ return _nc != null ? _nc : '';
114
+ }(),
115
+ body: bodyFromRemainder(kids)
116
+ };
117
+ }
118
+ /**
119
+ * Parse CT_DataModel (`dgm:dataModel`).
120
+ * dml-diagram.xsd CT_DataModel: ptLst, cxnLst, bg, whole, extLst.
121
+ */
122
+ export function parseDiagramData(tree) {
123
+ requireDgmRoot(tree, 'dataModel');
124
+ var ptLst = findChild(tree, 'ptLst', isDgmNamespace);
125
+ var cxnLst = findChild(tree, 'cxnLst', isDgmNamespace);
126
+ var bg = findChild(tree, 'bg', isDgmNamespace);
127
+ var whole = findChild(tree, 'whole', isDgmNamespace);
128
+ // extLst is typically a:extLst under dataModel (DrawingML).
129
+ var extLst = function () {
130
+ var _nc = function () {
131
+ var _nc = findChild(tree, 'extLst', isANamespace);
132
+ return _nc != null ? _nc : findChild(tree, 'extLst', isDgmNamespace);
133
+ }();
134
+ return _nc != null ? _nc : findChild(tree, 'extLst');
135
+ }();
136
+ var ptEls = ptLst ? findChildren(ptLst, 'pt', isDgmNamespace) : [];
137
+ var cxnEls = cxnLst ? findChildren(cxnLst, 'cxn', isDgmNamespace) : [];
138
+ if (ptEls.length > MAX_DIAGRAM_POINTS) {
139
+ throw new DiagramParseError('limit_exceeded', "Point count " + String(ptEls.length) + " exceeds MAX_DIAGRAM_POINTS (" + String(MAX_DIAGRAM_POINTS) + ").");
140
+ }
141
+ if (cxnEls.length > MAX_DIAGRAM_CONNECTIONS) {
142
+ throw new DiagramParseError('limit_exceeded', "Connection count " + String(cxnEls.length) + " exceeds MAX_DIAGRAM_CONNECTIONS (" + String(MAX_DIAGRAM_CONNECTIONS) + ").");
143
+ }
144
+ var points = ptEls.map(parsePt);
145
+ var connections = cxnEls.map(parseCxn);
146
+ return new DiagramDataModel({
147
+ points: points,
148
+ connections: connections,
149
+ background: bg ? cloneElement(bg) : null,
150
+ whole: whole ? cloneElement(whole) : null,
151
+ extLst: extLst ? cloneElement(extLst) : null
152
+ });
153
+ }
154
+ /** Parse CT_DiagramDefinition (`dgm:layoutDef`). */
155
+ export function parseDiagramLayout(tree) {
156
+ requireDgmRoot(tree, 'layoutDef');
157
+ return new DiagramLayout(tree);
158
+ }
159
+ /** Parse CT_StyleDefinition (`dgm:styleDef`). */
160
+ export function parseDiagramQuickStyle(tree) {
161
+ requireDgmRoot(tree, 'styleDef');
162
+ return new DiagramQuickStyle(tree);
163
+ }
164
+ /** Parse CT_ColorTransform (`dgm:colorsDef`). */
165
+ export function parseDiagramColors(tree) {
166
+ requireDgmRoot(tree, 'colorsDef');
167
+ return new DiagramColors(tree);
168
+ }
169
+ /**
170
+ * Parse Microsoft diagram drawing root.
171
+ * Accepts `dsp:drawing` or any element in DSP_NAMESPACE; also tolerates
172
+ * unknown root when namespace matches MS drawing content (preserve tree).
173
+ */
174
+ export function parseDiagramDrawing(tree) {
175
+ // Prefer dsp:drawing; if not, still wrap as opaque drawing view so
176
+ // round-trip of unknown MS roots is possible without inventing markup.
177
+ if (tree.localName === 'drawing' || (tree.namespaceUri != null && tree.namespaceUri.indexOf('drawing/2008/diagram') !== -1)) {
178
+ return new DiagramDrawing(tree);
179
+ }
180
+ // Accept any tree as opaque drawing for catalog load of non-standard caches.
181
+ return new DiagramDrawing(tree);
182
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Serializers: diagram models/views → ElementTree (Transitional write).
3
+ * Never invent optional markup beyond model state; emit XSD defaults only
4
+ * when the model holds non-default values or required attributes.
5
+ *
6
+ * Citations: dml-diagram.xsd; ECMA-376 Transitional namespaces.
7
+ */
8
+ import { DiagramDataModel } from './diagram-data-model';
9
+ import { DiagramColors, DiagramDrawing, DiagramLayout, DiagramQuickStyle } from './diagram-views';
10
+ import { ElementNode } from './element-tree';
11
+ /**
12
+ * Serialize CT_DataModel as `dgm:dataModel` (Transitional NS).
13
+ */
14
+ export declare function serializeDiagramData(model: DiagramDataModel): ElementNode;
15
+ export declare function serializeDiagramLayout(view: DiagramLayout): ElementNode;
16
+ export declare function serializeDiagramQuickStyle(view: DiagramQuickStyle): ElementNode;
17
+ export declare function serializeDiagramColors(view: DiagramColors): ElementNode;
18
+ export declare function serializeDiagramDrawing(view: DiagramDrawing): ElementNode;
19
+ /** Helper: emit a minimal a:extLst shell (for tests / extensions). */
20
+ export declare function extLst(children?: ElementNode[]): ElementNode;