@metadev/daga 4.2.9 → 4.2.10

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.
package/Changelog.md CHANGED
@@ -6,6 +6,10 @@ List of releases and changes.
6
6
 
7
7
  ## Next release Joyeuse
8
8
 
9
+ ## v. 4.2.10
10
+
11
+ - Fix errors with cloned objects containing functions [#345](https://github.com/metadevpro/daga/pull/345)
12
+
9
13
  ## v. 4.2.9
10
14
 
11
15
  - Enable configuring the text heading the diagram properties component to values other than `'Diagram properties'` [#341](https://github.com/metadevpro/daga/pull/341)
package/index.cjs.js CHANGED
@@ -1186,6 +1186,25 @@ const numberOfRows = s => {
1186
1186
  return ((_a = s.match(/\n/g)) === null || _a === void 0 ? void 0 : _a.length) || 0;
1187
1187
  };
1188
1188
 
1189
+ /**
1190
+ * Clones an object with support for functions.
1191
+ * @private
1192
+ */
1193
+ const clone = o => {
1194
+ if (typeof o !== 'object') {
1195
+ return o;
1196
+ }
1197
+ const res = {};
1198
+ for (const e of Object.entries(o)) {
1199
+ if (typeof e[1] === 'object') {
1200
+ res[e[0]] = clone(e[1]);
1201
+ } else {
1202
+ res[e[0]] = e[1];
1203
+ }
1204
+ }
1205
+ return res;
1206
+ };
1207
+
1189
1208
  /******************************************************************************
1190
1209
  Copyright (c) Microsoft Corporation.
1191
1210
 
@@ -2050,7 +2069,7 @@ class ValueSet {
2050
2069
  if (property.type === exports.Type.Object) {
2051
2070
  this.valueSets[key] = this.constructSubValueSet(key);
2052
2071
  } else {
2053
- this.values[key] = structuredClone(property.defaultValue);
2072
+ this.values[key] = clone(property.defaultValue);
2054
2073
  }
2055
2074
  if (rootAttribute !== undefined && rootAttribute !== null) {
2056
2075
  if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
@@ -2074,7 +2093,7 @@ class ValueSet {
2074
2093
  const property = this.propertySet.getProperty(key);
2075
2094
  const propertySet = new PropertySet(property.properties);
2076
2095
  const valueSet = new ValueSet(propertySet, this.rootElement);
2077
- valueSet.overwriteValues(structuredClone(property.defaultValue));
2096
+ valueSet.overwriteValues(clone(property.defaultValue));
2078
2097
  return valueSet;
2079
2098
  }
2080
2099
  /**
@@ -5080,7 +5099,7 @@ class AddNodeCollabAction {
5080
5099
  node.label.text = this.label || '';
5081
5100
  }
5082
5101
  if (this.values !== undefined) {
5083
- node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
5102
+ node.valueSet.setValues(clone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
5084
5103
  } else {
5085
5104
  node.valueSet.resetValues();
5086
5105
  }
@@ -7307,7 +7326,7 @@ class DiagramUserSelection extends DiagramElementSet {
7307
7326
  if (selectedValueSet) {
7308
7327
  this.propertyEditorSelection = selection;
7309
7328
  if (makeUpdateValuesAction) {
7310
- this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
7329
+ this.propertyEditorValues = clone(selectedValueSet.getValues());
7311
7330
  }
7312
7331
  if (propertyEditor) {
7313
7332
  if (selection instanceof DiagramNode || selection instanceof DiagramConnection) {
@@ -7351,7 +7370,7 @@ class DiagramUserSelection extends DiagramElementSet {
7351
7370
  return;
7352
7371
  }
7353
7372
  const from = this.propertyEditorValues;
7354
- const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
7373
+ const to = clone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
7355
7374
  const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === void 0 ? void 0 : _c.valueSet);
7356
7375
  const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
7357
7376
  currentAction.do();
package/index.esm.js CHANGED
@@ -1165,6 +1165,25 @@ const numberOfRows = s => {
1165
1165
  return ((_a = s.match(/\n/g)) === null || _a === void 0 ? void 0 : _a.length) || 0;
1166
1166
  };
1167
1167
 
1168
+ /**
1169
+ * Clones an object with support for functions.
1170
+ * @private
1171
+ */
1172
+ const clone = o => {
1173
+ if (typeof o !== 'object') {
1174
+ return o;
1175
+ }
1176
+ const res = {};
1177
+ for (const e of Object.entries(o)) {
1178
+ if (typeof e[1] === 'object') {
1179
+ res[e[0]] = clone(e[1]);
1180
+ } else {
1181
+ res[e[0]] = e[1];
1182
+ }
1183
+ }
1184
+ return res;
1185
+ };
1186
+
1168
1187
  /******************************************************************************
1169
1188
  Copyright (c) Microsoft Corporation.
1170
1189
 
@@ -2029,7 +2048,7 @@ class ValueSet {
2029
2048
  if (property.type === Type.Object) {
2030
2049
  this.valueSets[key] = this.constructSubValueSet(key);
2031
2050
  } else {
2032
- this.values[key] = structuredClone(property.defaultValue);
2051
+ this.values[key] = clone(property.defaultValue);
2033
2052
  }
2034
2053
  if (rootAttribute !== undefined && rootAttribute !== null) {
2035
2054
  if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
@@ -2053,7 +2072,7 @@ class ValueSet {
2053
2072
  const property = this.propertySet.getProperty(key);
2054
2073
  const propertySet = new PropertySet(property.properties);
2055
2074
  const valueSet = new ValueSet(propertySet, this.rootElement);
2056
- valueSet.overwriteValues(structuredClone(property.defaultValue));
2075
+ valueSet.overwriteValues(clone(property.defaultValue));
2057
2076
  return valueSet;
2058
2077
  }
2059
2078
  /**
@@ -5059,7 +5078,7 @@ class AddNodeCollabAction {
5059
5078
  node.label.text = this.label || '';
5060
5079
  }
5061
5080
  if (this.values !== undefined) {
5062
- node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
5081
+ node.valueSet.setValues(clone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
5063
5082
  } else {
5064
5083
  node.valueSet.resetValues();
5065
5084
  }
@@ -7286,7 +7305,7 @@ class DiagramUserSelection extends DiagramElementSet {
7286
7305
  if (selectedValueSet) {
7287
7306
  this.propertyEditorSelection = selection;
7288
7307
  if (makeUpdateValuesAction) {
7289
- this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
7308
+ this.propertyEditorValues = clone(selectedValueSet.getValues());
7290
7309
  }
7291
7310
  if (propertyEditor) {
7292
7311
  if (selection instanceof DiagramNode || selection instanceof DiagramConnection) {
@@ -7330,7 +7349,7 @@ class DiagramUserSelection extends DiagramElementSet {
7330
7349
  return;
7331
7350
  }
7332
7351
  const from = this.propertyEditorValues;
7333
- const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
7352
+ const to = clone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
7334
7353
  const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === void 0 ? void 0 : _c.valueSet);
7335
7354
  const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
7336
7355
  currentAction.do();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metadev/daga",
3
- "version": "4.2.9",
3
+ "version": "4.2.10",
4
4
  "dependencies": {},
5
5
  "peerDependencies": {
6
6
  "d3": "^7.9.0",
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Clones an object with support for functions.
3
+ * @private
4
+ */
5
+ export declare const clone: <T>(o: T) => T;
@@ -1,9 +1,4 @@
1
1
  import { DiagramConfig } from '../diagram/config/diagram-config';
2
- /**
3
- * Creates the structuredClone function if it doesn't exist.
4
- * @private
5
- */
6
- export declare const createStructuredClone: () => void;
7
2
  /**
8
3
  * Generic diagram configuration used for testing.
9
4
  * @private