From 946a4c56a04d24adaf800047db217abe7d42b458 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Fri, 18 Aug 2023 09:35:03 +1000 Subject: [PATCH] [v3 mac] Better logging --- v2/examples/customlayout/go.mod | 32 ++--- v2/examples/customlayout/go.sum | 20 +++ v3/examples/build/Taskfile.yml | 131 +++++++++++++++--- v3/internal/assetserver/assetserver.go | 26 +++- v3/internal/assetserver/assetserver_legacy.go | 7 +- .../assetserver/webview/responsewriter.go | 3 + .../webview/responsewriter_darwin.go | 6 + v3/internal/operatingsystem/os.go | 13 ++ v3/internal/operatingsystem/os_darwin.go | 56 ++++++++ v3/internal/operatingsystem/os_linux.go | 51 +++++++ v3/internal/operatingsystem/os_windows.go | 32 +++++ .../operatingsystem/version_windows.go | 62 +++++++++ v3/pkg/application/application.go | 5 +- v3/pkg/application/application_darwin.go | 12 +- v3/pkg/application/bindings.go | 4 + v3/pkg/application/logger_default.go | 1 + v3/pkg/application/messageprocessor.go | 15 +- .../messageprocessor_application.go | 2 + v3/pkg/application/messageprocessor_call.go | 1 + .../application/messageprocessor_clipboard.go | 8 +- .../messageprocessor_contextmenu.go | 2 + v3/pkg/application/messageprocessor_dialog.go | 9 ++ v3/pkg/application/messageprocessor_events.go | 6 +- v3/pkg/application/messageprocessor_params.go | 23 ++- .../application/messageprocessor_screens.go | 2 + v3/pkg/application/messageprocessor_window.go | 6 + v3/pkg/application/webview_window_darwin.go | 2 +- 27 files changed, 475 insertions(+), 62 deletions(-) create mode 100644 v3/internal/operatingsystem/os.go create mode 100644 v3/internal/operatingsystem/os_darwin.go create mode 100644 v3/internal/operatingsystem/os_linux.go create mode 100644 v3/internal/operatingsystem/os_windows.go create mode 100644 v3/internal/operatingsystem/version_windows.go diff --git a/v2/examples/customlayout/go.mod b/v2/examples/customlayout/go.mod index a25b9438..fcb4ce4f 100644 --- a/v2/examples/customlayout/go.mod +++ b/v2/examples/customlayout/go.mod @@ -7,27 +7,27 @@ require github.com/wailsapp/wails/v2 v2.1.0 require ( github.com/bep/debounce v1.2.1 // indirect github.com/go-ole/go-ole v1.2.6 // indirect - github.com/google/uuid v1.1.2 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect - github.com/labstack/echo/v4 v4.9.0 // indirect - github.com/labstack/gommon v0.3.1 // indirect - github.com/leaanthony/go-ansi-parser v1.0.1 // indirect + github.com/labstack/echo/v4 v4.10.2 // indirect + github.com/labstack/gommon v0.4.0 // indirect + github.com/leaanthony/go-ansi-parser v1.6.0 // indirect github.com/leaanthony/gosod v1.0.3 // indirect - github.com/leaanthony/slicer v1.5.0 // indirect - github.com/mattn/go-colorable v0.1.11 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 // indirect + github.com/leaanthony/slicer v1.6.0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/samber/lo v1.27.1 // indirect - github.com/tkrajina/go-reflector v0.5.5 // indirect + github.com/samber/lo v1.38.1 // indirect + github.com/tkrajina/go-reflector v0.5.6 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasttemplate v1.2.1 // indirect + github.com/valyala/fasttemplate v1.2.2 // indirect github.com/wailsapp/mimetype v1.4.1 // indirect - golang.org/x/crypto v0.1.0 // indirect - golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/crypto v0.9.0 // indirect + golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect + golang.org/x/net v0.10.0 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/text v0.9.0 // indirect ) replace github.com/wailsapp/wails/v2 v2.1.0 => ../.. diff --git a/v2/examples/customlayout/go.sum b/v2/examples/customlayout/go.sum index de073ade..b00ead2f 100644 --- a/v2/examples/customlayout/go.sum +++ b/v2/examples/customlayout/go.sum @@ -7,53 +7,69 @@ github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= github.com/labstack/echo/v4 v4.9.0 h1:wPOF1CE6gvt/kmbMR4dGzWvHMPT+sAEUJOwOTtvITVY= github.com/labstack/echo/v4 v4.9.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= +github.com/labstack/echo/v4 v4.10.2/go.mod h1:OEyqf2//K1DFdE57vw2DRgWY0M7s65IVQO2FzvI4J5k= github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o= github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= +github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc= github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA= github.com/leaanthony/go-ansi-parser v1.0.1 h1:97v6c5kYppVsbScf4r/VZdXyQ21KQIfeQOk2DgKxGG4= github.com/leaanthony/go-ansi-parser v1.0.1/go.mod h1:7arTzgVI47srICYhvgUV4CGd063sGEeoSlych5yeSPM= +github.com/leaanthony/go-ansi-parser v1.6.0/go.mod h1:+vva/2y4alzVmmIEpk9QDhA7vLC5zKDTRwfZGOp3IWU= github.com/leaanthony/gosod v1.0.3 h1:Fnt+/B6NjQOVuCWOKYRREZnjGyvg+mEhd1nkkA04aTQ= github.com/leaanthony/gosod v1.0.3/go.mod h1:BJ2J+oHsQIyIQpnLPjnqFGTMnOZXDbvWtRCSG7jGxs4= github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY= github.com/leaanthony/slicer v1.5.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY= +github.com/leaanthony/slicer v1.6.0/go.mod h1:o/Iz29g7LN0GqH3aMjWAe90381nyZlDNquK+mtH2Fj8= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 h1:acNfDZXmm28D2Yg/c3ALnZStzNaZMSagpbr96vY6Zjc= github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/samber/lo v1.27.1 h1:sTXwkRiIFIQG+G0HeAvOEnGjqWeWtI9cg5/n51KrxPg= github.com/samber/lo v1.27.1/go.mod h1:it33p9UtPMS7z72fP4gw/EIfQB2eI8ke7GR2wc6+Rhg= +github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M= github.com/tkrajina/go-reflector v0.5.5 h1:gwoQFNye30Kk7NrExj8zm3zFtrGPqOkzFMLuQZg1DtQ= github.com/tkrajina/go-reflector v0.5.5/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4= +github.com/tkrajina/go-reflector v0.5.6/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs= github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o= golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM= golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -62,12 +78,16 @@ golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/v3/examples/build/Taskfile.yml b/v3/examples/build/Taskfile.yml index 2e48ca49..d0d815f1 100644 --- a/v3/examples/build/Taskfile.yml +++ b/v3/examples/build/Taskfile.yml @@ -1,5 +1,8 @@ version: '3' +vars: + APP_NAME: "dev{{exeExt}}" + tasks: pre-build: @@ -8,13 +11,50 @@ tasks: post-build: summary: Post-build hooks + install-frontend-deps: + summary: Install frontend dependencies + dir: frontend + sources: + - package.json + - package-lock.json + generates: + - node_modules/* + preconditions: + - sh: npm version + msg: "Looks like npm isn't installed. Npm is part of the Node installer: https://nodejs.org/en/download/" + cmds: + - npm install + + build-frontend: + summary: Build the frontend project + dir: frontend + generates: + - frontend/dist/* + deps: + - install-frontend-deps + cmds: + - npm run build + build:darwin: summary: Builds the application platforms: - darwin cmds: - task: pre-build - - go build -gcflags=all="-N -l" -o bin/testapp + - task: build-frontend + - go build -gcflags=all="-N -l" -o bin/{{.APP_NAME}} + - task: post-build + env: + CGO_CFLAGS: "-mmacosx-version-min=10.13" + CGO_LDFLAGS: "-mmacosx-version-min=10.13" + + build:backend:darwin: + summary: Builds the application + platforms: + - darwin + cmds: + - task: pre-build + - go build -gcflags=all="-N -l" -o bin/{{.APP_NAME}} - task: post-build env: CGO_CFLAGS: "-mmacosx-version-min=10.13" @@ -26,7 +66,18 @@ tasks: - windows cmds: - task: pre-build - - go build -gcflags=all="-N -l" -o bin/testapp.exe + - task: build-frontend + - go build -gcflags=all="-N -l" -o bin/{{.APP_NAME}} + - task: post-build + + + build:backend:windows: + summary: Builds the backend application for Windows + platforms: + - windows + cmds: + - task: pre-build + - go build -gcflags=all="-N -l" -o bin/{{.APP_NAME}} - task: post-build build: @@ -35,39 +86,87 @@ tasks: - task: build:darwin - task: build:windows + build:backend: + summary: Builds the backend application + cmds: + - task: build:backend:darwin + - task: build:backend:windows + generate-icons: summary: Generates Windows `.ico` and Mac `.icns` files from an image dir: build cmds: # Generates both .ico and .icns files - - wails3 generate icons -input appicon.png + - wails generate icons -input appicon.png - build-prod: + build-app-prod-darwin: summary: Creates a production build of the application cmds: - - go build -tags production -ldflags="-w -s" -o bin/testapp{{exeExt}} + - task: pre-build + - task: build-frontend + - GOOS=darwin GOARCH={{.ARCH}} go build -tags production -ldflags="-w -s" -o build/bin/{{.APP_NAME}} + - task: post-build + env: + CGO_CFLAGS: "-mmacosx-version-min=10.13" + CGO_LDFLAGS: "-mmacosx-version-min=10.13" + vars: + ARCH: $GOARCH - package:darwin: + frontend:dev: + summary: Runs the frontend in development mode + dir: frontend + cmds: + - npm run dev + + run: + summary: Runs the application + cmds: + - ./bin/{{.APP_NAME}} + + dev: + summary: Runs the application in development mode + preconditions: + - sh: 'wails3 tool checkport -p 5173' + msg: "Vite does not appear to be running." + cmds: + - task: build:backend + - task: run + + create-app-bundle: + summary: Builds a `.app` bundle + cmds: + - mkdir -p {{.APP_NAME}}.app/Contents/{MacOS,Resources} + - cp build/icons.icns {{.APP_NAME}}.app/Contents/Resources + - cp build/bin/{{.APP_NAME}} {{.APP_NAME}}.app/Contents/MacOS + - cp build/Info.plist {{.APP_NAME}}.app/Contents + + package-darwin-arm64: summary: Packages a production build of the application into a `.app` bundle + platform: darwin deps: - - build-prod - - generate-icons + - task: build-app-prod-darwin + vars: + ARCH: arm64 + - generate-icons cmds: - - mkdir -p buildtest.app/Contents/{MacOS,Resources} - - cp build/icons.icns buildtest.app/Contents/Resources - - cp bin/testapp buildtest.app/Contents/MacOS - - cp build/Info.plist buildtest.app/Contents + - task: create-app-bundle - windows:generate:syso: + generate:syso: dir: build + platform: windows cmds: - - wails3 generate syso -arch amd64 -icon icons.ico -manifest wails.exe.manifest -info info.json -out ../wails.syso + - wails generate syso -arch {{.ARCH}} -icon icon.ico -manifest wails.exe.manifest -info info.json -out ../wails.syso + vars: + ARCH: $GOARCH package:windows: summary: Packages a production build of the application into a `.exe` bundle + platform: windows deps: - generate-icons cmds: - - task: windows:generate:syso - - go build -tags production -ldflags="-w -s -H windowsgui" -o bin/testapp.exe + - task: generate:syso + vars: + ARCH: amd64 + - go build -tags production -ldflags="-w -s -H windowsgui" -o bin/{{.APP_NAME}}.exe - powershell Remove-item wails.syso diff --git a/v3/internal/assetserver/assetserver.go b/v3/internal/assetserver/assetserver.go index 1a18a405..aa8a957c 100644 --- a/v3/internal/assetserver/assetserver.go +++ b/v3/internal/assetserver/assetserver.go @@ -3,6 +3,7 @@ package assetserver import ( "bytes" "fmt" + "github.com/wailsapp/wails/v3/internal/assetserver/webview" "log/slog" "math/rand" "net/http" @@ -93,7 +94,8 @@ func NewAssetServer(options *Options, servingFromDisk bool, logger *slog.Logger, externalURL, err := options.getExternalURL() if err != nil { return nil, err - } else { + } + if externalURL != nil { result.wsHandler = httputil.NewSingleHostReverseProxy(externalURL) err := result.checkExternalURL() if err != nil { @@ -137,10 +139,10 @@ func (d *AssetServer) AddPluginScript(pluginName string, script string) { d.pluginScripts[pluginScriptName] = script } -func (d *AssetServer) logRequest(req *http.Request, code int) { +func logRequest(logger *slog.Logger, req *http.Request, code int) { windowName := req.Header.Get(webViewRequestHeaderWindowName) windowID := req.Header.Get(webViewRequestHeaderWindowId) - d.logger.Info("AssetServer:", "code", code, "windowName", windowName, "windowID", windowID, "method", req.Method, "url", req.URL.Path) + logger.Info("Asset Request:", "windowName", windowName, "windowID", windowID, "code", code, "method", req.Method, "url", req.URL.Path) } func (d *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) { @@ -149,12 +151,14 @@ func (d *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) { d.wsHandler.ServeHTTP(rw, req) // Get response code from header code := rw.(*contentTypeSniffer).rw.(*legacyRequestNoOpCloserResponseWriter).ResponseWriter.(*httptest.ResponseRecorder).Code - d.logRequest(req, code) + logRequest(d.logger, req, code) return } else { if isWebSocket(req) { // WebSockets are not supported by the AssetServer rw.WriteHeader(http.StatusNotImplemented) + logRequest(d.logger, req, http.StatusNotImplemented) + return } } @@ -188,6 +192,8 @@ func (d *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(recorder.Code) } + logRequest(d.logger, req, recorder.Code) + return case runtimeJSPath: d.writeBlob(rw, path, d.runtimeJS) @@ -208,6 +214,7 @@ func (d *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) { case runtimePath: d.runtimeHandler.HandleRuntimeCall(rw, req) + return case ipcJSPath: content := d.runtime.DesktopIPC() @@ -220,10 +227,15 @@ func (d *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) { // Check if this is a plugin script if script, ok := d.pluginScripts[path]; ok { d.writeBlob(rw, path, []byte(script)) + } else { + d.handler.ServeHTTP(rw, req) + code := rw.(*contentTypeSniffer).rw.(webview.ResponseWriter).Code() + logRequest(d.logger, req, code) return } - d.handler.ServeHTTP(rw, req) } + + logRequest(d.logger, req, http.StatusOK) } func (d *AssetServer) processIndexHTML(indexHTML []byte) ([]byte, error) { @@ -278,9 +290,9 @@ func (d *AssetServer) serveError(rw http.ResponseWriter, err error, msg string, } func (d *AssetServer) logInfo(message string, args ...interface{}) { - d.logger.Info("AssetServer: "+message, args...) + d.logger.Info("Asset Request: "+message, args...) } func (d *AssetServer) logError(message string, args ...interface{}) { - d.logger.Error("AssetServer: "+message, args...) + d.logger.Error("Asset Request: "+message, args...) } diff --git a/v3/internal/assetserver/assetserver_legacy.go b/v3/internal/assetserver/assetserver_legacy.go index 69629da9..3bb0a459 100644 --- a/v3/internal/assetserver/assetserver_legacy.go +++ b/v3/internal/assetserver/assetserver_legacy.go @@ -53,7 +53,7 @@ func (r *legacyRequest) Body() (io.ReadCloser, error) { } func (r legacyRequest) Response() webview.ResponseWriter { - return &legacyRequestNoOpCloserResponseWriter{r.rw} + return &legacyRequestNoOpCloserResponseWriter{ResponseWriter: r.rw} } func (r legacyRequest) Close() error { return nil } @@ -73,6 +73,11 @@ func (r *legacyRequest) request() (*http.Request, error) { type legacyRequestNoOpCloserResponseWriter struct { http.ResponseWriter + code int } func (*legacyRequestNoOpCloserResponseWriter) Finish() {} + +func (r *legacyRequestNoOpCloserResponseWriter) Code() int { + return r.code +} diff --git a/v3/internal/assetserver/webview/responsewriter.go b/v3/internal/assetserver/webview/responsewriter.go index d67802a0..988a65c5 100644 --- a/v3/internal/assetserver/webview/responsewriter.go +++ b/v3/internal/assetserver/webview/responsewriter.go @@ -22,4 +22,7 @@ type ResponseWriter interface { // Finish the response and flush all data. A Finish after the request has already been finished has no effect. Finish() + + // Code returns the HTTP status code of the response + Code() int } diff --git a/v3/internal/assetserver/webview/responsewriter_darwin.go b/v3/internal/assetserver/webview/responsewriter_darwin.go index 1c0cbee7..cb2e606c 100644 --- a/v3/internal/assetserver/webview/responsewriter_darwin.go +++ b/v3/internal/assetserver/webview/responsewriter_darwin.go @@ -80,6 +80,7 @@ type responseWriter struct { header http.Header wroteHeader bool + code int finished bool } @@ -112,6 +113,7 @@ func (rw *responseWriter) Write(buf []byte) (int, error) { } func (rw *responseWriter) WriteHeader(code int) { + rw.code = code if rw.wroteHeader || rw.finished { return } @@ -145,3 +147,7 @@ func (rw *responseWriter) Finish() { C.URLSchemeTaskDidFinish(rw.r.task) } + +func (rw *responseWriter) Code() int { + return rw.code +} diff --git a/v3/internal/operatingsystem/os.go b/v3/internal/operatingsystem/os.go new file mode 100644 index 00000000..39f1de8e --- /dev/null +++ b/v3/internal/operatingsystem/os.go @@ -0,0 +1,13 @@ +package operatingsystem + +// OS contains information about the operating system +type OS struct { + ID string + Name string + Version string +} + +// Info retrieves information about the current platform +func Info() (*OS, error) { + return platformInfo() +} diff --git a/v3/internal/operatingsystem/os_darwin.go b/v3/internal/operatingsystem/os_darwin.go new file mode 100644 index 00000000..213ccfb0 --- /dev/null +++ b/v3/internal/operatingsystem/os_darwin.go @@ -0,0 +1,56 @@ +//go:build darwin + +package operatingsystem + +import ( + "os/exec" + "strings" +) + +func getSysctlValue(key string) (string, error) { + // Run "sysctl" command + command := exec.Command("sysctl", key) + // Capture stdout + var stdout strings.Builder + command.Stdout = &stdout + // Run command + err := command.Run() + if err != nil { + return "", err + } + version := strings.TrimPrefix(stdout.String(), key+": ") + return strings.TrimSpace(version), nil +} + +func platformInfo() (*OS, error) { + // Default value + var result OS + result.ID = "Unknown" + result.Name = "MacOS" + result.Version = "Unknown" + + version, err := getSysctlValue("kern.osproductversion") + if err != nil { + return nil, err + } + result.Version = version + ID, err := getSysctlValue("kern.osversion") + if err != nil { + return nil, err + } + result.ID = ID + + // cmd := CreateCommand(directory, command, args...) + // var stdo, stde bytes.Buffer + // cmd.Stdout = &stdo + // cmd.Stderr = &stde + // err := cmd.Run() + // return stdo.String(), stde.String(), err + // } + // sysctl := shell.NewCommand("sysctl") + // kern.ostype: Darwin + // kern.osrelease: 20.1.0 + // kern.osrevision: 199506 + + return &result, nil +} diff --git a/v3/internal/operatingsystem/os_linux.go b/v3/internal/operatingsystem/os_linux.go new file mode 100644 index 00000000..49e00c02 --- /dev/null +++ b/v3/internal/operatingsystem/os_linux.go @@ -0,0 +1,51 @@ +//go:build linux +// +build linux + +package operatingsystem + +import ( + "fmt" + "os" + "strings" +) + +// platformInfo is the platform specific method to get system information +func platformInfo() (*OS, error) { + _, err := os.Stat("/etc/os-release") + if os.IsNotExist(err) { + return nil, fmt.Errorf("unable to read system information") + } + + osRelease, _ := os.ReadFile("/etc/os-release") + return parseOsRelease(string(osRelease)), nil +} + +func parseOsRelease(osRelease string) *OS { + + // Default value + var result OS + result.ID = "Unknown" + result.Name = "Unknown" + result.Version = "Unknown" + + // Split into lines + lines := strings.Split(osRelease, "\n") + // Iterate lines + for _, line := range lines { + // Split each line by the equals char + splitLine := strings.SplitN(line, "=", 2) + // Check we have + if len(splitLine) != 2 { + continue + } + switch splitLine[0] { + case "ID": + result.ID = strings.ToLower(strings.Trim(splitLine[1], "\"")) + case "NAME": + result.Name = strings.Trim(splitLine[1], "\"") + case "VERSION_ID": + result.Version = strings.Trim(splitLine[1], "\"") + } + } + return &result +} diff --git a/v3/internal/operatingsystem/os_windows.go b/v3/internal/operatingsystem/os_windows.go new file mode 100644 index 00000000..38ea43a1 --- /dev/null +++ b/v3/internal/operatingsystem/os_windows.go @@ -0,0 +1,32 @@ +//go:build windows + +package operatingsystem + +import ( + "fmt" + + "golang.org/x/sys/windows/registry" +) + +func platformInfo() (*OS, error) { + // Default value + var result OS + result.ID = "Unknown" + result.Name = "Windows" + result.Version = "Unknown" + + // Credit: https://stackoverflow.com/a/33288328 + // Ignore errors as it isn't a showstopper + key, _ := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE) + + productName, _, _ := key.GetStringValue("ProductName") + currentBuild, _, _ := key.GetStringValue("CurrentBuildNumber") + displayVersion, _, _ := key.GetStringValue("DisplayVersion") + releaseId, _, _ := key.GetStringValue("ReleaseId") + + result.Name = productName + result.Version = fmt.Sprintf("%s (Build: %s)", releaseId, currentBuild) + result.ID = displayVersion + + return &result, key.Close() +} diff --git a/v3/internal/operatingsystem/version_windows.go b/v3/internal/operatingsystem/version_windows.go new file mode 100644 index 00000000..a8f53d13 --- /dev/null +++ b/v3/internal/operatingsystem/version_windows.go @@ -0,0 +1,62 @@ +//go:build windows + +package operatingsystem + +import ( + "strconv" + + "golang.org/x/sys/windows/registry" +) + +type WindowsVersionInfo struct { + Major int + Minor int + Build int + DisplayVersion string +} + +func (w *WindowsVersionInfo) IsWindowsVersionAtLeast(major, minor, buildNumber int) bool { + return w.Major >= major && w.Minor >= minor && w.Build >= buildNumber +} + +func GetWindowsVersionInfo() (*WindowsVersionInfo, error) { + key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE) + if err != nil { + return nil, err + } + + return &WindowsVersionInfo{ + Major: regDWORDKeyAsInt(key, "CurrentMajorVersionNumber"), + Minor: regDWORDKeyAsInt(key, "CurrentMinorVersionNumber"), + Build: regStringKeyAsInt(key, "CurrentBuildNumber"), + DisplayVersion: regKeyAsString(key, "DisplayVersion"), + }, nil +} + +func regDWORDKeyAsInt(key registry.Key, name string) int { + result, _, err := key.GetIntegerValue(name) + if err != nil { + return -1 + } + return int(result) +} + +func regStringKeyAsInt(key registry.Key, name string) int { + resultStr, _, err := key.GetStringValue(name) + if err != nil { + return -1 + } + result, err := strconv.Atoi(resultStr) + if err != nil { + return -1 + } + return result +} + +func regKeyAsString(key registry.Key, name string) string { + resultStr, _, err := key.GetStringValue(name) + if err != nil { + return "" + } + return resultStr +} diff --git a/v3/pkg/application/application.go b/v3/pkg/application/application.go index 8a593d41..4f63768e 100644 --- a/v3/pkg/application/application.go +++ b/v3/pkg/application/application.go @@ -60,7 +60,7 @@ func New(appOptions Options) *App { ExternalURL: appOptions.Assets.ExternalURL, } - srv, err := assetserver.NewAssetServer(opts, false, result.Logger, wailsruntime.RuntimeAssetsBundle, result.isDebugMode, NewMessageProcessor()) + srv, err := assetserver.NewAssetServer(opts, false, result.Logger, wailsruntime.RuntimeAssetsBundle, result.isDebugMode, NewMessageProcessor(result.Logger)) if err != nil { result.fatal(err.Error()) } @@ -513,9 +513,6 @@ func (a *App) handleWindowMessage(event *windowMessage) { } func (a *App) handleWebViewRequest(request *webViewAssetRequest) { - // Get window from window map - url, _ := request.URL() - a.info("Window: '%s', Request: %s", request.windowName, url) a.assets.ServeWebViewRequest(request) } diff --git a/v3/pkg/application/application_darwin.go b/v3/pkg/application/application_darwin.go index bbe105bd..0276a8ba 100644 --- a/v3/pkg/application/application_darwin.go +++ b/v3/pkg/application/application_darwin.go @@ -126,6 +126,7 @@ static void show(void) { */ import "C" import ( + "github.com/wailsapp/wails/v3/internal/operatingsystem" "unsafe" "github.com/wailsapp/wails/v3/internal/assetserver/webview" @@ -269,4 +270,13 @@ func setIcon(icon []byte) { C.setApplicationIcon(unsafe.Pointer(&icon[0]), C.int(len(icon))) } -func (a *App) logPlatformInfo() {} +func (a *App) logPlatformInfo() { + info, err := operatingsystem.Info() + if err != nil { + a.error("Error getting OS info", "error", err.Error()) + return + } + + a.info("Platform Info:", "name", info.Name, "version", info.Version, "id", info.ID) + +} diff --git a/v3/pkg/application/bindings.go b/v3/pkg/application/bindings.go index 9fe604c7..fee0b714 100644 --- a/v3/pkg/application/bindings.go +++ b/v3/pkg/application/bindings.go @@ -16,6 +16,10 @@ type CallOptions struct { Args []any `json:"args"` } +func (c CallOptions) Name() string { + return fmt.Sprintf("%s.%s.%s", c.PackageName, c.StructName, c.MethodName) +} + type PluginCallOptions struct { Name string `json:"name"` Args []any `json:"args"` diff --git a/v3/pkg/application/logger_default.go b/v3/pkg/application/logger_default.go index 853b1f21..2f1d3f0d 100644 --- a/v3/pkg/application/logger_default.go +++ b/v3/pkg/application/logger_default.go @@ -4,6 +4,7 @@ package application import ( "github.com/lmittmann/tint" + "github.com/mattn/go-isatty" "log/slog" "os" "time" diff --git a/v3/pkg/application/messageprocessor.go b/v3/pkg/application/messageprocessor.go index 46a1cf15..9d35c2a9 100644 --- a/v3/pkg/application/messageprocessor.go +++ b/v3/pkg/application/messageprocessor.go @@ -2,6 +2,7 @@ package application import ( "fmt" + "log/slog" "net/http" "strconv" "strings" @@ -14,10 +15,13 @@ import ( type MessageProcessor struct { pluginManager *PluginManager + logger *slog.Logger } -func NewMessageProcessor() *MessageProcessor { - return &MessageProcessor{} +func NewMessageProcessor(logger *slog.Logger) *MessageProcessor { + return &MessageProcessor{ + logger: logger, + } } func (m *MessageProcessor) httpError(rw http.ResponseWriter, message string, args ...any) { @@ -69,7 +73,7 @@ func (m *MessageProcessor) HandleRuntimeCall(rw http.ResponseWriter, r *http.Req targetWindow := m.getTargetWindow(r) if targetWindow == nil { - m.Error("No valid window found") + m.httpError(rw, "No valid window found") return } @@ -93,15 +97,14 @@ func (m *MessageProcessor) HandleRuntimeCall(rw http.ResponseWriter, r *http.Req default: m.httpError(rw, "Unknown runtime call: %s", object) } - } func (m *MessageProcessor) Error(message string, args ...any) { - fmt.Printf("[MessageProcessor] Error: "+message, args...) + m.logger.Error(message, args...) } func (m *MessageProcessor) Info(message string, args ...any) { - fmt.Printf("[MessageProcessor] Info: "+message, args...) + m.logger.Info(message, args...) } func (m *MessageProcessor) json(rw http.ResponseWriter, data any) { diff --git a/v3/pkg/application/messageprocessor_application.go b/v3/pkg/application/messageprocessor_application.go index 4eaf9e9b..e19f09c6 100644 --- a/v3/pkg/application/messageprocessor_application.go +++ b/v3/pkg/application/messageprocessor_application.go @@ -20,4 +20,6 @@ func (m *MessageProcessor) processApplicationMethod(method string, rw http.Respo m.httpError(rw, "Unknown event method: %s", method) } + m.Info("Runtime:", "method", "Application."+method) + } diff --git a/v3/pkg/application/messageprocessor_call.go b/v3/pkg/application/messageprocessor_call.go index 51dcc942..24e92e18 100644 --- a/v3/pkg/application/messageprocessor_call.go +++ b/v3/pkg/application/messageprocessor_call.go @@ -59,6 +59,7 @@ func (m *MessageProcessor) processCallMethod(method string, rw http.ResponseWrit } } m.callCallback(window, callID, string(jsonResult), true) + m.Info("Call Binding:", "method", options.Name(), "args", args.data, "result", result) }() m.ok(rw) default: diff --git a/v3/pkg/application/messageprocessor_clipboard.go b/v3/pkg/application/messageprocessor_clipboard.go index 003fc4ae..8d82770b 100644 --- a/v3/pkg/application/messageprocessor_clipboard.go +++ b/v3/pkg/application/messageprocessor_clipboard.go @@ -8,16 +8,18 @@ func (m *MessageProcessor) processClipboardMethod(method string, rw http.Respons switch method { case "SetText": - title := params.String("text") - if title == nil { + text := params.String("text") + if text == nil { m.Error("SetText: text is required") return } - globalApplication.Clipboard().SetText(*title) + globalApplication.Clipboard().SetText(*text) m.ok(rw) + m.Info("", "method", "Clipboard."+method, "text", *text) case "Text": text, _ := globalApplication.Clipboard().Text() m.text(rw, text) + m.Info("", "method", "Clipboard."+method, "text", text) default: m.httpError(rw, "Unknown clipboard method: %s", method) } diff --git a/v3/pkg/application/messageprocessor_contextmenu.go b/v3/pkg/application/messageprocessor_contextmenu.go index d0fe57c9..6bc47abb 100644 --- a/v3/pkg/application/messageprocessor_contextmenu.go +++ b/v3/pkg/application/messageprocessor_contextmenu.go @@ -27,4 +27,6 @@ func (m *MessageProcessor) processContextMenuMethod(method string, rw http.Respo m.httpError(rw, "Unknown clipboard method: %s", method) } + m.Info("Runtime:", "method", "ContextMenu."+method) + } diff --git a/v3/pkg/application/messageprocessor_dialog.go b/v3/pkg/application/messageprocessor_dialog.go index 39964cea..0a2418b5 100644 --- a/v3/pkg/application/messageprocessor_dialog.go +++ b/v3/pkg/application/messageprocessor_dialog.go @@ -13,6 +13,7 @@ func (m *MessageProcessor) dialogErrorCallback(window *WebviewWindow, message st m.Error(errorMsg) msg := "_wails.dialogErrorCallback('" + *dialogID + "', " + strconv.Quote(errorMsg) + ");" window.ExecJS(msg) + m.Error(message, "error", err) } func (m *MessageProcessor) dialogCallback(window *WebviewWindow, dialogID *string, result string, isJSON bool) { @@ -73,6 +74,8 @@ func (m *MessageProcessor) processDialogMethod(method string, rw http.ResponseWr dialog.AddButtons(options.Buttons) dialog.Show() m.ok(rw) + m.Info("Runtime:", "method", "Dialog."+method, "options", options) + case "OpenFile": var options OpenFileDialogOptions err := params.ToStruct(&options) @@ -99,6 +102,7 @@ func (m *MessageProcessor) processDialogMethod(method string, rw http.ResponseWr return } m.dialogCallback(window, dialogID, string(result), true) + m.Info("Runtime:", "method", "Dialog."+method, "result", result) } } else { file, err := dialog.PromptForSingleSelection() @@ -107,9 +111,12 @@ func (m *MessageProcessor) processDialogMethod(method string, rw http.ResponseWr return } m.dialogCallback(window, dialogID, file, false) + m.Info("Runtime:", "method", "Dialog."+method, "result", file) } }() m.ok(rw) + m.Info("Runtime:", "method", "Dialog."+method, "options", options) + case "SaveFile": var options SaveFileDialogOptions err := params.ToStruct(&options) @@ -130,8 +137,10 @@ func (m *MessageProcessor) processDialogMethod(method string, rw http.ResponseWr return } m.dialogCallback(window, dialogID, file, false) + m.Info("Runtime:", "method", "Dialog."+method, "result", file) }() m.ok(rw) + m.Info("Runtime:", "method", "Dialog."+method, "options", options) default: m.httpError(rw, "Unknown dialog method: %s", method) diff --git a/v3/pkg/application/messageprocessor_events.go b/v3/pkg/application/messageprocessor_events.go index 439452a3..333b0faf 100644 --- a/v3/pkg/application/messageprocessor_events.go +++ b/v3/pkg/application/messageprocessor_events.go @@ -6,9 +6,10 @@ import ( func (m *MessageProcessor) processEventsMethod(method string, rw http.ResponseWriter, _ *http.Request, window *WebviewWindow, params QueryParams) { + var event WailsEvent + switch method { case "Emit": - var event WailsEvent err := params.ToStruct(&event) if err != nil { m.httpError(rw, "Error parsing event: %s", err) @@ -23,6 +24,9 @@ func (m *MessageProcessor) processEventsMethod(method string, rw http.ResponseWr m.ok(rw) default: m.httpError(rw, "Unknown event method: %s", method) + return } + m.Info("Runtime:", "method", "Events."+method, "event", event) + } diff --git a/v3/pkg/application/messageprocessor_params.go b/v3/pkg/application/messageprocessor_params.go index 39d741ce..b3030da4 100644 --- a/v3/pkg/application/messageprocessor_params.go +++ b/v3/pkg/application/messageprocessor_params.go @@ -126,19 +126,31 @@ func (a *Args) Int(s string) *int { return nil } if val := a.data[s]; val != nil { - result := val.(int) - return &result + return convertNumber[int](val) } return nil } +func convertNumber[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](val any) *T { + if val == nil { + return nil + } + var result T + switch v := val.(type) { + case T: + result = v + case float64: + result = T(v) + } + return &result +} + func (a *Args) UInt8(s string) *uint8 { if a == nil { return nil } if val := a.data[s]; val != nil { - result := val.(uint8) - return &result + return convertNumber[uint8](val) } return nil } @@ -147,8 +159,7 @@ func (a *Args) UInt(s string) *uint { return nil } if val := a.data[s]; val != nil { - result := val.(uint) - return &result + return convertNumber[uint](val) } return nil } diff --git a/v3/pkg/application/messageprocessor_screens.go b/v3/pkg/application/messageprocessor_screens.go index 22a32a17..16aca994 100644 --- a/v3/pkg/application/messageprocessor_screens.go +++ b/v3/pkg/application/messageprocessor_screens.go @@ -32,4 +32,6 @@ func (m *MessageProcessor) processScreensMethod(method string, rw http.ResponseW m.httpError(rw, "Unknown clipboard method: %s", method) } + m.Info("Runtime:", "method", "Screens."+method) + } diff --git a/v3/pkg/application/messageprocessor_window.go b/v3/pkg/application/messageprocessor_window.go index fda827e2..2d5d9161 100644 --- a/v3/pkg/application/messageprocessor_window.go +++ b/v3/pkg/application/messageprocessor_window.go @@ -189,4 +189,10 @@ func (m *MessageProcessor) processWindowMethod(method string, rw http.ResponseWr m.httpError(rw, "Unknown window method: %s", method) } + var logArgs = []any{"method", "Window." + method} + for name, arg := range args.data { + logArgs = append(logArgs, name) + logArgs = append(logArgs, arg) + } + m.Info("Runtime:", logArgs...) } diff --git a/v3/pkg/application/webview_window_darwin.go b/v3/pkg/application/webview_window_darwin.go index 37a728c5..de7f7efc 100644 --- a/v3/pkg/application/webview_window_darwin.go +++ b/v3/pkg/application/webview_window_darwin.go @@ -1027,7 +1027,7 @@ func (w *macosWebviewWindow) run() { w.setMaxSize(w.parent.options.MaxWidth, w.parent.options.MaxHeight) } //w.setZoom(w.parent.options.Zoom) - if isDebugMode() || w.parent.options.DevToolsEnabled { + if globalApplication.isDebugMode || w.parent.options.DevToolsEnabled { w.enableDevTools() } w.setBackgroundColour(w.parent.options.BackgroundColour)