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