@buoy-gg/permissions 7.0.55 → 7.0.57
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/lib/commonjs/engine/adapters/capacitor.js +1 -0
- package/lib/commonjs/engine/adapters/capacitor.web.js +1 -0
- package/lib/commonjs/engine/adapters/coarsenPosition.js +1 -0
- package/lib/commonjs/engine/adapters/expo.js +3 -3
- package/lib/commonjs/engine/domAlert.js +1 -0
- package/lib/commonjs/engine/expoConfig.js +1 -0
- package/lib/commonjs/engine/expoConfig.web.js +1 -0
- package/lib/commonjs/engine/install.web.js +1 -1
- package/lib/commonjs/engine/model.js +1 -1
- package/lib/commonjs/engine/prompt.js +2 -2
- package/lib/commonjs/engine/readSavedSync.web.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/module/engine/adapters/capacitor.js +1 -0
- package/lib/module/engine/adapters/capacitor.web.js +1 -0
- package/lib/module/engine/adapters/coarsenPosition.js +1 -0
- package/lib/module/engine/adapters/expo.js +3 -3
- package/lib/module/engine/domAlert.js +1 -0
- package/lib/module/engine/expoConfig.js +1 -0
- package/lib/module/engine/expoConfig.web.js +1 -0
- package/lib/module/engine/install.web.js +1 -1
- package/lib/module/engine/model.js +1 -1
- package/lib/module/engine/prompt.js +2 -2
- package/lib/module/engine/readSavedSync.web.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/typescript/engine/adapters/capacitor.d.ts +4 -0
- package/lib/typescript/engine/adapters/capacitor.web.d.ts +5 -0
- package/lib/typescript/engine/adapters/coarsenPosition.d.ts +6 -0
- package/lib/typescript/engine/adapters/expo.d.ts +1 -6
- package/lib/typescript/engine/domAlert.d.ts +10 -0
- package/lib/typescript/engine/expoConfig.d.ts +10 -0
- package/lib/typescript/engine/expoConfig.web.d.ts +7 -0
- package/lib/typescript/engine/install.web.d.ts +0 -5
- package/lib/typescript/engine/model.d.ts +18 -0
- package/lib/typescript/engine/readSavedSync.web.d.ts +7 -2
- package/lib/web/index.mjs +3 -1
- package/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.installCapacitorPermissionsAdapter=installCapacitorPermissionsAdapter;exports.refreshCapacitorRealStates=refreshCapacitorRealStates;function installCapacitorPermissionsAdapter(){return false}async function refreshCapacitorRealStates(){}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.__resetCapacitorPermissionsForTests=__resetCapacitorPermissionsForTests;exports.installCapacitorPermissionsAdapter=installCapacitorPermissionsAdapter;exports.refreshCapacitorRealStates=refreshCapacitorRealStates;var _coarsenPosition=require("./coarsenPosition");var _license=require("@buoy-gg/license");var _model=require("../model");var _store=require("../store");const PERMISSIONS_ORDER=10;const KNOWN_PLUGINS=[{plugin:"Geolocation",library:"@capacitor/geolocation",aliases:{location:"location"}},{plugin:"Camera",library:"@capacitor/camera",aliases:{camera:"camera",photos:"photos"}},{plugin:"PushNotifications",library:"@capacitor/push-notifications",aliases:{notifications:"receive"}},{plugin:"LocalNotifications",library:"@capacitor/local-notifications",aliases:{notifications:"display"}}];const GATED=[{plugin:"Geolocation",methods:["getCurrentPosition"],permission:()=>"location",message:()=>"Location permission was denied"},{plugin:"Camera",methods:["getPhoto","pickImages","pickLimitedLibraryPhotos"],permission:r=>r.source==="CAMERA"?"camera":"photos",message:r=>r==="camera"?"User denied access to camera":"User denied access to photos"}];function source(r){return KNOWN_PLUGINS.find(e=>e.plugin===r)?.library??`Capacitor ${r}`}const refused=r=>r==="denied"||r==="blocked"||r==="restricted";function idsIn(r){const e=new Set;for(const t of Object.keys(r)){const i=(0,_model.capacitorAliasId)(t);if(i)e.add(i)}return Array.from(e)}function asStatus(r){return r&&typeof r==="object"?r:{}}let installed=false;function installCapacitorPermissionsAdapter(){if(installed)return true;if(!(0,_license.installCapacitorBridge)())return false;installed=true;const r=(0,_store.getPlatform)();(0,_license.interceptCapacitor)({plugin:"*",methods:["checkPermissions"],order:PERMISSIONS_ORDER,promise:async(e,t)=>{const i=asStatus(await t());const n=idsIn(i);if(n.length===0)return i;for(const o of n){const a=(0,_model.fromCapacitorStatus)(o,i,r);(0,_store.noteReal)(o,a,source(e.plugin));const u=(0,_store.getOverride)(o);(0,_store.recordCall)({source:source(e.plugin),method:`${e.plugin}.checkPermissions`,permission:o,kind:"check",real:a,returned:u??a,overridden:u!==null})}return(0,_model.toCapacitorStatus)(i,_store.getOverride,r)}});(0,_license.interceptCapacitor)({plugin:"*",methods:["requestPermissions"],order:PERMISSIONS_ORDER,promise:async(e,t)=>{const i=Array.isArray(e.options.permissions)?e.options.permissions.map(String):null;const n=s=>{const c=(0,_model.capacitorAliasId)(s);return c!==null&&(0,_store.getOverride)(c)!==null};const o=i??Object.keys(asStatus(await(0,_license.callCapacitorNative)(e.plugin,"checkPermissions").catch(()=>({}))));if(!o.some(n)){const s=asStatus(await t());for(const c of idsIn(s)){const l=(0,_model.fromCapacitorStatus)(c,s,r);(0,_store.noteReal)(c,l,source(e.plugin));(0,_store.recordCall)({source:source(e.plugin),method:`${e.plugin}.requestPermissions`,permission:c,kind:"request",real:l,returned:l,overridden:false})}return s}const a=o.filter(s=>!n(s));let u=a.length?asStatus(await(0,_license.callCapacitorNative)(e.plugin,"requestPermissions",{...e.options,permissions:a})):asStatus(await(0,_license.callCapacitorNative)(e.plugin,"checkPermissions").catch(()=>({})));for(const s of idsIn(u)){if((0,_store.getOverride)(s)!==null)continue;const c=(0,_model.fromCapacitorStatus)(s,u,r);(0,_store.noteReal)(s,c,source(e.plugin));(0,_store.recordCall)({source:source(e.plugin),method:`${e.plugin}.requestPermissions`,permission:s,kind:"request",real:c,returned:c,overridden:false})}const p=new Set;for(const s of o.filter(n)){const c=(0,_model.capacitorAliasId)(s);if(p.has(c))continue;p.add(c);const{state:l,answer:d}=await(0,_store.resolveRequest)(c);(0,_store.recordCall)({source:source(e.plugin),method:`${e.plugin}.requestPermissions`,permission:c,kind:"request",real:null,returned:l,overridden:true,answer:d})}for(const s of o)if(!(s in u))u={...u,[s]:"prompt"};return(0,_model.toCapacitorStatus)(u,_store.getOverride,r)}});for(const e of GATED){(0,_license.interceptCapacitor)({plugin:e.plugin,methods:e.methods,order:PERMISSIONS_ORDER,promise:(t,i)=>{const n=e.permission(t.options);const o=(0,_store.getOverride)(n);if((0,_store.getSettings)().enforce&&o==="limited"&&e.plugin==="Geolocation")return i().then(u=>(0,_coarsenPosition.coarsenPosition)(u));if(!(0,_store.getSettings)().enforce||!refused(o))return i();const a=e.message(n);(0,_store.recordCall)({source:source(e.plugin),method:`${e.plugin}.${t.method}`,permission:n,kind:"gated",real:null,returned:o,overridden:true,error:a});return Promise.reject(new Error(a))}})}(0,_license.interceptCapacitor)({plugin:"Geolocation",methods:["watchPosition"],order:PERMISSIONS_ORDER,callback:(e,t,i)=>{const n=(0,_store.getOverride)("location");if((0,_store.getSettings)().enforce&&n==="limited")return i((a,u)=>t(u?a:(0,_coarsenPosition.coarsenPosition)(a),u));if(!(0,_store.getSettings)().enforce||!refused(n))return i(t);const o="Location permission was denied";(0,_store.recordCall)({source:source("Geolocation"),method:"Geolocation.watchPosition",permission:"location",kind:"gated",real:null,returned:n,overridden:true,error:o});setTimeout(()=>t(null,new Error(o)),0);return(0,_license.makeCapacitorCallbackId)()}});for(const e of KNOWN_PLUGINS){if(!(0,_license.hasCapacitorPlugin)(e.plugin))continue;const t=Object.keys(e.aliases);(0,_store.registerLibrary)(e.library,t);for(const i of t){const n=e.aliases[i];(0,_store.registerRealRequester)(i,async()=>{const o=asStatus(await(0,_license.callCapacitorNative)(e.plugin,"requestPermissions",{permissions:[n]}));const a=(0,_model.fromCapacitorStatus)(i,o,r);(0,_store.recordCall)({source:e.library,method:`${e.plugin}.requestPermissions (system)`,permission:i,kind:"request",real:a,returned:a,overridden:false});return a})}}return true}async function refreshCapacitorRealStates(){const r=(0,_store.getPlatform)();for(const e of KNOWN_PLUGINS){if(!(0,_license.hasCapacitorPlugin)(e.plugin))continue;try{const t=asStatus(await(0,_license.callCapacitorNative)(e.plugin,"checkPermissions"));for(const i of idsIn(t))(0,_store.noteReal)(i,(0,_model.fromCapacitorStatus)(i,t,r),e.library)}catch{}}}function __resetCapacitorPermissionsForTests(){installed=false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.coarsenPosition=coarsenPosition;function coarsenPosition(e){const o=e;if(!o?.coords||typeof o.coords.latitude!=="number"||typeof o.coords.longitude!=="number")return e;const t=r=>Math.round(r/.02)*.02;return{...o,coords:{...o.coords,latitude:Number(t(o.coords.latitude).toFixed(4)),longitude:Number(t(o.coords.longitude).toFixed(4)),accuracy:Math.max(o.coords.accuracy??0,3e3),altitude:null,altitudeAccuracy:null,heading:null,speed:null}}}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.EXPO_MODULES=void 0;exports.coarsenPosition
|
|
2
|
-
\u2192 Caused by: ${e}`:`Call to function '${s}.${
|
|
3
|
-
\u2192 Caused by: ${e}`}function getterArgs(s,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.EXPO_MODULES=void 0;Object.defineProperty(exports,"coarsenPosition",{enumerable:true,get:function(){return _coarsenPosition.coarsenPosition}});exports.installExpoAdapter=installExpoAdapter;exports.refreshExpoRealStates=refreshExpoRealStates;var _model=require("../model");var _store=require("../store");var _wrap=require("./wrap");var _coarsenPosition=require("./coarsenPosition");const LOCATION_DENIED={ios:{code:"ERR_DENIED_FOREGROUND_LOCATION_PERMISSION",reason:"Location permission is required to do this operation"},android:{code:"ERR_LOCATION_UNAUTHORIZED",reason:"Not authorized to use location services"}};const BACKGROUND_DENIED={ios:{code:"ERR_DENIED_BACKGROUND_LOCATION_PERMISSION",reason:"Background location permission is required to do this operation"},android:{code:"ERR_LOCATION_BACKGROUND_UNAUTHORIZED",reason:"Not authorized to use background location services"}};const EXPO_MODULES=exports.EXPO_MODULES=[{module:"ExpoLocation",library:"expo-location",permissions:[{get:"getForegroundPermissionsAsync",request:"requestForegroundPermissionsAsync",permission:"location",flavor:"location"},{get:"getBackgroundPermissionsAsync",request:"requestBackgroundPermissionsAsync",permission:"locationBackground",flavor:"locationBackground"},{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"location",flavor:"location"}],gated:[{method:"getCurrentPositionAsync",permission:"location",...LOCATION_DENIED},{method:"getLastKnownPositionAsync",permission:"location",...LOCATION_DENIED},{method:"watchPositionImplAsync",permission:"location",...LOCATION_DENIED},{method:"startGeofencingAsync",permission:"locationBackground",...BACKGROUND_DENIED},{method:"startLocationUpdatesAsync",permission:"locationBackground",...BACKGROUND_DENIED}]},{module:"ExpoMaps",library:"expo-maps",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"location",flavor:"plain"}]},{module:"ExpoCamera",library:"expo-camera",permissions:[{get:"getCameraPermissionsAsync",request:"requestCameraPermissionsAsync",permission:"camera",flavor:"plain"},{get:"getMicrophonePermissionsAsync",request:"requestMicrophonePermissionsAsync",permission:"microphone",flavor:"plain"}]},{module:"ExpoNotificationPermissionsModule",library:"expo-notifications",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"notifications",flavor:"notifications",defaultArgs:s=>s==="ios"?[{allowAlert:true,allowBadge:true,allowSound:true}]:[void 0]}]},{module:"ExpoMediaLibrary",library:"expo-media-library",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"photos",flavor:"privileges",defaultArgs:()=>[false]}],gated:["getAssetsAsync","getAlbumsAsync","getAssetInfoAsync","createAssetAsync","saveToLibraryAsync"].map(s=>({method:s,permission:"photos",ios:{code:"ERR_MEDIA_LIBRARY_PERMISSIONS",reason:"Media Library permission is required to do this operation"}}))},{module:"ExponentImagePicker",library:"expo-image-picker",permissions:[{get:"getCameraPermissionsAsync",request:"requestCameraPermissionsAsync",permission:"camera",flavor:"plain"},{get:"getMediaLibraryPermissionsAsync",request:"requestMediaLibraryPermissionsAsync",permission:"photos",flavor:"privileges",defaultArgs:()=>[false]}],gated:[{method:"launchCameraAsync",permission:"camera",ios:{code:"ERR_MISSING_CAMERA_PERMISSION",reason:"Missing camera or camera roll permission"},android:{code:"ERR_USER_REJECTED_PERMISSIONS",reason:"User rejected permissions"}}]},{module:"ExpoContacts",library:"expo-contacts",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"contacts",flavor:"privileges"}]},{module:"ExpoCalendar",library:"expo-calendar",permissions:[{get:"getCalendarPermissionsAsync",request:"requestCalendarPermissionsAsync",permission:"calendar",flavor:"plain"},{get:"getRemindersPermissionsAsync",request:"requestRemindersPermissionsAsync",permission:"reminders",flavor:"plain"}]},{module:"CalendarNext",library:"expo-calendar",permissions:[{get:"getCalendarPermissions",request:"requestCalendarPermissions",permission:"calendar",flavor:"plain"},{get:"getRemindersPermissions",request:"requestRemindersPermissions",permission:"reminders",flavor:"plain"}]},{module:"ExpoTrackingTransparency",library:"expo-tracking-transparency",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"tracking",flavor:"plain"}]},{module:"ExpoAudio",library:"expo-audio",permissions:[{get:"getRecordingPermissionsAsync",request:"requestRecordingPermissionsAsync",permission:"microphone",flavor:"plain"}]},{module:"ExponentPedometer",library:"expo-sensors",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"motion",flavor:"plain"}]}];function expoModules(){const s=globalThis.expo?.modules;return s&&typeof s==="object"?s:null}function names(s){try{return new Set(Object.keys(s))}catch{return new Set}}const refused=s=>s==="denied"||s==="blocked"||s==="restricted"||s==="undetermined";function expoMessage(s,a,e,r){return r==="ios"?`Calling the '${a}' function has failed
|
|
2
|
+
\u2192 Caused by: ${e}`:`Call to function '${s}.${a}' has been rejected.
|
|
3
|
+
\u2192 Caused by: ${e}`}function getterArgs(s,a=[]){if(s.flavor!=="privileges")return[];return a.length>0?a.slice(0,1):[false]}function wrapPermission(s,a,e){const r=a.library;(0,_wrap.wrapMethod)(s,e.get,i=>async(...t)=>{const o=(0,_store.getPlatform)();let n;let c;try{n=await i(...t)}catch(d){c=d}const l=(0,_model.fromExpo)(n,o);(0,_store.noteReal)(e.permission,l,r);const u=(0,_store.getOverride)(e.permission);if(u===null){(0,_store.recordCall)({source:r,method:e.get,permission:e.permission,kind:"check",real:l,returned:l,overridden:false,error:c?String(c?.message??c):void 0});if(c)throw c;return n}const m=(0,_model.toExpo)(u,o,e.flavor,n);(0,_store.recordCall)({source:r,method:e.get,permission:e.permission,kind:"check",real:l,returned:u,overridden:true});return m});(0,_wrap.wrapMethod)(s,e.request,i=>async(...t)=>{const o=(0,_store.getPlatform)();if((0,_store.getOverride)(e.permission)===null){try{const d=await i(...t);const p=(0,_model.fromExpo)(d,o);(0,_store.noteReal)(e.permission,p,r);(0,_store.recordCall)({source:r,method:e.request,permission:e.permission,kind:"request",real:p,returned:p,overridden:false});return d}catch(d){(0,_store.recordCall)({source:r,method:e.request,permission:e.permission,kind:"request",real:null,returned:null,overridden:false,error:String(d?.message??d)});throw d}}let n;const c=s[e.get];try{const d=c.__buoyPermissionsOriginal;n=d?await d.apply(s,getterArgs(e,t)):void 0}catch{n=void 0}const l=(0,_model.fromExpo)(n,o);(0,_store.noteReal)(e.permission,l,r);const{state:u,answer:m}=await(0,_store.resolveRequest)(e.permission);(0,_store.recordCall)({source:r,method:e.request,permission:e.permission,kind:"request",real:l,returned:u,overridden:true,answer:m});return(0,_model.toExpo)(u,o,e.flavor,n)})}const POSITION_METHODS=new Set(["getCurrentPositionAsync","getLastKnownPositionAsync"]);function wrapGated(s,a,e){(0,_wrap.wrapMethod)(s,e.method,r=>(...i)=>{const t=(0,_store.getPlatform)();const o=t==="ios"?e.ios:e.android;const n=(0,_store.getOverride)(e.permission);const c=(0,_store.getSettings)().enforce;if(o&&c&&n!==null&&refused(n)){const l=expoMessage(a.module,e.method,o.reason,t);(0,_store.recordCall)({source:a.library,method:e.method,permission:e.permission,kind:"gated",real:null,returned:n,overridden:true,error:o.code});return Promise.reject((0,_wrap.codedError)(o.code,l))}if(c&&n==="limited"&&POSITION_METHODS.has(e.method)){return Promise.resolve(r(...i)).then(l=>(0,_coarsenPosition.coarsenPosition)(l))}return r(...i)})}function registerRealRequest(s,a,e){(0,_store.registerRealRequester)(e.permission,async()=>{const r=s[e.request];const i=r?.__buoyPermissionsOriginal??r;if(typeof i!=="function")return null;const t=await i.apply(s,e.defaultArgs?.((0,_store.getPlatform)())??[]);const o=(0,_model.fromExpo)(t,(0,_store.getPlatform)());(0,_store.recordCall)({source:a.library,method:`${e.request} (system)`,permission:e.permission,kind:"request",real:o,returned:o,overridden:false});return o})}function installExpoAdapter(){const s=expoModules();if(!s)return[];const a=names(s);const e=[];for(const r of EXPO_MODULES){if(!a.has(r.module))continue;let i;try{i=s[r.module]}catch{i=void 0}if(!i||typeof i!=="object")continue;const t=[];for(const o of r.permissions){if(typeof i[o.get]!=="function")continue;wrapPermission(i,r,o);registerRealRequest(i,r,o);t.push(o.permission)}for(const o of r.gated??[])wrapGated(i,r,o);if(t.length>0){(0,_store.registerLibrary)(r.library,t);e.push(r.library)}}return e}async function refreshExpoRealStates(){const s=expoModules();if(!s)return;const a=names(s);const e=(0,_store.getPlatform)();const r=[];for(const i of EXPO_MODULES){if(!a.has(i.module))continue;const t=s[i.module];if(!t)continue;const o=new Set;for(const n of i.permissions){if(o.has(n.permission))continue;const c=t[n.get];const l=c?.__buoyPermissionsOriginal??c;if(typeof l!=="function")continue;o.add(n.permission);r.push(Promise.resolve().then(()=>l.apply(t,getterArgs(n))).then(u=>(0,_store.noteReal)(n.permission,(0,_model.fromExpo)(u,e),i.library)).catch(()=>{}))}}await Promise.all(r)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.domAlert=void 0;function el(s,o,d,n){const e=s.createElement(o);Object.assign(e.style,d);if(n!==void 0)e.textContent=n;return e}const domAlert=exports.domAlert={alert(s,o,d,n){const e=globalThis.document;if(!e?.body){n?.onDismiss?.();return}const t=el(e,"div",{position:"fixed",inset:"0",zIndex:"2147483000",background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",fontFamily:"-apple-system, system-ui, Roboto, sans-serif"});t.setAttribute("role","alertdialog");t.setAttribute("data-testid","buoy-permission-prompt");const r=el(e,"div",{width:"100%",maxWidth:"290px",background:"#f2f2f7",color:"#000",borderRadius:"14px",overflow:"hidden",textAlign:"center"});r.appendChild(el(e,"div",{padding:"18px 16px 4px",fontWeight:"600",fontSize:"17px",lineHeight:"22px"},s));if(o){r.appendChild(el(e,"div",{padding:"0 16px 16px",fontSize:"13px",lineHeight:"18px",whiteSpace:"pre-line"},o))}let l=false;const p=()=>{l=true;t.remove()};const c=d?.length?d:[{text:"OK"}];for(const i of c){const a=el(e,"button",{display:"block",width:"100%",padding:"11px 8px",border:"0",borderTop:"0.5px solid rgba(60,60,67,0.29)",background:"transparent",color:"#007aff",fontSize:"17px",fontWeight:i.style==="cancel"?"600":"400",cursor:"pointer"},i.text);a.addEventListener("click",()=>{if(l)return;p();i.onPress?.()});r.appendChild(a)}t.appendChild(r);if(n?.cancelable){t.addEventListener("click",i=>{if(l||i.target!==t)return;p();n.onDismiss?.()})}e.body.appendChild(t)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.readExpoConfig=readExpoConfig;let config;function readExpoConfig(){if(config!==void 0)return config;config=null;try{const e=require("expo-constants");config=(e?.default??e)?.expoConfig??null}catch{}return config}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.readExpoConfig=readExpoConfig;exports.setWebAppName=setWebAppName;let appName=null;function setWebAppName(e){appName=e&&e.trim()?e.trim():null}function readExpoConfig(){return appName?{name:appName}:null}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.installPermissions=installPermissions;function installPermissions(){return false}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.installPermissions=installPermissions;var _license=require("@buoy-gg/license");var _capacitor=require("./adapters/capacitor");var _domAlert=require("./domAlert");var _expoConfig=require("./expoConfig.web");var _prompt=require("./prompt");var _store=require("./store");const INSTALLED="__buoyPermissionsInstalled";function notifyApp(){(0,_license.emitCapacitorEvent)("App","appStateChange",{isActive:false});(0,_license.emitCapacitorEvent)("App","pause",{});setTimeout(()=>{(0,_license.emitCapacitorEvent)("App","resume",{});(0,_license.emitCapacitorEvent)("App","appStateChange",{isActive:true})},60)}function installPermissions(){const t=(0,_license.capacitorPlatform)();if(!t)return false;const i=globalThis;if(i[INSTALLED])return false;i[INSTALLED]=true;(0,_store.configurePermissions)({platform:t,host:{isSimulator:null,deviceName:null,bundleId:null}});(0,_store.bootPermissions)();(0,_store.setPrompter)((0,_prompt.createAlertPrompter)(_domAlert.domAlert));const r=globalThis.document?.title??null;(0,_expoConfig.setWebAppName)(r);if((0,_license.hasCapacitorPlugin)("App")){void(0,_license.callCapacitorNative)("App","getInfo").then(e=>(0,_expoConfig.setWebAppName)(e?.name??r)).catch(()=>{})}if(!(0,_capacitor.installCapacitorPermissionsAdapter)())return false;(0,_store.onPermissionChange)(({from:e})=>{if(e==="tool"&&(0,_store.getSettings)().notifyApp)notifyApp()});void(0,_license.loadCapacitorAppHost)().then(e=>{if(e)(0,_store.configurePermissions)({platform:t,host:{isSimulator:e.isSimulator,deviceName:e.deviceName,bundleId:e.bundleId}})});setTimeout(()=>{void(0,_capacitor.refreshCapacitorRealStates)()},1500);return true}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.REQUEST_ANSWERS=exports.PERMISSION_STATES=exports.KNOWN_PERMISSION_IDS=void 0;exports.canPrompt=canPrompt;exports.fromExpo=fromExpo;exports.fromRnp=fromRnp;exports.isPermissionId=isPermissionId;exports.isSupported=isSupported;exports.normalizeState=normalizeState;exports.permissionInfo=permissionInfo;exports.promptChoices=promptChoices;exports.settingsLabel=settingsLabel;exports.stateAfterRequest=stateAfterRequest;exports.stateDescription=stateDescription;exports.stateLabel=stateLabel;exports.supportedStates=supportedStates;exports.toAndroidCheck=toAndroidCheck;exports.toAndroidRequestResult=toAndroidRequestResult;exports.toExpo=toExpo;exports.toRnp=toRnp;const PERMISSION_STATES=exports.PERMISSION_STATES=["undetermined","granted","limited","denied","blocked","restricted"];const REQUEST_ANSWERS=exports.REQUEST_ANSWERS=["ask","allow","limited","deny"];const CATALOG={location:{id:"location",label:"Location",limited:{ios:"Approximate",android:"Approximate"},purpose:"use your location"},locationBackground:{id:"locationBackground",label:"Background Location",purpose:"use your location in the background"},camera:{id:"camera",label:"Camera",purpose:"access your camera"},microphone:{id:"microphone",label:"Microphone",purpose:"access your microphone"},notifications:{id:"notifications",label:"Notifications",limited:{ios:"Provisional"},purpose:"send you notifications"},photos:{id:"photos",label:"Photos",limited:{ios:"Selected Photos",android:"Selected Photos"},purpose:"access your photos"},contacts:{id:"contacts",label:"Contacts",limited:{ios:"Selected Contacts"},purpose:"access your contacts"},calendar:{id:"calendar",label:"Calendar",purpose:"access your calendar"},reminders:{id:"reminders",label:"Reminders",only:"ios",purpose:"access your reminders"},tracking:{id:"tracking",label:"Tracking",only:"ios",purpose:"track your activity across other companies' apps and websites"},motion:{id:"motion",label:"Motion & Fitness",purpose:"access your motion and fitness activity"},bluetooth:{id:"bluetooth",label:"Bluetooth",purpose:"use Bluetooth"}};const KNOWN_PERMISSION_IDS=exports.KNOWN_PERMISSION_IDS=Object.keys(CATALOG);function isPermissionId(e){return typeof e==="string"&&(e in CATALOG||e.startsWith("android:")&&e.length>8)}function permissionInfo(e){const i=CATALOG[e];if(i)return i;const n=e.slice("android:".length).replace(/^android\.permission\./,"");return{id:e,label:n.toLowerCase().split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),only:"android",purpose:`use ${n.toLowerCase().replace(/_/g," ")}`}}function supportedStates(e,i){const n=permissionInfo(e);const o=["undetermined","granted"];if(n.limited?.[i])o.push("limited");o.push("denied");if(i==="android")o.push("blocked");if(i==="ios"&&e!=="notifications")o.push("restricted");return o}function isSupported(e,i,n){return supportedStates(e,i).includes(n)}function normalizeState(e,i,n){if(isSupported(e,i,n))return n;if(n==="blocked")return"denied";if(n==="restricted")return i==="android"?"blocked":"denied";if(n==="limited")return"granted";return n}function canPrompt(e,i){if(i==="undetermined")return true;return e==="android"&&i==="denied"}function stateAfterRequest(e,i,n,o){if(!canPrompt(i,n))return n;if(o==="allow"||o==="once")return"granted";if(o==="limited")return isSupported(e,i,"limited")?"limited":"granted";if(i==="android")return n==="denied"?"blocked":"denied";return"denied"}function offersOnce(e,i){if(i==="ios")return e==="location";return e==="camera"||e==="microphone"}function promptChoices(e,i){const n=permissionInfo(e);const o=n.limited?.[i];const t=i==="ios";const r=[];if(t&&offersOnce(e,i))r.push({answer:"once",label:"Allow Once"});if(e==="location"||e==="locationBackground"){r.push({answer:"allow",label:t?"Allow While Using App":"While using the app"})}else{r.push({answer:"allow",label:"Allow"})}if(!t&&offersOnce(e,i))r.push({answer:"once",label:"Only this time"});if(o){const d=e==="location"?t?"Allow With Approximate Location":"Approximate location":e==="photos"?t?"Limit Access\u2026":"Select photos":e==="contacts"?"Select Contacts\u2026":`Allow ${o}`;r.push({answer:"limited",label:d})}r.push({answer:"deny",label:t?"Don\u2019t Allow":"Don\u2019t allow"});return r}function settingsLabel(e,i,n){if(i==="ios"){if(e==="location"||e==="locationBackground"){if(n==="undetermined")return"Ask Next Time";if(n==="granted")return e==="locationBackground"?"Always":"While Using the App";if(n==="limited")return"While Using the App, Approximate";if(n==="denied")return"Never"}if(e==="photos"||e==="contacts"){if(n==="granted")return"Full Access";if(n==="limited")return"Limited Access";if(n==="denied")return"None"}if(e==="notifications"){if(n==="granted")return"Allow Notifications";if(n==="limited")return"Deliver Quietly";if(n==="denied")return"Off"}if(n==="granted")return"Allow";if(n==="denied")return"Don\u2019t Allow"}else{if(e==="location"&&n==="granted")return"Allow only while using the app";if(e==="location"&&n==="limited")return"While using the app, approximate";if(e==="photos"&&n==="granted")return"Allow all";if(e==="photos"&&n==="limited")return"Allow limited access";if(n==="granted")return"Allow";if(n==="denied")return"Don\u2019t allow"}return stateLabel(e,i,n)}function stateDescription(e,i,n){switch(n){case"undetermined":return"Never asked. The next request shows a prompt.";case"granted":return"Full access.";case"limited":if(e==="location")return"Allowed, with an approximate position.";if(e==="photos")return"Allowed for the photos the person picked.";if(e==="contacts")return"Allowed for the contacts the person picked.";if(e==="notifications")return"Delivered quietly to Notification Center, without asking.";return"Partial access.";case"denied":return i==="ios"?"The person said no. The app can't ask again, only send them to Settings.":"The person said no once. The app can ask one more time.";case"blocked":return"The person said no for good. Only Settings can change it.";case"restricted":return"Turned off by Screen Time or device management. The person can't change it."}}function fromExpo(e,i){if(!e||typeof e!=="object")return null;const n=e;const o=typeof n.ios?.status==="number"?n.ios.status:void 0;if(o===3||o===4)return"limited";if(n.status==="granted"){if(n.accessPrivileges==="limited")return"limited";if(n.ios?.accuracy==="reduced")return"limited";if(n.android?.accuracy==="coarse")return"limited";return"granted"}if(n.status==="denied"){if(i==="android"&&n.canAskAgain===false)return"blocked";return"denied"}if(n.status==="undetermined")return"undetermined";return null}function fromRnp(e,i){switch(e){case"granted":return"granted";case"limited":return"limited";case"blocked":return i==="ios"?"denied":"blocked";case"denied":return i==="ios"?"undetermined":"denied";default:return null}}const NOTIFICATION_SETTING_KEYS=["allowsAlert","allowsBadge","allowsSound","allowsDisplayInNotificationCenter","allowsDisplayOnLockScreen","allowsDisplayInCarPlay","allowsCriticalAlerts","allowsAnnouncements"];function toExpo(e,i,n,o){const t=o&&typeof o==="object"?o:{};const r=e==="granted"||e==="limited";const d=r?"granted":e==="undetermined"?"undetermined":"denied";const u=e==="undetermined"||i==="android"&&e==="denied";const s={...t,status:d,granted:r,canAskAgain:u,expires:"never"};if(n==="privileges"){s.accessPrivileges=e==="granted"?"all":e==="limited"?"limited":"none"}if(n==="location"||n==="locationBackground"){const l=n==="locationBackground";if(i==="ios"){const c=r?l?"always":"whenInUse":"none";s.ios={...t.ios??{},scope:c,accuracy:e==="limited"?"reduced":"full"};if("scope"in t)s.scope=c}else{const c=e==="granted"?"fine":e==="limited"?"coarse":"none";s.android={...t.android??{},accuracy:c};if("scope"in t)s.scope=c}}if(n==="notifications"){if(i==="ios"){const l=e==="granted"?2:e==="limited"?3:e==="undetermined"?0:1;if(e==="limited"){s.status="undetermined";s.granted=false;s.canAskAgain=true}const c={...t.ios??{},status:l};for(const a of NOTIFICATION_SETTING_KEYS){c[a]=e==="undetermined"?null:e==="granted"?true:e==="limited"?a==="allowsDisplayInNotificationCenter":false}c.alertStyle=e==="granted"?1:0;s.ios=c}else{s.android={...t.android??{},importance:r?3:0}}}return s}function toRnp(e,i){switch(e){case"granted":return"granted";case"limited":return"limited";case"undetermined":return"denied";case"denied":return i==="ios"?"blocked":"denied";case"blocked":case"restricted":return"blocked"}}function toAndroidRequestResult(e){if(e==="granted"||e==="limited")return"granted";if(e==="blocked"||e==="restricted")return"never_ask_again";return"denied"}function toAndroidCheck(e,i){if(e==="granted")return true;if(e!=="limited")return false;return/ACCESS_COARSE_LOCATION|READ_MEDIA_VISUAL_USER_SELECTED/.test(i)}function stateLabel(e,i,n){switch(n){case"undetermined":return"Not Asked";case"granted":return"Allowed";case"limited":return permissionInfo(e).limited?.[i]??"Limited";case"denied":return"Denied";case"blocked":return"Blocked";case"restricted":return"Restricted"}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.REQUEST_ANSWERS=exports.PERMISSION_STATES=exports.KNOWN_PERMISSION_IDS=void 0;exports.canPrompt=canPrompt;exports.capacitorAliasId=capacitorAliasId;exports.fromCapacitor=fromCapacitor;exports.fromCapacitorStatus=fromCapacitorStatus;exports.fromExpo=fromExpo;exports.fromRnp=fromRnp;exports.isPermissionId=isPermissionId;exports.isSupported=isSupported;exports.normalizeState=normalizeState;exports.permissionInfo=permissionInfo;exports.promptChoices=promptChoices;exports.settingsLabel=settingsLabel;exports.stateAfterRequest=stateAfterRequest;exports.stateDescription=stateDescription;exports.stateLabel=stateLabel;exports.supportedStates=supportedStates;exports.toAndroidCheck=toAndroidCheck;exports.toAndroidRequestResult=toAndroidRequestResult;exports.toCapacitor=toCapacitor;exports.toCapacitorStatus=toCapacitorStatus;exports.toExpo=toExpo;exports.toRnp=toRnp;const PERMISSION_STATES=exports.PERMISSION_STATES=["undetermined","granted","limited","denied","blocked","restricted"];const REQUEST_ANSWERS=exports.REQUEST_ANSWERS=["ask","allow","limited","deny"];const CATALOG={location:{id:"location",label:"Location",limited:{ios:"Approximate",android:"Approximate"},purpose:"use your location"},locationBackground:{id:"locationBackground",label:"Background Location",purpose:"use your location in the background"},camera:{id:"camera",label:"Camera",purpose:"access your camera"},microphone:{id:"microphone",label:"Microphone",purpose:"access your microphone"},notifications:{id:"notifications",label:"Notifications",limited:{ios:"Provisional"},purpose:"send you notifications"},photos:{id:"photos",label:"Photos",limited:{ios:"Selected Photos",android:"Selected Photos"},purpose:"access your photos"},contacts:{id:"contacts",label:"Contacts",limited:{ios:"Selected Contacts"},purpose:"access your contacts"},calendar:{id:"calendar",label:"Calendar",purpose:"access your calendar"},reminders:{id:"reminders",label:"Reminders",only:"ios",purpose:"access your reminders"},tracking:{id:"tracking",label:"Tracking",only:"ios",purpose:"track your activity across other companies' apps and websites"},motion:{id:"motion",label:"Motion & Fitness",purpose:"access your motion and fitness activity"},bluetooth:{id:"bluetooth",label:"Bluetooth",purpose:"use Bluetooth"}};const KNOWN_PERMISSION_IDS=exports.KNOWN_PERMISSION_IDS=Object.keys(CATALOG);function isPermissionId(e){return typeof e==="string"&&(e in CATALOG||e.startsWith("android:")&&e.length>8)}function permissionInfo(e){const i=CATALOG[e];if(i)return i;const n=e.slice("android:".length).replace(/^android\.permission\./,"");return{id:e,label:n.toLowerCase().split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "),only:"android",purpose:`use ${n.toLowerCase().replace(/_/g," ")}`}}function supportedStates(e,i){const n=permissionInfo(e);const t=["undetermined","granted"];if(n.limited?.[i])t.push("limited");t.push("denied");if(i==="android")t.push("blocked");if(i==="ios"&&e!=="notifications")t.push("restricted");return t}function isSupported(e,i,n){return supportedStates(e,i).includes(n)}function normalizeState(e,i,n){if(isSupported(e,i,n))return n;if(n==="blocked")return"denied";if(n==="restricted")return i==="android"?"blocked":"denied";if(n==="limited")return"granted";return n}function canPrompt(e,i){if(i==="undetermined")return true;return e==="android"&&i==="denied"}function stateAfterRequest(e,i,n,t){if(!canPrompt(i,n))return n;if(t==="allow"||t==="once")return"granted";if(t==="limited")return isSupported(e,i,"limited")?"limited":"granted";if(i==="android")return n==="denied"?"blocked":"denied";return"denied"}function offersOnce(e,i){if(i==="ios")return e==="location";return e==="camera"||e==="microphone"}function promptChoices(e,i){const n=permissionInfo(e);const t=n.limited?.[i];const o=i==="ios";const r=[];if(o&&offersOnce(e,i))r.push({answer:"once",label:"Allow Once"});if(e==="location"||e==="locationBackground"){r.push({answer:"allow",label:o?"Allow While Using App":"While using the app"})}else{r.push({answer:"allow",label:"Allow"})}if(!o&&offersOnce(e,i))r.push({answer:"once",label:"Only this time"});if(t){const a=e==="location"?o?"Allow With Approximate Location":"Approximate location":e==="photos"?o?"Limit Access\u2026":"Select photos":e==="contacts"?"Select Contacts\u2026":`Allow ${t}`;r.push({answer:"limited",label:a})}r.push({answer:"deny",label:o?"Don\u2019t Allow":"Don\u2019t allow"});return r}function settingsLabel(e,i,n){if(i==="ios"){if(e==="location"||e==="locationBackground"){if(n==="undetermined")return"Ask Next Time";if(n==="granted")return e==="locationBackground"?"Always":"While Using the App";if(n==="limited")return"While Using the App, Approximate";if(n==="denied")return"Never"}if(e==="photos"||e==="contacts"){if(n==="granted")return"Full Access";if(n==="limited")return"Limited Access";if(n==="denied")return"None"}if(e==="notifications"){if(n==="granted")return"Allow Notifications";if(n==="limited")return"Deliver Quietly";if(n==="denied")return"Off"}if(n==="granted")return"Allow";if(n==="denied")return"Don\u2019t Allow"}else{if(e==="location"&&n==="granted")return"Allow only while using the app";if(e==="location"&&n==="limited")return"While using the app, approximate";if(e==="photos"&&n==="granted")return"Allow all";if(e==="photos"&&n==="limited")return"Allow limited access";if(n==="granted")return"Allow";if(n==="denied")return"Don\u2019t allow"}return stateLabel(e,i,n)}function stateDescription(e,i,n){switch(n){case"undetermined":return"Never asked. The next request shows a prompt.";case"granted":return"Full access.";case"limited":if(e==="location")return"Allowed, with an approximate position.";if(e==="photos")return"Allowed for the photos the person picked.";if(e==="contacts")return"Allowed for the contacts the person picked.";if(e==="notifications")return"Delivered quietly to Notification Center, without asking.";return"Partial access.";case"denied":return i==="ios"?"The person said no. The app can't ask again, only send them to Settings.":"The person said no once. The app can ask one more time.";case"blocked":return"The person said no for good. Only Settings can change it.";case"restricted":return"Turned off by Screen Time or device management. The person can't change it."}}function fromExpo(e,i){if(!e||typeof e!=="object")return null;const n=e;const t=typeof n.ios?.status==="number"?n.ios.status:void 0;if(t===3||t===4)return"limited";if(n.status==="granted"){if(n.accessPrivileges==="limited")return"limited";if(n.ios?.accuracy==="reduced")return"limited";if(n.android?.accuracy==="coarse")return"limited";return"granted"}if(n.status==="denied"){if(i==="android"&&n.canAskAgain===false)return"blocked";return"denied"}if(n.status==="undetermined")return"undetermined";return null}function fromRnp(e,i){switch(e){case"granted":return"granted";case"limited":return"limited";case"blocked":return i==="ios"?"denied":"blocked";case"denied":return i==="ios"?"undetermined":"denied";default:return null}}const NOTIFICATION_SETTING_KEYS=["allowsAlert","allowsBadge","allowsSound","allowsDisplayInNotificationCenter","allowsDisplayOnLockScreen","allowsDisplayInCarPlay","allowsCriticalAlerts","allowsAnnouncements"];function toExpo(e,i,n,t){const o=t&&typeof t==="object"?t:{};const r=e==="granted"||e==="limited";const a=r?"granted":e==="undetermined"?"undetermined":"denied";const u=e==="undetermined"||i==="android"&&e==="denied";const s={...o,status:a,granted:r,canAskAgain:u,expires:"never"};if(n==="privileges"){s.accessPrivileges=e==="granted"?"all":e==="limited"?"limited":"none"}if(n==="location"||n==="locationBackground"){const d=n==="locationBackground";if(i==="ios"){const c=r?d?"always":"whenInUse":"none";s.ios={...o.ios??{},scope:c,accuracy:e==="limited"?"reduced":"full"};if("scope"in o)s.scope=c}else{const c=e==="granted"?"fine":e==="limited"?"coarse":"none";s.android={...o.android??{},accuracy:c};if("scope"in o)s.scope=c}}if(n==="notifications"){if(i==="ios"){const d=e==="granted"?2:e==="limited"?3:e==="undetermined"?0:1;if(e==="limited"){s.status="undetermined";s.granted=false;s.canAskAgain=true}const c={...o.ios??{},status:d};for(const l of NOTIFICATION_SETTING_KEYS){c[l]=e==="undetermined"?null:e==="granted"?true:e==="limited"?l==="allowsDisplayInNotificationCenter":false}c.alertStyle=e==="granted"?1:0;s.ios=c}else{s.android={...o.android??{},importance:r?3:0}}}return s}function toRnp(e,i){switch(e){case"granted":return"granted";case"limited":return"limited";case"undetermined":return"denied";case"denied":return i==="ios"?"blocked":"denied";case"blocked":case"restricted":return"blocked"}}function toAndroidRequestResult(e){if(e==="granted"||e==="limited")return"granted";if(e==="blocked"||e==="restricted")return"never_ask_again";return"denied"}function toAndroidCheck(e,i){if(e==="granted")return true;if(e!=="limited")return false;return/ACCESS_COARSE_LOCATION|READ_MEDIA_VISUAL_USER_SELECTED/.test(i)}function stateLabel(e,i,n){switch(n){case"undetermined":return"Not Asked";case"granted":return"Allowed";case"limited":return permissionInfo(e).limited?.[i]??"Limited";case"denied":return"Denied";case"blocked":return"Blocked";case"restricted":return"Restricted"}}const CAPACITOR_ALIASES={location:"location",coarseLocation:"location",camera:"camera",photos:"photos",receive:"notifications",display:"notifications",notifications:"notifications",microphone:"microphone",contacts:"contacts",calendar:"calendar",reminders:"reminders",bluetooth:"bluetooth",motion:"motion",tracking:"tracking"};function capacitorAliasId(e){return CAPACITOR_ALIASES[e]??null}function fromCapacitor(e,i){switch(e){case"granted":return"granted";case"limited":return"limited";case"prompt":return"undetermined";case"prompt-with-rationale":return i==="android"?"denied":"undetermined";case"denied":return i==="android"?"blocked":"denied";default:return null}}function toCapacitor(e,i){switch(e){case"granted":return"granted";case"limited":return"limited";case"undetermined":return"prompt";case"denied":return i==="android"?"prompt-with-rationale":"denied";case"blocked":case"restricted":return"denied"}}function fromCapacitorStatus(e,i,n){if(e==="location"&&"location"in i){const t=fromCapacitor(i.location,n);const o=fromCapacitor(i.coarseLocation,n);if(t!=="granted"&&o==="granted")return"limited";return t}for(const[t,o]of Object.entries(i)){if(capacitorAliasId(t)===e)return fromCapacitor(o,n)}return null}function toCapacitorStatus(e,i,n){const t={...e};for(const o of Object.keys(e)){const r=capacitorAliasId(o);if(!r)continue;const a=i(r);if(a===null)continue;if(r==="location"&&a==="limited"){t[o]=o==="coarseLocation"||n==="ios"?"granted":"denied"}else if(a==="limited"&&r!=="photos"&&r!=="contacts"){t[o]="granted"}else{t[o]=toCapacitor(a,n)}}return t}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createAlertPrompter=createAlertPrompter;exports.readPurposeString=readPurposeString;var _model=require("./model");var _store=require("./store");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createAlertPrompter=createAlertPrompter;exports.readPurposeString=readPurposeString;var _model=require("./model");var _store=require("./store");var _expoConfig=require("./expoConfig");function readAppName(){const s=(0,_expoConfig.readExpoConfig)()?.name;return typeof s==="string"&&s?s:"This app"}const PURPOSE_SOURCES={location:{plist:["NSLocationWhenInUseUsageDescription"],plugins:[["expo-location","locationWhenInUsePermission"]]},locationBackground:{plist:["NSLocationAlwaysAndWhenInUseUsageDescription"],plugins:[["expo-location","locationAlwaysAndWhenInUsePermission"]]},camera:{plist:["NSCameraUsageDescription"],plugins:[["expo-camera","cameraPermission"],["expo-image-picker","cameraPermission"]]},microphone:{plist:["NSMicrophoneUsageDescription"],plugins:[["expo-audio","microphonePermission"],["expo-camera","microphonePermission"],["expo-image-picker","microphonePermission"]]},photos:{plist:["NSPhotoLibraryUsageDescription"],plugins:[["expo-image-picker","photosPermission"],["expo-media-library","photosPermission"]]},contacts:{plist:["NSContactsUsageDescription"],plugins:[["expo-contacts","contactsPermission"]]},calendar:{plist:["NSCalendarsFullAccessUsageDescription","NSCalendarsUsageDescription"],plugins:[["expo-calendar","calendarPermission"]]},reminders:{plist:["NSRemindersFullAccessUsageDescription","NSRemindersUsageDescription"],plugins:[["expo-calendar","remindersPermission"]]},tracking:{plist:["NSUserTrackingUsageDescription"],plugins:[["expo-tracking-transparency","userTrackingPermission"]]},motion:{plist:["NSMotionUsageDescription"],plugins:[["expo-sensors","motionPermission"]]},bluetooth:{plist:["NSBluetoothAlwaysUsageDescription"],plugins:[]}};function readPurposeString(s){const n=PURPOSE_SOURCES[s];const r=(0,_expoConfig.readExpoConfig)();if(!n||!r)return null;const a=readAppName();const p=e=>typeof e==="string"&&e.trim()?e.replace(/\$\(PRODUCT_NAME\)/g,a).trim():null;for(const e of n.plist){const i=p(r.ios?.infoPlist?.[e]);if(i)return i}for(const[e,i]of n.plugins){for(const o of r.plugins??[]){if(Array.isArray(o)&&o[0]===e&&o[1]&&typeof o[1]==="object"){const c=p(o[1][i]);if(c)return c}}}return null}const BUOY_NOTE="Test prompt from Buoy. Your phone's settings won't change.";let queue=Promise.resolve();function createAlertPrompter(s){return n=>{const r=()=>new Promise(p=>{const e=(0,_store.getPlatform)();const i=(0,_model.permissionInfo)(n);const o=readAppName();const c=e==="ios"?`Allow \u201C${o}\u201D to ${i.purpose}?`:`Allow ${o} to ${i.purpose}?`;const g=(0,_model.promptChoices)(n,e);let l=false;const u=t=>{if(l)return;l=true;p(t)};const m=e==="ios"?readPurposeString(n):null;s.alert(c,m?`${m}
|
|
2
2
|
|
|
3
|
-
${BUOY_NOTE}`:BUOY_NOTE,g.map(
|
|
3
|
+
${BUOY_NOTE}`:BUOY_NOTE,g.map(t=>({text:t.label,style:t.answer==="deny"?"cancel":"default",onPress:()=>u(t.answer)})),{cancelable:e==="android",onDismiss:()=>u("deny")})});const a=queue.then(r,r);queue=a.catch(()=>{});return a}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.readSavedSync=readSavedSync;function readSavedSync(){return void 0}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.readSavedSync=readSavedSync;var _persistence=require("./persistence");function readSavedSync(){try{const e=globalThis.localStorage;if(!e)return void 0;return(0,_persistence.parseSaved)(e.getItem(_persistence.PERMISSIONS_STORAGE_KEY))}catch{return void 0}}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"KNOWN_PERMISSION_IDS",{enumerable:true,get:function(){return _model.KNOWN_PERMISSION_IDS}});Object.defineProperty(exports,"PERMISSIONS_CHIP_ID",{enumerable:true,get:function(){return _PermissionsChip.PERMISSIONS_CHIP_ID}});Object.defineProperty(exports,"PERMISSIONS_ICON_COLOR",{enumerable:true,get:function(){return _sharedUi.PERMISSIONS_ICON_COLOR}});Object.defineProperty(exports,"PERMISSION_STATES",{enumerable:true,get:function(){return _model.PERMISSION_STATES}});Object.defineProperty(exports,"PermissionsBody",{enumerable:true,get:function(){return _PermissionsBody.PermissionsBody}});Object.defineProperty(exports,"PermissionsChip",{enumerable:true,get:function(){return _PermissionsChip.PermissionsChip}});Object.defineProperty(exports,"PermissionsIcon",{enumerable:true,get:function(){return _sharedUi.PermissionsIcon}});Object.defineProperty(exports,"PermissionsToolView",{enumerable:true,get:function(){return _PermissionsToolView.PermissionsToolView}});Object.defineProperty(exports,"clearPermissionOverride",{enumerable:true,get:function(){return _store.clearOverride}});Object.defineProperty(exports,"createPermissionsTool",{enumerable:true,get:function(){return _preset.createPermissionsTool}});Object.defineProperty(exports,"getPermissionOverride",{enumerable:true,get:function(){return _store.getOverride}});Object.defineProperty(exports,"getPermissionsSnapshot",{enumerable:true,get:function(){return _store.getPermissionsSnapshot}});Object.defineProperty(exports,"installPermissions",{enumerable:true,get:function(){return _install.installPermissions}});Object.defineProperty(exports,"isPermissionOverridden",{enumerable:true,get:function(){return _store.isOverridden}});Object.defineProperty(exports,"openPermissionsChip",{enumerable:true,get:function(){return _PermissionsChip.openPermissionsChip}});Object.defineProperty(exports,"permissionInfo",{enumerable:true,get:function(){return _model.permissionInfo}});Object.defineProperty(exports,"permissionsSyncAdapter",{enumerable:true,get:function(){return _permissionsSyncAdapter.permissionsSyncAdapter}});Object.defineProperty(exports,"permissionsToolPreset",{enumerable:true,get:function(){return _preset.permissionsToolPreset}});Object.defineProperty(exports,"resetPermissions",{enumerable:true,get:function(){return _store.resetPermissions}});Object.defineProperty(exports,"setPermissionOverride",{enumerable:true,get:function(){return _store.setOverride}});Object.defineProperty(exports,"stateLabel",{enumerable:true,get:function(){return _model.stateLabel}});Object.defineProperty(exports,"subscribePermissions",{enumerable:true,get:function(){return _store.subscribePermissions}});Object.defineProperty(exports,"supportedStates",{enumerable:true,get:function(){return _model.supportedStates}});Object.defineProperty(exports,"updatePermissionSettings",{enumerable:true,get:function(){return _store.updatePermissionSettings}});var _install=require("./engine/install");var _PermissionsChip=require("./components/PermissionsChip");var _preset=require("./preset");var _PermissionsBody=require("./components/PermissionsBody");var _PermissionsToolView=require("./components/PermissionsToolView");var _sharedUi=require("@buoy-gg/shared-ui");var _permissionsSyncAdapter=require("./sync/permissionsSyncAdapter");var _store=require("./engine/store");var _model=require("./engine/model");const isReactNativeRuntime=typeof navigator!=="undefined"&&navigator.product==="ReactNative";if(isReactNativeRuntime&&typeof __DEV__!=="undefined"&&__DEV__){(0,_install.installPermissions)();(0,_PermissionsChip.watchPermissionsChip)()}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"KNOWN_PERMISSION_IDS",{enumerable:true,get:function(){return _model.KNOWN_PERMISSION_IDS}});Object.defineProperty(exports,"PERMISSIONS_CHIP_ID",{enumerable:true,get:function(){return _PermissionsChip.PERMISSIONS_CHIP_ID}});Object.defineProperty(exports,"PERMISSIONS_ICON_COLOR",{enumerable:true,get:function(){return _sharedUi.PERMISSIONS_ICON_COLOR}});Object.defineProperty(exports,"PERMISSION_STATES",{enumerable:true,get:function(){return _model.PERMISSION_STATES}});Object.defineProperty(exports,"PermissionsBody",{enumerable:true,get:function(){return _PermissionsBody.PermissionsBody}});Object.defineProperty(exports,"PermissionsChip",{enumerable:true,get:function(){return _PermissionsChip.PermissionsChip}});Object.defineProperty(exports,"PermissionsIcon",{enumerable:true,get:function(){return _sharedUi.PermissionsIcon}});Object.defineProperty(exports,"PermissionsToolView",{enumerable:true,get:function(){return _PermissionsToolView.PermissionsToolView}});Object.defineProperty(exports,"clearPermissionOverride",{enumerable:true,get:function(){return _store.clearOverride}});Object.defineProperty(exports,"createPermissionsTool",{enumerable:true,get:function(){return _preset.createPermissionsTool}});Object.defineProperty(exports,"getPermissionOverride",{enumerable:true,get:function(){return _store.getOverride}});Object.defineProperty(exports,"getPermissionsSnapshot",{enumerable:true,get:function(){return _store.getPermissionsSnapshot}});Object.defineProperty(exports,"installPermissions",{enumerable:true,get:function(){return _install.installPermissions}});Object.defineProperty(exports,"isPermissionOverridden",{enumerable:true,get:function(){return _store.isOverridden}});Object.defineProperty(exports,"openPermissionsChip",{enumerable:true,get:function(){return _PermissionsChip.openPermissionsChip}});Object.defineProperty(exports,"permissionInfo",{enumerable:true,get:function(){return _model.permissionInfo}});Object.defineProperty(exports,"permissionsSyncAdapter",{enumerable:true,get:function(){return _permissionsSyncAdapter.permissionsSyncAdapter}});Object.defineProperty(exports,"permissionsToolPreset",{enumerable:true,get:function(){return _preset.permissionsToolPreset}});Object.defineProperty(exports,"resetPermissions",{enumerable:true,get:function(){return _store.resetPermissions}});Object.defineProperty(exports,"setPermissionOverride",{enumerable:true,get:function(){return _store.setOverride}});Object.defineProperty(exports,"stateLabel",{enumerable:true,get:function(){return _model.stateLabel}});Object.defineProperty(exports,"subscribePermissions",{enumerable:true,get:function(){return _store.subscribePermissions}});Object.defineProperty(exports,"supportedStates",{enumerable:true,get:function(){return _model.supportedStates}});Object.defineProperty(exports,"updatePermissionSettings",{enumerable:true,get:function(){return _store.updatePermissionSettings}});var _install=require("./engine/install");var _PermissionsChip=require("./components/PermissionsChip");var _preset=require("./preset");var _PermissionsBody=require("./components/PermissionsBody");var _PermissionsToolView=require("./components/PermissionsToolView");var _sharedUi=require("@buoy-gg/shared-ui");var _permissionsSyncAdapter=require("./sync/permissionsSyncAdapter");var _store=require("./engine/store");var _model=require("./engine/model");const isReactNativeRuntime=typeof navigator!=="undefined"&&navigator.product==="ReactNative";const isCapacitorShell=(()=>{try{const e=globalThis.Capacitor;return e?.isNativePlatform?.()===true}catch{return false}})();if((isReactNativeRuntime||isCapacitorShell)&&typeof __DEV__!=="undefined"&&__DEV__){(0,_install.installPermissions)();(0,_PermissionsChip.watchPermissionsChip)()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export function installCapacitorPermissionsAdapter(){return false}export async function refreshCapacitorRealStates(){}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{coarsenPosition as R}from"./coarsenPosition";import{callCapacitorNative as g,hasCapacitorPlugin as A,installCapacitorBridge as L,interceptCapacitor as P,makeCapacitorCallbackId as N}from"@buoy-gg/license";import{capacitorAliasId as b,fromCapacitorStatus as h,toCapacitorStatus as G}from"../model";import{getOverride as l,getPlatform as O,getSettings as y,noteReal as k,recordCall as p,registerLibrary as E,registerRealRequester as j,resolveRequest as _}from"../store";const w=10;const v=[{plugin:"Geolocation",library:"@capacitor/geolocation",aliases:{location:"location"}},{plugin:"Camera",library:"@capacitor/camera",aliases:{camera:"camera",photos:"photos"}},{plugin:"PushNotifications",library:"@capacitor/push-notifications",aliases:{notifications:"receive"}},{plugin:"LocalNotifications",library:"@capacitor/local-notifications",aliases:{notifications:"display"}}];const T=[{plugin:"Geolocation",methods:["getCurrentPosition"],permission:()=>"location",message:()=>"Location permission was denied"},{plugin:"Camera",methods:["getPhoto","pickImages","pickLimitedLibraryPhotos"],permission:o=>o.source==="CAMERA"?"camera":"photos",message:o=>o==="camera"?"User denied access to camera":"User denied access to photos"}];function d(o){return v.find(e=>e.plugin===o)?.library??`Capacitor ${o}`}const $=o=>o==="denied"||o==="blocked"||o==="restricted";function C(o){const e=new Set;for(const s of Object.keys(o)){const i=b(s);if(i)e.add(i)}return Array.from(e)}function m(o){return o&&typeof o==="object"?o:{}}let q=false;export function installCapacitorPermissionsAdapter(){if(q)return true;if(!L())return false;q=true;const o=O();P({plugin:"*",methods:["checkPermissions"],order:w,promise:async(e,s)=>{const i=m(await s());const n=C(i);if(n.length===0)return i;for(const r of n){const a=h(r,i,o);k(r,a,d(e.plugin));const u=l(r);p({source:d(e.plugin),method:`${e.plugin}.checkPermissions`,permission:r,kind:"check",real:a,returned:u??a,overridden:u!==null})}return G(i,l,o)}});P({plugin:"*",methods:["requestPermissions"],order:w,promise:async(e,s)=>{const i=Array.isArray(e.options.permissions)?e.options.permissions.map(String):null;const n=t=>{const c=b(t);return c!==null&&l(c)!==null};const r=i??Object.keys(m(await g(e.plugin,"checkPermissions").catch(()=>({}))));if(!r.some(n)){const t=m(await s());for(const c of C(t)){const f=h(c,t,o);k(c,f,d(e.plugin));p({source:d(e.plugin),method:`${e.plugin}.requestPermissions`,permission:c,kind:"request",real:f,returned:f,overridden:false})}return t}const a=r.filter(t=>!n(t));let u=a.length?m(await g(e.plugin,"requestPermissions",{...e.options,permissions:a})):m(await g(e.plugin,"checkPermissions").catch(()=>({})));for(const t of C(u)){if(l(t)!==null)continue;const c=h(t,u,o);k(t,c,d(e.plugin));p({source:d(e.plugin),method:`${e.plugin}.requestPermissions`,permission:t,kind:"request",real:c,returned:c,overridden:false})}const S=new Set;for(const t of r.filter(n)){const c=b(t);if(S.has(c))continue;S.add(c);const{state:f,answer:I}=await _(c);p({source:d(e.plugin),method:`${e.plugin}.requestPermissions`,permission:c,kind:"request",real:null,returned:f,overridden:true,answer:I})}for(const t of r)if(!(t in u))u={...u,[t]:"prompt"};return G(u,l,o)}});for(const e of T){P({plugin:e.plugin,methods:e.methods,order:w,promise:(s,i)=>{const n=e.permission(s.options);const r=l(n);if(y().enforce&&r==="limited"&&e.plugin==="Geolocation")return i().then(u=>R(u));if(!y().enforce||!$(r))return i();const a=e.message(n);p({source:d(e.plugin),method:`${e.plugin}.${s.method}`,permission:n,kind:"gated",real:null,returned:r,overridden:true,error:a});return Promise.reject(new Error(a))}})}P({plugin:"Geolocation",methods:["watchPosition"],order:w,callback:(e,s,i)=>{const n=l("location");if(y().enforce&&n==="limited")return i((a,u)=>s(u?a:R(a),u));if(!y().enforce||!$(n))return i(s);const r="Location permission was denied";p({source:d("Geolocation"),method:"Geolocation.watchPosition",permission:"location",kind:"gated",real:null,returned:n,overridden:true,error:r});setTimeout(()=>s(null,new Error(r)),0);return N()}});for(const e of v){if(!A(e.plugin))continue;const s=Object.keys(e.aliases);E(e.library,s);for(const i of s){const n=e.aliases[i];j(i,async()=>{const r=m(await g(e.plugin,"requestPermissions",{permissions:[n]}));const a=h(i,r,o);p({source:e.library,method:`${e.plugin}.requestPermissions (system)`,permission:i,kind:"request",real:a,returned:a,overridden:false});return a})}}return true}export async function refreshCapacitorRealStates(){const o=O();for(const e of v){if(!A(e.plugin))continue;try{const s=m(await g(e.plugin,"checkPermissions"));for(const i of C(s))k(i,h(i,s,o),e.library)}catch{}}}export function __resetCapacitorPermissionsForTests(){q=false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export function coarsenPosition(t){const o=t;if(!o?.coords||typeof o.coords.latitude!=="number"||typeof o.coords.longitude!=="number")return t;const e=u=>Math.round(u/.02)*.02;return{...o,coords:{...o.coords,latitude:Number(e(o.coords.latitude).toFixed(4)),longitude:Number(e(o.coords.longitude).toFixed(4)),accuracy:Math.max(o.coords.accuracy??0,3e3),altitude:null,altitudeAccuracy:null,heading:null,speed:null}}}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";import{fromExpo as f,toExpo as E}from"../model";import{getOverride as
|
|
2
|
-
\u2192 Caused by: ${e}`:`Call to function '${s}.${
|
|
3
|
-
\u2192 Caused by: ${e}`}function x(s,
|
|
1
|
+
"use strict";import{fromExpo as f,toExpo as E}from"../model";import{getOverride as P,getPlatform as p,getSettings as O,noteReal as g,recordCall as d,registerLibrary as _,registerRealRequester as C,resolveRequest as I}from"../store";import{codedError as S,wrapMethod as h}from"./wrap";const q={ios:{code:"ERR_DENIED_FOREGROUND_LOCATION_PERMISSION",reason:"Location permission is required to do this operation"},android:{code:"ERR_LOCATION_UNAUTHORIZED",reason:"Not authorized to use location services"}};const R={ios:{code:"ERR_DENIED_BACKGROUND_LOCATION_PERMISSION",reason:"Background location permission is required to do this operation"},android:{code:"ERR_LOCATION_BACKGROUND_UNAUTHORIZED",reason:"Not authorized to use background location services"}};export const EXPO_MODULES=[{module:"ExpoLocation",library:"expo-location",permissions:[{get:"getForegroundPermissionsAsync",request:"requestForegroundPermissionsAsync",permission:"location",flavor:"location"},{get:"getBackgroundPermissionsAsync",request:"requestBackgroundPermissionsAsync",permission:"locationBackground",flavor:"locationBackground"},{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"location",flavor:"location"}],gated:[{method:"getCurrentPositionAsync",permission:"location",...q},{method:"getLastKnownPositionAsync",permission:"location",...q},{method:"watchPositionImplAsync",permission:"location",...q},{method:"startGeofencingAsync",permission:"locationBackground",...R},{method:"startLocationUpdatesAsync",permission:"locationBackground",...R}]},{module:"ExpoMaps",library:"expo-maps",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"location",flavor:"plain"}]},{module:"ExpoCamera",library:"expo-camera",permissions:[{get:"getCameraPermissionsAsync",request:"requestCameraPermissionsAsync",permission:"camera",flavor:"plain"},{get:"getMicrophonePermissionsAsync",request:"requestMicrophonePermissionsAsync",permission:"microphone",flavor:"plain"}]},{module:"ExpoNotificationPermissionsModule",library:"expo-notifications",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"notifications",flavor:"notifications",defaultArgs:s=>s==="ios"?[{allowAlert:true,allowBadge:true,allowSound:true}]:[void 0]}]},{module:"ExpoMediaLibrary",library:"expo-media-library",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"photos",flavor:"privileges",defaultArgs:()=>[false]}],gated:["getAssetsAsync","getAlbumsAsync","getAssetInfoAsync","createAssetAsync","saveToLibraryAsync"].map(s=>({method:s,permission:"photos",ios:{code:"ERR_MEDIA_LIBRARY_PERMISSIONS",reason:"Media Library permission is required to do this operation"}}))},{module:"ExponentImagePicker",library:"expo-image-picker",permissions:[{get:"getCameraPermissionsAsync",request:"requestCameraPermissionsAsync",permission:"camera",flavor:"plain"},{get:"getMediaLibraryPermissionsAsync",request:"requestMediaLibraryPermissionsAsync",permission:"photos",flavor:"privileges",defaultArgs:()=>[false]}],gated:[{method:"launchCameraAsync",permission:"camera",ios:{code:"ERR_MISSING_CAMERA_PERMISSION",reason:"Missing camera or camera roll permission"},android:{code:"ERR_USER_REJECTED_PERMISSIONS",reason:"User rejected permissions"}}]},{module:"ExpoContacts",library:"expo-contacts",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"contacts",flavor:"privileges"}]},{module:"ExpoCalendar",library:"expo-calendar",permissions:[{get:"getCalendarPermissionsAsync",request:"requestCalendarPermissionsAsync",permission:"calendar",flavor:"plain"},{get:"getRemindersPermissionsAsync",request:"requestRemindersPermissionsAsync",permission:"reminders",flavor:"plain"}]},{module:"CalendarNext",library:"expo-calendar",permissions:[{get:"getCalendarPermissions",request:"requestCalendarPermissions",permission:"calendar",flavor:"plain"},{get:"getRemindersPermissions",request:"requestRemindersPermissions",permission:"reminders",flavor:"plain"}]},{module:"ExpoTrackingTransparency",library:"expo-tracking-transparency",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"tracking",flavor:"plain"}]},{module:"ExpoAudio",library:"expo-audio",permissions:[{get:"getRecordingPermissionsAsync",request:"requestRecordingPermissionsAsync",permission:"microphone",flavor:"plain"}]},{module:"ExponentPedometer",library:"expo-sensors",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"motion",flavor:"plain"}]}];function v(){const s=globalThis.expo?.modules;return s&&typeof s==="object"?s:null}function b(s){try{return new Set(Object.keys(s))}catch{return new Set}}const N=s=>s==="denied"||s==="blocked"||s==="restricted"||s==="undetermined";function k(s,a,e,r){return r==="ios"?`Calling the '${a}' function has failed
|
|
2
|
+
\u2192 Caused by: ${e}`:`Call to function '${s}.${a}' has been rejected.
|
|
3
|
+
\u2192 Caused by: ${e}`}function x(s,a=[]){if(s.flavor!=="privileges")return[];return a.length>0?a.slice(0,1):[false]}function w(s,a,e){const r=a.library;h(s,e.get,i=>async(...t)=>{const o=p();let n;let c;try{n=await i(...t)}catch(u){c=u}const l=f(n,o);g(e.permission,l,r);const m=P(e.permission);if(m===null){d({source:r,method:e.get,permission:e.permission,kind:"check",real:l,returned:l,overridden:false,error:c?String(c?.message??c):void 0});if(c)throw c;return n}const y=E(m,o,e.flavor,n);d({source:r,method:e.get,permission:e.permission,kind:"check",real:l,returned:m,overridden:true});return y});h(s,e.request,i=>async(...t)=>{const o=p();if(P(e.permission)===null){try{const u=await i(...t);const A=f(u,o);g(e.permission,A,r);d({source:r,method:e.request,permission:e.permission,kind:"request",real:A,returned:A,overridden:false});return u}catch(u){d({source:r,method:e.request,permission:e.permission,kind:"request",real:null,returned:null,overridden:false,error:String(u?.message??u)});throw u}}let n;const c=s[e.get];try{const u=c.__buoyPermissionsOriginal;n=u?await u.apply(s,x(e,t)):void 0}catch{n=void 0}const l=f(n,o);g(e.permission,l,r);const{state:m,answer:y}=await I(e.permission);d({source:r,method:e.request,permission:e.permission,kind:"request",real:l,returned:m,overridden:true,answer:y});return E(m,o,e.flavor,n)})}const M=new Set(["getCurrentPositionAsync","getLastKnownPositionAsync"]);export{coarsenPosition}from"./coarsenPosition";import{coarsenPosition as D}from"./coarsenPosition";function L(s,a,e){h(s,e.method,r=>(...i)=>{const t=p();const o=t==="ios"?e.ios:e.android;const n=P(e.permission);const c=O().enforce;if(o&&c&&n!==null&&N(n)){const l=k(a.module,e.method,o.reason,t);d({source:a.library,method:e.method,permission:e.permission,kind:"gated",real:null,returned:n,overridden:true,error:o.code});return Promise.reject(S(o.code,l))}if(c&&n==="limited"&&M.has(e.method)){return Promise.resolve(r(...i)).then(l=>D(l))}return r(...i)})}function T(s,a,e){C(e.permission,async()=>{const r=s[e.request];const i=r?.__buoyPermissionsOriginal??r;if(typeof i!=="function")return null;const t=await i.apply(s,e.defaultArgs?.(p())??[]);const o=f(t,p());d({source:a.library,method:`${e.request} (system)`,permission:e.permission,kind:"request",real:o,returned:o,overridden:false});return o})}export function installExpoAdapter(){const s=v();if(!s)return[];const a=b(s);const e=[];for(const r of EXPO_MODULES){if(!a.has(r.module))continue;let i;try{i=s[r.module]}catch{i=void 0}if(!i||typeof i!=="object")continue;const t=[];for(const o of r.permissions){if(typeof i[o.get]!=="function")continue;w(i,r,o);T(i,r,o);t.push(o.permission)}for(const o of r.gated??[])L(i,r,o);if(t.length>0){_(r.library,t);e.push(r.library)}}return e}export async function refreshExpoRealStates(){const s=v();if(!s)return;const a=b(s);const e=p();const r=[];for(const i of EXPO_MODULES){if(!a.has(i.module))continue;const t=s[i.module];if(!t)continue;const o=new Set;for(const n of i.permissions){if(o.has(n.permission))continue;const c=t[n.get];const l=c?.__buoyPermissionsOriginal??c;if(typeof l!=="function")continue;o.add(n.permission);r.push(Promise.resolve().then(()=>l.apply(t,x(n))).then(m=>g(n.permission,f(m,e),i.library)).catch(()=>{}))}}await Promise.all(r)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function o(l,d,r,n){const e=l.createElement(d);Object.assign(e.style,r);if(n!==void 0)e.textContent=n;return e}export const domAlert={alert(l,d,r,n){const e=globalThis.document;if(!e?.body){n?.onDismiss?.();return}const t=o(e,"div",{position:"fixed",inset:"0",zIndex:"2147483000",background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",fontFamily:"-apple-system, system-ui, Roboto, sans-serif"});t.setAttribute("role","alertdialog");t.setAttribute("data-testid","buoy-permission-prompt");const s=o(e,"div",{width:"100%",maxWidth:"290px",background:"#f2f2f7",color:"#000",borderRadius:"14px",overflow:"hidden",textAlign:"center"});s.appendChild(o(e,"div",{padding:"18px 16px 4px",fontWeight:"600",fontSize:"17px",lineHeight:"22px"},l));if(d){s.appendChild(o(e,"div",{padding:"0 16px 16px",fontSize:"13px",lineHeight:"18px",whiteSpace:"pre-line"},d))}let a=false;const p=()=>{a=true;t.remove()};const f=r?.length?r:[{text:"OK"}];for(const i of f){const c=o(e,"button",{display:"block",width:"100%",padding:"11px 8px",border:"0",borderTop:"0.5px solid rgba(60,60,67,0.29)",background:"transparent",color:"#007aff",fontSize:"17px",fontWeight:i.style==="cancel"?"600":"400",cursor:"pointer"},i.text);c.addEventListener("click",()=>{if(a)return;p();i.onPress?.()});s.appendChild(c)}t.appendChild(s);if(n?.cancelable){t.addEventListener("click",i=>{if(a||i.target!==t)return;p();n.onDismiss?.()})}e.body.appendChild(t)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";let n;export function readExpoConfig(){if(n!==void 0)return n;n=null;try{const t=require("expo-constants");n=(t?.default??t)?.expoConfig??null}catch{}return n}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";let e=null;export function setWebAppName(t){e=t&&t.trim()?t.trim():null}export function readExpoConfig(){return e?{name:e}:null}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export function installPermissions(){return false}
|
|
1
|
+
"use strict";import{callCapacitorNative as p,capacitorPlatform as l,emitCapacitorEvent as e,hasCapacitorPlugin as m,loadCapacitorAppHost as u}from"@buoy-gg/license";import{installCapacitorPermissionsAdapter as c,refreshCapacitorRealStates as f}from"./adapters/capacitor";import{domAlert as d}from"./domAlert";import{setWebAppName as a}from"./expoConfig.web";import{createAlertPrompter as A}from"./prompt";import{bootPermissions as g,configurePermissions as s,getSettings as v,onPermissionChange as P,setPrompter as h}from"./store";const n="__buoyPermissionsInstalled";function C(){e("App","appStateChange",{isActive:false});e("App","pause",{});setTimeout(()=>{e("App","resume",{});e("App","appStateChange",{isActive:true})},60)}export function installPermissions(){const i=l();if(!i)return false;const o=globalThis;if(o[n])return false;o[n]=true;s({platform:i,host:{isSimulator:null,deviceName:null,bundleId:null}});g();h(A(d));const r=globalThis.document?.title??null;a(r);if(m("App")){void p("App","getInfo").then(t=>a(t?.name??r)).catch(()=>{})}if(!c())return false;P(({from:t})=>{if(t==="tool"&&v().notifyApp)C()});void u().then(t=>{if(t)s({platform:i,host:{isSimulator:t.isSimulator,deviceName:t.deviceName,bundleId:t.bundleId}})});setTimeout(()=>{void f()},1500);return true}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export const PERMISSION_STATES=["undetermined","granted","limited","denied","blocked","restricted"];export const REQUEST_ANSWERS=["ask","allow","limited","deny"];const
|
|
1
|
+
"use strict";export const PERMISSION_STATES=["undetermined","granted","limited","denied","blocked","restricted"];export const REQUEST_ANSWERS=["ask","allow","limited","deny"];const l={location:{id:"location",label:"Location",limited:{ios:"Approximate",android:"Approximate"},purpose:"use your location"},locationBackground:{id:"locationBackground",label:"Background Location",purpose:"use your location in the background"},camera:{id:"camera",label:"Camera",purpose:"access your camera"},microphone:{id:"microphone",label:"Microphone",purpose:"access your microphone"},notifications:{id:"notifications",label:"Notifications",limited:{ios:"Provisional"},purpose:"send you notifications"},photos:{id:"photos",label:"Photos",limited:{ios:"Selected Photos",android:"Selected Photos"},purpose:"access your photos"},contacts:{id:"contacts",label:"Contacts",limited:{ios:"Selected Contacts"},purpose:"access your contacts"},calendar:{id:"calendar",label:"Calendar",purpose:"access your calendar"},reminders:{id:"reminders",label:"Reminders",only:"ios",purpose:"access your reminders"},tracking:{id:"tracking",label:"Tracking",only:"ios",purpose:"track your activity across other companies' apps and websites"},motion:{id:"motion",label:"Motion & Fitness",purpose:"access your motion and fitness activity"},bluetooth:{id:"bluetooth",label:"Bluetooth",purpose:"use Bluetooth"}};export const KNOWN_PERMISSION_IDS=Object.keys(l);export function isPermissionId(e){return typeof e==="string"&&(e in l||e.startsWith("android:")&&e.length>8)}export function permissionInfo(e){const i=l[e];if(i)return i;const n=e.slice("android:".length).replace(/^android\.permission\./,"");return{id:e,label:n.toLowerCase().split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "),only:"android",purpose:`use ${n.toLowerCase().replace(/_/g," ")}`}}export function supportedStates(e,i){const n=permissionInfo(e);const t=["undetermined","granted"];if(n.limited?.[i])t.push("limited");t.push("denied");if(i==="android")t.push("blocked");if(i==="ios"&&e!=="notifications")t.push("restricted");return t}export function isSupported(e,i,n){return supportedStates(e,i).includes(n)}export function normalizeState(e,i,n){if(isSupported(e,i,n))return n;if(n==="blocked")return"denied";if(n==="restricted")return i==="android"?"blocked":"denied";if(n==="limited")return"granted";return n}export function canPrompt(e,i){if(i==="undetermined")return true;return e==="android"&&i==="denied"}export function stateAfterRequest(e,i,n,t){if(!canPrompt(i,n))return n;if(t==="allow"||t==="once")return"granted";if(t==="limited")return isSupported(e,i,"limited")?"limited":"granted";if(i==="android")return n==="denied"?"blocked":"denied";return"denied"}function p(e,i){if(i==="ios")return e==="location";return e==="camera"||e==="microphone"}export function promptChoices(e,i){const n=permissionInfo(e);const t=n.limited?.[i];const o=i==="ios";const r=[];if(o&&p(e,i))r.push({answer:"once",label:"Allow Once"});if(e==="location"||e==="locationBackground"){r.push({answer:"allow",label:o?"Allow While Using App":"While using the app"})}else{r.push({answer:"allow",label:"Allow"})}if(!o&&p(e,i))r.push({answer:"once",label:"Only this time"});if(t){const s=e==="location"?o?"Allow With Approximate Location":"Approximate location":e==="photos"?o?"Limit Access\u2026":"Select photos":e==="contacts"?"Select Contacts\u2026":`Allow ${t}`;r.push({answer:"limited",label:s})}r.push({answer:"deny",label:o?"Don\u2019t Allow":"Don\u2019t allow"});return r}export function settingsLabel(e,i,n){if(i==="ios"){if(e==="location"||e==="locationBackground"){if(n==="undetermined")return"Ask Next Time";if(n==="granted")return e==="locationBackground"?"Always":"While Using the App";if(n==="limited")return"While Using the App, Approximate";if(n==="denied")return"Never"}if(e==="photos"||e==="contacts"){if(n==="granted")return"Full Access";if(n==="limited")return"Limited Access";if(n==="denied")return"None"}if(e==="notifications"){if(n==="granted")return"Allow Notifications";if(n==="limited")return"Deliver Quietly";if(n==="denied")return"Off"}if(n==="granted")return"Allow";if(n==="denied")return"Don\u2019t Allow"}else{if(e==="location"&&n==="granted")return"Allow only while using the app";if(e==="location"&&n==="limited")return"While using the app, approximate";if(e==="photos"&&n==="granted")return"Allow all";if(e==="photos"&&n==="limited")return"Allow limited access";if(n==="granted")return"Allow";if(n==="denied")return"Don\u2019t allow"}return stateLabel(e,i,n)}export function stateDescription(e,i,n){switch(n){case"undetermined":return"Never asked. The next request shows a prompt.";case"granted":return"Full access.";case"limited":if(e==="location")return"Allowed, with an approximate position.";if(e==="photos")return"Allowed for the photos the person picked.";if(e==="contacts")return"Allowed for the contacts the person picked.";if(e==="notifications")return"Delivered quietly to Notification Center, without asking.";return"Partial access.";case"denied":return i==="ios"?"The person said no. The app can't ask again, only send them to Settings.":"The person said no once. The app can ask one more time.";case"blocked":return"The person said no for good. Only Settings can change it.";case"restricted":return"Turned off by Screen Time or device management. The person can't change it."}}export function fromExpo(e,i){if(!e||typeof e!=="object")return null;const n=e;const t=typeof n.ios?.status==="number"?n.ios.status:void 0;if(t===3||t===4)return"limited";if(n.status==="granted"){if(n.accessPrivileges==="limited")return"limited";if(n.ios?.accuracy==="reduced")return"limited";if(n.android?.accuracy==="coarse")return"limited";return"granted"}if(n.status==="denied"){if(i==="android"&&n.canAskAgain===false)return"blocked";return"denied"}if(n.status==="undetermined")return"undetermined";return null}export function fromRnp(e,i){switch(e){case"granted":return"granted";case"limited":return"limited";case"blocked":return i==="ios"?"denied":"blocked";case"denied":return i==="ios"?"undetermined":"denied";default:return null}}const m=["allowsAlert","allowsBadge","allowsSound","allowsDisplayInNotificationCenter","allowsDisplayOnLockScreen","allowsDisplayInCarPlay","allowsCriticalAlerts","allowsAnnouncements"];export function toExpo(e,i,n,t){const o=t&&typeof t==="object"?t:{};const r=e==="granted"||e==="limited";const s=r?"granted":e==="undetermined"?"undetermined":"denied";const f=e==="undetermined"||i==="android"&&e==="denied";const c={...o,status:s,granted:r,canAskAgain:f,expires:"never"};if(n==="privileges"){c.accessPrivileges=e==="granted"?"all":e==="limited"?"limited":"none"}if(n==="location"||n==="locationBackground"){const a=n==="locationBackground";if(i==="ios"){const d=r?a?"always":"whenInUse":"none";c.ios={...o.ios??{},scope:d,accuracy:e==="limited"?"reduced":"full"};if("scope"in o)c.scope=d}else{const d=e==="granted"?"fine":e==="limited"?"coarse":"none";c.android={...o.android??{},accuracy:d};if("scope"in o)c.scope=d}}if(n==="notifications"){if(i==="ios"){const a=e==="granted"?2:e==="limited"?3:e==="undetermined"?0:1;if(e==="limited"){c.status="undetermined";c.granted=false;c.canAskAgain=true}const d={...o.ios??{},status:a};for(const u of m){d[u]=e==="undetermined"?null:e==="granted"?true:e==="limited"?u==="allowsDisplayInNotificationCenter":false}d.alertStyle=e==="granted"?1:0;c.ios=d}else{c.android={...o.android??{},importance:r?3:0}}}return c}export function toRnp(e,i){switch(e){case"granted":return"granted";case"limited":return"limited";case"undetermined":return"denied";case"denied":return i==="ios"?"blocked":"denied";case"blocked":case"restricted":return"blocked"}}export function toAndroidRequestResult(e){if(e==="granted"||e==="limited")return"granted";if(e==="blocked"||e==="restricted")return"never_ask_again";return"denied"}export function toAndroidCheck(e,i){if(e==="granted")return true;if(e!=="limited")return false;return/ACCESS_COARSE_LOCATION|READ_MEDIA_VISUAL_USER_SELECTED/.test(i)}export function stateLabel(e,i,n){switch(n){case"undetermined":return"Not Asked";case"granted":return"Allowed";case"limited":return permissionInfo(e).limited?.[i]??"Limited";case"denied":return"Denied";case"blocked":return"Blocked";case"restricted":return"Restricted"}}const h={location:"location",coarseLocation:"location",camera:"camera",photos:"photos",receive:"notifications",display:"notifications",notifications:"notifications",microphone:"microphone",contacts:"contacts",calendar:"calendar",reminders:"reminders",bluetooth:"bluetooth",motion:"motion",tracking:"tracking"};export function capacitorAliasId(e){return h[e]??null}export function fromCapacitor(e,i){switch(e){case"granted":return"granted";case"limited":return"limited";case"prompt":return"undetermined";case"prompt-with-rationale":return i==="android"?"denied":"undetermined";case"denied":return i==="android"?"blocked":"denied";default:return null}}export function toCapacitor(e,i){switch(e){case"granted":return"granted";case"limited":return"limited";case"undetermined":return"prompt";case"denied":return i==="android"?"prompt-with-rationale":"denied";case"blocked":case"restricted":return"denied"}}export function fromCapacitorStatus(e,i,n){if(e==="location"&&"location"in i){const t=fromCapacitor(i.location,n);const o=fromCapacitor(i.coarseLocation,n);if(t!=="granted"&&o==="granted")return"limited";return t}for(const[t,o]of Object.entries(i)){if(capacitorAliasId(t)===e)return fromCapacitor(o,n)}return null}export function toCapacitorStatus(e,i,n){const t={...e};for(const o of Object.keys(e)){const r=capacitorAliasId(o);if(!r)continue;const s=i(r);if(s===null)continue;if(r==="location"&&s==="limited"){t[o]=o==="coarseLocation"||n==="ios"?"granted":"denied"}else if(s==="limited"&&r!=="photos"&&r!=="contacts"){t[o]="granted"}else{t[o]=toCapacitor(s,n)}}return t}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";import{permissionInfo as
|
|
1
|
+
"use strict";import{permissionInfo as U,promptChoices as x}from"./model";import{getPlatform as y}from"./store";import{readExpoConfig as g}from"./expoConfig";function f(){const s=g()?.name;return typeof s==="string"&&s?s:"This app"}const S={location:{plist:["NSLocationWhenInUseUsageDescription"],plugins:[["expo-location","locationWhenInUsePermission"]]},locationBackground:{plist:["NSLocationAlwaysAndWhenInUseUsageDescription"],plugins:[["expo-location","locationAlwaysAndWhenInUsePermission"]]},camera:{plist:["NSCameraUsageDescription"],plugins:[["expo-camera","cameraPermission"],["expo-image-picker","cameraPermission"]]},microphone:{plist:["NSMicrophoneUsageDescription"],plugins:[["expo-audio","microphonePermission"],["expo-camera","microphonePermission"],["expo-image-picker","microphonePermission"]]},photos:{plist:["NSPhotoLibraryUsageDescription"],plugins:[["expo-image-picker","photosPermission"],["expo-media-library","photosPermission"]]},contacts:{plist:["NSContactsUsageDescription"],plugins:[["expo-contacts","contactsPermission"]]},calendar:{plist:["NSCalendarsFullAccessUsageDescription","NSCalendarsUsageDescription"],plugins:[["expo-calendar","calendarPermission"]]},reminders:{plist:["NSRemindersFullAccessUsageDescription","NSRemindersUsageDescription"],plugins:[["expo-calendar","remindersPermission"]]},tracking:{plist:["NSUserTrackingUsageDescription"],plugins:[["expo-tracking-transparency","userTrackingPermission"]]},motion:{plist:["NSMotionUsageDescription"],plugins:[["expo-sensors","motionPermission"]]},bluetooth:{plist:["NSBluetoothAlwaysUsageDescription"],plugins:[]}};export function readPurposeString(s){const n=S[s];const t=g();if(!n||!t)return null;const p=f();const a=e=>typeof e==="string"&&e.trim()?e.replace(/\$\(PRODUCT_NAME\)/g,p).trim():null;for(const e of n.plist){const i=a(t.ios?.infoPlist?.[e]);if(i)return i}for(const[e,i]of n.plugins){for(const o of t.plugins??[]){if(Array.isArray(o)&&o[0]===e&&o[1]&&typeof o[1]==="object"){const c=a(o[1][i]);if(c)return c}}}return null}const d="Test prompt from Buoy. Your phone's settings won't change.";let P=Promise.resolve();export function createAlertPrompter(s){return n=>{const t=()=>new Promise(a=>{const e=y();const i=U(n);const o=f();const c=e==="ios"?`Allow \u201C${o}\u201D to ${i.purpose}?`:`Allow ${o} to ${i.purpose}?`;const h=x(n,e);let l=false;const m=r=>{if(l)return;l=true;a(r)};const u=e==="ios"?readPurposeString(n):null;s.alert(c,u?`${u}
|
|
2
2
|
|
|
3
|
-
${
|
|
3
|
+
${d}`:d,h.map(r=>({text:r.label,style:r.answer==="deny"?"cancel":"default",onPress:()=>m(r.answer)})),{cancelable:e==="android",onDismiss:()=>m("deny")})});const p=P.then(t,t);P=p.catch(()=>{});return p}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export function readSavedSync(){return void 0}
|
|
1
|
+
"use strict";import{PERMISSIONS_STORAGE_KEY as r,parseSaved as t}from"./persistence";export function readSavedSync(){try{const e=globalThis.localStorage;if(!e)return void 0;return t(e.getItem(r))}catch{return void 0}}
|
package/lib/module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{installPermissions as
|
|
1
|
+
"use strict";import{installPermissions as s}from"./engine/install";import{watchPermissionsChip as r}from"./components/PermissionsChip";const i=typeof navigator!=="undefined"&&navigator.product==="ReactNative";const o=(()=>{try{const e=globalThis.Capacitor;return e?.isNativePlatform?.()===true}catch{return false}})();if((i||o)&&typeof __DEV__!=="undefined"&&__DEV__){s();r()}export{permissionsToolPreset,createPermissionsTool}from"./preset";export{PermissionsBody}from"./components/PermissionsBody";export{PermissionsToolView}from"./components/PermissionsToolView";export{PermissionsChip,openPermissionsChip,PERMISSIONS_CHIP_ID}from"./components/PermissionsChip";export{PermissionsIcon,PERMISSIONS_ICON_COLOR}from"@buoy-gg/shared-ui";export{permissionsSyncAdapter}from"./sync/permissionsSyncAdapter";export{installPermissions}from"./engine/install";export{setOverride as setPermissionOverride,clearOverride as clearPermissionOverride,resetPermissions,updatePermissionSettings,getPermissionsSnapshot,subscribePermissions,isOverridden as isPermissionOverridden,getOverride as getPermissionOverride}from"./engine/store";export{supportedStates,stateLabel,permissionInfo,PERMISSION_STATES,KNOWN_PERMISSION_IDS}from"./engine/model";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function installCapacitorPermissionsAdapter(): boolean;
|
|
2
|
+
/** What the OS says before the app asks: read each known plugin once. */
|
|
3
|
+
export declare function refreshCapacitorRealStates(): Promise<void>;
|
|
4
|
+
export declare function __resetCapacitorPermissionsForTests(): void;
|
|
5
|
+
//# sourceMappingURL=capacitor.web.d.ts.map
|
|
@@ -43,11 +43,7 @@ interface ExpoModuleSpec {
|
|
|
43
43
|
}
|
|
44
44
|
/** Module names and methods, read from the Expo SDK 54/55 native sources. */
|
|
45
45
|
export declare const EXPO_MODULES: ExpoModuleSpec[];
|
|
46
|
-
|
|
47
|
-
* Approximate location, the way iOS reduced accuracy reports it: the
|
|
48
|
-
* coordinate snapped to a grid about 2 km wide and an accuracy of 3 km.
|
|
49
|
-
*/
|
|
50
|
-
export declare function coarsenPosition<T>(position: T): T;
|
|
46
|
+
export { coarsenPosition } from "./coarsenPosition";
|
|
51
47
|
/** Wrap every Expo permission API in the app's binary. Returns the libraries found. */
|
|
52
48
|
export declare function installExpoAdapter(): string[];
|
|
53
49
|
/**
|
|
@@ -56,5 +52,4 @@ export declare function installExpoAdapter(): string[];
|
|
|
56
52
|
* doesn't add entries to the call log.
|
|
57
53
|
*/
|
|
58
54
|
export declare function refreshExpoRealStates(): Promise<void>;
|
|
59
|
-
export {};
|
|
60
55
|
//# sourceMappingURL=expo.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An `Alert.alert` twin for the web build: react-native-web's Alert does
|
|
3
|
+
* nothing, so Buoy's stand-in permission prompt draws its own dialog. Same
|
|
4
|
+
* contract as React Native's (title, message, buttons, cancelable/onDismiss),
|
|
5
|
+
* so `createAlertPrompter` works unchanged. Plain DOM, no React: it shows
|
|
6
|
+
* above the app and above Buoy's own panels.
|
|
7
|
+
*/
|
|
8
|
+
import type { AlertLike } from "./prompt";
|
|
9
|
+
export declare const domAlert: AlertLike;
|
|
10
|
+
//# sourceMappingURL=domAlert.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The app's Expo config, if expo-constants is installed. */
|
|
2
|
+
export type ExpoConfig = {
|
|
3
|
+
name?: unknown;
|
|
4
|
+
ios?: {
|
|
5
|
+
infoPlist?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
plugins?: unknown[];
|
|
8
|
+
};
|
|
9
|
+
export declare function readExpoConfig(): ExpoConfig | null;
|
|
10
|
+
//# sourceMappingURL=expoConfig.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ExpoConfig } from "./expoConfig";
|
|
2
|
+
export type { ExpoConfig } from "./expoConfig";
|
|
3
|
+
/** The app's display name, for the stand-in prompt's title (install.web.ts sets it). */
|
|
4
|
+
export declare function setWebAppName(name: string | null): void;
|
|
5
|
+
/** No Expo config in a browser or a Capacitor WebView; only the app's name. */
|
|
6
|
+
export declare function readExpoConfig(): ExpoConfig | null;
|
|
7
|
+
//# sourceMappingURL=expoConfig.web.d.ts.map
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web and Buoy Desktop render the Permissions panel but never patch
|
|
3
|
-
* permission APIs: the browser has its own permission model, and Desktop
|
|
4
|
-
* shows a phone's state over the socket.
|
|
5
|
-
*/
|
|
6
1
|
export declare function installPermissions(): boolean;
|
|
7
2
|
//# sourceMappingURL=install.web.d.ts.map
|
|
@@ -112,4 +112,22 @@ export declare function toAndroidRequestResult(state: PermissionState): "granted
|
|
|
112
112
|
/** PermissionsAndroid.check's result: is this exact Android permission held? */
|
|
113
113
|
export declare function toAndroidCheck(state: PermissionState, androidPermission: string): boolean;
|
|
114
114
|
export declare function stateLabel(id: PermissionId, platform: Platform, state: PermissionState): string;
|
|
115
|
+
/**
|
|
116
|
+
* Capacitor's permission vocabulary. Android: "prompt-with-rationale" is a
|
|
117
|
+
* first refusal (the app may ask again), and "denied" is final. iOS: "denied"
|
|
118
|
+
* is any refusal. "limited" comes from plugins that support it (photos).
|
|
119
|
+
*/
|
|
120
|
+
export type CapacitorState = "granted" | "denied" | "prompt" | "prompt-with-rationale" | "limited";
|
|
121
|
+
/** The permission an alias stands for, or null to leave the alias alone. */
|
|
122
|
+
export declare function capacitorAliasId(alias: string): PermissionId | null;
|
|
123
|
+
export declare function fromCapacitor(result: unknown, platform: Platform): PermissionState | null;
|
|
124
|
+
export declare function toCapacitor(state: PermissionState, platform: Platform): CapacitorState;
|
|
125
|
+
/**
|
|
126
|
+
* The real state behind a plugin's status object, for one permission. Two
|
|
127
|
+
* aliases can share a permission (`location` + `coarseLocation`): approximate
|
|
128
|
+
* location is "limited" when only the coarse one is granted.
|
|
129
|
+
*/
|
|
130
|
+
export declare function fromCapacitorStatus(id: PermissionId, status: Record<string, unknown>, platform: Platform): PermissionState | null;
|
|
131
|
+
/** A plugin's status object with Buoy's override written into each alias it covers. */
|
|
132
|
+
export declare function toCapacitorStatus(status: Record<string, unknown>, overrides: (id: PermissionId) => PermissionState | null, platform: Platform): Record<string, unknown>;
|
|
115
133
|
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
/**
|
|
1
|
+
import { type SavedPermissions } from "./persistence";
|
|
2
|
+
/**
|
|
3
|
+
* The saved overrides, read synchronously. The web build's persistentStorage
|
|
4
|
+
* writes plain `localStorage`, so saved overrides are in place before the
|
|
5
|
+
* app's first permission check (the Capacitor case). `undefined` when there
|
|
6
|
+
* is no `localStorage`.
|
|
7
|
+
*/
|
|
3
8
|
export declare function readSavedSync(): SavedPermissions | null | undefined;
|
|
4
9
|
//# sourceMappingURL=readSavedSync.web.d.ts.map
|
package/lib/web/index.mjs
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
"use client";var ye=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var ot=Object.prototype.hasOwnProperty;var it=(e,t)=>{for(var n in t)ye(e,n,{get:t[n],enumerable:true})},be=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of nt(t))!ot.call(e,i)&&i!==n&&ye(e,i,{get:()=>t[i],enumerable:!(o=tt(t,i))||o.enumerable});return e},rt=(e,t,n)=>(be(e,t,"default"),n&&be(n,t,"default"));var we=process.env.NODE_ENV!=="production";typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);function ee(){return false}import{useEffect as st,useSyncExternalStore as ve}from"react";var Ae={};it(Ae,{AccessibilityInfo:()=>dt,ActivityIndicator:()=>sn,Alert:()=>cn,Animated:()=>ut,AppRegistry:()=>mt,AppState:()=>ht,Appearance:()=>pt,BackHandler:()=>ft,Button:()=>an,CheckBox:()=>Et,Clipboard:()=>gt,DeviceEventEmitter:()=>Kt,Dimensions:()=>yt,Easing:()=>bt,FlatList:()=>Nt,I18nManager:()=>wt,Image:()=>Dt,ImageBackground:()=>Lt,InteractionManager:()=>At,Keyboard:()=>vt,KeyboardAvoidingView:()=>qt,LayoutAnimation:()=>St,Linking:()=>Pt,LogBox:()=>Wt,Modal:()=>on,NativeEventEmitter:()=>xt,NativeModules:()=>ct,PanResponder:()=>Rt,Picker:()=>_t,PixelRatio:()=>kt,Platform:()=>It,Pressable:()=>nn,ProgressBar:()=>Mt,RefreshControl:()=>Bt,SafeAreaView:()=>$t,ScrollView:()=>Se,SectionList:()=>zt,Share:()=>Tt,StatusBar:()=>jt,StyleSheet:()=>j,Switch:()=>rn,Text:()=>h,TextInput:()=>Xt,Touchable:()=>Ht,TouchableHighlight:()=>en,TouchableNativeFeedback:()=>Vt,TouchableOpacity:()=>P,TouchableWithoutFeedback:()=>tn,UIManager:()=>Ot,Vibration:()=>Ct,View:()=>g,VirtualizedList:()=>Ut,YellowBox:()=>Ft,findNodeHandle:()=>ln,unstable_createElement:()=>lt,useColorScheme:()=>Gt,useLocaleContext:()=>Yt,useWindowDimensions:()=>Jt});rt(Ae,at);import*as at from"react-native-web";import{unstable_createElement as lt,NativeModules as ct,AccessibilityInfo as dt,Animated as ut,Appearance as pt,AppRegistry as mt,AppState as ht,BackHandler as ft,Clipboard as gt,Dimensions as yt,Easing as bt,I18nManager as wt,Keyboard as vt,InteractionManager as At,LayoutAnimation as St,Linking as Pt,NativeEventEmitter as xt,PanResponder as Rt,PixelRatio as kt,Platform as It,Share as Tt,StyleSheet as j,UIManager as Ot,Vibration as Ct,CheckBox as Et,FlatList as Nt,Image as Dt,ImageBackground as Lt,KeyboardAvoidingView as qt,Picker as _t,ProgressBar as Mt,RefreshControl as Bt,SafeAreaView as $t,SectionList as zt,StatusBar as jt,Touchable as Ht,TouchableNativeFeedback as Vt,VirtualizedList as Ut,YellowBox as Ft,LogBox as Wt,DeviceEventEmitter as Kt,useColorScheme as Gt,useLocaleContext as Yt,useWindowDimensions as Jt}from"react-native-web";import*as w from"react-native-web";import{createElement as Zt,forwardRef as Qt}from"react";function A(e){let t=Qt((o,i)=>{let{accessibilityState:l,accessibilityValue:c,...m}=o;for(let d of["busy","checked","disabled","expanded","selected"])l?.[d]!==void 0&&m[`aria-${d}`]===void 0&&(m[`aria-${d}`]=l[d]);for(let[d,u]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))c?.[d]!==void 0&&m[`aria-${u}`]===void 0&&(m[`aria-${u}`]=c[d]);return Zt(e,{...m,ref:i})}),n=e.State;return n&&Object.assign(t,{State:n}),t.displayName=e.displayName??e.name??"NativeWebView",t}var g=A(w.View),h=A(w.Text),Xt=A(w.TextInput),P=A(w.TouchableOpacity),en=A(w.TouchableHighlight),tn=A(w.TouchableWithoutFeedback),nn=A(w.Pressable),Se=A(w.ScrollView),on=A(w.Modal),rn=A(w.Switch),sn=A(w.ActivityIndicator),an=A(w.Button),ln=w.findNodeHandle,cn={alert(e,t,n,o){if(typeof document>"u")return;let i=document.createElement("dialog");i.dataset.buoyRoot="",i.setAttribute("aria-label",e),i.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let l=document.createElement("h2");if(l.textContent=e,l.style.cssText="font-size:18px;margin:0 0 12px",i.appendChild(l),t){let u=document.createElement("p");u.textContent=t,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",i.appendChild(u)}let c=document.createElement("div");c.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let m=n?.length?n:[{text:"OK"}],d=()=>{i.close?.(),i.remove()};for(let u of m){let S=document.createElement("button");S.type="button",S.textContent=u.text??"OK",S.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,S.onclick=()=>{d(),u.onPress?.()},c.appendChild(S)}i.addEventListener("cancel",u=>{u.preventDefault(),o?.cancelable!==false&&(d(),o?.onDismiss?.())}),i.appendChild(c),document.body.appendChild(i),i.showModal?i.showModal():i.setAttribute("open","")}};import{FloatingTool as Pe,PermissionsIcon as xe,X as dn,dismissFloatingTool as un,getFloatingTools as pn,night as L,openBuoyTool as mn,openFloatingTool as Re}from"@buoy-gg/shared-ui/web";var te=["undetermined","granted","limited","denied","blocked","restricted"],hn=["ask","allow","limited","deny"],ne={location:{id:"location",label:"Location",limited:{ios:"Approximate",android:"Approximate"},purpose:"use your location"},locationBackground:{id:"locationBackground",label:"Background Location",purpose:"use your location in the background"},camera:{id:"camera",label:"Camera",purpose:"access your camera"},microphone:{id:"microphone",label:"Microphone",purpose:"access your microphone"},notifications:{id:"notifications",label:"Notifications",limited:{ios:"Provisional"},purpose:"send you notifications"},photos:{id:"photos",label:"Photos",limited:{ios:"Selected Photos",android:"Selected Photos"},purpose:"access your photos"},contacts:{id:"contacts",label:"Contacts",limited:{ios:"Selected Contacts"},purpose:"access your contacts"},calendar:{id:"calendar",label:"Calendar",purpose:"access your calendar"},reminders:{id:"reminders",label:"Reminders",only:"ios",purpose:"access your reminders"},tracking:{id:"tracking",label:"Tracking",only:"ios",purpose:"track your activity across other companies' apps and websites"},motion:{id:"motion",label:"Motion & Fitness",purpose:"access your motion and fitness activity"},bluetooth:{id:"bluetooth",label:"Bluetooth",purpose:"use Bluetooth"}},oe=Object.keys(ne);function ke(e){return typeof e=="string"&&(e in ne||e.startsWith("android:")&&e.length>8)}function R(e){let t=ne[e];if(t)return t;let n=e.slice(8).replace(/^android\.permission\./,"");return{id:e,label:n.toLowerCase().split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),only:"android",purpose:`use ${n.toLowerCase().replace(/_/g," ")}`}}function H(e,t){let n=R(e),o=["undetermined","granted"];return n.limited?.[t]&&o.push("limited"),o.push("denied"),t==="android"&&o.push("blocked"),t==="ios"&&e!=="notifications"&&o.push("restricted"),o}function fn(e,t,n){return H(e,t).includes(n)}function gn(e,t,n){return fn(e,t,n)?n:n==="blocked"?"denied":n==="restricted"?t==="android"?"blocked":"denied":n==="limited"?"granted":n}function yn(e,t,n){switch(n){case"undetermined":return"Never asked. The next request shows a prompt.";case"granted":return"Full access.";case"limited":return e==="location"?"Allowed, with an approximate position.":e==="photos"?"Allowed for the photos the person picked.":e==="contacts"?"Allowed for the contacts the person picked.":e==="notifications"?"Delivered quietly to Notification Center, without asking.":"Partial access.";case"denied":return t==="ios"?"The person said no. The app can't ask again, only send them to Settings.":"The person said no once. The app can ask one more time.";case"blocked":return"The person said no for good. Only Settings can change it.";case"restricted":return"Turned off by Screen Time or device management. The person can't change it."}}function bn(e,t){if(!e||typeof e!="object")return null;let n=e,o=typeof n.ios?.status=="number"?n.ios.status:void 0;return o===3||o===4?"limited":n.status==="granted"?n.accessPrivileges==="limited"||n.ios?.accuracy==="reduced"||n.android?.accuracy==="coarse"?"limited":"granted":n.status==="denied"?t==="android"&&n.canAskAgain===false?"blocked":"denied":n.status==="undetermined"?"undetermined":null}function k(e,t,n){switch(n){case"undetermined":return"Not Asked";case"granted":return"Allowed";case"limited":return R(e).limited?.[t]??"Limited";case"denied":return"Denied";case"blocked":return"Blocked";case"restricted":return"Restricted"}}import{devToolsStorageKeys as wn,persistentStorage as vn}from"@buoy-gg/shared-ui/web";var I={requestAnswer:"ask",persist:true,showChip:true,notifyApp:true,enforce:true,interceptSettings:true},An=wn.permissions.state();function q(e,t){return typeof e=="boolean"?e:t}function Sn(e){let t=e&&typeof e=="object"?e:{};return{requestAnswer:hn.includes(t.requestAnswer)?t.requestAnswer:I.requestAnswer,persist:q(t.persist,I.persist),showChip:q(t.showChip,I.showChip),notifyApp:q(t.notifyApp,I.notifyApp),enforce:q(t.enforce,I.enforce),interceptSettings:q(t.interceptSettings,I.interceptSettings)}}var ie=Promise.resolve();function Ie(e){let t=JSON.stringify(e);return ie=ie.then(()=>vn.setItem(An,t)).catch(()=>{}),ie.then(()=>{})}var Pn=50,Te="__buoyPermissionsStore",Oe=globalThis,r=Oe[Te]??(Oe[Te]={platform:"ios",booted:false,overrides:new Map,settings:{...I},seen:new Map,libraries:new Set,log:[],nextLogId:1,listeners:new Set,snapshot:null,prompter:null,changeHooks:new Set,realRequesters:new Map,host:{isSimulator:null,deviceName:null,bundleId:null},once:new Set});r.once??(r.once=new Set);var V=()=>{let e=globalThis.__buoyRealNow;return typeof e=="function"?e():Date.now()};function T(){r.snapshot=null;for(let e of Array.from(r.listeners))try{e()}catch{}}function _(){if(!r.settings.persist){Ie({v:1,overrides:{},settings:r.settings});return}Ie(xn())}function xn(){return{v:1,overrides:Object.fromEntries(Array.from(r.overrides,([e,t])=>[e,r.once.has(e)?"undetermined":t])),settings:r.settings}}function C(e){let t=r.seen.get(e);return t||(t={sources:new Set,real:null,calls:0,lastCallAt:null,lastReadAt:null,changedAt:null},r.seen.set(e,t)),t}async function Rn(e){let t=re(e),n=r.realRequesters.get(t);if(!n)throw new Error(`No installed library can ask the system for ${R(t).label}.`);let o=await n();return o!==null&&Ee(t,o),y()}function U(e,t){for(let n of Array.from(r.changeHooks))try{n({id:e,from:t})}catch{}}function Ce(){return r.platform}function kn(){return r.settings}function In(e){return r.overrides.get(e)??null}function Tn(e){return r.overrides.has(e)}function On(){return r.overrides.size>0}function Ee(e,t,n){if(t===null)return;let o=C(e);n&&o.sources.add(n),o.real!==t&&(o.real=t,T())}function re(e){if(!ke(e))throw new Error(`Unknown permission "${String(e)}". Use one of: ${oe.join(", ")}, or android:<android.permission.NAME>.`);return e}function Ne(e,t){let n=re(e);if(!te.includes(t))throw new Error(`Unknown state "${String(t)}". Use one of: ${te.join(", ")}.`);let o=t,i=H(n,r.platform),l=r.platform==="ios"&&o==="blocked"?"denied":o;if(!i.includes(l))throw new Error(`${R(n).label} can't be "${o}" on ${r.platform}. It can be: ${i.join(", ")}.`);return(r.overrides.get(n)!==l||r.once.has(n))&&(r.overrides.set(n,l),r.once.delete(n),C(n).changedAt=V(),_(),T(),U(n,"tool")),y()}function De(e){let t=re(e);return r.overrides.delete(t)&&(r.once.delete(t),C(t).changedAt=V(),_(),T(),U(t,"tool")),y()}function se(){if(r.overrides.size>0){let e=V();for(let t of r.overrides.keys())C(t).changedAt=e;r.overrides.clear(),r.once.clear(),_(),T(),U(null,"tool")}return y()}function Cn(){return Object.fromEntries(r.overrides)}function En(e){let t=V();for(let n of r.overrides.keys())C(n).changedAt=t;r.overrides.clear(),r.once.clear();for(let[n,o]of Object.entries(e)){let i=n;!o||!ke(i)||(r.overrides.set(i,gn(i,r.platform,o)),C(i).changedAt=t)}return _(),T(),U(null,"tool"),y()}function Le(e){let t={};for(let[o,i]of Object.entries(e))i!==void 0&&(t[o]=i);if(t.requestAnswer!==void 0&&!["ask","allow","limited","deny"].includes(t.requestAnswer))throw new Error('requestAnswer must be "ask", "allow", "limited" or "deny".');let n=Sn({...r.settings,...t});return r.settings=n,_(),T(),y()}function Nn(){r.log=[];for(let e of r.seen.values())e.calls=0,e.lastCallAt=null;return T(),y()}function Dn(e,t){if(!e||!t)return null;let n=o=>o==="granted"||o==="limited";return n(e)&&!n(t)?"The phone hasn't allowed this, so calls that need it, like getting a position or a photo, still fail.":null}function y(){if(r.snapshot)return r.snapshot;let e=new Set([...r.seen.keys(),...r.overrides.keys()]),t=o=>{let i=oe.indexOf(o);return i===-1?1e3:i},n=Array.from(e).filter(o=>{let i=R(o).only;return!i||i===r.platform}).sort((o,i)=>t(o)-t(i)||o.localeCompare(i)).map(o=>{let i=r.seen.get(o),l=r.overrides.get(o)??null,c=i?.real??null;return{id:o,label:R(o).label,states:H(o,r.platform),override:l,real:c,effective:l??c,sources:i?Array.from(i.sources).sort():[],calls:i?.calls??0,lastCallAt:i?.lastCallAt??null,lastReadAt:i?.lastReadAt??null,changedAt:i?.changedAt??null,stale:i?.changedAt!=null&&i.lastReadAt!=null&&i.lastReadAt<i.changedAt,once:r.once.has(o),warning:Dn(l,c),canRequestReal:r.realRequesters.has(o)}});return r.snapshot={platform:r.platform,host:r.host,libraries:Array.from(r.libraries).sort(),permissions:n,overriddenCount:r.overrides.size,settings:r.settings,log:r.log.slice(0,Pn)},r.snapshot}function M(e){return r.listeners.add(e),()=>r.listeners.delete(e)}import{jsx as v,jsxs as ae}from"react/jsx-runtime";var F="permissions-chip",Ln=8e3,qe={id:F,render:e=>v(Be,{...e})},qn=()=>pn().some(e=>e.id===F);function _n(){Re(qe)}var E=null,le=new Set,W=()=>{};function K(e){E&&clearTimeout(E.timer),E=e;for(let t of Array.from(le))t();W()}function Mn(e){return le.add(e),()=>{le.delete(e)}}var _e=()=>E;function Bn(){K({overrides:Cn(),timer:setTimeout(()=>K(null),Ln)}),se()}function $n(){let e=E;e&&(K(null),En(e.overrides))}var Me=false;function zn(){if(Me)return;Me=true;let e=false;W=()=>{let t=(On()||E!==null)&&kn().showChip;t&&!e?Re(qe):!t&&qn()&&un(F),e=t},M(W),W()}function Be({id:e,revealToken:t}){let n=ve(M,y,y),o=ve(Mn,_e,_e);st(()=>{o&&n.overriddenCount>0&&K(null)},[o,n.overriddenCount]);let i=n.permissions.filter(m=>m.override!==null),l=i.length===1?i[0]:null,c=l?`${l.label}: ${l.once&&l.override==="granted"?"Allowed Once":k(l.id,n.platform,l.override)}`:`${i.length} permissions simulated`;return o&&i.length===0?v(Pe,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:"Move or hide the permissions strip",handleAdornment:v(xe,{size:12}),children:ae(g,{style:x.row,children:[v(h,{style:x.title,numberOfLines:1,testID:"permissions-chip-summary",children:"Real permissions"}),v(P,{testID:"permissions-chip-undo",accessibilityRole:"button",accessibilityLabel:"Undo, put the simulated permissions back",onPress:$n,style:x.undo,hitSlop:{top:8,bottom:8,left:8,right:8},children:v(h,{style:x.undoText,children:"Undo"})})]})}):v(Pe,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the permissions strip. ${c}`,handleAdornment:v(xe,{size:12}),children:ae(g,{style:x.row,children:[ae(P,{testID:"permissions-chip-open",accessibilityRole:"button",accessibilityLabel:`${c}. Open Permissions`,onPress:()=>{mn("permissions")},style:x.open,children:[v(g,{style:x.dot}),v(h,{style:x.title,numberOfLines:1,testID:"permissions-chip-summary",children:c})]}),v(g,{style:x.separator}),v(P,{testID:"permissions-chip-reset",accessibilityRole:"button",accessibilityLabel:"Use real permissions",onPress:Bn,style:x.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:v(dn,{size:16,color:L.color.textSecondary})})]})})}var x=j.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingLeft:12,paddingRight:4,minHeight:40,minWidth:200},open:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:1},dot:{width:7,height:7,borderRadius:4,backgroundColor:L.color.accent},title:{color:L.color.text,fontSize:14,fontWeight:"600",flexShrink:1},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},undo:{paddingHorizontal:12,paddingVertical:6},undoText:{color:L.color.accent,fontSize:14,fontWeight:"600"},separator:{width:j.hairlineWidth,height:20,backgroundColor:L.color.separator}});import{PermissionsIcon as jn,PERMISSIONS_ICON_COLOR as Hn,createToolFactory as Vn,defineToolPreset as Un}from"@buoy-gg/shared-ui/web";import{useEffect as Fn,useSyncExternalStore as Wn}from"react";import{reloadApp as Kn}from"@buoy-gg/shared-ui/web";var ce={ios:{code:"ERR_DENIED_FOREGROUND_LOCATION_PERMISSION",reason:"Location permission is required to do this operation"},android:{code:"ERR_LOCATION_UNAUTHORIZED",reason:"Not authorized to use location services"}},$e={ios:{code:"ERR_DENIED_BACKGROUND_LOCATION_PERMISSION",reason:"Background location permission is required to do this operation"},android:{code:"ERR_LOCATION_BACKGROUND_UNAUTHORIZED",reason:"Not authorized to use background location services"}},Gn=[{module:"ExpoLocation",library:"expo-location",permissions:[{get:"getForegroundPermissionsAsync",request:"requestForegroundPermissionsAsync",permission:"location",flavor:"location"},{get:"getBackgroundPermissionsAsync",request:"requestBackgroundPermissionsAsync",permission:"locationBackground",flavor:"locationBackground"},{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"location",flavor:"location"}],gated:[{method:"getCurrentPositionAsync",permission:"location",...ce},{method:"getLastKnownPositionAsync",permission:"location",...ce},{method:"watchPositionImplAsync",permission:"location",...ce},{method:"startGeofencingAsync",permission:"locationBackground",...$e},{method:"startLocationUpdatesAsync",permission:"locationBackground",...$e}]},{module:"ExpoMaps",library:"expo-maps",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"location",flavor:"plain"}]},{module:"ExpoCamera",library:"expo-camera",permissions:[{get:"getCameraPermissionsAsync",request:"requestCameraPermissionsAsync",permission:"camera",flavor:"plain"},{get:"getMicrophonePermissionsAsync",request:"requestMicrophonePermissionsAsync",permission:"microphone",flavor:"plain"}]},{module:"ExpoNotificationPermissionsModule",library:"expo-notifications",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"notifications",flavor:"notifications",defaultArgs:e=>e==="ios"?[{allowAlert:true,allowBadge:true,allowSound:true}]:[void 0]}]},{module:"ExpoMediaLibrary",library:"expo-media-library",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"photos",flavor:"privileges",defaultArgs:()=>[false]}],gated:["getAssetsAsync","getAlbumsAsync","getAssetInfoAsync","createAssetAsync","saveToLibraryAsync"].map(e=>({method:e,permission:"photos",ios:{code:"ERR_MEDIA_LIBRARY_PERMISSIONS",reason:"Media Library permission is required to do this operation"}}))},{module:"ExponentImagePicker",library:"expo-image-picker",permissions:[{get:"getCameraPermissionsAsync",request:"requestCameraPermissionsAsync",permission:"camera",flavor:"plain"},{get:"getMediaLibraryPermissionsAsync",request:"requestMediaLibraryPermissionsAsync",permission:"photos",flavor:"privileges",defaultArgs:()=>[false]}],gated:[{method:"launchCameraAsync",permission:"camera",ios:{code:"ERR_MISSING_CAMERA_PERMISSION",reason:"Missing camera or camera roll permission"},android:{code:"ERR_USER_REJECTED_PERMISSIONS",reason:"User rejected permissions"}}]},{module:"ExpoContacts",library:"expo-contacts",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"contacts",flavor:"privileges"}]},{module:"ExpoCalendar",library:"expo-calendar",permissions:[{get:"getCalendarPermissionsAsync",request:"requestCalendarPermissionsAsync",permission:"calendar",flavor:"plain"},{get:"getRemindersPermissionsAsync",request:"requestRemindersPermissionsAsync",permission:"reminders",flavor:"plain"}]},{module:"CalendarNext",library:"expo-calendar",permissions:[{get:"getCalendarPermissions",request:"requestCalendarPermissions",permission:"calendar",flavor:"plain"},{get:"getRemindersPermissions",request:"requestRemindersPermissions",permission:"reminders",flavor:"plain"}]},{module:"ExpoTrackingTransparency",library:"expo-tracking-transparency",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"tracking",flavor:"plain"}]},{module:"ExpoAudio",library:"expo-audio",permissions:[{get:"getRecordingPermissionsAsync",request:"requestRecordingPermissionsAsync",permission:"microphone",flavor:"plain"}]},{module:"ExponentPedometer",library:"expo-sensors",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"motion",flavor:"plain"}]}];function Yn(){let e=globalThis.expo?.modules;return e&&typeof e=="object"?e:null}function Jn(e){try{return new Set(Object.keys(e))}catch{return new Set}}function Zn(e,t=[]){return e.flavor!=="privileges"?[]:t.length>0?t.slice(0,1):[false]}async function ze(){let e=Yn();if(!e)return;let t=Jn(e),n=Ce(),o=[];for(let i of Gn){if(!t.has(i.module))continue;let l=e[i.module];if(!l)continue;let c=new Set;for(let m of i.permissions){if(c.has(m.permission))continue;let d=l[m.get],u=d?.__buoyPermissionsOriginal??d;typeof u=="function"&&(c.add(m.permission),o.push(Promise.resolve().then(()=>u.apply(l,Zn(m))).then(S=>Ee(m.permission,bn(S,n),i.library)).catch(()=>{})))}}await Promise.all(o)}import{createSyncAdapter as Qn}from"@buoy-gg/shared-ui/web";import{BUOY_SYNTHETIC_MARK as Xn}from"@buoy-gg/shared-ui/web";var je=null;function de(e){try{je?.emit("appStateDidChange",{app_state:e,[Xn]:true})}catch{}}function eo(){Ce()==="ios"&&de("inactive"),de("background")}function to(){de("active")}var G=null,He=false,Ve=null;function no(){return He}function Y(){return Ve?(Ve(),true):false}function oo(){!je||He||(G&&clearTimeout(G),G=setTimeout(()=>{G=null,eo(),setTimeout(to,60)},120))}function J(e){return e&&typeof e=="object"?e:{}}function ue(e){return e.permission??e.id??e.permissionId??e.name}function B(e,t){let n=e[t];if(typeof n=="boolean")return n;if(n==="true")return true;if(n==="false")return false}var Ue=Qn({version:1,getSnapshot(){return y()},subscribe(e){return M(e)},actions:{async getState(){return await ze(),no()?{...y(),settingsStandInOpen:true}:y()},setOverride(e){let t=J(e),n=ue(t),o=t.state??t.status??t.value;if(n===void 0||o===void 0)throw new Error('setOverride needs `permission` (e.g. "location", "camera", "notifications") and `state` ("undetermined", "granted", "limited", "denied", "blocked" or "restricted").');return Y(),Ne(n,o)},clearOverride(e){let t=ue(J(e));if(t===void 0)throw new Error("clearOverride needs `permission`.");return Y(),De(t)},requestReal(e){let t=ue(J(e));if(t===void 0)throw new Error("requestReal needs `permission`.");return Rn(t)},resetAll(){return Y(),se()},updateSettings(e){let t=J(e);return Le({requestAnswer:t.requestAnswer??t.answer,persist:B(t,"persist"),showChip:B(t,"showChip"),notifyApp:B(t,"notifyApp"),enforce:B(t,"enforce"),interceptSettings:B(t,"interceptSettings")})},clearLog(){return Nn()},simulateReturnFromSettings(){return Y()||oo(),y()}}});import{useEffect as io,useReducer as ro,useState as Fe}from"react";import{Check as so,ChevronLeft as ao,ChevronRight as We,NightCard as O,NightFootnote as N,NightRows as pe,NightSectionLabel as Ke,night as a,useSafeAreaInsets as lo,useToolScreenHeader as co}from"@buoy-gg/shared-ui/web";import{Fragment as Ge,jsx as s,jsxs as f}from"react/jsx-runtime";var me=1500,uo=()=>{let e=globalThis.__buoyRealNow;return typeof e=="function"?e():Date.now()};function po(e,t){return e.effective?e.once&&e.effective==="granted"?"Allowed Once":k(e.id,t,e.effective):"Not Checked"}function Ye({snapshot:e,onAction:t,onReload:n}){let o=lo({minBottom:16}),[i,l]=Fe(null),[c,m]=Fe({name:"list"}),d=(b,Q)=>{l(null),t(b,Q).catch(X=>{l(X instanceof Error?X.message:String(X))})},u=c.name==="detail"?e?.permissions.find(b=>b.id===c.id):void 0,S=()=>m(c.name==="detail"&&c.from==="other"?{name:"other"}:{name:"list"}),D=c.name==="other"?"Other Permissions":u?u.label:null,et=co(D?{title:D,onBack:S,searchable:false}:null,[D,c.name,c.name==="detail"?c.from:null]);if(!e)return s(g,{style:p.waiting,testID:"permissions-waiting",children:s(N,{centered:true,children:"Waiting for the app\u2026"})});let{platform:Z,permissions:he}=e,fe=he.filter(b=>b.calls>0||b.override!==null),$=he.filter(b=>!(b.calls>0||b.override!==null)),ge=(b,Q)=>m({name:"detail",id:b,from:Q}),z;return c.name==="detail"&&u?z=s(fo,{row:u,platform:Z,log:e.log,run:d,onPicked:S}):c.name==="other"?z=f(g,{children:[s(Je,{rows:$,platform:Z,onOpen:b=>ge(b,"other")}),s(N,{children:"Your app can ask for these but hasn't yet."})]}):z=f(Ge,{children:[fe.length>0?s(Je,{rows:fe,platform:Z,onOpen:b=>ge(b,"list"),onReload:n}):s(O,{padded:true,children:s(h,{style:p.empty,testID:"permissions-empty",children:"Your app hasn't checked any permissions yet. Open a screen that uses location, the camera or notifications and it will show up here."})}),$.length>0?s(O,{children:f(P,{testID:"permissions-other",accessibilityRole:"button",accessibilityLabel:`Other Permissions, ${$.length}`,activeOpacity:.6,onPress:()=>m({name:"other"}),style:p.row,children:[s(h,{style:p.rowTitle,children:"Other Permissions"}),f(g,{style:p.rowRight,children:[s(h,{style:p.rowValue,children:$.length}),s(We,{size:16,color:a.color.textTertiary})]})]})}):null,e.overriddenCount>0?s(O,{children:s(P,{testID:"permissions-reset",accessibilityRole:"button",accessibilityLabel:"Use Real Permissions",activeOpacity:.6,onPress:()=>d("resetAll"),style:p.row,children:s(h,{style:p.destructive,children:"Use Real Permissions"})})}):null]}),f(Se,{style:p.fill,contentContainerStyle:[p.content,{paddingBottom:o.bottom}],testID:"permissions-scroll",children:[!et&&c.name!=="list"?f(P,{testID:"permissions-back",accessibilityRole:"button",accessibilityLabel:"Back",onPress:S,style:p.inlineBack,children:[s(ao,{size:18,color:a.color.accent}),s(h,{style:p.inlineBackText,children:c.name==="detail"&&c.from==="other"?"Other Permissions":"Permissions"}),D?s(h,{style:p.inlineTitle,children:D}):null]}):null,i?s(N,{tone:"danger",centered:true,children:s(h,{testID:"permissions-error",children:i})}):null,z]})}function Je({rows:e,platform:t,onOpen:n,onReload:o}){let[,i]=ro(d=>d+1,0),l=uo(),c=e.filter(d=>d.stale&&d.changedAt!==null&&l-d.changedAt<me).map(d=>me-(l-d.changedAt)),m=c.length>0?Math.min(...c):null;return io(()=>{if(m===null)return;let d=setTimeout(i,m+50);return()=>clearTimeout(d)},[m]),s(O,{children:s(pe,{children:e.map(d=>{let u=d.stale&&d.changedAt!==null&&l-d.changedAt>=me;return f(g,{children:[s(mo,{row:d,platform:t,onPress:()=>n(d.id)}),u?f(g,{style:p.stale,testID:`permissions-stale-${d.id}`,children:[s(h,{style:p.staleText,children:"The app hasn't checked again since this changed."}),o?s(P,{testID:`permissions-reload-${d.id}`,accessibilityRole:"button",accessibilityLabel:"Reload App",onPress:o,hitSlop:{top:8,bottom:8,left:8,right:8},children:s(h,{style:p.staleAction,children:"Reload App"})}):null]}):null]},d.id)})})})}function mo({row:e,platform:t,onPress:n}){let o=e.override!==null,i=po(e,t),l=e.real?k(e.id,t,e.real):"Not Checked";return f(P,{testID:`permissions-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.label}: ${i}${o?`, simulated. Phone: ${l}`:""}`,activeOpacity:.6,onPress:n,style:p.row,children:[f(g,{style:p.rowLeft,children:[s(h,{style:p.rowTitle,children:e.label}),o?f(h,{style:p.rowSub,testID:`permissions-phone-${e.id}`,children:["Phone: ",l]}):null]}),f(g,{style:p.rowRight,children:[o?s(g,{style:p.dot}):null,s(h,{style:[p.rowValue,o?p.rowValueSimulated:null],testID:`permissions-value-${e.id}`,numberOfLines:1,children:i}),s(We,{size:16,color:a.color.textTertiary})]})]})}function Ze({title:e,detail:t,selected:n,testID:o,onPress:i}){return f(P,{testID:o,accessibilityRole:"button",accessibilityLabel:`${e}. ${t}`,accessibilityState:{selected:n},activeOpacity:.6,onPress:i,style:p.option,children:[f(g,{style:p.optionText,children:[s(h,{style:p.rowTitle,children:e}),s(h,{style:p.optionDetail,children:t})]}),s(g,{style:p.check,children:n?s(so,{size:18,color:a.color.accent}):null})]})}var ho={check:"Checked",request:"Asked",settings:"Opened Settings",gated:"Needed it"};function fo({row:e,platform:t,log:n,run:o,onPicked:i}){let l=e.real?k(e.id,t,e.real):null,c=u=>{u===null?o("clearOverride",{permission:e.id}):o("setOverride",{permission:e.id,state:u}),i()},m=n.filter(u=>u.permission===e.id).slice(0,8),d=e.canRequestReal&&e.real==="undetermined";return f(Ge,{children:[f(g,{children:[s(Ke,{children:"What the app sees"}),s(O,{children:f(pe,{children:[s(Ze,{title:"Phone's Setting",detail:l?`Use what the phone says: ${l}.`:"Use what the phone says.",selected:e.override===null,testID:`permissions-state-${e.id}-real`,onPress:()=>c(null)},"real"),e.states.map(u=>s(Ze,{title:k(e.id,t,u),detail:yn(e.id,t,u),selected:e.override===u,testID:`permissions-state-${e.id}-${u}`,onPress:()=>c(u)},u))]})})]}),d?f(g,{children:[s(O,{children:s(P,{testID:`permissions-request-real-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Show the real system prompt for ${e.label}`,activeOpacity:.6,onPress:()=>o("requestReal",{permission:e.id}),style:p.row,children:s(h,{style:p.action,children:"Show Real Prompt"})})}),s(N,{children:e.warning??"Asks the phone for real, so calls that need this permission work."})]}):e.warning?s(N,{tone:"warning",children:s(h,{testID:`permissions-warning-${e.id}`,children:e.warning})}):null,m.length>0?f(g,{children:[s(Ke,{children:"Recent"}),s(O,{children:s(pe,{children:m.map(u=>s(yo,{entry:u,platform:t},u.id))})}),e.sources.length>0?f(N,{children:["Read through ",e.sources.join(", ")]}):null]}):null]})}function go(e){let t=new Date(e),n=o=>String(o).padStart(2,"0");return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function yo({entry:e,platform:t}){let n=e.error?"Failed":e.returned&&e.permission?e.answer==="once"&&e.returned==="granted"?"Allowed Once":k(e.permission,t,e.returned):"";return f(g,{style:p.recentRow,testID:`permissions-log-${e.id}`,children:[s(h,{style:p.recentTime,children:go(e.at)}),s(h,{style:p.recentVerb,numberOfLines:1,children:ho[e.kind]}),s(h,{style:[p.recentResult,e.error?p.recentFailed:null],numberOfLines:1,children:n})]})}var p=j.create({fill:{flex:1},content:{paddingHorizontal:a.gutter,paddingTop:12,gap:a.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},empty:{color:a.color.textSecondary,fontSize:a.font.body,lineHeight:20},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:50,paddingHorizontal:a.rowPadH,paddingVertical:10},rowLeft:{flexShrink:1,gap:2},rowTitle:{color:a.color.text,fontSize:a.font.row},rowSub:{color:a.color.textTertiary,fontSize:a.font.caption},rowRight:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},rowValue:{color:a.color.textSecondary,fontSize:a.font.row},rowValueSimulated:{color:a.color.accent},dot:{width:7,height:7,borderRadius:4,backgroundColor:a.color.accent},stale:{flexDirection:"row",alignItems:"center",flexWrap:"wrap",columnGap:10,rowGap:4,paddingHorizontal:a.rowPadH,paddingBottom:12,marginTop:-4},staleText:{color:a.color.textSecondary,fontSize:a.font.caption,flexShrink:1},staleAction:{color:a.color.accent,fontSize:a.font.caption,fontWeight:"600"},destructive:{color:a.color.danger,fontSize:a.font.row},action:{color:a.color.accent,fontSize:a.font.row},option:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:a.rowPadH,paddingVertical:11,minHeight:50},optionText:{flex:1,gap:2},optionDetail:{color:a.color.textTertiary,fontSize:a.font.caption,lineHeight:17},check:{width:20,alignItems:"center"},inlineBack:{flexDirection:"row",alignItems:"center",gap:4,marginBottom:-8},inlineBackText:{color:a.color.accent,fontSize:a.font.row},inlineTitle:{color:a.color.text,fontSize:a.font.row,fontWeight:"600",marginLeft:"auto"},recentRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:a.rowPadH,paddingVertical:10},recentTime:{color:a.color.textTertiary,fontSize:a.font.caption,fontVariant:["tabular-nums"]},recentVerb:{color:a.color.text,fontSize:a.font.body,flex:1},recentResult:{color:a.color.textSecondary,fontSize:a.font.body},recentFailed:{color:a.color.danger}});import{jsx as bo}from"react/jsx-runtime";var wo=Ue.actions;async function vo(e,t){let n=wo[e];if(!n)throw new Error(`Unknown permissions action: ${e}`);return n(t)}function Ao(){Kn("auto","buoy permissions").catch(()=>{})}function Qe(){Fn(()=>{ee(),ze()},[]);let e=Wn(M,y,y);return bo(Ye,{snapshot:e,onAction:vo,onReload:Ao})}import{jsx as So}from"react/jsx-runtime";var Xe=Un({id:"permissions",name:"PERMISSIONS",description:"Test denied, blocked, limited and not-asked permission states",slot:"both",color:Hn,icon:({size:e,color:t})=>So(jn,{size:e,color:t}),component:Qe,modal:{subtitle:"choose what the app is allowed to do"}}),Po=Vn(Xe);import{PermissionsIcon as xo,PERMISSIONS_ICON_COLOR as Ro}from"@buoy-gg/shared-ui/web";var ko=typeof navigator<"u"&&navigator.product==="ReactNative";ko&&typeof we<"u"&&we&&(ee(),zn());export{oe as KNOWN_PERMISSION_IDS,F as PERMISSIONS_CHIP_ID,Ro as PERMISSIONS_ICON_COLOR,te as PERMISSION_STATES,Qe as PermissionsBody,Be as PermissionsChip,xo as PermissionsIcon,Ye as PermissionsToolView,De as clearPermissionOverride,Po as createPermissionsTool,In as getPermissionOverride,y as getPermissionsSnapshot,ee as installPermissions,Tn as isPermissionOverridden,_n as openPermissionsChip,R as permissionInfo,Ue as permissionsSyncAdapter,Xe as permissionsToolPreset,se as resetPermissions,Ne as setPermissionOverride,k as stateLabel,M as subscribePermissions,H as supportedStates,Le as updatePermissionSettings};
|
|
1
|
+
"use client";var Be=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var jt=Object.prototype.hasOwnProperty;var zt=(e,t)=>{for(var i in t)Be(e,i,{get:t[i],enumerable:true})},_e=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ut(t))!jt.call(e,n)&&n!==i&&Be(e,n,{get:()=>t[n],enumerable:!(o=_t(t,n))||o.enumerable});return e},Ht=(e,t,i)=>(_e(e,t,"default"),i&&_e(i,t,"default"));var Ue=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{callCapacitorNative as Ft,capacitorPlatform as Vt,emitCapacitorEvent as ie,hasCapacitorPlugin as Wt,loadCapacitorAppHost as Gt}from"@buoy-gg/license/web";function je(e){let t=e;if(!t?.coords||typeof t.coords.latitude!="number"||typeof t.coords.longitude!="number")return e;let i=o=>Math.round(o/.02)*.02;return{...t,coords:{...t.coords,latitude:Number(i(t.coords.latitude).toFixed(4)),longitude:Number(i(t.coords.longitude).toFixed(4)),accuracy:Math.max(t.coords.accuracy??0,3e3),altitude:null,altitudeAccuracy:null,heading:null,speed:null}}}import{callCapacitorNative as H,hasCapacitorPlugin as ze,installCapacitorBridge as Kt,interceptCapacitor as oe,makeCapacitorCallbackId as Yt}from"@buoy-gg/license/web";var ne=["undetermined","granted","limited","denied","blocked","restricted"],Jt=["ask","allow","limited","deny"],ye={location:{id:"location",label:"Location",limited:{ios:"Approximate",android:"Approximate"},purpose:"use your location"},locationBackground:{id:"locationBackground",label:"Background Location",purpose:"use your location in the background"},camera:{id:"camera",label:"Camera",purpose:"access your camera"},microphone:{id:"microphone",label:"Microphone",purpose:"access your microphone"},notifications:{id:"notifications",label:"Notifications",limited:{ios:"Provisional"},purpose:"send you notifications"},photos:{id:"photos",label:"Photos",limited:{ios:"Selected Photos",android:"Selected Photos"},purpose:"access your photos"},contacts:{id:"contacts",label:"Contacts",limited:{ios:"Selected Contacts"},purpose:"access your contacts"},calendar:{id:"calendar",label:"Calendar",purpose:"access your calendar"},reminders:{id:"reminders",label:"Reminders",only:"ios",purpose:"access your reminders"},tracking:{id:"tracking",label:"Tracking",only:"ios",purpose:"track your activity across other companies' apps and websites"},motion:{id:"motion",label:"Motion & Fitness",purpose:"access your motion and fitness activity"},bluetooth:{id:"bluetooth",label:"Bluetooth",purpose:"use Bluetooth"}},be=Object.keys(ye);function we(e){return typeof e=="string"&&(e in ye||e.startsWith("android:")&&e.length>8)}function R(e){let t=ye[e];if(t)return t;let i=e.slice(8).replace(/^android\.permission\./,"");return{id:e,label:i.toLowerCase().split("_").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" "),only:"android",purpose:`use ${i.toLowerCase().replace(/_/g," ")}`}}function re(e,t){let i=R(e),o=["undetermined","granted"];return i.limited?.[t]&&o.push("limited"),o.push("denied"),t==="android"&&o.push("blocked"),t==="ios"&&e!=="notifications"&&o.push("restricted"),o}function He(e,t,i){return re(e,t).includes(i)}function Fe(e,t,i){return He(e,t,i)?i:i==="blocked"?"denied":i==="restricted"?t==="android"?"blocked":"denied":i==="limited"?"granted":i}function Ve(e,t){return t==="undetermined"?true:e==="android"&&t==="denied"}function Zt(e,t,i,o){return Ve(t,i)?o==="allow"||o==="once"?"granted":o==="limited"?He(e,t,"limited")?"limited":"granted":t==="android"&&i==="denied"?"blocked":"denied":i}function We(e,t){return t==="ios"?e==="location":e==="camera"||e==="microphone"}function Xt(e,t){let i=R(e).limited?.[t],o=t==="ios",n=[];if(o&&We(e,t)&&n.push({answer:"once",label:"Allow Once"}),e==="location"||e==="locationBackground"?n.push({answer:"allow",label:o?"Allow While Using App":"While using the app"}):n.push({answer:"allow",label:"Allow"}),!o&&We(e,t)&&n.push({answer:"once",label:"Only this time"}),i){let r=e==="location"?o?"Allow With Approximate Location":"Approximate location":e==="photos"?o?"Limit Access\u2026":"Select photos":e==="contacts"?"Select Contacts\u2026":`Allow ${i}`;n.push({answer:"limited",label:r})}return n.push({answer:"deny",label:o?"Don\u2019t Allow":"Don\u2019t allow"}),n}function Qt(e,t,i){switch(i){case"undetermined":return"Never asked. The next request shows a prompt.";case"granted":return"Full access.";case"limited":return e==="location"?"Allowed, with an approximate position.":e==="photos"?"Allowed for the photos the person picked.":e==="contacts"?"Allowed for the contacts the person picked.":e==="notifications"?"Delivered quietly to Notification Center, without asking.":"Partial access.";case"denied":return t==="ios"?"The person said no. The app can't ask again, only send them to Settings.":"The person said no once. The app can ask one more time.";case"blocked":return"The person said no for good. Only Settings can change it.";case"restricted":return"Turned off by Screen Time or device management. The person can't change it."}}function ei(e,t){if(!e||typeof e!="object")return null;let i=e,o=typeof i.ios?.status=="number"?i.ios.status:void 0;return o===3||o===4?"limited":i.status==="granted"?i.accessPrivileges==="limited"||i.ios?.accuracy==="reduced"||i.android?.accuracy==="coarse"?"limited":"granted":i.status==="denied"?t==="android"&&i.canAskAgain===false?"blocked":"denied":i.status==="undetermined"?"undetermined":null}function N(e,t,i){switch(i){case"undetermined":return"Not Asked";case"granted":return"Allowed";case"limited":return R(e).limited?.[t]??"Limited";case"denied":return"Denied";case"blocked":return"Blocked";case"restricted":return"Restricted"}}var ti={location:"location",coarseLocation:"location",camera:"camera",photos:"photos",receive:"notifications",display:"notifications",notifications:"notifications",microphone:"microphone",contacts:"contacts",calendar:"calendar",reminders:"reminders",bluetooth:"bluetooth",motion:"motion",tracking:"tracking"};function F(e){return ti[e]??null}function ve(e,t){switch(e){case"granted":return"granted";case"limited":return"limited";case"prompt":return"undetermined";case"prompt-with-rationale":return t==="android"?"denied":"undetermined";case"denied":return t==="android"?"blocked":"denied";default:return null}}function ii(e,t){switch(e){case"granted":return"granted";case"limited":return"limited";case"undetermined":return"prompt";case"denied":return t==="android"?"prompt-with-rationale":"denied";case"blocked":case"restricted":return"denied"}}function V(e,t,i){if(e==="location"&&"location"in t){let o=ve(t.location,i),n=ve(t.coarseLocation,i);return o!=="granted"&&n==="granted"?"limited":o}for(let[o,n]of Object.entries(t))if(F(o)===e)return ve(n,i);return null}function Ge(e,t,i){let o={...e};for(let n of Object.keys(e)){let r=F(n);if(!r)continue;let a=t(r);a!==null&&(r==="location"&&a==="limited"?o[n]=n==="coarseLocation"||i==="ios"?"granted":"denied":a==="limited"&&r!=="photos"&&r!=="contacts"?o[n]="granted":o[n]=ii(a,i))}return o}import{devToolsStorageKeys as oi,persistentStorage as Ke}from"@buoy-gg/shared-ui/web";function ni(){try{let e=globalThis.localStorage;return e?Je(e.getItem(Ae)):void 0}catch{return}}var D={requestAnswer:"ask",persist:true,showChip:true,notifyApp:true,enforce:true,interceptSettings:true},Ae=oi.permissions.state();function W(e,t){return typeof e=="boolean"?e:t}function Ye(e){let t=e&&typeof e=="object"?e:{};return{requestAnswer:Jt.includes(t.requestAnswer)?t.requestAnswer:D.requestAnswer,persist:W(t.persist,D.persist),showChip:W(t.showChip,D.showChip),notifyApp:W(t.notifyApp,D.notifyApp),enforce:W(t.enforce,D.enforce),interceptSettings:W(t.interceptSettings,D.interceptSettings)}}function Je(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1)return null;let i={};for(let[o,n]of Object.entries(t.overrides??{}))we(o)&&ne.includes(n)&&(i[o]=n);return{v:1,overrides:i,settings:Ye(t.settings)}}catch{return null}}async function ri(){try{return Je(await Ke.getItem(Ae))}catch{return null}}var Pe=Promise.resolve();function Ze(e){let t=JSON.stringify(e);return Pe=Pe.then(()=>Ke.setItem(Ae,t)).catch(()=>{}),Pe.then(()=>{})}var Xe=200,si=50,Qe="__buoyPermissionsStore",et=globalThis,s=et[Qe]??(et[Qe]={platform:"ios",booted:false,overrides:new Map,settings:{...D},seen:new Map,libraries:new Set,log:[],nextLogId:1,listeners:new Set,snapshot:null,prompter:null,changeHooks:new Set,realRequesters:new Map,host:{isSimulator:null,deviceName:null,bundleId:null},once:new Set});s.once??(s.once=new Set);var G=()=>{let e=globalThis.__buoyRealNow;return typeof e=="function"?e():Date.now()};function A(){s.snapshot=null;for(let e of Array.from(s.listeners))try{e()}catch{}}function B(){if(!s.settings.persist){Ze({v:1,overrides:{},settings:s.settings});return}Ze(ai())}function ai(){return{v:1,overrides:Object.fromEntries(Array.from(s.overrides,([e,t])=>[e,s.once.has(e)?"undetermined":t])),settings:s.settings}}function O(e){let t=s.seen.get(e);return t||(t={sources:new Set,real:null,calls:0,lastCallAt:null,lastReadAt:null,changedAt:null},s.seen.set(e,t)),t}function tt(e){if(e&&(s.settings=e.settings,s.overrides.clear(),!!e.settings.persist))for(let[t,i]of Object.entries(e.overrides)){let o=t;s.overrides.set(o,Fe(o,s.platform,i))}}function it(e){s.platform=e.platform,e.host&&(s.host=e.host),A()}function li(){if(s.booted)return;s.booted=true;let e=ni();if(e!==void 0){tt(e),A();return}ri().then(t=>{s.overrides.size>0||(tt(t),A())})}function ci(e,t){s.realRequesters.has(e)||s.realRequesters.set(e,t)}async function di(e){let t=Se(e),i=s.realRequesters.get(t);if(!i)throw new Error(`No installed library can ask the system for ${R(t).label}.`);let o=await i();return o!==null&&U(t,o),w()}function ui(e){s.prompter=e}function pi(e){return s.changeHooks.add(e),()=>s.changeHooks.delete(e)}function K(e,t){for(let i of Array.from(s.changeHooks))try{i({id:e,from:t})}catch{}}function mi(e,t){let i=!s.libraries.has(e);s.libraries.add(e);for(let o of t){let n=O(o);n.sources.has(e)||(n.sources.add(e),i=true)}i&&A()}function Y(){return s.platform}function _(){return s.settings}function E(e){return s.overrides.get(e)??null}function fi(e){return s.overrides.has(e)}function hi(){return s.overrides.size>0}function U(e,t,i){if(t===null)return;let o=O(e);i&&o.sources.add(i),o.real!==t&&(o.real=t,A())}function L(e){let t={...e,id:s.nextLogId++,at:G()};if(s.log.unshift(t),s.log.length>Xe&&(s.log.length=Xe),e.permission){let i=O(e.permission);(e.kind==="check"||e.kind==="request")&&i.sources.add(e.source),i.calls+=1,i.lastCallAt=t.at,(e.kind==="check"||e.kind==="request")&&(i.lastReadAt=t.at),e.real!==null&&e.kind!=="gated"&&(i.real=e.real)}return A(),t}async function gi(e){let t=s.overrides.get(e);if(t===void 0)throw new Error(`${e} is not overridden`);if(!Ve(s.platform,t))return{state:t};let i,o=s.settings.requestAnswer;o==="ask"&&s.prompter?i=await s.prompter(e):i=o==="ask"?"allow":o;let n=s.overrides.get(e);if(n===void 0)return{state:t,answer:i};let r=Zt(e,s.platform,n,i);return i==="once"&&r==="granted"&&s.once.add(e),r!==n&&(s.overrides.set(e,r),B(),A(),K(e,"request")),{state:r,answer:i}}function Se(e){if(!we(e))throw new Error(`Unknown permission "${String(e)}". Use one of: ${be.join(", ")}, or android:<android.permission.NAME>.`);return e}function ot(e,t){let i=Se(e);if(!ne.includes(t))throw new Error(`Unknown state "${String(t)}". Use one of: ${ne.join(", ")}.`);let o=t,n=re(i,s.platform),r=s.platform==="ios"&&o==="blocked"?"denied":o;if(!n.includes(r))throw new Error(`${R(i).label} can't be "${o}" on ${s.platform}. It can be: ${n.join(", ")}.`);return(s.overrides.get(i)!==r||s.once.has(i))&&(s.overrides.set(i,r),s.once.delete(i),O(i).changedAt=G(),B(),A(),K(i,"tool")),w()}function nt(e){let t=Se(e);return s.overrides.delete(t)&&(s.once.delete(t),O(t).changedAt=G(),B(),A(),K(t,"tool")),w()}function xe(){if(s.overrides.size>0){let e=G();for(let t of s.overrides.keys())O(t).changedAt=e;s.overrides.clear(),s.once.clear(),B(),A(),K(null,"tool")}return w()}function yi(){return Object.fromEntries(s.overrides)}function bi(e){let t=G();for(let i of s.overrides.keys())O(i).changedAt=t;s.overrides.clear(),s.once.clear();for(let[i,o]of Object.entries(e)){let n=i;!o||!we(n)||(s.overrides.set(n,Fe(n,s.platform,o)),O(n).changedAt=t)}return B(),A(),K(null,"tool"),w()}function rt(e){let t={};for(let[o,n]of Object.entries(e))n!==void 0&&(t[o]=n);if(t.requestAnswer!==void 0&&!["ask","allow","limited","deny"].includes(t.requestAnswer))throw new Error('requestAnswer must be "ask", "allow", "limited" or "deny".');let i=Ye({...s.settings,...t});return s.settings=i,B(),A(),w()}function wi(){s.log=[];for(let e of s.seen.values())e.calls=0,e.lastCallAt=null;return A(),w()}function vi(e,t){if(!e||!t)return null;let i=o=>o==="granted"||o==="limited";return i(e)&&!i(t)?"The phone hasn't allowed this, so calls that need it, like getting a position or a photo, still fail.":null}function w(){if(s.snapshot)return s.snapshot;let e=new Set([...s.seen.keys(),...s.overrides.keys()]),t=o=>{let n=be.indexOf(o);return n===-1?1e3:n},i=Array.from(e).filter(o=>{let n=R(o).only;return!n||n===s.platform}).sort((o,n)=>t(o)-t(n)||o.localeCompare(n)).map(o=>{let n=s.seen.get(o),r=s.overrides.get(o)??null,a=n?.real??null;return{id:o,label:R(o).label,states:re(o,s.platform),override:r,real:a,effective:r??a,sources:n?Array.from(n.sources).sort():[],calls:n?.calls??0,lastCallAt:n?.lastCallAt??null,lastReadAt:n?.lastReadAt??null,changedAt:n?.changedAt??null,stale:n?.changedAt!=null&&n.lastReadAt!=null&&n.lastReadAt<n.changedAt,once:s.once.has(o),warning:vi(r,a),canRequestReal:s.realRequesters.has(o)}});return s.snapshot={platform:s.platform,host:s.host,libraries:Array.from(s.libraries).sort(),permissions:i,overriddenCount:s.overrides.size,settings:s.settings,log:s.log.slice(0,si)},s.snapshot}function J(e){return s.listeners.add(e),()=>s.listeners.delete(e)}var se=10,ke=[{plugin:"Geolocation",library:"@capacitor/geolocation",aliases:{location:"location"}},{plugin:"Camera",library:"@capacitor/camera",aliases:{camera:"camera",photos:"photos"}},{plugin:"PushNotifications",library:"@capacitor/push-notifications",aliases:{notifications:"receive"}},{plugin:"LocalNotifications",library:"@capacitor/local-notifications",aliases:{notifications:"display"}}],Ai=[{plugin:"Geolocation",methods:["getCurrentPosition"],permission:()=>"location",message:()=>"Location permission was denied"},{plugin:"Camera",methods:["getPhoto","pickImages","pickLimitedLibraryPhotos"],permission:e=>e.source==="CAMERA"?"camera":"photos",message:e=>e==="camera"?"User denied access to camera":"User denied access to photos"}];function T(e){return ke.find(t=>t.plugin===e)?.library??`Capacitor ${e}`}var st=e=>e==="denied"||e==="blocked"||e==="restricted";function ae(e){let t=new Set;for(let i of Object.keys(e)){let o=F(i);o&&t.add(o)}return Array.from(t)}function q(e){return e&&typeof e=="object"?e:{}}var at=false;function Pi(){if(at)return true;if(!Kt())return false;at=true;let e=Y();oe({plugin:"*",methods:["checkPermissions"],order:se,promise:async(t,i)=>{let o=q(await i()),n=ae(o);if(n.length===0)return o;for(let r of n){let a=V(r,o,e);U(r,a,T(t.plugin));let c=E(r);L({source:T(t.plugin),method:`${t.plugin}.checkPermissions`,permission:r,kind:"check",real:a,returned:c??a,overridden:c!==null})}return Ge(o,E,e)}}),oe({plugin:"*",methods:["requestPermissions"],order:se,promise:async(t,i)=>{let o=Array.isArray(t.options.permissions)?t.options.permissions.map(String):null,n=l=>{let m=F(l);return m!==null&&E(m)!==null},r=o??Object.keys(q(await H(t.plugin,"checkPermissions").catch(()=>({}))));if(!r.some(n)){let l=q(await i());for(let m of ae(l)){let b=V(m,l,e);U(m,b,T(t.plugin)),L({source:T(t.plugin),method:`${t.plugin}.requestPermissions`,permission:m,kind:"request",real:b,returned:b,overridden:false})}return l}let a=r.filter(l=>!n(l)),c=a.length?q(await H(t.plugin,"requestPermissions",{...t.options,permissions:a})):q(await H(t.plugin,"checkPermissions").catch(()=>({})));for(let l of ae(c)){if(E(l)!==null)continue;let m=V(l,c,e);U(l,m,T(t.plugin)),L({source:T(t.plugin),method:`${t.plugin}.requestPermissions`,permission:l,kind:"request",real:m,returned:m,overridden:false})}let u=new Set;for(let l of r.filter(n)){let m=F(l);if(u.has(m))continue;u.add(m);let{state:b,answer:M}=await gi(m);L({source:T(t.plugin),method:`${t.plugin}.requestPermissions`,permission:m,kind:"request",real:null,returned:b,overridden:true,answer:M})}for(let l of r)l in c||(c={...c,[l]:"prompt"});return Ge(c,E,e)}});for(let t of Ai)oe({plugin:t.plugin,methods:t.methods,order:se,promise:(i,o)=>{let n=t.permission(i.options),r=E(n);if(_().enforce&&r==="limited"&&t.plugin==="Geolocation")return o().then(c=>je(c));if(!_().enforce||!st(r))return o();let a=t.message(n);return L({source:T(t.plugin),method:`${t.plugin}.${i.method}`,permission:n,kind:"gated",real:null,returned:r,overridden:true,error:a}),Promise.reject(new Error(a))}});oe({plugin:"Geolocation",methods:["watchPosition"],order:se,callback:(t,i,o)=>{let n=E("location");if(_().enforce&&n==="limited")return o((a,c)=>i(c?a:je(a),c));if(!_().enforce||!st(n))return o(i);let r="Location permission was denied";return L({source:T("Geolocation"),method:"Geolocation.watchPosition",permission:"location",kind:"gated",real:null,returned:n,overridden:true,error:r}),setTimeout(()=>i(null,new Error(r)),0),Yt()}});for(let t of ke){if(!ze(t.plugin))continue;let i=Object.keys(t.aliases);mi(t.library,i);for(let o of i){let n=t.aliases[o];ci(o,async()=>{let r=q(await H(t.plugin,"requestPermissions",{permissions:[n]})),a=V(o,r,e);return L({source:t.library,method:`${t.plugin}.requestPermissions (system)`,permission:o,kind:"request",real:a,returned:a,overridden:false}),a})}}return true}async function Si(){let e=Y();for(let t of ke)if(ze(t.plugin))try{let i=q(await H(t.plugin,"checkPermissions"));for(let o of ae(i))U(o,V(o,i,e),t.library)}catch{}}function Z(e,t,i,o){let n=e.createElement(t);return Object.assign(n.style,i),o!==void 0&&(n.textContent=o),n}var xi={alert(e,t,i,o){let n=globalThis.document;if(!n?.body){o?.onDismiss?.();return}let r=Z(n,"div",{position:"fixed",inset:"0",zIndex:"2147483000",background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",fontFamily:"-apple-system, system-ui, Roboto, sans-serif"});r.setAttribute("role","alertdialog"),r.setAttribute("data-testid","buoy-permission-prompt");let a=Z(n,"div",{width:"100%",maxWidth:"290px",background:"#f2f2f7",color:"#000",borderRadius:"14px",overflow:"hidden",textAlign:"center"});a.appendChild(Z(n,"div",{padding:"18px 16px 4px",fontWeight:"600",fontSize:"17px",lineHeight:"22px"},e)),t&&a.appendChild(Z(n,"div",{padding:"0 16px 16px",fontSize:"13px",lineHeight:"18px",whiteSpace:"pre-line"},t));let c=false,u=()=>{c=true,r.remove()},l=i?.length?i:[{text:"OK"}];for(let m of l){let b=Z(n,"button",{display:"block",width:"100%",padding:"11px 8px",border:"0",borderTop:"0.5px solid rgba(60,60,67,0.29)",background:"transparent",color:"#007aff",fontSize:"17px",fontWeight:m.style==="cancel"?"600":"400",cursor:"pointer"},m.text);b.addEventListener("click",()=>{c||(u(),m.onPress?.())}),a.appendChild(b)}r.appendChild(a),o?.cancelable&&r.addEventListener("click",m=>{c||m.target!==r||(u(),o.onDismiss?.())}),n.body.appendChild(r)}};var Ie=null;function lt(e){Ie=e&&e.trim()?e.trim():null}function ct(){return Ie?{name:Ie}:null}function dt(){let e=ct()?.name;return typeof e=="string"&&e?e:"This app"}var ki={location:{plist:["NSLocationWhenInUseUsageDescription"],plugins:[["expo-location","locationWhenInUsePermission"]]},locationBackground:{plist:["NSLocationAlwaysAndWhenInUseUsageDescription"],plugins:[["expo-location","locationAlwaysAndWhenInUsePermission"]]},camera:{plist:["NSCameraUsageDescription"],plugins:[["expo-camera","cameraPermission"],["expo-image-picker","cameraPermission"]]},microphone:{plist:["NSMicrophoneUsageDescription"],plugins:[["expo-audio","microphonePermission"],["expo-camera","microphonePermission"],["expo-image-picker","microphonePermission"]]},photos:{plist:["NSPhotoLibraryUsageDescription"],plugins:[["expo-image-picker","photosPermission"],["expo-media-library","photosPermission"]]},contacts:{plist:["NSContactsUsageDescription"],plugins:[["expo-contacts","contactsPermission"]]},calendar:{plist:["NSCalendarsFullAccessUsageDescription","NSCalendarsUsageDescription"],plugins:[["expo-calendar","calendarPermission"]]},reminders:{plist:["NSRemindersFullAccessUsageDescription","NSRemindersUsageDescription"],plugins:[["expo-calendar","remindersPermission"]]},tracking:{plist:["NSUserTrackingUsageDescription"],plugins:[["expo-tracking-transparency","userTrackingPermission"]]},motion:{plist:["NSMotionUsageDescription"],plugins:[["expo-sensors","motionPermission"]]},bluetooth:{plist:["NSBluetoothAlwaysUsageDescription"],plugins:[]}};function Ii(e){let t=ki[e],i=ct();if(!t||!i)return null;let o=dt(),n=r=>typeof r=="string"&&r.trim()?r.replace(/\$\(PRODUCT_NAME\)/g,o).trim():null;for(let r of t.plist){let a=n(i.ios?.infoPlist?.[r]);if(a)return a}for(let[r,a]of t.plugins)for(let c of i.plugins??[])if(Array.isArray(c)&&c[0]===r&&c[1]&&typeof c[1]=="object"){let u=n(c[1][a]);if(u)return u}return null}var ut="Test prompt from Buoy. Your phone's settings won't change.",pt=Promise.resolve();function Ci(e){return t=>{let i=()=>new Promise(n=>{let r=Y(),a=R(t),c=dt(),u=r==="ios"?`Allow \u201C${c}\u201D to ${a.purpose}?`:`Allow ${c} to ${a.purpose}?`,l=Xt(t,r),m=false,b=C=>{m||(m=true,n(C))},M=r==="ios"?Ii(t):null;e.alert(u,M?`${M}
|
|
2
|
+
|
|
3
|
+
${ut}`:ut,l.map(C=>({text:C.label,style:C.answer==="deny"?"cancel":"default",onPress:()=>b(C.answer)})),{cancelable:r==="android",onDismiss:()=>b("deny")})}),o=pt.then(i,i);return pt=o.catch(()=>{}),o}}var mt="__buoyPermissionsInstalled";function Ri(){ie("App","appStateChange",{isActive:false}),ie("App","pause",{}),setTimeout(()=>{ie("App","resume",{}),ie("App","appStateChange",{isActive:true})},60)}function Ce(){let e=Vt();if(!e)return false;let t=globalThis;if(t[mt])return false;t[mt]=true,it({platform:e,host:{isSimulator:null,deviceName:null,bundleId:null}}),li(),ui(Ci(xi));let i=globalThis.document?.title??null;return lt(i),Wt("App")&&Ft("App","getInfo").then(o=>lt(o?.name??i)).catch(()=>{}),Pi()?(pi(({from:o})=>{o==="tool"&&_().notifyApp&&Ri()}),Gt().then(o=>{o&&it({platform:e,host:{isSimulator:o.isSimulator,deviceName:o.deviceName,bundleId:o.bundleId}})}),setTimeout(()=>{Si()},1500),true):false}import{useEffect as Ti,useSyncExternalStore as ft}from"react";var ht={};zt(ht,{AccessibilityInfo:()=>Di,ActivityIndicator:()=>To,Alert:()=>No,Animated:()=>Li,AppRegistry:()=>$i,AppState:()=>Mi,Appearance:()=>qi,BackHandler:()=>Bi,Button:()=>Oo,CheckBox:()=>eo,Clipboard:()=>_i,DeviceEventEmitter:()=>yo,Dimensions:()=>Ui,Easing:()=>ji,FlatList:()=>to,I18nManager:()=>zi,Image:()=>io,ImageBackground:()=>oo,InteractionManager:()=>Fi,Keyboard:()=>Hi,KeyboardAvoidingView:()=>no,LayoutAnimation:()=>Vi,Linking:()=>Wi,LogBox:()=>go,Modal:()=>Co,NativeEventEmitter:()=>Gi,NativeModules:()=>Ni,PanResponder:()=>Ki,Picker:()=>ro,PixelRatio:()=>Yi,Platform:()=>Ji,Pressable:()=>Io,ProgressBar:()=>so,RefreshControl:()=>ao,SafeAreaView:()=>lo,ScrollView:()=>gt,SectionList:()=>co,Share:()=>Zi,StatusBar:()=>uo,StyleSheet:()=>le,Switch:()=>Ro,Text:()=>h,TextInput:()=>So,Touchable:()=>po,TouchableHighlight:()=>xo,TouchableNativeFeedback:()=>mo,TouchableOpacity:()=>k,TouchableWithoutFeedback:()=>ko,UIManager:()=>Xi,Vibration:()=>Qi,View:()=>y,VirtualizedList:()=>fo,YellowBox:()=>ho,findNodeHandle:()=>Eo,unstable_createElement:()=>Ei,useColorScheme:()=>bo,useLocaleContext:()=>wo,useWindowDimensions:()=>vo});Ht(ht,Oi);import*as Oi from"react-native-web";import{unstable_createElement as Ei,NativeModules as Ni,AccessibilityInfo as Di,Animated as Li,Appearance as qi,AppRegistry as $i,AppState as Mi,BackHandler as Bi,Clipboard as _i,Dimensions as Ui,Easing as ji,I18nManager as zi,Keyboard as Hi,InteractionManager as Fi,LayoutAnimation as Vi,Linking as Wi,NativeEventEmitter as Gi,PanResponder as Ki,PixelRatio as Yi,Platform as Ji,Share as Zi,StyleSheet as le,UIManager as Xi,Vibration as Qi,CheckBox as eo,FlatList as to,Image as io,ImageBackground as oo,KeyboardAvoidingView as no,Picker as ro,ProgressBar as so,RefreshControl as ao,SafeAreaView as lo,SectionList as co,StatusBar as uo,Touchable as po,TouchableNativeFeedback as mo,VirtualizedList as fo,YellowBox as ho,LogBox as go,DeviceEventEmitter as yo,useColorScheme as bo,useLocaleContext as wo,useWindowDimensions as vo}from"react-native-web";import*as P from"react-native-web";import{createElement as Ao,forwardRef as Po}from"react";function x(e){let t=Po((o,n)=>{let{accessibilityState:r,accessibilityValue:a,...c}=o;for(let u of["busy","checked","disabled","expanded","selected"])r?.[u]!==void 0&&c[`aria-${u}`]===void 0&&(c[`aria-${u}`]=r[u]);for(let[u,l]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[u]!==void 0&&c[`aria-${l}`]===void 0&&(c[`aria-${l}`]=a[u]);return Ao(e,{...c,ref:n})}),i=e.State;return i&&Object.assign(t,{State:i}),t.displayName=e.displayName??e.name??"NativeWebView",t}var y=x(P.View),h=x(P.Text),So=x(P.TextInput),k=x(P.TouchableOpacity),xo=x(P.TouchableHighlight),ko=x(P.TouchableWithoutFeedback),Io=x(P.Pressable),gt=x(P.ScrollView),Co=x(P.Modal),Ro=x(P.Switch),To=x(P.ActivityIndicator),Oo=x(P.Button),Eo=P.findNodeHandle,No={alert(e,t,i,o){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let r=document.createElement("h2");if(r.textContent=e,r.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(r),t){let l=document.createElement("p");l.textContent=t,l.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(l)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let c=i?.length?i:[{text:"OK"}],u=()=>{n.close?.(),n.remove()};for(let l of c){let m=document.createElement("button");m.type="button",m.textContent=l.text??"OK",m.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${l.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,m.onclick=()=>{u(),l.onPress?.()},a.appendChild(m)}n.addEventListener("cancel",l=>{l.preventDefault(),o?.cancelable!==false&&(u(),o?.onDismiss?.())}),n.appendChild(a),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{FloatingTool as yt,PermissionsIcon as bt,X as Do,dismissFloatingTool as Lo,getFloatingTools as qo,night as X,openBuoyTool as $o,openFloatingTool as wt}from"@buoy-gg/shared-ui/web";import{jsx as S,jsxs as Re}from"react/jsx-runtime";var ce="permissions-chip",Mo=8e3,vt={id:ce,render:e=>S(St,{...e})},Bo=()=>qo().some(e=>e.id===ce);function _o(){wt(vt)}var j=null,Te=new Set,de=()=>{};function ue(e){j&&clearTimeout(j.timer),j=e;for(let t of Array.from(Te))t();de()}function Uo(e){return Te.add(e),()=>{Te.delete(e)}}var At=()=>j;function jo(){ue({overrides:yi(),timer:setTimeout(()=>ue(null),Mo)}),xe()}function zo(){let e=j;e&&(ue(null),bi(e.overrides))}var Pt=false;function Ho(){if(Pt)return;Pt=true;let e=false;de=()=>{let t=(hi()||j!==null)&&_().showChip;t&&!e?wt(vt):!t&&Bo()&&Lo(ce),e=t},J(de),de()}function St({id:e,revealToken:t}){let i=ft(J,w,w),o=ft(Uo,At,At);Ti(()=>{o&&i.overriddenCount>0&&ue(null)},[o,i.overriddenCount]);let n=i.permissions.filter(c=>c.override!==null),r=n.length===1?n[0]:null,a=r?`${r.label}: ${r.once&&r.override==="granted"?"Allowed Once":N(r.id,i.platform,r.override)}`:`${n.length} permissions simulated`;return o&&n.length===0?S(yt,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:"Move or hide the permissions strip",handleAdornment:S(bt,{size:12}),children:Re(y,{style:I.row,children:[S(h,{style:I.title,numberOfLines:1,testID:"permissions-chip-summary",children:"Real permissions"}),S(k,{testID:"permissions-chip-undo",accessibilityRole:"button",accessibilityLabel:"Undo, put the simulated permissions back",onPress:zo,style:I.undo,hitSlop:{top:8,bottom:8,left:8,right:8},children:S(h,{style:I.undoText,children:"Undo"})})]})}):S(yt,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the permissions strip. ${a}`,handleAdornment:S(bt,{size:12}),children:Re(y,{style:I.row,children:[Re(k,{testID:"permissions-chip-open",accessibilityRole:"button",accessibilityLabel:`${a}. Open Permissions`,onPress:()=>{$o("permissions")},style:I.open,children:[S(y,{style:I.dot}),S(h,{style:I.title,numberOfLines:1,testID:"permissions-chip-summary",children:a})]}),S(y,{style:I.separator}),S(k,{testID:"permissions-chip-reset",accessibilityRole:"button",accessibilityLabel:"Use real permissions",onPress:jo,style:I.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:S(Do,{size:16,color:X.color.textSecondary})})]})})}var I=le.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingLeft:12,paddingRight:4,minHeight:40,minWidth:200},open:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:1},dot:{width:7,height:7,borderRadius:4,backgroundColor:X.color.accent},title:{color:X.color.text,fontSize:14,fontWeight:"600",flexShrink:1},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},undo:{paddingHorizontal:12,paddingVertical:6},undoText:{color:X.color.accent,fontSize:14,fontWeight:"600"},separator:{width:le.hairlineWidth,height:20,backgroundColor:X.color.separator}});import{PermissionsIcon as Fo,PERMISSIONS_ICON_COLOR as Vo,createToolFactory as Wo,defineToolPreset as Go}from"@buoy-gg/shared-ui/web";import{useEffect as Ko,useSyncExternalStore as Yo}from"react";import{reloadApp as Jo}from"@buoy-gg/shared-ui/web";var Oe={ios:{code:"ERR_DENIED_FOREGROUND_LOCATION_PERMISSION",reason:"Location permission is required to do this operation"},android:{code:"ERR_LOCATION_UNAUTHORIZED",reason:"Not authorized to use location services"}},xt={ios:{code:"ERR_DENIED_BACKGROUND_LOCATION_PERMISSION",reason:"Background location permission is required to do this operation"},android:{code:"ERR_LOCATION_BACKGROUND_UNAUTHORIZED",reason:"Not authorized to use background location services"}},Zo=[{module:"ExpoLocation",library:"expo-location",permissions:[{get:"getForegroundPermissionsAsync",request:"requestForegroundPermissionsAsync",permission:"location",flavor:"location"},{get:"getBackgroundPermissionsAsync",request:"requestBackgroundPermissionsAsync",permission:"locationBackground",flavor:"locationBackground"},{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"location",flavor:"location"}],gated:[{method:"getCurrentPositionAsync",permission:"location",...Oe},{method:"getLastKnownPositionAsync",permission:"location",...Oe},{method:"watchPositionImplAsync",permission:"location",...Oe},{method:"startGeofencingAsync",permission:"locationBackground",...xt},{method:"startLocationUpdatesAsync",permission:"locationBackground",...xt}]},{module:"ExpoMaps",library:"expo-maps",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"location",flavor:"plain"}]},{module:"ExpoCamera",library:"expo-camera",permissions:[{get:"getCameraPermissionsAsync",request:"requestCameraPermissionsAsync",permission:"camera",flavor:"plain"},{get:"getMicrophonePermissionsAsync",request:"requestMicrophonePermissionsAsync",permission:"microphone",flavor:"plain"}]},{module:"ExpoNotificationPermissionsModule",library:"expo-notifications",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"notifications",flavor:"notifications",defaultArgs:e=>e==="ios"?[{allowAlert:true,allowBadge:true,allowSound:true}]:[void 0]}]},{module:"ExpoMediaLibrary",library:"expo-media-library",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"photos",flavor:"privileges",defaultArgs:()=>[false]}],gated:["getAssetsAsync","getAlbumsAsync","getAssetInfoAsync","createAssetAsync","saveToLibraryAsync"].map(e=>({method:e,permission:"photos",ios:{code:"ERR_MEDIA_LIBRARY_PERMISSIONS",reason:"Media Library permission is required to do this operation"}}))},{module:"ExponentImagePicker",library:"expo-image-picker",permissions:[{get:"getCameraPermissionsAsync",request:"requestCameraPermissionsAsync",permission:"camera",flavor:"plain"},{get:"getMediaLibraryPermissionsAsync",request:"requestMediaLibraryPermissionsAsync",permission:"photos",flavor:"privileges",defaultArgs:()=>[false]}],gated:[{method:"launchCameraAsync",permission:"camera",ios:{code:"ERR_MISSING_CAMERA_PERMISSION",reason:"Missing camera or camera roll permission"},android:{code:"ERR_USER_REJECTED_PERMISSIONS",reason:"User rejected permissions"}}]},{module:"ExpoContacts",library:"expo-contacts",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"contacts",flavor:"privileges"}]},{module:"ExpoCalendar",library:"expo-calendar",permissions:[{get:"getCalendarPermissionsAsync",request:"requestCalendarPermissionsAsync",permission:"calendar",flavor:"plain"},{get:"getRemindersPermissionsAsync",request:"requestRemindersPermissionsAsync",permission:"reminders",flavor:"plain"}]},{module:"CalendarNext",library:"expo-calendar",permissions:[{get:"getCalendarPermissions",request:"requestCalendarPermissions",permission:"calendar",flavor:"plain"},{get:"getRemindersPermissions",request:"requestRemindersPermissions",permission:"reminders",flavor:"plain"}]},{module:"ExpoTrackingTransparency",library:"expo-tracking-transparency",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"tracking",flavor:"plain"}]},{module:"ExpoAudio",library:"expo-audio",permissions:[{get:"getRecordingPermissionsAsync",request:"requestRecordingPermissionsAsync",permission:"microphone",flavor:"plain"}]},{module:"ExponentPedometer",library:"expo-sensors",permissions:[{get:"getPermissionsAsync",request:"requestPermissionsAsync",permission:"motion",flavor:"plain"}]}];function Xo(){let e=globalThis.expo?.modules;return e&&typeof e=="object"?e:null}function Qo(e){try{return new Set(Object.keys(e))}catch{return new Set}}function en(e,t=[]){return e.flavor!=="privileges"?[]:t.length>0?t.slice(0,1):[false]}async function kt(){let e=Xo();if(!e)return;let t=Qo(e),i=Y(),o=[];for(let n of Zo){if(!t.has(n.module))continue;let r=e[n.module];if(!r)continue;let a=new Set;for(let c of n.permissions){if(a.has(c.permission))continue;let u=r[c.get],l=u?.__buoyPermissionsOriginal??u;typeof l=="function"&&(a.add(c.permission),o.push(Promise.resolve().then(()=>l.apply(r,en(c))).then(m=>U(c.permission,ei(m,i),n.library)).catch(()=>{})))}}await Promise.all(o)}import{createSyncAdapter as tn}from"@buoy-gg/shared-ui/web";import{BUOY_SYNTHETIC_MARK as on}from"@buoy-gg/shared-ui/web";var It=null;function Ee(e){try{It?.emit("appStateDidChange",{app_state:e,[on]:true})}catch{}}function nn(){Y()==="ios"&&Ee("inactive"),Ee("background")}function rn(){Ee("active")}var pe=null,Ct=false,Rt=null;function sn(){return Ct}function me(){return Rt?(Rt(),true):false}function an(){!It||Ct||(pe&&clearTimeout(pe),pe=setTimeout(()=>{pe=null,nn(),setTimeout(rn,60)},120))}function fe(e){return e&&typeof e=="object"?e:{}}function Ne(e){return e.permission??e.id??e.permissionId??e.name}function Q(e,t){let i=e[t];if(typeof i=="boolean")return i;if(i==="true")return true;if(i==="false")return false}var Tt=tn({version:1,getSnapshot(){return w()},subscribe(e){return J(e)},actions:{async getState(){return await kt(),sn()?{...w(),settingsStandInOpen:true}:w()},setOverride(e){let t=fe(e),i=Ne(t),o=t.state??t.status??t.value;if(i===void 0||o===void 0)throw new Error('setOverride needs `permission` (e.g. "location", "camera", "notifications") and `state` ("undetermined", "granted", "limited", "denied", "blocked" or "restricted").');return me(),ot(i,o)},clearOverride(e){let t=Ne(fe(e));if(t===void 0)throw new Error("clearOverride needs `permission`.");return me(),nt(t)},requestReal(e){let t=Ne(fe(e));if(t===void 0)throw new Error("requestReal needs `permission`.");return di(t)},resetAll(){return me(),xe()},updateSettings(e){let t=fe(e);return rt({requestAnswer:t.requestAnswer??t.answer,persist:Q(t,"persist"),showChip:Q(t,"showChip"),notifyApp:Q(t,"notifyApp"),enforce:Q(t,"enforce"),interceptSettings:Q(t,"interceptSettings")})},clearLog(){return wi()},simulateReturnFromSettings(){return me()||an(),w()}}});import{useEffect as ln,useReducer as cn,useState as Ot}from"react";import{Check as dn,ChevronLeft as un,ChevronRight as Et,NightCard as $,NightFootnote as z,NightRows as De,NightSectionLabel as Nt,night as p,useSafeAreaInsets as pn,useToolScreenHeader as mn}from"@buoy-gg/shared-ui/web";import{Fragment as Dt,jsx as d,jsxs as g}from"react/jsx-runtime";var Le=1500,fn=()=>{let e=globalThis.__buoyRealNow;return typeof e=="function"?e():Date.now()};function hn(e,t){return e.effective?e.once&&e.effective==="granted"?"Allowed Once":N(e.id,t,e.effective):"Not Checked"}function Lt({snapshot:e,onAction:t,onReload:i}){let o=pn({minBottom:16}),[n,r]=Ot(null),[a,c]=Ot({name:"list"}),u=(v,he)=>{r(null),t(v,he).catch(ge=>{r(ge instanceof Error?ge.message:String(ge))})},l=a.name==="detail"?e?.permissions.find(v=>v.id===a.id):void 0,m=()=>c(a.name==="detail"&&a.from==="other"?{name:"other"}:{name:"list"}),b=a.name==="other"?"Other Permissions":l?l.label:null,M=mn(b?{title:b,onBack:m,searchable:false}:null,[b,a.name,a.name==="detail"?a.from:null]);if(!e)return d(y,{style:f.waiting,testID:"permissions-waiting",children:d(z,{centered:true,children:"Waiting for the app\u2026"})});let{platform:C,permissions:qe}=e,$e=qe.filter(v=>v.calls>0||v.override!==null),ee=qe.filter(v=>!(v.calls>0||v.override!==null)),Me=(v,he)=>c({name:"detail",id:v,from:he}),te;return a.name==="detail"&&l?te=d(bn,{row:l,platform:C,log:e.log,run:u,onPicked:m}):a.name==="other"?te=g(y,{children:[d(qt,{rows:ee,platform:C,onOpen:v=>Me(v,"other")}),d(z,{children:"Your app can ask for these but hasn't yet."})]}):te=g(Dt,{children:[$e.length>0?d(qt,{rows:$e,platform:C,onOpen:v=>Me(v,"list"),onReload:i}):d($,{padded:true,children:d(h,{style:f.empty,testID:"permissions-empty",children:"Your app hasn't checked any permissions yet. Open a screen that uses location, the camera or notifications and it will show up here."})}),ee.length>0?d($,{children:g(k,{testID:"permissions-other",accessibilityRole:"button",accessibilityLabel:`Other Permissions, ${ee.length}`,activeOpacity:.6,onPress:()=>c({name:"other"}),style:f.row,children:[d(h,{style:f.rowTitle,children:"Other Permissions"}),g(y,{style:f.rowRight,children:[d(h,{style:f.rowValue,children:ee.length}),d(Et,{size:16,color:p.color.textTertiary})]})]})}):null,e.overriddenCount>0?d($,{children:d(k,{testID:"permissions-reset",accessibilityRole:"button",accessibilityLabel:"Use Real Permissions",activeOpacity:.6,onPress:()=>u("resetAll"),style:f.row,children:d(h,{style:f.destructive,children:"Use Real Permissions"})})}):null]}),g(gt,{style:f.fill,contentContainerStyle:[f.content,{paddingBottom:o.bottom}],testID:"permissions-scroll",children:[!M&&a.name!=="list"?g(k,{testID:"permissions-back",accessibilityRole:"button",accessibilityLabel:"Back",onPress:m,style:f.inlineBack,children:[d(un,{size:18,color:p.color.accent}),d(h,{style:f.inlineBackText,children:a.name==="detail"&&a.from==="other"?"Other Permissions":"Permissions"}),b?d(h,{style:f.inlineTitle,children:b}):null]}):null,n?d(z,{tone:"danger",centered:true,children:d(h,{testID:"permissions-error",children:n})}):null,te]})}function qt({rows:e,platform:t,onOpen:i,onReload:o}){let[,n]=cn(u=>u+1,0),r=fn(),a=e.filter(u=>u.stale&&u.changedAt!==null&&r-u.changedAt<Le).map(u=>Le-(r-u.changedAt)),c=a.length>0?Math.min(...a):null;return ln(()=>{if(c===null)return;let u=setTimeout(n,c+50);return()=>clearTimeout(u)},[c]),d($,{children:d(De,{children:e.map(u=>{let l=u.stale&&u.changedAt!==null&&r-u.changedAt>=Le;return g(y,{children:[d(gn,{row:u,platform:t,onPress:()=>i(u.id)}),l?g(y,{style:f.stale,testID:`permissions-stale-${u.id}`,children:[d(h,{style:f.staleText,children:"The app hasn't checked again since this changed."}),o?d(k,{testID:`permissions-reload-${u.id}`,accessibilityRole:"button",accessibilityLabel:"Reload App",onPress:o,hitSlop:{top:8,bottom:8,left:8,right:8},children:d(h,{style:f.staleAction,children:"Reload App"})}):null]}):null]},u.id)})})})}function gn({row:e,platform:t,onPress:i}){let o=e.override!==null,n=hn(e,t),r=e.real?N(e.id,t,e.real):"Not Checked";return g(k,{testID:`permissions-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.label}: ${n}${o?`, simulated. Phone: ${r}`:""}`,activeOpacity:.6,onPress:i,style:f.row,children:[g(y,{style:f.rowLeft,children:[d(h,{style:f.rowTitle,children:e.label}),o?g(h,{style:f.rowSub,testID:`permissions-phone-${e.id}`,children:["Phone: ",r]}):null]}),g(y,{style:f.rowRight,children:[o?d(y,{style:f.dot}):null,d(h,{style:[f.rowValue,o?f.rowValueSimulated:null],testID:`permissions-value-${e.id}`,numberOfLines:1,children:n}),d(Et,{size:16,color:p.color.textTertiary})]})]})}function $t({title:e,detail:t,selected:i,testID:o,onPress:n}){return g(k,{testID:o,accessibilityRole:"button",accessibilityLabel:`${e}. ${t}`,accessibilityState:{selected:i},activeOpacity:.6,onPress:n,style:f.option,children:[g(y,{style:f.optionText,children:[d(h,{style:f.rowTitle,children:e}),d(h,{style:f.optionDetail,children:t})]}),d(y,{style:f.check,children:i?d(dn,{size:18,color:p.color.accent}):null})]})}var yn={check:"Checked",request:"Asked",settings:"Opened Settings",gated:"Needed it"};function bn({row:e,platform:t,log:i,run:o,onPicked:n}){let r=e.real?N(e.id,t,e.real):null,a=l=>{l===null?o("clearOverride",{permission:e.id}):o("setOverride",{permission:e.id,state:l}),n()},c=i.filter(l=>l.permission===e.id).slice(0,8),u=e.canRequestReal&&e.real==="undetermined";return g(Dt,{children:[g(y,{children:[d(Nt,{children:"What the app sees"}),d($,{children:g(De,{children:[d($t,{title:"Phone's Setting",detail:r?`Use what the phone says: ${r}.`:"Use what the phone says.",selected:e.override===null,testID:`permissions-state-${e.id}-real`,onPress:()=>a(null)},"real"),e.states.map(l=>d($t,{title:N(e.id,t,l),detail:Qt(e.id,t,l),selected:e.override===l,testID:`permissions-state-${e.id}-${l}`,onPress:()=>a(l)},l))]})})]}),u?g(y,{children:[d($,{children:d(k,{testID:`permissions-request-real-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Show the real system prompt for ${e.label}`,activeOpacity:.6,onPress:()=>o("requestReal",{permission:e.id}),style:f.row,children:d(h,{style:f.action,children:"Show Real Prompt"})})}),d(z,{children:e.warning??"Asks the phone for real, so calls that need this permission work."})]}):e.warning?d(z,{tone:"warning",children:d(h,{testID:`permissions-warning-${e.id}`,children:e.warning})}):null,c.length>0?g(y,{children:[d(Nt,{children:"Recent"}),d($,{children:d(De,{children:c.map(l=>d(vn,{entry:l,platform:t},l.id))})}),e.sources.length>0?g(z,{children:["Read through ",e.sources.join(", ")]}):null]}):null]})}function wn(e){let t=new Date(e),i=o=>String(o).padStart(2,"0");return`${i(t.getHours())}:${i(t.getMinutes())}:${i(t.getSeconds())}`}function vn({entry:e,platform:t}){let i=e.error?"Failed":e.returned&&e.permission?e.answer==="once"&&e.returned==="granted"?"Allowed Once":N(e.permission,t,e.returned):"";return g(y,{style:f.recentRow,testID:`permissions-log-${e.id}`,children:[d(h,{style:f.recentTime,children:wn(e.at)}),d(h,{style:f.recentVerb,numberOfLines:1,children:yn[e.kind]}),d(h,{style:[f.recentResult,e.error?f.recentFailed:null],numberOfLines:1,children:i})]})}var f=le.create({fill:{flex:1},content:{paddingHorizontal:p.gutter,paddingTop:12,gap:p.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},empty:{color:p.color.textSecondary,fontSize:p.font.body,lineHeight:20},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:50,paddingHorizontal:p.rowPadH,paddingVertical:10},rowLeft:{flexShrink:1,gap:2},rowTitle:{color:p.color.text,fontSize:p.font.row},rowSub:{color:p.color.textTertiary,fontSize:p.font.caption},rowRight:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},rowValue:{color:p.color.textSecondary,fontSize:p.font.row},rowValueSimulated:{color:p.color.accent},dot:{width:7,height:7,borderRadius:4,backgroundColor:p.color.accent},stale:{flexDirection:"row",alignItems:"center",flexWrap:"wrap",columnGap:10,rowGap:4,paddingHorizontal:p.rowPadH,paddingBottom:12,marginTop:-4},staleText:{color:p.color.textSecondary,fontSize:p.font.caption,flexShrink:1},staleAction:{color:p.color.accent,fontSize:p.font.caption,fontWeight:"600"},destructive:{color:p.color.danger,fontSize:p.font.row},action:{color:p.color.accent,fontSize:p.font.row},option:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:p.rowPadH,paddingVertical:11,minHeight:50},optionText:{flex:1,gap:2},optionDetail:{color:p.color.textTertiary,fontSize:p.font.caption,lineHeight:17},check:{width:20,alignItems:"center"},inlineBack:{flexDirection:"row",alignItems:"center",gap:4,marginBottom:-8},inlineBackText:{color:p.color.accent,fontSize:p.font.row},inlineTitle:{color:p.color.text,fontSize:p.font.row,fontWeight:"600",marginLeft:"auto"},recentRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:p.rowPadH,paddingVertical:10},recentTime:{color:p.color.textTertiary,fontSize:p.font.caption,fontVariant:["tabular-nums"]},recentVerb:{color:p.color.text,fontSize:p.font.body,flex:1},recentResult:{color:p.color.textSecondary,fontSize:p.font.body},recentFailed:{color:p.color.danger}});import{jsx as An}from"react/jsx-runtime";var Pn=Tt.actions;async function Sn(e,t){let i=Pn[e];if(!i)throw new Error(`Unknown permissions action: ${e}`);return i(t)}function xn(){Jo("auto","buoy permissions").catch(()=>{})}function Mt(){Ko(()=>{Ce(),kt()},[]);let e=Yo(J,w,w);return An(Lt,{snapshot:e,onAction:Sn,onReload:xn})}import{jsx as kn}from"react/jsx-runtime";var Bt=Go({id:"permissions",name:"PERMISSIONS",description:"Test denied, blocked, limited and not-asked permission states",slot:"both",color:Vo,icon:({size:e,color:t})=>kn(Fo,{size:e,color:t}),component:Mt,modal:{subtitle:"choose what the app is allowed to do"}}),In=Wo(Bt);import{PermissionsIcon as Cn,PERMISSIONS_ICON_COLOR as Rn}from"@buoy-gg/shared-ui/web";var Tn=typeof navigator<"u"&&navigator.product==="ReactNative",On=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})();(Tn||On)&&typeof Ue<"u"&&Ue&&(Ce(),Ho());export{be as KNOWN_PERMISSION_IDS,ce as PERMISSIONS_CHIP_ID,Rn as PERMISSIONS_ICON_COLOR,ne as PERMISSION_STATES,Mt as PermissionsBody,St as PermissionsChip,Cn as PermissionsIcon,Lt as PermissionsToolView,nt as clearPermissionOverride,In as createPermissionsTool,E as getPermissionOverride,w as getPermissionsSnapshot,Ce as installPermissions,fi as isPermissionOverridden,_o as openPermissionsChip,R as permissionInfo,Tt as permissionsSyncAdapter,Bt as permissionsToolPreset,xe as resetPermissions,ot as setPermissionOverride,N as stateLabel,J as subscribePermissions,re as supportedStates,rt as updatePermissionSettings};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/permissions",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.57",
|
|
4
4
|
"description": "Permission state overrides for React Native: make your app see not asked, allowed, limited, denied or blocked for location, camera, notifications and more, without touching device settings. Works with Expo modules, PermissionsAndroid and react-native-permissions.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -17,15 +17,17 @@
|
|
|
17
17
|
"./lib/web/**/*.mjs"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
20
|
+
"@buoy-gg/shared-ui": "^7.0.57"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
+
"@buoy-gg/license": "7.0.57",
|
|
23
24
|
"react": "*"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@types/react": "^19.1.0",
|
|
27
28
|
"@types/react-native": "^0.73.0",
|
|
28
|
-
"typescript": "~5.8.3"
|
|
29
|
+
"typescript": "~5.8.3",
|
|
30
|
+
"@buoy-gg/license": "^7.0.57"
|
|
29
31
|
},
|
|
30
32
|
"react-native-builder-bob": {
|
|
31
33
|
"source": "src",
|