@aippy/runtime 0.2.4-dev.8 → 0.2.4-dev.9

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