@webority/tokens 0.128.0 → 0.130.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.
@@ -4,7 +4,7 @@
4
4
  "sm": {
5
5
  "radius": {
6
6
  "$type": "dimension",
7
- "$value": "{radius.sm}"
7
+ "$value": "{radius.md}"
8
8
  },
9
9
  "padding-x": {
10
10
  "$type": "dimension",
@@ -97,7 +97,7 @@
97
97
  "md": {
98
98
  "radius": {
99
99
  "$type": "dimension",
100
- "$value": "{radius.sm}"
100
+ "$value": "{radius.md}"
101
101
  },
102
102
  "padding-x": {
103
103
  "$type": "dimension",
@@ -190,7 +190,7 @@
190
190
  "lg": {
191
191
  "radius": {
192
192
  "$type": "dimension",
193
- "$value": "{radius.sm}"
193
+ "$value": "{radius.md}"
194
194
  },
195
195
  "padding-x": {
196
196
  "$type": "dimension",
@@ -298,6 +298,11 @@
298
298
  "shadow": {
299
299
  "$type": "shadow",
300
300
  "$value": "0 0 0 2px {color.primary-soft}"
301
+ },
302
+ "soft-shadow": {
303
+ "$type": "shadow",
304
+ "$value": "0 0 0 {component.focus-ring.width} {color.focus-ring-soft}",
305
+ "$description": "Soft halo drawn around a focused text field, in the translucent focus ring colour."
301
306
  }
302
307
  },
303
308
  "press": {
@@ -348,6 +353,27 @@
348
353
  "platforms": ["web"]
349
354
  }
350
355
  },
356
+ "pad": {
357
+ "$type": "dimension",
358
+ "$value": {
359
+ "value": 20,
360
+ "unit": "px"
361
+ },
362
+ "$description": "Padding inside a card and its header; a card class can set it to retune one card."
363
+ },
364
+ "title-fs": {
365
+ "$type": "dimension",
366
+ "$value": {
367
+ "value": 16,
368
+ "unit": "px"
369
+ },
370
+ "$description": "Font size of a card title."
371
+ },
372
+ "title-lh": {
373
+ "$type": "number",
374
+ "$value": 1.3,
375
+ "$description": "Line height of a card title."
376
+ },
351
377
  "shadow-lifted": {
352
378
  "$type": "shadow",
353
379
  "$value": "none"
@@ -370,6 +396,75 @@
370
396
  }
371
397
  }
372
398
  },
399
+ "modal": {
400
+ "$extensions": {
401
+ "com.webority": {
402
+ "platforms": ["web"]
403
+ }
404
+ },
405
+ "max-width": {
406
+ "$type": "dimension",
407
+ "$value": {
408
+ "value": 440,
409
+ "unit": "px"
410
+ },
411
+ "$description": "Maximum width of a modal dialog; each dialog sets it from its size."
412
+ }
413
+ },
414
+ "drawer": {
415
+ "$extensions": {
416
+ "com.webority": {
417
+ "platforms": ["web"]
418
+ }
419
+ },
420
+ "max": {
421
+ "$type": "number",
422
+ "$value": 90,
423
+ "$description": "Height of a bottom sheet drawer as a count of viewport height percent."
424
+ }
425
+ },
426
+ "step-tile": {
427
+ "$extensions": {
428
+ "com.webority": {
429
+ "platforms": ["web"]
430
+ }
431
+ },
432
+ "size": {
433
+ "$type": "dimension",
434
+ "$value": {
435
+ "value": 34,
436
+ "unit": "px"
437
+ },
438
+ "$description": "Width and height of the numbered circle in a step tile."
439
+ }
440
+ },
441
+ "kpi": {
442
+ "$extensions": {
443
+ "com.webority": {
444
+ "platforms": ["web"]
445
+ }
446
+ },
447
+ "value-size": {
448
+ "$type": "dimension",
449
+ "$value": {
450
+ "value": 24,
451
+ "unit": "px"
452
+ },
453
+ "$description": "Font size of the main figure in a KPI tile."
454
+ }
455
+ },
456
+ "nav-menu": {
457
+ "$extensions": {
458
+ "com.webority": {
459
+ "platforms": ["web"]
460
+ }
461
+ },
462
+ "current-bg": {
463
+ "$type": "color",
464
+ "$value": "transparent",
465
+ "$description": "Background of the current item in a navigation menu."
466
+ }
467
+ },
373
468
  "container": {
374
469
  "$extensions": {
375
470
  "com.webority": {
@@ -1673,6 +1768,15 @@
1673
1768
  "value": 30,
1674
1769
  "unit": "px"
1675
1770
  }
1771
+ },
1772
+ "edge-offset": {
1773
+ "$type": "dimension",
1774
+ "$value": "{space.lg}",
1775
+ "$extensions": {
1776
+ "com.webority": {
1777
+ "platforms": ["web"]
1778
+ }
1779
+ }
1676
1780
  }
1677
1781
  },
1678
1782
  "banner": {
@@ -39,6 +39,42 @@
39
39
  }
40
40
  }
41
41
  },
42
+ "surface-inverse-wash-4": {
43
+ "$value": "color-mix(in srgb, {color.text-inverse} 4%, transparent)",
44
+ "$description": "Faintest translucent wash over an inverse band, for a resting tile or row.",
45
+ "$extensions": {
46
+ "com.webority": {
47
+ "platforms": ["web"]
48
+ }
49
+ }
50
+ },
51
+ "surface-inverse-wash-8": {
52
+ "$value": "color-mix(in srgb, {color.text-inverse} 8%, transparent)",
53
+ "$description": "Light translucent wash over an inverse band, for a hovered tile or row.",
54
+ "$extensions": {
55
+ "com.webority": {
56
+ "platforms": ["web"]
57
+ }
58
+ }
59
+ },
60
+ "surface-inverse-wash-12": {
61
+ "$value": "color-mix(in srgb, {color.text-inverse} 12%, transparent)",
62
+ "$description": "Medium translucent wash over an inverse band, for a selected or pressed tile or row.",
63
+ "$extensions": {
64
+ "com.webority": {
65
+ "platforms": ["web"]
66
+ }
67
+ }
68
+ },
69
+ "surface-inverse-wash-24": {
70
+ "$value": "color-mix(in srgb, {color.text-inverse} 24%, transparent)",
71
+ "$description": "Strong translucent wash over an inverse band, for a divider or a filled chip.",
72
+ "$extensions": {
73
+ "com.webority": {
74
+ "platforms": ["web"]
75
+ }
76
+ }
77
+ },
42
78
  "surface-dark": {
43
79
  "$value": "{palette.text-heading}",
44
80
  "$description": "Band that stays dark in light and dark mode, such as a site footer or a dark hero."
@@ -121,6 +157,15 @@
121
157
  "$value": "{color.primary-text}",
122
158
  "$description": "Colour of the keyboard focus ring drawn on focus-visible controls."
123
159
  },
160
+ "focus-ring-soft": {
161
+ "$value": "color-mix(in srgb, {color.focus-ring} 25%, transparent)",
162
+ "$description": "Translucent step of the focus ring colour, for a soft halo around a focused field.",
163
+ "$extensions": {
164
+ "com.webority": {
165
+ "platforms": ["web"]
166
+ }
167
+ }
168
+ },
124
169
  "scrim": {
125
170
  "$value": "color-mix(in srgb, {palette.text-heading} 45%, transparent)",
126
171
  "$description": "Dim behind page-level backdrops such as drawers, modals and the shell."
@@ -603,6 +603,27 @@
603
603
  }
604
604
  },
605
605
  "shadow": {
606
+ "elevated": {
607
+ "$value": {
608
+ "color": "rgba(0, 0, 0, 0.45)",
609
+ "offsetX": {
610
+ "value": 0,
611
+ "unit": "px"
612
+ },
613
+ "offsetY": {
614
+ "value": 2,
615
+ "unit": "px"
616
+ },
617
+ "blur": {
618
+ "value": 8,
619
+ "unit": "px"
620
+ },
621
+ "spread": {
622
+ "value": -2,
623
+ "unit": "px"
624
+ }
625
+ }
626
+ },
606
627
  "popover": {
607
628
  "$value": {
608
629
  "color": "rgba(0, 0, 0, 0.55)",
@@ -155,6 +155,27 @@
155
155
  }
156
156
  }
157
157
  },
158
+ "elevated": {
159
+ "$value": {
160
+ "color": "{palette.phone-shadow-md}",
161
+ "offsetX": {
162
+ "value": 0,
163
+ "unit": "px"
164
+ },
165
+ "offsetY": {
166
+ "value": 4,
167
+ "unit": "px"
168
+ },
169
+ "blur": {
170
+ "value": 8,
171
+ "unit": "px"
172
+ },
173
+ "spread": {
174
+ "value": 0,
175
+ "unit": "px"
176
+ }
177
+ }
178
+ },
158
179
  "popover": {
159
180
  "$value": {
160
181
  "color": "{palette.phone-shadow-lg}",
@@ -378,13 +378,13 @@
378
378
  "elevated": {
379
379
  "$type": "shadow",
380
380
  "$value": {
381
- "color": "{palette.phone-shadow-md}",
381
+ "color": "rgba(7, 20, 55, 0.10)",
382
382
  "offsetX": {
383
383
  "value": 0,
384
384
  "unit": "px"
385
385
  },
386
386
  "offsetY": {
387
- "value": 4,
387
+ "value": 2,
388
388
  "unit": "px"
389
389
  },
390
390
  "blur": {
@@ -392,14 +392,13 @@
392
392
  "unit": "px"
393
393
  },
394
394
  "spread": {
395
- "value": 0,
395
+ "value": -2,
396
396
  "unit": "px"
397
397
  }
398
398
  },
399
- "$description": "Shadow of a surface lifted above the page, such as a toast or a floating action button.",
399
+ "$description": "Shadow of a surface lifted slightly above the page, such as a toast, a sticky bar or a floating action button.",
400
400
  "$extensions": {
401
401
  "com.webority": {
402
- "platforms": ["phone"],
403
402
  "elevation": 4
404
403
  }
405
404
  }
@@ -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{applyMarkup as c,applySource as l}from"./source.js";import{applyComponentProps as u,applyPropSplits as d,applyPropValues as f,applyProps as p,applyThemeReads as m}from"./themeReads.js";import{createRequire as h}from"node:module";import{existsSync as g,readFileSync as _,readdirSync as v,writeFileSync as y}from"node:fs";import{dirname as b,isAbsolute as x,join as S,relative as C,resolve as w,sep as T}from"node:path";import{fileURLToPath as E,pathToFileURL as D}from"node:url";import{spawnSync as O}from"node:child_process";var k=/^\d+\.\d+\.\d+$/,A=/^(?:workspace:|file:|link:)/,j=`WEBORITY_UPGRADE_FROM`;function M(e){if(typeof e!=`string`||!k.test(e))throw Error(`invalid version "${e}"`)}function N(e,t){M(e),M(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 P(){let e=b(E(import.meta.url));for(;;){let t=S(e,`package.json`);if(g(t)&&JSON.parse(_(t,`utf8`)).name===`@webority/tokens`)return e;let n=b(e);if(n===e)throw Error(`cannot find the @webority/tokens package folder`);e=n}}function F(e){let t=[];for(let n of v(e)){if(!n.endsWith(`.json`))continue;let r=n.slice(0,-5);k.test(r)&&t.push({version:r,table:JSON.parse(_(S(e,n),`utf8`))})}return t.sort((e,t)=>N(e.version,t.version))}function I(e,t){let n=O(`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=>g(S(e,t)));return[...new Set(r)]}function L(e,t){let n=I(e,t??[`.`]);if(t!==void 0&&n.length===0)throw Error(`no tracked files under ${t.join(`, `)}`);return n}function R(e){return e.split(`/`).includes(`node_modules`)}var z=new Set([`node_modules`,`vendor`,`vendors`,`external`]),B=/\.(?:min|bundle)\.(?:js|css)$/;function V(e){let t=e.split(`/`);return t.some(e=>z.has(e))||t.some((e,n)=>e===`lib`&&t[n-1]===`wwwroot`)?!0:B.test(e)}function H(e,t){return[...new Set([...e,...t])]}function U(e,t,n){return F(e).filter(e=>N(e.version,t)>0&&N(e.version,n)<=0).map(e=>e.table)}function W(e,h,g,v,b){v&&b(`dry run: nothing written`);let x=[],C=[],w=[],T=h.filter(e=>i(e)&&!V(e)),E=g.map(()=>new Set);if(g.some(e=>(e.css.ownable??[]).length>0))for(let t of T){let n=_(S(e,t),`utf8`);g.forEach((e,r)=>{for(let i of a(n,t,e))E[r].add(i)})}for(let i of T){let a=_(S(e,i),`utf8`),h=a,T=e=>{for(let t of e)x.push({file:i,line:t.line,from:t.from,to:t.to}),b(`${i}:${t.line} ${t.from} -> ${t.to}`)},D=e=>{C.push({file:i,line:e.line,name:e.name,hint:e.hint}),b(`choose ${i}:${e.line} ${e.name}: ${e.hint}`)},O=e=>{for(let t of e)t.message.startsWith(`skipped, it does not parse`)?b(`skipped ${i}: ${t.message}`):D({line:t.line,name:t.path,hint:t.message})};for(let[e,a]of g.entries()){let g=r(h,i,a,E[e]);h=g.text,T(g.hits);for(let e of g.choose)D(e);for(let e of g.checkRole)b(`verify ${i}:${e.line} ${e.from} -> ${e.to}`);let _=m(h,i,a.themeReads);h=_.text,T(_.hits),O(_.findings);let v=[e=>p(e,i,a.props),e=>u(e,i,a.componentProps),e=>f(e,i,a.propValues),e=>d(e,i,a.propSplits),e=>o(e,i,a.razorAttributes),e=>n(e,i,a.components??[]),e=>s(e,i,a.razorTags??[]),e=>t(e,i,a.classes??[]),e=>c(e,i,a.markup),e=>l(e,i,a.source)];for(let e of v){let t=e(h);h=t.text,T(t.hits),O(t.findings)}}h!==a&&(w.push(i),v||y(S(e,i),h,`utf8`))}return{hits:x,choose:C,changedFiles:w}}function G(e){let t=/^([ \t]+)\S/m.exec(e);return t?t[1]:4}function K(e,t,n,r,i){let a=[];for(let o of I(e,[`package.json`,`:(glob)**/package.json`])){if(R(o))continue;let s=_(S(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];A.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,G(s));s.endsWith(`
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{createRequire as _}from"node:module";import{existsSync as v,readFileSync as y,readdirSync as b,writeFileSync as x}from"node:fs";import{dirname as S,isAbsolute as C,join as w,relative as T,resolve as E,sep as D}from"node:path";import{fileURLToPath as O,pathToFileURL as k}from"node:url";import{spawnSync as A}from"node:child_process";var j=/^\d+\.\d+\.\d+$/,M=/^(?:workspace:|file:|link:)/,N=`WEBORITY_UPGRADE_FROM`;function P(e){if(typeof e!=`string`||!j.test(e))throw Error(`invalid version "${e}"`)}function F(e,t){P(e),P(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 I(){let e=S(O(import.meta.url));for(;;){let t=w(e,`package.json`);if(v(t)&&JSON.parse(y(t,`utf8`)).name===`@webority/tokens`)return e;let n=S(e);if(n===e)throw Error(`cannot find the @webority/tokens package folder`);e=n}}function L(e){let t=[];for(let n of b(e)){if(!n.endsWith(`.json`))continue;let r=n.slice(0,-5);j.test(r)&&t.push({version:r,table:JSON.parse(y(w(e,n),`utf8`))})}return t.sort((e,t)=>F(e.version,t.version))}function R(e,t){let n=A(`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=>v(w(e,t)));return[...new Set(r)]}function z(e,t){let n=R(e,t??[`.`]);if(t!==void 0&&n.length===0)throw Error(`no tracked files under ${t.join(`, `)}`);return n}function B(e){return e.split(`/`).includes(`node_modules`)}var V=new Set([`node_modules`,`vendor`,`vendors`,`external`]),H=/\.(?:min|bundle)\.(?:js|css)$/;function U(e){let t=e.split(`/`);return t.some(e=>V.has(e))||t.some((e,n)=>e===`lib`&&t[n-1]===`wwwroot`)?!0:H.test(e)}function W(e,t){return[...new Set([...e,...t])]}function G(e,t,n){return L(e).filter(e=>F(e.version,t)>0&&F(e.version,n)<=0).map(e=>e.table)}function K(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 q(e,_,v,b,S,C={}){b&&S(`dry run: nothing written`);let T=v.map(e=>K(e,C)),E=[],D=[],O=[],k=_.filter(e=>i(e)&&!U(e)),A=T.map(()=>new Set);if(T.some(e=>(e.css.ownable??[]).length>0))for(let t of k){let n=y(w(e,t),`utf8`);T.forEach((e,r)=>{for(let i of a(n,t,e))A[r].add(i)})}for(let i of k){let a=y(w(e,i),`utf8`),_=a,v=e=>{for(let t of e)E.push({file:i,line:t.line,from:t.from,to:t.to}),S(`${i}:${t.line} ${t.from} -> ${t.to}`)},C=e=>{D.push({file:i,line:e.line,name:e.name,hint:e.hint}),S(`choose ${i}:${e.line} ${e.name}: ${e.hint}`)},k=e=>{for(let t of e)t.message.startsWith(`skipped, it does not parse`)?S(`skipped ${i}: ${t.message}`):C({line:t.line,name:t.path,hint:t.message})};for(let[e,a]of T.entries()){let y=r(_,i,a,A[e]);_=y.text,v(y.hits);for(let e of y.choose)C(e);for(let e of y.checkRole)S(`verify ${i}:${e.line} ${e.from} -> ${e.to}`);let b=h(_,i,a.themeReads);_=b.text,v(b.hits),k(b.findings);let x=[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 x){let t=e(_);_=t.text,v(t.hits),k(t.findings)}}_!==a&&(O.push(i),b||x(w(e,i),_,`utf8`))}return{hits:E,choose:D,changedFiles:O}}function J(e){let t=/^([ \t]+)\S/m.exec(e);return t?t[1]:4}function Y(e,t,n,r,i){let a=[];for(let o of R(e,[`package.json`,`:(glob)**/package.json`])){if(B(o))continue;let s=y(w(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];M.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
2
  `)&&(t+=`
3
3
  `),s.includes(`\r
4
4
  `)&&(t=t.replace(/\n/g,`\r
5
- `)),y(S(e,o),t,`utf8`)}}return a}function q(e,t,n,r,i){let a=[];for(let o of I(e,[`Directory.Packages.props`,`:(glob)**/Directory.Packages.props`])){if(R(o))continue;let s=_(S(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&&y(S(e,o),l,`utf8`))}return a}function J(e){let t;try{t=h(S(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(_(t,`utf8`))}var Y=[{file:`pnpm-lock.yaml`,manager:`pnpm`,command:[`corepack`,`pnpm`,`install`]},{file:`package-lock.json`,manager:`npm`,command:[`npm`,`install`]}];function X(e){let t=Y.filter(t=>g(S(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 Z(e,t){let n=w(e,t),r=C(e,n);if(r===``||x(r)||r.split(T)[0]===`..`)throw Error(`--app ${t}: give a folder inside the repo root`);if(!g(S(n,`package.json`)))throw Error(`--app ${t}: no package.json in that folder`);return n}function Q(e,t,n){return O(e,t,{cwd:n.cwd,env:process.env,stdio:`inherit`,windowsHide:!0,shell:process.platform===`win32`})}async function $({appRoot:e,designRoot:t,app:n,version:r,from:i}){let a=h(S(e,`package.json`)).resolve(`@webority/tokens`);process.env[j]=i;try{return await(await import(D(a).href)).upgrade({root:t,app:n,version:r,dryRun:!1})}finally{delete process.env[j]}}async function ee({root:e,designRoot:t,version:n,dryRun:r,from:i,dir:a,log:o,brandFn:s}){let c=F(a);if(!r&&!c.some(e=>e.version===n))throw Error(`no rename table for ${n}`);let l=c.filter(e=>N(e.version,i)>0&&N(e.version,n)<=0).map(e=>e.table),u=W(e,L(e),l,r,o);return r||await s({root:t}),u}async function te({root:e,designRoot:t,app:n,version:r,dryRun:i,deps:a,log:o}){let s=S(e,`node_modules`,`@webority`,`tokens`,`package.json`);if(!g(s))throw Error(`@webority/tokens is not installed; add it at the lockstep version and run again`);let c=JSON.parse(_(s,`utf8`)).version,l=J(e),u=i?null:X(e),d=[...K(e,r,l,!i,o),...q(e,r,l,!i,o)];if(i){o(`dry run: install skipped; tables are those of the installed ${c}`);let t=U(a.renamesDir??S(e,`node_modules`,`@webority`,`tokens`,`renames`),c,r),n=W(e,L(e),t,!0,o);return{...n,changedFiles:H(d,n.changedFiles)}}let f=a.run??Q,[p,...m]=u.command,{status:h}=await f(p,m,{cwd:e});if(h!==0)throw Error(`${u.manager} install failed with exit code ${h}`);let v=await(a.reenter??$)({appRoot:e,designRoot:t,app:n,version:r,dryRun:!1,from:c});return{...v,changedFiles:H(d,v.changedFiles)}}async function ne(t,n={}){let r=t.version;M(r);let i=t.root??process.cwd(),a=t.app===void 0?i:Z(i,t.app),o=t.dryRun??!1,s=n.log??console.log,c=()=>n.renamesDir??S(P(),`renames`);if(Array.isArray(t.paths)&&t.paths.length>0){let e=F(c()).filter(e=>e.version===r).map(e=>e.table);if(e.length===0)throw Error(`no rename table for ${r}`);return W(a,L(a,t.paths),e,o,s)}if(!g(S(i,`.webority`,`design.json`)))throw Error(`write .webority/design.json (design-map.md) and run again`);let l=process.env[j];return l?ee({root:a,designRoot:i,version:r,dryRun:o,from:l,dir:c(),log:s,brandFn:n.brand??e}):te({root:a,designRoot:i,app:t.app,version:r,dryRun:o,deps:n,log:s})}export{ne as upgrade};
5
+ `)),x(w(e,o),t,`utf8`)}}return a}function X(e,t,n,r,i){let a=[];for(let o of R(e,[`Directory.Packages.props`,`:(glob)**/Directory.Packages.props`])){if(B(o))continue;let s=y(w(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&&x(w(e,o),l,`utf8`))}return a}function Z(e){let t;try{t=_(w(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(y(t,`utf8`))}var Q=[{file:`pnpm-lock.yaml`,manager:`pnpm`,command:[`corepack`,`pnpm`,`install`]},{file:`package-lock.json`,manager:`npm`,command:[`npm`,`install`]}];function $(e){let t=Q.filter(t=>v(w(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 ee(e,t){let n=E(e,t),r=T(e,n);if(r===``||C(r)||r.split(D)[0]===`..`)throw Error(`--app ${t}: give a folder inside the repo root`);if(!v(w(n,`package.json`)))throw Error(`--app ${t}: no package.json in that folder`);return n}function te(e,t,n){return A(e,t,{cwd:n.cwd,env:process.env,stdio:`inherit`,windowsHide:!0,shell:process.platform===`win32`})}async function ne({appRoot:e,designRoot:t,app:n,version:r,from:i,aliases:a}){let o=_(w(e,`package.json`)).resolve(`@webority/tokens`);process.env[N]=i;try{return await(await import(k(o).href)).upgrade({root:t,app:n,version:r,dryRun:!1,aliases:a})}finally{delete process.env[N]}}async function re({root:e,designRoot:t,version:n,dryRun:r,from:i,dir:a,log:o,brandFn:s,aliases:c}){let l=L(a);if(!r&&!l.some(e=>e.version===n))throw Error(`no rename table for ${n}`);let u=l.filter(e=>F(e.version,i)>0&&F(e.version,n)<=0).map(e=>e.table),d=q(e,z(e),u,r,o,c);return r||await s({root:t}),d}async function ie({root:e,designRoot:t,app:n,version:r,dryRun:i,deps:a,log:o,aliases:s}){let c=w(e,`node_modules`,`@webority`,`tokens`,`package.json`);if(!v(c))throw Error(`@webority/tokens is not installed; add it at the lockstep version and run again`);let l=JSON.parse(y(c,`utf8`)).version,u=Z(e),d=i?null:$(e),f=[...Y(e,r,u,!i,o),...X(e,r,u,!i,o)];if(i){o(`dry run: install skipped; tables are those of the installed ${l}`);let t=G(a.renamesDir??w(e,`node_modules`,`@webority`,`tokens`,`renames`),l,r),n=q(e,z(e),t,!0,o,s);return{...n,changedFiles:W(f,n.changedFiles)}}let p=a.run??te,[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??ne)({appRoot:e,designRoot:t,app:n,version:r,dryRun:!1,from:l,aliases:s});return{..._,changedFiles:W(f,_.changedFiles)}}async function ae(t,n={}){let r=t.version;P(r);let i=t.root??process.cwd(),a=t.app===void 0?i:ee(i,t.app),o=t.dryRun??!1,s=t.aliases??{},c=n.log??console.log,l=()=>n.renamesDir??w(I(),`renames`);if(Array.isArray(t.paths)&&t.paths.length>0){let e=L(l()).filter(e=>e.version===r).map(e=>e.table);if(e.length===0)throw Error(`no rename table for ${r}`);return q(a,z(a,t.paths),e,o,c,s)}if(!v(w(i,`.webority`,`design.json`)))throw Error(`write .webority/design.json (design-map.md) and run again`);let u=process.env[N];return u?re({root:a,designRoot:i,version:r,dryRun:o,from:u,dir:l(),log:c,brandFn:n.brand??e,aliases:s}):ie({root:a,designRoot:i,app:t.app,version:r,dryRun:o,deps:n,log:c,aliases:s})}export{ae as upgrade};
@@ -0,0 +1,2 @@
1
+ import{findQuoteEnd as e,tagOccurrences as t}from"./tagScan.js";import{applyEdits as n}from"./themeReads.js";var r=new Set([`.cshtml`,`.razor`]),i=/(\s*)([^\s=/>"']+)(\s*=\s*)?/y,a=e=>{let t=/\.[^./]*$/.exec(e);return t?t[0].toLowerCase():``},o=(e,t)=>e.slice(0,t).split(`
2
+ `).length;function s(t,n,r){let a=[],o=n;for(;;){i.lastIndex=o;let n=i.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;a.push(c),o=c.attrEnd}return a}function c(e,i,c){if(c.length===0||!r.has(a(i)))return{text:e,hits:[],findings:[]};let l=[],u=[],d=[];for(let n of c)for(let r of n.tags)for(let{nameEnd:a,end:c}of t(e,r)){if(c===-1){d.push({file:i,line:o(e,a),path:`<${r}>`,message:`the tag could not be read (a quote in an attribute value does not pair up); set it by hand`});continue}let t=s(e,a,c),f=new Set(t.map(e=>e.name));for(let a of t){if(a.name!==n.attribute)continue;let t=o(e,a.nameStart),s=`<${r}> ${n.attribute}`,c=a.kind===`none`?`true`:a.kind===`quoted`?a.value.toLowerCase():void 0;if(c!==void 0&&!Object.hasOwn(n.values,c)&&n.keep?.includes(c))continue;if(c===void 0||!Object.hasOwn(n.values,c)){d.push({file:i,line:t,path:s,message:n.flag});continue}let p=Object.entries(n.values[c]).filter(([,e])=>e!==null),m=p.map(([e])=>e).filter(e=>e!==n.attribute&&f.has(e));if(m.length>0){d.push({file:i,line:t,path:s,message:`<${r}> already sets ${m.join(` and `)}; merge ${n.attribute} into it by hand`});continue}let h=p.map(([e,t])=>`${e}="${t}"`).join(` `),g=p.length===0?a.wsStart:a.nameStart;l.push({start:g,end:a.attrEnd,text:h}),u.push({line:t,from:e.slice(a.nameStart,a.attrEnd),to:h})}}return u.sort((e,t)=>e.line-t.line||(e.from<t.from?-1:+(e.from>t.from))),d.sort((e,t)=>e.line-t.line||(e.path<t.path?-1:+(e.path>t.path))),{text:n(e,l,i),hits:u,findings:d}}export{c as applyRazorValueSplits};
@@ -1,3 +1,3 @@
1
1
  import e from"node:path";var t=new Set([`.js`,`.jsx`,`.mjs`,`.cjs`,`.ts`,`.tsx`,`.mts`,`.cts`]),n=new Set([`.cshtml`,`.razor`,`.html`]),r=`["'\`]`,i=`[A-Za-z_$][\\w$]*`,a=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),o=e=>[...e].sort((e,t)=>t.length-e.length).map(a).join(`|`),s=e=>{let t=[0];for(let n=0;n<e.length;n++)e[n]===`
2
- `&&t.push(n+1);return t},c=(e,t)=>{let n=0,r=e.length-1;for(;n<r;){let i=n+r+1>>1;e[i]<=t?n=i:r=i-1}return n+1},l=(e,t)=>e<t?-1:+(e>t),u=(e,t,n)=>{if(t.length===0)return e;let i=new Map(t),a=RegExp(`(${r})(${o(i.keys())})\\1`,`g`),l=s(e);return e.replace(a,(e,t,r,a)=>{let o=i.get(r);return n.push({line:c(l,a),from:r,to:o}),`${t}${o}${t}`})},d=(e,t,n)=>{let r=e;for(let e of t){let t=e.receiver===void 0?void 0:RegExp(`^(?:${e.receiver})$`),o=RegExp(`(${i})(\\?\\.|\\.)${a(e.from)}(?![\\w$])`,`g`),l=s(r);r=r.replace(o,(r,i,a,o)=>t!==void 0&&!t.test(i)?r:(n.push({line:c(l,o),from:`${i}${a}${e.from}`,to:`${i}${a}${e.to}`}),`${i}${a}${e.to}`))}return r},f=(e,t)=>{let n=e.split(`
3
- `),r=[];for(let e of t){let t=new RegExp(e.pattern);for(let i=0;i<n.length;i++){let a=t.exec(n[i]);a!==null&&r.push({line:i+1,path:a[0],message:e.hint})}}return r};function p(n,r,i){if(i===void 0||!t.has(e.extname(r).toLowerCase()))return{text:n,hits:[],findings:[]};let a=[],o=d(u(n,i.literals,a),i.members,a),s=f(o,i.flags);return a.sort((e,t)=>e.line-t.line||l(e.from,t.from)),s.sort((e,t)=>e.line-t.line||l(e.path,t.path)),{text:o,hits:a,findings:s}}function m(t,r,i){if(i===void 0||!n.has(e.extname(r).toLowerCase()))return{text:t,hits:[],findings:[]};let a=[],o=u(t,i.literals,a),s=f(o,i.flags);return a.sort((e,t)=>e.line-t.line||l(e.from,t.from)),s.sort((e,t)=>e.line-t.line||l(e.path,t.path)),{text:o,hits:a,findings:s}}export{t as SOURCE_EXTENSIONS,m as applyMarkup,p as applySource};
2
+ `&&t.push(n+1);return t},c=(e,t)=>{let n=0,r=e.length-1;for(;n<r;){let i=n+r+1>>1;e[i]<=t?n=i:r=i-1}return n+1},l=(e,t)=>e<t?-1:+(e>t),u=(e,t,n)=>{if(t.length===0)return e;let i=new Map(t),a=RegExp(`(${r})(${o(i.keys())})\\1`,`g`),l=s(e);return e.replace(a,(e,t,r,a)=>{let o=i.get(r);return n.push({line:c(l,a),from:r,to:o}),`${t}${o}${t}`})},d=(e,t,n)=>{let r=e;for(let e of t){let t=e.receiver===void 0?void 0:RegExp(`^(?:${e.receiver})$`),o=RegExp(`(${i})(\\?\\.|\\.)${a(e.from)}(?![\\w$])`,`g`),l=s(r);r=r.replace(o,(r,i,a,o)=>t!==void 0&&!t.test(i)?r:(n.push({line:c(l,o),from:`${i}${a}${e.from}`,to:`${i}${a}${e.to}`}),`${i}${a}${e.to}`))}return r},f=(e,t)=>RegExp(`(?:\\bfrom\\s*|\\bimport\\s*\\(?\\s*|\\brequire\\(\\s*)["']${a(t)}["']`).test(e),p=(e,t)=>{let n=e.split(`
3
+ `),r=[],i=new Map;for(let a of t){if(a.importedFrom!==void 0&&(i.has(a.importedFrom)||i.set(a.importedFrom,f(e,a.importedFrom)),!i.get(a.importedFrom)))continue;let t=new RegExp(a.pattern);for(let e=0;e<n.length;e++){let i=t.exec(n[e]);i!==null&&r.push({line:e+1,path:i[0],message:a.hint})}}return r};function m(n,r,i){if(i===void 0||!t.has(e.extname(r).toLowerCase()))return{text:n,hits:[],findings:[]};let a=[],o=d(u(n,i.literals,a),i.members,a),s=p(o,i.flags);return a.sort((e,t)=>e.line-t.line||l(e.from,t.from)),s.sort((e,t)=>e.line-t.line||l(e.path,t.path)),{text:o,hits:a,findings:s}}function h(t,r,i){if(i===void 0||!n.has(e.extname(r).toLowerCase()))return{text:t,hits:[],findings:[]};let a=[],o=u(t,i.literals,a),s=p(o,i.flags);return a.sort((e,t)=>e.line-t.line||l(e.from,t.from)),s.sort((e,t)=>e.line-t.line||l(e.path,t.path)),{text:o,hits:a,findings:s}}export{t as SOURCE_EXTENSIONS,h as applyMarkup,m as applySource};
@@ -1,2 +1,2 @@
1
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,t)=>d(e)&&i.has(e.type)&&e.callee.type===`Identifier`&&t.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,t)=>{let n=new Map;return f(e,(e,r)=>{if(e.type!==`VariableDeclarator`||e.id.type!==`Identifier`||!b(e.init,t))return;let i=x(r);n.has(i)||n.set(i,new Set),n.get(i)?.add(e.id.name)}),n},C=(e,t,r)=>t.some(t=>(n.has(t.type)||t.type===`Program`)&&r.get(t)?.has(e)===!0),w=(e,t,n,r)=>e.type===`Identifier`?e.name===`theme`&&r.size>0||C(e.name,t,n):b(e,r),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 o=new Set;f(i,e=>{if(e.type===`ImportDeclaration`&&e.source.value.startsWith(`@webority/`))for(let t of e.specifiers){if(t.type!==`ImportSpecifier`)continue;let e=t.imported.type===`StringLiteral`?t.imported.value:t.imported.name;a.has(e)&&o.add(t.local.name)}});let s=S(i,o),d=n.filter(e=>e.kind===`path`||e.kind===`prefix`||e.kind===`gone`).sort((e,t)=>g(t.from).length-g(e.from).length),b=n.filter(e=>e.kind===`kebab`),x=[],C=[],E=[],D=new Set,O=(e,n)=>{let r=`${e}:${n}`;D.has(r)||(D.add(r),E.push({file:t,line:e,path:n,message:u}))},k=(e,n)=>{let i=[],a=e;for(;r.has(a.type);)i.unshift(a),a=a.object;if(!w(a,n,s,o))return;let l=[];for(let e of i){let t=T(e);if(t===void 0)break;l.push(t)}let u=l.length;if(u===0)return;let f=[...l];for(let e of d){let n=g(e.from),r=e.kind===`prefix`&&e.from.endsWith(`.`);if(!(u<n.length||r&&u===n.length)&&n.every((e,t)=>l[t]===e)){if(e.kind===`gone`){E.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`){f=[...g(e.to),...l.slice(n.length)];break}}}for(let e of b){let t=e.under.split(`.`),n=t.length;if(f.length<=n||!t.every((e,t)=>f[t]===e))continue;let r=f[n];Object.hasOwn(e.names,r)&&(f[n]=e.names[r]);for(let e=n+1;e<f.length;e++)/[A-Z]/.test(f[e])&&(f[e]=f[e].replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase())}if(_(f,l))return;let p=f.map((e,t)=>{let n=i[t]?.optional===!0;return c.test(e)?`${n?`?.`:`.`}${e}`:`${n?`?.`:``}["${e}"]`}).join(``);x.push({start:a.end,end:i[u-1].end,text:p}),C.push({line:i[0].property.loc.start.line,from:l.join(`.`),to:f.join(`.`)})};return f(i,(e,t)=>{r.has(e.type)&&!y(e,t)&&k(e,t),e.type===`JSXAttribute`&&e.name.type===`JSXIdentifier`&&l.has(e.name.name)&&O(e.loc.start.line,e.name.name),e.type===`Identifier`&&e.name===`ThemeOverrides`&&O(e.loc.start.line,e.name)}),C.sort((e,t)=>e.line-t.line||v(e.from,t.from)),E.sort((e,t)=>e.line-t.line||v(e.path,t.path)),{text:h(e,x,t),hits:C,findings:E}}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:[]}}function A(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=[],s=new Set;for(let c of n){let n=N(r,c.package);f(r,r=>{if(r.type!==`JSXOpeningElement`)return;let l=P(r.name,n);if(c.components.includes(l))for(let n of r.attributes){if(n.type!==`JSXAttribute`||n.name.type!==`JSXIdentifier`||n.name.name!==c.prop||s.has(n.start))continue;s.add(n.start);let u=n.loc.start.line,d=`${l}.${c.prop}`;if(c.flag){o.push({file:t,line:u,path:d,message:c.flag});continue}if(c.to&&c.to!==c.prop&&r.attributes.some(e=>j(e,c.to))){o.push({file:t,line:u,path:d,message:`${l} already sets ${c.to}; merge ${c.prop} into it by hand`});continue}let f=n.value===null?void 0:O(n.value)?.value??null,p=c.prop,m=f,h=i.length;c.to&&c.to!==c.prop&&(i.push({start:n.name.start,end:n.name.end,text:c.to}),p=c.to);let g=O(n.value);if(c.values&&g!==void 0&&Object.hasOwn(c.values,g.value)){let t=e[g.start];m=c.values[g.value],i.push({start:g.start,end:g.end,text:`${t}${m}${t}`})}i.length!==h&&a.push({line:u,from:M(c.prop,f),to:M(p,m)})}})}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}}var j=(e,t)=>e.type===`JSXAttribute`&&e.name.type===`JSXIdentifier`&&e.name.name===t,M=(e,t)=>t===void 0?e:t===null?`${e}={...}`:`${e}="${t}"`,N=(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}},P=(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 F(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=N(r,s.package);f(r,r=>{if(r.type!==`JSXOpeningElement`)return;let c=P(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 I(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=N(r,e.package);f(r,r=>{if(r.type!==`JSXOpeningElement`)return;let o=P(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{A as applyComponentProps,I as applyPropSplits,F as applyPropValues,k as applyProps,E as applyThemeReads};
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,t)=>d(e)&&i.has(e.type)&&e.callee.type===`Identifier`&&t.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,t)=>{let n=new Map;return f(e,(e,r)=>{if(e.type!==`VariableDeclarator`||e.id.type!==`Identifier`||!b(e.init,t))return;let i=x(r);n.has(i)||n.set(i,new Set),n.get(i)?.add(e.id.name)}),n},C=(e,t,r)=>t.some(t=>(n.has(t.type)||t.type===`Program`)&&r.get(t)?.has(e)===!0),w=(e,t,n,r)=>e.type===`Identifier`?e.name===`theme`&&r.size>0||C(e.name,t,n):b(e,r),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 o=new Set;f(i,e=>{if(e.type===`ImportDeclaration`&&e.source.value.startsWith(`@webority/`))for(let t of e.specifiers){if(t.type!==`ImportSpecifier`)continue;let e=t.imported.type===`StringLiteral`?t.imported.value:t.imported.name;a.has(e)&&o.add(t.local.name)}});let s=S(i,o),d=n.filter(e=>e.kind===`path`||e.kind===`prefix`||e.kind===`gone`).sort((e,t)=>g(t.from).length-g(e.from).length),b=n.filter(e=>e.kind===`kebab`),x=[],C=[],E=[],D=new Set,O=(e,n)=>{let r=`${e}:${n}`;D.has(r)||(D.add(r),E.push({file:t,line:e,path:n,message:u}))},k=(e,n)=>{let i=[],a=e;for(;r.has(a.type);)i.unshift(a),a=a.object;if(!w(a,n,s,o))return;let l=[];for(let e of i){let t=T(e);if(t===void 0)break;l.push(t)}let u=l.length;if(u===0)return;let f=[...l];for(let e of d){let n=g(e.from),r=e.kind===`prefix`&&e.from.endsWith(`.`);if(!(u<n.length||r&&u===n.length)&&n.every((e,t)=>l[t]===e)){if(e.kind===`gone`){E.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`){f=[...g(e.to),...l.slice(n.length)];break}}}for(let e of b){let t=e.under.split(`.`),n=t.length;if(f.length<=n||!t.every((e,t)=>f[t]===e))continue;let r=f[n];Object.hasOwn(e.names,r)&&(f[n]=e.names[r]);for(let e=n+1;e<f.length;e++)/[A-Z]/.test(f[e])&&(f[e]=f[e].replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase())}if(_(f,l))return;let p=f.map((e,t)=>{let n=i[t]?.optional===!0;return c.test(e)?`${n?`?.`:`.`}${e}`:`${n?`?.`:``}["${e}"]`}).join(``);x.push({start:a.end,end:i[u-1].end,text:p}),C.push({line:i[0].property.loc.start.line,from:l.join(`.`),to:f.join(`.`)})};return f(i,(e,t)=>{r.has(e.type)&&!y(e,t)&&k(e,t),e.type===`JSXAttribute`&&e.name.type===`JSXIdentifier`&&l.has(e.name.name)&&O(e.loc.start.line,e.name.name),e.type===`Identifier`&&e.name===`ThemeOverrides`&&O(e.loc.start.line,e.name)}),C.sort((e,t)=>e.line-t.line||v(e.from,t.from)),E.sort((e,t)=>e.line-t.line||v(e.path,t.path)),{text:h(e,x,t),hits:C,findings:E}}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:[]}}function A(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=[],s=new Set;for(let c of n){let n=N(r,c.package);f(r,r=>{if(r.type!==`JSXOpeningElement`)return;let l=P(r.name,n);if(c.components.includes(l))for(let n of r.attributes){if(n.type!==`JSXAttribute`||n.name.type!==`JSXIdentifier`||n.name.name!==c.prop||s.has(n.start))continue;s.add(n.start);let u=n.loc.start.line,d=`${l}.${c.prop}`;if(c.flag&&c.to===void 0&&c.values===void 0){o.push({file:t,line:u,path:d,message:c.flag});continue}if(c.to&&c.to!==c.prop&&r.attributes.some(e=>j(e,c.to))){o.push({file:t,line:u,path:d,message:`${l} already sets ${c.to}; merge ${c.prop} into it by hand`});continue}let f=n.value===null?void 0:O(n.value)?.value??null,p=c.prop,m=f,h=i.length;c.to&&c.to!==c.prop&&(i.push({start:n.name.start,end:n.name.end,text:c.to}),p=c.to);let g=O(n.value);if(c.values&&g!==void 0&&Object.hasOwn(c.values,g.value)){let t=e[g.start];m=c.values[g.value],i.push({start:g.start,end:g.end,text:`${t}${m}${t}`})}c.flag&&g===void 0&&o.push({file:t,line:u,path:d,message:c.flag}),i.length!==h&&a.push({line:u,from:M(c.prop,f),to:M(p,m)})}})}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}}var j=(e,t)=>e.type===`JSXAttribute`&&e.name.type===`JSXIdentifier`&&e.name.name===t,M=(e,t)=>t===void 0?e:t===null?`${e}={...}`:`${e}="${t}"`,N=(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}},P=(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 F(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=N(r,s.package);f(r,r=>{if(r.type!==`JSXOpeningElement`)return;let c=P(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 I(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=N(r,e.package);f(r,r=>{if(r.type!==`JSXOpeningElement`)return;let o=P(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{A as applyComponentProps,h as applyEdits,I as applyPropSplits,F as applyPropValues,k as applyProps,E as applyThemeReads,P as componentOf,N as importedComponents,p as parseSource,m as skipped,O as stringNode,f as visit};
@@ -0,0 +1,3 @@
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
+ `,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}};function u(a,u,d){if(d.length===0)return{text:a,hits:[],findings:[]};let f;try{f=r(a,u)}catch(e){return i(a,u,e)}if(f===null)return{text:a,hits:[],findings:[]};let p=[],m=[],h=[];for(let e of d){let r=n(f,e.package);o(f,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}`,d=s(t.value);if(d!==void 0&&!Object.hasOwn(e.values,d)&&e.keep?.includes(d))continue;if(d===void 0||!Object.hasOwn(e.values,d)){h.push({file:u,line:n,path:r,message:e.flag});continue}let f=Object.entries(e.values[d]).filter(([,e])=>e!==null),g=f.map(([e])=>e).filter(t=>t!==e.prop&&o.has(t));if(g.length>0){h.push({file:u,line:n,path:r,message:`${i} already sets ${g.join(` and `)}; merge ${e.prop} into it by hand`});continue}let _=f.map(([e,t])=>c(e,t)).join(` `),v=f.length===0?l(a,t):{start:t.start,end:t.end};p.push({start:v.start,end:v.end,text:_}),m.push({line:n,from:a.slice(t.start,t.end),to:_})}})}return m.sort((e,t)=>e.line-t.line||(e.from<t.from?-1:+(e.from>t.from))),h.sort((e,t)=>e.line-t.line||(e.path<t.path?-1:+(e.path>t.path))),{text:e(a,p,u),hits:m,findings:h}}export{u as applyValueSplits};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/tokens",
3
- "version": "0.128.0",
3
+ "version": "0.130.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",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.108.0",
2
+ "version": "0.107.0",
3
3
  "css": {
4
4
  "rename": [],
5
5
  "reads": [],