Skip to content
Moku
@moku-labs/native pages

tauri

The only subprocess seam: argv builders, process-group dev, error taxonomy, secret scrubbing.

On this page

What it does

tauri is the one place that spawns a process. It builds the arguments for @tauri-apps/cli, streams scrubbed output, classifies failures and owns the lifetime of a dev session.

How it works

The runner. The CLI needs Node, so every verb spawns an absolute node and tauri.js pair. The first iOS build writes the same pair into the Xcode project, because Tauri's bare node tauri does not resolve inside Xcode.

Scrubbing. Every output line is scrubbed before it can reach a log or a callback. stderrTail on a TauriError is already safe.

Dev. There is no "ready" line on stdout, so dev() polls web.devUrl. A second dev() while one runs throws. A stop escalates to a process-group kill.

Config

pluginConfigs.tauri.

OptionTypeDefaultDescription
readiness{ intervalMs, timeoutMs }{ intervalMs: 250, timeoutMs: 60000 }The web.devUrl poll.
nodePathstringfound on PATHAn explicit node.
archNodeJS.Architectureprocess.archThe host arch behind the iOS simulator slice. x64 gives --target x86_64, others --target <arch>-sim.
spawnImplSpawnFna real process-group spawnTest seam.

API

Mounted at app.tauri.

MethodSignatureDescription
icon(opts: { source }) => Promise<RunResult>tauri icon into src-tauri/icons.
build(opts: BuildOptions) => Promise<RunResult>tauri build, or the ios or android form. Takes the flavor flags, exportMethod, onTick, onOutput and env.
mobileInit(opts: { target }) => Promise<RunResult>tauri ios init or tauri android init. Only call it when project.getCompleteness says not-initialized.
dev(opts: { target?, onOutput? }) => Promise<DevHandle>Returns at once. DevHandle is { url, ready, exited, stop() }.
getVersion() => Promise<{ cliVersion } | undefined>undefined when the CLI cannot run.
getRunner() => TauriRunnerThe absolute pair. Throws when node or the CLI cannot be found.

Events

None. Output comes through the callbacks.

Depends on

Nothing. It reads projectDir and web.devUrl from the global config, and PATH through env.

Example

scripts/native-tail.ts
import { TauriError } from "@moku-labs/native";
import { native } from "../src/native";

await native.start();

const handle = await native.tauri.dev({ onOutput: line => console.log(line) });
await handle.ready;
console.log("up on", handle.url);
await handle.stop();

try {
  await native.tauri.icon({ source: "assets/icon.png" });
} catch (error) {
  if (error instanceof TauriError) console.error(error.kind, error.exitCode, error.stderrTail);
}

await native.stop();
  • tauri.build is one step. It does not generate anything. Use build.run unless you already have the tree.
  • env never changes the arguments. The debug and dev profiles are still release builds, with no --debug.