@aippy/runtime 0.2.6 → 0.2.7-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 +22 -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 +54 -0
- package/dist/ai/shared/fetch.d.ts +28 -0
- package/dist/ai/shared/index.d.ts +6 -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 +121 -129
- package/dist/device/sensors.d.ts +5 -1
- package/dist/errors-CDEBaBxB.js +26 -0
- package/dist/errors-DWRVLkVz.js +152 -0
- package/dist/index/index.js +93 -47
- package/dist/index.d.ts +2 -0
- 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 +48 -36
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.7-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
1
|
var D = Object.defineProperty;
|
|
2
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
|
|
4
|
-
import { c as s
|
|
5
|
-
|
|
3
|
+
var I = (n, e, t) => U(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { c as s } from "../errors-CDEBaBxB.js";
|
|
5
|
+
import { a as T } from "../runtime-CmoG3v2m.js";
|
|
6
|
+
import { h as N } from "../native-bridge-JAmH-zTN.js";
|
|
7
|
+
class L {
|
|
6
8
|
constructor() {
|
|
7
|
-
|
|
9
|
+
I(this, "stream", null);
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Check if camera is supported
|
|
@@ -43,20 +45,20 @@ class T {
|
|
|
43
45
|
try {
|
|
44
46
|
const t = document.createElement("video");
|
|
45
47
|
t.srcObject = this.stream, t.play();
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
+
const o = document.createElement("canvas"), i = o.getContext("2d");
|
|
49
|
+
if (!i)
|
|
48
50
|
throw s("Failed to get canvas context", "UNKNOWN_ERROR");
|
|
49
|
-
|
|
51
|
+
o.width = e.width || t.videoWidth, o.height = e.height || t.videoHeight, i.drawImage(t, 0, 0, o.width, o.height);
|
|
50
52
|
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
|
-
|
|
53
|
+
o.toBlob((l) => {
|
|
52
54
|
l ? u(l) : m(new Error("Failed to create blob"));
|
|
53
55
|
}, `image/${r}`, c);
|
|
54
|
-
}), d =
|
|
56
|
+
}), d = o.toDataURL(`image/${r}`, c);
|
|
55
57
|
return {
|
|
56
58
|
blob: a,
|
|
57
59
|
dataUrl: d,
|
|
58
|
-
width:
|
|
59
|
-
height:
|
|
60
|
+
width: o.width,
|
|
61
|
+
height: o.height
|
|
60
62
|
};
|
|
61
63
|
} catch (t) {
|
|
62
64
|
throw s(
|
|
@@ -72,7 +74,7 @@ class T {
|
|
|
72
74
|
this.stream && (this.stream.getTracks().forEach((e) => e.stop()), this.stream = null);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
const
|
|
77
|
+
const X = new L();
|
|
76
78
|
class k {
|
|
77
79
|
/**
|
|
78
80
|
* Check if geolocation is supported
|
|
@@ -86,8 +88,8 @@ class k {
|
|
|
86
88
|
async getCurrentPosition(e = {}) {
|
|
87
89
|
if (!this.isSupported())
|
|
88
90
|
throw s("Geolocation API is not supported", "NOT_SUPPORTED");
|
|
89
|
-
return new Promise((t,
|
|
90
|
-
const
|
|
91
|
+
return new Promise((t, o) => {
|
|
92
|
+
const i = {
|
|
91
93
|
enableHighAccuracy: e.enableHighAccuracy ?? !0,
|
|
92
94
|
timeout: e.timeout ?? 1e4,
|
|
93
95
|
maximumAge: e.maximumAge ?? 6e4
|
|
@@ -119,9 +121,9 @@ class k {
|
|
|
119
121
|
a = "Geolocation timeout";
|
|
120
122
|
break;
|
|
121
123
|
}
|
|
122
|
-
|
|
124
|
+
o(s(a, c));
|
|
123
125
|
},
|
|
124
|
-
|
|
126
|
+
i
|
|
125
127
|
);
|
|
126
128
|
});
|
|
127
129
|
}
|
|
@@ -131,29 +133,29 @@ class k {
|
|
|
131
133
|
watchPosition(e, t = {}) {
|
|
132
134
|
if (!this.isSupported())
|
|
133
135
|
throw s("Geolocation API is not supported", "NOT_SUPPORTED");
|
|
134
|
-
const
|
|
136
|
+
const o = {
|
|
135
137
|
enableHighAccuracy: t.enableHighAccuracy ?? !0,
|
|
136
138
|
timeout: t.timeout ?? 1e4,
|
|
137
139
|
maximumAge: t.maximumAge ?? 6e4
|
|
138
140
|
};
|
|
139
141
|
return navigator.geolocation.watchPosition(
|
|
140
|
-
(
|
|
142
|
+
(i) => {
|
|
141
143
|
const r = {
|
|
142
|
-
latitude:
|
|
143
|
-
longitude:
|
|
144
|
-
accuracy:
|
|
145
|
-
altitude:
|
|
146
|
-
altitudeAccuracy:
|
|
147
|
-
heading:
|
|
148
|
-
speed:
|
|
149
|
-
timestamp:
|
|
144
|
+
latitude: i.coords.latitude,
|
|
145
|
+
longitude: i.coords.longitude,
|
|
146
|
+
accuracy: i.coords.accuracy,
|
|
147
|
+
altitude: i.coords.altitude ?? void 0,
|
|
148
|
+
altitudeAccuracy: i.coords.altitudeAccuracy ?? void 0,
|
|
149
|
+
heading: i.coords.heading ?? void 0,
|
|
150
|
+
speed: i.coords.speed ?? void 0,
|
|
151
|
+
timestamp: i.timestamp
|
|
150
152
|
};
|
|
151
153
|
e(r);
|
|
152
154
|
},
|
|
153
|
-
(
|
|
154
|
-
console.error("Geolocation watch error:",
|
|
155
|
+
(i) => {
|
|
156
|
+
console.error("Geolocation watch error:", i);
|
|
155
157
|
},
|
|
156
|
-
|
|
158
|
+
o
|
|
157
159
|
);
|
|
158
160
|
}
|
|
159
161
|
/**
|
|
@@ -163,24 +165,14 @@ class k {
|
|
|
163
165
|
navigator.geolocation.clearWatch(e);
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
|
-
const
|
|
168
|
+
const Y = new k();
|
|
167
169
|
function E() {
|
|
168
170
|
return "DeviceMotionEvent" in window;
|
|
169
171
|
}
|
|
170
|
-
function I() {
|
|
171
|
-
return "DeviceOrientationEvent" in window;
|
|
172
|
-
}
|
|
173
172
|
function R() {
|
|
174
|
-
|
|
175
|
-
return console.log("🔍 [Aippy Sensors] hasNativeBridge check:", {
|
|
176
|
-
hasWindow: n,
|
|
177
|
-
hasWebkit: e,
|
|
178
|
-
hasMessageHandlers: t,
|
|
179
|
-
hasAippyListener: i,
|
|
180
|
-
result: i
|
|
181
|
-
}), i;
|
|
173
|
+
return "DeviceOrientationEvent" in window;
|
|
182
174
|
}
|
|
183
|
-
function
|
|
175
|
+
function M() {
|
|
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
178
|
function P(n, e, t) {
|
|
@@ -198,7 +190,7 @@ function P(n, e, t) {
|
|
|
198
190
|
}
|
|
199
191
|
}
|
|
200
192
|
async function x() {
|
|
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;
|
|
@@ -215,24 +207,24 @@ async function x() {
|
|
|
215
207
|
}
|
|
216
208
|
function F(n) {
|
|
217
209
|
console.log("🔧 [Aippy Sensors] watchMotionNative - Setting up native bridge listener");
|
|
218
|
-
const e =
|
|
219
|
-
const
|
|
210
|
+
const e = T.addMotionListener((t) => {
|
|
211
|
+
const o = M(), i = 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(i, r, o), [g, f] = P(a, d, o), y = t.attitude && typeof t.attitude.yaw == "number" && typeof t.attitude.pitch == "number" && typeof t.attitude.roll == "number";
|
|
220
212
|
let p = 0;
|
|
221
|
-
|
|
213
|
+
y && (p = t.attitude.yaw * (180 / Math.PI), p < 0 && (p += 360));
|
|
222
214
|
const v = {
|
|
223
215
|
gravity: { x: m, y: l, z: c },
|
|
224
|
-
acceleration: { x:
|
|
216
|
+
acceleration: { x: g, y: f, z: u },
|
|
225
217
|
accelerationIncludingGravity: {
|
|
226
|
-
x: m +
|
|
218
|
+
x: m + g,
|
|
227
219
|
y: l + f,
|
|
228
220
|
z: c + u
|
|
229
221
|
},
|
|
230
222
|
rotation: {
|
|
231
|
-
alpha:
|
|
223
|
+
alpha: y ? p : (t.rotationRate?.z ?? 0) * (180 / Math.PI),
|
|
232
224
|
beta: (t.rotationRate?.x ?? 0) * (180 / Math.PI),
|
|
233
225
|
gamma: (t.rotationRate?.y ?? 0) * (180 / Math.PI)
|
|
234
226
|
},
|
|
235
|
-
attitude:
|
|
227
|
+
attitude: y ? {
|
|
236
228
|
yaw: p,
|
|
237
229
|
pitch: t.attitude.pitch * (180 / Math.PI),
|
|
238
230
|
roll: t.attitude.roll * (180 / Math.PI),
|
|
@@ -265,10 +257,10 @@ async function _() {
|
|
|
265
257
|
function A(n, e = !0) {
|
|
266
258
|
if (!E())
|
|
267
259
|
throw s("Device motion API is not supported", "NOT_SUPPORTED");
|
|
268
|
-
let t = !1,
|
|
269
|
-
const
|
|
260
|
+
let t = !1, o = null;
|
|
261
|
+
const i = (a) => {
|
|
270
262
|
if (!t) return;
|
|
271
|
-
const d =
|
|
263
|
+
const d = M();
|
|
272
264
|
let u, m, l;
|
|
273
265
|
if (a.acceleration) {
|
|
274
266
|
const w = a.accelerationIncludingGravity, h = a.acceleration;
|
|
@@ -277,13 +269,13 @@ function A(n, e = !0) {
|
|
|
277
269
|
const w = a.accelerationIncludingGravity, h = 9.8;
|
|
278
270
|
u = (w?.x ?? 0) / h, m = (w?.y ?? 0) / h, l = (w?.z ?? 0) / h;
|
|
279
271
|
}
|
|
280
|
-
const
|
|
272
|
+
const g = a.acceleration?.x ?? 0, f = a.acceleration?.y ?? 0, y = a.acceleration?.z ?? 0, [p, v] = P(u, m, d), [O, S] = P(g, f, d), b = {
|
|
281
273
|
gravity: { x: p, y: v, z: l },
|
|
282
|
-
acceleration: { x: O, y: S, z:
|
|
274
|
+
acceleration: { x: O, y: S, z: y },
|
|
283
275
|
accelerationIncludingGravity: {
|
|
284
276
|
x: p + O,
|
|
285
277
|
y: v + S,
|
|
286
|
-
z: l +
|
|
278
|
+
z: l + y
|
|
287
279
|
},
|
|
288
280
|
rotation: {
|
|
289
281
|
alpha: a.rotationRate?.alpha ?? 0,
|
|
@@ -292,51 +284,51 @@ function A(n, e = !0) {
|
|
|
292
284
|
},
|
|
293
285
|
timestamp: Date.now()
|
|
294
286
|
};
|
|
295
|
-
n(
|
|
287
|
+
n(b);
|
|
296
288
|
}, r = async () => {
|
|
297
|
-
e && !await _() || (t = !0, window.addEventListener("devicemotion",
|
|
289
|
+
e && !await _() || (t = !0, window.addEventListener("devicemotion", i));
|
|
298
290
|
};
|
|
299
291
|
return (async () => {
|
|
300
292
|
if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && e) {
|
|
301
293
|
const d = async () => {
|
|
302
|
-
|
|
294
|
+
o = null, await r();
|
|
303
295
|
};
|
|
304
|
-
window.addEventListener("click", d, { once: !0 }), window.addEventListener("touchstart", d, { once: !0 }),
|
|
296
|
+
window.addEventListener("click", d, { once: !0 }), window.addEventListener("touchstart", d, { once: !0 }), o = () => {
|
|
305
297
|
window.removeEventListener("click", d), window.removeEventListener("touchstart", d);
|
|
306
298
|
};
|
|
307
299
|
} else
|
|
308
300
|
await r();
|
|
309
301
|
})(), () => {
|
|
310
|
-
t = !1, window.removeEventListener("devicemotion",
|
|
302
|
+
t = !1, window.removeEventListener("devicemotion", i), o && (o(), o = null);
|
|
311
303
|
};
|
|
312
304
|
}
|
|
313
305
|
function q(n, e, t = 500) {
|
|
314
|
-
let
|
|
306
|
+
let o = !1, i = null;
|
|
315
307
|
const r = F((a) => {
|
|
316
|
-
|
|
308
|
+
o || (o = !0, clearTimeout(c)), n(a);
|
|
317
309
|
}), c = setTimeout(async () => {
|
|
318
|
-
if (!
|
|
310
|
+
if (!o) {
|
|
319
311
|
if (console.warn("[Aippy Sensors] No native data, falling back to Web API"), r(), typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && e)
|
|
320
312
|
try {
|
|
321
313
|
if (console.log("[Aippy Sensors] Trying direct permission request..."), await DeviceMotionEvent.requestPermission() === "granted") {
|
|
322
|
-
console.log("[Aippy Sensors] Permission granted via fallback"),
|
|
314
|
+
console.log("[Aippy Sensors] Permission granted via fallback"), i = A(n, !1);
|
|
323
315
|
return;
|
|
324
316
|
}
|
|
325
317
|
} catch {
|
|
326
318
|
console.log("[Aippy Sensors] Direct permission failed, waiting for user interaction");
|
|
327
319
|
}
|
|
328
|
-
|
|
320
|
+
i = A(n, e);
|
|
329
321
|
}
|
|
330
322
|
}, t);
|
|
331
323
|
return () => {
|
|
332
|
-
clearTimeout(c), r(),
|
|
324
|
+
clearTimeout(c), r(), i?.();
|
|
333
325
|
};
|
|
334
326
|
}
|
|
335
|
-
function
|
|
336
|
-
return
|
|
327
|
+
function j(n, e = !0) {
|
|
328
|
+
return N() ? q(n, e) : A(n, e);
|
|
337
329
|
}
|
|
338
|
-
function
|
|
339
|
-
if (!
|
|
330
|
+
function $(n) {
|
|
331
|
+
if (!R())
|
|
340
332
|
throw s("Device orientation API is not supported", "NOT_SUPPORTED");
|
|
341
333
|
const e = (t) => {
|
|
342
334
|
n({
|
|
@@ -352,7 +344,7 @@ function Y(n) {
|
|
|
352
344
|
}
|
|
353
345
|
class z {
|
|
354
346
|
isOrientationSupported() {
|
|
355
|
-
return
|
|
347
|
+
return R();
|
|
356
348
|
}
|
|
357
349
|
isMotionSupported() {
|
|
358
350
|
return E();
|
|
@@ -361,16 +353,16 @@ class z {
|
|
|
361
353
|
if (!this.isOrientationSupported())
|
|
362
354
|
throw s("Device orientation API is not supported", "NOT_SUPPORTED");
|
|
363
355
|
return new Promise((e, t) => {
|
|
364
|
-
const
|
|
365
|
-
window.removeEventListener("deviceorientation",
|
|
366
|
-
x:
|
|
367
|
-
y:
|
|
368
|
-
z:
|
|
356
|
+
const o = (i) => {
|
|
357
|
+
window.removeEventListener("deviceorientation", o), e({
|
|
358
|
+
x: i.alpha ?? 0,
|
|
359
|
+
y: i.beta ?? 0,
|
|
360
|
+
z: i.gamma ?? 0,
|
|
369
361
|
timestamp: Date.now()
|
|
370
362
|
});
|
|
371
363
|
};
|
|
372
|
-
window.addEventListener("deviceorientation",
|
|
373
|
-
window.removeEventListener("deviceorientation",
|
|
364
|
+
window.addEventListener("deviceorientation", o), setTimeout(() => {
|
|
365
|
+
window.removeEventListener("deviceorientation", o), t(s("Device orientation timeout", "UNKNOWN_ERROR"));
|
|
374
366
|
}, 5e3);
|
|
375
367
|
});
|
|
376
368
|
}
|
|
@@ -378,11 +370,11 @@ class z {
|
|
|
378
370
|
watchOrientation(e) {
|
|
379
371
|
if (!this.isOrientationSupported())
|
|
380
372
|
throw s("Device orientation API is not supported", "NOT_SUPPORTED");
|
|
381
|
-
const t = (
|
|
373
|
+
const t = (o) => {
|
|
382
374
|
e({
|
|
383
|
-
x:
|
|
384
|
-
y:
|
|
385
|
-
z:
|
|
375
|
+
x: o.alpha ?? 0,
|
|
376
|
+
y: o.beta ?? 0,
|
|
377
|
+
z: o.gamma ?? 0,
|
|
386
378
|
timestamp: Date.now()
|
|
387
379
|
});
|
|
388
380
|
};
|
|
@@ -394,16 +386,16 @@ class z {
|
|
|
394
386
|
if (!this.isMotionSupported())
|
|
395
387
|
throw s("Device motion API is not supported", "NOT_SUPPORTED");
|
|
396
388
|
return new Promise((e, t) => {
|
|
397
|
-
const
|
|
398
|
-
window.removeEventListener("devicemotion",
|
|
399
|
-
x:
|
|
400
|
-
y:
|
|
401
|
-
z:
|
|
389
|
+
const o = (i) => {
|
|
390
|
+
window.removeEventListener("devicemotion", o), e({
|
|
391
|
+
x: i.acceleration?.x ?? 0,
|
|
392
|
+
y: i.acceleration?.y ?? 0,
|
|
393
|
+
z: i.acceleration?.z ?? 0,
|
|
402
394
|
timestamp: Date.now()
|
|
403
395
|
});
|
|
404
396
|
};
|
|
405
|
-
window.addEventListener("devicemotion",
|
|
406
|
-
window.removeEventListener("devicemotion",
|
|
397
|
+
window.addEventListener("devicemotion", o), setTimeout(() => {
|
|
398
|
+
window.removeEventListener("devicemotion", o), t(s("Device motion timeout", "UNKNOWN_ERROR"));
|
|
407
399
|
}, 5e3);
|
|
408
400
|
});
|
|
409
401
|
}
|
|
@@ -411,11 +403,11 @@ class z {
|
|
|
411
403
|
watchMotion(e) {
|
|
412
404
|
if (!this.isMotionSupported())
|
|
413
405
|
throw s("Device motion API is not supported", "NOT_SUPPORTED");
|
|
414
|
-
const t = (
|
|
406
|
+
const t = (o) => {
|
|
415
407
|
e({
|
|
416
|
-
x:
|
|
417
|
-
y:
|
|
418
|
-
z:
|
|
408
|
+
x: o.acceleration?.x ?? 0,
|
|
409
|
+
y: o.acceleration?.y ?? 0,
|
|
410
|
+
z: o.acceleration?.z ?? 0,
|
|
419
411
|
timestamp: Date.now()
|
|
420
412
|
});
|
|
421
413
|
};
|
|
@@ -427,8 +419,8 @@ class z {
|
|
|
427
419
|
return x();
|
|
428
420
|
}
|
|
429
421
|
}
|
|
430
|
-
const
|
|
431
|
-
class
|
|
422
|
+
const B = new z();
|
|
423
|
+
class G {
|
|
432
424
|
/**
|
|
433
425
|
* Check if file system access is supported
|
|
434
426
|
*/
|
|
@@ -456,12 +448,12 @@ class W {
|
|
|
456
448
|
)
|
|
457
449
|
}] : void 0,
|
|
458
450
|
multiple: e.multiple ?? !1
|
|
459
|
-
},
|
|
460
|
-
|
|
451
|
+
}, o = await window.showOpenFilePicker(t), i = await Promise.all(
|
|
452
|
+
o.map(async (r) => r.getFile())
|
|
461
453
|
);
|
|
462
454
|
return {
|
|
463
|
-
files:
|
|
464
|
-
paths:
|
|
455
|
+
files: i,
|
|
456
|
+
paths: i.map((r) => r.name)
|
|
465
457
|
};
|
|
466
458
|
} catch (t) {
|
|
467
459
|
throw t instanceof Error && t.name === "AbortError" ? s("File picker was cancelled", "PERMISSION_DENIED") : s(
|
|
@@ -476,17 +468,17 @@ class W {
|
|
|
476
468
|
async openFilePickerLegacy(e = {}) {
|
|
477
469
|
if (!this.isLegacySupported())
|
|
478
470
|
throw s("File input is not supported", "NOT_SUPPORTED");
|
|
479
|
-
return new Promise((t,
|
|
480
|
-
const
|
|
481
|
-
|
|
471
|
+
return new Promise((t, o) => {
|
|
472
|
+
const i = document.createElement("input");
|
|
473
|
+
i.type = "file", i.multiple = e.multiple ?? !1, i.accept = e.accept?.join(",") ?? "", i.onchange = (r) => {
|
|
482
474
|
const c = r.target, a = Array.from(c.files || []);
|
|
483
475
|
t({
|
|
484
476
|
files: a,
|
|
485
477
|
paths: a.map((d) => d.name)
|
|
486
478
|
});
|
|
487
|
-
},
|
|
488
|
-
|
|
489
|
-
},
|
|
479
|
+
}, i.oncancel = () => {
|
|
480
|
+
o(s("File picker was cancelled", "PERMISSION_DENIED"));
|
|
481
|
+
}, i.click();
|
|
490
482
|
});
|
|
491
483
|
}
|
|
492
484
|
/**
|
|
@@ -500,11 +492,11 @@ class W {
|
|
|
500
492
|
*/
|
|
501
493
|
async saveFile(e, t) {
|
|
502
494
|
try {
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
} catch (
|
|
495
|
+
const o = URL.createObjectURL(e), i = document.createElement("a");
|
|
496
|
+
i.href = o, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(o);
|
|
497
|
+
} catch (o) {
|
|
506
498
|
throw s(
|
|
507
|
-
`Failed to save file: ${
|
|
499
|
+
`Failed to save file: ${o instanceof Error ? o.message : "Unknown error"}`,
|
|
508
500
|
"UNKNOWN_ERROR"
|
|
509
501
|
);
|
|
510
502
|
}
|
|
@@ -513,23 +505,23 @@ class W {
|
|
|
513
505
|
* Read file as text
|
|
514
506
|
*/
|
|
515
507
|
async readAsText(e) {
|
|
516
|
-
return new Promise((t,
|
|
517
|
-
const
|
|
518
|
-
|
|
508
|
+
return new Promise((t, o) => {
|
|
509
|
+
const i = new FileReader();
|
|
510
|
+
i.onload = () => t(i.result), i.onerror = () => o(s("Failed to read file", "UNKNOWN_ERROR")), i.readAsText(e);
|
|
519
511
|
});
|
|
520
512
|
}
|
|
521
513
|
/**
|
|
522
514
|
* Read file as data URL
|
|
523
515
|
*/
|
|
524
516
|
async readAsDataURL(e) {
|
|
525
|
-
return new Promise((t,
|
|
526
|
-
const
|
|
527
|
-
|
|
517
|
+
return new Promise((t, o) => {
|
|
518
|
+
const i = new FileReader();
|
|
519
|
+
i.onload = () => t(i.result), i.onerror = () => o(s("Failed to read file", "UNKNOWN_ERROR")), i.readAsDataURL(e);
|
|
528
520
|
});
|
|
529
521
|
}
|
|
530
522
|
}
|
|
531
|
-
const
|
|
532
|
-
function
|
|
523
|
+
const Z = new G();
|
|
524
|
+
function V(n) {
|
|
533
525
|
return new Promise((e) => {
|
|
534
526
|
if ("vibrate" in navigator)
|
|
535
527
|
navigator.vibrate(n), e();
|
|
@@ -544,19 +536,19 @@ function B(n) {
|
|
|
544
536
|
});
|
|
545
537
|
}
|
|
546
538
|
export {
|
|
547
|
-
|
|
548
|
-
|
|
539
|
+
L as CameraAPI,
|
|
540
|
+
G as FileSystemAPI,
|
|
549
541
|
k as GeolocationAPI,
|
|
550
542
|
z as SensorsAPI,
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
543
|
+
X as camera,
|
|
544
|
+
Z as fileSystem,
|
|
545
|
+
Y as geolocation,
|
|
546
|
+
N as hasNativeBridge,
|
|
555
547
|
E as isMotionSupported,
|
|
556
|
-
|
|
548
|
+
R as isOrientationSupported,
|
|
557
549
|
x as requestMotionPermission,
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
550
|
+
B as sensors,
|
|
551
|
+
V as vibrate,
|
|
552
|
+
j as watchMotion,
|
|
553
|
+
$ as watchOrientation
|
|
562
554
|
};
|
package/dist/device/sensors.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
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;
|
|
3
8
|
export declare function isOrientationSupported(): boolean;
|
|
4
|
-
export declare function hasNativeBridge(): boolean;
|
|
5
9
|
/** Request motion sensor permission (iOS 13+) */
|
|
6
10
|
export declare function requestMotionPermission(): Promise<boolean>;
|
|
7
11
|
/** Watch device motion (auto selects native bridge or Web API) */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var e = Object.defineProperty;
|
|
2
|
+
var o = (E, R, N) => R in E ? e(E, R, { enumerable: !0, configurable: !0, writable: !0, value: N }) : E[R] = N;
|
|
3
|
+
var O = (E, R, N) => o(E, typeof R != "symbol" ? R + "" : R, N);
|
|
4
|
+
class I extends Error {
|
|
5
|
+
constructor(N, r = "AIPPY_ERROR", t) {
|
|
6
|
+
super(N);
|
|
7
|
+
O(this, "code");
|
|
8
|
+
O(this, "context");
|
|
9
|
+
this.name = "AippyRuntimeError", this.code = r, this.context = t;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const _ = {
|
|
13
|
+
NOT_SUPPORTED: "NOT_SUPPORTED",
|
|
14
|
+
PERMISSION_DENIED: "PERMISSION_DENIED",
|
|
15
|
+
INVALID_CONFIG: "INVALID_CONFIG",
|
|
16
|
+
NETWORK_ERROR: "NETWORK_ERROR",
|
|
17
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR"
|
|
18
|
+
};
|
|
19
|
+
function s(E, R = "UNKNOWN_ERROR", N) {
|
|
20
|
+
return new I(E, _[R], N);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
I as A,
|
|
24
|
+
_ as E,
|
|
25
|
+
s as c
|
|
26
|
+
};
|