Skip to content
This repository has been archived by the owner on Dec 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from OmegaRogue/pull-request-no-injection
Browse files Browse the repository at this point in the history
1.5.1
  • Loading branch information
theripper93 authored Jan 22, 2024
2 parents cbe2f79 + f3bae89 commit ca00499
Show file tree
Hide file tree
Showing 12 changed files with 5,470 additions and 7,499 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ jobs:

- name: Rename output files
run: |
mv out/make/deb/x64/vtt-desktop-client_${{ github.event.release.tag_name }}_amd64.deb ./vtt-desktop-client_${{ github.event.release.tag_name }}_amd64.deb
mv out/make/rpm/x64/vtt-desktop-client-${{ github.event.release.tag_name }}-1.x86_64.rpm ./vtt-desktop-client-${{ github.event.release.tag_name }}-1.x86_64.rpm
tag=${{ github.event.release.tag_name }}
mv out/make/deb/x64/vtt-desktop-client_${tag//-/\~}_amd64.deb ./vtt-desktop-client_${{ github.event.release.tag_name }}_amd64.deb
mv out/make/rpm/x64/vtt-desktop-client-${tag//-/.}-1.x86_64.rpm ./vtt-desktop-client-${{ github.event.release.tag_name }}-1.x86_64.rpm
mv out/make/zip/linux/x64/vtt-desktop-client-linux-x64-${{ github.event.release.tag_name }}.zip ./vtt-desktop-client-linux-x64-${{ github.event.release.tag_name }}.zip
- name: Archive production artifacts
uses: actions/upload-artifact@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
tags:
- "1.*"
- "!1.*-*"
jobs:
fork:
if: github.repository_owner == 'OmegaRogue'
Expand Down
3 changes: 0 additions & 3 deletions .idea/fvtt-player-client.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: build

export VERSION
build:
yarn install
if [ -z $${$VERSION+x} ]; then yarn version --no-git-tag-version --new-version $$VERSION;fi
yarn run electron-forge make --platform linux --targets '@electron-forge/maker-zip'
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

wiki https://wiki.theripper93.com/free/vtt-desktop-client

## Differences between this and theripper93's player client

| Feature | [theripper93](https://github.com/theripper93/fvtt-player-client) | omegarogue |
|----------------------------------------------|:----------------------------------------------------------------:|:----------:|
| Back to server select button in setup screen | ✔️ | ✔️ |
| Back to server select button in login screen | ✔️ ️ | ✔️ |
| Back to server select button in game || ✔️ |

## Customization

You can pre-configure and customize the client by editing the `config.json` file.
From where the executable is located,
you can find the `config.json` file by navigating to the `resources/app` folder.
You can edit the file with any text editor.

Example config:

```json
{
"games": [
{
"name": "This is the name of my game",
"url": "https://www.nintendo.com/games/detail/the-legend-of-zelda-breath-of-the-wild-switch"
}
],
"background": "https://images2.alphacoders.com/123/123862.jpg",
"backgroundColor": "#000000",
"textColor": "white",
"accentColor": "green"
}
```

## Getting data from `localStorage` to put into `config.json`

```js
Expand Down
8 changes: 5 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
<label for="clear-cache-on-close">Clear Cache on close</label>
<input id="clear-cache-on-close" class="no-text" type="checkbox">
</div>
<div class="insecure-ssl-field field">
<label for="clear-cache-on-close">Ignore Certificate errors</label>
<input class="no-text" id="insecure-ssl" type="checkbox">
</div>
<div class="button-group">
<button id="clear-cache">Clear Cache</button>
<button id="save-app-config">Save</button>
Expand All @@ -109,9 +113,7 @@ <h3>Put this in your <code>config.json</code> file to include it installation-wi
<button onclick="copyText()">Copy</button>
<button onclick="toggleExportConfig()">Close</button>
<script>
const gamesList = JSON.parse(window.localStorage.getItem("gameList") || "[]");
const appConfig = JSON.parse(window.localStorage.getItem("appConfig") || "{}");
const config = {...appConfig, games: gamesList};
const config = await window.api.localAppConfig();
code = document.getElementById("export-text");
const text = JSON.stringify(config, null, 4);
txt = document.createTextNode(text);
Expand Down
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vtt-desktop-client",
"packageManager": "yarn@3.3.1",
"version": "1.4.4",
"packageManager": "yarn@1.22.19",
"version": "1.5.0",
"license": "MIT",
"description": "VTT Desktop Client",
"main": ".vite/build/main.js",
Expand All @@ -27,18 +27,16 @@
"@electron-forge/maker-squirrel": "^7.2.0",
"@electron-forge/maker-zip": "^7.2.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.2.0",
"@electron-forge/plugin-local-electron": "^7.2.0",
"@electron-forge/plugin-vite": "^7.2.0",
"@types/node": "^20.11.5",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"electron": "^28.1.4",
"electron": "^25.9.8",
"electron-builder": "^24.9.1",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.29.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"yarn-upgrade-all": "^0.7.2"
"typescript": "^5.3.3"
},
"scripts": {
"start": "electron-forge start",
Expand All @@ -48,7 +46,8 @@
"make:linux": "electron-forge make --platform linux",
"make:windows": "electron-forge make --platform win32",
"make:macos": "electron-forge make --platform darwin",
"lint": "eslint --ext .ts,.tsx ."
"lint": "eslint --ext .ts,.tsx .",
"make:linuxpkg": "electron-forge make --platform linux --targets '@electron-forge/maker-zip'"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
Expand Down
39 changes: 34 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// noinspection ES6MissingAwait,JSIgnoredPromiseFromCall

import {app, BrowserWindow, ipcMain, safeStorage,} from 'electron';
import {app, BrowserWindow, ipcMain, safeStorage, session} from 'electron';
import path from 'path';
import fs from 'fs';

Expand Down Expand Up @@ -44,16 +44,29 @@ if (!isSingleInstance) {

const windowsData = {} as WindowsData;

let partitionId: number = 0;

function getSession(): Electron.Session {
const partitionIdTemp = partitionId;
partitionId++
if (partitionIdTemp == 0)
return session.defaultSession;
return session.fromPartition(`persist:${partitionIdTemp}`, {cache: true});
}

// let win: BrowserWindow;

function createWindow(): BrowserWindow {
const localSession = getSession();
let window = new BrowserWindow({
show: false, width: 800, height: 600, webPreferences: {
preload: path.join(__dirname, "preload.js"),
nodeIntegration: false,
contextIsolation: true,
webgl: true
webgl: true,
session: localSession
},

});

// Fix Popouts
Expand Down Expand Up @@ -212,17 +225,34 @@ ipcMain.handle("get-user-data", (_, gameId: GameId) => getLoginDetails(gameId))

ipcMain.handle("app-version", () => app.getVersion())

ipcMain.handle("app-config", () => {
function getAppConfig(): AppConfig {
try {
const json = fs.readFileSync(path.join(app.getAppPath(), "config.json")).toString();
const appConfig = JSON.parse(json) as AppConfig;
let appConfig = JSON.parse(json) as AppConfig;
if (appConfig.ignoreCertificateErrors) {
app.commandLine.appendSwitch("ignore-certificate-errors");
}
const userData = getUserData();
appConfig = {...appConfig, ...userData.app};
return appConfig;
} catch (e) {
return {} as AppConfig;
}
}

ipcMain.on("save-app-config", (_e, data: AppConfig) => {
const currentData = getUserData();
currentData.app = {...currentData.app, ...data};
fs.writeFileSync(path.join(app.getPath("userData"), "userData.json"), JSON.stringify(currentData));
});
ipcMain.handle("app-config", getAppConfig);
ipcMain.handle("local-app-config", () => {
try {
const userData = getUserData();
return userData.app ?? {} as AppConfig;
} catch (e) {
return {} as AppConfig;
}
});

ipcMain.handle("select-path", (e) => {
Expand Down Expand Up @@ -250,7 +280,6 @@ ipcMain.on("return-select", (e) => {
});



app.on('activate', (_, hasVisibleWindows) => {
if (!hasVisibleWindows) {
createWindow();
Expand Down
8 changes: 8 additions & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ export type ContextBridgeApi = {
userData: (gameId: string | number) => Promise<GameUserDataDecrypted>;
appVersion: () => Promise<string>;
appConfig: () => Promise<AppConfig>;
localAppConfig: () => Promise<AppConfig>;
cachePath: () => Promise<string>;
setCachePath: (cachePath: string) => void;
returnToServerSelect: () => void;
saveUserData: (data: SaveUserData) => void;
openGame: (id: number | string) => void;
clearCache: () => void;
saveAppConfig: (data: AppConfig) => void;
}
const exposedApi: ContextBridgeApi = {
// request(channel: RequestChannels, ...args: unknown[]): Promise<unknown> {
Expand All @@ -54,6 +56,9 @@ const exposedApi: ContextBridgeApi = {
appConfig() {
return ipcRenderer.invoke("app-config") as Promise<AppConfig>;
},
localAppConfig() {
return ipcRenderer.invoke("local-app-config") as Promise<AppConfig>;
},
appVersion() {
return ipcRenderer.invoke("app-version") as Promise<string>;
},
Expand All @@ -75,6 +80,9 @@ const exposedApi: ContextBridgeApi = {
setCachePath(cachePath: string) {
ipcRenderer.send("cache-path", cachePath);
},
saveAppConfig(data: AppConfig) {
ipcRenderer.send("save-app-config", data);
}


}
Expand Down
Loading

0 comments on commit ca00499

Please sign in to comment.