@webority/tokens 0.96.0 → 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.js +5 -6
- package/dist/canvas/webority-phone.json +1 -1
- package/dist/canvas/webority-web-390.json +1 -1
- package/dist/canvas/webority-web.json +1 -1
- package/dist/emit/canvas.js +1 -1
- package/dist/emit/web.js +5 -8
- package/dist/meanings.json +2 -2
- package/dist/model/resolve.js +2 -2
- package/dist/source/meaning.tokens.json +1 -1
- package/dist/source/palette.tokens.json +7 -27
- package/package.json +1 -1
- package/renames/0.97.0.json +61 -0
- package/dist/model/derive.js +0 -1
package/dist/build.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import{__toESM as e}from"./_virtual/_rolldown/runtime.js";import{BRAND_OUTPUT_FILES as t,HEAD_FOLDER as n,loadBrand as r}from"./brand.js";import{require__2020 as i}from"./node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.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{
|
|
2
|
-
`));let
|
|
3
|
-
`));let
|
|
4
|
-
`))t.length!==0&&
|
|
5
|
-
`));for(let
|
|
6
|
-
`))}function j(e,r,i){let a=b.resolve(e,r.path);return r.kind===`razor`?[b.join(a,`wwwroot`,n,t.css),i.css]:r.kind===`spa`?[b.join(a,`src`,n,t.css),i.css]:r.kind===`phone`?[b.join(a,n,t.phone),i.phone]:[b.join(a,n,t.email),i.email]}async function M(){let e={};for(let[t,n]of Object.entries(w))e[t]=JSON.parse(await v(new URL(`./source/${n}`,import.meta.url),`utf8`));return e}export{E as brand};
|
|
1
|
+
import{__toESM as e}from"./_virtual/_rolldown/runtime.js";import{BRAND_OUTPUT_FILES as t,HEAD_FOLDER as n,loadBrand as r}from"./brand.js";import{require__2020 as i}from"./node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.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{loadModel as m}from"./model/index.js";import{mkdir as h,readFile as g,writeFile as _}from"node:fs/promises";import v from"node:path";var y=e(i(),1),b=new URL(`../schema/design-map.schema.json`,import.meta.url),x=new URL(`../package.json`,import.meta.url),S={palette:`palette.tokens.json`,scale:`scale.tokens.json`,meaning:`meaning.tokens.json`,modeDark:`mode.dark.tokens.json`},C=/^.+: \S+: .+\. .+$/;async function w(e){let n=v.resolve(e.root??process.cwd()),i=e.check===!0,{version:S}=JSON.parse(await g(x,`utf8`)),w=[],O=[],k=async(e,t)=>{if(i){let n=null;try{n=await g(e,`utf8`)}catch(e){if(e.code!==`ENOENT`)throw e}n!==t&&O.push(e);return}await h(v.dirname(e),{recursive:!0}),await _(e,t,`utf8`),w.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=v.resolve(n,e.out),i=await m(),o=s(i),c=[[v.join(r,`canvas`,t.web),T(o.web)],[v.join(r,`canvas`,t.web390),T(o.web390)],[v.join(r,`canvas`,t.phoneTheme),T(o.phone)],[v.join(r,`meanings.json`),T(l(i))],[v.join(r,`canvas`,`renames.json`),T(a)]];if(e.web){let t=p(i),r=v.resolve(n,e.web);c.push([r,t.tokens]),c.push([v.join(v.dirname(r),`_bootstrap.generated.scss`),t.bootstrap])}if(e.phone){let t=d({light:f(i,`light`),dark:f(i,`dark`)});c.push([v.resolve(n,e.phone),t.contents])}for(let[e,t]of c)await k(e,t);return{written:w,stale:O}}let A=v.join(n,`.webority`,`design.json`),j;try{j=await g(A,`utf8`)}catch(e){throw e.code===`ENOENT`?Error(`${A}: file missing. Run from the repo root or create the design map.`):e}let M;try{M=JSON.parse(j)}catch(e){throw Error(`${A}: /: ${e.message}. Fix the design map.`)}let N=JSON.parse(await g(b,`utf8`)),P=new y.Ajv2020({allErrors:!0,strict:!1}).compile(N);if(!P(M))throw Error(P.errors.map(e=>`${A}: ${e.instancePath||`/`}: ${e.message}. Fix the design map.`).join(`
|
|
2
|
+
`));let F=M.tokens.brands,I=M.tokens.heads??[];if((e.brand!==void 0||e.out!==void 0)&&F.length>1)throw Error(`brand: --brand/--out: the repo has ${F.length} brands. Remove the flag to build every brand.`);let L=[];if(F.forEach((e,t)=>{e.source===`library`&&L.push(`${A}: tokens.brands[${t}].source: "library" is built with --library. Run webority brand --library --out <dir>.`)}),I.forEach((e,t)=>{F.some(t=>t.name===e.brand)||L.push(`${A}: tokens.heads[${t}].brand: no brand named ${e.brand}. Add it to tokens.brands.`)}),L.length>0)throw Error(L.join(`
|
|
3
|
+
`));let R=await D(),z=await m(),B={light:f(z,`light`),dark:f(z,`dark`)},V=[];for(let i of F){let a=F.length===1&&e.brand!==void 0?e.brand:i.source,l=F.length===1&&e.out!==void 0?e.out:i.export,d=v.resolve(n,a);try{let e=r(d,R,o),a=await m({brand:e}),h=s(a),g=p(a,{library:z}),_=u(B,{light:f(a,`light`),dark:f(a,`dark`)},{package:`@webority/tokens`,version:S,brand:e.name}),y=T(c(h.web,h.web390)),b={css:g.css,phone:_.contents,email:y},x=v.resolve(n,l),C=[[v.join(x,t.css),g.css],[v.join(x,t.bootstrap),g.variables],[v.join(x,t.web),T(h.web)],[v.join(x,t.web390),T(h.web390)],[v.join(x,t.phoneTheme),T(h.phone)],[v.join(x,t.phone),_.contents],[v.join(x,t.email),y]];V.push(...C);for(let e of I)e.brand===i.name&&V.push(E(n,e,b))}catch(e){for(let t of String(e?.message??e).split(`
|
|
4
|
+
`))t.length!==0&&L.push(C.test(t)?t:`${d}: -: ${t}. Fix the source.`)}}if(L.length>0)throw Error(L.join(`
|
|
5
|
+
`));for(let[e,t]of V)await k(e,t);return{written:w,stale:O}}function T(e){return`${JSON.stringify(e,null,4)}\n`}function E(e,r,i){let a=v.resolve(e,r.path);return r.kind===`razor`?[v.join(a,`wwwroot`,n,t.css),i.css]:r.kind===`spa`?[v.join(a,`src`,n,t.css),i.css]:r.kind===`phone`?[v.join(a,n,t.phone),i.phone]:[v.join(a,n,t.email),i.email]}async function D(){let e={};for(let[t,n]of Object.entries(S))e[t]=JSON.parse(await g(new URL(`./source/${n}`,import.meta.url),`utf8`));return e}export{w as brand};
|
package/dist/emit/canvas.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return{web:t(e,`web`,1440),web390:t(e,`web`,390),phone:t(e,`phone`,null)}}function t(e,t,a){let o=n(e,`light`,t,a),s=n(e,`dark`,t,a),c={format:`webority-theme-tokens/2`,source:{package:e.source.package,version:e.source.version,brand:e.source.brand,platform:t,width:a},modes:[`light`,`dark`],colors:{light:{},dark:{}},space:{},radius:{},text:{},typography:{fontWeight:{},leading:{}},fonts:{},shadow:{},components:{}};for(let t of e.tokens.values())t.group===`color`?i(c,e,t,o,s):e.existsIn(t.path,o)&&r(c,e,t,o);return c}function n(e,t,n,r){let i=e.contexts.find(e=>e.mode===t&&e.platform===n&&e.width===r);if(!i){let e=r===null?``:` ${r}`;throw Error(`emitCanvas: the model has no ${t} ${n}${e} context`)}return i}function r(e,t,n,r){let{path:i,name:o}=n;switch(n.group){case`space`:e.space[o]=s(t,i,r);break;case`radius`:e.radius[o]=s(t,i,r);break;case`text`:e.text[o]={size:s(t,i,r)};break;case`weight`:e.typography.fontWeight[o]=c(t,i,r);break;case`leading`:e.typography.leading[o]=c(t,i,r);break;case`font`:e.fonts[o]=l(t,i,r);break;case`shadow`:e.shadow[o]=u(t,i,r);break;case`component`:a(e,t,i,r);break}}function i(e,t,n,r,i){let a=t.existsIn(n.path,r);if(a!==t.existsIn(n.path,i))throw Error(`emitCanvas: ${n.path} is present in one mode only`);if(a&&(e.colors.light[n.name]=o(t,n.path,r),e.colors.dark[n.name]=o(t,n.path,i),n.brandOwn)){if(typeof n.description!=`string`||n.description===``)throw Error(`emitCanvas: ${n.path} is a brand colour and needs a description`);e.colorMeanings??={},e.colorMeanings[n.name]=n.description}}function a(e,t,n,r){let i=n.split(`.`);if(i.length!==3&&i.length!==4)throw Error(`emitCanvas: ${n} must be component.<name>.<prop> or component.<name>.<size>.<prop>`);let a=i[1],o=i[i.length-1];e.components[a]??={base:{},sizes:{}};let s=
|
|
1
|
+
function e(e){return{web:t(e,`web`,1440),web390:t(e,`web`,390),phone:t(e,`phone`,null)}}function t(e,t,a){let o=n(e,`light`,t,a),s=n(e,`dark`,t,a),c={format:`webority-theme-tokens/2`,source:{package:e.source.package,version:e.source.version,brand:e.source.brand,platform:t,width:a},modes:[`light`,`dark`],colors:{light:{},dark:{}},space:{},radius:{},text:{},typography:{fontWeight:{},leading:{}},fonts:{},shadow:{},components:{}};for(let t of e.tokens.values())t.group===`color`?i(c,e,t,o,s):e.existsIn(t.path,o)&&r(c,e,t,o);return c}function n(e,t,n,r){let i=e.contexts.find(e=>e.mode===t&&e.platform===n&&e.width===r);if(!i){let e=r===null?``:` ${r}`;throw Error(`emitCanvas: the model has no ${t} ${n}${e} context`)}return i}function r(e,t,n,r){let{path:i,name:o}=n;switch(n.group){case`space`:e.space[o]=s(t,i,r);break;case`radius`:e.radius[o]=s(t,i,r);break;case`text`:e.text[o]={size:s(t,i,r)};break;case`weight`:e.typography.fontWeight[o]=c(t,i,r);break;case`leading`:e.typography.leading[o]=c(t,i,r);break;case`font`:e.fonts[o]=l(t,i,r);break;case`shadow`:e.shadow[o]=u(t,i,r);break;case`component`:a(e,t,i,r);break}}function i(e,t,n,r,i){let a=t.existsIn(n.path,r);if(a!==t.existsIn(n.path,i))throw Error(`emitCanvas: ${n.path} is present in one mode only`);if(a&&(e.colors.light[n.name]=o(t,n.path,r),e.colors.dark[n.name]=o(t,n.path,i),n.brandOwn)){if(typeof n.description!=`string`||n.description===``)throw Error(`emitCanvas: ${n.path} is a brand colour and needs a description`);e.colorMeanings??={},e.colorMeanings[n.name]=n.description}}function a(e,t,n,r){let i=n.split(`.`);if(i.length!==3&&i.length!==4)throw Error(`emitCanvas: ${n} must be component.<name>.<prop> or component.<name>.<size>.<prop>`);let a=i[1],o=i[i.length-1];e.components[a]??={base:{},sizes:{}};let s=e.components[a].base;i.length===4&&(e.components[a].sizes[i[2]]??={},s=e.components[a].sizes[i[2]]),s[o]=f(t,n,r)}function o(e,t,n){let r=e.resolvedIn(t,n);if(typeof r!=`string`)throw Error(`emitCanvas: ${t} is not a colour string`);return r}function s(e,t,n){let r=e.resolvedIn(t,n);if(typeof r==`number`)return r;if(typeof r==`object`&&r&&r.unit===`px`&&typeof r.value==`number`)return r.value;throw Error(`emitCanvas: ${t} is not a px length`)}function c(e,t,n){let r=e.resolvedIn(t,n);if(typeof r!=`number`)throw Error(`emitCanvas: ${t} is not a number`);return r}function l(e,t,n){let r=e.resolvedIn(t,n);if(!Array.isArray(r)||r.length===0)throw Error(`emitCanvas: ${t} is not a font family list`);return{family:r[0],fallback:r.slice(1).join(`, `)}}function u(e,t,n){let r=e.resolvedIn(t,n);if(r===`none`)return null;if(typeof r!=`object`||!r||typeof r.color!=`string`)throw Error(`emitCanvas: ${t} is not a shadow`);let[i,a,o,s]=[`offsetX`,`offsetY`,`blur`,`spread`].map(e=>d(t,r[e])),c={x:i,y:a,blur:o,spread:s,color:r.color},l=e.tokens.get(t)?.extensions?.elevation;return Number.isFinite(l)&&(c.elevation=l),c}function d(e,t){let n=typeof t==`number`?t:t?.value;if(typeof n!=`number`)throw Error(`emitCanvas: ${e} has a shadow length that is not a number`);return n}function f(e,t,n){let r=e.resolvedIn(t,n);if(typeof r==`string`||typeof r==`number`)return String(r);if(typeof r==`object`&&r&&typeof r.unit==`string`)return`${r.value}${r.unit}`;throw Error(`emitCanvas: ${t} is not a component value`)}export{e as emitCanvas};
|
package/dist/emit/web.js
CHANGED
|
@@ -3,7 +3,7 @@ import{BREAKPOINT_PX as e,breakpointRules as t,fluidLength as n}from"../model/le
|
|
|
3
3
|
[data-bs-theme="dark"]:not(:root)`,h=`:root[data-theme="auto"]`,g=`[data-theme="dark"]:not(:root) [data-theme="light"],
|
|
4
4
|
[data-theme="dark"]:not(:root) [data-bs-theme="light"],
|
|
5
5
|
[data-bs-theme="dark"]:not(:root) [data-theme="light"],
|
|
6
|
-
[data-bs-theme="dark"]:not(:root) [data-bs-theme="light"]`,_=`// var() resolves where a name is declared, so the html copies keep the light values for a light box.`,v=`/* var() resolves where a name is declared, so the html copies keep the light values for a light box. */`,y=`// Zero specificity, so a component's own class on a themed section or inside it keeps its colour.`,b=`/* Zero specificity, so a component's own class on a themed section or inside it keeps its colour. */`;function x(e){return String(Number(e.toFixed(4)))}function S(e,t){if(typeof t==`string`)return t.replace(s,(e,t)=>`var(${r(t)})`);if(typeof t==`number`)return x(t);if(Array.isArray(t)){if(e.type===`cubicBezier`&&t.length===4&&t.every(e=>typeof e==`number`))return`cubic-bezier(${t.map(e=>x(e)).join(`, `)})`;if(e.type===`fontFamily`&&t.every(e=>typeof e==`string`))return t.map(e=>/\s/.test(e)?`"${e}"`:e).join(`, `)}else if(t&&typeof t==`object`){if(`unit`in t&&typeof t.value==`number`)return`${x(t.value)}${t.unit}`;if(`color`in t)return[t.offsetX,t.offsetY,t.blur,t.spread,t.color].map(t=>S(e,t)).join(` `)}throw Error(`emitWeb: ${e.path}: cannot write a ${e.type} value as CSS.`)}function C(e,t,n){
|
|
6
|
+
[data-bs-theme="dark"]:not(:root) [data-bs-theme="light"]`,_=`// var() resolves where a name is declared, so the html copies keep the light values for a light box.`,v=`/* var() resolves where a name is declared, so the html copies keep the light values for a light box. */`,y=`// Zero specificity, so a component's own class on a themed section or inside it keeps its colour.`,b=`/* Zero specificity, so a component's own class on a themed section or inside it keeps its colour. */`;function x(e){return String(Number(e.toFixed(4)))}function S(e,t){if(typeof t==`string`)return t.replace(s,(e,t)=>`var(${r(t)})`);if(typeof t==`number`)return x(t);if(Array.isArray(t)){if(e.type===`cubicBezier`&&t.length===4&&t.every(e=>typeof e==`number`))return`cubic-bezier(${t.map(e=>x(e)).join(`, `)})`;if(e.type===`fontFamily`&&t.every(e=>typeof e==`string`))return t.map(e=>/\s/.test(e)?`"${e}"`:e).join(`, `)}else if(t&&typeof t==`object`){if(`unit`in t&&typeof t.value==`number`)return`${x(t.value)}${t.unit}`;if(`color`in t)return[t.offsetX,t.offsetY,t.blur,t.spread,t.color].map(t=>S(e,t)).join(` `)}throw Error(`emitWeb: ${e.path}: cannot write a ${e.type} value as CSS.`)}function C(e,t,n){return S(e.tokens.get(t),e.valueIn(t,n))}function w(e,t){if(t&&typeof t==`object`&&t.unit===`px`&&typeof t.value==`number`)return t.value;throw Error(`emitWeb: ${e}: a text size must be a px dimension.`)}function T(e,a){let s=e.tokens.get(a),c=r(a);if(s.group===`text`){if(t(s).length>0)throw Error(`emitWeb: ${a}: a text size cannot carry breakpoints.`);let r=w(a,e.valueIn(a,o)),l=w(a,e.valueIn(a,i)),u=s.extensions?.fluidUntil;if(r!==l&&u===void 0)throw Error(`emitWeb: ${a}: the 390 and 1440 sizes differ but no fluidUntil is recorded.`);return{path:a,name:c,root:n(r,l,u??1440),tiers:[]}}let l=t(s);return l.length>0?{path:a,name:c,root:C(e,a,o),tiers:l.map(e=>({tier:e.tier,text:S(s,e.value)}))}:{path:a,name:c,root:C(e,a,i),tiers:[]}}function E(e){let t=[];for(let n of e.tokens.keys())e.existsIn(n,i)&&t.push(T(e,n));return t}function D(e,n){let o=[];for(let[s,c]of e.tokens){if(!e.existsIn(s,a)||!e.existsIn(s,i)||t(c).length>0)continue;let l=C(e,s,a);if(c.group===`text`){if(l!==C(e,s,i))throw Error(`emitWeb: ${s}: a text size cannot change with the mode.`);continue}n(s,l)&&o.push({path:s,name:r(s),text:l})}return o}function O(e){let t=Number.parseInt(e.slice(1),16);return`${t>>16&255}, ${t>>8&255}, ${t&255}`}function k(e,t){let n=[];for(let[r,i]of d){let o=`color.${i}`,s=e.resolvedIn(o,a);if(!l.test(s))throw Error(`emitWeb: ${o}: a Bootstrap rgb triplet needs an opaque colour.`);t(o,s)&&n.push({name:r,text:O(s)})}return n}function A(e,t){let n=D(e,t?(e,n)=>!t.tokens.has(e)||!t.existsIn(e,a)||n!==C(t,e,a):(t,n)=>n!==C(e,t,i)),o=k(e,t?(e,n)=>n!==t.resolvedIn(e,a):()=>!0);if(t)return[...n,...o];let s=u.map(([e,t])=>({name:e,text:`var(${r(`color.${t}`)})`}));return[...n,...s,...o]}function j(e,t){return`${e} {\n${t.join(`
|
|
7
7
|
`).split(`
|
|
8
8
|
`).map(e=>e===``?e:` ${e}`).join(`
|
|
9
9
|
`)}\n}`}function M(e){return e.split(`,
|
|
@@ -13,11 +13,8 @@ import{BREAKPOINT_PX as e,breakpointRules as t,fluidLength as n}from"../model/le
|
|
|
13
13
|
|
|
14
14
|
`)}function P(e){return[v,j(`html`,e.map(e=>`--wui-light-${e}: var(--${e});`)),j(g,e.map(e=>`--${e}: var(--wui-light-${e});`)),j(M(g),[`color-scheme: light;`,`color: var(--color-text);`])].join(`
|
|
15
15
|
|
|
16
|
-
`)}function F(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 I(t,n){let r=E(t),i=new Map((n?E(n):[]).map(e=>[e.path,e])),a=[],o=r.filter(e=>i.get(e.path)?.root!==e.root).map(e=>`${e.name}: ${e.root};`);o.length>0&&a.push(j(`:root`,o));for(let[t,n]of Object.entries(e)){let e=[];for(let n of r)for(let r of n.tiers)r.tier===t&&i.get(n.path)?.tiers.find(e=>e.tier===t)?.text!==r.text&&e.push(`${n.name}: ${r.text};`);e.length>0&&a.push(j(`@media (min-width: ${n}px)`,[j(`:root`,e)]))}let s=A(t,n);if(s.length>0){let e=s.map(e=>`${e.name}: ${e.text};`),t=n?b:y;a.push(j(p,[...e,`color-scheme: dark;`]),j(m,e),`${t}\n${j(M(m),[`color-scheme: dark;`,`color: var(--color-text);`])}`);let r=s.map(e=>e.name.slice(2));if(n){let e=new Set(A(n,null).map(e=>e.name.slice(2))),t=r.filter(t=>!e.has(t));t.length>0&&a.push(P(t))}else a.push(N(r));a.push(j(`@media (prefers-color-scheme: dark)`,[j(h,[...e,`color-scheme: dark;`])]))}return[F(t,n!==null,n!==null),...a].join(`
|
|
16
|
+
`)}function F(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 I(t,n){let r=E(t),i=new Map((n?E(n):[]).map(e=>[e.path,e])),a=[],o=r.filter(e=>i.get(e.path)?.root!==e.root).map(e=>`${e.name}: ${e.root};`);o.length>0&&a.push(j(`:root`,o));for(let[t,n]of Object.entries(e)){let e=[];for(let n of r)for(let r of n.tiers)r.tier===t&&i.get(n.path)?.tiers.find(e=>e.tier===t)?.text!==r.text&&e.push(`${n.name}: ${r.text};`);e.length>0&&a.push(j(`@media (min-width: ${n}px)`,[j(`:root`,e)]))}let s=A(t,n);if(s.length>0){let e=s.map(e=>`${e.name}: ${e.text};`),t=n?b:y;a.push(j(p,[...e,`color-scheme: dark;`]),j(m,e),`${t}\n${j(M(m),[`color-scheme: dark;`,`color: var(--color-text);`])}`);let r=s.map(e=>e.name.slice(2));if(n){let e=new Set(A(n,null).map(e=>e.name.slice(2))),t=r.filter(t=>!e.has(t));t.length>0&&a.push(P(t))}else a.push(N(r));a.push(j(`@media (prefers-color-scheme: dark)`,[j(h,[...e,`color-scheme: dark;`])]))}return`${[F(t,n!==null,n!==null),...a].join(`
|
|
17
17
|
|
|
18
|
-
`)
|
|
19
|
-
`}function
|
|
20
|
-
`)
|
|
21
|
-
`}function z(e,t){let n=f.filter(([,n])=>L(e,n)!==L(t,n)).map(([t,n])=>`${t}: ${L(e,n)};`);return[F(e,!0),...n].join(`
|
|
22
|
-
`)+`
|
|
23
|
-
`}function B(e,t){return t===void 0?{tokens:I(e,null),bootstrap:R(e)}:{css:I(e,t.library),variables:z(e,t.library)}}export{B as emitWeb};
|
|
18
|
+
`)}\n`}function L(e,t){let n=e.tokens.get(t);if(n.type===`color`)return e.resolvedIn(t,i);let r=e.valueIn(t,i),a=typeof r==`string`?c.exec(r):null;if(a)return L(e,a[1]);let o=S(n,r);if(o.includes(`var(`))throw Error(`emitWeb: ${t}: a Bootstrap variable needs a literal.`);return o}function R(e){let t=f.map(([t,n])=>`${t}: ${L(e,n)} !default;`);return`${[F(e,!1),...t].join(`
|
|
19
|
+
`)}\n`}function z(e,t){let n=f.filter(([,n])=>L(e,n)!==L(t,n)).map(([t,n])=>`${t}: ${L(e,n)};`);return`${[F(e,!0),...n].join(`
|
|
20
|
+
`)}\n`}function B(e,t){return t===void 0?{tokens:I(e,null),bootstrap:R(e)}:{css:I(e,t.library),variables:z(e,t.library)}}export{B as emitWeb};
|
package/dist/meanings.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"format": "webority-meanings/1",
|
|
3
3
|
"source": {
|
|
4
4
|
"package": "@webority/tokens",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.99.0"
|
|
6
6
|
},
|
|
7
7
|
"color": {
|
|
8
8
|
"bg": {
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
]
|
|
228
228
|
},
|
|
229
229
|
"primary-text": {
|
|
230
|
-
"description": "Primary as text and small glyphs on a page
|
|
230
|
+
"description": "Primary as text and small glyphs on a page.",
|
|
231
231
|
"platforms": [
|
|
232
232
|
"web",
|
|
233
233
|
"phone"
|
package/dist/model/resolve.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{cssVarOfPath as e}from"../names.js";import{
|
|
2
|
-
`));return{tokens:
|
|
1
|
+
import{cssVarOfPath as e}from"../names.js";import{line as t}from"./load.js";import{resolveColour as n}from"./colour.js";import{findCycles as r,mapReferences as i,referencesIn as a}from"./references.js";function o(){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 s(e){return`${e.mode}|${e.platform}|${e.width}`}function c(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 l({tokens:l,layers:u,cssNames:d,source:f,refusals:p}){let m=o(),h=e=>{let t=m.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},g=e=>{let t=[u.base];return e.mode===`dark`&&t.push(u.dark),e.platform===`phone`&&t.push(u.phone),e.platform===`web`&&e.width===390&&t.push(u.width390),t.push(u.brandBase),e.mode===`dark`&&t.push(u.brandDark),t},_=(e,t)=>{let n=g(t).reverse();for(let t of n){let n=t.get(e);if(n)return n}},v=(e,t)=>{let n=l.get(e);return n?n.platforms===null||n.platforms.includes(t.platform):!1},y=(e,t)=>{if(!v(e,t))throw Error(`model: ${e} does not exist on ${t.platform}`)},b=new Map,x=(t,r)=>{let a=`${s(r)}|${t}`;if(b.has(a))return b.get(a);y(t,r);let o=l.get(t),{value:u}=_(t,r),d;if(o.type===`color`){if(typeof u!=`string`)throw Error(`model: ${t} is a colour with a value that is not text`);if(o.extensions.derive)throw Error(`model: ${t} uses derive, which is removed; set the colour itself`);d=n(i(u,t=>`var(${e(t)})`),e=>S(e,r))}else d=i(u,(e,n)=>{let i=x(e,r);return n?i:c(i,e,t)});return b.set(a,d),d},S=(e,t)=>{let n=d.get(e);if(n===void 0||!v(n,t))return;if(l.get(n).type===`color`)return x(n,t);let{value:r}=_(n,t);return typeof r==`string`?r:void 0},C=()=>{for(let e of Object.values(u))for(let[n,r]of e)for(let e of a(r.value))if(!l.has(e)){let i=t(r.file,n,`references ${e}, which no token declares`,`Declare ${e} or correct the name.`);p.includes(i)||p.push(i)}},w=()=>{for(let e of m){let n=new Map;for(let t of l.keys())v(t,e)&&n.set(t,a(_(t,e).value));for(let i of r(n)){let n=t(_(i[0],e).file,i[0],`reference cycle ${i.join(` -> `)}`,`Point one of these tokens at a value instead.`);p.includes(n)||p.push(n)}}},T=()=>{for(let e of m)for(let n of l.keys()){if(!v(n,e))continue;let{file:r,value:i}=_(n,e);for(let o of a(i))if(l.has(o)&&!v(o,e)){let i=t(r,n,`references ${o}, which does not exist on ${e.platform}`,`Mark ${n} for the platform that has ${o}, or give ${n} a ${e.platform} override.`);p.includes(i)||p.push(i)}}},E=()=>{for(let e of m)for(let n of l.keys())if(v(n,e))try{x(n,e)}catch(r){let i=t(_(n,e).file,n,r.message.replace(/\.$/,``),`Correct the value or the tokens it references.`);p.includes(i)||p.push(i)}},D=p.length;C();let O=p.length>D;if(O||w(),O||T(),p.length===0&&E(),p.length>0)throw Error(p.join(`
|
|
2
|
+
`));return{tokens:l,contexts:o(),existsIn:(e,t)=>v(e,h(t)),valueIn:(e,t)=>{let n=h(t);return y(e,n),structuredClone(_(e,n).value)},resolvedIn:(e,t)=>{let n=h(t);return structuredClone(x(e,n))},referenceIn:(e,t)=>{let n=h(t);return y(e,n),a(_(e,n).value)[0]},source:f}}export{o as buildContexts,l as buildModel};
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
},
|
|
186
186
|
"primary-text": {
|
|
187
187
|
"$value": "{palette.primary-ink}",
|
|
188
|
-
"$description": "Primary as text and small glyphs on a page
|
|
188
|
+
"$description": "Primary as text and small glyphs on a page."
|
|
189
189
|
},
|
|
190
190
|
"on-primary": {
|
|
191
191
|
"$value": "{palette.primary-text}",
|
|
@@ -223,23 +223,13 @@
|
|
|
223
223
|
},
|
|
224
224
|
"primary-text": {
|
|
225
225
|
"$type": "color",
|
|
226
|
-
"$value": "
|
|
227
|
-
"$description": "Text and icon colour on a solid primary fill, such as a primary button label."
|
|
228
|
-
"$extensions": {
|
|
229
|
-
"com.webority": {
|
|
230
|
-
"derive": "on-fill"
|
|
231
|
-
}
|
|
232
|
-
}
|
|
226
|
+
"$value": "#ffffff",
|
|
227
|
+
"$description": "Text and icon colour on a solid primary fill, such as a primary button label."
|
|
233
228
|
},
|
|
234
229
|
"primary-ink": {
|
|
235
230
|
"$type": "color",
|
|
236
231
|
"$value": "{palette.primary}",
|
|
237
|
-
"$description": "Primary as text and small glyphs on light surfaces
|
|
238
|
-
"$extensions": {
|
|
239
|
-
"com.webority": {
|
|
240
|
-
"derive": "aa-ink"
|
|
241
|
-
}
|
|
242
|
-
}
|
|
232
|
+
"$description": "Primary as text and small glyphs on light surfaces."
|
|
243
233
|
},
|
|
244
234
|
"info-text": {
|
|
245
235
|
"$type": "color",
|
|
@@ -583,23 +573,13 @@
|
|
|
583
573
|
},
|
|
584
574
|
"dark-primary": {
|
|
585
575
|
"$type": "color",
|
|
586
|
-
"$value": "
|
|
587
|
-
"$description": "Primary as text, rings, focus borders and the fill under dark ink in dark mode."
|
|
588
|
-
"$extensions": {
|
|
589
|
-
"com.webority": {
|
|
590
|
-
"derive": "dark-aa-ink"
|
|
591
|
-
}
|
|
592
|
-
}
|
|
576
|
+
"$value": "#9590ef",
|
|
577
|
+
"$description": "Primary as text, rings, focus borders and the fill under dark ink in dark mode."
|
|
593
578
|
},
|
|
594
579
|
"dark-primary-hover": {
|
|
595
580
|
"$type": "color",
|
|
596
|
-
"$value": "
|
|
597
|
-
"$description": "Primary fill while it is hovered in dark mode."
|
|
598
|
-
"$extensions": {
|
|
599
|
-
"com.webority": {
|
|
600
|
-
"derive": "dark-hover"
|
|
601
|
-
}
|
|
602
|
-
}
|
|
581
|
+
"$value": "#a29df1",
|
|
582
|
+
"$description": "Primary fill while it is hovered in dark mode."
|
|
603
583
|
},
|
|
604
584
|
"dark-chart-2": {
|
|
605
585
|
"$type": "color",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/tokens",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.99.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",
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.97.0",
|
|
3
|
+
"css": {
|
|
4
|
+
"rename": [],
|
|
5
|
+
"reads": [],
|
|
6
|
+
"choose": {},
|
|
7
|
+
"checkRole": []
|
|
8
|
+
},
|
|
9
|
+
"themeReads": [],
|
|
10
|
+
"props": [
|
|
11
|
+
{
|
|
12
|
+
"package": "@webority/ui-react",
|
|
13
|
+
"props": ["variant"],
|
|
14
|
+
"from": "subtle",
|
|
15
|
+
"to": "neutral"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"propValues": [],
|
|
19
|
+
"propSplits": [],
|
|
20
|
+
"razorAttributes": [],
|
|
21
|
+
"source": {
|
|
22
|
+
"literals": [
|
|
23
|
+
["btn-subtle", "btn-neutral"],
|
|
24
|
+
["X-Wui-Data", "Wui-Data"],
|
|
25
|
+
["x-wui-data", "wui-data"],
|
|
26
|
+
["X-Wui-Fragment", "Wui-Fragment"],
|
|
27
|
+
["x-wui-fragment", "wui-fragment"],
|
|
28
|
+
["X-Wui-Keep-Open", "Wui-Keep-Open"],
|
|
29
|
+
["x-wui-keep-open", "wui-keep-open"],
|
|
30
|
+
["X-Wui-Message", "Wui-Message"],
|
|
31
|
+
["x-wui-message", "wui-message"],
|
|
32
|
+
["X-Wui-Next", "Wui-Next"],
|
|
33
|
+
["x-wui-next", "wui-next"],
|
|
34
|
+
["X-Wui-Redirect", "Wui-Redirect"],
|
|
35
|
+
["x-wui-redirect", "wui-redirect"],
|
|
36
|
+
["X-Wui-Request", "Wui-Request"],
|
|
37
|
+
["x-wui-request", "wui-request"],
|
|
38
|
+
["X-Wui-Result", "Wui-Result"],
|
|
39
|
+
["x-wui-result", "wui-result"],
|
|
40
|
+
["X-Wui-Toast-Action", "Wui-Toast-Action"],
|
|
41
|
+
["x-wui-toast-action", "wui-toast-action"],
|
|
42
|
+
["X-Wui-Toast-Variant", "Wui-Toast-Variant"],
|
|
43
|
+
["x-wui-toast-variant", "wui-toast-variant"]
|
|
44
|
+
],
|
|
45
|
+
"members": [],
|
|
46
|
+
"flags": [
|
|
47
|
+
{
|
|
48
|
+
"pattern": "@webority/theme/css/brand-signal|webority-brand-signal\\.css",
|
|
49
|
+
"hint": "removed: build the product's own brand file with `webority brand` and link its generated CSS"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"pattern": "\\bwebority-theme-export\\b",
|
|
53
|
+
"hint": "removed: run `webority brand` from @webority/tokens, which writes webority-theme-tokens/2"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"pattern": "\\b(?:initUI|setTheme|getTheme|subscribeTheme|resetTheme|setColorMode|getColorMode)\\b.*@webority/mobile-ui|@webority/mobile-ui.*\\b(?:initUI|setTheme|getTheme|subscribeTheme|resetTheme|setColorMode|getColorMode)\\b",
|
|
57
|
+
"hint": "removed from @webority/mobile-ui: pass brand, settings and initialPreference to ThemeProvider instead"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/model/derive.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=4.5,t=[`#FFFFFF`,`#F4F6F8`,`#F5F6FA`,`#F9FBFC`],n=[`#0F1117`,`#0D0F15`,`#232733`,`#181B23`],r=`#181B23`,i=`#232733`,a=`#0F0F0F`,o=`#FFFFFF`,s=`#000000`,c=50,l={"on-fill":_,"aa-ink":v,"dark-aa-ink":y,"dark-hover":b};function u(e,t){if(!Object.hasOwn(l,e))throw Error(`Unknown derive rule: ${e}`);return l[e](t)}function d(e){let t=/^#([0-9a-f]{6})$/i.exec(e);if(!t)throw Error(`Not a #rrggbb colour: ${e}`);let n=Number.parseInt(t[1],16);return{r:n>>16&255,g:n>>8&255,b:n&255}}function f(e){return`#${[e.r,e.g,e.b].map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}`}function p(e,t,n){return{r:n*e.r+(1-n)*t.r,g:n*e.g+(1-n)*t.g,b:n*e.b+(1-n)*t.b}}function m(e){let t=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function h(e,t){let n=m(e),r=m(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function g(e,t){let n=21;for(let r of t)n=Math.min(n,h(e,r));return n}function _({primary:e}){let t=d(e);return f(h(d(o),t)>=4.5?d(o):d(a))}function v({primary:e}){let n=d(e),r=[...t.map(d),p(n,d(o),.15)],i=n,a=0;for(;g(i,r)<4.5&&a<c;)a+=1,i=p(d(s),n,a*.02);return f(i)}function y({primary:e}){let t=d(e),s=n.map(d),l=d(a),u=t,m=0;for(;g(u,[...s,p(u,d(r),.15),p(t,d(i),.2),l])<4.5&&m<c;)m+=1,u=p(d(o),t,m*.02);return f(u)}function b({darkPrimary:e}){if(!e)throw Error(`dark-hover needs darkPrimary, the rounded hex that dark-aa-ink returned.`);return f(p(d(o),d(e),.12))}export{e as FLOOR,h as contrast,u as derive};
|