@incajs/cli 0.0.5 → 0.0.7

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 CHANGED
@@ -23,7 +23,10 @@ bootstrapping; it wins outright when both exist.
23
23
  ## Commands
24
24
 
25
25
  - **`inca dev`** — watches your app and opens a live-reloading window,
26
- reloading on every change.
26
+ reloading on every change. `--experimental-hmr` (or
27
+ `INCA_EXPERIMENTAL_HMR=1`) opts into experimental, module-granular
28
+ hot reloading instead — see the
29
+ [HMR guide](https://tom96da.github.io/incajs/guide/hmr).
27
30
  - **`inca build`** — bundles your app for production, once, with no
28
31
  window opened.
29
32
  - **`inca package`** — builds your app, then packages it with a
@@ -52,6 +52,59 @@ export interface BuildOutput {
52
52
  at: number;
53
53
  };
54
54
  }
55
+ /**
56
+ * A failed HMR update's detail — the same fields a Rollup/Vite plugin
57
+ * error carries beyond `message`/`stack`, when it has them.
58
+ */
59
+ export interface UpdateError {
60
+ message: string;
61
+ stack?: string | null;
62
+ plugin?: string | null;
63
+ id?: string | null;
64
+ frame?: string | null;
65
+ loc?: {
66
+ line: number;
67
+ column: number;
68
+ } | null;
69
+ }
70
+ /** Options for {@link Bundler.hmr}. */
71
+ export interface HmrOptions {
72
+ /** The app's own entry point — may import `.vue` files. */
73
+ entry: string;
74
+ /** The app's root directory — where its dev-only scratch files are written. */
75
+ cwd: string;
76
+ /**
77
+ * Values the built app carries for `inca-host` to read — its name, id
78
+ * and window. Any JSON-serializable object.
79
+ */
80
+ runtimeConfig?: unknown;
81
+ /** Overrides where the synthesized entry imports `hmr-runtime.js` from. Test-only. */
82
+ runtimePath?: string;
83
+ /** Where the bundler's own output goes. Defaults to `process.stdout`. */
84
+ stdout?: NodeJS.WritableStream;
85
+ /** Where the bundler's warnings and errors go. Defaults to `process.stderr`. */
86
+ stderr?: NodeJS.WritableStream;
87
+ /** Drops per-update/reload logging; warnings and errors still surface. */
88
+ quiet?: boolean;
89
+ /** Delivers a bundler payload to the running app over the dev channel. */
90
+ notify: (payload: unknown) => void;
91
+ /** Called in place of forwarding a whole-app reload payload to the app. */
92
+ reload: () => void;
93
+ /** Called when an update the app fetched failed to compile. */
94
+ onError: (error: UpdateError) => void;
95
+ /** Called after a successful update, with the file that changed and how long it took. */
96
+ onUpdate?: (info: {
97
+ file: string;
98
+ took: number;
99
+ }) => void;
100
+ }
101
+ /** A running HMR session — the value {@link Bundler.hmr} resolves to. */
102
+ export interface HmrChannel extends Watcher {
103
+ /** The synthesized entry `inca-host` evaluates for this session. */
104
+ entryFile: string;
105
+ /** Feeds a payload the running app sent back into the bundler's dev server. */
106
+ dispatch: (payload: unknown) => void;
107
+ }
55
108
  /**
56
109
  * The contract a bundler adapter satisfies. Supporting another bundler
57
110
  * means adding a sibling adapter module and injecting its `Bundler` here —
@@ -61,4 +114,9 @@ export interface Bundler {
61
114
  watch(options: BundlerOptions): Promise<Watcher>;
62
115
  /** One-shot production build, used by `inca build` — rejects on failure. */
63
116
  build(options: BuildOptions): Promise<BuildOutput>;
117
+ /**
118
+ * Module-granular dev updates, used by `inca dev --experimental-hmr`.
119
+ * Optional — a bundler adapter with no HMR support simply omits it.
120
+ */
121
+ hmr?(options: HmrOptions): Promise<HmrChannel>;
64
122
  }
@@ -1,6 +1,12 @@
1
1
  import { Plugin } from 'vite';
2
2
  /** The file a build writes its app's config to, beside the entry. */
3
3
  export declare const CONFIG_FILE_NAME = "inca.json";
4
+ /**
5
+ * Serializes `config` the way `inca.json` is written: `undefined` for
6
+ * anything that shouldn't produce a file — `undefined` itself, or an
7
+ * object with no keys.
8
+ */
9
+ export declare function serializeConfig(config: unknown): string | undefined;
4
10
  /**
5
11
  * Writes `config` to `inca.json` beside the entry, for `inca-host` to read
6
12
  * when it starts the app.
@@ -0,0 +1,7 @@
1
+ import { HmrChannel, HmrOptions } from '../types.mts';
2
+ /**
3
+ * Starts a Vite dev server driving the app over its dev channel instead of
4
+ * a browser: a `"client"` environment with a custom {@link HotChannel}
5
+ * standing in for the WebSocket server `server.ws: false` disables.
6
+ */
7
+ export declare function hmr({ entry, cwd, runtimeConfig, runtimePath, stdout, stderr, quiet, notify, reload, onError, onUpdate, }: HmrOptions): Promise<HmrChannel>;
@@ -1,2 +1,3 @@
1
1
  export { build } from './build.mts';
2
+ export { hmr } from './hmr.mts';
2
3
  export { watch } from './watch.mts';
@@ -1,7 +1,8 @@
1
1
  import { Logger } from 'vite';
2
2
  /**
3
3
  * A Vite {@link Logger} writing to the given streams: `info` to `stdout`,
4
- * `warn` and `error` to `stderr`. Messages arrive fully formatted and are
5
- * written as they are; Vite's own `LogOptions` are ignored.
4
+ * `warn`/`error` to `stderr`, all unfiltered by Vite's own `LogOptions` — a
5
+ * custom logger bypasses those. `quiet` drops `info` only; `warn`/`error`
6
+ * still write, since they report something broken, not just what changed.
6
7
  */
7
- export declare function streamLogger(stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream): Logger;
8
+ export declare function streamLogger(stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream, quiet?: boolean): Logger;