@phalanx-engine/server 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.
- package/README.md +507 -0
- package/dist/Phalanx.d.ts +85 -0
- package/dist/Phalanx.d.ts.map +1 -0
- package/dist/Phalanx.js +600 -0
- package/dist/Phalanx.js.map +1 -0
- package/dist/config/defaults.d.ts +10 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +51 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/validation.d.ts +15 -0
- package/dist/config/validation.d.ts.map +1 -0
- package/dist/config/validation.js +74 -0
- package/dist/config/validation.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/services/GameRoom.d.ts +359 -0
- package/dist/services/GameRoom.d.ts.map +1 -0
- package/dist/services/GameRoom.js +1272 -0
- package/dist/services/GameRoom.js.map +1 -0
- package/dist/services/MatchmakingService.d.ts +102 -0
- package/dist/services/MatchmakingService.d.ts.map +1 -0
- package/dist/services/MatchmakingService.js +286 -0
- package/dist/services/MatchmakingService.js.map +1 -0
- package/dist/services/OAuthExchangeService.d.ts +49 -0
- package/dist/services/OAuthExchangeService.d.ts.map +1 -0
- package/dist/services/OAuthExchangeService.js +96 -0
- package/dist/services/OAuthExchangeService.js.map +1 -0
- package/dist/services/PrivateRoomService.d.ts +136 -0
- package/dist/services/PrivateRoomService.d.ts.map +1 -0
- package/dist/services/PrivateRoomService.js +395 -0
- package/dist/services/PrivateRoomService.js.map +1 -0
- package/dist/services/TokenValidator.d.ts +60 -0
- package/dist/services/TokenValidator.d.ts.map +1 -0
- package/dist/services/TokenValidator.js +213 -0
- package/dist/services/TokenValidator.js.map +1 -0
- package/dist/types/index.d.ts +390 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/DeterministicRandom.d.ts +88 -0
- package/dist/utils/DeterministicRandom.d.ts.map +1 -0
- package/dist/utils/DeterministicRandom.js +140 -0
- package/dist/utils/DeterministicRandom.js.map +1 -0
- package/dist/utils/FixedMath.d.ts +22 -0
- package/dist/utils/FixedMath.d.ts.map +1 -0
- package/dist/utils/FixedMath.js +26 -0
- package/dist/utils/FixedMath.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import prand from 'pure-rand';
|
|
2
|
+
/**
|
|
3
|
+
* Deterministic Random Number Generator
|
|
4
|
+
*
|
|
5
|
+
* Wrapper around pure-rand library for deterministic pseudo-random number generation.
|
|
6
|
+
* All clients initialized with the same seed will produce identical sequences.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const rng = new DeterministicRandom(12345);
|
|
11
|
+
* const damage = rng.intRange(10, 20); // Same on all clients with same seed
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class DeterministicRandom {
|
|
15
|
+
private rng;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new deterministic RNG with the given seed
|
|
18
|
+
* @param seed - A number seed value
|
|
19
|
+
*/
|
|
20
|
+
constructor(seed: number);
|
|
21
|
+
/**
|
|
22
|
+
* Generate next random 32-bit integer and advance state
|
|
23
|
+
*/
|
|
24
|
+
private nextInt;
|
|
25
|
+
/**
|
|
26
|
+
* Get next random float in range [0, 1)
|
|
27
|
+
*/
|
|
28
|
+
float(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Get next random float in range [min, max)
|
|
31
|
+
* @param min - Minimum value (inclusive)
|
|
32
|
+
* @param max - Maximum value (exclusive)
|
|
33
|
+
*/
|
|
34
|
+
floatRange(min: number, max: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* Get next random integer in range [min, max]
|
|
37
|
+
* @param min - Minimum value (inclusive)
|
|
38
|
+
* @param max - Maximum value (inclusive)
|
|
39
|
+
*/
|
|
40
|
+
intRange(min: number, max: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* Get next random integer in range [0, max)
|
|
43
|
+
* @param max - Maximum value (exclusive)
|
|
44
|
+
*/
|
|
45
|
+
int(max: number): number;
|
|
46
|
+
/**
|
|
47
|
+
* Get next random boolean
|
|
48
|
+
* @param probability - Probability of true (default 0.5)
|
|
49
|
+
*/
|
|
50
|
+
boolean(probability?: number): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Get a random element from an array
|
|
53
|
+
* @param array - Array to pick from
|
|
54
|
+
*/
|
|
55
|
+
pick<T>(array: readonly T[]): T;
|
|
56
|
+
/**
|
|
57
|
+
* Shuffle an array in place using Fisher-Yates algorithm
|
|
58
|
+
* @param array - Array to shuffle
|
|
59
|
+
* @returns The same array, shuffled
|
|
60
|
+
*/
|
|
61
|
+
shuffle<T>(array: T[]): T[];
|
|
62
|
+
/**
|
|
63
|
+
* Create a fork of this RNG with independent state
|
|
64
|
+
* Useful for parallel simulations that need separate random streams
|
|
65
|
+
*/
|
|
66
|
+
fork(): DeterministicRandom;
|
|
67
|
+
/**
|
|
68
|
+
* Get current generator for serialization
|
|
69
|
+
* Note: pure-rand generators are immutable, so this returns a copy
|
|
70
|
+
*/
|
|
71
|
+
getGenerator(): prand.RandomGenerator;
|
|
72
|
+
/**
|
|
73
|
+
* Set generator from previously saved state
|
|
74
|
+
* @param generator - Previously saved generator
|
|
75
|
+
*/
|
|
76
|
+
setGenerator(generator: prand.RandomGenerator): void;
|
|
77
|
+
/**
|
|
78
|
+
* Generate a random seed (for server use)
|
|
79
|
+
* Uses crypto module for secure random seed generation
|
|
80
|
+
*/
|
|
81
|
+
static generateSeed(): number;
|
|
82
|
+
/**
|
|
83
|
+
* Create RNG from a bigint seed (for compatibility with previous API)
|
|
84
|
+
* @param seed - A bigint to use as seed
|
|
85
|
+
*/
|
|
86
|
+
static fromBigInt(seed: bigint): DeterministicRandom;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=DeterministicRandom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeterministicRandom.d.ts","sourceRoot":"","sources":["../../src/utils/DeterministicRandom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,WAAW,CAAC;AAE9B;;;;;;;;;;;GAWG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,GAAG,CAAwB;IAEnC;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAKxB;;OAEG;IACH,OAAO,CAAC,OAAO;IAMf;;OAEG;IACH,KAAK,IAAI,MAAM;IAMf;;;;OAIG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAI5C;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAQ1C;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIxB;;;OAGG;IACH,OAAO,CAAC,WAAW,GAAE,MAAY,GAAG,OAAO;IAI3C;;;OAGG;IACH,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC;IAO/B;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;IAU3B;;;OAGG;IACH,IAAI,IAAI,mBAAmB;IAM3B;;;OAGG;IACH,YAAY,IAAI,KAAK,CAAC,eAAe;IAIrC;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,eAAe,GAAG,IAAI;IAIpD;;;OAGG;IACH,MAAM,CAAC,YAAY,IAAI,MAAM;IAO7B;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB;CAIrD"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import prand from 'pure-rand';
|
|
2
|
+
/**
|
|
3
|
+
* Deterministic Random Number Generator
|
|
4
|
+
*
|
|
5
|
+
* Wrapper around pure-rand library for deterministic pseudo-random number generation.
|
|
6
|
+
* All clients initialized with the same seed will produce identical sequences.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const rng = new DeterministicRandom(12345);
|
|
11
|
+
* const damage = rng.intRange(10, 20); // Same on all clients with same seed
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export class DeterministicRandom {
|
|
15
|
+
rng;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new deterministic RNG with the given seed
|
|
18
|
+
* @param seed - A number seed value
|
|
19
|
+
*/
|
|
20
|
+
constructor(seed) {
|
|
21
|
+
// Use xoroshiro128+ algorithm - fast and high quality
|
|
22
|
+
this.rng = prand.xoroshiro128plus(seed);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Generate next random 32-bit integer and advance state
|
|
26
|
+
*/
|
|
27
|
+
nextInt() {
|
|
28
|
+
const [value, next] = this.rng.next();
|
|
29
|
+
this.rng = next;
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get next random float in range [0, 1)
|
|
34
|
+
*/
|
|
35
|
+
float() {
|
|
36
|
+
// Use unsigned 32-bit integer for conversion
|
|
37
|
+
const value = this.nextInt() >>> 0;
|
|
38
|
+
return value / 0x100000000;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get next random float in range [min, max)
|
|
42
|
+
* @param min - Minimum value (inclusive)
|
|
43
|
+
* @param max - Maximum value (exclusive)
|
|
44
|
+
*/
|
|
45
|
+
floatRange(min, max) {
|
|
46
|
+
return min + this.float() * (max - min);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get next random integer in range [min, max]
|
|
50
|
+
* @param min - Minimum value (inclusive)
|
|
51
|
+
* @param max - Maximum value (inclusive)
|
|
52
|
+
*/
|
|
53
|
+
intRange(min, max) {
|
|
54
|
+
min = Math.floor(min);
|
|
55
|
+
max = Math.floor(max);
|
|
56
|
+
const [value, next] = prand.uniformIntDistribution(min, max)(this.rng);
|
|
57
|
+
this.rng = next;
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get next random integer in range [0, max)
|
|
62
|
+
* @param max - Maximum value (exclusive)
|
|
63
|
+
*/
|
|
64
|
+
int(max) {
|
|
65
|
+
return this.intRange(0, max - 1);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get next random boolean
|
|
69
|
+
* @param probability - Probability of true (default 0.5)
|
|
70
|
+
*/
|
|
71
|
+
boolean(probability = 0.5) {
|
|
72
|
+
return this.float() < probability;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get a random element from an array
|
|
76
|
+
* @param array - Array to pick from
|
|
77
|
+
*/
|
|
78
|
+
pick(array) {
|
|
79
|
+
if (array.length === 0) {
|
|
80
|
+
throw new Error('Cannot pick from empty array');
|
|
81
|
+
}
|
|
82
|
+
return array[this.intRange(0, array.length - 1)];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Shuffle an array in place using Fisher-Yates algorithm
|
|
86
|
+
* @param array - Array to shuffle
|
|
87
|
+
* @returns The same array, shuffled
|
|
88
|
+
*/
|
|
89
|
+
shuffle(array) {
|
|
90
|
+
for (let i = array.length - 1; i > 0; i--) {
|
|
91
|
+
const j = this.intRange(0, i);
|
|
92
|
+
const temp = array[i];
|
|
93
|
+
array[i] = array[j];
|
|
94
|
+
array[j] = temp;
|
|
95
|
+
}
|
|
96
|
+
return array;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create a fork of this RNG with independent state
|
|
100
|
+
* Useful for parallel simulations that need separate random streams
|
|
101
|
+
*/
|
|
102
|
+
fork() {
|
|
103
|
+
// Generate a new seed from current state
|
|
104
|
+
const newSeed = this.nextInt();
|
|
105
|
+
return new DeterministicRandom(newSeed >>> 0);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get current generator for serialization
|
|
109
|
+
* Note: pure-rand generators are immutable, so this returns a copy
|
|
110
|
+
*/
|
|
111
|
+
getGenerator() {
|
|
112
|
+
return this.rng;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Set generator from previously saved state
|
|
116
|
+
* @param generator - Previously saved generator
|
|
117
|
+
*/
|
|
118
|
+
setGenerator(generator) {
|
|
119
|
+
this.rng = generator;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Generate a random seed (for server use)
|
|
123
|
+
* Uses crypto module for secure random seed generation
|
|
124
|
+
*/
|
|
125
|
+
static generateSeed() {
|
|
126
|
+
// Use dynamic import to avoid issues in environments without crypto
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
128
|
+
const crypto = require('crypto');
|
|
129
|
+
return crypto.randomBytes(4).readUInt32BE();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Create RNG from a bigint seed (for compatibility with previous API)
|
|
133
|
+
* @param seed - A bigint to use as seed
|
|
134
|
+
*/
|
|
135
|
+
static fromBigInt(seed) {
|
|
136
|
+
// Use lower 32 bits of the bigint
|
|
137
|
+
return new DeterministicRandom(Number(BigInt.asUintN(32, seed)));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=DeterministicRandom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeterministicRandom.js","sourceRoot":"","sources":["../../src/utils/DeterministicRandom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,WAAW,CAAC;AAE9B;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,mBAAmB;IACtB,GAAG,CAAwB;IAEnC;;;OAGG;IACH,YAAY,IAAY;QACtB,sDAAsD;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IAED;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,IAAY;QAC5B,kCAAkC;QAClC,OAAO,IAAI,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixed-Point Math Module
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from phalanx-math for convenience.
|
|
5
|
+
* The canonical implementation is in phalanx-math.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { FP, FPVector3 } from '@phalanx-engine/server';
|
|
10
|
+
*
|
|
11
|
+
* const position = FPVector3.FromFloat(10.5, 0, 20.3);
|
|
12
|
+
* const target = FPVector3.FromFloat(5.0, 0, 10.0);
|
|
13
|
+
*
|
|
14
|
+
* const distance = FPVector3.Distance(position, target);
|
|
15
|
+
*
|
|
16
|
+
* // Convert back to number for display
|
|
17
|
+
* console.log(FP.ToFloat(distance));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export { FixedPoint, FP, FPVector2, FPVector3, } from '@phalanx-engine/math';
|
|
21
|
+
export type { FPVector2 as FPVector2Interface, FPVector3 as FPVector3Interface } from '@phalanx-engine/math';
|
|
22
|
+
//# sourceMappingURL=FixedMath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FixedMath.d.ts","sourceRoot":"","sources":["../../src/utils/FixedMath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAEL,UAAU,EAEV,EAAE,EACF,SAAS,EACT,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,SAAS,IAAI,kBAAkB,EAAE,SAAS,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixed-Point Math Module
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from phalanx-math for convenience.
|
|
5
|
+
* The canonical implementation is in phalanx-math.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { FP, FPVector3 } from '@phalanx-engine/server';
|
|
10
|
+
*
|
|
11
|
+
* const position = FPVector3.FromFloat(10.5, 0, 20.3);
|
|
12
|
+
* const target = FPVector3.FromFloat(5.0, 0, 10.0);
|
|
13
|
+
*
|
|
14
|
+
* const distance = FPVector3.Distance(position, target);
|
|
15
|
+
*
|
|
16
|
+
* // Convert back to number for display
|
|
17
|
+
* console.log(FP.ToFloat(distance));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
// Re-export everything from phalanx-math
|
|
21
|
+
export {
|
|
22
|
+
// Core type
|
|
23
|
+
FixedPoint,
|
|
24
|
+
// Unified API (Unity/Quantum style)
|
|
25
|
+
FP, FPVector2, FPVector3, } from '@phalanx-engine/math';
|
|
26
|
+
//# sourceMappingURL=FixedMath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FixedMath.js","sourceRoot":"","sources":["../../src/utils/FixedMath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,yCAAyC;AACzC,OAAO;AACL,YAAY;AACZ,UAAU;AACV,oCAAoC;AACpC,EAAE,EACF,SAAS,EACT,SAAS,GACV,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phalanx Engine Utilities
|
|
3
|
+
*/
|
|
4
|
+
export { DeterministicRandom } from './DeterministicRandom.js';
|
|
5
|
+
export { FP, FPVector2, FPVector3, FixedPoint } from './FixedMath.js';
|
|
6
|
+
export type { FPVector2Interface, FPVector3Interface } from './FixedMath.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@phalanx-engine/server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Phalanx Engine Server - A game-agnostic deterministic lockstep multiplayer server with authentication, matchmaking, and command synchronization",
|
|
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
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"multiplayer",
|
|
16
|
+
"game-server",
|
|
17
|
+
"lockstep",
|
|
18
|
+
"deterministic",
|
|
19
|
+
"netcode",
|
|
20
|
+
"socket.io",
|
|
21
|
+
"matchmaking",
|
|
22
|
+
"phalanx"
|
|
23
|
+
],
|
|
24
|
+
"author": "",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/phaeton-forge/phalanx-engine.git",
|
|
29
|
+
"directory": "phalanx-server"
|
|
30
|
+
},
|
|
31
|
+
"bugs": "https://github.com/phaeton-forge/phalanx-engine/issues",
|
|
32
|
+
"homepage": "https://github.com/phaeton-forge/phalanx-engine/tree/main/phalanx-server#readme",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=24.0.0 <25.0.0"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"README.md"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"pure-rand": "^7.0.1",
|
|
45
|
+
"socket.io": "^4.7.0",
|
|
46
|
+
"@phalanx-engine/math": "0.1.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^20.0.0",
|
|
50
|
+
"rimraf": "^5.0.0",
|
|
51
|
+
"socket.io-client": "^4.7.0",
|
|
52
|
+
"typescript": "^5.3.0",
|
|
53
|
+
"vitest": "^1.0.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsc",
|
|
57
|
+
"dev": "tsc --watch",
|
|
58
|
+
"clean": "rimraf dist",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest"
|
|
61
|
+
}
|
|
62
|
+
}
|