@tokamakdev/plugin-location 0.1.0-beta.130 → 0.1.0-beta.131
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/android/Exports.generated.kt +184 -180
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Generated by `tok plugin generate android`. Do not edit.
|
|
2
2
|
package com.tokamak.plugins.location
|
|
3
3
|
|
|
4
|
+
import com.tokamak.runtime.TokamakCodec
|
|
4
5
|
import com.tokamak.runtime.TokamakDispatch
|
|
5
6
|
import com.tokamak.runtime.TokamakHost
|
|
6
7
|
import com.tokamak.runtime.TokamakPluginBytesReply
|
|
@@ -10,7 +11,7 @@ import kotlin.reflect.KClass
|
|
|
10
11
|
import org.json.JSONArray
|
|
11
12
|
import org.json.JSONObject
|
|
12
13
|
|
|
13
|
-
/** Routes the Worker's requests to the methods [TokamakLocationPlugin] exports
|
|
14
|
+
/** Routes the Worker's requests to the methods [TokamakLocationPlugin] exports. */
|
|
14
15
|
class TokamakLocationPluginDispatch(host: TokamakHost) : TokamakDispatch<TokamakLocationPlugin>(TokamakLocationPlugin(host), host) {
|
|
15
16
|
override fun callBytes(method: String, payload: ByteArray, reply: TokamakPluginBytesReply): (() -> Unit)? {
|
|
16
17
|
val arguments by lazy(LazyThreadSafetyMode.NONE) { TokamakValue.arguments(payload) }
|
|
@@ -56,209 +57,212 @@ class TokamakLocationPluginDispatch(host: TokamakHost) : TokamakDispatch<Tokamak
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
/** Converts the values and events of [TokamakLocationPlugin] to and from JSON. */
|
|
61
|
+
companion object : TokamakCodec {
|
|
62
|
+
override fun eventPayload(name: String, event: Any): ByteArray =
|
|
63
|
+
when (name) {
|
|
64
|
+
"update" -> encodeEvent(name, event, LocationUpdate::class) { json(it) }
|
|
65
|
+
"region" -> encodeEvent(name, event, RegionTransition::class) { json(it) }
|
|
66
|
+
"error" -> encodeEvent(name, event, LocationErrorEvent::class) { json(it) }
|
|
67
|
+
else -> super.eventPayload(name, event)
|
|
68
|
+
}
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
override fun encodeValue(value: Any): Any =
|
|
71
|
+
when (value) {
|
|
72
|
+
is Coordinates -> json(value)
|
|
73
|
+
is LocationErrorEvent -> json(value)
|
|
74
|
+
is LocationPermission -> json(value)
|
|
75
|
+
is LocationUpdate -> json(value)
|
|
76
|
+
is MonitoredRegion -> json(value)
|
|
77
|
+
is PermissionRequest -> json(value)
|
|
78
|
+
is Position -> json(value)
|
|
79
|
+
is Region -> json(value)
|
|
80
|
+
is RegionTransition -> json(value)
|
|
81
|
+
is ServiceNotification -> json(value)
|
|
82
|
+
is SetupConfig -> json(value)
|
|
83
|
+
is UpdateOptions -> json(value)
|
|
84
|
+
else -> super.encodeValue(value)
|
|
85
|
+
}
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
87
|
+
override fun decodeValue(json: TokamakValue, type: KClass<*>): Any =
|
|
88
|
+
when (type) {
|
|
89
|
+
Coordinates::class -> json.asCoordinates()
|
|
90
|
+
LocationErrorEvent::class -> json.asLocationErrorEvent()
|
|
91
|
+
LocationPermission::class -> json.asLocationPermission()
|
|
92
|
+
LocationUpdate::class -> json.asLocationUpdate()
|
|
93
|
+
MonitoredRegion::class -> json.asMonitoredRegion()
|
|
94
|
+
PermissionRequest::class -> json.asPermissionRequest()
|
|
95
|
+
Position::class -> json.asPosition()
|
|
96
|
+
Region::class -> json.asRegion()
|
|
97
|
+
RegionTransition::class -> json.asRegionTransition()
|
|
98
|
+
ServiceNotification::class -> json.asServiceNotification()
|
|
99
|
+
SetupConfig::class -> json.asSetupConfig()
|
|
100
|
+
UpdateOptions::class -> json.asUpdateOptions()
|
|
101
|
+
else -> super.decodeValue(json, type)
|
|
102
|
+
}
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
private fun TokamakValue.asCoordinates(): Coordinates =
|
|
105
|
+
Coordinates(
|
|
106
|
+
latitude = this["latitude"].double(),
|
|
107
|
+
longitude = this["longitude"].double(),
|
|
108
|
+
accuracy = this["accuracy"].double(),
|
|
109
|
+
altitude = this["altitude"].nullable { it.double() },
|
|
110
|
+
altitudeAccuracy = this["altitudeAccuracy"].nullable { it.double() },
|
|
111
|
+
heading = this["heading"].nullable { it.double() },
|
|
112
|
+
speed = this["speed"].nullable { it.double() },
|
|
113
|
+
)
|
|
111
114
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
private fun json(value: Coordinates): JSONObject =
|
|
116
|
+
JSONObject()
|
|
117
|
+
.put("latitude", value.latitude)
|
|
118
|
+
.put("longitude", value.longitude)
|
|
119
|
+
.put("accuracy", value.accuracy)
|
|
120
|
+
.putOpt("altitude", value.altitude)
|
|
121
|
+
.putOpt("altitudeAccuracy", value.altitudeAccuracy)
|
|
122
|
+
.putOpt("heading", value.heading)
|
|
123
|
+
.putOpt("speed", value.speed)
|
|
121
124
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
private fun TokamakValue.asLocationErrorEvent(): LocationErrorEvent =
|
|
126
|
+
LocationErrorEvent(
|
|
127
|
+
name = this["name"].string(),
|
|
128
|
+
message = this["message"].string(),
|
|
129
|
+
)
|
|
127
130
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
private fun json(value: LocationErrorEvent): JSONObject =
|
|
132
|
+
JSONObject()
|
|
133
|
+
.put("name", value.name)
|
|
134
|
+
.put("message", value.message)
|
|
132
135
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
private fun TokamakValue.asLocationPermission(): LocationPermission =
|
|
137
|
+
LocationPermission(
|
|
138
|
+
inUse = this["inUse"].enum(Permission.entries),
|
|
139
|
+
background = this["background"].enum(Permission.entries),
|
|
140
|
+
precision = this["precision"].enum(Precision.entries),
|
|
141
|
+
)
|
|
139
142
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
private fun json(value: LocationPermission): JSONObject =
|
|
144
|
+
JSONObject()
|
|
145
|
+
.put("inUse", value.inUse.name)
|
|
146
|
+
.put("background", value.background.name)
|
|
147
|
+
.put("precision", value.precision.name)
|
|
145
148
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
private fun TokamakValue.asLocationUpdate(): LocationUpdate =
|
|
150
|
+
LocationUpdate(
|
|
151
|
+
positions = this["positions"].list { it.asPosition() },
|
|
152
|
+
)
|
|
150
153
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
private fun json(value: LocationUpdate): JSONObject =
|
|
155
|
+
JSONObject()
|
|
156
|
+
.put("positions", JSONArray(value.positions.map { json(it) }))
|
|
154
157
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
private fun TokamakValue.asMonitoredRegion(): MonitoredRegion =
|
|
159
|
+
MonitoredRegion(
|
|
160
|
+
id = this["id"].string(),
|
|
161
|
+
latitude = this["latitude"].double(),
|
|
162
|
+
longitude = this["longitude"].double(),
|
|
163
|
+
radius = this["radius"].double(),
|
|
164
|
+
onEntry = this["onEntry"].boolean(),
|
|
165
|
+
onExit = this["onExit"].boolean(),
|
|
166
|
+
)
|
|
164
167
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
private fun json(value: MonitoredRegion): JSONObject =
|
|
169
|
+
JSONObject()
|
|
170
|
+
.put("id", value.id)
|
|
171
|
+
.put("latitude", value.latitude)
|
|
172
|
+
.put("longitude", value.longitude)
|
|
173
|
+
.put("radius", value.radius)
|
|
174
|
+
.put("onEntry", value.onEntry)
|
|
175
|
+
.put("onExit", value.onExit)
|
|
173
176
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
private fun TokamakValue.asPermissionRequest(): PermissionRequest =
|
|
178
|
+
PermissionRequest(
|
|
179
|
+
background = this["background"].nullable { it.boolean() },
|
|
180
|
+
precision = this["precision"].nullable { it.enum(Precision.entries) },
|
|
181
|
+
)
|
|
179
182
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
private fun json(value: PermissionRequest): JSONObject =
|
|
184
|
+
JSONObject()
|
|
185
|
+
.putOpt("background", value.background)
|
|
186
|
+
.putOpt("precision", value.precision?.name)
|
|
184
187
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
private fun TokamakValue.asPosition(): Position =
|
|
189
|
+
Position(
|
|
190
|
+
coords = this["coords"].asCoordinates(),
|
|
191
|
+
timestamp = this["timestamp"].long(),
|
|
192
|
+
)
|
|
190
193
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
194
|
+
private fun json(value: Position): JSONObject =
|
|
195
|
+
JSONObject()
|
|
196
|
+
.put("coords", json(value.coords))
|
|
197
|
+
.put("timestamp", value.timestamp)
|
|
195
198
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
199
|
+
private fun TokamakValue.asRegion(): Region =
|
|
200
|
+
Region(
|
|
201
|
+
id = this["id"].string(),
|
|
202
|
+
latitude = this["latitude"].double(),
|
|
203
|
+
longitude = this["longitude"].double(),
|
|
204
|
+
radius = this["radius"].double(),
|
|
205
|
+
onEntry = this["onEntry"].nullable { it.boolean() },
|
|
206
|
+
onExit = this["onExit"].nullable { it.boolean() },
|
|
207
|
+
)
|
|
205
208
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
private fun json(value: Region): JSONObject =
|
|
210
|
+
JSONObject()
|
|
211
|
+
.put("id", value.id)
|
|
212
|
+
.put("latitude", value.latitude)
|
|
213
|
+
.put("longitude", value.longitude)
|
|
214
|
+
.put("radius", value.radius)
|
|
215
|
+
.putOpt("onEntry", value.onEntry)
|
|
216
|
+
.putOpt("onExit", value.onExit)
|
|
214
217
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
private fun TokamakValue.asRegionTransition(): RegionTransition =
|
|
219
|
+
RegionTransition(
|
|
220
|
+
id = this["id"].string(),
|
|
221
|
+
transition = this["transition"].enum(Transition.entries),
|
|
222
|
+
timestamp = this["timestamp"].long(),
|
|
223
|
+
)
|
|
221
224
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
private fun json(value: RegionTransition): JSONObject =
|
|
226
|
+
JSONObject()
|
|
227
|
+
.put("id", value.id)
|
|
228
|
+
.put("transition", value.transition.name)
|
|
229
|
+
.put("timestamp", value.timestamp)
|
|
227
230
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
private fun TokamakValue.asServiceNotification(): ServiceNotification =
|
|
232
|
+
ServiceNotification(
|
|
233
|
+
title = this["title"].string(),
|
|
234
|
+
body = this["body"].string(),
|
|
235
|
+
channel = this["channel"].string(),
|
|
236
|
+
)
|
|
234
237
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
private fun json(value: ServiceNotification): JSONObject =
|
|
239
|
+
JSONObject()
|
|
240
|
+
.put("title", value.title)
|
|
241
|
+
.put("body", value.body)
|
|
242
|
+
.put("channel", value.channel)
|
|
240
243
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
244
|
+
private fun TokamakValue.asSetupConfig(): SetupConfig =
|
|
245
|
+
SetupConfig(
|
|
246
|
+
significantChanges = this["significantChanges"].nullable { it.boolean() },
|
|
247
|
+
)
|
|
245
248
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
+
private fun json(value: SetupConfig): JSONObject =
|
|
250
|
+
JSONObject()
|
|
251
|
+
.putOpt("significantChanges", value.significantChanges)
|
|
249
252
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
private fun TokamakValue.asUpdateOptions(): UpdateOptions =
|
|
254
|
+
UpdateOptions(
|
|
255
|
+
accuracy = this["accuracy"].nullable { it.enum(Accuracy.entries) },
|
|
256
|
+
distance = this["distance"].nullable { it.double() },
|
|
257
|
+
interval = this["interval"].nullable { it.long() },
|
|
258
|
+
foregroundService = this["foregroundService"].nullable { it.asServiceNotification() },
|
|
259
|
+
)
|
|
257
260
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
private fun json(value: UpdateOptions): JSONObject =
|
|
262
|
+
JSONObject()
|
|
263
|
+
.putOpt("accuracy", value.accuracy?.name)
|
|
264
|
+
.putOpt("distance", value.distance)
|
|
265
|
+
.putOpt("interval", value.interval)
|
|
266
|
+
.putOpt("foregroundService", value.foregroundService?.let { json(it) })
|
|
267
|
+
}
|
|
264
268
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokamakdev/plugin-location",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.131",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/mantty/tokamak.git",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"./events": "./src/events.ts"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@tokamakdev/plugin": "0.1.0-beta.
|
|
17
|
+
"@tokamakdev/plugin": "0.1.0-beta.131"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"android",
|