X Tutup
Skip to content

Commit 64c7d82

Browse files
committed
fix how the Itch object is exposed in the html game runner, fixes #3271
1 parent 2d5a200 commit 64c7d82

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/main/inject/inject-game.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
import querystring from "querystring";
22
import urlParser from "url";
3-
import { webFrame } from "electron";
3+
import { contextBridge } from "electron";
44

55
declare function atob(b64: string): string;
66

7-
interface Env {
8-
[key: string]: string;
9-
}
10-
11-
interface Itch {
12-
env: Env;
13-
args: string[];
14-
}
15-
16-
type ExtendedGlobal = typeof global & {
17-
Itch: Itch;
18-
};
19-
const extendedGlobal = global as ExtendedGlobal;
20-
217
(function () {
228
try {
239
console.log(
@@ -42,9 +28,10 @@ const extendedGlobal = global as ExtendedGlobal;
4228
const jsonSource = atob(
4329
Array.isArray(itchObjectBase64) ? itchObjectBase64[0] : itchObjectBase64
4430
);
45-
extendedGlobal.Itch = JSON.parse(jsonSource);
31+
const itchObject = JSON.parse(jsonSource);
32+
contextBridge.exposeInMainWorld("Itch", itchObject);
4633
console.log("Loaded itch environment!");
47-
console.dir(extendedGlobal.Itch);
34+
console.dir(itchObject);
4835
} catch (e) {
4936
console.error("While loading itch environment: ", e);
5037
} finally {

0 commit comments

Comments
 (0)
X Tutup