@aippy/runtime 0.2.7-dev.5 → 0.2.7-dev.7
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/ai/config/index.d.ts +1 -1
- package/dist/ai/config/parser.d.ts +5 -12
- package/dist/ai/errors.d.ts +1 -0
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.js +15 -16
- package/dist/ai/shared/fetch.d.ts +0 -4
- package/dist/ai/shared/index.d.ts +1 -1
- package/dist/app-version-checker-B1UXEcy9.js +240 -0
- package/dist/bridge-BQQ3PfSO.js +237 -0
- package/dist/config-B0A7gHQM.js +28 -0
- package/dist/container-message-YB3cWpWj.js +56 -0
- package/dist/core/errors.d.ts +22 -3
- package/dist/core/headers.d.ts +31 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +22 -50
- package/dist/device/index.js +194 -194
- package/dist/errors-B3bDbQbD.js +40 -0
- package/dist/helper-BjRhidue.js +238 -0
- package/dist/hooks-C7VP176R.js +98 -0
- package/dist/index/index.js +89 -80
- package/dist/pwa-C5nXU0DN.js +250 -0
- package/dist/tweaks/index.js +1 -1
- package/dist/url-c26cuIpu.js +7 -0
- package/dist/{useTweaks-QxMRmg7i.js → useTweaks-B7Muzo78.js} +10 -9
- package/dist/user/hooks.d.ts +6 -2
- package/dist/user/index.d.ts +1 -0
- package/dist/user/index.js +3 -3
- package/dist/utils/app-version-checker.d.ts +62 -0
- package/dist/utils/app-version-requirements.json.d.ts +13 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +17 -11
- package/dist/utils/ui.d.ts +3 -1
- package/dist/utils/url.d.ts +7 -0
- package/package.json +1 -1
- package/dist/bridge-Ca3H2iN1.js +0 -197
- package/dist/container-message-DGrno17o.js +0 -31
- package/dist/errors-CDEBaBxB.js +0 -26
- package/dist/helper-BENVYOU-.js +0 -247
- package/dist/hooks-CE9cjXHP.js +0 -46
- package/dist/pwa-CilSlaik.js +0 -249
- package/dist/ui-y5N62DqC.js +0 -175
package/dist/device/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { c as s } from "../errors-
|
|
5
|
-
import { a as
|
|
6
|
-
import { hasNativeBridge as
|
|
7
|
-
class
|
|
1
|
+
var N = Object.defineProperty;
|
|
2
|
+
var L = (n, e, t) => e in n ? N(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var M = (n, e, t) => L(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { c as a, a as s } from "../errors-B3bDbQbD.js";
|
|
5
|
+
import { a as U } from "../runtime-CmoG3v2m.js";
|
|
6
|
+
import { hasNativeBridge as D } from "../native-bridge-BnvipFJc.js";
|
|
7
|
+
class F {
|
|
8
8
|
constructor() {
|
|
9
|
-
|
|
9
|
+
M(this, "stream", null);
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Check if camera is supported
|
|
@@ -19,7 +19,7 @@ class L {
|
|
|
19
19
|
*/
|
|
20
20
|
async getStream(e = {}) {
|
|
21
21
|
if (!this.isSupported())
|
|
22
|
-
throw
|
|
22
|
+
throw a("Camera API is not supported", s.NOT_SUPPORTED);
|
|
23
23
|
try {
|
|
24
24
|
const t = {
|
|
25
25
|
video: {
|
|
@@ -30,9 +30,9 @@ class L {
|
|
|
30
30
|
};
|
|
31
31
|
return this.stream = await navigator.mediaDevices.getUserMedia(t), this.stream;
|
|
32
32
|
} catch (t) {
|
|
33
|
-
throw
|
|
33
|
+
throw a(
|
|
34
34
|
`Failed to access camera: ${t instanceof Error ? t.message : "Unknown error"}`,
|
|
35
|
-
|
|
35
|
+
s.PERMISSION_DENIED
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -41,29 +41,29 @@ class L {
|
|
|
41
41
|
*/
|
|
42
42
|
async capturePhoto(e = {}) {
|
|
43
43
|
if (!this.stream)
|
|
44
|
-
throw
|
|
44
|
+
throw a("No camera stream available", s.NOT_SUPPORTED);
|
|
45
45
|
try {
|
|
46
46
|
const t = document.createElement("video");
|
|
47
47
|
t.srcObject = this.stream, t.play();
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
50
|
-
throw
|
|
51
|
-
|
|
52
|
-
const r = e.format || "jpeg",
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}, `image/${r}`,
|
|
56
|
-
}), d =
|
|
48
|
+
const i = document.createElement("canvas"), o = i.getContext("2d");
|
|
49
|
+
if (!o)
|
|
50
|
+
throw a("Failed to get canvas context", s.OPERATION_FAILED);
|
|
51
|
+
i.width = e.width || t.videoWidth, i.height = e.height || t.videoHeight, o.drawImage(t, 0, 0, i.width, i.height);
|
|
52
|
+
const r = e.format || "jpeg", l = e.quality === "high" ? 0.9 : e.quality === "medium" ? 0.7 : 0.5, c = await new Promise((m, p) => {
|
|
53
|
+
i.toBlob((u) => {
|
|
54
|
+
u ? m(u) : p(a("Failed to create blob", s.OPERATION_FAILED));
|
|
55
|
+
}, `image/${r}`, l);
|
|
56
|
+
}), d = i.toDataURL(`image/${r}`, l);
|
|
57
57
|
return {
|
|
58
|
-
blob:
|
|
58
|
+
blob: c,
|
|
59
59
|
dataUrl: d,
|
|
60
|
-
width:
|
|
61
|
-
height:
|
|
60
|
+
width: i.width,
|
|
61
|
+
height: i.height
|
|
62
62
|
};
|
|
63
63
|
} catch (t) {
|
|
64
|
-
throw
|
|
64
|
+
throw a(
|
|
65
65
|
`Failed to capture photo: ${t instanceof Error ? t.message : "Unknown error"}`,
|
|
66
|
-
|
|
66
|
+
s.OPERATION_FAILED
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -74,7 +74,7 @@ class L {
|
|
|
74
74
|
this.stream && (this.stream.getTracks().forEach((e) => e.stop()), this.stream = null);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const $ = new F();
|
|
78
78
|
class k {
|
|
79
79
|
/**
|
|
80
80
|
* Check if geolocation is supported
|
|
@@ -87,16 +87,16 @@ class k {
|
|
|
87
87
|
*/
|
|
88
88
|
async getCurrentPosition(e = {}) {
|
|
89
89
|
if (!this.isSupported())
|
|
90
|
-
throw
|
|
91
|
-
return new Promise((t,
|
|
92
|
-
const
|
|
90
|
+
throw a("Geolocation API is not supported", s.NOT_SUPPORTED);
|
|
91
|
+
return new Promise((t, i) => {
|
|
92
|
+
const o = {
|
|
93
93
|
enableHighAccuracy: e.enableHighAccuracy ?? !0,
|
|
94
94
|
timeout: e.timeout ?? 1e4,
|
|
95
95
|
maximumAge: e.maximumAge ?? 6e4
|
|
96
96
|
};
|
|
97
97
|
navigator.geolocation.getCurrentPosition(
|
|
98
98
|
(r) => {
|
|
99
|
-
const
|
|
99
|
+
const l = {
|
|
100
100
|
latitude: r.coords.latitude,
|
|
101
101
|
longitude: r.coords.longitude,
|
|
102
102
|
accuracy: r.coords.accuracy,
|
|
@@ -106,24 +106,24 @@ class k {
|
|
|
106
106
|
speed: r.coords.speed ?? void 0,
|
|
107
107
|
timestamp: r.timestamp
|
|
108
108
|
};
|
|
109
|
-
t(
|
|
109
|
+
t(l);
|
|
110
110
|
},
|
|
111
111
|
(r) => {
|
|
112
|
-
let c = "UNKNOWN_ERROR", a = "Unknown geolocation error";
|
|
113
112
|
switch (r.code) {
|
|
114
113
|
case r.PERMISSION_DENIED:
|
|
115
|
-
|
|
114
|
+
i(a("Geolocation permission denied", s.PERMISSION_DENIED));
|
|
116
115
|
break;
|
|
117
116
|
case r.POSITION_UNAVAILABLE:
|
|
118
|
-
a
|
|
117
|
+
i(a("Position unavailable", s.OPERATION_FAILED));
|
|
119
118
|
break;
|
|
120
119
|
case r.TIMEOUT:
|
|
121
|
-
a
|
|
120
|
+
i(a("Geolocation timeout", s.TIMEOUT));
|
|
122
121
|
break;
|
|
122
|
+
default:
|
|
123
|
+
i(a("Unknown geolocation error", s.UNKNOWN_ERROR));
|
|
123
124
|
}
|
|
124
|
-
o(s(a, c));
|
|
125
125
|
},
|
|
126
|
-
|
|
126
|
+
o
|
|
127
127
|
);
|
|
128
128
|
});
|
|
129
129
|
}
|
|
@@ -132,30 +132,30 @@ class k {
|
|
|
132
132
|
*/
|
|
133
133
|
watchPosition(e, t = {}) {
|
|
134
134
|
if (!this.isSupported())
|
|
135
|
-
throw
|
|
136
|
-
const
|
|
135
|
+
throw a("Geolocation API is not supported", s.NOT_SUPPORTED);
|
|
136
|
+
const i = {
|
|
137
137
|
enableHighAccuracy: t.enableHighAccuracy ?? !0,
|
|
138
138
|
timeout: t.timeout ?? 1e4,
|
|
139
139
|
maximumAge: t.maximumAge ?? 6e4
|
|
140
140
|
};
|
|
141
141
|
return navigator.geolocation.watchPosition(
|
|
142
|
-
(
|
|
142
|
+
(o) => {
|
|
143
143
|
const r = {
|
|
144
|
-
latitude:
|
|
145
|
-
longitude:
|
|
146
|
-
accuracy:
|
|
147
|
-
altitude:
|
|
148
|
-
altitudeAccuracy:
|
|
149
|
-
heading:
|
|
150
|
-
speed:
|
|
151
|
-
timestamp:
|
|
144
|
+
latitude: o.coords.latitude,
|
|
145
|
+
longitude: o.coords.longitude,
|
|
146
|
+
accuracy: o.coords.accuracy,
|
|
147
|
+
altitude: o.coords.altitude ?? void 0,
|
|
148
|
+
altitudeAccuracy: o.coords.altitudeAccuracy ?? void 0,
|
|
149
|
+
heading: o.coords.heading ?? void 0,
|
|
150
|
+
speed: o.coords.speed ?? void 0,
|
|
151
|
+
timestamp: o.timestamp
|
|
152
152
|
};
|
|
153
153
|
e(r);
|
|
154
154
|
},
|
|
155
|
-
(
|
|
156
|
-
console.error("Geolocation watch error:",
|
|
155
|
+
(o) => {
|
|
156
|
+
console.error("Geolocation watch error:", o);
|
|
157
157
|
},
|
|
158
|
-
|
|
158
|
+
i
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
@@ -165,17 +165,17 @@ class k {
|
|
|
165
165
|
navigator.geolocation.clearWatch(e);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
const
|
|
169
|
-
function
|
|
168
|
+
const B = new k();
|
|
169
|
+
function A() {
|
|
170
170
|
return "DeviceMotionEvent" in window;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function T() {
|
|
173
173
|
return "DeviceOrientationEvent" in window;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function b() {
|
|
176
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;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function E(n, e, t) {
|
|
179
179
|
switch (t) {
|
|
180
180
|
case 0:
|
|
181
181
|
return [n, -e];
|
|
@@ -189,10 +189,10 @@ function P(n, e, t) {
|
|
|
189
189
|
return [n, -e];
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
async function
|
|
193
|
-
if (console.log("🔐 [Aippy Sensors] requestMotionPermission called"),
|
|
192
|
+
async function _() {
|
|
193
|
+
if (console.log("🔐 [Aippy Sensors] requestMotionPermission called"), D())
|
|
194
194
|
return console.log("✅ [Aippy Sensors] Native bridge available, skipping permission request"), !0;
|
|
195
|
-
if (!
|
|
195
|
+
if (!A())
|
|
196
196
|
return console.warn("❌ [Aippy Sensors] Device motion not supported"), !1;
|
|
197
197
|
const n = typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function";
|
|
198
198
|
if (console.log("🔍 [Aippy Sensors] Permission API available:", n), n)
|
|
@@ -205,27 +205,27 @@ async function x() {
|
|
|
205
205
|
}
|
|
206
206
|
return console.log("✅ [Aippy Sensors] No permission needed (granted by default)"), !0;
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function x(n) {
|
|
209
209
|
console.log("🔧 [Aippy Sensors] watchMotionNative - Setting up native bridge listener");
|
|
210
|
-
const e =
|
|
211
|
-
const
|
|
212
|
-
let
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
gravity: { x:
|
|
216
|
-
acceleration: { x:
|
|
210
|
+
const e = U.addMotionListener((t) => {
|
|
211
|
+
const i = b(), o = t.gravity?.x ?? 0, r = t.gravity?.y ?? 0, l = t.gravity?.z ?? 0, c = t.userAcceleration?.x ?? 0, d = t.userAcceleration?.y ?? 0, m = t.userAcceleration?.z ?? 0, [p, u] = E(o, r, i), [f, v] = E(c, d, i), g = t.attitude && typeof t.attitude.yaw == "number" && typeof t.attitude.pitch == "number" && typeof t.attitude.roll == "number";
|
|
212
|
+
let w = 0;
|
|
213
|
+
g && (w = t.attitude.yaw * (180 / Math.PI), w < 0 && (w += 360));
|
|
214
|
+
const P = {
|
|
215
|
+
gravity: { x: p, y: u, z: l },
|
|
216
|
+
acceleration: { x: f, y: v, z: m },
|
|
217
217
|
accelerationIncludingGravity: {
|
|
218
|
-
x:
|
|
219
|
-
y:
|
|
220
|
-
z:
|
|
218
|
+
x: p + f,
|
|
219
|
+
y: u + v,
|
|
220
|
+
z: l + m
|
|
221
221
|
},
|
|
222
222
|
rotation: {
|
|
223
|
-
alpha:
|
|
223
|
+
alpha: g ? w : (t.rotationRate?.z ?? 0) * (180 / Math.PI),
|
|
224
224
|
beta: (t.rotationRate?.x ?? 0) * (180 / Math.PI),
|
|
225
225
|
gamma: (t.rotationRate?.y ?? 0) * (180 / Math.PI)
|
|
226
226
|
},
|
|
227
|
-
attitude:
|
|
228
|
-
yaw:
|
|
227
|
+
attitude: g ? {
|
|
228
|
+
yaw: w,
|
|
229
229
|
pitch: t.attitude.pitch * (180 / Math.PI),
|
|
230
230
|
roll: t.attitude.roll * (180 / Math.PI),
|
|
231
231
|
quaternion: t.attitude.quaternion ? {
|
|
@@ -237,12 +237,12 @@ function F(n) {
|
|
|
237
237
|
} : void 0,
|
|
238
238
|
timestamp: Date.now()
|
|
239
239
|
};
|
|
240
|
-
n(
|
|
240
|
+
n(P);
|
|
241
241
|
});
|
|
242
242
|
return console.log("✅ [Aippy Sensors] watchMotionNative - Listener setup complete"), e;
|
|
243
243
|
}
|
|
244
|
-
async function
|
|
245
|
-
if (!
|
|
244
|
+
async function q() {
|
|
245
|
+
if (!A())
|
|
246
246
|
return console.warn("[Aippy Sensors] Device motion not supported"), !1;
|
|
247
247
|
if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function")
|
|
248
248
|
try {
|
|
@@ -254,82 +254,82 @@ async function _() {
|
|
|
254
254
|
}
|
|
255
255
|
return !0;
|
|
256
256
|
}
|
|
257
|
-
function
|
|
258
|
-
if (!
|
|
259
|
-
throw
|
|
260
|
-
let t = !1,
|
|
261
|
-
const
|
|
257
|
+
function I(n, e = !0) {
|
|
258
|
+
if (!A())
|
|
259
|
+
throw a("Device motion API is not supported", s.NOT_SUPPORTED);
|
|
260
|
+
let t = !1, i = null;
|
|
261
|
+
const o = (c) => {
|
|
262
262
|
if (!t) return;
|
|
263
|
-
const d =
|
|
264
|
-
let
|
|
265
|
-
if (
|
|
266
|
-
const
|
|
267
|
-
|
|
263
|
+
const d = b();
|
|
264
|
+
let m, p, u;
|
|
265
|
+
if (c.acceleration) {
|
|
266
|
+
const h = c.accelerationIncludingGravity, y = c.acceleration;
|
|
267
|
+
m = (h?.x ?? 0) - (y?.x ?? 0), p = (h?.y ?? 0) - (y?.y ?? 0), u = (h?.z ?? 0) - (y?.z ?? 0);
|
|
268
268
|
} else {
|
|
269
|
-
const
|
|
270
|
-
|
|
269
|
+
const h = c.accelerationIncludingGravity, y = 9.8;
|
|
270
|
+
m = (h?.x ?? 0) / y, p = (h?.y ?? 0) / y, u = (h?.z ?? 0) / y;
|
|
271
271
|
}
|
|
272
|
-
const
|
|
273
|
-
gravity: { x:
|
|
274
|
-
acceleration: { x: O, y: S, z:
|
|
272
|
+
const f = c.acceleration?.x ?? 0, v = c.acceleration?.y ?? 0, g = c.acceleration?.z ?? 0, [w, P] = E(m, p, d), [O, S] = E(f, v, d), R = {
|
|
273
|
+
gravity: { x: w, y: P, z: u },
|
|
274
|
+
acceleration: { x: O, y: S, z: g },
|
|
275
275
|
accelerationIncludingGravity: {
|
|
276
|
-
x:
|
|
277
|
-
y:
|
|
278
|
-
z:
|
|
276
|
+
x: w + O,
|
|
277
|
+
y: P + S,
|
|
278
|
+
z: u + g
|
|
279
279
|
},
|
|
280
280
|
rotation: {
|
|
281
|
-
alpha:
|
|
282
|
-
beta:
|
|
283
|
-
gamma:
|
|
281
|
+
alpha: c.rotationRate?.alpha ?? 0,
|
|
282
|
+
beta: c.rotationRate?.beta ?? 0,
|
|
283
|
+
gamma: c.rotationRate?.gamma ?? 0
|
|
284
284
|
},
|
|
285
285
|
timestamp: Date.now()
|
|
286
286
|
};
|
|
287
|
-
n(
|
|
287
|
+
n(R);
|
|
288
288
|
}, r = async () => {
|
|
289
|
-
e && !await
|
|
289
|
+
e && !await q() || (t = !0, window.addEventListener("devicemotion", o));
|
|
290
290
|
};
|
|
291
291
|
return (async () => {
|
|
292
292
|
if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && e) {
|
|
293
293
|
const d = async () => {
|
|
294
|
-
|
|
294
|
+
i = null, await r();
|
|
295
295
|
};
|
|
296
|
-
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 }), i = () => {
|
|
297
297
|
window.removeEventListener("click", d), window.removeEventListener("touchstart", d);
|
|
298
298
|
};
|
|
299
299
|
} else
|
|
300
300
|
await r();
|
|
301
301
|
})(), () => {
|
|
302
|
-
t = !1, window.removeEventListener("devicemotion",
|
|
302
|
+
t = !1, window.removeEventListener("devicemotion", o), i && (i(), i = null);
|
|
303
303
|
};
|
|
304
304
|
}
|
|
305
|
-
function
|
|
306
|
-
let
|
|
307
|
-
const r =
|
|
308
|
-
|
|
309
|
-
}),
|
|
310
|
-
if (!
|
|
305
|
+
function z(n, e, t = 500) {
|
|
306
|
+
let i = !1, o = null;
|
|
307
|
+
const r = x((c) => {
|
|
308
|
+
i || (i = !0, clearTimeout(l)), n(c);
|
|
309
|
+
}), l = setTimeout(async () => {
|
|
310
|
+
if (!i) {
|
|
311
311
|
if (console.warn("[Aippy Sensors] No native data, falling back to Web API"), r(), typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && e)
|
|
312
312
|
try {
|
|
313
313
|
if (console.log("[Aippy Sensors] Trying direct permission request..."), await DeviceMotionEvent.requestPermission() === "granted") {
|
|
314
|
-
console.log("[Aippy Sensors] Permission granted via fallback"),
|
|
314
|
+
console.log("[Aippy Sensors] Permission granted via fallback"), o = I(n, !1);
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
317
|
} catch {
|
|
318
318
|
console.log("[Aippy Sensors] Direct permission failed, waiting for user interaction");
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
o = I(n, e);
|
|
321
321
|
}
|
|
322
322
|
}, t);
|
|
323
323
|
return () => {
|
|
324
|
-
clearTimeout(
|
|
324
|
+
clearTimeout(l), r(), o?.();
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
|
-
function
|
|
328
|
-
return
|
|
327
|
+
function Z(n, e = !0) {
|
|
328
|
+
return D() ? z(n, e) : I(n, e);
|
|
329
329
|
}
|
|
330
|
-
function
|
|
331
|
-
if (!
|
|
332
|
-
throw
|
|
330
|
+
function j(n) {
|
|
331
|
+
if (!T())
|
|
332
|
+
throw a("Device orientation API is not supported", s.NOT_SUPPORTED);
|
|
333
333
|
const e = (t) => {
|
|
334
334
|
n({
|
|
335
335
|
alpha: t.alpha ?? 0,
|
|
@@ -342,39 +342,39 @@ function $(n) {
|
|
|
342
342
|
window.removeEventListener("deviceorientation", e);
|
|
343
343
|
};
|
|
344
344
|
}
|
|
345
|
-
class
|
|
345
|
+
class G {
|
|
346
346
|
isOrientationSupported() {
|
|
347
|
-
return
|
|
347
|
+
return T();
|
|
348
348
|
}
|
|
349
349
|
isMotionSupported() {
|
|
350
|
-
return
|
|
350
|
+
return A();
|
|
351
351
|
}
|
|
352
352
|
async getOrientation() {
|
|
353
353
|
if (!this.isOrientationSupported())
|
|
354
|
-
throw
|
|
354
|
+
throw a("Device orientation API is not supported", s.NOT_SUPPORTED);
|
|
355
355
|
return new Promise((e, t) => {
|
|
356
|
-
const
|
|
357
|
-
window.removeEventListener("deviceorientation",
|
|
358
|
-
x:
|
|
359
|
-
y:
|
|
360
|
-
z:
|
|
356
|
+
const i = (o) => {
|
|
357
|
+
window.removeEventListener("deviceorientation", i), e({
|
|
358
|
+
x: o.alpha ?? 0,
|
|
359
|
+
y: o.beta ?? 0,
|
|
360
|
+
z: o.gamma ?? 0,
|
|
361
361
|
timestamp: Date.now()
|
|
362
362
|
});
|
|
363
363
|
};
|
|
364
|
-
window.addEventListener("deviceorientation",
|
|
365
|
-
window.removeEventListener("deviceorientation",
|
|
364
|
+
window.addEventListener("deviceorientation", i), setTimeout(() => {
|
|
365
|
+
window.removeEventListener("deviceorientation", i), t(a("Device orientation timeout", s.TIMEOUT));
|
|
366
366
|
}, 5e3);
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
369
|
/** @deprecated Use watchOrientation() instead */
|
|
370
370
|
watchOrientation(e) {
|
|
371
371
|
if (!this.isOrientationSupported())
|
|
372
|
-
throw
|
|
373
|
-
const t = (
|
|
372
|
+
throw a("Device orientation API is not supported", s.NOT_SUPPORTED);
|
|
373
|
+
const t = (i) => {
|
|
374
374
|
e({
|
|
375
|
-
x:
|
|
376
|
-
y:
|
|
377
|
-
z:
|
|
375
|
+
x: i.alpha ?? 0,
|
|
376
|
+
y: i.beta ?? 0,
|
|
377
|
+
z: i.gamma ?? 0,
|
|
378
378
|
timestamp: Date.now()
|
|
379
379
|
});
|
|
380
380
|
};
|
|
@@ -384,30 +384,30 @@ class z {
|
|
|
384
384
|
}
|
|
385
385
|
async getMotion() {
|
|
386
386
|
if (!this.isMotionSupported())
|
|
387
|
-
throw
|
|
387
|
+
throw a("Device motion API is not supported", s.NOT_SUPPORTED);
|
|
388
388
|
return new Promise((e, t) => {
|
|
389
|
-
const
|
|
390
|
-
window.removeEventListener("devicemotion",
|
|
391
|
-
x:
|
|
392
|
-
y:
|
|
393
|
-
z:
|
|
389
|
+
const i = (o) => {
|
|
390
|
+
window.removeEventListener("devicemotion", i), e({
|
|
391
|
+
x: o.acceleration?.x ?? 0,
|
|
392
|
+
y: o.acceleration?.y ?? 0,
|
|
393
|
+
z: o.acceleration?.z ?? 0,
|
|
394
394
|
timestamp: Date.now()
|
|
395
395
|
});
|
|
396
396
|
};
|
|
397
|
-
window.addEventListener("devicemotion",
|
|
398
|
-
window.removeEventListener("devicemotion",
|
|
397
|
+
window.addEventListener("devicemotion", i), setTimeout(() => {
|
|
398
|
+
window.removeEventListener("devicemotion", i), t(a("Device motion timeout", s.TIMEOUT));
|
|
399
399
|
}, 5e3);
|
|
400
400
|
});
|
|
401
401
|
}
|
|
402
402
|
/** @deprecated Use watchMotion() instead */
|
|
403
403
|
watchMotion(e) {
|
|
404
404
|
if (!this.isMotionSupported())
|
|
405
|
-
throw
|
|
406
|
-
const t = (
|
|
405
|
+
throw a("Device motion API is not supported", s.NOT_SUPPORTED);
|
|
406
|
+
const t = (i) => {
|
|
407
407
|
e({
|
|
408
|
-
x:
|
|
409
|
-
y:
|
|
410
|
-
z:
|
|
408
|
+
x: i.acceleration?.x ?? 0,
|
|
409
|
+
y: i.acceleration?.y ?? 0,
|
|
410
|
+
z: i.acceleration?.z ?? 0,
|
|
411
411
|
timestamp: Date.now()
|
|
412
412
|
});
|
|
413
413
|
};
|
|
@@ -416,11 +416,11 @@ class z {
|
|
|
416
416
|
};
|
|
417
417
|
}
|
|
418
418
|
async requestPermission() {
|
|
419
|
-
return
|
|
419
|
+
return _();
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
const
|
|
423
|
-
class
|
|
422
|
+
const V = new G();
|
|
423
|
+
class C {
|
|
424
424
|
/**
|
|
425
425
|
* Check if file system access is supported
|
|
426
426
|
*/
|
|
@@ -438,7 +438,7 @@ class G {
|
|
|
438
438
|
*/
|
|
439
439
|
async openFilePicker(e = {}) {
|
|
440
440
|
if (!this.isSupported())
|
|
441
|
-
throw
|
|
441
|
+
throw a("File System Access API is not supported", s.NOT_SUPPORTED);
|
|
442
442
|
try {
|
|
443
443
|
const t = {
|
|
444
444
|
types: e.accept ? [{
|
|
@@ -448,17 +448,17 @@ class G {
|
|
|
448
448
|
)
|
|
449
449
|
}] : void 0,
|
|
450
450
|
multiple: e.multiple ?? !1
|
|
451
|
-
},
|
|
452
|
-
|
|
451
|
+
}, i = await window.showOpenFilePicker(t), o = await Promise.all(
|
|
452
|
+
i.map(async (r) => r.getFile())
|
|
453
453
|
);
|
|
454
454
|
return {
|
|
455
|
-
files:
|
|
456
|
-
paths:
|
|
455
|
+
files: o,
|
|
456
|
+
paths: o.map((r) => r.name)
|
|
457
457
|
};
|
|
458
458
|
} catch (t) {
|
|
459
|
-
throw t instanceof Error && t.name === "AbortError" ?
|
|
459
|
+
throw t instanceof Error && t.name === "AbortError" ? a("File picker was cancelled", s.PERMISSION_DENIED) : a(
|
|
460
460
|
`Failed to open file picker: ${t instanceof Error ? t.message : "Unknown error"}`,
|
|
461
|
-
|
|
461
|
+
s.PERMISSION_DENIED
|
|
462
462
|
);
|
|
463
463
|
}
|
|
464
464
|
}
|
|
@@ -467,18 +467,18 @@ class G {
|
|
|
467
467
|
*/
|
|
468
468
|
async openFilePickerLegacy(e = {}) {
|
|
469
469
|
if (!this.isLegacySupported())
|
|
470
|
-
throw
|
|
471
|
-
return new Promise((t,
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
const
|
|
470
|
+
throw a("File input is not supported", s.NOT_SUPPORTED);
|
|
471
|
+
return new Promise((t, i) => {
|
|
472
|
+
const o = document.createElement("input");
|
|
473
|
+
o.type = "file", o.multiple = e.multiple ?? !1, o.accept = e.accept?.join(",") ?? "", o.onchange = (r) => {
|
|
474
|
+
const l = r.target, c = Array.from(l.files || []);
|
|
475
475
|
t({
|
|
476
|
-
files:
|
|
477
|
-
paths:
|
|
476
|
+
files: c,
|
|
477
|
+
paths: c.map((d) => d.name)
|
|
478
478
|
});
|
|
479
|
-
},
|
|
480
|
-
|
|
481
|
-
},
|
|
479
|
+
}, o.oncancel = () => {
|
|
480
|
+
i(a("File picker was cancelled", s.PERMISSION_DENIED));
|
|
481
|
+
}, o.click();
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
484
|
/**
|
|
@@ -492,12 +492,12 @@ class G {
|
|
|
492
492
|
*/
|
|
493
493
|
async saveFile(e, t) {
|
|
494
494
|
try {
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
} catch (
|
|
498
|
-
throw
|
|
499
|
-
`Failed to save file: ${
|
|
500
|
-
|
|
495
|
+
const i = URL.createObjectURL(e), o = document.createElement("a");
|
|
496
|
+
o.href = i, o.download = t, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(i);
|
|
497
|
+
} catch (i) {
|
|
498
|
+
throw a(
|
|
499
|
+
`Failed to save file: ${i instanceof Error ? i.message : "Unknown error"}`,
|
|
500
|
+
s.OPERATION_FAILED
|
|
501
501
|
);
|
|
502
502
|
}
|
|
503
503
|
}
|
|
@@ -505,23 +505,23 @@ class G {
|
|
|
505
505
|
* Read file as text
|
|
506
506
|
*/
|
|
507
507
|
async readAsText(e) {
|
|
508
|
-
return new Promise((t,
|
|
509
|
-
const
|
|
510
|
-
|
|
508
|
+
return new Promise((t, i) => {
|
|
509
|
+
const o = new FileReader();
|
|
510
|
+
o.onload = () => t(o.result), o.onerror = () => i(a("Failed to read file", s.OPERATION_FAILED)), o.readAsText(e);
|
|
511
511
|
});
|
|
512
512
|
}
|
|
513
513
|
/**
|
|
514
514
|
* Read file as data URL
|
|
515
515
|
*/
|
|
516
516
|
async readAsDataURL(e) {
|
|
517
|
-
return new Promise((t,
|
|
518
|
-
const
|
|
519
|
-
|
|
517
|
+
return new Promise((t, i) => {
|
|
518
|
+
const o = new FileReader();
|
|
519
|
+
o.onload = () => t(o.result), o.onerror = () => i(a("Failed to read file", s.OPERATION_FAILED)), o.readAsDataURL(e);
|
|
520
520
|
});
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
|
-
const
|
|
524
|
-
function
|
|
523
|
+
const K = new C();
|
|
524
|
+
function J(n) {
|
|
525
525
|
return new Promise((e) => {
|
|
526
526
|
if ("vibrate" in navigator)
|
|
527
527
|
navigator.vibrate(n), e();
|
|
@@ -536,19 +536,19 @@ function V(n) {
|
|
|
536
536
|
});
|
|
537
537
|
}
|
|
538
538
|
export {
|
|
539
|
-
|
|
540
|
-
|
|
539
|
+
F as CameraAPI,
|
|
540
|
+
C as FileSystemAPI,
|
|
541
541
|
k as GeolocationAPI,
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
542
|
+
G as SensorsAPI,
|
|
543
|
+
$ as camera,
|
|
544
|
+
K as fileSystem,
|
|
545
|
+
B as geolocation,
|
|
546
|
+
D as hasNativeBridge,
|
|
547
|
+
A as isMotionSupported,
|
|
548
|
+
T as isOrientationSupported,
|
|
549
|
+
_ as requestMotionPermission,
|
|
550
|
+
V as sensors,
|
|
551
|
+
J as vibrate,
|
|
552
|
+
Z as watchMotion,
|
|
553
|
+
j as watchOrientation
|
|
554
554
|
};
|