@stacksjs/stx 0.2.549 → 0.2.551
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import"./chunk-a5kaw8sc.js";import"./chunk-ec8k75ep.js";import"./chunk-kvmg6r89.js";import"./chunk-r4199q6x.js";import"./chunk-6v1gwdbv.js";import{W}from"./chunk-cc204fg5.js";import"./chunk-j2erwdgt.js";import"./chunk-jmvp99ay.js";import"./chunk-e124cgb6.js";import"./chunk-0zkmzwh2.js";import"./chunk-1xgs9gd5.js";import"./chunk-dyreg5df.js";import"./chunk-d37enreq.js";import"./chunk-b9jb44kv.js";import"./chunk-tqnh98j7.js";import"./chunk-3nc2fr4q.js";import"./chunk-zmq9hwta.js";import"./chunk-ah7h9q0x.js";import"./chunk-frgpx23w.js";import"./chunk-90zzfgm2.js";import"./chunk-m6m19hwd.js";import"./chunk-xng76fpn.js";import"./chunk-5hdby5qp.js";import"./chunk-vvkfde23.js";import"./chunk-kch9a9v1.js";import"./chunk-a9f7c95b.js";import"./chunk-yq1mvakj.js";import"./chunk-jsgwt566.js";import"./chunk-gjx5256r.js";import"./chunk-ecssbjvj.js";import"./chunk-exbtztv6.js";import"./chunk-7y1bszgt.js";import"./chunk-wy4hfmjs.js";import"./chunk-39tkfkp7.js";import"./chunk-7ze47qgv.js";import"./chunk-azb58ven.js";import{yt,bt}from"./chunk-xneqhbm5.js";import"./chunk-mvgmz8y8.js";import"./chunk-neegs8ab.js";import"./chunk-pz8mf91e.js";import"./chunk-77j26p6r.js";import"./chunk-v79qs0qh.js";import"./chunk-8nwzd6eg.js";import"./chunk-75hb7wg6.js";import"./chunk-n7wkd877.js";import"./chunk-0y7wf87h.js";import{Xs,Js,Ys,Zs,wr,Qs,eo,to,vr,xr,_n,Tn,$n}from"./chunk-tv6ft73q.js";import"./chunk-mre8szx6.js";import"./chunk-wk85dz07.js";import{xi}from"./chunk-1b50m7e7.js";import{u}from"./chunk-cg8hg6cs.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as V}from"@stacksjs/clapp";var j="0.2.
|
|
3
|
+
import"./chunk-a5kaw8sc.js";import"./chunk-ec8k75ep.js";import"./chunk-kvmg6r89.js";import"./chunk-r4199q6x.js";import"./chunk-6v1gwdbv.js";import{W}from"./chunk-cc204fg5.js";import"./chunk-j2erwdgt.js";import"./chunk-jmvp99ay.js";import"./chunk-e124cgb6.js";import"./chunk-0zkmzwh2.js";import"./chunk-1xgs9gd5.js";import"./chunk-dyreg5df.js";import"./chunk-d37enreq.js";import"./chunk-b9jb44kv.js";import"./chunk-tqnh98j7.js";import"./chunk-3nc2fr4q.js";import"./chunk-zmq9hwta.js";import"./chunk-ah7h9q0x.js";import"./chunk-frgpx23w.js";import"./chunk-90zzfgm2.js";import"./chunk-m6m19hwd.js";import"./chunk-xng76fpn.js";import"./chunk-5hdby5qp.js";import"./chunk-vvkfde23.js";import"./chunk-kch9a9v1.js";import"./chunk-a9f7c95b.js";import"./chunk-yq1mvakj.js";import"./chunk-jsgwt566.js";import"./chunk-gjx5256r.js";import"./chunk-ecssbjvj.js";import"./chunk-exbtztv6.js";import"./chunk-7y1bszgt.js";import"./chunk-wy4hfmjs.js";import"./chunk-39tkfkp7.js";import"./chunk-7ze47qgv.js";import"./chunk-azb58ven.js";import{yt,bt}from"./chunk-xneqhbm5.js";import"./chunk-mvgmz8y8.js";import"./chunk-neegs8ab.js";import"./chunk-pz8mf91e.js";import"./chunk-77j26p6r.js";import"./chunk-v79qs0qh.js";import"./chunk-8nwzd6eg.js";import"./chunk-75hb7wg6.js";import"./chunk-n7wkd877.js";import"./chunk-0y7wf87h.js";import{Xs,Js,Ys,Zs,wr,Qs,eo,to,vr,xr,_n,Tn,$n}from"./chunk-tv6ft73q.js";import"./chunk-mre8szx6.js";import"./chunk-wk85dz07.js";import{xi}from"./chunk-1b50m7e7.js";import{u}from"./chunk-cg8hg6cs.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as V}from"@stacksjs/clapp";var j="0.2.551";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new V("stx");function B(h){let p=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(p))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(p<1024||p>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 A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),i=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:i}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(p){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function z(h){let p=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(p))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(p<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(p>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 O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),U=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,p=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(p)}function H(h){if(!h)return;let p;try{p=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof p!=="object"||p===null||Array.isArray(p))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(p))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return p}async function L(h,p){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let r=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(r.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...r),p.verbose)console.log(`Found ${r.length} file(s) matching pattern: ${c}`)}catch(r){return console.error(`Error expanding glob pattern ${c}:`,r),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),p.filter)x.push("--pattern",p.filter);if(p.timeout)x.push("--timeout",p.timeout.toString());if(p.reporter&&p.reporter!=="default")if(p.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",p.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${p.reporter}' is not supported. Using default reporter.`);if(p.coverage)x.push("--coverage");if(p.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:p.ui?"true":"false",STX_TEST_VERBOSE:p.verbose?"true":"false"},o="bun";if(p.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let i=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(r)=>{let d=((performance.now()-i)/1000).toFixed(2);if(r===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
|
|
4
4
|
Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var J=n.argv.length>=3&&(U(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(J){let h=n.argv[2],p={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=B(n.argv[++x]);if(!e.isValid)F(e);p.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")p.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!p.markdown)p.markdown={};if(!p.markdown.syntaxHighlighting)p.markdown.syntaxHighlighting={};p.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!p.markdown)p.markdown={};if(!p.markdown.syntaxHighlighting)p.markdown.syntaxHighlighting={};p.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!p.markdown)p.markdown={};if(!p.markdown.syntaxHighlighting)p.markdown.syntaxHighlighting={};p.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")p.cache=!1;else if(t==="--native")p.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),r=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of r)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await Tn(t,p))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else _n(h,p).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let i=0;i<=e.length;i++)o[i]=[i];for(let i=0;i<=t.length;i++)o[0][i]=i;for(let i=1;i<=e.length;i++)for(let s=1;s<=t.length;s++)if(e.charAt(i-1)===t.charAt(s-1))o[i][s]=o[i-1][s-1];else o[i][s]=Math.min(o[i-1][s-1]+1,o[i][s-1]+1,o[i-1][s]+1);return o[e.length][t.length]};y.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(t)=>{try{if(await Zs(t))console.log("Documentation generated successfully."),n.exit(0);else console.error("Documentation generation failed."),n.exit(1)}catch(e){console.error("Error generating documentation:",e),n.exit(1)}}),y.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(t,e)=>{try{let{fetchCollections:o,generatePackage:i}=await import("./chunk-t61vdbje.js");if(t==="list"){console.log(`
|
|
5
5
|
\uD83D\uDCDA Fetching available icon collections...
|
|
6
6
|
`);let s=await o(),c=Object.entries(s).sort((r,l)=>l[1].total-r[1].total);console.log(`Available collections:
|
|
@@ -36,7 +36,14 @@ export function createBrowserScreenBridge(platform, options) {
|
|
|
36
36
|
send("APPEARANCE", { colorScheme: bridge.colorScheme });
|
|
37
37
|
};
|
|
38
38
|
let currentNavigation = {};
|
|
39
|
-
const tabIcons = new Map,
|
|
39
|
+
const tabIcons = new Map, motion = matchMedia("(prefers-reduced-motion: reduce)"), syncTabPulses = () => {
|
|
40
|
+
for (const tab of tabIcons.values())
|
|
41
|
+
if (!(tab.pulse && !tab.text && !tab.root.querySelector("img") && !motion.matches && !document.hidden)) {
|
|
42
|
+
tab.animation?.cancel();
|
|
43
|
+
tab.animation = null;
|
|
44
|
+
} else if (!tab.animation && typeof tab.root.animate === "function")
|
|
45
|
+
tab.animation = tab.root.animate([{ opacity: 1 }, { opacity: 0.55 }], { duration: 700, iterations: 1 / 0, direction: "alternate" });
|
|
46
|
+
}, navigation = (patch) => {
|
|
40
47
|
currentNavigation = { ...currentNavigation, ...patch };
|
|
41
48
|
const settings = currentNavigation;
|
|
42
49
|
if ("tabAccessory" in patch) {
|
|
@@ -66,6 +73,14 @@ export function createBrowserScreenBridge(platform, options) {
|
|
|
66
73
|
}
|
|
67
74
|
const item = patch.tabItem, tab = item?.id ? tabIcons.get(item.id) : null;
|
|
68
75
|
if (tab && item) {
|
|
76
|
+
if ("title" in item)
|
|
77
|
+
tab.label.textContent = item.title?.slice(0, 40) || tab.title;
|
|
78
|
+
if ("iconText" in item)
|
|
79
|
+
tab.text = item.iconText || null;
|
|
80
|
+
if ("iconTint" in item)
|
|
81
|
+
tab.tint = item.iconTint || null;
|
|
82
|
+
if ("iconPulse" in item)
|
|
83
|
+
tab.pulse = item.iconPulse === !0;
|
|
69
84
|
if ("image" in item && item.image && /^https:\/\//.test(item.image)) {
|
|
70
85
|
const image = document.createElement("img");
|
|
71
86
|
image.src = item.image;
|
|
@@ -83,6 +98,9 @@ export function createBrowserScreenBridge(platform, options) {
|
|
|
83
98
|
tab.root.innerHTML = tab.fallback;
|
|
84
99
|
tab.root.style.cssText = "";
|
|
85
100
|
}
|
|
101
|
+
tab.root.style.color = "";
|
|
102
|
+
tab.root.style.color = tab.tint || (tab.text ? "#ff2d55" : "");
|
|
103
|
+
syncTabPulses();
|
|
86
104
|
if ("accessibilityLabel" in item)
|
|
87
105
|
if (item.accessibilityLabel)
|
|
88
106
|
tab.link.setAttribute("aria-label", item.accessibilityLabel);
|
|
@@ -162,10 +180,14 @@ export function createBrowserScreenBridge(platform, options) {
|
|
|
162
180
|
chromeRenderers.push(icon);
|
|
163
181
|
icon.render({ id: `tab_${tab.id}`, type: "Icon", props: { symbol: tab.symbol }, style: { width: 23, height: 23 }, events: {}, children: [] });
|
|
164
182
|
}
|
|
165
|
-
tabIcons.set(tab.id, { root: iconRoot, fallback: iconRoot.innerHTML, link });
|
|
166
183
|
const label = document.createElement("span");
|
|
167
184
|
label.textContent = tab.title;
|
|
185
|
+
label.style.fontVariantNumeric = "tabular-nums";
|
|
168
186
|
link.append(label);
|
|
187
|
+
link.setAttribute("data-testid", `craft-tab-${tab.id}`);
|
|
188
|
+
iconRoot.setAttribute("data-tab-icon", "");
|
|
189
|
+
label.setAttribute("data-tab-title", "");
|
|
190
|
+
tabIcons.set(tab.id, { root: iconRoot, fallback: iconRoot.innerHTML, link, label, title: tab.title, text: null, tint: null, pulse: !1, animation: null });
|
|
169
191
|
if (location.pathname.replace(/\/$/, "") === tab.id || tab.id !== rootPath && location.pathname.startsWith(`${tab.id}/`)) {
|
|
170
192
|
link.setAttribute("aria-current", "page");
|
|
171
193
|
link.style.color = "#007aff";
|
|
@@ -174,6 +196,10 @@ export function createBrowserScreenBridge(platform, options) {
|
|
|
174
196
|
}
|
|
175
197
|
tabs.hidden = !options.tabs?.length;
|
|
176
198
|
const navigateScreen = (screen, params, replace = !1) => {
|
|
199
|
+
if (replace && typeof screen === "string" && screen.startsWith("/") && !screen.startsWith("//")) {
|
|
200
|
+
platform.navigate(screen, !0);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
177
203
|
const route = Object.entries(options.routes).find(([, name]) => name === screen)?.[0];
|
|
178
204
|
if (!route)
|
|
179
205
|
throw Error(`No browser route for screen ${screen}`);
|
|
@@ -244,6 +270,9 @@ export function createBrowserScreenBridge(platform, options) {
|
|
|
244
270
|
pending.clear();
|
|
245
271
|
observer.disconnect();
|
|
246
272
|
media.removeEventListener("change", theme);
|
|
273
|
+
motion.removeEventListener("change", syncTabPulses);
|
|
274
|
+
for (const tab of tabIcons.values())
|
|
275
|
+
tab.animation?.cancel();
|
|
247
276
|
document.removeEventListener("visibilitychange", visibility);
|
|
248
277
|
stopEvents?.();
|
|
249
278
|
renderer.dispose();
|
|
@@ -255,10 +284,14 @@ export function createBrowserScreenBridge(platform, options) {
|
|
|
255
284
|
shell.remove();
|
|
256
285
|
listener = null;
|
|
257
286
|
}
|
|
258
|
-
}, visibility = () =>
|
|
287
|
+
}, visibility = () => {
|
|
288
|
+
syncTabPulses();
|
|
289
|
+
send("APP_STATE", { state: document.hidden ? "background" : "active" });
|
|
290
|
+
};
|
|
259
291
|
document.addEventListener("visibilitychange", visibility);
|
|
260
292
|
const media = matchMedia("(prefers-color-scheme: dark)");
|
|
261
293
|
media.addEventListener("change", theme);
|
|
294
|
+
motion.addEventListener("change", syncTabPulses);
|
|
262
295
|
const observer = new MutationObserver(theme);
|
|
263
296
|
observer.observe(document.documentElement, { attributes: !0, attributeFilter: ["class"] });
|
|
264
297
|
const stopEvents = platform.emit?.(send);
|
|
@@ -23,6 +23,17 @@ export declare interface NativeNavigationButton {
|
|
|
23
23
|
badgeStyle?: 'count' | 'dot'
|
|
24
24
|
onPress?: (event: { id: string }) => unknown
|
|
25
25
|
}
|
|
26
|
+
/** Update one tab without replacing its stack, symbol or selection. */
|
|
27
|
+
export declare interface NativeTabItemOptions {
|
|
28
|
+
id: string
|
|
29
|
+
title?: string | null
|
|
30
|
+
iconText?: string | null
|
|
31
|
+
iconTint?: string | null
|
|
32
|
+
iconPulse?: boolean
|
|
33
|
+
image?: string | null
|
|
34
|
+
badge?: string | null
|
|
35
|
+
accessibilityLabel?: string | null
|
|
36
|
+
}
|
|
26
37
|
export declare interface NativeNavigationOptions {
|
|
27
38
|
title?: string
|
|
28
39
|
largeTitle?: boolean
|
|
@@ -31,7 +42,7 @@ export declare interface NativeNavigationOptions {
|
|
|
31
42
|
leftButtons?: NativeNavigationButton[]
|
|
32
43
|
rightButtons?: NativeNavigationButton[]
|
|
33
44
|
tabAccessory?: { path: string, title: string, symbol: string, badge?: string | null, accessibilityLabel?: string } | null
|
|
34
|
-
tabItem?:
|
|
45
|
+
tabItem?: NativeTabItemOptions
|
|
35
46
|
}
|
|
36
47
|
export declare interface NativeNavigation {
|
|
37
48
|
push: (screen: string, params?: Record<string, unknown>) => string
|
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.551",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -123,12 +123,12 @@
|
|
|
123
123
|
"dependencies": {
|
|
124
124
|
"@stacksjs/ts-css": "^0.3.11",
|
|
125
125
|
"@stacksjs/clapp": "^0.2.16",
|
|
126
|
-
"@stacksjs/desktop": "0.2.
|
|
127
|
-
"@stacksjs/sanitizer": "0.2.
|
|
126
|
+
"@stacksjs/desktop": "0.2.551",
|
|
127
|
+
"@stacksjs/sanitizer": "0.2.551",
|
|
128
128
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
129
|
-
"bun-plugin-stx": "0.2.
|
|
129
|
+
"bun-plugin-stx": "0.2.551",
|
|
130
130
|
"bunfig": "^0.15.19",
|
|
131
|
-
"stx-router": "0.2.
|
|
131
|
+
"stx-router": "0.2.551",
|
|
132
132
|
"ts-broadcasting": "^0.0.11",
|
|
133
133
|
"ts-images": "^0.2.22",
|
|
134
134
|
"ts-syntax-highlighter": "^0.2.1"
|