@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 +3 -2
- package/src/modules/doc/amfTopic/amfTopic.ts +67 -21
- package/src/modules/doc/amfTopic/worker.ts +3 -0
- package/src/modules/doc/contentCallout/contentCallout.html +1 -1
- package/src/modules/doc/contentCallout/contentCallout.ts +1 -1
- package/src/modules/doc/contentLayout/contentLayout.html +1 -1
- package/src/modules/doc/heading/heading.html +4 -4
- package/src/modules/doc/heading/heading.ts +1 -1
- package/src/modules/doc/headingAnchor/headingAnchor.ts +2 -2
- package/src/modules/doc/headingContent/headingContent.html +2 -2
- package/src/modules/doc/headingContent/headingContent.ts +2 -2
- package/src/modules/doc/overview/overview.html +2 -2
- package/src/modules/doc/overview/overview.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.3.300-
|
|
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
|
-
|
|
26
|
+
const amfClonePromise =
|
|
27
27
|
!this.amf ||
|
|
28
28
|
(value && this._model && value.amf !== this._model?.amf)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
37
|
-
}
|
|
35
|
+
? clone(value.type)
|
|
36
|
+
: Promise.resolve(this.type);
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
|
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
|
|
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
|
}
|
|
@@ -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
|
|
6
|
+
@api title!: string;
|
|
7
7
|
@api variant!: CalloutVariant;
|
|
8
8
|
cardVariant?: string;
|
|
9
9
|
iconName?: string;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<h1 class={className} if:true={isAriaLevelOne}>
|
|
3
|
-
<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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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}>{
|
|
2
|
+
<template if:false={hash}>{title}</template>
|
|
3
3
|
<template if:true={hash}>
|
|
4
|
-
<span class="title">{
|
|
4
|
+
<span class="title">{title} </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
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
6
|
+
@api title!: string;
|
|
7
7
|
@api description!: string;
|
|
8
8
|
@api primaryLink!: Link;
|
|
9
9
|
@api secondaryLink!: Link;
|