@vite-hub/comments 0.6.1 → 0.7.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/README.md +6 -4
- package/dist/{client-diagnostics-D987sEK7.js → client-diagnostics-DoXqdnBd.js} +8 -0
- package/dist/client.d.ts +48 -3
- package/dist/client.js +231 -150
- package/dist/{database-Cguz3hZL.js → database-BuSNVwTx.js} +1 -1
- package/dist/database.js +1 -1
- package/dist/{define-C2tnAtBU.js → define-BqPcuDhf.js} +1 -1
- package/dist/{errors-ByCRdInk.js → errors-CBvIpwbo.js} +1 -1
- package/dist/hosted/hosted-comments/frame.js +1 -1
- package/dist/hosted/hosted-comments/tools.js +371 -0
- package/dist/hosted/hosted-comments.js +1 -19
- package/dist/index.js +4 -4
- package/dist/{install-D6hXZaSN.js → install-CqBWFmU7.js} +21 -15
- package/dist/{installed-bPUnazFf.js → installed-wUYjqk_k.js} +1 -1
- package/dist/{operations-8hqTi0DH.d.ts → operations-DFLer1fR.d.ts} +1 -0
- package/dist/{operations-BkkrI8a3.d.ts → operations-Qt8ASQqW.d.ts} +1 -1
- package/dist/{operations-B1ALn4VS.js → operations-kMPw-Cyb.js} +6 -7
- package/dist/operations.d.ts +1 -1
- package/dist/operations.js +2 -2
- package/dist/overlay/client-CrnKCZXc.js +4 -0
- package/dist/overlay/overlay.js +62 -35
- package/dist/page/loader.js +25 -23
- package/dist/{page-tools-shared-fvmJQCrP.js → page-tools-shared-BNw-aWEH.js} +2 -5
- package/dist/{plugin-l4sPt5-n.js → plugin-ChOHe7vq.js} +7 -7
- package/dist/realtime.d.ts +4 -1
- package/dist/realtime.js +1 -1
- package/dist/{request-origin-YPzfE2eh.js → request-origin-B-CPVAVk.js} +6 -1
- package/dist/{rpc-BYmbVkr8.js → rpc-kkxzQ3Qy.js} +1 -1
- package/dist/rpc.js +1 -1
- package/dist/runtime/auth.js +1 -1
- package/dist/runtime/console.js +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +13 -13
- package/dist/{server-DvSehkPP.js → server-8o9u8leM.js} +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +6 -6
- package/dist/{service-BIGe1Hpo.js → service-XT2A8YEF.js} +2 -2
- package/dist/{session-CCRLR9bf.js → session-DGdFKWDB.js} +7 -6
- package/dist/testing.js +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +8 -4
- package/package.json +9 -8
- package/dist/hosted/hosted-comments/client-Czl2zu9P.js +0 -4
- package/dist/hosted/hosted-comments/dist-DyVmH21U.js +0 -14
- package/dist/hosted/hosted-comments/overlay-DpS0P-nd.js +0 -186
- package/dist/hosted/hosted-comments/protocol-DuB0Zhs-.js +0 -1
- package/dist/hosted/hosted-comments/rest-transport-CKZG_jZ4.js +0 -1
- package/dist/hosted/hosted-comments/tools-D8xg-kDW.js +0 -126
- package/dist/overlay/client-C7ftI-CB.js +0 -4
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import{a as e,n as t,r as n,s as r,t as i}from"./hosted-comments/protocol-DuB0Zhs-.js";var a=`vitehub`,o=[`comment`];function s(e,t){let n=new URLSearchParams(e);if(n.has(`vitehub`)||o.some(e=>n.has(e)))return!0;let r=t.split(`;`).map(e=>e.trim());return r.includes(`vitehub-tools=1`)?!0:r.includes(`vitehub_session=1`)&&!r.some(e=>e.startsWith(`vitehub-tools=`))}var c=`/_vitehub/page/assets`,l=`/_vitehub/page/tools`,u=`button{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:var(--vitehub-pill-justify,center);gap:4px;min-width:28px;height:28px;padding:0 8px;border-radius:8px;font:inherit;white-space:nowrap;color:var(--vitehub-pill-text);cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition-property:background-color,color;transition-duration:150ms;transition-timing-function:cubic-bezier(.23,1,.32,1)}
|
|
3
|
-
@media(hover:hover){button:where(:not(:disabled):hover){background:var(--vitehub-pill-hover);color:var(--vitehub-pill-strong)}}
|
|
4
|
-
button[aria-pressed=true],button[aria-expanded=true]{background:var(--vitehub-pill-on);color:var(--vitehub-pill-on-text)}
|
|
5
|
-
:host([aria-busy=true]) button,button[aria-busy=true]{background:var(--vitehub-pill-on);color:var(--vitehub-pill-on-text);cursor:progress}
|
|
6
|
-
button:focus-visible{outline:2px solid var(--vitehub-pill-on);outline-offset:1px}
|
|
7
|
-
button svg{width:14px;height:14px;flex:none}
|
|
8
|
-
@media(any-pointer:coarse){button{min-width:44px;height:44px}}
|
|
9
|
-
@media(prefers-reduced-motion:reduce){button{transition:none}}`,d=`data-vitehub-pill`;function f(e){let t=new URL(e,`http://localhost`).pathname,n=t.lastIndexOf(`${c}/`);return n===-1?l:`${t.slice(0,n)}${l}`}function p(e){return typeof e==`string`&&e?e:void 0}function m(e){if(typeof e!=`object`||!e)return;let t=p(Reflect.get(e,`id`)),n=p(Reflect.get(e,`script`));if(!t||!n)return;let r={id:t,label:p(Reflect.get(e,`label`))??t,icon:p(Reflect.get(e,`icon`))??``,script:n};Reflect.get(e,`lazy`)===!0&&(r.lazy=!0);let i=p(Reflect.get(e,`hotkey`));i&&(r.hotkey=i);let a=p(Reflect.get(e,`param`));return a&&(r.param=a),r}function h(e){if(typeof e!=`object`||!e)return;let t=p(Reflect.get(e,`name`)),n=p(Reflect.get(e,`signOut`));if(!t||!n?.startsWith(`/`)||n.startsWith(`//`)||n.includes(`\\`))return;let r={name:t,signOut:n},i=p(Reflect.get(e,`email`));i&&(r.email=i);let a=p(Reflect.get(e,`image`));return a&&/^https?:\/\//i.test(a)&&(r.image=a),Reflect.get(e,`via`)===`console`&&(r.via=`console`),Reflect.get(e,`guest`)===!0&&(r.guest=!0),r}function g(e){let t=typeof e==`object`&&e?Reflect.get(e,`tools`):void 0,n={tools:Array.isArray(t)?t.map(m).filter(e=>!!e):[]},r=typeof e==`object`&&e?h(Reflect.get(e,`account`)):void 0;return r&&(n.account=r),n}var _=`https://app.t3.codes/new`,v=/^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/(?!\.+$)[A-Za-z0-9._-]{1,100}$/,y=40;function b(e){return e&&v.test(e)?e:void 0}function x(e,t){return e.length>t?`${e.slice(0,t).trimEnd()}…`:e}function S(e,t){return e.kind===`page`?`on the whole page`:e.kind===`text`?`on the text "${x(e.exact,t)}" in ${x(e.selector,t)}`:`on ${x(e.selector,t)}`}function C(e,t){let[n,...r]=e.messages,i=e.revision===void 0?``:` (version ${e.revision})`;return[`"${x(n?.body??``,t)}" — ${n?.author??`Someone`}, ${S(e.anchor,t)}${i}`,...r.map(e=>`Reply: "${x(e.body,t)}" — ${e.author}`),...e.files?.length?[`Files: ${e.files.join(` `)}`]:[]]}function w(e,t){if(!e)return[`When you are done, tell me what you changed.`];let{mcp:n,project:r,resolve:i}=e,a=`operation "comments.get", and input { threadId } for ${t.length===1?`thread ${t[0]}`:`each ID in ${JSON.stringify(t)}`}`;return[`In the ViteHub MCP (${n}), use list_apps to verify team ${r.teamId} and app ${r.url} (id: ${r.id}). If the team is different, ask me to switch to that team in the Console; if the app is missing, ask me to check the link. Only after both match, call read_operation with the app id, ${a}.`,i?`When the fix is live, use run_operation with the app id, operation "comments.resolve", and input { threadId, reply }. In the reply, say what you changed.`:`Report the fixes to me without resolving the threads.`]}function T(e){return`${e.id}: "${x(e.messages[0]?.body??``,y)}"`}function E({agent:e,threads:t,url:n},r){let i=new URL(n).href,a=t.length===1,o=w(e,t.map(e=>e.id)),s=a?`Fix this comment on ${i}`:`Fix these ${t.length} comments on ${i}`;return r===`ids`?[s,...o].join(`
|
|
10
|
-
|
|
11
|
-
`):r===`titles`?[s,t.map((e,t)=>a?T(e):`${t+1}. ${T(e)}`).join(`
|
|
12
|
-
`),...o].join(`
|
|
13
|
-
|
|
14
|
-
`):a?[s,...C(t[0],r),...o].join(`
|
|
15
|
-
`):[s,...t.map((e,t)=>C(e,r).map((e,n)=>n===0?`${t+1}. ${e}`:` ${e}`).join(`
|
|
16
|
-
`)),o.join(`
|
|
17
|
-
`)].join(`
|
|
18
|
-
|
|
19
|
-
`)}function D(e){return E(e,1/0)}function O(e,t){let n=b(t),r=t=>{let r=new URL(_);return r.searchParams.set(`prompt`,E(e,t)),n&&r.searchParams.set(`repo`,n),r.href},i=[1/0];for(let e=2e3;e>=y;e=Math.floor(e/2))i.push(e);for(let t of[...i,`titles`,...e.agent?[`ids`]:[]]){let e=r(t);if(e.length<=8e3)return e}}var k=`modulepreload`,A=function(e,t){return new URL(e,t).href},j={},M=function(e){return e.pathname.endsWith(`.css`)},N=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},P=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=A(t,n);let r=s(t),i=M(r);return N(j,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:k,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},F=15e3,I=3e4,L=5e3,R=RegExp(`^#(/?)vhc=([\\w-]+)$`);function z(){let e=R.exec(location.hash);if(!e)return;let[,t,n]=e;return history.replaceState(history.state,``,`${location.pathname}${location.search}${t?`#/`:``}`),n}function B(e){try{return sessionStorage.getItem(e)===`1`}catch{return!1}}function V(e){try{sessionStorage.setItem(e,`1`)}catch{}}function H(i,a){let o=document.createElement(`iframe`);o.src=`${i}${n(a)}`,o.hidden=!0,o.tabIndex=-1,o.title=`ViteHub Comments`,o.setAttribute(`aria-hidden`,`true`),o.setAttribute(`data-comments-ui`,``);let s=new MessageChannel,c=new Map,l=0,u={call:(t,n)=>new Promise((i,a)=>{let o=++l,u=setTimeout(()=>{c.delete(o),a(r(0))},I);c.set(o,t=>{clearTimeout(u),t.ok?i(t):a(e(t.error))}),s.port1.postMessage({id:o,method:t,input:n})})};return new Promise((e,n)=>{let a=setTimeout(()=>n(r(0)),F);s.port1.addEventListener(`message`,({data:t})=>{if(typeof t==`object`&&t){if(Reflect.get(t,`event`)===`ready`)clearTimeout(a),e(u);else{let e=Reflect.get(t,`id`),n=typeof e==`number`?c.get(e):void 0;if(!n||typeof e!=`number`)return;c.delete(e),n(t)}}}),s.port1.start(),o.addEventListener(`load`,()=>o.contentWindow?.postMessage({type:t},i,[s.port2]),{once:!0}),o.addEventListener(`error`,()=>n(r(0)),{once:!0}),document.documentElement.append(o)})}async function U(e,t){return await new Promise(n=>{let r=setTimeout(()=>i(!1),L);function i(t){clearTimeout(r),e.removeEventListener(`message`,a),n(t)}function a({data:e}){e.type===`redeemed`&&e.code===t&&i(!0)}e.addEventListener(`message`,a),e.postMessage({type:`code`,code:t})})}async function W(e,t,n){let r=z(),a=`vitehub-comments:${e}`;if(!r&&!B(a)&&!s(location.search,document.cookie))return;V(a);let o=new BroadcastChannel(i(e)),c=H(t,e),l=async e=>(await(await c).call(`redeem`,e)).value===!0,u=P(()=>import(`./hosted-comments/tools-D8xg-kDW.js`).then(e=>e.t),__vite__mapDeps([0,1,2]),import.meta.url),d={id:e,console:t,...n?{repository:n}:{}};o.addEventListener(`message`,({data:e})=>{e.type===`code`&&l(e.code).then(t=>{t&&(o.postMessage({type:`redeemed`,code:e.code}),u.then(({mountHostedComments:e})=>e(c,d)))},()=>void 0)});let f=r?await l(r).catch(()=>!1):!1;if(r&&!f&&await U(o,r)){window.close();return}let{mountHostedComments:p}=await u;await p(c,d)}var G=document.querySelector(`script[data-vitehub-comments]`),K=G?.dataset.vitehubComments;K&&W(K,new URL(import.meta.url).origin,b(G?.dataset.vitehubRepo));export{f as a,s as c,g as i,d as l,D as n,o,O as r,a as s,P as t,u};
|
|
1
|
+
var e=`vitehub`,t=[`comment`];function n(e,n){let r=new URLSearchParams(e);if(r.has(`vitehub`)||t.some(e=>r.has(e)))return!0;let i=n.split(`;`).map(e=>e.trim());return i.includes(`vitehub-tools=1`)?!0:i.includes(`vitehub_session=1`)&&!i.some(e=>e.startsWith(`vitehub-tools=`))}`${JSON.stringify([e,...t])}`;var r=/^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/(?!\.+$)[A-Za-z0-9._-]{1,100}$/;function i(e){return e&&r.test(e)?e:void 0}function a(e,...t){return typeof e==`function`?e(...t):e}var o=Error.captureStackTrace,s=class e extends Error{get why(){return this.message}constructor(t,n=e){super(t.why,{cause:t.cause}),this.code=this.name=t.code,this.docs=t.docs,this.fix=t.fix,this.sources=t.sources,this.data=t.data,o?.(this,n)}toJSON(){return{name:this.name,why:this.why,fix:this.fix,docs:this.docs,sources:this.sources,cause:this.cause,data:this.data,stack:this.stack}}};function c(e,t){return typeof e==`string`?`${e}/${t.toLowerCase()}`:e?.(t)}var l=e=>t=>t instanceof s&&e in t;function u(e){let t=e.reporters??[],n=Symbol(),r=Object.defineProperty({},"is",{value:l(n)}),{docsBase:i}=e;for(let o of Object.keys(e.codes)){let l=e.codes[o],u=l.docs===!1?void 0:l.docs||c(i,o),d=(e={},r={})=>{let i=new s({code:o,why:a(l.why,e),fix:a(l.fix,e),docs:u,cause:e.cause,sources:e.sources,data:a(l.data,e)},d);i[n]=1;for(let e of t)e(i,r);return i};d.is=e=>r.is(e)&&e.code===o,r[o]=d}return r}var d=u({docsBase:`https://vitehub.dev/docs/comments/diagnostics`,codes:{COMMENTS_HOSTED_CONFLICT:{why:`This page runs the app's own Comments, so the Hosted Comments script does not start its overlay.`,fix:"Remove the Hosted Comments script, or keep it and set `comments: { overlay: false }` to turn off the app's overlay. See https://vitehub.dev/docs/comments/configure#add-hosted-comments"},COMMENTS_OUTBOX_ACCOUNT_CHANGED:{why:`The current author is not the author of this queued comment.`,fix:`Sign in as the original author and retry the outbox.`},COMMENTS_OUTBOX_RESOLVE_BLOCKED:{why:`Queued delivery must resume before the thread can close.`,fix:`Go online, then retry or dismiss any blocked comments and resolve the thread again.`},COMMENTS_OUTBOX_SENDING:{why:`The server may already have this comment, so the draft cannot change.`,fix:`Wait for delivery to finish, then edit or delete the server copy.`},COMMENTS_OVERLAY_ELEMENT_TAKEN:{why:({name:e})=>`Another script defined the <${e}> element, so this Comments overlay cannot start.`,fix:`Load one Comments overlay script on the page. Remove the other script that defines the element.`},COMMENTS_R0001:{why:({target:e})=>`createAnchor() found nothing to anchor to for ${e}.`,fix:`Pass an element, a non-empty selection, or a point that is over an element of the page.`},COMMENTS_R0013:{why:`The comments request did not get an answer from the server.`,fix:`Check the connection and the app URL, then try again.`},COMMENTS_R0015:{why:`The comment list kept changing while its pages were loading.`,fix:`Refresh again. The previous cache is kept until two complete scans agree.`}}});function f(e){let{code:t,details:n,fix:r,retryAfter:i,status:a,why:o}=e,c=t.startsWith(`COMMENTS_`)?`https://vitehub.dev/docs/comments/diagnostics/${t.toLowerCase()}`:void 0;return Object.assign(new s({code:t,why:o,...r?{fix:r}:{},...c?{docs:c}:{}}),{status:a,...n?{details:n}:{},...i===void 0?{}:{retryAfter:i}})}function p(e,t,n){return Object.assign(d.COMMENTS_R0013(t===void 0?{}:{cause:t}),{status:e,...n===void 0?{}:{retryAfter:n}})}var m=`vitehub-comments:connect`;function h(e){return`vitehub-comments:${e}`}function g(e){return`/comments/${encodeURIComponent(e)}/embed`}var _=15e3,v=3e4,y=5e3,b=`vitehub-comments:`,x=RegExp(`^#(/?)vhc=([\\w-]+)$`);function S(e=!1){let t=x.exec(location.hash);if(!t)return;let[,n,r]=t,i=new URL(location.href);return e&&i.searchParams.delete(`vhp`),i.hash=n?`#/`:``,history.replaceState(history.state,``,i),r}function C(e){try{return sessionStorage.getItem(e)===`1`}catch{return!1}}function w(){try{for(let e=0;e<sessionStorage.length;e++)if(sessionStorage.key(e)?.startsWith(b))return!0}catch{}return!1}function T(e){try{sessionStorage.setItem(e,`1`)}catch{}}function E(e,t){let n=document.createElement(`iframe`);n.src=`${e}${g(t)}`,n.hidden=!0,n.tabIndex=-1,n.title=`ViteHub Comments`,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`data-comments-ui`,``);let r=new MessageChannel,i=new Map,a=0,o={call:(e,t)=>new Promise((n,o)=>{let s=++a,c=setTimeout(()=>{i.delete(s),o(p(0))},v);i.set(s,e=>{clearTimeout(c),e.ok?n(e):o(f(e.error))}),r.port1.postMessage({id:s,method:e,input:t})})};return new Promise((t,a)=>{let s=setTimeout(()=>a(p(0)),_);r.port1.addEventListener(`message`,({data:e})=>{if(typeof e==`object`&&e){if(Reflect.get(e,`event`)===`ready`)clearTimeout(s),t(o);else{let t=Reflect.get(e,`id`),n=typeof t==`number`?i.get(t):void 0;if(!n||typeof t!=`number`)return;i.delete(t),n(e)}}}),r.port1.start(),n.addEventListener(`load`,()=>n.contentWindow?.postMessage({type:m},e,[r.port2]),{once:!0}),n.addEventListener(`error`,()=>a(p(0)),{once:!0}),document.documentElement.append(n)})}async function D(e,t){return await new Promise(n=>{let r=setTimeout(()=>i(!1),y);function i(t){clearTimeout(r),e.removeEventListener(`message`,a),n(t)}function a({data:e}){e.type===`redeemed`&&e.code===t&&i(!0)}e.addEventListener(`message`,a),e.postMessage({type:`code`,code:t})})}function O(){return import(new URL(`hosted-comments/tools.js`,``+import.meta.url).href)}async function k(e,t,r,i=n(location.search,document.cookie),a){let o=S(a!==void 0),s=`${b}${e}`;if(!o&&!C(s)&&!i)return;T(s);let c=new BroadcastChannel(h(e)),l=E(t,e),u=async e=>(await(await l).call(`redeem`,e)).value===!0,d=O(),f={id:e,console:t,...r?{repository:r}:{},...a?{consoleUrl:a}:{}};c.addEventListener(`message`,({data:e})=>{e.type===`code`&&u(e.code).then(t=>{t&&(c.postMessage({type:`redeemed`,code:e.code}),d.then(({mountHostedComments:e})=>e(l,f)))},()=>void 0)});let p=o?await u(o).catch(()=>!1):!1;if(o&&!p&&await D(c,o)){window.close();return}let{mountHostedComments:m}=await d;await m(l,f)}function A(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`id`)==`string`&&typeof Reflect.get(e,`team`)==`string`}async function j(e,t,r){let i=n(location.search,``)||w(),a=x.test(location.hash);if(!i&&!a)return;let o=new URL(`/comments/project`,t);for(let t of e)o.searchParams.append(`key`,t);o.searchParams.set(`base`,r);let s=await fetch(o,{credentials:`omit`}).then(e=>e.ok?e.json():void 0).catch(()=>void 0),c=typeof s==`object`&&s?Reflect.get(s,`projects`):void 0,l=Array.isArray(c)?c.filter(A):[],u=e=>{let n=new URL(`/open`,t);return n.searchParams.set(`project`,`${location.origin}${r}`),n.searchParams.set(`path`,`/`),e&&n.searchParams.set(`app`,e),n.href},d=e=>k(e,t,void 0,!0,u(e)),f=a?new URLSearchParams(location.search).get(`vhp`):null,p=l.filter(e=>C(`${b}${e.id}`)),m=f?l.find(e=>e.id===f):l.length===1?l[0]:p.length===1?p[0]:void 0;if(m)return await d(m.id);a&&S(!0);let{mountHostedProjectChoice:h}=await O();await h(u(),l.map(e=>({team:e.team,choose:()=>void d(e.id)})))}var M=document.querySelector(`script[data-vitehub-comments], script[data-vitehub-console-key]`),N=new URL(import.meta.url).origin,P=M?.dataset.vitehubComments,F=M?.dataset.vitehubConsoleKey?.split(/\s+/).filter(Boolean)??[];P?k(P,N,i(M?.dataset.vitehubRepo)):F.length&&j(F,N,M?.dataset.vitehubBase??``);
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as threadChanged, S as suggest, T as clientRateLimitIssue, a as createThread, b as scopeOf, c as earlierThread, g as replyToThread, l as editMessage, r as can, s as earlierReply } from "./service-
|
|
2
|
-
import { a as defineCommentSubject, i as defaultPolicy, n as commentsRoleAllows, s as markCommentsDefinition } from "./define-
|
|
3
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
1
|
+
import { C as threadChanged, S as suggest, T as clientRateLimitIssue, a as createThread, b as scopeOf, c as earlierThread, g as replyToThread, l as editMessage, r as can, s as earlierReply } from "./service-XT2A8YEF.js";
|
|
2
|
+
import { a as defineCommentSubject, i as defaultPolicy, n as commentsRoleAllows, s as markCommentsDefinition } from "./define-BqPcuDhf.js";
|
|
3
|
+
import { t as commentsErrorDiagnostics } from "./errors-CBvIpwbo.js";
|
|
4
4
|
import { t as commentsErrors } from "./errors-C0VwRHiy.js";
|
|
5
|
-
import { a as runtimeOf, n as pendingKey, o as runtimes, t as commentSendOf } from "./installed-
|
|
5
|
+
import { a as runtimeOf, n as pendingKey, o as runtimes, t as commentSendOf } from "./installed-wUYjqk_k.js";
|
|
6
6
|
import { c as normalizeCommentPage, n as commentRoom } from "./page-2NzFladc.js";
|
|
7
7
|
import { t as describeCommentContext } from "./context-DbkBjITZ.js";
|
|
8
8
|
// src/index.ts
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { i as installCommentsRuntime } from "./server-
|
|
1
|
+
import { i as installCommentsRuntime } from "./server-8o9u8leM.js";
|
|
2
2
|
import { r as guestIdPrefix } from "./identity-CT7-UGmS.js";
|
|
3
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
4
|
-
import { a as commentsSchemaGate, d as commentForge, f as commentMessages, m as commentsSchema, p as commentThreads, r as commentSendsTables, t as commentSends, u as commentCounters } from "./database-
|
|
3
|
+
import { t as commentsErrorDiagnostics } from "./errors-CBvIpwbo.js";
|
|
4
|
+
import { a as commentsSchemaGate, d as commentForge, f as commentMessages, m as commentsSchema, p as commentThreads, r as commentSendsTables, t as commentSends, u as commentCounters } from "./database-BuSNVwTx.js";
|
|
5
5
|
import { t as logFailure } from "./request-log-DllKQXj7.js";
|
|
6
6
|
import { i as getActiveCloudflareBinding, n as recentGitHubToken } from "./tokens-Bx4lZ0yt.js";
|
|
7
7
|
import { t as describeCommentContext } from "./context-DbkBjITZ.js";
|
|
8
8
|
import { t as invariant } from "./invariant-CmdvZ3vp.js";
|
|
9
|
-
import { n as isSecureOrigin } from "./request-origin-
|
|
9
|
+
import { n as isSecureOrigin } from "./request-origin-B-CPVAVk.js";
|
|
10
10
|
import { t as commentsErrors } from "./errors-C0VwRHiy.js";
|
|
11
|
-
import { n as pendingKey, o as runtimes } from "./installed-
|
|
11
|
+
import { n as pendingKey, o as runtimes } from "./installed-wUYjqk_k.js";
|
|
12
|
+
import { PgTable } from "drizzle-orm/pg-core";
|
|
12
13
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
13
14
|
import * as v from "valibot";
|
|
14
|
-
import { and, asc, desc, eq, getTableName, gt, gte, inArray, isNotNull, isNull, like, lt, lte, or, sql } from "drizzle-orm";
|
|
15
|
+
import { and, asc, desc, eq, getTableName, gt, gte, inArray, is, isNotNull, isNull, like, lt, lte, or, sql } from "drizzle-orm";
|
|
15
16
|
import { forgeEnv, githubAppCredentials, githubInstallationFor, githubInstallationRouting, readForgeEnv, readGitHubAppPrivateKey } from "@vite-hub/forge";
|
|
16
17
|
// \0rolldown/runtime.js
|
|
17
18
|
var __defProp = Object.defineProperty;
|
|
@@ -129,9 +130,6 @@ function isUniqueViolation(error) {
|
|
|
129
130
|
}
|
|
130
131
|
return false;
|
|
131
132
|
}
|
|
132
|
-
function escapeLike(value) {
|
|
133
|
-
return value.replaceAll(/[%_\\]/g, "\\$&");
|
|
134
|
-
}
|
|
135
133
|
function createCommentsStore(database, tables = {
|
|
136
134
|
commentCounters,
|
|
137
135
|
commentMessages,
|
|
@@ -139,6 +137,16 @@ function createCommentsStore(database, tables = {
|
|
|
139
137
|
}) {
|
|
140
138
|
const { commentCounters: counters, commentMessages: messages, commentThreads: threads } = tables;
|
|
141
139
|
const db = database;
|
|
140
|
+
const postgres = is(messages, PgTable);
|
|
141
|
+
function contains(text, value) {
|
|
142
|
+
return postgres ? sql`strpos(${text}, ${value}) > 0` : sql`instr(${text}, ${value}) > 0`;
|
|
143
|
+
}
|
|
144
|
+
function containsQuotedString(column, value) {
|
|
145
|
+
return contains(column, JSON.stringify(value));
|
|
146
|
+
}
|
|
147
|
+
function listIncludes(column, value) {
|
|
148
|
+
return postgres ? sql`${column}::jsonb @> jsonb_build_array(${value}::text)` : sql`exists (select 1 from json_each(${column}) where json_each.value = ${value})`;
|
|
149
|
+
}
|
|
142
150
|
async function attach(rows) {
|
|
143
151
|
const ids = rows.map((row) => row.id);
|
|
144
152
|
const byThread = /* @__PURE__ */ new Map();
|
|
@@ -295,7 +303,7 @@ function createCommentsStore(database, tables = {
|
|
|
295
303
|
...query.status ? [eq(threads.status, query.status)] : [],
|
|
296
304
|
...query.revision ? [lte(threads.revision, query.revision.lte)] : [],
|
|
297
305
|
...query.mine ? [query.userId ? eq(threads.authorId, query.userId) : sql`1 = 0`] : [],
|
|
298
|
-
...query.mentions ? [query.userId ? sql`exists (select 1 from ${messages} where ${messages.threadId} = ${threads.id} and ${messages.mentions
|
|
306
|
+
...query.mentions ? [query.userId ? sql`exists (select 1 from ${messages} where ${messages.threadId} = ${threads.id} and ${listIncludes(messages.mentions, query.userId)})` : sql`1 = 0`] : [],
|
|
299
307
|
...before ? [or(lt(threads.updatedAt, before.updatedAt), and(eq(threads.updatedAt, before.updatedAt), lt(threads.id, before.id)))] : []
|
|
300
308
|
];
|
|
301
309
|
const limit = Math.min(Math.max(Math.trunc(query.limit ?? 200), 1), 500);
|
|
@@ -313,12 +321,11 @@ function createCommentsStore(database, tables = {
|
|
|
313
321
|
return row ? find(row.threadId) : null;
|
|
314
322
|
},
|
|
315
323
|
async getByAttachment(key, cursor) {
|
|
316
|
-
const pattern = `%${JSON.stringify(key).replaceAll(/[\\%_]/g, (character) => `\\${character}`)}%`;
|
|
317
324
|
const rows = await db.select({
|
|
318
325
|
id: messages.id,
|
|
319
326
|
threadId: messages.threadId,
|
|
320
327
|
attachments: messages.attachments
|
|
321
|
-
}).from(messages).where(and(
|
|
328
|
+
}).from(messages).where(and(containsQuotedString(messages.attachments, key), cursor === void 0 ? void 0 : gt(messages.id, cursor))).orderBy(asc(messages.id)).limit(candidateLimit);
|
|
322
329
|
const ids = [...new Set(rows.filter((row) => parseJson(row.attachments, []).includes(key)).map((row) => row.threadId))];
|
|
323
330
|
return {
|
|
324
331
|
threads: (await Promise.all(ids.map((id) => find(id)))).filter((thread) => thread !== null),
|
|
@@ -439,7 +446,7 @@ function createCommentsStore(database, tables = {
|
|
|
439
446
|
const resolved = (await db.select({
|
|
440
447
|
id: threads.id,
|
|
441
448
|
resolvedBy: threads.resolvedBy
|
|
442
|
-
}).from(threads).where(
|
|
449
|
+
}).from(threads).where(containsQuotedString(threads.resolvedBy, userId))).flatMap(({ id, resolvedBy }) => resolvedBy !== null && parseJson(resolvedBy, void 0)?.id === userId ? [{
|
|
443
450
|
id,
|
|
444
451
|
resolvedBy
|
|
445
452
|
}] : []);
|
|
@@ -477,8 +484,7 @@ function createCommentsStore(database, tables = {
|
|
|
477
484
|
return [...seen.values()];
|
|
478
485
|
},
|
|
479
486
|
async knownUsers(query, limit, canRead) {
|
|
480
|
-
const
|
|
481
|
-
const matching = sql`lower(coalesce(${messages.authorName}, ${messages.authorId})) like ${pattern} escape '\\'`;
|
|
487
|
+
const matching = contains(sql`lower(coalesce(${messages.authorName}, ${messages.authorId}))`, query.toLowerCase());
|
|
482
488
|
const seen = /* @__PURE__ */ new Map();
|
|
483
489
|
const readable = candidateThreadAccess(canRead);
|
|
484
490
|
let before;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as hasCommentsRuntime, t as commentsRuntime } from "./server-
|
|
1
|
+
import { r as hasCommentsRuntime, t as commentsRuntime } from "./server-8o9u8leM.js";
|
|
2
2
|
// src/installed.ts
|
|
3
3
|
/** The runtime that `installComments()` connected to each definition. */
|
|
4
4
|
const runtimes = /* @__PURE__ */ new WeakMap();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as CommentsRuntime, t as CommentsAttachmentBody } from "./service-IvgrI4XM.js";
|
|
2
|
-
import { t as AnyOperation } from "./operations-
|
|
2
|
+
import { t as AnyOperation } from "./operations-DFLer1fR.js";
|
|
3
3
|
import { f as CommentsPolicyGate, g as CommentsUser } from "./define-B1jLSPe9.js";
|
|
4
4
|
import { C as CommentStatusInput, D as CommentUser, E as CommentUploadInput, O as CommentUsersInput, T as CommentThread, c as CommentCreateInput, f as CommentEditInput, g as CommentGetInput, i as CommentAttachment, l as CommentDeleteInput, n as CommentActor, s as CommentContext, v as CommentListQuery, x as CommentReplyInput, y as CommentMessage } from "./types-BX3vH18p.js";
|
|
5
5
|
import * as v from "valibot";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { n as outboxAccountHeader } from "./client-files-lC6X7XyS.js";
|
|
2
|
-
import { t as commentsErrorDiagnostics } from "./errors-ByCRdInk.js";
|
|
3
2
|
import { n as pagePathOf, t as isPagePath } from "./path-8yqMd8zR.js";
|
|
4
3
|
import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
|
|
5
|
-
import {
|
|
4
|
+
import { t as commentsErrorDiagnostics } from "./errors-CBvIpwbo.js";
|
|
5
|
+
import { C as threadChanged, E as createClientRateLimit, S as suggest, _ as requestIdSchema, a as createThread, c as earlierThread, d as maximumAttachmentBytes, f as maximumCommentBodyLength, g as replyToThread, h as readAttachment, l as editMessage, m as personOf, n as base64, o as deniedError, r as can, s as earlierReply, t as attachmentThread, u as fail, v as retried, w as clientAddressKey, x as storeAttachment, y as retriedReply } from "./service-XT2A8YEF.js";
|
|
6
6
|
import { n as guestFromHeaders, t as authorOf } from "./identity-CT7-UGmS.js";
|
|
7
7
|
import { t as describeCommentContext } from "./context-DbkBjITZ.js";
|
|
8
|
-
import { t as commentsRuntime } from "./server-
|
|
8
|
+
import { t as commentsRuntime } from "./server-8o9u8leM.js";
|
|
9
9
|
import { defineDiagnostics } from "nostics";
|
|
10
10
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
11
11
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
@@ -40,7 +40,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
40
40
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
41
41
|
},
|
|
42
42
|
INTERNAL_R0024: {
|
|
43
|
-
fix: "Start the dev server
|
|
43
|
+
fix: "Start the dev server (`nuxt dev` or `vite dev`), or pass `--url <origin>` of a deployed app and set VITEHUB_CONSOLE_PRIVATE_KEY_<NAME> to a private key whose public key the app has in VITEHUB_CONSOLE_KEY_<NAME>.",
|
|
44
44
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
45
45
|
},
|
|
46
46
|
INTERNAL_R0023: {
|
|
@@ -156,7 +156,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
156
156
|
fix: "Give a switch column `format: \"switch\"` and `switch: { operation, input }` with a registered operation name, or remove both."
|
|
157
157
|
},
|
|
158
158
|
INTERNAL_R0025: {
|
|
159
|
-
fix: "Start `vite dev` in the project that you run the command from, or pass `--url` of that server.",
|
|
159
|
+
fix: "Start the dev server (`nuxt dev` or `vite dev`) in the project that you run the command from, or pass `--url` of that server.",
|
|
160
160
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
161
161
|
},
|
|
162
162
|
INTERNAL_R0026: {
|
|
@@ -177,7 +177,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
177
177
|
},
|
|
178
178
|
INTERNAL_R0002: {
|
|
179
179
|
...dynamicError,
|
|
180
|
-
fix:
|
|
180
|
+
fix: ({ fix }) => fix ?? "Build for a host that provides this capability, or set the option named in the message to `false`."
|
|
181
181
|
},
|
|
182
182
|
INTERNAL_R0004: {
|
|
183
183
|
...dynamicError,
|
|
@@ -415,7 +415,6 @@ function isSectionId(section) {
|
|
|
415
415
|
function operationInputJsonSchema(operation) {
|
|
416
416
|
return standardJsonSchema(operation.input, "input") ?? { type: "object" };
|
|
417
417
|
}
|
|
418
|
-
/** `"blob:media"` → `["blob:media", "blob"]`: a grant of the section covers each of its scopes. */
|
|
419
418
|
function grantsFor(section) {
|
|
420
419
|
const separator = section.indexOf(":");
|
|
421
420
|
return separator === -1 ? [section] : [section, section.slice(0, separator)];
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as maximumCommentBodyLength } from "./service-IvgrI4XM.js";
|
|
2
|
-
import { a as commentsOperations, i as commentInputSchemas, n as commentActions, r as commentAnchorSchema, t as CommentsCaller } from "./operations-
|
|
2
|
+
import { a as commentsOperations, i as commentInputSchemas, n as commentActions, r as commentAnchorSchema, t as CommentsCaller } from "./operations-Qt8ASQqW.js";
|
|
3
3
|
export { CommentsCaller, commentActions, commentAnchorSchema, commentInputSchemas, commentsOperations, maximumCommentBodyLength };
|
package/dist/operations.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as commentsOperations, n as commentAnchorSchema, r as commentInputSchemas, t as commentActions } from "./operations-
|
|
2
|
-
import { f as maximumCommentBodyLength } from "./service-
|
|
1
|
+
import { i as commentsOperations, n as commentAnchorSchema, r as commentInputSchemas, t as commentActions } from "./operations-kMPw-Cyb.js";
|
|
2
|
+
import { f as maximumCommentBodyLength } from "./service-XT2A8YEF.js";
|
|
3
3
|
export { commentActions, commentAnchorSchema, commentInputSchemas, commentsOperations, maximumCommentBodyLength };
|