@colyseus/schema 4.0.12 → 4.0.14
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 +31 -0
- package/build/codegen/api.d.ts +2 -0
- package/build/codegen/cli.cjs +934 -177
- package/build/codegen/cli.cjs.map +1 -1
- package/build/codegen/languages/c.d.ts +11 -0
- package/build/codegen/languages/cpp.d.ts +8 -0
- package/build/codegen/languages/csharp.d.ts +8 -0
- package/build/codegen/languages/gdscript.d.ts +14 -0
- package/build/codegen/languages/haxe.d.ts +8 -0
- package/build/codegen/languages/java.d.ts +11 -1
- package/build/codegen/languages/js.d.ts +8 -0
- package/build/codegen/languages/lua.d.ts +8 -0
- package/build/codegen/languages/ts.d.ts +8 -0
- package/build/codegen/types.d.ts +14 -0
- package/build/index.cjs +5 -1
- package/build/index.cjs.map +1 -1
- package/build/index.js +5 -1
- package/build/index.mjs +5 -1
- package/build/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/codegen/api.ts +26 -15
- package/src/codegen/cli.ts +9 -15
- package/src/codegen/languages/c.ts +282 -0
- package/src/codegen/languages/cpp.ts +74 -22
- package/src/codegen/languages/csharp.ts +87 -19
- package/src/codegen/languages/gdscript.ts +219 -0
- package/src/codegen/languages/haxe.ts +41 -5
- package/src/codegen/languages/java.ts +45 -4
- package/src/codegen/languages/js.ts +62 -20
- package/src/codegen/languages/lua.ts +60 -18
- package/src/codegen/languages/ts.ts +65 -14
- package/src/codegen/types.ts +15 -0
- package/src/decoder/strategy/Callbacks.ts +5 -1
package/README.md
CHANGED
|
@@ -287,6 +287,37 @@ schema-codegen ./schemas/State.ts --output ./cpp-project/ --cpp
|
|
|
287
287
|
schema-codegen ./schemas/State.ts --output ./haxe-project/ --haxe
|
|
288
288
|
```
|
|
289
289
|
|
|
290
|
+
### Code Generation Options
|
|
291
|
+
|
|
292
|
+
| Option | Description |
|
|
293
|
+
|--------|-------------|
|
|
294
|
+
| `--output` | The output directory for generated client-side schema files (required) |
|
|
295
|
+
| `--bundle` | Bundle all generated files into a single file |
|
|
296
|
+
| `--namespace` | Generate namespace/package on output code |
|
|
297
|
+
| `--decorator` | Custom name for `@type` decorator to scan for |
|
|
298
|
+
|
|
299
|
+
### Bundle Mode
|
|
300
|
+
|
|
301
|
+
By default, the code generator creates one file per schema class. Use the `--bundle` option to combine all generated classes into a single file:
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
# Generate a single bundled file
|
|
305
|
+
schema-codegen ./schemas/State.ts --output ./unity-project/ --csharp --bundle
|
|
306
|
+
|
|
307
|
+
# With namespace
|
|
308
|
+
schema-codegen ./schemas/State.ts --output ./unity-project/ --csharp --bundle --namespace MyGame.Schema
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Bundle mode output filenames:
|
|
312
|
+
- **TypeScript**: `schema.ts` (or `{namespace}.ts`)
|
|
313
|
+
- **JavaScript**: `schema.js` (or `{namespace}.js`)
|
|
314
|
+
- **C#**: `Schema.cs` (or `{namespace}.cs`)
|
|
315
|
+
- **C++**: `schema.hpp` (or `{namespace}.hpp`)
|
|
316
|
+
- **Haxe**: `Schema.hx` (or `{namespace}.hx`)
|
|
317
|
+
- **Java**: `Schema.java`
|
|
318
|
+
- **Lua**: `schema.lua` (or `{namespace}.lua`)
|
|
319
|
+
- **C**: `schema.h` (or `{namespace}.h`)
|
|
320
|
+
|
|
290
321
|
## Benchmarks:
|
|
291
322
|
|
|
292
323
|
| Scenario | `@colyseus/schema` | `msgpack` + `fossil-delta` |
|
package/build/codegen/api.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export declare const generators: Record<string, any>;
|
|
1
2
|
export interface GenerateOptions {
|
|
2
3
|
files: string[];
|
|
3
4
|
output: string;
|
|
4
5
|
decorator?: string;
|
|
5
6
|
namespace?: string;
|
|
7
|
+
bundle?: boolean;
|
|
6
8
|
}
|
|
7
9
|
export declare function generate(targetId: string, options: GenerateOptions): void;
|