@salesforcedevs/docs-components 1.3.300-fix-alpha1 → 1.3.300-fix-alpha3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.3.300-fix-alpha1",
3
+ "version": "1.3.300-fix-alpha3",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -1475,10 +1475,18 @@ export default class AmfReference extends LightningElement {
1475
1475
  // update topic view
1476
1476
  const { referenceId, amfId, type } = this.selectedTopic!;
1477
1477
 
1478
+ // Adding stringify inside try/catch
1479
+ let amfModelString = "";
1480
+ try {
1481
+ amfModelString = JSON.stringify(this.amfMap[referenceId].model);
1482
+ } catch (error) {
1483
+ console.error(`Error stringifying amf model: ${error}`);
1484
+ }
1485
+
1478
1486
  // This updates the component in the content section.
1479
1487
  this.topicModel = {
1480
1488
  type,
1481
- amf: JSON.stringify(this.amfMap[referenceId].model),
1489
+ amf: amfModelString,
1482
1490
  parser: this.amfMap[referenceId].parser,
1483
1491
  id: amfId
1484
1492
  };
@@ -14,7 +14,7 @@ const TABLE_SIZE_MATCH = "769px";
14
14
 
15
15
  export default class AmfTopic extends LightningElement {
16
16
  private _model: TopicModel | undefined;
17
- private amf: Json | undefined;
17
+ private amf: Json;
18
18
  private type: string | undefined;
19
19
 
20
20
  @api
@@ -27,7 +27,11 @@ export default class AmfTopic extends LightningElement {
27
27
  !this.amf ||
28
28
  (value && this._model && value.amf !== this._model?.amf)
29
29
  ) {
30
- this.amf = value && JSON.parse(value.amf);
30
+ try {
31
+ this.amf = value && JSON.parse(value.amf);
32
+ } catch (error) {
33
+ console.error(`Error parsing amf model: ${error}`);
34
+ }
31
35
  }
32
36
  if (
33
37
  !this.type ||
@@ -105,13 +109,3 @@ export default class AmfTopic extends LightningElement {
105
109
  }
106
110
  }
107
111
  }
108
-
109
- /**
110
- * The underlying web components we use from api-console mutate their models we pass in.
111
- * Since LWC makes them Read Only, we need to copy them before passing to the Web Component.
112
- * @param value JSON Serializable object to clone.
113
- * @returns A copy of Value. One that has been serialized and parsed via JSON. (Functions, Regex, etc are not preserved.)
114
- */
115
- // function clone(value: any): any {
116
- // return JSON.parse(JSON.stringify(value));
117
- // }
@@ -51,6 +51,6 @@ export type AmfModel = Json;
51
51
  export interface TopicModel {
52
52
  id: string;
53
53
  type: string;
54
- amf: AmfModel;
54
+ amf: string;
55
55
  parser: AmfModelParser;
56
56
  }