@colyseus/schema 4.0.6 → 4.0.8
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/bin/schema-codegen +1 -1
- package/build/codegen/cli.cjs +1555 -0
- package/build/codegen/cli.cjs.map +1 -0
- package/build/encoder/ChangeTree.d.ts +0 -1
- package/build/index.cjs.map +1 -1
- package/build/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/codegen/api.ts +12 -11
- package/src/encoder/ChangeTree.ts +2 -1
package/package.json
CHANGED
package/src/codegen/api.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { createRequire } from "module";
|
|
4
|
-
// import { fileURLToPath } from "url";
|
|
5
3
|
|
|
6
4
|
import { File } from "./types.js";
|
|
7
5
|
import { parseFiles } from "./parser.js";
|
|
8
6
|
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
// Statically import all language generators (for bundling)
|
|
8
|
+
import { generate as csharp } from "./languages/csharp.js";
|
|
9
|
+
import { generate as cpp } from "./languages/cpp.js";
|
|
10
|
+
import { generate as haxe } from "./languages/haxe.js";
|
|
11
|
+
import { generate as ts } from "./languages/ts.js";
|
|
12
|
+
import { generate as js } from "./languages/js.js";
|
|
13
|
+
import { generate as java } from "./languages/java.js";
|
|
14
|
+
import { generate as lua } from "./languages/lua.js";
|
|
15
|
+
|
|
16
|
+
const generators: Record<string, Function> = { csharp, cpp, haxe, ts, js, java, lua, };
|
|
13
17
|
|
|
14
18
|
export interface GenerateOptions {
|
|
15
19
|
files: string[],
|
|
@@ -19,12 +23,9 @@ export interface GenerateOptions {
|
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
export function generate(targetId: string, options: GenerateOptions) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
generator = require('./languages/' + targetId + '.js').generate;
|
|
26
|
+
const generator = generators[targetId];
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
if (!generator) {
|
|
28
29
|
throw new Error("You must provide a valid generator as argument, such as: --csharp, --haxe or --cpp");
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -23,7 +23,8 @@ declare global {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface IRef {
|
|
26
|
-
|
|
26
|
+
// FIXME: we only commented this out to allow mixing @colyseus/schema bundled types with server types in Cocos Creator
|
|
27
|
+
// [$changes]?: ChangeTree;
|
|
27
28
|
[$refId]?: number;
|
|
28
29
|
[$getByIndex]?: (index: number, isEncodeAll?: boolean) => any;
|
|
29
30
|
[$deleteByIndex]?: (index: number) => void;
|