@ateam-ai-mobile/expo 0.1.7 → 0.1.8
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/bootstrap.js +841 -323
- package/dist/bootstrap.js.map +1 -1
- package/dist/bootstrap.mjs +9 -7
- package/dist/bootstrap.mjs.map +1 -1
- package/dist/chunk-7FWYEHN5.mjs +203 -0
- package/dist/chunk-7FWYEHN5.mjs.map +1 -0
- package/dist/{chunk-4XYXJYN5.mjs → chunk-C7M5WAHA.mjs} +583 -298
- package/dist/chunk-C7M5WAHA.mjs.map +1 -0
- package/dist/{chunk-5HM6UA2K.mjs → chunk-GF2MPTAB.mjs} +83 -7
- package/dist/chunk-GF2MPTAB.mjs.map +1 -0
- package/dist/chunk-J6XRNX7P.mjs +19 -0
- package/dist/chunk-J6XRNX7P.mjs.map +1 -0
- package/dist/{chunk-TZXWVYYR.mjs → chunk-PCAEUX2N.mjs} +1 -1
- package/dist/chunk-PCAEUX2N.mjs.map +1 -0
- package/dist/{chunk-VQJPSLHP.mjs → chunk-Z5AI2SXX.mjs} +13 -4
- package/dist/chunk-Z5AI2SXX.mjs.map +1 -0
- package/dist/createBridge.js +41 -10
- package/dist/createBridge.js.map +1 -1
- package/dist/createBridge.mjs +5 -1
- package/dist/createBridge.mjs.map +1 -1
- package/dist/device/createDeviceProvider.js +278 -17
- package/dist/device/createDeviceProvider.js.map +1 -1
- package/dist/device/createDeviceProvider.mjs +5 -3
- package/dist/device-bridge/index.d.mts +13 -1
- package/dist/device-bridge/index.d.ts +13 -1
- package/dist/device-bridge/index.js +49 -12
- package/dist/device-bridge/index.js.map +1 -1
- package/dist/device-bridge/index.mjs +3 -1
- package/dist/index.d.mts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +594 -297
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/maps/index.d.mts +56 -0
- package/dist/maps/index.d.ts +56 -0
- package/dist/maps/index.js +95 -0
- package/dist/maps/index.js.map +1 -0
- package/dist/maps/index.mjs +17 -0
- package/dist/maps/index.mjs.map +1 -0
- package/dist/vision/index.d.mts +4 -2
- package/dist/vision/index.d.ts +4 -2
- package/dist/vision/index.js.map +1 -1
- package/dist/vision/index.mjs +1 -1
- package/expo-module.config.json +1 -1
- package/ios/AdaMaps/AdaMapsModule.swift +180 -0
- package/ios/AdaMaps.podspec +25 -0
- package/ios/AdaVision.podspec +4 -0
- package/ios/AdaVisionModule.swift +63 -9
- package/package.json +10 -4
- package/src/args.ts +56 -0
- package/src/createBridge.ts +3 -1
- package/src/device/createDeviceProvider.ts +88 -3
- package/src/device-bridge/collectors/location.ts +21 -9
- package/src/device-state/collectors.ts +5 -1
- package/src/device-state/domains/deviceContext.ts +5 -3
- package/src/device-state/domains/interaction.ts +2 -1
- package/src/device-state/domains/spatial.ts +200 -116
- package/src/device-state/domains/visual.ts +34 -13
- package/src/device-state/events.ts +49 -0
- package/src/device-state/headingSource.ts +43 -8
- package/src/device-state/index.ts +3 -2
- package/src/device-state/replay.ts +76 -11
- package/src/device-state/spatialEvents.ts +300 -0
- package/src/geo.ts +23 -0
- package/src/maps/index.ts +81 -0
- package/src/maps/normalize.ts +225 -0
- package/src/vision/index.ts +4 -2
- package/dist/chunk-4XYXJYN5.mjs.map +0 -1
- package/dist/chunk-5HM6UA2K.mjs.map +0 -1
- package/dist/chunk-TZXWVYYR.mjs.map +0 -1
- package/dist/chunk-VQJPSLHP.mjs.map +0 -1
|
@@ -94,7 +94,7 @@ var init_cookies = __esm({
|
|
|
94
94
|
var nfc_exports = {};
|
|
95
95
|
__export(nfc_exports, {
|
|
96
96
|
isEnabled: () => isEnabled,
|
|
97
|
-
isSupported: () =>
|
|
97
|
+
isSupported: () => isSupported3,
|
|
98
98
|
readOnce: () => readOnce
|
|
99
99
|
});
|
|
100
100
|
async function ensureInit() {
|
|
@@ -109,7 +109,7 @@ async function ensureInit() {
|
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
async function
|
|
112
|
+
async function isSupported3() {
|
|
113
113
|
try {
|
|
114
114
|
return await import_react_native_nfc_manager.default.isSupported();
|
|
115
115
|
} catch {
|
|
@@ -177,7 +177,7 @@ __export(createDeviceProvider_exports, {
|
|
|
177
177
|
});
|
|
178
178
|
module.exports = __toCommonJS(createDeviceProvider_exports);
|
|
179
179
|
var Haptics = __toESM(require("expo-haptics"));
|
|
180
|
-
var
|
|
180
|
+
var ExpoLocation3 = __toESM(require("expo-location"));
|
|
181
181
|
var ImagePicker = __toESM(require("expo-image-picker"));
|
|
182
182
|
var Notifications = __toESM(require("expo-notifications"));
|
|
183
183
|
var DocumentPicker = __toESM(require("expo-document-picker"));
|
|
@@ -312,6 +312,202 @@ async function detectObjects(id, maxItems = 10, minConfidence = 0.25) {
|
|
|
312
312
|
return native.detectObjects(id, maxItems, minConfidence);
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
+
// src/maps/index.ts
|
|
316
|
+
var import_react_native = require("react-native");
|
|
317
|
+
var import_expo_modules_core2 = require("expo-modules-core");
|
|
318
|
+
var ExpoLocation = __toESM(require("expo-location"));
|
|
319
|
+
|
|
320
|
+
// src/geo.ts
|
|
321
|
+
function distanceOf(path) {
|
|
322
|
+
const R = 6371e3;
|
|
323
|
+
let total = 0;
|
|
324
|
+
for (let i = 1; i < path.length; i++) {
|
|
325
|
+
const a = path[i - 1], b = path[i];
|
|
326
|
+
const dLat = (b.latitude - a.latitude) * Math.PI / 180;
|
|
327
|
+
const dLon = (b.longitude - a.longitude) * Math.PI / 180;
|
|
328
|
+
const la1 = a.latitude * Math.PI / 180, la2 = b.latitude * Math.PI / 180;
|
|
329
|
+
const h = Math.sin(dLat / 2) ** 2 + Math.cos(la1) * Math.cos(la2) * Math.sin(dLon / 2) ** 2;
|
|
330
|
+
total += 2 * R * Math.asin(Math.sqrt(h));
|
|
331
|
+
}
|
|
332
|
+
return Math.round(total);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// src/args.ts
|
|
336
|
+
var shown = (v) => {
|
|
337
|
+
let s;
|
|
338
|
+
try {
|
|
339
|
+
s = JSON.stringify(v, (_k, x) => typeof x === "number" && !Number.isFinite(x) ? `${x}` : x)?.replace(/"\\u0001(NaN|-?Infinity)\\u0001"/g, "$1");
|
|
340
|
+
} catch {
|
|
341
|
+
}
|
|
342
|
+
s = s ?? String(v);
|
|
343
|
+
return s.length > 80 ? `${s.slice(0, 77)}...` : s;
|
|
344
|
+
};
|
|
345
|
+
function refuseArgument(capability, verb, problem, nothing) {
|
|
346
|
+
const e = new Error(`${capability}.${verb}: ${problem}; ${nothing}.`);
|
|
347
|
+
e.code = "INVALID_ARGUMENT";
|
|
348
|
+
return e;
|
|
349
|
+
}
|
|
350
|
+
function countArg(capability, verb, name, value, def, max, nothing) {
|
|
351
|
+
const v = value ?? def;
|
|
352
|
+
if (typeof v !== "number" || !Number.isFinite(v) || v < 1) {
|
|
353
|
+
throw refuseArgument(capability, verb, `${name} must be a number from 1 (at most ${max} are used), not ${shown(value)}`, nothing);
|
|
354
|
+
}
|
|
355
|
+
return Math.min(max, Math.floor(v));
|
|
356
|
+
}
|
|
357
|
+
function fractionArg(capability, verb, name, value, def, nothing) {
|
|
358
|
+
const v = value ?? def;
|
|
359
|
+
if (typeof v !== "number" || !Number.isFinite(v) || v < 0 || v > 1) {
|
|
360
|
+
throw refuseArgument(capability, verb, `${name} must be a number from 0 to 1, not ${shown(value)}`, nothing);
|
|
361
|
+
}
|
|
362
|
+
return v;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// src/maps/normalize.ts
|
|
366
|
+
var SEARCH_RADIUS_DEFAULT_M = 3e3;
|
|
367
|
+
var SEARCH_RADIUS_MAX_M = 1e5;
|
|
368
|
+
var SEARCH_LIMIT_DEFAULT = 8;
|
|
369
|
+
var SEARCH_LIMIT_MAX = 25;
|
|
370
|
+
var text = (v) => typeof v === "string" && v.trim() !== "" ? v : null;
|
|
371
|
+
var refuseArgument2 = (verb, problem, nothing) => refuseArgument("maps", verb, problem, nothing);
|
|
372
|
+
function coordinateArg(verb, name, value, nothing) {
|
|
373
|
+
const c = value;
|
|
374
|
+
const latitude = c?.latitude, longitude = c?.longitude;
|
|
375
|
+
if (typeof latitude === "number" && Number.isFinite(latitude) && Math.abs(latitude) <= 90 && typeof longitude === "number" && Number.isFinite(longitude) && Math.abs(longitude) <= 180) {
|
|
376
|
+
return { latitude, longitude };
|
|
377
|
+
}
|
|
378
|
+
throw refuseArgument2(
|
|
379
|
+
verb,
|
|
380
|
+
`${name} must be { latitude, longitude } numbers (latitude -90..90, longitude -180..180), not ${shown(value)}`,
|
|
381
|
+
nothing
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
function searchArgs(query, opts) {
|
|
385
|
+
const nothing = "nothing was searched";
|
|
386
|
+
if (typeof query !== "string" || query.trim() === "") {
|
|
387
|
+
throw refuseArgument2("search", `query must be a non-empty string, not ${shown(query)}`, nothing);
|
|
388
|
+
}
|
|
389
|
+
const near = opts?.near == null ? null : coordinateArg("search", "near", opts.near, nothing);
|
|
390
|
+
const radiusM = opts?.radiusM ?? SEARCH_RADIUS_DEFAULT_M;
|
|
391
|
+
if (typeof radiusM !== "number" || !(radiusM > 0 && radiusM <= SEARCH_RADIUS_MAX_M)) {
|
|
392
|
+
throw refuseArgument2(
|
|
393
|
+
"search",
|
|
394
|
+
`radiusM must be metres above 0 and at most ${SEARCH_RADIUS_MAX_M}, not ${shown(radiusM)}`,
|
|
395
|
+
nothing
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
const limit = countArg("maps", "search", "limit", opts?.limit, SEARCH_LIMIT_DEFAULT, SEARCH_LIMIT_MAX, nothing);
|
|
399
|
+
return { query, near, radiusM, limit };
|
|
400
|
+
}
|
|
401
|
+
var point = (c) => ({
|
|
402
|
+
latitude: Number(c.latitude),
|
|
403
|
+
longitude: Number(c.longitude)
|
|
404
|
+
});
|
|
405
|
+
function toMapsAddress(raw) {
|
|
406
|
+
const r = raw ?? {};
|
|
407
|
+
return {
|
|
408
|
+
name: text(r.name),
|
|
409
|
+
street: text(r.street),
|
|
410
|
+
streetNumber: text(r.streetNumber),
|
|
411
|
+
district: text(r.district),
|
|
412
|
+
city: text(r.city),
|
|
413
|
+
region: text(r.region),
|
|
414
|
+
postalCode: text(r.postalCode),
|
|
415
|
+
country: text(r.country),
|
|
416
|
+
isoCountryCode: text(r.isoCountryCode)
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function toMapsCategory(raw) {
|
|
420
|
+
const c = text(raw);
|
|
421
|
+
return c ? c.replace(/^MKPOICategory/, "") || null : null;
|
|
422
|
+
}
|
|
423
|
+
function toMapsPlaces(raw, near) {
|
|
424
|
+
return (raw ?? []).map((r) => {
|
|
425
|
+
const coordinate = point(r);
|
|
426
|
+
return {
|
|
427
|
+
name: text(r.name),
|
|
428
|
+
coordinate,
|
|
429
|
+
address: toMapsAddress(r.address),
|
|
430
|
+
category: toMapsCategory(r.category),
|
|
431
|
+
distanceM: near ? distanceOf([near, coordinate]) : null
|
|
432
|
+
};
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
function toReverseGeocodedPlace(at, address) {
|
|
436
|
+
return {
|
|
437
|
+
name: address.name,
|
|
438
|
+
coordinate: point(at),
|
|
439
|
+
address,
|
|
440
|
+
category: null,
|
|
441
|
+
distanceM: null
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function toMapsRoute(raw) {
|
|
445
|
+
const steps = (raw.steps ?? []).map((s) => ({
|
|
446
|
+
instructions: typeof s.instructions === "string" ? s.instructions : "",
|
|
447
|
+
distanceM: Number(s.distance),
|
|
448
|
+
notice: text(s.notice),
|
|
449
|
+
polyline: (s.polyline ?? []).map(point)
|
|
450
|
+
}));
|
|
451
|
+
return {
|
|
452
|
+
mode: "walking",
|
|
453
|
+
distanceM: Number(raw.distance),
|
|
454
|
+
expectedTravelTimeMs: Math.round(Number(raw.expectedTravelTime) * 1e3),
|
|
455
|
+
steps,
|
|
456
|
+
polyline: (raw.polyline ?? []).map(point)
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function mapsFailure(verb, err) {
|
|
460
|
+
const nativeCode = String(err?.code ?? "");
|
|
461
|
+
const detail = String(err?.message ?? err ?? "").trim();
|
|
462
|
+
let code;
|
|
463
|
+
let why;
|
|
464
|
+
if (nativeCode === "THROTTLED") {
|
|
465
|
+
code = "THROTTLED";
|
|
466
|
+
why = "Apple is rate-limiting map requests from this app \u2014 wait before retrying";
|
|
467
|
+
} else if (nativeCode === "OFFLINE") {
|
|
468
|
+
code = "OFFLINE";
|
|
469
|
+
why = "the map service could not be reached \u2014 the phone may be offline";
|
|
470
|
+
} else if (nativeCode === "ERR_GEOCODING_NETWORK") {
|
|
471
|
+
code = "OFFLINE";
|
|
472
|
+
why = "the geocoder could not be reached \u2014 the phone may be offline, or Apple is rate-limiting requests (iOS reports both the same way)";
|
|
473
|
+
} else {
|
|
474
|
+
code = "UNAVAILABLE";
|
|
475
|
+
why = "the map service failed";
|
|
476
|
+
}
|
|
477
|
+
const failure = new Error(
|
|
478
|
+
`maps.${verb} could not look: ${why}. This is not "found nothing".` + (detail ? ` (${nativeCode ? nativeCode + ": " : ""}${detail})` : "")
|
|
479
|
+
);
|
|
480
|
+
failure.code = code;
|
|
481
|
+
return failure;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// src/maps/index.ts
|
|
485
|
+
var native2 = (0, import_expo_modules_core2.requireOptionalNativeModule)("AdaMaps");
|
|
486
|
+
function missingReason() {
|
|
487
|
+
if (import_react_native.Platform.OS !== "ios") return `iOS (Apple MapKit) \u2014 ${import_react_native.Platform.OS} has no implementation yet`;
|
|
488
|
+
if (!native2) return "the app build with the AdaMaps module (this build predates it \u2014 a native rebuild is needed)";
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
function isSupported2() {
|
|
492
|
+
try {
|
|
493
|
+
return missingReason() === null && (native2?.isSupported() ?? false);
|
|
494
|
+
} catch {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
async function search(query, near, radiusM, limit) {
|
|
499
|
+
if (!native2) throw new Error("ada-maps native module not present in this build");
|
|
500
|
+
return near ? native2.search(query, near.latitude, near.longitude, true, radiusM, limit) : native2.search(query, 0, 0, false, radiusM, limit);
|
|
501
|
+
}
|
|
502
|
+
async function route(from, to) {
|
|
503
|
+
if (!native2) throw new Error("ada-maps native module not present in this build");
|
|
504
|
+
return native2.route(from.latitude, from.longitude, to.latitude, to.longitude);
|
|
505
|
+
}
|
|
506
|
+
async function reverseGeocode(at) {
|
|
507
|
+
const [first] = await ExpoLocation.reverseGeocodeAsync({ latitude: at.latitude, longitude: at.longitude });
|
|
508
|
+
return first ? toMapsAddress(first) : null;
|
|
509
|
+
}
|
|
510
|
+
|
|
315
511
|
// src/device-bridge/actions/messaging.ts
|
|
316
512
|
var SMS = __toESM(require("expo-sms"));
|
|
317
513
|
|
|
@@ -320,10 +516,10 @@ var ExpoCalendar = __toESM(require("expo-calendar"));
|
|
|
320
516
|
|
|
321
517
|
// src/device-bridge/actions/navigation.ts
|
|
322
518
|
var Linking = __toESM(require("expo-linking"));
|
|
323
|
-
var
|
|
519
|
+
var import_react_native2 = require("react-native");
|
|
324
520
|
|
|
325
521
|
// src/device-bridge/collectors/health.ts
|
|
326
|
-
var
|
|
522
|
+
var import_react_native3 = require("react-native");
|
|
327
523
|
|
|
328
524
|
// src/device-bridge/background.ts
|
|
329
525
|
var TaskManager = __toESM(require("expo-task-manager"));
|
|
@@ -337,7 +533,13 @@ var ExpoContacts = __toESM(require("expo-contacts"));
|
|
|
337
533
|
var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
|
|
338
534
|
|
|
339
535
|
// src/device-bridge/collectors/location.ts
|
|
340
|
-
var
|
|
536
|
+
var ExpoLocation2 = __toESM(require("expo-location"));
|
|
537
|
+
var WATCH_TIER = {
|
|
538
|
+
navigation: ExpoLocation2.Accuracy.BestForNavigation,
|
|
539
|
+
high: ExpoLocation2.Accuracy.High,
|
|
540
|
+
balanced: ExpoLocation2.Accuracy.Balanced,
|
|
541
|
+
low: ExpoLocation2.Accuracy.Low
|
|
542
|
+
};
|
|
341
543
|
|
|
342
544
|
// src/device-bridge/collectors/battery.ts
|
|
343
545
|
var ExpoBattery = __toESM(require("expo-battery"));
|
|
@@ -349,7 +551,7 @@ var ExpoNetwork = __toESM(require("expo-network"));
|
|
|
349
551
|
var ExpoNotifications = __toESM(require("expo-notifications"));
|
|
350
552
|
|
|
351
553
|
// src/device-bridge/collectors/appEngagement.ts
|
|
352
|
-
var
|
|
554
|
+
var import_react_native4 = require("react-native");
|
|
353
555
|
var import_async_storage2 = __toESM(require("@react-native-async-storage/async-storage"));
|
|
354
556
|
|
|
355
557
|
// src/device-bridge/collectors/camera.ts
|
|
@@ -464,9 +666,9 @@ function stubApi(capability) {
|
|
|
464
666
|
}
|
|
465
667
|
function createLocationAPI() {
|
|
466
668
|
const ensurePermission = async () => {
|
|
467
|
-
const existing = await
|
|
669
|
+
const existing = await ExpoLocation3.getForegroundPermissionsAsync();
|
|
468
670
|
if (existing.status === "granted") return;
|
|
469
|
-
const asked = await
|
|
671
|
+
const asked = await ExpoLocation3.requestForegroundPermissionsAsync();
|
|
470
672
|
if (asked.status !== "granted") {
|
|
471
673
|
throw new Error(
|
|
472
674
|
"Location permission was not granted. Enable it for this app in Settings > Privacy > Location Services."
|
|
@@ -476,8 +678,8 @@ function createLocationAPI() {
|
|
|
476
678
|
return {
|
|
477
679
|
async getCurrent(opts) {
|
|
478
680
|
await ensurePermission();
|
|
479
|
-
const fix = await
|
|
480
|
-
accuracy: opts?.accuracy === "high" ?
|
|
681
|
+
const fix = await ExpoLocation3.getCurrentPositionAsync({
|
|
682
|
+
accuracy: opts?.accuracy === "high" ? ExpoLocation3.Accuracy.High : ExpoLocation3.Accuracy.Balanced
|
|
481
683
|
});
|
|
482
684
|
return {
|
|
483
685
|
latitude: fix.coords.latitude,
|
|
@@ -492,8 +694,8 @@ function createLocationAPI() {
|
|
|
492
694
|
try {
|
|
493
695
|
await ensurePermission();
|
|
494
696
|
if (cancelled) return;
|
|
495
|
-
subscription = await
|
|
496
|
-
{ accuracy:
|
|
697
|
+
subscription = await ExpoLocation3.watchPositionAsync(
|
|
698
|
+
{ accuracy: ExpoLocation3.Accuracy.Balanced },
|
|
497
699
|
(fix) => cb({ latitude: fix.coords.latitude, longitude: fix.coords.longitude })
|
|
498
700
|
);
|
|
499
701
|
if (cancelled) {
|
|
@@ -905,18 +1107,27 @@ function createVisionAPI() {
|
|
|
905
1107
|
// pixels). [] = looked, found no text (a real finding); throws = could not
|
|
906
1108
|
// look (unknown/aged-out id). describe (VNClassifyImage) is the next pass.
|
|
907
1109
|
async readText(frameId, opts) {
|
|
908
|
-
|
|
1110
|
+
const langs = opts?.languages;
|
|
1111
|
+
if (langs != null && (!Array.isArray(langs) || langs.some((l) => typeof l !== "string"))) {
|
|
1112
|
+
throw refuseArgument("vision", "readText", `languages must be an array of language codes, not ${shown(langs)}`, "nothing was read");
|
|
1113
|
+
}
|
|
1114
|
+
return readText(frameId, langs);
|
|
909
1115
|
},
|
|
910
1116
|
// describe: on-device labels (VNClassifyImage), not prose — the sentence is
|
|
911
1117
|
// the skill's job. [] = looked, recognised nothing.
|
|
912
1118
|
async describe(frameId, opts) {
|
|
913
|
-
return describe(frameId, opts?.maxLabels
|
|
1119
|
+
return describe(frameId, countArg("vision", "describe", "maxLabels", opts?.maxLabels, 5, 50, "nothing was labelled"));
|
|
914
1120
|
},
|
|
915
1121
|
// detectObjects: on-device located objects (bundled detector), each with a
|
|
916
1122
|
// box — what a guidance loop reads to say WHERE a thing is, not just that the
|
|
917
1123
|
// scene contains it. [] = looked, found nothing; throws = could not look.
|
|
918
1124
|
async detectObjects(frameId, opts) {
|
|
919
|
-
|
|
1125
|
+
const nothing = "nothing was detected";
|
|
1126
|
+
return detectObjects(
|
|
1127
|
+
frameId,
|
|
1128
|
+
countArg("vision", "detectObjects", "maxItems", opts?.maxItems, 10, 50, nothing),
|
|
1129
|
+
fractionArg("vision", "detectObjects", "minConfidence", opts?.minConfidence, 0.25, nothing)
|
|
1130
|
+
);
|
|
920
1131
|
},
|
|
921
1132
|
// assessQuality: resolve the frame id to its LOCAL file, measure on-device,
|
|
922
1133
|
// and record the result back onto the frame so a later read of
|
|
@@ -934,6 +1145,55 @@ function createVisionAPI() {
|
|
|
934
1145
|
}
|
|
935
1146
|
};
|
|
936
1147
|
}
|
|
1148
|
+
function createMapsAPI() {
|
|
1149
|
+
const refuseIfMissing = (verb, nothing) => {
|
|
1150
|
+
const missing = missingReason();
|
|
1151
|
+
if (missing) {
|
|
1152
|
+
throw new CapabilityUnavailableError(`maps.${verb}`, `maps.${verb} needs ${missing}; ${nothing}.`);
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
return {
|
|
1156
|
+
async isSupported() {
|
|
1157
|
+
return isSupported2();
|
|
1158
|
+
},
|
|
1159
|
+
// [] = Apple looked and found nothing (a real finding); throws = could not
|
|
1160
|
+
// look. The defaults (radiusM 3000, limit 8) live in searchArgs.
|
|
1161
|
+
async search(query, opts) {
|
|
1162
|
+
const args = searchArgs(query, opts);
|
|
1163
|
+
refuseIfMissing("search", "nothing was searched");
|
|
1164
|
+
const raw = await search(args.query, args.near, args.radiusM, args.limit).catch((err) => {
|
|
1165
|
+
throw mapsFailure("search", err);
|
|
1166
|
+
});
|
|
1167
|
+
return toMapsPlaces(raw, args.near);
|
|
1168
|
+
},
|
|
1169
|
+
// null = nothing at that point; throws = could not look.
|
|
1170
|
+
async reverseGeocode(at) {
|
|
1171
|
+
const point2 = coordinateArg("reverseGeocode", "at", at, "nothing was looked up");
|
|
1172
|
+
const address = await reverseGeocode(point2).catch((err) => {
|
|
1173
|
+
throw mapsFailure("reverseGeocode", err);
|
|
1174
|
+
});
|
|
1175
|
+
return address ? toReverseGeocodedPlace(point2, address) : null;
|
|
1176
|
+
},
|
|
1177
|
+
// null = Apple found no route. Never an empty 0 m route, which would read as
|
|
1178
|
+
// "you have arrived". A remote bundle can pass any string as `mode`, so a
|
|
1179
|
+
// mode this build cannot honour refuses rather than silently walking.
|
|
1180
|
+
async route(from, to, opts) {
|
|
1181
|
+
if (opts?.mode !== void 0 && opts.mode !== "walking") {
|
|
1182
|
+
throw new CapabilityUnavailableError(
|
|
1183
|
+
"maps.route",
|
|
1184
|
+
`maps.route supports walking only, not "${String(opts.mode)}"; no route was requested.`
|
|
1185
|
+
);
|
|
1186
|
+
}
|
|
1187
|
+
const a = coordinateArg("route", "from", from, "no route was requested");
|
|
1188
|
+
const b = coordinateArg("route", "to", to, "no route was requested");
|
|
1189
|
+
refuseIfMissing("route", "no route was requested");
|
|
1190
|
+
const raw = await route(a, b).catch((err) => {
|
|
1191
|
+
throw mapsFailure("route", err);
|
|
1192
|
+
});
|
|
1193
|
+
return raw ? toMapsRoute(raw) : null;
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
937
1197
|
function createDeviceProvider(config) {
|
|
938
1198
|
const connectivity = createConnectivityAPI(config?.reachabilityUrl);
|
|
939
1199
|
return {
|
|
@@ -956,7 +1216,8 @@ function createDeviceProvider(config) {
|
|
|
956
1216
|
scanner: createScannerAPI(),
|
|
957
1217
|
nfc: createNfcAPI(),
|
|
958
1218
|
bluetooth: createBluetoothAPI(),
|
|
959
|
-
vision: createVisionAPI()
|
|
1219
|
+
vision: createVisionAPI(),
|
|
1220
|
+
maps: createMapsAPI()
|
|
960
1221
|
};
|
|
961
1222
|
}
|
|
962
1223
|
// Annotate the CommonJS export names for ESM import in node:
|