@vercel/board 0.45.0 → 0.46.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.
- package/dist/{access-3udXjJAg.mjs → access-Crbvd2Dm.mjs} +2 -2
- package/dist/access.d.mts +2 -2
- package/dist/access.mjs +5 -5
- package/dist/{actors-DasGZnfb.mjs → actors-BBphaJ_G.mjs} +3 -3
- package/dist/{auth-aiOVE82-.mjs → auth-C-pFnJBA.mjs} +2 -2
- package/dist/{auth-BG_whr9_.d.mts → auth-CkNXnQno.d.mts} +1 -1
- package/dist/{backend-D6yTo8Un.d.mts → backend-D3p8gjba.d.mts} +126 -4
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{chat-provider-BvNqOQFL.mjs → chat-provider-1zpY6Qo_.mjs} +2 -2
- package/dist/{chat-provider-V2jnjVLq.d.mts → chat-provider-Bn33acHd.d.mts} +2 -2
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +2 -2
- package/dist/cli-embedded.mjs +3 -2
- package/dist/cli.mjs +6 -6
- package/dist/{commands-DewS14_P.d.mts → commands-CSZPQ38I.d.mts} +54 -0
- package/dist/{commands-CqdnjUkm.mjs → commands-D0lyo8O8.mjs} +319 -0
- package/dist/{conformance-BInS4_6b.mjs → conformance-Blzd4CXG.mjs} +972 -6
- package/dist/conformance.d.mts +6 -5
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-XVBt02Bl.mjs → engine-C_SlBihU.mjs} +15 -7
- package/dist/{errors-ZazTZh-s.mjs → errors-DZ1tbwSM.mjs} +151 -3
- package/dist/{events-D17RndlV.mjs → events-mGuhF4i5.mjs} +2 -2
- package/dist/{exports-DCf75prP.mjs → exports-DQauuHrc.mjs} +1248 -45
- package/dist/exports-DUX_Yzo7.d.mts +44 -0
- package/dist/{external-DfhN7lKK.mjs → external-BVr1Sq0y.mjs} +1 -1
- package/dist/{index-Djmr4GzQ.d.mts → index-BHXg4Xdo.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +5 -5
- package/dist/index.node.d.mts +7 -6
- package/dist/index.node.mjs +5 -4
- package/dist/inspect/app.js +215 -115
- package/dist/inspect/engine.js +5 -5
- package/dist/{inspect-B0_aKQM8.mjs → inspect-2OIjv2lW.mjs} +242 -20
- package/dist/inspect-F-b4GPXX.mjs +2 -0
- package/dist/{local-Bel_oeFa.mjs → local-11FMUJrU.mjs} +1593 -60
- package/dist/{main-DmsdcUZ_.mjs → main-BYmbTDgo.mjs} +1167 -24
- package/dist/{memory-DyEL0fvN.mjs → memory-CZBdVNn8.mjs} +2 -2
- package/dist/{middleware-BHHKHA9q.mjs → middleware-BKsTcMAv.mjs} +2 -2
- package/dist/{provider-BC9mPYVh.d.mts → provider-D3bfHRHA.d.mts} +119 -3
- package/dist/{routes-CkUetTO2.mjs → routes-B2HHHD_C.mjs} +246 -6
- package/dist/{routes-zm4TXKCC.d.mts → routes-NEc6w3QC.d.mts} +540 -6
- package/dist/{schemas-BhZaystC.mjs → schemas-7VFdomFB.mjs} +34 -1
- package/dist/{serve-bPSEx_8X.mjs → serve-DS2T2iWI.mjs} +4 -4
- package/dist/{server-CcvxkXzG.mjs → server-Ch3tuK2k.mjs} +10 -10
- package/dist/{serving-BLVRrJ7P.mjs → serving-9riPNrHk.mjs} +1 -1
- package/dist/{sql-CyVcjw8x.mjs → sql-Bml29DpM.mjs} +174 -9
- package/dist/{sqlite-Con-8duk.mjs → sqlite-4C5u7-ag.mjs} +2 -2
- package/dist/{sqlite-db-BdzxtUOV.mjs → sqlite-db-eVb9v3zc.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-chat-sdk.mjs +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-github.mjs +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +2 -2
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync-slack.mjs +4 -4
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{origin-BHmEdok7.mjs → task-batch-BJcLiYe1.mjs} +83 -8
- package/dist/{tokens-BErYXuHZ.mjs → tokens-DPKF_cb5.mjs} +2 -2
- package/docs/01-board/01-mounting.md +3 -3
- package/docs/01-board/07-schedules.md +2 -2
- package/docs/01-board/08-middleware.md +7 -0
- package/docs/01-board/11-tasks.md +348 -0
- package/docs/03-guides/02-inspector.md +66 -9
- package/docs/03-guides/06-sandboxed-agents.md +5 -3
- package/docs/03-guides/07-build-a-ui.md +210 -0
- package/docs/04-reference/01-cli.md +216 -8
- package/docs/04-reference/02-board.md +277 -2
- package/docs/04-reference/03-http.md +185 -11
- package/docs/04-reference/05-conformance.md +10 -7
- package/package.json +1 -1
- package/dist/exports-Gspe1eEq.d.mts +0 -4
- package/dist/inspect-CULoD54F.mjs +0 -2
package/dist/inspect/engine.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{A as e,C as t,D as n,E as r,
|
|
2
|
-
`,r)+1||e.length,!i.startsWith(`|`)||/^\|\s*(Project|Name)\s*\|/.test(i)||/^\|\s*:?-/.test(i))continue;let o=i.split(`|`).slice(1,-1).map(e=>e.trim());if(o.length<2)continue;let s=
|
|
3
|
-
`)}function
|
|
4
|
-
`)}`:e,
|
|
5
|
-
`).filter(e=>/^📎 .* didn't come over: /u.test(e)),G=e=>JSON.stringify([e.url,e.message,e.snapshot,e.unavailable]),be=(e,t)=>e.length===t.length&&e.every((e,n)=>G(e)===G(t[n])),xe=new AbortController().signal,Se=e=>{try{return JSON.parse(JSON.stringify(e??null))}catch{return null}},K=e=>typeof e==`string`?h(e):Array.isArray(e)?e.map(K):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[h(e),K(t)])):e,q=e=>{let t=e?.data?.error,n=typeof t==`string`?t:e instanceof Error?e.message:String(e);return h(n.slice(0,500))||`unknown error`},Ce=e=>e instanceof _&&e.status===404;function J(e,t,n){return n.startsWith(`${e}:`)?n:`${e}:${n.startsWith(`${t}:`)?n.slice(t.length+1):n}`}function we(e,t,n){return`author`in n?{...n,author:{...n.author,id:J(e,t,n.author.id)}}:n}function Te(t){let o=null,s=()=>{if(!o)throw Error(`sync used before board() bound it`);return o},l={self:`sync`,origin:{via:{kind:`engine`}}};function d(e,t,n=xe,r=l){let i=s().backend;return i[e].call(i,r,t,n)}let f=e=>{let n=t[e];if(!n)throw u(`no sync entry named ${e}`);return n},h=e=>e.slice(0,e.indexOf(`:`)),g=e=>s().syncedHere(e),b=async e=>t[h(e)]!==void 0&&await g(h(e)),x=e=>e.slice(e.indexOf(`:`)+1);async function w(e){try{return await d(`syncThread`,{thread:e})}catch(e){if(Ce(e))return null;throw e}}async function E(e){try{let{message:t,replies:n}=await d(`message`,{id:e});return[t,...n]}catch(e){if(Ce(e))return[];throw e}}async function D(e){return(await E(e)).find(t=>t.id===e)??null}async function O(e){return e.length===0?{}:(await d(`syncCopies`,{message:[...new Set(e)]})).copies}let k=(e,t)=>d(`syncFind`,e,t),A=null;function ie(){if(A)return A;let e=d(`me`,{}).then(e=>e.principal);return A=e,e.catch(()=>{A===e&&(A=null)}),e}async function j(){let[{actors:e},t]=await Promise.all([d(`actors`,{}),ie().catch(()=>null)]),n={byId:{},principal:t};for(let t of e)n.byId[t.id]={id:t.id,kind:t.kind,handle:t.handle,name:t.name,avatar:t.avatar,...t.via?{via:{...t.via}}:{},...t.platform?{platform:t.platform}:{},...t.verified?{verified:!0}:{}};return n}let M=/* @__PURE__ */ new Map;function N(e,t){let n=`${e}:${t}`,r=M.get(n);if(r&&(!r.failed||Date.now()-r.at<6e4))return r.id;let i={id:f(e).resolveChannel(t),failed:!1,at:Date.now()};return i.id.catch(r=>{i.failed=!0;let a=pe(r);!a&&M.get(n)===i&&M.delete(n),console.warn(`[board] sync ${e}: ${a?`skipping`:`couldn't resolve`} ${t}: ${r.message}`)}),M.set(n,i),i.id}function se(e,t){if(!p(t))return x(t);try{let n=f(e).inboxChannel(e,t);return n===null?null:x(n)}catch{return null}}let P=/* @__PURE__ */ new Map;function F(e,t){let n=`${e}\u001f${t.toLowerCase()}`,r=P.get(n);if(r&&Date.now()-r.at<3e5)return r.mention;P.size>=1e3&&P.clear();let i=f(e),a=i.findByEmail(t).then(e=>e?i.mention({id:e.id,kind:`external`,handle:e.handle,name:e.name,avatar:e.avatar}):null,()=>null);return P.set(n,{at:Date.now(),mention:a}),a}async function I(e){let t=e.indexOf(`:`);if(t<=0)throw u(`sync targets look like <key>:<channel or thread>, got: ${e}`);let n=e.slice(0,t),r=f(n);try{let i=fe.parse(await r.resolveTarget(e.slice(t+1)));if(i.kind===`channel`&&!r.canStartThreads)throw Error(`${r.platform} cannot start threads; use an existing thread`);return{target:`${n}:${i.target}`,kind:i.kind}}catch(t){throw u(`can't sync to ${e}: ${t.message}`)}}async function L(e,t){let{event:n,raw:r,dedupe:i}=me.parse(K({...t,raw:Se(t.raw)}));for(let t of[n.channel,n.thread,`subthread`in n?n.subthread:null])if(t!==null&&!t.startsWith(`${e}:`))throw u(`provider locations must belong to sync entry ${e}`);let a=ge(f(e)),o=a&&await a(x(n.channel),t=>N(e,t)).catch(async e=>{if(await R(n.thread))return!0;throw e});(!a||o||await R(n.thread))&&await d(`inboxPush`,{key:e,events:[{id:i,event:n,raw:r}]})}async function R(e){try{return(await k({thread:e},AbortSignal.timeout(2e3))).thread!==null}catch(e){let t=e?.name;if(t===`TimeoutError`||t===`AbortError`)return!0;throw e}}async function he(e,n){let r=t[e];if(!r)throw C(`no sync entry named ${e}`);if(!await g(e))return new Response(null,{status:200});let i;try{i=await r.receive(e,n,t=>L(e,t))}catch(e){return e instanceof _&&e.status===400?(console.error(`[board] dropped an event the board refuses`,e),new Response(null,{status:200})):(console.error(`[board] intake failed`,e),new Response(`intake failed`,{status:500}))}let a=G([e]).catch(t=>console.error(`[board] couldn't pull ${e}'s inbox:`,q(t)));return T(a),i}async function G(e=Object.keys(t)){let n=0,r=Date.now()+24e4;for(let t of e)if(await g(t))for(;Date.now()<r;){let{items:e}=await d(`inboxNext`,{key:t,limit:10});if(e.length===0)break;await Promise.all(e.map(e=>Te(t,e))),n+=e.length}return n}async function Te(e,t){let n;try{await Oe(e,{event:t.event,raw:t.raw},{id:t.id,attempt:t.attempt+1})}catch(r){console.error(`[board] sync ${e} couldn't import ${t.id}:`,q(r)),n=q(r)}await d(`inboxAck`,{key:e,id:t.id,lease:t.lease,...n===void 0?{}:{error:n}}).catch(e=>console.error(`[board] couldn't ack an inbox event:`,q(e)))}async function Ee(e,t,n,i,a=[]){if(t.length===0)return[];let o=[];for(let s of t){if(o.some(e=>e.url===s.url))continue;let t=(await k({thread:s.thread,message:s.message})).message,c=t===null?null:await D(t);if(c&&!c.deleted&&c.channel===i){o.push({url:s.url,message:c.id,unavailable:null,snapshot:{author:c.author?r(c.author):c.by.actor,text:c.text,createdAt:c.createdAt,files:c.attachments.map(e=>({name:e.name,url:null}))}});continue}if(s.snapshot){o.push({url:s.url,message:null,snapshot:s.snapshot,unavailable:null});continue}let l=a.find(e=>e.url===s.url&&e.snapshot&&e.message===null);if(l){o.push(l);continue}let u=await e.fetchLink(s,n).catch(e=>({snapshot:null,unavailable:q(e)}));o.push({url:s.url,message:null,snapshot:u.snapshot,unavailable:u.snapshot?null:(u.unavailable??`unknown`).slice(0,300)})}return K(o)}async function De(t,n,r){let a=[],o=[],s=null;for(let c of n.slice(0,10)){if(s!==null){o.push(ve(c,s));continue}if(c.size!==void 0&&c.size>26214400){o.push(H(c,`over ${e/1024/1024} MB`));continue}let n;try{let e=await t.fetchFile(c);if(e===null){o.push(H(c,`${t.platform} can't hand it over`));continue}n=e}catch(e){if(r<3)throw e;console.warn(`[board] couldn't fetch ${c.name??`a file`} from ${t.platform}:`,q(e)),o.push(H(c,`${t.platform} wouldn't hand it over`));continue}if(n.byteLength>26214400){o.push(H(c,`over ${e/1024/1024} MB`));continue}if(n.byteLength===0){o.push(H(c,`it was empty`));continue}let l=c.name??`${c.type}`;try{a.push((await d(`upload`,{data:n,name:l,type:c.mimeType||i(l)})).attachment)}catch(e){if(e instanceof _&&(e.code===`too_large`||e.code===`no_direct_uploads`)){o.push(H(c,`over ${y/1024/1024} MB`));continue}if(!U(e))throw e;s=e.message,o.push(ve(c,s))}}for(let e of n.slice(10))o.push(H(e,`a message carries at most 10`));return{attachments:a,notes:o}}async function Oe(e,t,n){let r=f(e),i={...t,event:we(e,r.platform,t.event)},{event:a,raw:o}=i,c=(await k({thread:a.thread})).thread??void 0;if(a.kind===`message`){let e=(await k({thread:a.subthread??a.thread,message:a.message})).message;if(e!==null){let t=(await D(e))?.origin;if(!t||t.message!==a.message||(t.subthread??t.thread)!==(a.subthread??a.thread))return}}let l=`author`in a?a.author:{id:`${e}:system`,handle:r.platform,name:r.platform,avatar:null,isBot:!0},d,p=()=>d??=z(r.event({id:n.id,key:e,event:a,raw:o})),m,h,g=!0,_={direction:`in`,key:e,channel:x(a.channel),get event(){return p()},board:s().client({author:l,key:e,...Ae(e,a)},n.id),import(t,r={}){if(!g)throw u(`the sync function has finished`);return m??=ke(e,i,n,c,t,r),m},permalink(){let e=h??r.permalink(p());return h=e,e.catch(()=>{h===e&&(h=void 0)}),e},resolve:t=>N(e,t)};try{await r.sync(_),await m}finally{g=!1}}async function ke(e,t,n,r,i,a){let o=i??(r?(await w(r))?.channel:void 0);if(o===void 0)return{root:null,message:null};try{return await je(e,t,n,m.parse(o),de.parse(a))}catch(e){if(!(e instanceof te))throw e;let n=(await k({thread:t.event.thread})).thread;return{root:n===null?null:(await w(n))?.root??null,message:null}}}function Ae(e,t){let n=f(e),r=(`subthread`in t?t.subthread:null)??t.thread;return{via:{kind:`sync`,key:e,platform:n.platform,channel:t.channel,thread:r},respond:async e=>{await n.post(x(r),`thread`,{markdown:e})}}}async function je(e,t,n,r,i){let{event:o,raw:s}=t,c=Ae(e,o),l=f(e),p=(await k({thread:o.thread})).thread??void 0,m=p?await w(p):null,h=m?.root,g=e=>ee(`board-inbound`,n.id,String(e)),_={key:e,channel:c.via.channel,thread:c.via.thread},v=async e=>{if(!e.dropped)return e.message;for(let t of e.dropped)await c.respond(t);throw new te(e.dropped)},y=async({attachments:t=[],...n})=>({id:await v(await d(`syncImport`,{op:`post`,from:e,source:_,...n,origin:n.origin??null,...t.length?{attachments:t.map(e=>e.id)}:{}})),re:n.re??null}),b=e=>({root:e.re??e.id,message:e.id}),S=(e={})=>{let t={...e,...i.labels};for(let e of i.unset??[])delete t[e];return t},C=e=>{if(!i.root)return e;let t=i.root(z(structuredClone(e)));if(t&&typeof t==`object`&&`then`in t)throw u(`root overrides must be synchronous`);let n=de.pick({text:!0,labels:!0}).parse(t);return{...e,text:n.text??e.text,labels:{...e.labels,...n.labels}}},T=(t,n,r)=>d(`syncImport`,{op:`labels`,author:t,from:e,origin:{thread:o.thread},set:n,unset:r}),ne=async(e,t)=>{if(!i.labels&&!i.unset)return;let n=await D(t),r=Object.fromEntries(Object.entries(i.labels??{}).filter(([e,t])=>n?.labels[e]!==t)),a=(i.unset??[]).filter(e=>n?.labels[e]!==void 0);(Object.keys(r).length||a.length)&&await T(e,r,a)};switch(o.kind){case`message`:{let t=(await k({thread:o.subthread??o.thread,message:o.message})).message;if(t!==null)return{root:h??t,message:t};let{attachments:a,notes:c}=o.files?.length?await De(l,o.files,n.attempt):{attachments:[],notes:[]},u=await Ee(l,o.links??[],{thread:o.subthread??o.thread,message:o.message},m?.channel??r),d={...u.length?{links:u}:{},author:o.author,text:V(W(i.text??o.text,c),a.length>0),...a.length?{attachments:a}:{},origin:{channel:o.channel,thread:o.thread,subthread:o.subthread,message:o.message,context:o.context},id:await g(0)},f={...d,...i.noSync?{noSync:!0}:{}};if(h!==void 0)return await ne(o.author,h),b(await y({...f,re:h}));let p=await l.fetchRoot(x(o.thread));if(p===null){let e=C({text:o.text,labels:{},author:o.author,raw:s});return b(await y({...d,channel:r,text:V(W(i.text??e.text,c),a.length>0),labels:S(e.labels)}))}let _=C({...p,raw:p.raw??null}),v=await y({author:{...p.author,id:J(e,l.platform,p.author.id)},channel:r,text:V(_.text),labels:S(_.labels),origin:{channel:o.channel,thread:o.thread,subthread:null,message:`root:${n.id}`,context:null},id:await g(1)});return b(await y({...f,re:v.id}))}case`edited`:case`deleted`:case`reaction`:{let t=(await k({thread:o.subthread??o.thread,message:o.message})).message;if(t===null)return{root:h??null,message:null};let n=`author`in o?o.author:{id:`${e}:system`,handle:l.platform,name:l.platform,avatar:null,isBot:!0},r={thread:o.subthread??o.thread,message:o.message};if(h!==void 0&&await ne(n,h),o.kind===`deleted`)await d(`syncImport`,{op:`delete`,author:n,from:e,origin:r});else if(o.kind===`edited`){let a=await D(t),s=V(W(i.text??o.text,a?ye(a.text):[]),(a?.attachments.length??0)>0);a&&!o.linksOnly&&a.text!==s&&await v(await d(`syncImport`,{op:`edit`,author:n,from:e,origin:r,text:s,source:_}));let c=a?await Ee(l,o.links??[],r,a.channel,a.links):[];a&&!be(c,a.links)&&await d(`syncImport`,{op:`links`,author:n,from:e,origin:r,links:c})}else{if(l.singleReaction){let i=a(o.emoji),s=/* @__PURE__ */ new Set([n.id,`${await ie()}+${n.id}`]);for(let[a,c]of Object.entries((await D(t))?.reactions??{}))c.some(e=>s.has(e))&&!(o.added&&a===i)&&await d(`syncImport`,{op:`react`,author:n,from:e,origin:r,emoji:a,remove:!0})}(!l.singleReaction||o.added)&&await d(`syncImport`,{op:`react`,author:n,from:e,origin:r,emoji:o.emoji,remove:!o.added})}return{root:h??null,message:t}}case`lifecycle`:{if(h!==void 0){let t=await D(h),r=t?.origin?.message===`lifecycle:${n.id}`,a=S((r?C({text:Y(o),labels:o.labels,author:o.author,raw:s}):null)?.labels??o.labels),c=e=>o.owns?.some(t=>e.startsWith(t))??!1,l=Object.fromEntries(Object.entries(a).filter(([e,n])=>t?.labels[e]!==n)),u=Object.keys(t?.labels??{}).filter(e=>!(e in a)&&(o.unset.includes(e)||i.unset?.includes(e)||c(e)));if(t&&!t.deleted&&(Object.keys(l).length||u.length)&&await T(o.author,l,u),o.retitled&&t&&!t.deleted&&t.from===e&&t.origin?.thread===o.thread){let n=V(i.text??C({text:Y(o),labels:t.labels,author:o.author,raw:s}).text);t.text!==n&&await v(await d(`syncImport`,{op:`edit`,author:o.author,from:e,origin:{thread:t.origin.thread,message:t.origin.message},text:n}))}return o.reply?b(await y({author:o.author,re:h,text:V(i.text??o.reply),...i.noSync?{noSync:!0}:{},id:await g(1)})):{root:h,message:r?h:null}}if(!o.createRoot)return{root:null,message:null};let t=C({text:Y(o),labels:o.labels,author:o.author,raw:s}),a=await y({author:o.author,channel:r,text:V(o.reply?t.text:i.text??t.text),labels:S(t.labels),origin:{channel:o.channel,thread:o.thread,subthread:null,message:`lifecycle:${n.id}`,context:null},id:await g(0)});return o.reply?b(await y({author:o.author,re:a.id,text:V(i.text??o.reply),...i.noSync?{noSync:!0}:{},id:await g(1)})):b(a)}}}async function Me(e,t,n,r){let i=ce(r);if(i.length===0)return r;let a=/* @__PURE__ */ new Map;for(let t of i)t.kind===`actor`&&!n.byId[t.actor]&&le(t.actor)&&a.set(t.actor,await F(e,t.actor));let o=/* @__PURE__ */ new Map;for(let t of i){if(t.kind!==`handle`)continue;let r=Object.values(n.byId).filter(e=>{let n=e.handle.toLowerCase();return n===t.handle||!t.handle.includes(`/`)&&n.slice(n.indexOf(`/`)+1)===t.handle});o.set(t.handle,r.flatMap(t=>{let r=X(e,t.id,n);return r===null?[]:[{id:t.id,mention:r}]}))}let s=[...o.values()].some(e=>new Set(e.map(e=>e.mention)).size>1)?new Set((await E(t.re??t.id)).map(e=>e.by.actor)):null,c=e=>{let t=new Set(e.map(e=>e.mention));return t.size===1?[...t][0]:null};return ue(r,t=>{if(t.kind===`handle`){let e=o.get(t.handle)??[];return c(e)??(s?c(e.filter(e=>s.has(e.id))):null)}if(a.has(t.actor))return a.get(t.actor)??t.actor;let r=n.byId[t.actor];return r?X(e,r.id,n)??r.name:null})}function Ne(e,t,n){let{principal:r,profile:i}=re(t),a=i===null?t:c(i)!==null&&r===n.principal?i:null;return a?.startsWith(`${e}:`)?a.slice(e.length+1):null}function X(e,t,n){let r=n.byId[t],i=r?Ne(e,t,n):null;if(i===null)return null;let a=f(e);return a.mention({...r,id:`${a.platform}:${i}`})}async function Pe(e,r,i,a,o){let s=a.byId[i.by.actor],c=s?.name??i.by.actor,l=`${s?.via?` ${n(s.via)}`:``}${i.from?` (${s?.platform??t[i.from]?.platform??i.from})`:``}`,d=s?.kind===`deployment`&&!s.via?/(?:@[^@/]+| \([^()]+\))$/.exec(c)?.[0]??``:``,p=`${c}${l}`,m=`${d}${l}`,h=f(e),g=(o??(e=>h.render(e)))(z({message:{...structuredClone(i),text:oe(i.text,i.by.actor)},author:s?{...s}:null,mentionOf:t=>X(e,t,a),label:p,target:r}));if(typeof g!=`string`)throw u(`a provider renderer must return markdown`);let _=`**${p}**: `,v=await Me(e,i,a,g.startsWith(_)&&_e(g.slice(_.length))?`**${p}**:\n\n${g.slice(_.length)}`:g),y=i.by.actor===`github:user:35613825`?ae(i.text):null;return{markdown:v,...s?.verified?{as:{name:p,avatar:Fe(i,s),attribution:m}}:{},...y?{deployments:y}:{}}}function Fe(e,t){let n=e=>!e||/\/avatars\/[a-z0-9-]+$/.test(e),r=t?.avatar??null;if(!n(r))return r;let i=t?.handle.split(`/`)[0]??``,a=e.by.principal.slice(12);return!e.by.principal.startsWith(`vercel:user:`)||!i||/^user-/.test(i)||i.toLowerCase()===a.toLowerCase()?r:`https://vercel.com/api/www/avatar?u=${encodeURIComponent(i)}&s=64&format=png`}let Ie=e=>e.attachments.map(t=>`\n📎 ${t.name} (${v(t.size)}, on the board: #${e.id})`).join(``),Z=async(e,t,n,r=!1,i)=>{let a=h(e),{markdown:o,...s}=await Pe(a,e,t,n,i);return{markdown:t.attachments.length>0&&(r||!f(a).uploadsFiles)?`${o}\n${Ie(t)}`:o,...s}};async function Le(e,t,n,r,i){let a=e.replyTo===null?void 0:(await O([e.replyTo]))[e.replyTo]?.[t],o=a!==void 0&&a.thread!==n?a.thread:n,s=f(h(t)),c=await Z(t,e,r,!1,i),l,d;if(!c.markdown.trim()&&e.attachments.length&&s.uploadsFiles)try{let n=await Be(e,t,o);d=n.message,l=n.files}catch(n){if(!s.refusesFiles(n)&&!U(n))throw n;c=await Z(t,e,r,!0,i),d=(await s.post(x(o),`thread`,c)).message,l=null}else{if(!c.markdown.trim())throw u(`a renderer must return text unless the message has media`);d=(await s.post(x(o),`thread`,c)).message}let p={thread:o,message:d,...l===void 0?{}:{files:l}};return await Re(e,t,p),p}async function Re(e,t,n){await d(`syncReceipt`,{kind:`message`,message:e.id,target:t,external:{thread:n.thread,message:n.message},...n.files===void 0?{}:{files:n.files}})}async function ze(e){return Promise.all(e.attachments.map(async e=>{let{data:t}=await d(`attachment`,{id:e.id});return{data:t instanceof Uint8Array?t:new Uint8Array(await new Response(t).arrayBuffer()),filename:e.name,mimeType:e.type}}))}async function Be(e,t,n){return f(h(t)).uploadFiles(x(n),await ze(e))}async function Q(e,t,n,r,i){let a=f(h(t));if(!a.uploadsFiles||e.attachments.length===0||n.files!==void 0)return;let o;try{o=(await Be(e,t,n.thread)).files}catch(s){if(!a.refusesFiles(s)&&!U(s))throw Object.assign(/* @__PURE__ */ Error(`files: ${q(s)}`),{cause:s,data:{error:`files: ${q(s)}`}});console.warn(`[board] ${t} won't take #${e.id}'s files (${q(s)}); noting them in its text`),o=null,await Z(t,e,r,!0,i).then(e=>a.edit(x(n.thread),n.message,e)).catch(n=>console.warn(`[board] couldn't note #${e.id}'s files on ${t}:`,q(n)))}await d(`syncReceipt`,{kind:`files`,message:e.id,target:t,files:o})}let Ve=(e,t,n,r)=>{e.some(e=>e.error===r)||e.push({id:t,target:n,error:r})};async function He(e,t){if(t.length!==0){if(e<5||S(e))throw t[0].error;for(let{id:e,target:n,error:r}of t)console.error(`[board] gave up ${n===null?`syncing #${e}`:`delivering #${e} to ${n}`}:`,q(r)),n!==null&&await d(`syncReceipt`,{kind:`failed`,message:e,target:n,error:q(r)})}}async function $(e,t,n,r,i){let a,o=!0,s=()=>u(`the sync function has finished`),c={direction:`out`,key:e,channel:r===null?null:se(e,r),event:z(structuredClone(t)),message:z(structuredClone(n)),target:r,deliver(e={}){if(!o)throw s();return a??=r===null?Promise.resolve():i(e.render),a},start(t){if(!o)throw s();return Ue(e,n,t)},resolve:t=>N(e,t)};try{await f(e).sync(c),await a}finally{o=!1}}async function Ue(e,t,n){let{target:r,kind:i}=await I(`${e}:${n}`),a=t.re===null?t:await D(t.re);!a||a.deleted||a.noSync||r!==(a.origin?a.origin.channel??ne(a.origin.thread):null)&&await d(`syncReceipt`,{kind:`thread`,message:a.id,target:r,targetKind:i,cause:`config`})}async function We(e,n){let r=[];for(let e of Object.keys(t))t[e].canStartThreads&&await g(e)&&r.push(e);if(e.payload.noSync||r.length===0)return;let i=await D(e.message.id);if(!i||i.deleted)return;let a=[];for(let t of r)try{await $(t,e,i,null,async()=>{})}catch(e){Ve(a,i.id,null,e)}await He(n,a)}async function Ge(e,t){let{thread:n,target:r}=e.payload;if(!await b(r)||(e.payload.kind??(p(r)?`thread`:`channel`))===`thread`)return;let i=await w(n);if(!i?.targets.includes(r))return;let[a,...o]=await E(i.root);if(!a||a.id!==i.root||a.deleted)return;let s=[];try{await $(h(r),e,a,r,e=>Ke(i,a,o,r,s,e))}catch(e){Ve(s,a.id,r,e)}await He(t,s)}async function Ke(e,t,n,r,i,a){let o=await j(),s=await O([t.id,...n.map(e=>e.id)]),c=e=>(i.push({id:t.id,target:r,error:e}),e),l=e.external[r];if(l){let e=s[t.id]?.[r];if(e)try{await Q(t,r,e,o,a)}catch(e){throw c(e)}}else try{let e=f(h(r)),n=await Z(r,t,o,!1,a),i=!n.markdown.trim()&&t.attachments.length>0&&e.uploadsFiles;if(!n.markdown.trim()&&!i)throw u(`a renderer must return text unless the message has media`);let s,c=await(async()=>{if(!i&&(t.attachments.length===0||!e.startsThreadsWithFiles))return e.post(x(r),`channel`,n);try{let a=await e.post(x(r),`channel`,{...n,files:await ze(t)});return s=i?a.files??[]:a.files,a}catch(n){if(!e.refusesFiles(n)&&!U(n))throw n;return s=null,e.post(x(r),`channel`,await Z(r,t,o,!0,a))}})();l=`${h(r)}:${c.thread}`;let d={thread:l,message:c.message,...s===void 0?{}:{files:s}};await Re(t,r,d),await Q(t,r,d,o,a)}catch(e){throw c(e)}let d=[];for(let e of n)if(!(e.deleted||e.noSync||qe(e,r)))try{await Q(e,r,s[e.id]?.[r]??await Le(e,r,l,o,a),o,a)}catch(t){d.push({id:e.id,target:r,error:t})}if(i.push(...d),d.length)throw d[0].error}let qe=(e,t)=>e.origin?.thread===t||e.from!==null&&h(t)===e.from;async function Je(e,t){if(!e.message)return;if(e.message.re===null)return We(e,t);if(e.payload.noSync)return;let n=await w(e.payload.thread);if(!n||n.targets.length===0)return;let r=await D(e.message.id);if(!r||r.deleted)return;let i=await j(),a=[];for(let t of n.targets){let o=n.external[t];if(await b(t)&&o&&!qe(r,t))try{await $(h(t),e,r,t,async e=>{let n=(await O([r.id]))[r.id]?.[t]??await Le(r,t,o,i,e);await Q(r,t,n,i,e)})}catch(e){Ve(a,r.id,t,e)}}await He(t,a)}async function Ye(e){let t=(await O([e.payload.id]))[e.payload.id]??{};if(Object.keys(t).length===0)return;let n=e.type===`message.edited`?await D(e.payload.id):e.message??await D(e.payload.id);if(!n||e.type===`message.edited`&&n.deleted)return;let r=await j();for(let[i,o]of Object.entries(t))if(!(!await b(i)||e.payload.from!==null&&h(i)===e.payload.from))try{await $(h(i),e,n,i,async t=>{let s=f(h(i)),c=x(o.thread);e.type===`message.edited`?await s.edit(c,o.message,await Z(i,n,r,o.files===null,t)):e.type===`message.deleted`?(await s.delete(c,o.message),o.files?.length&&await s.deleteFiles(o.files)):e.type===`reaction.added`?await s.react(c,o.message,a(e.payload.emoji),!0):await s.react(c,o.message,a(e.payload.emoji),!1)})}catch(t){console.warn(`[board] skipped ${e.type} on ${i}:`,t.message)}}async function Xe(e){let{id:t}=e.payload,n=(await O([t]))[t]??{},r=e.message;if(!r||Object.keys(n).length===0)return;let i=await D(t);if(!i||i.deleted)return;let a=await j(),o={...i,labels:r.labels},s={...i,labels:e.before?.labels??{}};for(let[t,r]of Object.entries(n))if(await b(t))try{await $(h(t),e,o,t,async e=>{let n=await Z(t,o,a,r.files===null,e);n.markdown!==(await Z(t,s,a,r.files===null,e)).markdown&&await f(h(t)).edit(x(r.thread),r.message,n)})}catch(e){console.warn(`[board] skipped labels.changed on ${t}:`,q(e))}}async function Ze(e,{attempt:t}){switch(e.type){case`thread.synced`:return Ge(e,t);case`message.posted`:return Je(e,t);case`message.edited`:case`message.deleted`:case`reaction.added`:case`reaction.removed`:return Ye(e);case`labels.changed`:return Xe(e)}}async function Qe(e,t){let n=e[0]?await w(e[0].thread):null;if(!n)return[];let r=[];for(let e of new Set(Object.values(n.external)))await b(e)&&r.push(e);return(await Promise.all(r.map(async n=>{let r=h(n);try{let i=f(r),a=null;for(let t=e.length-1;t>=0&&a===null;t--){let r=e[t];!r.deleted&&r.origin?.thread===n&&(a=r.origin.message)}return await i.startTyping(x(n),a,t),n}catch(e){return console.warn(`[board] skipped typing on ${n}:`,q(e)),null}}))).filter(e=>e!==null)}async function $e(e,t){try{return`${e}:${await f(e).resolveChannel(t)}`}catch(e){throw u(`can't resolve inbox channel: ${e.message}`)}}let et=e=>e===`unsupported`||e===`invalid_target`?400:e===`channel_not_found`?404:e===`ratelimited`?429:[`no_client`,`list_failed`,`internal_error`,`fatal_error`,`service_unavailable`,`request_timeout`].includes(e)?502:403;async function tt(e,t,n,r){let i=f(e);try{return await i.read(t,{limit:n,after:r})}catch(n){throw n instanceof B?new _(et(n.code),n.code,n.message):u(`can't read ${t} from ${e}: ${q(n)}`,`platform_error`)}}async function nt(e,t){let n=f(e);try{return await n.join(t)}catch(n){throw n instanceof B?new _(et(n.code),n.code,n.message):u(`can't join ${t} on ${e}: ${q(n)}`,`platform_error`)}}return{entries:t,bind(e){o=e},caller:l,deliver:Ze,receive:Oe,pull:G,normalizeTarget:I,handleWebhook:he,inboxChannel:$e,typing:Qe,readSource:tt,joinSource:nt}}function Y(e){let t=e.url?`${e.title}\n${e.url}`:e.title;return e.body?`${t}\n\n${e.body}`:t}export{Te as createSyncEngine,J as keyedId};
|
|
1
|
+
import{A as e,C as t,D as n,E as r,F as i,M as a,N as o,O as s,P as c,S as l,T as u,_ as d,a as f,b as p,c as m,d as h,f as g,g as _,h as v,i as y,j as b,k as x,l as S,m as C,n as w,o as T,p as E,r as ee,s as te,t as ne,u as re,v as ie,w as D,x as O,y as k}from"./app.js";o({id:c().min(1),platform:c().min(1),key:c().min(1),...E.shape,raw:i()});const ae=o({root:a(e=>typeof e==`function`).optional(),text:c().optional(),labels:l.optional(),unset:e(O).optional(),noSync:b().optional()}).strict();function A(e){if(e&&typeof e==`object`){for(let t of Object.values(e))A(t);Object.freeze(e)}return e}const oe=o({target:c().min(1),channel:c().min(1),kind:x([`channel`,`thread`])}).strict();var j=class extends Error{code;constructor(e,t){super(t),this.code=e}};const se=e=>e instanceof j&&e.code===`channel_not_found`,ce=o({event:g,raw:i(),dedupe:c().min(1)}),M=/* @__PURE__ */ new WeakMap,le=e=>M.get(e),ue=e=>/^(```|~~~|[-*+] |\d+[.)] |#{1,6} |>|\|)/.test(e),N=/^\[vc\]: #\S*\r?\n/,P=/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,F=/!\[([^\]]+)\]\(https:\/\/vercel\.com\/static\/status\/[^)]+\)\s*(?:\[[^\]]*\]\((https?:\/\/[^)\s]+)\))?/;function de(e){if(!N.test(e))return null;let t=e.search(/<details><summary>\d+ Skipped Deployments?<\/summary>/),n=[],r=0;for(let i of e.split(/\r?\n/)){let a=r;if(r=e.indexOf(`
|
|
2
|
+
`,r)+1||e.length,!i.startsWith(`|`)||/^\|\s*(Project|Name)\s*\|/.test(i)||/^\|\s*:?-/.test(i))continue;let o=i.split(`|`).slice(1,-1).map(e=>e.trim());if(o.length<2)continue;let s=F.exec(o[1]);if(!s)continue;let c=[...o[0].matchAll(P)].at(-1),l=c?.[1]??o[0].replace(/<[^>]*>/g,``).trim();if(!l)continue;let u=o[2]?[...o[2].matchAll(P)].find(e=>/preview/i.test(e[1])):void 0,d=o[3]?.match(/<relative-time[^>]*>([^<]+)<\/relative-time>/)?.[1]?.trim()??(o[3]?.replace(/<[^>]*>/g,``).trim()||null),f=o[3]?.match(/<relative-time[^>]*\sdatetime="([^"]+)"/)?.[1]??null;n.push({project:l,projectUrl:c?.[2]??null,status:s[1].trim(),deploymentUrl:s[2]??null,previewUrl:u?.[2]??null,updated:d,updatedAt:f!==null&&!Number.isNaN(Date.parse(f))?f:null,skipped:t!==-1&&a>t})}return n.length>0?n:null}const I={ready:`✅`,building:`⏳`,queued:`⏳`,initializing:`⏳`,error:`❌`,failed:`❌`,canceled:`⚪`,ignored:`⚪`},L=(e,t)=>t?`[${e}](${t})`:e;function R(e){return e.map(e=>`- ${[`${I[e.status.toLowerCase()]??`▲`} **${L(e.project,e.projectUrl)}**`,`${L(e.status,e.deploymentUrl)}${e.skipped?` (skipped)`:``}`,...e.previewUrl?[L(`Preview`,e.previewUrl)]:[],...e.updated?[e.updated]:[]].join(` · `)}`).join(`
|
|
3
|
+
`)}function fe(e,t){let n=t===`github:user:35613825`?de(e):null;return n?`**▲ Vercel**\n${R(n)}`:e}const z=(e,n=!1)=>{let r=D(e),i=r.trim()===``?n?``:`(no text)`:r;return i.length>1e4?`${i.slice(0,t-1).toWellFormed()}…`:i},B=(e,t,r=e.name??`a file`)=>`📎 ${r}${e.size===void 0?``:` (${n(e.size)})`} didn't come over: ${t}`,V=e=>e instanceof _&&e.code===`no_files`,pe=(e,t)=>{let n=e.name??`a file`;if(!e.url||!/^https?:\/\//.test(e.url))return B(e,t);let r=n.replace(/[[\]\\]/g,e=>`\\${e}`),i=e.url.replace(/[ ()]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`);return B(e,t,`[${r}](${i})`)},H=(e,t)=>t.length?`${e.trim()?`${e}\n\n`:``}${t.join(`
|
|
4
|
+
`)}`:e,me=e=>e.split(`
|
|
5
|
+
`).filter(e=>/^📎 .* didn't come over: /u.test(e)),U=e=>JSON.stringify([e.url,e.message,e.snapshot,e.unavailable]),he=(e,t)=>e.length===t.length&&e.every((e,n)=>U(e)===U(t[n])),ge=new AbortController().signal,_e=e=>{try{return JSON.parse(JSON.stringify(e??null))}catch{return null}},W=e=>typeof e==`string`?D(e):Array.isArray(e)?e.map(W):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[D(e),W(t)])):e,G=e=>{let t=e?.data?.error,n=typeof t==`string`?t:e instanceof Error?e.message:String(e);return D(n.slice(0,500))||`unknown error`},ve=e=>e instanceof _&&e.status===404;function K(e,t,n){return n.startsWith(`${e}:`)?n:`${e}:${n.startsWith(`${t}:`)?n.slice(t.length+1):n}`}function ye(e,t,n){return`author`in n?{...n,author:{...n.author,id:K(e,t,n.author.id)}}:n}function q(e){let t=null,i=()=>{if(!t)throw Error(`sync used before board() bound it`);return t},a={self:`sync`,origin:{via:{kind:`engine`}}};function o(e,t,n=ge,r=a){let o=i().backend;return o[e].call(o,r,t,n)}let c=t=>{let n=e[t];if(!n)throw d(`no sync entry named ${t}`);return n},l=e=>e.slice(0,e.indexOf(`:`)),g=e=>i().syncedHere(e),b=async t=>e[l(t)]!==void 0&&await g(l(t)),x=e=>e.slice(e.indexOf(`:`)+1);async function E(e){try{return await o(`syncThread`,{thread:e})}catch(e){if(ve(e))return null;throw e}}async function D(e){try{let{message:t,replies:n}=await o(`message`,{id:e});return[t,...n]}catch(e){if(ve(e))return[];throw e}}async function O(e){return(await D(e)).find(t=>t.id===e)??null}async function M(e){return e.length===0?{}:(await o(`syncCopies`,{message:[...new Set(e)]})).copies}let N=(e,t)=>o(`syncFind`,e,t),P=null;function F(){if(P)return P;let e=o(`me`,{}).then(e=>e.principal);return P=e,e.catch(()=>{P===e&&(P=null)}),e}async function I(){let[{actors:e},t]=await Promise.all([o(`actors`,{}),F().catch(()=>null)]),n={byId:{},principal:t};for(let t of e)n.byId[t.id]={id:t.id,kind:t.kind,handle:t.handle,name:t.name,avatar:t.avatar,...t.via?{via:{...t.via}}:{},...t.platform?{platform:t.platform}:{},...t.verified?{verified:!0}:{}};return n}let L=/* @__PURE__ */ new Map;function R(e,t){let n=`${e}:${t}`,r=L.get(n);if(r&&(!r.failed||Date.now()-r.at<6e4))return r.id;let i={id:c(e).resolveChannel(t),failed:!1,at:Date.now()};return i.id.catch(r=>{i.failed=!0;let a=se(r);!a&&L.get(n)===i&&L.delete(n),console.warn(`[board] sync ${e}: ${a?`skipping`:`couldn't resolve`} ${t}: ${r.message}`)}),L.set(n,i),i.id}function U(e,t){if(!v(t))return x(t);try{let n=c(e).inboxChannel(e,t);return n===null?null:x(n)}catch{return null}}let q=/* @__PURE__ */ new Map;function be(e,t){let n=`${e}\u001f${t.toLowerCase()}`,r=q.get(n);if(r&&Date.now()-r.at<3e5)return r.mention;q.size>=1e3&&q.clear();let i=c(e),a=i.findByEmail(t).then(e=>e?i.mention({id:e.id,kind:`external`,handle:e.handle,name:e.name,avatar:e.avatar}):null,()=>null);return q.set(n,{at:Date.now(),mention:a}),a}async function xe(e){let t=e.indexOf(`:`);if(t<=0)throw d(`sync targets look like <key>:<channel or thread>, got: ${e}`);let n=e.slice(0,t),r=c(n);try{let i=oe.parse(await r.resolveTarget(e.slice(t+1)));if(i.kind===`channel`&&!r.canStartThreads)throw Error(`${r.platform} cannot start threads; use an existing thread`);return{target:`${n}:${i.target}`,kind:i.kind}}catch(t){throw d(`can't sync to ${e}: ${t.message}`)}}async function Se(e,t){let{event:n,raw:r,dedupe:i}=ce.parse(W({...t,raw:_e(t.raw)}));for(let t of[n.channel,n.thread,`subthread`in n?n.subthread:null])if(t!==null&&!t.startsWith(`${e}:`))throw d(`provider locations must belong to sync entry ${e}`);let a=le(c(e)),s=a&&await a(x(n.channel),t=>R(e,t)).catch(async e=>{if(await Ce(n.thread))return!0;throw e});(!a||s||await Ce(n.thread))&&await o(`inboxPush`,{key:e,events:[{id:i,event:n,raw:r}]})}async function Ce(e){try{return(await N({thread:e},AbortSignal.timeout(2e3))).thread!==null}catch(e){let t=e?.name;if(t===`TimeoutError`||t===`AbortError`)return!0;throw e}}async function we(t,n){let r=e[t];if(!r)throw ie(`no sync entry named ${t}`);if(!await g(t))return new Response(null,{status:200});let i;try{i=await r.receive(t,n,e=>Se(t,e))}catch(e){return e instanceof _&&e.status===400?(console.error(`[board] dropped an event the board refuses`,e),new Response(null,{status:200})):(console.error(`[board] intake failed`,e),new Response(`intake failed`,{status:500}))}let a=Te([t]).catch(e=>console.error(`[board] couldn't pull ${t}'s inbox:`,G(e)));return ee(a),i}async function Te(t=Object.keys(e)){let n=0,r=Date.now()+24e4;for(let e of t)if(await g(e))for(;Date.now()<r;){let{items:t}=await o(`inboxNext`,{key:e,limit:10});if(t.length===0)break;await Promise.all(t.map(t=>Ee(e,t))),n+=t.length}return n}async function Ee(e,t){let n;try{await ke(e,{event:t.event,raw:t.raw},{id:t.id,attempt:t.attempt+1})}catch(r){console.error(`[board] sync ${e} couldn't import ${t.id}:`,G(r)),n=G(r)}await o(`inboxAck`,{key:e,id:t.id,lease:t.lease,...n===void 0?{}:{error:n}}).catch(e=>console.error(`[board] couldn't ack an inbox event:`,G(e)))}async function De(e,t,n,r,i=[]){if(t.length===0)return[];let a=[];for(let o of t){if(a.some(e=>e.url===o.url))continue;let t=(await N({thread:o.thread,message:o.message})).message,s=t===null?null:await O(t);if(s&&!s.deleted&&s.channel===r){a.push({url:o.url,message:s.id,unavailable:null,snapshot:{author:s.author?T(s.author):s.by.actor,text:s.text,createdAt:s.createdAt,files:s.attachments.map(e=>({name:e.name,url:null}))}});continue}if(o.snapshot){a.push({url:o.url,message:null,snapshot:o.snapshot,unavailable:null});continue}let c=i.find(e=>e.url===o.url&&e.snapshot&&e.message===null);if(c){a.push(c);continue}let l=await e.fetchLink(o,n).catch(e=>({snapshot:null,unavailable:G(e)}));a.push({url:o.url,message:null,snapshot:l.snapshot,unavailable:l.snapshot?null:(l.unavailable??`unknown`).slice(0,300)})}return W(a)}async function Oe(e,t,n){let i=[],a=[],c=null;for(let l of t.slice(0,10)){if(c!==null){a.push(pe(l,c));continue}if(l.size!==void 0&&l.size>26214400){a.push(B(l,`over ${r/1024/1024} MB`));continue}let t;try{let n=await e.fetchFile(l);if(n===null){a.push(B(l,`${e.platform} can't hand it over`));continue}t=n}catch(t){if(n<3)throw t;console.warn(`[board] couldn't fetch ${l.name??`a file`} from ${e.platform}:`,G(t)),a.push(B(l,`${e.platform} wouldn't hand it over`));continue}if(t.byteLength>26214400){a.push(B(l,`over ${r/1024/1024} MB`));continue}if(t.byteLength===0){a.push(B(l,`it was empty`));continue}let d=l.name??`${l.type}`;try{i.push((await o(`upload`,{data:t,name:d,type:l.mimeType||s(d)})).attachment)}catch(e){if(e instanceof _&&(e.code===`too_large`||e.code===`no_direct_uploads`)){a.push(B(l,`over ${u/1024/1024} MB`));continue}if(!V(e))throw e;c=e.message,a.push(pe(l,c))}}for(let e of t.slice(10))a.push(B(e,`a message carries at most 10`));return{attachments:i,notes:a}}async function ke(e,t,n){let r=c(e),a={...t,event:ye(e,r.platform,t.event)},{event:o,raw:s}=a,l=(await N({thread:o.thread})).thread??void 0;if(o.kind===`message`){let e=(await N({thread:o.subthread??o.thread,message:o.message})).message;if(e!==null){let t=(await O(e))?.origin;if(!t||t.message!==o.message||(t.subthread??t.thread)!==(o.subthread??o.thread))return}}let u=`author`in o?o.author:{id:`${e}:system`,handle:r.platform,name:r.platform,avatar:null,isBot:!0},f,p=()=>f??=A(r.event({id:n.id,key:e,event:o,raw:s})),m,h,g=!0,_={direction:`in`,key:e,channel:x(o.channel),get event(){return p()},board:i().client({author:u,key:e,...je(e,o)},n.id),import(t,r={}){if(!g)throw d(`the sync function has finished`);return m??=Ae(e,a,n,l,t,r),m},permalink(){let e=h??r.permalink(p());return h=e,e.catch(()=>{h===e&&(h=void 0)}),e},resolve:t=>R(e,t)};try{await r.sync(_),await m}finally{g=!1}}async function Ae(e,t,n,r,i,a){let o=i??(r?(await E(r))?.channel:void 0);if(o===void 0)return{root:null,message:null};try{return await Me(e,t,n,p.parse(o),ae.parse(a))}catch(e){if(!(e instanceof ne))throw e;let n=(await N({thread:t.event.thread})).thread;return{root:n===null?null:(await E(n))?.root??null,message:null}}}function je(e,t){let n=c(e),r=(`subthread`in t?t.subthread:null)??t.thread;return{via:{kind:`sync`,key:e,platform:n.platform,channel:t.channel,thread:r},respond:async e=>{await n.post(x(r),`thread`,{markdown:e})}}}async function Me(e,t,n,r,i){let{event:a,raw:s}=t,l=je(e,a),u=c(e),f=(await N({thread:a.thread})).thread??void 0,p=f?await E(f):null,m=p?.root,g=e=>h(`board-inbound`,n.id,String(e)),_={key:e,channel:l.via.channel,thread:l.via.thread},v=async e=>{if(!e.dropped)return e.message;for(let t of e.dropped)await l.respond(t);throw new ne(e.dropped)},y=async({attachments:t=[],...n})=>({id:await v(await o(`syncImport`,{op:`post`,from:e,source:_,...n,origin:n.origin??null,...t.length?{attachments:t.map(e=>e.id)}:{}})),re:n.re??null}),b=e=>({root:e.re??e.id,message:e.id}),S=(e={})=>{let t={...e,...i.labels};for(let e of i.unset??[])delete t[e];return t},C=e=>{if(!i.root)return e;let t=i.root(A(structuredClone(e)));if(t&&typeof t==`object`&&`then`in t)throw d(`root overrides must be synchronous`);let n=ae.pick({text:!0,labels:!0}).parse(t);return{...e,text:n.text??e.text,labels:{...e.labels,...n.labels}}},w=(t,n,r)=>o(`syncImport`,{op:`labels`,author:t,from:e,origin:{thread:a.thread},set:n,unset:r}),T=async(e,t)=>{if(!i.labels&&!i.unset)return;let n=await O(t),r=Object.fromEntries(Object.entries(i.labels??{}).filter(([e,t])=>n?.labels[e]!==t)),a=(i.unset??[]).filter(e=>n?.labels[e]!==void 0);(Object.keys(r).length||a.length)&&await w(e,r,a)};switch(a.kind){case`message`:{let t=(await N({thread:a.subthread??a.thread,message:a.message})).message;if(t!==null)return{root:m??t,message:t};let{attachments:o,notes:c}=a.files?.length?await Oe(u,a.files,n.attempt):{attachments:[],notes:[]},l=await De(u,a.links??[],{thread:a.subthread??a.thread,message:a.message},p?.channel??r),d={...l.length?{links:l}:{},author:a.author,text:z(H(i.text??a.text,c),o.length>0),...o.length?{attachments:o}:{},origin:{channel:a.channel,thread:a.thread,subthread:a.subthread,message:a.message,context:a.context},id:await g(0)},f={...d,...i.noSync?{noSync:!0}:{}};if(m!==void 0)return await T(a.author,m),b(await y({...f,re:m}));let h=await u.fetchRoot(x(a.thread));if(h===null){let e=C({text:a.text,labels:{},author:a.author,raw:s});return b(await y({...d,channel:r,text:z(H(i.text??e.text,c),o.length>0),labels:S(e.labels)}))}let _=C({...h,raw:h.raw??null}),v=await y({author:{...h.author,id:K(e,u.platform,h.author.id)},channel:r,text:z(_.text),labels:S(_.labels),origin:{channel:a.channel,thread:a.thread,subthread:null,message:`root:${n.id}`,context:null},id:await g(1)});return b(await y({...f,re:v.id}))}case`edited`:case`deleted`:case`reaction`:{let t=(await N({thread:a.subthread??a.thread,message:a.message})).message;if(t===null)return{root:m??null,message:null};let n=`author`in a?a.author:{id:`${e}:system`,handle:u.platform,name:u.platform,avatar:null,isBot:!0},r={thread:a.subthread??a.thread,message:a.message};if(m!==void 0&&await T(n,m),a.kind===`deleted`)await o(`syncImport`,{op:`delete`,author:n,from:e,origin:r});else if(a.kind===`edited`){let s=await O(t),c=z(H(i.text??a.text,s?me(s.text):[]),(s?.attachments.length??0)>0);s&&!a.linksOnly&&s.text!==c&&await v(await o(`syncImport`,{op:`edit`,author:n,from:e,origin:r,text:c,source:_}));let l=s?await De(u,a.links??[],r,s.channel,s.links):[];s&&!he(l,s.links)&&await o(`syncImport`,{op:`links`,author:n,from:e,origin:r,links:l})}else{if(u.singleReaction){let i=k(a.emoji),s=/* @__PURE__ */ new Set([n.id,`${await F()}+${n.id}`]);for(let[c,l]of Object.entries((await O(t))?.reactions??{}))l.some(e=>s.has(e))&&!(a.added&&c===i)&&await o(`syncImport`,{op:`react`,author:n,from:e,origin:r,emoji:c,remove:!0})}(!u.singleReaction||a.added)&&await o(`syncImport`,{op:`react`,author:n,from:e,origin:r,emoji:a.emoji,remove:!a.added})}return{root:m??null,message:t}}case`lifecycle`:{if(m!==void 0){let t=await O(m),r=t?.origin?.message===`lifecycle:${n.id}`,c=S((r?C({text:J(a),labels:a.labels,author:a.author,raw:s}):null)?.labels??a.labels),l=e=>a.owns?.some(t=>e.startsWith(t))??!1,u=Object.fromEntries(Object.entries(c).filter(([e,n])=>t?.labels[e]!==n)),d=Object.keys(t?.labels??{}).filter(e=>!(e in c)&&(a.unset.includes(e)||i.unset?.includes(e)||l(e)));if(t&&!t.deleted&&(Object.keys(u).length||d.length)&&await w(a.author,u,d),a.retitled&&t&&!t.deleted&&t.from===e&&t.origin?.thread===a.thread){let n=z(i.text??C({text:J(a),labels:t.labels,author:a.author,raw:s}).text);t.text!==n&&await v(await o(`syncImport`,{op:`edit`,author:a.author,from:e,origin:{thread:t.origin.thread,message:t.origin.message},text:n}))}return a.reply?b(await y({author:a.author,re:m,text:z(i.text??a.reply),...i.noSync?{noSync:!0}:{},id:await g(1)})):{root:m,message:r?m:null}}if(!a.createRoot)return{root:null,message:null};let t=C({text:J(a),labels:a.labels,author:a.author,raw:s}),c=await y({author:a.author,channel:r,text:z(a.reply?t.text:i.text??t.text),labels:S(t.labels),origin:{channel:a.channel,thread:a.thread,subthread:null,message:`lifecycle:${n.id}`,context:null},id:await g(0)});return a.reply?b(await y({author:a.author,re:c.id,text:z(i.text??a.reply),...i.noSync?{noSync:!0}:{},id:await g(1)})):b(c)}}}async function Ne(e,t,n,r){let i=m(r);if(i.length===0)return r;let a=/* @__PURE__ */ new Map;for(let t of i)t.kind===`actor`&&!n.byId[t.actor]&&S(t.actor)&&a.set(t.actor,await be(e,t.actor));let o=/* @__PURE__ */ new Map;for(let t of i){if(t.kind!==`handle`)continue;let r=Object.values(n.byId).filter(e=>{let n=e.handle.toLowerCase();return n===t.handle||!t.handle.includes(`/`)&&n.slice(n.indexOf(`/`)+1)===t.handle});o.set(t.handle,r.flatMap(t=>{let r=Y(e,t.id,n);return r===null?[]:[{id:t.id,mention:r}]}))}let s=[...o.values()].some(e=>new Set(e.map(e=>e.mention)).size>1)?new Set((await D(t.re??t.id)).map(e=>e.by.actor)):null,c=e=>{let t=new Set(e.map(e=>e.mention));return t.size===1?[...t][0]:null};return re(r,t=>{if(t.kind===`handle`){let e=o.get(t.handle)??[];return c(e)??(s?c(e.filter(e=>s.has(e.id))):null)}if(a.has(t.actor))return a.get(t.actor)??t.actor;let r=Pe(t.actor,n);return r?Y(e,r.id,n)??r.name:null})}function Pe(e,t){return t.byId[e]??(t.principal?t.byId[`${t.principal}+${e}`]:void 0)??null}function Fe(e,t,n){let{principal:r,profile:i}=y(t),a=i===null?t:f(i)!==null&&r===n.principal?i:null;return a?.startsWith(`${e}:`)?a.slice(e.length+1):null}function Y(e,t,n){let r=n.byId[t],i=r?Fe(e,t,n):null;if(i===null)return null;let a=c(e);return a.mention({...r,id:`${a.platform}:${i}`})}async function Ie(t,n,r,i,a){let o=i.byId[r.by.actor],s=o?.name??r.by.actor,l=`${o?.via?` ${te(o.via)}`:``}${r.from?` (${o?.platform??e[r.from]?.platform??r.from})`:``}`,u=o?.kind===`deployment`&&!o.via?/(?:@[^@/]+| \([^()]+\))$/.exec(s)?.[0]??``:``,f=`${s}${l}`,p=`${u}${l}`,m=c(t),h=(a??(e=>m.render(e)))(A({message:{...structuredClone(r),text:fe(r.text,r.by.actor)},author:o?{...o}:null,mentionOf:e=>Y(t,e,i),label:f,target:n}));if(typeof h!=`string`)throw d(`a provider renderer must return markdown`);let g=`**${f}**: `,_=await Ne(t,r,i,h.startsWith(g)&&ue(h.slice(g.length))?`**${f}**:\n\n${h.slice(g.length)}`:h),v=r.by.actor===`github:user:35613825`?de(r.text):null;return{markdown:_,...o?.verified?{as:{name:f,avatar:Le(r,o),attribution:p}}:{},...v?{deployments:v}:{}}}function Le(e,t){let n=e=>!e||/\/avatars\/[a-z0-9-]+$/.test(e),r=t?.avatar??null;if(!n(r))return r;let i=t?.handle.split(`/`)[0]??``,a=e.by.principal.slice(12);return!e.by.principal.startsWith(`vercel:user:`)||!i||/^user-/.test(i)||i.toLowerCase()===a.toLowerCase()?r:`https://vercel.com/api/www/avatar?u=${encodeURIComponent(i)}&s=64&format=png`}let Re=e=>e.attachments.map(t=>`\n📎 ${t.name} (${n(t.size)}, on the board: #${e.id})`).join(``),X=async(e,t,n,r=!1,i)=>{let a=l(e),{markdown:o,...s}=await Ie(a,e,t,n,i);return{markdown:t.attachments.length>0&&(r||!c(a).uploadsFiles)?`${o}\n${Re(t)}`:o,...s}};async function ze(e,t,n,r,i){let a=e.replyTo===null?void 0:(await M([e.replyTo]))[e.replyTo]?.[t],o=a!==void 0&&a.thread!==n?a.thread:n,s=c(l(t)),u=await X(t,e,r,!1,i),f,p;if(!u.markdown.trim()&&e.attachments.length&&s.uploadsFiles)try{let n=await He(e,t,o);p=n.message,f=n.files}catch(n){if(!s.refusesFiles(n)&&!V(n))throw n;u=await X(t,e,r,!0,i),p=(await s.post(x(o),`thread`,u)).message,f=null}else{if(!u.markdown.trim())throw d(`a renderer must return text unless the message has media`);p=(await s.post(x(o),`thread`,u)).message}let m={thread:o,message:p,...f===void 0?{}:{files:f}};return await Be(e,t,m),m}async function Be(e,t,n){await o(`syncReceipt`,{kind:`message`,message:e.id,target:t,external:{thread:n.thread,message:n.message},...n.files===void 0?{}:{files:n.files}})}async function Ve(e){return Promise.all(e.attachments.map(async e=>{let{data:t}=await o(`attachment`,{id:e.id});return{data:t instanceof Uint8Array?t:new Uint8Array(await new Response(t).arrayBuffer()),filename:e.name,mimeType:e.type}}))}async function He(e,t,n){return c(l(t)).uploadFiles(x(n),await Ve(e))}async function Z(e,t,n,r,i){let a=c(l(t));if(!a.uploadsFiles||e.attachments.length===0||n.files!==void 0)return;let s;try{s=(await He(e,t,n.thread)).files}catch(o){if(!a.refusesFiles(o)&&!V(o))throw Object.assign(/* @__PURE__ */ Error(`files: ${G(o)}`),{cause:o,data:{error:`files: ${G(o)}`}});console.warn(`[board] ${t} won't take #${e.id}'s files (${G(o)}); noting them in its text`),s=null,await X(t,e,r,!0,i).then(e=>a.edit(x(n.thread),n.message,e)).catch(n=>console.warn(`[board] couldn't note #${e.id}'s files on ${t}:`,G(n)))}await o(`syncReceipt`,{kind:`files`,message:e.id,target:t,files:s})}let Q=(e,t,n,r)=>{e.some(e=>e.error===r)||e.push({id:t,target:n,error:r})};async function Ue(e,t){if(t.length!==0){if(e<5||w(e))throw t[0].error;for(let{id:e,target:n,error:r}of t)console.error(`[board] gave up ${n===null?`syncing #${e}`:`delivering #${e} to ${n}`}:`,G(r)),n!==null&&await o(`syncReceipt`,{kind:`failed`,message:e,target:n,error:G(r)})}}async function $(e,t,n,r,i){let a,o=!0,s=()=>d(`the sync function has finished`),l={direction:`out`,key:e,channel:r===null?null:U(e,r),event:A(structuredClone(t)),message:A(structuredClone(n)),target:r,deliver(e={}){if(!o)throw s();return a??=r===null?Promise.resolve():i(e.render),a},start(t){if(!o)throw s();return We(e,n,t)},resolve:t=>R(e,t)};try{await c(e).sync(l),await a}finally{o=!1}}async function We(e,t,n){let{target:r,kind:i}=await xe(`${e}:${n}`),a=t.re===null?t:await O(t.re);!a||a.deleted||a.noSync||r!==(a.origin?a.origin.channel??C(a.origin.thread):null)&&await o(`syncReceipt`,{kind:`thread`,message:a.id,target:r,targetKind:i,cause:`config`})}async function Ge(t,n){let r=[];for(let t of Object.keys(e))e[t].canStartThreads&&await g(t)&&r.push(t);if(t.payload.noSync||r.length===0)return;let i=await O(t.message.id);if(!i||i.deleted)return;let a=[];for(let e of r)try{await $(e,t,i,null,async()=>{})}catch(e){Q(a,i.id,null,e)}await Ue(n,a)}async function Ke(e,t){let{thread:n,target:r}=e.payload;if(!await b(r)||(e.payload.kind??(v(r)?`thread`:`channel`))===`thread`)return;let i=await E(n);if(!i?.targets.includes(r))return;let[a,...o]=await D(i.root);if(!a||a.id!==i.root||a.deleted)return;let s=[];try{await $(l(r),e,a,r,e=>qe(i,a,o,r,s,e))}catch(e){Q(s,a.id,r,e)}await Ue(t,s)}async function qe(e,t,n,r,i,a){let o=await I(),s=await M([t.id,...n.map(e=>e.id)]),u=e=>(i.push({id:t.id,target:r,error:e}),e),f=e.external[r];if(f){let e=s[t.id]?.[r];if(e)try{await Z(t,r,e,o,a)}catch(e){throw u(e)}}else try{let e=c(l(r)),n=await X(r,t,o,!1,a),i=!n.markdown.trim()&&t.attachments.length>0&&e.uploadsFiles;if(!n.markdown.trim()&&!i)throw d(`a renderer must return text unless the message has media`);let s,u=await(async()=>{if(!i&&(t.attachments.length===0||!e.startsThreadsWithFiles))return e.post(x(r),`channel`,n);try{let a=await e.post(x(r),`channel`,{...n,files:await Ve(t)});return s=i?a.files??[]:a.files,a}catch(n){if(!e.refusesFiles(n)&&!V(n))throw n;return s=null,e.post(x(r),`channel`,await X(r,t,o,!0,a))}})();f=`${l(r)}:${u.thread}`;let p={thread:f,message:u.message,...s===void 0?{}:{files:s}};await Be(t,r,p),await Z(t,r,p,o,a)}catch(e){throw u(e)}let p=[];for(let e of n)if(!(e.deleted||e.noSync||Je(e,r)))try{await Z(e,r,s[e.id]?.[r]??await ze(e,r,f,o,a),o,a)}catch(t){p.push({id:e.id,target:r,error:t})}if(i.push(...p),p.length)throw p[0].error}let Je=(e,t)=>e.origin?.thread===t||e.from!==null&&l(t)===e.from;async function Ye(e,t){if(!e.message)return;if(e.message.re===null)return Ge(e,t);if(e.payload.noSync)return;let n=await E(e.payload.thread);if(!n||n.targets.length===0)return;let r=await O(e.message.id);if(!r||r.deleted)return;let i=await I(),a=[];for(let t of n.targets){let o=n.external[t];if(await b(t)&&o&&!Je(r,t))try{await $(l(t),e,r,t,async e=>{let n=(await M([r.id]))[r.id]?.[t]??await ze(r,t,o,i,e);await Z(r,t,n,i,e)})}catch(e){Q(a,r.id,t,e)}}await Ue(t,a)}async function Xe(e){let t=(await M([e.payload.id]))[e.payload.id]??{};if(Object.keys(t).length===0)return;let n=e.type===`message.edited`?await O(e.payload.id):e.message??await O(e.payload.id);if(!n||e.type===`message.edited`&&n.deleted)return;let r=await I();for(let[i,a]of Object.entries(t))if(!(!await b(i)||e.payload.from!==null&&l(i)===e.payload.from))try{await $(l(i),e,n,i,async t=>{let o=c(l(i)),s=x(a.thread);e.type===`message.edited`?await o.edit(s,a.message,await X(i,n,r,a.files===null,t)):e.type===`message.deleted`?(await o.delete(s,a.message),a.files?.length&&await o.deleteFiles(a.files)):e.type===`reaction.added`?await o.react(s,a.message,k(e.payload.emoji),!0):await o.react(s,a.message,k(e.payload.emoji),!1)})}catch(t){console.warn(`[board] skipped ${e.type} on ${i}:`,t.message)}}async function Ze(e){let{id:t}=e.payload,n=(await M([t]))[t]??{},r=e.message;if(!r||Object.keys(n).length===0)return;let i=await O(t);if(!i||i.deleted)return;let a=await I(),o={...i,labels:r.labels},s={...i,labels:e.before?.labels??{}};for(let[t,r]of Object.entries(n))if(await b(t))try{await $(l(t),e,o,t,async e=>{let n=await X(t,o,a,r.files===null,e);n.markdown!==(await X(t,s,a,r.files===null,e)).markdown&&await c(l(t)).edit(x(r.thread),r.message,n)})}catch(e){console.warn(`[board] skipped labels.changed on ${t}:`,G(e))}}async function Qe(e,{attempt:t}){switch(e.type){case`thread.synced`:return Ke(e,t);case`message.posted`:return Ye(e,t);case`message.edited`:case`message.deleted`:case`reaction.added`:case`reaction.removed`:return Xe(e);case`labels.changed`:return Ze(e)}}async function $e(e,t){let n=e[0]?await E(e[0].thread):null;if(!n)return[];let r=[];for(let e of new Set(Object.values(n.external)))await b(e)&&r.push(e);return(await Promise.all(r.map(async n=>{let r=l(n);try{let i=c(r),a=null;for(let t=e.length-1;t>=0&&a===null;t--){let r=e[t];!r.deleted&&r.origin?.thread===n&&(a=r.origin.message)}return await i.startTyping(x(n),a,t),n}catch(e){return console.warn(`[board] skipped typing on ${n}:`,G(e)),null}}))).filter(e=>e!==null)}async function et(e,t){try{return`${e}:${await c(e).resolveChannel(t)}`}catch(e){throw d(`can't resolve inbox channel: ${e.message}`)}}let tt=e=>e===`unsupported`||e===`invalid_target`?400:e===`channel_not_found`?404:e===`ratelimited`?429:[`no_client`,`list_failed`,`internal_error`,`fatal_error`,`service_unavailable`,`request_timeout`].includes(e)?502:403;async function nt(e,t,n,r){let i=c(e);try{return await i.read(t,{limit:n,after:r})}catch(n){throw n instanceof j?new _(tt(n.code),n.code,n.message):d(`can't read ${t} from ${e}: ${G(n)}`,`platform_error`)}}async function rt(e,t){let n=c(e);try{return await n.join(t)}catch(n){throw n instanceof j?new _(tt(n.code),n.code,n.message):d(`can't join ${t} on ${e}: ${G(n)}`,`platform_error`)}}return{entries:e,bind(e){t=e},caller:a,deliver:Qe,receive:ke,pull:Te,normalizeTarget:xe,handleWebhook:we,inboxChannel:et,typing:$e,readSource:nt,joinSource:rt}}function J(e){let t=e.url?`${e.title}\n${e.url}`:e.title;return e.body?`${t}\n\n${e.body}`:t}export{q as createSyncEngine,K as keyedId};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./schemas-
|
|
3
|
-
import { t as Failed, u as who } from "./main-
|
|
1
|
+
import { g as InvalidProfileHeader, v as parseProfileHeader, y as ATTACHMENT_BYTES_MAX } from "./errors-DZ1tbwSM.mjs";
|
|
2
|
+
import "./schemas-7VFdomFB.mjs";
|
|
3
|
+
import { t as Failed, u as who } from "./main-BYmbTDgo.mjs";
|
|
4
4
|
import { t as page } from "./page-D-OzDOAX.mjs";
|
|
5
5
|
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
6
6
|
import { createServer } from "node:http";
|
|
@@ -74,20 +74,32 @@ a:focus-visible, button:focus-visible, [role='separator']:focus-visible { outlin
|
|
|
74
74
|
|
|
75
75
|
/* --- sidebar: same background as the page; its edge is the resize line --- */
|
|
76
76
|
.sidebar { position: relative; flex-shrink: 0; display: flex; }
|
|
77
|
-
.sidebar-
|
|
77
|
+
.sidebar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
|
78
|
+
/* What's said on the board scrolls; its settings and who you are stay put under it. */
|
|
79
|
+
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 8px 12px; }
|
|
80
|
+
.sidebar-foot { flex-shrink: 0; padding: 4px 8px 12px; }
|
|
78
81
|
.brand {
|
|
79
82
|
height: 46px;
|
|
80
83
|
flex-shrink: 0;
|
|
81
84
|
display: flex;
|
|
82
85
|
align-items: center;
|
|
83
86
|
justify-content: space-between;
|
|
84
|
-
margin: 0 -8px 8px;
|
|
85
87
|
padding: 0 8px 0 16px;
|
|
86
88
|
border-bottom: 1px solid var(--hairline);
|
|
87
89
|
color: var(--bright);
|
|
88
90
|
font-weight: 600;
|
|
91
|
+
gap: 8px;
|
|
89
92
|
}
|
|
90
|
-
|
|
93
|
+
/* Which board this is: its name, and where it is under it. */
|
|
94
|
+
.brand .which { display: grid; min-width: 0; line-height: 1.3; }
|
|
95
|
+
.brand .name, .brand .at { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
96
|
+
.brand .at { color: var(--faint); font-size: 11px; font-weight: 400; }
|
|
97
|
+
.sidebar h2 { display: flex; align-items: center; justify-content: space-between; height: 18px; margin: 16px 8px 4px; font-size: 11px; font-weight: 500; color: var(--faint); }
|
|
98
|
+
.sidebar h2 .tool { min-width: 20px; height: 20px; margin-right: -6px; padding: 0; color: var(--faint); }
|
|
99
|
+
.sidebar .item.settings { gap: 8px; color: var(--faint); font-size: 12px; }
|
|
100
|
+
.sidebar .item.settings:hover, .sidebar .item.settings[aria-current='page'] { color: var(--bright); }
|
|
101
|
+
.new-channel { display: flex; align-items: center; gap: 2px; margin: 2px 0 4px; }
|
|
102
|
+
.new-channel input { flex: 1; min-width: 0; height: 28px; padding: 0 8px; border: 0; outline: 1px solid var(--muted); background: var(--shade); font-size: 12px; }
|
|
91
103
|
.sidebar .item {
|
|
92
104
|
display: flex;
|
|
93
105
|
align-items: center;
|
|
@@ -102,12 +114,11 @@ a:focus-visible, button:focus-visible, [role='separator']:focus-visible { outlin
|
|
|
102
114
|
.sidebar .item.unread { color: var(--bright); font-weight: 600; }
|
|
103
115
|
.sidebar .count { color: var(--faint); font-size: 11px; font-weight: 400; }
|
|
104
116
|
.sidebar .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
|
|
105
|
-
.whoami-wrap {
|
|
117
|
+
.whoami-wrap { padding-top: 2px; }
|
|
106
118
|
.whoami { width: 100%; display: flex; align-items: center; gap: 6px; padding: 6px 8px; color: var(--muted); font-size: 11px; text-align: left; }
|
|
107
119
|
.whoami:hover, .whoami[data-popup-open] { background: var(--shade); color: var(--bright); }
|
|
108
|
-
.whoami .
|
|
109
|
-
.whoami
|
|
110
|
-
.whoami.naming { margin-top: auto; flex-direction: column; align-items: stretch; }
|
|
120
|
+
.whoami .as { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
121
|
+
.whoami.naming { flex-direction: column; align-items: stretch; }
|
|
111
122
|
.whoami.naming .send { align-self: flex-end; }
|
|
112
123
|
.whoami.naming input { width: 100%; height: 28px; padding: 0 8px; border: 0; outline: 1px solid var(--muted); background: var(--shade); font-size: 12px; }
|
|
113
124
|
.choice { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
|
@@ -144,6 +155,19 @@ a:focus-visible, button:focus-visible, [role='separator']:focus-visible { outlin
|
|
|
144
155
|
.header .title { color: var(--bright); font-weight: 600; }
|
|
145
156
|
.header .meta { color: var(--faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
|
|
146
157
|
.header .spacer { flex: 1; }
|
|
158
|
+
.header.flat { border-bottom: 0; }
|
|
159
|
+
|
|
160
|
+
/* --- tabs: plain text, the current one underlined. Under a flat header they carry its hairline. --- */
|
|
161
|
+
.tabs { flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; min-height: 34px; padding: 0 20px; border-bottom: 1px solid var(--hairline); }
|
|
162
|
+
.tabs.plain { border-bottom: 0; padding-top: 4px; }
|
|
163
|
+
.tab { padding: 7px 0; margin-bottom: -1px; border-bottom: 1px solid transparent; color: var(--muted); white-space: nowrap; cursor: default; }
|
|
164
|
+
.tab:hover { color: var(--bright); }
|
|
165
|
+
.tab[aria-current='page'] { border-bottom-color: var(--accent); color: var(--bright); }
|
|
166
|
+
.tab-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
|
|
167
|
+
.tab-actions .act { height: 24px; }
|
|
168
|
+
.text-link { color: var(--accent); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; white-space: nowrap; cursor: default; }
|
|
169
|
+
.text-link:hover { text-decoration-color: currentColor; }
|
|
170
|
+
.tool.only-narrow, .scrim { display: none; }
|
|
147
171
|
.header > .tool:first-child { margin-left: -8px; }
|
|
148
172
|
|
|
149
173
|
.live { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 11px; }
|
|
@@ -360,6 +384,7 @@ button.file:hover { background: var(--shade-hover); color: var(--bright); }
|
|
|
360
384
|
.suggest input { width: 100%; min-width: 0; height: 28px; border: 0; outline: none; background: none; }
|
|
361
385
|
.suggest:focus-within { outline: 1px solid var(--muted); }
|
|
362
386
|
.suggest .prefix { color: var(--faint); }
|
|
387
|
+
.suggest input::placeholder { color: var(--faint); }
|
|
363
388
|
.label-add > .suggest { width: 38%; }
|
|
364
389
|
|
|
365
390
|
/* --- filters --- */
|
|
@@ -408,25 +433,209 @@ button.file:hover { background: var(--shade-hover); color: var(--bright); }
|
|
|
408
433
|
.composer-footer .hint { margin-left: auto; margin-right: 8px; }
|
|
409
434
|
.pane .composer-footer .hint { display: none; }
|
|
410
435
|
.pane .composer-footer .send { margin-left: auto; }
|
|
411
|
-
.send { height: 32px; padding: 0 12px; background: var(--accent); color: var(--label); font-weight: 500; }
|
|
436
|
+
.send { height: 32px; padding: 0 12px; background: var(--accent); color: var(--label); font-weight: 500; white-space: nowrap; }
|
|
412
437
|
.send.small { height: 28px; padding: 0 10px; }
|
|
413
438
|
.send:disabled { opacity: 0.5; }
|
|
414
439
|
|
|
440
|
+
/* --- a view that isn't a feed: rows under a header --- */
|
|
441
|
+
.page { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0 16px; }
|
|
442
|
+
.more { display: block; margin: 8px 20px; }
|
|
443
|
+
/* A few facts, each a quiet name and what it is. */
|
|
444
|
+
.facts { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 3px 10px; margin: 0; }
|
|
445
|
+
.facts dt { color: var(--faint); font-size: 11px; line-height: 18px; }
|
|
446
|
+
.facts dd { margin: 0; color: var(--dim); overflow-wrap: anywhere; }
|
|
447
|
+
.segment.small { height: 22px; padding: 0 8px; font-size: 11px; }
|
|
448
|
+
|
|
449
|
+
/* --- buttons that act, and the small forms that ask first --- */
|
|
450
|
+
.acts { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
451
|
+
.acts .act[aria-haspopup] { padding: 0 7px; }
|
|
452
|
+
.act { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; background: var(--shade); color: var(--dim); font-size: 12px; white-space: nowrap; }
|
|
453
|
+
.act:hover, .act[data-popup-open] { background: var(--shade-hover); color: var(--bright); }
|
|
454
|
+
.act.primary, .act.primary:hover { background: var(--accent); color: var(--label); }
|
|
455
|
+
.act.danger { color: var(--red); }
|
|
456
|
+
/* A row's own control: there when you're on the row, and it says what it is only when you reach for it. */
|
|
457
|
+
.act.quiet { visibility: hidden; background: none; color: var(--muted); }
|
|
458
|
+
:hover > .act.quiet, :focus-within > .act.quiet { visibility: visible; }
|
|
459
|
+
.act.quiet:hover, .act.quiet:focus-visible { background: var(--shade-hover); color: var(--red); }
|
|
460
|
+
.act:disabled { opacity: 0.5; }
|
|
461
|
+
.ask { display: grid; gap: 8px; }
|
|
462
|
+
.ask textarea { width: 100%; min-height: 64px; padding: 6px 8px; border: 0; outline: none; background: var(--shade); font-size: 13px; line-height: 1.5; resize: vertical; }
|
|
463
|
+
.ask textarea:focus { outline: 1px solid var(--muted); }
|
|
464
|
+
.ask .hint { margin: 0; }
|
|
465
|
+
.ask .suggest .prefix { margin-right: 8px; font-size: 11px; white-space: nowrap; }
|
|
466
|
+
.ask .send { justify-self: end; }
|
|
467
|
+
|
|
468
|
+
/* --- tasks: a thread with a state, so one more line on its root --- */
|
|
469
|
+
.task-state { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; white-space: nowrap; }
|
|
470
|
+
.task-state svg { flex-shrink: 0; }
|
|
471
|
+
.task-state.ready, .task-state.claimed, .task-state.blocked { color: var(--bright); }
|
|
472
|
+
.task-state.completed { color: var(--dim); }
|
|
473
|
+
.task-state.failed { color: var(--red); }
|
|
474
|
+
.task-state.waiting, .task-state.canceled { color: var(--faint); }
|
|
475
|
+
.task-line, .task-head { display: flex; flex-wrap: wrap; align-items: center; margin-left: -15px; clip-path: inset(0 0 0 15px); }
|
|
476
|
+
/* Each item carries its own separator, and the row clips the ones at its left edge: none starts a line. */
|
|
477
|
+
.task-line > *, .task-head > * { position: relative; padding-left: 15px; }
|
|
478
|
+
.task-line > *::before, .task-head > *::before { content: '\\00b7'; position: absolute; left: 4px; color: var(--faint); font-weight: 400; }
|
|
479
|
+
.task-line { margin-top: 3px; color: var(--muted); font-size: 12px; }
|
|
480
|
+
.task-note { color: var(--dim); overflow-wrap: anywhere; }
|
|
481
|
+
.lease { font-variant-numeric: tabular-nums; }
|
|
482
|
+
.needs { display: inline-flex; flex-wrap: wrap; gap: 0 8px; }
|
|
483
|
+
.need { color: var(--accent); cursor: default; }
|
|
484
|
+
.need:hover { text-decoration: underline; }
|
|
485
|
+
.need-state { margin-left: 4px; color: var(--faint); }
|
|
486
|
+
.need-state.completed { color: var(--muted); }
|
|
487
|
+
.need-state.failed { color: var(--red); }
|
|
488
|
+
|
|
489
|
+
/* The task in full, under the thread's header: it's part of the header, so the hairline goes under it. */
|
|
490
|
+
.task-card { flex-shrink: 0; display: grid; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--hairline); font-size: 12px; }
|
|
491
|
+
.task-head { color: var(--dim); }
|
|
492
|
+
.task-head .task-state { font-size: 13px; font-weight: 600; }
|
|
493
|
+
.task-card .hint { margin: 0; }
|
|
494
|
+
|
|
495
|
+
.task-rows { display: grid; }
|
|
496
|
+
.task-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto auto 30px; align-items: center; gap: 14px; padding: 5px 20px; outline: none; }
|
|
497
|
+
.task-row:hover, .task-row[aria-current] { background: var(--shade); }
|
|
498
|
+
.task-row:focus-visible { outline: 2px dashed var(--accent); outline-offset: -2px; }
|
|
499
|
+
.task-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
|
|
500
|
+
.task-title .label { margin-left: 6px; vertical-align: 1px; }
|
|
501
|
+
.task-now { max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
|
|
502
|
+
.task-now .needs { display: inline; }
|
|
503
|
+
.task-now .need + .need { margin-left: 8px; }
|
|
504
|
+
.task-where { color: var(--faint); font-size: 12px; white-space: nowrap; }
|
|
505
|
+
.task-row .time { text-align: right; }
|
|
506
|
+
@media (max-width: 700px) {
|
|
507
|
+
.task-row { grid-template-columns: 88px minmax(0, 1fr) 30px; row-gap: 0; }
|
|
508
|
+
.task-where { display: none; }
|
|
509
|
+
.task-now { grid-column: 2 / -1; grid-row: 2; max-width: none; }
|
|
510
|
+
.task-now:empty { display: none; }
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.composer-task { display: flex; gap: 6px; margin: 8px 8px 0; }
|
|
514
|
+
.composer-task .suggest { flex: 1; }
|
|
515
|
+
.composer-task .prefix { margin-right: 8px; font-size: 11px; white-space: nowrap; }
|
|
516
|
+
|
|
517
|
+
/* --- blocks: the data a message carries, as a card where its fence was --- */
|
|
518
|
+
.block { max-width: 640px; margin: 6px 0; border: 1px solid var(--hairline); font-size: 12px; }
|
|
519
|
+
.block-head { display: flex; align-items: center; gap: 10px; height: 26px; padding: 0 0 0 10px; background: var(--shade); }
|
|
520
|
+
.block-head .spacer { flex: 1; }
|
|
521
|
+
.block-head .tool { height: 26px; }
|
|
522
|
+
.message.active .block-head { background: var(--shade-hover); }
|
|
523
|
+
.block-schema { color: var(--bright); font-weight: 600; cursor: default; }
|
|
524
|
+
.block-schema:hover { text-decoration: underline; }
|
|
525
|
+
.block-schema .faint { font-weight: 400; }
|
|
526
|
+
.block-fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 14px; margin: 0; padding: 7px 10px; cursor: text; }
|
|
527
|
+
.block-field { display: contents; }
|
|
528
|
+
.block-field dt { color: var(--faint); }
|
|
529
|
+
.block-field dd { margin: 0; color: var(--dim); overflow-wrap: anywhere; }
|
|
530
|
+
.block-field a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
|
|
531
|
+
.block-raw { margin: 0; padding: 7px 10px; color: var(--dim); font-family: inherit; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; }
|
|
532
|
+
|
|
533
|
+
/* --- schemas --- */
|
|
534
|
+
.schema-row { display: grid; grid-template-columns: minmax(120px, 200px) auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 6px 20px; }
|
|
535
|
+
.schema-row:hover { background: var(--shade); }
|
|
536
|
+
.schema-name { color: var(--bright); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
537
|
+
.schema-versions { display: flex; gap: 10px; }
|
|
538
|
+
.schema-versions .tab { padding: 0; margin: 0; }
|
|
539
|
+
.schema-about { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
|
|
540
|
+
.small { font-size: 11px; }
|
|
541
|
+
.schema-detail { display: grid; gap: 10px; padding: 4px 20px 16px; max-width: 860px; }
|
|
542
|
+
.schema-detail .hint { margin: 0; font-size: 12px; }
|
|
543
|
+
.schema-detail code { color: var(--dim); }
|
|
544
|
+
.schema-fields { display: grid; grid-template-columns: max-content max-content minmax(0, 1fr); gap: 3px 16px; font-size: 12px; cursor: text; }
|
|
545
|
+
.schema-field { display: contents; }
|
|
546
|
+
.field-name { color: var(--bright); }
|
|
547
|
+
.schema-json { position: relative; }
|
|
548
|
+
.schema-json pre { margin: 0; padding: 10px 12px; max-height: 360px; overflow: auto; border: 1px solid var(--hairline); background: var(--shade); color: var(--dim); font-family: inherit; font-size: 12px; line-height: 1.5; cursor: text; }
|
|
549
|
+
.schema-json .act { position: absolute; top: 6px; right: 6px; background: var(--bg); }
|
|
550
|
+
.ask textarea.code { min-height: 180px; font-size: 12px; white-space: pre; }
|
|
551
|
+
.suggest.version { width: 64px; flex-shrink: 0; }
|
|
552
|
+
.error-text { color: var(--red); }
|
|
553
|
+
@media (max-width: 700px) {
|
|
554
|
+
.schema-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0; }
|
|
555
|
+
.schema-about { grid-column: 1 / -1; grid-row: 2; }
|
|
556
|
+
.schema-row > .small { display: none; }
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/* --- access: grants, and the board's answer to who decides a channel --- */
|
|
560
|
+
.page h3 { margin: 16px 20px 4px; color: var(--faint); font-size: 11px; font-weight: 500; }
|
|
561
|
+
.page h3 b { color: var(--dim); font-weight: 600; }
|
|
562
|
+
.page > h3:first-child, .page > section:first-child h3 { margin-top: 6px; }
|
|
563
|
+
.grant-row { display: grid; grid-template-columns: 30px minmax(120px, 340px) minmax(0, 1fr) auto auto; align-items: center; gap: 12px; min-height: 30px; padding: 3px 20px; }
|
|
564
|
+
.grant-row:hover { background: var(--shade); }
|
|
565
|
+
.grant-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--bright); }
|
|
566
|
+
.grant-who .badge { margin-left: 8px; }
|
|
567
|
+
.grant-can { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
|
|
568
|
+
.grant-can b { color: var(--bright); font-weight: 600; }
|
|
569
|
+
.grant-row .act { height: 22px; }
|
|
570
|
+
.explain { display: grid; gap: 8px; padding: 2px 20px 6px; }
|
|
571
|
+
.explain-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
|
|
572
|
+
.explain-ask > .suggest { width: 200px; }
|
|
573
|
+
.who-fields { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
574
|
+
.who-fields .suggest { width: 190px; }
|
|
575
|
+
.ask .who-fields .suggest { flex: 1; width: auto; min-width: 150px; }
|
|
576
|
+
.ask textarea.code.can { min-height: 64px; }
|
|
577
|
+
.explained { display: grid; gap: 6px; max-width: 900px; padding: 10px 12px; background: var(--shade); cursor: text; }
|
|
578
|
+
.explained p { margin: 0; color: var(--dim); font-size: 14px; }
|
|
579
|
+
.explained b { color: var(--bright); font-weight: 600; }
|
|
580
|
+
.explained .facts { grid-template-columns: 56px minmax(0, 1fr); font-size: 12px; }
|
|
581
|
+
.explained .grant-row { margin: 0 -12px; padding: 3px 12px; }
|
|
582
|
+
.explained .grant-row:hover { background: var(--shade-hover); }
|
|
583
|
+
@media (max-width: 700px) {
|
|
584
|
+
.grant-row { grid-template-columns: 30px minmax(0, 1fr) auto; row-gap: 2px; padding: 5px 20px; }
|
|
585
|
+
.grant-can { grid-column: 2 / -1; grid-row: 2; }
|
|
586
|
+
.grant-row > .small { display: none; }
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/* --- schedules, watchers, and a thread's copies --- */
|
|
590
|
+
.sched-row { display: grid; grid-template-columns: 64px minmax(110px, 200px) minmax(0, 1fr) auto auto 52px; align-items: center; gap: 14px; min-height: 30px; padding: 3px 20px; }
|
|
591
|
+
.sched-row:hover { background: var(--shade); }
|
|
592
|
+
.sched-when { color: var(--bright); white-space: nowrap; }
|
|
593
|
+
.sched-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
|
|
594
|
+
.sched-row .act { height: 22px; justify-self: end; }
|
|
595
|
+
.watch-row { display: grid; grid-template-columns: minmax(90px, 180px) minmax(0, 1fr); gap: 14px; padding: 4px 20px; }
|
|
596
|
+
.watch-row:hover { background: var(--shade); }
|
|
597
|
+
.watch-id { color: var(--bright); }
|
|
598
|
+
.watch-row code { color: var(--dim); overflow-wrap: anywhere; }
|
|
599
|
+
.thread-facts { flex-shrink: 0; padding: 10px 20px; border-bottom: 1px solid var(--hairline); font-size: 12px; }
|
|
600
|
+
.thread-facts .fact { display: contents; }
|
|
601
|
+
.copies { display: flex; flex-wrap: wrap; gap: 2px 12px; }
|
|
602
|
+
.label-add.end { justify-content: flex-end; gap: 12px; }
|
|
603
|
+
.suggest input:disabled { opacity: 0.4; }
|
|
604
|
+
@media (max-width: 700px) {
|
|
605
|
+
.sched-row { grid-template-columns: 64px minmax(0, 1fr) auto; row-gap: 0; padding: 5px 20px; }
|
|
606
|
+
.sched-row > .faint { display: none; }
|
|
607
|
+
.sched-text { grid-column: 1 / -1; grid-row: 2; }
|
|
608
|
+
}
|
|
609
|
+
|
|
415
610
|
.inbox-row { display: grid; grid-template-columns: 70px 90px 1fr; gap: 12px; padding: 6px 20px; }
|
|
416
611
|
.inbox-row:hover { background: var(--shade); }
|
|
417
612
|
.inbox-row pre { margin: 4px 0 0; color: var(--faint); font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
418
613
|
|
|
614
|
+
/* --- a narrow page: the sidebar comes over it when it's asked for --- */
|
|
615
|
+
@media (max-width: 900px) {
|
|
616
|
+
.tool.only-narrow { display: inline-flex; }
|
|
617
|
+
.shell.nav .sidebar { display: flex; position: fixed; inset: 0 auto 0 0; z-index: 41; width: min(280px, 84vw) !important; opacity: 1 !important; border-right: 1px solid var(--hairline); background: var(--bg); }
|
|
618
|
+
.shell.nav .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: var(--accent-transparent); }
|
|
619
|
+
}
|
|
620
|
+
@media (max-width: 700px) {
|
|
621
|
+
.composer-footer .hint { display: none; }
|
|
622
|
+
.composer-footer .send { margin-left: auto; }
|
|
623
|
+
}
|
|
624
|
+
|
|
419
625
|
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
|
|
420
626
|
.toast { max-width: 420px; padding: 8px 12px; border: 1px solid var(--dim); background: var(--bg); color: var(--bright); }
|
|
421
627
|
`;
|
|
422
628
|
/** The prebuilt UI where board is installed, read only when an inspector starts without one. */
|
|
423
629
|
const bundle = async () => (await import("./page-Dr9Aqlej.mjs")).page();
|
|
424
|
-
const
|
|
630
|
+
const attribute = (value) => value.replace(/[&<>"']/g, (char) => `&#${char.charCodeAt(0)};`);
|
|
631
|
+
/** The page, with what only this run's page is told: its token for the proxy, and the profile inspect started as. */
|
|
632
|
+
const shell = (token, profile) => `<!doctype html>
|
|
425
633
|
<html lang="en">
|
|
426
634
|
<head>
|
|
427
635
|
<meta charset="utf-8">
|
|
428
636
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
429
637
|
<meta name="inspect-token" content="${token}">
|
|
638
|
+
<meta name="inspect-profile" content="${attribute(JSON.stringify(profile))}">
|
|
430
639
|
<title>board</title>
|
|
431
640
|
<style>${CSS}</style>
|
|
432
641
|
</head>
|
|
@@ -457,6 +666,10 @@ const CSP = [
|
|
|
457
666
|
async function startInspector(options) {
|
|
458
667
|
const { client } = options;
|
|
459
668
|
const me = await client.me();
|
|
669
|
+
const started = me.profile === null ? null : me.avatar ? {
|
|
670
|
+
name: me.profile,
|
|
671
|
+
avatar: me.avatar
|
|
672
|
+
} : me.profile;
|
|
460
673
|
const board = (await client.discovery().catch(() => null))?.url ?? client.url;
|
|
461
674
|
const app = options.page ?? await bundle();
|
|
462
675
|
const token = randomBytes(24).toString("base64url");
|
|
@@ -485,14 +698,23 @@ async function startInspector(options) {
|
|
|
485
698
|
response.on("close", () => controller.abort());
|
|
486
699
|
try {
|
|
487
700
|
const body = reading ? void 0 : await read(request, path === "/attachments" ? ATTACHMENT_BYTES_MAX : void 0);
|
|
488
|
-
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
name
|
|
492
|
-
avatar
|
|
493
|
-
|
|
701
|
+
let as = null;
|
|
702
|
+
const named = request.headers["x-board-profile"];
|
|
703
|
+
if (typeof named === "string" && named.trim() !== "") try {
|
|
704
|
+
const { name, avatar } = parseProfileHeader(named);
|
|
705
|
+
as = avatar === null ? name : {
|
|
706
|
+
name,
|
|
707
|
+
avatar
|
|
708
|
+
};
|
|
709
|
+
} catch (error) {
|
|
710
|
+
if (!(error instanceof InvalidProfileHeader)) throw error;
|
|
711
|
+
return json(response, 400, { error: {
|
|
712
|
+
code: "invalid_profile",
|
|
713
|
+
message: error.message
|
|
714
|
+
} });
|
|
715
|
+
}
|
|
494
716
|
const upstream = await client.request(`${path}${url.search}`, {
|
|
495
|
-
|
|
717
|
+
as,
|
|
496
718
|
method: request.method ?? "GET",
|
|
497
719
|
headers: {
|
|
498
720
|
...request.headers["content-type"] ? { "content-type": String(request.headers["content-type"]) } : {},
|
|
@@ -525,7 +747,7 @@ async function startInspector(options) {
|
|
|
525
747
|
if (url.pathname === "/board" || url.pathname.startsWith("/board/")) return void proxy(request, response, url).catch(() => response.headersSent ? response.end() : send(response, 500, "text/plain; charset=utf-8", "error"));
|
|
526
748
|
if (request.method !== "GET") return send(response, 405, "text/plain; charset=utf-8", "method not allowed");
|
|
527
749
|
if (url.pathname === "/app.js") return app ? send(response, 200, "text/javascript; charset=utf-8", app) : send(response, 503, "text/plain; charset=utf-8", "the inspector's UI isn't built: run `pnpm --filter @vercel/board build`");
|
|
528
|
-
send(response, 200, "text/html; charset=utf-8", shell(token), { "content-security-policy": CSP });
|
|
750
|
+
send(response, 200, "text/html; charset=utf-8", shell(token, started), { "content-security-policy": CSP });
|
|
529
751
|
});
|
|
530
752
|
const port = await listen(server, options.port ?? 4747, options.port === void 0);
|
|
531
753
|
const allowed = (options.hosts ?? []).map((host) => host.toLowerCase());
|