@aippy/runtime 0.2.3 → 0.2.4-dev.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- var h = Object.defineProperty;
2
- var p = (n, e, t) => e in n ? h(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var m = (n, e, t) => p(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { c as a } from "../errors-CDEBaBxB.js";
5
- class g {
1
+ var O = Object.defineProperty;
2
+ var S = (n, e, t) => e in n ? O(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var h = (n, e, t) => S(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { c as s, b as A } from "../runtime-DjBdOttl.js";
5
+ class N {
6
6
  constructor() {
7
- m(this, "stream", null);
7
+ h(this, "stream", null);
8
8
  }
9
9
  /**
10
10
  * Check if camera is supported
@@ -17,7 +17,7 @@ class g {
17
17
  */
18
18
  async getStream(e = {}) {
19
19
  if (!this.isSupported())
20
- throw a("Camera API is not supported", "NOT_SUPPORTED");
20
+ throw s("Camera API is not supported", "NOT_SUPPORTED");
21
21
  try {
22
22
  const t = {
23
23
  video: {
@@ -28,7 +28,7 @@ class g {
28
28
  };
29
29
  return this.stream = await navigator.mediaDevices.getUserMedia(t), this.stream;
30
30
  } catch (t) {
31
- throw a(
31
+ throw s(
32
32
  `Failed to access camera: ${t instanceof Error ? t.message : "Unknown error"}`,
33
33
  "PERMISSION_DENIED"
34
34
  );
@@ -39,27 +39,27 @@ class g {
39
39
  */
40
40
  async capturePhoto(e = {}) {
41
41
  if (!this.stream)
42
- throw a("No camera stream available", "NOT_SUPPORTED");
42
+ throw s("No camera stream available", "NOT_SUPPORTED");
43
43
  try {
44
44
  const t = document.createElement("video");
45
45
  t.srcObject = this.stream, t.play();
46
- const o = document.createElement("canvas"), i = o.getContext("2d");
47
- if (!i)
48
- throw a("Failed to get canvas context", "UNKNOWN_ERROR");
49
- o.width = e.width || t.videoWidth, o.height = e.height || t.videoHeight, i.drawImage(t, 0, 0, o.width, o.height);
50
- const r = e.format || "jpeg", c = e.quality === "high" ? 0.9 : e.quality === "medium" ? 0.7 : 0.5, s = await new Promise((u, w) => {
51
- o.toBlob((l) => {
52
- l ? u(l) : w(new Error("Failed to create blob"));
53
- }, `image/${r}`, c);
54
- }), d = o.toDataURL(`image/${r}`, c);
46
+ const i = document.createElement("canvas"), o = i.getContext("2d");
47
+ if (!o)
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", d = e.quality === "high" ? 0.9 : e.quality === "medium" ? 0.7 : 0.5, a = await new Promise((l, u) => {
51
+ i.toBlob((m) => {
52
+ m ? l(m) : u(new Error("Failed to create blob"));
53
+ }, `image/${r}`, d);
54
+ }), c = i.toDataURL(`image/${r}`, d);
55
55
  return {
56
- blob: s,
57
- dataUrl: d,
58
- width: o.width,
59
- height: o.height
56
+ blob: a,
57
+ dataUrl: c,
58
+ width: i.width,
59
+ height: i.height
60
60
  };
61
61
  } catch (t) {
62
- throw a(
62
+ throw s(
63
63
  `Failed to capture photo: ${t instanceof Error ? t.message : "Unknown error"}`,
64
64
  "UNKNOWN_ERROR"
65
65
  );
@@ -72,8 +72,8 @@ class g {
72
72
  this.stream && (this.stream.getTracks().forEach((e) => e.stop()), this.stream = null);
73
73
  }
74
74
  }
75
- const f = new g();
76
- class v {
75
+ const T = new N();
76
+ class R {
77
77
  /**
78
78
  * Check if geolocation is supported
79
79
  */
@@ -85,16 +85,16 @@ class v {
85
85
  */
86
86
  async getCurrentPosition(e = {}) {
87
87
  if (!this.isSupported())
88
- throw a("Geolocation API is not supported", "NOT_SUPPORTED");
89
- return new Promise((t, o) => {
90
- const i = {
88
+ throw s("Geolocation API is not supported", "NOT_SUPPORTED");
89
+ return new Promise((t, i) => {
90
+ const o = {
91
91
  enableHighAccuracy: e.enableHighAccuracy ?? !0,
92
92
  timeout: e.timeout ?? 1e4,
93
93
  maximumAge: e.maximumAge ?? 6e4
94
94
  };
95
95
  navigator.geolocation.getCurrentPosition(
96
96
  (r) => {
97
- const c = {
97
+ const d = {
98
98
  latitude: r.coords.latitude,
99
99
  longitude: r.coords.longitude,
100
100
  accuracy: r.coords.accuracy,
@@ -104,24 +104,24 @@ class v {
104
104
  speed: r.coords.speed ?? void 0,
105
105
  timestamp: r.timestamp
106
106
  };
107
- t(c);
107
+ t(d);
108
108
  },
109
109
  (r) => {
110
- let c = "UNKNOWN_ERROR", s = "Unknown geolocation error";
110
+ let d = "UNKNOWN_ERROR", a = "Unknown geolocation error";
111
111
  switch (r.code) {
112
112
  case r.PERMISSION_DENIED:
113
- c = "PERMISSION_DENIED", s = "Geolocation permission denied";
113
+ d = "PERMISSION_DENIED", a = "Geolocation permission denied";
114
114
  break;
115
115
  case r.POSITION_UNAVAILABLE:
116
- s = "Position unavailable";
116
+ a = "Position unavailable";
117
117
  break;
118
118
  case r.TIMEOUT:
119
- s = "Geolocation timeout";
119
+ a = "Geolocation timeout";
120
120
  break;
121
121
  }
122
- o(a(s, c));
122
+ i(s(a, d));
123
123
  },
124
- i
124
+ o
125
125
  );
126
126
  });
127
127
  }
@@ -130,30 +130,30 @@ class v {
130
130
  */
131
131
  watchPosition(e, t = {}) {
132
132
  if (!this.isSupported())
133
- throw a("Geolocation API is not supported", "NOT_SUPPORTED");
134
- const o = {
133
+ throw s("Geolocation API is not supported", "NOT_SUPPORTED");
134
+ const i = {
135
135
  enableHighAccuracy: t.enableHighAccuracy ?? !0,
136
136
  timeout: t.timeout ?? 1e4,
137
137
  maximumAge: t.maximumAge ?? 6e4
138
138
  };
139
139
  return navigator.geolocation.watchPosition(
140
- (i) => {
140
+ (o) => {
141
141
  const r = {
142
- latitude: i.coords.latitude,
143
- longitude: i.coords.longitude,
144
- accuracy: i.coords.accuracy,
145
- altitude: i.coords.altitude ?? void 0,
146
- altitudeAccuracy: i.coords.altitudeAccuracy ?? void 0,
147
- heading: i.coords.heading ?? void 0,
148
- speed: i.coords.speed ?? void 0,
149
- timestamp: i.timestamp
142
+ latitude: o.coords.latitude,
143
+ longitude: o.coords.longitude,
144
+ accuracy: o.coords.accuracy,
145
+ altitude: o.coords.altitude ?? void 0,
146
+ altitudeAccuracy: o.coords.altitudeAccuracy ?? void 0,
147
+ heading: o.coords.heading ?? void 0,
148
+ speed: o.coords.speed ?? void 0,
149
+ timestamp: o.timestamp
150
150
  };
151
151
  e(r);
152
152
  },
153
- (i) => {
154
- console.error("Geolocation watch error:", i);
153
+ (o) => {
154
+ console.error("Geolocation watch error:", o);
155
155
  },
156
- o
156
+ i
157
157
  );
158
158
  }
159
159
  /**
@@ -163,51 +163,215 @@ class v {
163
163
  navigator.geolocation.clearWatch(e);
164
164
  }
165
165
  }
166
- const N = new v();
167
- class E {
166
+ const x = new R();
167
+ function w() {
168
+ return "DeviceMotionEvent" in window;
169
+ }
170
+ function v() {
171
+ return "DeviceOrientationEvent" in window;
172
+ }
173
+ function f() {
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 I() {
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;
185
+ }
186
+ function y(n, e, t) {
187
+ switch (t) {
188
+ case 0:
189
+ return [n, e];
190
+ case 180:
191
+ return [-n, -e];
192
+ case 90:
193
+ return [-e, n];
194
+ case -90:
195
+ return [e, -n];
196
+ default:
197
+ return [n, e];
198
+ }
199
+ }
200
+ async function E() {
201
+ if (console.log("🔐 [Aippy Sensors] requestMotionPermission called"), f())
202
+ return console.log("✅ [Aippy Sensors] Native bridge available, skipping permission request"), !0;
203
+ if (!w())
204
+ 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)
207
+ try {
208
+ console.log("🙏 [Aippy Sensors] Requesting device motion permission...");
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;
213
+ }
214
+ return console.log("✅ [Aippy Sensors] No permission needed (granted by default)"), !0;
215
+ }
216
+ function b(n) {
217
+ console.log("🔧 [Aippy Sensors] watchMotionNative - Setting up native bridge listener");
218
+ const e = A.addMotionListener((t) => {
219
+ const i = I(), o = t.gravity?.x ?? 0, r = t.gravity?.y ?? 0, d = t.gravity?.z ?? 0, a = t.acceleration?.x ?? 0, c = t.acceleration?.y ?? 0, l = t.acceleration?.z ?? 0, [u, m] = y(o, r, i), [p, g] = y(a, c, i), P = {
220
+ gravity: {
221
+ x: u,
222
+ y: m,
223
+ z: d
224
+ // Z轴不受屏幕旋转影响
225
+ },
226
+ acceleration: {
227
+ x: p,
228
+ y: g,
229
+ z: l
230
+ // Z轴不受屏幕旋转影响
231
+ },
232
+ accelerationIncludingGravity: {
233
+ x: u + p,
234
+ y: m + g,
235
+ z: d + l
236
+ },
237
+ rotation: {
238
+ alpha: t.rotation?.alpha ?? 0,
239
+ beta: t.rotation?.beta ?? 0,
240
+ gamma: t.rotation?.gamma ?? 0
241
+ },
242
+ timestamp: Date.now()
243
+ };
244
+ n(P);
245
+ });
246
+ return console.log("✅ [Aippy Sensors] watchMotionNative - Listener setup complete"), e;
247
+ }
248
+ function D(n, e = !0) {
249
+ if (!w())
250
+ throw s("Device motion API is not supported", "NOT_SUPPORTED");
251
+ let t = !1, i = null;
252
+ const o = (a) => {
253
+ if (!t) return;
254
+ const c = {
255
+ gravity: {
256
+ x: a.acceleration?.x ?? 0,
257
+ y: a.acceleration?.y ?? 0,
258
+ z: a.acceleration?.z ?? 0
259
+ },
260
+ acceleration: {
261
+ x: a.acceleration?.x ?? 0,
262
+ y: a.acceleration?.y ?? 0,
263
+ z: a.acceleration?.z ?? 0
264
+ },
265
+ accelerationIncludingGravity: {
266
+ x: a.accelerationIncludingGravity?.x ?? 0,
267
+ y: a.accelerationIncludingGravity?.y ?? 0,
268
+ z: a.accelerationIncludingGravity?.z ?? 0
269
+ },
270
+ rotation: {
271
+ alpha: a.rotationRate?.alpha ?? 0,
272
+ beta: a.rotationRate?.beta ?? 0,
273
+ gamma: a.rotationRate?.gamma ?? 0
274
+ },
275
+ timestamp: Date.now()
276
+ };
277
+ if (a.acceleration) {
278
+ const l = a.accelerationIncludingGravity, u = a.acceleration;
279
+ c.gravity = {
280
+ x: (l?.x ?? 0) - (u?.x ?? 0),
281
+ y: (l?.y ?? 0) - (u?.y ?? 0),
282
+ z: (l?.z ?? 0) - (u?.z ?? 0)
283
+ };
284
+ } else {
285
+ const l = a.accelerationIncludingGravity, u = 9.8;
286
+ c.gravity = {
287
+ x: (l?.x ?? 0) / u,
288
+ y: (l?.y ?? 0) / u,
289
+ z: (l?.z ?? 0) / u
290
+ };
291
+ }
292
+ n(c);
293
+ }, r = async () => {
294
+ e && !await E() || (t = !0, window.addEventListener("devicemotion", o));
295
+ };
296
+ return (async () => {
297
+ if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && e) {
298
+ const c = async () => {
299
+ i = null, await r();
300
+ };
301
+ window.addEventListener("click", c, { once: !0 }), window.addEventListener("touchstart", c, { once: !0 }), i = () => {
302
+ window.removeEventListener("click", c), window.removeEventListener("touchstart", c);
303
+ };
304
+ } else
305
+ await r();
306
+ })(), () => {
307
+ t = !1, window.removeEventListener("devicemotion", o), i && (i(), i = null);
308
+ };
309
+ }
310
+ function _(n, e = !0) {
311
+ const t = f();
312
+ return console.log(`🎯 [Aippy Sensors] watchMotion - Using ${t ? "NATIVE BRIDGE" : "WEB API"} mode`), t ? (console.log("📱 [Aippy Sensors] Starting native bridge motion listener"), b(n)) : (console.log("🌐 [Aippy Sensors] Starting Web API motion listener (may require permission)"), D(n, e));
313
+ }
314
+ function F(n) {
315
+ if (!v())
316
+ throw s("Device orientation API is not supported", "NOT_SUPPORTED");
317
+ const e = (t) => {
318
+ const i = {
319
+ alpha: t.alpha ?? 0,
320
+ beta: t.beta ?? 0,
321
+ gamma: t.gamma ?? 0,
322
+ timestamp: Date.now()
323
+ };
324
+ n(i);
325
+ };
326
+ return window.addEventListener("deviceorientation", e), () => {
327
+ window.removeEventListener("deviceorientation", e);
328
+ };
329
+ }
330
+ class U {
168
331
  /**
169
332
  * Check if device orientation is supported
170
333
  */
171
334
  isOrientationSupported() {
172
- return "DeviceOrientationEvent" in window;
335
+ return v();
173
336
  }
174
337
  /**
175
338
  * Check if device motion is supported
176
339
  */
177
340
  isMotionSupported() {
178
- return "DeviceMotionEvent" in window;
341
+ return w();
179
342
  }
180
343
  /**
181
344
  * Get device orientation data
182
345
  */
183
346
  async getOrientation() {
184
347
  if (!this.isOrientationSupported())
185
- throw a("Device orientation API is not supported", "NOT_SUPPORTED");
348
+ throw s("Device orientation API is not supported", "NOT_SUPPORTED");
186
349
  return new Promise((e, t) => {
187
- const o = (i) => {
188
- window.removeEventListener("deviceorientation", o), e({
189
- x: i.alpha ?? 0,
190
- y: i.beta ?? 0,
191
- z: i.gamma ?? 0,
350
+ const i = (o) => {
351
+ window.removeEventListener("deviceorientation", i), e({
352
+ x: o.alpha ?? 0,
353
+ y: o.beta ?? 0,
354
+ z: o.gamma ?? 0,
192
355
  timestamp: Date.now()
193
356
  });
194
357
  };
195
- window.addEventListener("deviceorientation", o), setTimeout(() => {
196
- window.removeEventListener("deviceorientation", o), t(a("Device orientation timeout", "UNKNOWN_ERROR"));
358
+ window.addEventListener("deviceorientation", i), setTimeout(() => {
359
+ window.removeEventListener("deviceorientation", i), t(s("Device orientation timeout", "UNKNOWN_ERROR"));
197
360
  }, 5e3);
198
361
  });
199
362
  }
200
363
  /**
201
364
  * Watch device orientation changes
365
+ * @deprecated Use watchOrientation() function instead
202
366
  */
203
367
  watchOrientation(e) {
204
368
  if (!this.isOrientationSupported())
205
- throw a("Device orientation API is not supported", "NOT_SUPPORTED");
206
- const t = (o) => {
369
+ throw s("Device orientation API is not supported", "NOT_SUPPORTED");
370
+ const t = (i) => {
207
371
  e({
208
- x: o.alpha ?? 0,
209
- y: o.beta ?? 0,
210
- z: o.gamma ?? 0,
372
+ x: i.alpha ?? 0,
373
+ y: i.beta ?? 0,
374
+ z: i.gamma ?? 0,
211
375
  timestamp: Date.now()
212
376
  });
213
377
  };
@@ -220,32 +384,33 @@ class E {
220
384
  */
221
385
  async getMotion() {
222
386
  if (!this.isMotionSupported())
223
- throw a("Device motion API is not supported", "NOT_SUPPORTED");
387
+ throw s("Device motion API is not supported", "NOT_SUPPORTED");
224
388
  return new Promise((e, t) => {
225
- const o = (i) => {
226
- window.removeEventListener("devicemotion", o), e({
227
- x: i.acceleration?.x ?? 0,
228
- y: i.acceleration?.y ?? 0,
229
- z: i.acceleration?.z ?? 0,
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,
230
394
  timestamp: Date.now()
231
395
  });
232
396
  };
233
- window.addEventListener("devicemotion", o), setTimeout(() => {
234
- window.removeEventListener("devicemotion", o), t(a("Device motion timeout", "UNKNOWN_ERROR"));
397
+ window.addEventListener("devicemotion", i), setTimeout(() => {
398
+ window.removeEventListener("devicemotion", i), t(s("Device motion timeout", "UNKNOWN_ERROR"));
235
399
  }, 5e3);
236
400
  });
237
401
  }
238
402
  /**
239
403
  * Watch device motion changes
404
+ * @deprecated Use watchMotion() function instead
240
405
  */
241
406
  watchMotion(e) {
242
407
  if (!this.isMotionSupported())
243
- throw a("Device motion API is not supported", "NOT_SUPPORTED");
244
- const t = (o) => {
408
+ throw s("Device motion API is not supported", "NOT_SUPPORTED");
409
+ const t = (i) => {
245
410
  e({
246
- x: o.acceleration?.x ?? 0,
247
- y: o.acceleration?.y ?? 0,
248
- z: o.acceleration?.z ?? 0,
411
+ x: i.acceleration?.x ?? 0,
412
+ y: i.acceleration?.y ?? 0,
413
+ z: i.acceleration?.z ?? 0,
249
414
  timestamp: Date.now()
250
415
  });
251
416
  };
@@ -257,17 +422,11 @@ class E {
257
422
  * Request permission for motion sensors (iOS 13+)
258
423
  */
259
424
  async requestPermission() {
260
- if (!this.isMotionSupported())
261
- return !1;
262
- try {
263
- return (await navigator.permissions?.query({ name: "accelerometer" }))?.state === "granted";
264
- } catch {
265
- return !1;
266
- }
425
+ return E();
267
426
  }
268
427
  }
269
- const R = new E();
270
- class O {
428
+ const z = new U();
429
+ class M {
271
430
  /**
272
431
  * Check if file system access is supported
273
432
  */
@@ -285,7 +444,7 @@ class O {
285
444
  */
286
445
  async openFilePicker(e = {}) {
287
446
  if (!this.isSupported())
288
- throw a("File System Access API is not supported", "NOT_SUPPORTED");
447
+ throw s("File System Access API is not supported", "NOT_SUPPORTED");
289
448
  try {
290
449
  const t = {
291
450
  types: e.accept ? [{
@@ -295,15 +454,15 @@ class O {
295
454
  )
296
455
  }] : void 0,
297
456
  multiple: e.multiple ?? !1
298
- }, o = await window.showOpenFilePicker(t), i = await Promise.all(
299
- o.map(async (r) => r.getFile())
457
+ }, i = await window.showOpenFilePicker(t), o = await Promise.all(
458
+ i.map(async (r) => r.getFile())
300
459
  );
301
460
  return {
302
- files: i,
303
- paths: i.map((r) => r.name)
461
+ files: o,
462
+ paths: o.map((r) => r.name)
304
463
  };
305
464
  } catch (t) {
306
- throw t instanceof Error && t.name === "AbortError" ? a("File picker was cancelled", "PERMISSION_DENIED") : a(
465
+ throw t instanceof Error && t.name === "AbortError" ? s("File picker was cancelled", "PERMISSION_DENIED") : s(
307
466
  `Failed to open file picker: ${t instanceof Error ? t.message : "Unknown error"}`,
308
467
  "PERMISSION_DENIED"
309
468
  );
@@ -314,18 +473,18 @@ class O {
314
473
  */
315
474
  async openFilePickerLegacy(e = {}) {
316
475
  if (!this.isLegacySupported())
317
- throw a("File input is not supported", "NOT_SUPPORTED");
318
- return new Promise((t, o) => {
319
- const i = document.createElement("input");
320
- i.type = "file", i.multiple = e.multiple ?? !1, i.accept = e.accept?.join(",") ?? "", i.onchange = (r) => {
321
- const c = r.target, s = Array.from(c.files || []);
476
+ throw s("File input is not supported", "NOT_SUPPORTED");
477
+ return new Promise((t, i) => {
478
+ const o = document.createElement("input");
479
+ o.type = "file", o.multiple = e.multiple ?? !1, o.accept = e.accept?.join(",") ?? "", o.onchange = (r) => {
480
+ const d = r.target, a = Array.from(d.files || []);
322
481
  t({
323
- files: s,
324
- paths: s.map((d) => d.name)
482
+ files: a,
483
+ paths: a.map((c) => c.name)
325
484
  });
326
- }, i.oncancel = () => {
327
- o(a("File picker was cancelled", "PERMISSION_DENIED"));
328
- }, i.click();
485
+ }, o.oncancel = () => {
486
+ i(s("File picker was cancelled", "PERMISSION_DENIED"));
487
+ }, o.click();
329
488
  });
330
489
  }
331
490
  /**
@@ -339,11 +498,11 @@ class O {
339
498
  */
340
499
  async saveFile(e, t) {
341
500
  try {
342
- const o = URL.createObjectURL(e), i = document.createElement("a");
343
- i.href = o, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(o);
344
- } catch (o) {
345
- throw a(
346
- `Failed to save file: ${o instanceof Error ? o.message : "Unknown error"}`,
501
+ const i = URL.createObjectURL(e), o = document.createElement("a");
502
+ o.href = i, o.download = t, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(i);
503
+ } catch (i) {
504
+ throw s(
505
+ `Failed to save file: ${i instanceof Error ? i.message : "Unknown error"}`,
347
506
  "UNKNOWN_ERROR"
348
507
  );
349
508
  }
@@ -352,23 +511,23 @@ class O {
352
511
  * Read file as text
353
512
  */
354
513
  async readAsText(e) {
355
- return new Promise((t, o) => {
356
- const i = new FileReader();
357
- i.onload = () => t(i.result), i.onerror = () => o(a("Failed to read file", "UNKNOWN_ERROR")), i.readAsText(e);
514
+ return new Promise((t, i) => {
515
+ const o = new FileReader();
516
+ o.onload = () => t(o.result), o.onerror = () => i(s("Failed to read file", "UNKNOWN_ERROR")), o.readAsText(e);
358
517
  });
359
518
  }
360
519
  /**
361
520
  * Read file as data URL
362
521
  */
363
522
  async readAsDataURL(e) {
364
- return new Promise((t, o) => {
365
- const i = new FileReader();
366
- i.onload = () => t(i.result), i.onerror = () => o(a("Failed to read file", "UNKNOWN_ERROR")), i.readAsDataURL(e);
523
+ return new Promise((t, i) => {
524
+ const o = new FileReader();
525
+ o.onload = () => t(o.result), o.onerror = () => i(s("Failed to read file", "UNKNOWN_ERROR")), o.readAsDataURL(e);
367
526
  });
368
527
  }
369
528
  }
370
- const S = new O();
371
- function D(n) {
529
+ const G = new M();
530
+ function W(n) {
372
531
  return new Promise((e) => {
373
532
  if ("vibrate" in navigator)
374
533
  navigator.vibrate(n), e();
@@ -383,13 +542,19 @@ function D(n) {
383
542
  });
384
543
  }
385
544
  export {
386
- g as CameraAPI,
387
- O as FileSystemAPI,
388
- v as GeolocationAPI,
389
- E as SensorsAPI,
390
- f as camera,
391
- S as fileSystem,
392
- N as geolocation,
393
- R as sensors,
394
- D as vibrate
545
+ N as CameraAPI,
546
+ M as FileSystemAPI,
547
+ R as GeolocationAPI,
548
+ U as SensorsAPI,
549
+ T as camera,
550
+ G as fileSystem,
551
+ x as geolocation,
552
+ f as hasNativeBridge,
553
+ w as isMotionSupported,
554
+ v as isOrientationSupported,
555
+ E as requestMotionPermission,
556
+ z as sensors,
557
+ W as vibrate,
558
+ _ as watchMotion,
559
+ F as watchOrientation
395
560
  };
@@ -1,6 +1,39 @@
1
- import { SensorData } from './types';
1
+ import { SensorData, MotionData, OrientationData } from './types';
2
2
  /**
3
- * Device sensors functionality wrapper
3
+ * Check if device motion is supported
4
+ */
5
+ export declare function isMotionSupported(): boolean;
6
+ /**
7
+ * Check if device orientation is supported
8
+ */
9
+ export declare function isOrientationSupported(): boolean;
10
+ /**
11
+ * Check if native bridge is available
12
+ */
13
+ export declare function hasNativeBridge(): boolean;
14
+ /**
15
+ * Request permission for motion sensors (iOS 13+)
16
+ * @returns Promise<boolean> - true if permission granted
17
+ */
18
+ export declare function requestMotionPermission(): Promise<boolean>;
19
+ /**
20
+ * Watch device motion changes with full motion data
21
+ * Automatically uses native bridge if available, otherwise falls back to Web API
22
+ *
23
+ * @param callback - Function to call with motion data
24
+ * @param autoRequestPermission - Automatically request permission on iOS (default: true, only for Web API)
25
+ * @returns Cleanup function to stop watching
26
+ */
27
+ export declare function watchMotion(callback: (data: MotionData) => void, autoRequestPermission?: boolean): () => void;
28
+ /**
29
+ * Watch device orientation changes
30
+ * @param callback - Function to call with orientation data
31
+ * @returns Cleanup function to stop watching
32
+ */
33
+ export declare function watchOrientation(callback: (data: OrientationData) => void): () => void;
34
+ /**
35
+ * Legacy SensorsAPI class for backward compatibility
36
+ * @deprecated Use watchMotion() and watchOrientation() functions instead
4
37
  */
5
38
  export declare class SensorsAPI {
6
39
  /**
@@ -17,6 +50,7 @@ export declare class SensorsAPI {
17
50
  getOrientation(): Promise<SensorData>;
18
51
  /**
19
52
  * Watch device orientation changes
53
+ * @deprecated Use watchOrientation() function instead
20
54
  */
21
55
  watchOrientation(callback: (data: SensorData) => void): () => void;
22
56
  /**
@@ -25,6 +59,7 @@ export declare class SensorsAPI {
25
59
  getMotion(): Promise<SensorData>;
26
60
  /**
27
61
  * Watch device motion changes
62
+ * @deprecated Use watchMotion() function instead
28
63
  */
29
64
  watchMotion(callback: (data: SensorData) => void): () => void;
30
65
  /**
@@ -33,6 +68,7 @@ export declare class SensorsAPI {
33
68
  requestPermission(): Promise<boolean>;
34
69
  }
35
70
  /**
36
- * Sensors API instance
71
+ * Sensors API instance (for backward compatibility)
72
+ * @deprecated Use watchMotion() and watchOrientation() functions instead
37
73
  */
38
74
  export declare const sensors: SensorsAPI;