haxball.js 2.2.2 โ†’ 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ github: [mertushka]
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: bug
6
+ assignees: mertushka
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. `npm install haxball.js` '...'
16
+ 2. ...
17
+
18
+ **Expected behavior**
19
+ A clear and concise description of what you expected to happen.
20
+
21
+ **Screenshots**
22
+ If applicable, add screenshots to help explain your problem.
23
+
24
+ **Device (please complete the following information):**
25
+ - OS: [e.g. W11]
26
+ - Node.JS Version [e.g. 20.x LTS]
27
+
28
+ **Additional context**
29
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,124 @@
1
+ name: ๐Ÿš€ Haxball.JS CI/CD
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "0 0 * * 0" # Run at 00:00 on Sunday
6
+ workflow_dispatch: # Allow manual triggers
7
+ push:
8
+ branches: [main, develop]
9
+ pull_request:
10
+ branches: [main]
11
+
12
+ jobs:
13
+ build:
14
+ name: ๐Ÿ› ๏ธ Build Source
15
+ runs-on: ubuntu-latest
16
+ outputs:
17
+ hash: ${{ steps.nodeify.outputs.hash }}
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+
21
+ - name: ๐Ÿ“ฆ Setup Node.js
22
+ uses: actions/setup-node@v3
23
+ with:
24
+ node-version: 20.x
25
+ cache: "npm"
26
+
27
+ - name: ๐Ÿ“ฅ Install Dependencies
28
+ run: npm ci
29
+
30
+ - name: ๐Ÿ”จ Build Source Code
31
+ id: nodeify
32
+ run: |
33
+ OUTPUT=$(npm run build)
34
+ if [[ $OUTPUT =~ SUCCESS:([a-zA-Z0-9]+) ]]; then
35
+ HASH="${BASH_REMATCH[1]}"
36
+ echo "hash=$HASH" >> $GITHUB_OUTPUT
37
+ echo "๐ŸŽ‰ Build successful with hash: $HASH"
38
+ else
39
+ echo "โŒ Build failed: $OUTPUT"
40
+ exit 1
41
+ fi
42
+
43
+ - name: ๐Ÿ“ค Upload Build Artifact
44
+ uses: actions/upload-artifact@v3
45
+ with:
46
+ name: haxball-build
47
+ path: src/build.js
48
+ retention-days: 7
49
+
50
+ test:
51
+ needs: build
52
+ name: ๐Ÿงช Test (${{ matrix.os }}, Node ${{ matrix.node-version }})
53
+ runs-on: ${{ matrix.os }}
54
+ strategy:
55
+ matrix:
56
+ os: [ubuntu-latest, windows-latest, macos-latest]
57
+ node-version: [18.x, 20.x]
58
+ fail-fast: false
59
+
60
+ steps:
61
+ - uses: actions/checkout@v3
62
+
63
+ - name: ๐Ÿ“ฆ Setup Node.js
64
+ uses: actions/setup-node@v3
65
+ with:
66
+ node-version: ${{ matrix.node-version }}
67
+ cache: "npm"
68
+
69
+ - name: ๐Ÿ“ฅ Download Build
70
+ uses: actions/download-artifact@v3
71
+ with:
72
+ name: haxball-build
73
+ path: src
74
+
75
+ - name: ๐Ÿ“ฅ Install Dependencies
76
+ run: npm ci
77
+
78
+ - name: ๐Ÿงช Run Core Tests
79
+ run: npm test
80
+ env:
81
+ TEST_PROXY: ""
82
+
83
+ - name: ๐ŸŒ Run Proxy Tests (Optional)
84
+ if: always()
85
+ continue-on-error: true
86
+ run: npm test
87
+ env:
88
+ TEST_PROXY: "1"
89
+
90
+ publish:
91
+ needs: build
92
+ name: ๐Ÿ“ข Publish Build
93
+ if: github.event_name != 'pull_request'
94
+ runs-on: ubuntu-latest
95
+ steps:
96
+ - uses: actions/checkout@v3
97
+
98
+ - name: ๐Ÿ“ฅ Download Build
99
+ uses: actions/download-artifact@v3
100
+ with:
101
+ name: haxball-build
102
+ path: src
103
+
104
+ - name: ๐Ÿ”„ Prepare Build
105
+ run: |
106
+ mv src/build.js src/index.js
107
+ echo "โœจ Build prepared for publishing"
108
+
109
+ - name: ๐Ÿš€ Commit and Push
110
+ run: |
111
+ git config --global user.name 'github-actions[bot]'
112
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
113
+
114
+ if [[ -n "$(git status --porcelain)" ]]; then
115
+ git add src/index.js
116
+ git commit -m "๐Ÿค– Update Haxball.JS Build (${{ needs.build.outputs.hash }})
117
+
118
+ ๐Ÿ”„ Auto-generated by GitHub Actions
119
+ ๐Ÿท๏ธ Build Hash: ${{ needs.build.outputs.hash }}
120
+ โšก Includes latest Haxball updates"
121
+ git push
122
+ else
123
+ echo "๐Ÿ“ No changes to commit"
124
+ fi
@@ -1,22 +1,39 @@
1
- name: "๐Ÿš€ release"
1
+ name: ๐Ÿ“ฆ NPM Release
2
2
 
3
3
  on:
4
- release:
5
- types: [published]
4
+ release:
5
+ types: [published]
6
6
 
7
7
  jobs:
8
- release:
9
- name: ๐Ÿš€ release
10
- runs-on: ubuntu-latest
11
- steps:
12
- - name: ๐Ÿ“š checkout
13
- uses: actions/checkout@v2
14
- - name: ๐ŸŸข node
15
- uses: actions/setup-node@v2
16
- with:
17
- node-version: 14
18
- registry-url: https://registry.npmjs.org
19
- - name: ๐Ÿš€ publish
20
- run: npm publish --access public
21
- env:
22
- NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
8
+ release:
9
+ name: ๐Ÿš€ Publish to NPM
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: ๐Ÿ“š Checkout Repository
13
+ uses: actions/checkout@v3
14
+
15
+ - name: ๐ŸŸข Setup Node.js
16
+ uses: actions/setup-node@v3
17
+ with:
18
+ node-version: 20.x
19
+ registry-url: https://registry.npmjs.org
20
+ cache: "npm"
21
+
22
+ - name: ๐Ÿ“ฅ Install Dependencies
23
+ run: npm ci
24
+
25
+ - name: ๐Ÿ”จ Build Package
26
+ run: npm run build
27
+
28
+ - name: ๐Ÿš€ Publish to NPM
29
+ run: |
30
+ echo "๐Ÿ“ฆ Publishing version $(node -p "require('./package.json').version")"
31
+ npm publish --access public
32
+ env:
33
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
34
+
35
+ - name: โœจ Post-Release Info
36
+ run: |
37
+ echo "๐ŸŽ‰ Successfully published to NPM!"
38
+ echo "๐Ÿ“Š Package: $(node -p "require('./package.json').name")"
39
+ echo "๐Ÿ“Œ Version: $(node -p "require('./package.json').version")"
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ contact@mertushka.pw.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
@@ -0,0 +1,9 @@
1
+ <h2 id="how-to-contribute">๐Ÿ’ก How To Contribute</h2>
2
+
3
+ - Make a fork of this repository
4
+ - Clone to you machine and entry on respective paste
5
+ - Create a branch with your resource: `git checkout -b my-feature`
6
+ - Commit your changes: `git commit -m 'feat: My new feature'`
7
+ - Push your branch: `git push origin my-feature`
8
+ - A green button will appear at the beginning of this repository
9
+ - Click to open and fill in the pull request information
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Mario Carbajal & Mertushka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -29,11 +29,9 @@
29
29
  npm install haxball.js
30
30
  ```
31
31
 
32
- #### ๐Ÿ’ป Module Usage Example
32
+ #### Module Usage Example
33
33
 
34
34
  ```js
35
- // room.js
36
-
37
35
  const HaxballJS = require("haxball.js");
38
36
 
39
37
  HaxballJS.then((HBInit) => {
@@ -56,9 +54,9 @@ HaxballJS.then((HBInit) => {
56
54
  });
57
55
  ```
58
56
 
59
- #### ๐Ÿ’ป (Optional) Proxy
57
+ #### (Optional) Proxy
60
58
 
61
- Haxball has a limit of 2 rooms per IP. Therefore, you can use proxy with adding `proxy: "<YOUR_PROXY_IP>"` in your RoomConfig.
59
+ Haxball has a limit of 2 rooms per IP. Therefore, you can use proxy with adding `proxy: "http://<YOUR_PROXY_IP>"` in your `RoomConfig`.
62
60
 
63
61
  Example:
64
62
 
@@ -69,42 +67,53 @@ HBInit({
69
67
  });
70
68
  ```
71
69
 
72
- #### ๐Ÿ’ป (Optional) TypeScript
70
+ ### ๐Ÿ’ป TypeScript
73
71
 
74
- From v2.1.0, the package has basic typings included. Typings are automatically imported alongside `haxball.js` package.
72
+ #### TypeScript Example
75
73
 
76
- Install TypeScript and ts-node in your project:
74
+ ```js
75
+ import HaxballJS from "haxball.js";
77
76
 
78
- ```bash
79
- npm install typescript --save-dev
80
- npm install ts-node --save-dev
81
- ```
77
+ HaxballJS.then((HBInit) => {
78
+ // Same as in Haxball Headless Host Documentation
79
+ const room = HBInit({
80
+ roomName: "Haxball.JS",
81
+ maxPlayers: 16,
82
+ public: true,
83
+ noPlayer: true,
84
+ token: "YOUR_TOKEN_HERE", // Required
85
+ });
82
86
 
83
- Name the file `room.ts` instead of `room.js` and use example room code from the previous section.
87
+ room.setDefaultStadium("Big");
88
+ room.setScoreLimit(5);
89
+ room.setTimeLimit(0);
84
90
 
85
- You may run the server with `ts-node room.ts` instead of `node room.js`. To make it runnable with `npm start`, add the alias to `package.json`:
91
+ room.onRoomLink = function (link) {
92
+ console.log(link);
93
+ };
94
+ });
95
+ ```
96
+
97
+ #### ๐Ÿ’ป (Optional, Highly Experimental!) Bun
86
98
 
87
- ```json
88
- // package.json
99
+ It's highly experimental and risky to use it in a production environment, but `haxball.js` is compatible with [Bun.JS](https://bun.sh/).
89
100
 
90
- //...
91
- "scripts": {
92
- "start": "ts-node run.ts"
93
- }
94
- //...
101
+ ```bash
102
+ bun install haxball.js
103
+ bun index.ts
95
104
  ```
96
105
 
97
106
  ---
98
107
 
99
108
  <h2 id="technologies">๐Ÿš€ Technologies</h2>
100
109
 
101
- - wrtc - WebRTC implementation for NodeJS
110
+ - node-datachannel - WebRTC implementation for Node.JS
102
111
  - ws - Websocket Connection
103
112
  - json5 - JSON Helper Module
104
- - @peculiar/webcrypto - Webcrypto implementation for NodeJS
113
+ - @peculiar/webcrypto - WebCrypto implementation for Node.JS
105
114
  - pako - ZLIB port for NodeJS
106
- - xhr2 - W3C XMLHttpRequest implementation for NodeJS
107
- - http-proxy-agent - Websocket Proxy Support
115
+ - xhr2 - W3C XMLHttpRequest implementation for Node.JS
116
+ - https-proxy-agent - Websocket Proxy Support
108
117
  - @types/haxball-headless-browser - Type definitions
109
118
 
110
119
  [Back To The Top](#title)
@@ -135,7 +144,8 @@ You may run the server with `ts-node room.ts` instead of `node room.js`. To make
135
144
 
136
145
  - Make a fork of this repository
137
146
  - Clone to you machine and entry on respective paste
138
- - Create a branch with your resource: `git checkout -b my-feature`
147
+ - Make sure to update testing token on `test/room.js` with a valid one for Github Actions CI/CD (Important)
148
+ - Create a branch from develop: `git checkout -b my-feature develop`
139
149
  - Commit your changes: `git commit -m 'feat: My new feature'`
140
150
  - Push your branch: `git push origin my-feature`
141
151
  - A green button will appear at the beginning of this repository
@@ -167,12 +177,8 @@ You may run the server with `ts-node room.ts` instead of `node room.js`. To make
167
177
 
168
178
  <h2 id="license">๐Ÿ” License</h2>
169
179
 
170
- Copyright ยฉ 2023 [Mertushka <mertushka@proton.me>](https://github.com/mertushka)
180
+ Copyright ยฉ 2023 mertushka & basro
171
181
 
172
182
  This project is licensed by [MIT License](https://api.github.com/licenses/mit).
173
183
 
174
184
  [Back To The Top](#title)
175
-
176
- ---
177
-
178
- _This README was generated with ๐Ÿ’Ÿ by [readme-template-generator](https://github.com/mertushka/readme-template-generator)_
package/SECURITY.md ADDED
@@ -0,0 +1,12 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | ------------------ |
7
+ | 2.x.x | :white_check_mark: |
8
+ | 1.x.x | :x: |
9
+
10
+ ## Reporting a Vulnerability
11
+
12
+ Contact [@basro](https://github.com/basro) or [@mertushka](https://github.com/mertushka) privately.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haxball.js",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "A powerful library for interacting with the Haxball Headless API",
5
5
  "main": "src/index.js",
6
6
  "types": "types/index.d.ts",
@@ -21,10 +21,10 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@peculiar/webcrypto": "^1.5.0",
24
- "@roamhq/wrtc": "^0.8.0",
25
24
  "@types/haxball-headless-browser": ">=0.3.0",
26
25
  "https-proxy-agent": "^7.0.5",
27
26
  "json5": "^2.2.3",
27
+ "node-datachannel": "^0.23.0",
28
28
  "pako": "^2.1.0",
29
29
  "ws": "^8.18.0",
30
30
  "xhr2": "^0.2.1"
@@ -40,5 +40,8 @@
40
40
  "bugs": {
41
41
  "url": "https://github.com/mertushka/haxball.js/issues"
42
42
  },
43
- "homepage": "https://github.com/mertushka/haxball.js#readme"
43
+ "homepage": "https://github.com/mertushka/haxball.js#readme",
44
+ "trustedDependencies": [
45
+ "node-datachannel"
46
+ ]
44
47
  }