@stacksjs/stx 0.2.102 → 0.2.104
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/cli.js +6 -5
- package/dist/site-builder/seo.js +21 -6
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -16441,11 +16441,12 @@ ${Q.join(`
|
|
|
16441
16441
|
`);if(U.match(/(<\/body>)/i))U=U.replace(/(<\/body>)/i,`${q}
|
|
16442
16442
|
$1`);else U+=`
|
|
16443
16443
|
${q}`}U=await V4(U)}if(Y.wrapInDocument){if(!U.trim().toLowerCase().startsWith("<!doctype")&&!U.trim().toLowerCase().startsWith("<html"))U=Ix(U,Y.title)}if(Y.injectCSS)try{let{injectCrosswindCSS:_}=await Promise.resolve().then(() => (Z4(),h3));U=await _(U)}catch{}return U}var mF=D(()=>{i0();t4();W1();I6()});import b$ from"fs";import F6 from"path";function cF($){try{return b$.statSync($).mtimeMs}catch{return null}}function TX($,Z){let Y=Math.max(0,Math.round((Z-$)/1000));if(Y<60)return`${Y}s ago`;if(Y<3600)return`${Math.round(Y/60)}m ago`;return`${Math.round(Y/3600)}h ago`}function Sx($,Z){try{return globalThis.Bun?.resolveSync($,Z)??null}catch{return null}}function IW($,Z="stx"){let Y=F6.resolve($);for(let X=0;X<10;X++){let J=F6.join(Y,"pantry","@stacksjs",Z);if(b$.existsSync(J))return J;let Q=F6.dirname(Y);if(Q===Y)break;Y=Q}return null}async function EX($={}){let Z=$.cwd?F6.resolve($.cwd):process.cwd(),Y=$.resolve??Sx,X=Date.now(),J=[],Q=Y("@stacksjs/stx",Z);J.push(Q?{name:"@stacksjs/stx resolves to",status:"ok",detail:Q}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let G=Y("bun-plugin-stx",Z);if(G)J.push({name:"bun-plugin-stx resolves to",status:"ok",detail:G});let K=IW(Z,"stx");if(!K)J.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let W=F6.join(K,"src/signals.ts"),U=[F6.join(K,"dist/index.js"),F6.join(K,"dist/signals.js")].find((j)=>b$.existsSync(j))||null,_=cF(W),z=U?cF(U):null;if(_==null)J.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${K} but no src/signals.ts to compare`});else if(z==null)J.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${K} && bun build.ts`});else if(z<_){let j=Math.round((_-z)/1000);J.push({name:"pantry dist freshness",status:"error",detail:`dist (${TX(z,X)}) is OLDER than src/signals.ts (${TX(_,X)}) by ${j}s \u2014 your edit isn't built`,fix:`cd ${K} && bun build.ts`})}else J.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${TX(_,X)}, dist ${TX(z,X)})`});let B=F6.join(Z,"node_modules/@stacksjs/stx"),q=null;try{q=b$.lstatSync(B)}catch{q=null}if(!q)J.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(q.isSymbolicLink()){let j=null;try{j=b$.realpathSync(B)}catch{}let H=(()=>{try{return b$.realpathSync(K)}catch{return K}})();J.push(j===H?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${j||"(dangling)"}, not pantry`})}else J.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(J.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),$.generateRuntime)try{let U=$.generateRuntime().length;J.push(U>1000?{name:"signals runtime",status:"ok",detail:`generated ${U.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${U} chars \u2014 suspiciously short`})}catch(W){J.push({name:"signals runtime",status:"error",detail:`failed to generate: ${W.message}`})}return{checks:J,ok:!J.some((W)=>W.status==="error")}}function IX($){let Z={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},Y=["stx runtime resolution:"];for(let X of $.checks)if(Y.push(` ${Z[X.status]} ${X.name}: ${X.detail}`),X.fix)Y.push(` \u2192 ${X.fix}`);return Y.push(""),Y.push($.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),Y.join(`
|
|
16444
|
-
`)}var DW=()=>{};function u8($,Z,Y={},X="/"){let J=Z.seo??{},Q=Y.title??J.title??Z.name,G=Y.description??J.description??Z.description??"",K=Y.image??J.image,W=`${Z.url.replace(/\/$/,"")}${X}`,U=J.siteName??Z.name,_=J.type??"website",z=J.locale??"en_US",B=[];if(J.favicon){let
|
|
16445
|
-
${
|
|
16444
|
+
`)}var DW=()=>{};function u8($,Z,Y={},X="/"){let J=Z.seo??{},Q=Y.title??J.title??Z.name,G=Y.description??J.description??Z.description??"",K=Y.image??J.image,W=`${Z.url.replace(/\/$/,"")}${X}`,U=J.siteName??Z.name,_=J.type??"website",z=J.locale??"en_US",B=[];if(J.favicon){let F=J.favicon.toLowerCase().split(".").pop(),A=F==="svg"?"image/svg+xml":F==="ico"?"image/x-icon":F==="png"?"image/png":F==="jpg"||F==="jpeg"?"image/jpeg":"";B.push(`<link rel="icon"${A?` type="${A}"`:""} href="${z1(J.favicon)}">`)}if(B.push(`<title>${Cx(Q)}</title>`,`<link rel="canonical" href="${z1(W)}">`,`<meta name="description" content="${z1(G)}">`,`<meta property="og:title" content="${z1(Q)}">`,`<meta property="og:description" content="${z1(G)}">`,`<meta property="og:type" content="${z1(_)}">`,`<meta property="og:url" content="${z1(W)}">`,`<meta property="og:site_name" content="${z1(U)}">`,`<meta property="og:locale" content="${z1(z)}">`,`<meta name="twitter:card" content="${K?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${z1(Q)}">`,`<meta name="twitter:description" content="${z1(G)}">`),K)B.push(`<meta property="og:image" content="${z1(K)}">`),B.push(`<meta name="twitter:image" content="${z1(K)}">`);if(J.twitter)B.push(`<meta name="twitter:site" content="@${z1(J.twitter.replace(/^@/,""))}">`),B.push(`<meta name="twitter:creator" content="@${z1(J.twitter.replace(/^@/,""))}">`);let q=/<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;if(q.test($))$=$.replace(q,"");$=$.replace(/<!--\s*SEO\s*-->[\s\S]*?<!--\s*\/SEO\s*-->\s*/g,""),$=$.replace(/<meta\s+name="title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+property="og:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+property="og:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"");let j=$.search(/<\/head>/i),H=j===-1?$:$.slice(0,j),O=(F)=>{if(/^<title[\s>]/i.test(F))return/<title[\s>]/i.test(H);if(/rel="canonical"/i.test(F))return/<link[^>]+rel=["']canonical["']/i.test(H);let w=/(?:property|name)="([^"]+)"/i.exec(F)?.[1];if(!w)return!1;return new RegExp(`<meta[^>]+(?:property|name)=["']${w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["']`,"i").test(H)},V=B.filter((F)=>!O(F));if(V.length===0)return $;let L=`<!-- SEO -->
|
|
16445
|
+
${V.join(`
|
|
16446
16446
|
`)}
|
|
16447
|
-
<!-- /SEO
|
|
16448
|
-
${
|
|
16447
|
+
<!-- /SEO -->`;if(j!==-1)return`${$.slice(0,j)}${L}
|
|
16448
|
+
${$.slice(j)}`;if(/<head[^>]*>/i.test($))return $.replace(/<head([^>]*)>/i,`<head$1>
|
|
16449
|
+
${L}`);return`${L}
|
|
16449
16450
|
${$}`}function z1($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Cx($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function m8($,Z){let Y=$.url.replace(/\/$/,""),X=new Date().toISOString().slice(0,10);return['<?xml version="1.0" encoding="UTF-8"?>','<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',Z.filter((Q)=>Q.page?.sitemap!==!1).map((Q)=>{let G=`${Y}${Q.path}`,K=Q.page?.priority??(Q.path==="/"?1:0.8),W=Q.page?.changefreq??"monthly";return[" <url>",` <loc>${bx(G)}</loc>`,` <lastmod>${X}</lastmod>`,` <changefreq>${W}</changefreq>`,` <priority>${K.toFixed(1)}</priority>`," </url>"].join(`
|
|
16450
16451
|
`)}).join(`
|
|
16451
16452
|
`),"</urlset>",""].join(`
|
|
@@ -20782,7 +20783,7 @@ else {
|
|
|
20782
20783
|
`)}function Qw($,Z){let Y=" ".repeat(Z),X=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let U=typeof W.value==="string"?`"${W.value}"`:String(W.value);X.push(`${K}: ${U}`)}let J=X.length>0?`{ ${X.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:Qw(K,Z+1)),G=Q.length>0?`,
|
|
20783
20784
|
${Y} [${Q.join(`,
|
|
20784
20785
|
${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${J}${G})`}function Tf($,Z,Y){if(Z.target==="universal"){let X=[];X.push("// Universal entry point"),X.push("");for(let[J,Q]of Y)X.push(`// --- ${J.toUpperCase()} ---`),X.push(`#if ${J.toUpperCase()}`),X.push(Q),X.push("#endif"),X.push("");return X.join(`
|
|
20785
|
-
`)}return Y.get(Z.target)||KU($,Z)}function Ef($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:Kw(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function If($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function Gw(){return`id_${++Df}`}function Kw($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function kf($){return $.charAt(0).toUpperCase()+$.slice(1)}function Sf($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function Cf($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function WU($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=WU(Y);return Z}function UU($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=UU(Y);return Z}function Ww($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var _U,Df=0,bf,Pf;var _w=D(()=>{_U=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);bf={compileToNative:$w,createHotReloadServer:Ww,NATIVE_COMPONENTS:_U},Pf=bf});import{spawn as qw}from"child_process";import y0 from"fs";import yf from"os";import Y0 from"path";import y from"process";import{CLI as xf}from"@stacksjs/clapp";var R6="0.2.102";G5();fW();iG();ZK();h4();tG();mG();DW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",H0=new xf("stx");function zw($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function Bw($){try{if(!y0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(y0.existsSync(Y)){let Q=y0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(y0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function zU($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var m$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),vf=($)=>$.endsWith(".stx")||$.endsWith(".md");function u$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);y.exit(Z)}async function gf($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(m$(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(yf.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...y.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=qw(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let z=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),y.on("SIGINT",()=>{console.log(`
|
|
20786
|
+
`)}return Y.get(Z.target)||KU($,Z)}function Ef($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:Kw(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function If($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function Gw(){return`id_${++Df}`}function Kw($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function kf($){return $.charAt(0).toUpperCase()+$.slice(1)}function Sf($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function Cf($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function WU($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=WU(Y);return Z}function UU($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=UU(Y);return Z}function Ww($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var _U,Df=0,bf,Pf;var _w=D(()=>{_U=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);bf={compileToNative:$w,createHotReloadServer:Ww,NATIVE_COMPONENTS:_U},Pf=bf});import{spawn as qw}from"child_process";import y0 from"fs";import yf from"os";import Y0 from"path";import y from"process";import{CLI as xf}from"@stacksjs/clapp";var R6="0.2.104";G5();fW();iG();ZK();h4();tG();mG();DW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",H0=new xf("stx");function zw($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function Bw($){try{if(!y0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(y0.existsSync(Y)){let Q=y0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(y0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function zU($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var m$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),vf=($)=>$.endsWith(".stx")||$.endsWith(".md");function u$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);y.exit(Z)}async function gf($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(m$(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(yf.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...y.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=qw(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let z=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),y.on("SIGINT",()=>{console.log(`
|
|
20786
20787
|
Test run interrupted`),K.kill("SIGINT"),y.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var ff=y.argv.length>=3&&(vf(y.argv[2])&&y0.existsSync(y.argv[2])||m$(y.argv[2]));if(ff){let $=y.argv[2],Z={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Y=3;Y<y.argv.length;Y++){let X=y.argv[Y];if(X==="--port"&&Y+1<y.argv.length){let J=zw(y.argv[++Y]);if(!J.isValid)u$(J);Z.port=Number.parseInt(y.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<y.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=y.argv[++Y]}else if(X==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(X==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(X==="--no-cache")Z.cache=!1;else if(X==="--native")Z.native=!0}if(m$($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),X=$.endsWith(".stx")?Y.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Y.filter((K)=>K.endsWith(".md")):Y.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),J=$.split("*")[0].replace(/\/$/,"")||".",Q=Y0.resolve(J);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((_)=>/\[.+\]/.test(Y0.basename(_)));for(let _ of U)if(!X.includes(_))X.push(_)}catch{}if(X.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),y.exit(1);if(!await t8(X,Z))y.exit(1)}catch(Y){console.error("Failed to process files:",Y),y.exit(1)}else o8($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),y.exit(1)})}else{let $=function(X,J){let Q=[];for(let G=0;G<=J.length;G++)Q[G]=[G];for(let G=0;G<=X.length;G++)Q[0][G]=G;for(let G=1;G<=J.length;G++)for(let K=1;K<=X.length;K++)if(J.charAt(G-1)===X.charAt(K-1))Q[G][K]=Q[G-1][K-1];else Q[G][K]=Math.min(Q[G-1][K-1]+1,Q[G][K-1]+1,Q[G-1][K]+1);return Q[J.length][X.length]};H0.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(X)=>{try{if(await pG(X))console.log("Documentation generated successfully."),y.exit(0);else console.error("Documentation generation failed."),y.exit(1)}catch(J){console.error("Error generating documentation:",J),y.exit(1)}}),H0.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(X,J)=>{try{let{fetchCollections:Q,generatePackage:G}=await import("@stacksjs/iconify-generator");if(X==="list"){console.log(`
|
|
20787
20788
|
\uD83D\uDCDA Fetching available icon collections...
|
|
20788
20789
|
`);let K=await Q(),W=Object.entries(K).sort((U,_)=>_[1].total-U[1].total);console.log(`Available collections:
|
package/dist/site-builder/seo.js
CHANGED
|
@@ -13,15 +13,30 @@ export function injectSeo(html, site, page = {}, pagePath = "/") {
|
|
|
13
13
|
tags.push(`<meta name="twitter:site" content="@${escapeAttr(seo.twitter.replace(/^@/, ""))}">`);
|
|
14
14
|
tags.push(`<meta name="twitter:creator" content="@${escapeAttr(seo.twitter.replace(/^@/, ""))}">`);
|
|
15
15
|
}
|
|
16
|
-
const
|
|
17
|
-
${tags.join(`
|
|
18
|
-
`)}
|
|
19
|
-
<!-- /SEO -->`, stxAutoBlockRe = /<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;
|
|
16
|
+
const stxAutoBlockRe = /<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;
|
|
20
17
|
if (stxAutoBlockRe.test(html))
|
|
21
18
|
html = html.replace(stxAutoBlockRe, "");
|
|
22
19
|
html = html.replace(/<!--\s*SEO\s*-->[\s\S]*?<!--\s*\/SEO\s*-->\s*/g, "");
|
|
23
|
-
html = html.replace(/<title
|
|
24
|
-
|
|
20
|
+
html = html.replace(/<meta\s+name="title"\s+content="stx Project"[^>]*>\s*/g, "").replace(/<meta\s+name="description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g, "").replace(/<meta\s+property="og:title"\s+content="stx Project"[^>]*>\s*/g, "").replace(/<meta\s+property="og:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g, "").replace(/<meta\s+name="twitter:title"\s+content="stx Project"[^>]*>\s*/g, "").replace(/<meta\s+name="twitter:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g, "");
|
|
21
|
+
const headEnd = html.search(/<\/head>/i), head = headEnd === -1 ? html : html.slice(0, headEnd), declared = (tag) => {
|
|
22
|
+
if (/^<title[\s>]/i.test(tag))
|
|
23
|
+
return /<title[\s>]/i.test(head);
|
|
24
|
+
if (/rel="canonical"/i.test(tag))
|
|
25
|
+
return /<link[^>]+rel=["']canonical["']/i.test(head);
|
|
26
|
+
const key = /(?:property|name)="([^"]+)"/i.exec(tag)?.[1];
|
|
27
|
+
if (!key)
|
|
28
|
+
return !1;
|
|
29
|
+
return new RegExp(`<meta[^>]+(?:property|name)=["']${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["']`, "i").test(head);
|
|
30
|
+
}, missing = tags.filter((tag) => !declared(tag));
|
|
31
|
+
if (missing.length === 0)
|
|
32
|
+
return html;
|
|
33
|
+
const block = `<!-- SEO -->
|
|
34
|
+
${missing.join(`
|
|
35
|
+
`)}
|
|
36
|
+
<!-- /SEO -->`;
|
|
37
|
+
if (headEnd !== -1)
|
|
38
|
+
return `${html.slice(0, headEnd)}${block}
|
|
39
|
+
${html.slice(headEnd)}`;
|
|
25
40
|
if (/<head[^>]*>/i.test(html))
|
|
26
41
|
return html.replace(/<head([^>]*)>/i, `<head$1>
|
|
27
42
|
${block}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.104",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -117,16 +117,16 @@
|
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@cwcss/crosswind": "^0.2.6",
|
|
119
119
|
"@stacksjs/clapp": "^0.2.0",
|
|
120
|
-
"@stacksjs/sanitizer": "0.2.
|
|
120
|
+
"@stacksjs/sanitizer": "0.2.104",
|
|
121
121
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
122
|
-
"bun-plugin-stx": "0.2.
|
|
122
|
+
"bun-plugin-stx": "0.2.104",
|
|
123
123
|
"bunfig": "^0.15.15",
|
|
124
|
-
"stx-router": "0.2.
|
|
124
|
+
"stx-router": "0.2.104",
|
|
125
125
|
"ts-broadcasting": "^0.0.8",
|
|
126
126
|
"ts-images": "^0.1.9",
|
|
127
127
|
"ts-syntax-highlighter": "^0.2.1"
|
|
128
128
|
},
|
|
129
129
|
"optionalDependencies": {
|
|
130
|
-
"@stacksjs/desktop": "0.2.
|
|
130
|
+
"@stacksjs/desktop": "0.2.104"
|
|
131
131
|
}
|
|
132
132
|
}
|