Skip to content

Commit

Permalink
extension: changes to multiple parts of the code after the first pre-…
Browse files Browse the repository at this point in the history
…release
  • Loading branch information
joacoc committed Aug 4, 2023
1 parent c7eb73c commit d1ac714
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
11 changes: 0 additions & 11 deletions esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ const watchConfig = {
},
};

const webviewConfig = {
...baseConfig,
entryPoints: ["./src/webview/index.ts"],
outfile: "./out/webview.js",
};

const scriptsConfig = {
...baseConfig,
entryPoints: ["./src/providers/scripts/results.ts", "./src/providers/scripts/auth.ts"],
Expand Down Expand Up @@ -66,10 +60,6 @@ const testConfig = {
...extensionConfig,
...watchConfig,
});
await build({
...webviewConfig,
...watchConfig,
});
await build({
...scriptsConfig,
...watchConfig,
Expand All @@ -82,7 +72,6 @@ const testConfig = {
} else {
// Build extension and webview code
await build(extensionConfig);
await build(webviewConfig);
await build(scriptsConfig);
await build(testConfig);
console.log("build complete");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
},
"scripts": {
"vscode:prepublish": "npm run esbuild-base -- --minify",
"esbuild-base": "esbuild ./src/extension.ts ./src/webview/index.ts ./src/providers/scripts/* --bundle --outdir=out/ --external:vscode --format=cjs --platform=node",
"esbuild-base": "esbuild ./src/extension.ts ./src/providers/scripts/* --bundle --outdir=out/ --external:vscode --format=cjs --platform=node",
"esbuild": "npm run esbuild-base -- --sourcemap",
"esbuild-watch": "npm run esbuild-base -- --sourcemap --watch",
"lint": "eslint src --ext ts",
Expand Down
4 changes: 4 additions & 0 deletions resources/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ vscode-divider {
margin-bottom: 1rem;
}

vscode-dropdown {
width: 150px;
}

#setup-container label, vscode-dropdown, vscode-button, svg {
display: inline-block;
vertical-align: middle;
Expand Down
3 changes: 1 addition & 2 deletions src/context/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ export class Config {
if (this.config.profiles && this.config.profile) {
return this.profileToNonStorable(this.config.profile, this.config.profiles[this.config.profile]);
} else {
console.log("[Config]", "Error loading the default user profile");
vscode.window.showErrorMessage("Error loading the default user profile.");
console.log("[Config]", "Error loading the default user profile. Most chances are that the user is new.");
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/providers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ export default class AuthProvider implements vscode.WebviewViewProvider {

private _getHtmlForWebview(webview: vscode.Webview) {
// Do the same for the stylesheet.
const webviewUri = getUri(webview, this._extensionUri, ["out", "webview", "index.js"]);
const scriptUri = getUri(webview, this._extensionUri, ["out", "scripts", "auth.js"]);
// const webviewUri = getUri(webview, this._extensionUri, ["out", "webview", "index.js"]);
const scriptUri = getUri(webview, this._extensionUri, ["out", "providers", "scripts", "auth.js"]);
const styleUri = getUri(webview, this._extensionUri, ["resources", "style.css"]);

const config = vscode.workspace.getConfiguration('workbench');
Expand Down Expand Up @@ -342,8 +342,7 @@ export default class AuthProvider implements vscode.WebviewViewProvider {
${content}
</div>
<script nonce="${nonce}" src="${scriptUri}"></script>
<script type="module" nonce="${nonce}" src="${webviewUri}"></script>
<script type="module" nonce="${nonce}" src="${scriptUri}"></script>
</body>
</html>`;
}
Expand Down
6 changes: 2 additions & 4 deletions src/providers/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export default class ResultsProvider implements vscode.WebviewViewProvider {
}

private _getHtmlForWebview(webview: vscode.Webview) {
const webviewUri = getUri(webview, this._extensionUri, ["out", "webview", "index.js"]);
const scriptUri = getUri(webview, this._extensionUri, ["out", "scripts", "results.js"]);
const scriptUri = getUri(webview, this._extensionUri, ["out", "providers", "scripts", "results.js"]);

// Use a nonce to only allow a specific script to be run.
const nonce = getNonce();
Expand All @@ -96,8 +95,7 @@ export default class ResultsProvider implements vscode.WebviewViewProvider {
</head>
<body>
<div id="container"></div>
<script nonce="${nonce}" src="${scriptUri}"></script>
<script type="module" nonce="${nonce}" src="${webviewUri}"></script>
<script type="module" nonce="${nonce}" src="${scriptUri}"></script>
</body>
</html>`;
}
Expand Down
12 changes: 12 additions & 0 deletions src/providers/scripts/auth.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
/*
* This file imports all the VSCode UX/UI guidelines.
*/

// This script will be run within the webview itself
// It cannot access the main VS Code APIs directly.
(function () {
// @ts-ignore
const vscode = acquireVsCodeApi();

// Load UX/UI from VSCode.
const { provideVSCodeDesignSystem, vsCodeDropdown, vsCodeTextField, vsCodeOption, vsCodeButton, vsCodeDataGrid, vsCodeDataGridCell, vsCodeDataGridRow, vsCodeLink, vsCodeProgressRing, vsCodeDivider } = require ("@vscode/webview-ui-toolkit");

provideVSCodeDesignSystem().register(vsCodeDropdown(), vsCodeOption(), vsCodeButton(), vsCodeDataGrid(), vsCodeDataGridCell(), vsCodeDataGridRow(), vsCodeLink(), vsCodeTextField(), vsCodeProgressRing(), vsCodeDivider());

const oldState = vscode.getState() || { profiles: [] };

/** @type {Array<{ value: string }>} */
Expand Down Expand Up @@ -107,6 +116,9 @@

const schemas = document.getElementById("schemas") as HTMLSelectElement;
schemas.disabled = true;

const addProfileLinkButton = document.getElementById("addProfileLink") as HTMLSelectElement;
addProfileLinkButton.disabled = true;
}
}
});
Expand Down
5 changes: 5 additions & 0 deletions src/providers/scripts/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
// @ts-ignore
const vscode = acquireVsCodeApi();

// Load UX/UI from VSCode.
const { provideVSCodeDesignSystem, vsCodeDropdown, vsCodeTextField, vsCodeOption, vsCodeButton, vsCodeDataGrid, vsCodeDataGridCell, vsCodeDataGridRow, vsCodeLink, vsCodeProgressRing, vsCodeDivider } = require ("@vscode/webview-ui-toolkit");

provideVSCodeDesignSystem().register(vsCodeDropdown(), vsCodeOption(), vsCodeButton(), vsCodeDataGrid(), vsCodeDataGridCell(), vsCodeDataGridRow(), vsCodeLink(), vsCodeTextField(), vsCodeProgressRing(), vsCodeDivider());

const oldState = vscode.getState() || { results: [] };

/** @type {Array<{ value: string }>} */
Expand Down
6 changes: 0 additions & 6 deletions src/webview/index.ts

This file was deleted.

0 comments on commit d1ac714

Please sign in to comment.