QjsProcessRuntime class final
A JsrRuntime over a qjs subprocess using the stdio wire protocol.
Engine resolution: explicit binary override, then the FA_QJS_BIN
environment variable, then qjs from PATH. A missing binary surfaces as
ExtEngineUnavailableException (spawn ProcessException), never a raw
crash.
Wire protocol (host side): one JSON object per \n line.
- JS→host bridge request
{seq, method, args}— answered with{seq, ok, value}or{seq, ok: false, error}viabridges. - Host→JS invoke
{invoke, fn, args}— answered with{invoke, ok, value}or{invoke, ok: false, error}. {fatal: m}— bootstrap/main failure; fails start and every pending call withExtProtocolException.
Constructors
- QjsProcessRuntime({Duration startTimeout = const Duration(seconds: 30), String? binary})
Properties
-
commitPayload
→ Future<
Map< String, dynamic> > -
Registration payload returned by
__extCommit. Fails when start has not completed.no setter - engineId → String
-
'qjs-process'|'flutter-js'|'web-worker'|'qjs-wasm'|'fake'.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- lastStderr → String
-
Last engine diagnostics lines (stderr + stdout notes) — see
ExtEngineRouter.lastNotes.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startTimeout → Duration
-
Bound for start (spawn +
__extCommitround trip). Overrun kills the engine with SIGKILL and surfaces TimeoutException.final
Methods
-
answerBridge(
int seq, String method, Object? args) → void -
Answers a
{seq, method, args}bridge request on stdin. -
dispose(
) → Future< void> - SIGTERM, 2s grace, SIGKILL, then deletes the temp script directory. Idempotent.
-
invoke(
String fn, List< Object?> args, {Duration? timeout}) → Future<Object?> -
Invokes the global JS function
fnwith JSON-ableargs; resolves with a JSON-able result. Implementations enforcetimeout(kill/dispose on overrun =>TimeoutException). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
note(
String line) → void - Records one diagnostic line in the engine stderr buffer.
-
start(
{required String bootstrapJs, required String mainJs, required ExtBridgeHandler bridges}) → Future< void> -
Bootstraps the engine: evaluates
bootstrapJs(engine transport + shared core, seeext_bootstrap_js.dart) thenmainJs(the extension source), and must resolve only after__extCommit()returned the registration payload.bridgesdispatches the extension'sjsr.ext.*host calls. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
composeScript(
String bootstrapJs, String mainJs) → String -
The exact extension script handed to
qjs(composition defined incomposeExtScript). -
engineProbe(
) → Future< String> -
Verifies the resolved qjs binary by running
<bin> -e 'print(1)'and returns a version string (<bin> -v, falling back to the binary path). ThrowsExtEngineUnavailableExceptionwhen the binary is missing or broken. Used byfa ext list. -
resolveBinary(
{String? binaryOverride}) → String -
Resolves the qjs binary:
binaryOverride, thenFA_QJS_BIN, thenPATH.