@ts-for-gir/generator-json 4.0.0-rc.1 → 4.0.0-rc.3

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/generator-json",
3
- "version": "4.0.0-rc.1",
3
+ "version": "4.0.0-rc.3",
4
4
  "description": "JSON generator for ts-for-gir",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -36,17 +36,17 @@
36
36
  "json"
37
37
  ],
38
38
  "devDependencies": {
39
- "@ts-for-gir/tsconfig": "^4.0.0-rc.1",
39
+ "@ts-for-gir/tsconfig": "^4.0.0-rc.3",
40
40
  "@types/node": "^24.12.2",
41
41
  "typescript": "^6.0.2"
42
42
  },
43
43
  "dependencies": {
44
- "@gi.ts/parser": "^4.0.0-rc.1",
45
- "@ts-for-gir/generator-base": "^4.0.0-rc.1",
46
- "@ts-for-gir/generator-typescript": "^4.0.0-rc.1",
47
- "@ts-for-gir/gir-module-metadata": "^4.0.0-rc.1",
48
- "@ts-for-gir/lib": "^4.0.0-rc.1",
49
- "@ts-for-gir/reporter": "^4.0.0-rc.1",
44
+ "@gi.ts/parser": "^4.0.0-rc.3",
45
+ "@ts-for-gir/generator-base": "^4.0.0-rc.3",
46
+ "@ts-for-gir/generator-typescript": "^4.0.0-rc.3",
47
+ "@ts-for-gir/gir-module-metadata": "^4.0.0-rc.3",
48
+ "@ts-for-gir/lib": "^4.0.0-rc.3",
49
+ "@ts-for-gir/reporter": "^4.0.0-rc.3",
50
50
  "typedoc": "^0.28.18"
51
51
  }
52
52
  }
@@ -115,6 +115,8 @@ export interface GirNamespaceMetadata {
115
115
  description?: string;
116
116
  /** Logo/icon URL */
117
117
  logoUrl?: string;
118
+ /** Icon filename from refs/library-icons (e.g. "librsvg-r.svg") */
119
+ iconFile?: string;
118
120
  /** Project website URL */
119
121
  websiteUrl?: string;
120
122
  /** URL to upstream C API documentation */
@@ -128,6 +128,15 @@ export class TypeDocPipeline {
128
128
  result.project.packageVersion = module.libraryVersion.toString();
129
129
 
130
130
  this.registerGirMetadata(result.app, module);
131
+
132
+ // Attach metadata directly to module reflections for HTML rendering.
133
+ // registerGirMetadata only hooks into the serializer (for JSON export);
134
+ // the theme needs metadata on the reflections themselves.
135
+ const nsMeta = this.buildNamespaceMetadata(module);
136
+ for (const child of result.project.children ?? []) {
137
+ (child as unknown as { girNamespaceMetadata?: GirNamespaceMetadata }).girNamespaceMetadata ??= nsMeta;
138
+ }
139
+
131
140
  return result;
132
141
  }
133
142
 
@@ -215,6 +224,7 @@ export class TypeDocPipeline {
215
224
  [new TSConfigReader()],
216
225
  );
217
226
  this.fixExportImportReferences(result.project);
227
+ this.enrichModuleReflections(result.project);
218
228
  return result;
219
229
  }
220
230
 
@@ -271,7 +281,9 @@ export class TypeDocPipeline {
271
281
  ...existing,
272
282
  displayName: existing.displayName ?? meta.displayName,
273
283
  description: existing.description ?? meta.description,
274
- logoUrl: existing.logoUrl ?? meta.logoUrl,
284
+ logoUrl:
285
+ existing.logoUrl ?? meta.logoUrl ?? (meta.iconFile ? `assets/library-icons/${meta.iconFile}` : undefined),
286
+ iconFile: existing.iconFile ?? meta.iconFile,
275
287
  websiteUrl: existing.websiteUrl ?? meta.websiteUrl,
276
288
  cDocsUrl: existing.cDocsUrl ?? meta.cDocsUrl,
277
289
  license: existing.license ?? meta.license,
@@ -280,6 +292,33 @@ export class TypeDocPipeline {
280
292
  }
281
293
  }
282
294
 
295
+ /**
296
+ * Attach metadata to module reflections by matching against known GIR modules.
297
+ * Used in combined mode where modules are discovered via "packages" entry point strategy.
298
+ */
299
+ private enrichModuleReflections(project: ProjectReflection): void {
300
+ if (!project.children) return;
301
+
302
+ // Build lookup maps: by importName (e.g. "rsvg-2.0") and by packageName (e.g. "Rsvg-2.0")
303
+ const metaByImportName = new Map<string, GirNamespaceMetadata>();
304
+ for (const module of this.modules) {
305
+ metaByImportName.set(module.importName, this.buildNamespaceMetadata(module));
306
+ }
307
+
308
+ for (const child of project.children) {
309
+ const enriched = child as DeclarationReflection & { girNamespaceMetadata?: GirNamespaceMetadata };
310
+ if (enriched.girNamespaceMetadata?.category) continue;
311
+
312
+ // Module name may be scoped (e.g. "@girs/rsvg-2.0") — extract the importName part
313
+ const scopeMatch = child.name.match(/^@[^/]+\/(.+)$/);
314
+ const importName = scopeMatch ? scopeMatch[1] : child.name.toLowerCase();
315
+ const nsMeta = metaByImportName.get(importName);
316
+ if (nsMeta) {
317
+ enriched.girNamespaceMetadata ??= nsMeta;
318
+ }
319
+ }
320
+ }
321
+
283
322
  async cleanup(): Promise<void> {
284
323
  if (this.tempDir) {
285
324
  await rm(this.tempDir, { recursive: true, force: true });
@@ -672,7 +711,8 @@ export class TypeDocPipeline {
672
711
  packageVersion: pkgJson?.version,
673
712
  displayName: meta?.displayName,
674
713
  description: meta?.description ?? pkgJson?.description,
675
- logoUrl: meta?.logoUrl,
714
+ logoUrl: meta?.logoUrl ?? (meta?.iconFile ? `assets/library-icons/${meta.iconFile}` : undefined),
715
+ iconFile: meta?.iconFile,
676
716
  websiteUrl: meta?.websiteUrl ?? pkgJson?.homepage,
677
717
  cDocsUrl: meta?.cDocsUrl,
678
718
  license: meta?.license ?? pkgJson?.license,