@ts-for-gir/lib 4.0.0-rc.4 → 4.0.0-rc.6
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/lib",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.6",
|
|
4
4
|
"description": "Typescript .d.ts generator from GIR for gjs",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"type definitions"
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@ts-for-gir/tsconfig": "^4.0.0-rc.
|
|
44
|
+
"@ts-for-gir/tsconfig": "^4.0.0-rc.6",
|
|
45
45
|
"@types/ejs": "^3.1.5",
|
|
46
46
|
"@types/lodash": "^4.17.24",
|
|
47
|
-
"@types/node": "^
|
|
47
|
+
"@types/node": "^25.6.0",
|
|
48
48
|
"rimraf": "^6.1.3",
|
|
49
|
-
"typescript": "^6.0.
|
|
49
|
+
"typescript": "^6.0.3"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@gi.ts/parser": "^4.0.0-rc.
|
|
53
|
-
"@ts-for-gir/reporter": "^4.0.0-rc.
|
|
54
|
-
"@ts-for-gir/templates": "^4.0.0-rc.
|
|
52
|
+
"@gi.ts/parser": "^4.0.0-rc.6",
|
|
53
|
+
"@ts-for-gir/reporter": "^4.0.0-rc.6",
|
|
54
|
+
"@ts-for-gir/templates": "^4.0.0-rc.6",
|
|
55
55
|
"colorette": "^2.0.20",
|
|
56
|
-
"ejs": "^5.0.
|
|
56
|
+
"ejs": "^5.0.2",
|
|
57
57
|
"glob": "^13.0.6",
|
|
58
58
|
"lodash": "4.18.1"
|
|
59
59
|
}
|
|
@@ -132,6 +132,15 @@ export class DependencyManager {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
createImportPath(packageName: string, namespace: string, version: string): string {
|
|
135
|
+
// In external-deps mode every dep import is resolved against an installed npm package
|
|
136
|
+
// (e.g. `@girs/glib-2.0`), regardless of `package` mode. User-supplied overrides win
|
|
137
|
+
// for namespaces with non-default scopes/versions (e.g. `Soup → @girs/soup-3.0`).
|
|
138
|
+
if (this.config.externalDeps) {
|
|
139
|
+
const override = this.config.externalPackages?.[namespace];
|
|
140
|
+
if (override) return override;
|
|
141
|
+
const importName = transformImportName(packageName);
|
|
142
|
+
return `${this.config.npmScope}/${importName}`;
|
|
143
|
+
}
|
|
135
144
|
if (!this.config.package) {
|
|
136
145
|
return `gi://${namespace}?version=${version}`;
|
|
137
146
|
}
|
package/src/gir/registry.ts
CHANGED
|
@@ -103,13 +103,17 @@ export class NSRegistry {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
transform(options: OptionsTransform) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
// In tolerant external-deps mode (with --allow-missing-deps) the core namespaces
|
|
107
|
+
// may not be loaded. Sync their package_version only when actually present;
|
|
108
|
+
// generify/inject still run on whatever IS loaded (other modules' transformations
|
|
109
|
+
// don't depend on GLib being in the registry).
|
|
110
|
+
const GLib = this.namespace("GLib", "2.0");
|
|
111
|
+
const Gio = this.namespace("Gio", "2.0");
|
|
112
|
+
const GObject = this.namespace("GObject", "2.0");
|
|
109
113
|
|
|
110
114
|
// These follow the GLib version.
|
|
111
|
-
Gio.package_version = [...GLib.package_version];
|
|
112
|
-
GObject.package_version = [...GLib.package_version];
|
|
115
|
+
if (GLib && Gio) Gio.package_version = [...GLib.package_version];
|
|
116
|
+
if (GLib && GObject) GObject.package_version = [...GLib.package_version];
|
|
113
117
|
|
|
114
118
|
const interfaceVisitor = new InterfaceVisitor();
|
|
115
119
|
|
|
@@ -119,11 +123,13 @@ export class NSRegistry {
|
|
|
119
123
|
|
|
120
124
|
this.registerTransformation(classVisitor);
|
|
121
125
|
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
if (GLib && Gio) {
|
|
127
|
+
console.log("Adding generics...");
|
|
128
|
+
generify(this, options.inferGenerics);
|
|
124
129
|
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
console.log("Injecting types...");
|
|
131
|
+
inject(this);
|
|
132
|
+
}
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
defaultVersionOf(name: string): string | null {
|
|
@@ -64,4 +64,25 @@ export interface OptionsGeneration extends OptionsBase {
|
|
|
64
64
|
merge?: boolean;
|
|
65
65
|
/** Directory containing pre-generated TypeDoc JSON files for merge mode (from 'ts-for-gir json') */
|
|
66
66
|
jsonDir?: string;
|
|
67
|
+
/**
|
|
68
|
+
* External-deps mode: emit `import` statements that reference dependency types from
|
|
69
|
+
* already-installed npm packages (e.g. `@girs/glib-2.0`) instead of regenerating them.
|
|
70
|
+
* Designed for project-local GIRs (Vala bridges etc.) where the surrounding `@girs/*`
|
|
71
|
+
* ecosystem is already in node_modules. No GJS supporting files, no index aggregator.
|
|
72
|
+
*/
|
|
73
|
+
externalDeps: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* In `externalDeps` mode, allow generation to proceed even when some transitive dep GIRs
|
|
76
|
+
* cannot be found. Default is strict: missing deps abort the run, since divergent dep
|
|
77
|
+
* availability between environments (dev with -devel packages vs CI without) would
|
|
78
|
+
* silently produce inconsistent generated `.d.ts` output.
|
|
79
|
+
*/
|
|
80
|
+
allowMissingDeps: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Override the default `<npmScope>/<importName>` mapping for individual namespaces when
|
|
83
|
+
* resolving external dependency imports in `externalDeps` mode.
|
|
84
|
+
*
|
|
85
|
+
* Example: `{ Soup: '@girs/soup-3.0', GLib: '@girs/glib-2.0' }`
|
|
86
|
+
*/
|
|
87
|
+
externalPackages?: Record<string, string>;
|
|
67
88
|
}
|
package/src/types/user-config.ts
CHANGED
|
@@ -77,4 +77,24 @@ export interface UserConfig {
|
|
|
77
77
|
merge?: boolean;
|
|
78
78
|
/** Directory containing pre-generated TypeDoc JSON files for merge mode (from 'ts-for-gir json') */
|
|
79
79
|
jsonDir?: string;
|
|
80
|
+
/**
|
|
81
|
+
* External-deps mode: emit `import` statements that reference dependency types from
|
|
82
|
+
* already-installed npm packages (e.g. `@girs/glib-2.0`) instead of regenerating them.
|
|
83
|
+
* Designed for project-local GIRs (Vala bridges etc.) where the surrounding `@girs/*`
|
|
84
|
+
* ecosystem is already in node_modules.
|
|
85
|
+
*/
|
|
86
|
+
externalDeps: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Allow `externalDeps` generation to proceed when some transitive dep GIRs are missing.
|
|
89
|
+
* Default is strict: missing deps cause an error to prevent silent type-quality drift
|
|
90
|
+
* between environments with and without system GIR -devel packages installed.
|
|
91
|
+
*/
|
|
92
|
+
allowMissingDeps: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Override the default `<npmScope>/<importName>` mapping for individual namespaces when
|
|
95
|
+
* resolving external dependency imports in `externalDeps` mode.
|
|
96
|
+
*
|
|
97
|
+
* Example: `{ Soup: '@girs/soup-3.0', GLib: '@girs/glib-2.0' }`
|
|
98
|
+
*/
|
|
99
|
+
externalPackages?: Record<string, string>;
|
|
80
100
|
}
|