@aippy/runtime 0.2.6-dev.0 → 0.2.7-dev.0

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