@incajs/cli 0.0.0 → 0.0.2

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.
Files changed (42) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +66 -2
  3. package/bin/inca.mjs +7 -0
  4. package/dist/adapter/types.d.mts +47 -0
  5. package/dist/adapter/vite/build.d.mts +8 -0
  6. package/dist/adapter/vite/captureOutput.d.mts +15 -0
  7. package/dist/adapter/vite/config.d.mts +26 -0
  8. package/dist/adapter/vite/index.d.mts +2 -0
  9. package/dist/adapter/vite/watch.d.mts +8 -0
  10. package/dist/build.d.mts +21 -0
  11. package/dist/chunks/__vite-optional-peer-dep_dotenv_c12-CxKvRg9-.js +3 -0
  12. package/dist/chunks/__vite-optional-peer-dep_giget_c12-BYcrHYBM.js +5 -0
  13. package/dist/chunks/__vite-optional-peer-dep_jiti_c12-DZVJNj6v.js +5 -0
  14. package/dist/chunks/_format-BKs7bsc4.js +98 -0
  15. package/dist/chunks/defaults-EWjAFeZ3.js +1184 -0
  16. package/dist/chunks/dist-BVKUE9C4.js +114 -0
  17. package/dist/chunks/json5-feUuPtTt.js +756 -0
  18. package/dist/chunks/jsonc-BdzClvC8.js +46 -0
  19. package/dist/chunks/ohash-CHaRSTtv.js +231 -0
  20. package/dist/chunks/toml-BERh2MAo.js +417 -0
  21. package/dist/chunks/yaml-N2dF3WHm.js +2123 -0
  22. package/dist/cli.d.mts +2 -0
  23. package/dist/cli.js +503 -0
  24. package/dist/config/defaults.d.mts +44 -0
  25. package/dist/config/index.d.mts +18 -0
  26. package/dist/config/loader.d.mts +37 -0
  27. package/dist/config/types.d.mts +35 -0
  28. package/dist/config.js +5 -0
  29. package/dist/defaultBundler.d.mts +7 -0
  30. package/dist/dev-client/hostBin.d.mts +9 -0
  31. package/dist/dev-client/hostClient.d.mts +50 -0
  32. package/dist/dev-client/hostError.d.mts +6 -0
  33. package/dist/dev-client/index.d.mts +4 -0
  34. package/dist/dev-client/protocol.d.mts +38 -0
  35. package/dist/dev.d.mts +25 -0
  36. package/dist/entry.d.mts +8 -0
  37. package/dist/fault.d.mts +6 -0
  38. package/dist/index.d.mts +2 -0
  39. package/dist/index.js +0 -0
  40. package/dist/package.d.mts +45 -0
  41. package/dist/plist.d.mts +4 -0
  42. package/package.json +64 -3
@@ -0,0 +1,50 @@
1
+ import { AppErrorParams } from './protocol.mts';
2
+ export interface HostClientOptions {
3
+ /** The entry module passed to the host as `--dev <entryFile>`. */
4
+ entryFile: string;
5
+ /** Overrides which `inca-host` binary gets spawned, in place of automatic resolution. */
6
+ hostBin?: string;
7
+ /**
8
+ * Every diagnostic line the transport itself produces: the host's real
9
+ * stderr, a stray stdout line, and a `ready` protocol mismatch. Defaults
10
+ * to this process's own stderr.
11
+ */
12
+ onStderr?: (line: string) => void;
13
+ /**
14
+ * The window is up and the first bundle has been evaluated, and the host
15
+ * speaks the protocol revision this package was built for.
16
+ */
17
+ onReady?: () => void;
18
+ /** An app's own event listener threw; the host caught it and kept rendering. */
19
+ onAppError?: (error: AppErrorParams) => void;
20
+ /**
21
+ * Handlers for notification `method`s this package doesn't implement
22
+ * itself (e.g. a future Vite integration), keyed by method name —
23
+ * `params` forwarded untouched.
24
+ */
25
+ integrations?: Record<string, (params: unknown) => void>;
26
+ }
27
+ /**
28
+ * Spawns `inca-host --dev <entryFile>` and speaks newline-delimited
29
+ * JSON-RPC 2.0 on its stdin/stdout. One instance owns exactly one child
30
+ * process for its whole lifetime — a reload is a `reload` call on the same
31
+ * child, never a respawn.
32
+ */
33
+ export declare class HostClient {
34
+ #private;
35
+ constructor(options: HostClientOptions);
36
+ /**
37
+ * Starts the child and wires up its streams. Resolves once the process
38
+ * has actually spawned; rejects if it never does (e.g. the resolved
39
+ * binary doesn't exist).
40
+ */
41
+ start(): Promise<void>;
42
+ /** Sends a request and resolves with its result once the host answers. */
43
+ call(method: string, params?: unknown): Promise<unknown>;
44
+ /**
45
+ * Asks the host to `shutdown` and waits for the child to actually exit —
46
+ * that exit is the real acknowledgement, not the response. Kills it once
47
+ * `timeoutMs` passes without that, so a wedged app can't block teardown.
48
+ */
49
+ stop(timeoutMs?: number): Promise<void>;
50
+ }
@@ -0,0 +1,6 @@
1
+ /** A fault the host answered a request with, carrying its JSON-RPC code. */
2
+ export declare class HostError extends Error {
3
+ readonly code: number;
4
+ readonly hostStack: string | null;
5
+ constructor(message: string, code: number, hostStack?: string | null);
6
+ }
@@ -0,0 +1,4 @@
1
+ export { resolveHostBin } from './hostBin.mts';
2
+ export { HostError } from './hostError.mts';
3
+ export { HostClient } from './hostClient.mts';
4
+ export type { HostClientOptions } from './hostClient.mts';
@@ -0,0 +1,38 @@
1
+ export declare const JSONRPC = "2.0";
2
+ /**
3
+ * The host method-set revision this package expects, checked against
4
+ * `ready`'s `params.protocol` — a mismatch means an incompatible host
5
+ * build.
6
+ */
7
+ export declare const HOST_PROTOCOL_VERSION = 0;
8
+ /** `ready`'s notification params. */
9
+ export interface ReadyParams {
10
+ protocol: number;
11
+ }
12
+ /** `appError`'s notification params. */
13
+ export interface AppErrorParams {
14
+ message: string;
15
+ stack: string | null;
16
+ }
17
+ export interface RpcResult {
18
+ jsonrpc: typeof JSONRPC;
19
+ id: number;
20
+ result: unknown;
21
+ }
22
+ export interface RpcFailure {
23
+ jsonrpc: typeof JSONRPC;
24
+ id: number;
25
+ error: {
26
+ code: number;
27
+ message: string;
28
+ data?: {
29
+ stack: string | null;
30
+ };
31
+ };
32
+ }
33
+ export interface RpcNotification {
34
+ jsonrpc: typeof JSONRPC;
35
+ method: string;
36
+ params: unknown;
37
+ }
38
+ export declare function isRpcMessage(value: unknown): value is RpcResult | RpcFailure | RpcNotification;
package/dist/dev.d.mts ADDED
@@ -0,0 +1,25 @@
1
+ import { Bundler } from './adapter/types.mts';
2
+ export interface DevOptions {
3
+ /** The app's root directory. Defaults to `process.cwd()`. */
4
+ cwd?: string;
5
+ /**
6
+ * The app's entry point. Defaults to resolving it automatically: a
7
+ * committed `src/main.mts`, or `src/App.vue` wrapped in a synthesized one.
8
+ */
9
+ entry?: string;
10
+ /** Overrides the bundler — see {@link defaultBundler} for what's wired in by default. */
11
+ bundler?: Bundler;
12
+ /** Overrides host binary resolution — passed straight through to `HostClient`. */
13
+ hostBin?: string;
14
+ /** Defaults to `process.stdout`. */
15
+ stdout?: NodeJS.WritableStream;
16
+ /** Defaults to `process.stderr`. */
17
+ stderr?: NodeJS.WritableStream;
18
+ /** Aborting tears the host and the bundler watcher down and resolves `dev()`. */
19
+ signal: AbortSignal;
20
+ }
21
+ /**
22
+ * Builds the app, starts `inca-host` once the first build lands, and
23
+ * reloads it on every rebuild — until `options.signal` aborts.
24
+ */
25
+ export declare function dev(options: DevOptions): Promise<void>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Resolves an app's entry point. `src/main.mts`, committed by the app,
3
+ * wins outright and is used verbatim — full control over bootstrapping.
4
+ * Otherwise `src/App.vue` is wrapped in a synthesized entry equivalent to
5
+ * `createIncaApp(App).mount()`, so a plain `.vue` file is a whole app
6
+ * with no configuration at all.
7
+ */
8
+ export declare function resolveEntry(cwd: string): Promise<string>;
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,2 @@
1
+ export type { BuildOptions, BuildOutput, Bundler, BundlerOptions, Watcher, } from './adapter/types.mts';
2
+ export type { ResolvedAppConfig } from './config/loader.mts';
package/dist/index.js ADDED
File without changes
@@ -0,0 +1,45 @@
1
+ import { Bundler } from './adapter/types.mts';
2
+ /** A platform `inca package` can emit a distributable application for. */
3
+ export type PackageTarget = "macos" | "linux";
4
+ /** Options for {@link packageApp}. */
5
+ export interface PackageAppOptions {
6
+ /** The app's root directory. Defaults to `process.cwd()`. */
7
+ cwd?: string;
8
+ /**
9
+ * The app's entry point. Defaults to resolving it the same way `inca
10
+ * dev`/`build` do: a committed `src/main.mts`, or `src/App.vue` wrapped
11
+ * in a synthesized one.
12
+ */
13
+ entry?: string;
14
+ /** Overrides the bundler — see {@link build}'s default. */
15
+ bundler?: Bundler;
16
+ /**
17
+ * Overrides which `inca-host` binary gets embedded in the packaged
18
+ * app, in place of automatic resolution (`INCA_HOST_BIN`, then the
19
+ * per-platform `@incajs/host-*` package — see {@link resolveHostBin}).
20
+ */
21
+ hostBin?: string;
22
+ /**
23
+ * The platform to package for. Defaults to whichever one the current
24
+ * process is running on.
25
+ */
26
+ target?: PackageTarget;
27
+ /** Where progress notes go. Defaults to `process.stdout`. */
28
+ stdout?: NodeJS.WritableStream;
29
+ }
30
+ /** The result of a successful {@link packageApp} call. */
31
+ export interface PackageResult {
32
+ /** The packaged app's path — a `.app` directory on macOS, a plain directory on Linux. */
33
+ appPath: string;
34
+ }
35
+ /**
36
+ * Builds the app and pairs it with the prebuilt `inca-host` into a
37
+ * distributable, platform-native application — a `.app` on macOS, a plain
38
+ * directory on Linux — written alongside the build output, under the
39
+ * app's own `dist/`. The app launches with no arguments and no terminal,
40
+ * since `inca-host` finds its own bundle beside its executable.
41
+ *
42
+ * @throws if the app's metadata can't be read, the build fails, or no
43
+ * `inca-host` binary can be resolved for the target platform.
44
+ */
45
+ export declare function packageApp(options?: PackageAppOptions): Promise<PackageResult>;
@@ -0,0 +1,4 @@
1
+ /** A macOS `Info.plist`'s value types — the only ones `inca package` writes. */
2
+ export type PlistValue = string | boolean;
3
+ /** Encodes a flat key/value dict as an `Info.plist` XML document. */
4
+ export declare function encodePlist(dict: Record<string, PlistValue>): string;
package/package.json CHANGED
@@ -1,24 +1,85 @@
1
1
  {
2
2
  "name": "@incajs/cli",
3
- "version": "0.0.0",
4
- "description": "Incarnative.js — the `inca` CLI (dev/build/package). Name reservation; the real implementation is still in development.",
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.",
5
5
  "keywords": [
6
6
  "bundler",
7
7
  "cli",
8
8
  "desktop-app",
9
+ "dev-server",
9
10
  "gpui",
10
11
  "gui",
11
12
  "incajs",
12
13
  "incarnative.js",
13
- "quickjs"
14
+ "json-rpc",
15
+ "quickjs",
16
+ "vite"
14
17
  ],
18
+ "homepage": "https://tom96da.github.io/incajs/",
15
19
  "license": "(MIT OR Apache-2.0)",
16
20
  "repository": {
17
21
  "type": "git",
18
22
  "url": "git+https://github.com/tom96da/incajs.git",
19
23
  "directory": "packages/cli"
20
24
  },
25
+ "bin": {
26
+ "inca": "./bin/inca.mjs"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "bin"
31
+ ],
32
+ "type": "module",
33
+ "sideEffects": false,
34
+ "main": "./dist/index.js",
35
+ "types": "./dist/index.d.mts",
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.mts",
39
+ "import": "./dist/index.js"
40
+ },
41
+ "./config": {
42
+ "types": "./dist/config/index.d.mts",
43
+ "import": "./dist/config.js"
44
+ }
45
+ },
21
46
  "publishConfig": {
22
47
  "access": "public"
48
+ },
49
+ "dependencies": {
50
+ "@vitejs/plugin-vue": "^6.0.9",
51
+ "vite": "^8.3.0"
52
+ },
53
+ "devDependencies": {
54
+ "@types/node": "^26.6.2",
55
+ "@vue/runtime-core": "^3.5.43",
56
+ "c12": "4.0.0-rc.1",
57
+ "oxfmt": "^0.68.0",
58
+ "oxlint": "^1.83.0",
59
+ "rolldown": "~1.2.9",
60
+ "vue": "^3.5.43"
61
+ },
62
+ "peerDependencies": {
63
+ "vue": "^3.5.43"
64
+ },
65
+ "peerDependenciesMeta": {
66
+ "vue": {
67
+ "optional": true
68
+ }
69
+ },
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"
74
+ },
75
+ "engines": {
76
+ "node": ">=22.18"
77
+ },
78
+ "scripts": {
79
+ "build": "vite build",
80
+ "test": "vitest run",
81
+ "lint": "oxlint --type-aware",
82
+ "format": "oxfmt --check .",
83
+ "typecheck": "oxlint -A all --type-aware --type-check"
23
84
  }
24
85
  }