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.
Files changed (124) hide show
  1. package/README.md +3 -3
  2. package/cjpm.toml +52 -25
  3. package/cli/cjpm.toml +1 -1
  4. package/cli/src/doctor.cj +304 -0
  5. package/cli/src/main.cj +33 -7
  6. package/cli/src/project.cj +59 -1
  7. package/cli/src/resolve.cj +348 -304
  8. package/cli/src/scaffold.cj +139 -22
  9. package/cli/templates/ohos-pc/AppScope/app.json5 +13 -0
  10. package/cli/templates/ohos-pc/AppScope/resources/base/element/string.json +8 -0
  11. package/cli/templates/ohos-pc/AppScope/resources/base/media/background.png +0 -0
  12. package/cli/templates/ohos-pc/AppScope/resources/base/media/foreground.png +0 -0
  13. package/cli/templates/ohos-pc/AppScope/resources/base/media/layered_image.json +6 -0
  14. package/cli/templates/ohos-pc/README.md +79 -0
  15. package/cli/templates/ohos-pc/build-hap.sh +190 -0
  16. package/cli/templates/ohos-pc/build-profile.json5 +46 -0
  17. package/cli/templates/ohos-pc/entry/build-profile.json5 +26 -0
  18. package/cli/templates/ohos-pc/entry/cjpm.toml +43 -0
  19. package/cli/templates/ohos-pc/entry/hvigorfile.ts +6 -0
  20. package/cli/templates/ohos-pc/entry/oh-package.json5 +9 -0
  21. package/cli/templates/ohos-pc/entry/src/main/cangjie/ability_stage.cj +17 -0
  22. package/cli/templates/ohos-pc/entry/src/main/cangjie/app_host.cj +94 -0
  23. package/cli/templates/ohos-pc/entry/src/main/cangjie/index.cj +167 -0
  24. package/cli/templates/ohos-pc/entry/src/main/cangjie/main_ability.cj +139 -0
  25. package/cli/templates/ohos-pc/entry/src/main/module.json5 +49 -0
  26. package/cli/templates/ohos-pc/entry/src/main/resources/base/element/color.json +8 -0
  27. package/cli/templates/ohos-pc/entry/src/main/resources/base/element/string.json +16 -0
  28. package/cli/templates/ohos-pc/entry/src/main/resources/base/media/background.png +0 -0
  29. package/cli/templates/ohos-pc/entry/src/main/resources/base/media/foreground.png +0 -0
  30. package/cli/templates/ohos-pc/entry/src/main/resources/base/media/layered_image.json +6 -0
  31. package/cli/templates/ohos-pc/entry/src/main/resources/base/media/startIcon.png +0 -0
  32. package/cli/templates/ohos-pc/entry/src/main/resources/base/profile/main_pages.json +2 -0
  33. package/cli/templates/ohos-pc/entry/src/main/resources/rawfile/capabilities.json +6 -0
  34. package/cli/templates/ohos-pc/entry/src/main/resources/rawfile/index.html +92 -0
  35. package/cli/templates/ohos-pc/hvigor/hvigor-config.json5 +5 -0
  36. package/cli/templates/ohos-pc/hvigorfile.ts +6 -0
  37. package/cli/templates/ohos-pc/oh-package.json5 +10 -0
  38. package/native/build_linux.sh +30 -2
  39. package/native/build_win.bat +62 -61
  40. package/native/core/bridge_core.c +1626 -0
  41. package/native/{bridge_core.h → core/bridge_core.h} +246 -6
  42. package/native/platforms/harmonyos/README.md +106 -0
  43. package/native/platforms/linux/bridge_linux.c +2485 -0
  44. package/native/platforms/windows/bridge_win.c +3248 -0
  45. package/native/tests/test_bridge_core.c +528 -1
  46. package/package.json +12 -3
  47. package/prebuilt/win32-x64/cj-tauri.exe +0 -0
  48. package/src/api_system.cj +10 -2
  49. package/src/app.cj +248 -85
  50. package/src/arkweb_proxy.cj +56 -0
  51. package/src/arkweb_script.cj +154 -0
  52. package/src/capability.cj +140 -0
  53. package/src/clipboard_bridge.cj +55 -0
  54. package/src/dragdrop.cj +26 -0
  55. package/src/embedded_assets.cj +98 -0
  56. package/src/hexutil.cj +53 -0
  57. package/src/host.cj +197 -26
  58. package/src/host_arkweb.cj +740 -0
  59. package/src/host_factory.cj +48 -0
  60. package/src/host_webkit.cj +202 -26
  61. package/src/host_webview2.cj +176 -3
  62. package/src/hotkey.cj +66 -0
  63. package/src/ipc_hub.cj +49 -0
  64. package/src/ipc_message.cj +2 -1
  65. package/src/jsutil.cj +33 -0
  66. package/src/log_bridge.cj +107 -0
  67. package/src/logging.cj +127 -0
  68. package/src/menu.cj +197 -196
  69. package/src/plugin.cj +40 -0
  70. package/src/plugins/clipboard/plugin_clipboard.cj +144 -0
  71. package/src/{plugin_dialog.cj → plugins/dialog/plugin_dialog.cj} +74 -17
  72. package/src/plugins/fs/plugin_fs.cj +194 -0
  73. package/src/plugins/http/plugin_http.cj +459 -0
  74. package/src/plugins/log/plugin_log.cj +105 -0
  75. package/src/{plugin_menu.cj → plugins/menu/plugin_menu.cj} +4 -2
  76. package/src/plugins/mqtt/mqtt_codec.cj +661 -0
  77. package/src/plugins/mqtt/plugin_mqtt.cj +1446 -0
  78. package/src/plugins/notification/plugin_notification.cj +146 -0
  79. package/src/plugins/plugins.cj +5 -0
  80. package/src/plugins/redis/plugin_redis.cj +2409 -0
  81. package/src/plugins/redis/redis_codec.cj +556 -0
  82. package/src/{plugin_serial.cj → plugins/serial/plugin_serial.cj} +442 -489
  83. package/src/{serial_bridge.cj → plugins/serial/serial_bridge.cj} +185 -184
  84. package/src/{plugin_shell.cj → plugins/shell/plugin_shell.cj} +230 -228
  85. package/src/plugins/sqlite/plugin_sqlite.cj +697 -0
  86. package/src/plugins/sqlite/sqlite_ffi.cj +206 -0
  87. package/src/plugins/store/plugin_store.cj +287 -0
  88. package/src/plugins/ws/plugin_ws.cj +470 -0
  89. package/src/process_hidden.cj +174 -0
  90. package/src/scope.cj +391 -0
  91. package/src/shell_event.cj +69 -68
  92. package/src/tests/capability_test.cj +53 -0
  93. package/src/tests/fake_host.cj +85 -20
  94. package/src/tests/ipc_hub_test.cj +13 -0
  95. package/src/tests/jsutil_test.cj +62 -0
  96. package/src/tests/logging_test.cj +62 -0
  97. package/src/tests/mqtt_codec_test.cj +405 -0
  98. package/src/tests/plugin_clipboard_test.cj +222 -0
  99. package/src/tests/plugin_dialog_test.cj +98 -4
  100. package/src/tests/plugin_http_test.cj +124 -0
  101. package/src/tests/plugin_menu_test.cj +1 -0
  102. package/src/tests/plugin_notification_test.cj +205 -0
  103. package/src/tests/plugin_serial_test.cj +269 -267
  104. package/src/tests/plugin_shell_test.cj +189 -188
  105. package/src/tests/plugin_sqlite_test.cj +230 -0
  106. package/src/tests/plugin_store_test.cj +260 -0
  107. package/src/tests/plugin_test.cj +542 -524
  108. package/src/tests/plugin_ws_test.cj +40 -0
  109. package/src/tests/process_hidden_test.cj +129 -0
  110. package/src/tests/redis_codec_test.cj +396 -0
  111. package/src/tests/scope_test.cj +350 -0
  112. package/src/tests/shell_event_test.cj +0 -1
  113. package/src/tests/system_host_test.cj +81 -79
  114. package/src/tests/urlutil_test.cj +53 -0
  115. package/src/tests/version_test.cj +75 -65
  116. package/src/tray.cj +90 -0
  117. package/src/urlutil.cj +159 -0
  118. package/src/version.cj +23 -2
  119. package/src/window.cj +51 -42
  120. package/native/bridge_core.c +0 -797
  121. package/native/bridge_linux.c +0 -1268
  122. package/native/bridge_win.c +0 -1633
  123. package/src/plugin_fs.cj +0 -118
  124. /package/native/{bridge_js.h → core/bridge_js.h} +0 -0
@@ -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
- "$CC" -shared -fPIC -O2 -fstack-protector-all bridge_core.c bridge_linux.c \
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
@@ -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
- gcc -shared -O2 -fstack-protector-all bridge_core.c bridge_win.c -o libcjtbridge.dll ^
41
- -Wl,--out-implib,libcjtbridge.dll.a ^
42
- -I"%WEBVIEW2_SDK_INCLUDE%" ^
43
- -lole32 -loleaut32 -luuid -luser32 -lgdi32 -ladvapi32 -lcomdlg32
44
-
45
- if errorlevel 1 (
46
- echo [ERROR] build libcjtbridge.dll failed
47
- exit /b 1
48
- )
49
-
50
- REM Sync the x64 loader matching the headers, so the WebView never puts an
51
- REM SDK newer than the installed runtime on the wire.
52
- if not exist webview2 mkdir webview2
53
- copy /y "%WEBVIEW2_SDK_ROOT%\build\native\x64\WebView2Loader.dll" webview2\ >nul
54
- if errorlevel 1 (
55
- echo [WARN] WebView2Loader.dll copy failed, check %WEBVIEW2_SDK_ROOT%\build\native\x64
56
- ) else (
57
- echo [OK] WebView2Loader.dll synced
58
- )
59
-
60
- echo [OK] libcjtbridge.dll built
61
- 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