@hazem3500/palette 0.9.131 → 0.9.133
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 +10 -6
- package/dist/adapters/css-variables.js +1 -1
- package/dist/adapters/tailwind.d.ts +1 -1
- package/dist/adapters/tailwind.js +1 -1
- package/dist/anchors.d.ts +2 -1
- package/dist/chunk-3SNXBRAS.js +1 -0
- package/dist/chunk-JWGDIIKJ.js +1 -0
- package/dist/{chunk-UUV356RI.js → chunk-KMRWUNT7.js} +1 -1
- package/dist/{chunk-RAAJF54I.js → chunk-OAGWNW4W.js} +1 -1
- package/dist/{color-editor-I5ELNYPO.js → color-editor-GCCLM3TV.js} +1 -1
- package/dist/design-comment-LHFSWNU7.js +1 -0
- package/dist/{design-export-55QSPEWM.js → design-export-I766FRDX.js} +1 -1
- package/dist/{design-geometry-OXGWR5J2.js → design-geometry-W7PSW5J2.js} +1 -1
- package/dist/design-mode.js +1 -1
- package/dist/design-system.d.ts +1 -1
- package/dist/frame-size-E6OGNHNX.js +1 -0
- package/dist/frame-size.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{inline-text-editor-S4LVCKZL.js → inline-text-editor-5JSAHEHE.js} +1 -1
- package/dist/message-links.d.ts +2 -0
- package/dist/node.mjs +100 -21
- package/dist/open-state.d.ts +7 -0
- package/dist/postgres/011_comment_api_key_name.sql +1 -0
- package/dist/postgres/012_comment_images.sql +25 -0
- package/dist/react-props-panel-P47YFFSU.js +1 -0
- package/dist/react-props-panel.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/review-layer.d.ts +1 -0
- package/dist/server.js +97 -20
- package/dist/setup.js +1 -1
- package/dist/snapshot-CFKV3VWX.js +1 -0
- package/dist/snapshot-annotate-HW4ZWT7T.js +1 -0
- package/dist/snapshot-annotate.d.ts +16 -0
- package/dist/snapshot.d.ts +15 -4
- package/dist/thread-snapshot-2V4AV3UN.js +1 -0
- package/dist/thread-snapshot.d.ts +4 -6
- package/dist/token-adapter.d.ts +1 -0
- package/dist/{token-custom-7MJFPGVB.js → token-custom-CPPHGYMJ.js} +1 -1
- package/dist/{token-page-YQ52JS6G.js → token-page-63C3T4DY.js} +1 -1
- package/dist/{token-picker-HHT4OC3V.js → token-picker-ARVCFUCY.js} +1 -1
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
- package/server/bot-tokens.ts +7 -3
- package/server/index.ts +80 -17
- package/server/migrations/0025_comment_api_key_name.sql +1 -0
- package/server/migrations/0026_comment_images.sql +22 -0
- package/server/setup-client.txt +115 -79
- package/server/snapshots.ts +2 -1
- package/server/tokens.ts +2 -2
- package/src/types.ts +4 -0
- package/dist/chunk-EVRPBA4F.js +0 -1
- package/dist/design-comment-VXRH45UI.js +0 -1
- package/dist/frame-size-EAVSR4SA.js +0 -1
- package/dist/react-props-panel-VON2NO7N.js +0 -1
- package/dist/snapshot-BFHCCGOL.js +0 -1
- package/dist/thread-snapshot-TJHRZZOR.js +0 -1
- /package/dist/{design-panel-DBAUVCIJ.js → design-panel-GU2SWV33.js} +0 -0
package/README.md
CHANGED
|
@@ -363,7 +363,7 @@ const tokens: TailwindToken[] = [
|
|
|
363
363
|
{ path: "radius.md", type: "dimension", class: "rounded-md", properties: ["border-radius"], value: "6px" },
|
|
364
364
|
{ path: "typography.h1", type: "typography", class: "text-h1",
|
|
365
365
|
properties: ["font-size", "line-height", "font-weight"], value: "32px/40px 600" },
|
|
366
|
-
...tailwindSpacing(), // p-*, px-*, …, m-*, gap-* on the 4px scale
|
|
366
|
+
...tailwindSpacing(), // p-*, px-*, …, m-*, gap-*, w-*, h-* on the 4px scale
|
|
367
367
|
];
|
|
368
368
|
|
|
369
369
|
initPalette({ project, design: { tokens: tailwindTokens({ tokens }, { themes: [mode, product] }), themes: [mode, product] } });
|
|
@@ -373,7 +373,7 @@ initPalette({ project, design: { tokens: tailwindTokens({ tokens }, { themes: [m
|
|
|
373
373
|
- `values` keys are option ids (`dark`), `axis=option` pairs (`mode=dark`), or combinations joined with `+` (`track+dark`). The most specific match wins, then `value`.
|
|
374
374
|
- `resolve()` reads base-state classes only; variants such as `hover:` or `md:` are ignored. When classes overlap, the narrower class wins, as in Tailwind (`p-4 px-2` reads `padding-left` from `px-2`). Properties with no table class are reported off-token with their computed value; pass `offToken: [...]` to narrow the list or `false` to turn it off.
|
|
375
375
|
- Previews replace table classes the new class fully covers, keep everything else in place, and stack; undoing restores the original `class` exactly. Classes outside the table, such as `text-[14px]`, are left alone.
|
|
376
|
-
- `tailwindSpacing({ prefix, scale, steps })` narrows the families (`p`, `px`, `py`, `pt`, `pr`, `pb`, `pl`, `m`, `mx`, …, `gap`, `gap-x`, `gap-y`), the pixels per step (default 4), and the steps (default Tailwind's 0 to 96). Paths are `spacing.<class>`, for example `spacing.p-4`.
|
|
376
|
+
- `tailwindSpacing({ prefix, scale, steps })` narrows the families (`p`, `px`, `py`, `pt`, `pr`, `pb`, `pl`, `m`, `mx`, …, `gap`, `gap-x`, `gap-y`, `w`, `h`), the pixels per step (default 4), and the steps (default Tailwind's 0 to 96). Paths are `spacing.<class>`, for example `spacing.p-4`.
|
|
377
377
|
- Tailwind's JIT only emits CSS for classes it finds in source, so a full table can list classes such as `p-9` or `mt-96` that have no rule and preview nothing. `tailwindTokens(table, { onlyGenerated: true })` lists only tokens whose first class has a rule in the page's stylesheets, including rules inside `@media`, `@supports`, `@layer`, `@container`, nested rules and same-origin `@import`. Names are matched exactly as escaped CSS, so `p-1.5`, `w-1/2`, `-mt-4`, `p-[13px]`, `md:p-4` and `!p-4` each need their own rule. The scan runs on the first `list()` and again only when a stylesheet is added, removed, replaced, loads or gains rules, including `adoptedStyleSheets`. With `onlyGenerated`, the adapter also has `subscribe()`: adding, removing, editing or loading a `<style>` or `<link>` refreshes the list in Design mode, including an open picker. Rules added only through `insertRule()` or `adoptedStyleSheets` show with the next such change.
|
|
378
378
|
- Cross-origin sheets: Palette cannot read a cross-origin stylesheet served without CORS, such as a font stylesheet pulled in with `@import url(https://fonts…)`. By default it skips each unreadable sheet or `@import`, assumes it holds no utility CSS, and filters with the rest. It hides nothing while a `<link>` stylesheet is still loading or failed, or when no readable sheet has a style rule. If your utilities themselves come from another origin, pass `onlyGenerated: { strict: true }`, which hides nothing while any sheet is unreadable, or serve that CSS with `crossorigin` on the `<link>` and `Access-Control-Allow-Origin`. `onlyGenerated: true` is the default object.
|
|
379
379
|
- `filter(token)` returning `false` leaves a token out of `list()`, alone or with `onlyGenerated`. Hidden tokens still resolve on elements that already use their class.
|
|
@@ -496,6 +496,10 @@ Tokens start with `palette_pat_` (`komo_pat_` for tokens issued before the renam
|
|
|
496
496
|
| `comments:read` | List and read threads, `palette whoami`. |
|
|
497
497
|
| `comments:write` | Create threads, reply, edit, react, resolve, tag, move. |
|
|
498
498
|
|
|
499
|
+
Comments and replies support Markdown links, bold, emphasis, inline code, and fenced code blocks. Raw HTML is displayed as text.
|
|
500
|
+
|
|
501
|
+
To attach a PNG or WebP (up to 256 KiB) with a token, post the comment first, then send the image as the raw body of `PUT /threads/{threadId}/comments/{commentId}/image` with its image content type. The comment author can upload or replace the image. The authenticated thread response includes the image URL. To add or remove your reaction, send `POST /threads/{threadId}/comments/{commentId}/reactions` with `{"emoji":"👍","active":true}` or `active:false`. Project bot tokens can use both endpoints for the projects they belong to.
|
|
502
|
+
|
|
499
503
|
A token acts as its owner, narrowed by its scopes and project list: it never passes an ownership check or private-project invitation its owner would fail, and it cannot manage tokens, projects, members, or webhooks. Credentials resolve in this order: `PALETTE_TOKEN`, a token saved by `palette login --token`, then a browser login session.
|
|
500
504
|
|
|
501
505
|
**Rotate** by creating a replacement, updating the secret, confirming `palette whoami`, then revoking the old token. Prefer an expiry of 90 days or less. **Revoke** from **Account → API tokens** or `/account`; the token stops working on its next request (HTTP 401), and so does an expired one.
|
|
@@ -635,7 +639,7 @@ Pass these to `initPalette(config)` from `@hazem3500/palette` or `usePalette(con
|
|
|
635
639
|
| `sessionEndpoint` | `string` | `endpoint` | Canonical API identity for trusted gateways to the same service; never share across independent APIs. |
|
|
636
640
|
| `avatar` | `(user: { id, name }) => string \| undefined` | None | Photo URL for signed-in reviewers the server has none for, such as IAP sign-in. HTTPS only; guests keep their initial. |
|
|
637
641
|
| `snapshots` | `{ image?, html?, maxBytes?, redact?(element) }` | Off | Save an image and/or trimmed HTML of the commented element with each new thread. See [Comment snapshots](#comment-snapshots). |
|
|
638
|
-
| `share` | `{ label }` | Off | Let reviewers keep new comments out of a webhook integration, e.g. `{ label: "Post to the GitHub PR" }`. Adds
|
|
642
|
+
| `share` | `{ label }` | Off | Let reviewers keep new comments out of a webhook integration, e.g. `{ label: "Post to the GitHub PR" }`. Adds an account default and a checkbox for each new comment; a kept comment's `comment.created` event carries `share: false`. Needs a server with `config.share` ([NODE.md](NODE.md#keeping-comments-out-of-integrations)). |
|
|
639
643
|
|
|
640
644
|
Google sign-in uses the account photo (`picture`) automatically, loaded from `lh3.googleusercontent.com`. Under a restrictive CSP, allow that host (or your `avatar` host) in `img-src`; blocked or failed photos fall back to the initial.
|
|
641
645
|
|
|
@@ -769,7 +773,7 @@ Worker bindings: `DB` (D1), optional `EDGE_LIMIT` (rate limiter). Variables: `PR
|
|
|
769
773
|
|
|
770
774
|
### Element snapshots
|
|
771
775
|
|
|
772
|
-
A comment can carry a snapshot of its target element: one image (`image/webp` or `image/png`, up to 256 KiB) and one trimmed HTML capture (`text/html`, UTF-8, up to 32 KiB) per thread.
|
|
776
|
+
A comment can carry a snapshot of its target element: one image (`image/webp` or `image/png`, up to 256 KiB) and one trimmed HTML capture (`text/html`, UTF-8, up to 32 KiB) per thread. Element capture is opt-in on the client. Dragging a region in comment mode previews an image of that area unless image capture is disabled. You can attach a PNG, JPEG, or WebP to a new comment and click the image to open a larger preview for marking it up before posting. **Snapshots may contain page content and user data**, so treat them like the comments they belong to.
|
|
773
777
|
|
|
774
778
|
- `POST /threads/:id/snapshot?kind=image|html` takes the raw file with its `Content-Type`, or `multipart/form-data` with `kind` and `file` fields. A new upload replaces the thread's previous snapshot of that kind. Uploads need a session with write access to the project; guests are refused unless the project sets `allowGuestSnapshots`, and then only on their own threads. The thread's author or a signed-in reviewer can replace or `DELETE /threads/:id/snapshot/:kind`.
|
|
775
779
|
- `GET /threads/:id/snapshot/:kind` needs a session, even on link-access projects, and returns `Cache-Control: private`, `X-Content-Type-Options: nosniff` and `Content-Security-Policy: sandbox`. HTML is always served as `text/plain`; show it to agents or in a sandboxed viewer, never as live markup.
|
|
@@ -870,12 +874,12 @@ The `@hazem3500/palette/server` export loads built ESM in Node and includes Work
|
|
|
870
874
|
|
|
871
875
|
### Experimental page-element resize and move
|
|
872
876
|
|
|
873
|
-
|
|
877
|
+
Resize handles and movement are available in Design mode. To turn them off:
|
|
874
878
|
|
|
875
879
|
```ts
|
|
876
880
|
initPalette({
|
|
877
881
|
// ...your existing endpoint/project/repo/branch options
|
|
878
|
-
design: { experimentalGeometry:
|
|
882
|
+
design: { experimentalGeometry: false },
|
|
879
883
|
});
|
|
880
884
|
```
|
|
881
885
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=e=>{let t=e?.cssVariable??(e?.ref?.startsWith("--")?e.ref:void 0);return t&&/^--[\w-]+$/.test(t)?t:void 0};var t=["padding","margin","gap"],r={color:["color",["color","background-color","border-color"],"Color"],spacing:["dimension",t,"Spacing"],radius:["dimension",["border-radius"],"Radius"],text:["dimension",["font-size"],"Font size"],font:["fontFamily",["font-family"],"Font"],leading:["lineHeight",["line-height"],"Line height"],"font-weight":["fontWeight",["font-weight"],"Font weight"]},o=/^(#[0-9a-f]{3,8}|(rgb|hsl|hwb|lab|lch|oklab|oklch|color)a?\(.*\))$/i,l=/^-?\d*\.?\d+(px|rem|em|%|vw|vh|ch)$/,n=(e,t=("object"==typeof window?window:null))=>{let{conditionText:r}=e;return"string"!=typeof r||("media"in e?"function"!=typeof t?.matchMedia||t.matchMedia(r).matches:!!(typeof CSS<"u"&&"supports"in CSS&&e.constructor.name.includes("Supports"))&&CSS.supports(r))},a=/^(:root|html|:host)$/,i=(e,t,r,o)=>{for(let l of Array.from(e))if("selectorText"in l&&l.style){let{selectorText:e,style:n}=l,i=e.split(",").map(e=>e.trim()),s=i.some(e=>a.test(e));if(!s&&!i.some(e=>o.has(e)))continue;for(let e of Array.from(n))e.startsWith("--")&&(s?t:r).set(e,n.getPropertyValue(e).trim())}else"cssRules"in l&&i(l.cssRules,t,r,o)},s=/^(\d{1,3})(\s*,\s*|\s+)(\d{1,3})\2(\d{1,3})$/,c=e=>t=>{let r=document.createElement("span").style;r.color=t;let o=r.color.match(/[\d.]+/g);return o&&o.length>2?o.slice(0,3).map(e=>Math.round(+e)).join(e):t};function p(e,n){let a=e.slice(2),i=Object.keys(r).sort((e,t)=>t.length-e.length).find(e=>a===e||a.startsWith(`${e}-`));if(i){let[e,t,o]=r[i];if("fontFamily"!==e||!/^\d+$/.test(n))return{type:e,properties:t,group:o,ns:i}}return o.test(n)?{type:"color",properties:r.color[1],group:"Color"}:l.test(n)?{type:"dimension",properties:[...t,"border-radius"],group:"Size"}:null}var u=e=>{let t=e.replace(/::?(not|is|where|has)\(([^)]*)\)/g," $2 ");return 1e6*(t.match(/#[\w-]+/g)??[]).length+1e3*(t.match(/\.[\w-]+|\[[^\]]*\]|:(?!:)[\w-]+/g)??[]).length+(t.replace(/#[\w-]+|\.[\w-]+|\[[^\]]*\]|::?[\w-]+/g," ").match(/(^|[\s>+~])[a-z][\w-]*/gi)??[]).length},f={"background-color":["background-color","background"],"border-color":["border-color","border"],padding:["padding"],margin:["margin"],gap:["gap"],"border-radius":["border-radius"],font:["font"]};function d(t={}){let r=t.include??(e=>!e.startsWith("--tw-")),o=t.limit??300,l=t.scopes??{},a=new Map,d=new Map;function h(e={}){let t=new Map,n=new Map,c=new Set(Object.values(e).flatMap(e=>l[e]?[l[e]]:[]));for(let e of Array.from(document.styleSheets))try{i(e.cssRules,t,n,c)}catch{}let u=getComputedStyle(document.documentElement),f=new Map;for(let[e,l]of t){let t=u.getPropertyValue(e).trim(),a=t&&r(e)?p(e,t):null;if(!a||f.size>=o)continue;let i=e.slice(2),{ns:c,...d}=a,h=c?c.length:i.indexOf("-"),m=h>0&&i.length>h?`${i.slice(0,h)}.${i.slice(h+1)}`:i,g="color"===a.type?s.exec(t):null,y=g&&[g[1],g[3],g[4]].map(Number);y?.every(e=>e<256)&&(t=`#${y.map(e=>e.toString(16).padStart(2,"0")).join("")}`),f.set(e,{name:e,path:m,value:t,...d,declared:n.get(e)??l,...y?{channels:g[2].includes(",")?", ":" "}:{}})}return a=f,f}let m=e=>{let t=/^var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)$/.exec(e.trim());return t&&a.has(t[1])?t[1]:null};function g(e,t){let r=e.style,o=f[t]??[t];for(let e of o){let t=r?.getPropertyValue(e);if(t&&"important"!==r.getPropertyPriority(e))return m(t)}let l=null,a=0,i=t=>{for(let r of Array.from(t))if("selectorText"in r&&r.style){let{selectorText:t,style:n}=r;for(let r of t.split(",")){let t=!1;try{t=e.matches(r.trim())}catch{}if(t)for(let e of o){let t=n.getPropertyValue(e);if(!t)continue;let o=(n.getPropertyPriority(e)?1e12:0)+1e3*u(r)+a++;(!l||o>=l.rank)&&(l={rank:o,value:t})}}}else"cssRules"in r&&n(r,e.ownerDocument.defaultView)&&i(r.cssRules)};for(let t of Array.from(e.ownerDocument.styleSheets))try{i(t.cssRules)}catch{}return l?m(l.value):null}function y(e){let t=[...h(e).values()].map(e=>{let t=m(e.declared??"");return{path:e.path,type:e.type,value:e.value,properties:[...e.properties],group:e.group,ref:e.name,cssVariable:e.name,...t&&t!==e.name?{alias:a.get(t).path}:{},...e.channels?{toCss:c(e.channels)}:{}}});return d=new Map(t.map(e=>[e.path,e])),t}return{id:"css-variables",list:y,previewValues:(t,r,o)=>(d.size||y(),function(t,r,o={},l,n=document){let a=[];for(let n of t){let t=r(n.path),i=e(t);if(!t||!i)continue;let s=n.alias?e(r(n.alias)):void 0,c=n.value;try{c=s?`var(${s})`:t.toCss?t.toCss(n.value):n.value}catch{}if(!c||/[{};<]/.test(c))continue;let p=n.theme?.split("+")??[],u=p.flatMap(e=>o[e]?[`:is(${o[e]})`]:[]),f=n.theme?Object.entries(o).filter(([e])=>!p.includes(e)).map(([,e])=>`:not(${e})`):[];n.theme&&!u.length&&!f.length&&n.theme!==l||a.push(`${u.join("")||":root"}${f.join("")}{${i}:${c}!important}`)}if(!a.length)return()=>{};let i=n.createElement("style");return i.dataset.paletteTokenPreview="",i.textContent=a.join(""),(n.head??n.documentElement).append(i),()=>i.remove()}(t,e=>d.get(e),l,r,o?.document)),resolve(e){a.size||h();let t={},r=getComputedStyle(e);for(let o of new Set([...a.values()].flatMap(e=>e.properties))){let l=g(e,o);t[o]=l?{path:a.get(l).path}:{offToken:r.getPropertyValue(o).trim()}}return t},preview(e,t,r){let o=e.style,l=o.getPropertyValue(t),n=o.getPropertyPriority(t);return o.setProperty(t,`var(${r.ref??`--${r.path.replace(".","-")}`})`),()=>{l?o.setProperty(t,l,n):o.removeProperty(t)}},describe(e,t,r,o){let l=`var(${o.ref})`,n="path"in r?[...a.values()].find(e=>e.path===r.path)?.name:void 0;return n?n===o.ref?`Keep ${t}: ${l}`:`Replace var(${n}) with ${l} for ${t}`:`Set ${t} to ${l}`}}}export{d as discoverCssTokens};
|
|
1
|
+
var e=e=>{let t=e?.cssVariable??(e?.ref?.startsWith("--")?e.ref:void 0);return t&&/^--[\w-]+$/.test(t)?t:void 0};var t=["padding","margin","gap","width","height"],r={color:["color",["color","background-color","border-color"],"Color"],spacing:["dimension",t,"Spacing"],radius:["dimension",["border-radius"],"Radius"],text:["dimension",["font-size"],"Font size"],font:["fontFamily",["font-family"],"Font"],leading:["lineHeight",["line-height"],"Line height"],"font-weight":["fontWeight",["font-weight"],"Font weight"]},o=/^(#[0-9a-f]{3,8}|(rgb|hsl|hwb|lab|lch|oklab|oklch|color)a?\(.*\))$/i,l=/^-?\d*\.?\d+(px|rem|em|%|vw|vh|ch)$/,n=(e,t=("object"==typeof window?window:null))=>{let{conditionText:r}=e;return"string"!=typeof r||("media"in e?"function"!=typeof t?.matchMedia||t.matchMedia(r).matches:!!(typeof CSS<"u"&&"supports"in CSS&&e.constructor.name.includes("Supports"))&&CSS.supports(r))},a=/^(:root|html|:host)$/,i=(e,t,r,o)=>{for(let l of Array.from(e))if("selectorText"in l&&l.style){let{selectorText:e,style:n}=l,i=e.split(",").map(e=>e.trim()),s=i.some(e=>a.test(e));if(!s&&!i.some(e=>o.has(e)))continue;for(let e of Array.from(n))e.startsWith("--")&&(s?t:r).set(e,n.getPropertyValue(e).trim())}else"cssRules"in l&&i(l.cssRules,t,r,o)},s=/^(\d{1,3})(\s*,\s*|\s+)(\d{1,3})\2(\d{1,3})$/,c=e=>t=>{let r=document.createElement("span").style;r.color=t;let o=r.color.match(/[\d.]+/g);return o&&o.length>2?o.slice(0,3).map(e=>Math.round(+e)).join(e):t};function p(e,n){let a=e.slice(2),i=Object.keys(r).sort((e,t)=>t.length-e.length).find(e=>a===e||a.startsWith(`${e}-`));if(i){let[e,t,o]=r[i];if("fontFamily"!==e||!/^\d+$/.test(n))return{type:e,properties:t,group:o,ns:i}}return o.test(n)?{type:"color",properties:r.color[1],group:"Color"}:l.test(n)?{type:"dimension",properties:[...t,"border-radius"],group:"Size"}:null}var u=e=>{let t=e.replace(/::?(not|is|where|has)\(([^)]*)\)/g," $2 ");return 1e6*(t.match(/#[\w-]+/g)??[]).length+1e3*(t.match(/\.[\w-]+|\[[^\]]*\]|:(?!:)[\w-]+/g)??[]).length+(t.replace(/#[\w-]+|\.[\w-]+|\[[^\]]*\]|::?[\w-]+/g," ").match(/(^|[\s>+~])[a-z][\w-]*/gi)??[]).length},f={"background-color":["background-color","background"],"border-color":["border-color","border"],padding:["padding"],margin:["margin"],gap:["gap"],"border-radius":["border-radius"],font:["font"]};function d(t={}){let r=t.include??(e=>!e.startsWith("--tw-")),o=t.limit??300,l=t.scopes??{},a=new Map,d=new Map;function h(e={}){let t=new Map,n=new Map,c=new Set(Object.values(e).flatMap(e=>l[e]?[l[e]]:[]));for(let e of Array.from(document.styleSheets))try{i(e.cssRules,t,n,c)}catch{}let u=getComputedStyle(document.documentElement),f=new Map;for(let[e,l]of t){let t=u.getPropertyValue(e).trim(),a=t&&r(e)?p(e,t):null;if(!a||f.size>=o)continue;let i=e.slice(2),{ns:c,...d}=a,h=c?c.length:i.indexOf("-"),m=h>0&&i.length>h?`${i.slice(0,h)}.${i.slice(h+1)}`:i,g="color"===a.type?s.exec(t):null,y=g&&[g[1],g[3],g[4]].map(Number);y?.every(e=>e<256)&&(t=`#${y.map(e=>e.toString(16).padStart(2,"0")).join("")}`),f.set(e,{name:e,path:m,value:t,...d,declared:n.get(e)??l,...y?{channels:g[2].includes(",")?", ":" "}:{}})}return a=f,f}let m=e=>{let t=/^var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)$/.exec(e.trim());return t&&a.has(t[1])?t[1]:null};function g(e,t){let r=e.style,o=f[t]??[t];for(let e of o){let t=r?.getPropertyValue(e);if(t&&"important"!==r.getPropertyPriority(e))return m(t)}let l=null,a=0,i=t=>{for(let r of Array.from(t))if("selectorText"in r&&r.style){let{selectorText:t,style:n}=r;for(let r of t.split(",")){let t=!1;try{t=e.matches(r.trim())}catch{}if(t)for(let e of o){let t=n.getPropertyValue(e);if(!t)continue;let o=(n.getPropertyPriority(e)?1e12:0)+1e3*u(r)+a++;(!l||o>=l.rank)&&(l={rank:o,value:t})}}}else"cssRules"in r&&n(r,e.ownerDocument.defaultView)&&i(r.cssRules)};for(let t of Array.from(e.ownerDocument.styleSheets))try{i(t.cssRules)}catch{}return l?m(l.value):null}function y(e){let t=[...h(e).values()].map(e=>{let t=m(e.declared??"");return{path:e.path,type:e.type,value:e.value,properties:[...e.properties],group:e.group,ref:e.name,cssVariable:e.name,...t&&t!==e.name?{alias:a.get(t).path}:{},...e.channels?{toCss:c(e.channels)}:{}}});return d=new Map(t.map(e=>[e.path,e])),t}return{id:"css-variables",list:y,previewValues:(t,r,o)=>(d.size||y(),function(t,r,o={},l,n=document){let a=[];for(let n of t){let t=r(n.path),i=e(t);if(!t||!i)continue;let s=n.alias?e(r(n.alias)):void 0,c=n.value;try{c=s?`var(${s})`:t.toCss?t.toCss(n.value):n.value}catch{}if(!c||/[{};<]/.test(c))continue;let p=n.theme?.split("+")??[],u=p.flatMap(e=>o[e]?[`:is(${o[e]})`]:[]),f=n.theme?Object.entries(o).filter(([e])=>!p.includes(e)).map(([,e])=>`:not(${e})`):[];n.theme&&!u.length&&!f.length&&n.theme!==l||a.push(`${u.join("")||":root"}${f.join("")}{${i}:${c}!important}`)}if(!a.length)return()=>{};let i=n.createElement("style");return i.dataset.paletteTokenPreview="",i.textContent=a.join(""),(n.head??n.documentElement).append(i),()=>i.remove()}(t,e=>d.get(e),l,r,o?.document)),resolve(e){a.size||h();let t={},r=getComputedStyle(e);for(let o of new Set([...a.values()].flatMap(e=>e.properties))){let l=g(e,o);t[o]=l?{path:a.get(l).path}:{offToken:r.getPropertyValue(o).trim()}}return t},preview(e,t,r){let o=e.style,l=o.getPropertyValue(t),n=o.getPropertyPriority(t);return o.setProperty(t,`var(${r.ref??`--${r.path.replace(".","-")}`})`),()=>{l?o.setProperty(t,l,n):o.removeProperty(t)}},describe(e,t,r,o){let l=`var(${o.ref})`,n="path"in r?[...a.values()].find(e=>e.path===r.path)?.name:void 0;return n?n===o.ref?`Keep ${t}: ${l}`:`Replace var(${n}) with ${l} for ${t}`:`Set ${t} to ${l}`}}}export{d as discoverCssTokens};
|
|
@@ -76,7 +76,7 @@ export declare function tailwindTokens(table: TailwindTable, options?: TailwindT
|
|
|
76
76
|
/** Tailwind's default spacing steps (multiples of the base unit). */
|
|
77
77
|
export declare const defaultSpacingSteps: number[];
|
|
78
78
|
export interface TailwindSpacingOptions {
|
|
79
|
-
/** Utility families; defaults to every padding, margin and
|
|
79
|
+
/** Utility families; defaults to every padding, margin, gap and size family (p, px, ..., m, ..., gap, w, h). */
|
|
80
80
|
prefix?: string[];
|
|
81
81
|
/** Pixels per step; Tailwind's default is 4. */
|
|
82
82
|
scale?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return(e=>"http://www.w3.org/2000/svg"===e?.namespaceURI)(e)||"http://www.w3.org/1999/xhtml"===e?.namespaceURI}var t=new WeakMap;var r=e=>{let t=e?.cssVariable??(e?.ref?.startsWith("--")?e.ref:void 0);return t&&/^--[\w-]+$/.test(t)?t:void 0};var l=/^\s*((?:(?:italic|oblique|normal|small-caps|bold|bolder|lighter|[1-9]00)\s+)*)([+-]?(?:\d*\.)?\d+[a-z%]*)(?:\s*\/\s*((?:\d*\.)?\d+[a-z%]*|normal))?(?:\s+([\s\S]+?))?\s*$/i;var s,n=["top","right","bottom","left"],o={padding:n.map(e=>`padding-${e}`),margin:n.map(e=>`margin-${e}`),gap:["row-gap","column-gap"],"border-radius":["top-left","top-right","bottom-right","bottom-left"].map(e=>`border-${e}-radius`),"border-width":n.map(e=>`border-${e}-width`),"border-color":n.map(e=>`border-${e}-color`)},a=e=>(Array.isArray(e)?e:[e]).flatMap(e=>e.split(/\s+/)).filter(Boolean),i=e=>e.getAttribute("class"),p=e=>e.includes(":")?null:e.replace(/^!|!$/g,""),u=/\.((?:\\[\da-f]{1,6} ?|\\[^]|[\w-]|[^\0-\x7f])+)/gi,c=[new Set,0,!1,!1],d=e=>[...e.styleSheets,...e.adoptedStyleSheets??[]];function
|
|
1
|
+
function e(e){return(e=>"http://www.w3.org/2000/svg"===e?.namespaceURI)(e)||"http://www.w3.org/1999/xhtml"===e?.namespaceURI}var t=new WeakMap;var r=e=>{let t=e?.cssVariable??(e?.ref?.startsWith("--")?e.ref:void 0);return t&&/^--[\w-]+$/.test(t)?t:void 0};var l=/^\s*((?:(?:italic|oblique|normal|small-caps|bold|bolder|lighter|[1-9]00)\s+)*)([+-]?(?:\d*\.)?\d+[a-z%]*)(?:\s*\/\s*((?:\d*\.)?\d+[a-z%]*|normal))?(?:\s+([\s\S]+?))?\s*$/i;var s,n=["top","right","bottom","left"],o={padding:n.map(e=>`padding-${e}`),margin:n.map(e=>`margin-${e}`),gap:["row-gap","column-gap"],"border-radius":["top-left","top-right","bottom-right","bottom-left"].map(e=>`border-${e}-radius`),"border-width":n.map(e=>`border-${e}-width`),"border-color":n.map(e=>`border-${e}-color`)},a=e=>(Array.isArray(e)?e:[e]).flatMap(e=>e.split(/\s+/)).filter(Boolean),i=e=>e.getAttribute("class"),p=e=>e.includes(":")?null:e.replace(/^!|!$/g,""),u=/\.((?:\\[\da-f]{1,6} ?|\\[^]|[\w-]|[^\0-\x7f])+)/gi,c=[new Set,0,!1,!1],d=e=>[...e.styleSheets,...e.adoptedStyleSheets??[]];function g(e,t=d(e)){let r=[...e.querySelectorAll("link[rel~=stylesheet]:not([disabled])")].map(e=>e.sheet);for(let e of t){let t;try{t=e.cssRules.length}catch{}r.push(e,t)}return r}var f=(e,t)=>e.length===t.length&&e.every((e,r)=>e===t[r]),y=e=>/^(style|link)$/i.test(e?.nodeName??""),h=e=>y(e.target)||y(e.target.parentNode)||[...e.addedNodes,...e.removedNodes].some(e=>y(e)||!!e.querySelector?.("style,link"));function m(e,t){let r=t?.document??document,l=g(r),s=()=>{let t=g(r);f(t,l)||(l=t,e())},n=new MutationObserver(e=>e.some(h)&&s()),o=new AbortController;n.observe(r,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["disabled","media","rel","href"]});for(let e of["load","error"])r.addEventListener(e,s,{capture:!0,signal:o.signal});return()=>{n.disconnect(),o.abort()}}function b(e,t){let r=CSS.escape(t),l=e=>e===r||e===`\\!${r}`||e===`${r}\\!`||e.endsWith(`\\:${r}`)||e.endsWith(`\\:\\!${r}`),s=[],n=e=>{let t;try{t=e()}catch{return}for(let e of t)null!=e.selectorText&&[...e.selectorText.matchAll(u)].some(e=>l(e[1]))&&s.push(e),e.cssRules&&n(()=>e.cssRules),"styleSheet"in e&&n(()=>e.styleSheet.cssRules)};for(let t of d(e))n(()=>t.cssRules);return s}function v(e,t){if("typography"===e.token.type){let e=function(e){let t=l.exec(e);if(!t)return;let r=t[1].trim().split(/\s+/).filter(Boolean);return{style:r.filter(e=>/^(italic|oblique|small-caps)$/i.test(e)).join(" "),weight:r.find(e=>/^(bold|bolder|lighter|[1-9]00)$/i.test(e))??"",size:t[2],lineHeight:t[3]??"",family:t[4]??""}}(t);return e?[["font-style",e.style],["font-weight",e.weight],["font-size",e.size],["line-height",e.lineHeight],["font-family",e.family]].flatMap(([e,t])=>t?[[e,t,!0]]:[]):[]}return[...e.covers].map(e=>[e,t,!1])}function w(e,t={}){let r,l=0;for(let[s,n]of Object.entries(e.values??{})){let e=s.split("+");e.every(e=>{let[r,l]=e.split("=");return void 0===l?Object.values(t).includes(r):t[r]===l})&&e.length>l&&([r,l]=[n,e.length])}return r??e.value??""}function k(l,n={}){let y=l.tokens.map(e=>({token:e,classes:a(e.class),covers:new Set(e.properties.flatMap(e=>[e,...o[e]??[]]))})),h=new Map;for(let e of y)for(let t of e.classes)h.set(t,e);let k=new Map(y.map(e=>[e.token.path,e])),P=!1===n.offToken?[]:n.offToken??[...new Set(l.tokens.flatMap(e=>e.properties))],$=new WeakMap,S=e=>(e??"").split(/\s+/).flatMap(e=>{let t=p(e),r=t?h.get(t):void 0;return r?[{name:e,entry:r}]:[]});function x(e,t){if(!t.stack.length)return null===t.original?e.removeAttribute("class"):e.setAttribute("class",t.original),void $.delete(e);e.setAttribute("class",t.stack.reduce((e,t)=>function(e,t,r){let l=e.split(/\s+/).filter(Boolean),s=r.classes[0],n=-1,a=l.filter((e,l)=>{let s=p(e),a=s?h.get(s):void 0,i=!!a&&(a===r||[...a.covers].every(e=>r.covers.has(e))&&(a.covers.has(t)||(o[t]??[]).some(e=>a.covers.has(e))));return i&&n<0&&(n=l),!i}),i=l.slice(0,n<0?l.length:n).filter(e=>a.includes(e)).length;return a.splice(i,0,s),a.join(" ")}(e,t.property,t.entry),t.original??""))}return{id:"tailwind",list(e,t){let r=e??Object.fromEntries((n.themes??[]).map(e=>[e.id,e.current()])),l=n.onlyGenerated?function(e,t){let r=d(t),l=g(t,r);if(!s||!f(l,s)){s=l,c=[new Set,0,!1,l.includes(null)];let e=t=>{let r;try{r=t()}catch{return void(c[2]=!0)}for(let t of r){if(null!=t.selectorText){c[1]++;for(let e of t.selectorText.matchAll(u))c[0].add(e[1])}t.cssRules&&e(()=>t.cssRules),"styleSheet"in t&&e(()=>t.styleSheet.cssRules)}};for(let t of r)e(()=>t.cssRules)}return c[3]||!c[1]||e&&c[2]?null:c[0]}(!0!==n.onlyGenerated&&!!n.onlyGenerated.strict,t?.document??document):null;return y.filter(({token:e,classes:t})=>(!l||l.has(CSS.escape(t[0])))&&(!n.filter||n.filter(e))).map(({token:e,classes:t})=>({path:e.path,type:e.type,value:w(e,r),properties:[...e.properties],ref:t[0],...e.label?{label:e.label}:{},...e.group?{group:e.group}:{},...e.description?{description:e.description}:{},...e.states?{states:[...e.states]}:{},...e.cssVariable?{cssVariable:e.cssVariable}:{},...e.toCss?{toCss:e.toCss}:{}}))},previewValues(e,t,l){let s=l?.document??document,o=function(e,t,l={},s,n=document){let o=[];for(let n of e){let e=t(n.path),a=r(e);if(!e||!a)continue;let i=n.alias?r(t(n.alias)):void 0,p=n.value;try{p=i?`var(${i})`:e.toCss?e.toCss(n.value):n.value}catch{}if(!p||/[{};<]/.test(p))continue;let u=n.theme?.split("+")??[],c=u.flatMap(e=>l[e]?[`:is(${l[e]})`]:[]),d=n.theme?Object.entries(l).filter(([e])=>!u.includes(e)).map(([,e])=>`:not(${e})`):[];n.theme&&!c.length&&!d.length&&n.theme!==s||o.push(`${c.join("")||":root"}${d.join("")}{${a}:${p}!important}`)}if(!o.length)return()=>{};let a=n.createElement("style");return a.dataset.paletteTokenPreview="",a.textContent=o.join(""),(n.head??n.documentElement).append(a),()=>a.remove()}(e,e=>k.get(e)?.token,n.scopes,t,s),a=function(e,t,r,l){let s=[];for(let n of e){let e=t(n.path);if(!e||e.token.cssVariable||/[{};<]/.test(n.value)||n.theme&&n.theme!==r)continue;let o=v(e,n.value);if(o.length)for(let t of b(l,e.classes[0]))for(let[e,r,l]of o){let n="box-shadow"===e&&t.style.getPropertyValue("--tw-shadow")?"--tw-shadow":e,o=t.style.getPropertyValue(n);if(!o&&!l)continue;let a=t.style.getPropertyPriority(n);t.style.setProperty(n,r,a),s.push(()=>o?t.style.setProperty(n,o,a):t.style.removeProperty(n))}}return()=>{for(let e of s.reverse())e()}}(e,e=>k.get(e),t,s);return()=>{a(),o()}},...n.onlyGenerated?{subscribe:m}:{},resolve(t){let r,l={},s=function(e){let t=new Map;for(let r of S(e))for(let e of r.entry.covers){let l=t.get(e);(!l||r.entry.covers.size<=l.entry.covers.size)&&t.set(e,r)}for(let[e,r]of t)o[e]?.some(e=>t.get(e)?.entry!==r.entry)&&t.delete(e);return t}(i(t));if(e(t)){for(let[e,r]of s){let l=t.style.getPropertyValue(e),n=r.name.startsWith("!")||r.name.endsWith("!");l&&(!n||"important"===t.style.getPropertyPriority(e))&&s.delete(e)}for(let[e,t]of s)o[e]?.some(e=>s.get(e)?.entry!==t.entry)&&s.delete(e)}for(let[e,t]of s)l[e]={path:t.entry.token.path};for(let e of P){if(s.has(e)||o[e]?.some(e=>s.has(e)))continue;r??=getComputedStyle(t);let n=r.getPropertyValue(e);n&&(l[e]={offToken:n})}return l},preview(r,l,s){let n=k.get(s.path);if(!n)return()=>{};let o=$.get(r)??{original:i(r),stack:[],inline:new Map};$.set(r,o),e(r)&&(o.inline.has(l)||o.inline.set(l,function(e,r){let l=e.getAttribute("style"),s=e.style.cssText,n=e.style.getPropertyValue(r),o=e.style.getPropertyPriority(r),a=getComputedStyle(e).getPropertyValue(r).trim(),i=t=>{let l=e.ownerDocument.createElement("span").style;return l.cssText=t,l.setProperty(r,""),l.cssText},p=i(s),u={value:n,priority:o,computed:a,absent:null===l,restore(){t.get(e)?.push(()=>{e.style.getPropertyValue(r)===n&&e.style.getPropertyPriority(r)===o&&u.restore()}),i(e.style.cssText)===p?null===l?(e.getAttribute("style"),e.removeAttribute("style")):e.setAttribute("style",l):(e.style.setProperty(r,n,o),null===l&&!e.style.length&&function(e){e.style.length||(e.getAttribute("style"),e.removeAttribute("style"))}(e))}};return u}(r,l)),r.style.setProperty(l,""));let a={property:l,entry:n};return o.stack.push(a),x(r,o),()=>{let e=o.stack.indexOf(a);e<0||(o.stack.splice(e,1),x(r,o),o.stack.some(e=>e.property===l)||(o.inline.get(l)?.restore(),o.inline.delete(l)))}},describe(e,t,r,l){let s=k.get(l.path)?.classes[0]??l.ref??l.path;if("path"in r){let t=k.get(r.path),l=$.get(e)?.original??i(e),n=S(l).find(e=>e.entry===t)?.name??t?.classes[0]??r.path;return n===s?`Keep class "${s}"`:`Replace class "${n}" with "${s}"`}return`Add class "${s}"`}}}var P={p:["Padding",["padding"]],px:["Padding",["padding-left","padding-right"]],py:["Padding",["padding-top","padding-bottom"]],pt:["Padding",["padding-top"]],pr:["Padding",["padding-right"]],pb:["Padding",["padding-bottom"]],pl:["Padding",["padding-left"]],m:["Margin",["margin"]],mx:["Margin",["margin-left","margin-right"]],my:["Margin",["margin-top","margin-bottom"]],mt:["Margin",["margin-top"]],mr:["Margin",["margin-right"]],mb:["Margin",["margin-bottom"]],ml:["Margin",["margin-left"]],gap:["Gap",["gap"]],"gap-x":["Gap",["column-gap"]],"gap-y":["Gap",["row-gap"]],w:["Size",["width"]],h:["Size",["height"]]},$=[0,.5,1,1.5,2,2.5,3,3.5,4,5,6,7,8,9,10,11,12,14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96];function S(e={}){let t=e.scale??4,r=e.steps??$;return(e.prefix??Object.keys(P)).flatMap(e=>{let l=P[e];if(!l)throw new Error(`Palette: unknown spacing prefix "${e}"`);return r.map(r=>{let s=`${e}-${r}`;return{path:`spacing.${s}`,type:"dimension",class:s,properties:l[1],value:r*t+"px",group:l[0],label:s}})})}export{$ as defaultSpacingSteps,S as tailwindSpacing,k as tailwindTokens,w as tokenValue};
|
package/dist/anchors.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Anchor } from "./types.js";
|
|
2
|
+
export declare const reviewOverlay = "dialog,[role=dialog],[role=alertdialog],[popover],[data-radix-popper-content-wrapper],[role=menu],[role=listbox]";
|
|
2
3
|
/** Prefer a persistent comment owner without changing precise DOM anchor capture. */
|
|
3
4
|
export declare function commentAnchorTarget(element: Element, root: Element, resolve?: (element: Element) => Element | undefined): Element;
|
|
4
5
|
export declare function captureAnchor(element: Element, start: {
|
|
@@ -7,7 +8,7 @@ export declare function captureAnchor(element: Element, start: {
|
|
|
7
8
|
}, end: {
|
|
8
9
|
x: number;
|
|
9
10
|
y: number;
|
|
10
|
-
}, source?: string | ((element: Element) => string | undefined)): Anchor;
|
|
11
|
+
}, source?: string | ((element: Element) => string | undefined), withinTarget?: boolean): Anchor;
|
|
11
12
|
type Search = (scope: Element, anchor: Anchor, scoped: boolean) => Element[];
|
|
12
13
|
export declare function resolveAnchor(anchor: Anchor, target?: Element | null, find?: Search): Element | null;
|
|
13
14
|
export declare function locateAnchor(anchor: Anchor, target?: Element | null): {
|