@ts-for-gir/cli 4.0.0-beta.39 → 4.0.0-beta.40

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.
Files changed (2) hide show
  1. package/bin/ts-for-gir +49 -19
  2. package/package.json +10 -10
package/bin/ts-for-gir CHANGED
@@ -6596,7 +6596,7 @@ __export(parser_exports, {
6596
6596
  parseGir: () => parseGir
6597
6597
  });
6598
6598
 
6599
- // ../../.yarn/cache/fast-xml-parser-npm-5.4.1-48bbd2c631-2b40067c3a.zip/node_modules/fast-xml-parser/src/util.js
6599
+ // ../../.yarn/cache/fast-xml-parser-npm-5.4.2-dc824fc7a7-12585d5dd7.zip/node_modules/fast-xml-parser/src/util.js
6600
6600
  var nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
6601
6601
  var nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
6602
6602
  var nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
@@ -6624,7 +6624,7 @@ function isExist(v) {
6624
6624
  return typeof v !== "undefined";
6625
6625
  }
6626
6626
 
6627
- // ../../.yarn/cache/fast-xml-parser-npm-5.4.1-48bbd2c631-2b40067c3a.zip/node_modules/fast-xml-parser/src/validator.js
6627
+ // ../../.yarn/cache/fast-xml-parser-npm-5.4.2-dc824fc7a7-12585d5dd7.zip/node_modules/fast-xml-parser/src/validator.js
6628
6628
  var defaultOptions = {
6629
6629
  allowBooleanAttributes: false,
6630
6630
  //A tag can have attributes without any value
@@ -6930,7 +6930,7 @@ function getPositionFromMatch(match) {
6930
6930
  return match.startIndex + match[1].length;
6931
6931
  }
6932
6932
 
6933
- // ../../.yarn/cache/fast-xml-parser-npm-5.4.1-48bbd2c631-2b40067c3a.zip/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
6933
+ // ../../.yarn/cache/fast-xml-parser-npm-5.4.2-dc824fc7a7-12585d5dd7.zip/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
6934
6934
  var defaultOptions2 = {
6935
6935
  preserveOrder: false,
6936
6936
  attributeNamePrefix: "@_",
@@ -6987,6 +6987,7 @@ function normalizeProcessEntities(value) {
6987
6987
  maxExpansionDepth: 10,
6988
6988
  maxTotalExpansions: 1e3,
6989
6989
  maxExpandedLength: 1e5,
6990
+ maxEntityCount: 100,
6990
6991
  allowedTags: null,
6991
6992
  tagFilter: null
6992
6993
  };
@@ -6999,6 +7000,7 @@ function normalizeProcessEntities(value) {
6999
7000
  maxExpansionDepth: value.maxExpansionDepth ?? 10,
7000
7001
  maxTotalExpansions: value.maxTotalExpansions ?? 1e3,
7001
7002
  maxExpandedLength: value.maxExpandedLength ?? 1e5,
7003
+ maxEntityCount: value.maxEntityCount ?? 100,
7002
7004
  allowedTags: value.allowedTags ?? null,
7003
7005
  tagFilter: value.tagFilter ?? null
7004
7006
  };
@@ -7011,7 +7013,7 @@ var buildOptions = function(options2) {
7011
7013
  return built;
7012
7014
  };
7013
7015
 
7014
- // ../../.yarn/cache/fast-xml-parser-npm-5.4.1-48bbd2c631-2b40067c3a.zip/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
7016
+ // ../../.yarn/cache/fast-xml-parser-npm-5.4.2-dc824fc7a7-12585d5dd7.zip/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
7015
7017
  var METADATA_SYMBOL;
7016
7018
  if (typeof Symbol !== "function") {
7017
7019
  METADATA_SYMBOL = "@@xmlMetadata";
@@ -7045,7 +7047,7 @@ var XmlNode = class {
7045
7047
  }
7046
7048
  };
7047
7049
 
7048
- // ../../.yarn/cache/fast-xml-parser-npm-5.4.1-48bbd2c631-2b40067c3a.zip/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
7050
+ // ../../.yarn/cache/fast-xml-parser-npm-5.4.2-dc824fc7a7-12585d5dd7.zip/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
7049
7051
  var DocTypeReader = class {
7050
7052
  constructor(options2) {
7051
7053
  this.suppressValidationErr = !options2;
@@ -7053,6 +7055,7 @@ var DocTypeReader = class {
7053
7055
  }
7054
7056
  readDocType(xmlData, i) {
7055
7057
  const entities = /* @__PURE__ */ Object.create(null);
7058
+ let entityCount = 0;
7056
7059
  if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
7057
7060
  i = i + 9;
7058
7061
  let angleBracketsCount = 1;
@@ -7065,11 +7068,17 @@ var DocTypeReader = class {
7065
7068
  let entityName, val;
7066
7069
  [entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
7067
7070
  if (val.indexOf("&") === -1) {
7071
+ if (this.options.enabled !== false && this.options.maxEntityCount && entityCount >= this.options.maxEntityCount) {
7072
+ throw new Error(
7073
+ `Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
7074
+ );
7075
+ }
7068
7076
  const escaped = entityName.replace(/[.\-+*:]/g, "\\.");
7069
7077
  entities[entityName] = {
7070
7078
  regx: RegExp(`&${escaped};`, "g"),
7071
7079
  val
7072
7080
  };
7081
+ entityCount++;
7073
7082
  }
7074
7083
  } else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
7075
7084
  i += 8;
@@ -7432,7 +7441,7 @@ function handleInfinity(str, num, options2) {
7432
7441
  }
7433
7442
  }
7434
7443
 
7435
- // ../../.yarn/cache/fast-xml-parser-npm-5.4.1-48bbd2c631-2b40067c3a.zip/node_modules/fast-xml-parser/src/ignoreAttributes.js
7444
+ // ../../.yarn/cache/fast-xml-parser-npm-5.4.2-dc824fc7a7-12585d5dd7.zip/node_modules/fast-xml-parser/src/ignoreAttributes.js
7436
7445
  function getIgnoreAttributesFn(ignoreAttributes) {
7437
7446
  if (typeof ignoreAttributes === "function") {
7438
7447
  return ignoreAttributes;
@@ -7452,7 +7461,7 @@ function getIgnoreAttributesFn(ignoreAttributes) {
7452
7461
  return () => false;
7453
7462
  }
7454
7463
 
7455
- // ../../.yarn/cache/fast-xml-parser-npm-5.4.1-48bbd2c631-2b40067c3a.zip/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
7464
+ // ../../.yarn/cache/fast-xml-parser-npm-5.4.2-dc824fc7a7-12585d5dd7.zip/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
7456
7465
  var OrderedObjParser = class {
7457
7466
  constructor(options2) {
7458
7467
  this.options = options2;
@@ -8020,7 +8029,7 @@ function fromCodePoint(str, base, prefix) {
8020
8029
  }
8021
8030
  }
8022
8031
 
8023
- // ../../.yarn/cache/fast-xml-parser-npm-5.4.1-48bbd2c631-2b40067c3a.zip/node_modules/fast-xml-parser/src/xmlparser/node2json.js
8032
+ // ../../.yarn/cache/fast-xml-parser-npm-5.4.2-dc824fc7a7-12585d5dd7.zip/node_modules/fast-xml-parser/src/xmlparser/node2json.js
8024
8033
  var METADATA_SYMBOL2 = XmlNode.getMetaDataSymbol();
8025
8034
  function prettify(node, options2) {
8026
8035
  return compress(node, options2);
@@ -8105,7 +8114,7 @@ function isLeafTag(obj, options2) {
8105
8114
  return false;
8106
8115
  }
8107
8116
 
8108
- // ../../.yarn/cache/fast-xml-parser-npm-5.4.1-48bbd2c631-2b40067c3a.zip/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
8117
+ // ../../.yarn/cache/fast-xml-parser-npm-5.4.2-dc824fc7a7-12585d5dd7.zip/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
8109
8118
  var XMLParser = class {
8110
8119
  constructor(options2) {
8111
8120
  this.externalEntities = {};
@@ -11007,6 +11016,9 @@ var IntrospectedClass = class _IntrospectedClass extends IntrospectedBaseClass {
11007
11016
  constructor(name, namespace) {
11008
11017
  super({ name, namespace });
11009
11018
  }
11019
+ get gtype() {
11020
+ return this.name;
11021
+ }
11010
11022
  getAllSignals() {
11011
11023
  const allSignals = this.getBaseSignals();
11012
11024
  if (this.hasGObjectSupport()) {
@@ -12167,6 +12179,7 @@ var IntrospectedRecord = class _IntrospectedRecord extends IntrospectedBaseClass
12167
12179
  _structFor = null;
12168
12180
  _isSimple = null;
12169
12181
  _isSimpleWithoutPointers = null;
12182
+ _overriddenGType = null;
12170
12183
  /**
12171
12184
  * Returns all signals for this record (records typically don't have signals)
12172
12185
  */
@@ -12179,6 +12192,12 @@ var IntrospectedRecord = class _IntrospectedRecord extends IntrospectedBaseClass
12179
12192
  get structFor() {
12180
12193
  return this._structFor;
12181
12194
  }
12195
+ get gtype() {
12196
+ return this._overriddenGType ?? this.name;
12197
+ }
12198
+ overrideGType(gtype) {
12199
+ this._overriddenGType = gtype;
12200
+ }
12182
12201
  getType() {
12183
12202
  if (this._structFor) {
12184
12203
  return this._structFor;
@@ -12248,6 +12267,7 @@ var IntrospectedRecord = class _IntrospectedRecord extends IntrospectedBaseClass
12248
12267
  constructors,
12249
12268
  _isForeign,
12250
12269
  _structFor,
12270
+ _overriddenGType,
12251
12271
  props,
12252
12272
  fields,
12253
12273
  callbacks,
@@ -12261,6 +12281,7 @@ var IntrospectedRecord = class _IntrospectedRecord extends IntrospectedBaseClass
12261
12281
  }
12262
12282
  clazz._structFor = _structFor;
12263
12283
  clazz._isForeign = _isForeign;
12284
+ clazz._overriddenGType = _overriddenGType;
12264
12285
  clazz.props = (options2.props ?? props).map((p) => p.copy({ parent: clazz }));
12265
12286
  clazz.fields = (options2.fields ?? fields).map((f) => f.copy({ parent: clazz }));
12266
12287
  clazz.callbacks = (options2.callbacks ?? callbacks).map((c) => c.copy({ parent: clazz }));
@@ -12473,6 +12494,7 @@ var GirComplexRecord = class extends IntrospectedRecord {
12473
12494
  // ../lib/src/gir/enum.ts
12474
12495
  var IntrospectedEnum = class _IntrospectedEnum extends IntrospectedNamespaceMember {
12475
12496
  members = /* @__PURE__ */ new Map();
12497
+ isRegistered = false;
12476
12498
  flags = false;
12477
12499
  ns;
12478
12500
  constructor(name, namespace, options2 = {}) {
@@ -12480,11 +12502,12 @@ var IntrospectedEnum = class _IntrospectedEnum extends IntrospectedNamespaceMemb
12480
12502
  this.ns = namespace;
12481
12503
  }
12482
12504
  copy({ members } = {}) {
12483
- const { namespace, name, flags } = this;
12505
+ const { namespace, name, isRegistered, flags } = this;
12484
12506
  const en = new _IntrospectedEnum(name, namespace);
12485
12507
  for (const [key, member] of (members ?? this.members).entries()) {
12486
12508
  en.members.set(key, member.copy());
12487
12509
  }
12510
+ en.isRegistered = isRegistered;
12488
12511
  en.flags = flags;
12489
12512
  en._copyBaseProperties(this);
12490
12513
  return en;
@@ -12528,6 +12551,7 @@ var IntrospectedEnum = class _IntrospectedEnum extends IntrospectedNamespaceMemb
12528
12551
  static fromXML(element, ns, options2, flags = false) {
12529
12552
  const em = new _IntrospectedEnum(sanitizeMemberName(element.$.name), ns);
12530
12553
  if (element.$["glib:type-name"]) {
12554
+ em.isRegistered = true;
12531
12555
  em.resolve_names.push(element.$["glib:type-name"]);
12532
12556
  ns.registerResolveName(element.$["glib:type-name"], ns.namespace, em.name);
12533
12557
  }
@@ -12572,6 +12596,11 @@ var IntrospectedError = class _IntrospectedError extends IntrospectedEnum {
12572
12596
  en.flags = flags;
12573
12597
  return en._copyBaseProperties(this);
12574
12598
  }
12599
+ asClass() {
12600
+ const clazz = super.asClass();
12601
+ clazz.overrideGType(this.namespace.namespace === "GLib" ? "Error" : "GLib.Error");
12602
+ return clazz;
12603
+ }
12575
12604
  static fromXML(element, ns, options2) {
12576
12605
  const err = new _IntrospectedError(sanitizeMemberName(element.$.name), ns);
12577
12606
  if (element.$["glib:type-name"]) {
@@ -13072,7 +13101,7 @@ var GirModule = class _GirModule {
13072
13101
  return !this.hasImport(el.name);
13073
13102
  };
13074
13103
  if (ns.enumeration) {
13075
- const enumerations = ns.enumeration?.map((enumeration) => {
13104
+ const enumerations = ns.enumeration?.filter(isIntrospectable).map((enumeration) => {
13076
13105
  if (enumeration.$["glib:error-domain"]) {
13077
13106
  return IntrospectedError.fromXML(enumeration, this, options2);
13078
13107
  } else {
@@ -19143,7 +19172,6 @@ export const ${node.name}: ${node.name}Namespace & {
19143
19172
  generateEnum(girEnum, indentCount = 0) {
19144
19173
  const desc = [];
19145
19174
  const { name, namespace } = girEnum;
19146
- desc.push(...this.addGirDocComment(girEnum.doc, [], indentCount));
19147
19175
  const isInvalidEnum = Array.from(girEnum.members.keys()).some(
19148
19176
  (name2) => name2.match(/^[0-9]+$/) || name2 === "NaN" || name2 === "Infinity"
19149
19177
  );
@@ -19151,13 +19179,14 @@ export const ${node.name}: ${node.name}Namespace & {
19151
19179
  desc.push(...girEnum.asClass().asString(this));
19152
19180
  return desc;
19153
19181
  }
19154
- desc.push("");
19182
+ if (girEnum.isRegistered) {
19183
+ desc.push(`export namespace ${name} {`);
19184
+ const gtypeNamespace = namespace.namespace === "GObject" ? "" : "GObject.";
19185
+ desc.push(` export const $gtype: ${gtypeNamespace}GType<${name}>;`);
19186
+ desc.push("}");
19187
+ desc.push("");
19188
+ }
19155
19189
  desc.push(...this.addGirDocComment(girEnum.doc, [], indentCount));
19156
- desc.push(`export namespace ${name} {`);
19157
- const gtypeNamespace = namespace.namespace === "GObject" ? "" : "GObject.";
19158
- desc.push(` export const $gtype: ${gtypeNamespace}GType<${name}>;`);
19159
- desc.push("}");
19160
- desc.push("");
19161
19190
  desc.push(this.generateExport("enum", name, "{", indentCount));
19162
19191
  if (girEnum.members) {
19163
19192
  for (const girEnumMember of girEnum.members.values()) {
@@ -19166,6 +19195,7 @@ export const ${node.name}: ${node.name}Namespace & {
19166
19195
  }
19167
19196
  }
19168
19197
  desc.push("}");
19198
+ desc.push("");
19169
19199
  return desc;
19170
19200
  }
19171
19201
  generateEnumMember(tsMember, indentCount = 1) {
@@ -19778,7 +19808,7 @@ ${girClass.__ts__indexSignature}
19778
19808
  def.push(this.generateExport("class", classHead, "{"));
19779
19809
  }
19780
19810
  const gtypeNamespace = this.namespace.namespace === "GObject" ? "" : "GObject.";
19781
- def.push(`static $gtype: ${gtypeNamespace}GType<${girClass.name}>;`);
19811
+ def.push(`static $gtype: ${gtypeNamespace}GType<${girClass.gtype}>;`);
19782
19812
  if (girClass.__ts__indexSignature) {
19783
19813
  def.push(`
19784
19814
  ${girClass.__ts__indexSignature}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-for-gir/cli",
3
- "version": "4.0.0-beta.39",
3
+ "version": "4.0.0-beta.40",
4
4
  "description": "TypeScript type definition generator for GObject introspection GIR files",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -52,13 +52,13 @@
52
52
  ".": "./src/index.ts"
53
53
  },
54
54
  "devDependencies": {
55
- "@gi.ts/parser": "^4.0.0-beta.39",
56
- "@ts-for-gir/generator-base": "^4.0.0-beta.39",
57
- "@ts-for-gir/generator-html-doc": "^4.0.0-beta.39",
58
- "@ts-for-gir/generator-json": "^4.0.0-beta.39",
59
- "@ts-for-gir/generator-typescript": "^4.0.0-beta.39",
60
- "@ts-for-gir/lib": "^4.0.0-beta.39",
61
- "@ts-for-gir/reporter": "^4.0.0-beta.39",
55
+ "@gi.ts/parser": "^4.0.0-beta.40",
56
+ "@ts-for-gir/generator-base": "^4.0.0-beta.40",
57
+ "@ts-for-gir/generator-html-doc": "^4.0.0-beta.40",
58
+ "@ts-for-gir/generator-json": "^4.0.0-beta.40",
59
+ "@ts-for-gir/generator-typescript": "^4.0.0-beta.40",
60
+ "@ts-for-gir/lib": "^4.0.0-beta.40",
61
+ "@ts-for-gir/reporter": "^4.0.0-beta.40",
62
62
  "@types/ejs": "^3.1.5",
63
63
  "@types/inquirer": "^9.0.9",
64
64
  "@types/node": "^24.11.0",
@@ -68,9 +68,9 @@
68
68
  },
69
69
  "dependencies": {
70
70
  "@inquirer/prompts": "^8.3.0",
71
- "@ts-for-gir/templates": "^4.0.0-beta.39",
71
+ "@ts-for-gir/templates": "^4.0.0-beta.40",
72
72
  "colorette": "^2.0.20",
73
- "cosmiconfig": "^9.0.0",
73
+ "cosmiconfig": "^9.0.1",
74
74
  "ejs": "^4.0.1",
75
75
  "glob": "^13.0.6",
76
76
  "inquirer": "^13.3.0",