Compare commits

...

119 Commits

Author SHA1 Message Date
Lea Anthony d24d82f86d Rename exp -> v3 2023-01-18 21:34:11 +11:00
Lea Anthony 81e9223124 Merge branch 'master' into future/exp 2023-01-18 21:27:30 +11:00
Lea Anthony 18d0ed890a Merge branch 'blog/v3-roadmap' 2023-01-18 20:59:38 +11:00
Lea Anthony 2374bb7e0e Update clir 2023-01-18 20:57:31 +11:00
Lea Anthony 4c42ef9710 Create generate bindings command 2023-01-18 20:19:12 +11:00
stffabi b4d64678b5 Basic integration of the assetserver 2023-01-18 09:31:09 +01:00
Lea Anthony 2479603143 Add github issue link 2023-01-18 17:41:33 +11:00
Lea Anthony a4f729a6a0 Rename parser package.
Fix linting issues
Add README.md
2023-01-18 08:22:31 +11:00
Lea Anthony dbf6b3a718 updated 2023-01-18 07:57:10 +11:00
stffabi 45c3a501d9 [cli] Fix applying default arch to platform flag (#2309) 2023-01-17 20:39:15 +01:00
Lea Anthony 401165ce30 blog 2023-01-17 21:19:17 +11:00
Lea Anthony 8e593e9c35 Start of TS models generation support 2023-01-17 18:57:35 +11:00
Lea Anthony 0a09363db7 Support struct discovery over multiple files 2023-01-17 07:45:41 +11:00
stffabi caa0b6c804 [assetServer, darwin] Use AssetServer native WKWebView request handling (#2283) 2023-01-16 13:02:18 +01:00
stffabi 8f92cf1074 [assetHandler] Allow middleware to set the content-type for an assets file (#2286) 2023-01-16 21:05:25 +11:00
Gwyn 8c7fa4cf4c Updates all default gitignore templates to be newline terminated. (#2306)
This allows echoing new patterns to the end of the file without
causing a string concatenation error.
2023-01-16 21:02:52 +11:00
Oussama Sethoum d0bd849be6 Update events.mdx (#2300)
* Update events.mdx

* Add doc update to docs dir

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-01-16 20:59:58 +11:00
stffabi 0a98efeea9 [runtime] Improve —wails-draggable by starting a drag immediately but only for the first click in a series (#2302)
This removes the sometime lagging experience when
starting to drag on Windows. But it's still possible to use
double-click events for adding e.g. a WindowToggleMaximise.
2023-01-16 20:56:13 +11:00
github-actions[bot] 93cfc777f9 chore: update sponsors.svg (#2293)
Co-authored-by: leaanthony <leaanthony@users.noreply.github.com>
2023-01-16 20:53:31 +11:00
Lea Anthony b0b96c9838 Support struct discovery in methods 2023-01-16 20:30:05 +11:00
Lea Anthony 8bbf5ff3f1 Recursive bound model discovery implemented 2023-01-15 20:25:42 +11:00
stffabi d15e673a19 [windows] Some improvements to fullscreen (#2299) 2023-01-15 06:14:15 +01:00
Lea Anthony 572fbc9705 Initial parsing to discover bound struct names 2023-01-13 17:35:43 +11:00
Lea Anthony f371b513d1 Fix name of Window menu in role 2023-01-13 17:33:54 +11:00
Supian M ec8e9b2715 Fix Broken Badge (#2292) 2023-01-12 20:01:56 +11:00
stffabi aaf039bcff [windows] Disable frameless decorations during fullscreen (#2288)
Otherwise this leads to thin transparent lines on the window borders on older Windows versions.
2023-01-11 15:22:48 +01:00
stffabi 05679e70d0 [runtime] Frameless resize now sets the cursor on documentElement (#2289)
Otherwise if the body does not cover the full viewport the cursor won't
be shown outside of its rectangle.
2023-01-10 13:19:09 +01:00
stffabi 8e4606d104 [windows] Improve fullscreen mode for frameless windows (#2279)
* Improve fullscreen mode for frameless windows
* Set Window background color in addition to WebView2 background color
2023-01-09 12:15:43 +01:00
Lea Anthony 54ca6c7059 Refactor assetserver into pkg (#2260) 2023-01-08 11:25:21 +01:00
Lea Anthony e5d3803fc1 Initial runtime builds
Added Taskfile for fast runtime builds
2023-01-08 21:06:31 +11:00
Lea Anthony 6e3b4cf1a1 Add Warmine to showcase 2023-01-08 12:53:14 +11:00
Zámbó, Levente c3011813b0 linux separate window c and go file (#2275) 2023-01-07 16:20:11 +11:00
Johannes Haseitl ccceadbd24 Replace more slack links with discord invites (#2256)
* Add Discord link and deprecate slack links

* More slack -> discord changes

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-01-07 16:19:33 +11:00
Noah Hsu e1fc7119bc docs: fix admonitions syntax (#2263) 2023-01-07 15:36:37 +11:00
Lea Anthony 06a0377963 Fix frameless
Add rounded corners for frameless
Create NSWindow subclass
Add pre-post build hooks
2023-01-07 11:26:46 +11:00
Zámbó, Levente add10df5ff fix missing bin dir on build hook (#2273)
* fix missing bin dir on build hook

* add fix to changelog
2023-01-07 06:51:01 +11:00
Lea Anthony 62a5509390 Do not display internal tasks when using wails task list 2023-01-06 20:20:40 +11:00
Lea Anthony 54805d99a0 Remove New from Dialog methods 2023-01-06 20:19:20 +11:00
stffabi 284e20a290 Add EnableFraudulentWebsiteDetection to options (#2269)
This allows to explicitly opt-in to scan services for fraudulent
content, such as malware or phishing attempts.
2023-01-06 00:06:26 +11:00
Zámbó, Levente 0a32c1124e Add common text clipboard support (#2228) 2023-01-05 16:41:07 +11:00
Igor Sementsov fc9dd99dea Update troubleshooting.mdx (#2252)
* Update troubleshooting.mdx

https://github.com/wailsapp/wails/issues/2249

* Move guide to docs

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-01-05 16:19:49 +11:00
希嘉嘉 2727af43d4 Update templates.mdx (#2230)
添加 solid 模版的中文描述信息。
2023-01-05 16:09:53 +11:00
github-actions[bot] 4d0163d8af chore: update sponsors.svg (#2271)
Co-authored-by: leaanthony <leaanthony@users.noreply.github.com>
2023-01-05 15:12:13 +11:00
Lea Anthony d1e2ee452f Integrate Task 2023-01-05 15:02:08 +11:00
Lea Anthony b5127d95ff Add EnableFraudulentWebsiteWarnings feature
Co-authored-by: stffabi <stffabi@users.noreply.github.com>
2023-01-04 20:12:28 +11:00
Lea Anthony 174a31b49a Add run command for running tasks in a Taskfile.yml
Add `generate` command for generating assets
Add build example
2023-01-04 20:01:13 +11:00
stffabi ebc653a584 [windows] Add support for AdditionalBrowserArgs to the legacy Webview2Loader (#2267) 2023-01-02 22:41:56 +01:00
Lea Anthony 746b4dfc04 Fix sizes bug
Remove redundant menu package
2023-01-03 05:43:56 +11:00
Lea Anthony e5da0eb5f8 Add icon generation
Add syso generation
Add tests
2023-01-02 21:23:44 +11:00
Zámbó, Levente ef5f547d27 Support GPU acceleration settings on Windows & Linux (#2266)
* support GPU acceleration settings Window & Linux

* fix linux empty option crash

* fix change linux gpu policy switch case

* add PR to changelog
2023-01-02 09:38:53 +11:00
Lea Anthony f4044ebcd9 Add icon tool 2023-01-02 08:23:29 +11:00
Lea Anthony bc7d8295ba Refactor window -> webviewwindow 2023-01-02 05:48:52 +11:00
Lea Anthony 71fb7fadff Merge branch 'chore/move_assetserver_to_pkg' into future/exp 2022-12-31 13:08:34 +11:00
Lea Anthony be240795e2 Refactor assetserver into pkg 2022-12-31 11:01:24 +11:00
Lea Anthony cf5def05a6 Refactor application API to use options by default. Updated examples. 2022-12-31 10:38:36 +11:00
Lea Anthony d3b4105f75 Chore/refactor assetserver (#2250)
* Remove context from API calls

* Remove logger dependency

* Remove fs dependency

* Remove runtime dependency

* Update Windows/Linux calls to NewAssetServerMainPage

* Add missing imports

* fix runtime import clash
2022-12-31 10:36:07 +11:00
stffabi 66bc258f81 [windows] Fix compile error for 386 platform (#2257) 2022-12-30 21:33:39 +01:00
Lea Anthony 908aecfd1c Update Changelog 2022-12-30 15:58:11 +11:00
Lea Anthony ad802a3ad0 Frameless support
applicationShouldTerminateAfterLastWindowClosed support
2022-12-30 14:14:28 +11:00
Lea Anthony 287039a8f3 Task experiment 2022-12-28 19:17:38 +11:00
Lea Anthony ad1d104d85 Add screen support
Co-authored-by: Oleg Gulevskyy <43781031+oleggulevskyy@users.noreply.github.com>
2022-12-28 14:09:13 +11:00
Lea Anthony 92af7455ad Support Show/Hide window
Better demo
window.Run() -> window.Show()
2022-12-27 21:15:43 +11:00
Lea Anthony b6b6acf1d9 Remove debug printfs 2022-12-27 15:31:24 +11:00
Lea Anthony 5187641e25 Remove C.toggleFullscreen 2022-12-27 15:29:57 +11:00
Lea Anthony 41779866c4 Disable fullscreen button if there are size constraints 2022-12-27 13:42:57 +11:00
Lea Anthony f800222781 Allow SetSize to adjust min/max constraints 2022-12-27 09:38:00 +11:00
Lea Anthony 0c364b2813 Fix sizing of window/contentrect
Fix set min/max size
Ignore SetSize when in fullscreen
Disable size constraints when going fullscreen
2022-12-27 09:23:54 +11:00
Lea Anthony 7dbb8c1377 Improve Minimise, Maximise
Add Restore
setAutoenablesItems:NO
2022-12-26 20:21:51 +11:00
Lea Anthony 6a0c101b08 Fix dialog ID issue
Use map instead of uint for dialog IDs
2022-12-24 20:40:34 +11:00
Lea Anthony f240f2100c Refactor mainthread dispatch 2022-12-24 15:35:04 +11:00
Lea Anthony 2b91ced1b7 Support SetPosition
Optimise event listener callbacks
2022-12-24 13:38:48 +11:00
Lea Anthony b7f1defbf3 NavigateToURL -> SetURL
Fixed typo in colour
Removed EnableDevTools
2022-12-23 23:18:28 +11:00
Lea Anthony 2946a0aa25 GetCurrentWindow -> CurrentWindow 2022-12-23 19:55:54 +11:00
Lea Anthony b043126031 Add open file dialog filters
Add clipboard
Fix mouse event handling
2022-12-23 07:34:12 +11:00
Lea Anthony 4d58b56d54 Improve dialogs 2022-12-21 21:30:26 +11:00
Lea Anthony 025e8d7645 Add SaveFileDialog
Add Toolbar Styles
Add Invisible Titlebar option with drag support
2022-12-20 21:49:19 +11:00
Lea Anthony e7abe1c606 Add Webview navigation events
Add HTML/JS/CSS in config
Add RenderHTML()
Tidy up window delegate
2022-12-19 21:17:50 +11:00
Lea Anthony ea1f086289 OpenDialog attach to window & multiple files selection 2022-12-19 08:26:59 +11:00
Lea Anthony b1e8f2f887 Start of file dialogs 2022-12-18 23:06:31 +11:00
Lea Anthony 45adc49683 Add application icon support
Add message dialog support
Add default icons
Add png to byte slice task
Fixed kitchen sink
2022-12-18 13:06:03 +11:00
Lea Anthony 2409984aab Add application about dialog
Add application icon support
2022-12-18 00:40:53 +11:00
Lea Anthony 8f9eeb8055 Improve menu demo 2022-12-17 20:49:58 +11:00
Lea Anthony a8d5f185c2 Fix resizing bug
Refactor some application setters
2022-12-17 20:49:46 +11:00
Lea Anthony bbb418f98f Fix submenu radio processing 2022-12-17 20:49:04 +11:00
Lea Anthony f8eb680559 Add Window & Help menus
Fix min/max sizing
2022-12-17 19:56:29 +11:00
Lea Anthony da5fa806d7 Add Zoom In/Out & Actual size roles 2022-12-16 21:28:16 +11:00
Lea Anthony 88f6a3d1b9 Refactor and support more roles 2022-12-16 21:09:31 +11:00
Lea Anthony 475880c0a8 Add services, hide, hideothers, unhide role
Add application.Name()
refactor roles
Add app menu role
2022-12-16 21:06:49 +11:00
Lea Anthony faf418eac0 Add global reference for application
Add default application meu for Mac
Add window example
Fix invalid accelerator error logging
2022-12-15 21:21:19 +11:00
Lea Anthony f35b8dfec5 Refactor Application
Add SetActivationPolicy
Added labels to menus
2022-12-15 18:06:09 +11:00
Lea Anthony 14fcfb8348 Refactor event types 2022-12-15 18:03:01 +11:00
Lea Anthony f84c4aca72 Refactor message processing functions 2022-12-15 08:01:49 +11:00
Lea Anthony dad7798da9 New Systray example 2022-12-15 08:01:21 +11:00
Lea Anthony 79af667b7a Support Menu Accelerators 2022-12-15 08:00:49 +11:00
Lea Anthony d84cb5b190 Fix enabled menuitem 2022-12-14 19:15:58 +11:00
Lea Anthony 7c18f25508 Support radio menuitems
Support systemtray destroy()
2022-12-14 19:03:27 +11:00
Lea Anthony 085de606ee Support submenus 2022-12-14 08:48:17 +11:00
Lea Anthony c7ac90def4 Support template icons 2022-12-14 08:26:52 +11:00
Lea Anthony bb36ce61bc Refactor dispatching 2022-12-14 07:52:10 +11:00
Lea Anthony a35a876094 Add support for system tray + menus 2022-12-13 21:54:12 +11:00
Lea Anthony f38c6c6d1c Add Fatal() 2022-12-11 20:05:00 +11:00
Lea Anthony f6a16950f2 Add Window methods Width(), Height(), Size() + Position()
Fix main thread locking issue
Add Window aliases
2022-12-11 19:57:20 +11:00
Lea Anthony ddb2f63f7b Support Window aliases 2022-12-11 14:39:53 +11:00
Lea Anthony bf8e541221 Support Window events
Convert events to uint
Rename system events to application events
2022-12-11 13:01:38 +11:00
Lea Anthony 4a2cf597c2 Fix resizable 2022-12-11 11:26:21 +11:00
Lea Anthony 27370559d3 Refactor Is* methods
Add more events
2022-12-11 11:09:52 +11:00
Lea Anthony a134bfac42 Add Center
Add more events
2022-12-10 22:34:15 +11:00
Lea Anthony d5e21d5003 Fix race condition in closing window during navigating
Add sane defaults
2022-12-09 08:22:17 +11:00
Lea Anthony 85abb1122f Add main thread dispatching
Make `window.Run` operate on main thread
2022-12-09 07:47:47 +11:00
Lea Anthony 0257362a86 Support per-window message dispatching 2022-12-08 23:06:27 +11:00
Lea Anthony 1872672d0c Support appearance 2022-12-08 18:20:04 +11:00
Lea Anthony 644655662e Support toolbar config 2022-12-08 18:09:02 +11:00
Lea Anthony 508bbb4fb4 Support Min/Max/Fullscreen, BackgroundColour 2022-12-08 17:25:39 +11:00
Lea Anthony cb9df61a98 Support MacBackdrop type
Fix devtools window error
2022-12-08 07:47:04 +11:00
Lea Anthony ab976e56af Support ExecJS 2022-12-07 23:58:45 +11:00
Lea Anthony df1cc2ee0b Support EnableDevTools 2022-12-07 23:52:16 +11:00
Lea Anthony af6daa273e Support min/max window size 2022-12-07 23:44:19 +11:00
Lea Anthony 05803fb5d5 Add more Window API 2022-12-07 23:30:20 +11:00
Lea Anthony 5a37091bb0 Initial play around 2022-12-07 21:55:09 +11:00
272 changed files with 19992 additions and 1403 deletions
+3
View File
@@ -31,3 +31,6 @@ v2/test/kitchensink/frontend/package.json.md5
v2/cmd/wails/internal/commands/initialise/templates/testtemplates/
.env
/website/static/img/.cache.json
/v3/.task
/v3/examples/build/bin/testapp
+2 -2
View File
@@ -30,8 +30,8 @@
<img alt="Slack" src="https://img.shields.io/badge/slack-gophers%2Fwails%20-blue?logo=slack"/>
</a>
<br/>
<a href="https://github.com/wailsapp/wails/actions/workflows/build.yml" rel="nofollow">
<img src="https://img.shields.io/github/workflow/status/wailsapp/wails/Build?logo=github" alt="Build" />
<a href="https://github.com/wailsapp/wails/actions/workflows/build-and-test.yml" rel="nofollow">
<img src="https://img.shields.io/github/actions/workflow/status/wailsapp/wails/build-and-test.yml?branch=master&logo=Github" alt="Build" />
</a>
<a href="https://github.com/wailsapp/wails/tags" rel="nofollow">
<img alt="GitHub tag (latest SemVer pre-release)" src="https://img.shields.io/github/v/tag/wailsapp/wails?include_prereleases&label=version"/>
+2 -2
View File
@@ -30,8 +30,8 @@
<img alt="Slack" src="https://img.shields.io/badge/slack-gophers%2Fwails%20-blue?logo=slack"/>
</a>
<br/>
<a href="https://github.com/wailsapp/wails/actions/workflows/build.yml" rel="nofollow">
<img src="https://img.shields.io/github/workflow/status/wailsapp/wails/Build?logo=github" alt="Build" />
<a href="https://github.com/wailsapp/wails/actions/workflows/build-and-test.yml" rel="nofollow">
<img src="https://img.shields.io/github/actions/workflow/status/wailsapp/wails/build-and-test.yml?branch=master&logo=Github" alt="Build" />
</a>
<a href="https://github.com/wailsapp/wails/tags" rel="nofollow">
<img alt="GitHub tag (latest SemVer pre-release)" src="https://img.shields.io/github/v/tag/wailsapp/wails?include_prereleases&label=version"/>
+2 -2
View File
@@ -28,8 +28,8 @@
<img alt="Slack" src="https://img.shields.io/badge/slack-gophers%2Fwails%20-blue?logo=slack"/>
</a>
<br/>
<a href="https://github.com/wailsapp/wails/actions/workflows/build.yml" rel="nofollow">
<img src="https://img.shields.io/github/workflow/status/wailsapp/wails/Build?logo=github" alt="Build" />
<a href="https://github.com/wailsapp/wails/actions/workflows/build-and-test.yml" rel="nofollow">
<img src="https://img.shields.io/github/actions/workflow/status/wailsapp/wails/build-and-test.yml?branch=master&logo=Github" alt="Build" />
</a>
<a href="https://github.com/wailsapp/wails/tags" rel="nofollow">
<img alt="GitHub tag (latest SemVer pre-release)" src="https://img.shields.io/github/v/tag/wailsapp/wails?include_prereleases&label=version"/>
+2 -2
View File
@@ -30,8 +30,8 @@
<img alt="Slack" src="https://img.shields.io/badge/slack-gophers%2Fwails%20-blue?logo=slack"/>
</a>
<br/>
<a href="https://github.com/wailsapp/wails/actions/workflows/build.yml" rel="nofollow">
<img src="https://img.shields.io/github/workflow/status/wailsapp/wails/Build?logo=github" alt="Build" />
<a href="https://github.com/wailsapp/wails/actions/workflows/build-and-test.yml" rel="nofollow">
<img src="https://img.shields.io/github/actions/workflow/status/wailsapp/wails/build-and-test.yml?branch=master&logo=Github" alt="Build" />
</a>
<a href="https://github.com/wailsapp/wails/tags" rel="nofollow">
<img alt="GitHub tag (latest SemVer pre-release)" src="https://img.shields.io/github/v/tag/wailsapp/wails?include_prereleases&label=version"/>
+1 -1
View File
@@ -141,7 +141,7 @@ func (a *App) start() error {
// Defer the shutdown
defer a.shutdown()
// Run the renderer
// run the renderer
err = a.renderer.Run()
if err != nil {
return err
+1 -1
View File
@@ -55,7 +55,7 @@ func newIPCMessage(incomingMessage string, responseFunction func(*ipcResponse) e
// hasCallbackID checks if the message can send an error back to the frontend
func (m *ipcMessage) hasCallbackID() error {
if m.CallbackID == "" {
return fmt.Errorf("attempted to return error to message with no Callback ID")
return fmt.Errorf("attempted to return error to message with no callback ID")
}
return nil
}
+2 -2
View File
@@ -186,7 +186,7 @@ func (w *WebView) evalJSSync(js string) error {
go func() {
exit := false
// We are done when we receive the Callback ID
// We are done when we receive the callback ID
w.log.Debug("SyncJS: sending with ID = " + ID)
w.eventManager.On(ID, func(...interface{}) {
w.log.Debug("SyncJS: Got callback ID = " + ID)
@@ -361,7 +361,7 @@ func (w *WebView) focus() {
// callback sends a callback to the frontend
func (w *WebView) callback(data string) error {
callbackCMD := fmt.Sprintf("window.wails._.Callback('%s');", data)
callbackCMD := fmt.Sprintf("window.wails._.callback('%s');", data)
return w.evalJS(callbackCMD)
}
+8 -8
View File
@@ -2,14 +2,15 @@ package flags
import (
"fmt"
"github.com/leaanthony/slicer"
"github.com/wailsapp/wails/v2/internal/system"
"github.com/wailsapp/wails/v2/pkg/commands/build"
"github.com/wailsapp/wails/v2/pkg/commands/buildtags"
"os"
"os/exec"
"runtime"
"strings"
"github.com/leaanthony/slicer"
"github.com/wailsapp/wails/v2/internal/system"
"github.com/wailsapp/wails/v2/pkg/commands/build"
"github.com/wailsapp/wails/v2/pkg/commands/buildtags"
)
const (
@@ -51,7 +52,6 @@ type Build struct {
}
func (b *Build) Default() *Build {
defaultPlatform := os.Getenv("GOOS")
if defaultPlatform == "" {
defaultPlatform = runtime.GOOS
@@ -64,13 +64,13 @@ func (b *Build) Default() *Build {
defaultArch = runtime.GOARCH
}
}
b.defaultArch = defaultArch
platform := defaultPlatform + "/" + defaultArch
result := &Build{
Platform: platform,
Platform: defaultPlatform + "/" + defaultArch,
WebView2: "download",
GarbleArgs: "-literals -tiny -seed=random",
defaultArch: defaultArch,
}
result.BuildCommon = result.BuildCommon.Default()
return result
+3 -2
View File
@@ -4,12 +4,13 @@ import (
"context"
"embed"
"fmt"
"time"
"github.com/wailsapp/wails/v2/pkg/application"
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/windows"
"github.com/wailsapp/wails/v2/pkg/runtime"
"time"
)
//go:embed all:frontend/dist
@@ -52,7 +53,7 @@ func main() {
// create windows programmatically and be able to show/hide
// them from the systray with something like:
//
// myWindow := mainApp.NewWindow(...)
// myWindow := mainApp.NewWebviewWindow(...)
// mainApp.NewSystemTray(&options.SystemTray{
// OnLeftClick: func() {
// myWindow.SetVisibility(!myWindow.IsVisible())
+2 -1
View File
@@ -12,8 +12,9 @@ import (
"os"
"path/filepath"
"github.com/wailsapp/wails/v2/pkg/assetserver"
"github.com/wailsapp/wails/v2/internal/binding"
"github.com/wailsapp/wails/v2/internal/frontend/assetserver"
"github.com/wailsapp/wails/v2/internal/frontend/desktop"
"github.com/wailsapp/wails/v2/internal/frontend/devserver"
"github.com/wailsapp/wails/v2/internal/frontend/dispatcher"
@@ -17,7 +17,7 @@
#define WindowStartsMinimised 2
#define WindowStartsFullscreen 3
WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug, int windowStartState, int startsHidden, int minWidth, int minHeight, int maxWidth, int maxHeight);
WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug, int windowStartState, int startsHidden, int minWidth, int minHeight, int maxWidth, int maxHeight, bool fraudulentWebsiteWarningEnabled);
void Run(void*, const char* url);
void SetTitle(void* ctx, const char *title);
@@ -48,11 +48,6 @@ const bool IsFullScreen(void *ctx);
const bool IsMinimised(void *ctx);
const bool IsMaximised(void *ctx);
void ProcessURLDidReceiveResponse(void *inctx, unsigned long long requestId, int statusCode, void *headersString, int headersStringLength);
bool ProcessURLDidReceiveData(void *inctx, unsigned long long requestId, void* data, int datalength);
void ProcessURLDidFinish(void *inctx, unsigned long long requestId);
int ProcessURLRequestReadBodyStream(void *inctx, unsigned long long requestId, void *buf, int bufLen);
/* Dialogs */
void MessageDialog(void *inctx, const char* dialogType, const char* title, const char* message, const char* button1, const char* button2, const char* button3, const char* button4, const char* defaultButton, const char* cancelButton, void* iconData, int iconDataLength);
@@ -13,7 +13,7 @@
#import "WailsMenu.h"
#import "WailsMenuItem.h"
WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug, int windowStartState, int startsHidden, int minWidth, int minHeight, int maxWidth, int maxHeight) {
WailsContext* Create(const char* title, int width, int height, int frameless, int resizable, int fullscreen, int fullSizeContent, int hideTitleBar, int titlebarAppearsTransparent, int hideTitle, int useToolbar, int hideToolbarSeparator, int webviewIsTransparent, int alwaysOnTop, int hideWindowOnClose, const char *appearance, int windowIsTranslucent, int debug, int windowStartState, int startsHidden, int minWidth, int minHeight, int maxWidth, int maxHeight, bool fraudulentWebsiteWarningEnabled) {
[NSApplication sharedApplication];
@@ -25,7 +25,7 @@ WailsContext* Create(const char* title, int width, int height, int frameless, in
fullscreen = 1;
}
[result CreateWindow:width :height :frameless :resizable :fullscreen :fullSizeContent :hideTitleBar :titlebarAppearsTransparent :hideTitle :useToolbar :hideToolbarSeparator :webviewIsTransparent :hideWindowOnClose :safeInit(appearance) :windowIsTranslucent :minWidth :minHeight :maxWidth :maxHeight];
[result CreateWindow:width :height :frameless :resizable :fullscreen :fullSizeContent :hideTitleBar :titlebarAppearsTransparent :hideTitle :useToolbar :hideToolbarSeparator :webviewIsTransparent :hideWindowOnClose :safeInit(appearance) :windowIsTranslucent :minWidth :minHeight :maxWidth :maxHeight :fraudulentWebsiteWarningEnabled];
[result SetTitle:safeInit(title)];
[result Center];
@@ -52,36 +52,6 @@ WailsContext* Create(const char* title, int width, int height, int frameless, in
return result;
}
void ProcessURLDidReceiveResponse(void *inctx, unsigned long long requestId, int statusCode, void *headersString, int headersStringLength) {
WailsContext *ctx = (__bridge WailsContext*) inctx;
@autoreleasepool {
NSData *nsHeadersJSON = [NSData dataWithBytes:headersString length:headersStringLength];
[ctx processURLDidReceiveResponse:requestId :statusCode :nsHeadersJSON];
}
}
bool ProcessURLDidReceiveData(void *inctx, unsigned long long requestId, void* data, int datalength) {
WailsContext *ctx = (__bridge WailsContext*) inctx;
@autoreleasepool {
NSData *nsdata = [NSData dataWithBytes:data length:datalength];
return [ctx processURLDidReceiveData:requestId :nsdata];
}
}
void ProcessURLDidFinish(void *inctx, unsigned long long requestId) {
WailsContext *ctx = (__bridge WailsContext*) inctx;
@autoreleasepool {
[ctx processURLDidFinish:requestId];
}
}
int ProcessURLRequestReadBodyStream(void *inctx, unsigned long long requestId, void *buf, int bufLen) {
WailsContext *ctx = (__bridge WailsContext*) inctx;
@autoreleasepool {
return [ctx processURLRequestReadBodyStream:requestId :buf :bufLen];
}
}
void ExecJS(void* inctx, const char *script) {
WailsContext *ctx = (__bridge WailsContext*) inctx;
NSString *nsscript = safeInit(script);
@@ -47,9 +47,6 @@
@property bool debug;
@property (retain) WKUserContentController* userContentController;
@property (retain) NSLock *urlRequestsLock;
@property unsigned long long urlRequestsId;
@property (retain) NSMutableDictionary *urlRequests;
@property (retain) NSMenu* applicationMenu;
@@ -57,7 +54,7 @@
@property (retain) NSString* aboutTitle;
@property (retain) NSString* aboutDescription;
- (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString *)appearance :(bool)windowIsTranslucent :(int)minWidth :(int)minHeight :(int)maxWidth :(int)maxHeight;
- (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString *)appearance :(bool)windowIsTranslucent :(int)minWidth :(int)minHeight :(int)maxWidth :(int)maxHeight :(bool)fraudulentWebsiteWarningEnabled;
- (void) SetSize:(int)width :(int)height;
- (void) SetPosition:(int)x :(int) y;
- (void) SetMinSize:(int)minWidth :(int)minHeight;
@@ -89,10 +86,6 @@
- (void) SaveFileDialog :(NSString*)title :(NSString*)defaultFilename :(NSString*)defaultDirectory :(bool)canCreateDirectories :(bool)treatPackagesAsDirectories :(bool)showHiddenFiles :(NSString*)filters;
- (void) loadRequest:(NSString*)url;
- (void) processURLDidReceiveResponse:(unsigned long long)requestId :(int)statusCode :(NSData *)headersJSON;
- (bool) processURLDidReceiveData:(unsigned long long)requestId :(NSData *)data;
- (void) processURLDidFinish:(unsigned long long)requestId;
- (int) processURLRequestReadBodyStream:(unsigned long long)requestId :(void *)buf :(int)bufLen;
- (void) ExecJS:(NSString*)script;
- (NSScreen*) getCurrentScreen;
@@ -108,7 +108,6 @@ typedef void (^schemeTaskCaller)(id<WKURLSchemeTask>);
[self.mainWindow release];
[self.mouseEvent release];
[self.userContentController release];
[self.urlRequests release];
[self.applicationMenu release];
[super dealloc];
}
@@ -137,10 +136,7 @@ typedef void (^schemeTaskCaller)(id<WKURLSchemeTask>);
return NO;
}
- (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString*)appearance :(bool)windowIsTranslucent :(int)minWidth :(int)minHeight :(int)maxWidth :(int)maxHeight {
self.urlRequestsId = 0;
self.urlRequests = [NSMutableDictionary new];
- (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString*)appearance :(bool)windowIsTranslucent :(int)minWidth :(int)minHeight :(int)maxWidth :(int)maxHeight :(bool)fraudulentWebsiteWarningEnabled {
NSWindowStyleMask styleMask = 0;
if( !frameless ) {
@@ -220,7 +216,11 @@ typedef void (^schemeTaskCaller)(id<WKURLSchemeTask>);
[config setURLSchemeHandler:self forURLScheme:@"wails"];
// [config.preferences setValue:[NSNumber numberWithBool:true] forKey:@"developerExtrasEnabled"];
if (@available(macOS 10.15, *)) {
config.preferences.fraudulentWebsiteWarningEnabled = fraudulentWebsiteWarningEnabled;
}
WKUserContentController* userContentController = [WKUserContentController new];
[userContentController addScriptMessageHandler:self name:@"external"];
config.userContentController = userContentController;
@@ -427,156 +427,19 @@ typedef void (^schemeTaskCaller)(id<WKURLSchemeTask>);
}];
}
- (void) processURLDidReceiveResponse:(unsigned long long)requestId :(int)statusCode :(NSData *)headersJSON {
[self processURLSchemeTaskCall:requestId :^(id<WKURLSchemeTask> urlSchemeTask) {
NSDictionary *headerFields = [NSJSONSerialization JSONObjectWithData: headersJSON options: NSJSONReadingMutableContainers error: nil];
NSHTTPURLResponse *response = [[[NSHTTPURLResponse alloc] initWithURL:urlSchemeTask.request.URL statusCode:statusCode HTTPVersion:@"HTTP/1.1" headerFields:headerFields] autorelease];
[urlSchemeTask didReceiveResponse:response];
}];
}
- (bool) processURLDidReceiveData:(unsigned long long)requestId :(NSData *)data {
return [self processURLSchemeTaskCall:requestId :^(id<WKURLSchemeTask> urlSchemeTask) {
[urlSchemeTask didReceiveData:data];
}];
}
- (void) processURLDidFinish:(unsigned long long)requestId {
[self processURLSchemeTaskCall:requestId :^(id<WKURLSchemeTask> urlSchemeTask) {
[urlSchemeTask didFinish];
}];
NSNumber *key = [NSNumber numberWithUnsignedLongLong:requestId];
[self removeURLSchemeTask:key];
}
- (int) processURLRequestReadBodyStream:(unsigned long long)requestId :(void *)buf :(int)bufLen {
int res = 0;
int *pRes = &res;
bool hasRequest = [self processURLSchemeTaskCall:requestId :^(id<WKURLSchemeTask> urlSchemeTask) {
NSInputStream *stream = urlSchemeTask.request.HTTPBodyStream;
if (!stream) {
*pRes = -3;
} else {
NSStreamStatus status = stream.streamStatus;
if (status == NSStreamStatusAtEnd) {
*pRes = 0;
} else if (status != NSStreamStatusOpen) {
*pRes = -4;
} else if (!stream.hasBytesAvailable) {
*pRes = 0;
} else {
*pRes = [stream read:buf maxLength:bufLen];
}
}
}];
if (!hasRequest) {
res = -2;
}
return res;
}
- (void)webView:(nonnull WKWebView *)webView startURLSchemeTask:(nonnull id<WKURLSchemeTask>)urlSchemeTask {
// This callback is run with an autorelease pool
const char *url = [urlSchemeTask.request.URL.absoluteString UTF8String];
const char *method = [urlSchemeTask.request.HTTPMethod UTF8String];
const char *headerJSON = "";
const void *body = nil;
int bodyLen = 0;
int hasBodyStream = 0;
NSData *headers = [NSJSONSerialization dataWithJSONObject: urlSchemeTask.request.allHTTPHeaderFields options:0 error: nil];
if (headers) {
NSString* headerString = [[[NSString alloc] initWithData:headers encoding:NSUTF8StringEncoding] autorelease];
headerJSON = [headerString UTF8String];
}
if (urlSchemeTask.request.HTTPBody) {
body = urlSchemeTask.request.HTTPBody.bytes;
bodyLen = urlSchemeTask.request.HTTPBody.length;
} else if (urlSchemeTask.request.HTTPBodyStream) {
hasBodyStream = 1;
[urlSchemeTask.request.HTTPBodyStream open];
}
unsigned long long requestId;
@synchronized(self.urlRequests) {
self.urlRequestsId++;
requestId = self.urlRequestsId;
NSNumber *key = [NSNumber numberWithUnsignedLongLong:requestId];
self.urlRequests[key] = urlSchemeTask;
}
processURLRequest(self, requestId, url, method, headerJSON, body, bodyLen, hasBodyStream);
processURLRequest(self, urlSchemeTask);
}
- (void)webView:(nonnull WKWebView *)webView stopURLSchemeTask:(nonnull id<WKURLSchemeTask>)urlSchemeTask {
NSArray<NSNumber*> *keys;
@synchronized(self.urlRequests) {
keys = [self.urlRequests allKeys];
}
for (NSNumber *key in keys) {
if (self.urlRequests[key] == urlSchemeTask) {
[self removeURLSchemeTask:key];
}
}
}
- (void) removeURLSchemeTask:(NSNumber *)urlSchemeTaskKey {
id<WKURLSchemeTask> urlSchemeTask = nil;
@synchronized(self.urlRequests) {
urlSchemeTask = self.urlRequests[urlSchemeTaskKey];
}
if (!urlSchemeTask) {
return;
}
NSInputStream *stream = urlSchemeTask.request.HTTPBodyStream;
if (stream) {
[stream close];
}
@synchronized(self.urlRequests) {
[self.urlRequests removeObjectForKey:urlSchemeTaskKey];
}
}
- (bool)processURLSchemeTaskCall:(unsigned long long)requestId :(schemeTaskCaller)fn {
NSNumber *key = [NSNumber numberWithUnsignedLongLong:requestId];
id<WKURLSchemeTask> urlSchemeTask;
@synchronized(self.urlRequests) {
urlSchemeTask = self.urlRequests[key];
}
if (urlSchemeTask == nil) {
// Stopped task, drop content...
return false;
}
@try {
fn(urlSchemeTask);
} @catch (NSException *exception) {
[self removeURLSchemeTask:key];
// This is very bad to detect a stopped schemeTask this should be implemented in a better way
// But it seems to be very tricky to not deadlock when keeping a lock curing executing fn()
// It seems like those call switch the thread back to the main thread and then deadlocks when they reentrant want
// to get the lock again to start another request or stop it.
if ([exception.reason isEqualToString: @"This task has already been stopped"]) {
return false;
NSStreamStatus status = stream.streamStatus;
if (status != NSStreamStatusClosed && status != NSStreamStatusNotOpen) {
[stream close];
}
@throw exception;
}
return true;
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
@@ -0,0 +1,36 @@
//go:build darwin
package darwin
import (
"os/exec"
)
func (f *Frontend) ClipboardGetText() (string, error) {
pasteCmd := exec.Command("pbpaste")
out, err := pasteCmd.Output()
if err != nil {
return "", err
}
return string(out), nil
}
func (f *Frontend) ClipboardSetText(text string) error {
copyCmd := exec.Command("pbcopy")
in, err := copyCmd.StdinPipe()
if err != nil {
return err
}
if err := copyCmd.Start(); err != nil {
return err
}
if _, err := in.Write([]byte(text)); err != nil {
return err
}
if err := in.Close(); err != nil {
return err
}
return copyCmd.Wait()
}
+21 -36
View File
@@ -19,13 +19,18 @@ import (
"fmt"
"html/template"
"log"
"net/http"
"net/url"
"strconv"
"unsafe"
"github.com/wailsapp/wails/v2/pkg/assetserver"
"github.com/wailsapp/wails/v2/pkg/assetserver/webview"
"github.com/wailsapp/wails/v2/pkg/assetserver"
"github.com/wailsapp/wails/v2/internal/binding"
"github.com/wailsapp/wails/v2/internal/frontend"
"github.com/wailsapp/wails/v2/internal/frontend/assetserver"
"github.com/wailsapp/wails/v2/internal/frontend/runtime"
"github.com/wailsapp/wails/v2/internal/logger"
"github.com/wailsapp/wails/v2/pkg/options"
)
@@ -33,7 +38,7 @@ import (
const startURL = "wails://wails/"
var messageBuffer = make(chan string, 100)
var requestBuffer = make(chan *wkWebViewRequest, 100)
var requestBuffer = make(chan webview.Request, 100)
var callbackBuffer = make(chan uint, 10)
type Frontend struct {
@@ -86,16 +91,15 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.
} else {
appBindings.DB().UpdateObfuscatedCallMap()
}
assets, err := assetserver.NewAssetServerMainPage(ctx, bindings, appoptions)
assets, err := assetserver.NewAssetServerMainPage(bindings, appoptions, ctx.Value("assetdir") != nil, myLogger, runtime.RuntimeAssetsBundle)
if err != nil {
log.Fatal(err)
}
assets.ExpectedWebViewHost = result.startURL.Host
result.assets = assets
// Start 10 processors to handle requests in parallel
for i := 0; i < 10; i++ {
go result.startRequestProcessor()
}
go result.startRequestProcessor()
}
go result.startMessageProcessor()
@@ -111,7 +115,8 @@ func (f *Frontend) startMessageProcessor() {
}
func (f *Frontend) startRequestProcessor() {
for request := range requestBuffer {
f.processRequest(request)
f.assets.ServeWebViewRequest(request)
request.Release()
}
}
func (f *Frontend) startCallbackProcessor() {
@@ -324,7 +329,7 @@ func (f *Frontend) processMessage(message string) {
switch result[0] {
case 'c':
// Callback from a method call
// callback from a method call
f.Callback(result[1:])
default:
f.logger.Info("Unknown message returned from dispatcher: %+v", result)
@@ -334,38 +339,13 @@ func (f *Frontend) processMessage(message string) {
}
func (f *Frontend) Callback(message string) {
f.ExecJS(`window.wails.Callback(` + strconv.Quote(message) + `);`)
f.ExecJS(`window.wails.callback(` + strconv.Quote(message) + `);`)
}
func (f *Frontend) ExecJS(js string) {
f.mainWindow.ExecJS(js)
}
func (f *Frontend) processRequest(r *wkWebViewRequest) {
rw := &wkWebViewResponseWriter{r: r}
defer rw.Close()
f.assets.ProcessHTTPRequest(
r.url,
rw,
func() (*http.Request, error) {
req, err := r.GetHttpRequest()
if err != nil {
return nil, err
}
if req.URL.Host != f.startURL.Host {
if req.Body != nil {
req.Body.Close()
}
return nil, fmt.Errorf("Expected host '%s' in request, but was '%s'", f.startURL.Host, req.URL.Host)
}
return req, nil
},
)
}
//func (f *Frontend) processSystemEvent(message string) {
// sl := strings.Split(message, ":")
// if len(sl) != 2 {
@@ -392,3 +372,8 @@ func processMessage(message *C.char) {
func processCallback(callbackID uint) {
callbackBuffer <- callbackID
}
//export processURLRequest
func processURLRequest(ctx unsafe.Pointer, wkURLSchemeTask unsafe.Pointer) {
requestBuffer <- webview.NewRequest(wkURLSchemeTask)
}
+1 -1
View File
@@ -219,7 +219,7 @@ int main(int argc, const char * argv[]) {
int windowStartState = 0;
int startsHidden = 0;
WailsContext *result = Create("OI OI!",400,400, frameless, resizable, fullscreen, fullSizeContent, hideTitleBar, titlebarAppearsTransparent, hideTitle, useToolbar, hideToolbarSeparator, webviewIsTransparent, alwaysOnTop, hideWindowOnClose, appearance, windowIsTranslucent, debug, windowStartState,
startsHidden, 400, 400, 600, 600);
startsHidden, 400, 400, 600, 600, false);
SetBackgroundColour(result, 255, 0, 0, 255);
void *m = NewMenu("");
SetAbout(result, "Fake title", "I am a description", _Users_username_Pictures_SaltBae_png, _Users_username_Pictures_SaltBae_png_len);
@@ -15,7 +15,7 @@ extern "C"
#endif
void processMessage(const char *);
void processURLRequest(void*, unsigned long long, const char *, const char *, const char *, const void *, int, int);
void processURLRequest(void *, void*);
void processMessageDialogResponse(int);
void processOpenFileDialogResponse(const char*);
void processSaveFileDialogResponse(const char*);
@@ -67,6 +67,8 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window {
title = c.String(frontendOptions.Title)
enableFraudulentWebsiteWarnings := C.bool(frontendOptions.EnableFraudulentWebsiteDetection)
if frontendOptions.Mac != nil {
mac := frontendOptions.Mac
if mac.TitleBar != nil {
@@ -85,7 +87,7 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window {
var context *C.WailsContext = C.Create(title, width, height, frameless, resizable, fullscreen, fullSizeContent,
hideTitleBar, titlebarAppearsTransparent, hideTitle, useToolbar, hideToolbarSeparator, webviewIsTransparent,
alwaysOnTop, hideWindowOnClose, appearance, windowIsTranslucent, debug, windowStartState, startsHidden,
minWidth, minHeight, maxWidth, maxHeight)
minWidth, minHeight, maxWidth, maxHeight, enableFraudulentWebsiteWarnings)
// Create menu
result := &Window{

Some files were not shown because too many files have changed in this diff Show More