@incajs/cli 0.0.2 → 0.0.4

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.
@@ -28,7 +28,8 @@ export declare function unscopedName(name: string): string;
28
28
  *
29
29
  * @param name - e.g. a `productName`
30
30
  * @returns `name` lowercased, with runs of non-`[a-z0-9]` collapsed to a
31
- * single `-` and trimmed from both ends
31
+ * single `-` and trimmed from both ends; `"app"` for a name that holds
32
+ * none of those characters
32
33
  */
33
34
  export declare function slugify(name: string): string;
34
35
  /**
@@ -1,3 +1,4 @@
1
+ import { WindowConfig } from './types.mts';
1
2
  /** `entry`/`outDir` only — what `build()`/`dev()` need, with no `package.json` requirement. */
2
3
  export interface ResolvedBuildConfig {
3
4
  /** Absolute path, if `inca.config.ts` set one. */
@@ -14,9 +15,21 @@ export interface ResolvedAppConfig extends ResolvedBuildConfig {
14
15
  version: string;
15
16
  /** Absolute path, if the app declared one. */
16
17
  icon?: string;
18
+ /** What the app declared about its window, if anything. */
19
+ window?: WindowConfig;
17
20
  /** package.json's `"inca"` key is deprecated; callers warn when this is true. */
18
21
  usedPackageJsonKey: boolean;
19
22
  }
23
+ /**
24
+ * What a built app carries for its host to read: the name the platform
25
+ * shows it under, the id it is known by, and its window. Each field is
26
+ * absent unless the app's config sets it.
27
+ */
28
+ export interface RuntimeConfig {
29
+ name?: string;
30
+ identifier?: string;
31
+ window?: WindowConfig;
32
+ }
20
33
  /**
21
34
  * Loads just `entry`/`outDir` from `inca.config.ts`, with derived defaults.
22
35
  * Never touches `package.json`.
@@ -35,3 +48,19 @@ export declare function resolveBuildConfig(cwd: string): Promise<ResolvedBuildCo
35
48
  * `productName`, or an `icon` doesn't resolve to a real file
36
49
  */
37
50
  export declare function resolveAppConfig(cwd: string): Promise<ResolvedAppConfig>;
51
+ /**
52
+ * Narrows a full config down to what a build carries for the host.
53
+ *
54
+ * @param config - a config {@link resolveAppConfig} returned
55
+ * @returns its name, id and window
56
+ */
57
+ export declare function runtimeConfigOf(config: ResolvedAppConfig): RuntimeConfig;
58
+ /**
59
+ * Loads {@link RuntimeConfig} for an app that may name itself nowhere.
60
+ * An app with no `package.json`, or none that gives it a name, still gets
61
+ * whatever window settings it declared.
62
+ *
63
+ * @param cwd - the app's root directory
64
+ * @returns the config, or `undefined` when the app declares none of it
65
+ */
66
+ export declare function resolveRuntimeConfig(cwd: string): Promise<RuntimeConfig | undefined>;
@@ -32,4 +32,35 @@ export interface IncaConfig {
32
32
  * @default "dist"
33
33
  */
34
34
  outDir?: string;
35
+ /** The window the app opens in. */
36
+ window?: WindowConfig;
37
+ }
38
+ /** What an app declares about its window — see {@link IncaConfig.window}. */
39
+ export interface WindowConfig {
40
+ /**
41
+ * Initial width, in pixels. Falls back to the width the app's root
42
+ * element declares, then to this default.
43
+ * @default 800
44
+ */
45
+ width?: number;
46
+ /**
47
+ * Initial height, in pixels. Falls back to the height the app's root
48
+ * element declares, then to this default.
49
+ * @default 600
50
+ */
51
+ height?: number;
52
+ /**
53
+ * The window's title.
54
+ * @default the app's productName
55
+ */
56
+ title?: string;
57
+ /**
58
+ * Whether a user can resize the window.
59
+ * @default false
60
+ */
61
+ resizable?: boolean;
62
+ /** Smallest width the window can be, in pixels. It opens at least this wide. */
63
+ minWidth?: number;
64
+ /** Smallest height the window can be, in pixels. It opens at least this tall. */
65
+ minHeight?: number;
35
66
  }
package/dist/config.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, t } from "./chunks/defaults-EWjAFeZ3.js";
1
+ import { a as e, t } from "./chunks/defaults-DNvHueCI.js";
2
2
  //#region src/config/index.mts
3
3
  var n = e();
4
4
  //#endregion
@@ -17,6 +17,11 @@ export interface HostClientOptions {
17
17
  onReady?: () => void;
18
18
  /** An app's own event listener threw; the host caught it and kept rendering. */
19
19
  onAppError?: (error: AppErrorParams) => void;
20
+ /**
21
+ * The host exited on its own — its window was closed, or it crashed.
22
+ * Not called for the exit `stop()` asks for.
23
+ */
24
+ onExit?: (code: number | null, signal: NodeJS.Signals | null) => void;
20
25
  /**
21
26
  * Handlers for notification `method`s this package doesn't implement
22
27
  * itself (e.g. a future Vite integration), keyed by method name —
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Claims `cwd` for this process. Two `inca dev`s on one app watch the same
3
+ * files and interleave their output on one terminal, and an orphan left by
4
+ * an earlier run stays invisible until this says so. A lock whose pid is
5
+ * gone is taken over.
6
+ *
7
+ * @returns a function releasing the lock.
8
+ * @throws if another live `inca dev` holds `cwd`.
9
+ */
10
+ export declare function acquireDevLock(cwd: string): Promise<() => Promise<void>>;
package/dist/dev.d.mts CHANGED
@@ -9,7 +9,10 @@ export interface DevOptions {
9
9
  entry?: string;
10
10
  /** Overrides the bundler — see {@link defaultBundler} for what's wired in by default. */
11
11
  bundler?: Bundler;
12
- /** Overrides host binary resolution — passed straight through to `HostClient`. */
12
+ /**
13
+ * Overrides host binary resolution. On macOS this is the binary the
14
+ * app bundle wraps; elsewhere it is launched directly.
15
+ */
13
16
  hostBin?: string;
14
17
  /** Defaults to `process.stdout`. */
15
18
  stdout?: NodeJS.WritableStream;
@@ -20,6 +23,9 @@ export interface DevOptions {
20
23
  }
21
24
  /**
22
25
  * Builds the app, starts `inca-host` once the first build lands, and
23
- * reloads it on every rebuild — until `options.signal` aborts.
26
+ * reloads it on every rebuild — until `options.signal` aborts or the host
27
+ * exits on its own.
28
+ *
29
+ * @throws if another `inca dev` is already running for this app.
24
30
  */
25
31
  export declare function dev(options: DevOptions): Promise<void>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A failure the CLI raises itself, identified by an `ERR_INCA_*` code the
3
+ * way Node's own errors carry one. The code is what a user searches for
4
+ * and what `printFault` names alongside the message, so every distinct
5
+ * cause gets its own.
6
+ */
7
+ export declare class IncaError extends Error {
8
+ readonly code: string;
9
+ readonly name = "IncaError";
10
+ constructor(code: string, message: string);
11
+ }
package/dist/log.d.mts ADDED
@@ -0,0 +1,28 @@
1
+ /** Shared by {@link log} and {@link printFault}. */
2
+ export interface LogOptions {
3
+ /** Prefixes the line with `HH:MM:SS`, the way Vite's dev server stamps its own. */
4
+ timestamp?: boolean;
5
+ }
6
+ /** Writes one `[inca] <message>` line to `stream`. */
7
+ export declare function log(stream: NodeJS.WritableStream, message: string, options?: LogOptions): void;
8
+ /** A failure reduced to the message and stack worth printing. */
9
+ export interface Fault {
10
+ message: string;
11
+ stack: string | null;
12
+ /** An `ERR_INCA_*` identifier, when the failure has one to look up. */
13
+ code?: string | null;
14
+ }
15
+ /**
16
+ * Reduces an error a bundler re-wrapped: its text is kept whole — the
17
+ * excerpt a compiler points at is the useful part — while the error class
18
+ * and any `ERR_INCA_*` marker are lifted off the first line, the latter
19
+ * into the fault's code.
20
+ */
21
+ export declare function bundlerFault(message: string): Fault;
22
+ /** Reduces a thrown value to a {@link Fault}. A `HostError` carries the host process's stack. */
23
+ export declare function toFault(error: unknown): Fault;
24
+ /**
25
+ * Writes `[inca] <label> (<code>): <message>` to `stream` — the code only
26
+ * when the failure carries one — followed by the stack when there is one.
27
+ */
28
+ export declare function printFault(stream: NodeJS.WritableStream, label: string, fault: Fault, options?: LogOptions): void;
@@ -0,0 +1,47 @@
1
+ /** The app metadata a `.app` bundle's `Info.plist` carries. */
2
+ export interface MacosAppMetadata {
3
+ /** The name macOS shows in the Dock, the menu bar and the Finder. */
4
+ productName: string;
5
+ /** A reverse-DNS-style unique id, written as `CFBundleIdentifier`. */
6
+ identifier: string;
7
+ /** The app's version, written as both `CFBundleVersion` and `CFBundleShortVersionString`. */
8
+ version: string;
9
+ /** Absolute path to an icon file, copied into `Contents/Resources`. */
10
+ icon?: string;
11
+ }
12
+ /** Options for {@link writeMacosApp}. */
13
+ export interface WriteMacosAppOptions {
14
+ /** Where the `.app` directory is written. An existing one there is replaced. */
15
+ appPath: string;
16
+ /** What the bundle's `Info.plist` describes. */
17
+ metadata: MacosAppMetadata;
18
+ /** The `inca-host` binary the bundle's executable is made from. */
19
+ hostBin: string;
20
+ /**
21
+ * Hard-links the executable to `hostBin` rather than copying it, and
22
+ * copies when the two paths are on different filesystems. Set it where
23
+ * the bundle is rebuilt often and holds no files of its own.
24
+ */
25
+ link?: boolean;
26
+ }
27
+ /** The paths {@link writeMacosApp} created. */
28
+ export interface MacosApp {
29
+ /** The `.app` directory itself. */
30
+ appPath: string;
31
+ /** The bundle's executable, at `Contents/MacOS/<productName>`. */
32
+ executablePath: string;
33
+ /** `Contents/Resources`, where an app's own files belong. */
34
+ resourcesDir: string;
35
+ }
36
+ /**
37
+ * Writes a macOS `.app` bundle around the `inca-host` binary:
38
+ * `Contents/MacOS` holding the executable, `Contents/Resources` left empty
39
+ * apart from the icon, and `Info.plist`/`PkgInfo` beside them. macOS reads
40
+ * the app's name, icon and identifier from the bundle, so an executable
41
+ * launched from one carries them wherever the platform shows an app.
42
+ *
43
+ * @param options - where to write, what to describe, and which binary to use
44
+ * @returns the bundle's own path, its executable, and its resources directory
45
+ * @throws if any part of the bundle can't be written
46
+ */
47
+ export declare function writeMacosApp(options: WriteMacosAppOptions): Promise<MacosApp>;
@@ -24,8 +24,10 @@ export interface PackageAppOptions {
24
24
  * process is running on.
25
25
  */
26
26
  target?: PackageTarget;
27
- /** Where progress notes go. Defaults to `process.stdout`. */
27
+ /** Where progress notes and the bundler's own output go. Defaults to `process.stdout`. */
28
28
  stdout?: NodeJS.WritableStream;
29
+ /** Where the bundler's warnings and errors go. Defaults to `process.stderr`. */
30
+ stderr?: NodeJS.WritableStream;
29
31
  }
30
32
  /** The result of a successful {@link packageApp} call. */
31
33
  export interface PackageResult {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@incajs/cli",
3
- "version": "0.0.2",
4
- "description": "The inca CLI: watches an app's entry point through a bundler adapter, starts inca-host once the first bundle lands, and reloads it on every rebuild.",
3
+ "version": "0.0.4",
4
+ "description": "Dev server, bundler, and packager for Incarnative.js apps.",
5
5
  "keywords": [
6
6
  "bundler",
7
7
  "cli",
@@ -68,9 +68,9 @@
68
68
  }
69
69
  },
70
70
  "optionalDependencies": {
71
- "@incajs/host-darwin-arm64": "0.0.2",
72
- "@incajs/host-linux-arm64": "0.0.2",
73
- "@incajs/host-linux-x64": "0.0.2"
71
+ "@incajs/host-darwin-arm64": "0.0.4",
72
+ "@incajs/host-linux-arm64": "0.0.4",
73
+ "@incajs/host-linux-x64": "0.0.4"
74
74
  },
75
75
  "engines": {
76
76
  "node": ">=22.18"
package/dist/fault.d.mts DELETED
@@ -1,6 +0,0 @@
1
- export interface Fault {
2
- message: string;
3
- stack: string | null;
4
- }
5
- export declare function toFault(error: unknown): Fault;
6
- export declare function printFault(stream: NodeJS.WritableStream, label: string, fault: Fault): void;