@hazem3500/palette 0.9.122 → 0.9.124
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 +1 -1
- package/dist/chunk-RZUSE3F5.js +1 -0
- package/dist/index.js +1 -1
- package/dist/node.mjs +1 -1
- package/dist/react.js +1 -1
- package/dist/server.js +1 -1
- package/dist/setup.js +1 -1
- package/dist/thread-snapshot-TJHRZZOR.js +1 -0
- package/package.json +1 -1
- package/server/setup-client.txt +56 -56
- package/dist/chunk-7DRZRQU4.js +0 -1
- package/dist/thread-snapshot-ML2RZVID.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-RZUSE3F5.js";import"./chunk-KLPQTFVH.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-HHUTDVTM.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{E as e,G as t}from"./chunk-4HBBEVFK.js";var n=new WeakMap;function a(t){let a=n.get(t);a?.isConnected||(a=e("style","",'.palette-snapshot{display:block;width:fit-content;margin-top:8px;padding:0;border:0;border-radius:6px;background:none;color:inherit;font:inherit;cursor:zoom-in;line-height:0}\n.palette-snapshot img{display:block;width:72px;height:48px;border-radius:6px;object-fit:contain;background:color-mix(in oklab,currentColor 8%,transparent);outline:1px solid color-mix(in oklab,currentColor 16%,transparent);outline-offset:-1px}\n.palette-snapshot:not([data-ready]){background:color-mix(in oklab,currentColor 8%,transparent)}\n.palette-snapshot:not([data-ready]) img{visibility:hidden}\n.palette-snapshot[hidden]{display:none}\n.palette-snapshot:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:2px}\n.palette-snapshot[data-large]{width:auto;max-width:100%}\n.palette-snapshot[data-large] img{width:auto;height:auto;min-width:72px;min-height:48px;max-width:100%;max-height:180px;object-fit:contain}\n.thread-item>.palette-snapshot{margin:6px 12px 0 calc(12px + var(--palette-avatar,20px) + var(--palette-gutter,8px))}\n.dialog:has(.thread-navigation:not([hidden]) .palette-snapshot-view) .message .palette-snapshot{display:none}\n.palette-snapshot-view{margin-top:8px}\n.palette-snapshot-view p{margin:0 0 6px}\n.palette-snapshot-code{box-sizing:border-box;max-height:160px;margin:0;padding:8px;overflow:auto;border-radius:6px;background:color-mix(in oklab,currentColor 8%,transparent);font:11px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere;scrollbar-width:thin}\n.palette-snapshot-code:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:2px}\n.palette-snapshot-text{justify-self:start;margin-top:8px;padding:4px 8px;border:0;border-radius:6px;background:color-mix(in oklab,currentColor 8%,transparent);color:inherit;font-family:inherit;font-size:11px;line-height:1.4;cursor:pointer}\n.palette-snapshot-draft{display:flex;align-items:center;gap:8px;margin-top:8px;font-size:12px;color:#999}\n.palette-snapshot-draft .palette-snapshot{margin:0}\n.palette-snapshot-draft span{flex:1;min-width:0}\n.palette-snapshot-draft .icon{width:28px;height:28px}\n.palette-snapshot-viewer{box-sizing:border-box;max-width:min(1200px,calc(100vw - 32px));max-height:calc(100dvh - 32px);margin:auto;padding:12px;overflow:hidden;border:0;border-radius:16px;background:#242424;color:#eee;box-shadow:inset 0 0 0 1px #ffffff1f,0 24px 64px -16px rgb(0 0 0/55%);font:12px/1.4 -apple-system,BlinkMacSystemFont,"Inter","Segoe UI",sans-serif;pointer-events:auto;color-scheme:dark}\n.palette-snapshot-viewer[open]{display:flex;flex-direction:column;gap:8px;animation:palette-snapshot-in var(--duration-fast,250ms) var(--ease-smooth-out,cubic-bezier(.22,1,.36,1))}\n.palette-snapshot-viewer::backdrop{background:rgb(0 0 0/40%);pointer-events:auto}\n.palette-snapshot-viewer header{display:flex;align-items:center;gap:8px}\n.palette-snapshot-viewer h2{flex:1;margin:0;padding-left:4px;font-size:13px;font-weight:600}\n.palette-snapshot-viewer .icon{width:28px;height:28px;border-radius:8px;color:#bbb}\n.palette-snapshot-viewer .icon:hover{background:#ffffff14;color:#eee}\n.palette-snapshot-viewer .icon:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:-2px}\n.palette-snapshot-viewer img{display:block;min-height:0;max-width:100%;max-height:calc(100dvh - 104px);margin:auto;border-radius:8px;object-fit:contain}\n.palette-snapshot-viewer .palette-snapshot-code{max-height:calc(100dvh - 104px);width:min(720px,calc(100vw - 56px))}\n@keyframes palette-snapshot-in{from{opacity:0;scale:.98;translate:0 4px}}\n@media (prefers-reduced-motion:reduce){.palette-snapshot-viewer[open]{animation:none}}\n@media (pointer:coarse){.palette-snapshot-viewer .icon,.palette-snapshot-draft .icon{width:44px;height:44px}}'),n.set(t,a),t.append(a))}var o=20,r=[],i=0,s=[],p=0;function l(){let e=performance.now();for(;s.length&&e-s[0]>=6e4;)s.shift();for(;r.length&&i<2&&s.length<20;)i++,s.push(e),r.shift()();r.length&&!p&&s.length>=20&&(p=window.setTimeout(()=>(p=0,l()),6e4-(e-s[0])))}var d=new Map;function c(e,t){let n,a=t.token();try{n=new URL(e)}catch{return Promise.resolve(null)}if(!a||n.origin!==t.origin())return Promise.resolve(null);let o=`${a} ${e}`,s=d.get(o);if(s)return s;s=new Promise(e=>{r.push(()=>e(()=>(i--,l()))),l()}).then(async e=>{try{let e=await fetch(n,{headers:{Authorization:`Bearer ${a}`},credentials:"omit",signal:AbortSignal.timeout(15e3)});if(404===e.status)return null;if(!e.ok)throw new Error(String(e.status));return await e.blob()}finally{e()}}),d.set(o,s),s.catch(()=>d.get(o)===s&&d.delete(o));for(let e of d.keys())d.size>40&&d.delete(e);return s}var h,f=new WeakMap,u=new Map,m=new WeakSet,g="img[data-palette-snapshot]";function x(e){let t=f.get(e);!t||u.has(e)||!e.isConnected||c(t.url,t.context).then(n=>{if(!e.isConnected||u.has(e))return;if(!n)return t.done?.(!1);let a=URL.createObjectURL(n);u.set(e,a),e.src=a,t.done?.(!0)},()=>t.done?.(!1))}function b(e){h?h.observe(e):x(e)}function v(e){m.has(e)||(m.add(e),"function"==typeof IntersectionObserver&&(h??=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&x(t.target)})),new MutationObserver(e=>{for(let t of e){for(let e of t.removedNodes)if(e instanceof Element)for(let t of e.matches(g)?[e]:e.querySelectorAll(g))t.isConnected||h?.unobserve(t);for(let e of t.addedNodes)if(e instanceof Element&&e.isConnected)for(let t of e.matches(g)?[e]:e.querySelectorAll(g))b(t)}!function(){for(let[e,t]of u)e.isConnected||(URL.revokeObjectURL(t),u.delete(e),e.removeAttribute("src"))}()}).observe(e,{childList:!0,subtree:!0}))}function w(e){for(let t of[...C.get(e)??[]])t();for(let[t,n]of u)t.getRootNode()===e&&(URL.revokeObjectURL(n),u.delete(t),t.removeAttribute("src"),h?.unobserve(t))}function y(e){let{context:t,text:n}=e.anchor,a=(t?.label||n||"").replace(/\s+/g," ").trim();return`Snapshot of ${a?`“${a.length>60?`${a.slice(0,59)}…`:a}”`:t?.tag?`the ${t.tag} element`:"the commented element"} when the comment was left`}var k=/^<!-- (?:palette|komo): (no image snapshot, [^>]*?)\.? -->\s*/;function L(e){let t=k.exec(e);return t?{note:`${t[1][0].toUpperCase()}${t[1].slice(1)}.`,code:e.slice(t[0].length)}:{note:"",code:e}}function S(t){let n=e("pre","palette-snapshot-code");return n.textContent=t,n.tabIndex=0,n.setAttribute("role","region"),n.setAttribute("aria-label","HTML snapshot"),n}var C=new Map;async function R(n,o,r){a(n);let i=n.activeElement,s=e("dialog","palette-snapshot-viewer");s.setAttribute("aria-modal","true"),s.setAttribute("aria-label",o.alt);let p=e("header"),l=t("Close snapshot",()=>h(),"icon","close");if(l.removeAttribute("title"),p.append(e("h2","",o.src?"Snapshot":"HTML snapshot"),l),s.append(p),o.src){let t=e("img");t.alt=o.alt,t.src=o.src,s.append(t),await t.decode().catch(()=>{})}else{let{note:t,code:n}=L(o.html??"");t&&s.append(e("p","",t)),s.append(S(n))}if(!n.host.isConnected)return r?.();let d=new AbortController,{signal:c}=d,h=()=>{c.aborted||(d.abort(),C.get(n)?.delete(h),s.close(),s.remove(),r?.(),i?.isConnected&&i.focus({preventScroll:!0}))};s.addEventListener("close",h,{signal:c}),C.set(n,(C.get(n)??new Set).add(h)),window.addEventListener("keydown",e=>{e.stopImmediatePropagation(),"Escape"===e.key&&(e.preventDefault(),h())},{capture:!0,signal:c});let f=!1,u=e=>{let t=s.getBoundingClientRect();return e.target===s&&(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)};return s.addEventListener("pointerdown",e=>f=u(e),{signal:c}),s.addEventListener("click",e=>f&&u(e)&&h(),{signal:c}),n.append(s),s.showModal(),l.focus(),s}function A(t,n,a,o=!1,r){let i=y(n),s=e("img");s.alt=i,s.dataset.paletteSnapshot="",s.decoding="async";let p=e("button","palette-snapshot");return p.type="button",p.setAttribute("aria-haspopup","dialog"),o&&(p.dataset.large=""),p.append(s),f.set(s,{url:t,context:a,done:e=>{e?p.dataset.ready="":p.dataset.ready||(r?r():p.hidden=!0)}}),p.addEventListener("click",()=>{c(t,a).then(e=>{if(!e)return;let t=URL.createObjectURL(e);R(a.root,{src:t,alt:i},()=>URL.revokeObjectURL(t))})}),p}function E(e,t,n){v(n),e.replaceWith(t);let a=t.querySelector(g);a?.isConnected&&b(a)}function M(n,o,r,i,s){let{image:p,html:l}=i.snapshot??{};if(a(o.root),3===r)return void s?.then(a=>{a&&(a.image||a.html)&&n.isConnected&&!o.dropped.has(i.anchor)&&E(n,function(n,a,o){let r=e("div","palette-snapshot-draft"),i=y({anchor:a});if(n.image){let t=e("button","palette-snapshot");t.type="button",t.dataset.ready="",t.setAttribute("aria-haspopup","dialog");let a=e("img");a.alt=i,a.src=n.image,t.append(a),t.addEventListener("click",()=>{R(o.root,{src:n.image,alt:i})}),r.append(t)}r.append(e("span","",n.image?n.html?"Snapshot and HTML attached":"Snapshot attached":"HTML snapshot attached"));let s=t("Remove snapshot",()=>{o.dropped.add(a),r.closest("form")?.querySelector("textarea")?.focus(),r.remove()},"icon","trash");return r.append(s),r}(a,i.anchor,o),o.root)});let d=r>1?(p||l)&&function(t,n){let{image:a,html:o}=t.snapshot,r=e("div","palette-snapshot-view"),i=()=>{if(!o)return r.remove();c(o,n).then(async t=>{if(!t)return r.remove();let{note:n,code:a}=L(await t.text());r.replaceChildren(e("p","",n||"How it looked, as HTML:"),S(a))},()=>r.remove())};return r.append(e("p","","How it looked:")),a?r.append(A(a,t,n,!0,i)):i(),r}(i,o):p?A(p,i,o):r&&l&&function(e,n,a){let o=t("HTML snapshot",()=>{c(e,a).then(async e=>{e&&R(a.root,{html:await e.text(),alt:y(n)})})},"palette-snapshot-text");return o.removeAttribute("title"),o.setAttribute("aria-haspopup","dialog"),o}(l,i,o);if(4===r){let t=e("div");t.append(function(t,n){let a=new URL(t.page,location.origin);a.searchParams.set("comment",t.id);let o=e("a","thread-route",t.page);o.href=a.href,o.addEventListener("click",e=>{e.preventDefault(),n.go(a)});let r=e("p","","Left on ");return r.append(o),r}(i,o),...d?[d]:[]),d=t}d&&E(n,d,o.root)}function U(e,t){t.notify("Remove this comment’s snapshot?",{label:"Remove",run:()=>{t.remove(e),t.notify("Snapshot removed")}})}export{o as READS_PER_MINUTE,U as confirmRemove,w as disposeSnapshots,M as mountSnapshot,R as openSnapshotViewer,c as readSnapshot,y as snapshotAlt,L as splitNote};
|