@stacksjs/stx 0.2.494 → 0.2.497
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-2pph3dh0.js";import"./chunk-c57j92td.js";import"./chunk-rmavqxd8.js";import"./chunk-v7vkqg8f.js";import"./chunk-d4k4nyj0.js";import{U}from"./chunk-m9nr12a1.js";import"./chunk-b77v56fz.js";import"./chunk-qmcmjdy7.js";import"./chunk-1erc0vrb.js";import"./chunk-81t6zr3m.js";import"./chunk-e6y6s7q8.js";import"./chunk-kp4mzspk.js";import"./chunk-cp7hph6f.js";import"./chunk-0egg3666.js";import"./chunk-298s08st.js";import"./chunk-67actssw.js";import"./chunk-z9tvn738.js";import"./chunk-z9fz5dby.js";import"./chunk-vtn0gmen.js";import"./chunk-71bbv43t.js";import"./chunk-stvqwzen.js";import"./chunk-25m2wqsd.js";import"./chunk-rhrv2j36.js";import"./chunk-h6q8jafh.js";import"./chunk-93sr9q8g.js";import"./chunk-01rz8h7x.js";import"./chunk-40jd0b4h.js";import"./chunk-1v86h5vn.js";import"./chunk-4mrgy3ve.js";import"./chunk-tdetcthb.js";import"./chunk-b5mcvm6y.js";import"./chunk-1c407nky.js";import"./chunk-3s9s1mdt.js";import"./chunk-s9mq9x2k.js";import"./chunk-2hc5mbw8.js";import{mt,ht}from"./chunk-dve4q9tg.js";import"./chunk-15w4adyd.js";import"./chunk-zqxqdns1.js";import"./chunk-vp827ah7.js";import"./chunk-3mynjdqr.js";import"./chunk-vg9dyc4y.js";import"./chunk-zv0vgamy.js";import"./chunk-8fb1mqw1.js";import"./chunk-33snwgdy.js";import"./chunk-4ssg2hn4.js";import{Ks,Xs,Gs,Js,hr,Ys,Zs,Qs,yr,br,Cn,$n,En}from"./chunk-b90y5phw.js";import"./chunk-8qdvhbv7.js";import"./chunk-er7y8hk9.js";import{yi}from"./chunk-szry3s17.js";import{u}from"./chunk-cg8hg6cs.js";import{spawn as R}from"child_process";import S from"fs";import M from"os";import f from"path";import n from"process";import{CLI as V}from"@stacksjs/clapp";var j="0.2.
|
|
3
|
+
import"./chunk-2pph3dh0.js";import"./chunk-c57j92td.js";import"./chunk-rmavqxd8.js";import"./chunk-v7vkqg8f.js";import"./chunk-d4k4nyj0.js";import{U}from"./chunk-m9nr12a1.js";import"./chunk-b77v56fz.js";import"./chunk-qmcmjdy7.js";import"./chunk-1erc0vrb.js";import"./chunk-81t6zr3m.js";import"./chunk-e6y6s7q8.js";import"./chunk-kp4mzspk.js";import"./chunk-cp7hph6f.js";import"./chunk-0egg3666.js";import"./chunk-298s08st.js";import"./chunk-67actssw.js";import"./chunk-z9tvn738.js";import"./chunk-z9fz5dby.js";import"./chunk-vtn0gmen.js";import"./chunk-71bbv43t.js";import"./chunk-stvqwzen.js";import"./chunk-25m2wqsd.js";import"./chunk-rhrv2j36.js";import"./chunk-h6q8jafh.js";import"./chunk-93sr9q8g.js";import"./chunk-01rz8h7x.js";import"./chunk-40jd0b4h.js";import"./chunk-1v86h5vn.js";import"./chunk-4mrgy3ve.js";import"./chunk-tdetcthb.js";import"./chunk-b5mcvm6y.js";import"./chunk-1c407nky.js";import"./chunk-3s9s1mdt.js";import"./chunk-s9mq9x2k.js";import"./chunk-2hc5mbw8.js";import{mt,ht}from"./chunk-dve4q9tg.js";import"./chunk-15w4adyd.js";import"./chunk-zqxqdns1.js";import"./chunk-vp827ah7.js";import"./chunk-3mynjdqr.js";import"./chunk-vg9dyc4y.js";import"./chunk-zv0vgamy.js";import"./chunk-8fb1mqw1.js";import"./chunk-33snwgdy.js";import"./chunk-4ssg2hn4.js";import{Ks,Xs,Gs,Js,hr,Ys,Zs,Qs,yr,br,Cn,$n,En}from"./chunk-b90y5phw.js";import"./chunk-8qdvhbv7.js";import"./chunk-er7y8hk9.js";import{yi}from"./chunk-szry3s17.js";import{u}from"./chunk-cg8hg6cs.js";import{spawn as R}from"child_process";import S from"fs";import M from"os";import f from"path";import n from"process";import{CLI as V}from"@stacksjs/clapp";var j="0.2.497";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("["),H=(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 L(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 G(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.join(M.tmpdir(),`stx-test-report-${Date.now()}.xml`);x.push("--reporter",p.reporter),x.push("--reporter-outfile",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&&(H(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 $n(t,p))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else Cn(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 Js(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:
|
|
@@ -120,12 +120,12 @@ export declare interface EventPayload {
|
|
|
120
120
|
force?: number
|
|
121
121
|
identifier: number
|
|
122
122
|
}>
|
|
123
|
-
contentOffset?: { x: number
|
|
124
|
-
contentSize?: { width: number
|
|
125
|
-
layoutMeasurement?: { width: number
|
|
123
|
+
contentOffset?: { x: number, y: number }
|
|
124
|
+
contentSize?: { width: number, height: number }
|
|
125
|
+
layoutMeasurement?: { width: number, height: number }
|
|
126
126
|
text?: string
|
|
127
|
-
selection?: { start: number
|
|
128
|
-
layout?: { x: number
|
|
127
|
+
selection?: { start: number, end: number }
|
|
128
|
+
layout?: { x: number, y: number, width: number, height: number }
|
|
129
129
|
[key: string]: unknown
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -283,6 +283,7 @@ export type BridgeMessageType = | 'RENDER' // Render a new componen
|
|
|
283
283
|
| 'PUSH_TOKEN' // A new push device token
|
|
284
284
|
| 'SOUND_EVENT' // A craft.audio sound ended or failed
|
|
285
285
|
| 'NETWORK_STREAM' // A piece, the end or the failure of a streaming fetch
|
|
286
|
+
| 'CRAFT_EVENT' // A host event in the page's name (craftLocationUpdate)
|
|
286
287
|
| 'MEMORY_WARNING' // Low memory warning
|
|
287
288
|
|
|
288
289
|
// API
|
|
@@ -325,12 +326,13 @@ export declare class STXBridge {
|
|
|
325
326
|
on<T>(type: BridgeMessageType, handler: MessageHandler<T>): () => void;
|
|
326
327
|
once<T>(type: BridgeMessageType, handler: MessageHandler<T>): () => void;
|
|
327
328
|
dispose(reason?: ApiCancelPayload['reason']): void;
|
|
328
|
-
render(document: import('../compiler/ir').STXDocument | import('../compiler/ir').STXNode, options?: { containerId?: string
|
|
329
|
+
render(document: import('../compiler/ir').STXDocument | import('../compiler/ir').STXNode, options?: { containerId?: string, mode?: 'replace' | 'append' | 'prepend' }): string;
|
|
329
330
|
mutate(payload: NativeMutationPayload): string;
|
|
330
331
|
update(updates: UpdatePayload['updates']): string;
|
|
331
332
|
remove(keys: string[]): string;
|
|
332
333
|
navigate(screen: string, params?: Record<string, unknown>, animation?: NavigatePayload['animation']): string;
|
|
333
334
|
goBack(): string;
|
|
335
|
+
popToRoot(): string;
|
|
334
336
|
callNativeAPI<T>(module: string, method: string, ...args: unknown[]): Promise<T>;
|
|
335
337
|
callPersonFacingAPI<T>(module: string, method: string, ...args: unknown[]): Promise<T>;
|
|
336
338
|
log(level: 'info' | 'warn' | 'error', message: string, data?: unknown): void;
|
|
@@ -105,6 +105,9 @@ export class STXBridge {
|
|
|
105
105
|
goBack() {
|
|
106
106
|
return this.send("NAVIGATE_BACK", {});
|
|
107
107
|
}
|
|
108
|
+
popToRoot() {
|
|
109
|
+
return this.send("NAVIGATE_POP_TO_ROOT", {});
|
|
110
|
+
}
|
|
108
111
|
async callNativeAPI(module, method, ...args) {
|
|
109
112
|
return this.request("API_REQUEST", {
|
|
110
113
|
version: 1,
|
|
@@ -13,13 +13,16 @@ function capabilityFlags(capabilities) {
|
|
|
13
13
|
storage: capabilities.has("storage"),
|
|
14
14
|
localDatabase: capabilities.has("database"),
|
|
15
15
|
lifecycle: capabilities.has("lifecycle"),
|
|
16
|
-
geolocation:
|
|
16
|
+
geolocation: capabilities.has("geolocation"),
|
|
17
|
+
music: capabilities.has("music"),
|
|
17
18
|
clipboard: capabilities.has("clipboard"),
|
|
18
19
|
contacts: !1,
|
|
19
20
|
calendar: !1,
|
|
20
21
|
localNotifications: capabilities.has("notifications"),
|
|
21
22
|
inAppPurchase: !1,
|
|
22
|
-
keepAwake:
|
|
23
|
+
keepAwake: capabilities.has("keepAwake"),
|
|
24
|
+
brightness: capabilities.has("brightness"),
|
|
25
|
+
statusBar: capabilities.has("statusBar"),
|
|
23
26
|
orientationLock: !1,
|
|
24
27
|
deepLinks: capabilities.has("deepLinks"),
|
|
25
28
|
flashlight: !1,
|
|
@@ -211,6 +214,69 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
211
214
|
handlers.error.forEach((handler) => handler(String(payload?.message || "The sound could not be played")));
|
|
212
215
|
});
|
|
213
216
|
}
|
|
217
|
+
if (capabilities.has("keepAwake"))
|
|
218
|
+
craft.setKeepAwake = (enabled) => request("KeepAwake", "set", [enabled !== !1]);
|
|
219
|
+
if (capabilities.has("brightness")) {
|
|
220
|
+
craft.getBrightness = () => request("Brightness", "get", []);
|
|
221
|
+
craft.setBrightness = (level) => request("Brightness", "set", [Number(level)]);
|
|
222
|
+
}
|
|
223
|
+
if (capabilities.has("statusBar"))
|
|
224
|
+
craft.statusBar = { setStyle: (style) => request("StatusBar", "setStyle", [style]) };
|
|
225
|
+
if (capabilities.has("geolocation")) {
|
|
226
|
+
const watchers = new Map;
|
|
227
|
+
let nextWatch = 0;
|
|
228
|
+
const unwatched = () => {
|
|
229
|
+
if (watchers.size === 0)
|
|
230
|
+
request("Location", "clearWatch", []).catch(() => {});
|
|
231
|
+
};
|
|
232
|
+
craft.location = {
|
|
233
|
+
getCurrentPosition: (options = {}) => ask("Location", "getCurrentPosition", [options]),
|
|
234
|
+
watchPosition: (callback, options = {}) => {
|
|
235
|
+
if (typeof callback !== "function")
|
|
236
|
+
throw TypeError("location.watchPosition needs a function");
|
|
237
|
+
const id = ++nextWatch, first = watchers.size === 0;
|
|
238
|
+
watchers.set(id, callback);
|
|
239
|
+
if (first)
|
|
240
|
+
ask("Location", "watchPosition", [options]).catch(() => {});
|
|
241
|
+
return id;
|
|
242
|
+
},
|
|
243
|
+
clearWatch: (id) => {
|
|
244
|
+
if (id === void 0)
|
|
245
|
+
watchers.clear();
|
|
246
|
+
else if (!watchers.delete(id))
|
|
247
|
+
return;
|
|
248
|
+
unwatched();
|
|
249
|
+
},
|
|
250
|
+
startRecording: (options = {}) => ask("Location", "startRecording", [options]),
|
|
251
|
+
pauseRecording: () => request("Location", "pauseRecording", []),
|
|
252
|
+
resumeRecording: () => request("Location", "resumeRecording", []),
|
|
253
|
+
stopRecording: () => request("Location", "stopRecording", []),
|
|
254
|
+
getRecordingState: () => request("Location", "getRecordingState", []),
|
|
255
|
+
readRecording: () => request("Location", "readRecording", [])
|
|
256
|
+
};
|
|
257
|
+
target.addEventListener?.("craftLocationUpdate", (event) => {
|
|
258
|
+
watchers.forEach((callback) => callback(event?.detail));
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (capabilities.has("music")) {
|
|
262
|
+
const control = (command, extra = {}) => request("Music", "control", [{ command, ...extra }]);
|
|
263
|
+
craft.music = {
|
|
264
|
+
getAuthorizationStatus: () => request("Music", "getAuthorizationStatus", []),
|
|
265
|
+
requestAuthorization: () => ask("Music", "requestAuthorization", []),
|
|
266
|
+
getNowPlaying: () => request("Music", "getNowPlaying", []),
|
|
267
|
+
play: () => control("play"),
|
|
268
|
+
pause: () => control("pause"),
|
|
269
|
+
togglePlayPause: () => control("togglePlayPause"),
|
|
270
|
+
skipToNext: () => control("skipToNext"),
|
|
271
|
+
skipToPrevious: (options = {}) => control("skipToPrevious", { restartAfter: typeof options.restartAfter === "number" ? options.restartAfter : null }),
|
|
272
|
+
observe: (enabled) => request("Music", "observe", [{ enabled: enabled !== !1 }])
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
protocol.on("CRAFT_EVENT", ({ payload }) => {
|
|
276
|
+
if (typeof payload?.event !== "string" || typeof target.dispatchEvent !== "function" || typeof target.CustomEvent !== "function")
|
|
277
|
+
return;
|
|
278
|
+
target.dispatchEvent(new target.CustomEvent(payload.event, { detail: payload.detail ?? {} }));
|
|
279
|
+
});
|
|
214
280
|
if (capabilities.has("push")) {
|
|
215
281
|
const tokenHandlers = new Set;
|
|
216
282
|
craft.push = {
|
|
@@ -267,6 +333,7 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
267
333
|
push: (screen, params) => navigate("NAVIGATE", screen, params),
|
|
268
334
|
replace: (screen, params) => navigate("NAVIGATE_REPLACE", screen, params),
|
|
269
335
|
back: () => protocol.goBack(),
|
|
336
|
+
popToRoot: () => protocol.popToRoot(),
|
|
270
337
|
open: (path) => {
|
|
271
338
|
if (typeof path !== "string" || !path.trim())
|
|
272
339
|
throw TypeError("navigation.open needs a path, such as /m/workout/42");
|
|
@@ -381,10 +448,10 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
381
448
|
return new Promise((resolve, reject) => {
|
|
382
449
|
signal?.addEventListener?.("abort", () => {
|
|
383
450
|
stream.body.cancel();
|
|
384
|
-
if (
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
451
|
+
if (settled)
|
|
452
|
+
return;
|
|
453
|
+
settled = !0;
|
|
454
|
+
reject(abortError(signal.reason));
|
|
388
455
|
});
|
|
389
456
|
request("Network", "stream", [{ id, url, method, headers, body }]).then((data) => {
|
|
390
457
|
if (settled)
|
|
@@ -55,6 +55,22 @@ export declare interface NativeSound {
|
|
|
55
55
|
onEnd: (callback: () => unknown) => () => void
|
|
56
56
|
onError: (callback: (message: string) => unknown) => () => void
|
|
57
57
|
}
|
|
58
|
+
export declare interface NativeLocation {
|
|
59
|
+
latitude: number
|
|
60
|
+
longitude: number
|
|
61
|
+
altitude?: number
|
|
62
|
+
accuracy?: number
|
|
63
|
+
altitudeAccuracy?: number
|
|
64
|
+
heading?: number
|
|
65
|
+
speed?: number
|
|
66
|
+
timestamp: number
|
|
67
|
+
}
|
|
68
|
+
export declare interface NativeLocationRecordingState {
|
|
69
|
+
id: string | null
|
|
70
|
+
active: boolean
|
|
71
|
+
paused: boolean
|
|
72
|
+
startedAt: number | null
|
|
73
|
+
}
|
|
58
74
|
export declare interface NativeShareOptions {
|
|
59
75
|
title?: string
|
|
60
76
|
text?: string
|
|
@@ -150,6 +166,21 @@ export declare interface NativeCraft {
|
|
|
150
166
|
}
|
|
151
167
|
openURL?: (url: string) => Promise<boolean>
|
|
152
168
|
share?: ((options: NativeShareOptions) => Promise<boolean>) & { share: (options: NativeShareOptions) => Promise<boolean> }
|
|
169
|
+
location?: {
|
|
170
|
+
getCurrentPosition: (options?: { enableHighAccuracy?: boolean, timeout?: number, maximumAge?: number }) => Promise<NativeLocation>
|
|
171
|
+
watchPosition: (callback: (location: NativeLocation) => unknown, options?: Record<string, unknown>) => number
|
|
172
|
+
clearWatch: (id?: number) => void
|
|
173
|
+
startRecording: (options?: Record<string, unknown>) => Promise<NativeLocationRecordingState>
|
|
174
|
+
pauseRecording: () => Promise<NativeLocationRecordingState>
|
|
175
|
+
resumeRecording: () => Promise<NativeLocationRecordingState>
|
|
176
|
+
stopRecording: () => Promise<NativeLocationRecordingState & { locations: NativeLocation[] }>
|
|
177
|
+
getRecordingState: () => Promise<NativeLocationRecordingState & { sampleCount: number }>
|
|
178
|
+
readRecording: () => Promise<NativeLocation[]>
|
|
179
|
+
}
|
|
180
|
+
setKeepAwake?: (enabled: boolean) => Promise<boolean>
|
|
181
|
+
getBrightness?: () => Promise<number>
|
|
182
|
+
setBrightness?: (level: number) => Promise<number>
|
|
183
|
+
statusBar?: { setStyle: (style: 'light' | 'dark' | 'default') => Promise<boolean> }
|
|
153
184
|
health?: {
|
|
154
185
|
requestAuthorization: (types: string[], options?: { write?: boolean }) => Promise<boolean>
|
|
155
186
|
getData: (type: string, options?: { startDate?: number, endDate?: number }) => Promise<unknown>
|
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.497",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -122,12 +122,12 @@
|
|
|
122
122
|
"dependencies": {
|
|
123
123
|
"@stacksjs/ts-css": "^0.3.2",
|
|
124
124
|
"@stacksjs/clapp": "^0.2.16",
|
|
125
|
-
"@stacksjs/desktop": "0.2.
|
|
126
|
-
"@stacksjs/sanitizer": "0.2.
|
|
125
|
+
"@stacksjs/desktop": "0.2.497",
|
|
126
|
+
"@stacksjs/sanitizer": "0.2.497",
|
|
127
127
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
128
|
-
"bun-plugin-stx": "0.2.
|
|
128
|
+
"bun-plugin-stx": "0.2.497",
|
|
129
129
|
"bunfig": "^0.15.19",
|
|
130
|
-
"stx-router": "0.2.
|
|
130
|
+
"stx-router": "0.2.497",
|
|
131
131
|
"ts-broadcasting": "^0.0.11",
|
|
132
132
|
"ts-images": "^0.2.22",
|
|
133
133
|
"ts-syntax-highlighter": "^0.2.1"
|