@colyseus/schema 5.0.22 → 5.0.23

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.
@@ -1029,8 +1029,8 @@ function getDecorators(node) {
1029
1029
  return node.modifiers?.filter(ts__namespace.isDecorator);
1030
1030
  }
1031
1031
 
1032
- const name$9 = "Unity/C#";
1033
- const typeMaps$9 = {
1032
+ const name$a = "Unity/C#";
1033
+ const typeMaps$a = {
1034
1034
  "string": "string",
1035
1035
  "number": "float",
1036
1036
  "boolean": "bool",
@@ -1045,7 +1045,7 @@ const typeMaps$9 = {
1045
1045
  "float32": "float",
1046
1046
  "float64": "double",
1047
1047
  };
1048
- const COMMON_IMPORTS$6 = `using Colyseus.Schema;
1048
+ const COMMON_IMPORTS$7 = `using Colyseus.Schema;
1049
1049
  #if UNITY_5_3_OR_NEWER
1050
1050
  using UnityEngine.Scripting;
1051
1051
  #endif`;
@@ -1060,10 +1060,10 @@ const capitalize$1 = (s) => {
1060
1060
  /**
1061
1061
  * Generate individual files for each class/interface/enum
1062
1062
  */
1063
- function generate$a(context, options) {
1063
+ function generate$b(context, options) {
1064
1064
  // enrich typeMaps with enums
1065
1065
  context.enums.forEach((structure) => {
1066
- typeMaps$9[structure.name] = structure.name;
1066
+ typeMaps$a[structure.name] = structure.name;
1067
1067
  });
1068
1068
  return [
1069
1069
  ...context.classes.map(structure => ({
@@ -1083,23 +1083,23 @@ function generate$a(context, options) {
1083
1083
  /**
1084
1084
  * Generate a single bundled file containing all classes, interfaces, and enums
1085
1085
  */
1086
- function renderBundle$9(context, options) {
1086
+ function renderBundle$a(context, options) {
1087
1087
  const fileName = options.namespace ? `${options.namespace}.cs` : "Schema.cs";
1088
1088
  const indent = options.namespace ? "\t" : "";
1089
1089
  // enrich typeMaps with enums
1090
1090
  context.enums.forEach((structure) => {
1091
- typeMaps$9[structure.name] = structure.name;
1091
+ typeMaps$a[structure.name] = structure.name;
1092
1092
  });
1093
1093
  // Collect all bodies
1094
- const classBodies = context.classes.map(klass => generateClassBody$9(klass, indent));
1095
- const interfaceBodies = context.interfaces.map(iface => generateInterfaceBody$2(iface, indent));
1094
+ const classBodies = context.classes.map(klass => generateClassBody$a(klass, indent));
1095
+ const interfaceBodies = context.interfaces.map(iface => generateInterfaceBody$3(iface, indent));
1096
1096
  const enumBodies = context.enums
1097
1097
  .filter(structure => structure.name !== 'OPERATION')
1098
- .map(e => generateEnumBody$2(e, indent));
1098
+ .map(e => generateEnumBody$3(e, indent));
1099
1099
  const allBodies = [...classBodies, ...interfaceBodies, ...enumBodies].join("\n\n");
1100
1100
  const content = `${getCommentHeader()}
1101
1101
 
1102
- ${COMMON_IMPORTS$6}
1102
+ ${COMMON_IMPORTS$7}
1103
1103
  ${options.namespace ? `\nnamespace ${options.namespace} {\n` : ""}
1104
1104
  ${allBodies}
1105
1105
  ${options.namespace ? "}" : ""}`;
@@ -1108,13 +1108,13 @@ ${options.namespace ? "}" : ""}`;
1108
1108
  /**
1109
1109
  * Generate just the class body (without imports/namespace) for bundling
1110
1110
  */
1111
- function generateClassBody$9(klass, indent = "") {
1111
+ function generateClassBody$a(klass, indent = "") {
1112
1112
  return `${indent}public partial class ${klass.name} : ${klass.extends} {
1113
1113
  #if UNITY_5_3_OR_NEWER
1114
1114
  [Preserve]
1115
1115
  #endif
1116
1116
  public ${klass.name}() { }
1117
- ${klass.properties.map((prop) => generateProperty$4(prop, indent)).join("\n\n")}
1117
+ ${klass.properties.map((prop) => generateProperty$5(prop, indent)).join("\n\n")}
1118
1118
  ${indent}}`;
1119
1119
  }
1120
1120
  /**
@@ -1124,9 +1124,9 @@ function generateClass$9(klass, namespace) {
1124
1124
  const indent = (namespace) ? "\t" : "";
1125
1125
  return `${getCommentHeader()}
1126
1126
 
1127
- ${COMMON_IMPORTS$6}
1127
+ ${COMMON_IMPORTS$7}
1128
1128
  ${namespace ? `\nnamespace ${namespace} {` : ""}
1129
- ${generateClassBody$9(klass, indent)}
1129
+ ${generateClassBody$a(klass, indent)}
1130
1130
  ${namespace ? "}" : ""}
1131
1131
  `;
1132
1132
  }
@@ -1145,7 +1145,7 @@ function canUseNativeEnum(_enum) {
1145
1145
  /**
1146
1146
  * Generate just the enum body (without imports/namespace) for bundling
1147
1147
  */
1148
- function generateEnumBody$2(_enum, indent = "") {
1148
+ function generateEnumBody$3(_enum, indent = "") {
1149
1149
  if (canUseNativeEnum(_enum)) {
1150
1150
  const members = _enum.properties
1151
1151
  .map((prop, i) => {
@@ -1188,10 +1188,10 @@ function generateEnum$2(_enum, namespace) {
1188
1188
  const indent = namespace ? "\t" : "";
1189
1189
  return `${getCommentHeader()}
1190
1190
  ${namespace ? `\nnamespace ${namespace} {` : ""}
1191
- ${generateEnumBody$2(_enum, indent)}
1191
+ ${generateEnumBody$3(_enum, indent)}
1192
1192
  ${namespace ? "}" : ""}`;
1193
1193
  }
1194
- function generateProperty$4(prop, indent = "") {
1194
+ function generateProperty$5(prop, indent = "") {
1195
1195
  let typeArgs = `"${prop.type}"`;
1196
1196
  let property = "public";
1197
1197
  let langType;
@@ -1223,7 +1223,7 @@ function generateProperty$4(prop, indent = "") {
1223
1223
  /**
1224
1224
  * Generate just the interface body (without imports/namespace) for bundling
1225
1225
  */
1226
- function generateInterfaceBody$2(struct, indent = "") {
1226
+ function generateInterfaceBody$3(struct, indent = "") {
1227
1227
  return `${indent}public class ${struct.name} {
1228
1228
  ${struct.properties.map(prop => `\t${indent}public ${getType(prop)} ${prop.name};`).join("\n")}
1229
1229
  ${indent}}`;
@@ -1237,12 +1237,12 @@ function generateInterface$2(struct, namespace) {
1237
1237
 
1238
1238
  using Colyseus.Schema;
1239
1239
  ${namespace ? `\nnamespace ${namespace} {` : ""}
1240
- ${generateInterfaceBody$2(struct, indent)}
1240
+ ${generateInterfaceBody$3(struct, indent)}
1241
1241
  ${namespace ? "}" : ""}
1242
1242
  `;
1243
1243
  }
1244
1244
  function getChildType(prop) {
1245
- return typeMaps$9[prop.childType];
1245
+ return typeMaps$a[prop.childType];
1246
1246
  }
1247
1247
  function getType(prop) {
1248
1248
  if (prop.childType) {
@@ -1263,20 +1263,20 @@ function getType(prop) {
1263
1263
  }
1264
1264
  else {
1265
1265
  return (prop.type === "array")
1266
- ? `${typeMaps$9[prop.childType] || prop.childType}[]`
1267
- : typeMaps$9[prop.type];
1266
+ ? `${typeMaps$a[prop.childType] || prop.childType}[]`
1267
+ : typeMaps$a[prop.type];
1268
1268
  }
1269
1269
  }
1270
1270
 
1271
1271
  var csharp = /*#__PURE__*/Object.freeze({
1272
1272
  __proto__: null,
1273
- generate: generate$a,
1274
- name: name$9,
1275
- renderBundle: renderBundle$9
1273
+ generate: generate$b,
1274
+ name: name$a,
1275
+ renderBundle: renderBundle$a
1276
1276
  });
1277
1277
 
1278
- const name$8 = "C++";
1279
- const typeMaps$8 = {
1278
+ const name$9 = "C++";
1279
+ const typeMaps$9 = {
1280
1280
  "string": "string",
1281
1281
  "number": "varint_t",
1282
1282
  "boolean": "bool",
@@ -1323,7 +1323,7 @@ const distinct$6 = (value, index, self) => self.indexOf(value) === index;
1323
1323
  /**
1324
1324
  * Generate individual files for each class
1325
1325
  */
1326
- function generate$9(context, options) {
1326
+ function generate$a(context, options) {
1327
1327
  return context.classes.map(klass => ({
1328
1328
  name: klass.name + ".hpp",
1329
1329
  content: generateClass$8(klass, options.namespace, context.classes)
@@ -1332,10 +1332,10 @@ function generate$9(context, options) {
1332
1332
  /**
1333
1333
  * Generate a single bundled header file containing all classes
1334
1334
  */
1335
- function renderBundle$8(context, options) {
1335
+ function renderBundle$9(context, options) {
1336
1336
  const fileName = options.namespace ? `${options.namespace}.hpp` : "schema.hpp";
1337
1337
  const guardName = `__SCHEMA_CODEGEN_${(options.namespace || "SCHEMA").toUpperCase()}_H__`;
1338
- const classBodies = context.classes.map(klass => generateClassBody$8(klass, context.classes, options.namespace));
1338
+ const classBodies = context.classes.map(klass => generateClassBody$9(klass, context.classes, options.namespace));
1339
1339
  const content = `${getCommentHeader()}
1340
1340
  #ifndef ${guardName}
1341
1341
  #define ${guardName} 1
@@ -1353,7 +1353,7 @@ ${options.namespace ? "}" : ""}
1353
1353
  /**
1354
1354
  * Generate just the class body (without includes/guards) for bundling
1355
1355
  */
1356
- function generateClassBody$8(klass, allClasses, namespace) {
1356
+ function generateClassBody$9(klass, allClasses, namespace) {
1357
1357
  const propertiesPerType = {};
1358
1358
  const allRefs = [];
1359
1359
  klass.properties.forEach(property => {
@@ -1370,12 +1370,12 @@ function generateClassBody$8(klass, allClasses, namespace) {
1370
1370
  const allProperties = getAllProperties$1(klass, allClasses);
1371
1371
  const createInstanceMethod = (allRefs.length === 0) ? "" :
1372
1372
  `\tinline Schema* createInstance(std::type_index type) {
1373
- \t\t${generateFieldIfElseChain(allRefs, (property) => `type == typeid(${property.childType})`, (property) => `return new ${property.childType}();`, (property) => typeMaps$8[property.childType] === undefined)}
1373
+ \t\t${generateFieldIfElseChain(allRefs, (property) => `type == typeid(${property.childType})`, (property) => `return new ${property.childType}();`, (property) => typeMaps$9[property.childType] === undefined)}
1374
1374
  \t\treturn ${klass.extends}::createInstance(type);
1375
1375
  \t}`;
1376
1376
  return `class ${klass.name} : public ${klass.extends} {
1377
1377
  public:
1378
- ${klass.properties.map(prop => generateProperty$3(prop)).join("\n")}
1378
+ ${klass.properties.map(prop => generateProperty$4(prop)).join("\n")}
1379
1379
 
1380
1380
  \t${klass.name}() {
1381
1381
  \t\tthis->_indexes = ${generateAllIndexes(allProperties)};
@@ -1408,7 +1408,7 @@ function generateClass$8(klass, namespace, allClasses) {
1408
1408
  }
1409
1409
  });
1410
1410
  const localIncludes = allRefs.
1411
- filter(ref => ref.childType && typeMaps$8[ref.childType] === undefined).
1411
+ filter(ref => ref.childType && typeMaps$9[ref.childType] === undefined).
1412
1412
  map(ref => ref.childType).
1413
1413
  concat(getInheritanceTree(klass, allClasses, false).map(klass => klass.name)).
1414
1414
  filter(distinct$6).
@@ -1422,13 +1422,13 @@ ${COMMON_INCLUDES$1}
1422
1422
  ${localIncludes}
1423
1423
 
1424
1424
  ${namespace ? `namespace ${namespace} {` : ""}
1425
- ${generateClassBody$8(klass, allClasses)}
1425
+ ${generateClassBody$9(klass, allClasses)}
1426
1426
  ${namespace ? "}" : ""}
1427
1427
 
1428
1428
  #endif
1429
1429
  `;
1430
1430
  }
1431
- function generateProperty$3(prop) {
1431
+ function generateProperty$4(prop) {
1432
1432
  let property = "";
1433
1433
  let langType;
1434
1434
  let initializer = "";
@@ -1442,26 +1442,26 @@ function generateProperty$3(prop) {
1442
1442
  else if (prop.type === "array") {
1443
1443
  langType = (isUpcaseFirst)
1444
1444
  ? `ArraySchema<${prop.childType}*>`
1445
- : `ArraySchema<${typeMaps$8[prop.childType]}>`;
1445
+ : `ArraySchema<${typeMaps$9[prop.childType]}>`;
1446
1446
  initializer = `new ${langType}()`;
1447
1447
  }
1448
1448
  else if (prop.type === "map") {
1449
1449
  langType = (isUpcaseFirst)
1450
1450
  ? `MapSchema<${prop.childType}*>`
1451
- : `MapSchema<${typeMaps$8[prop.childType]}>`;
1451
+ : `MapSchema<${typeMaps$9[prop.childType]}>`;
1452
1452
  initializer = `new ${langType}()`;
1453
1453
  }
1454
1454
  isPropPointer = "*";
1455
1455
  }
1456
1456
  else {
1457
- langType = typeMaps$8[prop.type];
1457
+ langType = typeMaps$9[prop.type];
1458
1458
  initializer = typeInitializer$2[prop.type];
1459
1459
  }
1460
1460
  property += ` ${langType} ${isPropPointer}${prop.name}`;
1461
1461
  return `\t${property} = ${initializer};`;
1462
1462
  }
1463
1463
  function generateGettersAndSetters(klass, type, properties) {
1464
- let langType = typeMaps$8[type];
1464
+ let langType = typeMaps$9[type];
1465
1465
  let typeCast = "";
1466
1466
  const getMethodName = `get${capitalize(type)}`;
1467
1467
  const setMethodName = `set${capitalize(type)}`;
@@ -1485,7 +1485,7 @@ function generateGettersAndSetters(klass, type, properties) {
1485
1485
  \tinline void ${setMethodName}(const string &field, ${langType} value)
1486
1486
  \t{
1487
1487
  \t\t${generateFieldIfElseChain(properties, (property) => `field == "${property.name}"`, (property) => {
1488
- const isSchemaType = (typeMaps$8[property.childType] === undefined);
1488
+ const isSchemaType = (typeMaps$9[property.childType] === undefined);
1489
1489
  if (type === "ref") {
1490
1490
  langType = `${property.childType}*`;
1491
1491
  typeCast = (isSchemaType)
@@ -1495,12 +1495,12 @@ function generateGettersAndSetters(klass, type, properties) {
1495
1495
  else if (type === "array") {
1496
1496
  typeCast = (isSchemaType)
1497
1497
  ? `(ArraySchema<${property.childType}*> *)`
1498
- : `(ArraySchema<${typeMaps$8[property.childType]}> *)`;
1498
+ : `(ArraySchema<${typeMaps$9[property.childType]}> *)`;
1499
1499
  }
1500
1500
  else if (type === "map") {
1501
1501
  typeCast = (isSchemaType)
1502
1502
  ? `(MapSchema<${property.childType}*> *)`
1503
- : `(MapSchema<${typeMaps$8[property.childType]}> *)`;
1503
+ : `(MapSchema<${typeMaps$9[property.childType]}> *)`;
1504
1504
  }
1505
1505
  return `this->${property.name} = ${typeCast}value;\n\t\t\treturn;`;
1506
1506
  })}
@@ -1539,7 +1539,7 @@ function generateAllTypes(properties) {
1539
1539
  }
1540
1540
  function generateAllChildSchemaTypes(properties) {
1541
1541
  return `{${properties.map((property, i) => {
1542
- if (property.childType && typeMaps$8[property.childType] === undefined) {
1542
+ if (property.childType && typeMaps$9[property.childType] === undefined) {
1543
1543
  return `{${i}, typeid(${property.childType})}`;
1544
1544
  }
1545
1545
  else {
@@ -1549,7 +1549,7 @@ function generateAllChildSchemaTypes(properties) {
1549
1549
  }
1550
1550
  function generateAllChildPrimitiveTypes(properties) {
1551
1551
  return `{${properties.map((property, i) => {
1552
- if (typeMaps$8[property.childType] !== undefined) {
1552
+ if (typeMaps$9[property.childType] !== undefined) {
1553
1553
  return `{${i}, "${property.childType}"}`;
1554
1554
  }
1555
1555
  else {
@@ -1577,13 +1577,13 @@ function getAllProperties$1(klass, allClasses) {
1577
1577
 
1578
1578
  var cpp = /*#__PURE__*/Object.freeze({
1579
1579
  __proto__: null,
1580
- generate: generate$9,
1581
- name: name$8,
1582
- renderBundle: renderBundle$8
1580
+ generate: generate$a,
1581
+ name: name$9,
1582
+ renderBundle: renderBundle$9
1583
1583
  });
1584
1584
 
1585
- const name$7 = "Haxe";
1586
- const typeMaps$7 = {
1585
+ const name$8 = "Haxe";
1586
+ const typeMaps$8 = {
1587
1587
  "string": "String",
1588
1588
  "number": "Dynamic",
1589
1589
  "boolean": "Bool",
@@ -1613,12 +1613,12 @@ const typeInitializer$1 = {
1613
1613
  "float32": "0",
1614
1614
  "float64": "0",
1615
1615
  };
1616
- const COMMON_IMPORTS$5 = `import io.colyseus.serializer.schema.Schema;
1616
+ const COMMON_IMPORTS$6 = `import io.colyseus.serializer.schema.Schema;
1617
1617
  import io.colyseus.serializer.schema.types.*;`;
1618
1618
  /**
1619
1619
  * Generate individual files for each class
1620
1620
  */
1621
- function generate$8(context, options) {
1621
+ function generate$9(context, options) {
1622
1622
  return context.classes.map(klass => ({
1623
1623
  name: klass.name + ".hx",
1624
1624
  content: generateClass$7(klass, options.namespace, context.classes)
@@ -1627,13 +1627,13 @@ function generate$8(context, options) {
1627
1627
  /**
1628
1628
  * Generate a single bundled file containing all classes
1629
1629
  */
1630
- function renderBundle$7(context, options) {
1630
+ function renderBundle$8(context, options) {
1631
1631
  const fileName = options.namespace ? `${options.namespace}.hx` : "Schema.hx";
1632
- const classBodies = context.classes.map(klass => generateClassBody$7(klass));
1632
+ const classBodies = context.classes.map(klass => generateClassBody$8(klass));
1633
1633
  const content = `${getCommentHeader()}
1634
1634
 
1635
1635
  ${options.namespace ? `package ${options.namespace};` : ""}
1636
- ${COMMON_IMPORTS$5}
1636
+ ${COMMON_IMPORTS$6}
1637
1637
 
1638
1638
  ${classBodies.join("\n\n")}
1639
1639
  `;
@@ -1642,9 +1642,9 @@ ${classBodies.join("\n\n")}
1642
1642
  /**
1643
1643
  * Generate just the class body (without package/imports) for bundling
1644
1644
  */
1645
- function generateClassBody$7(klass) {
1645
+ function generateClassBody$8(klass) {
1646
1646
  return `class ${klass.name} extends ${klass.extends} {
1647
- ${klass.properties.map(prop => generateProperty$2(prop)).join("\n")}
1647
+ ${klass.properties.map(prop => generateProperty$3(prop)).join("\n")}
1648
1648
  }`;
1649
1649
  }
1650
1650
  /**
@@ -1654,12 +1654,12 @@ function generateClass$7(klass, namespace, allClasses) {
1654
1654
  return `${getCommentHeader()}
1655
1655
 
1656
1656
  ${namespace ? `package ${namespace};` : ""}
1657
- ${COMMON_IMPORTS$5}
1657
+ ${COMMON_IMPORTS$6}
1658
1658
 
1659
- ${generateClassBody$7(klass)}
1659
+ ${generateClassBody$8(klass)}
1660
1660
  `;
1661
1661
  }
1662
- function generateProperty$2(prop) {
1662
+ function generateProperty$3(prop) {
1663
1663
  let langType;
1664
1664
  let initializer = "";
1665
1665
  let typeArgs = `"${prop.type}"`;
@@ -1684,18 +1684,18 @@ function generateProperty$2(prop) {
1684
1684
  else if (prop.type === "array") {
1685
1685
  langType = (isUpcaseFirst)
1686
1686
  ? `ArraySchema<${prop.childType}>`
1687
- : `ArraySchema<${typeMaps$7[prop.childType]}>`;
1687
+ : `ArraySchema<${typeMaps$8[prop.childType]}>`;
1688
1688
  initializer = `new ${langType}()`;
1689
1689
  }
1690
1690
  else if (prop.type === "map") {
1691
1691
  langType = (isUpcaseFirst)
1692
1692
  ? `MapSchema<${prop.childType}>`
1693
- : `MapSchema<${typeMaps$7[prop.childType]}>`;
1693
+ : `MapSchema<${typeMaps$8[prop.childType]}>`;
1694
1694
  initializer = `new ${langType}()`;
1695
1695
  }
1696
1696
  }
1697
1697
  else {
1698
- langType = typeMaps$7[prop.type];
1698
+ langType = typeMaps$8[prop.type];
1699
1699
  initializer = typeInitializer$1[prop.type];
1700
1700
  }
1701
1701
  // TODO: remove initializer. The callbacks at the Haxe decoder side have a
@@ -1706,13 +1706,13 @@ function generateProperty$2(prop) {
1706
1706
 
1707
1707
  var haxe = /*#__PURE__*/Object.freeze({
1708
1708
  __proto__: null,
1709
- generate: generate$8,
1710
- name: name$7,
1711
- renderBundle: renderBundle$7
1709
+ generate: generate$9,
1710
+ name: name$8,
1711
+ renderBundle: renderBundle$8
1712
1712
  });
1713
1713
 
1714
- const name$6 = "TypeScript";
1715
- const typeMaps$6 = {
1714
+ const name$7 = "TypeScript";
1715
+ const typeMaps$7 = {
1716
1716
  "string": "string",
1717
1717
  "number": "number",
1718
1718
  "boolean": "boolean",
@@ -1727,12 +1727,12 @@ const typeMaps$6 = {
1727
1727
  "float32": "number",
1728
1728
  "float64": "number",
1729
1729
  };
1730
- const COMMON_IMPORTS$4 = `import { Schema, type, ArraySchema, MapSchema, SetSchema, DataChange } from '@colyseus/schema';`;
1730
+ const COMMON_IMPORTS$5 = `import { Schema, type, ArraySchema, MapSchema, SetSchema, DataChange } from '@colyseus/schema';`;
1731
1731
  const distinct$5 = (value, index, self) => self.indexOf(value) === index;
1732
1732
  /**
1733
1733
  * Generate individual files for each class/interface
1734
1734
  */
1735
- function generate$7(context, options) {
1735
+ function generate$8(context, options) {
1736
1736
  return [
1737
1737
  ...context.classes.map(structure => ({
1738
1738
  name: structure.name + ".ts",
@@ -1747,15 +1747,15 @@ function generate$7(context, options) {
1747
1747
  /**
1748
1748
  * Generate a single bundled file containing all classes and interfaces
1749
1749
  */
1750
- function renderBundle$6(context, options) {
1750
+ function renderBundle$7(context, options) {
1751
1751
  const fileName = options.namespace ? `${options.namespace}.ts` : "schema.ts";
1752
1752
  // Collect all class bodies
1753
- const classBodies = context.classes.map(klass => generateClassBody$6(klass));
1753
+ const classBodies = context.classes.map(klass => generateClassBody$7(klass));
1754
1754
  // Collect all interface bodies
1755
- const interfaceBodies = context.interfaces.map(iface => generateInterfaceBody$1(iface));
1755
+ const interfaceBodies = context.interfaces.map(iface => generateInterfaceBody$2(iface));
1756
1756
  const content = `${getCommentHeader()}
1757
1757
 
1758
- ${COMMON_IMPORTS$4}
1758
+ ${COMMON_IMPORTS$5}
1759
1759
 
1760
1760
  ${classBodies.join("\n\n")}
1761
1761
  ${interfaceBodies.length > 0 ? "\n" + interfaceBodies.join("\n\n") : ""}`;
@@ -1764,15 +1764,15 @@ ${interfaceBodies.length > 0 ? "\n" + interfaceBodies.join("\n\n") : ""}`;
1764
1764
  /**
1765
1765
  * Generate just the class body (without imports) for bundling
1766
1766
  */
1767
- function generateClassBody$6(klass) {
1767
+ function generateClassBody$7(klass) {
1768
1768
  return `export class ${klass.name} extends ${klass.extends} {
1769
- ${klass.properties.map(prop => ` ${generateProperty$1(prop)}`).join("\n")}
1769
+ ${klass.properties.map(prop => ` ${generateProperty$2(prop)}`).join("\n")}
1770
1770
  }`;
1771
1771
  }
1772
1772
  /**
1773
1773
  * Generate just the interface body (without imports) for bundling
1774
1774
  */
1775
- function generateInterfaceBody$1(iface) {
1775
+ function generateInterfaceBody$2(iface) {
1776
1776
  return `export interface ${iface.name} {
1777
1777
  ${iface.properties.map(prop => ` ${prop.name}: ${prop.type};`).join("\n")}
1778
1778
  }`;
@@ -1790,7 +1790,7 @@ function generateClass$6(klass, namespace, allClasses) {
1790
1790
  }
1791
1791
  });
1792
1792
  const localImports = allRefs.
1793
- filter(ref => ref.childType && typeMaps$6[ref.childType] === undefined).
1793
+ filter(ref => ref.childType && typeMaps$7[ref.childType] === undefined).
1794
1794
  map(ref => ref.childType).
1795
1795
  concat(getInheritanceTree(klass, allClasses, false).map(klass => klass.name)).
1796
1796
  filter(distinct$5).
@@ -1798,13 +1798,13 @@ function generateClass$6(klass, namespace, allClasses) {
1798
1798
  join("\n");
1799
1799
  return `${getCommentHeader()}
1800
1800
 
1801
- ${COMMON_IMPORTS$4}
1801
+ ${COMMON_IMPORTS$5}
1802
1802
  ${localImports}
1803
1803
 
1804
- ${generateClassBody$6(klass)}
1804
+ ${generateClassBody$7(klass)}
1805
1805
  `;
1806
1806
  }
1807
- function generateProperty$1(prop) {
1807
+ function generateProperty$2(prop) {
1808
1808
  let langType;
1809
1809
  let initializer = "";
1810
1810
  let typeArgs;
@@ -1824,7 +1824,7 @@ function generateProperty$1(prop) {
1824
1824
  else if (prop.type === "array") {
1825
1825
  langType = (isUpcaseFirst)
1826
1826
  ? `ArraySchema<${prop.childType}>`
1827
- : `ArraySchema<${typeMaps$6[prop.childType]}>`;
1827
+ : `ArraySchema<${typeMaps$7[prop.childType]}>`;
1828
1828
  initializer = `new ${langType}()`;
1829
1829
  typeArgs = (isUpcaseFirst)
1830
1830
  ? `[ ${prop.childType} ]`
@@ -1833,7 +1833,7 @@ function generateProperty$1(prop) {
1833
1833
  else if (prop.type === "map") {
1834
1834
  langType = (isUpcaseFirst)
1835
1835
  ? `MapSchema<${prop.childType}>`
1836
- : `MapSchema<${typeMaps$6[prop.childType]}>`;
1836
+ : `MapSchema<${typeMaps$7[prop.childType]}>`;
1837
1837
  initializer = `new ${langType}()`;
1838
1838
  typeArgs = (isUpcaseFirst)
1839
1839
  ? `{ map: ${prop.childType} }`
@@ -1842,7 +1842,7 @@ function generateProperty$1(prop) {
1842
1842
  else if (prop.type === "set") {
1843
1843
  langType = (isUpcaseFirst)
1844
1844
  ? `SetSchema<${prop.childType}>`
1845
- : `SetSchema<${typeMaps$6[prop.childType]}>`;
1845
+ : `SetSchema<${typeMaps$7[prop.childType]}>`;
1846
1846
  initializer = `new ${langType}()`;
1847
1847
  typeArgs = (isUpcaseFirst)
1848
1848
  ? `{ set: ${prop.childType} }`
@@ -1855,7 +1855,7 @@ function generateProperty$1(prop) {
1855
1855
  typeArgs = `{ quantized: { min: ${q.min}, max: ${q.max}, bits: ${q.bits}${q.wrap ? `, mode: "wrap"` : ""} } }`;
1856
1856
  }
1857
1857
  else {
1858
- langType = typeMaps$6[prop.type];
1858
+ langType = typeMaps$7[prop.type];
1859
1859
  typeArgs = `"${prop.type}"`;
1860
1860
  }
1861
1861
  // TS1263: "Declarations with initializers cannot also have definite assignment assertions"
@@ -1868,19 +1868,19 @@ function generateProperty$1(prop) {
1868
1868
  function generateInterface$1(structure, namespace, allClasses) {
1869
1869
  return `${getCommentHeader()}
1870
1870
 
1871
- ${generateInterfaceBody$1(structure)}
1871
+ ${generateInterfaceBody$2(structure)}
1872
1872
  `;
1873
1873
  }
1874
1874
 
1875
1875
  var ts = /*#__PURE__*/Object.freeze({
1876
1876
  __proto__: null,
1877
- generate: generate$7,
1878
- name: name$6,
1879
- renderBundle: renderBundle$6
1877
+ generate: generate$8,
1878
+ name: name$7,
1879
+ renderBundle: renderBundle$7
1880
1880
  });
1881
1881
 
1882
- const name$5 = "JavaScript";
1883
- const typeMaps$5 = {
1882
+ const name$6 = "JavaScript";
1883
+ const typeMaps$6 = {
1884
1884
  "string": "string",
1885
1885
  "number": "number",
1886
1886
  "boolean": "boolean",
@@ -1895,14 +1895,14 @@ const typeMaps$5 = {
1895
1895
  "float32": "number",
1896
1896
  "float64": "number",
1897
1897
  };
1898
- const COMMON_IMPORTS$3 = `const schema = require("@colyseus/schema");
1898
+ const COMMON_IMPORTS$4 = `const schema = require("@colyseus/schema");
1899
1899
  const Schema = schema.Schema;
1900
1900
  const type = schema.type;`;
1901
1901
  const distinct$4 = (value, index, self) => self.indexOf(value) === index;
1902
1902
  /**
1903
1903
  * Generate individual files for each class
1904
1904
  */
1905
- function generate$6(context, options) {
1905
+ function generate$7(context, options) {
1906
1906
  return context.classes.map(klass => ({
1907
1907
  name: klass.name + ".js",
1908
1908
  content: generateClass$5(klass, options.namespace, context.classes)
@@ -1911,13 +1911,13 @@ function generate$6(context, options) {
1911
1911
  /**
1912
1912
  * Generate a single bundled file containing all classes
1913
1913
  */
1914
- function renderBundle$5(context, options) {
1914
+ function renderBundle$6(context, options) {
1915
1915
  const fileName = options.namespace ? `${options.namespace}.js` : "schema.js";
1916
- const classBodies = context.classes.map(klass => generateClassBody$5(klass));
1916
+ const classBodies = context.classes.map(klass => generateClassBody$6(klass));
1917
1917
  const classExports = context.classes.map(klass => ` ${klass.name},`).join("\n");
1918
1918
  const content = `${getCommentHeader()}
1919
1919
 
1920
- ${COMMON_IMPORTS$3}
1920
+ ${COMMON_IMPORTS$4}
1921
1921
 
1922
1922
  ${classBodies.join("\n\n")}
1923
1923
 
@@ -1930,7 +1930,7 @@ ${classExports}
1930
1930
  /**
1931
1931
  * Generate just the class body (without imports) for bundling
1932
1932
  */
1933
- function generateClassBody$5(klass) {
1933
+ function generateClassBody$6(klass) {
1934
1934
  return `class ${klass.name} extends ${klass.extends} {
1935
1935
  constructor () {
1936
1936
  super();
@@ -1954,7 +1954,7 @@ function generateClass$5(klass, namespace, allClasses) {
1954
1954
  }
1955
1955
  });
1956
1956
  const localImports = allRefs.
1957
- filter(ref => ref.childType && typeMaps$5[ref.childType] === undefined).
1957
+ filter(ref => ref.childType && typeMaps$6[ref.childType] === undefined).
1958
1958
  map(ref => ref.childType).
1959
1959
  concat(getInheritanceTree(klass, allClasses, false).map(klass => klass.name)).
1960
1960
  filter(distinct$4).
@@ -1962,10 +1962,10 @@ function generateClass$5(klass, namespace, allClasses) {
1962
1962
  join("\n");
1963
1963
  return `${getCommentHeader()}
1964
1964
 
1965
- ${COMMON_IMPORTS$3}
1965
+ ${COMMON_IMPORTS$4}
1966
1966
  ${localImports}
1967
1967
 
1968
- ${generateClassBody$5(klass)}
1968
+ ${generateClassBody$6(klass)}
1969
1969
 
1970
1970
  export default ${klass.name};
1971
1971
  `;
@@ -2015,13 +2015,13 @@ function generatePropertyInitializer(prop) {
2015
2015
 
2016
2016
  var js = /*#__PURE__*/Object.freeze({
2017
2017
  __proto__: null,
2018
- generate: generate$6,
2019
- name: name$5,
2020
- renderBundle: renderBundle$5
2018
+ generate: generate$7,
2019
+ name: name$6,
2020
+ renderBundle: renderBundle$6
2021
2021
  });
2022
2022
 
2023
- const name$4 = "Java";
2024
- const typeMaps$4 = {
2023
+ const name$5 = "Java";
2024
+ const typeMaps$5 = {
2025
2025
  "string": "String",
2026
2026
  "number": "float",
2027
2027
  "boolean": "boolean",
@@ -2051,7 +2051,7 @@ const typeInitializer = {
2051
2051
  "float32": "0",
2052
2052
  "float64": "0",
2053
2053
  };
2054
- const COMMON_IMPORTS$2 = `import io.colyseus.serializer.schema.Schema;
2054
+ const COMMON_IMPORTS$3 = `import io.colyseus.serializer.schema.Schema;
2055
2055
  import io.colyseus.serializer.schema.annotations.SchemaClass;
2056
2056
  import io.colyseus.serializer.schema.annotations.SchemaField;`;
2057
2057
  /**
@@ -2060,7 +2060,7 @@ import io.colyseus.serializer.schema.annotations.SchemaField;`;
2060
2060
  /**
2061
2061
  * Generate individual files for each class
2062
2062
  */
2063
- function generate$5(context, options) {
2063
+ function generate$6(context, options) {
2064
2064
  return context.classes.map(klass => ({
2065
2065
  name: klass.name + ".java",
2066
2066
  content: generateClass$4(klass, options.namespace)
@@ -2071,13 +2071,13 @@ function generate$5(context, options) {
2071
2071
  * Note: Java typically requires one public class per file, so bundled mode
2072
2072
  * generates all classes in a single file with package-private visibility
2073
2073
  */
2074
- function renderBundle$4(context, options) {
2074
+ function renderBundle$5(context, options) {
2075
2075
  const fileName = options.namespace ? `Schema.java` : "Schema.java";
2076
- const classBodies = context.classes.map(klass => generateClassBody$4(klass));
2076
+ const classBodies = context.classes.map(klass => generateClassBody$5(klass));
2077
2077
  const content = `${getCommentHeader()}
2078
2078
  ${options.namespace ? `\npackage ${options.namespace};` : ""}
2079
2079
 
2080
- ${COMMON_IMPORTS$2}
2080
+ ${COMMON_IMPORTS$3}
2081
2081
 
2082
2082
  ${classBodies.join("\n\n")}
2083
2083
  `;
@@ -2086,10 +2086,10 @@ ${classBodies.join("\n\n")}
2086
2086
  /**
2087
2087
  * Generate just the class body (without package/imports) for bundling
2088
2088
  */
2089
- function generateClassBody$4(klass) {
2089
+ function generateClassBody$5(klass) {
2090
2090
  return `@SchemaClass
2091
2091
  class ${klass.name} extends ${klass.extends} {
2092
- ${klass.properties.map(prop => generateProperty(prop, "")).join("\n\n")}
2092
+ ${klass.properties.map(prop => generateProperty$1(prop, "")).join("\n\n")}
2093
2093
  }`;
2094
2094
  }
2095
2095
  /**
@@ -2100,16 +2100,16 @@ function generateClass$4(klass, namespace) {
2100
2100
  return `${getCommentHeader()}
2101
2101
  ${namespace ? `\npackage ${namespace};` : ""}
2102
2102
 
2103
- ${COMMON_IMPORTS$2}
2103
+ ${COMMON_IMPORTS$3}
2104
2104
 
2105
2105
  @SchemaClass
2106
2106
  ${indent}public class ${klass.name} extends ${klass.extends} {
2107
- ${klass.properties.map(prop => generateProperty(prop, indent)).join("\n\n")}
2107
+ ${klass.properties.map(prop => generateProperty$1(prop, indent)).join("\n\n")}
2108
2108
  ${indent}}
2109
2109
  ${namespace ? "}" : ""}
2110
2110
  `;
2111
2111
  }
2112
- function generateProperty(prop, indent = "") {
2112
+ function generateProperty$1(prop, indent = "") {
2113
2113
  let typeArgs = `${prop.index}/${prop.type}`;
2114
2114
  let property = "public";
2115
2115
  let langType;
@@ -2123,7 +2123,7 @@ function generateProperty(prop, indent = "") {
2123
2123
  if (prop.type === "ref") {
2124
2124
  langType = (isUpcaseFirst)
2125
2125
  ? prop.childType
2126
- : typeMaps$4[prop.childType];
2126
+ : typeMaps$5[prop.childType];
2127
2127
  initializer = `new ${langType}${(prop.type !== "ref" && isUpcaseFirst) ? "<>" : ""}(${ctorArgs})`;
2128
2128
  }
2129
2129
  else if (prop.type === "array") {
@@ -2145,7 +2145,7 @@ function generateProperty(prop, indent = "") {
2145
2145
  }
2146
2146
  }
2147
2147
  else {
2148
- langType = typeMaps$4[prop.type];
2148
+ langType = typeMaps$5[prop.type];
2149
2149
  initializer = typeInitializer[prop.type];
2150
2150
  }
2151
2151
  property += ` ${langType} ${prop.name}`;
@@ -2155,18 +2155,18 @@ function generateProperty(prop, indent = "") {
2155
2155
 
2156
2156
  var java = /*#__PURE__*/Object.freeze({
2157
2157
  __proto__: null,
2158
- generate: generate$5,
2159
- name: name$4,
2160
- renderBundle: renderBundle$4
2158
+ generate: generate$6,
2159
+ name: name$5,
2160
+ renderBundle: renderBundle$5
2161
2161
  });
2162
2162
 
2163
- const name$3 = "LUA";
2163
+ const name$4 = "LUA";
2164
2164
  /**
2165
2165
  TODO:
2166
2166
  - Support inheritance
2167
2167
  - Support importing Schema dependencies
2168
2168
  */
2169
- const typeMaps$3 = {
2169
+ const typeMaps$4 = {
2170
2170
  "string": "string",
2171
2171
  "number": "number",
2172
2172
  "boolean": "boolean",
@@ -2181,14 +2181,14 @@ const typeMaps$3 = {
2181
2181
  "float32": "number",
2182
2182
  "float64": "number",
2183
2183
  };
2184
- const COMMON_IMPORTS$1 = `local schema = require 'colyseus.serializer.schema.schema'`;
2184
+ const COMMON_IMPORTS$2 = `local schema = require 'colyseus.serializer.schema.schema'`;
2185
2185
  const QUANTIZE_IMPORT = `local quantize = require 'colyseus.serializer.schema.quantize'`;
2186
2186
  const distinct$3 = (value, index, self) => self.indexOf(value) === index;
2187
2187
  const hasQuantized = (classes) => classes.some(klass => klass.properties.some(prop => prop.quantized));
2188
2188
  /**
2189
2189
  * Generate individual files for each class
2190
2190
  */
2191
- function generate$4(context, options) {
2191
+ function generate$5(context, options) {
2192
2192
  return context.classes.map(klass => ({
2193
2193
  name: klass.name + ".lua",
2194
2194
  content: generateClass$3(klass, options.namespace, context.classes)
@@ -2197,13 +2197,13 @@ function generate$4(context, options) {
2197
2197
  /**
2198
2198
  * Generate a single bundled file containing all classes
2199
2199
  */
2200
- function renderBundle$3(context, options) {
2200
+ function renderBundle$4(context, options) {
2201
2201
  const fileName = options.namespace ? `${options.namespace}.lua` : "schema.lua";
2202
- const classBodies = context.classes.map(klass => generateClassBody$3(klass));
2202
+ const classBodies = context.classes.map(klass => generateClassBody$4(klass));
2203
2203
  const classNames = context.classes.map(klass => ` ${klass.name} = ${klass.name},`).join("\n");
2204
2204
  const content = `${getCommentHeader().replace(/\/\//mg, "--")}
2205
2205
 
2206
- ${COMMON_IMPORTS$1}${hasQuantized(context.classes) ? `\n${QUANTIZE_IMPORT}` : ""}
2206
+ ${COMMON_IMPORTS$2}${hasQuantized(context.classes) ? `\n${QUANTIZE_IMPORT}` : ""}
2207
2207
 
2208
2208
  ${classBodies.join("\n\n")}
2209
2209
 
@@ -2216,7 +2216,7 @@ ${classNames}
2216
2216
  /**
2217
2217
  * Generate just the class body (without requires) for bundling
2218
2218
  */
2219
- function generateClassBody$3(klass) {
2219
+ function generateClassBody$4(klass) {
2220
2220
  // Inheritance support
2221
2221
  const inherits = (klass.extends !== "Schema")
2222
2222
  ? `, ${klass.extends}`
@@ -2241,7 +2241,7 @@ function generateClass$3(klass, namespace, allClasses) {
2241
2241
  }
2242
2242
  });
2243
2243
  const localRequires = allRefs.
2244
- filter(ref => ref.childType && typeMaps$3[ref.childType] === undefined).
2244
+ filter(ref => ref.childType && typeMaps$4[ref.childType] === undefined).
2245
2245
  map(ref => ref.childType).
2246
2246
  concat(getInheritanceTree(klass, allClasses, false).map(klass => klass.name)).
2247
2247
  filter(distinct$3).
@@ -2249,10 +2249,10 @@ function generateClass$3(klass, namespace, allClasses) {
2249
2249
  join("\n");
2250
2250
  return `${getCommentHeader().replace(/\/\//mg, "--")}
2251
2251
 
2252
- ${COMMON_IMPORTS$1}${hasQuantized([klass]) ? `\n${QUANTIZE_IMPORT}` : ""}
2252
+ ${COMMON_IMPORTS$2}${hasQuantized([klass]) ? `\n${QUANTIZE_IMPORT}` : ""}
2253
2253
  ${localRequires}
2254
2254
 
2255
- ${generateClassBody$3(klass)}
2255
+ ${generateClassBody$4(klass)}
2256
2256
 
2257
2257
  return ${klass.name}
2258
2258
  `;
@@ -2302,22 +2302,22 @@ function getLUATypeAnnotation(prop) {
2302
2302
  return "MapSchema";
2303
2303
  }
2304
2304
  else {
2305
- return typeMaps$3[prop.type];
2305
+ return typeMaps$4[prop.type];
2306
2306
  }
2307
2307
  }
2308
2308
 
2309
2309
  var lua = /*#__PURE__*/Object.freeze({
2310
2310
  __proto__: null,
2311
- generate: generate$4,
2312
- name: name$3,
2313
- renderBundle: renderBundle$3
2311
+ generate: generate$5,
2312
+ name: name$4,
2313
+ renderBundle: renderBundle$4
2314
2314
  });
2315
2315
 
2316
- const name$2 = "C";
2316
+ const name$3 = "C";
2317
2317
  /**
2318
2318
  * Type mappings for C
2319
2319
  */
2320
- const typeMaps$2 = {
2320
+ const typeMaps$3 = {
2321
2321
  "string": "char*",
2322
2322
  "number": "double",
2323
2323
  "boolean": "bool",
@@ -2370,7 +2370,7 @@ const distinct$2 = (value, index, self) => self.indexOf(value) === index;
2370
2370
  /**
2371
2371
  * Generate individual files for each class
2372
2372
  */
2373
- function generate$3(context, options) {
2373
+ function generate$4(context, options) {
2374
2374
  return context.classes.map(klass => ({
2375
2375
  name: toSnakeCase(klass.name) + ".h",
2376
2376
  content: generateClass$2(klass, options.namespace, context.classes)
@@ -2379,10 +2379,10 @@ function generate$3(context, options) {
2379
2379
  /**
2380
2380
  * Generate a single bundled header file containing all classes
2381
2381
  */
2382
- function renderBundle$2(context, options) {
2382
+ function renderBundle$3(context, options) {
2383
2383
  const fileName = options.namespace ? `${toSnakeCase(options.namespace)}.h` : "schema.h";
2384
2384
  const guardName = `__SCHEMA_CODEGEN_${(options.namespace || "SCHEMA").toUpperCase()}_H__`;
2385
- const classBodies = context.classes.map(klass => generateClassBody$2(klass, context.classes)).join("\n\n");
2385
+ const classBodies = context.classes.map(klass => generateClassBody$3(klass, context.classes)).join("\n\n");
2386
2386
  const content = `${getCommentHeader()}
2387
2387
  #ifndef ${guardName}
2388
2388
  #define ${guardName} 1
@@ -2398,7 +2398,7 @@ ${classBodies}
2398
2398
  /**
2399
2399
  * Generate just the class body (without guards/includes) for bundling
2400
2400
  */
2401
- function generateClassBody$2(klass, allClasses) {
2401
+ function generateClassBody$3(klass, allClasses) {
2402
2402
  const snakeName = toSnakeCase(klass.name);
2403
2403
  const typeName = `${snakeName}_t`;
2404
2404
  const allProperties = getAllProperties(klass, allClasses);
@@ -2426,7 +2426,7 @@ function generateClass$2(klass, namespace, allClasses) {
2426
2426
  });
2427
2427
  // Generate includes for referenced schema types
2428
2428
  const refIncludes = allRefs
2429
- .filter(ref => ref.childType && typeMaps$2[ref.childType] === undefined)
2429
+ .filter(ref => ref.childType && typeMaps$3[ref.childType] === undefined)
2430
2430
  .map(ref => ref.childType)
2431
2431
  .concat(getInheritanceTree(klass, allClasses, false).map(k => k.name))
2432
2432
  .filter(distinct$2)
@@ -2438,7 +2438,7 @@ function generateClass$2(klass, namespace, allClasses) {
2438
2438
 
2439
2439
  ${COMMON_INCLUDES}
2440
2440
  ${refIncludes ? `\n${refIncludes}\n` : ""}
2441
- ${generateClassBody$2(klass, allClasses)}
2441
+ ${generateClassBody$3(klass, allClasses)}
2442
2442
 
2443
2443
  #endif
2444
2444
  `;
@@ -2459,7 +2459,7 @@ function getCType(prop) {
2459
2459
  return `${toSnakeCase(prop.childType)}_t*`;
2460
2460
  }
2461
2461
  else if (prop.type === "array") {
2462
- if (typeMaps$2[prop.childType]) {
2462
+ if (typeMaps$3[prop.childType]) {
2463
2463
  return `colyseus_array_schema_t*`;
2464
2464
  }
2465
2465
  else {
@@ -2467,7 +2467,7 @@ function getCType(prop) {
2467
2467
  }
2468
2468
  }
2469
2469
  else if (prop.type === "map") {
2470
- if (typeMaps$2[prop.childType]) {
2470
+ if (typeMaps$3[prop.childType]) {
2471
2471
  return `colyseus_map_schema_t*`;
2472
2472
  }
2473
2473
  else {
@@ -2475,7 +2475,7 @@ function getCType(prop) {
2475
2475
  }
2476
2476
  }
2477
2477
  else {
2478
- return typeMaps$2[prop.type] || `${toSnakeCase(prop.type)}_t*`;
2478
+ return typeMaps$3[prop.type] || `${toSnakeCase(prop.type)}_t*`;
2479
2479
  }
2480
2480
  }
2481
2481
  function getFieldType(prop) {
@@ -2503,11 +2503,11 @@ function generateFieldsArray(klass, typeName, snakeName, allProperties) {
2503
2503
  let vtableRef = "NULL";
2504
2504
  let childPrimitiveRef = "NULL";
2505
2505
  let quantizedRef = "NULL";
2506
- if (prop.type === "ref" && prop.childType && !typeMaps$2[prop.childType]) {
2506
+ if (prop.type === "ref" && prop.childType && !typeMaps$3[prop.childType]) {
2507
2507
  const childSnake = toSnakeCase(prop.childType);
2508
2508
  vtableRef = `&${childSnake}_vtable`;
2509
2509
  }
2510
- else if ((prop.type === "array" || prop.type === "map") && prop.childType && !typeMaps$2[prop.childType]) {
2510
+ else if ((prop.type === "array" || prop.type === "map") && prop.childType && !typeMaps$3[prop.childType]) {
2511
2511
  const childSnake = toSnakeCase(prop.childType);
2512
2512
  vtableRef = `&${childSnake}_vtable`;
2513
2513
  }
@@ -2537,7 +2537,7 @@ function generateDestroyFunction(klass, snakeName, typeName, allProperties) {
2537
2537
  freeStatements.push(` if (instance->${prop.name}) free(instance->${prop.name});`);
2538
2538
  }
2539
2539
  else if (prop.type === "ref") {
2540
- if (typeMaps$2[prop.childType]) {
2540
+ if (typeMaps$3[prop.childType]) {
2541
2541
  freeStatements.push(` if (instance->${prop.name}) free(instance->${prop.name});`);
2542
2542
  }
2543
2543
  else {
@@ -2574,16 +2574,16 @@ function getAllProperties(klass, allClasses) {
2574
2574
 
2575
2575
  var c = /*#__PURE__*/Object.freeze({
2576
2576
  __proto__: null,
2577
- generate: generate$3,
2578
- name: name$2,
2579
- renderBundle: renderBundle$2
2577
+ generate: generate$4,
2578
+ name: name$3,
2579
+ renderBundle: renderBundle$3
2580
2580
  });
2581
2581
 
2582
- const name$1 = "GDScript";
2582
+ const name$2 = "GDScript";
2583
2583
  /**
2584
2584
  * Type mappings from schema types to GDScript Colyseus.Schema type constants
2585
2585
  */
2586
- const typeMaps$1 = {
2586
+ const typeMaps$2 = {
2587
2587
  "string": "Colyseus.Schema.STRING",
2588
2588
  "number": "Colyseus.Schema.NUMBER",
2589
2589
  "boolean": "Colyseus.Schema.BOOLEAN",
@@ -2610,10 +2610,10 @@ const distinct$1 = (value, index, self) => self.indexOf(value) === index;
2610
2610
  /**
2611
2611
  * Generate individual files for each class
2612
2612
  */
2613
- function generate$2(context, options) {
2613
+ function generate$3(context, options) {
2614
2614
  // Enrich typeMaps with enums
2615
2615
  context.enums.forEach((structure) => {
2616
- typeMaps$1[structure.name] = structure.name;
2616
+ typeMaps$2[structure.name] = structure.name;
2617
2617
  });
2618
2618
  return [
2619
2619
  ...context.classes.map(klass => ({
@@ -2629,16 +2629,16 @@ function generate$2(context, options) {
2629
2629
  /**
2630
2630
  * Generate a single bundled file containing all classes and enums
2631
2631
  */
2632
- function renderBundle$1(context, options) {
2632
+ function renderBundle$2(context, options) {
2633
2633
  const fileName = options.namespace ? `${options.namespace}.gd` : "schema.gd";
2634
2634
  // Enrich typeMaps with enums
2635
2635
  context.enums.forEach((structure) => {
2636
- typeMaps$1[structure.name] = structure.name;
2636
+ typeMaps$2[structure.name] = structure.name;
2637
2637
  });
2638
2638
  const enumBodies = context.enums
2639
2639
  .filter(structure => structure.name !== 'OPERATION')
2640
- .map(e => generateEnumBody$1(e));
2641
- const classBodies = context.classes.map(klass => generateClassBody$1(klass));
2640
+ .map(e => generateEnumBody$2(e));
2641
+ const classBodies = context.classes.map(klass => generateClassBody$2(klass));
2642
2642
  const content = `${getCommentHeader("#")}
2643
2643
 
2644
2644
  ${enumBodies.length > 0 ? enumBodies.join("\n\n") + "\n\n" : ""}${classBodies.join("\n\n")}
@@ -2648,7 +2648,7 @@ ${enumBodies.length > 0 ? enumBodies.join("\n\n") + "\n\n" : ""}${classBodies.jo
2648
2648
  /**
2649
2649
  * Generate just the class body (without preload) for bundling
2650
2650
  */
2651
- function generateClassBody$1(klass) {
2651
+ function generateClassBody$2(klass) {
2652
2652
  // Determine parent class
2653
2653
  const parentClass = (klass.extends !== "Schema")
2654
2654
  ? klass.extends
@@ -2693,7 +2693,7 @@ function generateClass$1(klass, namespace, allClasses) {
2693
2693
  });
2694
2694
  // Get required preloads for referenced types
2695
2695
  const preloads = allRefs
2696
- .filter(ref => ref.childType && typeMaps$1[ref.childType] === undefined)
2696
+ .filter(ref => ref.childType && typeMaps$2[ref.childType] === undefined)
2697
2697
  .map(ref => ref.childType)
2698
2698
  .concat(getInheritanceTree(klass, allClasses, false).map(klass => klass.name))
2699
2699
  .filter(distinct$1)
@@ -2701,7 +2701,7 @@ function generateClass$1(klass, namespace, allClasses) {
2701
2701
  .join("\n");
2702
2702
  return `${getCommentHeader("#")}
2703
2703
 
2704
- ${preloads ? preloads + "\n\n" : ""}${generateClassBody$1(klass)}
2704
+ ${preloads ? preloads + "\n\n" : ""}${generateClassBody$2(klass)}
2705
2705
  `;
2706
2706
  }
2707
2707
  /**
@@ -2713,12 +2713,12 @@ function generateFieldDefinition(prop) {
2713
2713
  const isUpcaseFirst = prop.childType.match(/^[A-Z]/);
2714
2714
  // Array or Map container
2715
2715
  const containerType = containerMaps[prop.type];
2716
- const childTypeRef = isUpcaseFirst ? prop.childType : typeMaps$1[prop.childType] || `"${prop.childType}"`;
2716
+ const childTypeRef = isUpcaseFirst ? prop.childType : typeMaps$2[prop.childType] || `"${prop.childType}"`;
2717
2717
  args = [`"${prop.name}"`, containerType, childTypeRef];
2718
2718
  }
2719
2719
  else {
2720
2720
  // Primitive type
2721
- const typeRef = typeMaps$1[prop.type] || `"${prop.type}"`;
2721
+ const typeRef = typeMaps$2[prop.type] || `"${prop.type}"`;
2722
2722
  args = [`"${prop.name}"`, typeRef];
2723
2723
  }
2724
2724
  return `\t\t\tColyseus.Schema.Field.new(${args.join(", ")})`;
@@ -2726,7 +2726,7 @@ function generateFieldDefinition(prop) {
2726
2726
  /**
2727
2727
  * Generate just the enum body for bundling
2728
2728
  */
2729
- function generateEnumBody$1(_enum) {
2729
+ function generateEnumBody$2(_enum) {
2730
2730
  const enumValues = _enum.properties.map((prop, index) => {
2731
2731
  let value;
2732
2732
  if (prop.type) {
@@ -2752,24 +2752,24 @@ ${enumValues}
2752
2752
  function generateEnum$1(_enum, _namespace) {
2753
2753
  return `${getCommentHeader("#")}
2754
2754
 
2755
- ${generateEnumBody$1(_enum)}
2755
+ ${generateEnumBody$2(_enum)}
2756
2756
  `;
2757
2757
  }
2758
2758
 
2759
2759
  var gdscript = /*#__PURE__*/Object.freeze({
2760
2760
  __proto__: null,
2761
- generate: generate$2,
2762
- name: name$1,
2763
- renderBundle: renderBundle$1
2761
+ generate: generate$3,
2762
+ name: name$2,
2763
+ renderBundle: renderBundle$2
2764
2764
  });
2765
2765
 
2766
- const name = "Dart/Flutter";
2766
+ const name$1 = "Dart/Flutter";
2767
2767
  /**
2768
2768
  * Dart types for interface (plain message) properties. Schema scalar getters
2769
2769
  * don't use this table: the `colyseus` package reads every numeric field as
2770
2770
  * `double` through `SchemaView`, so all numeric schema types collapse there.
2771
2771
  */
2772
- const typeMaps = {
2772
+ const typeMaps$1 = {
2773
2773
  "string": "String",
2774
2774
  "number": "double",
2775
2775
  "boolean": "bool",
@@ -2784,12 +2784,12 @@ const typeMaps = {
2784
2784
  "float32": "double",
2785
2785
  "float64": "double",
2786
2786
  };
2787
- const enumNames = new Set();
2788
- const COMMON_IMPORTS = `import 'package:colyseus/colyseus.dart';`;
2787
+ const enumNames$1 = new Set();
2788
+ const COMMON_IMPORTS$1 = `import 'package:colyseus/colyseus.dart';`;
2789
2789
  // Field names come from the server schema and may not be lowerCamelCase.
2790
2790
  const LINT_HEADER = `// ignore_for_file: non_constant_identifier_names, constant_identifier_names`;
2791
2791
  const distinct = (value, index, self) => self.indexOf(value) === index;
2792
- const isSchemaType = (childType) => childType !== undefined && /^[A-Z]/.test(childType) && !enumNames.has(childType);
2792
+ const isSchemaType$1 = (childType) => childType !== undefined && /^[A-Z]/.test(childType) && !enumNames$1.has(childType);
2793
2793
  /**
2794
2794
  * Dart Code Generator
2795
2795
  *
@@ -2802,8 +2802,8 @@ const isSchemaType = (childType) => childType !== undefined && /^[A-Z]/.test(chi
2802
2802
  /**
2803
2803
  * Generate individual files for each class/interface/enum
2804
2804
  */
2805
- function generate$1(context, options) {
2806
- context.enums.forEach((structure) => enumNames.add(structure.name));
2805
+ function generate$2(context, options) {
2806
+ context.enums.forEach((structure) => enumNames$1.add(structure.name));
2807
2807
  return [
2808
2808
  ...context.classes.map(klass => ({
2809
2809
  name: `${klass.name}.dart`,
@@ -2822,20 +2822,20 @@ function generate$1(context, options) {
2822
2822
  /**
2823
2823
  * Generate a single bundled file containing all classes, interfaces, and enums
2824
2824
  */
2825
- function renderBundle(context, options) {
2825
+ function renderBundle$1(context, options) {
2826
2826
  const fileName = options.namespace ? `${options.namespace}.dart` : "schema.dart";
2827
- context.enums.forEach((structure) => enumNames.add(structure.name));
2827
+ context.enums.forEach((structure) => enumNames$1.add(structure.name));
2828
2828
  const bodies = [
2829
- ...context.classes.map(klass => generateClassBody(klass, context.classes)),
2830
- ...context.interfaces.map(iface => generateInterfaceBody(iface)),
2829
+ ...context.classes.map(klass => generateClassBody$1(klass, context.classes)),
2830
+ ...context.interfaces.map(iface => generateInterfaceBody$1(iface)),
2831
2831
  ...context.enums
2832
2832
  .filter(structure => structure.name !== 'OPERATION')
2833
- .map(e => generateEnumBody(e)),
2833
+ .map(e => generateEnumBody$1(e)),
2834
2834
  ].join("\n\n");
2835
2835
  const content = `${getCommentHeader()}
2836
2836
  ${LINT_HEADER}
2837
2837
 
2838
- ${COMMON_IMPORTS}
2838
+ ${COMMON_IMPORTS$1}
2839
2839
 
2840
2840
  ${bodies}
2841
2841
  `;
@@ -2844,7 +2844,7 @@ ${bodies}
2844
2844
  /**
2845
2845
  * Generate just the class body (without imports) for bundling
2846
2846
  */
2847
- function generateClassBody(klass, allClasses) {
2847
+ function generateClassBody$1(klass, allClasses) {
2848
2848
  // `SchemaRef` is a `base` class, so subclasses carry a modifier: `base`
2849
2849
  // when the class is itself extended (extendable from any file), `final`
2850
2850
  // otherwise.
@@ -2866,7 +2866,7 @@ ${getters}
2866
2866
  */
2867
2867
  function generateClass(klass, allClasses) {
2868
2868
  const localRefs = klass.properties
2869
- .filter(prop => isSchemaType(prop.childType))
2869
+ .filter(prop => isSchemaType$1(prop.childType))
2870
2870
  .map(prop => prop.childType)
2871
2871
  .concat(klass.extends !== "Schema" ? [klass.extends] : [])
2872
2872
  .filter(distinct)
@@ -2876,9 +2876,9 @@ function generateClass(klass, allClasses) {
2876
2876
  return `${getCommentHeader()}
2877
2877
  ${LINT_HEADER}
2878
2878
 
2879
- ${COMMON_IMPORTS}
2879
+ ${COMMON_IMPORTS$1}
2880
2880
  ${localRefs ? localRefs + "\n" : ""}
2881
- ${generateClassBody(klass, allClasses)}
2881
+ ${generateClassBody$1(klass, allClasses)}
2882
2882
  `;
2883
2883
  }
2884
2884
  /**
@@ -2892,7 +2892,7 @@ function scalarDartType(type) {
2892
2892
  if (type === "boolean") {
2893
2893
  return "bool";
2894
2894
  }
2895
- if (typeMaps[type] === "double" || type === "quantized" || type === "number") {
2895
+ if (typeMaps$1[type] === "double" || type === "quantized" || type === "number") {
2896
2896
  return "double";
2897
2897
  }
2898
2898
  return undefined;
@@ -2902,7 +2902,7 @@ function generateGetter(prop) {
2902
2902
  ? ` @Deprecated("field '${prop.name}' is deprecated.")\n`
2903
2903
  : '';
2904
2904
  let body;
2905
- if (prop.childType && isSchemaType(prop.childType)) {
2905
+ if (prop.childType && isSchemaType$1(prop.childType)) {
2906
2906
  if (prop.type === "ref") {
2907
2907
  body = ` ${prop.childType}? get ${prop.name} => refOf('${prop.name}', ${prop.childType}.new);`;
2908
2908
  }
@@ -2914,7 +2914,7 @@ function generateGetter(prop) {
2914
2914
  }
2915
2915
  }
2916
2916
  else if (prop.childType) {
2917
- const child = typeMaps[prop.childType] ?? "dynamic";
2917
+ const child = typeMaps$1[prop.childType] ?? "dynamic";
2918
2918
  if (prop.type === "map") {
2919
2919
  body = ` MapSchema<${child}> get ${prop.name} => primitiveMapOf('${prop.name}');`;
2920
2920
  }
@@ -2947,9 +2947,9 @@ function generateGetter(prop) {
2947
2947
  /**
2948
2948
  * Generate just the interface body for bundling
2949
2949
  */
2950
- function generateInterfaceBody(struct) {
2950
+ function generateInterfaceBody$1(struct) {
2951
2951
  const fields = struct.properties
2952
- .map(prop => ` ${getInterfaceType(prop)}? ${prop.name};`)
2952
+ .map(prop => ` ${getInterfaceType$1(prop)}? ${prop.name};`)
2953
2953
  .join("\n");
2954
2954
  return `class ${struct.name} {
2955
2955
  ${fields}
@@ -2960,7 +2960,7 @@ ${fields}
2960
2960
  */
2961
2961
  function generateInterface(struct) {
2962
2962
  const localRefs = struct.properties
2963
- .filter(prop => isSchemaType(prop.childType ?? (typeMaps[prop.type] ? undefined : prop.type)))
2963
+ .filter(prop => isSchemaType$1(prop.childType ?? (typeMaps$1[prop.type] ? undefined : prop.type)))
2964
2964
  .map(prop => prop.childType ?? prop.type)
2965
2965
  .filter(distinct)
2966
2966
  .map(ref => `import '${ref}.dart';`)
@@ -2968,20 +2968,20 @@ function generateInterface(struct) {
2968
2968
  return `${getCommentHeader()}
2969
2969
  ${LINT_HEADER}
2970
2970
  ${localRefs ? "\n" + localRefs + "\n" : ""}
2971
- ${generateInterfaceBody(struct)}
2971
+ ${generateInterfaceBody$1(struct)}
2972
2972
  `;
2973
2973
  }
2974
- function getInterfaceType(prop) {
2974
+ function getInterfaceType$1(prop) {
2975
2975
  if (prop.type === "array") {
2976
- return `List<${typeMaps[prop.childType] ?? prop.childType ?? "dynamic"}>`;
2976
+ return `List<${typeMaps$1[prop.childType] ?? prop.childType ?? "dynamic"}>`;
2977
2977
  }
2978
- return typeMaps[prop.type] ?? prop.type ?? "dynamic";
2978
+ return typeMaps$1[prop.type] ?? prop.type ?? "dynamic";
2979
2979
  }
2980
2980
  /**
2981
2981
  * Generate just the enum body for bundling: a namespace of consts, since
2982
2982
  * Colyseus enums may carry string or float values Dart enums can't.
2983
2983
  */
2984
- function generateEnumBody(_enum) {
2984
+ function generateEnumBody$1(_enum) {
2985
2985
  const members = _enum.properties
2986
2986
  .map((prop, i) => {
2987
2987
  let value;
@@ -3005,18 +3005,265 @@ function generateEnum(_enum) {
3005
3005
  return `${getCommentHeader()}
3006
3006
  ${LINT_HEADER}
3007
3007
 
3008
- ${generateEnumBody(_enum)}
3008
+ ${generateEnumBody$1(_enum)}
3009
3009
  `;
3010
3010
  }
3011
3011
 
3012
3012
  var dart = /*#__PURE__*/Object.freeze({
3013
+ __proto__: null,
3014
+ generate: generate$2,
3015
+ name: name$1,
3016
+ renderBundle: renderBundle$1
3017
+ });
3018
+
3019
+ const name = "Swift";
3020
+ /**
3021
+ * Swift types for interface (plain message) properties. Schema getters do not
3022
+ * use this table: the `Colyseus` package reads every numeric field as `Double`
3023
+ * through `SchemaView`, so all numeric schema types collapse there.
3024
+ */
3025
+ const typeMaps = {
3026
+ "string": "String",
3027
+ "number": "Double",
3028
+ "boolean": "Bool",
3029
+ "int8": "Int",
3030
+ "uint8": "Int",
3031
+ "int16": "Int",
3032
+ "uint16": "Int",
3033
+ "int32": "Int",
3034
+ "uint32": "Int",
3035
+ "int64": "Int",
3036
+ "uint64": "Int",
3037
+ "float32": "Double",
3038
+ "float64": "Double",
3039
+ };
3040
+ const enumNames = new Set();
3041
+ const COMMON_IMPORTS = `import Colyseus`;
3042
+ const isSchemaType = (childType) => childType !== undefined && /^[A-Z]/.test(childType) && !enumNames.has(childType);
3043
+ /**
3044
+ * Swift Code Generator
3045
+ *
3046
+ * Emits typed façades over the `Colyseus` package's runtime: one `SchemaRef`
3047
+ * subclass per schema, whose properties read through the shared handle on the
3048
+ * instance the core decoded. Nothing is copied and nothing is stored, so a
3049
+ * generated class stays correct as patches arrive.
3050
+ *
3051
+ * Collection properties return `MapSchema<T>` / `ArraySchema<T>`, which carry
3052
+ * the field they came from — that is what `callbacks.onAdd(state.players, …)`
3053
+ * registers against.
3054
+ */
3055
+ /**
3056
+ * Generate individual files for each class/interface/enum
3057
+ */
3058
+ function generate$1(context, options) {
3059
+ context.enums.forEach((structure) => enumNames.add(structure.name));
3060
+ return [
3061
+ ...context.classes.map(klass => ({
3062
+ name: `${klass.name}.swift`,
3063
+ content: generateFile(generateClassBody(klass, context.classes, !!options.namespace), options)
3064
+ })),
3065
+ ...context.interfaces.map(structure => ({
3066
+ name: `${structure.name}.swift`,
3067
+ content: generateFile(generateInterfaceBody(structure), options),
3068
+ })),
3069
+ ...context.enums.filter(structure => structure.name !== 'OPERATION').map((structure) => ({
3070
+ name: `${structure.name}.swift`,
3071
+ content: generateFile(generateEnumBody(structure), options),
3072
+ })),
3073
+ ];
3074
+ }
3075
+ /**
3076
+ * Generate a single bundled file containing all classes, interfaces, and enums
3077
+ */
3078
+ function renderBundle(context, options) {
3079
+ const fileName = options.namespace ? `${options.namespace}.swift` : "Schema.swift";
3080
+ context.enums.forEach((structure) => enumNames.add(structure.name));
3081
+ const bodies = [
3082
+ ...context.classes.map(klass => generateClassBody(klass, context.classes, !!options.namespace)),
3083
+ ...context.interfaces.map(iface => generateInterfaceBody(iface)),
3084
+ ...context.enums
3085
+ .filter(structure => structure.name !== 'OPERATION')
3086
+ .map(e => generateEnumBody(e)),
3087
+ ].join("\n\n");
3088
+ return { name: fileName, content: generateFile(bodies, options) };
3089
+ }
3090
+ /**
3091
+ * Swift has no namespaces, so one stands in as a caseless enum. Declarations
3092
+ * go inside it through an extension, which works the same whether they are
3093
+ * bundled into one file or split across many.
3094
+ */
3095
+ function generateFile(body, options) {
3096
+ const header = `${getCommentHeader()}
3097
+
3098
+ ${COMMON_IMPORTS}
3099
+ `;
3100
+ if (!options.namespace) {
3101
+ return `${header}
3102
+ ${body}
3103
+ `;
3104
+ }
3105
+ return `${header}
3106
+ public enum ${options.namespace} {}
3107
+
3108
+ extension ${options.namespace} {
3109
+ ${indent(body)}
3110
+ }
3111
+ `;
3112
+ }
3113
+ function indent(text) {
3114
+ return text
3115
+ .split("\n")
3116
+ .map(line => (line.length > 0 ? ` ${line}` : line))
3117
+ .join("\n");
3118
+ }
3119
+ function generateClassBody(klass, allClasses, namespaced) {
3120
+ // A class nobody extends is final. One that is extended stays open so a
3121
+ // consumer in another module can subclass it — except inside a namespace,
3122
+ // where `open` conflicts with the extension's own access level and the
3123
+ // subclass is generated alongside it anyway.
3124
+ const isExtended = allClasses.some(other => other.extends === klass.name);
3125
+ const modifier = isExtended ? (namespaced ? "public" : "open") : "public final";
3126
+ const parent = (klass.extends === "Schema") ? "SchemaRef" : klass.extends;
3127
+ const properties = klass.properties
3128
+ .map(prop => generateProperty(prop))
3129
+ .filter(Boolean)
3130
+ .join("\n");
3131
+ // Swift does not carry an `@unchecked Sendable` conformance across module
3132
+ // boundaries, so every subclass has to restate it. What it asserts is the
3133
+ // SDK's own contract: decoded state is read where it is pumped.
3134
+ return `${modifier} class ${klass.name}: ${parent}, @unchecked Sendable {
3135
+ ${properties}
3136
+ }`;
3137
+ }
3138
+ /**
3139
+ * The Swift type a scalar schema field reads as, or undefined when the field
3140
+ * can only be read dynamically (enum-typed and unknown types).
3141
+ */
3142
+ function scalarSwiftType(type) {
3143
+ if (type === "string") {
3144
+ return "String";
3145
+ }
3146
+ if (type === "boolean") {
3147
+ return "Bool";
3148
+ }
3149
+ if (typeMaps[type] === "Double" || typeMaps[type] === "Int" || type === "quantized" || type === "number") {
3150
+ return "Double";
3151
+ }
3152
+ return undefined;
3153
+ }
3154
+ function generateProperty(prop) {
3155
+ const deprecation = (prop.deprecated)
3156
+ ? ` @available(*, deprecated, message: "field '${prop.name}' is deprecated.")\n`
3157
+ : '';
3158
+ const escaped = escapeName(prop.name);
3159
+ let body;
3160
+ if (prop.childType && isSchemaType(prop.childType)) {
3161
+ if (prop.type === "ref") {
3162
+ body = ` public var ${escaped}: ${prop.childType}? { refOf("${prop.name}") }`;
3163
+ }
3164
+ else if (prop.type === "map") {
3165
+ body = ` public var ${escaped}: MapSchema<${prop.childType}> { mapOf("${prop.name}") }`;
3166
+ }
3167
+ else {
3168
+ body = ` public var ${escaped}: ArraySchema<${prop.childType}> { arrayOf("${prop.name}") }`;
3169
+ }
3170
+ }
3171
+ else if (prop.childType) {
3172
+ // A collection of primitives. Everything numeric reads as Double, the
3173
+ // same collapse the scalar getters make.
3174
+ const child = typeMaps[prop.childType] === "String" ? "String" : "Double";
3175
+ if (prop.type === "map") {
3176
+ body = ` public var ${escaped}: MapSchema<${child}> { mapOf("${prop.name}") }`;
3177
+ }
3178
+ else if (prop.type === "array") {
3179
+ body = ` public var ${escaped}: ArraySchema<${child}> { arrayOf("${prop.name}") }`;
3180
+ }
3181
+ else {
3182
+ // A "ref" with a primitive child has no typed shape to offer.
3183
+ body = ` public var ${escaped}: Double { view["${prop.name}"] }`;
3184
+ }
3185
+ }
3186
+ else {
3187
+ const swiftType = scalarSwiftType(prop.type);
3188
+ if (swiftType === "String") {
3189
+ body = ` public var ${escaped}: String { view.string("${prop.name}") ?? "" }`;
3190
+ }
3191
+ else if (swiftType === "Bool") {
3192
+ body = ` public var ${escaped}: Bool { view.bool("${prop.name}") }`;
3193
+ }
3194
+ else if (swiftType === "Double") {
3195
+ body = ` public var ${escaped}: Double { view["${prop.name}"] }`;
3196
+ }
3197
+ else {
3198
+ // Enum-typed or unknown: read as the number the wire carries.
3199
+ body = ` public var ${escaped}: Double { view["${prop.name}"] }`;
3200
+ }
3201
+ }
3202
+ return deprecation + body;
3203
+ }
3204
+ /**
3205
+ * Message payloads are plain structs rather than façades: they arrive as
3206
+ * msgpack, not as decoded schema state.
3207
+ */
3208
+ function generateInterfaceBody(struct) {
3209
+ const fields = struct.properties
3210
+ .map(prop => ` public var ${escapeName(prop.name)}: ${getInterfaceType(prop)}?`)
3211
+ .join("\n");
3212
+ return `public struct ${struct.name}: Codable {
3213
+ ${fields}
3214
+
3215
+ public init() {}
3216
+ }`;
3217
+ }
3218
+ function getInterfaceType(prop) {
3219
+ if (prop.type === "array") {
3220
+ return `[${typeMaps[prop.childType] ?? prop.childType ?? "Double"}]`;
3221
+ }
3222
+ return typeMaps[prop.type] ?? prop.type ?? "Double";
3223
+ }
3224
+ /**
3225
+ * A namespace of constants rather than a Swift enum: Colyseus enums may carry
3226
+ * string or floating-point values, and a Swift enum's raw type has to be one
3227
+ * or the other.
3228
+ */
3229
+ function generateEnumBody(_enum) {
3230
+ const members = _enum.properties
3231
+ .map((prop, i) => {
3232
+ let value;
3233
+ if (prop.type) {
3234
+ value = isNaN(Number(prop.type)) ? `"${prop.type}"` : `${Number(prop.type)}`;
3235
+ }
3236
+ else {
3237
+ value = `${i}`;
3238
+ }
3239
+ return ` public static let ${escapeName(prop.name)} = ${value}`;
3240
+ })
3241
+ .join("\n");
3242
+ return `public enum ${_enum.name} {
3243
+ ${members}
3244
+ }`;
3245
+ }
3246
+ /** Field names come from the server schema and may collide with a keyword. */
3247
+ const SWIFT_KEYWORDS = new Set([
3248
+ "associatedtype", "class", "deinit", "enum", "extension", "fileprivate", "func", "import",
3249
+ "init", "inout", "internal", "let", "open", "operator", "private", "precedencegroup",
3250
+ "protocol", "public", "rethrows", "static", "struct", "subscript", "typealias", "var",
3251
+ "break", "case", "catch", "continue", "default", "defer", "do", "else", "fallthrough",
3252
+ "for", "guard", "if", "in", "repeat", "return", "throw", "switch", "where", "while",
3253
+ "Any", "as", "await", "false", "is", "nil", "self", "Self", "super", "throws", "true", "try",
3254
+ ]);
3255
+ function escapeName(name) {
3256
+ return SWIFT_KEYWORDS.has(name) ? `\`${name}\`` : name;
3257
+ }
3258
+
3259
+ var swift = /*#__PURE__*/Object.freeze({
3013
3260
  __proto__: null,
3014
3261
  generate: generate$1,
3015
3262
  name: name,
3016
3263
  renderBundle: renderBundle
3017
3264
  });
3018
3265
 
3019
- const generators = { csharp, cpp, haxe, ts, js, java, lua, c, gdscript, dart, };
3266
+ const generators = { csharp, cpp, haxe, ts, js, java, lua, c, gdscript, dart, swift, };
3020
3267
  function generate(targetId, options) {
3021
3268
  const generator = generators[targetId];
3022
3269
  if (!generator) {