@jfvilas/kwirth-plugin-rallyx 0.1.2 → 0.1.4

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.
Files changed (4) hide show
  1. package/NOTICE.md +74 -74
  2. package/README.md +96 -76
  3. package/front.js +3556 -3565
  4. package/package.json +6 -2
package/NOTICE.md CHANGED
@@ -1,74 +1,74 @@
1
- # NOTICE — Rally-X Plugin
2
-
3
- ## Upstream Game
4
-
5
- The Rally-X game is a homebrew recreation of the classic 1980s arcade game
6
- Rally-X (originally by Midway/Namco), developed by Marco Parenzan.
7
-
8
- - **Source:** https://github.com/marcoparenzan/rallyx
9
- - **License:** MIT (see below)
10
- - **Technology:** Phaser 2.x (HTML5 game framework) + RequireJS (AMD module loader)
11
-
12
- ### Modifications
13
-
14
- The game code has been adapted to run inside a Kwirth plugin iframe:
15
-
16
- 1. **Named AMD defines:** The original modules use anonymous `define([])` calls
17
- that rely on the script URL for the module name. In the iframe (inline
18
- scripts), there is no URL, so each module has been given an explicit name:
19
- `define("car", [])`, `define("flag", [])`, etc.
20
-
21
- 2. **Cookie → localStorage:** The original high-score persistence uses browser
22
- cookies. In the iframe `srcdoc` context, cookies are unreliable, so the
23
- `setCookie`/`getCookie`/`deleteCookie` functions have been replaced with
24
- `localStorage` equivalents.
25
-
26
- 3. **postMessage bridge:** A bridge has been added to report game state (score,
27
- lives, round, fuel) and game-over events to the parent window (the Kwirth
28
- plugin), so the plugin can display HUD values and persist scores in the
29
- cluster's ConfigMap.
30
-
31
- 4. **Asset loading:** Assets are inlined as data URIs. A Phaser loader patch
32
- redirects the game's `"assets/..."` URLs to these data URIs, so the game
33
- code itself is unmodified in its asset loading calls.
34
-
35
- ### Files vendored from upstream
36
-
37
- - `src/front/rallyx/phaser.txt` — Phaser 2.x library (unmodified)
38
- - `src/front/rallyx/require.txt` — RequireJS library (unmodified)
39
- - `src/front/rallyx/js/*.txt` — Game modules (modified as described above)
40
- - `src/front/rallyx/assets/*` — Game assets (unmodified)
41
-
42
- ## Phaser
43
-
44
- - **Source:** https://phaser.io/
45
- - **License:** MIT
46
-
47
- ## RequireJS
48
-
49
- - **Source:** https://requirejs.org/
50
- - **License:** MIT
51
-
52
- ## License (upstream game)
53
-
54
- The MIT License (MIT)
55
-
56
- Copyright (c) 2017 Marco Parenzan
57
-
58
- Permission is hereby granted, free of charge, to any person obtaining a copy
59
- of this software and associated documentation files (the "Software"), to deal
60
- in the Software without restriction, including without limitation the rights
61
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
62
- copies of the Software, and to permit persons to whom the Software is
63
- furnished to do so, subject to the following conditions:
64
-
65
- The above copyright notice and this permission notice shall be included in
66
- all copies or substantial portions of the Software.
67
-
68
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
70
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
71
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
72
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
73
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
74
- THE SOFTWARE.
1
+ # NOTICE — Rally-X Plugin
2
+
3
+ ## Upstream Game
4
+
5
+ The Rally-X game is a homebrew recreation of the classic 1980s arcade game
6
+ Rally-X (originally by Midway/Namco), developed by Marco Parenzan.
7
+
8
+ - **Source:** https://github.com/marcoparenzan/rallyx
9
+ - **License:** MIT (see below)
10
+ - **Technology:** Phaser 2.x (HTML5 game framework) + RequireJS (AMD module loader)
11
+
12
+ ### Modifications
13
+
14
+ The game code has been adapted to run inside a Kwirth plugin iframe:
15
+
16
+ 1. **Named AMD defines:** The original modules use anonymous `define([])` calls
17
+ that rely on the script URL for the module name. In the iframe (inline
18
+ scripts), there is no URL, so each module has been given an explicit name:
19
+ `define("car", [])`, `define("flag", [])`, etc.
20
+
21
+ 2. **Cookie → localStorage:** The original high-score persistence uses browser
22
+ cookies. In the iframe `srcdoc` context, cookies are unreliable, so the
23
+ `setCookie`/`getCookie`/`deleteCookie` functions have been replaced with
24
+ `localStorage` equivalents.
25
+
26
+ 3. **postMessage bridge:** A bridge has been added to report game state (score,
27
+ lives, round, fuel) and game-over events to the parent window (the Kwirth
28
+ plugin), so the plugin can display HUD values and persist scores in the
29
+ cluster's ConfigMap.
30
+
31
+ 4. **Asset loading:** Assets are inlined as data URIs. A Phaser loader patch
32
+ redirects the game's `"assets/..."` URLs to these data URIs, so the game
33
+ code itself is unmodified in its asset loading calls.
34
+
35
+ ### Files vendored from upstream
36
+
37
+ - `src/front/rallyx/phaser.txt` — Phaser 2.x library (unmodified)
38
+ - `src/front/rallyx/require.txt` — RequireJS library (unmodified)
39
+ - `src/front/rallyx/js/*.txt` — Game modules (modified as described above)
40
+ - `src/front/rallyx/assets/*` — Game assets (unmodified)
41
+
42
+ ## Phaser
43
+
44
+ - **Source:** https://phaser.io/
45
+ - **License:** MIT
46
+
47
+ ## RequireJS
48
+
49
+ - **Source:** https://requirejs.org/
50
+ - **License:** MIT
51
+
52
+ ## License (upstream game)
53
+
54
+ The MIT License (MIT)
55
+
56
+ Copyright (c) 2017 Marco Parenzan
57
+
58
+ Permission is hereby granted, free of charge, to any person obtaining a copy
59
+ of this software and associated documentation files (the "Software"), to deal
60
+ in the Software without restriction, including without limitation the rights
61
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
62
+ copies of the Software, and to permit persons to whom the Software is
63
+ furnished to do so, subject to the following conditions:
64
+
65
+ The above copyright notice and this permission notice shall be included in
66
+ all copies or substantial portions of the Software.
67
+
68
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
70
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
71
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
72
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
73
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
74
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,76 +1,96 @@
1
- # Rally-X
2
-
3
- A Rally-X arcade game channel plugin for [Kwirth](https://kwirthmagnify.dev), the Kubernetes
4
- observability and operations platform ([source](https://github.com/kwirthmagnify/kwirth)).
5
-
6
- ## What it is
7
-
8
- This plugin runs a homebrew recreation of the classic 1980s Rally-X arcade game
9
- (originally by Midway/Namco) inside a Kwirth tab. The game is built with Phaser
10
- 2.x and runs in an isolated iframe, so its globals never clash with Kwirth's
11
- React/MUI.
12
-
13
- The game state (score, lives, round, fuel) is displayed in a HUD bar above the
14
- game area. High scores are persisted in a Kubernetes ConfigMap, shared across
15
- all users of the cluster.
16
-
17
- ## How it works
18
-
19
- - The game (Phaser + RequireJS + all assets) is bundled into the plugin's
20
- `front.js` as text and base64. At runtime, it is injected into an iframe via
21
- `srcdoc` — no network requests needed.
22
- - The iframe survives tab switches: switching away hides it, switching back
23
- repositions it. Only stopping the channel destroys it.
24
- - A `postMessage` bridge reports game state to the plugin for HUD display and
25
- score persistence.
26
- - High scores are stored via the back channel's `writeStorage` (ConfigMap
27
- `kwirth-store-channel-rallyx-scores`).
28
-
29
- ## Installation
30
-
31
- Rally-X is published to npm as `@jfvilas/kwirth-plugin-rallyx` and listed in the **jfvilas marketplace**.
32
- If your Kwirth does not list it yet, add this manifest as a marketplace:
33
-
34
- ```
35
- https://raw.githubusercontent.com/jfvilas/kwirth/master/manifest.json
36
- ```
37
-
38
- Then install **Rally-X** from the plugin manager and add the channel to a tab. Source code at
39
- [github.com/jfvilas/kwirth](https://github.com/jfvilas/kwirth) (folder `plugins/rallyx`).
40
-
41
- ## Controls
42
-
43
- | Key | Action |
44
- |-----|--------|
45
- | ← ↑ → ↓ | Drive |
46
- | Ctrl | Drop smoke |
47
- | Space / Ctrl | Start (on title screen) |
48
-
49
- ## Architecture
50
-
51
- ```
52
- src/
53
- ├── back/index.ts — back channel: score persistence (ConfigMap)
54
- ├── common/RallyxTypes.ts — shared types
55
- ├── front/
56
- │ ├── index.ts — registers RallyxChannel on window.__kwirth_plugins__
57
- │ ├── RallyxChannel.tsx — IChannel impl (lifecycle, message routing)
58
- │ ├── RallyxMachine.ts — iframe manager (builds HTML, manages lifecycle)
59
- │ ├── RallyxTabContent.tsx — tab UI (HUD, game area, scores overlay)
60
- │ ├── RallyxSetup.tsx — setup dialog (sender notification, pause-on-blur)
61
- │ ├── RallyxConfig.ts — config classes
62
- │ ├── RallyxData.ts — channel state (survives tab switches)
63
- │ ├── RallyxScores.ts — score store (back + local fallback)
64
- │ ├── icons.tsx — plugin icon
65
- │ └── rallyx/
66
- │ ├── phaser.txt — Phaser 2.x library
67
- │ ├── require.txt — RequireJS library
68
- │ ├── js/*.txt — game modules (named AMD defines)
69
- │ └── assets/ — game assets (PNGs, tilemap JSON)
70
- └── types/assets.d.ts — ambient declarations for non-TS imports
71
- ```
72
-
73
- ## License
74
-
75
- The upstream game is MIT licensed (Copyright (c) 2017 Marco Parenzan).
76
- See [NOTICE.md](NOTICE.md) for full attribution.
1
+ # Rally-X — a channel plugin for Kwirth
2
+
3
+ A Rally-X arcade game inside a [Kwirth](https://kwirthmagnify.dev) tab: drive your blue car through the maze,
4
+ pick up the flags before the fuel runs out, and lose the red cars behind a cloud of smoke. A homebrew
5
+ recreation of the 1980 arcade classic, with a high-score table shared by everyone on the cluster.
6
+
7
+ ![A round in play](https://raw.githubusercontent.com/jfvilas/kwirth/master/plugins/rallyx/docs/screenshots/game.png)
8
+
9
+ - Kwirth: https://kwirthmagnify.dev — source at https://github.com/kwirthmagnify/kwirth
10
+ - Plugin source: https://github.com/jfvilas/kwirth (folder `plugins/rallyx`)
11
+ - The game is MIT licensed, Copyright (c) 2017 Marco Parenzan; see [NOTICE.md](NOTICE.md).
12
+
13
+ ## What it is
14
+
15
+ A **standalone channel**: it reads nothing of the cluster, asks for no cluster scope and selects no pods.
16
+ Picking it switches the view to `none` on its own.
17
+
18
+ The game is built with Phaser 2 and runs in an isolated iframe, so its globals never clash with Kwirth's.
19
+ Phaser, RequireJS and every asset travel inside the plugin's `front.js`, so it needs no network once
20
+ installed. The iframe **survives tab switches**: switching away hides it, coming back puts it in place again,
21
+ and only stopping the channel destroys it. A small bridge reports the game's state to the tab, which shows
22
+ it in the bar above the game: score, lives, round, fuel and best score.
23
+
24
+ ## Using it
25
+
26
+ Add the **rallyx** channel to a tab and start it. The setup asks for:
27
+
28
+ | Field | Meaning |
29
+ |---|---|
30
+ | **Notify a sender when the record is beaten** | Optional: one of Kwirth's senders gets a message when someone takes the top of the table |
31
+ | **Pause when the tab loses focus** | The game freezes when you click elsewhere, and goes on when you click it again |
32
+
33
+ | Key | Action |
34
+ |---|---|
35
+ | Arrows | Drive |
36
+ | Ctrl | Smoke screen |
37
+ | Space / Ctrl | Start, on the title screen |
38
+ | Ctrl+Shift+Enter | Kwirth's full screen, also while the game has the focus |
39
+
40
+ The game keeps its 4:3 proportions and fits the tab.
41
+
42
+ ## The high-score table
43
+
44
+ It lives in the cluster, not in the browser: the back end stores it in a ConfigMap,
45
+ `kwirth-store-channel-rallyx-scores`, so every user of that Kwirth sees the same table and it survives
46
+ changing machines.
47
+
48
+ ## Installing it in Kwirth
49
+
50
+ It is published on npmjs as `@jfvilas/kwirth-plugin-rallyx` and listed in the jfvilas marketplace. If your
51
+ Kwirth does not list it yet, add it as a marketplace with this manifest URL:
52
+
53
+ ```
54
+ https://raw.githubusercontent.com/jfvilas/kwirth/master/manifest.json
55
+ ```
56
+
57
+ Then install `rallyx` from the plugin manager. No restart is needed and it depends on no other extension.
58
+
59
+ ## Screenshots
60
+
61
+ The setup:
62
+
63
+ ![Setup](https://raw.githubusercontent.com/jfvilas/kwirth/master/plugins/rallyx/docs/screenshots/setup.png)
64
+
65
+ The title screen:
66
+
67
+ ![Title](https://raw.githubusercontent.com/jfvilas/kwirth/master/plugins/rallyx/docs/screenshots/title.png)
68
+
69
+ Full screen:
70
+
71
+ ![Full screen](https://raw.githubusercontent.com/jfvilas/kwirth/master/plugins/rallyx/docs/screenshots/fullscreen.png)
72
+
73
+ ## Building
74
+
75
+ ```
76
+ npm install
77
+ npm run build # typecheck + dist/
78
+ npm run watch # fast rebuild without typecheck
79
+ npm test # unit tests
80
+ ```
81
+
82
+ The e2e (`e2e/`, Playwright) runs against a live Kwirth with its own `.creds.json`;
83
+ `tests/zz-readme.spec.ts` takes the screenshots of this README.
84
+
85
+ ```
86
+ src/
87
+ ├── back/index.ts back channel: the score table (ConfigMap)
88
+ ├── common/RallyxTypes.ts shared types
89
+ └── front/
90
+ ├── RallyxChannel.tsx the channel: lifecycle and messages
91
+ ├── RallyxMachine.ts the iframe: builds its HTML, keeps it alive
92
+ ├── RallyxTabContent.tsx the tab: HUD, game area, score panel
93
+ ├── RallyxSetup.tsx the setup dialog
94
+ ├── RallyxScores.ts the score store (back, with a local fallback)
95
+ └── rallyx/ Phaser, RequireJS, the game modules and its assets
96
+ ```