@augmentd-labs/canvas-web 2.15.0 → 2.15.1

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.
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{wt as t,xt as n}from"./react-DQazvoR7.js";import{Ct as r}from"./ui-BX_B5WCf.js";import{In as i,dn as a}from"./workspace-BnBIVxoH.js";import{a as o,d as s}from"./blobs-DnFjQBfZ.js";import{_ as c,a as l,c as u,i as d,n as f,o as p,r as m,t as h}from"./text-documents-CpwLpQdq.js";import{t as g}from"./EditorOverlay-B3kjuXI-.js";var _=e(t(),1),v=n();function y({doc:e,workspaceName:t,onSaved:n,onClose:y,onDetails:b}){let{showSuccessToast:x,showErrorToast:S}=o(),C=e.schema===s,w=d(e),T=w&&l(e),E=m(e)??`markdown`,D=u(t,e.id,{mode:`text`,enabled:w&&!T,maxTextLength:f,version:e.checksumArray?.[0]??null}),[O,k]=(0,_.useState)(C?String(e.data?.content??``):``),[A,j]=(0,_.useState)(null),M=`${e.id}:${e.checksumArray?.[0]??``}`;w&&D.text!=null&&A!==M&&(j(M),k(D.text));let[N,P]=(0,_.useState)(!1),F=C||D.text!=null&&!D.loading,I=async()=>{P(!0);try{C?await a(t,{id:e.id,schema:e.schema,schemaVersion:e.schemaVersion,data:{...e.data,content:O}}):await h(t,e,O),x(`Document saved`),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),n()}catch(e){S(e instanceof Error?e.message:`Failed to save document`)}finally{P(!1)}},L=C?String(e.data?.title??`Note`):c(e)||`document-${e.id}`;return(0,v.jsx)(g,{onClose:y,onDetails:b,title:(0,v.jsx)(`span`,{className:`truncate text-sm font-medium`,children:L}),actions:(0,v.jsxs)(i,{size:`sm`,onClick:I,disabled:N||!F||T,children:[(0,v.jsx)(r,{className:`mr-1.5 h-4 w-4`}),N?`Saving…`:`Save`]}),children:(0,v.jsx)(`div`,{className:`flex h-full min-h-0 flex-col px-4 py-4 md:px-8`,children:(0,v.jsx)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-3xl flex-1 flex-col`,children:T?(0,v.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This file is too large to edit here (`,`>`,Math.round(f/1e3),` kB) — download it instead.`]}):D.error?(0,v.jsx)(`p`,{className:`text-sm text-destructive`,children:D.error}):F?(0,v.jsx)(p,{kind:C?`markdown`:E,value:O,onChange:k,placeholder:C?`Write your note…`:void 0,fill:!0}):(0,v.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading content…`})})})})}export{y as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{wt as t,xt as n}from"./react-DQazvoR7.js";import{Ct as r}from"./ui-BX_B5WCf.js";import{In as i,dn as a}from"./workspace-BnBIVxoH.js";import{f as o,o as s}from"./blobs-bUMClq1N.js";import{_ as c,a as l,c as u,i as d,n as f,o as p,r as m,t as h}from"./text-documents-seImmPVm.js";import{t as g}from"./EditorOverlay-B3kjuXI-.js";var _=e(t(),1),v=n();function y({doc:e,workspaceName:t,onSaved:n,onClose:y,onDetails:b}){let{showSuccessToast:x,showErrorToast:S}=s(),C=e.schema===o,w=d(e),T=w&&l(e),E=m(e)??`markdown`,D=u(t,e.id,{mode:`text`,enabled:w&&!T,maxTextLength:f,version:e.checksumArray?.[0]??null}),[O,k]=(0,_.useState)(C?String(e.data?.content??``):``),[A,j]=(0,_.useState)(null),M=`${e.id}:${e.checksumArray?.[0]??``}`;w&&D.text!=null&&A!==M&&(j(M),k(D.text));let[N,P]=(0,_.useState)(!1),F=C||D.text!=null&&!D.loading,I=async()=>{P(!0);try{C?await a(t,{id:e.id,schema:e.schema,schemaVersion:e.schemaVersion,data:{...e.data,content:O}}):await h(t,e,O),x(`Document saved`),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),n()}catch(e){S(e instanceof Error?e.message:`Failed to save document`)}finally{P(!1)}},L=C?String(e.data?.title??`Note`):c(e)||`document-${e.id}`;return(0,v.jsx)(g,{onClose:y,onDetails:b,title:(0,v.jsx)(`span`,{className:`truncate text-sm font-medium`,children:L}),actions:(0,v.jsxs)(i,{size:`sm`,onClick:I,disabled:N||!F||T,children:[(0,v.jsx)(r,{className:`mr-1.5 h-4 w-4`}),N?`Saving…`:`Save`]}),children:(0,v.jsx)(`div`,{className:`flex h-full min-h-0 flex-col px-4 py-4 md:px-8`,children:(0,v.jsx)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-3xl flex-1 flex-col`,children:T?(0,v.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This file is too large to edit here (`,`>`,Math.round(f/1e3),` kB) — download it instead.`]}):D.error?(0,v.jsx)(`p`,{className:`text-sm text-destructive`,children:D.error}):F?(0,v.jsx)(p,{kind:C?`markdown`:E,value:O,onChange:k,placeholder:C?`Write your note…`:void 0,fill:!0}):(0,v.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading content…`})})})})}export{y as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{wt as t}from"./react-DQazvoR7.js";import{Mn as n,Tn as r}from"./workspace-BnBIVxoH.js";var i=e(t(),1),a=(0,i.createContext)(void 0);function o(){let e=(0,i.useContext)(a);if(e===void 0)throw Error(`useToast must be used within a ToastContainer`);return e}var s=`data/schema/note`,c=`data/schema/link`,l=`data/schema/tab`,u=`data/schema/file`,d=`data/schema/drawing`,f=`data/schema/message/email`,p=`data/schema/task`,m=`data/schema/identity`;function h(e,t){return e.startsWith(`${t}/`)?e.slice(t.length+1):``}var g={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,svg:`image/svg+xml`,avif:`image/avif`,heic:`image/heic`,heif:`image/heif`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,oga:`audio/ogg`,m4a:`audio/mp4`,flac:`audio/flac`,aac:`audio/aac`,mp4:`video/mp4`,m4v:`video/mp4`,webm:`video/webm`,mov:`video/quicktime`,mkv:`video/x-matroska`,avi:`video/x-msvideo`,ogv:`video/ogg`,pdf:`application/pdf`,md:`text/markdown`,markdown:`text/markdown`,txt:`text/plain`,json:`application/json`,xml:`application/xml`,csv:`text/csv`,log:`text/plain`,yml:`text/yaml`,yaml:`text/yaml`};function _(e){let t=/\.([a-z0-9]+)$/i.exec(e||``);return t?t[1].toLowerCase():``}function v(e){return g[_(e)]}function y(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:e===`application/pdf`?`pdf`:e.startsWith(`text/`)||e.endsWith(`+json`)||e===`application/json`||e===`application/xml`?`text`:null}function b(e,t){if(e===`text/markdown`||/\.(md|markdown)$/i.test(t||``))return`markdown`;if(e&&e!==`application/octet-stream`){let t=y(e);if(t)return t}let n=v(t);if(n){let e=y(n);if(e)return e}return`binary`}function x(e){if(!e)return null;try{let t=new URL(e),n=t.hostname.replace(/^www\.|^m\./,``);if(n===`youtu.be`)return t.pathname.slice(1).split(`/`)[0]||null;if(n===`youtube.com`||n===`youtube-nocookie.com`){if(t.pathname===`/watch`)return t.searchParams.get(`v`);let e=t.pathname.match(/^\/(shorts|embed|live)\/([^/]+)/);if(e)return e[2]}return null}catch{return null}}function S(){let{showToast:e}=o();return{showErrorToast:(t,n=`Error`)=>e({title:n,description:t,variant:`destructive`}),showSuccessToast:(t,n=`Success`)=>e({title:n,description:t})}}async function C(e,t){return r.post(`${n.workspaces}/${e}/blobs`,t,{headers:{"Content-Type":`application/octet-stream`}})}async function w(e,t){return r.post(`${n.workspaces}/${e}/blobs/exists`,{checksums:t})}function T(e,t,{onProgress:r,signal:i}={}){return D(`${n.workspaces}/${e}/blobs`,`POST`,t,{onProgress:r,signal:i})}function E(e,t,r,i={}){let a=t.key.split(`/`).map(encodeURIComponent).join(`/`);return D(`${n.workspaces}/${encodeURIComponent(e)}/backends/${encodeURIComponent(t.driver)}/${encodeURIComponent(t.address)}/objects/${a}`,`PUT`,r,i,{"If-None-Match":`*`,"X-Canvas-Mtime":String(r.lastModified)})}function D(e,t,n,{onProgress:r,signal:i},a={}){return new Promise((o,s)=>{if(i?.aborted){s(new DOMException(`Upload aborted`,`AbortError`));return}let c=new XMLHttpRequest;c.open(t,e),c.withCredentials=!0,c.responseType=`json`,c.setRequestHeader(`Content-Type`,`application/octet-stream`);for(let[e,t]of Object.entries(a))c.setRequestHeader(e,t);let l=localStorage.getItem(`authToken`);l&&c.setRequestHeader(`Authorization`,`Bearer ${l}`),r&&c.upload.addEventListener(`progress`,e=>{e.lengthComputable&&r(e.loaded,e.total)});let u=()=>c.abort();i?.addEventListener(`abort`,u,{once:!0}),c.addEventListener(`load`,()=>{i?.removeEventListener(`abort`,u);let e=c.response;c.status>=200&&c.status<300&&e?.payload?o(e.payload):s(Error(c.status===412?`A file with this name already exists. Rename the file before uploading; nothing was overwritten.`:e?.message||`Upload failed (HTTP ${c.status})`))}),c.addEventListener(`error`,()=>{i?.removeEventListener(`abort`,u),s(Error(`Network error during upload`))}),c.addEventListener(`abort`,()=>{i?.removeEventListener(`abort`,u),s(new DOMException(`Upload aborted`,`AbortError`))}),c.send(n)})}export{a as _,S as a,u as c,s as d,l as f,x as g,h,T as i,m as l,b as m,E as n,d as o,p,C as r,f as s,w as t,c as u,o as v};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{wt as t}from"./react-DQazvoR7.js";import{Mn as n,Tn as r}from"./workspace-BnBIVxoH.js";var i=e(t(),1),a=(0,i.createContext)(void 0);function o(){let e=(0,i.useContext)(a);if(e===void 0)throw Error(`useToast must be used within a ToastContainer`);return e}var s=`data/schema/note`,c=`data/schema/link`,l=`data/schema/tab`,u=`data/schema/file`,d=`data/schema/drawing`,f=`data/schema/message/email`,p=`data/schema/task`,m=`data/schema/identity`;function h(e,t){return e.startsWith(`${t}/`)?e.slice(t.length+1):``}var g={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,svg:`image/svg+xml`,avif:`image/avif`,heic:`image/heic`,heif:`image/heif`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,oga:`audio/ogg`,m4a:`audio/mp4`,flac:`audio/flac`,aac:`audio/aac`,mp4:`video/mp4`,m4v:`video/mp4`,webm:`video/webm`,mov:`video/quicktime`,mkv:`video/x-matroska`,avi:`video/x-msvideo`,ogv:`video/ogg`,pdf:`application/pdf`,md:`text/markdown`,markdown:`text/markdown`,txt:`text/plain`,json:`application/json`,xml:`application/xml`,csv:`text/csv`,log:`text/plain`,yml:`text/yaml`,yaml:`text/yaml`};function _(e){let t=/\.([a-z0-9]+)$/i.exec(e||``);return t?t[1].toLowerCase():``}function v(e){return g[_(e)]}function y(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:e===`application/pdf`?`pdf`:e.startsWith(`text/`)||e.endsWith(`+json`)||e===`application/json`||e===`application/xml`?`text`:null}function b(e,t){if(e===`text/markdown`||/\.(md|markdown)$/i.test(t||``))return`markdown`;if(e&&e!==`application/octet-stream`){let t=y(e);if(t)return t}let n=v(t);if(n){let e=y(n);if(e)return e}return`binary`}function x(e){if(!e)return null;try{let t=new URL(e),n=t.hostname.replace(/^www\.|^m\./,``);if(n===`youtu.be`)return t.pathname.slice(1).split(`/`)[0]||null;if(n===`youtube.com`||n===`youtube-nocookie.com`){if(t.pathname===`/watch`)return t.searchParams.get(`v`);let e=t.pathname.match(/^\/(shorts|embed|live)\/([^/]+)/);if(e)return e[2]}return null}catch{return null}}function S(){let{showToast:e}=o();return{showErrorToast:(t,n=`Error`)=>e({title:n,description:t,variant:`destructive`}),showSuccessToast:(t,n=`Success`)=>e({title:n,description:t})}}async function C(e,t){return r.post(`${n.workspaces}/${e}/blobs`,t,{headers:{"Content-Type":`application/octet-stream`}})}async function w(e,t){return r.post(`${n.workspaces}/${e}/blobs/exists`,{checksums:t})}async function T(e,t,i,{ifMatch:a,contentType:o}={}){let s=t.key.split(`/`).map(encodeURIComponent).join(`/`),c=`${n.workspaces}/${encodeURIComponent(e)}/backends/${encodeURIComponent(t.driver)}/${encodeURIComponent(t.address)}/objects/${s}`;return r.put(c,i,{headers:{"Content-Type":o||`application/octet-stream`,"X-Canvas-Mtime":String(Date.now()),...a?{"If-Match":`"${a}"`}:{"If-None-Match":`*`}}})}function E(e,t,{onProgress:r,signal:i}={}){return O(`${n.workspaces}/${e}/blobs`,`POST`,t,{onProgress:r,signal:i})}function D(e,t,r,i={}){let a=t.key.split(`/`).map(encodeURIComponent).join(`/`);return O(`${n.workspaces}/${encodeURIComponent(e)}/backends/${encodeURIComponent(t.driver)}/${encodeURIComponent(t.address)}/objects/${a}`,`PUT`,r,i,{"If-None-Match":`*`,"X-Canvas-Mtime":String(r.lastModified)})}function O(e,t,n,{onProgress:r,signal:i},a={}){return new Promise((o,s)=>{if(i?.aborted){s(new DOMException(`Upload aborted`,`AbortError`));return}let c=new XMLHttpRequest;c.open(t,e),c.withCredentials=!0,c.responseType=`json`,c.setRequestHeader(`Content-Type`,`application/octet-stream`);for(let[e,t]of Object.entries(a))c.setRequestHeader(e,t);let l=localStorage.getItem(`authToken`);l&&c.setRequestHeader(`Authorization`,`Bearer ${l}`),r&&c.upload.addEventListener(`progress`,e=>{e.lengthComputable&&r(e.loaded,e.total)});let u=()=>c.abort();i?.addEventListener(`abort`,u,{once:!0}),c.addEventListener(`load`,()=>{i?.removeEventListener(`abort`,u);let e=c.response;c.status>=200&&c.status<300&&e?.payload?o(e.payload):s(Error(c.status===412?`A file with this name already exists. Rename the file before uploading; nothing was overwritten.`:e?.message||`Upload failed (HTTP ${c.status})`))}),c.addEventListener(`error`,()=>{i?.removeEventListener(`abort`,u),s(Error(`Network error during upload`))}),c.addEventListener(`abort`,()=>{i?.removeEventListener(`abort`,u),s(new DOMException(`Upload aborted`,`AbortError`))}),c.send(n)})}export{x as _,T as a,f as c,c as d,s as f,h as g,b as h,E as i,u as l,p as m,D as n,S as o,l as p,C as r,d as s,w as t,m as u,a as v,o as y};