Skip to content

Commit

Permalink
Merge branch 'main' into iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
JumpLink committed Nov 7, 2024
2 parents 7a14094 + 9a294b3 commit 922819c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 57 deletions.
45 changes: 9 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,24 @@ on:
branches:
- "*"
jobs:
examples:
ci:

runs-on: ubuntu-22.04
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
node-version: [22.x]
architecture:
- x64
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
submodules: true
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# - name: Workaround for bad mirror
# run: sudo gem install apt-spy2; sudo apt-spy2 check; sudo apt-spy2 fix --commit;
- name: Update package repository
run: sudo apt-get update; # sudo apt-get upgrade
- name: Install dependencies
Expand All @@ -40,36 +38,11 @@ jobs:
- run: gjs --version
- run: yarn install
- run: yarn build
- run: yarn build:examples
- run: yarn validate:examples
- run: yarn test:examples:cli-apps

gjs-types-all:

runs-on: ubuntu-22.04

strategy:
matrix:
node-version: [20.x]
architecture:
- x64
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Update package repository
run: sudo apt-get update; # sudo apt-get upgrade
- name: Install dependencies
run: sudo apt-get --yes install gjs libappindicator3-dev libgda-5.0-dev libgirepository1.0-dev libgtk-3-dev libgtk-4-dev libgtksourceview-3.0-dev libnotify-dev libsoup2.4-dev libsoup-3.0-dev libwebkit2gtk-4.0-dev libadwaita-1-dev gnome-shell-common libmutter-10-dev libgcr-3-dev libgnome-desktop-3-dev build-essential gobject-introspection libgirepository1.0-dev libcairo2-dev
- run: yarn install
- run: yarn build
- run: yarn build:types:packages
- name: Show diff
run: (cd ./types && git diff | cat)
- run: yarn validate:types:packages
- run: yarn test:tests
- run: yarn test:tests
- run: yarn build:examples
- run: yarn validate:examples
- run: yarn test:examples:cli-apps
42 changes: 23 additions & 19 deletions examples/gio-2-cat/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,37 @@
* the label should show a translation of 'Print help'
*/

import '@girs/gjs';
import '@girs/gjs/dom';
import GLib from '@girs/glib-2.0';
import Gio from '@girs/gio-2.0';
import '@girs/gjs'
import '@girs/gjs/dom'
import GLib from '@girs/glib-2.0'
import Gio from '@girs/gio-2.0'

const loop = GLib.MainLoop.new(null, false);
const loop = GLib.MainLoop.new(null, false)
const textDecoder = new TextDecoder()

function cat(filename: string) {
const file = Gio.file_new_for_path(filename);
const file = Gio.file_new_for_path(filename)

file.load_contents_async(null, (obj, res) => {
let contents: Uint8Array;
let contents: Uint8Array
try {
contents = obj!.load_contents_finish(res)![1];
contents = obj!.load_contents_finish(res)![1]
} catch (e) {
logError(e);
loop.quit();
return;
logError(e)
loop.quit()
return
}
print(textDecoder.decode(contents));
loop.quit();
});
print(textDecoder.decode(contents))
loop.quit()
})

// Tests instanceof, see https://github.com/gjsify/ts-for-gir/issues/195
if (!(file instanceof Gio.File)) {
throw new Error('file is not an instance of Gio.File')
}

loop.run();
loop.run()
}

if (ARGV.length !== 1)
printerr('Usage: gio-cat.js filename');
else
cat(ARGV[0]);
if (ARGV.length !== 1) printerr('Usage: gio-cat.js filename')
else cat(ARGV[0])
6 changes: 5 additions & 1 deletion packages/generator-typescript/src/module-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ export class ModuleGenerator extends FormatGenerator<string[]> {
]
}
generateInterfaceDeclaration(node: IntrospectedInterface): string[] {
return [`\n\nexport const ${node.name}: ${node.name}Namespace;\n`]
return [
`\n\nexport const ${node.name}: ${node.name}Namespace & {
new (): ${node.name} // This allows \`obj instanceof ${node.name}\`
}\n`,
]
}
generateError(node: IntrospectedError): string[] {
const { namespace } = this
Expand Down
4 changes: 3 additions & 1 deletion packages/generator-typescript/templates/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ _%>
"removeComments": false,
"inlineSourceMap": false,
"inlineSources": false,
"newLine": "LF"
"newLine": "LF",
// Show diagnostics
"diagnostics": true
},
"include": <%- JSON.stringify(includes) %>
}

0 comments on commit 922819c

Please sign in to comment.