Skip to content

Commit 371e103

Browse files
authored
Merge branch 'v3-alpha' into template-dependencies
2 parents bccff0f + 0a05348 commit 371e103

File tree

12 files changed

+165
-27
lines changed

12 files changed

+165
-27
lines changed

docs/src/content/docs/changelog.mdx

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7676
- Add cancellation support for query methods on `sqlite` service by [@fbbdev](https://github.com/fbbdev) in [#4067](https://github.com/wailsapp/wails/pull/4067)
7777
- Add prepared statement support to `sqlite` service with JS bindings by [@fbbdev](https://github.com/fbbdev) in [#4067](https://github.com/wailsapp/wails/pull/4067)
7878
- Add `SetMenu()` on window to allow for setting a menu on a window by [@leaanthony](https://github.com/leaanthony)
79+
-  Add File Association support for mac by [@wimaha](https://github.com/wimaha) in [#4177](https://github.com/wailsapp/wails/pull/4177)
7980

8081
### Fixed
8182

@@ -111,6 +112,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
111112
- Fixed initially-hidden menu items by [@IanVS](https://github.com/IanVS) in [#4116](https://github.com/wailsapp/wails/pull/4116)
112113
- Fixed assetFileServer not serving `.html` files when non-extension request when `[request]` doesn't exist but `[request].html` does
113114
- Fixed icon generation paths by [@robin-samuel](https://github.com/robin-samuel) in [#4125](https://github.com/wailsapp/wails/pull/4125)
115+
- Fixed Dialogs runtime function returning escaped paths on Windows by [TheGB0077](https://github.com/TheGB0077) in [#4188](https://github.com/wailsapp/wails/pull/4188)
114116

115117
### Changed
116118

@@ -140,6 +142,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
140142
- Built-in service creation functions with options are now consistently called `NewWithConfig` by [@fbbdev](https://github.com/fbbdev) in [#4067](https://github.com/wailsapp/wails/pull/4067)
141143
- `Select` method on `sqlite` service is now named `Query` for consistency with Go APIs by [@fbbdev](https://github.com/fbbdev) in [#4067](https://github.com/wailsapp/wails/pull/4067)
142144
- Templates: moved runtime to "dependencies", organized package.json files by [@IanVS](https://github.com/IanVS) in [#4133](https://github.com/wailsapp/wails/pull/4133)
145+
- Creates and ad-hoc signs app bundles in dev to enable certain macOS APIs by [@popaprozac] in [#4171](https://github.com/wailsapp/wails/pull/4171)
143146

144147
## v3.0.0-alpha.9 - 2025-01-13
145148

docs/src/content/docs/guides/file-associations.mdx

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fileAssociations:
6262
| description | Description shown in file properties | Windows |
6363
| iconName | Name of the icon file (without extension) in the build folder | All |
6464
| role | Application's role for this file type (e.g., `Editor`, `Viewer`) | macOS |
65+
| mimeType | MIME type for the file (e.g., `image/jpeg`) | macOS |
6566

6667
## Listening for File Open Events
6768

@@ -105,6 +106,8 @@ Let's walk through setting up file associations for a simple text editor:
105106
Run `wails3 generate icons --help` for more information.
106107
:::
107108

109+
- For macOS add copy statement like `cp build/darwin/documenticon.icns {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources` in the `create:app:bundle:` task.
110+
108111
2. ### Configure File Associations
109112

110113
Edit the `build/config.yml` file to add your file associations:

docs/src/content/docs/learn/build.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ the application on macOS. Key features include:
123123
- Building binaries for amd64, arm64 and universal (both) architectures
124124
- Generating `.icns` icon file
125125
- Creating an `.app` bundle for distributing
126+
- Ad-hoc signing `.app` bundles
126127
- Setting macOS-specific build flags and environment variables
127128

128129
## Task Execution and Command Aliases

v3/internal/commands/build-assets.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import (
44
"embed"
55
_ "embed"
66
"fmt"
7-
"github.com/leaanthony/gosod"
8-
"gopkg.in/yaml.v3"
97
"io/fs"
108
"os"
119
"path/filepath"
1210
"runtime"
1311
"strings"
1412
"time"
13+
14+
"github.com/leaanthony/gosod"
15+
"gopkg.in/yaml.v3"
1516
)
1617

1718
//go:embed build_assets
@@ -121,6 +122,7 @@ type FileAssociation struct {
121122
Description string `yaml:"description"`
122123
IconName string `yaml:"iconName"`
123124
Role string `yaml:"role"`
125+
MimeType string `yaml:"mimeType"`
124126
}
125127

126128
type UpdateConfig struct {

v3/internal/commands/build_assets/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fileAssociations:
5656
# description: Image File
5757
# iconName: jpegFileIcon
5858
# role: Editor
59+
# mimeType: image/jpeg # (optional)
5960

6061
# Other data
6162
other:

v3/internal/commands/build_assets/darwin/Taskfile.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ tasks:
6969
- cp build/darwin/icons.icns {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources
7070
- cp {{.BIN_DIR}}/{{.APP_NAME}} {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS
7171
- cp build/darwin/Info.plist {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents
72+
- codesign --force --deep --sign - {{.BIN_DIR}}/{{.APP_NAME}}.app
7273

7374
run:
7475
cmds:
75-
- '{{.BIN_DIR}}/{{.APP_NAME}}'
76+
- mkdir -p {{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/{MacOS,Resources}
77+
- cp build/darwin/icons.icns {{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Resources
78+
- cp {{.BIN_DIR}}/{{.APP_NAME}} {{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS
79+
- cp build/darwin/Info.dev.plist {{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/Info.plist
80+
- codesign --force --deep --sign - {{.BIN_DIR}}/{{.APP_NAME}}.dev.app
81+
- '{{.BIN_DIR}}/{{.APP_NAME}}.dev.app/Contents/MacOS/{{.APP_NAME}}'

v3/internal/commands/updatable_build_assets/darwin/Info.dev.plist.tmpl

+34-11
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,50 @@
22
<plist version="1.0">
33
<dict>
44
<key>CFBundlePackageType</key>
5-
<string>APPL</string>
5+
<string>APPL</string>
66
<key>CFBundleName</key>
7-
<string>{{.ProductName}}</string>
7+
<string>{{.ProductName}}</string>
88
<key>CFBundleExecutable</key>
9-
<string>{{.BinaryName}}</string>
9+
<string>{{.BinaryName}}</string>
1010
<key>CFBundleIdentifier</key>
11-
<string>{{.ProductIdentifier}}</string>
11+
<string>{{.ProductIdentifier}}</string>
1212
<key>CFBundleVersion</key>
13-
<string>{{.ProductVersion}}</string>
13+
<string>{{.ProductVersion}}</string>
1414
<key>CFBundleGetInfoString</key>
15-
<string>{{.ProductComments}}</string>
15+
<string>{{.ProductComments}}</string>
1616
<key>CFBundleShortVersionString</key>
17-
<string>{{.ProductVersion}}</string>
17+
<string>{{.ProductVersion}}</string>
1818
<key>CFBundleIconFile</key>
19-
<string>icons</string>
19+
<string>icons</string>
2020
<key>LSMinimumSystemVersion</key>
21-
<string>10.15.0</string>
21+
<string>10.15.0</string>
2222
<key>NSHighResolutionCapable</key>
23-
<string>true</string>
23+
<string>true</string>
2424
<key>NSHumanReadableCopyright</key>
25-
<string>{{.ProductCopyright}}</string>
25+
<string>{{.ProductCopyright}}</string>
26+
{{- if .FileAssociations}}
27+
<key>CFBundleDocumentTypes</key>
28+
<array>
29+
{{- range .FileAssociations}}
30+
<dict>
31+
<key>CFBundleTypeExtensions</key>
32+
<array>
33+
<string>{{.Ext}}</string>
34+
</array>
35+
<key>CFBundleTypeName</key>
36+
<string>{{.Name}}</string>
37+
<key>CFBundleTypeRole</key>
38+
<string>{{.Role}}</string>
39+
<key>CFBundleTypeIconFile</key>
40+
<string>{{.IconName}}</string>
41+
{{- if .MimeType}}
42+
<key>CFBundleTypeMimeType</key>
43+
<string>{{.MimeType}}</string>
44+
{{- end}}
45+
</dict>
46+
{{- end}}
47+
</array>
48+
{{- end}}
2649
<key>NSAppTransportSecurity</key>
2750
<dict>
2851
<key>NSAllowsLocalNetworking</key>

v3/internal/commands/updatable_build_assets/darwin/Info.plist.tmpl

+34-11
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,49 @@
22
<plist version="1.0">
33
<dict>
44
<key>CFBundlePackageType</key>
5-
<string>APPL</string>
5+
<string>APPL</string>
66
<key>CFBundleName</key>
7-
<string>{{.ProductName}}</string>
7+
<string>{{.ProductName}}</string>
88
<key>CFBundleExecutable</key>
9-
<string>{{.BinaryName}}</string>
9+
<string>{{.BinaryName}}</string>
1010
<key>CFBundleIdentifier</key>
11-
<string>{{.ProductIdentifier}}</string>
11+
<string>{{.ProductIdentifier}}</string>
1212
<key>CFBundleVersion</key>
13-
<string>{{.ProductVersion}}</string>
13+
<string>{{.ProductVersion}}</string>
1414
<key>CFBundleGetInfoString</key>
15-
<string>{{.ProductComments}}</string>
15+
<string>{{.ProductComments}}</string>
1616
<key>CFBundleShortVersionString</key>
17-
<string>{{.ProductVersion}}</string>
17+
<string>{{.ProductVersion}}</string>
1818
<key>CFBundleIconFile</key>
19-
<string>icons</string>
19+
<string>icons</string>
2020
<key>LSMinimumSystemVersion</key>
21-
<string>10.15.0</string>
21+
<string>10.15.0</string>
2222
<key>NSHighResolutionCapable</key>
23-
<string>true</string>
23+
<string>true</string>
2424
<key>NSHumanReadableCopyright</key>
25-
<string>{{.ProductCopyright}}</string>
25+
<string>{{.ProductCopyright}}</string>
26+
{{- if .FileAssociations}}
27+
<key>CFBundleDocumentTypes</key>
28+
<array>
29+
{{- range .FileAssociations}}
30+
<dict>
31+
<key>CFBundleTypeExtensions</key>
32+
<array>
33+
<string>{{.Ext}}</string>
34+
</array>
35+
<key>CFBundleTypeName</key>
36+
<string>{{.Name}}</string>
37+
<key>CFBundleTypeRole</key>
38+
<string>{{.Role}}</string>
39+
<key>CFBundleTypeIconFile</key>
40+
<string>{{.IconName}}</string>
41+
{{- if .MimeType}}
42+
<key>CFBundleTypeMimeType</key>
43+
<string>{{.MimeType}}</string>
44+
{{- end}}
45+
</dict>
46+
{{- end}}
47+
</array>
48+
{{- end}}
2649
</dict>
2750
</plist>

v3/pkg/application/dialogs.go

+3
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ func (d *OpenFileDialogStruct) PromptForMultipleSelection() ([]string, error) {
291291
}
292292

293293
selections, err := InvokeSyncWithResultAndError(d.impl.show)
294+
if err != nil {
295+
return nil, err
296+
}
294297

295298
var result []string
296299
for filename := range selections {

v3/pkg/application/dialogs_windows.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,20 @@ func showCfdDialog(newDlg func() (cfd.Dialog, error), isMultiSelect bool) (any,
247247
}()
248248

249249
if multi, _ := dlg.(cfd.OpenMultipleFilesDialog); multi != nil && isMultiSelect {
250-
return multi.ShowAndGetResults()
250+
paths, err := multi.ShowAndGetResults()
251+
if err != nil {
252+
return nil, err
253+
}
254+
255+
for i, path := range paths {
256+
paths[i] = filepath.Clean(path)
257+
}
258+
return paths, nil
259+
}
260+
261+
path, err := dlg.ShowAndGetResult()
262+
if err != nil {
263+
return nil, err
251264
}
252-
return dlg.ShowAndGetResult()
265+
return filepath.Clean(path), nil
253266
}
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//go:build windows
2+
3+
package application_test
4+
5+
import (
6+
"path/filepath"
7+
"testing"
8+
9+
"github.com/matryer/is"
10+
)
11+
12+
func TestCleanPath(t *testing.T) {
13+
i := is.New(t)
14+
tests := []struct {
15+
name string
16+
inputPath string
17+
expected string
18+
}{
19+
{
20+
name: "path with double separators",
21+
inputPath: `C:\\temp\\folder`,
22+
expected: `C:\temp\folder`,
23+
},
24+
{
25+
name: "path with forward slashes",
26+
inputPath: `C://temp//folder`,
27+
expected: `C:\temp\folder`,
28+
},
29+
{
30+
name: "path with trailing separator",
31+
inputPath: `C:\\temp\\folder\\`,
32+
expected: `C:\temp\folder`,
33+
},
34+
{
35+
name: "path with escaped tab character",
36+
inputPath: `C:\\Users\\test\\tab.txt`,
37+
expected: `C:\Users\test\tab.txt`,
38+
},
39+
{
40+
name: "newline character",
41+
inputPath: `C:\\Users\\test\\newline\\n.txt`,
42+
expected: `C:\Users\test\newline\n.txt`,
43+
},
44+
{
45+
name: "UNC path with multiple separators",
46+
inputPath: `\\\\\\\\host\\share\\test.txt`,
47+
expected: `\\\\host\share\test.txt`,
48+
},
49+
}
50+
51+
for _, tt := range tests {
52+
t.Run(tt.name, func(t *testing.T) {
53+
cleaned := filepath.Clean(tt.inputPath)
54+
i.Equal(cleaned, tt.expected)
55+
})
56+
}
57+
}

website/src/pages/changelog.mdx

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
## [Unreleased]
1616

17+
### Fixed
18+
- Fixed locking issue on Windows when multiselect dialog returns an error. Fixed in [PR](https://github.com/wailsapp/wails/pull/4156) by @johannes-luebke
19+
1720
## v2.9.1 - 2024-06-18
1821

1922
### Fixed

0 commit comments

Comments
 (0)