@ts-for-gir/templates 4.0.0-beta.36 → 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 +77 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
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/templates" />
|
|
10
|
+
<img src="https://img.shields.io/npm/dw/@ts-for-gir/templates" />
|
|
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
|
+
# Templates
|
|
20
|
+
|
|
21
|
+
Template collection for `ts-for-gir`. This package contains EJS templates and static template files used by the TypeScript generator to produce TypeScript definition files and NPM packages from GIR data.
|
|
22
|
+
|
|
23
|
+
## Purpose
|
|
24
|
+
|
|
25
|
+
The templates package serves as the template repository for the `ts-for-gir` ecosystem, providing:
|
|
26
|
+
|
|
27
|
+
- **EJS Templates**: Dynamic templates for generating TypeScript declaration files (.d.ts)
|
|
28
|
+
- **Static Templates**: Pre-built type definitions for core GJS modules and runtime APIs
|
|
29
|
+
- **Package Templates**: Templates for generating NPM package.json files and documentation
|
|
30
|
+
- **GJS Runtime Types**: TypeScript definitions for GJS-specific APIs like console, system, gettext, and DOM
|
|
31
|
+
|
|
32
|
+
## Template Categories
|
|
33
|
+
|
|
34
|
+
### Core GIR Templates
|
|
35
|
+
- Module templates for generating TypeScript definitions from GIR data
|
|
36
|
+
- Ambient module declarations for `gi://` imports
|
|
37
|
+
- Import/export templates for different module formats
|
|
38
|
+
|
|
39
|
+
### GJS Runtime Templates
|
|
40
|
+
Located in `templates/gjs/`, these provide TypeScript definitions for:
|
|
41
|
+
- **Cairo**: 2D graphics library bindings
|
|
42
|
+
- **Console**: GJS console API with logging functions
|
|
43
|
+
- **DOM**: Basic DOM-like APIs for GJS
|
|
44
|
+
- **Gettext**: Internationalization support
|
|
45
|
+
- **System**: System-level utilities and information
|
|
46
|
+
|
|
47
|
+
### Library-Specific Templates
|
|
48
|
+
Pre-built templates for common libraries with special handling:
|
|
49
|
+
- GLib, GObject, Gio core libraries
|
|
50
|
+
- Cogl, Granite, GStreamer bindings
|
|
51
|
+
- Custom overrides for complex type mappings
|
|
52
|
+
|
|
53
|
+
### Package Generation Templates
|
|
54
|
+
- NPM package.json generation
|
|
55
|
+
- README.md templates for generated packages
|
|
56
|
+
- TypeScript configuration files
|
|
57
|
+
- Documentation generation templates
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
This package is used internally by `@ts-for-gir/generator-typescript` and is not intended for direct use by end users. The templates are automatically loaded and processed during the type generation process.
|
|
62
|
+
|
|
63
|
+
The template processor uses EJS to render dynamic content, allowing for:
|
|
64
|
+
- Conditional template sections
|
|
65
|
+
- Variable substitution
|
|
66
|
+
- Loop-based code generation
|
|
67
|
+
- Template inheritance and includes
|
|
68
|
+
|
|
69
|
+
## Template Structure
|
|
70
|
+
|
|
71
|
+
Templates follow a consistent structure with:
|
|
72
|
+
- **prepend**: Content added before generated code
|
|
73
|
+
- **append**: Content added after generated code
|
|
74
|
+
- **Variables**: Dynamic data injected during processing
|
|
75
|
+
- **Conditionals**: Logic for handling different generation scenarios
|
|
76
|
+
|
|
77
|
+
This package ensures consistent output formatting and provides a centralized location for all template-related assets in the ts-for-gir toolchain.
|