@ts-for-gir/cli 4.0.0-rc.7 → 4.0.0-rc.9

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/ts-for-gir CHANGED
@@ -7268,7 +7268,7 @@ import { dirname, join } from "node:path";
7268
7268
  import { fileURLToPath } from "node:url";
7269
7269
  function getPackageVersion() {
7270
7270
  if (true) {
7271
- return "4.0.0-rc.7";
7271
+ return "4.0.0-rc.9";
7272
7272
  }
7273
7273
  const currentModulePath = fileURLToPath(import.meta.url);
7274
7274
  const currentDir = dirname(currentModulePath);
@@ -8165,13 +8165,17 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
8165
8165
  var NEW_LINE_REG_EXP = /[\n\r]+/g;
8166
8166
  function getPackageVersion2() {
8167
8167
  if (true) {
8168
- return "4.0.0-rc.7";
8168
+ return "4.0.0-rc.9";
8169
+ }
8170
+ try {
8171
+ const currentModulePath = fileURLToPath2(import.meta.url);
8172
+ const currentDir = dirname2(currentModulePath);
8173
+ const packageJsonPath = join2(currentDir, "..", "package.json");
8174
+ const content = readFileSync2(packageJsonPath, "utf-8");
8175
+ return JSON.parse(content).version;
8176
+ } catch {
8177
+ return "0.0.0-unknown";
8169
8178
  }
8170
- const currentModulePath = fileURLToPath2(import.meta.url);
8171
- const currentDir = dirname2(currentModulePath);
8172
- const packageJsonPath = join2(currentDir, "..", "package.json");
8173
- const content = readFileSync2(packageJsonPath, "utf-8");
8174
- return JSON.parse(content).version;
8175
8179
  }
8176
8180
  var APP_NAME = "ts-for-gir";
8177
8181
  var APP_USAGE = "TypeScript type definition generator for GObject introspection GIR files";
@@ -15984,7 +15988,10 @@ var IntrospectedFunction = class _IntrospectedFunction extends IntrospectedNames
15984
15988
  });
15985
15989
  }
15986
15990
  static filterParameters(parameters, length_params, user_data_params) {
15987
- return parameters.filter((_, i) => !length_params.includes(i) && !user_data_params.includes(i)).filter((v) => !(v.type instanceof TypeIdentifier && v.type.is("GLib", "DestroyNotify")));
15991
+ return parameters.filter((_, i) => !length_params.includes(i) && !user_data_params.includes(i)).filter((v) => {
15992
+ const unwrapped = v.type.unwrap();
15993
+ return !(unwrapped instanceof TypeIdentifier && unwrapped.is("GLib", "DestroyNotify"));
15994
+ });
15988
15995
  }
15989
15996
  static processOptionalParameters(parameters) {
15990
15997
  return parameters.reverse().reduce(
@@ -20986,7 +20993,6 @@ function addInfoComment(comment, indentCount = 0) {
20986
20993
  if (comment) {
20987
20994
  def.push("");
20988
20995
  def.push(`${indent}// ${comment}`);
20989
- def.push("");
20990
20996
  }
20991
20997
  return def;
20992
20998
  }
@@ -20994,7 +21000,7 @@ function mergeDescs(descs, comment, indentCount = 1) {
20994
21000
  const def = [];
20995
21001
  const indent = generateIndent(indentCount);
20996
21002
  for (const desc of descs) {
20997
- def.push(`${indent}${desc}`);
21003
+ def.push(desc.length === 0 ? desc : `${indent}${desc}`);
20998
21004
  }
20999
21005
  if (def.length > 0) {
21000
21006
  def.unshift(...addInfoComment(comment, indentCount));
@@ -21037,8 +21043,14 @@ function convertCDefaultValue(rawValue, ns) {
21037
21043
  // ../lib/src/utils/path.ts
21038
21044
  import { dirname as dirname4, resolve as resolve3 } from "node:path";
21039
21045
  import { fileURLToPath as fileURLToPath3 } from "node:url";
21040
- var __filename = fileURLToPath3(import.meta.url);
21041
- var __dirname = resolve3(dirname4(__filename), "../..");
21046
+ function resolvePackageDir() {
21047
+ try {
21048
+ return resolve3(dirname4(fileURLToPath3(import.meta.url)), "../..");
21049
+ } catch {
21050
+ return "";
21051
+ }
21052
+ }
21053
+ var __dirname = resolvePackageDir();
21042
21054
 
21043
21055
  // src/start.ts
21044
21056
  import yargs from "yargs";
@@ -21820,7 +21832,7 @@ var formatAsCsv = (problems) => {
21820
21832
  ]);
21821
21833
  return [headers.join(","), ...rows.map((row) => row.join(","))].join("\n");
21822
21834
  };
21823
- var exportResults = (problems, filePath, format, logger6) => {
21835
+ var exportResults = (problems, filePath, format, logger5) => {
21824
21836
  let content;
21825
21837
  switch (format) {
21826
21838
  case "json": {
@@ -21840,14 +21852,14 @@ var exportResults = (problems, filePath, format, logger6) => {
21840
21852
  }
21841
21853
  }
21842
21854
  writeFileSync(filePath, content, "utf-8");
21843
- logger6.success(`Results exported to: ${filePath}`);
21855
+ logger5.success(`Results exported to: ${filePath}`);
21844
21856
  };
21845
21857
  var handler = async (args) => {
21846
- const logger6 = new Logger(args.verbose ?? false, "AnalyzeCommand");
21858
+ const logger5 = new Logger(args.verbose ?? false, "AnalyzeCommand");
21847
21859
  try {
21848
21860
  const report = loadReportFile(args.reportFile);
21849
21861
  if (args.verbose) {
21850
- logger6.info(`Loaded report with ${report.problems.length} problems`);
21862
+ logger5.info(`Loaded report with ${report.problems.length} problems`);
21851
21863
  }
21852
21864
  const hasFilters = Boolean(args.severity || args.category || args.namespace || args.type || args.search);
21853
21865
  if (args.summary || !hasFilters) {
@@ -21862,7 +21874,7 @@ var handler = async (args) => {
21862
21874
  }
21863
21875
  if (args.export) {
21864
21876
  const format = args.format ?? "json";
21865
- exportResults(filteredProblems, args.export, format, logger6);
21877
+ exportResults(filteredProblems, args.export, format, logger5);
21866
21878
  }
21867
21879
  if (hasFilters && !args.summary) {
21868
21880
  console.log(
@@ -21872,7 +21884,7 @@ var handler = async (args) => {
21872
21884
  }
21873
21885
  } catch (error) {
21874
21886
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
21875
- logger6.error(`Analysis failed: ${errorMessage}`);
21887
+ logger5.error(`Analysis failed: ${errorMessage}`);
21876
21888
  process.exit(1);
21877
21889
  }
21878
21890
  };
@@ -22501,8 +22513,8 @@ var PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__";
22501
22513
  var TEXT_FILE_EXT = /* @__PURE__ */ new Set([".json", ".md", ".ts", ".tsx", ".js", ".mjs", ".cjs"]);
22502
22514
  var builder3 = createBuilder(createOptions, examples3);
22503
22515
  function findTemplatesRoot() {
22504
- const __filename2 = fileURLToPath4(import.meta.url);
22505
- const __dirname3 = dirname6(__filename2);
22516
+ const __filename = fileURLToPath4(import.meta.url);
22517
+ const __dirname3 = dirname6(__filename);
22506
22518
  const candidates = [
22507
22519
  // Bundled production binary (bin/ts-for-gir): ../dist-templates
22508
22520
  resolve5(__dirname3, "..", "dist-templates"),
@@ -23004,7 +23016,6 @@ var SignalGenerator = class {
23004
23016
  const def = [];
23005
23017
  const indent = generateIndent(indentCount);
23006
23018
  def.push(`${indent}// Signal signatures`);
23007
- def.push(`${indent}interface SignalSignatures`);
23008
23019
  const parentSignatures = [];
23009
23020
  const parentResolution = girClass.resolveParents().extends();
23010
23021
  if (parentResolution && parentResolution.node instanceof IntrospectedClass) {
@@ -23024,20 +23035,22 @@ var SignalGenerator = class {
23024
23035
  return interfaceTypeIdentifier ? `${interfaceTypeIdentifier}.SignalSignatures` : null;
23025
23036
  }).filter((sig) => !!sig);
23026
23037
  parentSignatures.push(...interfaceSignatures);
23038
+ let signatureHead;
23027
23039
  if (parentSignatures.length > 0) {
23028
- def.push(` extends ${parentSignatures.join(", ")} {`);
23040
+ signatureHead = `${indent}interface SignalSignatures extends ${parentSignatures.join(", ")} {`;
23029
23041
  } else {
23030
23042
  const isGObjectObject = girClass.name === "Object" && girClass.namespace.namespace === "GObject";
23031
23043
  if (isGObjectObject) {
23032
- def.push(" {");
23044
+ signatureHead = `${indent}interface SignalSignatures {`;
23033
23045
  } else {
23034
23046
  const gobjectNamespace = this.namespace.assertInstalledImport("GObject");
23035
23047
  const gobjectObjectClass = gobjectNamespace.assertClass("Object");
23036
23048
  const gobjectRef = gobjectObjectClass.getType().resolveIdentifier(this.namespace, this.config)?.print(this.namespace, this.config);
23037
23049
  const fallbackRef = gobjectRef ? `${gobjectRef}.SignalSignatures` : "GObject.Object.SignalSignatures";
23038
- def.push(` extends ${fallbackRef} {`);
23050
+ signatureHead = `${indent}interface SignalSignatures extends ${fallbackRef} {`;
23039
23051
  }
23040
23052
  }
23053
+ def.push(signatureHead);
23041
23054
  const allSignals = girClass.getAllSignals();
23042
23055
  allSignals.forEach((signalInfo) => {
23043
23056
  let cbType;
@@ -23083,7 +23096,6 @@ var SignalGenerator = class {
23083
23096
  def.push(`${indent} ${signalKey}: ${cbType};`);
23084
23097
  });
23085
23098
  def.push(`${indent}}`);
23086
- def.push("");
23087
23099
  return def;
23088
23100
  }
23089
23101
  /**
@@ -23109,8 +23121,7 @@ var SignalGenerator = class {
23109
23121
  `${indent} * It is not defined at runtime and should not be accessed in JS code.`,
23110
23122
  `${indent} * @internal`,
23111
23123
  `${indent} */`,
23112
- `${indent}$signals: ${girClass.name}.SignalSignatures;`,
23113
- ""
23124
+ `${indent}$signals: ${girClass.name}.SignalSignatures;`
23114
23125
  ];
23115
23126
  }
23116
23127
  /**
@@ -23140,27 +23151,32 @@ var SignalGenerator = class {
23140
23151
  const filteredFunctions = filterConflicts(girClass.namespace, girClass, signalFunctions, 0 /* DELETE */);
23141
23152
  const allowedNames = new Set(filteredFunctions.map((f) => f.name));
23142
23153
  const gobjectRef = this.namespace.namespace === "GObject" ? "" : "GObject.";
23143
- const methods = [];
23154
+ const groups = [];
23144
23155
  if (allowedNames.has("connect")) {
23145
- methods.push(
23156
+ groups.push([
23146
23157
  SIGNAL_JSDOC,
23147
23158
  `connect<K extends keyof ${girClass.name}.SignalSignatures>(signal: K, callback: ${gobjectRef}SignalCallback<this, ${girClass.name}.SignalSignatures[K]>): number;`,
23148
23159
  "connect(signal: string, callback: (...args: any[]) => any): number;"
23149
- );
23160
+ ]);
23150
23161
  }
23151
23162
  if (allowedNames.has("connect_after")) {
23152
- methods.push(
23163
+ groups.push([
23153
23164
  SIGNAL_JSDOC,
23154
23165
  `connect_after<K extends keyof ${girClass.name}.SignalSignatures>(signal: K, callback: ${gobjectRef}SignalCallback<this, ${girClass.name}.SignalSignatures[K]>): number;`,
23155
23166
  "connect_after(signal: string, callback: (...args: any[]) => any): number;"
23156
- );
23167
+ ]);
23157
23168
  }
23158
23169
  if (allowedNames.has("emit")) {
23159
- methods.push(
23170
+ groups.push([
23160
23171
  SIGNAL_JSDOC,
23161
23172
  `emit<K extends keyof ${girClass.name}.SignalSignatures>(signal: K, ...args: ${gobjectRef}GjsParameters<${girClass.name}.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never): void;`,
23162
23173
  "emit(signal: string, ...args: any[]): void;"
23163
- );
23174
+ ]);
23175
+ }
23176
+ const methods = [];
23177
+ for (const group of groups) {
23178
+ if (methods.length > 0) methods.push("");
23179
+ methods.push(...group);
23164
23180
  }
23165
23181
  return methods;
23166
23182
  }
@@ -23369,37 +23385,37 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
23369
23385
  generateClassCallback(node) {
23370
23386
  return this.generateCallback(node);
23371
23387
  }
23372
- generateConstructor(node) {
23388
+ generateConstructor(node, indentCount = 0) {
23373
23389
  const Parameters = this.generateParameters(node.parameters);
23374
- return [`constructor(${Parameters});`];
23390
+ const indent = generateIndent(indentCount);
23391
+ return [`${indent}constructor(${Parameters});`];
23375
23392
  }
23376
- generateDirectAllocationConstructor(node) {
23377
- const ConstructorFields = node.parameters.map((param) => param.asField().asString(this)).join("\n");
23378
- return [
23379
- `
23380
- constructor(properties?: Partial<{
23381
- ${ConstructorFields}
23382
- }>);`
23383
- ];
23393
+ generateDirectAllocationConstructor(node, indentCount = 1) {
23394
+ const indent = generateIndent(indentCount);
23395
+ const fieldIndent = generateIndent(indentCount + 1);
23396
+ const constructorFields = node.parameters.flatMap((param) => param.asField().asString(this)).flatMap((line) => line.split("\n")).map((line) => line.replace(/^\s+/, "")).filter((line) => line.length > 0).map((line) => `${fieldIndent}${line}`).join("\n");
23397
+ return ["", `${indent}constructor(properties?: Partial<{`, constructorFields, `${indent}}>);`];
23384
23398
  }
23385
23399
  generateParameters(parameters) {
23386
23400
  return parameters.flatMap((p) => {
23387
23401
  return p.asString(this);
23388
23402
  }).join(", ");
23389
23403
  }
23390
- generateConstructorFunction(node) {
23404
+ generateConstructorFunction(node, indentCount = 0) {
23391
23405
  const { namespace, options: options2 } = this;
23392
23406
  const Parameters = this.generateParameters(node.parameters);
23407
+ const indent = generateIndent(indentCount);
23393
23408
  const invalid = isInvalid(node.name);
23394
23409
  const name = invalid ? `["${node.name}"]` : node.name;
23395
23410
  const warning = node.getWarning();
23396
23411
  const genericTypes = this.generateGenericParameters(node.generics);
23397
- return [
23398
- `${warning ? `${warning}
23399
- ` : ""}`,
23400
- ...this.addGirDocComment(node.doc),
23401
- `static ${name}${genericTypes}(${Parameters}): ${node.return().resolve(namespace, options2).rootPrint(namespace, options2)};`
23402
- ];
23412
+ const lines = [];
23413
+ if (warning) lines.push(`${indent}${warning}`);
23414
+ lines.push(...this.addGirDocComment(node.doc, [], indentCount));
23415
+ lines.push(
23416
+ `${indent}static ${name}${genericTypes}(${Parameters}): ${node.return().resolve(namespace, options2).rootPrint(namespace, options2)};`
23417
+ );
23418
+ return lines;
23403
23419
  }
23404
23420
  generateRecord(node) {
23405
23421
  const structFor = node.structFor;
@@ -23444,25 +23460,30 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
23444
23460
  })
23445
23461
  );
23446
23462
  const gtypeNamespace = namespace.namespace === "GObject" ? "" : "GObject.";
23447
- return [
23448
- `export interface ${node.name}Namespace {
23449
- ${isGObject ? `$gtype: ${gtypeNamespace}GType<${node.name}>;` : ""}
23450
- prototype: ${node.name};
23451
- ${staticFields.length > 0 ? staticFields.flatMap((sf) => sf.asString(this)).join("\n") : ""}
23452
- ${staticFunctions.length > 0 ? staticFunctions.flatMap((sf) => {
23453
- return sf.asClassFunction(node).asString(this);
23454
- }).join("\n") : ""}
23455
- }`
23456
- ];
23463
+ const bodyIndent = generateIndent(1);
23464
+ const bodyLines = [];
23465
+ if (isGObject) bodyLines.push(`${bodyIndent}$gtype: ${gtypeNamespace}GType<${node.name}>;`);
23466
+ bodyLines.push(`${bodyIndent}prototype: ${node.name};`);
23467
+ for (const sf of staticFields) {
23468
+ for (const line of sf.asString(this)) {
23469
+ if (line.length === 0) continue;
23470
+ bodyLines.push(`${bodyIndent}${line.replace(/^\s+/, "")}`);
23471
+ }
23472
+ }
23473
+ for (const sf of staticFunctions) {
23474
+ for (const line of sf.asClassFunction(node).asString(this)) {
23475
+ if (line.length === 0) continue;
23476
+ bodyLines.push(`${bodyIndent}${line.replace(/^\s+/, "")}`);
23477
+ }
23478
+ }
23479
+ return [`export interface ${node.name}Namespace {`, ...bodyLines, "}"];
23457
23480
  }
23458
23481
  generateInterfaceDeclaration(node) {
23459
23482
  return [
23460
- `
23461
-
23462
- export const ${node.name}: ${node.name}Namespace & {
23463
- new (): ${node.name} // This allows \`obj instanceof ${node.name}\`
23464
- }
23465
- `
23483
+ "",
23484
+ `export const ${node.name}: ${node.name}Namespace & {`,
23485
+ ` new (): ${node.name}; // This allows \`obj instanceof ${node.name}\``,
23486
+ "};"
23466
23487
  ];
23467
23488
  }
23468
23489
  generateError(node) {
@@ -23617,13 +23638,16 @@ export const ${node.name}: ${node.name}Namespace & {
23617
23638
  }
23618
23639
  }
23619
23640
  const typeStr = this.generateDirectedType(type, "out" /* Out */);
23620
- desc.push(`${indent}${commentOut}${staticStr}${readonly}${name}${affix}: ${typeStr}`);
23641
+ desc.push(`${indent}${commentOut}${staticStr}${readonly}${name}${affix}: ${typeStr};`);
23621
23642
  return desc;
23622
23643
  }
23623
23644
  generateProperties(tsProps, comment, indentCount = 0) {
23624
23645
  const def = [];
23625
23646
  for (const tsProp of tsProps) {
23626
- def.push(...this.generateProperty(tsProp, false, indentCount));
23647
+ const propLines = this.generateProperty(tsProp, false, indentCount);
23648
+ if (propLines.length === 0) continue;
23649
+ if (def.length > 0) def.push("");
23650
+ def.push(...propLines);
23627
23651
  }
23628
23652
  if (def.length > 0) {
23629
23653
  def.unshift(...addInfoComment(comment, indentCount));
@@ -23633,7 +23657,10 @@ export const ${node.name}: ${node.name}Namespace & {
23633
23657
  generateFields(tsProps, comment, indentCount = 0) {
23634
23658
  const def = [];
23635
23659
  for (const tsProp of tsProps) {
23636
- def.push(...this.generateField(tsProp));
23660
+ const fieldLines = this.generateField(tsProp, indentCount);
23661
+ if (fieldLines.length === 0) continue;
23662
+ if (def.length > 0) def.push("");
23663
+ def.push(...fieldLines);
23637
23664
  }
23638
23665
  if (def.length > 0) {
23639
23666
  def.unshift(...addInfoComment(comment, indentCount));
@@ -23813,8 +23840,8 @@ export const ${node.name}: ${node.name}Namespace & {
23813
23840
  }
23814
23841
  return typeStr;
23815
23842
  }
23816
- generateClassFunction(node) {
23817
- return this.generateFunction(node);
23843
+ generateClassFunction(node, indentCount = 0) {
23844
+ return this.generateFunction(node, indentCount);
23818
23845
  }
23819
23846
  generateFunction(tsFunction, indentCount = 0) {
23820
23847
  const def = [];
@@ -23870,14 +23897,17 @@ export const ${node.name}: ${node.name}Namespace & {
23870
23897
  def.push(
23871
23898
  `${indent}${commentOut}${exportStr}${staticStr}${globalStr}${name}${genericStr}(${inParamsDef.join(
23872
23899
  ", "
23873
- )})${retSep} ${returnType}`
23900
+ )})${retSep} ${returnType};`
23874
23901
  );
23875
23902
  return def;
23876
23903
  }
23877
23904
  generateFunctions(tsFunctions, indentCount = 1, comment) {
23878
23905
  const def = [];
23879
23906
  for (const girFunction of tsFunctions) {
23880
- def.push(...this.generateFunction(girFunction, indentCount));
23907
+ const fnLines = this.generateFunction(girFunction, indentCount);
23908
+ if (fnLines.length === 0) continue;
23909
+ if (def.length > 0) def.push("");
23910
+ def.push(...fnLines);
23881
23911
  }
23882
23912
  if (def.length > 0) {
23883
23913
  def.unshift(...addInfoComment(comment, indentCount));
@@ -23903,7 +23933,7 @@ export const ${node.name}: ${node.name}Namespace & {
23903
23933
  }
23904
23934
  const interfaceHead = `${name}${genericParameters}`;
23905
23935
  def.push(this.generateExport("interface", `${interfaceHead}`, "{", indentCount));
23906
- def.push(`${indentBody}(${inParamsDef.join(", ")}): ${returnTypeStr}`);
23936
+ def.push(`${indentBody}(${inParamsDef.join(", ")}): ${returnTypeStr};`);
23907
23937
  def.push(`${indent}}`);
23908
23938
  return def;
23909
23939
  }
@@ -23973,7 +24003,7 @@ export const ${node.name}: ${node.name}Namespace & {
23973
24003
  const exp = !this.config.noNamespace ? "" : "export ";
23974
24004
  const ComputedName = generateMemberName(tsConst);
23975
24005
  const typeStr = this.generateType(resolveDirectedType(tsConst.type, "out" /* Out */) ?? tsConst.type);
23976
- desc.push(`${indent}${exp}const ${ComputedName}: ${typeStr}`);
24006
+ desc.push(`${indent}${exp}const ${ComputedName}: ${typeStr};`);
23977
24007
  return desc;
23978
24008
  }
23979
24009
  generateAlias(girAlias, indentCount = 0) {
@@ -23995,7 +24025,7 @@ export const ${node.name}: ${node.name}Namespace & {
23995
24025
  }).join(", ");
23996
24026
  const generics = genericList ? `<${genericList}>` : "";
23997
24027
  const exp = !this.config.noNamespace ? "" : "export ";
23998
- desc.push(`${indent}${exp}type ${girAlias.name}${generics} = ${girAlias.type.print(this.namespace, this.config)}`);
24028
+ desc.push(`${indent}${exp}type ${girAlias.name}${generics} = ${girAlias.type.print(this.namespace, this.config)};`);
23999
24029
  return desc;
24000
24030
  }
24001
24031
  generateConstructPropsInterface(girClass, indentCount = 0) {
@@ -24027,10 +24057,11 @@ export const ${node.name}: ${node.name}Namespace & {
24027
24057
  }
24028
24058
  def.push(...addInfoComment("Constructor properties interface", indentCount));
24029
24059
  const { props } = girClass;
24030
- const ConstructorProps = filterConflicts(girClass.namespace, girClass, props, 1 /* PRESERVE */).flatMap((v) => v.asString(this, true)).join("\n ");
24060
+ const memberIndent = generateIndent(indentCount + 1);
24061
+ const constructorPropMembers = filterConflicts(girClass.namespace, girClass, props, 1 /* PRESERVE */).flatMap((v) => v.asString(this, true)).map((m) => `${memberIndent}${m}`).join("\n");
24031
24062
  def.push(`${indent}${exp}interface ${constructPropInterfaceName}${genericTypes} ${ext} {`);
24032
- def.push(ConstructorProps);
24033
- def.push(`${indent}}`, "");
24063
+ def.push(constructorPropMembers);
24064
+ def.push(`${indent}}`);
24034
24065
  return def;
24035
24066
  }
24036
24067
  generateClassStaticFields(girClass, indentCount = 1) {
@@ -24121,22 +24152,23 @@ export const ${node.name}: ${node.name}Namespace & {
24121
24152
  }
24122
24153
  generateClassConstructors(girClass, indentCount = 1) {
24123
24154
  const def = [];
24155
+ const indent = generateIndent(indentCount);
24124
24156
  if (girClass.mainConstructor instanceof IntrospectedDirectAllocationConstructor)
24125
- def.push(...this.generateDirectAllocationConstructor(girClass.mainConstructor));
24157
+ def.push(...this.generateDirectAllocationConstructor(girClass.mainConstructor, indentCount));
24126
24158
  else if (girClass.mainConstructor instanceof IntrospectedConstructor)
24127
- def.push(...this.generateConstructor(girClass.mainConstructor));
24128
- else if (girClass.namespace.namespace === "GObject" && girClass.name === "Object" || girClass.someParent((p) => p.namespace.namespace === "GObject" && p.name === "Object"))
24129
- def.push(`
24130
- constructor(properties?: Partial<${girClass.name}.ConstructorProps>, ...args: any[]);
24131
- `);
24132
- if (girClass instanceof IntrospectedClass && (!girClass.__ts__indexSignature || girClass.__ts__indexSignature.includes("[key: string]: any"))) {
24133
- def.push("_init(...args: any[]): void;\n");
24159
+ def.push(...this.generateConstructor(girClass.mainConstructor, indentCount));
24160
+ else if (girClass.namespace.namespace === "GObject" && girClass.name === "Object" || girClass.someParent((p) => p.namespace.namespace === "GObject" && p.name === "Object")) {
24161
+ def.push(`${indent}constructor(properties?: Partial<${girClass.name}.ConstructorProps>, ...args: any[]);`);
24162
+ }
24163
+ const hasInit = girClass instanceof IntrospectedClass && (!girClass.__ts__indexSignature || girClass.__ts__indexSignature.includes("[key: string]: any"));
24164
+ if (hasInit) {
24165
+ if (def.length > 0) def.push("");
24166
+ def.push(`${indent}_init(...args: any[]): void;`);
24167
+ }
24168
+ for (const constructorFunction of filterFunctionConflict(girClass.parent, girClass, girClass.constructors, [])) {
24169
+ if (def.length > 0) def.push("");
24170
+ def.push(...this.generateConstructorFunction(constructorFunction, indentCount));
24134
24171
  }
24135
- def.push(
24136
- ...filterFunctionConflict(girClass.parent, girClass, girClass.constructors, []).flatMap(
24137
- (constructorFunction) => this.generateConstructorFunction(constructorFunction)
24138
- )
24139
- );
24140
24172
  if (def.length) {
24141
24173
  def.unshift(...addInfoComment("Constructors", indentCount));
24142
24174
  }
@@ -24432,7 +24464,8 @@ ${girClass.__ts__indexSignature}
24432
24464
  def.push(this.generateExport("class", classHead, "{"));
24433
24465
  }
24434
24466
  const gtypeNamespace = this.namespace.namespace === "GObject" ? "" : "GObject.";
24435
- def.push(`static $gtype: ${gtypeNamespace}GType<${girClass.gtype}>;`);
24467
+ const classBodyIndent = generateIndent(1);
24468
+ def.push(`${classBodyIndent}static $gtype: ${gtypeNamespace}GType<${girClass.gtype}>;`);
24436
24469
  if (girClass.__ts__indexSignature) {
24437
24470
  def.push(`
24438
24471
  ${girClass.__ts__indexSignature}
@@ -24452,6 +24485,8 @@ ${girClass.__ts__indexSignature}
24452
24485
  const rawProperties = girClass.implementedProperties();
24453
24486
  const rawMethods = girClass.implementedMethods(rawProperties);
24454
24487
  const selfName = `${girClass.namespace.namespace}.${girClass.name}`;
24488
+ const memberIndent = generateIndent(1);
24489
+ const indentMember = (lines) => lines.map((line) => line.length === 0 ? line : `${memberIndent}${line}`);
24455
24490
  const propsBySource = groupBySource(rawProperties);
24456
24491
  for (const [source, props] of propsBySource) {
24457
24492
  const copied = props.map((p) => p.copy({ parent: girClass }));
@@ -24461,7 +24496,8 @@ ${girClass.__ts__indexSignature}
24461
24496
  if (source !== selfName) {
24462
24497
  injectInheritedTags(memberLines, source);
24463
24498
  }
24464
- def.push(...memberLines);
24499
+ def.push("");
24500
+ def.push(...indentMember(memberLines));
24465
24501
  }
24466
24502
  }
24467
24503
  }
@@ -24478,7 +24514,8 @@ ${girClass.__ts__indexSignature}
24478
24514
  if (source !== selfName) {
24479
24515
  injectInheritedTags(memberLines, source);
24480
24516
  }
24481
- def.push(...memberLines);
24517
+ def.push("");
24518
+ def.push(...indentMember(memberLines));
24482
24519
  }
24483
24520
  }
24484
24521
  }
@@ -24563,11 +24600,13 @@ ${girClass.__ts__indexSignature}
24563
24600
  }
24564
24601
  if (girModule.members) {
24565
24602
  for (const m of girModule.members.values()) {
24566
- out.push(
24567
- ...(Array.isArray(m) ? m : [m]).flatMap((m2) => m2 ?? []).filter((m2) => m2.emit).flatMap((m2) => m2.asString(this) ?? "")
24568
- );
24603
+ const memberLines = (Array.isArray(m) ? m : [m]).flatMap((m2) => m2 ?? []).filter((m2) => m2.emit).flatMap((m2) => m2.asString(this) ?? "");
24604
+ if (memberLines.length === 0) continue;
24605
+ if (out.length > 0) out.push("");
24606
+ out.push(...memberLines);
24569
24607
  }
24570
24608
  }
24609
+ if (out.length > 0) out.push("");
24571
24610
  out.push(
24572
24611
  ...this.generateConst(
24573
24612
  new IntrospectedConstant({
@@ -24595,6 +24634,7 @@ ${girClass.__ts__indexSignature}
24595
24634
  }),
24596
24635
  0
24597
24636
  ),
24637
+ "",
24598
24638
  ...this.generateConst(
24599
24639
  new IntrospectedConstant({
24600
24640
  doc: printGirDocComment(
@@ -24621,6 +24661,12 @@ ${girClass.__ts__indexSignature}
24621
24661
  if (overrideSuffix) {
24622
24662
  out.push("", overrideSuffix);
24623
24663
  }
24664
+ if (!this.config.noNamespace) {
24665
+ const indent = generateIndent(1);
24666
+ for (let i = 0; i < out.length; i++) {
24667
+ out[i] = out[i].split("\n").map((line) => line.length === 0 ? line : `${indent}${line}`).join("\n");
24668
+ }
24669
+ }
24624
24670
  return Promise.resolve(out);
24625
24671
  }
24626
24672
  /**
@@ -25961,6 +26007,7 @@ import {
25961
26007
  normalizePath,
25962
26008
  ReferenceReflection,
25963
26009
  ReflectionCategory,
26010
+ ReflectionKind,
25964
26011
  Serializer,
25965
26012
  TSConfigReader
25966
26013
  } from "typedoc";
@@ -26558,19 +26605,59 @@ var TypeDocPipeline = class {
26558
26605
  }
26559
26606
  /**
26560
26607
  * Extract a human-readable source name from an inherited member's `inheritedFrom`.
26561
- * e.g. `"Window.accessible_role"` → looks up parent to get `"Gtk.Window"`.
26608
+ *
26609
+ * Two TypeDoc quirks are handled:
26610
+ *
26611
+ * 1. Per-class phantom inheritance chain. For `Window extends Widget extends
26612
+ * InitiallyUnowned extends Object`, Window's `bind_property.inheritedFrom`
26613
+ * points to `Widget.bind_property` (itself inherited from
26614
+ * `InitiallyUnowned.bind_property`), not directly to the original definer.
26615
+ * Walking the chain transitively yields the most-original visible source,
26616
+ * matching gi-docgen's upstream documentation convention. When the chain
26617
+ * crosses a package boundary the reference can't be resolved at runtime
26618
+ * (target=-1), but the reference's `name` field still records the
26619
+ * qualified original definer.
26620
+ *
26621
+ * 2. Accessor signatures. For an inherited accessor like Widget.cursor,
26622
+ * `inheritedFrom.reflection` may be the get/set signature whose `parent`
26623
+ * is the Accessor reflection (`Gtk.Widget.cursor`), not the class. Using
26624
+ * that name verbatim creates a per-property "Inherited from
26625
+ * Widget.cursor" section instead of a single "Inherited from Gtk.Widget"
26626
+ * section. Walking up to the nearest containing class/interface fixes it.
26562
26627
  */
26563
26628
  extractInheritedSourceName(child) {
26564
26629
  if (!child.inheritedFrom) return null;
26565
- const target = child.inheritedFrom.reflection;
26566
- if (target?.parent) {
26567
- const parent = target.parent;
26568
- const fullName = parent.getFullName();
26630
+ let target = child.inheritedFrom.reflection;
26631
+ let unresolvedBoundaryName = target ? void 0 : child.inheritedFrom.name;
26632
+ const seen = /* @__PURE__ */ new Set();
26633
+ while (target?.isDeclaration() && target.inheritedFrom) {
26634
+ if (!target.inheritedFrom.reflection) {
26635
+ unresolvedBoundaryName = target.inheritedFrom.name;
26636
+ break;
26637
+ }
26638
+ if (seen.has(target.id)) break;
26639
+ seen.add(target.id);
26640
+ target = target.inheritedFrom.reflection;
26641
+ }
26642
+ if (unresolvedBoundaryName) {
26643
+ const lastDot2 = unresolvedBoundaryName.lastIndexOf(".");
26644
+ if (lastDot2 > 0) return unresolvedBoundaryName.slice(0, lastDot2);
26645
+ }
26646
+ if (target) {
26647
+ let owner = target.parent;
26648
+ while (owner && !owner.kindOf(ReflectionKind.ClassOrInterface)) {
26649
+ owner = owner.parent;
26650
+ }
26651
+ const fullName = owner?.getFullName();
26569
26652
  if (fullName) return fullName;
26653
+ if (target.parent) {
26654
+ const parentName = target.parent.getFullName();
26655
+ if (parentName) return parentName;
26656
+ }
26570
26657
  }
26571
26658
  const name = child.inheritedFrom.name;
26572
- const dotIdx = name.indexOf(".");
26573
- return dotIdx > 0 ? name.slice(0, dotIdx) : name;
26659
+ const lastDot = name.lastIndexOf(".");
26660
+ return lastDot > 0 ? name.slice(0, lastDot) : name;
26574
26661
  }
26575
26662
  /**
26576
26663
  * Fix ReferenceReflection targets broken by TypeDoc's handling of
@@ -26795,10 +26882,10 @@ import { JSX } from "typedoc";
26795
26882
  var giDocgenFooter = (_context) => JSX.createElement(JSX.Fragment, null);
26796
26883
 
26797
26884
  // ../typedoc-theme/src/partials/header.ts
26798
- import { JSX as JSX2, ReflectionKind as ReflectionKind2 } from "typedoc";
26885
+ import { JSX as JSX2, ReflectionKind as ReflectionKind3 } from "typedoc";
26799
26886
 
26800
26887
  // ../typedoc-theme/src/utils.ts
26801
- import { ReflectionKind } from "typedoc";
26888
+ import { ReflectionKind as ReflectionKind2 } from "typedoc";
26802
26889
  function getGirTypeFromComment(refl) {
26803
26890
  const comment = refl.comment;
26804
26891
  if (!comment) return void 0;
@@ -26903,17 +26990,17 @@ function getGirNamespaceMetadata(reflection) {
26903
26990
  const mod = findOwningModule(reflection) ?? reflection;
26904
26991
  return mod.girNamespaceMetadata;
26905
26992
  }
26906
- var COMPANION_OWNER_KINDS = ReflectionKind.Class | ReflectionKind.Interface | ReflectionKind.Enum;
26993
+ var COMPANION_OWNER_KINDS = ReflectionKind2.Class | ReflectionKind2.Interface | ReflectionKind2.Enum;
26907
26994
  function findCompanionNamespace(refl) {
26908
26995
  if (!refl.kindOf(COMPANION_OWNER_KINDS)) return void 0;
26909
26996
  const parent = refl.parent;
26910
26997
  if (!parent || !("children" in parent)) return void 0;
26911
26998
  const siblings = parent.children;
26912
26999
  if (!siblings) return void 0;
26913
- return siblings.find((child) => child !== refl && child.kindOf(ReflectionKind.Namespace) && child.name === refl.name);
27000
+ return siblings.find((child) => child !== refl && child.kindOf(ReflectionKind2.Namespace) && child.name === refl.name);
26914
27001
  }
26915
27002
  function isCompanionNamespace(nsRefl) {
26916
- if (!nsRefl.kindOf(ReflectionKind.Namespace)) return false;
27003
+ if (!nsRefl.kindOf(ReflectionKind2.Namespace)) return false;
26917
27004
  const parent = nsRefl.parent;
26918
27005
  if (!parent || !("children" in parent)) return false;
26919
27006
  const siblings = parent.children;
@@ -26930,7 +27017,7 @@ function getHierarchyRoots(project) {
26930
27017
  const queue = [project];
26931
27018
  for (let i = 0; i < queue.length; i++) {
26932
27019
  const refl = queue[i];
26933
- if (refl.kindOf(ReflectionKind.Class)) {
27020
+ if (refl.kindOf(ReflectionKind2.Class)) {
26934
27021
  const decl = refl;
26935
27022
  if (decl.typeHierarchy) {
26936
27023
  roots.push(decl);
@@ -27005,7 +27092,7 @@ var giDocgenHeader = (context, props) => {
27005
27092
  } else if (props.model.isDocument()) {
27006
27093
  renderTitle = headings.document;
27007
27094
  } else {
27008
- kindString = ReflectionKind2.singularString(props.model.kind);
27095
+ kindString = ReflectionKind3.singularString(props.model.kind);
27009
27096
  }
27010
27097
  if (kindString) {
27011
27098
  const girType = getGirTypeFromComment(props.model);
@@ -27023,7 +27110,7 @@ var giDocgenHeader = (context, props) => {
27023
27110
  refl = refl.parent;
27024
27111
  }
27025
27112
  path.reverse();
27026
- const isModulePage = !props.model.isProject() && props.model.kindOf(ReflectionKind2.Module) && !props.model.parent?.parent;
27113
+ const isModulePage = !props.model.isProject() && props.model.kindOf(ReflectionKind3.Module) && !props.model.parent?.parent;
27027
27114
  const nsMeta = isModulePage ? getGirNamespaceMetadata(props.model) : void 0;
27028
27115
  return JSX2.createElement(
27029
27116
  "div",
@@ -27256,7 +27343,7 @@ var giDocgenLayout = (context, template2, props) => JSX3.createElement(
27256
27343
  import {
27257
27344
  JSX as JSX4,
27258
27345
  ReferenceReflection as ReferenceReflection2,
27259
- ReflectionKind as ReflectionKind3
27346
+ ReflectionKind as ReflectionKind4
27260
27347
  } from "typedoc";
27261
27348
  function isNoneSection(section) {
27262
27349
  return section.title.toLocaleLowerCase() === "none";
@@ -27364,11 +27451,11 @@ function giDocgenModuleReflection(context, mod) {
27364
27451
  const parent = mod.parent;
27365
27452
  const siblings = parent && "children" in parent ? parent.children : void 0;
27366
27453
  const companionOwner = siblings?.find(
27367
- (child) => child !== mod && child.kindOf(ReflectionKind3.Class | ReflectionKind3.Interface | ReflectionKind3.Enum) && child.name === mod.name
27454
+ (child) => child !== mod && child.kindOf(ReflectionKind4.Class | ReflectionKind4.Interface | ReflectionKind4.Enum) && child.name === mod.name
27368
27455
  );
27369
27456
  if (companionOwner) {
27370
27457
  const ownerUrl = context.urlTo(companionOwner);
27371
- const kindName = companionOwner.kindOf(ReflectionKind3.Enum) ? "enum" : companionOwner.kindOf(ReflectionKind3.Interface) ? "interface" : "class";
27458
+ const kindName = companionOwner.kindOf(ReflectionKind4.Enum) ? "enum" : companionOwner.kindOf(ReflectionKind4.Interface) ? "interface" : "class";
27372
27459
  return JSX4.createElement(
27373
27460
  JSX4.Fragment,
27374
27461
  null,
@@ -27441,7 +27528,7 @@ function giDocgenModuleReflection(context, mod) {
27441
27528
  );
27442
27529
  }),
27443
27530
  // 3. README content — rendered at the bottom in a collapsible section
27444
- mod.isDeclaration() && mod.kind === ReflectionKind3.Module && !!mod.readme?.length && (() => {
27531
+ mod.isDeclaration() && mod.kind === ReflectionKind4.Module && !!mod.readme?.length && (() => {
27445
27532
  const readmeTitle = "Readme";
27446
27533
  context.page.startNewSection(readmeTitle);
27447
27534
  return JSX4.createElement(
@@ -27663,10 +27750,10 @@ var giDocgenPageSidebar = (context, props) => JSX7.createElement(JSX7.Fragment,
27663
27750
  import { readFileSync as readFileSync7 } from "node:fs";
27664
27751
  import { dirname as dirname8, join as join14 } from "node:path";
27665
27752
  import { fileURLToPath as fileURLToPath5 } from "node:url";
27666
- import { i18n, JSX as JSX8, ReflectionKind as ReflectionKind4 } from "typedoc";
27753
+ import { i18n, JSX as JSX8, ReflectionKind as ReflectionKind5 } from "typedoc";
27667
27754
  function getTsForGirVersion() {
27668
27755
  if (true) {
27669
- return "4.0.0-rc.7";
27756
+ return "4.0.0-rc.9";
27670
27757
  }
27671
27758
  const __dirname3 = dirname8(fileURLToPath5(import.meta.url));
27672
27759
  return JSON.parse(readFileSync7(join14(__dirname3, "..", "..", "package.json"), "utf8")).version;
@@ -27687,9 +27774,9 @@ function giDocgenModuleInfo(context, mod, nsMeta) {
27687
27774
  );
27688
27775
  });
27689
27776
  const childNamespaces = mod.children?.filter(
27690
- (child) => child.kindOf(ReflectionKind4.Namespace) && child.name !== "default" && !isCompanionNamespace(child)
27777
+ (child) => child.kindOf(ReflectionKind5.Namespace) && child.name !== "default" && !isCompanionNamespace(child)
27691
27778
  );
27692
- const childModules = mod.children?.filter((child) => child.kindOf(ReflectionKind4.Module) && child.name !== "default");
27779
+ const childModules = mod.children?.filter((child) => child.kindOf(ReflectionKind5.Module) && child.name !== "default");
27693
27780
  const packageVersion = mod.packageVersion || nsMeta.packageVersion;
27694
27781
  const pageModel = context.page.model;
27695
27782
  const isChildActive = (child) => {
@@ -27899,7 +27986,7 @@ var giDocgenToolbar = (context, _props) => {
27899
27986
  import {
27900
27987
  DeclarationReflection as DeclarationReflection3,
27901
27988
  JSX as JSX10,
27902
- ReflectionKind as ReflectionKind5,
27989
+ ReflectionKind as ReflectionKind6,
27903
27990
  i18n as i18n2
27904
27991
  } from "typedoc";
27905
27992
  function hasTypeParameters(reflection) {
@@ -27972,10 +28059,10 @@ function renderCompanionNamespaceSection(context, companionNs) {
27972
28059
  );
27973
28060
  }
27974
28061
  function giDocgenReflectionTemplate(context, props) {
27975
- if (props.model.kindOf(ReflectionKind5.TypeAlias | ReflectionKind5.Variable) && props.model instanceof DeclarationReflection3 && props.model.type) {
28062
+ if (props.model.kindOf(ReflectionKind6.TypeAlias | ReflectionKind6.Variable) && props.model instanceof DeclarationReflection3 && props.model.type) {
27976
28063
  return context.memberDeclaration(props.model);
27977
28064
  }
27978
- if (props.model.kindOf(ReflectionKind5.ExportContainer) && (props.model.isDeclaration() || props.model.isProject())) {
28065
+ if (props.model.kindOf(ReflectionKind6.ExportContainer) && (props.model.isDeclaration() || props.model.isProject())) {
27979
28066
  return context.moduleReflection(props.model);
27980
28067
  }
27981
28068
  const companionNs = props.model instanceof DeclarationReflection3 ? findCompanionNamespace(props.model) : void 0;
@@ -28251,21 +28338,9 @@ var HtmlDocGenerator = class _HtmlDocGenerator {
28251
28338
  };
28252
28339
 
28253
28340
  // src/formatters/typescript-formatter.ts
28254
- import prettier from "prettier";
28255
- var logger4 = new Logger(false, "TypeScriptFormatter");
28256
28341
  var TypeScriptFormatter = class extends Formatter {
28257
28342
  format(input2) {
28258
- try {
28259
- return prettier.format(input2, {
28260
- singleQuote: true,
28261
- parser: "typescript",
28262
- printWidth: 120,
28263
- tabWidth: 4
28264
- });
28265
- } catch (error) {
28266
- logger4.warn("Failed to format with prettier, returning original input", error);
28267
- return Promise.resolve(input2);
28268
- }
28343
+ return Promise.resolve(input2);
28269
28344
  }
28270
28345
  };
28271
28346
 
@@ -28355,7 +28430,7 @@ var GenerationHandler = class {
28355
28430
  async function runGenerationCommand(args, options2) {
28356
28431
  const config = await load(args);
28357
28432
  const generateConfig = getOptionsGeneration(config);
28358
- const logger6 = new Logger(true, options2.loggerName);
28433
+ const logger5 = new Logger(true, options2.loggerName);
28359
28434
  const registry = new NSRegistry();
28360
28435
  options2.configureRegistry?.(registry);
28361
28436
  const moduleLoader = new ModuleLoader(generateConfig, registry);
@@ -28367,7 +28442,7 @@ async function runGenerationCommand(args, options2) {
28367
28442
  config.ignoreVersionConflicts
28368
28443
  );
28369
28444
  if (keep.length === 0) {
28370
- logger6.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
28445
+ logger5.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
28371
28446
  return;
28372
28447
  }
28373
28448
  tsForGir = new GenerationHandler(generateConfig, options2.generatorType, registry);
@@ -28493,7 +28568,7 @@ var json2 = {
28493
28568
  // src/commands/list.ts
28494
28569
  var command7 = "list [modules..]";
28495
28570
  var description7 = "Lists all available GIR modules";
28496
- var logger5 = new Logger(true, "ListCommand");
28571
+ var logger4 = new Logger(true, "ListCommand");
28497
28572
  var examples7 = [
28498
28573
  [`${APP_NAME} list -g ./vala-girs/gir-1.0`, "Lists all available GIR modules in ./vala-girs/gir-1.0"],
28499
28574
  [
@@ -28510,35 +28585,35 @@ var handler7 = async (args) => {
28510
28585
  const { grouped, failed } = await moduleLoader.getModules(config.modules, config.ignore);
28511
28586
  const moduleGroups = Object.values(grouped);
28512
28587
  if (Object.keys(grouped).length === 0) {
28513
- return logger5.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
28588
+ return logger4.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
28514
28589
  }
28515
28590
  const conflictModules = moduleGroups.filter((moduleGroup) => moduleGroup.hasConflict);
28516
28591
  const allModules = moduleGroups.filter((moduleGroup) => !moduleGroup.hasConflict);
28517
- logger5.info("\nSearch for gir files in:");
28592
+ logger4.info("\nSearch for gir files in:");
28518
28593
  for (const dir of config.girDirectories) {
28519
- logger5.white(`- ${dir}`);
28594
+ logger4.white(`- ${dir}`);
28520
28595
  }
28521
- logger5.info("\nAvailable Modules:");
28596
+ logger4.info("\nAvailable Modules:");
28522
28597
  for (const moduleGroup of allModules) {
28523
28598
  for (const module of moduleGroup.modules) {
28524
- logger5.white(`- ${module.packageName}`);
28525
- logger5.gray(` - ${module.path}`);
28599
+ logger4.white(`- ${module.packageName}`);
28600
+ logger4.gray(` - ${module.path}`);
28526
28601
  }
28527
28602
  }
28528
28603
  if (conflictModules.length > 0) {
28529
- logger5.danger("\nConflicts:");
28604
+ logger4.danger("\nConflicts:");
28530
28605
  for (const moduleGroup of conflictModules) {
28531
- logger5.white(`- ${moduleGroup.namespace}`);
28606
+ logger4.white(`- ${moduleGroup.namespace}`);
28532
28607
  for (const conflictModule of moduleGroup.modules) {
28533
- logger5.white(` - ${conflictModule.packageName}`);
28534
- logger5.gray(` - ${conflictModule.path}`);
28608
+ logger4.white(` - ${conflictModule.packageName}`);
28609
+ logger4.gray(` - ${conflictModule.path}`);
28535
28610
  }
28536
28611
  }
28537
28612
  }
28538
28613
  if (failed.length > 0) {
28539
- logger5.danger("\nDependencies not found:");
28614
+ logger4.danger("\nDependencies not found:");
28540
28615
  for (const fail of failed) {
28541
- logger5.white(`- ${fail}`);
28616
+ logger4.white(`- ${fail}`);
28542
28617
  }
28543
28618
  }
28544
28619
  };
@@ -28551,7 +28626,14 @@ var list = {
28551
28626
  };
28552
28627
 
28553
28628
  // src/start.ts
28554
- void yargs(hideBin(process.argv)).scriptName(APP_NAME).strict().usage(APP_USAGE).version(APP_VERSION).command(analyze).command(create).command(generate).command(json2).command(list).command(copy).command(doc).demandCommand(1).help().argv;
28629
+ try {
28630
+ await yargs(hideBin(process.argv)).scriptName(APP_NAME).strict().usage(APP_USAGE).version(APP_VERSION).exitProcess(false).fail(false).command(analyze).command(create).command(generate).command(json2).command(list).command(copy).command(doc).demandCommand(1).help().parseAsync();
28631
+ } catch (err) {
28632
+ const message = err instanceof Error ? err.message : String(err);
28633
+ process.stderr.write(`${message}
28634
+ `);
28635
+ process.exitCode = 1;
28636
+ }
28555
28637
  /*! Bundled license information:
28556
28638
 
28557
28639
  lodash/lodash.js:
@@ -11,7 +11,7 @@
11
11
  "clear": "rm -rf dist @types"
12
12
  },
13
13
  "devDependencies": {
14
- "@ts-for-gir/cli": "^4.0.0-rc.7",
14
+ "@ts-for-gir/cli": "^4.0.0-rc.9",
15
15
  "esbuild": "^0.28.0",
16
16
  "typescript": "^6.0.2"
17
17
  }
@@ -14,10 +14,10 @@
14
14
  "typescript": "^6.0.2"
15
15
  },
16
16
  "dependencies": {
17
- "@girs/adw-1": "^1.10.0-4.0.0-rc.6",
18
- "@girs/gio-2.0": "^2.88.0-4.0.0-rc.6",
19
- "@girs/gjs": "^4.0.0-rc.6",
20
- "@girs/glib-2.0": "^2.88.0-4.0.0-rc.6",
21
- "@girs/gtk-4.0": "^4.23.0-4.0.0-rc.6"
17
+ "@girs/adw-1": "^1.10.0-4.0.0-rc.8",
18
+ "@girs/gio-2.0": "^2.88.0-4.0.0-rc.8",
19
+ "@girs/gjs": "^4.0.0-rc.8",
20
+ "@girs/glib-2.0": "^2.88.0-4.0.0-rc.8",
21
+ "@girs/gtk-4.0": "^4.23.0-4.0.0-rc.8"
22
22
  }
23
23
  }
@@ -16,7 +16,7 @@
16
16
  "clear": "rm -rf @girs packages/*/dist"
17
17
  },
18
18
  "devDependencies": {
19
- "@ts-for-gir/cli": "^4.0.0-rc.7",
19
+ "@ts-for-gir/cli": "^4.0.0-rc.9",
20
20
  "typescript": "^6.0.2"
21
21
  }
22
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-for-gir/cli",
3
- "version": "4.0.0-rc.7",
3
+ "version": "4.0.0-rc.9",
4
4
  "description": "TypeScript type definition generator for GObject introspection GIR files",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -55,14 +55,14 @@
55
55
  ".": "./src/index.ts"
56
56
  },
57
57
  "devDependencies": {
58
- "@gi.ts/parser": "^4.0.0-rc.7",
59
- "@ts-for-gir/generator-base": "^4.0.0-rc.7",
60
- "@ts-for-gir/generator-html-doc": "^4.0.0-rc.7",
61
- "@ts-for-gir/generator-json": "^4.0.0-rc.7",
62
- "@ts-for-gir/generator-typescript": "^4.0.0-rc.7",
63
- "@ts-for-gir/lib": "^4.0.0-rc.7",
64
- "@ts-for-gir/reporter": "^4.0.0-rc.7",
65
- "@ts-for-gir/tsconfig": "^4.0.0-rc.7",
58
+ "@gi.ts/parser": "^4.0.0-rc.9",
59
+ "@ts-for-gir/generator-base": "^4.0.0-rc.9",
60
+ "@ts-for-gir/generator-html-doc": "^4.0.0-rc.9",
61
+ "@ts-for-gir/generator-json": "^4.0.0-rc.9",
62
+ "@ts-for-gir/generator-typescript": "^4.0.0-rc.9",
63
+ "@ts-for-gir/lib": "^4.0.0-rc.9",
64
+ "@ts-for-gir/reporter": "^4.0.0-rc.9",
65
+ "@ts-for-gir/tsconfig": "^4.0.0-rc.9",
66
66
  "@types/ejs": "^3.1.5",
67
67
  "@types/inquirer": "^9.0.9",
68
68
  "@types/node": "^25.6.0",
@@ -72,13 +72,12 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@inquirer/prompts": "^8.4.2",
75
- "@ts-for-gir/templates": "^4.0.0-rc.7",
75
+ "@ts-for-gir/templates": "^4.0.0-rc.9",
76
76
  "colorette": "^2.0.20",
77
77
  "cosmiconfig": "^9.0.1",
78
78
  "ejs": "^5.0.2",
79
79
  "glob": "^13.0.6",
80
80
  "inquirer": "^13.4.2",
81
- "prettier": "^3.8.3",
82
81
  "typedoc": "^0.28.19",
83
82
  "yargs": "^18.0.0"
84
83
  }
@@ -1,24 +1,17 @@
1
1
  /**
2
- * TypeScript formatter using Prettier
2
+ * TypeScript formatter pass-through.
3
+ *
4
+ * The generator's templates and string-builders emit the desired output
5
+ * shape directly; we no longer round-trip through Prettier. This shrinks
6
+ * the generation pipeline (no AST parse + reprint per file), drops a
7
+ * heavy bundler-hostile dependency for non-Node consumers, and makes
8
+ * generated output deterministic without an external formatter.
3
9
  */
4
10
 
5
- import { Formatter, Logger } from "@ts-for-gir/lib";
6
- import prettier from "prettier";
7
-
8
- const logger = new Logger(false, "TypeScriptFormatter");
11
+ import { Formatter } from "@ts-for-gir/lib";
9
12
 
10
13
  export class TypeScriptFormatter extends Formatter {
11
14
  format(input: string): Promise<string> {
12
- try {
13
- return prettier.format(input, {
14
- singleQuote: true,
15
- parser: "typescript",
16
- printWidth: 120,
17
- tabWidth: 4,
18
- });
19
- } catch (error) {
20
- logger.warn("Failed to format with prettier, returning original input", error);
21
- return Promise.resolve(input);
22
- }
15
+ return Promise.resolve(input);
23
16
  }
24
17
  }
package/src/start.ts CHANGED
@@ -4,18 +4,31 @@ import { hideBin } from "yargs/helpers";
4
4
 
5
5
  import { analyze, copy, create, doc, generate, json, list } from "./commands/index.ts";
6
6
 
7
- void yargs(hideBin(process.argv))
8
- .scriptName(APP_NAME)
9
- .strict()
10
- .usage(APP_USAGE)
11
- .version(APP_VERSION)
12
- // TODO: Fix this
13
- .command(analyze as unknown as CommandModule)
14
- .command(create as unknown as CommandModule)
15
- .command(generate as unknown as CommandModule)
16
- .command(json as unknown as CommandModule)
17
- .command(list as unknown as CommandModule)
18
- .command(copy as unknown as CommandModule)
19
- .command(doc as unknown as CommandModule)
20
- .demandCommand(1)
21
- .help().argv;
7
+ try {
8
+ await yargs(hideBin(process.argv))
9
+ .scriptName(APP_NAME)
10
+ .strict()
11
+ .usage(APP_USAGE)
12
+ .version(APP_VERSION)
13
+ // Disable yargs's internal `process.exit` and route both success
14
+ // and failure through `parseAsync` + `process.exitCode` so async
15
+ // command handlers complete and stdout drains before the runtime
16
+ // (Node or the gjsify Node-compat loader on GJS) tears down.
17
+ .exitProcess(false)
18
+ .fail(false)
19
+ // TODO: Fix this
20
+ .command(analyze as unknown as CommandModule)
21
+ .command(create as unknown as CommandModule)
22
+ .command(generate as unknown as CommandModule)
23
+ .command(json as unknown as CommandModule)
24
+ .command(list as unknown as CommandModule)
25
+ .command(copy as unknown as CommandModule)
26
+ .command(doc as unknown as CommandModule)
27
+ .demandCommand(1)
28
+ .help()
29
+ .parseAsync();
30
+ } catch (err) {
31
+ const message = err instanceof Error ? err.message : String(err);
32
+ process.stderr.write(`${message}\n`);
33
+ process.exitCode = 1;
34
+ }