@yufengtadian/freedom-cli 1.12.18 → 1.13.1
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/README.md +11 -3
- package/lib/build.js +1 -1
- package/lib/security.js +2 -2
- package/package.json +5 -1
- 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/templates/go/go.mod +1 -7
- package/templates/go/go.sum +2 -2
- package/templates/go/main.go +22 -8
- package/templates/go/pkg/freedom/anti_debug_other.go +2 -3
- package/templates/go/pkg/freedom/anti_debug_windows.go +10 -12
- package/templates/go/pkg/freedom/assets/{index.html → default.html} +1 -1
- package/templates/go/pkg/freedom/assets/freedom.js +200 -5
- package/templates/go/pkg/freedom/assets_embed.go +11 -13
- package/templates/go/pkg/freedom/authenticode_other.go +11 -0
- package/templates/go/pkg/freedom/authenticode_windows.go +87 -0
- package/templates/go/pkg/freedom/backend_proc.go +291 -53
- package/templates/go/pkg/freedom/bridge.go +13 -2
- package/templates/go/pkg/freedom/capability.go +77 -0
- package/templates/go/pkg/freedom/center_other.go +3 -0
- package/templates/go/pkg/freedom/center_windows.go +45 -35
- package/templates/go/pkg/freedom/dispatch.go +60 -0
- package/templates/go/pkg/freedom/events_windows.go +319 -0
- package/templates/go/pkg/freedom/freedom.go +193 -99
- package/templates/go/pkg/freedom/msgwindow_windows.go +257 -0
- package/templates/go/pkg/freedom/osver_other.go +15 -0
- package/templates/go/pkg/freedom/osver_windows.go +121 -0
- package/templates/go/pkg/freedom/proc_hide_windows.go +2 -2
- package/templates/go/pkg/freedom/{configfile.go → resources.go} +38 -35
- package/templates/go/pkg/freedom/security.go +19 -12
- package/templates/go/pkg/freedom/singleinstance_other.go +10 -0
- package/templates/go/pkg/freedom/singleinstance_windows.go +145 -0
- package/templates/go/pkg/freedom/spawn_other.go +11 -0
- package/templates/go/pkg/freedom/spawn_windows.go +23 -0
- package/templates/go/pkg/freedom/store.go +458 -0
- package/templates/go/pkg/freedom/syscap_linux.go +278 -0
- package/templates/go/pkg/freedom/syscap_other.go +15 -3
- package/templates/go/pkg/freedom/syscap_windows.go +228 -36
- package/templates/go/pkg/freedom/sysint_common.go +70 -0
- package/templates/go/pkg/freedom/sysint_windows.go +426 -0
- package/templates/go/pkg/freedom/tray_common.go +12 -0
- package/templates/go/pkg/freedom/tray_linux.go +302 -0
- package/templates/go/pkg/freedom/tray_other.go +2 -2
- package/templates/go/pkg/freedom/tray_windows.go +69 -39
- package/templates/go/pkg/freedom/updater.go +372 -0
- package/templates/go/pkg/freedom/window_mgr.go +385 -0
- package/templates/go/pkg/freedom/window_other.go +32 -66
- package/templates/go/pkg/freedom/window_windows.go +397 -254
- package/templates/go/build_all.txt +0 -0
- package/templates/go/build_err.txt +0 -0
- package/templates/go/gen_config.go +0 -22
- package/templates/go/pkg/freedom/center_windows_test.go +0 -32
- package/templates/go/pkg/freedom/security_test.go +0 -153
- package/templates/go/temp_vet_test/main.go +0 -40
- package/templates/go/test_err.txt +0 -0
- package/templates/go/vet_err.txt +0 -1
- package/templates/go/vet_err2.txt +0 -2
- package/templates/go/webview_go/.github/workflows/ci.yaml +0 -62
- package/templates/go/webview_go/CHANGELOG.md +0 -15
- package/templates/go/webview_go/LICENSE +0 -22
- package/templates/go/webview_go/README.md +0 -50
- package/templates/go/webview_go/examples/basic/main.go +0 -12
- package/templates/go/webview_go/examples/bind/main.go +0 -38
- package/templates/go/webview_go/glue.c +0 -36
- package/templates/go/webview_go/go.mod +0 -3
- package/templates/go/webview_go/go.sum +0 -0
- package/templates/go/webview_go/libs/mswebview2/LICENSE +0 -27
- package/templates/go/webview_go/libs/mswebview2/include/WebView2.h +0 -23568
- package/templates/go/webview_go/libs/mswebview2/include/vendor.go +0 -2
- package/templates/go/webview_go/libs/mswebview2/vendor.go +0 -2
- package/templates/go/webview_go/libs/mswebview2/version.txt +0 -1
- package/templates/go/webview_go/libs/webview/LICENSE +0 -22
- package/templates/go/webview_go/libs/webview/include/vendor.go +0 -2
- package/templates/go/webview_go/libs/webview/include/webview.h +0 -3871
- package/templates/go/webview_go/libs/webview/vendor.go +0 -2
- package/templates/go/webview_go/libs/webview/version.txt +0 -1
- package/templates/go/webview_go/webview.cc +0 -1
- package/templates/go/webview_go/webview.go +0 -481
- package/templates/go/webview_go/webview_test.go +0 -50
|
File without changes
|
|
File without changes
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
package main
|
|
2
|
-
|
|
3
|
-
import "freedom-cli-shell/pkg/freedom"
|
|
4
|
-
|
|
5
|
-
// appConfig 返回应用窗口配置(编译期默认值)。
|
|
6
|
-
//
|
|
7
|
-
// 通用壳在运行时还会读取 exe 同目录 resources/config.json(由 freedom CLI build
|
|
8
|
-
// 阶段根据 freedom.config.js 生成),其中的字段会覆盖本默认值。因此:
|
|
9
|
-
// - 使用预编译通用壳时,本文件中的值只是兜底,无需手动修改;
|
|
10
|
-
// - 若通过 go build 直接编译本项目(不使用 CLI),此处即为最终配置。
|
|
11
|
-
func appConfig() freedom.Config {
|
|
12
|
-
return freedom.Config{
|
|
13
|
-
Title: "Freedom App",
|
|
14
|
-
TitleBar: freedom.TitleBarFrameless,
|
|
15
|
-
Width: 1024,
|
|
16
|
-
Height: 720,
|
|
17
|
-
MinWidth: 400,
|
|
18
|
-
MinHeight: 300,
|
|
19
|
-
Center: true,
|
|
20
|
-
Debug: false,
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//go:build windows
|
|
2
|
-
|
|
3
|
-
package freedom
|
|
4
|
-
|
|
5
|
-
import "testing"
|
|
6
|
-
|
|
7
|
-
// TestClampCentered 覆盖 M5 双向 clamp 的所有分支:
|
|
8
|
-
// 小窗严格居中 / 超屏贴左上(上下界互打架)/ 副屏负坐标 / 右缘与下缘不越界。
|
|
9
|
-
func TestClampCentered(t *testing.T) {
|
|
10
|
-
cases := []struct {
|
|
11
|
-
name string
|
|
12
|
-
winW, winH, left, top int
|
|
13
|
-
workW, workH, wantX, wantY int
|
|
14
|
-
}{
|
|
15
|
-
{"主屏小窗严格居中", 240, 180, 0, 0, 1920, 1040, 840, 430},
|
|
16
|
-
{"主屏超屏贴左上角", 3000, 2000, 0, 0, 1920, 1040, 0, 0},
|
|
17
|
-
{"副屏负坐标居中", 800, 600, -1920, 0, 1920, 1080, -1360, 240},
|
|
18
|
-
{"右缘不越界", 1900, 1000, 0, 0, 1920, 1080, 10, 40},
|
|
19
|
-
{"窗口恰等于工作区", 1920, 1040, 0, 0, 1920, 1040, 0, 0},
|
|
20
|
-
{"副屏超屏上界回贴左上", 3000, 2000, -1920, 0, 1920, 1040, -1920, 0},
|
|
21
|
-
{"高度触下缘", 200, 1040, 0, 0, 1920, 1040, 860, 0},
|
|
22
|
-
}
|
|
23
|
-
for _, c := range cases {
|
|
24
|
-
t.Run(c.name, func(t *testing.T) {
|
|
25
|
-
x, y := clampCentered(c.winW, c.winH, c.left, c.top, c.workW, c.workH)
|
|
26
|
-
if x != c.wantX || y != c.wantY {
|
|
27
|
-
t.Fatalf("clampCentered(%d,%d,%d,%d,%d,%d) = (%d,%d), want (%d,%d)",
|
|
28
|
-
c.winW, c.winH, c.left, c.top, c.workW, c.workH, x, y, c.wantX, c.wantY)
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
package freedom
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"bytes"
|
|
5
|
-
"crypto/aes"
|
|
6
|
-
"crypto/cipher"
|
|
7
|
-
"crypto/hmac"
|
|
8
|
-
"crypto/sha256"
|
|
9
|
-
"encoding/hex"
|
|
10
|
-
"os"
|
|
11
|
-
"path/filepath"
|
|
12
|
-
"testing"
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
// 跨语言一致性:deriveSecurityKey 的期望值由 Node crypto.pbkdf2Sync 生成
|
|
16
|
-
// (见 lib/security.js 测试 / 开发时用 node -e 复算)。两侧必须一致,
|
|
17
|
-
// 否则 CLI high 模式 build 的加密资源壳无法解密。
|
|
18
|
-
var deriveExpect = map[string]string{
|
|
19
|
-
"demo": "87186aa64360bdecb9d87f3bc78c20afabc04ff99abbf04b202d5ead7aea9484",
|
|
20
|
-
"myapp.exe": "853b7b028120502eaefae453e05f36df7e4d2948e3d6766272a6965e0401675d",
|
|
21
|
-
"HelloApp": "30255eaff0c089efdcb22736ae255a98f5a2bb8e3c00741440102811e1345f9a",
|
|
22
|
-
"HelloApp.app": "30255eaff0c089efdcb22736ae255a98f5a2bb8e3c00741440102811e1345f9a",
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
func TestDeriveKeyMatchesNode(t *testing.T) {
|
|
26
|
-
for name, wantHex := range deriveExpect {
|
|
27
|
-
got := hex.EncodeToString(deriveSecurityKey(name))
|
|
28
|
-
if got != wantHex {
|
|
29
|
-
t.Errorf("deriveSecurityKey(%q) = %s, want %s", name, got, wantHex)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
func TestAppIdentityName(t *testing.T) {
|
|
35
|
-
cases := map[string]string{
|
|
36
|
-
"demo": "demo",
|
|
37
|
-
"myapp.exe": "myapp",
|
|
38
|
-
"HelloApp.app": "HelloApp",
|
|
39
|
-
// 与 lib/security.js appIdentityFor 正则语义一致:仅去除最后一个 .exe/.app 后缀
|
|
40
|
-
"app.exe.app": "app.exe",
|
|
41
|
-
}
|
|
42
|
-
for in, want := range cases {
|
|
43
|
-
if got := appIdentityName(in); got != want {
|
|
44
|
-
t.Errorf("appIdentityName(%q) = %q, want %q", in, got, want)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
func TestPBKDF2RFCVector(t *testing.T) {
|
|
50
|
-
// RFC 6070 向量:PBKDF2-HMAC-SHA1("password", "salt", 1, 20)
|
|
51
|
-
// 我们实现的 PRF 是 SHA256,此处验证实现不 panic 且长度正确 + 与 SHA256 自我一致。
|
|
52
|
-
dk := pbkdf2HMACSHA256([]byte("password"), []byte("salt"), 4096, 32)
|
|
53
|
-
if len(dk) != 32 {
|
|
54
|
-
t.Fatalf("pbkdf2 len = %d, want 32", len(dk))
|
|
55
|
-
}
|
|
56
|
-
// 确定性:同参重复调用结果一致
|
|
57
|
-
dk2 := pbkdf2HMACSHA256([]byte("password"), []byte("salt"), 4096, 32)
|
|
58
|
-
if !bytes.Equal(dk, dk2) {
|
|
59
|
-
t.Fatal("pbkdf2 not deterministic")
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
func TestDecryptAppBinRoundtrip(t *testing.T) {
|
|
64
|
-
payload := []byte(`{"html":"<html>hello</html>","config":"{\"title\":\"demo\"}"}`)
|
|
65
|
-
name := "demo"
|
|
66
|
-
key := deriveSecurityKey(name)
|
|
67
|
-
|
|
68
|
-
// 用标准 AES-GCM 加密构造 app.bin(模拟 CLI build 产物)
|
|
69
|
-
data, err := encryptForTest(name, payload)
|
|
70
|
-
if err != nil {
|
|
71
|
-
t.Fatalf("encryptForTest: %v", err)
|
|
72
|
-
}
|
|
73
|
-
p, err := decryptAppBin(name, data)
|
|
74
|
-
if err != nil {
|
|
75
|
-
t.Fatalf("decryptAppBin: %v", err)
|
|
76
|
-
}
|
|
77
|
-
if p.HTML != "<html>hello</html>" || p.Config != "{\"title\":\"demo\"}" {
|
|
78
|
-
t.Fatalf("roundtrip mismatch: %+v", p)
|
|
79
|
-
}
|
|
80
|
-
_ = key
|
|
81
|
-
|
|
82
|
-
// 篡改测试:改动密文任一位 → 解密失败(HMAC 认证标签校验)
|
|
83
|
-
bad := append([]byte(nil), data...)
|
|
84
|
-
bad[len(bad)-1] ^= 0x01
|
|
85
|
-
if _, err := decryptAppBin(name, bad); err == nil {
|
|
86
|
-
t.Fatal("tampered ciphertext should fail")
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
func TestDecryptAppBinWrongName(t *testing.T) {
|
|
91
|
-
payload := []byte(`{"html":"x","config":"{}"}`)
|
|
92
|
-
data, err := encryptForTest("demo", payload)
|
|
93
|
-
if err != nil {
|
|
94
|
-
t.Fatalf("encryptForTest: %v", err)
|
|
95
|
-
}
|
|
96
|
-
// 用错误应用名(相当于 exe 被重命名)解密 → 必须失败
|
|
97
|
-
if _, err := decryptAppBin("other", data); err == nil {
|
|
98
|
-
t.Fatal("decrypt with wrong app name should fail")
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
func TestVerifyIntegrity(t *testing.T) {
|
|
103
|
-
dir := t.TempDir()
|
|
104
|
-
name := "demo"
|
|
105
|
-
appBin := []byte("FRDM1-fake-bin-content")
|
|
106
|
-
key := deriveSecurityKey(name)
|
|
107
|
-
mac := hmac.New(sha256.New, key)
|
|
108
|
-
mac.Write(appBin)
|
|
109
|
-
want := hex.EncodeToString(mac.Sum(nil))
|
|
110
|
-
|
|
111
|
-
// 正常:匹配
|
|
112
|
-
good := `{"v":1,"appBin":"` + want + `","backend":{}}`
|
|
113
|
-
if err := os.WriteFile(filepath.Join(dir, ".integrity"), []byte(good), 0o644); err != nil {
|
|
114
|
-
t.Fatal(err)
|
|
115
|
-
}
|
|
116
|
-
if err := verifyIntegrity(dir, name, appBin); err != nil {
|
|
117
|
-
t.Fatalf("verifyIntegrity should pass: %v", err)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// 篡改:app.bin 内容变化 → 校验失败
|
|
121
|
-
if err := verifyIntegrity(dir, name, append(appBin, 0x00)); err == nil {
|
|
122
|
-
t.Fatal("tampered appBin should fail integrity")
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// 无 .integrity → 跳过(向后兼容)
|
|
126
|
-
dir2 := t.TempDir()
|
|
127
|
-
if err := verifyIntegrity(dir2, name, appBin); err != nil {
|
|
128
|
-
t.Fatalf("missing .integrity should pass: %v", err)
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// ---- 测试辅助 ----
|
|
133
|
-
|
|
134
|
-
// encryptForTest 用与 CLI lib/security.js 相同的容器格式加密载荷(供壳单测使用)。
|
|
135
|
-
// 算法与正式流程一致:AES-256-CTR 加密 → HMAC-SHA256(密文) 截 16B 认证标签。
|
|
136
|
-
func encryptForTest(name string, plain []byte) ([]byte, error) {
|
|
137
|
-
key := deriveSecurityKey(name)
|
|
138
|
-
block, err := aes.NewCipher(key)
|
|
139
|
-
if err != nil {
|
|
140
|
-
return nil, err
|
|
141
|
-
}
|
|
142
|
-
iv := make([]byte, securityIVLen) // 固定 iv 便于确定性(仅测试)
|
|
143
|
-
stream := cipher.NewCTR(block, iv)
|
|
144
|
-
ct := make([]byte, len(plain))
|
|
145
|
-
stream.XORKeyStream(ct, plain)
|
|
146
|
-
mac := hmac.New(sha256.New, key)
|
|
147
|
-
mac.Write(ct)
|
|
148
|
-
tag := mac.Sum(nil)[:securityTagLen]
|
|
149
|
-
out := append([]byte(securityMagic), iv...)
|
|
150
|
-
out = append(out, tag...)
|
|
151
|
-
out = append(out, ct...)
|
|
152
|
-
return out, nil
|
|
153
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
package main
|
|
2
|
-
|
|
3
|
-
import "unsafe"
|
|
4
|
-
|
|
5
|
-
// 写法B:widl 风格链式解引用
|
|
6
|
-
func comVtableB(ppv uintptr, index uint32) uintptr {
|
|
7
|
-
vt := *(*uintptr)(*(*unsafe.Pointer)(unsafe.Pointer(ppv)))
|
|
8
|
-
return *(*uintptr)(unsafe.Pointer(vt + uintptr(index)*8))
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// 写法D:先转 unsafe.Pointer 立即传给子函数
|
|
12
|
-
func comVtableD(ppv uintptr, index uint32) uintptr {
|
|
13
|
-
return comVtableDPtr(unsafe.Pointer(ppv), index)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
func comVtableDPtr(pp unsafe.Pointer, index uint32) uintptr {
|
|
17
|
-
vt := *(*uintptr)(pp)
|
|
18
|
-
return *(*uintptr)(unsafe.Add(unsafe.Pointer(vt), uintptr(index)*8))
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// 写法E:uintptr 参数直接转结构体指针再读字段
|
|
22
|
-
type unkBox struct{ v unsafe.Pointer }
|
|
23
|
-
|
|
24
|
-
func comVtableE(ppv uintptr, index uint32) uintptr {
|
|
25
|
-
b := (*unkBox)(unsafe.Pointer(ppv))
|
|
26
|
-
slots := unsafe.Slice((*uintptr)(b.v), int(index)+1)
|
|
27
|
-
return slots[index]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// 写法F:类型化数组头 + Slice
|
|
31
|
-
func comVtableF(ppv uintptr, index uint32) uintptr {
|
|
32
|
-
obj := (*[1]unsafe.Pointer)(unsafe.Pointer(ppv))
|
|
33
|
-
vt := *obj
|
|
34
|
-
slots := unsafe.Slice((*uintptr)(vt[0]), int(index)+1)
|
|
35
|
-
return slots[index]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
func main() {
|
|
39
|
-
_, _, _, _ = comVtableB(0, 0), comVtableD(0, 0), comVtableE(0, 0), comVtableF(0, 0)
|
|
40
|
-
}
|
|
File without changes
|
package/templates/go/vet_err.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pkg\freedom\syscap_windows.go:56:30: possible misuse of unsafe.Pointer
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
name: CI Pipeline
|
|
2
|
-
on: [push, pull_request]
|
|
3
|
-
|
|
4
|
-
jobs:
|
|
5
|
-
build:
|
|
6
|
-
runs-on: ${{ matrix.image }}
|
|
7
|
-
strategy:
|
|
8
|
-
fail-fast: false
|
|
9
|
-
matrix:
|
|
10
|
-
# Go 1.23 was the latest version as of 2024-08-31 but the action output a "warning":
|
|
11
|
-
# Failed to restore: "/usr/bin/tar" failed with error: The process '/usr/bin/tar' failed with exit code 2
|
|
12
|
-
# Go 1.22 didn't output the above "warning" so we're using this version.
|
|
13
|
-
# Go 1.14 made -mod=vendor default.
|
|
14
|
-
# Go 1.13 is the version set in go.mod.
|
|
15
|
-
include:
|
|
16
|
-
- { image: macos-14, go: '1.22' }
|
|
17
|
-
- { image: macos-14, go: '1.21' }
|
|
18
|
-
- { image: macos-14, go: '1.20' }
|
|
19
|
-
# Go 1.19 is the earliest version available for ARM64.
|
|
20
|
-
- { image: macos-14, go: '1.19' }
|
|
21
|
-
# macos-12 runner has x86_64 support which is needed for old versions of Go
|
|
22
|
-
- { image: macos-12, go: '1.18' }
|
|
23
|
-
- { image: macos-12, go: '1.17' }
|
|
24
|
-
- { image: macos-12, go: '1.16' }
|
|
25
|
-
- { image: macos-12, go: '1.15' }
|
|
26
|
-
- { image: macos-12, go: '1.14' }
|
|
27
|
-
- { image: macos-12, go: '1.13' }
|
|
28
|
-
- { image: ubuntu-22.04, go: '1.22', apt: libgtk-4-dev libwebkitgtk-6.0-dev }
|
|
29
|
-
- { image: ubuntu-22.04, go: '1.22', apt: libgtk-3-dev libwebkit2gtk-4.1-dev }
|
|
30
|
-
- { image: ubuntu-22.04, go: '1.22', apt: libgtk-3-dev libwebkit2gtk-4.0-dev }
|
|
31
|
-
- { image: ubuntu-22.04, go: '1.21', apt: libgtk-3-dev libwebkit2gtk-4.1-dev }
|
|
32
|
-
- { image: ubuntu-22.04, go: '1.20', apt: libgtk-3-dev libwebkit2gtk-4.1-dev }
|
|
33
|
-
- { image: ubuntu-22.04, go: '1.19', apt: libgtk-3-dev libwebkit2gtk-4.1-dev }
|
|
34
|
-
- { image: ubuntu-22.04, go: '1.18', apt: libgtk-3-dev libwebkit2gtk-4.1-dev }
|
|
35
|
-
- { image: ubuntu-22.04, go: '1.17', apt: libgtk-3-dev libwebkit2gtk-4.1-dev }
|
|
36
|
-
- { image: ubuntu-22.04, go: '1.16', apt: libgtk-3-dev libwebkit2gtk-4.1-dev }
|
|
37
|
-
- { image: ubuntu-22.04, go: '1.15', apt: libgtk-3-dev libwebkit2gtk-4.1-dev }
|
|
38
|
-
- { image: ubuntu-22.04, go: '1.14', apt: libgtk-3-dev libwebkit2gtk-4.1-dev }
|
|
39
|
-
- { image: ubuntu-22.04, go: '1.13', apt: libgtk-3-dev libwebkit2gtk-4.1-dev }
|
|
40
|
-
- { image: windows-2022, go: '1.22' }
|
|
41
|
-
- { image: windows-2022, go: '1.21' }
|
|
42
|
-
# Go 1.20 is the earliest version that is usable in this environment as of 2024-08-31.
|
|
43
|
-
# Compilation fails with older versions:
|
|
44
|
-
# [...]/bin/ld.exe: [...]\go-link-3209855222\000008.o: in function `x_cgo_thread_start':
|
|
45
|
-
# \\_\_\runtime\cgo/gcc_util.c:18: undefined reference to `__imp___iob_func'
|
|
46
|
-
- { image: windows-2022, go: '1.20' }
|
|
47
|
-
name: Build (${{ matrix.image }}, go ${{ matrix.go }})
|
|
48
|
-
steps:
|
|
49
|
-
- uses: actions/checkout@v4
|
|
50
|
-
- name: Install dependencies
|
|
51
|
-
if: runner.os == 'Linux'
|
|
52
|
-
run: sudo apt-get update && sudo apt-get install -y libwebkit2gtk-4.0-dev
|
|
53
|
-
- uses: actions/setup-go@v5
|
|
54
|
-
with:
|
|
55
|
-
go-version: ${{ matrix.go }}
|
|
56
|
-
- name: Build examples
|
|
57
|
-
run: >
|
|
58
|
-
go build
|
|
59
|
-
./examples/basic
|
|
60
|
-
./examples/bind
|
|
61
|
-
- name: Run tests
|
|
62
|
-
run: go test
|
|
@@ -1,15 +0,0 @@
|
|
|
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.
|
|
@@ -1,22 +0,0 @@
|
|
|
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.
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
package main
|
|
2
|
-
|
|
3
|
-
import webview "github.com/webview/webview_go"
|
|
4
|
-
|
|
5
|
-
const html = `<button id="increment">Tap me</button>
|
|
6
|
-
<div>You tapped <span id="count">0</span> time(s).</div>
|
|
7
|
-
<script>
|
|
8
|
-
const [incrementElement, countElement] =
|
|
9
|
-
document.querySelectorAll("#increment, #count");
|
|
10
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
11
|
-
incrementElement.addEventListener("click", () => {
|
|
12
|
-
window.increment().then(result => {
|
|
13
|
-
countElement.textContent = result.count;
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
</script>`
|
|
18
|
-
|
|
19
|
-
type IncrementResult struct {
|
|
20
|
-
Count uint `json:"count"`
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
func main() {
|
|
24
|
-
var count uint = 0
|
|
25
|
-
w := webview.New(false)
|
|
26
|
-
defer w.Destroy()
|
|
27
|
-
w.SetTitle("Bind Example")
|
|
28
|
-
w.SetSize(480, 320, webview.HintNone)
|
|
29
|
-
|
|
30
|
-
// A binding that increments a value and immediately returns the new value.
|
|
31
|
-
w.Bind("increment", func() IncrementResult {
|
|
32
|
-
count++
|
|
33
|
-
return IncrementResult{Count: count}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
w.SetHtml(html)
|
|
37
|
-
w.Run()
|
|
38
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
|
@@ -1,27 +0,0 @@
|
|
|
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.
|