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