@webority/tokens 0.164.0 → 0.167.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/LICENSE +1 -1
- package/dist/brand.d.ts +1 -1
- package/dist/brand.js +1 -1
- package/dist/build.d.ts +1 -0
- package/dist/build.js +1 -1
- package/dist/canvas/webority-phone.json +9 -7
- package/dist/canvas/webority-web-390.json +12 -4
- package/dist/canvas/webority-web.json +12 -4
- package/dist/cli.js +2 -2
- package/dist/emit/phone.d.ts +2 -0
- package/dist/emit/phone.js +3 -3
- package/dist/emit/web.d.ts +4 -2
- package/dist/emit/web.js +18 -14
- package/dist/meanings.json +1 -1
- package/dist/model/contrast.js +1 -1
- package/dist/model/index.d.ts +5 -1
- package/dist/model/load.d.ts +2 -0
- package/dist/model/load.js +1 -1
- package/dist/model/resolve.js +2 -2
- package/dist/names.js +1 -1
- package/dist/source/component.tokens.json +26 -10
- package/dist/source/contrast.more.tokens.json +16 -0
- package/dist/source/medium.print.tokens.json +20 -0
- package/dist/source/platform.phone.tokens.json +5 -0
- package/dist/source/scale.tokens.json +33 -4
- package/dist/webority.resolver.json +7 -1
- package/package.json +2 -2
- package/renames/0.158.0.json +32 -25
- package/renames/0.160.0.json +39 -6
- package/renames/0.165.0.json +53 -0
- package/renames/0.167.0.json +70 -0
- package/schema/design-map.schema.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Copyright (c) Webority Technologies. All rights reserved.
|
|
2
2
|
|
|
3
|
-
This software and its
|
|
3
|
+
This software and its Webority packages are the proprietary and confidential property
|
|
4
4
|
of Webority Technologies. They are published publicly only for the convenience of
|
|
5
5
|
Webority's own projects and internal consumption.
|
|
6
6
|
|
package/dist/brand.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare const BRAND_OUTPUT_FILES: Readonly<{
|
|
|
60
60
|
web: "webority-web.json";
|
|
61
61
|
web390: "webority-web-390.json";
|
|
62
62
|
phoneTheme: "webority-phone.json";
|
|
63
|
-
phone: "brand.phone.
|
|
63
|
+
phone: "brand.phone.ts";
|
|
64
64
|
email: "email.json";
|
|
65
65
|
}>;
|
|
66
66
|
/** The folder inside each head that receives the copies of the generated files. */
|
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.
|
|
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.ts`,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
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
package/dist/build.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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(`
|
|
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.webModes!==void 0&&e.library!==!0)throw Error(`--web-modes is only for --library`);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.webModes&&!e.web)throw Error(`--web-modes needs --web`);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]),e.webModes&&c.push([b.resolve(t,e.webModes),n.modes])}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
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
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(`
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"format": "webority-theme-tokens/2",
|
|
3
3
|
"source": {
|
|
4
4
|
"package": "@webority/tokens",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.167.0",
|
|
6
6
|
"brand": null,
|
|
7
7
|
"platform": "phone",
|
|
8
8
|
"width": null
|
|
@@ -212,6 +212,8 @@
|
|
|
212
212
|
"md": 10,
|
|
213
213
|
"lg": 14,
|
|
214
214
|
"xl": 20,
|
|
215
|
+
"2xl": 18,
|
|
216
|
+
"3xl": 20,
|
|
215
217
|
"pill": 9999
|
|
216
218
|
},
|
|
217
219
|
"text": {
|
|
@@ -390,7 +392,7 @@
|
|
|
390
392
|
"sm": {
|
|
391
393
|
"padding-x": "12px",
|
|
392
394
|
"padding-y": "4px",
|
|
393
|
-
"min-height": "
|
|
395
|
+
"min-height": "35px",
|
|
394
396
|
"text": "13px",
|
|
395
397
|
"radius": "10px",
|
|
396
398
|
"icon": "16px",
|
|
@@ -399,7 +401,7 @@
|
|
|
399
401
|
"md": {
|
|
400
402
|
"padding-x": "16px",
|
|
401
403
|
"padding-y": "8px",
|
|
402
|
-
"min-height": "
|
|
404
|
+
"min-height": "40px",
|
|
403
405
|
"text": "15px",
|
|
404
406
|
"radius": "10px",
|
|
405
407
|
"icon": "18px",
|
|
@@ -407,8 +409,8 @@
|
|
|
407
409
|
},
|
|
408
410
|
"lg": {
|
|
409
411
|
"padding-x": "24px",
|
|
410
|
-
"padding-y": "
|
|
411
|
-
"min-height": "
|
|
412
|
+
"padding-y": "8px",
|
|
413
|
+
"min-height": "45px",
|
|
412
414
|
"text": "17px",
|
|
413
415
|
"radius": "14px",
|
|
414
416
|
"icon": "20px",
|
|
@@ -417,8 +419,8 @@
|
|
|
417
419
|
"xl": {
|
|
418
420
|
"padding-x": "32px",
|
|
419
421
|
"padding-y": "12px",
|
|
420
|
-
"min-height": "
|
|
421
|
-
"text": "
|
|
422
|
+
"min-height": "50px",
|
|
423
|
+
"text": "17px",
|
|
422
424
|
"radius": "14px",
|
|
423
425
|
"icon": "22px",
|
|
424
426
|
"badge-icon": "22px"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"format": "webority-theme-tokens/2",
|
|
3
3
|
"source": {
|
|
4
4
|
"package": "@webority/tokens",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.167.0",
|
|
6
6
|
"brand": null,
|
|
7
7
|
"platform": "web",
|
|
8
8
|
"width": 390
|
|
@@ -296,6 +296,8 @@
|
|
|
296
296
|
"md": 10,
|
|
297
297
|
"lg": 14,
|
|
298
298
|
"xl": 16,
|
|
299
|
+
"2xl": 18,
|
|
300
|
+
"3xl": 20,
|
|
299
301
|
"pill": 9999
|
|
300
302
|
},
|
|
301
303
|
"text": {
|
|
@@ -412,6 +414,9 @@
|
|
|
412
414
|
},
|
|
413
415
|
"lg": {
|
|
414
416
|
"radius": "8px"
|
|
417
|
+
},
|
|
418
|
+
"xl": {
|
|
419
|
+
"radius": "8px"
|
|
415
420
|
}
|
|
416
421
|
}
|
|
417
422
|
},
|
|
@@ -517,13 +522,16 @@
|
|
|
517
522
|
"base": {},
|
|
518
523
|
"sizes": {
|
|
519
524
|
"sm": {
|
|
520
|
-
"radius": "
|
|
525
|
+
"radius": "14px"
|
|
521
526
|
},
|
|
522
527
|
"md": {
|
|
523
|
-
"radius": "
|
|
528
|
+
"radius": "16px"
|
|
524
529
|
},
|
|
525
530
|
"lg": {
|
|
526
|
-
"radius": "
|
|
531
|
+
"radius": "18px"
|
|
532
|
+
},
|
|
533
|
+
"xl": {
|
|
534
|
+
"radius": "20px"
|
|
527
535
|
}
|
|
528
536
|
}
|
|
529
537
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"format": "webority-theme-tokens/2",
|
|
3
3
|
"source": {
|
|
4
4
|
"package": "@webority/tokens",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.167.0",
|
|
6
6
|
"brand": null,
|
|
7
7
|
"platform": "web",
|
|
8
8
|
"width": 1440
|
|
@@ -296,6 +296,8 @@
|
|
|
296
296
|
"md": 10,
|
|
297
297
|
"lg": 14,
|
|
298
298
|
"xl": 16,
|
|
299
|
+
"2xl": 18,
|
|
300
|
+
"3xl": 20,
|
|
299
301
|
"pill": 9999
|
|
300
302
|
},
|
|
301
303
|
"text": {
|
|
@@ -412,6 +414,9 @@
|
|
|
412
414
|
},
|
|
413
415
|
"lg": {
|
|
414
416
|
"radius": "8px"
|
|
417
|
+
},
|
|
418
|
+
"xl": {
|
|
419
|
+
"radius": "8px"
|
|
415
420
|
}
|
|
416
421
|
}
|
|
417
422
|
},
|
|
@@ -517,13 +522,16 @@
|
|
|
517
522
|
"base": {},
|
|
518
523
|
"sizes": {
|
|
519
524
|
"sm": {
|
|
520
|
-
"radius": "
|
|
525
|
+
"radius": "14px"
|
|
521
526
|
},
|
|
522
527
|
"md": {
|
|
523
|
-
"radius": "
|
|
528
|
+
"radius": "16px"
|
|
524
529
|
},
|
|
525
530
|
"lg": {
|
|
526
|
-
"radius": "
|
|
531
|
+
"radius": "18px"
|
|
532
|
+
},
|
|
533
|
+
"xl": {
|
|
534
|
+
"radius": "20px"
|
|
527
535
|
}
|
|
528
536
|
}
|
|
529
537
|
},
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{brand as e}from"./build.js";import{check as t}from"./check.js";import{upgrade as n}from"./upgrade/index.js";import{writeFileSync as r}from"node:fs";var i=`Usage: webority <command>
|
|
2
|
-
brand [--brand <file>] [--library] [--out <dir>] [--web <scss>] [--phone <ts>] [--check]
|
|
2
|
+
brand [--brand <file>] [--library] [--out <dir>] [--web <scss>] [--web-modes <scss>] [--phone <ts>] [--check]
|
|
3
3
|
upgrade <version> [--dry-run] [--app <folder>] [--path <p>]... [--alias <pkg>=<library pkg>]... [--report <path>]
|
|
4
|
-
check`,a=[`brand`,`upgrade`,`check`],o=[`generated`,`design-map`,`repo-checks`],s={"--brand":`brand`,"--out":`out`,"--web":`web`,"--phone":`phone`},c=class extends Error{};function l(e){return console.error(e),console.error(i),2}function u(e){if(!(e instanceof Error))throw e;return console.error(e.message),1}function d(e,t,n){let r=[],i={},a=new Set;for(let o=0;o<e.length;o+=1){let s=e[o]??``;if(t.includes(s)){let t=e[o+1];if(t===void 0||t.startsWith(`--`))throw new c(`${s} needs a value.`);i[s]=[...i[s]??[],t],o+=1}else if(n.includes(s))a.add(s);else if(s.startsWith(`--`))throw new c(`Unknown flag ${s}.`);else r.push(s)}return{positionals:r,values:i,flags:a}}function f(e,t){if(e===`brand`){let{positionals:e,values:n,flags:r}=d(t,Object.keys(s),[`--library`,`--check`]);if(e.length>0)throw new c(`brand takes no argument, got ${e[0]}.`);let i={};for(let[e,t]of Object.entries(s)){let r=n[e]?.at(-1);r!==void 0&&(i[t]=r)}return r.has(`--library`)&&(i.library=!0),r.has(`--check`)&&(i.check=!0),{kind:`brand`,options:i}}if(e===`upgrade`){let{positionals:e,values:n,flags:r}=d(t,[`--path`,`--app`,`--alias`,`--report`],[`--dry-run`]),[i,...a]=e;if(i===void 0)throw new c(`upgrade needs a <version>.`);if(a.length>0)throw new c(`Unexpected argument ${a[0]}.`);let o={version:i};r.has(`--dry-run`)&&(o.dryRun=!0);let s=n[`--alias`];if(s!==void 0){o.aliases={};for(let e of s){let[t,n]=e.split(`=`);if(!t||!n||e.split(`=`).length!==2)throw new c(`--alias takes <pkg>=<library pkg>, got ${e}.`);o.aliases[t]=n}}let l=n[`--report`];if(l!==void 0){if(l.length>1)throw new c(`--report takes one path.`);let e=l[0];e!==void 0&&(o.report=e)}let u=n[`--app`];if(u!==void 0){if(u.length>1)throw new c(`--app takes one folder.`);if(n[`--path`]!==void 0)throw new c(`--app and --path cannot be combined.`);let e=u[0];e!==void 0&&(o.app=e)}let f=n[`--path`];return f!==void 0&&(o.paths=f),{kind:`upgrade`,options:o}}if(t.length>0)throw new c(`check takes no arguments, got ${t[0]}.`);return{kind:`check`}}async function p(s,d={brand:e,upgrade:n,check:t}){if(s.includes(`--help`)||s.includes(`-h`))return console.log(i),0;if(s.length===0)return console.error(i),2;let[p=``,...m]=s;if(!a.includes(p))return l(`Unknown command ${p}. Commands: brand, upgrade, check.`);let h;try{h=f(p,m)}catch(e){if(e instanceof c)return l(e.message);throw e}if(h.kind===`brand`){let e;try{e=await d.brand(h.options)}catch(e){return u(e)}for(let t of e.written)console.log(`wrote ${t}`);if(!h.options.check)return 0;for(let t of e.stale)console.log(`stale ${t}`);return+(e.stale.length>0)}if(h.kind===`upgrade`){let{report:e,...t}=h.options,n;try{n=await d.upgrade(t)}catch(e){return u(e)}for(let e of n.hits)console.log(`${e.file}:${e.line} ${e.from} -> ${e.to}`);for(let e of n.choose)console.log(`choose ${e.file}:${e.line} ${e.name}: ${e.hint}`);if(e!==void 0)try{r(e,`${JSON.stringify({hits:n.hits,choose:n.choose,changedFiles:n.changedFiles},null,4)}\n`,`utf8`)}catch(e){return u(e)}return+(n.choose.length>0)}let g;try{g=await d.check()}catch(e){return u(e)}for(let e of o)g.findings.some(t=>t.check===e)||console.log(`ok ${e}`);for(let e of g.findings){let t=e.file?`${e.file}: `:``;console.log(`FAIL ${e.check}: ${t}${e.message}`)}return+(g.findings.length>0)}export{e as brand,t as check,p as run,n as upgrade};
|
|
4
|
+
check`,a=[`brand`,`upgrade`,`check`],o=[`generated`,`design-map`,`repo-checks`],s={"--brand":`brand`,"--out":`out`,"--web":`web`,"--web-modes":`webModes`,"--phone":`phone`},c=class extends Error{};function l(e){return console.error(e),console.error(i),2}function u(e){if(!(e instanceof Error))throw e;return console.error(e.message),1}function d(e,t,n){let r=[],i={},a=new Set;for(let o=0;o<e.length;o+=1){let s=e[o]??``;if(t.includes(s)){let t=e[o+1];if(t===void 0||t.startsWith(`--`))throw new c(`${s} needs a value.`);i[s]=[...i[s]??[],t],o+=1}else if(n.includes(s))a.add(s);else if(s.startsWith(`--`))throw new c(`Unknown flag ${s}.`);else r.push(s)}return{positionals:r,values:i,flags:a}}function f(e,t){if(e===`brand`){let{positionals:e,values:n,flags:r}=d(t,Object.keys(s),[`--library`,`--check`]);if(e.length>0)throw new c(`brand takes no argument, got ${e[0]}.`);let i={};for(let[e,t]of Object.entries(s)){let r=n[e]?.at(-1);r!==void 0&&(i[t]=r)}return r.has(`--library`)&&(i.library=!0),r.has(`--check`)&&(i.check=!0),{kind:`brand`,options:i}}if(e===`upgrade`){let{positionals:e,values:n,flags:r}=d(t,[`--path`,`--app`,`--alias`,`--report`],[`--dry-run`]),[i,...a]=e;if(i===void 0)throw new c(`upgrade needs a <version>.`);if(a.length>0)throw new c(`Unexpected argument ${a[0]}.`);let o={version:i};r.has(`--dry-run`)&&(o.dryRun=!0);let s=n[`--alias`];if(s!==void 0){o.aliases={};for(let e of s){let[t,n]=e.split(`=`);if(!t||!n||e.split(`=`).length!==2)throw new c(`--alias takes <pkg>=<library pkg>, got ${e}.`);o.aliases[t]=n}}let l=n[`--report`];if(l!==void 0){if(l.length>1)throw new c(`--report takes one path.`);let e=l[0];e!==void 0&&(o.report=e)}let u=n[`--app`];if(u!==void 0){if(u.length>1)throw new c(`--app takes one folder.`);if(n[`--path`]!==void 0)throw new c(`--app and --path cannot be combined.`);let e=u[0];e!==void 0&&(o.app=e)}let f=n[`--path`];return f!==void 0&&(o.paths=f),{kind:`upgrade`,options:o}}if(t.length>0)throw new c(`check takes no arguments, got ${t[0]}.`);return{kind:`check`}}async function p(s,d={brand:e,upgrade:n,check:t}){if(s.includes(`--help`)||s.includes(`-h`))return console.log(i),0;if(s.length===0)return console.error(i),2;let[p=``,...m]=s;if(!a.includes(p))return l(`Unknown command ${p}. Commands: brand, upgrade, check.`);let h;try{h=f(p,m)}catch(e){if(e instanceof c)return l(e.message);throw e}if(h.kind===`brand`){let e;try{e=await d.brand(h.options)}catch(e){return u(e)}for(let t of e.written)console.log(`wrote ${t}`);if(!h.options.check)return 0;for(let t of e.stale)console.log(`stale ${t}`);return+(e.stale.length>0)}if(h.kind===`upgrade`){let{report:e,...t}=h.options,n;try{n=await d.upgrade(t)}catch(e){return u(e)}for(let e of n.hits)console.log(`${e.file}:${e.line} ${e.from} -> ${e.to}`);for(let e of n.choose)console.log(`choose ${e.file}:${e.line} ${e.name}: ${e.hint}`);if(e!==void 0)try{r(e,`${JSON.stringify({hits:n.hits,choose:n.choose,changedFiles:n.changedFiles},null,4)}\n`,`utf8`)}catch(e){return u(e)}return+(n.choose.length>0)}let g;try{g=await d.check()}catch(e){return u(e)}for(let e of o)g.findings.some(t=>t.check===e)||console.log(`ok ${e}`);for(let e of g.findings){let t=e.file?`${e.file}: `:``;console.log(`FAIL ${e.check}: ${t}${e.message}`)}return+(g.findings.length>0)}export{e as brand,t as check,p as run,n as upgrade};
|
package/dist/emit/phone.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export interface PhoneToken {
|
|
|
8
8
|
platforms: readonly ("web" | "phone")[] | null;
|
|
9
9
|
/** The com.webority extension object, or null. */
|
|
10
10
|
extensions: Record<string, unknown> | null;
|
|
11
|
+
/** What the token is for: required on a colour a brand adds, which the library has no name for. */
|
|
12
|
+
description: string | null;
|
|
11
13
|
}
|
|
12
14
|
export interface PhoneTokenSets {
|
|
13
15
|
light: readonly PhoneToken[];
|
package/dist/emit/phone.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{isObjectLike as e}from"../guards.js";import{present as t}from"../present.js";var n="// Generated by `webority brand --library` from packages/tokens/src/source. Do not edit: run `corepack pnpm --filter @webority/mobile-ui tokens`.",r=/^[A-Za-z_$][A-Za-z0-9_$]*$/,i=/^#([0-9a-fA-F]{6})([0-9a-fA-F]{2})?$/,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)$/,o=[`xs`,`sm`,`md`,`lg`,`xl`],s=`must be component.<name>.<prop> or component.<name>.<size>.<prop>`,c=[`light`,`dark`],l=new Map([[`color`,`colors`],[`space`,`space`],[`radius`,`radius`],[`text`,`text`],[`weight`,`weight`],[`leading`,`leading`],[`letter-spacing`,`letter-spacing`],[`font`,`font`],[`shadow`,`shadow`],[`size`,`size`],[`component`,`components`]]),u=[{key:`colors`,constName:`COLOR_NAMES`,typeName:`ColorName`},{key:`space`,constName:`SPACE_NAMES`,typeName:`SpaceName`},{key:`radius`,constName:`RADIUS_NAMES`,typeName:`RadiusName`},{key:`text`,constName:`TEXT_NAMES`,typeName:`TextName`},{key:`weight`,constName:`WEIGHT_NAMES`,typeName:`WeightName`},{key:`leading`,constName:`LEADING_NAMES`,typeName:`LeadingName`},{key:`letter-spacing`,constName:`LETTER_SPACING_NAMES`,typeName:`LetterSpacingName`},{key:`font`,constName:`FONT_NAMES`,typeName:`FontName`},{key:`shadow`,constName:`SHADOW_NAMES`,typeName:`ShadowName`},{key:`motion.duration`,constName:`DURATION_NAMES`,typeName:`DurationName`},{key:`motion.ease`,constName:`EASE_NAMES`,typeName:`EaseName`},{key:`size`,constName:`SIZE_NAMES`,typeName:`SizeName`}],d={space:`SpaceName`,text:`TextName`,radius:`RadiusName`,px:`number`,number:`number`,ms:`number`},f=[`export type FontWeightValue = "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";`,`/** Face name per weight; an empty object means the platform system font. */`,`export type FontFaces = Partial<Record<WeightName, string>>;`,`export interface PhoneShadow {`,` shadowColor: string;`,` shadowOffset: { width: number; height: number };`,` shadowOpacity: number;`,` shadowRadius: number;`,` elevation: number;`,`}`,`export type ComponentKind = "space" | "text" | "radius" | "px" | "number" | "ms";`,`type Sized<S extends string, T> = Record<S, T>;`,`type L3 = "sm" | "md" | "lg";`],p=[`export interface TokenSet {`,` mode: "light" | "dark";`,` colors: Record<ColorName, string>;`,` space: Record<SpaceName, number>;`,` radius: Record<RadiusName, number>;`,` text: Record<TextName, { size: number }>;`,` weight: Record<WeightName, FontWeightValue>;`,` leading: Record<LeadingName, number>;`,` "letter-spacing": Record<LetterSpacingName, number>;`,` font: Record<FontName, FontFaces>;`,` shadow: Record<ShadowName, PhoneShadow>;`,` motion: { duration: Record<DurationName, number>; ease: Record<EaseName, readonly [number, number, number, number]> };`,` size: Record<SizeName, number>;`,` components: ComponentTokens;`,`}`];function m(e,t){let n=e.contexts.find(e=>e.platform===`phone`&&e.mode===t);if(!n)throw Error(`phoneSets: the model has no ${t} phone context`);let r=[];for(let t of e.tokens.values()){if(!e.existsIn(t.path,n))continue;let i=e.resolvedIn(t.path,n);r.push({path:t.path.split(`.`),type:t.type,value:t.group===`text`?_(t.path,i):i,reference:e.referenceIn(t.path,n)??null,platforms:t.platforms,extensions:Object.keys(t.extensions).length>0?t.extensions:null})}return r}function h(e){let t=E(e.light),r=E(e.dark);I(t,r);let i=[n];for(let e of u)i.push(...B(e,b(t.lists,e.key)));return i.push(...f),i.push(...G(t.components)),i.push(...K(t.components)),i.push(...p),i.push(...Y(`lightTokens`,`light`,t)),i.push(...Y(`darkTokens`,`dark`,r)),{name:`tokens.generated.ts`,contents:`${i.join(`
|
|
2
|
-
`)}\n`}}function g(e,t,n){let r={colors:{light:{},dark:{}},radius:{},font:{}};for(let n of c){let i=E(e[n]).values,a=E(t[n]).values;for(let e of new Set([...i.keys(),...a.keys()])){let t=i.get(e),o=a.get(e);if(!t&&o&&e.startsWith(`colors.`))
|
|
3
|
-
`)}\n`}}function _(e,t){return{size:T(t,e)}}function v(t,n){return e(t)?t[n]:void 0}function y(e,n){return t(e[n],`token path segment ${n}`)}function b(e,n){return t(e.get(n),`phone emitter ${n} list`)}function x(e,n){return t(e.get(n),`phone emitter value for ${n}`).value}function S(e){return e.extensions?.internal===!0?!1:e.platforms===null||e.platforms.includes(`phone`)}function C(e,t){return Error(`Token group ${e} has no phone mapping; mark it web or add one to emit/phone.js (first: ${t})`)}function w(e){let[t,n]=e.path;if(t===`motion`){if(n===`duration`||n===`ease`)return`motion.${n}`;throw C(t,e.path.join(`.`))}let r=t===void 0?void 0:l.get(t);if(r===void 0)throw C(t,e.path.join(`.`));return r}function T(t,n){let r=e(t)?t.value:t;if(typeof r!=`number`||!Number.isFinite(r))throw Error(`Token ${n} has no numeric value`);return r}function E(e){let t=new Map(u.map(e=>[e.key,[]])),n=new Map,r=new Map;for(let i of e){if(!S(i))continue;let e=i.path.join(`.`),a=w(i);if(i.value===void 0||i.value===null)throw Error(`Token ${e} has no phone value`);if(a===`components`){P(i,e,n,r);continue}let o=i.path.slice(a.startsWith(`motion.`)?2:1).join(`-`);n.set(`${a}.${o}`,{path:e,value:D(a,o,i,e)}),b(t,a).push(o)}return{lists:t,values:n,components:r}}function D(e,t,n,r){let{value:i}=n;switch(e){case`colors`:return i;case`space`:case`radius`:case`letter-spacing`:case`size`:case`leading`:case`motion.duration`:return T(i,r);case`text`:return{size:T(v(i,`size`),r)};case`weight`:return String(T(i,r));case`font`:return O(n,t);case`shadow`:return k(n,t,r);case`motion.ease`:return j(i,r)}}function O(e,t){if(Array.isArray(e.value)&&e.value.length===1&&e.value[0]===`System`)return{};if(!e.extensions?.faces)throw Error(`Font ${t} is not the system font and has no faces`);return e.extensions.faces}function k(t,n,r){let i=t.value;if(!e(i))throw Error(`Shadow ${n} has no shadow value`);let{hex:a,opacity:o}=A(i.color,r),s=t.extensions?.elevation;if(typeof s!=`number`||!Number.isFinite(s))throw Error(`Shadow ${n} has no elevation`);return{shadowColor:a,shadowOffset:{width:T(i.offsetX,r),height:T(i.offsetY,r)},shadowOpacity:o,shadowRadius:T(i.blur,r),elevation:s}}function A(e,t){let n=typeof e==`string`?i.exec(e):null;if(n){let e=n[1],r=n[2];if(e===void 0)throw Error(`Shadow ${t} colour has no digits`);let i=r===void 0?1:Math.round(parseInt(r,16)/255*1e3)/1e3;return{hex:`#${e.toLowerCase()}`,opacity:i}}let r=typeof e==`string`?a.exec(e):null;if(r)return{hex:`#${r.slice(1,4).map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`,opacity:Number(r[4])};throw Error(`Shadow ${t} colour is not #RRGGBB, #RRGGBBAA or rgba(): ${String(e)}`)}function j(e,t){if(!Array.isArray(e)||e.length!==4||!e.every(e=>Number.isFinite(e)))throw Error(`Token ${t} has no phone value`);return[...e]}function M(e){return e!==void 0&&o.includes(e)}function N(e,n){return t(e.props.get(n),`component prop ${n} kind`)}function P(e,t,n,r){let i=e.path,a=i.length===4;if(i.length!==3&&!a||a&&!M(i[2]))throw Error(`Component token ${t} ${s}`);let o=y(i,1),c=y(i,i.length-1),{kind:l,value:u}=F(e,t),d=r.get(o);if(d===void 0&&(d={props:new Map,sizes:new Map,free:new Map},r.set(o,d)),d.props.has(c)&&d.props.get(c)!==l)throw Error(`Component ${o} prop ${c} has two kinds`);if(d.props.set(c,l),a){let
|
|
1
|
+
import{isObjectLike as e}from"../guards.js";import{present as t}from"../present.js";var n="// Generated by `webority brand --library` from packages/tokens/src/source. Do not edit: run `corepack pnpm --filter @webority/mobile-ui tokens`.",r=/^[A-Za-z_$][A-Za-z0-9_$]*$/,i=/^#([0-9a-fA-F]{6})([0-9a-fA-F]{2})?$/,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)$/,o=[`xs`,`sm`,`md`,`lg`,`xl`],s=`must be component.<name>.<prop> or component.<name>.<size>.<prop>`,c=[`light`,`dark`],l=new Map([[`color`,`colors`],[`space`,`space`],[`radius`,`radius`],[`text`,`text`],[`weight`,`weight`],[`leading`,`leading`],[`letter-spacing`,`letter-spacing`],[`font`,`font`],[`shadow`,`shadow`],[`size`,`size`],[`component`,`components`]]),u=[{key:`colors`,constName:`COLOR_NAMES`,typeName:`ColorName`},{key:`space`,constName:`SPACE_NAMES`,typeName:`SpaceName`},{key:`radius`,constName:`RADIUS_NAMES`,typeName:`RadiusName`},{key:`text`,constName:`TEXT_NAMES`,typeName:`TextName`},{key:`weight`,constName:`WEIGHT_NAMES`,typeName:`WeightName`},{key:`leading`,constName:`LEADING_NAMES`,typeName:`LeadingName`},{key:`letter-spacing`,constName:`LETTER_SPACING_NAMES`,typeName:`LetterSpacingName`},{key:`font`,constName:`FONT_NAMES`,typeName:`FontName`},{key:`shadow`,constName:`SHADOW_NAMES`,typeName:`ShadowName`},{key:`motion.duration`,constName:`DURATION_NAMES`,typeName:`DurationName`},{key:`motion.ease`,constName:`EASE_NAMES`,typeName:`EaseName`},{key:`size`,constName:`SIZE_NAMES`,typeName:`SizeName`}],d={space:`SpaceName`,text:`TextName`,radius:`RadiusName`,px:`number`,number:`number`,ms:`number`},f=[`export type FontWeightValue = "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";`,`/** Face name per weight; an empty object means the platform system font. */`,`export type FontFaces = Partial<Record<WeightName, string>>;`,`export interface PhoneShadow {`,` shadowColor: string;`,` shadowOffset: { width: number; height: number };`,` shadowOpacity: number;`,` shadowRadius: number;`,` elevation: number;`,`}`,`export type ComponentKind = "space" | "text" | "radius" | "px" | "number" | "ms";`,`type Sized<S extends string, T> = Record<S, T>;`,`type L3 = "sm" | "md" | "lg";`],p=[`export interface TokenSet {`,` mode: "light" | "dark";`,` colors: Record<ColorName, string>;`,` space: Record<SpaceName, number>;`,` radius: Record<RadiusName, number>;`,` text: Record<TextName, { size: number }>;`,` weight: Record<WeightName, FontWeightValue>;`,` leading: Record<LeadingName, number>;`,` "letter-spacing": Record<LetterSpacingName, number>;`,` font: Record<FontName, FontFaces>;`,` shadow: Record<ShadowName, PhoneShadow>;`,` motion: { duration: Record<DurationName, number>; ease: Record<EaseName, readonly [number, number, number, number]> };`,` size: Record<SizeName, number>;`,` components: ComponentTokens;`,`}`];function m(e,t){let n=e.contexts.find(e=>e.platform===`phone`&&e.mode===t);if(!n)throw Error(`phoneSets: the model has no ${t} phone context`);let r=[];for(let t of e.tokens.values()){if(!e.existsIn(t.path,n))continue;let i=e.resolvedIn(t.path,n);r.push({path:t.path.split(`.`),type:t.type,value:t.group===`text`?_(t.path,i):i,reference:e.referenceIn(t.path,n)??null,platforms:t.platforms,extensions:Object.keys(t.extensions).length>0?t.extensions:null,description:t.description})}return r}function h(e){let t=E(e.light),r=E(e.dark);I(t,r);let i=[n];for(let e of u)i.push(...B(e,b(t.lists,e.key)));return i.push(...f),i.push(...G(t.components)),i.push(...K(t.components)),i.push(...p),i.push(...Y(`lightTokens`,`light`,t)),i.push(...Y(`darkTokens`,`dark`,r)),{name:`tokens.generated.ts`,contents:`${i.join(`
|
|
2
|
+
`)}\n`}}function g(e,t,n){let r={colors:{light:{},dark:{}},descriptions:{},radius:{},font:{}};for(let n of c){let i=E(e[n]).values,a=E(t[n]).values;for(let e of new Set([...i.keys(),...a.keys()])){let t=i.get(e),o=a.get(e);if(!t&&o&&e.startsWith(`colors.`)){let t=e.slice(7),i=o.description;if(i===null||i===``)throw Error(`Brand-only colour ${t} has no description`);r.colors[n][t]=o.value,r.descriptions[t]=i;continue}if(!t||!o)throw Error(R(e));if(JSON.stringify(t.value)===JSON.stringify(o.value))continue;let s=e.lastIndexOf(`.`),c=e.slice(0,s),l=e.slice(s+1);if(c===`radius`&&(l===`none`||l===`pill`))throw Error(`A brand cannot change radius none or pill`);if(c===`colors`)r.colors[n][l]=o.value;else if(c===`radius`)L(r.radius,l,o.value,e);else if(c===`font`)L(r.font,l,o.value,e);else throw Error(R(e))}}let i=Object.fromEntries(c.filter(e=>Object.keys(r.colors[e]).length>0).map(e=>[e,r.colors[e]])),a={};Object.keys(i).length>0&&(a.colors=i),Object.keys(r.radius).length>0&&(a.radius=r.radius),Object.keys(r.font).length>0&&(a.font=r.font),Object.keys(r.descriptions).length>0&&(a.descriptions=r.descriptions);let o=[`// Generated by \`webority brand\` for ${n.brand} from ${n.package} ${n.version}. Do not edit.`,``,`import type { BrandOverrides } from "@webority/mobile-ui";`];return Object.keys(a).length===0?o.push(`export const brand: BrandOverrides = {};`):o.push(`export const brand: BrandOverrides = {`,...Object.entries(a).flatMap(([e,t])=>Z(e,t,` `)),`};`),{name:`brand.phone.ts`,contents:`${o.join(`
|
|
3
|
+
`)}\n`}}function _(e,t){return{size:T(t,e)}}function v(t,n){return e(t)?t[n]:void 0}function y(e,n){return t(e[n],`token path segment ${n}`)}function b(e,n){return t(e.get(n),`phone emitter ${n} list`)}function x(e,n){return t(e.get(n),`phone emitter value for ${n}`).value}function S(e){return e.extensions?.internal===!0?!1:e.platforms===null||e.platforms.includes(`phone`)}function C(e,t){return Error(`Token group ${e} has no phone mapping; mark it web or add one to emit/phone.js (first: ${t})`)}function w(e){let[t,n]=e.path;if(t===`motion`){if(n===`duration`||n===`ease`)return`motion.${n}`;throw C(t,e.path.join(`.`))}let r=t===void 0?void 0:l.get(t);if(r===void 0)throw C(t,e.path.join(`.`));return r}function T(t,n){let r=e(t)?t.value:t;if(typeof r!=`number`||!Number.isFinite(r))throw Error(`Token ${n} has no numeric value`);return r}function E(e){let t=new Map(u.map(e=>[e.key,[]])),n=new Map,r=new Map;for(let i of e){if(!S(i))continue;let e=i.path.join(`.`),a=w(i);if(i.value===void 0||i.value===null)throw Error(`Token ${e} has no phone value`);if(a===`components`){P(i,e,n,r);continue}let o=i.path.slice(a.startsWith(`motion.`)?2:1).join(`-`);n.set(`${a}.${o}`,{path:e,value:D(a,o,i,e),description:i.description}),b(t,a).push(o)}return{lists:t,values:n,components:r}}function D(e,t,n,r){let{value:i}=n;switch(e){case`colors`:return i;case`space`:case`radius`:case`letter-spacing`:case`size`:case`leading`:case`motion.duration`:return T(i,r);case`text`:return{size:T(v(i,`size`),r)};case`weight`:return String(T(i,r));case`font`:return O(n,t);case`shadow`:return k(n,t,r);case`motion.ease`:return j(i,r)}}function O(e,t){if(Array.isArray(e.value)&&e.value.length===1&&e.value[0]===`System`)return{};if(!e.extensions?.faces)throw Error(`Font ${t} is not the system font and has no faces`);return e.extensions.faces}function k(t,n,r){let i=t.value;if(!e(i))throw Error(`Shadow ${n} has no shadow value`);let{hex:a,opacity:o}=A(i.color,r),s=t.extensions?.elevation;if(typeof s!=`number`||!Number.isFinite(s))throw Error(`Shadow ${n} has no elevation`);return{shadowColor:a,shadowOffset:{width:T(i.offsetX,r),height:T(i.offsetY,r)},shadowOpacity:o,shadowRadius:T(i.blur,r),elevation:s}}function A(e,t){let n=typeof e==`string`?i.exec(e):null;if(n){let e=n[1],r=n[2];if(e===void 0)throw Error(`Shadow ${t} colour has no digits`);let i=r===void 0?1:Math.round(parseInt(r,16)/255*1e3)/1e3;return{hex:`#${e.toLowerCase()}`,opacity:i}}let r=typeof e==`string`?a.exec(e):null;if(r)return{hex:`#${r.slice(1,4).map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`,opacity:Number(r[4])};throw Error(`Shadow ${t} colour is not #RRGGBB, #RRGGBBAA or rgba(): ${String(e)}`)}function j(e,t){if(!Array.isArray(e)||e.length!==4||!e.every(e=>Number.isFinite(e)))throw Error(`Token ${t} has no phone value`);return[...e]}function M(e){return e!==void 0&&o.includes(e)}function N(e,n){return t(e.props.get(n),`component prop ${n} kind`)}function P(e,t,n,r){let i=e.path,a=i.length===4;if(i.length!==3&&!a||a&&!M(i[2]))throw Error(`Component token ${t} ${s}`);let o=y(i,1),c=y(i,i.length-1),{kind:l,value:u}=F(e,t),d=r.get(o);if(d===void 0&&(d={props:new Map,sizes:new Map,free:new Map},r.set(o,d)),d.props.has(c)&&d.props.get(c)!==l)throw Error(`Component ${o} prop ${c} has two kinds`);if(d.props.set(c,l),a){let r=y(i,2),a=d.sizes.get(r);a===void 0&&(a=new Map,d.sizes.set(r,a)),a.set(c,u),n.set(`components.${o}.${r}.${c}`,{path:t,value:u,description:e.description})}else d.free.set(c,u),n.set(`components.${o}.${c}`,{path:t,value:u,description:e.description})}function F(e,t){let{reference:n}=e;for(let[e,t]of[[`space.`,`space`],[`text.`,`text`],[`radius.`,`radius`]])if(n?.startsWith(e))return{kind:t,value:n.slice(e.length)};if(!n){if(e.type===`dimension`)return{kind:`px`,value:T(e.value,t)};if(e.type===`number`)return{kind:`number`,value:T(e.value,t)};if(e.type===`duration`)return{kind:`ms`,value:T(e.value,t)}}throw Error(`Component token ${t} has an unsupported value`)}function I(e,t){for(let[n,{path:r}]of e.values)if(!t.values.has(n))throw Error(`Token ${r} exists in one mode only`);for(let[n,{path:r}]of t.values)if(!e.values.has(n))throw Error(`Token ${r} exists in one mode only`)}function L(e,t,n,r){if(Object.hasOwn(e,t)&&JSON.stringify(e[t])!==JSON.stringify(n))throw Error(`A brand sets ${r} differently in light and dark`);e[t]=n}function R(e){return`A brand overrides colours, radius and fonts only; ${e} differs`}function z(e){return r.test(e)?e:JSON.stringify(e)}function B(e,t){let n=`export type ${e.typeName} = (typeof ${e.constName})[number];`;return t.length<=12?[`export const ${e.constName} = [${t.map(e=>JSON.stringify(e)).join(`, `)}] as const;`,n]:[`export const ${e.constName} = [`,...t.map(e=>` ${JSON.stringify(e)},`),`] as const;`,n]}var V=140;function H(e,t){return t.map(t=>`${z(t)}: ${d[N(e,t)]}`)}function U(e){return e.split(/[^A-Za-z0-9]+/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function W(e,t){return[`export interface ${e} {`,...t.map(e=>` ${e};`),`}`]}function G(e){let t=[],n=[];for(let[r,i]of e){let e=H(i,[...i.free.keys()]),a=H(i,[...new Set([...i.sizes.values()].flatMap(e=>[...e.keys()]))]),s=o.filter(e=>i.sizes.has(e)),c=s.join()===`sm,md,lg`?`L3`:s.map(e=>JSON.stringify(e)).join(` | `),l=e=>`{ ${e.join(`; `)} }`,u=(t,n)=>a.length===0?n:`Sized<${c}, ${t}>${e.length>0?` & ${n}`:``}`,d=` ${z(r)}: ${u(l(a),l(e))};`;if(d.length<=V){n.push(d);continue}let f=U(r);a.length>0&&t.push(...W(`${f}SizeTokens`,a)),e.length>0&&t.push(...W(`${f}Tokens`,e)),n.push(` ${z(r)}: ${u(`${f}SizeTokens`,`${f}Tokens`)};`)}let r=[...t,`export interface ComponentTokens {`,...n];return r.push(`}`,`export type ComponentName = keyof ComponentTokens;`,`type SizeKeysOf<C extends ComponentName> = Extract<keyof ComponentTokens[C], "xs" | "sm" | "md" | "lg" | "xl">;`,`export type ComponentSizeTokens<C extends ComponentName> = ComponentTokens[C][SizeKeysOf<C>];`),r}function K(e){let t=[`export const COMPONENT_KINDS = {`];for(let[n,r]of e){let e=[...r.props].map(([e,t])=>`${z(e)}: ${JSON.stringify(t)}`),i=` ${z(n)}: { ${e.join(`, `)} },`;i.length<=V?t.push(i):t.push(` ${z(n)}: {`,...e.map(e=>` ${e},`),` },`)}return t.push(`} as const satisfies { readonly [C in ComponentName]: Readonly<Record<string, ComponentKind>> };`),t}function q(e){let t={};for(let[n,r]of e){let e={};for(let t of o){let n=r.sizes.get(t);n!==void 0&&(e[t]=Object.fromEntries(n))}for(let[t,n]of r.free)e[t]=n;t[n]=e}return t}function J(e,t){let{lists:n}=t,r=(e,n)=>Object.fromEntries(n.map(n=>[n,x(t.values,`${e}.${n}`)]));return{mode:e,colors:r(`colors`,b(n,`colors`)),space:r(`space`,b(n,`space`)),radius:r(`radius`,b(n,`radius`)),text:r(`text`,b(n,`text`)),weight:r(`weight`,b(n,`weight`)),leading:r(`leading`,b(n,`leading`)),"letter-spacing":r(`letter-spacing`,b(n,`letter-spacing`)),font:r(`font`,b(n,`font`)),shadow:r(`shadow`,b(n,`shadow`)),motion:{duration:r(`motion.duration`,b(n,`motion.duration`)),ease:r(`motion.ease`,b(n,`motion.ease`))},size:r(`size`,b(n,`size`)),components:q(t.components)}}function Y(e,t,n){let r=J(t,n);return[`export const ${e}: TokenSet = {`,...Object.entries(r).flatMap(([e,t])=>Z(e,t,` `)),`};`]}function X(e){return Array.isArray(e)?`[${e.map(e=>X(e)).join(`, `)}]`:JSON.stringify(e)}function Z(e,t,n){let r=`${n}${z(e)}`;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=Object.entries(t);return e.length===0?[`${r}: {},`]:[`${r}: {`,...e.flatMap(([e,t])=>Z(e,t,`${n} `)),`${n}},`]}return[`${r}: ${X(t)},`]}export{g as emitPhoneBrand,h as emitPhoneTheme,m as phoneSets};
|
package/dist/emit/web.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Model } from "../model/index.ts";
|
|
2
|
-
/** Library mode: the token SCSS and the Bootstrap variables, references kept as var(). */
|
|
2
|
+
/** Library mode: the token SCSS and the Bootstrap variables, references kept as var(), and the opt-in media blocks. */
|
|
3
3
|
export interface LibraryWebFiles {
|
|
4
4
|
tokens: string;
|
|
5
5
|
bootstrap: string;
|
|
6
|
+
/** The contrast and print blocks, in their own file, so the tokens file does not change. */
|
|
7
|
+
modes: string;
|
|
6
8
|
}
|
|
7
9
|
/** Brand mode: only what differs from the library, as brand.css and _brand-variables.scss. */
|
|
8
10
|
export interface BrandWebFiles {
|
|
@@ -10,7 +12,7 @@ export interface BrandWebFiles {
|
|
|
10
12
|
variables: string;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
|
-
* Library mode returns the tokens and
|
|
15
|
+
* Library mode returns the tokens, bootstrap and modes SCSS. Brand mode returns the brand CSS and variables that differ from the library.
|
|
14
16
|
*/
|
|
15
17
|
export declare function emitWeb(model: Model): LibraryWebFiles;
|
|
16
18
|
export declare function emitWeb(model: Model, options: {
|
package/dist/emit/web.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
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
|
|
2
|
-
|
|
3
|
-
[data-bs-theme
|
|
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,contrast:`standard`,medium:`screen`},l={mode:`dark`,platform:`web`,width:1440,contrast:`standard`,medium:`screen`},u={mode:`light`,platform:`web`,width:390,contrast:`standard`,medium:`screen`},d={mode:`light`,platform:`web`,width:1440,contrast:`more`,medium:`screen`},f={mode:`light`,platform:`web`,width:1440,contrast:`standard`,medium:`print`},p=`:root,
|
|
2
|
+
[data-theme],
|
|
3
|
+
[data-bs-theme]`,ee=/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g,te=/^\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}$/,ne=/^#[0-9a-f]{6}$/i,m=[[`--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`]],h=[[`--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`]],g=[[`--bs-secondary-rgb`,`text-muted`]],_=[[`$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`]],re=[[`$primary`,`color.primary`],[`$link-color`,`color.link`],[`$link-hover-color`,`color.link-hover`]],ie={"$border-color-translucent":`rgba(13, 24, 43, 0.08)`},v=[`color.link`,`color.link-hover`],y=`:root[data-theme="dark"],
|
|
4
|
+
:root[data-bs-theme="dark"]`,b=`[data-theme="dark"]:not(:root),
|
|
5
|
+
[data-bs-theme="dark"]:not(:root)`,x=`:root[data-theme="auto"]`,S=`:root[data-theme="dark"] [data-theme="light"],
|
|
4
6
|
:root[data-theme="dark"] [data-bs-theme="light"],
|
|
5
7
|
:root[data-bs-theme="dark"] [data-theme="light"],
|
|
6
|
-
:root[data-bs-theme="dark"] [data-bs-theme="light"]`,
|
|
7
|
-
:root[data-theme="auto"] [data-bs-theme="light"]`,
|
|
8
|
+
:root[data-bs-theme="dark"] [data-bs-theme="light"]`,C=`:root[data-theme="auto"] [data-theme="light"],
|
|
9
|
+
:root[data-theme="auto"] [data-bs-theme="light"]`,w=`[data-theme="dark"]:not(:root) [data-theme="light"],
|
|
8
10
|
[data-theme="dark"]:not(:root) [data-bs-theme="light"],
|
|
9
11
|
[data-bs-theme="dark"]:not(:root) [data-theme="light"],
|
|
10
|
-
[data-bs-theme="dark"]:not(:root) [data-bs-theme="light"]`,
|
|
12
|
+
[data-bs-theme="dark"]:not(:root) [data-bs-theme="light"]`,ae=`// var() resolves where a name is declared, so the html copies keep the light values for a light box.`,oe=`/* var() resolves where a name is declared, so the html copies keep the light values for a light box. */`,T=`// Zero specificity, so a component's own class on a themed section or inside it keeps its colour.`,E=`/* Zero specificity, so a component's own class on a themed section or inside it keeps its colour. */`,D=`// A light box under a dark page root takes literal light values: var() would resolve against the dark root.`,O=`/* A light box under a dark page root takes literal light values: var() would resolve against the dark root. */`;function k(e){return String(Number(e.toFixed(4)))}function A(e,t){return s(e.tokens.get(t),`token ${t}`)}function se(e){if(e==null)return 1440;if(typeof e==`number`)return e;throw Error(`emitWeb: fluidUntil must be a number`)}function j(t,n){if(typeof n==`string`)return n.replace(ee,(e,t)=>`var(${o(t)})`);if(typeof n==`number`)return k(n);if(Array.isArray(n)){if(t.type===`cubicBezier`&&n.length===4&&n.every(e=>typeof e==`number`))return`cubic-bezier(${n.map(e=>k(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`${k(n.value)}${String(n.unit)}`;if(`color`in n)return[n.offsetX,n.offsetY,n.blur,n.spread,n.color].map(e=>j(t,e)).join(` `)}throw Error(`emitWeb: ${t.path}: cannot write a ${t.type} value as CSS.`)}function M(e,t,n){return j(A(e,t),e.valueIn(t,n))}function N(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 ce(e,t){let n=A(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=N(t,e.valueIn(t,u)),s=N(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,se(l)),tiers:[]}}let s=r(n);return s.length>0?{path:t,name:a,root:M(e,t,u),tiers:s.map(e=>({tier:e.tier,text:j(n,e.value)}))}:{path:t,name:a,root:M(e,t,c),tiers:[]}}function P(e){let t=[];for(let n of e.tokens.keys())e.existsIn(n,c)&&t.push(ce(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=M(e,i,l);if(a.group===`text`){if(s!==M(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:M(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=W(e,r,l);if(t(r,s)){let t=i?I(W(e,r,c)):null;n.push({name:a,text:I(s),light:t})}}};return r(h,!0),r(g,!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=W(e,`color.primary`,t);return[{name:`--bs-primary`,text:n},{name:`--bs-primary-rgb`,text:I(n)}]}function B(e){return!e.tokens.has(`color.primary-text`)||!e.tokens.has(`color.primary`)?!1:[c,l].some(t=>W(e,`color.primary-text`,t)!==W(e,`color.primary`,t))}function V(e,t,n){return!v.every(n=>e.tokens.has(n)&&t.tokens.has(n))||v.every(r=>e.resolvedIn(r,n)===t.resolvedIn(r,n))?[]:H(e,n)}function H(e,t){let n=W(e,`color.link`,t),r=W(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 U(e){return v.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(W(e,`color.link`,l)),light:I(W(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(W(e,`color.link-hover`,l)),light:I(W(e,`color.link-hover`,c))}]:[]}function W(e,t,n){let r=e.resolvedIn(t,n);if(typeof r!=`string`||!ne.test(r))throw Error(`emitWeb: ${t}: a Bootstrap rgb triplet needs an opaque colour.`);return r}function G(e,t){let n=F(e,t?(e,n)=>!t.tokens.has(e)||!t.existsIn(e,l)||n!==M(t,e,l):(t,n)=>n!==M(e,t,c)),r=L(e,t?(e,n)=>n!==t.resolvedIn(e,l):()=>!0);if(t){let i=V(e,t,c).length>0?H(e,l):V(e,t,l);return[...n,...r,...i]}let i=m.map(([e,t])=>{let n=`var(${o(`color.${t}`)})`;return{name:e,text:n,light:n}});return[...n,...i,...r,...U(e)]}function K(e,t,n){return e.tokens.has(n)&&t.tokens.has(n)&&e.resolvedIn(n,c)!==t.resolvedIn(n,c)}function le(e,t){let n=m.filter(([n,r])=>n!==`--bs-primary`&&K(e,t,`color.${r}`)).map(([e,t])=>({name:e,text:`var(${o(`color.${t}`)})`})),r=h.filter(([n,r])=>n!==`--bs-primary-rgb`&&K(e,t,`color.${r}`)).map(([t,n])=>({name:t,text:I(W(e,`color.${n}`,c))}));return[...n,...r]}function q(e,t){return`${e} {\n${t.join(`
|
|
11
13
|
`).split(`
|
|
12
14
|
`).map(e=>e===``?e:` ${e}`).join(`
|
|
13
|
-
`)}\n}`}var
|
|
15
|
+
`)}\n}`}var ue=`/* Bootstrap's text and link helpers read --bs-primary-rgb, the fill; these read the primary text token. */`,de=[q(`.text-primary`,[`color: color-mix(in srgb, var(--color-primary-text) calc(var(--bs-text-opacity, 1) * 100%), transparent) !important;`]),q(`.link-primary`,[`color: color-mix(in srgb, var(--color-primary-text) calc(var(--bs-link-opacity, 1) * 100%), transparent) !important;`,`text-decoration-color: color-mix(
|
|
14
16
|
in srgb,
|
|
15
17
|
var(--color-primary-text) calc(var(--bs-link-underline-opacity, 1) * 100%),
|
|
16
18
|
transparent
|
|
@@ -18,13 +20,15 @@ import{isObjectLike as e}from"../guards.js";import{BREAKPOINT_PX as t,TOUCH_MEDI
|
|
|
18
20
|
|
|
19
21
|
`);function J(e){return e.split(`,
|
|
20
22
|
`).map(e=>`:where(${e})`).join(`,
|
|
21
|
-
`)}function
|
|
22
|
-
`)}\n);`,
|
|
23
|
+
`)}function fe(e,t){let n=G(e,null).filter(e=>e.light!=null);if(!t)return n;let r=new Map(G(t,null).filter(e=>e.light!=null).map(e=>[e.name,e.light]));return n.filter(e=>r.get(e.name)!==e.light)}function pe(e,t){if(e.length===0)return[];let n=e.map(e=>`${e.name}: ${String(e.light)};`);return[t?O:D,q(S,n),q(J(S),[`color-scheme: light;`,`color: var(--color-text);`]),q(`@media (prefers-color-scheme: dark)`,[q(C,n),q(J(C),[`color-scheme: light;`,`color: var(--color-text);`])])]}function me(e){let t=[];for(let n=0;n<e.length;n+=6)t.push(e.slice(n,n+6).join(`, `));return[`$wui-dark-layer-names: (\n${t.map((e,n)=>` ${e}${n<t.length-1?`,`:``}`).join(`
|
|
24
|
+
`)}\n);`,ae,q(`html`,[`@each $name in $wui-dark-layer-names {`,` --wui-light-#{$name}: var(--#{$name});`,`}`]),q(w,[`@each $name in $wui-dark-layer-names {`,` --#{$name}: var(--wui-light-#{$name});`,`}`]),q(J(w),[`color-scheme: light;`,`color: var(--color-text);`])].join(`
|
|
23
25
|
|
|
24
|
-
`)}function
|
|
26
|
+
`)}function he(e){return[oe,q(`html`,e.map(e=>`--wui-light-${e}: var(--${e});`)),q(w,e.map(e=>`--${e}: var(--wui-light-${e});`)),q(J(w),[`color-scheme: light;`,`color: var(--color-text);`])].join(`
|
|
25
27
|
|
|
26
|
-
`)}function
|
|
28
|
+
`)}function Y(e,t,n=!1){let{package:r,version:i,brand:a}=e.source,o=t?`Generated by ${r} ${i} for the ${a} brand. Do not edit; run webority brand.`:`Generated by ${r} ${i} from its token source. Do not edit; run webority brand --library.`;return n?`/* ${o} */`:`// ${o}`}function X(e,r){let i=P(e),o=new Map((r?P(r):[]).map(e=>[e.path,e])),s=[],l=i.filter(e=>o.get(e.path)?.root!==e.root).map(e=>`${e.name}: ${e.root};`);r&&(l.push(...R(e,r,c).map(e=>`${e.name}: ${e.text};`)),l.push(...V(e,r,c).map(e=>`${e.name}: ${e.text};`)),l.push(...le(e,r).map(e=>`${e.name}: ${e.text};`))),l.length>0&&s.push(q(`:root`,l));for(let[e,n]of Object.entries(t)){let t=[];for(let n of i)for(let r of n.tiers)r.tier===e&&o.get(n.path)?.tiers.find(t=>t.tier===e)?.text!==r.text&&t.push(`${n.name}: ${r.text};`);t.length>0&&s.push(q(`@media (min-width: ${n}px)`,[q(`:root`,t)]))}let u=[];for(let t of i){let n=A(e,t.path),i=a(n);if(i===null)continue;let o=j(n,i),s=r?.tokens.get(t.path),c=s?a(s):null;s&&c!==null&&j(s,c)===o||u.push(`${t.name}: ${o};`)}u.length>0&&s.push(q(`@media ${n}`,[q(`:root`,u)]));let d=G(e,r);if(d.length>0){let t=d.map(e=>`${e.name}: ${e.text};`),n=r?E:T;s.push(q(y,[...t,`color-scheme: dark;`]),q(b,t),`${n}\n${q(J(b),[`color-scheme: dark;`,`color: var(--color-text);`])}`);let i=d.map(e=>e.name.slice(2));if(r){let e=new Set(G(r,null).map(e=>e.name.slice(2))),t=i.filter(t=>!e.has(t));t.length>0&&s.push(he(t))}else s.push(me(i));s.push(q(`@media (prefers-color-scheme: dark)`,[q(x,[...t,`color-scheme: dark;`])])),s.push(...pe(fe(e,r),r!==null))}return r!==null&&B(e)&&s.push(`${ue}\n${de}`),`${[Y(e,r!==null,r!==null),...s].join(`
|
|
27
29
|
|
|
28
|
-
`)}\n`}function
|
|
29
|
-
`)}\n`}function
|
|
30
|
-
`)}\n`}function
|
|
30
|
+
`)}\n`}function Z(e,t){let n=A(e,t);if(n.type===`color`)return String(e.resolvedIn(t,c));let r=e.valueIn(t,c),i=(typeof r==`string`?te.exec(r):null)?.[1];if(i!==void 0)return Z(e,i);let a=j(n,r);if(a.includes(`var(`))throw Error(`emitWeb: ${t}: a Bootstrap variable needs a literal.`);return a}function Q(e,t,n){return n===null?ie[t]:Z(e,n)}function ge(e){let t=_.map(([t,n])=>`${t}: ${String(Q(e,t,n))} !default;`);return`${[Y(e,!1),...t].join(`
|
|
31
|
+
`)}\n`}function _e(e,t){let n=[...re,..._].filter(([n,r])=>Q(e,n,r)!==Q(t,n,r)),r=n.map(([t,n])=>`${t}: ${String(Q(e,t,n))};`),i=n.map(([e])=>e),a=i.length===0?[]:[`@use "@webority/theme/scss/config" with (`,...i.map((e,t)=>` ${e}: ${e}${t<i.length-1?`,`:``}`),`);`];return`${[Y(e,!0),...r,...a].join(`
|
|
32
|
+
`)}\n`}function $(e,t){let n=new Set(t.medium===`print`?G(e,null).flatMap(e=>e.path===void 0?[]:[e.path]):[]),i=[];for(let[a,s]of e.tokens){if(!e.existsIn(a,c)||!e.existsIn(a,t)||r(s).length>0)continue;let l=M(e,a,t),u=M(e,a,c);if(s.group===`text`){if(l!==u)throw Error(`emitWeb: ${a}: a text size cannot change in a contrast or print context.`)}else(l!==u||n.has(a))&&i.push({name:o(a),text:`${l} !important`})}return i}function ve(e){return[...h,...g,[`--bs-link-color-rgb`,`link`],[`--bs-link-hover-color-rgb`,`link-hover`]].map(([t,n])=>({name:t,text:`${I(W(e,`color.${n}`,f))} !important`}))}function ye(e){let t=e=>e.map(e=>`${e.name}: ${e.text};`);return[q(`@media (prefers-contrast: more)`,[q(p,t($(e,d)))]),q(`@media print`,[q(p,[...t($(e,f)),...t(ve(e)),`color-scheme: light !important;`])])]}function be(e){return`${[Y(e,!1),...ye(e)].join(`
|
|
33
|
+
|
|
34
|
+
`)}\n`}function xe(e,t){return t===void 0?{tokens:X(e,null),bootstrap:ge(e),modes:be(e)}:{css:X(e,t.library),variables:_e(e,t.library)}}export{xe as emitWeb};
|
package/dist/meanings.json
CHANGED
package/dist/model/contrast.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=4.55,t=/^#[0-9a-f]{6}$/i,n=.0025,r=e=>{let t=Number.parseInt(e.slice(1,7),16);return[t>>16&255,t>>8&255,t&255]},i=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},a=e=>{let[t,n,a]=r(e);return .2126*i(t)+.7152*i(n)+.0722*i(a)},o=e=>{let[t,n,i]=r(e),a=t/255,o=n/255,s=i/255,c=Math.max(a,o,s),l=Math.min(a,o,s),u=c-l,d=(c+l)/2;if(u===0)return[0,0,d];let f=d>.5?u/(2-c-l):u/(c+l);return[(c===a?((o-s)/u+6)%6:c===o?(s-a)/u+2:(a-o)/u+4)*60,f,d]},s=([e,t,n])=>{let r=t*Math.min(n,1-n),i=t=>{let i=(t+e/30)%12,a=n-r*Math.max(-1,Math.min(i-3,9-i,1));return Math.round(a*255).toString(16).padStart(2,`0`)};return`#${i(0)}${i(8)}${i(4)}`.toUpperCase()},c=(e,t,r)=>{let[i,a,c]=o(e),l=e;for(let e=c+t*n;e>=0&&e<=1;e+=t*n)if(l=s([i,a,e]),r(l))return l;return l};function l(e,t){let n=a(e),r=a(t),i=Math.max(n,r),o=Math.min(n,r);return(i+.05)/(o+.05)}function u(n,r){if(!t.test(n)||!t.test(r))return n;let i=t=>l(t,r)>=e;return i(n)?n.toLowerCase():c(n,a(r)>a(n)?-1:1,i).toLowerCase()}function d(e,t){let n={};for(let r of[`light`,`dark`]){let i={mode:r,platform:`phone`,width:null};if(![`color.primary`,`color.on-primary`].every(n=>e.existsIn(n,i)&&t.existsIn(n,i)))continue;let a=String(e.resolvedIn(`color.primary`,i)),o=String(e.resolvedIn(`color.on-primary`,i));if(a===t.resolvedIn(`color.primary`,i)&&o===t.resolvedIn(`color.on-primary`,i))continue;let s=u(a,o);s!==a.toLowerCase()&&(n[r]={color:{primary:{$type:`color`,$value:s}}})}return{light:n.light??{},dark:n.dark??{}}}export{e as READABLE_TARGET,l as contrastRatio,u as deriveSolidFill,d as phonePairLayer};
|
|
1
|
+
var e=4.55,t=/^#[0-9a-f]{6}$/i,n=.0025,r=e=>{let t=Number.parseInt(e.slice(1,7),16);return[t>>16&255,t>>8&255,t&255]},i=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},a=e=>{let[t,n,a]=r(e);return .2126*i(t)+.7152*i(n)+.0722*i(a)},o=e=>{let[t,n,i]=r(e),a=t/255,o=n/255,s=i/255,c=Math.max(a,o,s),l=Math.min(a,o,s),u=c-l,d=(c+l)/2;if(u===0)return[0,0,d];let f=d>.5?u/(2-c-l):u/(c+l);return[(c===a?((o-s)/u+6)%6:c===o?(s-a)/u+2:(a-o)/u+4)*60,f,d]},s=([e,t,n])=>{let r=t*Math.min(n,1-n),i=t=>{let i=(t+e/30)%12,a=n-r*Math.max(-1,Math.min(i-3,9-i,1));return Math.round(a*255).toString(16).padStart(2,`0`)};return`#${i(0)}${i(8)}${i(4)}`.toUpperCase()},c=(e,t,r)=>{let[i,a,c]=o(e),l=e;for(let e=c+t*n;e>=0&&e<=1;e+=t*n)if(l=s([i,a,e]),r(l))return l;return l};function l(e,t){let n=a(e),r=a(t),i=Math.max(n,r),o=Math.min(n,r);return(i+.05)/(o+.05)}function u(n,r){if(!t.test(n)||!t.test(r))return n;let i=t=>l(t,r)>=e;return i(n)?n.toLowerCase():c(n,a(r)>a(n)?-1:1,i).toLowerCase()}function d(e,t){let n={};for(let r of[`light`,`dark`]){let i={mode:r,platform:`phone`,width:null,contrast:`standard`,medium:`screen`};if(![`color.primary`,`color.on-primary`].every(n=>e.existsIn(n,i)&&t.existsIn(n,i)))continue;let a=String(e.resolvedIn(`color.primary`,i)),o=String(e.resolvedIn(`color.on-primary`,i));if(a===t.resolvedIn(`color.primary`,i)&&o===t.resolvedIn(`color.on-primary`,i))continue;let s=u(a,o);s!==a.toLowerCase()&&(n[r]={color:{primary:{$type:`color`,$value:s}}})}return{light:n.light??{},dark:n.dark??{}}}export{e as READABLE_TARGET,l as contrastRatio,u as deriveSolidFill,d as phonePairLayer};
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { BrandInput } from "./load.ts";
|
|
2
2
|
export type Mode = "light" | "dark";
|
|
3
3
|
export type Platform = "web" | "phone";
|
|
4
|
+
export type Contrast = "standard" | "more";
|
|
5
|
+
export type Medium = "screen" | "print";
|
|
4
6
|
export interface Context {
|
|
5
7
|
mode: Mode;
|
|
6
8
|
platform: Platform;
|
|
7
9
|
width: number | null;
|
|
10
|
+
contrast: Contrast;
|
|
11
|
+
medium: Medium;
|
|
8
12
|
}
|
|
9
13
|
export interface Token {
|
|
10
14
|
/** dotted path, such as "color.text-muted" */
|
|
@@ -27,7 +31,7 @@ export interface Token {
|
|
|
27
31
|
export interface Model {
|
|
28
32
|
/** every path declared by the base set (and the brand file) */
|
|
29
33
|
tokens: Map<string, Token>;
|
|
30
|
-
/** light and dark x web at 1440 and 390,
|
|
34
|
+
/** light and dark x web at 1440 and 390, light and dark x phone, then the more-contrast light and dark and the print light at 1440 */
|
|
31
35
|
contexts: Context[];
|
|
32
36
|
existsIn: (path: string, context: Context) => boolean;
|
|
33
37
|
/** $value after overrides, references kept */
|
package/dist/model/load.d.ts
CHANGED
package/dist/model/load.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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{messageOf as n}from"../guards.js";import{STEPS as r,cssVarOfPath as i}from"../names.js";import{present as a}from"../present.js";import{readFile as o}from"node:fs/promises";import{basename as s,dirname as c,resolve as l}from"node:path";var
|
|
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{messageOf as n}from"../guards.js";import{STEPS as r,cssVarOfPath as i}from"../names.js";import{present as a}from"../present.js";import{readFile as o}from"node:fs/promises";import{basename as s,dirname as c,resolve as l}from"node:path";var ee=e(t(),1),te=new URL(`../../package.json`,import.meta.url),ne=new URL(`../../schema/webority-tokens.schema.json`,import.meta.url),u=`Declare each token in one source file.`;function d(e,t,n,r){return`${e}: ${t}: ${n}. ${r}`}function f(e,t){e.includes(t)||e.push(t)}function p(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m(e){return p(e)&&typeof e.$ref==`string`}function h(e){return Array.isArray(e)&&e.every(e=>e===`web`||e===`phone`)}var g=e=>Object.hasOwn(r,e);function _(e){let t=e.$extensions;if(!p(t))return{};let n=t[`com.webority`];return p(n)?n:{}}function v(e){let t=[],n=(e,r,i)=>{for(let[a,o]of Object.entries(e)){if(a.startsWith(`$`)||!p(o))continue;let e=[...r,a],s=typeof o.$type==`string`?o.$type:i.type,c={...i.extensions,..._(o)};`$value`in o?t.push({path:e.join(`.`),token:o,type:s,extensions:c}):n(o,e,{type:s,extensions:c})}};return n(e,[],{type:void 0,extensions:{}}),t}function y(e,t){let[n,...r]=e.path.split(`.`),i=e.extensions;return{path:e.path,group:a(n,`the token group`),name:r.join(`-`),type:t,description:typeof e.token.$description==`string`?e.token.$description:null,platforms:h(i.platforms)?i.platforms:null,internal:i.internal===!0,brandOwn:!1,extensions:i}}function b(e,t,n,a){let{path:o,group:s,name:c}=e,l;try{l=i(o)}catch{f(n,d(t,o,`its group ${s} has no CSS prefix`,`Add the group to PREFIX in names.ts.`))}if(g(s)&&!r[s].includes(c)&&f(n,d(t,o,`"${c}" is not a step of ${s}`,`Use one of: ${r[s].join(`, `)}.`)),l!==void 0){let e=a.get(l);e===void 0?a.set(l,o):e!==o&&f(n,d(t,o,`its CSS name ${l} is also the name of ${e}`,`Rename one of the two tokens.`))}}function x(e,t,n,r){let i={...e.extensions};return(i.platforms!==void 0||i.internal!==void 0)&&(f(r,d(t,e.path,`changes the platforms or internal mark`,`Set marks in the base set only.`)),delete i.platforms,delete i.internal),Object.assign(n.extensions,i),{value:e.token.$value,file:t}}function S(e,t,n){f(e,d(t,n,`overrides a token the base set does not declare`,`Declare ${n} in the base set first.`))}function C(e,t,n){let r=new Map;for(let{ref:i,data:a}of e)if(a)for(let e of v(a)){let a=t.get(e.path);a?r.set(e.path,x(e,i,a,n)):S(n,i,e.path)}return r}async function w(e,t){let r=s(e),i=[],h=c(e),g;try{g=JSON.parse(await o(e,`utf8`))}catch(e){throw Error(d(r,`(file)`,`cannot be read as JSON (${n(e)})`,`Restore the file or correct its path.`))}if(!Array.isArray(g.sets)||g.sets.length===0||!g.sets.every(e=>p(e)&&Array.isArray(e.sources)&&e.sources.every(m)))throw Error(d(r,`sets`,`must be a non-empty array of { sources: [{ "$ref": string }] }`,`Match the resolver of the library source.`));if(!Array.isArray(g.modifiers))throw Error(d(r,`modifiers`,`must be an array`,`Match the resolver of the library source.`));let _=g.sets,w=g.modifiers,T=[[`mode`,[`light`,`dark`]],[`platform`,[`web`,`phone`]],[`width`,[`1440`,`390`]],[`contrast`,[`standard`,`more`]],[`medium`,[`screen`,`print`]]];if(w.length!==T.length)throw Error(d(r,`modifiers`,`must hold the mode, platform, width, contrast and medium modifiers, in that order`,`Match the resolver of the library source.`));let re=e=>Array.isArray(e)&&e.length===0;T.forEach(([e,t],n)=>{let i=w[n],o=p(i)&&p(i.contexts)?i.contexts:void 0,s=o===void 0?``:Object.keys(o).sort().join(`,`);if(!(p(i)&&o!==void 0&&i.name===e&&s===[...t].sort().join(`,`)&&t.every(e=>{let t=o[e];return Array.isArray(t)&&t.every(m)})&&re(o[a(t[0],`the default context of the ${e} modifier`)])))throw Error(d(r,`modifiers.${e}`,`is not the ${e} modifier with the contexts ${t.join(`, `)} and an empty list for ${t[0]}`,`Match the resolver of the library source, whose default context lists no file.`))});let E=(e,t)=>a(w.find(t=>t.name===e),`the ${e} modifier`).contexts[t],D=_.flatMap(e=>e.sources.map(e=>e.$ref)),O=E(`mode`,`dark`).map(e=>e.$ref),k=E(`platform`,`phone`).map(e=>e.$ref),A=E(`width`,`390`).map(e=>e.$ref),ie=E(`contrast`,`more`).map(e=>e.$ref),ae=E(`medium`,`print`).map(e=>e.$ref),j=JSON.parse(await o(ne,`utf8`)),M=new ee.default({allErrors:!0,strict:!1});M.addSchema(j);let N=M.compile(j),P=M.getSchema(`${j.$id}#/$defs/sourceMeaning`);if(!P)throw Error(`webority-tokens: the schema has no sourceMeaning definition.`);let F=new Map,I=async e=>{let t=l(h,e);if(F.has(t))return a(F.get(t),`the cached file ${t}`);let r;try{r=JSON.parse(await o(t,`utf8`))}catch(r){return f(i,d(e,`(file)`,`cannot be read as JSON (${n(r)})`,`Restore the file or correct its $ref in the resolver.`)),F.set(t,null),null}let c=[];N(r)||c.push(...N.errors??[]),s(t)===`meaning.tokens.json`&&!P(r)&&c.push(...P.errors??[]);for(let t of c){if(t.keyword===`if`)continue;let n=t.instancePath.slice(1).split(`/`).filter(e=>e!==``),r=n.length===0?`(file)`:n.map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)).join(`.`),a=t.params?.additionalProperty??t.params?.propertyName,o=a===void 0?String(t.message):`${String(t.message)} "${a}"`;f(i,d(e,r,o,`Correct it against schema/webority-tokens.schema.json.`))}return F.set(t,r),r},L=async e=>Promise.all(e.map(async e=>({ref:e,data:await I(e)}))),R=await L(D),z=await L(O),B=await L(k),V=await L(A),H=await L(ie),U=await L(ae),W=new Map,G=new Map,K=new Map;for(let{ref:e,data:t}of R)if(t)for(let n of v(t)){if(W.has(n.path)){f(i,d(e,n.path,`is already declared in ${a(K.get(n.path),`the base entry at ${n.path}`).file}`,u));continue}if(n.type===void 0||n.type===``){f(i,d(e,n.path,`has no $type`,`Add $type to the token or to its group.`));continue}let t=y(n,n.type);b(t,e,i,G),W.set(n.path,t),K.set(n.path,{value:n.token.$value,file:e})}let q=C(z,W,i),oe=C(B,W,i),se=C(V,W,i),ce=C(H,W,i),le=C(U,W,i),J=new Map,Y=new Map,X=new Map,Z=new Map;if(t){let e=`brand ${t.name}`;for(let n of v(t.base)){let t=W.get(n.path);if(t){J.set(n.path,x(n,e,t,i));continue}if(n.type===void 0||n.type===``){f(i,d(e,n.path,`has no $type`,`Add $type to the token or to its group.`));continue}let r=y(n,n.type);b(r,e,i,G),r.brandOwn=!0,W.set(n.path,r),J.set(n.path,{value:n.token.$value,file:e})}for(let n of v(t.dark)){let t=W.get(n.path);t?Y.set(n.path,x(n,e,t,i)):S(i,e,n.path)}let n=[[t.phone?.light,X],[t.phone?.dark,Z]];for(let[t,r]of n)if(p(t))for(let n of v(t)){let t=W.get(n.path);t?r.set(n.path,x(n,e,t,i)):S(i,e,n.path)}}let Q=JSON.parse(await o(te,`utf8`)),$={package:Q.name,version:Q.version,brand:t?.name??null};return{tokens:W,layers:{base:K,dark:q,phone:oe,width390:se,contrastMore:ce,print:le,brandBase:J,brandDark:Y,brandPhoneLight:X,brandPhoneDark:Z},cssNames:G,source:$,refusals:i}}export{d as line,w as readSources};
|
package/dist/model/resolve.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{messageOf as e}from"../guards.js";import{cssVarOfPath as t}from"../names.js";import{present as n}from"../present.js";import{resolveColour as r}from"./colour.js";import{line as i}from"./load.js";import{findCycles as a,mapReferences as o,referencesIn as s}from"./references.js";function c(){return[{mode:`light`,platform:`web`,width:1440},{mode:`dark`,platform:`web`,width:1440},{mode:`light`,platform:`web`,width:390},{mode:`dark`,platform:`web`,width:390},{mode:`light`,platform:`phone`,width:null},{mode:`dark`,platform:`phone`,width:null}]}function l(e){return`${e.mode}|${e.platform}|${e.width}`}function u(e,t,n){if(typeof e==`string`)return e;if(typeof e==`number`)return String(e);if(typeof e==`object`&&e&&`value`in e&&`unit`in e)return`${e.value}${e.unit}`;throw Error(`model: ${t} cannot sit inside the text of ${n}`)}function d({tokens:d,layers:f,cssNames:p,source:m,refusals:h}){let g=c(),_=e=>{let t=g.find(t=>t.mode===e.mode&&t.platform===e.platform&&t.width===e.width);if(!t)throw Error(`model: ${JSON.stringify(e)} is not one of the model's contexts`);return t},v=e=>{let t=[f.base];return e.mode===`dark`&&t.push(f.dark),e.platform===`phone`&&t.push(f.phone),e.platform===`web`&&e.width===390&&t.push(f.width390),t.push(f.brandBase),e.mode===`dark`&&t.push(f.brandDark),e.platform===`phone`&&t.push(e.mode===`dark`?f.brandPhoneDark:f.brandPhoneLight),t},y=new Set([f.brandBase,f.brandDark,f.brandPhoneLight,f.brandPhoneDark]),b=(e,t,r)=>r.platform===`phone`&&y.has(e)&&t.startsWith(`font.`)&&!n(d.get(t),`the token at ${t}`).extensions.faces,x=(e,t)=>{let n=v(t).reverse();for(let r of n){if(b(r,e,t)||r===f.brandBase&&
|
|
2
|
-
`));return{tokens:d,contexts:c(),existsIn:(e,t)=>
|
|
1
|
+
import{messageOf as e}from"../guards.js";import{cssVarOfPath as t}from"../names.js";import{present as n}from"../present.js";import{resolveColour as r}from"./colour.js";import{line as i}from"./load.js";import{findCycles as a,mapReferences as o,referencesIn as s}from"./references.js";function c(){return[{mode:`light`,platform:`web`,width:1440,contrast:`standard`,medium:`screen`},{mode:`dark`,platform:`web`,width:1440,contrast:`standard`,medium:`screen`},{mode:`light`,platform:`web`,width:390,contrast:`standard`,medium:`screen`},{mode:`dark`,platform:`web`,width:390,contrast:`standard`,medium:`screen`},{mode:`light`,platform:`phone`,width:null,contrast:`standard`,medium:`screen`},{mode:`dark`,platform:`phone`,width:null,contrast:`standard`,medium:`screen`},{mode:`light`,platform:`web`,width:1440,contrast:`more`,medium:`screen`},{mode:`dark`,platform:`web`,width:1440,contrast:`more`,medium:`screen`},{mode:`light`,platform:`web`,width:1440,contrast:`standard`,medium:`print`}]}function l(e){return`${e.mode}|${e.platform}|${e.width}|${e.contrast}|${e.medium}`}function u(e,t,n){if(typeof e==`string`)return e;if(typeof e==`number`)return String(e);if(typeof e==`object`&&e&&`value`in e&&`unit`in e)return`${e.value}${e.unit}`;throw Error(`model: ${t} cannot sit inside the text of ${n}`)}function d({tokens:d,layers:f,cssNames:p,source:m,refusals:h}){let g=c(),_=e=>{let t=g.find(t=>t.mode===e.mode&&t.platform===e.platform&&t.width===e.width&&t.contrast===e.contrast&&t.medium===e.medium);if(!t)throw Error(`model: ${JSON.stringify(e)} is not one of the model's contexts`);return t},v=e=>{let t=[f.base];return e.mode===`dark`&&t.push(f.dark),e.contrast===`more`&&t.push(f.contrastMore),e.medium===`print`&&t.push(f.print),e.platform===`phone`&&t.push(f.phone),e.platform===`web`&&e.width===390&&t.push(f.width390),t.push(f.brandBase),e.mode===`dark`&&t.push(f.brandDark),e.platform===`phone`&&t.push(e.mode===`dark`?f.brandPhoneDark:f.brandPhoneLight),t},y=new Set([f.brandBase,f.brandDark,f.brandPhoneLight,f.brandPhoneDark]),b=(e,t,r)=>r.platform===`phone`&&y.has(e)&&t.startsWith(`font.`)&&!n(d.get(t),`the token at ${t}`).extensions.faces,x=(e,t)=>t.mode===`dark`&&f.dark.has(e)||t.contrast===`more`&&f.contrastMore.has(e)||t.medium===`print`&&f.print.has(e),S=(e,t)=>{let n=v(t).reverse();for(let r of n){if(b(r,e,t)||r===f.brandBase&&x(e,t))continue;let n=r.get(e);if(n)return n}},C=(e,t)=>n(S(e,t),`the entry for ${e}`),w=(e,t)=>{let n=d.get(e);return n?n.platforms===null||n.platforms.includes(t.platform):!1},T=(e,t)=>{if(!w(e,t))throw Error(`model: ${e} does not exist on ${t.platform}`)},E=new Map,D=(e,i)=>{let a=`${l(i)}|${e}`;if(E.has(a))return E.get(a);T(e,i);let s=n(d.get(e),`the token at ${e}`),{value:c}=C(e,i),f;if(s.type===`color`){if(typeof c!=`string`)throw Error(`model: ${e} is a colour with a value that is not text`);if(s.extensions.derive)throw Error(`model: ${e} uses derive, which is removed; set the colour itself`);let n=String(o(c,e=>`var(${t(e)})`));f=r(n,e=>O(e,i))}else f=o(c,(t,n)=>{let r=D(t,i);return n?r:u(r,t,e)});return E.set(a,f),f},O=(e,t)=>{let r=p.get(e);if(r===void 0||!w(r,t))return;if(n(d.get(r),`the token at ${r}`).type===`color`){let e=D(r,t);return typeof e==`string`?e:void 0}let{value:i}=C(r,t);return typeof i==`string`?i:void 0},k=()=>{for(let e of Object.values(f))for(let[t,n]of e)for(let e of s(n.value))if(!d.has(e)){let r=i(n.file,t,`references ${e}, which no token declares`,`Declare ${e} or correct the name.`);h.includes(r)||h.push(r)}},A=()=>{for(let e of g){let t=new Map;for(let n of d.keys())w(n,e)&&t.set(n,s(C(n,e).value));for(let r of a(t)){let t=n(r[0],`the first token of the cycle`),a=i(C(t,e).file,t,`reference cycle ${r.join(` -> `)}`,`Point one of these tokens at a value instead.`);h.includes(a)||h.push(a)}}},j=()=>{for(let e of g)for(let t of d.keys()){if(!w(t,e))continue;let{file:n,value:r}=C(t,e);for(let a of s(r))if(d.has(a)&&!w(a,e)){let r=i(n,t,`references ${a}, which does not exist on ${e.platform}`,`Mark ${t} for the platform that has ${a}, or give ${t} a ${e.platform} override.`);h.includes(r)||h.push(r)}}},M=()=>{for(let t of g)for(let n of d.keys())if(w(n,t))try{D(n,t)}catch(r){let a=i(C(n,t).file,n,e(r).replace(/\.$/,``),`Correct the value or the tokens it references.`);h.includes(a)||h.push(a)}},N=h.length;k();let P=h.length>N;if(P||A(),P||j(),h.length===0&&M(),h.length>0)throw Error(h.join(`
|
|
2
|
+
`));return{tokens:d,contexts:c(),existsIn:(e,t)=>w(e,_(t)),valueIn:(e,t)=>{let n=_(t);return T(e,n),structuredClone(C(e,n).value)},resolvedIn:(e,t)=>{let n=_(t);return structuredClone(D(e,n))},referenceIn:(e,t)=>{let n=_(t);return T(e,n),s(C(e,n).value)[0]},source:m}}export{c as buildContexts,d as buildModel};
|
package/dist/names.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{present as e}from"./present.js";var t={palette:`--wui-`,color:`--color-`,effect:`--wui-`,space:`--wui-space-`,radius:`--wui-radius-`,text:`--wui-fs-`,weight:`--wui-fw-`,leading:`--wui-lh-`,"letter-spacing":`--wui-letter-spacing-`,font:`--wui-font-`,shadow:`--wui-shadow-`,motion:`--wui-`,section:`--wui-section-`,size:`--wui-`,z:`--wui-z-`,component:`--wui-`},n={space:[`none`,`xxs`,`xs`,`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`,`4xl`],radius:[`none`,`sm`,`md`,`lg`,`xl`,`pill`],text:[`xs`,`sm`,`base`,`lg`,`xl`,`2xl`,`3xl`,`4xl`,`5xl`,`6xl`,`7xl`,`8xl`],weight:[`normal`,`medium`,`semibold`,`bold`],"letter-spacing":[`tight`,`normal`,`wide`],leading:[`heading`,`body`,`display`,`prose`,`lead`]};function r(e,n){let r=t[e];if(r===void 0)throw Error(`webority-tokens: ${e} is not a token group; add it to PREFIX in names.ts.`);return`${r}${n}`}function i(t){let[n,...i]=t.split(`.`);return r(e(n,`the token group`),i.join(`-`))}export{n as STEPS,r as cssVar,i as cssVarOfPath};
|
|
1
|
+
import{present as e}from"./present.js";var t={palette:`--wui-`,color:`--color-`,effect:`--wui-`,space:`--wui-space-`,radius:`--wui-radius-`,text:`--wui-fs-`,weight:`--wui-fw-`,leading:`--wui-lh-`,"letter-spacing":`--wui-letter-spacing-`,font:`--wui-font-`,shadow:`--wui-shadow-`,motion:`--wui-`,section:`--wui-section-`,size:`--wui-`,z:`--wui-z-`,component:`--wui-`},n={space:[`none`,`xxs`,`xs`,`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`,`4xl`],radius:[`none`,`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`,`pill`],text:[`xs`,`sm`,`base`,`lg`,`xl`,`2xl`,`3xl`,`4xl`,`5xl`,`6xl`,`7xl`,`8xl`],weight:[`normal`,`medium`,`semibold`,`bold`],"letter-spacing":[`tight`,`normal`,`wide`],leading:[`heading`,`body`,`display`,`prose`,`lead`]};function r(e,n){let r=t[e];if(r===void 0)throw Error(`webority-tokens: ${e} is not a token group; add it to PREFIX in names.ts.`);return`${r}${n}`}function i(t){let[n,...i]=t.split(`.`);return r(e(n,`the token group`),i.join(`-`))}export{n as STEPS,r as cssVar,i as cssVarOfPath};
|
|
@@ -279,6 +279,17 @@
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
+
},
|
|
283
|
+
"xl": {
|
|
284
|
+
"radius": {
|
|
285
|
+
"$type": "dimension",
|
|
286
|
+
"$value": "{radius.sm}",
|
|
287
|
+
"$extensions": {
|
|
288
|
+
"com.webority": {
|
|
289
|
+
"platforms": ["web"]
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
282
293
|
}
|
|
283
294
|
},
|
|
284
295
|
"label": {
|
|
@@ -593,7 +604,7 @@
|
|
|
593
604
|
"min-height": {
|
|
594
605
|
"$type": "dimension",
|
|
595
606
|
"$value": {
|
|
596
|
-
"value":
|
|
607
|
+
"value": 35,
|
|
597
608
|
"unit": "px"
|
|
598
609
|
}
|
|
599
610
|
},
|
|
@@ -603,7 +614,7 @@
|
|
|
603
614
|
},
|
|
604
615
|
"radius": {
|
|
605
616
|
"$type": "dimension",
|
|
606
|
-
"$value": "{radius.
|
|
617
|
+
"$value": "{radius.lg}",
|
|
607
618
|
"$extensions": {
|
|
608
619
|
"com.webority": {
|
|
609
620
|
"platforms": ["web", "phone"]
|
|
@@ -637,7 +648,7 @@
|
|
|
637
648
|
"min-height": {
|
|
638
649
|
"$type": "dimension",
|
|
639
650
|
"$value": {
|
|
640
|
-
"value":
|
|
651
|
+
"value": 40,
|
|
641
652
|
"unit": "px"
|
|
642
653
|
}
|
|
643
654
|
},
|
|
@@ -647,7 +658,7 @@
|
|
|
647
658
|
},
|
|
648
659
|
"radius": {
|
|
649
660
|
"$type": "dimension",
|
|
650
|
-
"$value": "{radius.
|
|
661
|
+
"$value": "{radius.xl}",
|
|
651
662
|
"$extensions": {
|
|
652
663
|
"com.webority": {
|
|
653
664
|
"platforms": ["web", "phone"]
|
|
@@ -676,12 +687,12 @@
|
|
|
676
687
|
},
|
|
677
688
|
"padding-y": {
|
|
678
689
|
"$type": "dimension",
|
|
679
|
-
"$value": "{space.
|
|
690
|
+
"$value": "{space.sm}"
|
|
680
691
|
},
|
|
681
692
|
"min-height": {
|
|
682
693
|
"$type": "dimension",
|
|
683
694
|
"$value": {
|
|
684
|
-
"value":
|
|
695
|
+
"value": 45,
|
|
685
696
|
"unit": "px"
|
|
686
697
|
}
|
|
687
698
|
},
|
|
@@ -691,7 +702,7 @@
|
|
|
691
702
|
},
|
|
692
703
|
"radius": {
|
|
693
704
|
"$type": "dimension",
|
|
694
|
-
"$value": "{radius.
|
|
705
|
+
"$value": "{radius.2xl}",
|
|
695
706
|
"$extensions": {
|
|
696
707
|
"com.webority": {
|
|
697
708
|
"platforms": ["web", "phone"]
|
|
@@ -725,17 +736,22 @@
|
|
|
725
736
|
"min-height": {
|
|
726
737
|
"$type": "dimension",
|
|
727
738
|
"$value": {
|
|
728
|
-
"value":
|
|
739
|
+
"value": 50,
|
|
729
740
|
"unit": "px"
|
|
730
741
|
}
|
|
731
742
|
},
|
|
732
743
|
"text": {
|
|
733
744
|
"$type": "dimension",
|
|
734
|
-
"$value": "{text.
|
|
745
|
+
"$value": "{text.lg}"
|
|
735
746
|
},
|
|
736
747
|
"radius": {
|
|
737
748
|
"$type": "dimension",
|
|
738
|
-
"$value": "{radius.
|
|
749
|
+
"$value": "{radius.3xl}",
|
|
750
|
+
"$extensions": {
|
|
751
|
+
"com.webority": {
|
|
752
|
+
"platforms": ["web", "phone"]
|
|
753
|
+
}
|
|
754
|
+
}
|
|
739
755
|
},
|
|
740
756
|
"icon": {
|
|
741
757
|
"$type": "dimension",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"color": {
|
|
3
|
+
"text-subtle": { "$value": "{color.text-muted}" },
|
|
4
|
+
"border": { "$value": "{color.text-muted}" },
|
|
5
|
+
"border-subtle": { "$value": "{color.text-muted}" },
|
|
6
|
+
"border-strong": { "$value": "{color.text-muted}" },
|
|
7
|
+
"field-border": { "$value": "{color.text-muted}" },
|
|
8
|
+
"field-border-hover": { "$value": "{color.text-muted}" },
|
|
9
|
+
"focus-ring-soft": { "$value": "{color.focus-ring}" }
|
|
10
|
+
},
|
|
11
|
+
"component": {
|
|
12
|
+
"focus-ring": {
|
|
13
|
+
"width": { "$value": "{space.xs}" }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"color": {
|
|
3
|
+
"bg": { "$value": "{palette.bg-light}" },
|
|
4
|
+
"bg-subtle": { "$value": "{palette.bg-light}" },
|
|
5
|
+
"bg-muted": { "$value": "{palette.bg-light}" },
|
|
6
|
+
"surface": { "$value": "{palette.bg-light}" },
|
|
7
|
+
"field-bg": { "$value": "{palette.bg-light}" },
|
|
8
|
+
"text": { "$value": "{palette.ink}" },
|
|
9
|
+
"text-body": { "$value": "{palette.ink}" },
|
|
10
|
+
"text-muted": { "$value": "{palette.text-1}" },
|
|
11
|
+
"text-subtle": { "$value": "{palette.text-2}" },
|
|
12
|
+
"border": { "$value": "{palette.text-4}" },
|
|
13
|
+
"border-subtle": { "$value": "{palette.text-4}" },
|
|
14
|
+
"border-strong": { "$value": "{palette.text-3}" },
|
|
15
|
+
"field-border": { "$value": "{palette.text-4}" },
|
|
16
|
+
"field-border-hover": { "$value": "{palette.text-4}" },
|
|
17
|
+
"link": { "$value": "{palette.ink}" },
|
|
18
|
+
"link-hover": { "$value": "{palette.ink}" }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -122,6 +122,22 @@
|
|
|
122
122
|
},
|
|
123
123
|
"$description": "Extra-large step of the corner radius scale."
|
|
124
124
|
},
|
|
125
|
+
"2xl": {
|
|
126
|
+
"$type": "dimension",
|
|
127
|
+
"$value": {
|
|
128
|
+
"value": 18,
|
|
129
|
+
"unit": "px"
|
|
130
|
+
},
|
|
131
|
+
"$description": "Second extra-large step of the corner radius scale, for large buttons."
|
|
132
|
+
},
|
|
133
|
+
"3xl": {
|
|
134
|
+
"$type": "dimension",
|
|
135
|
+
"$value": {
|
|
136
|
+
"value": 20,
|
|
137
|
+
"unit": "px"
|
|
138
|
+
},
|
|
139
|
+
"$description": "Largest step of the corner radius scale, for extra-large buttons."
|
|
140
|
+
},
|
|
125
141
|
"pill": {
|
|
126
142
|
"$type": "dimension",
|
|
127
143
|
"$value": {
|
|
@@ -647,10 +663,10 @@
|
|
|
647
663
|
"control-md": {
|
|
648
664
|
"$type": "dimension",
|
|
649
665
|
"$value": {
|
|
650
|
-
"value":
|
|
666
|
+
"value": 40,
|
|
651
667
|
"unit": "px"
|
|
652
668
|
},
|
|
653
|
-
"$description": "Default height of a
|
|
669
|
+
"$description": "Default height of a field, select or tab; 45px on phones and touch screens, above the 44px touch minimum.",
|
|
654
670
|
"$extensions": {
|
|
655
671
|
"com.webority": {
|
|
656
672
|
"platforms": ["web"],
|
|
@@ -664,10 +680,23 @@
|
|
|
664
680
|
"control-lg": {
|
|
665
681
|
"$type": "dimension",
|
|
666
682
|
"$value": {
|
|
667
|
-
"value":
|
|
683
|
+
"value": 45,
|
|
684
|
+
"unit": "px"
|
|
685
|
+
},
|
|
686
|
+
"$description": "Height of the large control size, for prominent fields.",
|
|
687
|
+
"$extensions": {
|
|
688
|
+
"com.webority": {
|
|
689
|
+
"platforms": ["web"]
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
"control-xl": {
|
|
694
|
+
"$type": "dimension",
|
|
695
|
+
"$value": {
|
|
696
|
+
"value": 50,
|
|
668
697
|
"unit": "px"
|
|
669
698
|
},
|
|
670
|
-
"$description": "Height of the large control size, for
|
|
699
|
+
"$description": "Height of the extra-large control size, for a field on a sign-up or marketing form.",
|
|
671
700
|
"$extensions": {
|
|
672
701
|
"com.webority": {
|
|
673
702
|
"platforms": ["web"]
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
"modifiers": [
|
|
14
14
|
{ "name": "mode", "default": "light", "contexts": { "light": [], "dark": [{ "$ref": "source/mode.dark.tokens.json" }] } },
|
|
15
15
|
{ "name": "platform", "default": "web", "contexts": { "web": [], "phone": [{ "$ref": "source/platform.phone.tokens.json" }] } },
|
|
16
|
-
{ "name": "width", "default": "1440", "contexts": { "1440": [], "390": [{ "$ref": "source/width.390.tokens.json" }] } }
|
|
16
|
+
{ "name": "width", "default": "1440", "contexts": { "1440": [], "390": [{ "$ref": "source/width.390.tokens.json" }] } },
|
|
17
|
+
{
|
|
18
|
+
"name": "contrast",
|
|
19
|
+
"default": "standard",
|
|
20
|
+
"contexts": { "standard": [], "more": [{ "$ref": "source/contrast.more.tokens.json" }] }
|
|
21
|
+
},
|
|
22
|
+
{ "name": "medium", "default": "screen", "contexts": { "screen": [], "print": [{ "$ref": "source/medium.print.tokens.json" }] } }
|
|
17
23
|
]
|
|
18
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/tokens",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.167.0",
|
|
4
4
|
"description": "The Webority design tokens in one W3C Design Tokens source (palette, scale, meaning and component tiers, with light and dark, web and phone, and 390 and 1440 widths), and the webority command that brands a product, upgrades it between releases and checks it against the token source.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@babel/types": "7.29.8",
|
|
43
43
|
"@types/node": "25.6.0",
|
|
44
|
-
"@webority/biome-config": "0.
|
|
44
|
+
"@webority/biome-config": "0.167.0",
|
|
45
45
|
"ajv": "8.20.0",
|
|
46
46
|
"typescript": "^7.0.2",
|
|
47
47
|
"vite": "^8.3.6"
|
package/renames/0.158.0.json
CHANGED
|
@@ -125,25 +125,17 @@
|
|
|
125
125
|
"app-checkbox",
|
|
126
126
|
"app-choice-card",
|
|
127
127
|
"app-choice-chip",
|
|
128
|
-
"app-color-field",
|
|
129
128
|
"app-copy-button",
|
|
130
|
-
"app-input",
|
|
131
|
-
"app-input-group",
|
|
132
129
|
"app-kpi-tile",
|
|
133
130
|
"app-link",
|
|
134
|
-
"app-number-input",
|
|
135
|
-
"app-phone-number-input",
|
|
136
131
|
"app-radio",
|
|
137
132
|
"app-radio-group",
|
|
138
133
|
"app-rating",
|
|
139
|
-
"app-search",
|
|
140
134
|
"app-segmented",
|
|
141
|
-
"app-select",
|
|
142
135
|
"app-split-button",
|
|
143
136
|
"app-stepper",
|
|
144
137
|
"app-switch",
|
|
145
138
|
"app-tabs",
|
|
146
|
-
"app-textarea",
|
|
147
139
|
"app-tooltip",
|
|
148
140
|
"app-wizard",
|
|
149
141
|
"app-workspace-switcher"
|
|
@@ -155,34 +147,49 @@
|
|
|
155
147
|
"md": "Md",
|
|
156
148
|
"lg": "Lg"
|
|
157
149
|
},
|
|
158
|
-
"nullableTags": ["app-checkbox", "app-
|
|
150
|
+
"nullableTags": ["app-checkbox", "app-radio", "app-switch"]
|
|
159
151
|
},
|
|
160
152
|
{
|
|
161
153
|
"tags": [
|
|
162
|
-
"app-
|
|
163
|
-
"app-
|
|
164
|
-
"app-
|
|
165
|
-
"app-
|
|
166
|
-
"app-
|
|
167
|
-
"app-
|
|
168
|
-
"app-
|
|
154
|
+
"app-color-field",
|
|
155
|
+
"app-input",
|
|
156
|
+
"app-input-group",
|
|
157
|
+
"app-number-input",
|
|
158
|
+
"app-phone-number-input",
|
|
159
|
+
"app-search",
|
|
160
|
+
"app-select",
|
|
161
|
+
"app-textarea"
|
|
169
162
|
],
|
|
170
163
|
"attribute": "size",
|
|
164
|
+
"enum": "FieldSize",
|
|
165
|
+
"values": {
|
|
166
|
+
"sm": "Sm",
|
|
167
|
+
"md": "Md",
|
|
168
|
+
"lg": "Lg"
|
|
169
|
+
},
|
|
170
|
+
"nullableTags": ["app-input", "app-search", "app-select", "app-textarea"]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"tags": ["app-file-picker", "app-otp-input", "app-slider"],
|
|
174
|
+
"attribute": "size",
|
|
171
175
|
"enum": "ControlSize",
|
|
172
176
|
"values": {
|
|
173
177
|
"sm": "Sm",
|
|
174
178
|
"md": "Md",
|
|
175
179
|
"lg": "Lg"
|
|
176
180
|
},
|
|
177
|
-
"nullableTags": [
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"
|
|
185
|
-
|
|
181
|
+
"nullableTags": ["app-file-picker", "app-otp-input", "app-slider"]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"tags": ["app-date-picker", "app-date-range-picker", "app-mention-input", "app-time-picker"],
|
|
185
|
+
"attribute": "size",
|
|
186
|
+
"enum": "FieldSize",
|
|
187
|
+
"values": {
|
|
188
|
+
"sm": "Sm",
|
|
189
|
+
"md": "Md",
|
|
190
|
+
"lg": "Lg"
|
|
191
|
+
},
|
|
192
|
+
"nullableTags": ["app-date-picker", "app-date-range-picker", "app-mention-input", "app-time-picker"]
|
|
186
193
|
},
|
|
187
194
|
{
|
|
188
195
|
"tags": ["app-alert", "app-banner", "app-meter", "app-metric"],
|
package/renames/0.160.0.json
CHANGED
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"keepExpressions": true
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
|
-
"tags": ["app-checkbox", "app-
|
|
114
|
+
"tags": ["app-checkbox", "app-radio", "app-switch"],
|
|
115
115
|
"attribute": "size",
|
|
116
116
|
"enum": "ControlSize",
|
|
117
117
|
"values": {
|
|
@@ -119,7 +119,19 @@
|
|
|
119
119
|
"md": "Md",
|
|
120
120
|
"lg": "Lg"
|
|
121
121
|
},
|
|
122
|
-
"nullableTags": ["app-checkbox", "app-
|
|
122
|
+
"nullableTags": ["app-checkbox", "app-radio", "app-switch"],
|
|
123
|
+
"keepExpressions": true
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"tags": ["app-input", "app-search", "app-select", "app-textarea"],
|
|
127
|
+
"attribute": "size",
|
|
128
|
+
"enum": "FieldSize",
|
|
129
|
+
"values": {
|
|
130
|
+
"sm": "Sm",
|
|
131
|
+
"md": "Md",
|
|
132
|
+
"lg": "Lg"
|
|
133
|
+
},
|
|
134
|
+
"nullableTags": ["app-input", "app-search", "app-select", "app-textarea"],
|
|
123
135
|
"keepExpressions": true
|
|
124
136
|
},
|
|
125
137
|
{
|
|
@@ -307,7 +319,11 @@
|
|
|
307
319
|
"tags": ["app-consent-banner"],
|
|
308
320
|
"attribute": "categories",
|
|
309
321
|
"enum": "ConsentCategory",
|
|
310
|
-
"values": {
|
|
322
|
+
"values": {
|
|
323
|
+
"analytics": "Analytics",
|
|
324
|
+
"functional": "Functional",
|
|
325
|
+
"marketing": "Marketing"
|
|
326
|
+
}
|
|
311
327
|
},
|
|
312
328
|
{
|
|
313
329
|
"tags": ["app-lead-popup"],
|
|
@@ -339,19 +355,36 @@
|
|
|
339
355
|
"tags": ["app-lead-popup"],
|
|
340
356
|
"attribute": "triggers",
|
|
341
357
|
"enum": "LeadPopupTrigger",
|
|
342
|
-
"values": {
|
|
358
|
+
"values": {
|
|
359
|
+
"exit": "Exit",
|
|
360
|
+
"delay": "Delay",
|
|
361
|
+
"scroll": "Scroll",
|
|
362
|
+
"pages": "Pages"
|
|
363
|
+
}
|
|
343
364
|
},
|
|
344
365
|
{
|
|
345
366
|
"tags": ["app-section-lead-capture"],
|
|
346
367
|
"attribute": "fields",
|
|
347
368
|
"enum": "LeadCaptureField",
|
|
348
|
-
"values": {
|
|
369
|
+
"values": {
|
|
370
|
+
"name": "Name",
|
|
371
|
+
"email": "Email",
|
|
372
|
+
"phone": "Phone",
|
|
373
|
+
"company": "Company",
|
|
374
|
+
"message": "Message"
|
|
375
|
+
}
|
|
349
376
|
},
|
|
350
377
|
{
|
|
351
378
|
"tags": ["app-section-lead-capture"],
|
|
352
379
|
"attribute": "required",
|
|
353
380
|
"enum": "LeadCaptureField",
|
|
354
|
-
"values": {
|
|
381
|
+
"values": {
|
|
382
|
+
"name": "Name",
|
|
383
|
+
"email": "Email",
|
|
384
|
+
"phone": "Phone",
|
|
385
|
+
"company": "Company",
|
|
386
|
+
"message": "Message"
|
|
387
|
+
}
|
|
355
388
|
}
|
|
356
389
|
],
|
|
357
390
|
"csharpEnumArguments": []
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.165.0",
|
|
3
|
+
"css": {
|
|
4
|
+
"rename": [],
|
|
5
|
+
"reads": [],
|
|
6
|
+
"choose": {},
|
|
7
|
+
"checkRole": []
|
|
8
|
+
},
|
|
9
|
+
"classes": [],
|
|
10
|
+
"themeReads": [],
|
|
11
|
+
"props": [],
|
|
12
|
+
"propValues": [],
|
|
13
|
+
"propSplits": [],
|
|
14
|
+
"razorAttributes": [],
|
|
15
|
+
"componentProps": [],
|
|
16
|
+
"valueSplits": [],
|
|
17
|
+
"components": [],
|
|
18
|
+
"razorValueSplits": [],
|
|
19
|
+
"razorTags": [],
|
|
20
|
+
"razorEnumAttributes": [],
|
|
21
|
+
"razorListAttributes": [],
|
|
22
|
+
"csharpEnumArguments": [],
|
|
23
|
+
"markup": {
|
|
24
|
+
"literals": [],
|
|
25
|
+
"flags": [
|
|
26
|
+
{
|
|
27
|
+
"pattern": "<app-(resizable|resizable-handle|resizable-panel|rolling-number|row-switch)\\b",
|
|
28
|
+
"hint": "removed in 0.165.0 with no successor: delete the tag"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"pattern": "<wui-(resizable|rolling-number)\\b",
|
|
32
|
+
"hint": "removed in 0.165.0 with no successor: delete the element"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"source": {
|
|
37
|
+
"literals": [],
|
|
38
|
+
"members": [],
|
|
39
|
+
"flags": [],
|
|
40
|
+
"removedImports": [
|
|
41
|
+
{
|
|
42
|
+
"package": "@webority/ui-react",
|
|
43
|
+
"names": ["AppResizable", "AppResizableHandle", "AppResizablePanel", "AppRollingNumber", "AppRowSwitch"],
|
|
44
|
+
"hint": "removed in 0.165.0 with no successor: delete the use"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"package": "@webority/ui-elements",
|
|
48
|
+
"names": ["WuiResizable", "WuiRollingNumber"],
|
|
49
|
+
"hint": "removed in 0.165.0 with no successor: delete the use"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.167.0",
|
|
3
|
+
"css": {
|
|
4
|
+
"rename": [],
|
|
5
|
+
"reads": [],
|
|
6
|
+
"choose": {},
|
|
7
|
+
"checkRole": []
|
|
8
|
+
},
|
|
9
|
+
"classes": [],
|
|
10
|
+
"themeReads": [],
|
|
11
|
+
"props": [],
|
|
12
|
+
"propValues": [],
|
|
13
|
+
"propSplits": [],
|
|
14
|
+
"razorAttributes": [],
|
|
15
|
+
"componentProps": [
|
|
16
|
+
{ "package": "@webority/mobile-ui", "components": ["Accordion"], "prop": "containerStyle", "to": "style" },
|
|
17
|
+
{ "package": "@webority/mobile-ui", "components": ["AppBar"], "prop": "containerStyle", "to": "style" },
|
|
18
|
+
{ "package": "@webority/mobile-ui", "components": ["Banner"], "prop": "containerStyle", "to": "style" },
|
|
19
|
+
{ "package": "@webority/mobile-ui", "components": ["Card"], "prop": "containerStyle", "to": "style" },
|
|
20
|
+
{ "package": "@webority/mobile-ui", "components": ["Checkbox"], "prop": "containerStyle", "to": "style" },
|
|
21
|
+
{ "package": "@webority/mobile-ui", "components": ["Chip"], "prop": "containerStyle", "to": "style" },
|
|
22
|
+
{ "package": "@webority/mobile-ui", "components": ["FloatingActionButton"], "prop": "containerStyle", "to": "style" },
|
|
23
|
+
{ "package": "@webority/mobile-ui", "components": ["NumberInput"], "prop": "containerStyle", "to": "style" },
|
|
24
|
+
{ "package": "@webority/mobile-ui", "components": ["ProgressBar"], "prop": "containerStyle", "to": "style" },
|
|
25
|
+
{ "package": "@webority/mobile-ui", "components": ["Radio"], "prop": "containerStyle", "to": "style" },
|
|
26
|
+
{ "package": "@webority/mobile-ui", "components": ["Rating"], "prop": "containerStyle", "to": "style" },
|
|
27
|
+
{ "package": "@webority/mobile-ui", "components": ["SegmentedControl"], "prop": "containerStyle", "to": "style" },
|
|
28
|
+
{ "package": "@webority/mobile-ui", "components": ["Slider"], "prop": "containerStyle", "to": "style" },
|
|
29
|
+
{ "package": "@webority/mobile-ui", "components": ["Stepper"], "prop": "containerStyle", "to": "style" },
|
|
30
|
+
{ "package": "@webority/mobile-ui", "components": ["Tooltip"], "prop": "containerStyle", "to": "style" },
|
|
31
|
+
{ "package": "@webority/mobile-ui", "components": ["Switch"], "prop": "containerStyle", "to": "style" },
|
|
32
|
+
{ "package": "@webority/mobile-ui", "components": ["FormField"], "prop": "containerStyle", "to": "style" },
|
|
33
|
+
{ "package": "@webority/mobile-ui", "components": ["HookFormField"], "prop": "containerStyle", "to": "style" },
|
|
34
|
+
{ "package": "@webority/mobile-ui", "components": ["Carousel"], "prop": "containerStyle", "to": "style" },
|
|
35
|
+
{ "package": "@webority/mobile-ui", "components": ["Swipeable"], "prop": "containerStyle", "to": "style" },
|
|
36
|
+
{ "package": "@webority/mobile-ui", "components": ["ImageGallery"], "prop": "containerStyle", "to": "style" },
|
|
37
|
+
{ "package": "@webority/mobile-ui", "components": ["FloatingActionButtonGroup"], "prop": "containerStyle", "to": "style" },
|
|
38
|
+
{ "package": "@webority/mobile-ui", "components": ["BottomSheet"], "prop": "containerStyle", "to": "sheetStyle" },
|
|
39
|
+
{ "package": "@webority/mobile-ui", "components": ["NonModalBottomSheet"], "prop": "containerStyle", "to": "sheetStyle" },
|
|
40
|
+
{ "package": "@webority/mobile-ui", "components": ["Drawer"], "prop": "containerStyle", "to": "sheetStyle" },
|
|
41
|
+
{ "package": "@webority/mobile-ui", "components": ["DatePicker"], "prop": "containerStyle", "to": "sheetStyle" },
|
|
42
|
+
{ "package": "@webority/mobile-ui", "components": ["DateRangePicker"], "prop": "containerStyle", "to": "sheetStyle" },
|
|
43
|
+
{ "package": "@webority/mobile-ui", "components": ["TimePicker"], "prop": "containerStyle", "to": "sheetStyle" },
|
|
44
|
+
{ "package": "@webority/mobile-ui", "components": ["ListItem"], "prop": "containerStyle", "to": "rowStyle" },
|
|
45
|
+
{ "package": "@webority/mobile-ui", "components": ["Input"], "prop": "containerStyle", "to": "fieldStyle" },
|
|
46
|
+
{ "package": "@webority/mobile-ui", "components": ["DecimalInput"], "prop": "containerStyle", "to": "fieldStyle" },
|
|
47
|
+
{ "package": "@webority/mobile-ui", "components": ["Button"], "prop": "containerStyle", "to": "wrapperStyle" },
|
|
48
|
+
{ "package": "@webority/mobile-ui", "components": ["Dialog"], "prop": "containerStyle", "to": "bodyStyle" },
|
|
49
|
+
{ "package": "@webority/mobile-ui", "components": ["Dialog"], "prop": "contentStyle", "to": "style" },
|
|
50
|
+
{ "package": "@webority/mobile-ui", "components": ["ForceUpdateDialog"], "prop": "containerStyle", "to": "bodyStyle" },
|
|
51
|
+
{ "package": "@webority/mobile-ui", "components": ["ForceUpdateDialog"], "prop": "contentStyle", "to": "style" }
|
|
52
|
+
],
|
|
53
|
+
"valueSplits": [],
|
|
54
|
+
"components": [],
|
|
55
|
+
"razorValueSplits": [],
|
|
56
|
+
"razorTags": [],
|
|
57
|
+
"razorEnumAttributes": [],
|
|
58
|
+
"razorListAttributes": [],
|
|
59
|
+
"csharpEnumArguments": [],
|
|
60
|
+
"markup": {
|
|
61
|
+
"literals": [],
|
|
62
|
+
"flags": []
|
|
63
|
+
},
|
|
64
|
+
"source": {
|
|
65
|
+
"literals": [],
|
|
66
|
+
"members": [],
|
|
67
|
+
"flags": [],
|
|
68
|
+
"removedImports": []
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
|
|
152
152
|
},
|
|
153
153
|
"kind": {
|
|
154
|
-
"description": "Which generated file the head receives: razor gets brand.css in wwwroot/generated, spa (a Vite web portal) gets brand.css in src/generated for its style entry to import after the theme tokens, phone gets brand.phone.
|
|
154
|
+
"description": "Which generated file the head receives: razor gets brand.css in wwwroot/generated, spa (a Vite web portal) gets brand.css in src/generated for its style entry to import after the theme tokens, phone gets brand.phone.ts and email gets email.json in generated.",
|
|
155
155
|
"enum": ["razor", "spa", "phone", "email"]
|
|
156
156
|
}
|
|
157
157
|
},
|