@aippy/runtime 0.2.5-dev.0 → 0.2.6

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