@stacksjs/stx 0.2.118 → 0.2.119

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 CHANGED
@@ -4331,6 +4331,14 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
4331
4331
  // Store ref in scope.$refs and componentScope.$refs
4332
4332
  if (scope.$refs) scope.$refs[value] = el;
4333
4333
  if (componentScope.$refs) componentScope.$refs[value] = el;
4334
+ // Also fill a same-named signal declared in the script block, so the
4335
+ // documented ref() + x-ref pair works and reading the signal returns
4336
+ // the element. Without this the signal stayed empty and every read of
4337
+ // it silently returned undefined.
4338
+ var refTarget = (scope && scope[value]) || componentScope[value];
4339
+ if (refTarget && typeof refTarget === 'function' && refTarget._isSignal && typeof refTarget.set === 'function') {
4340
+ refTarget.set(el);
4341
+ }
4334
4342
  }
4335
4343
  else if (name.startsWith('@') || name.startsWith(':')) {
4336
4344
  // Event handlers: @click, :click, @submit.prevent, :keydown.enter, etc.
@@ -5797,6 +5805,15 @@ else if (timer === null) {
5797
5805
  }
5798
5806
 
5799
5807
  function useInterval(interval, options) {
5808
+ // Accept the callback-first form too \u2014 useInterval(fn, 1000) is what most
5809
+ // callers reach for, and silently ignoring the callback (the previous
5810
+ // behaviour) produced a timer that ticked into the void.
5811
+ var callback = null;
5812
+ if (typeof interval === 'function') {
5813
+ callback = interval;
5814
+ interval = typeof options === 'number' ? options : 1000;
5815
+ options = {};
5816
+ }
5800
5817
  interval = interval || 1000;
5801
5818
  options = options || {};
5802
5819
  var count = 0;
@@ -5824,6 +5841,7 @@ else if (timer === null) {
5824
5841
  listeners.forEach(function(fn) { fn(count); });
5825
5842
  resume();
5826
5843
  }
5844
+ if (callback) listeners.push(callback);
5827
5845
  resume();
5828
5846
  onDestroy(function() { pause(); listeners = []; });
5829
5847
  return {
@@ -21398,7 +21416,7 @@ else {
21398
21416
  `)}function Cw($,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:""}"`:Cw(K,Z+1)),G=Q.length>0?`,
21399
21417
  ${Y} [${Q.join(`,
21400
21418
  ${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${J}${G})`}function jh($,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(`
21401
- `)}return Y.get(Z.target)||TU($,Z)}function Hh($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:Pw(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 Oh($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function bw(){return`id_${++Lh}`}function Pw($){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 Vh($){return $.charAt(0).toUpperCase()+$.slice(1)}function Fh($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function Ah($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function EU($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=EU(Y);return Z}function IU($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=IU(Y);return Z}function yw($){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 DU,Lh=0,Nh,wh;var vw=D(()=>{DU=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"}]]);Nh={compileToNative:Ew,createHotReloadServer:yw,NATIVE_COMPONENTS:DU},wh=Nh});import{spawn as hw}from"child_process";import v0 from"fs";import Rh from"os";import X0 from"path";import f from"process";import{CLI as Mh}from"@stacksjs/clapp";var D6="0.2.118";U$();YU();zK();FK();l4();OK();GK();iW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",O0=new Mh("stx");function fw($){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 gw($){try{if(!v0.existsSync($)){let Y=X0.dirname($),X=X0.basename($);if(v0.existsSync(Y)){let Q=v0.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(v0.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 kU($){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 n5=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),Th=($)=>$.endsWith(".stx")||$.endsWith(".md");function i5($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);f.exit(Z)}async function Eh($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(n5(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=X0.join(Rh.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",X0.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...f.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=hw(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let _=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),f.on("SIGINT",()=>{console.log(`
21419
+ `)}return Y.get(Z.target)||TU($,Z)}function Hh($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:Pw(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 Oh($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function bw(){return`id_${++Lh}`}function Pw($){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 Vh($){return $.charAt(0).toUpperCase()+$.slice(1)}function Fh($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function Ah($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function EU($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=EU(Y);return Z}function IU($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=IU(Y);return Z}function yw($){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 DU,Lh=0,Nh,wh;var vw=D(()=>{DU=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"}]]);Nh={compileToNative:Ew,createHotReloadServer:yw,NATIVE_COMPONENTS:DU},wh=Nh});import{spawn as hw}from"child_process";import v0 from"fs";import Rh from"os";import X0 from"path";import f from"process";import{CLI as Mh}from"@stacksjs/clapp";var D6="0.2.119";U$();YU();zK();FK();l4();OK();GK();iW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",O0=new Mh("stx");function fw($){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 gw($){try{if(!v0.existsSync($)){let Y=X0.dirname($),X=X0.basename($);if(v0.existsSync(Y)){let Q=v0.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(v0.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 kU($){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 n5=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),Th=($)=>$.endsWith(".stx")||$.endsWith(".md");function i5($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);f.exit(Z)}async function Eh($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(n5(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=X0.join(Rh.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",X0.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...f.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=hw(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let _=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),f.on("SIGINT",()=>{console.log(`
21402
21420
  Test run interrupted`),K.kill("SIGINT"),f.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var Ih=f.argv.length>=3&&(Th(f.argv[2])&&v0.existsSync(f.argv[2])||n5(f.argv[2]));if(Ih){let $=f.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<f.argv.length;Y++){let X=f.argv[Y];if(X==="--port"&&Y+1<f.argv.length){let J=fw(f.argv[++Y]);if(!J.isValid)i5(J);Z.port=Number.parseInt(f.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<f.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=f.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(n5($))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=X0.resolve(J);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((z)=>/\[.+\]/.test(X0.basename(z)));for(let z of U)if(!X.includes(z))X.push(z)}catch{}if(X.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),f.exit(1);if(!await j3(X,Z))f.exit(1)}catch(Y){console.error("Failed to process files:",Y),f.exit(1)}else q3($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),f.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]};O0.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 UK(X))console.log("Documentation generated successfully."),f.exit(0);else console.error("Documentation generation failed."),f.exit(1)}catch(J){console.error("Error generating documentation:",J),f.exit(1)}}),O0.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(`
21403
21421
  \uD83D\uDCDA Fetching available icon collections...
21404
21422
  `);let K=await Q(),W=Object.entries(K).sort((U,z)=>z[1].total-U[1].total);console.log(`Available collections:
@@ -39,7 +39,7 @@ export declare function useThrottle<T extends (...args: any[]) => any>(fn: T, li
39
39
  * // counter increments every second
40
40
  * ```
41
41
  */
42
- export declare function useInterval(interval?: number, options?: IntervalOptions): IntervalRef;
42
+ export declare function useInterval(interval?: number | ((counter: number) => void), options?: IntervalOptions | number): IntervalRef;
43
43
  /**
44
44
  * One-shot timeout with start/stop control and auto-cleanup.
45
45
  *
@@ -95,16 +95,26 @@ export function useThrottle(fn, limit = 250) {
95
95
  return throttled;
96
96
  }
97
97
  export function useInterval(interval = 1000, options = {}) {
98
+ let callback = null;
99
+ if (typeof interval === "function") {
100
+ callback = interval;
101
+ interval = typeof options === "number" ? options : 1000;
102
+ options = {};
103
+ }
104
+ const delay = interval || 1000, config = typeof options === "number" ? {} : options;
98
105
  let count = 0, id = null, running = !1;
99
- const listeners = new Set, tick = () => {
106
+ const listeners = new Set;
107
+ if (callback)
108
+ listeners.add(callback);
109
+ const tick = () => {
100
110
  count++;
101
111
  listeners.forEach((fn) => fn(count));
102
112
  }, resume = () => {
103
113
  if (running)
104
114
  return;
105
115
  running = !0;
106
- id = setInterval(tick, interval);
107
- if (options.immediate)
116
+ id = setInterval(tick, delay);
117
+ if (config.immediate)
108
118
  tick();
109
119
  }, pause = () => {
110
120
  if (!running)
package/dist/pwa.js CHANGED
@@ -4000,6 +4000,14 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
4000
4000
  // Store ref in scope.$refs and componentScope.$refs
4001
4001
  if (scope.$refs) scope.$refs[value] = el;
4002
4002
  if (componentScope.$refs) componentScope.$refs[value] = el;
4003
+ // Also fill a same-named signal declared in the script block, so the
4004
+ // documented ref() + x-ref pair works and reading the signal returns
4005
+ // the element. Without this the signal stayed empty and every read of
4006
+ // it silently returned undefined.
4007
+ var refTarget = (scope && scope[value]) || componentScope[value];
4008
+ if (refTarget && typeof refTarget === 'function' && refTarget._isSignal && typeof refTarget.set === 'function') {
4009
+ refTarget.set(el);
4010
+ }
4003
4011
  }
4004
4012
  else if (name.startsWith('@') || name.startsWith(':')) {
4005
4013
  // Event handlers: @click, :click, @submit.prevent, :keydown.enter, etc.
@@ -5466,6 +5474,15 @@ else if (timer === null) {
5466
5474
  }
5467
5475
 
5468
5476
  function useInterval(interval, options) {
5477
+ // Accept the callback-first form too \u2014 useInterval(fn, 1000) is what most
5478
+ // callers reach for, and silently ignoring the callback (the previous
5479
+ // behaviour) produced a timer that ticked into the void.
5480
+ var callback = null;
5481
+ if (typeof interval === 'function') {
5482
+ callback = interval;
5483
+ interval = typeof options === 'number' ? options : 1000;
5484
+ options = {};
5485
+ }
5469
5486
  interval = interval || 1000;
5470
5487
  options = options || {};
5471
5488
  var count = 0;
@@ -5493,6 +5510,7 @@ else if (timer === null) {
5493
5510
  listeners.forEach(function(fn) { fn(count); });
5494
5511
  resume();
5495
5512
  }
5513
+ if (callback) listeners.push(callback);
5496
5514
  resume();
5497
5515
  onDestroy(function() { pause(); listeners = []; });
5498
5516
  return {
package/dist/signals.js CHANGED
@@ -2076,6 +2076,14 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
2076
2076
  // Store ref in scope.$refs and componentScope.$refs
2077
2077
  if (scope.$refs) scope.$refs[value] = el;
2078
2078
  if (componentScope.$refs) componentScope.$refs[value] = el;
2079
+ // Also fill a same-named signal declared in the script block, so the
2080
+ // documented ref() + x-ref pair works and reading the signal returns
2081
+ // the element. Without this the signal stayed empty and every read of
2082
+ // it silently returned undefined.
2083
+ var refTarget = (scope && scope[value]) || componentScope[value];
2084
+ if (refTarget && typeof refTarget === 'function' && refTarget._isSignal && typeof refTarget.set === 'function') {
2085
+ refTarget.set(el);
2086
+ }
2079
2087
  }
2080
2088
  else if (name.startsWith('@') || name.startsWith(':')) {
2081
2089
  // Event handlers: @click, :click, @submit.prevent, :keydown.enter, etc.
@@ -3542,6 +3550,15 @@ else if (timer === null) {
3542
3550
  }
3543
3551
 
3544
3552
  function useInterval(interval, options) {
3553
+ // Accept the callback-first form too \u2014 useInterval(fn, 1000) is what most
3554
+ // callers reach for, and silently ignoring the callback (the previous
3555
+ // behaviour) produced a timer that ticked into the void.
3556
+ var callback = null;
3557
+ if (typeof interval === 'function') {
3558
+ callback = interval;
3559
+ interval = typeof options === 'number' ? options : 1000;
3560
+ options = {};
3561
+ }
3545
3562
  interval = interval || 1000;
3546
3563
  options = options || {};
3547
3564
  var count = 0;
@@ -3569,6 +3586,7 @@ else if (timer === null) {
3569
3586
  listeners.forEach(function(fn) { fn(count); });
3570
3587
  resume();
3571
3588
  }
3589
+ if (callback) listeners.push(callback);
3572
3590
  resume();
3573
3591
  onDestroy(function() { pause(); listeners = []; });
3574
3592
  return {
package/dist/ssg.js CHANGED
@@ -2809,6 +2809,14 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
2809
2809
  // Store ref in scope.$refs and componentScope.$refs
2810
2810
  if (scope.$refs) scope.$refs[value] = el;
2811
2811
  if (componentScope.$refs) componentScope.$refs[value] = el;
2812
+ // Also fill a same-named signal declared in the script block, so the
2813
+ // documented ref() + x-ref pair works and reading the signal returns
2814
+ // the element. Without this the signal stayed empty and every read of
2815
+ // it silently returned undefined.
2816
+ var refTarget = (scope && scope[value]) || componentScope[value];
2817
+ if (refTarget && typeof refTarget === 'function' && refTarget._isSignal && typeof refTarget.set === 'function') {
2818
+ refTarget.set(el);
2819
+ }
2812
2820
  }
2813
2821
  else if (name.startsWith('@') || name.startsWith(':')) {
2814
2822
  // Event handlers: @click, :click, @submit.prevent, :keydown.enter, etc.
@@ -4275,6 +4283,15 @@ else if (timer === null) {
4275
4283
  }
4276
4284
 
4277
4285
  function useInterval(interval, options) {
4286
+ // Accept the callback-first form too \u2014 useInterval(fn, 1000) is what most
4287
+ // callers reach for, and silently ignoring the callback (the previous
4288
+ // behaviour) produced a timer that ticked into the void.
4289
+ var callback = null;
4290
+ if (typeof interval === 'function') {
4291
+ callback = interval;
4292
+ interval = typeof options === 'number' ? options : 1000;
4293
+ options = {};
4294
+ }
4278
4295
  interval = interval || 1000;
4279
4296
  options = options || {};
4280
4297
  var count = 0;
@@ -4302,6 +4319,7 @@ else if (timer === null) {
4302
4319
  listeners.forEach(function(fn) { fn(count); });
4303
4320
  resume();
4304
4321
  }
4322
+ if (callback) listeners.push(callback);
4305
4323
  resume();
4306
4324
  onDestroy(function() { pause(); listeners = []; });
4307
4325
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.118",
4
+ "version": "0.2.119",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.12",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/desktop": "0.2.118",
121
- "@stacksjs/sanitizer": "0.2.118",
120
+ "@stacksjs/desktop": "0.2.119",
121
+ "@stacksjs/sanitizer": "0.2.119",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.118",
123
+ "bun-plugin-stx": "0.2.119",
124
124
  "bunfig": "^0.15.15",
125
- "stx-router": "0.2.118",
125
+ "stx-router": "0.2.119",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.1.9",
128
128
  "ts-syntax-highlighter": "^0.2.1"