@iksnerd/blazon 0.3.1 → 0.3.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.
- package/README.md +3 -1
- package/dist/chunks/{site-builder-CH6OcFSE.js → site-builder-DlaZeZHi.js} +2481 -2396
- package/dist/cli/index.js +3 -3
- package/dist/core/brand/export.d.ts +3 -1
- package/dist/core/brand/export.d.ts.map +1 -1
- package/dist/core/brand/schema.d.ts +21 -0
- package/dist/core/brand/schema.d.ts.map +1 -1
- package/dist/core/checker/catalogue.d.ts +8 -0
- package/dist/core/checker/catalogue.d.ts.map +1 -1
- package/dist/core/fonts.d.ts +10 -1
- package/dist/core/fonts.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/inputs.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/data.d.ts +10 -0
- package/dist/types/data.d.ts.map +1 -1
- package/dist/ui/assets/index-Biy1hkeq.css +2 -0
- package/dist/ui/assets/{index-CLKH0m9J.js → index-dkJG6W9p.js} +10 -3
- package/dist/ui/index.html +2 -2
- package/mcp/dist/index.js +8 -5
- package/package.json +5 -2
- package/plugins/blazon.copy/README.md +14 -12
- package/plugins/blazon.favicons/README.md +3 -0
- package/plugins/blazon.office-template/bin/blazon-blazon.office-template./360/237/224/214 +1 -1
- package/plugins/blazon.platform-tokens/README.md +58 -2
- package/plugins/blazon.platform-tokens/bin/blazon-blazon.platform-tokens./360/237/224/214 +57 -12
- package/plugins/blazon.press-kit/README.md +54 -3
- package/plugins/blazon.press-kit/bin/blazon-blazon.press-kit./360/237/224/214 +247 -49
- package/plugins/blazon.print-book/README.md +14 -3
- package/plugins/blazon.tailwind/README.md +1 -1
- package/plugins/shipped.lock +7 -7
- package/dist/ui/assets/index-DluSqfla.css +0 -2
|
@@ -45,6 +45,13 @@ ${s} .blazon-prose { max-width: none; font-size: 20px; line-height: ${i}; }
|
|
|
45
45
|
${a?`${s} .blazon-prose :is(p, ul, ol, table) { margin-bottom: ${a}; }\n`:``}${o?`${s} .blazon-prose h3 { margin-top: ${o}; }\n`:``}${s} .blazon-prose table { font-size: 16px; }
|
|
46
46
|
${s} .blazon-prose blockquote { font-size: 15px; }
|
|
47
47
|
${s} .blazon-prose p, ${s} .blazon-prose li { max-width: 62ch; }
|
|
48
|
+
/* A Markdown task item (a native checkbox in an li) has no bullet, and its box is drawn by the book: the browser's own is a pale
|
|
49
|
+
grey that all but vanishes on paper. A border in the text colour, a checked box filled with it and a ring of the page colour
|
|
50
|
+
inside, so the two read apart in black and white. 0.8em in a box of the line's size, sunk a little so the text keeps its baseline */
|
|
51
|
+
${s} .blazon-prose li:has(> input[type="checkbox"]) { list-style: none; }
|
|
52
|
+
${s} .blazon-prose li > input[type="checkbox"] { appearance: none; box-sizing: border-box; width: 0.8em; height: 0.8em; margin: 0 0.5em 0 0;
|
|
53
|
+
vertical-align: -0.04em; border: 2px solid var(--foreground); border-radius: 2px; background: transparent; print-color-adjust: exact; }
|
|
54
|
+
${s} .blazon-prose li > input[type="checkbox"]:checked { background: var(--foreground); box-shadow: inset 0 0 0 1.5px var(--background); }
|
|
48
55
|
/* A continued slide's label, the section heading and "(continued)" in the muted colour on one line: the heading gives way
|
|
49
56
|
with an ellipsis, the suffix never. 14px, so 12.6px (9.5 pt) at the smallest a slide is drawn at */
|
|
50
57
|
${s} [data-print-continued-label] { display: flex; height: 20px; margin-bottom: 12px; font: 500 14px/20px var(--font-sans); color: var(--muted-foreground); }
|
|
@@ -70,6 +77,6 @@ ${s} [data-section-asset] img { max-height: 330px; width: auto; max-width: 100%;
|
|
|
70
77
|
/* The viewer's small type, raised by the same 1.11 as the body: its smallest (a caption, a label) is 12px, 9 pt on the
|
|
71
78
|
slide and 8.1 pt at the smallest scale a slide is drawn at. In :where, so a rule above that sets a size (a heading) wins */
|
|
72
79
|
${pS.map(([e,t])=>`${s} :where([class~="${e}"]) { font-size: ${t}px; }`).join(`
|
|
73
|
-
`)}`}var pS=[[`text-[0.625rem]`,12],[`text-[11px]`,12.5],[`text-xs`,13.5],[`text-[0.8rem]`,14],[`text-[13px]`,14.5],[`text-sm`,16],[`text-[15px]`,17],[`text-base`,18],[`text-lg`,20]];function mS(e,t,n,r){let i=document.createElement(`div`);i.dataset.printSlide=e,r&&(i.dataset.printSqueeze=``);let a=document.createElement(`div`);a.dataset.printSlideBody=``,e===`content`&&(a.className=`blazon-prose`);let o=t.map(e=>e.cloneNode(!0));if(n===`split`){a.dataset.layout=`split`;let e=document.createElement(`div`);e.append(...o.slice(0,-1));let t=document.createElement(`div`);t.append(o.at(-1)),a.append(e,t)}else a.append(...o);let s=t[0]?.dataset.printContinued;return e===`content`&&s&&a.prepend(hS(s)),i.append(a),i}function hS(e){let t=document.createElement(`div`);t.dataset.printContinuedLabel=``;let[n,r]=[document.createElement(`span`),document.createElement(`span`)];return n.textContent=e,r.textContent=` (continued)`,t.append(n,r),t}function gS(e,t){let n=document.createElement(`div`);n.dataset.printFooter=``;let[r,i]=[document.createElement(`span`),document.createElement(`span`)];return r.textContent=e,i.textContent=String(t),n.append(r,i),n}var _S=`[data-frame] img:not([data-min-size]), [data-section-asset] img:not([data-min-size])`;function vS(e,t){let n=e.matches(_S)?[e]:[...e.querySelectorAll(_S)];return Math.floor(n.reduce((e,n)=>e+n.getBoundingClientRect().height*(1-t),0))}function yS(e,t){let n=[...e.querySelectorAll(_S)],r=n.map(e=>e.getBoundingClientRect().height),i=r.reduce((e,t)=>e+t,0);for(let a=0;a<bS;a++){let a=e.scrollHeight-iS.height;if(a<=1||i<=0)return;n.forEach((e,n)=>{let o=e.getBoundingClientRect().height;e.style.maxHeight=`${Math.max(r[n]*t,o-a*r[n]/i)}px`})}}var bS=4,xS=.5;function SS(e,t){for(let n of e.querySelectorAll(`[data-min-size]`)){let e=Number(n.dataset.minSize);if(!(e>0))continue;let r=n.dataset.minAxis===`height`?`height`:`width`;n.style[r]=`${e/t}px`,n.style[r===`width`?`height`:`width`]=`auto`}}function CS(e,t){let n=e.querySelector(`[data-print-slide-body]`);if(e.dataset.printSlide!==`content`)return;e.dataset.printSqueeze!==void 0&&yS(n,t);let r=1,i=[...n.querySelectorAll(`[data-frame] img:not([data-min-size]), [data-section-asset] img:not([data-min-size])`)].map(e=>[e,e.getBoundingClientRect().width]);for(let e=0;e<bS;e++){let e=n.scrollHeight;if(!e||e-iS.height/r<=1)break;let t=Math.max(xS,iS.height/e);if(t>=r)break;r=t,n.style.zoom=String(r),n.style.width=`${iS.width/r}px`,n.style.height=`${iS.height/r}px`,SS(n,r);for(let[e,t]of i)t>0&&(e.style.maxWidth=`${t}px`)}n.scrollHeight-iS.height/r>1&&(e.dataset.printClipped=``)}var wS=2,TS=e=>e instanceof HTMLElement&&![`STYLE`,`SCRIPT`].includes(e.tagName)&&e.getBoundingClientRect().height>0;function ES(e){if(e instanceof HTMLTableElement){let t=[...e.tBodies].flatMap(e=>[...e.rows]);return t.length>1?{target:e,groups:t.map(e=>[e]),head:e.tHead}:null}let t=[],n=-1/0;for(let r of e.children){if(!TS(r))continue;let e=r.getBoundingClientRect().top;t.length===0||e-n>=wS?t.push([r]):t.at(-1).push(r),n=e}return t.length>1?{target:e,groups:t,head:null}:null}function DS(e){if(e instanceof HTMLTableElement||e instanceof HTMLUListElement||e instanceof HTMLOListElement)return!0;let{display:t,flexWrap:n}=getComputedStyle(e);return t.includes(`grid`)||t.includes(`flex`)&&n!==`nowrap`}function OS(e){let t=null;for(let n of[e,...e.querySelectorAll(`table, div, ul, ol, section`)]){if(!DS(n)||n.closest(`figure`)!==null&&e.contains(n.closest(`figure`)))continue;let r=ES(n);r&&(!t||r.groups.length>t.groups.length)&&(t=r)}return t}function kS(e,t){let n=[];for(let r=t;r!==e;r=r.parentElement)n.unshift([...r.parentElement.children].indexOf(r));return n}function AS(e,t,n,r,i=``){let a=OS(e);if(!a)return null;if(jS(a)){let o=e.cloneNode(!0),s=o;for(let t of kS(e,a.target))s=s.children[t];for(let e of s.children)e instanceof HTMLElement&&(e.style.gridColumn=`auto`);e.after(o);try{let a=IS(o,t-e.getBoundingClientRect().height+o.getBoundingClientRect().height,n,r,i,!0);if(a)return a}finally{o.remove()}}return IS(e,t,n,r,i,!1)}function jS({target:e,groups:t}){return!(e instanceof HTMLTableElement)&&getComputedStyle(e).display.includes(`grid`)&&t.length>1&&t.every(e=>e.length===1&&e[0].classList.contains(`col-span-full`))}function MS(e){return e.length>2&&e.slice(0,-1).every(t=>Math.abs(t-e[0])<=1)}var NS=48;function PS({target:e,groups:t}){return e instanceof HTMLTableElement&&t.length>3&&e.getBoundingClientRect().width*2+NS<=iS.width&&e.tFoot===null&&e.caption===null&&e.querySelector(`[rowspan], [colspan], table table`)===null}function FS(e,t,n){let r=e.cloneNode(!0),i=e=>[...e.querySelectorAll(`tbody tr`)];i(e).slice(n).forEach(e=>e.remove()),i(r).slice(0,n).forEach(e=>e.remove());let a=document.createElement(`div`);a.dataset.printColumns=``,a.style.cssText=`display:flex;align-items:flex-start;gap:${NS}px;margin-bottom:${getComputedStyle(e).marginBottom}`;for(let n of[e,r]){for(let e of[...n.tBodies])e.rows.length===0&&e.remove();let e=document.createElement(`colgroup`);for(let n of t)e.append(Object.assign(document.createElement(`col`),{style:`width:${n}px`}));n.prepend(e),n.style.cssText=`table-layout:fixed;width:${t.reduce((e,t)=>e+t,0)}px;margin:0`,a.append(n)}return a}function IS(e,t,n,r,i,a){let o=OS(e);if(!o)return null;let{target:s,groups:c,head:l}=o,u=e.getBoundingClientRect().top,d=c.map(e=>e[0].getBoundingClientRect().top),f=Math.max(...c.at(-1).map(e=>e.getBoundingClientRect().bottom)),p=d.map((e,t)=>(d[t+1]??f)-e),m=d[0]-u,h=Math.max(0,t-m-p.reduce((e,t)=>e+t,0)),g=(l?d[0]-l.getBoundingClientRect().top:0)+(i?32:0),_=PS(o),v=d.length>1?d[1]-Math.max(...c[0].map(e=>e.getBoundingClientRect().bottom)):0,y=!_&&!a&&!(s instanceof HTMLTableElement||s instanceof HTMLUListElement||s instanceof HTMLOListElement)&&MS(p)?zS+(iS.height-aS)+Math.max(0,v):0,b=_||a?Rx(p,n-m,r-g,_?2:1):Lx(p,n-m+y,r-g+y).map(e=>[e]),x=b.map(e=>[e[0][0],e.at(-1)[1]]);if(x.length<2&&!(a||_&&b[0].length>1))return null;let S=_?[...(l?.rows[0]??s.tBodies[0].rows[0]).cells].map(e=>e.getBoundingClientRect().width):[],C=kS(e,s),w=[],T=[];return x.forEach(([t,n],r)=>{let a=e.cloneNode(!0),o=a,l=[a];for(let e of C)l.push(o=o.children[e]);l.forEach((e,t)=>{let n=l[t+1];if(!n)return;let i=[...e.children],a=i.indexOf(n);i.forEach((e,t)=>{(t<a&&r>0||t>a&&r<x.length-1)&&e.remove()})});let u=new Set(c.slice(t,n).flat()),d=s instanceof HTMLTableElement?[...o.querySelectorAll(`tbody tr`)]:[...o.children].filter(e=>e instanceof HTMLElement),f=s instanceof HTMLTableElement?c.flat():[...s.children].filter(e=>e instanceof HTMLElement);if(d.forEach((e,t)=>{u.has(f[t])||e.remove()}),o instanceof HTMLTableElement)for(let e of[...o.tBodies])e.rows.length===0&&e.remove();o instanceof HTMLOListElement&&(o.start=s.start+f.slice(0,f.indexOf(c[t][0])).filter(e=>e.tagName===`LI`).length);let v=a,y=b[r];if(_&&y.length>1&&o instanceof HTMLTableElement){let e=FS(o,S,y[0][1]-t);o===a?v=e:o.replaceWith(e)}if(r>0){v.dataset.printContinued=i;for(let e of v.querySelectorAll(`[id]`))e.removeAttribute(`id`);v.removeAttribute(`id`)}w.push(v);let E=Math.max(...y.map(([e,t])=>p.slice(e,t).reduce((e,t)=>e+t,0)));T.push(E+(r===0?m:g)+(r===x.length-1?h:0))}),{els:w,heights:T}}function LS(e,t,n){let r=0,i=n-1;for(i>=0&&e[i].lead&&(r+=t[i--]);i>=0&&e[i].kind===`heading`;)r+=t[i--];return r}function RS(e,t){let n=e=>(e?.textContent??``).replace(/\s+/g,` `).trim();for(let r=t-1;r>=0&&e[r].kind!==`opener`;r--){let t=e[r].el;if(/^H[2-6]$/.test(t.tagName)&&n(t))return n(t)}return n(e[t].el.querySelector(`h2, h3, h4, h5, h6`))}var zS=16;function BS(e,t,n){let r=[],i=[];return e.forEach((a,o)=>{let s=t[o],c=LS(e,t,o),l=a.kind!==`opener`&&c+s>n*1.1111111111111112?AS(a.el,s,n-c-zS,n-zS,RS(e,o)):null;l?l.els.forEach((e,t)=>{r.push({el:e,origin:a.el,...t===0&&a.kind&&{kind:a.kind},...t>0&&{continued:!0},...a.figure&&{figure:!0},...a.table&&{table:!0}}),i.push(l.heights[t])}):(r.push(a),i.push(s))}),{blocks:r,heights:i}}function VS(e){return e.length===0?[[]]:Rx(e,10,10,3)}function HS(e,t,n){let r=n-t;return e.map(e=>r>0?Math.max(1,Math.round((e-t)/r)+1):1)}var US=e=>`print-page-${e}`;function WS(e){let t=e.split(`/`).pop()??``,n=/^(?:\d+(?:\.\d+)?[-_.])?(.+?)\.(?:md|markdown)$/.exec(t);return n?`doc/${n[1]}`:null}function GS(e,t){try{return new URL(e,t).origin===t}catch{return!1}}function KS(e,t,n){let r;try{r=new URL(e,t)}catch{return null}if(r.origin!==t)return null;let i=decodeURIComponent(r.hash.slice(1)),a=WS(r.pathname);return a===null?null:i&&(n.headingPage.get(`${a}#section-${i}`)??n.headingPage.get(`${a}#${i}`))||n.chapterPage.get(a)||null}function qS(e,t,n){let r=0;for(let i of e.querySelectorAll(`a[href]`)){let e=i.getAttribute(`href`)??``,a=KS(e,t,n);if(a===null)GS(e,t)&&i.removeAttribute(`href`);else{if(i.setAttribute(`href`,`#${US(a)}`),!i.querySelector(`[data-print-page-ref]`)){let e=i.ownerDocument.createElement(`span`);e.dataset.printPageRef=``,e.textContent=`, p. ${a}`,i.append(e)}r++}}return r}var JS=15e3;
|
|
74
|
-
`),[m,h]=(0,_.useState)(),g=VS(m?.key===p?m.lines:f.map(()=>1)),v=sS(g.length),y=(0,_.useRef)(null),b=(0,_.useRef)(null),x=(0,_.useRef)(null),[S,C]=(0,_.useState)([]);(0,_.useEffect)(()=>{let e=!1;return
|
|
75
|
-
M`,...f].map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex items-start justify-between gap-6 border-b py-1 text-lg`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 whitespace-pre-line [overflow-wrap:anywhere]`,children:e}),(0,Z.jsx)(`span`,{className:`flex-none whitespace-nowrap`,children:`9999`})]},t))}),(0,Z.jsx)(`div`,{ref:x,"data-print-deck":``}),(0,Z.jsx)(`div`,{ref:b,"data-print-flow":``,"aria-hidden":`true`,children:d.map(e=>(0,Z.jsxs)(`section`,{"data-print-chapter":e.id,children:[(0,Z.jsx)(`h2`,{"data-print-chapter-title":``,className:`sr-only`,children:e.title}),e.body()]},e.id))})]})}function
|
|
80
|
+
`)}`}var pS=[[`text-[0.625rem]`,12],[`text-[11px]`,12.5],[`text-xs`,13.5],[`text-[0.8rem]`,14],[`text-[13px]`,14.5],[`text-sm`,16],[`text-[15px]`,17],[`text-base`,18],[`text-lg`,20]];function mS(e,t,n,r){let i=document.createElement(`div`);i.dataset.printSlide=e,r&&(i.dataset.printSqueeze=``);let a=document.createElement(`div`);a.dataset.printSlideBody=``,e===`content`&&(a.className=`blazon-prose`);let o=t.map(e=>e.cloneNode(!0));if(n===`split`){a.dataset.layout=`split`;let e=document.createElement(`div`);e.append(...o.slice(0,-1));let t=document.createElement(`div`);t.append(o.at(-1)),a.append(e,t)}else a.append(...o);let s=t[0]?.dataset.printContinued;return e===`content`&&s&&a.prepend(hS(s)),i.append(a),i}function hS(e){let t=document.createElement(`div`);t.dataset.printContinuedLabel=``;let[n,r]=[document.createElement(`span`),document.createElement(`span`)];return n.textContent=e,r.textContent=` (continued)`,t.append(n,r),t}function gS(e,t){let n=document.createElement(`div`);n.dataset.printFooter=``;let[r,i]=[document.createElement(`span`),document.createElement(`span`)];return r.textContent=e,i.textContent=String(t),n.append(r,i),n}var _S=`[data-frame] img:not([data-min-size]), [data-section-asset] img:not([data-min-size])`;function vS(e,t){let n=e.matches(_S)?[e]:[...e.querySelectorAll(_S)];return Math.floor(n.reduce((e,n)=>e+n.getBoundingClientRect().height*(1-t),0))}function yS(e,t){let n=[...e.querySelectorAll(_S)],r=n.map(e=>e.getBoundingClientRect().height),i=r.reduce((e,t)=>e+t,0);for(let a=0;a<bS;a++){let a=e.scrollHeight-iS.height;if(a<=1||i<=0)return;n.forEach((e,n)=>{let o=e.getBoundingClientRect().height;e.style.maxHeight=`${Math.max(r[n]*t,o-a*r[n]/i)}px`})}}var bS=4,xS=.5;function SS(e,t){for(let n of e.querySelectorAll(`[data-min-size]`)){let e=Number(n.dataset.minSize);if(!(e>0))continue;let r=n.dataset.minAxis===`height`?`height`:`width`;n.style[r]=`${e/t}px`,n.style[r===`width`?`height`:`width`]=`auto`}}function CS(e,t){let n=e.querySelector(`[data-print-slide-body]`);if(e.dataset.printSlide!==`content`)return;e.dataset.printSqueeze!==void 0&&yS(n,t);let r=1,i=[...n.querySelectorAll(`[data-frame] img:not([data-min-size]), [data-section-asset] img:not([data-min-size])`)].map(e=>[e,e.getBoundingClientRect().width]);for(let e=0;e<bS;e++){let e=n.scrollHeight;if(!e||e-iS.height/r<=1)break;let t=Math.max(xS,iS.height/e);if(t>=r)break;r=t,n.style.zoom=String(r),n.style.width=`${iS.width/r}px`,n.style.height=`${iS.height/r}px`,SS(n,r);for(let[e,t]of i)t>0&&(e.style.maxWidth=`${t}px`)}n.scrollHeight-iS.height/r>1&&(e.dataset.printClipped=``)}var wS=2,TS=e=>e instanceof HTMLElement&&![`STYLE`,`SCRIPT`].includes(e.tagName)&&e.getBoundingClientRect().height>0;function ES(e){if(e instanceof HTMLTableElement){let t=[...e.tBodies].flatMap(e=>[...e.rows]);return t.length>1?{target:e,groups:t.map(e=>[e]),head:e.tHead}:null}let t=[],n=-1/0;for(let r of e.children){if(!TS(r))continue;let e=r.getBoundingClientRect().top;t.length===0||e-n>=wS?t.push([r]):t.at(-1).push(r),n=e}return t.length>1?{target:e,groups:t,head:null}:null}function DS(e){if(e instanceof HTMLTableElement||e instanceof HTMLUListElement||e instanceof HTMLOListElement)return!0;let{display:t,flexWrap:n}=getComputedStyle(e);return t.includes(`grid`)||t.includes(`flex`)&&n!==`nowrap`}function OS(e){let t=null;for(let n of[e,...e.querySelectorAll(`table, div, ul, ol, section`)]){if(!DS(n)||n.closest(`figure`)!==null&&e.contains(n.closest(`figure`)))continue;let r=ES(n);r&&(!t||r.groups.length>t.groups.length)&&(t=r)}return t}function kS(e,t){let n=[];for(let r=t;r!==e;r=r.parentElement)n.unshift([...r.parentElement.children].indexOf(r));return n}function AS(e,t,n,r,i=``){let a=OS(e);if(!a)return null;if(jS(a)){let o=e.cloneNode(!0),s=o;for(let t of kS(e,a.target))s=s.children[t];for(let e of s.children)e instanceof HTMLElement&&(e.style.gridColumn=`auto`);e.after(o);try{let a=IS(o,t-e.getBoundingClientRect().height+o.getBoundingClientRect().height,n,r,i,!0);if(a)return a}finally{o.remove()}}return IS(e,t,n,r,i,!1)}function jS({target:e,groups:t}){return!(e instanceof HTMLTableElement)&&getComputedStyle(e).display.includes(`grid`)&&t.length>1&&t.every(e=>e.length===1&&e[0].classList.contains(`col-span-full`))}function MS(e){return e.length>2&&e.slice(0,-1).every(t=>Math.abs(t-e[0])<=1)}var NS=48;function PS({target:e,groups:t}){return e instanceof HTMLTableElement&&t.length>3&&e.getBoundingClientRect().width*2+NS<=iS.width&&e.tFoot===null&&e.caption===null&&e.querySelector(`[rowspan], [colspan], table table`)===null}function FS(e,t,n){let r=e.cloneNode(!0),i=e=>[...e.querySelectorAll(`tbody tr`)];i(e).slice(n).forEach(e=>e.remove()),i(r).slice(0,n).forEach(e=>e.remove());let a=document.createElement(`div`);a.dataset.printColumns=``,a.style.cssText=`display:flex;align-items:flex-start;gap:${NS}px;margin-bottom:${getComputedStyle(e).marginBottom}`;for(let n of[e,r]){for(let e of[...n.tBodies])e.rows.length===0&&e.remove();let e=document.createElement(`colgroup`);for(let n of t)e.append(Object.assign(document.createElement(`col`),{style:`width:${n}px`}));n.prepend(e),n.style.cssText=`table-layout:fixed;width:${t.reduce((e,t)=>e+t,0)}px;margin:0`,a.append(n)}return a}function IS(e,t,n,r,i,a){let o=OS(e);if(!o)return null;let{target:s,groups:c,head:l}=o,u=e.getBoundingClientRect().top,d=c.map(e=>e[0].getBoundingClientRect().top),f=Math.max(...c.at(-1).map(e=>e.getBoundingClientRect().bottom)),p=d.map((e,t)=>(d[t+1]??f)-e),m=d[0]-u,h=Math.max(0,t-m-p.reduce((e,t)=>e+t,0)),g=(l?d[0]-l.getBoundingClientRect().top:0)+(i?32:0),_=PS(o),v=d.length>1?d[1]-Math.max(...c[0].map(e=>e.getBoundingClientRect().bottom)):0,y=!_&&!a&&!(s instanceof HTMLTableElement||s instanceof HTMLUListElement||s instanceof HTMLOListElement)&&MS(p)?zS+(iS.height-aS)+Math.max(0,v):0,b=_||a?Rx(p,n-m,r-g,_?2:1):Lx(p,n-m+y,r-g+y).map(e=>[e]),x=b.map(e=>[e[0][0],e.at(-1)[1]]);if(x.length<2&&!(a||_&&b[0].length>1))return null;let S=_?[...(l?.rows[0]??s.tBodies[0].rows[0]).cells].map(e=>e.getBoundingClientRect().width):[],C=kS(e,s),w=[],T=[];return x.forEach(([t,n],r)=>{let a=e.cloneNode(!0),o=a,l=[a];for(let e of C)l.push(o=o.children[e]);l.forEach((e,t)=>{let n=l[t+1];if(!n)return;let i=[...e.children],a=i.indexOf(n);i.forEach((e,t)=>{(t<a&&r>0||t>a&&r<x.length-1)&&e.remove()})});let u=new Set(c.slice(t,n).flat()),d=s instanceof HTMLTableElement?[...o.querySelectorAll(`tbody tr`)]:[...o.children].filter(e=>e instanceof HTMLElement),f=s instanceof HTMLTableElement?c.flat():[...s.children].filter(e=>e instanceof HTMLElement);if(d.forEach((e,t)=>{u.has(f[t])||e.remove()}),o instanceof HTMLTableElement)for(let e of[...o.tBodies])e.rows.length===0&&e.remove();o instanceof HTMLOListElement&&(o.start=s.start+f.slice(0,f.indexOf(c[t][0])).filter(e=>e.tagName===`LI`).length);let v=a,y=b[r];if(_&&y.length>1&&o instanceof HTMLTableElement){let e=FS(o,S,y[0][1]-t);o===a?v=e:o.replaceWith(e)}if(r>0){v.dataset.printContinued=i;for(let e of v.querySelectorAll(`[id]`))e.removeAttribute(`id`);v.removeAttribute(`id`)}w.push(v);let E=Math.max(...y.map(([e,t])=>p.slice(e,t).reduce((e,t)=>e+t,0)));T.push(E+(r===0?m:g)+(r===x.length-1?h:0))}),{els:w,heights:T}}function LS(e,t,n){let r=0,i=n-1;for(i>=0&&e[i].lead&&(r+=t[i--]);i>=0&&e[i].kind===`heading`;)r+=t[i--];return r}function RS(e,t){let n=e=>(e?.textContent??``).replace(/\s+/g,` `).trim();for(let r=t-1;r>=0&&e[r].kind!==`opener`;r--){let t=e[r].el;if(/^H[2-6]$/.test(t.tagName)&&n(t))return n(t)}return n(e[t].el.querySelector(`h2, h3, h4, h5, h6`))}var zS=16;function BS(e,t,n){let r=[],i=[];return e.forEach((a,o)=>{let s=t[o],c=LS(e,t,o),l=a.kind!==`opener`&&c+s>n*1.1111111111111112?AS(a.el,s,n-c-zS,n-zS,RS(e,o)):null;l?l.els.forEach((e,t)=>{r.push({el:e,origin:a.el,...t===0&&a.kind&&{kind:a.kind},...t>0&&{continued:!0},...a.figure&&{figure:!0},...a.table&&{table:!0}}),i.push(l.heights[t])}):(r.push(a),i.push(s))}),{blocks:r,heights:i}}function VS(e){return e.length===0?[[]]:Rx(e,10,10,3)}function HS(e,t,n){let r=n-t;return e.map(e=>r>0?Math.max(1,Math.round((e-t)/r)+1):1)}var US=e=>`print-page-${e}`;function WS(e){let t=e.split(`/`).pop()??``,n=/^(?:\d+(?:\.\d+)?[-_.])?(.+?)\.(?:md|markdown)$/.exec(t);return n?`doc/${n[1]}`:null}function GS(e,t){try{return new URL(e,t).origin===t}catch{return!1}}function KS(e,t,n){let r;try{r=new URL(e,t)}catch{return null}if(r.origin!==t)return null;let i=decodeURIComponent(r.hash.slice(1)),a=WS(r.pathname);return a===null?null:i&&(n.headingPage.get(`${a}#section-${i}`)??n.headingPage.get(`${a}#${i}`))||n.chapterPage.get(a)||null}function qS(e,t,n){let r=0;for(let i of e.querySelectorAll(`a[href]`)){let e=i.getAttribute(`href`)??``,a=KS(e,t,n);if(a===null)GS(e,t)&&i.removeAttribute(`href`);else{if(i.setAttribute(`href`,`#${US(a)}`),!i.querySelector(`[data-print-page-ref]`)){let e=i.ownerDocument.createElement(`span`);e.dataset.printPageRef=``,e.textContent=`, p. ${a}`,i.append(e)}r++}}return r}var JS=15e3,YS=new WeakSet;if(typeof document<`u`)for(let e of[`load`,`error`])document.addEventListener(e,e=>YS.add(e.target),!0);function XS(){return[...document.querySelectorAll(`link[rel~="stylesheet"]`)].filter(e=>!e.sheet&&!YS.has(e))}function ZS(e){return new Promise(t=>{let n=setInterval(()=>e.isConnected||r(),50);function r(){clearInterval(n),t()}e.addEventListener(`load`,r),e.addEventListener(`error`,r)})}async function QS(e){let t=[...e.querySelectorAll(`img`)];for(let e of t)e.loading=`eager`;let n=(async()=>{for(;await Promise.all(XS().map(ZS)),e.offsetHeight,await document.fonts?.ready,XS().length!==0||(document.fonts?.status??`loaded`)!==`loaded`;);await Promise.all(t.map(e=>e.decode?.().catch(()=>void 0)))})();await Promise.race([n,new Promise(e=>setTimeout(e,JS))])}function $S({data:e,view:t,mode:n,selection:r,title:i,subtitle:a,favicons:o,layout:s=`compact`}){let{squeezeFloor:c}=dS(s),l=i??e.title,u=a??e.description,d=tS(r,e,t,n,o),f=d.map(e=>e.title),p=f.join(`
|
|
81
|
+
`),[m,h]=(0,_.useState)(),g=VS(m?.key===p?m.lines:f.map(()=>1)),v=sS(g.length),y=(0,_.useRef)(null),b=(0,_.useRef)(null),x=(0,_.useRef)(null),[S,C]=(0,_.useState)([]);(0,_.useEffect)(()=>{let e=!1;return QS(y.current).then(()=>{if(e||!y.current)return;let[t,n,...r]=[...y.current.children].map(e=>e.getBoundingClientRect().height);h({key:p,lines:HS(r,t,n)})}),()=>{e=!0}},[p]),(0,_.useEffect)(()=>{let e=!1;if(Reflect.deleteProperty(window,`__blazonPrint`),o!==void 0&&m?.key===p)return QS(b.current).then(async()=>{if(e||!b.current||!x.current)return;let t=[],n=[],r=new Map,i=new Map;for(let e of b.current.querySelectorAll(`[data-print-chapter]`)){let a=Yx(e),{blocks:o,heights:s}=BS(a,Xx(a,e),aS),u=o.map((e,t)=>({height:s[t],...e.kind&&{kind:e.kind},...e.figure&&{figure:!0},...e.table&&{table:!0},...e.lead&&{lead:!0},...e.continued&&{continued:!0},...e.figure&&vS(e.el,c)>0&&{slack:vS(e.el,c)}})),d=Kx(Ux(u,aS),u,aS);t.push(v+n.length),i.set(e.dataset.printChapter,v+n.length);for(let t of e.querySelectorAll(`section[id]`)){let i=o.findIndex(e=>t.contains(e.origin??e.el)),a=d.findIndex(e=>e.blocks.includes(i));i>=0&&a>=0&&r.set(`${e.dataset.printChapter}#${t.id}`,v+n.length+a)}for(let e of d){let t=o[e.blocks[0]].kind===`opener`?`opener`:`content`,r=mS(t,e.blocks.map(e=>o[e].el),e.layout,e.squeeze);t===`content`&&r.append(gS(l,v+n.length)),n.push(r)}}n.forEach((e,t)=>void(e.id=US(v+t)));for(let e of n)qS(e,window.location.origin,{chapterPage:i,headingPage:r});x.current.replaceChildren(...n),await QS(x.current),e||(n.forEach(e=>CS(e,c)),C(t),window.__blazonPrint={ready:!0,pages:v-1+n.length,layout:s,clipped:n.flatMap((e,t)=>e.dataset.printClipped===void 0?[]:[v+t])})}),()=>{e=!0}},[r,o,l,v,m,p,s,c]);let w=Ee(e.theme.inverse,e.theme.inverseText)?`dark`:`light`,T=Te(e,e.theme.inverse,w===`dark`);return(0,Z.jsxs)(`main`,{"data-print-book":``,className:`bg-background text-foreground`,children:[(0,Z.jsx)(`style`,{children:fS(s)}),(0,Z.jsxs)(`div`,{"data-print-slide":`cover`,className:`flex flex-col justify-end gap-6 bg-[var(--blazon-inverse)] p-20 text-[var(--blazon-inverse-text)]`,children:[T&&(0,Z.jsx)(`img`,{"data-print-cover-logo":``,className:`mb-auto h-12 w-auto self-start`,src:T,alt:``}),(0,Z.jsx)(`h1`,{className:`font-heading text-[96px] leading-[0.95] font-semibold tracking-[-0.035em]`,children:l}),u&&(0,Z.jsx)(`p`,{className:`max-w-3xl text-xl opacity-80`,children:u})]}),g.map((e,t)=>(0,Z.jsxs)(`div`,{"data-print-slide":`contents`,"data-print-contents":``,children:[(0,Z.jsx)(`h2`,{className:`mb-8`,children:t===0?`Contents`:`Contents (continued)`}),(0,Z.jsx)(`div`,{className:`grid`,style:{gridTemplateColumns:`repeat(3, minmax(0, 1fr))`,columnGap:48},children:e.map(([e,t])=>(0,Z.jsx)(`ol`,{className:`flex flex-col gap-y-2`,children:d.slice(e,t).map((t,n)=>(0,Z.jsxs)(`li`,{"data-chapter":t.id,className:`flex items-start justify-between gap-6 border-b py-1 text-lg`,children:[(0,Z.jsx)(`span`,{"data-title":``,className:`min-w-0 [overflow-wrap:anywhere]`,children:t.title}),S[e+n]!==void 0&&(0,Z.jsx)(`span`,{"data-page":``,className:`flex-none whitespace-nowrap`,children:S[e+n]})]},t.id))},e))}),(0,Z.jsxs)(`div`,{"data-print-footer":``,children:[(0,Z.jsx)(`span`,{children:l}),(0,Z.jsx)(`span`,{children:2+t})]})]},t)),(0,Z.jsx)(`ol`,{ref:y,"aria-hidden":`true`,"data-print-probe":``,className:`flex flex-col`,style:{position:`absolute`,left:-1e5,top:0,width:oS},children:[`M`,`M
|
|
82
|
+
M`,...f].map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex items-start justify-between gap-6 border-b py-1 text-lg`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 whitespace-pre-line [overflow-wrap:anywhere]`,children:e}),(0,Z.jsx)(`span`,{className:`flex-none whitespace-nowrap`,children:`9999`})]},t))}),(0,Z.jsx)(`div`,{ref:x,"data-print-deck":``}),(0,Z.jsx)(`div`,{ref:b,"data-print-flow":``,"aria-hidden":`true`,children:d.map(e=>(0,Z.jsxs)(`section`,{"data-print-chapter":e.id,children:[(0,Z.jsx)(`h2`,{"data-print-chapter-title":``,className:`sr-only`,children:e.title}),e.body()]},e.id))})]})}function eC(e){let[t=``,n=``]=tC(e,`?`),r={selection:t.slice(7)};for(let e of n.split(`&`)){let[t=``,n=``]=tC(e,`=`);if(t===`title`||t===`subtitle`||t===`layout`)try{let e=decodeURIComponent(n);t===`layout`?r.layout=uS(e):e!==``&&(r[t]=e)}catch{}}return r}function tC(e,t){let n=e.indexOf(t);return n<0?[e]:[e.slice(0,n),e.slice(n+1)]}function nC(){let[e,t]=(0,_.useState)(()=>window.location.hash);return(0,_.useEffect)(()=>{let e=()=>t(window.location.hash);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),e}function rC({data:e,view:t,hash:n,query:r,mode:i,favicons:a}){if(r)return(0,Z.jsx)(iy,{data:t,query:r});if(n.startsWith(`#doc/`)){let r=e.docs.find(e=>e.slug===n.slice(5));if(r)return(0,Z.jsx)(Jv,{data:t,doc:r,mode:i})}let o=Fy[n];if(o)return(0,Z.jsx)(o,{data:t});if(n===`#review`)return(0,Z.jsx)(Hy,{data:e});if(n===`#favicons`&&a!==null)return a?(0,Z.jsx)(Nx,{data:e,favicons:a}):null;if(n.startsWith(`#assets/`)){let t=ye(e).find(e=>`#assets/${e.category}`===n);if(t)return(0,Z.jsx)(Dx,{data:e,assets:t.assets,title:t.label,description:t.description,rules:t.rules,kind:be(t)})}return(0,Z.jsx)(Px,{})}function iC(e,t,n,r){if(n)return{section:`Search`,page:n};if(t.startsWith(`#doc/`)){let n=e.docs.find(e=>e.slug===t.slice(5));if(n)return{section:_e(n),page:n.title}}if(t===`#tokens/all`)return{section:`Tokens`,page:`All tokens`};let i=he.find(e=>e.hash===t);if(i)return{section:`Tokens`,page:i.label};if(t===`#review`)return{section:`Quality`,page:`Review`};if(t===`#favicons`&&r!==null)return{section:`Assets`,page:`Favicons`};let a=ye(e).find(e=>`#assets/${e.category}`===t);return a?{section:`Assets`,page:a.label}:{section:e.title,page:`Not found`}}var aC=()=>void 0;function oC(){let{toggleSidebar:e}=Cm();return(0,Z.jsx)(Tu,{variant:`ghost`,size:`icon`,"aria-label":`Menu`,className:`-ml-1 lg:hidden`,onClick:e,children:(0,Z.jsx)(td,{})})}function sC(){let e=b(),t=nC(),[n,r]=ze(),[i,a]=(0,_.useState)({text:``,hash:t});i.hash!==t&&a({text:``,hash:t});let o=i.text,s=e=>a({text:e,hash:t}),[c,l]=zd(e),u=Pd(),d=(0,_.useMemo)(()=>Ud(e,Vd(e,c,n)),[e,c,n]),f=(0,_.useRef)(null),p=(0,_.useRef)(e),[m,h]=t.split(`?`),g=m||ge(e),v=new URLSearchParams(h??``).get(`token`);if((0,_.useEffect)(()=>Ie(d),[d]),(0,_.useEffect)(()=>{document.documentElement.toggleAttribute(`data-mode-themed`,Bd(e)!==void 0)},[e]),(0,_.useEffect)(()=>{e!==p.current&&Ad(`Updated`)},[e]),(0,_.useEffect)(()=>{window.scrollTo?.(0,0)},[t]),(0,_.useEffect)(()=>{if(!v)return;let e=[...document.querySelectorAll(`[data-token="${CSS.escape(v)}"]`)],t=e.find(e=>e.getClientRects().length>0)??e[0];t&&(t.scrollIntoView?.({block:`center`}),t.classList.remove(`blazon-flash`),t.offsetWidth,t.classList.add(`blazon-flash`))},[v,g]),g===`#print`||g.startsWith(`#print/`))return(0,Z.jsx)($S,{data:e,view:d,mode:n,...eC(t),favicons:u});let y=o.trim().toLowerCase(),x=iC(e,g,y,u);return(0,Z.jsx)(Od,{children:(0,Z.jsx)(fm,{children:(0,Z.jsxs)(wm,{open:!0,onOpenChange:aC,className:`flex-col`,children:[(0,Z.jsxs)(`header`,{className:`sticky top-0 z-20 flex h-14 shrink-0 items-center gap-2 border-b bg-background/95 px-4 backdrop-blur`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 lg:w-[calc(var(--sidebar-width)-1rem)]`,children:[(0,Z.jsx)(oC,{}),(0,Z.jsx)(Hm,{data:e,mode:n})]}),(0,Z.jsx)(Kh,{className:`hidden min-w-0 md:flex`,children:(0,Z.jsxs)(qh,{children:[(0,Z.jsx)(Jh,{children:x.section}),(0,Z.jsx)(Xh,{}),(0,Z.jsx)(Jh,{className:`min-w-0`,children:(0,Z.jsx)(Yh,{className:`truncate`,children:x.page})})]})}),(0,Z.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-2`,children:[(0,Z.jsxs)(`label`,{className:`relative min-w-0`,children:[(0,Z.jsx)(ld,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(Wf,{type:`search`,placeholder:`Search tokens and pages`,"aria-label":`Search`,value:o,onChange:e=>s(e.target.value),className:`h-8 w-[clamp(140px,28vw,320px)] pl-8`})]}),(0,Z.jsx)(Kd,{data:e,selected:c,onSelect:l,exclude:Bd(e),className:`hidden md:flex`}),(0,Z.jsx)(Gh,{}),(0,Z.jsx)(Tu,{variant:`ghost`,size:`icon`,"aria-label":n===`dark`?`Light mode`:`Dark mode`,onClick:()=>r(n===`dark`?`light`:`dark`),children:n===`dark`?(0,Z.jsx)(dd,{}):(0,Z.jsx)(rd,{})})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1`,children:[(0,Z.jsx)(Um,{data:e,hash:g,mode:n,favicons:u,contexts:c,onSelectContext:l,className:`lg:top-14 lg:h-[calc(100svh-3.5rem)]`}),(0,Z.jsx)(Dm,{ref:f,lang:Hd(e,`locale`,c),className:`min-w-0`,children:(0,Z.jsx)(rC,{data:e,view:d,hash:g,query:y,mode:n,favicons:u})})]})]})})})}(0,v.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(_.StrictMode,{children:(0,Z.jsx)(sC,{})}));
|
package/dist/ui/index.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Brand Book</title>
|
|
7
7
|
<link rel="icon" href="data:," />
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-dkJG6W9p.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="./assets/index-Biy1hkeq.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
12
|
<div id="root"></div>
|
package/mcp/dist/index.js
CHANGED
|
@@ -21668,7 +21668,7 @@ var OPERATIONS = [
|
|
|
21668
21668
|
{
|
|
21669
21669
|
name: "check_brand",
|
|
21670
21670
|
title: "Check the brand",
|
|
21671
|
-
description: "Runs blazon check on the brand, without plugins, and returns its findings and counts. Plugins in blazon.json do not run, so the counts can be lower than `blazon check` prints; `pluginsSkipped` and `warnings`
|
|
21671
|
+
description: "Runs blazon check on the brand, without plugins, and returns its findings and counts. Plugins in blazon.json do not run, so the counts can be lower than `blazon check` prints, but only for a plugin with a check role; a build-only plugin adds no finding. `pluginsSkipped` and `warnings` list every configured plugin, since a role is known only by starting the plugin. `passed` is false when the brand has errors, and values read from such a brand can be wrong. Returns at most `limit` findings (default 50, at most 500); `counts` stay whole. Not for reading a value: use get_token.",
|
|
21672
21672
|
annotations: {
|
|
21673
21673
|
readOnlyHint: true,
|
|
21674
21674
|
destructiveHint: false,
|
|
@@ -21779,7 +21779,7 @@ var OPERATIONS = [
|
|
|
21779
21779
|
pluginsSkipped: {
|
|
21780
21780
|
type: "array",
|
|
21781
21781
|
items: { type: "string" },
|
|
21782
|
-
description: "
|
|
21782
|
+
description: "Every plugin blazon.json lists, which did not run because the server never starts a plugin. Only one with a check role can make `blazon check` report more findings than `counts`; the server cannot tell which without starting it. Absent when the config lists none"
|
|
21783
21783
|
}
|
|
21784
21784
|
},
|
|
21785
21785
|
required: [
|
|
@@ -22544,7 +22544,7 @@ function buildPageText(description) {
|
|
|
22544
22544
|
* read from the packages installed at the repository root. The server's `version` is blazon's, since it ships inside blazon.
|
|
22545
22545
|
*/
|
|
22546
22546
|
var VERSIONS = {
|
|
22547
|
-
"blazon": "0.3.
|
|
22547
|
+
"blazon": "0.3.3",
|
|
22548
22548
|
"sdk": "1.32.2",
|
|
22549
22549
|
"zod": "4.6.7"
|
|
22550
22550
|
};
|
|
@@ -22567,7 +22567,10 @@ function configuredPlugins(brand) {
|
|
|
22567
22567
|
return [];
|
|
22568
22568
|
}
|
|
22569
22569
|
}
|
|
22570
|
-
/**
|
|
22570
|
+
/**
|
|
22571
|
+
* `check_brand` runs `blazon check --no-plugins`, so it says which plugins of the config did not run. A plugin's roles are only in the manifest
|
|
22572
|
+
* its program prints (`--blazon-manifest`), so the server cannot tell a check plugin from a build-only one without starting it: it lists all and says so.
|
|
22573
|
+
*/
|
|
22571
22574
|
function skippedPlugins(brand) {
|
|
22572
22575
|
const names = configuredPlugins(brand);
|
|
22573
22576
|
if (names.length === 0) return {
|
|
@@ -22576,7 +22579,7 @@ function skippedPlugins(brand) {
|
|
|
22576
22579
|
};
|
|
22577
22580
|
return {
|
|
22578
22581
|
fields: { pluginsSkipped: names },
|
|
22579
|
-
warnings: [
|
|
22582
|
+
warnings: [`Plugins in blazon.json did not run: ${names.join(", ")}. Only a plugin with a check role can add findings to these counts; a build-only plugin adds none. The server cannot read a plugin's role without starting it, so it lists every configured plugin. Run \`blazon check\` for the full counts.`]
|
|
22580
22583
|
};
|
|
22581
22584
|
}
|
|
22582
22585
|
var LOOKUPS = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iksnerd/blazon",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Brand book and design token compiler: DTCG tokens, brand rules checked by blazon check, a static brand book that wears the brand",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
"test": "vitest run",
|
|
41
41
|
"test:related": "vitest related --run",
|
|
42
42
|
"test:files": "vitest run",
|
|
43
|
+
"test:guards": "vitest run test/core/no-private-markers.test.ts test/core/layers.test.ts",
|
|
43
44
|
"test:deck": "vitest run test/deck/brand-deck-plan test/deck/brand-deck-fonts.test.ts test/deck/brand-deck-examples.test.ts test/deck/examples-deck.test.ts test/plugins/shipped/brand-deck test/brand/brand-python.test.ts",
|
|
44
|
-
"test:docs": "vitest run test/docs/manual.test.ts test/docs/rfc.test.ts test/docs/checks-generated.test.ts test/docs/versions.test.ts",
|
|
45
|
+
"test:docs": "vitest run test/docs/manual.test.ts test/docs/rfc.test.ts test/docs/checks-generated.test.ts test/docs/layers-generated.test.ts test/docs/versions.test.ts test/docs/changelog-fragments.test.ts",
|
|
45
46
|
"conformance:reads": "rm -f reads.json reads.json.lines && CONFORMANCE_READS=reads.json vitest run test/plugins/host && tsx scripts/conformance-reads.ts reads.json",
|
|
46
47
|
"test:watch": "vitest",
|
|
47
48
|
"typecheck": "node node_modules/typescript7/bin/tsc --noEmit && node scripts/typecheck-mcp.mjs",
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
"format:files": "prettier --check --no-error-on-unmatched-pattern",
|
|
55
56
|
"check": "npm run typecheck && npm run lint && npm run lint:py && npm run format:check",
|
|
56
57
|
"checks-docs": "tsx scripts/gen-checks-docs.ts",
|
|
58
|
+
"layers-docs": "tsx scripts/gen-layers-docs.ts",
|
|
57
59
|
"docs:stats": "tsx scripts/docs-stats.ts",
|
|
58
60
|
"gen:mcp": "tsx scripts/gen-mcp-operations.ts",
|
|
59
61
|
"shipped-lock": "tsx scripts/shipped-lock.mjs",
|
|
@@ -62,6 +64,7 @@
|
|
|
62
64
|
"prepack": "npm run build && npm run build-starter",
|
|
63
65
|
"prepublishOnly": "npm run prepack && npm run check-pack",
|
|
64
66
|
"release": "node scripts/release.mjs",
|
|
67
|
+
"changelog:preview": "node scripts/release.mjs --preview",
|
|
65
68
|
"blazon:src": "tsx scripts/blazon-src.ts",
|
|
66
69
|
"build:viewer": "vite build -c vite.viewer.config.ts",
|
|
67
70
|
"dev:blazon": "tsx scripts/blazon-src.ts dev examples/blazon",
|
|
@@ -4,18 +4,20 @@ The plugin blazon ships to hold a brand book's text to the brand's copy rules: t
|
|
|
4
4
|
|
|
5
5
|
The source is `src/shipped/copy/`, and `npm run build` (`npm run build:plugins`) bundles it, with the blazon code it uses, into `bin/blazon-blazon.copy.🔌`, the one file that holds the plugin's code and that `plugins/shipped.lock` pins. It loads nothing from `node_modules`, so the pin covers all the code it runs, apart from Node itself. Name it in `blazon.json` and give it the rules:
|
|
6
6
|
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"plugins": [
|
|
10
|
+
{
|
|
11
|
+
"name": "blazon.copy",
|
|
12
|
+
"options": {
|
|
13
|
+
"avoid": [{ "terms": ["powerful", "seamless", "robust", "effortless"], "say": "a number, or nothing" }],
|
|
14
|
+
"headings": "sentence",
|
|
15
|
+
"sentences": { "maxWords": 25 },
|
|
16
|
+
"skip": ["11-voice.md"]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
19
21
|
```
|
|
20
22
|
|
|
21
23
|
With no options it checks nothing. The options and the findings are in [the manual](../../docs/manual/14-shipped-plugins.md#blazoncopy), and the design is [RFC 0006](../../docs/rfc/0006-copy-rules.md).
|
|
@@ -11,3 +11,6 @@ The source is `src/shipped/favicons/`, and `npm run build` (`npm run build:plugi
|
|
|
11
11
|
| Variable | Says | Secret |
|
|
12
12
|
|---|---|---|
|
|
13
13
|
| `BLAZON_CHROME` | The path to a Chrome or Chromium program. Without it the plugin uses the Google Chrome installed on the computer. It never downloads a browser | no |
|
|
14
|
+
| `HOME`, `TMPDIR` | Listed in the manifest, for the browser the plugin starts | no |
|
|
15
|
+
|
|
16
|
+
The manifest lists all three, so the entry in `blazon.json` approves them in its `env`: `["BLAZON_CHROME", "HOME", "TMPDIR"]`.
|
|
@@ -311,7 +311,7 @@ var GENERIC = /* @__PURE__ */ new Set([
|
|
|
311
311
|
]);
|
|
312
312
|
/** The families of a CSS font stack, unquoted, in order */
|
|
313
313
|
function families(stack) {
|
|
314
|
-
return [...stack.matchAll(
|
|
314
|
+
return [...stack.matchAll(/\s*"([^"]+)"|\s*'([^']+)'|([^,]+)/g)].map((match) => (match[1] ?? match[2] ?? match[3]).trim()).filter((name) => name !== "");
|
|
315
315
|
}
|
|
316
316
|
/** The first family of the stack that names a font: not a generic, not a var(). */
|
|
317
317
|
var fontOf = (stack) => stack ? families(stack).find((name) => !GENERIC.has(name.toLowerCase()) && !/[()]/.test(name)) : void 0;
|
|
@@ -11,12 +11,68 @@ The source is `src/shipped/platform-tokens/`, and `npm run build` (`npm run buil
|
|
|
11
11
|
| `android/values/colors.xml` | `<color name="color_brand_primary">`, `#RRGGBB` or `#AARRGGBB` |
|
|
12
12
|
| `android/values-night/colors.xml` | The colors the dark context changes |
|
|
13
13
|
| `android/values/dimens.xml` | `<dimen>` in dp: a px is 1 dp, a rem is 16 |
|
|
14
|
-
| `ios/BlazonTokens.swift` | `public enum BlazonColors` (SwiftUI `Color`) and `BlazonDimensions` (`CGFloat`); a color the dark context changes follows the system appearance |
|
|
14
|
+
| `ios/BlazonTokens.swift` (`ios/<Prefix>Tokens.swift` with a `prefix`) | `public enum BlazonColors` (SwiftUI `Color`) and `BlazonDimensions` (`CGFloat`); a color the dark context changes follows the system appearance |
|
|
15
15
|
| `ios/Colors.xcassets` | A colorset for each color, with a dark appearance where the dark context changes it |
|
|
16
16
|
| `compose/Colors.kt`, `compose/Dimens.kt` | `BlazonColors`, `BlazonDarkColors` (every color, dark where the dark context sets one, so the whole object can be swapped) and `BlazonDimens` (`Dp`) |
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
`color` and `dimension` tokens are written, and from a `border` token its width, as a dimension named `<token path>.width` (`border.rule` is `border.rule.width`: `border_rule_width` on Android, `borderRuleWidth` in Swift and Kotlin). The border's colour is not written (it is a colour token or a hex in the composite) and its style is not carried: a style other than `solid` gets one `border-style-dropped` info finding for the token. A width that is not in px or rem is a `dimension-unreadable` warning and the token is left out. `include` and `exclude` match the border token's own path (`border.rule`), not `.width`. Any other type is named once in a `tokens-skipped` finding. That leaves out typography, fontFamily, fontWeight, shadow, gradient, duration, cubicBezier, transition and number tokens. A token's value is its resolved value, so an alias is written with the value it points at and keeps its own name. Colors are converted to sRGB with colorjs.io, with alpha kept.
|
|
19
19
|
|
|
20
20
|
## Checked with the platform tools
|
|
21
21
|
|
|
22
22
|
The Swift file type-checks with `swiftc -typecheck` for macOS 10.15 and iOS 13, and the asset catalog compiles with `actool`. Kotlin is not compiled; it is written against the Compose `Color(Long)` and `Dp` API.
|
|
23
|
+
|
|
24
|
+
## Options
|
|
25
|
+
|
|
26
|
+
| Option | Default | Does |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| `platforms` | `["android", "ios", "compose"]` | Any of those three |
|
|
29
|
+
| `dark` | the context named `dark` | The name of the context that is the dark appearance |
|
|
30
|
+
| `prefix` | none | Letters and digits, starting with a letter. See "What the prefix reaches" |
|
|
31
|
+
| `include` | none (every token) | A list of token path prefixes in dot form; only the tokens under one of them are written |
|
|
32
|
+
| `exclude` | none | A list of token path prefixes in dot form; the tokens under one of them are not written. Applied after `include` |
|
|
33
|
+
|
|
34
|
+
`include` and `exclude` take path prefixes, not patterns: no glob, no regular expression. An entry matches a token when its names, split at the dots, are the first names of the token's path, compared as plain text one by one. `["breakpoint", "component.button.website"]` matches `breakpoint.md` and every token under `component.button.website`, and does not match `breakpoints.x`. Each name is letters, digits, `_` and `-`, and a list holds 1 to 100 entries (an empty list is refused, it would write nothing); anything else is an `option-invalid` finding and the option is ignored. They apply to colors, dimensions and the dark context, in every output. An entry that matches no token of the brand is not an error: a `filter-unmatched` info finding names it, so a typo shows. A token left out by `include` or `exclude` is not counted in `tokens-skipped`.
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"plugins": [
|
|
39
|
+
{ "name": "blazon.platform-tokens", "options": { "prefix": "Acme", "exclude": ["radius"] } }
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Run on blazon's own example brand with this entry, `blazon tokens` writes the same 39 files as with no options except for the iOS names below, and no `radius.*` dimension in any output.
|
|
45
|
+
|
|
46
|
+
## What the prefix reaches
|
|
47
|
+
|
|
48
|
+
Checked by running the plugin on the example brand with and without `"prefix": "Acme"` and comparing the two file trees and the names in them.
|
|
49
|
+
|
|
50
|
+
| Output | Reached | With `Acme` |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `android/values/colors.xml`, `values-night/colors.xml`, `dimens.xml` | Yes, first in each resource name | `acme_social_format_square_height` |
|
|
53
|
+
| `ios/` Swift file name | Yes | `AcmeTokens.swift` (`BlazonTokens.swift` with no prefix) |
|
|
54
|
+
| `ios/Colors.xcassets` colorset names | Yes, the prefix in lowerCamel in front of the Swift name | `acmeSignalOrange.colorset` |
|
|
55
|
+
| Swift types | Yes | `AcmeColors`, `AcmeDimensions` |
|
|
56
|
+
| Kotlin objects | Yes | `AcmeColors`, `AcmeDarkColors`, `AcmeDimens` |
|
|
57
|
+
| Names of the members of the Swift and Kotlin types | No, the type already says it | `AcmeColors.signalOrange` |
|
|
58
|
+
| Kotlin `package` line | No | `package blazon.tokens` |
|
|
59
|
+
| `README.txt` | Only the Swift file name it mentions | `add AcmeTokens.swift and Colors.xcassets ...` |
|
|
60
|
+
|
|
61
|
+
The Kotlin package stays `blazon.tokens` with any prefix. The Kotlin files are meant to be copied into your module and the package line set to yours (the file says so in `README.txt`), so the plugin does not guess a package name, and a second option for it is not worth the surface. With no prefix every file is byte-identical to what earlier versions wrote.
|
|
62
|
+
|
|
63
|
+
## Names
|
|
64
|
+
|
|
65
|
+
One token has a name for each output, from its dotted path. Android keeps every segment; the others drop a leading `color` segment of a color token, because the type or the catalog says it is a color. Take the color `color.brand.primary` and the dimension `space.4` with the prefix `Acme`:
|
|
66
|
+
|
|
67
|
+
| Output | Color | Dimension | Rule |
|
|
68
|
+
|---|---|---|---|
|
|
69
|
+
| Android resource | `acme_color_brand_primary` | `acme_space_4` | prefix, then every segment, lower snake case |
|
|
70
|
+
| Swift member | `brandPrimary` | `space4` | lowerCamel, leading `color` dropped |
|
|
71
|
+
| Kotlin member | `brandPrimary` | `space4` | as Swift |
|
|
72
|
+
| Asset catalog colorset | `acmeBrandPrimary` | none | prefix in lowerCamel, then the Swift name |
|
|
73
|
+
|
|
74
|
+
So one color is `acme_color_brand_primary` on Android and `brandPrimary` elsewhere; that is deliberate and the names are not changed. Without the prefix the Android name has no `acme_`, and the colorset is `brandPrimary`. The longer rules (digits, keywords, collisions) are in the manual.
|
|
75
|
+
|
|
76
|
+
## Not written
|
|
77
|
+
|
|
78
|
+
Typography, fontFamily, fontWeight, shadow, gradient, duration, cubicBezier, transition and number tokens are not written, and nor is the colour or style of a `border` token (its width is); the build names the skipped types in one `tokens-skipped` finding.
|
|
@@ -8120,6 +8120,10 @@ function nameTokens(paths, style, kind, prefix) {
|
|
|
8120
8120
|
};
|
|
8121
8121
|
});
|
|
8122
8122
|
}
|
|
8123
|
+
/** The name of a colorset in the asset catalog: the Swift name, with the prefix in front as lowerCamel (`acmeBlue100`), or the Swift name alone with no prefix */
|
|
8124
|
+
var assetName = (prefix, swift) => prefix ? `${lowerFirst(prefix)}${upperFirst(swift)}` : swift;
|
|
8125
|
+
/** The Swift file name: `BlazonTokens.swift`, or `AcmeTokens.swift` with the prefix `acme` */
|
|
8126
|
+
var swiftFile = (prefix) => `${typeName(prefix, "Tokens")}.swift`;
|
|
8123
8127
|
/** The Swift and Kotlin type name for a group of tokens: `BlazonColors`, or `AcmeColors` with the prefix `acme` */
|
|
8124
8128
|
var typeName = (prefix, suffix) => `${prefix ? upperFirst(prefix) : "Blazon"}${suffix}`;
|
|
8125
8129
|
var HEADER$1 = "// Written by blazon.platform-tokens from brand.json. Do not edit: build again instead.";
|
|
@@ -8212,12 +8216,12 @@ extension Color {
|
|
|
8212
8216
|
#endif
|
|
8213
8217
|
}
|
|
8214
8218
|
}`;
|
|
8215
|
-
/** iOS: BlazonTokens.swift with enums of SwiftUI Colors and CGFloat dimensions, and an asset catalog with a colorset for each color, with dark appearances */
|
|
8219
|
+
/** iOS: BlazonTokens.swift (or <Prefix>Tokens.swift) with enums of SwiftUI Colors and CGFloat dimensions, and an asset catalog with a colorset for each color, with dark appearances */
|
|
8216
8220
|
function iosFiles(plan) {
|
|
8217
8221
|
const files = /* @__PURE__ */ new Map();
|
|
8218
8222
|
if (plan.colors.length) {
|
|
8219
8223
|
files.set("ios/Colors.xcassets/Contents.json", json({ info: INFO }));
|
|
8220
|
-
for (const c of plan.colors) files.set(`ios/Colors.xcassets/${c.swift}.colorset/Contents.json`, json({
|
|
8224
|
+
for (const c of plan.colors) files.set(`ios/Colors.xcassets/${assetName(plan.prefix, c.swift)}.colorset/Contents.json`, json({
|
|
8221
8225
|
colors: [entry(c.light), ...c.dark ? [entry(c.dark, true)] : []],
|
|
8222
8226
|
info: INFO
|
|
8223
8227
|
}));
|
|
@@ -8229,7 +8233,7 @@ function iosFiles(plan) {
|
|
|
8229
8233
|
if (plan.colors.length) out.push("", `public enum ${typeName(plan.prefix, "Colors")} {`, ...plan.colors.map((c) => ` public static let ${c.swift} = ${c.dark ? `Color(blazonLight: ${rgba(c.light)}, dark: ${rgba(c.dark)})` : srgb(c.light)}`), "}");
|
|
8230
8234
|
if (plan.dimensions.length) out.push("", "// px tokens are points 1:1; rem tokens are 16 points to the rem.", `public enum ${typeName(plan.prefix, "Dimensions")} {`, ...plan.dimensions.map((d) => ` public static let ${d.swift}: CGFloat = ${dp(d.dp)}`), "}");
|
|
8231
8235
|
if (dynamic) out.push("", DYNAMIC);
|
|
8232
|
-
files.set(
|
|
8236
|
+
files.set(`ios/${swiftFile(plan.prefix)}`, `${out.join("\n")}\n`);
|
|
8233
8237
|
return files;
|
|
8234
8238
|
}
|
|
8235
8239
|
/** The plugin's name, which blazon's config names it by, and the prefix of its finding codes */
|
|
@@ -8260,8 +8264,17 @@ var PLATFORMS = [
|
|
|
8260
8264
|
var KEYS = [
|
|
8261
8265
|
"platforms",
|
|
8262
8266
|
"dark",
|
|
8263
|
-
"prefix"
|
|
8267
|
+
"prefix",
|
|
8268
|
+
"include",
|
|
8269
|
+
"exclude"
|
|
8264
8270
|
];
|
|
8271
|
+
var PATH = /^[\p{L}\p{N}_-]+(\.[\p{L}\p{N}_-]+)*$/u;
|
|
8272
|
+
/** True when `path` is `prefix` or lies under it: the names are compared one by one, so `breakpoint` does not reach `breakpoints.x`. Plain comparison, no pattern. */
|
|
8273
|
+
function underPrefix(path, prefix) {
|
|
8274
|
+
const names = path.split(".");
|
|
8275
|
+
const head = prefix.split(".");
|
|
8276
|
+
return head.length <= names.length && head.every((name, at) => name === names[at]);
|
|
8277
|
+
}
|
|
8265
8278
|
var finding = findingFor(NAME);
|
|
8266
8279
|
var invalid = (message) => finding("option-invalid", "error", "options", message);
|
|
8267
8280
|
/**
|
|
@@ -8295,6 +8308,12 @@ function parseOptions(raw, contexts) {
|
|
|
8295
8308
|
if (typeof raw.prefix !== "string" || !/^([A-Za-z][A-Za-z0-9]*)?$/.test(raw.prefix)) findings.push(invalid("prefix must be letters and digits, starting with a letter"));
|
|
8296
8309
|
else options.prefix = raw.prefix;
|
|
8297
8310
|
}
|
|
8311
|
+
for (const key of ["include", "exclude"]) {
|
|
8312
|
+
const list = raw[key];
|
|
8313
|
+
if (list === void 0) continue;
|
|
8314
|
+
if (!Array.isArray(list) || list.length === 0 || list.length > 100 || list.some((item) => typeof item !== "string" || !PATH.test(item))) findings.push(invalid(`${key} must be a list of 1 to 100 token paths in dot form, such as "breakpoint" or "component.button.website", each name letters, digits, "_" and "-" (no pattern characters)`));
|
|
8315
|
+
else options[key] = [...new Set(list)];
|
|
8316
|
+
}
|
|
8298
8317
|
return {
|
|
8299
8318
|
options,
|
|
8300
8319
|
findings
|
|
@@ -8310,6 +8329,9 @@ var PLATFORM_OF = {
|
|
|
8310
8329
|
swift: "ios",
|
|
8311
8330
|
kotlin: "compose"
|
|
8312
8331
|
};
|
|
8332
|
+
var isComposite = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && "width" in value;
|
|
8333
|
+
/** The width of a border token in dp: the `width` of its composite value, or the value itself when it is a plain dimension */
|
|
8334
|
+
var borderWidth = (token) => isComposite(token.resolved) ? readDimension(token.resolved.width, void 0) : readDimension(token.resolved, token.value);
|
|
8313
8335
|
var byPath = (a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
|
|
8314
8336
|
var count = (n, what) => `${n} ${what}${n === 1 ? "" : "s"}`;
|
|
8315
8337
|
/** The context that is the dark appearance: the one the option names, else the one named `dark`; none, or a finding when two modifiers have one */
|
|
@@ -8323,16 +8345,27 @@ function darkContext(contexts, options, findings) {
|
|
|
8323
8345
|
}
|
|
8324
8346
|
return matches[0];
|
|
8325
8347
|
}
|
|
8348
|
+
/** The tokens `include` and `exclude` leave, and an info finding for each entry that matched no token of the brand (a typo shows) */
|
|
8349
|
+
function filterTokens(tokens, options, findings) {
|
|
8350
|
+
const { include, exclude } = options;
|
|
8351
|
+
const keep = (path) => (!include || include.some((prefix) => underPrefix(path, prefix))) && !(exclude ?? []).some((prefix) => underPrefix(path, prefix));
|
|
8352
|
+
for (const [key, list] of [["include", include], ["exclude", exclude]]) for (const prefix of list ?? []) if (!tokens.some((token) => underPrefix(token.path, prefix))) findings.push(finding("filter-unmatched", "info", `options.${key}`, `${key} ${JSON.stringify(prefix)} matches no token of the brand: check the spelling (it matches a whole name or a group of names, not part of a name)`));
|
|
8353
|
+
return {
|
|
8354
|
+
kept: tokens.filter((token) => keep(token.path)),
|
|
8355
|
+
keep
|
|
8356
|
+
};
|
|
8357
|
+
}
|
|
8326
8358
|
/** The tokens to write, their names, and what was said about each. */
|
|
8327
8359
|
function planTokens(brand, options) {
|
|
8328
8360
|
const findings = [];
|
|
8329
|
-
const
|
|
8361
|
+
const { kept, keep } = filterTokens([...brand.tokens].sort(byPath), options, findings);
|
|
8362
|
+
const tokens = kept;
|
|
8330
8363
|
const skipped = /* @__PURE__ */ new Map();
|
|
8331
|
-
for (const token of tokens) if (token.type !== "color" && token.type !== "dimension") skipped.set(token.type || "untyped", (skipped.get(token.type || "untyped") ?? 0) + 1);
|
|
8364
|
+
for (const token of tokens) if (token.type !== "color" && token.type !== "dimension" && token.type !== "border") skipped.set(token.type || "untyped", (skipped.get(token.type || "untyped") ?? 0) + 1);
|
|
8332
8365
|
if (skipped.size) {
|
|
8333
8366
|
const total = [...skipped.values()].reduce((sum, n) => sum + n, 0);
|
|
8334
8367
|
const list = [...skipped].sort(([a], [b]) => a < b ? -1 : 1).map(([type, n]) => `${type} (${n})`);
|
|
8335
|
-
findings.push(finding("tokens-skipped", "info", "tokens", `${count(total, "token")} not written: this plugin writes color and dimension tokens only. Skipped types: ${list.join(", ")}`));
|
|
8368
|
+
findings.push(finding("tokens-skipped", "info", "tokens", `${count(total, "token")} not written: this plugin writes color and dimension tokens, and the width of border tokens, only. Skipped types: ${list.join(", ")}`));
|
|
8336
8369
|
}
|
|
8337
8370
|
const colors = /* @__PURE__ */ new Map();
|
|
8338
8371
|
const dimensions = /* @__PURE__ */ new Map();
|
|
@@ -8352,13 +8385,22 @@ function planTokens(brand, options) {
|
|
|
8352
8385
|
const amount = readDimension(token.resolved, token.value);
|
|
8353
8386
|
if (amount === void 0) findings.push(finding("dimension-unreadable", "warning", token.path, `${token.path} is not a px or rem dimension (${JSON.stringify(token.value)}), so it was left out`));
|
|
8354
8387
|
else dimensions.set(token.path, amount);
|
|
8388
|
+
} else if (token.type === "border") {
|
|
8389
|
+
const amount = borderWidth(token);
|
|
8390
|
+
if (amount === void 0) {
|
|
8391
|
+
findings.push(finding("dimension-unreadable", "warning", token.path, `${token.path} has no border width in px or rem (${JSON.stringify(token.value)}), so it was left out`));
|
|
8392
|
+
continue;
|
|
8393
|
+
}
|
|
8394
|
+
dimensions.set(`${token.path}.width`, amount);
|
|
8395
|
+
const style = isComposite(token.resolved) ? token.resolved.style : void 0;
|
|
8396
|
+
if (style !== void 0 && style !== "solid") findings.push(finding("border-style-dropped", "info", token.path, `${token.path} has the style ${typeof style === "string" ? JSON.stringify(style) : "a custom stroke style"}, which has no equivalent in these files: only its width was written, as ${token.path}.width`));
|
|
8355
8397
|
}
|
|
8356
8398
|
const context = darkContext(brand.contexts, options, findings);
|
|
8357
8399
|
const darks = /* @__PURE__ */ new Map();
|
|
8358
8400
|
if (context) {
|
|
8359
8401
|
const unmatched = [];
|
|
8360
8402
|
let dimensionsChanged = 0;
|
|
8361
|
-
for (const token of [...context.tokens].sort(byPath)) if (token.type === "color") {
|
|
8403
|
+
for (const token of [...context.tokens].filter((item) => keep(item.path)).sort(byPath)) if (token.type === "color") {
|
|
8362
8404
|
const light = colors.get(token.path);
|
|
8363
8405
|
if (!light) {
|
|
8364
8406
|
unmatched.push(token.path);
|
|
@@ -8369,6 +8411,9 @@ function planTokens(brand, options) {
|
|
|
8369
8411
|
} else if (token.type === "dimension") {
|
|
8370
8412
|
const light = dimensions.get(token.path);
|
|
8371
8413
|
if (light !== void 0 && readDimension(token.resolved, token.value) !== light) dimensionsChanged++;
|
|
8414
|
+
} else if (token.type === "border") {
|
|
8415
|
+
const light = dimensions.get(`${token.path}.width`);
|
|
8416
|
+
if (light !== void 0 && borderWidth(token) !== light) dimensionsChanged++;
|
|
8372
8417
|
}
|
|
8373
8418
|
if (unmatched.length) findings.push(finding("dark-unmatched", "warning", "contexts", `${context.context} sets ${count(unmatched.length, "color")} that the main tokens do not have, so ${unmatched.length === 1 ? "it was" : "they were"} left out: ${unmatched.join(", ")}`));
|
|
8374
8419
|
if (dimensionsChanged) findings.push(finding("dark-dimensions-ignored", "info", "contexts", `${context.context} changes ${count(dimensionsChanged, "dimension token")}; dimensions are written once, with the main values`));
|
|
@@ -8407,20 +8452,20 @@ function planTokens(brand, options) {
|
|
|
8407
8452
|
findings
|
|
8408
8453
|
};
|
|
8409
8454
|
}
|
|
8410
|
-
var WHERE = {
|
|
8455
|
+
var WHERE = (prefix) => ({
|
|
8411
8456
|
android: {
|
|
8412
8457
|
folder: "android/",
|
|
8413
8458
|
line: "copy values/ (and values-night/, if there is one) into your module's src/main/res/, beside any file of the same name"
|
|
8414
8459
|
},
|
|
8415
8460
|
ios: {
|
|
8416
8461
|
folder: "ios/",
|
|
8417
|
-
line:
|
|
8462
|
+
line: `add ${swiftFile(prefix)} and Colors.xcassets to your Xcode target`
|
|
8418
8463
|
},
|
|
8419
8464
|
compose: {
|
|
8420
8465
|
folder: "compose/",
|
|
8421
8466
|
line: "copy Colors.kt and Dimens.kt into your module's source folder and set the package line to yours"
|
|
8422
8467
|
}
|
|
8423
|
-
};
|
|
8468
|
+
});
|
|
8424
8469
|
async function build(text) {
|
|
8425
8470
|
const job = jobFor(text);
|
|
8426
8471
|
const brand = readBrand(job.brand);
|
|
@@ -8434,7 +8479,7 @@ async function build(text) {
|
|
|
8434
8479
|
if (made.size) written.push(platform);
|
|
8435
8480
|
for (const [file, data] of made) files.set(file, data);
|
|
8436
8481
|
}
|
|
8437
|
-
if (written.length) files.set("README.txt", `Design tokens for apps, written by blazon.platform-tokens from brand.json.\n\n${written.map((platform) => `${WHERE[platform].folder} ${WHERE[platform].line}`).join("\n")}\n`);
|
|
8482
|
+
if (written.length) files.set("README.txt", `Design tokens for apps, written by blazon.platform-tokens from brand.json.\n\n${written.map((platform) => `${WHERE(options.prefix)[platform].folder} ${WHERE(options.prefix)[platform].line}`).join("\n")}\n`);
|
|
8438
8483
|
for (const [file, data] of [...files].sort(([a], [b]) => a < b ? -1 : 1)) {
|
|
8439
8484
|
node_fs.default.mkdirSync(node_path.default.dirname(node_path.default.join(job.outDir, file)), { recursive: true });
|
|
8440
8485
|
node_fs.default.writeFileSync(node_path.default.join(job.outDir, file), data);
|
|
@@ -10,8 +10,59 @@ The source is `src/shipped/press-kit/`, and `npm run build` (`npm run build:plug
|
|
|
10
10
|
|---|---|
|
|
11
11
|
| `logos/` | Assets that are logos (the `logos` category, or the files `logo.onLight` and `logo.onDark` name), as they are, in a folder for each background their sidecars name |
|
|
12
12
|
| `colors/` | The color tokens that are not aliases, as JSON, CSS and text; CMYK, Pantone and RAL only where a token states them |
|
|
13
|
-
| `fonts.txt` | The
|
|
14
|
-
| `about.txt` | `brand.title`
|
|
15
|
-
| `press-kit.pdf` | The title, the description, up to ten colors and one logo, drawn in Chrome |
|
|
13
|
+
| `fonts.txt` | The brand's fonts: the front family of `fontDisplay`, `fontBody` and each font token, and the families the font stylesheets load, unless it is a system font nothing loads (then it is a fallback); the source and license only where a font token states them (its `font` extension) or the data has them, else the license file blazon found beside the family's font files (`License file:` with its path), else `not stated`. The fallbacks are one last line, `Fallback fonts, not shipped` |
|
|
14
|
+
| `about.txt` | `brand.title`, then the `company` option's description, else `brand.description` (without either, a line saying none is set), then the company's boilerplate and facts and the `note` |
|
|
15
|
+
| `press-kit.pdf` | The title, the description (the company's when the option gives one), the boilerplate, the facts, the note, up to ten colors and one logo, drawn in Chrome |
|
|
16
16
|
|
|
17
17
|
A logo marked `needs-review`, and a generated logo with no `review`, are left out, with a finding for each. A color token marked `needs-review` is left out too, unless the `unreviewed` option is `true`, which includes it labelled as unreviewed.
|
|
18
|
+
|
|
19
|
+
## Options
|
|
20
|
+
|
|
21
|
+
Every option is plain data in the plugin's `options` in `blazon.json`. A wrong one is an `option-invalid` finding at `options.<key>` that names the key; it is left at its default and the rest of the kit is written. An unknown key, a wrong type, an empty or blank text, a text over its limit and a list over its limit are all wrong.
|
|
22
|
+
|
|
23
|
+
| Option | Type | Default | Does |
|
|
24
|
+
|---|---|---|---|
|
|
25
|
+
| `name` | string | `press-kit` | Folder, zip and PDF name, without an extension: letters, digits, dots, hyphens and underscores, up to 64 characters |
|
|
26
|
+
| `pdf` | boolean | `true` | `false` writes no PDF and needs no browser |
|
|
27
|
+
| `unreviewed` | boolean | `false` | `true` includes the colors marked `needs-review`, labelled as unreviewed |
|
|
28
|
+
| `logos` | list of asset ids | every logo | The logos to include; one that is not ready stays out |
|
|
29
|
+
| `company` | object | none | The company behind the brand, for a brand whose own title and description are a book's. Keys: `description`, `boilerplate`, `facts` |
|
|
30
|
+
| `company.description` | string, up to 1000 characters | none | Replaces `brand.description` in `about.txt` and the PDF when given |
|
|
31
|
+
| `company.boilerplate` | string, up to 2000 characters | none | One text printed after the description in `about.txt` and the PDF; blank lines make paragraphs |
|
|
32
|
+
| `company.facts` | list of up to 20 `{ "label", "value" }` | none | Labelled lines in the order given, such as the legal name and the registration number. A label is up to 60 characters and a value up to 300, each on one line |
|
|
33
|
+
| `note` | string, up to 280 characters, one line | none | Printed as `Note: ...` in `README.txt`, `about.txt`, `colors/colors.txt` and the PDF, such as that the colors are not yet approved |
|
|
34
|
+
|
|
35
|
+
With none of `company` and `note` the files are the bytes they were before, apart from the fixes in the next section.
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"plugins": [
|
|
40
|
+
{
|
|
41
|
+
"name": "blazon.press-kit",
|
|
42
|
+
"env": ["BLAZON_CHROME", "HOME", "TMPDIR"],
|
|
43
|
+
"options": {
|
|
44
|
+
"name": "acme-press-kit",
|
|
45
|
+
"company": {
|
|
46
|
+
"description": "Acme builds payment tools for teams that move money across borders.",
|
|
47
|
+
"boilerplate": "Acme Ltd is a licensed payment institution. Press enquiries: press@acme.example.",
|
|
48
|
+
"facts": [
|
|
49
|
+
{ "label": "Legal name", "value": "Acme Ltd" },
|
|
50
|
+
{ "label": "Registered address", "value": "1 Example Street, London" },
|
|
51
|
+
{ "label": "Registration number", "value": "01234567" }
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"note": "The colours are proposed and not yet approved."
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
That entry was run on `examples/blazon`; `about.txt` then reads the company description, the boilerplate, the three facts and `Note: The colours are proposed and not yet approved.`, each in its own paragraph.
|
|
62
|
+
|
|
63
|
+
## Fonts and swatches
|
|
64
|
+
|
|
65
|
+
- A family is a brand font when it is at the front of a font stack and is not a system font, or when a stylesheet or font file of the brand loads it, or when its font token states a source or license. The same families blazon treats as system fonts everywhere (`blazon fonts`) are fallbacks, and so is every family after the first in a stack. They are not listed as fonts with `License: not stated`; `fonts.txt` ends with one line, `Fallback fonts, not shipped: ...`. A stack with no brand font writes no `fonts.txt`.
|
|
66
|
+
- The license comes from the font token (`license`, `licenseUrl`, `source` of its `dev.blazon` `font`), then from the license file beside the family's font files (`OFL.txt`, `LICENSE`, `LICENCE`, `COPYING`), which blazon reads into `brand.json` as `theme.fontLicenses`: the plugin is given the brand and the built site, not the project folder, so it never opens the file itself. It prints `License file:` with the project path and, as `License:`, an `SPDX-License-Identifier:` line or the first short line that is not a copyright notice (`see <path>` when none). The kit copies no font and no license text.
|
|
67
|
+
- The PDF draws up to ten colors. A color belongs to the group named by the path before its last segment (`color.blue.500` is step `500` of `color.blue`). Groups run in the order their first color appears in the brand, each group's steps together, a group goes in whole, and the walk stops at the first group that does not fit in the places left (the first group alone is cut at ten). A swatch reads `blue 500`; a color straight under `color` keeps its short description, else its last segment.
|
|
68
|
+
- `README.txt` aligns its descriptions two spaces after the longest file name, or at column 16 when the names are shorter.
|