@yufengtadian/freedom-cli 1.12.17 → 1.13.0

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.
Files changed (81) hide show
  1. package/lib/build.js +74 -9
  2. package/lib/cli.js +61 -3
  3. package/lib/init.js +9 -1
  4. package/lib/security.js +2 -2
  5. package/lib/utils.js +5 -2
  6. package/lib/verify.js +236 -0
  7. package/package.json +43 -39
  8. package/shell/darwin-arm64/freedom-shell +0 -0
  9. package/shell/linux-x64/freedom-shell +0 -0
  10. package/shell/win-x64/freedom-shell.exe +0 -0
  11. package/templates/go/go.mod +1 -7
  12. package/templates/go/go.sum +2 -2
  13. package/templates/go/main.go +22 -8
  14. package/templates/go/pkg/freedom/anti_debug_other.go +2 -3
  15. package/templates/go/pkg/freedom/anti_debug_windows.go +10 -12
  16. package/templates/go/pkg/freedom/assets/{index.html → default.html} +1 -1
  17. package/templates/go/pkg/freedom/assets/freedom.js +219 -21
  18. package/templates/go/pkg/freedom/assets_embed.go +11 -13
  19. package/templates/go/pkg/freedom/authenticode_other.go +11 -0
  20. package/templates/go/pkg/freedom/authenticode_windows.go +87 -0
  21. package/templates/go/pkg/freedom/backend_proc.go +295 -51
  22. package/templates/go/pkg/freedom/bridge.go +13 -2
  23. package/templates/go/pkg/freedom/capability.go +77 -0
  24. package/templates/go/pkg/freedom/center_other.go +3 -0
  25. package/templates/go/pkg/freedom/center_windows.go +64 -36
  26. package/templates/go/pkg/freedom/dispatch.go +60 -0
  27. package/templates/go/pkg/freedom/events_windows.go +319 -0
  28. package/templates/go/pkg/freedom/freedom.go +242 -92
  29. package/templates/go/pkg/freedom/msgwindow_windows.go +257 -0
  30. package/templates/go/pkg/freedom/osver_other.go +15 -0
  31. package/templates/go/pkg/freedom/osver_windows.go +121 -0
  32. package/templates/go/pkg/freedom/proc_hide_windows.go +2 -2
  33. package/templates/go/pkg/freedom/{configfile.go → resources.go} +56 -32
  34. package/templates/go/pkg/freedom/security.go +19 -12
  35. package/templates/go/pkg/freedom/singleinstance_other.go +10 -0
  36. package/templates/go/pkg/freedom/singleinstance_windows.go +145 -0
  37. package/templates/go/pkg/freedom/spawn_other.go +11 -0
  38. package/templates/go/pkg/freedom/spawn_windows.go +23 -0
  39. package/templates/go/pkg/freedom/store.go +458 -0
  40. package/templates/go/pkg/freedom/syscap_linux.go +278 -0
  41. package/templates/go/pkg/freedom/syscap_other.go +22 -0
  42. package/templates/go/pkg/freedom/syscap_windows.go +845 -0
  43. package/templates/go/pkg/freedom/sysint_common.go +70 -0
  44. package/templates/go/pkg/freedom/sysint_windows.go +426 -0
  45. package/templates/go/pkg/freedom/tray_common.go +12 -0
  46. package/templates/go/pkg/freedom/tray_linux.go +302 -0
  47. package/templates/go/pkg/freedom/tray_other.go +10 -0
  48. package/templates/go/pkg/freedom/tray_windows.go +536 -0
  49. package/templates/go/pkg/freedom/updater.go +372 -0
  50. package/templates/go/pkg/freedom/window_mgr.go +385 -0
  51. package/templates/go/pkg/freedom/window_other.go +32 -66
  52. package/templates/go/pkg/freedom/window_windows.go +406 -251
  53. package/templates/project-minimal/freedom.config.js +58 -0
  54. package/templates/project-minimal/index.html +41 -0
  55. package/templates/project-minimal/package.json +14 -0
  56. package/templates/project-minimal/src/main.js +19 -0
  57. package/templates/project-minimal/vite.config.js +18 -0
  58. package/templates/go/gen_config.go +0 -22
  59. package/templates/go/pkg/freedom/security_test.go +0 -153
  60. package/templates/go/webview_go/.github/workflows/ci.yaml +0 -62
  61. package/templates/go/webview_go/CHANGELOG.md +0 -15
  62. package/templates/go/webview_go/LICENSE +0 -22
  63. package/templates/go/webview_go/README.md +0 -50
  64. package/templates/go/webview_go/examples/basic/main.go +0 -12
  65. package/templates/go/webview_go/examples/bind/main.go +0 -38
  66. package/templates/go/webview_go/glue.c +0 -36
  67. package/templates/go/webview_go/go.mod +0 -3
  68. package/templates/go/webview_go/go.sum +0 -0
  69. package/templates/go/webview_go/libs/mswebview2/LICENSE +0 -27
  70. package/templates/go/webview_go/libs/mswebview2/include/WebView2.h +0 -23568
  71. package/templates/go/webview_go/libs/mswebview2/include/vendor.go +0 -2
  72. package/templates/go/webview_go/libs/mswebview2/vendor.go +0 -2
  73. package/templates/go/webview_go/libs/mswebview2/version.txt +0 -1
  74. package/templates/go/webview_go/libs/webview/LICENSE +0 -22
  75. package/templates/go/webview_go/libs/webview/include/vendor.go +0 -2
  76. package/templates/go/webview_go/libs/webview/include/webview.h +0 -3871
  77. package/templates/go/webview_go/libs/webview/vendor.go +0 -2
  78. package/templates/go/webview_go/libs/webview/version.txt +0 -1
  79. package/templates/go/webview_go/webview.cc +0 -1
  80. package/templates/go/webview_go/webview.go +0 -481
  81. package/templates/go/webview_go/webview_test.go +0 -50
@@ -0,0 +1,58 @@
1
+ // Freedom 应用配置(极简模板)。
2
+ // 构建时由 freedom CLI 读取,生成对应的壳层配置。
3
+ export default {
4
+ // 应用名(窗口标题 / 可执行文件名)。
5
+ name: 'freedom-app',
6
+
7
+ // 窗口初始尺寸(像素)。
8
+ width: 1024,
9
+ height: 720,
10
+
11
+ // 窗口最小尺寸(设为 0 表示不限制)。
12
+ minWidth: 400,
13
+ minHeight: 300,
14
+
15
+ // 启动时是否在屏幕居中。
16
+ center: true,
17
+
18
+ // 是否开启 WebView 开发者工具。
19
+ debug: false,
20
+
21
+ // 安全模式,在终端随时可改,三选一:
22
+ // 'none' - 明文资源(默认,兼容历史产物)
23
+ // 'basic' - 明文资源 + 构建期加固提示
24
+ // 'high' - resources 整体加密为 app.bin(磁盘无明文 HTML/配置),
25
+ // 壳内存解密 + 完整性校验,另含 anti-debug / 进程隐藏
26
+ // 终端命令:freedom security <none|basic|high>,或在 freedom build 时传 --security <mode>
27
+ security: 'none',
28
+
29
+ // 标题栏策略,在终端随时可改,二选一:
30
+ // 'native' - 保留系统原生标题栏(极简模板默认:不引入自绘标题栏,开箱即用)
31
+ // 'frameless' - 完全无边框,关闭 / 最大化 / 最小化按钮由前端自绘。
32
+ // 切换 frameless 后需在前端自行实现窗口控制按钮(完整示例见完整模板 full:
33
+ // freedom init --template full 生成的 index.html / src/main.js)。
34
+ // 终端命令:freedom titlebar <native|frameless>
35
+ titlebar: 'native',
36
+
37
+ // 应用图标(可执行文件 / .app 的图标):
38
+ // Windows 需 .ico(推荐含 16/32/48/256 多尺寸),构建时注入 exe 资源;
39
+ // macOS 需 .icns,构建时放入 .app/Contents/Resources 并写入 Info.plist。
40
+ // 值为相对项目根目录的路径或绝对路径,未配置则使用壳默认图标。
41
+ // 终端命令:freedom icon <path>(Windows 主用)
42
+ icon: undefined,
43
+
44
+ // 产物输出目录(相对项目根目录或绝对路径):
45
+ // 'dist' - 输出到 dist/ 子目录(默认)
46
+ // '.' - 直接输出到项目根目录(dist 的上级),exe 与单文件 index.html 就地生成
47
+ // 'build/app' 等任意路径亦可
48
+ // 注意:输出到项目根目录时不会覆盖项目源文件(index.html 仅保留 src 源文件)。
49
+ outDir: 'dist',
50
+
51
+ // 后端策略:
52
+ // undefined - 仅使用框架内置能力(ping / 窗口控制),不启动独立后端进程
53
+ // { command, args } - 启动任意语言后端进程(Go/Node/Python/Rust 均可),
54
+ // 经 stdin/stdout NDJSON 与壳通信,方法直接暴露给前端
55
+ // 示例(Node 后端):
56
+ // backend: { command: 'node', args: ['backend/main.mjs'] }
57
+ // backend: undefined,
58
+ };
@@ -0,0 +1,41 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Freedom App</title>
7
+ <style>
8
+ /* 极简模板:使用系统原生标题栏(titlebar: 'native'),无自绘标题栏 / 无演示内容 */
9
+ * { margin: 0; padding: 0; box-sizing: border-box; }
10
+ html, body { height: 100%; }
11
+ body {
12
+ font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
13
+ background: #111827;
14
+ color: #e5e7eb;
15
+ display: flex; align-items: center; justify-content: center;
16
+ min-height: 100%;
17
+ overflow: hidden;
18
+ user-select: none;
19
+ }
20
+ .center { text-align: center; }
21
+ h1 { font-size: 26px; font-weight: 700; }
22
+ .desc { margin-top: 10px; color: #9ca3af; font-size: 14px; }
23
+ button {
24
+ margin-top: 18px; padding: 9px 20px; border: none; border-radius: 8px;
25
+ background: #6366f1; color: #fff; font-size: 14px; cursor: pointer;
26
+ }
27
+ button:hover { background: #4f46e5; }
28
+ .result { margin-top: 10px; color: #a5b4fc; font-size: 13px; }
29
+ </style>
30
+ </head>
31
+ <body>
32
+ <div class="center">
33
+ <h1>Freedom App</h1>
34
+ <div class="desc">你的桌面应用已就绪(极简模板,系统原生标题栏)。</div>
35
+ <button id="pingBtn">测试桥接</button>
36
+ <div class="result" id="result">点击上方按钮验证前后端桥接。</div>
37
+ </div>
38
+
39
+ <script type="module" src="/src/main.js"></script>
40
+ </body>
41
+ </html>
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "freedom-app",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build"
9
+ },
10
+ "devDependencies": {
11
+ "vite": "^5.4.0",
12
+ "vite-plugin-singlefile": "^2.0.2"
13
+ }
14
+ }
@@ -0,0 +1,19 @@
1
+ // Freedom 前端入口(极简模板)。
2
+ // window.freedom 由壳层注入,无需 import:
3
+ // call(method, ...args) -> Promise 调用后端方法
4
+ // on(event, cb) / off(event, cb) 订阅 / 取消订阅后端事件
5
+ // window.minimize() / maximize() / close() 等窗口控制(frameless 模式下自绘按钮用)
6
+
7
+ // 桥接自检:__freedom__ping 是壳注入的全局函数,优先直调;
8
+ // 低版本壳不存在时回退经 bridge 路由(壳层 bridge 对 ping 特判兼容)。
9
+ document.getElementById('pingBtn').addEventListener('click', async () => {
10
+ const el = document.getElementById('result');
11
+ try {
12
+ const r = (typeof window.__freedom__ping === 'function')
13
+ ? await window.__freedom__ping()
14
+ : await window.freedom.call('__freedom__ping');
15
+ el.textContent = '桥接正常:' + r;
16
+ } catch (e) {
17
+ el.textContent = '桥接异常:' + e.message;
18
+ }
19
+ });
@@ -0,0 +1,18 @@
1
+ import { defineConfig } from 'vite';
2
+ import { viteSingleFile } from 'vite-plugin-singlefile';
3
+
4
+ // 单文件打包:把所有 JS/CSS 内联进一个 index.html,
5
+ // 便于 freedom CLI 嵌入 Go 壳层(内存加载,无本地端口)。
6
+ // outDir 指向临时构建区 .freedom/vite-dist,最终产物由 freedom build 统一输出到
7
+ // freedom.config.js 的 outDir(默认 dist/,可设为项目根目录)。
8
+ export default defineConfig({
9
+ plugins: [viteSingleFile()],
10
+ build: {
11
+ target: 'esnext',
12
+ outDir: '.freedom/vite-dist',
13
+ assetsInlineLimit: 100000000,
14
+ chunkSizeWarningLimit: 100000000,
15
+ cssCodeSplit: false,
16
+ reportCompressedSize: false,
17
+ },
18
+ });
@@ -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,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,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
- [![GoDoc](https://godoc.org/github.com/webview/webview_go?status.svg)](https://godoc.org/github.com/webview/webview_go)
4
- [![Go Report Card](https://goreportcard.com/badge/github.com/webview/webview_go)](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,12 +0,0 @@
1
- package main
2
-
3
- import webview "github.com/webview/webview_go"
4
-
5
- func main() {
6
- w := webview.New(false)
7
- defer w.Destroy()
8
- w.SetTitle("Basic Example")
9
- w.SetSize(480, 320, webview.HintNone)
10
- w.SetHtml("Thanks for using webview!")
11
- w.Run()
12
- }
@@ -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
- }
@@ -1,3 +0,0 @@
1
- module github.com/webview/webview_go
2
-
3
- go 1.13
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.