@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.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,63 @@ 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;
280
+ }): Promise<CleanResult>;
281
+ clearMobileBuildOutput(opts: {
282
+ target: MobileTarget;
173
283
  }): Promise<CleanResult>;
284
+ resolveDerivedPath(target: string): string;
285
+ ensureIconSource(): Promise<string>;
174
286
  resolve<K extends keyof CapabilityConfigMap>(name: K, config?: CapabilityConfigMap[K]): ResolvedCapability;
175
287
  isKnownCapability(name: string): name is keyof CapabilityConfigMap;
176
- registryRows(): ReadonlyArray<RegistryRow>;
177
- requiredFiles(platform: "ios" | "android"): readonly string[];
288
+ getRegistryRows(): ReadonlyArray<RegistryRow>;
289
+ getRequiredFiles(opts: {
290
+ target: MobileTarget;
291
+ }): readonly string[];
178
292
  };
293
+ //#endregion
294
+ //#region src/plugins/tauri/errors.d.ts
295
+ /**
296
+ * Thrown by every one-shot verb (`icon`/`build`/`mobileInit`) on a non-zero exit.
297
+ * Carries a classified {@link TauriErrorKind} and the scrubbed stderr tail so
298
+ * callers (`build`, `doctor`, `cli`) can render an actionable message without
299
+ * re-deriving the taxonomy or re-scrubbing raw output.
300
+ */
301
+ declare class TauriError extends Error implements TauriErrorDetails {
302
+ readonly kind: TauriErrorKind;
303
+ readonly exitCode: number | null;
304
+ readonly stderrTail: string;
305
+ /**
306
+ * Constructs a classified `TauriError`.
307
+ *
308
+ * @param kind - Taxonomy bucket.
309
+ * @param message - Fully formatted `[native] ...` message.
310
+ * @param details - Exit code + scrubbed stderr tail.
311
+ * @param details.exitCode - Raw process exit code (`null` when signal-terminated).
312
+ * @param details.stderrTail - Scrubbed tail of stderr — already safe to log/display.
313
+ * @example
314
+ * ```ts
315
+ * throw new TauriError("compile-failed", "[native] tauri compile failed.\n See stderr.", {
316
+ * exitCode: 101,
317
+ * stderrTail: "error[E0432]: unresolved import `foo`",
318
+ * });
319
+ * ```
320
+ */
321
+ constructor(kind: TauriErrorKind, message: string, details: {
322
+ exitCode: number | null;
323
+ stderrTail: string;
324
+ });
325
+ }
179
326
  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 };
327
+ 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
328
  }
182
329
  /**
183
330
  * Structural spawn seam — injectable for tests (skeleton-conventions §3).
@@ -202,6 +349,11 @@ type SpawnFn = (opts: {
202
349
  type Config$3 = {
203
350
  spawnImpl?: SpawnFn | undefined;
204
351
  nodePath?: string | undefined;
352
+ /**
353
+ * Host architecture the iOS simulator rust target is derived from. `undefined` reads the
354
+ * real `process.arch`; pinning it keeps an assertion off the machine the suite runs on.
355
+ */
356
+ arch?: NodeJS.Architecture | undefined;
205
357
  readiness: {
206
358
  intervalMs: number;
207
359
  timeoutMs: number;
@@ -220,6 +372,21 @@ type CompileTick = {
220
372
  index?: number;
221
373
  total?: number;
222
374
  };
375
+ /**
376
+ * The build verb's full option surface — everything that changes the argv: the target, the
377
+ * shared {@link BuildFlavor} flags, and the iOS-only export method. A target that does not
378
+ * use an option ignores it rather than failing (the build plugin passes whatever the
379
+ * consumer configured, for every target).
380
+ */
381
+ type BuildArgvOptions = BuildFlavor & {
382
+ target: Target; /** iOS: `--export-method` for a device build; ignored for a simulator build. */
383
+ exportMethod?: AppleExportMethod | undefined;
384
+ };
385
+ /** Options for `Api.build` — the argv options plus the live output/progress callbacks. */
386
+ type BuildOptions = BuildArgvOptions & {
387
+ onTick?: ((tick: CompileTick) => void) | undefined;
388
+ onOutput?: ((line: string) => void) | undefined;
389
+ };
223
390
  /** How a dev session ended. */
224
391
  type DevExit = {
225
392
  code: number | null;
@@ -233,44 +400,18 @@ type DevHandle = {
233
400
  stop(): Promise<void>;
234
401
  };
235
402
  /** Classified subprocess failure taxonomy. */
236
- type TauriErrorKind = "toolchain-missing" | "config-invalid" | "compile-failed" | "signing-failed" | "device-unavailable" | "cancelled" | "unknown";
403
+ type TauriErrorKind = "toolchain-missing" | "platform-missing" | "config-invalid" | "compile-failed" | "xcode-script-failed" | "signing-failed" | "device-unavailable" | "cancelled" | "unknown";
237
404
  /** Extra fields carried on a classified failure, alongside the standard `Error` shape. */
238
405
  type TauriErrorDetails = {
239
406
  /** 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
407
  readonly exitCode: number | null;
252
- readonly stderrTail: string;
253
408
  /**
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
- * ```
409
+ * Scrubbed tail of the run's output (secrets already masked) — safe to log/display.
410
+ * Built from BOTH streams: the extracted cause lines, a `…` separator, then the last
411
+ * raw lines.
268
412
  */
269
- constructor(kind: TauriErrorKind, message: string, details: {
270
- exitCode: number | null;
271
- stderrTail: string;
272
- });
273
- }
413
+ readonly stderrTail: string;
414
+ };
274
415
  /** Mutable plugin state — the one live dev handle (undefined = no live session; unicorn/no-null). */
275
416
  type State$1 = {
276
417
  dev: DevHandle | undefined;
@@ -280,96 +421,94 @@ type Api$3 = {
280
421
  icon(opts: {
281
422
  source: string;
282
423
  }): Promise<RunResult>;
283
- build(opts: {
284
- target: Target;
285
- onTick?: (tick: CompileTick) => void;
286
- onOutput?: (line: string) => void;
287
- }): Promise<RunResult>;
424
+ build(opts: BuildOptions): Promise<RunResult>;
288
425
  mobileInit(opts: {
289
- platform: "ios" | "android";
426
+ target: MobileTarget;
290
427
  }): Promise<RunResult>;
291
428
  dev(opts: {
292
- target?: Target;
293
- onOutput?: (line: string) => void;
429
+ target?: Target | undefined;
430
+ onOutput?: ((line: string) => void) | undefined;
294
431
  }): Promise<DevHandle>;
295
- version(): Promise<{
432
+ getVersion(): Promise<{
296
433
  cliVersion: string;
297
- } | null>;
434
+ } | undefined>;
435
+ getRunner(): TauriRunner;
298
436
  };
299
437
  /**
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.
438
+ * Domain context shared by every tauri domain file: core's `PluginCtx` over this plugin's
439
+ * own config/state (it declares no events) plus the three fields core composes in per
440
+ * framework — `global` (projectDir, web.devUrl) and the `log`/`env` core APIs (MC2/MC3).
304
441
  */
305
- type TauriContext = {
442
+ type TauriContext = PluginCtx<Config$3, State$1> & {
306
443
  readonly global: Readonly<Config>;
307
- readonly config: Readonly<Config$3>;
308
- state: State$1;
309
444
  readonly log: LogApi;
310
445
  readonly env: EnvApi;
311
446
  };
312
447
  declare namespace types_d_exports {
313
- export { Api$2 as Api, BuildContext, BuildResult };
448
+ export { Api$2 as Api, BuildContext, BuildDeps, BuildResult, PathResolver, PhaseTiming, RunAllOptions, RunOptions };
314
449
  }
315
- /** Result of one target's full pipeline pass. */
450
+ /** One pipeline phase's measured duration, in execution order. */
451
+ type PhaseTiming = {
452
+ phase: NativePhase;
453
+ durationMs: number;
454
+ };
455
+ /** Result of one target's full pipeline pass — `phases` always carries all six entries. */
316
456
  type BuildResult = {
317
457
  target: Target;
318
458
  outPath: string;
319
459
  artifacts: readonly string[];
320
460
  durationMs: number;
321
- phases: ReadonlyArray<{
322
- phase: NativePhase;
323
- durationMs: number;
324
- }>;
461
+ phases: readonly PhaseTiming[];
325
462
  };
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[]>;
463
+ /** Options for one target's pipeline pass. Platform-specific flags are ignored elsewhere. */
464
+ type RunOptions = BuildFlavor & {
465
+ target: Target;
466
+ };
467
+ /** Options for a sequential multi-target pass (default targets: `ctx.global.targets`). */
468
+ type RunAllOptions = BuildFlavor & {
469
+ targets?: readonly Target[] | undefined;
334
470
  };
335
471
  /**
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).
472
+ * Resolves a path to the comparable form containment is measured in — real path, symlinks
473
+ * followed, case folded. Always `project.resolveDerivedPath`: the project plugin owns that
474
+ * rule, and the collect guard must answer exactly what the clean guard answers.
342
475
  */
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
- };
476
+ type PathResolver = (target: string) => string;
477
+ /**
478
+ * The dependency API slices the pipeline calls, resolved ONCE in `createBuildApi` and
479
+ * threaded through every phase — `Pick` rather than the whole `Api`, so the exact
480
+ * cross-plugin surface build depends on (D-007) is readable in one place.
481
+ */
482
+ type BuildDeps = {
483
+ readonly project: Pick<Api$4, "generate" | "getBundleLayout" | "getCompleteness" | "patchMobile" | "clearMobileBuildOutput" | "ensureIconSource" | "resolveDerivedPath">;
484
+ readonly tauri: Pick<Api$3, "build" | "mobileInit" | "icon" | "getRunner">;
485
+ };
486
+ /** Public API of the build plugin — the per-target pipeline orchestrator. */
487
+ type Api$2 = {
488
+ prepare(opts: {
489
+ target: Target;
490
+ }): Promise<void>;
491
+ run(opts: RunOptions): Promise<BuildResult>;
492
+ runAll(opts?: RunAllOptions): Promise<readonly BuildResult[]>;
352
493
  };
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
494
  /**
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).
495
+ * Domain context for the build plugin's pipeline: core's `PluginCtx` (build declares no
496
+ * config and no state, and emits the framework's own `Events`) plus `global` and the `log`
497
+ * core API (MC2). No `require`: the two dependency APIs are resolved once at the wiring
498
+ * point by the real `ctx.require` and travel as {@link BuildDeps}.
364
499
  */
365
- type BuildContext = {
500
+ type BuildContext = PluginCtx<Record<string, never>, Record<string, never>, Events> & {
366
501
  readonly global: Readonly<Config>;
367
502
  readonly log: LogApi;
368
- readonly emit: EmitFn<Events>;
369
- readonly require: <P extends PluginLike$2>(plugin: P) => PluginApiOf$2<P>;
370
503
  };
504
+ //#endregion
505
+ //#region src/plugins/doctor/checks/types.d.ts
506
+ /** The project plugin's API surface a check may read — narrowed to doctor's three needs. */
507
+ type CheckProjectApi = Pick<Api$4, "getRequiredFiles" | "getCompleteness" | "getRegistryRows">;
508
+ /** The tauri plugin's API surface a check may read — the one probe routed through tauri (D-013). */
509
+ type CheckTauriApi = Pick<Api$3, "getVersion">;
371
510
  declare namespace types_d_exports$2 {
372
- export { Api$1 as Api, CheckResult, Config$2 as Config, DoctorContext, DoctorEvents, DoctorReport, ProbeFn };
511
+ export { Api$1 as Api, CheckResult, Config$2 as Config, DoctorContext, DoctorDeps, DoctorEvents, DoctorReport, ProbeFn };
373
512
  }
374
513
  /** Structural probe seam — injectable for tests. */
375
514
  type ProbeFn = (cmd: string, args: readonly string[]) => Promise<{
@@ -378,7 +517,8 @@ type ProbeFn = (cmd: string, args: readonly string[]) => Promise<{
378
517
  }>;
379
518
  /** doctor plugin per-plugin config (| undefined required under exactOptionalPropertyTypes). */
380
519
  type Config$2 = {
381
- probeImpl?: ProbeFn | undefined;
520
+ probeImpl?: ProbeFn | undefined; /** Per-check budget: a check that outruns it yields a `warn` result. Default 10_000. */
521
+ probeTimeoutMs: number;
382
522
  };
383
523
  /** One completed check — also the doctor:check event payload. */
384
524
  type CheckResult = {
@@ -398,52 +538,32 @@ type DoctorEvents = {
398
538
  "doctor:check": CheckResult;
399
539
  };
400
540
  /**
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).
541
+ * Domain context for the doctor API factory: core's `PluginCtx` over this plugin's config
542
+ * (it has no state) and the `doctor:check` event it declares, plus `global` and the
543
+ * `log`/`env` core APIs (MC2/MC3). No `require`: the dependency APIs are resolved once at
544
+ * the wiring point and travel as {@link DoctorDeps}.
408
545
  */
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 = {
546
+ type DoctorContext = PluginCtx<Config$2, Record<string, never>, DoctorEvents> & {
432
547
  readonly global: Readonly<Config>;
433
- readonly config: Readonly<Config$2>;
434
548
  readonly log: LogApi;
435
549
  readonly env: EnvApi;
436
- readonly emit: EmitFn<DoctorEvents>;
437
- readonly require: <P extends PluginLike$1>(plugin: P) => PluginApiOf$1<P>;
550
+ };
551
+ /**
552
+ * The dependency API slices the checks read — doctor depends on exactly `project` and
553
+ * `tauri` (D-007), and each check only ever sees these narrow surfaces.
554
+ */
555
+ type DoctorDeps = {
556
+ readonly project: CheckProjectApi;
557
+ readonly tauri: CheckTauriApi;
438
558
  };
439
559
  /** Public API of the doctor plugin. */
440
560
  type Api$1 = {
441
561
  run(opts?: {
442
- target?: Target;
562
+ target?: Target | undefined;
443
563
  }): Promise<DoctorReport>;
444
564
  };
445
565
  declare namespace types_d_exports$1 {
446
- export { Api, CliContext, Config$1 as Config, ConfirmFn, RenderFn, State };
566
+ export { Api, CliContext, CliDeps, CliStateContext, Config$1 as Config, ConfirmFn, RenderFn, State };
447
567
  }
448
568
  /** Structural render sink — injectable for tests (default: branded `@moku-labs/common/cli` console). */
449
569
  type RenderFn = (line: string) => void;
@@ -454,64 +574,61 @@ type Config$1 = {
454
574
  renderImpl?: RenderFn | undefined;
455
575
  confirmImpl?: ConfirmFn | undefined;
456
576
  };
457
- /** Live-render bookkeeping for the current verb invocation (undefined = no active phase; unicorn/no-null). */
577
+ /**
578
+ * Plugin state: the one branded console every verb and hook renders through (created
579
+ * once in `createState`) plus the live-render bookkeeping for the current verb
580
+ * invocation (`startedAt: undefined` = no phase running; unicorn/no-null).
581
+ */
458
582
  type State = {
583
+ readonly ui: BrandConsole;
459
584
  progress: {
460
- phase: NativePhase | undefined;
461
585
  startedAt: number | undefined;
462
- ticks: number;
463
586
  };
464
587
  };
465
588
  /** Public API of the cli plugin — typed verbs, NO argv parsing. */
466
589
  type Api = {
467
- build(opts?: {
468
- target?: Target;
469
- all?: boolean;
590
+ build(opts?: BuildFlavor & {
591
+ target?: Target | undefined;
592
+ all?: boolean | undefined;
470
593
  }): Promise<void>;
471
594
  dev(opts?: {
472
- target?: Target;
595
+ target?: Target | undefined;
473
596
  }): Promise<void>;
474
597
  doctor(opts?: {
475
- target?: Target;
598
+ target?: Target | undefined;
476
599
  }): Promise<boolean>;
477
600
  clean(opts?: {
478
- target?: Target;
601
+ target?: Target | undefined;
479
602
  }): Promise<void>;
480
603
  };
481
604
  /**
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).
605
+ * Context the `createState` factory receives (core's MinimalContext tier: the global
606
+ * config plus this plugin's RESOLVED config — which is where the injected render seam
607
+ * arrives, so the branded console can be built once, up front).
487
608
  */
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
- };
609
+ type CliStateContext = {
610
+ readonly global: Readonly<Config>;
611
+ readonly config: Readonly<Config$1>;
497
612
  };
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
613
  /**
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`.
614
+ * Domain context shared by the cli plugin's `api` and `hooks` factories: core's `PluginCtx`
615
+ * over this plugin's config (the render/confirm seams) and state (the shared branded
616
+ * console), plus `global`. cli emits nothing of its own, and it holds no `require`: the four
617
+ * dependency APIs are resolved once at the wiring point and travel as {@link CliDeps}.
509
618
  */
510
- type CliContext = {
619
+ type CliContext = PluginCtx<Config$1, State> & {
511
620
  readonly global: Readonly<Config>;
512
- readonly config: Readonly<Config$1>;
513
- state: State;
514
- readonly require: <P extends PluginLike>(plugin: P) => PluginApiOf<P>;
621
+ };
622
+ /**
623
+ * The dependency API slices the verbs delegate to — cli depends on exactly
624
+ * project/tauri/build/doctor (D-007), and every verb is a thin delegate, so the surface it
625
+ * actually calls is this narrow.
626
+ */
627
+ type CliDeps = {
628
+ readonly project: Pick<Api$4, "clean">;
629
+ readonly tauri: Pick<Api$3, "dev">;
630
+ readonly build: Api$2;
631
+ readonly doctor: Api$1;
515
632
  };
516
633
  //#endregion
517
634
  //#region src/plugins/build/index.d.ts
@@ -560,8 +677,9 @@ declare const doctorPlugin: import("@moku-labs/core").PluginInstance<"doctor", C
560
677
  //#endregion
561
678
  //#region src/plugins/project/index.d.ts
562
679
  /**
563
- * Complex tier — capability registry + .moku/tauri generators + write-if-changed writer +
564
- * mobile init-once-then-patch (Android signing only in v1) + clean.
680
+ * Complex tier — capability registry + generators/ + write-if-changed writer + the mobile/
681
+ * sub-domain (completeness gate, Android signing block, runner-command rewrite) + the
682
+ * guarded clean.
565
683
  *
566
684
  * @see README.md
567
685
  * @example
@@ -573,8 +691,10 @@ declare const projectPlugin: import("@moku-labs/core").PluginInstance<"project",
573
691
  //#endregion
574
692
  //#region src/plugins/tauri/index.d.ts
575
693
  /**
576
- * Standard tier — `@tauri-apps/cli` subprocess seam: argv builders, injectable spawn,
577
- * process-group dev lifecycle, stream parsing, error taxonomy, secret scrubbing.
694
+ * Complex tier (flat layout) — `@tauri-apps/cli` subprocess seam: argv builders, injectable
695
+ * spawn, process-group dev lifecycle, stream parsing, error taxonomy, secret scrubbing.
696
+ * Each concern is its own file next to this one; the ≤30-line wiring rule keeps the layout
697
+ * flat rather than nested.
578
698
  *
579
699
  * NO onStop by design (D-002): spec/08 §2 TeardownContext = { global } — a regular plugin's
580
700
  * onStop cannot reach ctx.state, so dev teardown is owned by the dev seam's own control flow
@@ -592,6 +712,10 @@ declare const tauriPlugin: import("@moku-labs/core").PluginInstance<"tauri", Con
592
712
  /**
593
713
  * Creates a native consumer app (Layer 3) from this framework.
594
714
  *
715
+ * Wires the five framework plugins plus `log`/`env`, validates app identity at
716
+ * composition time, and returns the frozen, fully-typed app. See the file JSDoc above
717
+ * for the full options/defaults tables.
718
+ *
595
719
  * @example
596
720
  * ```ts
597
721
  * export const native = createApp({ config: { app: { name: "MyApp", identifier: "com.example.myapp" } } });
@@ -612,4 +736,4 @@ declare const createApp: <const ExtraPlugins extends readonly import("@moku-labs
612
736
  */
613
737
  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
738
  //#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 };
739
+ 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 };