@kbve/laser 0.0.8 → 0.1.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 (69) hide show
  1. package/README.md +40 -10
  2. package/laser.es.js +376 -0
  3. package/package.json +54 -24
  4. package/src/index.d.ts +0 -19
  5. package/src/index.js +0 -37
  6. package/src/index.js.map +0 -1
  7. package/src/lib/animations/TypewriterComponent.d.ts +0 -8
  8. package/src/lib/animations/TypewriterComponent.js +0 -53
  9. package/src/lib/animations/TypewriterComponent.js.map +0 -1
  10. package/src/lib/constants.d.ts +0 -2
  11. package/src/lib/constants.js +0 -6
  12. package/src/lib/constants.js.map +0 -1
  13. package/src/lib/eventhandler.d.ts +0 -31
  14. package/src/lib/eventhandler.js +0 -45
  15. package/src/lib/eventhandler.js.map +0 -1
  16. package/src/lib/icon/CollapseIcon.d.ts +0 -4
  17. package/src/lib/icon/CollapseIcon.js +0 -10
  18. package/src/lib/icon/CollapseIcon.js.map +0 -1
  19. package/src/lib/icon/ExpandIcon.d.ts +0 -4
  20. package/src/lib/icon/ExpandIcon.js +0 -10
  21. package/src/lib/icon/ExpandIcon.js.map +0 -1
  22. package/src/lib/laser.d.ts +0 -1
  23. package/src/lib/laser.js +0 -8
  24. package/src/lib/laser.js.map +0 -1
  25. package/src/lib/localdb.d.ts +0 -55
  26. package/src/lib/localdb.js +0 -592
  27. package/src/lib/localdb.js.map +0 -1
  28. package/src/lib/minigame/dice/MinigameDice.d.ts +0 -4
  29. package/src/lib/minigame/dice/MinigameDice.js +0 -85
  30. package/src/lib/minigame/dice/MinigameDice.js.map +0 -1
  31. package/src/lib/phaser/map/mapdatabase.d.ts +0 -1
  32. package/src/lib/phaser/map/mapdatabase.js +0 -175
  33. package/src/lib/phaser/map/mapdatabase.js.map +0 -1
  34. package/src/lib/phaser/monster/bird.d.ts +0 -7
  35. package/src/lib/phaser/monster/bird.js +0 -44
  36. package/src/lib/phaser/monster/bird.js.map +0 -1
  37. package/src/lib/phaser/npc/chatbubble.d.ts +0 -10
  38. package/src/lib/phaser/npc/chatbubble.js +0 -78
  39. package/src/lib/phaser/npc/chatbubble.js.map +0 -1
  40. package/src/lib/phaser/npc/npcdatabase.d.ts +0 -59
  41. package/src/lib/phaser/npc/npcdatabase.js +0 -550
  42. package/src/lib/phaser/npc/npcdatabase.js.map +0 -1
  43. package/src/lib/phaser/npc/npchandler.d.ts +0 -21
  44. package/src/lib/phaser/npc/npchandler.js +0 -123
  45. package/src/lib/phaser/npc/npchandler.js.map +0 -1
  46. package/src/lib/phaser/npc/tooltipmenu.d.ts +0 -17
  47. package/src/lib/phaser/npc/tooltipmenu.js +0 -68
  48. package/src/lib/phaser/npc/tooltipmenu.js.map +0 -1
  49. package/src/lib/phaser/player/playercontroller.d.ts +0 -24
  50. package/src/lib/phaser/player/playercontroller.js +0 -219
  51. package/src/lib/phaser/player/playercontroller.js.map +0 -1
  52. package/src/lib/quadtree.d.ts +0 -23
  53. package/src/lib/quadtree.js +0 -123
  54. package/src/lib/quadtree.js.map +0 -1
  55. package/src/lib/regex.d.ts +0 -1
  56. package/src/lib/regex.js +0 -6
  57. package/src/lib/regex.js.map +0 -1
  58. package/src/lib/utils/debug.d.ts +0 -8
  59. package/src/lib/utils/debug.js +0 -46
  60. package/src/lib/utils/debug.js.map +0 -1
  61. package/src/lib/utils/loader.d.ts +0 -3
  62. package/src/lib/utils/loader.js +0 -87
  63. package/src/lib/utils/loader.js.map +0 -1
  64. package/src/lib/utils/ulid.d.ts +0 -1
  65. package/src/lib/utils/ulid.js +0 -38
  66. package/src/lib/utils/ulid.js.map +0 -1
  67. package/src/types.d.ts +0 -423
  68. package/src/types.js +0 -14
  69. package/src/types.js.map +0 -1
package/README.md CHANGED
@@ -1,22 +1,52 @@
1
1
  # Laser
2
2
 
3
- Laser is an npm library that provides seamless integration between React and Phaser, allowing you to create rich, interactive web applications with ease.
3
+ <a href="https://kbve.com" style="float: right;"><img width="150" height="50" title="KBVE logo" src="https://kbve.com/assets/images/brand/letter_logo.svg" /></a>
4
4
 
5
- ## Features
5
+ Laser is a lightweight integration layer for Phaser and React Three Fiber in React 19 applications.
6
+ It provides React hooks and components for embedding Phaser games and R3F scenes with a shared event bus, making it easy to build hybrid 2D/3D game UIs.
6
7
 
7
- - **React and Phaser Integration**: Leverage the power of both React and Phaser in your projects.
8
- - **Component-Based Architecture**: Utilize React's component-based architecture for structuring your game elements.
9
- - **Easy Setup**: Quickly set up and start building your projects with minimal configuration.
10
- - **Optimized Performance**: Efficiently manage and update your game state with React's rendering optimizations.
8
+ ## Features
11
9
 
12
- ## Installation
10
+ - **Phaser integration** — `<PhaserGame>` component with ref-based access, `usePhaserGame` context hook, and `usePhaserEvent` for subscribing to Phaser events
11
+ - **React Three Fiber integration** — `<Stage>` component and `useGameLoop` hook for frame-synced game logic
12
+ - **Shared event bus** — `LaserEventBus` for decoupled communication between Phaser and R3F layers
13
+ - **TypeScript-first** — Full type definitions with exported types for configs, events, and geometry primitives
13
14
 
14
- To install Laser, use npm or pnpm:
15
+ ## Install
15
16
 
16
17
  ```bash
17
- pnpm install @kbve/laser
18
+ npm install @kbve/laser
18
19
  ```
19
20
 
21
+ ### Peer Dependencies
22
+
23
+ Laser requires the following peer dependencies (install the ones you need):
24
+
25
+ - `react` >= 18.0.0
26
+ - `react-dom` >= 18.0.0
27
+ - `phaser` >= 3.80.0 _(optional — only needed for Phaser features)_
28
+ - `three` >= 0.160.0 _(optional — only needed for R3F features)_
29
+ - `@react-three/fiber` >= 9.0.0 _(optional)_
30
+ - `@react-three/drei` >= 10.0.0 _(optional)_
31
+
20
32
  ## Usage
21
33
 
22
- We recommend that you import all of it as `import * as Laser from '@kbve/laser';`
34
+ ```tsx
35
+ import {
36
+ PhaserGame,
37
+ usePhaserEvent,
38
+ Stage,
39
+ useGameLoop,
40
+ laserEvents,
41
+ } from '@kbve/laser';
42
+ ```
43
+
44
+ ### Support
45
+
46
+ For questions or help, reach out via our [Discord server](https://kbve.com/discord/).
47
+
48
+ [![Discord](https://img.shields.io/discord/342732838598082562?logo=discord)](https://kbve.com/discord/)
49
+
50
+ ## License
51
+
52
+ MIT
package/laser.es.js ADDED
@@ -0,0 +1,376 @@
1
+ import { jsxs as m, jsx as b } from "react/jsx-runtime";
2
+ import { createContext as D, useContext as P, forwardRef as S, useRef as p, useState as k, useImperativeHandle as E, useEffect as w, useMemo as I } from "react";
3
+ import c from "phaser";
4
+ import { Canvas as C, useFrame as K } from "@react-three/fiber";
5
+ import { addComponent as X, addEntity as Y, createWorld as N, hasComponent as Q, query as tt, removeEntity as et } from "bitecs";
6
+ import { RAPIER as it, createRapierPhysics as rt } from "@phaserjs/rapier-connector";
7
+ class A {
8
+ handlers = /* @__PURE__ */ new Map();
9
+ on(t, e) {
10
+ let s = this.handlers.get(t);
11
+ return s || (s = /* @__PURE__ */ new Set(), this.handlers.set(t, s)), s.add(e), () => {
12
+ s.delete(e);
13
+ };
14
+ }
15
+ off(t, e) {
16
+ this.handlers.get(t)?.delete(e);
17
+ }
18
+ emit(t, e) {
19
+ this.handlers.get(t)?.forEach((s) => {
20
+ s(e);
21
+ });
22
+ }
23
+ clear() {
24
+ this.handlers.clear();
25
+ }
26
+ }
27
+ const f = new A();
28
+ class d {
29
+ bounds;
30
+ capacity;
31
+ points;
32
+ divided;
33
+ cache;
34
+ northeast;
35
+ northwest;
36
+ southeast;
37
+ southwest;
38
+ constructor(t, e = 4) {
39
+ this.bounds = t, this.capacity = e, this.points = [], this.divided = !1, this.cache = /* @__PURE__ */ new Map();
40
+ }
41
+ subdivide() {
42
+ const { xMin: t, yMin: e, xMax: s, yMax: i } = this.bounds, n = (s - t) / 2, o = (i - e) / 2, a = t, h = e;
43
+ this.northeast = new d(
44
+ { xMin: a + n, xMax: a + 2 * n, yMin: e, yMax: h + o },
45
+ this.capacity
46
+ ), this.northwest = new d(
47
+ { xMin: t, xMax: a + n, yMin: e, yMax: h + o },
48
+ this.capacity
49
+ ), this.southeast = new d(
50
+ { xMin: a + n, xMax: a + 2 * n, yMin: h + o, yMax: h + 2 * o },
51
+ this.capacity
52
+ ), this.southwest = new d(
53
+ { xMin: t, xMax: a + n, yMin: h + o, yMax: h + 2 * o },
54
+ this.capacity
55
+ ), this.divided = !0;
56
+ }
57
+ insert(t) {
58
+ return this.contains(t.bounds) ? this.points.length < this.capacity ? (this.points.push(t), !0) : (this.divided || this.subdivide(), !!(this.northeast?.insert(t) || this.northwest?.insert(t) || this.southeast?.insert(t) || this.southwest?.insert(t))) : !1;
59
+ }
60
+ contains(t) {
61
+ const { xMin: e, yMin: s, xMax: i, yMax: n } = this.bounds;
62
+ return t.xMin >= e && t.xMax <= i && t.yMin >= s && t.yMax <= n;
63
+ }
64
+ queryRange(t, e = []) {
65
+ if (!this.intersects(t))
66
+ return e;
67
+ for (const s of this.points)
68
+ this.isWithinBounds(s.bounds, t) && e.push(s);
69
+ return this.divided && (this.northwest?.queryRange(t, e), this.northeast?.queryRange(t, e), this.southwest?.queryRange(t, e), this.southeast?.queryRange(t, e)), e;
70
+ }
71
+ query(t, e = []) {
72
+ const s = `${t.x},${t.y}`, i = this.cache.get(s);
73
+ if (i)
74
+ return i;
75
+ if (!this.intersects({
76
+ xMin: t.x,
77
+ xMax: t.x,
78
+ yMin: t.y,
79
+ yMax: t.y
80
+ }))
81
+ return e;
82
+ for (const n of this.points)
83
+ this.isWithinRange(t, n.bounds) && e.push(n);
84
+ return this.divided && (this.northwest?.query(t, e), this.northeast?.query(t, e), this.southwest?.query(t, e), this.southeast?.query(t, e)), this.cache.set(s, e), e;
85
+ }
86
+ intersects(t) {
87
+ const { xMin: e, yMin: s, xMax: i, yMax: n } = this.bounds;
88
+ return !(t.xMin > i || t.xMax < e || t.yMin > n || t.yMax < s);
89
+ }
90
+ isWithinBounds(t, e) {
91
+ return t.xMax >= e.xMin && t.xMin <= e.xMax && t.yMax >= e.yMin && t.yMin <= e.yMax;
92
+ }
93
+ isWithinRange(t, e) {
94
+ return t.x >= e.xMin && t.x <= e.xMax && t.y >= e.yMin && t.y <= e.yMax;
95
+ }
96
+ }
97
+ const g = D(null);
98
+ function R() {
99
+ const r = P(g);
100
+ if (!r)
101
+ throw new Error(
102
+ "usePhaserGame must be used within a <PhaserGame> component"
103
+ );
104
+ return r;
105
+ }
106
+ const z = S(
107
+ function({ config: t, onReady: e, onDestroy: s, className: i, style: n, children: o }, a) {
108
+ const h = p(null), l = p(null), [y, x] = k("idle");
109
+ E(
110
+ a,
111
+ () => ({
112
+ game: l.current,
113
+ status: y
114
+ }),
115
+ [y]
116
+ ), w(() => {
117
+ if (!h.current) return;
118
+ x("booting");
119
+ const u = new c.Game({
120
+ type: c.AUTO,
121
+ width: t.width ?? 800,
122
+ height: t.height ?? 600,
123
+ parent: h.current,
124
+ scene: t.scenes,
125
+ physics: t.physics,
126
+ plugins: t.plugins,
127
+ scale: t.scale,
128
+ backgroundColor: t.backgroundColor,
129
+ transparent: t.transparent
130
+ });
131
+ return l.current = u, u.events.once("ready", () => {
132
+ x("running"), f.emit("game:ready", { game: u }), e?.(u);
133
+ }), () => {
134
+ x("destroyed"), f.emit("game:destroy", void 0), s?.(), u.destroy(!0), l.current = null;
135
+ };
136
+ }, [t, e, s]);
137
+ const v = I(
138
+ () => ({ game: l.current, status: y }),
139
+ [y]
140
+ );
141
+ return /* @__PURE__ */ m(g.Provider, { value: v, children: [
142
+ /* @__PURE__ */ b("div", { ref: h, className: i, style: n }),
143
+ o
144
+ ] });
145
+ }
146
+ );
147
+ function T(r, t, e) {
148
+ const { game: s } = R(), i = p(t);
149
+ i.current = t, w(() => {
150
+ if (!s) return;
151
+ const n = (...o) => i.current(...o);
152
+ if (e) {
153
+ const o = s.scene.getScene(e);
154
+ if (o)
155
+ return o.events.on(r, n), () => {
156
+ o.events.off(r, n);
157
+ };
158
+ } else
159
+ return s.events.on(r, n), () => {
160
+ s.events.off(r, n);
161
+ };
162
+ }, [s, r, e]);
163
+ }
164
+ class j {
165
+ scene;
166
+ base;
167
+ thumb;
168
+ radius;
169
+ deadZone;
170
+ _direction = null;
171
+ _isActive = !1;
172
+ fixed;
173
+ activePointer = null;
174
+ constructor(t, e) {
175
+ this.scene = t, this.radius = e?.radius ?? 60, this.deadZone = e?.deadZone ?? 0.25, this.fixed = e?.fixed ?? !0;
176
+ const s = e?.x ?? 120, i = e?.y ?? t.scale.height - 120;
177
+ this.base = t.add.circle(
178
+ s,
179
+ i,
180
+ this.radius,
181
+ e?.baseColor ?? 8947848,
182
+ e?.baseAlpha ?? 0.35
183
+ ).setDepth(100).setScrollFactor(0), this.thumb = t.add.circle(
184
+ s,
185
+ i,
186
+ this.radius * 0.4,
187
+ e?.thumbColor ?? 16777215,
188
+ e?.thumbAlpha ?? 0.5
189
+ ).setDepth(101).setScrollFactor(0), this.setupInput();
190
+ }
191
+ setupInput() {
192
+ this.scene.input.on("pointerdown", (t) => {
193
+ if (this.activePointer) return;
194
+ const e = t.x - this.base.x, s = t.y - this.base.y, i = Math.sqrt(e * e + s * s);
195
+ this.fixed && i > this.radius * 2 || (this.fixed || (this.base.setPosition(t.x, t.y), this.thumb.setPosition(t.x, t.y)), this.activePointer = t, this._isActive = !0);
196
+ }), this.scene.input.on("pointermove", (t) => {
197
+ t === this.activePointer && this.updateThumb(t.x, t.y);
198
+ }), this.scene.input.on("pointerup", (t) => {
199
+ t === this.activePointer && this.resetThumb();
200
+ });
201
+ }
202
+ updateThumb(t, e) {
203
+ const s = t - this.base.x, i = e - this.base.y, n = Math.sqrt(s * s + i * i), o = Math.min(n, this.radius), a = Math.atan2(i, s);
204
+ if (this.thumb.setPosition(
205
+ this.base.x + Math.cos(a) * o,
206
+ this.base.y + Math.sin(a) * o
207
+ ), o / this.radius < this.deadZone) {
208
+ this._direction = null;
209
+ return;
210
+ }
211
+ this._direction = this.angleToDirection(a);
212
+ }
213
+ angleToDirection(t) {
214
+ let e = t * 180 / Math.PI;
215
+ return e < 0 && (e += 360), e >= 337.5 || e < 22.5 ? "right" : e >= 22.5 && e < 67.5 ? "down-right" : e >= 67.5 && e < 112.5 ? "down" : e >= 112.5 && e < 157.5 ? "down-left" : e >= 157.5 && e < 202.5 ? "left" : e >= 202.5 && e < 247.5 ? "up-left" : e >= 247.5 && e < 292.5 ? "up" : "up-right";
216
+ }
217
+ resetThumb() {
218
+ this.thumb.setPosition(this.base.x, this.base.y), this._direction = null, this._isActive = !1, this.activePointer = null;
219
+ }
220
+ get direction() {
221
+ return this._direction;
222
+ }
223
+ get isActive() {
224
+ return this._isActive;
225
+ }
226
+ setVisible(t) {
227
+ return this.base.setVisible(t), this.thumb.setVisible(t), this;
228
+ }
229
+ destroy() {
230
+ this.base.destroy(), this.thumb.destroy();
231
+ }
232
+ }
233
+ class V {
234
+ scene;
235
+ gridEngine;
236
+ quadtree;
237
+ cursor;
238
+ wasdKeys;
239
+ tooltip;
240
+ tileSize;
241
+ playerId;
242
+ joystick = null;
243
+ constructor(t, e, s, i) {
244
+ if (this.scene = t, this.gridEngine = e, this.quadtree = s, this.tileSize = i?.tileSize ?? 48, this.playerId = i?.playerId ?? "player", this.cursor = this.scene.input.keyboard?.createCursorKeys(), this.initializeWASDKeys(), this.tooltip = this.scene.add.text(0, 0, "Press [F]", {
245
+ font: "16px Arial",
246
+ backgroundColor: "#000000"
247
+ }).setDepth(4).setPadding(3, 2, 2, 3).setVisible(!1), i?.joystick) {
248
+ const n = typeof i.joystick == "object" ? i.joystick : void 0;
249
+ this.joystick = new j(t, n);
250
+ }
251
+ }
252
+ initializeWASDKeys() {
253
+ const t = this.scene.input.keyboard;
254
+ t && (this.wasdKeys = {
255
+ W: t.addKey(c.Input.Keyboard.KeyCodes.W),
256
+ A: t.addKey(c.Input.Keyboard.KeyCodes.A),
257
+ S: t.addKey(c.Input.Keyboard.KeyCodes.S),
258
+ D: t.addKey(c.Input.Keyboard.KeyCodes.D)
259
+ });
260
+ }
261
+ checkForNearbyObjects() {
262
+ const t = this.gridEngine.getPosition(this.playerId), e = t.x * this.tileSize, s = t.y * this.tileSize, i = this.quadtree.query(t);
263
+ i.length > 0 ? (this.tooltip.setPosition(e, s - 60).setVisible(!0), f.emit("player:nearby", {
264
+ position: t,
265
+ ranges: i
266
+ })) : this.tooltip.setVisible(!1);
267
+ }
268
+ getPlayerPosition() {
269
+ return this.gridEngine.getPosition(this.playerId);
270
+ }
271
+ handleMovement() {
272
+ if (this.scene.input.keyboard?.addKey("F").isDown) {
273
+ const s = this.gridEngine.getPosition(
274
+ this.playerId
275
+ ), i = this.quadtree.query(s);
276
+ if (i.length > 0) {
277
+ f.emit("player:interact", {
278
+ position: s,
279
+ ranges: i
280
+ });
281
+ for (const n of i)
282
+ n.action();
283
+ }
284
+ }
285
+ if (this.joystick?.isActive && this.joystick.direction) {
286
+ this.gridEngine.move(this.playerId, this.joystick.direction), this.checkForNearbyObjects();
287
+ return;
288
+ }
289
+ if (!this.cursor) {
290
+ this.checkForNearbyObjects();
291
+ return;
292
+ }
293
+ const t = this.cursor, e = this.wasdKeys;
294
+ (t.left.isDown || e.A.isDown) && (t.up.isDown || e.W.isDown) ? this.gridEngine.move(this.playerId, "up-left") : (t.left.isDown || e.A.isDown) && (t.down.isDown || e.S.isDown) ? this.gridEngine.move(this.playerId, "down-left") : (t.right.isDown || e.D.isDown) && (t.up.isDown || e.W.isDown) ? this.gridEngine.move(this.playerId, "up-right") : (t.right.isDown || e.D.isDown) && (t.down.isDown || e.S.isDown) ? this.gridEngine.move(this.playerId, "down-right") : t.left.isDown || e.A.isDown ? this.gridEngine.move(this.playerId, "left") : t.right.isDown || e.D.isDown ? this.gridEngine.move(this.playerId, "right") : t.up.isDown || e.W.isDown ? this.gridEngine.move(this.playerId, "up") : (t.down.isDown || e.S.isDown) && this.gridEngine.move(this.playerId, "down"), this.checkForNearbyObjects();
295
+ }
296
+ }
297
+ function G(r) {
298
+ return +r[r.length - 1];
299
+ }
300
+ function O(r) {
301
+ return r.startsWith("monster_bird_") && !r.startsWith("monster_bird_shadow");
302
+ }
303
+ function M(r, t, e, s, i) {
304
+ const n = [];
305
+ for (let o = 0; o < 10; o++) {
306
+ const a = r.add.sprite(0, 0, "monster_bird");
307
+ a.setCrop(t, e, s, i), a.scale = 3, n.push(a);
308
+ }
309
+ return n;
310
+ }
311
+ function Z(r) {
312
+ return M(r, 0, 0, 61, 47);
313
+ }
314
+ function L(r) {
315
+ return M(r, 22, 47, 16, 10);
316
+ }
317
+ function B(r) {
318
+ r.anims.create({
319
+ key: "bird",
320
+ frames: r.anims.generateFrameNumbers("monster_bird", {
321
+ start: 0,
322
+ end: 2
323
+ }),
324
+ frameRate: 10,
325
+ repeat: -1,
326
+ yoyo: !0
327
+ });
328
+ }
329
+ const $ = ({
330
+ children: r,
331
+ className: t,
332
+ ...e
333
+ }) => /* @__PURE__ */ m(
334
+ C,
335
+ {
336
+ camera: { position: [0, 0, 5] },
337
+ ...e,
338
+ className: t,
339
+ children: [
340
+ /* @__PURE__ */ b("ambientLight", { intensity: 1.5 }),
341
+ r
342
+ ]
343
+ }
344
+ );
345
+ function H(r) {
346
+ const t = p(r);
347
+ t.current = r, K((e, s) => {
348
+ t.current(s, e.clock.elapsedTime);
349
+ });
350
+ }
351
+ export {
352
+ A as LaserEventBus,
353
+ g as PhaserContext,
354
+ z as PhaserGame,
355
+ V as PlayerController,
356
+ d as Quadtree,
357
+ it as RAPIER,
358
+ $ as Stage,
359
+ j as VirtualJoystick,
360
+ X as addComponent,
361
+ Y as addEntity,
362
+ B as createBirdAnimation,
363
+ Z as createBirdSprites,
364
+ rt as createRapierPhysics,
365
+ L as createShadowSprites,
366
+ N as createWorld,
367
+ G as getBirdNum,
368
+ Q as hasComponent,
369
+ O as isBird,
370
+ f as laserEvents,
371
+ tt as query,
372
+ et as removeEntity,
373
+ H as useGameLoop,
374
+ T as usePhaserEvent,
375
+ R as usePhaserGame
376
+ };
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@kbve/laser",
3
- "version": "0.0.8",
4
- "description": "A comprehensive game development toolkit for Node.js. Laser is a powerful npm package designed to streamline game development processes, with a focus on efficient game client management. It provides essential tools and utilities to enhance your game creation workflow, including an event handler, quadtree, client management and performance utilities.",
3
+ "version": "0.1.0",
4
+ "description": "Phaser + React Three Fiber integration layer for React 19",
5
5
  "keywords": [
6
6
  "phaser",
7
- "gamedev"
7
+ "react",
8
+ "r3f",
9
+ "react-three-fiber",
10
+ "gamedev",
11
+ "three.js"
8
12
  ],
9
13
  "homepage": "https://kbve.com/application/javascript/",
10
14
  "bugs": {
@@ -16,28 +20,54 @@
16
20
  },
17
21
  "author": "KBVE <hello@kbve.com>",
18
22
  "license": "MIT",
19
- "dependencies": {
20
- "tslib": "^2.3.0",
21
- "nanostores": "^0.9.3",
22
- "phaser": "^3.80.1",
23
- "styled-components": "5.3.6",
24
- "tailwind-merge": "^2.2.1",
25
- "react": "18.2.0",
26
- "react-dom": "18.2.0",
27
- "@nanostores/persistent": "^0.9.1",
28
- "@nanostores/react": "^0.7.2",
29
- "three": "^0.161.0",
30
- "react-spring": "^9.7.3",
31
- "@react-three/drei": "^9.108.3",
32
- "@react-three/fiber": "^8.16.2",
33
- "@react-three/flex": "^1.0.1",
34
- "dexie": "^4.0.7",
35
- "dexie-react-hooks": "^1.1.7"
23
+ "type": "module",
24
+ "main": "./laser.es.js",
25
+ "module": "./laser.es.js",
26
+ "types": "./index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./laser.es.js",
30
+ "types": "./index.d.ts"
31
+ }
36
32
  },
37
- "type": "commonjs",
38
- "main": "./src/index.js",
39
- "typings": "./src/index.d.ts",
33
+ "files": [
34
+ "laser.es.js",
35
+ "index.d.ts",
36
+ "**/*.d.ts",
37
+ "*.md"
38
+ ],
39
+ "peerDependencies": {
40
+ "react": ">=18.0.0",
41
+ "react-dom": ">=18.0.0",
42
+ "phaser": ">=3.80.0",
43
+ "three": ">=0.160.0",
44
+ "@react-three/fiber": ">=9.0.0",
45
+ "@react-three/drei": ">=10.0.0",
46
+ "bitecs": ">=0.4.0",
47
+ "@phaserjs/rapier-connector": ">=1.0.0"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "phaser": {
51
+ "optional": true
52
+ },
53
+ "three": {
54
+ "optional": true
55
+ },
56
+ "@react-three/fiber": {
57
+ "optional": true
58
+ },
59
+ "@react-three/drei": {
60
+ "optional": true
61
+ },
62
+ "bitecs": {
63
+ "optional": true
64
+ },
65
+ "@phaserjs/rapier-connector": {
66
+ "optional": true
67
+ }
68
+ },
69
+ "dependencies": {},
40
70
  "publishConfig": {
41
71
  "access": "public"
42
72
  }
43
- }
73
+ }
package/src/index.d.ts DELETED
@@ -1,19 +0,0 @@
1
- export * from './types';
2
- export * from './lib/constants';
3
- export * from './lib/laser';
4
- export * from './lib/quadtree';
5
- export * from './lib/eventhandler';
6
- export * from './lib/localdb';
7
- export * from './lib/utils/ulid';
8
- export * from './lib/utils/debug';
9
- export * from './lib/utils/loader';
10
- export { default as CollapseIcon } from './lib/icon/CollapseIcon';
11
- export { default as ExpandIcon } from './lib/icon/ExpandIcon';
12
- export { default as MinigameDice } from './lib/minigame/dice/MinigameDice';
13
- export { default as TypewriterComponent } from './lib/animations/TypewriterComponent';
14
- export * from './lib/phaser/player/playercontroller';
15
- export * from './lib/phaser/npc/tooltipmenu';
16
- export * from './lib/phaser/npc/chatbubble';
17
- export * from './lib/phaser/npc/npchandler';
18
- export * from './lib/phaser/npc/npcdatabase';
19
- export * from './lib/phaser/monster/bird';
package/src/index.js DELETED
@@ -1,37 +0,0 @@
1
- "use strict";
2
- // Types
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.TypewriterComponent = exports.MinigameDice = exports.ExpandIcon = exports.CollapseIcon = void 0;
5
- const tslib_1 = require("tslib");
6
- tslib_1.__exportStar(require("./types"), exports);
7
- // Constants
8
- tslib_1.__exportStar(require("./lib/constants"), exports);
9
- tslib_1.__exportStar(require("./lib/laser"), exports);
10
- tslib_1.__exportStar(require("./lib/quadtree"), exports);
11
- tslib_1.__exportStar(require("./lib/eventhandler"), exports);
12
- tslib_1.__exportStar(require("./lib/localdb"), exports);
13
- // Utils
14
- tslib_1.__exportStar(require("./lib/utils/ulid"), exports); // ULID
15
- tslib_1.__exportStar(require("./lib/utils/debug"), exports); // Debug
16
- tslib_1.__exportStar(require("./lib/utils/loader"), exports); // Loader
17
- // Icons
18
- var CollapseIcon_1 = require("./lib/icon/CollapseIcon");
19
- Object.defineProperty(exports, "CollapseIcon", { enumerable: true, get: function () { return tslib_1.__importDefault(CollapseIcon_1).default; } });
20
- var ExpandIcon_1 = require("./lib/icon/ExpandIcon");
21
- Object.defineProperty(exports, "ExpandIcon", { enumerable: true, get: function () { return tslib_1.__importDefault(ExpandIcon_1).default; } });
22
- // MiniGames
23
- var MinigameDice_1 = require("./lib/minigame/dice/MinigameDice");
24
- Object.defineProperty(exports, "MinigameDice", { enumerable: true, get: function () { return tslib_1.__importDefault(MinigameDice_1).default; } });
25
- // Animations
26
- var TypewriterComponent_1 = require("./lib/animations/TypewriterComponent");
27
- Object.defineProperty(exports, "TypewriterComponent", { enumerable: true, get: function () { return tslib_1.__importDefault(TypewriterComponent_1).default; } });
28
- // Phaser
29
- tslib_1.__exportStar(require("./lib/phaser/player/playercontroller"), exports);
30
- // NPC
31
- tslib_1.__exportStar(require("./lib/phaser/npc/tooltipmenu"), exports);
32
- tslib_1.__exportStar(require("./lib/phaser/npc/chatbubble"), exports);
33
- tslib_1.__exportStar(require("./lib/phaser/npc/npchandler"), exports);
34
- tslib_1.__exportStar(require("./lib/phaser/npc/npcdatabase"), exports);
35
- // Monsters
36
- tslib_1.__exportStar(require("./lib/phaser/monster/bird"), exports);
37
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/laser/src/index.ts"],"names":[],"mappings":";AAAA,QAAQ;;;;AAER,kDAAwB;AAExB,YAAY;AACZ,0DAAgC;AAEhC,sDAA4B;AAC5B,yDAA+B;AAC/B,6DAAmC;AACnC,wDAA8B;AAE9B,QAAQ;AACR,2DAAiC,CAAC,OAAO;AACzC,4DAAkC,CAAC,QAAQ;AAC3C,6DAAmC,CAAC,SAAS;AAE7C,QAAQ;AACR,wDAAkE;AAAzD,qIAAA,OAAO,OAAgB;AAChC,oDAA8D;AAArD,iIAAA,OAAO,OAAc;AAE9B,YAAY;AACZ,iEAA2E;AAAlE,qIAAA,OAAO,OAAgB;AAEhC,aAAa;AACb,4EAAqF;AAA5E,mJAAA,OAAO,OAAuB;AAEvC,SAAS;AACT,+EAAqD;AAErD,MAAM;AACN,uEAA6C;AAC7C,sEAA4C;AAC5C,sEAA4C;AAC5C,uEAA6C;AAI7C,WAAW;AACX,oEAA0C"}
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- interface TypewriterComponentProps {
3
- text: string;
4
- speed?: number;
5
- onComplete?: () => void;
6
- }
7
- declare const _default: React.NamedExoticComponent<TypewriterComponentProps>;
8
- export default _default;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = tslib_1.__importStar(require("react"));
6
- const TypewriterComponent = ({ text, speed = 80, onComplete }) => {
7
- const [displayedText, setDisplayedText] = (0, react_1.useState)([]);
8
- const displayedTextRef = (0, react_1.useRef)([]);
9
- (0, react_1.useEffect)(() => {
10
- let timeoutId;
11
- let currentIndex = 0;
12
- const parts = text.split(/(<\/?span[^>]*>)/g).filter(Boolean);
13
- const characters = [];
14
- parts.forEach((part, index) => {
15
- if (part.startsWith('<span') || part.startsWith('</span')) {
16
- const tagMatch = part.match(/<span class="([^"]*)">/);
17
- if (tagMatch) {
18
- const className = tagMatch[1];
19
- characters.push((0, jsx_runtime_1.jsx)("span", { className: className }, `span-${index}`));
20
- }
21
- else {
22
- characters.push((0, jsx_runtime_1.jsx)("span", {}, `span-${index}`));
23
- }
24
- }
25
- else {
26
- part.split('').forEach((char, charIndex) => {
27
- characters.push((0, jsx_runtime_1.jsx)("span", { children: char }, `char-${index}-${charIndex}`));
28
- });
29
- }
30
- });
31
- currentIndex = 0;
32
- const typeNextCharacter = () => {
33
- if (currentIndex < characters.length) {
34
- displayedTextRef.current = [...displayedTextRef.current, characters[currentIndex]];
35
- setDisplayedText([...displayedTextRef.current]);
36
- currentIndex++;
37
- timeoutId = window.setTimeout(typeNextCharacter, speed);
38
- }
39
- else if (onComplete) {
40
- onComplete();
41
- }
42
- };
43
- displayedTextRef.current = [];
44
- setDisplayedText([]);
45
- typeNextCharacter();
46
- return () => {
47
- window.clearTimeout(timeoutId);
48
- };
49
- }, [text, speed, onComplete]);
50
- return (0, jsx_runtime_1.jsx)("div", { children: displayedText });
51
- };
52
- exports.default = react_1.default.memo(TypewriterComponent);
53
- //# sourceMappingURL=TypewriterComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TypewriterComponent.js","sourceRoot":"","sources":["../../../../../../packages/laser/src/lib/animations/TypewriterComponent.tsx"],"names":[],"mappings":";;;;AAAA,uDAA2D;AAQ3D,MAAM,mBAAmB,GAAuC,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IACnG,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAgB,EAAE,CAAC,CAAC;IACtE,MAAM,gBAAgB,GAAG,IAAA,cAAM,EAAgB,EAAE,CAAC,CAAC;IAEnD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,SAAiB,CAAC;QACtB,IAAI,YAAY,GAAG,CAAC,CAAC;QAErB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAkB,EAAE,CAAC;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC5B,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;gBACtD,IAAI,QAAQ,EAAE,CAAC;oBACb,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;oBAC9B,UAAU,CAAC,IAAI,CAAC,iCAA4B,SAAS,EAAE,SAAS,IAArC,QAAQ,KAAK,EAAE,CAA+B,CAAC,CAAC;gBAC7E,CAAC;qBAAM,CAAC;oBACN,UAAU,CAAC,IAAI,CAAC,mCAAW,QAAQ,KAAK,EAAE,CAAS,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;oBACzC,UAAU,CAAC,IAAI,CAAC,2CAA0C,IAAI,IAAnC,QAAQ,KAAK,IAAI,SAAS,EAAE,CAAe,CAAC,CAAC;gBAC1E,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,YAAY,GAAG,CAAC,CAAC;QAEjB,MAAM,iBAAiB,GAAG,GAAG,EAAE;YAC7B,IAAI,YAAY,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;gBACrC,gBAAgB,CAAC,OAAO,GAAG,CAAC,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;gBACnF,gBAAgB,CAAC,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;gBAChD,YAAY,EAAE,CAAC;gBACf,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;YAC1D,CAAC;iBAAM,IAAI,UAAU,EAAE,CAAC;gBACtB,UAAU,EAAE,CAAC;YACf,CAAC;QACH,CAAC,CAAC;QAEF,gBAAgB,CAAC,OAAO,GAAG,EAAE,CAAC;QAC9B,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACrB,iBAAiB,EAAE,CAAC;QAEpB,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;IAE9B,OAAO,0CAAM,aAAa,GAAO,CAAC;AACpC,CAAC,CAAC;AAEF,kBAAe,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const kbve_hcaptcha_site_key = "5ba581fa-b6fc-4bb0-8222-02fcd6a59e35";
2
- export declare const hcaptcha_api = "https://js.hcaptcha.com/1/api.js";
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hcaptcha_api = exports.kbve_hcaptcha_site_key = void 0;
4
- exports.kbve_hcaptcha_site_key = '5ba581fa-b6fc-4bb0-8222-02fcd6a59e35'; // 9-20-2023 Key
5
- exports.hcaptcha_api = 'https://js.hcaptcha.com/1/api.js';
6
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/laser/src/lib/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,sCAAsC,CAAC,CAAC,gBAAgB;AACjF,QAAA,YAAY,GAAG,kCAAkC,CAAC"}