@aippy/runtime 0.2.5-dev.1 → 0.2.6

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