@ts-for-gir/lib 4.0.0-beta.35 → 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/package.json +4 -4
- package/src/dependency-manager.ts +23 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/lib",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.36",
|
|
4
4
|
"description": "Typescript .d.ts generator from GIR for gjs",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"typescript": "^5.9.2"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@gi.ts/parser": "^4.0.0-beta.
|
|
52
|
-
"@ts-for-gir/reporter": "^4.0.0-beta.
|
|
53
|
-
"@ts-for-gir/templates": "^4.0.0-beta.
|
|
51
|
+
"@gi.ts/parser": "^4.0.0-beta.36",
|
|
52
|
+
"@ts-for-gir/reporter": "^4.0.0-beta.36",
|
|
53
|
+
"@ts-for-gir/templates": "^4.0.0-beta.36",
|
|
54
54
|
"colorette": "^2.0.20",
|
|
55
55
|
"ejs": "^3.1.10",
|
|
56
56
|
"glob": "^11.0.3",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { type GirInclude, type GirNamespace, type GirRepository, type GirXML, parser } from "@gi.ts/parser";
|
|
3
|
+
import { APP_VERSION } from "./constants.ts";
|
|
3
4
|
import type { GirModule } from "./gir-module.ts";
|
|
4
5
|
import { LibraryVersion } from "./library-version.ts";
|
|
5
6
|
import { Logger } from "./logger.ts";
|
|
@@ -109,10 +110,20 @@ export class DependencyManager {
|
|
|
109
110
|
];
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
createImportProperties(namespace: string, packageName: string, version: string) {
|
|
113
|
+
createImportProperties(namespace: string, packageName: string, version: string, libraryVersion?: LibraryVersion) {
|
|
113
114
|
const importPath = this.createImportPath(packageName, namespace, version);
|
|
114
115
|
const importDef = this.createImportDef(namespace, importPath);
|
|
115
|
-
|
|
116
|
+
|
|
117
|
+
// For GObject and Gio, use GLib's library version if available
|
|
118
|
+
let effectiveLibraryVersion = libraryVersion;
|
|
119
|
+
if ((namespace === "GObject" || namespace === "Gio") && this._cache["GLib-2.0"]) {
|
|
120
|
+
const glibDep = this._cache["GLib-2.0"];
|
|
121
|
+
if (glibDep.libraryVersion.toString() !== "0.0.0") {
|
|
122
|
+
effectiveLibraryVersion = glibDep.libraryVersion;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const packageJsonImport = this.createPackageJsonImport(importPath, effectiveLibraryVersion);
|
|
116
127
|
return {
|
|
117
128
|
importPath,
|
|
118
129
|
importDef,
|
|
@@ -135,8 +146,15 @@ export class DependencyManager {
|
|
|
135
146
|
: `import type ${namespace} from '${importPath}';`;
|
|
136
147
|
}
|
|
137
148
|
|
|
138
|
-
createPackageJsonImport(importPath: string): string {
|
|
139
|
-
|
|
149
|
+
createPackageJsonImport(importPath: string, libraryVersion?: LibraryVersion): string {
|
|
150
|
+
let depVersion: string;
|
|
151
|
+
if (this.config.workspace) {
|
|
152
|
+
depVersion = "workspace:^";
|
|
153
|
+
} else if (libraryVersion) {
|
|
154
|
+
depVersion = `${libraryVersion.toString()}-${APP_VERSION}`;
|
|
155
|
+
} else {
|
|
156
|
+
depVersion = APP_VERSION;
|
|
157
|
+
}
|
|
140
158
|
return `"${importPath}": "${depVersion}"`;
|
|
141
159
|
}
|
|
142
160
|
|
|
@@ -258,7 +276,7 @@ export class DependencyManager {
|
|
|
258
276
|
version,
|
|
259
277
|
libraryVersion,
|
|
260
278
|
girXML,
|
|
261
|
-
...this.createImportProperties(namespace, packageName, version),
|
|
279
|
+
...this.createImportProperties(namespace, packageName, version, libraryVersion),
|
|
262
280
|
};
|
|
263
281
|
|
|
264
282
|
// Special case for Cairo
|