@hazem3500/palette 0.9.132 → 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/dist/anchors.d.ts +2 -1
- package/dist/chunk-3SNXBRAS.js +1 -0
- package/dist/chunk-JWGDIIKJ.js +1 -0
- package/dist/index.js +1 -1
- package/dist/node.mjs +1 -1
- package/dist/react.js +1 -1
- package/dist/review-layer.d.ts +1 -0
- package/dist/server.js +1 -1
- package/dist/setup.js +1 -1
- package/dist/snapshot-CFKV3VWX.js +1 -0
- package/dist/{snapshot-annotate-T3XC5ENZ.js → snapshot-annotate-HW4ZWT7T.js} +1 -1
- package/dist/snapshot.d.ts +3 -3
- package/package.json +1 -1
- package/server/setup-client.txt +58 -58
- package/dist/chunk-DQPAVGRB.js +0 -1
- package/dist/chunk-UVWLXKWZ.js +0 -1
- package/dist/snapshot-TUAELSKH.js +0 -1
package/dist/setup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n,d as o}from"./chunk-
|
|
1
|
+
import{a as n,d as o}from"./chunk-3SNXBRAS.js";import"./chunk-KLPQTFVH.js";import"./chunk-HHUTDVTM.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-5HZI7HRR.js";import"./chunk-2BS2OWWH.js";import"./chunk-J47R52WX.js";import"./chunk-VX6XCU4E.js";import"./chunk-4HBBEVFK.js";function r(r){return(t={})=>o(n({...r,...t}))}var t=r;export{t as defineKomo,r as definePalette};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b as s,c as t,d as e,e as I,f as T,g as m,h as o,i as n,j as p,k as i,l as r,m as h,n as E,o as L}from"./chunk-JWGDIIKJ.js";export{e as ATTRIBUTE_LIMIT,t as HTML_LIMIT,o as IMAGE_BYTES,a as OPT_OUT,s as PLACEHOLDER,I as TEXT_LIMIT,E as captureSnapshot,r as imageAttachment,p as imageDataUrl,h as noteComment,n as omitInvisibleFrameStyles,T as skipped,L as snapshotFor,m as snapshotHtml,i as snapshotImage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./chunk-
|
|
1
|
+
import{j as e}from"./chunk-JWGDIIKJ.js";import{E as t,G as a}from"./chunk-4HBBEVFK.js";var r=[["pen","Pen"],["arrow","Arrow"],["rectangle","Rectangle"],["highlight","Highlight"]],o=[["Red","#fa5252"],["Yellow","#ffd43b"],["Blue","#4dabf7"],["Green","#51cf66"]];function l(e,t,a){let{points:[r,...o],tool:l,color:n}=t,p=o.at(-1)??r;if(e.save(),e.strokeStyle=e.fillStyle=n,e.lineWidth=a,e.lineJoin=e.lineCap="round",e.beginPath(),"rectangle"===l){let t=Math.abs(p.x-r.x),o=Math.abs(p.y-r.y);e.roundRect(Math.min(r.x,p.x),Math.min(r.y,p.y),t,o,Math.min(a,t/2,o/2)),e.stroke()}else if("arrow"===l){let t=Math.atan2(p.y-r.y,p.x-r.x),o=Math.min(4.5*a,.6*Math.hypot(p.x-r.x,p.y-r.y)),l={x:p.x-o*Math.cos(t),y:p.y-o*Math.sin(t)};e.moveTo(r.x,r.y),e.lineTo(l.x,l.y),e.stroke(),e.beginPath(),e.moveTo(p.x,p.y);for(let a of[-1,1])e.lineTo(l.x+a*o*.42*Math.sin(t),l.y-a*o*.42*Math.cos(t));e.closePath(),e.fill()}else{if("highlight"===l&&(e.globalAlpha=.38,e.lineWidth=5*a),e.moveTo(r.x,r.y),o.length){for(let t=0;t<o.length-1;t++){let a=o[t],r=o[t+1];e.quadraticCurveTo(a.x,a.y,(a.x+r.x)/2,(a.y+r.y)/2)}e.lineTo(p.x,p.y)}else e.lineTo(r.x+.1,r.y);e.stroke()}e.restore()}async function n(n,p,i,d,s,u){if(n.querySelector(".palette-markup[open]"))return;let h=d?.source??p,c=new Image;if(c.src=h,await c.decode(),s.aborted||!n.host.isConnected||n.querySelector(".palette-markup[open]"))return;let m=n.activeElement,f=t("dialog","palette-snapshot-viewer palette-markup");f.setAttribute("aria-label","Image preview");let g=t("style","",'\n.palette-snapshot-viewer.palette-markup{box-sizing:border-box;width:min(1040px,calc(100vw - 32px));padding:0;background:#1b1b1d;color:#f4f4f5}\n.palette-markup header{padding:10px 14px;margin:0;border-bottom:1px solid #ffffff14}\n.palette-markup h2{font-size:14px;padding:0}\n.palette-markup .palette-markup-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:2px 14px 4px}\n.palette-markup-tools,.palette-markup-colors,.palette-markup-history{display:flex;align-items:center;gap:3px}\n.palette-markup-tools{background:#ffffff0a;border:1px solid #ffffff0d;border-radius:9px;padding:2px}\n.palette-markup .palette-markup-control{border:0;border-radius:6px;background:transparent;color:#d4d4d8;padding:0 9px;min-height:34px;font:inherit;cursor:pointer}\n.palette-markup .palette-markup-control[aria-pressed=true]{background:#ffffff1a;color:#fff}\n.palette-markup .palette-markup-control:disabled{opacity:.36;cursor:default}\n.palette-markup .palette-markup-control:focus-visible,.palette-markup-swatch:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:2px}\n.palette-markup-swatch{display:grid;place-items:center;width:30px;height:34px;padding:0;background:none;border:0;border-radius:6px;cursor:pointer}\n.palette-markup-swatch::before{content:"";width:13px;height:13px;border-radius:50%;background:var(--swatch)}\n.palette-markup-swatch[aria-pressed=true]::before{outline:1px solid currentColor;outline-offset:3px}\n.palette-markup .palette-markup-done{background:#e6dcfb;color:#26212e;font-weight:600}\n.palette-markup .palette-markup-history{margin-left:auto}\n.palette-markup-stage{display:grid;place-items:center;min-width:0;padding:20px;overflow:hidden;background:#101012;border-block-start:1px solid #ffffff12}\n.palette-markup-stage canvas{display:block;max-width:100%;height:auto;border-radius:4px;touch-action:none;cursor:crosshair}\n.palette-markup-stage canvas[data-tool=highlight]{cursor:cell}\n.palette-markup-status:not(:empty){margin:0;padding:0 14px 10px;color:#fda4af}\n@media(hover:hover){.palette-markup .palette-markup-control:enabled:hover{background:#ffffff19;color:#fff}.palette-markup .palette-markup-done:enabled:hover{background:#f0e9ff;color:#26212e}}\n@media(pointer:coarse){.palette-markup .palette-markup-control,.palette-markup-swatch{min-height:44px}.palette-markup-swatch{width:44px}}\n@media(max-width:520px){.palette-snapshot-viewer.palette-markup{width:calc(100vw - 16px);max-width:calc(100vw - 16px)}.palette-markup header,.palette-markup .palette-markup-toolbar{padding-inline:10px}.palette-markup .palette-markup-history{margin-left:0}.palette-markup-stage{padding:12px}}\n'),k=t("header"),x=t("div","palette-markup-toolbar");x.setAttribute("aria-label","Image annotation tools"),x.setAttribute("role","toolbar");let b=t("div","palette-markup-tools"),w=t("div","palette-markup-colors"),v=t("div","palette-markup-history"),y=t("div","palette-markup-stage"),M=t("canvas");M.setAttribute("aria-label","Image with annotations"),M.setAttribute("role","img"),M.width=c.naturalWidth,M.height=c.naturalHeight,M.style.width=`min(100%, calc(max(60px, 100dvh - 220px) * ${M.width/M.height}))`;let C=M.getContext("2d");if(!C)throw new Error("Canvas is unavailable.");let E=[...d?.marks??[]],I=[],A="pen",L=o[0][1],T=null,P=null,S=0,R=!1,K=Math.max(2,M.width/180),q=()=>{C.clearRect(0,0,M.width,M.height),C.drawImage(c,0,0);for(let e of E)l(C,e,K);P&&l(C,P,K)},B=()=>{S||=requestAnimationFrame(()=>{S=0,q()})},W=e=>{let t=M.getBoundingClientRect();return{x:Math.max(0,Math.min(M.width,(e.clientX-t.left)*M.width/t.width)),y:Math.max(0,Math.min(M.height,(e.clientY-t.top)*M.height/t.height))}},z=r.map(([e,t])=>a(t,()=>{A=e,"highlight"===e&&(L=o[1][1]),U()},"palette-markup-control")),D=o.map(([e,t])=>{let r=a(e,()=>{L=t,U()},"palette-markup-swatch");return r.textContent="",r.style.setProperty("--swatch",t),r});M.addEventListener("pointerdown",e=>{0!==e.button||null!==T||R||(M.setPointerCapture(e.pointerId),T=e.pointerId,P={tool:A,color:L,points:[W(e)]},U(),B())});let F=e=>{if(!P)return;let t=W(e);"arrow"===P.tool||"rectangle"===P.tool?P.points[1]=t:P.points.push(t)};M.addEventListener("pointermove",e=>{e.pointerId===T&&(F(e),B())}),M.addEventListener("pointerup",e=>{e.pointerId!==T||!P||(F(e),E.push(P),I.length=0,P=null,T=null,U(),B())});let G=e=>{e.pointerId===T&&(T=null,P=null,U(),B())};M.addEventListener("pointercancel",G),M.addEventListener("lostpointercapture",G);let H=a("Undo",()=>{let e=E.pop();e&&I.push(e),U(),B()},"palette-markup-control"),J=a("Redo",()=>{let e=I.pop();e&&E.push(e),U(),B()},"palette-markup-control"),j=t("p","palette-markup-status");j.setAttribute("role","status");let Y=a("Done",()=>{if(P||R)return;let t=d?.marks??[];E.length===t.length&&E.every((e,a)=>e===t[a])?f.close():(R=!0,U(),q(),e(M,{x:0,y:0,width:M.width,height:M.height},i).then(e=>{f.open&&(f.close(),u(e,{source:h,marks:E}))},()=>{j.textContent="Could not save the image.",R=!1,U()}))},"palette-markup-control palette-markup-done");function U(){M.dataset.tool=A,z.forEach((e,t)=>e.setAttribute("aria-pressed",String(A===r[t][0]))),D.forEach((e,t)=>e.setAttribute("aria-pressed",String(L===o[t][1]))),H.disabled=!E.length||!!P||R,J.disabled=!I.length||!!P||R,Y.disabled=!!P||R}b.append(...z),w.append(...D),v.append(H,J),x.append(b,w,v);let V=a("Close image preview",()=>f.close(),"icon","close");k.append(t("h2","","Image preview"),Y,V),y.append(M),f.append(g,k,x,y,j);let X=new AbortController;window.addEventListener("keydown",e=>{if(!f.open)return;let t=e.key.toLowerCase(),a=(e.metaKey||e.ctrlKey)&&("z"===t||"y"===t);("escape"===t||a)&&(e.preventDefault(),"escape"===t?f.close():("y"===t||e.shiftKey?J:H).click()),e.stopImmediatePropagation()},{capture:!0,signal:X.signal});let $=()=>{X.abort(),f.close()};s.addEventListener("abort",$,{once:!0}),f.addEventListener("close",()=>{s.removeEventListener("abort",$),X.abort(),cancelAnimationFrame(S),f.remove(),m?.isConnected&&m.focus({preventScroll:!0})},{once:!0}),n.append(f),U(),q(),f.showModal()}export{n as annotateImage};
|
package/dist/snapshot.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ type Crop = {
|
|
|
46
46
|
};
|
|
47
47
|
export declare function imageDataUrl(image: CanvasImageSource, crop: Crop, limit: number, density?: number): Promise<string>;
|
|
48
48
|
/** The selected region or the whole element as WebP. */
|
|
49
|
-
export declare function snapshotImage(element: Element, options?: PaletteSnapshots, region?: Crop): Promise<string>;
|
|
49
|
+
export declare function snapshotImage(element: Element, options?: PaletteSnapshots, region?: Crop, freeze?: boolean): Promise<string>;
|
|
50
50
|
export declare function imageAttachment(file: File, limit: number): Promise<CapturedSnapshot>;
|
|
51
51
|
/** The server's snapshot support, from `/config`. */
|
|
52
52
|
export interface SnapshotLimits {
|
|
@@ -63,11 +63,11 @@ export declare const noteComment: (note: SnapshotNote) => string;
|
|
|
63
63
|
* that can't be read (another origin's pixels) falls back to the HTML, which then
|
|
64
64
|
* starts with a comment saying why.
|
|
65
65
|
*/
|
|
66
|
-
export declare function captureSnapshot(element: Element | null, options: PaletteSnapshots, htmlLimit?: number, region?: Crop): Promise<CapturedSnapshot | null>;
|
|
66
|
+
export declare function captureSnapshot(element: Element | null, options: PaletteSnapshots, htmlLimit?: number, region?: Crop, freeze?: boolean): Promise<CapturedSnapshot | null>;
|
|
67
67
|
/**
|
|
68
68
|
* The snapshot of a draft's target, captured once per anchor: the composer reads it
|
|
69
69
|
* for a preview, and posting passes `post` to upload each kind as its raw file after
|
|
70
70
|
* the thread is saved. Never rejects; failed uploads are reported when supported and the comment stays posted.
|
|
71
71
|
*/
|
|
72
|
-
export declare function snapshotFor<Anchor extends object>(anchor: Anchor, resolve: (anchor: Anchor) => Element | null, options: PaletteSnapshots, limits: SnapshotLimits, post?: (kind: "image" | "html" | "status", body: Blob) => Promise<unknown>, region?: Crop, attachment?: Promise<CapturedSnapshot | null
|
|
72
|
+
export declare function snapshotFor<Anchor extends object>(anchor: Anchor, resolve: (anchor: Anchor) => Element | null, options: PaletteSnapshots, limits: SnapshotLimits, post?: (kind: "image" | "html" | "status", body: Blob) => Promise<unknown>, region?: Crop, attachment?: Promise<CapturedSnapshot | null>, freeze?: boolean): Promise<CapturedSnapshot | null>;
|
|
73
73
|
export {};
|