@stacksjs/mobile 0.70.375
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/LICENSE.md +21 -0
- package/README.md +20 -0
- package/dist/index.d.ts +270 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +238 -0
- package/package.json +47 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Open Web Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @stacksjs/mobile
|
|
2
|
+
|
|
3
|
+
Craft-powered mobile APIs for Stacks and STX applications. The package keeps
|
|
4
|
+
native capability detection, readiness, haptics, location, camera, sharing,
|
|
5
|
+
secure storage, lifecycle, health, Live Activities, and watch connectivity
|
|
6
|
+
behind one browser-safe interface.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { haptics, isNativeMobile, location } from '@stacksjs/mobile'
|
|
10
|
+
|
|
11
|
+
if (isNativeMobile())
|
|
12
|
+
await haptics.selection()
|
|
13
|
+
|
|
14
|
+
const position = await location.getCurrentPosition()
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The `health` facade reads authorized Apple Health or Android Health Connect
|
|
18
|
+
metrics and writes completed workouts using one payload. `watchConnectivity`
|
|
19
|
+
keeps companion controls and recording state synchronized without exposing
|
|
20
|
+
platform bridge globals to application code.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundled TypeScript declarations
|
|
3
|
+
* Generated from 2 source files
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
// From: src/index.ts
|
|
8
|
+
export declare const biometrics: BiometricsApi;
|
|
9
|
+
export declare const camera: CameraApi;
|
|
10
|
+
export declare const device: DeviceApi;
|
|
11
|
+
export declare const haptics: HapticsApi;
|
|
12
|
+
export declare const lifecycle: LifecycleApi;
|
|
13
|
+
export declare const location: LocationApi;
|
|
14
|
+
export declare const notifications: NotificationsApi;
|
|
15
|
+
export declare const permissions: PermissionsApi;
|
|
16
|
+
export declare const secureStorage: SecureStorageApi;
|
|
17
|
+
export declare const share: ShareApi;
|
|
18
|
+
export declare const appReview: AppReviewApi;
|
|
19
|
+
export declare function normalizeDeepLinkURL(value: unknown): string | null;
|
|
20
|
+
export declare const deepLinks: DeepLinksApi;
|
|
21
|
+
export declare const keepAwake: KeepAwakeApi;
|
|
22
|
+
export declare const network: NetworkApi;
|
|
23
|
+
export declare const pushNotifications: PushNotificationsApi;
|
|
24
|
+
export declare const health: HealthApi;
|
|
25
|
+
export declare const liveActivities: LiveActivitiesApi;
|
|
26
|
+
export declare const watchConnectivity: WatchConnectivityApi;
|
|
27
|
+
export declare function isNativeMobile(): boolean;
|
|
28
|
+
export declare function onMobileReady(callback: (event: CraftReadyEvent) => void): () => void;
|
|
29
|
+
export declare function withNativeFeedback<T>(action: () => T | Promise<T>): Promise<T>;
|
|
30
|
+
export declare const mobile: unknown;
|
|
31
|
+
|
|
32
|
+
// From: src/types.ts
|
|
33
|
+
export declare interface DeviceInfo {
|
|
34
|
+
platform: 'ios' | 'android' | 'macos' | 'windows' | 'linux'
|
|
35
|
+
osVersion: string
|
|
36
|
+
model: string
|
|
37
|
+
manufacturer: string
|
|
38
|
+
deviceId: string
|
|
39
|
+
isTablet: boolean
|
|
40
|
+
screen?: { width: number, height: number, scale: number }
|
|
41
|
+
battery?: { level: number, isCharging: boolean }
|
|
42
|
+
network?: { type: 'wifi' | 'cellular' | 'ethernet' | 'none', isConnected: boolean }
|
|
43
|
+
}
|
|
44
|
+
export declare interface DeviceCapabilities {
|
|
45
|
+
camera: boolean
|
|
46
|
+
biometrics: boolean
|
|
47
|
+
nfc: boolean
|
|
48
|
+
bluetooth: boolean
|
|
49
|
+
gps: boolean
|
|
50
|
+
backgroundLocation?: boolean
|
|
51
|
+
accelerometer: boolean
|
|
52
|
+
gyroscope: boolean
|
|
53
|
+
haptics: boolean
|
|
54
|
+
ar: boolean
|
|
55
|
+
faceId: boolean
|
|
56
|
+
touchId: boolean
|
|
57
|
+
}
|
|
58
|
+
export type HapticStyle = 'light' | 'medium' | 'heavy' | 'soft' | 'rigid';
|
|
59
|
+
export type HapticNotificationType = 'success' | 'warning' | 'error';
|
|
60
|
+
export type PermissionType = | 'camera'
|
|
61
|
+
| 'microphone'
|
|
62
|
+
| 'photos'
|
|
63
|
+
| 'location'
|
|
64
|
+
| 'locationAlways'
|
|
65
|
+
| 'notifications'
|
|
66
|
+
| 'contacts'
|
|
67
|
+
| 'calendar'
|
|
68
|
+
| 'reminders'
|
|
69
|
+
| 'bluetooth'
|
|
70
|
+
| 'motion'
|
|
71
|
+
| 'health';
|
|
72
|
+
export type PermissionStatus = 'granted' | 'denied' | 'undetermined' | 'restricted';
|
|
73
|
+
export declare interface CameraOptions {
|
|
74
|
+
camera?: 'front' | 'back'
|
|
75
|
+
quality?: number
|
|
76
|
+
maxWidth?: number
|
|
77
|
+
maxHeight?: number
|
|
78
|
+
saveToGallery?: boolean
|
|
79
|
+
}
|
|
80
|
+
export declare interface PhotoResult {
|
|
81
|
+
base64: string
|
|
82
|
+
uri: string
|
|
83
|
+
width: number
|
|
84
|
+
height: number
|
|
85
|
+
mimeType: string
|
|
86
|
+
}
|
|
87
|
+
export type BiometricType = 'faceId' | 'touchId' | 'fingerprint' | 'face' | 'iris';
|
|
88
|
+
export declare interface Location {
|
|
89
|
+
latitude: number
|
|
90
|
+
longitude: number
|
|
91
|
+
altitude?: number
|
|
92
|
+
accuracy: number
|
|
93
|
+
heading?: number
|
|
94
|
+
speed?: number
|
|
95
|
+
timestamp: number
|
|
96
|
+
}
|
|
97
|
+
export declare interface LocationOptions {
|
|
98
|
+
enableHighAccuracy?: boolean
|
|
99
|
+
timeout?: number
|
|
100
|
+
maximumAge?: number
|
|
101
|
+
}
|
|
102
|
+
export declare interface LocationRecordingState {
|
|
103
|
+
id: string | null
|
|
104
|
+
active: boolean
|
|
105
|
+
paused: boolean
|
|
106
|
+
startedAt: number | null
|
|
107
|
+
sampleCount?: number
|
|
108
|
+
}
|
|
109
|
+
export declare interface LocationRecordingResult extends LocationRecordingState {
|
|
110
|
+
locations: Location[]
|
|
111
|
+
}
|
|
112
|
+
export declare interface ShareOptions {
|
|
113
|
+
text?: string
|
|
114
|
+
url?: string
|
|
115
|
+
title?: string
|
|
116
|
+
files?: string[]
|
|
117
|
+
}
|
|
118
|
+
export type AppState = 'active' | 'inactive' | 'background';
|
|
119
|
+
export declare interface NotificationOptions {
|
|
120
|
+
title: string
|
|
121
|
+
body?: string
|
|
122
|
+
badge?: number
|
|
123
|
+
sound?: string
|
|
124
|
+
data?: Record<string, unknown>
|
|
125
|
+
scheduleAt?: number
|
|
126
|
+
}
|
|
127
|
+
export declare interface DeviceApi {
|
|
128
|
+
getInfo: () => Promise<DeviceInfo>
|
|
129
|
+
getCapabilities: () => Promise<DeviceCapabilities>
|
|
130
|
+
isMobile: () => boolean
|
|
131
|
+
isIOS: () => boolean
|
|
132
|
+
isAndroid: () => boolean
|
|
133
|
+
getLocale: () => string
|
|
134
|
+
getTimezone: () => string
|
|
135
|
+
}
|
|
136
|
+
export declare interface HapticsApi {
|
|
137
|
+
impact: (style?: HapticStyle) => Promise<void>
|
|
138
|
+
notification: (type?: HapticNotificationType) => Promise<void>
|
|
139
|
+
selection: () => Promise<void>
|
|
140
|
+
vibrate: (pattern: number[]) => Promise<void>
|
|
141
|
+
}
|
|
142
|
+
export declare interface PermissionsApi {
|
|
143
|
+
check: (permission: PermissionType) => Promise<PermissionStatus>
|
|
144
|
+
request: (permission: PermissionType) => Promise<PermissionStatus>
|
|
145
|
+
checkMultiple: (permissions: PermissionType[]) => Promise<Record<PermissionType, PermissionStatus>>
|
|
146
|
+
requestMultiple: (permissions: PermissionType[]) => Promise<Record<PermissionType, PermissionStatus>>
|
|
147
|
+
openSettings: () => Promise<void>
|
|
148
|
+
}
|
|
149
|
+
export declare interface CameraApi {
|
|
150
|
+
takePicture: (options?: CameraOptions) => Promise<PhotoResult>
|
|
151
|
+
pickImage: () => Promise<PhotoResult>
|
|
152
|
+
pickMultiple: (options?: { maxCount?: number }) => Promise<PhotoResult[]>
|
|
153
|
+
isAvailable: () => Promise<boolean>
|
|
154
|
+
}
|
|
155
|
+
export declare interface BiometricsApi {
|
|
156
|
+
isAvailable: () => Promise<boolean>
|
|
157
|
+
getBiometricType: () => Promise<BiometricType | null>
|
|
158
|
+
authenticate: (reason: string) => Promise<boolean>
|
|
159
|
+
}
|
|
160
|
+
export declare interface SecureStorageApi {
|
|
161
|
+
set: (key: string, value: string) => Promise<void>
|
|
162
|
+
get: (key: string) => Promise<string | null>
|
|
163
|
+
delete: (key: string) => Promise<void>
|
|
164
|
+
clear: () => Promise<void>
|
|
165
|
+
}
|
|
166
|
+
export declare interface LocationApi {
|
|
167
|
+
getCurrentPosition: (options?: LocationOptions) => Promise<Location>
|
|
168
|
+
watchPosition: (callback: (location: Location) => void, options?: LocationOptions) => number
|
|
169
|
+
clearWatch: (watchId: number) => void
|
|
170
|
+
startRecording: (options?: LocationOptions) => Promise<LocationRecordingState>
|
|
171
|
+
pauseRecording: () => Promise<LocationRecordingState>
|
|
172
|
+
resumeRecording: () => Promise<LocationRecordingState>
|
|
173
|
+
stopRecording: () => Promise<LocationRecordingResult>
|
|
174
|
+
getRecordingState: () => Promise<LocationRecordingState>
|
|
175
|
+
readRecording: () => Promise<Location[]>
|
|
176
|
+
}
|
|
177
|
+
export declare interface ShareApi {
|
|
178
|
+
share: (options: ShareOptions) => Promise<void>
|
|
179
|
+
isAvailable: () => boolean
|
|
180
|
+
}
|
|
181
|
+
export declare interface LifecycleApi {
|
|
182
|
+
getState: () => AppState
|
|
183
|
+
onStateChange: (callback: (state: AppState) => void) => () => void
|
|
184
|
+
}
|
|
185
|
+
export declare interface NotificationsApi {
|
|
186
|
+
show: (options: NotificationOptions) => Promise<void>
|
|
187
|
+
schedule: (options: NotificationOptions) => Promise<void>
|
|
188
|
+
cancelAll: () => Promise<void>
|
|
189
|
+
setBadge: (count: number) => Promise<void>
|
|
190
|
+
}
|
|
191
|
+
export declare interface KeepAwakeApi {
|
|
192
|
+
enable: () => Promise<void>
|
|
193
|
+
disable: () => Promise<void>
|
|
194
|
+
}
|
|
195
|
+
export declare interface DeepLinksApi {
|
|
196
|
+
getInitialURL: () => Promise<string | null>
|
|
197
|
+
onLink: (callback: (url: string) => void) => () => void
|
|
198
|
+
}
|
|
199
|
+
export declare interface NetworkStatus {
|
|
200
|
+
type: 'wifi' | 'cellular' | 'ethernet' | 'none' | 'unknown'
|
|
201
|
+
isConnected: boolean
|
|
202
|
+
}
|
|
203
|
+
export declare interface NetworkApi {
|
|
204
|
+
getStatus: () => Promise<NetworkStatus>
|
|
205
|
+
onChange: (callback: (status: NetworkStatus) => void) => () => void
|
|
206
|
+
}
|
|
207
|
+
export declare interface AppReviewApi {
|
|
208
|
+
request: () => Promise<boolean>
|
|
209
|
+
}
|
|
210
|
+
export declare interface PushNotificationsApi {
|
|
211
|
+
register: () => Promise<string>
|
|
212
|
+
onToken: (callback: (token: string) => void) => () => void
|
|
213
|
+
onNotification: (callback: (data: Record<string, unknown>) => void) => () => void
|
|
214
|
+
}
|
|
215
|
+
export type HealthDataType = 'steps' | 'heartRate' | 'activeEnergy' | 'distance' | 'workouts';
|
|
216
|
+
export declare interface HealthDataOptions {
|
|
217
|
+
startDate?: number
|
|
218
|
+
endDate?: number
|
|
219
|
+
}
|
|
220
|
+
export declare interface HealthDataResult {
|
|
221
|
+
value: number
|
|
222
|
+
unit: string
|
|
223
|
+
}
|
|
224
|
+
export type HealthWorkoutType = 'running' | 'walking' | 'hiking' | 'cycling';
|
|
225
|
+
export declare interface HealthWorkoutLocation {
|
|
226
|
+
latitude: number
|
|
227
|
+
longitude: number
|
|
228
|
+
altitude?: number
|
|
229
|
+
accuracy?: number
|
|
230
|
+
timestamp: number
|
|
231
|
+
}
|
|
232
|
+
export declare interface HealthWorkout {
|
|
233
|
+
activityId: string
|
|
234
|
+
type: HealthWorkoutType
|
|
235
|
+
startDate: number
|
|
236
|
+
endDate: number
|
|
237
|
+
distanceMeters?: number
|
|
238
|
+
activeEnergyCalories?: number
|
|
239
|
+
locations?: HealthWorkoutLocation[]
|
|
240
|
+
}
|
|
241
|
+
export declare interface HealthWorkoutResult {
|
|
242
|
+
id: string
|
|
243
|
+
}
|
|
244
|
+
export declare interface HealthApi {
|
|
245
|
+
requestAuthorization: (types: HealthDataType[]) => Promise<boolean>
|
|
246
|
+
getData: (type: HealthDataType, options?: HealthDataOptions) => Promise<HealthDataResult>
|
|
247
|
+
saveWorkout: (workout: HealthWorkout) => Promise<HealthWorkoutResult>
|
|
248
|
+
}
|
|
249
|
+
export declare interface LiveActivityState {
|
|
250
|
+
status?: string
|
|
251
|
+
distanceMeters?: number
|
|
252
|
+
durationSeconds?: number
|
|
253
|
+
progress?: number
|
|
254
|
+
}
|
|
255
|
+
export declare interface LiveActivityOptions extends LiveActivityState {
|
|
256
|
+
activityId: string
|
|
257
|
+
title: string
|
|
258
|
+
}
|
|
259
|
+
export declare interface LiveActivitiesApi {
|
|
260
|
+
start: (options: LiveActivityOptions) => Promise<{ id: string }>
|
|
261
|
+
update: (state: LiveActivityState) => Promise<void>
|
|
262
|
+
end: () => Promise<void>
|
|
263
|
+
}
|
|
264
|
+
export declare interface WatchConnectivityApi {
|
|
265
|
+
send: (message: Record<string, unknown>) => Promise<Record<string, unknown>>
|
|
266
|
+
updateContext: (context: Record<string, unknown>) => Promise<void>
|
|
267
|
+
isReachable: () => Promise<boolean>
|
|
268
|
+
onMessage: (callback: (message: Record<string, unknown>) => void) => () => void
|
|
269
|
+
onReachabilityChange: (callback: (reachable: boolean) => void) => () => void
|
|
270
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as p from"craft-native/mobile";var{biometrics:f,camera:A,device:u,haptics:l,lifecycle:v,location:h,notifications:w,permissions:m,secureStorage:d,share:y,appReview:k,deepLinks:n,keepAwake:x,network:L,pushNotifications:R,health:g,liveActivities:C,watchConnectivity:N}=p,b=f,S=A,c=u,o=l,E=v,H=h,P=w,D=m,T=d,M=y,B=k;function r(t){if(typeof t==="string")return t.trim()||null;if(!t||typeof t!=="object")return null;let e=t.url;return typeof e==="string"&&e.trim()?e:null}var K={async getInitialURL(){return r(await n.getInitialURL?.())},onLink(t){return n.onLink?.((e)=>{let i=r(e);if(i)t(i)})??(()=>{})}},U=x,W=L,F=R,I=g,j=C,q=N;function a(){if(typeof globalThis>"u")return;return globalThis}function z(){let t=a();return Boolean(t?.craft)&&c.isMobile()}function G(t){let e=a();if(!e)return()=>{};if(e.craft)return queueMicrotask(()=>t(new Event("craftReady"))),()=>{};let i=(s)=>t(s);return e.addEventListener("craftReady",i,{once:!0}),()=>e.removeEventListener("craftReady",i)}async function J(t){await o.impact("light");try{let e=await t();return await o.notification("success"),e}catch(e){throw await o.notification("error"),e}}var O={biometrics:b,camera:S,device:c,haptics:o,lifecycle:E,location:H,notifications:P,permissions:D,secureStorage:T,share:M,appReview:B,deepLinks:K,keepAwake:U,network:W,pushNotifications:F,health:I,liveActivities:j,watchConnectivity:q,isNativeMobile:z,onReady:G,withFeedback:J};export{J as withNativeFeedback,q as watchConnectivity,M as share,T as secureStorage,F as pushNotifications,D as permissions,G as onMobileReady,P as notifications,r as normalizeDeepLinkURL,W as network,O as mobile,H as location,j as liveActivities,E as lifecycle,U as keepAwake,z as isNativeMobile,I as health,o as haptics,c as device,K as deepLinks,S as camera,b as biometrics,B as appReview};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
export declare interface DeviceInfo {
|
|
2
|
+
platform: 'ios' | 'android' | 'macos' | 'windows' | 'linux'
|
|
3
|
+
osVersion: string
|
|
4
|
+
model: string
|
|
5
|
+
manufacturer: string
|
|
6
|
+
deviceId: string
|
|
7
|
+
isTablet: boolean
|
|
8
|
+
screen?: { width: number, height: number, scale: number }
|
|
9
|
+
battery?: { level: number, isCharging: boolean }
|
|
10
|
+
network?: { type: 'wifi' | 'cellular' | 'ethernet' | 'none', isConnected: boolean }
|
|
11
|
+
}
|
|
12
|
+
export declare interface DeviceCapabilities {
|
|
13
|
+
camera: boolean
|
|
14
|
+
biometrics: boolean
|
|
15
|
+
nfc: boolean
|
|
16
|
+
bluetooth: boolean
|
|
17
|
+
gps: boolean
|
|
18
|
+
backgroundLocation?: boolean
|
|
19
|
+
accelerometer: boolean
|
|
20
|
+
gyroscope: boolean
|
|
21
|
+
haptics: boolean
|
|
22
|
+
ar: boolean
|
|
23
|
+
faceId: boolean
|
|
24
|
+
touchId: boolean
|
|
25
|
+
}
|
|
26
|
+
export declare interface CameraOptions {
|
|
27
|
+
camera?: 'front' | 'back'
|
|
28
|
+
quality?: number
|
|
29
|
+
maxWidth?: number
|
|
30
|
+
maxHeight?: number
|
|
31
|
+
saveToGallery?: boolean
|
|
32
|
+
}
|
|
33
|
+
export declare interface PhotoResult {
|
|
34
|
+
base64: string
|
|
35
|
+
uri: string
|
|
36
|
+
width: number
|
|
37
|
+
height: number
|
|
38
|
+
mimeType: string
|
|
39
|
+
}
|
|
40
|
+
export declare interface Location {
|
|
41
|
+
latitude: number
|
|
42
|
+
longitude: number
|
|
43
|
+
altitude?: number
|
|
44
|
+
accuracy: number
|
|
45
|
+
heading?: number
|
|
46
|
+
speed?: number
|
|
47
|
+
timestamp: number
|
|
48
|
+
}
|
|
49
|
+
export declare interface LocationOptions {
|
|
50
|
+
enableHighAccuracy?: boolean
|
|
51
|
+
timeout?: number
|
|
52
|
+
maximumAge?: number
|
|
53
|
+
}
|
|
54
|
+
export declare interface LocationRecordingState {
|
|
55
|
+
id: string | null
|
|
56
|
+
active: boolean
|
|
57
|
+
paused: boolean
|
|
58
|
+
startedAt: number | null
|
|
59
|
+
sampleCount?: number
|
|
60
|
+
}
|
|
61
|
+
export declare interface LocationRecordingResult extends LocationRecordingState {
|
|
62
|
+
locations: Location[]
|
|
63
|
+
}
|
|
64
|
+
export declare interface ShareOptions {
|
|
65
|
+
text?: string
|
|
66
|
+
url?: string
|
|
67
|
+
title?: string
|
|
68
|
+
files?: string[]
|
|
69
|
+
}
|
|
70
|
+
export declare interface NotificationOptions {
|
|
71
|
+
title: string
|
|
72
|
+
body?: string
|
|
73
|
+
badge?: number
|
|
74
|
+
sound?: string
|
|
75
|
+
data?: Record<string, unknown>
|
|
76
|
+
scheduleAt?: number
|
|
77
|
+
}
|
|
78
|
+
export declare interface DeviceApi {
|
|
79
|
+
getInfo: () => Promise<DeviceInfo>
|
|
80
|
+
getCapabilities: () => Promise<DeviceCapabilities>
|
|
81
|
+
isMobile: () => boolean
|
|
82
|
+
isIOS: () => boolean
|
|
83
|
+
isAndroid: () => boolean
|
|
84
|
+
getLocale: () => string
|
|
85
|
+
getTimezone: () => string
|
|
86
|
+
}
|
|
87
|
+
export declare interface HapticsApi {
|
|
88
|
+
impact: (style?: HapticStyle) => Promise<void>
|
|
89
|
+
notification: (type?: HapticNotificationType) => Promise<void>
|
|
90
|
+
selection: () => Promise<void>
|
|
91
|
+
vibrate: (pattern: number[]) => Promise<void>
|
|
92
|
+
}
|
|
93
|
+
export declare interface PermissionsApi {
|
|
94
|
+
check: (permission: PermissionType) => Promise<PermissionStatus>
|
|
95
|
+
request: (permission: PermissionType) => Promise<PermissionStatus>
|
|
96
|
+
checkMultiple: (permissions: PermissionType[]) => Promise<Record<PermissionType, PermissionStatus>>
|
|
97
|
+
requestMultiple: (permissions: PermissionType[]) => Promise<Record<PermissionType, PermissionStatus>>
|
|
98
|
+
openSettings: () => Promise<void>
|
|
99
|
+
}
|
|
100
|
+
export declare interface CameraApi {
|
|
101
|
+
takePicture: (options?: CameraOptions) => Promise<PhotoResult>
|
|
102
|
+
pickImage: () => Promise<PhotoResult>
|
|
103
|
+
pickMultiple: (options?: { maxCount?: number }) => Promise<PhotoResult[]>
|
|
104
|
+
isAvailable: () => Promise<boolean>
|
|
105
|
+
}
|
|
106
|
+
export declare interface BiometricsApi {
|
|
107
|
+
isAvailable: () => Promise<boolean>
|
|
108
|
+
getBiometricType: () => Promise<BiometricType | null>
|
|
109
|
+
authenticate: (reason: string) => Promise<boolean>
|
|
110
|
+
}
|
|
111
|
+
export declare interface SecureStorageApi {
|
|
112
|
+
set: (key: string, value: string) => Promise<void>
|
|
113
|
+
get: (key: string) => Promise<string | null>
|
|
114
|
+
delete: (key: string) => Promise<void>
|
|
115
|
+
clear: () => Promise<void>
|
|
116
|
+
}
|
|
117
|
+
export declare interface LocationApi {
|
|
118
|
+
getCurrentPosition: (options?: LocationOptions) => Promise<Location>
|
|
119
|
+
watchPosition: (callback: (location: Location) => void, options?: LocationOptions) => number
|
|
120
|
+
clearWatch: (watchId: number) => void
|
|
121
|
+
startRecording: (options?: LocationOptions) => Promise<LocationRecordingState>
|
|
122
|
+
pauseRecording: () => Promise<LocationRecordingState>
|
|
123
|
+
resumeRecording: () => Promise<LocationRecordingState>
|
|
124
|
+
stopRecording: () => Promise<LocationRecordingResult>
|
|
125
|
+
getRecordingState: () => Promise<LocationRecordingState>
|
|
126
|
+
readRecording: () => Promise<Location[]>
|
|
127
|
+
}
|
|
128
|
+
export declare interface ShareApi {
|
|
129
|
+
share: (options: ShareOptions) => Promise<void>
|
|
130
|
+
isAvailable: () => boolean
|
|
131
|
+
}
|
|
132
|
+
export declare interface LifecycleApi {
|
|
133
|
+
getState: () => AppState
|
|
134
|
+
onStateChange: (callback: (state: AppState) => void) => () => void
|
|
135
|
+
}
|
|
136
|
+
export declare interface NotificationsApi {
|
|
137
|
+
show: (options: NotificationOptions) => Promise<void>
|
|
138
|
+
schedule: (options: NotificationOptions) => Promise<void>
|
|
139
|
+
cancelAll: () => Promise<void>
|
|
140
|
+
setBadge: (count: number) => Promise<void>
|
|
141
|
+
}
|
|
142
|
+
export declare interface KeepAwakeApi {
|
|
143
|
+
enable: () => Promise<void>
|
|
144
|
+
disable: () => Promise<void>
|
|
145
|
+
}
|
|
146
|
+
export declare interface DeepLinksApi {
|
|
147
|
+
getInitialURL: () => Promise<string | null>
|
|
148
|
+
onLink: (callback: (url: string) => void) => () => void
|
|
149
|
+
}
|
|
150
|
+
export declare interface NetworkStatus {
|
|
151
|
+
type: 'wifi' | 'cellular' | 'ethernet' | 'none' | 'unknown'
|
|
152
|
+
isConnected: boolean
|
|
153
|
+
}
|
|
154
|
+
export declare interface NetworkApi {
|
|
155
|
+
getStatus: () => Promise<NetworkStatus>
|
|
156
|
+
onChange: (callback: (status: NetworkStatus) => void) => () => void
|
|
157
|
+
}
|
|
158
|
+
export declare interface AppReviewApi {
|
|
159
|
+
request: () => Promise<boolean>
|
|
160
|
+
}
|
|
161
|
+
export declare interface PushNotificationsApi {
|
|
162
|
+
register: () => Promise<string>
|
|
163
|
+
onToken: (callback: (token: string) => void) => () => void
|
|
164
|
+
onNotification: (callback: (data: Record<string, unknown>) => void) => () => void
|
|
165
|
+
}
|
|
166
|
+
export declare interface HealthDataOptions {
|
|
167
|
+
startDate?: number
|
|
168
|
+
endDate?: number
|
|
169
|
+
}
|
|
170
|
+
export declare interface HealthDataResult {
|
|
171
|
+
value: number
|
|
172
|
+
unit: string
|
|
173
|
+
}
|
|
174
|
+
export declare interface HealthWorkoutLocation {
|
|
175
|
+
latitude: number
|
|
176
|
+
longitude: number
|
|
177
|
+
altitude?: number
|
|
178
|
+
accuracy?: number
|
|
179
|
+
timestamp: number
|
|
180
|
+
}
|
|
181
|
+
export declare interface HealthWorkout {
|
|
182
|
+
activityId: string
|
|
183
|
+
type: HealthWorkoutType
|
|
184
|
+
startDate: number
|
|
185
|
+
endDate: number
|
|
186
|
+
distanceMeters?: number
|
|
187
|
+
activeEnergyCalories?: number
|
|
188
|
+
locations?: HealthWorkoutLocation[]
|
|
189
|
+
}
|
|
190
|
+
export declare interface HealthWorkoutResult {
|
|
191
|
+
id: string
|
|
192
|
+
}
|
|
193
|
+
export declare interface HealthApi {
|
|
194
|
+
requestAuthorization: (types: HealthDataType[]) => Promise<boolean>
|
|
195
|
+
getData: (type: HealthDataType, options?: HealthDataOptions) => Promise<HealthDataResult>
|
|
196
|
+
saveWorkout: (workout: HealthWorkout) => Promise<HealthWorkoutResult>
|
|
197
|
+
}
|
|
198
|
+
export declare interface LiveActivityState {
|
|
199
|
+
status?: string
|
|
200
|
+
distanceMeters?: number
|
|
201
|
+
durationSeconds?: number
|
|
202
|
+
progress?: number
|
|
203
|
+
}
|
|
204
|
+
export declare interface LiveActivityOptions extends LiveActivityState {
|
|
205
|
+
activityId: string
|
|
206
|
+
title: string
|
|
207
|
+
}
|
|
208
|
+
export declare interface LiveActivitiesApi {
|
|
209
|
+
start: (options: LiveActivityOptions) => Promise<{ id: string }>
|
|
210
|
+
update: (state: LiveActivityState) => Promise<void>
|
|
211
|
+
end: () => Promise<void>
|
|
212
|
+
}
|
|
213
|
+
export declare interface WatchConnectivityApi {
|
|
214
|
+
send: (message: Record<string, unknown>) => Promise<Record<string, unknown>>
|
|
215
|
+
updateContext: (context: Record<string, unknown>) => Promise<void>
|
|
216
|
+
isReachable: () => Promise<boolean>
|
|
217
|
+
onMessage: (callback: (message: Record<string, unknown>) => void) => () => void
|
|
218
|
+
onReachabilityChange: (callback: (reachable: boolean) => void) => () => void
|
|
219
|
+
}
|
|
220
|
+
export type HapticStyle = 'light' | 'medium' | 'heavy' | 'soft' | 'rigid';
|
|
221
|
+
export type HapticNotificationType = 'success' | 'warning' | 'error';
|
|
222
|
+
export type PermissionType = | 'camera'
|
|
223
|
+
| 'microphone'
|
|
224
|
+
| 'photos'
|
|
225
|
+
| 'location'
|
|
226
|
+
| 'locationAlways'
|
|
227
|
+
| 'notifications'
|
|
228
|
+
| 'contacts'
|
|
229
|
+
| 'calendar'
|
|
230
|
+
| 'reminders'
|
|
231
|
+
| 'bluetooth'
|
|
232
|
+
| 'motion'
|
|
233
|
+
| 'health';
|
|
234
|
+
export type PermissionStatus = 'granted' | 'denied' | 'undetermined' | 'restricted';
|
|
235
|
+
export type BiometricType = 'faceId' | 'touchId' | 'fingerprint' | 'face' | 'iris';
|
|
236
|
+
export type AppState = 'active' | 'inactive' | 'background';
|
|
237
|
+
export type HealthDataType = 'steps' | 'heartRate' | 'activeEnergy' | 'distance' | 'workouts';
|
|
238
|
+
export type HealthWorkoutType = 'running' | 'walking' | 'hiking' | 'cycling';
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stacksjs/mobile",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"version": "0.70.375",
|
|
6
|
+
"description": "Craft-powered native mobile runtime for Stacks and STX applications",
|
|
7
|
+
"author": "Chris Breuer",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/mobile#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
13
|
+
"directory": "./storage/framework/core/mobile"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"bun": "./dist/index.js",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"module": "dist/index.js",
|
|
24
|
+
"types": "dist/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"README.md",
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "bun build.ts",
|
|
31
|
+
"typecheck": "bun tsc --noEmit",
|
|
32
|
+
"test": "bun test"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@stacksjs/build": "0.70.375",
|
|
36
|
+
"better-dx": "^0.2.17",
|
|
37
|
+
"craft-native": ">=0.0.55"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"craft-native": ">=0.0.65"
|
|
41
|
+
},
|
|
42
|
+
"peerDependenciesMeta": {
|
|
43
|
+
"craft-native": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|