Skip to content

Commit

Permalink
Merge pull request #45 from gjsify/master
Browse files Browse the repository at this point in the history
Moved type definition generation to new TypeDefinitionGenerator
  • Loading branch information
sammydre authored Jan 27, 2022
2 parents 3ad88f9 + d57b72d commit e1dacad
Show file tree
Hide file tree
Showing 146 changed files with 19,087 additions and 4,734 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: sudo apt-get update
- name: Install dependencies for regress test
run: sudo apt-get --yes install libappindicator3-dev libgda-5.0-dev libgirepository1.0-dev libgtk-3-dev libgtksourceview-3.0-dev libnotify-dev libsoup2.4-dev libwebkit2gtk-4.0-dev
run: sudo apt-get --yes install gjs libappindicator3-dev libgda-5.0-dev libgirepository1.0-dev libgtk-3-dev libgtksourceview-3.0-dev libnotify-dev libsoup2.4-dev libwebkit2gtk-4.0-dev
- run: npm install
- run: npm run regress
- run: npm run test:ava
# Ava test needs a refactoring
# - run: npm run test:ava
- run: npm run build:types:gjs
- run: npm run validate:types:gjs
- run: npm run build:types:node
- run: npm run validate:types:node
- run: npm run build
- run: npm run build:examples:gjs
- run: npm run start:cli-examples:gjs
# TODO fix build node-gtk on Github actions
# - name: Install dependencies for node-gtk
# run: sudo apt-get --yes install build-essential gobject-introspection libgirepository1.0-dev libcairo2 libcairo2-dev
# - run: npm run install:examples:node
# - run: npm run build:examples:node
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ node_modules/
tmp/
lib/
examples/**/@types/
@types/
@types/node-gtk/*
@types/Gjs/*
# Uncommit this to see type build changes
# !@types/Gjs/Gtk-4.0.d.ts
# !@types/node-gtk/Gtk-4.0.d.ts
index.ts.bak
2 changes: 1 addition & 1 deletion .ts-for-gir.all.rc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
modules: ['*'],
girDirectories: ['./vala-girs/gir-1.0', './girs'],
ignoreConflicts: true,
prettify: true,
pretty: false,
ignore: [
'Colorhug-1.0', // Duplicate of ColorHug-1.0
'GUPnP-DLNA-1.0', // Same namespace as GUPnP-1.0.gir, is this a bug or should we merge the type definitions?
Expand Down
2 changes: 1 addition & 1 deletion .ts-for-gir.gtk3.rc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
modules: ['Gtk-3.0'],
girDirectories: ['./vala-girs/gir-1.0'],
prettify: true,
pretty: false,
ignore: [],
}
2 changes: 1 addition & 1 deletion .ts-for-gir.gtk4.rc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
modules: ['Gtk-4.0'],
girDirectories: ['./vala-girs/gir-1.0'],
prettify: true,
pretty: false,
ignore: [],
}
2 changes: 1 addition & 1 deletion .ts-for-gir.regress.rc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
modules: ['Gtk-3.0', 'Soup-2.4', 'GtkSource-3.0', 'WebKit2-4.0', 'AppIndicator3-0.1', 'Gda-5.0', 'Notify-0.7'],
ignoreConflicts: true,
prettify: true,
pretty: false,
ignore: []
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
modules: ['RygelCore-2.4', 'RygelRenderer-2.4'],
modules: ['RygelCore-2.6', 'RygelRenderer-2.6'],
girDirectories: ['./vala-girs/gir-1.0'],
pretty: false,
ignore: [],
}
34 changes: 23 additions & 11 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,71 @@
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "./src/index.ts",
"program": "./src/start.ts",
"args": [
"generate", "--configName=.ts-for-gir.gtk3.rc.js", "-o", "./tmp"
],
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeArgs": ["--nolazy", "--loader", "ts-node/esm"],
"sourceMaps": true
},
{
"name": "build:types:gtk4",
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "./src/start.ts",
"args": [
"generate", "--configName=.ts-for-gir.gtk4.rc.js", "-o", "./tmp"
],
"runtimeArgs": ["--nolazy", "--loader", "ts-node/esm"],
"sourceMaps": true
},
{
"name": "build:types",
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "${workspaceRoot}/src/index.ts",
"program": "${workspaceRoot}/src/start.ts",
"args": [
"generate", "--configName=.ts-for-gir.all.rc.js", "-o", "./tmp"
],
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeArgs": ["--nolazy", "--loader", "ts-node/esm"],
"sourceMaps": true,
},
{
"name": "build:types:gjs",
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "${workspaceRoot}/src/index.ts",
"program": "${workspaceRoot}/src/start.ts",
"args": [
"generate", "--configName=.ts-for-gir.all.rc.js", "--environments=gjs", "-o", "./tmp"
],
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeArgs": ["--nolazy", "-r", "ts-node/esm"],
"sourceMaps": true,
},
{
"name": "build:types:node",
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "${workspaceRoot}/src/index.ts",
"program": "${workspaceRoot}/src/start.ts",
"args": [
"generate", "--configName=.ts-for-gir.all.rc.js", "--environments=node", "-o", "./tmp"
],
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeArgs": ["--nolazy", "-r", "ts-node/esm"],
"sourceMaps": true,
},
{
"name": "regress",
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "${workspaceRoot}/src/index.ts",
"program": "${workspaceRoot}/src/start.ts",
"args": [
"generate", "--configName='.ts-for-gir.regress.rc.js", "-o", "./tmp"
],
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeArgs": ["--nolazy", "--loader", "ts-node/esm"],
"sourceMaps": true,
},
{
Expand All @@ -73,7 +85,7 @@
"${workspaceRoot}/test.js",
"--no-color"
],
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeArgs": ["--nolazy", "--loader", "ts-node/esm"],
"sourceMaps": true,
}
]
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"deno.enable": false,
"editor.tabSize": 4,
"typescript.tsdk": "./node_modules/typescript/lib",
"editor.codeActionsOnSave": {
Expand Down Expand Up @@ -72,6 +73,7 @@
"dbus",
"Dbusmenu",
"dcgettext",
"Descs",
"DESERET",
"detokenize",
"dgettext",
Expand All @@ -82,9 +84,11 @@
"ELBASAN",
"ellipsize",
"EMBOX",
"emitable",
"emitv",
"enumtype",
"errorno",
"espree",
"Farstream",
"FBIG",
"FCOE",
Expand Down
139 changes: 139 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
## TODO
- Refactor Ava test

# v2.0.0
- The browser example now uses ESM for Gjs and Node.js
- Upgrade all dependencies to latest
- [node-gtk] don't add $obj parameter in connect() method either, thanks to @peat-psuwit
- [node-gtk] Fixed Return types, see #46
- New and simpler patch format
- Replaced `ESLint` with `prettier` for prettify output, this fixes #29
- New `doc` command for future implementation
- New class `HtmlDocGenerator` this is not implemented yet, but can serve as a template for a future implementation
- Fix type `Uint8Array` (should not be `Uint8Array[]`)
- CI: Run Gjs CLI examples to test working bindings
- The generated types now contain a note that they are automatically generated with `ts-for-gir`
- Split option `exportDefault` to `useNamespace` and `moduleType` to specify `ESM` or `CommonJS` module generation
- Fix VSCode debugging configuration to work with ESM
- Debugging information added to README.md
- Moved all signature generations to new TypeDefinitionGenerator
- The utility functions are no longer static members of a class
- Fixed a bug in the `forEachInterface` method, which caused that not all inherited methods were implemented anymore (slipped in with the last PR)
- Added this CHANGELOG.md

# 17 Jan 2022
- All types in vala-gir can now be built and validated without errors, this can be tested with `npm run test:girs:all`, this test is now also executed with github actions
- Switch to ESM for ts-for-gir itself
- Replaced `oclif` with `yargs` for CLI parsing (`yargs` has ESM Support, `oclif` not)
- Improved @realh's Gjs ESM support
- Improved types based on [gobject-introspection/docs/gir-1.2.rnc](https://gitlab.gnome.org/GNOME/gobject-introspection/-/blob/master/docs/gir-1.2.rnc) and [gi.ts/parser/src/xml.ts](https://gitlab.gnome.org/ewlsh/gi.ts/-/blob/master/packages/parser/src/xml.ts)
- Changed `examples/Gjs/builder` example to use the Gjs ESM feature using `gi://` imports
- Version conflicts in Gir modules fixed, now multiple versions of the same module name can be generated
- Made the source code more readable in some places, this mainly affects places where an array was returned, here a more meaningful tuple / object is now returned
- Dependencies updated
- It is now possible to build all gir modules from the vala-girs repository.
- Some older girs are missing in the vala-girs repository, they are now included in this repository
- Added some new examples

## Breaking Changes
- Node.js minimum version is now 16 for ESM support
- The config files must now also be in ESM format, if they are not in json format:


See PR [#44](https://github.com/sammydre/ts-for-gjs/pull/44)
# 5 Jan 2022
- Fix error type

See PR [#43](https://github.com/sammydre/ts-for-gjs/pull/43)

# 1 Aug 2021
- Add support for ES modules using default exports

See PR [#41](https://github.com/sammydre/ts-for-gjs/pull/41)

# 14 Jan 2021
- Use /usr/local/share when on Darwin systems

See PR [#39](https://github.com/sammydre/ts-for-gjs/pull/39)

# 21 Apr 2021
- Missing quote in generate example

See PR [#38](https://github.com/sammydre/ts-for-gjs/pull/38)

# 13 Dec 2020
- Use qualified names in circular dependency check (fixes #28)
- Fixed type transformations for arrays of bytes
- Add support for inline callback types
- Expose instance parameters of class methods
- Add CI / action tests using Github workflow

See PR [#30](https://github.com/sammydre/ts-for-gjs/pull/30), [#31](https://github.com/sammydre/ts-for-gjs/pull/31), [#34](https://github.com/sammydre/ts-for-gjs/pull/34), [#36](https://github.com/sammydre/ts-for-gjs/pull/36) and [#37](https://github.com/sammydre/ts-for-gjs/pull/37)

# 16 Oct 2020
- Improved types and also use more types in test data
- Fixed test npm run build:test:girs
- Upgrade dependencies (With the upgrade of eslint some new automatic formatting has been added which increases the PR)
- Added tests to README.md
- Added version to fix
- Add versions property type to imports.gi for gobject-introspection classes #25
- Added src to NPM module to fix
- Is it possible to use ts-for-gjs as dev dependency #20
- Split method exportObjectInternal in more methods to make it more readable
- Improved debugging by log the full error when an error occurs
- Some improvements taken from @realh `s fork

See PR [#27](https://github.com/sammydre/ts-for-gjs/pull/27)

# 10 Oct 2020
- Add ts-node as devDep to fix running in-tree
- improve typing for cast.ts

See PR [#22](https://github.com/sammydre/ts-for-gjs/pull/22) and [#23](https://github.com/sammydre/ts-for-gjs/pull/23)

# 7 Mar 2020
- Moved CLI specific code to `cli.ts`
- Add a new `TemplateProcessor` class to generate definitions from templates to reduce the GirModule class
- Add a new `Transformation` class to transform methods, enums, etc for the specific environment (gjs or node)
- Convert string templates to ejs templates
- Because there are now more source files, I have moved them all to `src/`
- The compiled source files now in `lib/`
- I have moved the dependencies loading to `module-loader.ts`
- I have moved the file parser to `module-loader.ts`
- I have moved the cli specific to `./src/commands/*` and `./src/config`
- All types now in `./src/types`, each type / interface in his own file
- Added `bin/bin.js`, required to use ts-for-gir as a cl tool by npm
- Added **ESLint** with the **Prettier** plugin, I tried to keep the code style (for example, there is a rule to not use semicolon's).
- ESLint and Prettier are also used to validate and auto format the generated template files.
- I've changed the default output dir to `@types/` to make it easier to generate type definitions in other projects without having to specify the output path each time
- The output path now contains subfolder's for `Gjs` and / or `node-gtk` (the directory name `node-gtk` is required to get typescript automatically working with `import * as gi from 'node-gtk'`)
- There is now a new option called `--build-type` which can be `"lib"` or `"types"`, `"lib"` is the default for generating types for `Gjs` and the way it was before. I added "types" for node-gtk and generates the types e.g. as you would publish them on DefinitelyTyped.
- Source maps are now also generated, which simplify debugging, Zhe IDE can now points directly to the typescript files e.g. at a breakpoint
- Updated dependencies
- Replaced [commander.js](https://github.com/tj/commander.js/) with [oclif](https://github.com/oclif/oclif) because `commander.js` was a difficult to use with multiple arguments
- Added wild card support for module names to load (e.g. Gtk*)
- Ask which module version should be used if several are found
- It can now be specified which modules should be ignored
- A config can now be created in which the cli options are available (e.g. the modules that should be ignored)
- Added new reserved keywords for functions, class names, etc
- Fixed data type errors
- Added a new list

See PR [#19](https://github.com/sammydre/ts-for-gjs/pull/19)


# 19 Jul 2019
- Export symbols used by registerClass

See PR [#16](https://github.com/sammydre/ts-for-gjs/pull/16)

# 14 Jul 2019
- Add GObject signal connect methods
- Fix GType and add $gtype properties

See PR [#14](https://github.com/sammydre/ts-for-gjs/pull/14) and [#15](https://github.com/sammydre/ts-for-gjs/pull/15)

# 2 Jul 2019
- Fix return value of signal connect methods

See PR [#10](https://github.com/sammydre/ts-for-gjs/pull/10)
Loading

0 comments on commit e1dacad

Please sign in to comment.