@hazem3500/komo 0.9.38 → 0.9.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -154,6 +154,8 @@ In Design mode, each style field of the picked element:
154
154
 
155
155
  `list()` and `resolve()` may return promises; the panel renders first and the token controls join when they resolve. `list()` is called once per theme state. A comment on a token swap records `Element color: #6b6b6b [color.text.secondary] → #1f1f1f [color.text.primary]`, followed by your `describe()` text on an `Apply:` line.
156
156
 
157
+ Returning `{ path: "tone.base" }` declares a semantic binding, including when the host renders that token as a concrete inline value. Its Before/Undo baseline follows the current theme's resolved token value; existing classes, CSS-variable references, declaration priorities and unrelated styles are preserved. Return `{ offToken: value }` for a genuine custom literal, even if it happens to equal a token. Supply current resolved values through `list(theme)` and notify subscribers after applying a theme change.
158
+
157
159
  Writing an adapter for utility classes:
158
160
 
159
161
  ```ts
@@ -0,0 +1 @@
1
+ import{e,g as t}from"./chunk-WNJLJD4A.js";import{a as r}from"./chunk-RPY7OOOR.js";var n=new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen transparent".split(" ")),o=new Map,a=new Map,l=new WeakMap,i=new WeakMap,s=new Map,u=new WeakMap,p=!1;function d(e,t){let r=a.get(e);r?.delete(t),r?.size||a.delete(e)}function f(t,s,u,p,d){let f=l.get(t);if(f||l.set(t,f=new Map),(!f.has(s)||!o.has(t)&&!a.has(t))&&(f.set(s,u),r(t))){let r=i.get(t);r||i.set(t,r=new Map);let o=e(t,s),a=o.value.trim().toLowerCase(),l=/^(?:inherit|initial|unset|revert(?:-layer)?|currentcolor|context-fill|context-stroke)$|%|\b(?:var|env|attr|calc|min|max|clamp|color-mix|light-dark|anchor|anchor-size)\(|\(\s*from\b|\d(?:r?(?:em|ex|ch|cap|ic|lh)|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max))\b/.test(a),u=!!a&&!l&&(n.has(a)||M(a)===M(o.computed)),d=r.get(s);if(d?.adapter===p)d.original=o,d.concrete=u;else{let e={adapter:p,original:o,concrete:u,style:o,token:void 0};e.style={get value(){let r=e.original;if(!e.concrete||!e.token)return r.value;let n=t.ownerDocument.createElement("span").style;return n.setProperty(s,e.token.value),n.getPropertyValue(s)||r.value},get priority(){return e.original.priority},get absent(){return e.original.absent},get computed(){return e.token?.value??e.original.computed},restore(){let r=e.original;r.restore(),e.concrete&&e.token&&M(e.token.value)!==M(r.value)&&t.style.setProperty(s,e.token.value,r.priority)}},r.set(s,e)}}return c(t,p,d),f.get(s)}function g(e,t){return e?l.get(e)?.get(t):void 0}function c(e,t,r,n){let o=n&&new Set(n);for(let[n,a]of i.get(e)??[]){if(a.adapter!==t)continue;let l=g(e,n);a.token=l&&"path"in l?r.find(e=>e.path===l.path):void 0,a.token&&o?.has(n)&&a.style.restore()}}function h(e,t,r){if(a.get(e)?.has(t))return{offToken:getComputedStyle(e).getPropertyValue(t).trim()};let n=T(e,t);return n?{path:n.path}:r}function m(e,t){if(!l.get(e)?.has(t))return;let r=a.get(e),n=r?.has(t)??!1,o=l.get(e)?.get(t),i=!!T(e,t)||!!o&&"path"in o;return r||a.set(e,r=new Set),r.add(t),{priority:"important",...!n&&i?{undo:()=>{d(e,t),p||(L(!0),L(!1))}}:{}}}function y(e,t){return i.get(e)?.get(t)?.style??o.get(e)?.find(e=>e.property===t)?.inline}function k(e){let t={};for(let r of e?.themes??[])try{t[r.id]=r.current()}catch{}return t}function b(e,t,r,n){if(n.aborted||!e?.themes?.length)return;let o=JSON.stringify(k(e)),a=()=>{let t=JSON.stringify(k(e));t===o||n.aborted||(o=t,r())},l=[],i=!1;for(let t of e.themes)try{t.subscribe?l.push(t.subscribe(a)):i=!0}catch{i=!0}let s=i?new MutationObserver(a):void 0;s?.observe(t.documentElement,{attributes:!0}),t.body&&s?.observe(t.body,{attributes:!0}),n.addEventListener("abort",()=>{s?.disconnect();for(let e of l)e()},{once:!0})}function v(e,t={}){let r=u.get(e);r||u.set(e,r=new Map);let n=JSON.stringify(Object.entries(t).sort()),o=r.get(n);return o||(o=Promise.resolve().then(()=>e.list(Object.keys(t).length?t:void 0)).then(e=>Array.isArray(e)?e.filter(e=>e&&"string"==typeof e.path):[]),o.catch(()=>r.delete(n)),r.set(n,o)),o}function w(e,t){return Promise.resolve().then(()=>e.resolve(t)).then(e=>e??{},()=>({}))}function $(e,t){return e.filter(e=>e.properties?.includes(t))}function M(e){let t,r=e.trim().toLowerCase().replace(/\s+/g," "),n=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/.exec(r)?.[1];if(n)t=(n.length<5?[...n].map(e=>e+e).join(""):n).match(/../g).map((e,t)=>parseInt(e,16)/(t>2?255:1));else{let e=/^rgba?\(([^)]*)\)$/.exec(r)?.[1].split(/\s*[,/]\s*|\s+/);e&&(3===e.length||4===e.length)&&e.every(e=>/^[\d.]+%?$/.test(e))&&(t=e.map((e,t)=>parseFloat(e)*(e.endsWith("%")?t>2?.01:2.55:1)))}if(!t)return r.replace(/\s*,\s*/g,",");let[o,a,l,i=1]=t.map((e,t)=>t>2?+e.toFixed(2):Math.round(e));return 1===i?`rgb(${o},${a},${l})`:`rgba(${o},${a},${l},${i})`}function S(e,t){let r=M(t);return r?e.find(e=>"string"==typeof e.value&&M(e.value)===r):void 0}function x(e){return e.label||e.path}function j(e,t=e.value,r){return[e.path,e.ref,t,r,e.states?.length?`States: ${e.states.join(", ")}`:"",e.description].filter(Boolean).join(" · ")}function q(){let e=document.createElement("span");return e.className="design-token-off",e.setAttribute("role","img"),e}function O(e,t,r){e.title=`Not from a token · ${t||"unset"}${r?` · matches ${x(r)}`:""}`,e.setAttribute("aria-label",e.title)}function P(n,o,a,l){let i=r(o)?e(o,a):void 0;try{r(o)&&o.style.setProperty(a,"");let e=n.preview?n.preview(o,a,l):t(o,a,l.value),s=!0;return()=>{s&&(s=!1,e?.(),i?.restore())}}catch{throw i?.restore(),new Error("This token could not be previewed.")}}function T(e,t){if(!a.get(e)?.has(t))return[...o.get(e)??[]].reverse().find(e=>e.property===t)?.token}function A(t,n,l,i,s,u){let p=o.get(n);p||o.set(n,p=[]);let f=p.find(e=>e.property===l),g=r(n)?e(n,l):void 0,c=a.get(n)?.has(l)??!1,h=P(t,n,l,i);return d(n,l),p.push({adapter:t,property:l,token:i,from:f?.from??s,fromToken:f?f.fromToken:u,undo:h,inline:g,customBefore:c}),()=>E(n)}function E(e){let t=o.get(e),r=t?.pop();if(r?.undo(),r?.customBefore){let t=a.get(e);t||a.set(e,t=new Set),t.add(r.property)}else r&&d(e,r.property);t&&!t.length&&o.delete(e)}function N(e){return!!o.get(e)?.length}function z(e){return!!a.get(e)?.size}function J(e){for(;o.has(e);)E(e);a.delete(e)}function W(){for(let e of[...o.keys()])J(e);a.clear(),s.clear()}function B(e){return[...new Set(o.get(e)?.map(e=>e.property))].filter(t=>!a.get(e)?.has(t))}function L(t){if(t!==p){p=t,t&&(s=new Map([...a].flatMap(([t,n])=>r(t)?[[t,new Map([...n].map(r=>[r,e(t,r)]))]]:[])));for(let[n,a]of o)if(t)for(let e of[...a].reverse())e.undo();else for(let t of a)t.customBefore&&t.inline?.restore(),r(n)&&(t.inline=e(n,t.property)),t.undo=P(t.adapter,n,t.property,t.token);if(!t){for(let e of s.values())for(let t of e.values())t.restore();s.clear()}}}function C(e,t){let r=p;r||L(!0);for(let r of new Set([...o.keys(),...a.keys()])){let n=[...(o.get(r)??[]).filter(t=>t.adapter===e).map(e=>e.property),...a.get(r)??[]];c(r,e,t,n)}for(let r of o.values())for(let n of r)n.adapter===e&&(n.token=t.find(e=>e.path===n.token.path)??n.token,"path"in n.from&&(n.fromToken=t.find(e=>e.path===n.from.path)));r||L(!1)}function D(e,t){try{let r=t.adapter.describe?.(e,t.property,t.from,t.token);return r?String(r).replace(/\s+/g," ").replace(/→/g,"->").trim().slice(0,300):void 0}catch{return}}function F(e){let t=[],r=new Set;for(let n of function(e){let t=new Map;for(let r of o.get(e)??[])t.set(r.property,r);return[...t.values()].filter(t=>!(a.get(e)?.has(t.property)||"path"in t.from&&t.from.path===t.token.path))}(e)){r.add(n.adapter.id);let o="path"in n.from?`${n.fromToken?.value?`${n.fromToken.value} `:""}[${n.from.path}]`:n.from.offToken||"(unset)";t.push(`Element ${n.property}: ${o} → ${n.token.value} [${n.token.path}]`);let a=D(e,n);a&&t.push(`Apply: ${a}`)}if(t.length)return["Proposed design-token changes (preview only)",...t,`Token adapter: ${[...r].join(", ")}`].join("\n")}export{f as a,g as b,c,h as d,m as e,y as f,k as g,b as h,v as i,w as j,$ as k,S as l,x as m,j as n,q as o,O as p,P as q,T as r,A as s,N as t,z as u,J as v,W as w,B as x,L as y,C as z,F as A};