@moku-labs/native 0.1.0 → 0.2.0

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