Skip to content

Commit 3aa3e09

Browse files
authored
Merge pull request #4100 from fbbdev/v3-alpha-feature/typescript-runtime
[v3] TypeScript runtime
2 parents 73da970 + 6423abe commit 3aa3e09

File tree

88 files changed

+9076
-3391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+9076
-3391
lines changed

.github/workflows/build-and-test-v3.yml

+122-28
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,111 @@ jobs:
2626
echo "approved=false" >> $GITHUB_OUTPUT
2727
fi
2828
29+
check_build_artifacts:
30+
name: Check runtime build artifact changes
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
with:
36+
persist-credentials: 'true'
37+
38+
- name: Get changed files
39+
id: changed-files
40+
uses: tj-actions/changed-files@v45
41+
with:
42+
files: |
43+
v3/internal/runtime/desktop/@wailsio/runtime/dist/**
44+
v3/internal/runtime/desktop/@wailsio/runtime/types/**
45+
46+
- name: Get merge base
47+
id: merge-base
48+
if: steps.changed-files.outputs.any_changed == 'true'
49+
env:
50+
BASE_SHA: ${{github.event.pull_request.base.sha}}
51+
HEAD_SHA: ${{github.event.pull_request.head.sha}}
52+
run: |
53+
echo "sha=$(git merge-base "$BASE_SHA" "$HEAD_SHA")" >> $GITHUB_OUTPUT
54+
55+
- name: This PR includes changes to runtime build artifacts
56+
uses: actions/github-script@v7
57+
if: steps.changed-files.outputs.any_changed == 'true'
58+
env:
59+
MERGE_BASE_SHA: ${{steps.merge-base.outputs.sha}}
60+
with:
61+
script: |
62+
process.exitCode = 1
63+
core.error(
64+
'The CI pipeline will rebuild and publish the runtime automatically.\n' +
65+
'Please run the following command (or equivalent) in your local wails repo\n' +
66+
'to revert all build artifact changes; then update the PR:\n\n' +
67+
' cd v3/internal/runtime/desktop/@wailsio/runtime &&\n' +
68+
` git restore -s ${process.env.MERGE_BASE_SHA} -W -S -- dist types &&\n` +
69+
' git commit -m "Revert build artifact changes"\n',
70+
{ title: 'This PR includes changes to runtime build artifacts' }
71+
);
72+
73+
test_js:
74+
name: Run JS Tests
75+
needs: check_approval
76+
runs-on: ubuntu-latest
77+
strategy:
78+
matrix:
79+
node-version: [20.x]
80+
81+
steps:
82+
- name: Checkout code
83+
uses: actions/checkout@v4
84+
85+
- name: Use Node.js ${{ matrix.node-version }}
86+
uses: actions/setup-node@v4
87+
with:
88+
node-version: ${{ matrix.node-version }}
89+
90+
- name: Install Task
91+
uses: arduino/setup-task@v2
92+
with:
93+
version: 3.x
94+
repo-token: ${{ secrets.GITHUB_TOKEN }}
95+
96+
- name: Install dependencies
97+
working-directory: v3/internal/runtime/desktop/@wailsio/runtime
98+
run: |
99+
npm ci
100+
npx --yes esbuild@latest --version
101+
102+
- name: Clean build artifacts
103+
working-directory: v3/internal/runtime/desktop/@wailsio/runtime
104+
run: npm run clean
105+
106+
- name: Type-check runtime
107+
working-directory: v3
108+
run: task runtime:check
109+
110+
- name: Test runtime
111+
working-directory: v3
112+
run: task runtime:test
113+
114+
- name: Check that the bundled runtime builds
115+
working-directory: v3
116+
run: task runtime:build
117+
118+
- name: Check that the npm package builds
119+
working-directory: v3/internal/runtime/desktop/@wailsio/runtime
120+
run: npm run build
121+
122+
- name: Store runtime build artifacts
123+
uses: actions/upload-artifact@v4
124+
with:
125+
name: runtime-build-artifacts
126+
path: |
127+
v3/internal/runtime/desktop/@wailsio/runtime/dist/
128+
v3/internal/runtime/desktop/@wailsio/runtime/types/
129+
v3/internal/runtime/desktop/@wailsio/runtime/tsconfig.tsbuildinfo
130+
29131
test_go:
30132
name: Run Go Tests v3
31-
needs: check_approval
133+
needs: [check_approval, test_js]
32134
runs-on: ${{ matrix.os }}
33135
strategy:
34136
fail-fast: false
@@ -59,25 +161,31 @@ jobs:
59161
version: 3.x
60162
repo-token: ${{ secrets.GITHUB_TOKEN }}
61163

164+
- name: Retrieve runtime build artifacts
165+
uses: actions/download-artifact@v4
166+
with:
167+
name: runtime-build-artifacts
168+
path: v3/internal/runtime/desktop/@wailsio/runtime/
169+
62170
- name: Build Examples
63-
working-directory: ./v3
171+
working-directory: v3
64172
run: task test:examples
65173

66174
- name: Run tests (mac)
67175
if: matrix.os == 'macos-latest'
68176
env:
69177
CGO_LDFLAGS: -framework UniformTypeIdentifiers -mmacosx-version-min=10.13
70-
working-directory: ./v3
178+
working-directory: v3
71179
run: go test -v ./...
72180

73181
- name: Run tests (windows)
74182
if: matrix.os == 'windows-latest'
75-
working-directory: ./v3
183+
working-directory: v3
76184
run: go test -v ./...
77185

78186
- name: Run tests (ubuntu)
79187
if: matrix.os == 'ubuntu-latest'
80-
working-directory: ./v3
188+
working-directory: v3
81189
run: >
82190
xvfb-run --auto-servernum
83191
sh -c '
@@ -86,33 +194,19 @@ jobs:
86194
'
87195
88196
- name: Typecheck binding generator output
89-
working-directory: ./v3
197+
working-directory: v3
90198
run: task generator:test:check
91199

92-
test_js:
93-
name: Run JS Tests
94-
needs: check_approval
200+
cleanup:
201+
name: Cleanup build artifacts
202+
if: always()
203+
needs: [test_js, test_go]
95204
runs-on: ubuntu-latest
96-
strategy:
97-
matrix:
98-
node-version: [20.x]
99-
100205
steps:
101-
- name: Checkout code
102-
uses: actions/checkout@v4
103-
104-
- name: Use Node.js ${{ matrix.node-version }}
105-
uses: actions/setup-node@v4
206+
- uses: geekyeggo/delete-artifact@v5
106207
with:
107-
node-version: ${{ matrix.node-version }}
108-
109-
- name: Install dependencies
110-
run: npm install
111-
working-directory: v2/internal/frontend/runtime
112-
113-
- name: Run tests
114-
run: npm test
115-
working-directory: v2/internal/frontend/runtime
208+
name: runtime-build-artifacts
209+
failOnError: false
116210

117211
test_templates:
118212
name: Test Templates
@@ -160,7 +254,7 @@ jobs:
160254
repo-token: ${{ secrets.GITHUB_TOKEN }}
161255

162256
- name: Build Wails3 CLI
163-
working-directory: ./v3
257+
working-directory: v3
164258
run: |
165259
task install
166260
wails3 doctor

.github/workflows/publish-npm.yml

+52-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
on:
22
push:
33
branches: ['v3-alpha']
4+
workflow_dispatch:
45

56
jobs:
67
publish:
@@ -12,51 +13,84 @@ jobs:
1213
ref: 'v3-alpha'
1314
ssh-key: ${{ secrets.DEPLOY_KEY }}
1415

15-
1616
- name: Configure git
1717
run: |
1818
git config --local user.email "[email protected]"
1919
git config --local user.name "GitHub Actions"
2020
21-
- name: Setup go-task
22-
uses: pnorton5432/setup-task@v1
21+
- name: Install Task
22+
uses: arduino/setup-task@v2
2323
with:
24-
task-version: 3.29.1
24+
version: 3.x
25+
repo-token: ${{ secrets.GITHUB_TOKEN }}
2526

26-
- uses: actions/setup-node@v3
27+
- name: Use Node.js 20
28+
uses: actions/setup-node@v4
2729
with:
2830
node-version: "20"
29-
- run: |
31+
32+
- name: Install dependencies
33+
working-directory: v3/internal/runtime/desktop/@wailsio/runtime
34+
run: |
3035
npm ci
31-
npm run build:types
32-
npm run build:docs
36+
npx --yes esbuild@latest --version
37+
38+
- name: Clean build artifacts
3339
working-directory: v3/internal/runtime/desktop/@wailsio/runtime
40+
run: npm run clean
41+
42+
- name: Build bundled runtime
43+
working-directory: v3
44+
run: task runtime:build
45+
46+
- name: Test+Build npm package
47+
working-directory: v3/internal/runtime/desktop/@wailsio/runtime
48+
run: |
49+
npm test
50+
npm run build
3451
35-
- name: Verify Changed files
52+
- name: Detect npm package changes
3653
uses: tj-actions/verify-changed-files@v20
37-
id: verify-changed-files
54+
id: package-changes
3855
with:
3956
files: |
40-
v3/internal/runtime/desktop/@wailsio/runtime/src/*.js
41-
v3/internal/runtime/desktop/@wailsio/runtime/types/*.d.ts
42-
v3/internal/runtime/desktop/@wailsio/runtime/docs/**/*.*
57+
v3/internal/runtime/desktop/@wailsio/runtime/dist/**
58+
v3/internal/runtime/desktop/@wailsio/runtime/types/**
4359
4460
- name: Bump version
45-
if: steps.verify-changed-files.outputs.files_changed == 'true'
61+
if: github.event_name == 'workflow_dispatch' || steps.package-changes.outputs.files_changed == 'true'
4662
id: bump-version
4763
working-directory: v3/internal/runtime/desktop/@wailsio/runtime
48-
run: echo "version=$(npm --no-git-tag-version --force version prerelease)" >> "$GITHUB_OUTPUT"
64+
run: |
65+
echo "version=$(npm version prerelease)" >> $GITHUB_OUTPUT
4966
5067
- name: Commit changes
51-
if: steps.verify-changed-files.outputs.files_changed == 'true'
68+
if: github.event_name == 'workflow_dispatch' || steps.package-changes.outputs.files_changed == 'true'
5269
run: |
5370
git add .
5471
git commit -m "[skip ci] Publish @wailsio/runtime ${{ steps.bump-version.outputs.version }}"
5572
git push
5673
57-
- uses: JS-DevTools/npm-publish@v3
58-
if: steps.verify-changed-files.outputs.files_changed == 'true'
74+
- name: Publish npm package
75+
uses: JS-DevTools/npm-publish@v3
76+
if: github.event_name == 'workflow_dispatch' || steps.package-changes.outputs.files_changed == 'true'
5977
with:
6078
package: v3/internal/runtime/desktop/@wailsio/runtime
6179
access: public
6280
token: ${{ secrets.NPM_TOKEN }}
81+
82+
- name: Detect docs and bundled runtime changes
83+
if: github.event_name != 'workflow_dispatch' && steps.package-changes.outputs.files_changed != 'true'
84+
uses: tj-actions/verify-changed-files@v20
85+
id: docs-bundle-changes
86+
with:
87+
files: |
88+
v3/internal/assetserver/bundledassets/**
89+
v3/internal/runtime/desktop/@wailsio/runtime/docs/**
90+
91+
- name: Commit docs and bundled runtime changes
92+
if: github.event_name != 'workflow_dispatch' && steps.package-changes.outputs.files_changed != 'true' && steps.docs-bundle-changes.outputs.files_changed == 'true'
93+
run: |
94+
git add .
95+
git commit -m "[skip ci] Update runtime docs and bundle"
96+
git push

docs/src/content/docs/changelog.mdx

+9
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6161
- Add test harness for application startup/shutdown sequence and service startup/shutdown tests by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
6262
- Add `RegisterService` method for registering services after the application has been created by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
6363
- Add `MarshalError` field in application and service options for custom error handling in binding calls by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
64+
- Add cancellable promise wrapper that propagates cancellation requests through promise chains by [@fbbdev](https://github.com/fbbdev) in [#4100](https://github.com/wailsapp/wails/pull/4100)
65+
- Add the ability to tie binding call cancellation to an `AbortSignal` by [@fbbdev](https://github.com/fbbdev) in [#4100](https://github.com/wailsapp/wails/pull/4100)
66+
- Support `data-wml-*` attributes for WML alongside the usual `wml-*` attributes by [@leaanthony](https://github.com/leaanthony)
6467

6568
### Fixed
6669

@@ -91,6 +94,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9194
- Fixed handling and formatting of errors in message processors by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
9295
-  Fixed skipped service shutdown when quitting application by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
9396
-  Ensure menu updates occur on the main thread by [@leaanthony](https://github.com/leaanthony)
97+
- The dragging and resizing mechanism is now more robust and matches expected platform behaviour more closely by [@fbbdev](https://github.com/fbbdev) in [#4100](https://github.com/wailsapp/wails/pull/4100)
98+
- Fixed [#4097](https://github.com/wailsapp/wails/issues/4097) Webpack/angular discards runtime init code by [@fbbdev](https://github.com/fbbdev) in [#4100](https://github.com/wailsapp/wails/pull/4100)
9499

95100
### Changed
96101

@@ -112,6 +117,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
112117
- `ServiceStartup` errors are now returned from `App.Run` instead of terminating the process by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
113118
- Binding and dialog calls from JS now reject with error objects instead of strings by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
114119
- Improved systray menu positioning on Windows by [@leaanthony](https://github.com/leaanthony)
120+
- The JS runtime has been ported to TypeScript by [@fbbdev](https://github.com/fbbdev) in [#4100](https://github.com/wailsapp/wails/pull/4100)
121+
- The runtime initialises as soon as it is imported, no need to wait for the window to load by [@fbbdev](https://github.com/fbbdev) in [#4100](https://github.com/wailsapp/wails/pull/4100)
122+
- The runtime does not export an init method anymore. A side effects import can be used to initialise it by [@fbbdev](https://github.com/fbbdev) in [#4100](https://github.com/wailsapp/wails/pull/4100)
123+
- Bound methods now return a `CancellablePromise` that rejects with a `CancelError` if cancelled. The actual result of the call is discarded by [@fbbdev](https://github.com/fbbdev) in [#4100](https://github.com/wailsapp/wails/pull/4100)
115124

116125
## v3.0.0-alpha.9 - 2025-01-13
117126

docs/src/content/docs/guides/menus.mdx

+4
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ You can control when the default context menu appears using the `--default-conte
366366
</div>
367367
```
368368

369+
:::note
370+
This feature will only work as expected after the runtime [has been initialised](../../learn/runtime#initialisation).
371+
:::
372+
369373
#### Nested Context Menu Behavior
370374

371375
When using the `--default-contextmenu` property on nested elements, the following rules apply:

0 commit comments

Comments
 (0)