@webority/tokens 0.144.2 → 0.146.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/meanings.json
CHANGED
|
@@ -1 +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};
|
|
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(t){throw Error(`${e} could not be read as a package manifest: ${t.message}`,{cause:t})}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.146.0",
|
|
4
4
|
"description": "The Webority design tokens in one W3C Design Tokens source (palette, scale, meaning and component tiers, with light and dark, web and phone, and 390 and 1440 widths), and the webority command that brands a product, upgrades it between releases and checks it against the token source.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|