@ateam-ai-mobile/expo 0.1.18 → 0.1.20
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.d.mts +11 -0
- package/dist/bootstrap.d.ts +11 -0
- package/dist/bootstrap.js +12 -2
- package/dist/bootstrap.js.map +1 -1
- package/dist/bootstrap.mjs +11 -3
- package/dist/bootstrap.mjs.map +1 -1
- package/dist/capabilities/index.d.mts +112 -0
- package/dist/capabilities/index.d.ts +112 -0
- package/dist/{chunk-Z5AI2SXX.mjs → capabilities/index.js} +995 -225
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/index.mjs +595 -0
- package/dist/capabilities/index.mjs.map +1 -0
- package/dist/chunk-AE55BKYV.mjs +24 -0
- package/dist/chunk-AE55BKYV.mjs.map +1 -0
- package/dist/chunk-GA7DS3PA.mjs +14 -0
- package/dist/chunk-GA7DS3PA.mjs.map +1 -0
- package/dist/chunk-GW7YGXOW.mjs +47 -0
- package/dist/chunk-GW7YGXOW.mjs.map +1 -0
- package/dist/chunk-IJPR5ITF.mjs +19 -0
- package/dist/chunk-IJPR5ITF.mjs.map +1 -0
- package/dist/chunk-KRGCWVDJ.mjs +815 -0
- package/dist/chunk-KRGCWVDJ.mjs.map +1 -0
- package/dist/chunk-RZDAY2GS.mjs +1009 -0
- package/dist/chunk-RZDAY2GS.mjs.map +1 -0
- package/dist/{chunk-DLDG77DX.mjs → chunk-SOUNJY7R.mjs} +6 -6
- package/dist/device/createDeviceProvider.mjs +4 -3
- package/dist/device-bridge/collectors/health.d.mts +1 -1
- package/dist/device-bridge/collectors/health.d.ts +1 -1
- package/dist/device-bridge/deviceId.d.mts +23 -0
- package/dist/device-bridge/deviceId.d.ts +23 -0
- package/dist/device-bridge/deviceId.js +45 -0
- package/dist/device-bridge/deviceId.js.map +1 -0
- package/dist/device-bridge/deviceId.mjs +12 -0
- package/dist/device-bridge/deviceId.mjs.map +1 -0
- package/dist/device-bridge/index.d.mts +2 -2
- package/dist/device-bridge/index.d.ts +2 -2
- package/dist/device-bridge/index.mjs +7 -5
- package/dist/push/index.d.mts +24 -0
- package/dist/push/index.d.ts +24 -0
- package/dist/push/index.js +224 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/index.mjs +174 -0
- package/dist/push/index.mjs.map +1 -0
- package/dist/push/silentSync.d.mts +8 -0
- package/dist/push/silentSync.d.ts +8 -0
- package/dist/push/silentSync.js +1075 -0
- package/dist/push/silentSync.js.map +1 -0
- package/dist/push/silentSync.mjs +67 -0
- package/dist/push/silentSync.mjs.map +1 -0
- package/dist/{types-BRanJYTn.d.mts → types-DFsbxj1m.d.mts} +1 -1
- package/dist/{types-BRanJYTn.d.ts → types-DFsbxj1m.d.ts} +1 -1
- package/package.json +29 -6
- package/src/bootstrap.ts +19 -0
- package/src/capabilities/CapabilitiesSetup.tsx +239 -0
- package/src/capabilities/CapabilityCard.tsx +188 -0
- package/src/capabilities/choices.ts +65 -0
- package/src/capabilities/config.ts +32 -0
- package/src/capabilities/index.ts +22 -0
- package/src/capabilities/store.ts +358 -0
- package/src/device-bridge/deviceId.ts +33 -0
- package/src/device-bridge/plugin.ts +1 -1
- package/src/push/index.ts +18 -0
- package/src/push/messaging.ts +49 -0
- package/src/push/registration.ts +31 -0
- package/src/push/silentSync.ts +83 -0
- package/src/push/usePushNotifications.ts +224 -0
- package/dist/chunk-Z5AI2SXX.mjs.map +0 -1
- /package/dist/{chunk-DLDG77DX.mjs.map → chunk-SOUNJY7R.mjs.map} +0 -0
|
@@ -1,30 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/capabilities/index.ts
|
|
31
|
+
var capabilities_exports2 = {};
|
|
32
|
+
__export(capabilities_exports2, {
|
|
33
|
+
CapabilitiesSetup: () => CapabilitiesSetup,
|
|
34
|
+
CapabilityCard: () => CapabilityCard,
|
|
35
|
+
configureDeviceSync: () => configureDeviceSync,
|
|
36
|
+
useCapabilitiesStore: () => useCapabilitiesStore
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(capabilities_exports2);
|
|
39
|
+
|
|
40
|
+
// src/capabilities/store.ts
|
|
41
|
+
var import_zustand = require("zustand");
|
|
42
|
+
var import_async_storage4 = __toESM(require("@react-native-async-storage/async-storage"));
|
|
43
|
+
var import_core = require("@ateam-ai-mobile/core");
|
|
17
44
|
|
|
18
45
|
// src/device-bridge/relay-client.ts
|
|
19
46
|
var RelayClient = class {
|
|
20
|
-
constructor(
|
|
47
|
+
constructor(config2) {
|
|
21
48
|
this.offlineQueue = [];
|
|
22
|
-
this.baseUrl =
|
|
23
|
-
this.deviceId =
|
|
24
|
-
this.tenant =
|
|
25
|
-
this.actorId =
|
|
26
|
-
this.apiKey =
|
|
27
|
-
this.timeout =
|
|
49
|
+
this.baseUrl = config2.relayUrl.replace(/\/$/, "");
|
|
50
|
+
this.deviceId = config2.deviceId;
|
|
51
|
+
this.tenant = config2.tenant;
|
|
52
|
+
this.actorId = config2.actorId ?? "default";
|
|
53
|
+
this.apiKey = config2.apiKey ?? "";
|
|
54
|
+
this.timeout = config2.timeout ?? 1e4;
|
|
28
55
|
}
|
|
29
56
|
// ─── Data Sync ───
|
|
30
57
|
/**
|
|
@@ -190,7 +217,7 @@ var RelayClient = class {
|
|
|
190
217
|
};
|
|
191
218
|
|
|
192
219
|
// src/device-bridge/actions/messaging.ts
|
|
193
|
-
|
|
220
|
+
var SMS = __toESM(require("expo-sms"));
|
|
194
221
|
async function execute(actionId, params) {
|
|
195
222
|
const phone = params.phone;
|
|
196
223
|
const message = params.message;
|
|
@@ -237,7 +264,7 @@ async function execute(actionId, params) {
|
|
|
237
264
|
}
|
|
238
265
|
|
|
239
266
|
// src/device-bridge/actions/calendar-actions.ts
|
|
240
|
-
|
|
267
|
+
var ExpoCalendar = __toESM(require("expo-calendar"));
|
|
241
268
|
async function getDefaultCalendarId() {
|
|
242
269
|
const calendars = await ExpoCalendar.getCalendarsAsync(ExpoCalendar.EntityTypes.EVENT);
|
|
243
270
|
const defaultCal = calendars.find((c) => c.isPrimary) || calendars[0];
|
|
@@ -420,8 +447,8 @@ async function execute2(actionId, params) {
|
|
|
420
447
|
}
|
|
421
448
|
|
|
422
449
|
// src/device-bridge/actions/navigation.ts
|
|
423
|
-
|
|
424
|
-
|
|
450
|
+
var Linking = __toESM(require("expo-linking"));
|
|
451
|
+
var import_react_native = require("react-native");
|
|
425
452
|
async function execute3(actionId, params) {
|
|
426
453
|
const destination = params.destination;
|
|
427
454
|
const mode = params.mode || "driving";
|
|
@@ -436,7 +463,7 @@ async function execute3(actionId, params) {
|
|
|
436
463
|
try {
|
|
437
464
|
const encodedDest = encodeURIComponent(destination);
|
|
438
465
|
let url;
|
|
439
|
-
if (Platform.OS === "ios") {
|
|
466
|
+
if (import_react_native.Platform.OS === "ios") {
|
|
440
467
|
const modeMap = {
|
|
441
468
|
driving: "d",
|
|
442
469
|
transit: "r",
|
|
@@ -482,6 +509,206 @@ async function execute3(actionId, params) {
|
|
|
482
509
|
}
|
|
483
510
|
}
|
|
484
511
|
|
|
512
|
+
// src/device-bridge/collectors/health.ts
|
|
513
|
+
var import_react_native2 = require("react-native");
|
|
514
|
+
var _HK = null;
|
|
515
|
+
var _hkProbed = false;
|
|
516
|
+
function getHK() {
|
|
517
|
+
if (import_react_native2.Platform.OS !== "ios") return null;
|
|
518
|
+
if (_hkProbed) return _HK;
|
|
519
|
+
_hkProbed = true;
|
|
520
|
+
try {
|
|
521
|
+
const mod = require("@kingstinct/react-native-healthkit");
|
|
522
|
+
if (mod && typeof mod.requestAuthorization === "function") {
|
|
523
|
+
_HK = mod;
|
|
524
|
+
} else {
|
|
525
|
+
console.warn("[health] @kingstinct/react-native-healthkit native bridge unavailable \u2014 HealthKit disabled (Expo Go?)");
|
|
526
|
+
}
|
|
527
|
+
} catch (e) {
|
|
528
|
+
console.warn("[health] @kingstinct/react-native-healthkit require failed:", e);
|
|
529
|
+
}
|
|
530
|
+
return _HK;
|
|
531
|
+
}
|
|
532
|
+
var lastHealthInitError = null;
|
|
533
|
+
var READ_TYPES = [
|
|
534
|
+
"HKQuantityTypeIdentifierStepCount",
|
|
535
|
+
"HKQuantityTypeIdentifierFlightsClimbed",
|
|
536
|
+
"HKQuantityTypeIdentifierActiveEnergyBurned",
|
|
537
|
+
"HKQuantityTypeIdentifierDistanceWalkingRunning",
|
|
538
|
+
// Added for mood signals — all read-only, covered by the same auth sheet.
|
|
539
|
+
"HKQuantityTypeIdentifierRestingHeartRate",
|
|
540
|
+
"HKQuantityTypeIdentifierAppleExerciseTime",
|
|
541
|
+
"HKCategoryTypeIdentifierSleepAnalysis"
|
|
542
|
+
];
|
|
543
|
+
var _initPromise = null;
|
|
544
|
+
async function ensureInit() {
|
|
545
|
+
const HK = getHK();
|
|
546
|
+
if (!HK) {
|
|
547
|
+
lastHealthInitError = "@kingstinct/react-native-healthkit native module not loaded";
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
if (_initPromise) return _initPromise;
|
|
551
|
+
_initPromise = (async () => {
|
|
552
|
+
try {
|
|
553
|
+
await HK.requestAuthorization({ toRead: READ_TYPES, toWrite: [] });
|
|
554
|
+
lastHealthInitError = null;
|
|
555
|
+
return true;
|
|
556
|
+
} catch (e) {
|
|
557
|
+
lastHealthInitError = `requestAuthorization threw: ${e?.message || String(e)}`;
|
|
558
|
+
console.warn("[health]", lastHealthInitError);
|
|
559
|
+
_initPromise = null;
|
|
560
|
+
return false;
|
|
561
|
+
}
|
|
562
|
+
})();
|
|
563
|
+
return _initPromise;
|
|
564
|
+
}
|
|
565
|
+
async function hasPermission() {
|
|
566
|
+
return ensureInit();
|
|
567
|
+
}
|
|
568
|
+
async function requestPermission() {
|
|
569
|
+
return ensureInit();
|
|
570
|
+
}
|
|
571
|
+
function startOfDay(d) {
|
|
572
|
+
const out = new Date(d);
|
|
573
|
+
out.setHours(0, 0, 0, 0);
|
|
574
|
+
return out;
|
|
575
|
+
}
|
|
576
|
+
function dateKey(d) {
|
|
577
|
+
const y = d.getFullYear();
|
|
578
|
+
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
579
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
580
|
+
return `${y}-${m}-${day}`;
|
|
581
|
+
}
|
|
582
|
+
async function readDailySum(identifier, unit, start, end) {
|
|
583
|
+
const HK = getHK();
|
|
584
|
+
if (!HK?.queryStatisticsForQuantity) return 0;
|
|
585
|
+
try {
|
|
586
|
+
const result = await HK.queryStatisticsForQuantity(
|
|
587
|
+
identifier,
|
|
588
|
+
["cumulativeSum"],
|
|
589
|
+
{
|
|
590
|
+
unit,
|
|
591
|
+
filter: { date: { startDate: start, endDate: end } }
|
|
592
|
+
}
|
|
593
|
+
);
|
|
594
|
+
const q = result?.sumQuantity?.quantity;
|
|
595
|
+
return typeof q === "number" ? q : 0;
|
|
596
|
+
} catch {
|
|
597
|
+
return 0;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
async function readDailyAverage(identifier, unit, start, end) {
|
|
601
|
+
const HK = getHK();
|
|
602
|
+
if (!HK?.queryStatisticsForQuantity) return null;
|
|
603
|
+
try {
|
|
604
|
+
const result = await HK.queryStatisticsForQuantity(
|
|
605
|
+
identifier,
|
|
606
|
+
["discreteAverage"],
|
|
607
|
+
{ unit, filter: { date: { startDate: start, endDate: end } } }
|
|
608
|
+
);
|
|
609
|
+
const q = result?.averageQuantity?.quantity;
|
|
610
|
+
return typeof q === "number" ? q : null;
|
|
611
|
+
} catch {
|
|
612
|
+
return null;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
async function readSleepMinutes(start, end) {
|
|
616
|
+
const HK = getHK();
|
|
617
|
+
const query = HK?.queryCategorySamples || HK?.queryCategorySamplesAsync || HK?.querySamples;
|
|
618
|
+
if (!query) return null;
|
|
619
|
+
try {
|
|
620
|
+
const samples = await query.call(
|
|
621
|
+
HK,
|
|
622
|
+
"HKCategoryTypeIdentifierSleepAnalysis",
|
|
623
|
+
{ filter: { date: { startDate: start, endDate: end } } }
|
|
624
|
+
);
|
|
625
|
+
if (!Array.isArray(samples) || samples.length === 0) return null;
|
|
626
|
+
let ms = 0;
|
|
627
|
+
for (const s of samples) {
|
|
628
|
+
const v = s?.value;
|
|
629
|
+
const isAsleep = v !== 0 && v !== 2;
|
|
630
|
+
if (!isAsleep) continue;
|
|
631
|
+
const a = new Date(s?.startDate).getTime();
|
|
632
|
+
const b = new Date(s?.endDate).getTime();
|
|
633
|
+
if (Number.isFinite(a) && Number.isFinite(b) && b > a) ms += b - a;
|
|
634
|
+
}
|
|
635
|
+
return ms > 0 ? Math.round(ms / 6e4) : null;
|
|
636
|
+
} catch {
|
|
637
|
+
return null;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
async function collectMoodExtras() {
|
|
641
|
+
const ok = await ensureInit();
|
|
642
|
+
if (!ok) return { sleep_min: null, resting_hr: null, active_energy_kcal: null, exercise_min: null };
|
|
643
|
+
const start = startOfDay(/* @__PURE__ */ new Date());
|
|
644
|
+
const end = new Date(start);
|
|
645
|
+
end.setDate(end.getDate() + 1);
|
|
646
|
+
const sleepStart = new Date(start);
|
|
647
|
+
sleepStart.setHours(sleepStart.getHours() - 6);
|
|
648
|
+
const [sleep_min, resting_hr, energy, exercise] = await Promise.all([
|
|
649
|
+
readSleepMinutes(sleepStart, end),
|
|
650
|
+
readDailyAverage("HKQuantityTypeIdentifierRestingHeartRate", "count/min", start, end),
|
|
651
|
+
readDailySum("HKQuantityTypeIdentifierActiveEnergyBurned", "kcal", start, end),
|
|
652
|
+
readDailySum("HKQuantityTypeIdentifierAppleExerciseTime", "min", start, end)
|
|
653
|
+
]);
|
|
654
|
+
return {
|
|
655
|
+
sleep_min,
|
|
656
|
+
resting_hr: resting_hr != null ? Math.round(resting_hr) : null,
|
|
657
|
+
active_energy_kcal: energy ? Math.round(energy) : null,
|
|
658
|
+
exercise_min: exercise ? Math.round(exercise) : null
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
async function readDay(date) {
|
|
662
|
+
const start = startOfDay(date);
|
|
663
|
+
const end = new Date(start);
|
|
664
|
+
end.setDate(end.getDate() + 1);
|
|
665
|
+
const [steps, floors, energy, distance] = await Promise.all([
|
|
666
|
+
readDailySum("HKQuantityTypeIdentifierStepCount", "count", start, end),
|
|
667
|
+
readDailySum("HKQuantityTypeIdentifierFlightsClimbed", "count", start, end),
|
|
668
|
+
readDailySum("HKQuantityTypeIdentifierActiveEnergyBurned", "kcal", start, end),
|
|
669
|
+
// Ask for kilometers directly so we don't have to convert from meters.
|
|
670
|
+
readDailySum("HKQuantityTypeIdentifierDistanceWalkingRunning", "km", start, end)
|
|
671
|
+
]);
|
|
672
|
+
return {
|
|
673
|
+
date: dateKey(start),
|
|
674
|
+
available: true,
|
|
675
|
+
steps: Math.round(steps),
|
|
676
|
+
floors: Math.round(floors),
|
|
677
|
+
active_energy_kcal: Math.round(energy),
|
|
678
|
+
distance_km: Math.round(distance * 100) / 100
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
function unavailableDay(date) {
|
|
682
|
+
return {
|
|
683
|
+
date: dateKey(date),
|
|
684
|
+
available: false,
|
|
685
|
+
steps: null,
|
|
686
|
+
floors: null,
|
|
687
|
+
active_energy_kcal: null,
|
|
688
|
+
distance_km: null
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
async function collectToday() {
|
|
692
|
+
const ok = await ensureInit();
|
|
693
|
+
if (!ok) {
|
|
694
|
+
return unavailableDay(/* @__PURE__ */ new Date());
|
|
695
|
+
}
|
|
696
|
+
return readDay(/* @__PURE__ */ new Date());
|
|
697
|
+
}
|
|
698
|
+
async function collectHistory(days) {
|
|
699
|
+
const n = Math.max(1, Math.min(30, Math.floor(days)));
|
|
700
|
+
const ok = await ensureInit();
|
|
701
|
+
if (!ok) return [];
|
|
702
|
+
const today = startOfDay(/* @__PURE__ */ new Date());
|
|
703
|
+
const out = [];
|
|
704
|
+
for (let i = 0; i < n; i++) {
|
|
705
|
+
const d = new Date(today);
|
|
706
|
+
d.setDate(d.getDate() - i);
|
|
707
|
+
out.push(await readDay(d));
|
|
708
|
+
}
|
|
709
|
+
return out;
|
|
710
|
+
}
|
|
711
|
+
|
|
485
712
|
// src/device-bridge/actions/health-actions.ts
|
|
486
713
|
async function executeToday(actionId) {
|
|
487
714
|
try {
|
|
@@ -523,13 +750,13 @@ async function executeHistory(actionId, params) {
|
|
|
523
750
|
|
|
524
751
|
// src/device-bridge/actions/queue-poller.ts
|
|
525
752
|
var QueuePoller = class {
|
|
526
|
-
constructor(
|
|
753
|
+
constructor(config2) {
|
|
527
754
|
this.timer = null;
|
|
528
755
|
this.running = false;
|
|
529
|
-
this.relayClient =
|
|
530
|
-
this.pollInterval =
|
|
531
|
-
this.onActionExecuted =
|
|
532
|
-
this.onError =
|
|
756
|
+
this.relayClient = config2.relayClient;
|
|
757
|
+
this.pollInterval = config2.pollInterval ?? 5e3;
|
|
758
|
+
this.onActionExecuted = config2.onActionExecuted;
|
|
759
|
+
this.onError = config2.onError;
|
|
533
760
|
}
|
|
534
761
|
/**
|
|
535
762
|
* Start polling for actions.
|
|
@@ -619,8 +846,8 @@ var QueuePoller = class {
|
|
|
619
846
|
};
|
|
620
847
|
|
|
621
848
|
// src/device-bridge/background.ts
|
|
622
|
-
|
|
623
|
-
|
|
849
|
+
var TaskManager = __toESM(require("expo-task-manager"));
|
|
850
|
+
var BackgroundFetch = __toESM(require("expo-background-fetch"));
|
|
624
851
|
|
|
625
852
|
// src/device-bridge/capabilities.ts
|
|
626
853
|
var capabilities_exports = {};
|
|
@@ -638,7 +865,7 @@ __export(capabilities_exports, {
|
|
|
638
865
|
});
|
|
639
866
|
|
|
640
867
|
// src/device-bridge/collectors/calendar.ts
|
|
641
|
-
|
|
868
|
+
var ExpoCalendar2 = __toESM(require("expo-calendar"));
|
|
642
869
|
async function requestPermission2() {
|
|
643
870
|
const { status } = await ExpoCalendar2.requestCalendarPermissionsAsync();
|
|
644
871
|
return status === "granted";
|
|
@@ -649,16 +876,16 @@ async function hasPermission2() {
|
|
|
649
876
|
}
|
|
650
877
|
async function collectToday2() {
|
|
651
878
|
const now = /* @__PURE__ */ new Date();
|
|
652
|
-
const
|
|
879
|
+
const startOfDay2 = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
653
880
|
const endOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59);
|
|
654
881
|
const calendars = await ExpoCalendar2.getCalendarsAsync(ExpoCalendar2.EntityTypes.EVENT);
|
|
655
882
|
const userCalendarIds = getUserCalendarIds(calendars);
|
|
656
|
-
const events = await ExpoCalendar2.getEventsAsync(userCalendarIds,
|
|
883
|
+
const events = await ExpoCalendar2.getEventsAsync(userCalendarIds, startOfDay2, endOfDay);
|
|
657
884
|
const filtered = filterHolidays(events);
|
|
658
885
|
const mapped = filtered.map((e) => ({
|
|
659
886
|
id: e.id,
|
|
660
887
|
title: e.title || "Untitled",
|
|
661
|
-
date:
|
|
888
|
+
date: startOfDay2.toISOString().slice(0, 10),
|
|
662
889
|
start: formatTime2(new Date(e.startDate)),
|
|
663
890
|
end: formatTime2(new Date(e.endDate)),
|
|
664
891
|
location: e.location || "",
|
|
@@ -668,7 +895,7 @@ async function collectToday2() {
|
|
|
668
895
|
mapped.sort((a, b) => a.start.localeCompare(b.start));
|
|
669
896
|
return {
|
|
670
897
|
ok: true,
|
|
671
|
-
date:
|
|
898
|
+
date: startOfDay2.toISOString().slice(0, 10),
|
|
672
899
|
day_of_week: now.toLocaleDateString("en-US", { weekday: "long" }),
|
|
673
900
|
event_count: mapped.length,
|
|
674
901
|
events: mapped
|
|
@@ -741,8 +968,8 @@ function formatTime2(date) {
|
|
|
741
968
|
}
|
|
742
969
|
|
|
743
970
|
// src/device-bridge/collectors/contacts.ts
|
|
744
|
-
|
|
745
|
-
|
|
971
|
+
var ExpoContacts = __toESM(require("expo-contacts"));
|
|
972
|
+
var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
|
|
746
973
|
var HASH_STORE_KEY = "device-bridge.contacts.hashes.v1";
|
|
747
974
|
async function requestPermission3() {
|
|
748
975
|
const { status } = await ExpoContacts.requestPermissionsAsync();
|
|
@@ -785,7 +1012,7 @@ async function collectAll() {
|
|
|
785
1012
|
}
|
|
786
1013
|
let stored = {};
|
|
787
1014
|
try {
|
|
788
|
-
const blob = await
|
|
1015
|
+
const blob = await import_async_storage.default.getItem(HASH_STORE_KEY);
|
|
789
1016
|
if (blob) stored = JSON.parse(blob);
|
|
790
1017
|
} catch {
|
|
791
1018
|
}
|
|
@@ -815,7 +1042,7 @@ async function collectAll() {
|
|
|
815
1042
|
return null;
|
|
816
1043
|
}
|
|
817
1044
|
try {
|
|
818
|
-
await
|
|
1045
|
+
await import_async_storage.default.setItem(HASH_STORE_KEY, JSON.stringify(currentHashes));
|
|
819
1046
|
} catch {
|
|
820
1047
|
}
|
|
821
1048
|
return contacts;
|
|
@@ -849,31 +1076,54 @@ function formatBirthday(birthday) {
|
|
|
849
1076
|
}
|
|
850
1077
|
|
|
851
1078
|
// src/device-bridge/collectors/location.ts
|
|
852
|
-
var
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1079
|
+
var ExpoLocation2 = __toESM(require("expo-location"));
|
|
1080
|
+
|
|
1081
|
+
// src/maps/index.ts
|
|
1082
|
+
var import_react_native3 = require("react-native");
|
|
1083
|
+
var import_expo_modules_core = require("expo-modules-core");
|
|
1084
|
+
var ExpoLocation = __toESM(require("expo-location"));
|
|
1085
|
+
|
|
1086
|
+
// src/maps/normalize.ts
|
|
1087
|
+
var text = (v) => typeof v === "string" && v.trim() !== "" ? v : null;
|
|
1088
|
+
function toMapsAddress(raw) {
|
|
1089
|
+
const r = raw ?? {};
|
|
1090
|
+
return {
|
|
1091
|
+
name: text(r.name),
|
|
1092
|
+
street: text(r.street),
|
|
1093
|
+
streetNumber: text(r.streetNumber),
|
|
1094
|
+
district: text(r.district),
|
|
1095
|
+
city: text(r.city),
|
|
1096
|
+
region: text(r.region),
|
|
1097
|
+
postalCode: text(r.postalCode),
|
|
1098
|
+
country: text(r.country),
|
|
1099
|
+
isoCountryCode: text(r.isoCountryCode)
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
// src/maps/index.ts
|
|
1104
|
+
var native = (0, import_expo_modules_core.requireOptionalNativeModule)("AdaMaps");
|
|
1105
|
+
async function reverseGeocode(at) {
|
|
1106
|
+
const [first] = await ExpoLocation.reverseGeocodeAsync({ latitude: at.latitude, longitude: at.longitude });
|
|
1107
|
+
return first ? toMapsAddress(first) : null;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
// src/device-bridge/collectors/location.ts
|
|
861
1111
|
async function requestPermission4() {
|
|
862
|
-
const { status: fg } = await
|
|
1112
|
+
const { status: fg } = await ExpoLocation2.requestForegroundPermissionsAsync();
|
|
863
1113
|
if (fg !== "granted") return false;
|
|
864
1114
|
try {
|
|
865
|
-
await
|
|
1115
|
+
await ExpoLocation2.requestBackgroundPermissionsAsync();
|
|
866
1116
|
} catch {
|
|
867
1117
|
}
|
|
868
1118
|
return fg === "granted";
|
|
869
1119
|
}
|
|
870
1120
|
async function hasPermission4() {
|
|
871
|
-
const { status } = await
|
|
1121
|
+
const { status } = await ExpoLocation2.getForegroundPermissionsAsync();
|
|
872
1122
|
return status === "granted";
|
|
873
1123
|
}
|
|
874
1124
|
async function collectCurrent() {
|
|
875
|
-
const location = await
|
|
876
|
-
accuracy:
|
|
1125
|
+
const location = await ExpoLocation2.getCurrentPositionAsync({
|
|
1126
|
+
accuracy: ExpoLocation2.Accuracy.Balanced
|
|
877
1127
|
});
|
|
878
1128
|
let place = "Current Location";
|
|
879
1129
|
let address = `${location.coords.latitude.toFixed(4)}, ${location.coords.longitude.toFixed(4)}`;
|
|
@@ -907,67 +1157,12 @@ async function collectCurrent() {
|
|
|
907
1157
|
}
|
|
908
1158
|
};
|
|
909
1159
|
}
|
|
910
|
-
async function ensurePermission() {
|
|
911
|
-
if (await hasPermission4()) return;
|
|
912
|
-
const granted = await requestPermission4();
|
|
913
|
-
if (!granted) {
|
|
914
|
-
throw new Error(
|
|
915
|
-
"Location permission was not granted. Enable it for this app in iOS Settings > Privacy > Location Services."
|
|
916
|
-
);
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
async function getPosition(opts = {}) {
|
|
920
|
-
await ensurePermission();
|
|
921
|
-
const fix = await ExpoLocation.getCurrentPositionAsync({
|
|
922
|
-
accuracy: opts.accuracy === "high" ? ExpoLocation.Accuracy.High : ExpoLocation.Accuracy.Balanced
|
|
923
|
-
});
|
|
924
|
-
return toPosition(fix);
|
|
925
|
-
}
|
|
926
|
-
function toPosition(fix) {
|
|
927
|
-
return {
|
|
928
|
-
latitude: fix.coords.latitude,
|
|
929
|
-
longitude: fix.coords.longitude,
|
|
930
|
-
altitude: fix.coords.altitude ?? void 0,
|
|
931
|
-
accuracy: nonNegative(fix.coords.accuracy),
|
|
932
|
-
timestamp: fix.timestamp ?? Date.now(),
|
|
933
|
-
speed: nonNegative(fix.coords.speed),
|
|
934
|
-
course: nonNegative(fix.coords.heading)
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
function nonNegative(v) {
|
|
938
|
-
return typeof v === "number" && v >= 0 ? v : void 0;
|
|
939
|
-
}
|
|
940
1160
|
var WATCH_TIER = {
|
|
941
|
-
navigation:
|
|
942
|
-
high:
|
|
943
|
-
balanced:
|
|
944
|
-
low:
|
|
1161
|
+
navigation: ExpoLocation2.Accuracy.BestForNavigation,
|
|
1162
|
+
high: ExpoLocation2.Accuracy.High,
|
|
1163
|
+
balanced: ExpoLocation2.Accuracy.Balanced,
|
|
1164
|
+
low: ExpoLocation2.Accuracy.Low
|
|
945
1165
|
};
|
|
946
|
-
function watchPosition(cb, opts) {
|
|
947
|
-
let subscription = null;
|
|
948
|
-
let cancelled = false;
|
|
949
|
-
(async () => {
|
|
950
|
-
try {
|
|
951
|
-
await ensurePermission();
|
|
952
|
-
if (cancelled) return;
|
|
953
|
-
subscription = await ExpoLocation.watchPositionAsync(
|
|
954
|
-
{ accuracy: WATCH_TIER[opts?.accuracy ?? "balanced"] },
|
|
955
|
-
(fix) => cb(toPosition(fix))
|
|
956
|
-
);
|
|
957
|
-
if (cancelled) {
|
|
958
|
-
subscription?.remove();
|
|
959
|
-
subscription = null;
|
|
960
|
-
}
|
|
961
|
-
} catch (err) {
|
|
962
|
-
console.warn("[location] watchPosition failed:", err?.message || String(err));
|
|
963
|
-
}
|
|
964
|
-
})();
|
|
965
|
-
return () => {
|
|
966
|
-
cancelled = true;
|
|
967
|
-
subscription?.remove();
|
|
968
|
-
subscription = null;
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
1166
|
function classifyLocation(geocoded) {
|
|
972
1167
|
const name = (geocoded.name || "").toLowerCase();
|
|
973
1168
|
const street = (geocoded.street || "").toLowerCase();
|
|
@@ -980,7 +1175,7 @@ function classifyLocation(geocoded) {
|
|
|
980
1175
|
}
|
|
981
1176
|
|
|
982
1177
|
// src/device-bridge/collectors/battery.ts
|
|
983
|
-
|
|
1178
|
+
var ExpoBattery = __toESM(require("expo-battery"));
|
|
984
1179
|
async function collectBattery() {
|
|
985
1180
|
const level = await ExpoBattery.getBatteryLevelAsync();
|
|
986
1181
|
const state = await ExpoBattery.getBatteryStateAsync();
|
|
@@ -1026,11 +1221,7 @@ function mapBatteryState(state) {
|
|
|
1026
1221
|
}
|
|
1027
1222
|
|
|
1028
1223
|
// src/device-bridge/collectors/connectivity.ts
|
|
1029
|
-
var
|
|
1030
|
-
__export(connectivity_exports, {
|
|
1031
|
-
collectConnectivity: () => collectConnectivity
|
|
1032
|
-
});
|
|
1033
|
-
import * as ExpoNetwork from "expo-network";
|
|
1224
|
+
var ExpoNetwork = __toESM(require("expo-network"));
|
|
1034
1225
|
async function collectConnectivity() {
|
|
1035
1226
|
const networkState = await ExpoNetwork.getNetworkStateAsync();
|
|
1036
1227
|
let type = "none";
|
|
@@ -1066,7 +1257,7 @@ function getCellularGeneration() {
|
|
|
1066
1257
|
}
|
|
1067
1258
|
|
|
1068
1259
|
// src/device-bridge/collectors/notifications.ts
|
|
1069
|
-
|
|
1260
|
+
var ExpoNotifications = __toESM(require("expo-notifications"));
|
|
1070
1261
|
async function requestPermission5() {
|
|
1071
1262
|
const { status } = await ExpoNotifications.requestPermissionsAsync();
|
|
1072
1263
|
return status === "granted";
|
|
@@ -1103,6 +1294,61 @@ function mapPriority(p) {
|
|
|
1103
1294
|
return "medium";
|
|
1104
1295
|
}
|
|
1105
1296
|
|
|
1297
|
+
// src/device-bridge/collectors/appEngagement.ts
|
|
1298
|
+
var import_react_native4 = require("react-native");
|
|
1299
|
+
var import_async_storage2 = __toESM(require("@react-native-async-storage/async-storage"));
|
|
1300
|
+
var KEY = "ateam.appEngagement.v1";
|
|
1301
|
+
var _tally = null;
|
|
1302
|
+
var _foregroundSince = null;
|
|
1303
|
+
function todayKey() {
|
|
1304
|
+
const d = /* @__PURE__ */ new Date();
|
|
1305
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
1306
|
+
}
|
|
1307
|
+
function fresh() {
|
|
1308
|
+
return { date: todayKey(), sessions: 0, activeMs: 0 };
|
|
1309
|
+
}
|
|
1310
|
+
async function load() {
|
|
1311
|
+
try {
|
|
1312
|
+
const raw = await import_async_storage2.default.getItem(KEY);
|
|
1313
|
+
if (raw) {
|
|
1314
|
+
const parsed = JSON.parse(raw);
|
|
1315
|
+
_tally = parsed?.date === todayKey() ? parsed : fresh();
|
|
1316
|
+
} else {
|
|
1317
|
+
_tally = fresh();
|
|
1318
|
+
}
|
|
1319
|
+
} catch {
|
|
1320
|
+
_tally = fresh();
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
function persist() {
|
|
1324
|
+
if (_tally) import_async_storage2.default.setItem(KEY, JSON.stringify(_tally)).catch(() => {
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
function rollIfNewDay() {
|
|
1328
|
+
if (!_tally || _tally.date !== todayKey()) {
|
|
1329
|
+
_tally = fresh();
|
|
1330
|
+
persist();
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
function flushForeground() {
|
|
1334
|
+
if (_foregroundSince == null || !_tally) return;
|
|
1335
|
+
const now = Date.now();
|
|
1336
|
+
const delta = now - _foregroundSince;
|
|
1337
|
+
if (delta > 0) _tally.activeMs += delta;
|
|
1338
|
+
_foregroundSince = now;
|
|
1339
|
+
}
|
|
1340
|
+
async function getToday() {
|
|
1341
|
+
if (!_tally) await load();
|
|
1342
|
+
rollIfNewDay();
|
|
1343
|
+
flushForeground();
|
|
1344
|
+
persist();
|
|
1345
|
+
if (!_tally) return { app_sessions: null, app_active_min: null };
|
|
1346
|
+
return {
|
|
1347
|
+
app_sessions: _tally.sessions,
|
|
1348
|
+
app_active_min: Math.round(_tally.activeMs / 6e4)
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1106
1352
|
// src/device-bridge/collectors/mood.ts
|
|
1107
1353
|
function emptySignals() {
|
|
1108
1354
|
return {
|
|
@@ -1160,17 +1406,17 @@ async function collectToday3() {
|
|
|
1160
1406
|
}
|
|
1161
1407
|
|
|
1162
1408
|
// src/device-bridge/collectors/camera.ts
|
|
1163
|
-
|
|
1409
|
+
var import_expo_camera = require("expo-camera");
|
|
1164
1410
|
async function hasPermission6() {
|
|
1165
1411
|
try {
|
|
1166
|
-
return (await Camera.getCameraPermissionsAsync()).granted;
|
|
1412
|
+
return (await import_expo_camera.Camera.getCameraPermissionsAsync()).granted;
|
|
1167
1413
|
} catch {
|
|
1168
1414
|
return false;
|
|
1169
1415
|
}
|
|
1170
1416
|
}
|
|
1171
1417
|
async function requestPermission6() {
|
|
1172
1418
|
try {
|
|
1173
|
-
return (await Camera.requestCameraPermissionsAsync()).granted;
|
|
1419
|
+
return (await import_expo_camera.Camera.requestCameraPermissionsAsync()).granted;
|
|
1174
1420
|
} catch {
|
|
1175
1421
|
return false;
|
|
1176
1422
|
}
|
|
@@ -1371,10 +1617,10 @@ var CAPABILITY_FACTORIES = {
|
|
|
1371
1617
|
notifications: notificationsCapability,
|
|
1372
1618
|
health: healthCapability
|
|
1373
1619
|
};
|
|
1374
|
-
async function registerBackgroundSync(
|
|
1620
|
+
async function registerBackgroundSync(config2) {
|
|
1375
1621
|
TaskManager.defineTask(BACKGROUND_TASK_NAME, async () => {
|
|
1376
1622
|
try {
|
|
1377
|
-
const hasNew = await syncDomains(
|
|
1623
|
+
const hasNew = await syncDomains(config2, ["location", "battery", "calendar"]);
|
|
1378
1624
|
return hasNew ? BackgroundFetch.BackgroundFetchResult.NewData : BackgroundFetch.BackgroundFetchResult.NoData;
|
|
1379
1625
|
} catch (error) {
|
|
1380
1626
|
console.error("[DeviceBridge] Background sync failed:", error);
|
|
@@ -1396,13 +1642,13 @@ async function unregisterBackgroundSync() {
|
|
|
1396
1642
|
await BackgroundFetch.unregisterTaskAsync(BACKGROUND_TASK_NAME);
|
|
1397
1643
|
}
|
|
1398
1644
|
}
|
|
1399
|
-
async function syncDomains(
|
|
1645
|
+
async function syncDomains(config2, domains) {
|
|
1400
1646
|
const relay = new RelayClient({
|
|
1401
|
-
relayUrl:
|
|
1402
|
-
deviceId:
|
|
1403
|
-
tenant:
|
|
1404
|
-
actorId:
|
|
1405
|
-
apiKey:
|
|
1647
|
+
relayUrl: config2.relayUrl,
|
|
1648
|
+
deviceId: config2.deviceId,
|
|
1649
|
+
tenant: config2.tenant,
|
|
1650
|
+
actorId: config2.actorId,
|
|
1651
|
+
apiKey: config2.apiKey,
|
|
1406
1652
|
timeout: 15e3
|
|
1407
1653
|
// longer than foreground — background tasks are budget-limited but not latency-sensitive
|
|
1408
1654
|
});
|
|
@@ -1428,95 +1674,30 @@ async function collectAndPush(relay, domain) {
|
|
|
1428
1674
|
}
|
|
1429
1675
|
|
|
1430
1676
|
// src/device-bridge/biometrics.ts
|
|
1431
|
-
var
|
|
1432
|
-
__export(biometrics_exports, {
|
|
1433
|
-
authenticate: () => authenticate,
|
|
1434
|
-
capabilities: () => capabilities
|
|
1435
|
-
});
|
|
1436
|
-
import * as LocalAuthentication from "expo-local-authentication";
|
|
1437
|
-
async function capabilities() {
|
|
1438
|
-
const [hasHardware, isEnrolled, types] = await Promise.all([
|
|
1439
|
-
LocalAuthentication.hasHardwareAsync(),
|
|
1440
|
-
LocalAuthentication.isEnrolledAsync(),
|
|
1441
|
-
LocalAuthentication.supportedAuthenticationTypesAsync()
|
|
1442
|
-
]);
|
|
1443
|
-
const supportedTypes = types.map((t) => {
|
|
1444
|
-
if (t === LocalAuthentication.AuthenticationType.FINGERPRINT) return "fingerprint";
|
|
1445
|
-
if (t === LocalAuthentication.AuthenticationType.FACIAL_RECOGNITION) return "face";
|
|
1446
|
-
if (t === LocalAuthentication.AuthenticationType.IRIS) return "iris";
|
|
1447
|
-
return "none";
|
|
1448
|
-
}).filter((t) => t !== "none");
|
|
1449
|
-
return { hasHardware, isEnrolled, supportedTypes };
|
|
1450
|
-
}
|
|
1451
|
-
async function authenticate(opts) {
|
|
1452
|
-
try {
|
|
1453
|
-
const res = await LocalAuthentication.authenticateAsync({
|
|
1454
|
-
promptMessage: opts.reason,
|
|
1455
|
-
cancelLabel: opts.cancelLabel,
|
|
1456
|
-
disableDeviceFallback: opts.fallbackToPasscode === false
|
|
1457
|
-
});
|
|
1458
|
-
if (res.success) return { success: true };
|
|
1459
|
-
return { success: false, error: res.error || "unknown" };
|
|
1460
|
-
} catch (e) {
|
|
1461
|
-
return { success: false, error: String(e?.message || e) };
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1677
|
+
var LocalAuthentication = __toESM(require("expo-local-authentication"));
|
|
1464
1678
|
|
|
1465
1679
|
// src/device-bridge/sharing.ts
|
|
1466
|
-
var
|
|
1467
|
-
__export(sharing_exports, {
|
|
1468
|
-
isAvailable: () => isAvailable,
|
|
1469
|
-
shareFile: () => shareFile
|
|
1470
|
-
});
|
|
1471
|
-
import * as Sharing from "expo-sharing";
|
|
1472
|
-
async function shareFile(fileUri, opts = {}) {
|
|
1473
|
-
try {
|
|
1474
|
-
const available = await Sharing.isAvailableAsync();
|
|
1475
|
-
if (!available) return { ok: false, error: "sharing_unavailable" };
|
|
1476
|
-
await Sharing.shareAsync(fileUri, opts);
|
|
1477
|
-
return { ok: true };
|
|
1478
|
-
} catch (e) {
|
|
1479
|
-
return { ok: false, error: String(e?.message || e) };
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
async function isAvailable() {
|
|
1483
|
-
return Sharing.isAvailableAsync();
|
|
1484
|
-
}
|
|
1680
|
+
var Sharing = __toESM(require("expo-sharing"));
|
|
1485
1681
|
|
|
1486
1682
|
// src/device-bridge/scanner.ts
|
|
1487
|
-
var
|
|
1488
|
-
__export(scanner_exports, {
|
|
1489
|
-
CameraView: () => CameraView,
|
|
1490
|
-
normalizeResult: () => normalizeResult,
|
|
1491
|
-
requestPermissions: () => requestPermissions,
|
|
1492
|
-
useCameraPermissions: () => useCameraPermissions
|
|
1493
|
-
});
|
|
1494
|
-
import { CameraView, useCameraPermissions } from "expo-camera";
|
|
1495
|
-
async function requestPermissions() {
|
|
1496
|
-
const { Camera: Camera2 } = await import("expo-camera");
|
|
1497
|
-
const { status } = await Camera2.requestCameraPermissionsAsync();
|
|
1498
|
-
return { granted: status === "granted", status };
|
|
1499
|
-
}
|
|
1500
|
-
function normalizeResult(r) {
|
|
1501
|
-
return { type: r.type, data: r.data };
|
|
1502
|
-
}
|
|
1683
|
+
var import_expo_camera2 = require("expo-camera");
|
|
1503
1684
|
|
|
1504
1685
|
// src/device-bridge/index.ts
|
|
1505
1686
|
var DeviceBridge = class {
|
|
1506
|
-
constructor(
|
|
1687
|
+
constructor(config2) {
|
|
1507
1688
|
// Capability registry
|
|
1508
1689
|
this.caps = /* @__PURE__ */ new Map();
|
|
1509
1690
|
this.syncTimers = /* @__PURE__ */ new Map();
|
|
1510
1691
|
this.subscriptions = /* @__PURE__ */ new Map();
|
|
1511
1692
|
this.domainStatus = /* @__PURE__ */ new Map();
|
|
1512
1693
|
this.running = false;
|
|
1513
|
-
this.config =
|
|
1694
|
+
this.config = config2;
|
|
1514
1695
|
this.relay = new RelayClient({
|
|
1515
|
-
relayUrl:
|
|
1516
|
-
deviceId:
|
|
1517
|
-
tenant:
|
|
1518
|
-
actorId:
|
|
1519
|
-
apiKey:
|
|
1696
|
+
relayUrl: config2.relayUrl,
|
|
1697
|
+
deviceId: config2.deviceId,
|
|
1698
|
+
tenant: config2.tenant,
|
|
1699
|
+
actorId: config2.actorId,
|
|
1700
|
+
apiKey: config2.apiKey
|
|
1520
1701
|
});
|
|
1521
1702
|
this.queuePoller = new QueuePoller({
|
|
1522
1703
|
relayClient: this.relay,
|
|
@@ -1792,19 +1973,608 @@ var DeviceBridge = class {
|
|
|
1792
1973
|
}
|
|
1793
1974
|
};
|
|
1794
1975
|
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1976
|
+
// src/device-bridge/deviceId.ts
|
|
1977
|
+
var DEVICE_ID_KEY = "ateam.deviceId";
|
|
1978
|
+
async function getOrCreateDeviceId(storage) {
|
|
1979
|
+
const saved = await storage.getItem(DEVICE_ID_KEY);
|
|
1980
|
+
if (saved) return saved;
|
|
1981
|
+
const id = `device-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1982
|
+
await storage.setItem(DEVICE_ID_KEY, id);
|
|
1983
|
+
return id;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
// src/capabilities/config.ts
|
|
1987
|
+
var config = null;
|
|
1988
|
+
function configureDeviceSync(next) {
|
|
1989
|
+
config = next;
|
|
1990
|
+
}
|
|
1991
|
+
function getDeviceSyncConfig() {
|
|
1992
|
+
return config;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
// src/capabilities/choices.ts
|
|
1996
|
+
var import_async_storage3 = __toESM(require("@react-native-async-storage/async-storage"));
|
|
1997
|
+
var STORAGE_KEY = "ateam.capabilities";
|
|
1998
|
+
var SETUP_KEY = "ateam.capabilities.setup";
|
|
1999
|
+
var DEFAULT_ENABLED = {
|
|
2000
|
+
calendar: true,
|
|
2001
|
+
contacts: true,
|
|
2002
|
+
location: true,
|
|
2003
|
+
battery: true,
|
|
2004
|
+
connectivity: true,
|
|
2005
|
+
health: true,
|
|
2006
|
+
mood: true,
|
|
2007
|
+
// Opt-IN: the camera is more invasive than the sync collectors and should not
|
|
2008
|
+
// prompt every user for camera access on first launch. It lights up only when
|
|
2009
|
+
// the user turns it on (which then requests the OS permission), so a solution
|
|
2010
|
+
// that wants a camera preview asks the user to enable it.
|
|
2011
|
+
camera: false
|
|
1809
2012
|
};
|
|
1810
|
-
|
|
2013
|
+
var HIDDEN_FROM_UI = /* @__PURE__ */ new Set(["notifications"]);
|
|
2014
|
+
async function loadChoices() {
|
|
2015
|
+
const setupDone = await import_async_storage3.default.getItem(SETUP_KEY);
|
|
2016
|
+
const saved = await import_async_storage3.default.getItem(STORAGE_KEY);
|
|
2017
|
+
return { setupDone: setupDone === "true", prefs: saved ? JSON.parse(saved) : {} };
|
|
2018
|
+
}
|
|
2019
|
+
function isEnabled(id, prefs) {
|
|
2020
|
+
return prefs[id] ?? DEFAULT_ENABLED[id] ?? true;
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
// src/capabilities/store.ts
|
|
2024
|
+
var bridge = null;
|
|
2025
|
+
var bridgeOwner = null;
|
|
2026
|
+
var startQueue = Promise.resolve();
|
|
2027
|
+
var startGeneration = 0;
|
|
2028
|
+
var builtInCapabilities = [];
|
|
2029
|
+
var foregroundUnsub = null;
|
|
2030
|
+
var useCapabilitiesStore = (0, import_zustand.create)((set, get) => {
|
|
2031
|
+
const runStart = async () => {
|
|
2032
|
+
const tenant = (0, import_core.getTenant)();
|
|
2033
|
+
const actorId = (0, import_core.getUser)()?.actorId;
|
|
2034
|
+
if (bridge) {
|
|
2035
|
+
if (bridgeOwner?.tenant === tenant && bridgeOwner?.actorId === actorId) {
|
|
2036
|
+
console.log("[Capabilities] Bridge already running");
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
console.log("[Capabilities] Team or user changed \u2014 restarting bridge");
|
|
2040
|
+
get().stopBridge();
|
|
2041
|
+
}
|
|
2042
|
+
const { capabilities: caps } = get();
|
|
2043
|
+
const enabledCaps = caps.filter((c) => c.enabled);
|
|
2044
|
+
if (enabledCaps.length === 0) {
|
|
2045
|
+
console.log("[Capabilities] No capabilities enabled \u2014 bridge not started");
|
|
2046
|
+
return;
|
|
2047
|
+
}
|
|
2048
|
+
const config2 = getDeviceSyncConfig();
|
|
2049
|
+
if (!config2) {
|
|
2050
|
+
console.error("[Capabilities] Bridge not started: device sync is not configured \u2014 pass deviceSync to bootstrapExpoAdas (or call configureDeviceSync)");
|
|
2051
|
+
return;
|
|
2052
|
+
}
|
|
2053
|
+
if (!tenant || !actorId) {
|
|
2054
|
+
console.error(`[Capabilities] Bridge not started: no signed-in ${!tenant ? "tenant" : "user"}`);
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
2057
|
+
const generation = startGeneration;
|
|
2058
|
+
const deviceId = await getOrCreateDeviceId(config2.secureStorage);
|
|
2059
|
+
if (generation !== startGeneration) return;
|
|
2060
|
+
console.log(`[Capabilities] Starting bridge for tenant=${tenant} actor=${actorId} device=${deviceId} with ${enabledCaps.length} capabilities: ${enabledCaps.map((c) => c.id).join(", ")}`);
|
|
2061
|
+
const started = new DeviceBridge({
|
|
2062
|
+
relayUrl: config2.relayUrl(),
|
|
2063
|
+
deviceId,
|
|
2064
|
+
tenant,
|
|
2065
|
+
actorId,
|
|
2066
|
+
// RelayClient sends `Authorization: Bearer <apiKey>` so the relay's
|
|
2067
|
+
// auth gate accepts the call. Empty string = misconfig → relay returns
|
|
2068
|
+
// 401, surfaced as a sync error in the UI.
|
|
2069
|
+
apiKey: config2.relayKey,
|
|
2070
|
+
onStatusChange: (status) => {
|
|
2071
|
+
for (const capStatus of status.capabilities) {
|
|
2072
|
+
const current = get().capabilities.find((c) => c.id === capStatus.id);
|
|
2073
|
+
if (current && current.osPermission !== capStatus.permission) {
|
|
2074
|
+
get().setOsPermission(capStatus.id, capStatus.permission);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
},
|
|
2078
|
+
onError: (err) => {
|
|
2079
|
+
console.warn(`[device-bridge] ${err.domain}: ${err.message}`);
|
|
2080
|
+
}
|
|
2081
|
+
});
|
|
2082
|
+
bridge = started;
|
|
2083
|
+
bridgeOwner = { tenant, actorId };
|
|
2084
|
+
try {
|
|
2085
|
+
const enabledIds = new Set(enabledCaps.map((c) => c.id));
|
|
2086
|
+
const capsToRegister = builtInCapabilities.filter((c) => enabledIds.has(c.id));
|
|
2087
|
+
started.registerAll(capsToRegister);
|
|
2088
|
+
await started.requestAllPermissions();
|
|
2089
|
+
if (generation !== startGeneration) return;
|
|
2090
|
+
const statuses = started.listCapabilities();
|
|
2091
|
+
set((state) => ({
|
|
2092
|
+
bridgeRunning: true,
|
|
2093
|
+
capabilities: state.capabilities.map((c) => {
|
|
2094
|
+
const status = statuses.find((s) => s.id === c.id);
|
|
2095
|
+
return status ? { ...c, osPermission: status.permission } : c;
|
|
2096
|
+
})
|
|
2097
|
+
}));
|
|
2098
|
+
await started.startSync();
|
|
2099
|
+
if (generation !== startGeneration) {
|
|
2100
|
+
started.stopSync();
|
|
2101
|
+
return;
|
|
2102
|
+
}
|
|
2103
|
+
console.log("[Capabilities] Bridge started and syncing");
|
|
2104
|
+
} catch (err) {
|
|
2105
|
+
if (bridge === started) get().stopBridge();
|
|
2106
|
+
throw err;
|
|
2107
|
+
}
|
|
2108
|
+
if (!foregroundUnsub) {
|
|
2109
|
+
foregroundUnsub = (0, import_core.onAppForeground)(() => {
|
|
2110
|
+
bridge?.syncCapabilityNow("battery").catch((err) => {
|
|
2111
|
+
console.warn("[Capabilities] foreground battery sync failed:", err);
|
|
2112
|
+
});
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
};
|
|
2116
|
+
return {
|
|
2117
|
+
capabilities: [],
|
|
2118
|
+
hasCompletedSetup: false,
|
|
2119
|
+
isLoading: true,
|
|
2120
|
+
bridgeRunning: false,
|
|
2121
|
+
initialize: async () => {
|
|
2122
|
+
try {
|
|
2123
|
+
builtInCapabilities = capabilities_exports.allBuiltIn().filter((c) => !HIDDEN_FROM_UI.has(c.id));
|
|
2124
|
+
const { setupDone, prefs } = await loadChoices();
|
|
2125
|
+
const capStates = builtInCapabilities.map((cap) => ({
|
|
2126
|
+
id: cap.id,
|
|
2127
|
+
name: cap.name,
|
|
2128
|
+
description: cap.description,
|
|
2129
|
+
reason: cap.reason,
|
|
2130
|
+
icon: cap.icon || cap.id,
|
|
2131
|
+
requiresPermission: cap.requiresPermission,
|
|
2132
|
+
enabled: isEnabled(cap.id, prefs),
|
|
2133
|
+
osPermission: cap.permissionState
|
|
2134
|
+
}));
|
|
2135
|
+
set({
|
|
2136
|
+
capabilities: capStates,
|
|
2137
|
+
hasCompletedSetup: setupDone,
|
|
2138
|
+
isLoading: false
|
|
2139
|
+
});
|
|
2140
|
+
console.log(`[Capabilities] Initialized ${capStates.length} capabilities from device-bridge (setup ${setupDone ? "done" : "pending"})`);
|
|
2141
|
+
} catch (err) {
|
|
2142
|
+
console.error("[Capabilities] Initialize failed:", err);
|
|
2143
|
+
set({ isLoading: false });
|
|
2144
|
+
}
|
|
2145
|
+
},
|
|
2146
|
+
toggleCapability: async (id, enabled) => {
|
|
2147
|
+
set((state) => ({
|
|
2148
|
+
capabilities: state.capabilities.map(
|
|
2149
|
+
(cap) => cap.id === id ? { ...cap, enabled } : cap
|
|
2150
|
+
)
|
|
2151
|
+
}));
|
|
2152
|
+
const prefs = {};
|
|
2153
|
+
for (const cap of get().capabilities) {
|
|
2154
|
+
prefs[cap.id] = cap.id === id ? enabled : cap.enabled;
|
|
2155
|
+
}
|
|
2156
|
+
await import_async_storage4.default.setItem(STORAGE_KEY, JSON.stringify(prefs));
|
|
2157
|
+
if (bridge && get().bridgeRunning) {
|
|
2158
|
+
if (enabled) {
|
|
2159
|
+
const builtIn = builtInCapabilities.find((c) => c.id === id);
|
|
2160
|
+
if (builtIn) {
|
|
2161
|
+
bridge.register(builtIn);
|
|
2162
|
+
const granted = await bridge.requestPermission(id);
|
|
2163
|
+
set((state) => ({
|
|
2164
|
+
capabilities: state.capabilities.map(
|
|
2165
|
+
(c) => c.id === id ? { ...c, osPermission: granted ? "granted" : "denied" } : c
|
|
2166
|
+
)
|
|
2167
|
+
}));
|
|
2168
|
+
}
|
|
2169
|
+
} else {
|
|
2170
|
+
console.log(`[Capabilities] ${id} disabled \u2014 restarting bridge`);
|
|
2171
|
+
get().stopBridge();
|
|
2172
|
+
await get().startBridge();
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
},
|
|
2176
|
+
setOsPermission: (id, permState) => {
|
|
2177
|
+
set((s) => ({
|
|
2178
|
+
capabilities: s.capabilities.map(
|
|
2179
|
+
(cap) => cap.id === id ? { ...cap, osPermission: permState } : cap
|
|
2180
|
+
)
|
|
2181
|
+
}));
|
|
2182
|
+
},
|
|
2183
|
+
completeSetup: async () => {
|
|
2184
|
+
await import_async_storage4.default.setItem(SETUP_KEY, "true");
|
|
2185
|
+
set({ hasCompletedSetup: true });
|
|
2186
|
+
},
|
|
2187
|
+
startBridge: () => {
|
|
2188
|
+
const run = startQueue.then(runStart);
|
|
2189
|
+
startQueue = run.catch((err) => {
|
|
2190
|
+
console.error("[Capabilities] Bridge start failed:", err);
|
|
2191
|
+
});
|
|
2192
|
+
return run;
|
|
2193
|
+
},
|
|
2194
|
+
stopBridge: () => {
|
|
2195
|
+
startGeneration++;
|
|
2196
|
+
if (bridge) {
|
|
2197
|
+
bridge.stopSync();
|
|
2198
|
+
bridge = null;
|
|
2199
|
+
bridgeOwner = null;
|
|
2200
|
+
set({ bridgeRunning: false });
|
|
2201
|
+
console.log("[Capabilities] Bridge stopped");
|
|
2202
|
+
}
|
|
2203
|
+
if (foregroundUnsub) {
|
|
2204
|
+
foregroundUnsub();
|
|
2205
|
+
foregroundUnsub = null;
|
|
2206
|
+
}
|
|
2207
|
+
},
|
|
2208
|
+
syncNow: async () => {
|
|
2209
|
+
if (!bridge) return { ok: false, error: "bridge not running" };
|
|
2210
|
+
try {
|
|
2211
|
+
await bridge.syncNow();
|
|
2212
|
+
const statuses = bridge.listCapabilities();
|
|
2213
|
+
const failed = statuses.filter(
|
|
2214
|
+
(s) => s.sync?.state === "error" || s.sync?.state === "syncing"
|
|
2215
|
+
);
|
|
2216
|
+
if (failed.length > 0) {
|
|
2217
|
+
const summary = failed.map((s) => `${s.id}:${s.sync?.state}${s.sync?.error ? `(${s.sync.error})` : ""}`).join(", ");
|
|
2218
|
+
return { ok: false, error: summary };
|
|
2219
|
+
}
|
|
2220
|
+
return { ok: true };
|
|
2221
|
+
} catch (e) {
|
|
2222
|
+
return { ok: false, error: e?.message || String(e) };
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
};
|
|
2226
|
+
});
|
|
2227
|
+
|
|
2228
|
+
// src/capabilities/CapabilitiesSetup.tsx
|
|
2229
|
+
var import_react = require("react");
|
|
2230
|
+
var import_react_native6 = require("react-native");
|
|
2231
|
+
var import_core3 = require("@ateam-ai-mobile/core");
|
|
2232
|
+
|
|
2233
|
+
// src/capabilities/CapabilityCard.tsx
|
|
2234
|
+
var import_react_native5 = require("react-native");
|
|
2235
|
+
var import_core2 = require("@ateam-ai-mobile/core");
|
|
2236
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2237
|
+
var fontFam = import_react_native5.Platform.OS === "ios" ? "SF Pro Rounded" : void 0;
|
|
2238
|
+
var ICONS = {
|
|
2239
|
+
calendar: "\u{1F4C5}",
|
|
2240
|
+
contacts: "\u{1F465}",
|
|
2241
|
+
location: "\u{1F4CD}",
|
|
2242
|
+
battery: "\u{1F50B}",
|
|
2243
|
+
wifi: "\u{1F4F6}",
|
|
2244
|
+
notifications: "\u{1F514}"
|
|
2245
|
+
};
|
|
2246
|
+
function CapabilityCard({ capability, onToggle }) {
|
|
2247
|
+
const { id, name, description, reason, icon, enabled, osPermission, requiresPermission } = capability;
|
|
2248
|
+
const isDenied = osPermission === "denied";
|
|
2249
|
+
const isGranted = osPermission === "granted" || osPermission === "not_needed";
|
|
2250
|
+
const handleToggle = (value) => {
|
|
2251
|
+
if (isDenied && value) {
|
|
2252
|
+
import_react_native5.Linking.openSettings();
|
|
2253
|
+
return;
|
|
2254
|
+
}
|
|
2255
|
+
onToggle(id, value);
|
|
2256
|
+
};
|
|
2257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native5.View, { style: [styles.card, enabled && styles.cardEnabled], children: [
|
|
2258
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native5.View, { style: styles.row, children: [
|
|
2259
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: [styles.iconBox, enabled && styles.iconBoxEnabled], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Text, { style: styles.iconText, children: ICONS[icon] || "\u2699\uFE0F" }) }),
|
|
2260
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native5.View, { style: styles.info, children: [
|
|
2261
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Text, { style: styles.name, children: name }),
|
|
2262
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Text, { style: styles.description, children: description })
|
|
2263
|
+
] }),
|
|
2264
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2265
|
+
import_react_native5.Switch,
|
|
2266
|
+
{
|
|
2267
|
+
value: enabled,
|
|
2268
|
+
onValueChange: handleToggle,
|
|
2269
|
+
trackColor: { false: import_core2.ada.border, true: import_core2.ada.orange },
|
|
2270
|
+
thumbColor: "#fff",
|
|
2271
|
+
ios_backgroundColor: import_core2.ada.border
|
|
2272
|
+
}
|
|
2273
|
+
)
|
|
2274
|
+
] }),
|
|
2275
|
+
enabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Text, { style: styles.reason, children: reason }),
|
|
2276
|
+
enabled && requiresPermission && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: styles.statusRow, children: isDenied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Pressable, { onPress: () => import_react_native5.Linking.openSettings(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: styles.deniedBadge, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Text, { style: styles.deniedText, children: "Blocked \u2014 tap to open Settings" }) }) }) : isGranted ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: styles.grantedBadge, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Text, { style: styles.grantedText, children: "Active" }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.View, { style: styles.pendingBadge, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native5.Text, { style: styles.pendingText, children: "Will ask permission" }) }) })
|
|
2277
|
+
] });
|
|
2278
|
+
}
|
|
2279
|
+
var styles = import_react_native5.StyleSheet.create({
|
|
2280
|
+
card: {
|
|
2281
|
+
backgroundColor: import_core2.ada.paperSoft,
|
|
2282
|
+
borderRadius: import_core2.borderRadius.lg,
|
|
2283
|
+
borderWidth: 1,
|
|
2284
|
+
borderColor: import_core2.ada.border,
|
|
2285
|
+
padding: import_core2.spacing.lg,
|
|
2286
|
+
marginBottom: import_core2.spacing.md
|
|
2287
|
+
},
|
|
2288
|
+
cardEnabled: {
|
|
2289
|
+
borderColor: import_core2.ada.orange,
|
|
2290
|
+
borderWidth: 1.5
|
|
2291
|
+
},
|
|
2292
|
+
row: {
|
|
2293
|
+
flexDirection: "row",
|
|
2294
|
+
alignItems: "center",
|
|
2295
|
+
gap: import_core2.spacing.md
|
|
2296
|
+
},
|
|
2297
|
+
iconBox: {
|
|
2298
|
+
width: 44,
|
|
2299
|
+
height: 44,
|
|
2300
|
+
borderRadius: 12,
|
|
2301
|
+
backgroundColor: import_core2.ada.paperDeep,
|
|
2302
|
+
justifyContent: "center",
|
|
2303
|
+
alignItems: "center"
|
|
2304
|
+
},
|
|
2305
|
+
iconBoxEnabled: {
|
|
2306
|
+
backgroundColor: import_core2.ada.orangeSoft
|
|
2307
|
+
},
|
|
2308
|
+
iconText: {
|
|
2309
|
+
fontSize: 20
|
|
2310
|
+
},
|
|
2311
|
+
info: {
|
|
2312
|
+
flex: 1
|
|
2313
|
+
},
|
|
2314
|
+
name: {
|
|
2315
|
+
color: import_core2.ada.ink,
|
|
2316
|
+
fontSize: import_core2.fontSize.lg,
|
|
2317
|
+
fontWeight: "600",
|
|
2318
|
+
fontFamily: fontFam,
|
|
2319
|
+
letterSpacing: -0.2
|
|
2320
|
+
},
|
|
2321
|
+
description: {
|
|
2322
|
+
color: import_core2.ada.inkSoft,
|
|
2323
|
+
fontSize: import_core2.fontSize.sm,
|
|
2324
|
+
marginTop: 2,
|
|
2325
|
+
lineHeight: 18,
|
|
2326
|
+
fontFamily: fontFam,
|
|
2327
|
+
letterSpacing: -0.05
|
|
2328
|
+
},
|
|
2329
|
+
reason: {
|
|
2330
|
+
color: import_core2.ada.inkMuted,
|
|
2331
|
+
fontSize: import_core2.fontSize.xs,
|
|
2332
|
+
marginTop: import_core2.spacing.sm,
|
|
2333
|
+
marginLeft: 44 + import_core2.spacing.md,
|
|
2334
|
+
lineHeight: 16,
|
|
2335
|
+
fontFamily: fontFam
|
|
2336
|
+
},
|
|
2337
|
+
statusRow: {
|
|
2338
|
+
marginTop: import_core2.spacing.sm,
|
|
2339
|
+
marginLeft: 44 + import_core2.spacing.md
|
|
2340
|
+
},
|
|
2341
|
+
grantedBadge: {
|
|
2342
|
+
backgroundColor: "rgba(90, 138, 92, 0.14)",
|
|
2343
|
+
borderRadius: import_core2.borderRadius.sm,
|
|
2344
|
+
paddingHorizontal: import_core2.spacing.sm,
|
|
2345
|
+
paddingVertical: 3,
|
|
2346
|
+
alignSelf: "flex-start"
|
|
2347
|
+
},
|
|
2348
|
+
grantedText: {
|
|
2349
|
+
color: "#5A8A5C",
|
|
2350
|
+
fontSize: import_core2.fontSize.xs,
|
|
2351
|
+
fontWeight: "700",
|
|
2352
|
+
fontFamily: fontFam,
|
|
2353
|
+
letterSpacing: 0.2
|
|
2354
|
+
},
|
|
2355
|
+
pendingBadge: {
|
|
2356
|
+
backgroundColor: import_core2.ada.orangeSoft,
|
|
2357
|
+
borderRadius: import_core2.borderRadius.sm,
|
|
2358
|
+
paddingHorizontal: import_core2.spacing.sm,
|
|
2359
|
+
paddingVertical: 3,
|
|
2360
|
+
alignSelf: "flex-start"
|
|
2361
|
+
},
|
|
2362
|
+
pendingText: {
|
|
2363
|
+
color: import_core2.ada.orangeDeep,
|
|
2364
|
+
fontSize: import_core2.fontSize.xs,
|
|
2365
|
+
fontWeight: "700",
|
|
2366
|
+
fontFamily: fontFam,
|
|
2367
|
+
letterSpacing: 0.2
|
|
2368
|
+
},
|
|
2369
|
+
deniedBadge: {
|
|
2370
|
+
backgroundColor: "rgba(193, 85, 69, 0.14)",
|
|
2371
|
+
borderRadius: import_core2.borderRadius.sm,
|
|
2372
|
+
paddingHorizontal: import_core2.spacing.sm,
|
|
2373
|
+
paddingVertical: 3,
|
|
2374
|
+
alignSelf: "flex-start"
|
|
2375
|
+
},
|
|
2376
|
+
deniedText: {
|
|
2377
|
+
color: "#C15545",
|
|
2378
|
+
fontSize: import_core2.fontSize.xs,
|
|
2379
|
+
fontWeight: "700",
|
|
2380
|
+
fontFamily: fontFam,
|
|
2381
|
+
letterSpacing: 0.2
|
|
2382
|
+
}
|
|
2383
|
+
});
|
|
2384
|
+
|
|
2385
|
+
// src/capabilities/CapabilitiesSetup.tsx
|
|
2386
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2387
|
+
var fontFam2 = import_react_native6.Platform.OS === "ios" ? "SF Pro Rounded" : void 0;
|
|
2388
|
+
function CapabilitiesSetup({
|
|
2389
|
+
onComplete,
|
|
2390
|
+
header,
|
|
2391
|
+
title = "What can the assistant use?",
|
|
2392
|
+
subtitle = "Choose what it can see on this device. You're in charge \u2014 change it anytime in settings.",
|
|
2393
|
+
loading
|
|
2394
|
+
}) {
|
|
2395
|
+
const {
|
|
2396
|
+
capabilities,
|
|
2397
|
+
toggleCapability,
|
|
2398
|
+
completeSetup,
|
|
2399
|
+
isLoading
|
|
2400
|
+
} = useCapabilitiesStore();
|
|
2401
|
+
const [requesting, setRequesting] = (0, import_react.useState)(false);
|
|
2402
|
+
const enabledCount = capabilities.filter((c) => c.enabled).length;
|
|
2403
|
+
const permissionCount = capabilities.filter((c) => c.enabled && c.requiresPermission).length;
|
|
2404
|
+
const handleContinue = async () => {
|
|
2405
|
+
setRequesting(true);
|
|
2406
|
+
await completeSetup();
|
|
2407
|
+
setRequesting(false);
|
|
2408
|
+
onComplete();
|
|
2409
|
+
};
|
|
2410
|
+
const handleSkip = async () => {
|
|
2411
|
+
for (const cap of capabilities) {
|
|
2412
|
+
if (cap.enabled) {
|
|
2413
|
+
await toggleCapability(cap.id, false);
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
await completeSetup();
|
|
2417
|
+
onComplete();
|
|
2418
|
+
};
|
|
2419
|
+
if (isLoading) {
|
|
2420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.SafeAreaView, { style: styles2.center, children: loading ?? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.ActivityIndicator, { size: "large", color: import_core3.ada.inkMuted }) });
|
|
2421
|
+
}
|
|
2422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native6.SafeAreaView, { style: styles2.container, children: [
|
|
2423
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native6.ScrollView, { contentContainerStyle: styles2.content, children: [
|
|
2424
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native6.View, { style: styles2.header, children: [
|
|
2425
|
+
header ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.View, { style: styles2.heroRow, children: header }) : null,
|
|
2426
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.Text, { style: styles2.title, children: title }),
|
|
2427
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.Text, { style: styles2.subtitle, children: subtitle })
|
|
2428
|
+
] }),
|
|
2429
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native6.View, { style: styles2.section, children: [
|
|
2430
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.Text, { style: styles2.sectionTitle, children: "NEEDS YOUR PERMISSION" }),
|
|
2431
|
+
capabilities.filter((c) => c.requiresPermission).map((cap) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2432
|
+
CapabilityCard,
|
|
2433
|
+
{
|
|
2434
|
+
capability: cap,
|
|
2435
|
+
onToggle: toggleCapability
|
|
2436
|
+
},
|
|
2437
|
+
cap.id
|
|
2438
|
+
))
|
|
2439
|
+
] }),
|
|
2440
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native6.View, { style: styles2.section, children: [
|
|
2441
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.Text, { style: styles2.sectionTitle, children: "ALWAYS AVAILABLE" }),
|
|
2442
|
+
capabilities.filter((c) => !c.requiresPermission).map((cap) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2443
|
+
CapabilityCard,
|
|
2444
|
+
{
|
|
2445
|
+
capability: cap,
|
|
2446
|
+
onToggle: toggleCapability
|
|
2447
|
+
},
|
|
2448
|
+
cap.id
|
|
2449
|
+
))
|
|
2450
|
+
] }),
|
|
2451
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.View, { style: styles2.summaryBox, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native6.Text, { style: styles2.summaryText, children: [
|
|
2452
|
+
enabledCount,
|
|
2453
|
+
" of ",
|
|
2454
|
+
capabilities.length,
|
|
2455
|
+
" on",
|
|
2456
|
+
permissionCount > 0 && ` \xB7 ${permissionCount} will ask for permission`
|
|
2457
|
+
] }) })
|
|
2458
|
+
] }),
|
|
2459
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native6.View, { style: styles2.footer, children: [
|
|
2460
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2461
|
+
import_react_native6.Pressable,
|
|
2462
|
+
{
|
|
2463
|
+
style: [styles2.continueBtn, requesting && styles2.continueBtnDisabled],
|
|
2464
|
+
onPress: handleContinue,
|
|
2465
|
+
disabled: requesting,
|
|
2466
|
+
children: requesting ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.ActivityIndicator, { size: "small", color: import_core3.ada.paper }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.Text, { style: styles2.continueBtnText, children: enabledCount > 0 ? "Continue" : "Continue without these" })
|
|
2467
|
+
}
|
|
2468
|
+
),
|
|
2469
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.Pressable, { style: styles2.skipBtn, onPress: handleSkip, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native6.Text, { style: styles2.skipBtnText, children: "Skip for now" }) })
|
|
2470
|
+
] })
|
|
2471
|
+
] });
|
|
2472
|
+
}
|
|
2473
|
+
var styles2 = import_react_native6.StyleSheet.create({
|
|
2474
|
+
container: {
|
|
2475
|
+
flex: 1,
|
|
2476
|
+
backgroundColor: import_core3.ada.paper
|
|
2477
|
+
},
|
|
2478
|
+
center: {
|
|
2479
|
+
flex: 1,
|
|
2480
|
+
justifyContent: "center",
|
|
2481
|
+
alignItems: "center",
|
|
2482
|
+
backgroundColor: import_core3.ada.paper
|
|
2483
|
+
},
|
|
2484
|
+
content: {
|
|
2485
|
+
paddingBottom: 20
|
|
2486
|
+
},
|
|
2487
|
+
header: {
|
|
2488
|
+
paddingHorizontal: import_core3.spacing.xl,
|
|
2489
|
+
paddingTop: 20,
|
|
2490
|
+
paddingBottom: import_core3.spacing.lg
|
|
2491
|
+
},
|
|
2492
|
+
heroRow: {
|
|
2493
|
+
flexDirection: "row",
|
|
2494
|
+
alignItems: "center",
|
|
2495
|
+
gap: 10,
|
|
2496
|
+
marginBottom: import_core3.spacing.lg
|
|
2497
|
+
},
|
|
2498
|
+
title: {
|
|
2499
|
+
color: import_core3.ada.ink,
|
|
2500
|
+
fontSize: 28,
|
|
2501
|
+
fontWeight: "700",
|
|
2502
|
+
letterSpacing: -0.5,
|
|
2503
|
+
marginBottom: 8,
|
|
2504
|
+
fontFamily: fontFam2
|
|
2505
|
+
},
|
|
2506
|
+
subtitle: {
|
|
2507
|
+
color: import_core3.ada.inkSoft,
|
|
2508
|
+
fontSize: import_core3.fontSize.md,
|
|
2509
|
+
lineHeight: 22,
|
|
2510
|
+
letterSpacing: -0.1,
|
|
2511
|
+
fontFamily: fontFam2
|
|
2512
|
+
},
|
|
2513
|
+
section: {
|
|
2514
|
+
paddingHorizontal: import_core3.spacing.lg,
|
|
2515
|
+
marginBottom: import_core3.spacing.lg
|
|
2516
|
+
},
|
|
2517
|
+
sectionTitle: {
|
|
2518
|
+
color: import_core3.ada.inkMuted,
|
|
2519
|
+
fontSize: 11,
|
|
2520
|
+
fontWeight: "700",
|
|
2521
|
+
letterSpacing: 1.4,
|
|
2522
|
+
marginBottom: import_core3.spacing.sm,
|
|
2523
|
+
paddingHorizontal: 4,
|
|
2524
|
+
fontFamily: fontFam2
|
|
2525
|
+
},
|
|
2526
|
+
summaryBox: {
|
|
2527
|
+
marginHorizontal: import_core3.spacing.lg,
|
|
2528
|
+
backgroundColor: import_core3.ada.orangeSoft,
|
|
2529
|
+
borderRadius: import_core3.borderRadius.md,
|
|
2530
|
+
padding: import_core3.spacing.md,
|
|
2531
|
+
alignItems: "center"
|
|
2532
|
+
},
|
|
2533
|
+
summaryText: {
|
|
2534
|
+
color: import_core3.ada.orangeDeep,
|
|
2535
|
+
fontSize: import_core3.fontSize.sm,
|
|
2536
|
+
fontWeight: "600",
|
|
2537
|
+
fontFamily: fontFam2,
|
|
2538
|
+
letterSpacing: -0.1
|
|
2539
|
+
},
|
|
2540
|
+
footer: {
|
|
2541
|
+
paddingHorizontal: import_core3.spacing.lg,
|
|
2542
|
+
paddingVertical: import_core3.spacing.lg,
|
|
2543
|
+
borderTopWidth: 1,
|
|
2544
|
+
borderTopColor: import_core3.ada.border,
|
|
2545
|
+
gap: import_core3.spacing.sm
|
|
2546
|
+
},
|
|
2547
|
+
continueBtn: {
|
|
2548
|
+
backgroundColor: import_core3.ada.ink,
|
|
2549
|
+
borderRadius: 999,
|
|
2550
|
+
paddingVertical: 16,
|
|
2551
|
+
alignItems: "center"
|
|
2552
|
+
},
|
|
2553
|
+
continueBtnDisabled: {
|
|
2554
|
+
opacity: 0.6
|
|
2555
|
+
},
|
|
2556
|
+
continueBtnText: {
|
|
2557
|
+
color: import_core3.ada.paper,
|
|
2558
|
+
fontSize: import_core3.fontSize.lg,
|
|
2559
|
+
fontWeight: "600",
|
|
2560
|
+
fontFamily: fontFam2,
|
|
2561
|
+
letterSpacing: -0.2
|
|
2562
|
+
},
|
|
2563
|
+
skipBtn: {
|
|
2564
|
+
paddingVertical: 12,
|
|
2565
|
+
alignItems: "center"
|
|
2566
|
+
},
|
|
2567
|
+
skipBtnText: {
|
|
2568
|
+
color: import_core3.ada.inkMuted,
|
|
2569
|
+
fontSize: import_core3.fontSize.md,
|
|
2570
|
+
fontFamily: fontFam2
|
|
2571
|
+
}
|
|
2572
|
+
});
|
|
2573
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2574
|
+
0 && (module.exports = {
|
|
2575
|
+
CapabilitiesSetup,
|
|
2576
|
+
CapabilityCard,
|
|
2577
|
+
configureDeviceSync,
|
|
2578
|
+
useCapabilitiesStore
|
|
2579
|
+
});
|
|
2580
|
+
//# sourceMappingURL=index.js.map
|