@yufengtadian/freedom-cli 1.13.2 → 1.14.0-preview
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +40 -0
- package/README.md +74 -21
- package/lib/agents.js +182 -52
- package/lib/build.js +119 -42
- package/lib/cli.js +106 -9
- package/lib/release.js +22 -6
- package/lib/security.js +525 -45
- package/lib/shell.js +288 -64
- package/lib/toolchain.js +339 -0
- package/lib/utils.js +51 -0
- package/lib/verify.js +85 -30
- package/lib/webkit.js +45 -0
- package/package.json +4 -3
- package/shell/darwin-arm64/freedom-shell +0 -0
- package/shell/linux-x64/freedom-shell +0 -0
- package/shell/win-x64/freedom-shell.exe +0 -0
- package/skill/freedom/SKILL.md +3 -3
- package/templates/desktop/backend/desktop.mjs +16 -6
- package/templates/desktop/freedom.config.js +4 -1
- package/templates/go/go.mod +3 -0
- package/templates/go/pkg/freedom/anti_debug_linux.go +69 -0
- package/templates/go/pkg/freedom/anti_debug_other.go +5 -3
- package/templates/go/pkg/freedom/anti_debug_windows.go +136 -12
- package/templates/go/pkg/freedom/assets_embed.go +1 -0
- package/templates/go/pkg/freedom/backend_proc.go +5 -5
- package/templates/go/pkg/freedom/events_windows.go +5 -5
- package/templates/go/pkg/freedom/freedom.go +17 -3
- package/templates/go/pkg/freedom/msgwindow_windows.go +8 -8
- package/templates/go/pkg/freedom/resources.go +59 -1
- package/templates/go/pkg/freedom/security.go +475 -41
- package/templates/go/pkg/freedom/shutdown.go +55 -0
- package/templates/go/pkg/freedom/shutdown_windows.go +47 -0
- package/templates/go/pkg/freedom/store.go +3 -3
- package/templates/go/pkg/freedom/syscap_windows.go +33 -33
- package/templates/go/pkg/freedom/sysint_windows.go +2 -2
- package/templates/go/pkg/freedom/tray_windows.go +18 -18
- package/templates/go/pkg/freedom/updater.go +3 -3
- package/templates/go/third_party/webview_go/CHANGELOG.md +15 -0
- package/templates/go/third_party/webview_go/FREEDOM-PATCH.md +32 -0
- package/templates/go/third_party/webview_go/LICENSE +22 -0
- package/templates/go/third_party/webview_go/README.md +50 -0
- package/templates/go/third_party/webview_go/glue.c +36 -0
- package/templates/go/third_party/webview_go/go.mod +3 -0
- package/templates/go/third_party/webview_go/go.sum +0 -0
- package/templates/go/third_party/webview_go/libs/mswebview2/LICENSE +27 -0
- package/templates/go/third_party/webview_go/libs/mswebview2/include/WebView2.h +23568 -0
- package/templates/go/third_party/webview_go/libs/mswebview2/include/vendor.go +2 -0
- package/templates/go/third_party/webview_go/libs/mswebview2/vendor.go +2 -0
- package/templates/go/third_party/webview_go/libs/mswebview2/version.txt +1 -0
- package/templates/go/third_party/webview_go/libs/webview/LICENSE +22 -0
- package/templates/go/third_party/webview_go/libs/webview/include/vendor.go +2 -0
- package/templates/go/third_party/webview_go/libs/webview/include/webview.h +3598 -0
- package/templates/go/third_party/webview_go/libs/webview/vendor.go +2 -0
- package/templates/go/third_party/webview_go/libs/webview/version.txt +1 -0
- package/templates/go/third_party/webview_go/webkit2_40.go +21 -0
- package/templates/go/third_party/webview_go/webkit2_41.go +8 -0
- package/templates/go/third_party/webview_go/webview.cc +1 -0
- package/templates/go/third_party/webview_go/webview.go +332 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
package freedom
|
|
2
|
+
|
|
3
|
+
// 退出前清扫(跨平台):high 模式把后端源码解密到系统临时目录,正常退出由 Run 的
|
|
4
|
+
// defer 删除;但 SIGINT / SIGTERM(Ctrl+C、`kill`、systemd stop)会让 Go 直接终止
|
|
5
|
+
// 进程,defer 与 cleanup 都不执行,明文后端源码就永久躺在 %TEMP% / /tmp 里——
|
|
6
|
+
// 直到用户下次再启动这个应用才会被启动期 GC 回收。对「磁盘不留明文」的承诺来说
|
|
7
|
+
// 这是真空档,故在此显式接管常规信号:命中即先清扫再退。
|
|
8
|
+
//
|
|
9
|
+
// 边界:SIGKILL / taskkill /F / 断电无法拦截(无用户态代码可跑),仍靠下次启动的
|
|
10
|
+
// gcStaleSecureBackendDirs 兜底;Windows 的控制台事件见 shutdown_windows.go。
|
|
11
|
+
|
|
12
|
+
import (
|
|
13
|
+
"os"
|
|
14
|
+
"os/signal"
|
|
15
|
+
"sync"
|
|
16
|
+
"syscall"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
// secureCleanup 由 Run 注册(Run 未跑过就没有可清的东西)。
|
|
20
|
+
var secureCleanup func()
|
|
21
|
+
|
|
22
|
+
// cleanupOnce 用指针:单测需要一个可复位的实例来断言「只挂一次」。
|
|
23
|
+
var cleanupOnce = new(sync.Once)
|
|
24
|
+
|
|
25
|
+
// platformShutdownHooks 由各平台补挂退出通道(Windows 控制台事件),无额外通道的平台为 nil。
|
|
26
|
+
var platformShutdownHooks func()
|
|
27
|
+
|
|
28
|
+
// installShutdownCleanup 幂等地挂上退出清扫通道,由 Run 在注册 secureCleanup 后调用。
|
|
29
|
+
func installShutdownCleanup() {
|
|
30
|
+
cleanupOnce.Do(func() {
|
|
31
|
+
ch := make(chan os.Signal, 1)
|
|
32
|
+
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
|
|
33
|
+
go waitForShutdownSignal(ch)
|
|
34
|
+
if platformShutdownHooks != nil {
|
|
35
|
+
platformShutdownHooks()
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// waitForShutdownSignal 命中信号即清扫退场;拆成变量便于单测注入(真实信号无法跨平台自投)。
|
|
41
|
+
var waitForShutdownSignal = func(ch <-chan os.Signal) {
|
|
42
|
+
<-ch
|
|
43
|
+
exitAfterCleanup()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// exitAfterCleanup 清扫后以 130(128+SIGINT 惯例)退出。
|
|
47
|
+
func exitAfterCleanup() {
|
|
48
|
+
if fn := secureCleanup; fn != nil {
|
|
49
|
+
fn()
|
|
50
|
+
}
|
|
51
|
+
shutdownExit(130)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// shutdownExit 是 os.Exit 的槽位:单测靠它断言"先清扫再退出",否则会把测试进程一起带走。
|
|
55
|
+
var shutdownExit = os.Exit
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//go:build windows
|
|
2
|
+
|
|
3
|
+
package freedom
|
|
4
|
+
|
|
5
|
+
// Windows 退出通道补挂:SIGTERM 在本平台不存在,控制台关闭 / 注销 / 关机走
|
|
6
|
+
// SetConsoleCtrlHandler。命中 CTRL_CLOSE_EVENT 时系统只给约 5 秒宽限,
|
|
7
|
+
// 删一个临时目录绑绑有余;GUI 无控制台时注册会失败,静默跳过(不影响信号通道)。
|
|
8
|
+
//
|
|
9
|
+
// 覆盖面要说清:`-H windowsgui` 发布的正式壳根本没有控制台,这条通道对它永不触发,
|
|
10
|
+
// 其正常关窗由 WM_CLOSE → DestroyWindow → Run 的 defer 清扫,强杀/崩溃由下次启动的
|
|
11
|
+
// gcStaleSecureBackendDirs 兜底。本通道实际服务控制台子系统构建(裸 go build、调试期直接跑 exe)。
|
|
12
|
+
|
|
13
|
+
import (
|
|
14
|
+
"syscall"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
var (
|
|
18
|
+
kernel32Shutdown = syscall.NewLazyDLL("kernel32.dll")
|
|
19
|
+
procSetConsoleCtrlHandler = kernel32Shutdown.NewProc("SetConsoleCtrlHandler")
|
|
20
|
+
|
|
21
|
+
consoleCtrlCloseEvent uint32 = 2
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
// consoleCtrlHandlerProc 的形参与返回必须是 uintptr:syscall.NewCallback 会校验
|
|
25
|
+
// 「一个 uintptr 宽返回值」,写成 BOOL 习惯的 uint32 直接 panic
|
|
26
|
+
// (compileCallback: expected function with one uintptr-sized result)。
|
|
27
|
+
func consoleCtrlHandlerProc(ctrlType uintptr) uintptr {
|
|
28
|
+
if uint32(ctrlType) == consoleCtrlCloseEvent {
|
|
29
|
+
exitAfterCleanup() // 不返回:清扫后立即退场
|
|
30
|
+
}
|
|
31
|
+
return 0 // 继续交给链上其它处理器
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// consoleCtrlHandler 固定在包级求值一次:syscall.NewCallback 每次调用都占用全局句柄表,
|
|
35
|
+
// 重复申请会泄漏(与 events_windows.go 的同款约束)。
|
|
36
|
+
var consoleCtrlHandler = syscall.NewCallback(consoleCtrlHandlerProc)
|
|
37
|
+
|
|
38
|
+
func init() {
|
|
39
|
+
platformShutdownHooks = installConsoleCtrlCleanup
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func installConsoleCtrlCleanup() {
|
|
43
|
+
if err := procSetConsoleCtrlHandler.Find(); err != nil {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
procSetConsoleCtrlHandler.Call(consoleCtrlHandler, 1)
|
|
47
|
+
}
|
|
@@ -232,7 +232,7 @@ func saveWindowState(dir string, st WindowState) error {
|
|
|
232
232
|
|
|
233
233
|
// ---- os / process 信息 ----
|
|
234
234
|
|
|
235
|
-
func osInfo() map[string]interface{} {
|
|
235
|
+
func osInfo(app *App) map[string]interface{} {
|
|
236
236
|
host, _ := os.Hostname()
|
|
237
237
|
info := map[string]interface{}{
|
|
238
238
|
"platform": runtime.GOOS,
|
|
@@ -240,7 +240,7 @@ func osInfo() map[string]interface{} {
|
|
|
240
240
|
"hostname": host,
|
|
241
241
|
"osVersion": osVersionString(), // 平台分文件:osver_windows.go / osver_other.go
|
|
242
242
|
"goVersion": runtime.Version(),
|
|
243
|
-
"appVersion":
|
|
243
|
+
"appVersion": app.appVersion(), // 运行时声明优先,回落 ldflags 注入值
|
|
244
244
|
"numCPU": runtime.NumCPU(),
|
|
245
245
|
}
|
|
246
246
|
// M6:WebView2 Runtime 探测回显(仅 Windows 且检出时给键,其他平台省略)
|
|
@@ -311,7 +311,7 @@ func (a *App) sysGeneric(method string, args map[string]json.RawMessage) (result
|
|
|
311
311
|
}
|
|
312
312
|
return sf.keys(), true, nil
|
|
313
313
|
case "os.info":
|
|
314
|
-
info := osInfo()
|
|
314
|
+
info := osInfo(a)
|
|
315
315
|
// M3:回显生效的能力收口,前端可据此隐藏入口(nil=全开时省略该键)。
|
|
316
316
|
if a.cfg.Capabilities != nil {
|
|
317
317
|
info["capabilities"] = map[string][]string{
|
|
@@ -26,7 +26,7 @@ import (
|
|
|
26
26
|
var comInitDone atomic.Bool
|
|
27
27
|
|
|
28
28
|
var (
|
|
29
|
-
ole32
|
|
29
|
+
ole32 = syscall.NewLazyDLL("ole32.dll")
|
|
30
30
|
procCoCreateInstance = ole32.NewProc("CoCreateInstance")
|
|
31
31
|
procCoTaskMemFree = ole32.NewProc("CoTaskMemFree")
|
|
32
32
|
procCoInitializeEx = ole32.NewProc("CoInitializeEx")
|
|
@@ -102,6 +102,7 @@ func comVtable(ppv uintptr, index uint32) uintptr {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
// comVtableImpl 是实际的 vtable 查找实现,通过单独函数隔离 vet 检查。
|
|
105
|
+
//
|
|
105
106
|
//go:noinline
|
|
106
107
|
func comVtableImpl(ppv uintptr, index uint32) uintptr {
|
|
107
108
|
// 读取 vtable 指针:COM 对象首 8 字节是指针数组。
|
|
@@ -146,10 +147,10 @@ var (
|
|
|
146
147
|
|
|
147
148
|
// ITaskbarList3 vtable 索引(0=QueryInterface,1=AddRef,2=Release)。
|
|
148
149
|
const (
|
|
149
|
-
tb3HrInit
|
|
150
|
-
tb3SetProgressValue
|
|
151
|
-
tb3SetProgressState
|
|
152
|
-
tb3SetOverlayIcon
|
|
150
|
+
tb3HrInit = 3
|
|
151
|
+
tb3SetProgressValue = 8
|
|
152
|
+
tb3SetProgressState = 9
|
|
153
|
+
tb3SetOverlayIcon = 17
|
|
153
154
|
)
|
|
154
155
|
|
|
155
156
|
// TBPFLAG 任务栏进度条状态。
|
|
@@ -170,7 +171,7 @@ func taskbarList3() uintptr {
|
|
|
170
171
|
hr, _, _ := procCoCreateInstance.Call(
|
|
171
172
|
uintptr(unsafe.Pointer(&clsidTaskbarList)),
|
|
172
173
|
0,
|
|
173
|
-
0x1 /*CLSCTX_INPROC_SERVER
|
|
174
|
+
0x1, /*CLSCTX_INPROC_SERVER*/
|
|
174
175
|
uintptr(unsafe.Pointer(&iidTaskbarList3)),
|
|
175
176
|
uintptr(unsafe.Pointer(&ppv)),
|
|
176
177
|
)
|
|
@@ -265,11 +266,11 @@ const (
|
|
|
265
266
|
dwmwaSystemBackdropType = 38
|
|
266
267
|
dwmwaBorderColor = 34
|
|
267
268
|
|
|
268
|
-
dwmsbtAuto
|
|
269
|
-
dwmsbtNone
|
|
270
|
-
dwmsbtMainWindow
|
|
271
|
-
dwmsbtTransientWin
|
|
272
|
-
dwmsbtTabbedWindow
|
|
269
|
+
dwmsbtAuto = 0
|
|
270
|
+
dwmsbtNone = 1
|
|
271
|
+
dwmsbtMainWindow = 2 // Mica
|
|
272
|
+
dwmsbtTransientWin = 3 // Acrylic
|
|
273
|
+
dwmsbtTabbedWindow = 4
|
|
273
274
|
|
|
274
275
|
dwmwcpDefault = 0
|
|
275
276
|
dwmwcpDoNotRound = 1
|
|
@@ -401,9 +402,9 @@ func hiconFromPNG(pngData []byte) uintptr {
|
|
|
401
402
|
}
|
|
402
403
|
|
|
403
404
|
type iconInfo struct {
|
|
404
|
-
fIcon
|
|
405
|
-
xHotspot, yHotspot
|
|
406
|
-
hbmMask, hbmColor
|
|
405
|
+
fIcon int32
|
|
406
|
+
xHotspot, yHotspot uint32
|
|
407
|
+
hbmMask, hbmColor uintptr
|
|
407
408
|
}
|
|
408
409
|
ii := iconInfo{fIcon: 1, hbmMask: hbmMask, hbmColor: hbmColor}
|
|
409
410
|
hicon, _, _ := procCreateIconIndirect.Call(uintptr(unsafe.Pointer(&ii)))
|
|
@@ -412,7 +413,6 @@ func hiconFromPNG(pngData []byte) uintptr {
|
|
|
412
413
|
return hicon
|
|
413
414
|
}
|
|
414
415
|
|
|
415
|
-
|
|
416
416
|
// syscallMessageBox 调用系统消息框。返回按钮标识(ok/yes/no/cancel)。
|
|
417
417
|
func syscallMessageBox(hwnd uintptr, title, message, buttons, icon string) (string, error) {
|
|
418
418
|
var flags uintptr
|
|
@@ -465,33 +465,33 @@ var procMessageBoxW = user32win.NewProc("MessageBoxW")
|
|
|
465
465
|
|
|
466
466
|
// IFileOpenDialog / IFileSaveDialog / IShellItem COM 常量。
|
|
467
467
|
var (
|
|
468
|
-
clsidFileOpenDialog
|
|
469
|
-
clsidFileSaveDialog
|
|
470
|
-
iidIFileOpenDialog
|
|
471
|
-
iidIFileSaveDialog
|
|
472
|
-
iidIShellItem
|
|
468
|
+
clsidFileOpenDialog = comGUIDFromString("{DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7}")
|
|
469
|
+
clsidFileSaveDialog = comGUIDFromString("{C0B4E2F3-BA21-4773-8DBA-335EC946EB8B}")
|
|
470
|
+
iidIFileOpenDialog = comGUIDFromString("{D57C7288-D4AD-4768-BE02-9D969532D960}")
|
|
471
|
+
iidIFileSaveDialog = comGUIDFromString("{84BCCD23-5FDE-4CDB-AEA4-AF64B83D78AB}")
|
|
472
|
+
iidIShellItem = comGUIDFromString("{43826D1E-E718-42EE-BC55-A1E261C37BFE}")
|
|
473
473
|
)
|
|
474
474
|
|
|
475
475
|
// IFileDialog vtable 索引(IModalWindow: 0-3, IFileDialog: 4-20)。
|
|
476
476
|
const (
|
|
477
|
-
ifdSetFileTypes
|
|
477
|
+
ifdSetFileTypes = 4
|
|
478
478
|
ifdSetFileTypeIndex = 5
|
|
479
|
-
ifdSetOptions
|
|
480
|
-
ifdSetTitle
|
|
481
|
-
ifdSetFileName
|
|
482
|
-
ifdGetResult
|
|
483
|
-
ifdShow
|
|
479
|
+
ifdSetOptions = 9
|
|
480
|
+
ifdSetTitle = 17
|
|
481
|
+
ifdSetFileName = 15
|
|
482
|
+
ifdGetResult = 20
|
|
483
|
+
ifdShow = 3 // IModalWindow::Show
|
|
484
484
|
)
|
|
485
485
|
|
|
486
486
|
// IFOS 选项(IFileDialogOptions)。
|
|
487
487
|
const (
|
|
488
|
-
fosOverwritePrompt
|
|
489
|
-
fosStrictFileTypes
|
|
490
|
-
fosNoChangeDir
|
|
491
|
-
fosForceFileSystem
|
|
492
|
-
fosAllowMultiSelect
|
|
493
|
-
fosPathMustExist
|
|
494
|
-
fosFileMustExist
|
|
488
|
+
fosOverwritePrompt = 0x00000002
|
|
489
|
+
fosStrictFileTypes = 0x00000004
|
|
490
|
+
fosNoChangeDir = 0x00000008
|
|
491
|
+
fosForceFileSystem = 0x00000040
|
|
492
|
+
fosAllowMultiSelect = 0x00000200
|
|
493
|
+
fosPathMustExist = 0x00000800
|
|
494
|
+
fosFileMustExist = 0x00001000
|
|
495
495
|
fosDefaultNoMiniMode = 0x20000000
|
|
496
496
|
)
|
|
497
497
|
|
|
@@ -34,7 +34,7 @@ var (
|
|
|
34
34
|
"alt": modAlt, "option": modAlt,
|
|
35
35
|
"ctrl": modControl, "control": modControl,
|
|
36
36
|
"shift": modShift,
|
|
37
|
-
"win":
|
|
37
|
+
"win": modWin, "cmd": modWin, "meta": modWin, "super": modWin,
|
|
38
38
|
}
|
|
39
39
|
hotkeyVKs = map[string]uint32{}
|
|
40
40
|
)
|
|
@@ -230,7 +230,7 @@ const (
|
|
|
230
230
|
keyRead = 0x101
|
|
231
231
|
regSz = 1
|
|
232
232
|
|
|
233
|
-
runKeyPath
|
|
233
|
+
runKeyPath = `Software\Microsoft\Windows\CurrentVersion\Run`
|
|
234
234
|
classesBase = `Software\Classes`
|
|
235
235
|
)
|
|
236
236
|
|
|
@@ -39,12 +39,12 @@ const (
|
|
|
39
39
|
tpmRightButton = 0x00000002
|
|
40
40
|
tpmLeftAlign = 0x00000000
|
|
41
41
|
|
|
42
|
-
mfString
|
|
43
|
-
mfSeparator
|
|
44
|
-
mfChecked
|
|
45
|
-
mfGrayed
|
|
46
|
-
mfEnabled
|
|
47
|
-
mfPopup
|
|
42
|
+
mfString = 0x00000000
|
|
43
|
+
mfSeparator = 0x00000800
|
|
44
|
+
mfChecked = 0x00000008
|
|
45
|
+
mfGrayed = 0x00000001
|
|
46
|
+
mfEnabled = 0x00000000
|
|
47
|
+
mfPopup = 0x00000010
|
|
48
48
|
mfByPosition = 0x00000400
|
|
49
49
|
)
|
|
50
50
|
|
|
@@ -52,19 +52,19 @@ var (
|
|
|
52
52
|
shell32 = syscall.NewLazyDLL("shell32.dll")
|
|
53
53
|
procShellNotifyIconW = shell32.NewProc("Shell_NotifyIconW")
|
|
54
54
|
|
|
55
|
-
procRegisterClassExW
|
|
56
|
-
procCreateWindowExW
|
|
57
|
-
procDefWindowProcW
|
|
58
|
-
procCreatePopupMenu
|
|
59
|
-
procCreateMenu
|
|
60
|
-
procAppendMenuW
|
|
61
|
-
procInsertMenuW
|
|
62
|
-
procDestroyMenu
|
|
63
|
-
procTrackPopupMenu
|
|
64
|
-
procGetCursorPos
|
|
55
|
+
procRegisterClassExW = user32win.NewProc("RegisterClassExW")
|
|
56
|
+
procCreateWindowExW = user32win.NewProc("CreateWindowExW")
|
|
57
|
+
procDefWindowProcW = user32win.NewProc("DefWindowProcW")
|
|
58
|
+
procCreatePopupMenu = user32win.NewProc("CreatePopupMenu")
|
|
59
|
+
procCreateMenu = user32win.NewProc("CreateMenu")
|
|
60
|
+
procAppendMenuW = user32win.NewProc("AppendMenuW")
|
|
61
|
+
procInsertMenuW = user32win.NewProc("InsertMenuW")
|
|
62
|
+
procDestroyMenu = user32win.NewProc("DestroyMenu")
|
|
63
|
+
procTrackPopupMenu = user32win.NewProc("TrackPopupMenu")
|
|
64
|
+
procGetCursorPos = user32win.NewProc("GetCursorPos")
|
|
65
65
|
procSetForegroundWindow = user32win.NewProc("SetForegroundWindow")
|
|
66
|
-
procSetMenu
|
|
67
|
-
procDrawMenuBar
|
|
66
|
+
procSetMenu = user32win.NewProc("SetMenu")
|
|
67
|
+
procDrawMenuBar = user32win.NewProc("DrawMenuBar")
|
|
68
68
|
)
|
|
69
69
|
|
|
70
70
|
// ---- 结构 ----
|
|
@@ -178,9 +178,9 @@ func (a *App) CheckUpdate(ctx context.Context) (*UpdateInfo, error) {
|
|
|
178
178
|
if !updateURLAllowed(m.URL) {
|
|
179
179
|
return nil, fmt.Errorf("freedom: artifact URL scheme rejected: %q", m.URL)
|
|
180
180
|
}
|
|
181
|
-
cmp, err := compareVersions(
|
|
181
|
+
cmp, err := compareVersions(a.appVersion(), m.Version)
|
|
182
182
|
if err != nil {
|
|
183
|
-
return nil, fmt.Errorf("freedom: current version %q uncomparable: %w",
|
|
183
|
+
return nil, fmt.Errorf("freedom: current version %q uncomparable: %w", a.appVersion(), err)
|
|
184
184
|
}
|
|
185
185
|
a.upMu.Lock()
|
|
186
186
|
if cmp >= 0 {
|
|
@@ -333,7 +333,7 @@ func (a *App) updateCheckAsync() interface{} {
|
|
|
333
333
|
return
|
|
334
334
|
}
|
|
335
335
|
if info == nil {
|
|
336
|
-
a.Emit("update.upToDate", map[string]string{"current":
|
|
336
|
+
a.Emit("update.upToDate", map[string]string{"current": a.appVersion()})
|
|
337
337
|
return
|
|
338
338
|
}
|
|
339
339
|
a.Emit("update.available", info)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
### Migrating from v0.1.1 to v0.10.0
|
|
4
|
+
|
|
5
|
+
1. `Webview.Open()` has been removed. Use other webview APIs to create a window, open a link and run main UI loop.
|
|
6
|
+
2. `Webview.Debug()` and `webview.Debugf()` have been removed. Use your favorite logging library to debug webview apps.
|
|
7
|
+
3. `Webview.Settings` struct has been removed. Title, URL and size are controlled via other API setters and can be updated at any time, not only when webview is created.
|
|
8
|
+
4. `Webview.Loop()` has been removed. Use `Run()` instead.
|
|
9
|
+
5. `WebView.Run()`, `WebView.Terminate()`, `WebView.SetTitle()`, `WebView.Dispatch()` stayed the same.
|
|
10
|
+
6. `WebView.Exit()` has been renamed to `WebView.Destroy()`
|
|
11
|
+
7. `WebView.SetColor()` and `WebView.SetFullScreen()` have been removed. Use `Window()` to get native window handle and probably write some Cgo code to adjust native window to your taste.
|
|
12
|
+
8. `Webview.Dialog` has been removed. But it is likely to be brought back as a standalone module.
|
|
13
|
+
9. `WebView.Eval()` remained the same.
|
|
14
|
+
10. `WebView.InjectCSS()` has been removed. Use eval to inject style tag with CSS inside.
|
|
15
|
+
11. `WebView.Bind()` kept the name, but changed the semantics. Only functions can be bound. Not the structs, like in Lorca.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
From: https://github.com/webview/webview_go
|
|
2
|
+
Upstream commit: 6173450d4dd6 (v0.0.0-20240831120633)
|
|
3
|
+
License: MIT (see LICENSE)
|
|
4
|
+
|
|
5
|
+
Why this copy exists
|
|
6
|
+
------------------
|
|
7
|
+
Upstream hardcodes the CGO dependency name as `pkg-config: gtk+-3.0 webkit2gtk-4.0`.
|
|
8
|
+
Ubuntu 24.04 / Debian 13 removed the webkit2gtk-4.0 dev package (libsoup2 line) and ship
|
|
9
|
+
the API-compatible webkit2gtk-4.1 instead, so `go build` fails there with
|
|
10
|
+
"Package webkit2gtk-4.0 was not found".
|
|
11
|
+
|
|
12
|
+
What was changed (the only two deltas)
|
|
13
|
+
--------------------------------------
|
|
14
|
+
1. webview.go: dropped the hardcoded linux `pkg-config:` line (comment marks the spot).
|
|
15
|
+
2. webkit2_40.go / webkit2_41.go: the same directive, split by mutually exclusive build
|
|
16
|
+
tags. Default stays 4.0 (unchanged behaviour on old distros and in CI artifacts);
|
|
17
|
+
`-tags webkit2_41` selects 4.1.
|
|
18
|
+
|
|
19
|
+
Nothing else was touched: examples/ and webview_test.go were deleted, no code change.
|
|
20
|
+
|
|
21
|
+
Who flips the tag
|
|
22
|
+
-----------------
|
|
23
|
+
- repo/dev + CI: build.sh sources tools/webkit-env.sh (appends -tags=webkit2_41 to GOFLAGS)
|
|
24
|
+
- npm CLI: freedom-cli/lib/webkit.js (applyWebkitTags), used by `freedom shell build`
|
|
25
|
+
Detection is by pkg-config availability, so no user-facing flag is needed.
|
|
26
|
+
|
|
27
|
+
To refresh from upstream: copy the new tree over this directory, re-apply the two deltas
|
|
28
|
+
above, delete examples/ and webview_test.go, then re-sync the identical copy under
|
|
29
|
+
freedom-cli/templates/go/third_party/webview_go/ (it is what `freedom shell build` compiles).
|
|
30
|
+
|
|
31
|
+
webkitgtk-6.0 is NOT bridgeable this way (different C API: WebKitNetworkSession,
|
|
32
|
+
permission handlers); it needs an upstream port.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Serge Zaitsev
|
|
4
|
+
Copyright (c) 2020 webview
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# webview_go
|
|
2
|
+
|
|
3
|
+
[](https://godoc.org/github.com/webview/webview_go)
|
|
4
|
+
[](https://goreportcard.com/report/github.com/webview/webview_go)
|
|
5
|
+
|
|
6
|
+
Go language binding for the [webview library][webview].
|
|
7
|
+
|
|
8
|
+
> [!NOTE]
|
|
9
|
+
> Versions <= 0.1.1 are available in the [old repository][webview].
|
|
10
|
+
|
|
11
|
+
### Getting Started
|
|
12
|
+
|
|
13
|
+
See [Go package documentation][go-docs] for the Go API documentation, or simply read the source code.
|
|
14
|
+
|
|
15
|
+
Start with creating a new directory structure for your project.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
mkdir my-project && cd my-project
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Create a new Go module.
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
go mod init example.com/app
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Save one of the example programs into your project directory.
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
curl -sSLo main.go "https://raw.githubusercontent.com/webview/webview_go/master/examples/basic/main.go"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Install dependencies.
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
go get github.com/webview/webview_go
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Build the example. On Windows, add `-ldflags="-H windowsgui"` to the command line.
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
go build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Notes
|
|
46
|
+
|
|
47
|
+
Calling `Eval()` or `Dispatch()` before `Run()` does not work because the webview instance has only been configured and not yet started.
|
|
48
|
+
|
|
49
|
+
[go-docs]: https://pkg.go.dev/github.com/webview/webview_go
|
|
50
|
+
[webview]: https://github.com/webview/webview
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#include "webview.h"
|
|
2
|
+
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
|
|
6
|
+
struct binding_context {
|
|
7
|
+
webview_t w;
|
|
8
|
+
uintptr_t index;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
void _webviewDispatchGoCallback(void *);
|
|
12
|
+
void _webviewBindingGoCallback(webview_t, char *, char *, uintptr_t);
|
|
13
|
+
|
|
14
|
+
static void _webview_dispatch_cb(webview_t w, void *arg) {
|
|
15
|
+
_webviewDispatchGoCallback(arg);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static void _webview_binding_cb(const char *id, const char *req, void *arg) {
|
|
19
|
+
struct binding_context *ctx = (struct binding_context *) arg;
|
|
20
|
+
_webviewBindingGoCallback(ctx->w, (char *)id, (char *)req, ctx->index);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void CgoWebViewDispatch(webview_t w, uintptr_t arg) {
|
|
24
|
+
webview_dispatch(w, _webview_dispatch_cb, (void *)arg);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void CgoWebViewBind(webview_t w, const char *name, uintptr_t index) {
|
|
28
|
+
struct binding_context *ctx = calloc(1, sizeof(struct binding_context));
|
|
29
|
+
ctx->w = w;
|
|
30
|
+
ctx->index = index;
|
|
31
|
+
webview_bind(w, name, _webview_binding_cb, (void *)ctx);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void CgoWebViewUnbind(webview_t w, const char *name) {
|
|
35
|
+
webview_unbind(w, name);
|
|
36
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (C) Microsoft Corporation. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions are
|
|
5
|
+
met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above
|
|
10
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
11
|
+
in the documentation and/or other materials provided with the
|
|
12
|
+
distribution.
|
|
13
|
+
* The name of Microsoft Corporation, or the names of its contributors
|
|
14
|
+
may not be used to endorse or promote products derived from this
|
|
15
|
+
software without specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
19
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
20
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
21
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
22
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
24
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
25
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|