@aippy/runtime 0.2.4 → 0.2.5-dev.0

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 v, A as d, C as u, E as A, R as _, b as m, c as R, p as g } from "../runtime-DjBdOttl.js";
1
+ import { a as 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";
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.4", a = {
25
+ const r = "0.2.5-dev.0", 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
- v as AippyRuntime,
37
- d as AippyRuntimeError,
36
+ d as AippyRuntime,
37
+ f as AippyRuntimeError,
38
38
  u as Cancellable,
39
39
  s as DEFAULT_CONFIG,
40
40
  A as ERROR_CODES,
@@ -1,8 +1,8 @@
1
- var U = Object.defineProperty;
2
- var L = (n, t, e) => t in n ? U(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var S = (n, t, e) => L(n, typeof t != "symbol" ? t + "" : t, e);
4
- import { c as s, b as D } from "../runtime-DjBdOttl.js";
5
- class k {
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 {
6
6
  constructor() {
7
7
  S(this, "stream", null);
8
8
  }
@@ -17,7 +17,7 @@ class k {
17
17
  */
18
18
  async getStream(t = {}) {
19
19
  if (!this.isSupported())
20
- throw s("Camera API is not supported", "NOT_SUPPORTED");
20
+ throw c("Camera API is not supported", "NOT_SUPPORTED");
21
21
  try {
22
22
  const e = {
23
23
  video: {
@@ -28,7 +28,7 @@ class k {
28
28
  };
29
29
  return this.stream = await navigator.mediaDevices.getUserMedia(e), this.stream;
30
30
  } catch (e) {
31
- throw s(
31
+ throw c(
32
32
  `Failed to access camera: ${e instanceof Error ? e.message : "Unknown error"}`,
33
33
  "PERMISSION_DENIED"
34
34
  );
@@ -39,19 +39,19 @@ class k {
39
39
  */
40
40
  async capturePhoto(t = {}) {
41
41
  if (!this.stream)
42
- throw s("No camera stream available", "NOT_SUPPORTED");
42
+ throw c("No camera stream available", "NOT_SUPPORTED");
43
43
  try {
44
44
  const e = document.createElement("video");
45
45
  e.srcObject = this.stream, e.play();
46
46
  const i = document.createElement("canvas"), o = i.getContext("2d");
47
47
  if (!o)
48
- throw s("Failed to get canvas context", "UNKNOWN_ERROR");
48
+ throw c("Failed to get canvas context", "UNKNOWN_ERROR");
49
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", c = t.quality === "high" ? 0.9 : t.quality === "medium" ? 0.7 : 0.5, a = await new Promise((u, m) => {
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) => {
51
51
  i.toBlob((l) => {
52
52
  l ? u(l) : m(new Error("Failed to create blob"));
53
- }, `image/${r}`, c);
54
- }), d = i.toDataURL(`image/${r}`, c);
53
+ }, `image/${r}`, s);
54
+ }), d = i.toDataURL(`image/${r}`, s);
55
55
  return {
56
56
  blob: a,
57
57
  dataUrl: d,
@@ -59,7 +59,7 @@ class k {
59
59
  height: i.height
60
60
  };
61
61
  } catch (e) {
62
- throw s(
62
+ throw c(
63
63
  `Failed to capture photo: ${e instanceof Error ? e.message : "Unknown error"}`,
64
64
  "UNKNOWN_ERROR"
65
65
  );
@@ -72,8 +72,8 @@ class k {
72
72
  this.stream && (this.stream.getTracks().forEach((t) => t.stop()), this.stream = null);
73
73
  }
74
74
  }
75
- const W = new k();
76
- class T {
75
+ const H = new D();
76
+ class x {
77
77
  /**
78
78
  * Check if geolocation is supported
79
79
  */
@@ -85,7 +85,7 @@ class T {
85
85
  */
86
86
  async getCurrentPosition(t = {}) {
87
87
  if (!this.isSupported())
88
- throw s("Geolocation API is not supported", "NOT_SUPPORTED");
88
+ throw c("Geolocation API is not supported", "NOT_SUPPORTED");
89
89
  return new Promise((e, i) => {
90
90
  const o = {
91
91
  enableHighAccuracy: t.enableHighAccuracy ?? !0,
@@ -94,7 +94,7 @@ class T {
94
94
  };
95
95
  navigator.geolocation.getCurrentPosition(
96
96
  (r) => {
97
- const c = {
97
+ const s = {
98
98
  latitude: r.coords.latitude,
99
99
  longitude: r.coords.longitude,
100
100
  accuracy: r.coords.accuracy,
@@ -104,13 +104,13 @@ class T {
104
104
  speed: r.coords.speed ?? void 0,
105
105
  timestamp: r.timestamp
106
106
  };
107
- e(c);
107
+ e(s);
108
108
  },
109
109
  (r) => {
110
- let c = "UNKNOWN_ERROR", a = "Unknown geolocation error";
110
+ let s = "UNKNOWN_ERROR", a = "Unknown geolocation error";
111
111
  switch (r.code) {
112
112
  case r.PERMISSION_DENIED:
113
- c = "PERMISSION_DENIED", a = "Geolocation permission denied";
113
+ s = "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 T {
119
119
  a = "Geolocation timeout";
120
120
  break;
121
121
  }
122
- i(s(a, c));
122
+ i(c(a, s));
123
123
  },
124
124
  o
125
125
  );
@@ -130,7 +130,7 @@ class T {
130
130
  */
131
131
  watchPosition(t, e = {}) {
132
132
  if (!this.isSupported())
133
- throw s("Geolocation API is not supported", "NOT_SUPPORTED");
133
+ throw c("Geolocation API is not supported", "NOT_SUPPORTED");
134
134
  const i = {
135
135
  enableHighAccuracy: e.enableHighAccuracy ?? !0,
136
136
  timeout: e.timeout ?? 1e4,
@@ -163,7 +163,7 @@ class T {
163
163
  navigator.geolocation.clearWatch(t);
164
164
  }
165
165
  }
166
- const H = new T();
166
+ const C = new x();
167
167
  function E() {
168
168
  return "DeviceMotionEvent" in window;
169
169
  }
@@ -213,42 +213,25 @@ async function b() {
213
213
  }
214
214
  return console.log("✅ [Aippy Sensors] No permission needed (granted by default)"), !0;
215
215
  }
216
- function x(n) {
216
+ function F(n) {
217
217
  console.log("🔧 [Aippy Sensors] watchMotionNative - Setting up native bridge listener");
218
- const t = D.addMotionListener((e) => {
219
- const i = I(), o = e.gravity?.x ?? 0, r = e.gravity?.y ?? 0, c = e.gravity?.z ?? 0, a = e.userAcceleration?.x ?? 0, d = e.userAcceleration?.y ?? 0, u = e.userAcceleration?.z ?? 0, [m, l] = P(o, r, i), [y, v] = P(a, d, i), g = e.attitude && typeof e.attitude.yaw == "number" && typeof e.attitude.pitch == "number" && typeof e.attitude.roll == "number";
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
220
  let w = 0;
221
221
  g && (w = e.attitude.yaw * (180 / Math.PI), w < 0 && (w += 360));
222
222
  const f = {
223
- gravity: {
224
- x: m,
225
- y: l,
226
- z: c
227
- // Z-axis not affected by screen rotation
228
- },
229
- acceleration: {
230
- x: y,
231
- y: v,
232
- z: u
233
- // Z-axis not affected by screen rotation
234
- },
223
+ gravity: { x: m, y: l, z: s },
224
+ acceleration: { x: y, y: v, z: u },
235
225
  accelerationIncludingGravity: {
236
226
  x: m + y,
237
227
  y: l + v,
238
- z: c + u
228
+ z: s + u
239
229
  },
240
- // iOS native uses rotationRate.x/y/z (rad/s)
241
- // Convert to rotation.alpha/beta/gamma (deg/s)
242
230
  rotation: {
243
- // If attitude is available, use yaw for alpha (compass heading)
244
- // Otherwise fallback to rotationRate.z (angular velocity)
245
231
  alpha: g ? w : (e.rotationRate?.z ?? 0) * (180 / Math.PI),
246
232
  beta: (e.rotationRate?.x ?? 0) * (180 / Math.PI),
247
- // x -> beta (around X-axis)
248
233
  gamma: (e.rotationRate?.y ?? 0) * (180 / Math.PI)
249
- // y -> gamma (around Y-axis)
250
234
  },
251
- // Add attitude data for more precise orientation info
252
235
  attitude: g ? {
253
236
  yaw: w,
254
237
  pitch: e.attitude.pitch * (180 / Math.PI),
@@ -266,9 +249,9 @@ function x(n) {
266
249
  });
267
250
  return console.log("✅ [Aippy Sensors] watchMotionNative - Listener setup complete"), t;
268
251
  }
269
- function _(n, t = !0) {
252
+ function M(n, t = !0) {
270
253
  if (!E())
271
- throw s("Device motion API is not supported", "NOT_SUPPORTED");
254
+ throw c("Device motion API is not supported", "NOT_SUPPORTED");
272
255
  let e = !1, i = null;
273
256
  const o = (a) => {
274
257
  if (!e) return;
@@ -281,19 +264,9 @@ function _(n, t = !0) {
281
264
  const p = a.accelerationIncludingGravity, h = 9.8;
282
265
  u = (p?.x ?? 0) / h, m = (p?.y ?? 0) / h, l = (p?.z ?? 0) / h;
283
266
  }
284
- const y = a.acceleration?.x ?? 0, v = a.acceleration?.y ?? 0, g = a.acceleration?.z ?? 0, [w, f] = P(u, m, d), [O, A] = P(y, v, d), M = {
285
- gravity: {
286
- x: w,
287
- y: f,
288
- z: l
289
- // Z-axis not affected by screen rotation
290
- },
291
- acceleration: {
292
- x: O,
293
- y: A,
294
- z: g
295
- // Z-axis not affected by screen rotation
296
- },
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 },
297
270
  accelerationIncludingGravity: {
298
271
  x: w + O,
299
272
  y: f + A,
@@ -306,7 +279,7 @@ function _(n, t = !0) {
306
279
  },
307
280
  timestamp: Date.now()
308
281
  };
309
- n(M);
282
+ n(U);
310
283
  }, r = async () => {
311
284
  t && !await b() || (e = !0, window.addEventListener("devicemotion", o));
312
285
  };
@@ -324,45 +297,45 @@ function _(n, t = !0) {
324
297
  e = !1, window.removeEventListener("devicemotion", o), i && (i(), i = null);
325
298
  };
326
299
  }
327
- function C(n, t = !0) {
328
- const e = R();
329
- return console.log(`🎯 [Aippy Sensors] watchMotion - Using ${e ? "NATIVE BRIDGE" : "WEB API"} mode`), e ? (console.log("📱 [Aippy Sensors] Starting native bridge motion listener"), x(n)) : (console.log("🌐 [Aippy Sensors] Starting Web API motion listener (may require permission)"), _(n, t));
300
+ function _(n, t, e = 500) {
301
+ let i = !1, o = null;
302
+ 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);
307
+ return () => {
308
+ clearTimeout(s), r(), o?.();
309
+ };
310
+ }
311
+ function K(n, t = !0) {
312
+ return R() ? _(n, t) : M(n, t);
330
313
  }
331
- function B(n) {
314
+ function X(n) {
332
315
  if (!N())
333
- throw s("Device orientation API is not supported", "NOT_SUPPORTED");
316
+ throw c("Device orientation API is not supported", "NOT_SUPPORTED");
334
317
  const t = (e) => {
335
- const i = {
318
+ n({
336
319
  alpha: e.alpha ?? 0,
337
320
  beta: e.beta ?? 0,
338
321
  gamma: e.gamma ?? 0,
339
322
  timestamp: Date.now()
340
- };
341
- n(i);
323
+ });
342
324
  };
343
325
  return window.addEventListener("deviceorientation", t), () => {
344
326
  window.removeEventListener("deviceorientation", t);
345
327
  };
346
328
  }
347
- class F {
348
- /**
349
- * Check if device orientation is supported
350
- */
329
+ class z {
351
330
  isOrientationSupported() {
352
331
  return N();
353
332
  }
354
- /**
355
- * Check if device motion is supported
356
- */
357
333
  isMotionSupported() {
358
334
  return E();
359
335
  }
360
- /**
361
- * Get device orientation data
362
- */
363
336
  async getOrientation() {
364
337
  if (!this.isOrientationSupported())
365
- throw s("Device orientation API is not supported", "NOT_SUPPORTED");
338
+ throw c("Device orientation API is not supported", "NOT_SUPPORTED");
366
339
  return new Promise((t, e) => {
367
340
  const i = (o) => {
368
341
  window.removeEventListener("deviceorientation", i), t({
@@ -373,17 +346,14 @@ class F {
373
346
  });
374
347
  };
375
348
  window.addEventListener("deviceorientation", i), setTimeout(() => {
376
- window.removeEventListener("deviceorientation", i), e(s("Device orientation timeout", "UNKNOWN_ERROR"));
349
+ window.removeEventListener("deviceorientation", i), e(c("Device orientation timeout", "UNKNOWN_ERROR"));
377
350
  }, 5e3);
378
351
  });
379
352
  }
380
- /**
381
- * Watch device orientation changes
382
- * @deprecated Use watchOrientation() function instead
383
- */
353
+ /** @deprecated Use watchOrientation() instead */
384
354
  watchOrientation(t) {
385
355
  if (!this.isOrientationSupported())
386
- throw s("Device orientation API is not supported", "NOT_SUPPORTED");
356
+ throw c("Device orientation API is not supported", "NOT_SUPPORTED");
387
357
  const e = (i) => {
388
358
  t({
389
359
  x: i.alpha ?? 0,
@@ -396,12 +366,9 @@ class F {
396
366
  window.removeEventListener("deviceorientation", e);
397
367
  };
398
368
  }
399
- /**
400
- * Get device motion data
401
- */
402
369
  async getMotion() {
403
370
  if (!this.isMotionSupported())
404
- throw s("Device motion API is not supported", "NOT_SUPPORTED");
371
+ throw c("Device motion API is not supported", "NOT_SUPPORTED");
405
372
  return new Promise((t, e) => {
406
373
  const i = (o) => {
407
374
  window.removeEventListener("devicemotion", i), t({
@@ -412,17 +379,14 @@ class F {
412
379
  });
413
380
  };
414
381
  window.addEventListener("devicemotion", i), setTimeout(() => {
415
- window.removeEventListener("devicemotion", i), e(s("Device motion timeout", "UNKNOWN_ERROR"));
382
+ window.removeEventListener("devicemotion", i), e(c("Device motion timeout", "UNKNOWN_ERROR"));
416
383
  }, 5e3);
417
384
  });
418
385
  }
419
- /**
420
- * Watch device motion changes
421
- * @deprecated Use watchMotion() function instead
422
- */
386
+ /** @deprecated Use watchMotion() instead */
423
387
  watchMotion(t) {
424
388
  if (!this.isMotionSupported())
425
- throw s("Device motion API is not supported", "NOT_SUPPORTED");
389
+ throw c("Device motion API is not supported", "NOT_SUPPORTED");
426
390
  const e = (i) => {
427
391
  t({
428
392
  x: i.acceleration?.x ?? 0,
@@ -435,15 +399,12 @@ class F {
435
399
  window.removeEventListener("devicemotion", e);
436
400
  };
437
401
  }
438
- /**
439
- * Request permission for motion sensors (iOS 13+)
440
- */
441
402
  async requestPermission() {
442
403
  return b();
443
404
  }
444
405
  }
445
- const K = new F();
446
- class z {
406
+ const Y = new z();
407
+ class G {
447
408
  /**
448
409
  * Check if file system access is supported
449
410
  */
@@ -461,7 +422,7 @@ class z {
461
422
  */
462
423
  async openFilePicker(t = {}) {
463
424
  if (!this.isSupported())
464
- throw s("File System Access API is not supported", "NOT_SUPPORTED");
425
+ throw c("File System Access API is not supported", "NOT_SUPPORTED");
465
426
  try {
466
427
  const e = {
467
428
  types: t.accept ? [{
@@ -479,7 +440,7 @@ class z {
479
440
  paths: o.map((r) => r.name)
480
441
  };
481
442
  } catch (e) {
482
- throw e instanceof Error && e.name === "AbortError" ? s("File picker was cancelled", "PERMISSION_DENIED") : s(
443
+ throw e instanceof Error && e.name === "AbortError" ? c("File picker was cancelled", "PERMISSION_DENIED") : c(
483
444
  `Failed to open file picker: ${e instanceof Error ? e.message : "Unknown error"}`,
484
445
  "PERMISSION_DENIED"
485
446
  );
@@ -490,17 +451,17 @@ class z {
490
451
  */
491
452
  async openFilePickerLegacy(t = {}) {
492
453
  if (!this.isLegacySupported())
493
- throw s("File input is not supported", "NOT_SUPPORTED");
454
+ throw c("File input is not supported", "NOT_SUPPORTED");
494
455
  return new Promise((e, i) => {
495
456
  const o = document.createElement("input");
496
457
  o.type = "file", o.multiple = t.multiple ?? !1, o.accept = t.accept?.join(",") ?? "", o.onchange = (r) => {
497
- const c = r.target, a = Array.from(c.files || []);
458
+ const s = r.target, a = Array.from(s.files || []);
498
459
  e({
499
460
  files: a,
500
461
  paths: a.map((d) => d.name)
501
462
  });
502
463
  }, o.oncancel = () => {
503
- i(s("File picker was cancelled", "PERMISSION_DENIED"));
464
+ i(c("File picker was cancelled", "PERMISSION_DENIED"));
504
465
  }, o.click();
505
466
  });
506
467
  }
@@ -518,7 +479,7 @@ class z {
518
479
  const i = URL.createObjectURL(t), o = document.createElement("a");
519
480
  o.href = i, o.download = e, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(i);
520
481
  } catch (i) {
521
- throw s(
482
+ throw c(
522
483
  `Failed to save file: ${i instanceof Error ? i.message : "Unknown error"}`,
523
484
  "UNKNOWN_ERROR"
524
485
  );
@@ -530,7 +491,7 @@ class z {
530
491
  async readAsText(t) {
531
492
  return new Promise((e, i) => {
532
493
  const o = new FileReader();
533
- o.onload = () => e(o.result), o.onerror = () => i(s("Failed to read file", "UNKNOWN_ERROR")), o.readAsText(t);
494
+ o.onload = () => e(o.result), o.onerror = () => i(c("Failed to read file", "UNKNOWN_ERROR")), o.readAsText(t);
534
495
  });
535
496
  }
536
497
  /**
@@ -539,12 +500,12 @@ class z {
539
500
  async readAsDataURL(t) {
540
501
  return new Promise((e, i) => {
541
502
  const o = new FileReader();
542
- o.onload = () => e(o.result), o.onerror = () => i(s("Failed to read file", "UNKNOWN_ERROR")), o.readAsDataURL(t);
503
+ o.onload = () => e(o.result), o.onerror = () => i(c("Failed to read file", "UNKNOWN_ERROR")), o.readAsDataURL(t);
543
504
  });
544
505
  }
545
506
  }
546
- const X = new z();
547
- function Y(n) {
507
+ const j = new G();
508
+ function $(n) {
548
509
  return new Promise((t) => {
549
510
  if ("vibrate" in navigator)
550
511
  navigator.vibrate(n), t();
@@ -559,19 +520,19 @@ function Y(n) {
559
520
  });
560
521
  }
561
522
  export {
562
- k as CameraAPI,
563
- z as FileSystemAPI,
564
- T as GeolocationAPI,
565
- F as SensorsAPI,
566
- W as camera,
567
- X as fileSystem,
568
- H as geolocation,
523
+ D as CameraAPI,
524
+ G as FileSystemAPI,
525
+ x as GeolocationAPI,
526
+ z as SensorsAPI,
527
+ H as camera,
528
+ j as fileSystem,
529
+ C as geolocation,
569
530
  R as hasNativeBridge,
570
531
  E as isMotionSupported,
571
532
  N as isOrientationSupported,
572
533
  b as requestMotionPermission,
573
- K as sensors,
574
- Y as vibrate,
575
- C as watchMotion,
576
- B as watchOrientation
534
+ Y as sensors,
535
+ $ as vibrate,
536
+ K as watchMotion,
537
+ X as watchOrientation
577
538
  };
@@ -1,74 +1,24 @@
1
1
  import { SensorData, MotionData, OrientationData } from './types';
2
- /**
3
- * Check if device motion is supported
4
- */
5
2
  export declare function isMotionSupported(): boolean;
6
- /**
7
- * Check if device orientation is supported
8
- */
9
3
  export declare function isOrientationSupported(): boolean;
10
- /**
11
- * Check if native bridge is available
12
- */
13
4
  export declare function hasNativeBridge(): boolean;
14
- /**
15
- * Request permission for motion sensors (iOS 13+)
16
- * @returns Promise<boolean> - true if permission granted
17
- */
5
+ /** Request motion sensor permission (iOS 13+) */
18
6
  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
- */
7
+ /** Watch device motion (auto selects native bridge or Web API) */
27
8
  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
- */
9
+ /** Watch device orientation changes */
33
10
  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
37
- */
11
+ /** @deprecated Use watchMotion() and watchOrientation() instead */
38
12
  export declare class SensorsAPI {
39
- /**
40
- * Check if device orientation is supported
41
- */
42
13
  isOrientationSupported(): boolean;
43
- /**
44
- * Check if device motion is supported
45
- */
46
14
  isMotionSupported(): boolean;
47
- /**
48
- * Get device orientation data
49
- */
50
15
  getOrientation(): Promise<SensorData>;
51
- /**
52
- * Watch device orientation changes
53
- * @deprecated Use watchOrientation() function instead
54
- */
16
+ /** @deprecated Use watchOrientation() instead */
55
17
  watchOrientation(callback: (data: SensorData) => void): () => void;
56
- /**
57
- * Get device motion data
58
- */
59
18
  getMotion(): Promise<SensorData>;
60
- /**
61
- * Watch device motion changes
62
- * @deprecated Use watchMotion() function instead
63
- */
19
+ /** @deprecated Use watchMotion() instead */
64
20
  watchMotion(callback: (data: SensorData) => void): () => void;
65
- /**
66
- * Request permission for motion sensors (iOS 13+)
67
- */
68
21
  requestPermission(): Promise<boolean>;
69
22
  }
70
- /**
71
- * Sensors API instance (for backward compatibility)
72
- * @deprecated Use watchMotion() and watchOrientation() functions instead
73
- */
23
+ /** @deprecated Use watchMotion() and watchOrientation() instead */
74
24
  export declare const sensors: SensorsAPI;
@@ -1,42 +1,46 @@
1
1
  function r(e, o) {
2
2
  try {
3
3
  if (window.parent && window.parent !== window) {
4
- const n = {
4
+ const a = {
5
5
  __aippyGame: !0,
6
6
  payload: e
7
7
  };
8
- window.parent.postMessage(n, "*");
8
+ window.parent.postMessage(a, "*");
9
9
  }
10
- const a = window.webkit?.messageHandlers?.aippyListener;
11
- a && a.postMessage({
10
+ const n = window.webkit?.messageHandlers?.aippyListener;
11
+ n && n.postMessage({
12
12
  command: o,
13
13
  parameters: JSON.stringify(e)
14
14
  });
15
- } catch (a) {
16
- console.warn("[Aippy Leaderboard] Failed to send game event:", a);
15
+ } catch (n) {
16
+ console.warn("[Aippy Leaderboard] Failed to send game event:", n);
17
17
  }
18
18
  }
19
19
  function t(e) {
20
- r({
20
+ const o = {
21
21
  type: "score",
22
- score: e
23
- }, "leaderboard.reportScore"), console.log(`[Aippy Leaderboard] Score reported: ${e}`);
22
+ score: e,
23
+ url: window.location.href
24
+ };
25
+ r(o, "leaderboard.reportScore"), console.log(`[Aippy Leaderboard] Score reported: ${e}, URL: ${window.location.href}`);
24
26
  }
25
- function p(e) {
26
- r({
27
+ function d(e) {
28
+ const o = {
27
29
  type: "score",
28
- score: e
29
- }, "leaderboard.updateScore"), console.log(`[Aippy Leaderboard] Score updated: ${e}`);
30
+ score: e,
31
+ url: window.location.href
32
+ };
33
+ r(o, "leaderboard.updateScore"), console.log(`[Aippy Leaderboard] Score updated: ${e}, URL: ${window.location.href}`);
30
34
  }
31
- function d(e, o) {
32
- const a = {
35
+ function i(e, o) {
36
+ const n = {
33
37
  type: e,
34
38
  ...o
35
39
  };
36
- r(a, "leaderboard.event"), console.log(`[Aippy Leaderboard] Event sent: ${e}`, o);
40
+ r(n, "leaderboard.event"), console.log(`[Aippy Leaderboard] Event sent: ${e}`, o);
37
41
  }
38
42
  export {
39
43
  t as reportScore,
40
- d as sendEvent,
41
- p as updateScore
44
+ i as sendEvent,
45
+ d as updateScore
42
46
  };
@@ -9,6 +9,8 @@ export interface ScorePayload {
9
9
  type: 'score';
10
10
  /** The score value */
11
11
  score: number;
12
+ /** The URL of the current H5 application */
13
+ url?: string;
12
14
  /** Score unit (e.g., 'points', 'coins') */
13
15
  unit?: string;
14
16
  /** Whether bigger score is better for leaderboard ranking */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aippy/runtime",
3
- "version": "0.2.4",
3
+ "version": "0.2.5-dev.0",
4
4
  "description": "Aippy Runtime SDK - Runtime SDK for Aippy projects",
5
5
  "private": false,
6
6
  "type": "module",