cascivo 1.8.0 → 1.8.2
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/{app-DDq0Utmj.mjs → app-BhCskK3W.mjs} +3 -3
- package/dist/{app-DDq0Utmj.mjs.map → app-BhCskK3W.mjs.map} +1 -1
- package/dist/{blueprint-eOLGuyAi.mjs → blueprint-B6Z8NrCr.mjs} +2 -2
- package/dist/{blueprint-eOLGuyAi.mjs.map → blueprint-B6Z8NrCr.mjs.map} +1 -1
- package/dist/cmdspec.json +1 -1
- package/dist/{create-BA9GQ8nl.mjs → create-DIaknp48.mjs} +163 -147
- package/dist/create-DIaknp48.mjs.map +1 -0
- package/dist/generated/audit-contract.json +97 -23
- package/dist/index.mjs +31 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/create-BA9GQ8nl.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{t as e}from"./rolldown-runtime-DT7IzrpZ.mjs";import{a as t,l as n,n as r,o as i,r as a,s as o,t as s}from"./config-CTk7uDrh.mjs";import{i as c,n as l,r as u,t as d}from"./fs-B7O-fNID.mjs";import{r as f,t as p}from"./http-B52v4-hw.mjs";import{a as m,c as h,i as g,l as _,n as v,o as y,r as ee,s as b,t as te}from"./lock-C6ILDVCl.mjs";import{n as x,r as S,t as ne}from"./peer-versions-DIPdOfWj.mjs";import{n as
|
|
3
|
-
Styling: cascivo components read --cascivo-* tokens, which this project does not import yet.`),console.log(` ${o(t,[`@cascivo/themes`])}`),console.log(` import '@cascivo/themes/all' // once, in your entry file`),console.log(` <html data-theme="light"> // or any container`))}function
|
|
4
|
-
`));let e;try{e=await
|
|
5
|
-
`)}`)}if(_.size>0&&!r.dryRun&&(r.noInstall?console.log(`\nSkipped install (--no-install). Install with:\n ${o(a,[..._])}`):
|
|
6
|
-
`).some(e=>e.trim().replace(/\/+$/,``)===r))return`"${r}/" is not excluded from your formatter. Running it will rewrite code you own, and \`cascivo update\` will then report drift on files you never edited. Add "${r}/" to ${i}.`}return null}function
|
|
7
|
-
`;)n++;else if(i===`/`&&a===`*`){for(n+=2;n<r&&(e[n]!==`*`||e[n+1]!==`/`);)n++;n+=2}else if(i===`'`||i===`"`){for(n++;n<r&&e[n]!==i;)e[n]===`\\`&&n++,n++;n++,t+=i+i}else if(i==="`"){for(n++;n<r&&e[n]!=="`";)e[n]===`\\`&&n++,n++;n++,t+="``"}else t+=i,n++}return t}async function
|
|
8
|
-
`):``}function
|
|
9
|
-
`)}function
|
|
2
|
+
import{t as e}from"./rolldown-runtime-DT7IzrpZ.mjs";import{a as t,l as n,n as r,o as i,r as a,s as o,t as s}from"./config-CTk7uDrh.mjs";import{i as c,n as l,r as u,t as d}from"./fs-B7O-fNID.mjs";import{r as f,t as p}from"./http-B52v4-hw.mjs";import{a as m,c as h,i as g,l as _,n as v,o as y,r as ee,s as b,t as te}from"./lock-C6ILDVCl.mjs";import{n as x,r as S,t as ne}from"./peer-versions-DIPdOfWj.mjs";import{n as re,r as C,t as w}from"./args-B4PN85cC.mjs";import{t as T}from"./merge-D332dc_m.mjs";import{createRequire as E}from"node:module";import{argv as D,stdin as O,stdout as ie}from"node:process";import{pathToFileURL as ae}from"node:url";import{existsSync as k,readFileSync as A,readdirSync as oe,writeFileSync as j}from"node:fs";import{basename as se,dirname as ce,join as M,resolve as N}from"node:path";import{spawnSync as le}from"node:child_process";import{readFile as ue}from"node:fs/promises";import{asTemplateMeta as de,buildRegistry as fe,isTemplateItem as P,parseItem as F,parseLegacyRegistry as pe,validateIndex as me,validateItem as he,validateTemplate as ge}from"@cascivo/registry";import{createInterface as I}from"node:readline/promises";function L(e,n=process.cwd(),r={}){if(e.length===0)return!0;let a=r.pm??t(n),[s,c]=i(a,e,{dev:r.dev??!1,...r.floors?{floors:r.floors}:{},...r.pin?{pin:r.pin}:{}});return console.log(`Installing ${e.join(`, `)} with ${s}…`),le(s,c,{cwd:n,stdio:`inherit`,shell:process.platform===`win32`}).status===0||(console.error(`Failed to install: ${e.join(`, `)}`),console.error(`Install them yourself with: ${o(a,e,{dev:r.dev??!1})}`),!1)}const _e=/^([^/]+)\/([^/]+)\/([^#]+)(?:#(.+))?$/;function R(e,t=process.env){return e.replace(/\$\{([^}]+)\}/g,(e,n)=>{let r=t[n];if(r===void 0)throw Error(`Environment variable ${n} is not set`);return r})}function ve(e,t=process.env){if(e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`./`)||e.startsWith(`/`))return{kind:`url`,name:e,raw:e};if(e.startsWith(`@`)){let t=e.indexOf(`/`,1);if(t===-1)throw Error(`Invalid namespace address: ${e} (expected @ns/name)`);return{kind:`namespace`,namespace:e.slice(0,t),name:e.slice(t+1),raw:e}}let n=e.includes(`#`)?e.slice(0,e.indexOf(`#`)):e,r=_e.exec(e);if(r&&!n.includes(`.`)&&n.split(`/`).length>=3){let[,t,n,i,a]=r;return{kind:`github`,name:`${t}/${n}/${i}`,ref:a??`main`,raw:e}}return{kind:`bare`,name:e,raw:e}}function ye(e,t,n,r){let i=typeof n==`string`?n:n.url;if(!i.includes(`{name}`))throw Error(`Registry namespace "${e}" URL template must contain {name}: ${i}`);return R(i.replace(`{name}`,t),r)}async function be(e,t,n=process.env,r){switch(e.kind){case`url`:return{url:e.name};case`bare`:return{url:`${t.registry.replace(/\/registry\.json$/,``).replace(/\/r$/,``)}/r/${e.name}.json`};case`github`:{let t=e.name.split(`/`),n=t[0],r=t[1],i=t.slice(2).join(`/`);return{url:`https://raw.githubusercontent.com/${n}/${r}/${e.ref??`main`}/r/${i}.json`}}case`namespace`:{let i=e.namespace,a=e.name;if(t.registries?.[i]){let e=t.registries[i],r=ye(i,a,e,n),o=typeof e==`string`?void 0:e.headers,s=typeof e==`string`?void 0:e.params,c=o?Object.fromEntries(Object.entries(o).map(([e,t])=>[e,R(t,n)])):void 0,l=s?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,R(t,n)])):void 0,u={url:r};return c&&(u.headers=c),l&&(u.params=l),u}if(r){let e=await r(i);if(e)return{url:ye(i,a,e,n)}}if(i===`@cascivo`||i===`@cascade`)return{url:`${s}/r/${a}.json`};throw Error(`Unknown namespace "${i}". Add it to registries in cascivo.config.ts or check the directory at cascivo.com`)}}}async function xe(e,t,n=process.env,r){let i=/* @__PURE__ */ new Set,a=[...e],o=[];for(;a.length>0;){let e=a.shift(),s=ve(e,n),c=s.raw;if(i.has(c))continue;i.add(c);let{url:l,headers:u,params:d}=await be(s,t,n,r),f={};u&&(f.headers=u),d&&(f.params=d);let m=F(await p(l,f),l),h={spec:e,addr:s,itemUrl:l,item:m,registryBase:l.replace(/\/[^/]+\.json$/,``)};u&&(h.headers=u),d&&(h.params=d),o.push(h);for(let e of m.registryDependencies??[])a.push(e)}return{items:o}}const Se=`${s}/r/registries.json`;function Ce(e,t){if(typeof e!=`object`||!e)return null;let n=e.registries;if(!Array.isArray(n))return null;for(let e of n){if(typeof e!=`object`||!e)continue;let n=e;if(n.namespace!==t)continue;let r=n.registryUrl;return typeof r!=`string`||!/^https?:\/\//.test(r)?null:r}return null}async function we(e,t){try{let n;if(t){let e=await t(Se,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);n=await e.json()}else n=await p(Se);return Ce(n,e)}catch(e){let t=e instanceof Error?e.message:String(e);return console.warn(`Could not reach cascivo.com directory: ${t}`),null}}var Te=/* @__PURE__ */ e({LAYOUT_ALIASES:()=>H,NAME_NOTES:()=>U,add:()=>Ae,isThirdParty:()=>Oe,resolveBareClosure:()=>W,resolveTemplateTarget:()=>V});const Ee=/* @__PURE__ */ new Set([`react`,`react-dom`]);function z(e){try{let t=JSON.parse(A(M(e,`package.json`),`utf8`));return{...t.dependencies,...t.devDependencies}}catch{return{}}}function B(e,t){let n=z(e);n[`@cascivo/themes`]===void 0&&n[`@cascivo/tokens`]===void 0&&(console.log(`
|
|
3
|
+
Styling: cascivo components read --cascivo-* tokens, which this project does not import yet.`),console.log(` ${o(t,[`@cascivo/themes`])}`),console.log(` import '@cascivo/themes/all' // once, in your entry file`),console.log(` <html data-theme="light"> // or any container`))}function V(e,t){return d(e,N(e,t))}const H={box:`layout/flex`,hstack:`layout/flex`,vstack:`layout/flex`,gap:`spacer`},U={stack:`Note: cascivo's Stack overlaps children into a card-pile (z-axis), not a vertical spacing layout. For vertical spacing use Flex direction="vertical" (cascivo add flex; aliases: vstack, hstack).`};function W(e,t){let n=t.map(e=>({name:e,requested:!0})),r=/* @__PURE__ */ new Set,i=[],a=[];for(;n.length>0;){let{name:t,requested:o}=n.shift(),s=H[t.toLowerCase()]??t,c=h(e,s);if(!c){a.push(t);continue}if(r.has(c.name))continue;r.add(c.name);let l=_(c,t);i.push({entry:c,requested:o,...l?{viaAlias:l}:{}});for(let e of c.registryDependencies??[])n.push({name:e,requested:!1})}return{resolved:i,missing:a}}const De=/^https:\/\/(cascivo\.com|raw\.githubusercontent\.com\/cascivo\/cascivo)\//;function Oe(e){return!De.test(e)}function ke(e){return e.startsWith(`@`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`./`)||e.startsWith(`/`)||e.split(`/`).length>=3}async function Ae(e,n,r={}){if(e.length===0){console.error(`Usage: cascivo add <component...>`);return}let i=r.cwd??process.cwd(),a=r.pm??t(i),s=e.filter(ke),l=e.filter(e=>!ke(e)),d=null;if(l.length>0){d=await y(n.registry);let e=new Set(d.templates.map(e=>e.toLowerCase())),t=l.filter(t=>e.has(t.toLowerCase()));t.length>0&&(l=l.filter(t=>!e.has(t.toLowerCase())),s.push(...t.map(e=>`@cascivo/${e.toLowerCase()}`)))}let p=await v(i)??te();if(s.length>0){let e=await xe(s,n,process.env,we);if(r.dryRun){console.log(`Dry run — would install:`);for(let t of e.items){let e=P(t.item)?` [template]`:``;console.log(` ${t.spec} (${t.item.name}@${t.item.version})${e} from ${t.itemUrl}`);for(let e of t.item.files){let n=P(t.item)&&e.target?` → ${e.target}`:``;console.log(` ${e.url}${n}`)}t.item.registryDependencies?.length&&console.log(` components: ${t.item.registryDependencies.join(`, `)}`)}return}for(let{item:t,itemUrl:o,registryBase:s}of e.items){Oe(o)&&console.log(`\nReview before use — files from non-directory registry: ${s}\n`+(t.files??[]).map(e=>` ${e.url}`).join(`
|
|
4
|
+
`));let e;try{e=await je(t,n,i,{pm:a,...r.noInstall?{noInstall:!0}:{}})}catch(e){console.error(`Failed to install ${t.name}: ${e instanceof Error?e.message:e}`),process.exitCode=1;continue}p=g(p,t.name,{registry:s,version:t.version,installedAt:(/* @__PURE__ */ new Date()).toISOString().slice(0,10),files:e})}if(await m(p,i),l.length===0){B(i,a);return}}if(l.length===0)return;d??=await y(n.registry);let _=/* @__PURE__ */ new Set,x=n.registry.replace(/\/registry\.json$/,``).replace(/\/r$/,``);for(let e of l){let t=U[e.toLowerCase()];t&&console.log(t);let n=H[e.toLowerCase()];if(!n)continue;let r=h(d,n);r&&console.log(`"${e}" is not a cascivo component — installing ${r.name} (its ${e} primitive).`)}let{resolved:S,missing:re}=W(d,l);for(let e of re)console.error(`Component "${e}" not found in registry. Run "cascivo list".`);for(let{entry:e,requested:t,viaAlias:n}of S)t&&n&&console.log(`\n"${n}" is cascivo's "${e.name}" — installing that.`);let C=/* @__PURE__ */ new Set;for(let{entry:e,requested:t}of S)t&&e.install&&!C.has(e.install)&&(C.add(e.install),console.log(`\n"${e.name}" ships in the ${e.install} npm package — no source is copied into your project. Updates come from your package manager, not \`cascivo update\`.`));for(let{entry:e,requested:t}of S){if(!t||!e.deprecated)continue;let{replacement:n,since:r,note:i}=e.deprecated;console.warn(`\n⚠ "${e.name}" is deprecated since ${r}. Use "${n}" instead:\n cascivo add ${n}\n`+(i?` ${i}\n`:``)+` Adding "${e.name}" anyway — it still works.\n`)}let w={};for(let{entry:e}of S)for(let[t,n]of Object.entries(e.peerVersions??{}))w[t]=n;let T=/* @__PURE__ */ new Set,E=[];for(let{entry:e,requested:t}of S){if(e.install){let t=e.install;T.add(t),console.log(`"${e.name}" is distributed as the npm package ${t} — a runtime dependency, not copied source (updates come via your package manager).`),E.push(` import { ${e.meta.name} } from '${t}'`),e.styles&&E.push(` import '${e.styles}' // once, in your entry file`);continue}let r=e.name.includes(`/`)?e.name.split(`/`).pop():e.name,a={},o;try{o=await Promise.all(e.files.map(async e=>({url:e,content:await f(e)})))}catch(t){console.error(`Failed to install ${e.name}: ${t instanceof Error?t.message:t}`),process.exitCode=1;continue}for(let{url:e,content:t}of o){let o=u(n.outputDir,r,b(e),i);await c(o,t),a[o]=ee(t)}for(let t of e.dependencies)Ee.has(t)||_.add(t);p=g(p,e.name,{registry:x,version:e.version,installedAt:(/* @__PURE__ */ new Date()).toISOString().slice(0,10),files:a});let s=t?``:` (dependency)`;console.log(`Added ${e.name} to ${n.outputDir}/${r}/${s}`)}if(T.size>0){let e=z(i),t=[...T].filter(t=>e[t]===void 0);r.dryRun?console.log(`Dry run — would install npm package(s): ${[...T].join(`, `)}`):t.length>0&&(r.noInstall?console.log(`\nSkipped install (--no-install). Install with:\n ${o(a,t)}`):L(t,i,{pm:a})||(process.exitCode=1)),E.length>0&&console.log(`\nImport it:\n${E.join(`
|
|
5
|
+
`)}`)}if(_.size>0&&!r.dryRun&&(r.noInstall?console.log(`\nSkipped install (--no-install). Install with:\n ${o(a,[..._])}`):L([..._],i,{pm:a})),Object.keys(w).length>0){let e=await ne(i,w);for(let t of e)console.error(`\nWarning: ${t.pkg} ${t.installed?`${t.installed} is`:`is not`} installed, but the copied component source needs ${t.pkg} ${t.required}. Run: ${o(a,[`${t.pkg}@latest`])}`),process.exitCode=1}await m(p,i),B(i,a)}async function je(e,n,r,i={}){let a={},s=/* @__PURE__ */ new Set,l=P(e),d=e.name.includes(`/`)?e.name.split(`/`).pop():e.name,p=await Promise.all((e.files??[]).map(async e=>({file:e,content:await f(e.url)})));for(let{file:e,content:t}of p){let i=l&&e.target?V(r,e.target):u(n.outputDir,d,b(e.url),r);await c(i,t),a[i]=ee(t)}for(let t of e.dependencies??[])Ee.has(t)||s.add(t);if(s.size>0&&(i.noInstall?console.log(`\nSkipped install (--no-install). Install with:\n ${o(i.pm??t(r),[...s])}`):L([...s],r,i.pm?{pm:i.pm}:{})),l){let t=e.files?.filter(e=>e.target).map(e=>e.target)??[];console.log(`Installed template ${e.name} (${t.length} files)`)}else console.log(`Added ${e.name} to ${n.outputDir}/${d}/`);return a}var Me=/* @__PURE__ */ e({checkDuplicateCore:()=>He,checkFormatterIgnore:()=>Ke,checkProjectDependencies:()=>Be,checkSignalsCompat:()=>Ue,checkSsrConfig:()=>Ze,detectInstallPath:()=>G,runDoctor:()=>$e,stripCommentsAndStrings:()=>K});const Ne=[`@cascivo/core`,`@cascivo/tokens`,`@cascivo/themes`,`@preact/signals-react`],Pe=[`@cascivo/react`,`@cascivo/themes`,`@preact/signals-react`],Fe={"@cascivo/core":`AI-RULES.md: never add @cascivo/core to a prebuilt-path app — it is transitive, and everything is re-exported from @cascivo/react`,"@cascivo/tokens":`GETTING-STARTED.md: @cascivo/tokens comes with @cascivo/themes as a direct dependency — never install it by hand`},Ie=[`@cascivo/i18n`,`@cascivo/charts`],Le=[`cascivo.config.ts`,`cascivo.config.js`,`cascivo.config.mjs`];function G(e){let t={},n=!0;try{let n=JSON.parse(A(M(e,`package.json`),`utf8`));t={...n.dependencies,...n.devDependencies}}catch{n=!1}if(!n)return`unknown`;let r=t[`@cascivo/react`]!==void 0,i=Re(e);return r&&i?`hybrid`:r?`prebuilt`:i?`copied`:`unknown`}function Re(e){for(let t of ze(e)){let n=M(e,t);if(k(n))try{if(oe(n).some(e=>e.endsWith(`.tsx`)))return!0}catch{}}return!1}function ze(e){let t=/* @__PURE__ */ new Set([`src/components/ui`]);for(let n of Le){let r=M(e,n);if(k(r))try{let e=/outputDir\s*:\s*['"]([^'"]+)['"]/.exec(A(r,`utf8`))?.[1];e!==void 0&&t.add(e)}catch{}}return[...t]}function Be(e){let n={};try{let t=JSON.parse(A(M(e,`package.json`),`utf8`));n={...t.dependencies,...t.devDependencies}}catch{return[]}let r=G(e);if(r===`unknown`)return[];let i=t(e),a=[],s=r===`prebuilt`?Pe:Ne;for(let e of s)n[e]===void 0&&a.push({package:e,required:!0,hint:`detected ${r} install path — ${o(i,[e])}`});if(r===`prebuilt`)for(let[e,t]of Object.entries(Fe))n[e]!==void 0&&a.push({package:e,required:!0,kind:`forbidden`,hint:t});for(let e of Ie)n[e]===void 0&&a.push({package:e,required:!1,hint:o(i,[e])});return a}const Ve=[`@cascivo/react`,`@cascivo/charts`,`@cascivo/flow`,`@cascivo/editor`];async function He(e){let t=await x(e,`@cascivo/core`),n=[];for(let r of Ve){let i=M(e,`node_modules`,r);if(!k(i))continue;let a=await x(i,`@cascivo/core`);a!==null&&a!==t&&n.push(`${r} → ${a}`)}return n.length===0?null:{root:t,nested:n,hint:`Align the @cascivo/* versions (they are released together — see breaking-changes.json) and reinstall. Two copies of @cascivo/core means two signal registries: writes through one are invisible to components subscribed through the other, with no error.`}}async function Ue(e){let[n,r]=await Promise.all([x(e,`@preact/signals-react`),x(e,`react`)]);if(n===null)return null;let i;try{i=S(n,`3.0.0`)<0}catch{return null}if(!i)return null;let a=t(e),s=o(a,[`@preact/signals-react@^3`]),c=null;if(r!==null){let e=/^(\d+)\./.exec(r.trim());c=e?Number(e[1]):null}return c!==null&&c>=19?{severity:`error`,detail:`@preact/signals-react ${n} cannot run on React ${r} — React 19 removed an internal signals 2.x imports, so it fails at module load. Upgrade to signals-react 3.x.`,hint:s}:{severity:`warning`,detail:`@preact/signals-react ${n} is below the required 3.x floor. It works on React 18 today but breaks the moment you move to React 19; upgrade now.`,hint:s}}const We=[`@tanstack/react-start`,`vite-ssr`,`@remix-run/dev`],Ge=[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`,`vite.config.mts`];function Ke(e,t){let n=[{configs:[`.prettierrc`,`.prettierrc.json`,`.prettierrc.js`,`prettier.config.js`],ignore:`.prettierignore`},{configs:[`.oxfmtrc`,`.oxfmtrc.json`],ignore:`.oxfmtignore`}],r=t.replace(/\/+$/,``);for(let{configs:t,ignore:i}of n){if(!t.some(t=>k(M(e,t))))continue;let n=``;try{n=A(M(e,i),`utf8`)}catch{}if(!n.split(`
|
|
6
|
+
`).some(e=>e.trim().replace(/\/+$/,``)===r))return`"${r}/" is not excluded from your formatter. Running it will rewrite code you own, and \`cascivo update\` will then report drift on files you never edited. Add "${r}/" to ${i}.`}return null}const qe=[`astro.config.mjs`,`astro.config.ts`,`astro.config.js`,`astro.config.mts`];function Je(e){if(/\bresolve\s*\.\s*noExternal\b/.test(e))return!0;for(let t of e.matchAll(/\bresolve\s*:\s*\{/g)){let n=1,r=t.index+t[0].length,i=r;for(;r<e.length&&n>0;){let t=e[r];t===`{`?n++:t===`}`&&n--,r++}if(/\bnoExternal\b/.test(e.slice(i,r)))return!0}return!1}function Ye(e){let t;try{t=JSON.parse(A(M(e,`node_modules/@cascivo/react/package.json`),`utf8`))}catch{return!1}if(typeof t!=`object`||!t||!(`keywords`in t))return!1;let{keywords:n}=t;return Array.isArray(n)&&n.includes(`astro-component`)}function Xe(e,t){let n=G(e);if(n!==`prebuilt`&&n!==`hybrid`)return null;let r=A(M(e,t),`utf8`);if(/@cascivo\/astro/.test(r)||Je(r)||Ye(e))return null;let i=/\bssr\s*:\s*\{[^}]*noExternal/.test(r);return`${t} does not use the @cascivo/astro integration, so cascivo's CSS is externalized in Astro's prerender and islands render unstyled with no error`+(i?` (Astro ignores ssr.noExternal; it reads resolve.noExternal)`:``)+". Run `npx astro add @cascivo/astro`. Recipe: https://cascivo.com/docs/using-with-astro.md"}function Ze(e){let t=qe.find(t=>k(M(e,t)));if(t!==void 0)return Xe(e,t);let n={};try{let t=JSON.parse(A(M(e,`package.json`),`utf8`));n={...t.dependencies,...t.devDependencies}}catch{return null}let r=We.find(e=>n[e]!==void 0);if(r===void 0)return null;for(let t of Ge){let n=M(e,t);if(!k(n))continue;let r=A(n,`utf8`);if(/noExternal/.test(r)&&/@cascivo/.test(r)||/cascivoSsr/.test(r))return null}return`${r} is a Vite SSR framework, but no vite config marks the cascivo packages ssr.noExternal — an unconfigured SSR build crashes with \`Unknown file extension ".css"\`. Add \`ssr: { noExternal: [/^@cascivo\\//] }\` (or the cascivoSsr() plugin from @cascivo/vite-plugin). Recipe: https://cascivo.com/docs/using-with-vite-ssr.md`}const Qe=[`useState`,`useEffect`,`useLayoutEffect`,`useContext`,`useReducer`];function K(e){let t=``,n=0,r=e.length;for(;n<r;){let i=e[n],a=e[n+1];if(i===`/`&&a===`/`)for(;n<r&&e[n]!==`
|
|
7
|
+
`;)n++;else if(i===`/`&&a===`*`){for(n+=2;n<r&&(e[n]!==`*`||e[n+1]!==`/`);)n++;n+=2}else if(i===`'`||i===`"`){for(n++;n<r&&e[n]!==i;)e[n]===`\\`&&n++,n++;n++,t+=i+i}else if(i==="`"){for(n++;n<r&&e[n]!=="`";)e[n]===`\\`&&n++,n++;n++,t+="``"}else t+=i,n++}return t}async function $e(e){let t=[],n=M(e,`packages`,`components`,`src`);if(!k(n))return{violations:[],passed:!0};let r=oe(n,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name),i=M(e,`packages`,`react`,`src`,`index.ts`),a=k(i)?A(i,`utf8`):``;for(let e of r){let r=M(n,e,`${e}.tsx`);if(!k(r))continue;let i=A(r,`utf8`),o=K(i);for(let n of Qe)RegExp(`\\b${n}\\b`).test(o)&&t.push({file:r,rule:`no-react-hooks`,detail:`Banned hook '${n}' in ${e}.tsx`});/aria-label="[A-Z]/.test(i)&&t.push({file:r,rule:`no-hardcoded-strings`,detail:`Hardcoded aria-label in ${e}.tsx — use t(builtin.*)`}),RegExp(`from.*components/src/${e}`).test(a)||t.push({file:r,rule:`missing-react-export`,detail:`${e} not exported from @cascivo/react`})}return{violations:t,passed:t.length===0}}const et={AppFrame:`app-shell`,CardContent:`card`,CardFooter:`card`,CardHeader:`card`,CardTitle:`card`,ListItem:`list`,GridItem:`grid`,RadioCardGroup:`radio-card`};function tt(e){return et[e]??e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}const nt=/^[A-Z][A-Za-z0-9]*$/,rt=/^[A-Za-z_$][\w$]*(?:-[\w$]+)*$/,it=/^[A-Za-z_$][\w$]*$/,at=/^\$(?:data|actions|state|state\.set|state\.toggle)\.[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/,ot=/^[\w-]+(?:\.[\w-]+)*$/;function q(e,t){throw Error(`Invalid ViewConfig at ${e}: ${t}`)}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function st(e,t){J(e)||q(t,`expected an object`);let n={};for(let[r,i]of Object.entries(e))rt.test(r)||q(`${t}.${r}`,`not a valid prop name`),(typeof i!=`string`||!at.test(i))&&q(`${t}.${r}`,`expected a "$data.*", "$actions.*" or "$state.*" reference`),n[r]=i;return n}function ct(e,t){return(typeof e.$t!=`string`||!ot.test(e.$t))&&q(`${t}.$t`,`invalid key`),{$t:e.$t}}function lt(e,t){J(e)||q(t,`expected a component node object`);let{component:n,props:r,bind:i,events:a,children:o}=e;(typeof n!=`string`||!nt.test(n))&&q(`${t}.component`,`expected a PascalCase component name`);let s={component:n};if(r!==void 0){J(r)||q(`${t}.props`,`expected an object`);for(let[e,n]of Object.entries(r))rt.test(e)||q(`${t}.props.${e}`,`not a valid prop name`),J(n)&&`$t`in n&&(r[e]=ct(n,`${t}.props.${e}`));s.props=r}return i!==void 0&&(s.bind=st(i,`${t}.bind`)),a!==void 0&&(s.events=st(a,`${t}.events`)),o!==void 0&&(typeof o==`string`?s.children=o:Array.isArray(o)?s.children=o.map((e,n)=>lt(e,`${t}.children[${n}]`)):J(o)&&`$t`in o?s.children=ct(o,`${t}.children`):q(`${t}.children`,`expected a string, a node array or a { $t } reference`)),s}function ut(e){J(e)||q(`$`,`expected an object`);let{state:t,view:n}=e,r={view:{regions:{}}};if(t!==void 0){J(t)||q(`state`,`expected an object`);let e={};for(let[n,r]of Object.entries(t))it.test(n)||q(`state.${n}`,`not a valid identifier`),r===null||typeof r==`string`||typeof r==`number`||typeof r==`boolean`?e[n]=r:q(`state.${n}`,`expected a string, number, boolean or null`);r.state=e}(!J(n)||!J(n.regions))&&q(`view.regions`,`expected an object`);for(let[e,t]of Object.entries(n.regions))/^[\w-]+$/.test(e)||q(`view.regions.${e}`,`not a valid region name`),Array.isArray(t)||q(`view.regions.${e}`,`expected an array of nodes`),r.view.regions[e]=t.map((t,n)=>lt(t,`view.regions.${e}[${n}]`));return r}function dt(e){return typeof e==`object`&&!!e&&`$t`in e}function ft(e){return typeof e==`string`?`'${e.replace(/'/g,`\\'`)}'`:String(e)}function pt(e){return typeof e==`string`?e.includes(`"`)?`{${JSON.stringify(e)}}`:`"${e}"`:typeof e==`number`||typeof e==`boolean`?`{${e}}`:e===null?`{null}`:dt(e)?`{${JSON.stringify(e.$t)}} {/* i18n: ${e.$t} */}`:`{${JSON.stringify(e)}}`}function mt(e,t,n,r){return e===void 0?``:typeof e==`string`?/[{}<>]/.test(e)?`{${JSON.stringify(e)}}`:e:dt(e)?`{/* i18n: ${e.$t} */}`:Array.isArray(e)?e.map(e=>ht(e,t+` `,n,r)).join(`
|
|
8
|
+
`):``}function ht(e,t,n,r){let i=e.component;r.add(i);let a=[];if(e.props)for(let[t,n]of Object.entries(e.props))a.push(`${t}=${pt(n)}`);if(e.bind)for(let[t,n]of Object.entries(e.bind))n.startsWith(`$state.`)?a.push(`${t}={${n.slice(7)}.value}`):a.push(`${t}={data.${n.replace(/^\$data\./,``)}}`);if(e.events)for(let[t,n]of Object.entries(e.events))if(n.startsWith(`$state.set.`)){let e=n.slice(11);a.push(`${t}={(e) => (${e}.value = coerceValue(e))}`)}else if(n.startsWith(`$state.toggle.`)){let e=n.slice(14);a.push(`${t}={() => (${e}.value = !${e}.value)}`)}else a.push(`${t}={actions.${n.replace(/^\$actions\./,``)}}`);let o=a.length>0?` `+a.join(` `):``,s=e.children===void 0?void 0:mt(e.children,t,[],r);return s!==void 0&&s!==``?`${t}<${i}${o}>\n${t} ${s}\n${t}</${i}>`:`${t}<${i}${o} />`}function gt(e){let t=[],n=[];function r(e){if(e.bind)for(let n of Object.values(e.bind)){if(n.startsWith(`$state.`))continue;let e=n.replace(/^\$data\./,``);t.includes(e)||t.push(e)}if(e.events)for(let t of Object.values(e.events)){if(t.startsWith(`$state.`))continue;let e=t.replace(/^\$actions\./,``);n.includes(e)||n.push(e)}Array.isArray(e.children)&&e.children.forEach(r)}return e.forEach(r),{boundProps:t,actionProps:n}}function _t(e){let t=e=>e.events&&Object.values(e.events).some(e=>e.startsWith(`$state.set.`))?!0:Array.isArray(e.children)?e.children.some(t):!1;return e.some(t)}function vt(e,t){let n=[...e].sort();if(`package`in t)return`import { ${n.join(`, `)} } from '${t.package}'`;let r=/* @__PURE__ */ new Map;for(let e of n){let t=tt(e);r.set(t,[...r.get(t)??[],e])}return[...r].sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>`import { ${n.join(`, `)} } from '${t.dir}/${e}'`).join(`
|
|
9
|
+
`)}function yt(e,t,n){let r=/* @__PURE__ */ new Set,i=Object.values(e.view.regions).flat(),{boundProps:a,actionProps:o}=gt(i),s=Object.entries(e.state??{}),c=s.length>0,l=_t(i),u=Object.entries(e.view.regions).map(([e,t])=>` <div className="region-${e}">\n${t.map(e=>ht(e,` `,[],r)).join(`
|
|
10
10
|
`)}\n </div>`).join(`
|
|
11
11
|
`),d=a.length>0,f=o.length>0,p=[d?`data: {\n${a.map(e=>` ${e.replace(/\./g,`_`)}: unknown // TODO: type your data`).join(`
|
|
12
12
|
`)}\n }`:``,f?`actions: {\n${o.map(e=>` ${e}: (...args: unknown[]) => unknown`).join(`
|
|
@@ -20,10 +20,10 @@ function coerceValue(e: unknown) {
|
|
|
20
20
|
return e
|
|
21
21
|
}
|
|
22
22
|
`:``,_=c?` useSignals()
|
|
23
|
-
`+s.map(([e,t])=>` const ${e} = useSignal(${
|
|
23
|
+
`+s.map(([e,t])=>` const ${e} = useSignal(${ft(t)})`).join(`
|
|
24
24
|
`)+`
|
|
25
25
|
`:``;return`import React from 'react'${h}
|
|
26
|
-
${
|
|
26
|
+
${vt(r,n)}
|
|
27
27
|
${g}
|
|
28
28
|
interface PageProps ${m}
|
|
29
29
|
|
|
@@ -34,7 +34,7 @@ ${u}
|
|
|
34
34
|
</div>
|
|
35
35
|
)
|
|
36
36
|
}
|
|
37
|
-
`}async function
|
|
37
|
+
`}async function bt(e,t){let n=e.find((t,n)=>e[n-1]===`--out`),r=e.find(e=>!e.startsWith(`--`)),i=e.find((t,n)=>e[n-1]===`--components-dir`),a=e.find((t,n)=>e[n-1]===`--from`);if(!r){console.error(`Usage: cascivo generate <config.json> [--out output.tsx] [--components-dir ./src/components/ui | --from @cascivo/react]`),process.exitCode=1;return}if(a&&i){console.error(`Pass --from or --components-dir, not both.`),process.exitCode=1;return}let{readFileSync:o}=await import(`node:fs`),s;try{s=ut(JSON.parse(o(r,`utf-8`)))}catch(e){console.error(`${r}: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}let c=/* @__PURE__ */ new Map,l=a?{package:a}:{dir:i??t.outputDir??`./src/components/ui`},u=yt(s,c,l),d=n??M(ce(r),`${se(r,`.json`)}.tsx`);j(d,u,`utf-8`),console.log(`Generated ${d}`);try{let{spawnSync:e}=await import(`node:child_process`);e(`pnpm`,[`exec`,`vp`,`fmt`,d],{encoding:`utf8`,stdio:`inherit`}).status!==0&&e(`npx`,[`--yes`,`prettier`,`--write`,d],{encoding:`utf8`,stdio:`inherit`}).status!==0&&console.log(`(Note: formatter not found — output may need manual formatting)`)}catch{}}const Y=[`@cascivo/core`,`@cascivo/tokens`,`@cascivo/themes`,`@preact/signals-react`],X=[`cascivo`];async function xt(){let e=I({input:O,output:ie});try{let t=(await e.question(`Theme? (${a.join(`/`)}) [light]: `)).trim().toLowerCase();return a.includes(t)?t:`light`}finally{e.close()}}function St(e){return`import type { CascadeConfig } from 'cascivo'
|
|
38
38
|
|
|
39
39
|
const config: CascadeConfig = {
|
|
40
40
|
registry: '${r.registry}',
|
|
@@ -43,25 +43,26 @@ const config: CascadeConfig = {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export default config
|
|
46
|
-
`}const
|
|
47
|
-
ESLint: copied cascivo source may trip a strict host config on stylistic rules.`),console.log(` Scope them off your components dir — see docs/USING-WITH-STRICT-ESLINT.md`))}function
|
|
46
|
+
`}const Ct=[`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`.eslintrc`,`.eslintrc.js`,`.eslintrc.cjs`,`.eslintrc.json`,`.eslintrc.yml`,`.eslintrc.yaml`];function wt(e){Ct.some(t=>k(M(e,t)))&&(console.log(`
|
|
47
|
+
ESLint: copied cascivo source may trip a strict host config on stylistic rules.`),console.log(` Scope them off your components dir — see docs/USING-WITH-STRICT-ESLINT.md`))}function Tt(e,t,n){let r=M(e,`package.json`);if(!k(r))return[];let i;try{i=JSON.parse(A(r,`utf8`))}catch{return[]}let a=n.dev?`devDependencies`:`dependencies`,o=i[a]??={},s=[];for(let e of t)o[e]===void 0&&(o[e]=`latest`,s.push(e));return s.length===0?[]:(j(r,`${JSON.stringify(i,null,2)}\n`,`utf8`),s)}const Et=[{config:[`.prettierrc`,`.prettierrc.json`,`.prettierrc.js`,`prettier.config.js`],ignore:`.prettierignore`},{config:[`.oxfmtrc`,`.oxfmtrc.json`],ignore:`.oxfmtignore`}];function Dt(e,t){let n=`${t.replace(/\/+$/,``)}/`;for(let{config:t,ignore:r}of Et){if(!(t.some(t=>k(M(e,t)))||Ot(e,r)))continue;let i=M(e,r),a=k(i)?A(i,`utf8`):``;if(a.split(`
|
|
48
48
|
`).some(e=>e.trim()===n))continue;let o=`# cascivo: vendored component source — you own it, so do not reformat it
|
|
49
49
|
`,s=a===``?o+n+`
|
|
50
50
|
`:`${a.replace(/\n*$/,`
|
|
51
|
-
`)}\n${o}${n}\n`;
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
`)}\n${o}${n}\n`;j(i,s,`utf8`),console.log(`\nAdded "${n}" to ${r} (so your formatter does not rewrite copied source).`)}}function Ot(e,t){if(t!==`.prettierignore`)return!1;let n=M(e,`package.json`);if(!k(n))return!1;try{return`prettier`in JSON.parse(A(n,`utf8`))}catch{return!1}}const kt=[`astro.config.mjs`,`astro.config.ts`,`astro.config.js`,`astro.config.mts`];function At(e){kt.some(t=>k(M(e,t)))&&(console.log(`
|
|
52
|
+
Astro detected. Next steps:`),console.log(` npx astro add @cascivo/astro # layer order, theme and no-flash script, zero config`),console.log(` Compose compound components (Tabs, Accordion, Popover…) inside one .tsx island:`),console.log(` Astro renders each .astro child separately, so React context cannot reach their parts.`),console.log(` Hydrate only the interactive islands: client:visible or client:load on those,`),console.log(` and leave static pieces without a client: directive.`))}function jt(){console.log(`
|
|
53
|
+
Dependencies`),console.log(` runtime: ${Y.join(` `)}`),console.log(` dev: ${X.join(` `)} (types for cascivo.config.ts)`),console.log(" on demand: @cascivo/i18n, @cascivo/charts — added by `cascivo add` when a component or chart needs them")}async function Mt(e=[],n=process.cwd()){let i=e.includes(`--yes`)||e.includes(`-y`),s=e.includes(`--no-install`),l=w(e,`theme`)?.toLowerCase();if(l!==void 0&&!a.includes(l)){console.error(`Unknown theme "${l}". Available: ${a.join(`, `)}`),process.exitCode=1;return}let u=C(e);if(`error`in u){console.error(u.error),process.exitCode=1;return}let d=t(n,u.pm?{override:u.pm}:{}),f=l===void 0&&!i&&O.isTTY,p=l??(f?await xt():`light`),m=M(n,`cascivo.config.ts`);if(await c(m,St(p)),console.log(`\nCreated cascivo.config.ts (theme: ${p})`),s)console.log(`
|
|
54
|
+
Skipped install (--no-install). Install the dependencies yourself:`),console.log(` ${o(d,Y)}`),console.log(` ${o(d,X,{dev:!0})}`);else{let e=L(Y,n,{pm:d}),t=L(X,n,{pm:d,dev:!0});if(!e||!t){let r=[...e?[]:Tt(n,Y,{dev:!1}),...t?[]:Tt(n,X,{dev:!0})];console.error(`
|
|
54
55
|
Install failed — cascivo.config.ts was written but the packages are not installed.`),r.length>0?(console.error(`Wrote ${r.length} dependency entries to package.json: ${r.join(`, `)}`),console.error(`Recover with:\n ${d} install`)):console.error(`Recover with:\n ${o(d,Y)}\n ${o(d,X,{dev:!0})}`),process.exitCode=1}}console.log(`
|
|
55
56
|
Stylesheets — import these once, in this order, in your entry file:`),console.log(` import '@cascivo/tokens' // primitive tokens — every --cascivo-* value`),console.log(` import '@cascivo/themes/${p}.css'${` `.repeat(Math.max(1,16-p.length))}// the ${p} theme's semantic values`),console.log(" // …then your component CSS (`cascivo add` writes .module.css beside each component)"),console.log(`
|
|
56
57
|
Then set the theme on your root element:`),console.log(` <html data-theme="${p}">`),console.log(`
|
|
57
58
|
Switching themes at runtime? Use a bundle instead of the single theme:`),console.log(` import '@cascivo/themes/light-dark.css' // light + dark — the common case`),console.log(` import '@cascivo/themes/all.css' // all twelve themes`),console.log(` import { ThemeProvider } from '@cascivo/core'`),console.log(`
|
|
58
59
|
In YOUR components, when you read a signal during render:`),console.log(` import { useSignals } from '@cascivo/core'`),console.log(` function MyComponent() {`),console.log(` useSignals() // ← first statement, or the component never re-renders`),console.log(` return <span>{count.value}</span>`),console.log(` }`),console.log(`
|
|
59
|
-
Adding a chart later? Charts ship as an npm package with their own stylesheet:`),console.log(" import '@cascivo/charts/styles.css' // `cascivo add <chart>` reminds you"),
|
|
60
|
+
Adding a chart later? Charts ship as an npm package with their own stylesheet:`),console.log(" import '@cascivo/charts/styles.css' // `cascivo add <chart>` reminds you"),jt(),Dt(n,r.outputDir),wt(n),At(n),console.log(`
|
|
60
61
|
Packages version independently (changesets), so a low number means fewer`),console.log(`releases, not less finished. Pin exact versions, and before upgrading run:`),console.log(` cascivo doctor --drift # reads breaking-changes.json, reports API drift`),console.log(`
|
|
61
|
-
Add components with: cascivo add <name>`)}const
|
|
62
|
-
`)}function
|
|
62
|
+
Add components with: cascivo add <name>`)}const Nt={component:`Components`,layout:`Layouts (copy-paste)`,block:`Blocks (copy-paste)`,section:`Sections (copy-paste)`,chart:`Charts (npm: @cascivo/charts)`,flow:`Flow (npm: @cascivo/flow)`,editor:`Editor (npm: @cascivo/editor)`};function Pt(e){return e.deprecated?` ⚠ deprecated → ${e.deprecated.replacement}`:``}function Ft(e){let t=e.map(e=>[e.name,e.category,e.description+Pt(e)]),n=[`Name`,`Category`,`Description`],r=n.map((e,n)=>Math.max(e.length,...t.map(e=>(e[n]??``).length))),i=e=>e.map((e,t)=>e.padEnd(r[t]??e.length)).join(` `).trimEnd(),a=r.map(e=>`-`.repeat(e)).join(` `);return[i(n),a,...t.map(i)].join(`
|
|
63
|
+
`)}function It(e){if(e.length===0)return`No components found.`;if(!e.some(e=>e.type!==void 0))return Ft(e);let t=/* @__PURE__ */ new Map;for(let n of e){let e=n.type??`component`;t.has(e)||t.set(e,[]),t.get(e).push(n)}let n=[];for(let[e,r]of t){let t=Nt[e]??e;n.push(`${t}\n${Ft(r)}`)}return n.join(`
|
|
63
64
|
|
|
64
|
-
`)}async function
|
|
65
|
+
`)}async function Lt(e,t={}){let n=(await y(e.registry)).components;t.installed&&(n=n.filter(t=>{let n=t.name.includes(`/`)?t.name.split(`/`).pop():t.name;return k(M(process.cwd(),e.outputDir,n))})),console.log(It(n)),console.log("\nTip: install any entry by its bare name — `cascivo add flex` resolves to `layout/flex`. Layout primitives (Flex, Grid, AutoGrid, Columns, Spacer, Center) replace inline-style layout; see docs/cookbooks/layout-and-spacing.md.")}function Rt(e){let t=[],n=[],r=new Set(e.items.map(e=>e.name));for(let i of e.items)if(P(i)){for(let e of ge(i))t.push(`template "${i.name}": ${e}`);for(let e of i.registryDependencies??[])!(e.includes(`/`)||e.startsWith(`@`)||e.startsWith(`http`))&&!r.has(e)&&n.push(`template "${i.name}": component "${e}" is not in this index — it must resolve from another registry at install time`)}return{errors:t,warnings:n}}async function zt(e){let t=`cascade-registry.json`,n=`public/r`;for(let r=0;r<e.length;r++)e[r]===`--in`&&e[r+1]?(t=e[r+1],r++):e[r]===`--out`&&e[r+1]&&(n=e[r+1],r++);let r=N(t);if(!k(r)){console.error(`cascade registry build: file not found: ${r}`),process.exitCode=1;return}let i=JSON.parse(await ue(r,`utf8`));ce(r);let a=typeof i==`object`&&i&&i.schemaVersion===2?i:pe(i),o=me(a);if(o.warnings.length>0)for(let e of o.warnings)console.warn(`warn: ${e}`);if(!o.ok){for(let e of o.errors)console.error(`error: ${e}`);process.exitCode=1;return}let s=Rt(a);for(let e of s.warnings)console.warn(`warn: ${e}`);if(s.errors.length>0){for(let e of s.errors)console.error(`error: ${e}`);process.exitCode=1;return}let c=N(n);await fe(a,c),console.log(`cascade registry build: wrote static output to ${c}`)}function Bt(e,t){let n=t.toLowerCase();return e.name.toLowerCase().includes(n)||e.description.toLowerCase().includes(n)||e.tags.some(e=>e.toLowerCase().includes(n))}async function Vt(e,t){let n=e.indexOf(`--registry`),r=n===-1?void 0:e[n+1],i=e.filter((t,n)=>t!==`--registry`&&e[n-1]!==`--registry`).join(` `).trim();if(!i){console.error(`Usage: cascivo search <query> [--registry @ns]`);return}let a=[];if(!r){let e=await y(t.registry);for(let t of e.components)Bt(t,i)&&a.push({name:t.name,version:t.version,description:t.description})}let o=t.registries??{};for(let[e,t]of Object.entries(o))if(!(r&&e!==r))try{let n=(typeof t==`string`?t:t.url).replace(/{name}[^$]*$/,``).replace(/\/$/,``)+`/registry.json`,r=await p(n),o=typeof r==`object`&&r&&Array.isArray(r.items)?r.items??[]:[];for(let t of o){if(!he(t).ok)continue;let n=t;Bt(n,i)&&a.push({name:`${e}/${n.name}`,version:n.version,description:n.description,registry:e})}}catch{console.warn(` [warn] Could not search ${e} registry`)}if(a.length===0){console.log(`No results found.`);return}for(let e of a){let t=e.registry?` (${e.registry})`:``;console.log(`${e.name}@${e.version}${t} — ${e.description}`)}}const Z={baseMode:`light`,accentHue:250,accentChroma:.2,radiusBase:.375,fontFamily:`system`,presetId:`light`};function Ht(e){if(!e)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=JSON.parse(n);return{baseMode:r.baseMode===`dark`?`dark`:`light`,accentHue:typeof r.accentHue==`number`?r.accentHue:Z.accentHue,accentChroma:typeof r.accentChroma==`number`?r.accentChroma:Z.accentChroma,radiusBase:typeof r.radiusBase==`number`?r.radiusBase:Z.radiusBase,fontFamily:r.fontFamily??Z.fontFamily,presetId:r.presetId??null}}catch{return null}}const Ut={geometric:`'Futura', 'Century Gothic', 'Trebuchet MS', ui-sans-serif, sans-serif`,humanist:`'Gill Sans', 'Trebuchet MS', 'Calibri', ui-sans-serif, sans-serif`,transitional:`'Optima', 'Candara', 'Palatino Linotype', ui-sans-serif, sans-serif`,mono:`ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace`};function Wt(e,t={}){let{previewMode:n=!1,themeName:r=`create-custom`}=t,i=e.baseMode===`light`,a=e.accentHue,o=e.accentChroma,s=(e,t=o)=>`oklch(${e} ${t.toFixed(3)} ${a})`,c=[`/* Add to your project CSS after importing the base theme: */`,`/* @import '@cascivo/themes/${e.baseMode}.css'; */`,`/* @import './theme.css'; */`,``,`@layer cascivo.theme {`,` [data-theme="${r}"] {`];return n&&(c.push(i?`
|
|
65
66
|
color-scheme: light;
|
|
66
67
|
--cascivo-color-background: oklch(1 0 0);
|
|
67
68
|
--cascivo-color-surface: oklch(0.985 0.002 264);
|
|
@@ -157,16 +158,16 @@ Add components with: cascivo add <name>`)}const Dt={component:`Components`,layou
|
|
|
157
158
|
--cascivo-ring-width: 2px;
|
|
158
159
|
--cascivo-ring-offset: 0px;
|
|
159
160
|
--cascivo-ring-color: color-mix(in oklch, var(--cascivo-color-accent) 65%, transparent);
|
|
160
|
-
--cascivo-focus-ring: 0 0 0 var(--cascivo-ring-width) var(--cascivo-ring-color);`),c.push(``)),c.push(` /* ── Accent ─────────────────────────────────── */`,` --cascivo-color-accent: ${s(i?.52:.65)};`,` --cascivo-color-accent-foreground: ${i?`oklch(1 0 0)`:`oklch(0.145 0.005 ${a})`};`,` --cascivo-color-accent-hover: ${s(i?.45:.707)};`,` --cascivo-color-accent-active: ${s(i?.373:.808,Math.min(o,.155))};`,` --cascivo-color-accent-subtle: ${s(i?.97:.623,.025)};`,` --cascivo-color-accent-muted: ${s(i?.932:.623,i?.055:o*.2)};`,``,` /* ── Radius ─────────────────────────────────── */`,` --cascivo-radius-base: ${e.radiusBase}rem;`,` --cascivo-radius-control: var(--cascivo-radius-base);`,` --cascivo-radius-surface: calc(var(--cascivo-radius-base) * 1.66);`,` --cascivo-radius-indicator: calc(var(--cascivo-radius-base) / 2);`,` --cascivo-radius-full: 9999px;`,` --cascivo-radius-component: var(--cascivo-radius-base);`,` --cascivo-radius-button: var(--cascivo-radius-base);`,` --cascivo-radius-input: var(--cascivo-radius-base);`,` --cascivo-radius-card: calc(var(--cascivo-radius-base) * 1.66);`,` --cascivo-radius-badge: var(--cascivo-radius-full);`,` --cascivo-radius-modal: calc(var(--cascivo-radius-base) * 2);`),e.fontFamily!==`system`&&(c.push(``),c.push(` /* ── Font ───────────────────────────────────── */`),c.push(` --cascivo-font-sans: ${
|
|
161
|
-
`)}const
|
|
162
|
-
Import the base theme and your overlay in your entry CSS:`),console.log(` @import '@cascivo/themes/${a.baseMode}.css';`),console.log(` @import './${n}.theme.css';`),console.log(`Then set it on a container:`),console.log(` <div data-theme="${n}">…</div>`)}async function
|
|
163
|
-
Import the theme in your root CSS or entry file:`),console.log(` import '@cascivo/themes/${n}.css'`),console.log(`Then set it on a container:`),console.log(` <div data-theme="${n}">…</div>`)}function
|
|
161
|
+
--cascivo-focus-ring: 0 0 0 var(--cascivo-ring-width) var(--cascivo-ring-color);`),c.push(``)),c.push(` /* ── Accent ─────────────────────────────────── */`,` --cascivo-color-accent: ${s(i?.52:.65)};`,` --cascivo-color-accent-foreground: ${i?`oklch(1 0 0)`:`oklch(0.145 0.005 ${a})`};`,` --cascivo-color-accent-hover: ${s(i?.45:.707)};`,` --cascivo-color-accent-active: ${s(i?.373:.808,Math.min(o,.155))};`,` --cascivo-color-accent-subtle: ${s(i?.97:.623,.025)};`,` --cascivo-color-accent-muted: ${s(i?.932:.623,i?.055:o*.2)};`,``,` /* ── Radius ─────────────────────────────────── */`,` --cascivo-radius-base: ${e.radiusBase}rem;`,` --cascivo-radius-control: var(--cascivo-radius-base);`,` --cascivo-radius-surface: calc(var(--cascivo-radius-base) * 1.66);`,` --cascivo-radius-indicator: calc(var(--cascivo-radius-base) / 2);`,` --cascivo-radius-full: 9999px;`,` --cascivo-radius-component: var(--cascivo-radius-base);`,` --cascivo-radius-button: var(--cascivo-radius-base);`,` --cascivo-radius-input: var(--cascivo-radius-base);`,` --cascivo-radius-card: calc(var(--cascivo-radius-base) * 1.66);`,` --cascivo-radius-badge: var(--cascivo-radius-full);`,` --cascivo-radius-modal: calc(var(--cascivo-radius-base) * 2);`),e.fontFamily!==`system`&&(c.push(``),c.push(` /* ── Font ───────────────────────────────────── */`),c.push(` --cascivo-font-sans: ${Ut[e.fontFamily]??Ut.humanist};`)),c.push(` }`),c.push(`}`),c.join(`
|
|
162
|
+
`)}const Gt=/^[a-z][a-z0-9-]*$/;function Kt(e,t){let n=e.find(e=>e.startsWith(`--${t}=`));if(n)return n.slice(t.length+3);let r=e.indexOf(`--${t}`),i=r===-1?void 0:e[r+1];return i&&!i.startsWith(`--`)?i:void 0}async function qt(e,t){let n=e.find(e=>!e.startsWith(`--`)),r=Kt(e,`from`),i=e.includes(`--dry-run`);if(!n||!r){console.error(`Usage: cascivo theme create <name> --from <hash> [--out <path>]`),console.error(`Get <hash> from the theme builder at https://cascivo.com/create (Copy CLI command).`);return}if(!Gt.test(n)){console.error(`Invalid theme name "${n}". Use lowercase letters, digits, and dashes.`);return}let a=Ht(r);if(!a){console.error(`Could not decode --from. Copy the command again from the theme builder.`);return}let o=Wt(a,{themeName:n});if(i){console.log(o);return}let s=N(t,Kt(e,`out`)??`${n}.theme.css`);await c(s,o),console.log(`\n✓ Wrote ${n}.theme.css`),console.log(`
|
|
163
|
+
Import the base theme and your overlay in your entry CSS:`),console.log(` @import '@cascivo/themes/${a.baseMode}.css';`),console.log(` @import './${n}.theme.css';`),console.log(`Then set it on a container:`),console.log(` <div data-theme="${n}">…</div>`)}async function Jt(e){let[t,n]=e;if(t===`create`){await qt(e.slice(1),process.cwd());return}if(t!==`add`||!n){console.error(`Usage: cascivo theme add <${a.join(`|`)}>`),console.error(` cascivo theme create <name> --from <hash>`);return}if(!a.includes(n)){console.error(`Unknown theme "${n}". Available: ${a.join(`, `)}`);return}L([`@cascivo/themes`]),console.log(`
|
|
164
|
+
Import the theme in your root CSS or entry file:`),console.log(` import '@cascivo/themes/${n}.css'`),console.log(`Then set it on a container:`),console.log(` <div data-theme="${n}">…</div>`)}function Yt(e,t){let n=e.split(`
|
|
164
165
|
`),r=t.split(`
|
|
165
|
-
`),i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array.from({length:a+1},()=>0));for(let e=i-1;e>=0;e--)for(let t=a-1;t>=0;t--)o[e][t]=n[e]===r[t]?o[e+1][t+1]+1:Math.max(o[e+1][t],o[e][t+1]);let s=[],c=0,l=0;for(;c<i&&l<a;)n[c]===r[l]?(s.push(` ${n[c]}`),c++,l++):o[c+1][l]>=o[c][l+1]?(s.push(`- ${n[c]}`),c++):(s.push(`+ ${r[l]}`),l++);for(;c<i;)s.push(`- ${n[c++]}`);for(;l<a;)s.push(`+ ${r[l++]}`);return s}function
|
|
166
|
-
`)),i.push({path:a,content:r}))}if(i.length===0){console.log(`${e} is already up to date.`);return}if(r.yes||await
|
|
166
|
+
`),i=n.length,a=r.length,o=Array.from({length:i+1},()=>Array.from({length:a+1},()=>0));for(let e=i-1;e>=0;e--)for(let t=a-1;t>=0;t--)o[e][t]=n[e]===r[t]?o[e+1][t+1]+1:Math.max(o[e+1][t],o[e][t+1]);let s=[],c=0,l=0;for(;c<i&&l<a;)n[c]===r[l]?(s.push(` ${n[c]}`),c++,l++):o[c+1][l]>=o[c][l+1]?(s.push(`- ${n[c]}`),c++):(s.push(`+ ${r[l]}`),l++);for(;c<i;)s.push(`- ${n[c++]}`);for(;l<a;)s.push(`+ ${r[l++]}`);return s}function Xt(e,t){return e!==t}async function Zt(e){let t=I({input:O,output:ie});try{let n=(await t.question(`${e} (y/N): `)).trim().toLowerCase();return n===`y`||n===`yes`}finally{t.close()}}async function Qt(e,t,n={}){if(n.check)return tn(t);if(!e){console.error(`Usage: cascivo update <component>`);return}let r=(await v())?.items[e],i=await y(t.registry),a=h(i,e);if(!a){console.error(`Component "${e}" not found in registry. Run "cascivo list".`);return}if(r){let i=r.version,o=`${r.registry}/r/${e}@${i}.json`,s=null;try{s=F(await p(o),o)}catch{console.warn(`Warning: could not fetch base version ${i} from ${o}. Falling back to two-way diff.`)}s?await $t(e,a,s,t,n):await en(e,a,t,n)}else console.warn(`Warning: "${e}" has no lock entry. Falling back to two-way diff update (pre-v11 install).`),await en(e,a,t,n)}async function $t(e,t,n,r,i){if(!t)return;let a=e.includes(`/`)?e.split(`/`).pop():e,o=[],s=[];for(let e of t.files){let t=b(e),i=n.files.find(e=>b(e.url)===t),c=u(r.outputDir,a,t),l=await f(e),d=k(c)?await ue(c,`utf8`):``,p=i?await f(i.url):``;if(p===``&&d===``){o.push({file:t,result:`clean`}),s.push({dest:c,content:l,conflicts:0});continue}let{text:m,conflicts:h}=T(p,d,l);if(h>0)o.push({file:t,result:`conflict`});else if(m===d){o.push({file:t,result:`unchanged`});continue}else o.push({file:t,result:`clean`});s.push({dest:c,content:m,conflicts:h})}if(s.length===0){console.log(`${e} is already up to date.`);return}for(let e of o){let t=e.result===`conflict`?`⚠`:e.result===`clean`?`✓`:`·`;console.log(` ${t} ${e.file} (${e.result})`)}let l=s.filter(e=>e.conflicts>0);if((i.yes?l.length===0:await Zt(`\nApply ${s.length} change(s) to ${e}?`))||i.yes){let n=await v(),r=n;for(let{dest:e,content:t,conflicts:n}of s){if(i.yes&&n>0){console.log(` skipped (conflicts): ${e}`);continue}await c(e,t)}if(n&&r){let i=l.length>0;r=g(r,e,{...n.items[e],version:t.version,...i?{conflicted:!0}:{}}),await m(r)}console.log(`Updated ${e}.`),l.length>0&&console.log(`${l.length} file(s) have conflict markers — resolve them manually.`)}else console.log(`Aborted. No files changed.`)}async function en(e,t,n,r){if(!t)return;let i=[];for(let e of t.files){let r;try{r=await f(e)}catch(e){console.error(e instanceof Error?e.message:String(e));return}let a=u(n.outputDir,t.name,b(e)),o=await l(a);o===null?(console.log(`New file: ${a}`),i.push({path:a,content:r})):Xt(o,r)&&(console.log(`\n--- ${a}`),console.log(Yt(o,r).join(`
|
|
167
|
+
`)),i.push({path:a,content:r}))}if(i.length===0){console.log(`${e} is already up to date.`);return}if(r.yes||await Zt(`\nApply ${i.length} change(s) to ${e}?`)){for(let{path:e,content:t}of i)await c(e,t);console.log(`Updated ${e}.`)}else console.log(`Aborted. No files changed.`)}async function tn(e){let t=await v();if(!t||Object.keys(t.items).length===0){console.log(`No installed components found in cascivo.lock.`);return}let n=await y(e.registry),r=0;for(let[e,i]of Object.entries(t.items)){let t=h(n,e);if(t){if(t.fileHashes&&Object.keys(t.fileHashes).length>0){let n=new Map(Object.entries(i.files).map(([e,t])=>[e.split(`/`).pop(),t])),a=Object.entries(t.fileHashes).filter(([e,t])=>n.get(e)!==t);a.length>0&&(console.log(`${e}: ${a.length} file(s) changed upstream (${i.version} → ${t.version})`),r++)}else t.version!==i.version&&(console.log(`${e}: ${i.version} → ${t.version}`),r++)}}r>0?(console.log(`${r} component(s) outdated.`),process.exitCode=1):console.log(`All components up to date.`)}function nn(e){let t=[];if(t.push(`\n${e.name} v${e.version}`),t.push(`Type: ${e.type}${e.category?` / ${e.category}`:``}`),t.push(e.description),e.author&&t.push(`Author: ${e.author}`),e.license&&t.push(`License: ${e.license}`),e.homepage&&t.push(`Homepage: ${e.homepage}`),e.install?(t.push(`Distribution: npm package — pnpm add ${e.install}`),e.styles&&t.push(`Stylesheet: import '${e.styles}' (required)`)):P(e)||t.push(`Distribution: copy-paste — npx cascivo add ${e.name}`),P(e))try{let n=de(e.meta);if(t.push(`\nTemplate: ${n.intent}`),t.push(`Framework: ${n.framework}`),n.demoUrl&&t.push(`Demo: ${n.demoUrl}`),n.pages?.length){t.push(`Pages:`);for(let e of n.pages)t.push(` ${e.name} → ${e.target}`)}}catch{}if(e.changelog?.length){t.push(`
|
|
167
168
|
Changelog:`);for(let n of e.changelog.slice(0,5))t.push(` ${n.version}: ${n.note}`)}if(e.files?.length){t.push(`
|
|
168
|
-
Files:`);for(let n of e.files)t.push(` ${n.url}${n.target?` → ${n.target}`:``}`)}if(e.dependencies?.length&&t.push(`\nDependencies: ${e.dependencies.join(`, `)}`),e.registryDependencies?.length){let n=
|
|
169
|
-
`)}async function
|
|
169
|
+
Files:`);for(let n of e.files)t.push(` ${n.url}${n.target?` → ${n.target}`:``}`)}if(e.dependencies?.length&&t.push(`\nDependencies: ${e.dependencies.join(`, `)}`),e.registryDependencies?.length){let n=P(e)?`Components`:`Registry dependencies`;t.push(`${n}: ${e.registryDependencies.join(`, `)}`)}return t.join(`
|
|
170
|
+
`)}async function rn(e,t){let n=e[0];if(!n){console.error(`Usage: cascivo view <component-spec>`);return}let{url:r,headers:i,params:a}=await be(ve(n),t),o={};i&&(o.headers=i),a&&(o.params=a);let s=F(await p(r,o),r);console.log(nn(s))}const Q=E(import.meta.url)(`../package.json`).version,an=`cascivo ${Q} — the CSS-native, signal-driven, AI-first design system
|
|
170
171
|
|
|
171
172
|
Usage: cascivo <command> [options]
|
|
172
173
|
|
|
@@ -192,7 +193,7 @@ Commands:
|
|
|
192
193
|
tokens import <file> Import external design tokens as cascivo overrides
|
|
193
194
|
email lint <file...> Check rendered email HTML for client support and dead links
|
|
194
195
|
|
|
195
|
-
Run "cascivo <command> --help" for details.`,$=a.join(` | `)
|
|
196
|
+
Run "cascivo <command> --help" for details.`,$=a.join(` | `),on={app:`Usage: cascivo app add page "<title>" [options]
|
|
196
197
|
cascivo app add example <name>
|
|
197
198
|
cascivo app upgrade
|
|
198
199
|
|
|
@@ -392,5 +393,5 @@ Options:
|
|
|
392
393
|
--repo <owner/repo> Repository the template will be hosted in`,tokens:`Usage: cascivo tokens import <file>
|
|
393
394
|
|
|
394
395
|
Import external design tokens (W3C design-tokens JSON) as cascivo token
|
|
395
|
-
overrides.`};async function
|
|
396
|
+
overrides.`};async function sn(e){let[t,...r]=e;if(t!==void 0&&(r.includes(`--help`)||r.includes(`-h`))){let e=on[t];if(e!==void 0){console.log(e);return}}switch(t){case`create`:let{create:e}=await import(`./create-DIaknp48.mjs`);await e(r);break;case`app`:{let{app:e}=await import(`./app-BhCskK3W.mjs`);await e(r);break}case`init`:await Mt(r);break;case`add`:{let e=C(r);if(`error`in e){console.error(e.error),process.exitCode=1;break}await Ae(re(r,[`pm`,`package-manager`]),await n(),{dryRun:r.includes(`--dry-run`),yes:r.includes(`--yes`),noInstall:r.includes(`--no-install`),...e.pm?{pm:e.pm}:{}});break}case`list`:await Lt(await n(),{installed:r.includes(`--installed`)});break;case`update`:await Qt(r.filter(e=>!e.startsWith(`--`))[0],await n(),{check:r.includes(`--check`),yes:r.includes(`--yes`)});break;case`search`:await Vt(r,await n());break;case`view`:await rn(r,await n());break;case`theme`:await Jt(r);break;case`eject`:{let{eject:e}=await import(`./eject-CCb1WqVx.mjs`),t=e=>{let t=r.find(t=>t.startsWith(`--${e}=`));if(t)return t.slice(e.length+3);let n=r.indexOf(`--${e}`),i=n===-1?void 0:r[n+1];return i&&!i.startsWith(`--`)?i:void 0},i=t(`tokens`);await e(r,await n(),{...i?{tokens:i.split(`,`).map(e=>e.trim()).filter(Boolean)}:{},...t(`scope`)?{scope:t(`scope`)}:{},...t(`out`)?{out:t(`out`)}:{},dryRun:r.includes(`--dry-run`)});break}case`generate`:await bt(r,await n());break;case`registry`:r[0]===`build`?await zt(r.slice(1)):(console.error(`Unknown registry subcommand: ${r[0]}`),process.exitCode=1);break;case`template`:if(r[0]===`init`){let{templateInit:e}=await import(`./template-init-BFlRHOxK.mjs`);await e(r.slice(1))}else console.error(`Unknown template subcommand: ${r[0]}`),process.exitCode=1;break;case`doctor`:{let e=r.includes(`--ci`);if(r.includes(`--drift`)){let{runDoctorDrift:e}=await import(`./drift-DiXM2Rag.mjs`);await e(await n())}else{let t=process.cwd(),r=await $e(t),{checkDuplicateCore:i,checkFormatterIgnore:a,checkProjectDependencies:o,checkSignalsCompat:s,checkSsrConfig:c,detectInstallPath:l}=await Promise.resolve().then(()=>Me),u=l(t)!==`unknown`,d=u?o(t):[],f=d.filter(e=>e.required),p=u?await s(t):null,m=p?.severity===`error`,h=u?c(t):null,g=u?await i(t):null,_=u?a(t,(await n()).outputDir):null,{runDoctorDrift:v}=await import(`./drift-DiXM2Rag.mjs`),y=u?await v(await n(),t):{ran:!1,reason:`no cascivo install detected`,issues:0};if(r.passed&&d.length===0&&p===null&&h===null&&g===null&&_===null&&y.issues===0)console.log(y.ran?`No violations found.`:`No violations found (drift: not checked — ${y.reason}).`);else{for(let e of r.violations)console.error(`[${e.rule}] ${e.detail}\n ${e.file}`);for(let e of f)console.error(e.kind===`forbidden`?`[forbidden-dependency] ${e.package} must not be a direct dependency here. Remove it — ${e.hint}`:`[missing-dependency] ${e.package} is not in package.json. Install: ${e.hint}`);p&&(m?console.error:console.log)(`[${m?`signals-incompatible`:`signals-outdated`}] ${p.detail} Upgrade: ${p.hint}`),h&&console.log(`[ssr-config] ${h}`),_&&console.log(`[formatter-drift] ${_}`),g&&console.error(`[duplicate-core] More than one @cascivo/core is installed (root: ${g.root??`none`}; ${g.nested.join(`; `)}). `+g.hint);for(let e of d.filter(e=>!e.required))console.log(`[optional] ${e.package} is not installed; add it when a component or chart needs it: ${e.hint}`);e&&(r.violations.length>0||f.length>0||m||g!==null||y.issues>0)&&(process.exitCode=1)}}break}case`mcp`:{let{mcp:e}=await import(`./mcp-CqX_Yi06.mjs`).then(e=>e.t);await e(r);break}case`audit`:{let{audit:e}=await import(`./audit-Boq9kXpR.mjs`);await e(r,await n());break}case`email`:{let{email:e}=await import(`./email-Drn2bDlp.mjs`);await e(r);break}case`tokens`:if(r[0]===`import`){let{tokensImport:e}=await import(`./tokens-VSJC9GgT.mjs`);await e(r.slice(1))}else console.error(`Unknown tokens subcommand: ${r[0]}`),process.exitCode=1;break;case void 0:case`--help`:case`-h`:case`help`:console.log(an);break;case`--version`:case`-v`:console.log(Q);break;default:console.error(`Unknown command: ${t}\n`),console.log(an),process.exitCode=1}}D[1]!==void 0&&import.meta.url===ae(D[1]).href&&sn(D.slice(2)).catch(e=>{console.error(e instanceof Error?e.message:String(e)),process.exitCode=1});export{Q as VERSION,sn as run,Te as t};
|
|
396
397
|
//# sourceMappingURL=index.mjs.map
|