@webority/theme 0.87.1 → 0.87.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as e,writeFileSync as t}from"node:fs";var n=`webority-theme-tokens/1`,r=[`--wui-primary`,`--bs-primary`,`--bs-primary-rgb`,`--bs-link-color-rgb`,`--bs-body-font-family`];function i(e){console.error(`webority-theme-export: ${e}`),console.error(`usage: webority-theme-export <compiled.css>... --product <name> [--out <tokens.json>] [--widths 1440,390]`),process.exit(2)}function a(e){let t=[],n,r,a=[];for(let o=0;o<e.length;o++)e[o]===`--product`?n=e[++o]:e[o]===`--out`?r=e[++o]:e[o]===`--widths`?a=(e[++o]??``).split(`,`).map(e=>e.trim()):e[o].startsWith(`--`)?i(`unknown option ${e[o]}`):t.push(e[o]);return t.length===0&&i(`no compiled CSS file given`),(!n||!/^[a-z0-9-]+$/.test(n))&&i(`--product must be the product's lowercase name`),a.some(e=>!/^[1-9]\d*$/.test(e))&&i(`--widths takes whole pixel widths, such as 1440,390`),a.length>0&&!r&&i(`--widths needs --out, the file name each width's file is named after`),{files:t,product:n,out:r,widths:a.map(Number)}}var o=16;function s(e,t){let n=e.trim(),r=/^(clamp|calc|min|max)\((.*)\)$/.exec(n);if(r){let e=l(r[2],`,`).map(e=>s(e,t));return e.some(e=>e===null)?null:r[1]===`calc`?e.length===1?e[0]:null:r[1]===`clamp`?e.length===3?Math.min(Math.max(e[1],e[0]),e[2]):null:r[1]===`min`?Math.min(...e):Math.max(...e)}let i=n.split(/\s+/),a=0,c=1;for(let e=0;e<i.length;e++){if(e%2==1){if(i[e]!==`+`&&i[e]!==`-`)return null;c=i[e]===`+`?1:-1;continue}let n=/^(-?\d*\.?\d+)(px|rem|vw)?$/.exec(i[e]);if(!n||!n[2]&&Number(n[1])!==0)return null;let r=Number(n[1]),s=n[2]===`rem`?r*o:n[2]===`vw`?r*t/100:r;a+=c*s}return i.length%2==1?a:null}function c(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>{let r=s(n,t);return[e,r===null?n:`${Math.round(r*100)/100}px`]}))}function l(e,t){let n=[],r=0,i=null,a=0;for(let o=0;o<e.length;o++){let s=e[o];i?s===`\\`?o++:s===i&&(i=null):s===`"`||s===`'`?i=s:s===`(`||s===`[`?r++:s===`)`||s===`]`?r--:s===t&&r===0&&(n.push(e.slice(a,o)),a=o+1)}return n.push(e.slice(a)),n}var u=10,d=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,f=/^rgba?\(([\s\S]*)\)$/i,p=/^color-mix\(([\s\S]*)\)$/i,m=/^var\(([\s\S]*)\)$/i;function h(e,t,n=0){if(n>u)return null;let r=e.trim(),i=m.exec(r);if(i){let e=l(i[1],`,`),r=e[0].trim();if(!/^--[a-z0-9-]+$/i.test(r))return null;let a=t(r);if(a!==void 0)return h(a,t,n+1);let o=e.slice(1).join(`,`).trim();return o?h(o,t,n+1):null}let a=d.exec(r);if(a){let e=a[1];e.length<=4&&(e=[...e].map(e=>e+e).join(``)),e.length===6&&(e+=`ff`);let t=t=>Number.parseInt(e.slice(t,t+2),16);return[t(0),t(2),t(4),t(6)/255]}let o=f.exec(r);if(o)return g(o[1]);let s=p.exec(r);if(s)return y(s[1],t,n);let c=r.toLowerCase();return c===`white`?[255,255,255,1]:c===`black`?[0,0,0,1]:c===`transparent`?[0,0,0,0]:null}function g(e){let t=e.trim(),n,r=l(t,`/`);if(r.length>2)return null;r.length===2&&(t=r[0].trim(),n=r[1].trim());let i=l(t,`,`).flatMap(e=>e.trim().split(/\s+/)).filter(Boolean);if(i.length!==3&&i.length!==4)return null;let a=i.slice(0,3).map(e=>/^-?\d*\.?\d+$/.test(e)?Math.min(255,Math.max(0,Number(e))):null);if(a.some(e=>e===null))return null;if(i.length===4){if(n!==void 0)return null;n=i[3]}let o=n===void 0?1:_(n);return o===null?null:[...a,o]}function _(e){let t=e.trim(),n=/^(-?\d*\.?\d+)%$/.exec(t);return n?Math.min(1,Math.max(0,Number(n[1])/100)):/^-?\d*\.?\d+$/.test(t)?Math.min(1,Math.max(0,Number(t))):null}function v(e){let t=e.trim(),n=/\s+(-?\d*\.?\d+)%$/.exec(t);if(!n)return{colour:t};let r=t.slice(0,n.index).trim();return r?{colour:r,percent:Number(n[1])}:null}function y(e,t,n){let r=l(e,`,`);if(r.length!==3||!/^in\s+srgb$/i.test(r[0].trim()))return null;let i=v(r[1]),a=v(r[2]);if(!i||!a)return null;let o=h(i.colour,t,n+1),s=h(a.colour,t,n+1);if(!o||!s)return null;let c=i.percent,u=a.percent,d=1;if(c===void 0&&u===void 0)c=50,u=50;else if(u===void 0)u=100-c;else if(c===void 0)c=100-u;else if(c+u!==100){let e=c+u;e>0?(e<100&&(d=e/100),c=c*100/e,u=u*100/e):(c=0,u=0)}let f=c/100,p=u/100,m=o[3]*f+s[3]*p;return[...[0,1,2].map(e=>m===0?0:(o[e]*o[3]*f+s[e]*s[3]*p)/m),m*d]}function b(e){let t=e.slice(0,3).map(e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,`0`)).join(``),n=Math.round(Math.min(1,Math.max(0,e[3]))*255);return`#${t}${n<255?n.toString(16).padStart(2,`0`):``}`}function x(e){let t=[],n=0,r=null,i=0,a=-1;for(let o=0;o<e.length;o++){let s=e[o];if(r)s===`\\`?o++:s===r&&(r=null);else if(s===`"`||s===`'`)r=s;else if(s===`{`)n===0&&(a=o),n++;else if(s===`}`){if(n--,n===0){let n=e.slice(i,a).trim();n.startsWith(`@`)||t.push({selectors:l(n,`,`).map(S),body:e.slice(a+1,o)}),i=o+1}}else s===`;`&&n===0&&(i=o+1)}return t}function S(e){return e.trim().replace(/\s+/g,` `).replace(/["']/g,``)}var C=new Set([`:root`,`[data-bs-theme=light]`,`:root[data-bs-theme=light]`,`:root[data-theme=light]`]),w=new Set([`:root[data-theme=dark]`,`:root[data-bs-theme=dark]`]),T=new Set([`[data-bs-theme=dark]`]);function E(e){let t=[];for(let n of l(e,`;`)){let e=n.indexOf(`:`);if(e<0)continue;let r=n.slice(0,e).trim();r.startsWith(`--`)&&t.push([r,n.slice(e+1).trim().replace(/\s*!important$/,``)])}return t}function D(e,t,n){for(let[r,i]of Object.entries(e)){if(!i.startsWith(`var(`)&&!i.startsWith(`color-mix(`))continue;let a=h(i,t,0);a
|
|
2
|
+
import{readFileSync as e,writeFileSync as t}from"node:fs";var n=`webority-theme-tokens/1`,r=[`--wui-primary`,`--bs-primary`,`--bs-primary-rgb`,`--bs-link-color-rgb`,`--bs-body-font-family`];function i(e){console.error(`webority-theme-export: ${e}`),console.error(`usage: webority-theme-export <compiled.css>... --product <name> [--out <tokens.json>] [--widths 1440,390]`),process.exit(2)}function a(e){let t=[],n,r,a=[];for(let o=0;o<e.length;o++)e[o]===`--product`?n=e[++o]:e[o]===`--out`?r=e[++o]:e[o]===`--widths`?a=(e[++o]??``).split(`,`).map(e=>e.trim()):e[o].startsWith(`--`)?i(`unknown option ${e[o]}`):t.push(e[o]);return t.length===0&&i(`no compiled CSS file given`),(!n||!/^[a-z0-9-]+$/.test(n))&&i(`--product must be the product's lowercase name`),a.some(e=>!/^[1-9]\d*$/.test(e))&&i(`--widths takes whole pixel widths, such as 1440,390`),a.length>0&&!r&&i(`--widths needs --out, the file name each width's file is named after`),{files:t,product:n,out:r,widths:a.map(Number)}}var o=16;function s(e,t){let n=e.trim(),r=/^(clamp|calc|min|max)\((.*)\)$/.exec(n);if(r){let e=l(r[2],`,`).map(e=>s(e,t));return e.some(e=>e===null)?null:r[1]===`calc`?e.length===1?e[0]:null:r[1]===`clamp`?e.length===3?Math.min(Math.max(e[1],e[0]),e[2]):null:r[1]===`min`?Math.min(...e):Math.max(...e)}let i=n.split(/\s+/),a=0,c=1;for(let e=0;e<i.length;e++){if(e%2==1){if(i[e]!==`+`&&i[e]!==`-`)return null;c=i[e]===`+`?1:-1;continue}let n=/^(-?\d*\.?\d+)(px|rem|vw)?$/.exec(i[e]);if(!n||!n[2]&&Number(n[1])!==0)return null;let r=Number(n[1]),s=n[2]===`rem`?r*o:n[2]===`vw`?r*t/100:r;a+=c*s}return i.length%2==1?a:null}function c(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>{let r=s(n,t);return[e,r===null?n:`${Math.round(r*100)/100}px`]}))}function l(e,t){let n=[],r=0,i=null,a=0;for(let o=0;o<e.length;o++){let s=e[o];i?s===`\\`?o++:s===i&&(i=null):s===`"`||s===`'`?i=s:s===`(`||s===`[`?r++:s===`)`||s===`]`?r--:s===t&&r===0&&(n.push(e.slice(a,o)),a=o+1)}return n.push(e.slice(a)),n}var u=10,d=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,f=/^rgba?\(([\s\S]*)\)$/i,p=/^color-mix\(([\s\S]*)\)$/i,m=/^var\(([\s\S]*)\)$/i;function h(e,t,n=0){if(n>u)return null;let r=e.trim(),i=m.exec(r);if(i){let e=l(i[1],`,`),r=e[0].trim();if(!/^--[a-z0-9-]+$/i.test(r))return null;let a=t(r);if(a!==void 0)return h(a,t,n+1);let o=e.slice(1).join(`,`).trim();return o?h(o,t,n+1):null}let a=d.exec(r);if(a){let e=a[1];e.length<=4&&(e=[...e].map(e=>e+e).join(``)),e.length===6&&(e+=`ff`);let t=t=>Number.parseInt(e.slice(t,t+2),16);return[t(0),t(2),t(4),t(6)/255]}let o=f.exec(r);if(o)return g(o[1]);let s=p.exec(r);if(s)return y(s[1],t,n);let c=r.toLowerCase();return c===`white`?[255,255,255,1]:c===`black`?[0,0,0,1]:c===`transparent`?[0,0,0,0]:null}function g(e){let t=e.trim(),n,r=l(t,`/`);if(r.length>2)return null;r.length===2&&(t=r[0].trim(),n=r[1].trim());let i=l(t,`,`).flatMap(e=>e.trim().split(/\s+/)).filter(Boolean);if(i.length!==3&&i.length!==4)return null;let a=i.slice(0,3).map(e=>/^-?\d*\.?\d+$/.test(e)?Math.min(255,Math.max(0,Number(e))):null);if(a.some(e=>e===null))return null;if(i.length===4){if(n!==void 0)return null;n=i[3]}let o=n===void 0?1:_(n);return o===null?null:[...a,o]}function _(e){let t=e.trim(),n=/^(-?\d*\.?\d+)%$/.exec(t);return n?Math.min(1,Math.max(0,Number(n[1])/100)):/^-?\d*\.?\d+$/.test(t)?Math.min(1,Math.max(0,Number(t))):null}function v(e){let t=e.trim(),n=/\s+(-?\d*\.?\d+)%$/.exec(t);if(!n)return{colour:t};let r=t.slice(0,n.index).trim();return r?{colour:r,percent:Number(n[1])}:null}function y(e,t,n){let r=l(e,`,`);if(r.length!==3||!/^in\s+srgb$/i.test(r[0].trim()))return null;let i=v(r[1]),a=v(r[2]);if(!i||!a)return null;let o=h(i.colour,t,n+1),s=h(a.colour,t,n+1);if(!o||!s)return null;let c=i.percent,u=a.percent,d=1;if(c===void 0&&u===void 0)c=50,u=50;else if(u===void 0)u=100-c;else if(c===void 0)c=100-u;else if(c+u!==100){let e=c+u;e>0?(e<100&&(d=e/100),c=c*100/e,u=u*100/e):(c=0,u=0)}let f=c/100,p=u/100,m=o[3]*f+s[3]*p;return[...[0,1,2].map(e=>m===0?0:(o[e]*o[3]*f+s[e]*s[3]*p)/m),m*d]}function b(e){let t=e.slice(0,3).map(e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,`0`)).join(``),n=Math.round(Math.min(1,Math.max(0,e[3]))*255);return`#${t}${n<255?n.toString(16).padStart(2,`0`):``}`}function x(e){let t=[],n=0,r=null,i=0,a=-1;for(let o=0;o<e.length;o++){let s=e[o];if(r)s===`\\`?o++:s===r&&(r=null);else if(s===`"`||s===`'`)r=s;else if(s===`{`)n===0&&(a=o),n++;else if(s===`}`){if(n--,n===0){let n=e.slice(i,a).trim();n.startsWith(`@`)||t.push({selectors:l(n,`,`).map(S),body:e.slice(a+1,o)}),i=o+1}}else s===`;`&&n===0&&(i=o+1)}return t}function S(e){return e.trim().replace(/\s+/g,` `).replace(/["']/g,``)}var C=new Set([`:root`,`[data-bs-theme=light]`,`:root[data-bs-theme=light]`,`:root[data-theme=light]`]),w=new Set([`:root[data-theme=dark]`,`:root[data-bs-theme=dark]`]),T=new Set([`[data-bs-theme=dark]`]);function E(e){let t=[];for(let n of l(e,`;`)){let e=n.indexOf(`:`);if(e<0)continue;let r=n.slice(0,e).trim();r.startsWith(`--`)&&t.push([r,n.slice(e+1).trim().replace(/\s*!important$/,``)])}return t}function D(e,t){let n=e;for(let e=0;e<8;e+=1){let e=/^var\(\s*(--[\w-]+)\s*\)$/.exec(n);if(!e)return n;if(n=t(e[1]),n===void 0)return null}return null}function O(e,t,n){for(let[r,i]of Object.entries(e)){if(!i.startsWith(`var(`)&&!i.startsWith(`color-mix(`))continue;let a=h(i,t,0);if(a){e[r]=b(a);continue}let o=i.startsWith(`var(`)?D(i,t):null;o!==null&&o!==i?e[r]=o:console.error(`webority-theme-export: ${r} in ${n} left as written: ${i}`)}}var{files:k,product:A,out:j,widths:M}=a(process.argv.slice(2)),N={},P={},F={};for(let t of k){let n=e(t,`utf8`).replace(/\/\*[\s\S]*?\*\//g,``);for(let e of x(n)){let t=t=>e.selectors.some(e=>t.has(e)),n=t(w)?P:t(T)?F:t(C)?N:null;if(n)for(let[t,r]of E(e.body))n[t]=r}}O(N,e=>N[e],`light`),O(P,e=>e in P?P[e]:N[e],`dark`),O(F,e=>e in F?F[e]:e in P?P[e]:N[e],`bootstrapDark`);var I=r.filter(e=>!(e in N));I.length>0&&(console.error(`webority-theme-export: ${k.join(`, `)} declares no ${I.join(`, `)} on :root.`),console.error(`Pass the compiled stylesheet that carries the full theme, not a page or component bundle.`),process.exit(1));var L=e=>Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t))),R=`${JSON.stringify({format:n,product:A,light:L(N),dark:L(P),bootstrapDark:L(F)},null,2)}\n`;if(M.length>0){let e=j.replace(/\.json$/i,``);for(let r of M){let i=`${e}-${r}.json`,a={light:c(N,r),dark:c(P,r),bootstrapDark:c(F,r)},o={format:n,product:A,width:r,light:L(a.light),dark:L(a.dark),bootstrapDark:L(a.bootstrapDark)};t(i,`${JSON.stringify(o,null,2)}\n`),process.stderr.write(`webority-theme-export: ${Object.keys(N).length} light values at ${r}px -> ${i}\n`)}}else j?(t(j,R),process.stderr.write(`webority-theme-export: ${Object.keys(N).length} light and ${Object.keys(P).length} dark and ${Object.keys(F).length} Bootstrap dark values -> ${j}\n`)):process.stdout.write(R);export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/theme",
|
|
3
|
-
"version": "0.87.
|
|
3
|
+
"version": "0.87.3",
|
|
4
4
|
"description": "Webority shared design system — Bootstrap 5.3 SCSS overrides, --wui-* tokens, and shared component CSS. The single source of brand chrome for React portals and Razor sites.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|