cj-tauri 0.8.0 → 1.1.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.
- package/README.md +3 -3
- package/cjpm.toml +52 -25
- package/cli/cjpm.toml +1 -1
- package/cli/src/doctor.cj +304 -0
- package/cli/src/main.cj +33 -7
- package/cli/src/project.cj +59 -1
- package/cli/src/resolve.cj +348 -304
- package/cli/src/scaffold.cj +139 -22
- package/cli/templates/ohos-pc/AppScope/app.json5 +13 -0
- package/cli/templates/ohos-pc/AppScope/resources/base/element/string.json +8 -0
- package/cli/templates/ohos-pc/AppScope/resources/base/media/background.png +0 -0
- package/cli/templates/ohos-pc/AppScope/resources/base/media/foreground.png +0 -0
- package/cli/templates/ohos-pc/AppScope/resources/base/media/layered_image.json +6 -0
- package/cli/templates/ohos-pc/README.md +79 -0
- package/cli/templates/ohos-pc/build-hap.sh +190 -0
- package/cli/templates/ohos-pc/build-profile.json5 +46 -0
- package/cli/templates/ohos-pc/entry/build-profile.json5 +26 -0
- package/cli/templates/ohos-pc/entry/cjpm.toml +43 -0
- package/cli/templates/ohos-pc/entry/hvigorfile.ts +6 -0
- package/cli/templates/ohos-pc/entry/oh-package.json5 +9 -0
- package/cli/templates/ohos-pc/entry/src/main/cangjie/ability_stage.cj +17 -0
- package/cli/templates/ohos-pc/entry/src/main/cangjie/app_host.cj +94 -0
- package/cli/templates/ohos-pc/entry/src/main/cangjie/index.cj +167 -0
- package/cli/templates/ohos-pc/entry/src/main/cangjie/main_ability.cj +139 -0
- package/cli/templates/ohos-pc/entry/src/main/module.json5 +49 -0
- package/cli/templates/ohos-pc/entry/src/main/resources/base/element/color.json +8 -0
- package/cli/templates/ohos-pc/entry/src/main/resources/base/element/string.json +16 -0
- package/cli/templates/ohos-pc/entry/src/main/resources/base/media/background.png +0 -0
- package/cli/templates/ohos-pc/entry/src/main/resources/base/media/foreground.png +0 -0
- package/cli/templates/ohos-pc/entry/src/main/resources/base/media/layered_image.json +6 -0
- package/cli/templates/ohos-pc/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/cli/templates/ohos-pc/entry/src/main/resources/base/profile/main_pages.json +2 -0
- package/cli/templates/ohos-pc/entry/src/main/resources/rawfile/capabilities.json +6 -0
- package/cli/templates/ohos-pc/entry/src/main/resources/rawfile/index.html +92 -0
- package/cli/templates/ohos-pc/hvigor/hvigor-config.json5 +5 -0
- package/cli/templates/ohos-pc/hvigorfile.ts +6 -0
- package/cli/templates/ohos-pc/oh-package.json5 +10 -0
- package/native/build_linux.sh +30 -2
- package/native/build_win.bat +62 -61
- package/native/core/bridge_core.c +1626 -0
- package/native/{bridge_core.h → core/bridge_core.h} +246 -6
- package/native/platforms/harmonyos/README.md +106 -0
- package/native/platforms/linux/bridge_linux.c +2485 -0
- package/native/platforms/windows/bridge_win.c +3248 -0
- package/native/tests/test_bridge_core.c +528 -1
- package/package.json +12 -3
- package/prebuilt/win32-x64/cj-tauri.exe +0 -0
- package/src/api_system.cj +10 -2
- package/src/app.cj +248 -85
- package/src/arkweb_proxy.cj +56 -0
- package/src/arkweb_script.cj +154 -0
- package/src/capability.cj +140 -0
- package/src/clipboard_bridge.cj +55 -0
- package/src/dragdrop.cj +26 -0
- package/src/embedded_assets.cj +98 -0
- package/src/hexutil.cj +53 -0
- package/src/host.cj +197 -26
- package/src/host_arkweb.cj +740 -0
- package/src/host_factory.cj +48 -0
- package/src/host_webkit.cj +202 -26
- package/src/host_webview2.cj +176 -3
- package/src/hotkey.cj +66 -0
- package/src/ipc_hub.cj +49 -0
- package/src/ipc_message.cj +2 -1
- package/src/jsutil.cj +33 -0
- package/src/log_bridge.cj +107 -0
- package/src/logging.cj +127 -0
- package/src/menu.cj +197 -196
- package/src/plugin.cj +40 -0
- package/src/plugins/clipboard/plugin_clipboard.cj +144 -0
- package/src/{plugin_dialog.cj → plugins/dialog/plugin_dialog.cj} +74 -17
- package/src/plugins/fs/plugin_fs.cj +194 -0
- package/src/plugins/http/plugin_http.cj +459 -0
- package/src/plugins/log/plugin_log.cj +105 -0
- package/src/{plugin_menu.cj → plugins/menu/plugin_menu.cj} +4 -2
- package/src/plugins/mqtt/mqtt_codec.cj +661 -0
- package/src/plugins/mqtt/plugin_mqtt.cj +1446 -0
- package/src/plugins/notification/plugin_notification.cj +146 -0
- package/src/plugins/plugins.cj +5 -0
- package/src/plugins/redis/plugin_redis.cj +2409 -0
- package/src/plugins/redis/redis_codec.cj +556 -0
- package/src/{plugin_serial.cj → plugins/serial/plugin_serial.cj} +442 -489
- package/src/{serial_bridge.cj → plugins/serial/serial_bridge.cj} +185 -184
- package/src/{plugin_shell.cj → plugins/shell/plugin_shell.cj} +230 -228
- package/src/plugins/sqlite/plugin_sqlite.cj +697 -0
- package/src/plugins/sqlite/sqlite_ffi.cj +206 -0
- package/src/plugins/store/plugin_store.cj +287 -0
- package/src/plugins/ws/plugin_ws.cj +470 -0
- package/src/process_hidden.cj +174 -0
- package/src/scope.cj +391 -0
- package/src/shell_event.cj +69 -68
- package/src/tests/capability_test.cj +53 -0
- package/src/tests/fake_host.cj +85 -20
- package/src/tests/ipc_hub_test.cj +13 -0
- package/src/tests/jsutil_test.cj +62 -0
- package/src/tests/logging_test.cj +62 -0
- package/src/tests/mqtt_codec_test.cj +405 -0
- package/src/tests/plugin_clipboard_test.cj +222 -0
- package/src/tests/plugin_dialog_test.cj +98 -4
- package/src/tests/plugin_http_test.cj +124 -0
- package/src/tests/plugin_menu_test.cj +1 -0
- package/src/tests/plugin_notification_test.cj +205 -0
- package/src/tests/plugin_serial_test.cj +269 -267
- package/src/tests/plugin_shell_test.cj +189 -188
- package/src/tests/plugin_sqlite_test.cj +230 -0
- package/src/tests/plugin_store_test.cj +260 -0
- package/src/tests/plugin_test.cj +542 -524
- package/src/tests/plugin_ws_test.cj +40 -0
- package/src/tests/process_hidden_test.cj +129 -0
- package/src/tests/redis_codec_test.cj +396 -0
- package/src/tests/scope_test.cj +350 -0
- package/src/tests/shell_event_test.cj +0 -1
- package/src/tests/system_host_test.cj +81 -79
- package/src/tests/urlutil_test.cj +53 -0
- package/src/tests/version_test.cj +75 -65
- package/src/tray.cj +90 -0
- package/src/urlutil.cj +159 -0
- package/src/version.cj +23 -2
- package/src/window.cj +51 -42
- package/native/bridge_core.c +0 -797
- package/native/bridge_linux.c +0 -1268
- package/native/bridge_win.c +0 -1633
- package/src/plugin_fs.cj +0 -118
- /package/native/{bridge_js.h → core/bridge_js.h} +0 -0
package/native/build_linux.sh
CHANGED
|
@@ -38,10 +38,38 @@ if ! pkg-config --exists $PKGS; then
|
|
|
38
38
|
exit 1
|
|
39
39
|
fi
|
|
40
40
|
|
|
41
|
+
# 全局快捷键的可选编译(RFC-002 §6.3):有 X11 dev 就带上(CJ_HAVE_X11 + -lX11),
|
|
42
|
+
# 没有也能编——能力位如实不置位,运行期调用打一行说明。Debian/Ubuntu: libx11-dev
|
|
43
|
+
X11_FLAGS=""
|
|
44
|
+
X11_LIBS=""
|
|
45
|
+
if pkg-config --exists x11; then
|
|
46
|
+
X11_FLAGS="-DCJ_HAVE_X11"
|
|
47
|
+
X11_LIBS="$(pkg-config --libs x11)"
|
|
48
|
+
echo "[ok] X11 found - global hotkeys enabled (CJ_HAVE_X11)"
|
|
49
|
+
else
|
|
50
|
+
echo "[warn] X11 dev not found - global hotkeys disabled (apt install libx11-dev to enable)" >&2
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# 托盘的可选编译(RFC-002 §6.3):有 libayatana-appindicator3 就带上(CJ_HAVE_TRAY),
|
|
54
|
+
# 没有也能编——能力位如实不置位。Debian/Ubuntu: libayatana-appindicator3-dev
|
|
55
|
+
TRAY_FLAGS=""
|
|
56
|
+
TRAY_LIBS=""
|
|
57
|
+
TRAY_CFLAGS=""
|
|
58
|
+
if pkg-config --exists ayatana-appindicator3-0.1; then
|
|
59
|
+
TRAY_FLAGS="-DCJ_HAVE_TRAY"
|
|
60
|
+
TRAY_CFLAGS="$(pkg-config --cflags ayatana-appindicator3-0.1)"
|
|
61
|
+
TRAY_LIBS="$(pkg-config --libs ayatana-appindicator3-0.1)"
|
|
62
|
+
echo "[ok] ayatana-appindicator3 found - tray enabled (CJ_HAVE_TRAY)"
|
|
63
|
+
else
|
|
64
|
+
echo "[warn] ayatana-appindicator3 not found - tray disabled (apt install libayatana-appindicator3-dev to enable)" >&2
|
|
65
|
+
fi
|
|
66
|
+
|
|
41
67
|
# shellcheck disable=SC2086
|
|
42
|
-
|
|
68
|
+
# core/ = 跨平台共享层;platforms/linux/ = GTK/WebKit 平台实现(目录契约见 AGENTS §2)
|
|
69
|
+
"$CC" -shared -fPIC -O2 -fstack-protector-all \
|
|
70
|
+
-Icore $X11_FLAGS $TRAY_FLAGS $TRAY_CFLAGS core/bridge_core.c platforms/linux/bridge_linux.c \
|
|
43
71
|
-o libcjtbridge.so \
|
|
44
|
-
$(pkg-config --cflags --libs $PKGS)
|
|
72
|
+
$(pkg-config --cflags --libs $PKGS) $X11_LIBS $TRAY_LIBS
|
|
45
73
|
|
|
46
74
|
if [ ! -f libcjtbridge.so ]; then
|
|
47
75
|
echo "[ERROR] build libcjtbridge.so failed" >&2
|
package/native/build_win.bat
CHANGED
|
@@ -1,61 +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
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
REM
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|