@aippy/runtime 0.2.4-dev.11 → 0.2.4-dev.2
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.
- package/dist/core/index.js +1 -1
- package/dist/device/index.js +97 -101
- package/package.json +1 -1
package/dist/core/index.js
CHANGED
package/dist/device/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { c as s, b as
|
|
5
|
-
class
|
|
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
|
-
|
|
7
|
+
A(this, "stream", null);
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Check if camera is supported
|
|
@@ -47,14 +47,14 @@ class N {
|
|
|
47
47
|
if (!o)
|
|
48
48
|
throw s("Failed to get canvas context", "UNKNOWN_ERROR");
|
|
49
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",
|
|
51
|
-
i.toBlob((
|
|
52
|
-
|
|
53
|
-
}, `image/${r}`,
|
|
54
|
-
}),
|
|
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
|
+
}, `image/${r}`, c);
|
|
54
|
+
}), d = i.toDataURL(`image/${r}`, c);
|
|
55
55
|
return {
|
|
56
56
|
blob: a,
|
|
57
|
-
dataUrl:
|
|
57
|
+
dataUrl: d,
|
|
58
58
|
width: i.width,
|
|
59
59
|
height: i.height
|
|
60
60
|
};
|
|
@@ -72,8 +72,8 @@ class N {
|
|
|
72
72
|
this.stream && (this.stream.getTracks().forEach((e) => e.stop()), this.stream = null);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
const
|
|
76
|
-
class
|
|
75
|
+
const H = new k();
|
|
76
|
+
class T {
|
|
77
77
|
/**
|
|
78
78
|
* Check if geolocation is supported
|
|
79
79
|
*/
|
|
@@ -94,7 +94,7 @@ class R {
|
|
|
94
94
|
};
|
|
95
95
|
navigator.geolocation.getCurrentPosition(
|
|
96
96
|
(r) => {
|
|
97
|
-
const
|
|
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 R {
|
|
|
104
104
|
speed: r.coords.speed ?? void 0,
|
|
105
105
|
timestamp: r.timestamp
|
|
106
106
|
};
|
|
107
|
-
t(
|
|
107
|
+
t(c);
|
|
108
108
|
},
|
|
109
109
|
(r) => {
|
|
110
|
-
let
|
|
110
|
+
let c = "UNKNOWN_ERROR", a = "Unknown geolocation error";
|
|
111
111
|
switch (r.code) {
|
|
112
112
|
case r.PERMISSION_DENIED:
|
|
113
|
-
|
|
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 R {
|
|
|
119
119
|
a = "Geolocation timeout";
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
|
-
i(s(a,
|
|
122
|
+
i(s(a, c));
|
|
123
123
|
},
|
|
124
124
|
o
|
|
125
125
|
);
|
|
@@ -163,14 +163,14 @@ class R {
|
|
|
163
163
|
navigator.geolocation.clearWatch(e);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
const
|
|
167
|
-
function
|
|
166
|
+
const q = new T();
|
|
167
|
+
function f() {
|
|
168
168
|
return "DeviceMotionEvent" in window;
|
|
169
169
|
}
|
|
170
|
-
function
|
|
170
|
+
function N() {
|
|
171
171
|
return "DeviceOrientationEvent" in window;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function R() {
|
|
174
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,
|
|
@@ -197,10 +197,10 @@ function y(n, e, t) {
|
|
|
197
197
|
return [n, e];
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
async function
|
|
201
|
-
if (console.log("🔐 [Aippy Sensors] requestMotionPermission called"),
|
|
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 (!
|
|
203
|
+
if (!f())
|
|
204
204
|
return console.warn("❌ [Aippy Sensors] Device motion not supported"), !1;
|
|
205
205
|
const n = typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function";
|
|
206
206
|
if (console.log("🔍 [Aippy Sensors] Permission API available:", n), n)
|
|
@@ -213,26 +213,26 @@ async function E() {
|
|
|
213
213
|
}
|
|
214
214
|
return console.log("✅ [Aippy Sensors] No permission needed (granted by default)"), !0;
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function _(n) {
|
|
217
217
|
console.log("🔧 [Aippy Sensors] watchMotionNative - Setting up native bridge listener");
|
|
218
|
-
const e =
|
|
219
|
-
const i = I(), o = t.gravity?.x ?? 0, r = t.gravity?.y ?? 0,
|
|
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:
|
|
222
|
-
y:
|
|
223
|
-
z:
|
|
221
|
+
x: m,
|
|
222
|
+
y: l,
|
|
223
|
+
z: c
|
|
224
224
|
// Z轴不受屏幕旋转影响
|
|
225
225
|
},
|
|
226
226
|
acceleration: {
|
|
227
|
-
x:
|
|
228
|
-
y:
|
|
229
|
-
z:
|
|
227
|
+
x: g,
|
|
228
|
+
y: h,
|
|
229
|
+
z: u
|
|
230
230
|
// Z轴不受屏幕旋转影响
|
|
231
231
|
},
|
|
232
232
|
accelerationIncludingGravity: {
|
|
233
|
-
x:
|
|
234
|
-
y:
|
|
235
|
-
z:
|
|
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,31 +241,42 @@ function b(n) {
|
|
|
241
241
|
},
|
|
242
242
|
timestamp: Date.now()
|
|
243
243
|
};
|
|
244
|
-
n(
|
|
244
|
+
n(v);
|
|
245
245
|
});
|
|
246
246
|
return console.log("✅ [Aippy Sensors] watchMotionNative - Listener setup complete"), e;
|
|
247
247
|
}
|
|
248
|
-
function
|
|
249
|
-
if (!
|
|
248
|
+
function F(n, e = !0) {
|
|
249
|
+
if (!f())
|
|
250
250
|
throw s("Device motion API is not supported", "NOT_SUPPORTED");
|
|
251
251
|
let t = !1, i = null;
|
|
252
252
|
const o = (a) => {
|
|
253
253
|
if (!t) return;
|
|
254
|
-
const
|
|
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 = {
|
|
255
264
|
gravity: {
|
|
256
|
-
x:
|
|
257
|
-
y:
|
|
258
|
-
z:
|
|
265
|
+
x: E,
|
|
266
|
+
y: P,
|
|
267
|
+
z: l
|
|
268
|
+
// Z轴不受屏幕旋转影响
|
|
259
269
|
},
|
|
260
270
|
acceleration: {
|
|
261
|
-
x:
|
|
262
|
-
y:
|
|
263
|
-
z:
|
|
271
|
+
x: O,
|
|
272
|
+
y: S,
|
|
273
|
+
z: v
|
|
274
|
+
// Z轴不受屏幕旋转影响
|
|
264
275
|
},
|
|
265
276
|
accelerationIncludingGravity: {
|
|
266
|
-
x:
|
|
267
|
-
y:
|
|
268
|
-
z:
|
|
277
|
+
x: E + O,
|
|
278
|
+
y: P + S,
|
|
279
|
+
z: l + v
|
|
269
280
|
},
|
|
270
281
|
rotation: {
|
|
271
282
|
alpha: a.rotationRate?.alpha ?? 0,
|
|
@@ -274,32 +285,17 @@ function D(n, e = !0) {
|
|
|
274
285
|
},
|
|
275
286
|
timestamp: Date.now()
|
|
276
287
|
};
|
|
277
|
-
|
|
278
|
-
const l = a.accelerationIncludingGravity, u = a.acceleration;
|
|
279
|
-
c.gravity = {
|
|
280
|
-
x: (l?.x ?? 0) - (u?.x ?? 0),
|
|
281
|
-
y: (l?.y ?? 0) - (u?.y ?? 0),
|
|
282
|
-
z: (l?.z ?? 0) - (u?.z ?? 0)
|
|
283
|
-
};
|
|
284
|
-
} else {
|
|
285
|
-
const l = a.accelerationIncludingGravity, u = 9.8;
|
|
286
|
-
c.gravity = {
|
|
287
|
-
x: (l?.x ?? 0) / u,
|
|
288
|
-
y: (l?.y ?? 0) / u,
|
|
289
|
-
z: (l?.z ?? 0) / u
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
n(c);
|
|
288
|
+
n(D);
|
|
293
289
|
}, r = async () => {
|
|
294
|
-
e && !await
|
|
290
|
+
e && !await b() || (t = !0, window.addEventListener("devicemotion", o));
|
|
295
291
|
};
|
|
296
292
|
return (async () => {
|
|
297
293
|
if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && e) {
|
|
298
|
-
const
|
|
294
|
+
const d = async () => {
|
|
299
295
|
i = null, await r();
|
|
300
296
|
};
|
|
301
|
-
window.addEventListener("click",
|
|
302
|
-
window.removeEventListener("click",
|
|
297
|
+
window.addEventListener("click", d, { once: !0 }), window.addEventListener("touchstart", d, { once: !0 }), i = () => {
|
|
298
|
+
window.removeEventListener("click", d), window.removeEventListener("touchstart", d);
|
|
303
299
|
};
|
|
304
300
|
} else
|
|
305
301
|
await r();
|
|
@@ -307,12 +303,12 @@ function D(n, e = !0) {
|
|
|
307
303
|
t = !1, window.removeEventListener("devicemotion", o), i && (i(), i = null);
|
|
308
304
|
};
|
|
309
305
|
}
|
|
310
|
-
function
|
|
311
|
-
const t =
|
|
312
|
-
return console.log(`🎯 [Aippy Sensors] watchMotion - Using ${t ? "NATIVE BRIDGE" : "WEB API"} mode`), t ? (console.log("📱 [Aippy Sensors] Starting native bridge motion listener"),
|
|
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));
|
|
313
309
|
}
|
|
314
|
-
function
|
|
315
|
-
if (!
|
|
310
|
+
function B(n) {
|
|
311
|
+
if (!N())
|
|
316
312
|
throw s("Device orientation API is not supported", "NOT_SUPPORTED");
|
|
317
313
|
const e = (t) => {
|
|
318
314
|
const i = {
|
|
@@ -327,18 +323,18 @@ function F(n) {
|
|
|
327
323
|
window.removeEventListener("deviceorientation", e);
|
|
328
324
|
};
|
|
329
325
|
}
|
|
330
|
-
class
|
|
326
|
+
class x {
|
|
331
327
|
/**
|
|
332
328
|
* Check if device orientation is supported
|
|
333
329
|
*/
|
|
334
330
|
isOrientationSupported() {
|
|
335
|
-
return
|
|
331
|
+
return N();
|
|
336
332
|
}
|
|
337
333
|
/**
|
|
338
334
|
* Check if device motion is supported
|
|
339
335
|
*/
|
|
340
336
|
isMotionSupported() {
|
|
341
|
-
return
|
|
337
|
+
return f();
|
|
342
338
|
}
|
|
343
339
|
/**
|
|
344
340
|
* Get device orientation data
|
|
@@ -422,11 +418,11 @@ class U {
|
|
|
422
418
|
* Request permission for motion sensors (iOS 13+)
|
|
423
419
|
*/
|
|
424
420
|
async requestPermission() {
|
|
425
|
-
return
|
|
421
|
+
return b();
|
|
426
422
|
}
|
|
427
423
|
}
|
|
428
|
-
const
|
|
429
|
-
class
|
|
424
|
+
const K = new x();
|
|
425
|
+
class G {
|
|
430
426
|
/**
|
|
431
427
|
* Check if file system access is supported
|
|
432
428
|
*/
|
|
@@ -477,10 +473,10 @@ class M {
|
|
|
477
473
|
return new Promise((t, i) => {
|
|
478
474
|
const o = document.createElement("input");
|
|
479
475
|
o.type = "file", o.multiple = e.multiple ?? !1, o.accept = e.accept?.join(",") ?? "", o.onchange = (r) => {
|
|
480
|
-
const
|
|
476
|
+
const c = r.target, a = Array.from(c.files || []);
|
|
481
477
|
t({
|
|
482
478
|
files: a,
|
|
483
|
-
paths: a.map((
|
|
479
|
+
paths: a.map((d) => d.name)
|
|
484
480
|
});
|
|
485
481
|
}, o.oncancel = () => {
|
|
486
482
|
i(s("File picker was cancelled", "PERMISSION_DENIED"));
|
|
@@ -526,8 +522,8 @@ class M {
|
|
|
526
522
|
});
|
|
527
523
|
}
|
|
528
524
|
}
|
|
529
|
-
const
|
|
530
|
-
function
|
|
525
|
+
const X = new G();
|
|
526
|
+
function Y(n) {
|
|
531
527
|
return new Promise((e) => {
|
|
532
528
|
if ("vibrate" in navigator)
|
|
533
529
|
navigator.vibrate(n), e();
|
|
@@ -542,19 +538,19 @@ function W(n) {
|
|
|
542
538
|
});
|
|
543
539
|
}
|
|
544
540
|
export {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
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
|
|
560
556
|
};
|