@aippy/runtime 0.2.3-dev.1 → 0.2.4-dev.3
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/audio/index.d.ts +2 -1
- package/dist/audio/index.js +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +23 -19
- package/dist/core/runtime.d.ts +71 -0
- package/dist/device/index.js +316 -183
- package/dist/device/sensors.d.ts +39 -3
- package/dist/device/types.d.ts +38 -0
- package/dist/index/index.js +50 -40
- package/dist/runtime-DOnodF_1.js +165 -0
- package/dist/{useAudioContext-BKgy28A1.js → useAudioContext-CNQQSTab.js} +2 -2
- package/package.json +1 -1
- package/dist/errors-CDEBaBxB.js +0 -26
package/dist/audio/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { patchAudioContext } from './patchAudioContext';
|
|
10
10
|
export type { AudioContextPatchOptions, AutoPauseOptions, MediaElementType, PatchedAudioContext, } from './types';
|
|
11
|
-
export { createHiddenMediaElement, createHiddenVideoElement,
|
|
11
|
+
export { createHiddenMediaElement, createHiddenVideoElement, isMediaStreamAudioSupported, } from './utils';
|
|
12
12
|
export { useAudioContext } from './useAudioContext';
|
|
13
13
|
export type { UseAudioContextOptions, UseAudioContextReturn } from './useAudioContext';
|
|
14
|
+
export { isIOSDevice } from './utils';
|
package/dist/audio/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as i, a as t,
|
|
1
|
+
import { c as i, a as t, b as d, i as o, p as s, u as n } from "../useAudioContext-CNQQSTab.js";
|
|
2
2
|
export {
|
|
3
3
|
i as createHiddenMediaElement,
|
|
4
4
|
t as createHiddenVideoElement,
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -1,45 +1,49 @@
|
|
|
1
|
-
import { A as f, E as
|
|
2
|
-
const
|
|
1
|
+
import { a as d, A as f, C as u, E as A, R as _, b as m, c as R } from "../runtime-DOnodF_1.js";
|
|
2
|
+
const s = {
|
|
3
3
|
mode: "development",
|
|
4
4
|
debug: !1,
|
|
5
5
|
apiBaseUrl: void 0,
|
|
6
6
|
headers: {}
|
|
7
7
|
};
|
|
8
|
-
function
|
|
8
|
+
function o() {
|
|
9
9
|
const e = {};
|
|
10
10
|
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
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const n =
|
|
12
|
+
function c(e) {
|
|
13
|
+
const n = o();
|
|
14
14
|
return {
|
|
15
|
-
...
|
|
15
|
+
...s,
|
|
16
16
|
...n,
|
|
17
17
|
...e,
|
|
18
18
|
headers: {
|
|
19
|
-
...
|
|
19
|
+
...s.headers,
|
|
20
20
|
...n.headers,
|
|
21
21
|
...e?.headers
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
version:
|
|
27
|
-
},
|
|
25
|
+
const r = "0.2.4-dev.3", i = {
|
|
26
|
+
version: r
|
|
27
|
+
}, a = i.version, t = "@aippy/runtime";
|
|
28
28
|
function p() {
|
|
29
29
|
return {
|
|
30
|
-
name:
|
|
31
|
-
version:
|
|
30
|
+
name: t,
|
|
31
|
+
version: a,
|
|
32
32
|
buildTime: (/* @__PURE__ */ new Date()).toISOString()
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
export {
|
|
36
|
+
d as AippyRuntime,
|
|
36
37
|
f as AippyRuntimeError,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
u as Cancellable,
|
|
39
|
+
s as DEFAULT_CONFIG,
|
|
40
|
+
A as ERROR_CODES,
|
|
41
|
+
_ as ReceiveChannel,
|
|
42
|
+
t as SDK_NAME,
|
|
43
|
+
a as VERSION,
|
|
44
|
+
m as aippyRuntime,
|
|
45
|
+
R as createError,
|
|
46
|
+
o as getConfigFromEnv,
|
|
43
47
|
p as getVersionInfo,
|
|
44
|
-
|
|
48
|
+
c as mergeConfig
|
|
45
49
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aippy Runtime - Unified runtime for native bridge communication
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Cancellable class - For managing subscriptions
|
|
6
|
+
*/
|
|
7
|
+
export declare class Cancellable {
|
|
8
|
+
private cancelFn?;
|
|
9
|
+
private cancelled;
|
|
10
|
+
constructor(cancelFn?: (() => void) | undefined);
|
|
11
|
+
cancel(): void;
|
|
12
|
+
get isCancelled(): boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* ReceiveChannel - Manages message receiving and subscription
|
|
16
|
+
*/
|
|
17
|
+
export declare class ReceiveChannel {
|
|
18
|
+
private emitter;
|
|
19
|
+
/**
|
|
20
|
+
* Emit a message to subscribers
|
|
21
|
+
*/
|
|
22
|
+
emit(message: {
|
|
23
|
+
endpoint: string;
|
|
24
|
+
payload: any;
|
|
25
|
+
}): void;
|
|
26
|
+
/**
|
|
27
|
+
* Subscribe to messages on a specific endpoint
|
|
28
|
+
*/
|
|
29
|
+
subscribe(endpoint: string, callback: (payload: any) => void): Cancellable;
|
|
30
|
+
/**
|
|
31
|
+
* Subscribe to a single message (auto-unsubscribe after first message)
|
|
32
|
+
*/
|
|
33
|
+
once(endpoint: string, callback: (payload: any) => void): Cancellable;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* AippyRuntime - Main runtime class for native bridge communication
|
|
37
|
+
*/
|
|
38
|
+
export declare class AippyRuntime {
|
|
39
|
+
receiveChannel: ReceiveChannel;
|
|
40
|
+
private seq;
|
|
41
|
+
/**
|
|
42
|
+
* Receive message from native layer
|
|
43
|
+
* Called by native code via: window.aippyRuntime.receiveMessage(message)
|
|
44
|
+
*/
|
|
45
|
+
receiveMessage(message: {
|
|
46
|
+
endpoint: string;
|
|
47
|
+
payload: any;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Create a subscription to native events
|
|
51
|
+
* @param handler - WebKit message handler (e.g., deviceMotionHandler)
|
|
52
|
+
* @param subscribePayload - Subscription parameters (e.g., { type: "motion" })
|
|
53
|
+
* @param callback - Callback to handle received data
|
|
54
|
+
* @returns Cancellable subscription
|
|
55
|
+
*/
|
|
56
|
+
createSubscription(handler: any, subscribePayload: any, callback: (data: any) => void): Cancellable;
|
|
57
|
+
/**
|
|
58
|
+
* Make a subscription message with unique endpoint
|
|
59
|
+
*/
|
|
60
|
+
private makeSubscriptionMessage;
|
|
61
|
+
/**
|
|
62
|
+
* Add motion listener (convenience method)
|
|
63
|
+
* @param callback - Callback to handle motion data
|
|
64
|
+
* @returns Cleanup function
|
|
65
|
+
*/
|
|
66
|
+
addMotionListener(callback: (data: any) => void): () => void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Global runtime instance - Singleton pattern
|
|
70
|
+
*/
|
|
71
|
+
export declare const aippyRuntime: AippyRuntime;
|
package/dist/device/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { c as a } from "../
|
|
5
|
-
class
|
|
1
|
+
var v = Object.defineProperty;
|
|
2
|
+
var f = (c, t, e) => t in c ? v(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
|
|
3
|
+
var p = (c, t, e) => f(c, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { c as a, b as E } from "../runtime-DOnodF_1.js";
|
|
5
|
+
class P {
|
|
6
6
|
constructor() {
|
|
7
|
-
|
|
7
|
+
p(this, "stream", null);
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Check if camera is supported
|
|
@@ -15,21 +15,21 @@ class g {
|
|
|
15
15
|
/**
|
|
16
16
|
* Get camera stream
|
|
17
17
|
*/
|
|
18
|
-
async getStream(
|
|
18
|
+
async getStream(t = {}) {
|
|
19
19
|
if (!this.isSupported())
|
|
20
20
|
throw a("Camera API is not supported", "NOT_SUPPORTED");
|
|
21
21
|
try {
|
|
22
|
-
const
|
|
22
|
+
const e = {
|
|
23
23
|
video: {
|
|
24
|
-
width:
|
|
25
|
-
height:
|
|
26
|
-
facingMode:
|
|
24
|
+
width: t.width,
|
|
25
|
+
height: t.height,
|
|
26
|
+
facingMode: t.facingMode || "environment"
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
return this.stream = await navigator.mediaDevices.getUserMedia(
|
|
30
|
-
} catch (
|
|
29
|
+
return this.stream = await navigator.mediaDevices.getUserMedia(e), this.stream;
|
|
30
|
+
} catch (e) {
|
|
31
31
|
throw a(
|
|
32
|
-
`Failed to access camera: ${
|
|
32
|
+
`Failed to access camera: ${e instanceof Error ? e.message : "Unknown error"}`,
|
|
33
33
|
"PERMISSION_DENIED"
|
|
34
34
|
);
|
|
35
35
|
}
|
|
@@ -37,30 +37,30 @@ class g {
|
|
|
37
37
|
/**
|
|
38
38
|
* Capture photo from stream
|
|
39
39
|
*/
|
|
40
|
-
async capturePhoto(
|
|
40
|
+
async capturePhoto(t = {}) {
|
|
41
41
|
if (!this.stream)
|
|
42
42
|
throw a("No camera stream available", "NOT_SUPPORTED");
|
|
43
43
|
try {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
44
|
+
const e = document.createElement("video");
|
|
45
|
+
e.srcObject = this.stream, e.play();
|
|
46
|
+
const i = document.createElement("canvas"), o = i.getContext("2d");
|
|
47
|
+
if (!o)
|
|
48
48
|
throw a("Failed to get canvas context", "UNKNOWN_ERROR");
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, `image/${
|
|
54
|
-
}),
|
|
49
|
+
i.width = t.width || e.videoWidth, i.height = t.height || e.videoHeight, o.drawImage(e, 0, 0, i.width, i.height);
|
|
50
|
+
const n = t.format || "jpeg", d = t.quality === "high" ? 0.9 : t.quality === "medium" ? 0.7 : 0.5, r = await new Promise((l, u) => {
|
|
51
|
+
i.toBlob((w) => {
|
|
52
|
+
w ? l(w) : u(new Error("Failed to create blob"));
|
|
53
|
+
}, `image/${n}`, d);
|
|
54
|
+
}), s = i.toDataURL(`image/${n}`, d);
|
|
55
55
|
return {
|
|
56
|
-
blob:
|
|
57
|
-
dataUrl:
|
|
58
|
-
width:
|
|
59
|
-
height:
|
|
56
|
+
blob: r,
|
|
57
|
+
dataUrl: s,
|
|
58
|
+
width: i.width,
|
|
59
|
+
height: i.height
|
|
60
60
|
};
|
|
61
|
-
} catch (
|
|
61
|
+
} catch (e) {
|
|
62
62
|
throw a(
|
|
63
|
-
`Failed to capture photo: ${
|
|
63
|
+
`Failed to capture photo: ${e instanceof Error ? e.message : "Unknown error"}`,
|
|
64
64
|
"UNKNOWN_ERROR"
|
|
65
65
|
);
|
|
66
66
|
}
|
|
@@ -69,11 +69,11 @@ class g {
|
|
|
69
69
|
* Stop camera stream
|
|
70
70
|
*/
|
|
71
71
|
stopStream() {
|
|
72
|
-
this.stream && (this.stream.getTracks().forEach((
|
|
72
|
+
this.stream && (this.stream.getTracks().forEach((t) => t.stop()), this.stream = null);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
const
|
|
76
|
-
class
|
|
75
|
+
const D = new P();
|
|
76
|
+
class O {
|
|
77
77
|
/**
|
|
78
78
|
* Check if geolocation is supported
|
|
79
79
|
*/
|
|
@@ -83,99 +83,230 @@ class v {
|
|
|
83
83
|
/**
|
|
84
84
|
* Get current position
|
|
85
85
|
*/
|
|
86
|
-
async getCurrentPosition(
|
|
86
|
+
async getCurrentPosition(t = {}) {
|
|
87
87
|
if (!this.isSupported())
|
|
88
88
|
throw a("Geolocation API is not supported", "NOT_SUPPORTED");
|
|
89
|
-
return new Promise((
|
|
90
|
-
const
|
|
91
|
-
enableHighAccuracy:
|
|
92
|
-
timeout:
|
|
93
|
-
maximumAge:
|
|
89
|
+
return new Promise((e, i) => {
|
|
90
|
+
const o = {
|
|
91
|
+
enableHighAccuracy: t.enableHighAccuracy ?? !0,
|
|
92
|
+
timeout: t.timeout ?? 1e4,
|
|
93
|
+
maximumAge: t.maximumAge ?? 6e4
|
|
94
94
|
};
|
|
95
95
|
navigator.geolocation.getCurrentPosition(
|
|
96
|
-
(
|
|
97
|
-
const
|
|
98
|
-
latitude:
|
|
99
|
-
longitude:
|
|
100
|
-
accuracy:
|
|
101
|
-
altitude:
|
|
102
|
-
altitudeAccuracy:
|
|
103
|
-
heading:
|
|
104
|
-
speed:
|
|
105
|
-
timestamp:
|
|
96
|
+
(n) => {
|
|
97
|
+
const d = {
|
|
98
|
+
latitude: n.coords.latitude,
|
|
99
|
+
longitude: n.coords.longitude,
|
|
100
|
+
accuracy: n.coords.accuracy,
|
|
101
|
+
altitude: n.coords.altitude ?? void 0,
|
|
102
|
+
altitudeAccuracy: n.coords.altitudeAccuracy ?? void 0,
|
|
103
|
+
heading: n.coords.heading ?? void 0,
|
|
104
|
+
speed: n.coords.speed ?? void 0,
|
|
105
|
+
timestamp: n.timestamp
|
|
106
106
|
};
|
|
107
|
-
|
|
107
|
+
e(d);
|
|
108
108
|
},
|
|
109
|
-
(
|
|
110
|
-
let
|
|
111
|
-
switch (
|
|
112
|
-
case
|
|
113
|
-
|
|
109
|
+
(n) => {
|
|
110
|
+
let d = "UNKNOWN_ERROR", r = "Unknown geolocation error";
|
|
111
|
+
switch (n.code) {
|
|
112
|
+
case n.PERMISSION_DENIED:
|
|
113
|
+
d = "PERMISSION_DENIED", r = "Geolocation permission denied";
|
|
114
114
|
break;
|
|
115
|
-
case
|
|
116
|
-
|
|
115
|
+
case n.POSITION_UNAVAILABLE:
|
|
116
|
+
r = "Position unavailable";
|
|
117
117
|
break;
|
|
118
|
-
case
|
|
119
|
-
|
|
118
|
+
case n.TIMEOUT:
|
|
119
|
+
r = "Geolocation timeout";
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
i(a(r, d));
|
|
123
123
|
},
|
|
124
|
-
|
|
124
|
+
o
|
|
125
125
|
);
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Watch position changes
|
|
130
130
|
*/
|
|
131
|
-
watchPosition(
|
|
131
|
+
watchPosition(t, e = {}) {
|
|
132
132
|
if (!this.isSupported())
|
|
133
133
|
throw a("Geolocation API is not supported", "NOT_SUPPORTED");
|
|
134
|
-
const
|
|
135
|
-
enableHighAccuracy:
|
|
136
|
-
timeout:
|
|
137
|
-
maximumAge:
|
|
134
|
+
const i = {
|
|
135
|
+
enableHighAccuracy: e.enableHighAccuracy ?? !0,
|
|
136
|
+
timeout: e.timeout ?? 1e4,
|
|
137
|
+
maximumAge: e.maximumAge ?? 6e4
|
|
138
138
|
};
|
|
139
139
|
return navigator.geolocation.watchPosition(
|
|
140
|
-
(
|
|
141
|
-
const
|
|
142
|
-
latitude:
|
|
143
|
-
longitude:
|
|
144
|
-
accuracy:
|
|
145
|
-
altitude:
|
|
146
|
-
altitudeAccuracy:
|
|
147
|
-
heading:
|
|
148
|
-
speed:
|
|
149
|
-
timestamp:
|
|
140
|
+
(o) => {
|
|
141
|
+
const n = {
|
|
142
|
+
latitude: o.coords.latitude,
|
|
143
|
+
longitude: o.coords.longitude,
|
|
144
|
+
accuracy: o.coords.accuracy,
|
|
145
|
+
altitude: o.coords.altitude ?? void 0,
|
|
146
|
+
altitudeAccuracy: o.coords.altitudeAccuracy ?? void 0,
|
|
147
|
+
heading: o.coords.heading ?? void 0,
|
|
148
|
+
speed: o.coords.speed ?? void 0,
|
|
149
|
+
timestamp: o.timestamp
|
|
150
150
|
};
|
|
151
|
-
|
|
151
|
+
t(n);
|
|
152
152
|
},
|
|
153
|
-
(
|
|
154
|
-
console.error("Geolocation watch error:",
|
|
153
|
+
(o) => {
|
|
154
|
+
console.error("Geolocation watch error:", o);
|
|
155
155
|
},
|
|
156
|
-
|
|
156
|
+
i
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* Clear position watch
|
|
161
161
|
*/
|
|
162
|
-
clearWatch(
|
|
163
|
-
navigator.geolocation.clearWatch(
|
|
162
|
+
clearWatch(t) {
|
|
163
|
+
navigator.geolocation.clearWatch(t);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
const
|
|
167
|
-
|
|
166
|
+
const A = new O();
|
|
167
|
+
function m() {
|
|
168
|
+
return "DeviceMotionEvent" in window;
|
|
169
|
+
}
|
|
170
|
+
function h() {
|
|
171
|
+
return "DeviceOrientationEvent" in window;
|
|
172
|
+
}
|
|
173
|
+
function g() {
|
|
174
|
+
return typeof window < "u" && !!window.webkit?.messageHandlers?.deviceMotionHandler;
|
|
175
|
+
}
|
|
176
|
+
async function y() {
|
|
177
|
+
if (g())
|
|
178
|
+
return !0;
|
|
179
|
+
if (!m())
|
|
180
|
+
return !1;
|
|
181
|
+
if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function")
|
|
182
|
+
try {
|
|
183
|
+
return await DeviceMotionEvent.requestPermission() === "granted";
|
|
184
|
+
} catch {
|
|
185
|
+
return !1;
|
|
186
|
+
}
|
|
187
|
+
return !0;
|
|
188
|
+
}
|
|
189
|
+
function R(c) {
|
|
190
|
+
return E.addMotionListener((e) => {
|
|
191
|
+
const i = {
|
|
192
|
+
gravity: {
|
|
193
|
+
x: e.gravity?.x ?? 0,
|
|
194
|
+
y: e.gravity?.y ?? 0,
|
|
195
|
+
z: e.gravity?.z ?? 0
|
|
196
|
+
},
|
|
197
|
+
acceleration: {
|
|
198
|
+
x: e.acceleration?.x ?? 0,
|
|
199
|
+
y: e.acceleration?.y ?? 0,
|
|
200
|
+
z: e.acceleration?.z ?? 0
|
|
201
|
+
},
|
|
202
|
+
accelerationIncludingGravity: {
|
|
203
|
+
x: (e.gravity?.x ?? 0) + (e.acceleration?.x ?? 0),
|
|
204
|
+
y: (e.gravity?.y ?? 0) + (e.acceleration?.y ?? 0),
|
|
205
|
+
z: (e.gravity?.z ?? 0) + (e.acceleration?.z ?? 0)
|
|
206
|
+
},
|
|
207
|
+
rotation: {
|
|
208
|
+
alpha: e.rotation?.alpha ?? 0,
|
|
209
|
+
beta: e.rotation?.beta ?? 0,
|
|
210
|
+
gamma: e.rotation?.gamma ?? 0
|
|
211
|
+
},
|
|
212
|
+
timestamp: Date.now()
|
|
213
|
+
};
|
|
214
|
+
c(i);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function N(c, t = !0) {
|
|
218
|
+
if (!m())
|
|
219
|
+
throw a("Device motion API is not supported", "NOT_SUPPORTED");
|
|
220
|
+
let e = !1, i = null;
|
|
221
|
+
const o = (r) => {
|
|
222
|
+
if (!e) return;
|
|
223
|
+
const s = {
|
|
224
|
+
gravity: {
|
|
225
|
+
x: r.acceleration?.x ?? 0,
|
|
226
|
+
y: r.acceleration?.y ?? 0,
|
|
227
|
+
z: r.acceleration?.z ?? 0
|
|
228
|
+
},
|
|
229
|
+
acceleration: {
|
|
230
|
+
x: r.acceleration?.x ?? 0,
|
|
231
|
+
y: r.acceleration?.y ?? 0,
|
|
232
|
+
z: r.acceleration?.z ?? 0
|
|
233
|
+
},
|
|
234
|
+
accelerationIncludingGravity: {
|
|
235
|
+
x: r.accelerationIncludingGravity?.x ?? 0,
|
|
236
|
+
y: r.accelerationIncludingGravity?.y ?? 0,
|
|
237
|
+
z: r.accelerationIncludingGravity?.z ?? 0
|
|
238
|
+
},
|
|
239
|
+
rotation: {
|
|
240
|
+
alpha: r.rotationRate?.alpha ?? 0,
|
|
241
|
+
beta: r.rotationRate?.beta ?? 0,
|
|
242
|
+
gamma: r.rotationRate?.gamma ?? 0
|
|
243
|
+
},
|
|
244
|
+
timestamp: Date.now()
|
|
245
|
+
};
|
|
246
|
+
if (r.acceleration) {
|
|
247
|
+
const l = r.accelerationIncludingGravity, u = r.acceleration;
|
|
248
|
+
s.gravity = {
|
|
249
|
+
x: (l?.x ?? 0) - (u?.x ?? 0),
|
|
250
|
+
y: (l?.y ?? 0) - (u?.y ?? 0),
|
|
251
|
+
z: (l?.z ?? 0) - (u?.z ?? 0)
|
|
252
|
+
};
|
|
253
|
+
} else {
|
|
254
|
+
const l = r.accelerationIncludingGravity, u = 9.8;
|
|
255
|
+
s.gravity = {
|
|
256
|
+
x: (l?.x ?? 0) / u,
|
|
257
|
+
y: (l?.y ?? 0) / u,
|
|
258
|
+
z: (l?.z ?? 0) / u
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
c(s);
|
|
262
|
+
}, n = async () => {
|
|
263
|
+
t && !await y() || (e = !0, window.addEventListener("devicemotion", o));
|
|
264
|
+
};
|
|
265
|
+
return (async () => {
|
|
266
|
+
if (typeof DeviceMotionEvent < "u" && typeof DeviceMotionEvent.requestPermission == "function" && t) {
|
|
267
|
+
const s = async () => {
|
|
268
|
+
i = null, await n();
|
|
269
|
+
};
|
|
270
|
+
window.addEventListener("click", s, { once: !0 }), window.addEventListener("touchstart", s, { once: !0 }), i = () => {
|
|
271
|
+
window.removeEventListener("click", s), window.removeEventListener("touchstart", s);
|
|
272
|
+
};
|
|
273
|
+
} else
|
|
274
|
+
await n();
|
|
275
|
+
})(), () => {
|
|
276
|
+
e = !1, window.removeEventListener("devicemotion", o), i && (i(), i = null);
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function x(c, t = !0) {
|
|
280
|
+
return g() ? R(c) : N(c, t);
|
|
281
|
+
}
|
|
282
|
+
function L(c) {
|
|
283
|
+
if (!h())
|
|
284
|
+
throw a("Device orientation API is not supported", "NOT_SUPPORTED");
|
|
285
|
+
const t = (e) => {
|
|
286
|
+
const i = {
|
|
287
|
+
alpha: e.alpha ?? 0,
|
|
288
|
+
beta: e.beta ?? 0,
|
|
289
|
+
gamma: e.gamma ?? 0,
|
|
290
|
+
timestamp: Date.now()
|
|
291
|
+
};
|
|
292
|
+
c(i);
|
|
293
|
+
};
|
|
294
|
+
return window.addEventListener("deviceorientation", t), () => {
|
|
295
|
+
window.removeEventListener("deviceorientation", t);
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
class S {
|
|
168
299
|
/**
|
|
169
300
|
* Check if device orientation is supported
|
|
170
301
|
*/
|
|
171
302
|
isOrientationSupported() {
|
|
172
|
-
return
|
|
303
|
+
return h();
|
|
173
304
|
}
|
|
174
305
|
/**
|
|
175
306
|
* Check if device motion is supported
|
|
176
307
|
*/
|
|
177
308
|
isMotionSupported() {
|
|
178
|
-
return
|
|
309
|
+
return m();
|
|
179
310
|
}
|
|
180
311
|
/**
|
|
181
312
|
* Get device orientation data
|
|
@@ -183,36 +314,37 @@ class E {
|
|
|
183
314
|
async getOrientation() {
|
|
184
315
|
if (!this.isOrientationSupported())
|
|
185
316
|
throw a("Device orientation API is not supported", "NOT_SUPPORTED");
|
|
186
|
-
return new Promise((
|
|
187
|
-
const
|
|
188
|
-
window.removeEventListener("deviceorientation",
|
|
189
|
-
x:
|
|
190
|
-
y:
|
|
191
|
-
z:
|
|
317
|
+
return new Promise((t, e) => {
|
|
318
|
+
const i = (o) => {
|
|
319
|
+
window.removeEventListener("deviceorientation", i), t({
|
|
320
|
+
x: o.alpha ?? 0,
|
|
321
|
+
y: o.beta ?? 0,
|
|
322
|
+
z: o.gamma ?? 0,
|
|
192
323
|
timestamp: Date.now()
|
|
193
324
|
});
|
|
194
325
|
};
|
|
195
|
-
window.addEventListener("deviceorientation",
|
|
196
|
-
window.removeEventListener("deviceorientation",
|
|
326
|
+
window.addEventListener("deviceorientation", i), setTimeout(() => {
|
|
327
|
+
window.removeEventListener("deviceorientation", i), e(a("Device orientation timeout", "UNKNOWN_ERROR"));
|
|
197
328
|
}, 5e3);
|
|
198
329
|
});
|
|
199
330
|
}
|
|
200
331
|
/**
|
|
201
332
|
* Watch device orientation changes
|
|
333
|
+
* @deprecated Use watchOrientation() function instead
|
|
202
334
|
*/
|
|
203
|
-
watchOrientation(
|
|
335
|
+
watchOrientation(t) {
|
|
204
336
|
if (!this.isOrientationSupported())
|
|
205
337
|
throw a("Device orientation API is not supported", "NOT_SUPPORTED");
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
x:
|
|
209
|
-
y:
|
|
210
|
-
z:
|
|
338
|
+
const e = (i) => {
|
|
339
|
+
t({
|
|
340
|
+
x: i.alpha ?? 0,
|
|
341
|
+
y: i.beta ?? 0,
|
|
342
|
+
z: i.gamma ?? 0,
|
|
211
343
|
timestamp: Date.now()
|
|
212
344
|
});
|
|
213
345
|
};
|
|
214
|
-
return window.addEventListener("deviceorientation",
|
|
215
|
-
window.removeEventListener("deviceorientation",
|
|
346
|
+
return window.addEventListener("deviceorientation", e), () => {
|
|
347
|
+
window.removeEventListener("deviceorientation", e);
|
|
216
348
|
};
|
|
217
349
|
}
|
|
218
350
|
/**
|
|
@@ -221,53 +353,48 @@ class E {
|
|
|
221
353
|
async getMotion() {
|
|
222
354
|
if (!this.isMotionSupported())
|
|
223
355
|
throw a("Device motion API is not supported", "NOT_SUPPORTED");
|
|
224
|
-
return new Promise((
|
|
225
|
-
const
|
|
226
|
-
window.removeEventListener("devicemotion",
|
|
227
|
-
x:
|
|
228
|
-
y:
|
|
229
|
-
z:
|
|
356
|
+
return new Promise((t, e) => {
|
|
357
|
+
const i = (o) => {
|
|
358
|
+
window.removeEventListener("devicemotion", i), t({
|
|
359
|
+
x: o.acceleration?.x ?? 0,
|
|
360
|
+
y: o.acceleration?.y ?? 0,
|
|
361
|
+
z: o.acceleration?.z ?? 0,
|
|
230
362
|
timestamp: Date.now()
|
|
231
363
|
});
|
|
232
364
|
};
|
|
233
|
-
window.addEventListener("devicemotion",
|
|
234
|
-
window.removeEventListener("devicemotion",
|
|
365
|
+
window.addEventListener("devicemotion", i), setTimeout(() => {
|
|
366
|
+
window.removeEventListener("devicemotion", i), e(a("Device motion timeout", "UNKNOWN_ERROR"));
|
|
235
367
|
}, 5e3);
|
|
236
368
|
});
|
|
237
369
|
}
|
|
238
370
|
/**
|
|
239
371
|
* Watch device motion changes
|
|
372
|
+
* @deprecated Use watchMotion() function instead
|
|
240
373
|
*/
|
|
241
|
-
watchMotion(
|
|
374
|
+
watchMotion(t) {
|
|
242
375
|
if (!this.isMotionSupported())
|
|
243
376
|
throw a("Device motion API is not supported", "NOT_SUPPORTED");
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
x:
|
|
247
|
-
y:
|
|
248
|
-
z:
|
|
377
|
+
const e = (i) => {
|
|
378
|
+
t({
|
|
379
|
+
x: i.acceleration?.x ?? 0,
|
|
380
|
+
y: i.acceleration?.y ?? 0,
|
|
381
|
+
z: i.acceleration?.z ?? 0,
|
|
249
382
|
timestamp: Date.now()
|
|
250
383
|
});
|
|
251
384
|
};
|
|
252
|
-
return window.addEventListener("devicemotion",
|
|
253
|
-
window.removeEventListener("devicemotion",
|
|
385
|
+
return window.addEventListener("devicemotion", e), () => {
|
|
386
|
+
window.removeEventListener("devicemotion", e);
|
|
254
387
|
};
|
|
255
388
|
}
|
|
256
389
|
/**
|
|
257
390
|
* Request permission for motion sensors (iOS 13+)
|
|
258
391
|
*/
|
|
259
392
|
async requestPermission() {
|
|
260
|
-
|
|
261
|
-
return !1;
|
|
262
|
-
try {
|
|
263
|
-
return (await navigator.permissions?.query({ name: "accelerometer" }))?.state === "granted";
|
|
264
|
-
} catch {
|
|
265
|
-
return !1;
|
|
266
|
-
}
|
|
393
|
+
return y();
|
|
267
394
|
}
|
|
268
395
|
}
|
|
269
|
-
const
|
|
270
|
-
class
|
|
396
|
+
const M = new S();
|
|
397
|
+
class I {
|
|
271
398
|
/**
|
|
272
399
|
* Check if file system access is supported
|
|
273
400
|
*/
|
|
@@ -283,28 +410,28 @@ class O {
|
|
|
283
410
|
/**
|
|
284
411
|
* Open file picker (modern API)
|
|
285
412
|
*/
|
|
286
|
-
async openFilePicker(
|
|
413
|
+
async openFilePicker(t = {}) {
|
|
287
414
|
if (!this.isSupported())
|
|
288
415
|
throw a("File System Access API is not supported", "NOT_SUPPORTED");
|
|
289
416
|
try {
|
|
290
|
-
const
|
|
291
|
-
types:
|
|
417
|
+
const e = {
|
|
418
|
+
types: t.accept ? [{
|
|
292
419
|
description: "Files",
|
|
293
420
|
accept: Object.fromEntries(
|
|
294
|
-
|
|
421
|
+
t.accept.map((n) => [n, [n]])
|
|
295
422
|
)
|
|
296
423
|
}] : void 0,
|
|
297
|
-
multiple:
|
|
298
|
-
},
|
|
299
|
-
|
|
424
|
+
multiple: t.multiple ?? !1
|
|
425
|
+
}, i = await window.showOpenFilePicker(e), o = await Promise.all(
|
|
426
|
+
i.map(async (n) => n.getFile())
|
|
300
427
|
);
|
|
301
428
|
return {
|
|
302
|
-
files:
|
|
303
|
-
paths:
|
|
429
|
+
files: o,
|
|
430
|
+
paths: o.map((n) => n.name)
|
|
304
431
|
};
|
|
305
|
-
} catch (
|
|
306
|
-
throw
|
|
307
|
-
`Failed to open file picker: ${
|
|
432
|
+
} catch (e) {
|
|
433
|
+
throw e instanceof Error && e.name === "AbortError" ? a("File picker was cancelled", "PERMISSION_DENIED") : a(
|
|
434
|
+
`Failed to open file picker: ${e instanceof Error ? e.message : "Unknown error"}`,
|
|
308
435
|
"PERMISSION_DENIED"
|
|
309
436
|
);
|
|
310
437
|
}
|
|
@@ -312,38 +439,38 @@ class O {
|
|
|
312
439
|
/**
|
|
313
440
|
* Open file picker (legacy fallback)
|
|
314
441
|
*/
|
|
315
|
-
async openFilePickerLegacy(
|
|
442
|
+
async openFilePickerLegacy(t = {}) {
|
|
316
443
|
if (!this.isLegacySupported())
|
|
317
444
|
throw a("File input is not supported", "NOT_SUPPORTED");
|
|
318
|
-
return new Promise((
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
files:
|
|
324
|
-
paths:
|
|
445
|
+
return new Promise((e, i) => {
|
|
446
|
+
const o = document.createElement("input");
|
|
447
|
+
o.type = "file", o.multiple = t.multiple ?? !1, o.accept = t.accept?.join(",") ?? "", o.onchange = (n) => {
|
|
448
|
+
const d = n.target, r = Array.from(d.files || []);
|
|
449
|
+
e({
|
|
450
|
+
files: r,
|
|
451
|
+
paths: r.map((s) => s.name)
|
|
325
452
|
});
|
|
326
|
-
},
|
|
327
|
-
|
|
328
|
-
},
|
|
453
|
+
}, o.oncancel = () => {
|
|
454
|
+
i(a("File picker was cancelled", "PERMISSION_DENIED"));
|
|
455
|
+
}, o.click();
|
|
329
456
|
});
|
|
330
457
|
}
|
|
331
458
|
/**
|
|
332
459
|
* Open file picker with fallback
|
|
333
460
|
*/
|
|
334
|
-
async openFile(
|
|
335
|
-
return this.isSupported() ? await this.openFilePicker(
|
|
461
|
+
async openFile(t = {}) {
|
|
462
|
+
return this.isSupported() ? await this.openFilePicker(t) : await this.openFilePickerLegacy(t);
|
|
336
463
|
}
|
|
337
464
|
/**
|
|
338
465
|
* Save file
|
|
339
466
|
*/
|
|
340
|
-
async saveFile(
|
|
467
|
+
async saveFile(t, e) {
|
|
341
468
|
try {
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
} catch (
|
|
469
|
+
const i = URL.createObjectURL(t), o = document.createElement("a");
|
|
470
|
+
o.href = i, o.download = e, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(i);
|
|
471
|
+
} catch (i) {
|
|
345
472
|
throw a(
|
|
346
|
-
`Failed to save file: ${
|
|
473
|
+
`Failed to save file: ${i instanceof Error ? i.message : "Unknown error"}`,
|
|
347
474
|
"UNKNOWN_ERROR"
|
|
348
475
|
);
|
|
349
476
|
}
|
|
@@ -351,45 +478,51 @@ class O {
|
|
|
351
478
|
/**
|
|
352
479
|
* Read file as text
|
|
353
480
|
*/
|
|
354
|
-
async readAsText(
|
|
355
|
-
return new Promise((
|
|
356
|
-
const
|
|
357
|
-
|
|
481
|
+
async readAsText(t) {
|
|
482
|
+
return new Promise((e, i) => {
|
|
483
|
+
const o = new FileReader();
|
|
484
|
+
o.onload = () => e(o.result), o.onerror = () => i(a("Failed to read file", "UNKNOWN_ERROR")), o.readAsText(t);
|
|
358
485
|
});
|
|
359
486
|
}
|
|
360
487
|
/**
|
|
361
488
|
* Read file as data URL
|
|
362
489
|
*/
|
|
363
|
-
async readAsDataURL(
|
|
364
|
-
return new Promise((
|
|
365
|
-
const
|
|
366
|
-
|
|
490
|
+
async readAsDataURL(t) {
|
|
491
|
+
return new Promise((e, i) => {
|
|
492
|
+
const o = new FileReader();
|
|
493
|
+
o.onload = () => e(o.result), o.onerror = () => i(a("Failed to read file", "UNKNOWN_ERROR")), o.readAsDataURL(t);
|
|
367
494
|
});
|
|
368
495
|
}
|
|
369
496
|
}
|
|
370
|
-
const
|
|
371
|
-
function
|
|
372
|
-
return new Promise((
|
|
497
|
+
const T = new I();
|
|
498
|
+
function k(c) {
|
|
499
|
+
return new Promise((t) => {
|
|
373
500
|
if ("vibrate" in navigator)
|
|
374
|
-
navigator.vibrate(
|
|
501
|
+
navigator.vibrate(c), t();
|
|
375
502
|
else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.aippyListener) {
|
|
376
|
-
const
|
|
503
|
+
const e = {
|
|
377
504
|
command: "navigator.vibrate",
|
|
378
|
-
parameters:
|
|
505
|
+
parameters: c
|
|
379
506
|
};
|
|
380
|
-
window.webkit.messageHandlers.aippyListener.postMessage(
|
|
507
|
+
window.webkit.messageHandlers.aippyListener.postMessage(e), t();
|
|
381
508
|
} else
|
|
382
|
-
console.warn("Vibration not supported in this environment"),
|
|
509
|
+
console.warn("Vibration not supported in this environment"), t();
|
|
383
510
|
});
|
|
384
511
|
}
|
|
385
512
|
export {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
513
|
+
P as CameraAPI,
|
|
514
|
+
I as FileSystemAPI,
|
|
515
|
+
O as GeolocationAPI,
|
|
516
|
+
S as SensorsAPI,
|
|
517
|
+
D as camera,
|
|
518
|
+
T as fileSystem,
|
|
519
|
+
A as geolocation,
|
|
520
|
+
g as hasNativeBridge,
|
|
521
|
+
m as isMotionSupported,
|
|
522
|
+
h as isOrientationSupported,
|
|
523
|
+
y as requestMotionPermission,
|
|
524
|
+
M as sensors,
|
|
525
|
+
k as vibrate,
|
|
526
|
+
x as watchMotion,
|
|
527
|
+
L as watchOrientation
|
|
395
528
|
};
|
package/dist/device/sensors.d.ts
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
|
-
import { SensorData } from './types';
|
|
1
|
+
import { SensorData, MotionData, OrientationData } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Check if device motion is supported
|
|
4
|
+
*/
|
|
5
|
+
export declare function isMotionSupported(): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Check if device orientation is supported
|
|
8
|
+
*/
|
|
9
|
+
export declare function isOrientationSupported(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Check if native bridge is available
|
|
12
|
+
*/
|
|
13
|
+
export declare function hasNativeBridge(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Request permission for motion sensors (iOS 13+)
|
|
16
|
+
* @returns Promise<boolean> - true if permission granted
|
|
17
|
+
*/
|
|
18
|
+
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
|
+
*/
|
|
27
|
+
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
|
+
*/
|
|
33
|
+
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
|
|
4
37
|
*/
|
|
5
38
|
export declare class SensorsAPI {
|
|
6
39
|
/**
|
|
@@ -17,6 +50,7 @@ export declare class SensorsAPI {
|
|
|
17
50
|
getOrientation(): Promise<SensorData>;
|
|
18
51
|
/**
|
|
19
52
|
* Watch device orientation changes
|
|
53
|
+
* @deprecated Use watchOrientation() function instead
|
|
20
54
|
*/
|
|
21
55
|
watchOrientation(callback: (data: SensorData) => void): () => void;
|
|
22
56
|
/**
|
|
@@ -25,6 +59,7 @@ export declare class SensorsAPI {
|
|
|
25
59
|
getMotion(): Promise<SensorData>;
|
|
26
60
|
/**
|
|
27
61
|
* Watch device motion changes
|
|
62
|
+
* @deprecated Use watchMotion() function instead
|
|
28
63
|
*/
|
|
29
64
|
watchMotion(callback: (data: SensorData) => void): () => void;
|
|
30
65
|
/**
|
|
@@ -33,6 +68,7 @@ export declare class SensorsAPI {
|
|
|
33
68
|
requestPermission(): Promise<boolean>;
|
|
34
69
|
}
|
|
35
70
|
/**
|
|
36
|
-
* Sensors API instance
|
|
71
|
+
* Sensors API instance (for backward compatibility)
|
|
72
|
+
* @deprecated Use watchMotion() and watchOrientation() functions instead
|
|
37
73
|
*/
|
|
38
74
|
export declare const sensors: SensorsAPI;
|
package/dist/device/types.d.ts
CHANGED
|
@@ -58,6 +58,44 @@ export interface SensorData {
|
|
|
58
58
|
/** Timestamp */
|
|
59
59
|
timestamp: number;
|
|
60
60
|
}
|
|
61
|
+
export interface MotionData {
|
|
62
|
+
/** Gravity vector (normalized, -1 to 1) */
|
|
63
|
+
gravity: {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
z: number;
|
|
67
|
+
};
|
|
68
|
+
/** Linear acceleration (m/s²) */
|
|
69
|
+
acceleration: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
z: number;
|
|
73
|
+
};
|
|
74
|
+
/** Acceleration including gravity (m/s²) */
|
|
75
|
+
accelerationIncludingGravity: {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
z: number;
|
|
79
|
+
};
|
|
80
|
+
/** Rotation rate (deg/s) */
|
|
81
|
+
rotation: {
|
|
82
|
+
alpha: number;
|
|
83
|
+
beta: number;
|
|
84
|
+
gamma: number;
|
|
85
|
+
};
|
|
86
|
+
/** Timestamp */
|
|
87
|
+
timestamp: number;
|
|
88
|
+
}
|
|
89
|
+
export interface OrientationData {
|
|
90
|
+
/** Rotation around Z axis (0-360°) */
|
|
91
|
+
alpha: number;
|
|
92
|
+
/** Rotation around X axis (-180 to 180°) */
|
|
93
|
+
beta: number;
|
|
94
|
+
/** Rotation around Y axis (-90 to 90°) */
|
|
95
|
+
gamma: number;
|
|
96
|
+
/** Timestamp */
|
|
97
|
+
timestamp: number;
|
|
98
|
+
}
|
|
61
99
|
export interface FileSystemOptions {
|
|
62
100
|
/** File types to accept */
|
|
63
101
|
accept?: string[];
|
package/dist/index/index.js
CHANGED
|
@@ -1,44 +1,54 @@
|
|
|
1
|
-
import { DEFAULT_CONFIG as
|
|
2
|
-
import {
|
|
3
|
-
import { CameraAPI as
|
|
4
|
-
import { c as
|
|
5
|
-
import { a as
|
|
6
|
-
import { c as
|
|
7
|
-
import { reportScore as
|
|
1
|
+
import { DEFAULT_CONFIG as o, SDK_NAME as r, VERSION as t, getConfigFromEnv as i, getVersionInfo as s, mergeConfig as n } from "../core/index.js";
|
|
2
|
+
import { a as m, A as c, C as d, E as f, R as u, b as l, c as A } from "../runtime-DOnodF_1.js";
|
|
3
|
+
import { CameraAPI as E, FileSystemAPI as C, GeolocationAPI as R, SensorsAPI as x, camera as P, fileSystem as I, geolocation as M, hasNativeBridge as g, isMotionSupported as y, isOrientationSupported as O, requestMotionPermission as b, sensors as v, vibrate as h, watchMotion as w, watchOrientation as D } from "../device/index.js";
|
|
4
|
+
import { c as N, a as T, P as V, b as _, p as k, d as G } from "../pwa-8DGmPqLV.js";
|
|
5
|
+
import { a as U, b as q } from "../useTweaks-QxMRmg7i.js";
|
|
6
|
+
import { c as K, a as L, b as W, i as j, p as z, u as J } from "../useAudioContext-CNQQSTab.js";
|
|
7
|
+
import { reportScore as X, sendEvent as Y, updateScore as Z } from "../leaderboard/index.js";
|
|
8
8
|
export {
|
|
9
|
-
m as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
m as AippyRuntime,
|
|
10
|
+
c as AippyRuntimeError,
|
|
11
|
+
E as CameraAPI,
|
|
12
|
+
d as Cancellable,
|
|
13
|
+
o as DEFAULT_CONFIG,
|
|
14
|
+
f as ERROR_CODES,
|
|
15
|
+
C as FileSystemAPI,
|
|
16
|
+
R as GeolocationAPI,
|
|
17
|
+
N as PWAUtils,
|
|
18
|
+
T as PerformanceMonitor,
|
|
19
|
+
V as PlatformDetector,
|
|
20
|
+
u as ReceiveChannel,
|
|
21
|
+
r as SDK_NAME,
|
|
22
|
+
x as SensorsAPI,
|
|
20
23
|
t as VERSION,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
I as
|
|
29
|
-
|
|
30
|
-
i as
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
l as aippyRuntime,
|
|
25
|
+
U as aippyTweaks,
|
|
26
|
+
q as aippyTweaksRuntime,
|
|
27
|
+
P as camera,
|
|
28
|
+
A as createError,
|
|
29
|
+
K as createHiddenMediaElement,
|
|
30
|
+
L as createHiddenVideoElement,
|
|
31
|
+
I as fileSystem,
|
|
32
|
+
M as geolocation,
|
|
33
|
+
i as getConfigFromEnv,
|
|
34
|
+
s as getVersionInfo,
|
|
35
|
+
g as hasNativeBridge,
|
|
36
|
+
W as isIOSDevice,
|
|
37
|
+
j as isMediaStreamAudioSupported,
|
|
38
|
+
y as isMotionSupported,
|
|
39
|
+
O as isOrientationSupported,
|
|
33
40
|
n as mergeConfig,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
z as patchAudioContext,
|
|
42
|
+
_ as performanceMonitor,
|
|
43
|
+
k as platform,
|
|
44
|
+
G as pwa,
|
|
45
|
+
X as reportScore,
|
|
46
|
+
b as requestMotionPermission,
|
|
47
|
+
Y as sendEvent,
|
|
48
|
+
v as sensors,
|
|
49
|
+
Z as updateScore,
|
|
50
|
+
J as useAudioContext,
|
|
51
|
+
h as vibrate,
|
|
52
|
+
w as watchMotion,
|
|
53
|
+
D as watchOrientation
|
|
44
54
|
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var p = (i, e, t) => e in i ? l(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var r = (i, e, t) => p(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
class u extends Error {
|
|
5
|
+
constructor(t, s = "AIPPY_ERROR", n) {
|
|
6
|
+
super(t);
|
|
7
|
+
r(this, "code");
|
|
8
|
+
r(this, "context");
|
|
9
|
+
this.name = "AippyRuntimeError", this.code = s, this.context = n;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const R = {
|
|
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 O(i, e = "UNKNOWN_ERROR", t) {
|
|
20
|
+
return new u(i, R[e], t);
|
|
21
|
+
}
|
|
22
|
+
class o {
|
|
23
|
+
constructor(e) {
|
|
24
|
+
r(this, "cancelled", !1);
|
|
25
|
+
this.cancelFn = e;
|
|
26
|
+
}
|
|
27
|
+
cancel() {
|
|
28
|
+
this.cancelled || (this.cancelled = !0, this.cancelFn?.());
|
|
29
|
+
}
|
|
30
|
+
get isCancelled() {
|
|
31
|
+
return this.cancelled;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
class d {
|
|
35
|
+
constructor() {
|
|
36
|
+
r(this, "listeners", /* @__PURE__ */ new Map());
|
|
37
|
+
}
|
|
38
|
+
addEventListener(e, t) {
|
|
39
|
+
this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t);
|
|
40
|
+
}
|
|
41
|
+
removeEventListener(e, t) {
|
|
42
|
+
const s = this.listeners.get(e);
|
|
43
|
+
if (s) {
|
|
44
|
+
const n = s.indexOf(t);
|
|
45
|
+
n > -1 && s.splice(n, 1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
emit(e, t) {
|
|
49
|
+
const s = this.listeners.get(e);
|
|
50
|
+
s && s.forEach((n) => n(t));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
class h {
|
|
54
|
+
constructor() {
|
|
55
|
+
r(this, "emitter", new d());
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Emit a message to subscribers
|
|
59
|
+
*/
|
|
60
|
+
emit(e) {
|
|
61
|
+
this.emitter.emit(e.endpoint, e.payload);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Subscribe to messages on a specific endpoint
|
|
65
|
+
*/
|
|
66
|
+
subscribe(e, t) {
|
|
67
|
+
const s = (n) => {
|
|
68
|
+
t(n);
|
|
69
|
+
};
|
|
70
|
+
return this.emitter.addEventListener(e, s), new o(() => {
|
|
71
|
+
this.emitter.removeEventListener(e, s);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Subscribe to a single message (auto-unsubscribe after first message)
|
|
76
|
+
*/
|
|
77
|
+
once(e, t) {
|
|
78
|
+
const s = this.subscribe(e, (n) => {
|
|
79
|
+
s.cancel(), t(n);
|
|
80
|
+
});
|
|
81
|
+
return s;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
class E {
|
|
85
|
+
constructor() {
|
|
86
|
+
r(this, "receiveChannel", new h());
|
|
87
|
+
r(this, "seq", 0);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Receive message from native layer
|
|
91
|
+
* Called by native code via: window.aippyRuntime.receiveMessage(message)
|
|
92
|
+
*/
|
|
93
|
+
receiveMessage(e) {
|
|
94
|
+
return this.receiveChannel.emit(e), Promise.resolve();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create a subscription to native events
|
|
98
|
+
* @param handler - WebKit message handler (e.g., deviceMotionHandler)
|
|
99
|
+
* @param subscribePayload - Subscription parameters (e.g., { type: "motion" })
|
|
100
|
+
* @param callback - Callback to handle received data
|
|
101
|
+
* @returns Cancellable subscription
|
|
102
|
+
*/
|
|
103
|
+
createSubscription(e, t, s) {
|
|
104
|
+
const n = this.makeSubscriptionMessage(t), a = this.receiveChannel.subscribe(n.endpoint, (c) => {
|
|
105
|
+
c.error === void 0 && s(c);
|
|
106
|
+
});
|
|
107
|
+
try {
|
|
108
|
+
e.postMessage(n);
|
|
109
|
+
} catch {
|
|
110
|
+
}
|
|
111
|
+
return new o(() => {
|
|
112
|
+
a.cancel();
|
|
113
|
+
try {
|
|
114
|
+
e.postMessage({
|
|
115
|
+
endpoint: n.endpoint,
|
|
116
|
+
payload: "unsubscribe"
|
|
117
|
+
});
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Make a subscription message with unique endpoint
|
|
124
|
+
*/
|
|
125
|
+
makeSubscriptionMessage(e) {
|
|
126
|
+
return {
|
|
127
|
+
endpoint: (this.seq++).toString(),
|
|
128
|
+
payload: {
|
|
129
|
+
subscribe: e
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Add motion listener (convenience method)
|
|
135
|
+
* @param callback - Callback to handle motion data
|
|
136
|
+
* @returns Cleanup function
|
|
137
|
+
*/
|
|
138
|
+
addMotionListener(e) {
|
|
139
|
+
const t = window.webkit?.messageHandlers?.deviceMotionHandler;
|
|
140
|
+
if (!t)
|
|
141
|
+
return () => {
|
|
142
|
+
};
|
|
143
|
+
const s = this.createSubscription(
|
|
144
|
+
t,
|
|
145
|
+
{ type: "motion" },
|
|
146
|
+
(n) => {
|
|
147
|
+
n.motion && e(n.motion);
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
return () => {
|
|
151
|
+
s.cancel();
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const m = new E();
|
|
156
|
+
typeof window < "u" && (window.aippyRuntime = m);
|
|
157
|
+
export {
|
|
158
|
+
u as A,
|
|
159
|
+
o as C,
|
|
160
|
+
R as E,
|
|
161
|
+
h as R,
|
|
162
|
+
E as a,
|
|
163
|
+
m as b,
|
|
164
|
+
O as c
|
|
165
|
+
};
|
package/package.json
CHANGED
package/dist/errors-CDEBaBxB.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
};
|