zazz-ui 0.0.0 → 0.3.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ Notable changes to the `zazz-ui` CLI. The CLI versions independently of `@zazz-ui/core` (ADR-0010); the kit's own changelog is the one `update` and `diff` print.
4
+
5
+ ## 0.3.0 (2026-10-07)
6
+
7
+ First public release. npm had only a `0.0.0` placeholder before it.
8
+
9
+ - Works with `@zazz-ui/core` 0.1 through 0.5 (manifest v1–v2). A kit outside that range fails with a message that says whether it is too old or too new.
10
+ - `init`, `add`, `update`, and `diff` vendor the kit into your project and record a hash of every file, so `update` merges your edits instead of overwriting them.
11
+ - `--legacy <path>` wires an existing stylesheet into `layer(legacy.imports)`.
12
+ - `update` from a 0.4.x kit to 0.5 removes the old class and layout base files (`_utilities.css`, `_layout.css`) and vendors the generated utilities layer.
13
+ - With a kit that exports its runtime list (0.5 and later), the vendored core runtime includes `base/navigation.js`, which stays inert until a page sets `<html data-ui-navigation="swap">`, and the scroll-state polyfill, which `index.js` loads only where `CSS.supports("container-type", "scroll-state")` is false. Without the polyfill, `--*--stuck` utilities only work in Chromium.
14
+ - `zazz.json` no longer carries a `$schema` key. No schema is published, and the CLI drops an existing key the next time it writes the file.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Derek Nelsen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # zazz-ui
2
2
 
3
- CLI for the [Zazz Design Framework](https://github.com/dereknelsen/zazz-ui).
3
+ The CLI for the [Zazz Design Framework](https://zazz.sh). It copies primitives from [`@zazz-ui/core`](https://www.npmjs.com/package/@zazz-ui/core) into your project so you own the code, and it records where every file came from so future updates can merge instead of overwrite.
4
4
 
5
- **Under development.** This is a placeholder release reserving the package name. The CLI (`init` / `add` / `update` for vendoring Zazz primitives into your project) is being specified and built — follow progress at [github.com/dereknelsen/zazz-ui](https://github.com/dereknelsen/zazz-ui).
5
+ ```bash
6
+ pnpm dlx zazz-ui init
7
+ pnpm dlx zazz-ui add button combobox
8
+ ```
9
+
10
+ (`npx zazz-ui …` works too.)
11
+
12
+ ## What init does
13
+
14
+ `init` vendors the base platform into `zazz/` (or `--dir <path>`): the css layers (tokens, reset, typography, generated utilities), the core runtime scripts (plus the scroll-state polyfill, which `index.js` loads only in browsers without container scroll-state queries), an `index.css` and `index.js` entry pair, and a `head.html` snippet to paste into your `<head>` (fonts, import map, polyfills, theme persistence). It also writes `zazz.json`, which records the kit version and a hash of every vendored file's original bytes.
15
+
16
+ Flags: `--dir <path>`, `--ts` (vendor TypeScript sources instead of compiled js), `--legacy <path>` (wire an existing stylesheet into the `legacy.imports` cascade sublayer), `--no-fonts`, `--no-theme-script`. Re-running `init` repairs the tree: missing files come back, files you edited are left alone.
17
+
18
+ ## What add does
19
+
20
+ `add <primitive...>` resolves the primitives you ask for plus everything they depend on (adding `combobox` brings `select`, `fields`, `popover`, `button`, `kbd`, and `badge`), copies the files at your project's recorded kit version, and inserts the entry imports at the right cascade position. Your edits to vendored files are never touched. `--examples` also copies the primitive's example markup.
21
+
22
+ ## What update does
23
+
24
+ `update [@version]` moves the whole project to a new kit version (default latest). Because `zazz.json` records the pristine hash of every file at vendor time, update knows exactly which files you've touched: unedited files silently take the new version, files you edited where upstream didn't move stay yours, and non-overlapping changes merge automatically. Only a real conflict asks you anything, with four ways out: write git-style conflict markers to resolve in your editor, keep your version, take theirs, or skip. Skipping rolls back that whole primitive (or the base platform) so a re-run offers the merge again, and the command exits 2 so CI can tell "needs a human" from "broken". Non-interactive runs skip conflicts unless you pass `--keep`, `--theirs`, or `--markers`.
25
+
26
+ Naming primitives narrows the update (`update @0.5.0 button`): only those move, the base platform stays put, and `zazz.json` records the version skew per primitive. New dependencies a primitive gains are vendored automatically, files removed upstream are cleaned up (or kept, if you edited them), and the relevant slice of the kit's changelog prints before anything happens, breaking changes flagged.
27
+
28
+ `diff [@version] [name...]` shows all of it read-only: your files against the target version's exact bytes, plus the changelog slice. `--upstream` compares pristine-to-pristine instead, ignoring your edits.
29
+
30
+ ## Owning the code
31
+
32
+ There is no runtime dependency on `@zazz-ui/core`. The files in `zazz/` are yours: edit them, delete what you don't want, commit them like any other source. `zazz.json` is what makes that safe, and `update` is what makes it cheap.
33
+
34
+ ## Requirements
35
+
36
+ Node 22.22+ (or 24.15+). Works with `@zazz-ui/core` 0.1 through 0.5 (manifest v1–v2); given a newer kit, the CLI tells you to upgrade it. Works offline once a kit version is cached; respects your `.npmrc` (registries, proxies, auth). `--registry`, `--offline`, and `--prefer-offline` are available on every command.
37
+
38
+ ## License
39
+
40
+ MIT. Part of the [zazz-ui](https://github.com/dereknelsen/zazz-ui) monorepo.
@@ -0,0 +1,129 @@
1
+ import { t as ZazzError } from "./errors-DC2U2USS.js";
2
+ import { _ as resolveKit, a as renderIndexJs, c as createUi, d as baseCssSplit, g as kitSpec, h as loadFetchOptions, i as renderIndexCss, l as apply, m as primitiveFiles, n as insertCssImports, o as sha256, p as baseScriptFiles, r as renderHead, s as vendorFiles, t as appendJsImports, u as describe, v as loadConfig, y as filterCollisions } from "./wiring-BBm_hxrx.js";
3
+ import { existsSync } from "node:fs";
4
+ import { readFile } from "node:fs/promises";
5
+ import path from "node:path";
6
+
7
+ //#region src/commands/add.ts
8
+ /**
9
+ * @fileoverview `zazz-ui add` — vendor primitives and their dependencies.
10
+ * @description Resolves the requested primitives' dependency closure through
11
+ * the kit's own manifest at the project's *recorded* kit version (never
12
+ * latest — moving forward is `update`'s job), vendors what isn't already
13
+ * there (css, scripts per language, required base scripts), inserts entry
14
+ * imports at cascade position, regenerates `head.html`, and records
15
+ * per-primitive provenance. No examples unless `--examples`.
16
+ */
17
+ async function runAdd(names, flags, global) {
18
+ const cwd = path.resolve(global.cwd);
19
+ const ui = createUi({
20
+ silent: global.silent === true,
21
+ yes: global.yes === true
22
+ });
23
+ const fetch = await loadFetchOptions({
24
+ cwd,
25
+ registry: global.registry,
26
+ offline: global.offline,
27
+ preferOffline: global.preferOffline
28
+ });
29
+ const loaded = await loadConfig(cwd);
30
+ if (!loaded) throw new ZazzError("no zazz.json found — this project isn't initialized", { hint: "run `zazz-ui init` first" });
31
+ const { config, root } = loaded;
32
+ ui.intro("zazz-ui add");
33
+ const kit = await ui.spinner(`Loading @zazz-ui/core@${config.kit.version}…`, () => resolveKit(kitSpec(config.kit.version), fetch), (resolved) => `Using @zazz-ui/core@${resolved.version}`);
34
+ for (const name of names) if (!kit.manifest.primitives[name]) throw new ZazzError(`unknown primitive "${name}"`, { hint: `the kit at ${kit.version} ships: ${Object.keys(kit.manifest.primitives).sort().join(", ")}` });
35
+ const closure = kit.manifest.resolveClosure(names);
36
+ const fresh = closure.filter((name) => !config.primitives[name]);
37
+ if (fresh.length === 0) {
38
+ ui.outro(`Nothing to do — ${names.join(", ")} (and dependencies) already vendored.`);
39
+ return;
40
+ }
41
+ const ridingAlong = fresh.filter((name) => !names.includes(name));
42
+ ui.step(`Closure at ${kit.version}: ${closure.join(", ")}` + (ridingAlong.length > 0 ? ` (new dependencies: ${ridingAlong.join(", ")})` : ""));
43
+ const destRoot = path.join(root, config.dir);
44
+ const vendorWrites = [];
45
+ for (const name of fresh) {
46
+ const entry = kit.manifest.primitives[name];
47
+ if (!entry) continue;
48
+ const { writes, hashes } = await vendorFiles(kit, primitiveFiles(entry, config.language, { examples: flags.examples === true && names.includes(name) }), destRoot);
49
+ vendorWrites.push(...writes);
50
+ config.primitives[name] = {
51
+ version: kit.version,
52
+ files: hashes
53
+ };
54
+ }
55
+ const base = await vendorFiles(kit, baseScriptFiles(fresh.flatMap((name) => kit.manifest.primitives[name] ?? []), config.language).filter((file) => !(file in config.base.files)), destRoot);
56
+ vendorWrites.push(...base.writes);
57
+ Object.assign(config.base.files, base.hashes);
58
+ const { kept, skipped } = await filterCollisions(vendorWrites, {
59
+ ui,
60
+ force: flags.force === true
61
+ });
62
+ const tx = {
63
+ root,
64
+ writes: [...kept, ...await wiringWrites(kit, config, destRoot, fresh)],
65
+ config
66
+ };
67
+ if (flags.dryRun === true) {
68
+ ui.step(`plan:\n${describe(tx)}`);
69
+ ui.outro("Dry run — nothing written.");
70
+ return;
71
+ }
72
+ await apply(tx);
73
+ if (skipped.length > 0) {
74
+ ui.warn(`Skipped ${skipped.length} existing file(s) (kept yours; --force overwrites):\n ${skipped.map((dest) => path.relative(root, dest)).join("\n ")}`);
75
+ process.exitCode = 2;
76
+ }
77
+ ui.outro(`Vendored ${fresh.join(", ")} into ${config.dir}/ — entry imports inserted in cascade order.`);
78
+ }
79
+ /** Entry insertion + head regeneration; records the new generated hashes. */
80
+ async function wiringWrites(kit, config, destRoot, fresh) {
81
+ const writes = [];
82
+ const cascade = kit.manifest.cssCascadeOrder;
83
+ const cssPath = path.join(destRoot, "index.css");
84
+ const cssAdditions = fresh.map((name) => ({
85
+ name,
86
+ css: kit.manifest.primitives[name]?.css ?? []
87
+ }));
88
+ const currentCss = existsSync(cssPath) ? await readFile(cssPath, "utf8") : renderIndexCss({
89
+ kit,
90
+ legacy: config.legacy,
91
+ primitives: []
92
+ });
93
+ const nextCss = insertCssImports(currentCss, cssAdditions, cascade, baseCssSplit(kit.manifest).post[0]);
94
+ if (!existsSync(cssPath) || nextCss !== currentCss) writes.push({
95
+ dest: cssPath,
96
+ content: nextCss,
97
+ note: "entry"
98
+ });
99
+ config.base.files["index.css"] = sha256(nextCss);
100
+ const entryName = config.language === "ts" ? "index.ts" : "index.js";
101
+ const entryPath = path.join(destRoot, entryName);
102
+ const scripts = [...new Set(fresh.flatMap((name) => {
103
+ const entry = kit.manifest.primitives[name];
104
+ return entry ? [...entry.base, ...entry.js] : [];
105
+ }))];
106
+ const currentEntry = existsSync(entryPath) ? await readFile(entryPath, "utf8") : renderIndexJs({
107
+ kit,
108
+ language: config.language
109
+ });
110
+ const nextEntry = appendJsImports(currentEntry, scripts, config.language);
111
+ if (!existsSync(entryPath) || nextEntry !== currentEntry) writes.push({
112
+ dest: entryPath,
113
+ content: nextEntry,
114
+ note: "entry"
115
+ });
116
+ config.base.files[entryName] = sha256(nextEntry);
117
+ const headPath = path.join(destRoot, "head.html");
118
+ const nextHead = renderHead(kit, config);
119
+ if (nextHead !== (existsSync(headPath) ? await readFile(headPath, "utf8") : null)) writes.push({
120
+ dest: headPath,
121
+ content: nextHead,
122
+ note: "head"
123
+ });
124
+ config.base.files["head.html"] = sha256(nextHead);
125
+ return writes;
126
+ }
127
+
128
+ //#endregion
129
+ export { runAdd };
package/dist/cli.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import { t as ZazzError } from "./errors-DC2U2USS.js";
3
+ import { createRequire } from "node:module";
4
+ import chalk from "chalk";
5
+ import { Command, Option } from "commander";
6
+
7
+ //#region src/cli.ts
8
+ /**
9
+ * @fileoverview `zazz-ui` — vendor Zazz primitives into your project.
10
+ * @description Thin commander program: parses flags, hands off to command
11
+ * modules, and renders `ZazzError`s at the boundary. All behavior lives in
12
+ * the command modules and the deep seams they call (kit, config, plan,
13
+ * vendor, wiring, transaction).
14
+ */
15
+ const { version } = createRequire(import.meta.url)("../package.json");
16
+ const program = new Command("zazz-ui").description("Vendor Zazz Design Framework primitives into your project").version(version).option("-c, --cwd <path>", "run as if started in <path>", process.cwd()).option("-y, --yes", "answer prompts with their defaults; never block").option("--silent", "no output except errors").option("--registry <url>", "npm registry override").option("--offline", "cache only; never touch the network").option("--prefer-offline", "use cached data without revalidating");
17
+ program.command("init").description("vendor the Zazz base (tokens, reset, runtime) into this project").argument("[version]", "kit version, @-prefixed (e.g. @0.5.0); default latest").option("--dir <path>", "target directory for vendored files", "zazz").option("--ts", "vendor TypeScript sources instead of compiled .js").option("--legacy <path>", "wire an existing stylesheet into the legacy.imports cascade sublayer").option("--no-fonts", "omit the Geist fonts block from head.html").option("--no-theme-script", "omit the theme-persistence script from head.html").option("--force", "overwrite existing files without asking").option("--dry-run", "print the plan without writing").action(async (versionArg, options) => {
18
+ const { runInit } = await import("./init-CDXpbPiY.js");
19
+ await runInit(versionArg, options, program.opts());
20
+ });
21
+ program.command("update").description("move vendored files to a new kit version with 3-way merges").argument("[args...]", "target version @-prefixed (default @latest) and/or primitive names to narrow to").addOption(new Option("--keep", "resolve every conflict by keeping your version").conflicts(["theirs", "markers"])).addOption(new Option("--theirs", "resolve every conflict by taking the new version").conflicts(["keep", "markers"])).addOption(new Option("--markers", "write diff3 conflict markers for every conflict").conflicts(["keep", "theirs"])).option("--force", "overwrite stray files without asking").option("--dry-run", "print the plan without writing").action(async (args, options) => {
22
+ const { runUpdate } = await import("./update-CAg-JSg2.js");
23
+ await runUpdate(args, options, program.opts());
24
+ });
25
+ program.command("diff").description("preview what an update would change (read-only)").argument("[args...]", "target version @-prefixed (default @latest) and/or names to narrow to (base, button, …)").option("--upstream", "compare pristine recorded vs target instead of your files vs target").action(async (args, options) => {
26
+ const { runDiff } = await import("./diff-DAn1ZKsj.js");
27
+ await runDiff(args, options, program.opts());
28
+ });
29
+ program.command("add").description("vendor primitives (and their dependencies) at the project's kit version").argument("<primitive...>", "primitive names (e.g. button combobox)").option("--examples", "also copy the primitives' example html").option("--force", "overwrite existing files without asking").option("--dry-run", "print the closure and file plan without writing").action(async (names, options) => {
30
+ const { runAdd } = await import("./add-uh698Oeq.js");
31
+ await runAdd(names, options, program.opts());
32
+ });
33
+ try {
34
+ await program.parseAsync();
35
+ } catch (error) {
36
+ if (error instanceof ZazzError) {
37
+ console.error(chalk.red(`✖ ${error.message}`));
38
+ if (error.hint) console.error(chalk.dim(` ${error.hint}`));
39
+ process.exitCode = error.exitCode;
40
+ } else throw error;
41
+ }
42
+
43
+ //#endregion
44
+ export { };
@@ -0,0 +1,197 @@
1
+ import { t as ZazzError } from "./errors-DC2U2USS.js";
2
+ import { _ as resolveKit, a as renderIndexJs, c as createUi, f as baseFiles, g as kitSpec, h as loadFetchOptions, i as renderIndexCss, m as primitiveFiles, o as sha256, r as renderHead, t as appendJsImports, v as loadConfig } from "./wiring-BBm_hxrx.js";
3
+ import { a as compareVersions, i as isBinary, o as sliceChangelog, r as splitVersionArgs, t as readChangelog } from "./update-C4m0n9xX.js";
4
+ import chalk from "chalk";
5
+ import { existsSync } from "node:fs";
6
+ import { readFile } from "node:fs/promises";
7
+ import path from "node:path";
8
+ import { structuredPatch } from "diff";
9
+
10
+ //#region src/commands/diff.ts
11
+ /**
12
+ * @fileoverview `zazz-ui diff` — preview what an update would change.
13
+ * @description Read-only, always exit 0. Default compares your on-disk files
14
+ * against the target version's exact pristine bytes; `--upstream` compares
15
+ * pristine-at-recorded against pristine-at-target instead (what upstream
16
+ * changed, regardless of your edits). Ends with the relevant changelog slice.
17
+ * Generated entries diff against a regeneration at the target, mirroring what
18
+ * `update` would produce.
19
+ */
20
+ async function runDiff(args, flags, global) {
21
+ const cwd = path.resolve(global.cwd);
22
+ const ui = createUi({
23
+ silent: global.silent === true,
24
+ yes: global.yes === true
25
+ });
26
+ const fetch = await loadFetchOptions({
27
+ cwd,
28
+ registry: global.registry,
29
+ offline: global.offline,
30
+ preferOffline: global.preferOffline
31
+ });
32
+ const loaded = await loadConfig(cwd);
33
+ if (!loaded) throw new ZazzError("no zazz.json found — this project isn't initialized", { hint: "run `zazz-ui init` first" });
34
+ const { config, root } = loaded;
35
+ const { version, names } = splitVersionArgs(args);
36
+ for (const name of names) if (name !== "base" && !config.primitives[name]) throw new ZazzError(`"${name}" isn't vendored in this project`, { hint: `vendored: ${["base", ...Object.keys(config.primitives).sort()].join(", ")}` });
37
+ ui.intro("zazz-ui diff");
38
+ const target = await ui.spinner(`Resolving @zazz-ui/core@${version}…`, () => resolveKit(kitSpec(version), fetch), (resolved) => `Comparing against @zazz-ui/core@${resolved.version}`);
39
+ const kitCache = /* @__PURE__ */ new Map();
40
+ kitCache.set(target.version, Promise.resolve(target));
41
+ const kitAt = (v) => {
42
+ let kit = kitCache.get(v);
43
+ if (!kit) {
44
+ kit = resolveKit(kitSpec(v), fetch);
45
+ kitCache.set(v, kit);
46
+ }
47
+ return kit;
48
+ };
49
+ const vendoredNames = Object.keys(config.primitives);
50
+ const scope = names.length > 0 ? names : ["base", ...sortedByCascade(vendoredNames, target)];
51
+ let changes = 0;
52
+ for (const unit of scope) {
53
+ const files = await unitFiles(unit, {
54
+ config,
55
+ target
56
+ });
57
+ const recordedVersion = unit === "base" ? config.base.version ?? config.kit.version : config.primitives[unit]?.version ?? config.kit.version;
58
+ const oldKit = flags.upstream === true ? await kitAt(recordedVersion) : null;
59
+ const lines = [];
60
+ for (const spec of files) {
61
+ const theirs = await spec.theirs();
62
+ const mine = flags.upstream === true ? oldKit === null ? null : await upstreamSource(spec, oldKit, {
63
+ config,
64
+ target: oldKit
65
+ }) : await localSource(spec, root, config);
66
+ const rendered = renderFileDiff(spec.file, mine, theirs, { editedLocally: flags.upstream !== true && mine !== null && spec.recordedHash !== null && sha256(mine) !== spec.recordedHash });
67
+ if (rendered) lines.push(rendered);
68
+ }
69
+ if (lines.length > 0) {
70
+ changes += lines.length;
71
+ ui.step(`${chalk.bold(unit)} ${chalk.dim(`(${recordedVersion} → ${target.version})`)}\n${lines.join("\n")}`);
72
+ }
73
+ }
74
+ if (changes === 0) ui.step(`No differences against ${target.version}.`);
75
+ const changelog = await readChangelog(target);
76
+ if (changelog && compareVersions(target.version, config.kit.version) > 0) {
77
+ const slice = sliceChangelog(changelog, {
78
+ from: config.kit.version,
79
+ to: target.version
80
+ }, new Set(vendoredNames));
81
+ if (slice) ui.step(slice);
82
+ }
83
+ ui.outro(`Read-only — run \`zazz-ui update @${target.version}\` to apply.`);
84
+ }
85
+ /** The file set for one unit, with target-pristine (or regenerated) sources. */
86
+ async function unitFiles(unit, context) {
87
+ const { config, target } = context;
88
+ const fromKit = (file) => async () => target.has(file) ? target.readFile(file) : null;
89
+ if (unit !== "base") {
90
+ const record = config.primitives[unit];
91
+ const entry = target.manifest.primitives[unit];
92
+ const recorded = record ? Object.keys(record.files) : [];
93
+ const wantExamples = entry !== void 0 && entry.examples.some((file) => record && file in record.files);
94
+ const needed = entry ? primitiveFiles(entry, config.language, { examples: wantExamples }) : [];
95
+ return [.../* @__PURE__ */ new Set([...recorded, ...needed])].map((file) => ({
96
+ file,
97
+ recordedHash: record?.files[file] ?? null,
98
+ theirs: fromKit(file)
99
+ }));
100
+ }
101
+ const generated = /* @__PURE__ */ new Set([
102
+ "index.css",
103
+ "index.js",
104
+ "index.ts",
105
+ "head.html"
106
+ ]);
107
+ const entryScript = config.language === "ts" ? "index.ts" : "index.js";
108
+ const vendorable = [.../* @__PURE__ */ new Set([...Object.keys(config.base.files).filter((file) => !generated.has(file)), ...baseFiles(target.manifest, config.language)])];
109
+ const entries = generateEntries(target, config);
110
+ return [
111
+ ...vendorable.map((file) => ({
112
+ file,
113
+ recordedHash: config.base.files[file] ?? null,
114
+ theirs: fromKit(file)
115
+ })),
116
+ {
117
+ file: "index.css",
118
+ recordedHash: config.base.files["index.css"] ?? null,
119
+ theirs: async () => entries.css
120
+ },
121
+ {
122
+ file: entryScript,
123
+ recordedHash: config.base.files[entryScript] ?? null,
124
+ theirs: async () => entries.js
125
+ },
126
+ {
127
+ file: "head.html",
128
+ recordedHash: config.base.files["head.html"] ?? null,
129
+ theirs: async () => renderHead(target, config)
130
+ }
131
+ ];
132
+ }
133
+ /** Entry pair regenerated at the target with the currently vendored set. */
134
+ function generateEntries(target, config) {
135
+ const cascade = new Map(target.manifest.cssCascadeOrder.map((name, index) => [name, index]));
136
+ const ordered = Object.keys(config.primitives).filter((name) => target.manifest.primitives[name]).sort((a, b) => (cascade.get(a) ?? Infinity) - (cascade.get(b) ?? Infinity));
137
+ const css = renderIndexCss({
138
+ kit: target,
139
+ legacy: config.legacy,
140
+ primitives: ordered.map((name) => ({
141
+ name,
142
+ css: target.manifest.primitives[name]?.css ?? []
143
+ }))
144
+ });
145
+ const scripts = ordered.flatMap((name) => {
146
+ const entry = target.manifest.primitives[name];
147
+ return entry ? [...entry.base, ...entry.js] : [];
148
+ });
149
+ return {
150
+ css,
151
+ js: appendJsImports(renderIndexJs({
152
+ kit: target,
153
+ language: config.language
154
+ }), [...new Set(scripts)], config.language)
155
+ };
156
+ }
157
+ async function localSource(spec, root, config) {
158
+ const dest = path.join(root, config.dir, ...spec.file.split("/"));
159
+ return existsSync(dest) ? readFile(dest) : null;
160
+ }
161
+ /** `--upstream` left side: pristine at the recorded version (or regenerated). */
162
+ async function upstreamSource(spec, oldKit, context) {
163
+ if (oldKit.has(spec.file)) return oldKit.readFile(spec.file);
164
+ const entries = generateEntries(oldKit, context.config);
165
+ if (spec.file === "index.css") return entries.css;
166
+ if (spec.file === "index.js" || spec.file === "index.ts") return entries.js;
167
+ if (spec.file === "head.html") return renderHead(oldKit, context.config);
168
+ return null;
169
+ }
170
+ /** One file's colorized diff block, or null when there is nothing to show. */
171
+ function renderFileDiff(file, mine, theirs, options) {
172
+ if (mine === null && theirs === null) return null;
173
+ const badge = options.editedLocally ? chalk.yellow(" (edited locally)") : "";
174
+ if (theirs === null) return `${chalk.bold(file)}${badge} ${chalk.red("— removed upstream")}`;
175
+ if (mine === null) return `${chalk.bold(file)} ${chalk.green("— new at this version")}`;
176
+ const mineBuf = typeof mine === "string" ? Buffer.from(mine) : mine;
177
+ const theirsBuf = typeof theirs === "string" ? Buffer.from(theirs) : theirs;
178
+ if (mineBuf.equals(theirsBuf)) return null;
179
+ if (isBinary(mineBuf) || isBinary(theirsBuf)) return `${chalk.bold(file)}${badge} ${chalk.yellow("— binary files differ")}`;
180
+ const patch = structuredPatch(file, file, mineBuf.toString("utf8"), theirsBuf.toString("utf8"), void 0, void 0, { context: 3 });
181
+ if (patch.hunks.length === 0) return null;
182
+ const lines = [`${chalk.bold(file)}${badge}`];
183
+ for (const hunk of patch.hunks) {
184
+ lines.push(chalk.cyan(`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`));
185
+ for (const line of hunk.lines) if (line.startsWith("+")) lines.push(chalk.green(line));
186
+ else if (line.startsWith("-")) lines.push(chalk.red(line));
187
+ else lines.push(chalk.dim(line));
188
+ }
189
+ return lines.join("\n");
190
+ }
191
+ function sortedByCascade(names, kit) {
192
+ const cascade = new Map(kit.manifest.cssCascadeOrder.map((name, index) => [name, index]));
193
+ return [...names].sort((a, b) => (cascade.get(a) ?? Infinity) - (cascade.get(b) ?? Infinity));
194
+ }
195
+
196
+ //#endregion
197
+ export { runDiff };
@@ -0,0 +1,33 @@
1
+ //#region src/errors.ts
2
+ /**
3
+ * @fileoverview The CLI's one error type and its canonical messages.
4
+ * @description Commands and modules throw `ZazzError` for every expected
5
+ * failure; the boundary in `cli.ts` renders `message` (and `hint`, dimmed)
6
+ * and exits with `exitCode`. Exit codes: 1 = hard error, 2 = completed with
7
+ * skipped files (CI can tell "broken" from "needs a human merge").
8
+ */
9
+ var ZazzError = class extends Error {
10
+ exitCode;
11
+ hint;
12
+ constructor(message, options = {}) {
13
+ super(message);
14
+ this.name = "ZazzError";
15
+ this.exitCode = options.exitCode ?? 1;
16
+ this.hint = options.hint;
17
+ }
18
+ };
19
+ /** The offline cache-miss error. */
20
+ function offlineMiss(spec) {
21
+ return new ZazzError(`cannot reach npm and ${spec} is not cached`, { hint: "reconnect, or drop --offline; exact versions cache after the first fetch" });
22
+ }
23
+ /** The kit-newer-than-CLI error. */
24
+ function kitTooNew(version, detail) {
25
+ return new ZazzError(`@zazz-ui/core@${version} is newer than this CLI understands (${detail})`, { hint: "upgrade with: pnpm dlx zazz-ui@latest (or npm i -g zazz-ui@latest)" });
26
+ }
27
+ /** The kit-older-than-CLI error (a manifest below the supported range). */
28
+ function kitTooOld(version, detail) {
29
+ return new ZazzError(`@zazz-ui/core@${version} is older than this CLI supports (${detail})`, { hint: "target a newer kit version (e.g. @latest), or use an older zazz-ui" });
30
+ }
31
+
32
+ //#endregion
33
+ export { offlineMiss as i, kitTooNew as n, kitTooOld as r, ZazzError as t };
@@ -0,0 +1,3 @@
1
+ import { n as runInit, t as parseVersionArg } from "./init-DsZP08nV.js";
2
+
3
+ export { runInit };