@phalanx-engine/client 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 (94) hide show
  1. package/README.md +1037 -0
  2. package/dist/DesyncDetector.d.ts +80 -0
  3. package/dist/DesyncDetector.d.ts.map +1 -0
  4. package/dist/DesyncDetector.js +93 -0
  5. package/dist/DesyncDetector.js.map +1 -0
  6. package/dist/DeterministicRandom.d.ts +78 -0
  7. package/dist/DeterministicRandom.d.ts.map +1 -0
  8. package/dist/DeterministicRandom.js +122 -0
  9. package/dist/DeterministicRandom.js.map +1 -0
  10. package/dist/EventEmitter.d.ts +65 -0
  11. package/dist/EventEmitter.d.ts.map +1 -0
  12. package/dist/EventEmitter.js +102 -0
  13. package/dist/EventEmitter.js.map +1 -0
  14. package/dist/FixedMath.d.ts +22 -0
  15. package/dist/FixedMath.d.ts.map +1 -0
  16. package/dist/FixedMath.js +26 -0
  17. package/dist/FixedMath.js.map +1 -0
  18. package/dist/PhalanxClient.d.ts +335 -0
  19. package/dist/PhalanxClient.d.ts.map +1 -0
  20. package/dist/PhalanxClient.js +844 -0
  21. package/dist/PhalanxClient.js.map +1 -0
  22. package/dist/RenderLoop.d.ts +95 -0
  23. package/dist/RenderLoop.d.ts.map +1 -0
  24. package/dist/RenderLoop.js +192 -0
  25. package/dist/RenderLoop.js.map +1 -0
  26. package/dist/SocketManager.d.ts +228 -0
  27. package/dist/SocketManager.d.ts.map +1 -0
  28. package/dist/SocketManager.js +584 -0
  29. package/dist/SocketManager.js.map +1 -0
  30. package/dist/StateHasher.d.ts +76 -0
  31. package/dist/StateHasher.d.ts.map +1 -0
  32. package/dist/StateHasher.js +129 -0
  33. package/dist/StateHasher.js.map +1 -0
  34. package/dist/auth/AuthManager.d.ts +188 -0
  35. package/dist/auth/AuthManager.d.ts.map +1 -0
  36. package/dist/auth/AuthManager.js +462 -0
  37. package/dist/auth/AuthManager.js.map +1 -0
  38. package/dist/auth/adapters/GoogleOAuthAdapter.d.ts +164 -0
  39. package/dist/auth/adapters/GoogleOAuthAdapter.d.ts.map +1 -0
  40. package/dist/auth/adapters/GoogleOAuthAdapter.js +521 -0
  41. package/dist/auth/adapters/GoogleOAuthAdapter.js.map +1 -0
  42. package/dist/auth/index.d.ts +45 -0
  43. package/dist/auth/index.d.ts.map +1 -0
  44. package/dist/auth/index.js +54 -0
  45. package/dist/auth/index.js.map +1 -0
  46. package/dist/auth/storage.d.ts +56 -0
  47. package/dist/auth/storage.d.ts.map +1 -0
  48. package/dist/auth/storage.js +78 -0
  49. package/dist/auth/storage.js.map +1 -0
  50. package/dist/auth/types.d.ts +212 -0
  51. package/dist/auth/types.d.ts.map +1 -0
  52. package/dist/auth/types.js +7 -0
  53. package/dist/auth/types.js.map +1 -0
  54. package/dist/index.d.ts +70 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +83 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/recovery/BrowserLifecycle.d.ts +33 -0
  59. package/dist/recovery/BrowserLifecycle.d.ts.map +1 -0
  60. package/dist/recovery/BrowserLifecycle.js +62 -0
  61. package/dist/recovery/BrowserLifecycle.js.map +1 -0
  62. package/dist/recovery/GuestPlayerIdStore.d.ts +17 -0
  63. package/dist/recovery/GuestPlayerIdStore.d.ts.map +1 -0
  64. package/dist/recovery/GuestPlayerIdStore.js +31 -0
  65. package/dist/recovery/GuestPlayerIdStore.js.map +1 -0
  66. package/dist/recovery/KeyValueStorage.d.ts +32 -0
  67. package/dist/recovery/KeyValueStorage.d.ts.map +1 -0
  68. package/dist/recovery/KeyValueStorage.js +58 -0
  69. package/dist/recovery/KeyValueStorage.js.map +1 -0
  70. package/dist/recovery/MobileTransport.d.ts +12 -0
  71. package/dist/recovery/MobileTransport.d.ts.map +1 -0
  72. package/dist/recovery/MobileTransport.js +24 -0
  73. package/dist/recovery/MobileTransport.js.map +1 -0
  74. package/dist/recovery/NetworkQuality.d.ts +22 -0
  75. package/dist/recovery/NetworkQuality.d.ts.map +1 -0
  76. package/dist/recovery/NetworkQuality.js +35 -0
  77. package/dist/recovery/NetworkQuality.js.map +1 -0
  78. package/dist/recovery/RoomPersistence.d.ts +55 -0
  79. package/dist/recovery/RoomPersistence.d.ts.map +1 -0
  80. package/dist/recovery/RoomPersistence.js +68 -0
  81. package/dist/recovery/RoomPersistence.js.map +1 -0
  82. package/dist/recovery/RoomRecoveryController.d.ts +146 -0
  83. package/dist/recovery/RoomRecoveryController.d.ts.map +1 -0
  84. package/dist/recovery/RoomRecoveryController.js +348 -0
  85. package/dist/recovery/RoomRecoveryController.js.map +1 -0
  86. package/dist/recovery/index.d.ts +13 -0
  87. package/dist/recovery/index.d.ts.map +1 -0
  88. package/dist/recovery/index.js +8 -0
  89. package/dist/recovery/index.js.map +1 -0
  90. package/dist/types.d.ts +501 -0
  91. package/dist/types.d.ts.map +1 -0
  92. package/dist/types.js +6 -0
  93. package/dist/types.js.map +1 -0
  94. package/package.json +66 -0
@@ -0,0 +1,501 @@
1
+ /**
2
+ * Phalanx Client Types
3
+ * Types for the client-side library
4
+ */
5
+ import type { DesyncEvent } from './DesyncDetector.js';
6
+ import type { RoomRecoveryStatusEvent, RoomTerminatedEvent } from './recovery/RoomRecoveryController.js';
7
+ import type { KeyValueStorage } from './recovery/KeyValueStorage.js';
8
+ import type { RecoverTimeoutBudget } from './recovery/NetworkQuality.js';
9
+ export type { DesyncEvent };
10
+ export type { RoomRecoveryStatusEvent, RoomTerminatedEvent } from './recovery/RoomRecoveryController.js';
11
+ /**
12
+ * Configuration for pause/resume behavior
13
+ */
14
+ export interface PauseConfig {
15
+ /**
16
+ * Maximum number of pauses allowed per player.
17
+ * Set to Infinity for unlimited pauses.
18
+ * @default Infinity
19
+ */
20
+ maxPausesPerPlayer: number;
21
+ /**
22
+ * Whether the game can only be resumed by the same player who paused it.
23
+ * If false, any player can resume the game.
24
+ * @default false
25
+ */
26
+ requireSamePlayerToResume: boolean;
27
+ }
28
+ /** Socket.IO transport names supported by PhalanxClient. */
29
+ export type SocketTransport = 'polling' | 'websocket';
30
+ /**
31
+ * Configuration for the Phalanx client
32
+ */
33
+ export interface PhalanxClientConfig {
34
+ /**
35
+ * URL of the Phalanx server (e.g., 'http://localhost:3000')
36
+ */
37
+ serverUrl: string;
38
+ /**
39
+ * Unique identifier for this player.
40
+ * If auth is enabled and user signs in, this will be overwritten with the auth user ID.
41
+ */
42
+ playerId?: string;
43
+ /**
44
+ * Display name for this player.
45
+ * If auth is enabled and user signs in, this will be overwritten with the auth username.
46
+ */
47
+ username?: string;
48
+ /**
49
+ * Authentication token (e.g., Google ID token).
50
+ * Required if server has authentication enabled.
51
+ * If using built-in auth, this is managed automatically.
52
+ */
53
+ authToken?: string;
54
+ /**
55
+ * Authentication configuration.
56
+ * If provided, the client will manage authentication internally.
57
+ */
58
+ auth?: PhalanxAuthConfig;
59
+ /**
60
+ * Whether to automatically attempt reconnection after disconnection
61
+ * @default true
62
+ */
63
+ autoReconnect?: boolean;
64
+ /**
65
+ * Maximum number of reconnection attempts
66
+ * @default 5
67
+ */
68
+ maxReconnectAttempts?: number;
69
+ /**
70
+ * Delay between reconnection attempts in milliseconds
71
+ * @default 1000
72
+ */
73
+ reconnectDelayMs?: number;
74
+ /**
75
+ * Connection timeout in milliseconds
76
+ * @default 10000
77
+ */
78
+ connectionTimeoutMs?: number;
79
+ /**
80
+ * Timeout for private-room recovery acknowledgements in milliseconds.
81
+ * @default 10000
82
+ */
83
+ recoverRoomTimeoutMs?: number;
84
+ /**
85
+ * Socket.IO transports to use when connecting.
86
+ * Defaults to WebSocket-only for existing desktop behavior. Mobile
87
+ * clients can pass ['polling', 'websocket'] for a more resilient fallback.
88
+ * @default ['websocket']
89
+ */
90
+ socketTransports?: readonly SocketTransport[];
91
+ /**
92
+ * If true, automatically pick `['polling']` on mobile UAs and
93
+ * `['websocket']` on desktop. Ignored when `socketTransports` is
94
+ * also set explicitly. Opt-in to avoid silently regressing games
95
+ * that intentionally pin a specific transport.
96
+ * @default false
97
+ */
98
+ mobileFriendlyTransports?: boolean;
99
+ /**
100
+ * Persist a stable guest playerId across page reloads so private-room
101
+ * recovery can survive a hard reload. When `true`, uses the default
102
+ * key `phalanx:guestPlayerId:v1`. When a string, uses that as the key.
103
+ * Authenticated users override this with the auth user id, so this is
104
+ * primarily a guest-mode quality-of-life flag.
105
+ * @default false
106
+ */
107
+ persistGuestPlayerId?: boolean | string;
108
+ /**
109
+ * Configure mobile-friendly room recovery (visibilitychange/pageshow
110
+ * listeners, exponential backoff, room persistence, pre-game stall
111
+ * watchdog). When omitted recovery is disabled and the controller is
112
+ * not constructed.
113
+ */
114
+ roomRecovery?: PhalanxRoomRecoveryConfig;
115
+ /**
116
+ * Tick rate (ticks per second) - should match server configuration
117
+ * @default 20
118
+ */
119
+ tickRate?: number;
120
+ /**
121
+ * Pause/resume behavior configuration.
122
+ * Should match server configuration for proper validation.
123
+ */
124
+ pause?: Partial<PauseConfig>;
125
+ /**
126
+ * Enable debug logging
127
+ * @default false
128
+ */
129
+ debug?: boolean;
130
+ }
131
+ /**
132
+ * Configuration for the optional mobile-friendly room recovery layer.
133
+ * See `RoomRecoveryController` for behavior. Leave unset to disable.
134
+ */
135
+ export interface PhalanxRoomRecoveryConfig {
136
+ /** Master enable flag. When false the controller is not created. */
137
+ enabled: boolean;
138
+ /**
139
+ * localStorage key for the persisted active-room record.
140
+ * @default 'phalanx:activeRoom:v1'
141
+ */
142
+ storageKey?: string;
143
+ /**
144
+ * Local TTL mirroring the server's RoomService.ROOM_TTL_MS.
145
+ * @default 5 * 60 * 1000
146
+ */
147
+ roomTtlMs?: number;
148
+ /**
149
+ * Storage adapter. Defaults to `localStorage` (with a memory fallback
150
+ * when the DOM is unavailable). React Native / Capacitor host apps can
151
+ * supply a custom synchronous wrapper around their native storage.
152
+ */
153
+ storage?: KeyValueStorage;
154
+ /** Per-quality recover-room ack timeout budget. */
155
+ recoverTimeoutBudget?: RecoverTimeoutBudget;
156
+ /** Max backoff retries before emitting `gave-up`. @default 5 */
157
+ maxRecoverAttempts?: number;
158
+ /** Auto-arm the pre-game stall watchdog. @default true */
159
+ preGameStallWatchdog?: boolean;
160
+ /** Pre-game stall budget in ms. @default 4500 */
161
+ preGameStallMs?: number;
162
+ }
163
+ /**
164
+ * Authentication configuration for PhalanxClient
165
+ */
166
+ export interface PhalanxAuthConfig {
167
+ /**
168
+ * OAuth provider to use
169
+ */
170
+ provider: 'google';
171
+ /**
172
+ * Google OAuth configuration
173
+ */
174
+ google?: {
175
+ /**
176
+ * Google OAuth Client ID
177
+ */
178
+ clientId: string;
179
+ /**
180
+ * OAuth scopes (default: ['openid', 'profile', 'email'])
181
+ */
182
+ scopes?: string[];
183
+ /**
184
+ * Redirect URI after auth (default: window.location.origin)
185
+ */
186
+ redirectUri?: string;
187
+ /**
188
+ * Backend endpoint URL for token exchange.
189
+ * Required for secure token exchange with client_secret on server.
190
+ */
191
+ tokenExchangeUrl?: string;
192
+ };
193
+ }
194
+ /**
195
+ * A command sent from or to players
196
+ * When received from server, includes playerId and tick added by server
197
+ */
198
+ export interface PlayerCommand {
199
+ type: string;
200
+ data: unknown;
201
+ /** Added by server when broadcasting - identifies the player who sent the command */
202
+ playerId?: string;
203
+ /** Added by server when broadcasting - the tick this command was submitted for */
204
+ tick?: number;
205
+ }
206
+ /**
207
+ * Information about a player in match-found event
208
+ */
209
+ export interface MatchPlayerInfo {
210
+ playerId: string;
211
+ username: string;
212
+ }
213
+ /**
214
+ * Event received when a match is found
215
+ */
216
+ export interface MatchFoundEvent {
217
+ matchId: string;
218
+ playerId: string;
219
+ teamId: number;
220
+ teammates: MatchPlayerInfo[];
221
+ opponents: MatchPlayerInfo[];
222
+ }
223
+ /**
224
+ * Event received during countdown before game starts
225
+ */
226
+ export interface CountdownEvent {
227
+ seconds: number;
228
+ }
229
+ /**
230
+ * Event received when the game starts
231
+ */
232
+ export interface GameStartEvent {
233
+ matchId: string;
234
+ /** Random seed for deterministic RNG (optional for backward compatibility) */
235
+ randomSeed?: number;
236
+ }
237
+ /**
238
+ * Event received on each tick for synchronization
239
+ */
240
+ export interface TickSyncEvent {
241
+ tick: number;
242
+ timestamp: number;
243
+ }
244
+ /**
245
+ * Commands batch received each tick from the server
246
+ */
247
+ export interface CommandsBatchEvent {
248
+ tick: number;
249
+ commands: PlayerCommand[];
250
+ }
251
+ /**
252
+ * Queue status event received after joining queue
253
+ */
254
+ export interface QueueStatusEvent {
255
+ position: number;
256
+ waitTime: number;
257
+ }
258
+ /**
259
+ * Event received when another player disconnects
260
+ */
261
+ export interface PlayerDisconnectedEvent {
262
+ playerId: string;
263
+ gracePeriodMs: number;
264
+ }
265
+ /**
266
+ * Event received when another player reconnects
267
+ */
268
+ export interface PlayerReconnectedEvent {
269
+ playerId: string;
270
+ }
271
+ /**
272
+ * Event received when a player reports ready during the loading phase
273
+ */
274
+ export interface PlayerReadyEvent {
275
+ playerId: string;
276
+ }
277
+ /**
278
+ * State received when reconnecting to a match.
279
+ *
280
+ * Includes a snapshot of the countdown / game-start phase so a client
281
+ * that reconnected mid-countdown (e.g. a private-room host whose mobile
282
+ * browser killed the WebSocket while they were sharing the invite link)
283
+ * can render the correct remaining number without waiting for the next
284
+ * 1Hz broadcast tick, and so a client that reconnected after `game-start`
285
+ * already fired can synthesize the event locally and enter the playing
286
+ * phase without waiting for an event it will never receive again.
287
+ *
288
+ * The countdown/gameStart fields are optional for wire-compatibility
289
+ * with older servers that don't populate them.
290
+ */
291
+ export interface ReconnectStateEvent {
292
+ matchId: string;
293
+ currentTick: number;
294
+ state: 'countdown' | 'waiting-for-ready' | 'playing' | 'paused' | 'finished';
295
+ recentCommands: TickCommandsHistory[];
296
+ /**
297
+ * Integer number of seconds left on the countdown at the moment this
298
+ * snapshot was taken, or `null` if the countdown is no longer running
299
+ * (either it never started with a positive duration, or `game-start`
300
+ * has already been emitted).
301
+ */
302
+ countdownSecondsRemaining?: number | null;
303
+ /**
304
+ * True if `game-start` has already been broadcast for this match.
305
+ * Clients should treat this as a signal to synthesize a local
306
+ * `game-start` event rather than waiting for the server to emit one.
307
+ */
308
+ gameStartEmitted?: boolean;
309
+ /**
310
+ * The match's deterministic RNG seed. Forwarded here so clients that
311
+ * missed the original `game-start` broadcast can still feed the seed
312
+ * into their deterministic simulation on the synthesized start.
313
+ */
314
+ randomSeed?: number;
315
+ }
316
+ /**
317
+ * Commands history for a specific tick (used in reconnection)
318
+ */
319
+ export interface TickCommandsHistory {
320
+ tick: number;
321
+ commands: PlayerCommand[];
322
+ }
323
+ /**
324
+ * Reconnection status response
325
+ */
326
+ export interface ReconnectStatusEvent {
327
+ success: boolean;
328
+ reason?: string;
329
+ }
330
+ /**
331
+ * Acknowledgment for submitted commands
332
+ */
333
+ export interface SubmitCommandsAck {
334
+ accepted: boolean;
335
+ reason?: string;
336
+ }
337
+ /**
338
+ * Event received when match ends
339
+ */
340
+ export interface MatchEndEvent {
341
+ reason: string;
342
+ /** Additional details about the match end (e.g., desync info) */
343
+ details?: unknown;
344
+ /** Winner information (null on desync) */
345
+ winner?: string | null;
346
+ }
347
+ /**
348
+ * Event received when the game is paused
349
+ */
350
+ export interface GamePausedEvent {
351
+ requestedBy: string;
352
+ lastTick: number;
353
+ }
354
+ /**
355
+ * Event received when the game is resumed
356
+ */
357
+ export interface GameResumedEvent {
358
+ requestedBy: string;
359
+ }
360
+ /**
361
+ * Hash comparison data received from server
362
+ */
363
+ export interface HashComparisonEvent {
364
+ tick: number;
365
+ hashes: Record<string, string>;
366
+ }
367
+ /**
368
+ * Error event from the server
369
+ */
370
+ export interface PhalanxError {
371
+ message: string;
372
+ code?: string;
373
+ }
374
+ /**
375
+ * Connection state of the client
376
+ */
377
+ export type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
378
+ /**
379
+ * Client state (overall lifecycle)
380
+ */
381
+ export type ClientState = 'idle' | 'in-queue' | 'match-found' | 'countdown' | 'playing' | 'paused' | 'reconnecting' | 'finished';
382
+ /**
383
+ * Commands grouped by player ID (for easier processing in game logic)
384
+ */
385
+ export interface CommandsBatch {
386
+ tick: number;
387
+ commands: {
388
+ [playerId: string]: PlayerCommand[];
389
+ };
390
+ }
391
+ /**
392
+ * Tick handler callback type
393
+ */
394
+ export type TickHandler = (tick: number, commands: CommandsBatch) => void;
395
+ /**
396
+ * Frame handler callback type
397
+ */
398
+ export type FrameHandler = (alpha: number, dt: number) => void;
399
+ /**
400
+ * Unsubscribe function type
401
+ */
402
+ export type Unsubscribe = () => void;
403
+ /**
404
+ * Pause/Resume handler callback type
405
+ */
406
+ export type PauseHandler = () => void;
407
+ /**
408
+ * Auth user information
409
+ */
410
+ export interface PhalanxAuthUser {
411
+ id: string;
412
+ username?: string;
413
+ email?: string;
414
+ avatarUrl?: string;
415
+ provider: string;
416
+ }
417
+ /**
418
+ * Auth state
419
+ */
420
+ export interface PhalanxAuthState {
421
+ isAuthenticated: boolean;
422
+ isLoading: boolean;
423
+ user: PhalanxAuthUser | null;
424
+ error?: string;
425
+ }
426
+ /**
427
+ * Events emitted by PhalanxClient
428
+ */
429
+ export interface PhalanxClientEvents {
430
+ connected: () => void;
431
+ disconnected: () => void;
432
+ reconnecting: (attempt: number) => void;
433
+ reconnectFailed: () => void;
434
+ error: (error: PhalanxError) => void;
435
+ authStateChanged: (state: PhalanxAuthState) => void;
436
+ authError: (error: PhalanxError) => void;
437
+ queueJoined: (status: QueueStatusEvent) => void;
438
+ queueLeft: () => void;
439
+ queueError: (error: PhalanxError) => void;
440
+ matchFound: (event: MatchFoundEvent) => void;
441
+ countdown: (event: CountdownEvent) => void;
442
+ gameStart: (event: GameStartEvent) => void;
443
+ matchEnd: (event: MatchEndEvent) => void;
444
+ gamePaused: (event: GamePausedEvent) => void;
445
+ gameResumed: (event: GameResumedEvent) => void;
446
+ tick: (event: TickSyncEvent) => void;
447
+ commands: (event: CommandsBatchEvent) => void;
448
+ playerDisconnected: (event: PlayerDisconnectedEvent) => void;
449
+ playerReconnected: (event: PlayerReconnectedEvent) => void;
450
+ playerReady: (event: PlayerReadyEvent) => void;
451
+ reconnectState: (event: ReconnectStateEvent) => void;
452
+ reconnectStatus: (event: ReconnectStatusEvent) => void;
453
+ desync: (event: DesyncEvent) => void;
454
+ roomCreated: (event: RoomCreatedEvent) => void;
455
+ roomError: (event: RoomErrorEvent) => void;
456
+ roomExpired: (event: RoomExpiredEvent) => void;
457
+ roomCancelled: (event: RoomCancelledEvent) => void;
458
+ roomRecovered: (event: RoomRecoveredEvent) => void;
459
+ recoveryStatus: (event: RoomRecoveryStatusEvent) => void;
460
+ roomTerminated: (event: RoomTerminatedEvent) => void;
461
+ }
462
+ /**
463
+ * Event emitted when a private room is created.
464
+ */
465
+ export interface RoomCreatedEvent {
466
+ code: string;
467
+ }
468
+ /**
469
+ * Event emitted when a room operation fails.
470
+ */
471
+ export interface RoomErrorEvent {
472
+ message: string;
473
+ }
474
+ /**
475
+ * Event emitted when a room expires (TTL exceeded).
476
+ */
477
+ export interface RoomExpiredEvent {
478
+ code: string;
479
+ }
480
+ /**
481
+ * Event emitted when a room is cancelled.
482
+ */
483
+ export interface RoomCancelledEvent {
484
+ code: string;
485
+ }
486
+ /**
487
+ * Event emitted when a host successfully reclaims a private room after a
488
+ * transient socket disconnect (e.g. mobile browser killing the WebSocket
489
+ * when the user switches to a messenger to share the invite link).
490
+ *
491
+ * The returned `code` is the canonical server-side value — callers should
492
+ * prefer it over whatever they passed into `recoverRoom`. In practice
493
+ * this differs from the caller's input only in casing: the server
494
+ * uppercases the provided code and rejects anything else with
495
+ * `room-error: "Room expired"`. Echoing the stored code lets callers
496
+ * update any cached value that drifted in case only.
497
+ */
498
+ export interface RoomRecoveredEvent {
499
+ code: string;
500
+ }
501
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KA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,EAAE,WAAW,KAAK,IAAI,CAAC;IAGrC,WAAW,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC/C,SAAS,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,WAAW,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC/C,aAAa,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnD,aAAa,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAGnD,cAAc,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;IACzD,cAAc,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACtD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;CACd"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Phalanx Client Types
3
+ * Types for the client-side library
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@phalanx-engine/client",
3
+ "version": "0.1.0",
4
+ "description": "Client library for Phalanx Engine - a game-agnostic deterministic lockstep multiplayer engine",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./auth": {
14
+ "types": "./dist/auth/index.d.ts",
15
+ "import": "./dist/auth/index.js"
16
+ }
17
+ },
18
+ "keywords": [
19
+ "multiplayer",
20
+ "game-client",
21
+ "lockstep",
22
+ "deterministic",
23
+ "netcode",
24
+ "socket.io-client",
25
+ "phalanx",
26
+ "game-engine"
27
+ ],
28
+ "author": "",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/phaeton-forge/phalanx-engine.git",
33
+ "directory": "phalanx-client"
34
+ },
35
+ "bugs": "https://github.com/phaeton-forge/phalanx-engine/issues",
36
+ "homepage": "https://github.com/phaeton-forge/phalanx-engine/tree/main/phalanx-client#readme",
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "engines": {
41
+ "node": ">=24.0.0 <25.0.0"
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "README.md"
46
+ ],
47
+ "dependencies": {
48
+ "pure-rand": "^7.0.1",
49
+ "socket.io-client": "^4.7.0",
50
+ "@phalanx-engine/math": "0.1.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^20.0.0",
54
+ "rimraf": "^5.0.0",
55
+ "typescript": "^5.3.0",
56
+ "vitest": "^1.0.0",
57
+ "@phalanx-engine/server": "0.1.0"
58
+ },
59
+ "scripts": {
60
+ "build": "tsc",
61
+ "dev": "tsc --watch",
62
+ "clean": "rimraf dist",
63
+ "test": "vitest run",
64
+ "test:watch": "vitest"
65
+ }
66
+ }