quickjs_runtime 0.3.5
quickjs_runtime: ^0.3.5 copied to clipboard
Pure-Dart QuickJS JavaScript runtime on dart:ffi with synchronous host callbacks. Vendored QuickJS 2024-01-13 + a C bridge with JSON marshaling.
0.3.4 #
Added #
AsyncEnginePool.attachMainRuntimeaccepts a per-runtimedispatchContextprovider: therunAsyncdispatch path now captures context per main engine (overriding the pool-level default), so a shared pool can serve main engines whose dispatch context differs per engine (script directory, job params, ...). Explicitdispatch( context: ...)still wins over both providers. Consumer-opaque, must be SendPort-safe (plain JSON-ish values).
0.3.3 #
- Conformance fixture v2: byte-identical cross-runtime script with
Buffer/URL/utilExtras/osProcess/events/fetchShapes/parallel sections
plus a timer-protocol family (
actionTimers+drainTimers). util: legacy Node predicates —isArray,isString,isNumber,isBoolean,isNull,isUndefined,isFunction.util.inspect: strings are now always single-quoted (Node semantics).util.format: extra string args inserted raw; non-strings inspected (previously everything was JSON.stringify-ed).
0.3.2 #
Fixes the native-library path join for pub.flutter-io.cn (hosted) checkouts:
the package_config fallback built
<root>native/quickjs/libquickjs_bridge.so without a separator when
rootUri has no trailing slash (hosted) — workers died with
Failed to load dynamic library ...0.3.1native/.... Also mirrors the
stringified-env shim into the async prelude (require('os')). No API
changes.
0.3.1 #
Restores the sync fetch and timers / microtask auto-drain /
require('events') features: their stacked PRs (#7, #8) were merged
out-of-band and their commits were not part of the main tree the
0.3.0 tarball was published from — the 0.3.0 section below documents
the intended surface, but only 0.3.1 actually ships it. Internally the
async surface now lives in its own prelude
(node_compat_async.dart); require('events')/require('os')
registration moved from the core builtin map into that prelude. No
other API or behavior changes.
0.3.0 #
-
Sync
fetch(opt-in):NodeCompatConfig.httpFetchhook + realHeaders/Response(text()/json()/arrayBuffer(),bodyUsed,ok/status/headers); failures surface asTypeError: fetch failedwithcause. Bodies are plain values, soawait res.text()works through them;AbortSignalis not supported (documented deviation). Without the hook,fetchstays a self-documenting stub — the runtime remains I/O-clean. -
Real timers + microtask auto-drain + events: promise reactions,
queueMicrotaskandprocess.nextTicknow actually run — the QuickJS pending-job queue is drained (capped) after every successful eval.setTimeout/setInterval/setImmediate+clear*are real, host-driven callbacks viaNodeCompatHandle.drainTimers()inready(default, UI-safe) /block(sleeps until the nearest reffed timer — CLI "setTimeout as sleep") /nonemodes, withunref(), a callback-count guard and a wall-clock budget.require('events')provides the full synchronousEventEmitter. -
Node parity pack (issue #3 follow-up): real
Buffer(Uint8Array subclass, Node encodings + LE/BE accessors),URL/URLSearchParams(WHATWG subset verified against real Node),console.time/table/group/count/dir/trace, Node-styleutil.inspect,os+url+bufferbuiltin modules,process.argv/pid/hrtime/uptime/memoryUsage/stdout/stderr/on('exit'),__filename/__dirname(+NodeCompatHandle.setScriptPath), typeof-safeIntlstubs. Default text codecs are now real UTF-8 (dart:convert) — the latin-1 approximation is gone;Bufferremoved from tier-2 stubs;installNodeCompatreturns aNodeCompatHandle. -
Node/js compat layer (issue #3), opt-in via
installNodeCompat(rt, cfg):- Tier 1 — real:
global,console.*(pluggable sink),process(env/platform/arch/version/exitCode/cwd/exit),path(posix subset),assert(node-like subset),util(subset),TextEncoder/TextDecoder(utf-8),atob/btoa,performance.now(),crypto.randomUUID()/getRandomValues(),structuredClone(JSON fidelity),require()builtin registry + consumer modules (installNodeCompatModule) + fallback to a pre-existing loader. - Tier 2 — self-documenting stub:
AbortController—typeof-safe, throws the alternative on call (fetch has no signal support yet). - Host hooks: env, cwd, clock, secure random, utf-8/base64 codecs, console sink, exit notification. Without hooks, safe defaults.
- Tier 1 — real:
0.2.0 #
AsyncEnginePool: pre-spawned engine-worker isolates for parallel JavaScript execution over the synchronous host-callback bridge. Consumer owns the worker body (top-levelAsyncWorkerMainwith anAsyncWorkerLinknext/complete protocol, or a simplerAsyncJobExecutorone-engine-per-job hook); the pool owns transport and lifecycle — dispatch/wait mailbox protocol (pthreads condvar vianative_synchronization), FIFO backpressure, fire-and-forget envelope caching, dead-worker error completion.runAsync(fn, args)scripting surface:AsyncEnginePool.attachMainRuntimeregisters the__jsrDispatchHost/__jsrWaitHosthost functions and the prelude exposingrunAsync/AsyncJob/runAsync.allwith a blockingwait().runAsyncJobOnRuntime: runs one dispatched (closure-free) function on a consumer-wired runtime and returns itsAsyncJobEnvelope.
0.1.0 #
- Initial release: QuickJS 2024-01-13 runtime on
dart:ffiwith synchronous host callbacks (NativeCallable). QuickjsRuntime: eval (JSON results),registerHostFunction,setGlobal,executePendingJobs,close.QuickjsFfi: flat C ABI bindings toquickjs_bridge.c(JSON marshaling).tool/build_quickjs.shbuildslibquickjs_bridge.so(gcc); lookup viaJSR_QUICKJS_LIB,.dart_tool/package_config.json, script dir, or cwd.