@ts-for-gir/generator-typescript 4.0.0-beta.25 → 4.0.0-beta.26

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.
Files changed (71) hide show
  1. package/package.json +12 -27
  2. package/src/index.ts +4 -0
  3. package/src/module-generator-example.ts +68 -0
  4. package/src/module-generator.ts +1981 -0
  5. package/src/npm-package.ts +115 -0
  6. package/src/overrides/glib.ts +13 -0
  7. package/src/overrides/gobject.ts +52 -0
  8. package/src/template-processor.ts +216 -0
  9. package/src/type-definition-generator.ts +165 -0
  10. package/src/utils.ts +7 -0
  11. package/lib/index.d.ts +0 -3
  12. package/lib/index.js +0 -4
  13. package/lib/index.js.map +0 -1
  14. package/lib/module-generator.d.ts +0 -143
  15. package/lib/module-generator.js +0 -1320
  16. package/lib/module-generator.js.map +0 -1
  17. package/lib/npm-package.d.ts +0 -15
  18. package/lib/npm-package.js +0 -76
  19. package/lib/npm-package.js.map +0 -1
  20. package/lib/package-data-parser.d.ts +0 -13
  21. package/lib/package-data-parser.js +0 -67
  22. package/lib/package-data-parser.js.map +0 -1
  23. package/lib/template-processor.d.ts +0 -108
  24. package/lib/template-processor.js +0 -259
  25. package/lib/template-processor.js.map +0 -1
  26. package/lib/type-definition-generator.d.ts +0 -20
  27. package/lib/type-definition-generator.js +0 -106
  28. package/lib/type-definition-generator.js.map +0 -1
  29. package/lib/utils.d.ts +0 -1
  30. package/lib/utils.js +0 -7
  31. package/lib/utils.js.map +0 -1
  32. package/packages.xml +0 -1213
  33. package/templates/README-GJS.md +0 -133
  34. package/templates/README.md +0 -92
  35. package/templates/cogl-2-0.d.ts +0 -1
  36. package/templates/gi.d.ts +0 -8
  37. package/templates/gimp-3.0.d.ts +0 -24
  38. package/templates/gio-2.0.d.ts +0 -37
  39. package/templates/gjs/cairo-1.0.d.ts +0 -0
  40. package/templates/gjs/cairo.d.ts +0 -855
  41. package/templates/gjs/cairo.js +0 -4
  42. package/templates/gjs/console.d.ts +0 -30
  43. package/templates/gjs/console.js +0 -4
  44. package/templates/gjs/dom.d.ts +0 -312
  45. package/templates/gjs/dom.js +0 -1
  46. package/templates/gjs/gettext.d.ts +0 -48
  47. package/templates/gjs/gettext.js +0 -4
  48. package/templates/gjs/gjs-ambient.d.ts +0 -26
  49. package/templates/gjs/gjs-ambient.js +0 -1
  50. package/templates/gjs/gjs.d.ts +0 -753
  51. package/templates/gjs/gjs.js +0 -4
  52. package/templates/gjs/system.d.ts +0 -187
  53. package/templates/gjs/system.js +0 -4
  54. package/templates/gobject-2.0.d.ts +0 -253
  55. package/templates/granite-1.0.d.ts +0 -8
  56. package/templates/granite-7.0.d.ts +0 -8
  57. package/templates/gstbase-0.10.d.ts +0 -6
  58. package/templates/index-locally.d.ts +0 -8
  59. package/templates/index.d.ts +0 -17
  60. package/templates/index.js +0 -4
  61. package/templates/module-ambient.d.ts +0 -18
  62. package/templates/module-ambient.js +0 -1
  63. package/templates/module-import.d.ts +0 -16
  64. package/templates/module-import.js +0 -2
  65. package/templates/module.append.d.ts +0 -17
  66. package/templates/module.d.ts +0 -53
  67. package/templates/module.js +0 -4
  68. package/templates/package.json +0 -95
  69. package/templates/rygelserver-2.6.d.ts +0 -4
  70. package/templates/tsconfig.json +0 -32
  71. package/templates/typedoc.json +0 -26
package/package.json CHANGED
@@ -1,26 +1,18 @@
1
1
  {
2
2
  "name": "@ts-for-gir/generator-typescript",
3
- "version": "4.0.0-beta.25",
3
+ "version": "4.0.0-beta.26",
4
4
  "description": "TypeScript type definition generator for ts-for-gir",
5
- "module": "lib/index.js",
6
- "main": "lib/index.js",
5
+ "main": "src/index.ts",
6
+ "module": "src/index.ts",
7
7
  "type": "module",
8
8
  "engines": {
9
9
  "node": ">=18"
10
10
  },
11
11
  "exports": {
12
- ".": {
13
- "types": "./lib/index.d.ts",
14
- "import": "./lib/index.js"
15
- }
12
+ ".": "./src/index.ts"
16
13
  },
17
14
  "scripts": {
18
- "build": "yarn lint && yarn build:ts",
19
- "build:ts": "tsc",
20
- "clear": "yarn clear:build",
21
- "clear:build": "rimraf ./lib",
22
- "watch": "yarn build:ts --watch",
23
- "lint": "eslint . --fix"
15
+ "check": "tsc --noEmit"
24
16
  },
25
17
  "repository": {
26
18
  "type": "git",
@@ -28,9 +20,7 @@
28
20
  },
29
21
  "author": "Pascal Garber <pascal@artandcode.studio>",
30
22
  "files": [
31
- "lib",
32
- "templates",
33
- "packages.xml"
23
+ "src"
34
24
  ],
35
25
  "license": "Apache-2.0",
36
26
  "bugs": {
@@ -42,20 +32,15 @@
42
32
  ],
43
33
  "devDependencies": {
44
34
  "@types/ejs": "^3.1.5",
45
- "@types/node": "^24.0.1",
35
+ "@types/node": "^24.2.1",
46
36
  "@types/xml2js": "^0.4.14",
47
- "@typescript-eslint/eslint-plugin": "^8.34.0",
48
- "@typescript-eslint/parser": "^8.34.0",
49
- "eslint": "^9.29.0",
50
- "eslint-config-prettier": "^10.1.5",
51
- "eslint-plugin-prettier": "^5.4.1",
52
- "prettier": "^3.5.3",
53
- "rimraf": "^6.0.1",
54
- "typescript": "^5.8.3"
37
+ "typescript": "^5.9.2"
55
38
  },
56
39
  "dependencies": {
57
- "@ts-for-gir/generator-base": "^4.0.0-beta.25",
58
- "@ts-for-gir/lib": "^4.0.0-beta.25",
40
+ "@gi.ts/parser": "^4.0.0-beta.26",
41
+ "@ts-for-gir/generator-base": "^4.0.0-beta.26",
42
+ "@ts-for-gir/lib": "^4.0.0-beta.26",
43
+ "@ts-for-gir/templates": "^4.0.0-beta.26",
59
44
  "ejs": "^3.1.10",
60
45
  "xml2js": "^0.6.2"
61
46
  }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { ModuleGenerator, ModuleGeneratorFormat } from "./module-generator.ts";
2
+ export { NpmPackage } from "./npm-package.ts";
3
+ export { TemplateProcessor } from "./template-processor.ts";
4
+ export { TypeDefinitionGenerator } from "./type-definition-generator.ts";
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Example usage of the refactored ModuleGenerator
3
+ *
4
+ * This demonstrates how the unified ModuleGenerator now incorporates
5
+ * functionality from DtsGenerator and DtsModuleGenerator
6
+ */
7
+
8
+ import type { GirModule, NSRegistry, OptionsGeneration } from "@ts-for-gir/lib";
9
+ import { ModuleGenerator } from "./module-generator.ts";
10
+
11
+ // Example: Using ModuleGenerator with different output formats
12
+ async function generateTypeDefinitions(girModule: GirModule, config: OptionsGeneration, registry: NSRegistry) {
13
+ // Create a ModuleGenerator instance
14
+ const generator = new ModuleGenerator(girModule, config, registry);
15
+
16
+ // 1. Generate as string array (default behavior)
17
+ const arrayOutput = await generator.generateModule(girModule);
18
+ console.log("String array output:", arrayOutput);
19
+
20
+ // 2. Generate as single string (DtsGenerator compatibility)
21
+ const stringOutput = await generator.generateModuleString(girModule);
22
+ console.log("String output:", stringOutput);
23
+
24
+ // 3. Generate as module declaration (DtsModuleGenerator compatibility)
25
+ const moduleDeclaration = await generator.generateModuleDeclaration(girModule);
26
+ console.log("Module declaration output:", moduleDeclaration);
27
+
28
+ // 4. Generate namespace as string
29
+ const namespaceString = await generator.generateNamespaceAsString(girModule);
30
+ console.log("Namespace string output:", namespaceString);
31
+
32
+ // 5. The AdvancedVariants feature is automatically applied
33
+ // when generating GLib or GObject modules (unless disabled with noAdvancedVariants option)
34
+ if (girModule.namespace === "GLib" && !config.noAdvancedVariants) {
35
+ console.log("GLib module will include advanced variant type definitions");
36
+ }
37
+ if (girModule.namespace === "GObject") {
38
+ console.log("GObject module will include registerClass overrides");
39
+ }
40
+ }
41
+
42
+ // Example: Migrating from DtsGenerator
43
+ function migrateFromDtsGenerator(girModule: GirModule, config: OptionsGeneration, registry: NSRegistry) {
44
+ // Before (using DtsGenerator):
45
+ // const generator = new DtsGenerator(girModule, config);
46
+ // const output = await generator.generateNamespace(girModule);
47
+
48
+ // After (using ModuleGenerator):
49
+ const generator = new ModuleGenerator(girModule, config, registry);
50
+ const output = generator.generateNamespaceAsString(girModule);
51
+
52
+ return output;
53
+ }
54
+
55
+ // Example: Migrating from DtsModuleGenerator
56
+ function migrateFromDtsModuleGenerator(girModule: GirModule, config: OptionsGeneration, registry: NSRegistry) {
57
+ // Before (using DtsModuleGenerator):
58
+ // const generator = new DtsModuleGenerator(girModule, config);
59
+ // const output = await generator.generateNamespace(girModule);
60
+
61
+ // After (using ModuleGenerator):
62
+ const generator = new ModuleGenerator(girModule, config, registry);
63
+ const output = generator.generateModuleDeclaration(girModule);
64
+
65
+ return output;
66
+ }
67
+
68
+ export { generateTypeDefinitions, migrateFromDtsGenerator, migrateFromDtsModuleGenerator };