zazz-ui 0.3.0 → 0.3.1

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,10 @@
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.1 (2026-10-13)
6
+
7
+ - `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.
8
+
5
9
  ## 0.3.0 (2026-10-07)
6
10
 
7
11
  First public release. npm had only a `0.0.0` placeholder before it.
package/README.md CHANGED
@@ -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.6 (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-C77bl5LR.js";
3
3
  import { existsSync } from "node:fs";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import path from "node:path";
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-OVodXfKt.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-CTuqOys3.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-B38wvndQ.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-Bm5kc6TG.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-C77bl5LR.js";
3
+ import { a as compareVersions, i as isBinary, o as sliceChangelog, r as splitVersionArgs, t as readChangelog } from "./update-BAfhUb3N.js";
4
4
  import chalk from "chalk";
5
5
  import { existsSync } from "node:fs";
6
6
  import { readFile } from "node:fs/promises";
@@ -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-C77bl5LR.js";
3
3
  import { existsSync } from "node:fs";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import path from "node:path";
@@ -0,0 +1,3 @@
1
+ import { n as runInit, t as parseVersionArg } from "./init-CXljM6FO.js";
2
+
3
+ export { runInit };
@@ -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-C77bl5LR.js";
3
+ import { t as parseVersionArg } from "./init-CXljM6FO.js";
4
4
  import chalk from "chalk";
5
5
  import { existsSync } from "node:fs";
6
6
  import { readFile } from "node:fs/promises";
@@ -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-BAfhUb3N.js";
2
2
 
3
3
  export { runUpdate };
@@ -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,13 @@ 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
+ /** Everything `init` vendors: base css + core runtime, its polyfills, and its fallbacks, per language. */
386
399
  function baseFiles(manifest, language) {
387
- return [...baseCss(manifest), ...[...coreRuntime(manifest), ...corePolyfills(manifest).map((polyfill) => polyfill.file)].flatMap((jsPath) => scriptVariants(jsPath, language))];
400
+ return [...baseCss(manifest), ...[
401
+ ...coreRuntime(manifest),
402
+ ...corePolyfills(manifest).map((polyfill) => polyfill.file),
403
+ ...coreFallbacks(manifest).flatMap((fallback) => [fallback.file, ...fallback.requires])
404
+ ].flatMap((jsPath) => scriptVariants(jsPath, language))];
388
405
  }
389
406
  /** Everything `add` vendors for one primitive (dependencies resolved by the caller). */
390
407
  function primitiveFiles(entry, language, options) {
@@ -610,14 +627,35 @@ function renderIndexJs(options) {
610
627
  return `if (typeof CSS !== "undefined" && !CSS.supports("${property}", "${value}")) {\n void import("./${specifier}");\n}`;
611
628
  });
612
629
  const polyfills = gates.length > 0 ? `\n// Polyfills load only where the browser lacks the CSS feature.\n${gates.join("\n")}\n` : "";
630
+ const fallbacks = coreFallbacks(options.kit.manifest).map(({ file, gate }) => {
631
+ const [specifier] = scriptVariants(file, options.language);
632
+ return FALLBACK_SNIPPETS[gate](`./${specifier}`);
633
+ }).join("\n");
613
634
  return `/**
614
635
  * index.js — vendored Zazz behavior entry (generated by zazz-ui; yours to edit).
615
636
  * zazz-ui add inserts primitive imports after the last import, in dependency order.
616
637
  */
617
638
 
618
639
  ${runtime.join("\n")}
619
- ${polyfills}`;
620
- }
640
+ ${polyfills}${fallbacks ? `\n${fallbacks}\n` : ""}`;
641
+ }
642
+ /** The document check for each fallback gate, as the kit's `index.ts` writes it. */
643
+ const FALLBACK_SNIPPETS = { "blocked-inline-styles": (specifier) => `// A Content Security Policy that blocks inline style attributes leaves the
644
+ // attribute text in the DOM with an empty declaration block; load the CSSOM fallback.
645
+ function blockedInlineStyles() {
646
+ for (const el of document.querySelectorAll("[style]")) {
647
+ const text = el.getAttribute("style");
648
+ if (text && text.includes(":") && el.style.length === 0) return true;
649
+ }
650
+ return false;
651
+ }
652
+ if (typeof document !== "undefined") {
653
+ const check = () => {
654
+ if (blockedInlineStyles()) void import("${specifier}");
655
+ };
656
+ if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", check);
657
+ else check();
658
+ }` };
621
659
  function importLine(jsPath, language) {
622
660
  const [file] = scriptVariants(jsPath, language);
623
661
  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.1",
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",
@@ -1,3 +0,0 @@
1
- import { n as runInit, t as parseVersionArg } from "./init-DsZP08nV.js";
2
-
3
- export { runInit };