@webority/tokens 0.0.0-stage → 0.90.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/LICENSE +5 -0
- package/dist/_virtual/_rolldown/runtime.js +1 -0
- package/dist/brand.d.ts +33 -0
- package/dist/brand.js +2 -0
- package/dist/build.js +5 -0
- package/dist/canvas/renames.json +159 -0
- package/dist/canvas/webority-phone.json +763 -0
- package/dist/canvas/webority-web-390.json +423 -0
- package/dist/canvas/webority-web.json +423 -0
- package/dist/canvas-renames.js +1 -0
- package/dist/check.js +2 -0
- package/dist/cli.d.ts +91 -0
- package/dist/cli.js +2 -0
- package/dist/deviations.js +1 -0
- package/dist/emit/canvas.js +1 -0
- package/dist/emit/email.js +2 -0
- package/dist/emit/meanings.js +1 -0
- package/dist/emit/phone.js +3 -0
- package/dist/emit/web.js +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/meanings.json +879 -0
- package/dist/model/colour.js +1 -0
- package/dist/model/derive.js +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/length.js +1 -0
- package/dist/model/load.js +1 -0
- package/dist/model/references.js +1 -0
- package/dist/model/resolve.js +2 -0
- package/dist/names.d.ts +13 -0
- package/dist/names.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +2 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +4 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +4 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +1 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +1 -0
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +1 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.9/node_modules/fast-uri/index.js +1 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.9/node_modules/fast-uri/lib/schemes.js +1 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.9/node_modules/fast-uri/lib/utils.js +1 -0
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +1 -0
- package/dist/outputs.d.ts +139 -0
- package/dist/source/component.tokens.json +1672 -0
- package/dist/source/meaning.tokens.json +1025 -0
- package/dist/source/mode.dark.tokens.json +594 -0
- package/dist/source/palette.tokens.json +1406 -0
- package/dist/source/platform.phone.tokens.json +395 -0
- package/dist/source/scale.tokens.json +869 -0
- package/dist/source/width.390.tokens.json +96 -0
- package/dist/upgrade/css.js +2 -0
- package/dist/upgrade/index.js +5 -0
- package/dist/upgrade/razorAttributes.js +3 -0
- package/dist/upgrade/themeReads.js +2 -0
- package/dist/webority.js +2 -0
- package/dist/webority.resolver.json +18 -0
- package/package.json +46 -3
- package/renames/0.87.1.json +14 -0
- package/renames/0.89.0.json +1423 -0
- package/renames/renames.d.ts +42 -0
- package/schema/design-map.schema.json +143 -0
- package/schema/webority-tokens.schema.json +211 -0
- package/README.md +0 -3
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"text": {
|
|
3
|
+
"xs": {
|
|
4
|
+
"$value": {
|
|
5
|
+
"value": 12.07,
|
|
6
|
+
"unit": "px",
|
|
7
|
+
"lineHeight": 1.5
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"sm": {
|
|
11
|
+
"$value": {
|
|
12
|
+
"value": 13.11,
|
|
13
|
+
"unit": "px",
|
|
14
|
+
"lineHeight": 1.5
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"base": {
|
|
18
|
+
"$value": {
|
|
19
|
+
"value": 15.38,
|
|
20
|
+
"unit": "px",
|
|
21
|
+
"lineHeight": 1.5
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"lg": {
|
|
25
|
+
"$value": {
|
|
26
|
+
"value": 17.04,
|
|
27
|
+
"unit": "px",
|
|
28
|
+
"lineHeight": 1.4
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"xl": {
|
|
32
|
+
"$value": {
|
|
33
|
+
"value": 20.35,
|
|
34
|
+
"unit": "px",
|
|
35
|
+
"lineHeight": 1.3
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"2xl": {
|
|
39
|
+
"$value": {
|
|
40
|
+
"value": 24.7,
|
|
41
|
+
"unit": "px",
|
|
42
|
+
"lineHeight": 1.25
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"3xl": {
|
|
46
|
+
"$value": {
|
|
47
|
+
"value": 30.83,
|
|
48
|
+
"unit": "px",
|
|
49
|
+
"lineHeight": 1.2
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"4xl": {
|
|
53
|
+
"$value": {
|
|
54
|
+
"value": 36.95,
|
|
55
|
+
"unit": "px",
|
|
56
|
+
"lineHeight": 1.1
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"5xl": {
|
|
60
|
+
"$value": {
|
|
61
|
+
"value": 45.03,
|
|
62
|
+
"unit": "px",
|
|
63
|
+
"lineHeight": 1.05
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"6xl": {
|
|
67
|
+
"$value": {
|
|
68
|
+
"value": 56.65,
|
|
69
|
+
"unit": "px",
|
|
70
|
+
"lineHeight": 1
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"7xl": {
|
|
74
|
+
"$value": {
|
|
75
|
+
"value": 64,
|
|
76
|
+
"unit": "px",
|
|
77
|
+
"lineHeight": 1
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"8xl": {
|
|
81
|
+
"$value": {
|
|
82
|
+
"value": 72.03,
|
|
83
|
+
"unit": "px",
|
|
84
|
+
"lineHeight": 1
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"size": {
|
|
89
|
+
"container-pad": {
|
|
90
|
+
"$value": {
|
|
91
|
+
"value": 24,
|
|
92
|
+
"unit": "px"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=new Set([`.css`,`.scss`,`.sass`,`.less`,`.js`,`.jsx`,`.mjs`,`.ts`,`.tsx`,`.cshtml`,`.razor`,`.html`,`.vue`,`.json`]),t=new Set([`node_modules`,`dist`,`bin`,`obj`,`.git`,`.next`,`coverage`]);function n(e,t,n){for(let r=0;r+1<e.length;r++)if(e[r]===t&&e[r+1]===n)return!0;return!1}function r(r){let i=r.replace(/\\/g,`/`).split(`/`);if(i.some(e=>t.has(e))||n(i,`wwwroot`,`lib`))return!1;let a=i[i.length-1].match(/\.[^.]+$/),o=a?a[0].toLowerCase():``;return o===`.css`&&n(i,`wwwroot`,`css`)?!1:e.has(o)}function i(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function a(e){return[...e].sort((e,t)=>t.length-e.length).map(i).join(`|`)}function o(e,t,n){if(!r(t))return{text:e,hits:[],choose:[],checkRole:[]};let{rename:i,reads:o,choose:s,checkRole:c}=n.css,l=new Map;for(let[e,t]of o)l.set(e,t);for(let[e,t]of i)l.set(e,t);let u=new Set(o.map(([e])=>e)),d=new Set([...i.map(([e])=>e),...Object.keys(s)]),f=[];if(u.size>0&&f.push(`(?<=var\\(\\s*)(${a(u)})(?![\\w-])`),d.size>0&&f.push(`(?<![\\w-])(${a(d)})(?![\\w-])`),f.length===0)return{text:e,hits:[],choose:[],checkRole:[]};let p=new RegExp(f.join(`|`),`g`),m=new Set(c),h=[],g=[],_=[],v=1,y=0;return{text:e.replace(p,(t,...n)=>{let r=n[n.length-2];for(;y<r;y++)e[y]===`
|
|
2
|
+
`&&v++;if(Object.hasOwn(s,t))return g.push({line:v,name:t,hint:s[t]}),t;let i=l.get(t);return h.push({line:v,from:t,to:i}),m.has(i)&&_.push({line:v,from:t,to:i}),i}),hits:h,choose:g,checkRole:_}}export{e as CSS_TARGET_EXTENSIONS,o as applyCssTable,r as isCssTarget};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{brand as e}from"../build.js";import{applyCssTable as t,isCssTarget as n}from"./css.js";import{applyRazorAttributes as r}from"./razorAttributes.js";import{applyPropSplits as i,applyPropValues as a,applyProps as o,applyThemeReads as s}from"./themeReads.js";import{createRequire as c}from"node:module";import{existsSync as l,readFileSync as u,readdirSync as d,writeFileSync as f}from"node:fs";import{dirname as p,join as m}from"node:path";import{fileURLToPath as h,pathToFileURL as g}from"node:url";import{spawnSync as _}from"node:child_process";var v=/^\d+\.\d+\.\d+$/,y=/^(?:workspace:|file:|link:)/,b=`WEBORITY_UPGRADE_FROM`;function x(e){if(typeof e!=`string`||!v.test(e))throw Error(`invalid version "${e}"`)}function S(e,t){x(e),x(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 C(){let e=p(h(import.meta.url));for(;;){let t=m(e,`package.json`);if(l(t)&&JSON.parse(u(t,`utf8`)).name===`@webority/tokens`)return e;let n=p(e);if(n===e)throw Error(`cannot find the @webority/tokens package folder`);e=n}}function w(e){let t=[];for(let n of d(e)){if(!n.endsWith(`.json`))continue;let r=n.slice(0,-5);v.test(r)&&t.push({version:r,table:JSON.parse(u(m(e,n),`utf8`))})}return t.sort((e,t)=>S(e.version,t.version))}function T(e,t){let n=_(`git`,[`ls-files`,`-z`,`--`,...t],{cwd:e,encoding:`utf8`,windowsHide:!0,maxBuffer:64*1024*1024});if(n.status!==0)throw Error(`not a git repository: ${e}`);let r=n.stdout.split(`\0`).filter(Boolean).map(e=>e.split(`\\`).join(`/`));return[...new Set(r)]}function E(e,t){let n=T(e,t??[`.`]);if(t!==void 0&&n.length===0)throw Error(`no tracked files under ${t.join(`, `)}`);return n}function D(e){return e.split(`/`).includes(`node_modules`)}function O(e,t){return[...new Set([...e,...t])]}function k(e,t,n){return w(e).filter(e=>S(e.version,t)>0&&S(e.version,n)<=0).map(e=>e.table)}function A(e,c,l,d,p){d&&p(`dry run: nothing written`);let h=[],g=[],_=[];for(let v of c){if(!n(v))continue;let c=u(m(e,v),`utf8`),y=c,b=e=>{for(let t of e)h.push({file:v,line:t.line,from:t.from,to:t.to}),p(`${v}:${t.line} ${t.from} -> ${t.to}`)},x=e=>{g.push({file:v,line:e.line,name:e.name,hint:e.hint}),p(`choose ${v}:${e.line} ${e.name}: ${e.hint}`)},S=e=>{for(let t of e)t.message.startsWith(`skipped, it does not parse`)?p(`skipped ${v}: ${t.message}`):x({line:t.line,name:t.path,hint:t.message})};for(let e of l){let n=t(y,v,e);y=n.text,b(n.hits);for(let e of n.choose)x(e);for(let e of n.checkRole)p(`verify ${v}:${e.line} ${e.from} -> ${e.to}`);let c=s(y,v,e.themeReads);y=c.text,b(c.hits),S(c.findings);let l=[t=>o(t,v,e.props),t=>a(t,v,e.propValues),t=>i(t,v,e.propSplits),t=>r(t,v,e.razorAttributes)];for(let e of l){let t=e(y);y=t.text,b(t.hits),S(t.findings)}}y!==c&&(_.push(v),d||f(m(e,v),y,`utf8`))}return{hits:h,choose:g,changedFiles:_}}function j(e){let t=/^([ \t]+)\S/m.exec(e);return t?t[1]:4}function M(e,t,n,r,i){let a=[];for(let o of T(e,[`package.json`,`:(glob)**/package.json`])){if(D(o))continue;let s=u(m(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];y.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,j(s));s.endsWith(`
|
|
2
|
+
`)&&(t+=`
|
|
3
|
+
`),s.includes(`\r
|
|
4
|
+
`)&&(t=t.replace(/\n/g,`\r
|
|
5
|
+
`)),f(m(e,o),t,`utf8`)}}return a}function N(e,t,n,r,i){let a=[];for(let o of T(e,[`Directory.Packages.props`,`:(glob)**/Directory.Packages.props`])){if(D(o))continue;let s=u(m(e,o),`utf8`),c=!1,l=s.replace(/<PackageVersion\b[^>]*>/g,e=>{let r=/\sInclude="([^"]*)"/.exec(e)?.[1],a=/\sVersion="([^"]*)"/.exec(e)?.[1];return r===void 0||a===void 0||!n.nuget.includes(r)||a===t?e:(i(`pin ${o}: ${r} ${a} -> ${t}`),c=!0,e.replace(/(\sVersion=")[^"]*(")/,`$1${t}$2`))});c&&(a.push(o),r&&f(m(e,o),l,`utf8`))}return a}function P(e){let t;try{t=c(m(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(u(t,`utf8`))}function F(e,t,n){return _(e,t,{cwd:n.cwd,env:process.env,stdio:`inherit`,windowsHide:!0,shell:process.platform===`win32`})}async function I({root:e,version:t,from:n}){let r=c(m(e,`package.json`)).resolve(`@webority/tokens`);process.env[b]=n;try{return await(await import(g(r).href)).upgrade({root:e,version:t,dryRun:!1})}finally{delete process.env[b]}}async function L({root:e,version:t,dryRun:n,from:r,dir:i,log:a,brandFn:o}){let s=w(i);if(!n&&!s.some(e=>e.version===t))throw Error(`no rename table for ${t}`);let c=s.filter(e=>S(e.version,r)>0&&S(e.version,t)<=0).map(e=>e.table),l=A(e,E(e),c,n,a);return n||await o({root:e}),l}async function R({root:e,version:t,dryRun:n,deps:r,log:i}){let a=m(e,`node_modules`,`@webority`,`tokens`,`package.json`);if(!l(a))throw Error(`@webority/tokens is not installed; add it at the lockstep version and run again`);let o=JSON.parse(u(a,`utf8`)).version,s=P(e),c=[...M(e,t,s,!n,i),...N(e,t,s,!n,i)];if(n){i(`dry run: install skipped; tables are those of the installed ${o}`);let n=k(r.renamesDir??m(e,`node_modules`,`@webority`,`tokens`,`renames`),o,t),a=A(e,E(e),n,!0,i);return{...a,changedFiles:O(c,a.changedFiles)}}let{status:d}=await(r.run??F)(`corepack`,[`pnpm`,`install`],{cwd:e});if(d!==0)throw Error(`pnpm install failed with exit code ${d}`);let f=await(r.reenter??I)({root:e,version:t,dryRun:!1,from:o});return{...f,changedFiles:O(c,f.changedFiles)}}async function z(t,n={}){let r=t.version;x(r);let i=t.root??process.cwd(),a=t.dryRun??!1,o=n.log??console.log,s=()=>n.renamesDir??m(C(),`renames`);if(Array.isArray(t.paths)&&t.paths.length>0){let e=w(s()).filter(e=>e.version===r).map(e=>e.table);if(e.length===0)throw Error(`no rename table for ${r}`);return A(i,E(i,t.paths),e,a,o)}if(!l(m(i,`.webority`,`design.json`)))throw Error(`write .webority/design.json (design-map.md) and run again`);let c=process.env[b];return c?L({root:i,version:r,dryRun:a,from:c,dir:s(),log:o,brandFn:n.brand??e}):R({root:i,version:r,dryRun:a,deps:n,log:o})}export{z as upgrade};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var e=new Set([`.cshtml`,`.razor`]);function t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function n(e){let t=/\.[^./]*$/.exec(e);return t?t[0].toLowerCase():``}function r(e){let t=[];for(let n=e.indexOf(`
|
|
2
|
+
`);n!==-1;n=e.indexOf(`
|
|
3
|
+
`,n+1))t.push(n);return t}function i(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n+1}function a(e,t){let n=``;for(let r=t;r<e.length;r++){let t=e[r];if(n)t===n&&(n=``);else if(t===`"`||t===`'`)n=t;else if(t===`>`)return r}return-1}function o(e,t){let n=`<${t}`,r=[];for(let t=e.indexOf(n);t!==-1;t=e.indexOf(n,t+1)){let i=t+n.length;if(!/[\s/>]/.test(e[i]??``))continue;let o=a(e,i);o!==-1&&r.push({nameEnd:i,end:o})}return r}function s(e,t){return e<t?-1:+(e>t)}function c(a,c,l){if(l.length===0||!e.has(n(c)))return{text:a,hits:[],findings:[]};let u=r(a),d=[],f=[],p=[];for(let e of l){let n=e.attribute,r=t(n),s=RegExp(`(?<=\\s)${r}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`,`g`),l=RegExp(`(?<=\\s)${r}(?=[\\s/]|$)(?!\\s*=)`,`g`),m=(t,r)=>({file:c,line:r,path:`<${t}> ${n}`,message:`${n} takes a named value such as "${e.values.true}" or "${e.values.false}" now, not a boolean; set it by hand`});for(let t of e.tags)for(let{nameEnd:r,end:c}of o(a,t)){let o=a.slice(r,c);for(let a of o.matchAll(s)){let o=r+a.index,s=i(u,o),c=a[1]??a[2],l=o+a[0].length-1,h=l-c.length,g=c.toLowerCase();if(Object.hasOwn(e.values,g)){let t=e.values[g];d.push({start:h,end:l,text:t}),f.push({line:s,from:`${n}="${c}"`,to:`${n}="${t}"`})}else c.startsWith(`@`)&&p.push(m(t,s))}for(let e of o.matchAll(l))p.push(m(t,i(u,r+e.index)))}}d.sort((e,t)=>t.start-e.start);let m=a;for(let e of d)m=m.slice(0,e.start)+e.text+m.slice(e.end);return f.sort((e,t)=>e.line-t.line||s(e.from,t.from)),p.sort((e,t)=>e.line-t.line||s(e.path,t.path)),{text:m,hits:f,findings:p}}export{c as applyRazorAttributes};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"node:path";import{parse as t}from"@babel/parser";var n=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`ObjectMethod`,`ClassMethod`]),r=new Set([`MemberExpression`,`OptionalMemberExpression`]),i=new Set([`CallExpression`,`OptionalCallExpression`]),a=new Set([`useTheme`,`getTheme`]),o=new Set([`loc`,`start`,`end`,`extra`,`comments`,`leadingComments`,`trailingComments`,`innerComments`]),s=new Map([[`.js`,[`jsx`]],[`.jsx`,[`jsx`]],[`.mjs`,[`jsx`]],[`.cjs`,[`jsx`]],[`.ts`,[`typescript`]],[`.tsx`,[`typescript`,`jsx`]]]),c=/^[A-Za-z_$][\w$]*$/,l=new Set([`lightOverrides`,`darkOverrides`]),u=`move the brand into theme/brand.tokens.json, list the app under tokens.heads.phone, run webority brand, pass brand and settings`,d=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,f=(e,t,n=[])=>{if(Array.isArray(e)){for(let r of e)f(r,t,n);return}if(!d(e))return;t(e,n);let r=[...n,e];for(let[n,i]of Object.entries(e))!o.has(n)&&typeof i==`object`&&i&&f(i,t,r)},p=(n,r)=>{let i=s.get(e.extname(r).toLowerCase());return i===void 0?null:t(n,{sourceType:`module`,plugins:i})},m=(e,t,n)=>({text:e,hits:[],findings:[{file:t,line:1,path:``,message:`skipped, it does not parse (${(n instanceof Error?n.message:String(n)).split(`
|
|
2
|
+
`)[0]})`}]}),h=(e,t,n)=>{let r=[...t].sort((e,t)=>e.start-t.start||e.end-t.end),i=0;for(let e of r){if(e.start<i)throw Error(`two edits overlap in ${n}; fix it by hand`);i=e.end}let a=e;for(let e of r.reverse())a=a.slice(0,e.start)+e.text+a.slice(e.end);return a},g=e=>e.replace(/\.$/,``).split(`.`),_=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),v=(e,t)=>e<t?-1:+(e>t),y=(e,t)=>{let n=t.at(-1);return n!==void 0&&r.has(n.type)&&n.object===e},b=e=>d(e)&&i.has(e.type)&&e.callee.type===`Identifier`&&a.has(e.callee.name),x=e=>{for(let t=e.length-1;t>=0;t--)if(n.has(e[t].type))return e[t];return e.find(e=>e.type===`Program`)},S=e=>{let t=new Map;return f(e,(e,n)=>{if(e.type!==`VariableDeclarator`||e.id.type!==`Identifier`||!b(e.init))return;let r=x(n);t.has(r)||t.set(r,new Set),t.get(r)?.add(e.id.name)}),t},C=(e,t,r)=>t.some(t=>(n.has(t.type)||t.type===`Program`)&&r.get(t)?.has(e)===!0),w=(e,t,n)=>e.type===`Identifier`?e.name===`theme`||C(e.name,t,n):b(e),T=e=>{if(e.computed!==!0&&e.property.type===`Identifier`)return e.property.name;if(e.computed===!0&&e.property.type===`StringLiteral`)return e.property.value};function E(e,t,n){if(n.length===0)return{text:e,hits:[],findings:[]};let i;try{i=p(e,t)}catch(n){return m(e,t,n)}if(i===null)return{text:e,hits:[],findings:[]};let a=S(i),o=n.filter(e=>e.kind===`path`||e.kind===`prefix`||e.kind===`gone`).sort((e,t)=>g(t.from).length-g(e.from).length),s=n.filter(e=>e.kind===`kebab`),d=[],b=[],x=[],C=new Set,E=(e,n)=>{let r=`${e}:${n}`;C.has(r)||(C.add(r),x.push({file:t,line:e,path:n,message:u}))},D=(e,n)=>{let i=[],l=e;for(;r.has(l.type);)i.unshift(l),l=l.object;if(!w(l,n,a))return;let u=[];for(let e of i){let t=T(e);if(t===void 0)break;u.push(t)}let f=u.length;if(f===0)return;let p=[...u];for(let e of o){let n=g(e.from),r=e.kind===`prefix`&&e.from.endsWith(`.`);if(!(f<n.length||r&&f===n.length)&&n.every((e,t)=>u[t]===e)){if(e.kind===`gone`){x.push({file:t,line:i[n.length-1].property.loc.start.line,path:n.join(`.`),message:`no longer exists; ${e.hint}`});return}if(e.kind===`path`||e.kind===`prefix`){p=[...g(e.to),...u.slice(n.length)];break}}}for(let e of s){let t=e.under.split(`.`),n=t.length;if(p.length<=n||!t.every((e,t)=>p[t]===e))continue;let r=p[n];Object.hasOwn(e.names,r)&&(p[n]=e.names[r]);for(let e=n+1;e<p.length;e++)/[A-Z]/.test(p[e])&&(p[e]=p[e].replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase())}if(_(p,u))return;let m=p.map((e,t)=>{let n=i[t]?.optional===!0;return c.test(e)?`${n?`?.`:`.`}${e}`:`${n?`?.`:``}["${e}"]`}).join(``);d.push({start:l.end,end:i[f-1].end,text:m}),b.push({line:i[0].property.loc.start.line,from:u.join(`.`),to:p.join(`.`)})};return f(i,(e,t)=>{r.has(e.type)&&!y(e,t)&&D(e,t),e.type===`JSXAttribute`&&e.name.type===`JSXIdentifier`&&l.has(e.name.name)&&E(e.loc.start.line,e.name.name),e.type===`Identifier`&&e.name===`ThemeOverrides`&&E(e.loc.start.line,e.name)}),b.sort((e,t)=>e.line-t.line||v(e.from,t.from)),x.sort((e,t)=>e.line-t.line||v(e.path,t.path)),{text:h(e,d,t),hits:b,findings:x}}var D=(e,t,n)=>{if(e.type===`JSXIdentifier`)return t.has(e.name);if(e.type===`JSXMemberExpression`){let t=e;for(;t.type===`JSXMemberExpression`;)t=t.object;return t.type===`JSXIdentifier`&&n.has(t.name)}return!1},O=e=>{if(e?.type===`StringLiteral`)return e;if(e?.type===`JSXExpressionContainer`&&e.expression.type===`StringLiteral`)return e.expression};function k(e,t,n){if(n.length===0)return{text:e,hits:[],findings:[]};let r;try{r=p(e,t)}catch(n){return m(e,t,n)}if(r===null)return{text:e,hits:[],findings:[]};let i=[],a=[];for(let t of n){let n=new Set,o=new Set;f(r,e=>{if(!(e.type!==`ImportDeclaration`||e.source.value!==t.package))for(let t of e.specifiers)t.type===`ImportNamespaceSpecifier`?o.add(t.local.name):n.add(t.local.name)});let s=new Set(t.props);f(r,r=>{if(!(r.type!==`JSXOpeningElement`||!D(r.name,n,o)))for(let n of r.attributes){if(n.type!==`JSXAttribute`||n.name.type!==`JSXIdentifier`||!s.has(n.name.name))continue;let r=O(n.value);if(r===void 0||r.value!==t.from)continue;let o=e[r.start];i.push({start:r.start,end:r.end,text:`${o}${t.to}${o}`}),a.push({line:r.loc.start.line,from:`${n.name.name}="${t.from}"`,to:`${n.name.name}="${t.to}"`})}})}return a.sort((e,t)=>e.line-t.line||v(e.from,t.from)),{text:h(e,i,t),hits:a,findings:[]}}var A=(e,t)=>{let n=new Map,r=new Set;return f(e,e=>{if(!(e.type!==`ImportDeclaration`||e.source.value!==t))for(let t of e.specifiers)if(t.type===`ImportSpecifier`){let e=t.imported.type===`StringLiteral`?t.imported.value:t.imported.name;n.set(t.local.name,e)}else t.type===`ImportNamespaceSpecifier`&&r.add(t.local.name)}),{named:n,namespaces:r}},j=(e,t)=>{if(e.type===`JSXIdentifier`)return t.named.get(e.name);if(e.type===`JSXMemberExpression`&&e.object.type===`JSXIdentifier`&&t.namespaces.has(e.object.name))return e.property.name};function M(e,t,n){if(n.length===0)return{text:e,hits:[],findings:[]};let r;try{r=p(e,t)}catch(n){return m(e,t,n)}if(r===null)return{text:e,hits:[],findings:[]};let i=[],a=[],o=[];for(let s of n){let n=A(r,s.package);f(r,r=>{if(r.type!==`JSXOpeningElement`)return;let c=j(r.name,n);if(s.components.includes(c))for(let n of r.attributes){if(n.type!==`JSXAttribute`||n.name.type!==`JSXIdentifier`||n.name.name!==s.prop)continue;let r=n.value,l=n.loc.start.line,u=r?.type===`JSXExpressionContainer`?r.expression:void 0,d=r===null?!0:u?.type===`BooleanLiteral`?u.value:void 0,f;if(d!==void 0)f=`${s.prop}="${d?s.true:s.false}"`;else if(O(r)!==void 0)continue;else{o.push({file:t,line:l,path:`${c}.${s.prop}`,message:`${s.prop} takes a named value such as "${s.true}" or "${s.false}" now, not a boolean; set it by hand`});continue}i.push({start:n.start,end:n.end,text:f}),a.push({line:l,from:e.slice(n.start,n.end),to:f})}})}return a.sort((e,t)=>e.line-t.line||v(e.from,t.from)),o.sort((e,t)=>e.line-t.line||v(e.path,t.path)),{text:h(e,i,t),hits:a,findings:o}}function N(e,t,n){if(n.length===0)return{text:e,hits:[],findings:[]};let r;try{r=p(e,t)}catch(n){return m(e,t,n)}if(r===null)return{text:e,hits:[],findings:[]};let i=t=>e.slice(t.start,t.end),a=new Set([`ObjectExpression`,`Identifier`,`MemberExpression`,`OptionalMemberExpression`]),o=new Set([`SequenceExpression`,`AssignmentExpression`,`ConditionalExpression`,`YieldExpression`]),s=e=>{if(e?.type===`LogicalExpression`&&e.operator===`&&`)return{test:e.left,consequent:e.right};let t=e?.alternate;if(e?.type===`ConditionalExpression`&&(t.type===`NullLiteral`||t.type===`Identifier`&&t.name===`undefined`||t.type===`BooleanLiteral`&&t.value===!1))return{test:e.test,consequent:e.consequent}},c=e=>o.has(e.test.type)?`(${i(e.test)})`:i(e.test),l=[],u=[],d=[];for(let e of n){let n=A(r,e.package);f(r,r=>{if(r.type!==`JSXOpeningElement`)return;let o=j(r.name,n);if(!e.components.includes(o))return;let f=r.attributes.some(t=>t.type===`JSXAttribute`&&t.name.type===`JSXIdentifier`&&t.name.name===e.into);for(let n of r.attributes){if(n.type!==`JSXAttribute`||n.name.type!==`JSXIdentifier`||n.name.name!==e.prop)continue;let r=n.value,p=n.loc.start.line;if(O(r)!==void 0)continue;let m=`${o}.${e.prop}`;if(f){d.push({file:t,line:p,path:m,message:`already sets ${e.into}; set ${e.prop} to "${e.on}" or "${e.off}" by hand`});continue}let h=r?.type===`JSXExpressionContainer`?r.expression:void 0,g=r===null?!0:h?.type===`BooleanLiteral`?h.value:void 0,_=s(h),v;if(g!==void 0)v=`${e.prop}="${g?e.on:e.off}"`;else if(a.has(h?.type))v=`${e.prop}="${e.on}" ${e.into}={${i(h)}}`;else if(_!==void 0&&_.consequent.type===`BooleanLiteral`&&_.consequent.value===!0)v=`${e.prop}={${c(_)} ? "${e.on}" : "${e.off}"}`;else if(_!==void 0&&a.has(_.consequent.type))v=`${e.prop}={${c(_)} ? "${e.on}" : "${e.off}"} ${e.into}={${i(_.consequent)}}`;else{d.push({file:t,line:p,path:m,message:`${e.prop} takes "${e.on}" or "${e.off}" now, and its settings object moves to ${e.into}; set both by hand`});continue}l.push({start:n.start,end:n.end,text:v}),u.push({line:p,from:i(n),to:v})}})}return u.sort((e,t)=>e.line-t.line||v(e.from,t.from)),d.sort((e,t)=>e.line-t.line||v(e.path,t.path)),{text:h(e,l,t),hits:u,findings:d}}export{N as applyPropSplits,M as applyPropValues,k as applyProps,E as applyThemeReads};
|
package/dist/webority.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2025.10",
|
|
3
|
+
"sets": [
|
|
4
|
+
{
|
|
5
|
+
"sources": [
|
|
6
|
+
{ "$ref": "source/palette.tokens.json" },
|
|
7
|
+
{ "$ref": "source/scale.tokens.json" },
|
|
8
|
+
{ "$ref": "source/meaning.tokens.json" },
|
|
9
|
+
{ "$ref": "source/component.tokens.json" }
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"modifiers": [
|
|
14
|
+
{ "name": "mode", "default": "light", "contexts": { "light": [], "dark": [{ "$ref": "source/mode.dark.tokens.json" }] } },
|
|
15
|
+
{ "name": "platform", "default": "web", "contexts": { "web": [], "phone": [{ "$ref": "source/platform.phone.tokens.json" }] } },
|
|
16
|
+
{ "name": "width", "default": "1440", "contexts": { "1440": [], "390": [{ "$ref": "source/width.390.tokens.json" }] } }
|
|
17
|
+
]
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/tokens",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.90.0",
|
|
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
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"schema",
|
|
14
|
+
"renames"
|
|
15
|
+
],
|
|
16
|
+
"bin": {
|
|
17
|
+
"webority": "./dist/webority.js"
|
|
18
|
+
},
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./names": {
|
|
26
|
+
"types": "./dist/names.d.ts",
|
|
27
|
+
"default": "./dist/names.js"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
"./canvas/*.json": "./dist/canvas/*.json",
|
|
31
|
+
"./meanings.json": "./dist/meanings.json",
|
|
32
|
+
"./schema/*": "./schema/*",
|
|
33
|
+
"./renames/*": "./renames/*"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=24.15 <25"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@babel/parser": "7.29.8"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"ajv": "8.20.0",
|
|
43
|
+
"vite": "^8.0.12"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "vite build && node dist/webority.js brand --library --out dist",
|
|
47
|
+
"test": "node --test \"src/**/*.test.js\""
|
|
48
|
+
}
|
|
6
49
|
}
|