-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for configuration file webview
- Loading branch information
1 parent
d5dd14a
commit a8523f6
Showing
15 changed files
with
506 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/teroshdl/resources/webviews/fileConfiguration/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
wb |
66 changes: 66 additions & 0 deletions
66
packages/teroshdl/resources/webviews/fileConfiguration/esbuild.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const { build } = require("esbuild"); | ||
const path = require("path"); | ||
|
||
//@ts-check | ||
/** @typedef {import('esbuild').BuildOptions} BuildOptions **/ | ||
|
||
/** @type BuildOptions */ | ||
const baseConfig = { | ||
bundle: true, | ||
minify: process.env.NODE_ENV === "production", | ||
sourcemap: process.env.NODE_ENV !== "production", | ||
}; | ||
|
||
// Config for webview source code (to be run in a web-based context) | ||
/** @type BuildOptions */ | ||
const webviewFileConfiguration = { | ||
...baseConfig, | ||
target: "es2020", | ||
format: "esm", | ||
entryPoints: [path.join(__dirname, "fileConfiguration.ts")], | ||
outfile: path.join(__dirname, "wb", "webviewFileConfiguration.js"), | ||
}; | ||
|
||
// This watch config adheres to the conventions of the esbuild-problem-matchers | ||
// extension (https://github.com/connor4312/esbuild-problem-matchers#esbuild-via-js) | ||
/** @type BuildOptions */ | ||
const watchConfig = { | ||
watch: { | ||
onRebuild(error, result) { | ||
console.log("[watch] build started"); | ||
if (error) { | ||
error.errors.forEach((error) => | ||
console.error( | ||
`> ${error.location.file}:${error.location.line}:${error.location.column}: error: ${error.text}` | ||
) | ||
); | ||
} else { | ||
console.log("[watch] build finished"); | ||
} | ||
}, | ||
}, | ||
}; | ||
|
||
// Build script | ||
(async () => { | ||
const args = process.argv.slice(2); | ||
try { | ||
if (args.includes("--watch")) { | ||
// Build and watch extension and webview code | ||
console.log("[watch] build started"); | ||
await build({ | ||
...webviewFileConfiguration, | ||
...watchConfig, | ||
}); | ||
console.log("[watch] build finished"); | ||
} else { | ||
// Build extension and webview code | ||
await build(webviewFileConfiguration); | ||
console.log("build complete"); | ||
} | ||
} catch (err) { | ||
console.log(err); | ||
// process.stderr.write(err.stderr); | ||
process.exit(1); | ||
} | ||
})(); |
49 changes: 49 additions & 0 deletions
49
packages/teroshdl/resources/webviews/fileConfiguration/fileConfiguration.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
|
||
<style> | ||
vscode-dropdown { | ||
width: 100%; | ||
} | ||
</style> | ||
|
||
</head> | ||
|
||
<body> | ||
<vscode-form-group> | ||
|
||
<br><br> | ||
|
||
<vscode-badge id="file-name"></vscode-badge> | ||
|
||
<br><br> | ||
|
||
<vscode-label for="file-type">File type:</vscode-label> | ||
<vscode-dropdown id="file-type"> | ||
</vscode-dropdown> | ||
|
||
<br><br><br> | ||
|
||
<vscode-label for="file-version">File Version:</vscode-label> | ||
<vscode-dropdown id="file-version"> | ||
</vscode-dropdown> | ||
|
||
<br><br><br> | ||
|
||
<vscode-label for="source-type">Source Type:</vscode-label> | ||
<vscode-dropdown id="source-type"> | ||
</vscode-dropdown> | ||
|
||
<br><br><br> | ||
|
||
<vscode-button id="apply-button">Apply</vscode-button> | ||
|
||
</vscode-form-group> | ||
<script type="module" src="{{webviewUri}}"></script> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.