Skip to content

Add runtime build watch, remove custom condition, update TS templates #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: v3-alpha-feature/event-types
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions v3/internal/generator/render/templates/eventcreate.js.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Create as $Create } from "{{js $runtime}}";
{{if (and (not $useInterfaces) .Defs)}}
{{- range $imports.External}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as {{jsimport .}} from "{{js .RelPath}}/{{js $models}}";
{{- end}}{{if $imports.External}}
{{end}}
{{- if $imports.ImportModels}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as $models from "./{{js $models}}";
{{end}}
function configure() {
Expand Down
6 changes: 0 additions & 6 deletions v3/internal/generator/render/templates/eventdata.d.ts.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
{{if .Defs}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import type { Events } from "{{js $runtime}}";
{{range $imports.External}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import type * as {{jsimport .}} from "{{js .RelPath}}/{{js $models}}";
{{- end}}{{if $imports.External}}
{{end}}
{{- if $imports.ImportModels}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import type * as $models from "./{{js $models}}";
{{end}}
declare module "{{js $runtime}}" {
Expand Down
4 changes: 0 additions & 4 deletions v3/internal/generator/render/templates/models.js.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
{{if not $useInterfaces}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Create as $Create } from "{{js $runtime}}";
{{end -}}
{{range $imports.External}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as {{jsimport .}} from "{{js .RelPath}}/{{js $models}}";
{{- end}}{{if $imports.External}}
{{end}}
Expand Down
4 changes: 0 additions & 4 deletions v3/internal/generator/render/templates/models.ts.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
{{if not $useInterfaces}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Create as $Create } from "{{js $runtime}}";
{{end -}}
{{range $imports.External}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as {{jsimport .}} from "{{js .RelPath}}/{{js $models}}";
{{- end}}{{if $imports.External}}
{{end}}
Expand Down
8 changes: 1 addition & 7 deletions v3/internal/generator/render/templates/service.js.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@
* @module
*/
{{end}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Call as $Call, CancellablePromise as $CancellablePromise{{if not $useInterfaces}}, Create as $Create{{end}} } from "{{js $runtime}}";
import { Call as $Call, type CancellablePromise as $CancellablePromise{{if not $useInterfaces}}, Create as $Create{{end}} } from "{{js $runtime}}";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we can have a type import here in the JS template. JS output has to work out of the box in all supported webviews without any bundler/transpiler.

We should probably make this a tsdoc import:

/**
 * @import { CancellablePromise as $CancellablePromise } from "@wailsio/runtime"
 */

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks, got over-eager and thought this was TS, probably because of the @ts-ignore comment. Should have looked more closely at the file extension.

{{range $imports.External}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as {{jsimport .}} from "{{js .RelPath}}/{{js $models}}";
{{- end}}{{if $imports.External}}
{{end}}
{{- if $imports.ImportModels}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as $models from "./{{js $models}}";
{{end}}
{{- range .Methods}}
Expand Down
8 changes: 1 addition & 7 deletions v3/internal/generator/render/templates/service.ts.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@
* @module
*/
{{end}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Call as $Call, CancellablePromise as $CancellablePromise{{if not $useInterfaces}}, Create as $Create{{end}} } from "{{js $runtime}}";
import { Call as $Call, type CancellablePromise as $CancellablePromise{{if not $useInterfaces}}, Create as $Create{{end}} } from "{{js $runtime}}";
{{range $imports.External}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as {{jsimport .}} from "{{js .RelPath}}/{{js $models}}";
{{- end}}{{if $imports.External}}
{{end}}
{{- if $imports.ImportModels}}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as $models from "./{{js $models}}";
{{end}}
{{- range .Methods}}
Expand Down
1 change: 0 additions & 1 deletion v3/internal/generator/testdata/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,

"customConditions": ["wails-development"],
"paths": {
"/wails/runtime.js": ["../../runtime/desktop/@wailsio/runtime"]
}
Expand Down
20 changes: 20 additions & 0 deletions v3/internal/runtime/desktop/@wailsio/runtime/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# @wailsio/runtime

## Development

When developing wails, you can create templates with a direct link back to this package, enabling you to make changes here and see the impact in a real project.

First, to enable this mode:

1. `cd` to the wails `v3` directory
2. `wails3 task install`

Then, when you initialize a new project using `wails3 init`, the development version of wails will be used, and a link will be created in the `package.json` back to this directory.

Before running `wails3 dev` in that new project, you'll need to build the output of this package:

1. Install project dependencies with `npm i`
2. Build the project using `npm run build:code`
- Or `npm run build:code:watch` to automatically recompile when you make changes

To revert a project back to the npm-published version of `@wailsio/runtime`, simply change the reference in `package.json` back to `"latest"`.
Loading
Loading