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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/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.8";
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.8";
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";
@@ -20986,7 +20990,6 @@ function addInfoComment(comment, indentCount = 0) {
20986
20990
  if (comment) {
20987
20991
  def.push("");
20988
20992
  def.push(`${indent}// ${comment}`);
20989
- def.push("");
20990
20993
  }
20991
20994
  return def;
20992
20995
  }
@@ -20994,7 +20997,7 @@ function mergeDescs(descs, comment, indentCount = 1) {
20994
20997
  const def = [];
20995
20998
  const indent = generateIndent(indentCount);
20996
20999
  for (const desc of descs) {
20997
- def.push(`${indent}${desc}`);
21000
+ def.push(desc.length === 0 ? desc : `${indent}${desc}`);
20998
21001
  }
20999
21002
  if (def.length > 0) {
21000
21003
  def.unshift(...addInfoComment(comment, indentCount));
@@ -21037,8 +21040,14 @@ function convertCDefaultValue(rawValue, ns) {
21037
21040
  // ../lib/src/utils/path.ts
21038
21041
  import { dirname as dirname4, resolve as resolve3 } from "node:path";
21039
21042
  import { fileURLToPath as fileURLToPath3 } from "node:url";
21040
- var __filename = fileURLToPath3(import.meta.url);
21041
- var __dirname = resolve3(dirname4(__filename), "../..");
21043
+ function resolvePackageDir() {
21044
+ try {
21045
+ return resolve3(dirname4(fileURLToPath3(import.meta.url)), "../..");
21046
+ } catch {
21047
+ return "";
21048
+ }
21049
+ }
21050
+ var __dirname = resolvePackageDir();
21042
21051
 
21043
21052
  // src/start.ts
21044
21053
  import yargs from "yargs";
@@ -21820,7 +21829,7 @@ var formatAsCsv = (problems) => {
21820
21829
  ]);
21821
21830
  return [headers.join(","), ...rows.map((row) => row.join(","))].join("\n");
21822
21831
  };
21823
- var exportResults = (problems, filePath, format, logger6) => {
21832
+ var exportResults = (problems, filePath, format, logger5) => {
21824
21833
  let content;
21825
21834
  switch (format) {
21826
21835
  case "json": {
@@ -21840,14 +21849,14 @@ var exportResults = (problems, filePath, format, logger6) => {
21840
21849
  }
21841
21850
  }
21842
21851
  writeFileSync(filePath, content, "utf-8");
21843
- logger6.success(`Results exported to: ${filePath}`);
21852
+ logger5.success(`Results exported to: ${filePath}`);
21844
21853
  };
21845
21854
  var handler = async (args) => {
21846
- const logger6 = new Logger(args.verbose ?? false, "AnalyzeCommand");
21855
+ const logger5 = new Logger(args.verbose ?? false, "AnalyzeCommand");
21847
21856
  try {
21848
21857
  const report = loadReportFile(args.reportFile);
21849
21858
  if (args.verbose) {
21850
- logger6.info(`Loaded report with ${report.problems.length} problems`);
21859
+ logger5.info(`Loaded report with ${report.problems.length} problems`);
21851
21860
  }
21852
21861
  const hasFilters = Boolean(args.severity || args.category || args.namespace || args.type || args.search);
21853
21862
  if (args.summary || !hasFilters) {
@@ -21862,7 +21871,7 @@ var handler = async (args) => {
21862
21871
  }
21863
21872
  if (args.export) {
21864
21873
  const format = args.format ?? "json";
21865
- exportResults(filteredProblems, args.export, format, logger6);
21874
+ exportResults(filteredProblems, args.export, format, logger5);
21866
21875
  }
21867
21876
  if (hasFilters && !args.summary) {
21868
21877
  console.log(
@@ -21872,7 +21881,7 @@ var handler = async (args) => {
21872
21881
  }
21873
21882
  } catch (error) {
21874
21883
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
21875
- logger6.error(`Analysis failed: ${errorMessage}`);
21884
+ logger5.error(`Analysis failed: ${errorMessage}`);
21876
21885
  process.exit(1);
21877
21886
  }
21878
21887
  };
@@ -22501,8 +22510,8 @@ var PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__";
22501
22510
  var TEXT_FILE_EXT = /* @__PURE__ */ new Set([".json", ".md", ".ts", ".tsx", ".js", ".mjs", ".cjs"]);
22502
22511
  var builder3 = createBuilder(createOptions, examples3);
22503
22512
  function findTemplatesRoot() {
22504
- const __filename2 = fileURLToPath4(import.meta.url);
22505
- const __dirname3 = dirname6(__filename2);
22513
+ const __filename = fileURLToPath4(import.meta.url);
22514
+ const __dirname3 = dirname6(__filename);
22506
22515
  const candidates = [
22507
22516
  // Bundled production binary (bin/ts-for-gir): ../dist-templates
22508
22517
  resolve5(__dirname3, "..", "dist-templates"),
@@ -23004,7 +23013,6 @@ var SignalGenerator = class {
23004
23013
  const def = [];
23005
23014
  const indent = generateIndent(indentCount);
23006
23015
  def.push(`${indent}// Signal signatures`);
23007
- def.push(`${indent}interface SignalSignatures`);
23008
23016
  const parentSignatures = [];
23009
23017
  const parentResolution = girClass.resolveParents().extends();
23010
23018
  if (parentResolution && parentResolution.node instanceof IntrospectedClass) {
@@ -23024,20 +23032,22 @@ var SignalGenerator = class {
23024
23032
  return interfaceTypeIdentifier ? `${interfaceTypeIdentifier}.SignalSignatures` : null;
23025
23033
  }).filter((sig) => !!sig);
23026
23034
  parentSignatures.push(...interfaceSignatures);
23035
+ let signatureHead;
23027
23036
  if (parentSignatures.length > 0) {
23028
- def.push(` extends ${parentSignatures.join(", ")} {`);
23037
+ signatureHead = `${indent}interface SignalSignatures extends ${parentSignatures.join(", ")} {`;
23029
23038
  } else {
23030
23039
  const isGObjectObject = girClass.name === "Object" && girClass.namespace.namespace === "GObject";
23031
23040
  if (isGObjectObject) {
23032
- def.push(" {");
23041
+ signatureHead = `${indent}interface SignalSignatures {`;
23033
23042
  } else {
23034
23043
  const gobjectNamespace = this.namespace.assertInstalledImport("GObject");
23035
23044
  const gobjectObjectClass = gobjectNamespace.assertClass("Object");
23036
23045
  const gobjectRef = gobjectObjectClass.getType().resolveIdentifier(this.namespace, this.config)?.print(this.namespace, this.config);
23037
23046
  const fallbackRef = gobjectRef ? `${gobjectRef}.SignalSignatures` : "GObject.Object.SignalSignatures";
23038
- def.push(` extends ${fallbackRef} {`);
23047
+ signatureHead = `${indent}interface SignalSignatures extends ${fallbackRef} {`;
23039
23048
  }
23040
23049
  }
23050
+ def.push(signatureHead);
23041
23051
  const allSignals = girClass.getAllSignals();
23042
23052
  allSignals.forEach((signalInfo) => {
23043
23053
  let cbType;
@@ -23083,7 +23093,6 @@ var SignalGenerator = class {
23083
23093
  def.push(`${indent} ${signalKey}: ${cbType};`);
23084
23094
  });
23085
23095
  def.push(`${indent}}`);
23086
- def.push("");
23087
23096
  return def;
23088
23097
  }
23089
23098
  /**
@@ -23109,8 +23118,7 @@ var SignalGenerator = class {
23109
23118
  `${indent} * It is not defined at runtime and should not be accessed in JS code.`,
23110
23119
  `${indent} * @internal`,
23111
23120
  `${indent} */`,
23112
- `${indent}$signals: ${girClass.name}.SignalSignatures;`,
23113
- ""
23121
+ `${indent}$signals: ${girClass.name}.SignalSignatures;`
23114
23122
  ];
23115
23123
  }
23116
23124
  /**
@@ -23140,27 +23148,32 @@ var SignalGenerator = class {
23140
23148
  const filteredFunctions = filterConflicts(girClass.namespace, girClass, signalFunctions, 0 /* DELETE */);
23141
23149
  const allowedNames = new Set(filteredFunctions.map((f) => f.name));
23142
23150
  const gobjectRef = this.namespace.namespace === "GObject" ? "" : "GObject.";
23143
- const methods = [];
23151
+ const groups = [];
23144
23152
  if (allowedNames.has("connect")) {
23145
- methods.push(
23153
+ groups.push([
23146
23154
  SIGNAL_JSDOC,
23147
23155
  `connect<K extends keyof ${girClass.name}.SignalSignatures>(signal: K, callback: ${gobjectRef}SignalCallback<this, ${girClass.name}.SignalSignatures[K]>): number;`,
23148
23156
  "connect(signal: string, callback: (...args: any[]) => any): number;"
23149
- );
23157
+ ]);
23150
23158
  }
23151
23159
  if (allowedNames.has("connect_after")) {
23152
- methods.push(
23160
+ groups.push([
23153
23161
  SIGNAL_JSDOC,
23154
23162
  `connect_after<K extends keyof ${girClass.name}.SignalSignatures>(signal: K, callback: ${gobjectRef}SignalCallback<this, ${girClass.name}.SignalSignatures[K]>): number;`,
23155
23163
  "connect_after(signal: string, callback: (...args: any[]) => any): number;"
23156
- );
23164
+ ]);
23157
23165
  }
23158
23166
  if (allowedNames.has("emit")) {
23159
- methods.push(
23167
+ groups.push([
23160
23168
  SIGNAL_JSDOC,
23161
23169
  `emit<K extends keyof ${girClass.name}.SignalSignatures>(signal: K, ...args: ${gobjectRef}GjsParameters<${girClass.name}.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never): void;`,
23162
23170
  "emit(signal: string, ...args: any[]): void;"
23163
- );
23171
+ ]);
23172
+ }
23173
+ const methods = [];
23174
+ for (const group of groups) {
23175
+ if (methods.length > 0) methods.push("");
23176
+ methods.push(...group);
23164
23177
  }
23165
23178
  return methods;
23166
23179
  }
@@ -23369,37 +23382,37 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
23369
23382
  generateClassCallback(node) {
23370
23383
  return this.generateCallback(node);
23371
23384
  }
23372
- generateConstructor(node) {
23385
+ generateConstructor(node, indentCount = 0) {
23373
23386
  const Parameters = this.generateParameters(node.parameters);
23374
- return [`constructor(${Parameters});`];
23387
+ const indent = generateIndent(indentCount);
23388
+ return [`${indent}constructor(${Parameters});`];
23375
23389
  }
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
- ];
23390
+ generateDirectAllocationConstructor(node, indentCount = 1) {
23391
+ const indent = generateIndent(indentCount);
23392
+ const fieldIndent = generateIndent(indentCount + 1);
23393
+ 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");
23394
+ return ["", `${indent}constructor(properties?: Partial<{`, constructorFields, `${indent}}>);`];
23384
23395
  }
23385
23396
  generateParameters(parameters) {
23386
23397
  return parameters.flatMap((p) => {
23387
23398
  return p.asString(this);
23388
23399
  }).join(", ");
23389
23400
  }
23390
- generateConstructorFunction(node) {
23401
+ generateConstructorFunction(node, indentCount = 0) {
23391
23402
  const { namespace, options: options2 } = this;
23392
23403
  const Parameters = this.generateParameters(node.parameters);
23404
+ const indent = generateIndent(indentCount);
23393
23405
  const invalid = isInvalid(node.name);
23394
23406
  const name = invalid ? `["${node.name}"]` : node.name;
23395
23407
  const warning = node.getWarning();
23396
23408
  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
- ];
23409
+ const lines = [];
23410
+ if (warning) lines.push(`${indent}${warning}`);
23411
+ lines.push(...this.addGirDocComment(node.doc, [], indentCount));
23412
+ lines.push(
23413
+ `${indent}static ${name}${genericTypes}(${Parameters}): ${node.return().resolve(namespace, options2).rootPrint(namespace, options2)};`
23414
+ );
23415
+ return lines;
23403
23416
  }
23404
23417
  generateRecord(node) {
23405
23418
  const structFor = node.structFor;
@@ -23444,25 +23457,30 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
23444
23457
  })
23445
23458
  );
23446
23459
  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
- ];
23460
+ const bodyIndent = generateIndent(1);
23461
+ const bodyLines = [];
23462
+ if (isGObject) bodyLines.push(`${bodyIndent}$gtype: ${gtypeNamespace}GType<${node.name}>;`);
23463
+ bodyLines.push(`${bodyIndent}prototype: ${node.name};`);
23464
+ for (const sf of staticFields) {
23465
+ for (const line of sf.asString(this)) {
23466
+ if (line.length === 0) continue;
23467
+ bodyLines.push(`${bodyIndent}${line.replace(/^\s+/, "")}`);
23468
+ }
23469
+ }
23470
+ for (const sf of staticFunctions) {
23471
+ for (const line of sf.asClassFunction(node).asString(this)) {
23472
+ if (line.length === 0) continue;
23473
+ bodyLines.push(`${bodyIndent}${line.replace(/^\s+/, "")}`);
23474
+ }
23475
+ }
23476
+ return [`export interface ${node.name}Namespace {`, ...bodyLines, "}"];
23457
23477
  }
23458
23478
  generateInterfaceDeclaration(node) {
23459
23479
  return [
23460
- `
23461
-
23462
- export const ${node.name}: ${node.name}Namespace & {
23463
- new (): ${node.name} // This allows \`obj instanceof ${node.name}\`
23464
- }
23465
- `
23480
+ "",
23481
+ `export const ${node.name}: ${node.name}Namespace & {`,
23482
+ ` new (): ${node.name}; // This allows \`obj instanceof ${node.name}\``,
23483
+ "};"
23466
23484
  ];
23467
23485
  }
23468
23486
  generateError(node) {
@@ -23617,13 +23635,16 @@ export const ${node.name}: ${node.name}Namespace & {
23617
23635
  }
23618
23636
  }
23619
23637
  const typeStr = this.generateDirectedType(type, "out" /* Out */);
23620
- desc.push(`${indent}${commentOut}${staticStr}${readonly}${name}${affix}: ${typeStr}`);
23638
+ desc.push(`${indent}${commentOut}${staticStr}${readonly}${name}${affix}: ${typeStr};`);
23621
23639
  return desc;
23622
23640
  }
23623
23641
  generateProperties(tsProps, comment, indentCount = 0) {
23624
23642
  const def = [];
23625
23643
  for (const tsProp of tsProps) {
23626
- def.push(...this.generateProperty(tsProp, false, indentCount));
23644
+ const propLines = this.generateProperty(tsProp, false, indentCount);
23645
+ if (propLines.length === 0) continue;
23646
+ if (def.length > 0) def.push("");
23647
+ def.push(...propLines);
23627
23648
  }
23628
23649
  if (def.length > 0) {
23629
23650
  def.unshift(...addInfoComment(comment, indentCount));
@@ -23633,7 +23654,10 @@ export const ${node.name}: ${node.name}Namespace & {
23633
23654
  generateFields(tsProps, comment, indentCount = 0) {
23634
23655
  const def = [];
23635
23656
  for (const tsProp of tsProps) {
23636
- def.push(...this.generateField(tsProp));
23657
+ const fieldLines = this.generateField(tsProp, indentCount);
23658
+ if (fieldLines.length === 0) continue;
23659
+ if (def.length > 0) def.push("");
23660
+ def.push(...fieldLines);
23637
23661
  }
23638
23662
  if (def.length > 0) {
23639
23663
  def.unshift(...addInfoComment(comment, indentCount));
@@ -23813,8 +23837,8 @@ export const ${node.name}: ${node.name}Namespace & {
23813
23837
  }
23814
23838
  return typeStr;
23815
23839
  }
23816
- generateClassFunction(node) {
23817
- return this.generateFunction(node);
23840
+ generateClassFunction(node, indentCount = 0) {
23841
+ return this.generateFunction(node, indentCount);
23818
23842
  }
23819
23843
  generateFunction(tsFunction, indentCount = 0) {
23820
23844
  const def = [];
@@ -23870,14 +23894,17 @@ export const ${node.name}: ${node.name}Namespace & {
23870
23894
  def.push(
23871
23895
  `${indent}${commentOut}${exportStr}${staticStr}${globalStr}${name}${genericStr}(${inParamsDef.join(
23872
23896
  ", "
23873
- )})${retSep} ${returnType}`
23897
+ )})${retSep} ${returnType};`
23874
23898
  );
23875
23899
  return def;
23876
23900
  }
23877
23901
  generateFunctions(tsFunctions, indentCount = 1, comment) {
23878
23902
  const def = [];
23879
23903
  for (const girFunction of tsFunctions) {
23880
- def.push(...this.generateFunction(girFunction, indentCount));
23904
+ const fnLines = this.generateFunction(girFunction, indentCount);
23905
+ if (fnLines.length === 0) continue;
23906
+ if (def.length > 0) def.push("");
23907
+ def.push(...fnLines);
23881
23908
  }
23882
23909
  if (def.length > 0) {
23883
23910
  def.unshift(...addInfoComment(comment, indentCount));
@@ -23903,7 +23930,7 @@ export const ${node.name}: ${node.name}Namespace & {
23903
23930
  }
23904
23931
  const interfaceHead = `${name}${genericParameters}`;
23905
23932
  def.push(this.generateExport("interface", `${interfaceHead}`, "{", indentCount));
23906
- def.push(`${indentBody}(${inParamsDef.join(", ")}): ${returnTypeStr}`);
23933
+ def.push(`${indentBody}(${inParamsDef.join(", ")}): ${returnTypeStr};`);
23907
23934
  def.push(`${indent}}`);
23908
23935
  return def;
23909
23936
  }
@@ -23973,7 +24000,7 @@ export const ${node.name}: ${node.name}Namespace & {
23973
24000
  const exp = !this.config.noNamespace ? "" : "export ";
23974
24001
  const ComputedName = generateMemberName(tsConst);
23975
24002
  const typeStr = this.generateType(resolveDirectedType(tsConst.type, "out" /* Out */) ?? tsConst.type);
23976
- desc.push(`${indent}${exp}const ${ComputedName}: ${typeStr}`);
24003
+ desc.push(`${indent}${exp}const ${ComputedName}: ${typeStr};`);
23977
24004
  return desc;
23978
24005
  }
23979
24006
  generateAlias(girAlias, indentCount = 0) {
@@ -23995,7 +24022,7 @@ export const ${node.name}: ${node.name}Namespace & {
23995
24022
  }).join(", ");
23996
24023
  const generics = genericList ? `<${genericList}>` : "";
23997
24024
  const exp = !this.config.noNamespace ? "" : "export ";
23998
- desc.push(`${indent}${exp}type ${girAlias.name}${generics} = ${girAlias.type.print(this.namespace, this.config)}`);
24025
+ desc.push(`${indent}${exp}type ${girAlias.name}${generics} = ${girAlias.type.print(this.namespace, this.config)};`);
23999
24026
  return desc;
24000
24027
  }
24001
24028
  generateConstructPropsInterface(girClass, indentCount = 0) {
@@ -24027,10 +24054,11 @@ export const ${node.name}: ${node.name}Namespace & {
24027
24054
  }
24028
24055
  def.push(...addInfoComment("Constructor properties interface", indentCount));
24029
24056
  const { props } = girClass;
24030
- const ConstructorProps = filterConflicts(girClass.namespace, girClass, props, 1 /* PRESERVE */).flatMap((v) => v.asString(this, true)).join("\n ");
24057
+ const memberIndent = generateIndent(indentCount + 1);
24058
+ const constructorPropMembers = filterConflicts(girClass.namespace, girClass, props, 1 /* PRESERVE */).flatMap((v) => v.asString(this, true)).map((m) => `${memberIndent}${m}`).join("\n");
24031
24059
  def.push(`${indent}${exp}interface ${constructPropInterfaceName}${genericTypes} ${ext} {`);
24032
- def.push(ConstructorProps);
24033
- def.push(`${indent}}`, "");
24060
+ def.push(constructorPropMembers);
24061
+ def.push(`${indent}}`);
24034
24062
  return def;
24035
24063
  }
24036
24064
  generateClassStaticFields(girClass, indentCount = 1) {
@@ -24121,22 +24149,23 @@ export const ${node.name}: ${node.name}Namespace & {
24121
24149
  }
24122
24150
  generateClassConstructors(girClass, indentCount = 1) {
24123
24151
  const def = [];
24152
+ const indent = generateIndent(indentCount);
24124
24153
  if (girClass.mainConstructor instanceof IntrospectedDirectAllocationConstructor)
24125
- def.push(...this.generateDirectAllocationConstructor(girClass.mainConstructor));
24154
+ def.push(...this.generateDirectAllocationConstructor(girClass.mainConstructor, indentCount));
24126
24155
  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");
24156
+ def.push(...this.generateConstructor(girClass.mainConstructor, indentCount));
24157
+ else if (girClass.namespace.namespace === "GObject" && girClass.name === "Object" || girClass.someParent((p) => p.namespace.namespace === "GObject" && p.name === "Object")) {
24158
+ def.push(`${indent}constructor(properties?: Partial<${girClass.name}.ConstructorProps>, ...args: any[]);`);
24159
+ }
24160
+ const hasInit = girClass instanceof IntrospectedClass && (!girClass.__ts__indexSignature || girClass.__ts__indexSignature.includes("[key: string]: any"));
24161
+ if (hasInit) {
24162
+ if (def.length > 0) def.push("");
24163
+ def.push(`${indent}_init(...args: any[]): void;`);
24164
+ }
24165
+ for (const constructorFunction of filterFunctionConflict(girClass.parent, girClass, girClass.constructors, [])) {
24166
+ if (def.length > 0) def.push("");
24167
+ def.push(...this.generateConstructorFunction(constructorFunction, indentCount));
24134
24168
  }
24135
- def.push(
24136
- ...filterFunctionConflict(girClass.parent, girClass, girClass.constructors, []).flatMap(
24137
- (constructorFunction) => this.generateConstructorFunction(constructorFunction)
24138
- )
24139
- );
24140
24169
  if (def.length) {
24141
24170
  def.unshift(...addInfoComment("Constructors", indentCount));
24142
24171
  }
@@ -24432,7 +24461,8 @@ ${girClass.__ts__indexSignature}
24432
24461
  def.push(this.generateExport("class", classHead, "{"));
24433
24462
  }
24434
24463
  const gtypeNamespace = this.namespace.namespace === "GObject" ? "" : "GObject.";
24435
- def.push(`static $gtype: ${gtypeNamespace}GType<${girClass.gtype}>;`);
24464
+ const classBodyIndent = generateIndent(1);
24465
+ def.push(`${classBodyIndent}static $gtype: ${gtypeNamespace}GType<${girClass.gtype}>;`);
24436
24466
  if (girClass.__ts__indexSignature) {
24437
24467
  def.push(`
24438
24468
  ${girClass.__ts__indexSignature}
@@ -24452,6 +24482,8 @@ ${girClass.__ts__indexSignature}
24452
24482
  const rawProperties = girClass.implementedProperties();
24453
24483
  const rawMethods = girClass.implementedMethods(rawProperties);
24454
24484
  const selfName = `${girClass.namespace.namespace}.${girClass.name}`;
24485
+ const memberIndent = generateIndent(1);
24486
+ const indentMember = (lines) => lines.map((line) => line.length === 0 ? line : `${memberIndent}${line}`);
24455
24487
  const propsBySource = groupBySource(rawProperties);
24456
24488
  for (const [source, props] of propsBySource) {
24457
24489
  const copied = props.map((p) => p.copy({ parent: girClass }));
@@ -24461,7 +24493,8 @@ ${girClass.__ts__indexSignature}
24461
24493
  if (source !== selfName) {
24462
24494
  injectInheritedTags(memberLines, source);
24463
24495
  }
24464
- def.push(...memberLines);
24496
+ def.push("");
24497
+ def.push(...indentMember(memberLines));
24465
24498
  }
24466
24499
  }
24467
24500
  }
@@ -24478,7 +24511,8 @@ ${girClass.__ts__indexSignature}
24478
24511
  if (source !== selfName) {
24479
24512
  injectInheritedTags(memberLines, source);
24480
24513
  }
24481
- def.push(...memberLines);
24514
+ def.push("");
24515
+ def.push(...indentMember(memberLines));
24482
24516
  }
24483
24517
  }
24484
24518
  }
@@ -24563,11 +24597,13 @@ ${girClass.__ts__indexSignature}
24563
24597
  }
24564
24598
  if (girModule.members) {
24565
24599
  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
- );
24600
+ const memberLines = (Array.isArray(m) ? m : [m]).flatMap((m2) => m2 ?? []).filter((m2) => m2.emit).flatMap((m2) => m2.asString(this) ?? "");
24601
+ if (memberLines.length === 0) continue;
24602
+ if (out.length > 0) out.push("");
24603
+ out.push(...memberLines);
24569
24604
  }
24570
24605
  }
24606
+ if (out.length > 0) out.push("");
24571
24607
  out.push(
24572
24608
  ...this.generateConst(
24573
24609
  new IntrospectedConstant({
@@ -24595,6 +24631,7 @@ ${girClass.__ts__indexSignature}
24595
24631
  }),
24596
24632
  0
24597
24633
  ),
24634
+ "",
24598
24635
  ...this.generateConst(
24599
24636
  new IntrospectedConstant({
24600
24637
  doc: printGirDocComment(
@@ -24621,6 +24658,12 @@ ${girClass.__ts__indexSignature}
24621
24658
  if (overrideSuffix) {
24622
24659
  out.push("", overrideSuffix);
24623
24660
  }
24661
+ if (!this.config.noNamespace) {
24662
+ const indent = generateIndent(1);
24663
+ for (let i = 0; i < out.length; i++) {
24664
+ out[i] = out[i].split("\n").map((line) => line.length === 0 ? line : `${indent}${line}`).join("\n");
24665
+ }
24666
+ }
24624
24667
  return Promise.resolve(out);
24625
24668
  }
24626
24669
  /**
@@ -25961,6 +26004,7 @@ import {
25961
26004
  normalizePath,
25962
26005
  ReferenceReflection,
25963
26006
  ReflectionCategory,
26007
+ ReflectionKind,
25964
26008
  Serializer,
25965
26009
  TSConfigReader
25966
26010
  } from "typedoc";
@@ -26558,19 +26602,59 @@ var TypeDocPipeline = class {
26558
26602
  }
26559
26603
  /**
26560
26604
  * 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"`.
26605
+ *
26606
+ * Two TypeDoc quirks are handled:
26607
+ *
26608
+ * 1. Per-class phantom inheritance chain. For `Window extends Widget extends
26609
+ * InitiallyUnowned extends Object`, Window's `bind_property.inheritedFrom`
26610
+ * points to `Widget.bind_property` (itself inherited from
26611
+ * `InitiallyUnowned.bind_property`), not directly to the original definer.
26612
+ * Walking the chain transitively yields the most-original visible source,
26613
+ * matching gi-docgen's upstream documentation convention. When the chain
26614
+ * crosses a package boundary the reference can't be resolved at runtime
26615
+ * (target=-1), but the reference's `name` field still records the
26616
+ * qualified original definer.
26617
+ *
26618
+ * 2. Accessor signatures. For an inherited accessor like Widget.cursor,
26619
+ * `inheritedFrom.reflection` may be the get/set signature whose `parent`
26620
+ * is the Accessor reflection (`Gtk.Widget.cursor`), not the class. Using
26621
+ * that name verbatim creates a per-property "Inherited from
26622
+ * Widget.cursor" section instead of a single "Inherited from Gtk.Widget"
26623
+ * section. Walking up to the nearest containing class/interface fixes it.
26562
26624
  */
26563
26625
  extractInheritedSourceName(child) {
26564
26626
  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();
26627
+ let target = child.inheritedFrom.reflection;
26628
+ let unresolvedBoundaryName = target ? void 0 : child.inheritedFrom.name;
26629
+ const seen = /* @__PURE__ */ new Set();
26630
+ while (target?.isDeclaration() && target.inheritedFrom) {
26631
+ if (!target.inheritedFrom.reflection) {
26632
+ unresolvedBoundaryName = target.inheritedFrom.name;
26633
+ break;
26634
+ }
26635
+ if (seen.has(target.id)) break;
26636
+ seen.add(target.id);
26637
+ target = target.inheritedFrom.reflection;
26638
+ }
26639
+ if (unresolvedBoundaryName) {
26640
+ const lastDot2 = unresolvedBoundaryName.lastIndexOf(".");
26641
+ if (lastDot2 > 0) return unresolvedBoundaryName.slice(0, lastDot2);
26642
+ }
26643
+ if (target) {
26644
+ let owner = target.parent;
26645
+ while (owner && !owner.kindOf(ReflectionKind.ClassOrInterface)) {
26646
+ owner = owner.parent;
26647
+ }
26648
+ const fullName = owner?.getFullName();
26569
26649
  if (fullName) return fullName;
26650
+ if (target.parent) {
26651
+ const parentName = target.parent.getFullName();
26652
+ if (parentName) return parentName;
26653
+ }
26570
26654
  }
26571
26655
  const name = child.inheritedFrom.name;
26572
- const dotIdx = name.indexOf(".");
26573
- return dotIdx > 0 ? name.slice(0, dotIdx) : name;
26656
+ const lastDot = name.lastIndexOf(".");
26657
+ return lastDot > 0 ? name.slice(0, lastDot) : name;
26574
26658
  }
26575
26659
  /**
26576
26660
  * Fix ReferenceReflection targets broken by TypeDoc's handling of
@@ -26795,10 +26879,10 @@ import { JSX } from "typedoc";
26795
26879
  var giDocgenFooter = (_context) => JSX.createElement(JSX.Fragment, null);
26796
26880
 
26797
26881
  // ../typedoc-theme/src/partials/header.ts
26798
- import { JSX as JSX2, ReflectionKind as ReflectionKind2 } from "typedoc";
26882
+ import { JSX as JSX2, ReflectionKind as ReflectionKind3 } from "typedoc";
26799
26883
 
26800
26884
  // ../typedoc-theme/src/utils.ts
26801
- import { ReflectionKind } from "typedoc";
26885
+ import { ReflectionKind as ReflectionKind2 } from "typedoc";
26802
26886
  function getGirTypeFromComment(refl) {
26803
26887
  const comment = refl.comment;
26804
26888
  if (!comment) return void 0;
@@ -26903,17 +26987,17 @@ function getGirNamespaceMetadata(reflection) {
26903
26987
  const mod = findOwningModule(reflection) ?? reflection;
26904
26988
  return mod.girNamespaceMetadata;
26905
26989
  }
26906
- var COMPANION_OWNER_KINDS = ReflectionKind.Class | ReflectionKind.Interface | ReflectionKind.Enum;
26990
+ var COMPANION_OWNER_KINDS = ReflectionKind2.Class | ReflectionKind2.Interface | ReflectionKind2.Enum;
26907
26991
  function findCompanionNamespace(refl) {
26908
26992
  if (!refl.kindOf(COMPANION_OWNER_KINDS)) return void 0;
26909
26993
  const parent = refl.parent;
26910
26994
  if (!parent || !("children" in parent)) return void 0;
26911
26995
  const siblings = parent.children;
26912
26996
  if (!siblings) return void 0;
26913
- return siblings.find((child) => child !== refl && child.kindOf(ReflectionKind.Namespace) && child.name === refl.name);
26997
+ return siblings.find((child) => child !== refl && child.kindOf(ReflectionKind2.Namespace) && child.name === refl.name);
26914
26998
  }
26915
26999
  function isCompanionNamespace(nsRefl) {
26916
- if (!nsRefl.kindOf(ReflectionKind.Namespace)) return false;
27000
+ if (!nsRefl.kindOf(ReflectionKind2.Namespace)) return false;
26917
27001
  const parent = nsRefl.parent;
26918
27002
  if (!parent || !("children" in parent)) return false;
26919
27003
  const siblings = parent.children;
@@ -26930,7 +27014,7 @@ function getHierarchyRoots(project) {
26930
27014
  const queue = [project];
26931
27015
  for (let i = 0; i < queue.length; i++) {
26932
27016
  const refl = queue[i];
26933
- if (refl.kindOf(ReflectionKind.Class)) {
27017
+ if (refl.kindOf(ReflectionKind2.Class)) {
26934
27018
  const decl = refl;
26935
27019
  if (decl.typeHierarchy) {
26936
27020
  roots.push(decl);
@@ -27005,7 +27089,7 @@ var giDocgenHeader = (context, props) => {
27005
27089
  } else if (props.model.isDocument()) {
27006
27090
  renderTitle = headings.document;
27007
27091
  } else {
27008
- kindString = ReflectionKind2.singularString(props.model.kind);
27092
+ kindString = ReflectionKind3.singularString(props.model.kind);
27009
27093
  }
27010
27094
  if (kindString) {
27011
27095
  const girType = getGirTypeFromComment(props.model);
@@ -27023,7 +27107,7 @@ var giDocgenHeader = (context, props) => {
27023
27107
  refl = refl.parent;
27024
27108
  }
27025
27109
  path.reverse();
27026
- const isModulePage = !props.model.isProject() && props.model.kindOf(ReflectionKind2.Module) && !props.model.parent?.parent;
27110
+ const isModulePage = !props.model.isProject() && props.model.kindOf(ReflectionKind3.Module) && !props.model.parent?.parent;
27027
27111
  const nsMeta = isModulePage ? getGirNamespaceMetadata(props.model) : void 0;
27028
27112
  return JSX2.createElement(
27029
27113
  "div",
@@ -27256,7 +27340,7 @@ var giDocgenLayout = (context, template2, props) => JSX3.createElement(
27256
27340
  import {
27257
27341
  JSX as JSX4,
27258
27342
  ReferenceReflection as ReferenceReflection2,
27259
- ReflectionKind as ReflectionKind3
27343
+ ReflectionKind as ReflectionKind4
27260
27344
  } from "typedoc";
27261
27345
  function isNoneSection(section) {
27262
27346
  return section.title.toLocaleLowerCase() === "none";
@@ -27364,11 +27448,11 @@ function giDocgenModuleReflection(context, mod) {
27364
27448
  const parent = mod.parent;
27365
27449
  const siblings = parent && "children" in parent ? parent.children : void 0;
27366
27450
  const companionOwner = siblings?.find(
27367
- (child) => child !== mod && child.kindOf(ReflectionKind3.Class | ReflectionKind3.Interface | ReflectionKind3.Enum) && child.name === mod.name
27451
+ (child) => child !== mod && child.kindOf(ReflectionKind4.Class | ReflectionKind4.Interface | ReflectionKind4.Enum) && child.name === mod.name
27368
27452
  );
27369
27453
  if (companionOwner) {
27370
27454
  const ownerUrl = context.urlTo(companionOwner);
27371
- const kindName = companionOwner.kindOf(ReflectionKind3.Enum) ? "enum" : companionOwner.kindOf(ReflectionKind3.Interface) ? "interface" : "class";
27455
+ const kindName = companionOwner.kindOf(ReflectionKind4.Enum) ? "enum" : companionOwner.kindOf(ReflectionKind4.Interface) ? "interface" : "class";
27372
27456
  return JSX4.createElement(
27373
27457
  JSX4.Fragment,
27374
27458
  null,
@@ -27441,7 +27525,7 @@ function giDocgenModuleReflection(context, mod) {
27441
27525
  );
27442
27526
  }),
27443
27527
  // 3. README content — rendered at the bottom in a collapsible section
27444
- mod.isDeclaration() && mod.kind === ReflectionKind3.Module && !!mod.readme?.length && (() => {
27528
+ mod.isDeclaration() && mod.kind === ReflectionKind4.Module && !!mod.readme?.length && (() => {
27445
27529
  const readmeTitle = "Readme";
27446
27530
  context.page.startNewSection(readmeTitle);
27447
27531
  return JSX4.createElement(
@@ -27663,10 +27747,10 @@ var giDocgenPageSidebar = (context, props) => JSX7.createElement(JSX7.Fragment,
27663
27747
  import { readFileSync as readFileSync7 } from "node:fs";
27664
27748
  import { dirname as dirname8, join as join14 } from "node:path";
27665
27749
  import { fileURLToPath as fileURLToPath5 } from "node:url";
27666
- import { i18n, JSX as JSX8, ReflectionKind as ReflectionKind4 } from "typedoc";
27750
+ import { i18n, JSX as JSX8, ReflectionKind as ReflectionKind5 } from "typedoc";
27667
27751
  function getTsForGirVersion() {
27668
27752
  if (true) {
27669
- return "4.0.0-rc.7";
27753
+ return "4.0.0-rc.8";
27670
27754
  }
27671
27755
  const __dirname3 = dirname8(fileURLToPath5(import.meta.url));
27672
27756
  return JSON.parse(readFileSync7(join14(__dirname3, "..", "..", "package.json"), "utf8")).version;
@@ -27687,9 +27771,9 @@ function giDocgenModuleInfo(context, mod, nsMeta) {
27687
27771
  );
27688
27772
  });
27689
27773
  const childNamespaces = mod.children?.filter(
27690
- (child) => child.kindOf(ReflectionKind4.Namespace) && child.name !== "default" && !isCompanionNamespace(child)
27774
+ (child) => child.kindOf(ReflectionKind5.Namespace) && child.name !== "default" && !isCompanionNamespace(child)
27691
27775
  );
27692
- const childModules = mod.children?.filter((child) => child.kindOf(ReflectionKind4.Module) && child.name !== "default");
27776
+ const childModules = mod.children?.filter((child) => child.kindOf(ReflectionKind5.Module) && child.name !== "default");
27693
27777
  const packageVersion = mod.packageVersion || nsMeta.packageVersion;
27694
27778
  const pageModel = context.page.model;
27695
27779
  const isChildActive = (child) => {
@@ -27899,7 +27983,7 @@ var giDocgenToolbar = (context, _props) => {
27899
27983
  import {
27900
27984
  DeclarationReflection as DeclarationReflection3,
27901
27985
  JSX as JSX10,
27902
- ReflectionKind as ReflectionKind5,
27986
+ ReflectionKind as ReflectionKind6,
27903
27987
  i18n as i18n2
27904
27988
  } from "typedoc";
27905
27989
  function hasTypeParameters(reflection) {
@@ -27972,10 +28056,10 @@ function renderCompanionNamespaceSection(context, companionNs) {
27972
28056
  );
27973
28057
  }
27974
28058
  function giDocgenReflectionTemplate(context, props) {
27975
- if (props.model.kindOf(ReflectionKind5.TypeAlias | ReflectionKind5.Variable) && props.model instanceof DeclarationReflection3 && props.model.type) {
28059
+ if (props.model.kindOf(ReflectionKind6.TypeAlias | ReflectionKind6.Variable) && props.model instanceof DeclarationReflection3 && props.model.type) {
27976
28060
  return context.memberDeclaration(props.model);
27977
28061
  }
27978
- if (props.model.kindOf(ReflectionKind5.ExportContainer) && (props.model.isDeclaration() || props.model.isProject())) {
28062
+ if (props.model.kindOf(ReflectionKind6.ExportContainer) && (props.model.isDeclaration() || props.model.isProject())) {
27979
28063
  return context.moduleReflection(props.model);
27980
28064
  }
27981
28065
  const companionNs = props.model instanceof DeclarationReflection3 ? findCompanionNamespace(props.model) : void 0;
@@ -28251,21 +28335,9 @@ var HtmlDocGenerator = class _HtmlDocGenerator {
28251
28335
  };
28252
28336
 
28253
28337
  // src/formatters/typescript-formatter.ts
28254
- import prettier from "prettier";
28255
- var logger4 = new Logger(false, "TypeScriptFormatter");
28256
28338
  var TypeScriptFormatter = class extends Formatter {
28257
28339
  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
- }
28340
+ return Promise.resolve(input2);
28269
28341
  }
28270
28342
  };
28271
28343
 
@@ -28355,7 +28427,7 @@ var GenerationHandler = class {
28355
28427
  async function runGenerationCommand(args, options2) {
28356
28428
  const config = await load(args);
28357
28429
  const generateConfig = getOptionsGeneration(config);
28358
- const logger6 = new Logger(true, options2.loggerName);
28430
+ const logger5 = new Logger(true, options2.loggerName);
28359
28431
  const registry = new NSRegistry();
28360
28432
  options2.configureRegistry?.(registry);
28361
28433
  const moduleLoader = new ModuleLoader(generateConfig, registry);
@@ -28367,7 +28439,7 @@ async function runGenerationCommand(args, options2) {
28367
28439
  config.ignoreVersionConflicts
28368
28440
  );
28369
28441
  if (keep.length === 0) {
28370
- logger6.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
28442
+ logger5.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
28371
28443
  return;
28372
28444
  }
28373
28445
  tsForGir = new GenerationHandler(generateConfig, options2.generatorType, registry);
@@ -28493,7 +28565,7 @@ var json2 = {
28493
28565
  // src/commands/list.ts
28494
28566
  var command7 = "list [modules..]";
28495
28567
  var description7 = "Lists all available GIR modules";
28496
- var logger5 = new Logger(true, "ListCommand");
28568
+ var logger4 = new Logger(true, "ListCommand");
28497
28569
  var examples7 = [
28498
28570
  [`${APP_NAME} list -g ./vala-girs/gir-1.0`, "Lists all available GIR modules in ./vala-girs/gir-1.0"],
28499
28571
  [
@@ -28510,35 +28582,35 @@ var handler7 = async (args) => {
28510
28582
  const { grouped, failed } = await moduleLoader.getModules(config.modules, config.ignore);
28511
28583
  const moduleGroups = Object.values(grouped);
28512
28584
  if (Object.keys(grouped).length === 0) {
28513
- return logger5.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
28585
+ return logger4.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
28514
28586
  }
28515
28587
  const conflictModules = moduleGroups.filter((moduleGroup) => moduleGroup.hasConflict);
28516
28588
  const allModules = moduleGroups.filter((moduleGroup) => !moduleGroup.hasConflict);
28517
- logger5.info("\nSearch for gir files in:");
28589
+ logger4.info("\nSearch for gir files in:");
28518
28590
  for (const dir of config.girDirectories) {
28519
- logger5.white(`- ${dir}`);
28591
+ logger4.white(`- ${dir}`);
28520
28592
  }
28521
- logger5.info("\nAvailable Modules:");
28593
+ logger4.info("\nAvailable Modules:");
28522
28594
  for (const moduleGroup of allModules) {
28523
28595
  for (const module of moduleGroup.modules) {
28524
- logger5.white(`- ${module.packageName}`);
28525
- logger5.gray(` - ${module.path}`);
28596
+ logger4.white(`- ${module.packageName}`);
28597
+ logger4.gray(` - ${module.path}`);
28526
28598
  }
28527
28599
  }
28528
28600
  if (conflictModules.length > 0) {
28529
- logger5.danger("\nConflicts:");
28601
+ logger4.danger("\nConflicts:");
28530
28602
  for (const moduleGroup of conflictModules) {
28531
- logger5.white(`- ${moduleGroup.namespace}`);
28603
+ logger4.white(`- ${moduleGroup.namespace}`);
28532
28604
  for (const conflictModule of moduleGroup.modules) {
28533
- logger5.white(` - ${conflictModule.packageName}`);
28534
- logger5.gray(` - ${conflictModule.path}`);
28605
+ logger4.white(` - ${conflictModule.packageName}`);
28606
+ logger4.gray(` - ${conflictModule.path}`);
28535
28607
  }
28536
28608
  }
28537
28609
  }
28538
28610
  if (failed.length > 0) {
28539
- logger5.danger("\nDependencies not found:");
28611
+ logger4.danger("\nDependencies not found:");
28540
28612
  for (const fail of failed) {
28541
- logger5.white(`- ${fail}`);
28613
+ logger4.white(`- ${fail}`);
28542
28614
  }
28543
28615
  }
28544
28616
  };
@@ -28551,7 +28623,14 @@ var list = {
28551
28623
  };
28552
28624
 
28553
28625
  // 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;
28626
+ try {
28627
+ 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();
28628
+ } catch (err) {
28629
+ const message = err instanceof Error ? err.message : String(err);
28630
+ process.stderr.write(`${message}
28631
+ `);
28632
+ process.exitCode = 1;
28633
+ }
28555
28634
  /*! Bundled license information:
28556
28635
 
28557
28636
  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.8",
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.7",
18
+ "@girs/gio-2.0": "^2.88.0-4.0.0-rc.7",
19
+ "@girs/gjs": "^4.0.0-rc.7",
20
+ "@girs/glib-2.0": "^2.88.0-4.0.0-rc.7",
21
+ "@girs/gtk-4.0": "^4.23.0-4.0.0-rc.7"
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.8",
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.8",
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.8",
59
+ "@ts-for-gir/generator-base": "^4.0.0-rc.8",
60
+ "@ts-for-gir/generator-html-doc": "^4.0.0-rc.8",
61
+ "@ts-for-gir/generator-json": "^4.0.0-rc.8",
62
+ "@ts-for-gir/generator-typescript": "^4.0.0-rc.8",
63
+ "@ts-for-gir/lib": "^4.0.0-rc.8",
64
+ "@ts-for-gir/reporter": "^4.0.0-rc.8",
65
+ "@ts-for-gir/tsconfig": "^4.0.0-rc.8",
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.8",
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
+ }