@aippy/runtime 0.2.5-dev.0 → 0.2.6-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.
- package/README.md +34 -0
- package/dist/ai/errors.d.ts +21 -0
- package/dist/ai/index.d.ts +45 -0
- package/dist/ai/index.js +20 -0
- package/dist/ai/openai/index.d.ts +11 -0
- package/dist/ai/openai/provider.d.ts +51 -0
- package/dist/ai/shared/config.d.ts +50 -0
- package/dist/ai/shared/index.d.ts +5 -0
- package/dist/ai/ui/config.d.ts +81 -0
- package/dist/ai/ui/endpoints.d.ts +16 -0
- package/dist/ai/ui/index.d.ts +15 -0
- package/dist/ai/ui/types.d.ts +46 -0
- package/dist/ai.d.ts +2 -0
- package/dist/bridge-DdAH4txB.js +222 -0
- package/dist/core/index.js +15 -14
- package/dist/core/native-bridge.d.ts +9 -0
- package/dist/device/index.js +138 -107
- package/dist/device/sensors.d.ts +56 -8
- package/dist/errors-3xwlPAB-.js +148 -0
- package/dist/errors-CDEBaBxB.js +26 -0
- package/dist/index/index.js +93 -47
- package/dist/index.d.ts +2 -0
- package/dist/leaderboard/index.js +18 -22
- package/dist/leaderboard/types.d.ts +0 -2
- package/dist/native-bridge-JAmH-zTN.js +6 -0
- package/dist/{runtime-DjBdOttl.js → runtime-CmoG3v2m.js} +55 -76
- package/dist/user/api.d.ts +9 -0
- package/dist/user/bridge.d.ts +80 -0
- package/dist/user/config.d.ts +21 -0
- package/dist/user/hooks.d.ts +38 -0
- package/dist/user/index.d.ts +11 -0
- package/dist/user/index.js +28 -0
- package/dist/user/types.d.ts +111 -0
- package/dist/user/userSessionInfo.d.ts +6 -0
- package/dist/user.d.ts +2 -0
- package/dist/userSessionInfo-CBk9ywXi.js +186 -0
- package/package.json +25 -12
package/dist/core/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as v, E as d, c as u } from "../errors-CDEBaBxB.js";
|
|
2
|
+
import { A as m, C as _, R, a as g, p as I } from "../runtime-CmoG3v2m.js";
|
|
2
3
|
const s = {
|
|
3
4
|
mode: "development",
|
|
4
5
|
debug: !1,
|
|
@@ -9,7 +10,7 @@ function o() {
|
|
|
9
10
|
const e = {};
|
|
10
11
|
return typeof process < "u" && process.env && (process.env.NODE_ENV && (e.mode = process.env.NODE_ENV), process.env.AIPPY_DEBUG && (e.debug = process.env.AIPPY_DEBUG === "true"), process.env.AIPPY_API_BASE_URL && (e.apiBaseUrl = process.env.AIPPY_API_BASE_URL)), e;
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
+
function p(e) {
|
|
13
14
|
const n = o();
|
|
14
15
|
return {
|
|
15
16
|
...s,
|
|
@@ -22,10 +23,10 @@ function c(e) {
|
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
|
-
const r = "0.2.
|
|
26
|
+
const r = "0.2.6-dev.0", a = {
|
|
26
27
|
version: r
|
|
27
28
|
}, i = a.version, t = "@aippy/runtime";
|
|
28
|
-
function
|
|
29
|
+
function c() {
|
|
29
30
|
return {
|
|
30
31
|
name: t,
|
|
31
32
|
version: i,
|
|
@@ -33,18 +34,18 @@ function p() {
|
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
m as AippyRuntime,
|
|
38
|
+
v as AippyRuntimeError,
|
|
39
|
+
_ as Cancellable,
|
|
39
40
|
s as DEFAULT_CONFIG,
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
d as ERROR_CODES,
|
|
42
|
+
R as ReceiveChannel,
|
|
42
43
|
t as SDK_NAME,
|
|
43
44
|
i as VERSION,
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
g as aippyRuntime,
|
|
46
|
+
u as createError,
|
|
46
47
|
o as getConfigFromEnv,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
c as getVersionInfo,
|
|
49
|
+
p as mergeConfig,
|
|
50
|
+
I as processMotionData
|
|
50
51
|
};
|
package/dist/device/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { c
|
|
5
|
-
|
|
1
|
+
var U = Object.defineProperty;
|
|
2
|
+
var D = (r, t, e) => t in r ? U(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var A = (r, t, e) => D(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { c } from "../errors-CDEBaBxB.js";
|
|
5
|
+
import { a as L } from "../runtime-CmoG3v2m.js";
|
|
6
|
+
import { h as N } from "../native-bridge-JAmH-zTN.js";
|
|
7
|
+
class T {
|
|
6
8
|
constructor() {
|
|
7
|
-
|
|
9
|
+
A(this, "stream", null);
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Check if camera is supported
|
|
@@ -47,11 +49,11 @@ class D {
|
|
|
47
49
|
if (!o)
|
|
48
50
|
throw c("Failed to get canvas context", "UNKNOWN_ERROR");
|
|
49
51
|
i.width = t.width || e.videoWidth, i.height = t.height || e.videoHeight, o.drawImage(e, 0, 0, i.width, i.height);
|
|
50
|
-
const
|
|
52
|
+
const n = t.format || "jpeg", s = t.quality === "high" ? 0.9 : t.quality === "medium" ? 0.7 : 0.5, a = await new Promise((u, m) => {
|
|
51
53
|
i.toBlob((l) => {
|
|
52
54
|
l ? u(l) : m(new Error("Failed to create blob"));
|
|
53
|
-
}, `image/${
|
|
54
|
-
}), d = i.toDataURL(`image/${
|
|
55
|
+
}, `image/${n}`, s);
|
|
56
|
+
}), d = i.toDataURL(`image/${n}`, s);
|
|
55
57
|
return {
|
|
56
58
|
blob: a,
|
|
57
59
|
dataUrl: d,
|
|
@@ -72,8 +74,8 @@ class D {
|
|
|
72
74
|
this.stream && (this.stream.getTracks().forEach((t) => t.stop()), this.stream = null);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
const H = new
|
|
76
|
-
class
|
|
77
|
+
const H = new T();
|
|
78
|
+
class k {
|
|
77
79
|
/**
|
|
78
80
|
* Check if geolocation is supported
|
|
79
81
|
*/
|
|
@@ -93,29 +95,29 @@ class x {
|
|
|
93
95
|
maximumAge: t.maximumAge ?? 6e4
|
|
94
96
|
};
|
|
95
97
|
navigator.geolocation.getCurrentPosition(
|
|
96
|
-
(
|
|
98
|
+
(n) => {
|
|
97
99
|
const s = {
|
|
98
|
-
latitude:
|
|
99
|
-
longitude:
|
|
100
|
-
accuracy:
|
|
101
|
-
altitude:
|
|
102
|
-
altitudeAccuracy:
|
|
103
|
-
heading:
|
|
104
|
-
speed:
|
|
105
|
-
timestamp:
|
|
100
|
+
latitude: n.coords.latitude,
|
|
101
|
+
longitude: n.coords.longitude,
|
|
102
|
+
accuracy: n.coords.accuracy,
|
|
103
|
+
altitude: n.coords.altitude ?? void 0,
|
|
104
|
+
altitudeAccuracy: n.coords.altitudeAccuracy ?? void 0,
|
|
105
|
+
heading: n.coords.heading ?? void 0,
|
|
106
|
+
speed: n.coords.speed ?? void 0,
|
|
107
|
+
timestamp: n.timestamp
|
|
106
108
|
};
|
|
107
109
|
e(s);
|
|
108
110
|
},
|
|
109
|
-
(
|
|
111
|
+
(n) => {
|
|
110
112
|
let s = "UNKNOWN_ERROR", a = "Unknown geolocation error";
|
|
111
|
-
switch (
|
|
112
|
-
case
|
|
113
|
+
switch (n.code) {
|
|
114
|
+
case n.PERMISSION_DENIED:
|
|
113
115
|
s = "PERMISSION_DENIED", a = "Geolocation permission denied";
|
|
114
116
|
break;
|
|
115
|
-
case
|
|
117
|
+
case n.POSITION_UNAVAILABLE:
|
|
116
118
|
a = "Position unavailable";
|
|
117
119
|
break;
|
|
118
|
-
case
|
|
120
|
+
case n.TIMEOUT:
|
|
119
121
|
a = "Geolocation timeout";
|
|
120
122
|
break;
|
|
121
123
|
}
|
|
@@ -138,7 +140,7 @@ class x {
|
|
|
138
140
|
};
|
|
139
141
|
return navigator.geolocation.watchPosition(
|
|
140
142
|
(o) => {
|
|
141
|
-
const
|
|
143
|
+
const n = {
|
|
142
144
|
latitude: o.coords.latitude,
|
|
143
145
|
longitude: o.coords.longitude,
|
|
144
146
|
accuracy: o.coords.accuracy,
|
|
@@ -148,7 +150,7 @@ class x {
|
|
|
148
150
|
speed: o.coords.speed ?? void 0,
|
|
149
151
|
timestamp: o.timestamp
|
|
150
152
|
};
|
|
151
|
-
t(
|
|
153
|
+
t(n);
|
|
152
154
|
},
|
|
153
155
|
(o) => {
|
|
154
156
|
console.error("Geolocation watch error:", o);
|
|
@@ -163,47 +165,37 @@ class x {
|
|
|
163
165
|
navigator.geolocation.clearWatch(t);
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
|
-
const
|
|
168
|
+
const K = new k();
|
|
167
169
|
function E() {
|
|
168
170
|
return "DeviceMotionEvent" in window;
|
|
169
171
|
}
|
|
170
|
-
function N() {
|
|
171
|
-
return "DeviceOrientationEvent" in window;
|
|
172
|
-
}
|
|
173
172
|
function R() {
|
|
174
|
-
|
|
175
|
-
return console.log("🔍 [Aippy Sensors] hasNativeBridge check:", {
|
|
176
|
-
hasWindow: n,
|
|
177
|
-
hasWebkit: t,
|
|
178
|
-
hasMessageHandlers: e,
|
|
179
|
-
hasAippyListener: i,
|
|
180
|
-
result: i
|
|
181
|
-
}), i;
|
|
173
|
+
return "DeviceOrientationEvent" in window;
|
|
182
174
|
}
|
|
183
175
|
function I() {
|
|
184
176
|
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
177
|
}
|
|
186
|
-
function P(
|
|
178
|
+
function P(r, t, e) {
|
|
187
179
|
switch (e) {
|
|
188
180
|
case 0:
|
|
189
|
-
return [
|
|
181
|
+
return [r, -t];
|
|
190
182
|
case 180:
|
|
191
|
-
return [-
|
|
183
|
+
return [-r, t];
|
|
192
184
|
case 90:
|
|
193
|
-
return [-t,
|
|
185
|
+
return [-t, r];
|
|
194
186
|
case -90:
|
|
195
|
-
return [t, -
|
|
187
|
+
return [t, -r];
|
|
196
188
|
default:
|
|
197
|
-
return [
|
|
189
|
+
return [r, -t];
|
|
198
190
|
}
|
|
199
191
|
}
|
|
200
192
|
async function b() {
|
|
201
|
-
if (console.log("🔐 [Aippy Sensors] requestMotionPermission called"),
|
|
193
|
+
if (console.log("🔐 [Aippy Sensors] requestMotionPermission called"), N())
|
|
202
194
|
return console.log("✅ [Aippy Sensors] Native bridge available, skipping permission request"), !0;
|
|
203
195
|
if (!E())
|
|
204
196
|
return console.warn("❌ [Aippy Sensors] Device motion not supported"), !1;
|
|
205
|
-
const
|
|
206
|
-
if (console.log("🔍 [Aippy Sensors] Permission API available:",
|
|
197
|
+
const r = typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function";
|
|
198
|
+
if (console.log("🔍 [Aippy Sensors] Permission API available:", r), r)
|
|
207
199
|
try {
|
|
208
200
|
console.log("🙏 [Aippy Sensors] Requesting device motion permission...");
|
|
209
201
|
const t = await DeviceMotionEvent.requestPermission();
|
|
@@ -213,25 +205,42 @@ async function b() {
|
|
|
213
205
|
}
|
|
214
206
|
return console.log("✅ [Aippy Sensors] No permission needed (granted by default)"), !0;
|
|
215
207
|
}
|
|
216
|
-
function
|
|
208
|
+
function x(r) {
|
|
217
209
|
console.log("🔧 [Aippy Sensors] watchMotionNative - Setting up native bridge listener");
|
|
218
|
-
const t =
|
|
219
|
-
const i = I(), o = e.gravity?.x ?? 0,
|
|
210
|
+
const t = L.addMotionListener((e) => {
|
|
211
|
+
const i = I(), o = e.gravity?.x ?? 0, n = 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, n, 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
212
|
let w = 0;
|
|
221
213
|
g && (w = e.attitude.yaw * (180 / Math.PI), w < 0 && (w += 360));
|
|
222
214
|
const f = {
|
|
223
|
-
gravity: {
|
|
224
|
-
|
|
215
|
+
gravity: {
|
|
216
|
+
x: m,
|
|
217
|
+
y: l,
|
|
218
|
+
z: s
|
|
219
|
+
// Z-axis not affected by screen rotation
|
|
220
|
+
},
|
|
221
|
+
acceleration: {
|
|
222
|
+
x: y,
|
|
223
|
+
y: v,
|
|
224
|
+
z: u
|
|
225
|
+
// Z-axis not affected by screen rotation
|
|
226
|
+
},
|
|
225
227
|
accelerationIncludingGravity: {
|
|
226
228
|
x: m + y,
|
|
227
229
|
y: l + v,
|
|
228
230
|
z: s + u
|
|
229
231
|
},
|
|
232
|
+
// iOS native uses rotationRate.x/y/z (rad/s)
|
|
233
|
+
// Convert to rotation.alpha/beta/gamma (deg/s)
|
|
230
234
|
rotation: {
|
|
235
|
+
// If attitude is available, use yaw for alpha (compass heading)
|
|
236
|
+
// Otherwise fallback to rotationRate.z (angular velocity)
|
|
231
237
|
alpha: g ? w : (e.rotationRate?.z ?? 0) * (180 / Math.PI),
|
|
232
238
|
beta: (e.rotationRate?.x ?? 0) * (180 / Math.PI),
|
|
239
|
+
// x -> beta (around X-axis)
|
|
233
240
|
gamma: (e.rotationRate?.y ?? 0) * (180 / Math.PI)
|
|
241
|
+
// y -> gamma (around Y-axis)
|
|
234
242
|
},
|
|
243
|
+
// Add attitude data for more precise orientation info
|
|
235
244
|
attitude: g ? {
|
|
236
245
|
yaw: w,
|
|
237
246
|
pitch: e.attitude.pitch * (180 / Math.PI),
|
|
@@ -245,11 +254,11 @@ function F(n) {
|
|
|
245
254
|
} : void 0,
|
|
246
255
|
timestamp: Date.now()
|
|
247
256
|
};
|
|
248
|
-
|
|
257
|
+
r(f);
|
|
249
258
|
});
|
|
250
259
|
return console.log("✅ [Aippy Sensors] watchMotionNative - Listener setup complete"), t;
|
|
251
260
|
}
|
|
252
|
-
function
|
|
261
|
+
function _(r, t = !0) {
|
|
253
262
|
if (!E())
|
|
254
263
|
throw c("Device motion API is not supported", "NOT_SUPPORTED");
|
|
255
264
|
let e = !1, i = null;
|
|
@@ -264,12 +273,22 @@ function M(n, t = !0) {
|
|
|
264
273
|
const p = a.accelerationIncludingGravity, h = 9.8;
|
|
265
274
|
u = (p?.x ?? 0) / h, m = (p?.y ?? 0) / h, l = (p?.z ?? 0) / h;
|
|
266
275
|
}
|
|
267
|
-
const y = a.acceleration?.x ?? 0, v = a.acceleration?.y ?? 0, g = a.acceleration?.z ?? 0, [w, f] = P(u, m, d), [O,
|
|
268
|
-
gravity: {
|
|
269
|
-
|
|
276
|
+
const y = a.acceleration?.x ?? 0, v = a.acceleration?.y ?? 0, g = a.acceleration?.z ?? 0, [w, f] = P(u, m, d), [O, S] = P(y, v, d), M = {
|
|
277
|
+
gravity: {
|
|
278
|
+
x: w,
|
|
279
|
+
y: f,
|
|
280
|
+
z: l
|
|
281
|
+
// Z-axis not affected by screen rotation
|
|
282
|
+
},
|
|
283
|
+
acceleration: {
|
|
284
|
+
x: O,
|
|
285
|
+
y: S,
|
|
286
|
+
z: g
|
|
287
|
+
// Z-axis not affected by screen rotation
|
|
288
|
+
},
|
|
270
289
|
accelerationIncludingGravity: {
|
|
271
290
|
x: w + O,
|
|
272
|
-
y: f +
|
|
291
|
+
y: f + S,
|
|
273
292
|
z: l + g
|
|
274
293
|
},
|
|
275
294
|
rotation: {
|
|
@@ -279,60 +298,60 @@ function M(n, t = !0) {
|
|
|
279
298
|
},
|
|
280
299
|
timestamp: Date.now()
|
|
281
300
|
};
|
|
282
|
-
|
|
283
|
-
},
|
|
301
|
+
r(M);
|
|
302
|
+
}, n = async () => {
|
|
284
303
|
t && !await b() || (e = !0, window.addEventListener("devicemotion", o));
|
|
285
304
|
};
|
|
286
305
|
return (async () => {
|
|
287
306
|
if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && t) {
|
|
288
307
|
const d = async () => {
|
|
289
|
-
i = null, await
|
|
308
|
+
i = null, await n();
|
|
290
309
|
};
|
|
291
310
|
window.addEventListener("click", d, { once: !0 }), window.addEventListener("touchstart", d, { once: !0 }), i = () => {
|
|
292
311
|
window.removeEventListener("click", d), window.removeEventListener("touchstart", d);
|
|
293
312
|
};
|
|
294
313
|
} else
|
|
295
|
-
await
|
|
314
|
+
await n();
|
|
296
315
|
})(), () => {
|
|
297
316
|
e = !1, window.removeEventListener("devicemotion", o), i && (i(), i = null);
|
|
298
317
|
};
|
|
299
318
|
}
|
|
300
|
-
function
|
|
301
|
-
|
|
302
|
-
|
|
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);
|
|
319
|
+
function X(r, t = !0) {
|
|
320
|
+
const e = N();
|
|
321
|
+
return console.log(`🎯 [Aippy Sensors] watchMotion - Using ${e ? "NATIVE BRIDGE" : "WEB API"} mode`), e ? (console.log("📱 [Aippy Sensors] Starting native bridge motion listener"), x(r)) : (console.log("🌐 [Aippy Sensors] Starting Web API motion listener (may require permission)"), _(r, t));
|
|
313
322
|
}
|
|
314
|
-
function
|
|
315
|
-
if (!
|
|
323
|
+
function Y(r) {
|
|
324
|
+
if (!R())
|
|
316
325
|
throw c("Device orientation API is not supported", "NOT_SUPPORTED");
|
|
317
326
|
const t = (e) => {
|
|
318
|
-
|
|
327
|
+
const i = {
|
|
319
328
|
alpha: e.alpha ?? 0,
|
|
320
329
|
beta: e.beta ?? 0,
|
|
321
330
|
gamma: e.gamma ?? 0,
|
|
322
331
|
timestamp: Date.now()
|
|
323
|
-
}
|
|
332
|
+
};
|
|
333
|
+
r(i);
|
|
324
334
|
};
|
|
325
335
|
return window.addEventListener("deviceorientation", t), () => {
|
|
326
336
|
window.removeEventListener("deviceorientation", t);
|
|
327
337
|
};
|
|
328
338
|
}
|
|
329
|
-
class
|
|
339
|
+
class F {
|
|
340
|
+
/**
|
|
341
|
+
* Check if device orientation is supported
|
|
342
|
+
*/
|
|
330
343
|
isOrientationSupported() {
|
|
331
|
-
return
|
|
344
|
+
return R();
|
|
332
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* Check if device motion is supported
|
|
348
|
+
*/
|
|
333
349
|
isMotionSupported() {
|
|
334
350
|
return E();
|
|
335
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Get device orientation data
|
|
354
|
+
*/
|
|
336
355
|
async getOrientation() {
|
|
337
356
|
if (!this.isOrientationSupported())
|
|
338
357
|
throw c("Device orientation API is not supported", "NOT_SUPPORTED");
|
|
@@ -350,7 +369,10 @@ class z {
|
|
|
350
369
|
}, 5e3);
|
|
351
370
|
});
|
|
352
371
|
}
|
|
353
|
-
/**
|
|
372
|
+
/**
|
|
373
|
+
* Watch device orientation changes
|
|
374
|
+
* @deprecated Use watchOrientation() function instead
|
|
375
|
+
*/
|
|
354
376
|
watchOrientation(t) {
|
|
355
377
|
if (!this.isOrientationSupported())
|
|
356
378
|
throw c("Device orientation API is not supported", "NOT_SUPPORTED");
|
|
@@ -366,6 +388,9 @@ class z {
|
|
|
366
388
|
window.removeEventListener("deviceorientation", e);
|
|
367
389
|
};
|
|
368
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Get device motion data
|
|
393
|
+
*/
|
|
369
394
|
async getMotion() {
|
|
370
395
|
if (!this.isMotionSupported())
|
|
371
396
|
throw c("Device motion API is not supported", "NOT_SUPPORTED");
|
|
@@ -383,7 +408,10 @@ class z {
|
|
|
383
408
|
}, 5e3);
|
|
384
409
|
});
|
|
385
410
|
}
|
|
386
|
-
/**
|
|
411
|
+
/**
|
|
412
|
+
* Watch device motion changes
|
|
413
|
+
* @deprecated Use watchMotion() function instead
|
|
414
|
+
*/
|
|
387
415
|
watchMotion(t) {
|
|
388
416
|
if (!this.isMotionSupported())
|
|
389
417
|
throw c("Device motion API is not supported", "NOT_SUPPORTED");
|
|
@@ -399,12 +427,15 @@ class z {
|
|
|
399
427
|
window.removeEventListener("devicemotion", e);
|
|
400
428
|
};
|
|
401
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Request permission for motion sensors (iOS 13+)
|
|
432
|
+
*/
|
|
402
433
|
async requestPermission() {
|
|
403
434
|
return b();
|
|
404
435
|
}
|
|
405
436
|
}
|
|
406
|
-
const
|
|
407
|
-
class
|
|
437
|
+
const B = new F();
|
|
438
|
+
class z {
|
|
408
439
|
/**
|
|
409
440
|
* Check if file system access is supported
|
|
410
441
|
*/
|
|
@@ -428,16 +459,16 @@ class G {
|
|
|
428
459
|
types: t.accept ? [{
|
|
429
460
|
description: "Files",
|
|
430
461
|
accept: Object.fromEntries(
|
|
431
|
-
t.accept.map((
|
|
462
|
+
t.accept.map((n) => [n, [n]])
|
|
432
463
|
)
|
|
433
464
|
}] : void 0,
|
|
434
465
|
multiple: t.multiple ?? !1
|
|
435
466
|
}, i = await window.showOpenFilePicker(e), o = await Promise.all(
|
|
436
|
-
i.map(async (
|
|
467
|
+
i.map(async (n) => n.getFile())
|
|
437
468
|
);
|
|
438
469
|
return {
|
|
439
470
|
files: o,
|
|
440
|
-
paths: o.map((
|
|
471
|
+
paths: o.map((n) => n.name)
|
|
441
472
|
};
|
|
442
473
|
} catch (e) {
|
|
443
474
|
throw e instanceof Error && e.name === "AbortError" ? c("File picker was cancelled", "PERMISSION_DENIED") : c(
|
|
@@ -454,8 +485,8 @@ class G {
|
|
|
454
485
|
throw c("File input is not supported", "NOT_SUPPORTED");
|
|
455
486
|
return new Promise((e, i) => {
|
|
456
487
|
const o = document.createElement("input");
|
|
457
|
-
o.type = "file", o.multiple = t.multiple ?? !1, o.accept = t.accept?.join(",") ?? "", o.onchange = (
|
|
458
|
-
const s =
|
|
488
|
+
o.type = "file", o.multiple = t.multiple ?? !1, o.accept = t.accept?.join(",") ?? "", o.onchange = (n) => {
|
|
489
|
+
const s = n.target, a = Array.from(s.files || []);
|
|
459
490
|
e({
|
|
460
491
|
files: a,
|
|
461
492
|
paths: a.map((d) => d.name)
|
|
@@ -504,15 +535,15 @@ class G {
|
|
|
504
535
|
});
|
|
505
536
|
}
|
|
506
537
|
}
|
|
507
|
-
const
|
|
508
|
-
function
|
|
538
|
+
const $ = new z();
|
|
539
|
+
function j(r) {
|
|
509
540
|
return new Promise((t) => {
|
|
510
541
|
if ("vibrate" in navigator)
|
|
511
|
-
navigator.vibrate(
|
|
542
|
+
navigator.vibrate(r), t();
|
|
512
543
|
else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.aippyListener) {
|
|
513
544
|
const e = {
|
|
514
545
|
command: "navigator.vibrate",
|
|
515
|
-
parameters:
|
|
546
|
+
parameters: r
|
|
516
547
|
};
|
|
517
548
|
window.webkit.messageHandlers.aippyListener.postMessage(e), t();
|
|
518
549
|
} else
|
|
@@ -520,19 +551,19 @@ function $(n) {
|
|
|
520
551
|
});
|
|
521
552
|
}
|
|
522
553
|
export {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
554
|
+
T as CameraAPI,
|
|
555
|
+
z as FileSystemAPI,
|
|
556
|
+
k as GeolocationAPI,
|
|
557
|
+
F as SensorsAPI,
|
|
527
558
|
H as camera,
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
559
|
+
$ as fileSystem,
|
|
560
|
+
K as geolocation,
|
|
561
|
+
N as hasNativeBridge,
|
|
531
562
|
E as isMotionSupported,
|
|
532
|
-
|
|
563
|
+
R as isOrientationSupported,
|
|
533
564
|
b as requestMotionPermission,
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
565
|
+
B as sensors,
|
|
566
|
+
j as vibrate,
|
|
567
|
+
X as watchMotion,
|
|
568
|
+
Y as watchOrientation
|
|
538
569
|
};
|
package/dist/device/sensors.d.ts
CHANGED
|
@@ -1,24 +1,72 @@
|
|
|
1
|
+
import { hasNativeBridge } from '../core/native-bridge';
|
|
1
2
|
import { SensorData, MotionData, OrientationData } from './types';
|
|
3
|
+
export { hasNativeBridge };
|
|
4
|
+
/**
|
|
5
|
+
* Check if device motion is supported
|
|
6
|
+
*/
|
|
2
7
|
export declare function isMotionSupported(): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Check if device orientation is supported
|
|
10
|
+
*/
|
|
3
11
|
export declare function isOrientationSupported(): boolean;
|
|
4
|
-
|
|
5
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Request permission for motion sensors (iOS 13+)
|
|
14
|
+
* @returns Promise<boolean> - true if permission granted
|
|
15
|
+
*/
|
|
6
16
|
export declare function requestMotionPermission(): Promise<boolean>;
|
|
7
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Watch device motion changes with full motion data
|
|
19
|
+
* Automatically uses native bridge if available, otherwise falls back to Web API
|
|
20
|
+
*
|
|
21
|
+
* @param callback - Function to call with motion data
|
|
22
|
+
* @param autoRequestPermission - Automatically request permission on iOS (default: true, only for Web API)
|
|
23
|
+
* @returns Cleanup function to stop watching
|
|
24
|
+
*/
|
|
8
25
|
export declare function watchMotion(callback: (data: MotionData) => void, autoRequestPermission?: boolean): () => void;
|
|
9
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Watch device orientation changes
|
|
28
|
+
* @param callback - Function to call with orientation data
|
|
29
|
+
* @returns Cleanup function to stop watching
|
|
30
|
+
*/
|
|
10
31
|
export declare function watchOrientation(callback: (data: OrientationData) => void): () => void;
|
|
11
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Legacy SensorsAPI class for backward compatibility
|
|
34
|
+
* @deprecated Use watchMotion() and watchOrientation() functions instead
|
|
35
|
+
*/
|
|
12
36
|
export declare class SensorsAPI {
|
|
37
|
+
/**
|
|
38
|
+
* Check if device orientation is supported
|
|
39
|
+
*/
|
|
13
40
|
isOrientationSupported(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Check if device motion is supported
|
|
43
|
+
*/
|
|
14
44
|
isMotionSupported(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Get device orientation data
|
|
47
|
+
*/
|
|
15
48
|
getOrientation(): Promise<SensorData>;
|
|
16
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Watch device orientation changes
|
|
51
|
+
* @deprecated Use watchOrientation() function instead
|
|
52
|
+
*/
|
|
17
53
|
watchOrientation(callback: (data: SensorData) => void): () => void;
|
|
54
|
+
/**
|
|
55
|
+
* Get device motion data
|
|
56
|
+
*/
|
|
18
57
|
getMotion(): Promise<SensorData>;
|
|
19
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Watch device motion changes
|
|
60
|
+
* @deprecated Use watchMotion() function instead
|
|
61
|
+
*/
|
|
20
62
|
watchMotion(callback: (data: SensorData) => void): () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Request permission for motion sensors (iOS 13+)
|
|
65
|
+
*/
|
|
21
66
|
requestPermission(): Promise<boolean>;
|
|
22
67
|
}
|
|
23
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Sensors API instance (for backward compatibility)
|
|
70
|
+
* @deprecated Use watchMotion() and watchOrientation() functions instead
|
|
71
|
+
*/
|
|
24
72
|
export declare const sensors: SensorsAPI;
|