@salesforcedevs/docs-components 1.3.300-alpha.0 → 1.3.300-async-fix-alpha2

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-alpha.0",
3
+ "version": "1.3.300-async-fix-alpha2",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -17,7 +17,8 @@
17
17
  "lodash.orderby": "^4.6.0",
18
18
  "lodash.uniqby": "^4.7.0",
19
19
  "query-string": "^7.1.3",
20
- "sentence-case": "^3.0.4"
20
+ "sentence-case": "^3.0.4",
21
+ "yieldable-json": "^2.0.1"
21
22
  },
22
23
  "devDependencies": {
23
24
  "@types/classnames": "^2.2.10",
@@ -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;
17
+ private amf: Json | undefined;
18
18
  private type: string | undefined;
19
19
 
20
20
  @api
@@ -23,24 +23,28 @@ export default class AmfTopic extends LightningElement {
23
23
  }
24
24
 
25
25
  set model(value: TopicModel) {
26
- if (
26
+ const amfClonePromise =
27
27
  !this.amf ||
28
28
  (value && this._model && value.amf !== this._model?.amf)
29
- ) {
30
- this.amf = value && clone(value.amf);
31
- }
32
- if (
29
+ ? clone(value.amf)
30
+ : Promise.resolve(this.amf);
31
+
32
+ const typeClonePromise =
33
33
  !this.type ||
34
34
  (value && this._model && value.type !== this._model?.type)
35
- ) {
36
- this.type = value && clone(value.type);
37
- }
35
+ ? clone(value.type)
36
+ : Promise.resolve(this.type);
38
37
 
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. }
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
+ });
44
48
  }
45
49
 
46
50
  update(): void {
@@ -98,10 +102,12 @@ export default class AmfTopic extends LightningElement {
98
102
  }
99
103
 
100
104
  renderedCallback(): void {
101
- try {
102
- this.update();
103
- } catch (error) {
104
- console.error(error);
105
+ if (this._model) {
106
+ try {
107
+ this.update();
108
+ } catch (error) {
109
+ console.error(error);
110
+ }
105
111
  }
106
112
  }
107
113
  }
@@ -110,8 +116,48 @@ export default class AmfTopic extends LightningElement {
110
116
  * The underlying web components we use from api-console mutate their models we pass in.
111
117
  * Since LWC makes them Read Only, we need to copy them before passing to the Web Component.
112
118
  * @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.)
119
+ * @returns A Promise that resolves with a copy of Value, serialized and parsed via JSON.
114
120
  */
115
- function clone(value: any): any {
116
- return JSON.parse(JSON.stringify(value));
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
+ }
147
+
148
+ worker.onmessage = function (e) {
149
+ if (e.data.success) {
150
+ resolve(e.data.data);
151
+ } else {
152
+ reject(new Error(e.data.error));
153
+ }
154
+ };
155
+
156
+ worker.onerror = function (e) {
157
+ reject(new Error(e.message));
158
+ };
159
+ } else {
160
+ reject(new Error("Your browser doesn't support web workers."));
161
+ }
162
+ });
117
163
  }
@@ -0,0 +1,3 @@
1
+ onmessage = function (event) {
2
+ postMessage(JSON.parse(JSON.stringify(event.data)));
3
+ };
@@ -12,7 +12,7 @@
12
12
 
13
13
  <div class="dx-callout-content">
14
14
  <p class="doc-status-title dx-callout-title dx-text-body-3">
15
- {header}
15
+ {title}
16
16
  </p>
17
17
  <span class="dx-callout-body dx-text-body-3">
18
18
  <slot onslotchange={onSlotChange}></slot>
@@ -3,7 +3,7 @@ import cx from "classnames";
3
3
  import { CalloutVariant, LightningSlotElement } from "typings/custom";
4
4
 
5
5
  export default class ContentCallout extends LightningElement {
6
- @api header!: string;
6
+ @api title!: string;
7
7
  @api variant!: CalloutVariant;
8
8
  cardVariant?: string;
9
9
  iconName?: string;
@@ -50,7 +50,7 @@
50
50
  </div>
51
51
  <div lwc:if={showToc} class="right-nav-bar is-sticky">
52
52
  <dx-toc
53
- header={tocTitle}
53
+ title={tocTitle}
54
54
  options={tocOptions}
55
55
  value={tocValue}
56
56
  ></dx-toc>
@@ -1,14 +1,14 @@
1
1
  <template>
2
2
  <h1 class={className} if:true={isAriaLevelOne}>
3
- <doc-heading-content header={header} hash={hash}></doc-heading-content>
3
+ <doc-heading-content title={title} hash={hash}></doc-heading-content>
4
4
  </h1>
5
5
  <h2 class={className} if:true={isAriaLevelTwo}>
6
- <doc-heading-content header={header} hash={hash}></doc-heading-content>
6
+ <doc-heading-content title={title} hash={hash}></doc-heading-content>
7
7
  </h2>
8
8
  <h3 class={className} if:true={isAriaLevelThree}>
9
- <doc-heading-content header={header} hash={hash}></doc-heading-content>
9
+ <doc-heading-content title={title} hash={hash}></doc-heading-content>
10
10
  </h3>
11
11
  <h4 class={className} if:true={isAriaLevelFour}>
12
- <doc-heading-content header={header} hash={hash}></doc-heading-content>
12
+ <doc-heading-content title={title} hash={hash}></doc-heading-content>
13
13
  </h4>
14
14
  </template>
@@ -13,7 +13,7 @@ export const displayLevels = Object.values(ariaDisplayLevels);
13
13
 
14
14
  // @ts-ignore: Really Dark Magic (TM) to do with ariaLevel needing explicit getter/setters
15
15
  export default class Heading extends LightningElement {
16
- @api header: string = "";
16
+ @api title: string = "";
17
17
  @api hash: string | null = null;
18
18
 
19
19
  @api
@@ -6,7 +6,7 @@ export default class HeadingAnchor extends LightningElement {
6
6
  @api iconSize?: IconSize = "override";
7
7
  @api iconSprite?: IconSprite = "utility";
8
8
  @api iconSymbol?: IconSymbol;
9
- @api header: string = "";
9
+ @api title: string = "";
10
10
  @api urlText: string = "";
11
11
 
12
12
  label: string = "Copy link to clipboard";
@@ -22,7 +22,7 @@ export default class HeadingAnchor extends LightningElement {
22
22
  }, 2000);
23
23
 
24
24
  try {
25
- if (this.header && this.urlText) {
25
+ if (this.title && this.urlText) {
26
26
  const [hostUrl] = window.location.href.split("#");
27
27
  const url = `${hostUrl}#${this.urlText}`;
28
28
  await navigator.clipboard.writeText(url);
@@ -1,7 +1,7 @@
1
1
  <template>
2
- <template if:false={hash}>{header}</template>
2
+ <template if:false={hash}>{title}</template>
3
3
  <template if:true={hash}>
4
- <span class="title">{header}&nbsp;</span>
4
+ <span class="title">{title}&nbsp;</span>
5
5
  <dx-tooltip placement="top" label={label}>
6
6
  <span class="button-container">
7
7
  <button onclick={copy} aria-label="copy">
@@ -1,7 +1,7 @@
1
1
  import { LightningElement, api } from "lwc";
2
2
 
3
3
  export default class HeadingContent extends LightningElement {
4
- @api header: string = "";
4
+ @api title: string = "";
5
5
  @api hash: string | null = null;
6
6
 
7
7
  label: string = "Copy link to clipboard";
@@ -18,7 +18,7 @@ export default class HeadingContent extends LightningElement {
18
18
  }, 2000);
19
19
 
20
20
  try {
21
- if (this.header && this.hash) {
21
+ if (this.title && this.hash) {
22
22
  const [hostUrl] = window.location.href.split("#");
23
23
  const url = `${hostUrl}#${this.hash}`;
24
24
  await navigator.clipboard.writeText(url);
@@ -10,7 +10,7 @@
10
10
  <div class="content">
11
11
  <dx-group-text
12
12
  class="description"
13
- header={header}
13
+ title={title}
14
14
  body={description}
15
15
  size="large"
16
16
  title-aria-level="1"
@@ -20,7 +20,7 @@
20
20
  </div>
21
21
  <div>
22
22
  <dx-group-text
23
- header={featuresListTitle}
23
+ title={featuresListTitle}
24
24
  size="medium"
25
25
  class="features"
26
26
  ></dx-group-text>
@@ -3,7 +3,7 @@ import { DocPhaseInfo, FeatureItem, Link } from "typings/custom";
3
3
 
4
4
  export default class Overview extends LightningElement {
5
5
  @api docPhaseInfo!: DocPhaseInfo;
6
- @api header!: string;
6
+ @api title!: string;
7
7
  @api description!: string;
8
8
  @api primaryLink!: Link;
9
9
  @api secondaryLink!: Link;