uhuu-components 0.4.6 → 0.4.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/index.d.ts CHANGED
@@ -812,17 +812,35 @@ export interface BrandKitJson {
812
812
  [token: string]: unknown;
813
813
  };
814
814
  colorMode?: "light" | "manual" | "shade";
815
- /** Template variables Brand Kit precomputed at publish. Applied as is when `version` is 2. */
815
+ /** Template variables Brand Kit precomputed at publish for current public 3.x documents. */
816
816
  runtime?: BrandKitRuntimeBlock;
817
+ /** What wrote the document; a published version names itself in `release`. */
818
+ generator?: { name?: string; release?: BrandKitRelease; [key: string]: unknown };
817
819
  [key: string]: unknown;
818
820
  }
819
821
 
820
822
  /**
821
- * `brandkit.json.runtime` (brandkit.json "2.0"): shadcn role variables (`--primary`, `--color-primary`),
822
- * `--color-kit-*` / `--font-*` / `--font-kit-*` values, ready to apply, and the fonts to load.
823
+ * `generator.release` of a published version's document (older documents have none): it lets
824
+ * `?brand=v9` and `uhuu-components brand status | activate v9` name another version of the brand a
825
+ * template's `src/brand/brandkit.json` holds.
826
+ */
827
+ export interface BrandKitRelease {
828
+ teamId: string;
829
+ kitId: string;
830
+ /** `v1`, `v2`… */
831
+ version: string;
832
+ /** This version's immutable `…/versions/vN/brandkit.json`. */
833
+ url: string;
834
+ /** The Brand Kit app's origin, which says which version is newest. */
835
+ appUrl?: string;
836
+ }
837
+
838
+ /**
839
+ * `brandkit.json.runtime` (public 3.x): canonical semantic and font-role variables, ready to
840
+ * apply, and the fonts to load. It cannot carry template layout or decoration tokens.
823
841
  */
824
842
  export interface BrandKitRuntimeBlock {
825
- version: 2;
843
+ version: 3;
826
844
  light: Record<string, string>;
827
845
  fontStylesheets?: string[];
828
846
  fontFaces?: Array<{
@@ -838,15 +856,13 @@ export interface BrandKitRuntimeBlock {
838
856
  }
839
857
 
840
858
  export interface BrandKitLogo {
841
- /** Absolute URL (SVG preferred, else PNG). */
859
+ /** Absolute SVG URL. */
842
860
  src: string;
843
861
  alt?: string;
844
862
  kind: "primary" | "mark" | "wordmark";
845
863
  background?: "light" | "dark" | "any";
846
864
  /** The language a named or language version is for. */
847
865
  locale?: string;
848
- minWidth?: { value: number; unit: "px" | "mm" };
849
- clearSpace?: { value: number; unit: "px" | "mm" | "mark" };
850
866
  }
851
867
 
852
868
  export interface BrandKitCollectionItem {
@@ -872,7 +888,7 @@ export interface BrandKitCollection {
872
888
  export interface BrandKitMapStyle {
873
889
  url: string;
874
890
  name?: string;
875
- source: "config.maps" | "config.env";
891
+ source: "extensions.maps" | "extensions.env";
876
892
  }
877
893
 
878
894
  export type BrandKitLogoKind = "primary" | "logo" | "lockup" | "mark" | "icon" | "symbol" | "wordmark";
@@ -882,16 +898,14 @@ export type BrandKitMediaKind = "photos" | "icons" | "graphics" | "backgrounds"
882
898
  export interface BrandKitRuntime {
883
899
  /** The kit being rendered: the fetched one, else the `brandKit` prop. */
884
900
  brandKit: BrandKitJson | null;
885
- /** `--<role>`, `--color-<role>`, `--color-kit-*`, `--font-*` and `--font-kit-*`, as the provider's scope element carries them. */
901
+ /** Canonical semantic, extension-colour and font-role variables as the provider's scope element carries them. */
886
902
  cssVars: Record<string, string>;
887
903
  /** Where the rendered kit came from (`src` once fetched, else the `sourceUrl` prop). */
888
904
  sourceUrl?: string;
889
- /** `idle` without `src` (a snapshot or the `brandKit` prop renders); `loading` until it arrives; `ready`; `error`. */
905
+ /** `idle` without `src` (the `brandKit` prop renders); `loading` until it arrives; `ready`; `error`. */
890
906
  status: "idle" | "loading" | "ready" | "error";
891
- /** The snapshot the rendered kit came from, when no fetched kit replaced it. */
892
- snapshot: BrandKitSnapshotInfo | null;
893
907
  /**
894
- * A logo, resolved: `logoSystem` first, then `logos`. Default `{ kind: "primary", background: "light" }`.
908
+ * A logo resolved from `logoSystem`. Default `{ kind: "primary", background: "light" }`.
895
909
  * `name` and `locale` pick a named or language version, falling back to the standard logo.
896
910
  */
897
911
  logo(options?: { kind?: BrandKitLogoKind; background?: "light" | "dark"; name?: string; locale?: string }): BrandKitLogo | null;
@@ -899,34 +913,32 @@ export interface BrandKitRuntime {
899
913
  chartPalette(options?: { fallback?: string[]; count?: number }): BrandChartPalette;
900
914
  /** The brand's default locale and currency (`extensions.locale`); `payload.locale` wins over it. */
901
915
  locale: { locale?: string; currency?: string };
902
- /** The assigned media collection's promoted version, items resolved. */
903
- collection(kind: BrandKitMediaKind | string, options?: { versionId?: string }): BrandKitCollection | null;
916
+ /** Public 3.x: canonical kind/id and active-version selection. */
917
+ collection(kindOrId: BrandKitMediaKind | string, options?: { versionId?: string }): BrandKitCollection | null;
904
918
  mapStyle(mode: "micro" | "macro"): BrandKitMapStyle | null;
905
- /** A `config.env` value; keys compare case- and punctuation-insensitively, first present wins. */
919
+ /** An `extensions.env.strings` value; keys compare case- and punctuation-insensitively. */
906
920
  env(keys: string | string[]): string | undefined;
907
921
  /** A kit-relative asset path made absolute. */
908
922
  resolveUrl(path: unknown): string | undefined;
909
923
  }
910
924
 
911
925
  export interface BrandKitProviderProps {
912
- /** The kit to render; with `src`, the fallback until the fetched kit arrives or when the fetch fails. */
913
- brandKit?: BrandKitJson | null;
914
- /** A brandkit.json URL to fetch, usually `brandKitSelection(payload, { snapshot }).src`. */
915
- src?: string | null;
916
926
  /**
917
- * The template's locked brand (`src/brand/`, from `brandkit pull`): renders with no request for
918
- * the brand, logos and fonts from the template's copies. Wins over `brandKit`; a fetched `src`
919
- * replaces it. Pass a stable object.
927
+ * The kit to render, usually the template's own `src/brand/brandkit.json`; with `src`, the fallback
928
+ * until the fetched kit arrives or when the fetch fails.
920
929
  */
921
- snapshot?: BrandKitSnapshot | null;
930
+ brandKit?: BrandKitJson | null;
931
+ /** A brandkit.json URL to fetch, usually `brandKitSelection(payload).src`. */
932
+ src?: string | null;
922
933
  /** Brand values the template opts into beyond colours and fonts: `{ radius: true }` adds `--radius*`. Stable object. */
923
934
  adopt?: { radius?: boolean };
924
935
  /** Custom properties for whatever the kit leaves out; the kit wins. Pass a stable object. */
925
936
  defaults?: Record<string, string>;
926
937
  /** Where a `brandKit` passed in came from; its directory resolves relative URLs when the kit has no `baseUrl`. */
927
938
  sourceUrl?: string;
939
+ /** Called with each kit fetched from `src`; never for a development preview (`?brand=`). */
928
940
  onLoad?: (brandKit: BrandKitJson) => void;
929
- /** Default: `console.error`. */
941
+ /** Called when `src` fails to load; never for a development preview. Default: `console.error`. */
930
942
  onError?: (error: unknown) => void;
931
943
  /** For the scope element. `style` is applied last, so `{ display: "block" }` gives it a box. */
932
944
  className?: string;
@@ -939,6 +951,10 @@ export interface BrandKitProviderProps {
939
951
  * element (`data-uhuu-brand-kit-status` tells a print step when a fetched kit has arrived), and
940
952
  * loads the fonts the kit declares. Colours are hex, `rgb()`/`rgba()`, `oklch()`/`oklab()` or
941
953
  * keywords: HSL is converted, anything else is skipped as if absent.
954
+ *
955
+ * On a development host, and never when `$uhuu_renderer` is set, `?brand=` on the page URL (`v9`, a
956
+ * `…/versions/vN/brandkit.json` link, or a same-origin path) renders that candidate instead, under a
957
+ * bar with what changed and Stop. It is written nowhere and never printed.
942
958
  */
943
959
  export const BrandKitProvider: ComponentType<BrandKitProviderProps>;
944
960
 
@@ -949,46 +965,15 @@ export function useBrandKit(): BrandKitRuntime | null;
949
965
  export const BRAND_KIT_PUBLIC_BASE_URL: string;
950
966
 
951
967
  /**
952
- * The brandkit.json URL a payload points at: `brandKitUrl` (URL or `kit-…` id), `brandKitId`, or
953
- * `brandKit.storage.publicUrl`. Ids need `brandKitTeamId` (or `teamId`) and resolve under `publicBaseUrl`.
954
- * @deprecated Use `brandKitSelection(payload, { snapshot })`: a pinned `payload.brand`, then the template's snapshot.
955
- */
956
- export function brandKitSourceUrl(
957
- payload: Record<string, unknown> | null | undefined,
958
- options?: { publicBaseUrl?: string; teamId?: string | number },
959
- ): string | null;
960
-
961
- /**
962
- * Which brand a document renders: a pinned `payload.brand` (unpinned warns), then the deprecated
963
- * `brandKitUrl` / `brandKitId` (warns), then the template's snapshot, then none.
968
+ * Which brand a document renders: a pinned `payload.brand` (unpinned warns), then none: the
969
+ * template's own current `brandkit.json` (`brandKit` prop) renders.
970
+ * `pinned` is true when `src` is an immutable `…/versions/vN/brandkit.json` (and for a preset, which
971
+ * fetches nothing). A `version: "vN"` beside a kit's root `…/kits/<kit>/brandkit.json` selects that
972
+ * version's URL; a version alone pins nothing.
964
973
  */
965
974
  export function brandKitSelection(
966
975
  payload: Record<string, unknown> | null | undefined,
967
- options?: { snapshot?: BrandKitSnapshot | null; publicBaseUrl?: string; teamId?: string | number },
968
- ): { source: "payload" | "payload-legacy" | "snapshot" | "none"; src: string | null; pinned: boolean; presetId?: string };
969
-
970
- /** A template's locked brand: the published document, its `brand.lock.json`, and where the copies are served. */
971
- export interface BrandKitSnapshot {
972
- brandKit: BrandKitJson;
973
- /** `brand.lock.json` (`uhuu.brand-lock.v1`). */
974
- lock: Record<string, unknown>;
975
- /** The folder the snapshot is served from (`/brand`, an absolute URL). */
976
- baseUrl?: string;
977
- /** Snapshot paths to bundled URLs (`import.meta.glob('./brand/assets/**', { query: '?url', import: 'default', eager: true })`, keyed by `assets/…`). */
978
- assets?: Record<string, string>;
979
- }
980
-
981
- export interface BrandKitSnapshotInfo {
982
- kind: "team" | "template";
983
- kitId?: string;
984
- version?: string;
985
- digest?: string;
986
- }
987
-
988
- export const BRAND_LOCK_SCHEMA: "uhuu.brand-lock.v1";
989
-
990
- /** The kit a snapshot renders: copied files point at the template's copies, the rest at absolute published URLs. */
991
- export function brandKitFromSnapshot(snapshot: BrandKitSnapshot): { brandKit: BrandKitJson; lock: Record<string, unknown>; info: BrandKitSnapshotInfo } | null;
976
+ ): { source: "payload" | "none"; src: string | null; pinned: boolean; presetId?: string };
992
977
 
993
978
  export interface BrandChartPalette {
994
979
  colors: string[];
@@ -1436,6 +1421,8 @@ export interface PageEditorProps {
1436
1421
  /**
1437
1422
  * Development only: the brand-kit switcher in the dev tools menu (dev tools on). It lists
1438
1423
  * `brandKits` and calls back; it does not load a kit: wire the choice to `BrandKitProvider`.
1424
+ * Inside a `BrandKitProvider` on a development host the Brand Kit submenu also offers
1425
+ * *Preview a version…* (`?brand=`), with or without `brandKits`.
1439
1426
  */
1440
1427
  brandKits?: BrandKitOption[];
1441
1428
  /** Development only: the kit the dev switcher marks as active. */
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.6",
2
+ "version": "0.4.7",
3
3
  "name": "uhuu-components",
4
4
  "main": "uhuu-components.umd.cjs",
5
5
  "module": "uhuu-components.es.js",
@@ -15,6 +15,9 @@
15
15
  }
16
16
  },
17
17
  "license": "https://uhuu.io/license",
18
+ "bin": {
19
+ "uhuu-components": "cli.js"
20
+ },
18
21
  "scripts": {
19
22
  "prepublishOnly": "node verify-release.cjs"
20
23
  },
@@ -23,7 +26,8 @@
23
26
  "uhuu-components.es.js.map",
24
27
  "uhuu-components.umd.cjs",
25
28
  "uhuu-components.umd.cjs.map",
26
- "index.d.ts"
29
+ "index.d.ts",
30
+ "cli.js"
27
31
  ],
28
32
  "peerDependencies": {
29
33
  "react": "^18.0.0 || ^19.0.0",