@bud.sh/app 0.2.0 → 0.3.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.
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workspace-9KxFcfyV.js","assets/jsx-B4XNFIzB.js","assets/on-mixin-iWnqUzq5.js","assets/component-DWct-Tq6.js","assets/children-N0l0v7XI.js","assets/run-B2H4brp5.js","assets/frame-D6XmK4Df.js","assets/attrs-mixin-CmlG_FtV.js","assets/create-element--E6NJ0nh.js","assets/preload-helper-BLdHbfdN.js","assets/loader-Q6-HPKft.js","assets/task-design-bktfn_Ok.js","assets/lru-BkhKJhvt.js","assets/method-DybmO5PB.js","assets/project-threads-DezXiVK6.js","assets/cloneFileDiffMetadata-CWfw01dG.js","assets/project-work-CB1JHqGW.js","assets/tasks-request-mWMk9pBo.js","assets/workspace-tab-Bg2MFdMB.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./run-B2H4brp5.js";import{t}from"./preload-helper-BLdHbfdN.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function n(e=document,t){let n=!1,r=e.defaultView?.HTMLElement??HTMLElement,i={capture:!0,signal:t};e.addEventListener(`keydown`,e=>{!e.metaKey&&!e.ctrlKey&&!e.altKey&&(n=!0)},i),e.addEventListener(`pointerdown`,()=>{n=!1,e.activeElement?.removeAttribute(`data-focus-method`)},i),e.addEventListener(`focusin`,e=>{n&&e.target instanceof r&&(e.target.dataset.focusMethod=`keyboard`)},i),e.addEventListener(`focusout`,e=>{e.target instanceof r&&delete e.target.dataset.focusMethod},i)}n();var r=e({async loadModule(e,n){if(e===`bud:workspace`&&n===`Workspace`){let{Workspace:e}=await t(async()=>{let{Workspace:e}=await import(`./workspace-9KxFcfyV.js`);return{Workspace:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]));return e}throw Error(`Unknown client entry: ${e}#${n}`)}});r.addEventListener(`error`,e=>{console.error(`Remix component error:`,e.error)}),await r.ready();
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workspace-CznMN7F6.js","assets/jsx-B4XNFIzB.js","assets/on-mixin-iWnqUzq5.js","assets/component-DWct-Tq6.js","assets/children-N0l0v7XI.js","assets/run-B2H4brp5.js","assets/frame-D6XmK4Df.js","assets/attrs-mixin-CmlG_FtV.js","assets/create-element--E6NJ0nh.js","assets/preload-helper-BLdHbfdN.js","assets/loader-Q6-HPKft.js","assets/task-design-bktfn_Ok.js","assets/lru-BkhKJhvt.js","assets/method-DybmO5PB.js","assets/project-threads-DezXiVK6.js","assets/cloneFileDiffMetadata-CWfw01dG.js","assets/project-work-CB1JHqGW.js","assets/tasks-request-mWMk9pBo.js","assets/workspace-tab-Bg2MFdMB.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./run-B2H4brp5.js";import{t}from"./preload-helper-BLdHbfdN.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function n(e=document,t){let n=!1,r=e.defaultView?.HTMLElement??HTMLElement,i={capture:!0,signal:t};e.addEventListener(`keydown`,e=>{!e.metaKey&&!e.ctrlKey&&!e.altKey&&(n=!0)},i),e.addEventListener(`pointerdown`,()=>{n=!1,e.activeElement?.removeAttribute(`data-focus-method`)},i),e.addEventListener(`focusin`,e=>{n&&e.target instanceof r&&(e.target.dataset.focusMethod=`keyboard`)},i),e.addEventListener(`focusout`,e=>{e.target instanceof r&&delete e.target.dataset.focusMethod},i)}n();var r=e({async loadModule(e,n){if(e===`bud:workspace`&&n===`Workspace`){let{Workspace:e}=await t(async()=>{let{Workspace:e}=await import(`./workspace-CznMN7F6.js`);return{Workspace:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]));return e}throw Error(`Unknown client entry: ${e}#${n}`)}});r.addEventListener(`error`,e=>{console.error(`Remix component error:`,e.error)}),await r.ready();
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pages-BVrTX_Eq.js","assets/jsx-B4XNFIzB.js","assets/component-DWct-Tq6.js","assets/on-mixin-iWnqUzq5.js","assets/children-N0l0v7XI.js","assets/attrs-mixin-CmlG_FtV.js","assets/create-element--E6NJ0nh.js","assets/loader-Q6-HPKft.js","assets/screen-Dfvzj6n2.js","assets/task-design-bktfn_Ok.js","assets/lru-BkhKJhvt.js","assets/method-DybmO5PB.js","assets/project-threads-DezXiVK6.js","assets/frame-D6XmK4Df.js","assets/preload-helper-BLdHbfdN.js","assets/cloneFileDiffMetadata-CWfw01dG.js","assets/project-comments-D897aU5O.js","assets/workspace-tab-Bg2MFdMB.js","assets/project-branches-DpxQx-T4.js","assets/canvas-DxaIItAs.js","assets/project-thread-links-Bp_TseD0.js","assets/tasks-request-mWMk9pBo.js","assets/tasks-Cqfj4fQN.js","assets/project-work-CB1JHqGW.js","assets/files-C-7xoSt4.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./jsx-B4XNFIzB.js";import{n as t}from"./on-mixin-iWnqUzq5.js";import{n}from"./run-B2H4brp5.js";import{n as r}from"./attrs-mixin-CmlG_FtV.js";import{t as i}from"./preload-helper-BLdHbfdN.js";import{c as a,i as o,l as s,o as c,r as l,t as ee}from"./loader-Q6-HPKft.js";import{Et as u,Fn as d,Gn as f,Hn as p,In as m,Kn as h,Ln as g,Mn as _,Nn as v,Ot as y,Pn as b,Q as x,Un as S,Vn as C,jn as w,yt as T}from"./task-design-bktfn_Ok.js";import{$ as te,At as ne,Dt as re,J as E,Ot as D,Q as O,X as ie,Y as ae,Z as oe,b as k,dt as A,et as j,jt as se,kt as ce,nt as le,ot as M,rt as ue,t as N,tt as de,v as P,y as fe}from"./project-threads-DezXiVK6.js";import{d as pe}from"./method-DybmO5PB.js";import{t as me}from"./project-work-CB1JHqGW.js";import{n as he}from"./workspace-tab-Bg2MFdMB.js";function ge(t){let n=`connecting`,i=r((e,r)=>{let{project:i}=t.props;me(i),N(i);let a=fe(i.token);n=a.status;let o=a.watchStatus(e=>{n=e,t.update()});r.addEventListener(`abort`,o,{once:!0}),t.update()});return()=>e(`span`,{class:`contents`,mix:i,children:e(D,{status:n})})}var _e=new WeakMap;function F(e,t){let n=f(e,t,{abortEarly:!0});if(n.success)return n.value;let r=n.issues[0];throw _e.get(r)??Error(r.message)}function I(e,t){return b((n,r)=>{let i=e[`~run`](n,r);return i.issues?g(t,r.path):i})}function L(e,t){return b((n,r)=>{let i=e[`~run`](n,r);if(i.issues)return i;let a=t(i.value);return a===void 0?i:g(a,r.path)})}function R(e,t){return b((n,r)=>{let i=e[`~run`](n,r);if(i.issues)return i;try{return{value:t(i.value)}}catch(e){if(!(e instanceof Error))throw e;let t=g(e.message,r.path);return _e.set(t.issues[0],e),t}})}function ve(e){return b((t,n)=>e(t)[`~run`](t,n))}function z(e,t){return b((n,r)=>n==null?{value:t()}:e[`~run`](n,r))}function B(e,t){let n=p(t);return b((r,i)=>{if(!r||typeof r!=`object`||Array.isArray(r))return g(`${e} must be an object.`,i.path);for(let n of Object.keys(r))if(!Object.hasOwn(t,n))return g(`${e}.${n} is not a supported setting.`,[...i.path,n]);return n[`~run`](r,i)})}function ye(e,t,n=0){let r=_(e);return b((e,i)=>!Array.isArray(e)||e.length<n?g(t,i.path):r[`~run`](e,i))}var be=d(B(`files`,{edit:z(I(v(),`files.edit must be true or false.`),()=>!0)}),()=>({edit:!0})),V=`flows must be [{ id, title, start, script, steps: [{ id, title }], block? }] with short ids, local paths and unique steps.`,xe=e=>typeof e==`string`&&/^[a-z0-9][a-z0-9-]{0,62}$/.test(e),H=e=>typeof e==`string`&&e.trim()!==``&&e.length<=200;function Se(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let{id:t,title:n,start:r,script:i,steps:a,block:o=[]}=e;if(!xe(t)||!H(n)||!H(i)||i.includes(`\0`)||typeof r!=`string`||!r.startsWith(`/`)||r.startsWith(`//`)||new URL(r,`http://bud.invalid`).origin!==`http://bud.invalid`||!Array.isArray(a)||!a.length||a.length>50)return null;let s=a.map(e=>{let{id:t,title:n}=e??{};return xe(t)&&H(n)?{id:t,title:n.trim()}:null});if(s.some(e=>!e))return null;let c=s.map(e=>e.id);return new Set(c).size!==c.length||!Array.isArray(o)||o.some(e=>!H(e))?null:{id:t,title:n.trim(),start:r,script:i.trim(),steps:s,block:o}}var Ce=b((e,t)=>{if(e===void 0)return{value:[]};if(!Array.isArray(e))return g(V,t.path);let n=e.map(Se);if(n.some(e=>!e))return g(V,t.path);let r=n.map(e=>e.id);return new Set(r).size===r.length?{value:n}:g(V,t.path)});function we(e,t){return{id:`${e.id}/${t.id}`,path:`${e.start.replace(/#.*$/,``)}#${e.id}-${t.id}`,title:t.title,group:e.title,flow:{id:e.id,step:t.id}}}var Te=Object.freeze({".svg":`image/svg+xml`,".png":`image/png`,".webp":`image/webp`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".ico":`image/x-icon`}),Ee=`logo must be an image path inside the project (.svg, .png, .webp, .jpg, .gif or .ico), or { light, dark }.`;function De(e){if(typeof e!=`string`||e.length>1024||e.includes(`\0`))return null;let t=e.trim().replaceAll(`\\`,`/`);if(!t||t.startsWith(`/`)||/^[a-z]:/i.test(t)||t.split(`/`).includes(`..`))return null;let n=t.slice(t.lastIndexOf(`.`)).toLowerCase();return Object.hasOwn(Te,n)?t:null}var Oe=b((e,t)=>{if(e===void 0)return{value:null};let n=De(typeof e==`object`&&e?e.light:e),r=typeof e==`object`&&e?e.dark:void 0,i=r===void 0?null:De(r),a=typeof e==`object`&&e?Object.keys(e):[];return n&&(r===void 0||i)&&a.every(e=>e===`light`||e===`dark`)?{value:{light:n,dark:i}}:g(Ee,t.path)}),ke=Object.freeze(`background.shell.main.canvas.panel.board.editor.editor-tabs.foreground.muted.primary.primary-hover.primary-foreground.border.tab-divider.hover.selected.control.control-active.control-selected.card.menu.menu-hover.card-frame.card-surface.card-border.card-frame-border.card-badge.overlay-shadow.tooltip.board-control.board-control-hover.board-card.control-elevation.board-elevation.board-card-elevation.card-elevation.board-card-lift.frame-control.modal-elevation.segment-elevation.control-open-elevation.board-segment.scrollbar.focus.scrollbar-hover.tooltip-border.tooltip-shadow`.split(`.`)),U=`theme must be { light, dark }, each mapping Bud's tokens (${ke.slice(0,3).join(`, `)}, …) to CSS colors or shadows.`;function Ae(e){if(typeof e!=`string`)return null;let t=e.trim();return!t||t.length>300||!/^[#a-zA-Z0-9(),.%\s/+-]+$/.test(t)||/url\s*\(/i.test(t)?null:t}function W(e){if(e===void 0)return{};if(!e||typeof e!=`object`||Array.isArray(e))return null;let t={};for(let[n,r]of Object.entries(e)){let e=Ae(r);if(!ke.includes(n)||e===null)return null;t[n]=e}return Object.freeze(t)}var je=b((e,t)=>{if(e===void 0)return{value:{light:{},dark:{}}};if(!e||typeof e!=`object`||Array.isArray(e))return g(U,t.path);let{light:n,dark:r,...i}=e,a={light:W(n),dark:W(r)};return Object.keys(i).length||!a.light||!a.dark?g(U,t.path):{value:{light:a.light,dark:a.dark}}}),G=`branches must be { main?, build?: { install?, build?, serve? } } with a branch name and nonempty shell commands.`;function Me(e){return typeof e==`string`&&e.length<=255&&/^[A-Za-z0-9._/-]+$/.test(e)&&!e.startsWith(`-`)&&!e.startsWith(`/`)&&!e.endsWith(`/`)&&!e.endsWith(`.lock`)&&!e.includes(`..`)&&!e.includes(`//`)?e:null}function K(e){return typeof e==`string`&&e.trim()&&e.length<=4096&&!e.includes(`\0`)?e.trim():null}var Ne=b((e,t)=>{let n={main:null,install:null,build:null,serve:null};if(e===void 0)return{value:n};if(!e||typeof e!=`object`||Array.isArray(e))return g(G,t.path);let r=e,i=r.build??{};if(!i||typeof i!=`object`||Array.isArray(i)||Object.keys(r).some(e=>e!==`main`&&e!==`build`))return g(G,t.path);let a=i;if(Object.keys(a).some(e=>![`install`,`build`,`serve`].includes(e)))return g(G,t.path);let o={main:r.main===void 0?null:Me(r.main),install:a.install===void 0?null:K(a.install),build:a.build===void 0?null:K(a.build),serve:a.serve===void 0?null:K(a.serve)};return r.main!==void 0&&!o.main||[`install`,`build`,`serve`].some(e=>a[e]!==void 0&&!o[e])?g(G,t.path):{value:o}});function q(e,t,n){let r=t?/\.server\.ts$/:/\.(?:ts|tsx|js|jsx)$/;return I(h().refine(e=>e.length<=1024&&e.startsWith(`./`)&&!/[\u0000-\u001f\u007f\\?#%]/.test(e)&&r.test(e)&&(t||!/\.server\.[cm]?[jt]sx?$/.test(e))&&!e.slice(2).split(`/`).some(e=>!e||e===`.`||e===`..`||e===`node_modules`)),n??(t?`${e} must be a built-in adapter or a ./ module ending in .server.ts inside the project.`:`${e} must be bud:beads or a ./ browser module ending in .ts, .tsx, .js or .jsx inside the project.`))}var Pe=m([!1,`bud:beads`,`bud:memory`,`bud:git-comments`]);function Fe(e){let t=q(`storage.${e}`,!0);return d(L(ve(e=>e===!1||e===`bud:beads`||e===`bud:memory`||e===`bud:git-comments`?Pe:t),t=>e===`work`&&t===`bud:git-comments`?`storage.work cannot use bud:git-comments; it only stores threads.`:void 0),`bud:beads`)}var Ie=d(B(`storage`,{work:Fe(`work`),threads:Fe(`threads`)}),()=>({work:`bud:beads`,threads:`bud:beads`})),Le=d(B(`designs`,{tasks:d(ve(e=>e===`bud:beads`?m([`bud:beads`]):q(`designs.tasks`,!1)),`bud:beads`),pages:d(m([`path`,`title`]),`path`)}),()=>({tasks:`bud:beads`,pages:`path`})),Re=new Set([`bud:dom`,`bud:react`,`bud:react-grab`]),ze=q(`picker`,!1,`picker must be bud:dom, bud:react, bud:react-grab or a ./ browser module ending in .ts, .tsx, .js or .jsx inside the project.`),Be=b((e,t)=>{if(e===void 0)return{value:{name:`bud:dom`,module:null}};if(typeof e==`string`&&Re.has(e))return{value:{name:e,module:null}};let n=ze[`~run`](e,t);return n.issues?n:{value:{name:n.value,module:n.value}}}),Ve=`ready must be a CSS selector, { selector } or { expression }.`,J=b((e,t)=>{let n=typeof e==`string`?{selector:e}:e;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=Object.entries(n),[t,r]=e[0]??[];if(e.length===1&&(t===`selector`||t===`expression`)&&typeof r==`string`&&r.trim()&&r.length<=4096)return{value:t===`selector`?{selector:r.trim()}:{expression:r.trim()}}}return g(Ve,t.path)}),He=()=>[`light`,`dark`],Ue=()=>[{id:`desktop`,name:`Desktop`,width:1440,height:900,mobile:!1}],Y=`previews.viewports must list up to 4 { name, width, height?, mobile? } with distinct names, widths from 240 to 3840 and heights from 240 to 4000.`;function We(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,32)}var Ge=b((e,t)=>{if(!Array.isArray(e)||e.length===0||e.length>4)return g(Y,t.path);let n=[];for(let r of e){if(!r||typeof r!=`object`||Array.isArray(r))return g(Y,t.path);let{name:e,width:i,height:a,mobile:o,...s}=r,c=(e,t,n)=>typeof e==`number`&&Number.isInteger(e)&&e>=t&&e<=n;if(Object.keys(s).length||typeof e!=`string`||!e.trim()||e.length>40||!We(e)||!c(i,240,3840)||a!==void 0&&!c(a,240,4e3)||o!==void 0&&typeof o!=`boolean`)return g(Y,t.path);let l=o??i<800;n.push({id:We(e),name:e.trim(),width:i,height:a??(l?Math.round(i*844/390):900),mobile:l})}return new Set(n.map(e=>e.id)).size===n.length?{value:n}:g(Y,t.path)}),Ke=d(B(`previews`,{scale:z(I(C().refine(e=>Number.isInteger(e)&&e>=1&&e<=3),`previews.scale must be 1, 2 or 3.`),()=>2),themes:z(I(_(m([`light`,`dark`])).refine(e=>e.length>0&&new Set(e).size===e.length),`previews.themes must list light, dark or both, once each.`),He),viewports:z(Ge,Ue),ready:z(J,()=>null),readyTimeout:z(I(C().refine(e=>Number.isInteger(e)&&e>=1e3&&e<=6e5),`previews.readyTimeout must be whole milliseconds from 1000 to 600000.`),()=>6e4),css:z(I(h().refine(e=>e.length<=2e4&&!e.includes(`<`)),`previews.css must be CSS text without <, up to 20000 characters.`),()=>``)}),()=>({scale:2,themes:He(),viewports:Ue(),ready:null,readyTimeout:6e4,css:``}));function qe(e,t){let n=[],r=new Set;function i(e,a){if(!e||typeof e!=`object`||Array.isArray(e)||r.has(e))throw Error(`Screen routes must be a Remix route map.`);r.add(e);for(let[r,o]of Object.entries(e)){let e=a?`${a}.${r}`:r;if(!o||typeof o!=`object`)throw Error(`Screen route ${e} must be a Remix route.`);if(!(`pattern`in o)){i(o,e);continue}if(![`GET`,`ANY`].includes(o.method)||typeof o.href!=`function`||typeof o.pattern?.source!=`string`)throw Error(`Screen route ${e} must be a GET route.`);let s=pe.parse(o.pattern.source),c=s.toJSON(),l=`/${c.pathname}`;if(c.protocol||c.hostname||c.port||c.pathname.split(`/`).some(e=>/^\.{1,2}$/.test(decodeURIComponent(e)))||l!==t&&!l.startsWith(`${t}/`)&&!l.startsWith(`${t}(/`))throw Error(`Screen route ${e} must stay under ${t}.`);n.push({name:e,pattern:s.source})}r.delete(e)}if(i(e,``),!n.length)throw Error(`Screen routes must contain at least one route.`);return n}function Je(){return{id:`pages`,label:`Pages`,icon:`browser`,path:`/pages`,module:`bud:pages`}}function Ye(){return{id:`canvas`,label:`Canvas`,icon:`grid`,path:`/canvas`,module:`bud:canvas`}}function Xe(){return{id:`tasks`,label:`Tasks`,icon:`tasks`,path:`/tasks`,module:`bud:tasks`}}function Ze(){return{id:`files`,label:`Files`,icon:`files`,path:`/files`,module:`bud:files`}}var X=[Je(),Ye(),Xe(),Ze()],Z=new Map(X.map(e=>[e.module,e])),Qe=[`/comments`,...X.map(e=>e.path),`/api`,`/health`,`/__bud`,`/assets`,`/app`,`/src`,`/node_modules`,`/agents`,`/brand`,`/fonts`,`/frameworks`,`/licenses`],$e=L(I(w().refine(e=>!!e&&typeof e==`object`),`Each screen must be an object.`),({id:e,label:t,icon:n=`layers`,module:r,path:i})=>{if(typeof e!=`string`||!/^[a-z][a-z0-9-]{0,31}$/.test(e))return`Screen ids are 1-32 lowercase letters, digits and hyphens.`;if(typeof t!=`string`||!t.trim())return`Screen ${e} needs a label.`;if(typeof n!=`string`||!n)return`Screen ${e} needs an icon name.`;if(typeof r!=`string`)return`Screen ${e} needs a module.`;let a=Z.get(r);if(i??=a?.path??`/${e}`,a)return e!==a.id||i!==a.path?`${r} keeps id "${a.id}" and path "${a.path}".`:void 0;if(!/^\.\/[^\0\\]+\.(?:ts|tsx|js|jsx)$/.test(r))return`Screen ${e} must be a ./ module ending in .ts, .tsx, .js or .jsx.`;if(typeof i!=`string`||!/^\/[a-z0-9][a-z0-9-]*$/.test(i))return`Screen ${e} needs one static path segment, such as /${e}.`;if(X.some(t=>t.id===e))return`Screen id "${e}" is reserved for a built-in screen.`;if(Qe.includes(i))return`Bud reserves the path ${i}.`}),et=d(R(I(_(w()).refine(e=>e.length>0),`screens must list at least one screen.`),e=>{let t=new Set,n=new Set;return e.map(e=>{let r=F($e,e),{id:i,label:a,icon:o=`layers`,module:s}=r,c=r.path??Z.get(s)?.path??`/${i}`;if(t.has(i)||n.has(c))throw Error(`Screen ids and paths must be unique.`);return t.add(i),n.add(c),r.routes!==void 0&&qe(r.routes,c),{id:i,label:a,icon:o,path:c,module:s,...r.routes===void 0?{}:{routes:r.routes}}})}),()=>X.map(e=>({...e}))),tt=e=>!!e&&typeof e==`object`;function Q(e,t){let n=p(t);return b((t,r)=>tt(t)?n[`~run`](Array.isArray(t)?{...t}:t,r):g(e,r.path))}var nt=L(Q(`Bud config must export an object.`,{routes:I(_(w()).refine(e=>e.length>0),`bud.config must define at least one route.`),name:S(I(h().refine(e=>!!e.trim()),`name must be a nonempty string.`)),target:S(Q(`target must be an object.`,{origin:w(),port:w()})),comments:S(Q(`comments must be an object.`,{remote:w()})),port:w(),screens:w(),storage:w(),designs:w(),previews:w(),files:w(),logo:w(),theme:w(),picker:w(),branches:w(),flows:w()}),({target:e})=>{if(e?.port===0)return`target.port must be a listening port, not zero.`;if(e?.origin!==void 0&&(typeof e.origin!=`string`||!e.origin.trim()))return`target.origin must be an HTTP(S) origin.`}),rt=L(w().transform(e=>typeof e==`string`?{path:e,title:e===`/`?`Home`:e}:e),e=>{if(!e||typeof e.path!=`string`||!e.path.startsWith(`/`)||e.path.startsWith(`//`))return`Canvas routes must be local paths beginning with a single /.`;if(new URL(e.path,`http://bud.invalid`).origin!==`http://bud.invalid`||e.path.includes(`\\`))return`Canvas routes must stay on the target origin.`;let t=e.id??it(e.path);if(typeof t!=`string`||!t.trim())return`Canvas route IDs and paths must be unique.`;if(typeof e.title!=`string`||!e.title.trim())return`Each route needs a title.`;if(e.pattern!==void 0&&(typeof e.pattern!=`string`||!e.pattern.startsWith(`/`)))return`A route pattern must be a path beginning with /.`;if(e.group!==void 0&&(typeof e.group!=`string`||!e.group.trim()||e.group.length>120))return`A route group must be a short name.`;if(e.ready!==void 0&&e.ready!==!1&&!f(J,e.ready).success)return`A route ready must be false, a CSS selector, { selector } or { expression }.`}).transform(e=>{let t=it(e.path);return{id:e.id??t,path:t,title:e.title,...e.pattern===void 0?{}:{pattern:e.pattern},...e.group===void 0?{}:{group:e.group.trim()},...e.ready===void 0?{}:{ready:e.ready===!1?null:F(J,e.ready)}}});function it(e){let t=new URL(e,`http://bud.invalid`),n=t.searchParams.toString();return`${t.pathname}${n?`?${n}`:``}${t.hash}`}var at=L(ye(rt,`bud.config must define at least one route.`,1),e=>new Set(e.map(e=>e.id)).size!==e.length||new Set(e.map(e=>e.path)).size!==e.length?`Canvas route IDs and paths must be unique.`:void 0),ot=e=>e===void 0||Number.isInteger(e)&&e>=0&&e<=65535,st=e=>typeof e==`string`&&/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(e);R(L(R(L(R(L(R(nt,e=>({...e,routes:F(at,e.routes)})),({port:e,target:t})=>ot(e??0)&&ot(t?.port)?void 0:`Ports must be integers between 0 and 65535.`),({target:e,...t})=>{let n=e?.origin??(e?.port?`http://127.0.0.1:${e.port}`:void 0);return{...t,targetOrigin:n&&ct(n,`target.origin must be an HTTP(S) origin without a path or credentials.`)}}),({comments:e})=>st(e?.remote??`origin`)?void 0:`comments.remote must be a Git remote name.`),e=>{let t=F(Ce,e.flows),n=t.flatMap(e=>e.steps.map(t=>we(e,t))),r=e.routes.findIndex(e=>e.path===`/`)+1;return{...e,flows:t,routes:[...e.routes.slice(0,r),...n,...e.routes.slice(r)]}}),({routes:e})=>new Set(e.map(e=>e.id)).size!==e.length||new Set(e.map(e=>e.path)).size!==e.length?`A flow step must not reuse a route’s id or path.`:void 0),e=>({name:e.name??`Your project`,routes:e.routes,flows:e.flows,port:e.port??0,targetOrigin:e.targetOrigin,remote:e.comments?.remote??`origin`,screens:F(et,e.screens),storage:F(Ie,e.storage),designs:F(Le,e.designs),previews:F(Ke,e.previews),files:F(be,e.files),logo:F(Oe,e.logo),theme:F(je,e.theme),picker:F(Be,e.picker),branches:F(Ne,e.branches)}));function ct(e,t){let n=new URL(e);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password||n.pathname!==`/`||n.search||n.hash)throw Error(t);return n.origin}function $(e,t){let n=T();for(let t of e)n.add(t.pattern,t.name);let r=n.match(t,{baseURL:`http://bud.invalid`});return r?{route:r.data,params:r.params}:null}function lt(e,t){let n=e?$(qe(e,t.path),t.url):{route:null,params:{}};if(!n)throw Error(`No screen route matches ${t.url.pathname}.`);return{...t,...n}}var ut={"bud:pages":()=>i(()=>import(`./pages-BVrTX_Eq.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])),"bud:canvas":()=>i(()=>import(`./canvas-DxaIItAs.js`),__vite__mapDeps([19,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,21])),"bud:tasks":()=>i(()=>import(`./tasks-Cqfj4fQN.js`),__vite__mapDeps([22,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,21,23,20])),"bud:files":()=>i(()=>import(`./files-C-7xoSt4.js`),__vite__mapDeps([24,10,1,5,3,2,4,6,14,7,8,9,11,15,12,13,16,20,21]))};function dt(e){return Object.hasOwn(ut,e)?ut[e]():i(()=>import(e),[])}async function ft(e,t,n=dt){let r=(await n(e)).default;if(typeof r?.render!=`function`)throw Error(`A screen module must export defineScreen({ render }) as its default.`);let i=await r.load?.(lt(r.routes,t));return t.signal.throwIfAborted(),{screen:r,data:i}}async function pt(e,t,n=e=>i(()=>import(e),[])){if(t.throwIfAborted(),!e)return;if(`error`in e)throw Error(e.error);let r=await n(e.url);return t.throwIfAborted(),x(r.default)}function mt(n){let i,u=``;async function d(){let{module:e,project:t,label:r}=n.props;i=void 0,u=``,n.update();let{location:a}=n.props,o={project:t,signal:n.signal,path:a.path,url:new URL(a.href,window.location.origin),active:n.props.active,conversation:a.conversation,route:null,params:{}};try{if(`error`in e)throw Error(e.error);o.taskDesign=await pt(n.props.taskDesign,n.signal),i={...await ft(e.url,o),context:o}}catch(e){if(n.signal.aborted)return;console.error(e),u=e instanceof Error&&e.message?e.message:`Could not open ${r}.`}n.update()}let f=r(()=>{d()});return()=>{let{label:r,module:p,location:m}=n.props,h=i?.context,g=``;if(i&&h)try{if(m.routes&&!$(m.routes,m.href))throw Error(`No screen route matches ${m.href}.`);h=lt(i.screen.routes,{...h,active:n.props.active,conversation:m.conversation,url:new URL(m.href,h.url.origin)})}catch(e){g=e instanceof Error?e.message:`This screen route is invalid.`}return e(`div`,{class:`h-full min-h-0`,mix:f,children:g?e(`div`,{class:`p-3 md:p-4`,children:e(s,{role:`alert`,children:g})}):i&&h?i.screen.render(i.data,h):u?e(`div`,{class:`h-full overflow-y-auto p-3 md:p-4`,children:e(l,{class:`max-w-2xl`,role:`alert`,children:[e(c,{title:`${r} didn't open`,subtitle:u}),e(o,{class:`flex-col items-start gap-3`,children:[e(s,{as:`p`,variant:`ui`,tone:`muted`,children:`Fix the screen and retry. Details are in the browser console.`}),e(a,{mix:t(`click`,()=>{`error`in p||n.props.taskDesign&&`error`in n.props.taskDesign?window.location.reload():d()}),children:`Retry`})]})]})}):e(ee,{label:`Loading ${r}…`})})}}async function ht(e,t,n,r,i=fetch){e=y(e);let a=await P(k.comments.get.href({id:e}),n,r,u,i);if(r.throwIfAborted(),a.id!==e)throw Error(`The comments service returned another discussion.`);let o=M(a),s=t.find(e=>e.module===o.module);if(!s)throw Error(`Enable the screen that owns this discussion to open it.`);if(s.routes&&!$(s.routes,o.href))throw Error(`The discussion location is not available in this screen.`);return{active:s.id,module:{url:s.module},location:{path:s.path,href:o.href,...s.routes?{routes:s.routes}:{},conversation:{id:e,original:o.original}}}}function gt(i){let u=new Map,d=i.props,f=``,p=i.props.conversation,m,h=!!p,g=``,_=!1;function v(){i.signal.aborted||i.update()}async function y(e){if(p!==e)return;m?.abort();let t=new AbortController;m=t;let n=AbortSignal.any([i.signal,t.signal]);h=!0,g=``,v();try{let t=i.props.project;if(!t)throw Error(`Connect a project to open this discussion.`);let r=await ht(e,i.props.conversationTargets??[],t.token,n);!n.aborted&&p===e&&(d=r,b.set(r.active,window.location.pathname))}catch(e){n.aborted||(g=e instanceof Error?e.message:`Could not open this discussion.`)}finally{m===t&&!n.aborted&&(h=!1,v())}}let b=new Map,x,S,C=()=>`bud:tabs:${i.props.project?.id}:v1`,w=()=>`${window.location.pathname}${window.location.search}${window.location.hash}`;function T(e){x=e,se(C(),e);let t=i.props.project;t&&(document.cookie=`${de(t.id)}=${le(e)}; Path=/; Max-Age=31536000; SameSite=Strict`),v()}function D(){if(!x)return;let e=w();S===e?S=void 0:j(E(x))!==e&&T(ue(x,e))}function M(e){let t=j(E(e));T(e),t!==w()&&(S=t,n(t,{history:`replace`,resetScroll:!1}))}function N(e){let{pathname:t}=new URL(e,`http://bud.local`);if(A(e))return{href:e,title:`Discussion`,icon:`message`};let n=i.props.screens.map(e=>({item:e,root:new URL(e.href,`http://bud.local`).pathname})).filter(({root:e})=>e===`/`||t===e||t.startsWith(`${e}/`)).sort((e,t)=>t.root.length-e.root.length)[0],r=n?.item??i.props.screens[0];if(r.id===`pages`&&n&&t.startsWith(`${n.root}/`)){let a=t.slice(n.root.length);return{href:e,title:i.props.project?.routes.find(e=>e.path===a)?.title??a,icon:r.icon}}let a=(n&&n.root!==`/`?t.slice(n.root.length):t).split(`/`).filter(Boolean).at(-1);return{href:e,title:(a&&n?.root!==`/`?decodeURIComponent(a):void 0)??r.label,icon:r.icon}}let P=r((e,t)=>{_=!0,p&&y(p);function r(){let{pathname:e,search:t,hash:n}=window.location,r=`${e}${t}${n}`,i=A(r);if(i)return i!==p&&(p=i,y(i)),d.location.conversation?.id===i&&b.set(d.active,r),!0;let a=u.get(d.active);if(!a)return!1;let o=a.location.path;return e!==o&&(o===`/`||!e.startsWith(`${o}/`))?!1:(m?.abort(),p=void 0,h=!1,g=``,b.set(d.active,r),a.location={...a.location,href:r,conversation:void 0},d={...d,location:a.location},!0)}r(),i.props.project&&T(O(ne(C()),w(),crypto.randomUUID())),i.update(),window.addEventListener(`click`,e=>{if(!x||!(e.metaKey||e.ctrlKey)||e.shiftKey||e.button!==0)return;let t=e.target?.closest?.(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.target||t.hasAttribute(`download`))return;let n=new URL(t.href);n.origin!==window.location.origin||n.pathname.startsWith(`/api/`)||(e.preventDefault(),e.stopPropagation(),T(oe(x,`${n.pathname}${n.search}${n.hash}`,crypto.randomUUID(),!1)))},{capture:!0,signal:t}),window.addEventListener(`popstate`,()=>{!r()&&!window.navigation?.currentEntry?.getState()&&n(window.location.href,{history:`replace`,resetScroll:!1}),window.navigation||D(),i.update()},{signal:t}),window.navigation?.addEventListener(`navigate`,r,{signal:t}),window.navigation?.addEventListener(`currententrychange`,()=>{r(),D(),i.update()},{signal:t}),window.navigation?.addEventListener(`navigatesuccess`,()=>{r(),i.update()},{signal:t})});return()=>{let{screens:r,project:v,taskDesign:C}=i.props,w=JSON.stringify([i.props.active,i.props.location.href,i.props.conversation]);if(f!==w){if(f=w,p=i.props.conversation,m?.abort(),g=``,h=!!p,p){let e=p;_&&i.queueTask(()=>{y(e)})}else d=i.props}let{active:T,module:ne,location:D}=d,O=r.find(e=>e.id===T)??r[0];v&&!h&&!g&&u.set(O.id,{module:ne,location:D,taskDesign:O.id===`tasks`?C:void 0});let A=x??i.props.initialTabs??(v?ie(D.href,`current`):void 0);A&&i.queueTask(()=>he(A.active));let se=r.map(e=>e.id===O.id?e:{...e,href:b.get(e.id)??e.href});return e(ce,{items:se,activeId:O.id,title:O.label,canvas:!!v,logo:v?.logo?{light:k.logo.href({theme:`light`}),dark:v.logo.dark?k.logo.href({theme:`dark`}):void 0,label:v.name}:void 0,status:v?e(ge,{project:v}):void 0,tabs:v&&A?e(re,{tabs:A.tabs.map(e=>({id:e.id,...N(j(e))})),active:A.active,recent:E(A).recent.filter(e=>e!==j(E(A))).map(N),canBack:E(A).index>0,canForward:E(A).index<E(A).entries.length-1,onSelect:e=>M({...A,active:e}),onClose:e=>M(ae(A,e)),onBack:()=>M(te(A,-1)),onForward:()=>M(te(A,1)),onNew:()=>M(oe(A,r[0]?.href??`/`,crypto.randomUUID(),!0)),onOpen:e=>{S=void 0,n(e)}}):void 0,children:v?e(`div`,{class:`h-full min-h-0`,mix:P,children:[h?e(ee,{label:`Opening discussion…`}):g?e(`div`,{class:`p-3 md:p-4`,children:e(l,{class:`max-w-2xl`,role:`alert`,children:[e(c,{title:`Discussion didn't open`,subtitle:g}),e(o,{children:e(a,{mix:t(`click`,()=>{p&&y(p)}),children:`Retry`})})]})}):null,[...u].map(([t,{module:n,taskDesign:i,location:a}])=>e(`div`,{class:`h-full min-h-0`,hidden:h||!!g||t!==O.id,children:e(mt,{label:r.find(e=>e.id===t)?.label??t,module:n,taskDesign:i,project:v,location:a,active:!h&&!g&&t===O.id})},`${t}:${v.token}`))]}):e(l,{class:`max-w-2xl`,children:[e(c,{title:`Your project, side by side.`,subtitle:`Open Bud beside a local project to review its pages, files and tasks.`}),e(o,{children:e(s,{as:`p`,variant:`ui`,children:`Start your project with the Bud Vite plugin, or run Bud from its directory. Its screens appear here when the companion connects.`})})]})})}}export{gt as Workspace};
@@ -33,7 +33,7 @@
33
33
  </script>
34
34
  <!--bud-import-map-->
35
35
  <title>bud.sh</title>
36
- <script data-rmx-preserve-dom type="module" crossorigin src="/assets/index-sj6mWw9-.js"></script>
36
+ <script data-rmx-preserve-dom type="module" crossorigin src="/assets/index-GPPa1XPO.js"></script>
37
37
  <link data-rmx-preserve-dom rel="modulepreload" crossorigin href="/assets/component-DWct-Tq6.js">
38
38
  <link data-rmx-preserve-dom rel="modulepreload" crossorigin href="/assets/jsx-B4XNFIzB.js">
39
39
  <link data-rmx-preserve-dom rel="modulepreload" crossorigin href="/assets/children-N0l0v7XI.js">
@@ -7493,7 +7493,7 @@ var logWithLevel$1 = (level) => (...message) => {
7493
7493
  return void_$2;
7494
7494
  });
7495
7495
  };
7496
- var colors = {
7496
+ var colors$1 = {
7497
7497
  bold: "1",
7498
7498
  red: "31",
7499
7499
  green: "32",
@@ -7505,7 +7505,7 @@ var colors = {
7505
7505
  black: "30",
7506
7506
  bgBrightRed: "101"
7507
7507
  };
7508
- colors.gray, colors.blue, colors.green, colors.yellow, colors.red, colors.bgBrightRed, colors.black;
7508
+ colors$1.gray, colors$1.blue, colors$1.green, colors$1.yellow, colors$1.red, colors$1.bgBrightRed, colors$1.black;
7509
7509
  var defaultDateFormat = (date) => `${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${date.getSeconds().toString().padStart(2, "0")}.${date.getMilliseconds().toString().padStart(3, "0")}`;
7510
7510
  /** @internal */
7511
7511
  var defaultLogger = /*#__PURE__*/ loggerMake(({ cause, date, fiber, logLevel, message }) => {
@@ -36360,6 +36360,113 @@ var BudLogoSchema = createSchema((value, context) => {
36360
36360
  return fail$11(logoMessage, context.path);
36361
36361
  });
36362
36362
  //#endregion
36363
+ //#region ../project/src/lib/theme.ts
36364
+ /**
36365
+ * Bud's colors and shadows a theme may set, as `--bud-<name>` in its styles. Everything else
36366
+ * Bud derives from them.
36367
+ */
36368
+ var THEME_TOKENS = Object.freeze([
36369
+ "background",
36370
+ "shell",
36371
+ "main",
36372
+ "canvas",
36373
+ "panel",
36374
+ "board",
36375
+ "editor",
36376
+ "editor-tabs",
36377
+ "foreground",
36378
+ "muted",
36379
+ "primary",
36380
+ "primary-hover",
36381
+ "primary-foreground",
36382
+ "border",
36383
+ "tab-divider",
36384
+ "hover",
36385
+ "selected",
36386
+ "control",
36387
+ "control-active",
36388
+ "control-selected",
36389
+ "card",
36390
+ "menu",
36391
+ "menu-hover",
36392
+ "card-frame",
36393
+ "card-surface",
36394
+ "card-border",
36395
+ "card-frame-border",
36396
+ "card-badge",
36397
+ "overlay-shadow",
36398
+ "tooltip",
36399
+ "board-control",
36400
+ "board-control-hover",
36401
+ "board-card",
36402
+ "control-elevation",
36403
+ "board-elevation",
36404
+ "board-card-elevation",
36405
+ "card-elevation",
36406
+ "board-card-lift",
36407
+ "frame-control",
36408
+ "modal-elevation",
36409
+ "segment-elevation",
36410
+ "control-open-elevation",
36411
+ "board-segment",
36412
+ "scrollbar",
36413
+ "focus",
36414
+ "scrollbar-hover",
36415
+ "tooltip-border",
36416
+ "tooltip-shadow"
36417
+ ]);
36418
+ var themeMessage = `theme must be { light, dark }, each mapping Bud's tokens (${THEME_TOKENS.slice(0, 3).join(", ")}, …) to CSS colors or shadows.`;
36419
+ function cssValue(value) {
36420
+ if (typeof value !== "string") return null;
36421
+ let trimmed = value.trim();
36422
+ if (!trimmed || trimmed.length > 300) return null;
36423
+ if (!/^[#a-zA-Z0-9(),.%\s/+-]+$/.test(trimmed) || /url\s*\(/i.test(trimmed)) return null;
36424
+ return trimmed;
36425
+ }
36426
+ function colors(value) {
36427
+ if (value === void 0) return {};
36428
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
36429
+ let result = {};
36430
+ for (let [name, raw] of Object.entries(value)) {
36431
+ let checked = cssValue(raw);
36432
+ if (!THEME_TOKENS.includes(name) || checked === null) return null;
36433
+ result[name] = checked;
36434
+ }
36435
+ return Object.freeze(result);
36436
+ }
36437
+ /** A theme in its one resolved form; Bud's own colors when absent. */
36438
+ var BudThemeSchema = createSchema((value, context) => {
36439
+ if (value === void 0) return { value: {
36440
+ light: {},
36441
+ dark: {}
36442
+ } };
36443
+ if (!value || typeof value !== "object" || Array.isArray(value)) return fail$11(themeMessage, context.path);
36444
+ let { light, dark, ...rest } = value;
36445
+ let resolved = {
36446
+ light: colors(light),
36447
+ dark: colors(dark)
36448
+ };
36449
+ if (Object.keys(rest).length || !resolved.light || !resolved.dark) return fail$11(themeMessage, context.path);
36450
+ return { value: {
36451
+ light: resolved.light,
36452
+ dark: resolved.dark
36453
+ } };
36454
+ });
36455
+ /**
36456
+ * The theme as styles that follow Bud's own, so its tokens win in each color scheme.
36457
+ * @param theme - The resolved theme.
36458
+ * @returns A `<style>` element, or an empty string for Bud's own colors.
36459
+ */
36460
+ function themeStyle(theme) {
36461
+ let block = (selector, values) => {
36462
+ let entries = Object.entries(values);
36463
+ if (!entries.length) return "";
36464
+ return `${selector}{${entries.map(([name, value]) => `--bud-${name}:${value};`).join("")}}`;
36465
+ };
36466
+ let css = block(":root:not([data-theme='dark'])", theme.light) + block(":root[data-theme='dark']", theme.dark);
36467
+ return css ? `<style data-bud-theme>${css}</style>` : "";
36468
+ }
36469
+ //#endregion
36363
36470
  //#region ../project/src/lib/branches.ts
36364
36471
  var message = "branches must be { main?, build?: { install?, build?, serve? } } with a branch name and nonempty shell commands.";
36365
36472
  function branch(value) {
@@ -36700,6 +36807,7 @@ var ConfigFields = check(section("Bud config must export an object.", {
36700
36807
  previews: any(),
36701
36808
  files: any(),
36702
36809
  logo: any(),
36810
+ theme: any(),
36703
36811
  picker: any(),
36704
36812
  branches: any(),
36705
36813
  flows: any()
@@ -36775,6 +36883,7 @@ var BudConfigSchema = delegate(check(delegate(check(delegate(check(delegate(Conf
36775
36883
  previews: parseConfig(BudPreviewsSchema, config.previews),
36776
36884
  files: parseConfig(BudFilesSchema, config.files),
36777
36885
  logo: parseConfig(BudLogoSchema, config.logo),
36886
+ theme: parseConfig(BudThemeSchema, config.theme),
36778
36887
  picker: parseConfig(BudPickerSchema, config.picker),
36779
36888
  branches: parseConfig(BudBranchesSchema, config.branches)
36780
36889
  }));
@@ -39300,7 +39409,7 @@ function createAppController(template, project, runtime) {
39300
39409
  let title = (conversation ? "Discussion" : screen.label).replace(/[&<>]/g, (character) => `&#${character.charCodeAt(0)};`);
39301
39410
  let logo = project?.config.logo;
39302
39411
  let shell = logo ? withLogoIcons(template, logo, (theme) => routes.logo.href({ theme })) : template;
39303
- return new Response(shell.replace("<title>bud.sh</title>", () => `<title>${title} · bud.sh</title>`).replace("<!--app-html-->", () => content), { headers: { "Content-Type": "text/html; charset=utf-8" } });
39412
+ return new Response(shell.replace("<title>bud.sh</title>", () => `<title>${title} · bud.sh</title>`).replace("</head>", () => project ? `${themeStyle(project.config.theme)}</head>` : "</head>").replace("<!--app-html-->", () => content), { headers: { "Content-Type": "text/html; charset=utf-8" } });
39304
39413
  }
39305
39414
  return createController(routes, { actions: {
39306
39415
  conversation({ params, request }) {
@@ -202,6 +202,99 @@ var BudLogoSchema = createSchema((value, context) => {
202
202
  return fail(logoMessage, context.path);
203
203
  });
204
204
  //#endregion
205
+ //#region ../project/src/lib/theme.ts
206
+ /**
207
+ * Bud's colors and shadows a theme may set, as `--bud-<name>` in its styles. Everything else
208
+ * Bud derives from them.
209
+ */
210
+ var THEME_TOKENS = Object.freeze([
211
+ "background",
212
+ "shell",
213
+ "main",
214
+ "canvas",
215
+ "panel",
216
+ "board",
217
+ "editor",
218
+ "editor-tabs",
219
+ "foreground",
220
+ "muted",
221
+ "primary",
222
+ "primary-hover",
223
+ "primary-foreground",
224
+ "border",
225
+ "tab-divider",
226
+ "hover",
227
+ "selected",
228
+ "control",
229
+ "control-active",
230
+ "control-selected",
231
+ "card",
232
+ "menu",
233
+ "menu-hover",
234
+ "card-frame",
235
+ "card-surface",
236
+ "card-border",
237
+ "card-frame-border",
238
+ "card-badge",
239
+ "overlay-shadow",
240
+ "tooltip",
241
+ "board-control",
242
+ "board-control-hover",
243
+ "board-card",
244
+ "control-elevation",
245
+ "board-elevation",
246
+ "board-card-elevation",
247
+ "card-elevation",
248
+ "board-card-lift",
249
+ "frame-control",
250
+ "modal-elevation",
251
+ "segment-elevation",
252
+ "control-open-elevation",
253
+ "board-segment",
254
+ "scrollbar",
255
+ "focus",
256
+ "scrollbar-hover",
257
+ "tooltip-border",
258
+ "tooltip-shadow"
259
+ ]);
260
+ var themeMessage = `theme must be { light, dark }, each mapping Bud's tokens (${THEME_TOKENS.slice(0, 3).join(", ")}, …) to CSS colors or shadows.`;
261
+ function cssValue(value) {
262
+ if (typeof value !== "string") return null;
263
+ let trimmed = value.trim();
264
+ if (!trimmed || trimmed.length > 300) return null;
265
+ if (!/^[#a-zA-Z0-9(),.%\s/+-]+$/.test(trimmed) || /url\s*\(/i.test(trimmed)) return null;
266
+ return trimmed;
267
+ }
268
+ function colors(value) {
269
+ if (value === void 0) return {};
270
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
271
+ let result = {};
272
+ for (let [name, raw] of Object.entries(value)) {
273
+ let checked = cssValue(raw);
274
+ if (!THEME_TOKENS.includes(name) || checked === null) return null;
275
+ result[name] = checked;
276
+ }
277
+ return Object.freeze(result);
278
+ }
279
+ /** A theme in its one resolved form; Bud's own colors when absent. */
280
+ var BudThemeSchema = createSchema((value, context) => {
281
+ if (value === void 0) return { value: {
282
+ light: {},
283
+ dark: {}
284
+ } };
285
+ if (!value || typeof value !== "object" || Array.isArray(value)) return fail(themeMessage, context.path);
286
+ let { light, dark, ...rest } = value;
287
+ let resolved = {
288
+ light: colors(light),
289
+ dark: colors(dark)
290
+ };
291
+ if (Object.keys(rest).length || !resolved.light || !resolved.dark) return fail(themeMessage, context.path);
292
+ return { value: {
293
+ light: resolved.light,
294
+ dark: resolved.dark
295
+ } };
296
+ });
297
+ //#endregion
205
298
  //#region ../project/src/lib/branches.ts
206
299
  var message = "branches must be { main?, build?: { install?, build?, serve? } } with a branch name and nonempty shell commands.";
207
300
  function branch(value) {
@@ -550,6 +643,7 @@ var ConfigFields = check(section("Bud config must export an object.", {
550
643
  previews: any(),
551
644
  files: any(),
552
645
  logo: any(),
646
+ theme: any(),
553
647
  picker: any(),
554
648
  branches: any(),
555
649
  flows: any()
@@ -624,6 +718,7 @@ delegate(check(delegate(check(delegate(check(delegate(ConfigFields, (config) =>
624
718
  previews: parseConfig(BudPreviewsSchema, config.previews),
625
719
  files: parseConfig(BudFilesSchema, config.files),
626
720
  logo: parseConfig(BudLogoSchema, config.logo),
721
+ theme: parseConfig(BudThemeSchema, config.theme),
627
722
  picker: parseConfig(BudPickerSchema, config.picker),
628
723
  branches: parseConfig(BudBranchesSchema, config.branches)
629
724
  }));