zazz-ui 0.3.0 → 0.3.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
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
4
 
5
+ ## 0.3.2 (2026-10-26)
6
+
7
+ - `init --ts` vendors the kit's `globals.d.ts`, the ambient types the TypeScript sources check against (`window.Utils`, `Signals`, `Toaster`, `CommandEvent`). A full `update` adds it to an existing `--ts` project and keeps it current. If you copied the file in by hand, delete your copy after updating, or TypeScript reports a duplicate `EmblaCarouselType`.
8
+ - The CSP fallback check in the generated `index.js`/`index.ts` reads `style` only after narrowing to `HTMLElement`, so a TypeScript entry (or `checkJs`) no longer flags `el.style` on an `Element`.
9
+
10
+ ## 0.3.1 (2026-10-13)
11
+
12
+ - `init` vendors the kit's runtime fallbacks (`CORE_FALLBACKS`, from core 0.6.3: the Content Security Policy fallback `base/csp.js` and the `style` parser it imports) and writes their document check into `index.js`, the way the kit's own entry does. A fallback with a gate this CLI does not know is skipped, so a newer kit still vendors.
13
+
5
14
  ## 0.3.0 (2026-10-07)
6
15
 
7
16
  First public release. npm had only a `0.0.0` placeholder before it.
package/README.md CHANGED
@@ -13,7 +13,7 @@ pnpm dlx zazz-ui add button combobox
13
13
 
14
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
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.
16
+ Flags: `--dir <path>`, `--ts` (vendor TypeScript sources instead of compiled js, plus the kit's ambient `globals.d.ts`), `--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
17
 
18
18
  ## What add does
19
19
 
@@ -33,7 +33,7 @@ There is no runtime dependency on `@zazz-ui/core`. The files in `zazz/` are your
33
33
 
34
34
  ## Requirements
35
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.
36
+ Node 22.22+ (or 24.15+). Works with `@zazz-ui/core` 0.1 through 0.8 (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
37
 
38
38
  ## License
39
39
 
@@ -1,5 +1,5 @@
1
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";
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-CWDMdCmo.js";
3
3
  import { existsSync } from "node:fs";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import path from "node:path";
@@ -45,14 +45,17 @@ async function runAdd(names, flags, global) {
45
45
  for (const name of fresh) {
46
46
  const entry = kit.manifest.primitives[name];
47
47
  if (!entry) continue;
48
- const { writes, hashes } = await vendorFiles(kit, primitiveFiles(entry, config.language, { examples: flags.examples === true && names.includes(name) }), destRoot);
48
+ const files = primitiveFiles(entry, config.language, { examples: flags.examples === true && names.includes(name) });
49
+ const { writes, hashes } = await vendorFiles(kit, files, destRoot);
49
50
  vendorWrites.push(...writes);
50
51
  config.primitives[name] = {
51
52
  version: kit.version,
52
53
  files: hashes
53
54
  };
54
55
  }
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
+ const freshEntries = fresh.flatMap((name) => kit.manifest.primitives[name] ?? []);
57
+ const neededBase = baseScriptFiles(freshEntries, config.language).filter((file) => !(file in config.base.files));
58
+ const base = await vendorFiles(kit, neededBase, destRoot);
56
59
  vendorWrites.push(...base.writes);
57
60
  Object.assign(config.base.files, base.hashes);
58
61
  const { kept, skipped } = await filterCollisions(vendorWrites, {
package/dist/cli.js CHANGED
@@ -15,19 +15,19 @@ import { Command, Option } from "commander";
15
15
  const { version } = createRequire(import.meta.url)("../package.json");
16
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
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");
18
+ const { runInit } = await import("./init-DqkIVXKV.js");
19
19
  await runInit(versionArg, options, program.opts());
20
20
  });
21
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");
22
+ const { runUpdate } = await import("./update-BPtPsPr7.js");
23
23
  await runUpdate(args, options, program.opts());
24
24
  });
25
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");
26
+ const { runDiff } = await import("./diff-BRTyzqhQ.js");
27
27
  await runDiff(args, options, program.opts());
28
28
  });
29
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");
30
+ const { runAdd } = await import("./add-Cvilkl7S.js");
31
31
  await runAdd(names, options, program.opts());
32
32
  });
33
33
  try {
@@ -1,6 +1,6 @@
1
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";
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-CWDMdCmo.js";
3
+ import { a as compareVersions, i as isBinary, o as sliceChangelog, r as splitVersionArgs, t as readChangelog } from "./update-CaIG25mx.js";
4
4
  import chalk from "chalk";
5
5
  import { existsSync } from "node:fs";
6
6
  import { readFile } from "node:fs/promises";
@@ -0,0 +1,3 @@
1
+ import { n as runInit, t as parseVersionArg } from "./init-m26gsqEa.js";
2
+
3
+ export { runInit };
@@ -1,5 +1,5 @@
1
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, l as apply, o as sha256, r as renderHead, s as vendorFiles, t as appendJsImports, u as describe, v as loadConfig, y as filterCollisions } from "./wiring-BBm_hxrx.js";
2
+ import { _ as resolveKit, a as renderIndexJs, c as createUi, f as baseFiles, g as kitSpec, h as loadFetchOptions, i as renderIndexCss, l as apply, o as sha256, r as renderHead, s as vendorFiles, t as appendJsImports, u as describe, v as loadConfig, y as filterCollisions } from "./wiring-CWDMdCmo.js";
3
3
  import { existsSync } from "node:fs";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import path from "node:path";
@@ -142,7 +142,8 @@ async function repair(config, root, context) {
142
142
  });
143
143
  continue;
144
144
  }
145
- if (sha256(await readFile(dest)) === recordedHash) intact += 1;
145
+ const onDisk = await readFile(dest);
146
+ if (sha256(onDisk) === recordedHash) intact += 1;
146
147
  else if (context.force) writes.push({
147
148
  dest,
148
149
  content,
@@ -1,3 +1,3 @@
1
- import { n as runUpdate, r as splitVersionArgs, t as readChangelog } from "./update-C4m0n9xX.js";
1
+ import { n as runUpdate, r as splitVersionArgs, t as readChangelog } from "./update-CaIG25mx.js";
2
2
 
3
3
  export { runUpdate };
@@ -1,6 +1,6 @@
1
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, l as apply, m as primitiveFiles, o as sha256, p as baseScriptFiles, r as renderHead, t as appendJsImports, u as describe, v as loadConfig, y as filterCollisions } from "./wiring-BBm_hxrx.js";
3
- import { t as parseVersionArg } from "./init-DsZP08nV.js";
2
+ import { _ as resolveKit, a as renderIndexJs, c as createUi, f as baseFiles, g as kitSpec, h as loadFetchOptions, i as renderIndexCss, l as apply, m as primitiveFiles, o as sha256, p as baseScriptFiles, r as renderHead, t as appendJsImports, u as describe, v as loadConfig, y as filterCollisions } from "./wiring-CWDMdCmo.js";
3
+ import { t as parseVersionArg } from "./init-m26gsqEa.js";
4
4
  import chalk from "chalk";
5
5
  import { existsSync } from "node:fs";
6
6
  import { readFile } from "node:fs/promises";
@@ -161,6 +161,8 @@ const SUPPORTED_MANIFEST = {
161
161
  max: 2
162
162
  };
163
163
  const EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
164
+ /** The document checks this CLI can write into the entry; a fallback with another gate is skipped. */
165
+ const FALLBACK_GATES = ["blocked-inline-styles"];
164
166
  /**
165
167
  * @description Turns a user-facing version argument into a full pacote spec.
166
168
  * The `ZAZZ_UI_KIT` environment variable overrides the whole spec (e2e tests
@@ -261,6 +263,7 @@ async function loadKitFromDir(extractDir, meta) {
261
263
  const baseCssPost = manifestModule.BASE_CSS_POST;
262
264
  const coreRuntime = manifestModule.CORE_RUNTIME;
263
265
  const corePolyfills = manifestModule.CORE_POLYFILLS;
266
+ const coreFallbacks = Array.isArray(manifestModule.CORE_FALLBACKS) ? manifestModule.CORE_FALLBACKS.filter(isRuntimeFallback) : [];
264
267
  return {
265
268
  version: meta.version,
266
269
  integrity: meta.integrity,
@@ -273,7 +276,8 @@ async function loadKitFromDir(extractDir, meta) {
273
276
  ...Array.isArray(baseCssPre) ? { baseCssPre } : {},
274
277
  ...Array.isArray(baseCssPost) ? { baseCssPost } : {},
275
278
  ...Array.isArray(coreRuntime) ? { coreRuntime } : {},
276
- ...Array.isArray(corePolyfills) && corePolyfills.every(isRuntimePolyfill) ? { corePolyfills } : {}
279
+ ...Array.isArray(corePolyfills) && corePolyfills.every(isRuntimePolyfill) ? { corePolyfills } : {},
280
+ ...coreFallbacks.length > 0 ? { coreFallbacks } : {}
277
281
  },
278
282
  buildHead,
279
283
  readFile: async (srcRelPath) => readFile(resolveWithin(srcDir, srcRelPath)),
@@ -285,6 +289,11 @@ function isRuntimePolyfill(value) {
285
289
  const { file, supports } = value;
286
290
  return typeof file === "string" && Array.isArray(supports) && supports.length === 2 && supports.every((part) => typeof part === "string");
287
291
  }
292
+ function isRuntimeFallback(value) {
293
+ if (typeof value !== "object" || value === null) return false;
294
+ const { file, requires, gate } = value;
295
+ return typeof file === "string" && Array.isArray(requires) && requires.every((part) => typeof part === "string") && FALLBACK_GATES.includes(gate);
296
+ }
288
297
  /** Path-traversal guard for manifest-supplied paths. */
289
298
  function resolveWithin(root, relative) {
290
299
  const resolved = path.resolve(root, relative);
@@ -363,6 +372,10 @@ const V1_CORE_RUNTIME = [
363
372
  function corePolyfills(manifest) {
364
373
  return manifest.corePolyfills ?? [];
365
374
  }
375
+ /** Document-gated fallbacks the entry loads where the page needs them (the CSP fallback); none before 0.6.3. */
376
+ function coreFallbacks(manifest) {
377
+ return manifest.coreFallbacks ?? [];
378
+ }
366
379
  /** Base stylesheets split around the primitives: pre loads first, post is the override layer. */
367
380
  function baseCssSplit(manifest) {
368
381
  return {
@@ -382,9 +395,21 @@ function scriptVariants(jsPath, language) {
382
395
  if (language === "ts") return [jsPath.replace(/\.js$/, ".ts")];
383
396
  return [jsPath, jsPath.replace(/\.js$/, ".d.ts")];
384
397
  }
385
- /** Everything `init` vendors: base css + core runtime and its polyfills, per language. */
398
+ /**
399
+ * Everything `init` vendors: base css + core runtime, its polyfills, and its
400
+ * fallbacks, per language. TypeScript also gets the ambient `globals.d.ts`
401
+ * the sources type-check against (the emitted `.d.ts` files don't need it).
402
+ */
386
403
  function baseFiles(manifest, language) {
387
- return [...baseCss(manifest), ...[...coreRuntime(manifest), ...corePolyfills(manifest).map((polyfill) => polyfill.file)].flatMap((jsPath) => scriptVariants(jsPath, language))];
404
+ return [
405
+ ...language === "ts" ? ["globals.d.ts"] : [],
406
+ ...baseCss(manifest),
407
+ ...[
408
+ ...coreRuntime(manifest),
409
+ ...corePolyfills(manifest).map((polyfill) => polyfill.file),
410
+ ...coreFallbacks(manifest).flatMap((fallback) => [fallback.file, ...fallback.requires])
411
+ ].flatMap((jsPath) => scriptVariants(jsPath, language))
412
+ ];
388
413
  }
389
414
  /** Everything `add` vendors for one primitive (dependencies resolved by the caller). */
390
415
  function primitiveFiles(entry, language, options) {
@@ -610,14 +635,35 @@ function renderIndexJs(options) {
610
635
  return `if (typeof CSS !== "undefined" && !CSS.supports("${property}", "${value}")) {\n void import("./${specifier}");\n}`;
611
636
  });
612
637
  const polyfills = gates.length > 0 ? `\n// Polyfills load only where the browser lacks the CSS feature.\n${gates.join("\n")}\n` : "";
638
+ const fallbacks = coreFallbacks(options.kit.manifest).map(({ file, gate }) => {
639
+ const [specifier] = scriptVariants(file, options.language);
640
+ return FALLBACK_SNIPPETS[gate](`./${specifier}`);
641
+ }).join("\n");
613
642
  return `/**
614
643
  * index.js — vendored Zazz behavior entry (generated by zazz-ui; yours to edit).
615
644
  * zazz-ui add inserts primitive imports after the last import, in dependency order.
616
645
  */
617
646
 
618
647
  ${runtime.join("\n")}
619
- ${polyfills}`;
620
- }
648
+ ${polyfills}${fallbacks ? `\n${fallbacks}\n` : ""}`;
649
+ }
650
+ /** The document check for each fallback gate, as the kit's `index.ts` writes it. */
651
+ const FALLBACK_SNIPPETS = { "blocked-inline-styles": (specifier) => `// A Content Security Policy that blocks inline style attributes leaves the
652
+ // attribute text in the DOM with an empty declaration block; load the CSSOM fallback.
653
+ function blockedInlineStyles() {
654
+ for (const el of document.querySelectorAll("[style]")) {
655
+ const text = el.getAttribute("style");
656
+ if (text && text.includes(":") && el instanceof HTMLElement && el.style.length === 0) return true;
657
+ }
658
+ return false;
659
+ }
660
+ if (typeof document !== "undefined") {
661
+ const check = () => {
662
+ if (blockedInlineStyles()) void import("${specifier}");
663
+ };
664
+ if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", check);
665
+ else check();
666
+ }` };
621
667
  function importLine(jsPath, language) {
622
668
  const [file] = scriptVariants(jsPath, language);
623
669
  return `import "./${file}";`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zazz-ui",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "CLI for the Zazz Design Framework — vendors primitives from @zazz-ui/core into your project, with provenance-tracked updates.",
5
5
  "keywords": [
6
6
  "cli",
@@ -32,22 +32,22 @@
32
32
  "access": "public"
33
33
  },
34
34
  "dependencies": {
35
- "@clack/prompts": "^1.7.0",
36
- "@npmcli/config": "^11.0.1",
37
- "chalk": "^6.0.0",
35
+ "@clack/prompts": "^1.8.1",
36
+ "@npmcli/config": "^11.2.0",
37
+ "chalk": "^6.0.1",
38
38
  "commander": "^15.0.0",
39
39
  "diff": "^9.0.0",
40
40
  "node-diff3": "^3.2.1",
41
41
  "pacote": "^22.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@types/node": "^26.2.0",
44
+ "@types/node": "^26.6.5",
45
45
  "@types/pacote": "^11.1.8",
46
46
  "tar": "^7.5.22",
47
47
  "typescript": "^7.0.2",
48
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
49
- "vite-plus": "0.2.4",
50
- "vitest": "4.1.10"
48
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
49
+ "vite-plus": "1.3.0",
50
+ "vitest": "5.0.5"
51
51
  },
52
52
  "engines": {
53
53
  "node": "^22.22.2 || ^24.15.0 || >=26.0.0"
@@ -1,3 +0,0 @@
1
- import { n as runInit, t as parseVersionArg } from "./init-DsZP08nV.js";
2
-
3
- export { runInit };