From a16f898ed8fde3f060dee456eaa6e7350964c41b Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Wed, 18 Jun 2025 19:45:49 +0100 Subject: [PATCH 1/5] j --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a2fc14f..df9a27b 100644 --- a/README.md +++ b/README.md @@ -71,4 +71,4 @@ air ``` ## License -`tiramisu` is licensed under the GNU General Public License (GPL) v3.0. See the [LICENSE](LICENSE) file for more details. \ No newline at end of file +`tiramisu` is licensed under the GNU General Public License (GPL) v3.0. See the [LICENSE](LICENSE) file for more details. From c3243503a7df00338965498f53ff186d7d8e73a2 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Thu, 26 Jun 2025 19:39:10 +0100 Subject: [PATCH 2/5] oops --- .air.toml | 2 +- .gitignore | 3 ++- Taskfile.yml | 2 +- examples/{ => testbench}/index.html | 0 examples/{ => testbench}/main.go | 0 5 files changed, 4 insertions(+), 3 deletions(-) rename examples/{ => testbench}/index.html (100%) rename examples/{ => testbench}/main.go (100%) diff --git a/.air.toml b/.air.toml index d7ff5c6..c998ed5 100644 --- a/.air.toml +++ b/.air.toml @@ -5,7 +5,7 @@ tmp_dir = "tmp" [build] args_bin = [] bin = "tmp\\main.exe" - cmd = "go build -o ./tmp/main.exe ./example" + cmd = "go build -o ./tmp/main.exe ./examples/testbench" delay = 1000 exclude_dir = ["assets", "tmp", "vendor", "testdata", "runtime/out", "node_modules", "dist"] exclude_file = [] diff --git a/.gitignore b/.gitignore index 72c806f..eb92321 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ tmp/ -out/ \ No newline at end of file +out/ +*.exe \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml index f3cc338..7c5b726 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -6,4 +6,4 @@ tasks: default: cmds: - bunx tsc -p ./runtime - - go build -ldflags='-H windowsgui' ./example + - go build -ldflags='-H windowsgui' ./examples/testbench diff --git a/examples/index.html b/examples/testbench/index.html similarity index 100% rename from examples/index.html rename to examples/testbench/index.html diff --git a/examples/main.go b/examples/testbench/main.go similarity index 100% rename from examples/main.go rename to examples/testbench/main.go From 34e396271dc41e2d982c9f91c19ba9d168abd9e8 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Fri, 27 Jun 2025 15:14:59 +0100 Subject: [PATCH 3/5] oosp --- .gitignore | 1 - runtime/out/preload.d.ts | 11 +++++++++++ runtime/out/preload.js | 12 ++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 runtime/out/preload.d.ts create mode 100644 runtime/out/preload.js diff --git a/.gitignore b/.gitignore index eb92321..d194f34 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ tmp/ -out/ *.exe \ No newline at end of file diff --git a/runtime/out/preload.d.ts b/runtime/out/preload.d.ts new file mode 100644 index 0000000..b55de9c --- /dev/null +++ b/runtime/out/preload.d.ts @@ -0,0 +1,11 @@ +declare const tiramisu: { + invoke: (name: string, ...args: any[]) => Promise; + fs: { + readFile: (path: string) => Promise; + readDir: (path: string) => Promise; + exists: (path: string) => Promise; + }; + notifications: { + notify: (message: string, ico?: string) => Promise; + }; +}; diff --git a/runtime/out/preload.js b/runtime/out/preload.js new file mode 100644 index 0000000..bff5712 --- /dev/null +++ b/runtime/out/preload.js @@ -0,0 +1,12 @@ +const tiramisu = { + invoke: window.__TIRAMISU_INTERNAL_invoke, + fs: { + readFile: window.__TIRAMISU_FILESYSTEM_readFile, + readDir: window.__TIRAMISU_FILESYSTEM_readDir, + exists: window.__TIRAMISU_INTERNAL_exists, + }, + notifications: { + notify: window.__TIRAMISU_NOTIFICATIONS_notify, + }, +}; +window.tiramisu = tiramisu; From a3791b599b084b3c34685ff095b3c8f79a69e405 Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Fri, 27 Jun 2025 15:23:51 +0100 Subject: [PATCH 4/5] make fn optional in app.Run --- README.md | 2 +- examples/minimal/index.html | 6 ++++++ examples/minimal/main.go | 24 ++++++++++++++++++++++++ tiramisu.go | 8 +++++--- 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 examples/minimal/index.html create mode 100644 examples/minimal/main.go diff --git a/README.md b/README.md index df9a27b..7ecd4db 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ import ( func main() { // create the webview instance - app := tiramisu.New(tiramisu.Options{ + app := tiramisu.New(tiramisu.TiramisuOptions{ Title: "Tiramisu Example", Width: 800, Height: 600, diff --git a/examples/minimal/index.html b/examples/minimal/index.html new file mode 100644 index 0000000..e1fd12b --- /dev/null +++ b/examples/minimal/index.html @@ -0,0 +1,6 @@ + + + +

hello tiramisu!

+ + \ No newline at end of file diff --git a/examples/minimal/main.go b/examples/minimal/main.go new file mode 100644 index 0000000..fb114b0 --- /dev/null +++ b/examples/minimal/main.go @@ -0,0 +1,24 @@ +package main + +import ( + _ "embed" + + t "git.iwakura.rip/grng/tiramisu" + webview "github.com/webview/webview_go" +) + +//go:embed index.html +var html string + +func main() { + app := t.New(t.TiramisuOptions{ + Debug: true, + Width: 800, + Height: 600, + Title: "Tiramisu", + Hints: webview.HintFixed, + }) + + app.HTML(html) + app.Run() +} diff --git a/tiramisu.go b/tiramisu.go index 3292cc5..7d46ece 100644 --- a/tiramisu.go +++ b/tiramisu.go @@ -40,14 +40,16 @@ func New(o TiramisuOptions) *Tiramisu { return t } -func (t *Tiramisu) Run(fn func()) { +func (t *Tiramisu) Run(fns ...func()) { defer t.w.Destroy() t.w.Dispatch(func() { t.loadJSRuntime() t.loadGoRuntime() - if fn != nil { - fn() + for _, fn := range fns { + if fn != nil { + fn() + } } }) t.w.Run() From c95bafd34fbb51779d13da1aab0f2026c9f0c4fc Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Fri, 27 Jun 2025 15:26:32 +0100 Subject: [PATCH 5/5] forgot navigate --- README.md | 2 +- tiramisu.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ecd4db..4833a3f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Build modern, cross-platform desktop apps in HTML + Go from one codebase. It use - ⚡**Fast development**: Use *ANY* web framework for your UI. Tiramisu handles all the magic of making it work, for you. ## Installation -`go install git.iwakura.rip/grng/tiramisu` +`go get -u git.iwakura.rip/grng/tiramisu` ## Example diff --git a/tiramisu.go b/tiramisu.go index 7d46ece..e51a7b1 100644 --- a/tiramisu.go +++ b/tiramisu.go @@ -97,6 +97,12 @@ func (t *Tiramisu) HTML(html string) { t.loadGoRuntime() } +func (t *Tiramisu) Navigate(url string) { + t.w.Navigate(url) + t.loadJSRuntime() + t.loadGoRuntime() +} + //go:embed runtime/out/* var runtimeFS embed.FS