Files
cutdex/packages/cutdex_native
T
lingjhf 0343e2f723 refactor(build): unify SDK configuration and release tooling
Pin Flutter with FVM and share local environment loading across IDE, Python, and Dart entrypoints. Keep CI on the verified preinstalled SDK and skip local overrides.

Extract common build presets, process execution, and file hashing. Propagate project roots through SDK selection and release commands, and migrate macOS release, signing, and DMG orchestration to Python.

Reuse local check suites in CI, support Android source overrides, and update documentation and regression tests.
0343e2f723 · 2026-10-06 23:34:15 +08:00
History
..
2026-10-05 23:36:23 +08:00
2026-10-05 23:36:23 +08:00
2026-10-05 23:36:23 +08:00
2026-10-05 23:36:23 +08:00
2026-10-05 23:36:23 +08:00
2026-10-05 23:36:23 +08:00
2026-10-05 23:36:23 +08:00
2026-10-05 23:36:23 +08:00
2026-10-05 23:36:23 +08:00
2026-10-05 23:36:23 +08:00

cutdex_native

Cutdex workspace 内部 Flutter 原生插件,暂不发布。

能力 macOS Windows
窗口标题栏、拖动区域与关闭请求拦截 支持 支持
本地文件拖放区域 支持 支持
原生上下文菜单 支持 由 UI 包回退为 Flutter 菜单
原生窗口全屏会话 支持 未提供

Android、iOS 注册设备信息查询;窗口、拖放、菜单与全屏能力仍由对应桌面平台提供。

设备信息

NativeDeviceInfo.read() 在 Android 返回最大显示区域的最短边(逻辑像素),在 iOS 返回 NativeInterfaceIdiom。无法查询时返回 null。插件不使用当前应用窗口大小,也不决定手机、平板或桌面布局;分类阈值、回退规则与状态装配由应用维护。

窗口

Dart 使用 WindowChromeSession、HeaderControlRegion 与 WindowHeaderLayout。关闭请求通过回调交给应用处理,插件不决定项目保存、路由、退出行为或应用最小窗口尺寸。坐标上报统一使用 NativeBoundsReporter,按绘制变换计算窗口逻辑坐标中的外接矩形。

macOS 宿主窗口继承 CutdexNativeWindow,导入 cutdex_native 后按 Flutter 常规流程注册插件。该窗口类负责 AppKit 响应链与标题栏手势,宿主只负责创建 Flutter 控制器和应用生命周期接线。Windows 由插件注册自动接入。

文件拖放

NativeFileDropRegion 接收稳定的 regionId、NativeDropConfiguration、启用状态与回调,回调中的文件是原始路径列表。扩展名白名单与数量上限由调用方提供。

两端均拒绝目录和不存在的文件,并在落下时重新检查文件引用。

NativeDropConfiguration 拷贝并规范化白名单,按值比较;输入列表的后续修改不会改变规则。无约束配置使用 NativeDropConfiguration.unrestricted。标题栏命中区域与拖放区域随 TickerMode 停用和恢复;隐藏页面拒绝迟到的拖放事件。

需要拖动位置和自定义异步准备流程时,使用 NativeFileDropConnection。其事件包含阶段、会话编号、区域内坐标和路径;调用方在文件使用完成后调用 release。macOS 的安全作用域权限持续到释放,销毁区域不会提前释放正在处理的拖放会话。

同一 regionId 的替换连接取得事件所有权,旧连接不能清除新区域或修改其选项。连接销毁后不能再次绑定,但仍可释放未完成文件操作的权限。区域标识用于重复使用同一目的地,不应每帧生成新标识。macOS 拖动源图像是否隐藏由 hidesSourceImage 控制。

插件不导入媒体,不识别项目、时间线或聊天,也不创建临时素材副本。

菜单与全屏

NativeContextMenu.show 接收 NativeMenuEntry 和位置,返回选中的操作编号;应用或 UI 包负责执行操作。NativeFullscreenSession 接收退出回调,按顺序处理窗口全屏请求。使用 dispose(exitFullscreen: true) 在未被替换时恢复窗口;恢复会等待正在进行的转换完成。预览内容和布局由应用管理。

在应用根目录执行 fvm dart tool/flutter_local.dart pub get;在本包目录执行 python3 ../../tool/project_tools.py flutter test。真实窗口与系统拖放还需在对应桌面平台验证。

原生回归

以下命令在应用根目录执行,先退出占用同一构建目录的应用。

macOS 标题栏手势使用真实 AppKit 响应链,文件引用策略使用临时文件与目录:

python3 tool/build.py macos --mode debug --flavor development
bash packages/cutdex_native/tool/macos/test_header_control_gestures.sh
bash packages/cutdex_native/tool/macos/test_file_drop_policy.sh

Windows 标题栏回归验证真实 HWND、命中区域、最大化、DPI 与标题栏恢复;先准备 Flutter C++ wrapper:

python tool/build.py windows --mode debug --flavor development
cmake -S packages/cutdex_native/tool/windows/window_chrome_tests -B build/window_chrome_tests -A x64
cmake --build build/window_chrome_tests --config Release
ctest --test-dir build/window_chrome_tests -C Release --output-on-failure

原生回归不替代 Finder/Explorer 的真实文件拖放验收。