@ts-for-gir/cli 4.0.0-beta.34 → 4.0.0-beta.36
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/README.md +1 -1
- package/bin/ts-for-gir +259 -14
- package/bin/ts-for-gir-dev +15 -15
- package/package.json +9 -9
- package/src/commands/generate.ts +1 -1
- package/src/commands/json.ts +1 -1
- package/src/module-loader.ts +2 -0
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ Examples:
|
|
|
125
125
|
ts-for-gir generate Run 'ts-for-gir generate' in your gjs
|
|
126
126
|
project to generate typings for your
|
|
127
127
|
project, pass the gir modules you need
|
|
128
|
-
ts-for-gir generate Gtk* You can also use wild cards
|
|
128
|
+
ts-for-gir generate 'Gtk*' You can also use wild cards
|
|
129
129
|
ts-for-gir generate '*' If you want to parse all of your locally
|
|
130
130
|
installed gir modules run
|
|
131
131
|
ts-for-gir generate --configName='.ts-for-gir.gtk4.rc.js' Use a special config file
|
package/bin/ts-for-gir
CHANGED
|
@@ -8502,10 +8502,17 @@ var DependencyManager = class _DependencyManager {
|
|
|
8502
8502
|
await this.get("cairo", "1.0")
|
|
8503
8503
|
];
|
|
8504
8504
|
}
|
|
8505
|
-
createImportProperties(namespace, packageName, version) {
|
|
8505
|
+
createImportProperties(namespace, packageName, version, libraryVersion) {
|
|
8506
8506
|
const importPath = this.createImportPath(packageName, namespace, version);
|
|
8507
8507
|
const importDef = this.createImportDef(namespace, importPath);
|
|
8508
|
-
|
|
8508
|
+
let effectiveLibraryVersion = libraryVersion;
|
|
8509
|
+
if ((namespace === "GObject" || namespace === "Gio") && this._cache["GLib-2.0"]) {
|
|
8510
|
+
const glibDep = this._cache["GLib-2.0"];
|
|
8511
|
+
if (glibDep.libraryVersion.toString() !== "0.0.0") {
|
|
8512
|
+
effectiveLibraryVersion = glibDep.libraryVersion;
|
|
8513
|
+
}
|
|
8514
|
+
}
|
|
8515
|
+
const packageJsonImport = this.createPackageJsonImport(importPath, effectiveLibraryVersion);
|
|
8509
8516
|
return {
|
|
8510
8517
|
importPath,
|
|
8511
8518
|
importDef,
|
|
@@ -8523,8 +8530,15 @@ var DependencyManager = class _DependencyManager {
|
|
|
8523
8530
|
createImportDef(namespace, importPath) {
|
|
8524
8531
|
return this.config.noNamespace ? `import type * as ${namespace} from '${importPath}'` : `import type ${namespace} from '${importPath}';`;
|
|
8525
8532
|
}
|
|
8526
|
-
createPackageJsonImport(importPath) {
|
|
8527
|
-
|
|
8533
|
+
createPackageJsonImport(importPath, libraryVersion) {
|
|
8534
|
+
let depVersion;
|
|
8535
|
+
if (this.config.workspace) {
|
|
8536
|
+
depVersion = "workspace:^";
|
|
8537
|
+
} else if (libraryVersion) {
|
|
8538
|
+
depVersion = `${libraryVersion.toString()}-${APP_VERSION}`;
|
|
8539
|
+
} else {
|
|
8540
|
+
depVersion = APP_VERSION;
|
|
8541
|
+
}
|
|
8528
8542
|
return `"${importPath}": "${depVersion}"`;
|
|
8529
8543
|
}
|
|
8530
8544
|
async parseGir(path) {
|
|
@@ -8604,7 +8618,7 @@ var DependencyManager = class _DependencyManager {
|
|
|
8604
8618
|
version,
|
|
8605
8619
|
libraryVersion,
|
|
8606
8620
|
girXML,
|
|
8607
|
-
...this.createImportProperties(namespace, packageName, version)
|
|
8621
|
+
...this.createImportProperties(namespace, packageName, version, libraryVersion)
|
|
8608
8622
|
};
|
|
8609
8623
|
if (!noOverride && namespace === "cairo" && version === "1.0") {
|
|
8610
8624
|
dependency.importDef = this.createImportDef("cairo", "cairo");
|
|
@@ -12723,15 +12737,27 @@ var GirModule = class _GirModule {
|
|
|
12723
12737
|
const clazzes = Array.from(this.members.values()).filter(
|
|
12724
12738
|
(m) => m instanceof IntrospectedBaseClass
|
|
12725
12739
|
);
|
|
12726
|
-
const
|
|
12740
|
+
for (const clazz of clazzes) {
|
|
12741
|
+
if (name.startsWith(clazz.name)) {
|
|
12742
|
+
const potentialCallbackName = name.slice(clazz.name.length);
|
|
12743
|
+
const callback = clazz.callbacks.find((c) => c.name === potentialCallbackName);
|
|
12744
|
+
if (callback) {
|
|
12745
|
+
return [clazz.name, callback.name];
|
|
12746
|
+
}
|
|
12747
|
+
}
|
|
12748
|
+
}
|
|
12749
|
+
const allMatches = clazzes.map((m) => [
|
|
12727
12750
|
m,
|
|
12728
12751
|
m.callbacks.find((c) => c.name === name || c.resolve_names.includes(name))
|
|
12729
|
-
]).
|
|
12730
|
-
if (
|
|
12731
|
-
return [res[0].name, res[1].name];
|
|
12732
|
-
} else {
|
|
12752
|
+
]).filter((r) => r[1] != null);
|
|
12753
|
+
if (allMatches.length === 0) {
|
|
12733
12754
|
return [null, name];
|
|
12734
12755
|
}
|
|
12756
|
+
if (allMatches.length > 1) {
|
|
12757
|
+
this.log.warn(`Found multiple matches for ${name}: ${allMatches.map((m) => m[0].name).join(", ")}`);
|
|
12758
|
+
}
|
|
12759
|
+
const res = allMatches[0];
|
|
12760
|
+
return [res[0].name, res[1].name];
|
|
12735
12761
|
}
|
|
12736
12762
|
/**
|
|
12737
12763
|
* This is an internal method to add TypeScript <reference>
|
|
@@ -16284,6 +16310,10 @@ function detectConflictType(ns, c, element, thisType) {
|
|
|
16284
16310
|
if (fieldConflict) return fieldConflict;
|
|
16285
16311
|
const propertyConflict = checkPropertyConflicts(ns, c, element, thisType);
|
|
16286
16312
|
if (propertyConflict) return propertyConflict;
|
|
16313
|
+
if (element instanceof IntrospectedVirtualClassFunction) {
|
|
16314
|
+
const vfuncConflict = checkVfuncSignatureConflicts(ns, c, element, thisType);
|
|
16315
|
+
if (vfuncConflict) return vfuncConflict;
|
|
16316
|
+
}
|
|
16287
16317
|
return checkFunctionNameConflicts(ns, c, element, thisType);
|
|
16288
16318
|
}
|
|
16289
16319
|
function checkFieldConflicts(c, element) {
|
|
@@ -16337,14 +16367,84 @@ function checkFunctionNameConflicts(ns, c, element, thisType) {
|
|
|
16337
16367
|
})
|
|
16338
16368
|
);
|
|
16339
16369
|
}
|
|
16370
|
+
function checkVfuncSignatureConflicts(ns, c, element, thisType) {
|
|
16371
|
+
if (!(c instanceof IntrospectedInterface)) {
|
|
16372
|
+
return void 0;
|
|
16373
|
+
}
|
|
16374
|
+
return c.findParentMap((resolved_parent) => {
|
|
16375
|
+
const parentVirtualMethods = resolved_parent.members.filter(
|
|
16376
|
+
(m) => m instanceof IntrospectedVirtualClassFunction && m.name === element.name
|
|
16377
|
+
);
|
|
16378
|
+
for (const parentMethod of parentVirtualMethods) {
|
|
16379
|
+
if (isConflictingFunction(ns, thisType, element, resolved_parent.getType(), parentMethod)) {
|
|
16380
|
+
return 6 /* VFUNC_SIGNATURE_CONFLICT */;
|
|
16381
|
+
}
|
|
16382
|
+
}
|
|
16383
|
+
if (resolved_parent instanceof IntrospectedInterface) {
|
|
16384
|
+
const parentInterfaceVirtualMethods = resolved_parent.members.filter(
|
|
16385
|
+
(m) => m instanceof IntrospectedVirtualClassFunction && m.name === element.name
|
|
16386
|
+
);
|
|
16387
|
+
for (const parentMethod of parentInterfaceVirtualMethods) {
|
|
16388
|
+
if (isConflictingFunction(ns, thisType, element, resolved_parent.getType(), parentMethod)) {
|
|
16389
|
+
return 6 /* VFUNC_SIGNATURE_CONFLICT */;
|
|
16390
|
+
}
|
|
16391
|
+
}
|
|
16392
|
+
}
|
|
16393
|
+
return void 0;
|
|
16394
|
+
});
|
|
16395
|
+
}
|
|
16340
16396
|
function createConflictElement(element, conflictType) {
|
|
16341
16397
|
if (element instanceof IntrospectedField || element instanceof IntrospectedProperty) {
|
|
16342
16398
|
return element.copy({
|
|
16343
16399
|
type: new TypeConflict(element.type, conflictType)
|
|
16344
16400
|
});
|
|
16345
16401
|
}
|
|
16402
|
+
if (conflictType === 6 /* VFUNC_SIGNATURE_CONFLICT */ && element instanceof IntrospectedVirtualClassFunction) {
|
|
16403
|
+
return element;
|
|
16404
|
+
}
|
|
16346
16405
|
return null;
|
|
16347
16406
|
}
|
|
16407
|
+
function hasVfuncSignatureConflicts(ns, interfaceClass) {
|
|
16408
|
+
const thisType = interfaceClass.getType();
|
|
16409
|
+
const virtualMethods = interfaceClass.members.filter(
|
|
16410
|
+
(m) => m instanceof IntrospectedVirtualClassFunction
|
|
16411
|
+
);
|
|
16412
|
+
if (virtualMethods.length === 0) {
|
|
16413
|
+
return false;
|
|
16414
|
+
}
|
|
16415
|
+
for (const vmethod of virtualMethods) {
|
|
16416
|
+
const conflictType = checkVfuncSignatureConflicts(ns, interfaceClass, vmethod, thisType);
|
|
16417
|
+
if (conflictType === 6 /* VFUNC_SIGNATURE_CONFLICT */) {
|
|
16418
|
+
return true;
|
|
16419
|
+
}
|
|
16420
|
+
}
|
|
16421
|
+
const hasParentWithVirtualMethods = interfaceClass.someParent((parent) => {
|
|
16422
|
+
if (!(parent instanceof IntrospectedInterface)) {
|
|
16423
|
+
return false;
|
|
16424
|
+
}
|
|
16425
|
+
const parentHasVirtualMethods = parent.members.some((m) => m instanceof IntrospectedVirtualClassFunction);
|
|
16426
|
+
if (!parentHasVirtualMethods) {
|
|
16427
|
+
return false;
|
|
16428
|
+
}
|
|
16429
|
+
for (const vmethod of virtualMethods) {
|
|
16430
|
+
const parentVirtualMethods = parent.members.filter(
|
|
16431
|
+
(m) => m instanceof IntrospectedVirtualClassFunction && m.name === vmethod.name
|
|
16432
|
+
);
|
|
16433
|
+
for (const parentMethod of parentVirtualMethods) {
|
|
16434
|
+
const ourReturn = vmethod.return();
|
|
16435
|
+
const parentReturn = parentMethod.return();
|
|
16436
|
+
if (!ourReturn.equals(parentReturn)) {
|
|
16437
|
+
return true;
|
|
16438
|
+
}
|
|
16439
|
+
if (isConflictingFunction(ns, thisType, vmethod, parent.getType(), parentMethod)) {
|
|
16440
|
+
return true;
|
|
16441
|
+
}
|
|
16442
|
+
}
|
|
16443
|
+
}
|
|
16444
|
+
return false;
|
|
16445
|
+
});
|
|
16446
|
+
return hasParentWithVirtualMethods;
|
|
16447
|
+
}
|
|
16348
16448
|
|
|
16349
16449
|
// ../lib/src/utils/generation.ts
|
|
16350
16450
|
function generateMemberName(tsVar) {
|
|
@@ -18326,7 +18426,8 @@ var ModuleGenerator = class _ModuleGenerator extends FormatGenerator {
|
|
|
18326
18426
|
const isGObject = node.someParent((p) => p.namespace.namespace === "GObject" && p.name === "Object");
|
|
18327
18427
|
const functions = filterFunctionConflict(node.namespace, node, node.members, []);
|
|
18328
18428
|
const hasStaticFunctions = functions.some((f) => f instanceof IntrospectedStaticClassFunction);
|
|
18329
|
-
const
|
|
18429
|
+
const hasVirtualMethods = node.members.some((m) => m instanceof IntrospectedVirtualClassFunction);
|
|
18430
|
+
const hasNamespace = isGObject || hasStaticFunctions || node.callbacks.length > 0 || hasVirtualMethods;
|
|
18330
18431
|
return [
|
|
18331
18432
|
...this.generateClassNamespaces(node),
|
|
18332
18433
|
...hasNamespace ? this.generateInterfaceNamespace(node) : [],
|
|
@@ -19012,6 +19113,76 @@ constructor(properties?: Partial<${girClass.name}.ConstructorProps>, ...args: an
|
|
|
19012
19113
|
);
|
|
19013
19114
|
return def;
|
|
19014
19115
|
}
|
|
19116
|
+
/**
|
|
19117
|
+
* Generate virtual methods with overloads for interfaces that have conflicting signatures.
|
|
19118
|
+
* This is used when an interface can't inherit from Interface namespace due to signature conflicts.
|
|
19119
|
+
* @param girInterface The interface to generate virtual methods for
|
|
19120
|
+
* @param indentCount Indentation level
|
|
19121
|
+
*/
|
|
19122
|
+
generateVirtualMethodOverloads(girInterface, indentCount = 1) {
|
|
19123
|
+
const def = [];
|
|
19124
|
+
const indent = generateIndent(indentCount);
|
|
19125
|
+
const virtualMethods = girInterface.members.filter(
|
|
19126
|
+
(m) => m instanceof IntrospectedVirtualClassFunction
|
|
19127
|
+
);
|
|
19128
|
+
if (virtualMethods.length === 0) {
|
|
19129
|
+
return def;
|
|
19130
|
+
}
|
|
19131
|
+
def.push("");
|
|
19132
|
+
def.push(`${indent}// Virtual methods - generated with overloads due to conflicts`);
|
|
19133
|
+
def.push("");
|
|
19134
|
+
const methodsByName = /* @__PURE__ */ new Map();
|
|
19135
|
+
for (const vmethod of virtualMethods) {
|
|
19136
|
+
const methods = methodsByName.get(vmethod.name) || [];
|
|
19137
|
+
methods.push(vmethod);
|
|
19138
|
+
methodsByName.set(vmethod.name, methods);
|
|
19139
|
+
}
|
|
19140
|
+
for (const [methodName, methods] of methodsByName) {
|
|
19141
|
+
const parentMethods = [];
|
|
19142
|
+
girInterface.someParent((parent) => {
|
|
19143
|
+
const parentVirtualMethods = parent.members.filter(
|
|
19144
|
+
(m) => m instanceof IntrospectedVirtualClassFunction && m.name === methodName
|
|
19145
|
+
);
|
|
19146
|
+
parentMethods.push(...parentVirtualMethods);
|
|
19147
|
+
return false;
|
|
19148
|
+
});
|
|
19149
|
+
const allMethods = [...methods, ...parentMethods];
|
|
19150
|
+
const uniqueSignatures = /* @__PURE__ */ new Map();
|
|
19151
|
+
for (const method of allMethods) {
|
|
19152
|
+
const signature = this.generateMethodSignature(method);
|
|
19153
|
+
if (!uniqueSignatures.has(signature)) {
|
|
19154
|
+
uniqueSignatures.set(signature, method);
|
|
19155
|
+
}
|
|
19156
|
+
}
|
|
19157
|
+
for (const method of uniqueSignatures.values()) {
|
|
19158
|
+
const methodDef = method.asString(this);
|
|
19159
|
+
if (methodDef.length > 0 && !methodDef[0].includes("@ignore")) {
|
|
19160
|
+
const docLines = [];
|
|
19161
|
+
if (method.doc) {
|
|
19162
|
+
docLines.push(...this.addGirDocComment(method.doc, [], indentCount));
|
|
19163
|
+
}
|
|
19164
|
+
if (docLines.length > 0) {
|
|
19165
|
+
const lastLine = docLines[docLines.length - 1];
|
|
19166
|
+
docLines[docLines.length - 1] = lastLine.replace(" */", ` * @ignore
|
|
19167
|
+
${indent} */`);
|
|
19168
|
+
} else {
|
|
19169
|
+
docLines.push(`${indent}/** @ignore */`);
|
|
19170
|
+
}
|
|
19171
|
+
def.push(...docLines);
|
|
19172
|
+
}
|
|
19173
|
+
def.push(...methodDef);
|
|
19174
|
+
}
|
|
19175
|
+
}
|
|
19176
|
+
return def;
|
|
19177
|
+
}
|
|
19178
|
+
/**
|
|
19179
|
+
* Generate a signature string for a virtual method (used for deduplication)
|
|
19180
|
+
*/
|
|
19181
|
+
generateMethodSignature(method) {
|
|
19182
|
+
const params = method.parameters.map((p) => `${p.name}:${p.type.print(this.namespace, this.config)}`).join(",");
|
|
19183
|
+
const returnType = method.return().print(this.namespace, this.config);
|
|
19184
|
+
return `${method.name}(${params}):${returnType}`;
|
|
19185
|
+
}
|
|
19015
19186
|
generateClassSignalInterfaces(girClass, indentCount = 0) {
|
|
19016
19187
|
const def = [];
|
|
19017
19188
|
const _tsSignals = girClass.signals;
|
|
@@ -19155,6 +19326,9 @@ constructor(properties?: Partial<${girClass.name}.ConstructorProps>, ...args: an
|
|
|
19155
19326
|
if (girClass instanceof IntrospectedClass) {
|
|
19156
19327
|
bodyDef.push(...this.generateClassSignalInterfaces(girClass, indentCount + 1));
|
|
19157
19328
|
}
|
|
19329
|
+
if (girClass instanceof IntrospectedInterface) {
|
|
19330
|
+
bodyDef.push(...this.generateVirtualInterface(girClass, indentCount + 1));
|
|
19331
|
+
}
|
|
19158
19332
|
bodyDef.push(...this.generateClassCallbacks(girClass));
|
|
19159
19333
|
bodyDef.push(...this.generateConstructPropsInterface(girClass, indentCount + 1));
|
|
19160
19334
|
if (!bodyDef.length) {
|
|
@@ -19185,6 +19359,20 @@ constructor(properties?: Partial<${girClass.name}.ConstructorProps>, ...args: an
|
|
|
19185
19359
|
...superType ? [superType.node.getType().print(this.namespace, this.config)] : [],
|
|
19186
19360
|
..."implements" in resolution ? resolution.implements().map((i) => i.node.getType().print(this.namespace, this.config)) : []
|
|
19187
19361
|
];
|
|
19362
|
+
let shouldGenerateVirtualMethodOverloads = false;
|
|
19363
|
+
if (girClass instanceof IntrospectedInterface) {
|
|
19364
|
+
const hasVirtualMethods = girClass.members.some((m) => m instanceof IntrospectedVirtualClassFunction);
|
|
19365
|
+
if (hasVirtualMethods) {
|
|
19366
|
+
const hasConflicts = hasVfuncSignatureConflicts(this.namespace, girClass);
|
|
19367
|
+
if (hasConflicts) {
|
|
19368
|
+
shouldGenerateVirtualMethodOverloads = true;
|
|
19369
|
+
} else {
|
|
19370
|
+
const typeNames = girClass.generics.map((g) => g.type.identifier).filter((name) => name && name.length > 0);
|
|
19371
|
+
const genericTypeNames = typeNames.length > 0 ? `<${typeNames.join(", ")}>` : "";
|
|
19372
|
+
implementationNames.push(`${girClass.name}.Interface${genericTypeNames}`);
|
|
19373
|
+
}
|
|
19374
|
+
}
|
|
19375
|
+
}
|
|
19188
19376
|
const ext = implementationNames.length ? ` extends ${implementationNames.join(", ")}` : "";
|
|
19189
19377
|
const interfaceHead = `${girClass.name}${genericParameters}${ext}`;
|
|
19190
19378
|
def.push(this.generateExport("interface", interfaceHead, "{"));
|
|
@@ -19196,11 +19384,68 @@ ${girClass.__ts__indexSignature}
|
|
|
19196
19384
|
def.push(...this.generateClassProperties(girClass));
|
|
19197
19385
|
def.push(...this.generateClassMemberFields(girClass));
|
|
19198
19386
|
def.push(...this.generateClassMethods(girClass));
|
|
19199
|
-
|
|
19387
|
+
if (!(girClass instanceof IntrospectedInterface) || shouldGenerateVirtualMethodOverloads) {
|
|
19388
|
+
if (shouldGenerateVirtualMethodOverloads && girClass instanceof IntrospectedInterface) {
|
|
19389
|
+
def.push(...this.generateVirtualMethodOverloads(girClass));
|
|
19390
|
+
} else {
|
|
19391
|
+
def.push(...this.generateClassVirtualMethods(girClass));
|
|
19392
|
+
}
|
|
19393
|
+
}
|
|
19200
19394
|
def.push("}");
|
|
19201
19395
|
def.push("");
|
|
19202
19396
|
return def;
|
|
19203
19397
|
}
|
|
19398
|
+
/**
|
|
19399
|
+
* Generates a virtual-methods-only interface for proper GObject interface implementation.
|
|
19400
|
+
* This interface contains only the virtual methods (vfunc_*) that need to be implemented
|
|
19401
|
+
* when creating a class that implements a GObject interface.
|
|
19402
|
+
*/
|
|
19403
|
+
generateVirtualInterface(girClass, indentCount = 1) {
|
|
19404
|
+
const def = [];
|
|
19405
|
+
if (!girClass) return def;
|
|
19406
|
+
const indent = generateIndent(indentCount);
|
|
19407
|
+
const virtualMethods = girClass.members.filter(
|
|
19408
|
+
(m) => m instanceof IntrospectedVirtualClassFunction
|
|
19409
|
+
);
|
|
19410
|
+
if (virtualMethods.length === 0) {
|
|
19411
|
+
return def;
|
|
19412
|
+
}
|
|
19413
|
+
const resolution = girClass.resolveParents();
|
|
19414
|
+
const parentInterfaces = [];
|
|
19415
|
+
const parentResolution = resolution.extends();
|
|
19416
|
+
if (parentResolution && parentResolution.node instanceof IntrospectedInterface) {
|
|
19417
|
+
const parentInterface = parentResolution.node;
|
|
19418
|
+
const parentTypeIdentifier = parentResolution.identifier.resolveIdentifier(this.namespace, this.config)?.print(this.namespace, this.config);
|
|
19419
|
+
const parentHasVirtualMethods = parentInterface.members.some(
|
|
19420
|
+
(m) => m instanceof IntrospectedVirtualClassFunction
|
|
19421
|
+
);
|
|
19422
|
+
if (parentTypeIdentifier && parentHasVirtualMethods) {
|
|
19423
|
+
parentInterfaces.push(`${parentTypeIdentifier}.Interface`);
|
|
19424
|
+
}
|
|
19425
|
+
}
|
|
19426
|
+
let extendsClause = "";
|
|
19427
|
+
if (parentInterfaces.length > 0) {
|
|
19428
|
+
extendsClause = ` extends ${parentInterfaces.join(", ")}`;
|
|
19429
|
+
}
|
|
19430
|
+
const genericParameters = this.generateGenericParameters(girClass.generics);
|
|
19431
|
+
def.push(`${indent}/**`);
|
|
19432
|
+
def.push(`${indent} * Interface for implementing ${girClass.name}.`);
|
|
19433
|
+
def.push(`${indent} * Contains only the virtual methods that need to be implemented.`);
|
|
19434
|
+
def.push(`${indent} */`);
|
|
19435
|
+
def.push(`${indent}interface Interface${genericParameters}${extendsClause} {`);
|
|
19436
|
+
if (virtualMethods.length > 0) {
|
|
19437
|
+
def.push(
|
|
19438
|
+
...this.generateFunctions(
|
|
19439
|
+
filterFunctionConflict(girClass.namespace, girClass, virtualMethods, []),
|
|
19440
|
+
indentCount + 1,
|
|
19441
|
+
"Virtual methods"
|
|
19442
|
+
)
|
|
19443
|
+
);
|
|
19444
|
+
}
|
|
19445
|
+
def.push(`${indent}}`);
|
|
19446
|
+
def.push("");
|
|
19447
|
+
return def;
|
|
19448
|
+
}
|
|
19204
19449
|
extends(node) {
|
|
19205
19450
|
const { namespace: ns, options: options2 } = this;
|
|
19206
19451
|
if (node.superType) {
|
|
@@ -19851,7 +20096,7 @@ var examples4 = [
|
|
|
19851
20096
|
`${APP_NAME} generate`,
|
|
19852
20097
|
`Run '${APP_NAME} generate' in your gjs project to generate typings for your project, pass the gir modules you need for your project`
|
|
19853
20098
|
],
|
|
19854
|
-
[`${APP_NAME} generate Gtk
|
|
20099
|
+
[`${APP_NAME} generate 'Gtk*'`, "You can also use wild cards"],
|
|
19855
20100
|
[`${APP_NAME} generate '*'`, "If you want to parse all of your locally installed gir modules run"],
|
|
19856
20101
|
[`${APP_NAME} generate --configName='.ts-for-gir.gtk4.rc.js`, "Use a special config file"],
|
|
19857
20102
|
[`${APP_NAME} generate --ignore=Gtk-4.0 xrandr-1.3`, "Generate .d.ts. files but not for Gtk-4.0 and xrandr-1.3"]
|
|
@@ -19912,7 +20157,7 @@ var description5 = "Generates JSON representation from GIR files for analysis an
|
|
|
19912
20157
|
var logger7 = new Logger(true, "JsonCommand");
|
|
19913
20158
|
var examples5 = [
|
|
19914
20159
|
[`${APP_NAME} json`, `Run '${APP_NAME} json' in your gjs project to generate JSON files for your project`],
|
|
19915
|
-
[`${APP_NAME} json Gtk
|
|
20160
|
+
[`${APP_NAME} json 'Gtk*'`, "You can also use wild cards"],
|
|
19916
20161
|
[`${APP_NAME} json '*'`, "If you want to parse all of your locally installed gir modules run"],
|
|
19917
20162
|
[`${APP_NAME} json --configName='.ts-for-gir.gtk4.rc.js`, "Use a special config file"],
|
|
19918
20163
|
[`${APP_NAME} json --ignore=Gtk-4.0 xrandr-1.3`, "Generate JSON files but not for Gtk-4.0 and xrandr-1.3"]
|
package/bin/ts-for-gir-dev
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* CLI Wrapper for TypeScript Execution
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* This wrapper is required to execute our CLI tool with the necessary Node.js parameters.
|
|
7
|
-
* Due to "type": "module" specified in package.json, Node.js only accepts .js files
|
|
7
|
+
* Due to "type": "module" specified in package.json, Node.js only accepts .js files
|
|
8
8
|
* and rejects .ts or .sh files directly. This wrapper bridges that gap by:
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
10
|
* 1. Providing a .js entry point that Node.js can execute
|
|
11
11
|
* 2. Spawning the actual TypeScript file with experimental Node.js flags
|
|
12
12
|
* 3. Enabling TypeScript execution without compilation step
|
|
13
|
-
*
|
|
13
|
+
*
|
|
14
14
|
* The experimental flags used:
|
|
15
15
|
* - --experimental-specifier-resolution=node: Enables Node.js-style module resolution
|
|
16
16
|
* - --experimental-strip-types: Strips TypeScript types during execution
|
|
@@ -18,26 +18,26 @@
|
|
|
18
18
|
* - --no-warnings: Suppresses experimental feature warnings
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import { spawn } from
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
21
|
+
import { spawn } from "node:child_process";
|
|
22
|
+
import { dirname, resolve } from "node:path";
|
|
23
|
+
import { fileURLToPath } from "node:url";
|
|
24
24
|
|
|
25
25
|
// Get the current file's directory in ES module context
|
|
26
26
|
const __filename = fileURLToPath(import.meta.url);
|
|
27
27
|
const __dirname = dirname(__filename);
|
|
28
28
|
|
|
29
29
|
// Resolve the path to the actual TypeScript CLI entry point
|
|
30
|
-
const tsPath = resolve(__dirname,
|
|
30
|
+
const tsPath = resolve(__dirname, "../src/start.ts");
|
|
31
31
|
|
|
32
32
|
// Configure Node.js arguments for TypeScript execution
|
|
33
33
|
const nodeArgs = [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
"--experimental-specifier-resolution=node",
|
|
35
|
+
"--experimental-strip-types",
|
|
36
|
+
"--experimental-transform-types",
|
|
37
|
+
"--no-warnings",
|
|
38
|
+
tsPath,
|
|
39
|
+
...process.argv.slice(2), // Forward all CLI arguments to the TypeScript file
|
|
40
40
|
];
|
|
41
41
|
|
|
42
42
|
// Spawn the Node.js process with TypeScript support and inherit stdio
|
|
43
|
-
spawn(
|
|
43
|
+
spawn("node", nodeArgs, { stdio: "inherit" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/cli",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.36",
|
|
4
4
|
"description": "TypeScript type definition generator for GObject introspection GIR files",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
".": "./src/index.ts"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@gi.ts/parser": "^4.0.0-beta.
|
|
57
|
-
"@ts-for-gir/generator-base": "^4.0.0-beta.
|
|
58
|
-
"@ts-for-gir/generator-html-doc": "^4.0.0-beta.
|
|
59
|
-
"@ts-for-gir/generator-json": "^4.0.0-beta.
|
|
60
|
-
"@ts-for-gir/generator-typescript": "^4.0.0-beta.
|
|
61
|
-
"@ts-for-gir/lib": "^4.0.0-beta.
|
|
62
|
-
"@ts-for-gir/reporter": "^4.0.0-beta.
|
|
56
|
+
"@gi.ts/parser": "^4.0.0-beta.36",
|
|
57
|
+
"@ts-for-gir/generator-base": "^4.0.0-beta.36",
|
|
58
|
+
"@ts-for-gir/generator-html-doc": "^4.0.0-beta.36",
|
|
59
|
+
"@ts-for-gir/generator-json": "^4.0.0-beta.36",
|
|
60
|
+
"@ts-for-gir/generator-typescript": "^4.0.0-beta.36",
|
|
61
|
+
"@ts-for-gir/lib": "^4.0.0-beta.36",
|
|
62
|
+
"@ts-for-gir/reporter": "^4.0.0-beta.36",
|
|
63
63
|
"@types/ejs": "^3.1.5",
|
|
64
64
|
"@types/inquirer": "^9.0.9",
|
|
65
65
|
"@types/node": "^24.2.1",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@inquirer/prompts": "^7.8.2",
|
|
73
|
-
"@ts-for-gir/templates": "^4.0.0-beta.
|
|
73
|
+
"@ts-for-gir/templates": "^4.0.0-beta.36",
|
|
74
74
|
"colorette": "^2.0.20",
|
|
75
75
|
"cosmiconfig": "^9.0.0",
|
|
76
76
|
"ejs": "^3.1.10",
|
package/src/commands/generate.ts
CHANGED
|
@@ -32,7 +32,7 @@ const examples: ReadonlyArray<[string, string?]> = [
|
|
|
32
32
|
`${APP_NAME} generate`,
|
|
33
33
|
`Run '${APP_NAME} generate' in your gjs project to generate typings for your project, pass the gir modules you need for your project`,
|
|
34
34
|
],
|
|
35
|
-
[`${APP_NAME} generate Gtk
|
|
35
|
+
[`${APP_NAME} generate 'Gtk*'`, "You can also use wild cards"],
|
|
36
36
|
[`${APP_NAME} generate '*'`, "If you want to parse all of your locally installed gir modules run"],
|
|
37
37
|
[`${APP_NAME} generate --configName='.ts-for-gir.gtk4.rc.js`, "Use a special config file"],
|
|
38
38
|
[`${APP_NAME} generate --ignore=Gtk-4.0 xrandr-1.3`, "Generate .d.ts. files but not for Gtk-4.0 and xrandr-1.3"],
|
package/src/commands/json.ts
CHANGED
|
@@ -28,7 +28,7 @@ const logger = new Logger(true, "JsonCommand");
|
|
|
28
28
|
|
|
29
29
|
const examples: ReadonlyArray<[string, string?]> = [
|
|
30
30
|
[`${APP_NAME} json`, `Run '${APP_NAME} json' in your gjs project to generate JSON files for your project`],
|
|
31
|
-
[`${APP_NAME} json Gtk
|
|
31
|
+
[`${APP_NAME} json 'Gtk*'`, "You can also use wild cards"],
|
|
32
32
|
[`${APP_NAME} json '*'`, "If you want to parse all of your locally installed gir modules run"],
|
|
33
33
|
[`${APP_NAME} json --configName='.ts-for-gir.gtk4.rc.js`, "Use a special config file"],
|
|
34
34
|
[`${APP_NAME} json --ignore=Gtk-4.0 xrandr-1.3`, "Generate JSON files but not for Gtk-4.0 and xrandr-1.3"],
|
package/src/module-loader.ts
CHANGED
|
@@ -235,6 +235,8 @@ export class ModuleLoader {
|
|
|
235
235
|
const GObject = await this.dependencyManager.get("GObject", "2.0");
|
|
236
236
|
const Cairo = await this.dependencyManager.get("cairo", "1.0");
|
|
237
237
|
|
|
238
|
+
// Update library versions for GObject and Gio to use GLib's version
|
|
239
|
+
|
|
238
240
|
const dependencies = await this.fileFinder.girFilePathToDependencies(girFiles);
|
|
239
241
|
|
|
240
242
|
const { loaded, failed } = await this.loadGirModules(
|