@moku-labs/native 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,18 +1,62 @@
1
+ import { createRequire } from "node:module";
1
2
  import { EnvApi, LogApi } from "@moku-labs/common";
2
- import { EmitFn } from "@moku-labs/core";
3
+ import { PluginCtx } from "@moku-labs/core";
4
+ import { BrandConsole } from "@moku-labs/common/cli";
3
5
 
6
+ //#region \0rolldown/runtime.js
7
+ //#endregion
4
8
  //#region src/config.d.ts
5
- /** The five packaging targets (D1 — all five in v1). */
9
+ /** The five packaging targets shipped in v1. */
6
10
  declare const TARGETS: readonly ["macos", "windows", "linux", "ios", "android"];
7
11
  /** A native packaging target. */
8
12
  type Target = (typeof TARGETS)[number];
13
+ /**
14
+ * The two targets that own a `src-tauri/gen/<platform>` tree — the init/completeness/patch
15
+ * story is theirs alone, so every mobile-only signature takes this instead of `Target`.
16
+ */
17
+ type MobileTarget = Extract<Target, "ios" | "android">;
18
+ /**
19
+ * The absolute `node` + `tauri.js` pair every Tauri invocation is spawned with. The `tauri`
20
+ * plugin resolves it, and `project` writes the SAME pair into the generated Xcode/Gradle
21
+ * build phases, where Tauri's own generator emits a bare `node tauri` that does not exist.
22
+ */
23
+ type TauriRunner = {
24
+ nodePath: string;
25
+ tauriJsPath: string;
26
+ };
27
+ /**
28
+ * Which artifact flavour a mobile build produces. Shared verbatim by `tauri.build`,
29
+ * `build.run`/`build.runAll`, `cli.build` and the collect phase, so one flag set travels
30
+ * the whole pipeline instead of being re-declared per layer. A target that does not use a
31
+ * flag ignores it rather than failing.
32
+ */
33
+ type BuildFlavor = {
34
+ /** iOS: build the host's simulator slice instead of a signed device archive. */simulator?: boolean | undefined; /** Android: emit a store bundle (`.aab`) instead of the default installable `.apk`. */
35
+ aab?: boolean | undefined;
36
+ };
37
+ /**
38
+ * Resolves the packaging targets a host can build with no extra opt-in — the default
39
+ * `config.targets`. Exactly one desktop target per host (`darwin` → `macos`,
40
+ * `win32` → `windows`, `linux` → `linux`), and an empty list for any other host.
41
+ *
42
+ * Mobile is never inferred: `ios`/`android` need an SDK the host may not have, so a
43
+ * consumer asks for them explicitly via `config.targets`.
44
+ *
45
+ * @param platform - The host platform id (`process.platform`).
46
+ * @returns The targets that host packages by default — frozen-safe, never mobile.
47
+ * @example
48
+ * ```ts
49
+ * createApp({ config: { targets: [...hostTargets(process.platform), "ios"] } });
50
+ * ```
51
+ */
52
+ declare function hostTargets(platform: NodeJS.Platform): readonly Target[];
9
53
  /** Pipeline phases in execution order — drives NativePhase and progress rendering (mirrors web's PHASE_ORDER). */
10
54
  declare const PHASE_ORDER: readonly ["scaffold", "codegen", "icons", "compile", "bundle", "collect"];
11
55
  /** A build pipeline phase. */
12
56
  type NativePhase = (typeof PHASE_ORDER)[number];
13
57
  /**
14
58
  * Per-capability packaging parameters — ONE map drives both `Config["capabilities"]`
15
- * and project's `resolve<K extends keyof CapabilityConfigMap>` (S2-refined; spec/09 §3/§5 technique).
59
+ * and project's `resolve<K extends keyof CapabilityConfigMap>` (refined; spec/09 §3/§5 technique).
16
60
  * deep-link is custom-scheme-only in v1 (D-011); the `mode` discriminant keeps `"universal"` additive later.
17
61
  */
18
62
  type CapabilityConfigMap = {
@@ -25,11 +69,31 @@ type CapabilityConfigMap = {
25
69
  scheme: string;
26
70
  };
27
71
  };
72
+ /** How `tauri ios build` exports the signed archive (`--export-method`). */
73
+ type AppleExportMethod = "app-store-connect" | "release-testing" | "debugging";
74
+ /**
75
+ * Apple signing identifiers for macOS and iOS builds — identifiers only, never secrets.
76
+ * Credentials stay in the environment and Tauri reads them itself: `APPLE_ID`,
77
+ * `APPLE_PASSWORD`, `APPLE_TEAM_ID`, `APPLE_API_KEY`, `APPLE_API_ISSUER`,
78
+ * `APPLE_API_KEY_PATH`, `APPLE_CERTIFICATE`, `APPLE_CERTIFICATE_PASSWORD`.
79
+ */
80
+ type AppleSigning = {
81
+ /** Apple Developer team id → `bundle.iOS.developmentTeam`. */teamId?: string; /** Codesign identity → `bundle.macOS.signingIdentity`; `"-"` means ad-hoc. */
82
+ signingIdentity?: string; /** Multi-team notarization provider → `bundle.macOS.providerShortName`. */
83
+ providerShortName?: string; /** Consumer entitlements plist, relative to cwd → `bundle.macOS.entitlements`. */
84
+ entitlements?: string; /** Generate a sandbox entitlements file for the App Store when `entitlements` is unset. */
85
+ appStore?: boolean; /** Archive export method passed to `tauri ios build`. */
86
+ exportMethod?: AppleExportMethod; /** Minimum macOS version → `bundle.macOS.minimumSystemVersion`. */
87
+ macosMinimumSystemVersion?: string; /** Minimum iOS version → `bundle.iOS.minimumSystemVersion`. */
88
+ iosMinimumSystemVersion?: string;
89
+ };
28
90
  /** Signing configuration — env-var REFERENCES and config-safe identifiers only, never raw secrets. */
29
91
  type SigningConfig = {
92
+ apple?: AppleSigning;
30
93
  android?: {
31
94
  keystorePath?: string;
32
- keystorePasswordEnv?: string;
95
+ keystorePasswordEnv?: string; /** Key password env-var name; falls back to `keystorePasswordEnv` when unset. */
96
+ keyPasswordEnv?: string;
33
97
  keyAlias?: string;
34
98
  };
35
99
  windows?: {
@@ -41,24 +105,31 @@ type SigningConfig = {
41
105
  * Required-with-defaults fields keep the complete-C default literal valid under exactOptionalPropertyTypes.
42
106
  */
43
107
  type Config = {
44
- /** App identity — project.onInit validates name/identifier are non-empty (reverse-DNS identifier). */app: {
108
+ /**
109
+ * App identity and store metadata — project.onInit validates name/identifier are
110
+ * non-empty (reverse-DNS identifier). `icon` is a 1024x1024 PNG relative to cwd
111
+ * (a placeholder is generated when unset); `category` maps to `bundle.category`;
112
+ * `buildNumber` maps to the iOS/macOS `bundleVersion`.
113
+ */
114
+ app: {
45
115
  name: string;
46
116
  identifier: string;
47
117
  version?: string;
48
- }; /** Web build/dev wiring codegenned into tauri.conf.json (S3). cwd for monorepo layouts (S3-refined). */
118
+ icon?: string;
119
+ category?: string;
120
+ buildNumber?: string;
121
+ }; /** Web build/dev wiring codegenned into tauri.conf.json. cwd for monorepo layouts. */
49
122
  web: {
50
123
  build: string;
51
- dev: {
52
- command: string;
53
- url: string;
54
- };
124
+ devCommand: string;
125
+ devUrl: string;
55
126
  dist: string;
56
127
  cwd?: string;
57
128
  }; /** Composed `@moku-labs/system` plugins — the kernel-guaranteed name-only contract (spec/03 §1). */
58
129
  system: ReadonlyArray<{
59
130
  name: string;
60
131
  }>; /** Per-capability packaging parameters. */
61
- capabilities: Partial<CapabilityConfigMap>; /** Targets this app ships (D1 default: all five). */
132
+ capabilities: Partial<CapabilityConfigMap>; /** Targets this app ships (default: the host's own desktop target — see {@link hostTargets}). */
62
133
  targets: readonly Target[]; /** Generated Tauri project root (contains src-tauri/). Gitignored build output. */
63
134
  projectDir: string; /** Installer delivery root. */
64
135
  outDir: string; /** Signing env-var references. */
@@ -86,16 +157,29 @@ type Events = {
86
157
  "native:phase": NativePhaseEvent;
87
158
  "native:complete": NativeCompleteEvent;
88
159
  };
160
+ //#endregion
161
+ //#region src/plugins/project/layout.d.ts
162
+ /** One bundle format Tauri writes: its output directory, and the artifact glob inside it. */
163
+ type BundleFormat = {
164
+ /** Directory name under `<root>/bundle/`. */readonly directory: string; /** Glob matching the finished artifact in that directory. */
165
+ readonly pattern: string;
166
+ };
167
+ /** Where one target's build output lives inside the generated project. */
168
+ type BundleLayout = {
169
+ /** Output root, relative to `projectDir`. */readonly root: string; /** Desktop bundle-format directories under `<root>/bundle/` — empty for a mobile target. */
170
+ readonly formats: readonly BundleFormat[]; /** The mobile `gen/<platform>` directory relative to `root` — undefined for desktop. */
171
+ readonly genDirectory: string | undefined;
172
+ };
89
173
  declare namespace types_d_exports$3 {
90
- export { Api$4 as Api, CleanResult, CompletenessResult, GenerateResult, ManifestEntry, PatchResult, PlistEntry, ProjectContext, RegistryRow, ResolvedCapability, TauriConfFragment };
174
+ export { Api$4 as Api, CleanResult, CompletenessResult, DeepLinkConf, GenerateResult, ManifestEntry, PatchMobileOptions, PatchResult, PlistEntry, ProjectContext, RegistryRow, ResolvedCapability, TauriConfFragment };
91
175
  }
92
176
  /** Result of a write-if-changed generation pass. */
93
177
  type GenerateResult = {
94
- written: string[];
95
- unchanged: string[];
96
- skipped: string[];
178
+ readonly written: readonly string[];
179
+ readonly unchanged: readonly string[];
180
+ readonly skipped: readonly string[];
97
181
  };
98
- /** Mobile gen/-tree gate — completeness (required-file set), not existence (S4 refinement). */
182
+ /** Mobile gen/-tree gate — completeness (required-file set), not existence. */
99
183
  type CompletenessResult = {
100
184
  status: "not-applicable";
101
185
  } | {
@@ -106,29 +190,55 @@ type CompletenessResult = {
106
190
  } | {
107
191
  status: "complete";
108
192
  };
109
- /** Result of the idempotent mobile patch pass (v1: Android signing only). */
193
+ /** Result of the idempotent mobile patch pass (Android signing + the mobile runner command). */
110
194
  type PatchResult = {
111
- patched: string[];
112
- unchanged: string[];
195
+ readonly patched: readonly string[];
196
+ readonly unchanged: readonly string[];
197
+ };
198
+ /** Options for one mobile patch pass. The runner patch is skipped when `runner` is absent. */
199
+ type PatchMobileOptions = {
200
+ target: MobileTarget;
201
+ runner?: TauriRunner | undefined;
113
202
  };
114
203
  /** Result of a clean pass. */
115
204
  type CleanResult = {
116
205
  removed: readonly string[];
117
206
  };
118
- /** One capability registry row — packaging metadata with per-row research confidence. */
207
+ /**
208
+ * One capability registry row — packaging metadata with per-row research confidence.
209
+ * A row is backed EITHER by a real Tauri plugin (crate + npm package + Rust init) or by
210
+ * a core Tauri cargo feature (tray), so every plugin-only field is optional and
211
+ * `cargoFeatures` is always present.
212
+ */
119
213
  type RegistryRow = {
120
214
  name: keyof CapabilityConfigMap;
121
- npmPackage: `@tauri-apps/plugin-${string}`;
122
- crate: `tauri-plugin-${string}`;
123
- crateRange: string;
124
- npmRange: string;
125
- rustInit: string;
215
+ npmPackage?: `@tauri-apps/plugin-${string}`;
216
+ crate?: `tauri-plugin-${string}`;
217
+ crateRange?: string;
218
+ npmRange?: string;
219
+ rustInit?: string; /** Cargo features this capability enables on the `tauri` dependency. */
220
+ cargoFeatures: readonly string[];
126
221
  permissions: readonly string[];
127
222
  platforms: readonly Target[];
128
223
  confidence: "high" | "medium" | "low";
129
224
  };
130
- /** A tauri.conf.json contribution fragment (plugins section + bundle metadata). */
131
- type TauriConfFragment = Record<string, unknown>;
225
+ /** The tauri.conf.json `plugins["deep-link"]` shape — desktop and mobile are separate keys. */
226
+ type DeepLinkConf = {
227
+ desktop: {
228
+ schemes: readonly string[];
229
+ };
230
+ mobile: ReadonlyArray<{
231
+ scheme: readonly string[];
232
+ appLink: boolean;
233
+ }>;
234
+ };
235
+ /**
236
+ * A tauri.conf.json `plugins.<name>` contribution — the union of the real v1 shapes. The
237
+ * empty member is the "this plugin takes no config" case: it is never written to
238
+ * tauri.conf.json, because such a plugin deserializes `unit` and a `{}` map there aborts
239
+ * the app at startup.
240
+ */
241
+ type TauriConfFragment = Record<string, never> | DeepLinkConf;
132
242
  /** An Info.ios.plist sidecar entry (src-tauri root, outside gen/) — empty for every v1 row. */
133
243
  type PlistEntry = {
134
244
  key: string;
@@ -146,12 +256,11 @@ type ResolvedCapability = RegistryRow & {
146
256
  manifest: readonly ManifestEntry[];
147
257
  };
148
258
  /**
149
- * Domain context for the project plugin's API factory. This plugin has no per-plugin
150
- * config/state — it consumes global config only (D-005) — so this is deliberately
151
- * narrower than the kernel's full `PluginContext`: just `global` + the injected `log`
152
- * core API (MC2).
259
+ * Domain context for the project plugin's API factory: core's `PluginCtx` (this plugin
260
+ * declares neither config nor state nor events — D-005, it reads global config only) plus
261
+ * the two fields core composes in per framework, `global` and the `log` core API (MC2).
153
262
  */
154
- type ProjectContext = {
263
+ type ProjectContext = PluginCtx<Record<string, never>, Record<string, never>> & {
155
264
  readonly global: Readonly<Config>;
156
265
  readonly log: LogApi;
157
266
  };
@@ -160,22 +269,63 @@ type Api$4 = {
160
269
  generate(opts: {
161
270
  target: Target;
162
271
  }): Promise<GenerateResult>;
163
- completeness(opts: {
272
+ getBundleLayout(opts: {
273
+ target: Target;
274
+ }): BundleLayout;
275
+ getCompleteness(opts: {
164
276
  target: Target;
165
277
  }): CompletenessResult;
166
- patchMobile(opts: {
167
- target: "ios" | "android";
168
- }): Promise<PatchResult>;
278
+ patchMobile(opts: PatchMobileOptions): Promise<PatchResult>;
169
279
  clean(opts?: {
170
- target?: Target;
280
+ target?: Target | undefined;
171
281
  }): Promise<CleanResult>;
282
+ clearMobileBuildOutput(opts: {
283
+ target: MobileTarget;
284
+ }): Promise<CleanResult>;
285
+ resolveDerivedPath(target: string): string;
286
+ ensureIconSource(): Promise<string>;
172
287
  resolve<K extends keyof CapabilityConfigMap>(name: K, config?: CapabilityConfigMap[K]): ResolvedCapability;
173
288
  isKnownCapability(name: string): name is keyof CapabilityConfigMap;
174
- registryRows(): ReadonlyArray<RegistryRow>;
175
- requiredFiles(platform: "ios" | "android"): readonly string[];
289
+ getRegistryRows(): ReadonlyArray<RegistryRow>;
290
+ getRequiredFiles(opts: {
291
+ target: MobileTarget;
292
+ }): readonly string[];
176
293
  };
294
+ //#endregion
295
+ //#region src/plugins/tauri/errors.d.ts
296
+ /**
297
+ * Thrown by every one-shot verb (`icon`/`build`/`mobileInit`) on a non-zero exit.
298
+ * Carries a classified {@link TauriErrorKind} and the scrubbed stderr tail so
299
+ * callers (`build`, `doctor`, `cli`) can render an actionable message without
300
+ * re-deriving the taxonomy or re-scrubbing raw output.
301
+ */
302
+ declare class TauriError extends Error implements TauriErrorDetails {
303
+ readonly kind: TauriErrorKind;
304
+ readonly exitCode: number | null;
305
+ readonly stderrTail: string;
306
+ /**
307
+ * Constructs a classified `TauriError`.
308
+ *
309
+ * @param kind - Taxonomy bucket.
310
+ * @param message - Fully formatted `[native] ...` message.
311
+ * @param details - Exit code + scrubbed stderr tail.
312
+ * @param details.exitCode - Raw process exit code (`null` when signal-terminated).
313
+ * @param details.stderrTail - Scrubbed tail of stderr — already safe to log/display.
314
+ * @example
315
+ * ```ts
316
+ * throw new TauriError("compile-failed", "[native] tauri compile failed.\n See stderr.", {
317
+ * exitCode: 101,
318
+ * stderrTail: "error[E0432]: unresolved import `foo`",
319
+ * });
320
+ * ```
321
+ */
322
+ constructor(kind: TauriErrorKind, message: string, details: {
323
+ exitCode: number | null;
324
+ stderrTail: string;
325
+ });
326
+ }
177
327
  declare namespace types_d_exports$4 {
178
- export { Api$3 as Api, CompileTick, Config$3 as Config, DevExit, DevHandle, RunResult, SpawnFn, State$1 as State, TauriContext, TauriError, TauriErrorDetails, TauriErrorKind };
328
+ export { Api$3 as Api, BuildArgvOptions, BuildOptions, CompileTick, Config$3 as Config, DevExit, DevHandle, RunResult, SpawnFn, State$1 as State, TauriContext, TauriError, TauriErrorDetails, TauriErrorKind };
179
329
  }
180
330
  /**
181
331
  * Structural spawn seam — injectable for tests (skeleton-conventions §3).
@@ -200,6 +350,11 @@ type SpawnFn = (opts: {
200
350
  type Config$3 = {
201
351
  spawnImpl?: SpawnFn | undefined;
202
352
  nodePath?: string | undefined;
353
+ /**
354
+ * Host architecture the iOS simulator rust target is derived from. `undefined` reads the
355
+ * real `process.arch`; pinning it keeps an assertion off the machine the suite runs on.
356
+ */
357
+ arch?: NodeJS.Architecture | undefined;
203
358
  readiness: {
204
359
  intervalMs: number;
205
360
  timeoutMs: number;
@@ -218,6 +373,21 @@ type CompileTick = {
218
373
  index?: number;
219
374
  total?: number;
220
375
  };
376
+ /**
377
+ * The build verb's full option surface — everything that changes the argv: the target, the
378
+ * shared {@link BuildFlavor} flags, and the iOS-only export method. A target that does not
379
+ * use an option ignores it rather than failing (the build plugin passes whatever the
380
+ * consumer configured, for every target).
381
+ */
382
+ type BuildArgvOptions = BuildFlavor & {
383
+ target: Target; /** iOS: `--export-method` for a device build; ignored for a simulator build. */
384
+ exportMethod?: AppleExportMethod | undefined;
385
+ };
386
+ /** Options for `Api.build` — the argv options plus the live output/progress callbacks. */
387
+ type BuildOptions = BuildArgvOptions & {
388
+ onTick?: ((tick: CompileTick) => void) | undefined;
389
+ onOutput?: ((line: string) => void) | undefined;
390
+ };
221
391
  /** How a dev session ended. */
222
392
  type DevExit = {
223
393
  code: number | null;
@@ -231,44 +401,18 @@ type DevHandle = {
231
401
  stop(): Promise<void>;
232
402
  };
233
403
  /** Classified subprocess failure taxonomy. */
234
- type TauriErrorKind = "toolchain-missing" | "config-invalid" | "compile-failed" | "signing-failed" | "device-unavailable" | "cancelled" | "unknown";
404
+ type TauriErrorKind = "toolchain-missing" | "platform-missing" | "config-invalid" | "compile-failed" | "xcode-script-failed" | "signing-failed" | "device-unavailable" | "cancelled" | "unknown";
235
405
  /** Extra fields carried on a classified failure, alongside the standard `Error` shape. */
236
406
  type TauriErrorDetails = {
237
407
  /** The taxonomy bucket assigned by `errors.ts#classify`. */readonly kind: TauriErrorKind; /** Raw process exit code (`null` when the process was signal-terminated). */
238
- readonly exitCode: number | null; /** Scrubbed tail of stderr (secrets already masked) — safe to log/display. */
239
- readonly stderrTail: string;
240
- };
241
- /**
242
- * Thrown by every one-shot verb (`icon`/`build`/`mobileInit`) on a non-zero exit.
243
- * Carries a classified {@link TauriErrorKind} and the scrubbed stderr tail so
244
- * callers (`build`, `doctor`, `cli`) can render an actionable message without
245
- * re-deriving the taxonomy or re-scrubbing raw output.
246
- */
247
- declare class TauriError extends Error implements TauriErrorDetails {
248
- readonly kind: TauriErrorKind;
249
408
  readonly exitCode: number | null;
250
- readonly stderrTail: string;
251
409
  /**
252
- * Constructs a classified `TauriError`.
253
- *
254
- * @param kind - Taxonomy bucket.
255
- * @param message - Fully formatted `[native] ...` message.
256
- * @param details - Exit code + scrubbed stderr tail.
257
- * @param details.exitCode - Raw process exit code (`null` when signal-terminated).
258
- * @param details.stderrTail - Scrubbed tail of stderr — already safe to log/display.
259
- * @example
260
- * ```ts
261
- * throw new TauriError("compile-failed", "[native] tauri compile failed.\n See stderr.", {
262
- * exitCode: 101,
263
- * stderrTail: "error[E0432]: unresolved import `foo`",
264
- * });
265
- * ```
410
+ * Scrubbed tail of the run's output (secrets already masked) — safe to log/display.
411
+ * Built from BOTH streams: the extracted cause lines, a `…` separator, then the last
412
+ * raw lines.
266
413
  */
267
- constructor(kind: TauriErrorKind, message: string, details: {
268
- exitCode: number | null;
269
- stderrTail: string;
270
- });
271
- }
414
+ readonly stderrTail: string;
415
+ };
272
416
  /** Mutable plugin state — the one live dev handle (undefined = no live session; unicorn/no-null). */
273
417
  type State$1 = {
274
418
  dev: DevHandle | undefined;
@@ -278,96 +422,94 @@ type Api$3 = {
278
422
  icon(opts: {
279
423
  source: string;
280
424
  }): Promise<RunResult>;
281
- build(opts: {
282
- target: Target;
283
- onTick?: (tick: CompileTick) => void;
284
- onOutput?: (line: string) => void;
285
- }): Promise<RunResult>;
425
+ build(opts: BuildOptions): Promise<RunResult>;
286
426
  mobileInit(opts: {
287
- platform: "ios" | "android";
427
+ target: MobileTarget;
288
428
  }): Promise<RunResult>;
289
429
  dev(opts: {
290
- target?: Target;
291
- onOutput?: (line: string) => void;
430
+ target?: Target | undefined;
431
+ onOutput?: ((line: string) => void) | undefined;
292
432
  }): Promise<DevHandle>;
293
- version(): Promise<{
433
+ getVersion(): Promise<{
294
434
  cliVersion: string;
295
- } | null>;
435
+ } | undefined>;
436
+ getRunner(): TauriRunner;
296
437
  };
297
438
  /**
298
- * Domain context shared by every tauri domain file. Structural composition
299
- * (not the bare `PluginCtx` export) because this plugin needs `global`
300
- * (projectDir, web.dev.url) and the `log`/`env` core APIs alongside
301
- * `config`/`state` — see moku-testing's mock-context.md §Standard Factory.
439
+ * Domain context shared by every tauri domain file: core's `PluginCtx` over this plugin's
440
+ * own config/state (it declares no events) plus the three fields core composes in per
441
+ * framework — `global` (projectDir, web.devUrl) and the `log`/`env` core APIs (MC2/MC3).
302
442
  */
303
- type TauriContext = {
443
+ type TauriContext = PluginCtx<Config$3, State$1> & {
304
444
  readonly global: Readonly<Config>;
305
- readonly config: Readonly<Config$3>;
306
- state: State$1;
307
445
  readonly log: LogApi;
308
446
  readonly env: EnvApi;
309
447
  };
310
448
  declare namespace types_d_exports {
311
- export { Api$2 as Api, BuildContext, BuildResult };
449
+ export { Api$2 as Api, BuildContext, BuildDeps, BuildResult, PathResolver, PhaseTiming, RunAllOptions, RunOptions };
312
450
  }
313
- /** Result of one target's full pipeline pass. */
451
+ /** One pipeline phase's measured duration, in execution order. */
452
+ type PhaseTiming = {
453
+ phase: NativePhase;
454
+ durationMs: number;
455
+ };
456
+ /** Result of one target's full pipeline pass — `phases` always carries all six entries. */
314
457
  type BuildResult = {
315
458
  target: Target;
316
459
  outPath: string;
317
460
  artifacts: readonly string[];
318
461
  durationMs: number;
319
- phases: ReadonlyArray<{
320
- phase: NativePhase;
321
- durationMs: number;
322
- }>;
462
+ phases: readonly PhaseTiming[];
323
463
  };
324
- /** Public API of the build plugin — the per-target pipeline orchestrator. */
325
- type Api$2 = {
326
- run(opts: {
327
- target: Target;
328
- }): Promise<BuildResult>;
329
- runAll(opts?: {
330
- targets?: readonly Target[];
331
- }): Promise<readonly BuildResult[]>;
464
+ /** Options for one target's pipeline pass. Platform-specific flags are ignored elsewhere. */
465
+ type RunOptions = BuildFlavor & {
466
+ target: Target;
467
+ };
468
+ /** Options for a sequential multi-target pass (default targets: `ctx.global.targets`). */
469
+ type RunAllOptions = BuildFlavor & {
470
+ targets?: readonly Target[] | undefined;
332
471
  };
333
472
  /**
334
- * Structural mirror of `@moku-labs/core`'s unexported `PluginLike` — same field shape
335
- * (`name`/`spec`/`_phantom`), so a real plugin instance (e.g. `projectPlugin`) satisfies
336
- * it without importing a core-internal type. `PluginCtx`'s own JSDoc anticipates this:
337
- * "for advanced composition (e.g. adding require), use EmitFn<E> directly" — this is the
338
- * `require`-side equivalent, re-derived locally since core intentionally exports only
339
- * `PluginCtx`/`EmitFn` for domain composition (moku-testing mock-context.md).
473
+ * Resolves a path to the comparable form containment is measured in — real path, symlinks
474
+ * followed, case folded. Always `project.resolveDerivedPath`: the project plugin owns that
475
+ * rule, and the collect guard must answer exactly what the clean guard answers.
340
476
  */
341
- type PluginLike$2 = {
342
- readonly name: string;
343
- readonly spec: unknown;
344
- readonly _phantom: {
345
- readonly config: unknown;
346
- readonly state: unknown;
347
- readonly api: unknown;
348
- readonly events?: Record<string, unknown>;
349
- };
477
+ type PathResolver = (target: string) => string;
478
+ /**
479
+ * The dependency API slices the pipeline calls, resolved ONCE in `createBuildApi` and
480
+ * threaded through every phase — `Pick` rather than the whole `Api`, so the exact
481
+ * cross-plugin surface build depends on (D-007) is readable in one place.
482
+ */
483
+ type BuildDeps = {
484
+ readonly project: Pick<Api$4, "generate" | "getBundleLayout" | "getCompleteness" | "patchMobile" | "clearMobileBuildOutput" | "ensureIconSource" | "resolveDerivedPath">;
485
+ readonly tauri: Pick<Api$3, "build" | "mobileInit" | "icon" | "getRunner">;
486
+ };
487
+ /** Public API of the build plugin — the per-target pipeline orchestrator. */
488
+ type Api$2 = {
489
+ prepare(opts: {
490
+ target: Target;
491
+ }): Promise<void>;
492
+ run(opts: RunOptions): Promise<BuildResult>;
493
+ runAll(opts?: RunAllOptions): Promise<readonly BuildResult[]>;
350
494
  };
351
- /** Extracts a plugin-like value's API type from its phantom `api` slot. */
352
- type PluginApiOf$2<P extends PluginLike$2> = P extends {
353
- readonly _phantom: {
354
- readonly api: infer A;
355
- };
356
- } ? A : never;
357
495
  /**
358
- * Domain context for the build plugin's pipeline. Structural (not the bare `PluginCtx`
359
- * export) because this plugin genuinely needs `require` — build's only two dependencies
360
- * are `project` and `tauri` (D-007) — alongside `global` and the `log` core API (MC2).
361
- * No `config`/`state` fields: build has neither (spec/03 §Config, §State).
496
+ * Domain context for the build plugin's pipeline: core's `PluginCtx` (build declares no
497
+ * config and no state, and emits the framework's own `Events`) plus `global` and the `log`
498
+ * core API (MC2). No `require`: the two dependency APIs are resolved once at the wiring
499
+ * point by the real `ctx.require` and travel as {@link BuildDeps}.
362
500
  */
363
- type BuildContext = {
501
+ type BuildContext = PluginCtx<Record<string, never>, Record<string, never>, Events> & {
364
502
  readonly global: Readonly<Config>;
365
503
  readonly log: LogApi;
366
- readonly emit: EmitFn<Events>;
367
- readonly require: <P extends PluginLike$2>(plugin: P) => PluginApiOf$2<P>;
368
504
  };
505
+ //#endregion
506
+ //#region src/plugins/doctor/checks/types.d.ts
507
+ /** The project plugin's API surface a check may read — narrowed to doctor's three needs. */
508
+ type CheckProjectApi = Pick<Api$4, "getRequiredFiles" | "getCompleteness" | "getRegistryRows">;
509
+ /** The tauri plugin's API surface a check may read — the one probe routed through tauri (D-013). */
510
+ type CheckTauriApi = Pick<Api$3, "getVersion">;
369
511
  declare namespace types_d_exports$2 {
370
- export { Api$1 as Api, CheckResult, Config$2 as Config, DoctorContext, DoctorEvents, DoctorReport, ProbeFn };
512
+ export { Api$1 as Api, CheckResult, Config$2 as Config, DoctorContext, DoctorDeps, DoctorEvents, DoctorReport, ProbeFn };
371
513
  }
372
514
  /** Structural probe seam — injectable for tests. */
373
515
  type ProbeFn = (cmd: string, args: readonly string[]) => Promise<{
@@ -376,7 +518,8 @@ type ProbeFn = (cmd: string, args: readonly string[]) => Promise<{
376
518
  }>;
377
519
  /** doctor plugin per-plugin config (| undefined required under exactOptionalPropertyTypes). */
378
520
  type Config$2 = {
379
- probeImpl?: ProbeFn | undefined;
521
+ probeImpl?: ProbeFn | undefined; /** Per-check budget: a check that outruns it yields a `warn` result. Default 10_000. */
522
+ probeTimeoutMs: number;
380
523
  };
381
524
  /** One completed check — also the doctor:check event payload. */
382
525
  type CheckResult = {
@@ -396,52 +539,32 @@ type DoctorEvents = {
396
539
  "doctor:check": CheckResult;
397
540
  };
398
541
  /**
399
- * Structural mirror of `@moku-labs/core`'s unexported `PluginLike` — same field shape
400
- * (`name`/`spec`/`_phantom`), so a real plugin instance (e.g. `projectPlugin`) satisfies
401
- * it without importing a core-internal type. `PluginCtx`'s own JSDoc anticipates this:
402
- * "for advanced composition (e.g. adding require), use EmitFn<E> directly" — this is the
403
- * `require`-side equivalent, re-derived locally since core intentionally exports only
404
- * `PluginCtx`/`EmitFn` for domain composition (moku-testing mock-context.md; house style
405
- * established by the sibling `build` plugin's `types.ts`, spec/04 §Dependencies).
542
+ * Domain context for the doctor API factory: core's `PluginCtx` over this plugin's config
543
+ * (it has no state) and the `doctor:check` event it declares, plus `global` and the
544
+ * `log`/`env` core APIs (MC2/MC3). No `require`: the dependency APIs are resolved once at
545
+ * the wiring point and travel as {@link DoctorDeps}.
406
546
  */
407
- type PluginLike$1 = {
408
- readonly name: string;
409
- readonly spec: unknown;
410
- readonly _phantom: {
411
- readonly config: unknown;
412
- readonly state: unknown;
413
- readonly api: unknown;
414
- readonly events?: Record<string, unknown>;
415
- };
416
- };
417
- /** Extracts a plugin-like value's API type from its phantom `api` slot. */
418
- type PluginApiOf$1<P extends PluginLike$1> = P extends {
419
- readonly _phantom: {
420
- readonly api: infer A;
421
- };
422
- } ? A : never;
423
- /**
424
- * Domain context for the doctor API factory. Structural composition (mock-context.md
425
- * "advanced composition" case): doctor genuinely needs `require` — its two dependencies
426
- * are `project` and `tauri` (D-007) — alongside `global` and the `log`/`env` core APIs
427
- * (MC2/MC3). No `state` field: doctor has none (spec/04 §State).
428
- */
429
- type DoctorContext = {
547
+ type DoctorContext = PluginCtx<Config$2, Record<string, never>, DoctorEvents> & {
430
548
  readonly global: Readonly<Config>;
431
- readonly config: Readonly<Config$2>;
432
549
  readonly log: LogApi;
433
550
  readonly env: EnvApi;
434
- readonly emit: EmitFn<DoctorEvents>;
435
- readonly require: <P extends PluginLike$1>(plugin: P) => PluginApiOf$1<P>;
551
+ };
552
+ /**
553
+ * The dependency API slices the checks read — doctor depends on exactly `project` and
554
+ * `tauri` (D-007), and each check only ever sees these narrow surfaces.
555
+ */
556
+ type DoctorDeps = {
557
+ readonly project: CheckProjectApi;
558
+ readonly tauri: CheckTauriApi;
436
559
  };
437
560
  /** Public API of the doctor plugin. */
438
561
  type Api$1 = {
439
562
  run(opts?: {
440
- target?: Target;
563
+ target?: Target | undefined;
441
564
  }): Promise<DoctorReport>;
442
565
  };
443
566
  declare namespace types_d_exports$1 {
444
- export { Api, CliContext, Config$1 as Config, ConfirmFn, RenderFn, State };
567
+ export { Api, CliContext, CliDeps, CliStateContext, Config$1 as Config, ConfirmFn, RenderFn, State };
445
568
  }
446
569
  /** Structural render sink — injectable for tests (default: branded `@moku-labs/common/cli` console). */
447
570
  type RenderFn = (line: string) => void;
@@ -452,64 +575,61 @@ type Config$1 = {
452
575
  renderImpl?: RenderFn | undefined;
453
576
  confirmImpl?: ConfirmFn | undefined;
454
577
  };
455
- /** Live-render bookkeeping for the current verb invocation (undefined = no active phase; unicorn/no-null). */
578
+ /**
579
+ * Plugin state: the one branded console every verb and hook renders through (created
580
+ * once in `createState`) plus the live-render bookkeeping for the current verb
581
+ * invocation (`startedAt: undefined` = no phase running; unicorn/no-null).
582
+ */
456
583
  type State = {
584
+ readonly ui: BrandConsole;
457
585
  progress: {
458
- phase: NativePhase | undefined;
459
586
  startedAt: number | undefined;
460
- ticks: number;
461
587
  };
462
588
  };
463
589
  /** Public API of the cli plugin — typed verbs, NO argv parsing. */
464
590
  type Api = {
465
- build(opts?: {
466
- target?: Target;
467
- all?: boolean;
591
+ build(opts?: BuildFlavor & {
592
+ target?: Target | undefined;
593
+ all?: boolean | undefined;
468
594
  }): Promise<void>;
469
595
  dev(opts?: {
470
- target?: Target;
596
+ target?: Target | undefined;
471
597
  }): Promise<void>;
472
598
  doctor(opts?: {
473
- target?: Target;
599
+ target?: Target | undefined;
474
600
  }): Promise<boolean>;
475
601
  clean(opts?: {
476
- target?: Target;
602
+ target?: Target | undefined;
477
603
  }): Promise<void>;
478
604
  };
479
605
  /**
480
- * Structural mirror of `@moku-labs/core`'s unexported `PluginLike` — same field shape
481
- * (`name`/`spec`/`_phantom`), so a real plugin instance (e.g. `projectPlugin`) satisfies
482
- * it without importing a core-internal type. Re-derived locally per the house pattern
483
- * established by the sibling `build`/`doctor` plugins' `types.ts` (moku-testing
484
- * mock-context.md; spec/04 §Dependencies).
606
+ * Context the `createState` factory receives (core's MinimalContext tier: the global
607
+ * config plus this plugin's RESOLVED config — which is where the injected render seam
608
+ * arrives, so the branded console can be built once, up front).
485
609
  */
486
- type PluginLike = {
487
- readonly name: string;
488
- readonly spec: unknown;
489
- readonly _phantom: {
490
- readonly config: unknown;
491
- readonly state: unknown;
492
- readonly api: unknown;
493
- readonly events?: Record<string, unknown>;
494
- };
610
+ type CliStateContext = {
611
+ readonly global: Readonly<Config>;
612
+ readonly config: Readonly<Config$1>;
495
613
  };
496
- /** Extracts a plugin-like value's API type from its phantom `api` slot. */
497
- type PluginApiOf<P extends PluginLike> = P extends {
498
- readonly _phantom: {
499
- readonly api: infer A;
500
- };
501
- } ? A : never;
502
614
  /**
503
- * Domain context shared by the cli plugin's `api` and `hooks` factories. Structural
504
- * composition (not the bare `PluginCtx` export): cli genuinely needs `require` — its four
505
- * dependencies are project/tauri/build/doctor (D-007) — alongside the mutable render-progress
506
- * `state` and the injectable render/confirm seams on `config`.
615
+ * Domain context shared by the cli plugin's `api` and `hooks` factories: core's `PluginCtx`
616
+ * over this plugin's config (the render/confirm seams) and state (the shared branded
617
+ * console), plus `global`. cli emits nothing of its own, and it holds no `require`: the four
618
+ * dependency APIs are resolved once at the wiring point and travel as {@link CliDeps}.
507
619
  */
508
- type CliContext = {
620
+ type CliContext = PluginCtx<Config$1, State> & {
509
621
  readonly global: Readonly<Config>;
510
- readonly config: Readonly<Config$1>;
511
- state: State;
512
- readonly require: <P extends PluginLike>(plugin: P) => PluginApiOf<P>;
622
+ };
623
+ /**
624
+ * The dependency API slices the verbs delegate to — cli depends on exactly
625
+ * project/tauri/build/doctor (D-007), and every verb is a thin delegate, so the surface it
626
+ * actually calls is this narrow.
627
+ */
628
+ type CliDeps = {
629
+ readonly project: Pick<Api$4, "clean">;
630
+ readonly tauri: Pick<Api$3, "dev">;
631
+ readonly build: Api$2;
632
+ readonly doctor: Api$1;
513
633
  };
514
634
  //#endregion
515
635
  //#region src/plugins/build/index.d.ts
@@ -558,8 +678,9 @@ declare const doctorPlugin: import("@moku-labs/core").PluginInstance<"doctor", C
558
678
  //#endregion
559
679
  //#region src/plugins/project/index.d.ts
560
680
  /**
561
- * Complex tier — capability registry + .moku/tauri generators + write-if-changed writer +
562
- * mobile init-once-then-patch (Android signing only in v1) + clean.
681
+ * Complex tier — capability registry + generators/ + write-if-changed writer + the mobile/
682
+ * sub-domain (completeness gate, Android signing block, runner-command rewrite) + the
683
+ * guarded clean.
563
684
  *
564
685
  * @see README.md
565
686
  * @example
@@ -571,8 +692,10 @@ declare const projectPlugin: import("@moku-labs/core").PluginInstance<"project",
571
692
  //#endregion
572
693
  //#region src/plugins/tauri/index.d.ts
573
694
  /**
574
- * Standard tier — `@tauri-apps/cli` subprocess seam: argv builders, injectable spawn,
575
- * process-group dev lifecycle, stream parsing, error taxonomy, secret scrubbing.
695
+ * Complex tier (flat layout) — `@tauri-apps/cli` subprocess seam: argv builders, injectable
696
+ * spawn, process-group dev lifecycle, stream parsing, error taxonomy, secret scrubbing.
697
+ * Each concern is its own file next to this one; the ≤30-line wiring rule keeps the layout
698
+ * flat rather than nested.
576
699
  *
577
700
  * NO onStop by design (D-002): spec/08 §2 TeardownContext = { global } — a regular plugin's
578
701
  * onStop cannot reach ctx.state, so dev teardown is owned by the dev seam's own control flow
@@ -590,6 +713,10 @@ declare const tauriPlugin: import("@moku-labs/core").PluginInstance<"tauri", Con
590
713
  /**
591
714
  * Creates a native consumer app (Layer 3) from this framework.
592
715
  *
716
+ * Wires the five framework plugins plus `log`/`env`, validates app identity at
717
+ * composition time, and returns the frozen, fully-typed app. See the file JSDoc above
718
+ * for the full options/defaults tables.
719
+ *
593
720
  * @example
594
721
  * ```ts
595
722
  * export const native = createApp({ config: { app: { name: "MyApp", identifier: "com.example.myapp" } } });
@@ -610,4 +737,4 @@ declare const createApp: <const ExtraPlugins extends readonly import("@moku-labs
610
737
  */
611
738
  declare const createPlugin: import("@moku-labs/core").BoundCreatePluginFunction<Config, Events, import("@moku-labs/core").CoreApisFromTuple<[import("@moku-labs/core").CorePluginInstance<"log", import("@moku-labs/common").LogConfig, import("@moku-labs/common").LogState, import("@moku-labs/common").LogApi>, import("@moku-labs/core").CorePluginInstance<"env", import("@moku-labs/common").EnvConfig, import("@moku-labs/common").EnvState, import("@moku-labs/common").EnvApi>]>>;
612
739
  //#endregion
613
- export { types_d_exports as Build, type CapabilityConfigMap, types_d_exports$1 as Cli, type Config, types_d_exports$2 as Doctor, type Events, type NativeCompleteEvent, type NativePhase, type NativePhaseEvent, PHASE_ORDER, types_d_exports$3 as Project, type SigningConfig, TARGETS, type Target, types_d_exports$4 as Tauri, buildPlugin, cliPlugin, createApp, createPlugin, doctorPlugin, projectPlugin, tauriPlugin };
740
+ export { type AppleExportMethod, type AppleSigning, type types_d_exports as Build, type BuildFlavor, type CapabilityConfigMap, type types_d_exports$1 as Cli, type Config, type types_d_exports$2 as Doctor, type Events, type MobileTarget, type NativeCompleteEvent, type NativePhase, type NativePhaseEvent, PHASE_ORDER, type types_d_exports$3 as Project, type SigningConfig, TARGETS, type Target, type types_d_exports$4 as Tauri, TauriError, type TauriRunner, buildPlugin, cliPlugin, createApp, createPlugin, doctorPlugin, hostTargets, projectPlugin, tauriPlugin };