@ts-for-gir/generator-json 4.0.0-beta.35 → 4.0.0-beta.37
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 +103 -0
- package/package.json +6 -6
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/gjsify/ts-for-gir/main/.github/ts-for-gir.png" />
|
|
3
|
+
<h1 align="center">TS <small>for</small> GIR</h1>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
<img src="https://img.shields.io/github/actions/workflow/status/gjsify/ts-for-gir/ci.yml" />
|
|
8
|
+
<img src="https://img.shields.io/github/license/gjsify/ts-for-gir" />
|
|
9
|
+
<img src="https://img.shields.io/npm/v/@ts-for-gir/generator-json" />
|
|
10
|
+
<img src="https://img.shields.io/npm/dw/@ts-for-gir/generator-json" />
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">TypeScript type definition generator for GObject introspection GIR files</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<img src="https://raw.githubusercontent.com/gjsify/ts-for-gir/main/.github/feeling.gif" />
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
# JSON Generator
|
|
20
|
+
|
|
21
|
+
JSON output generator for `ts-for-gir`. This package provides an alternative output format that serializes the processed GIR data into structured JSON instead of TypeScript definitions.
|
|
22
|
+
|
|
23
|
+
## Purpose
|
|
24
|
+
|
|
25
|
+
The JSON generator serves as an alternative output format for the `ts-for-gir` toolchain, enabling:
|
|
26
|
+
|
|
27
|
+
- **Data Export**: Export processed GIR data in a structured, machine-readable format
|
|
28
|
+
- **Analysis Tools**: Provide input for external analysis and processing tools
|
|
29
|
+
- **Documentation**: Generate structured documentation data from GIR files
|
|
30
|
+
- **Integration**: Enable integration with other tools and languages beyond TypeScript
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- **Complete Type Serialization**: Converts all TypeScript type expressions to JSON format
|
|
35
|
+
- **Structured Output**: Organizes data into logical categories (classes, interfaces, functions, etc.)
|
|
36
|
+
- **Metadata Preservation**: Maintains documentation, deprecation info, and other metadata
|
|
37
|
+
- **Type System Mapping**: Maps complex TypeScript types to JSON representations
|
|
38
|
+
|
|
39
|
+
## JSON Structure
|
|
40
|
+
|
|
41
|
+
The generator produces JSON with the following structure:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"kind": "namespace",
|
|
46
|
+
"name": "ModuleName",
|
|
47
|
+
"version": "1.0",
|
|
48
|
+
"imports": {},
|
|
49
|
+
"classes": [...],
|
|
50
|
+
"interfaces": [...],
|
|
51
|
+
"functions": [...],
|
|
52
|
+
"enums": [...],
|
|
53
|
+
"constants": [...],
|
|
54
|
+
"records": [...],
|
|
55
|
+
"callbacks": [...],
|
|
56
|
+
"errors": [...]
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Type Representations
|
|
61
|
+
|
|
62
|
+
Types are serialized with a consistent structure:
|
|
63
|
+
|
|
64
|
+
- **Identifiers**: `{ "kind": "identifier", "namespace": "...", "name": "..." }`
|
|
65
|
+
- **Arrays**: `{ "kind": "array", "type": {...}, "depth": 1 }`
|
|
66
|
+
- **Unions**: `{ "kind": "or", "types": [...] }`
|
|
67
|
+
- **Tuples**: `{ "kind": "tuple", "types": [...] }`
|
|
68
|
+
- **Nullable**: `{ "kind": "null", "type": {...} }`
|
|
69
|
+
- **Native**: `{ "kind": "native", "type": "string" }`
|
|
70
|
+
|
|
71
|
+
## Node Types
|
|
72
|
+
|
|
73
|
+
Each element includes metadata:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"kind": "class|interface|function|...",
|
|
78
|
+
"name": "ElementName",
|
|
79
|
+
"doc": "Documentation string",
|
|
80
|
+
"metadata": {...},
|
|
81
|
+
"private": false,
|
|
82
|
+
...
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Usage
|
|
87
|
+
|
|
88
|
+
This package is used internally by the ts-for-gir CLI when JSON output is requested. It implements the standard Generator interface defined in `@ts-for-gir/generator-base`.
|
|
89
|
+
|
|
90
|
+
The JSON output can be useful for:
|
|
91
|
+
- Building documentation websites
|
|
92
|
+
- Creating API analysis tools
|
|
93
|
+
- Generating bindings for other languages
|
|
94
|
+
- Data processing and transformation pipelines
|
|
95
|
+
- IDE integration and tooling
|
|
96
|
+
|
|
97
|
+
## Integration
|
|
98
|
+
|
|
99
|
+
The JSON generator integrates with the ts-for-gir ecosystem through:
|
|
100
|
+
- **Reporter System**: Comprehensive logging and error reporting
|
|
101
|
+
- **Generator Interface**: Standard lifecycle methods (start, generate, finish)
|
|
102
|
+
- **Type System**: Full compatibility with ts-for-gir type representations
|
|
103
|
+
- **Configuration**: Respects all standard ts-for-gir options and settings
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/generator-json",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.37",
|
|
4
4
|
"description": "JSON generator for ts-for-gir",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"json"
|
|
37
37
|
],
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^24.2
|
|
39
|
+
"@types/node": "^24.5.2",
|
|
40
40
|
"typescript": "^5.9.2"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@gi.ts/parser": "^4.0.0-beta.
|
|
44
|
-
"@ts-for-gir/generator-base": "^4.0.0-beta.
|
|
45
|
-
"@ts-for-gir/lib": "^4.0.0-beta.
|
|
46
|
-
"@ts-for-gir/reporter": "^4.0.0-beta.
|
|
43
|
+
"@gi.ts/parser": "^4.0.0-beta.37",
|
|
44
|
+
"@ts-for-gir/generator-base": "^4.0.0-beta.37",
|
|
45
|
+
"@ts-for-gir/lib": "^4.0.0-beta.37",
|
|
46
|
+
"@ts-for-gir/reporter": "^4.0.0-beta.37"
|
|
47
47
|
}
|
|
48
48
|
}
|