bao_engine 0.1.0

SpiderMonkey engine wrapper for Bao runtime
docs.rs failed to build bao_engine-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

SpiderMonkey engine wrapper. Core types are provided by bun_sm; this crate retains only the modules that have complex inter-dependencies (context, job_queue).

Re-export Architecture

Layer order (bottom → top):
  bun_sm        — 底层:SpiderMonkey 值类型 + JSC API 兼容层 + module_loader
                   JSValue, JSGlobalObject, VirtualMachine, CallFrame, JSType, ModuleLoader
  bao_engine    — Re-export 层:从 bun_sm re-export 公共类型,保留自有模块
                   context, job_queue (复杂内部依赖)
  bao_runtime   — 消费层:pub use bao_engine::* (最终替换 bun_jsc::*)
  bao_browser   — 消费层:依赖 bao_engine 的 context + dispatch_sm

迁移步骤 (bun_jsc → bun_sm)

  1. Phase 1 (已完成): bao_engine 依赖 bun_sm,re-export 核心类型
  2. Phase 2 (进行中): bao_runtime 将 pub use bun_jsc::* 改为 pub use bun_sm::*
  3. Phase 3 (计划中): 移除 bun_jsc 依赖,所有 8,500+ JSC 引用指向 bun_sm

约定

  • 下游 crate 必须通过 bao_engine::Type 访问类型,禁止直接 use bun_sm::Type

    • 唯一例外:crate 确实需要 bun_sm 中未被 bao_engine re-export 的类型
    • 目的:维护单一依赖表面,避免下游 crate 同时依赖 bao_engine 和 bun_sm
  • 新代码直接使用 bun_sm::JSValue 等类型

  • bao_engine 仅 re-export,不定义值类型

  • 保留在 bao_engine 的模块(context/job_queue)因内部依赖复杂不迁移

  • module_loader 已迁移到 bun_sm,通过回调模式(JobQueueDrainFn)避免循环依赖

迁移模块到 bun_sm 的步骤

  1. 复制 .rs 文件到 bun_sm/src/
  2. 更新 use crate:: 引用为 bun_sm 自身路径
  3. bao_engine/src/ 删除原文件
  4. 在下方 Re-exports 区域添加 pub use bun_sm::xxx;
  5. 验证:cargo check -p bao_engine 通过