@moku-labs/native 0.3.7 → 0.3.9
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/README.md +69 -6
- package/dist/index.cjs +3114 -1060
- package/dist/index.d.cts +701 -39
- package/dist/index.d.mts +701 -39
- package/dist/index.mjs +3115 -1061
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -32,7 +32,28 @@ type TauriRunner = {
|
|
|
32
32
|
type BuildFlavor = {
|
|
33
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
34
|
aab?: boolean | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Build the debug profile instead of the store one: a still-optimized build that installs
|
|
37
|
+
* next to the store app (`.debug` id, "(debug)" name), is signed with the debug keystore,
|
|
38
|
+
* forwards the page console and allows cleartext. Unset means the store profile.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* await native.build.run({ target: "android", debug: true });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
debug?: boolean | undefined;
|
|
35
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Which profile a build is made in. `"store"` is the shippable build; `"debug"` is the
|
|
49
|
+
* on-device test build of {@link BuildFlavor.debug}. The page sees `"store"` as `"release"`.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const profile: BuildProfile = flavor.debug ? "debug" : "store";
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
type BuildProfile = "store" | "debug";
|
|
36
57
|
/**
|
|
37
58
|
* Resolves the packaging targets a host can build with no extra opt-in — the default
|
|
38
59
|
* `config.targets`. Exactly one desktop target per host (`darwin` → `macos`,
|
|
@@ -69,6 +90,17 @@ type CapabilityConfigMap = {
|
|
|
69
90
|
};
|
|
70
91
|
back: Record<string, never>;
|
|
71
92
|
haptics: Record<string, never>;
|
|
93
|
+
/**
|
|
94
|
+
* The page bridge `globalThis.__MOKU_NATIVE__` (Android): display rate, thermal state,
|
|
95
|
+
* safe-area insets, device info. Composed like every capability, by naming it in
|
|
96
|
+
* `config.system`; this entry only carries its (empty) parameters and composes nothing alone.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* createApp({ config: { system: [{ name: "shell" }], capabilities: { shell: {} } } });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
shell: Record<string, never>;
|
|
72
104
|
};
|
|
73
105
|
/**
|
|
74
106
|
* Which way up a mobile app runs. Build time only: it picks the iOS `Info.plist`
|
|
@@ -96,7 +128,7 @@ type AppleSigning = {
|
|
|
96
128
|
entitlements?: string; /** Generate a sandbox entitlements file for the App Store when `entitlements` is unset. */
|
|
97
129
|
appStore?: boolean; /** Archive export method passed to `tauri ios build`. */
|
|
98
130
|
exportMethod?: AppleExportMethod; /** Minimum macOS version → `bundle.macOS.minimumSystemVersion`. */
|
|
99
|
-
macosMinimumSystemVersion?: string; /** Minimum iOS version → `bundle.iOS.minimumSystemVersion
|
|
131
|
+
macosMinimumSystemVersion?: string; /** Minimum iOS version → `bundle.iOS.minimumSystemVersion`; `"15.0"` when unset (Xcode 27 rejects Tauri's 14.0). */
|
|
100
132
|
iosMinimumSystemVersion?: string;
|
|
101
133
|
};
|
|
102
134
|
/** Signing configuration — env-var REFERENCES and config-safe identifiers only, never raw secrets. */
|
|
@@ -145,6 +177,17 @@ type Config = {
|
|
|
145
177
|
* dark icons on a light one. Unset leaves the platform default (white in light mode).
|
|
146
178
|
*/
|
|
147
179
|
backgroundColor?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Android adaptive icon inset, in percent of the 108 dp canvas per side (`0 < n ≤ 30`).
|
|
182
|
+
* Wraps the launcher foreground in an `<inset>` so full-bleed art survives the mask.
|
|
183
|
+
* Unset leaves the icon untouched. `19.44` keeps the art inside the 66 dp safe zone.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* createApp({ config: { app: { name: "Demo", identifier: "com.acme.demo", adaptiveIconInset: 19.44 } } });
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
adaptiveIconInset?: number;
|
|
148
191
|
}; /** Web build/dev wiring codegenned into tauri.conf.json. cwd for monorepo layouts. */
|
|
149
192
|
web: {
|
|
150
193
|
build: string;
|
|
@@ -175,7 +218,8 @@ type NativeCompleteEvent = {
|
|
|
175
218
|
target: Target;
|
|
176
219
|
outPath: string;
|
|
177
220
|
artifacts: readonly string[];
|
|
178
|
-
durationMs: number;
|
|
221
|
+
durationMs: number; /** The profile the artifacts were built in — the CLI marks a debug delivery. */
|
|
222
|
+
profile: BuildProfile;
|
|
179
223
|
};
|
|
180
224
|
/**
|
|
181
225
|
* Framework-level events (spec/07 §6 `framework-domain:*`) — emitted by build, hookable by all plugins.
|
|
@@ -198,9 +242,13 @@ type BundleLayout = {
|
|
|
198
242
|
readonly genDirectory: string | undefined;
|
|
199
243
|
};
|
|
200
244
|
declare namespace types_d_exports$3 {
|
|
201
|
-
export { Api$4 as Api, CleanResult, CompletenessResult, DeepLinkConf, GenerateResult, ManifestEntry, PatchMobileOptions, PatchResult, PlistEntry, PlistValue, ProjectContext, RegistryRow, ResolvedCapability, TauriConfFragment };
|
|
245
|
+
export { AndroidProfile, Api$4 as Api, CleanResult, CompletenessResult, DebugKeystore, DeepLinkConf, GenerateResult, ManifestEntry, PageAgentResult, PatchMobileOptions, PatchResult, PlistEntry, PlistValue, ProjectContext, RegistryRow, ResolvedCapability, TauriConfFragment };
|
|
202
246
|
}
|
|
203
|
-
/**
|
|
247
|
+
/**
|
|
248
|
+
* What one `generate` pass did to each artifact, as paths under `projectDir`: written
|
|
249
|
+
* because its content changed, or left unchanged because it was already current.
|
|
250
|
+
* `skipped` stays empty — the writer never skips an artifact.
|
|
251
|
+
*/
|
|
204
252
|
type GenerateResult = {
|
|
205
253
|
readonly written: readonly string[];
|
|
206
254
|
readonly unchanged: readonly string[];
|
|
@@ -226,26 +274,92 @@ type PatchResult = {
|
|
|
226
274
|
readonly patched: readonly string[];
|
|
227
275
|
readonly unchanged: readonly string[];
|
|
228
276
|
};
|
|
229
|
-
/**
|
|
277
|
+
/**
|
|
278
|
+
* Options for one mobile patch pass. The runner patch is skipped when `runner` is absent;
|
|
279
|
+
* an absent `profile` is the store profile.
|
|
280
|
+
*/
|
|
230
281
|
type PatchMobileOptions = {
|
|
231
282
|
target: MobileTarget;
|
|
232
283
|
runner?: TauriRunner | undefined;
|
|
284
|
+
profile?: BuildProfile | undefined;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* The build profile one Android patch pass applies, with what that profile needs: the
|
|
288
|
+
* debug profile names the app `"<name> (debug)"` and signs with the debug keystore the
|
|
289
|
+
* caller resolved from `ctx.env`. `log` receives the warning about a network security
|
|
290
|
+
* config this plugin did not write.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* const profile: AndroidProfile = { profile: "debug", appName: "Demo", debugKeystore: "/home/me/.android/debug.keystore" };
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
type AndroidProfile = {
|
|
298
|
+
readonly profile: "store";
|
|
299
|
+
readonly log?: Pick<LogApi, "warn"> | undefined;
|
|
300
|
+
} | {
|
|
301
|
+
readonly profile: "debug";
|
|
302
|
+
readonly appName: string;
|
|
303
|
+
readonly debugKeystore: string;
|
|
304
|
+
readonly log?: Pick<LogApi, "warn"> | undefined;
|
|
233
305
|
};
|
|
234
|
-
/**
|
|
306
|
+
/**
|
|
307
|
+
* What a scan of the built page found: whether the editor agent ships in it, and the
|
|
308
|
+
* first `.js` file (relative to `web.dist`, POSIX separators) that carries it.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```ts
|
|
312
|
+
* const found: PageAgentResult = { agent: true, file: "page/main-4f2a.js" };
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
type PageAgentResult = {
|
|
316
|
+
agent: boolean;
|
|
317
|
+
file?: string;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* What one `clean` or `clearMobileBuildOutput` pass deleted, one path per removed file or
|
|
321
|
+
* directory; empty when there was nothing to remove.
|
|
322
|
+
*/
|
|
235
323
|
type CleanResult = {
|
|
236
324
|
removed: readonly string[];
|
|
237
325
|
};
|
|
326
|
+
/**
|
|
327
|
+
* The Android SDK debug keystore the debug profile signs with, and the shell command that
|
|
328
|
+
* creates it. `path` is undefined when the environment names no home directory.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* const keystore: DebugKeystore = {
|
|
333
|
+
* path: "/home/me/.android/debug.keystore",
|
|
334
|
+
* createCommand: 'mkdir -p "/home/me/.android" && keytool -genkeypair -v -keystore "/home/me/.android/debug.keystore" …'
|
|
335
|
+
* };
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
type DebugKeystore = {
|
|
339
|
+
readonly path: string | undefined;
|
|
340
|
+
readonly createCommand: string;
|
|
341
|
+
};
|
|
238
342
|
/**
|
|
239
343
|
* One capability registry row — packaging metadata with per-row research confidence.
|
|
240
344
|
* A row is backed by a real Tauri plugin (crate + npm package + Rust init), by a core
|
|
241
|
-
* Tauri cargo feature (tray),
|
|
242
|
-
*
|
|
345
|
+
* Tauri cargo feature (tray), by core permissions alone (back), or by a plugin crate this
|
|
346
|
+
* plugin generates itself (shell, `localCrate`), so every plugin-only field is optional and
|
|
347
|
+
* `cargoFeatures` is always present. A row has `crate` + `crateRange` or `localCrate`,
|
|
348
|
+
* never both.
|
|
243
349
|
*/
|
|
244
350
|
type RegistryRow = {
|
|
245
351
|
name: keyof CapabilityConfigMap;
|
|
246
352
|
npmPackage?: `@tauri-apps/plugin-${string}`;
|
|
247
353
|
crate?: `tauri-plugin-${string}`;
|
|
248
354
|
crateRange?: string;
|
|
355
|
+
/**
|
|
356
|
+
* A generated plugin crate, linked by path: its package name, and its directory
|
|
357
|
+
* relative to `projectDir` (POSIX).
|
|
358
|
+
*/
|
|
359
|
+
localCrate?: {
|
|
360
|
+
readonly name: "tauri-plugin-moku-shell";
|
|
361
|
+
readonly directory: string;
|
|
362
|
+
};
|
|
249
363
|
npmRange?: string;
|
|
250
364
|
rustInit?: string; /** Cargo features this capability enables on the `tauri` dependency. */
|
|
251
365
|
cargoFeatures: readonly string[];
|
|
@@ -293,8 +407,10 @@ type PlistEntry = {
|
|
|
293
407
|
/**
|
|
294
408
|
* An AndroidManifest need. `activity-attribute` sets one attribute on the main
|
|
295
409
|
* `<activity>`, or removes it when `value` is `undefined`; the orientation lock is one.
|
|
296
|
-
* `
|
|
297
|
-
*
|
|
410
|
+
* `application-attribute` does the same on the `<application>` start tag; the debug
|
|
411
|
+
* profile's network security config is one. `child` is the seam for a child element and
|
|
412
|
+
* the patch pass does not apply it. No registry row carries any kind: official plugins
|
|
413
|
+
* self-merge via build.rs.
|
|
298
414
|
*/
|
|
299
415
|
type ManifestEntry = {
|
|
300
416
|
kind: "child";
|
|
@@ -304,6 +420,10 @@ type ManifestEntry = {
|
|
|
304
420
|
kind: "activity-attribute";
|
|
305
421
|
name: `android:${string}`;
|
|
306
422
|
value: string | undefined;
|
|
423
|
+
} | {
|
|
424
|
+
kind: "application-attribute";
|
|
425
|
+
name: `android:${string}`;
|
|
426
|
+
value: string | undefined;
|
|
307
427
|
};
|
|
308
428
|
/** A capability resolved against consumer config. */
|
|
309
429
|
type ResolvedCapability = RegistryRow & {
|
|
@@ -314,36 +434,97 @@ type ResolvedCapability = RegistryRow & {
|
|
|
314
434
|
/**
|
|
315
435
|
* Domain context for the project plugin's API factory: core's `PluginCtx` (this plugin
|
|
316
436
|
* declares neither config nor state nor events — D-005, it reads global config only) plus
|
|
317
|
-
* the
|
|
437
|
+
* the fields core composes in per framework: `global`, the `log` core API (MC2) and the
|
|
438
|
+
* `env` core API (MC3), which resolves the debug keystore's home directory.
|
|
318
439
|
*/
|
|
319
440
|
type ProjectContext = PluginCtx<Record<string, never>, Record<string, never>> & {
|
|
320
441
|
readonly global: Readonly<Config>;
|
|
321
442
|
readonly log: LogApi;
|
|
443
|
+
readonly env: EnvApi;
|
|
322
444
|
};
|
|
323
445
|
/** Public API of the project plugin. */
|
|
324
446
|
type Api$4 = {
|
|
447
|
+
/**
|
|
448
|
+
* Writes or refreshes every pure artifact of one target into `projectDir`, through the
|
|
449
|
+
* write-if-changed writer. When the `shell` capability is composed for the target (named
|
|
450
|
+
* in `config.system`, or implied by the debug profile on android), the
|
|
451
|
+
* `tauri-plugin-moku-shell` crate is generated under `plugins/moku-shell/` too, with the
|
|
452
|
+
* profile baked into its page script. Without the shell, the output is the same for both
|
|
453
|
+
* profiles.
|
|
454
|
+
*
|
|
455
|
+
* @param opts - The generate options.
|
|
456
|
+
* @param opts.target - The packaging target to generate for.
|
|
457
|
+
* @param opts.profile - The build profile; `"store"` when omitted.
|
|
458
|
+
* @returns Which paths were written, left unchanged, or skipped.
|
|
459
|
+
* @example
|
|
460
|
+
* ```ts
|
|
461
|
+
* // A debug build of an Android app: the shell crate is generated even without a system entry.
|
|
462
|
+
* await app.project.generate({ target: "android", profile: "debug" });
|
|
463
|
+
* // { written: [".moku/tauri/src-tauri/tauri.conf.json", …, ".moku/tauri/plugins/moku-shell/src/page.js", …],
|
|
464
|
+
* // unchanged: [], skipped: [] }
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
325
467
|
generate(opts: {
|
|
326
468
|
target: Target;
|
|
469
|
+
profile?: BuildProfile | undefined;
|
|
327
470
|
}): Promise<GenerateResult>;
|
|
471
|
+
/**
|
|
472
|
+
* Returns where one target's build output lands inside the generated project, read from
|
|
473
|
+
* `layout.ts`, the one owner of that table: the output root (relative to `projectDir`),
|
|
474
|
+
* the desktop bundle-format directories with their artifact globs, and the mobile
|
|
475
|
+
* `gen/<platform>` directory. Build's collect phase globs against it instead of keeping
|
|
476
|
+
* a copy.
|
|
477
|
+
*
|
|
478
|
+
* @param opts - The lookup options.
|
|
479
|
+
* @param opts.target - The packaging target.
|
|
480
|
+
* @returns The output root, the bundle formats, and the mobile `gen/` directory.
|
|
481
|
+
* @example
|
|
482
|
+
* ```ts
|
|
483
|
+
* // Collect an iOS build: the output lives in the gen/apple tree, not under bundle/.
|
|
484
|
+
* app.project.getBundleLayout({ target: "ios" });
|
|
485
|
+
* // { root: "src-tauri", formats: [], genDirectory: "gen/apple" }
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
328
488
|
getBundleLayout(opts: {
|
|
329
489
|
target: Target;
|
|
330
490
|
}): BundleLayout;
|
|
491
|
+
/**
|
|
492
|
+
* Checks a mobile `gen/<platform>` tree against its required-file set, not mere
|
|
493
|
+
* existence: a partial `tauri <platform> init` leaves some files out. A desktop target is
|
|
494
|
+
* `"not-applicable"`, a missing tree `"not-initialized"`, a partial one `"incomplete"`
|
|
495
|
+
* with the missing paths.
|
|
496
|
+
*
|
|
497
|
+
* @param opts - The check options.
|
|
498
|
+
* @param opts.target - The packaging target to check.
|
|
499
|
+
* @returns The completeness verdict.
|
|
500
|
+
* @example
|
|
501
|
+
* ```ts
|
|
502
|
+
* // Before the first android build nothing has run `tauri android init` yet.
|
|
503
|
+
* app.project.getCompleteness({ target: "android" }); // { status: "not-initialized" }
|
|
504
|
+
* app.project.getCompleteness({ target: "macos" }); // { status: "not-applicable" }
|
|
505
|
+
* ```
|
|
506
|
+
*/
|
|
331
507
|
getCompleteness(opts: {
|
|
332
508
|
target: Target;
|
|
333
509
|
}): CompletenessResult;
|
|
334
510
|
/**
|
|
335
|
-
* Runs the idempotent mobile post-init patch pass. Android gets its
|
|
336
|
-
* the
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
511
|
+
* Runs the idempotent mobile post-init patch pass. Android gets its build-profile
|
|
512
|
+
* patches (debug: the `.debug` id suffix, the `"<name> (debug)"` label, a cleartext
|
|
513
|
+
* network security config; store: all three reverted to the bytes before), its release
|
|
514
|
+
* signing (the debug keystore under `HOME` ?? `USERPROFILE` in the debug profile), the
|
|
515
|
+
* main activity's manifest attributes (the orientation lock among them) and the status
|
|
516
|
+
* bar style in MainActivity.kt (light icons on a dark `app.backgroundColor`, dark icons
|
|
517
|
+
* on a light one); iOS gets the Xcode entitlements-modification setting; both get the
|
|
518
|
+
* Xcode/Android-Studio runner-command rewrite when a `runner` is supplied. The build
|
|
519
|
+
* plugin calls it after the mobile init pass, with the runner from `tauri.getRunner()`.
|
|
342
520
|
*
|
|
343
521
|
* @param opts - The patch options.
|
|
344
522
|
* @param opts.target - The mobile platform to patch.
|
|
345
523
|
* @param opts.runner - The absolute Node/`tauri.js` pair from `tauri.getRunner()`.
|
|
524
|
+
* @param opts.profile - The build profile; `"store"` when omitted.
|
|
346
525
|
* @returns The paths patched vs. left unchanged.
|
|
526
|
+
* @throws {Error} `[native]` in the debug profile when the debug keystore is missing,
|
|
527
|
+
* with the `keytool` command that creates it.
|
|
347
528
|
* @example
|
|
348
529
|
* ```ts
|
|
349
530
|
* // app.orientation is "portrait", app.backgroundColor is "#10161d", app.identifier is
|
|
@@ -355,20 +536,218 @@ type Api$4 = {
|
|
|
355
536
|
* ```
|
|
356
537
|
*/
|
|
357
538
|
patchMobile(opts: PatchMobileOptions): Promise<PatchResult>;
|
|
539
|
+
/**
|
|
540
|
+
* Wraps the Android adaptive icon foreground (`ic_launcher.xml` and the round icon) in an
|
|
541
|
+
* `<inset>` of `app.adaptiveIconInset` percent per side, or restores the plain foreground
|
|
542
|
+
* when the inset is unset. `tauri icon` rewrites these files, so the build plugin calls
|
|
543
|
+
* this after its icons phase, on every build. Idempotent; iOS and a tree without the
|
|
544
|
+
* adaptive icon directory get an empty result.
|
|
545
|
+
*
|
|
546
|
+
* @param opts - The patch options.
|
|
547
|
+
* @param opts.target - The mobile platform whose icons to patch.
|
|
548
|
+
* @returns The icon files patched vs. left unchanged.
|
|
549
|
+
* @example
|
|
550
|
+
* ```ts
|
|
551
|
+
* // app.adaptiveIconInset is 19.44 and `tauri icon` just rewrote the launcher icons.
|
|
552
|
+
* await app.project.patchMobileIcons({ target: "android" });
|
|
553
|
+
* // { patched: [".moku/tauri/src-tauri/gen/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml",
|
|
554
|
+
* // ".moku/tauri/src-tauri/gen/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml"],
|
|
555
|
+
* // unchanged: [] }
|
|
556
|
+
* ```
|
|
557
|
+
*/
|
|
558
|
+
patchMobileIcons(opts: {
|
|
559
|
+
target: MobileTarget;
|
|
560
|
+
}): Promise<PatchResult>;
|
|
561
|
+
/**
|
|
562
|
+
* Scans every `.js` file of the built page (`<web.cwd ?? .>/<web.dist>`) for the editor
|
|
563
|
+
* agent's marker strings — `"/__editor/hello"` and `"[moku-editor]"`, the two the engine's
|
|
564
|
+
* own release refusal uses. Source maps, HTML and symlinks out of the dist are never read.
|
|
565
|
+
* A missing dist is no agent.
|
|
566
|
+
*
|
|
567
|
+
* @returns `{ agent: true, file }` for the first file that carries the agent (relative to
|
|
568
|
+
* the dist), `{ agent: false }` otherwise.
|
|
569
|
+
* @example
|
|
570
|
+
* ```ts
|
|
571
|
+
* // The build plugin refuses a store build whose page still carries the editor agent.
|
|
572
|
+
* const page = await ctx.require(projectPlugin).detectPageAgent();
|
|
573
|
+
* // { agent: true, file: "page/main-4f2a.js" }
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
576
|
+
detectPageAgent(): Promise<PageAgentResult>;
|
|
577
|
+
/**
|
|
578
|
+
* Checks, after the compile phase, that the shell plugin is linked into the generated
|
|
579
|
+
* Gradle project: when `shell` is composed for the target and profile,
|
|
580
|
+
* `gen/android/tauri.settings.gradle` must name `moku-shell`. A tree initialised before
|
|
581
|
+
* the shell was added fails here instead of failing every `__MOKU_NATIVE__` call at
|
|
582
|
+
* runtime. A target or profile without the shell is a no-op.
|
|
583
|
+
*
|
|
584
|
+
* @param opts - The check options.
|
|
585
|
+
* @param opts.target - The mobile platform that was compiled.
|
|
586
|
+
* @param opts.profile - The build profile; `"store"` when omitted.
|
|
587
|
+
* @throws {Error} `[native] the shell plugin is not linked into gen/android …` with the
|
|
588
|
+
* clean-and-rebuild fix.
|
|
589
|
+
* @example
|
|
590
|
+
* ```ts
|
|
591
|
+
* // A debug android build composes the shell, so a stale tree fails before collect.
|
|
592
|
+
* await app.project.checkShellLinked({ target: "android", profile: "debug" });
|
|
593
|
+
* // rejects: [native] the shell plugin is not linked into gen/android (tree initialised …)
|
|
594
|
+
* ```
|
|
595
|
+
*/
|
|
596
|
+
checkShellLinked(opts: {
|
|
597
|
+
target: MobileTarget;
|
|
598
|
+
profile?: BuildProfile | undefined;
|
|
599
|
+
}): Promise<void>;
|
|
600
|
+
/**
|
|
601
|
+
* Deletes derived state: the whole `projectDir` when `target` is omitted, the
|
|
602
|
+
* `gen/<platform>` tree for a mobile target, that target's bundle-format directories for
|
|
603
|
+
* a desktop one. `projectDir` must be derived state (inside the cwd or the temp root) and
|
|
604
|
+
* every candidate inside it; only paths that existed are removed and listed.
|
|
605
|
+
*
|
|
606
|
+
* @param opts - The clean options; omit them to clean the whole `projectDir`.
|
|
607
|
+
* @param opts.target - The packaging target to scope the clean to.
|
|
608
|
+
* @returns The absolute paths actually removed.
|
|
609
|
+
* @throws {Error} `[native]` when `projectDir` is not derived state, or a path falls outside it.
|
|
610
|
+
* @example
|
|
611
|
+
* ```ts
|
|
612
|
+
* // Start android over from `tauri android init`; the cwd is /repo/app, projectDir the default.
|
|
613
|
+
* await app.project.clean({ target: "android" });
|
|
614
|
+
* // { removed: ["/repo/app/.moku/tauri/src-tauri/gen/android"] }
|
|
615
|
+
* ```
|
|
616
|
+
*/
|
|
358
617
|
clean(opts?: {
|
|
359
618
|
target?: Target | undefined;
|
|
360
619
|
}): Promise<CleanResult>;
|
|
620
|
+
/**
|
|
621
|
+
* Removes a mobile target's previous build output so the next compile writes into an
|
|
622
|
+
* empty tree: `gen/apple/build` on iOS (`tauri ios build` fails the second build of a tree
|
|
623
|
+
* with `Directory not empty`). Android always gets an empty result: Gradle manages its own
|
|
624
|
+
* `app/build`. Guarded like {@link Api.clean}: the output must be a real directory inside
|
|
625
|
+
* a derived `projectDir`.
|
|
626
|
+
*
|
|
627
|
+
* @param opts - The clear options.
|
|
628
|
+
* @param opts.target - The mobile platform whose previous build output to remove.
|
|
629
|
+
* @returns The paths removed — empty when there was nothing to remove.
|
|
630
|
+
* @throws {Error} `[native] Refusing to remove build output outside projectDir …` for a link out of the tree.
|
|
631
|
+
* @example
|
|
632
|
+
* ```ts
|
|
633
|
+
* // The build plugin clears the last iOS build before it compiles again.
|
|
634
|
+
* await ctx.require(projectPlugin).clearMobileBuildOutput({ target: "ios" });
|
|
635
|
+
* // { removed: ["/repo/app/.moku/tauri/src-tauri/gen/apple/build"] }
|
|
636
|
+
* ```
|
|
637
|
+
*/
|
|
361
638
|
clearMobileBuildOutput(opts: {
|
|
362
639
|
target: MobileTarget;
|
|
363
640
|
}): Promise<CleanResult>;
|
|
641
|
+
/**
|
|
642
|
+
* Resolves a path to the one form every containment guard of this framework compares in:
|
|
643
|
+
* absolute, symlinks followed, NFC-normalized, and case-folded on a case-insensitive
|
|
644
|
+
* platform. Build's collect guard borrows it so a single symlink cannot walk around a
|
|
645
|
+
* lexical check. For comparison only: never a path to display or to hand to the filesystem.
|
|
646
|
+
*
|
|
647
|
+
* @param target - The path to resolve, absolute or relative to the process cwd.
|
|
648
|
+
* @returns The comparable form of the real path.
|
|
649
|
+
* @example
|
|
650
|
+
* ```ts
|
|
651
|
+
* // Build checks that a delivery directory sits inside outDir; the cwd is /repo/app.
|
|
652
|
+
* app.project.resolveDerivedPath("dist-native/macos"); // "/repo/app/dist-native/macos"
|
|
653
|
+
* ```
|
|
654
|
+
*/
|
|
364
655
|
resolveDerivedPath(target: string): string;
|
|
656
|
+
/**
|
|
657
|
+
* Resolves the 1024x1024 source PNG `tauri icon` expands into the platform icon sets. A
|
|
658
|
+
* configured `app.icon` is used as is (resolved against the cwd); otherwise an embedded
|
|
659
|
+
* placeholder is written into `projectDir`, so a brand-new app packages without drawing
|
|
660
|
+
* an icon first.
|
|
661
|
+
*
|
|
662
|
+
* @returns The absolute path to the icon source.
|
|
663
|
+
* @throws {Error} `[native] app.icon "<path>" was not found at …` when `app.icon` names no file.
|
|
664
|
+
* @example
|
|
665
|
+
* ```ts
|
|
666
|
+
* // No app.icon configured, the cwd is /repo/app: the placeholder is written and used.
|
|
667
|
+
* await app.project.ensureIconSource(); // "/repo/app/.moku/tauri/placeholder-icon.png"
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
365
670
|
ensureIconSource(): Promise<string>;
|
|
671
|
+
/**
|
|
672
|
+
* Resolves one registry row against its optional packaging config into the full
|
|
673
|
+
* contribution: the row plus its tauri.conf fragment and the Info.plist-sidecar and
|
|
674
|
+
* manifest seams (both empty for every row today).
|
|
675
|
+
*
|
|
676
|
+
* @param name - A capability name known at compile time.
|
|
677
|
+
* @param config - The capability's packaging parameters (deep-link needs a scheme).
|
|
678
|
+
* @returns The resolved capability.
|
|
679
|
+
* @throws {Error} `[native] deep-link capability requires a non-empty scheme.` without a scheme.
|
|
680
|
+
* @example
|
|
681
|
+
* ```ts
|
|
682
|
+
* // What a custom URL scheme adds to tauri.conf.json.
|
|
683
|
+
* app.project.resolve("deep-link", { mode: "scheme", scheme: "myapp" }).conf;
|
|
684
|
+
* // { desktop: { schemes: ["myapp"] }, mobile: [{ scheme: ["myapp"], appLink: false }] }
|
|
685
|
+
* ```
|
|
686
|
+
*/
|
|
366
687
|
resolve<K extends keyof CapabilityConfigMap>(name: K, config?: CapabilityConfigMap[K]): ResolvedCapability;
|
|
688
|
+
/**
|
|
689
|
+
* Narrows a capability name that arrives as a plain string (a `config.system` entry) to
|
|
690
|
+
* one the registry knows, before it is handed to {@link Api.resolve}.
|
|
691
|
+
*
|
|
692
|
+
* @param name - A capability name to test against the registry.
|
|
693
|
+
* @returns True, narrowing `name`, when the registry has a row for it.
|
|
694
|
+
* @example
|
|
695
|
+
* ```ts
|
|
696
|
+
* // A system entry typed by hand: only registry names resolve.
|
|
697
|
+
* app.project.isKnownCapability("store"); // true
|
|
698
|
+
* app.project.isKnownCapability("camera"); // false
|
|
699
|
+
* ```
|
|
700
|
+
*/
|
|
367
701
|
isKnownCapability(name: string): name is keyof CapabilityConfigMap;
|
|
702
|
+
/**
|
|
703
|
+
* Lists every capability registry row — pinned crate and npm ranges, permissions,
|
|
704
|
+
* platforms and research confidence — as fresh copies, so a caller can never mutate the
|
|
705
|
+
* registry. Doctor checks the installed versions against them.
|
|
706
|
+
*
|
|
707
|
+
* @returns A copy of every registry row, in registry order.
|
|
708
|
+
* @example
|
|
709
|
+
* ```ts
|
|
710
|
+
* // Doctor walks the rows to compare pinned ranges with what is installed.
|
|
711
|
+
* ctx.require(projectPlugin).getRegistryRows().map(row => row.name);
|
|
712
|
+
* // ["store", "notification", "clipboard-manager", "tray", "deep-link", "back", "haptics", "shell"]
|
|
713
|
+
* ```
|
|
714
|
+
*/
|
|
368
715
|
getRegistryRows(): ReadonlyArray<RegistryRow>;
|
|
716
|
+
/**
|
|
717
|
+
* Returns the required-file set a mobile `gen/<platform>` tree must carry — the set
|
|
718
|
+
* {@link Api.getCompleteness} checks, for doctor to name in its report.
|
|
719
|
+
*
|
|
720
|
+
* @param opts - The lookup options.
|
|
721
|
+
* @param opts.target - The mobile platform to list required files for.
|
|
722
|
+
* @returns The required paths, relative to `src-tauri/gen/<platform>`.
|
|
723
|
+
* @example
|
|
724
|
+
* ```ts
|
|
725
|
+
* // Doctor reports how many required files a complete iOS tree carries.
|
|
726
|
+
* ctx.require(projectPlugin).getRequiredFiles({ target: "ios" });
|
|
727
|
+
* // ["project.yml", "Assets.xcassets", "Sources", "ExportOptions.plist"]
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
369
730
|
getRequiredFiles(opts: {
|
|
370
731
|
target: MobileTarget;
|
|
371
732
|
}): readonly string[];
|
|
733
|
+
/**
|
|
734
|
+
* Resolves the Android SDK debug keystore the debug profile signs with,
|
|
735
|
+
* `<home>/.android/debug.keystore`, and the shell command that creates it. Home is `HOME`,
|
|
736
|
+
* or `USERPROFILE` when `HOME` is unset or empty — the same rule {@link Api.patchMobile}
|
|
737
|
+
* signs by, so doctor's check and the build never disagree. Never throws: without a home
|
|
738
|
+
* directory `path` is undefined and the command names an unquoted `~/.android`. Reads the
|
|
739
|
+
* environment only, never the filesystem.
|
|
740
|
+
*
|
|
741
|
+
* @returns The keystore path and the `mkdir -p … && keytool -genkeypair …` command.
|
|
742
|
+
* @example
|
|
743
|
+
* ```ts
|
|
744
|
+
* // Doctor warns before a debug build that could not be signed; HOME is /home/me.
|
|
745
|
+
* ctx.require(projectPlugin).getDebugKeystore();
|
|
746
|
+
* // { path: "/home/me/.android/debug.keystore",
|
|
747
|
+
* // createCommand: 'mkdir -p "/home/me/.android" && keytool -genkeypair -v -keystore "/home/me/.android/debug.keystore" …' }
|
|
748
|
+
* ```
|
|
749
|
+
*/
|
|
750
|
+
getDebugKeystore(): DebugKeystore;
|
|
372
751
|
};
|
|
373
752
|
//#endregion
|
|
374
753
|
//#region src/plugins/tauri/errors.d.ts
|
|
@@ -425,7 +804,17 @@ type SpawnFn = (opts: {
|
|
|
425
804
|
stdout: string;
|
|
426
805
|
stderr: string;
|
|
427
806
|
}>;
|
|
428
|
-
/**
|
|
807
|
+
/**
|
|
808
|
+
* Per-plugin config of tauri: the readiness budget `dev` polls `web.devUrl` with, plus test
|
|
809
|
+
* seams (spawn, node path, host arch) that fall back to the real host when `undefined`
|
|
810
|
+
* (`| undefined` is required under exactOptionalPropertyTypes).
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* ```ts
|
|
814
|
+
* // A slow first Rust compile: give the dev server three minutes to answer.
|
|
815
|
+
* createApp({ pluginConfigs: { tauri: { readiness: { intervalMs: 250, timeoutMs: 180_000 } } } });
|
|
816
|
+
* ```
|
|
817
|
+
*/
|
|
429
818
|
type Config$3 = {
|
|
430
819
|
spawnImpl?: SpawnFn | undefined;
|
|
431
820
|
nodePath?: string | undefined;
|
|
@@ -462,12 +851,29 @@ type BuildArgvOptions = BuildFlavor & {
|
|
|
462
851
|
target: Target; /** iOS: `--export-method` for a device build; ignored for a simulator build. */
|
|
463
852
|
exportMethod?: AppleExportMethod | undefined;
|
|
464
853
|
};
|
|
465
|
-
/**
|
|
854
|
+
/**
|
|
855
|
+
* Options for `Api.build` — the argv options, the live output/progress callbacks, and extra
|
|
856
|
+
* environment for the child process.
|
|
857
|
+
*/
|
|
466
858
|
type BuildOptions = BuildArgvOptions & {
|
|
467
859
|
onTick?: ((tick: CompileTick) => void) | undefined;
|
|
468
860
|
onOutput?: ((line: string) => void) | undefined;
|
|
861
|
+
/**
|
|
862
|
+
* Extra environment for the spawned tauri CLI, merged over the inherited one — it reaches the
|
|
863
|
+
* web build tauri runs (`beforeBuildCommand`), e.g. `{ MOKU_NATIVE_PROFILE: "debug" }`. Never
|
|
864
|
+
* changes the argv. Omitted: the spawn call carries no `env` key at all.
|
|
865
|
+
*/
|
|
866
|
+
env?: Readonly<Record<string, string>> | undefined;
|
|
469
867
|
};
|
|
470
|
-
/**
|
|
868
|
+
/**
|
|
869
|
+
* How a dev session ended: the exit code, or the signal that stopped it (`code: null`).
|
|
870
|
+
*
|
|
871
|
+
* @example
|
|
872
|
+
* ```ts
|
|
873
|
+
* // Ctrl-C stops the session through a signal: no code, and not a failure.
|
|
874
|
+
* const exit: DevExit = { code: null, signal: "SIGTERM" };
|
|
875
|
+
* ```
|
|
876
|
+
*/
|
|
471
877
|
type DevExit = {
|
|
472
878
|
code: number | null;
|
|
473
879
|
signal: string | null;
|
|
@@ -492,26 +898,127 @@ type TauriErrorDetails = {
|
|
|
492
898
|
*/
|
|
493
899
|
readonly stderrTail: string;
|
|
494
900
|
};
|
|
495
|
-
/**
|
|
901
|
+
/**
|
|
902
|
+
* Mutable plugin state: the one live dev handle, kept so a second `dev` call is refused
|
|
903
|
+
* while a session runs; `undefined` when none is live (unicorn/no-null).
|
|
904
|
+
*/
|
|
496
905
|
type State$1 = {
|
|
497
906
|
dev: DevHandle | undefined;
|
|
498
907
|
};
|
|
499
908
|
/** Public API of the tauri plugin — the framework's ONLY subprocess seam. */
|
|
500
909
|
type Api$3 = {
|
|
910
|
+
/**
|
|
911
|
+
* Regenerates the icon set from a source image (`tauri icon`) into
|
|
912
|
+
* `<projectDir>/src-tauri/icons`.
|
|
913
|
+
*
|
|
914
|
+
* @param opts - Icon options.
|
|
915
|
+
* @param opts.source - Path to the source icon image.
|
|
916
|
+
* @returns The completed run's result.
|
|
917
|
+
* @throws {Error} A classified `TauriError` on a non-zero exit.
|
|
918
|
+
* @example
|
|
919
|
+
* ```ts
|
|
920
|
+
* // The build plugin's icons phase, with the source project.ensureIconSource() resolved.
|
|
921
|
+
* const tauri = ctx.require(tauriPlugin);
|
|
922
|
+
* await tauri.icon({ source: "/work/demo/assets/icon.png" }); // { code: 0, stdout, stderr, durationMs }
|
|
923
|
+
* ```
|
|
924
|
+
*/
|
|
501
925
|
icon(opts: {
|
|
502
926
|
source: string;
|
|
503
927
|
}): Promise<RunResult>;
|
|
928
|
+
/**
|
|
929
|
+
* Runs `tauri build` / `tauri ios|android build` for the given target, streaming scrubbed
|
|
930
|
+
* output and parsed compile ticks through the callbacks.
|
|
931
|
+
*
|
|
932
|
+
* @param opts - Build options (target, artifact flavour, progress callbacks, child env).
|
|
933
|
+
* @param opts.target - Packaging target.
|
|
934
|
+
* @param opts.simulator - iOS: build the host's simulator slice instead of a device archive.
|
|
935
|
+
* @param opts.exportMethod - iOS device builds: the `--export-method` to archive with.
|
|
936
|
+
* @param opts.aab - Android: emit a store bundle instead of the default installable APK.
|
|
937
|
+
* @param opts.onTick - Called with parsed compile progress ("Compiling crate N/M").
|
|
938
|
+
* @param opts.onOutput - Called with each scrubbed output line.
|
|
939
|
+
* @param opts.env - Extra environment for the tauri CLI, merged over the inherited one, so
|
|
940
|
+
* the web build tauri runs (`beforeBuildCommand`) can read it. Never changes the argv: the
|
|
941
|
+
* debug profile is still a release build (no `--debug`).
|
|
942
|
+
* @returns The completed run's result.
|
|
943
|
+
* @throws {Error} A classified `TauriError` on a non-zero exit.
|
|
944
|
+
* @example
|
|
945
|
+
* ```ts
|
|
946
|
+
* // The build plugin's compile phase: the web build reads MOKU_NATIVE_PROFILE, the APK stays --release.
|
|
947
|
+
* const tauri = ctx.require(tauriPlugin);
|
|
948
|
+
* await tauri.build({ target: "android", env: { MOKU_NATIVE_PROFILE: "debug" } });
|
|
949
|
+
* // { code: 0, stdout, stderr, durationMs }
|
|
950
|
+
* ```
|
|
951
|
+
*/
|
|
504
952
|
build(opts: BuildOptions): Promise<RunResult>;
|
|
953
|
+
/**
|
|
954
|
+
* Runs `tauri ios|android init` — the ONLY init verbs (D-013). Callers must check that
|
|
955
|
+
* `project.getCompleteness({ target })` reports `"not-initialized"` before calling this.
|
|
956
|
+
*
|
|
957
|
+
* @param opts - Mobile init options.
|
|
958
|
+
* @param opts.target - Mobile target to initialize.
|
|
959
|
+
* @returns The completed run's result.
|
|
960
|
+
* @throws {Error} A classified `TauriError` on a non-zero exit.
|
|
961
|
+
* @example
|
|
962
|
+
* ```ts
|
|
963
|
+
* // The build plugin's codegen pass initializes a mobile tree only when none exists yet.
|
|
964
|
+
* const tauri = ctx.require(tauriPlugin);
|
|
965
|
+
* if (ctx.require(projectPlugin).getCompleteness({ target: "ios" }).status === "not-initialized") {
|
|
966
|
+
* await tauri.mobileInit({ target: "ios" }); // writes <projectDir>/src-tauri/gen/apple
|
|
967
|
+
* }
|
|
968
|
+
* ```
|
|
969
|
+
*/
|
|
505
970
|
mobileInit(opts: {
|
|
506
971
|
target: MobileTarget;
|
|
507
972
|
}): Promise<RunResult>;
|
|
973
|
+
/**
|
|
974
|
+
* Starts the long-lived dev verb (`tauri dev` / `tauri ios|android dev`). Returns at once
|
|
975
|
+
* with a live handle — never awaits `exited` itself.
|
|
976
|
+
*
|
|
977
|
+
* @param opts - Dev options.
|
|
978
|
+
* @param opts.target - Optional packaging target (desktop-uniform when omitted).
|
|
979
|
+
* @param opts.onOutput - Called with each scrubbed output line (cli renders these; defaults to log-only).
|
|
980
|
+
* @returns The live dev handle.
|
|
981
|
+
* @throws {Error} `[native]` when a dev session is already running.
|
|
982
|
+
* @example
|
|
983
|
+
* ```ts
|
|
984
|
+
* // The cli's dev command: wait for the dev server, then for the session to end.
|
|
985
|
+
* const handle = await ctx.require(tauriPlugin).dev({ target: "ios", onOutput: line => ui.line(line) });
|
|
986
|
+
* await handle.ready; // web.devUrl answered
|
|
987
|
+
* await handle.exited; // code: null after Ctrl-C — a signal ended it, the normal end
|
|
988
|
+
* ```
|
|
989
|
+
*/
|
|
508
990
|
dev(opts: {
|
|
509
991
|
target?: Target | undefined;
|
|
510
992
|
onOutput?: ((line: string) => void) | undefined;
|
|
511
993
|
}): Promise<DevHandle>;
|
|
994
|
+
/**
|
|
995
|
+
* Probes CLI presence/version via `tauri info` — used by `doctor`.
|
|
996
|
+
*
|
|
997
|
+
* @returns The parsed CLI version, or `undefined` when the CLI can't be invoked.
|
|
998
|
+
* @example
|
|
999
|
+
* ```ts
|
|
1000
|
+
* // doctor's tauri-cli check: the one probe routed through the tauri plugin.
|
|
1001
|
+
* const version = await ctx.require(tauriPlugin).getVersion();
|
|
1002
|
+
* version?.cliVersion; // "2.11.4", or undefined when `tauri info` cannot run
|
|
1003
|
+
* ```
|
|
1004
|
+
*/
|
|
512
1005
|
getVersion(): Promise<{
|
|
513
1006
|
cliVersion: string;
|
|
514
1007
|
} | undefined>;
|
|
1008
|
+
/**
|
|
1009
|
+
* Returns the resolved `node` + `tauri.js` pair every verb spawns with, so
|
|
1010
|
+
* `project.patchMobile` can write the same invocation into the generated Xcode/Gradle
|
|
1011
|
+
* build scripts (tauri emits a bare `node tauri`, which does not exist).
|
|
1012
|
+
*
|
|
1013
|
+
* @returns The resolved invocation prefix.
|
|
1014
|
+
* @throws {Error} `[native]` when `node` or the tauri CLI cannot be resolved.
|
|
1015
|
+
* @example
|
|
1016
|
+
* ```ts
|
|
1017
|
+
* // The build plugin's codegen pass, after the mobile init.
|
|
1018
|
+
* const runner = ctx.require(tauriPlugin).getRunner(); // { nodePath: "/usr/local/bin/node", tauriJsPath: "…/@tauri-apps/cli/tauri.js" }
|
|
1019
|
+
* await ctx.require(projectPlugin).patchMobile({ target: "ios", runner, profile: "store" });
|
|
1020
|
+
* ```
|
|
1021
|
+
*/
|
|
515
1022
|
getRunner(): TauriRunner;
|
|
516
1023
|
};
|
|
517
1024
|
/**
|
|
@@ -525,7 +1032,7 @@ type TauriContext = PluginCtx<Config$3, State$1> & {
|
|
|
525
1032
|
readonly env: EnvApi;
|
|
526
1033
|
};
|
|
527
1034
|
declare namespace types_d_exports {
|
|
528
|
-
export { Api$2 as Api, BuildContext, BuildDeps, BuildResult, PathResolver, PhaseTiming, RunAllOptions, RunOptions };
|
|
1035
|
+
export { Api$2 as Api, BuildContext, BuildDeps, BuildResult, PathResolver, PhaseTiming, PrepareOptions, RunAllOptions, RunOptions };
|
|
529
1036
|
}
|
|
530
1037
|
/** One pipeline phase's measured duration, in execution order. */
|
|
531
1038
|
type PhaseTiming = {
|
|
@@ -534,11 +1041,17 @@ type PhaseTiming = {
|
|
|
534
1041
|
};
|
|
535
1042
|
/** Result of one target's full pipeline pass — `phases` always carries all six entries. */
|
|
536
1043
|
type BuildResult = {
|
|
537
|
-
target: Target;
|
|
1044
|
+
target: Target; /** `<outDir>/<target>` for a store build, `<outDir>/<target>-debug` for a debug one. */
|
|
538
1045
|
outPath: string;
|
|
539
1046
|
artifacts: readonly string[];
|
|
540
1047
|
durationMs: number;
|
|
541
|
-
phases: readonly PhaseTiming[];
|
|
1048
|
+
phases: readonly PhaseTiming[]; /** The profile the artifacts were built in — the same value `native:complete` carries. */
|
|
1049
|
+
profile: BuildProfile;
|
|
1050
|
+
};
|
|
1051
|
+
/** Options for a prepare pass: the target, and `debug` for the debug profile (Android only). */
|
|
1052
|
+
type PrepareOptions = {
|
|
1053
|
+
target: Target;
|
|
1054
|
+
debug?: boolean | undefined;
|
|
542
1055
|
};
|
|
543
1056
|
/** Options for one target's pipeline pass. Platform-specific flags are ignored elsewhere. */
|
|
544
1057
|
type RunOptions = BuildFlavor & {
|
|
@@ -560,15 +1073,61 @@ type PathResolver = (target: string) => string;
|
|
|
560
1073
|
* cross-plugin surface build depends on (D-007) is readable in one place.
|
|
561
1074
|
*/
|
|
562
1075
|
type BuildDeps = {
|
|
563
|
-
readonly project: Pick<Api$4, "generate" | "getBundleLayout" | "getCompleteness" | "patchMobile" | "clearMobileBuildOutput" | "ensureIconSource" | "resolveDerivedPath">;
|
|
1076
|
+
readonly project: Pick<Api$4, "generate" | "getBundleLayout" | "getCompleteness" | "patchMobile" | "clearMobileBuildOutput" | "ensureIconSource" | "resolveDerivedPath" | "patchMobileIcons" | "detectPageAgent" | "checkShellLinked">;
|
|
564
1077
|
readonly tauri: Pick<Api$3, "build" | "mobileInit" | "icon" | "getRunner">;
|
|
565
1078
|
};
|
|
566
1079
|
/** Public API of the build plugin — the per-target pipeline orchestrator. */
|
|
567
1080
|
type Api$2 = {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
1081
|
+
/**
|
|
1082
|
+
* Brings the generated project to a buildable state — scaffold, codegen, icons — and stops
|
|
1083
|
+
* there, in the store profile or, with `debug`, the debug one. `dev` calls it before
|
|
1084
|
+
* handing the tree to `tauri dev`, so a dev session never compiles a stale tree.
|
|
1085
|
+
*
|
|
1086
|
+
* @param opts - The target to prepare, and `debug` for the debug profile.
|
|
1087
|
+
* @returns Nothing; the tree under `projectDir` is ready for the build verb.
|
|
1088
|
+
* @throws {Error} `[native] --debug builds Android only for now (asked for <target>).` when
|
|
1089
|
+
* `debug` is set for any target but android — before any phase runs.
|
|
1090
|
+
* @example
|
|
1091
|
+
* ```ts
|
|
1092
|
+
* // A consumer prepares the debug tree of the phone build to open it in Android Studio: the
|
|
1093
|
+
* // shell crate is generated and the debug patches are applied, nothing is compiled.
|
|
1094
|
+
* await ctx.require(buildPlugin).prepare({ target: "android", debug: true });
|
|
1095
|
+
* ```
|
|
1096
|
+
*/
|
|
1097
|
+
prepare(opts: PrepareOptions): Promise<void>;
|
|
1098
|
+
/**
|
|
1099
|
+
* Runs the full `scaffold → codegen → icons → compile → bundle → collect` pipeline for one
|
|
1100
|
+
* target, emitting `native:phase` per phase and `native:complete` on success. A store build
|
|
1101
|
+
* whose page carries the editor agent is refused after the compile, before anything is
|
|
1102
|
+
* collected; a debug build is delivered into `<outDir>/<target>-debug`, beside the store one.
|
|
1103
|
+
*
|
|
1104
|
+
* @param opts - The target plus the platform flags (`simulator`, `aab`, `debug`).
|
|
1105
|
+
* @returns The completed pipeline's result.
|
|
1106
|
+
* @throws {Error} The first failing phase's error; `[native] --debug builds Android only …`
|
|
1107
|
+
* for `debug` on another target, before any phase.
|
|
1108
|
+
* @example
|
|
1109
|
+
* ```ts
|
|
1110
|
+
* // A debug build for the phone, installed beside the store app.
|
|
1111
|
+
* const result = await app.build.run({ target: "android", debug: true });
|
|
1112
|
+
* // result.outPath === "dist-native/android-debug", result.profile === "debug"
|
|
1113
|
+
* ```
|
|
1114
|
+
*/
|
|
571
1115
|
run(opts: RunOptions): Promise<BuildResult>;
|
|
1116
|
+
/**
|
|
1117
|
+
* Runs the pipeline sequentially for every target in `opts.targets` (default: the configured
|
|
1118
|
+
* `targets`), stopping at the first failing target. With `debug`, every target is checked up
|
|
1119
|
+
* front and the whole run is refused when one is not android — nothing is half-built.
|
|
1120
|
+
*
|
|
1121
|
+
* @param opts - The targets plus the platform flags threaded into every run.
|
|
1122
|
+
* @returns Every completed target's result, in target order.
|
|
1123
|
+
* @throws {Error} Whatever the first failing target's pipeline throws.
|
|
1124
|
+
* @example
|
|
1125
|
+
* ```ts
|
|
1126
|
+
* // targets: ["android"] in the app config
|
|
1127
|
+
* const [phone] = await app.build.runAll({ debug: true });
|
|
1128
|
+
* // phone.profile === "debug", phone.outPath === "dist-native/android-debug"
|
|
1129
|
+
* ```
|
|
1130
|
+
*/
|
|
572
1131
|
runAll(opts?: RunAllOptions): Promise<readonly BuildResult[]>;
|
|
573
1132
|
};
|
|
574
1133
|
/**
|
|
@@ -583,8 +1142,8 @@ type BuildContext = PluginCtx<Record<string, never>, Record<string, never>, Even
|
|
|
583
1142
|
};
|
|
584
1143
|
//#endregion
|
|
585
1144
|
//#region src/plugins/doctor/checks/types.d.ts
|
|
586
|
-
/** The project plugin's API surface a check may read — narrowed to doctor's
|
|
587
|
-
type CheckProjectApi = Pick<Api$4, "getRequiredFiles" | "getCompleteness" | "getRegistryRows">;
|
|
1145
|
+
/** The project plugin's API surface a check may read — narrowed to doctor's four needs. */
|
|
1146
|
+
type CheckProjectApi = Pick<Api$4, "getRequiredFiles" | "getCompleteness" | "getRegistryRows" | "getDebugKeystore">;
|
|
588
1147
|
/** The tauri plugin's API surface a check may read — the one probe routed through tauri (D-013). */
|
|
589
1148
|
type CheckTauriApi = Pick<Api$3, "getVersion">;
|
|
590
1149
|
declare namespace types_d_exports$2 {
|
|
@@ -638,6 +1197,25 @@ type DoctorDeps = {
|
|
|
638
1197
|
};
|
|
639
1198
|
/** Public API of the doctor plugin. */
|
|
640
1199
|
type Api$1 = {
|
|
1200
|
+
/**
|
|
1201
|
+
* Runs every check applicable to `opts.target` (or every configured target + host checks
|
|
1202
|
+
* when omitted), in parallel, emitting `doctor:check` for each one as it settles. Never
|
|
1203
|
+
* throws on check failures — a rejected check becomes an internal-error "fail" result and a
|
|
1204
|
+
* check that outruns `probeTimeoutMs` becomes a "warn" result; `run()` only throws on a
|
|
1205
|
+
* genuine internal bug in this orchestration itself.
|
|
1206
|
+
*
|
|
1207
|
+
* @param opts - Optional scoping.
|
|
1208
|
+
* @param opts.target - A single real packaging target to diagnose, or every configured
|
|
1209
|
+
* target + host checks when omitted.
|
|
1210
|
+
* @returns The aggregated report — `checks` stays in registry order regardless of the
|
|
1211
|
+
* order the individual checks settled (and were emitted) in.
|
|
1212
|
+
* @example
|
|
1213
|
+
* ```ts
|
|
1214
|
+
* // The cli's doctor command: diagnose one target, then render the summary.
|
|
1215
|
+
* const report = await ctx.require(doctorPlugin).run({ target: "ios" });
|
|
1216
|
+
* report.ok; // false when any check failed — warnings alone keep it true
|
|
1217
|
+
* ```
|
|
1218
|
+
*/
|
|
641
1219
|
run(opts?: {
|
|
642
1220
|
target?: Target | undefined;
|
|
643
1221
|
}): Promise<DoctorReport>;
|
|
@@ -669,16 +1247,91 @@ type State = {
|
|
|
669
1247
|
};
|
|
670
1248
|
/** Public API of the cli plugin — typed verbs, NO argv parsing. */
|
|
671
1249
|
type Api = {
|
|
1250
|
+
/**
|
|
1251
|
+
* Builds one target (default: the host target) or every configured target with
|
|
1252
|
+
* `{ all: true }` (which ignores any given `target`). The flavor flags pass straight
|
|
1253
|
+
* through to `build.run`/`build.runAll`. Progress renders live through the plugin's
|
|
1254
|
+
* `native:phase`/`native:complete` hooks — a debug delivery is marked
|
|
1255
|
+
* `debug build → <outPath>` in the completion panel. A failure (the store refusal of an
|
|
1256
|
+
* editor-agent page included) renders the scrubbed stderr tail before the `[native]`
|
|
1257
|
+
* error line, then rethrows unchanged.
|
|
1258
|
+
*
|
|
1259
|
+
* @param opts - Build options.
|
|
1260
|
+
* @param opts.target - The packaging target (default: the resolved host target).
|
|
1261
|
+
* @param opts.all - Build every configured target instead of one (ignores `target`).
|
|
1262
|
+
* @param opts.simulator - iOS: build for the host's simulator arch instead of a device archive.
|
|
1263
|
+
* @param opts.aab - Android: emit a store bundle (`.aab`) instead of an `.apk`.
|
|
1264
|
+
* @param opts.debug - Build the debug profile (Android only), delivered to `<outDir>/<target>-debug`.
|
|
1265
|
+
* @returns Resolves once the build (or all builds) complete.
|
|
1266
|
+
* @throws {Error} Whatever the pipeline throws — after rendering the failure.
|
|
1267
|
+
* `[native] --debug builds Android only …` when `debug` is set with a non-android target,
|
|
1268
|
+
* (or `all: true` with a non-android target).
|
|
1269
|
+
* @example
|
|
1270
|
+
* ```ts
|
|
1271
|
+
* // A debug build for the phone, installed beside the store app; the completion panel
|
|
1272
|
+
* // reads "debug build → dist-native/android-debug".
|
|
1273
|
+
* await app.cli.build({ target: "android", debug: true });
|
|
1274
|
+
* // Every configured target, store profile.
|
|
1275
|
+
* await app.cli.build({ all: true });
|
|
1276
|
+
* ```
|
|
1277
|
+
*/
|
|
672
1278
|
build(opts?: BuildFlavor & {
|
|
673
1279
|
target?: Target | undefined;
|
|
674
1280
|
all?: boolean | undefined;
|
|
675
1281
|
}): Promise<void>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Runs the dev loop. Brings the generated project to a buildable state first —
|
|
1284
|
+
* `build.prepare` runs scaffold → codegen → icons, so `tauri dev` never meets a
|
|
1285
|
+
* half-generated tree, and a failure there renders exactly like a failed build — then
|
|
1286
|
+
* awaits the dev handle's `ready` and `exited`. It NEVER stores the handle and NEVER calls
|
|
1287
|
+
* `stop()` itself (D-002); teardown is owned by the tauri seam (signal handlers,
|
|
1288
|
+
* process-group kill).
|
|
1289
|
+
*
|
|
1290
|
+
* @param opts - Dev options.
|
|
1291
|
+
* @param opts.target - Packaging target (default: the resolved host target).
|
|
1292
|
+
* @returns Resolves once the dev session exits cleanly (a Ctrl-C exit included).
|
|
1293
|
+
* @throws {Error} `[native]` when the host has no desktop target, or when the dev
|
|
1294
|
+
* session exits with a non-zero code.
|
|
1295
|
+
* @example
|
|
1296
|
+
* ```ts
|
|
1297
|
+
* // Live-reload the app in the iOS simulator until Ctrl-C.
|
|
1298
|
+
* await app.cli.dev({ target: "ios" });
|
|
1299
|
+
* ```
|
|
1300
|
+
*/
|
|
676
1301
|
dev(opts?: {
|
|
677
1302
|
target?: Target | undefined;
|
|
678
1303
|
}): Promise<void>;
|
|
1304
|
+
/**
|
|
1305
|
+
* Runs diagnosis, renders the summary, and returns whether every check passed. The
|
|
1306
|
+
* per-check rows (with their fix-its) print exactly once, live from this plugin's
|
|
1307
|
+
* `doctor:check` hook; this method adds only the counts and the verdict.
|
|
1308
|
+
*
|
|
1309
|
+
* @param opts - Optional scoping.
|
|
1310
|
+
* @param opts.target - A single target to diagnose (default: every configured target + host).
|
|
1311
|
+
* @returns Whether the report is `ok` (no failing check) — the caller sets `process.exitCode`.
|
|
1312
|
+
* @example
|
|
1313
|
+
* ```ts
|
|
1314
|
+
* // A CI step that fails when the Android toolchain is incomplete.
|
|
1315
|
+
* if (!(await app.cli.doctor({ target: "android" }))) process.exitCode = 1;
|
|
1316
|
+
* ```
|
|
1317
|
+
*/
|
|
679
1318
|
doctor(opts?: {
|
|
680
1319
|
target?: Target | undefined;
|
|
681
1320
|
}): Promise<boolean>;
|
|
1321
|
+
/**
|
|
1322
|
+
* Cleans derived state. Without a `target`, this wipes the ENTIRE project directory —
|
|
1323
|
+
* gated behind a styled confirm — before delegating to `project.clean` (D-006: project
|
|
1324
|
+
* owns the destructive filesystem knowledge, cli is a thin delegate).
|
|
1325
|
+
*
|
|
1326
|
+
* @param opts - Clean options.
|
|
1327
|
+
* @param opts.target - A single target to clean (default: confirm, then wipe everything).
|
|
1328
|
+
* @returns Resolves once cleaning completes (or immediately, if the user declines).
|
|
1329
|
+
* @example
|
|
1330
|
+
* ```ts
|
|
1331
|
+
* // Regenerate only the Android tree on the next build; no confirm is asked.
|
|
1332
|
+
* await app.cli.clean({ target: "android" });
|
|
1333
|
+
* ```
|
|
1334
|
+
*/
|
|
682
1335
|
clean(opts?: {
|
|
683
1336
|
target?: Target | undefined;
|
|
684
1337
|
}): Promise<void>;
|
|
@@ -759,10 +1412,11 @@ declare const doctorPlugin: import("@moku-labs/core").PluginInstance<"doctor", C
|
|
|
759
1412
|
//#endregion
|
|
760
1413
|
//#region src/plugins/project/index.d.ts
|
|
761
1414
|
/**
|
|
762
|
-
* Complex tier — capability registry + generators/
|
|
763
|
-
* sub-domain (completeness gate,
|
|
764
|
-
*
|
|
765
|
-
*
|
|
1415
|
+
* Complex tier — capability registry + generators/ (the `tauri-plugin-moku-shell` crate
|
|
1416
|
+
* among them) + write-if-changed writer + the mobile/ sub-domain (completeness gate, build
|
|
1417
|
+
* profile patches, Android signing block, Android manifest attributes, adaptive icon inset,
|
|
1418
|
+
* shell link check, Xcode settings, runner-command rewrite) + the build-time orientation
|
|
1419
|
+
* lock + the page agent scan + the guarded clean.
|
|
766
1420
|
*
|
|
767
1421
|
* @see README.md
|
|
768
1422
|
* @example
|
|
@@ -779,9 +1433,8 @@ declare const projectPlugin: import("@moku-labs/core").PluginInstance<"project",
|
|
|
779
1433
|
* Each concern is its own file next to this one; the ≤30-line wiring rule keeps the layout
|
|
780
1434
|
* flat rather than nested.
|
|
781
1435
|
*
|
|
782
|
-
* NO onStop by design (D-002):
|
|
783
|
-
*
|
|
784
|
-
* (signal handlers + DevHandle.stop()), which also covers Ctrl-C where onStop never fires.
|
|
1436
|
+
* NO onStop by design (D-002): teardown is owned by the dev seam (signal handlers +
|
|
1437
|
+
* DevHandle.stop()), which also covers Ctrl-C where onStop never fires.
|
|
785
1438
|
*
|
|
786
1439
|
* @see README.md
|
|
787
1440
|
* @example
|
|
@@ -799,6 +1452,12 @@ declare const tauriPlugin: import("@moku-labs/core").PluginInstance<"tauri", Con
|
|
|
799
1452
|
* composition time, and returns the frozen, fully-typed app. See the file JSDoc above
|
|
800
1453
|
* for the full options/defaults tables.
|
|
801
1454
|
*
|
|
1455
|
+
* @param options - Optional `{ config?, pluginConfigs?, plugins?, onReady?, onError?, onStart?,
|
|
1456
|
+
* onStop? }`: a `Partial<Config>` shallow-merged over the defaults, per-plugin overrides
|
|
1457
|
+
* keyed by plugin name, extra consumer plugins appended to the defaults, and lifecycle
|
|
1458
|
+
* callbacks.
|
|
1459
|
+
* @returns The frozen, fully-typed app: `start`/`stop` plus one API per plugin
|
|
1460
|
+
* (`app.cli`, `app.build`, `app.doctor`, `app.project`, `app.tauri`).
|
|
802
1461
|
* @example
|
|
803
1462
|
* ```ts
|
|
804
1463
|
* export const native = createApp({ config: { app: { name: "MyApp", identifier: "com.example.myapp" } } });
|
|
@@ -812,6 +1471,9 @@ declare const createApp: <const ExtraPlugins extends readonly import("@moku-labs
|
|
|
812
1471
|
/**
|
|
813
1472
|
* Creates a consumer-authored plugin bound to this framework's chain.
|
|
814
1473
|
*
|
|
1474
|
+
* @param name - Unique plugin id; becomes the plugin's key on the app.
|
|
1475
|
+
* @param spec - Plugin spec (config, state, api, hooks, lifecycle); every type infers from it.
|
|
1476
|
+
* @returns A typed plugin instance for the `createCore` or `createApp` plugins array.
|
|
815
1477
|
* @example
|
|
816
1478
|
* ```ts
|
|
817
1479
|
* const myPlugin = createPlugin("my", { api: () => ({}) });
|
|
@@ -819,4 +1481,4 @@ declare const createApp: <const ExtraPlugins extends readonly import("@moku-labs
|
|
|
819
1481
|
*/
|
|
820
1482
|
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>]>>;
|
|
821
1483
|
//#endregion
|
|
822
|
-
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, type Orientation, 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 };
|
|
1484
|
+
export { type AppleExportMethod, type AppleSigning, type types_d_exports as Build, type BuildFlavor, type BuildProfile, 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, type Orientation, 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 };
|