forked from laverdet/screeps-steamless-client
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from admon84/feat/prettier
feat: prettier
- Loading branch information
Showing
17 changed files
with
10,618 additions
and
10,375 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,19 @@ | ||
{ | ||
"env": { | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"plugin:prettier/recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "tsconfig.json", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"prettier" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
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,2 +1,2 @@ | ||
/dist | ||
/node_modules | ||
/dist |
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,2 @@ | ||
/* | ||
!src/ |
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 @@ | ||
{ | ||
"semi": true, | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"tabWidth": 4 | ||
} |
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 was deleted.
Oops, something went wrong.
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,10 +1,12 @@ | ||
{ | ||
"eslint.options": { | ||
"configFile": "./.vscode/.eslintrc.yaml" | ||
}, | ||
"files.exclude": { | ||
"node_modules": true, | ||
}, | ||
"files.insertFinalNewline": true, | ||
"typescript.enablePromptUseWorkspaceTsdk": true, | ||
"files.exclude": { | ||
"node_modules": true | ||
}, | ||
"files.insertFinalNewline": true, | ||
"typescript.enablePromptUseWorkspaceTsdk": true, | ||
"[html]": { | ||
"editor.defaultFormatter": "vscode.html-language-features" | ||
}, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
} |
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,21 +1,24 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ { | ||
"type": "npm", | ||
"script": "watch", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"label": "build", | ||
|
||
"runOptions": { "runOn": "folderOpen" }, | ||
"isBackground": true, | ||
"problemMatcher": [ "$tsc-watch" ], | ||
"presentation": { | ||
"reveal": "always", | ||
"focus": false, | ||
"panel": "shared" | ||
}, | ||
} ] | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "dev", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"label": "build", | ||
"runOptions": { | ||
"runOn": "folderOpen" | ||
}, | ||
"isBackground": true, | ||
"problemMatcher": [ "$tsc-watch" ], | ||
"presentation": { | ||
"reveal": "always", | ||
"focus": false, | ||
"panel": "shared" | ||
} | ||
} | ||
] | ||
} |
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,47 +1,85 @@ | ||
# Screeps Steamless Client | ||
## Screepers Steamless Client | ||
|
||
## About | ||
### Overview | ||
|
||
This package surfaces the [Screeps](https://screeps.com/) client in the browser of your choice for | ||
users who have purchased the [official Screeps | ||
app](https://store.steampowered.com/app/464350/Screeps/) on Steam. | ||
The Screepers Steamless Client is a package that allows you to run the [Screeps](https://screeps.com/) game client in your browser. It's designed for users who have purchased [Screeps](https://store.steampowered.com/app/464350/Screeps/) on Steam. The official Screeps client, which uses an older version of [NW.js](https://nwjs.io/), lacks support for many macOS devices. This client serves the Screeps files installed via Steam, enabling you to run Screeps in your browser on macOS, Linux, and Windows. | ||
|
||
I personally run into a lot of issues with the official client, especially on macOS. The official | ||
client is simply an [NW.js](https://nwjs.io/) wrapper around an [AngularJS](https://angularjs.org/) | ||
app. The version of NW.js included with the client is fairly ancient; at the time of this writing it | ||
was based on Chrome 76 [July 2019] -- a two year old version. I made this package because I was | ||
experiencing frequent crashes in the official client, and I desired a native experience on my Apple | ||
M1-based computer. | ||
|
||
This client just serves up the Screeps client files which are already sitting in your Steam folder. | ||
It also adds some basic endpoints for authentication via Steam OpenID. For all intents and purposes | ||
it is the official client but running in the browser of your choice. | ||
|
||
## Installation & Use | ||
### Installation & Usage | ||
|
||
```sh | ||
npm install -g screepers-steamless-client | ||
npx screepers-steamless-client | ||
``` | ||
|
||
Access the client at http://localhost:8080/. This address can be changed with the `--host` and `--port` arguments. | ||
|
||
If the `--backend` argument is used, this URL will directly proxy the backend server. This disables the server list page. | ||
|
||
If not using the `--backend` argument, you can use the format `http://localhost:8080/(SERVER_ADDRESS)/` to access different servers. Note that you can only log in to one server at a time. | ||
|
||
- For the official server: http://localhost:8080/(https://screeps.com)/ | ||
|
||
- For a local server on port 21025: http://localhost:8080/(http://localhost:21025)/ | ||
|
||
Steam OpenId support is required on your local server. Enable it with [screepsmod-auth](https://github.com/ScreepsMods/screepsmod-auth). For [xxscreeps](https://github.com/laverdet/xxscreeps/) servers, it's enabled by default. | ||
|
||
### Command Line Arguments | ||
|
||
- `--backend`: Specifies the backend URL. If provided, the entire URL is used as the endpoint. | ||
- `--internal_backend`: Specifies the internal backend URL. If provided, this URL is used to reference the internal endpoint. | ||
- `--package`: Specifies the path to the Screeps client package.nw file. Only needed if the path isn't automatically detected. | ||
- `--host`: Changes the host address. (default: `localhost`) | ||
- `--port`: Changes the port. (default: `8080`) | ||
- `--beautify`: Formats .js files loaded in the client for debugging. | ||
|
||
### Examples | ||
|
||
Set the path to the Screeps client package.nw file (only if not automatically detected): | ||
|
||
```sh | ||
npx screepers-steamless-client --package ~/Screeps/package.nw | ||
``` | ||
|
||
Proxy a server directly (server list disabled): | ||
|
||
```sh | ||
npx screepers-steamless-client --backend https://screeps.com | ||
npx screepers-steamless-client --backend http://localhost:21025 | ||
``` | ||
|
||
You must visit a specially crafted local URL in order to specify the server you want to connect to. | ||
In order to connect to the official Screeps World server you would visit: | ||
http://localhost:8080/(https://screeps.com)/. | ||
Example usage with Jomik's [screeps-server](https://github.com/Jomik/screeps-server). | ||
|
||
```yaml | ||
# docker-compose.yml | ||
version: '3' | ||
services: | ||
client: | ||
image: node:16 | ||
command: sh -c 'npx screepers-steamless-client --package /screeps.nw --host 0.0.0.0 --internal_backend http://screeps:21025 --backend http://localhost:21025' | ||
volumes: | ||
- ${SCREEPS_NW_PATH:?"Missing screeps nw file"}:/screeps.nw | ||
ports: | ||
- 8080:8080 | ||
restart: unless-stopped | ||
``` | ||
```bash | ||
# .env | ||
SCREEPS_NW_PATH="~/Library/Application Support/Steam/steamapps/common/Screeps/package.nw" | ||
``` | ||
|
||
### Development Scripts | ||
|
||
This project includes several scripts for development purposes: | ||
|
||
In order to visit a local server running on port 21025 you would visit: | ||
http://localhost:8080/(http://localhost:21025)/. Note that Steam OpenId support is required on your | ||
local server which can be enabled with | ||
[screepsmod-auth](https://github.com/ScreepsMods/screepsmod-auth). For xxscreeps servers this should | ||
be enabled by default. | ||
- `build`: Compiles to `dist`. Run this script with `npm run build`. | ||
- `dev`: Compiles to `dist` and watches for changes. Run this script with `npm run dev`. | ||
- `format`: Formats the `src` directory using Prettier. Run this script with `npm run format`. | ||
- `lint`: Lints the `src` directory using ESLint. Run this script with `npm run lint`. | ||
- `prepare`: Compiles to `dist`. This script is automatically run before the package is packed or published, and when installing git dependencies. Run this script with `npm run prepare`. | ||
|
||
## Tips | ||
### Tips | ||
|
||
This client makes use of "guest mode" which is enabled by default in | ||
[xxscreeps](https://github.com/laverdet/xxscreeps/). This will provide you with a read-only view of | ||
the server when you are not signed in. The client will show you as signed in as user Guest and your | ||
icon will belong to the Invader user. To sign in with your Steam account you need to select "Sign | ||
Out" first, which will sign you out of Guest and bring you to the real login page. Click the Steam | ||
icon towards the bottom to sign-in with your Steam account and play the game as normal. | ||
This client uses "guest mode" by default in [xxscreeps](https://github.com/laverdet/xxscreeps/), providing a read-only view of the server when not signed in. To sign in with your Steam account, select "Sign Out" first, then click the Steam icon to sign in and play as normal. | ||
|
||
![Safari Example](./docs/safari.png) |
Oops, something went wrong.