mizchi/js.mbt

Moonbit Js bindings

MoonBit

77

1,220 commits

updated Sep 16, 2026

See the code

README

mizchi/js

Comprehensive JavaScript/ FFI bindings for MoonBit, supporting multiple runtimes and platforms.

Import only what you need

0.13.0 split this library into nine modules. Depend on the ones your target actually has, and nothing else — a Cloudflare Worker no longer drags in node:fs, a CLI no longer drags in the DOM.

ModuleScope
mizchi/js_coreAny, Promise, Nullable, the raw FFI — everything depends on this
mizchi/js_builtinJS built-ins: Object, Array, JSON, RegExp, Date, Map/Set, ArrayBuffer, …
mizchi/js_webWeb Standards: fetch, Request/Response, URL, Streams, Blob, File, WebSocket, Crypto, Workers
mizchi/js_nodeNode.js: fs, http, path, stream, child_process, sqlite, …
mizchi/js_browserBrowser-only: DOM, canvas, IndexedDB, storage, navigation, service worker
mizchi/js_denoDeno runtime APIs
mizchi/js_bunBun runtime APIs
mizchi/js_webextensionsWebExtensions (chrome.* / browser.*)
mizchi/js_convertMoonBit ⇔ JS value conversion (Map/Json/Option/ResultAny)
mizchi/jsMeta package — re-exports js_core + js_builtin for when you want one import

Dependencies only ever point toward js_core:

js_core <- js_builtin <- js_web <- js_node / js_browser / js_deno
                     <- js_bun
        <- js_convert
        <- js_webextensions

You only declare what you import directly; the modules those pull in resolve on their own.

Bindings that live outside this repo:

ModuleScope
mizchi/npm_typedNPM package bindings (React, Hono, Zod, AI SDK, …)
mizchi/cloudflare.mbtCloudflare Workers bindings

📖 User Guide — which modules to pick, aliases, per-runtime recipes, and the 0.12.x → 0.13.0 migration table.

Installation

moon add mizchi/js_core
moon add mizchi/js_web       # ...and whatever else you need

moon.mod:

import {
  "mizchi/js_core@0.13.0",
  "mizchi/js_web@0.13.0",
}

moon.pkg — the default alias is the last path segment, so give the module-root packages a short one:

import {
  "mizchi/js_core" @core,
  "mizchi/js_web/http",
}

Version Requirements

Developed and CI-tested against:

moon 0.1.20260915
moonc v0.10.13

CI tracks the latest MoonBit release, so a recent toolchain is the supported configuration. For the older stable toolchain, use v0.8.x.

📚 API Documentation by Platform

PlatformDocumentationExamplesStatus
Core JavaScriptmodules/js_core/README.mdjs_examples.mbt.md🧪 Tested
Browsermodules/js_browser/README.mdbrowser_examples.mbt.md🧪 Tested
Node.jsmodules/js_node/README.mdnode_examples.mbt.md🧪 Tested
Denomodules/js_deno/README.md-🧪 Tested
Reactmizchi/npm_typedSee npm_typed repo📦 Moved

📖 Learning Resources

Supported Modules

Status Legend

  • 🧪 Tested: Comprehensive test coverage, production ready
  • 🚧 Partially: Core functionality implemented, tests incomplete
  • 🤖 AI Generated: FFI bindings created, needs testing
  • 📅 Planned: Scheduled for future implementation
  • Not Supported: Technical limitations

Core JavaScript APIs

mizchi/js_core - Core FFI Package

The mizchi/js_core package provides the foundation for JavaScript interoperability in MoonBit:

Type System

  • Any - Opaque type for JavaScript values
  • Nullable[T] - Represents null | T
  • Nullish[T] - Represents null | undefined | T
  • Union2[A,B] ~ Union5[A,B,C,D,E] - TypeScript union types (A | B)
  • Promise[T] - JavaScript Promise wrapper

FFI Operations (zero-cost conversions)

  • identity[A,B](value: A) -> B - Type casting using %identity
  • any[T](value: T) -> Any - Convert to Any
  • Any::cast[T](self) -> T - Cast from Any
  • obj["key"], obj["key"] = value - Property access (or _get(key), _set(key, value))
  • Any::_call(method, args), Any::_invoke(args) - Method calls

Object & JSON

  • new_object(), new_array() - Create JS objects/arrays
  • object_keys(), object_values(), object_assign(), object_has_own()
  • json_stringify(), json_parse(), json_stringify_pretty()

Async/Promise Support

  • run_async(f) - Execute async functions (MoonBit builtin %async.run)
  • suspend(f) - Await promises (MoonBit builtin %async.suspend)
  • promisify0 ~ promisify3 - Convert callbacks to promises
  • Promise utilities: resolve, reject, all, race, any, withResolvers

Error Handling

  • JsError - Generic JS error type
  • ThrowError - Wrapper for thrown errors
  • try_sync(op) - Safe wrapper converting JS exceptions to MoonBit errors
  • throwable(f) - Convert JS exceptions to ThrowError
  • export_sync(op) - Convert MoonBit errors to JS exceptions
  • throw_error(msg) - Throw JS Error

Type Checking

  • is_object(), is_array(), is_null(), is_undefined(), is_nullish()

Nullish Utilities

  • Nullish::to_option(), Nullable::to_option() - Convert to MoonBit Option
  • nullable(opt) - Convert Option to JS nullable
  • as_any(opt) - Convert Option[Any] to Any

API Summary

CategoryPackageStatusNote
Core FFI & Objects
Core FFImizchi/js_core🧪 Testedget, set, call, etc.
Objectmizchi/js_builtin/object🧪 TestedObject manipulation
Functionmizchi/js_builtin/function🧪 TestedFunction operations
Promisemizchi/js_core🧪 TestedAsync/Promise API
Errormizchi/js_builtin/error🧪 TestedError handling
JSONmizchi/js_builtin/json🧪 TestedJSON parse/stringify
Iteratormizchi/js_builtin/iterator🧪 TestedJS Iterator protocol
AsyncIteratormizchi/js_builtin/iterator🧪 TestedAsync iteration
WeakMap/Set/Refmizchi/js_builtin/weak🧪 TestedWeak references
Async Helpers
run_asyncmizchi/js_core🧪 TestedAsync execution
suspendmizchi/js_core🧪 TestedPromise suspension
sleepmizchi/js_core🧪 TestedDelay execution
promisifymizchi/js_core🧪 TestedCallback → Promise

JavaScript Built-ins

All JavaScript built-in objects are exported from mizchi/js:

CategoryPackageStatusNote
Global Functions
Globalmizchi/js_builtin/global🧪 TestedglobalThis, parseInt, parseFloat, setTimeout etc.
Core Types
Objectmizchi/js_builtin/object🧪 TestedObject manipulation
Functionmizchi/js_builtin/function🧪 TestedFunction operations
Symbolmizchi/js_builtin/symbol🧪 TestedSymbol primitive
Errormizchi/js_builtin/error🧪 TestedError types (TypeError, RangeError, etc.)
Primitives & Data
Stringmizchi/js_builtin/string🧪 TestedJsString (String methods)
Arraymizchi/js_builtin/array🧪 TestedJsArray (Array methods)
BigIntmizchi/js_builtin/bigint🧪 TestedJsBigInt (arbitrary precision)
JSONmizchi/js_builtin/json🧪 TestedJSON parse/stringify
Date & Math
Datemizchi/js_builtin/date🧪 TestedDate/time operations
Mathmizchi/js_builtin/math🧪 TestedMath operations
Collections
Map/Setmizchi/js_builtin/collection🧪 TestedJsMap, JsSet
WeakMap/Set/Refmizchi/js_builtin/weak🧪 TestedWeakMap, WeakSet, WeakRef, FinalizationRegistry
Binary Data
ArrayBuffermizchi/js_builtin/arraybuffer🧪 TestedBinary buffers
DataViewmizchi/js_builtin/arraybuffer🧪 TestedBuffer views
memory
Pattern & Reflection
RegExpmizchi/js_builtin/regexp🧪 TestedRegular expressions
Reflectmizchi/js_builtin/reflect🧪 TestedReflection API
Proxymizchi/js_builtin/proxy🤖 AI GeneratedProxy API
Iteration & Async
Iteratormizchi/js_builtin/iterator🧪 TestedJsIterator protocol
AsyncIteratormizchi/js_builtin/iterator🧪 TestedAsync iteration
Concurrency
Atomicsmizchi/js_builtin/atomics🧪 TestedAtomic operations
Resource Management
DisposableStackmizchi/js_builtin/disposable🧪 TestedDisposable resources

Web Standard APIs

Platform-independent Web Standard APIs (browsers, Node.js, Deno, edge runtimes), shipped as the separate mizchi/js_web module:

See mizchi/js_web for detailed Web APIs documentation

CategoryPackageStatusNote
Consolemizchi/js_web/console🧪 Testedconsole.log, console.error, etc.
fetchmizchi/js_web/http🧪 TestedHTTP requests
Requestmizchi/js_web/http🧪 TestedRequest objects
Responsemizchi/js_web/http🧪 TestedResponse objects
Headersmizchi/js_web/http🧪 TestedHTTP headers
FormDatamizchi/js_web/http🧪 TestedForm data
URLmizchi/js_web/url🧪 TestedURL parsing
URLSearchParamsmizchi/js_web/url🧪 TestedQuery strings
URLPatternmizchi/js_web/url🧪 TestedURL pattern matching
Blobmizchi/js_web/blob🧪 TestedBinary data
ReadableStreammizchi/js_web/streams🧪 TestedStream reading
WritableStreammizchi/js_web/streams🧪 TestedStream writing
TransformStreammizchi/js_web/streams🧪 TestedStream transformation
CompressionStreammizchi/js_web/streams🧪 TestedGZIP/Deflate compression
DecompressionStreammizchi/js_web/streams🧪 TestedGZIP/Deflate decompression
TextEncodermizchi/js_web/encoding🧪 TestedString to Uint8Array
TextDecodermizchi/js_web/encoding🧪 TestedUint8Array to String
Eventmizchi/js_web/event🧪 TestedEvent objects
CustomEventmizchi/js_web/event🧪 TestedCustom events
MessageEventmizchi/js_web/event🧪 TestedMessage events
Cryptomizchi/js_web/crypto🧪 TestedWeb Crypto API
WebSocketmizchi/js_web/websocket🧪 TestedWebSocket API
Workermizchi/js_web/worker🧪 TestedWeb Workers
MessageChannelmizchi/js_web/message🧪 TestedMessage passing
MessagePortmizchi/js_web/message🧪 TestedMessage ports
WebAssemblymizchi/js_web/webassembly🤖 AI GeneratedWASM integration
Performancemizchi/js_web/performance🤖 AI GeneratedPerformance API

Runtime-Specific APIs

Web Standard, Node.js, Browser, Deno, Bun, and WebExtensions APIs ship as separate mizchi/js_* modules — add each one to your moon.mod import list only if you need it.

PlatformModuleStatusDocumentation
Web Standardsmizchi/js_web/*🧪 TestedWeb README
Node.jsmizchi/js_node/*🧪 TestedNode.js README
Browser APImizchi/js_browser/*🧪 TestedBrowser README
Denomizchi/js_deno🧪 TestedDeno README
Bunmizchi/js_bun🤖 AI Generated-
WebExtensionsmizchi/js_webextensions🤖 AI GeneratedWebExtensions README

NPM Package Bindings

Moved to separate repository: NPM package bindings are now maintained at mizchi/npm_typed

CategoryPackagesRepository
UI FrameworksReact, React DOM, React Router, Preact, Inkmizchi/npm_typed
Web FrameworksHono, better-authmizchi/npm_typed
AI / LLMVercel AI SDK, MCP SDK, Claude Code SDKmizchi/npm_typed
Cloud Services@aws-sdk/client-s3 (S3, R2, GCS, MinIO)mizchi/npm_typed
DatabasePGlite, DuckDB, Drizzle, pgmizchi/npm_typed
ValidationZod, AJVmizchi/npm_typed
Build ToolsTerser, Vite, Unplugin, Lighthousemizchi/npm_typed
Utilitiesdate-fns, semver, chalk, dotenv, chokidar, yargs, debugmizchi/npm_typed
TestingTesting Library, Puppeteer, Playwright, Vitest, JSDOM, MSWmizchi/npm_typed
Parsinghtmlparser2, js-yamlmizchi/npm_typed
Othersimple-git, ignore, memfs, source-map, comlinkmizchi/npm_typed

Limited Support APIs

FeatureStatusNote
eval()❌ Not SupportedSecurity and type safety concerns
new Function()❌ Not SupportedSecurity and type safety concerns

Project Status

  • 📦 FFI foundation (mizchi/js_core) - Any, Promise, Nullable, target-specific interop. Split out into its own module
  • 📦 JS built-ins (mizchi/js_builtin) - Object, Array, JSON, RegExp, Symbol, Proxy, ... Split out into its own module
  • 📦 MoonBit ⇔ JS conversion (mizchi/js_convert) - Map/Json/Option/ResultAny, runtime type inspection. Split out into its own module
  • mizchi/js - meta package re-exporting js_core + js_builtin, plus the wasm-gc entry
  • 📦 Web Standards (mizchi/js_web) - fetch, URL, Streams, Blob, Crypto, WebSocket, Workers. Split out into its own module
  • 📦 Node.js Core APIs (mizchi/js_node) - fs, path, process, child_process, etc. Split out into its own module
  • 📦 Browser / DOM (mizchi/js_browser) - Split out in v0.11.0
  • 📦 Deno Runtime (mizchi/js_deno) - Split out in v0.11.0
  • 📦 Bun Runtime (mizchi/js_bun) - Split out in v0.11.0
  • 📦 WebExtensions (mizchi/js_webextensions) - Split out in v0.11.0
  • 📦 React / NPM Packages - Maintained at mizchi/npm_typed
  • 📦 Cloudflare Workers - Maintained at mizchi/cloudflare.mbt

Goals

  • Provide comprehensive JavaScript FFI bindings for MoonBit
  • Platform Coverage (split across mizchi/js_* modules)
    • ✅ Browser DOM and Web APIs (mizchi/js_browser)
    • ✅ Node.js (bundled with mizchi/js) / Deno (mizchi/js_deno) / Bun (mizchi/js_bun)
    • ✅ JavaScript built-in objects and Web Standard APIs (mizchi/js)
  • Ecosystem

Quick Start

Basic FFI Operations

// Create JavaScript objects
let obj = @js.from_entries([
  ("name", @js.any("Alice")),
  ("age", @js.any(30))
])

// Get property
let name = obj["name"]

// Set property
obj["age"] = @js.any(31)

// Call method
let result = obj._call("toString", [])

// Type casting
let age: Int = obj["age"].cast()

LICENSE

MIT

Contributors

mizchi

1,172 commits

claude

34 commits

uuumm

2 commits

mizchi/js.mbt

Moonbit Js bindings

MoonBit

77

1,220 commits

updated Sep 16, 2026

See the code

README

mizchi/js

Comprehensive JavaScript/ FFI bindings for MoonBit, supporting multiple runtimes and platforms.

Import only what you need

0.13.0 split this library into nine modules. Depend on the ones your target actually has, and nothing else — a Cloudflare Worker no longer drags in node:fs, a CLI no longer drags in the DOM.

ModuleScope
mizchi/js_coreAny, Promise, Nullable, the raw FFI — everything depends on this
mizchi/js_builtinJS built-ins: Object, Array, JSON, RegExp, Date, Map/Set, ArrayBuffer, …
mizchi/js_webWeb Standards: fetch, Request/Response, URL, Streams, Blob, File, WebSocket, Crypto, Workers
mizchi/js_nodeNode.js: fs, http, path, stream, child_process, sqlite, …
mizchi/js_browserBrowser-only: DOM, canvas, IndexedDB, storage, navigation, service worker
mizchi/js_denoDeno runtime APIs
mizchi/js_bunBun runtime APIs
mizchi/js_webextensionsWebExtensions (chrome.* / browser.*)
mizchi/js_convertMoonBit ⇔ JS value conversion (Map/Json/Option/ResultAny)
mizchi/jsMeta package — re-exports js_core + js_builtin for when you want one import

Dependencies only ever point toward js_core:

js_core <- js_builtin <- js_web <- js_node / js_browser / js_deno
                     <- js_bun
        <- js_convert
        <- js_webextensions

You only declare what you import directly; the modules those pull in resolve on their own.

Bindings that live outside this repo:

ModuleScope
mizchi/npm_typedNPM package bindings (React, Hono, Zod, AI SDK, …)
mizchi/cloudflare.mbtCloudflare Workers bindings

📖 User Guide — which modules to pick, aliases, per-runtime recipes, and the 0.12.x → 0.13.0 migration table.

Installation

moon add mizchi/js_core
moon add mizchi/js_web       # ...and whatever else you need

moon.mod:

import {
  "mizchi/js_core@0.13.0",
  "mizchi/js_web@0.13.0",
}

moon.pkg — the default alias is the last path segment, so give the module-root packages a short one:

import {
  "mizchi/js_core" @core,
  "mizchi/js_web/http",
}

Version Requirements

Developed and CI-tested against:

moon 0.1.20260915
moonc v0.10.13

CI tracks the latest MoonBit release, so a recent toolchain is the supported configuration. For the older stable toolchain, use v0.8.x.

📚 API Documentation by Platform

PlatformDocumentationExamplesStatus
Core JavaScriptmodules/js_core/README.mdjs_examples.mbt.md🧪 Tested
Browsermodules/js_browser/README.mdbrowser_examples.mbt.md🧪 Tested
Node.jsmodules/js_node/README.mdnode_examples.mbt.md🧪 Tested
Denomodules/js_deno/README.md-🧪 Tested
Reactmizchi/npm_typedSee npm_typed repo📦 Moved

📖 Learning Resources

Supported Modules

Status Legend

  • 🧪 Tested: Comprehensive test coverage, production ready
  • 🚧 Partially: Core functionality implemented, tests incomplete
  • 🤖 AI Generated: FFI bindings created, needs testing
  • 📅 Planned: Scheduled for future implementation
  • Not Supported: Technical limitations

Core JavaScript APIs

mizchi/js_core - Core FFI Package

The mizchi/js_core package provides the foundation for JavaScript interoperability in MoonBit:

Type System

  • Any - Opaque type for JavaScript values
  • Nullable[T] - Represents null | T
  • Nullish[T] - Represents null | undefined | T
  • Union2[A,B] ~ Union5[A,B,C,D,E] - TypeScript union types (A | B)
  • Promise[T] - JavaScript Promise wrapper

FFI Operations (zero-cost conversions)

  • identity[A,B](value: A) -> B - Type casting using %identity
  • any[T](value: T) -> Any - Convert to Any
  • Any::cast[T](self) -> T - Cast from Any
  • obj["key"], obj["key"] = value - Property access (or _get(key), _set(key, value))
  • Any::_call(method, args), Any::_invoke(args) - Method calls

Object & JSON

  • new_object(), new_array() - Create JS objects/arrays
  • object_keys(), object_values(), object_assign(), object_has_own()
  • json_stringify(), json_parse(), json_stringify_pretty()

Async/Promise Support

  • run_async(f) - Execute async functions (MoonBit builtin %async.run)
  • suspend(f) - Await promises (MoonBit builtin %async.suspend)
  • promisify0 ~ promisify3 - Convert callbacks to promises
  • Promise utilities: resolve, reject, all, race, any, withResolvers

Error Handling

  • JsError - Generic JS error type
  • ThrowError - Wrapper for thrown errors
  • try_sync(op) - Safe wrapper converting JS exceptions to MoonBit errors
  • throwable(f) - Convert JS exceptions to ThrowError
  • export_sync(op) - Convert MoonBit errors to JS exceptions
  • throw_error(msg) - Throw JS Error

Type Checking

  • is_object(), is_array(), is_null(), is_undefined(), is_nullish()

Nullish Utilities

  • Nullish::to_option(), Nullable::to_option() - Convert to MoonBit Option
  • nullable(opt) - Convert Option to JS nullable
  • as_any(opt) - Convert Option[Any] to Any

API Summary

CategoryPackageStatusNote
Core FFI & Objects
Core FFImizchi/js_core🧪 Testedget, set, call, etc.
Objectmizchi/js_builtin/object🧪 TestedObject manipulation
Functionmizchi/js_builtin/function🧪 TestedFunction operations
Promisemizchi/js_core🧪 TestedAsync/Promise API
Errormizchi/js_builtin/error🧪 TestedError handling
JSONmizchi/js_builtin/json🧪 TestedJSON parse/stringify
Iteratormizchi/js_builtin/iterator🧪 TestedJS Iterator protocol
AsyncIteratormizchi/js_builtin/iterator🧪 TestedAsync iteration
WeakMap/Set/Refmizchi/js_builtin/weak🧪 TestedWeak references
Async Helpers
run_asyncmizchi/js_core🧪 TestedAsync execution
suspendmizchi/js_core🧪 TestedPromise suspension
sleepmizchi/js_core🧪 TestedDelay execution
promisifymizchi/js_core🧪 TestedCallback → Promise

JavaScript Built-ins

All JavaScript built-in objects are exported from mizchi/js:

CategoryPackageStatusNote
Global Functions
Globalmizchi/js_builtin/global🧪 TestedglobalThis, parseInt, parseFloat, setTimeout etc.
Core Types
Objectmizchi/js_builtin/object🧪 TestedObject manipulation
Functionmizchi/js_builtin/function🧪 TestedFunction operations
Symbolmizchi/js_builtin/symbol🧪 TestedSymbol primitive
Errormizchi/js_builtin/error🧪 TestedError types (TypeError, RangeError, etc.)
Primitives & Data
Stringmizchi/js_builtin/string🧪 TestedJsString (String methods)
Arraymizchi/js_builtin/array🧪 TestedJsArray (Array methods)
BigIntmizchi/js_builtin/bigint🧪 TestedJsBigInt (arbitrary precision)
JSONmizchi/js_builtin/json🧪 TestedJSON parse/stringify
Date & Math
Datemizchi/js_builtin/date🧪 TestedDate/time operations
Mathmizchi/js_builtin/math🧪 TestedMath operations
Collections
Map/Setmizchi/js_builtin/collection🧪 TestedJsMap, JsSet
WeakMap/Set/Refmizchi/js_builtin/weak🧪 TestedWeakMap, WeakSet, WeakRef, FinalizationRegistry
Binary Data
ArrayBuffermizchi/js_builtin/arraybuffer🧪 TestedBinary buffers
DataViewmizchi/js_builtin/arraybuffer🧪 TestedBuffer views
memory
Pattern & Reflection
RegExpmizchi/js_builtin/regexp🧪 TestedRegular expressions
Reflectmizchi/js_builtin/reflect🧪 TestedReflection API
Proxymizchi/js_builtin/proxy🤖 AI GeneratedProxy API
Iteration & Async
Iteratormizchi/js_builtin/iterator🧪 TestedJsIterator protocol
AsyncIteratormizchi/js_builtin/iterator🧪 TestedAsync iteration
Concurrency
Atomicsmizchi/js_builtin/atomics🧪 TestedAtomic operations
Resource Management
DisposableStackmizchi/js_builtin/disposable🧪 TestedDisposable resources

Web Standard APIs

Platform-independent Web Standard APIs (browsers, Node.js, Deno, edge runtimes), shipped as the separate mizchi/js_web module:

See mizchi/js_web for detailed Web APIs documentation

CategoryPackageStatusNote
Consolemizchi/js_web/console🧪 Testedconsole.log, console.error, etc.
fetchmizchi/js_web/http🧪 TestedHTTP requests
Requestmizchi/js_web/http🧪 TestedRequest objects
Responsemizchi/js_web/http🧪 TestedResponse objects
Headersmizchi/js_web/http🧪 TestedHTTP headers
FormDatamizchi/js_web/http🧪 TestedForm data
URLmizchi/js_web/url🧪 TestedURL parsing
URLSearchParamsmizchi/js_web/url🧪 TestedQuery strings
URLPatternmizchi/js_web/url🧪 TestedURL pattern matching
Blobmizchi/js_web/blob🧪 TestedBinary data
ReadableStreammizchi/js_web/streams🧪 TestedStream reading
WritableStreammizchi/js_web/streams🧪 TestedStream writing
TransformStreammizchi/js_web/streams🧪 TestedStream transformation
CompressionStreammizchi/js_web/streams🧪 TestedGZIP/Deflate compression
DecompressionStreammizchi/js_web/streams🧪 TestedGZIP/Deflate decompression
TextEncodermizchi/js_web/encoding🧪 TestedString to Uint8Array
TextDecodermizchi/js_web/encoding🧪 TestedUint8Array to String
Eventmizchi/js_web/event🧪 TestedEvent objects
CustomEventmizchi/js_web/event🧪 TestedCustom events
MessageEventmizchi/js_web/event🧪 TestedMessage events
Cryptomizchi/js_web/crypto🧪 TestedWeb Crypto API
WebSocketmizchi/js_web/websocket🧪 TestedWebSocket API
Workermizchi/js_web/worker🧪 TestedWeb Workers
MessageChannelmizchi/js_web/message🧪 TestedMessage passing
MessagePortmizchi/js_web/message🧪 TestedMessage ports
WebAssemblymizchi/js_web/webassembly🤖 AI GeneratedWASM integration
Performancemizchi/js_web/performance🤖 AI GeneratedPerformance API

Runtime-Specific APIs

Web Standard, Node.js, Browser, Deno, Bun, and WebExtensions APIs ship as separate mizchi/js_* modules — add each one to your moon.mod import list only if you need it.

PlatformModuleStatusDocumentation
Web Standardsmizchi/js_web/*🧪 TestedWeb README
Node.jsmizchi/js_node/*🧪 TestedNode.js README
Browser APImizchi/js_browser/*🧪 TestedBrowser README
Denomizchi/js_deno🧪 TestedDeno README
Bunmizchi/js_bun🤖 AI Generated-
WebExtensionsmizchi/js_webextensions🤖 AI GeneratedWebExtensions README

NPM Package Bindings

Moved to separate repository: NPM package bindings are now maintained at mizchi/npm_typed

CategoryPackagesRepository
UI FrameworksReact, React DOM, React Router, Preact, Inkmizchi/npm_typed
Web FrameworksHono, better-authmizchi/npm_typed
AI / LLMVercel AI SDK, MCP SDK, Claude Code SDKmizchi/npm_typed
Cloud Services@aws-sdk/client-s3 (S3, R2, GCS, MinIO)mizchi/npm_typed
DatabasePGlite, DuckDB, Drizzle, pgmizchi/npm_typed
ValidationZod, AJVmizchi/npm_typed
Build ToolsTerser, Vite, Unplugin, Lighthousemizchi/npm_typed
Utilitiesdate-fns, semver, chalk, dotenv, chokidar, yargs, debugmizchi/npm_typed
TestingTesting Library, Puppeteer, Playwright, Vitest, JSDOM, MSWmizchi/npm_typed
Parsinghtmlparser2, js-yamlmizchi/npm_typed
Othersimple-git, ignore, memfs, source-map, comlinkmizchi/npm_typed

Limited Support APIs

FeatureStatusNote
eval()❌ Not SupportedSecurity and type safety concerns
new Function()❌ Not SupportedSecurity and type safety concerns

Project Status

  • 📦 FFI foundation (mizchi/js_core) - Any, Promise, Nullable, target-specific interop. Split out into its own module
  • 📦 JS built-ins (mizchi/js_builtin) - Object, Array, JSON, RegExp, Symbol, Proxy, ... Split out into its own module
  • 📦 MoonBit ⇔ JS conversion (mizchi/js_convert) - Map/Json/Option/ResultAny, runtime type inspection. Split out into its own module
  • mizchi/js - meta package re-exporting js_core + js_builtin, plus the wasm-gc entry
  • 📦 Web Standards (mizchi/js_web) - fetch, URL, Streams, Blob, Crypto, WebSocket, Workers. Split out into its own module
  • 📦 Node.js Core APIs (mizchi/js_node) - fs, path, process, child_process, etc. Split out into its own module
  • 📦 Browser / DOM (mizchi/js_browser) - Split out in v0.11.0
  • 📦 Deno Runtime (mizchi/js_deno) - Split out in v0.11.0
  • 📦 Bun Runtime (mizchi/js_bun) - Split out in v0.11.0
  • 📦 WebExtensions (mizchi/js_webextensions) - Split out in v0.11.0
  • 📦 React / NPM Packages - Maintained at mizchi/npm_typed
  • 📦 Cloudflare Workers - Maintained at mizchi/cloudflare.mbt

Goals

  • Provide comprehensive JavaScript FFI bindings for MoonBit
  • Platform Coverage (split across mizchi/js_* modules)
    • ✅ Browser DOM and Web APIs (mizchi/js_browser)
    • ✅ Node.js (bundled with mizchi/js) / Deno (mizchi/js_deno) / Bun (mizchi/js_bun)
    • ✅ JavaScript built-in objects and Web Standard APIs (mizchi/js)
  • Ecosystem

Quick Start

Basic FFI Operations

// Create JavaScript objects
let obj = @js.from_entries([
  ("name", @js.any("Alice")),
  ("age", @js.any(30))
])

// Get property
let name = obj["name"]

// Set property
obj["age"] = @js.any(31)

// Call method
let result = obj._call("toString", [])

// Type casting
let age: Int = obj["age"].cast()

LICENSE

MIT

Contributors

mizchi

1,172 commits

claude

34 commits

uuumm

2 commits

Languages

MoonBit

91.8%

TypeScript

7.4%