conformtools 0.6.28 → 0.6.30
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/{account-RSL4PTDB.js → account-B7ZF6OQM.js} +1 -1
- package/dist/{agent-hook-setup-IACTYSVL.js → agent-hook-setup-KBCGZNEE.js} +1 -1
- package/dist/{analysis-engine-BBOSGAB2.js → analysis-engine-LGB4OXG7.js} +1 -1
- package/dist/{bridge-I6VDW7YC.js → bridge-4ZKCOIOA.js} +1 -1
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/{chunk-X76IIWBH.js → chunk-2XB3P2Q5.js} +1 -1
- package/dist/{chunk-CSH2RRI6.js → chunk-3QYAWIID.js} +1 -1
- package/dist/{chunk-7CASAJU4.js → chunk-463MBAHG.js} +1 -1
- package/dist/{chunk-QY4QDBIN.js → chunk-4QGSPWXM.js} +91 -91
- package/dist/{chunk-TGLH2JDW.js → chunk-FHCRWOI7.js} +1 -1
- package/dist/{chunk-NRURUPLU.js → chunk-GDPYFRSV.js} +1 -1
- package/dist/chunk-H3FD5KA2.js +7 -0
- package/dist/{chunk-BIX5ETBY.js → chunk-HHOFGYZ7.js} +1 -1
- package/dist/{chunk-CV7OBWOX.js → chunk-KMDKF7EJ.js} +1 -1
- package/dist/chunk-KWJVI7VL.js +545 -0
- package/dist/chunk-QQBDHVUU.js +3 -0
- package/dist/chunk-RKJML7MH.js +10 -0
- package/dist/{chunk-3KS3547B.js → chunk-SSFG7FNI.js} +1 -1
- package/dist/{chunk-WG75XXKG.js → chunk-TBODUVBP.js} +2 -2
- package/dist/{chunk-UXEL636C.js → chunk-UXVABU6B.js} +1 -1
- package/dist/{chunk-HNEKQMQG.js → chunk-YJREJ2MH.js} +1 -1
- package/dist/{chunk-UE76WJ3Y.js → chunk-ZL562JIE.js} +1 -1
- package/dist/chunk-ZNBXAGOK.js +7 -0
- package/dist/{chunk-RL5XRG6O.js → chunk-ZTXOFGJY.js} +1 -1
- package/dist/{claude-setup-6RMV3QZM.js → claude-setup-FYWGYBTH.js} +1 -1
- package/dist/cli.js +2 -2
- package/dist/demo-engine-I35YCWFG.js +3 -0
- package/dist/{engine-I2NXY2OK.js → engine-WJLTTZSK.js} +2 -2
- package/dist/framing-AYR35WRJ.js +3 -0
- package/dist/gfx-worker.js +1 -1
- package/dist/h264-QGSP23K2.js +3 -0
- package/dist/{h264-mxf-PKSTGNGH.js → h264-mxf-I4YANT5F.js} +1 -1
- package/dist/{host-relink-B3M3B3VF.js → host-relink-ACZC6TG2.js} +1 -1
- package/dist/{hosted-26GUD7IU.js → hosted-SPL5V4NR.js} +1 -1
- package/dist/hosts-RSOGNUPK.js +3 -0
- package/dist/http.js +2 -2
- package/dist/{inspect-RT36GEVU.js → inspect-B6KD6ZTA.js} +2 -2
- package/dist/{isobmff-65LRNCQH.js → isobmff-LAXAYC7P.js} +1 -1
- package/dist/{mc-video-2PCAX65A.js → mc-video-KQ7TP4DG.js} +1 -1
- package/dist/mcp.js +7 -7
- package/dist/{media-NCUTSVJ4.js → media-SUPBJX64.js} +1 -1
- package/dist/{mxf-WFJNAX7D.js → mxf-2TQO552L.js} +1 -1
- package/dist/{ops-SH3IUU2Z.js → ops-CVKPID5Z.js} +1 -1
- package/dist/{probe-VB6JH6ZJ.js → probe-HUPB4H4G.js} +1 -1
- package/dist/{r3d-X2O5LUAB.js → r3d-EPSGIBPT.js} +1 -1
- package/dist/resolve-bridge.py +9 -3
- package/dist/{sequence-patch-OHYBBKKZ.js → sequence-patch-GXM3QSJC.js} +1 -1
- package/dist/{store-F2CTSR6E.js → store-INNJPUPR.js} +1 -1
- package/dist/{timeline-33MJ3HOK.js → timeline-EXRRCS47.js} +1 -1
- package/package.json +5 -5
- package/dist/chunk-7GEOQ4N6.js +0 -537
- package/dist/chunk-AR5BTVBM.js +0 -7
- package/dist/chunk-IDADYIY6.js +0 -7
- package/dist/chunk-TIZC6IEH.js +0 -10
- package/dist/chunk-ZPIY5DOU.js +0 -3
- package/dist/demo-engine-ITZ7VG6Q.js +0 -3
- package/dist/framing-QC7Z2GRK.js +0 -3
- package/dist/h264-TVMYQ7EB.js +0 -3
- package/dist/hosts-LVKUUVG7.js +0 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
+
import{c as le,d as ue,g as pe,h as fe,i as de}from"./chunk-VZ3XYHK4.js";import{a as me}from"./chunk-YJREJ2MH.js";import{a as s}from"./chunk-E75BCWXY.js";import{C as T,D as R,E as re,F as O,G as oe,P as ie,S as ae,W as se,X as ce,b as c,ea as l,h as y,i as te,o as h,p as b,v as ne,z as _}from"./chunk-QQBDHVUU.js";var Be=["pro","studio","enterprise"],gt=e=>Be.includes((e??"").toLowerCase()),ge=["align","reconform","conform-reference"],he=["autobalance","p2p","p2p-send","receive"],Fe={transferGB:2e3},g={payg:{id:"payg",name:"Pay As You Go",includes:{web:!0,mcp:!1,app:!1,studio_tools:!1}},web:{id:"web",name:"Indie",unlisted:!0,includes:{web:!0,mcp:!1,app:!1,studio_tools:!1},allowance:{transferGB:50}},indie:{id:"indie",name:"Pro",popular:!0,includes:{web:!0,mcp:!0,app:!0,studio_tools:!1},allowance:{transferGB:250}},pro:{id:"pro",name:"Studio",includes:{web:!0,mcp:!0,app:!0,studio_tools:!0},allowance:{transferGB:1e3}},studio:{id:"studio",name:"Enterprise",includes:{web:!0,mcp:!0,app:!0,studio_tools:!0},allowance:Fe}},_e={web:!0,mcp:!0,app:!0,studio_tools:!0};import{AsyncLocalStorage as xe}from"node:async_hooks";var M=()=>{throw new Error("this build has no local engine \u2014 timelines are read and written on conform.tools")};function we(e,t){return M()}function ye(e,t){return M()}function be(e){return M()}var Ge=new xe;function B(e){let t=Ge.getStore();if(!t||t.declared.includes(e))return;let n=`verb '${t.verb}' reached the protected stage '${e}' without declaring it in protectedStages (core/verbs.ts)`;if(c("CONFORM_STRICT_STAGES")==="1")throw new s("internal",n);console.error(`[conform] warning: ${n}`)}var F=!1,ze=new xe;function J(){let e=ze.getStore();if(e==="hosted")return"hosted";if(e==="local"){if(!!1)throw new s("unsupported","offline conversion needs the app's own engine (this build converts on conform.tools)");return"local"}return c("CONFORM_ENGINE")==="hosted"||!!1?"hosted":"local"}async function vt(e){return B("canonicalize"),J()==="local"?await we(e.fmt,e.data):await ve(e.fmt,e.file)}async function St(e,t){return B("write"),J()==="local"?await ye(e,t):await Se(e,t)}async function xt(e){if(J()!=="local")return null;B("canonicalize");let t=JSON.parse(await be(JSON.stringify(e)));return{session:t.session,issues:t.issues??[]}}import{createPrivateKey as Et,createPublicKey as Ke,sign as At,verify as We}from"node:crypto";import{Buffer as v}from"node:buffer";var He="CONFORMTOOLS_LICENSE_V1",ke=/^[0-9A-F]{8}(-[0-9A-F]{8}){3}$/,Oe=e=>JSON.stringify({dev_mode:e.dev_mode??!1,email:e.email,expires_at:e.expires_at,features:e.features,issued_at:e.issued_at,machine_fingerprint:e.machine_fingerprint,tier:e.tier});function Ee(e){let t=e.split(/\r?\n/).map(r=>r.trim()).filter(r=>r&&!r.startsWith("#")&&!r.startsWith("-----")).join(""),n=JSON.parse(v.from(t,"base64").toString("utf8"));if(n?.magic!==He||!n.payload?.data)throw new Error("not a conform.tools licence");return n.payload}function Ae(e,t){let n=v.from(e.signature,"base64"),r=v.from(Oe(e.data));return n.length!==64?!1:t.some(o=>We(null,r,Ke({key:v.concat([v.from("302a300506032b6570032100","hex"),v.from(o)]),format:"der",type:"spki"}),n))}var Ye=["cMwVBrEYKMzlG6pC7FF2lNKIoEqGz2xB5yph6clNnTg=","qnheqkkDU09l1oI6h2CFh4uQ97bY/hkTA5niGKH0+X8="],qe=Ye.map(e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)));function I(){let e=c("CONFORM_RECORDS_DIR");if(e)return e;let t=b(),n=y()==="darwin"?l(t,"Library/Application Support"):y()==="win32"?c("LOCALAPPDATA")??l(t,"AppData/Local"):c("XDG_DATA_HOME")??l(t,".local/share");return l(n,"conform.tools")}var Ve=()=>c("CONFORM_LICENSE_PATH")??l(I(),"license.lic"),N=()=>l(I(),"grant.lic"),Xe=null;function $(){return Xe??=(async()=>{let e=await me();if(!e)return[];let t=await ae(e,["machine"],{timeoutMs:15e3}).catch(()=>null);try{return JSON.parse(t?.stdout??"").machines.filter(n=>ke.test(n))}catch{return[]}})()}function Ze(e,t,n=Date.now()){if(!Ae(e,qe))return{ok:!1,reason:"invalid licence signature"};let r=Date.parse(e.data.expires_at);if(!Number.isFinite(r)||r<n)return{ok:!1,reason:`licence expired ${e.data.expires_at}`};let o=[t??[]].flat().filter(Boolean);return o.length?o.includes(e.data.machine_fingerprint)?{ok:!0,data:e.data}:{ok:!1,reason:"licence is for another machine"}:{ok:!1,reason:"this machine's ID could not be read (the conform.tools engine is not installed here)"}}async function Pe(){let e;try{e=await _(Ve())}catch{return null}try{return Ze(Ee(e),await $())}catch(t){return{ok:!1,reason:t.message}}}var Qe={production:{supabaseUrl:"https://sttpwvjbpsetzbhrkohl.supabase.co",anonKey:"sb_publishable_cyuIPsrQa5Ye7lqFxjnknQ_ozDuwwzp",appBase:"https://conform.tools"},staging:{supabaseUrl:"https://slxggvbvgzkiwojcgykx.supabase.co",anonKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNseGdndmJ2Z3praXdvamNneWt4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzEyODUzMTksImV4cCI6MjA4Njg2MTMxOX0.b18iDsWftny0k9VmOCcbN6kLlyZsZ7GULn_jRH9CE9I",appBase:"https://beta.conform.tools"}};function a(){let e=c("CONFORM_ENV")==="staging"?"staging":"production",t=Qe[e];return{env:e,supabaseUrl:c("CONFORM_SUPABASE_URL")??t.supabaseUrl,anonKey:c("CONFORM_SUPABASE_ANON_KEY")??t.anonKey,appBase:c("CONFORM_APP_BASE")??t.appBase}}var et=600*1e3,Te=72*3600*1e3,tt=300*1e3,S=()=>l(h(),a().env==="production"?"auth.json":`auth-${a().env}.json`);async function x(){for(let e of new Set([S(),l(h(),"auth.json")]))try{let t=JSON.parse(await _(e));if(t.env===a().env&&t.access_token)return t}catch{}return await rt()}var nt=()=>{let e=y()==="win32"?c("APPDATA")??l(b(),"AppData","Roaming"):y()==="darwin"?l(b(),"Library","Application Support"):c("XDG_CONFIG_HOME")??l(b(),".config");return l(e,"conform-tools","kv-store.json")};async function rt(){let e=nt();try{let t=JSON.parse(await _(e)),n=JSON.parse(t["ct-supabase-auth"]??"null");if(!n?.access_token||!n.refresh_token)return null;let r=n.access_token.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");if(JSON.parse(atob(r+"=".repeat(-r.length&3))).iss!==`${a().supabaseUrl}/auth/v1`)return null;let i={env:a().env,access_token:n.access_token,refresh_token:n.refresh_token,expires_at:n.expires_at??0};return await L(i),delete t["ct-supabase-auth"],await T(e,JSON.stringify(t)),i}catch{return null}}async function ot(){try{for await(let e of ie(h())){if(!/^auth(?:-(\w+))?\.json$/.exec(e.name))continue;let n=JSON.parse(await _(l(h(),e.name)));if(n.access_token&&n.env&&n.env!==a().env)return{other_env:n.env}}}catch{}return{}}async function L(e){await R(h()),await T(S(),JSON.stringify(e)),await oe(S(),384)}var z=6e3,P=0,K=()=>Date.now()<P,Ne=()=>{P=Date.now()+6e4};function Bt(){P=0}var $e=e=>e.expires_at-60>Date.now()/1e3;async function G(e){let t=await x();return t&&t.refresh_token!==e.refresh_token&&Object.assign(e,t),$e(e)}async function W(e){if($e(e))return e.access_token;if(K())return null;if(await G(e))return e.access_token;let t=await re(`${S()}.lock`);try{if(await G(e))return e.access_token;let n=a(),r=await fetch(`${n.supabaseUrl}/auth/v1/token?grant_type=refresh_token`,{method:"POST",headers:{apikey:n.anonKey,"content-type":"application/json"},body:JSON.stringify({refresh_token:e.refresh_token}),signal:AbortSignal.timeout(z)}).catch(i=>{throw Ne(),i});if(!r.ok)return r.status!==400&&r.status!==401?null:await G(e)?e.access_token:"";let o=await r.json();return e.access_token=o.access_token,o.refresh_token&&(e.refresh_token=o.refresh_token),e.expires_at=o.expires_at??Math.floor(Date.now()/1e3)+(o.expires_in??3600),await L(e),e.access_token}catch{return null}finally{await t()}}async function Ft(){return(await x().catch(()=>null))?.last_entitlement?.model_key??null}async function Jt(){return(await H()).token}async function H(e="conform.tools"){let t=await x();if(!t)return m=null,{token:null,error:new s("not_signed_in",`${e}: not signed in to conform.tools \u2014 run account_login`)};let n=await W(t);return n?{token:n,error:null}:n===""?(m=null,{token:null,error:new s("not_signed_in",`${e}: the sign-in expired or was revoked \u2014 sign in again (account_login)`)}):{token:null,error:new s("offline",`${e}: couldn't reach conform.tools to renew the sign-in (no answer, or the server was busy). You are still signed in; it retries by itself \u2014 check the network if it keeps happening.`)}}var m=null;function Ie(e,t){return{signed_in:!0,entitled:e.entitled,env:a().env,email:e.email,access:e.access,tier:e.tier,trial_days_remaining:e.trial_days_remaining,source:t,...e.entitled?{}:{reason:"not_entitled"},...e.invite_only?{invite_only:!0}:{},...e.dev?{dev:!0}:{}}}async function Y(e={}){let t=await Pe();if(t?.ok)return{signed_in:!!await x().catch(()=>null),entitled:!0,env:a().env,email:t.data.email,access:"licence",tier:t.data.tier,source:"licence"};let n=await it(e);return t&&!n.entitled?{...n,licence_error:t.reason}:n}async function it(e){if(!e.force&&m&&Date.now()-m.at<et)return{...m.status,source:"cache"};let t=a(),n=await x();if(!n)return{signed_in:!1,entitled:!1,env:t.env,reason:"not_signed_in",...await ot()};let r=await W(n);if(r==="")return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(r&&!K())try{let o=(await $())[0],i=await fetch(`${t.supabaseUrl}/functions/v1/v1-billing/v1/billing/entitlement${o?`?machine=${o}`:""}`,{headers:{authorization:`Bearer ${r}`,apikey:t.anonKey},signal:AbortSignal.timeout(z)}).catch(u=>{throw Ne(),u});if(i.status===401||i.status===403)return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(i.ok){let{grant:u,...p}=(await i.json()).data;o&&await at(u),n.last_entitlement=p,n.last_entitlement_at=Date.now(),await L(n);let f=Ie(p,"live");return m={at:Date.now(),status:f},f}}catch{}if(n.last_entitlement&&n.last_entitlement_at&&Date.now()-n.last_entitlement_at<Te){let o=Te-(Date.now()-n.last_entitlement_at);return{...Ie(n.last_entitlement,"grace"),grace_remaining_h:Math.round(o/36e4)/10}}return{signed_in:!0,entitled:!1,env:t.env,reason:"offline_grace_expired"}}async function at(e){try{if(!e)return await O(N());await R(I()),await T(N(),e)}catch{}}function st(e){return e.source==="licence"?`${e.email} \xB7 machine licence (${e.tier}) \u2014 runs offline, no account check`:ct(e)+(e.licence_error?`
|
|
4
|
+
(the machine licence was not used: ${e.licence_error})`:"")}function ct(e){let t=a();if(!e.signed_in)return`not signed in (${t.env})${e.other_env?`; you are signed in to ${e.other_env} only (each server keeps its own sign-in)`:""}. Run the account_login tool, or \`npx -y conformtools@latest login\` in a terminal.`;if(e.reason==="auth_rejected")return"signed-in session was rejected (expired or revoked) \u2014 sign in again with account_login.";if(e.reason==="offline_grace_expired")return"offline for more than 72 h since the last account check \u2014 reconnect and run account_status.";let n=`${e.email??"(unknown email)"} \xB7 ${t.env}`;if(!e.entitled&&e.invite_only)return`${n}
|
|
5
|
+
the conform.tools engine (the MCP and the app) is invite-only for now, and ${e.email??"this account"} is not on the list. If that is the wrong Google account, run account_logout, then account_login with the invited one.`;if(!e.entitled)return`${n}
|
|
6
|
+
no active plan on ${e.email??"this account"}: the MCP is in the ${g.indie.name} plan and up. If that is the wrong Google account, run account_logout, then account_login and pick the account with the plan; otherwise choose a plan at ${t.appBase}/pricing, then run account_status.`;let r=e.access==="trial"?`trial, ${e.trial_days_remaining??"?"} day(s) left`:e.access==="allowlist"?"invited (early access)":`subscribed${e.tier?` (${q(e.tier)})`:""}`,o=D(e),i=o?` \xB7 includes ${[o.web&&"the web tools",o.mcp&&"the MCP",o.app&&"the app"].filter(Boolean).join(", ")||"the web tools"}`:"";return`${n}
|
|
7
|
+
${r}${i}${e.source==="grace"?` \u2014 offline, using the last check (${e.grace_remaining_h} h of grace left)`:""}`}function q(e){return g[e.toLowerCase()]?.name??e}function D(e){if(e.access==="trial")return _e;let t=(e.tier??"").toLowerCase();return(t==="enterprise"?g.studio:g[t])?.includes??null}var Le=()=>Y();function Gt(e){Le=e}async function De(){let e=await Le();if(e.entitled)return e;let t=e.signed_in&&e.reason==="not_entitled"?"not_entitled":"not_signed_in";throw new s(t,st(e),{account:e})}async function zt(){let e=await De();if(e.source==="licence"||D(e)?.mcp!==!1)return e;throw new s("not_entitled",`The conform.tools MCP is in the ${g.indie.name} plan and up. ${e.access==="trial"?"Your trial":`Your plan${e.tier?` (${q(e.tier)})`:""}`} includes Timeline Exchange on ${a().appBase}, but not the engine on this machine. Upgrade at ${a().appBase}/pricing, then run account_status.`,{account:e,needs:"mcp"})}async function lt(){let e=await De();if(e.source==="licence")return e;if(!D(e)?.app)throw new s("not_entitled",`The conform.tools app is in the ${g.indie.name} plan and up. ${e.access==="trial"?"Your trial":`Your plan${e.tier?` (${q(e.tier)})`:""}`} does not include the app. Upgrade at ${a().appBase}/pricing, then reopen the app.`,{account:e,needs:"app"});let t=await ft();if(t)throw new s("seat_in_use",`This seat is in use on ${t}. Each seat runs the app on one computer at a time: quit the app there (or sign out), or wait 15 minutes after it last ran, then reopen it here.`,{account:e,needs:"seat",in_use_by:t});return e}var Ce=()=>c("CONFORM_DEV")==="0",Kt=()=>!Ce()&&(F||m?.status.dev===!0);async function ut(){return!Ce()&&(F||(await Y().catch(()=>null))?.dev===!0)}async function Wt(e){if(!(!he.includes(e)||await ut()))throw new s("not_found",`no tool "${e}"`)}async function Ht(e){if(!ge.includes(e))return;let t=await lt();if(!(t.source==="licence"||D(t)?.studio_tools!==!1))throw new s("not_entitled",`This tool is in the ${g.pro.name} plan. Upgrade at ${a().appBase}/pricing.`,{account:t,needs:"studio_tools"})}var pt=240*1e3,A=null;async function ft(){if(A&&Date.now()-A.at<pt)return A.busy;let e=await Ue("POST").catch(()=>null);return A={at:Date.now(),busy:e},e}async function Ue(e){let t=a(),n=await x(),r=(await $())[0],o=n&&await W(n);if(!o||!r||K())return null;let i=await fetch(`${t.supabaseUrl}/functions/v1/v1-billing/v1/billing/seat`,{method:e,headers:{authorization:`Bearer ${o}`,apikey:t.anonKey,"content-type":"application/json"},body:JSON.stringify({machine:r,name:te()}),signal:AbortSignal.timeout(z)});return i.status===409?(await i.json()).in_use_by??"another computer":null}var E=null;function Yt(e={}){if(E)return E;let t=a(),n=crypto.randomUUID().replaceAll("-","");return E=new Promise((r,o)=>{let i=!1,u=d=>{i||(i=!0,clearTimeout(f),setTimeout(()=>p.close(),250),E=null,d())},p=ce({hostname:"127.0.0.1",port:0,onListen:async d=>{let k=`${t.appBase}/plugin-auth?client=engine&port=${d}&state=${n}`,w=await se(k);e.onUrl?.(k,w)}},async d=>{let k=new URL(d.url);if(k.pathname!=="/callback")return new Response("not found",{status:404});let w=k.searchParams,Z=w.get("access_token")??"",Q=w.get("refresh_token")??"",C=!!Z&&!!Q&&w.get("state")===n;if(C){let ee=Number(w.get("expires_at"));await L({env:t.env,access_token:Z,refresh_token:Q,expires_at:ee>0?ee:Math.floor(Date.now()/1e3)+3600}),m=null,P=0,Y({force:!0}).then(U=>u(()=>r(U)),U=>u(()=>o(U)))}return new Response(dt(C),{status:C?200:400,headers:{"content-type":"text/html; charset=utf-8"}})}),f=setTimeout(()=>u(()=>o(new s("not_signed_in","sign-in was not completed within 5 minutes"))),e.timeoutMs??tt)}),E}async function qt(){await Ue("DELETE").catch(()=>{}),A=null,m=null,P=0,await ne(S())&&await O(S()),await O(N()).catch(()=>{});let e=l(h(),"auth.json");try{JSON.parse(await _(e)).env===a().env&&await O(e)}catch{}}function dt(e){let[t,n]=e?["Connected","You're signed in \u2014 you can close this tab."]:["Sign-in failed","Please try again."];return`<!doctype html><meta charset=utf-8><title>conform.tools</title><body style='font:16px -apple-system,Helvetica,Arial,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7;color:#1d1d1f'><div style='text-align:center'><div style='font-size:22px;font-weight:700'>conform<span style='color:#ff3c00'>.tools</span></div><div style='margin-top:14px;font-size:20px;font-weight:600'>${t}</div><div style='margin-top:6px;color:#6e6e73'>${n}</div></div></body>`}le(!0);var Re={aaf:"aaf",avb:"avb",prproj:"prproj",drt:"resolve-drt",otio:"otio",capcut:"capcut",flame:"flame-archive",fcpxml:"resolve-fcpxml",xmeml:"fcp-xml",blscene:"baselight-blscene"},rn=Object.keys(Re),mt=new Set([502,503,504,529,546]),V=(e,t)=>`${a().supabaseUrl}/functions/v1/${e}${t}`;async function X(){let{token:e,error:t}=await H("reading and writing timelines runs on conform.tools");if(!e&&c("CONFORM_ANONYMOUS_READ")==="1")return a().anonKey;if(!e)throw t;return e}async function Me(e,t){let n;for(let r=0;r<3;r++){try{let o=await fetch(e,t);if(!mt.has(o.status)||r===2)return o;n=new Error(`status ${o.status}`)}catch(o){if(n=o,r===2)break}await new Promise(o=>setTimeout(o,1500*(r+1)))}throw new s("offline",`conform.tools is unreachable (${n instanceof Error?n.message:String(n)}) \u2014 reading and writing timelines need the network`)}async function je(e,t){let r=(await e.json().catch(()=>({})))?.error?.message??`${t} failed (${e.status})`;throw e.status===401?new s("not_signed_in",`${r} \u2014 sign in again (account_login)`):e.status===402||e.status===403?new s("not_entitled",r):new s(e.status>=500?"engine":"refused",r)}async function ve(e,t){let n=Re[e];if(!n)throw new s("unsupported",`'${e}' timelines are not read by conform.tools yet`);let{fmt:r,extract:o}=await ue(t,n),i=JSON.stringify({format:r,source_filename:t.name,persist:!1}),{contentType:u,body:p}=await pe(i,typeof o=="string"?o:JSON.stringify(o)),f=await Me(V("v1-timeline-canonicalize","/v1/timeline-canonicalize"),{method:"POST",headers:{"content-type":u,authorization:`Bearer ${await X()}`,apikey:a().anonKey},body:p});f.ok||await je(f,"read");let d=await f.json();return JSON.stringify(d.session)}async function Se(e,t){let n=await Me(V("v1-write","/v1/write"),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${await X()}`,apikey:a().anonKey,"x-engine-accept-delivery":"cdn"},body:JSON.stringify({target_format:e,session:t})});n.ok||await je(n,"write");let r=de(n.headers.get(fe))??[];if(n.headers.get("x-engine-delivery")==="cdn"){let i=await n.json(),u=await fetch(i.download_url);if(!u.ok)throw new s("engine",`download failed (${u.status})`);let p=new Uint8Array(await u.arrayBuffer());if(p.byteLength!==i.size)throw new s("engine",`download incomplete: ${p.byteLength} of ${i.size} bytes`);return{body:p,contentType:i.content_type,filenameSuggestion:i.filename,issues:r,serverSession:i.session_id??void 0}}let o=n.headers.get("content-disposition")?.match(/filename="([^"]+)"/)?.[1];return{body:new Uint8Array(await n.arrayBuffer()),contentType:n.headers.get("content-type")??"application/octet-stream",filenameSuggestion:o??`timeline.${e}`,issues:r,serverSession:n.headers.get("x-session-id")??void 0}}async function on(e,t,n){try{let r={"content-type":"application/json",authorization:`Bearer ${await X()}`,apikey:a().anonKey},o=d=>V("v1-sessions",`/v1/sessions/${encodeURIComponent(e)}/original${d}`),i=await fetch(o(""),{method:"POST",headers:r,body:JSON.stringify({filename:t,content_type:"application/octet-stream"})});if(!i.ok)return!1;let{key:u,upload:p}=await i.json();return(await fetch(p.url,{method:p.method??"PUT",headers:p.headers??{"content-type":"application/octet-stream"},body:n})).ok?(await fetch(o("/complete"),{method:"POST",headers:r,body:JSON.stringify({key:u})})).ok:!1}catch{return!1}}export{gt as a,he as b,g as c,rn as d,ve as e,Se as f,on as g,Ge as h,F as i,ze as j,J as k,vt as l,St as m,xt as n,$ as o,a as p,nt as q,z as r,Bt as s,Ft as t,Jt as u,H as v,Y as w,st as x,D as y,Gt as z,De as A,zt as B,lt as C,Kt as D,ut as E,Wt as F,Ht as G,Yt as H,qt as I};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{p as Q,v as mt}from"./chunk-AR5BTVBM.js";import{a as j}from"./chunk-E75BCWXY.js";import{B as P,C as k,O as pt,da as y,o as R,z as S}from"./chunk-ZPIY5DOU.js";import{createHash as qt}from"node:crypto";import{open as Zt}from"node:fs/promises";var Mt=new Uint16Array(256);for(let e=0;e<256;e++){let t=0,n=e<<8;for(let r=0;r<8;r++)(t^n)&32768?t=t<<1^4129:t=t<<1,n=n<<1;Mt[e]=t&65535}var tt=0,wt=2;var ne=Date.UTC(2020,0,1,0,0,0);function ht(e,t,n,r,o,s,a,i,f,c,u,_,p,w,l,b){let F=z(o,d.__wbindgen_export3,d.__wbindgen_export4),A=x,v=rt(a,d.__wbindgen_export3),W=x,Dt=d.udf_add_file_stream(g(e),g(t),g(n),g(r),F,A,s,v,W,i,f,c,u,_,p,w,l,b);return M(Dt)}function oe(e,t,n,r){let o,s;try{let p=d.__wbindgen_add_to_stack_pointer(-16),w=z(e,d.__wbindgen_export3,d.__wbindgen_export4),l=x,b=z(t,d.__wbindgen_export3,d.__wbindgen_export4),F=x,A=z(n,d.__wbindgen_export3,d.__wbindgen_export4),v=x;d.udf_build_layout(p,w,l,b,F,A,v,r);var a=h().getInt32(p+0,!0),i=h().getInt32(p+4,!0),f=h().getInt32(p+8,!0),c=h().getInt32(p+12,!0),u=a,_=i;if(c)throw u=0,_=0,M(f);return o=u,s=_,C(u,_)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export5(o,s,1)}}function xt(e,t,n,r,o,s,a){let i=z(o,d.__wbindgen_export3,d.__wbindgen_export4),f=x,c=rt(a,d.__wbindgen_export3),u=x,_=d.udf_fill_sparse_stream(g(e),g(t),g(n),g(r),i,f,s,c,u);return M(_)}function ae(){let e,t;try{let o=d.__wbindgen_add_to_stack_pointer(-16);d.udf_last_panic(o);var n=h().getInt32(o+0,!0),r=h().getInt32(o+4,!0);return e=n,t=r,C(n,r)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export5(e,t,1)}}function St(e,t){let n=d.udf_parse_stream(g(e),g(t));return M(n)}function se(e){let t,n;try{let s=d.__wbindgen_add_to_stack_pointer(-16),a=rt(e,d.__wbindgen_export3),i=x;d.udf_read_conform_iuvd(s,a,i);var r=h().getInt32(s+0,!0),o=h().getInt32(s+4,!0);return t=r,n=o,C(r,o)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export5(t,n,1)}}function Lt(){return{__proto__:null,"./udf_bg.js":{__proto__:null,__wbg___wbindgen_is_function_acc5528be2b923f2:function(t){return typeof m(t)=="function"},__wbg___wbindgen_is_undefined_721f8decd50c87a3:function(t){return m(t)===void 0},__wbg___wbindgen_number_get_1cc01dd708740256:function(t,n){let r=m(n),o=typeof r=="number"?r:void 0;h().setFloat64(t+8,O(o)?0:o,!0),h().setInt32(t+0,!O(o),!0)},__wbg___wbindgen_throw_ea4887a5f8f9a9db:function(t,n){throw new Error(C(t,n))},__wbg__wbg_cb_unref_33c39e13d73b25f6:function(t){m(t)._wbg_cb_unref()},__wbg_call_0e855b388e315e17:function(){return et(function(t,n,r,o){let s=m(t).call(m(n),m(r),m(o));return g(s)},arguments)},__wbg_call_5575218572ead796:function(){return et(function(t,n,r){let o=m(t).call(m(n),m(r));return g(o)},arguments)},__wbg_call_8e98ed2f3c86c4b5:function(){return et(function(t,n){let r=m(t).call(m(n));return g(r)},arguments)},__wbg_error_2b5d73c4c4804cfd:function(t,n){console.error(C(t,n))},__wbg_length_589238bdcf171f0e:function(t){return m(t).length},__wbg_new_81880fb5002cb255:function(t){let n=new Uint8Array(m(t));return g(n)},__wbg_new_from_slice_543b875b27789a8f:function(t,n){let r=new Uint8Array(yt(t,n));return g(r)},__wbg_new_no_args_2d7333de60de5ac7:function(t,n){let r=new Function(C(t,n));return g(r)},__wbg_new_typed_00a409eb4ec4f2d9:function(t,n){try{var r={a:t,b:n},o=(a,i)=>{let f=r.a;r.a=0;try{return $t(f,r.b,a,i)}finally{r.a=f}};let s=new Promise(o);return g(s)}finally{r.a=0}},__wbg_prototypesetcall_d721637c7ca66eb8:function(t,n,r){Uint8Array.prototype.set.call(yt(t,n),m(r))},__wbg_queueMicrotask_1c9b3800e321a967:function(t){let n=m(t).queueMicrotask;return g(n)},__wbg_queueMicrotask_311744e534a929a3:function(t){queueMicrotask(m(t))},__wbg_resolve_d82363d90af6928a:function(t){let n=Promise.resolve(m(t));return g(n)},__wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938:function(){let t=typeof globalThis>"u"?null:globalThis;return O(t)?0:g(t)},__wbg_static_accessor_GLOBAL_ce44e66a4935da8c:function(){let t=typeof global>"u"?null:global;return O(t)?0:g(t)},__wbg_static_accessor_SELF_44f6e0cb5e67cdad:function(){let t=typeof self>"u"?null:self;return O(t)?0:g(t)},__wbg_static_accessor_WINDOW_168f178805d978fe:function(){let t=typeof window>"u"?null:window;return O(t)?0:g(t)},__wbg_then_05edfc8a4fea5106:function(t,n,r){let o=m(t).then(m(n),m(r));return g(o)},__wbg_then_591b6b3a75ee817a:function(t,n){let r=m(t).then(m(n));return g(r)},__wbindgen_cast_0000000000000001:function(t,n){let r=zt(t,n,jt);return g(r)},__wbindgen_cast_0000000000000002:function(t){return g(t)},__wbindgen_cast_0000000000000003:function(t,n){let r=C(t,n);return g(r)},__wbindgen_object_clone_ref:function(t){let n=m(t);return g(n)},__wbindgen_object_drop_ref:function(t){M(t)}}}}function jt(e,t,n){try{let s=d.__wbindgen_add_to_stack_pointer(-16);d.__wasm_bindgen_func_elem_268(s,e,t,g(n));var r=h().getInt32(s+0,!0),o=h().getInt32(s+4,!0);if(o)throw M(r)}finally{d.__wbindgen_add_to_stack_pointer(16)}}function $t(e,t,n,r){d.__wasm_bindgen_func_elem_282(e,t,g(n),g(r))}function g(e){N===E.length&&E.push(E.length+1);let t=N;return N=E[t],E[t]=e,t}var bt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>d.__wbindgen_export2(e.a,e.b));function Nt(e){e<1028||(E[e]=N,N=e)}function yt(e,t){return e=e>>>0,D().subarray(e/1,e/1+t)}var U=null;function h(){return(U===null||U.buffer.detached===!0||U.buffer.detached===void 0&&U.buffer!==d.memory.buffer)&&(U=new DataView(d.memory.buffer)),U}function C(e,t){return Wt(e>>>0,t)}var $=null;function D(){return($===null||$.byteLength===0)&&($=new Uint8Array(d.memory.buffer)),$}function m(e){return E[e]}function et(e,t){try{return e.apply(this,t)}catch(n){d.__wbindgen_export(g(n))}}var E=new Array(1024).fill(void 0);E.push(void 0,null,!0,!1);var N=E.length;function O(e){return e==null}function zt(e,t,n){let r={a:e,b:t,cnt:1},o=(...s)=>{r.cnt++;let a=r.a;r.a=0;try{return n(a,r.b,...s)}finally{r.a=a,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{--r.cnt===0&&(d.__wbindgen_export2(r.a,r.b),r.a=0,bt.unregister(r))},bt.register(o,r,r),o}function rt(e,t){let n=t(e.length*1,1)>>>0;return D().set(e,n/1),x=e.length,n}function z(e,t,n){if(n===void 0){let i=B.encode(e),f=t(i.length,1)>>>0;return D().subarray(f,f+i.length).set(i),x=i.length,f}let r=e.length,o=t(r,1)>>>0,s=D(),a=0;for(;a<r;a++){let i=e.charCodeAt(a);if(i>127)break;s[o+a]=i}if(a!==r){a!==0&&(e=e.slice(a)),o=n(o,r,r=a+e.length*3,1)>>>0;let i=D().subarray(o+a,o+r),f=B.encodeInto(e,i);a+=f.written,o=n(o,r,a,1)>>>0}return x=a,o}function M(e){let t=m(e);return Nt(e),t}var H=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});H.decode();var Bt=2146435072,nt=0;function Wt(e,t){return nt+=t,nt>=Bt&&(H=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),H.decode(),nt=t),H.decode(D().subarray(e,e+t))}var B=new TextEncoder;"encodeInto"in B||(B.encodeInto=function(e,t){let n=B.encode(e);return t.set(n),{read:e.length,written:n.length}});var x=0,Ht,Gt,d;function Jt(e,t){return Gt=e,d=e.exports,Ht=t,U=null,$=null,d.__wbindgen_start(),d}async function Vt(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(e.ok&&n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function G(e){if(d!==void 0)return d;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0&&(e=new URL("udf_bg.wasm",import.meta.url));let t=Lt();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Vt(await e,t);return Jt(n,r)}var ot=null;function Xt(e){return ot||(ot=(async()=>{if(e!==void 0)return G(e);if(typeof process<"u"&&process.versions?.node){let n="node:fs/promises",{readFile:r}=await import(n),o=await r(new URL("./wasm/udf_bg.wasm",import.meta.url));return G({module_or_path:o})}let{default:t}=await import("./udf_bg-HOHEKAVF.js");return G({module_or_path:t})})()),ot}function J(){return Xt()}function V(e){return(t,n)=>e.read(t,n)}function at(e){return(t,n)=>e.write(t,n)}function X(e){return()=>e.getSize()}function st(e){return t=>e.setSize?e.setSize(t):Promise.resolve()}async function It(e){await J();let t=JSON.parse(await St(V(e),X(e)));if(t.error)throw new Error(t.error);let n=null;if(t.iuvdPayload)try{n=JSON.parse(t.iuvdPayload)}catch{}let r=null,o=t.files.find(s=>s.name===".i2o-manifest.json");if(o&&o.extents.length>0&&o.extents[0].type===tt){let s=o.extents[0].position,a=await e.read((t.partitionStartSector+s)*2048,o.totalSize);try{r=JSON.parse(new TextDecoder().decode(a))}catch{}}return{totalSectors:t.totalSectors,partitionStartSector:t.partitionStartSector,partitionLength:t.partitionLength,volumeName:t.volumeName,files:t.files,manifest:r,iuvdPayload:n,rootIcbSector:t.rootIcbSector,rootDataSector:t.rootDataSector,rootDataLength:t.rootDataLength,rootDataSectors:t.rootDataSectors,vdsStartSector:t.vdsStartSector,partitionDescVdsSector:t.partitionDescVdsSector}}function me(e){let t=[],n=0;for(let r of e.extents)r.type===wt&&t.push({offset:n,length:r.length}),n+=r.length;return t}function At(e){let t=[],n=0;for(let r of e.extents)r.type===tt&&t.push({offset:n,length:r.length,imageSector:r.position}),n+=r.length;return t}async function we(e,t,n,r,o){return await J(),await xt(V(e),at(e),X(e),st(e),n,r,o),It(e)}async function be(e,t,n,r,o,s=0){await J();let a=new Date,i=!!(o&&o.length>0);return await ht(V(e),at(e),X(e),st(e),n,r,i?o:new Uint8Array(0),i,s,a.getFullYear(),a.getMonth()+1,a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),-a.getTimezoneOffset()),It(e)}var Y=1<<20,T=5*Y,Et=5*1024*Y,it=1e4,ct=8*Y,Kt=2048;function Ae(e,t,n=Math.max(16*Y,Math.ceil(e/(it-500)))){let r=[...t].filter(c=>c.len>0).sort((c,u)=>c.at-u.at),o=[];for(let c of r){let u=o[o.length-1];u&&c.at<u.at+u.len||(u&&u.at+u.len===c.at&&u.key===c.key&&u.offset+u.len===c.offset?u.len+=c.len:o.push({...c}))}let s=[],a=0;for(let c of o.filter(u=>u.len>=T))c.at>a&&s.push({at:a,len:c.at-a}),s.push({at:c.at,len:c.len,copy:c}),a=c.at+c.len;a<e&&s.push({at:a,len:e-a});let i=c=>c.reduce((u,_)=>{let p=u[u.length-1];return p&&!p.copy&&!_.copy?p.len+=_.len:u.push({..._}),u},[]);for(let c=!0;c;){c=!1,s=i(s);for(let u=0;u<s.length-1;u++){let _=s[u];if(_.len>=T)continue;let p=T-_.len,w=s[u+1],l=s[u-1];if(_.copy){delete _.copy,c=!0;break}w?.copy&&w.len-p>=T?(_.len+=p,w.at+=p,w.len-=p,w.copy={...w.copy,at:w.at,len:w.len,offset:w.copy.offset+p}):l?.copy&&l.len-p>=T?(l.len-=p,l.copy={...l.copy,len:l.len},_.at-=p,_.len+=p):w?.copy?delete w.copy:l?.copy&&delete l.copy,c=!0;break}}let f=[];for(let c of s){let u=c.copy?Math.min(Et,Math.max(n,T)):n;for(let _=c.at,p=c.at+c.len;_<p;){let w=Math.min(u,p-_);p-(_+w)>0&&p-(_+w)<T&&(w=p-_<=Et?p-_:w-T),f.push(c.copy?{kind:"copy",at:_,len:w,key:c.copy.key,offset:c.copy.offset+(_-c.at)}:{kind:"upload",at:_,len:w}),_+=w}}if(f.length>it)throw new Error(`the image needs ${f.length} pieces (S3 allows ${it})`);return f}function Ee(e,t,n,r){let o=[...r].sort((i,f)=>i.offset-f.offset),s=[],a=0;for(let i of o){let f=Math.min(i.offset,t);f>a&&s.push({at:a,len:f-a,key:e,offset:a}),a=Math.max(a,i.offset+i.length)}return a<Math.min(t,n)&&s.push({at:a,len:Math.min(t,n)-a,key:e,offset:a}),s}async function ve(e,t,n,r,o){let s=[];for(let a of t.files)for(let i of At(a)){let f=(t.partitionStartSector+i.imageSector)*Kt;for(let c=i.offset;c<i.offset+i.length;){let u=Math.min(i.offset+i.length,(Math.floor(c/ct)+1)*ct),_=f+(c-i.offset);s.push(o?.(_,u-c)??[qt("sha256").update(await e.read(_,u-c)).digest("hex"),_,u-c]),r?.(u-c),c=u}}return{v:1,block:ct,size:n,blocks:s}}function Pe(e,t){let n=new Map;for(let o of t)for(let[s,a,i]of o.index.blocks)n.set(`${s}:${i}`,{key:o.key,offset:a});let r=[];for(let[o,s,a]of e.blocks){let i=n.get(`${o}:${a}`);i&&r.push({at:s,len:a,key:i.key,offset:i.offset})}return r}var vt=(e,t)=>`${Q().supabaseUrl}/functions/v1/${e}${t}`;async function dt(e,t,n={}){let{token:r,error:o}=await mt();if(!r)throw o;let s=await fetch(vt(e,t),{method:n.method??(n.body?"POST":"GET"),headers:{authorization:`Bearer ${r}`,apikey:Q().anonKey,...n.body?{"content-type":"application/json"}:{}},...n.body?{body:JSON.stringify(n.body)}:{},signal:AbortSignal.timeout(2e4)}),a=await s.text();if(!s.ok){let i=a;try{let f=JSON.parse(a);i=f.error?.message??f.message??f.error??a}catch{}throw s.status===404&&/Requested function was not found/i.test(String(i))?new Error(`${e} isn't deployed on ${new URL(vt(e,t)).host}: this server doesn't have that feature yet (an older server, or a staging/production mismatch)`):new Error(`${n.method??"GET"} ${t}: ${s.status} ${i}`)}return a?JSON.parse(a):{}}function ke(e,t="org"){let n=`/v1/sessions/${e}/storage/multipart`,r=(o,s,a)=>dt("v1-sessions",o,{body:s,method:a});return{start:async o=>String((await r(`${n}/start`,{key:o,content_type:"application/x-iso9660-image"})).upload_id),partUrls:async(o,s,a,i)=>(await r(`${n}/${s}/part-urls`,{key:o,first_part:a,count:i})).parts,copyPart:async(o,s,a,i)=>String((await r(`${n}/${s}/copy-part`,{key:o,part_number:a,source_ref:{scheme:t,bucket:"i2o",key:i.key},byte_range:{offset:i.offset,length:i.length}})).etag),complete:async(o,s,a)=>{await r(`${n}/${s}/complete`,{key:o,parts:a})},abort:async(o,s)=>{await r(`${n}/${encodeURIComponent(s)}?key=${encodeURIComponent(o)}`,void 0,"DELETE")},readUrl:async o=>String((await r(`/v1/sessions/${e}/download-url`,{storage_path:o})).download_url)}}async function ut(e,t,n=4){for(let r=1;;r++)try{return await t()}catch(o){if(r>=n)throw new Error(`${e} failed after ${n} tries: ${o instanceof Error?o.message:o}`);await new Promise(s=>setTimeout(s,500*2**r))}}async function Te(e,t,n,r,o={}){let s=o.fetchFn??fetch,a=await e.start(t),i=n.reduce((l,b)=>l+b.len,0),f=new Array(n.length),c=0,u=0,_=new Map,p=async l=>(_.has(l)||(await e.partUrls(t,a,l+1,Math.min(100,n.length-l))).forEach((F,A)=>_.set(l+A,F)),_.get(l)),w=async l=>{let b=n[l];if(b.kind==="copy")f[l]=await ut(`copy piece ${l+1}`,()=>e.copyPart(t,a,l+1,{key:b.key,offset:b.offset,length:b.len}));else{let F=await r(b.at,b.len);f[l]=await ut(`upload piece ${l+1}`,async()=>{let A=await p(l),v=await s(A.upload_url,{method:A.method,headers:A.headers,body:F,signal:o.signal});if(!v.ok)throw _.delete(l),new Error(`${v.status} ${(await v.text()).slice(0,200)}`);let W=v.headers.get("etag");if(!W)throw new Error("the bucket returned no ETag (expose it in the bucket's CORS / response headers)");return W})}c+=b.len,o.onProgress?.(c,i)};try{await Promise.all(Array.from({length:Math.min(6,n.length)},async()=>{for(;u<n.length;)o.signal?.throwIfAborted(),await w(u++)})),await ut("complete",()=>e.complete(t,a,f.map((l,b)=>({part_number:b+1,etag:l}))))}catch(l){throw await e.abort(t,a).catch(()=>{}),l}return{uploaded:n.filter(l=>l.kind==="upload").reduce((l,b)=>l+b.len,0),copied:n.filter(l=>l.kind==="copy").reduce((l,b)=>l+b.len,0),pieces:n.length}}function Fe(e){let t=Zt(e,"r");return{read:async(n,r)=>{let o=new Uint8Array(r);return await(await t).read(o,0,r,n),o},close:async()=>{await(await t).close()}}}var gt="local",kt=/^[A-Za-z0-9_-]{1,64}$/,I=e=>{if(!kt.test(e))throw new j("invalid_args",`bad project_id '${e}'`);return y(R(),"projects",e)},lt=(e,t={})=>dt("v1-projects",e,t),Tt=e=>Number(/: (\d{3}) /.exec(String(e?.message))?.[1]??0);async function Ft(e){let t="",n={base:null,by:null};try{t=await S(y(I(e),"CONTEXT.md"))}catch{}try{n=JSON.parse(await S(y(I(e),"context.json")))}catch{}return{text:t,meta:n}}async function _t(e,t,n){await k(I(e)),await P(y(I(e),"CONTEXT.md"),t),await P(y(I(e),"context.json"),JSON.stringify(n))}var ft=async(e,t)=>(await _t(e,t.context,{base:t.context_updated_at,by:t.context_updated_by_name??null}),{text:t.context,updated_at:t.context_updated_at,updated_by:t.context_updated_by_name??null});async function Me(e){I(e);let t=await Ft(e);if(e===gt)return{text:t.text,updated_at:null,updated_by:null};if(t.meta.pending)try{return await Pt(e,t.text,t.meta.base)}catch(n){if(!(n instanceof j&&n.code==="context_conflict"))return{text:t.text,updated_at:t.meta.base,updated_by:t.meta.by,offline:!0,pending:!0};let r=n.data?.current??{context:"",context_updated_at:null},o=`${r.context.trimEnd()}
|
|
3
|
+
import{p as Q,v as mt}from"./chunk-ZNBXAGOK.js";import{a as j}from"./chunk-E75BCWXY.js";import{C as P,D as k,P as pt,ea as y,o as R,z as S}from"./chunk-QQBDHVUU.js";import{createHash as qt}from"node:crypto";import{open as Zt}from"node:fs/promises";var Mt=new Uint16Array(256);for(let e=0;e<256;e++){let t=0,n=e<<8;for(let r=0;r<8;r++)(t^n)&32768?t=t<<1^4129:t=t<<1,n=n<<1;Mt[e]=t&65535}var tt=0,wt=2;var ne=Date.UTC(2020,0,1,0,0,0);function ht(e,t,n,r,o,s,a,i,f,c,u,_,p,w,l,b){let F=z(o,d.__wbindgen_export3,d.__wbindgen_export4),A=x,v=rt(a,d.__wbindgen_export3),W=x,Dt=d.udf_add_file_stream(g(e),g(t),g(n),g(r),F,A,s,v,W,i,f,c,u,_,p,w,l,b);return M(Dt)}function oe(e,t,n,r){let o,s;try{let p=d.__wbindgen_add_to_stack_pointer(-16),w=z(e,d.__wbindgen_export3,d.__wbindgen_export4),l=x,b=z(t,d.__wbindgen_export3,d.__wbindgen_export4),F=x,A=z(n,d.__wbindgen_export3,d.__wbindgen_export4),v=x;d.udf_build_layout(p,w,l,b,F,A,v,r);var a=h().getInt32(p+0,!0),i=h().getInt32(p+4,!0),f=h().getInt32(p+8,!0),c=h().getInt32(p+12,!0),u=a,_=i;if(c)throw u=0,_=0,M(f);return o=u,s=_,C(u,_)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export5(o,s,1)}}function xt(e,t,n,r,o,s,a){let i=z(o,d.__wbindgen_export3,d.__wbindgen_export4),f=x,c=rt(a,d.__wbindgen_export3),u=x,_=d.udf_fill_sparse_stream(g(e),g(t),g(n),g(r),i,f,s,c,u);return M(_)}function ae(){let e,t;try{let o=d.__wbindgen_add_to_stack_pointer(-16);d.udf_last_panic(o);var n=h().getInt32(o+0,!0),r=h().getInt32(o+4,!0);return e=n,t=r,C(n,r)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export5(e,t,1)}}function St(e,t){let n=d.udf_parse_stream(g(e),g(t));return M(n)}function se(e){let t,n;try{let s=d.__wbindgen_add_to_stack_pointer(-16),a=rt(e,d.__wbindgen_export3),i=x;d.udf_read_conform_iuvd(s,a,i);var r=h().getInt32(s+0,!0),o=h().getInt32(s+4,!0);return t=r,n=o,C(r,o)}finally{d.__wbindgen_add_to_stack_pointer(16),d.__wbindgen_export5(t,n,1)}}function Lt(){return{__proto__:null,"./udf_bg.js":{__proto__:null,__wbg___wbindgen_is_function_acc5528be2b923f2:function(t){return typeof m(t)=="function"},__wbg___wbindgen_is_undefined_721f8decd50c87a3:function(t){return m(t)===void 0},__wbg___wbindgen_number_get_1cc01dd708740256:function(t,n){let r=m(n),o=typeof r=="number"?r:void 0;h().setFloat64(t+8,O(o)?0:o,!0),h().setInt32(t+0,!O(o),!0)},__wbg___wbindgen_throw_ea4887a5f8f9a9db:function(t,n){throw new Error(C(t,n))},__wbg__wbg_cb_unref_33c39e13d73b25f6:function(t){m(t)._wbg_cb_unref()},__wbg_call_0e855b388e315e17:function(){return et(function(t,n,r,o){let s=m(t).call(m(n),m(r),m(o));return g(s)},arguments)},__wbg_call_5575218572ead796:function(){return et(function(t,n,r){let o=m(t).call(m(n),m(r));return g(o)},arguments)},__wbg_call_8e98ed2f3c86c4b5:function(){return et(function(t,n){let r=m(t).call(m(n));return g(r)},arguments)},__wbg_error_2b5d73c4c4804cfd:function(t,n){console.error(C(t,n))},__wbg_length_589238bdcf171f0e:function(t){return m(t).length},__wbg_new_81880fb5002cb255:function(t){let n=new Uint8Array(m(t));return g(n)},__wbg_new_from_slice_543b875b27789a8f:function(t,n){let r=new Uint8Array(yt(t,n));return g(r)},__wbg_new_no_args_2d7333de60de5ac7:function(t,n){let r=new Function(C(t,n));return g(r)},__wbg_new_typed_00a409eb4ec4f2d9:function(t,n){try{var r={a:t,b:n},o=(a,i)=>{let f=r.a;r.a=0;try{return $t(f,r.b,a,i)}finally{r.a=f}};let s=new Promise(o);return g(s)}finally{r.a=0}},__wbg_prototypesetcall_d721637c7ca66eb8:function(t,n,r){Uint8Array.prototype.set.call(yt(t,n),m(r))},__wbg_queueMicrotask_1c9b3800e321a967:function(t){let n=m(t).queueMicrotask;return g(n)},__wbg_queueMicrotask_311744e534a929a3:function(t){queueMicrotask(m(t))},__wbg_resolve_d82363d90af6928a:function(t){let n=Promise.resolve(m(t));return g(n)},__wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938:function(){let t=typeof globalThis>"u"?null:globalThis;return O(t)?0:g(t)},__wbg_static_accessor_GLOBAL_ce44e66a4935da8c:function(){let t=typeof global>"u"?null:global;return O(t)?0:g(t)},__wbg_static_accessor_SELF_44f6e0cb5e67cdad:function(){let t=typeof self>"u"?null:self;return O(t)?0:g(t)},__wbg_static_accessor_WINDOW_168f178805d978fe:function(){let t=typeof window>"u"?null:window;return O(t)?0:g(t)},__wbg_then_05edfc8a4fea5106:function(t,n,r){let o=m(t).then(m(n),m(r));return g(o)},__wbg_then_591b6b3a75ee817a:function(t,n){let r=m(t).then(m(n));return g(r)},__wbindgen_cast_0000000000000001:function(t,n){let r=zt(t,n,jt);return g(r)},__wbindgen_cast_0000000000000002:function(t){return g(t)},__wbindgen_cast_0000000000000003:function(t,n){let r=C(t,n);return g(r)},__wbindgen_object_clone_ref:function(t){let n=m(t);return g(n)},__wbindgen_object_drop_ref:function(t){M(t)}}}}function jt(e,t,n){try{let s=d.__wbindgen_add_to_stack_pointer(-16);d.__wasm_bindgen_func_elem_268(s,e,t,g(n));var r=h().getInt32(s+0,!0),o=h().getInt32(s+4,!0);if(o)throw M(r)}finally{d.__wbindgen_add_to_stack_pointer(16)}}function $t(e,t,n,r){d.__wasm_bindgen_func_elem_282(e,t,g(n),g(r))}function g(e){N===E.length&&E.push(E.length+1);let t=N;return N=E[t],E[t]=e,t}var bt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>d.__wbindgen_export2(e.a,e.b));function Nt(e){e<1028||(E[e]=N,N=e)}function yt(e,t){return e=e>>>0,D().subarray(e/1,e/1+t)}var U=null;function h(){return(U===null||U.buffer.detached===!0||U.buffer.detached===void 0&&U.buffer!==d.memory.buffer)&&(U=new DataView(d.memory.buffer)),U}function C(e,t){return Wt(e>>>0,t)}var $=null;function D(){return($===null||$.byteLength===0)&&($=new Uint8Array(d.memory.buffer)),$}function m(e){return E[e]}function et(e,t){try{return e.apply(this,t)}catch(n){d.__wbindgen_export(g(n))}}var E=new Array(1024).fill(void 0);E.push(void 0,null,!0,!1);var N=E.length;function O(e){return e==null}function zt(e,t,n){let r={a:e,b:t,cnt:1},o=(...s)=>{r.cnt++;let a=r.a;r.a=0;try{return n(a,r.b,...s)}finally{r.a=a,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{--r.cnt===0&&(d.__wbindgen_export2(r.a,r.b),r.a=0,bt.unregister(r))},bt.register(o,r,r),o}function rt(e,t){let n=t(e.length*1,1)>>>0;return D().set(e,n/1),x=e.length,n}function z(e,t,n){if(n===void 0){let i=B.encode(e),f=t(i.length,1)>>>0;return D().subarray(f,f+i.length).set(i),x=i.length,f}let r=e.length,o=t(r,1)>>>0,s=D(),a=0;for(;a<r;a++){let i=e.charCodeAt(a);if(i>127)break;s[o+a]=i}if(a!==r){a!==0&&(e=e.slice(a)),o=n(o,r,r=a+e.length*3,1)>>>0;let i=D().subarray(o+a,o+r),f=B.encodeInto(e,i);a+=f.written,o=n(o,r,a,1)>>>0}return x=a,o}function M(e){let t=m(e);return Nt(e),t}var H=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});H.decode();var Bt=2146435072,nt=0;function Wt(e,t){return nt+=t,nt>=Bt&&(H=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),H.decode(),nt=t),H.decode(D().subarray(e,e+t))}var B=new TextEncoder;"encodeInto"in B||(B.encodeInto=function(e,t){let n=B.encode(e);return t.set(n),{read:e.length,written:n.length}});var x=0,Ht,Gt,d;function Jt(e,t){return Gt=e,d=e.exports,Ht=t,U=null,$=null,d.__wbindgen_start(),d}async function Vt(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(e.ok&&n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function G(e){if(d!==void 0)return d;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0&&(e=new URL("udf_bg.wasm",import.meta.url));let t=Lt();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Vt(await e,t);return Jt(n,r)}var ot=null;function Xt(e){return ot||(ot=(async()=>{if(e!==void 0)return G(e);if(typeof process<"u"&&process.versions?.node){let n="node:fs/promises",{readFile:r}=await import(n),o=await r(new URL("./wasm/udf_bg.wasm",import.meta.url));return G({module_or_path:o})}let{default:t}=await import("./udf_bg-HOHEKAVF.js");return G({module_or_path:t})})()),ot}function J(){return Xt()}function V(e){return(t,n)=>e.read(t,n)}function at(e){return(t,n)=>e.write(t,n)}function X(e){return()=>e.getSize()}function st(e){return t=>e.setSize?e.setSize(t):Promise.resolve()}async function It(e){await J();let t=JSON.parse(await St(V(e),X(e)));if(t.error)throw new Error(t.error);let n=null;if(t.iuvdPayload)try{n=JSON.parse(t.iuvdPayload)}catch{}let r=null,o=t.files.find(s=>s.name===".i2o-manifest.json");if(o&&o.extents.length>0&&o.extents[0].type===tt){let s=o.extents[0].position,a=await e.read((t.partitionStartSector+s)*2048,o.totalSize);try{r=JSON.parse(new TextDecoder().decode(a))}catch{}}return{totalSectors:t.totalSectors,partitionStartSector:t.partitionStartSector,partitionLength:t.partitionLength,volumeName:t.volumeName,files:t.files,manifest:r,iuvdPayload:n,rootIcbSector:t.rootIcbSector,rootDataSector:t.rootDataSector,rootDataLength:t.rootDataLength,rootDataSectors:t.rootDataSectors,vdsStartSector:t.vdsStartSector,partitionDescVdsSector:t.partitionDescVdsSector}}function me(e){let t=[],n=0;for(let r of e.extents)r.type===wt&&t.push({offset:n,length:r.length}),n+=r.length;return t}function At(e){let t=[],n=0;for(let r of e.extents)r.type===tt&&t.push({offset:n,length:r.length,imageSector:r.position}),n+=r.length;return t}async function we(e,t,n,r,o){return await J(),await xt(V(e),at(e),X(e),st(e),n,r,o),It(e)}async function be(e,t,n,r,o,s=0){await J();let a=new Date,i=!!(o&&o.length>0);return await ht(V(e),at(e),X(e),st(e),n,r,i?o:new Uint8Array(0),i,s,a.getFullYear(),a.getMonth()+1,a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),-a.getTimezoneOffset()),It(e)}var Y=1<<20,T=5*Y,Et=5*1024*Y,it=1e4,ct=8*Y,Kt=2048;function Ae(e,t,n=Math.max(16*Y,Math.ceil(e/(it-500)))){let r=[...t].filter(c=>c.len>0).sort((c,u)=>c.at-u.at),o=[];for(let c of r){let u=o[o.length-1];u&&c.at<u.at+u.len||(u&&u.at+u.len===c.at&&u.key===c.key&&u.offset+u.len===c.offset?u.len+=c.len:o.push({...c}))}let s=[],a=0;for(let c of o.filter(u=>u.len>=T))c.at>a&&s.push({at:a,len:c.at-a}),s.push({at:c.at,len:c.len,copy:c}),a=c.at+c.len;a<e&&s.push({at:a,len:e-a});let i=c=>c.reduce((u,_)=>{let p=u[u.length-1];return p&&!p.copy&&!_.copy?p.len+=_.len:u.push({..._}),u},[]);for(let c=!0;c;){c=!1,s=i(s);for(let u=0;u<s.length-1;u++){let _=s[u];if(_.len>=T)continue;let p=T-_.len,w=s[u+1],l=s[u-1];if(_.copy){delete _.copy,c=!0;break}w?.copy&&w.len-p>=T?(_.len+=p,w.at+=p,w.len-=p,w.copy={...w.copy,at:w.at,len:w.len,offset:w.copy.offset+p}):l?.copy&&l.len-p>=T?(l.len-=p,l.copy={...l.copy,len:l.len},_.at-=p,_.len+=p):w?.copy?delete w.copy:l?.copy&&delete l.copy,c=!0;break}}let f=[];for(let c of s){let u=c.copy?Math.min(Et,Math.max(n,T)):n;for(let _=c.at,p=c.at+c.len;_<p;){let w=Math.min(u,p-_);p-(_+w)>0&&p-(_+w)<T&&(w=p-_<=Et?p-_:w-T),f.push(c.copy?{kind:"copy",at:_,len:w,key:c.copy.key,offset:c.copy.offset+(_-c.at)}:{kind:"upload",at:_,len:w}),_+=w}}if(f.length>it)throw new Error(`the image needs ${f.length} pieces (S3 allows ${it})`);return f}function Ee(e,t,n,r){let o=[...r].sort((i,f)=>i.offset-f.offset),s=[],a=0;for(let i of o){let f=Math.min(i.offset,t);f>a&&s.push({at:a,len:f-a,key:e,offset:a}),a=Math.max(a,i.offset+i.length)}return a<Math.min(t,n)&&s.push({at:a,len:Math.min(t,n)-a,key:e,offset:a}),s}async function ve(e,t,n,r,o){let s=[];for(let a of t.files)for(let i of At(a)){let f=(t.partitionStartSector+i.imageSector)*Kt;for(let c=i.offset;c<i.offset+i.length;){let u=Math.min(i.offset+i.length,(Math.floor(c/ct)+1)*ct),_=f+(c-i.offset);s.push(o?.(_,u-c)??[qt("sha256").update(await e.read(_,u-c)).digest("hex"),_,u-c]),r?.(u-c),c=u}}return{v:1,block:ct,size:n,blocks:s}}function Pe(e,t){let n=new Map;for(let o of t)for(let[s,a,i]of o.index.blocks)n.set(`${s}:${i}`,{key:o.key,offset:a});let r=[];for(let[o,s,a]of e.blocks){let i=n.get(`${o}:${a}`);i&&r.push({at:s,len:a,key:i.key,offset:i.offset})}return r}var vt=(e,t)=>`${Q().supabaseUrl}/functions/v1/${e}${t}`;async function dt(e,t,n={}){let{token:r,error:o}=await mt();if(!r)throw o;let s=await fetch(vt(e,t),{method:n.method??(n.body?"POST":"GET"),headers:{authorization:`Bearer ${r}`,apikey:Q().anonKey,...n.body?{"content-type":"application/json"}:{}},...n.body?{body:JSON.stringify(n.body)}:{},signal:AbortSignal.timeout(2e4)}),a=await s.text();if(!s.ok){let i=a;try{let f=JSON.parse(a);i=f.error?.message??f.message??f.error??a}catch{}throw s.status===404&&/Requested function was not found/i.test(String(i))?new Error(`${e} isn't deployed on ${new URL(vt(e,t)).host}: this server doesn't have that feature yet (an older server, or a staging/production mismatch)`):new Error(`${n.method??"GET"} ${t}: ${s.status} ${i}`)}return a?JSON.parse(a):{}}function ke(e,t="org"){let n=`/v1/sessions/${e}/storage/multipart`,r=(o,s,a)=>dt("v1-sessions",o,{body:s,method:a});return{start:async o=>String((await r(`${n}/start`,{key:o,content_type:"application/x-iso9660-image"})).upload_id),partUrls:async(o,s,a,i)=>(await r(`${n}/${s}/part-urls`,{key:o,first_part:a,count:i})).parts,copyPart:async(o,s,a,i)=>String((await r(`${n}/${s}/copy-part`,{key:o,part_number:a,source_ref:{scheme:t,bucket:"i2o",key:i.key},byte_range:{offset:i.offset,length:i.length}})).etag),complete:async(o,s,a)=>{await r(`${n}/${s}/complete`,{key:o,parts:a})},abort:async(o,s)=>{await r(`${n}/${encodeURIComponent(s)}?key=${encodeURIComponent(o)}`,void 0,"DELETE")},readUrl:async o=>String((await r(`/v1/sessions/${e}/download-url`,{storage_path:o})).download_url)}}async function ut(e,t,n=4){for(let r=1;;r++)try{return await t()}catch(o){if(r>=n)throw new Error(`${e} failed after ${n} tries: ${o instanceof Error?o.message:o}`);await new Promise(s=>setTimeout(s,500*2**r))}}async function Te(e,t,n,r,o={}){let s=o.fetchFn??fetch,a=await e.start(t),i=n.reduce((l,b)=>l+b.len,0),f=new Array(n.length),c=0,u=0,_=new Map,p=async l=>(_.has(l)||(await e.partUrls(t,a,l+1,Math.min(100,n.length-l))).forEach((F,A)=>_.set(l+A,F)),_.get(l)),w=async l=>{let b=n[l];if(b.kind==="copy")f[l]=await ut(`copy piece ${l+1}`,()=>e.copyPart(t,a,l+1,{key:b.key,offset:b.offset,length:b.len}));else{let F=await r(b.at,b.len);f[l]=await ut(`upload piece ${l+1}`,async()=>{let A=await p(l),v=await s(A.upload_url,{method:A.method,headers:A.headers,body:F,signal:o.signal});if(!v.ok)throw _.delete(l),new Error(`${v.status} ${(await v.text()).slice(0,200)}`);let W=v.headers.get("etag");if(!W)throw new Error("the bucket returned no ETag (expose it in the bucket's CORS / response headers)");return W})}c+=b.len,o.onProgress?.(c,i)};try{await Promise.all(Array.from({length:Math.min(6,n.length)},async()=>{for(;u<n.length;)o.signal?.throwIfAborted(),await w(u++)})),await ut("complete",()=>e.complete(t,a,f.map((l,b)=>({part_number:b+1,etag:l}))))}catch(l){throw await e.abort(t,a).catch(()=>{}),l}return{uploaded:n.filter(l=>l.kind==="upload").reduce((l,b)=>l+b.len,0),copied:n.filter(l=>l.kind==="copy").reduce((l,b)=>l+b.len,0),pieces:n.length}}function Fe(e){let t=Zt(e,"r");return{read:async(n,r)=>{let o=new Uint8Array(r);return await(await t).read(o,0,r,n),o},close:async()=>{await(await t).close()}}}var gt="local",kt=/^[A-Za-z0-9_-]{1,64}$/,I=e=>{if(!kt.test(e))throw new j("invalid_args",`bad project_id '${e}'`);return y(R(),"projects",e)},lt=(e,t={})=>dt("v1-projects",e,t),Tt=e=>Number(/: (\d{3}) /.exec(String(e?.message))?.[1]??0);async function Ft(e){let t="",n={base:null,by:null};try{t=await S(y(I(e),"CONTEXT.md"))}catch{}try{n=JSON.parse(await S(y(I(e),"context.json")))}catch{}return{text:t,meta:n}}async function _t(e,t,n){await k(I(e)),await P(y(I(e),"CONTEXT.md"),t),await P(y(I(e),"context.json"),JSON.stringify(n))}var ft=async(e,t)=>(await _t(e,t.context,{base:t.context_updated_at,by:t.context_updated_by_name??null}),{text:t.context,updated_at:t.context_updated_at,updated_by:t.context_updated_by_name??null});async function Me(e){I(e);let t=await Ft(e);if(e===gt)return{text:t.text,updated_at:null,updated_by:null};if(t.meta.pending)try{return await Pt(e,t.text,t.meta.base)}catch(n){if(!(n instanceof j&&n.code==="context_conflict"))return{text:t.text,updated_at:t.meta.base,updated_by:t.meta.by,offline:!0,pending:!0};let r=n.data?.current??{context:"",context_updated_at:null},o=`${r.context.trimEnd()}
|
|
4
4
|
|
|
5
5
|
## Saved offline on this machine (merge into the notes above)
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{C as m,D as w,H as p,S as k,a as C,ea as u,o as y,p as v,v as c,z as b}from"./chunk-QQBDHVUU.js";import"./chunk-PSANHDZM.js";var S="conformtools-statusline";function O(e,n){let t=e.statusLine;return t&&!String(t.command??"").includes(S)?{settings:e,result:"kept"}:t?.command===n?{settings:e,result:"updated"}:{settings:{...e,statusLine:{type:"command",command:n,padding:0}},result:t?"updated":"installed"}}async function _(){let e=new URL(import.meta.url),n=C(new URL("./statusline.js",e));if(await c(n)){await w(y());let s=u(y(),`${S}.js`);return await p(n,s),`node "${s}"`}let t=C(new URL("../adapters/statusline.ts",e));return await c(t)?`deno run --allow-read --allow-env --no-check "${t}" ${S}`:null}function A(e,n){let t=e.permissions&&typeof e.permissions=="object"?e.permissions:{},s=Array.isArray(t.allow)?t.allow.filter(o=>typeof o=="string"):[];return s.includes(n)?{settings:e,added:!1}:{settings:{...e,permissions:{...t,allow:[...s,n]}},added:!0}}async function T(e={}){let n=e.server??"conformtools",t=`mcp__${n}`,s=e.settingsPath??u(v(),".claude","settings.json"),o={};if(await c(s)){let r=await b(s);try{o=r.trim()?JSON.parse(r):{}}catch(d){throw new Error(`${s} is not valid JSON (${d instanceof Error?d.message:d}); fix it first, nothing was changed`)}}let a=A(o,t),i=a.settings,l="skipped",f=a.added,P=e.statusline===!1?null:await _();if(P){let r=O(i,P);i=r.settings,l=r.result}let x;(f||l==="installed"||l==="updated"&&i!==a.settings)&&(await c(s)?(x=`${s}.conformtools-backup`,await p(s,x)):await w(u(s,"..")),await m(s,JSON.stringify(i,null,2)+`
|
|
4
4
|
`));let g="skipped",$;if(e.register!==!1)try{let r=await k("claude",["mcp","get",n]),d=r.code===0&&r.stdout.includes("conformtools@latest")&&!r.stdout.includes("--prefer-online");if(r.code===0&&!d)g="already";else{d&&await k("claude",["mcp","remove","-s","user",n]);let h=await k("claude",["mcp","add","-s","user",n,"--","npx",...R]);g=h.code===0?d?"updated":"added":"failed",h.code!==0&&($=h.stderr.trim().slice(-300))}}catch(r){g="failed",$=`claude CLI not found (${r instanceof Error?r.message:r}); add the server with: claude mcp add -s user ${n} -- npx ${R.join(" ")}`}return{settings:s,rule:t,added:f,backup:x,registered:g,detail:$,statusline:l}}function U(e){return[e.added?`Claude Code: allowed every conform.tools tool (${e.rule}) in ${e.settings}${e.backup?` (backup: ${e.backup})`:""}`:`Claude Code: ${e.rule} was already allowed in ${e.settings}`,{already:"MCP server: already registered",added:"MCP server: registered (claude mcp add -s user); every new session runs the newest version",updated:"MCP server: registered again so every new session runs the newest version (it was set up to keep a cached copy)",skipped:"MCP server: not checked",failed:`MCP server: not registered: ${e.detail??"claude mcp add failed"}`}[e.registered],{installed:"Status line: conform.tools (the running job and its progress) at the bottom of Claude Code",updated:"Status line: conform.tools, refreshed",kept:"Status line: you already have one, so it was left as it is (conformtools statusline prints ours)",skipped:"Status line: not installed"}[e.statusline],"Restart Claude Code (or /mcp) to load it. Remove the rule from permissions.allow to be asked again."].join(`
|
|
5
5
|
`)}var R=["-y","--prefer-online","conformtools@latest","mcp"],L='args = ["-y", "conformtools@latest", "mcp"]',j=e=>`[mcp_servers.${e}]
|
|
6
6
|
command = "npx"
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{l as G,m as V,p as Y,q as B}from"./chunk-
|
|
3
|
+
import{l as G,m as V,p as Y,q as B}from"./chunk-KWJVI7VL.js";import"./chunk-UXVABU6B.js";import"./chunk-3QYAWIID.js";import"./chunk-TBODUVBP.js";import"./chunk-ZL562JIE.js";import"./chunk-SSFG7FNI.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import{Ic as S,Qc as J,Rc as F}from"./chunk-4QGSPWXM.js";import"./chunk-IN6XVTUS.js";import"./chunk-RKJML7MH.js";import"./chunk-3PVQ5QP4.js";import"./chunk-VFXMP7IF.js";import"./chunk-2XB3P2Q5.js";import{a as D}from"./chunk-KMDKF7EJ.js";import"./chunk-TNCXZIOX.js";import"./chunk-5JIFRR7U.js";import"./chunk-WRDA44QF.js";import"./chunk-PGJMKUUP.js";import"./chunk-6QB4DV22.js";import"./chunk-OSUIS4JU.js";import"./chunk-JV7TZDKJ.js";import"./chunk-BBCQMZQN.js";import"./chunk-ASFUV3PB.js";import"./chunk-GDPYFRSV.js";import"./chunk-FHCRWOI7.js";import"./chunk-ZTXOFGJY.js";import"./chunk-H3FD5KA2.js";import"./chunk-LMRPCWHV.js";import"./chunk-HHOFGYZ7.js";import"./chunk-N34DQ6MH.js";import{b as L}from"./chunk-NU3X7P4N.js";import"./chunk-7Z65WW4I.js";import{k as H,w as I,x as W}from"./chunk-ZNBXAGOK.js";import"./chunk-VZ3XYHK4.js";import"./chunk-YJREJ2MH.js";import"./chunk-E75BCWXY.js";import{b as O,f as l,g as c}from"./chunk-QQBDHVUU.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var m=process.stdout,C=22,E=20,R=E/2,K=(o,n)=>Math.abs(n)<=Math.min(1-.417*Math.abs(o),2.393*(1-Math.abs(o))),so=(o,n)=>o*o+n*n<=1;function ro(o){let n=.62**-o,u=[];for(let s=0;s<E;s++){let a=[];for(let r=0;r<C;r++){let f=(r+.5)/C*2-1,i=(s+.5)/E*2-1,d=!1;if(K(f,i))for(let x=0;x<6;x++)for(let y of[!1,!0]){let p=.62**x*(y?.77:1)*n,$=.5*Math.max(0,1-p)**2;(y?so:K)(f/p,(i-$)/p)&&(d=!y)}a.push(d)}u.push(a)}return u}var A={C:["\u25E2\u2588\u25E3","\u2588 ","\u2588 ","\u25E5\u2588\u25E4"],O:["\u25E2\u2588\u25E3","\u2588 \u2588","\u2588 \u2588","\u25E5\u2588\u25E4"],N:["\u2588\u25E3 \u2588","\u2588\u2588\u25E3\u2588","\u2588\u25E5\u2588\u2588","\u2588 \u25E5\u2588"],F:["\u2588\u2588\u2588","\u2588\u2584\u2584","\u2588 ","\u2588 "],R:["\u2588\u2588\u25E3","\u2588 \u2588","\u2588\u2588\u25E4","\u2588 \u2588"],M:["\u2588\u25E3\u25E2\u2588","\u2588\u25E5\u25E4\u2588","\u2588 \u2588","\u2588 \u2588"],T:["\u2588\u2588\u2588"," \u2588 "," \u2588 "," \u2588 "],L:["\u2588 ","\u2588 ","\u2588 ","\u2588\u2588\u2588"],S:["\u25E2\u2588\u25E3","\u25E5\u25E3 "," \u25E5\u25E3","\u25E5\u2588\u25E4"],".":[" "," "," ","\u25CF"]},q="CONFORM.TOOLS",io=[...q].reduce((o,n)=>o+A[n][0].length+1,-1);async function z(o){if(!m.isTTY)return!1;let n=!!O("NO_COLOR"),u=/truecolor|24bit/i.test(O("COLORTERM")??""),s=t=>e=>n?e:`\x1B[${t}m${e}\x1B[0m`,a=s(u?"38;2;255;60;0":"38;5;202"),r=s(u?"38;2;255;222;0":"38;5;220"),f=s("1"),i=s("2"),d=(m.columns??80)>=C+4+io,x=t=>[...q].map(e=>e==="."?a(A[e][t]):f(A[e][t])).join(" "),y=(t,e)=>d&&t>=2&&t<=5?x(t-2):!d&&t===3?`${f("conform")}${a(".")}${f("tools")}`:t===7?e:"",p=(t,e,T=[])=>{let k=ro(t),P=[];for(let w=0;w<R;w++){let to=k[2*w].map((_,eo)=>{let N=k[2*w+1][eo];return _&&N?"\u2588":_?"\u2580":N?"\u2584":" "}).join(""),no=w>=8?T[w-8]??"":"";P.push(` ${a(to)} ${no||y(w,e)}\x1B[K`)}return P.join(`
|
|
4
4
|
`)+`
|
|
5
5
|
`},$=null;o.account.then(t=>{$=t});let j=t=>L(t,24),Z=!O("CI")&&O("TERM")!=="dumb";if(m.write(`
|
|
6
6
|
`),Z){let t=()=>m.write("\x1B[?25h");process.once("SIGINT",()=>{t(),process.exit(130)}),m.write("\x1B[?25l"+p(0,r(`\u25B6 ${j(0)}`)));let e=Date.now(),T=0;for(;$===null||Date.now()-e<900;)await new Promise(k=>setTimeout(k,1e3/24)),T=Math.round((Date.now()-e)*24/1e3),m.write(`\x1B[${R}A\r`+p(T/22%1,`${r(`\u25B6 ${j(T)}`)} ${i("checking your account\u2026")}`));m.write(`\x1B[${R}A\r`),t()}let oo=($??await o.account).split(`
|
|
7
7
|
`);return m.write(p(0,`${i("v")}${o.version} ${i("\xB7 built by post pros")}`,oo.map(t=>i(t)))),m.write(`
|
|
8
|
-
`),!0}var U=()=>z({version:D,account:Promise.race([I().catch(()=>null),new Promise(o=>setTimeout(o,1500,null))]).then(o=>o?W(o):"account: no answer (offline?)")}),co={login:"account_login",logout:"account_logout",whoami:"account_status",status:"account_status",telemetry:"account_telemetry"};l()[0]==="mcp"&&(await import("./mcp.js"),await new Promise(()=>{}));l()[0]==="http"&&(await import("./http.js"),await new Promise(()=>{}));l()[0]==="statusline"&&((await import("./statusline-GMMCFMOA.js")).main(),c(0));if(l()[0]==="setup"){let o=l()[1];o!=="claude"&&o!=="codex"&&(console.error(`conformtools setup <client>: supported: claude, codex${o?` (not ${o} yet)`:""}`),c(2));let{setupClaude:n,setupText:u,setupCodex:s,codexText:a}=await import("./claude-setup-
|
|
8
|
+
`),!0}var U=()=>z({version:D,account:Promise.race([I().catch(()=>null),new Promise(o=>setTimeout(o,1500,null))]).then(o=>o?W(o):"account: no answer (offline?)")}),co={login:"account_login",logout:"account_logout",whoami:"account_status",status:"account_status",telemetry:"account_telemetry"};l()[0]==="mcp"&&(await import("./mcp.js"),await new Promise(()=>{}));l()[0]==="http"&&(await import("./http.js"),await new Promise(()=>{}));l()[0]==="statusline"&&((await import("./statusline-GMMCFMOA.js")).main(),c(0));if(l()[0]==="setup"){let o=l()[1];o!=="claude"&&o!=="codex"&&(console.error(`conformtools setup <client>: supported: claude, codex${o?` (not ${o} yet)`:""}`),c(2));let{setupClaude:n,setupText:u,setupCodex:s,codexText:a}=await import("./claude-setup-FYWGYBTH.js"),{installAgentHook:r,hooksText:f}=await import("./agent-hook-setup-KBCGZNEE.js");try{console.log(o==="codex"?a(await s()):u(await n())),await S()&&console.log(f([await r(o)])),c(0)}catch(i){console.error(i instanceof Error?i.message:String(i)),c(1)}}if(l()[0]==="hooks"){let{installAllAgentHooks:o,removeAllAgentHooks:n,hooksText:u,hooksRemovedText:s,hooksStatusText:a}=await import("./agent-hook-setup-KBCGZNEE.js"),r=l()[1]??"status";r==="on"?console.log(await S()?u(await o()):"outcome telemetry is off, so the agent hook stays off: conformtools telemetry on first"):r==="off"?console.log(s(await n())):r==="status"?console.log(await a()):(console.error("conformtools hooks on|off|status"),c(2)),c(0)}F("cli");var Q=l().includes("--json"),[g,v]=l().filter(o=>o!=="--json");if(!g||g==="--list"||g==="help"||g==="--help"){await U(),console.log(`conformtools <verb> '<json args>' [--json]
|
|
9
9
|
|
|
10
10
|
login / whoami / logout sign in with your conform.tools Google account
|
|
11
11
|
telemetry on|off|status outcome telemetry (on by default, content-free; see the README, Feedback and privacy)
|