@stacksjs/stx 0.2.3 → 0.2.4
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/LICENSE.md +21 -0
- package/dist/cli.js +1 -1
- package/package.json +4 -4
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Stacks.js
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cli.js
CHANGED
|
@@ -10243,7 +10243,7 @@ window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
|
10243
10243
|
`)}function VQ($,Z){let Y=" ".repeat(Z),J=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let _=typeof W.value==="string"?`"${W.value}"`:String(W.value);J.push(`${K}: ${_}`)}let X=J.length>0?`{ ${J.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:VQ(K,Z+1)),G=Q.length>0?`,
|
|
10244
10244
|
${Y} [${Q.join(`,
|
|
10245
10245
|
${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${X}${G})`}function xH($,Z,Y){if(Z.target==="universal"){let J=[];J.push("// Universal entry point"),J.push("");for(let[X,Q]of Y)J.push(`// --- ${X.toUpperCase()} ---`),J.push(`#if ${X.toUpperCase()}`),J.push(Q),J.push("#endif"),J.push("");return J.join(`
|
|
10246
|
-
`)}return Y.get(Z.target)||G1($,Z)}function vH($,Z,Y){let J=[];function X(Q){J.push({name:Q.zigType,hash:AQ(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)X(G)}return X(Z),{version:"1.0.0",components:J,entry:$.id,assets:[],styles:$.styles}}function gH($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function FQ(){return`id_${++fH}`}function AQ($){let Z=0;for(let Y=0;Y<$.length;Y++){let J=$.charCodeAt(Y);Z=(Z<<5)-Z+J,Z=Z&Z}return Math.abs(Z).toString(36)}function hH($){return $.charAt(0).toUpperCase()+$.slice(1)}function dH($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function uH($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function K1($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=K1(Y);return Z}function W1($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=W1(Y);return Z}function RQ($){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 _1,fH=0,mH,pH;var MQ=I(()=>{_1=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-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"}]]);mH={compileToNative:qQ,createHotReloadServer:RQ,NATIVE_COMPONENTS:_1},pH=mH});import{spawn as TQ}from"child_process";import U4 from"fs";import cH from"os";import f from"path";import D from"process";import{CLI as lH}from"@stacksjs/clapp";var I6="0.2.
|
|
10246
|
+
`)}return Y.get(Z.target)||G1($,Z)}function vH($,Z,Y){let J=[];function X(Q){J.push({name:Q.zigType,hash:AQ(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)X(G)}return X(Z),{version:"1.0.0",components:J,entry:$.id,assets:[],styles:$.styles}}function gH($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function FQ(){return`id_${++fH}`}function AQ($){let Z=0;for(let Y=0;Y<$.length;Y++){let J=$.charCodeAt(Y);Z=(Z<<5)-Z+J,Z=Z&Z}return Math.abs(Z).toString(36)}function hH($){return $.charAt(0).toUpperCase()+$.slice(1)}function dH($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function uH($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function K1($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=K1(Y);return Z}function W1($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=W1(Y);return Z}function RQ($){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 _1,fH=0,mH,pH;var MQ=I(()=>{_1=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-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"}]]);mH={compileToNative:qQ,createHotReloadServer:RQ,NATIVE_COMPONENTS:_1},pH=mH});import{spawn as TQ}from"child_process";import U4 from"fs";import cH from"os";import f from"path";import D from"process";import{CLI as lH}from"@stacksjs/clapp";var I6="0.2.4";l6();m0();W6();var{serve:J7}=globalThis.Bun;import Z4 from"fs";import v from"path";import O4 from"process";class wJ{clients=new Set;server=null;options;constructor($={}){this.options={wsPort:$.wsPort??3001,showOverlay:$.showOverlay??!0,reconnectInterval:$.reconnectInterval??1000,maxReconnectAttempts:$.maxReconnectAttempts??10,verbose:$.verbose??!1}}start($){let Z=$??this.options.wsPort,Y=20;for(let J=0;J<Y;J++)try{if(this.server=Bun.serve({port:Z,fetch(X,Q){if(Q.upgrade(X,{data:{}}))return;return new Response("stx Hot Reload Server",{headers:{"Content-Type":"text/plain"}})},websocket:{open:(X)=>{if(this.clients.add(X),this.options.verbose)console.log(`[HMR] Client connected (${this.clients.size} total)`);X.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close:(X)=>{if(this.clients.delete(X),this.options.verbose)console.log(`[HMR] Client disconnected (${this.clients.size} total)`)},message:(X,Q)=>{}}}),this.options.verbose)console.log(`[HMR] WebSocket server started on port ${Z}`);return Z}catch(X){if(X?.code==="EADDRINUSE"){Z++;continue}throw X}throw Error(`Could not find an available port after ${Y} attempts starting from ${$??this.options.wsPort}`)}stop(){for(let $ of this.clients)try{$.close()}catch{}if(this.clients.clear(),this.server)this.server.stop(),this.server=null;if(this.options.verbose)console.log("[HMR] Server stopped")}broadcast($){let Z=JSON.stringify($),Y=0;for(let J of this.clients)try{if(J.readyState===1)J.send(Z),Y++}catch{this.clients.delete(J)}if(this.options.verbose&&Y>0)console.log(`[HMR] Broadcast ${$.type} to ${Y} client(s)`)}reload($){if(this.options.verbose)console.log(`[HMR] Sending reload to ${this.clients.size} client(s) for: ${$||"all"}`);this.broadcast({type:"reload",path:$,timestamp:Date.now()})}updateCss($,Z){this.broadcast({type:"css-update",path:$,content:Z,timestamp:Date.now()})}error($){this.broadcast({type:"error",content:$,timestamp:Date.now()})}get clientCount(){return this.clients.size}get port(){return this.options.wsPort}}function fB($,Z={}){let{showOverlay:Y=!0,reconnectInterval:J=1000,maxReconnectAttempts:X=10}=Z;return`
|
|
10247
10247
|
<script>
|
|
10248
10248
|
(function() {
|
|
10249
10249
|
// stx Hot Reload Client
|
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.4",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -104,9 +104,9 @@
|
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
106
|
"@stacksjs/clapp": "^0.2.0",
|
|
107
|
-
"@stacksjs/desktop": "
|
|
108
|
-
"@stacksjs/sanitizer": "
|
|
109
|
-
"bun-plugin-stx": "
|
|
107
|
+
"@stacksjs/desktop": "0.2.4",
|
|
108
|
+
"@stacksjs/sanitizer": "0.2.4",
|
|
109
|
+
"bun-plugin-stx": "0.2.4",
|
|
110
110
|
"bunfig": "^0.15.6",
|
|
111
111
|
"ts-syntax-highlighter": "^0.2.1"
|
|
112
112
|
}
|