cj-tauri 2.0.0 → 2.1.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 +206 -139
- package/bin/cj-tauri.js +287 -287
- package/cjpm.toml +63 -52
- package/cli/cjpm.toml +22 -22
- package/cli/src/doctor.cj +308 -306
- package/cli/src/main.cj +129 -129
- package/cli/src/manifest.cj +643 -558
- package/cli/src/manifest_test.cj +87 -0
- package/cli/src/project.cj +770 -770
- package/cli/src/resolve.cj +348 -348
- package/cli/src/scaffold.cj +369 -369
- package/cli/src/sync.cj +638 -526
- package/cli/src/util.cj +168 -168
- package/cli/templates/app/README.md +51 -48
- package/cli/templates/app/assets/capabilities/default.json +7 -7
- package/cli/templates/app/assets/ui/index.html +120 -118
- package/cli/templates/app/cj-tauri.toml +32 -22
- package/cli/templates/app/cjpm.toml +34 -34
- package/cli/templates/app/src/main.cj +101 -90
- package/cli/templates/app-react/README.md +56 -56
- package/cli/templates/app-react/assets/capabilities/default.json +7 -7
- package/cli/templates/app-react/assets/ui/index.html +25 -25
- package/cli/templates/app-react/assets/ui/package.json +19 -19
- package/cli/templates/app-react/assets/ui/src/App.css +67 -67
- package/cli/templates/app-react/assets/ui/src/App.jsx +124 -124
- package/cli/templates/app-react/assets/ui/src/main.jsx +6 -6
- package/cli/templates/app-react/assets/ui/vite.config.js +24 -24
- package/cli/templates/app-react/cj-tauri.toml +33 -23
- package/cli/templates/app-react/cjpm.toml +34 -34
- package/cli/templates/app-react/src/main.cj +91 -91
- package/cli/templates/app-vue/README.md +56 -56
- package/cli/templates/app-vue/assets/capabilities/default.json +7 -7
- package/cli/templates/app-vue/assets/ui/index.html +25 -25
- package/cli/templates/app-vue/assets/ui/package.json +18 -18
- package/cli/templates/app-vue/assets/ui/src/App.vue +176 -176
- package/cli/templates/app-vue/assets/ui/src/main.js +4 -4
- package/cli/templates/app-vue/assets/ui/vite.config.js +24 -24
- package/cli/templates/app-vue/cj-tauri.toml +33 -23
- package/cli/templates/app-vue/cjpm.toml +34 -34
- package/cli/templates/app-vue/src/main.cj +91 -91
- package/cli/templates/ohos-skeleton/AppScope/app.json5 +13 -13
- package/cli/templates/ohos-skeleton/AppScope/resources/base/element/string.json +8 -8
- package/cli/templates/ohos-skeleton/AppScope/resources/base/media/layered_image.json +6 -6
- package/cli/templates/ohos-skeleton/README.md +84 -79
- package/cli/templates/ohos-skeleton/build-hap.sh +15 -0
- package/cli/templates/ohos-skeleton/build-profile.json5 +46 -46
- package/cli/templates/ohos-skeleton/entry/build-profile.json5 +26 -26
- package/cli/templates/ohos-skeleton/entry/cjpm.toml +51 -43
- package/cli/templates/ohos-skeleton/entry/hvigorfile.ts +6 -6
- package/cli/templates/ohos-skeleton/entry/oh-package.json5 +9 -9
- package/cli/templates/ohos-skeleton/entry/src/main/cangjie/ability_stage.cj +17 -17
- package/cli/templates/ohos-skeleton/entry/src/main/cangjie/app_host.cj +94 -94
- package/cli/templates/ohos-skeleton/entry/src/main/cangjie/dialog_host.cj +217 -0
- package/cli/templates/ohos-skeleton/entry/src/main/cangjie/index.cj +527 -167
- package/cli/templates/ohos-skeleton/entry/src/main/cangjie/main_ability.cj +139 -139
- package/cli/templates/ohos-skeleton/entry/src/main/module.json5 +57 -49
- package/cli/templates/ohos-skeleton/entry/src/main/resources/base/element/color.json +8 -8
- package/cli/templates/ohos-skeleton/entry/src/main/resources/base/element/string.json +16 -16
- package/cli/templates/ohos-skeleton/entry/src/main/resources/base/media/layered_image.json +6 -6
- package/cli/templates/ohos-skeleton/entry/src/main/resources/base/profile/main_pages.json +2 -2
- package/cli/templates/ohos-skeleton/entry/src/main/resources/rawfile/capabilities.json +6 -6
- package/cli/templates/ohos-skeleton/entry/src/main/resources/rawfile/index.html +92 -92
- package/cli/templates/ohos-skeleton/hvigor/hvigor-config.json5 +5 -5
- package/cli/templates/ohos-skeleton/hvigorfile.ts +6 -6
- package/cli/templates/ohos-skeleton/oh-package.json5 +10 -10
- package/native/build_win.bat +62 -62
- package/native/core/bridge_core.c +1681 -1626
- package/native/core/bridge_core.h +675 -618
- package/native/core/bridge_js.h +108 -108
- package/native/platforms/harmonyos/README.md +115 -6
- package/native/platforms/linux/bridge_linux.c +2787 -2485
- package/native/platforms/windows/bridge_win.c +3745 -3248
- package/native/tests/gtk_threading_probe.c +143 -143
- package/native/tests/test_bridge_core.c +1339 -1228
- package/package.json +53 -53
- package/src/api_system.cj +67 -67
- package/src/app.cj +335 -969
- package/src/app_events.cj +166 -0
- package/src/app_host_ops.cj +287 -0
- package/src/app_run.cj +283 -0
- package/src/app_spec.cj +76 -76
- package/src/arkweb_menu.cj +216 -0
- package/src/arkweb_script.cj +142 -142
- package/src/capability.cj +409 -409
- package/src/clipboard_bridge.cj +178 -0
- package/src/dialog_spec.cj +79 -0
- package/src/dragdrop.cj +26 -26
- package/src/embedded_assets.cj +98 -98
- package/src/host.cj +752 -607
- package/src/host_arkweb.cj +924 -778
- package/src/host_webkit.cj +663 -570
- package/src/host_webview2.cj +663 -570
- package/src/hotkey.cj +66 -66
- package/src/ipc_hub.cj +401 -337
- package/src/ipc_message.cj +286 -286
- package/src/launch.cj +62 -62
- package/src/logging.cj +127 -127
- package/src/menu.cj +197 -197
- package/src/platform/platform_app_context.cj +77 -77
- package/src/platform/platform_assets.cj +33 -33
- package/src/platform/platform_discover.cj +176 -176
- package/src/platform/platform_env.cj +29 -29
- package/src/platform/platform_feature.cj +31 -31
- package/src/platform/platform_page_source.cj +87 -87
- package/src/platform/platform_target_info.cj +32 -32
- package/src/platform_host_provider.cj +87 -87
- package/src/plugin.cj +333 -333
- package/src/plugins/clipboard/plugin_clipboard.cj +152 -152
- package/src/plugins/dialog/plugin_dialog.cj +209 -209
- package/src/plugins/fs/plugin_fs.cj +105 -1
- package/src/plugins/http/http_backend.cj +131 -0
- package/src/plugins/http/http_desktop.cj +195 -0
- package/src/plugins/http/http_ohos.cj +204 -0
- package/src/plugins/http/plugin_http.cj +310 -459
- package/src/plugins/log/plugin_log.cj +105 -105
- package/src/plugins/menu/plugin_menu.cj +158 -158
- package/src/plugins/notification/plugin_notification.cj +154 -154
- package/src/plugins/serial/plugin_serial.cj +458 -454
- package/src/plugins/serial/serial_bridge.cj +194 -194
- package/src/plugins/serial/serial_manager_ohos.cj +92 -0
- package/src/plugins/serial/serial_ohos.cj +529 -0
- package/src/plugins/shell/plugin_shell.cj +258 -258
- package/src/plugins/sqlite/plugin_sqlite.cj +705 -710
- package/src/plugins/sqlite/sqlite_ffi.cj +206 -211
- package/src/plugins/ws/plugin_ws.cj +488 -470
- package/src/process_hidden.cj +174 -174
- package/src/scope.cj +391 -391
- package/src/shell_event.cj +69 -69
- package/src/tests/app_spec_test.cj +130 -127
- package/src/tests/capability_test.cj +243 -243
- package/src/tests/dialog_spec_test.cj +73 -0
- package/src/tests/fake_host.cj +201 -201
- package/src/tests/ipc_hub_test.cj +563 -487
- package/src/tests/logging_test.cj +62 -62
- package/src/tests/platform_contract_test.cj +264 -251
- package/src/tests/plugin_clipboard_test.cj +222 -222
- package/src/tests/plugin_dialog_test.cj +237 -237
- package/src/tests/plugin_fs_test.cj +207 -0
- package/src/tests/plugin_http_test.cj +124 -124
- package/src/tests/plugin_notification_test.cj +205 -205
- package/src/tests/plugin_serial_test.cj +48 -0
- package/src/tests/plugin_test.cj +605 -585
- package/src/tests/plugin_ws_test.cj +40 -40
- package/src/tests/process_hidden_test.cj +129 -129
- package/src/tests/scope_test.cj +350 -350
- package/src/tests/system_host_test.cj +99 -81
- package/src/tests/urlutil_test.cj +53 -53
- package/src/tests/version_test.cj +75 -75
- package/src/tests/window_registry_test.cj +123 -123
- package/src/tray.cj +90 -90
- package/src/urlutil.cj +159 -159
- package/src/version.cj +44 -44
- package/src/window.cj +51 -51
- package/src/window_registry.cj +116 -116
- package/prebuilt/win32-x64/cj-tauri.exe +0 -0
- package/src/plugins/serial/serial_ohos_stub.cj +0 -61
- package/src/plugins/sqlite/sqlite_ohos_stub.cj +0 -91
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<title>{{PROJECT_NAME}}</title>
|
|
6
|
-
<style>
|
|
7
|
-
:root { color-scheme: dark; }
|
|
8
|
-
body { font-family: system-ui, "HarmonyOS Sans", "Segoe UI", sans-serif; background: #16161d;
|
|
9
|
-
color: #e6e6e6; margin: 0; min-height: 100vh;
|
|
10
|
-
display: flex; flex-direction: column; align-items: center; justify-content: center; }
|
|
11
|
-
.card { background: #1f2029; border: 1px solid #2e3140; border-radius: 14px;
|
|
12
|
-
padding: 28px 32px; width: min(520px, 86vw);
|
|
13
|
-
box-shadow: 0 12px 32px rgba(0,0,0,.45); }
|
|
14
|
-
h1 { margin: 0 0 4px; font-size: 22px; color: #7ce7ff; }
|
|
15
|
-
.sub { margin: 0 0 18px; font-size: 13px; color: #9aa0b4; line-height: 1.6; }
|
|
16
|
-
.row { display: flex; gap: 8px; margin: 14px 0; }
|
|
17
|
-
input, button { font-size: 15px; padding: 9px 12px; border-radius: 9px; border: 1px solid transparent; }
|
|
18
|
-
input { flex: 1; background: #141821; color: #e6e6e6; border-color: #2e3140; }
|
|
19
|
-
input:focus { outline: none; border-color: #4a7fd4; }
|
|
20
|
-
button { background: #e94560; color: #fff; cursor: pointer; font-weight: 600; }
|
|
21
|
-
button:hover { opacity: .88; }
|
|
22
|
-
button.ghost { background: #2b3040; }
|
|
23
|
-
.result { margin-top: 6px; min-height: 24px; font-size: 15px; color: #50fa7b; word-break: break-all; }
|
|
24
|
-
.tick { margin-top: 10px; font-size: 13px; color: #8be9fd; min-height: 18px; }
|
|
25
|
-
.foot { margin-top: 18px; font-size: 12px; color: #6b7186; line-height: 1.7; }
|
|
26
|
-
</style>
|
|
27
|
-
</head>
|
|
28
|
-
<body>
|
|
29
|
-
<div class="card">
|
|
30
|
-
<h1>{{PROJECT_NAME}}</h1>
|
|
31
|
-
<p class="sub">仓颉后端(静态编译)+ ArkWeb 前端 · invoke / listen 双向 IPC · capability 安全模型</p>
|
|
32
|
-
|
|
33
|
-
<div class="row">
|
|
34
|
-
<input id="name" placeholder="输入名字" value="world">
|
|
35
|
-
<button id="greet">greet</button>
|
|
36
|
-
</div>
|
|
37
|
-
<div class="row">
|
|
38
|
-
<button id="timer" class="ghost">启动后端事件推送</button>
|
|
39
|
-
<button id="version" class="ghost">system:version</button>
|
|
40
|
-
</div>
|
|
41
|
-
|
|
42
|
-
<div id="result" class="result">等待 invoke…</div>
|
|
43
|
-
<div id="tick" class="tick"></div>
|
|
44
|
-
<div class="foot">未在 rawfile/capabilities.json 里声明的命令会被后端拒绝</div>
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<script>
|
|
48
|
-
// 注入的桥(对标 @tauri-apps/api):window.__CJ_TAURI__
|
|
49
|
-
// 鸿蒙的 ArkWeb 没有 document-start 注入,桥是在 onPageBegin 里注入的,
|
|
50
|
-
// 所以页面必须「等桥出现」而不是模块作用域直接读。
|
|
51
|
-
function withBridge(cb) {
|
|
52
|
-
if (window.__CJ_TAURI__) { cb(window.__CJ_TAURI__); return; }
|
|
53
|
-
setTimeout(function () { withBridge(cb); }, 50);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
withBridge(function (tauri) {
|
|
57
|
-
var result = document.getElementById('result');
|
|
58
|
-
var tick = document.getElementById('tick');
|
|
59
|
-
|
|
60
|
-
function show(text, ok) {
|
|
61
|
-
result.textContent = text;
|
|
62
|
-
result.style.color = ok === false ? '#ff6b81' : '#50fa7b';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// JS → 仓颉
|
|
66
|
-
document.getElementById('greet').onclick = function () {
|
|
67
|
-
var name = document.getElementById('name').value || 'world';
|
|
68
|
-
tauri.invoke('greet', { name: name })
|
|
69
|
-
.then(function (data) { show('invoke OK: ' + data); })
|
|
70
|
-
.catch(function (err) { show('invoke FAIL: ' + err.message, false); });
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
document.getElementById('version').onclick = function () {
|
|
74
|
-
tauri.invoke('system:version')
|
|
75
|
-
.then(function (data) { show('system:version -> ' + JSON.stringify(data)); })
|
|
76
|
-
.catch(function (err) { show('system:version FAIL: ' + err.message, false); });
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// 仓颉 → JS(事件推送)
|
|
80
|
-
document.getElementById('timer').onclick = function () {
|
|
81
|
-
tauri.invoke('timer')
|
|
82
|
-
.then(function (d) { show('后端: ' + d); })
|
|
83
|
-
.catch(function (err) { show('timer FAIL: ' + err.message, false); });
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
tauri.listen('tick', function (payload) {
|
|
87
|
-
tick.textContent = '收到后端事件 tick #' + payload.n;
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
</script>
|
|
91
|
-
</body>
|
|
92
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>{{PROJECT_NAME}}</title>
|
|
6
|
+
<style>
|
|
7
|
+
:root { color-scheme: dark; }
|
|
8
|
+
body { font-family: system-ui, "HarmonyOS Sans", "Segoe UI", sans-serif; background: #16161d;
|
|
9
|
+
color: #e6e6e6; margin: 0; min-height: 100vh;
|
|
10
|
+
display: flex; flex-direction: column; align-items: center; justify-content: center; }
|
|
11
|
+
.card { background: #1f2029; border: 1px solid #2e3140; border-radius: 14px;
|
|
12
|
+
padding: 28px 32px; width: min(520px, 86vw);
|
|
13
|
+
box-shadow: 0 12px 32px rgba(0,0,0,.45); }
|
|
14
|
+
h1 { margin: 0 0 4px; font-size: 22px; color: #7ce7ff; }
|
|
15
|
+
.sub { margin: 0 0 18px; font-size: 13px; color: #9aa0b4; line-height: 1.6; }
|
|
16
|
+
.row { display: flex; gap: 8px; margin: 14px 0; }
|
|
17
|
+
input, button { font-size: 15px; padding: 9px 12px; border-radius: 9px; border: 1px solid transparent; }
|
|
18
|
+
input { flex: 1; background: #141821; color: #e6e6e6; border-color: #2e3140; }
|
|
19
|
+
input:focus { outline: none; border-color: #4a7fd4; }
|
|
20
|
+
button { background: #e94560; color: #fff; cursor: pointer; font-weight: 600; }
|
|
21
|
+
button:hover { opacity: .88; }
|
|
22
|
+
button.ghost { background: #2b3040; }
|
|
23
|
+
.result { margin-top: 6px; min-height: 24px; font-size: 15px; color: #50fa7b; word-break: break-all; }
|
|
24
|
+
.tick { margin-top: 10px; font-size: 13px; color: #8be9fd; min-height: 18px; }
|
|
25
|
+
.foot { margin-top: 18px; font-size: 12px; color: #6b7186; line-height: 1.7; }
|
|
26
|
+
</style>
|
|
27
|
+
</head>
|
|
28
|
+
<body>
|
|
29
|
+
<div class="card">
|
|
30
|
+
<h1>{{PROJECT_NAME}}</h1>
|
|
31
|
+
<p class="sub">仓颉后端(静态编译)+ ArkWeb 前端 · invoke / listen 双向 IPC · capability 安全模型</p>
|
|
32
|
+
|
|
33
|
+
<div class="row">
|
|
34
|
+
<input id="name" placeholder="输入名字" value="world">
|
|
35
|
+
<button id="greet">greet</button>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="row">
|
|
38
|
+
<button id="timer" class="ghost">启动后端事件推送</button>
|
|
39
|
+
<button id="version" class="ghost">system:version</button>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div id="result" class="result">等待 invoke…</div>
|
|
43
|
+
<div id="tick" class="tick"></div>
|
|
44
|
+
<div class="foot">未在 rawfile/capabilities.json 里声明的命令会被后端拒绝</div>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
// 注入的桥(对标 @tauri-apps/api):window.__CJ_TAURI__
|
|
49
|
+
// 鸿蒙的 ArkWeb 没有 document-start 注入,桥是在 onPageBegin 里注入的,
|
|
50
|
+
// 所以页面必须「等桥出现」而不是模块作用域直接读。
|
|
51
|
+
function withBridge(cb) {
|
|
52
|
+
if (window.__CJ_TAURI__) { cb(window.__CJ_TAURI__); return; }
|
|
53
|
+
setTimeout(function () { withBridge(cb); }, 50);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
withBridge(function (tauri) {
|
|
57
|
+
var result = document.getElementById('result');
|
|
58
|
+
var tick = document.getElementById('tick');
|
|
59
|
+
|
|
60
|
+
function show(text, ok) {
|
|
61
|
+
result.textContent = text;
|
|
62
|
+
result.style.color = ok === false ? '#ff6b81' : '#50fa7b';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// JS → 仓颉
|
|
66
|
+
document.getElementById('greet').onclick = function () {
|
|
67
|
+
var name = document.getElementById('name').value || 'world';
|
|
68
|
+
tauri.invoke('greet', { name: name })
|
|
69
|
+
.then(function (data) { show('invoke OK: ' + data); })
|
|
70
|
+
.catch(function (err) { show('invoke FAIL: ' + err.message, false); });
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
document.getElementById('version').onclick = function () {
|
|
74
|
+
tauri.invoke('system:version')
|
|
75
|
+
.then(function (data) { show('system:version -> ' + JSON.stringify(data)); })
|
|
76
|
+
.catch(function (err) { show('system:version FAIL: ' + err.message, false); });
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// 仓颉 → JS(事件推送)
|
|
80
|
+
document.getElementById('timer').onclick = function () {
|
|
81
|
+
tauri.invoke('timer')
|
|
82
|
+
.then(function (d) { show('后端: ' + d); })
|
|
83
|
+
.catch(function (err) { show('timer FAIL: ' + err.message, false); });
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
tauri.listen('tick', function (payload) {
|
|
87
|
+
tick.textContent = '收到后端事件 tick #' + payload.n;
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
</script>
|
|
91
|
+
</body>
|
|
92
|
+
</html>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"modelVersion": "6.1.1",
|
|
3
|
-
"dependencies": {
|
|
4
|
-
}
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"modelVersion": "6.1.1",
|
|
3
|
+
"dependencies": {
|
|
4
|
+
}
|
|
5
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { appTasks } from '@ohos/hvigor-ohos-plugin';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
|
5
|
-
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
|
|
6
|
-
}
|
|
1
|
+
import { appTasks } from '@ohos/hvigor-ohos-plugin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
|
5
|
+
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
|
|
6
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"modelVersion": "6.1.1",
|
|
3
|
-
"description": "{{PROJECT_NAME}} - cj-tauri 鸿蒙 PC 应用",
|
|
4
|
-
"dependencies": {
|
|
5
|
-
},
|
|
6
|
-
"devDependencies": {
|
|
7
|
-
"@ohos/hypium": "1.0.25",
|
|
8
|
-
"@ohos/hamock": "1.0.0"
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"modelVersion": "6.1.1",
|
|
3
|
+
"description": "{{PROJECT_NAME}} - cj-tauri 鸿蒙 PC 应用",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
},
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@ohos/hypium": "1.0.25",
|
|
8
|
+
"@ohos/hamock": "1.0.0"
|
|
9
|
+
}
|
|
10
|
+
}
|
package/native/build_win.bat
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
REM ============================================================
|
|
3
|
-
REM cj-tauri Windows backend: build the WebView2 C bridge (libcjtbridge.dll)
|
|
4
|
-
REM
|
|
5
|
-
REM Requirements:
|
|
6
|
-
REM - mingw-w64 / llvm-mingw gcc on PATH
|
|
7
|
-
REM - WebView2 SDK (NuGet package Microsoft.Web.WebView2, unzipped = SDK root)
|
|
8
|
-
REM Default SDK root: D:\webview2sdk\sdk-1.0.2365.46
|
|
9
|
-
REM Override with the WEBVIEW2_SDK_ROOT environment variable.
|
|
10
|
-
REM
|
|
11
|
-
REM Version rule (important): the SDK must NOT be newer than the WebView2
|
|
12
|
-
REM Runtime installed on this machine. This machine has runtime 122.0.2365.106,
|
|
13
|
-
REM so use SDK 1.0.2365.46.
|
|
14
|
-
REM Check runtime version:
|
|
15
|
-
REM reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" /v pv
|
|
16
|
-
REM
|
|
17
|
-
REM Output: native\libcjtbridge.dll + native\libcjtbridge.dll.a (import lib)
|
|
18
|
-
REM native\webview2\WebView2Loader.dll (synced to the SDK version)
|
|
19
|
-
REM ============================================================
|
|
20
|
-
setlocal
|
|
21
|
-
|
|
22
|
-
set SCRIPT_DIR=%~dp0
|
|
23
|
-
if "%WEBVIEW2_SDK_ROOT%"=="" set WEBVIEW2_SDK_ROOT=D:\webview2sdk\sdk-1.0.2365.46
|
|
24
|
-
set WEBVIEW2_SDK_INCLUDE=%WEBVIEW2_SDK_ROOT%\build\native\include
|
|
25
|
-
|
|
26
|
-
if not exist "%WEBVIEW2_SDK_INCLUDE%\WebView2.h" (
|
|
27
|
-
echo [ERROR] WebView2.h not found in %WEBVIEW2_SDK_INCLUDE%
|
|
28
|
-
echo Download Microsoft.Web.WebView2 from nuget.org and unzip,
|
|
29
|
-
echo or set WEBVIEW2_SDK_ROOT.
|
|
30
|
-
exit /b 1
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
cd /d "%SCRIPT_DIR%"
|
|
34
|
-
|
|
35
|
-
REM bridge_core.c holds the platform-independent half (JS queue, dialog state
|
|
36
|
-
REM machine, init scripts, lifecycle flags) and exports every cj_bridge_* entry
|
|
37
|
-
REM point; bridge_win.c only implements the WebView2/COM primitives it calls.
|
|
38
|
-
REM Both must be linked, or the cj_core_* symbols bridge_win.c references go
|
|
39
|
-
REM undefined (that is what happens if you build bridge_win.c alone).
|
|
40
|
-
REM core\ = cross-platform shared layer; platforms\windows\ = WebView2 implementation
|
|
41
|
-
gcc -shared -O2 -fstack-protector-all -Icore core\bridge_core.c platforms\windows\bridge_win.c -o libcjtbridge.dll ^
|
|
42
|
-
-Wl,--out-implib,libcjtbridge.dll.a ^
|
|
43
|
-
-I"%WEBVIEW2_SDK_INCLUDE%" ^
|
|
44
|
-
-lole32 -loleaut32 -luuid -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lshell32
|
|
45
|
-
|
|
46
|
-
if errorlevel 1 (
|
|
47
|
-
echo [ERROR] build libcjtbridge.dll failed
|
|
48
|
-
exit /b 1
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
REM Sync the x64 loader matching the headers, so the WebView never puts an
|
|
52
|
-
REM SDK newer than the installed runtime on the wire.
|
|
53
|
-
if not exist webview2 mkdir webview2
|
|
54
|
-
copy /y "%WEBVIEW2_SDK_ROOT%\build\native\x64\WebView2Loader.dll" webview2\ >nul
|
|
55
|
-
if errorlevel 1 (
|
|
56
|
-
echo [WARN] WebView2Loader.dll copy failed, check %WEBVIEW2_SDK_ROOT%\build\native\x64
|
|
57
|
-
) else (
|
|
58
|
-
echo [OK] WebView2Loader.dll synced
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
echo [OK] libcjtbridge.dll built
|
|
62
|
-
endlocal
|
|
1
|
+
@echo off
|
|
2
|
+
REM ============================================================
|
|
3
|
+
REM cj-tauri Windows backend: build the WebView2 C bridge (libcjtbridge.dll)
|
|
4
|
+
REM
|
|
5
|
+
REM Requirements:
|
|
6
|
+
REM - mingw-w64 / llvm-mingw gcc on PATH
|
|
7
|
+
REM - WebView2 SDK (NuGet package Microsoft.Web.WebView2, unzipped = SDK root)
|
|
8
|
+
REM Default SDK root: D:\webview2sdk\sdk-1.0.2365.46
|
|
9
|
+
REM Override with the WEBVIEW2_SDK_ROOT environment variable.
|
|
10
|
+
REM
|
|
11
|
+
REM Version rule (important): the SDK must NOT be newer than the WebView2
|
|
12
|
+
REM Runtime installed on this machine. This machine has runtime 122.0.2365.106,
|
|
13
|
+
REM so use SDK 1.0.2365.46.
|
|
14
|
+
REM Check runtime version:
|
|
15
|
+
REM reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" /v pv
|
|
16
|
+
REM
|
|
17
|
+
REM Output: native\libcjtbridge.dll + native\libcjtbridge.dll.a (import lib)
|
|
18
|
+
REM native\webview2\WebView2Loader.dll (synced to the SDK version)
|
|
19
|
+
REM ============================================================
|
|
20
|
+
setlocal
|
|
21
|
+
|
|
22
|
+
set SCRIPT_DIR=%~dp0
|
|
23
|
+
if "%WEBVIEW2_SDK_ROOT%"=="" set WEBVIEW2_SDK_ROOT=D:\webview2sdk\sdk-1.0.2365.46
|
|
24
|
+
set WEBVIEW2_SDK_INCLUDE=%WEBVIEW2_SDK_ROOT%\build\native\include
|
|
25
|
+
|
|
26
|
+
if not exist "%WEBVIEW2_SDK_INCLUDE%\WebView2.h" (
|
|
27
|
+
echo [ERROR] WebView2.h not found in %WEBVIEW2_SDK_INCLUDE%
|
|
28
|
+
echo Download Microsoft.Web.WebView2 from nuget.org and unzip,
|
|
29
|
+
echo or set WEBVIEW2_SDK_ROOT.
|
|
30
|
+
exit /b 1
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
cd /d "%SCRIPT_DIR%"
|
|
34
|
+
|
|
35
|
+
REM bridge_core.c holds the platform-independent half (JS queue, dialog state
|
|
36
|
+
REM machine, init scripts, lifecycle flags) and exports every cj_bridge_* entry
|
|
37
|
+
REM point; bridge_win.c only implements the WebView2/COM primitives it calls.
|
|
38
|
+
REM Both must be linked, or the cj_core_* symbols bridge_win.c references go
|
|
39
|
+
REM undefined (that is what happens if you build bridge_win.c alone).
|
|
40
|
+
REM core\ = cross-platform shared layer; platforms\windows\ = WebView2 implementation
|
|
41
|
+
gcc -shared -O2 -fstack-protector-all -Icore core\bridge_core.c platforms\windows\bridge_win.c -o libcjtbridge.dll ^
|
|
42
|
+
-Wl,--out-implib,libcjtbridge.dll.a ^
|
|
43
|
+
-I"%WEBVIEW2_SDK_INCLUDE%" ^
|
|
44
|
+
-lole32 -loleaut32 -luuid -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lshell32
|
|
45
|
+
|
|
46
|
+
if errorlevel 1 (
|
|
47
|
+
echo [ERROR] build libcjtbridge.dll failed
|
|
48
|
+
exit /b 1
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
REM Sync the x64 loader matching the headers, so the WebView never puts an
|
|
52
|
+
REM SDK newer than the installed runtime on the wire.
|
|
53
|
+
if not exist webview2 mkdir webview2
|
|
54
|
+
copy /y "%WEBVIEW2_SDK_ROOT%\build\native\x64\WebView2Loader.dll" webview2\ >nul
|
|
55
|
+
if errorlevel 1 (
|
|
56
|
+
echo [WARN] WebView2Loader.dll copy failed, check %WEBVIEW2_SDK_ROOT%\build\native\x64
|
|
57
|
+
) else (
|
|
58
|
+
echo [OK] WebView2Loader.dll synced
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
echo [OK] libcjtbridge.dll built
|
|
62
|
+
endlocal
|