@salesforcedevs/docs-components 1.3.300-async-fix-alpha4 → 1.3.300-fix-alpha1

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-async-fix-alpha4",
3
+ "version": "1.3.300-fix-alpha1",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -1478,7 +1478,7 @@ export default class AmfReference extends LightningElement {
1478
1478
  // This updates the component in the content section.
1479
1479
  this.topicModel = {
1480
1480
  type,
1481
- amf: this.amfMap[referenceId].model,
1481
+ amf: JSON.stringify(this.amfMap[referenceId].model),
1482
1482
  parser: this.amfMap[referenceId].parser,
1483
1483
  id: amfId
1484
1484
  };
@@ -95,7 +95,7 @@ export interface ParsedTopicModel {
95
95
  export interface TopicModel {
96
96
  id: string;
97
97
  type: string;
98
- amf: AmfModel;
98
+ amf: string;
99
99
  parser: AmfParser;
100
100
  }
101
101
 
@@ -23,45 +23,24 @@ export default class AmfTopic extends LightningElement {
23
23
  }
24
24
 
25
25
  set model(value: TopicModel) {
26
- const amfNeedsClone =
26
+ if (
27
27
  !this.amf ||
28
- (value && this._model && value.amf !== this._model?.amf);
29
- const typeNeedsClone =
28
+ (value && this._model && value.amf !== this._model?.amf)
29
+ ) {
30
+ this.amf = value && JSON.parse(value.amf);
31
+ }
32
+ if (
30
33
  !this.type ||
31
- (value && this._model && value.type !== this._model?.type);
32
-
33
- this.cloneData(
34
- amfNeedsClone ? value.amf : this.amf,
35
- typeNeedsClone ? value.type : this.type
36
- )
37
- .then(([clonedAmf, clonedType]) => {
38
- this.amf = clonedAmf;
39
- this.type = clonedType;
40
- this._model = value;
41
- this.update();
42
- })
43
- .catch((error) => {
44
- console.error("Error cloning model:", error);
45
- });
46
- }
47
-
48
- async cloneData(
49
- amf: Json | undefined,
50
- type: string | undefined
51
- ): Promise<[Json, string]> {
52
- const clonedAmf = amf ? await this.clone(amf) : amf;
53
- const clonedType = type ? await this.clone(type) : type;
54
- return [clonedAmf, clonedType];
55
- }
34
+ (value && this._model && value.type !== this._model?.type)
35
+ ) {
36
+ this.type = value && value.type;
37
+ }
56
38
 
57
- async clone(value: any): Promise<any> {
58
- return new Promise((resolve, reject) => {
59
- try {
60
- resolve(JSON.parse(JSON.stringify(value)));
61
- } catch (error) {
62
- reject(error);
63
- }
64
- });
39
+ this._model = value;
40
+ if (this._model) {
41
+ this.update();
42
+ }
43
+ // else { Remove child? No model, seems like no component should be shown. }
65
44
  }
66
45
 
67
46
  update(): void {
@@ -112,18 +91,27 @@ export default class AmfTopic extends LightningElement {
112
91
  const isTabletOrDesktop = window.matchMedia(
113
92
  `(min-width: ${TABLE_SIZE_MATCH})`
114
93
  ).matches;
94
+
115
95
  if (isTabletOrDesktop) {
116
96
  window.scrollTo(0, 0);
117
97
  }
118
98
  }
119
99
 
120
100
  renderedCallback(): void {
121
- if (this._model) {
122
- try {
123
- this.update();
124
- } catch (error) {
125
- console.error(error);
126
- }
101
+ try {
102
+ this.update();
103
+ } catch (error) {
104
+ console.error(error);
127
105
  }
128
106
  }
129
107
  }
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
+ // }
@@ -1,3 +0,0 @@
1
- onmessage = function (event) {
2
- postMessage(JSON.parse(JSON.stringify(event.data)));
3
- };