Skip to content

Commit def54f8

Browse files
authored
feat: add WebView support for extension (#1359)
1 parent a205c0b commit def54f8

92 files changed

Lines changed: 10244 additions & 2672 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
default: "false"
1414

1515
env:
16-
GO_VERSION: "1.24"
16+
GO_VERSION: "1.25"
1717
FLUTTER_VERSION: "3.41.6"
1818
GA4_MEASUREMENT_ID: ${{ secrets.GA4_MEASUREMENT_ID }}
1919
GA4_API_SECRET: ${{ secrets.GA4_API_SECRET }}
@@ -81,7 +81,7 @@ jobs:
8181
"CLANGARM64_ROOT=$target" >> $env:GITHUB_ENV
8282
$b >> $env:GITHUB_PATH
8383
84-
- uses: actions/setup-go@v4
84+
- uses: actions/setup-go@v5
8585
with:
8686
go-version: ${{ env.GO_VERSION }}
8787
- uses: subosito/flutter-action@v2
@@ -198,7 +198,7 @@ jobs:
198198
needs: [get-release]
199199
steps:
200200
- uses: actions/checkout@v3
201-
- uses: actions/setup-go@v4
201+
- uses: actions/setup-go@v5
202202
with:
203203
go-version: ${{ env.GO_VERSION }}
204204
- name: Build
@@ -224,7 +224,7 @@ jobs:
224224
needs: [get-release, build-macos-amd64-lib]
225225
steps:
226226
- uses: actions/checkout@v3
227-
- uses: actions/setup-go@v4
227+
- uses: actions/setup-go@v5
228228
with:
229229
go-version: ${{ env.GO_VERSION }}
230230
- uses: actions/setup-node@v3
@@ -315,7 +315,7 @@ jobs:
315315
needs: [get-release]
316316
steps:
317317
- uses: actions/checkout@v3
318-
- uses: actions/setup-go@v4
318+
- uses: actions/setup-go@v5
319319
with:
320320
go-version: ${{ env.GO_VERSION }}
321321
- uses: subosito/flutter-action@v2
@@ -324,7 +324,7 @@ jobs:
324324
channel: master
325325
- run: |
326326
sudo apt update -y
327-
sudo apt install -y ninja-build libgtk-3-dev libayatana-appindicator3-1 libayatana-appindicator3-dev rpm patchelf libfuse2 locate libkeybinder-3.0-dev
327+
sudo apt install -y ninja-build libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-1 libayatana-appindicator3-dev rpm patchelf libfuse2 locate libkeybinder-3.0-dev
328328
arch=$(uname -m)
329329
wget -O appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${arch}.AppImage"
330330
chmod +x appimagetool
@@ -411,7 +411,7 @@ jobs:
411411
needs: [get-release]
412412
steps:
413413
- uses: actions/checkout@v3
414-
- uses: actions/setup-go@v4
414+
- uses: actions/setup-go@v5
415415
with:
416416
go-version: ${{ env.GO_VERSION }}
417417
- name: Setup LXD
@@ -480,6 +480,7 @@ jobs:
480480
- cmake
481481
- curl
482482
- libgtk-3-dev
483+
- libwebkit2gtk-4.1-dev
483484
- libkeybinder-3.0-dev
484485
- ninja-build
485486
- unzip
@@ -495,6 +496,7 @@ jobs:
495496
source: .
496497
plugin: nil
497498
stage-packages:
499+
- libwebkit2gtk-4.1-0
498500
- libgtk-3-dev
499501
- libkeybinder-3.0-dev
500502
- libappindicator3-dev
@@ -545,7 +547,7 @@ jobs:
545547
needs: [get-release]
546548
steps:
547549
- uses: actions/checkout@v3
548-
- uses: actions/setup-go@v4
550+
- uses: actions/setup-go@v5
549551
with:
550552
go-version: ${{ env.GO_VERSION }}
551553
- uses: actions/setup-java@v3
@@ -587,7 +589,7 @@ jobs:
587589
needs: [get-release]
588590
steps:
589591
- uses: actions/checkout@v3
590-
- uses: actions/setup-go@v4
592+
- uses: actions/setup-go@v5
591593
with:
592594
go-version: ${{ env.GO_VERSION }}
593595
- uses: subosito/flutter-action@v2
@@ -620,7 +622,7 @@ jobs:
620622
needs: [get-release]
621623
steps:
622624
- uses: actions/checkout@v3
623-
- uses: actions/setup-go@v4
625+
- uses: actions/setup-go@v5
624626
with:
625627
go-version: ${{ env.GO_VERSION }}
626628
- uses: subosito/flutter-action@v2

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
- "Dockerfile"
1818

1919
env:
20-
GO_VERSION: "1.24"
20+
GO_VERSION: "1.25"
2121

2222
permissions:
2323
contents: write
@@ -31,7 +31,7 @@ jobs:
3131

3232
steps:
3333
- uses: actions/checkout@v3
34-
- uses: actions/setup-go@v4
34+
- uses: actions/setup-go@v5
3535
with:
3636
go-version: ${{ env.GO_VERSION }}
3737
- uses: release-drafter/release-drafter@v5

.github/workflows/test.yml

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828
workflow_dispatch:
2929

3030
env:
31-
GO_VERSION: "1.24"
31+
GO_VERSION: "1.25"
3232
FLUTTER_VERSION: "3.41.6"
3333

3434
jobs:
@@ -50,21 +50,77 @@ jobs:
5050
runs-on: ubuntu-latest
5151
steps:
5252
- uses: actions/checkout@v3
53-
- uses: actions/setup-go@v4
53+
- uses: actions/setup-go@v5
5454
with:
5555
go-version: ${{ env.GO_VERSION }}
56+
- name: Install webview dependencies
57+
run: |
58+
sudo apt-get update -y
59+
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev xvfb
5660
- name: Run Unit tests.
5761
run: |
5862
# Get packages for testing and coverage (including cmd/web for flags_test.go)
59-
PACKAGES=$(go list ./... | grep -v /bind/ | grep -v -E '/cmd/(?!web)')
60-
go test -v -coverpkg=$(echo "$PACKAGES" | paste -sd "," -) -covermode=count -coverprofile=coverage.txt $PACKAGES
63+
PACKAGES=$(go list ./... | awk '!/\/bind\// && (!/\/cmd\// || /\/cmd\/web$/)')
64+
env CGO_ENABLED=1 xvfb-run -a go test -tags webview -v -coverpkg=$(echo "$PACKAGES" | paste -sd "," -) -covermode=count -coverprofile=coverage.txt $PACKAGES
6165
# Filter out main.go from coverage report to avoid lowering coverage percentage
6266
grep -v "main.go" coverage.txt > coverage_filtered.txt || true
6367
mv coverage_filtered.txt coverage.txt
6468
- uses: codecov/codecov-action@v4
6569
with:
6670
files: ./coverage.txt
6771
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
72+
test-webview-integration:
73+
name: Test webview integration (${{ matrix.name }})
74+
strategy:
75+
fail-fast: false
76+
matrix:
77+
include:
78+
- name: Windows
79+
os: windows-latest
80+
- name: macOS
81+
os: macos-latest
82+
runs-on: ${{ matrix.os }}
83+
steps:
84+
- uses: actions/checkout@v3
85+
- uses: actions/setup-go@v5
86+
with:
87+
go-version: ${{ env.GO_VERSION }}
88+
- uses: subosito/flutter-action@v2
89+
if: runner.os == 'macOS'
90+
with:
91+
flutter-version: ${{ env.FLUTTER_VERSION }}
92+
- name: Test webview
93+
if: runner.os == 'Windows'
94+
run: go test -tags webview -v -timeout 300s ./internal/webview/goprovider/
95+
env:
96+
CGO_ENABLED: 1
97+
- name: Test webview
98+
if: runner.os == 'macOS'
99+
shell: bash
100+
run: |
101+
set -euo pipefail
102+
SOCKET_PATH="$HOME/Library/Application Support/com.gopeed.gopeed/gopeed_webview.sock"
103+
LOG_PATH="$RUNNER_TEMP/gopeed-webview-rpc.log"
104+
rm -f "$SOCKET_PATH"
105+
106+
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/macos/Frameworks/libgopeed.dylib github.com/GopeedLab/gopeed/bind/desktop
107+
108+
cd ui/flutter
109+
flutter pub get
110+
flutter run -d macos >"$LOG_PATH" 2>&1 &
111+
FLUTTER_PID=$!
112+
cd ../..
113+
114+
cleanup() {
115+
kill "$FLUTTER_PID" >/dev/null 2>&1 || true
116+
}
117+
trap cleanup EXIT
118+
119+
if ! go test -tags webview -v -timeout 600s ./internal/webview/rpcprovider/ -args -webview-rpc-network unix -webview-rpc-address "$SOCKET_PATH"; then
120+
cat "$LOG_PATH"
121+
exit 1
122+
fi
123+
68124
build-desktop:
69125
strategy:
70126
matrix:
@@ -80,7 +136,7 @@ jobs:
80136
flutter_channel: "main"
81137
name: Build desktop check (${{ matrix.os }})
82138
runs-on: ${{ matrix.os }}
83-
needs: [test]
139+
needs: [ test ]
84140
steps:
85141
- uses: actions/checkout@v3
86142
- name: Enable long paths for flutter main branch checks
@@ -109,7 +165,7 @@ jobs:
109165
"CGO_ENABLED=1" >> $env:GITHUB_ENV
110166
"CLANGARM64_ROOT=$target" >> $env:GITHUB_ENV
111167
$b >> $env:GITHUB_PATH
112-
- uses: actions/setup-go@v4
168+
- uses: actions/setup-go@v5
113169
with:
114170
go-version: ${{ env.GO_VERSION }}
115171
- uses: subosito/flutter-action@v2
@@ -129,7 +185,7 @@ jobs:
129185
- if: runner.os == 'Linux'
130186
run: |
131187
sudo apt-get update -y
132-
sudo apt-get install -y ninja-build libgtk-3-dev libayatana-appindicator3-dev libkeybinder-3.0-dev
188+
sudo apt-get install -y ninja-build libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libkeybinder-3.0-dev
133189
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop
134190
cd ui/flutter
135191
flutter build linux
@@ -138,11 +194,11 @@ jobs:
138194
runs-on: ${{ matrix.os }}
139195
strategy:
140196
matrix:
141-
os: [macos-14, ubuntu-latest]
142-
needs: [test]
197+
os: [ macos-14, ubuntu-latest ]
198+
needs: [ test ]
143199
steps:
144200
- uses: actions/checkout@v3
145-
- uses: actions/setup-go@v4
201+
- uses: actions/setup-go@v5
146202
with:
147203
go-version: ${{ env.GO_VERSION }}
148204
- uses: subosito/flutter-action@v2
@@ -171,10 +227,10 @@ jobs:
171227
build-web:
172228
name: Build web check
173229
runs-on: ubuntu-latest
174-
needs: [test]
230+
needs: [ test ]
175231
steps:
176232
- uses: actions/checkout@v3
177-
- uses: actions/setup-go@v4
233+
- uses: actions/setup-go@v5
178234
with:
179235
go-version: ${{ env.GO_VERSION }}
180236
- uses: subosito/flutter-action@v2
@@ -192,10 +248,10 @@ jobs:
192248
build-docker:
193249
name: Build docker check
194250
runs-on: ubuntu-latest
195-
needs: [test]
251+
needs: [ test ]
196252
steps:
197253
- uses: actions/checkout@v3
198-
- uses: actions/setup-go@v4
254+
- uses: actions/setup-go@v5
199255
with:
200256
go-version: ${{ env.GO_VERSION }}
201257
- uses: subosito/flutter-action@v2

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24.11-alpine3.23 AS go
1+
FROM golang:1.25.4-alpine3.22 AS go
22
WORKDIR /app
33
COPY ./go.mod ./go.sum ./
44
RUN go mod download

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ This project is divided into two parts, the front end uses `flutter`, the back e
201201
202202
### 🌍 Environment
203203

204-
1. Golang 1.24+
204+
1. Golang 1.25+
205205
2. Flutter 3.38+
206206

207207
### 📋 Clone

README_ja-JP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Gopeed (正式名 Go Speed) は `Golang` + `Flutter` によって開発された
182182
183183
### 🌍 環境
184184

185-
1. Go 言語 1.24+
185+
1. Go 言語 1.25+
186186
2. Flutter 3.38+
187187

188188
### 📋 クローン

README_vi-VN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Dự án này được chia thành hai phần, phần giao diện sử dụng `f
188188
189189
### 🌍 Environment
190190

191-
1. Golang 1.24+
191+
1. Golang 1.25+
192192
2. Flutter 3.38+
193193

194194
### 📋 Clone

README_zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Gopeed 还提供了浏览器扩展用于接管浏览器下载,支持 Chrome、
192192
193193
### 🌍 环境要求
194194

195-
1. Golang 1.24+
195+
1. Golang 1.25+
196196
2. Flutter 3.38+
197197

198198
### 📋 克隆项目

README_zh-TW.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ go install github.com/GopeedLab/gopeed/cmd/gopeed@latest
189189
190190
### 🌍 開發環境
191191

192-
1. Golang 1.24+
192+
1. Golang 1.25+
193193
2. Flutter 3.38+
194194

195195
### 📋 克隆項目

bind/desktop/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func Start(cfg *C.char) (int, *C.char) {
1616
return 0, C.CString(err.Error())
1717
}
1818
config.ProductionMode = true
19+
applyWebViewProvider(&config)
1920
realPort, err := rest.Start(&config)
2021
if err != nil {
2122
return 0, C.CString(err.Error())

0 commit comments

Comments
 (0)