@cychien/ezdesign 0.9.2 → 0.11.0

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.
Files changed (34) hide show
  1. package/README.md +209 -550
  2. package/dist/cli.mjs +2640 -655
  3. package/dist/constants.d.ts +8 -4
  4. package/dist/extension/g/0.11.0-75c3fbebc3/dialog.js +1 -0
  5. package/dist/extension/g/0.11.0-75c3fbebc3/media.js +1 -0
  6. package/dist/extension/g/0.11.0-75c3fbebc3/page.js +44 -0
  7. package/dist/extension/g/0.11.0-75c3fbebc3/worker.js +57 -0
  8. package/dist/extension/manifest.json +15 -12
  9. package/dist/home.css +4706 -0
  10. package/dist/home.js +440 -0
  11. package/dist/native-host.mjs +33804 -115
  12. package/dist/overlay.css +5 -1
  13. package/dist/overlay.js +73 -22
  14. package/dist/shell.css +297 -1
  15. package/dist/shell.js +1230 -358
  16. package/dist/video-digest.js +16388 -0
  17. package/dist/vite.mjs +5 -1
  18. package/package.json +4 -3
  19. package/skills/ezdesign/SKILL.md +7 -3
  20. package/skills/ezdesign/reference/start.md +2 -1
  21. package/dist/extension/g/0.9.2-d9aee83dae/dialog.js +0 -1
  22. package/dist/extension/g/0.9.2-d9aee83dae/media.js +0 -1
  23. package/dist/extension/g/0.9.2-d9aee83dae/page.js +0 -39
  24. package/dist/extension/g/0.9.2-d9aee83dae/worker.js +0 -57
  25. /package/dist/extension/g/{0.9.2-d9aee83dae → 0.11.0-75c3fbebc3}/dialog.css +0 -0
  26. /package/dist/extension/g/{0.9.2-d9aee83dae → 0.11.0-75c3fbebc3}/dialog.html +0 -0
  27. /package/dist/extension/g/{0.9.2-d9aee83dae → 0.11.0-75c3fbebc3}/icon-128.png +0 -0
  28. /package/dist/extension/g/{0.9.2-d9aee83dae → 0.11.0-75c3fbebc3}/icon-16.png +0 -0
  29. /package/dist/extension/g/{0.9.2-d9aee83dae → 0.11.0-75c3fbebc3}/icon-32.png +0 -0
  30. /package/dist/extension/g/{0.9.2-d9aee83dae → 0.11.0-75c3fbebc3}/icon-48.png +0 -0
  31. /package/dist/extension/g/{0.9.2-d9aee83dae → 0.11.0-75c3fbebc3}/media.html +0 -0
  32. /package/dist/extension/g/{0.9.2-d9aee83dae → 0.11.0-75c3fbebc3}/setup.css +0 -0
  33. /package/dist/extension/g/{0.9.2-d9aee83dae → 0.11.0-75c3fbebc3}/setup.html +0 -0
  34. /package/dist/extension/g/{0.9.2-d9aee83dae → 0.11.0-75c3fbebc3}/setup.js +0 -0
@@ -25,6 +25,10 @@ export declare const NO_UPDATE_CHECK_ENV: string;
25
25
  export declare const DESIGN_HARNESS_ENV: string;
26
26
  export declare const API_URL_ENV: string;
27
27
  export declare const NO_IDLE_STOP_ENV: string;
28
+ export declare const PROJECTS_FILE: string;
29
+ export declare const HOME_PATH = "/__ezdesign/home";
30
+ export declare const LOGIN_ENV_VAR: string;
31
+ export declare const LOGIN_ENV_CACHE: string;
28
32
  /** Unset, empty, `0` and `false` are off; anything else is on. */
29
33
  export declare function envFlagOn(raw: string | undefined): boolean;
30
34
  export declare const DEFAULT_CONTROL_PORT = 4400;
@@ -50,10 +54,6 @@ export declare function controlPortRange(): {
50
54
  /** Surfaces a bad value at the command the user just ran, instead of leaving it
51
55
  * to a detached daemon whose message only reaches the log file. */
52
56
  export declare function assertControlPortEnv(): void;
53
- /** Per-file cap on a pasted attachment. A retina screenshot runs 2-5 MB, so this
54
- * clears the case the feature exists for while keeping a stray video out.
55
- * Mirrored in `src/client/attach.ts`, which cannot import from this module. */
56
- export declare const MAX_ATTACHMENT_BYTES: number;
57
57
  /** How long an attachment nothing references survives the sweep. Long enough
58
58
  * that a composer left open across a daemon restart still resolves its ids. */
59
59
  export declare const ATTACHMENT_GRACE_MS: number;
@@ -73,3 +73,7 @@ export declare const SHELL_RETRY_MS = 1000;
73
73
  * left open on it to reconnect: one retry, its connect, and slack. */
74
74
  export declare const SHELL_RETURN_MS = 2000;
75
75
  export declare const SOURCE_ATTR = "data-ez-source";
76
+ export declare const DEV_SERVER_READY_MS = 60000;
77
+ export declare const DEV_SERVER_PORT_SCAN_AFTER_MS = 3000;
78
+ export declare const DEV_SERVER_STOP_GRACE_MS = 3000;
79
+ export declare const DEV_SERVER_LOG_LINES = 2000;
@@ -0,0 +1 @@
1
+ "use strict";(()=>{function K(e,t,n){let i=n.width/t.width,o=n.height/t.height,c=(se,le)=>Math.min(le,Math.max(0,se)),s=c(Math.floor(e.x*i+1e-6),n.width),h=c(Math.floor(e.y*o+1e-6),n.height),ae=c(Math.ceil((e.x+e.width)*i-1e-6),n.width),oe=c(Math.ceil((e.y+e.height)*o-1e-6),n.height);return{x:s,y:h,width:ae-s,height:oe-h}}var $={permissions:["webRequest"],origins:["<all_urls>"]};var U="dialog:";function M(e){let t=e.normalize("NFC").trim().replace(/\s+/g," ");return t===""||t.length>64||/[,,]/.test(t)?null:ce(t)}function ce(e){let[t="",n=""]=e;return n!==n.toLowerCase()?e:t.toLowerCase()+e.slice(t.length)}function f(e){return e.normalize("NFKC").trim().replace(/\s+/g," ").toLowerCase()}var W={locked:[],chips:[],draft:"",highlighted:null},de=/[,,]/;function T(e){return[...e.locked,...e.chips]}function R(e,t){let n=M(t);return n===null||T(e).some(i=>f(i)===f(n))?e:{...e,chips:[...e.chips,n]}}function u(e,t,n){switch(t.type){case"input":{let i=t.value.split(de),o=i.pop()??"";return{...i.reduce(R,e),draft:o,highlighted:null}}case"enter":{let i=e.highlighted===null?e.draft:n[e.highlighted];return{...R(e,i??e.draft),draft:"",highlighted:null}}case"backspace":return e.draft===""&&e.chips.length?{...e,chips:e.chips.slice(0,-1),highlighted:null}:e;case"arrow":{if(n.length===0)return{...e,highlighted:null};let i=e.highlighted??(t.delta===1?-1:n.length);return{...e,highlighted:(i+t.delta+n.length)%n.length}}case"pick":return{...R(e,t.name),draft:"",highlighted:null};case"remove":return{...e,chips:e.chips.filter((i,o)=>o!==t.index)};case"lock":{let i=[];for(let c of t.names){let s=M(c);s&&!i.some(h=>f(h)===f(s))&&i.push(s)}let o=e.chips.filter(c=>!i.some(s=>f(s)===f(c)));return{...e,locked:i,chips:o}}}}var ue=location.hash.slice(1),D=window.top===window;document.documentElement.dataset.where=D?"window":"page";var O=chrome.runtime.connect({name:U+ue}),g=e=>O.postMessage(e),j=()=>performance.timeOrigin+performance.now(),Q="\u53EF\u7559\u7A7A\u6216\u591A\u500B\uFF0C\u4EE5 Enter \u6216\u9017\u865F\u9694\u958B",pe="\u4E32\u6D41\u5F71\u7247\u53EA\u6703\u5132\u5B58\u9023\u7D50\u3001\u76EE\u524D\u6642\u9593\u548C\u756B\u9762",ge="\u5F71\u7247\u8D85\u904E 200 MB\uFF0C\u53EA\u6703\u5132\u5B58\u9023\u7D50\u548C\u756B\u9762",me="\u6B63\u5728\u627E\u5F71\u7247\u7684\u539F\u59CB\u6A94\u2026",he=e=>`\u9019\u652F\u5F71\u7247\u7121\u6CD5\u76F4\u63A5\u4E0B\u8F09\uFF0C\u6309\u4E0B\u5132\u5B58\u5F8C\u6703\u5F9E\u982D\u64AD\u653E\u4E00\u6B21\u4E26\u9304\u4E0B\u4F86\uFF08\u7D04 ${e} \u79D2\uFF09\uFF0C\u9304\u5B8C\u524D\u8ACB\u4E0D\u8981\u95DC\u9589\u9019\u500B\u5206\u9801`;function a(e,t={},...n){let i=document.createElement(e);for(let[o,c]of Object.entries(t))i.setAttribute(o,c);return i.append(...n),i}var L=a("div",{class:"overlay"}),G=a("section",{class:"card",role:"dialog","aria-modal":"true","aria-labelledby":"ez-title"}),fe=a("h1",{id:"ez-title"},"\u5132\u5B58\u81F3 ezdesign"),_=a("p",{class:"source"}),p=a("figure",{class:"preview",hidden:""}),Y=a("span",{class:"chips"}),l=a("input",{type:"text",role:"combobox","aria-label":"\u6A19\u7C64","aria-autocomplete":"list","aria-expanded":"false","aria-controls":"ez-suggestions","data-testid":"ez-capture-tag-input",placeholder:Q,autocomplete:"off",spellcheck:"false"}),ye=a("div",{class:"tags"},Y,l),v=a("ul",{id:"ez-suggestions",role:"listbox","aria-label":"\u6A19\u7C64\u5EFA\u8B70","data-testid":"ez-capture-tag-suggestions",hidden:""}),z=a("textarea",{"aria-label":"\u70BA\u4EC0\u9EBC\u597D","data-testid":"ez-capture-note",rows:"3",placeholder:"\u53EF\u7559\u7A7A"}),N=a("p",{class:"status",role:"status","data-testid":"ez-capture-status"}),F=a("code"),k=a("button",{type:"button",class:"quiet"},"\u8907\u88FD"),J=a("div",{class:"install","data-testid":"ez-capture-install",hidden:""},F,k),m=a("button",{type:"button",class:"grant",hidden:""}),b=a("button",{type:"button",class:"grant","data-testid":"ez-capture-streams",hidden:""},"\u5141\u8A31\u8B80\u53D6\u7DB2\u9801\u4E0A\u7684\u5F71\u7247\u4F86\u6E90\uFF0C\u4E4B\u5F8C\u5B58\u5F71\u7247\u4E0D\u7528\u7B49\u5B83\u64AD\u5B8C"),Z=a("button",{type:"button","data-testid":"ez-capture-cancel"},"\u53D6\u6D88"),E=a("button",{type:"button",class:"primary","data-testid":"ez-capture-save"},"\u5132\u5B58"),q=a("header",{},fe,_);G.append(...D?[q,p]:[p,q],a("div",{class:"field"},a("span",{class:"label","aria-hidden":"true"},"\u6A19\u7C64"),a("div",{class:"combo"},ye,v)),a("div",{class:"field"},a("span",{class:"label","aria-hidden":"true"},"\u70BA\u4EC0\u9EBC\u597D"),z),N,J,m,b,a("footer",{},Z,E));L.append(G);document.body.append(L);var P=null,r=W,d=[],X=!1,S=!1,C=null,x=null;function ee(){if(C===null||x===null||x.nonce!==C)return;let{bitmap:e}=x;C=null,x=null,ie(e,e.width,e.height)}function y(){let e=r.locked.map(n=>a("span",{class:"chip locked",title:"\u5DF2\u6536\u85CF\u904E\u7684\u6A19\u7C64"},n)),t=r.chips.map((n,i)=>{let o=a("button",{type:"button",class:"chip","aria-label":`\u79FB\u9664\u6A19\u7C64 ${n}`},a("span",{},n),a("span",{class:"x","aria-hidden":"true"},"\xD7"));return o.addEventListener("click",()=>{r=u(r,{type:"remove",index:i},[]),y(),l.focus(),te()}),o});Y.replaceChildren(...e,...t),l.placeholder=e.length+t.length?"":Q,l.value!==r.draft&&(l.value=r.draft),w()}function w(){let e=r.draft.trim()!==""&&d.length>0;v.hidden=!e,l.setAttribute("aria-expanded",String(e)),v.replaceChildren(...d.map((t,n)=>{let i=a("li",{role:"option",id:`ez-suggestion-${n}`,"aria-selected":String(n===r.highlighted)},a("span",{class:"name"},t.name),a("span",{class:"uses"},String(t.uses)));return n===r.highlighted&&(i.dataset.active=""),i.addEventListener("mousedown",o=>{o.preventDefault(),ne(t.name)}),i})),e&&r.highlighted!==null?l.setAttribute("aria-activedescendant",`ez-suggestion-${r.highlighted}`):l.removeAttribute("aria-activedescendant")}function te(){if(r.draft.trim()===""){d=[],w();return}g({type:"suggest",prefix:r.draft.trim(),exclude:T(r)})}function ne(e){r=u(r,{type:"pick",name:e},[]),d=[],y(),l.focus()}var I=()=>d.map(e=>e.name);l.addEventListener("input",()=>{let e=r.chips.length;r=u(r,{type:"input",value:l.value},I()),r.chips.length!==e&&(d=[]),y(),te()});l.addEventListener("keydown",e=>{e.isComposing||((e.key==="ArrowDown"||e.key==="ArrowUp")&&d.length?(e.preventDefault(),r=u(r,{type:"arrow",delta:e.key==="ArrowDown"?1:-1},I()),w()):e.key==="Enter"&&!(e.metaKey||e.ctrlKey)?(e.preventDefault(),r=u(r,{type:"enter"},I()),d=[],y()):e.key==="Tab"&&r.highlighted!==null&&!v.hidden?(e.preventDefault(),ne(d[r.highlighted].name)):e.key==="Backspace"&&l.value===""&&(r=u(r,{type:"backspace"},I()),y()))});l.addEventListener("blur",()=>{d=[],w()});function re(){S||!P||P.confirm!=="enabled"||(r.draft.trim()&&(r=u(r,{type:"enter"},[])),r={...r,highlighted:null},y(),g({type:"confirm",tags:T(r),note:z.value}))}function H(e){if(S)return;S=!0,document.documentElement.dataset.leaving=e,D||window.parent.postMessage({type:"ez-capture-leaving",how:e},"*");let t=matchMedia("(prefers-reduced-motion: reduce)").matches,n=()=>g({type:"closed"});t?setTimeout(n,120):G.addEventListener("animationend",n,{once:!0})}function V(){S||(g({type:"cancel"}),H("cancelled"))}E.addEventListener("click",re);Z.addEventListener("click",V);L.addEventListener("mousedown",e=>{e.target===L&&V()});document.addEventListener("keydown",e=>{e.key==="Escape"?(e.preventDefault(),v.hidden?V():(d=[],w())):e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),re())});k.addEventListener("click",()=>{navigator.clipboard.writeText(F.textContent??"").then(()=>{k.textContent="\u5DF2\u8907\u88FD",setTimeout(()=>k.textContent="\u8907\u88FD",1500)})});m.addEventListener("click",()=>{let e=m.dataset.origin;e&&(m.disabled=!0,chrome.permissions.request({origins:[`${e}/*`]}).then(t=>g({type:t?"granted":"denied",origin:e}),()=>g({type:"denied",origin:e})))});b.addEventListener("click",()=>{b.disabled=!0,chrome.permissions.request($).then(e=>{e?g({type:"streams-granted"}):b.disabled=!1},()=>b.disabled=!1)});function be(e){switch(e.host.type){case"missing":return"\u9084\u6C92\u6709\u5B89\u88DD ezdesign host\uFF0C\u5728\u7D42\u7AEF\u6A5F\u57F7\u884C\u9019\u884C\u6307\u4EE4\u5F8C\u518D\u5B58\u4E00\u6B21\uFF1A";case"incompatible":return e.host.older==="host"?"ezdesign host \u7248\u672C\u592A\u820A\uFF0C\u66F4\u65B0\u5F8C\u518D\u5B58\u4E00\u6B21\uFF1A":"\u9019\u500B\u64F4\u5145\u529F\u80FD\u7248\u672C\u592A\u820A\uFF0C\u66F4\u65B0\u5F8C\u518D\u5B58\u4E00\u6B21\uFF1A";case"broken":return e.host.message;default:return null}}function we(e){P=e,_.textContent=e.page.title||e.page.url,_.title=e.page.url,e.duplicate&&!X&&(X=!0,r=u(r,{type:"lock",names:e.duplicate.tags},[]),z.value===""&&(z.value=e.duplicate.note),y());let t=be(e),n=e.host.type==="missing"||e.host.type==="incompatible"?e.host.installCommand:null;J.hidden=n===null,F.textContent=n??"",b.hidden=e.offer!=="streams";let i=e.staging.type==="needs-permission"?e.staging.origin:null;m.hidden=i===null,i&&(m.dataset.origin=i,m.textContent=`\u5141\u8A31\u8B80\u53D6 ${i}`,m.disabled=!1);let o=t??e.error??(e.staging.type==="failed"?e.staging.message:null)??(i?"\u9019\u5F35\u5716\u7247\u9700\u8981\u4F60\u5728\u9019\u500B\u7DB2\u7AD9\u7684\u767B\u5165\u72C0\u614B\u624D\u80FD\u8B80\u53D6\u3002":null)??(e.finding?me:null)??(e.staging.type==="recording"?`\u6B63\u5728\u9304\u88FD\u5F71\u7247 ${Math.floor(e.staging.seconds)} / ${Math.round(e.staging.total)} \u79D2`:null)??(e.notice==="record"&&e.recordSeconds!==null?he(e.recordSeconds):e.notice==="stream-link"?pe:e.notice==="too-large"?ge:null)??(e.duplicate?"\u5DF2\u6536\u85CF\u904E":"");N.textContent=o,N.dataset.tone=t||e.error||e.staging.type==="failed"?"error":"info",E.disabled=e.confirm!=="enabled",E.textContent=e.confirm==="saving"?"\u5132\u5B58\u4E2D\u2026":e.confirm==="saved"?"\u5DF2\u5132\u5B58":"\u5132\u5B58",E.setAttribute("aria-busy",String(e.confirm==="saving")),e.confirm==="saved"&&H("saved")}var xe="min(300px, max(96px, 100vh - 400px))",Ee=1200;function B(e,t){e.style.aspectRatio=`${t.width} / ${t.height}`,e.style.width=`min(100%, ${t.width}px, calc(${xe} * ${t.width/t.height}))`}function A(e){if(!e||p.childElementCount)return;let t=a("div",{class:"slot","aria-hidden":"true"});B(t,e),p.replaceChildren(t),p.hidden=!1}function ie(e,t,n,i){let o=i??{x:0,y:0,width:t,height:n},c=Math.min(1,Ee/Math.max(o.width,o.height)),s=a("canvas",{"data-testid":"ez-capture-preview",role:"img","aria-label":"\u9810\u89BD"});B(s,o),s.width=Math.max(1,Math.round(o.width*c)),s.height=Math.max(1,Math.round(o.height*c));let h=s.getContext("2d");h.imageSmoothingQuality="high",h.drawImage(e,o.x,o.y,o.width,o.height,0,0,s.width,s.height),p.replaceChildren(s),p.hidden=!1,requestAnimationFrame(()=>g({type:"preview-shown",at:j()}))}async function ve(e){switch(e.type){case"bitmap":A(e.size),C=e.nonce,ee();return;case"screenshot":{A(e.rect??e.viewport);let t=new Image;t.src=e.dataUrl,await t.decode();let n={width:t.naturalWidth,height:t.naturalHeight};ie(t,n.width,n.height,e.rect?K(e.rect,e.viewport,n):void 0);return}case"url":{A(e.size);let t=a("img",{"data-testid":"ez-capture-preview",alt:"\u9810\u89BD",src:e.src});e.size&&B(t,e.size),await t.decode().catch(()=>{}),p.replaceChildren(t),p.hidden=!1,requestAnimationFrame(()=>g({type:"preview-shown",at:j()}));return}case"none":return}}window.addEventListener("message",e=>{let t=e.data;e.source!==window.parent||t?.type!=="ez-capture-preview"||(x=t,ee())});O.onMessage.addListener(e=>{let t=e;t.type==="preview"?ve(t.preview):t.type==="view"?we(t.view):t.type==="suggestions"&&t.prefix===r.draft.trim()&&(d=t.tags,r={...r,highlighted:null},w())});O.onDisconnect.addListener(()=>H("cancelled"));window.addEventListener("focus",()=>{!S&&(document.activeElement===document.body||document.activeElement===null)&&l.focus()});l.focus();})();
@@ -0,0 +1 @@
1
+ "use strict";(()=>{function g(t){let r="";for(let e=0;e<t.length;e+=32768)r+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(r)}function p(t){let r=atob(t),e=new Uint8Array(r.length);for(let n=0;n<r.length;n++)e[n]=r.charCodeAt(n);return e}function f(t,r,e){let n=e.width/r.width,a=e.height/r.height,o=(h,w)=>Math.min(w,Math.max(0,h)),i=o(Math.floor(t.x*n+1e-6),e.width),c=o(Math.floor(t.y*a+1e-6),e.height),s=o(Math.ceil((t.x+t.width)*n-1e-6),e.width),m=o(Math.ceil((t.y+t.height)*a-1e-6),e.height);return{x:i,y:c,width:s-i,height:m-c}}function b(t){let r=Number.isFinite(t)&&t>0?t:0,e=[0,.5,1,2,r*.1,r*.25].filter(n=>n===0||n<r);return[...new Set(e.map(n=>Math.round(n*1e3)/1e3))].sort((n,a)=>n-a)}var u=16,M=4;function y(t){let r=t.length/4;if(!r)return!0;let e=0,n=0;for(let o=0;o<t.length;o+=4){let i=.299*t[o]+.587*t[o+1]+.114*t[o+2];e+=i,n+=i*i}let a=e/r;return Math.sqrt(Math.max(0,n/r-a*a))<M}function x(t,r){let e=Math.min(1,400/Math.max(t,r));return{width:Math.max(1,Math.round(t*e)),height:Math.max(1,Math.round(r*e))}}var E="image/webp",v=.8;async function L(t,r){let e=x(r.width,r.height),n=t,{width:a,height:o}=r;for(;a/2>=e.width*2&&o/2>=e.height*2;){a=Math.round(a/2),o=Math.round(o/2);let m=new OffscreenCanvas(a,o),h=m.getContext("2d");h.imageSmoothingQuality="high",h.drawImage(n,0,0,a,o),n=m}let i=new OffscreenCanvas(e.width,e.height),c=i.getContext("2d");c.imageSmoothingQuality="high",c.drawImage(n,0,0,e.width,e.height);let s=await i.convertToBlob({type:E,quality:v});if(s.type!==E)throw new Error(`this browser encodes ${s.type}, not WebP`);return{webp:new Uint8Array(await s.arrayBuffer()),...e,source:{...r}}}async function l(t,r){let e=await L(t,r);return{...e,webp:g(e.webp)}}var d=new Map;async function A(t){let r=new Blob(t),e=await createImageBitmap(r).catch(()=>null);if(e)try{return await l(e,{width:e.width,height:e.height})}finally{e.close()}let n=URL.createObjectURL(new Blob(t,{type:"image/svg+xml"}));try{let a=new Image;return await new Promise((o,i)=>{a.onload=()=>o(),a.onerror=()=>i(new Error("cannot decode")),a.src=n}),!a.naturalWidth||!a.naturalHeight?null:await l(a,{width:a.naturalWidth,height:a.naturalHeight})}catch{return null}finally{URL.revokeObjectURL(n)}}async function S(t,r){let e=URL.createObjectURL(new Blob(t)),n=document.createElement("video");n.muted=!0,n.preload="auto";try{let a=i=>new Promise((c,s)=>{n.addEventListener(i,()=>c(),{once:!0}),n.addEventListener("error",()=>s(new Error("cannot decode the video")),{once:!0})});n.src=e,await a("loadeddata");let o=async i=>{n.currentTime=Math.min(i,Math.max(0,n.duration-.001)),await a("seeked")};if(r==="opening"){let i=new OffscreenCanvas(u,u).getContext("2d",{willReadFrequently:!0}),c=b(n.duration);for(let s of c){if(await o(s),i.drawImage(n,0,0,u,u),!y(i.getImageData(0,0,u,u).data))break;s===c.at(-1)&&await o(0)}}else await o(r);return n.videoWidth?await l(n,{width:n.videoWidth,height:n.videoHeight}):null}catch{return null}finally{n.removeAttribute("src"),n.load(),URL.revokeObjectURL(e)}}async function T(t){let r=await(await fetch(t.screenshot)).blob(),e=await createImageBitmap(r),n={width:e.width,height:e.height},a=t.rect?f(t.rect,t.viewport,n):{x:0,y:0,...n};if(a.width<1||a.height<1)return{original:null,thumb:null};let o=await createImageBitmap(e,a.x,a.y,a.width,a.height),i={width:a.width,height:a.height},c=async()=>{if(!t.original)return null;let h=new OffscreenCanvas(i.width,i.height);h.getContext("2d").drawImage(o,0,0);let w=await h.convertToBlob({type:"image/png"});return{png:g(new Uint8Array(await w.arrayBuffer())),size:i}},[s,m]=await Promise.all([l(o,i),c()]);return{original:m,thumb:s}}async function B(t){switch(t.type){case"feed":return d.set(t.job,[...d.get(t.job)??[],p(t.data)]),{};case"thumbnail":{let r=d.get(t.job)??[];return d.delete(t.job),{thumb:t.at===null?await A(r):await S(r,t.at)}}case"crop":return T(t);case"drop":return d.delete(t.job),{}}}function I(t){return t.type==="thumbnail"?{thumb:null}:t.type==="crop"?{original:null,thumb:null}:{}}chrome.runtime.onMessage.addListener((t,r,e)=>{let n=t;if(!(n?.to!=="media"||r.id!==chrome.runtime.id))return B(n).then(e,()=>e(I(n))),!0});})();
@@ -0,0 +1,44 @@
1
+ "use strict";(()=>{function T(e){let n="";for(let o=0;o<e.length;o+=32768)n+=String.fromCharCode(...e.subarray(o,o+32768));return btoa(n)}function X(e,n){let o=Math.min(1,400/Math.max(e,n));return{width:Math.max(1,Math.round(e*o)),height:Math.max(1,Math.round(n*o))}}var q="image/webp",we=.8;async function Q(e,n){let o=X(n.width,n.height),t=e,{width:i,height:s}=n;for(;i/2>=o.width*2&&s/2>=o.height*2;){i=Math.round(i/2),s=Math.round(s/2);let f=new OffscreenCanvas(i,s),p=f.getContext("2d");p.imageSmoothingQuality="high",p.drawImage(t,0,0,i,s),t=f}let c=new OffscreenCanvas(o.width,o.height),d=c.getContext("2d");d.imageSmoothingQuality="high",d.drawImage(t,0,0,o.width,o.height);let u=await c.convertToBlob({type:q,quality:we});if(u.type!==q)throw new Error(`this browser encodes ${u.type}, not WebP`);return{webp:new Uint8Array(await u.arrayBuffer()),...o,source:{...n}}}async function J(e,n){let o=await Q(e,n);return{...o,webp:T(o.webp)}}async function Z(e,n){let o=new OffscreenCanvas(n.width,n.height);o.getContext("2d").drawImage(e,0,0,n.width,n.height);let t=await o.convertToBlob({type:"image/png"});return T(new Uint8Array(await t.arrayBuffer()))}var O="data-ez-capture-target";var N=null,H=null;function te(e){H=e}function V(e){let n=[e.currentSrc,e.getAttribute("src")?e.src:""];return e instanceof HTMLVideoElement&&n.push(...[...e.querySelectorAll("source")].map(o=>o.src)),n.filter(Boolean)}function ee(e){let n=e.getBoundingClientRect(),o=Math.max(0,Math.min(n.right,innerWidth)-Math.max(n.left,0)),t=Math.max(0,Math.min(n.bottom,innerHeight)-Math.max(n.top,0));return o*t}function G(e){return V(e)[0]??null}function W(e,n){if(H?.isConnected&&V(H).includes(e))return H;let t=[...document.querySelectorAll(n==="image"?"img":"video")].filter(i=>V(i).includes(e));return t.length<=1?t[0]??null:t.find(i=>i.matches(":hover"))??t.sort((i,s)=>ee(s)-ee(i))[0]}function xe(e){let n=e.getBoundingClientRect(),o=Math.max(0,n.left),t=Math.max(0,n.top),i=Math.min(innerWidth,n.right)-o,s=Math.min(innerHeight,n.bottom)-t;return i>0&&s>0?{x:o,y:t,width:i,height:s}:null}async function ve(e,n){if(e.readyState<HTMLMediaElement.HAVE_CURRENT_DATA||!e.videoWidth)return{type:"empty"};if(e.mediaKeys)return{type:"protected"};let o={width:e.videoWidth,height:e.videoHeight};try{let[t,i]=await Promise.all([J(e,o),n?Z(e,o):null]);return{type:"encoded",thumb:t,png:i}}catch(t){if(t.name==="SecurityError")return{type:"tainted"};throw t}}async function ne(e,n,o){let t=W(e,n);N?.removeAttribute(O),N=t,t?.setAttribute(O,"");let i={width:innerWidth,height:innerHeight};if(!t)return{found:!1,viewport:i,rect:null,natural:null,video:null};let s=t instanceof HTMLVideoElement?{width:t.videoWidth,height:t.videoHeight}:{width:t.naturalWidth,height:t.naturalHeight};return{found:!0,viewport:i,rect:xe(t),natural:s.width&&s.height?s:null,video:t instanceof HTMLVideoElement?{currentTime:t.currentTime,duration:Number.isFinite(t.duration)?t.duration:null,poster:/^https?:\/\//i.test(t.poster)?t.poster:null,frame:await ve(t,o)}:null}}function oe(){return N?.isConnected?N:null}async function re(e){try{return T(new Uint8Array(await(await fetch(e)).arrayBuffer()))}catch{return null}}var Ee=`
2
+ :host { all: initial; }
3
+ .pill {
4
+ position: fixed; top: 16px; left: 50%; z-index: 2147483647;
5
+ display: flex; align-items: center; gap: 6px;
6
+ padding: 6px 12px 6px 9px; border-radius: 8px; color: #fff; pointer-events: none;
7
+ background: oklch(0% 0 0 / 0.78); backdrop-filter: blur(16px) saturate(1.6);
8
+ box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1), 0 4px 16px oklch(0% 0 0 / 0.16);
9
+ font: 500 12px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
10
+ transform: translateX(-50%);
11
+ animation: in 0.22s cubic-bezier(0.23, 1, 0.32, 1) both;
12
+ }
13
+ .pill[data-leaving] { animation: out 0.18s cubic-bezier(0.23, 1, 0.32, 1) both; }
14
+ svg { flex-shrink: 0; }
15
+ .spin { animation: spin 0.9s linear infinite; }
16
+ .pill { font-variant-numeric: tabular-nums; }
17
+ @keyframes spin { to { transform: rotate(360deg); } }
18
+ @keyframes in { from { opacity: 0; transform: translate(-50%, -6px) scale(0.96); } }
19
+ @keyframes out { to { opacity: 0; } }
20
+ @media (prefers-reduced-motion: reduce) {
21
+ @keyframes in { from { opacity: 0; } }
22
+ .spin { animation: none; }
23
+ }
24
+ `,L="http://www.w3.org/2000/svg";function Me(){let e=document.createElementNS(L,"svg");for(let[o,t]of Object.entries({width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"}))e.setAttribute(o,t);let n=document.createElementNS(L,"path");for(let[o,t]of Object.entries({d:"M5 12.5 10 17.5 19 7",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"}))n.setAttribute(o,t);return e.append(n),e}var Te={done:1600,error:4e3};function Se(){let e=document.createElementNS(L,"svg");for(let[o,t]of Object.entries({width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",class:"spin"}))e.setAttribute(o,t);let n=document.createElementNS(L,"path");for(let[o,t]of Object.entries({d:"M21 12a9 9 0 1 1-6.2-8.56",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round"}))n.setAttribute(o,t);return e.append(n),e}function ke(){let e=document.createElementNS(L,"svg");for(let[o,t]of Object.entries({width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"}))e.setAttribute(o,t);let n=document.createElementNS(L,"path");for(let[o,t]of Object.entries({d:"M12 7v6M12 17h.01",stroke:"currentColor","stroke-width":"2.4","stroke-linecap":"round"}))n.setAttribute(o,t);return e.append(n),e}var ie={working:Se,done:Me,error:ke},l=null,ae=()=>new Promise(e=>requestAnimationFrame(e));function Ae(e){e.pill.dataset.leaving="",e.pill.addEventListener("animationend",()=>{e.host.remove(),l===e&&(l=null)},{once:!0})}function z(e,n){if(l&&!l.pill.dataset.leaving)l.timer&&clearTimeout(l.timer),l.label.textContent=e,l.tone!==n&&l.pill.firstElementChild.replaceWith(ie[n]()),l.tone=n;else{l&&l.host.remove();let t=document.createElement("div");t.setAttribute("data-ez-capture-saved",""),t.style.cssText="all: initial; position: fixed; z-index: 2147483647";let i=t.attachShadow({mode:"closed"}),s=document.createElement("style");s.textContent=Ee;let c=document.createElement("div");c.className="pill",c.setAttribute("role","status");let d=document.createElement("span");d.textContent=e,c.append(ie[n](),d),i.append(s,c),document.documentElement.append(t),l={host:t,pill:c,label:d,tone:n,timer:null}}let o=l;o.timer=n==="working"?null:setTimeout(()=>Ae(o),Te[n])}function se(){z("\u5DF2\u5132\u5B58","done")}async function D(){l&&(l.timer&&clearTimeout(l.timer),l.host.remove(),l=null,await ae(),await ae())}var U=new Map,Le=["position: fixed","inset: 0","width: 100vw","height: 100vh","margin: 0","padding: 0","border: 0","background: transparent","color-scheme: light","backdrop-filter: blur(0px)","transition: backdrop-filter 0.22s cubic-bezier(0.23, 1, 0.32, 1)","z-index: 2147483647"].join("; "),Ce="blur(4px)";async function ce(e){let n=document.createElement("div");n.setAttribute("data-ez-capture",""),n.style.cssText="all: initial; position: fixed; inset: 0; z-index: 2147483647";let o=n.attachShadow({mode:"closed"}),t=document.createElement("iframe");t.setAttribute("style",Le),t.setAttribute("allow","clipboard-write"),t.src=chrome.runtime.getURL(e.dialogPath),o.append(t);let i=new Promise(u=>{t.addEventListener("load",()=>u(!0),{once:!0}),t.addEventListener("error",()=>u(!1),{once:!0})}),s=new AbortController;if(document.documentElement.append(n),U.set(e.captureId,{host:n,listening:s}),!await i||!t.contentWindow)return F(e.captureId),{mounted:!1,handedOff:!1};t.focus(),requestAnimationFrame(()=>t.style.backdropFilter=Ce),addEventListener("message",u=>{let f=u.data;u.source!==t.contentWindow||f?.type!=="ez-capture-leaving"||(t.style.backdropFilter="blur(0px)",f.how==="saved"&&se())},{signal:s.signal});let c=e.bitmap?oe():null,d=c&&await createImageBitmap(c).catch(()=>null);if(!d)return{mounted:!0,handedOff:!1};try{let u={type:"ez-capture-preview",nonce:e.nonce,bitmap:d};return t.contentWindow.postMessage(u,"*",[d]),{mounted:!0,handedOff:!0}}catch{return d.close(),{mounted:!0,handedOff:!1}}}function F(e){let n=U.get(e);n?.listening.abort(),n?.host.remove(),U.delete(e)}var Pe=40*1024*1024,Re=8e6,_e=500,Ie=1e4,B=5e3,He=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"],C=new Map,Ne=100,Be=e=>new Promise(n=>setTimeout(n,e)),$=(e,n,o)=>new Promise(t=>{let i=setTimeout(()=>t(!1),o);e.addEventListener(n,()=>(clearTimeout(i),t(!0)),{once:!0})});async function de(e,n,o){let t=W(n,"video");if(!(t instanceof HTMLVideoElement))return{ok:!1,reason:"the video is no longer on the page"};if(t.mediaKeys)return{ok:!1,reason:"the video is protected"};let i=He.find(h=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(h));if(!i||!t.captureStream)return{ok:!1,reason:"this browser cannot record a video"};let s=Math.min(o,Number.isFinite(t.duration)?t.duration:o),c={time:t.currentTime,paused:t.paused,loop:t.loop,rate:t.playbackRate},d;try{d=t.captureStream()}catch(h){return{ok:!1,reason:h.name==="SecurityError"?"the video is from another site":String(h)}}let u=()=>{t.loop=c.loop,t.playbackRate=c.rate,t.currentTime=c.time,c.paused?t.pause():t.play().catch(()=>{})};t.pause(),t.loop=!1,t.playbackRate=1,t.currentTime!==0&&(t.currentTime=0,await $(t,"seeked",B));let f=await Promise.race([t.play().then(()=>!0,()=>!1),Be(B).then(()=>!1)]);f&&!d.getVideoTracks().length&&await $(d,"addtrack",B);let p=d.getVideoTracks()[0];if(!f||!p)return u(),{ok:!1,reason:"the video would not play"};let m=new MediaRecorder(new MediaStream([p]),{mimeType:i,videoBitsPerSecond:Math.min(Re,Math.floor(Pe*8/Math.max(1,s)))}),x=[];m.ondataavailable=h=>{h.data.size&&x.push(h.data)};let g=new Promise(h=>{let S=-1,k=performance.now(),_=0,A=setInterval(()=>{let r=performance.now();if(t.currentTime!==S&&(S=t.currentTime,k=r),document.hidden&&(k=r),r-_>=_e){_=r;let y={to:"worker",type:"record-progress",captureId:e,seconds:Math.min(s,S)};chrome.runtime.sendMessage(y).catch(()=>{})}t.ended||t.currentTime>=s-.02?a("done"):r-k>Ie&&a("stalled")},Ne),R=()=>a("done"),E=()=>{if(document.hidden){m.state==="recording"&&m.pause();return}t.paused&&!t.ended&&t.play().catch(()=>{}),m.state==="paused"&&m.resume()};t.addEventListener("ended",R),document.addEventListener("visibilitychange",E);let a=r=>{clearInterval(A),t.removeEventListener("ended",R),document.removeEventListener("visibilitychange",E),h(r)};C.set(e,{state:"running",stop:()=>a("dropped")})});m.start(1e3);let b=await g,v=$(m,"stop",B);if(m.stop(),await v,p.stop(),u(),b!=="done")return C.delete(e),{ok:!1,reason:b==="stalled"?"the video stopped playing":"the recording was called off"};let w=new Blob(x,{type:m.mimeType||"video/webm"});return C.set(e,{state:"done",blob:w}),{ok:!0,bytes:w.size}}async function le(e,n,o){let t=C.get(e);if(t?.state!=="done")throw new Error("no finished recording");return{data:T(new Uint8Array(await t.blob.slice(n,n+o).arrayBuffer()))}}function ue(e){let n=C.get(e);n?.state==="running"&&n.stop(),C.delete(e)}function j(e,n){return{x:Math.round(Math.min(e.x,n.x)),y:Math.round(Math.min(e.y,n.y)),width:Math.round(Math.abs(n.x-e.x)),height:Math.round(Math.abs(n.y-e.y))}}function K(e){return e.width>=8||e.height>=8}var me="#e56d41",Oe=`
25
+ :host { all: initial; }
26
+ .layer { position: fixed; inset: 0; cursor: crosshair; touch-action: none; }
27
+ .shade { position: fixed; background: oklch(0% 0 0 / 0.35); pointer-events: none; }
28
+ .box { position: fixed; pointer-events: none; outline: 1.5px dashed ${me}; outline-offset: -1px; }
29
+ .pick { position: fixed; pointer-events: none; outline: 2px solid ${me}; outline-offset: -2px; background: oklch(70% 0.15 45 / 0.08); }
30
+ .size, .what {
31
+ position: fixed; pointer-events: none; padding: 2px 6px; border-radius: 4px;
32
+ background: #171717; color: #fff; white-space: nowrap;
33
+ font: 500 11px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
34
+ font-variant-numeric: tabular-nums;
35
+ }
36
+ .hint {
37
+ position: fixed; top: 16px; left: 50%; transform: translateX(-50%); pointer-events: none;
38
+ padding: 6px 12px; border-radius: 8px; color: #fff;
39
+ background: oklch(0% 0 0 / 0.78); backdrop-filter: blur(16px) saturate(1.6);
40
+ box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1), 0 4px 16px oklch(0% 0 0 / 0.16);
41
+ font: 500 12px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
42
+ }
43
+ [hidden] { display: none; }
44
+ `,Ve=()=>performance.timeOrigin+performance.now(),pe=24;function he(e,n,o){for(let t of document.elementsFromPoint(e,n)){if(t===o||!(t instanceof HTMLVideoElement||t instanceof HTMLImageElement))continue;let i=t.getBoundingClientRect();if(!(i.width<pe||i.height<pe||!G(t))&&!(t instanceof HTMLImageElement&&!t.naturalWidth))return t}return null}function Ge(e){let n=Math.round(e);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function We(e){return e instanceof HTMLVideoElement?Number.isFinite(e.duration)?`\u5F71\u7247 \xB7 ${Ge(e.duration)}`:"\u5F71\u7247":`\u5716\u7247 \xB7 ${e.naturalWidth} \xD7 ${e.naturalHeight}`}var fe=()=>new Promise(e=>requestAnimationFrame(e));function P(e,n,o,t,i){e.style.left=`${n}px`,e.style.top=`${o}px`,e.style.width=`${Math.max(0,t)}px`,e.style.height=`${Math.max(0,i)}px`}function ge(){let e=document.createElement("div");e.setAttribute("data-ez-capture",""),e.style.cssText="all: initial; position: fixed; inset: 0; z-index: 2147483647";let n=e.attachShadow({mode:"closed"}),o=document.createElement("style");o.textContent=Oe;let t=document.createElement("div");t.className="layer";let i=()=>{let v=document.createElement("div");return v.className="shade",v.hidden=!0,v},[s,c,d,u]=[i(),i(),i(),i()],f=[s,c,d,u],p=document.createElement("div");p.className="box",p.hidden=!0;let m=document.createElement("div");m.className="size",m.hidden=!0;let x=document.createElement("div");x.className="pick",x.hidden=!0;let g=document.createElement("div");g.className="what",g.hidden=!0;let b=document.createElement("div");return b.className="hint",b.textContent="\u9EDE\u64CA\u5A92\u9AD4\uFF0C\u6216\u62D6\u66F3\u5340\u57DF\u622A\u5716\uFF0CEsc \u53D6\u6D88",n.append(o,t,...f,p,m,x,g,b),document.documentElement.append(e),new Promise(v=>{let w=null,h=!1,S=null,k=a=>{if(S=a,x.hidden=g.hidden=!a,w||(b.hidden=!!a),t.style.cursor=a?"pointer":"",!a)return;let r=a.getBoundingClientRect();P(x,r.x,r.y,r.width,r.height),g.textContent=We(a),g.style.left=`${Math.max(0,r.x)}px`,g.style.top=`${Math.max(0,r.y)+6}px`,g.style.transform="translateX(6px)"},_=a=>{let r=j(w,a),y=K(r);y&&k(null);for(let M of f)M.hidden=!y;if(p.hidden=m.hidden=!y,b.hidden=y||b.hidden,!y)return;P(s,0,0,innerWidth,r.y),P(c,0,r.y+r.height,innerWidth,innerHeight-r.y-r.height),P(d,0,r.y,r.x,r.height),P(u,r.x+r.width,r.y,innerWidth-r.x-r.width,r.height),P(p,r.x,r.y,r.width,r.height),m.textContent=`${r.width} \xD7 ${r.height}`;let I=r.y+r.height+28<innerHeight;m.style.left=`${r.x}px`,m.style.top=`${I?r.y+r.height+6:Math.max(0,r.y-26)}px`},A=async a=>{h||(h=!0,removeEventListener("keydown",R,!0),removeEventListener("wheel",E,!0),removeEventListener("touchmove",E,!0),e.remove(),await fe(),await fe(),v(a))},R=a=>{a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),A({type:"cancelled"}))},E=a=>a.preventDefault();t.addEventListener("pointerdown",a=>{a.button===0&&(a.preventDefault(),t.setPointerCapture(a.pointerId),w={x:a.clientX,y:a.clientY})}),t.addEventListener("pointermove",a=>{w?_({x:a.clientX,y:a.clientY}):k(he(a.clientX,a.clientY,e))}),t.addEventListener("pointerup",a=>{if(!w)return;let r=Ve(),y=j(w,{x:a.clientX,y:a.clientY}),I={width:innerWidth,height:innerHeight};if(K(y))return void A({type:"rect",rect:y,viewport:I,pickedAt:r});let M=S??he(a.clientX,a.clientY,e),Y=M&&G(M);if(!M||!Y)return void A({type:"viewport",viewport:I,pickedAt:r});te(M),A({type:"media",mediaType:M instanceof HTMLVideoElement?"video":"image",srcUrl:Y,pickedAt:r})}),addEventListener("keydown",R,!0),addEventListener("wheel",E,{capture:!0,passive:!1}),addEventListener("touchmove",E,{capture:!0,passive:!1})})}var ye=Symbol.for("ezdesign.capture.page-agent"),ze={"select-region":()=>D().then(ge),inspect:e=>D().then(()=>ne(e.srcUrl,e.mediaType,e.fullFrame)),read:async e=>({data:await re(e.url)}),present:e=>ce(e),dismiss:async e=>(F(e.captureId),{}),pill:async e=>(z(e.text,e.tone),{}),record:e=>de(e.captureId,e.srcUrl,e.maxSeconds),"recording-read":e=>le(e.captureId,e.offset,e.length),"recording-drop":async e=>(ue(e.captureId),{})},be=globalThis;be[ye]||(be[ye]=!0,chrome.runtime.onMessage.addListener((e,n,o)=>{let t=e;if(t?.to!=="page"||n.id!==chrome.runtime.id)return;let i=ze[t.type];return i(t).then(o,s=>o({error:String(s)})),!0}));})();