@ikas/bp-storefront 1.4.0-beta.86 → 1.4.0-beta.88
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=new RegExp(["[A-Z]?[a-z]+","[0-9]*(?:1ST|2ND|3RD|(?![123])[0-9]TH)(?=\\b|[a-z_])","[0-9]*(?:1st|2nd|3rd|(?![123])[0-9]th)(?=\\b|[A-Z_])","[A-Z]+(?![a-z])","[0-9]+","[A-Z]"].join("|"),"g");function e(e){return(String(e).match(n)||[]).map(function(n,e){var l=n.toLowerCase();return 0===e?l:l.charAt(0).toUpperCase()+l.slice(1)}).join("")}var l={settings:{},colors:[],typography:[],breakpoints:[],keyframes:[],colorSchemes:{schemes:[],values:[]}},i=function(n){return"var(--".concat(e(n),")")},r=function(n){return"_".concat(n)},o=function(n){return"bp(".concat(n,")")},u=function(n){return n.map(function(n){return{id:n.id,width:Number(n.width)||0}})};function t(n,e){return n&&n.includes("bp(")?e.reduce(function(n,e){return n.split(o(e.id)).join("".concat(e.width,"px"))},n):n}var a=function(n){var e;if(n)return Array.isArray(n)?null===(e=n[0])||void 0===e?void 0:e.value:n},d=function(n){var e,l=n;if(!l)return null;if(l.patternValueId)return i(l.patternValueId);if(l.colorSchemeId)return i(l.colorSchemeId);if(l.keyframeValueId)return r(l.keyframeValueId);var o=l.value;return null==o?null:"object"==typeof o?"string"==typeof o.css?o.css:null!=o.value?"".concat(o.value).concat(null!==(e=o.unit)&&void 0!==e?e:""):null:String(o)},v=/^__.+__$/,s=function(n){return v.test(null!=n?n:"")};function c(n){var o,u,t,v,c,f,m,p,y,h,b,g,S,N,A,I;if(!n)return l;for(var k=null===(o=n.theme)||void 0===o?void 0:o.pattern,V={},w=0,_=null!==(v=null===(t=null===(u=n.globalsBlueprint)||void 0===u?void 0:u.module)||void 0===t?void 0:t.variables)&&void 0!==v?v:[];w<_.length;w++){var D=_[w];if(!1!==D.isGlobal&&D.variableName&&(!s(D.id)&&!s(D.variableName))){var T=null!==(c=D.variableType)&&void 0!==c?c:"TEXT";V[D.variableName]={name:D.variableName,displayName:null!==(f=D.displayName)&&void 0!==f?f:D.variableName,type:T,value:"BOOLEAN"===T?!!D.defaultValue:null!==(m=D.defaultValue)&&void 0!==m?m:null}}}var j=(null!==(p=null==k?void 0:k.values)&&void 0!==p?p:[]).map(function(n){var e,l;return{id:n.id,name:null!==(e=n.name)&&void 0!==e?e:n.id,resolved:d(a(null===(l=n.style)||void 0===l?void 0:l.value)),cssVar:i(n.id)}}),Z=function(n){return(null!=n?n:[]).map(function(n){return{property:n.property,value:d(a(n.value))}}).filter(function(n){return null!=n.value})},x=(null!==(y=null==k?void 0:k.elements)&&void 0!==y?y:[]).map(function(n){for(var l,i={},o=0,u=Z(n.styles);o<u.length;o++){var t=u[o],a=t.property,d=t.value;i[e(a)]=d}return{id:n.id,name:null!==(l=n.name)&&void 0!==l?l:n.id,resolved:i,className:r(n.id)}}),z=(null!==(b=null===(h=n.theme)||void 0===h?void 0:h.breakpoints)&&void 0!==b?b:[]).map(function(n){var e,l;return{id:n.id,name:null!==(e=n.name)&&void 0!==e?e:n.id,width:null!==(l=n.width)&&void 0!==l?l:0}}),B=(null!==(S=null===(g=n.theme)||void 0===g?void 0:g.keyframes)&&void 0!==S?S:[]).map(function(n){var e,l,i;return{id:n.id,name:null!==(e=n.name)&&void 0!==e?e:n.id,type:null!==(l=n.type)&&void 0!==l?l:"keyframe",ref:r(n.id),settings:Z(n.styles),points:(null!==(i=n.points)&&void 0!==i?i:[]).map(function(n){return{point:n.point,styles:Z(n.styles)}})}}),E=(null!==(N=null==k?void 0:k.colorSchemes)&&void 0!==N?N:[]).map(function(n){var e;return{id:n.id,name:null!==(e=n.name)&&void 0!==e?e:n.id}}),C=null!==(A=null==k?void 0:k.colorSchemes)&&void 0!==A?A:[],L=null!==(I=null==k?void 0:k.colorSchemeValues)&&void 0!==I?I:[],O=L.map(function(n){for(var e,l,o,u,t=function(n){var e,l;return null!==(l=null===(e=L.find(function(e){return e.isDefault&&(n?e.designAssetId===n:!e.designAssetId)}))||void 0===e?void 0:e.colors)&&void 0!==l?l:[]}(n.designAssetId),a={},v=function(r){var u=null===(e=n.colors)||void 0===e?void 0:e.find(function(n){return n.colorSchemeId===r.id}),v=u?void 0:t.find(function(n){return n.colorSchemeId===r.id});a[r.id]={resolved:null!==(o=d(null!==(l=null==u?void 0:u.style)&&void 0!==l?l:null==v?void 0:v.style))&&void 0!==o?o:"#ffffff",cssVar:i(r.id)}},s=0,c=C;s<c.length;s++){v(c[s])}return{id:n.id,name:null!==(u=n.name)&&void 0!==u?u:n.id,isDefault:!!n.isDefault,className:r(n.id),colorsByScheme:a}});return{settings:V,colors:j,typography:x,breakpoints:z,keyframes:B,colorSchemes:{schemes:E,values:O}}}export{l as EMPTY_THEME_GLOBALS,o as breakpointCssToken,e as cssVarCamelCase,i as cssVarRef,s as isReservedVariableId,r as rawClassRef,t as resolveBreakpointMediaTokens,c as serializeThemeGlobals,u as toResolverBreakpoints};
|
|
@@ -11,15 +11,12 @@ export declare function cssVarCamelCase(str: string): string;
|
|
|
11
11
|
*/
|
|
12
12
|
/** Global-variable value kinds, mirrored from the editor sidebar `GlobalVariableType`. */
|
|
13
13
|
export type GlobalVariableType = "TEXT" | "RICH_TEXT" | "IMAGE" | "COLOR" | "NUMBER" | "BOOLEAN" | "BORDER" | "SHADOW";
|
|
14
|
-
/**
|
|
15
|
-
* A theme "global variable" (Theme Settings panel). `name` is the stable runtime key.
|
|
16
|
-
* The human-facing `displayName` is intentionally NOT part of this contract — the CC-server AI
|
|
17
|
-
* agent kept referencing display labels instead of stable keys, so labels are dropped from the
|
|
18
|
-
* theme-globals payload entirely (see the design-token types below).
|
|
19
|
-
*/
|
|
14
|
+
/** A theme "global variable" (Theme Settings panel). `name` is the stable runtime key. */
|
|
20
15
|
export type ThemeSetting = {
|
|
21
16
|
/** Stable runtime key — the variable's `variableName` (e.g. `_6Q0KV7VGGM`). */
|
|
22
17
|
name: string;
|
|
18
|
+
/** Human-facing label. */
|
|
19
|
+
displayName: string;
|
|
23
20
|
type: GlobalVariableType;
|
|
24
21
|
/**
|
|
25
22
|
* Concrete value, discriminated by `type`:
|
|
@@ -34,6 +31,7 @@ export type ThemeSetting = {
|
|
|
34
31
|
/** A single-value design token (color). `cssVar` resolves the live, scheme-aware value. */
|
|
35
32
|
export type DesignToken = {
|
|
36
33
|
id: string;
|
|
34
|
+
name: string;
|
|
37
35
|
/** Resolved base/default value (e.g. a hex string), or null when unset. */
|
|
38
36
|
resolved: string | null;
|
|
39
37
|
/** CSS custom-property reference, e.g. `var(--primaryColor)`. */
|
|
@@ -42,6 +40,7 @@ export type DesignToken = {
|
|
|
42
40
|
/** A typography token (text style). Apply `className` to an element to use it. */
|
|
43
41
|
export type TypographyToken = {
|
|
44
42
|
id: string;
|
|
43
|
+
name: string;
|
|
45
44
|
/** Resolved CSS values keyed by camelCased CSS property (e.g. `fontSize`, `fontWeight`). */
|
|
46
45
|
resolved: Record<string, string>;
|
|
47
46
|
/** Class selector the editor emits for this text style, e.g. `_<id>`. */
|
|
@@ -49,6 +48,7 @@ export type TypographyToken = {
|
|
|
49
48
|
};
|
|
50
49
|
export type BreakpointToken = {
|
|
51
50
|
id: string;
|
|
51
|
+
name: string;
|
|
52
52
|
width: number;
|
|
53
53
|
};
|
|
54
54
|
/** A resolved CSS style entry, e.g. { property: "animation-duration", value: "1.4s" }. */
|
|
@@ -58,6 +58,7 @@ export type StyleEntry = {
|
|
|
58
58
|
};
|
|
59
59
|
export type KeyframeToken = {
|
|
60
60
|
id: string;
|
|
61
|
+
name: string;
|
|
61
62
|
type: string;
|
|
62
63
|
/** CSS reference — the animation name / class the editor emits, e.g. `_<id>`. */
|
|
63
64
|
ref: string;
|
|
@@ -75,12 +76,22 @@ export type KeyframeToken = {
|
|
|
75
76
|
styles?: StyleEntry[];
|
|
76
77
|
}[];
|
|
77
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* A color SLOT — one entry of the top-level `getThemeColorSchemes().schemes` list. It is a
|
|
81
|
+
* label only (`id` + display `name`); the actual colors for the slot live in each palette's
|
|
82
|
+
* `colorsByScheme[id]`.
|
|
83
|
+
*/
|
|
84
|
+
export type ColorSchemeSlot = {
|
|
85
|
+
id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
};
|
|
78
88
|
/**
|
|
79
89
|
* A color palette (one entry of `getThemeColorSchemes().values`). Its colors live in
|
|
80
|
-
* `colorsByScheme
|
|
90
|
+
* `colorsByScheme` — the top-level `schemes` list holds only slot id→name labels.
|
|
81
91
|
*/
|
|
82
92
|
export type ColorSchemeToken = {
|
|
83
93
|
id: string;
|
|
94
|
+
name: string;
|
|
84
95
|
isDefault: boolean;
|
|
85
96
|
/** Class selector to activate this scheme value, e.g. `_<id>`. */
|
|
86
97
|
className: string;
|
|
@@ -102,12 +113,40 @@ export type ThemeGlobals = {
|
|
|
102
113
|
breakpoints: BreakpointToken[];
|
|
103
114
|
keyframes: KeyframeToken[];
|
|
104
115
|
colorSchemes: {
|
|
105
|
-
schemes:
|
|
106
|
-
id: string;
|
|
107
|
-
}[];
|
|
116
|
+
schemes: ColorSchemeSlot[];
|
|
108
117
|
values: ColorSchemeToken[];
|
|
109
118
|
};
|
|
110
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* Runtime-facing token views returned by the `@ikas/bp-storefront` getters
|
|
122
|
+
* (`getThemeColors` / `getThemeTypography` / ...). They intentionally OMIT `name`: at runtime
|
|
123
|
+
* a token must be identified by its STABLE `id` (color → `cssVar` / `var(--<id>)`, typography
|
|
124
|
+
* & keyframe → `className`/`ref` `_<id>`, color-scheme slot → a `colorsByScheme` key), NEVER by
|
|
125
|
+
* its human name. Names are non-unique (two design assets can ship the same name) and renaming
|
|
126
|
+
* them must not break references, so reading `.name` at render is an anti-pattern — hiding it
|
|
127
|
+
* from the return type turns that into a compile error.
|
|
128
|
+
*
|
|
129
|
+
* The full types above (with `name`) are still produced in the serialized {@link ThemeGlobals}
|
|
130
|
+
* payload and surfaced by the CLI/MCP `list-theme-globals` AUTHORING read, so the agent/editor
|
|
131
|
+
* can still discover and reuse existing tokens by name. `name` is hidden ONLY from the runtime
|
|
132
|
+
* getter return types.
|
|
133
|
+
*/
|
|
134
|
+
export type RuntimeDesignToken = Omit<DesignToken, "name">;
|
|
135
|
+
export type RuntimeTypographyToken = Omit<TypographyToken, "name">;
|
|
136
|
+
export type RuntimeBreakpointToken = Omit<BreakpointToken, "name">;
|
|
137
|
+
export type RuntimeKeyframeToken = Omit<KeyframeToken, "name">;
|
|
138
|
+
export type RuntimeColorSchemeToken = Omit<ColorSchemeToken, "name">;
|
|
139
|
+
export type RuntimeColorSchemeSlot = Omit<ColorSchemeSlot, "name">;
|
|
140
|
+
/**
|
|
141
|
+
* Runtime view of {@link ThemeGlobals.colorSchemes} (returned by `getThemeColorSchemes`). The
|
|
142
|
+
* slot list carries only `{ id }`: slot display LABELS (the slot `name`) are authoring-only —
|
|
143
|
+
* read them via the CLI/MCP `list-theme-globals` or the editor, not at runtime. Render a palette
|
|
144
|
+
* by iterating each value's `colorsByScheme`, keyed by slot id.
|
|
145
|
+
*/
|
|
146
|
+
export type RuntimeThemeColorSchemes = {
|
|
147
|
+
schemes: RuntimeColorSchemeSlot[];
|
|
148
|
+
values: RuntimeColorSchemeToken[];
|
|
149
|
+
};
|
|
111
150
|
export declare const EMPTY_THEME_GLOBALS: ThemeGlobals;
|
|
112
151
|
type StyleValueLike = {
|
|
113
152
|
value?: any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RuntimeBreakpointToken, RuntimeDesignToken, RuntimeKeyframeToken, RuntimeThemeColorSchemes, RuntimeTypographyToken, ThemeSetting } from "../../storefront-config/src";
|
|
2
2
|
/**
|
|
3
3
|
* Register the live global-variable object (`_g_`) so `getThemeSetting`/`getThemeSettings`
|
|
4
4
|
* return actual runtime values (constants, computed getters, and in-editor edits) instead
|
|
@@ -9,7 +9,7 @@ export declare function registerThemeSettingValues(values: Record<string, any> |
|
|
|
9
9
|
export declare function getThemeSettings(): ThemeSetting[];
|
|
10
10
|
/**
|
|
11
11
|
* A single global variable by its stable key (`variableName`, e.g. `_6Q0KV7VGGM`).
|
|
12
|
-
* Discover keys via {@link getThemeSettings}.
|
|
12
|
+
* Discover keys via {@link getThemeSettings} (each item carries a human `displayName`).
|
|
13
13
|
* The returned `value` is the live blueprint value when available, else the default.
|
|
14
14
|
* Its shape is discriminated by `type` (see {@link ThemeSetting.value}); note an
|
|
15
15
|
* IMAGE setting's value is an image REFERENCE (no `.url`) — resolve with
|
|
@@ -19,33 +19,30 @@ export declare function getThemeSetting(name: string): ThemeSetting | undefined;
|
|
|
19
19
|
/** Convenience: the resolved value of a global variable, or `undefined` if not found. */
|
|
20
20
|
export declare function getThemeSettingValue(name: string): any;
|
|
21
21
|
/** Theme color tokens. Each carries a resolved value and a `var(--id)` CSS reference. */
|
|
22
|
-
export declare function getThemeColors():
|
|
22
|
+
export declare function getThemeColors(): RuntimeDesignToken[];
|
|
23
23
|
/** Theme typography tokens (text styles). Apply `className` or read `resolved` CSS values. */
|
|
24
|
-
export declare function getThemeTypography():
|
|
24
|
+
export declare function getThemeTypography(): RuntimeTypographyToken[];
|
|
25
25
|
/** Theme responsive breakpoints (`{ id, width }`). */
|
|
26
|
-
export declare function getThemeBreakpoints():
|
|
26
|
+
export declare function getThemeBreakpoints(): RuntimeBreakpointToken[];
|
|
27
27
|
/** Theme keyframe/transition animations. Use `ref` as the CSS animation name. */
|
|
28
|
-
export declare function getThemeKeyframes():
|
|
28
|
+
export declare function getThemeKeyframes(): RuntimeKeyframeToken[];
|
|
29
29
|
/**
|
|
30
30
|
* Theme color schemes (palettes). Returns two PARALLEL lists with different jobs:
|
|
31
|
-
* - `schemes`: the color SLOTS as `{ id }` only — no colors and no display
|
|
32
|
-
*
|
|
31
|
+
* - `schemes`: the color SLOTS as `{ id }` only — no colors and no display label live here at
|
|
32
|
+
* runtime. A slot's human name is authoring-only (read it via the CLI/MCP `list-theme-globals`
|
|
33
|
+
* or the editor); at runtime identify a slot solely by its `id`.
|
|
33
34
|
* - `values`: the actual palettes. A palette's colors live in its `colorsByScheme`
|
|
34
35
|
* map, keyed by slot id → `{ resolved, cssVar }`.
|
|
35
36
|
*
|
|
36
|
-
* To render swatches, iterate `values[].colorsByScheme` (the source of truth for
|
|
37
|
-
* top-level `schemes` array — `schemes` carries slot ids only, so
|
|
37
|
+
* To render swatches, iterate `values[].colorsByScheme` (the source of truth for
|
|
38
|
+
* colors), NOT the top-level `schemes` array — `schemes` carries slot ids only, so
|
|
39
|
+
* iterating it renders empty:
|
|
38
40
|
*
|
|
39
41
|
* const { values } = getThemeColorSchemes();
|
|
40
42
|
* values.forEach(palette =>
|
|
41
43
|
* Object.entries(palette.colorsByScheme).forEach(([slotId, { resolved, cssVar }]) => {
|
|
42
|
-
* // slotId →
|
|
44
|
+
* // slotId → stable slot key, cssVar → live var() ref (prefer this), resolved → hex snapshot
|
|
43
45
|
* })
|
|
44
46
|
* );
|
|
45
47
|
*/
|
|
46
|
-
export declare function getThemeColorSchemes():
|
|
47
|
-
schemes: {
|
|
48
|
-
id: string;
|
|
49
|
-
}[];
|
|
50
|
-
values: ColorSchemeToken[];
|
|
51
|
-
};
|
|
48
|
+
export declare function getThemeColorSchemes(): RuntimeThemeColorSchemes;
|