import * as vscode from "vscode"; const getNonce = () => { let text = ""; const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (let i = 0; i < 32; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)); } return text; }; export const getWebviewContent = ({ webview, title, script, context, }: { webview: vscode.Webview; title: string; script: string; context: vscode.ExtensionContext; }) => { const nonce = getNonce(); const styleUri = webview.asWebviewUri( vscode.Uri.joinPath(context.extensionUri, "media/vendor/components.css") ); const scriptUris = [ // vendor files are copied over by `yarn run compile` "media/vendor/react.js", "media/vendor/react-dom.js", "media/vendor/components.js", script, ].map((script) => webview.asWebviewUri(vscode.Uri.joinPath(context.extensionUri, script)) ); return `