@aippy/runtime 0.2.4 → 0.2.5-dev.1

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