@webority/tokens 0.153.0 → 0.154.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/dist/brand.js +2 -2
- package/dist/build.d.ts +5 -0
- package/dist/build.js +6 -4
- package/dist/canvas/webority-phone.json +2 -5
- package/dist/canvas/webority-web-390.json +4 -5
- package/dist/canvas/webority-web.json +4 -5
- package/dist/emit/web.js +2 -2
- package/dist/meanings.json +171 -554
- package/dist/source/meaning.tokens.json +9 -0
- package/dist/source/mode.dark.tokens.json +3 -0
- package/package.json +2 -2
- package/renames/0.108.0.json +1 -1
package/dist/brand.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{EMAIL_COLOR_ROLES as e,EMAIL_PADDING_PATTERN as t,EMAIL_PADDING_ROLES as n,EMAIL_SHAPE as r,EMAIL_SPACE as i,EMAIL_TYPE_ROLES as a}from"./emit/email.js";import{messageOf as o}from"./guards.js";import{RAMP_STEPS as s,deriveRamp as c}from"./ramp.js";import{readFileSync as l}from"node:fs";var u=Object.freeze({css:`brand.css`,bootstrap:`_brand-variables.scss`,web:`webority-web.json`,web390:`webority-web-390.json`,phoneTheme:`webority-phone.json`,phone:`brand.phone.js`,email:`email.json`}),d=`generated`,f=/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g,p=[`palette`,`color`,`effect`,`font`,`radius`],m=[`space`,`text`,`shadow`,`section`,`component`,`email`],h=[`radius`,`padding`],g=[`size`,`lineHeight`,`phoneSize`,`phoneLineHeight`],_=[`narrowSize`,`narrowLineHeight`],v=/^(#[0-9a-fA-F]{6}|\{color\.[a-z0-9-]+\})$/;function y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b(e){return y(e)?e:{}}function x(e){return y(e)&&Object.hasOwn(e,`$value`)}function S(e,t){let n=[],r=(e,t)=>{for(let i of Object.keys(e)){if(i.startsWith(`$`))continue;let a=e[i],o=`${t}.${i}`;x(a)?n.push({path:o,node:a}):y(a)&&r(a,o)}};return r(e,t),n}function C(e,t){let n=e;for(let e of t.split(`.`)){if(!y(n)||!Object.hasOwn(n,e))return!1;n=n[e]}return x(n)}function w(e){let t=y(e)?e.$extensions:void 0,n=y(t)?t[`com.webority`]:void 0;return y(n)?n:{}}function T(e){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)&&!/^[0-9]+$/.test(e)}function E(e){return typeof e==`string`&&v.test(e)}function D(e){return y(e)&&typeof e.value==`number`&&Number.isInteger(e.value)&&e.value>=0&&e.unit===`px`}function O(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function k(e,t){return e===`space`?n.has(t):e===`button`&&t===`padding`}function A(e,n,r,i,a){let o=w(r);for(let t of Object.keys(o))(e!==`color`||t!==`dark`)&&a(i,`$extensions.com.webority.${t} is not allowed on this token`,`Remove it`);if(e===`color`)E(r.$value)||a(i,`$value is not a colour`,`Write "#RRGGBB" or a reference such as "{color.primary}"`),Object.hasOwn(o,`dark`)&&!E(o.dark)&&a(i,`$extensions.com.webority.dark is not a colour`,`Write "#RRGGBB" or a reference such as "{color.primary}"`);else if(e===`type`){let e=r.$value,t=y(e)?Object.keys(e):[],n=t.includes(`narrowSize`)||t.includes(`narrowLineHeight`)?[...g,..._]:g;y(e)&&t.length===n.length&&n.every(t=>O(e[t]))||a(i,`$value is not { size, lineHeight, phoneSize, phoneLineHeight } (optionally narrowSize, narrowLineHeight) in whole px`,`Write it as { "size": 16, "lineHeight": 24, "phoneSize": 15, "phoneLineHeight": 22 }`)}else k(e,n)?typeof r.$value==`string`&&t.test(r.$value)||a(i,`$value is not CSS px padding`,`Write it as "22px 24px", one to four px values or 0`):D(r.$value)||a(i,`$value is not { value, unit }`,`Write it as { "value": 12, "unit": "px" }`)}function j(e){return y(e)&&[`color`,`type`,`space`,`shape`,`button`].every(t=>e[t]===void 0||y(e[t]))}function M(t,n){let o=new Map([[`color`,Object.keys(e)],[`type`,Object.keys(a)],[`space`,Object.keys(i)],[`shape`,Object.keys(r)],[`button`,h]]);for(let e of Object.keys(t)){if(e.startsWith(`$`))continue;let r=o.get(e);if(r===void 0){n(`email.${e}`,`is not an email group`,`Use one of ${[...o.keys()].join(`, `)}`);continue}let i=t[e];if(!y(i))n(`email.${e}`,`is not a group`,`Write it as an object of tokens`);else for(let t of Object.keys(i)){if(t.startsWith(`$`))continue;let a=`email.${e}.${t}`;if(!r.includes(t)){n(a,`is not an email role`,`Use one of ${r.join(`, `)}`);continue}let o=i[t];x(o)?A(e,t,o,a,n):n(a,`is not a token`,`Give it a $value`)}}}function N(e,t,n){let r;try{r=JSON.parse(l(e,`utf8`))}catch(t){throw Error(`${e}: (file): cannot be read as JSON (${o(t)}). Restore the file or fix the JSON`)}if(!y(r))throw Error(`${e}: (file): is not a JSON object. Write the brand as one object with the groups palette, color, effect, font and radius`);let i=[],a=(t,n,r)=>{let a=`${e}: ${t}: ${n}. ${r}`;i.includes(a)||i.push(a)},u=w(r);for(let e of Object.keys(u))e!==`brand`&&e!==`deviation`&&a(`$extensions.com.webority.${e}`,`is not a brand file key`,`Remove it`);let d=Object.hasOwn(u,`deviation`),h=typeof u.deviation==`string`?u.deviation:void 0,g=d&&h!==void 0&&Object.hasOwn(n,h);d&&!g&&a(`$extensions.com.webority.deviation`,`${u.deviation} is not in deviations.json`,`Use one of: ${Object.keys(n).join(`, `)}`);let _=typeof u.brand==`string`?u.brand:``;/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(_)||a(`$extensions.com.webority.brand`,`is missing or not kebab case`,`Name the product in kebab case, such as acme`);let v=h===void 0?void 0:n[h],E=g&&v!==void 0?v.groups:[],D={},O=null;for(let e of Object.keys(r)){if(e.startsWith(`$`))continue;if(!p.includes(e)&&!m.includes(e)){a(e,`is not a brand group`,`A brand file holds only palette, color, effect, font and radius, plus the groups a recorded deviation allows`);continue}if(m.includes(e)&&!E.includes(e)){a(e,`this group needs a recorded deviation`,`Add $extensions.com.webority.deviation naming an entry of deviations.json, or remove the group`);continue}let t=r[e];y(t)?e===`email`?O=t:D[e]=t:a(e,`is not a group`,`Write it as an object of tokens`)}for(let[e,t]of Object.entries(D))for(let{path:n,node:r}of S(t,e)){let t=w(r);for(let r of Object.keys(t))r!==`platforms`&&r!==`dark`&&(r!==`faces`||e!==`font`)&&a(n,`$extensions.com.webority.${r} is not allowed on a token`,`Remove it`);if(Object.hasOwn(t,`platforms`)){let e=t.platforms;Array.isArray(e)&&e.length>0&&e.every(e=>e===`web`||e===`phone`)||a(n,`$extensions.com.webority.platforms is not a list of web and phone`,`Write it as ["phone"], ["web"] or both`)}Object.hasOwn(t,`dark`)&&e!==`color`&&e!==`effect`&&a(n,`$extensions.com.webority.dark applies to colour and effect tokens only`,`Remove it`)}for(let{path:e,node:t}of S(D.palette??{},`palette`))e.split(`.`).slice(1).every(T)||a(e,`the step name is not kebab case`,`Name it such as primary-500`),typeof t.$value!=`string`&&a(e,`$value is not a string`,`Write the colour as text such as "#0F766E" or a reference such as "{palette.primary}"`);let k=(e,n,r)=>{let i=`${e}.${n}`,o=w(r),s=C(t.meaning,i);typeof r.$value!=`string`&&a(i,`$value is not a string`,e===`color`?`Write a colour or a reference such as "{palette.primary}"`:`Write the effect as text such as a filter, colour or gradient`),s?C(t.modeDark,i)&&typeof o.dark!=`string`&&a(i,`needs $extensions.com.webority.dark because the meaning has a dark value`,`Add the dark value beside the light one`):(T(n)||a(i,`the name is not kebab case`,`Name it in kebab case`),(typeof r.$description!=`string`||r.$description===``)&&a(i,`is not a fleet meaning and has no $description`,`Add a $description saying what the colour is for, or use a meaning the library defines`)),Object.hasOwn(o,`dark`)&&typeof o.dark!=`string`&&a(i,`$extensions.com.webority.dark is not a string`,`Write a colour or a reference`)};for(let e of[`color`,`effect`]){let t=D[e]??{};for(let n of Object.keys(t)){if(n.startsWith(`$`))continue;let r=t[n];x(r)?k(e,n,r):a(`${e}.${n}`,`is not a token`,`Give it a $value`)}}let A=b(t.scale.font),N=Object.keys(A).filter(e=>x(A[e]));for(let{path:e,node:n}of S(D.font??{},`font`)){C(t.scale,e)||a(e,`is not a fleet font`,`Use one of ${N.join(`, `)}`);let r=n.$value;if(Array.isArray(r)&&r.length!==0&&r.every(e=>typeof e==`string`)||a(e,`$value is not a list of font family names`,`Write it as ["Webority Sans", "system-ui", "sans-serif"]`),Object.hasOwn(w(n),`faces`)){let t=w(n).faces,r=[`normal`,`medium`,`semibold`,`bold`];y(t)&&Object.keys(t).length>0&&Object.keys(t).every(e=>r.includes(e))&&Object.values(t).every(e=>typeof e==`string`&&e!==``)||a(e,`faces is not a map of weight to font file name`,`Write it as { "normal": "AcmeSans-Regular", "semibold": "AcmeSans-SemiBold" }`)}}let P=b(t.scale.radius),
|
|
2
|
-
`));let
|
|
1
|
+
import{EMAIL_COLOR_ROLES as e,EMAIL_PADDING_PATTERN as t,EMAIL_PADDING_ROLES as n,EMAIL_SHAPE as r,EMAIL_SPACE as i,EMAIL_TYPE_ROLES as a}from"./emit/email.js";import{messageOf as o}from"./guards.js";import{RAMP_STEPS as s,deriveRamp as c}from"./ramp.js";import{readFileSync as l}from"node:fs";var u=Object.freeze({css:`brand.css`,bootstrap:`_brand-variables.scss`,web:`webority-web.json`,web390:`webority-web-390.json`,phoneTheme:`webority-phone.json`,phone:`brand.phone.js`,email:`email.json`}),d=`generated`,f=/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g,p=[`palette`,`color`,`effect`,`font`,`radius`],m=[`space`,`text`,`shadow`,`section`,`component`,`email`],h=[`radius`,`padding`],g=[`size`,`lineHeight`,`phoneSize`,`phoneLineHeight`],_=[`narrowSize`,`narrowLineHeight`],v=/^(#[0-9a-fA-F]{6}|\{color\.[a-z0-9-]+\})$/;function y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b(e){return y(e)?e:{}}function x(e){return y(e)&&Object.hasOwn(e,`$value`)}function S(e,t){let n=[],r=(e,t)=>{for(let i of Object.keys(e)){if(i.startsWith(`$`))continue;let a=e[i],o=`${t}.${i}`;x(a)?n.push({path:o,node:a}):y(a)&&r(a,o)}};return r(e,t),n}function C(e,t){let n=e;for(let e of t.split(`.`)){if(!y(n)||!Object.hasOwn(n,e))return!1;n=n[e]}return x(n)}function w(e){let t=y(e)?e.$extensions:void 0,n=y(t)?t[`com.webority`]:void 0;return y(n)?n:{}}function T(e){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)&&!/^[0-9]+$/.test(e)}function E(e){return typeof e==`string`&&v.test(e)}function D(e){return y(e)&&typeof e.value==`number`&&Number.isInteger(e.value)&&e.value>=0&&e.unit===`px`}function O(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function k(e,t){return e===`space`?n.has(t):e===`button`&&t===`padding`}function A(e,n,r,i,a){let o=w(r);for(let t of Object.keys(o))(e!==`color`||t!==`dark`)&&a(i,`$extensions.com.webority.${t} is not allowed on this token`,`Remove it`);if(e===`color`)E(r.$value)||a(i,`$value is not a colour`,`Write "#RRGGBB" or a reference such as "{color.primary}"`),Object.hasOwn(o,`dark`)&&!E(o.dark)&&a(i,`$extensions.com.webority.dark is not a colour`,`Write "#RRGGBB" or a reference such as "{color.primary}"`);else if(e===`type`){let e=r.$value,t=y(e)?Object.keys(e):[],n=t.includes(`narrowSize`)||t.includes(`narrowLineHeight`)?[...g,..._]:g;y(e)&&t.length===n.length&&n.every(t=>O(e[t]))||a(i,`$value is not { size, lineHeight, phoneSize, phoneLineHeight } (optionally narrowSize, narrowLineHeight) in whole px`,`Write it as { "size": 16, "lineHeight": 24, "phoneSize": 15, "phoneLineHeight": 22 }`)}else k(e,n)?typeof r.$value==`string`&&t.test(r.$value)||a(i,`$value is not CSS px padding`,`Write it as "22px 24px", one to four px values or 0`):D(r.$value)||a(i,`$value is not { value, unit }`,`Write it as { "value": 12, "unit": "px" }`)}function j(e){return y(e)&&[`color`,`type`,`space`,`shape`,`button`].every(t=>e[t]===void 0||y(e[t]))}function M(t,n){let o=new Map([[`color`,Object.keys(e)],[`type`,Object.keys(a)],[`space`,Object.keys(i)],[`shape`,Object.keys(r)],[`button`,h]]);for(let e of Object.keys(t)){if(e.startsWith(`$`))continue;let r=o.get(e);if(r===void 0){n(`email.${e}`,`is not an email group`,`Use one of ${[...o.keys()].join(`, `)}`);continue}let i=t[e];if(!y(i))n(`email.${e}`,`is not a group`,`Write it as an object of tokens`);else for(let t of Object.keys(i)){if(t.startsWith(`$`))continue;let a=`email.${e}.${t}`;if(!r.includes(t)){n(a,`is not an email role`,`Use one of ${r.join(`, `)}`);continue}let o=i[t];x(o)?A(e,t,o,a,n):n(a,`is not a token`,`Give it a $value`)}}}function N(e,t,n){let r;try{r=JSON.parse(l(e,`utf8`))}catch(t){throw Error(`${e}: (file): cannot be read as JSON (${o(t)}). Restore the file or fix the JSON`)}if(!y(r))throw Error(`${e}: (file): is not a JSON object. Write the brand as one object with the groups palette, color, effect, font and radius`);let i=[],a=(t,n,r)=>{let a=`${e}: ${t}: ${n}. ${r}`;i.includes(a)||i.push(a)},u=w(r);for(let e of Object.keys(u))e!==`brand`&&e!==`deviation`&&a(`$extensions.com.webority.${e}`,`is not a brand file key`,`Remove it`);let d=Object.hasOwn(u,`deviation`),h=typeof u.deviation==`string`?u.deviation:void 0,g=d&&h!==void 0&&Object.hasOwn(n,h);d&&!g&&a(`$extensions.com.webority.deviation`,`${u.deviation} is not in deviations.json`,`Use one of: ${Object.keys(n).join(`, `)}`);let _=typeof u.brand==`string`?u.brand:``;/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(_)||a(`$extensions.com.webority.brand`,`is missing or not kebab case`,`Name the product in kebab case, such as acme`);let v=h===void 0?void 0:n[h],E=g&&v!==void 0?v.groups:[],D={},O=null;for(let e of Object.keys(r)){if(e.startsWith(`$`))continue;if(!p.includes(e)&&!m.includes(e)){a(e,`is not a brand group`,`A brand file holds only palette, color, effect, font and radius, plus the groups a recorded deviation allows`);continue}if(m.includes(e)&&!E.includes(e)){a(e,`this group needs a recorded deviation`,`Add $extensions.com.webority.deviation naming an entry of deviations.json, or remove the group`);continue}let t=r[e];y(t)?e===`email`?O=t:D[e]=t:a(e,`is not a group`,`Write it as an object of tokens`)}for(let[e,t]of Object.entries(D))for(let{path:n,node:r}of S(t,e)){let t=w(r);for(let r of Object.keys(t))r!==`platforms`&&r!==`dark`&&(r!==`faces`||e!==`font`)&&a(n,`$extensions.com.webority.${r} is not allowed on a token`,`Remove it`);if(Object.hasOwn(t,`platforms`)){let e=t.platforms;Array.isArray(e)&&e.length>0&&e.every(e=>e===`web`||e===`phone`)||a(n,`$extensions.com.webority.platforms is not a list of web and phone`,`Write it as ["phone"], ["web"] or both`)}Object.hasOwn(t,`dark`)&&e!==`color`&&e!==`effect`&&a(n,`$extensions.com.webority.dark applies to colour and effect tokens only`,`Remove it`)}for(let{path:e,node:t}of S(D.palette??{},`palette`))e.split(`.`).slice(1).every(T)||a(e,`the step name is not kebab case`,`Name it such as primary-500`),typeof t.$value!=`string`&&a(e,`$value is not a string`,`Write the colour as text such as "#0F766E" or a reference such as "{palette.primary}"`);let k=(e,n,r)=>{let i=`${e}.${n}`,o=w(r),s=C(t.meaning,i);typeof r.$value!=`string`&&a(i,`$value is not a string`,e===`color`?`Write a colour or a reference such as "{palette.primary}"`:`Write the effect as text such as a filter, colour or gradient`),s?C(t.modeDark,i)&&typeof o.dark!=`string`&&a(i,`needs $extensions.com.webority.dark because the meaning has a dark value`,`Add the dark value beside the light one`):(T(n)||a(i,`the name is not kebab case`,`Name it in kebab case`),(typeof r.$description!=`string`||r.$description===``)&&a(i,`is not a fleet meaning and has no $description`,`Add a $description saying what the colour is for, or use a meaning the library defines`)),Object.hasOwn(o,`dark`)&&typeof o.dark!=`string`&&a(i,`$extensions.com.webority.dark is not a string`,`Write a colour or a reference`)};for(let e of[`color`,`effect`]){let t=D[e]??{};for(let n of Object.keys(t)){if(n.startsWith(`$`))continue;let r=t[n];x(r)?k(e,n,r):a(`${e}.${n}`,`is not a token`,`Give it a $value`)}}let A=b(t.scale.font),N=Object.keys(A).filter(e=>x(A[e]));for(let{path:e,node:n}of S(D.font??{},`font`)){C(t.scale,e)||a(e,`is not a fleet font`,`Use one of ${N.join(`, `)}`);let r=n.$value;if(Array.isArray(r)&&r.length!==0&&r.every(e=>typeof e==`string`)||a(e,`$value is not a list of font family names`,`Write it as ["Webority Sans", "system-ui", "sans-serif"]`),Object.hasOwn(w(n),`faces`)){let t=w(n).faces,r=[`normal`,`medium`,`semibold`,`bold`];y(t)&&Object.keys(t).length>0&&Object.keys(t).every(e=>r.includes(e))&&Object.values(t).every(e=>typeof e==`string`&&e!==``)||a(e,`faces is not a map of weight to font file name`,`Write it as { "normal": "AcmeSans-Regular", "semibold": "AcmeSans-SemiBold" }`)}}let P=b(t.scale.radius),I=Object.keys(P).filter(e=>x(P[e]));for(let{path:e,node:n}of S(D.radius??{},`radius`)){C(t.scale,e)||a(e,`is not on the radius scale`,`Use one of ${I.join(`, `)}`);let r=n.$value,i=y(r)&&typeof r.value==`number`&&Number.isFinite(r.value)&&r.value>=0,o=y(r)?r.unit:void 0;i&&o===`px`||a(e,`$value is not { value, unit }`,`Write it as { "value": 12, "unit": "px" }`)}O!==null&&M(O,a);let L=structuredClone(r);delete L.$extensions,delete L.$description,delete L.email;for(let e of[`color`,`effect`])for(let{node:t}of S(b(L[e]),e))Object.hasOwn(w(t),`dark`)&&(delete w(t).dark,y(t.$extensions)&&(Object.keys(w(t)).length===0&&delete t.$extensions[`com.webority`],Object.keys(t.$extensions).length===0&&delete t.$extensions));let R=D.palette?.primary,z=x(R)?R.$value:void 0;if(typeof z==`string`&&/^#[0-9a-fA-F]{6}$/.test(z)){let e=c(z),t=L.palette;if(!y(t))throw Error(`webority-tokens: the palette group is missing.`);for(let n of s)C(L,`palette.${n}`)||(t[n]={$type:`color`,$value:e[n]})}let B=e=>C(L,e)||C(t.palette,e)||C(t.scale,e)||C(t.meaning,e);for(let e of Object.keys(D))for(let{path:t,node:n}of S(D[e]??{},e)){let e=[n.$value,w(n).dark].filter(e=>typeof e==`string`);for(let n of e)for(let e of n.matchAll(f)){let[,n=``]=e;B(n)||a(t,`references {${n}}, which no palette step, meaning, scale step or brand token defines`,`Name an existing token or add it to the brand file`)}}if(i.length>0)throw Error(i.join(`
|
|
2
|
+
`));let V={};for(let e of[`color`,`effect`])for(let{path:t,node:n}of S(D[e]??{},e)){let r=w(n).dark;if(typeof r!=`string`)continue;let i=t.slice(e.length+1),a=V[e];a===void 0&&(a={},V[e]=a),a[i]=n.$type===void 0?{$value:r}:{$value:r,$type:n.$type}}if(O!==null&&!j(O))throw Error(`${e}: email: is not an email group. Write it as an object of email role groups.`);return F(L),F(V),{name:_,base:L,dark:V,email:O}}var P=/#[0-9a-fA-F]{3,8}\b/g;function F(e){let t=e=>{if(typeof e==`string`)return e.replace(P,e=>e.toLowerCase());if(Array.isArray(e))return e.map(t);if(y(e))for(let n of Object.keys(e))e[n]=t(e[n]??null);return e};t(e)}export{u as BRAND_OUTPUT_FILES,d as HEAD_FOLDER,N as loadBrand};
|
package/dist/build.d.ts
CHANGED
|
@@ -39,3 +39,8 @@ export interface DesignMap {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
export declare function brand(options: BrandOptions): Promise<BrandResult>;
|
|
42
|
+
/**
|
|
43
|
+
* JSON in the layout the shared Biome preset formats to (4 spaces, line width 140), so a consumer's
|
|
44
|
+
* check passes on the generated files: an object always expanded, an array on one line when it fits.
|
|
45
|
+
*/
|
|
46
|
+
export declare function render(value: unknown): string;
|
package/dist/build.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import{__toESM as e}from"./_virtual/_rolldown/runtime.js";import{require__2020 as t}from"./node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js";import{BRAND_OUTPUT_FILES as n,HEAD_FOLDER as r,loadBrand as i}from"./brand.js";import a from"./canvas-renames.js";import o from"./deviations.js";import{emitCanvas as s}from"./emit/canvas.js";import{emitEmail as c}from"./emit/email.js";import{emitMeanings as l}from"./emit/meanings.js";import{emitPhoneBrand as u,emitPhoneTheme as d,phoneSets as f}from"./emit/phone.js";import{emitWeb as p}from"./emit/web.js";import{messageOf as m}from"./guards.js";import{phonePairLayer as h}from"./model/contrast.js";import{loadModel as g}from"./model/index.js";import{mkdir as _,readFile as v,writeFile as y}from"node:fs/promises";import b from"node:path";var x=e(t(),1),S=new URL(`../schema/design-map.schema.json`,import.meta.url),C=new URL(`../package.json`,import.meta.url),w={palette:`palette.tokens.json`,scale:`scale.tokens.json`,meaning:`meaning.tokens.json`,modeDark:`mode.dark.tokens.json`},T=/^.+: \S+: .+\. .+$/;async function E(e){let t=b.resolve(e.root??process.cwd()),r=e.check===!0,{version:w}=JSON.parse(await v(C,`utf8`)),E=[],
|
|
2
|
-
`));if(
|
|
3
|
-
`));let H=await
|
|
1
|
+
import{__toESM as e}from"./_virtual/_rolldown/runtime.js";import{require__2020 as t}from"./node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js";import{BRAND_OUTPUT_FILES as n,HEAD_FOLDER as r,loadBrand as i}from"./brand.js";import a from"./canvas-renames.js";import o from"./deviations.js";import{emitCanvas as s}from"./emit/canvas.js";import{emitEmail as c}from"./emit/email.js";import{emitMeanings as l}from"./emit/meanings.js";import{emitPhoneBrand as u,emitPhoneTheme as d,phoneSets as f}from"./emit/phone.js";import{emitWeb as p}from"./emit/web.js";import{messageOf as m}from"./guards.js";import{phonePairLayer as h}from"./model/contrast.js";import{loadModel as g}from"./model/index.js";import{mkdir as _,readFile as v,writeFile as y}from"node:fs/promises";import b from"node:path";var x=e(t(),1),S=new URL(`../schema/design-map.schema.json`,import.meta.url),C=new URL(`../package.json`,import.meta.url),w={palette:`palette.tokens.json`,scale:`scale.tokens.json`,meaning:`meaning.tokens.json`,modeDark:`mode.dark.tokens.json`},T=/^.+: \S+: .+\. .+$/;async function E(e){let t=b.resolve(e.root??process.cwd()),r=e.check===!0,{version:w}=JSON.parse(await v(C,`utf8`)),E=[],D=[],O=async(e,t)=>{if(r){let n=null;try{n=await v(e,`utf8`)}catch(e){if(M(e)!==`ENOENT`)throw e}n!==t&&D.push(e)}else await _(b.dirname(e),{recursive:!0}),await y(e,t,`utf8`),E.push(e)};if(e.library===!0){if(e.brand!==void 0)throw Error(`brand: --brand: not allowed with --library. Remove it.`);if(!e.out)throw Error(`brand: --out: required with --library. Pass --out <dir>.`);let r=b.resolve(t,e.out),i=await g(),o=s(i),c=[[b.join(r,`canvas`,n.web),k(o.web)],[b.join(r,`canvas`,n.web390),k(o.web390)],[b.join(r,`canvas`,n.phoneTheme),k(o.phone)],[b.join(r,`meanings.json`),k(l(i))],[b.join(r,`canvas`,`renames.json`),k(a)]];if(e.web){let n=p(i),r=b.resolve(t,e.web);c.push([r,n.tokens]),c.push([b.join(b.dirname(r),`_bootstrap.generated.scss`),n.bootstrap])}if(e.phone){let n={light:f(i,`light`),dark:f(i,`dark`)},r=d(n);c.push([b.resolve(t,e.phone),r.contents])}for(let[e,t]of c)await O(e,t);return{written:E,stale:D}}let A=b.join(t,`.webority`,`design.json`),j;try{j=await v(A,`utf8`)}catch(e){throw M(e)===`ENOENT`?Error(`${A}: file missing. Run from the repo root or create the design map.`):e}let F;try{F=JSON.parse(j)}catch(e){throw Error(`${A}: /: ${m(e)}. Fix the design map.`)}let I=JSON.parse(await v(S,`utf8`)),R=new x.Ajv2020({allErrors:!0,strict:!1}).compile(I);if(!R(F))throw Error((R.errors??[]).map(e=>`${A}: ${e.instancePath||`/`}: ${e.message}. Fix the design map.`).join(`
|
|
2
|
+
`));if(F.tokens===void 0)throw Error(`${A}: /tokens: missing. Add tokens.brands to .webority/design.json.`);let z=F.tokens.brands,B=F.tokens.heads??[];if((e.brand!==void 0||e.out!==void 0)&&z.length>1)throw Error(`brand: --brand/--out: the repo has ${z.length} brands. Remove the flag to build every brand.`);let V=[];if(z.forEach((e,t)=>{e.source===`library`&&V.push(`${A}: tokens.brands[${t}].source: "library" is built with --library. Run webority brand --library --out <dir>.`)}),B.forEach((e,t)=>{z.some(t=>t.name===e.brand)||V.push(`${A}: tokens.heads[${t}].brand: no brand named ${e.brand}. Add it to tokens.brands.`)}),V.length>0)throw Error(V.join(`
|
|
3
|
+
`));let H=await P(),U=await g(),W={light:f(U,`light`),dark:f(U,`dark`)},G=L(o),K=[];for(let r of z){let a=z.length===1&&e.brand!==void 0?e.brand:r.source,o=z.length===1&&e.out!==void 0?e.out:r.export,l=b.resolve(t,a);try{let e=i(l,H,G),a=await g({brand:e}),d=h(a,U),m=Object.keys(d.light).length+Object.keys(d.dark).length>0?await g({brand:{...e,phone:d}}):a,_=s(m),v=p(m,{library:U}),y={light:f(m,`light`),dark:f(m,`dark`)},x=u(W,y,{package:`@webority/tokens`,version:w,brand:e.name}),S=k(c(_.web,_.web390,e.email)),C={css:v.css,phone:x.contents,email:S},T=b.resolve(t,o),E=[[b.join(T,n.css),v.css],[b.join(T,n.bootstrap),v.variables],[b.join(T,n.web),k(_.web)],[b.join(T,n.web390),k(_.web390)],[b.join(T,n.phoneTheme),k(_.phone)],[b.join(T,n.phone),x.contents],[b.join(T,n.email),S]];K.push(...E);for(let e of B)e.brand===r.name&&K.push(N(t,e,C))}catch(e){for(let t of m(e).split(`
|
|
4
4
|
`))t.length!==0&&V.push(T.test(t)?t:`${l}: -: ${t}. Fix the source.`)}}if(V.length>0)throw Error(V.join(`
|
|
5
|
-
`));for(let[e,t]of K)await
|
|
5
|
+
`));for(let[e,t]of K)await O(e,t);return{written:E,stale:D}}var D=` `,O=140;function k(e){return`${A(e,``,0,!1)}\n`}function A(e,t,n,r){if(Array.isArray(e)){if(e.length===0)return`[]`;let i=j(e);if(i!==null&&n+i.length+ +!!r<=O)return i;let a=t+D;return`[\n${e.map((t,n)=>a+A(t,a,a.length,n<e.length-1)).join(`,
|
|
6
|
+
`)}\n${t}]`}if(typeof e==`object`&&e){let n=Object.entries(e).filter(([,e])=>e!==void 0);if(n.length===0)return`{}`;let r=t+D;return`{\n${n.map(([e,t],i)=>{let a=`${r}${JSON.stringify(e)}: `;return a+A(t,r,a.length,i<n.length-1)}).join(`,
|
|
7
|
+
`)}\n${t}}`}return JSON.stringify(e)??`null`}function j(e){let t=[];for(let n of e)if(Array.isArray(n)){let e=n.length===0?`[]`:j(n);if(e===null)return null;t.push(e)}else if(typeof n==`object`&&n){if(Object.keys(n).length>0)return null;t.push(`{}`)}else t.push(JSON.stringify(n)??`null`);return`[${t.join(`, `)}]`}function M(e){return e instanceof Error&&`code`in e?e.code:void 0}function N(e,t,i){let a=b.resolve(e,t.path);return t.kind===`razor`?[b.join(a,`wwwroot`,r,n.css),i.css]:t.kind===`spa`?[b.join(a,`src`,r,n.css),i.css]:t.kind===`phone`?[b.join(a,r,n.phone),i.phone]:[b.join(a,r,n.email),i.email]}async function P(){return{palette:await R(w.palette),scale:await R(w.scale),meaning:await R(w.meaning),modeDark:await R(w.modeDark)}}var F=[`space`,`text`,`shadow`,`section`,`component`,`email`];function I(e){return F.some(t=>t===e)}function L(e){let t={};for(let[n,r]of Object.entries(e)){let e=[];for(let t of r.groups){if(!I(t))throw Error(`webority-tokens: deviations.json names an unknown group "${t}".`);e.push(t)}t[n]={reason:r.reason,groups:e}}return t}async function R(e){return JSON.parse(await v(new URL(`./source/${e}`,import.meta.url),`utf8`))}export{E as brand,k as render};
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
"format": "webority-theme-tokens/2",
|
|
3
3
|
"source": {
|
|
4
4
|
"package": "@webority/tokens",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.154.0",
|
|
6
6
|
"brand": null,
|
|
7
7
|
"platform": "phone",
|
|
8
8
|
"width": null
|
|
9
9
|
},
|
|
10
|
-
"modes": [
|
|
11
|
-
"light",
|
|
12
|
-
"dark"
|
|
13
|
-
],
|
|
10
|
+
"modes": ["light", "dark"],
|
|
14
11
|
"colors": {
|
|
15
12
|
"light": {
|
|
16
13
|
"bg": "#ffffff",
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
"format": "webority-theme-tokens/2",
|
|
3
3
|
"source": {
|
|
4
4
|
"package": "@webority/tokens",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.154.0",
|
|
6
6
|
"brand": null,
|
|
7
7
|
"platform": "web",
|
|
8
8
|
"width": 390
|
|
9
9
|
},
|
|
10
|
-
"modes": [
|
|
11
|
-
"light",
|
|
12
|
-
"dark"
|
|
13
|
-
],
|
|
10
|
+
"modes": ["light", "dark"],
|
|
14
11
|
"colors": {
|
|
15
12
|
"light": {
|
|
16
13
|
"bg": "#f4f6f8",
|
|
@@ -35,6 +32,7 @@
|
|
|
35
32
|
"text-subtle": "#626a82",
|
|
36
33
|
"text-inverse": "#ffffff",
|
|
37
34
|
"link": "#4f46e5",
|
|
35
|
+
"link-hover": "#4338ca",
|
|
38
36
|
"border": "#ebedf3",
|
|
39
37
|
"border-subtle": "#f4f6f8",
|
|
40
38
|
"border-strong": "#c4cada",
|
|
@@ -168,6 +166,7 @@
|
|
|
168
166
|
"text-subtle": "#8a90a0",
|
|
169
167
|
"text-inverse": "#071437",
|
|
170
168
|
"link": "#aeaaf5",
|
|
169
|
+
"link-hover": "#c3c0f8",
|
|
171
170
|
"border": "#3d4554",
|
|
172
171
|
"border-subtle": "#3d455480",
|
|
173
172
|
"border-strong": "#515b6e",
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
"format": "webority-theme-tokens/2",
|
|
3
3
|
"source": {
|
|
4
4
|
"package": "@webority/tokens",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.154.0",
|
|
6
6
|
"brand": null,
|
|
7
7
|
"platform": "web",
|
|
8
8
|
"width": 1440
|
|
9
9
|
},
|
|
10
|
-
"modes": [
|
|
11
|
-
"light",
|
|
12
|
-
"dark"
|
|
13
|
-
],
|
|
10
|
+
"modes": ["light", "dark"],
|
|
14
11
|
"colors": {
|
|
15
12
|
"light": {
|
|
16
13
|
"bg": "#f4f6f8",
|
|
@@ -35,6 +32,7 @@
|
|
|
35
32
|
"text-subtle": "#626a82",
|
|
36
33
|
"text-inverse": "#ffffff",
|
|
37
34
|
"link": "#4f46e5",
|
|
35
|
+
"link-hover": "#4338ca",
|
|
38
36
|
"border": "#ebedf3",
|
|
39
37
|
"border-subtle": "#f4f6f8",
|
|
40
38
|
"border-strong": "#c4cada",
|
|
@@ -168,6 +166,7 @@
|
|
|
168
166
|
"text-subtle": "#8a90a0",
|
|
169
167
|
"text-inverse": "#071437",
|
|
170
168
|
"link": "#aeaaf5",
|
|
169
|
+
"link-hover": "#c3c0f8",
|
|
171
170
|
"border": "#3d4554",
|
|
172
171
|
"border-subtle": "#3d455480",
|
|
173
172
|
"border-strong": "#515b6e",
|
package/dist/emit/web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{isObjectLike as e}from"../guards.js";import{BREAKPOINT_PX as t,TOUCH_MEDIA as n,breakpointRules as r,fluidLength as i,touchValue as a}from"../model/length.js";import{cssVarOfPath as o}from"../names.js";import{present as s}from"../present.js";var c={mode:`light`,platform:`web`,width:1440},l={mode:`dark`,platform:`web`,width:1440},u={mode:`light`,platform:`web`,width:390},d=/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g,ee=/^\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}$/,te=/^#[0-9a-f]{6}$/i,f=[[`--bs-body-color`,`text`],[`--bs-emphasis-color`,`text`],[`--bs-secondary-color`,`text-muted`],[`--bs-tertiary-color`,`text-subtle`],[`--bs-heading-color`,`text`],[`--bs-body-bg`,`bg`],[`--bs-border-color`,`border`],[`--bs-secondary-bg`,`surface`],[`--bs-tertiary-bg`,`bg-muted`],[`--bs-primary`,`primary`]],p=[[`--bs-body-bg-rgb`,`bg`],[`--bs-primary-rgb`,`primary`],[`--bs-body-color-rgb`,`text`],[`--bs-emphasis-color-rgb`,`text`],[`--bs-secondary-color-rgb`,`text-muted`],[`--bs-tertiary-color-rgb`,`text-subtle`],[`--bs-secondary-bg-rgb`,`surface`],[`--bs-tertiary-bg-rgb`,`bg-muted`],[`--bs-border-color-rgb`,`border`]],ne=[[`--bs-secondary-rgb`,`text-muted`]],m=[[`$body-color`,`color.text-body`],[`$body-secondary-color`,`color.text-muted`],[`$body-tertiary-color`,`color.text-subtle`],[`$body-secondary-bg`,`color.bg-subtle`],[`$body-tertiary-bg`,`color.bg-muted`],[`$border-color`,`color.border`],[`$border-color-translucent`,null],[`$border-radius`,`radius.md`],[`$border-radius-sm`,`radius.sm`],[`$border-radius-lg`,`radius.lg`],[`$border-radius-pill`,`radius.pill`],[`$wui-shadow-overlay`,`shadow.popover`],[`$wui-shadow-overlay-lg`,`shadow.modal`],[`$line-height-base`,`leading.body`],[`$headings-line-height`,`leading.heading`],[`$display-line-height`,`leading.display`]],h=[[`$primary`,`color.primary`],[`$link-color`,`color.link`]],g={"$border-color-translucent":`rgba(13, 24, 43, 0.08)`},_=[`color.link`,`color.
|
|
1
|
+
import{isObjectLike as e}from"../guards.js";import{BREAKPOINT_PX as t,TOUCH_MEDIA as n,breakpointRules as r,fluidLength as i,touchValue as a}from"../model/length.js";import{cssVarOfPath as o}from"../names.js";import{present as s}from"../present.js";var c={mode:`light`,platform:`web`,width:1440},l={mode:`dark`,platform:`web`,width:1440},u={mode:`light`,platform:`web`,width:390},d=/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g,ee=/^\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}$/,te=/^#[0-9a-f]{6}$/i,f=[[`--bs-body-color`,`text`],[`--bs-emphasis-color`,`text`],[`--bs-secondary-color`,`text-muted`],[`--bs-tertiary-color`,`text-subtle`],[`--bs-heading-color`,`text`],[`--bs-body-bg`,`bg`],[`--bs-border-color`,`border`],[`--bs-secondary-bg`,`surface`],[`--bs-tertiary-bg`,`bg-muted`],[`--bs-primary`,`primary`]],p=[[`--bs-body-bg-rgb`,`bg`],[`--bs-primary-rgb`,`primary`],[`--bs-body-color-rgb`,`text`],[`--bs-emphasis-color-rgb`,`text`],[`--bs-secondary-color-rgb`,`text-muted`],[`--bs-tertiary-color-rgb`,`text-subtle`],[`--bs-secondary-bg-rgb`,`surface`],[`--bs-tertiary-bg-rgb`,`bg-muted`],[`--bs-border-color-rgb`,`border`]],ne=[[`--bs-secondary-rgb`,`text-muted`]],m=[[`$body-color`,`color.text-body`],[`$body-secondary-color`,`color.text-muted`],[`$body-tertiary-color`,`color.text-subtle`],[`$body-secondary-bg`,`color.bg-subtle`],[`$body-tertiary-bg`,`color.bg-muted`],[`$border-color`,`color.border`],[`$border-color-translucent`,null],[`$border-radius`,`radius.md`],[`$border-radius-sm`,`radius.sm`],[`$border-radius-lg`,`radius.lg`],[`$border-radius-pill`,`radius.pill`],[`$wui-shadow-overlay`,`shadow.popover`],[`$wui-shadow-overlay-lg`,`shadow.modal`],[`$line-height-base`,`leading.body`],[`$headings-line-height`,`leading.heading`],[`$display-line-height`,`leading.display`]],h=[[`$primary`,`color.primary`],[`$link-color`,`color.link`],[`$link-hover-color`,`color.link-hover`]],g={"$border-color-translucent":`rgba(13, 24, 43, 0.08)`},_=[`color.link`,`color.link-hover`],re=`:root[data-theme="dark"],
|
|
2
2
|
:root[data-bs-theme="dark"]`,v=`[data-theme="dark"]:not(:root),
|
|
3
3
|
[data-bs-theme="dark"]:not(:root)`,ie=`:root[data-theme="auto"]`,y=`:root[data-theme="dark"] [data-theme="light"],
|
|
4
4
|
:root[data-theme="dark"] [data-bs-theme="light"],
|
|
@@ -7,7 +7,7 @@ import{isObjectLike as e}from"../guards.js";import{BREAKPOINT_PX as t,TOUCH_MEDI
|
|
|
7
7
|
:root[data-theme="auto"] [data-bs-theme="light"]`,x=`[data-theme="dark"]:not(:root) [data-theme="light"],
|
|
8
8
|
[data-theme="dark"]:not(:root) [data-bs-theme="light"],
|
|
9
9
|
[data-bs-theme="dark"]:not(:root) [data-theme="light"],
|
|
10
|
-
[data-bs-theme="dark"]:not(:root) [data-bs-theme="light"]`,S=`// var() resolves where a name is declared, so the html copies keep the light values for a light box.`,C=`/* var() resolves where a name is declared, so the html copies keep the light values for a light box. */`,w=`// Zero specificity, so a component's own class on a themed section or inside it keeps its colour.`,T=`/* Zero specificity, so a component's own class on a themed section or inside it keeps its colour. */`,E=`// A light box under a dark page root takes literal light values: var() would resolve against the dark root.`,D=`/* A light box under a dark page root takes literal light values: var() would resolve against the dark root. */`;function O(e){return String(Number(e.toFixed(4)))}function k(e,t){return s(e.tokens.get(t),`token ${t}`)}function ae(e){if(e==null)return 1440;if(typeof e==`number`)return e;throw Error(`emitWeb: fluidUntil must be a number`)}function A(t,n){if(typeof n==`string`)return n.replace(d,(e,t)=>`var(${o(t)})`);if(typeof n==`number`)return O(n);if(Array.isArray(n)){if(t.type===`cubicBezier`&&n.length===4&&n.every(e=>typeof e==`number`))return`cubic-bezier(${n.map(e=>O(e)).join(`, `)})`;if(t.type===`fontFamily`&&n.every(e=>typeof e==`string`))return n.map(e=>/\s/.test(e)?`"${e}"`:e).join(`, `)}else if(e(n)){if(`unit`in n&&typeof n.value==`number`)return`${O(n.value)}${String(n.unit)}`;if(`color`in n)return[n.offsetX,n.offsetY,n.blur,n.spread,n.color].map(e=>A(t,e)).join(` `)}throw Error(`emitWeb: ${t.path}: cannot write a ${t.type} value as CSS.`)}function j(e,t,n){return A(k(e,t),e.valueIn(t,n))}function M(t,n){if(e(n)&&n.unit===`px`&&typeof n.value==`number`)return n.value;throw Error(`emitWeb: ${t}: a text size must be a px dimension.`)}function N(e,t){let n=k(e,t),a=o(t);if(n.group===`text`){if(r(n).length>0)throw Error(`emitWeb: ${t}: a text size cannot carry breakpoints.`);let o=M(t,e.valueIn(t,u)),s=M(t,e.valueIn(t,c)),l=n.extensions?.fluidUntil;if(o!==s&&l===void 0)throw Error(`emitWeb: ${t}: the 390 and 1440 sizes differ but no fluidUntil is recorded.`);return{path:t,name:a,root:i(o,s,ae(l)),tiers:[]}}let s=r(n);return s.length>0?{path:t,name:a,root:j(e,t,u),tiers:s.map(e=>({tier:e.tier,text:A(n,e.value)}))}:{path:t,name:a,root:j(e,t,c),tiers:[]}}function P(e){let t=[];for(let n of e.tokens.keys())e.existsIn(n,c)&&t.push(N(e,n));return t}function F(e,t){let n=[];for(let[i,a]of e.tokens){if(!e.existsIn(i,l)||!e.existsIn(i,c)||r(a).length>0)continue;let s=j(e,i,l);if(a.group===`text`){if(s!==j(e,i,c))throw Error(`emitWeb: ${i}: a text size cannot change with the mode.`)}else t(i,s)&&n.push({path:i,name:o(i),text:s,light:j(e,i,c)})}return n}function I(e){let t=Number.parseInt(e.slice(1),16);return`${t>>16&255}, ${t>>8&255}, ${t&255}`}function L(e,t){let n=[],r=(r,i)=>{for(let[a,o]of r){let r=`color.${o}`,s=U(e,r,l);if(t(r,s)){let t=i?I(U(e,r,c)):null;n.push({name:a,text:I(s),light:t})}}};return r(p,!0),r(ne,!1),n}function R(e,t,n){return!e.tokens.has(`color.primary`)||!t.tokens.has(`color.primary`)||e.resolvedIn(`color.primary`,n)===t.resolvedIn(`color.primary`,n)?[]:z(e,n)}function z(e,t){let n=U(e,`color.primary`,t);return[{name:`--bs-primary`,text:n},{name:`--bs-primary-rgb`,text:I(n)}]}function B(e,t,n){return!_.every(n=>e.tokens.has(n)&&t.tokens.has(n))||e.resolvedIn(
|
|
10
|
+
[data-bs-theme="dark"]:not(:root) [data-bs-theme="light"]`,S=`// var() resolves where a name is declared, so the html copies keep the light values for a light box.`,C=`/* var() resolves where a name is declared, so the html copies keep the light values for a light box. */`,w=`// Zero specificity, so a component's own class on a themed section or inside it keeps its colour.`,T=`/* Zero specificity, so a component's own class on a themed section or inside it keeps its colour. */`,E=`// A light box under a dark page root takes literal light values: var() would resolve against the dark root.`,D=`/* A light box under a dark page root takes literal light values: var() would resolve against the dark root. */`;function O(e){return String(Number(e.toFixed(4)))}function k(e,t){return s(e.tokens.get(t),`token ${t}`)}function ae(e){if(e==null)return 1440;if(typeof e==`number`)return e;throw Error(`emitWeb: fluidUntil must be a number`)}function A(t,n){if(typeof n==`string`)return n.replace(d,(e,t)=>`var(${o(t)})`);if(typeof n==`number`)return O(n);if(Array.isArray(n)){if(t.type===`cubicBezier`&&n.length===4&&n.every(e=>typeof e==`number`))return`cubic-bezier(${n.map(e=>O(e)).join(`, `)})`;if(t.type===`fontFamily`&&n.every(e=>typeof e==`string`))return n.map(e=>/\s/.test(e)?`"${e}"`:e).join(`, `)}else if(e(n)){if(`unit`in n&&typeof n.value==`number`)return`${O(n.value)}${String(n.unit)}`;if(`color`in n)return[n.offsetX,n.offsetY,n.blur,n.spread,n.color].map(e=>A(t,e)).join(` `)}throw Error(`emitWeb: ${t.path}: cannot write a ${t.type} value as CSS.`)}function j(e,t,n){return A(k(e,t),e.valueIn(t,n))}function M(t,n){if(e(n)&&n.unit===`px`&&typeof n.value==`number`)return n.value;throw Error(`emitWeb: ${t}: a text size must be a px dimension.`)}function N(e,t){let n=k(e,t),a=o(t);if(n.group===`text`){if(r(n).length>0)throw Error(`emitWeb: ${t}: a text size cannot carry breakpoints.`);let o=M(t,e.valueIn(t,u)),s=M(t,e.valueIn(t,c)),l=n.extensions?.fluidUntil;if(o!==s&&l===void 0)throw Error(`emitWeb: ${t}: the 390 and 1440 sizes differ but no fluidUntil is recorded.`);return{path:t,name:a,root:i(o,s,ae(l)),tiers:[]}}let s=r(n);return s.length>0?{path:t,name:a,root:j(e,t,u),tiers:s.map(e=>({tier:e.tier,text:A(n,e.value)}))}:{path:t,name:a,root:j(e,t,c),tiers:[]}}function P(e){let t=[];for(let n of e.tokens.keys())e.existsIn(n,c)&&t.push(N(e,n));return t}function F(e,t){let n=[];for(let[i,a]of e.tokens){if(!e.existsIn(i,l)||!e.existsIn(i,c)||r(a).length>0)continue;let s=j(e,i,l);if(a.group===`text`){if(s!==j(e,i,c))throw Error(`emitWeb: ${i}: a text size cannot change with the mode.`)}else t(i,s)&&n.push({path:i,name:o(i),text:s,light:j(e,i,c)})}return n}function I(e){let t=Number.parseInt(e.slice(1),16);return`${t>>16&255}, ${t>>8&255}, ${t&255}`}function L(e,t){let n=[],r=(r,i)=>{for(let[a,o]of r){let r=`color.${o}`,s=U(e,r,l);if(t(r,s)){let t=i?I(U(e,r,c)):null;n.push({name:a,text:I(s),light:t})}}};return r(p,!0),r(ne,!1),n}function R(e,t,n){return!e.tokens.has(`color.primary`)||!t.tokens.has(`color.primary`)||e.resolvedIn(`color.primary`,n)===t.resolvedIn(`color.primary`,n)?[]:z(e,n)}function z(e,t){let n=U(e,`color.primary`,t);return[{name:`--bs-primary`,text:n},{name:`--bs-primary-rgb`,text:I(n)}]}function B(e,t,n){return!_.every(n=>e.tokens.has(n)&&t.tokens.has(n))||_.every(r=>e.resolvedIn(r,n)===t.resolvedIn(r,n))?[]:V(e,n)}function V(e,t){let n=U(e,`color.link`,t),r=U(e,`color.link-hover`,t);return[{name:`--bs-link-color`,text:n},{name:`--bs-link-color-rgb`,text:I(n)},{name:`--bs-link-hover-color`,text:r},{name:`--bs-link-hover-color-rgb`,text:I(r)}]}function H(e){return _.every(t=>e.tokens.has(t))?[{name:`--bs-link-color`,text:`var(--color-link)`,light:`var(--color-link)`},{name:`--bs-link-color-rgb`,text:I(U(e,`color.link`,l)),light:I(U(e,`color.link`,c))},{name:`--bs-link-hover-color`,text:`var(--color-link-hover)`,light:`var(--color-link-hover)`},{name:`--bs-link-hover-color-rgb`,text:I(U(e,`color.link-hover`,l)),light:I(U(e,`color.link-hover`,c))}]:[]}function U(e,t,n){let r=e.resolvedIn(t,n);if(typeof r!=`string`||!te.test(r))throw Error(`emitWeb: ${t}: a Bootstrap rgb triplet needs an opaque colour.`);return r}function W(e,t){let n=F(e,t?(e,n)=>!t.tokens.has(e)||!t.existsIn(e,l)||n!==j(t,e,l):(t,n)=>n!==j(e,t,c)),r=L(e,t?(e,n)=>n!==t.resolvedIn(e,l):()=>!0);if(t){let i=B(e,t,c).length>0?V(e,l):B(e,t,l);return[...n,...r,...i]}let i=f.map(([e,t])=>{let n=`var(${o(`color.${t}`)})`;return{name:e,text:n,light:n}});return[...n,...i,...r,...H(e)]}function G(e,t,n){return e.tokens.has(n)&&t.tokens.has(n)&&e.resolvedIn(n,c)!==t.resolvedIn(n,c)}function K(e,t){let n=f.filter(([n,r])=>n!==`--bs-primary`&&G(e,t,`color.${r}`)).map(([e,t])=>({name:e,text:`var(${o(`color.${t}`)})`})),r=p.filter(([n,r])=>n!==`--bs-primary-rgb`&&G(e,t,`color.${r}`)).map(([t,n])=>({name:t,text:I(U(e,`color.${n}`,c))}));return[...n,...r]}function q(e,t){return`${e} {\n${t.join(`
|
|
11
11
|
`).split(`
|
|
12
12
|
`).map(e=>e===``?e:` ${e}`).join(`
|
|
13
13
|
`)}\n}`}function J(e){return e.split(`,
|