-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganise and rename config constants etc
- Loading branch information
Showing
5 changed files
with
21 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** True if the runtime is in Game Developer mode, with access to the devtools window. */ | ||
// WASM4_GAMEDEV_MODE is defined in vite.config.ts | ||
export const GAMEDEV_MODE = WASM4_GAMEDEV_MODE; | ||
|
||
/** True if we're developers of the WASM4 runtime itself, and are running the runtime | ||
using `npm start` or `vite` etc. */ | ||
export const PLATFORM_DEVELOPER_MODE = import.meta.env.MODE === "development"; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export const GAMEDEV_MODE = WASM4_GAMEDEV_MODE; | ||
export const WIDTH = 160; | ||
export const HEIGHT = 160; | ||
|
||
|
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 |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import * as constants from "./constants"; | ||
// True if we're developers of the WASM4 runtime itself, and are running the runtime | ||
// using `npm start` or `vite` etc. In this case, there's no wasm4 CLI web socket to | ||
// connect to, but we might be fighting for the Vite websocket. | ||
const PLATFORM_DEVELOPER_MODE = import.meta.env.MODE === "development"; | ||
import { GAMEDEV_MODE, PLATFORM_DEVELOPER_MODE } from "./config-constants"; | ||
|
||
export const websocket = constants.GAMEDEV_MODE && !PLATFORM_DEVELOPER_MODE | ||
// The w4 CLI web socket only exists for gamedev mode. | ||
// But if we're running `npm start` or `vite` there is no w4 CLI to connect to, | ||
// but there is a vite websocket we may be fighting for, causing issues with vite. | ||
export const cli_websocket = GAMEDEV_MODE && !PLATFORM_DEVELOPER_MODE | ||
? new WebSocket((location.protocol == "https:" ? "wss" : "ws") + "://" + location.host) | ||
: null; |
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