@salesforcedevs/docs-components 1.3.300-async-fix-alpha3 → 1.3.300-fix-alpha

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-alpha3",
3
+ "version": "1.3.300-fix-alpha",
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
  };
@@ -23,28 +23,24 @@ export default class AmfTopic extends LightningElement {
23
23
  }
24
24
 
25
25
  set model(value: TopicModel) {
26
- const amfClonePromise =
26
+ if (
27
27
  !this.amf ||
28
28
  (value && this._model && value.amf !== this._model?.amf)
29
- ? clone(value.amf)
30
- : Promise.resolve(this.amf);
31
-
32
- const typeClonePromise =
29
+ ) {
30
+ this.amf = value && JSON.parse(value.amf);
31
+ }
32
+ if (
33
33
  !this.type ||
34
34
  (value && this._model && value.type !== this._model?.type)
35
- ? clone(value.type)
36
- : Promise.resolve(this.type);
35
+ ) {
36
+ this.type = value && value.type;
37
+ }
37
38
 
38
- Promise.all([amfClonePromise, typeClonePromise])
39
- .then(([clonedAmf, clonedType]) => {
40
- this.amf = clonedAmf;
41
- this.type = clonedType;
42
- this._model = value;
43
- this.update();
44
- })
45
- .catch((error) => {
46
- console.error("Error cloning model:", error);
47
- });
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. }
48
44
  }
49
45
 
50
46
  update(): void {
@@ -102,12 +98,10 @@ export default class AmfTopic extends LightningElement {
102
98
  }
103
99
 
104
100
  renderedCallback(): void {
105
- if (this._model) {
106
- try {
107
- this.update();
108
- } catch (error) {
109
- console.error(error);
110
- }
101
+ try {
102
+ this.update();
103
+ } catch (error) {
104
+ console.error(error);
111
105
  }
112
106
  }
113
107
  }
@@ -116,51 +110,8 @@ export default class AmfTopic extends LightningElement {
116
110
  * The underlying web components we use from api-console mutate their models we pass in.
117
111
  * Since LWC makes them Read Only, we need to copy them before passing to the Web Component.
118
112
  * @param value JSON Serializable object to clone.
119
- * @returns A Promise that resolves with a copy of Value, serialized and parsed via JSON.
113
+ * @returns A copy of Value. One that has been serialized and parsed via JSON. (Functions, Regex, etc are not preserved.)
120
114
  */
121
- function clone(value: any): Promise<any> {
122
- return new Promise((resolve, reject) => {
123
- if (window.Worker) {
124
- const workerCode = `
125
- onmessage = function(e) {
126
- try {
127
- const jsonObject = JSON.parse(e.data);
128
- postMessage({ success: true, data: jsonObject });
129
- } catch (error) {
130
- postMessage({ success: false, error: error.message });
131
- }
132
- };
133
- `;
134
-
135
- const blob = new Blob([workerCode], {
136
- type: "application/javascript"
137
- });
138
- const workerURL = URL.createObjectURL(blob);
139
- const worker = new Worker(workerURL);
140
-
141
- try {
142
- const jsonObj = JSON.stringify(value);
143
- worker.postMessage(jsonObj);
144
- } catch (err) {
145
- reject(err);
146
- worker.terminate();
147
- }
148
-
149
- worker.onmessage = function (e) {
150
- worker.terminate();
151
- if (e.data.success) {
152
- resolve(e.data.data);
153
- } else {
154
- reject(new Error(e.data.error));
155
- }
156
- };
157
-
158
- worker.onerror = function (e) {
159
- worker.terminate();
160
- reject(new Error(e.message));
161
- };
162
- } else {
163
- reject(new Error("Your browser doesn't support web workers."));
164
- }
165
- });
166
- }
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
- };