@aippy/runtime 0.2.3 → 0.2.4-dev.3

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.
@@ -1,10 +1,10 @@
1
- var h = Object.defineProperty;
2
- var p = (n, e, t) => e in n ? h(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var m = (n, e, t) => p(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { c as a } from "../errors-CDEBaBxB.js";
5
- class g {
1
+ var v = Object.defineProperty;
2
+ var f = (c, t, e) => t in c ? v(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
3
+ var p = (c, t, e) => f(c, typeof t != "symbol" ? t + "" : t, e);
4
+ import { c as a, b as E } from "../runtime-DOnodF_1.js";
5
+ class P {
6
6
  constructor() {
7
- m(this, "stream", null);
7
+ p(this, "stream", null);
8
8
  }
9
9
  /**
10
10
  * Check if camera is supported
@@ -15,21 +15,21 @@ class g {
15
15
  /**
16
16
  * Get camera stream
17
17
  */
18
- async getStream(e = {}) {
18
+ async getStream(t = {}) {
19
19
  if (!this.isSupported())
20
20
  throw a("Camera API is not supported", "NOT_SUPPORTED");
21
21
  try {
22
- const t = {
22
+ const e = {
23
23
  video: {
24
- width: e.width,
25
- height: e.height,
26
- facingMode: e.facingMode || "environment"
24
+ width: t.width,
25
+ height: t.height,
26
+ facingMode: t.facingMode || "environment"
27
27
  }
28
28
  };
29
- return this.stream = await navigator.mediaDevices.getUserMedia(t), this.stream;
30
- } catch (t) {
29
+ return this.stream = await navigator.mediaDevices.getUserMedia(e), this.stream;
30
+ } catch (e) {
31
31
  throw a(
32
- `Failed to access camera: ${t instanceof Error ? t.message : "Unknown error"}`,
32
+ `Failed to access camera: ${e instanceof Error ? e.message : "Unknown error"}`,
33
33
  "PERMISSION_DENIED"
34
34
  );
35
35
  }
@@ -37,30 +37,30 @@ class g {
37
37
  /**
38
38
  * Capture photo from stream
39
39
  */
40
- async capturePhoto(e = {}) {
40
+ async capturePhoto(t = {}) {
41
41
  if (!this.stream)
42
42
  throw a("No camera stream available", "NOT_SUPPORTED");
43
43
  try {
44
- const t = document.createElement("video");
45
- t.srcObject = this.stream, t.play();
46
- const o = document.createElement("canvas"), i = o.getContext("2d");
47
- if (!i)
44
+ const e = document.createElement("video");
45
+ e.srcObject = this.stream, e.play();
46
+ const i = document.createElement("canvas"), o = i.getContext("2d");
47
+ if (!o)
48
48
  throw a("Failed to get canvas context", "UNKNOWN_ERROR");
49
- o.width = e.width || t.videoWidth, o.height = e.height || t.videoHeight, i.drawImage(t, 0, 0, o.width, o.height);
50
- const r = e.format || "jpeg", c = e.quality === "high" ? 0.9 : e.quality === "medium" ? 0.7 : 0.5, s = await new Promise((u, w) => {
51
- o.toBlob((l) => {
52
- l ? u(l) : w(new Error("Failed to create blob"));
53
- }, `image/${r}`, c);
54
- }), d = o.toDataURL(`image/${r}`, c);
49
+ i.width = t.width || e.videoWidth, i.height = t.height || e.videoHeight, o.drawImage(e, 0, 0, i.width, i.height);
50
+ const n = t.format || "jpeg", d = t.quality === "high" ? 0.9 : t.quality === "medium" ? 0.7 : 0.5, r = await new Promise((l, u) => {
51
+ i.toBlob((w) => {
52
+ w ? l(w) : u(new Error("Failed to create blob"));
53
+ }, `image/${n}`, d);
54
+ }), s = i.toDataURL(`image/${n}`, d);
55
55
  return {
56
- blob: s,
57
- dataUrl: d,
58
- width: o.width,
59
- height: o.height
56
+ blob: r,
57
+ dataUrl: s,
58
+ width: i.width,
59
+ height: i.height
60
60
  };
61
- } catch (t) {
61
+ } catch (e) {
62
62
  throw a(
63
- `Failed to capture photo: ${t instanceof Error ? t.message : "Unknown error"}`,
63
+ `Failed to capture photo: ${e instanceof Error ? e.message : "Unknown error"}`,
64
64
  "UNKNOWN_ERROR"
65
65
  );
66
66
  }
@@ -69,11 +69,11 @@ class g {
69
69
  * Stop camera stream
70
70
  */
71
71
  stopStream() {
72
- this.stream && (this.stream.getTracks().forEach((e) => e.stop()), this.stream = null);
72
+ this.stream && (this.stream.getTracks().forEach((t) => t.stop()), this.stream = null);
73
73
  }
74
74
  }
75
- const f = new g();
76
- class v {
75
+ const D = new P();
76
+ class O {
77
77
  /**
78
78
  * Check if geolocation is supported
79
79
  */
@@ -83,99 +83,230 @@ class v {
83
83
  /**
84
84
  * Get current position
85
85
  */
86
- async getCurrentPosition(e = {}) {
86
+ async getCurrentPosition(t = {}) {
87
87
  if (!this.isSupported())
88
88
  throw a("Geolocation API is not supported", "NOT_SUPPORTED");
89
- return new Promise((t, o) => {
90
- const i = {
91
- enableHighAccuracy: e.enableHighAccuracy ?? !0,
92
- timeout: e.timeout ?? 1e4,
93
- maximumAge: e.maximumAge ?? 6e4
89
+ return new Promise((e, i) => {
90
+ const o = {
91
+ enableHighAccuracy: t.enableHighAccuracy ?? !0,
92
+ timeout: t.timeout ?? 1e4,
93
+ maximumAge: t.maximumAge ?? 6e4
94
94
  };
95
95
  navigator.geolocation.getCurrentPosition(
96
- (r) => {
97
- const c = {
98
- latitude: r.coords.latitude,
99
- longitude: r.coords.longitude,
100
- accuracy: r.coords.accuracy,
101
- altitude: r.coords.altitude ?? void 0,
102
- altitudeAccuracy: r.coords.altitudeAccuracy ?? void 0,
103
- heading: r.coords.heading ?? void 0,
104
- speed: r.coords.speed ?? void 0,
105
- timestamp: r.timestamp
96
+ (n) => {
97
+ const d = {
98
+ latitude: n.coords.latitude,
99
+ longitude: n.coords.longitude,
100
+ accuracy: n.coords.accuracy,
101
+ altitude: n.coords.altitude ?? void 0,
102
+ altitudeAccuracy: n.coords.altitudeAccuracy ?? void 0,
103
+ heading: n.coords.heading ?? void 0,
104
+ speed: n.coords.speed ?? void 0,
105
+ timestamp: n.timestamp
106
106
  };
107
- t(c);
107
+ e(d);
108
108
  },
109
- (r) => {
110
- let c = "UNKNOWN_ERROR", s = "Unknown geolocation error";
111
- switch (r.code) {
112
- case r.PERMISSION_DENIED:
113
- c = "PERMISSION_DENIED", s = "Geolocation permission denied";
109
+ (n) => {
110
+ let d = "UNKNOWN_ERROR", r = "Unknown geolocation error";
111
+ switch (n.code) {
112
+ case n.PERMISSION_DENIED:
113
+ d = "PERMISSION_DENIED", r = "Geolocation permission denied";
114
114
  break;
115
- case r.POSITION_UNAVAILABLE:
116
- s = "Position unavailable";
115
+ case n.POSITION_UNAVAILABLE:
116
+ r = "Position unavailable";
117
117
  break;
118
- case r.TIMEOUT:
119
- s = "Geolocation timeout";
118
+ case n.TIMEOUT:
119
+ r = "Geolocation timeout";
120
120
  break;
121
121
  }
122
- o(a(s, c));
122
+ i(a(r, d));
123
123
  },
124
- i
124
+ o
125
125
  );
126
126
  });
127
127
  }
128
128
  /**
129
129
  * Watch position changes
130
130
  */
131
- watchPosition(e, t = {}) {
131
+ watchPosition(t, e = {}) {
132
132
  if (!this.isSupported())
133
133
  throw a("Geolocation API is not supported", "NOT_SUPPORTED");
134
- const o = {
135
- enableHighAccuracy: t.enableHighAccuracy ?? !0,
136
- timeout: t.timeout ?? 1e4,
137
- maximumAge: t.maximumAge ?? 6e4
134
+ const i = {
135
+ enableHighAccuracy: e.enableHighAccuracy ?? !0,
136
+ timeout: e.timeout ?? 1e4,
137
+ maximumAge: e.maximumAge ?? 6e4
138
138
  };
139
139
  return navigator.geolocation.watchPosition(
140
- (i) => {
141
- const r = {
142
- latitude: i.coords.latitude,
143
- longitude: i.coords.longitude,
144
- accuracy: i.coords.accuracy,
145
- altitude: i.coords.altitude ?? void 0,
146
- altitudeAccuracy: i.coords.altitudeAccuracy ?? void 0,
147
- heading: i.coords.heading ?? void 0,
148
- speed: i.coords.speed ?? void 0,
149
- timestamp: i.timestamp
140
+ (o) => {
141
+ const n = {
142
+ latitude: o.coords.latitude,
143
+ longitude: o.coords.longitude,
144
+ accuracy: o.coords.accuracy,
145
+ altitude: o.coords.altitude ?? void 0,
146
+ altitudeAccuracy: o.coords.altitudeAccuracy ?? void 0,
147
+ heading: o.coords.heading ?? void 0,
148
+ speed: o.coords.speed ?? void 0,
149
+ timestamp: o.timestamp
150
150
  };
151
- e(r);
151
+ t(n);
152
152
  },
153
- (i) => {
154
- console.error("Geolocation watch error:", i);
153
+ (o) => {
154
+ console.error("Geolocation watch error:", o);
155
155
  },
156
- o
156
+ i
157
157
  );
158
158
  }
159
159
  /**
160
160
  * Clear position watch
161
161
  */
162
- clearWatch(e) {
163
- navigator.geolocation.clearWatch(e);
162
+ clearWatch(t) {
163
+ navigator.geolocation.clearWatch(t);
164
164
  }
165
165
  }
166
- const N = new v();
167
- class E {
166
+ const A = new O();
167
+ function m() {
168
+ return "DeviceMotionEvent" in window;
169
+ }
170
+ function h() {
171
+ return "DeviceOrientationEvent" in window;
172
+ }
173
+ function g() {
174
+ return typeof window < "u" && !!window.webkit?.messageHandlers?.deviceMotionHandler;
175
+ }
176
+ async function y() {
177
+ if (g())
178
+ return !0;
179
+ if (!m())
180
+ return !1;
181
+ if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function")
182
+ try {
183
+ return await DeviceMotionEvent.requestPermission() === "granted";
184
+ } catch {
185
+ return !1;
186
+ }
187
+ return !0;
188
+ }
189
+ function R(c) {
190
+ return E.addMotionListener((e) => {
191
+ const i = {
192
+ gravity: {
193
+ x: e.gravity?.x ?? 0,
194
+ y: e.gravity?.y ?? 0,
195
+ z: e.gravity?.z ?? 0
196
+ },
197
+ acceleration: {
198
+ x: e.acceleration?.x ?? 0,
199
+ y: e.acceleration?.y ?? 0,
200
+ z: e.acceleration?.z ?? 0
201
+ },
202
+ accelerationIncludingGravity: {
203
+ x: (e.gravity?.x ?? 0) + (e.acceleration?.x ?? 0),
204
+ y: (e.gravity?.y ?? 0) + (e.acceleration?.y ?? 0),
205
+ z: (e.gravity?.z ?? 0) + (e.acceleration?.z ?? 0)
206
+ },
207
+ rotation: {
208
+ alpha: e.rotation?.alpha ?? 0,
209
+ beta: e.rotation?.beta ?? 0,
210
+ gamma: e.rotation?.gamma ?? 0
211
+ },
212
+ timestamp: Date.now()
213
+ };
214
+ c(i);
215
+ });
216
+ }
217
+ function N(c, t = !0) {
218
+ if (!m())
219
+ throw a("Device motion API is not supported", "NOT_SUPPORTED");
220
+ let e = !1, i = null;
221
+ const o = (r) => {
222
+ if (!e) return;
223
+ const s = {
224
+ gravity: {
225
+ x: r.acceleration?.x ?? 0,
226
+ y: r.acceleration?.y ?? 0,
227
+ z: r.acceleration?.z ?? 0
228
+ },
229
+ acceleration: {
230
+ x: r.acceleration?.x ?? 0,
231
+ y: r.acceleration?.y ?? 0,
232
+ z: r.acceleration?.z ?? 0
233
+ },
234
+ accelerationIncludingGravity: {
235
+ x: r.accelerationIncludingGravity?.x ?? 0,
236
+ y: r.accelerationIncludingGravity?.y ?? 0,
237
+ z: r.accelerationIncludingGravity?.z ?? 0
238
+ },
239
+ rotation: {
240
+ alpha: r.rotationRate?.alpha ?? 0,
241
+ beta: r.rotationRate?.beta ?? 0,
242
+ gamma: r.rotationRate?.gamma ?? 0
243
+ },
244
+ timestamp: Date.now()
245
+ };
246
+ if (r.acceleration) {
247
+ const l = r.accelerationIncludingGravity, u = r.acceleration;
248
+ s.gravity = {
249
+ x: (l?.x ?? 0) - (u?.x ?? 0),
250
+ y: (l?.y ?? 0) - (u?.y ?? 0),
251
+ z: (l?.z ?? 0) - (u?.z ?? 0)
252
+ };
253
+ } else {
254
+ const l = r.accelerationIncludingGravity, u = 9.8;
255
+ s.gravity = {
256
+ x: (l?.x ?? 0) / u,
257
+ y: (l?.y ?? 0) / u,
258
+ z: (l?.z ?? 0) / u
259
+ };
260
+ }
261
+ c(s);
262
+ }, n = async () => {
263
+ t && !await y() || (e = !0, window.addEventListener("devicemotion", o));
264
+ };
265
+ return (async () => {
266
+ if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && t) {
267
+ const s = async () => {
268
+ i = null, await n();
269
+ };
270
+ window.addEventListener("click", s, { once: !0 }), window.addEventListener("touchstart", s, { once: !0 }), i = () => {
271
+ window.removeEventListener("click", s), window.removeEventListener("touchstart", s);
272
+ };
273
+ } else
274
+ await n();
275
+ })(), () => {
276
+ e = !1, window.removeEventListener("devicemotion", o), i && (i(), i = null);
277
+ };
278
+ }
279
+ function x(c, t = !0) {
280
+ return g() ? R(c) : N(c, t);
281
+ }
282
+ function L(c) {
283
+ if (!h())
284
+ throw a("Device orientation API is not supported", "NOT_SUPPORTED");
285
+ const t = (e) => {
286
+ const i = {
287
+ alpha: e.alpha ?? 0,
288
+ beta: e.beta ?? 0,
289
+ gamma: e.gamma ?? 0,
290
+ timestamp: Date.now()
291
+ };
292
+ c(i);
293
+ };
294
+ return window.addEventListener("deviceorientation", t), () => {
295
+ window.removeEventListener("deviceorientation", t);
296
+ };
297
+ }
298
+ class S {
168
299
  /**
169
300
  * Check if device orientation is supported
170
301
  */
171
302
  isOrientationSupported() {
172
- return "DeviceOrientationEvent" in window;
303
+ return h();
173
304
  }
174
305
  /**
175
306
  * Check if device motion is supported
176
307
  */
177
308
  isMotionSupported() {
178
- return "DeviceMotionEvent" in window;
309
+ return m();
179
310
  }
180
311
  /**
181
312
  * Get device orientation data
@@ -183,36 +314,37 @@ class E {
183
314
  async getOrientation() {
184
315
  if (!this.isOrientationSupported())
185
316
  throw a("Device orientation API is not supported", "NOT_SUPPORTED");
186
- return new Promise((e, t) => {
187
- const o = (i) => {
188
- window.removeEventListener("deviceorientation", o), e({
189
- x: i.alpha ?? 0,
190
- y: i.beta ?? 0,
191
- z: i.gamma ?? 0,
317
+ return new Promise((t, e) => {
318
+ const i = (o) => {
319
+ window.removeEventListener("deviceorientation", i), t({
320
+ x: o.alpha ?? 0,
321
+ y: o.beta ?? 0,
322
+ z: o.gamma ?? 0,
192
323
  timestamp: Date.now()
193
324
  });
194
325
  };
195
- window.addEventListener("deviceorientation", o), setTimeout(() => {
196
- window.removeEventListener("deviceorientation", o), t(a("Device orientation timeout", "UNKNOWN_ERROR"));
326
+ window.addEventListener("deviceorientation", i), setTimeout(() => {
327
+ window.removeEventListener("deviceorientation", i), e(a("Device orientation timeout", "UNKNOWN_ERROR"));
197
328
  }, 5e3);
198
329
  });
199
330
  }
200
331
  /**
201
332
  * Watch device orientation changes
333
+ * @deprecated Use watchOrientation() function instead
202
334
  */
203
- watchOrientation(e) {
335
+ watchOrientation(t) {
204
336
  if (!this.isOrientationSupported())
205
337
  throw a("Device orientation API is not supported", "NOT_SUPPORTED");
206
- const t = (o) => {
207
- e({
208
- x: o.alpha ?? 0,
209
- y: o.beta ?? 0,
210
- z: o.gamma ?? 0,
338
+ const e = (i) => {
339
+ t({
340
+ x: i.alpha ?? 0,
341
+ y: i.beta ?? 0,
342
+ z: i.gamma ?? 0,
211
343
  timestamp: Date.now()
212
344
  });
213
345
  };
214
- return window.addEventListener("deviceorientation", t), () => {
215
- window.removeEventListener("deviceorientation", t);
346
+ return window.addEventListener("deviceorientation", e), () => {
347
+ window.removeEventListener("deviceorientation", e);
216
348
  };
217
349
  }
218
350
  /**
@@ -221,53 +353,48 @@ class E {
221
353
  async getMotion() {
222
354
  if (!this.isMotionSupported())
223
355
  throw a("Device motion API is not supported", "NOT_SUPPORTED");
224
- return new Promise((e, t) => {
225
- const o = (i) => {
226
- window.removeEventListener("devicemotion", o), e({
227
- x: i.acceleration?.x ?? 0,
228
- y: i.acceleration?.y ?? 0,
229
- z: i.acceleration?.z ?? 0,
356
+ return new Promise((t, e) => {
357
+ const i = (o) => {
358
+ window.removeEventListener("devicemotion", i), t({
359
+ x: o.acceleration?.x ?? 0,
360
+ y: o.acceleration?.y ?? 0,
361
+ z: o.acceleration?.z ?? 0,
230
362
  timestamp: Date.now()
231
363
  });
232
364
  };
233
- window.addEventListener("devicemotion", o), setTimeout(() => {
234
- window.removeEventListener("devicemotion", o), t(a("Device motion timeout", "UNKNOWN_ERROR"));
365
+ window.addEventListener("devicemotion", i), setTimeout(() => {
366
+ window.removeEventListener("devicemotion", i), e(a("Device motion timeout", "UNKNOWN_ERROR"));
235
367
  }, 5e3);
236
368
  });
237
369
  }
238
370
  /**
239
371
  * Watch device motion changes
372
+ * @deprecated Use watchMotion() function instead
240
373
  */
241
- watchMotion(e) {
374
+ watchMotion(t) {
242
375
  if (!this.isMotionSupported())
243
376
  throw a("Device motion API is not supported", "NOT_SUPPORTED");
244
- const t = (o) => {
245
- e({
246
- x: o.acceleration?.x ?? 0,
247
- y: o.acceleration?.y ?? 0,
248
- z: o.acceleration?.z ?? 0,
377
+ const e = (i) => {
378
+ t({
379
+ x: i.acceleration?.x ?? 0,
380
+ y: i.acceleration?.y ?? 0,
381
+ z: i.acceleration?.z ?? 0,
249
382
  timestamp: Date.now()
250
383
  });
251
384
  };
252
- return window.addEventListener("devicemotion", t), () => {
253
- window.removeEventListener("devicemotion", t);
385
+ return window.addEventListener("devicemotion", e), () => {
386
+ window.removeEventListener("devicemotion", e);
254
387
  };
255
388
  }
256
389
  /**
257
390
  * Request permission for motion sensors (iOS 13+)
258
391
  */
259
392
  async requestPermission() {
260
- if (!this.isMotionSupported())
261
- return !1;
262
- try {
263
- return (await navigator.permissions?.query({ name: "accelerometer" }))?.state === "granted";
264
- } catch {
265
- return !1;
266
- }
393
+ return y();
267
394
  }
268
395
  }
269
- const R = new E();
270
- class O {
396
+ const M = new S();
397
+ class I {
271
398
  /**
272
399
  * Check if file system access is supported
273
400
  */
@@ -283,28 +410,28 @@ class O {
283
410
  /**
284
411
  * Open file picker (modern API)
285
412
  */
286
- async openFilePicker(e = {}) {
413
+ async openFilePicker(t = {}) {
287
414
  if (!this.isSupported())
288
415
  throw a("File System Access API is not supported", "NOT_SUPPORTED");
289
416
  try {
290
- const t = {
291
- types: e.accept ? [{
417
+ const e = {
418
+ types: t.accept ? [{
292
419
  description: "Files",
293
420
  accept: Object.fromEntries(
294
- e.accept.map((r) => [r, [r]])
421
+ t.accept.map((n) => [n, [n]])
295
422
  )
296
423
  }] : void 0,
297
- multiple: e.multiple ?? !1
298
- }, o = await window.showOpenFilePicker(t), i = await Promise.all(
299
- o.map(async (r) => r.getFile())
424
+ multiple: t.multiple ?? !1
425
+ }, i = await window.showOpenFilePicker(e), o = await Promise.all(
426
+ i.map(async (n) => n.getFile())
300
427
  );
301
428
  return {
302
- files: i,
303
- paths: i.map((r) => r.name)
429
+ files: o,
430
+ paths: o.map((n) => n.name)
304
431
  };
305
- } catch (t) {
306
- throw t instanceof Error && t.name === "AbortError" ? a("File picker was cancelled", "PERMISSION_DENIED") : a(
307
- `Failed to open file picker: ${t instanceof Error ? t.message : "Unknown error"}`,
432
+ } catch (e) {
433
+ throw e instanceof Error && e.name === "AbortError" ? a("File picker was cancelled", "PERMISSION_DENIED") : a(
434
+ `Failed to open file picker: ${e instanceof Error ? e.message : "Unknown error"}`,
308
435
  "PERMISSION_DENIED"
309
436
  );
310
437
  }
@@ -312,38 +439,38 @@ class O {
312
439
  /**
313
440
  * Open file picker (legacy fallback)
314
441
  */
315
- async openFilePickerLegacy(e = {}) {
442
+ async openFilePickerLegacy(t = {}) {
316
443
  if (!this.isLegacySupported())
317
444
  throw a("File input is not supported", "NOT_SUPPORTED");
318
- return new Promise((t, o) => {
319
- const i = document.createElement("input");
320
- i.type = "file", i.multiple = e.multiple ?? !1, i.accept = e.accept?.join(",") ?? "", i.onchange = (r) => {
321
- const c = r.target, s = Array.from(c.files || []);
322
- t({
323
- files: s,
324
- paths: s.map((d) => d.name)
445
+ return new Promise((e, i) => {
446
+ const o = document.createElement("input");
447
+ o.type = "file", o.multiple = t.multiple ?? !1, o.accept = t.accept?.join(",") ?? "", o.onchange = (n) => {
448
+ const d = n.target, r = Array.from(d.files || []);
449
+ e({
450
+ files: r,
451
+ paths: r.map((s) => s.name)
325
452
  });
326
- }, i.oncancel = () => {
327
- o(a("File picker was cancelled", "PERMISSION_DENIED"));
328
- }, i.click();
453
+ }, o.oncancel = () => {
454
+ i(a("File picker was cancelled", "PERMISSION_DENIED"));
455
+ }, o.click();
329
456
  });
330
457
  }
331
458
  /**
332
459
  * Open file picker with fallback
333
460
  */
334
- async openFile(e = {}) {
335
- return this.isSupported() ? await this.openFilePicker(e) : await this.openFilePickerLegacy(e);
461
+ async openFile(t = {}) {
462
+ return this.isSupported() ? await this.openFilePicker(t) : await this.openFilePickerLegacy(t);
336
463
  }
337
464
  /**
338
465
  * Save file
339
466
  */
340
- async saveFile(e, t) {
467
+ async saveFile(t, e) {
341
468
  try {
342
- const o = URL.createObjectURL(e), i = document.createElement("a");
343
- i.href = o, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(o);
344
- } catch (o) {
469
+ const i = URL.createObjectURL(t), o = document.createElement("a");
470
+ o.href = i, o.download = e, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(i);
471
+ } catch (i) {
345
472
  throw a(
346
- `Failed to save file: ${o instanceof Error ? o.message : "Unknown error"}`,
473
+ `Failed to save file: ${i instanceof Error ? i.message : "Unknown error"}`,
347
474
  "UNKNOWN_ERROR"
348
475
  );
349
476
  }
@@ -351,45 +478,51 @@ class O {
351
478
  /**
352
479
  * Read file as text
353
480
  */
354
- async readAsText(e) {
355
- return new Promise((t, o) => {
356
- const i = new FileReader();
357
- i.onload = () => t(i.result), i.onerror = () => o(a("Failed to read file", "UNKNOWN_ERROR")), i.readAsText(e);
481
+ async readAsText(t) {
482
+ return new Promise((e, i) => {
483
+ const o = new FileReader();
484
+ o.onload = () => e(o.result), o.onerror = () => i(a("Failed to read file", "UNKNOWN_ERROR")), o.readAsText(t);
358
485
  });
359
486
  }
360
487
  /**
361
488
  * Read file as data URL
362
489
  */
363
- async readAsDataURL(e) {
364
- return new Promise((t, o) => {
365
- const i = new FileReader();
366
- i.onload = () => t(i.result), i.onerror = () => o(a("Failed to read file", "UNKNOWN_ERROR")), i.readAsDataURL(e);
490
+ async readAsDataURL(t) {
491
+ return new Promise((e, i) => {
492
+ const o = new FileReader();
493
+ o.onload = () => e(o.result), o.onerror = () => i(a("Failed to read file", "UNKNOWN_ERROR")), o.readAsDataURL(t);
367
494
  });
368
495
  }
369
496
  }
370
- const S = new O();
371
- function D(n) {
372
- return new Promise((e) => {
497
+ const T = new I();
498
+ function k(c) {
499
+ return new Promise((t) => {
373
500
  if ("vibrate" in navigator)
374
- navigator.vibrate(n), e();
501
+ navigator.vibrate(c), t();
375
502
  else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.aippyListener) {
376
- const t = {
503
+ const e = {
377
504
  command: "navigator.vibrate",
378
- parameters: n
505
+ parameters: c
379
506
  };
380
- window.webkit.messageHandlers.aippyListener.postMessage(t), e();
507
+ window.webkit.messageHandlers.aippyListener.postMessage(e), t();
381
508
  } else
382
- console.warn("Vibration not supported in this environment"), e();
509
+ console.warn("Vibration not supported in this environment"), t();
383
510
  });
384
511
  }
385
512
  export {
386
- g as CameraAPI,
387
- O as FileSystemAPI,
388
- v as GeolocationAPI,
389
- E as SensorsAPI,
390
- f as camera,
391
- S as fileSystem,
392
- N as geolocation,
393
- R as sensors,
394
- D as vibrate
513
+ P as CameraAPI,
514
+ I as FileSystemAPI,
515
+ O as GeolocationAPI,
516
+ S as SensorsAPI,
517
+ D as camera,
518
+ T as fileSystem,
519
+ A as geolocation,
520
+ g as hasNativeBridge,
521
+ m as isMotionSupported,
522
+ h as isOrientationSupported,
523
+ y as requestMotionPermission,
524
+ M as sensors,
525
+ k as vibrate,
526
+ x as watchMotion,
527
+ L as watchOrientation
395
528
  };