@webority/tokens 0.133.0 → 0.134.1
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/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/meanings.json +1 -1
- package/dist/upgrade/index.js +2 -2
- package/dist/upgrade/razorValueSplits.js +2 -2
- package/dist/upgrade/valueSplits.js +2 -1
- package/dist/upgrade/wrapperValues.js +1 -0
- package/package.json +2 -2
package/dist/meanings.json
CHANGED
package/dist/upgrade/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{brand as e}from"../build.js";import{applyClasses as t}from"./classes.js";import{applyComponents as n}from"./components.js";import{applyCssTable as r,isCssTarget as i,ownDeclarations as a}from"./css.js";import{applyRazorAttributes as o}from"./razorAttributes.js";import{applyRazorTags as s}from"./razorTags.js";import{applyRazorValueSplits as c}from"./razorValueSplits.js";import{applyMarkup as l,applySource as u}from"./source.js";import{applyComponentProps as d,applyPropSplits as f,applyPropValues as p,applyProps as m,applyThemeReads as h}from"./themeReads.js";import{applyValueSplits as g}from"./valueSplits.js";import{
|
|
1
|
+
import{brand as e}from"../build.js";import{applyClasses as t}from"./classes.js";import{applyComponents as n}from"./components.js";import{applyCssTable as r,isCssTarget as i,ownDeclarations as a}from"./css.js";import{applyRazorAttributes as o}from"./razorAttributes.js";import{applyRazorTags as s}from"./razorTags.js";import{applyRazorValueSplits as c}from"./razorValueSplits.js";import{applyMarkup as l,applySource as u}from"./source.js";import{applyComponentProps as d,applyPropSplits as f,applyPropValues as p,applyProps as m,applyThemeReads as h}from"./themeReads.js";import{applyValueSplits as g}from"./valueSplits.js";import{applyWrapperValues as _,findWrappers as v}from"./wrapperValues.js";import{createRequire as y}from"node:module";import{existsSync as b,readFileSync as x,readdirSync as S,realpathSync as C,writeFileSync as w}from"node:fs";import{dirname as T,isAbsolute as E,join as D,relative as O,resolve as k,sep as A}from"node:path";import{fileURLToPath as j,pathToFileURL as M}from"node:url";import{spawnSync as N}from"node:child_process";var P=/^\d+\.\d+\.\d+$/,F=/^(?:workspace:|file:|link:)/,I=`WEBORITY_UPGRADE_FROM`;function L(e){if(typeof e!=`string`||!P.test(e))throw Error(`invalid version "${e}"`)}function R(e,t){L(e),L(t);let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++)if(n[e]!==r[e])return n[e]-r[e];return 0}function z(){let e=T(j(import.meta.url));for(;;){let t=D(e,`package.json`);if(b(t)&&JSON.parse(x(t,`utf8`)).name===`@webority/tokens`)return e;let n=T(e);if(n===e)throw Error(`cannot find the @webority/tokens package folder`);e=n}}function B(){return JSON.parse(x(D(z(),`package.json`),`utf8`)).version}function V(e){let t=[];for(let n of S(e)){if(!n.endsWith(`.json`))continue;let r=n.slice(0,-5);P.test(r)&&t.push({version:r,table:JSON.parse(x(D(e,n),`utf8`))})}return t.sort((e,t)=>R(e.version,t.version))}function H(e,t){let n=N(`git`,[`ls-files`,`-z`,`--`,...t],{cwd:e,encoding:`utf8`,windowsHide:!0,maxBuffer:67108864});if(n.status!==0)throw Error(`not a git repository: ${e}`);let r=n.stdout.split(`\0`).filter(Boolean).map(e=>e.split(`\\`).join(`/`)).filter(t=>b(D(e,t)));return[...new Set(r)]}function U(e,t){let n=H(e,t??[`.`]);if(t!==void 0&&n.length===0)throw Error(`no tracked files under ${t.join(`, `)}`);return n}function W(e){return e.split(`/`).includes(`node_modules`)}var G=new Set([`node_modules`,`vendor`,`vendors`,`external`]),K=/\.(?:min|bundle)\.(?:js|css)$/;function q(e){let t=e.split(`/`);return t.some(e=>G.has(e))||t.some((e,n)=>e===`lib`&&t[n-1]===`wwwroot`)?!0:K.test(e)}function J(e,t){return[...new Set([...e,...t])]}function Y(e,t,n){return V(e).filter(e=>R(e.version,t)>0&&R(e.version,n)<=0).map(e=>e.table)}function X(e,t){let n=Object.entries(t);if(n.length===0)return e;let r=(e,t)=>e.flatMap(e=>[e,...n.filter(([,n])=>e[t]===n).map(([n])=>({...e,[t]:n}))]),i={...e};for(let t of[`props`,`componentProps`,`propValues`,`propSplits`,`valueSplits`,`components`])e[t]!==void 0&&(i[t]=r(e[t],`package`));return e.source!==void 0&&(i.source={...e.source,flags:r(e.source.flags,`importedFrom`)}),i}function Z(e,y,b,S,C,T={}){S&&C(`dry run: nothing written`);let E=b.map(e=>X(e,T)),O=[],k=[],A=[],j=y.filter(e=>i(e)&&!q(e)),M=E.map(()=>new Set);if(E.some(e=>(e.css.ownable??[]).length>0))for(let t of j){let n=x(D(e,t),`utf8`);E.forEach((e,r)=>{for(let i of a(n,t,e))M[r].add(i)})}let N=H(e,[`package.json`,`:(glob)**/package.json`]).filter(e=>!W(e)),P=new Map,F=E.map(t=>v(e,[...j,...N],t,P));for(let i of j){let a=x(D(e,i),`utf8`),v=a,y=e=>{for(let t of e)t.from!==t.to&&(O.push({file:i,line:t.line,from:t.from,to:t.to}),C(`${i}:${t.line} ${t.from} -> ${t.to}`))},b=e=>{k.push({file:i,line:e.line,name:e.name,hint:e.hint}),C(`choose ${i}:${e.line} ${e.name}: ${e.hint}`)},T=e=>{for(let t of e)t.message.startsWith(`skipped, it does not parse`)?C(`skipped ${i}: ${t.message}`):b({line:t.line,name:t.path,hint:t.message})};for(let[e,a]of E.entries()){let x=r(v,i,a,M[e]);v=x.text,y(x.hits);for(let e of x.choose)b(e);for(let e of x.checkRole)C(`verify ${i}:${e.line} ${e.from} -> ${e.to}`);let S=h(v,i,a.themeReads);v=S.text,y(S.hits),T(S.findings);let w=[t=>_(t,i,F[e]),e=>m(e,i,a.props),e=>d(e,i,a.componentProps),e=>p(e,i,a.propValues),e=>g(e,i,a.valueSplits??[]),e=>f(e,i,a.propSplits),e=>o(e,i,a.razorAttributes),e=>n(e,i,a.components??[]),e=>s(e,i,a.razorTags??[]),e=>c(e,i,a.razorValueSplits??[]),e=>t(e,i,a.classes??[]),e=>l(e,i,a.markup),e=>u(e,i,a.source)];for(let e of w){let t=e(v);v=t.text,y(t.hits),T(t.findings)}}v!==a&&(A.push(i),S||w(D(e,i),v,`utf8`))}return{hits:O,choose:k,changedFiles:A}}function Q(e){let t=/^([ \t]+)\S/m.exec(e);return t?t[1]:4}function $(e,t,n,r,i){let a=[];for(let o of H(e,[`package.json`,`:(glob)**/package.json`])){if(W(o))continue;let s=x(D(e,o),`utf8`),c=JSON.parse(s),l=!1;for(let e of[`dependencies`,`devDependencies`]){let r=c[e];if(r)for(let e of n.npm){if(!Object.hasOwn(r,e))continue;let n=r[e];F.test(n)||n===t||(r[e]=t,l=!0,i(`pin ${o}: ${e} ${n} -> ${t}`))}}if(l&&(a.push(o),r)){let t=JSON.stringify(c,null,Q(s));s.endsWith(`
|
|
2
2
|
`)&&(t+=`
|
|
3
3
|
`),s.includes(`\r
|
|
4
4
|
`)&&(t=t.replace(/\n/g,`\r
|
|
5
|
-
`)),
|
|
5
|
+
`)),w(D(e,o),t,`utf8`)}}return a}function ee(e,t,n,r,i){let a=[];for(let o of H(e,[`Directory.Packages.props`,`:(glob)**/Directory.Packages.props`])){if(W(o))continue;let s=x(D(e,o),`utf8`),c=!1,l=s.replace(/<PackageVersion\b[^>]*>/g,e=>{let r=/\sInclude="([^"]*)"/.exec(e)?.[1],a=/\sVersion="([^"]*)"/.exec(e)?.[1];if(r===void 0||a===void 0)return e;let s=/^\[([^\]]*)\]$/.exec(a),l=s?s[1]:a,u=s?`[${t}]`:t;return!n.nuget.includes(r)||l===t?e:(i(`pin ${o}: ${r} ${a} -> ${u}`),c=!0,e.replace(/(\sVersion=")[^"]*(")/,`$1${u}$2`))});c&&(a.push(o),r&&w(D(e,o),l,`utf8`))}return a}function te(e){let t;try{t=y(D(e,`package.json`)).resolve(`@webority/repo-checks/lockstep.json`)}catch{throw Error(`add @webority/repo-checks at the lockstep version and run again`)}return JSON.parse(x(t,`utf8`))}var ne=[{file:`pnpm-lock.yaml`,manager:`pnpm`,command:[`corepack`,`pnpm`,`install`]},{file:`package-lock.json`,manager:`npm`,command:[`npm`,`install`]}];function re(e){let t=ne.filter(t=>b(D(e,t.file)));if(t.length===0)throw Error(`no pnpm-lock.yaml or package-lock.json in ${e}`);if(t.length>1)throw Error(`${e} has both ${t[0].file} and ${t[1].file}; keep one lockfile`);return t[0]}function ie(e,t){let n=k(e,t),r=O(e,n);if(r===``||E(r)||r.split(A)[0]===`..`)throw Error(`--app ${t}: give a folder inside the repo root`);if(!b(D(n,`package.json`)))throw Error(`--app ${t}: no package.json in that folder`);return n}function ae(e,t,n){return N(e,t,{cwd:n.cwd,env:process.env,stdio:`inherit`,windowsHide:!0,shell:process.platform===`win32`})}async function oe({appRoot:e,designRoot:t,app:n,version:r,from:i,aliases:a}){let o=C.native(D(e,`node_modules`,`@webority`,`tokens`)),s=JSON.parse(x(D(o,`package.json`),`utf8`))?.exports?.[`.`],c=typeof s==`string`?s:s?.default;if(typeof c!=`string`)throw Error(`cannot find the installed @webority/tokens entry`);process.env[I]=i;try{return await(await import(M(D(o,c)).href)).upgrade({root:t,app:n,version:r,dryRun:!1,aliases:a})}finally{delete process.env[I]}}async function se({root:e,designRoot:t,version:n,dryRun:r,from:i,dir:a,log:o,brandFn:s,aliases:c}){let l=Y(a,i,n),u=Z(e,U(e),l,r,o,c);return r||await s({root:t}),u}async function ce({root:e,designRoot:t,app:n,version:r,dryRun:i,deps:a,log:o,aliases:s}){let c=D(e,`node_modules`,`@webority`,`tokens`,`package.json`);if(!b(c))throw Error(`@webority/tokens is not installed; add it at the lockstep version and run again`);let l=JSON.parse(x(c,`utf8`)).version,u=te(e),d=i?null:re(e),f=[...$(e,r,u,!i,o),...ee(e,r,u,!i,o)];if(i){o(`dry run: install skipped; tables are those of the installed ${l}`);let t=Y(a.renamesDir??D(e,`node_modules`,`@webority`,`tokens`,`renames`),l,r),n=Z(e,U(e),t,!0,o,s);return{...n,changedFiles:J(f,n.changedFiles)}}let p=a.run??ae,[m,...h]=d.command,{status:g}=await p(m,h,{cwd:e});if(g!==0)throw Error(`${d.manager} install failed with exit code ${g}`);let _=await(a.reenter??oe)({appRoot:e,designRoot:t,app:n,version:r,dryRun:!1,from:l,aliases:s});return{..._,changedFiles:J(f,_.changedFiles)}}async function le(t,n={}){let r=t.version;L(r);let i=t.root??process.cwd(),a=t.app===void 0?i:ie(i,t.app),o=t.dryRun??!1,s=t.aliases??{},c=n.log??console.log,l=()=>n.renamesDir??D(z(),`renames`);if(Array.isArray(t.paths)&&t.paths.length>0){let e=V(l()).filter(e=>e.version===r).map(e=>e.table);if(e.length===0&&r!==(n.ownVersion??B)())throw Error(`no rename table for ${r}`);return Z(a,U(a,t.paths),e,o,c,s)}if(!b(D(i,`.webority`,`design.json`)))throw Error(`write .webority/design.json (design-map.md) and run again`);let u=process.env[I];return u?se({root:a,designRoot:i,version:r,dryRun:o,from:u,dir:l(),log:c,brandFn:n.brand??e,aliases:s}):ce({root:a,designRoot:i,app:t.app,version:r,dryRun:o,deps:n,log:c,aliases:s})}export{le as upgrade};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{findQuoteEnd as e,tagOccurrences as t}from"./tagScan.js";import{applyEdits as n}from"./themeReads.js";var
|
|
2
|
-
`).length;function
|
|
1
|
+
import{findQuoteEnd as e,tagOccurrences as t}from"./tagScan.js";import{applyEdits as n}from"./themeReads.js";import{separatorAt as r}from"./valueSplits.js";var i=new Set([`.cshtml`,`.razor`]),a=/(\s*)([^\s=/>"']+)(\s*=\s*)?/y,o=e=>{let t=/\.[^./]*$/.exec(e);return t?t[0].toLowerCase():``},s=(e,t)=>e.slice(0,t).split(`
|
|
2
|
+
`).length;function c(t,n,r){let i=[],o=n;for(;;){a.lastIndex=o;let n=a.exec(t);if(n===null)break;let s=n.index+n[1].length,c={name:n[2],nameStart:s,nameEnd:s+n[2].length,wsStart:n.index,kind:`none`,attrEnd:s+n[2].length},l=n.index+n[0].length;if(n[3]!==void 0&&(t[l]===`"`||t[l]===`'`)){let n=e(t,l);if(n===-1)break;c.kind=`quoted`,c.value=t.slice(l+1,n),c.attrEnd=n+1}else n[3]!==void 0&&(c.kind=`bare`,c.attrEnd=l+/[^\s"'>]*/y.exec(t.slice(l))[0].length);if(c.attrEnd>r)break;i.push(c),o=c.attrEnd}return i}function l(e,a,l){if(l.length===0||!i.has(o(a)))return{text:e,hits:[],findings:[]};let u=[],d=[],f=[];for(let n of l)for(let i of n.tags)for(let{nameEnd:o,end:l}of t(e,i)){if(l===-1){f.push({file:a,line:s(e,o),path:`<${i}>`,message:`the tag could not be read (a quote in an attribute value does not pair up); set it by hand`});continue}let t=c(e,o,l),p=new Set(t.map(e=>e.name));for(let o of t){if(o.name!==n.attribute)continue;let t=s(e,o.nameStart),c=`<${i}> ${n.attribute}`,l=o.kind===`none`?`true`:o.kind===`quoted`?o.value.toLowerCase():void 0;if(l!==void 0&&!Object.hasOwn(n.values,l)&&n.keep?.includes(l))continue;if(l===void 0||!Object.hasOwn(n.values,l)){f.push({file:a,line:t,path:c,message:n.flag});continue}let m=Object.entries(n.values[l]).filter(([,e])=>e!==null),h=m.map(([e])=>e).filter(e=>e!==n.attribute&&p.has(e));if(h.length>0){f.push({file:a,line:t,path:c,message:`<${i}> already sets ${h.join(` and `)}; merge ${n.attribute} into it by hand`});continue}let g=m.map(([e,t])=>`${e}="${t}"`).join(r(e,o.nameStart)),_=m.length===0?o.wsStart:o.nameStart;u.push({start:_,end:o.attrEnd,text:g}),d.push({line:t,from:e.slice(o.nameStart,o.attrEnd),to:g.replace(/\n\s*/g,` `)})}}return d.sort((e,t)=>e.line-t.line||(e.from<t.from?-1:+(e.from>t.from))),f.sort((e,t)=>e.line-t.line||(e.path<t.path?-1:+(e.path>t.path))),{text:n(e,u,a),hits:d,findings:f}}export{l as applyRazorValueSplits};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import{applyEdits as e,componentOf as t,importedComponents as n,parseSource as r,skipped as i,stringNode as a,visit as o}from"./themeReads.js";var s=e=>e===null?`true`:e.type===`JSXExpressionContainer`&&e.expression.type===`BooleanLiteral`?String(e.expression.value):a(e)?.value,c=(e,t)=>typeof t==`string`?`${e}="${t}"`:`${e}={${t}}`,l=(e,t)=>{let n=e.lastIndexOf(`
|
|
2
2
|
`,t.start-1)+1,r=e.indexOf(`
|
|
3
|
-
`,t.end),i=r===-1?e.length:r;if(e.slice(n,t.start).trim()===``&&e.slice(t.end,i).trim()===``)return{start:n,end:i===e.length?i:i+1};let a=t.start;for(;a>0&&(e[a-1]===` `||e[a-1]===` `);)a--;return{start:a,end:t.end}}
|
|
3
|
+
`,t.end),i=r===-1?e.length:r;if(e.slice(n,t.start).trim()===``&&e.slice(t.end,i).trim()===``)return{start:n,end:i===e.length?i:i+1};let a=t.start;for(;a>0&&(e[a-1]===` `||e[a-1]===` `);)a--;return{start:a,end:t.end}},u=(e,t)=>{let n=e.lastIndexOf(`
|
|
4
|
+
`,t-1)+1,r=e.slice(n,t);return r.trim()===``&&n>0?`\n${r}`:` `};function d(a,d,f){if(f.length===0)return{text:a,hits:[],findings:[]};let p;try{p=r(a,d)}catch(e){return i(a,d,e)}if(p===null)return{text:a,hits:[],findings:[]};let m=[],h=[],g=[];for(let e of f){let r=n(p,e.package);o(p,n=>{if(n.type!==`JSXOpeningElement`)return;let i=t(n.name,r);if(!e.components.includes(i))return;let o=new Set(n.attributes.filter(e=>e.type===`JSXAttribute`&&e.name.type===`JSXIdentifier`).map(e=>e.name.name));for(let t of n.attributes){if(t.type!==`JSXAttribute`||t.name.type!==`JSXIdentifier`||t.name.name!==e.prop)continue;let n=t.loc.start.line,r=`${i}.${e.prop}`,f=s(t.value);if(f!==void 0&&!Object.hasOwn(e.values,f)&&e.keep?.includes(f))continue;if(f===void 0||!Object.hasOwn(e.values,f)){g.push({file:d,line:n,path:r,message:e.flag});continue}let p=Object.entries(e.values[f]).filter(([,e])=>e!==null),_=p.map(([e])=>e).filter(t=>t!==e.prop&&o.has(t));if(_.length>0){g.push({file:d,line:n,path:r,message:`${i} already sets ${_.join(` and `)}; merge ${e.prop} into it by hand`});continue}let v=p.map(([e,t])=>c(e,t)).join(u(a,t.start)),y=p.length===0?l(a,t):{start:t.start,end:t.end};m.push({start:y.start,end:y.end,text:v}),h.push({line:n,from:a.slice(t.start,t.end),to:v.replace(/\n\s*/g,` `)})}})}return h.sort((e,t)=>e.line-t.line||(e.from<t.from?-1:+(e.from>t.from))),g.sort((e,t)=>e.line-t.line||(e.path<t.path?-1:+(e.path>t.path))),{text:e(a,m,d),hits:h,findings:g}}export{d as applyValueSplits,u as separatorAt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{componentOf as e,importedComponents as t,parseSource as n,stringNode as r,visit as i}from"./themeReads.js";import{readFileSync as a}from"node:fs";import{basename as o,dirname as s,join as c}from"node:path";var l=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`]),u=5,d=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],f=e=>{let t=Object.entries(e).filter(([,e])=>e!==null);return t.length===0?`nothing (drop the prop)`:t.map(([e,t])=>typeof t==`string`?`${e}="${t}"`:`${e}={${t}}`).join(` `)};function p(e){let t=[];for(let n of e.valueSplits??[]){let e=new Map;for(let[t,r]of Object.entries(n.values))t!==`true`&&t!==`false`&&!n.keep?.includes(t)&&e.set(t,f(r));e.size>0&&t.push({package:n.package,components:n.components,prop:n.prop,label:e=>`${e}.${n.prop}`,old:e})}for(let n of e.componentProps??[]){if(n.values===void 0)continue;let e=n.to??n.prop,r=new Map;for(let[t,i]of Object.entries(n.values))t!==i&&r.set(t,`${e}="${i}"`);r.size>0&&t.push({package:n.package,components:n.components,prop:n.prop,label:e=>`${e}.${n.prop}`,old:r})}for(let n of e.props??[])for(let e of n.props)t.push({package:n.package,components:null,prop:e,label:t=>`${t}.${e}`,old:new Map([[n.from,`${e}="${n.to}"`]])});return t}var m=e=>e.type===`Identifier`?e.name:e.type===`StringLiteral`?e.value:void 0,h=(e,t)=>{for(let n of e.properties){if(n.type===`RestElement`){n.argument.type===`Identifier`&&t.rest.add(n.argument.name);continue}if(n.type!==`ObjectProperty`||n.computed)continue;let e=m(n.key);if(e===void 0)continue;t.named.add(e);let r=n.value;r.type===`Identifier`?t.locals.set(r.name,{prop:e,fallback:void 0}):r.type===`AssignmentPattern`&&r.left.type===`Identifier`&&t.locals.set(r.left.name,{prop:e,fallback:r.right})}},g=e=>{if(e!=null){if(l.has(e.type))return e;if(e.type===`CallExpression`)for(let t of e.arguments){let e=g(t);if(e!==void 0)return e}}},_=e=>/^[A-Z]/.test(e);function v(e,t){let n=[],r=(e,t)=>{if(t===void 0||!_(e))return;let r={props:new Set,rest:new Set,named:new Set,locals:new Map},a=t.params[0];if(a?.type===`AssignmentPattern`&&(a=a.left),a?.type===`Identifier`)r.props.add(a.name);else if(a?.type===`ObjectPattern`)h(a,r);else return;i(t.body,e=>{e.type===`VariableDeclarator`&&e.id.type===`ObjectPattern`&&e.init?.type===`Identifier`&&r.props.has(e.init.name)&&h(e.id,r)}),n.push({name:e,fn:t,shape:r})};return i(e,(e,n)=>{if(e.type===`FunctionDeclaration`&&e.id!==null)r(e.id.name,e);else if(e.type===`VariableDeclarator`&&e.id.type===`Identifier`)r(e.id.name,g(e.init));else if(e.type===`ExportDefaultDeclaration`&&n.length===1){let n=e.declaration;l.has(n.type)&&n.id===null?r(o(t).replace(/\.[^.]+$/,``),n):n.type===`CallExpression`&&r(o(t).replace(/\.[^.]+$/,``),g(n))}}),n}var y=e=>{let t=e.split(`/`);return e.startsWith(`@`)?t.slice(0,2).join(`/`):t[0]},b=e=>e.replace(/\.(?:jsx?|mjs|cjs|tsx?)$/i,``).replace(/\/index$/,``),x=(e,t)=>{let n=e.split(`/`),r=t.split(`/`),i=0;for(;i<n.length-1&&i<r.length-1&&n[i]===r[i];)i++;return i},S=(e,t,n,r)=>{let a=new Map;i(e,e=>{if(e.type!==`ImportDeclaration`)return;let t=e.source.value;for(let n of e.specifiers)if(n.type===`ImportDefaultSpecifier`)a.set(n.local.name,{specifier:t,imported:null});else if(n.type===`ImportSpecifier`){let e=n.imported.type===`StringLiteral`?n.imported.value:n.imported.name;a.set(n.local.name,{specifier:t,imported:e==="default"?null:e})}else a.set(n.local.name,{specifier:t,imported:void 0})});let l=e=>!e.startsWith(`.`)&&!e.startsWith(`/`)&&(e.startsWith(`@webority/`)||r.has(y(e)));return e=>{if(e.type!==`JSXIdentifier`)return[];let r=e.name,i=a.get(r);if(i===void 0)return n.filter(e=>e.file===t&&e.name===r);if(i.imported===void 0||l(i.specifier))return[];let u=o(b(i.specifier)),d=n.filter(e=>i.imported===null?e.name===r||o(b(e.file))===u:e.name===i.imported);if(d.length===0)return[];if(i.specifier.startsWith(`.`)){let e=c(s(t),i.specifier).split(`\\`).join(`/`),n=d.filter(t=>b(t.file)===b(e));if(n.length>0)return n}let f=Math.max(...d.map(e=>x(e.file,t))),p=d.filter(e=>x(e.file,t)===f),m=[...new Set(p.map(e=>e.file))].sort()[0];return p.filter(e=>e.file===m)}},C=(e,t,n)=>{let r=e.attributes.find(e=>e.type===`JSXAttribute`&&e.name.type===`JSXIdentifier`&&e.name.name===t);if(r!==void 0){let e=r.value?.type===`JSXExpressionContainer`?r.value.expression:void 0;return e?.type===`Identifier`?n.locals.get(e.name)?.prop:e?.type===`MemberExpression`&&!e.computed&&e.object.type===`Identifier`&&n.props.has(e.object.name)&&e.property.type===`Identifier`?e.property.name:void 0}for(let r of e.attributes){if(r.type!==`JSXSpreadAttribute`||r.argument.type!==`Identifier`)continue;let e=r.argument.name;if(n.props.has(e)||n.rest.has(e)&&!n.named.has(t))return t}};function w(r,s,l,f=new Map){let m=p(l),h=new Set;for(let e of s)if(!(o(e)!==`package.json`||e.split(`/`).includes(`node_modules`)))try{let t=JSON.parse(a(c(r,e),`utf8`));for(let e of d)for(let n of Object.keys(t[e]??{}))h.add(n)}catch{}if(m.length===0)return{wrappers:[],packages:h};let g=[];for(let e of s){if(!f.has(e))try{f.set(e,n(a(c(r,e),`utf8`),e))}catch{f.set(e,null)}let t=f.get(e);t!==null&&g.push({file:e,ast:t,definitions:v(t,e)})}let _=[],y=new Set;for(let n=0;n<u;n++){let r=[..._],a=_.length;for(let{file:a,ast:o,definitions:s}of g){if(s.length===0)continue;let c=S(o,a,r,h),l=new Map,u=e=>(l.has(e)||l.set(e,t(o,e)),l.get(e));for(let{name:t,fn:r,shape:o}of s)i(r.body,r=>{if(r.type!==`JSXOpeningElement`)return;let i=[];if(n===0)for(let t of m){let n=e(r.name,u(t.package));n!==void 0&&(t.components===null||t.components.includes(n))&&i.push({prop:t.prop,target:t,reaches:t.label(n)})}for(let e of c(r.name))(e.name!==t||e.file!==a)&&i.push({prop:e.prop,target:e.target,reaches:e.reaches});for(let e of i){let n=C(r,e.prop,o);if(n===void 0)continue;let i=`${a}\0${t}\0${n}\0${e.reaches}`;y.has(i)||(y.add(i),_.push({file:a,name:t,prop:n,target:e.target,reaches:e.reaches}))}})}if(_.length===a)break}return{wrappers:_,packages:h}}var T=(e,t)=>`"${e}" reaches ${t.reaches} through ${t.name} (${t.file}), which no longer takes it; it becomes ${t.target.old.get(e)} there, so pass the new props through ${t.name} by hand`,E=(e,t)=>`the default ${t.prop}="${e}" reaches ${t.reaches}, which no longer takes it; it becomes ${t.target.old.get(e)} there, so change the default and forward the new props by hand`;function D(e,t,a){if(a.wrappers.length===0)return{text:e,hits:[],findings:[]};let o;try{o=n(e,t)}catch{return{text:e,hits:[],findings:[]}}if(o===null)return{text:e,hits:[],findings:[]};let s=[],c=new Set,l=(e,n,r)=>{let i=`${e}\0${n}\0${r}`;c.has(i)||(c.add(i),s.push({file:t,line:e,path:n,message:r}))},u=S(o,t,a.wrappers,a.packages);i(o,e=>{if(e.type===`JSXOpeningElement`)for(let t of u(e.name))for(let n of e.attributes){if(n.type!==`JSXAttribute`||n.name.type!==`JSXIdentifier`||n.name.name!==t.prop)continue;let e=r(n.value)?.value;e!==void 0&&t.target.old.has(e)&&l(n.loc.start.line,`${t.name}.${t.prop}`,T(e,t))}});let d=a.wrappers.filter(e=>e.file===t);if(d.length>0)for(let{name:e,shape:n}of v(o,t))for(let{prop:t,fallback:r}of n.locals.values()){let n=r?.type===`StringLiteral`?r.value:void 0;if(n!==void 0)for(let i of d)i.name===e&&i.prop===t&&i.target.old.has(n)&&l(r.loc.start.line,`${e}.${t}`,E(n,i))}return s.sort((e,t)=>e.line-t.line||(e.path<t.path?-1:+(e.path>t.path))),{text:e,hits:[],findings:s}}export{D as applyWrapperValues,v as componentDefinitions,w as findWrappers,p as wrapperTargets};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/tokens",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.134.1",
|
|
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",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"./renames/*": "./renames/*"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
|
-
"node": ">=24.15 <
|
|
36
|
+
"node": ">=24.15 <27"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@babel/parser": "7.29.8"
|