@hazem3500/palette 0.9.118 → 0.9.120
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 -2
- package/dist/chunk-AAFGCZLH.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/shell-mode-I5OAFZVD.js +1 -0
- package/dist/shell-mode.d.ts +4 -3
- package/dist/snapshot-BFHCCGOL.js +1 -0
- package/dist/snapshot.d.ts +6 -1
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
- package/server/setup-client.txt +51 -51
- package/src/types.ts +2 -0
- package/dist/chunk-3DH4SW3Z.js +0 -1
- package/dist/shell-mode-RPV7AVA4.js +0 -1
- package/dist/snapshot-H5JZR3ES.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-AAFGCZLH.js";import"./chunk-KLPQTFVH.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-DU7H4TEX.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
|
+
var e="palette-shell",t="palette:shell";function o(t,o){let a=new URL(t,location.href);return a.searchParams.delete("komo-shell"),o?a.searchParams.set(e,o):a.searchParams.delete(e),a.href}function a(e,a=""){try{sessionStorage.removeItem(t),sessionStorage.removeItem("komo:shell"),a&&sessionStorage.setItem("palette:shell-off",a)}catch{}location.replace(o(e,""))}function l(e,a,l,r){try{let n=sessionStorage.getItem("palette:shell-off");if(n)return r(n);if(a&&l&&!confirm("Reload in Frame?\n\nUnposted Design changes will be lost."))return r("Reload cancelled.");let s=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,"0")).join("");sessionStorage.setItem(t,JSON.stringify({v:1,project:e,nonce:s,origin:location.origin})),location.replace(o(location.href,s))}catch{return r("Storage blocked.")}setTimeout(r,3e3,"Reload cancelled.")}function r(e,t){try{let a=e.location.href,l=o(a,t);a.startsWith(location.origin)&&l!==location.href&&history.replaceState(history.state,"",l)}catch{}}export{l as enterShell,a as leaveShellPage,o as shellUrl,r as syncShell};
|
package/dist/shell-mode.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ export declare function shellUrl(href: string, nonce: string): string;
|
|
|
3
3
|
/** Ends the shell: clears it, notes why when it ended early, and loads `href` as the normal page. */
|
|
4
4
|
export declare function leaveShellPage(href: string, reason?: string): void;
|
|
5
5
|
/**
|
|
6
|
-
* Reloads this page as the shell. `ask
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Reloads this page as the shell. With `ask`, it confirms only when `edited` (unposted
|
|
7
|
+
* Design changes would be lost); the app's own unsaved-changes guard covers app state.
|
|
8
|
+
* `fallback` runs when the reviewer cancels, storage is blocked, or the page didn't
|
|
9
|
+
* unload (that guard can keep it).
|
|
9
10
|
*/
|
|
10
11
|
export declare function enterShell(project: string, ask: boolean, edited: boolean, fallback: (reason: string) => void): void;
|
|
11
12
|
/** The shell's URL follows the frame's route, so reloading or sharing it keeps the page. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e="data-palette-no-snapshot",t=`[${e}],[data-komo-no-snapshot]`,a=e=>e.matches(t),n="[data-branch-comments],[data-palette-move-clone],[data-palette-viewport],[data-palette-snapshot-sandbox]",o="[redacted]",r=new Set(["script","noscript","template","style","link","meta","base","title"]),i=/^(?:href|src|action|formaction|xlink:href|poster|data|background)$/i,l=e=>"textarea"===e.localName||"input"===e.localName&&!/^(?:button|submit|reset|image|checkbox|radio|range|color)$/i.test(e.getAttribute("type")??""),s=2e4,c=200,d=500,h=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e,u=e=>(new TextEncoder).encode(e).length,m=e=>!!e.closest(`${t},${n}`);function f(e,t=1/0){for(let{name:a,value:n}of[...e.attributes])/^on/i.test(a)||"srcdoc"===a||/^data-(palette|komo)-/.test(a)&&!/-no-snapshot$/.test(a)||i.test(a)&&/^\s*(?:javascript|vbscript):/i.test(n)?e.removeAttribute(a):n.length>t&&e.setAttribute(a,h(n,t))}function p(e,t,i=s){let c=e.ownerDocument,d=i,m=e=>{if(3===e.nodeType){let t=h(e.nodeValue??"",500);return d-=t.length,c.createTextNode(t)}if(1!==e.nodeType)return null;let i=e;if(r.has(i.localName)||i.matches(n))return null;let s=i.cloneNode(!1);if(f(s,200),l(i)&&function(e,t){let a=e.value??e.getAttribute("value")??"";"textarea"===e.localName?t.textContent=a?o:"":(a||t.hasAttribute("value"))&&t.setAttribute("value",o)}(i,s),d-=s.outerHTML.length,a(i))return s;if(t?.(i))return l(i)||(s.textContent=o),s;if("textarea"===i.localName)return s;for(let e of i.childNodes){if(d<=0){s.append(c.createComment(" trimmed "));break}let t=m(e);t&&s.append(t)}return s},p=m(e);if(!p)return"";let g=p.outerHTML;if(u(g)<=i)return g;let w=c.createComment(" trimmed ");p.append(w);for(let e=u(p.outerHTML)-i;e>0&&p.firstChild!==w;e=u(p.outerHTML)-i)for(;e>0&&p.firstChild!==w;){let t=w.previousSibling;for(;t.lastChild;)t=t.lastChild;e-=1===t.nodeType?t.outerHTML.length:(t.nodeValue?.length??0)+7,t.parentNode.removeChild(t)}return g=p.outerHTML,u(g)>i?"":g}var g=class extends Error{constructor(e){super(e),this.reason=e}reason},w=25e4,y=e=>new Promise((t,a)=>{let n=new FileReader;n.onload=()=>t(n.result),n.onerror=()=>a(n.error),n.readAsDataURL(e)});async function b(e,t){if(e.startsWith("data:"))return e;let a=new URL(e,t.document.baseURI);try{let e=await fetch(a,{mode:"cors",signal:AbortSignal.timeout(5e3)});return e.ok?await y(await e.blob()):""}catch{if(a.origin!==t.location.origin)throw new g("cross-origin");return""}}var x=["top","right","bottom","left","block-start","block-end","inline-start","inline-end"],v=(e,t)=>"none"===e||"hidden"===e||"0px"===t;function $(e,t=t=>e.get(t),a){for(let n of x){let o=`border-${n}-style`,r=`border-${n}-width`;v(t(o),t(r))&&(e.delete(o),e.delete(r),e.delete(`border-${n}-color`),a?.has(o)&&!v(a.get(o),a.get(r))&&e.set(o,"none"))}if(v(t("outline-style"),t("outline-width"))){for(let t of[...e.keys()])t.startsWith("outline")&&e.delete(t);a?.has("outline-style")&&!v(a.get("outline-style"),a.get("outline-width"))&&e.set("outline-style","none")}}function M(e,t,a){let n=new Map;for(let o=0;o<e.length;o++){let r=e[o];if(r.startsWith("--"))continue;let i=e.getPropertyValue(r);(i!==t.get(r)||a&&i!==a.getPropertyValue(r))&&n.set(r,i)}$(n,t=>e.getPropertyValue(t),t);let o="";for(let[e,t]of n)o+=`${e}:${t};`;return o}var C=/url\((['"]?)(.*?)\1\)/g;async function T(e,t,i){let s=e.ownerDocument,c=s.defaultView,d=e.getBoundingClientRect(),h=e.offsetWidth??d.width,u=Math.min(e.offsetHeight??d.height,2e3);if(!h||!u)throw new g("failed");let m=function(){let e=document.createElement("iframe");e.setAttribute("data-palette-snapshot-sandbox",""),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.style.cssText="position:fixed;left:-10px;top:0;width:1px;height:1px;border:0;opacity:0;pointer-events:none",document.documentElement.append(e);let t=e.contentDocument;try{t.open(),t.write("<!doctype html><html><head></head><body></body></html>"),t.close()}catch{}let a=new Map;return{of(e){let n=`${e.namespaceURI} ${e.localName}`,o=a.get(n);if(!o){let r=t.createElementNS(e.namespaceURI,e.localName);(t.body??t.documentElement).append(r);let i=t.defaultView.getComputedStyle(r);o=new Map;for(let e=0;e<i.length;e++)o.set(i[e],i.getPropertyValue(i[e]));r.remove(),a.set(n,o)}return o},dispose:()=>e.remove()}}(),p=[],w=new Set,y=new Map,x=[],v="",$=0,T=e=>(e.catch(()=>{}),e),A=e=>{for(let[,,t]of e.matchAll(C))t&&!t.startsWith("data:")&&!y.has(t)&&y.set(t,T(b(t,c)));return e},I=(e,d)=>{if(3===e.nodeType)return s.createTextNode(e.nodeValue??"");if(1!==e.nodeType)return null;let y=e,C=y.localName;if(r.has(C)||y.matches(n))return null;if(++$>3e3)throw new g("too-large");let k,E=c.getComputedStyle(y);if("none"===E.display)return null;if("canvas"===C||"video"===C){k=s.createElement("img");let e=document.createElement("canvas");e.width=y.width||y.videoWidth||1,e.height=y.height||y.videoHeight||1;try{e.getContext("2d").drawImage(y,0,0,e.width,e.height),k.setAttribute("src",e.toDataURL("image/png"))}catch{throw new g("cross-origin")}}else if("iframe"===C||"embed"===C||"object"===C)k=s.createElement("div");else{k=y.cloneNode(!1),f(k);for(let e of["id","class","srcset","sizes","loading","style"])k.removeAttribute(e)}l(y)&&(k.removeAttribute("value"),k.hasAttribute("placeholder")&&t?.(y)&&k.setAttribute("placeholder",o)),"img"===C&&p.push(T(async function(e,t,a){let n=e.currentSrc||e.src;if(!n||n.startsWith("data:"))return n;await e.decode().catch(()=>{});let o=Math.min(e.naturalWidth,Math.ceil(e.offsetWidth*t)||e.naturalWidth),r=Math.round(o*e.naturalHeight/(e.naturalWidth||1));if(o&&r){let t=document.createElement("canvas");t.width=o,t.height=r;try{return t.getContext("2d").drawImage(e,0,0,o,r),t.toDataURL("image/png")}catch{}}return b(n,a)}(y,i,c).then(e=>k.setAttribute("src",e)))),w.add(E.fontFamily.split(",")[0].replace(/["']/g,"").trim().toLowerCase());let L=M(E,m.of(y),d);d||(L+=`${"inline"===E.display?"display:inline-block;":""}margin:0;position:relative;inset:auto;float:none;transform:none;translate:none;rotate:none;scale:none;flex:none;box-sizing:border-box;width:${h}px;height:${u}px;max-width:none;max-height:none;min-width:0;min-height:0;`);let R=a(y)&&!!d;R&&(L+="color:transparent;background:#e5e5e5;background-image:none;"),x.push([k,A(L)]);for(let e of["::before","::after"]){let t=c.getComputedStyle(y,e);R||/^(?:none|normal)$/.test(t.content)||(k.setAttribute("data-snapshot",String($)),v+=`[data-snapshot="${$}"]${e}{${A(M(t,m.of(y),E))}content:${t.content};}`)}if(R)return k;if(t?.(y))return l(y)||(k.textContent=o),k;if("textarea"===C)return k;for(let e of y.childNodes){if("picture"===C&&"img"!==e.localName)continue;let t=I(e,E);t&&k.append(t)}return k};try{await(s.fonts?.ready);let t=I(e),a=new Map(await Promise.all([...y].map(async([e,t])=>[e,await t]))),n=e=>e.replace(C,(e,t,n)=>a.has(n)?`url("${a.get(n)}")`:e);for(let[e,t]of x)e.setAttribute("style",n(t));v=n(v),await Promise.all(p);let o=s.createElement("div");o.setAttribute("style",`width:${h+32}px;height:${u+32}px;padding:16px;box-sizing:border-box;overflow:hidden;background:${function(e,t){for(let a=e.parentElement;a;a=a.parentElement){let e=t.getComputedStyle(a).backgroundColor;if(e&&!/^(?:transparent|rgba\(.*,\s*0\))$/.test(e))return e}return"#fff"}(e,c)}`);let r=s.createElement("style");r.textContent=await async function(e,t,a){let n=[],o=2e6,r=async(e,i)=>{for(let l of e){if(l.cssRules&&await r(l.cssRules,i),!l.cssText.startsWith("@font-face"))continue;let e=l.style,s=e.getPropertyValue("font-family").replace(/["']/g,"").trim().toLowerCase(),c=e.getPropertyValue("src").match(/url\((['"]?)(.*?)\1\)/)?.[2];if(!t.has(s)||!c||o<=0)continue;let d=await b(new URL(c,i).href,a).catch(()=>"");d&&(o-=d.length,n.push(`@font-face{font-family:"${s}";src:url("${d}");${["font-weight","font-style","font-stretch","unicode-range"].map(t=>e.getPropertyValue(t)?`${t}:${e.getPropertyValue(t)};`:"").join("")}}`))}};for(let t of e.styleSheets){let a;try{a=t.cssRules}catch{continue}await r(a,t.href??e.baseURI)}return n.join("")}(s,w,c)+v,o.append(r,t);let i={width:h+32,height:u+32},l=`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width}" height="${i.height}"><foreignObject x="0" y="0" width="100%" height="100%">${(new XMLSerializer).serializeToString(o)}</foreignObject></svg>`,d=new Image;return d.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(l)}`,await d.decode(),{image:d,...i}}finally{m.dispose()}}var A=(e,t)=>new Promise((a,n)=>{try{e.toBlob(a,"image/webp",t)}catch(e){n(e)}});async function I(e,t={}){let a=t.maxBytes??w,n=e.ownerDocument.defaultView??window,o=e.offsetWidth||e.getBoundingClientRect().width,r=Math.min(n.devicePixelRatio||1,2,1200/(o+32)),i=await T(e,t.redact,r),l=document.createElement("canvas"),s=.8;for(let e=0;e<12&&i.width*r>=48;e++){l.width=Math.max(1,Math.round(i.width*r)),l.height=Math.max(1,Math.round(i.height*r));let e,t=l.getContext("2d");if(!t)throw new g("unsupported");t.drawImage(i.image,0,0,l.width,l.height);try{e=await A(l,s)}catch{throw new g("cross-origin")}if(!e||"image/webp"!==e.type)throw new g("unsupported");if(e.size<=a)return y(e);s>.5?s=Math.round(100*(s-.15))/100:r*=Math.min(.85,Math.max(.3,.95*Math.sqrt(a/e.size)))}throw new g("too-large")}var k={"cross-origin":"cross-origin images","too-large":"the element is too large to draw",unsupported:"this browser can't encode WebP",failed:"it couldn't be drawn"},E=e=>`\x3c!-- palette: no image snapshot, ${k[e]}. --\x3e`;async function L(e,t,a=s){if(!e?.isConnected||m(e))return null;let n={},o=()=>p(e,t.redact,a-120);if(t.html&&(n.html=o()),t.image){await new Promise(e=>"function"==typeof requestIdleCallback?requestIdleCallback(e,{timeout:500}):setTimeout(e));try{n.image=await I(e,t)}catch(e){n.note=e instanceof g?e.reason:"failed","cross-origin"===n.note&&(n.html??=o()),n.html&&(n.html=E(n.note)+n.html)}}return n}var R=e=>{let[t,a]=e.split(","),n=Uint8Array.from(atob(a),e=>e.charCodeAt(0));return new Blob([n],{type:t.slice(5,-7)})},P=new WeakMap;function N(e,t,a,n,o){let r=P.get(e);if(!r){let o={...a,maxBytes:Math.min(a.maxBytes??w,n.maxImageBytes||1/0)};r=a.image||a.html?L(t(e),o,Math.min(s,n.maxHtmlBytes||1/0)).catch(()=>({note:"failed"})):Promise.resolve(null),P.set(e,r)}return o&&r.then(async e=>{let t="failed"===e?.note;for(let a of["image","html"]){let n=e?.[a];n&&await o(a,"image"===a?R(n):new Blob([n],{type:"text/html;charset=utf-8"})).catch(()=>t=!0)}if(n.readiness&&(t||!e?.image&&!e?.html))return o("status",new Blob([`{"status":"${t?"failed":"skipped"}"}`],{type:"application/json"})).catch(()=>{})}),r}export{c as ATTRIBUTE_LIMIT,s as HTML_LIMIT,w as IMAGE_BYTES,e as OPT_OUT,o as PLACEHOLDER,d as TEXT_LIMIT,L as captureSnapshot,E as noteComment,$ as omitInvisibleFrameStyles,m as skipped,N as snapshotFor,p as snapshotHtml,I as snapshotImage};
|
package/dist/snapshot.d.ts
CHANGED
|
@@ -29,8 +29,13 @@ export declare const IMAGE_BYTES = 250000;
|
|
|
29
29
|
* resets) set `border-style: solid` with `border-width: 0`, which differs from a bare tag's
|
|
30
30
|
* `none` baseline. Serialising those into an SVG foreignObject makes engines draw faint gray
|
|
31
31
|
* boxes that are not on the page.
|
|
32
|
+
*
|
|
33
|
+
* `styles` holds only the declarations that differ from the tag's default, so a `0px` width
|
|
34
|
+
* that matches the default is missing from it. `read` gives the element's full computed value
|
|
35
|
+
* to decide what paints. When the tag's own default paints (a button's outset border), the
|
|
36
|
+
* dropped side is written as `none` so the default does not come back.
|
|
32
37
|
*/
|
|
33
|
-
export declare function omitInvisibleFrameStyles(styles: Map<string, string>): void;
|
|
38
|
+
export declare function omitInvisibleFrameStyles(styles: Map<string, string>, read?: (name: string) => string | undefined, base?: Map<string, string>): void;
|
|
34
39
|
/** The element plus padding as WebP, at most 1200px wide and `maxBytes` in size. */
|
|
35
40
|
export declare function snapshotImage(element: Element, options?: PaletteSnapshots): Promise<string>;
|
|
36
41
|
/** The server's snapshot support, from `/config`. */
|
package/dist/types.d.ts
CHANGED
|
@@ -352,6 +352,8 @@ export interface CommentsController {
|
|
|
352
352
|
comment(element: Element): void;
|
|
353
353
|
destroy(): void;
|
|
354
354
|
open(): void;
|
|
355
|
+
/** Bring back a toolbar the reviewer dismissed, without opening the sidebar. */
|
|
356
|
+
restore(): void;
|
|
355
357
|
close(): void;
|
|
356
358
|
refresh(): Promise<void>;
|
|
357
359
|
}
|