From 0577fefd753a9207a5ce24f3b8ad31b5fa0b1a66 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Thu, 12 Oct 2023 08:41:18 +1100 Subject: [PATCH] Remove Browser plugin. Update plugin example --- v3/examples/plugins/main.go | 8 ++---- v3/plugins/browser/README.md | 51 ---------------------------------- v3/plugins/browser/plugin.go | 47 ------------------------------- v3/plugins/browser/plugin.js | 25 ----------------- v3/plugins/browser/plugin.yaml | 11 -------- 5 files changed, 3 insertions(+), 139 deletions(-) delete mode 100644 v3/plugins/browser/README.md delete mode 100644 v3/plugins/browser/plugin.go delete mode 100644 v3/plugins/browser/plugin.js delete mode 100644 v3/plugins/browser/plugin.yaml diff --git a/v3/examples/plugins/main.go b/v3/examples/plugins/main.go index 1acf418be..fe02b81f7 100644 --- a/v3/examples/plugins/main.go +++ b/v3/examples/plugins/main.go @@ -6,10 +6,9 @@ import ( "plugin_demo/plugins/hashes" "github.com/wailsapp/wails/v3/pkg/application" - "github.com/wailsapp/wails/v3/plugins/browser" + "github.com/wailsapp/wails/v3/plugins/experimental/server" "github.com/wailsapp/wails/v3/plugins/kvstore" "github.com/wailsapp/wails/v3/plugins/log" - "github.com/wailsapp/wails/v3/plugins/server" "github.com/wailsapp/wails/v3/plugins/single_instance" "github.com/wailsapp/wails/v3/plugins/sqlite" "github.com/wailsapp/wails/v3/plugins/start_at_login" @@ -27,9 +26,8 @@ func main() { ApplicationShouldTerminateAfterLastWindowClosed: true, }, Plugins: map[string]application.Plugin{ - "hashes": hashes.NewPlugin(), - "browser": browser.NewPlugin(), - "log": log.NewPlugin(), + "hashes": hashes.NewPlugin(), + "log": log.NewPlugin(), "sqlite": sqlite.NewPlugin(&sqlite.Config{ DBFile: "test.db", }), diff --git a/v3/plugins/browser/README.md b/v3/plugins/browser/README.md deleted file mode 100644 index f5103d33b..000000000 --- a/v3/plugins/browser/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# Browser Plugin - -This plugin provides the ability to open a URL or local file in the default browser. - -## Installation - -Add the plugin to the `Plugins` option in the Applications options: - -```go -package main - -import ( - "github.com/wailsapp/wails/v3/pkg/application" - "github.com/wailsapp/wails/v3/plugins/browser" -) - -func main() { - browserPlugin := browser.NewPlugin() - app := application.New(application.Options{ - // ... - Plugins: map[string]application.Plugin{ - "browser": browserPlugin, - }, - }) -``` - -## Usage - -### Go - -You can call the methods exported by the plugin directly: - -```go - browserPlugin.OpenURL("https://www.google.com") - // or - browserPlugin.OpenFile("/path/to/file") -``` - -### Javascript - -You can call the methods from the frontend using the Plugin method: - -```js - wails.Plugin("browser","OpenURL","https://www.google.com") - // or - wails.Plugin("browser","OpenFile","/path/to/file") -``` - -## Support - -If you find a bug in this plugin, please raise a ticket on the Wails [Issue Tracker](https://github.com/wailsapp/wails/issues). diff --git a/v3/plugins/browser/plugin.go b/v3/plugins/browser/plugin.go deleted file mode 100644 index d9d56a4ea..000000000 --- a/v3/plugins/browser/plugin.go +++ /dev/null @@ -1,47 +0,0 @@ -package browser - -import ( - "github.com/pkg/browser" -) - -// ---------------- Plugin Setup ---------------- -// This is the main plugin struct. It can be named anything you like. -// It must implement the application.Plugin interface. -// Both the Init() and Shutdown() methods are called synchronously when the app starts and stops. - -type Plugin struct{} - -func NewPlugin() *Plugin { - return &Plugin{} -} - -func (p *Plugin) Shutdown() {} - -func (p *Plugin) Name() string { - return "github.com/wailsapp/wails/v3/plugins/browser" -} - -func (p *Plugin) Init() error { - return nil -} - -func (p *Plugin) CallableByJS() []string { - return []string{ - "OpenURL", - "OpenFile", - } -} - -func (p *Plugin) InjectJS() string { - return "" -} - -// ---------------- Plugin Methods ---------------- - -func (p *Plugin) OpenURL(url string) error { - return browser.OpenURL(url) -} - -func (p *Plugin) OpenFile(path string) error { - return browser.OpenFile(path) -} diff --git a/v3/plugins/browser/plugin.js b/v3/plugins/browser/plugin.js deleted file mode 100644 index 4448ba2d3..000000000 --- a/v3/plugins/browser/plugin.js +++ /dev/null @@ -1,25 +0,0 @@ - -/** - * Opens the given URL in the default browser. - * @param url {string} - The URL to open. - * @returns {Promise} - */ -function OpenURL(url) { - return wails.CallByID(3188315539, url); -} - -/** - * Opens the given filename in the default browser. - * @param filename {string} - The file to open. - * @returns {Promise} - */ -function OpenFile(filename) { - return wails.CallByID(3105408620, filename); -} - -export default { - Browser: { - OpenURL, - OpenFile, - } -}; diff --git a/v3/plugins/browser/plugin.yaml b/v3/plugins/browser/plugin.yaml deleted file mode 100644 index 965625073..000000000 --- a/v3/plugins/browser/plugin.yaml +++ /dev/null @@ -1,11 +0,0 @@ -# This is the plugin definition file for the "browser" plugin. ---- -Name: browser -Description: Opens URLs and files in the default browser. -Author: Lea Anthony -Version: v1.0.0 -Website: https://wails.io -Repository: https://github.com/wailsapp/wails/v3/plugins/browser -License: MIT - -