@stacksjs/stx 0.2.535 → 0.2.536

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-vhfwnvmc.js";import"./chunk-bpr4bkde.js";import"./chunk-2bvk0qyd.js";import"./chunk-d7zterbp.js";import"./chunk-6v1gwdbv.js";import{W}from"./chunk-pwdvc964.js";import"./chunk-y18yvcjb.js";import"./chunk-tkvp3rz0.js";import"./chunk-v9vvzdag.js";import"./chunk-1es2y1jz.js";import"./chunk-1xgs9gd5.js";import"./chunk-x607yxrc.js";import"./chunk-33bzhsyw.js";import"./chunk-zzphh8g9.js";import"./chunk-tqnh98j7.js";import"./chunk-ty1v368m.js";import"./chunk-9a73re8k.js";import"./chunk-hvpzy98g.js";import"./chunk-2kvbg3t5.js";import"./chunk-z0h3we7z.js";import"./chunk-g12j8ahm.js";import"./chunk-f1cc1z85.js";import"./chunk-h51g1ydb.js";import"./chunk-p8qr0q85.js";import"./chunk-xab6b4mt.js";import"./chunk-8bt1mxny.js";import"./chunk-0dqxnx20.js";import"./chunk-33vbh6g3.js";import"./chunk-m5fw8jq1.js";import"./chunk-7g90r41h.js";import"./chunk-jsa2apk6.js";import"./chunk-xq7f1yc2.js";import"./chunk-yn3kp3qy.js";import"./chunk-qmza4327.js";import"./chunk-nd8v4xgb.js";import"./chunk-azb58ven.js";import{yt,bt}from"./chunk-nn66ek7z.js";import"./chunk-xz7dk3yc.js";import"./chunk-bk5g7qez.js";import"./chunk-90wh9zzy.js";import"./chunk-8m1y1kyr.js";import"./chunk-vjdj0ex3.js";import"./chunk-ngxqydsg.js";import"./chunk-jjwg83xv.js";import"./chunk-sh8ec2e0.js";import"./chunk-mx3rh8zj.js";import{Xs,Js,Ys,Zs,br,Qs,eo,to,wr,vr,_n,Tn,$n}from"./chunk-e6mmvwy9.js";import"./chunk-0yveptr0.js";import"./chunk-wk85dz07.js";import{xi}from"./chunk-bczcm7jk.js";import{p}from"./chunk-2a4szpje.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.535";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new V("stx");function B(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>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(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function z(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>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,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function H(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))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 m}async function L(h,m){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),m.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),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.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:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.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(`
3
+ import"./chunk-vhfwnvmc.js";import"./chunk-bpr4bkde.js";import"./chunk-2bvk0qyd.js";import"./chunk-d7zterbp.js";import"./chunk-6v1gwdbv.js";import{W}from"./chunk-pwdvc964.js";import"./chunk-y18yvcjb.js";import"./chunk-tkvp3rz0.js";import"./chunk-v9vvzdag.js";import"./chunk-1es2y1jz.js";import"./chunk-1xgs9gd5.js";import"./chunk-x607yxrc.js";import"./chunk-33bzhsyw.js";import"./chunk-zzphh8g9.js";import"./chunk-tqnh98j7.js";import"./chunk-ty1v368m.js";import"./chunk-9a73re8k.js";import"./chunk-hvpzy98g.js";import"./chunk-2kvbg3t5.js";import"./chunk-z0h3we7z.js";import"./chunk-g12j8ahm.js";import"./chunk-f1cc1z85.js";import"./chunk-h51g1ydb.js";import"./chunk-p8qr0q85.js";import"./chunk-xab6b4mt.js";import"./chunk-8bt1mxny.js";import"./chunk-0dqxnx20.js";import"./chunk-33vbh6g3.js";import"./chunk-m5fw8jq1.js";import"./chunk-7g90r41h.js";import"./chunk-jsa2apk6.js";import"./chunk-xq7f1yc2.js";import"./chunk-yn3kp3qy.js";import"./chunk-qmza4327.js";import"./chunk-nd8v4xgb.js";import"./chunk-azb58ven.js";import{yt,bt}from"./chunk-nn66ek7z.js";import"./chunk-xz7dk3yc.js";import"./chunk-bk5g7qez.js";import"./chunk-90wh9zzy.js";import"./chunk-8m1y1kyr.js";import"./chunk-vjdj0ex3.js";import"./chunk-ngxqydsg.js";import"./chunk-jjwg83xv.js";import"./chunk-sh8ec2e0.js";import"./chunk-mx3rh8zj.js";import{Xs,Js,Ys,Zs,br,Qs,eo,to,wr,vr,_n,Tn,$n}from"./chunk-e6mmvwy9.js";import"./chunk-0yveptr0.js";import"./chunk-wk85dz07.js";import{xi}from"./chunk-bczcm7jk.js";import{p}from"./chunk-2a4szpje.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.536";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new V("stx");function B(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>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(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function z(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>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,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function H(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))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 m}async function L(h,m){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),m.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),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.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:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.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],m={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);m.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")m.cache=!1;else if(t==="--native")m.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,m))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else _n(h,m).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-2qbvsvwc.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:
@@ -12,6 +12,18 @@ export class BrowserScreenRenderer {
12
12
  this.options = options;
13
13
  }
14
14
  render(tree) {
15
+ const ids = new Set, validate = (node) => {
16
+ if (!node.id || ids.has(node.id))
17
+ throw Error("Screen node ids must be unique and non-empty");
18
+ ids.add(node.id);
19
+ this.tag(node.type);
20
+ if (node.type === "Icon")
21
+ this.icon(node.props);
22
+ for (const child of node.children)
23
+ if (typeof child !== "string")
24
+ validate(child);
25
+ };
26
+ validate(tree);
15
27
  this.dispose();
16
28
  const create = (node, parent) => {
17
29
  if (!node.id)
@@ -64,7 +76,7 @@ export class BrowserScreenRenderer {
64
76
  this.revision = batch.revision;
65
77
  }
66
78
  validate(operations) {
67
- const parents = new Map([...this.nodes].map(([id, node]) => [id, node.parent])), children = new Map([...this.nodes].map(([id, node]) => [id, [...node.children]])), remove = (id) => {
79
+ const parents = new Map([...this.nodes].map(([id, node]) => [id, node.parent])), children = new Map([...this.nodes].map(([id, node]) => [id, [...node.children]])), descriptors = new Map([...this.nodes].map(([id, node]) => [id, { type: node.type, props: { ...node.props } }])), remove = (id) => {
68
80
  for (const child of children.get(id) ?? [])
69
81
  remove(child);
70
82
  parents.delete(id);
@@ -74,6 +86,10 @@ export class BrowserScreenRenderer {
74
86
  if (operation.op === "createNode") {
75
87
  if (parents.has(operation.id) || !this.tag(operation.node.type))
76
88
  throw Error(`Invalid create: ${operation.id}`);
89
+ const props = operation.node.props ?? {};
90
+ if (operation.node.type === "Icon")
91
+ this.icon(props);
92
+ descriptors.set(operation.id, { type: operation.node.type, props: { ...props } });
77
93
  parents.set(operation.id, null);
78
94
  children.set(operation.id, []);
79
95
  } else if (operation.op === "insertChild" || operation.op === "moveChild") {
@@ -103,8 +119,14 @@ export class BrowserScreenRenderer {
103
119
  if (parent)
104
120
  children.set(parent, children.get(parent).filter((id) => id !== operation.id));
105
121
  remove(operation.id);
106
- } else if (operation.patch.children && children.get(operation.id).length)
107
- throw Error("Cannot replace structural children with text");
122
+ } else {
123
+ if (operation.patch.children && children.get(operation.id).length)
124
+ throw Error("Cannot replace structural children with text");
125
+ const descriptor = descriptors.get(operation.id);
126
+ Object.assign(descriptor.props, operation.patch.props);
127
+ if (descriptor.type === "Icon")
128
+ this.icon(descriptor.props);
129
+ }
108
130
  }
109
131
  }
110
132
  tag(type) {
@@ -123,6 +145,8 @@ export class BrowserScreenRenderer {
123
145
  return record;
124
146
  }
125
147
  fire(record, name, payload = {}) {
148
+ if (record.props.disabled && ["onPress", "onLongPress", "onPressIn", "onPressOut"].includes(name))
149
+ return;
126
150
  const handler = record.events[name];
127
151
  if (handler)
128
152
  this.options.event(handler, payload);
@@ -410,15 +434,12 @@ export class BrowserScreenRenderer {
410
434
  if (type === "StatusBar")
411
435
  css.display = "none";
412
436
  if (type === "Icon") {
413
- const name = String(props.iconify ?? props.name ?? props.symbol ?? ""), icon = this.options.icons?.[SYMBOL_TO_ICON[name]] ?? this.options.icons?.[name] ?? this.options.icons?.[name.replace(/^i-lucide-/, "")] ?? this.options.icons?.[String(props.symbol)];
414
- if (icon) {
415
- css.backgroundColor = "currentColor";
416
- const data = `<svg xmlns="${SVG_NS}" viewBox="0 0 ${icon.width ?? 24} ${icon.height ?? 24}">${icon.body}</svg>`;
417
- css.mask = `url("data:image/svg+xml,${encodeURIComponent(data)}") center / contain no-repeat`;
418
- css.webkitMask = css.mask;
419
- element.setAttribute("aria-hidden", props.accessibilityLabel ? "false" : "true");
420
- } else
421
- throw Error(`No browser icon registered for ${name}`);
437
+ const icon = this.icon(props);
438
+ css.backgroundColor = "currentColor";
439
+ const data = `<svg xmlns="${SVG_NS}" viewBox="0 0 ${icon.width ?? 24} ${icon.height ?? 24}">${icon.body}</svg>`;
440
+ css.mask = `url("data:image/svg+xml,${encodeURIComponent(data)}") center / contain no-repeat`;
441
+ css.webkitMask = css.mask;
442
+ element.setAttribute("aria-hidden", props.accessibilityLabel ? "false" : "true");
422
443
  }
423
444
  if (type === "Text" && props.numberOfLines) {
424
445
  css.overflow = "hidden";
@@ -448,6 +469,12 @@ export class BrowserScreenRenderer {
448
469
  }
449
470
  }
450
471
  }
472
+ icon(props) {
473
+ const name = String(props.iconify ?? props.name ?? props.symbol ?? ""), icon = this.options.icons?.[SYMBOL_TO_ICON[name]] ?? this.options.icons?.[name] ?? this.options.icons?.[name.replace(/^i-lucide-/, "")] ?? this.options.icons?.[String(props.symbol)];
474
+ if (!icon)
475
+ throw Error(`No browser icon registered for ${name}`);
476
+ return icon;
477
+ }
451
478
  style(css, values) {
452
479
  const set = (key, value) => {
453
480
  const property = key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
@@ -30,7 +30,35 @@ export function createBrowserScreenBridge(platform, options) {
30
30
  shell.style.color = dark ? "#ffffff" : "#1c1c1e";
31
31
  bridge.colorScheme = dark ? "dark" : "light";
32
32
  send("APPEARANCE", { colorScheme: bridge.colorScheme });
33
- }, navigation = (settings) => {
33
+ };
34
+ let currentNavigation = {};
35
+ const tabIcons = new Map, navigation = (patch) => {
36
+ currentNavigation = { ...currentNavigation, ...patch };
37
+ const settings = currentNavigation, item = patch.tabItem, tab = item?.id ? tabIcons.get(item.id) : null;
38
+ if (tab && item) {
39
+ if ("image" in item && item.image && /^https:\/\//.test(item.image)) {
40
+ const image = document.createElement("img");
41
+ image.src = item.image;
42
+ image.alt = "";
43
+ image.style.cssText = "width:27px;height:27px;border-radius:50%;object-fit:cover";
44
+ image.onerror = () => {
45
+ tab.root.innerHTML = tab.fallback;
46
+ };
47
+ tab.root.replaceChildren(image);
48
+ } else if ("iconText" in item || "image" in item)
49
+ if (item.iconText) {
50
+ tab.root.textContent = item.iconText.slice(0, 8);
51
+ tab.root.style.cssText = "font-size:23px;font-weight:650;font-variant-numeric:tabular-nums;color:#ff2d55;line-height:27px";
52
+ } else {
53
+ tab.root.innerHTML = tab.fallback;
54
+ tab.root.style.cssText = "";
55
+ }
56
+ if ("accessibilityLabel" in item)
57
+ if (item.accessibilityLabel)
58
+ tab.link.setAttribute("aria-label", item.accessibilityLabel);
59
+ else
60
+ tab.link.removeAttribute("aria-label");
61
+ }
34
62
  const title = typeof settings.title === "string" ? settings.title : options.title ?? "";
35
63
  if (title)
36
64
  document.title = title;
@@ -100,6 +128,7 @@ export function createBrowserScreenBridge(platform, options) {
100
128
  chromeRenderers.push(icon);
101
129
  icon.render({ id: `tab_${tab.id}`, type: "Icon", props: { symbol: tab.symbol }, style: { width: 23, height: 23 }, events: {}, children: [] });
102
130
  }
131
+ tabIcons.set(tab.id, { root: iconRoot, fallback: iconRoot.innerHTML, link });
103
132
  const label = document.createElement("span");
104
133
  label.textContent = tab.title;
105
134
  link.append(label);
@@ -28,6 +28,7 @@ export declare interface NativeNavigationOptions {
28
28
  hidden?: boolean
29
29
  backTitle?: string
30
30
  rightButtons?: NativeNavigationButton[]
31
+ tabItem?: { id: string, iconText?: string | null, image?: string | null, badge?: string | null, accessibilityLabel?: string | null }
31
32
  }
32
33
  export declare interface NativeNavigation {
33
34
  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.535",
4
+ "version": "0.2.536",
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.535",
127
- "@stacksjs/sanitizer": "0.2.535",
126
+ "@stacksjs/desktop": "0.2.536",
127
+ "@stacksjs/sanitizer": "0.2.536",
128
128
  "@stacksjs/ts-i18n": "^0.1.11",
129
- "bun-plugin-stx": "0.2.535",
129
+ "bun-plugin-stx": "0.2.536",
130
130
  "bunfig": "^0.15.19",
131
- "stx-router": "0.2.535",
131
+ "stx-router": "0.2.536",
132
132
  "ts-broadcasting": "^0.0.11",
133
133
  "ts-images": "^0.2.22",
134
134
  "ts-syntax-highlighter": "^0.2.1"