@aippy/runtime 0.2.7-dev.6 → 0.2.7-dev.8

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,12 +1,12 @@
1
- var D = Object.defineProperty;
2
- var U = (n, e, t) => e in n ? D(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var I = (n, e, t) => U(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { c as s } from "../errors-CDEBaBxB.js";
5
- import { a as T } from "../runtime-CmoG3v2m.js";
6
- import { hasNativeBridge as N } from "../native-bridge-BnvipFJc.js";
7
- class L {
1
+ var N = Object.defineProperty;
2
+ var L = (n, e, t) => e in n ? N(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var M = (n, e, t) => L(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { c as a, a as s } from "../errors-B3bDbQbD.js";
5
+ import { a as U } from "../runtime-CmoG3v2m.js";
6
+ import { hasNativeBridge as D } from "../native-bridge-BnvipFJc.js";
7
+ class F {
8
8
  constructor() {
9
- I(this, "stream", null);
9
+ M(this, "stream", null);
10
10
  }
11
11
  /**
12
12
  * Check if camera is supported
@@ -19,7 +19,7 @@ class L {
19
19
  */
20
20
  async getStream(e = {}) {
21
21
  if (!this.isSupported())
22
- throw s("Camera API is not supported", "NOT_SUPPORTED");
22
+ throw a("Camera API is not supported", s.NOT_SUPPORTED);
23
23
  try {
24
24
  const t = {
25
25
  video: {
@@ -30,9 +30,9 @@ class L {
30
30
  };
31
31
  return this.stream = await navigator.mediaDevices.getUserMedia(t), this.stream;
32
32
  } catch (t) {
33
- throw s(
33
+ throw a(
34
34
  `Failed to access camera: ${t instanceof Error ? t.message : "Unknown error"}`,
35
- "PERMISSION_DENIED"
35
+ s.PERMISSION_DENIED
36
36
  );
37
37
  }
38
38
  }
@@ -41,29 +41,29 @@ class L {
41
41
  */
42
42
  async capturePhoto(e = {}) {
43
43
  if (!this.stream)
44
- throw s("No camera stream available", "NOT_SUPPORTED");
44
+ throw a("No camera stream available", s.NOT_SUPPORTED);
45
45
  try {
46
46
  const t = document.createElement("video");
47
47
  t.srcObject = this.stream, t.play();
48
- const o = document.createElement("canvas"), i = o.getContext("2d");
49
- if (!i)
50
- throw s("Failed to get canvas context", "UNKNOWN_ERROR");
51
- o.width = e.width || t.videoWidth, o.height = e.height || t.videoHeight, i.drawImage(t, 0, 0, o.width, o.height);
52
- const r = e.format || "jpeg", c = e.quality === "high" ? 0.9 : e.quality === "medium" ? 0.7 : 0.5, a = await new Promise((u, m) => {
53
- o.toBlob((l) => {
54
- l ? u(l) : m(new Error("Failed to create blob"));
55
- }, `image/${r}`, c);
56
- }), d = o.toDataURL(`image/${r}`, c);
48
+ const i = document.createElement("canvas"), o = i.getContext("2d");
49
+ if (!o)
50
+ throw a("Failed to get canvas context", s.OPERATION_FAILED);
51
+ i.width = e.width || t.videoWidth, i.height = e.height || t.videoHeight, o.drawImage(t, 0, 0, i.width, i.height);
52
+ const r = e.format || "jpeg", l = e.quality === "high" ? 0.9 : e.quality === "medium" ? 0.7 : 0.5, c = await new Promise((m, p) => {
53
+ i.toBlob((u) => {
54
+ u ? m(u) : p(a("Failed to create blob", s.OPERATION_FAILED));
55
+ }, `image/${r}`, l);
56
+ }), d = i.toDataURL(`image/${r}`, l);
57
57
  return {
58
- blob: a,
58
+ blob: c,
59
59
  dataUrl: d,
60
- width: o.width,
61
- height: o.height
60
+ width: i.width,
61
+ height: i.height
62
62
  };
63
63
  } catch (t) {
64
- throw s(
64
+ throw a(
65
65
  `Failed to capture photo: ${t instanceof Error ? t.message : "Unknown error"}`,
66
- "UNKNOWN_ERROR"
66
+ s.OPERATION_FAILED
67
67
  );
68
68
  }
69
69
  }
@@ -74,7 +74,7 @@ class L {
74
74
  this.stream && (this.stream.getTracks().forEach((e) => e.stop()), this.stream = null);
75
75
  }
76
76
  }
77
- const X = new L();
77
+ const $ = new F();
78
78
  class k {
79
79
  /**
80
80
  * Check if geolocation is supported
@@ -87,16 +87,16 @@ class k {
87
87
  */
88
88
  async getCurrentPosition(e = {}) {
89
89
  if (!this.isSupported())
90
- throw s("Geolocation API is not supported", "NOT_SUPPORTED");
91
- return new Promise((t, o) => {
92
- const i = {
90
+ throw a("Geolocation API is not supported", s.NOT_SUPPORTED);
91
+ return new Promise((t, i) => {
92
+ const o = {
93
93
  enableHighAccuracy: e.enableHighAccuracy ?? !0,
94
94
  timeout: e.timeout ?? 1e4,
95
95
  maximumAge: e.maximumAge ?? 6e4
96
96
  };
97
97
  navigator.geolocation.getCurrentPosition(
98
98
  (r) => {
99
- const c = {
99
+ const l = {
100
100
  latitude: r.coords.latitude,
101
101
  longitude: r.coords.longitude,
102
102
  accuracy: r.coords.accuracy,
@@ -106,24 +106,24 @@ class k {
106
106
  speed: r.coords.speed ?? void 0,
107
107
  timestamp: r.timestamp
108
108
  };
109
- t(c);
109
+ t(l);
110
110
  },
111
111
  (r) => {
112
- let c = "UNKNOWN_ERROR", a = "Unknown geolocation error";
113
112
  switch (r.code) {
114
113
  case r.PERMISSION_DENIED:
115
- c = "PERMISSION_DENIED", a = "Geolocation permission denied";
114
+ i(a("Geolocation permission denied", s.PERMISSION_DENIED));
116
115
  break;
117
116
  case r.POSITION_UNAVAILABLE:
118
- a = "Position unavailable";
117
+ i(a("Position unavailable", s.OPERATION_FAILED));
119
118
  break;
120
119
  case r.TIMEOUT:
121
- a = "Geolocation timeout";
120
+ i(a("Geolocation timeout", s.TIMEOUT));
122
121
  break;
122
+ default:
123
+ i(a("Unknown geolocation error", s.UNKNOWN_ERROR));
123
124
  }
124
- o(s(a, c));
125
125
  },
126
- i
126
+ o
127
127
  );
128
128
  });
129
129
  }
@@ -132,30 +132,30 @@ class k {
132
132
  */
133
133
  watchPosition(e, t = {}) {
134
134
  if (!this.isSupported())
135
- throw s("Geolocation API is not supported", "NOT_SUPPORTED");
136
- const o = {
135
+ throw a("Geolocation API is not supported", s.NOT_SUPPORTED);
136
+ const i = {
137
137
  enableHighAccuracy: t.enableHighAccuracy ?? !0,
138
138
  timeout: t.timeout ?? 1e4,
139
139
  maximumAge: t.maximumAge ?? 6e4
140
140
  };
141
141
  return navigator.geolocation.watchPosition(
142
- (i) => {
142
+ (o) => {
143
143
  const r = {
144
- latitude: i.coords.latitude,
145
- longitude: i.coords.longitude,
146
- accuracy: i.coords.accuracy,
147
- altitude: i.coords.altitude ?? void 0,
148
- altitudeAccuracy: i.coords.altitudeAccuracy ?? void 0,
149
- heading: i.coords.heading ?? void 0,
150
- speed: i.coords.speed ?? void 0,
151
- timestamp: i.timestamp
144
+ latitude: o.coords.latitude,
145
+ longitude: o.coords.longitude,
146
+ accuracy: o.coords.accuracy,
147
+ altitude: o.coords.altitude ?? void 0,
148
+ altitudeAccuracy: o.coords.altitudeAccuracy ?? void 0,
149
+ heading: o.coords.heading ?? void 0,
150
+ speed: o.coords.speed ?? void 0,
151
+ timestamp: o.timestamp
152
152
  };
153
153
  e(r);
154
154
  },
155
- (i) => {
156
- console.error("Geolocation watch error:", i);
155
+ (o) => {
156
+ console.error("Geolocation watch error:", o);
157
157
  },
158
- o
158
+ i
159
159
  );
160
160
  }
161
161
  /**
@@ -165,17 +165,17 @@ class k {
165
165
  navigator.geolocation.clearWatch(e);
166
166
  }
167
167
  }
168
- const Y = new k();
169
- function E() {
168
+ const B = new k();
169
+ function A() {
170
170
  return "DeviceMotionEvent" in window;
171
171
  }
172
- function R() {
172
+ function T() {
173
173
  return "DeviceOrientationEvent" in window;
174
174
  }
175
- function M() {
175
+ function b() {
176
176
  return typeof window < "u" && typeof window.orientation < "u" ? window.orientation : typeof window < "u" && window.screen?.orientation?.angle !== void 0 ? window.screen.orientation.angle : 0;
177
177
  }
178
- function P(n, e, t) {
178
+ function E(n, e, t) {
179
179
  switch (t) {
180
180
  case 0:
181
181
  return [n, -e];
@@ -189,10 +189,10 @@ function P(n, e, t) {
189
189
  return [n, -e];
190
190
  }
191
191
  }
192
- async function x() {
193
- if (console.log("🔐 [Aippy Sensors] requestMotionPermission called"), N())
192
+ async function _() {
193
+ if (console.log("🔐 [Aippy Sensors] requestMotionPermission called"), D())
194
194
  return console.log("✅ [Aippy Sensors] Native bridge available, skipping permission request"), !0;
195
- if (!E())
195
+ if (!A())
196
196
  return console.warn("❌ [Aippy Sensors] Device motion not supported"), !1;
197
197
  const n = typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function";
198
198
  if (console.log("🔍 [Aippy Sensors] Permission API available:", n), n)
@@ -205,27 +205,27 @@ async function x() {
205
205
  }
206
206
  return console.log("✅ [Aippy Sensors] No permission needed (granted by default)"), !0;
207
207
  }
208
- function F(n) {
208
+ function x(n) {
209
209
  console.log("🔧 [Aippy Sensors] watchMotionNative - Setting up native bridge listener");
210
- const e = T.addMotionListener((t) => {
211
- const o = M(), i = t.gravity?.x ?? 0, r = t.gravity?.y ?? 0, c = t.gravity?.z ?? 0, a = t.userAcceleration?.x ?? 0, d = t.userAcceleration?.y ?? 0, u = t.userAcceleration?.z ?? 0, [m, l] = P(i, r, o), [g, f] = P(a, d, o), y = t.attitude && typeof t.attitude.yaw == "number" && typeof t.attitude.pitch == "number" && typeof t.attitude.roll == "number";
212
- let p = 0;
213
- y && (p = t.attitude.yaw * (180 / Math.PI), p < 0 && (p += 360));
214
- const v = {
215
- gravity: { x: m, y: l, z: c },
216
- acceleration: { x: g, y: f, z: u },
210
+ const e = U.addMotionListener((t) => {
211
+ const i = b(), o = t.gravity?.x ?? 0, r = t.gravity?.y ?? 0, l = t.gravity?.z ?? 0, c = t.userAcceleration?.x ?? 0, d = t.userAcceleration?.y ?? 0, m = t.userAcceleration?.z ?? 0, [p, u] = E(o, r, i), [f, v] = E(c, d, i), g = t.attitude && typeof t.attitude.yaw == "number" && typeof t.attitude.pitch == "number" && typeof t.attitude.roll == "number";
212
+ let w = 0;
213
+ g && (w = t.attitude.yaw * (180 / Math.PI), w < 0 && (w += 360));
214
+ const P = {
215
+ gravity: { x: p, y: u, z: l },
216
+ acceleration: { x: f, y: v, z: m },
217
217
  accelerationIncludingGravity: {
218
- x: m + g,
219
- y: l + f,
220
- z: c + u
218
+ x: p + f,
219
+ y: u + v,
220
+ z: l + m
221
221
  },
222
222
  rotation: {
223
- alpha: y ? p : (t.rotationRate?.z ?? 0) * (180 / Math.PI),
223
+ alpha: g ? w : (t.rotationRate?.z ?? 0) * (180 / Math.PI),
224
224
  beta: (t.rotationRate?.x ?? 0) * (180 / Math.PI),
225
225
  gamma: (t.rotationRate?.y ?? 0) * (180 / Math.PI)
226
226
  },
227
- attitude: y ? {
228
- yaw: p,
227
+ attitude: g ? {
228
+ yaw: w,
229
229
  pitch: t.attitude.pitch * (180 / Math.PI),
230
230
  roll: t.attitude.roll * (180 / Math.PI),
231
231
  quaternion: t.attitude.quaternion ? {
@@ -237,12 +237,12 @@ function F(n) {
237
237
  } : void 0,
238
238
  timestamp: Date.now()
239
239
  };
240
- n(v);
240
+ n(P);
241
241
  });
242
242
  return console.log("✅ [Aippy Sensors] watchMotionNative - Listener setup complete"), e;
243
243
  }
244
- async function _() {
245
- if (!E())
244
+ async function q() {
245
+ if (!A())
246
246
  return console.warn("[Aippy Sensors] Device motion not supported"), !1;
247
247
  if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function")
248
248
  try {
@@ -254,82 +254,82 @@ async function _() {
254
254
  }
255
255
  return !0;
256
256
  }
257
- function A(n, e = !0) {
258
- if (!E())
259
- throw s("Device motion API is not supported", "NOT_SUPPORTED");
260
- let t = !1, o = null;
261
- const i = (a) => {
257
+ function I(n, e = !0) {
258
+ if (!A())
259
+ throw a("Device motion API is not supported", s.NOT_SUPPORTED);
260
+ let t = !1, i = null;
261
+ const o = (c) => {
262
262
  if (!t) return;
263
- const d = M();
264
- let u, m, l;
265
- if (a.acceleration) {
266
- const w = a.accelerationIncludingGravity, h = a.acceleration;
267
- u = (w?.x ?? 0) - (h?.x ?? 0), m = (w?.y ?? 0) - (h?.y ?? 0), l = (w?.z ?? 0) - (h?.z ?? 0);
263
+ const d = b();
264
+ let m, p, u;
265
+ if (c.acceleration) {
266
+ const h = c.accelerationIncludingGravity, y = c.acceleration;
267
+ m = (h?.x ?? 0) - (y?.x ?? 0), p = (h?.y ?? 0) - (y?.y ?? 0), u = (h?.z ?? 0) - (y?.z ?? 0);
268
268
  } else {
269
- const w = a.accelerationIncludingGravity, h = 9.8;
270
- u = (w?.x ?? 0) / h, m = (w?.y ?? 0) / h, l = (w?.z ?? 0) / h;
269
+ const h = c.accelerationIncludingGravity, y = 9.8;
270
+ m = (h?.x ?? 0) / y, p = (h?.y ?? 0) / y, u = (h?.z ?? 0) / y;
271
271
  }
272
- const g = a.acceleration?.x ?? 0, f = a.acceleration?.y ?? 0, y = a.acceleration?.z ?? 0, [p, v] = P(u, m, d), [O, S] = P(g, f, d), b = {
273
- gravity: { x: p, y: v, z: l },
274
- acceleration: { x: O, y: S, z: y },
272
+ const f = c.acceleration?.x ?? 0, v = c.acceleration?.y ?? 0, g = c.acceleration?.z ?? 0, [w, P] = E(m, p, d), [O, S] = E(f, v, d), R = {
273
+ gravity: { x: w, y: P, z: u },
274
+ acceleration: { x: O, y: S, z: g },
275
275
  accelerationIncludingGravity: {
276
- x: p + O,
277
- y: v + S,
278
- z: l + y
276
+ x: w + O,
277
+ y: P + S,
278
+ z: u + g
279
279
  },
280
280
  rotation: {
281
- alpha: a.rotationRate?.alpha ?? 0,
282
- beta: a.rotationRate?.beta ?? 0,
283
- gamma: a.rotationRate?.gamma ?? 0
281
+ alpha: c.rotationRate?.alpha ?? 0,
282
+ beta: c.rotationRate?.beta ?? 0,
283
+ gamma: c.rotationRate?.gamma ?? 0
284
284
  },
285
285
  timestamp: Date.now()
286
286
  };
287
- n(b);
287
+ n(R);
288
288
  }, r = async () => {
289
- e && !await _() || (t = !0, window.addEventListener("devicemotion", i));
289
+ e && !await q() || (t = !0, window.addEventListener("devicemotion", o));
290
290
  };
291
291
  return (async () => {
292
292
  if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && e) {
293
293
  const d = async () => {
294
- o = null, await r();
294
+ i = null, await r();
295
295
  };
296
- window.addEventListener("click", d, { once: !0 }), window.addEventListener("touchstart", d, { once: !0 }), o = () => {
296
+ window.addEventListener("click", d, { once: !0 }), window.addEventListener("touchstart", d, { once: !0 }), i = () => {
297
297
  window.removeEventListener("click", d), window.removeEventListener("touchstart", d);
298
298
  };
299
299
  } else
300
300
  await r();
301
301
  })(), () => {
302
- t = !1, window.removeEventListener("devicemotion", i), o && (o(), o = null);
302
+ t = !1, window.removeEventListener("devicemotion", o), i && (i(), i = null);
303
303
  };
304
304
  }
305
- function q(n, e, t = 500) {
306
- let o = !1, i = null;
307
- const r = F((a) => {
308
- o || (o = !0, clearTimeout(c)), n(a);
309
- }), c = setTimeout(async () => {
310
- if (!o) {
305
+ function z(n, e, t = 500) {
306
+ let i = !1, o = null;
307
+ const r = x((c) => {
308
+ i || (i = !0, clearTimeout(l)), n(c);
309
+ }), l = setTimeout(async () => {
310
+ if (!i) {
311
311
  if (console.warn("[Aippy Sensors] No native data, falling back to Web API"), r(), typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && e)
312
312
  try {
313
313
  if (console.log("[Aippy Sensors] Trying direct permission request..."), await DeviceMotionEvent.requestPermission() === "granted") {
314
- console.log("[Aippy Sensors] Permission granted via fallback"), i = A(n, !1);
314
+ console.log("[Aippy Sensors] Permission granted via fallback"), o = I(n, !1);
315
315
  return;
316
316
  }
317
317
  } catch {
318
318
  console.log("[Aippy Sensors] Direct permission failed, waiting for user interaction");
319
319
  }
320
- i = A(n, e);
320
+ o = I(n, e);
321
321
  }
322
322
  }, t);
323
323
  return () => {
324
- clearTimeout(c), r(), i?.();
324
+ clearTimeout(l), r(), o?.();
325
325
  };
326
326
  }
327
- function j(n, e = !0) {
328
- return N() ? q(n, e) : A(n, e);
327
+ function Z(n, e = !0) {
328
+ return D() ? z(n, e) : I(n, e);
329
329
  }
330
- function $(n) {
331
- if (!R())
332
- throw s("Device orientation API is not supported", "NOT_SUPPORTED");
330
+ function j(n) {
331
+ if (!T())
332
+ throw a("Device orientation API is not supported", s.NOT_SUPPORTED);
333
333
  const e = (t) => {
334
334
  n({
335
335
  alpha: t.alpha ?? 0,
@@ -342,39 +342,39 @@ function $(n) {
342
342
  window.removeEventListener("deviceorientation", e);
343
343
  };
344
344
  }
345
- class z {
345
+ class G {
346
346
  isOrientationSupported() {
347
- return R();
347
+ return T();
348
348
  }
349
349
  isMotionSupported() {
350
- return E();
350
+ return A();
351
351
  }
352
352
  async getOrientation() {
353
353
  if (!this.isOrientationSupported())
354
- throw s("Device orientation API is not supported", "NOT_SUPPORTED");
354
+ throw a("Device orientation API is not supported", s.NOT_SUPPORTED);
355
355
  return new Promise((e, t) => {
356
- const o = (i) => {
357
- window.removeEventListener("deviceorientation", o), e({
358
- x: i.alpha ?? 0,
359
- y: i.beta ?? 0,
360
- z: i.gamma ?? 0,
356
+ const i = (o) => {
357
+ window.removeEventListener("deviceorientation", i), e({
358
+ x: o.alpha ?? 0,
359
+ y: o.beta ?? 0,
360
+ z: o.gamma ?? 0,
361
361
  timestamp: Date.now()
362
362
  });
363
363
  };
364
- window.addEventListener("deviceorientation", o), setTimeout(() => {
365
- window.removeEventListener("deviceorientation", o), t(s("Device orientation timeout", "UNKNOWN_ERROR"));
364
+ window.addEventListener("deviceorientation", i), setTimeout(() => {
365
+ window.removeEventListener("deviceorientation", i), t(a("Device orientation timeout", s.TIMEOUT));
366
366
  }, 5e3);
367
367
  });
368
368
  }
369
369
  /** @deprecated Use watchOrientation() instead */
370
370
  watchOrientation(e) {
371
371
  if (!this.isOrientationSupported())
372
- throw s("Device orientation API is not supported", "NOT_SUPPORTED");
373
- const t = (o) => {
372
+ throw a("Device orientation API is not supported", s.NOT_SUPPORTED);
373
+ const t = (i) => {
374
374
  e({
375
- x: o.alpha ?? 0,
376
- y: o.beta ?? 0,
377
- z: o.gamma ?? 0,
375
+ x: i.alpha ?? 0,
376
+ y: i.beta ?? 0,
377
+ z: i.gamma ?? 0,
378
378
  timestamp: Date.now()
379
379
  });
380
380
  };
@@ -384,30 +384,30 @@ class z {
384
384
  }
385
385
  async getMotion() {
386
386
  if (!this.isMotionSupported())
387
- throw s("Device motion API is not supported", "NOT_SUPPORTED");
387
+ throw a("Device motion API is not supported", s.NOT_SUPPORTED);
388
388
  return new Promise((e, t) => {
389
- const o = (i) => {
390
- window.removeEventListener("devicemotion", o), e({
391
- x: i.acceleration?.x ?? 0,
392
- y: i.acceleration?.y ?? 0,
393
- z: i.acceleration?.z ?? 0,
389
+ const i = (o) => {
390
+ window.removeEventListener("devicemotion", i), e({
391
+ x: o.acceleration?.x ?? 0,
392
+ y: o.acceleration?.y ?? 0,
393
+ z: o.acceleration?.z ?? 0,
394
394
  timestamp: Date.now()
395
395
  });
396
396
  };
397
- window.addEventListener("devicemotion", o), setTimeout(() => {
398
- window.removeEventListener("devicemotion", o), t(s("Device motion timeout", "UNKNOWN_ERROR"));
397
+ window.addEventListener("devicemotion", i), setTimeout(() => {
398
+ window.removeEventListener("devicemotion", i), t(a("Device motion timeout", s.TIMEOUT));
399
399
  }, 5e3);
400
400
  });
401
401
  }
402
402
  /** @deprecated Use watchMotion() instead */
403
403
  watchMotion(e) {
404
404
  if (!this.isMotionSupported())
405
- throw s("Device motion API is not supported", "NOT_SUPPORTED");
406
- const t = (o) => {
405
+ throw a("Device motion API is not supported", s.NOT_SUPPORTED);
406
+ const t = (i) => {
407
407
  e({
408
- x: o.acceleration?.x ?? 0,
409
- y: o.acceleration?.y ?? 0,
410
- z: o.acceleration?.z ?? 0,
408
+ x: i.acceleration?.x ?? 0,
409
+ y: i.acceleration?.y ?? 0,
410
+ z: i.acceleration?.z ?? 0,
411
411
  timestamp: Date.now()
412
412
  });
413
413
  };
@@ -416,11 +416,11 @@ class z {
416
416
  };
417
417
  }
418
418
  async requestPermission() {
419
- return x();
419
+ return _();
420
420
  }
421
421
  }
422
- const B = new z();
423
- class G {
422
+ const V = new G();
423
+ class C {
424
424
  /**
425
425
  * Check if file system access is supported
426
426
  */
@@ -438,7 +438,7 @@ class G {
438
438
  */
439
439
  async openFilePicker(e = {}) {
440
440
  if (!this.isSupported())
441
- throw s("File System Access API is not supported", "NOT_SUPPORTED");
441
+ throw a("File System Access API is not supported", s.NOT_SUPPORTED);
442
442
  try {
443
443
  const t = {
444
444
  types: e.accept ? [{
@@ -448,17 +448,17 @@ class G {
448
448
  )
449
449
  }] : void 0,
450
450
  multiple: e.multiple ?? !1
451
- }, o = await window.showOpenFilePicker(t), i = await Promise.all(
452
- o.map(async (r) => r.getFile())
451
+ }, i = await window.showOpenFilePicker(t), o = await Promise.all(
452
+ i.map(async (r) => r.getFile())
453
453
  );
454
454
  return {
455
- files: i,
456
- paths: i.map((r) => r.name)
455
+ files: o,
456
+ paths: o.map((r) => r.name)
457
457
  };
458
458
  } catch (t) {
459
- throw t instanceof Error && t.name === "AbortError" ? s("File picker was cancelled", "PERMISSION_DENIED") : s(
459
+ throw t instanceof Error && t.name === "AbortError" ? a("File picker was cancelled", s.PERMISSION_DENIED) : a(
460
460
  `Failed to open file picker: ${t instanceof Error ? t.message : "Unknown error"}`,
461
- "PERMISSION_DENIED"
461
+ s.PERMISSION_DENIED
462
462
  );
463
463
  }
464
464
  }
@@ -467,18 +467,18 @@ class G {
467
467
  */
468
468
  async openFilePickerLegacy(e = {}) {
469
469
  if (!this.isLegacySupported())
470
- throw s("File input is not supported", "NOT_SUPPORTED");
471
- return new Promise((t, o) => {
472
- const i = document.createElement("input");
473
- i.type = "file", i.multiple = e.multiple ?? !1, i.accept = e.accept?.join(",") ?? "", i.onchange = (r) => {
474
- const c = r.target, a = Array.from(c.files || []);
470
+ throw a("File input is not supported", s.NOT_SUPPORTED);
471
+ return new Promise((t, i) => {
472
+ const o = document.createElement("input");
473
+ o.type = "file", o.multiple = e.multiple ?? !1, o.accept = e.accept?.join(",") ?? "", o.onchange = (r) => {
474
+ const l = r.target, c = Array.from(l.files || []);
475
475
  t({
476
- files: a,
477
- paths: a.map((d) => d.name)
476
+ files: c,
477
+ paths: c.map((d) => d.name)
478
478
  });
479
- }, i.oncancel = () => {
480
- o(s("File picker was cancelled", "PERMISSION_DENIED"));
481
- }, i.click();
479
+ }, o.oncancel = () => {
480
+ i(a("File picker was cancelled", s.PERMISSION_DENIED));
481
+ }, o.click();
482
482
  });
483
483
  }
484
484
  /**
@@ -492,12 +492,12 @@ class G {
492
492
  */
493
493
  async saveFile(e, t) {
494
494
  try {
495
- const o = URL.createObjectURL(e), i = document.createElement("a");
496
- i.href = o, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(o);
497
- } catch (o) {
498
- throw s(
499
- `Failed to save file: ${o instanceof Error ? o.message : "Unknown error"}`,
500
- "UNKNOWN_ERROR"
495
+ const i = URL.createObjectURL(e), o = document.createElement("a");
496
+ o.href = i, o.download = t, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(i);
497
+ } catch (i) {
498
+ throw a(
499
+ `Failed to save file: ${i instanceof Error ? i.message : "Unknown error"}`,
500
+ s.OPERATION_FAILED
501
501
  );
502
502
  }
503
503
  }
@@ -505,23 +505,23 @@ class G {
505
505
  * Read file as text
506
506
  */
507
507
  async readAsText(e) {
508
- return new Promise((t, o) => {
509
- const i = new FileReader();
510
- i.onload = () => t(i.result), i.onerror = () => o(s("Failed to read file", "UNKNOWN_ERROR")), i.readAsText(e);
508
+ return new Promise((t, i) => {
509
+ const o = new FileReader();
510
+ o.onload = () => t(o.result), o.onerror = () => i(a("Failed to read file", s.OPERATION_FAILED)), o.readAsText(e);
511
511
  });
512
512
  }
513
513
  /**
514
514
  * Read file as data URL
515
515
  */
516
516
  async readAsDataURL(e) {
517
- return new Promise((t, o) => {
518
- const i = new FileReader();
519
- i.onload = () => t(i.result), i.onerror = () => o(s("Failed to read file", "UNKNOWN_ERROR")), i.readAsDataURL(e);
517
+ return new Promise((t, i) => {
518
+ const o = new FileReader();
519
+ o.onload = () => t(o.result), o.onerror = () => i(a("Failed to read file", s.OPERATION_FAILED)), o.readAsDataURL(e);
520
520
  });
521
521
  }
522
522
  }
523
- const Z = new G();
524
- function V(n) {
523
+ const K = new C();
524
+ function J(n) {
525
525
  return new Promise((e) => {
526
526
  if ("vibrate" in navigator)
527
527
  navigator.vibrate(n), e();
@@ -536,19 +536,19 @@ function V(n) {
536
536
  });
537
537
  }
538
538
  export {
539
- L as CameraAPI,
540
- G as FileSystemAPI,
539
+ F as CameraAPI,
540
+ C as FileSystemAPI,
541
541
  k as GeolocationAPI,
542
- z as SensorsAPI,
543
- X as camera,
544
- Z as fileSystem,
545
- Y as geolocation,
546
- N as hasNativeBridge,
547
- E as isMotionSupported,
548
- R as isOrientationSupported,
549
- x as requestMotionPermission,
550
- B as sensors,
551
- V as vibrate,
552
- j as watchMotion,
553
- $ as watchOrientation
542
+ G as SensorsAPI,
543
+ $ as camera,
544
+ K as fileSystem,
545
+ B as geolocation,
546
+ D as hasNativeBridge,
547
+ A as isMotionSupported,
548
+ T as isOrientationSupported,
549
+ _ as requestMotionPermission,
550
+ V as sensors,
551
+ J as vibrate,
552
+ Z as watchMotion,
553
+ j as watchOrientation
554
554
  };