@salesforcedevs/docs-components 1.3.296 → 1.3.300-amf-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.296",
3
+ "version": "1.3.300-amf-fix-alpha",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -24,5 +24,5 @@
24
24
  "@types/lodash.orderby": "^4.6.7",
25
25
  "@types/lodash.uniqby": "^4.7.7"
26
26
  },
27
- "gitHead": "7a3e47bb11802dbded4c5bd3814b408cbeedecd7"
27
+ "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
28
28
  }
@@ -9,13 +9,12 @@ import {
9
9
  } from "./utils";
10
10
  import type { TopicModel } from "./types";
11
11
  import { Json } from "typings/custom";
12
-
13
12
  const TABLE_SIZE_MATCH = "769px";
14
13
 
15
14
  export default class AmfTopic extends LightningElement {
16
15
  private _model: TopicModel | undefined;
17
16
  private amf: Json;
18
- private type: string | undefined;
17
+ private type: any;
19
18
 
20
19
  @api
21
20
  get model(): TopicModel | undefined {
@@ -27,13 +26,13 @@ export default class AmfTopic extends LightningElement {
27
26
  !this.amf ||
28
27
  (value && this._model && value.amf !== this._model?.amf)
29
28
  ) {
30
- this.amf = value && clone(value.amf);
29
+ this.amf = value && this.clone(value.amf);
31
30
  }
32
31
  if (
33
32
  !this.type ||
34
33
  (value && this._model && value.type !== this._model?.type)
35
34
  ) {
36
- this.type = value && clone(value.type);
35
+ this.type = value && this.getTypeCloned(value.type);
37
36
  }
38
37
 
39
38
  this._model = value;
@@ -43,6 +42,52 @@ export default class AmfTopic extends LightningElement {
43
42
  // else { Remove child? No model, seems like no component should be shown. }
44
43
  }
45
44
 
45
+ cloneWithWorker(value) {
46
+ return new Promise((resolve, reject) => {
47
+ const worker = new Worker("./cloneAmfObject.ts");
48
+
49
+ worker.onmessage = (event) => {
50
+ resolve(event.data);
51
+ worker.terminate();
52
+ };
53
+
54
+ worker.onerror = (error) => {
55
+ reject(error);
56
+ worker.terminate();
57
+ };
58
+
59
+ worker.postMessage(value);
60
+ });
61
+ }
62
+
63
+ /**
64
+ * The underlying web components we use from api-console mutate their models we pass in.
65
+ * Since LWC makes them Read Only, we need to copy them before passing to the Web Component.
66
+ * @param value JSON Serializable object to clone.
67
+ * @returns A copy of Value. One that has been serialized and parsed via JSON. (Functions, Regex, etc are not preserved.)
68
+ */
69
+ // function clone(value: any): any {
70
+ // return JSON.parse(JSON.stringify(value));
71
+ // }
72
+
73
+ async clone(value: any) {
74
+ try {
75
+ const clonedObject = await this.cloneWithWorker(value);
76
+ return clonedObject;
77
+ } catch (error) {
78
+ console.error("Error cloning value:", error);
79
+ return null;
80
+ }
81
+ }
82
+
83
+ async getTypeCloned(value: any) {
84
+ const typeObj = await this.clone(value.type);
85
+ if (typeObj) {
86
+ return typeObj;
87
+ }
88
+ return "";
89
+ }
90
+
46
91
  update(): void {
47
92
  if (!this.model) {
48
93
  throw new Error("Amf TopicModel undefined when trying to update");
@@ -105,13 +150,3 @@ export default class AmfTopic extends LightningElement {
105
150
  }
106
151
  }
107
152
  }
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
- }
@@ -0,0 +1,5 @@
1
+ onmessage = function (event) {
2
+ const value = event.data;
3
+ const clonedValue = JSON.parse(JSON.stringify(value));
4
+ postMessage(clonedValue);
5
+ };
@@ -112,16 +112,23 @@ export default class Breadcrumbs extends LightningElement {
112
112
 
113
113
  renderedCallback(): void {
114
114
  if (!this.observer) {
115
- this.observer = new ResizeObserver((entries) => {
116
- const [nav] = entries;
117
- if (this.navWidth === nav.contentRect.width) {
118
- return;
119
- }
120
- this.navWidth = nav.contentRect.width;
121
- this.updateDropdownOptionAmount();
122
- });
123
-
124
- this.observer.observe(this.template.querySelector("nav")!);
115
+ try {
116
+ this.observer = new ResizeObserver((entries) => {
117
+ const [nav] = entries;
118
+ if (this.navWidth === nav.contentRect.width) {
119
+ return;
120
+ }
121
+ this.navWidth = nav.contentRect.width;
122
+ this.updateDropdownOptionAmount();
123
+ });
124
+
125
+ this.observer.observe(this.template.querySelector("nav")!);
126
+ } catch (error) {
127
+ console.error(
128
+ "Error occured while setting up ResizeObserver on breadcrumbs",
129
+ error
130
+ );
131
+ }
125
132
  }
126
133
  }
127
134
 
package/LICENSE DELETED
@@ -1,12 +0,0 @@
1
- Copyright (c) 2020, Salesforce.com, Inc.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
8
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
-
10
- * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.