From 1da68cfc7c662f3a86fe9bd5df72cf196fd2f1de Mon Sep 17 00:00:00 2001
From: Lea Anthony
Date: Tue, 29 Mar 2022 19:31:49 +1100
Subject: [PATCH] Remove unused directories + tidy up
---
.../generate/template/base/go.tmpl.mod | 2 -
.../templates/templates/svelte/go.mod.tmpl | 2 -
.../templates/templates/vanilla/go.mod.tmpl | 2 -
v2/internal/app/debug.go | 37 -
v2/internal/app/default.go | 42 -
v2/internal/app/desktop.go | 256 -
v2/internal/app/dev.go | 249 -
v2/internal/app/hybrid.go | 195 -
v2/internal/app/preflight_default.go | 10 -
v2/internal/app/preflight_windows.go | 27 -
v2/internal/app/production.go | 12 -
v2/internal/app/server.go | 165 -
v2/internal/assetdb/assetdb.go | 112 -
v2/internal/assetdb/assetdb_test.go | 70 -
v2/internal/assetdb/filesystem.go | 178 -
v2/internal/assetdb/filesystem_test.go | 108 -
v2/internal/bind/bind.go | 9 -
v2/internal/bridge/bridge.go | 113 -
v2/internal/bridge/client.go | 141 -
v2/internal/bridge/darwin.js | 1 -
v2/internal/bridge/dialog_client.go | 149 -
v2/internal/bridge/linux.js | 1 -
v2/internal/bridge/session.go | 187 -
v2/internal/bridge/windows.js | 1 -
v2/internal/deepcopy/LICENSE | 21 -
v2/internal/deepcopy/deepcopy.go | 125 -
v2/internal/deepcopy/deepcopy_test.go | 1110 ---
.../desktop/windows/go-webview2/README.md | 2 +-
v2/internal/html/asset.go | 128 -
v2/internal/html/asset_test.go | 53 -
v2/internal/html/assetbundle.go | 218 -
v2/internal/html/assetbundle_test.go | 84 -
v2/internal/html/testdata/basic.html | 14 -
.../html/testdata/inline_javascript.html | 15 -
v2/internal/html/testdata/multi_line.html | 17 -
v2/internal/html/testdata/self_closing.html | 14 -
v2/internal/html/testdata/src/bundle.js | 1 -
v2/internal/html/testdata/src/favicon.svg | 8 -
v2/internal/html/testdata/src/style.css | 3 -
v2/internal/runtime/assets/assets.go | 12 -
v2/internal/runtime/assets/desktop_darwin.js | 1 -
v2/internal/runtime/assets/desktop_linux.js | 1 -
v2/internal/runtime/assets/desktop_windows.js | 1 -
v2/internal/runtime/assets/wails.js | 1 -
v2/internal/runtime/js/.eslintrc | 24 -
v2/internal/runtime/js/babel.config.js | 22 -
v2/internal/runtime/js/core/bindings.js | 91 -
v2/internal/runtime/js/core/calls.js | 157 -
v2/internal/runtime/js/core/desktop.js | 24 -
v2/internal/runtime/js/core/events.js | 169 -
v2/internal/runtime/js/core/log.js | 115 -
v2/internal/runtime/js/core/main.js | 46 -
v2/internal/runtime/js/core/utils.js | 42 -
v2/internal/runtime/js/desktop/common.js | 15 -
v2/internal/runtime/js/desktop/darwin.js | 61 -
v2/internal/runtime/js/desktop/ipc.js | 41 -
v2/internal/runtime/js/desktop/linux.js | 61 -
v2/internal/runtime/js/desktop/windows.js | 61 -
v2/internal/runtime/js/package-lock.json | 5959 -----------------
v2/internal/runtime/js/package.json | 44 -
v2/internal/runtime/js/package.json.md5 | 1 -
v2/internal/runtime/js/runtime/.npmignore | 1 -
v2/internal/runtime/js/runtime/README.md | 3 -
v2/internal/runtime/js/runtime/bridge.js | 1726 -----
v2/internal/runtime/js/runtime/events.js | 76 -
v2/internal/runtime/js/runtime/init.js | 33 -
v2/internal/runtime/js/runtime/log.js | 113 -
v2/internal/runtime/js/runtime/main.js | 20 -
.../runtime/js/runtime/package-lock.json | 517 --
v2/internal/runtime/js/runtime/package.json | 28 -
v2/internal/runtime/js/runtime/runtime.d.ts | 26 -
.../runtime/js/runtime/src/Menu.svelte | 56 -
.../runtime/js/runtime/src/Menubar.svelte | 58 -
.../runtime/js/runtime/src/Overlay.svelte | 55 -
.../runtime/js/runtime/src/TrayMenu.svelte | 65 -
v2/internal/runtime/js/runtime/src/log.js | 9 -
v2/internal/runtime/js/runtime/src/main.js | 45 -
.../runtime/js/runtime/src/package-lock.json | 525 --
.../runtime/js/runtime/src/package.json | 21 -
.../runtime/js/runtime/src/rollup.config.js | 37 -
v2/internal/runtime/js/runtime/src/store.js | 64 -
.../runtime/js/runtime/src/websocket.js | 158 -
v2/internal/runtime/js/server/darwin.js | 17 -
v2/internal/runtime/js/server/ipc.js | 52 -
v2/internal/runtime/js/server/linux.js | 17 -
v2/internal/runtime/js/webpack.config.js | 4 -
v2/internal/runtime/js/webpack.desktop.js | 51 -
v2/internal/runtime/js/webpack.server.js | 54 -
v2/internal/runtime/scripts/rebuild.go | 84 -
v2/internal/webserver/routes.go | 49 -
v2/internal/webserver/webassets.go | 9 -
v2/internal/webserver/webserver.go | 87 -
v2/internal/webserver/websockets.go | 239 -
v2/pkg/commands/build/base.go | 53 -
v2/pkg/commands/build/build.go | 10 -
v2/pkg/commands/build/builder.go | 2 -
v2/pkg/commands/build/desktop.go | 128 -
v2/pkg/commands/build/desktop_darwin.go | 212 -
v2/pkg/commands/build/desktop_linux.go | 232 -
v2/pkg/commands/build/desktop_windows.go | 200 -
v2/pkg/commands/build/hybrid.go | 95 -
.../internal/packager/icons/dialog/README.md | 3 -
.../internal/packager/icons/dialog/build.go | 100 -
.../packager/icons/dialog/info-dark.png | Bin 780 -> 0 bytes
.../packager/icons/dialog/info-dark2x.png | Bin 1295 -> 0 bytes
.../packager/icons/dialog/info-light.png | Bin 764 -> 0 bytes
.../packager/icons/dialog/info-light2x.png | Bin 1293 -> 0 bytes
.../packager/icons/dialog/question-dark.png | Bin 941 -> 0 bytes
.../packager/icons/dialog/question-dark2x.png | Bin 1557 -> 0 bytes
.../packager/icons/dialog/question-light.png | Bin 930 -> 0 bytes
.../icons/dialog/question-light2x.png | Bin 1538 -> 0 bytes
.../packager/icons/dialog/warning-dark.png | Bin 830 -> 0 bytes
.../packager/icons/dialog/warning-dark2x.png | Bin 1274 -> 0 bytes
.../packager/icons/dialog/warning-light.png | Bin 720 -> 0 bytes
.../packager/icons/dialog/warning-light2x.png | Bin 1262 -> 0 bytes
v2/pkg/commands/build/packager_linux.go | 108 -
.../commands/build/server-assetdb.go.template | 11 -
v2/pkg/commands/build/server.go | 112 -
v2/pkg/parser/applicationVariableName.go | 50 -
v2/pkg/parser/comments.go | 21 -
v2/pkg/parser/conversion.go | 156 -
v2/pkg/parser/field.go | 309 -
v2/pkg/parser/findBoundStructs.go | 152 -
v2/pkg/parser/generate.go | 250 -
v2/pkg/parser/getFunctionReturnType.go | 69 -
v2/pkg/parser/globals.d.template | 27 -
v2/pkg/parser/index.d.template | 7 -
v2/pkg/parser/index.template | 13 -
v2/pkg/parser/method.go | 174 -
v2/pkg/parser/package.d copy.template | 31 -
v2/pkg/parser/package.d.template | 42 -
v2/pkg/parser/package.go | 152 -
v2/pkg/parser/package.json | 13 -
v2/pkg/parser/package.template | 44 -
v2/pkg/parser/parseBoundStructs.go | 75 -
v2/pkg/parser/parseStructFields.go | 35 -
v2/pkg/parser/parser.go | 122 -
v2/pkg/parser/resolvePackageReferences.go | 35 -
v2/pkg/parser/struct.go | 68 -
v2/pkg/parser/testproject/basic.go | 66 -
v2/pkg/parser/testproject/go.mod | 9 -
v2/pkg/parser/testproject/go.sum | 83 -
v2/pkg/parser/testproject/main.go | 21 -
.../parser/testproject/mypackage/mypackage.go | 36 -
144 files changed, 1 insertion(+), 18455 deletions(-)
delete mode 100644 v2/internal/app/debug.go
delete mode 100644 v2/internal/app/default.go
delete mode 100644 v2/internal/app/desktop.go
delete mode 100644 v2/internal/app/dev.go
delete mode 100644 v2/internal/app/hybrid.go
delete mode 100644 v2/internal/app/preflight_default.go
delete mode 100644 v2/internal/app/preflight_windows.go
delete mode 100644 v2/internal/app/production.go
delete mode 100644 v2/internal/app/server.go
delete mode 100644 v2/internal/assetdb/assetdb.go
delete mode 100644 v2/internal/assetdb/assetdb_test.go
delete mode 100644 v2/internal/assetdb/filesystem.go
delete mode 100644 v2/internal/assetdb/filesystem_test.go
delete mode 100644 v2/internal/bind/bind.go
delete mode 100644 v2/internal/bridge/bridge.go
delete mode 100644 v2/internal/bridge/client.go
delete mode 100644 v2/internal/bridge/darwin.js
delete mode 100644 v2/internal/bridge/dialog_client.go
delete mode 100644 v2/internal/bridge/linux.js
delete mode 100644 v2/internal/bridge/session.go
delete mode 100644 v2/internal/bridge/windows.js
delete mode 100644 v2/internal/deepcopy/LICENSE
delete mode 100644 v2/internal/deepcopy/deepcopy.go
delete mode 100644 v2/internal/deepcopy/deepcopy_test.go
delete mode 100644 v2/internal/html/asset.go
delete mode 100644 v2/internal/html/asset_test.go
delete mode 100644 v2/internal/html/assetbundle.go
delete mode 100644 v2/internal/html/assetbundle_test.go
delete mode 100644 v2/internal/html/testdata/basic.html
delete mode 100644 v2/internal/html/testdata/inline_javascript.html
delete mode 100644 v2/internal/html/testdata/multi_line.html
delete mode 100644 v2/internal/html/testdata/self_closing.html
delete mode 100644 v2/internal/html/testdata/src/bundle.js
delete mode 100644 v2/internal/html/testdata/src/favicon.svg
delete mode 100644 v2/internal/html/testdata/src/style.css
delete mode 100644 v2/internal/runtime/assets/assets.go
delete mode 100644 v2/internal/runtime/assets/desktop_darwin.js
delete mode 100644 v2/internal/runtime/assets/desktop_linux.js
delete mode 100644 v2/internal/runtime/assets/desktop_windows.js
delete mode 100644 v2/internal/runtime/assets/wails.js
delete mode 100644 v2/internal/runtime/js/.eslintrc
delete mode 100644 v2/internal/runtime/js/babel.config.js
delete mode 100644 v2/internal/runtime/js/core/bindings.js
delete mode 100644 v2/internal/runtime/js/core/calls.js
delete mode 100644 v2/internal/runtime/js/core/desktop.js
delete mode 100644 v2/internal/runtime/js/core/events.js
delete mode 100644 v2/internal/runtime/js/core/log.js
delete mode 100644 v2/internal/runtime/js/core/main.js
delete mode 100644 v2/internal/runtime/js/core/utils.js
delete mode 100644 v2/internal/runtime/js/desktop/common.js
delete mode 100644 v2/internal/runtime/js/desktop/darwin.js
delete mode 100644 v2/internal/runtime/js/desktop/ipc.js
delete mode 100644 v2/internal/runtime/js/desktop/linux.js
delete mode 100644 v2/internal/runtime/js/desktop/windows.js
delete mode 100644 v2/internal/runtime/js/package.json
delete mode 100644 v2/internal/runtime/js/package.json.md5
delete mode 100644 v2/internal/runtime/js/runtime/.npmignore
delete mode 100644 v2/internal/runtime/js/runtime/README.md
delete mode 100644 v2/internal/runtime/js/runtime/bridge.js
delete mode 100644 v2/internal/runtime/js/runtime/events.js
delete mode 100644 v2/internal/runtime/js/runtime/init.js
delete mode 100644 v2/internal/runtime/js/runtime/log.js
delete mode 100644 v2/internal/runtime/js/runtime/main.js
delete mode 100644 v2/internal/runtime/js/runtime/package-lock.json
delete mode 100644 v2/internal/runtime/js/runtime/package.json
delete mode 100644 v2/internal/runtime/js/runtime/runtime.d.ts
delete mode 100644 v2/internal/runtime/js/runtime/src/Menu.svelte
delete mode 100644 v2/internal/runtime/js/runtime/src/Menubar.svelte
delete mode 100644 v2/internal/runtime/js/runtime/src/Overlay.svelte
delete mode 100644 v2/internal/runtime/js/runtime/src/TrayMenu.svelte
delete mode 100644 v2/internal/runtime/js/runtime/src/log.js
delete mode 100644 v2/internal/runtime/js/runtime/src/main.js
delete mode 100644 v2/internal/runtime/js/runtime/src/package-lock.json
delete mode 100644 v2/internal/runtime/js/runtime/src/package.json
delete mode 100644 v2/internal/runtime/js/runtime/src/rollup.config.js
delete mode 100644 v2/internal/runtime/js/runtime/src/store.js
delete mode 100644 v2/internal/runtime/js/runtime/src/websocket.js
delete mode 100644 v2/internal/runtime/js/server/darwin.js
delete mode 100644 v2/internal/runtime/js/server/ipc.js
delete mode 100644 v2/internal/runtime/js/server/linux.js
delete mode 100644 v2/internal/runtime/js/webpack.config.js
delete mode 100644 v2/internal/runtime/js/webpack.desktop.js
delete mode 100644 v2/internal/runtime/js/webpack.server.js
delete mode 100644 v2/internal/runtime/scripts/rebuild.go
delete mode 100644 v2/internal/webserver/routes.go
delete mode 100644 v2/internal/webserver/webassets.go
delete mode 100644 v2/internal/webserver/webserver.go
delete mode 100644 v2/internal/webserver/websockets.go
delete mode 100644 v2/pkg/commands/build/desktop_darwin.go
delete mode 100644 v2/pkg/commands/build/desktop_linux.go
delete mode 100644 v2/pkg/commands/build/desktop_windows.go
delete mode 100644 v2/pkg/commands/build/hybrid.go
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/README.md
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/build.go
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/info-dark.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/info-dark2x.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/info-light.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/info-light2x.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/question-dark.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/question-dark2x.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/question-light.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/question-light2x.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/warning-dark.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/warning-dark2x.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/warning-light.png
delete mode 100644 v2/pkg/commands/build/internal/packager/icons/dialog/warning-light2x.png
delete mode 100644 v2/pkg/commands/build/server-assetdb.go.template
delete mode 100644 v2/pkg/commands/build/server.go
delete mode 100644 v2/pkg/parser/applicationVariableName.go
delete mode 100644 v2/pkg/parser/comments.go
delete mode 100644 v2/pkg/parser/conversion.go
delete mode 100644 v2/pkg/parser/field.go
delete mode 100644 v2/pkg/parser/findBoundStructs.go
delete mode 100644 v2/pkg/parser/generate.go
delete mode 100644 v2/pkg/parser/getFunctionReturnType.go
delete mode 100644 v2/pkg/parser/globals.d.template
delete mode 100644 v2/pkg/parser/index.d.template
delete mode 100644 v2/pkg/parser/index.template
delete mode 100644 v2/pkg/parser/method.go
delete mode 100644 v2/pkg/parser/package.d copy.template
delete mode 100644 v2/pkg/parser/package.d.template
delete mode 100644 v2/pkg/parser/package.go
delete mode 100644 v2/pkg/parser/package.json
delete mode 100644 v2/pkg/parser/package.template
delete mode 100644 v2/pkg/parser/parseBoundStructs.go
delete mode 100644 v2/pkg/parser/parseStructFields.go
delete mode 100644 v2/pkg/parser/parser.go
delete mode 100644 v2/pkg/parser/resolvePackageReferences.go
delete mode 100644 v2/pkg/parser/struct.go
delete mode 100644 v2/pkg/parser/testproject/basic.go
delete mode 100644 v2/pkg/parser/testproject/go.mod
delete mode 100644 v2/pkg/parser/testproject/go.sum
delete mode 100644 v2/pkg/parser/testproject/main.go
delete mode 100644 v2/pkg/parser/testproject/mypackage/mypackage.go
diff --git a/v2/cmd/wails/internal/commands/generate/template/base/go.tmpl.mod b/v2/cmd/wails/internal/commands/generate/template/base/go.tmpl.mod
index d3dd6ecd..2b2c9dc9 100644
--- a/v2/cmd/wails/internal/commands/generate/template/base/go.tmpl.mod
+++ b/v2/cmd/wails/internal/commands/generate/template/base/go.tmpl.mod
@@ -19,10 +19,8 @@ module changeme
github.com/leaanthony/debme v1.2.1 // indirect
github.com/leaanthony/go-ansi-parser v1.0.1 // indirect
github.com/leaanthony/go-common-file-dialog v1.0.3 // indirect
- github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/go-webview2 v0.0.0-20210914103035-f00aa774a934 // indirect
github.com/leaanthony/slicer v1.5.0 // indirect
github.com/leaanthony/typescriptify-golang-structs v0.1.7 // indirect
- github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc v0.0.0-20210921073452-54963136bf18 // indirect
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/savsgio/gotils v0.0.0-20200117113501-90175b0fbe3f // indirect
diff --git a/v2/cmd/wails/internal/commands/initialise/templates/templates/svelte/go.mod.tmpl b/v2/cmd/wails/internal/commands/initialise/templates/templates/svelte/go.mod.tmpl
index 06f70133..3b74eb32 100644
--- a/v2/cmd/wails/internal/commands/initialise/templates/templates/svelte/go.mod.tmpl
+++ b/v2/cmd/wails/internal/commands/initialise/templates/templates/svelte/go.mod.tmpl
@@ -19,10 +19,8 @@ github.com/klauspost/compress v1.12.2 // indirect
github.com/leaanthony/debme v1.2.1 // indirect
github.com/leaanthony/go-ansi-parser v1.0.1 // indirect
github.com/leaanthony/go-common-file-dialog v1.0.3 // indirect
-github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/go-webview2 v0.0.0-20210914103035-f00aa774a934 // indirect
github.com/leaanthony/slicer v1.5.0 // indirect
github.com/leaanthony/typescriptify-golang-structs v0.1.7 // indirect
-github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc v0.0.0-20210921073452-54963136bf18 // indirect
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/savsgio/gotils v0.0.0-20200117113501-90175b0fbe3f // indirect
diff --git a/v2/cmd/wails/internal/commands/initialise/templates/templates/vanilla/go.mod.tmpl b/v2/cmd/wails/internal/commands/initialise/templates/templates/vanilla/go.mod.tmpl
index 06f70133..3b74eb32 100644
--- a/v2/cmd/wails/internal/commands/initialise/templates/templates/vanilla/go.mod.tmpl
+++ b/v2/cmd/wails/internal/commands/initialise/templates/templates/vanilla/go.mod.tmpl
@@ -19,10 +19,8 @@ github.com/klauspost/compress v1.12.2 // indirect
github.com/leaanthony/debme v1.2.1 // indirect
github.com/leaanthony/go-ansi-parser v1.0.1 // indirect
github.com/leaanthony/go-common-file-dialog v1.0.3 // indirect
-github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/go-webview2 v0.0.0-20210914103035-f00aa774a934 // indirect
github.com/leaanthony/slicer v1.5.0 // indirect
github.com/leaanthony/typescriptify-golang-structs v0.1.7 // indirect
-github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc v0.0.0-20210921073452-54963136bf18 // indirect
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/savsgio/gotils v0.0.0-20200117113501-90175b0fbe3f // indirect
diff --git a/v2/internal/app/debug.go b/v2/internal/app/debug.go
deleted file mode 100644
index 3a6a6916..00000000
--- a/v2/internal/app/debug.go
+++ /dev/null
@@ -1,37 +0,0 @@
-//go:build dev
-// +build dev
-
-package app
-
-import (
- "flag"
- "strings"
-
- "github.com/wailsapp/wails/v2/pkg/logger"
-)
-
-// Init initialises the application for a debug environment
-func (a *App) Init() error {
- // Indicate debug mode
- a.debug = true
-
- // Set log levels
- loglevel := flag.String("loglevel", "debug", "Loglevel to use - Trace, Debug, Info, Warning, Error")
- flag.Parse()
- if len(*loglevel) > 0 {
- switch strings.ToLower(*loglevel) {
- case "trace":
- a.logger.SetLogLevel(logger.TRACE)
- case "info":
- a.logger.SetLogLevel(logger.INFO)
- case "warning":
- a.logger.SetLogLevel(logger.WARNING)
- case "error":
- a.logger.SetLogLevel(logger.ERROR)
- default:
- a.logger.SetLogLevel(logger.DEBUG)
- }
- }
-
- return nil
-}
diff --git a/v2/internal/app/default.go b/v2/internal/app/default.go
deleted file mode 100644
index 31f173cf..00000000
--- a/v2/internal/app/default.go
+++ /dev/null
@@ -1,42 +0,0 @@
-//go:build !desktop && !hybrid && !server && !dev
-// +build !desktop,!hybrid,!server,!dev
-
-package app
-
-// This is the default application that will get run if the user compiles using `go build`.
-// The reason we want to prevent that is that the `wails build` command does a lot of behind
-// the scenes work such as asset compilation. If we allow `go build`, the state of these assets
-// will be unknown and the application will not work as expected.
-
-import (
- "os"
-
- "github.com/wailsapp/wails/v2/internal/logger"
-
- "github.com/wailsapp/wails/v2/pkg/options"
-)
-
-// App defines a Wails application structure
-type App struct {
- Title string
- Width int
- Height int
- Resizable bool
-
- // Indicates if the app is running in debug mode
- debug bool
-
- logger *logger.Logger
-}
-
-// CreateApp returns a null application
-func CreateApp(_ *options.App) (*App, error) {
- return &App{}, nil
-}
-
-// Run the application
-func (a *App) Run() error {
- println(`FATAL: This application was built using "go build". This is unsupported. Please compile using "wails build".`)
- os.Exit(1)
- return nil
-}
diff --git a/v2/internal/app/desktop.go b/v2/internal/app/desktop.go
deleted file mode 100644
index b27f9291..00000000
--- a/v2/internal/app/desktop.go
+++ /dev/null
@@ -1,256 +0,0 @@
-//go:build desktop && !server
-// +build desktop,!server
-
-package app
-
-import (
- "context"
- "sync"
-
- "github.com/wailsapp/wails/v2/internal/binding"
- "github.com/wailsapp/wails/v2/internal/ffenestri"
- "github.com/wailsapp/wails/v2/internal/logger"
- "github.com/wailsapp/wails/v2/internal/menumanager"
- "github.com/wailsapp/wails/v2/internal/messagedispatcher"
- "github.com/wailsapp/wails/v2/internal/servicebus"
- "github.com/wailsapp/wails/v2/internal/signal"
- "github.com/wailsapp/wails/v2/internal/subsystem"
- "github.com/wailsapp/wails/v2/pkg/options"
-)
-
-// App defines a Wails application structure
-type App struct {
- appType string
-
- window *ffenestri.Application
- servicebus *servicebus.ServiceBus
- logger *logger.Logger
- signal *signal.Manager
- options *options.App
-
- // Subsystems
- log *subsystem.Log
- runtime *subsystem.Runtime
- event *subsystem.Event
- //binding *subsystem.Binding
- call *subsystem.Call
- menu *subsystem.Menu
- url *subsystem.URL
- dispatcher *messagedispatcher.Dispatcher
-
- menuManager *menumanager.Manager
-
- // Indicates if the app is in debug mode
- debug bool
-
- // This is our binding DB
- bindings *binding.Bindings
-
- // OnStartup/OnShutdown
- startupCallback func(ctx context.Context)
- shutdownCallback func()
-}
-
-// Create App
-func CreateApp(appoptions *options.App) (*App, error) {
-
- // Merge default options
- options.MergeDefaults(appoptions)
-
- // Set up logger
- myLogger := logger.New(appoptions.Logger)
- myLogger.SetLogLevel(appoptions.LogLevel)
-
- // Create the menu manager
- menuManager := menumanager.NewManager()
-
- // Process the application menu
- appMenu := options.GetApplicationMenu(appoptions)
- menuManager.SetApplicationMenu(appMenu)
-
- // Process context menus
- contextMenus := options.GetContextMenus(appoptions)
- for _, contextMenu := range contextMenus {
- menuManager.AddContextMenu(contextMenu)
- }
-
- // Process tray menus
- trayMenus := options.GetTrayMenus(appoptions)
- for _, trayMenu := range trayMenus {
- menuManager.AddTrayMenu(trayMenu)
- }
-
- window := ffenestri.NewApplicationWithConfig(appoptions, myLogger, menuManager)
-
- // Create binding exemptions - Ugly hack. There must be a better way
- bindingExemptions := []interface{}{appoptions.OnStartup, appoptions.OnShutdown, appoptions.OnDomReady}
-
- result := &App{
- appType: "desktop",
- window: window,
- servicebus: servicebus.New(myLogger),
- logger: myLogger,
- bindings: binding.NewBindings(myLogger, appoptions.Bind, bindingExemptions),
- menuManager: menuManager,
- startupCallback: appoptions.OnStartup,
- shutdownCallback: appoptions.OnShutdown,
- }
-
- result.options = appoptions
-
- // Initialise the app
- err := result.Init()
- if err != nil {
- return nil, err
- }
-
- // Preflight Checks
- err = result.PreflightChecks(appoptions)
- if err != nil {
- return nil, err
- }
-
- return result, nil
-
-}
-
-// Run the application
-func (a *App) Run() error {
-
- var err error
-
- // Setup a context
- var subsystemWaitGroup sync.WaitGroup
- parentContext := context.WithValue(context.Background(), "waitgroup", &subsystemWaitGroup)
- ctx, cancel := context.WithCancel(parentContext)
-
- // Start the service bus
- a.servicebus.Debug()
- err = a.servicebus.Start()
- if err != nil {
- return err
- }
-
- runtimesubsystem, err := subsystem.NewRuntime(ctx, a.servicebus, a.logger, a.startupCallback)
- if err != nil {
- return err
- }
- a.runtime = runtimesubsystem
- err = a.runtime.Start()
- if err != nil {
- return err
- }
-
- // Start the logging subsystem
- log, err := subsystem.NewLog(a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.log = log
- err = a.log.Start()
- if err != nil {
- return err
- }
-
- // create the dispatcher
- dispatcher, err := messagedispatcher.New(a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.dispatcher = dispatcher
- err = dispatcher.Start()
- if err != nil {
- return err
- }
-
- if a.options.Mac.URLHandlers != nil {
- // Start the url handler subsystem
- url, err := subsystem.NewURL(a.servicebus, a.logger, a.options.Mac.URLHandlers)
- if err != nil {
- return err
- }
- a.url = url
- err = a.url.Start()
- if err != nil {
- return err
- }
- }
-
- // Start the eventing subsystem
- eventsubsystem, err := subsystem.NewEvent(ctx, a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.event = eventsubsystem
- err = a.event.Start()
- if err != nil {
- return err
- }
-
- // Start the menu subsystem
- menusubsystem, err := subsystem.NewMenu(ctx, a.servicebus, a.logger, a.menuManager)
- if err != nil {
- return err
- }
- a.menu = menusubsystem
- err = a.menu.Start()
- if err != nil {
- return err
- }
-
- // Start the call subsystem
- callSubsystem, err := subsystem.NewCall(ctx, a.servicebus, a.logger, a.bindings.DB())
- if err != nil {
- return err
- }
- a.call = callSubsystem
- err = a.call.Start()
- if err != nil {
- return err
- }
-
- // Dump bindings as a debug
- bindingDump, err := a.bindings.ToJSON()
- if err != nil {
- return err
- }
-
- // Setup signal handler
- signalsubsystem, err := signal.NewManager(ctx, cancel, a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.signal = signalsubsystem
- a.signal.Start()
-
- err = a.window.Run(dispatcher, bindingDump, a.debug)
- a.logger.Trace("Ffenestri.Run() exited")
- if err != nil {
- return err
- }
-
- // Close down all the subsystems
- a.logger.Trace("Cancelling subsystems")
- cancel()
- subsystemWaitGroup.Wait()
-
- a.logger.Trace("Cancelling dispatcher")
- dispatcher.Close()
-
- // Close log
- a.logger.Trace("Stopping log")
- log.Close()
-
- a.logger.Trace("Stopping Service bus")
- err = a.servicebus.Stop()
- if err != nil {
- return err
- }
-
- // OnShutdown callback
- if a.shutdownCallback != nil {
- a.shutdownCallback()
- }
-
- return nil
-}
diff --git a/v2/internal/app/dev.go b/v2/internal/app/dev.go
deleted file mode 100644
index 3b7be059..00000000
--- a/v2/internal/app/dev.go
+++ /dev/null
@@ -1,249 +0,0 @@
-//go:build dev
-// +build dev
-
-package app
-
-/*
-import (
- "context"
- "sync"
-
- "github.com/wailsapp/wails/runtime"
-
- "github.com/wailsapp/wails/v2/internal/bridge"
- "github.com/wailsapp/wails/v2/internal/menumanager"
-
- "github.com/wailsapp/wails/v2/pkg/options"
-
- "github.com/wailsapp/wails/v2/internal/binding"
- "github.com/wailsapp/wails/v2/internal/logger"
- "github.com/wailsapp/wails/v2/internal/messagedispatcher"
- "github.com/wailsapp/wails/v2/internal/servicebus"
- "github.com/wailsapp/wails/v2/internal/signal"
- "github.com/wailsapp/wails/v2/internal/subsystem"
-)
-
-// App defines a Wails application structure
-type App struct {
- appType string
-
- servicebus *servicebus.ServiceBus
- logger *logger.Logger
- signal *signal.Manager
- options *options.App
-
- // Subsystems
- log *subsystem.Log
- runtime *subsystem.Runtime
- event *subsystem.Event
- //binding *subsystem.Binding
- call *subsystem.Call
- menu *subsystem.Menu
- dispatcher *messagedispatcher.Dispatcher
-
- menuManager *menumanager.Manager
-
- // Indicates if the app is in debug mode
- debug bool
-
- // This is our binding DB
- bindings *binding.Bindings
-
- // Application Stores
- loglevelStore *runtime.Store
- appconfigStore *runtime.Store
-
- // OnStartup/OnShutdown
- startupCallback func(*runtime.Runtime)
- shutdownCallback func()
-
- // Bridge
- bridge *bridge.Bridge
-}
-
-// Create App
-func CreateApp(appoptions *options.App) (*App, error) {
-
- // Merge default options
- options.MergeDefaults(appoptions)
-
- // Set up logger
- myLogger := logger.New(appoptions.Logger)
-
- // Create the menu manager
- menuManager := menumanager.NewManager()
-
- // Process the application menu
- menuManager.SetApplicationMenu(options.GetApplicationMenu(appoptions))
-
- // Process context menus
- contextMenus := options.GetContextMenus(appoptions)
- for _, contextMenu := range contextMenus {
- menuManager.AddContextMenu(contextMenu)
- }
-
- // Process tray menus
- trayMenus := options.GetTrayMenus(appoptions)
- for _, trayMenu := range trayMenus {
- menuManager.AddTrayMenu(trayMenu)
- }
-
- // Create binding exemptions - Ugly hack. There must be a better way
- bindingExemptions := []interface{}{appoptions.OnStartup, appoptions.OnShutdown, appoptions.OnDomReady}
-
- result := &App{
- appType: "dev",
- bindings: binding.NewBindings(myLogger, appoptions.Bind, bindingExemptions),
- logger: myLogger,
- servicebus: servicebus.New(myLogger),
- startupCallback: appoptions.OnStartup,
- shutdownCallback: appoptions.OnShutdown,
- bridge: bridge.NewBridge(myLogger),
- menuManager: menuManager,
- }
-
- result.options = appoptions
-
- // Initialise the app
- err := result.Init()
-
- return result, err
-
-}
-
-// Run the application
-func (a *App) Run() error {
-
- var err error
-
- // Setup a context
- var subsystemWaitGroup sync.WaitGroup
- parentContext := context.WithValue(context.Background(), "waitgroup", &subsystemWaitGroup)
- ctx, cancel := context.WithCancel(parentContext)
- defer cancel()
-
- // Start the service bus
- a.servicebus.Debug()
- err = a.servicebus.Start()
- if err != nil {
- return err
- }
-
- runtimesubsystem, err := subsystem.NewRuntime(ctx, a.servicebus, a.logger, a.startupCallback)
- if err != nil {
- return err
- }
- a.runtime = runtimesubsystem
- err = a.runtime.Start()
- if err != nil {
- return err
- }
-
- // Application Stores
- a.loglevelStore = a.runtime.GoRuntime().Store.New("wails:loglevel", a.options.LogLevel)
- a.appconfigStore = a.runtime.GoRuntime().Store.New("wails:appconfig", a.options)
-
- // Start the logging subsystem
- log, err := subsystem.NewLog(a.servicebus, a.logger, a.loglevelStore)
- if err != nil {
- return err
- }
- a.log = log
- err = a.log.Start()
- if err != nil {
- return err
- }
-
- // create the dispatcher
- dispatcher, err := messagedispatcher.New(a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.dispatcher = dispatcher
- err = dispatcher.Start()
- if err != nil {
- return err
- }
-
- // Start the eventing subsystem
- eventsubsystem, err := subsystem.NewEvent(ctx, a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.event = eventsubsystem
- err = a.event.Start()
- if err != nil {
- return err
- }
-
- // Start the menu subsystem
- menusubsystem, err := subsystem.NewMenu(ctx, a.servicebus, a.logger, a.menuManager)
- if err != nil {
- return err
- }
- a.menu = menusubsystem
- err = a.menu.Start()
- if err != nil {
- return err
- }
-
- // Start the call subsystem
- callSubsystem, err := subsystem.NewCall(ctx, a.servicebus, a.logger, a.bindings.DB())
- if err != nil {
- return err
- }
- a.call = callSubsystem
- err = a.call.Start()
- if err != nil {
- return err
- }
-
- // Dump bindings as a debug
- bindingDump, err := a.bindings.ToJSON()
- if err != nil {
- return err
- }
-
- // Generate backend.js
- a.bindings.GenerateBackendJS()
-
- // Setup signal handler
- signalsubsystem, err := signal.NewManager(ctx, cancel, a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.signal = signalsubsystem
- a.signal.Start()
-
- err = a.bridge.Run(dispatcher, a.menuManager, bindingDump, a.debug)
- a.logger.Trace("Bridge.Run() exited")
- if err != nil {
- return err
- }
-
- // Close down all the subsystems
- a.logger.Trace("Cancelling subsystems")
- cancel()
- subsystemWaitGroup.Wait()
-
- a.logger.Trace("Cancelling dispatcher")
- dispatcher.Close()
-
- // Close log
- a.logger.Trace("Stopping log")
- log.Close()
-
- a.logger.Trace("Stopping Service bus")
- err = a.servicebus.Stop()
- if err != nil {
- return err
- }
-
- // OnShutdown callback
- if a.shutdownCallback != nil {
- a.shutdownCallback()
- }
- return nil
-
-}
-*/
diff --git a/v2/internal/app/hybrid.go b/v2/internal/app/hybrid.go
deleted file mode 100644
index c9ff11df..00000000
--- a/v2/internal/app/hybrid.go
+++ /dev/null
@@ -1,195 +0,0 @@
-//go:build !server && !desktop && hybrid
-// +build !server,!desktop,hybrid
-
-package app
-
-import (
- "os"
- "path/filepath"
-
- "github.com/leaanthony/clir"
- "github.com/wailsapp/wails/v2/internal/binding"
- "github.com/wailsapp/wails/v2/internal/ffenestri"
- "github.com/wailsapp/wails/v2/internal/logger"
- "github.com/wailsapp/wails/v2/internal/messagedispatcher"
- "github.com/wailsapp/wails/v2/internal/servicebus"
- "github.com/wailsapp/wails/v2/internal/subsystem"
- "github.com/wailsapp/wails/v2/internal/webserver"
-)
-
-// Config defines the Application's configuration
-type Config struct {
- Title string // Title is the value to be displayed in the title bar
- Width int // Width is the desired window width
- Height int // Height is the desired window height
- DevTools bool // DevTools enables or disables the browser development tools
- Resizable bool // Resizable when False prevents window resizing
- ServerEnabled bool // ServerEnabled when True allows remote connections
-}
-
-// App defines a Wails application structure
-type App struct {
- config Config
- window *ffenestri.Application
- webserver *webserver.WebServer
- binding *subsystem.Binding
- call *subsystem.Call
- event *subsystem.Event
- log *subsystem.Log
- runtime *subsystem.Runtime
-
- bindings *binding.Bindings
- logger *logger.Logger
- dispatcher *messagedispatcher.Dispatcher
- servicebus *servicebus.ServiceBus
-
- debug bool
-}
-
-// Create App
-func CreateApp(options *Options) *App {
-
- // Merge default options
- options.mergeDefaults()
-
- // Set up logger
- myLogger := logger.New(os.Stdout)
- myLogger.SetLogLevel(logger.INFO)
-
- window := ffenestri.NewApplicationWithConfig(&ffenestri.Config{
- Title: options.Title,
- Width: options.Width,
- Height: options.Height,
- MinWidth: options.MinWidth,
- MinHeight: options.MinHeight,
- MaxWidth: options.MaxWidth,
- MaxHeight: options.MaxHeight,
- StartHidden: options.StartHidden,
- DevTools: options.DevTools,
-
- Resizable: !options.DisableResize,
- Fullscreen: options.Fullscreen,
- }, myLogger)
-
- app := &App{
- window: window,
- webserver: webserver.NewWebServer(myLogger),
- servicebus: servicebus.New(myLogger),
- logger: myLogger,
- bindings: binding.NewBindings(myLogger, options.Bind),
- }
-
- // Initialise the app
- app.Init()
-
- return app
-}
-
-// Run the application
-func (a *App) Run() error {
-
- // Default app options
- var port = 8080
- var ip = "localhost"
- var suppressLogging = false
-
- // Create CLI
- cli := clir.NewCli(filepath.Base(os.Args[0]), "Desktop/Server Build", "")
-
- // Setup flags
- cli.IntFlag("p", "Port to serve on", &port)
- cli.StringFlag("i", "IP to serve on", &ip)
- cli.BoolFlag("q", "Suppress logging", &suppressLogging)
-
- // Setup main action
- cli.Action(func() error {
-
- // Set IP + Port
- a.webserver.SetPort(port)
- a.webserver.SetIP(ip)
- a.webserver.SetBindings(a.bindings)
- // Log information (if we aren't suppressing it)
- if !suppressLogging {
- cli.PrintBanner()
- a.logger.Info("Running server at %s", a.webserver.URL())
- }
-
- a.servicebus.Start()
- log, err := subsystem.NewLog(a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.log = log
- a.log.Start()
- dispatcher, err := messagedispatcher.New(a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.dispatcher = dispatcher
- a.dispatcher.Start()
-
- // Start the runtime
- runtime, err := subsystem.NewRuntime(a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.runtime = runtime
- a.runtime.Start()
-
- // Start the binding subsystem
- binding, err := subsystem.NewBinding(a.servicebus, a.logger, a.bindings, runtime.GoRuntime())
- if err != nil {
- return err
- }
- a.binding = binding
- a.binding.Start()
-
- // Start the eventing subsystem
- event, err := subsystem.NewEvent(a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.event = event
- a.event.Start()
-
- // Start the call subsystem
- call, err := subsystem.NewCall(a.servicebus, a.logger, a.bindings.DB())
- if err != nil {
- return err
- }
- a.call = call
- a.call.Start()
-
- // Required so that the WailsInit functions are fired!
- runtime.GoRuntime().Events.Emit("wails:loaded")
-
- // Set IP + Port
- a.webserver.SetPort(port)
- a.webserver.SetIP(ip)
-
- // Log information (if we aren't suppressing it)
- if !suppressLogging {
- cli.PrintBanner()
- println("Running server at " + a.webserver.URL())
- }
-
- // Dump bindings as a debug
- bindingDump, err := a.bindings.ToJSON()
- if err != nil {
- return err
- }
-
- go func() {
- if err := a.webserver.Start(dispatcher, event); err != nil {
- a.logger.Error("Webserver failed to start %s", err)
- }
- }()
-
- result := a.window.Run(dispatcher, bindingDump)
- a.servicebus.Stop()
-
- return result
- })
-
- return cli.Run()
-}
diff --git a/v2/internal/app/preflight_default.go b/v2/internal/app/preflight_default.go
deleted file mode 100644
index 00197098..00000000
--- a/v2/internal/app/preflight_default.go
+++ /dev/null
@@ -1,10 +0,0 @@
-//go:build !windows
-// +build !windows
-
-package app
-
-import "github.com/wailsapp/wails/v2/pkg/options"
-
-func (a *App) PreflightChecks(options *options.App) error {
- return nil
-}
diff --git a/v2/internal/app/preflight_windows.go b/v2/internal/app/preflight_windows.go
deleted file mode 100644
index f8e99497..00000000
--- a/v2/internal/app/preflight_windows.go
+++ /dev/null
@@ -1,27 +0,0 @@
-//go:build windows
-// +build windows
-
-package app
-
-import (
- "github.com/wailsapp/wails/v2/internal/ffenestri/windows/wv2runtime"
- "github.com/wailsapp/wails/v2/pkg/options"
-)
-
-func (a *App) PreflightChecks(options *options.App) error {
-
- _ = options
-
- // Process the webview2 runtime situation. We can pass a strategy in via the `webview2` flag for `wails build`.
- // This will determine how wv2runtime.Process will handle a lack of valid runtime.
- installedVersion, err := wv2runtime.Process()
- if installedVersion != nil {
- a.logger.Debug("WebView2 Runtime installed: Name: '%s' Version:'%s' Location:'%s'. Minimum version required: %s.",
- installedVersion.Name, installedVersion.Version, installedVersion.Location, wv2runtime.MinimumRuntimeVersion)
- }
- if err != nil {
- return err
- }
-
- return nil
-}
diff --git a/v2/internal/app/production.go b/v2/internal/app/production.go
deleted file mode 100644
index 9a255482..00000000
--- a/v2/internal/app/production.go
+++ /dev/null
@@ -1,12 +0,0 @@
-//go:build production
-// +build production
-
-package app
-
-import "github.com/wailsapp/wails/v2/pkg/logger"
-
-// Init initialises the application for a production environment
-func (a *App) Init() error {
- a.logger.SetLogLevel(logger.ERROR)
- return nil
-}
diff --git a/v2/internal/app/server.go b/v2/internal/app/server.go
deleted file mode 100644
index 06734f0a..00000000
--- a/v2/internal/app/server.go
+++ /dev/null
@@ -1,165 +0,0 @@
-//go:build server && !desktop
-// +build server,!desktop
-
-package app
-
-import (
- "context"
- "os"
- "path/filepath"
-
- "github.com/wailsapp/wails/v2/pkg/options"
-
- "github.com/leaanthony/clir"
- "github.com/wailsapp/wails/v2/internal/binding"
- "github.com/wailsapp/wails/v2/internal/logger"
- "github.com/wailsapp/wails/v2/internal/messagedispatcher"
- "github.com/wailsapp/wails/v2/internal/servicebus"
- "github.com/wailsapp/wails/v2/internal/subsystem"
- "github.com/wailsapp/wails/v2/internal/webserver"
-)
-
-// App defines a Wails application structure
-type App struct {
- appType string
-
- binding *subsystem.Binding
- call *subsystem.Call
- event *subsystem.Event
- log *subsystem.Log
-
- options *options.App
-
- bindings *binding.Bindings
- logger *logger.Logger
- dispatcher *messagedispatcher.Dispatcher
- servicebus *servicebus.ServiceBus
- webserver *webserver.WebServer
-
- debug bool
-
- // OnStartup/OnShutdown
- startupCallback func(ctx context.Context)
- shutdownCallback func()
-}
-
-// Create App
-func CreateApp(appoptions *options.App) (*App, error) {
-
- // Merge default options
- options.MergeDefaults(appoptions)
-
- // Set up logger
- myLogger := logger.New(appoptions.Logger)
- myLogger.SetLogLevel(appoptions.LogLevel)
-
- result := &App{
- appType: "server",
- bindings: binding.NewBindings(myLogger, options.Bind),
- logger: myLogger,
- servicebus: servicebus.New(myLogger),
- webserver: webserver.NewWebServer(myLogger),
- startupCallback: appoptions.OnStartup,
- shutdownCallback: appoptions.OnShutdown,
- }
-
- // Initialise app
- result.Init()
-
- return result, nil
-}
-
-// Run the application
-func (a *App) Run() error {
-
- // Default app options
- var port = 8080
- var ip = "localhost"
- var SuppressLogging = false
- var debugMode = false
-
- // Create CLI
- cli := clir.NewCli(filepath.Base(os.Args[0]), "Server Build", "")
-
- // Setup flags
- cli.IntFlag("p", "Port to serve on", &port)
- cli.StringFlag("i", "IP to serve on", &ip)
- cli.BoolFlag("d", "Debug mode", &debugMode)
- cli.BoolFlag("q", "Suppress logging", &SuppressLogging)
-
- // Setup main action
- cli.Action(func() error {
-
- // Set IP + Port
- a.webserver.SetPort(port)
- a.webserver.SetIP(ip)
- a.webserver.SetBindings(a.bindings)
- // Log information (if we aren't Suppressing it)
- if !SuppressLogging {
- cli.PrintBanner()
- a.logger.Info("Running server at %s", a.webserver.URL())
- }
-
- if debugMode {
- a.servicebus.Debug()
- }
-
- // Start the runtime
- runtime, err := subsystem.NewRuntime(a.servicebus, a.logger, a.startupCallback)
- if err != nil {
- return err
- }
- a.runtime = runtime
- a.runtime.Start()
-
- a.servicebus.Start()
- log, err := subsystem.NewLog(a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.log = log
- a.log.Start()
- dispatcher, err := messagedispatcher.New(a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.dispatcher = dispatcher
- a.dispatcher.Start()
-
- // Start the binding subsystem
- binding, err := subsystem.NewBinding(a.servicebus, a.logger, a.bindings)
- if err != nil {
- return err
- }
- a.binding = binding
- a.binding.Start()
-
- // Start the eventing subsystem
- event, err := subsystem.NewEvent(a.servicebus, a.logger)
- if err != nil {
- return err
- }
- a.event = event
- a.event.Start()
-
- // Start the call subsystem
- call, err := subsystem.NewCall(a.servicebus, a.logger, a.bindings.DB(), a.runtime.GoRuntime())
- if err != nil {
- return err
- }
- a.call = call
- a.call.Start()
-
- // Required so that the WailsInit functions are fired!
- runtime.GoRuntime().Events.Emit("wails:loaded")
-
- if err := a.webserver.Start(dispatcher, event); err != nil {
- a.logger.Error("Webserver failed to start %s", err)
- return err
- }
-
- return nil
- })
-
- return cli.Run()
-}
diff --git a/v2/internal/assetdb/assetdb.go b/v2/internal/assetdb/assetdb.go
deleted file mode 100644
index 54892952..00000000
--- a/v2/internal/assetdb/assetdb.go
+++ /dev/null
@@ -1,112 +0,0 @@
-package assetdb
-
-import (
- "fmt"
- "strings"
- "unsafe"
-)
-
-// AssetDB is a database for assets encoded as byte slices
-type AssetDB struct {
- db map[string][]byte
-}
-
-// NewAssetDB creates a new AssetDB and initialises a blank db
-func NewAssetDB() *AssetDB {
- return &AssetDB{
- db: make(map[string][]byte),
- }
-}
-
-// AddAsset saves the given byte slice under the given name
-func (a *AssetDB) AddAsset(name string, data []byte) {
- a.db[name] = data
-}
-
-// Remove removes the named asset
-func (a *AssetDB) Remove(name string) {
- delete(a.db, name)
-}
-
-// Asset retrieves the byte slice for the given name
-func (a *AssetDB) Read(name string) ([]byte, error) {
- result := a.db[name]
- if result == nil {
- return nil, fmt.Errorf("asset '%s' not found", name)
- }
- return result, nil
-}
-
-// AssetAsString returns the asset as a string.
-// It also returns a boolean indicating whether the asset existed or not.
-func (a *AssetDB) String(name string) (string, error) {
- asset, err := a.Read(name)
- if err != nil {
- return "", err
- }
- return *(*string)(unsafe.Pointer(&asset)), nil
-}
-
-func (a *AssetDB) Dump() {
- fmt.Printf("Assets:\n")
- for k, _ := range a.db {
- fmt.Println(k)
- }
-}
-
-// Serialize converts the entire database to a file that when compiled will
-// reconstruct the AssetDB during init()
-// name: name of the asset.AssetDB instance
-// pkg: package name placed at the top of the file
-func (a *AssetDB) Serialize(name, pkg string) string {
- var cdata strings.Builder
- // Set buffer size to 4k
- cdata.Grow(4096)
-
- // Write header
- header := `// DO NOT EDIT - Generated automatically
-package %s
-
-import "github.com/wailsapp/wails/v2/internal/assetdb"
-
-var (
- %s *assetdb.AssetDB = assetdb.NewAssetDB()
-)
-
-// AssetsDB is a clean interface to the assetdb.AssetDB struct
-type AssetsDB interface {
- Read(string) ([]byte, error)
- String(string) (string, error)
-}
-
-// Assets returns the asset database
-func Assets() AssetsDB {
- return %s
-}
-
-func init() {
-`
- cdata.WriteString(fmt.Sprintf(header, pkg, name, name))
-
- for aname, bytes := range a.db {
- cdata.WriteString(fmt.Sprintf("\t%s.AddAsset(\"%s\", []byte{",
- name,
- aname))
-
- l := len(bytes)
- if l == 0 {
- cdata.WriteString("0x00})\n")
- continue
- }
-
- // Convert each byte to hex
- for _, b := range bytes[:l-1] {
- cdata.WriteString(fmt.Sprintf("0x%x, ", b))
- }
- cdata.WriteString(fmt.Sprintf("0x%x})\n", bytes[l-1]))
- }
-
- cdata.WriteString(`}`)
-
- return cdata.String()
-}
diff --git a/v2/internal/assetdb/assetdb_test.go b/v2/internal/assetdb/assetdb_test.go
deleted file mode 100644
index b3f34b9f..00000000
--- a/v2/internal/assetdb/assetdb_test.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package assetdb
-
-import "testing"
-import "github.com/matryer/is"
-
-func TestExistsAsBytes(t *testing.T) {
-
- is := is.New(t)
-
- var helloworld = []byte{72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33}
-
- db := NewAssetDB()
- db.AddAsset("hello", helloworld)
-
- result, err := db.Read("hello")
-
- is.True(err == nil)
- is.Equal(result, helloworld)
-}
-
-func TestNotExistsAsBytes(t *testing.T) {
-
- is := is.New(t)
-
- var helloworld = []byte{72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33}
-
- db := NewAssetDB()
- db.AddAsset("hello4", helloworld)
-
- result, err := db.Read("hello")
-
- is.True(err != nil)
- is.True(result == nil)
-}
-
-func TestExistsAsString(t *testing.T) {
-
- is := is.New(t)
-
- var helloworld = []byte{72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33}
-
- db := NewAssetDB()
- db.AddAsset("hello", helloworld)
-
- result, err := db.String("hello")
-
- // Ensure it exists
- is.True(err == nil)
-
- // Ensure the string is the same as the byte slice
- is.Equal(result, "Hello, World!")
-}
-
-func TestNotExistsAsString(t *testing.T) {
-
- is := is.New(t)
-
- var helloworld = []byte{72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33}
-
- db := NewAssetDB()
- db.AddAsset("hello", helloworld)
-
- result, err := db.String("help")
-
- // Ensure it doesn't exist
- is.True(err != nil)
-
- // Ensure the string is blank
- is.Equal(result, "")
-}
diff --git a/v2/internal/assetdb/filesystem.go b/v2/internal/assetdb/filesystem.go
deleted file mode 100644
index 954d97ca..00000000
--- a/v2/internal/assetdb/filesystem.go
+++ /dev/null
@@ -1,178 +0,0 @@
-//go:build !desktop
-// +build !desktop
-
-package assetdb
-
-import (
- "errors"
- "io"
- "net/http"
- "os"
- "path"
- "sort"
- "strings"
- "time"
-)
-
-var errWhence = errors.New("Seek: invalid whence")
-var errOffset = errors.New("Seek: invalid offset")
-
-// Open implements the http.FileSystem interface for the AssetDB
-func (a *AssetDB) Open(name string) (http.File, error) {
- if name == "/" || name == "" {
- return &Entry{name: "/", dir: true, db: a}, nil
- }
-
- if data, ok := a.db[name]; ok {
- return &Entry{name: name, data: data, size: len(data)}, nil
- } else {
- for n, _ := range a.db {
- if strings.HasPrefix(n, name+"/") {
- return &Entry{name: name, db: a, dir: true}, nil
- }
- }
- }
- return &Entry{}, os.ErrNotExist
-}
-
-// readdir returns the directory entries for the requested directory
-func (a *AssetDB) readdir(name string) ([]os.FileInfo, error) {
- dir := name
- var ents []string
-
- fim := make(map[string]os.FileInfo)
- for fn, data := range a.db {
- if strings.HasPrefix(fn, dir) {
- pieces := strings.Split(fn[len(dir)+1:], "/")
- if len(pieces) == 1 {
- fim[pieces[0]] = FI{name: pieces[0], dir: false, size: len(data)}
- ents = append(ents, pieces[0])
- } else {
- fim[pieces[0]] = FI{name: pieces[0], dir: true, size: -1}
- ents = append(ents, pieces[0])
- }
- }
- }
-
- if len(ents) == 0 {
- return nil, os.ErrNotExist
- }
-
- sort.Strings(ents)
- var list []os.FileInfo
- for _, dir := range ents {
- list = append(list, fim[dir])
- }
- return list, nil
-}
-
-// Entry implements the http.File interface to allow for
-// use in the http.FileSystem implementation of AssetDB
-type Entry struct {
- name string
- data []byte
- dir bool
- size int
- db *AssetDB
- off int
-}
-
-// Close is a noop
-func (e Entry) Close() error {
- return nil
-}
-
-// Read fills the slice provided returning how many bytes were written
-// and any errors encountered
-func (e *Entry) Read(p []byte) (n int, err error) {
- if e.off >= e.size {
- return 0, io.EOF
- }
- numout := len(p)
- if numout > e.size {
- numout = e.size
- }
- for i := 0; i < numout; i++ {
- p[i] = e.data[e.off+i]
- }
- e.off += numout
- n = int(numout)
- err = nil
- return
-}
-
-// Seek seeks to the specified offset from the location specified by whence
-func (e *Entry) Seek(offset int64, whence int) (int64, error) {
- switch whence {
- default:
- return 0, errWhence
- case io.SeekStart:
- offset += 0
- case io.SeekCurrent:
- offset += int64(e.off)
- case io.SeekEnd:
- offset += int64(e.size)
- }
-
- if offset < 0 {
- return 0, errOffset
- }
- e.off = int(offset)
- return offset, nil
-}
-
-// Readdir returns the directory entries inside this entry if it is a directory
-func (e Entry) Readdir(count int) ([]os.FileInfo, error) {
- ents := []os.FileInfo{}
- if !e.dir {
- return ents, errors.New("Not a directory")
- }
- return e.db.readdir(e.name)
-}
-
-// Stat returns information about this directory entry
-func (e Entry) Stat() (os.FileInfo, error) {
- return FI{e.name, e.size, e.dir}, nil
-}
-
-// FI is the AssetDB implementation of os.FileInfo.
-type FI struct {
- name string
- size int
- dir bool
-}
-
-// IsDir returns true if this is a directory
-func (fi FI) IsDir() bool {
- return fi.dir
-}
-
-// ModTime always returns now
-func (fi FI) ModTime() time.Time {
- return time.Time{}
-}
-
-// Mode returns the file as readonly and directories
-// as world writeable and executable
-func (fi FI) Mode() os.FileMode {
- if fi.IsDir() {
- return 0755 | os.ModeDir
- }
- return 0444
-}
-
-// Name returns the name of this object without
-// any leading slashes
-func (fi FI) Name() string {
- return path.Base(fi.name)
-}
-
-// Size returns the size of this item
-func (fi FI) Size() int64 {
- return int64(fi.size)
-}
-
-// Sys returns nil
-func (fi FI) Sys() interface{} {
- return nil
-}
diff --git a/v2/internal/assetdb/filesystem_test.go b/v2/internal/assetdb/filesystem_test.go
deleted file mode 100644
index 1c2ed94a..00000000
--- a/v2/internal/assetdb/filesystem_test.go
+++ /dev/null
@@ -1,108 +0,0 @@
-package assetdb
-
-import (
- "fmt"
- "os"
- "testing"
-
- "github.com/matryer/is"
-)
-
-func TestOpenLeadingSlash(t *testing.T) {
- is := is.New(t)
-
- var helloworld = []byte{72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33}
-
- db := NewAssetDB()
- db.AddAsset("/hello", helloworld)
-
- file, err := db.Open("/hello")
- // Ensure it does exist
- is.True(err == nil)
-
- buff := make([]byte, len(helloworld))
- n, err := file.Read(buff)
- fmt.Printf("Error %v\n", err)
- is.True(err == nil)
- is.Equal(n, len(helloworld))
- result := string(buff)
-
- // Ensure the string is blank
- is.Equal(result, string(helloworld))
-}
-
-func TestOpen(t *testing.T) {
- is := is.New(t)
-
- var helloworld = []byte{72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33}
-
- db := NewAssetDB()
- db.AddAsset("/hello", helloworld)
-
- file, err := db.Open("/hello")
-
- // Ensure it does exist
- is.True(err == nil)
-
- buff := make([]byte, len(helloworld))
- n, err := file.Read(buff)
- is.True(err == nil)
- is.Equal(n, len(helloworld))
- result := string(buff)
-
- // Ensure the string is blank
- is.Equal(result, string(helloworld))
-}
-
-func TestReaddir(t *testing.T) {
- is := is.New(t)
-
- var helloworld = []byte{72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33}
-
- db := NewAssetDB()
- db.AddAsset("/hello", helloworld)
- db.AddAsset("/directory/hello", helloworld)
- db.AddAsset("/directory/subdirectory/hello", helloworld)
-
- dir, err := db.Open("/doesntexist")
- is.True(err == os.ErrNotExist)
- ents, err := dir.Readdir(-1)
- is.Equal([]os.FileInfo{}, ents)
-
- dir, err = db.Open("/")
- is.True(dir != nil)
- is.True(err == nil)
- ents, err = dir.Readdir(-1)
- is.True(err == nil)
- is.Equal(3, len(ents))
-}
-
-func TestReaddirSubdirectory(t *testing.T) {
- is := is.New(t)
-
- var helloworld = []byte{72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33}
-
- db := NewAssetDB()
- db.AddAsset("/hello", helloworld)
- db.AddAsset("/directory/hello", helloworld)
- db.AddAsset("/directory/subdirectory/hello", helloworld)
-
- expected := []os.FileInfo{
- FI{name: "hello", dir: false, size: len(helloworld)},
- FI{name: "subdirectory", dir: true, size: -1},
- }
-
- dir, err := db.Open("/directory")
- is.True(dir != nil)
- is.True(err == nil)
- ents, err := dir.Readdir(-1)
- is.Equal(expected, ents)
-
- // Check sub-subdirectory
- dir, err = db.Open("/directory/subdirectory")
- is.True(dir != nil)
- is.True(err == nil)
- ents, err = dir.Readdir(-1)
- is.True(err == nil)
- is.Equal([]os.FileInfo{FI{name: "hello", size: len(helloworld)}}, ents)
-}
diff --git a/v2/internal/bind/bind.go b/v2/internal/bind/bind.go
deleted file mode 100644
index 156fd4ce..00000000
--- a/v2/internal/bind/bind.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package bind
-
-func IsStructPointer(value interface{}) bool {
- switch t := value.(type) {
- default:
- println(t)
- }
- return false
-}
diff --git a/v2/internal/bridge/bridge.go b/v2/internal/bridge/bridge.go
deleted file mode 100644
index 1ea509d3..00000000
--- a/v2/internal/bridge/bridge.go
+++ /dev/null
@@ -1,113 +0,0 @@
-package bridge
-
-import (
- "context"
- "log"
- "net/http"
- "sync"
-
- "github.com/wailsapp/wails/v2/internal/menumanager"
-
- "github.com/wailsapp/wails/v2/internal/messagedispatcher"
-
- "github.com/gorilla/websocket"
- "github.com/wailsapp/wails/v2/internal/logger"
-)
-
-type Bridge struct {
- upgrader websocket.Upgrader
- server *http.Server
- myLogger *logger.Logger
-
- bindings string
- dispatcher *messagedispatcher.Dispatcher
-
- mu sync.Mutex
- sessions map[string]*session
-
- ctx context.Context
- cancel context.CancelFunc
-
- // Dialog client
- dialog *messagedispatcher.DispatchClient
-
- // Menus
- menumanager *menumanager.Manager
-}
-
-func NewBridge(myLogger *logger.Logger) *Bridge {
- result := &Bridge{
- myLogger: myLogger,
- upgrader: websocket.Upgrader{CheckOrigin: func(r *http.Request) bool { return true }},
- sessions: make(map[string]*session),
- }
-
- myLogger.SetLogLevel(1)
-
- ctx, cancel := context.WithCancel(context.Background())
- result.ctx = ctx
- result.cancel = cancel
- result.server = &http.Server{Addr: ":34115"}
- http.HandleFunc("/bridge", result.wsBridgeHandler)
- return result
-}
-
-func (b *Bridge) Run(dispatcher *messagedispatcher.Dispatcher, menumanager *menumanager.Manager, bindings string, debug bool) error {
-
- // Ensure we cancel the context when we shutdown
- defer b.cancel()
-
- b.bindings = bindings
- b.dispatcher = dispatcher
- b.menumanager = menumanager
-
- // Setup dialog handler
- dialogClient := NewDialogClient(b.myLogger)
- b.dialog = dispatcher.RegisterClient(dialogClient)
- dialogClient.dispatcher = b.dialog
-
- b.myLogger.Info("Bridge mode started.")
-
- err := b.server.ListenAndServe()
- if err != nil && err != http.ErrServerClosed {
- return err
- }
-
- return nil
-}
-
-func (b *Bridge) wsBridgeHandler(w http.ResponseWriter, r *http.Request) {
- c, err := b.upgrader.Upgrade(w, r, nil)
- if err != nil {
- log.Print("upgrade:", err)
- return
- }
-
- if err != nil {
- http.Error(w, "Could not open websocket connection", http.StatusBadRequest)
- }
- b.myLogger.Info("Connection from frontend accepted [%s].", c.RemoteAddr().String())
- b.startSession(c)
-
-}
-
-func (b *Bridge) startSession(conn *websocket.Conn) {
-
- // Create a new session for this connection
- s := newSession(conn, b.menumanager, b.bindings, b.dispatcher, b.myLogger, b.ctx)
-
- // Setup the close handler
- conn.SetCloseHandler(func(int, string) error {
- b.myLogger.Info("Connection dropped [%s].", s.Identifier())
- b.dispatcher.RemoveClient(s.client)
- b.mu.Lock()
- delete(b.sessions, s.Identifier())
- b.mu.Unlock()
- return nil
- })
-
- b.mu.Lock()
- go s.start(len(b.sessions) == 0)
- b.sessions[s.Identifier()] = s
- b.mu.Unlock()
-}
diff --git a/v2/internal/bridge/client.go b/v2/internal/bridge/client.go
deleted file mode 100644
index 2c2db80e..00000000
--- a/v2/internal/bridge/client.go
+++ /dev/null
@@ -1,141 +0,0 @@
-package bridge
-
-import (
- "github.com/wailsapp/wails/v2/pkg/runtime"
-)
-
-type BridgeClient struct {
- session *session
-
- // Tray menu cache to send to reconnecting clients
- messageCache chan string
-}
-
-func (b BridgeClient) DeleteTrayMenuByID(id string) {
- b.session.sendMessage("TD" + id)
-}
-
-func NewBridgeClient() *BridgeClient {
- return &BridgeClient{
- messageCache: make(chan string, 100),
- }
-}
-
-func (b BridgeClient) Quit() {
- b.session.log.Info("Quit unsupported in Bridge mode")
-}
-
-func (b BridgeClient) NotifyEvent(message string) {
- b.session.sendMessage("n" + message)
- b.session.log.Info("Notify: %s", message)
-}
-
-func (b BridgeClient) CallResult(message string) {
- b.session.sendMessage("c" + message)
-}
-
-func (b BridgeClient) OpenFileDialog(dialogOptions runtime.OpenDialogOptions, callbackID string) {
- // Handled by dialog_client
-}
-
-func (b BridgeClient) OpenMultipleFilesDialog(dialogOptions runtime.OpenDialogOptions, callbackID string) {
- // Handled by dialog_client
-}
-
-func (b BridgeClient) OpenDirectoryDialog(dialogOptions runtime.OpenDialogOptions, callbackID string) {
- // Handled by dialog_client
-}
-
-func (b BridgeClient) SaveDialog(dialogOptions runtime.SaveDialogOptions, callbackID string) {
- // Handled by dialog_client
-}
-
-func (b BridgeClient) MessageDialog(dialogOptions runtime.MessageDialogOptions, callbackID string) {
- // Handled by dialog_client
-}
-
-func (b BridgeClient) WindowSetTitle(title string) {
- b.session.log.Info("WindowSetTitle unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowShow() {
- b.session.log.Info("WindowShow unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowHide() {
- b.session.log.Info("WindowHide unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowCenter() {
- b.session.log.Info("WindowCenter unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowMaximise() {
- b.session.log.Info("WindowMaximise unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowUnmaximise() {
- b.session.log.Info("WindowUnmaximise unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowMinimise() {
- b.session.log.Info("WindowMinimise unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowUnminimise() {
- b.session.log.Info("WindowUnminimise unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowPosition(x int, y int) {
- b.session.log.Info("WindowPosition unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowSize(width int, height int) {
- b.session.log.Info("WindowSize unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowSetMinSize(width int, height int) {
- b.session.log.Info("WindowSetMinSize unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowSetMaxSize(width int, height int) {
- b.session.log.Info("WindowSetMaxSize unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowFullscreen() {
- b.session.log.Info("WindowFullscreen unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowUnfullscreen() {
- b.session.log.Info("WindowUnfullscreen unsupported in Bridge mode")
-}
-
-func (b BridgeClient) WindowSetColour(colour int) {
- b.session.log.Info("WindowSetColour unsupported in Bridge mode")
-}
-
-func (b BridgeClient) DarkModeEnabled(callbackID string) {
- b.session.log.Info("DarkModeEnabled unsupported in Bridge mode")
-}
-
-func (b BridgeClient) MenuSetApplicationMenu(menuJSON string) {
- b.session.log.Info("MenuSetApplicationMenu unsupported in Bridge mode")
-}
-
-func (b BridgeClient) SetTrayMenu(trayMenuJSON string) {
- b.session.sendMessage("TS" + trayMenuJSON)
-}
-
-func (b BridgeClient) UpdateTrayMenuLabel(trayMenuJSON string) {
- b.session.sendMessage("TU" + trayMenuJSON)
-}
-
-func (b BridgeClient) UpdateContextMenu(contextMenuJSON string) {
- b.session.log.Info("UpdateContextMenu unsupported in Bridge mode")
-}
-
-func newBridgeClient(session *session) *BridgeClient {
- return &BridgeClient{
- session: session,
- }
-}
diff --git a/v2/internal/bridge/darwin.js b/v2/internal/bridge/darwin.js
deleted file mode 100644
index 4758b4e2..00000000
--- a/v2/internal/bridge/darwin.js
+++ /dev/null
@@ -1 +0,0 @@
-var Wails=function(n){var t={};function e(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return n[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var i in n)e.d(r,i,function(t){return n[t]}.bind(null,i));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s=0)}([function(n,t,e){"use strict";e.r(t);var r={};e.r(r),e.d(r,"Trace",(function(){return v})),e.d(r,"Print",(function(){return p})),e.d(r,"Debug",(function(){return y})),e.d(r,"Info",(function(){return m})),e.d(r,"Warning",(function(){return b})),e.d(r,"Error",(function(){return g})),e.d(r,"Fatal",(function(){return h})),e.d(r,"SetLogLevel",(function(){return S})),e.d(r,"Level",(function(){return E}));var i={};e.r(i),e.d(i,"Open",(function(){return x}));var o={};e.r(o),e.d(o,"Center",(function(){return N})),e.d(o,"SetTitle",(function(){return T})),e.d(o,"Fullscreen",(function(){return j})),e.d(o,"UnFullscreen",(function(){return D})),e.d(o,"SetSize",(function(){return I})),e.d(o,"SetPosition",(function(){return P})),e.d(o,"Hide",(function(){return A})),e.d(o,"Show",(function(){return J})),e.d(o,"Maximise",(function(){return L})),e.d(o,"Unmaximise",(function(){return R})),e.d(o,"Minimise",(function(){return _})),e.d(o,"Unminimise",(function(){return F})),e.d(o,"Close",(function(){return U}));var a={};e.r(a),e.d(a,"Open",(function(){return B})),e.d(a,"Save",(function(){return H})),e.d(a,"Message",(function(){return G}));var u={};e.r(u),e.d(u,"New",(function(){return en}));var c={};e.r(c),e.d(c,"SetIcon",(function(){return rn}));var l={AppType:"desktop",Platform:function(){return"darwin"}};var s=[];function f(n){s.push(n)}function d(n){if(function(n){window.wailsInvoke(n)}(n),s.length>0)for(var t=0;t0)var a=setTimeout((function(){i(Error("Call to "+n+" timed out. Request ID: "+o))}),e);k[o]={timeoutHandle:a,reject:i,resolve:r};try{var u={name:n,args:t,callbackID:o};d("C"+JSON.stringify(u))}catch(n){console.error(n)}}))}function W(n){var t;try{t=JSON.parse(n)}catch(t){var e="Invalid JSON passed to callback: ".concat(t.message,". Message: ").concat(n);throw y(e),new Error(e)}var r=t.callbackid,i=k[r];if(!i){var o="Callback '".concat(r,"' not registered!!!");throw console.error(o),new Error(o)}clearTimeout(i.timeoutHandle),delete k[r],t.error?i.reject(t.error):i.resolve(t.result)}function M(n){var t=[].slice.apply(arguments).slice(1);return C(".wails."+n,t)}function x(n){return d("RBO"+n)}function N(){d("Wc")}function T(n){d("WT"+n)}function j(){d("WF")}function D(){d("Wf")}function I(n,t){d("Ws:"+n+":"+t)}function P(n,t){d("Wp:"+n+":"+t)}function A(){d("WH")}function J(){d("WS")}function L(){d("WM")}function R(){d("WU")}function _(){d("Wm")}function F(){d("Wu")}function U(){d("WC")}function B(n){return M("Dialog.Open",n)}function H(n){return M("Dialog.Save",n)}function G(n){return M("Dialog.Message",n)}O=window.crypto?function(){var n=new Uint32Array(1);return window.crypto.getRandomValues(n)[0]}:function(){return 9007199254740991*Math.random()},window.backend={};var q=function n(t,e){!function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),e=e||-1,this.Callback=function(n){return t.apply(null,n),-1!==e&&0===(e-=1)}},z={};function V(n,t,e){z[n]=z[n]||[];var r=new q(t,e);console.log("Pushing event listener: "+n),z[n].push(r)}function K(n,t){V(n,t)}function Q(n,t){V(n,t,1)}function X(n){var t=n.name;if(z[t]){for(var e=z[t].slice(),r=0;r0)for(var t=0;t0)var a=setTimeout((function(){i(Error("Call to "+n+" timed out. Request ID: "+o))}),e);k[o]={timeoutHandle:a,reject:i,resolve:r};try{var u={name:n,args:t,callbackID:o};d("C"+JSON.stringify(u))}catch(n){console.error(n)}}))}function W(n){var t;try{t=JSON.parse(n)}catch(t){var e="Invalid JSON passed to callback: ".concat(t.message,". Message: ").concat(n);throw y(e),new Error(e)}var r=t.callbackid,i=k[r];if(!i){var o="Callback '".concat(r,"' not registered!!!");throw console.error(o),new Error(o)}clearTimeout(i.timeoutHandle),delete k[r],t.error?i.reject(t.error):i.resolve(t.result)}function x(n){var t=[].slice.apply(arguments).slice(1);return C(".wails."+n,t)}function M(n){return d("RBO"+n)}function N(){d("Wc")}function T(n){d("WT"+n)}function j(){d("WF")}function D(){d("Wf")}function I(n,t){d("Ws:"+n+":"+t)}function P(n,t){d("Wp:"+n+":"+t)}function A(){d("WH")}function J(){d("WS")}function L(){d("WM")}function R(){d("WU")}function _(){d("Wm")}function F(){d("Wu")}function U(){d("WC")}function B(n){return x("Dialog.Open",n)}function H(n){return x("Dialog.Save",n)}function G(n){return x("Dialog.Message",n)}O=window.crypto?function(){var n=new Uint32Array(1);return window.crypto.getRandomValues(n)[0]}:function(){return 9007199254740991*Math.random()},window.backend={};var q=function n(t,e){!function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),e=e||-1,this.Callback=function(n){return t.apply(null,n),-1!==e&&0===(e-=1)}},z={};function V(n,t,e){z[n]=z[n]||[];var r=new q(t,e);console.log("Pushing event listener: "+n),z[n].push(r)}function K(n,t){V(n,t)}function Q(n,t){V(n,t,1)}function X(n){var t=n.name;if(z[t]){for(var e=z[t].slice(),r=0;r:.
-func (s *session) Identifier() string {
- if s.conn != nil {
- return s.conn.RemoteAddr().String()
- }
- return ""
-}
-
-func (s *session) sendMessage(msg string) error {
- if !s.done {
- s.writeChan <- []byte(msg)
- }
- return nil
-}
-
-func (s *session) start(firstSession bool) {
- s.log.SetLogLevel(1)
- s.log.Info("Connected to frontend.")
- go s.writePump()
-
- var wailsRuntime string
- switch runtime.GOOS {
- case "darwin":
- wailsRuntime = darwinRuntime
- case "windows":
- wailsRuntime = windowsRuntime
- case "linux":
- wailsRuntime = linuxRuntime
- default:
- log.Fatal("platform not supported")
- }
-
- bindingsMessage := "window.wailsbindings = `" + s.bindings + "`;"
- s.log.Info(bindingsMessage)
- bootstrapMessage := bindingsMessage + wailsRuntime
-
- err := s.sendMessage("b" + bootstrapMessage)
- if err != nil {
- s.log.Error(err.Error())
- }
-
- // Send menus
- traymenus, err := s.menumanager.GetTrayMenus()
- if err != nil {
- s.log.Error(err.Error())
- }
-
- for _, trayMenu := range traymenus {
- err := s.sendMessage("TS" + trayMenu)
- if err != nil {
- s.log.Error(err.Error())
- }
- }
-
- for {
- messageType, buffer, err := s.conn.ReadMessage()
- if messageType == -1 {
- return
- }
- if err != nil {
- s.log.Error("Error reading message: %v", err)
- err = s.conn.Close()
- return
- }
-
- message := string(buffer)
-
- s.log.Debug("Got message: %#v\n", message)
-
- // Dispatch message as normal
- s.client.DispatchMessage(message)
-
- if s.done {
- break
- }
- }
-}
-
-// Shutdown
-func (s *session) Shutdown() {
- err := s.conn.Close()
- if err != nil {
- s.log.Error(err.Error())
- }
- s.done = true
- s.log.Info("session %v exit", s.Identifier())
-}
-
-// writePump pulls messages from the writeChan and sends them to the client
-// since it uses a channel to read the messages the socket is protected without locks
-func (s *session) writePump() {
- s.log.Debug("Session %v - writePump start", s.Identifier())
- defer s.log.Debug("Session %v - writePump shutdown", s.Identifier())
- for {
- select {
- case <-s.ctx.Done():
- s.Shutdown()
- return
- case msg, ok := <-s.writeChan:
- err := s.conn.SetWriteDeadline(time.Now().Add(1 * time.Second))
- if err != nil {
- s.log.Error(err.Error())
- }
- if !ok {
- s.log.Debug("writeChan was closed!")
- err := s.conn.WriteMessage(websocket.CloseMessage, []byte{})
- if err != nil {
- s.log.Error(err.Error())
- }
- return
- }
-
- if err := s.conn.WriteMessage(websocket.TextMessage, msg); err != nil {
- s.log.Debug(err.Error())
- return
- }
- }
- }
-}
diff --git a/v2/internal/bridge/windows.js b/v2/internal/bridge/windows.js
deleted file mode 100644
index 281f47bf..00000000
--- a/v2/internal/bridge/windows.js
+++ /dev/null
@@ -1 +0,0 @@
-var Wails=function(n){var t={};function e(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return n[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var i in n)e.d(r,i,function(t){return n[t]}.bind(null,i));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s=0)}([function(n,t,e){"use strict";e.r(t);var r={};e.r(r),e.d(r,"Trace",(function(){return v})),e.d(r,"Print",(function(){return p})),e.d(r,"Debug",(function(){return y})),e.d(r,"Info",(function(){return m})),e.d(r,"Warning",(function(){return b})),e.d(r,"Error",(function(){return g})),e.d(r,"Fatal",(function(){return h})),e.d(r,"SetLogLevel",(function(){return S})),e.d(r,"Level",(function(){return E}));var i={};e.r(i),e.d(i,"Open",(function(){return T}));var o={};e.r(o),e.d(o,"Center",(function(){return j})),e.d(o,"SetTitle",(function(){return x})),e.d(o,"Fullscreen",(function(){return M})),e.d(o,"UnFullscreen",(function(){return I})),e.d(o,"SetSize",(function(){return D})),e.d(o,"SetPosition",(function(){return P})),e.d(o,"Hide",(function(){return A})),e.d(o,"Show",(function(){return J})),e.d(o,"Maximise",(function(){return L})),e.d(o,"Unmaximise",(function(){return R})),e.d(o,"Minimise",(function(){return _})),e.d(o,"Unminimise",(function(){return F})),e.d(o,"Close",(function(){return U}));var a={};e.r(a),e.d(a,"Open",(function(){return B})),e.d(a,"Save",(function(){return H})),e.d(a,"Message",(function(){return G}));var u={};e.r(u),e.d(u,"New",(function(){return en}));var c={};e.r(c),e.d(c,"SetIcon",(function(){return rn}));var l={AppType:"desktop",Platform:function(){return"windows"}};var s=[];function f(n){s.push(n)}function d(n){if(function(n){window.wailsInvoke(n)}(n),s.length>0)for(var t=0;t0)var a=setTimeout((function(){i(Error("Call to "+n+" timed out. Request ID: "+o))}),e);k[o]={timeoutHandle:a,reject:i,resolve:r};try{var u={name:n,args:t,callbackID:o};d("C"+JSON.stringify(u))}catch(n){console.error(n)}}))}function W(n){var t;try{t=JSON.parse(n)}catch(t){var e="Invalid JSON passed to callback: ".concat(t.message,". Message: ").concat(n);throw y(e),new Error(e)}var r=t.callbackid,i=k[r];if(!i){var o="Callback '".concat(r,"' not registered!!!");throw console.error(o),new Error(o)}clearTimeout(i.timeoutHandle),delete k[r],t.error?i.reject(t.error):i.resolve(t.result)}function N(n){var t=[].slice.apply(arguments).slice(1);return C(".wails."+n,t)}function T(n){return d("RBO"+n)}function j(){d("Wc")}function x(n){d("WT"+n)}function M(){d("WF")}function I(){d("Wf")}function D(n,t){d("Ws:"+n+":"+t)}function P(n,t){d("Wp:"+n+":"+t)}function A(){d("WH")}function J(){d("WS")}function L(){d("WM")}function R(){d("WU")}function _(){d("Wm")}function F(){d("Wu")}function U(){d("WC")}function B(n){return N("Dialog.Open",n)}function H(n){return N("Dialog.Save",n)}function G(n){return N("Dialog.Message",n)}O=window.crypto?function(){var n=new Uint32Array(1);return window.crypto.getRandomValues(n)[0]}:function(){return 9007199254740991*Math.random()},window.backend={};var q=function n(t,e){!function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),e=e||-1,this.Callback=function(n){return t.apply(null,n),-1!==e&&0===(e-=1)}},z={};function V(n,t,e){z[n]=z[n]||[];var r=new q(t,e);console.log("Pushing event listener: "+n),z[n].push(r)}function K(n,t){V(n,t)}function Q(n,t){V(n,t,1)}function X(n){var t=n.name;if(z[t]){for(var e=z[t].slice(),r=0;r`, `
-
- `, 1)
-
- url := url.URL{Path: result}
- urlString := strings.ReplaceAll(url.String(), "/", "%2f")
-
- // Save Data uRI string
- return "data:text/html;charset=utf-8," + urlString, nil
-
- case AssetTypes.CSS:
-
- // Escape CSS data
- var re = regexp.MustCompile(`\s{2,}`)
- result := re.ReplaceAllString(a.Data, ``)
- result = strings.ReplaceAll(result, "\n", "")
- result = strings.ReplaceAll(result, "\r\n", "")
- result = strings.ReplaceAll(result, "\n", "")
- result = strings.ReplaceAll(result, "\t", "")
- result = strings.ReplaceAll(result, `\`, `\\`)
- result = strings.ReplaceAll(result, `"`, `\"`)
- result = strings.ReplaceAll(result, `'`, `\'`)
- result = strings.ReplaceAll(result, ` {`, `{`)
- result = strings.ReplaceAll(result, `: `, `:`)
- return fmt.Sprintf("window.wails._.InjectCSS(\"%s\");", result), nil
-
- case AssetTypes.JS:
- m := minify.New()
- m.AddFunc("application/javascript", js.Minify)
- var err error
- result, err := m.String("application/javascript", a.Data+";")
- if err != nil {
- return "", err
- }
- return result, nil
- default:
- return "", fmt.Errorf("minification for asset type %s not implemented", a.Type)
- }
-}
-
-// AsCHexData processes the asset data so it may be used by C
-func (a *Asset) AsCHexData() string {
- dataString, err := a.minifiedData()
- if err != nil {
- log.Fatal(err)
- }
- // Get byte data of the string
- bytes := *(*[]byte)(unsafe.Pointer(&dataString))
-
- // Create a strings builder
- var cdata strings.Builder
-
- // Set buffer size to 4k
- cdata.Grow(4096)
-
- // Convert each byte to hex
- for _, b := range bytes {
- cdata.WriteString(fmt.Sprintf("0x%x, ", b))
- }
-
- return cdata.String()
-}
-
-// Dump will output the asset to the terminal
-func (a *Asset) Dump() {
- fmt.Printf("{ Type: %s, Path: %s, Data: %+v }\n", a.Type, a.Path, a.Data[:10])
-}
diff --git a/v2/internal/html/asset_test.go b/v2/internal/html/asset_test.go
deleted file mode 100644
index f743b4ba..00000000
--- a/v2/internal/html/asset_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package html
-
-import "testing"
-
-func TestAsset_minifiedData(t *testing.T) {
- type fields struct {
- Type string
- Path string
- Data string
- }
- tests := []struct {
- name string
- fields fields
- want string
- wantErr bool
- }{
- {
- name: "multi-line tag",
- fields: fields{
- Type: AssetTypes.HTML,
- Path: "foo.html",
- Data: "\n",
- },
- want: "data:text/html;charset=utf-8,%3Clink%20rel=%22stylesheet%22%20href=%22src%2ffoo.css%22%20%3E%20",
- },
- {
- name: "multi-line tag no spaces",
- fields: fields{
- Type: AssetTypes.HTML,
- Path: "foo.html",
- Data: "\n",
- },
- want: "data:text/html;charset=utf-8,%3Clink%20rel=%22stylesheet%22%20href=%22src%2ffoo.css%22%20%3E%20",
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- a := &Asset{
- Type: tt.fields.Type,
- Path: tt.fields.Path,
- Data: tt.fields.Data,
- }
- got, err := a.minifiedData()
- if (err != nil) != tt.wantErr {
- t.Errorf("Asset.minifiedData() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- if got != tt.want {
- t.Errorf("Asset.minifiedData() = %v, want %v", got, tt.want)
- }
- })
- }
-}
diff --git a/v2/internal/html/assetbundle.go b/v2/internal/html/assetbundle.go
deleted file mode 100644
index 1878357a..00000000
--- a/v2/internal/html/assetbundle.go
+++ /dev/null
@@ -1,218 +0,0 @@
-package html
-
-import (
- "bytes"
- "fmt"
- "io"
- "os"
- "path/filepath"
- "strings"
-
- "github.com/leaanthony/slicer"
- "github.com/wailsapp/wails/v2/internal/assetdb"
- "golang.org/x/net/html"
-)
-
-// AssetBundle is a collection of Assets
-type AssetBundle struct {
- assets []*Asset
- basedirectory string
-}
-
-// NewAssetBundle creates a new AssetBundle struct containing
-// the given html and all the assets referenced by it
-func NewAssetBundle(pathToHTML string) (*AssetBundle, error) {
-
- // Create result
- result := &AssetBundle{
- basedirectory: filepath.Dir(pathToHTML),
- }
-
- err := result.loadAssets(pathToHTML)
- if err != nil {
- return nil, err
- }
-
- return result, nil
-}
-
-// loadAssets processes the given html file and loads in
-// all referenced assets
-func (a *AssetBundle) loadAssets(pathToHTML string) error {
-
- // Save HTML
- htmlAsset := &Asset{
- Type: AssetTypes.HTML,
- Path: filepath.Base(pathToHTML),
- }
- err := htmlAsset.Load(a.basedirectory)
- if err != nil {
- return err
- }
- a.assets = append(a.assets, htmlAsset)
-
- return a.processHTML(htmlAsset.AsString())
-}
-
-// Credit to: https://drstearns.github.io/tutorials/tokenizing/
-func (a *AssetBundle) processHTML(htmldata string) error {
-
- // Tokenize the html
- buf := bytes.NewBufferString(htmldata)
- tokenizer := html.NewTokenizer(buf)
-
- paths := slicer.String()
-
- for {
- //get the next token type
- tokenType := tokenizer.Next()
-
- //if it's an error token, we either reached
- //the end of the file, or the HTML was malformed
- if tokenType == html.ErrorToken {
- err := tokenizer.Err()
- if err == io.EOF {
- //end of the file, break out of the loop
- break
- }
- //otherwise, there was an error tokenizing,
- //which likely means the HTML was malformed.
- //since this is a simple command-line utility,
- //we can just use log.Fatalf() to report the error
- //and exit the process with a non-zero status code
- return tokenizer.Err()
- }
-
- //process the token according to the token type...
- if tokenType == html.StartTagToken || tokenType == html.SelfClosingTagToken {
- //get the token
- token := tokenizer.Token()
-
- //if the name of the element is "title"
- if "link" == token.Data {
- //the next token should be the page title
- tokenType = tokenizer.Next()
- //just make sure it's actually a text token
- asset := &Asset{}
- for _, attr := range token.Attr {
- // Favicon
- if attr.Key == "rel" && attr.Val == "icon" {
- asset.Type = AssetTypes.FAVICON
- }
- if attr.Key == "href" {
- asset.Path = attr.Val
- }
- // standard stylesheet
- if attr.Key == "rel" && attr.Val == "stylesheet" {
- asset.Type = AssetTypes.CSS
- }
- if attr.Key == "as" && attr.Val == "style" {
- asset.Type = AssetTypes.CSS
- }
- if attr.Key == "as" && attr.Val == "script" {
- asset.Type = AssetTypes.JS
- }
- if attr.Key == "rel" && attr.Val == "modulepreload" {
- asset.Type = AssetTypes.JS
- }
- }
-
- // Ensure we don't include duplicates
- if !paths.Contains(asset.Path) {
- err := asset.Load(a.basedirectory)
- if err != nil {
- return err
- }
- a.assets = append(a.assets, asset)
- paths.Add(asset.Path)
- }
- }
- if "script" == token.Data {
- tokenType = tokenizer.Next()
- //just make sure it's actually a text token
- asset := &Asset{Type: AssetTypes.JS}
- for _, attr := range token.Attr {
- if attr.Key == "src" {
- asset.Path = attr.Val
- break
- }
- }
- if !paths.Contains(asset.Path) && asset.Path != "" {
- err := asset.Load(a.basedirectory)
- if err != nil {
- return err
- }
- a.assets = append(a.assets, asset)
- paths.Add(asset.Path)
- }
- }
- }
- }
-
- return nil
-}
-
-// WriteToCFile dumps all the assets to C files in the given directory
-func (a *AssetBundle) WriteToCFile(targetDir string) (string, error) {
-
- // Write out the assets.c file
- var cdata strings.Builder
-
- // Write header
- header := `// assets.h
-// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL.
-// This file was auto-generated. DO NOT MODIFY.
-
-`
- cdata.WriteString(header)
-
- // Loop over the Assets
- var err error
- assetVariables := slicer.String()
- var variableName string
- for index, asset := range a.assets {
- // For desktop we ignore the favicon
- if asset.Type == AssetTypes.FAVICON {
- continue
- }
- variableName = fmt.Sprintf("%s%d", asset.Type, index)
- assetCdata := fmt.Sprintf("const unsigned char %s[]={ %s0x00 };\n", variableName, asset.AsCHexData())
- cdata.WriteString(assetCdata)
- assetVariables.Add(variableName)
- }
-
- if assetVariables.Length() > 0 {
- cdata.WriteString(fmt.Sprintf("\nconst unsigned char *assets[] = { %s, 0x00 };", assetVariables.Join(", ")))
- } else {
- cdata.WriteString("\nconst unsigned char *assets[] = { 0x00 };")
- }
-
- // Save file
- assetsFile := filepath.Join(targetDir, "assets.h")
- err = os.WriteFile(assetsFile, []byte(cdata.String()), 0600)
- if err != nil {
- return "", err
- }
- return assetsFile, nil
-}
-
-// ConvertToAssetDB returns an assetdb.AssetDB initialized with
-// the items in the AssetBundle
-func (a *AssetBundle) ConvertToAssetDB() (*assetdb.AssetDB, error) {
- theassetdb := assetdb.NewAssetDB()
-
- // Loop over the Assets
- for _, asset := range a.assets {
- theassetdb.AddAsset(asset.Path, []byte(asset.Data))
- }
-
- return theassetdb, nil
-}
-
-// Dump will output the assets to the terminal
-func (a *AssetBundle) Dump() {
- println("Assets:")
- for _, asset := range a.assets {
- asset.Dump()
- }
-}
diff --git a/v2/internal/html/assetbundle_test.go b/v2/internal/html/assetbundle_test.go
deleted file mode 100644
index d1009d7a..00000000
--- a/v2/internal/html/assetbundle_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package html
-
-import (
- "testing"
-)
-
-func TestNewAssetBundle(t *testing.T) {
- tests := []struct {
- name string
- pathToHTML string
- wantAssets []string
- wantErr bool
- }{
- {
- name: "basic html",
- pathToHTML: "testdata/basic.html",
- wantAssets: []string{
- AssetTypes.HTML,
- AssetTypes.FAVICON,
- AssetTypes.JS,
- AssetTypes.CSS,
- },
- wantErr: false,
- },
- {
- name: "self closing tags",
- pathToHTML: "testdata/self_closing.html",
- wantAssets: []string{
- AssetTypes.HTML,
- AssetTypes.FAVICON,
- AssetTypes.JS,
- AssetTypes.CSS,
- },
- wantErr: false,
- },
- {
- name: "multi-line tags",
- pathToHTML: "testdata/self_closing.html",
- wantAssets: []string{
- AssetTypes.HTML,
- AssetTypes.FAVICON,
- AssetTypes.JS,
- AssetTypes.CSS,
- },
- wantErr: false,
- },
- {
- name: "inline javascript",
- pathToHTML: "testdata/inline_javascript.html",
- wantAssets: []string{
- AssetTypes.HTML,
- AssetTypes.FAVICON,
- AssetTypes.JS,
- AssetTypes.CSS,
- },
- wantErr: false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- got, err := NewAssetBundle(tt.pathToHTML)
- if (err != nil) != tt.wantErr {
- t.Errorf("NewAssetBundle() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- if len(got.assets) != len(tt.wantAssets) {
- t.Errorf("NewAssetBundle() len(assets) = %d, want %d",
- len(got.assets), len(tt.wantAssets))
- }
-
- for i := range tt.wantAssets {
- if i >= len(got.assets) {
- t.Errorf("NewAssetBundle() missing assets[%d].Type = %s",
- i, tt.wantAssets[i])
- } else {
- if got.assets[i].Type != tt.wantAssets[i] {
- t.Errorf("NewAssetBundle() assets[%d].Type = %s, want %s",
- i, got.assets[i].Type, tt.wantAssets[i])
- }
- }
- }
- })
- }
-}
diff --git a/v2/internal/html/testdata/basic.html b/v2/internal/html/testdata/basic.html
deleted file mode 100644
index cdc3770b..00000000
--- a/v2/internal/html/testdata/basic.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-