@colyseus/schema 4.0.27 → 4.0.29
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 +23 -0
- package/build/codegen/cli.cjs +13 -5
- package/build/codegen/cli.cjs.map +1 -1
- package/build/index.cjs.map +1 -1
- package/build/index.mjs.map +1 -1
- package/build/types/custom/MapSchema.d.ts +1 -1
- package/package.json +9 -3
- package/src/codegen/cli.ts +4 -4
- package/src/codegen/parser.ts +10 -1
- package/src/types/custom/MapSchema.ts +1 -1
|
@@ -28,7 +28,7 @@ export declare class MapSchema<V = any, K extends string = string> implements Ma
|
|
|
28
28
|
static is(type: any): boolean;
|
|
29
29
|
constructor(initialValues?: Map<K, V> | Record<K, V>);
|
|
30
30
|
/** Iterator */
|
|
31
|
-
[Symbol.iterator]():
|
|
31
|
+
[Symbol.iterator](): ReturnType<Map<K, V>[typeof Symbol.iterator]>;
|
|
32
32
|
get [Symbol.toStringTag](): string;
|
|
33
33
|
static get [Symbol.species](): typeof MapSchema;
|
|
34
34
|
set(key: K, value: V): this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colyseus/schema",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.29",
|
|
4
4
|
"description": "Binary state serializer with delta encoding for games",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc -p tsconfig.build.json && rollup -c rollup.config.mjs",
|
|
12
12
|
"watch": "tsc -p tsconfig.build.json -w",
|
|
13
|
-
"test": "tsx --tsconfig tsconfig.test.json ./node_modules/.bin/mocha test/*.test.ts test/**/*.test.ts",
|
|
13
|
+
"test": "npm run test:types && tsx --tsconfig tsconfig.test.json ./node_modules/.bin/mocha test/*.test.ts test/**/*.test.ts",
|
|
14
|
+
"test:types": "tsc -p tsconfig.build.json && tsc -p tsconfig.types.json",
|
|
14
15
|
"typecheck": "tsc -p tsconfig.test.json",
|
|
15
16
|
"coverage": "c8 npm run test",
|
|
16
17
|
"generate-test-1": "bin/schema-codegen test-external/PrimitiveTypes.ts --namespace SchemaTest.PrimitiveTypes --output ../colyseus-unity-sdk/Assets/Colyseus/Tests/Editor/ColyseusTests/Schema/PrimitiveTypes",
|
|
@@ -82,7 +83,12 @@
|
|
|
82
83
|
"typescript": "^5.9.3"
|
|
83
84
|
},
|
|
84
85
|
"peerDependencies": {
|
|
85
|
-
"typescript": "
|
|
86
|
+
"typescript": ">=5.0.0"
|
|
87
|
+
},
|
|
88
|
+
"peerDependenciesMeta": {
|
|
89
|
+
"typescript": {
|
|
90
|
+
"optional": true
|
|
91
|
+
}
|
|
86
92
|
},
|
|
87
93
|
"c8": {
|
|
88
94
|
"include": [
|
package/src/codegen/cli.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import argv from "./argv.js";
|
|
2
2
|
import { generate, generators } from "./api.js";
|
|
3
3
|
|
|
4
|
-
function displayHelp() {
|
|
4
|
+
function displayHelp(exitCode: number = 0) {
|
|
5
5
|
console.log(`\nschema-codegen [path/to/Schema.ts]
|
|
6
6
|
|
|
7
7
|
Usage (C#/Unity)
|
|
@@ -22,7 +22,7 @@ ${Object.
|
|
|
22
22
|
Optional:
|
|
23
23
|
--namespace: generate namespace on output code
|
|
24
24
|
--decorator: custom name for @type decorator to scan for`);
|
|
25
|
-
process.exit();
|
|
25
|
+
process.exit(exitCode);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const args = argv(process.argv.slice(2));
|
|
@@ -39,7 +39,7 @@ for (let target in generators) {
|
|
|
39
39
|
|
|
40
40
|
if (!args.output) {
|
|
41
41
|
console.error("You must provide a valid --output directory.");
|
|
42
|
-
displayHelp();
|
|
42
|
+
displayHelp(1);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
try {
|
|
@@ -55,5 +55,5 @@ try {
|
|
|
55
55
|
} catch (e) {
|
|
56
56
|
console.error(e.message);
|
|
57
57
|
console.error(e.stack);
|
|
58
|
-
displayHelp();
|
|
58
|
+
displayHelp(1);
|
|
59
59
|
}
|
package/src/codegen/parser.ts
CHANGED
|
@@ -339,6 +339,14 @@ export function parseFiles(
|
|
|
339
339
|
decoratorName: string = "type",
|
|
340
340
|
context: Context = new Context()
|
|
341
341
|
) {
|
|
342
|
+
if (typeof ts.createSourceFile !== "function") {
|
|
343
|
+
// typescript@7+ (native) no longer ships the JS compiler API
|
|
344
|
+
throw new Error(
|
|
345
|
+
`schema-codegen requires the TypeScript compiler API, which the installed "typescript@${(ts as any).version}" package does not provide.\n` +
|
|
346
|
+
`TypeScript 7+ no longer ships the JS compiler API — install typescript 5.x or 6.x (e.g. \`npm install --save-dev typescript@6\`) to use schema-codegen.`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
342
350
|
/**
|
|
343
351
|
* Re-set globalContext for each test case
|
|
344
352
|
*/
|
|
@@ -389,7 +397,8 @@ export function parseFiles(
|
|
|
389
397
|
|
|
390
398
|
break;
|
|
391
399
|
} catch (e) {
|
|
392
|
-
//
|
|
400
|
+
// only swallow fs errors (ENOENT/EISDIR) while probing alternatives
|
|
401
|
+
if (!e?.code) { throw e; }
|
|
393
402
|
}
|
|
394
403
|
}
|
|
395
404
|
|
|
@@ -77,7 +77,7 @@ export class MapSchema<V=any, K extends string = string> implements Map<K, V>, C
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/** Iterator */
|
|
80
|
-
[Symbol.iterator]():
|
|
80
|
+
[Symbol.iterator](): ReturnType<Map<K, V>[typeof Symbol.iterator]> { return this.$items[Symbol.iterator](); }
|
|
81
81
|
get [Symbol.toStringTag]() { return this.$items[Symbol.toStringTag] }
|
|
82
82
|
|
|
83
83
|
static get [Symbol.species]() { return MapSchema; }
|