Skip to main content

lemon_js 0.4.0 copy "lemon_js: ^0.4.0" to clipboard
lemon_js: ^0.4.0 copied to clipboard

QuickJS JavaScript engine for Flutter — cross-platform FFI and WebAssembly.

更新日志 / Changelog #

0.4.0 #

  • 执行模式变化: 原生 Future API 默认在后台 worker 执行;同步 API 在调用方当前线程执行,两种入口共享同一个 JS 堆和 Context 状态。需要 Future API 也在当前 isolate 执行时,设置 JsOptions(execution: JsExecution.currentIsolate)。
  • 同步调用保留 Dart 宿主回调的同步返回语义,Future 转为 Promise;后台调用通过异步宿主桥接。原生访问通过互斥门串行化并切换当前执行线程的回调路由;后台正在推进 JS 时,同步调用明确报忙,避免并发进入引擎。
  • 修复后台消费 WebSocket 事件时关闭通知被过早释放的竞态;关闭事件被读取后才移除连接,保留消息与关闭通知的顺序。
  • 异步 Promise 等待使用明确的轮询时间间隔,避免零延迟定时器在 Flutter 测试时钟中持续占用同一时刻,阻止导航及事件推进。
  • JsEngine / JsContext 新增 supportsSync、evalSync、evalRawSync、callSync;JsFunctionHandle 新增 callSync / callRawSync。同步入口遇到 Promise 会报值转换错误,不会隐式等待。
  • 新增 callBatch / callBatchSync,同一全局函数的一批调用只经过一次桥接,按顺序执行,首次失败停止后续项,已完成的副作用不回滚。
  • 调用优化: 原生函数与插件调用直接进入 runtime 预装的调用执行器;结构化 eval 及临时 globals 的包装层不再逐次生成和编译。用户源码仍逐次编译执行,不缓存字节码或结果;保留队列、超时、取消及 Context 隔离语义。优化范围与历史 Release 数据见 调用基准。
  • Web 复用调用执行器,但不提供原生同步 FFI 能力。同步 API 与执行位置迁移说明见 执行方式与同步调用。
  • 原生 QuickJS-NG 升级至 v0.17.0;Web 升级至 quickjs-wasi 3.6.3,内置引擎同为 v0.17.0。
  • Web 接通 stackLimitBytes(最大 512 KiB);流结束、取消及 Sink 关闭时释放宿主回调,模块执行返回值与原生端保持一致。
  • 修复 Web 超时终止共享 Worker 后的恢复,重建启动脚本和宿主方法,避免旧 runtime ID 误用;保留结构化异常及流错误消息。
  • Node createHash 同步支持 MD5、SHA-1、SHA-256;Buffer 支持 UTF-8、hex、Base64 双向转换,修正 emoji 与二进制视图输入。同步哈希由 JS 实现,耗时计算应放在 worker isolate。
  • 修正 Web 资源更新脚本的包目录;补充同步运行时、Web 桥接、超时恢复、内存与栈限制回归测试。

0.3.1 #

  • 统一各插件包的发布版本为 0.3.1。
  • shared_preferences 使用 pub.dev 的 ^2.5.6,移除 Git 版本覆盖;KV 存储继续使用无本地缓存的 SharedPreferencesAsync。

0.3.0 #

中文 #

  • 新增实验性 OpenHarmony FFI 适配,包括 OHOS 插件声明、libquickjs.so 动态加载和 HarmonyOS 交叉编译所需的 CMake 配置。
  • 新增 OHOS example 宿主工程,以及分别构建 ARM64 真机和 x64 模拟器 HAP、校验 QuickJS FFI 导出符号的手动 CI 工作流。
  • 补充 CPF Flutter 与 HarmonyOS SDK 的环境配置、构建方式和支持边界,记录 API 24 自动填充编译冲突、第三方插件 ABI 及 x64 视频 Surface 等已知兼容问题。

English #

  • Added experimental OpenHarmony FFI integration, including the OHOS plugin declaration, libquickjs.so loading, and CMake handling required by the HarmonyOS cross toolchain.
  • Added an OHOS example host and a manually triggered CI workflow that builds ARM64 device and x64 emulator HAPs and verifies the exported QuickJS FFI symbol.
  • Documented the CPF Flutter and HarmonyOS SDK setup, build steps, and support boundaries, including known API 24 autofill compilation, third-party ABI, and x64 video Surface compatibility issues.

0.2.1 #

中文 #

  • iOS 和 macOS 改为共享的 Swift Package Manager 集成,并修复 Apple 平台 Release 构建中 QuickJS FFI 符号未链接的问题。
  • 增加 Android、iOS、Linux、macOS、Web 和 Windows 的示例构建与启动验证,覆盖应用 首帧、进程存活及启动诊断。
  • 新增宿主平台配置文档,说明 Apple、Android、Linux、Windows 和 Web 引用插件时所需的 构建依赖与工程设置。

English #

  • Migrated iOS and macOS to a shared Swift Package Manager integration and fixed missing QuickJS FFI symbols in Apple release builds.
  • Added example build and launch validation for Android, iOS, Linux, macOS, Web, and Windows, covering first-frame rendering, process liveness, and startup diagnostics.
  • Added host-platform setup documentation for the build dependencies and project configuration required when integrating the plugin on Apple, Android, Linux, Windows, and Web.

0.2.0 #

中文 #

  • 破坏性更新: 本次重构系统性调整了公开 API、类型名、参数名和导入入口,且不提供 旧名称兼容别名。升级前必须按照 破坏性 API 迁移指南 修改调用代码。
  • 主入口改为 JsEngine;多 Context 的 JsRuntime / JsContext 移至 package:lemon_js/lemon_js_context.dart。
  • 执行 API 统一为 eval/evalRaw、run/runRaw、runModule、runCommonJs 和 call/callRaw/callModule。
  • Dart → JavaScript 统一使用 inject*,JavaScript → Dart 统一使用 bind*;删除 JsFunctionHandle.cancel()。
  • 原 Mount/Capabilities 模型统一为 JsFeatures、features 和 loadFeatures();内置能力 统一使用 *Features 类型。
  • 插件、脚本、模块、资源路径、队列限制及 KV Store 的公开名称已统一;其中 KV 实现改为 JsMemoryKvStore 和 JsSharedPreferencesKvStore。
  • 平台插件壳统一为 LemonJsPlugin / lemon_js_plugin,Android namespace 改为 xyz.yhsj.lemon_js。
  • 修复 WebSocket host script 调用错误事件方法导致连接 Promise 永久等待的问题。
  • 增加 pub 包内的最小可运行示例,覆盖 Engine 创建、结构化求值和资源释放。

English #

  • Breaking update: This refactor systematically changes public APIs, type names, parameter names, and import entry points. No compatibility aliases are provided. Update consumers using the breaking API migration guide before upgrading.
  • Replaced the primary entry point with JsEngine; the multi-context JsRuntime / JsContext API now lives in package:lemon_js/lemon_js_context.dart.
  • Standardized execution on eval/evalRaw, run/runRaw, runModule, runCommonJs, and call/callRaw/callModule.
  • Standardized Dart-to-JavaScript interop on inject* and JavaScript-to-Dart interop on bind*, and removed JsFunctionHandle.cancel().
  • Replaced the Mount/Capabilities model with JsFeatures, features, and loadFeatures(); built-in capabilities now use *Features types.
  • Standardized plugin, script, module, resource-path, queue-limit, and KV Store names, including JsMemoryKvStore and JsSharedPreferencesKvStore.
  • Renamed platform plugin shells to LemonJsPlugin / lemon_js_plugin and changed the Android namespace to xyz.yhsj.lemon_js.
  • Fixed a WebSocket host-script event dispatch error that left connection promises pending indefinitely.
  • Added a minimal runnable Pub example covering engine creation, structured evaluation, and disposal.

0.1.1 #

中文 #

  • 新增通用命名空间 KV 接口、SharedPreferencesAsync 默认实现和 lemon_js/storage 挂载。
  • 新增可复用 JsHttpSession,供 Fetch、XHR 和 Axios 共享连接与网络配置。
  • 新增调用队列上限和稳定的 JsException.kind 框架错误分类。
  • 为 Dart/JS 双向值转换统一增加深度和容器数量预算,避免异常值图耗尽 Runtime 栈。
  • 重写 README,补充安装、基础执行、Dart/JS 互调、模块、宿主能力和插件最小示例,并修正 GitHub 文档链接。

English #

  • Added a general namespaced KV interface, a default SharedPreferencesAsync implementation, and the lemon_js/storage mount.
  • Added reusable JsHttpSession support for sharing connections and network configuration across Fetch, XHR, and Axios.
  • Added bounded call queues and stable framework error categories through JsException.kind.
  • Added shared depth and container-count budgets for Dart/JS value conversion to prevent malformed value graphs from exhausting the runtime stack.
  • Reworked the README with installation, evaluation, Dart/JS interop, modules, host capabilities, and plugin examples, and corrected GitHub documentation links.

0.1.0 #

中文 #

  • 提供 Flutter 原生平台上的 QuickJS FFI 运行时。
  • 提供 Flutter Web 的 WASM/Web Worker 运行时。
  • 支持 JavaScript 求值、异步任务、Promise、Timer、模块加载和结构化值转换。
  • 支持 Dart 函数、对象、类、Stream、插件和宿主能力挂载。

English #

  • Added the QuickJS FFI runtime for native Flutter platforms.
  • Added the WASM/Web Worker runtime for Flutter Web.
  • Added JavaScript evaluation, asynchronous jobs, Promises, timers, module loading, and structured value conversion.
  • Added Dart function, object, class, stream, plugin, and host capability bindings.
0
likes
150
points
470
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

QuickJS JavaScript engine for Flutter — cross-platform FFI and WebAssembly.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

archive, crypto, ffi, flutter, flutter_web_plugins, http, shared_preferences, web

More

Packages that depend on lemon_js

Packages that implement lemon_js