@ts-for-gir/cli 4.0.0-rc.6 → 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 +329 -160
- package/dist-templates/types-locally/package.json +1 -1
- package/dist-templates/types-npm/package.json +5 -5
- package/dist-templates/types-workspace/package.json +1 -1
- package/package.json +10 -11
- package/src/formatters/typescript-formatter.ts +9 -16
- package/src/start.ts +28 -15
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.
|
|
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.
|
|
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";
|
|
@@ -14393,12 +14397,16 @@ var IntrospectedProperty = class _IntrospectedProperty extends IntrospectedBase
|
|
|
14393
14397
|
writable = false;
|
|
14394
14398
|
readable = true;
|
|
14395
14399
|
constructOnly;
|
|
14400
|
+
/** GIR default-value attribute: the default value of the property as a string. */
|
|
14401
|
+
defaultValue;
|
|
14402
|
+
/** GIR getter attribute: name of the getter method for this property (used for nullable inference). */
|
|
14403
|
+
getter;
|
|
14396
14404
|
get namespace() {
|
|
14397
14405
|
return this.parent.namespace;
|
|
14398
14406
|
}
|
|
14399
14407
|
copy(options2) {
|
|
14400
14408
|
const { name, writable, readable, type, constructOnly, parent } = this;
|
|
14401
|
-
|
|
14409
|
+
const prop = new _IntrospectedProperty({
|
|
14402
14410
|
name: options2?.name ?? name,
|
|
14403
14411
|
writable,
|
|
14404
14412
|
readable,
|
|
@@ -14406,6 +14414,9 @@ var IntrospectedProperty = class _IntrospectedProperty extends IntrospectedBase
|
|
|
14406
14414
|
constructOnly,
|
|
14407
14415
|
parent: options2?.parent ?? parent
|
|
14408
14416
|
})._copyBaseProperties(this);
|
|
14417
|
+
prop.defaultValue = this.defaultValue;
|
|
14418
|
+
prop.getter = this.getter;
|
|
14419
|
+
return prop;
|
|
14409
14420
|
}
|
|
14410
14421
|
accept(visitor) {
|
|
14411
14422
|
const node = this.copy({
|
|
@@ -14463,6 +14474,11 @@ var IntrospectedProperty = class _IntrospectedProperty extends IntrospectedBase
|
|
|
14463
14474
|
property.doc = parseDoc(element);
|
|
14464
14475
|
property.metadata = parseMetadata(element);
|
|
14465
14476
|
}
|
|
14477
|
+
property.defaultValue = element.$["default-value"];
|
|
14478
|
+
property.getter = element.$.getter;
|
|
14479
|
+
if (element.$.nullable === "1" || element.$["allow-none"] === "1") {
|
|
14480
|
+
property.type = new NullableType(property.type);
|
|
14481
|
+
}
|
|
14466
14482
|
return property;
|
|
14467
14483
|
}
|
|
14468
14484
|
};
|
|
@@ -14655,6 +14671,28 @@ var IntrospectedSignal = class _IntrospectedSignal extends IntrospectedClassMemb
|
|
|
14655
14671
|
|
|
14656
14672
|
// ../lib/src/gir/introspected-classes.ts
|
|
14657
14673
|
var log = new ConsoleReporter(true, "gir/introspected-classes", true);
|
|
14674
|
+
function hasExtendsShadowOf(cls, prerequisite, name) {
|
|
14675
|
+
let current = cls.resolveParents().extends();
|
|
14676
|
+
while (current) {
|
|
14677
|
+
const node = current.node;
|
|
14678
|
+
if (node !== prerequisite) {
|
|
14679
|
+
const hasOwn = [...node.props, ...node.fields, ...node.members].some((m) => m.name === name);
|
|
14680
|
+
if (hasOwn) return true;
|
|
14681
|
+
}
|
|
14682
|
+
current = current.extends();
|
|
14683
|
+
}
|
|
14684
|
+
return false;
|
|
14685
|
+
}
|
|
14686
|
+
function resolveNullableProperties(cls) {
|
|
14687
|
+
for (const prop of cls.props) {
|
|
14688
|
+
if (prop.type instanceof NullableType) continue;
|
|
14689
|
+
const getterName = prop.getter ?? `get_${prop.name}`;
|
|
14690
|
+
const getter = cls.members.find((m) => m.name === getterName && !(m instanceof IntrospectedStaticClassFunction));
|
|
14691
|
+
if (getter instanceof IntrospectedClassFunction && getter.return() instanceof NullableType) {
|
|
14692
|
+
prop.type = new NullableType(prop.type);
|
|
14693
|
+
}
|
|
14694
|
+
}
|
|
14695
|
+
}
|
|
14658
14696
|
var IntrospectedClassFunction = class _IntrospectedClassFunction extends IntrospectedBase {
|
|
14659
14697
|
parameters;
|
|
14660
14698
|
return_type;
|
|
@@ -14665,6 +14703,8 @@ var IntrospectedClassFunction = class _IntrospectedClassFunction extends Introsp
|
|
|
14665
14703
|
returnTypeDoc;
|
|
14666
14704
|
/** If this function was generated from a signal, stores the signal name. */
|
|
14667
14705
|
signalOrigin;
|
|
14706
|
+
/** GIR glib:finish-func attribute: name of the function that finishes this async operation. */
|
|
14707
|
+
finishFuncName;
|
|
14668
14708
|
generics = [];
|
|
14669
14709
|
constructor({
|
|
14670
14710
|
name,
|
|
@@ -14711,6 +14751,7 @@ var IntrospectedClassFunction = class _IntrospectedClassFunction extends Introsp
|
|
|
14711
14751
|
});
|
|
14712
14752
|
fn.generics = [...this.generics];
|
|
14713
14753
|
fn.returnTypeDoc = this.returnTypeDoc;
|
|
14754
|
+
fn.finishFuncName = this.finishFuncName;
|
|
14714
14755
|
if (interfaceParent) {
|
|
14715
14756
|
fn.interfaceParent = interfaceParent;
|
|
14716
14757
|
}
|
|
@@ -14732,6 +14773,7 @@ var IntrospectedClassFunction = class _IntrospectedClassFunction extends Introsp
|
|
|
14732
14773
|
static fromXML(element, parent, options2) {
|
|
14733
14774
|
const fn = IntrospectedFunction.fromXML(element, parent.namespace, options2);
|
|
14734
14775
|
const { raw_name: name, output_parameters, parameters, return_type, doc: doc2, isIntrospectable: isIntrospectable2 } = fn;
|
|
14776
|
+
const isShadowedBy = element.$["shadowed-by"] != null;
|
|
14735
14777
|
const classFn = new _IntrospectedClassFunction({
|
|
14736
14778
|
parent,
|
|
14737
14779
|
name,
|
|
@@ -14739,10 +14781,11 @@ var IntrospectedClassFunction = class _IntrospectedClassFunction extends Introsp
|
|
|
14739
14781
|
parameters,
|
|
14740
14782
|
return_type,
|
|
14741
14783
|
doc: doc2,
|
|
14742
|
-
isIntrospectable: isIntrospectable2
|
|
14784
|
+
isIntrospectable: isIntrospectable2 && !isShadowedBy
|
|
14743
14785
|
});
|
|
14744
14786
|
classFn.returnTypeDoc = fn.returnTypeDoc;
|
|
14745
14787
|
classFn.generics = [...fn.generics];
|
|
14788
|
+
classFn.finishFuncName = element.$["glib:finish-func"];
|
|
14746
14789
|
return classFn;
|
|
14747
14790
|
}
|
|
14748
14791
|
anyify() {
|
|
@@ -14885,6 +14928,7 @@ var IntrospectedStaticClassFunction = class _IntrospectedStaticClassFunction ext
|
|
|
14885
14928
|
static fromXML(m, parent, options2) {
|
|
14886
14929
|
const fn = IntrospectedFunction.fromXML(m, parent.namespace, options2);
|
|
14887
14930
|
const { raw_name: name, output_parameters, parameters, return_type, doc: doc2, isIntrospectable: isIntrospectable2 } = fn;
|
|
14931
|
+
const isShadowedBy = m.$["shadowed-by"] != null;
|
|
14888
14932
|
return new _IntrospectedStaticClassFunction({
|
|
14889
14933
|
parent,
|
|
14890
14934
|
name,
|
|
@@ -14892,7 +14936,7 @@ var IntrospectedStaticClassFunction = class _IntrospectedStaticClassFunction ext
|
|
|
14892
14936
|
parameters,
|
|
14893
14937
|
return_type,
|
|
14894
14938
|
doc: doc2,
|
|
14895
|
-
isIntrospectable: isIntrospectable2
|
|
14939
|
+
isIntrospectable: isIntrospectable2 && !isShadowedBy
|
|
14896
14940
|
});
|
|
14897
14941
|
}
|
|
14898
14942
|
};
|
|
@@ -15211,6 +15255,7 @@ var IntrospectedClass = class _IntrospectedClass extends IntrospectedBaseClass {
|
|
|
15211
15255
|
if (extended?.node instanceof _IntrospectedClass) {
|
|
15212
15256
|
for (const item of getItems(extended.node)) {
|
|
15213
15257
|
if (items.has(item.name) || !validate3(item)) continue;
|
|
15258
|
+
if (!hasExtendsShadowOf(this, extended.node, item.name)) continue;
|
|
15214
15259
|
items.set(item.name, item);
|
|
15215
15260
|
}
|
|
15216
15261
|
}
|
|
@@ -15348,6 +15393,7 @@ var IntrospectedClass = class _IntrospectedClass extends IntrospectedBaseClass {
|
|
|
15348
15393
|
_IntrospectedClass.parseBasicProperties(element, clazz, ns, options2);
|
|
15349
15394
|
_IntrospectedClass.parseResolveNames(element, clazz, ns, name);
|
|
15350
15395
|
_IntrospectedClass.parseInheritanceAndMembers(element, clazz, ns, options2);
|
|
15396
|
+
resolveNullableProperties(clazz);
|
|
15351
15397
|
return clazz;
|
|
15352
15398
|
}
|
|
15353
15399
|
static parseBasicProperties(element, clazz, ns, options2) {
|
|
@@ -15578,6 +15624,7 @@ var IntrospectedInterface = class _IntrospectedInterface extends IntrospectedBas
|
|
|
15578
15624
|
_IntrospectedInterface.parseInterfaceBasicProperties(element, iface, namespace, options2);
|
|
15579
15625
|
_IntrospectedInterface.parseInterfaceResolveNames(element, iface, namespace, name);
|
|
15580
15626
|
_IntrospectedInterface.parseInterfaceMembers(element, iface, namespace, options2);
|
|
15627
|
+
resolveNullableProperties(iface);
|
|
15581
15628
|
return iface;
|
|
15582
15629
|
}
|
|
15583
15630
|
static parseInterfaceBasicProperties(element, iface, namespace, options2) {
|
|
@@ -15948,9 +15995,7 @@ var IntrospectedFunction = class _IntrospectedFunction extends IntrospectedNames
|
|
|
15948
15995
|
({ allowOptions, params }, p) => {
|
|
15949
15996
|
const { type, isOptional } = p;
|
|
15950
15997
|
if (allowOptions) {
|
|
15951
|
-
if (
|
|
15952
|
-
params.push(p.copy({ isOptional: true }));
|
|
15953
|
-
} else if (!isOptional) {
|
|
15998
|
+
if (!isOptional) {
|
|
15954
15999
|
params.push(p);
|
|
15955
16000
|
return { allowOptions: false, params };
|
|
15956
16001
|
} else {
|
|
@@ -17461,6 +17506,9 @@ function generatePromisifyOverloadedSignatures(node, async_parameters, sync_para
|
|
|
17461
17506
|
}
|
|
17462
17507
|
function findFinishMethodInClass(cls, node) {
|
|
17463
17508
|
const members = node instanceof IntrospectedStaticClassFunction ? [...cls.constructors, ...cls.members.filter((m) => m instanceof IntrospectedStaticClassFunction)] : [...cls.members.filter((m) => !(m instanceof IntrospectedStaticClassFunction))];
|
|
17509
|
+
if (node.finishFuncName) {
|
|
17510
|
+
return members.find((m) => m.name === node.finishFuncName);
|
|
17511
|
+
}
|
|
17464
17512
|
return members.find(
|
|
17465
17513
|
(m) => m.name === `${node.name.replace(/_async$/, "")}_finish` || m.name === `${node.name}_finish`
|
|
17466
17514
|
);
|
|
@@ -20172,6 +20220,14 @@ var fixMissingParent = (node) => {
|
|
|
20172
20220
|
var removeComplexFields = (node) => {
|
|
20173
20221
|
const { namespace } = node;
|
|
20174
20222
|
node.fields = node.fields.filter((f) => {
|
|
20223
|
+
if (f.type instanceof ArrayType) {
|
|
20224
|
+
const elementType = f.type.deepUnwrap();
|
|
20225
|
+
if (elementType instanceof TypeIdentifier) {
|
|
20226
|
+
const classNode = resolveTypeIdentifier(namespace, elementType);
|
|
20227
|
+
return !classNode?.isPrivate;
|
|
20228
|
+
}
|
|
20229
|
+
return true;
|
|
20230
|
+
}
|
|
20175
20231
|
const type = f.type.deepUnwrap();
|
|
20176
20232
|
if (type instanceof NativeType) {
|
|
20177
20233
|
return true;
|
|
@@ -20716,7 +20772,7 @@ function checkFunctionConflicts(ns, base, functionElement, conflict_ids, nextTyp
|
|
|
20716
20772
|
return false;
|
|
20717
20773
|
});
|
|
20718
20774
|
});
|
|
20719
|
-
const hasFieldConflicts = checkFieldPropertyConflicts(base, functionElement.name);
|
|
20775
|
+
const hasFieldConflicts = functionElement instanceof IntrospectedStaticClassFunction ? false : checkFieldPropertyConflicts(base, functionElement.name);
|
|
20720
20776
|
const hasGObjectConflicts = checkGObjectConflicts(base, functionElement.name);
|
|
20721
20777
|
const hasConflict = hasParentConflict || hasGObjectConflicts;
|
|
20722
20778
|
return {
|
|
@@ -20934,7 +20990,6 @@ function addInfoComment(comment, indentCount = 0) {
|
|
|
20934
20990
|
if (comment) {
|
|
20935
20991
|
def.push("");
|
|
20936
20992
|
def.push(`${indent}// ${comment}`);
|
|
20937
|
-
def.push("");
|
|
20938
20993
|
}
|
|
20939
20994
|
return def;
|
|
20940
20995
|
}
|
|
@@ -20942,7 +20997,7 @@ function mergeDescs(descs, comment, indentCount = 1) {
|
|
|
20942
20997
|
const def = [];
|
|
20943
20998
|
const indent = generateIndent(indentCount);
|
|
20944
20999
|
for (const desc of descs) {
|
|
20945
|
-
def.push(`${indent}${desc}`);
|
|
21000
|
+
def.push(desc.length === 0 ? desc : `${indent}${desc}`);
|
|
20946
21001
|
}
|
|
20947
21002
|
if (def.length > 0) {
|
|
20948
21003
|
def.unshift(...addInfoComment(comment, indentCount));
|
|
@@ -20950,11 +21005,49 @@ function mergeDescs(descs, comment, indentCount = 1) {
|
|
|
20950
21005
|
return def;
|
|
20951
21006
|
}
|
|
20952
21007
|
|
|
21008
|
+
// ../lib/src/utils/gir-defaults.ts
|
|
21009
|
+
function resolveCEnumConstant(cIdentifier, ns) {
|
|
21010
|
+
const own = ns.enum_constants.get(cIdentifier);
|
|
21011
|
+
if (own) return [ns.namespace, own[0], own[1]];
|
|
21012
|
+
for (const dep of ns.allDependencies) {
|
|
21013
|
+
const depModule = ns.getInstalledImport(dep.namespace);
|
|
21014
|
+
if (!depModule) continue;
|
|
21015
|
+
const entry = depModule.enum_constants.get(cIdentifier);
|
|
21016
|
+
if (entry) return [depModule.namespace, entry[0], entry[1]];
|
|
21017
|
+
}
|
|
21018
|
+
return null;
|
|
21019
|
+
}
|
|
21020
|
+
function convertSingleCValue(value, ns) {
|
|
21021
|
+
const trimmed = value.trim();
|
|
21022
|
+
if (trimmed === "NULL") return "null";
|
|
21023
|
+
if (trimmed === "TRUE") return "true";
|
|
21024
|
+
if (trimmed === "FALSE") return "false";
|
|
21025
|
+
if (/^-?\d+\.\d+$/.test(trimmed)) {
|
|
21026
|
+
const n = parseFloat(trimmed);
|
|
21027
|
+
if (!Number.isNaN(n)) return String(n);
|
|
21028
|
+
}
|
|
21029
|
+
const entry = resolveCEnumConstant(trimmed, ns);
|
|
21030
|
+
if (entry) return `${entry[0]}.${entry[1]}.${entry[2]}`;
|
|
21031
|
+
return trimmed;
|
|
21032
|
+
}
|
|
21033
|
+
function convertCDefaultValue(rawValue, ns) {
|
|
21034
|
+
if (rawValue.includes("|")) {
|
|
21035
|
+
return rawValue.split("|").map((part) => convertSingleCValue(part, ns)).join(" | ");
|
|
21036
|
+
}
|
|
21037
|
+
return convertSingleCValue(rawValue, ns);
|
|
21038
|
+
}
|
|
21039
|
+
|
|
20953
21040
|
// ../lib/src/utils/path.ts
|
|
20954
21041
|
import { dirname as dirname4, resolve as resolve3 } from "node:path";
|
|
20955
21042
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
20956
|
-
|
|
20957
|
-
|
|
21043
|
+
function resolvePackageDir() {
|
|
21044
|
+
try {
|
|
21045
|
+
return resolve3(dirname4(fileURLToPath3(import.meta.url)), "../..");
|
|
21046
|
+
} catch {
|
|
21047
|
+
return "";
|
|
21048
|
+
}
|
|
21049
|
+
}
|
|
21050
|
+
var __dirname = resolvePackageDir();
|
|
20958
21051
|
|
|
20959
21052
|
// src/start.ts
|
|
20960
21053
|
import yargs from "yargs";
|
|
@@ -21736,7 +21829,7 @@ var formatAsCsv = (problems) => {
|
|
|
21736
21829
|
]);
|
|
21737
21830
|
return [headers.join(","), ...rows.map((row) => row.join(","))].join("\n");
|
|
21738
21831
|
};
|
|
21739
|
-
var exportResults = (problems, filePath, format,
|
|
21832
|
+
var exportResults = (problems, filePath, format, logger5) => {
|
|
21740
21833
|
let content;
|
|
21741
21834
|
switch (format) {
|
|
21742
21835
|
case "json": {
|
|
@@ -21756,14 +21849,14 @@ var exportResults = (problems, filePath, format, logger6) => {
|
|
|
21756
21849
|
}
|
|
21757
21850
|
}
|
|
21758
21851
|
writeFileSync(filePath, content, "utf-8");
|
|
21759
|
-
|
|
21852
|
+
logger5.success(`Results exported to: ${filePath}`);
|
|
21760
21853
|
};
|
|
21761
21854
|
var handler = async (args) => {
|
|
21762
|
-
const
|
|
21855
|
+
const logger5 = new Logger(args.verbose ?? false, "AnalyzeCommand");
|
|
21763
21856
|
try {
|
|
21764
21857
|
const report = loadReportFile(args.reportFile);
|
|
21765
21858
|
if (args.verbose) {
|
|
21766
|
-
|
|
21859
|
+
logger5.info(`Loaded report with ${report.problems.length} problems`);
|
|
21767
21860
|
}
|
|
21768
21861
|
const hasFilters = Boolean(args.severity || args.category || args.namespace || args.type || args.search);
|
|
21769
21862
|
if (args.summary || !hasFilters) {
|
|
@@ -21778,7 +21871,7 @@ var handler = async (args) => {
|
|
|
21778
21871
|
}
|
|
21779
21872
|
if (args.export) {
|
|
21780
21873
|
const format = args.format ?? "json";
|
|
21781
|
-
exportResults(filteredProblems, args.export, format,
|
|
21874
|
+
exportResults(filteredProblems, args.export, format, logger5);
|
|
21782
21875
|
}
|
|
21783
21876
|
if (hasFilters && !args.summary) {
|
|
21784
21877
|
console.log(
|
|
@@ -21788,7 +21881,7 @@ var handler = async (args) => {
|
|
|
21788
21881
|
}
|
|
21789
21882
|
} catch (error) {
|
|
21790
21883
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
21791
|
-
|
|
21884
|
+
logger5.error(`Analysis failed: ${errorMessage}`);
|
|
21792
21885
|
process.exit(1);
|
|
21793
21886
|
}
|
|
21794
21887
|
};
|
|
@@ -22417,8 +22510,8 @@ var PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__";
|
|
|
22417
22510
|
var TEXT_FILE_EXT = /* @__PURE__ */ new Set([".json", ".md", ".ts", ".tsx", ".js", ".mjs", ".cjs"]);
|
|
22418
22511
|
var builder3 = createBuilder(createOptions, examples3);
|
|
22419
22512
|
function findTemplatesRoot() {
|
|
22420
|
-
const
|
|
22421
|
-
const __dirname3 = dirname6(
|
|
22513
|
+
const __filename = fileURLToPath4(import.meta.url);
|
|
22514
|
+
const __dirname3 = dirname6(__filename);
|
|
22422
22515
|
const candidates = [
|
|
22423
22516
|
// Bundled production binary (bin/ts-for-gir): ../dist-templates
|
|
22424
22517
|
resolve5(__dirname3, "..", "dist-templates"),
|
|
@@ -22920,7 +23013,6 @@ var SignalGenerator = class {
|
|
|
22920
23013
|
const def = [];
|
|
22921
23014
|
const indent = generateIndent(indentCount);
|
|
22922
23015
|
def.push(`${indent}// Signal signatures`);
|
|
22923
|
-
def.push(`${indent}interface SignalSignatures`);
|
|
22924
23016
|
const parentSignatures = [];
|
|
22925
23017
|
const parentResolution = girClass.resolveParents().extends();
|
|
22926
23018
|
if (parentResolution && parentResolution.node instanceof IntrospectedClass) {
|
|
@@ -22940,20 +23032,22 @@ var SignalGenerator = class {
|
|
|
22940
23032
|
return interfaceTypeIdentifier ? `${interfaceTypeIdentifier}.SignalSignatures` : null;
|
|
22941
23033
|
}).filter((sig) => !!sig);
|
|
22942
23034
|
parentSignatures.push(...interfaceSignatures);
|
|
23035
|
+
let signatureHead;
|
|
22943
23036
|
if (parentSignatures.length > 0) {
|
|
22944
|
-
|
|
23037
|
+
signatureHead = `${indent}interface SignalSignatures extends ${parentSignatures.join(", ")} {`;
|
|
22945
23038
|
} else {
|
|
22946
23039
|
const isGObjectObject = girClass.name === "Object" && girClass.namespace.namespace === "GObject";
|
|
22947
23040
|
if (isGObjectObject) {
|
|
22948
|
-
|
|
23041
|
+
signatureHead = `${indent}interface SignalSignatures {`;
|
|
22949
23042
|
} else {
|
|
22950
23043
|
const gobjectNamespace = this.namespace.assertInstalledImport("GObject");
|
|
22951
23044
|
const gobjectObjectClass = gobjectNamespace.assertClass("Object");
|
|
22952
23045
|
const gobjectRef = gobjectObjectClass.getType().resolveIdentifier(this.namespace, this.config)?.print(this.namespace, this.config);
|
|
22953
23046
|
const fallbackRef = gobjectRef ? `${gobjectRef}.SignalSignatures` : "GObject.Object.SignalSignatures";
|
|
22954
|
-
|
|
23047
|
+
signatureHead = `${indent}interface SignalSignatures extends ${fallbackRef} {`;
|
|
22955
23048
|
}
|
|
22956
23049
|
}
|
|
23050
|
+
def.push(signatureHead);
|
|
22957
23051
|
const allSignals = girClass.getAllSignals();
|
|
22958
23052
|
allSignals.forEach((signalInfo) => {
|
|
22959
23053
|
let cbType;
|
|
@@ -22999,7 +23093,6 @@ var SignalGenerator = class {
|
|
|
22999
23093
|
def.push(`${indent} ${signalKey}: ${cbType};`);
|
|
23000
23094
|
});
|
|
23001
23095
|
def.push(`${indent}}`);
|
|
23002
|
-
def.push("");
|
|
23003
23096
|
return def;
|
|
23004
23097
|
}
|
|
23005
23098
|
/**
|
|
@@ -23025,8 +23118,7 @@ var SignalGenerator = class {
|
|
|
23025
23118
|
`${indent} * It is not defined at runtime and should not be accessed in JS code.`,
|
|
23026
23119
|
`${indent} * @internal`,
|
|
23027
23120
|
`${indent} */`,
|
|
23028
|
-
`${indent}$signals: ${girClass.name}.SignalSignatures
|
|
23029
|
-
""
|
|
23121
|
+
`${indent}$signals: ${girClass.name}.SignalSignatures;`
|
|
23030
23122
|
];
|
|
23031
23123
|
}
|
|
23032
23124
|
/**
|
|
@@ -23056,27 +23148,32 @@ var SignalGenerator = class {
|
|
|
23056
23148
|
const filteredFunctions = filterConflicts(girClass.namespace, girClass, signalFunctions, 0 /* DELETE */);
|
|
23057
23149
|
const allowedNames = new Set(filteredFunctions.map((f) => f.name));
|
|
23058
23150
|
const gobjectRef = this.namespace.namespace === "GObject" ? "" : "GObject.";
|
|
23059
|
-
const
|
|
23151
|
+
const groups = [];
|
|
23060
23152
|
if (allowedNames.has("connect")) {
|
|
23061
|
-
|
|
23153
|
+
groups.push([
|
|
23062
23154
|
SIGNAL_JSDOC,
|
|
23063
23155
|
`connect<K extends keyof ${girClass.name}.SignalSignatures>(signal: K, callback: ${gobjectRef}SignalCallback<this, ${girClass.name}.SignalSignatures[K]>): number;`,
|
|
23064
23156
|
"connect(signal: string, callback: (...args: any[]) => any): number;"
|
|
23065
|
-
);
|
|
23157
|
+
]);
|
|
23066
23158
|
}
|
|
23067
23159
|
if (allowedNames.has("connect_after")) {
|
|
23068
|
-
|
|
23160
|
+
groups.push([
|
|
23069
23161
|
SIGNAL_JSDOC,
|
|
23070
23162
|
`connect_after<K extends keyof ${girClass.name}.SignalSignatures>(signal: K, callback: ${gobjectRef}SignalCallback<this, ${girClass.name}.SignalSignatures[K]>): number;`,
|
|
23071
23163
|
"connect_after(signal: string, callback: (...args: any[]) => any): number;"
|
|
23072
|
-
);
|
|
23164
|
+
]);
|
|
23073
23165
|
}
|
|
23074
23166
|
if (allowedNames.has("emit")) {
|
|
23075
|
-
|
|
23167
|
+
groups.push([
|
|
23076
23168
|
SIGNAL_JSDOC,
|
|
23077
23169
|
`emit<K extends keyof ${girClass.name}.SignalSignatures>(signal: K, ...args: ${gobjectRef}GjsParameters<${girClass.name}.SignalSignatures[K]> extends [any, ...infer Q] ? Q : never): void;`,
|
|
23078
23170
|
"emit(signal: string, ...args: any[]): void;"
|
|
23079
|
-
);
|
|
23171
|
+
]);
|
|
23172
|
+
}
|
|
23173
|
+
const methods = [];
|
|
23174
|
+
for (const group of groups) {
|
|
23175
|
+
if (methods.length > 0) methods.push("");
|
|
23176
|
+
methods.push(...group);
|
|
23080
23177
|
}
|
|
23081
23178
|
return methods;
|
|
23082
23179
|
}
|
|
@@ -23285,37 +23382,37 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
|
|
|
23285
23382
|
generateClassCallback(node) {
|
|
23286
23383
|
return this.generateCallback(node);
|
|
23287
23384
|
}
|
|
23288
|
-
generateConstructor(node) {
|
|
23385
|
+
generateConstructor(node, indentCount = 0) {
|
|
23289
23386
|
const Parameters = this.generateParameters(node.parameters);
|
|
23290
|
-
|
|
23387
|
+
const indent = generateIndent(indentCount);
|
|
23388
|
+
return [`${indent}constructor(${Parameters});`];
|
|
23291
23389
|
}
|
|
23292
|
-
generateDirectAllocationConstructor(node) {
|
|
23293
|
-
const
|
|
23294
|
-
|
|
23295
|
-
|
|
23296
|
-
constructor(properties?: Partial<{
|
|
23297
|
-
${ConstructorFields}
|
|
23298
|
-
}>);`
|
|
23299
|
-
];
|
|
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}}>);`];
|
|
23300
23395
|
}
|
|
23301
23396
|
generateParameters(parameters) {
|
|
23302
23397
|
return parameters.flatMap((p) => {
|
|
23303
23398
|
return p.asString(this);
|
|
23304
23399
|
}).join(", ");
|
|
23305
23400
|
}
|
|
23306
|
-
generateConstructorFunction(node) {
|
|
23401
|
+
generateConstructorFunction(node, indentCount = 0) {
|
|
23307
23402
|
const { namespace, options: options2 } = this;
|
|
23308
23403
|
const Parameters = this.generateParameters(node.parameters);
|
|
23404
|
+
const indent = generateIndent(indentCount);
|
|
23309
23405
|
const invalid = isInvalid(node.name);
|
|
23310
23406
|
const name = invalid ? `["${node.name}"]` : node.name;
|
|
23311
23407
|
const warning = node.getWarning();
|
|
23312
23408
|
const genericTypes = this.generateGenericParameters(node.generics);
|
|
23313
|
-
|
|
23314
|
-
|
|
23315
|
-
|
|
23316
|
-
|
|
23317
|
-
|
|
23318
|
-
|
|
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;
|
|
23319
23416
|
}
|
|
23320
23417
|
generateRecord(node) {
|
|
23321
23418
|
const structFor = node.structFor;
|
|
@@ -23360,25 +23457,30 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
|
|
|
23360
23457
|
})
|
|
23361
23458
|
);
|
|
23362
23459
|
const gtypeNamespace = namespace.namespace === "GObject" ? "" : "GObject.";
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
|
|
23366
|
-
|
|
23367
|
-
|
|
23368
|
-
|
|
23369
|
-
|
|
23370
|
-
|
|
23371
|
-
}
|
|
23372
|
-
|
|
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, "}"];
|
|
23373
23477
|
}
|
|
23374
23478
|
generateInterfaceDeclaration(node) {
|
|
23375
23479
|
return [
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
|
|
23380
|
-
}
|
|
23381
|
-
`
|
|
23480
|
+
"",
|
|
23481
|
+
`export const ${node.name}: ${node.name}Namespace & {`,
|
|
23482
|
+
` new (): ${node.name}; // This allows \`obj instanceof ${node.name}\``,
|
|
23483
|
+
"};"
|
|
23382
23484
|
];
|
|
23383
23485
|
}
|
|
23384
23486
|
generateError(node) {
|
|
@@ -23441,6 +23543,12 @@ export const ${node.name}: ${node.name}Namespace & {
|
|
|
23441
23543
|
if (tsProp.constructOnly) propTags.push({ tagName: "construct-only", paramName: "", text: "" });
|
|
23442
23544
|
else if (tsProp.readable && !tsProp.writable) propTags.push({ tagName: "read-only", paramName: "", text: "" });
|
|
23443
23545
|
else if (tsProp.writable && !tsProp.readable) propTags.push({ tagName: "write-only", paramName: "", text: "" });
|
|
23546
|
+
if (tsProp.defaultValue !== void 0)
|
|
23547
|
+
propTags.push({
|
|
23548
|
+
tagName: "default",
|
|
23549
|
+
paramName: "",
|
|
23550
|
+
text: convertCDefaultValue(tsProp.defaultValue, this.namespace)
|
|
23551
|
+
});
|
|
23444
23552
|
desc.push(...this.addGirDocComment(tsProp.doc, propTags, indentCount));
|
|
23445
23553
|
const indent = generateIndent(indentCount);
|
|
23446
23554
|
const name = generateMemberName(tsProp);
|
|
@@ -23527,13 +23635,16 @@ export const ${node.name}: ${node.name}Namespace & {
|
|
|
23527
23635
|
}
|
|
23528
23636
|
}
|
|
23529
23637
|
const typeStr = this.generateDirectedType(type, "out" /* Out */);
|
|
23530
|
-
desc.push(`${indent}${commentOut}${staticStr}${readonly}${name}${affix}: ${typeStr}
|
|
23638
|
+
desc.push(`${indent}${commentOut}${staticStr}${readonly}${name}${affix}: ${typeStr};`);
|
|
23531
23639
|
return desc;
|
|
23532
23640
|
}
|
|
23533
23641
|
generateProperties(tsProps, comment, indentCount = 0) {
|
|
23534
23642
|
const def = [];
|
|
23535
23643
|
for (const tsProp of tsProps) {
|
|
23536
|
-
|
|
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);
|
|
23537
23648
|
}
|
|
23538
23649
|
if (def.length > 0) {
|
|
23539
23650
|
def.unshift(...addInfoComment(comment, indentCount));
|
|
@@ -23543,7 +23654,10 @@ export const ${node.name}: ${node.name}Namespace & {
|
|
|
23543
23654
|
generateFields(tsProps, comment, indentCount = 0) {
|
|
23544
23655
|
const def = [];
|
|
23545
23656
|
for (const tsProp of tsProps) {
|
|
23546
|
-
|
|
23657
|
+
const fieldLines = this.generateField(tsProp, indentCount);
|
|
23658
|
+
if (fieldLines.length === 0) continue;
|
|
23659
|
+
if (def.length > 0) def.push("");
|
|
23660
|
+
def.push(...fieldLines);
|
|
23547
23661
|
}
|
|
23548
23662
|
if (def.length > 0) {
|
|
23549
23663
|
def.unshift(...addInfoComment(comment, indentCount));
|
|
@@ -23723,8 +23837,8 @@ export const ${node.name}: ${node.name}Namespace & {
|
|
|
23723
23837
|
}
|
|
23724
23838
|
return typeStr;
|
|
23725
23839
|
}
|
|
23726
|
-
generateClassFunction(node) {
|
|
23727
|
-
return this.generateFunction(node);
|
|
23840
|
+
generateClassFunction(node, indentCount = 0) {
|
|
23841
|
+
return this.generateFunction(node, indentCount);
|
|
23728
23842
|
}
|
|
23729
23843
|
generateFunction(tsFunction, indentCount = 0) {
|
|
23730
23844
|
const def = [];
|
|
@@ -23780,14 +23894,17 @@ export const ${node.name}: ${node.name}Namespace & {
|
|
|
23780
23894
|
def.push(
|
|
23781
23895
|
`${indent}${commentOut}${exportStr}${staticStr}${globalStr}${name}${genericStr}(${inParamsDef.join(
|
|
23782
23896
|
", "
|
|
23783
|
-
)})${retSep} ${returnType}
|
|
23897
|
+
)})${retSep} ${returnType};`
|
|
23784
23898
|
);
|
|
23785
23899
|
return def;
|
|
23786
23900
|
}
|
|
23787
23901
|
generateFunctions(tsFunctions, indentCount = 1, comment) {
|
|
23788
23902
|
const def = [];
|
|
23789
23903
|
for (const girFunction of tsFunctions) {
|
|
23790
|
-
|
|
23904
|
+
const fnLines = this.generateFunction(girFunction, indentCount);
|
|
23905
|
+
if (fnLines.length === 0) continue;
|
|
23906
|
+
if (def.length > 0) def.push("");
|
|
23907
|
+
def.push(...fnLines);
|
|
23791
23908
|
}
|
|
23792
23909
|
if (def.length > 0) {
|
|
23793
23910
|
def.unshift(...addInfoComment(comment, indentCount));
|
|
@@ -23813,7 +23930,7 @@ export const ${node.name}: ${node.name}Namespace & {
|
|
|
23813
23930
|
}
|
|
23814
23931
|
const interfaceHead = `${name}${genericParameters}`;
|
|
23815
23932
|
def.push(this.generateExport("interface", `${interfaceHead}`, "{", indentCount));
|
|
23816
|
-
def.push(`${indentBody}(${inParamsDef.join(", ")}): ${returnTypeStr}
|
|
23933
|
+
def.push(`${indentBody}(${inParamsDef.join(", ")}): ${returnTypeStr};`);
|
|
23817
23934
|
def.push(`${indent}}`);
|
|
23818
23935
|
return def;
|
|
23819
23936
|
}
|
|
@@ -23883,7 +24000,7 @@ export const ${node.name}: ${node.name}Namespace & {
|
|
|
23883
24000
|
const exp = !this.config.noNamespace ? "" : "export ";
|
|
23884
24001
|
const ComputedName = generateMemberName(tsConst);
|
|
23885
24002
|
const typeStr = this.generateType(resolveDirectedType(tsConst.type, "out" /* Out */) ?? tsConst.type);
|
|
23886
|
-
desc.push(`${indent}${exp}const ${ComputedName}: ${typeStr}
|
|
24003
|
+
desc.push(`${indent}${exp}const ${ComputedName}: ${typeStr};`);
|
|
23887
24004
|
return desc;
|
|
23888
24005
|
}
|
|
23889
24006
|
generateAlias(girAlias, indentCount = 0) {
|
|
@@ -23905,7 +24022,7 @@ export const ${node.name}: ${node.name}Namespace & {
|
|
|
23905
24022
|
}).join(", ");
|
|
23906
24023
|
const generics = genericList ? `<${genericList}>` : "";
|
|
23907
24024
|
const exp = !this.config.noNamespace ? "" : "export ";
|
|
23908
|
-
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)};`);
|
|
23909
24026
|
return desc;
|
|
23910
24027
|
}
|
|
23911
24028
|
generateConstructPropsInterface(girClass, indentCount = 0) {
|
|
@@ -23937,10 +24054,11 @@ export const ${node.name}: ${node.name}Namespace & {
|
|
|
23937
24054
|
}
|
|
23938
24055
|
def.push(...addInfoComment("Constructor properties interface", indentCount));
|
|
23939
24056
|
const { props } = girClass;
|
|
23940
|
-
const
|
|
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");
|
|
23941
24059
|
def.push(`${indent}${exp}interface ${constructPropInterfaceName}${genericTypes} ${ext} {`);
|
|
23942
|
-
def.push(
|
|
23943
|
-
def.push(`${indent}}
|
|
24060
|
+
def.push(constructorPropMembers);
|
|
24061
|
+
def.push(`${indent}}`);
|
|
23944
24062
|
return def;
|
|
23945
24063
|
}
|
|
23946
24064
|
generateClassStaticFields(girClass, indentCount = 1) {
|
|
@@ -24031,22 +24149,23 @@ export const ${node.name}: ${node.name}Namespace & {
|
|
|
24031
24149
|
}
|
|
24032
24150
|
generateClassConstructors(girClass, indentCount = 1) {
|
|
24033
24151
|
const def = [];
|
|
24152
|
+
const indent = generateIndent(indentCount);
|
|
24034
24153
|
if (girClass.mainConstructor instanceof IntrospectedDirectAllocationConstructor)
|
|
24035
|
-
def.push(...this.generateDirectAllocationConstructor(girClass.mainConstructor));
|
|
24154
|
+
def.push(...this.generateDirectAllocationConstructor(girClass.mainConstructor, indentCount));
|
|
24036
24155
|
else if (girClass.mainConstructor instanceof IntrospectedConstructor)
|
|
24037
|
-
def.push(...this.generateConstructor(girClass.mainConstructor));
|
|
24038
|
-
else if (girClass.namespace.namespace === "GObject" && girClass.name === "Object" || girClass.someParent((p) => p.namespace.namespace === "GObject" && p.name === "Object"))
|
|
24039
|
-
def.push(
|
|
24040
|
-
|
|
24041
|
-
|
|
24042
|
-
if (
|
|
24043
|
-
def.
|
|
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));
|
|
24044
24168
|
}
|
|
24045
|
-
def.push(
|
|
24046
|
-
...filterFunctionConflict(girClass.parent, girClass, girClass.constructors, []).flatMap(
|
|
24047
|
-
(constructorFunction) => this.generateConstructorFunction(constructorFunction)
|
|
24048
|
-
)
|
|
24049
|
-
);
|
|
24050
24169
|
if (def.length) {
|
|
24051
24170
|
def.unshift(...addInfoComment("Constructors", indentCount));
|
|
24052
24171
|
}
|
|
@@ -24342,7 +24461,8 @@ ${girClass.__ts__indexSignature}
|
|
|
24342
24461
|
def.push(this.generateExport("class", classHead, "{"));
|
|
24343
24462
|
}
|
|
24344
24463
|
const gtypeNamespace = this.namespace.namespace === "GObject" ? "" : "GObject.";
|
|
24345
|
-
|
|
24464
|
+
const classBodyIndent = generateIndent(1);
|
|
24465
|
+
def.push(`${classBodyIndent}static $gtype: ${gtypeNamespace}GType<${girClass.gtype}>;`);
|
|
24346
24466
|
if (girClass.__ts__indexSignature) {
|
|
24347
24467
|
def.push(`
|
|
24348
24468
|
${girClass.__ts__indexSignature}
|
|
@@ -24362,6 +24482,8 @@ ${girClass.__ts__indexSignature}
|
|
|
24362
24482
|
const rawProperties = girClass.implementedProperties();
|
|
24363
24483
|
const rawMethods = girClass.implementedMethods(rawProperties);
|
|
24364
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}`);
|
|
24365
24487
|
const propsBySource = groupBySource(rawProperties);
|
|
24366
24488
|
for (const [source, props] of propsBySource) {
|
|
24367
24489
|
const copied = props.map((p) => p.copy({ parent: girClass }));
|
|
@@ -24371,7 +24493,8 @@ ${girClass.__ts__indexSignature}
|
|
|
24371
24493
|
if (source !== selfName) {
|
|
24372
24494
|
injectInheritedTags(memberLines, source);
|
|
24373
24495
|
}
|
|
24374
|
-
def.push(
|
|
24496
|
+
def.push("");
|
|
24497
|
+
def.push(...indentMember(memberLines));
|
|
24375
24498
|
}
|
|
24376
24499
|
}
|
|
24377
24500
|
}
|
|
@@ -24388,7 +24511,8 @@ ${girClass.__ts__indexSignature}
|
|
|
24388
24511
|
if (source !== selfName) {
|
|
24389
24512
|
injectInheritedTags(memberLines, source);
|
|
24390
24513
|
}
|
|
24391
|
-
def.push(
|
|
24514
|
+
def.push("");
|
|
24515
|
+
def.push(...indentMember(memberLines));
|
|
24392
24516
|
}
|
|
24393
24517
|
}
|
|
24394
24518
|
}
|
|
@@ -24473,11 +24597,13 @@ ${girClass.__ts__indexSignature}
|
|
|
24473
24597
|
}
|
|
24474
24598
|
if (girModule.members) {
|
|
24475
24599
|
for (const m of girModule.members.values()) {
|
|
24476
|
-
|
|
24477
|
-
|
|
24478
|
-
);
|
|
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);
|
|
24479
24604
|
}
|
|
24480
24605
|
}
|
|
24606
|
+
if (out.length > 0) out.push("");
|
|
24481
24607
|
out.push(
|
|
24482
24608
|
...this.generateConst(
|
|
24483
24609
|
new IntrospectedConstant({
|
|
@@ -24505,6 +24631,7 @@ ${girClass.__ts__indexSignature}
|
|
|
24505
24631
|
}),
|
|
24506
24632
|
0
|
|
24507
24633
|
),
|
|
24634
|
+
"",
|
|
24508
24635
|
...this.generateConst(
|
|
24509
24636
|
new IntrospectedConstant({
|
|
24510
24637
|
doc: printGirDocComment(
|
|
@@ -24531,6 +24658,12 @@ ${girClass.__ts__indexSignature}
|
|
|
24531
24658
|
if (overrideSuffix) {
|
|
24532
24659
|
out.push("", overrideSuffix);
|
|
24533
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
|
+
}
|
|
24534
24667
|
return Promise.resolve(out);
|
|
24535
24668
|
}
|
|
24536
24669
|
/**
|
|
@@ -25871,6 +26004,7 @@ import {
|
|
|
25871
26004
|
normalizePath,
|
|
25872
26005
|
ReferenceReflection,
|
|
25873
26006
|
ReflectionCategory,
|
|
26007
|
+
ReflectionKind,
|
|
25874
26008
|
Serializer,
|
|
25875
26009
|
TSConfigReader
|
|
25876
26010
|
} from "typedoc";
|
|
@@ -26468,19 +26602,59 @@ var TypeDocPipeline = class {
|
|
|
26468
26602
|
}
|
|
26469
26603
|
/**
|
|
26470
26604
|
* Extract a human-readable source name from an inherited member's `inheritedFrom`.
|
|
26471
|
-
*
|
|
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.
|
|
26472
26624
|
*/
|
|
26473
26625
|
extractInheritedSourceName(child) {
|
|
26474
26626
|
if (!child.inheritedFrom) return null;
|
|
26475
|
-
|
|
26476
|
-
|
|
26477
|
-
|
|
26478
|
-
|
|
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();
|
|
26479
26649
|
if (fullName) return fullName;
|
|
26650
|
+
if (target.parent) {
|
|
26651
|
+
const parentName = target.parent.getFullName();
|
|
26652
|
+
if (parentName) return parentName;
|
|
26653
|
+
}
|
|
26480
26654
|
}
|
|
26481
26655
|
const name = child.inheritedFrom.name;
|
|
26482
|
-
const
|
|
26483
|
-
return
|
|
26656
|
+
const lastDot = name.lastIndexOf(".");
|
|
26657
|
+
return lastDot > 0 ? name.slice(0, lastDot) : name;
|
|
26484
26658
|
}
|
|
26485
26659
|
/**
|
|
26486
26660
|
* Fix ReferenceReflection targets broken by TypeDoc's handling of
|
|
@@ -26705,10 +26879,10 @@ import { JSX } from "typedoc";
|
|
|
26705
26879
|
var giDocgenFooter = (_context) => JSX.createElement(JSX.Fragment, null);
|
|
26706
26880
|
|
|
26707
26881
|
// ../typedoc-theme/src/partials/header.ts
|
|
26708
|
-
import { JSX as JSX2, ReflectionKind as
|
|
26882
|
+
import { JSX as JSX2, ReflectionKind as ReflectionKind3 } from "typedoc";
|
|
26709
26883
|
|
|
26710
26884
|
// ../typedoc-theme/src/utils.ts
|
|
26711
|
-
import { ReflectionKind } from "typedoc";
|
|
26885
|
+
import { ReflectionKind as ReflectionKind2 } from "typedoc";
|
|
26712
26886
|
function getGirTypeFromComment(refl) {
|
|
26713
26887
|
const comment = refl.comment;
|
|
26714
26888
|
if (!comment) return void 0;
|
|
@@ -26813,17 +26987,17 @@ function getGirNamespaceMetadata(reflection) {
|
|
|
26813
26987
|
const mod = findOwningModule(reflection) ?? reflection;
|
|
26814
26988
|
return mod.girNamespaceMetadata;
|
|
26815
26989
|
}
|
|
26816
|
-
var COMPANION_OWNER_KINDS =
|
|
26990
|
+
var COMPANION_OWNER_KINDS = ReflectionKind2.Class | ReflectionKind2.Interface | ReflectionKind2.Enum;
|
|
26817
26991
|
function findCompanionNamespace(refl) {
|
|
26818
26992
|
if (!refl.kindOf(COMPANION_OWNER_KINDS)) return void 0;
|
|
26819
26993
|
const parent = refl.parent;
|
|
26820
26994
|
if (!parent || !("children" in parent)) return void 0;
|
|
26821
26995
|
const siblings = parent.children;
|
|
26822
26996
|
if (!siblings) return void 0;
|
|
26823
|
-
return siblings.find((child) => child !== refl && child.kindOf(
|
|
26997
|
+
return siblings.find((child) => child !== refl && child.kindOf(ReflectionKind2.Namespace) && child.name === refl.name);
|
|
26824
26998
|
}
|
|
26825
26999
|
function isCompanionNamespace(nsRefl) {
|
|
26826
|
-
if (!nsRefl.kindOf(
|
|
27000
|
+
if (!nsRefl.kindOf(ReflectionKind2.Namespace)) return false;
|
|
26827
27001
|
const parent = nsRefl.parent;
|
|
26828
27002
|
if (!parent || !("children" in parent)) return false;
|
|
26829
27003
|
const siblings = parent.children;
|
|
@@ -26840,7 +27014,7 @@ function getHierarchyRoots(project) {
|
|
|
26840
27014
|
const queue = [project];
|
|
26841
27015
|
for (let i = 0; i < queue.length; i++) {
|
|
26842
27016
|
const refl = queue[i];
|
|
26843
|
-
if (refl.kindOf(
|
|
27017
|
+
if (refl.kindOf(ReflectionKind2.Class)) {
|
|
26844
27018
|
const decl = refl;
|
|
26845
27019
|
if (decl.typeHierarchy) {
|
|
26846
27020
|
roots.push(decl);
|
|
@@ -26915,7 +27089,7 @@ var giDocgenHeader = (context, props) => {
|
|
|
26915
27089
|
} else if (props.model.isDocument()) {
|
|
26916
27090
|
renderTitle = headings.document;
|
|
26917
27091
|
} else {
|
|
26918
|
-
kindString =
|
|
27092
|
+
kindString = ReflectionKind3.singularString(props.model.kind);
|
|
26919
27093
|
}
|
|
26920
27094
|
if (kindString) {
|
|
26921
27095
|
const girType = getGirTypeFromComment(props.model);
|
|
@@ -26933,7 +27107,7 @@ var giDocgenHeader = (context, props) => {
|
|
|
26933
27107
|
refl = refl.parent;
|
|
26934
27108
|
}
|
|
26935
27109
|
path.reverse();
|
|
26936
|
-
const isModulePage = !props.model.isProject() && props.model.kindOf(
|
|
27110
|
+
const isModulePage = !props.model.isProject() && props.model.kindOf(ReflectionKind3.Module) && !props.model.parent?.parent;
|
|
26937
27111
|
const nsMeta = isModulePage ? getGirNamespaceMetadata(props.model) : void 0;
|
|
26938
27112
|
return JSX2.createElement(
|
|
26939
27113
|
"div",
|
|
@@ -27166,7 +27340,7 @@ var giDocgenLayout = (context, template2, props) => JSX3.createElement(
|
|
|
27166
27340
|
import {
|
|
27167
27341
|
JSX as JSX4,
|
|
27168
27342
|
ReferenceReflection as ReferenceReflection2,
|
|
27169
|
-
ReflectionKind as
|
|
27343
|
+
ReflectionKind as ReflectionKind4
|
|
27170
27344
|
} from "typedoc";
|
|
27171
27345
|
function isNoneSection(section) {
|
|
27172
27346
|
return section.title.toLocaleLowerCase() === "none";
|
|
@@ -27274,11 +27448,11 @@ function giDocgenModuleReflection(context, mod) {
|
|
|
27274
27448
|
const parent = mod.parent;
|
|
27275
27449
|
const siblings = parent && "children" in parent ? parent.children : void 0;
|
|
27276
27450
|
const companionOwner = siblings?.find(
|
|
27277
|
-
(child) => child !== mod && child.kindOf(
|
|
27451
|
+
(child) => child !== mod && child.kindOf(ReflectionKind4.Class | ReflectionKind4.Interface | ReflectionKind4.Enum) && child.name === mod.name
|
|
27278
27452
|
);
|
|
27279
27453
|
if (companionOwner) {
|
|
27280
27454
|
const ownerUrl = context.urlTo(companionOwner);
|
|
27281
|
-
const kindName = companionOwner.kindOf(
|
|
27455
|
+
const kindName = companionOwner.kindOf(ReflectionKind4.Enum) ? "enum" : companionOwner.kindOf(ReflectionKind4.Interface) ? "interface" : "class";
|
|
27282
27456
|
return JSX4.createElement(
|
|
27283
27457
|
JSX4.Fragment,
|
|
27284
27458
|
null,
|
|
@@ -27351,7 +27525,7 @@ function giDocgenModuleReflection(context, mod) {
|
|
|
27351
27525
|
);
|
|
27352
27526
|
}),
|
|
27353
27527
|
// 3. README content — rendered at the bottom in a collapsible section
|
|
27354
|
-
mod.isDeclaration() && mod.kind ===
|
|
27528
|
+
mod.isDeclaration() && mod.kind === ReflectionKind4.Module && !!mod.readme?.length && (() => {
|
|
27355
27529
|
const readmeTitle = "Readme";
|
|
27356
27530
|
context.page.startNewSection(readmeTitle);
|
|
27357
27531
|
return JSX4.createElement(
|
|
@@ -27573,10 +27747,10 @@ var giDocgenPageSidebar = (context, props) => JSX7.createElement(JSX7.Fragment,
|
|
|
27573
27747
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
27574
27748
|
import { dirname as dirname8, join as join14 } from "node:path";
|
|
27575
27749
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
27576
|
-
import { i18n, JSX as JSX8, ReflectionKind as
|
|
27750
|
+
import { i18n, JSX as JSX8, ReflectionKind as ReflectionKind5 } from "typedoc";
|
|
27577
27751
|
function getTsForGirVersion() {
|
|
27578
27752
|
if (true) {
|
|
27579
|
-
return "4.0.0-rc.
|
|
27753
|
+
return "4.0.0-rc.8";
|
|
27580
27754
|
}
|
|
27581
27755
|
const __dirname3 = dirname8(fileURLToPath5(import.meta.url));
|
|
27582
27756
|
return JSON.parse(readFileSync7(join14(__dirname3, "..", "..", "package.json"), "utf8")).version;
|
|
@@ -27597,9 +27771,9 @@ function giDocgenModuleInfo(context, mod, nsMeta) {
|
|
|
27597
27771
|
);
|
|
27598
27772
|
});
|
|
27599
27773
|
const childNamespaces = mod.children?.filter(
|
|
27600
|
-
(child) => child.kindOf(
|
|
27774
|
+
(child) => child.kindOf(ReflectionKind5.Namespace) && child.name !== "default" && !isCompanionNamespace(child)
|
|
27601
27775
|
);
|
|
27602
|
-
const childModules = mod.children?.filter((child) => child.kindOf(
|
|
27776
|
+
const childModules = mod.children?.filter((child) => child.kindOf(ReflectionKind5.Module) && child.name !== "default");
|
|
27603
27777
|
const packageVersion = mod.packageVersion || nsMeta.packageVersion;
|
|
27604
27778
|
const pageModel = context.page.model;
|
|
27605
27779
|
const isChildActive = (child) => {
|
|
@@ -27809,7 +27983,7 @@ var giDocgenToolbar = (context, _props) => {
|
|
|
27809
27983
|
import {
|
|
27810
27984
|
DeclarationReflection as DeclarationReflection3,
|
|
27811
27985
|
JSX as JSX10,
|
|
27812
|
-
ReflectionKind as
|
|
27986
|
+
ReflectionKind as ReflectionKind6,
|
|
27813
27987
|
i18n as i18n2
|
|
27814
27988
|
} from "typedoc";
|
|
27815
27989
|
function hasTypeParameters(reflection) {
|
|
@@ -27882,10 +28056,10 @@ function renderCompanionNamespaceSection(context, companionNs) {
|
|
|
27882
28056
|
);
|
|
27883
28057
|
}
|
|
27884
28058
|
function giDocgenReflectionTemplate(context, props) {
|
|
27885
|
-
if (props.model.kindOf(
|
|
28059
|
+
if (props.model.kindOf(ReflectionKind6.TypeAlias | ReflectionKind6.Variable) && props.model instanceof DeclarationReflection3 && props.model.type) {
|
|
27886
28060
|
return context.memberDeclaration(props.model);
|
|
27887
28061
|
}
|
|
27888
|
-
if (props.model.kindOf(
|
|
28062
|
+
if (props.model.kindOf(ReflectionKind6.ExportContainer) && (props.model.isDeclaration() || props.model.isProject())) {
|
|
27889
28063
|
return context.moduleReflection(props.model);
|
|
27890
28064
|
}
|
|
27891
28065
|
const companionNs = props.model instanceof DeclarationReflection3 ? findCompanionNamespace(props.model) : void 0;
|
|
@@ -28161,21 +28335,9 @@ var HtmlDocGenerator = class _HtmlDocGenerator {
|
|
|
28161
28335
|
};
|
|
28162
28336
|
|
|
28163
28337
|
// src/formatters/typescript-formatter.ts
|
|
28164
|
-
import prettier from "prettier";
|
|
28165
|
-
var logger4 = new Logger(false, "TypeScriptFormatter");
|
|
28166
28338
|
var TypeScriptFormatter = class extends Formatter {
|
|
28167
28339
|
format(input2) {
|
|
28168
|
-
|
|
28169
|
-
return prettier.format(input2, {
|
|
28170
|
-
singleQuote: true,
|
|
28171
|
-
parser: "typescript",
|
|
28172
|
-
printWidth: 120,
|
|
28173
|
-
tabWidth: 4
|
|
28174
|
-
});
|
|
28175
|
-
} catch (error) {
|
|
28176
|
-
logger4.warn("Failed to format with prettier, returning original input", error);
|
|
28177
|
-
return Promise.resolve(input2);
|
|
28178
|
-
}
|
|
28340
|
+
return Promise.resolve(input2);
|
|
28179
28341
|
}
|
|
28180
28342
|
};
|
|
28181
28343
|
|
|
@@ -28265,7 +28427,7 @@ var GenerationHandler = class {
|
|
|
28265
28427
|
async function runGenerationCommand(args, options2) {
|
|
28266
28428
|
const config = await load(args);
|
|
28267
28429
|
const generateConfig = getOptionsGeneration(config);
|
|
28268
|
-
const
|
|
28430
|
+
const logger5 = new Logger(true, options2.loggerName);
|
|
28269
28431
|
const registry = new NSRegistry();
|
|
28270
28432
|
options2.configureRegistry?.(registry);
|
|
28271
28433
|
const moduleLoader = new ModuleLoader(generateConfig, registry);
|
|
@@ -28277,7 +28439,7 @@ async function runGenerationCommand(args, options2) {
|
|
|
28277
28439
|
config.ignoreVersionConflicts
|
|
28278
28440
|
);
|
|
28279
28441
|
if (keep.length === 0) {
|
|
28280
|
-
|
|
28442
|
+
logger5.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
|
|
28281
28443
|
return;
|
|
28282
28444
|
}
|
|
28283
28445
|
tsForGir = new GenerationHandler(generateConfig, options2.generatorType, registry);
|
|
@@ -28403,7 +28565,7 @@ var json2 = {
|
|
|
28403
28565
|
// src/commands/list.ts
|
|
28404
28566
|
var command7 = "list [modules..]";
|
|
28405
28567
|
var description7 = "Lists all available GIR modules";
|
|
28406
|
-
var
|
|
28568
|
+
var logger4 = new Logger(true, "ListCommand");
|
|
28407
28569
|
var examples7 = [
|
|
28408
28570
|
[`${APP_NAME} list -g ./vala-girs/gir-1.0`, "Lists all available GIR modules in ./vala-girs/gir-1.0"],
|
|
28409
28571
|
[
|
|
@@ -28420,35 +28582,35 @@ var handler7 = async (args) => {
|
|
|
28420
28582
|
const { grouped, failed } = await moduleLoader.getModules(config.modules, config.ignore);
|
|
28421
28583
|
const moduleGroups = Object.values(grouped);
|
|
28422
28584
|
if (Object.keys(grouped).length === 0) {
|
|
28423
|
-
return
|
|
28585
|
+
return logger4.error(ERROR_NO_MODULES_FOUND(config.girDirectories));
|
|
28424
28586
|
}
|
|
28425
28587
|
const conflictModules = moduleGroups.filter((moduleGroup) => moduleGroup.hasConflict);
|
|
28426
28588
|
const allModules = moduleGroups.filter((moduleGroup) => !moduleGroup.hasConflict);
|
|
28427
|
-
|
|
28589
|
+
logger4.info("\nSearch for gir files in:");
|
|
28428
28590
|
for (const dir of config.girDirectories) {
|
|
28429
|
-
|
|
28591
|
+
logger4.white(`- ${dir}`);
|
|
28430
28592
|
}
|
|
28431
|
-
|
|
28593
|
+
logger4.info("\nAvailable Modules:");
|
|
28432
28594
|
for (const moduleGroup of allModules) {
|
|
28433
28595
|
for (const module of moduleGroup.modules) {
|
|
28434
|
-
|
|
28435
|
-
|
|
28596
|
+
logger4.white(`- ${module.packageName}`);
|
|
28597
|
+
logger4.gray(` - ${module.path}`);
|
|
28436
28598
|
}
|
|
28437
28599
|
}
|
|
28438
28600
|
if (conflictModules.length > 0) {
|
|
28439
|
-
|
|
28601
|
+
logger4.danger("\nConflicts:");
|
|
28440
28602
|
for (const moduleGroup of conflictModules) {
|
|
28441
|
-
|
|
28603
|
+
logger4.white(`- ${moduleGroup.namespace}`);
|
|
28442
28604
|
for (const conflictModule of moduleGroup.modules) {
|
|
28443
|
-
|
|
28444
|
-
|
|
28605
|
+
logger4.white(` - ${conflictModule.packageName}`);
|
|
28606
|
+
logger4.gray(` - ${conflictModule.path}`);
|
|
28445
28607
|
}
|
|
28446
28608
|
}
|
|
28447
28609
|
}
|
|
28448
28610
|
if (failed.length > 0) {
|
|
28449
|
-
|
|
28611
|
+
logger4.danger("\nDependencies not found:");
|
|
28450
28612
|
for (const fail of failed) {
|
|
28451
|
-
|
|
28613
|
+
logger4.white(`- ${fail}`);
|
|
28452
28614
|
}
|
|
28453
28615
|
}
|
|
28454
28616
|
};
|
|
@@ -28461,7 +28623,14 @@ var list = {
|
|
|
28461
28623
|
};
|
|
28462
28624
|
|
|
28463
28625
|
// src/start.ts
|
|
28464
|
-
|
|
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
|
+
}
|
|
28465
28634
|
/*! Bundled license information:
|
|
28466
28635
|
|
|
28467
28636
|
lodash/lodash.js:
|
|
@@ -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.
|
|
18
|
-
"@girs/gio-2.0": "^2.88.0-4.0.0-rc.
|
|
19
|
-
"@girs/gjs": "^4.0.0-rc.
|
|
20
|
-
"@girs/glib-2.0": "^2.88.0-4.0.0-rc.
|
|
21
|
-
"@girs/gtk-4.0": "^4.23.0-4.0.0-rc.
|
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/cli",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
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.
|
|
59
|
-
"@ts-for-gir/generator-base": "^4.0.0-rc.
|
|
60
|
-
"@ts-for-gir/generator-html-doc": "^4.0.0-rc.
|
|
61
|
-
"@ts-for-gir/generator-json": "^4.0.0-rc.
|
|
62
|
-
"@ts-for-gir/generator-typescript": "^4.0.0-rc.
|
|
63
|
-
"@ts-for-gir/lib": "^4.0.0-rc.
|
|
64
|
-
"@ts-for-gir/reporter": "^4.0.0-rc.
|
|
65
|
-
"@ts-for-gir/tsconfig": "^4.0.0-rc.
|
|
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.
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
}
|