Skip to content
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

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

Open
wants to merge 22 commits into
base: v3-alpha-feature/event-types
Choose a base branch
from

Conversation

IanVS
Copy link

@IanVS IanVS commented Mar 3, 2025

This:

  • Converts package.json into package.json.tmpl
  • Organizes package.json in the templates, alphabetizing and dividing up dependencies and devDependencies` correctly.
  • Adds vite plugin to vite.config.ts for all ts templates
  • Converts the vite plugin to typescript

I also added a npm run build:code:watch script, so that developers can run that and be sure that changes to the runtime code is compiled to be consumed by linked projects. I've also added a README to describe the local development process of @wailsio/runtime.

I also did a few other things here:

  • Removed the // @ts-ignore comments from generated bindings, and instead created a custom tsconfig.bindings.json project which allows us to have its own config. I'm also "include"ing the "bindings" directory in the core tsconfig as well, and I'm not sure if that will cause trouble, but it allows a cmd+click on Events to go to the eventdata.d.ts, for example. Maybe we can refine this.
  • Allowed the types for Create to be exported. The function is exported, and it's used from the generated bindings, so by preventing the types from being created, it just caused unnecessary errors.
  • Downgraded vite to 5.x in the plugin, because of type mismatches for 6.x. I still don't quite understand what's going on here. Will investigate more later, and potentially upgrade all the templates to 6.x as well.

@@ -841,7 +841,7 @@ function rejectorFor<T>(promise: CancellablePromiseWithResolvers<T>, state: Canc
* Returns a promise that fulfills once all cancellation procedures for the given values have settled.
*/
function cancelAll(parent: CancellablePromise<unknown>, values: any[], cause?: any): Promise<void> {
const results = [];
const results: Promise<any>[] = [];
Copy link
Author

Choose a reason for hiding this comment

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

This was throwing an error in the lit-ts project without this. I'm not sure why it didn't error in the runtime project too.

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks. A stricter Promise<void>[] should be fine as well. Still good though

@IanVS IanVS changed the title Make progress on TS templates Add runtime build watch, remove custom condition, update TS templates Mar 4, 2025
@fbbdev fbbdev self-assigned this Mar 5, 2025
// 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.

"./plugins/*": "./plugins/*"
"./plugins/*": {
"types": "./types/plugins/*.d.ts",
"default": "./dist/plugins/*.js"
Copy link
Owner

Choose a reason for hiding this comment

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

Are you sure the build command is generating these files? I think the tsconfig still includes src only.

Copy link
Author

@IanVS IanVS Mar 5, 2025

Choose a reason for hiding this comment

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

I moved plugins into src/plugins, so that it is processed along with the rest of the code.

@@ -841,7 +841,7 @@ function rejectorFor<T>(promise: CancellablePromiseWithResolvers<T>, state: Canc
* Returns a promise that fulfills once all cancellation procedures for the given values have settled.
*/
function cancelAll(parent: CancellablePromise<unknown>, values: any[], cause?: any): Promise<void> {
const results = [];
const results: Promise<any>[] = [];
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks. A stricter Promise<void>[] should be fine as well. Still good though

@@ -44,9 +44,6 @@ export {

/**
* An internal utility consumed by the binding generator.
*
* @ignore
Copy link
Owner

Choose a reason for hiding this comment

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

It should still be @ignored though, so that it is omitted from the docs.

In a future PR I'm going to move this out of the runtime and into bindings as part of a deduplication effort.

Copy link
Author

@IanVS IanVS Mar 5, 2025

Choose a reason for hiding this comment

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

Is there a way to omit from docs but not from types?

Edit: okay, looks like @internal trims the type from the declaration, and @ignore prevents it from being included in the docs. 👍

@@ -1,5 +1,5 @@
{
"compilerOptions": {
"compilerOptions": {
Copy link
Owner

Choose a reason for hiding this comment

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

I think some end-of-line spaces have been added accidentally here and on another line (unless I'm misreading the gh diff and they've been removed)

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. Really wish prettier or another formatter was being used in this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants