Skip to content

Commit 47da736

Browse files
committed
web: Show version in menu (solves #641)
1 parent df08e51 commit 47da736

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

runtimes/web/src/constants.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// If you update this definition, make sure to also update the definition
2-
// in vite.config.ts to match.
3-
export const GAMEDEV_MODE: boolean = import.meta.env.VITE_WASM4_GAMEDEV_MODE !== "false";
4-
1+
export const GAMEDEV_MODE = WASM4_GAMEDEV_MODE;
52
export const WIDTH = 160;
63
export const HEIGHT = 160;
74

runtimes/web/src/ui/menu-overlay.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export class MenuOverlay extends LitElement {
6565
background: rgba(0, 0, 0, 0.85);
6666
}
6767
68+
.version {
69+
color: #fff;
70+
padding-bottom: 1em;
71+
}
72+
6873
.menu {
6974
border: 2px solid #f0f0f0;
7075
padding: 0 1em 0 1em;
@@ -244,6 +249,9 @@ export class MenuOverlay extends LitElement {
244249

245250
render () {
246251
return html`
252+
<div class="version">
253+
WASM-4 v${WASM4_VERSION}
254+
</div>
247255
<div class="menu">
248256
<ul style="display:${this.optionContext === optionContext.DEFAULT? "inherit": "none"}">
249257
${map(options[optionContext.DEFAULT], (option, idx) =>

runtimes/web/src/vite-env.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Include the types for Vite's special import.meta.env object.
22
/// <reference types="vite/client" />
33

4-
interface ImportMetaEnv {
5-
readonly VITE_WASM4_GAMEDEV_MODE: string
6-
}
4+
declare const WASM4_VERSION: string
5+
declare const WASM4_GAMEDEV_MODE: boolean

runtimes/web/vite.config.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import { UserConfig, defineConfig } from 'vite';
22
import minifyHTML from 'rollup-plugin-minify-html-literals-v3';
3-
4-
function isGamedevBuild(): boolean {
5-
// If you update this definition, make sure to also update the definition
6-
// in src/constants.ts to match.
7-
return process.env.VITE_WASM4_GAMEDEV_MODE !== "false";
8-
}
3+
import cliPackageJSON from '../../cli/package.json';
94

105
// https://vitejs.dev/config/
116
export default defineConfig(({ mode }) => {
12-
const gamedev_build = isGamedevBuild();
7+
const gamedev_build = process.env.VITE_WASM4_GAMEDEV_MODE !== "false";
138

149
let user_config: UserConfig = {
1510
server: {
@@ -46,6 +41,10 @@ export default defineConfig(({ mode }) => {
4641
plugins: [
4742
minifyHTML(),
4843
],
44+
define: {
45+
WASM4_GAMEDEV_MODE: gamedev_build,
46+
WASM4_VERSION: JSON.stringify(cliPackageJSON.version),
47+
},
4948
};
5049

5150
return user_config;

0 commit comments

Comments
 (0)