@stacksjs/stx 0.2.580 → 0.2.582

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-7hkc96de.js";import"./chunk-ah9xyss2.js";import"./chunk-yhpyqsbr.js";import"./chunk-zk2xk0wd.js";import"./chunk-vpdx7qr3.js";import{G}from"./chunk-faghmmrs.js";import"./chunk-43h8q2cm.js";import"./chunk-ayy9mmrw.js";import"./chunk-be2ba3hj.js";import"./chunk-eww6sdzz.js";import"./chunk-qdyp2zqf.js";import"./chunk-jtbzmbzz.js";import"./chunk-nrfh7gaa.js";import"./chunk-3wy8q3aq.js";import"./chunk-117xss52.js";import"./chunk-sv5nvfmb.js";import"./chunk-w3rmepwy.js";import"./chunk-h0a2s340.js";import"./chunk-k9th7hc4.js";import"./chunk-4rkvwm6v.js";import"./chunk-0vnngvy1.js";import"./chunk-tszkg6sj.js";import"./chunk-71sdgv7e.js";import"./chunk-ta3wn842.js";import"./chunk-s12bnv32.js";import"./chunk-djft0m5h.js";import"./chunk-5kh5ehfh.js";import"./chunk-dvgvvy5b.js";import"./chunk-wwj8zbzc.js";import"./chunk-yy3ser06.js";import"./chunk-6w2yqtrd.js";import"./chunk-yfq2v7x5.js";import"./chunk-9jh2ake5.js";import"./chunk-1r1maqep.js";import"./chunk-ev5f79mg.js";import"./chunk-ktyctev3.js";import{bt,wt}from"./chunk-kp0hg06s.js";import"./chunk-vx75fb0d.js";import"./chunk-y8q1n7hx.js";import"./chunk-0k5faspy.js";import"./chunk-qccgncp2.js";import"./chunk-t8wpzqs4.js";import"./chunk-g4crr86j.js";import"./chunk-6z3e1tyz.js";import"./chunk-rr8a7d4q.js";import"./chunk-cb2pyg5t.js";import{no,ro,so,oo,Cr,io,ao,co,_r,Er,In,On,Dn}from"./chunk-c1r7zq0q.js";import"./chunk-j1nqnmcd.js";import"./chunk-bj29pwm0.js";import{Ti}from"./chunk-cdgwkzms.js";import{u}from"./chunk-cg8hg6cs.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import s from"process";import{CLI as W}from"@stacksjs/clapp";var j="0.2.580";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new W("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((n)=>n.toLowerCase().includes(t.toLowerCase().substring(0,3))||n.endsWith(".stx")||n.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("["),V=(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}`);s.exit(p)}function U(h){if(!h)return;let p;try{p=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),s.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"}'`),s.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`),s.exit(1);return p}async function H(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={...s.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(),n=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{n.on("close",(r)=>{let d=((performance.now()-i)/1000).toFixed(2);if(r===0)c(!0);else c(!1)}),s.on("SIGINT",()=>{console.log(`
3
+ import"./chunk-7hkc96de.js";import"./chunk-ah9xyss2.js";import"./chunk-yhpyqsbr.js";import"./chunk-zk2xk0wd.js";import"./chunk-vpdx7qr3.js";import{G}from"./chunk-faghmmrs.js";import"./chunk-43h8q2cm.js";import"./chunk-ayy9mmrw.js";import"./chunk-be2ba3hj.js";import"./chunk-eww6sdzz.js";import"./chunk-qdyp2zqf.js";import"./chunk-jtbzmbzz.js";import"./chunk-nrfh7gaa.js";import"./chunk-3wy8q3aq.js";import"./chunk-117xss52.js";import"./chunk-sv5nvfmb.js";import"./chunk-w3rmepwy.js";import"./chunk-h0a2s340.js";import"./chunk-k9th7hc4.js";import"./chunk-4rkvwm6v.js";import"./chunk-0vnngvy1.js";import"./chunk-tszkg6sj.js";import"./chunk-71sdgv7e.js";import"./chunk-ta3wn842.js";import"./chunk-s12bnv32.js";import"./chunk-djft0m5h.js";import"./chunk-5kh5ehfh.js";import"./chunk-dvgvvy5b.js";import"./chunk-wwj8zbzc.js";import"./chunk-yy3ser06.js";import"./chunk-6w2yqtrd.js";import"./chunk-yfq2v7x5.js";import"./chunk-9jh2ake5.js";import"./chunk-1r1maqep.js";import"./chunk-ev5f79mg.js";import"./chunk-ktyctev3.js";import{bt,wt}from"./chunk-kp0hg06s.js";import"./chunk-vx75fb0d.js";import"./chunk-y8q1n7hx.js";import"./chunk-0k5faspy.js";import"./chunk-qccgncp2.js";import"./chunk-t8wpzqs4.js";import"./chunk-g4crr86j.js";import"./chunk-6z3e1tyz.js";import"./chunk-rr8a7d4q.js";import"./chunk-cb2pyg5t.js";import{no,ro,so,oo,Cr,io,ao,co,_r,Er,In,On,Dn}from"./chunk-c1r7zq0q.js";import"./chunk-j1nqnmcd.js";import"./chunk-bj29pwm0.js";import{Ti}from"./chunk-cdgwkzms.js";import{u}from"./chunk-cg8hg6cs.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import s from"process";import{CLI as W}from"@stacksjs/clapp";var j="0.2.582";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new W("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((n)=>n.toLowerCase().includes(t.toLowerCase().substring(0,3))||n.endsWith(".stx")||n.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("["),V=(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}`);s.exit(p)}function U(h){if(!h)return;let p;try{p=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),s.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"}'`),s.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`),s.exit(1);return p}async function H(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={...s.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(),n=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{n.on("close",(r)=>{let d=((performance.now()-i)/1000).toFixed(2);if(r===0)c(!0);else c(!1)}),s.on("SIGINT",()=>{console.log(`
4
4
  Test run interrupted`),n.kill("SIGINT"),s.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var L=s.argv.length>=3&&(V(s.argv[2])&&S.existsSync(s.argv[2])||O(s.argv[2]));if(L){let h=s.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<s.argv.length;x++){let t=s.argv[x];if(t==="--port"&&x+1<s.argv.length){let e=B(s.argv[++x]);if(!e.isValid)F(e);p.port=Number.parseInt(s.argv[x],10)}else if(t==="--no-watch")p.watch=!1;else if(t==="--highlight-theme"&&x+1<s.argv.length){if(!p.markdown)p.markdown={};if(!p.markdown.syntaxHighlighting)p.markdown.syntaxHighlighting={};p.markdown.syntaxHighlighting.defaultTheme=s.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((n)=>n.endsWith(".stx")):h.endsWith(".md")?x.filter((n)=>n.endsWith(".md")):x.filter((n)=>n.endsWith(".stx")||n.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let n=new Bun.Glob("**/*.stx"),r=(await Array.fromAsync(n.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}`),s.exit(1);if(!await On(t,p))s.exit(1)}catch(x){console.error("Failed to process files:",x),s.exit(1)}else In(h,p).catch((x)=>{console.error("Failed to start dev server:",x),s.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 n=1;n<=t.length;n++)if(e.charAt(i-1)===t.charAt(n-1))o[i][n]=o[i-1][n-1];else o[i][n]=Math.min(o[i-1][n-1]+1,o[i][n-1]+1,o[i-1][n]+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 oo(t))console.log("Documentation generated successfully."),s.exit(0);else console.error("Documentation generation failed."),s.exit(1)}catch(e){console.error("Error generating documentation:",e),s.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 n=await o(),c=Object.entries(n).sort((r,l)=>l[1].total-r[1].total);console.log(`Available collections:
@@ -51,8 +51,11 @@ export declare interface NativeScreenOptions {
51
51
  native?: (module: string, method: string, args: unknown[]) => unknown
52
52
  files?: { pickImage: { path: string, name: string, type: string, size: number } | null }
53
53
  secureStorage?: Record<string, string>
54
+ sessionTokenKey?: string
55
+ sessionEvents?: boolean
54
56
  keychain?: Record<string, string>
55
57
  storage?: Record<string, unknown>
58
+ onHostRead?: (namespace: 'secureStorage' | 'storage' | 'snapshots', key: string) => void
56
59
  offline?: () => boolean
57
60
  stream?: (path: string) => StatusAnswer | undefined
58
61
  globals?: Record<string, unknown>
@@ -98,6 +101,7 @@ export declare interface NativeScreen {
98
101
  disappear: () => void
99
102
  newParams: (params: Record<string, unknown>) => void
100
103
  craftEvent: (event: string, detail?: unknown) => void
104
+ setSessionToken: (token: string | null) => void
101
105
  keepSnapshot: (name: string, value?: unknown) => void
102
106
  setOnline: (online: boolean) => void
103
107
  send: (type: string, payload?: Record<string, unknown>) => void
@@ -69,7 +69,13 @@ export function mountNativeScreen(code, screen, options = {}) {
69
69
  intervals.delete(id);
70
70
  clearInterval(id);
71
71
  }
72
- }, apiBase = options.apiBase || "", label = options.requestLabel || ((method, at, init) => `${method} ${at}${init.headers && Object.keys(init.headers).some((name) => name.toLowerCase() === "authorization") ? "" : " (guest)"}`), nodes = new Map, messages = [], requests = [], headers = [], opened = [], replaced = [], moves = [], stored = copy(options.storage ?? {}), natives = [], animations = [], streams = [], secureStorage = { ...options.keychain, ...options.secureStorage }, bars = [], alerts = [], picks = [], removed = [], snapshots = { ...options.snapshots };
72
+ }, apiBase = options.apiBase || "", label = options.requestLabel || ((method, at, init) => `${method} ${at}${init.headers && Object.keys(init.headers).some((name) => name.toLowerCase() === "authorization") ? "" : " (guest)"}`), nodes = new Map, messages = [], requests = [], headers = [], opened = [], replaced = [], moves = [], stored = copy(options.storage ?? {}), natives = [], animations = [], streams = [], secureStorage = { ...options.keychain, ...options.secureStorage }, sessionTokenKey = options.sessionTokenKey ?? "auth.token", sessionWritten = (key, previous) => {
73
+ if (key !== sessionTokenKey || options.sessionEvents === !1)
74
+ return;
75
+ const token = secureStorage[key] || null;
76
+ if (token !== (previous || null))
77
+ send("SESSION_CHANGED", { key, token, previous: previous || null });
78
+ }, bars = [], alerts = [], picks = [], removed = [], snapshots = { ...options.snapshots };
73
79
  let receive = () => {};
74
80
  const visit = (node) => {
75
81
  nodes.set(node.id, node);
@@ -163,9 +169,17 @@ export function mountNativeScreen(code, screen, options = {}) {
163
169
  }
164
170
  },
165
171
  craft: {
166
- secureStorage: { getSync: (key) => secureStorage[key] ?? null },
172
+ secureStorage: {
173
+ getSync: (key) => {
174
+ options.onHostRead?.("secureStorage", key);
175
+ return secureStorage[key] ?? null;
176
+ }
177
+ },
167
178
  storage: {
168
- getSync: (key) => (key in stored) ? copy(stored[key]) : null,
179
+ getSync: (key) => {
180
+ options.onHostRead?.("storage", key);
181
+ return key in stored ? copy(stored[key]) : null;
182
+ },
169
183
  setSync: (key, value) => {
170
184
  if (value === null || value === void 0)
171
185
  delete stored[key];
@@ -174,7 +188,10 @@ export function mountNativeScreen(code, screen, options = {}) {
174
188
  }
175
189
  },
176
190
  snapshots: {
177
- get: (name) => snapshots[name] ?? null,
191
+ get: (name) => {
192
+ options.onHostRead?.("snapshots", name);
193
+ return snapshots[name] ?? null;
194
+ },
178
195
  set: async (name, value) => {
179
196
  await options.snapshotWrite?.(name, value);
180
197
  if (value === null || value === void 0)
@@ -230,6 +247,7 @@ export function mountNativeScreen(code, screen, options = {}) {
230
247
  appURL: options.appURL ?? "https://fixture.invalid/m",
231
248
  appVersion: options.appVersion ?? "1.0.0",
232
249
  appBuild: options.appBuild ?? "1",
250
+ sessionTokenKey,
233
251
  postMessage: (raw) => {
234
252
  const message = JSON.parse(raw);
235
253
  messages.push(JSON.parse(raw));
@@ -284,14 +302,17 @@ export function mountNativeScreen(code, screen, options = {}) {
284
302
  natives.push(`${request.module}.${request.method}`);
285
303
  Promise.resolve().then(async () => {
286
304
  const answer = await options.native?.(request.module, request.method, request.args);
305
+ if (ended)
306
+ return null;
287
307
  if (request.module === "SecureStorage" && ["set", "remove"].includes(request.method)) {
288
308
  if (answer === !1)
289
309
  return !1;
290
- const key = String(request.args[0]);
310
+ const key = String(request.args[0]), previous = secureStorage[key];
291
311
  if (request.method === "set")
292
312
  secureStorage[key] = String(request.args[1]);
293
313
  else
294
314
  delete secureStorage[key];
315
+ sessionWritten(key, previous);
295
316
  return !0;
296
317
  }
297
318
  if (request.module === "Storage" && request.method === "set") {
@@ -376,9 +397,9 @@ export function mountNativeScreen(code, screen, options = {}) {
376
397
  texts: () => all().flatMap((node) => node.children.filter((child) => typeof child === "string")),
377
398
  press,
378
399
  type: (node, text) => press(node, "onChangeText", { text }),
379
- barButtons: () => (bars.at(-1)?.rightButtons || []).map((button) => button.id),
400
+ barButtons: () => (bars.findLast((bar) => bar.rightButtons !== void 0)?.rightButtons || []).map((button) => button.id),
380
401
  tapBar: (id) => {
381
- if (!(bars.at(-1)?.rightButtons || []).some((button) => button.id === id))
402
+ if (!(bars.findLast((bar) => bar.rightButtons !== void 0)?.rightButtons || []).some((button) => button.id === id))
382
403
  throw Error(`no bar button ${id}`);
383
404
  send("NAV_BUTTON", { id });
384
405
  },
@@ -390,6 +411,14 @@ export function mountNativeScreen(code, screen, options = {}) {
390
411
  disappear: () => send("SCREEN_FOCUS", { focused: !1 }),
391
412
  newParams: (params) => send("ROUTE_PARAMS", { params }),
392
413
  craftEvent: (event, detail) => send("CRAFT_EVENT", { event, detail }),
414
+ setSessionToken: (token) => {
415
+ const previous = secureStorage[sessionTokenKey];
416
+ if (token)
417
+ secureStorage[sessionTokenKey] = token;
418
+ else
419
+ delete secureStorage[sessionTokenKey];
420
+ sessionWritten(sessionTokenKey, previous);
421
+ },
393
422
  keepSnapshot: (name, value) => {
394
423
  if (value === null)
395
424
  delete snapshots[name];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.580",
4
+ "version": "0.2.582",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -128,12 +128,12 @@
128
128
  "dependencies": {
129
129
  "@stacksjs/ts-css": "^0.3.11",
130
130
  "@stacksjs/clapp": "^0.2.16",
131
- "@stacksjs/desktop": "0.2.580",
132
- "@stacksjs/sanitizer": "0.2.580",
131
+ "@stacksjs/desktop": "0.2.582",
132
+ "@stacksjs/sanitizer": "0.2.582",
133
133
  "@stacksjs/ts-i18n": "^0.1.11",
134
- "bun-plugin-stx": "0.2.580",
134
+ "bun-plugin-stx": "0.2.582",
135
135
  "bunfig": "^0.15.21",
136
- "stx-router": "0.2.580",
136
+ "stx-router": "0.2.582",
137
137
  "ts-broadcasting": "^0.0.11",
138
138
  "ts-images": "^0.2.22",
139
139
  "ts-syntax-highlighter": "^0.2.1"