wails-auto-ipc
Version:
generate single app.go for wails app from multiple files
84 lines (66 loc) • 2.85 kB
Markdown
# wails-auto-ipc
- is a helper pack for `wails` app;
- main functionality auto ipc uses:
> - [`neinth`](https://www.npmjs.com/package/neinth) to generate `app.go` with
> exported(`upperCaseStarts`) on `package go_`, located on `/go_/`;
> > - detects only `func` and `type` declaration;
> > - you can add `appContext context.Context`(import from "context") as first argument if you
> > you want to use wails app context;
> > - renames frontend `wailjs` `App` `ipc references` parameters into the same argument name
> > with go parameter;
## additional:
- [`vorth`](https://www.npmjs.com/package/vorth) as front-end reactive library;
- `caveat`:
> - it's not standard `wails` approach where `frontend` are used as it's own scoped frontend
> layer, including the `sources`;
> - this helper treat the project root as `frontend` project root too, which is the reason why
> there's `package.json` generated in this package;
> - the '/jsconfig.json' are also made for `vorth` and `neinth` `typehinting`(generates `.mjs` >
> `typedef` on the fly);
> - you need to replace the `embed.FS` target on `/main.go` into something like this:
```go
// /main.go
package main
// ...
//go:embed all:frontend
var assets embed.FS
// ...
```
## how to install
- install fresh wails app;
- install wails-auto-ipc;
> - example is using `npm` and `npx`, you can use your favourite package manager;
```shell
npm i wails-auto-ipc
npx wails-auto-ipc -pmx [bunx|npx|your_favourite_package_manager_executable] -pn [your_app_name]
```
- OR
```shell
npm i wails-auto-ipc
npx wails-auto-ipc-with-vorth -pmx [bunx|npx|your_favourite_package_manager_executable] -pn [your_app_name]
```
> - watchout for the `v` flag, as it will renew
- what did the script do?
> - install wails-auto-ipc from npm;
> - copy `files` to `projectRoot`:
> > - `neinth-src/**/*`;
> > > - neinth script for `/app.go` generator;
> > - `.vscode/**/*`;
> > > - snippets collections;
> > - `README.wails-auto-ipc.md`;
> > - `jsconfig.json`:
> > > - unconventional `wails` approach, this library uses root directory as root of the
> > > frontend handler too;
> > - `vorth-src/**/*`:
> > > - optional if uses `wails-auto-ipc-with-vorth`;
> > - `vorth.config.mjs`;
> > > - optional if uses `wails-auto-ipc-with-vorth`;
> > - `package.json`;
> - replace `packagemanager` on the `package.json` scripts with `-pmx` flag;
> - replace `appName`, needed for app.go reference to your app, with `-pn` flag;
## wails note
- most of functionalities, assumes the code are written in `wails` `2.10.1` `specs`, including but
not limited to:
> - `/wails.json` structure;
> - wails js autoGenerated IPC reference syntaxes;
- we provide sample for simplified common ipc in `go_`: