vue-phaserjs 4.3.3 → 4.5.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.
Files changed (4) hide show
  1. package/README.md +35 -26
  2. package/dist/index.d.ts +1249 -1000
  3. package/dist/index.js +601 -286
  4. package/package.json +7 -7
package/README.md CHANGED
@@ -5,59 +5,68 @@
5
5
  [![NPM downloads][badge-npm-downloads]][url-npm]
6
6
  [![NPM Unpacked Size (with version)][badge-npm-unpacked-size]][url-npm]
7
7
 
8
- Inspired by [phavuer](https://github.com/laineus/phavuer).
8
+ This package integrates the [Phaser](https://phaser.io) game engine with Vue. It provides Vue components and composables that bridge Phaser scenes, game objects and Pinia state to the Vue component lifecycle.
9
9
 
10
- Vue integration for the [Phaser](https://phaser.io) game engine. Provides Vue components and composables that bridge Phaser scenes, game objects, and Pinia state with the Vue component lifecycle.
10
+ Design notes live in [the specs](https://github.com/Esposter/Esposter/tree/main/openspec/specs/vue-phaserjs).
11
11
 
12
12
  ## Table of Contents
13
13
 
14
14
  - 🚀 [Getting Started](#getting-started)
15
- - 📖 [Documentation](#documentation)
15
+ - 🧩 [Key Exports](#key-exports)
16
16
  - ⚖️ [License](#license)
17
17
 
18
18
  ---
19
19
 
20
20
  ## <a name="getting-started">🚀 Getting Started</a>
21
21
 
22
+ 1. Install the packages.
23
+
22
24
  ```bash
23
25
  pnpm i vue-phaserjs @esposter/shared parse-tmx vue phaser phaser4-rex-plugins pinia
24
26
  ```
25
27
 
26
- Add the type declaration files so scene key types and custom plugins get proper intellisense:
27
-
28
- - [`phaser.d.ts`](https://github.com/Esposter/Esposter/blob/main/apps/web/app/types/phaser.d.ts) — narrows scene key types
29
- - [`vue-phaserjs.d.ts`](https://github.com/Esposter/Esposter/blob/main/apps/web/app/types/vue-phaserjs.d.ts) — provides custom plugin types
30
-
31
- ## <a name="documentation">📖 Documentation</a>
32
-
33
- We highly recommend you take a look at the [documentation](https://github.com/Esposter/Esposter/tree/main/openspec/specs/vue-phaserjs) to level up.
28
+ Check: the install ends with no peer or version conflict, and `package.json` lists `vue-phaserjs`.
34
29
 
35
- ### Usage
30
+ 2. Add these type declaration files. The editor shows intellisense for scene keys and custom plugins.
31
+ - [`phaser.d.ts`](https://github.com/Esposter/Esposter/blob/main/apps/web/app/types/phaser.d.ts) narrows the scene key types.
32
+ - [`vue-phaserjs.d.ts`](https://github.com/Esposter/Esposter/blob/main/apps/web/app/types/vue-phaserjs.d.ts) provides the custom plugin types.
36
33
 
37
- See the reference implementation in [`apps/web/app/pages/dungeons.vue`](https://github.com/Esposter/Esposter/blob/main/apps/web/app/pages/dungeons.vue) for a complete example of a Phaser game embedded in a Nuxt/Vue page with Pinia-driven state.
34
+ 3. Create a component from this code. The page shows the text `Hello`.
38
35
 
39
- ### Features
36
+ ```vue
37
+ <script setup lang="ts">
38
+ import { Game, Scene, Text } from "vue-phaserjs";
39
+ </script>
40
40
 
41
- - Vue components wrapping Phaser `Game`, `Scene`, and common game objects
42
- - Reactive Pinia integration — game state flows naturally through Vue's reactivity system
43
- - Scene lifecycle hooks aligned with Vue's `onMounted` / `onUnmounted`
44
- - TypeScript-first with full generic scene key support
41
+ <template>
42
+ <Game :configuration="{ height: 600, width: 800 }">
43
+ <Scene autoStart sceneKey="menu">
44
+ <Text :configuration="{ style: { fontSize: '32px' }, text: 'Hello', x: 400, y: 300 }" />
45
+ </Scene>
46
+ </Game>
47
+ </template>
48
+ ```
45
49
 
46
- ### Commands
50
+ For a complete example, see [the dungeons page](https://github.com/Esposter/Esposter/blob/main/apps/web/app/pages/dungeons.vue). It embeds a Phaser game in a Nuxt/Vue page with Pinia-driven state.
47
51
 
48
- Run from `packages/vue-phaserjs/`:
52
+ ## <a name="key-exports">🧩 Key Exports</a>
49
53
 
50
- ```bash
51
- pnpm build # compile to dist/
52
- pnpm test # vitest watch mode (coverage is run from the repo root)
53
- pnpm lint:fix # auto-fix lint
54
- pnpm typecheck # type check
55
- ```
54
+ | Export | Kind | Purpose |
55
+ | ------------------------------------------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------- |
56
+ | `Game` | component | Starts a Phaser game in its element. Renders its slot once the game is ready. |
57
+ | `onCreate`, `onInit`, `onNextTick`, `onPreload`, `onShutdown`, `onUpdate` | function | Runs a callback at one stage of a scene's lifecycle. Returns the function that removes the callback. |
58
+ | `Scene` | component | Adds a Phaser scene. Starts it when `autoStart` is set. Renders its children while it is active. |
59
+ | `Sprite` | component | A sprite drawn in the enclosing scene from its configuration |
60
+ | `useAnimations` | composable | Creates a scene's animation frames. Removes them on shutdown or unmount. |
61
+ | `useGame` | composable | The Phaser game in the store. Throws until a Game component has created it. |
62
+ | `useTween` | composable | Sets a tween on a ref. Clears the ref when the tween completes. |
56
63
 
57
64
  ## <a name="license">⚖️ License</a>
58
65
 
59
66
  This project is licensed under the [Apache-2.0 license](https://github.com/Esposter/Esposter/blob/main/LICENSE).
60
67
 
68
+ Inspired by [phavuer](https://github.com/laineus/phavuer).
69
+
61
70
  [badge-license]: https://img.shields.io/github/license/Esposter/Esposter.svg?color=blue
62
71
  [url-license]: https://github.com/Esposter/Esposter/blob/main/LICENSE
63
72
  [badge-npm-version]: https://img.shields.io/npm/v/vue-phaserjs/latest?color=brightgreen