original
https://github.com/helix-editor/helix/blob/master/runtime/tutor
原文のキー表記・コマンドはそのまま残し、説明文のみ日本語に訳しています。
| // deno run -A compile-mbt.ts | |
| import * as comlink from "npm:comlink@4.4.2"; | |
| const mooncWorkerPath = import.meta.resolve( | |
| "npm:@moonbit/moonc-worker@0.1.202601213/moonc-worker.js" | |
| ); | |
| // 標準ライブラリの .mi ファイルを読み込む | |
| function getStdMiFiles(target = "js"): [string, Uint8Array][] { | |
| const home = Deno.env.get("HOME") || ""; |
| // JSON Parser in Wado - TDD approach | |
| // Goal: Verify if Wado can implement a JSON parser | |
| use {println, Stdout} from "core:cli"; | |
| // ============================================================================= | |
| // Parser State | |
| // ============================================================================= | |
| struct Parser { |
| // Minimal Baseline JIT for WebAssembly (ARM64) | |
| // Zig implementation | |
| const std = @import("std"); | |
| const fs = std.fs; | |
| const mem = std.mem; | |
| const Allocator = std.mem.Allocator; | |
| // ============================================================================ | |
| // Code buffer for JIT compilation |
original
https://github.com/helix-editor/helix/blob/master/runtime/tutor
原文のキー表記・コマンドはそのまま残し、説明文のみ日本語に訳しています。
This document analyzes the bundle size of MoonBit JavaScript output, identifying the main contributors to code size and potential optimization opportunities.
Note: The analyzed output is after terser DCE (Dead Code Elimination) with compress enabled. Unused code has already been removed.
https://github.com/mizchi/js.mbt/blob/main/src/examples/aisdk/main.mbt
Moonbit FFI Core
///|
#external
pub type JsValue
///|
pub fn[T] JsValue::cast(self : JsValue) -> T = "%identity"| /// original https://github.com/moonbit-community/jmop/blob/main/promise.mbt | |
| ///| | |
| extern "js" fn ffi_promise_resolve(x : Value) -> Value = "(x) => Promise.resolve(x)" | |
| ///| | |
| extern "js" fn ffi_promise_reject(e : Error) -> Value = "(x) => Promise.reject(x)" | |
| ///| | |
| extern "js" fn ffi_promise_then( |
| ```mbt | |
| async fn[T, U] map_async(arr: Array[T], f: async (T) -> U raise?) -> Array[U] raise? { | |
| let res: Array[U] = [] | |
| for item in arr { | |
| res.push(f(item)) | |
| } | |
| res | |
| } | |
| async test { |
///|
extern "js" fn ffi_request_animation_frame(f : () -> Unit) -> Unit =
#|(f) => {
#| if (globalThis.requestAnimationFrame) {
#| requestAnimationFrame(f)
#| } else {
#| setTimeout(f, 0) // fallback
#| }
#|}