mirror of
https://github.com/wavetermdev/wails.git
synced 2026-04-22 15:26:15 -07:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 204f33805f | |||
| c96cc3ff27 |
@@ -0,0 +1,15 @@
|
||||
name: Label sponsors
|
||||
on:
|
||||
pull_request:
|
||||
types: [ opened ]
|
||||
issues:
|
||||
types: [ opened ]
|
||||
jobs:
|
||||
build:
|
||||
name: is-sponsor-label
|
||||
if: github.repository == 'wailsapp/wails'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: JasonEtco/is-sponsor-label-action@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,9 +1,8 @@
|
||||
name: Upload Source Documents
|
||||
name: Push Checks
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
push_files_to_crowdin:
|
||||
@@ -14,28 +13,25 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Verify Changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v35
|
||||
uses: tj-actions/verify-changed-files@v11.1
|
||||
id: verify-changed-files
|
||||
with:
|
||||
files: |
|
||||
website/**/*.mdx
|
||||
website/**/*.md
|
||||
website/**/*.json
|
||||
|
||||
- name: Setup Nodejs
|
||||
- name: Set node
|
||||
if: steps.verify-changed-files.outputs.files_changed != 'true'
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 18.x
|
||||
node-version: 16.x
|
||||
|
||||
- name: Setup Task
|
||||
uses: arduino/setup-task@v1
|
||||
with:
|
||||
version: 3.x
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload source documents
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
- name: Push files
|
||||
env:
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
working-directory: ./website
|
||||
run: task crowdin:push
|
||||
run: |
|
||||
cd website
|
||||
corepack enable
|
||||
pnpm install
|
||||
pnpm run crowdin push -b master
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Sync Translations
|
||||
name: Sync Translated Documents
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@@ -10,30 +10,22 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Nodejs
|
||||
- name: Set node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 18.x
|
||||
|
||||
- name: Install Task
|
||||
uses: arduino/setup-task@v1
|
||||
with:
|
||||
version: 3.x
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
node-version: 16.x
|
||||
|
||||
- name: Sync Translated Documents
|
||||
run: cd scripts && chmod 755 ./sync-translated-documents.sh && ./sync-translated-documents.sh
|
||||
env:
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
working-directory: ./website
|
||||
run: task crowdin:pull
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
commit-message: "docs: sync translations"
|
||||
title: "docs: sync translations"
|
||||
commit-message: "docs: sync documents"
|
||||
title: "docs: sync documents"
|
||||
body: "- [x] Sync translated documents"
|
||||
branch: chore/sync-translations
|
||||
labels: translation
|
||||
branch: feature/documents
|
||||
delete-branch: true
|
||||
draft: true
|
||||
|
||||
@@ -35,4 +35,3 @@ v2/cmd/wails/internal/commands/initialise/templates/testtemplates/
|
||||
/v3/.task
|
||||
/v3/examples/build/bin/testapp
|
||||
/websitev3/site/
|
||||
/v3/examples/plugins/bin/testapp
|
||||
|
||||
+5
-5
@@ -1,24 +1,24 @@
|
||||
# https://taskfile.dev
|
||||
|
||||
version: "3"
|
||||
version: '3'
|
||||
|
||||
vars:
|
||||
GREETING: Hello, World!
|
||||
|
||||
tasks:
|
||||
contributors:check:
|
||||
check-contributors:
|
||||
cmds:
|
||||
- npx -y all-contributors-cli check
|
||||
|
||||
contributors:update:
|
||||
update-contributors:
|
||||
cmds:
|
||||
- go run v3/tasks/contribs/main.go
|
||||
|
||||
contributors:build:
|
||||
build-contributors:
|
||||
cmds:
|
||||
- npx -y all-contributors-cli generate
|
||||
|
||||
release:
|
||||
dir: v2/tools/release
|
||||
cmds:
|
||||
- go run release.go
|
||||
- go run release.go
|
||||
Generated
+3
-3
@@ -1775,9 +1775,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "5.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.21.0.tgz",
|
||||
"integrity": "sha512-HOjK8l6a57b2ZGXOcUsI5NLfoTrfmbOl90ixJDl0AEFG4wgHNDQxtZy15/ZQp7HhjkpaGlp/eneMgtsu1dIlUA==",
|
||||
"version": "5.13.0",
|
||||
"resolved": "https://registry.npmmirror.com/undici/-/undici-5.13.0.tgz",
|
||||
"integrity": "sha512-UDZKtwb2k7KRsK4SdXWG7ErXiL7yTGgLWvk2AXO1JMjgjh404nFo6tWSCM2xMpJwMPx3J8i/vfqEh1zOqvj82Q==",
|
||||
"dependencies": {
|
||||
"busboy": "^1.6.0"
|
||||
},
|
||||
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd ../website
|
||||
|
||||
npx @crowdin/cli@latest pull -b master --export-only-approved
|
||||
@@ -2,15 +2,14 @@ package flags
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/samber/lo"
|
||||
"github.com/wailsapp/wails/v2/internal/project"
|
||||
"github.com/wailsapp/wails/v2/pkg/commands/build"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/samber/lo"
|
||||
"github.com/wailsapp/wails/v2/internal/project"
|
||||
"github.com/wailsapp/wails/v2/pkg/commands/build"
|
||||
)
|
||||
|
||||
type Dev struct {
|
||||
@@ -127,7 +126,6 @@ func (d *Dev) GenerateBuildOptions() *build.Options {
|
||||
Compiler: d.Compiler,
|
||||
ForceBuild: d.ForceBuild,
|
||||
IgnoreFrontend: d.SkipFrontend,
|
||||
SkipBindings: d.SkipBindings,
|
||||
Verbosity: d.Verbosity,
|
||||
WailsJSDir: d.WailsJSDir,
|
||||
RaceDetector: d.RaceDetector,
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/wailsapp/wails/v2/cmd/wails/flags"
|
||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/gomod"
|
||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/logutils"
|
||||
"golang.org/x/mod/semver"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/commands/buildtags"
|
||||
|
||||
@@ -37,10 +36,6 @@ import (
|
||||
"github.com/wailsapp/wails/v2/pkg/commands/build"
|
||||
)
|
||||
|
||||
const (
|
||||
viteMinVersion = "v3.0.0"
|
||||
)
|
||||
|
||||
func sliceToMap(input []string) map[string]struct{} {
|
||||
result := map[string]struct{}{}
|
||||
for _, value := range input {
|
||||
@@ -49,6 +44,31 @@ func sliceToMap(input []string) map[string]struct{} {
|
||||
return result
|
||||
}
|
||||
|
||||
type devFlags struct {
|
||||
ldflags string
|
||||
compilerCommand string
|
||||
assetDir string
|
||||
extensions string
|
||||
reloadDirs string
|
||||
openBrowser bool
|
||||
noReload bool
|
||||
skipBindings bool
|
||||
wailsjsdir string
|
||||
tags string
|
||||
verbosity int
|
||||
loglevel string
|
||||
forceBuild bool
|
||||
debounceMS int
|
||||
devServer string
|
||||
appargs string
|
||||
saveConfig bool
|
||||
raceDetector bool
|
||||
|
||||
frontendDevServerURL string
|
||||
skipFrontend bool
|
||||
noColour bool
|
||||
}
|
||||
|
||||
// Application runs the application in dev mode
|
||||
func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
|
||||
|
||||
@@ -93,11 +113,10 @@ func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
|
||||
buildOptions.IgnoreApplication = false
|
||||
}
|
||||
|
||||
legacyUseDevServerInsteadofCustomScheme := false
|
||||
// frontend:dev:watcher command.
|
||||
frontendDevAutoDiscovery := projectConfig.IsFrontendDevServerURLAutoDiscovery()
|
||||
if command := projectConfig.DevWatcherCommand; command != "" {
|
||||
closer, devServerURL, devServerViteVersion, err := runFrontendDevWatcherCommand(projectConfig.GetFrontendDir(), command, frontendDevAutoDiscovery)
|
||||
closer, devServerURL, err := runFrontendDevWatcherCommand(projectConfig.GetFrontendDir(), command, frontendDevAutoDiscovery)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -106,12 +125,6 @@ func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
|
||||
f.FrontendDevServerURL = devServerURL
|
||||
}
|
||||
defer closer()
|
||||
|
||||
if devServerViteVersion != "" && semver.Compare(devServerViteVersion, viteMinVersion) < 0 {
|
||||
logutils.LogRed("Please upgrade your Vite Server to at least '%s' future Wails versions will require at least Vite '%s'", viteMinVersion, viteMinVersion)
|
||||
time.Sleep(3 * time.Second)
|
||||
legacyUseDevServerInsteadofCustomScheme = true
|
||||
}
|
||||
} else if frontendDevAutoDiscovery {
|
||||
return fmt.Errorf("unable to auto discover frontend:dev:serverUrl without a frontend:dev:watcher command, please either set frontend:dev:watcher or remove the auto discovery from frontend:dev:serverUrl")
|
||||
}
|
||||
@@ -119,7 +132,7 @@ func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
|
||||
// Do initial build but only for the application.
|
||||
logger.Println("Building application for development...")
|
||||
buildOptions.IgnoreFrontend = true
|
||||
debugBinaryProcess, appBinary, err := restartApp(buildOptions, nil, f, exitCodeChannel, legacyUseDevServerInsteadofCustomScheme)
|
||||
debugBinaryProcess, appBinary, err := restartApp(buildOptions, nil, f, exitCodeChannel)
|
||||
buildOptions.IgnoreFrontend = ignoreFrontend || f.FrontendDevServerURL != ""
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -165,7 +178,7 @@ func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
|
||||
}()
|
||||
|
||||
// Watch for changes and trigger restartApp()
|
||||
debugBinaryProcess = doWatcherLoop(buildOptions, debugBinaryProcess, f, watcher, exitCodeChannel, quitChannel, f.DevServerURL(), legacyUseDevServerInsteadofCustomScheme)
|
||||
debugBinaryProcess = doWatcherLoop(buildOptions, debugBinaryProcess, f, watcher, exitCodeChannel, quitChannel, f.DevServerURL())
|
||||
|
||||
// Kill the current program if running and remove dev binary
|
||||
if err := killProcessAndCleanupBinary(debugBinaryProcess, appBinary); err != nil {
|
||||
@@ -214,7 +227,7 @@ func runCommand(dir string, exitOnError bool, command string, args ...string) er
|
||||
}
|
||||
|
||||
// runFrontendDevWatcherCommand will run the `frontend:dev:watcher` command if it was given, ex- `npm run dev`
|
||||
func runFrontendDevWatcherCommand(frontendDirectory string, devCommand string, discoverViteServerURL bool) (func(), string, string, error) {
|
||||
func runFrontendDevWatcherCommand(frontendDirectory string, devCommand string, discoverViteServerURL bool) (func(), string, error) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
scanner := NewStdoutScanner()
|
||||
cmdSlice := strings.Split(devCommand, " ")
|
||||
@@ -226,7 +239,7 @@ func runFrontendDevWatcherCommand(frontendDirectory string, devCommand string, d
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
cancel()
|
||||
return nil, "", "", fmt.Errorf("unable to start frontend DevWatcher: %w", err)
|
||||
return nil, "", fmt.Errorf("unable to start frontend DevWatcher: %w", err)
|
||||
}
|
||||
|
||||
var viteServerURL string
|
||||
@@ -236,19 +249,10 @@ func runFrontendDevWatcherCommand(frontendDirectory string, devCommand string, d
|
||||
viteServerURL = serverURL
|
||||
case <-time.After(time.Second * 10):
|
||||
cancel()
|
||||
return nil, "", "", errors.New("failed to find Vite server URL")
|
||||
return nil, "", errors.New("failed to find Vite server URL")
|
||||
}
|
||||
}
|
||||
|
||||
viteVersion := ""
|
||||
select {
|
||||
case version := <-scanner.ViteServerVersionC:
|
||||
viteVersion = version
|
||||
|
||||
case <-time.After(time.Second * 5):
|
||||
// That's fine, then most probably it was not vite that was running
|
||||
}
|
||||
|
||||
logutils.LogGreen("Running frontend DevWatcher command: '%s'", devCommand)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -276,11 +280,11 @@ func runFrontendDevWatcherCommand(frontendDirectory string, devCommand string, d
|
||||
}
|
||||
cancel()
|
||||
wg.Wait()
|
||||
}, viteServerURL, viteVersion, nil
|
||||
}, viteServerURL, nil
|
||||
}
|
||||
|
||||
// restartApp does the actual rebuilding of the application when files change
|
||||
func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, exitCodeChannel chan int, legacyUseDevServerInsteadofCustomScheme bool) (*process.Process, string, error) {
|
||||
func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, exitCodeChannel chan int) (*process.Process, string, error) {
|
||||
|
||||
appBinary, err := build.Build(buildOptions)
|
||||
println()
|
||||
@@ -318,9 +322,6 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process
|
||||
os.Setenv("assetdir", f.AssetDir)
|
||||
os.Setenv("devserver", f.DevServer)
|
||||
os.Setenv("frontenddevserverurl", f.FrontendDevServerURL)
|
||||
if legacyUseDevServerInsteadofCustomScheme {
|
||||
os.Setenv("legacyusedevsererinsteadofcustomscheme", "true")
|
||||
}
|
||||
|
||||
// Start up new binary with correct args
|
||||
newProcess := process.NewProcess(appBinary, args...)
|
||||
@@ -340,7 +341,7 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process
|
||||
}
|
||||
|
||||
// doWatcherLoop is the main watch loop that runs while dev is active
|
||||
func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, watcher *fsnotify.Watcher, exitCodeChannel chan int, quitChannel chan os.Signal, devServerURL *url.URL, legacyUseDevServerInsteadofCustomScheme bool) *process.Process {
|
||||
func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, watcher *fsnotify.Watcher, exitCodeChannel chan int, quitChannel chan os.Signal, devServerURL *url.URL) *process.Process {
|
||||
// Main Loop
|
||||
var extensionsThatTriggerARebuild = sliceToMap(strings.Split(f.Extensions, ","))
|
||||
var dirsThatTriggerAReload []string
|
||||
@@ -446,7 +447,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
|
||||
rebuild = false
|
||||
logutils.LogGreen("[Rebuild triggered] files updated")
|
||||
// Try and build the app
|
||||
newBinaryProcess, _, err := restartApp(buildOptions, debugBinaryProcess, f, exitCodeChannel, legacyUseDevServerInsteadofCustomScheme)
|
||||
newBinaryProcess, _, err := restartApp(buildOptions, debugBinaryProcess, f, exitCodeChannel)
|
||||
if err != nil {
|
||||
logutils.LogRed("Error during build: %s", err.Error())
|
||||
continue
|
||||
|
||||
@@ -2,47 +2,30 @@ package dev
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/acarl005/stripansi"
|
||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/logutils"
|
||||
"golang.org/x/mod/semver"
|
||||
)
|
||||
|
||||
// stdoutScanner acts as a stdout target that will scan the incoming
|
||||
// data to find out the vite server url
|
||||
type stdoutScanner struct {
|
||||
ViteServerURLChan chan string
|
||||
ViteServerVersionC chan string
|
||||
versionDetected bool
|
||||
ViteServerURLChan chan string
|
||||
}
|
||||
|
||||
// NewStdoutScanner creates a new stdoutScanner
|
||||
func NewStdoutScanner() *stdoutScanner {
|
||||
return &stdoutScanner{
|
||||
ViteServerURLChan: make(chan string, 2),
|
||||
ViteServerVersionC: make(chan string, 2),
|
||||
ViteServerURLChan: make(chan string, 2),
|
||||
}
|
||||
}
|
||||
|
||||
// Write bytes to the scanner. Will copy the bytes to stdout
|
||||
func (s *stdoutScanner) Write(data []byte) (n int, err error) {
|
||||
input := stripansi.Strip(string(data))
|
||||
if !s.versionDetected {
|
||||
v, err := detectViteVersion(input)
|
||||
if v != "" || err != nil {
|
||||
if err != nil {
|
||||
logutils.LogRed("ViteStdoutScanner: %s", err)
|
||||
v = "v0.0.0"
|
||||
}
|
||||
s.ViteServerVersionC <- v
|
||||
s.versionDetected = true
|
||||
}
|
||||
}
|
||||
|
||||
match := strings.Index(input, "Local:")
|
||||
if match != -1 {
|
||||
sc := bufio.NewScanner(strings.NewReader(input))
|
||||
@@ -64,21 +47,3 @@ func (s *stdoutScanner) Write(data []byte) (n int, err error) {
|
||||
}
|
||||
return os.Stdout.Write(data)
|
||||
}
|
||||
|
||||
func detectViteVersion(line string) (string, error) {
|
||||
s := strings.Split(strings.TrimSpace(line), " ")
|
||||
if strings.ToLower(s[0]) != "vite" {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
if len(line) < 2 {
|
||||
return "", fmt.Errorf("unable to parse vite version")
|
||||
}
|
||||
|
||||
v := s[1]
|
||||
if !semver.IsValid(v) {
|
||||
return "", fmt.Errorf("%s is not a valid vite version string", v)
|
||||
}
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func printBulletPoint(text string, args ...any) {
|
||||
fatal(err.Error())
|
||||
}
|
||||
t = strings.Trim(t, "\n\r")
|
||||
pterm.Printfln(t, args...)
|
||||
pterm.Printf(t, args...)
|
||||
}
|
||||
|
||||
func printFooter() {
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^3.0.7"
|
||||
"vite": "^2.9.9"
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,9 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
iofs "io/fs"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/assetserver"
|
||||
|
||||
@@ -106,35 +104,17 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
||||
}
|
||||
|
||||
if frontendDevServerURL != "" {
|
||||
if os.Getenv("legacyusedevsererinsteadofcustomscheme") != "" {
|
||||
startURL, err := url.Parse("http://" + devServer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx = context.WithValue(ctx, "starturl", startURL)
|
||||
if devServer == "" {
|
||||
return nil, fmt.Errorf("Unable to use FrontendDevServerUrl without a DevServer address")
|
||||
}
|
||||
|
||||
ctx = context.WithValue(ctx, "frontenddevserverurl", frontendDevServerURL)
|
||||
|
||||
externalURL, err := url.Parse(frontendDevServerURL)
|
||||
startURL, err := url.Parse("http://" + devServer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if externalURL.Host == "" {
|
||||
return nil, fmt.Errorf("Invalid frontend:dev:serverUrl missing protocol scheme?")
|
||||
}
|
||||
|
||||
waitCb := func() { myLogger.Debug("Waiting for frontend DevServer '%s' to be ready", externalURL) }
|
||||
if !checkPortIsOpen(externalURL.Host, time.Minute, waitCb) {
|
||||
myLogger.Error("Timeout waiting for frontend DevServer")
|
||||
}
|
||||
|
||||
handler := assetserver.NewExternalAssetsHandler(myLogger, assetConfig, externalURL)
|
||||
assetConfig.Assets = nil
|
||||
assetConfig.Handler = handler
|
||||
assetConfig.Middleware = nil
|
||||
ctx = context.WithValue(ctx, "starturl", startURL)
|
||||
ctx = context.WithValue(ctx, "frontenddevserverurl", frontendDevServerURL)
|
||||
|
||||
myLogger.Info("Serving assets from frontend DevServer URL: %s", frontendDevServerURL)
|
||||
} else {
|
||||
@@ -266,22 +246,3 @@ func tryInferAssetDirFromFS(assets iofs.FS) (string, error) {
|
||||
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func checkPortIsOpen(host string, timeout time.Duration, waitCB func()) (ret bool) {
|
||||
if timeout == 0 {
|
||||
timeout = time.Minute
|
||||
}
|
||||
|
||||
deadline := time.Now().Add(timeout)
|
||||
for time.Now().Before(deadline) {
|
||||
conn, _ := net.DialTimeout("tcp", host, 2*time.Second)
|
||||
if conn != nil {
|
||||
conn.Close()
|
||||
return true
|
||||
}
|
||||
|
||||
waitCB()
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -12,6 +12,5 @@ typedef int Role;
|
||||
|
||||
static const Role AppMenu = 1;
|
||||
static const Role EditMenu = 2;
|
||||
static const Role WindowMenu = 3;
|
||||
|
||||
#endif /* Role_h */
|
||||
|
||||
@@ -68,20 +68,12 @@
|
||||
appName = [[NSProcessInfo processInfo] processName];
|
||||
}
|
||||
WailsMenu *appMenu = [[[WailsMenu new] initWithNSTitle:appName] autorelease];
|
||||
|
||||
if (ctx.aboutTitle != nil) {
|
||||
[appMenu addItem:[self newMenuItemWithContext :ctx :[@"About " stringByAppendingString:appName] :@selector(About) :nil :0]];
|
||||
[appMenu addItem:[NSMenuItem separatorItem]];
|
||||
}
|
||||
|
||||
[appMenu addItem:[self newMenuItem:[@"Hide " stringByAppendingString:appName] :@selector(hide:) :@"h" :NSEventModifierFlagCommand]];
|
||||
[appMenu addItem:[self newMenuItem:@"Hide Others" :@selector(hideOtherApplications:) :@"h" :(NSEventModifierFlagOption | NSEventModifierFlagCommand)]];
|
||||
[appMenu addItem:[self newMenuItem:@"Show All" :@selector(unhideAllApplications:) :@""]];
|
||||
[appMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
id quitTitle = [@"Quit " stringByAppendingString:appName];
|
||||
NSMenuItem* quitMenuItem = [self newMenuItem:quitTitle :@selector(Quit) :@"q" :NSEventModifierFlagCommand];
|
||||
quitMenuItem.target = ctx;
|
||||
if (ctx.aboutTitle != nil) {
|
||||
[appMenu addItem:[self newMenuItemWithContext :ctx :[@"About " stringByAppendingString:appName] :@selector(About) :nil :0]];
|
||||
}
|
||||
[appMenu addItem:quitMenuItem];
|
||||
[self appendSubmenu:appMenu];
|
||||
break;
|
||||
@@ -108,17 +100,6 @@
|
||||
[editMenu appendSubmenu:speechMenu];
|
||||
[self appendSubmenu:editMenu];
|
||||
|
||||
break;
|
||||
}
|
||||
case WindowMenu:
|
||||
{
|
||||
WailsMenu *windowMenu = [[[WailsMenu new] initWithNSTitle:@"Window"] autorelease];
|
||||
[windowMenu addItem:[self newMenuItem:@"Minimize" :@selector(performMiniaturize:) :@"m" :NSEventModifierFlagCommand]];
|
||||
[windowMenu addItem:[self newMenuItem:@"Zoom" :@selector(performZoom:) :@""]];
|
||||
[windowMenu addItem:[NSMenuItem separatorItem]];
|
||||
[windowMenu addItem:[self newMenuItem:@"Full Screen" :@selector(enterFullScreenMode:) :@"f" :(NSEventModifierFlagControl | NSEventModifierFlagCommand)]];
|
||||
[self appendSubmenu:windowMenu];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"html/template"
|
||||
"log"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/assetserver"
|
||||
@@ -113,6 +114,7 @@ func (f *Frontend) startMessageProcessor() {
|
||||
func (f *Frontend) startRequestProcessor() {
|
||||
for request := range requestBuffer {
|
||||
f.assets.ServeWebViewRequest(request)
|
||||
request.Release()
|
||||
}
|
||||
}
|
||||
func (f *Frontend) startCallbackProcessor() {
|
||||
@@ -335,11 +337,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
}
|
||||
|
||||
func (f *Frontend) Callback(message string) {
|
||||
escaped, err := json.Marshal(message)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
f.ExecJS(`window.wails.Callback(` + string(escaped) + `);`)
|
||||
f.ExecJS(`window.wails.Callback(` + strconv.Quote(message) + `);`)
|
||||
}
|
||||
|
||||
func (f *Frontend) ExecJS(js string) {
|
||||
|
||||
@@ -130,5 +130,6 @@ func (f *Frontend) MenuSetApplicationMenu(menu *menu.Menu) {
|
||||
}
|
||||
|
||||
func (f *Frontend) MenuUpdateApplicationMenu() {
|
||||
f.MenuSetApplicationMenu(f.frontendOptions.Menu)
|
||||
f.mainWindow.UpdateApplicationMenu()
|
||||
}
|
||||
|
||||
@@ -78,15 +78,16 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
"unsafe"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/assetserver/webview"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/binding"
|
||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||
@@ -165,7 +166,10 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.
|
||||
}
|
||||
result.assets = assets
|
||||
|
||||
go result.startRequestProcessor()
|
||||
// Start 10 processors to handle requests in parallel
|
||||
for i := 0; i < 10; i++ {
|
||||
go result.startRequestProcessor()
|
||||
}
|
||||
}
|
||||
|
||||
go result.startMessageProcessor()
|
||||
@@ -433,11 +437,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
}
|
||||
|
||||
func (f *Frontend) Callback(message string) {
|
||||
escaped, err := json.Marshal(message)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
f.ExecJS(`window.wails.Callback(` + string(escaped) + `);`)
|
||||
f.ExecJS(`window.wails.Callback(` + strconv.Quote(message) + `);`)
|
||||
}
|
||||
|
||||
func (f *Frontend) startDrag() {
|
||||
@@ -461,15 +461,50 @@ func processMessage(message *C.char) {
|
||||
messageBuffer <- goMessage
|
||||
}
|
||||
|
||||
var requestBuffer = make(chan webview.Request, 100)
|
||||
var requestBuffer = make(chan unsafe.Pointer, 100)
|
||||
|
||||
func (f *Frontend) startRequestProcessor() {
|
||||
for request := range requestBuffer {
|
||||
f.assets.ServeWebViewRequest(request)
|
||||
f.processRequest(request)
|
||||
C.g_object_unref(C.gpointer(request))
|
||||
}
|
||||
}
|
||||
|
||||
//export processURLRequest
|
||||
func processURLRequest(request unsafe.Pointer) {
|
||||
requestBuffer <- webview.NewRequest(request)
|
||||
// Increment reference counter to allow async processing, will be decremented after the processing
|
||||
// has been finished by a worker.
|
||||
C.g_object_ref(C.gpointer(request))
|
||||
requestBuffer <- request
|
||||
}
|
||||
|
||||
func (f *Frontend) processRequest(request unsafe.Pointer) {
|
||||
req := (*C.WebKitURISchemeRequest)(request)
|
||||
uri := C.webkit_uri_scheme_request_get_uri(req)
|
||||
goURI := C.GoString(uri)
|
||||
|
||||
rw := &webKitResponseWriter{req: req}
|
||||
defer rw.Close()
|
||||
|
||||
f.assets.ProcessHTTPRequestLegacy(
|
||||
rw,
|
||||
func() (*http.Request, error) {
|
||||
method := webkit_uri_scheme_request_get_http_method(req)
|
||||
r, err := http.NewRequest(method, goURI, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.Header = webkit_uri_scheme_request_get_http_headers(req)
|
||||
|
||||
if r.URL.Host != f.startURL.Host {
|
||||
if r.Body != nil {
|
||||
r.Body.Close()
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("Expected host '%s' in request, but was '%s'", f.startURL.Host, r.URL.Host)
|
||||
}
|
||||
|
||||
return r, nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -12,12 +12,10 @@ import (
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/linux"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/assetserver/webview"
|
||||
)
|
||||
|
||||
func validateWebKit2Version(options *options.App) {
|
||||
if C.webkit_get_major_version() == 2 && C.webkit_get_minor_version() >= webview.Webkit2MinMinorVersion {
|
||||
if C.webkit_get_major_version() == 2 && C.webkit_get_minor_version() >= webkit2MinMinorVersion {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -26,6 +24,6 @@ func validateWebKit2Version(options *options.App) {
|
||||
msg = options.Linux.Messages
|
||||
}
|
||||
|
||||
v := fmt.Sprintf("2.%d.0", webview.Webkit2MinMinorVersion)
|
||||
v := fmt.Sprintf("2.%d.0", webkit2MinMinorVersion)
|
||||
showModalDialogAndExit("WebKit2GTK", fmt.Sprintf(msg.WebKit2GTKMinRequired, v))
|
||||
}
|
||||
|
||||
+7
-3
@@ -1,6 +1,6 @@
|
||||
//go:build linux && (webkit2_36 || webkit2_40)
|
||||
//go:build linux && webkit2_36
|
||||
|
||||
package webview
|
||||
package linux
|
||||
|
||||
/*
|
||||
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.0 libsoup-2.4
|
||||
@@ -15,8 +15,12 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/assetserver"
|
||||
)
|
||||
|
||||
const webkit2MinMinorVersion = 36
|
||||
|
||||
func webkit_uri_scheme_request_get_http_method(req *C.WebKitURISchemeRequest) string {
|
||||
method := C.GoString(C.webkit_uri_scheme_request_get_http_method(req))
|
||||
return strings.ToUpper(method)
|
||||
@@ -47,7 +51,7 @@ func webkit_uri_scheme_request_finish(req *C.WebKitURISchemeRequest, code int, h
|
||||
C.webkit_uri_scheme_response_set_status(resp, C.guint(code), cReason)
|
||||
C.free(unsafe.Pointer(cReason))
|
||||
|
||||
cMimeType := C.CString(header.Get(HeaderContentType))
|
||||
cMimeType := C.CString(header.Get(assetserver.HeaderContentType))
|
||||
C.webkit_uri_scheme_response_set_content_type(resp, cMimeType)
|
||||
C.free(unsafe.Pointer(cMimeType))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user