@hazem3500/komo 0.9.38 → 0.9.39
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 +2 -0
- package/dist/chunk-DOCZLYPK.js +1 -0
- package/dist/{chunk-HHOQUW5B.js → chunk-L7GUPLCL.js} +1 -1
- package/dist/design-comment-GNLTLD32.js +1 -0
- package/dist/design-mode.js +1 -1
- package/dist/design-system.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/{inline-text-editor-ADEGBENA.js → inline-text-editor-5FFLOKZP.js} +1 -1
- package/dist/node.mjs +1 -1
- package/dist/react-props-panel-VPTKEFYK.js +1 -0
- package/dist/react.js +1 -1
- package/dist/server.js +1 -1
- package/dist/setup.js +1 -1
- package/dist/token-adapter.d.ts +1 -0
- package/dist/token-picker-LEZVMSHT.js +1 -0
- package/package.json +1 -1
- package/server/setup-client.txt +35 -35
- package/dist/chunk-CIOHAE5J.js +0 -1
- package/dist/design-comment-BYUC2WXI.js +0 -1
- package/dist/react-props-panel-5VXPVY3H.js +0 -1
- package/dist/token-picker-QETCH45O.js +0 -1
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 Map,o=new Map,a=new WeakMap,i=new WeakMap,s=new Map,l=new WeakMap,f=!1;function u(e,t){let r=o.get(e);r?.delete(t),r?.size||o.delete(e)}function p(t,s,l,f,u){let p=a.get(t);if(p||a.set(t,p=new Map),(!p.has(s)||!n.has(t)&&!o.has(t))&&(p.set(s,l),r(t))){let r=i.get(t);r||i.set(t,r=new Map);let n=e(t,s),o=!!n.value&&$(n.value)===$(n.computed),a=r.get(s);if(a?.adapter===f)a.original=n,a.concrete=o;else{let e={adapter:f,original:n,concrete:o,style:n,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&&$(e.token.value)!==$(r.value)&&t.style.setProperty(s,e.token.value,r.priority)}},r.set(s,e)}}return g(t,f,u),p.get(s)}function c(e,t){return e?a.get(e)?.get(t):void 0}function g(e,t,r,n){let o=n&&new Set(n);for(let[n,a]of i.get(e)??[]){if(a.adapter!==t)continue;let i=c(e,n);a.token=i&&"path"in i?r.find(e=>e.path===i.path):void 0,a.token&&o?.has(n)&&a.style.restore()}}function d(e,t,r){if(o.get(e)?.has(t))return{offToken:getComputedStyle(e).getPropertyValue(t).trim()};let n=A(e,t);return n?{path:n.path}:r}function h(e,t){if(!a.get(e)?.has(t))return;let r=o.get(e),n=r?.has(t)??!1,i=a.get(e)?.get(t),s=!!A(e,t)||!!i&&"path"in i;return r||o.set(e,r=new Set),r.add(t),{priority:"important",...!n&&s?{undo:()=>{u(e,t),f||(L(!0),L(!1))}}:{}}}function m(e,t){return i.get(e)?.get(t)?.style??n.get(e)?.find(e=>e.property===t)?.inline}function y(e){let t={};for(let r of e?.themes??[])try{t[r.id]=r.current()}catch{}return t}function v(e,t,r,n){if(n.aborted||!e?.themes?.length)return;let o=JSON.stringify(y(e)),a=()=>{let t=JSON.stringify(y(e));t===o||n.aborted||(o=t,r())},i=[],s=!1;for(let t of e.themes)try{t.subscribe?i.push(t.subscribe(a)):s=!0}catch{s=!0}let l=s?new MutationObserver(a):void 0;l?.observe(t.documentElement,{attributes:!0}),t.body&&l?.observe(t.body,{attributes:!0}),n.addEventListener("abort",()=>{l?.disconnect();for(let e of i)e()},{once:!0})}function k(e,t={}){let r=l.get(e);r||l.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 b(e,t){return Promise.resolve().then(()=>e.resolve(t)).then(e=>e??{},()=>({}))}function w(e,t){return e.filter(e=>e.properties?.includes(t))}function $(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,i,s=1]=t.map((e,t)=>t>2?+e.toFixed(2):Math.round(e));return 1===s?`rgb(${o},${a},${i})`:`rgba(${o},${a},${i},${s})`}function M(e,t){let r=$(t);return r?e.find(e=>"string"==typeof e.value&&$(e.value)===r):void 0}function S(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 O(){let e=document.createElement("span");return e.className="design-token-off",e.setAttribute("role","img"),e}function P(e,t,r){e.title=`Not from a token · ${t||"unset"}${r?` · matches ${S(r)}`:""}`,e.setAttribute("aria-label",e.title)}function T(n,o,a,i){let s=r(o)?e(o,a):void 0;try{r(o)&&o.style.setProperty(a,"");let e=n.preview?n.preview(o,a,i):t(o,a,i.value),l=!0;return()=>{l&&(l=!1,e?.(),s?.restore())}}catch{throw s?.restore(),new Error("This token could not be previewed.")}}function A(e,t){if(!o.get(e)?.has(t))return[...n.get(e)??[]].reverse().find(e=>e.property===t)?.token}function E(t,a,i,s,l,f){let p=n.get(a);p||n.set(a,p=[]);let c=p.find(e=>e.property===i),g=r(a)?e(a,i):void 0,d=o.get(a)?.has(i)??!1,h=T(t,a,i,s);return u(a,i),p.push({adapter:t,property:i,token:s,from:c?.from??l,fromToken:c?c.fromToken:f,undo:h,inline:g,customBefore:d}),()=>N(a)}function N(e){let t=n.get(e),r=t?.pop();if(r?.undo(),r?.customBefore){let t=o.get(e);t||o.set(e,t=new Set),t.add(r.property)}else r&&u(e,r.property);t&&!t.length&&n.delete(e)}function x(e){return!!n.get(e)?.length}function J(e){return!!o.get(e)?.size}function W(e){for(;n.has(e);)N(e);o.delete(e)}function B(){for(let e of[...n.keys()])W(e);o.clear(),s.clear()}function z(e){return[...new Set(n.get(e)?.map(e=>e.property))].filter(t=>!o.get(e)?.has(t))}function L(t){if(t!==f){f=t,t&&(s=new Map([...o].flatMap(([t,n])=>r(t)?[[t,new Map([...n].map(r=>[r,e(t,r)]))]]:[])));for(let[o,a]of n)if(t)for(let e of[...a].reverse())e.undo();else for(let t of a)t.customBefore&&t.inline?.restore(),r(o)&&(t.inline=e(o,t.property)),t.undo=T(t.adapter,o,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=f;r||L(!0);for(let r of new Set([...n.keys(),...o.keys()])){let a=[...(n.get(r)??[]).filter(t=>t.adapter===e).map(e=>e.property),...o.get(r)??[]];g(r,e,t,a)}for(let r of n.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 a of function(e){let t=new Map;for(let r of n.get(e)??[])t.set(r.property,r);return[...t.values()].filter(t=>!(o.get(e)?.has(t.property)||"path"in t.from&&t.from.path===t.token.path))}(e)){r.add(a.adapter.id);let n="path"in a.from?`${a.fromToken?.value?`${a.fromToken.value} `:""}[${a.from.path}]`:a.from.offToken||"(unset)";t.push(`Element ${a.property}: ${n} → ${a.token.value} [${a.token.path}]`);let o=D(e,a);o&&t.push(`Apply: ${o}`)}if(t.length)return["Proposed design-token changes (preview only)",...t,`Token adapter: ${[...r].join(", ")}`].join("\n")}export{p as a,c as b,g as c,d,h as e,m as f,y as g,v as h,k as i,b as j,w as k,M as l,S as m,j as n,O as o,P as p,T as q,A as r,E as s,x as t,J as u,W as v,B as w,z as x,L as y,C as z,F as A};
|