@twobirds/microcomponents 0.11.0 → 0.13.0

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 (40) hide show
  1. package/README.md +14 -4
  2. package/dist/cli/bundle.d.ts +23 -13
  3. package/dist/cli/bundle.d.ts.map +1 -1
  4. package/dist/cli/create.d.ts +28 -8
  5. package/dist/cli/create.d.ts.map +1 -1
  6. package/dist/cli/dev.d.ts +13 -8
  7. package/dist/cli/dev.d.ts.map +1 -1
  8. package/dist/cli/dispatch.d.ts +10 -2
  9. package/dist/cli/dispatch.d.ts.map +1 -1
  10. package/dist/cli/index.js +244 -72
  11. package/dist/cli/preview.d.ts +3 -1
  12. package/dist/cli/preview.d.ts.map +1 -1
  13. package/dist/cli/writeScaffold.d.ts +3 -3
  14. package/dist/docs/api-external.d.ts +11 -2
  15. package/dist/docs/api-external.d.ts.map +1 -1
  16. package/dist/docs/cli.d.ts +1 -1
  17. package/dist/docs/installation.d.ts +8 -3
  18. package/dist/docs/installation.d.ts.map +1 -1
  19. package/dist/helpers.min.js +1 -0
  20. package/dist/mcp/api.json +28 -2
  21. package/dist/mcp/concepts/event-system.md +20 -0
  22. package/dist/mcp/concepts/mc-types.md +15 -8
  23. package/dist/mcp/concepts/no-importmap.md +48 -0
  24. package/dist/mcp/concepts/project-layout.md +9 -5
  25. package/dist/mcp/concepts/state-management.md +13 -7
  26. package/dist/microcomponents.d.ts +1 -0
  27. package/dist/microcomponents.d.ts.map +1 -1
  28. package/dist/microcomponents.js +1 -1
  29. package/dist/microcomponents.min.js +1 -1
  30. package/dist/placeholders.min.js +1 -0
  31. package/dist/state/index.d.ts +2 -0
  32. package/dist/state/index.d.ts.map +1 -1
  33. package/dist/state/placeholders.js +1980 -0
  34. package/dist/utils/autoload.js +1451 -0
  35. package/dist/utils/events.d.ts +1 -1
  36. package/dist/utils/events.d.ts.map +1 -1
  37. package/dist/utils/helpers.js +693 -0
  38. package/dist/utils/index.d.ts +1 -1
  39. package/dist/utils/index.d.ts.map +1 -1
  40. package/package.json +21 -5
package/README.md CHANGED
@@ -100,20 +100,25 @@ pnpm run cli -- new my-card --target-html --target-css --dry-run
100
100
  ```bash
101
101
  pnpm run cli -- create --namespace mc --dir mc-app
102
102
  # created mc-app/package.json
103
+ # created mc-app/tsconfig.json
104
+ # created mc-app/tsconfig.test.json
105
+ # created mc-app/vitest.config.ts
103
106
  # created mc-app/opencode.jsonc
107
+ # created mc-app/.opencode/skills/components/SKILL.md
104
108
  # created mc-app/src/index.html
105
109
  # created mc-app/src/index-dev.html
106
110
  # created mc-app/src/mc/app.ts
107
- # created mc-app/src/mc/app.target.html
111
+ # created mc-app/src/mc/app.html
108
112
  # created mc-app/src/mc/app.target.css
109
113
  # created mc-app/src/mc/bundle.ts
114
+ # created mc-app/test/mc/app.spec.ts
110
115
  # ...
111
116
  # project "mc" created in mc-app/ — run: cd mc-app && pnpm install && pnpm dev
112
117
  ```
113
118
 
114
- `pnpm dev` runs `mc dev`: `tsc -w` plus a `node:http` server serving `build/`, so a saved component reaches the browser through `autoload()` with nothing bundled; companion assets are mirrored into `build/` next to the compiled component, and the library is resolved through an import map to the served `microcomponents.min.js`. `pnpm build` runs `tsc` then `mc bundle`, which emits one `bundle.js` into `public/` with every companion asset inlined by the CLI bundler, the concatenated `bundle.css`, and the production shell — a single script tag, no autoloader. `pnpm preview` serves `public/`. `opencode.jsonc` registers the MCP server, so opencode picks it up when you open the project.
119
+ `pnpm dev` runs `mc dev`: `tsc -w` plus a `node:http` server serving `build/`, so a saved component reaches the browser through `autoload()` with nothing bundled; companion assets and plain `.js` components are mirrored into `build/` next to the compiled component, and the server rewrites the `@twobirds/microcomponents` specifier in the JS it serves to the `/microcomponents.min.js` it answers, so the page carries no import map. `pnpm build` runs `tsc` then `mc bundle`, which emits one `bundle.js` into `public/` with every companion asset inlined by the CLI bundler, the concatenated `bundle.css`, and the production shell — a single script tag, no autoloader. `pnpm preview` serves `public/`. `pnpm typecheck` checks `src/` and `test/` in two contexts, and `pnpm test` runs the specs under vitest in jsdom, so component class code executes against a real DOM. `opencode.jsonc` registers the MCP server, so opencode picks it up when you open the project.
115
120
 
116
- The namespace (1 to 4 lowercase letters) becomes the `src/<namespace>/` folder and the first segment of every component tag, so `mc` is the home of tags like `<mc-app>`. Because the dev shell is the autoload base, `import.meta.url` + the tag-to-path rule resolves `<mc-app>` to `build/mc/app.js` — the compiled starter. New components are served automatically by the autoloader, but the bundle walks one entry, so add each one to `src/<namespace>/bundle.ts`. `--dir` defaults to the namespace, `--dry-run` prints the plan without touching disk.
121
+ The namespace (lowercase letters and digits, starting with a letter, any length) becomes the `src/<namespace>/` folder and the first segment of every component tag, so `mc` is the home of tags like `<mc-app>`. The project owns its namespace, so length is allowed; past 5 characters `mc create` warns and asks for confirmation, and `--yes` skips the prompt for scripted runs. Because the dev shell is the autoload base, `import.meta.url` + the tag-to-path rule resolves `<mc-app>` to `build/mc/app.js` — the compiled starter. New components are served automatically by the autoloader, but the bundle walks one entry, so add each one to `src/<namespace>/bundle.ts`. `--dir` defaults to the namespace, `--dry-run` prints the plan without touching disk.
117
122
 
118
123
  The project is written into a folder of its own, so its files are reported under that folder (`mc-app/src/mc/app.ts`) — the path you can find from the directory you ran the command in, not relative to the project root.
119
124
 
@@ -121,7 +126,7 @@ Existing files are never overwritten silently: every target is checked before th
121
126
 
122
127
  ```bash
123
128
  pnpm run cli -- create --namespace mc
124
- # refusing to overwrite 10 existing file(s):
129
+ # refusing to overwrite 16 existing file(s):
125
130
  # mc/package.json
126
131
  # mc/src/mc/app.ts
127
132
  # ...
@@ -134,11 +139,16 @@ Once installed from npm the same command is available as `mc` (and as `microcomp
134
139
  ```bash
135
140
  mc new my-card [--css] [--html] [--target-html] [--shadow-html] [--target-css] [--shadow-css] [--js] [--dir <path>] [--force] [--dry-run]
136
141
  mc create --namespace <ns> [--dir <path>] [--force] [--dry-run]
142
+ mc dev [--port <n>] [--host <addr>]
143
+ mc bundle
144
+ mc preview [--port <n>] [--host <addr>]
137
145
  mc clean
138
146
  mc check
139
147
  mc --version
140
148
  ```
141
149
 
150
+ `dev` serves `build/` with `tsc -w` running, and `preview` serves `public/`. Both bind to `127.0.0.1` by default, so the served files are not reachable off the machine; pass `--host 0.0.0.0` (or an interface address) when you want the LAN to reach them.
151
+
142
152
  `clean` and `check` are thin wrappers around the package.json scripts of the same name, so the scripts remain the single source of truth for what they do — `mc check` type-checks every project context (lib, cli, mcp, test, demo, node) and exits with the script's exit code. `mc --version` (`-v`) prints the version of the package the CLI ships in, read from its own package.json, so it reports the installed library, not the version of the project the command runs in.
143
153
 
144
154
  Nothing has to be installed to run it once — `npx` fetches the package into its own cache and runs the bin from there:
@@ -4,8 +4,9 @@
4
4
 
5
5
  The chain is `src/` → `build/` → `public/`. The scaffolded `build` script runs
6
6
  `tsc -p tsconfig.json` (so `build/` holds one `.js` per component at its
7
- autoload path), then `mc bundle` mirrors the companion assets into `build/`,
8
- walks the barrel entry named by `src/bundle.json` through {@link bundleEntry}
7
+ autoload path), then `mc bundle` mirrors the files `tsc` does not compile —
8
+ companion assets and plain `.js` components — into `build/`, walks the barrel
9
+ entry named by `src/bundle.json` through {@link bundleEntry}
9
10
  (inlining every `static assets`), rewrites the `@twobirds/microcomponents`
10
11
  specifier to the self-contained `microcomponents.min.js` shipped next to the
11
12
  bundle, concatenates the plain `.css` token presets into `bundle.css`, and
@@ -28,29 +29,35 @@ export interface BundleConfig {
28
29
  outDir?: string;
29
30
  }
30
31
  /**
31
- * Whether a file is a companion asset to mirror into `build/`.
32
+ * Whether a file in `src/` is copied verbatim into `build/`. Companion assets
33
+ * (`.css`, `.html`, `.json`) sit next to their compiled `.js`, and a plain `.js`
34
+ * component (`mc new --js`) is copied as it is: `tsc` compiles only `.ts`, so plain
35
+ * JS reaches the autoloader by copying, not by compiling. The page shells are not
36
+ * mirrored by this rule — `mc dev` copies the dev shell itself.
32
37
  *
33
38
  * @example
34
39
  * ```ts
35
- * isCompanion('app.target.html'); // true
36
- * isCompanion('index.html'); // false
40
+ * isMirrored('app.target.html'); // true
41
+ * isMirrored('app.js'); // true — a plain JS component
42
+ * isMirrored('index.html'); // false
37
43
  * ```
38
44
  * @param name Basename of the file.
39
45
  */
40
- export declare function isCompanion(name: string): boolean;
46
+ export declare function isMirrored(name: string): boolean;
41
47
  /**
42
- * Mirror companion assets (`.css`, `.html`, `.json`) from `src/` into `build/`,
43
- * preserving the tree, so the bundler reads each asset next to its compiled `.js`.
48
+ * Mirror the files `tsc` does not compile (`.css`, `.html`, `.json`, `.js`) from
49
+ * `src/` into `build/`, preserving the tree, so the bundler reads each asset and
50
+ * each plain JS component next to its compiled `.js`.
44
51
  *
45
52
  * @example
46
53
  * ```ts
47
- * await mirrorCompanions('<root>/src', '<root>/build');
54
+ * await mirrorSources('<root>/src', '<root>/build');
48
55
  * ```
49
56
  * @param srcDir Source root to walk.
50
57
  * @param buildDir Folder to write into.
51
58
  * @param rel Path of the walked directory relative to `srcDir`.
52
59
  */
53
- export declare function mirrorCompanions(srcDir: string, buildDir: string, rel?: string): Promise<void>;
60
+ export declare function mirrorSources(srcDir: string, buildDir: string, rel?: string): Promise<void>;
54
61
  /**
55
62
  * Collect the plain `.css` token presets under `src/`, skipping the companion
56
63
  * `.target.css` / `.shadow.css` files, which the bundler inlines into the JS.
@@ -67,14 +74,17 @@ export declare function collectPlainCss(srcDir: string, rel?: string, found?: st
67
74
  /**
68
75
  * Rewrite the library specifier in a bundled module to the self-contained bundle
69
76
  * shipped next to it, so the browser can resolve `@twobirds/microcomponents`
70
- * without a bare-specifier import map.
77
+ * without a bare-specifier import map. Subpath imports resolve to the same module,
78
+ * so the library stays one instance. This is the single source of truth for the
79
+ * rule: the bundler uses the relative target, the dev server passes its served URL.
71
80
  *
72
- * @example Turns the package specifier into a relative path.
81
+ * @example Turns the package specifier into a relative path, leaves others alone.
73
82
  * ```ts
74
83
  * rewriteLibrarySpecifier("import { DC } from '@twobirds/microcomponents';");
84
+ * rewriteLibrarySpecifier("import { z } from 'zod';"); // unchanged
75
85
  * ```
76
86
  * @param code Bundled module source.
77
- * @param target Relative specifier to point the import at.
87
+ * @param target Specifier to point the import at.
78
88
  */
79
89
  export declare function rewriteLibrarySpecifier(code: string, target?: string): string;
80
90
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/cli/bundle.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;GAeG;AAMH;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAKD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAYhG;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CACpC,MAAM,EAAE,MAAM,EACd,GAAG,SAAK,EACR,KAAK,GAAE,MAAM,EAAO,GAClB,OAAO,CAAC,MAAM,EAAE,CAAC,CAUnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAA6B,GAAG,MAAM,CAEjG;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAClC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/D,OAAO,CAAC,MAAM,EAAE,CAAC,CAkCnB;AAED;;;;;;;GAOG;AACH,w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E,GAC5E,OAAO,CAAC,MAAM,CAAC,CAIjB"}
@@ -8,8 +8,10 @@ runtime autoload loader uses, so the scaffold and the runtime can never disagree
8
8
  where a component lives.
9
9
 
10
10
  The namespace is the first segment of every component tag, so `xxx` makes `src/xxx/`
11
- the home of tags like `<xxx-app>` (tagPath `xxx-app` → `xxx/app`). The generated
12
- environment follows the three-path chain the library's own demos use: `src/` holds the
11
+ the home of tags like `<xxx-app>` (tagPath `xxx-app` → `xxx/app`). The project owns its
12
+ namespace, so it can be any length: `isLongNamespace` flags the ones past
13
+ `LONG_NAMESPACE` (5) for the CLI to warn about and confirm before anything is written.
14
+ The generated environment follows the three-path chain the library's own demos use: `src/` holds the
13
15
  authored sources, `build/` receives the per-file `tsc` output that the dev server
14
16
  serves through `autoload()`, and `public/` receives the bundled production site. Because
15
17
  the dev shell is the autoload base, `import.meta.url` + `tagPath('xxx-app')` resolves to
@@ -18,17 +20,35 @@ the dev shell is the autoload base, `import.meta.url` + `tagPath('xxx-app')` res
18
20
  @module CLI/Project
19
21
  */
20
22
  /**
21
- Whether a string is a valid project namespace: 1 to 4 lowercase letters.
23
+ Whether a string is a valid project namespace: lowercase letters and digits, starting
24
+ with a letter, any length. The project owns its namespace, so length is the user's
25
+ call — {@link isLongNamespace} flags the ones worth confirming before writing.
22
26
 
23
27
  @example
24
28
  ```ts
25
29
  console.log(isValidNamespace('mc'));
26
- console.log(isValidNamespace('mcxyz'));
27
- console.log(isValidNamespace('toolong'));
30
+ console.log(isValidNamespace('microcomponents'));
31
+ console.log(isValidNamespace('Shop'));
28
32
  ```
29
33
  @param ns - Candidate namespace.
30
34
  */
31
35
  export declare function isValidNamespace(ns: string): boolean;
36
+ /** A namespace longer than this is confirmed before the project is written. */
37
+ export declare const LONG_NAMESPACE = 5;
38
+ /**
39
+ Whether a namespace is long enough to warn about. The namespace is the project's own
40
+ and the first segment of every component tag, so a long one lands in every tag, every
41
+ folder path, and every bundle import.
42
+
43
+ @example
44
+ ```ts
45
+ console.log(isLongNamespace('mc')); // false
46
+ console.log(isLongNamespace('shop')); // false
47
+ console.log(isLongNamespace('microcomponents')); // true
48
+ ```
49
+ @param ns - Candidate namespace.
50
+ */
51
+ export declare function isLongNamespace(ns: string): boolean;
32
52
  /** Result of {@link scaffoldProject}. */
33
53
  export interface ProjectResult {
34
54
  /** Files to write, keyed by path relative to the project root. */
@@ -45,9 +65,9 @@ const { namespace, files } = scaffoldProject('mc');
45
65
  console.log(namespace);
46
66
  console.log(Object.keys(files));
47
67
  ```
48
- @param namespace - 1 to 4 lowercase letters; becomes the `src/<namespace>/` folder and
49
- the first segment of every component tag.
50
- @throws If `namespace` is not 1 to 4 lowercase letters.
68
+ @param namespace - lowercase letters and digits, starting with a letter, any length;
69
+ becomes the `src/<namespace>/` folder and the first segment of every component tag.
70
+ @throws If `namespace` is not lowercase letters and digits starting with a letter.
51
71
  */
52
72
  export declare function scaffoldProject(namespace: string): ProjectResult;
53
73
  //# sourceMappingURL=create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/cli/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;EAkBE;AAUF;;;;;;;;;;EAUE;AACF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC7B,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;EAYE;AACF,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CA0BhE"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/cli/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;EAoBE;AAUF;;;;;;;;;;;;EAYE;AACF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,+EAA+E;AAC/E,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;;;;;;;;EAYE;AACF,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC7B,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;EAYE;AACF,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CA6BhE"}
package/dist/cli/dev.d.ts CHANGED
@@ -3,12 +3,14 @@
3
3
 
4
4
  A minimal `node:http` static server rooted at the project's `build/` folder, so
5
5
  a saved component reaches the browser through `autoload()` with no bundling. It
6
- mirrors companion assets from `src/` into `build/` (on startup and on every
7
- change), runs `tsc -w` for the lifetime of the server, serves companion
6
+ mirrors the files `tsc` does not compile — companion assets and plain `.js`
7
+ components — from `src/` into `build/` (on startup and on every change), runs
8
+ `tsc -w` for the lifetime of the server, serves companion
8
9
  `.css` / `.html` / `.json` as raw text (so `loadAssets()` receives markup it
9
- can use), redirects `/` to the autoload shell (`index-dev.html`), and serves
10
- the self-contained library at `/microcomponents.min.js` — the target of the
11
- import map in the dev shell.
10
+ can use), redirects `/` to the autoload shell (`index-dev.html`), serves the
11
+ self-contained library at `/microcomponents.min.js`, and rewrites the
12
+ `@twobirds/microcomponents` specifier in served JS to that URL, so a compiled
13
+ component resolves the library with no import map in the page.
12
14
 
13
15
  There is no HMR: a page reload picks up the recompiled component.
14
16
 
@@ -45,8 +47,9 @@ export declare function mimeFor(name: string): string;
45
47
  */
46
48
  export declare function resolveTarget(url: string, buildRoot: string, minJs: string): string | undefined;
47
49
  /**
48
- * Mirror companion assets from `src/` into `build/`, preserving the tree, so the
49
- * served folder stays autoload-ready.
50
+ * Mirror the files `tsc` does not compile — companion assets and plain `.js`
51
+ * components — from `src/` into `build/`, preserving the tree, so the served
52
+ * folder stays autoload-ready.
50
53
  *
51
54
  * @example
52
55
  * ```ts
@@ -81,7 +84,9 @@ export declare function createDevServer(projectRoot: string, options: {
81
84
  * @param projectRoot Project root (defaults to the current directory).
82
85
  * @param minJs Path of `microcomponents.min.js` (defaults to this package's `dist/`).
83
86
  * @param port Dev-server port.
87
+ * @param host Bind address. Defaults to loopback, so a dev server serving source files is
88
+ * not reachable off the machine. Pass an interface address to serve the LAN.
84
89
  * @returns The process exit code (the server keeps running until killed).
85
90
  */
86
- export declare function runDev(projectRoot?: string, minJs?: string, port?: number): Promise<number>;
91
+ export declare function runDev(projectRoot?: string, minJs?: string, port?: number, host?: string): Promise<number>;
87
92
  //# sourceMappingURL=dev.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAsC,KAAK,MAAM,EAAuB,MAAM,WAAW,CAAC;AASjG;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO5C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAO/F;AA8BD;;;;;;;;;;;GAWG;AACH,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAW/F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC9B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACtC,MAAM,CAKR;AAED;;;;;;;;GAQG;AAEH,wBAAsB,MAAM,CAC3B,WAAW,GAAE,MAAsB,EACnC,KAAK,GAAE,MAAuE,EAC9E,IAAI,GAAE,MAAa,GACjB,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAsC,KAAK,MAAM,EAAuB,MAAM,WAAW,CAAC;AASjG;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO5C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAO/F;AAkCD;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAW/F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC9B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACtC,MAAM,CAKR;AAED;;;;;;;;;;GAUG;AAEH,wBAAsB,MAAM,CAC3B,WAAW,GAAE,MAAsB,EACnC,KAAK,GAAE,MAAuE,EAC9E,IAAI,GAAE,MAAa,EACnB,IAAI,GAAE,MAAoB,GACxB,OAAO,CAAC,MAAM,CAAC,CAiCjB"}
@@ -13,7 +13,10 @@ so the command works in any consumer project.
13
13
  */
14
14
  export type Runner = (script: string, options?: {
15
15
  port?: number;
16
+ host?: string;
16
17
  }) => Promise<number>;
18
+ /** Asks the user to confirm a namespace long enough to be worth a second look. */
19
+ export type Confirmer = (namespace: string) => Promise<boolean>;
17
20
  /**
18
21
  Runs a package.json script through pnpm and resolves with its exit code.
19
22
 
@@ -29,11 +32,13 @@ const code = await runScript('check');
29
32
  */
30
33
  export declare function runScript(script: string, options?: {
31
34
  port?: number;
35
+ host?: string;
32
36
  }): Promise<number>;
33
37
  /**
34
38
  Parses `argv` and routes it to the matching command, returning a process exit
35
39
  code. `run` is injectable so the script-wrapping commands can be tested without
36
- spawning anything.
40
+ spawning anything, and `confirm` is injectable so the long-namespace prompt can be
41
+ tested without a terminal.
37
42
 
38
43
  @example
39
44
  ```ts
@@ -46,6 +51,9 @@ const code = await main(['clean'], async (script) => {
46
51
  ```ts
47
52
  const code = await main(['--version']);
48
53
  ```
54
+ @param argv - Arguments to route (usually `process.argv.slice(2)`).
55
+ @param run - Runs a package.json script (defaults to {@link runScript}).
56
+ @param confirm - Confirms a long namespace (defaults to the terminal prompt).
49
57
  */
50
- export declare function main(argv: string[], run?: Runner): Promise<number>;
58
+ export declare function main(argv: string[], run?: Runner, confirm?: Confirmer): Promise<number>;
51
59
  //# sourceMappingURL=dispatch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/cli/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAoEF,MAAM,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAwHtF;;;;;;;;;;;;EAYE;AACF,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAW5F;AAED;;;;;;;;;;;;;;;;EAgBE;AACF,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,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