@aippy/runtime 0.2.4-dev.10 → 0.2.4-dev.12

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.
@@ -22,7 +22,7 @@ function c(e) {
22
22
  }
23
23
  };
24
24
  }
25
- const r = "0.2.4-dev.10", a = {
25
+ const r = "0.2.4-dev.12", a = {
26
26
  version: r
27
27
  }, i = a.version, t = "@aippy/runtime";
28
28
  function p() {
@@ -1,10 +1,10 @@
1
- var N = Object.defineProperty;
2
- var R = (o, e, t) => e in o ? N(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var E = (o, e, t) => R(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { c as a, b as O } from "../runtime-DjBdOttl.js";
5
- class b {
1
+ var U = Object.defineProperty;
2
+ var M = (n, e, t) => e in n ? U(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var A = (n, e, t) => M(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { c as s, b as L } from "../runtime-DjBdOttl.js";
5
+ class k {
6
6
  constructor() {
7
- E(this, "stream", null);
7
+ A(this, "stream", null);
8
8
  }
9
9
  /**
10
10
  * Check if camera is supported
@@ -17,7 +17,7 @@ class b {
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 b {
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 b {
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 i = document.createElement("canvas"), n = i.getContext("2d");
47
- if (!n)
48
- throw a("Failed to get canvas context", "UNKNOWN_ERROR");
49
- i.width = e.width || t.videoWidth, i.height = e.height || t.videoHeight, n.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, s = await new Promise((m, p) => {
51
- i.toBlob((w) => {
52
- w ? m(w) : p(new Error("Failed to create blob"));
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", c = e.quality === "high" ? 0.9 : e.quality === "medium" ? 0.7 : 0.5, a = await new Promise((u, m) => {
51
+ i.toBlob((l) => {
52
+ l ? u(l) : m(new Error("Failed to create blob"));
53
53
  }, `image/${r}`, c);
54
- }), u = i.toDataURL(`image/${r}`, c);
54
+ }), d = i.toDataURL(`image/${r}`, c);
55
55
  return {
56
- blob: s,
57
- dataUrl: u,
56
+ blob: a,
57
+ dataUrl: d,
58
58
  width: i.width,
59
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 b {
72
72
  this.stream && (this.stream.getTracks().forEach((e) => e.stop()), this.stream = null);
73
73
  }
74
74
  }
75
- const W = new b();
76
- class I {
75
+ const H = new k();
76
+ class T {
77
77
  /**
78
78
  * Check if geolocation is supported
79
79
  */
@@ -85,9 +85,9 @@ class I {
85
85
  */
86
86
  async getCurrentPosition(e = {}) {
87
87
  if (!this.isSupported())
88
- throw a("Geolocation API is not supported", "NOT_SUPPORTED");
88
+ throw s("Geolocation API is not supported", "NOT_SUPPORTED");
89
89
  return new Promise((t, i) => {
90
- const n = {
90
+ const o = {
91
91
  enableHighAccuracy: e.enableHighAccuracy ?? !0,
92
92
  timeout: e.timeout ?? 1e4,
93
93
  maximumAge: e.maximumAge ?? 6e4
@@ -107,21 +107,21 @@ class I {
107
107
  t(c);
108
108
  },
109
109
  (r) => {
110
- let c = "UNKNOWN_ERROR", s = "Unknown geolocation error";
110
+ let c = "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
+ c = "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
- i(a(s, c));
122
+ i(s(a, c));
123
123
  },
124
- n
124
+ o
125
125
  );
126
126
  });
127
127
  }
@@ -130,28 +130,28 @@ class I {
130
130
  */
131
131
  watchPosition(e, t = {}) {
132
132
  if (!this.isSupported())
133
- throw a("Geolocation API is not supported", "NOT_SUPPORTED");
133
+ throw s("Geolocation API is not supported", "NOT_SUPPORTED");
134
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
- (n) => {
140
+ (o) => {
141
141
  const r = {
142
- latitude: n.coords.latitude,
143
- longitude: n.coords.longitude,
144
- accuracy: n.coords.accuracy,
145
- altitude: n.coords.altitude ?? void 0,
146
- altitudeAccuracy: n.coords.altitudeAccuracy ?? void 0,
147
- heading: n.coords.heading ?? void 0,
148
- speed: n.coords.speed ?? void 0,
149
- timestamp: n.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
- (n) => {
154
- console.error("Geolocation watch error:", n);
153
+ (o) => {
154
+ console.error("Geolocation watch error:", o);
155
155
  },
156
156
  i
157
157
  );
@@ -163,47 +163,47 @@ class I {
163
163
  navigator.geolocation.clearWatch(e);
164
164
  }
165
165
  }
166
- const z = new I();
167
- function v() {
166
+ const q = new T();
167
+ function f() {
168
168
  return "DeviceMotionEvent" in window;
169
169
  }
170
- function y() {
170
+ function N() {
171
171
  return "DeviceOrientationEvent" in window;
172
172
  }
173
- function f() {
174
- const o = typeof window < "u", e = o && !!window.webkit, t = e && !!window.webkit?.messageHandlers, i = t && !!window.webkit?.messageHandlers?.aippyListener;
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
175
  return console.log("🔍 [Aippy Sensors] hasNativeBridge check:", {
176
- hasWindow: o,
176
+ hasWindow: n,
177
177
  hasWebkit: e,
178
178
  hasMessageHandlers: t,
179
179
  hasAippyListener: i,
180
180
  result: i
181
181
  }), i;
182
182
  }
183
- function D() {
183
+ function I() {
184
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
185
  }
186
- function P(o, e, t) {
186
+ function y(n, e, t) {
187
187
  switch (t) {
188
188
  case 0:
189
- return [o, e];
189
+ return [n, e];
190
190
  case 180:
191
- return [-o, -e];
191
+ return [-n, -e];
192
192
  case 90:
193
- return [e, -o];
193
+ return [-e, n];
194
194
  case -90:
195
- return [-e, o];
195
+ return [e, -n];
196
196
  default:
197
- return [o, e];
197
+ return [n, e];
198
198
  }
199
199
  }
200
- async function S() {
201
- if (console.log("🔐 [Aippy Sensors] requestMotionPermission called"), f())
200
+ async function b() {
201
+ if (console.log("🔐 [Aippy Sensors] requestMotionPermission called"), R())
202
202
  return console.log("✅ [Aippy Sensors] Native bridge available, skipping permission request"), !0;
203
- if (!v())
203
+ if (!f())
204
204
  return console.warn("❌ [Aippy Sensors] Device motion not supported"), !1;
205
- const o = typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function";
206
- if (console.log("🔍 [Aippy Sensors] Permission API available:", o), o)
205
+ const n = typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function";
206
+ if (console.log("🔍 [Aippy Sensors] Permission API available:", n), n)
207
207
  try {
208
208
  console.log("🙏 [Aippy Sensors] Requesting device motion permission...");
209
209
  const e = await DeviceMotionEvent.requestPermission();
@@ -213,26 +213,26 @@ async function S() {
213
213
  }
214
214
  return console.log("✅ [Aippy Sensors] No permission needed (granted by default)"), !0;
215
215
  }
216
- function L(o) {
216
+ function _(n) {
217
217
  console.log("🔧 [Aippy Sensors] watchMotionNative - Setting up native bridge listener");
218
- const e = O.addMotionListener((t) => {
219
- const i = D(), n = t.gravity?.x ?? 0, r = t.gravity?.y ?? 0, c = t.gravity?.z ?? 0, s = t.acceleration?.x ?? 0, u = t.acceleration?.y ?? 0, m = t.acceleration?.z ?? 0, [p, w] = P(n, r, i), [d, l] = P(s, u, i), g = -p, h = -w, A = {
218
+ const e = L.addMotionListener((t) => {
219
+ const i = I(), o = t.gravity?.x ?? 0, r = t.gravity?.y ?? 0, c = t.gravity?.z ?? 0, a = t.acceleration?.x ?? 0, d = t.acceleration?.y ?? 0, u = t.acceleration?.z ?? 0, [m, l] = y(o, r, i), [g, h] = y(a, d, i), v = {
220
220
  gravity: {
221
- x: g,
222
- y: h,
221
+ x: m,
222
+ y: l,
223
223
  z: c
224
224
  // Z轴不受屏幕旋转影响
225
225
  },
226
226
  acceleration: {
227
- x: d,
228
- y: l,
229
- z: m
227
+ x: g,
228
+ y: h,
229
+ z: u
230
230
  // Z轴不受屏幕旋转影响
231
231
  },
232
232
  accelerationIncludingGravity: {
233
- x: g + d,
234
- y: h + l,
235
- z: c + m
233
+ x: m + g,
234
+ y: l + h,
235
+ z: c + u
236
236
  },
237
237
  rotation: {
238
238
  alpha: t.rotation?.alpha ?? 0,
@@ -241,81 +241,75 @@ function L(o) {
241
241
  },
242
242
  timestamp: Date.now()
243
243
  };
244
- o(A);
244
+ n(v);
245
245
  });
246
246
  return console.log("✅ [Aippy Sensors] watchMotionNative - Listener setup complete"), e;
247
247
  }
248
- function U(o, e = !0) {
249
- if (!y() && !v())
250
- throw a("Device motion/orientation API is not supported", "NOT_SUPPORTED");
251
- let t = !1, i = null, n = 0, r = 0, c = 0, s = { x: 0, y: 0, z: 0 };
252
- const u = (d) => {
248
+ function F(n, e = !0) {
249
+ if (!f())
250
+ throw s("Device motion API is not supported", "NOT_SUPPORTED");
251
+ let t = !1, i = null;
252
+ const o = (a) => {
253
253
  if (!t) return;
254
- n = d.gamma ?? 0, r = d.beta ?? 0, c = d.alpha ?? 0;
255
- const l = n / 90, g = r / 90, h = {
254
+ const d = I();
255
+ let u, m, l;
256
+ if (a.acceleration) {
257
+ const w = a.accelerationIncludingGravity, p = a.acceleration;
258
+ u = (w?.x ?? 0) - (p?.x ?? 0), m = (w?.y ?? 0) - (p?.y ?? 0), l = (w?.z ?? 0) - (p?.z ?? 0);
259
+ } else {
260
+ const w = a.accelerationIncludingGravity, p = 9.8;
261
+ u = (w?.x ?? 0) / p, m = (w?.y ?? 0) / p, l = (w?.z ?? 0) / p;
262
+ }
263
+ const g = a.acceleration?.x ?? 0, h = a.acceleration?.y ?? 0, v = a.acceleration?.z ?? 0, [E, P] = y(u, m, d), [O, S] = y(g, h, d), D = {
256
264
  gravity: {
257
- x: l,
258
- y: g,
259
- z: 0
260
- // Z is not available from orientation
265
+ x: E,
266
+ y: P,
267
+ z: l
268
+ // Z轴不受屏幕旋转影响
269
+ },
270
+ acceleration: {
271
+ x: O,
272
+ y: S,
273
+ z: v
274
+ // Z轴不受屏幕旋转影响
261
275
  },
262
- acceleration: s,
263
276
  accelerationIncludingGravity: {
264
- x: l + s.x,
265
- y: g + s.y,
266
- z: s.z
277
+ x: E + O,
278
+ y: P + S,
279
+ z: l + v
267
280
  },
268
281
  rotation: {
269
- alpha: c,
270
- beta: r,
271
- gamma: n
282
+ alpha: a.rotationRate?.alpha ?? 0,
283
+ beta: a.rotationRate?.beta ?? 0,
284
+ gamma: a.rotationRate?.gamma ?? 0
272
285
  },
273
286
  timestamp: Date.now()
274
287
  };
275
- o(h);
276
- }, m = (d) => {
277
- t && (s = {
278
- x: d.acceleration?.x ?? 0,
279
- y: d.acceleration?.y ?? 0,
280
- z: d.acceleration?.z ?? 0
281
- });
282
- }, p = async () => {
283
- e && !await S() || (t = !0, window.addEventListener("deviceorientation", u), v() && window.addEventListener("devicemotion", m));
288
+ n(D);
289
+ }, r = async () => {
290
+ e && !await b() || (t = !0, window.addEventListener("devicemotion", o));
284
291
  };
285
292
  return (async () => {
286
293
  if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && e) {
287
- const l = async () => {
288
- i = null, await p();
294
+ const d = async () => {
295
+ i = null, await r();
289
296
  };
290
- window.addEventListener("click", l, { once: !0 }), window.addEventListener("touchstart", l, { once: !0 }), i = () => {
291
- window.removeEventListener("click", l), window.removeEventListener("touchstart", l);
297
+ window.addEventListener("click", d, { once: !0 }), window.addEventListener("touchstart", d, { once: !0 }), i = () => {
298
+ window.removeEventListener("click", d), window.removeEventListener("touchstart", d);
292
299
  };
293
300
  } else
294
- await p();
301
+ await r();
295
302
  })(), () => {
296
- t = !1, window.removeEventListener("deviceorientation", u), window.removeEventListener("devicemotion", m), i && (i(), i = null);
303
+ t = !1, window.removeEventListener("devicemotion", o), i && (i(), i = null);
297
304
  };
298
305
  }
299
- function G(o, e = !0) {
300
- const t = f();
301
- return console.log(`🎯 [Aippy Sensors] watchMotion - Using ${t ? "NATIVE BRIDGE" : "WEB API"} mode`), t ? (console.log("📱 [Aippy Sensors] Starting native bridge motion listener"), L(o)) : (console.log("🌐 [Aippy Sensors] Starting Web API motion listener (may require permission)"), U(o, e));
306
+ function C(n, e = !0) {
307
+ const t = R();
308
+ return console.log(`🎯 [Aippy Sensors] watchMotion - Using ${t ? "NATIVE BRIDGE" : "WEB API"} mode`), t ? (console.log("📱 [Aippy Sensors] Starting native bridge motion listener"), _(n)) : (console.log("🌐 [Aippy Sensors] Starting Web API motion listener (may require permission)"), F(n, e));
302
309
  }
303
- function M(o) {
304
- console.log("🔧 [Aippy Sensors] watchOrientationNative - Setting up native bridge listener");
305
- const e = O.addMotionListener((t) => {
306
- const i = {
307
- alpha: t.rotation?.alpha ?? 0,
308
- beta: t.rotation?.beta ?? 0,
309
- gamma: t.rotation?.gamma ?? 0,
310
- timestamp: Date.now()
311
- };
312
- o(i);
313
- });
314
- return console.log("✅ [Aippy Sensors] watchOrientationNative - Listener setup complete"), e;
315
- }
316
- function T(o) {
317
- if (!y())
318
- throw a("Device orientation API is not supported", "NOT_SUPPORTED");
310
+ function B(n) {
311
+ if (!N())
312
+ throw s("Device orientation API is not supported", "NOT_SUPPORTED");
319
313
  const e = (t) => {
320
314
  const i = {
321
315
  alpha: t.alpha ?? 0,
@@ -323,46 +317,42 @@ function T(o) {
323
317
  gamma: t.gamma ?? 0,
324
318
  timestamp: Date.now()
325
319
  };
326
- o(i);
320
+ n(i);
327
321
  };
328
322
  return window.addEventListener("deviceorientation", e), () => {
329
323
  window.removeEventListener("deviceorientation", e);
330
324
  };
331
325
  }
332
- function H(o) {
333
- const e = f();
334
- return console.log(`🎯 [Aippy Sensors] watchOrientation - Using ${e ? "NATIVE BRIDGE" : "WEB API"} mode`), e ? (console.log("📱 [Aippy Sensors] Starting native bridge orientation listener"), M(o)) : (console.log("🌐 [Aippy Sensors] Starting Web API orientation listener"), T(o));
335
- }
336
- class k {
326
+ class x {
337
327
  /**
338
328
  * Check if device orientation is supported
339
329
  */
340
330
  isOrientationSupported() {
341
- return y();
331
+ return N();
342
332
  }
343
333
  /**
344
334
  * Check if device motion is supported
345
335
  */
346
336
  isMotionSupported() {
347
- return v();
337
+ return f();
348
338
  }
349
339
  /**
350
340
  * Get device orientation data
351
341
  */
352
342
  async getOrientation() {
353
343
  if (!this.isOrientationSupported())
354
- throw a("Device orientation API is not supported", "NOT_SUPPORTED");
344
+ throw s("Device orientation API is not supported", "NOT_SUPPORTED");
355
345
  return new Promise((e, t) => {
356
- const i = (n) => {
346
+ const i = (o) => {
357
347
  window.removeEventListener("deviceorientation", i), e({
358
- x: n.alpha ?? 0,
359
- y: n.beta ?? 0,
360
- z: n.gamma ?? 0,
348
+ x: o.alpha ?? 0,
349
+ y: o.beta ?? 0,
350
+ z: o.gamma ?? 0,
361
351
  timestamp: Date.now()
362
352
  });
363
353
  };
364
354
  window.addEventListener("deviceorientation", i), setTimeout(() => {
365
- window.removeEventListener("deviceorientation", i), t(a("Device orientation timeout", "UNKNOWN_ERROR"));
355
+ window.removeEventListener("deviceorientation", i), t(s("Device orientation timeout", "UNKNOWN_ERROR"));
366
356
  }, 5e3);
367
357
  });
368
358
  }
@@ -372,7 +362,7 @@ class k {
372
362
  */
373
363
  watchOrientation(e) {
374
364
  if (!this.isOrientationSupported())
375
- throw a("Device orientation API is not supported", "NOT_SUPPORTED");
365
+ throw s("Device orientation API is not supported", "NOT_SUPPORTED");
376
366
  const t = (i) => {
377
367
  e({
378
368
  x: i.alpha ?? 0,
@@ -390,18 +380,18 @@ class k {
390
380
  */
391
381
  async getMotion() {
392
382
  if (!this.isMotionSupported())
393
- throw a("Device motion API is not supported", "NOT_SUPPORTED");
383
+ throw s("Device motion API is not supported", "NOT_SUPPORTED");
394
384
  return new Promise((e, t) => {
395
- const i = (n) => {
385
+ const i = (o) => {
396
386
  window.removeEventListener("devicemotion", i), e({
397
- x: n.acceleration?.x ?? 0,
398
- y: n.acceleration?.y ?? 0,
399
- z: n.acceleration?.z ?? 0,
387
+ x: o.acceleration?.x ?? 0,
388
+ y: o.acceleration?.y ?? 0,
389
+ z: o.acceleration?.z ?? 0,
400
390
  timestamp: Date.now()
401
391
  });
402
392
  };
403
393
  window.addEventListener("devicemotion", i), setTimeout(() => {
404
- window.removeEventListener("devicemotion", i), t(a("Device motion timeout", "UNKNOWN_ERROR"));
394
+ window.removeEventListener("devicemotion", i), t(s("Device motion timeout", "UNKNOWN_ERROR"));
405
395
  }, 5e3);
406
396
  });
407
397
  }
@@ -411,7 +401,7 @@ class k {
411
401
  */
412
402
  watchMotion(e) {
413
403
  if (!this.isMotionSupported())
414
- throw a("Device motion API is not supported", "NOT_SUPPORTED");
404
+ throw s("Device motion API is not supported", "NOT_SUPPORTED");
415
405
  const t = (i) => {
416
406
  e({
417
407
  x: i.acceleration?.x ?? 0,
@@ -428,11 +418,11 @@ class k {
428
418
  * Request permission for motion sensors (iOS 13+)
429
419
  */
430
420
  async requestPermission() {
431
- return S();
421
+ return b();
432
422
  }
433
423
  }
434
- const q = new k();
435
- class _ {
424
+ const K = new x();
425
+ class G {
436
426
  /**
437
427
  * Check if file system access is supported
438
428
  */
@@ -450,7 +440,7 @@ class _ {
450
440
  */
451
441
  async openFilePicker(e = {}) {
452
442
  if (!this.isSupported())
453
- throw a("File System Access API is not supported", "NOT_SUPPORTED");
443
+ throw s("File System Access API is not supported", "NOT_SUPPORTED");
454
444
  try {
455
445
  const t = {
456
446
  types: e.accept ? [{
@@ -460,15 +450,15 @@ class _ {
460
450
  )
461
451
  }] : void 0,
462
452
  multiple: e.multiple ?? !1
463
- }, i = await window.showOpenFilePicker(t), n = await Promise.all(
453
+ }, i = await window.showOpenFilePicker(t), o = await Promise.all(
464
454
  i.map(async (r) => r.getFile())
465
455
  );
466
456
  return {
467
- files: n,
468
- paths: n.map((r) => r.name)
457
+ files: o,
458
+ paths: o.map((r) => r.name)
469
459
  };
470
460
  } catch (t) {
471
- throw t instanceof Error && t.name === "AbortError" ? a("File picker was cancelled", "PERMISSION_DENIED") : a(
461
+ throw t instanceof Error && t.name === "AbortError" ? s("File picker was cancelled", "PERMISSION_DENIED") : s(
472
462
  `Failed to open file picker: ${t instanceof Error ? t.message : "Unknown error"}`,
473
463
  "PERMISSION_DENIED"
474
464
  );
@@ -479,18 +469,18 @@ class _ {
479
469
  */
480
470
  async openFilePickerLegacy(e = {}) {
481
471
  if (!this.isLegacySupported())
482
- throw a("File input is not supported", "NOT_SUPPORTED");
472
+ throw s("File input is not supported", "NOT_SUPPORTED");
483
473
  return new Promise((t, i) => {
484
- const n = document.createElement("input");
485
- n.type = "file", n.multiple = e.multiple ?? !1, n.accept = e.accept?.join(",") ?? "", n.onchange = (r) => {
486
- const c = r.target, s = Array.from(c.files || []);
474
+ const o = document.createElement("input");
475
+ o.type = "file", o.multiple = e.multiple ?? !1, o.accept = e.accept?.join(",") ?? "", o.onchange = (r) => {
476
+ const c = r.target, a = Array.from(c.files || []);
487
477
  t({
488
- files: s,
489
- paths: s.map((u) => u.name)
478
+ files: a,
479
+ paths: a.map((d) => d.name)
490
480
  });
491
- }, n.oncancel = () => {
492
- i(a("File picker was cancelled", "PERMISSION_DENIED"));
493
- }, n.click();
481
+ }, o.oncancel = () => {
482
+ i(s("File picker was cancelled", "PERMISSION_DENIED"));
483
+ }, o.click();
494
484
  });
495
485
  }
496
486
  /**
@@ -504,10 +494,10 @@ class _ {
504
494
  */
505
495
  async saveFile(e, t) {
506
496
  try {
507
- const i = URL.createObjectURL(e), n = document.createElement("a");
508
- n.href = i, n.download = t, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(i);
497
+ const i = URL.createObjectURL(e), o = document.createElement("a");
498
+ o.href = i, o.download = t, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(i);
509
499
  } catch (i) {
510
- throw a(
500
+ throw s(
511
501
  `Failed to save file: ${i instanceof Error ? i.message : "Unknown error"}`,
512
502
  "UNKNOWN_ERROR"
513
503
  );
@@ -518,8 +508,8 @@ class _ {
518
508
  */
519
509
  async readAsText(e) {
520
510
  return new Promise((t, i) => {
521
- const n = new FileReader();
522
- n.onload = () => t(n.result), n.onerror = () => i(a("Failed to read file", "UNKNOWN_ERROR")), n.readAsText(e);
511
+ const o = new FileReader();
512
+ o.onload = () => t(o.result), o.onerror = () => i(s("Failed to read file", "UNKNOWN_ERROR")), o.readAsText(e);
523
513
  });
524
514
  }
525
515
  /**
@@ -527,20 +517,20 @@ class _ {
527
517
  */
528
518
  async readAsDataURL(e) {
529
519
  return new Promise((t, i) => {
530
- const n = new FileReader();
531
- n.onload = () => t(n.result), n.onerror = () => i(a("Failed to read file", "UNKNOWN_ERROR")), n.readAsDataURL(e);
520
+ const o = new FileReader();
521
+ o.onload = () => t(o.result), o.onerror = () => i(s("Failed to read file", "UNKNOWN_ERROR")), o.readAsDataURL(e);
532
522
  });
533
523
  }
534
524
  }
535
- const B = new _();
536
- function C(o) {
525
+ const X = new G();
526
+ function Y(n) {
537
527
  return new Promise((e) => {
538
528
  if ("vibrate" in navigator)
539
- navigator.vibrate(o), e();
529
+ navigator.vibrate(n), e();
540
530
  else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.aippyListener) {
541
531
  const t = {
542
532
  command: "navigator.vibrate",
543
- parameters: o
533
+ parameters: n
544
534
  };
545
535
  window.webkit.messageHandlers.aippyListener.postMessage(t), e();
546
536
  } else
@@ -548,19 +538,19 @@ function C(o) {
548
538
  });
549
539
  }
550
540
  export {
551
- b as CameraAPI,
552
- _ as FileSystemAPI,
553
- I as GeolocationAPI,
554
- k as SensorsAPI,
555
- W as camera,
556
- B as fileSystem,
557
- z as geolocation,
558
- f as hasNativeBridge,
559
- v as isMotionSupported,
560
- y as isOrientationSupported,
561
- S as requestMotionPermission,
562
- q as sensors,
563
- C as vibrate,
564
- G as watchMotion,
565
- H as watchOrientation
541
+ k as CameraAPI,
542
+ G as FileSystemAPI,
543
+ T as GeolocationAPI,
544
+ x as SensorsAPI,
545
+ H as camera,
546
+ X as fileSystem,
547
+ q as geolocation,
548
+ R as hasNativeBridge,
549
+ f as isMotionSupported,
550
+ N as isOrientationSupported,
551
+ b as requestMotionPermission,
552
+ K as sensors,
553
+ Y as vibrate,
554
+ C as watchMotion,
555
+ B as watchOrientation
566
556
  };
@@ -27,8 +27,6 @@ export declare function requestMotionPermission(): Promise<boolean>;
27
27
  export declare function watchMotion(callback: (data: MotionData) => void, autoRequestPermission?: boolean): () => void;
28
28
  /**
29
29
  * Watch device orientation changes
30
- * Automatically uses native bridge if available, otherwise falls back to Web API
31
- *
32
30
  * @param callback - Function to call with orientation data
33
31
  * @returns Cleanup function to stop watching
34
32
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aippy/runtime",
3
- "version": "0.2.4-dev.10",
3
+ "version": "0.2.4-dev.12",
4
4
  "description": "Aippy Runtime SDK - Runtime SDK for Aippy projects",
5
5
  "private": false,
6
6
  "type": "module",