UNPKG

code-server

Version:

Run VS Code on a remote server.

1 lines 2.81 kB
(()=>{"use strict";var t={879:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CspAlerter=void 0;const n=s(838);e.CspAlerter=class{constructor(t){this.settingsManager=t,this.didShow=!1,this.didHaveCspWarning=!1,document.addEventListener("securitypolicyviolation",(()=>{this.onCspWarning()})),window.addEventListener("message",(t=>{t&&t.data&&"vscode-did-block-svg"===t.data.name&&this.onCspWarning()}))}setPoster(t){this.messaging=t,this.didHaveCspWarning&&this.showCspWarning()}onCspWarning(){this.didHaveCspWarning=!0,this.showCspWarning()}showCspWarning(){const t=(0,n.getStrings)(),e=this.settingsManager.settings;if(this.didShow||e.disableSecurityWarnings||!this.messaging)return;this.didShow=!0;const s=document.createElement("a");s.innerText=t.cspAlertMessageText,s.setAttribute("id","code-csp-warning"),s.setAttribute("title",t.cspAlertMessageTitle),s.setAttribute("role","button"),s.setAttribute("aria-label",t.cspAlertMessageLabel),s.onclick=()=>{this.messaging.postMessage("showPreviewSecuritySelector",{source:e.source})},document.body.appendChild(s)}}},460:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StyleLoadingMonitor=void 0,e.StyleLoadingMonitor=class{constructor(){this.unloadedStyles=[],this.finishedLoading=!1;const t=t=>{const e=t.target.dataset.source;this.unloadedStyles.push(e)};window.addEventListener("DOMContentLoaded",(()=>{for(const e of document.getElementsByClassName("code-user-style"))e.dataset.source&&(e.onerror=t)})),window.addEventListener("load",(()=>{this.unloadedStyles.length&&(this.finishedLoading=!0,this.poster&&this.poster.postMessage("previewStyleLoadError",{unloadedStyles:this.unloadedStyles}))}))}setPoster(t){this.poster=t,this.finishedLoading&&t.postMessage("previewStyleLoadError",{unloadedStyles:this.unloadedStyles})}}},532:(t,e)=>{function s(t){const e=document.getElementById("vscode-markdown-preview-data");if(e){const s=e.getAttribute(t);if(s)return JSON.parse(s)}throw new Error(`Could not load data for ${t}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.SettingsManager=e.getData=void 0,e.getData=s,e.SettingsManager=class{constructor(){this._settings=s("data-settings")}get settings(){return this._settings}updateSettings(t){this._settings=t}}},838:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getStrings=void 0,e.getStrings=function(){const t=document.getElementById("vscode-markdown-preview-data");if(t){const e=t.getAttribute("data-strings");if(e)return JSON.parse(e)}throw new Error("Could not load strings")}}},e={};function s(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,s),o.exports}(()=>{const t=s(879),e=s(460),n=s(532);window.cspAlerter=new t.CspAlerter(new n.SettingsManager),window.styleLoadingMonitor=new e.StyleLoadingMonitor})()})();