Socket
Socket
Sign inDemoInstall

@salesforcedevs/docs-components

Package Overview
Dependencies
Maintainers
0
Versions
625
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforcedevs/docs-components - npm Package Compare versions

Comparing version 1.3.300-async-fix-alpha3 to 1.3.300-async-fix-alpha4

2

package.json
{
"name": "@salesforcedevs/docs-components",
"version": "1.3.300-async-fix-alpha3",
"version": "1.3.300-async-fix-alpha4",
"description": "Docs Lightning web components for DSC",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -26,15 +26,13 @@ import { LightningElement, api } from "lwc";

set model(value: TopicModel) {
const amfClonePromise =
const amfNeedsClone =
!this.amf ||
(value && this._model && value.amf !== this._model?.amf)
? clone(value.amf)
: Promise.resolve(this.amf);
const typeClonePromise =
(value && this._model && value.amf !== this._model?.amf);
const typeNeedsClone =
!this.type ||
(value && this._model && value.type !== this._model?.type)
? clone(value.type)
: Promise.resolve(this.type);
(value && this._model && value.type !== this._model?.type);
Promise.all([amfClonePromise, typeClonePromise])
this.cloneData(
amfNeedsClone ? value.amf : this.amf,
typeNeedsClone ? value.type : this.type
)
.then(([clonedAmf, clonedType]) => {

@@ -51,2 +49,21 @@ this.amf = clonedAmf;

async cloneData(
amf: Json | undefined,
type: string | undefined
): Promise<[Json, string]> {
const clonedAmf = amf ? await this.clone(amf) : amf;
const clonedType = type ? await this.clone(type) : type;
return [clonedAmf, clonedType];
}
async clone(value: any): Promise<any> {
return new Promise((resolve, reject) => {
try {
resolve(JSON.parse(JSON.stringify(value)));
} catch (error) {
reject(error);
}
});
}
update(): void {

@@ -100,3 +117,2 @@ if (!this.model) {

).matches;
if (isTabletOrDesktop) {

@@ -117,54 +133,1 @@ window.scrollTo(0, 0);

}
/**
* The underlying web components we use from api-console mutate their models we pass in.
* Since LWC makes them Read Only, we need to copy them before passing to the Web Component.
* @param value JSON Serializable object to clone.
* @returns A Promise that resolves with a copy of Value, serialized and parsed via JSON.
*/
function clone(value: any): Promise<any> {
return new Promise((resolve, reject) => {
if (window.Worker) {
const workerCode = `
onmessage = function(e) {
try {
const jsonObject = JSON.parse(e.data);
postMessage({ success: true, data: jsonObject });
} catch (error) {
postMessage({ success: false, error: error.message });
}
};
`;
const blob = new Blob([workerCode], {
type: "application/javascript"
});
const workerURL = URL.createObjectURL(blob);
const worker = new Worker(workerURL);
try {
const jsonObj = JSON.stringify(value);
worker.postMessage(jsonObj);
} catch (err) {
reject(err);
worker.terminate();
}
worker.onmessage = function (e) {
worker.terminate();
if (e.data.success) {
resolve(e.data.data);
} else {
reject(new Error(e.data.error));
}
};
worker.onerror = function (e) {
worker.terminate();
reject(new Error(e.message));
};
} else {
reject(new Error("Your browser doesn't support web workers."));
}
});
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc