v8

MoonBit bindings for V8 aimed at prototyping MoonBit-first runtimes in the style of Node or Deno.

moonbit
v8
javascript
runtime
moon add mizchi/v8@0.2.0
Download zip
Author
Version
0.2.0
License
Apache-2.0
Last updated
4 months ago
Downloads
12K

Dependencies

README

#mizchi/v8

mizchi/v8 is a native-only V8 binding for MoonBit. It is intended as a foundation for prototyping embedded runtimes in the style of Node or Deno.

Experimental release note: on Moon 0.1.20260309 / MoonBit v0.8.3, this package still requires consumer-side prebuild and link setup.

#What You Can Do

  • evaluate scripts and modules from MoonBit
  • exchange JS values as String, JSON, or Bytes
  • keep pending promises and top-level await modules as host-side handles
  • work with preloaded modules, relative imports, and dynamic imports
  • build snapshots and runtime images for reusable isolate startup
  • experiment with host-side event loops through MoonBit.opSync(...) and MoonBit.opAsync(...)
  • drive Deno-style opAsync and top-level await through MoonBit's async event loop
  • preload an opt-in Deno shim with Deno.core.op*, utility helpers, and minimal Deno.inspect / cwd / execPath
  • preload an opt-in Node-style shim with global, process.nextTick, and a minimal Buffer
  • keep oden/ as a sibling module when you want to prototype a separate runtime/CLI on top of mizchi/v8

#Status

  • version: 0.2.0
  • target: native
  • usable as an embedder-facing experimental binding
  • implementation status and known gaps are tracked in docs/development-log.md

#Install From mooncakes

moon add mizchi/v8 node .mooncakes/mizchi/v8/src/scripts/setup-consumer.mjs --main-pkg cmd/main/moon.pkg moon check --target native

With Moon 0.1.20260309 / MoonBit v0.8.3, dependency-side native hooks are not applied to consumers automatically. The bundled setup helper patches the consumer module for the common case:

  • copies scripts/mizchi-v8-consumer-prebuild.mjs
  • adds --moonbit-unstable-prebuild to moon.mod.json
  • adds ${build.MIZCHI_V8_CC_LINK_FLAGS} and "supported-targets": "native" to the specified main package

If your main package lives somewhere else, pass it explicitly:

node .mooncakes/mizchi/v8/src/scripts/setup-consumer.mjs --main-pkg app/server/moon.pkg

If you use a local path dependency and the install hook does not run, the same helper can also build the native bridge in that checkout:

node ../v8.mbt/src/scripts/setup-consumer.mjs --module-root . --main-pkg cmd/main/moon.pkg --build-bridge

#Prerequisites

  • git
  • bash
  • Rust toolchain with cargo
  • a native C/C++ toolchain
  • node for the bundled consumer setup / prebuild scripts
  • network access to GitHub, crates.io, and the rusty_v8 release mirror

The published package also uses a postadd hook to eagerly build the native bridge in the installed module cache. The one-time consumer module setup is still required today, but the setup script above automates the common mooncakes workflow.

#Develop From Source

git clone https://github.com/mizchi/v8.mbt cd v8.mbt just bootstrap just test

just bootstrap builds deps/rusty_v8 and the Rust bridge in the current checkout. End users installing from mooncakes do not need to run it manually.

#Minimal Example

For one-shot evaluation, the top-level helpers are enough.

match @v8.eval_string("'Hello' + ', MoonBit!'") {
Ok(value) => println(value)
Err(err) => println(err.to_string())
}

For a longer-lived runtime, RuntimeBuilder can combine snapshot initialization and module preload.

let builder = @v8.runtime_builder_new()
.eval_snapshot("globalThis.base = 40;")
.load_module("dep", "export const answer = globalThis.base + 2;")

match builder.with_runtime(fn(runtime) {
runtime.eval_async_json(
"(async () => { let mod = await import('dep'); return { answer: mod.answer } })()",
)
}) {
Ok(value) => println(value)
Err(err) => println(err.to_string())
}

For host-driven event loop experiments, async ops can be handled as a queue.

match @v8.runtime_new() {
Ok(runtime) => {
ignore(runtime.register_async_json_op("add"))
let promise = runtime.eval_promise_string("MoonBit.opAsync('add', [20, 22])")
match runtime.take_async_json_op() {
Ok(Some(op)) => ignore(runtime.resolve_async_json_op(op.id, "{\"answer\":42}"))
_ => ()
}
println(
promise
|> Result::map(fn(handle) { handle.await_json() })
|> Result::flatten,
)
runtime.dispose()
}
Err(err) => println(err.to_string())
}

#Main APIs

  • evaluation: Runtime, eval_*, eval_module_*, perform_microtask_checkpoint
  • async handles: PromiseHandle, ModuleEvalHandle, ModuleHandle
  • bootstrap: Runtime::load_module, RuntimeBuilder, SnapshotBuilder, RuntimeImage
  • value bridge: set/get/call_global_json, set/get/call_global_bytes, eval_json, eval_bytes
  • host bridge: register_*_callback, register_*_result_callback, register_*_result_callback_with_json_error, register_*_op, take_*_op, resolve_*_op, reject_*_op, reject_async_*_op_with_json
  • resource table: add_resource, add_resource_with_close, ref_resource, unref_resource, list_resources, close_resource, try_close_resource
  • direct async callback: register_async_json_callback, register_async_bytes_callback, register_async_*_result_callback
  • async event loop bridge: with_runtime_async, register_async_*_task_*, eval_promise_*_async, PromiseHandle::await_*_async, ModuleEvalHandle::await_ready_async, Runtime::eval_module_handle_string_async
  • deno compat: Runtime::install_deno_core_compat, RuntimeBuilder::with_deno_core_compat, SnapshotBuilder::with_deno_core_compat, Deno.sleep, minimal setTimeout / clearTimeout / setInterval / clearInterval, Deno.core.refOpPromise / unrefOpPromise
  • minimal node shim: Runtime::install_node_compat, RuntimeBuilder::with_node_compat, SnapshotBuilder::with_node_compat
  • Failure reasons can be returned as JSON values in addition to plain strings.

For the complete public surface and more examples, see src/README.mbt.md.

#Limitations

  • native target only
  • this project primarily targets low-level embedder bindings; Deno compatibility is currently limited to an opt-in Deno.core op/util shim plus a few top-level Deno helpers, and Node compatibility to a minimal global / process / Buffer shim
  • the MoonBit async event-loop driver allows only one active loop per runtime and assumes you do not mix it with manual take_async_*_op handling on the same lane
  • Deno.sleep and the minimal setTimeout / clearTimeout / setInterval / clearInterval shim are built on queue-based async ops and also occupy runtime resource entries; Deno.core.refOpPromise / unrefOpPromise update that ref state
  • oden/ is now split out as a sibling MoonBit module with its own moon.mod.json, so you can keep runtime/CLI experiments separate while still depending on this package by local path; that module currently carries the MoonBit-first oden router for run / check / test / bundle / fmt / info / task / plan
  • mooncakes consumers still need a one-time setup step today
  • local path dependencies do not run install hooks automatically, but setup-consumer.mjs --build-bridge can cover the same bootstrap step

#Documentation

#License

Apache-2.0

#mizchi/v8

MoonBit から V8 を扱うためのネイティブバインディングです。

#Package

  • mizchi/v8

#Public Surface

  • version() -> String
  • module_source(String, String) -> ModuleSource
  • runtime_image_new(Bytes) -> RuntimeImage
  • snapshot_builder_new() -> SnapshotBuilder
  • snapshot_create(String) -> Result[Bytes, V8Error]
  • snapshot_extend(Bytes, String) -> Result[Bytes, V8Error]
  • runtime_new() -> Result[Runtime, V8Error]
  • runtime_new_with_snapshot(Bytes) -> Result[Runtime, V8Error]
  • runtime_builder_new() -> RuntimeBuilder
  • with_runtime_async(async (Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]
  • with_runtime_with_snapshot(Bytes, (Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]
  • with_runtime_with_snapshot_async(Bytes, async (Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]
  • PromiseState
  • PromiseHandle
  • ModuleEvalHandle
  • ModuleHandle
  • RuntimeResource
  • AsyncJsonOpRequest
  • SyncJsonOpRequest
  • SyncBytesOpRequest
  • AsyncBytesOpRequest
  • Runtime::load_module(String, String) -> Result[Unit, V8Error]
  • Runtime::load_modules(Array[ModuleSource]) -> Result[Unit, V8Error]
  • Runtime::register_sync_json_op(String) -> Result[Unit, V8Error]
  • Runtime::register_sync_json_callback(String, (String) -> String) -> Result[Unit, V8Error]
  • Runtime::register_sync_json_result_callback(String, (String) -> Result[String, String]) -> Result[Unit, V8Error]
  • Runtime::register_sync_json_result_callback_with_json_error(String, (String) -> Result[String, String]) -> Result[Unit, V8Error]
  • Runtime::push_sync_json_op_response(String, String, String) -> Result[Unit, V8Error]
  • Runtime::take_sync_json_op() -> Result[SyncJsonOpRequest?, V8Error]
  • Runtime::register_sync_bytes_op(String) -> Result[Unit, V8Error]
  • Runtime::register_sync_bytes_callback(String, (Bytes) -> Bytes) -> Result[Unit, V8Error]
  • Runtime::register_sync_bytes_result_callback(String, (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]
  • Runtime::register_sync_bytes_result_callback_with_json_error(String, (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]
  • Runtime::push_sync_bytes_op_response(String, Bytes, Bytes) -> Result[Unit, V8Error]
  • Runtime::take_sync_bytes_op() -> Result[SyncBytesOpRequest?, V8Error]
  • Runtime::register_async_json_op(String) -> Result[Unit, V8Error]
  • Runtime::register_async_json_callback(String, (String) -> String) -> Result[Unit, V8Error]
  • Runtime::register_async_json_result_callback(String, (String) -> Result[String, String]) -> Result[Unit, V8Error]
  • Runtime::register_async_json_result_callback_with_json_error(String, (String) -> Result[String, String]) -> Result[Unit, V8Error]
  • Runtime::register_async_json_task_callback(String, async (String) -> String) -> Result[Unit, V8Error]
  • Runtime::register_async_json_task_result_callback(String, async (String) -> Result[String, String]) -> Result[Unit, V8Error]
  • Runtime::register_async_json_task_result_callback_with_json_error(String, async (String) -> Result[String, String]) -> Result[Unit, V8Error]
  • Runtime::take_async_json_op() -> Result[AsyncJsonOpRequest?, V8Error]
  • Runtime::resolve_async_json_op(UInt64, String) -> Result[Unit, V8Error]
  • Runtime::reject_async_json_op(UInt64, String) -> Result[Unit, V8Error]
  • Runtime::reject_async_json_op_with_json(UInt64, String) -> Result[Unit, V8Error]
  • Runtime::register_async_bytes_op(String) -> Result[Unit, V8Error]
  • Runtime::register_async_bytes_callback(String, (Bytes) -> Bytes) -> Result[Unit, V8Error]
  • Runtime::register_async_bytes_result_callback(String, (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]
  • Runtime::register_async_bytes_result_callback_with_json_error(String, (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]
  • Runtime::register_async_bytes_task_callback(String, async (Bytes) -> Bytes) -> Result[Unit, V8Error]
  • Runtime::register_async_bytes_task_result_callback(String, async (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]
  • Runtime::register_async_bytes_task_result_callback_with_json_error(String, async (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]
  • Runtime::take_async_bytes_op() -> Result[AsyncBytesOpRequest?, V8Error]
  • Runtime::resolve_async_bytes_op(UInt64, Bytes) -> Result[Unit, V8Error]
  • Runtime::reject_async_bytes_op(UInt64, String) -> Result[Unit, V8Error]
  • Runtime::reject_async_bytes_op_with_json(UInt64, String) -> Result[Unit, V8Error]
  • Runtime::set_global_json(String, String) -> Result[Unit, V8Error]
  • Runtime::get_global_json(String) -> Result[String, V8Error]
  • Runtime::call_global_json(String, String) -> Result[String, V8Error]
  • Runtime::set_global_bytes(String, Bytes) -> Result[Unit, V8Error]
  • Runtime::get_global_bytes(String) -> Result[Bytes, V8Error]
  • Runtime::call_global_bytes(String, Bytes) -> Result[Bytes, V8Error]
  • Runtime::add_resource(String) -> Result[Int, V8Error]
  • Runtime::add_resource_with_close(String, () -> Unit) -> Result[Int, V8Error]
  • Runtime::ref_resource(Int) -> Result[Bool, V8Error]
  • Runtime::unref_resource(Int) -> Result[Bool, V8Error]
  • Runtime::get_resource_name(Int) -> Result[String?, V8Error]
  • Runtime::list_resources() -> Result[Array[RuntimeResource], V8Error]
  • Runtime::close_resource(Int) -> Result[Unit, V8Error]
  • Runtime::try_close_resource(Int) -> Result[Bool, V8Error]
  • Runtime::eval_json(String) -> Result[String, V8Error]
  • Runtime::eval_json_with_name(String, String) -> Result[String, V8Error]
  • Runtime::eval_async_json(String) -> Result[String, V8Error]
  • Runtime::eval_async_json_with_name(String, String) -> Result[String, V8Error]
  • Runtime::eval_bytes(String) -> Result[Bytes, V8Error]
  • Runtime::eval_bytes_with_name(String, String) -> Result[Bytes, V8Error]
  • Runtime::eval_async_bytes(String) -> Result[Bytes, V8Error]
  • Runtime::eval_async_bytes_with_name(String, String) -> Result[Bytes, V8Error]
  • Runtime::eval_string(String) -> Result[String, V8Error]
  • Runtime::eval_string_with_name(String, String) -> Result[String, V8Error]
  • Runtime::eval_async_string(String) -> Result[String, V8Error]
  • Runtime::eval_async_string_with_name(String, String) -> Result[String, V8Error]
  • Runtime::eval_promise_string(String) -> Result[PromiseHandle, V8Error]
  • Runtime::eval_promise_string_with_name(String, String) -> Result[PromiseHandle, V8Error]
  • Runtime::eval_promise_string_async(String) -> Result[String, V8Error]
  • Runtime::eval_promise_string_async_with_name(String, String) -> Result[String, V8Error]
  • Runtime::eval_promise_json_async(String) -> Result[String, V8Error]
  • Runtime::eval_promise_json_async_with_name(String, String) -> Result[String, V8Error]
  • Runtime::eval_promise_bytes_async(String) -> Result[Bytes, V8Error]
  • Runtime::eval_promise_bytes_async_with_name(String, String) -> Result[Bytes, V8Error]
  • Runtime::eval_module_handle_async_string(String) -> Result[ModuleEvalHandle, V8Error]
  • Runtime::eval_module_handle_async_string_with_specifier(String, String) -> Result[ModuleEvalHandle, V8Error]
  • Runtime::eval_module_handle_string_async(String) -> Result[ModuleHandle, V8Error]
  • Runtime::eval_module_handle_string_async_with_specifier(String, String) -> Result[ModuleHandle, V8Error]
  • Runtime::eval_module_handle_string(String) -> Result[ModuleHandle, V8Error]
  • Runtime::eval_module_handle_string_with_specifier(String, String) -> Result[ModuleHandle, V8Error]
  • Runtime::eval_module_string(String) -> Result[String, V8Error]
  • Runtime::eval_module_string_with_specifier(String, String) -> Result[String, V8Error]
  • Runtime::install_deno_core_compat() -> Result[Unit, V8Error]
  • Runtime::install_node_compat() -> Result[Unit, V8Error]
  • Runtime::perform_microtask_checkpoint() -> Result[Unit, V8Error]
  • Runtime::dispose() -> Unit
  • PromiseHandle::state() -> Result[PromiseState, V8Error]
  • PromiseHandle::result_string() -> Result[String, V8Error]
  • PromiseHandle::result_json() -> Result[String, V8Error]
  • PromiseHandle::result_bytes() -> Result[Bytes, V8Error]
  • PromiseHandle::await_string() -> Result[String, V8Error]
  • PromiseHandle::await_string_async() -> Result[String, V8Error]
  • PromiseHandle::await_json() -> Result[String, V8Error]
  • PromiseHandle::await_json_async() -> Result[String, V8Error]
  • PromiseHandle::await_bytes() -> Result[Bytes, V8Error]
  • PromiseHandle::await_bytes_async() -> Result[Bytes, V8Error]
  • eval_promise_string_async(String) -> Result[String, V8Error]
  • eval_promise_string_async_with_name(String, String) -> Result[String, V8Error]
  • eval_promise_json_async(String) -> Result[String, V8Error]
  • eval_promise_json_async_with_name(String, String) -> Result[String, V8Error]
  • eval_promise_bytes_async(String) -> Result[Bytes, V8Error]
  • eval_promise_bytes_async_with_name(String, String) -> Result[Bytes, V8Error]
  • PromiseHandle::dispose() -> Unit
  • PromiseHandle::is_closed() -> Bool
  • SyncJsonOpRequest { id : UInt64, name : String, payload_json : String }
  • SyncBytesOpRequest { id : UInt64, name : String, payload : Bytes }
  • AsyncJsonOpRequest { id : UInt64, name : String, payload_json : String }
  • AsyncBytesOpRequest { id : UInt64, name : String, payload : Bytes }
  • RuntimeResource { rid : Int, name : String, is_ref : Bool }
  • ModuleEvalHandle::module_handle() -> ModuleHandle
  • ModuleEvalHandle::promise_handle() -> PromiseHandle?
  • ModuleEvalHandle::await_ready() -> Result[ModuleHandle, V8Error]
  • ModuleEvalHandle::await_ready_async() -> Result[ModuleHandle, V8Error]
  • ModuleEvalHandle::dispose() -> Unit
  • ModuleEvalHandle::is_closed() -> Bool
  • ModuleHandle::get_export_json(String) -> Result[String, V8Error]
  • ModuleHandle::export_names() -> Result[Array[String], V8Error]
  • ModuleHandle::get_export_bytes(String) -> Result[Bytes, V8Error]
  • ModuleHandle::call_export_json(String, String) -> Result[String, V8Error]
  • ModuleHandle::call_export_bytes(String, Bytes) -> Result[Bytes, V8Error]
  • ModuleHandle::dispose() -> Unit
  • ModuleHandle::is_closed() -> Bool
  • RuntimeImage::load_module(String, String) -> RuntimeImage
  • RuntimeImage::load_modules(Array[ModuleSource]) -> RuntimeImage
  • RuntimeImage::build_runtime() -> Result[Runtime, V8Error]
  • RuntimeImage::with_runtime((Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]
  • RuntimeBuilder::eval_snapshot(String) -> RuntimeBuilder
  • RuntimeBuilder::with_deno_core_compat() -> RuntimeBuilder
  • RuntimeBuilder::with_node_compat() -> RuntimeBuilder
  • RuntimeBuilder::with_snapshot(Bytes) -> RuntimeBuilder
  • RuntimeBuilder::with_snapshot_builder(SnapshotBuilder) -> RuntimeBuilder
  • RuntimeBuilder::build_image() -> Result[RuntimeImage, V8Error]
  • SnapshotBuilder::with_snapshot(Bytes) -> SnapshotBuilder
  • SnapshotBuilder::with_deno_core_compat() -> SnapshotBuilder
  • SnapshotBuilder::with_node_compat() -> SnapshotBuilder
  • SnapshotBuilder::eval(String) -> SnapshotBuilder
  • SnapshotBuilder::build() -> Result[Bytes, V8Error]
  • SnapshotBuilder::build_image() -> Result[RuntimeImage, V8Error]
  • SnapshotBuilder::build_runtime() -> Result[Runtime, V8Error]
  • SnapshotBuilder::with_runtime((Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]
  • RuntimeBuilder::load_module(String, String) -> RuntimeBuilder
  • RuntimeBuilder::load_modules(Array[ModuleSource]) -> RuntimeBuilder
  • RuntimeBuilder::build() -> Result[Runtime, V8Error]
  • RuntimeBuilder::with_runtime((Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]
  • eval_string(String) -> Result[String, V8Error]
  • eval_string_with_name(String, String) -> Result[String, V8Error]
  • eval_async_string(String) -> Result[String, V8Error]
  • eval_async_string_with_name(String, String) -> Result[String, V8Error]
  • eval_json(String) -> Result[String, V8Error]
  • eval_json_with_name(String, String) -> Result[String, V8Error]
  • eval_async_json(String) -> Result[String, V8Error]
  • eval_async_json_with_name(String, String) -> Result[String, V8Error]
  • eval_bytes(String) -> Result[Bytes, V8Error]
  • eval_bytes_with_name(String, String) -> Result[Bytes, V8Error]
  • eval_async_bytes(String) -> Result[Bytes, V8Error]
  • eval_async_bytes_with_name(String, String) -> Result[Bytes, V8Error]
  • eval_module_string(String) -> Result[String, V8Error]
  • eval_module_string_with_specifier(String, String) -> Result[String, V8Error]

#Notes

  • rusty_v8 を依存取得に使い、Rust staticlib ブリッジ経由で MoonBit から呼びます
  • いまは Context 1 個を保持する最小ランタイムです
  • 複数 runtime を同時に保持できます
  • module 評価は top-level await に対応します
  • Runtime::load_module で事前登録した module に対して static import / dynamic import と相対 specifier を解決できます
  • Runtime::eval_async_string_with_nameRuntime::eval_module_string_with_specifier で script/module ごとの基準 specifier を制御できます
  • Runtime::eval_promise_stringRuntime::eval_promise_string_with_name で pending Promise を host 側 handle として保持できます
  • with_runtime_async / with_runtime_with_snapshot_async で runtime の生成と破棄を MoonBit async 側に寄せられます
  • PromiseHandle::result_json / result_bytes で fulfilled Promise の値を JSON/bytes のまま取得できます
  • PromiseHandle::await_string / await_json / await_bytes で checkpoint を内包して Promise を待てます
  • PromiseHandle::await_*_asyncModuleEvalHandle::await_ready_async で、Deno core の run_event_loop に近い形で MoonBit async event loop 上から pending op / microtask を進められます
  • Runtime::eval_promise_*_async と top-level eval_promise_*_async で handle を明示せずに same loop を使えます
  • Runtime::register_sync_json_callbackMoonBit.opSync(...) を MoonBit closure に直接 dispatch できます
  • Runtime::register_sync_json_result_callbackMoonBit.opSync(...) を closure の Result で return/throw できます
  • Runtime::register_sync_json_result_callback_with_json_errorMoonBit.opSync(...) を closure の Result で return/throw しつつ、throw reason を JSON value にできます
  • Runtime::register_sync_json_op / push_sync_json_op_response / take_sync_json_opMoonBit.opSync(...) を固定応答テーブル付きでも扱えます
  • Runtime::register_sync_bytes_callbackMoonBit.opSyncBytes(...) を MoonBit closure に直接 dispatch できます
  • Runtime::register_sync_bytes_result_callbackMoonBit.opSyncBytes(...) を closure の Result で return/throw できます
  • Runtime::register_sync_bytes_result_callback_with_json_errorMoonBit.opSyncBytes(...) を closure の Result で return/throw しつつ、throw reason を JSON value にできます
  • Runtime::register_sync_bytes_op / push_sync_bytes_op_response / take_sync_bytes_opMoonBit.opSyncBytes(...) を固定応答テーブル付きでも扱えます
  • Runtime::register_async_json_callbackMoonBit.opAsync(...) を MoonBit closure に直接 dispatch して Promise を解決できます
  • Runtime::register_async_json_result_callbackMoonBit.opAsync(...) を closure の Result で resolve/reject できます
  • Runtime::register_async_json_result_callback_with_json_errorMoonBit.opAsync(...) を closure の Result で resolve/reject しつつ、reject reason を JSON value にできます
  • Runtime::register_async_json_op / take_async_json_op / resolve_async_json_op / reject_async_json_op / reject_async_json_op_with_jsonMoonBit.opAsync(...) を host loop で処理できます
  • Runtime::register_async_json_task_* で queue ベース op を MoonBit async task として処理し、PromiseHandle::await_*_async からそのまま駆動できます
  • Runtime::register_async_bytes_callbackMoonBit.opAsyncBytes(...) を MoonBit closure に直接 dispatch して Promise を解決できます
  • Runtime::register_async_bytes_result_callbackMoonBit.opAsyncBytes(...) を closure の Result で resolve/reject できます
  • Runtime::register_async_bytes_result_callback_with_json_errorMoonBit.opAsyncBytes(...) を closure の Result で resolve/reject しつつ、reject reason を JSON value にできます
  • Runtime::register_async_bytes_op / take_async_bytes_op / resolve_async_bytes_op / reject_async_bytes_op / reject_async_bytes_op_with_jsonMoonBit.opAsyncBytes(...) を host loop で処理できます
  • Runtime::register_async_bytes_task_* で bytes lane も同じ MoonBit async event loop に載せられます
  • Runtime::eval_module_handle_async_string / eval_module_handle_async_string_with_specifierModuleEvalHandle::await_ready / await_ready_async で top-level await module を host loop で扱えます
  • Runtime::eval_module_handle_string_async / eval_module_handle_string_async_with_specifier で、その top-level await module path を handle までまとめて待てます
  • Runtime::eval_json / eval_bytes / eval_async_json / eval_async_bytes で script 結果を typed bridge で直接取得できます
  • Runtime::eval_module_handle_stringRuntime::eval_module_handle_string_with_specifier で評価済み module の export を host 側から取得できます
  • ModuleHandle::export_names / get_export_bytes / call_export_json / call_export_bytes で module namespace を host 側 API として直接扱えます
  • Runtime::set_global_json / get_global_json / call_global_json で host と JS の JSON ベース値受け渡しができます
  • Runtime::set_global_bytes / get_global_bytes / call_global_bytesUint8Array / ArrayBuffer を host と往復できます
  • Runtime::add_resource / add_resource_with_close / ref_resource / unref_resource / list_resources / close_resource / try_close_resource で embedder 側 resource table を管理できます
  • Runtime::install_deno_core_compat で opt-in の Deno shim を入れ、Deno.core.op* / ops* に加えて encode / decode / resources / close / tryClose / refOpPromise / unrefOpPromise などの utility helper と、Deno.sleep / 最小 setTimeout / clearTimeout / setInterval / clearIntervalDeno.args / Deno.build / Deno.version / Deno.inspect / Deno.cwd / Deno.execPath を使えます
  • Runtime::install_node_compat で opt-in の Node 風 shim を入れ、global / process.nextTick / Buffer / setImmediate を最小限の実装で使えます
  • snapshot_createsnapshot_extend で初期化済み isolate snapshot を作り、runtime_new_with_snapshot で起動できます
  • SnapshotBuilder で複数の初期化 script を積んでから snapshot 化できます
  • RuntimeBuilder で snapshot 初期化 script と module preload をまとめて runtime 起動に流せます
  • RuntimeBuilder::with_snapshot_builderSnapshotBuilder をそのまま runtime 起動に接続できます
  • RuntimeBuilder::with_deno_core_compatSnapshotBuilder::with_deno_core_compat で runtime/snapshot 作成時から同じ Deno shim を preload できます
  • RuntimeBuilder::with_node_compatSnapshotBuilder::with_node_compat で runtime/snapshot 作成時から同じ Node shim を preload できます
  • RuntimeImage は snapshot と module preload をまとめた再利用可能な起動イメージです
  • sync host op は preloaded JSON / bytes response table ベースで利用可能です
  • async host op は JSON / bytes queue ベースで利用可能です
  • sync host callback は JSON / bytes で利用可能です
  • async host callback は JSON / bytes で利用可能です
  • result callback は sync では throw、async では reject を返せます
  • with_json_error 系 callback と reject_async_*_op_with_json は throw/reject reason を JSON object / array / primitive で渡せます
  • async callback 経由の op は queue に積まれません
  • MoonBit async event loop driver は 1 runtime あたり 1 本だけ同時実行できます
  • MoonBit async event loop driver を使う lane では、同じ runtime 上で take_async_*_op による手動 loop と混在させない前提です
  • Deno.sleep と最小 setTimeout / clearTimeout / setInterval / clearInterval は queue ベース async op の上に載せつつ runtime resource table にも載り、refOpPromise / unrefOpPromise はその ref state を更新します
  • oden/ 配下に sibling module を切ると、mizchi/v8 とは別の moon.mod.json で CLI 層や runtime policy を分離して開発できます。現在の oden 側では run / check / test / bundle / fmt / info / task / plan を MoonBit-first な router として管理しています
  • Deno 互換は Deno.core の op/util shim と最小の top-level Deno helper に絞っていて、fs/runtime permissions/web API 全体までは含みません
  • Node 互換も今のところ global / process / Buffer / setImmediate の最小 shim に限り、標準 library 全体や fs/net/timers 実装は含みません

#
V8Error

pub suberror V8Error {
DependencyMissing(String)
ModuleClosed
NativeError(String)
PromiseClosed
RuntimeClosed
}

Public error contract for V8 runtime operations.
impl Eq for V8Error
impl Show for V8Error

#
AsyncBytesOpRequest

pub struct AsyncBytesOpRequest {
id : UInt64
name : String
payload : Bytes
}

#
AsyncJsonOpRequest

pub struct AsyncJsonOpRequest {
id : UInt64
name : String
payload_json : String
}

#
ModuleEvalHandle

pub struct ModuleEvalHandle {
// private fields
}

#
ModuleEvalHandle::await_ready

fn ModuleEvalHandle::await_ready(self : ModuleEvalHandle) -> Result[ModuleHandle, V8Error]

#
ModuleEvalHandle::await_ready_async

async fn ModuleEvalHandle::await_ready_async(self : ModuleEvalHandle) -> Result[ModuleHandle, V8Error]

#
ModuleEvalHandle::dispose

fn ModuleEvalHandle::dispose(self : ModuleEvalHandle) -> Unit

#
ModuleEvalHandle::is_closed

fn ModuleEvalHandle::is_closed(self : ModuleEvalHandle) -> Bool

#
ModuleEvalHandle::module_handle

fn ModuleEvalHandle::module_handle(self : ModuleEvalHandle) -> ModuleHandle

#
ModuleEvalHandle::promise_handle

fn ModuleEvalHandle::promise_handle(self : ModuleEvalHandle) -> PromiseHandle?

#
ModuleHandle

pub struct ModuleHandle {
// private fields
}

#
ModuleHandle::call_export_bytes

fn ModuleHandle::call_export_bytes(self : ModuleHandle, export_name : String, bytes : Bytes) -> Result[Bytes, V8Error]

#
ModuleHandle::call_export_json

fn ModuleHandle::call_export_json(self : ModuleHandle, export_name : String, args_json : String) -> Result[String, V8Error]

#
ModuleHandle::dispose

fn ModuleHandle::dispose(self : ModuleHandle) -> Unit

#
ModuleHandle::export_names

fn ModuleHandle::export_names(self : ModuleHandle) -> Result[Array[String], V8Error]

#
ModuleHandle::get_export_bytes

fn ModuleHandle::get_export_bytes(self : ModuleHandle, export_name : String) -> Result[Bytes, V8Error]

#
ModuleHandle::get_export_json

fn ModuleHandle::get_export_json(self : ModuleHandle, export_name : String) -> Result[String, V8Error]

#
ModuleHandle::is_closed

fn ModuleHandle::is_closed(self : ModuleHandle) -> Bool

#
ModuleHandleState

type ModuleHandleState

#
ModuleSource

pub struct ModuleSource {
specifier : String
source : String
}

#
PromiseHandle

pub struct PromiseHandle {
// private fields
}

#
PromiseHandle::await_bytes

fn PromiseHandle::await_bytes(self : PromiseHandle) -> Result[Bytes, V8Error]

#
PromiseHandle::await_bytes_async

async fn PromiseHandle::await_bytes_async(self : PromiseHandle) -> Result[Bytes, V8Error]

#
PromiseHandle::await_json

fn PromiseHandle::await_json(self : PromiseHandle) -> Result[String, V8Error]

#
PromiseHandle::await_json_async

async fn PromiseHandle::await_json_async(self : PromiseHandle) -> Result[String, V8Error]

#
PromiseHandle::await_string

fn PromiseHandle::await_string(self : PromiseHandle) -> Result[String, V8Error]

#
PromiseHandle::await_string_async

async fn PromiseHandle::await_string_async(self : PromiseHandle) -> Result[String, V8Error]

#
PromiseHandle::dispose

fn PromiseHandle::dispose(self : PromiseHandle) -> Unit

#
PromiseHandle::is_closed

fn PromiseHandle::is_closed(self : PromiseHandle) -> Bool

#
PromiseHandle::result_bytes

fn PromiseHandle::result_bytes(self : PromiseHandle) -> Result[Bytes, V8Error]

#
PromiseHandle::result_json

fn PromiseHandle::result_json(self : PromiseHandle) -> Result[String, V8Error]

#
PromiseHandle::result_string

fn PromiseHandle::result_string(self : PromiseHandle) -> Result[String, V8Error]

#
PromiseHandle::state

fn PromiseHandle::state(self : PromiseHandle) -> Result[PromiseState, V8Error]

#
PromiseHandleState

type PromiseHandleState

#
PromiseState

pub enum PromiseState {
Pending
Fulfilled
Rejected
}

impl Eq for PromiseState

#
Runtime

pub struct Runtime {
// private fields
}

#
Runtime::add_resource

fn Runtime::add_resource(self : Runtime, name : String) -> Result[Int, V8Error]

#
Runtime::add_resource_with_close

fn Runtime::add_resource_with_close(self : Runtime, name : String, on_close : () -> Unit) -> Result[Int, V8Error]

#
Runtime::call_global_bytes

fn Runtime::call_global_bytes(self : Runtime, name : String, bytes : Bytes) -> Result[Bytes, V8Error]

#
Runtime::call_global_json

fn Runtime::call_global_json(self : Runtime, name : String, args_json : String) -> Result[String, V8Error]

#
Runtime::close_resource

fn Runtime::close_resource(self : Runtime, rid : Int) -> Result[Unit, V8Error]

#
Runtime::dispose

fn Runtime::dispose(self : Runtime) -> Unit

#
Runtime::eval_async_bytes

fn Runtime::eval_async_bytes(self : Runtime, source : String) -> Result[Bytes, V8Error]

#
Runtime::eval_async_bytes_with_name

fn Runtime::eval_async_bytes_with_name(self : Runtime, resource_name : String, source : String) -> Result[Bytes, V8Error]

#
Runtime::eval_async_json

fn Runtime::eval_async_json(self : Runtime, source : String) -> Result[String, V8Error]

#
Runtime::eval_async_json_with_name

fn Runtime::eval_async_json_with_name(self : Runtime, resource_name : String, source : String) -> Result[String, V8Error]

#
Runtime::eval_async_string

fn Runtime::eval_async_string(self : Runtime, source : String) -> Result[String, V8Error]

#
Runtime::eval_async_string_with_name

fn Runtime::eval_async_string_with_name(self : Runtime, resource_name : String, source : String) -> Result[String, V8Error]

#
Runtime::eval_bytes

fn Runtime::eval_bytes(self : Runtime, source : String) -> Result[Bytes, V8Error]

#
Runtime::eval_bytes_with_name

fn Runtime::eval_bytes_with_name(self : Runtime, resource_name : String, source : String) -> Result[Bytes, V8Error]

#
Runtime::eval_json

fn Runtime::eval_json(self : Runtime, source : String) -> Result[String, V8Error]

#
Runtime::eval_json_with_name

fn Runtime::eval_json_with_name(self : Runtime, resource_name : String, source : String) -> Result[String, V8Error]

#
Runtime::eval_module_handle_async_string

fn Runtime::eval_module_handle_async_string(self : Runtime, source : String) -> Result[ModuleEvalHandle, V8Error]

#
Runtime::eval_module_handle_async_string_with_specifier

fn Runtime::eval_module_handle_async_string_with_specifier(self : Runtime, specifier : String, source : String) -> Result[ModuleEvalHandle, V8Error]

#
Runtime::eval_module_handle_string

fn Runtime::eval_module_handle_string(self : Runtime, source : String) -> Result[ModuleHandle, V8Error]

#
Runtime::eval_module_handle_string_async

async fn Runtime::eval_module_handle_string_async(self : Runtime, source : String) -> Result[ModuleHandle, V8Error]

#
Runtime::eval_module_handle_string_async_with_specifier

async fn Runtime::eval_module_handle_string_async_with_specifier(self : Runtime, specifier : String, source : String) -> Result[ModuleHandle, V8Error]

#
Runtime::eval_module_handle_string_with_specifier

fn Runtime::eval_module_handle_string_with_specifier(self : Runtime, specifier : String, source : String) -> Result[ModuleHandle, V8Error]

#
Runtime::eval_module_string

fn Runtime::eval_module_string(self : Runtime, source : String) -> Result[String, V8Error]

#
Runtime::eval_module_string_with_specifier

fn Runtime::eval_module_string_with_specifier(self : Runtime, specifier : String, source : String) -> Result[String, V8Error]

#
Runtime::eval_promise_bytes_async

async fn Runtime::eval_promise_bytes_async(self : Runtime, source : String) -> Result[Bytes, V8Error]

#
Runtime::eval_promise_bytes_async_with_name

async fn Runtime::eval_promise_bytes_async_with_name(self : Runtime, resource_name : String, source : String) -> Result[Bytes, V8Error]

#
Runtime::eval_promise_json_async

async fn Runtime::eval_promise_json_async(self : Runtime, source : String) -> Result[String, V8Error]

#
Runtime::eval_promise_json_async_with_name

async fn Runtime::eval_promise_json_async_with_name(self : Runtime, resource_name : String, source : String) -> Result[String, V8Error]

#
Runtime::eval_promise_string

fn Runtime::eval_promise_string(self : Runtime, source : String) -> Result[PromiseHandle, V8Error]

#
Runtime::eval_promise_string_async

async fn Runtime::eval_promise_string_async(self : Runtime, source : String) -> Result[String, V8Error]

#
Runtime::eval_promise_string_async_with_name

async fn Runtime::eval_promise_string_async_with_name(self : Runtime, resource_name : String, source : String) -> Result[String, V8Error]

#
Runtime::eval_promise_string_with_name

fn Runtime::eval_promise_string_with_name(self : Runtime, resource_name : String, source : String) -> Result[PromiseHandle, V8Error]

#
Runtime::eval_string

fn Runtime::eval_string(self : Runtime, source : String) -> Result[String, V8Error]

#
Runtime::eval_string_with_name

fn Runtime::eval_string_with_name(self : Runtime, resource_name : String, source : String) -> Result[String, V8Error]

#
Runtime::get_global_bytes

fn Runtime::get_global_bytes(self : Runtime, name : String) -> Result[Bytes, V8Error]

#
Runtime::get_global_json

fn Runtime::get_global_json(self : Runtime, name : String) -> Result[String, V8Error]

#
Runtime::get_resource_name

fn Runtime::get_resource_name(self : Runtime, rid : Int) -> Result[String?, V8Error]

#
Runtime::install_deno_core_compat

fn Runtime::install_deno_core_compat(self : Runtime) -> Result[Unit, V8Error]

#
Runtime::install_node_compat

fn Runtime::install_node_compat(self : Runtime) -> Result[Unit, V8Error]

#
Runtime::is_closed

fn Runtime::is_closed(self : Runtime) -> Bool

#
Runtime::list_resources

fn Runtime::list_resources(self : Runtime) -> Result[Array[RuntimeResource], V8Error]

#
Runtime::load_module

fn Runtime::load_module(self : Runtime, specifier : String, source : String) -> Result[Unit, V8Error]

#
Runtime::load_modules

fn Runtime::load_modules(self : Runtime, modules : Array[ModuleSource]) -> Result[Unit, V8Error]

#
Runtime::perform_microtask_checkpoint

fn Runtime::perform_microtask_checkpoint(self : Runtime) -> Result[Unit, V8Error]

#
Runtime::push_sync_bytes_op_response

fn Runtime::push_sync_bytes_op_response(self : Runtime, name : String, payload : Bytes, result_bytes : Bytes) -> Result[Unit, V8Error]

#
Runtime::push_sync_json_op_response

fn Runtime::push_sync_json_op_response(self : Runtime, name : String, payload_json : String, result_json : String) -> Result[Unit, V8Error]

#
Runtime::ref_resource

fn Runtime::ref_resource(self : Runtime, rid : Int) -> Result[Bool, V8Error]

#
Runtime::register_async_bytes_callback

fn Runtime::register_async_bytes_callback(self : Runtime, name : String, callback : (Bytes) -> Bytes) -> Result[Unit, V8Error]

#
Runtime::register_async_bytes_op

fn Runtime::register_async_bytes_op(self : Runtime, name : String) -> Result[Unit, V8Error]

#
Runtime::register_async_bytes_result_callback

fn Runtime::register_async_bytes_result_callback(self : Runtime, name : String, callback : (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]

#
Runtime::register_async_bytes_result_callback_with_json_error

fn Runtime::register_async_bytes_result_callback_with_json_error(self : Runtime, name : String, callback : (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]

#
Runtime::register_async_bytes_task_callback

fn Runtime::register_async_bytes_task_callback(self : Runtime, name : String, callback : async (Bytes) -> Bytes) -> Result[Unit, V8Error]

#
Runtime::register_async_bytes_task_result_callback

fn Runtime::register_async_bytes_task_result_callback(self : Runtime, name : String, callback : async (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]

#
Runtime::register_async_bytes_task_result_callback_with_json_error

fn Runtime::register_async_bytes_task_result_callback_with_json_error(self : Runtime, name : String, callback : async (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]

#
Runtime::register_async_json_callback

fn Runtime::register_async_json_callback(self : Runtime, name : String, callback : (String) -> String) -> Result[Unit, V8Error]

#
Runtime::register_async_json_op

fn Runtime::register_async_json_op(self : Runtime, name : String) -> Result[Unit, V8Error]

#
Runtime::register_async_json_result_callback

fn Runtime::register_async_json_result_callback(self : Runtime, name : String, callback : (String) -> Result[String, String]) -> Result[Unit, V8Error]

#
Runtime::register_async_json_result_callback_with_json_error

fn Runtime::register_async_json_result_callback_with_json_error(self : Runtime, name : String, callback : (String) -> Result[String, String]) -> Result[Unit, V8Error]

#
Runtime::register_async_json_task_callback

fn Runtime::register_async_json_task_callback(self : Runtime, name : String, callback : async (String) -> String) -> Result[Unit, V8Error]

#
Runtime::register_async_json_task_result_callback

fn Runtime::register_async_json_task_result_callback(self : Runtime, name : String, callback : async (String) -> Result[String, String]) -> Result[Unit, V8Error]

#
Runtime::register_async_json_task_result_callback_with_json_error

fn Runtime::register_async_json_task_result_callback_with_json_error(self : Runtime, name : String, callback : async (String) -> Result[String, String]) -> Result[Unit, V8Error]

#
Runtime::register_sync_bytes_callback

fn Runtime::register_sync_bytes_callback(self : Runtime, name : String, callback : (Bytes) -> Bytes) -> Result[Unit, V8Error]

#
Runtime::register_sync_bytes_op

fn Runtime::register_sync_bytes_op(self : Runtime, name : String) -> Result[Unit, V8Error]

#
Runtime::register_sync_bytes_result_callback

fn Runtime::register_sync_bytes_result_callback(self : Runtime, name : String, callback : (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]

#
Runtime::register_sync_bytes_result_callback_with_json_error

fn Runtime::register_sync_bytes_result_callback_with_json_error(self : Runtime, name : String, callback : (Bytes) -> Result[Bytes, String]) -> Result[Unit, V8Error]

#
Runtime::register_sync_json_callback

fn Runtime::register_sync_json_callback(self : Runtime, name : String, callback : (String) -> String) -> Result[Unit, V8Error]

#
Runtime::register_sync_json_op

fn Runtime::register_sync_json_op(self : Runtime, name : String) -> Result[Unit, V8Error]

#
Runtime::register_sync_json_result_callback

fn Runtime::register_sync_json_result_callback(self : Runtime, name : String, callback : (String) -> Result[String, String]) -> Result[Unit, V8Error]

#
Runtime::register_sync_json_result_callback_with_json_error

fn Runtime::register_sync_json_result_callback_with_json_error(self : Runtime, name : String, callback : (String) -> Result[String, String]) -> Result[Unit, V8Error]

#
Runtime::reject_async_bytes_op

fn Runtime::reject_async_bytes_op(self : Runtime, op_id : UInt64, message : String) -> Result[Unit, V8Error]

#
Runtime::reject_async_bytes_op_with_json

fn Runtime::reject_async_bytes_op_with_json(self : Runtime, op_id : UInt64, error_json : String) -> Result[Unit, V8Error]

#
Runtime::reject_async_json_op

fn Runtime::reject_async_json_op(self : Runtime, op_id : UInt64, message : String) -> Result[Unit, V8Error]

#
Runtime::reject_async_json_op_with_json

fn Runtime::reject_async_json_op_with_json(self : Runtime, op_id : UInt64, error_json : String) -> Result[Unit, V8Error]

#
Runtime::resolve_async_bytes_op

fn Runtime::resolve_async_bytes_op(self : Runtime, op_id : UInt64, result_bytes : Bytes) -> Result[Unit, V8Error]

#
Runtime::resolve_async_json_op

fn Runtime::resolve_async_json_op(self : Runtime, op_id : UInt64, result_json : String) -> Result[Unit, V8Error]

#
Runtime::run_event_loop_until_idle_async

async fn Runtime::run_event_loop_until_idle_async(self : Runtime) -> Result[Unit, V8Error]

#
Runtime::set_global_bytes

fn Runtime::set_global_bytes(self : Runtime, name : String, bytes : Bytes) -> Result[Unit, V8Error]

#
Runtime::set_global_json

fn Runtime::set_global_json(self : Runtime, name : String, json : String) -> Result[Unit, V8Error]

#
Runtime::take_async_bytes_op

fn Runtime::take_async_bytes_op(self : Runtime) -> Result[AsyncBytesOpRequest?, V8Error]

#
Runtime::take_async_json_op

fn Runtime::take_async_json_op(self : Runtime) -> Result[AsyncJsonOpRequest?, V8Error]

#
Runtime::take_sync_bytes_op

fn Runtime::take_sync_bytes_op(self : Runtime) -> Result[SyncBytesOpRequest?, V8Error]

#
Runtime::take_sync_json_op

fn Runtime::take_sync_json_op(self : Runtime) -> Result[SyncJsonOpRequest?, V8Error]

#
Runtime::try_close_resource

fn Runtime::try_close_resource(self : Runtime, rid : Int) -> Result[Bool, V8Error]

#
Runtime::unref_resource

fn Runtime::unref_resource(self : Runtime, rid : Int) -> Result[Bool, V8Error]

#
RuntimeBuilder

pub struct RuntimeBuilder {
// private fields
}

#
RuntimeBuilder::build

fn RuntimeBuilder::build(self : RuntimeBuilder) -> Result[Runtime, V8Error]

#
RuntimeBuilder::build_image

fn RuntimeBuilder::build_image(self : RuntimeBuilder) -> Result[RuntimeImage, V8Error]

#
RuntimeBuilder::eval_snapshot

fn RuntimeBuilder::eval_snapshot(self : RuntimeBuilder, source : String) -> RuntimeBuilder

#
RuntimeBuilder::load_module

fn RuntimeBuilder::load_module(self : RuntimeBuilder, specifier : String, source : String) -> RuntimeBuilder

#
RuntimeBuilder::load_modules

fn RuntimeBuilder::load_modules(self : RuntimeBuilder, modules : Array[ModuleSource]) -> RuntimeBuilder

#
RuntimeBuilder::with_deno_core_compat

fn RuntimeBuilder::with_deno_core_compat(self : RuntimeBuilder) -> RuntimeBuilder

#
RuntimeBuilder::with_node_compat

fn RuntimeBuilder::with_node_compat(self : RuntimeBuilder) -> RuntimeBuilder

#
RuntimeBuilder::with_runtime

fn[T] RuntimeBuilder::with_runtime(self : RuntimeBuilder, f : (Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]

#
RuntimeBuilder::with_snapshot

fn RuntimeBuilder::with_snapshot(self : RuntimeBuilder, snapshot : Bytes) -> RuntimeBuilder

#
RuntimeBuilder::with_snapshot_builder

fn RuntimeBuilder::with_snapshot_builder(self : RuntimeBuilder, snapshot_builder : SnapshotBuilder) -> RuntimeBuilder

#
RuntimeBuilderState

type RuntimeBuilderState

#
RuntimeImage

pub struct RuntimeImage {
// private fields
}

#
RuntimeImage::build_runtime

fn RuntimeImage::build_runtime(self : RuntimeImage) -> Result[Runtime, V8Error]

#
RuntimeImage::load_module

fn RuntimeImage::load_module(self : RuntimeImage, specifier : String, source : String) -> RuntimeImage

#
RuntimeImage::load_modules

fn RuntimeImage::load_modules(self : RuntimeImage, modules : Array[ModuleSource]) -> RuntimeImage

#
RuntimeImage::with_runtime

fn[T] RuntimeImage::with_runtime(self : RuntimeImage, f : (Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]

#
RuntimeImageState

type RuntimeImageState

#
RuntimeResource

pub struct RuntimeResource {
rid : Int
name : String
is_ref : Bool
}

#
RuntimeState

type RuntimeState

#
SnapshotBuilder

pub struct SnapshotBuilder {
// private fields
}

#
SnapshotBuilder::build

fn SnapshotBuilder::build(self : SnapshotBuilder) -> Result[Bytes, V8Error]

#
SnapshotBuilder::build_image

fn SnapshotBuilder::build_image(self : SnapshotBuilder) -> Result[RuntimeImage, V8Error]

#
SnapshotBuilder::build_runtime

fn SnapshotBuilder::build_runtime(self : SnapshotBuilder) -> Result[Runtime, V8Error]

#
SnapshotBuilder::eval

fn SnapshotBuilder::eval(self : SnapshotBuilder, source : String) -> SnapshotBuilder

#
SnapshotBuilder::with_deno_core_compat

fn SnapshotBuilder::with_deno_core_compat(self : SnapshotBuilder) -> SnapshotBuilder

#
SnapshotBuilder::with_node_compat

fn SnapshotBuilder::with_node_compat(self : SnapshotBuilder) -> SnapshotBuilder

#
SnapshotBuilder::with_runtime

fn[T] SnapshotBuilder::with_runtime(self : SnapshotBuilder, f : (Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]

#
SnapshotBuilder::with_snapshot

fn SnapshotBuilder::with_snapshot(self : SnapshotBuilder, snapshot : Bytes) -> SnapshotBuilder

#
SnapshotBuilderState

type SnapshotBuilderState

#
SyncBytesOpRequest

pub struct SyncBytesOpRequest {
id : UInt64
name : String
payload : Bytes
}

#
SyncJsonOpRequest

pub struct SyncJsonOpRequest {
id : UInt64
name : String
payload_json : String
}

#
eval_async_bytes

fn eval_async_bytes(source : String) -> Result[Bytes, V8Error]

#
eval_async_bytes_with_name

fn eval_async_bytes_with_name(resource_name : String, source : String) -> Result[Bytes, V8Error]

#
eval_async_json

fn eval_async_json(source : String) -> Result[String, V8Error]

#
eval_async_json_with_name

fn eval_async_json_with_name(resource_name : String, source : String) -> Result[String, V8Error]

#
eval_async_string

fn eval_async_string(source : String) -> Result[String, V8Error]

#
eval_async_string_with_name

fn eval_async_string_with_name(resource_name : String, source : String) -> Result[String, V8Error]

#
eval_bytes

fn eval_bytes(source : String) -> Result[Bytes, V8Error]

#
eval_bytes_with_name

fn eval_bytes_with_name(resource_name : String, source : String) -> Result[Bytes, V8Error]

#
eval_json

fn eval_json(source : String) -> Result[String, V8Error]

#
eval_json_with_name

fn eval_json_with_name(resource_name : String, source : String) -> Result[String, V8Error]

#
eval_module_string

fn eval_module_string(source : String) -> Result[String, V8Error]

#
eval_module_string_with_specifier

fn eval_module_string_with_specifier(specifier : String, source : String) -> Result[String, V8Error]

#
eval_promise_bytes_async

async fn eval_promise_bytes_async(source : String) -> Result[Bytes, V8Error]

#
eval_promise_bytes_async_with_name

async fn eval_promise_bytes_async_with_name(resource_name : String, source : String) -> Result[Bytes, V8Error]

#
eval_promise_json_async

async fn eval_promise_json_async(source : String) -> Result[String, V8Error]

#
eval_promise_json_async_with_name

async fn eval_promise_json_async_with_name(resource_name : String, source : String) -> Result[String, V8Error]

#
eval_promise_string_async

async fn eval_promise_string_async(source : String) -> Result[String, V8Error]

#
eval_promise_string_async_with_name

async fn eval_promise_string_async_with_name(resource_name : String, source : String) -> Result[String, V8Error]

#
eval_string

fn eval_string(source : String) -> Result[String, V8Error]

#
eval_string_with_name

fn eval_string_with_name(resource_name : String, source : String) -> Result[String, V8Error]

#
module_source

fn module_source(specifier : String, source : String) -> ModuleSource

#
runtime_builder_new

fn runtime_builder_new() -> RuntimeBuilder

#
runtime_image_new

fn runtime_image_new(snapshot : Bytes) -> RuntimeImage

#
runtime_new

fn runtime_new() -> Result[Runtime, V8Error]

#
runtime_new_with_snapshot

fn runtime_new_with_snapshot(snapshot : Bytes) -> Result[Runtime, V8Error]

#
snapshot_builder_new

fn snapshot_builder_new() -> SnapshotBuilder

#
snapshot_create

fn snapshot_create(source : String) -> Result[Bytes, V8Error]

#
snapshot_extend

fn snapshot_extend(snapshot : Bytes, source : String) -> Result[Bytes, V8Error]

#
version

fn version() -> String

#
with_runtime

fn[T] with_runtime(f : (Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]

#
with_runtime_async

async fn[T] with_runtime_async(f : async (Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]

#
with_runtime_with_snapshot

fn[T] with_runtime_with_snapshot(snapshot : Bytes, f : (Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]

#
with_runtime_with_snapshot_async

async fn[T] with_runtime_with_snapshot_async(snapshot : Bytes, f : async (Runtime) -> Result[T, V8Error]) -> Result[T, V8Error]