@buoy-gg/permissions 7.0.69 → 7.0.71
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/browser.js +1 -0
- package/lib/commonjs/engine/adapters/browser.web.js +1 -0
- package/lib/commonjs/engine/install.web.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/module/engine/adapters/browser.js +1 -0
- package/lib/module/engine/adapters/browser.web.js +1 -0
- package/lib/module/engine/install.web.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/typescript/engine/adapters/browser.d.ts +4 -0
- package/lib/typescript/engine/adapters/browser.web.d.ts +7 -0
- package/lib/web/index.mjs +2 -2
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.__resetBrowserPermissionsForTests=__resetBrowserPermissionsForTests;exports.installBrowserPermissionsAdapter=installBrowserPermissionsAdapter;function installBrowserPermissionsAdapter(){return false}function __resetBrowserPermissionsForTests(){}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.__resetBrowserPermissionsForTests=__resetBrowserPermissionsForTests;exports.installBrowserPermissionsAdapter=installBrowserPermissionsAdapter;exports.toBrowserState=toBrowserState;var _coarsenPosition=require("./coarsenPosition");var _store=require("../store");const NAMES={geolocation:"location",camera:"camera",microphone:"microphone",notifications:"notifications","push":"notifications"};const refused=e=>e==="denied"||e==="blocked"||e==="restricted";function toBrowserState(e){if(e==="undetermined")return"prompt";return refused(e)?"denied":"granted"}function fromBrowserState(e){return e==="prompt"?"undetermined":e==="granted"?"granted":e==="denied"?"denied":null}const nav=()=>globalThis.navigator;function deniedPositionError(){return{code:1,message:"User denied Geolocation",PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3}}function notAllowed(e){const o=globalThis.DOMException;if(o)return new o(e,"NotAllowedError");return Object.assign(new Error(e),{name:"NotAllowedError"})}async function stateForUse(e){const o=(0,_store.getOverride)(e);if(o!=="undetermined")return o;return(await(0,_store.resolveRequest)(e)).state}const live=new Map;function statusFor(e,o,c){const i=globalThis.EventTarget;const r=new i;r.onchange=null;r.name=o;Object.defineProperty(r,"state",{enumerable:true,get:()=>{const t=(0,_store.getOverride)(e);return t===null?c?.state??"prompt":toBrowserState(t)}});r.addEventListener("change",t=>r.onchange?.(t));const a=globalThis.Event;c?.addEventListener?.("change",()=>{if((0,_store.getOverride)(e)===null&&a)r.dispatchEvent(new a("change"))});const n=globalThis.WeakRef;if(n){let t=live.get(e);if(!t)live.set(e,t=new Set);t.add(new n(r))}return r}function announce(e){const o=globalThis.Event;if(!o)return;for(const[c,i]of live){if(e!==null&&c!==e)continue;for(const r of i){const a=r.deref();if(!a)i.delete(r);else a.dispatchEvent(new o("change"))}}}const ORIGINALS=new WeakMap;const wrapped=new WeakSet;function wrapOuter(e,o,c){if(!e)return;const i=e[o];if(typeof i!=="function"||wrapped.has(i))return;const r=c(i);wrapped.add(r);ORIGINALS.set(r,i);try{e[o]=r}catch{Object.defineProperty(e,o,{configurable:true,writable:true,value:r})}}function wrapAll(){const e=nav();if(!e)return;if(e.permissions?.query){wrapOuter(e.permissions,"query",r=>async function a(n){const t=NAMES[String(n?.name)];if(!t)return r.call(this,n);const s=await r.call(this,n).catch(()=>null);if(s)(0,_store.noteReal)(t,fromBrowserState(s.state),"navigator.permissions");const l=(0,_store.getOverride)(t);(0,_store.recordCall)({source:"navigator.permissions",method:"permissions.query",permission:t,kind:"check",real:s?fromBrowserState(s.state):null,returned:l??(s?fromBrowserState(s.state):null),overridden:l!==null});return statusFor(t,n.name,s)})}const o=e.geolocation;const c=r=>wrapOuter(o,r,a=>function n(t,s,l){if((0,_store.getOverride)("location")===null||!(0,_store.getSettings)().enforce)return a.call(this,t,s,l);let u=0;let d=false;void stateForUse("location").then(f=>{if(d)return;if(refused(f)){(0,_store.recordCall)({source:"navigator.geolocation",method:`geolocation.${r}`,permission:"location",kind:"gated",real:null,returned:f,overridden:true,error:"User denied Geolocation"});s?.(deniedPositionError());return}const p=f==="limited";const m=a.call(this,p?h=>t((0,_coarsenPosition.coarsenPosition)(h)):t,s,l);u=m});if(r!=="watchPosition")return void 0;const g=Math.floor(Math.random()*1e9)+1;watches.set(g,()=>{d=true;if(u)e.geolocation.clearWatch(u)});return g});c("getCurrentPosition");c("watchPosition");wrapOuter(o,"clearWatch",r=>function a(n){const t=watches.get(n);if(t){watches.delete(n);t();return}return r.call(this,n)});wrapOuter(e.mediaDevices,"getUserMedia",r=>async function a(n){const t=[];if(n?.video)t.push("camera");if(n?.audio)t.push("microphone");if((0,_store.getSettings)().enforce){for(const s of t){if((0,_store.getOverride)(s)===null)continue;const l=await stateForUse(s);if(refused(l)){(0,_store.recordCall)({source:"navigator.mediaDevices",method:"mediaDevices.getUserMedia",permission:s,kind:"gated",real:null,returned:l,overridden:true,error:"Permission denied"});throw notAllowed("Permission denied")}}}return r.call(this,n)});const i=globalThis.Notification;if(i&&!wrapped.has(i)){wrapped.add(i);const r=()=>{const n=Object.getPrototypeOf(i);const t=Object.getOwnPropertyDescriptor(i,"permission")??Object.getOwnPropertyDescriptor(n??{},"permission");return t?.get?String(t.get.call(i)):String(t?.value??"default")};const a=r();Object.defineProperty(i,"permission",{configurable:true,get:()=>{const n=(0,_store.getOverride)("notifications");if(n===null)return a;const t=toBrowserState(n);return t==="prompt"?"default":t}});wrapOuter(i,"requestPermission",n=>async function t(...s){if((0,_store.getOverride)("notifications")===null)return n.apply(this,s);const l=toBrowserState(await stateForUse("notifications")??"undetermined");const u=l==="prompt"?"default":l;const d=s[0];if(typeof d==="function")d(u);return u})}}const watches=new Map;let installed=false;function installBrowserPermissionsAdapter(){if(installed)return true;const e=nav();if(!e)return false;installed=true;wrapAll();setTimeout(wrapAll,0);(0,_store.onPermissionChange)(({id:o})=>{wrapAll();announce(o??null)});if(e.geolocation)(0,_store.registerLibrary)("navigator.geolocation",["location"]);if(e.mediaDevices?.getUserMedia)(0,_store.registerLibrary)("navigator.mediaDevices",["camera","microphone"]);if(globalThis.Notification)(0,_store.registerLibrary)("Notification",["notifications"]);for(const[o,c]of Object.entries(NAMES)){if(o==="push")continue;void ORIGINALS.get(e.permissions?.query)?.call(e.permissions,{name:o})?.then(i=>(0,_store.noteReal)(c,fromBrowserState(i.state),"navigator.permissions"))?.catch(()=>{})}return true}function __resetBrowserPermissionsForTests(){installed=false;live.clear();watches.clear()}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.installPermissions=installPermissions;var _license=require("@buoy-gg/license");var _capacitor=require("./adapters/capacitor");var _browser=require("./adapters/browser");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)();const r=globalThis;if(!t)return installInBrowser(r);if(r[INSTALLED])return false;r[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 i=globalThis.document?.title??null;(0,_expoConfig.setWebAppName)(i);if((0,_license.hasCapacitorPlugin)("App")){void(0,_license.callCapacitorNative)("App","getInfo").then(e=>(0,_expoConfig.setWebAppName)(e?.name??i)).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}function installInBrowser(t){if(t[INSTALLED]||typeof globalThis.document==="undefined")return false;t[INSTALLED]=true;(0,_store.configurePermissions)({platform:"android",host:{isSimulator:null,deviceName:null,bundleId:null}});(0,_store.bootPermissions)();(0,_store.setPrompter)((0,_prompt.createAlertPrompter)(_domAlert.domAlert));(0,_expoConfig.setWebAppName)(globalThis.document?.title??null);return(0,_browser.installBrowserPermissionsAdapter)()}
|
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";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)()}
|
|
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}})();const isBrowserPage=!isReactNativeRuntime&&typeof globalThis.document!=="undefined";if((isReactNativeRuntime||isCapacitorShell||isBrowserPage)&&typeof __DEV__!=="undefined"&&__DEV__){(0,_install.installPermissions)();(0,_PermissionsChip.watchPermissionsChip)()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export function installBrowserPermissionsAdapter(){return false}export function __resetBrowserPermissionsForTests(){}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{coarsenPosition as C}from"./coarsenPosition";import{getOverride as u,getSettings as S,noteReal as N,onPermissionChange as k,recordCall as b,registerLibrary as E,resolveRequest as L}from"../store";const D={geolocation:"location",camera:"camera",microphone:"microphone",notifications:"notifications","push":"notifications"};const P=e=>e==="denied"||e==="blocked"||e==="restricted";export function toBrowserState(e){if(e==="undetermined")return"prompt";return P(e)?"denied":"granted"}function p(e){return e==="prompt"?"undetermined":e==="granted"?"granted":e==="denied"?"denied":null}const A=()=>globalThis.navigator;function R(){return{code:1,message:"User denied Geolocation",PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3}}function W(e){const r=globalThis.DOMException;if(r)return new r(e,"NotAllowedError");return Object.assign(new Error(e),{name:"NotAllowedError"})}async function O(e){const r=u(e);if(r!=="undetermined")return r;return(await L(e)).state}const m=new Map;function x(e,r,c){const i=globalThis.EventTarget;const n=new i;n.onchange=null;n.name=r;Object.defineProperty(n,"state",{enumerable:true,get:()=>{const t=u(e);return t===null?c?.state??"prompt":toBrowserState(t)}});n.addEventListener("change",t=>n.onchange?.(t));const a=globalThis.Event;c?.addEventListener?.("change",()=>{if(u(e)===null&&a)n.dispatchEvent(new a("change"))});const o=globalThis.WeakRef;if(o){let t=m.get(e);if(!t)m.set(e,t=new Set);t.add(new o(n))}return n}function B(e){const r=globalThis.Event;if(!r)return;for(const[c,i]of m){if(e!==null&&c!==e)continue;for(const n of i){const a=n.deref();if(!a)i.delete(n);else a.dispatchEvent(new r("change"))}}}const I=new WeakMap;const h=new WeakSet;function g(e,r,c){if(!e)return;const i=e[r];if(typeof i!=="function"||h.has(i))return;const n=c(i);h.add(n);I.set(n,i);try{e[r]=n}catch{Object.defineProperty(e,r,{configurable:true,writable:true,value:n})}}function y(){const e=A();if(!e)return;if(e.permissions?.query){g(e.permissions,"query",n=>async function a(o){const t=D[String(o?.name)];if(!t)return n.call(this,o);const s=await n.call(this,o).catch(()=>null);if(s)N(t,p(s.state),"navigator.permissions");const l=u(t);b({source:"navigator.permissions",method:"permissions.query",permission:t,kind:"check",real:s?p(s.state):null,returned:l??(s?p(s.state):null),overridden:l!==null});return x(t,o.name,s)})}const r=e.geolocation;const c=n=>g(r,n,a=>function o(t,s,l){if(u("location")===null||!S().enforce)return a.call(this,t,s,l);let f=0;let d=false;void O("location").then(w=>{if(d)return;if(P(w)){b({source:"navigator.geolocation",method:`geolocation.${n}`,permission:"location",kind:"gated",real:null,returned:w,overridden:true,error:"User denied Geolocation"});s?.(R());return}const U=w==="limited";const j=a.call(this,U?q=>t(C(q)):t,s,l);f=j});if(n!=="watchPosition")return void 0;const M=Math.floor(Math.random()*1e9)+1;v.set(M,()=>{d=true;if(f)e.geolocation.clearWatch(f)});return M});c("getCurrentPosition");c("watchPosition");g(r,"clearWatch",n=>function a(o){const t=v.get(o);if(t){v.delete(o);t();return}return n.call(this,o)});g(e.mediaDevices,"getUserMedia",n=>async function a(o){const t=[];if(o?.video)t.push("camera");if(o?.audio)t.push("microphone");if(S().enforce){for(const s of t){if(u(s)===null)continue;const l=await O(s);if(P(l)){b({source:"navigator.mediaDevices",method:"mediaDevices.getUserMedia",permission:s,kind:"gated",real:null,returned:l,overridden:true,error:"Permission denied"});throw W("Permission denied")}}}return n.call(this,o)});const i=globalThis.Notification;if(i&&!h.has(i)){h.add(i);const n=()=>{const o=Object.getPrototypeOf(i);const t=Object.getOwnPropertyDescriptor(i,"permission")??Object.getOwnPropertyDescriptor(o??{},"permission");return t?.get?String(t.get.call(i)):String(t?.value??"default")};const a=n();Object.defineProperty(i,"permission",{configurable:true,get:()=>{const o=u("notifications");if(o===null)return a;const t=toBrowserState(o);return t==="prompt"?"default":t}});g(i,"requestPermission",o=>async function t(...s){if(u("notifications")===null)return o.apply(this,s);const l=toBrowserState(await O("notifications")??"undetermined");const f=l==="prompt"?"default":l;const d=s[0];if(typeof d==="function")d(f);return f})}}const v=new Map;let T=false;export function installBrowserPermissionsAdapter(){if(T)return true;const e=A();if(!e)return false;T=true;y();setTimeout(y,0);k(({id:r})=>{y();B(r??null)});if(e.geolocation)E("navigator.geolocation",["location"]);if(e.mediaDevices?.getUserMedia)E("navigator.mediaDevices",["camera","microphone"]);if(globalThis.Notification)E("Notification",["notifications"]);for(const[r,c]of Object.entries(D)){if(r==="push")continue;void I.get(e.permissions?.query)?.call(e.permissions,{name:r})?.then(i=>N(c,p(i.state),"navigator.permissions"))?.catch(()=>{})}return true}export function __resetBrowserPermissionsForTests(){T=false;m.clear();v.clear()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{callCapacitorNative as
|
|
1
|
+
"use strict";import{callCapacitorNative as f,capacitorPlatform as c,emitCapacitorEvent as i,hasCapacitorPlugin as d,loadCapacitorAppHost as A}from"@buoy-gg/license";import{installCapacitorPermissionsAdapter as g,refreshCapacitorRealStates as h}from"./adapters/capacitor";import{installBrowserPermissionsAdapter as b}from"./adapters/browser";import{domAlert as s}from"./domAlert";import{setWebAppName as n}from"./expoConfig.web";import{createAlertPrompter as p}from"./prompt";import{bootPermissions as m,configurePermissions as l,getSettings as v,onPermissionChange as P,setPrompter as u}from"./store";const o="__buoyPermissionsInstalled";function C(){i("App","appStateChange",{isActive:false});i("App","pause",{});setTimeout(()=>{i("App","resume",{});i("App","appStateChange",{isActive:true})},60)}export function installPermissions(){const e=c();const r=globalThis;if(!e)return S(r);if(r[o])return false;r[o]=true;l({platform:e,host:{isSimulator:null,deviceName:null,bundleId:null}});m();u(p(s));const a=globalThis.document?.title??null;n(a);if(d("App")){void f("App","getInfo").then(t=>n(t?.name??a)).catch(()=>{})}if(!g())return false;P(({from:t})=>{if(t==="tool"&&v().notifyApp)C()});void A().then(t=>{if(t)l({platform:e,host:{isSimulator:t.isSimulator,deviceName:t.deviceName,bundleId:t.bundleId}})});setTimeout(()=>{void h()},1500);return true}function S(e){if(e[o]||typeof globalThis.document==="undefined")return false;e[o]=true;l({platform:"android",host:{isSimulator:null,deviceName:null,bundleId:null}});m();u(p(s));n(globalThis.document?.title??null);return b()}
|
package/lib/module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{installPermissions as
|
|
1
|
+
"use strict";import{installPermissions as r}from"./engine/install";import{watchPermissionsChip as i}from"./components/PermissionsChip";const e=typeof navigator!=="undefined"&&navigator.product==="ReactNative";const o=(()=>{try{const s=globalThis.Capacitor;return s?.isNativePlatform?.()===true}catch{return false}})();const t=!e&&typeof globalThis.document!=="undefined";if((e||o||t)&&typeof __DEV__!=="undefined"&&__DEV__){r();i()}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,7 @@
|
|
|
1
|
+
import type { PermissionState } from "../model";
|
|
2
|
+
type BrowserState = "prompt" | "granted" | "denied";
|
|
3
|
+
export declare function toBrowserState(state: PermissionState): BrowserState;
|
|
4
|
+
export declare function installBrowserPermissionsAdapter(): boolean;
|
|
5
|
+
export declare function __resetBrowserPermissionsForTests(): void;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=browser.web.d.ts.map
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";var je=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Yt=Object.prototype.hasOwnProperty;var Jt=(e,t)=>{for(var n in t)je(e,n,{get:t[n],enumerable:true})},ze=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Gt(t))!Yt.call(e,o)&&o!==n&&je(e,o,{get:()=>t[o],enumerable:!(i=Kt(t,o))||i.enumerable});return e},Zt=(e,t,n)=>(ze(e,t,"default"),n&&ze(n,t,"default"));var He=(()=>{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 Xt,capacitorPlatform as Qt,emitCapacitorEvent as ie,hasCapacitorPlugin as en,loadCapacitorAppHost as tn}from"@buoy-gg/license/web";function Fe(e){let t=e;if(!t?.coords||typeof t.coords.latitude!="number"||typeof t.coords.longitude!="number")return e;let n=i=>Math.round(i/.02)*.02;return{...t,coords:{...t.coords,latitude:Number(n(t.coords.latitude).toFixed(4)),longitude:Number(n(t.coords.longitude).toFixed(4)),accuracy:Math.max(t.coords.accuracy??0,3e3),altitude:null,altitudeAccuracy:null,heading:null,speed:null}}}import{callCapacitorNative as F,hasCapacitorPlugin as Ve,installCapacitorBridge as nn,interceptCapacitor as oe,makeCapacitorCallbackId as on}from"@buoy-gg/license/web";var re=["undetermined","granted","limited","denied","blocked","restricted"],rn=["ask","allow","limited","deny"],we={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"}},ve=Object.keys(we);function Ae(e){return typeof e=="string"&&(e in we||e.startsWith("android:")&&e.length>8)}function R(e){let t=we[e];if(t)return t;let n=e.slice(8).replace(/^android\.permission\./,"");return{id:e,label:n.toLowerCase().split("_").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" "),only:"android",purpose:`use ${n.toLowerCase().replace(/_/g," ")}`}}function se(e,t){let n=R(e),i=["undetermined","granted"];return n.limited?.[t]&&i.push("limited"),i.push("denied"),t==="android"&&i.push("blocked"),t==="ios"&&e!=="notifications"&&i.push("restricted"),i}function We(e,t,n){return se(e,t).includes(n)}function Ke(e,t,n){return We(e,t,n)?n:n==="blocked"?"denied":n==="restricted"?t==="android"?"blocked":"denied":n==="limited"?"granted":n}function Ge(e,t){return t==="undetermined"?true:e==="android"&&t==="denied"}function sn(e,t,n,i){return Ge(t,n)?i==="allow"||i==="once"?"granted":i==="limited"?We(e,t,"limited")?"limited":"granted":t==="android"&&n==="denied"?"blocked":"denied":n}function Ye(e,t){return t==="ios"?e==="location":e==="camera"||e==="microphone"}function an(e,t){let n=R(e).limited?.[t],i=t==="ios",o=[];if(i&&Ye(e,t)&&o.push({answer:"once",label:"Allow Once"}),e==="location"||e==="locationBackground"?o.push({answer:"allow",label:i?"Allow While Using App":"While using the app"}):o.push({answer:"allow",label:"Allow"}),!i&&Ye(e,t)&&o.push({answer:"once",label:"Only this time"}),n){let r=e==="location"?i?"Allow With Approximate Location":"Approximate location":e==="photos"?i?"Limit Access\u2026":"Select photos":e==="contacts"?"Select Contacts\u2026":`Allow ${n}`;o.push({answer:"limited",label:r})}return o.push({answer:"deny",label:i?"Don\u2019t Allow":"Don\u2019t allow"}),o}function ln(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 cn(e,t){if(!e||typeof e!="object")return null;let n=e,i=typeof n.ios?.status=="number"?n.ios.status:void 0;return i===3||i===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 D(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"}}var dn={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 V(e){return dn[e]??null}function Se(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 un(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 W(e,t,n){if(e==="location"&&"location"in t){let i=Se(t.location,n),o=Se(t.coarseLocation,n);return i!=="granted"&&o==="granted"?"limited":i}for(let[i,o]of Object.entries(t))if(V(i)===e)return Se(o,n);return null}function Je(e,t,n){let i={...e};for(let o of Object.keys(e)){let r=V(o);if(!r)continue;let c=t(r);c!==null&&(r==="location"&&c==="limited"?i[o]=o==="coarseLocation"||n==="ios"?"granted":"denied":c==="limited"&&r!=="photos"&&r!=="contacts"?i[o]="granted":i[o]=un(c,n))}return i}import{devToolsStorageKeys as pn,persistentStorage as Ze}from"@buoy-gg/shared-ui/web";function mn(){try{let e=globalThis.localStorage;return e?Qe(e.getItem(Pe)):void 0}catch{return}}var q={requestAnswer:"ask",persist:true,showChip:true,notifyApp:true,enforce:true,interceptSettings:true},Pe=pn.permissions.state();function K(e,t){return typeof e=="boolean"?e:t}function Xe(e){let t=e&&typeof e=="object"?e:{};return{requestAnswer:rn.includes(t.requestAnswer)?t.requestAnswer:q.requestAnswer,persist:K(t.persist,q.persist),showChip:K(t.showChip,q.showChip),notifyApp:K(t.notifyApp,q.notifyApp),enforce:K(t.enforce,q.enforce),interceptSettings:K(t.interceptSettings,q.interceptSettings)}}function Qe(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1)return null;let n={};for(let[i,o]of Object.entries(t.overrides??{}))Ae(i)&&re.includes(o)&&(n[i]=o);return{v:1,overrides:n,settings:Xe(t.settings)}}catch{return null}}async function fn(){try{return Qe(await Ze.getItem(Pe))}catch{return null}}var ke=Promise.resolve();function et(e){let t=JSON.stringify(e);return ke=ke.then(()=>Ze.setItem(Pe,t)).catch(()=>{}),ke.then(()=>{})}var tt=200,hn=50,nt="__buoyPermissionsStore",it=globalThis,s=it[nt]??(it[nt]={platform:"ios",booted:false,overrides:new Map,settings:{...q},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){et({v:1,overrides:{},settings:s.settings});return}et(gn())}function gn(){return{v:1,overrides:Object.fromEntries(Array.from(s.overrides,([e,t])=>[e,s.once.has(e)?"undetermined":t])),settings:s.settings}}function T(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 ot(e){if(e&&(s.settings=e.settings,s.overrides.clear(),!!e.settings.persist))for(let[t,n]of Object.entries(e.overrides)){let i=t;s.overrides.set(i,Ke(i,s.platform,n))}}function rt(e){s.platform=e.platform,e.host&&(s.host=e.host),A()}function yn(){if(s.booted)return;s.booted=true;let e=mn();if(e!==void 0){ot(e),A();return}fn().then(t=>{s.overrides.size>0||(ot(t),A())})}function bn(e,t){s.realRequesters.has(e)||s.realRequesters.set(e,t)}async function wn(e){let t=xe(e),n=s.realRequesters.get(t);if(!n)throw new Error(`No installed library can ask the system for ${R(t).label}.`);let i=await n();return i!==null&&U(t,i),w()}function vn(e){s.prompter=e}function An(e){return s.changeHooks.add(e),()=>s.changeHooks.delete(e)}function Y(e,t){for(let n of Array.from(s.changeHooks))try{n({id:e,from:t})}catch{}}function Sn(e,t){let n=!s.libraries.has(e);s.libraries.add(e);for(let i of t){let o=T(i);o.sources.has(e)||(o.sources.add(e),n=true)}n&&A()}function J(){return s.platform}function _(){return s.settings}function O(e){return s.overrides.get(e)??null}function Pn(e){return s.overrides.has(e)}function kn(){return s.overrides.size>0}function U(e,t,n){if(t===null)return;let i=T(e);n&&i.sources.add(n),i.real!==t&&(i.real=t,A())}function $(e){let t={...e,id:s.nextLogId++,at:G()};if(s.log.unshift(t),s.log.length>tt&&(s.log.length=tt),e.permission){let n=T(e.permission);(e.kind==="check"||e.kind==="request")&&n.sources.add(e.source),n.calls+=1,n.lastCallAt=t.at,(e.kind==="check"||e.kind==="request")&&(n.lastReadAt=t.at),e.real!==null&&e.kind!=="gated"&&(n.real=e.real)}return A(),t}async function xn(e){let t=s.overrides.get(e);if(t===void 0)throw new Error(`${e} is not overridden`);if(!Ge(s.platform,t))return{state:t};let n,i=s.settings.requestAnswer;i==="ask"&&s.prompter?n=await s.prompter(e):n=i==="ask"?"allow":i;let o=s.overrides.get(e);if(o===void 0)return{state:t,answer:n};let r=sn(e,s.platform,o,n);return n==="once"&&r==="granted"&&s.once.add(e),r!==o&&(s.overrides.set(e,r),B(),A(),Y(e,"request")),{state:r,answer:n}}function xe(e){if(!Ae(e))throw new Error(`Unknown permission "${String(e)}". Use one of: ${ve.join(", ")}, or android:<android.permission.NAME>.`);return e}function st(e,t){let n=xe(e);if(!re.includes(t))throw new Error(`Unknown state "${String(t)}". Use one of: ${re.join(", ")}.`);let i=t,o=se(n,s.platform),r=s.platform==="ios"&&i==="blocked"?"denied":i;if(!o.includes(r))throw new Error(`${R(n).label} can't be "${i}" on ${s.platform}. It can be: ${o.join(", ")}.`);return(s.overrides.get(n)!==r||s.once.has(n))&&(s.overrides.set(n,r),s.once.delete(n),T(n).changedAt=G(),B(),A(),Y(n,"tool")),w()}function at(e){let t=xe(e);return s.overrides.delete(t)&&(s.once.delete(t),T(t).changedAt=G(),B(),A(),Y(t,"tool")),w()}function Ce(){if(s.overrides.size>0){let e=G();for(let t of s.overrides.keys())T(t).changedAt=e;s.overrides.clear(),s.once.clear(),B(),A(),Y(null,"tool")}return w()}function Cn(){return Object.fromEntries(s.overrides)}function In(e){let t=G();for(let n of s.overrides.keys())T(n).changedAt=t;s.overrides.clear(),s.once.clear();for(let[n,i]of Object.entries(e)){let o=n;!i||!Ae(o)||(s.overrides.set(o,Ke(o,s.platform,i)),T(o).changedAt=t)}return B(),A(),Y(null,"tool"),w()}function lt(e){let t={};for(let[i,o]of Object.entries(e))o!==void 0&&(t[i]=o);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=Xe({...s.settings,...t});return s.settings=n,B(),A(),w()}function Rn(){s.log=[];for(let e of s.seen.values())e.calls=0,e.lastCallAt=null;return A(),w()}function En(e,t){if(!e||!t)return null;let n=i=>i==="granted"||i==="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 w(){if(s.snapshot)return s.snapshot;let e=new Set([...s.seen.keys(),...s.overrides.keys()]),t=i=>{let o=ve.indexOf(i);return o===-1?1e3:o},n=Array.from(e).filter(i=>{let o=R(i).only;return!o||o===s.platform}).sort((i,o)=>t(i)-t(o)||i.localeCompare(o)).map(i=>{let o=s.seen.get(i),r=s.overrides.get(i)??null,c=o?.real??null;return{id:i,label:R(i).label,states:se(i,s.platform),override:r,real:c,effective:r??c,sources:o?Array.from(o.sources).sort():[],calls:o?.calls??0,lastCallAt:o?.lastCallAt??null,lastReadAt:o?.lastReadAt??null,changedAt:o?.changedAt??null,stale:o?.changedAt!=null&&o.lastReadAt!=null&&o.lastReadAt<o.changedAt,once:s.once.has(i),warning:En(r,c),canRequestReal:s.realRequesters.has(i)}});return s.snapshot={platform:s.platform,host:s.host,libraries:Array.from(s.libraries).sort(),permissions:n,overriddenCount:s.overrides.size,settings:s.settings,log:s.log.slice(0,hn)},s.snapshot}function Z(e){return s.listeners.add(e),()=>s.listeners.delete(e)}var ae=10,Ie=[{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"}}],Tn=[{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 E(e){return Ie.find(t=>t.plugin===e)?.library??`Capacitor ${e}`}var ct=e=>e==="denied"||e==="blocked"||e==="restricted";function le(e){let t=new Set;for(let n of Object.keys(e)){let i=V(n);i&&t.add(i)}return Array.from(t)}function M(e){return e&&typeof e=="object"?e:{}}var dt=false;function On(){if(dt)return true;if(!nn())return false;dt=true;let e=J();oe({plugin:"*",methods:["checkPermissions"],order:ae,promise:async(t,n)=>{let i=M(await n()),o=le(i);if(o.length===0)return i;for(let r of o){let c=W(r,i,e);U(r,c,E(t.plugin));let a=O(r);$({source:E(t.plugin),method:`${t.plugin}.checkPermissions`,permission:r,kind:"check",real:c,returned:a??c,overridden:a!==null})}return Je(i,O,e)}}),oe({plugin:"*",methods:["requestPermissions"],order:ae,promise:async(t,n)=>{let i=Array.isArray(t.options.permissions)?t.options.permissions.map(String):null,o=d=>{let l=V(d);return l!==null&&O(l)!==null},r=i??Object.keys(M(await F(t.plugin,"checkPermissions").catch(()=>({}))));if(!r.some(o)){let d=M(await n());for(let l of le(d)){let y=W(l,d,e);U(l,y,E(t.plugin)),$({source:E(t.plugin),method:`${t.plugin}.requestPermissions`,permission:l,kind:"request",real:y,returned:y,overridden:false})}return d}let c=r.filter(d=>!o(d)),a=c.length?M(await F(t.plugin,"requestPermissions",{...t.options,permissions:c})):M(await F(t.plugin,"checkPermissions").catch(()=>({})));for(let d of le(a)){if(O(d)!==null)continue;let l=W(d,a,e);U(d,l,E(t.plugin)),$({source:E(t.plugin),method:`${t.plugin}.requestPermissions`,permission:d,kind:"request",real:l,returned:l,overridden:false})}let u=new Set;for(let d of r.filter(o)){let l=V(d);if(u.has(l))continue;u.add(l);let{state:y,answer:C}=await xn(l);$({source:E(t.plugin),method:`${t.plugin}.requestPermissions`,permission:l,kind:"request",real:null,returned:y,overridden:true,answer:C})}for(let d of r)d in a||(a={...a,[d]:"prompt"});return Je(a,O,e)}});for(let t of Tn)oe({plugin:t.plugin,methods:t.methods,order:ae,promise:(n,i)=>{let o=t.permission(n.options),r=O(o);if(_().enforce&&r==="limited"&&t.plugin==="Geolocation")return i().then(a=>Fe(a));if(!_().enforce||!ct(r))return i();let c=t.message(o);return $({source:E(t.plugin),method:`${t.plugin}.${n.method}`,permission:o,kind:"gated",real:null,returned:r,overridden:true,error:c}),Promise.reject(new Error(c))}});oe({plugin:"Geolocation",methods:["watchPosition"],order:ae,callback:(t,n,i)=>{let o=O("location");if(_().enforce&&o==="limited")return i((c,a)=>n(a?c:Fe(c),a));if(!_().enforce||!ct(o))return i(n);let r="Location permission was denied";return $({source:E("Geolocation"),method:"Geolocation.watchPosition",permission:"location",kind:"gated",real:null,returned:o,overridden:true,error:r}),setTimeout(()=>n(null,new Error(r)),0),on()}});for(let t of Ie){if(!Ve(t.plugin))continue;let n=Object.keys(t.aliases);Sn(t.library,n);for(let i of n){let o=t.aliases[i];bn(i,async()=>{let r=M(await F(t.plugin,"requestPermissions",{permissions:[o]})),c=W(i,r,e);return $({source:t.library,method:`${t.plugin}.requestPermissions (system)`,permission:i,kind:"request",real:c,returned:c,overridden:false}),c})}}return true}async function Nn(){let e=J();for(let t of Ie)if(Ve(t.plugin))try{let n=M(await F(t.plugin,"checkPermissions"));for(let i of le(n))U(i,W(i,n,e),t.library)}catch{}}function X(e,t,n,i){let o=e.createElement(t);return Object.assign(o.style,n),i!==void 0&&(o.textContent=i),o}var Ln={alert(e,t,n,i){let o=globalThis.document;if(!o?.body){i?.onDismiss?.();return}let r=X(o,"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 c=X(o,"div",{width:"100%",maxWidth:"290px",background:"#f2f2f7",color:"#000",borderRadius:"14px",overflow:"hidden",textAlign:"center"});c.appendChild(X(o,"div",{padding:"18px 16px 4px",fontWeight:"600",fontSize:"17px",lineHeight:"22px"},e)),t&&c.appendChild(X(o,"div",{padding:"0 16px 16px",fontSize:"13px",lineHeight:"18px",whiteSpace:"pre-line"},t));let a=false,u=()=>{a=true,r.remove()},d=n?.length?n:[{text:"OK"}];for(let l of d){let y=X(o,"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:l.style==="cancel"?"600":"400",cursor:"pointer"},l.text);y.addEventListener("click",()=>{a||(u(),l.onPress?.())}),c.appendChild(y)}r.appendChild(c),i?.cancelable&&r.addEventListener("click",l=>{a||l.target!==r||(u(),i.onDismiss?.())}),o.body.appendChild(r)}};var Re=null;function ut(e){Re=e&&e.trim()?e.trim():null}function pt(){return Re?{name:Re}:null}function mt(){let e=pt()?.name;return typeof e=="string"&&e?e:"This app"}var Dn={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 qn(e){let t=Dn[e],n=pt();if(!t||!n)return null;let i=mt(),o=r=>typeof r=="string"&&r.trim()?r.replace(/\$\(PRODUCT_NAME\)/g,i).trim():null;for(let r of t.plist){let c=o(n.ios?.infoPlist?.[r]);if(c)return c}for(let[r,c]of t.plugins)for(let a of n.plugins??[])if(Array.isArray(a)&&a[0]===r&&a[1]&&typeof a[1]=="object"){let u=o(a[1][c]);if(u)return u}return null}var ft="Test prompt from Buoy. Your phone's settings won't change.",ht=Promise.resolve();function $n(e){return t=>{let n=()=>new Promise(o=>{let r=J(),c=R(t),a=mt(),u=r==="ios"?`Allow \u201C${a}\u201D to ${c.purpose}?`:`Allow ${a} to ${c.purpose}?`,d=an(t,r),l=false,y=L=>{l||(l=true,o(L))},C=r==="ios"?qn(t):null;e.alert(u,C?`${C}
|
|
1
|
+
"use client";var tt=Object.defineProperty;var hn=Object.getOwnPropertyDescriptor;var gn=Object.getOwnPropertyNames;var yn=Object.prototype.hasOwnProperty;var bn=(e,t)=>{for(var n in t)tt(e,n,{get:t[n],enumerable:true})},nt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of gn(t))!yn.call(e,o)&&o!==n&&tt(e,o,{get:()=>t[o],enumerable:!(i=hn(t,o))||i.enumerable});return e},wn=(e,t,n)=>(nt(e,t,"default"),n&&nt(n,t,"default"));var it=(()=>{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 vn,capacitorPlatform as An,emitCapacitorEvent as re,hasCapacitorPlugin as Pn,loadCapacitorAppHost as Sn}from"@buoy-gg/license/web";function ke(e){let t=e;if(!t?.coords||typeof t.coords.latitude!="number"||typeof t.coords.longitude!="number")return e;let n=i=>Math.round(i/.02)*.02;return{...t,coords:{...t.coords,latitude:Number(n(t.coords.latitude).toFixed(4)),longitude:Number(n(t.coords.longitude).toFixed(4)),accuracy:Math.max(t.coords.accuracy??0,3e3),altitude:null,altitudeAccuracy:null,heading:null,speed:null}}}import{callCapacitorNative as V,hasCapacitorPlugin as ot,installCapacitorBridge as kn,interceptCapacitor as se,makeCapacitorCallbackId as xn}from"@buoy-gg/license/web";var ae=["undetermined","granted","limited","denied","blocked","restricted"],En=["ask","allow","limited","deny"],xe={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"}},Ee=Object.keys(xe);function Ie(e){return typeof e=="string"&&(e in xe||e.startsWith("android:")&&e.length>8)}function R(e){let t=xe[e];if(t)return t;let n=e.slice(8).replace(/^android\.permission\./,"");return{id:e,label:n.toLowerCase().split("_").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" "),only:"android",purpose:`use ${n.toLowerCase().replace(/_/g," ")}`}}function le(e,t){let n=R(e),i=["undetermined","granted"];return n.limited?.[t]&&i.push("limited"),i.push("denied"),t==="android"&&i.push("blocked"),t==="ios"&&e!=="notifications"&&i.push("restricted"),i}function rt(e,t,n){return le(e,t).includes(n)}function st(e,t,n){return rt(e,t,n)?n:n==="blocked"?"denied":n==="restricted"?t==="android"?"blocked":"denied":n==="limited"?"granted":n}function at(e,t){return t==="undetermined"?true:e==="android"&&t==="denied"}function In(e,t,n,i){return at(t,n)?i==="allow"||i==="once"?"granted":i==="limited"?rt(e,t,"limited")?"limited":"granted":t==="android"&&n==="denied"?"blocked":"denied":n}function lt(e,t){return t==="ios"?e==="location":e==="camera"||e==="microphone"}function Cn(e,t){let n=R(e).limited?.[t],i=t==="ios",o=[];if(i&<(e,t)&&o.push({answer:"once",label:"Allow Once"}),e==="location"||e==="locationBackground"?o.push({answer:"allow",label:i?"Allow While Using App":"While using the app"}):o.push({answer:"allow",label:"Allow"}),!i&<(e,t)&&o.push({answer:"once",label:"Only this time"}),n){let r=e==="location"?i?"Allow With Approximate Location":"Approximate location":e==="photos"?i?"Limit Access\u2026":"Select photos":e==="contacts"?"Select Contacts\u2026":`Allow ${n}`;o.push({answer:"limited",label:r})}return o.push({answer:"deny",label:i?"Don\u2019t Allow":"Don\u2019t allow"}),o}function Tn(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 On(e,t){if(!e||typeof e!="object")return null;let n=e,i=typeof n.ios?.status=="number"?n.ios.status:void 0;return i===3||i===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 $(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"}}var Rn={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 W(e){return Rn[e]??null}function Ce(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 Nn(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 K(e,t,n){if(e==="location"&&"location"in t){let i=Ce(t.location,n),o=Ce(t.coarseLocation,n);return i!=="granted"&&o==="granted"?"limited":i}for(let[i,o]of Object.entries(t))if(W(i)===e)return Ce(o,n);return null}function ct(e,t,n){let i={...e};for(let o of Object.keys(e)){let r=W(o);if(!r)continue;let s=t(r);s!==null&&(r==="location"&&s==="limited"?i[o]=o==="coarseLocation"||n==="ios"?"granted":"denied":s==="limited"&&r!=="photos"&&r!=="contacts"?i[o]="granted":i[o]=Nn(s,n))}return i}import{devToolsStorageKeys as Dn,persistentStorage as dt}from"@buoy-gg/shared-ui/web";function Ln(){try{let e=globalThis.localStorage;return e?pt(e.getItem(Te)):void 0}catch{return}}var U={requestAnswer:"ask",persist:true,showChip:true,notifyApp:true,enforce:true,interceptSettings:true},Te=Dn.permissions.state();function G(e,t){return typeof e=="boolean"?e:t}function ut(e){let t=e&&typeof e=="object"?e:{};return{requestAnswer:En.includes(t.requestAnswer)?t.requestAnswer:U.requestAnswer,persist:G(t.persist,U.persist),showChip:G(t.showChip,U.showChip),notifyApp:G(t.notifyApp,U.notifyApp),enforce:G(t.enforce,U.enforce),interceptSettings:G(t.interceptSettings,U.interceptSettings)}}function pt(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1)return null;let n={};for(let[i,o]of Object.entries(t.overrides??{}))Ie(i)&&ae.includes(o)&&(n[i]=o);return{v:1,overrides:n,settings:ut(t.settings)}}catch{return null}}async function qn(){try{return pt(await dt.getItem(Te))}catch{return null}}var Oe=Promise.resolve();function mt(e){let t=JSON.stringify(e);return Oe=Oe.then(()=>dt.setItem(Te,t)).catch(()=>{}),Oe.then(()=>{})}var ft=200,Mn=50,ht="__buoyPermissionsStore",gt=globalThis,l=gt[ht]??(gt[ht]={platform:"ios",booted:false,overrides:new Map,settings:{...U},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});l.once??(l.once=new Set);var Y=()=>{let e=globalThis.__buoyRealNow;return typeof e=="function"?e():Date.now()};function S(){l.snapshot=null;for(let e of Array.from(l.listeners))try{e()}catch{}}function B(){if(!l.settings.persist){mt({v:1,overrides:{},settings:l.settings});return}mt($n())}function $n(){return{v:1,overrides:Object.fromEntries(Array.from(l.overrides,([e,t])=>[e,l.once.has(e)?"undetermined":t])),settings:l.settings}}function D(e){let t=l.seen.get(e);return t||(t={sources:new Set,real:null,calls:0,lastCallAt:null,lastReadAt:null,changedAt:null},l.seen.set(e,t)),t}function yt(e){if(e&&(l.settings=e.settings,l.overrides.clear(),!!e.settings.persist))for(let[t,n]of Object.entries(e.overrides)){let i=t;l.overrides.set(i,st(i,l.platform,n))}}function Re(e){l.platform=e.platform,e.host&&(l.host=e.host),S()}function bt(){if(l.booted)return;l.booted=true;let e=Ln();if(e!==void 0){yt(e),S();return}qn().then(t=>{l.overrides.size>0||(yt(t),S())})}function Un(e,t){l.realRequesters.has(e)||l.realRequesters.set(e,t)}async function jn(e){let t=Ne(e),n=l.realRequesters.get(t);if(!n)throw new Error(`No installed library can ask the system for ${R(t).label}.`);let i=await n();return i!==null&&q(t,i),v()}function wt(e){l.prompter=e}function vt(e){return l.changeHooks.add(e),()=>l.changeHooks.delete(e)}function J(e,t){for(let n of Array.from(l.changeHooks))try{n({id:e,from:t})}catch{}}function ce(e,t){let n=!l.libraries.has(e);l.libraries.add(e);for(let i of t){let o=D(i);o.sources.has(e)||(o.sources.add(e),n=true)}n&&S()}function Z(){return l.platform}function L(){return l.settings}function w(e){return l.overrides.get(e)??null}function Bn(e){return l.overrides.has(e)}function _n(){return l.overrides.size>0}function q(e,t,n){if(t===null)return;let i=D(e);n&&i.sources.add(n),i.real!==t&&(i.real=t,S())}function C(e){let t={...e,id:l.nextLogId++,at:Y()};if(l.log.unshift(t),l.log.length>ft&&(l.log.length=ft),e.permission){let n=D(e.permission);(e.kind==="check"||e.kind==="request")&&n.sources.add(e.source),n.calls+=1,n.lastCallAt=t.at,(e.kind==="check"||e.kind==="request")&&(n.lastReadAt=t.at),e.real!==null&&e.kind!=="gated"&&(n.real=e.real)}return S(),t}async function At(e){let t=l.overrides.get(e);if(t===void 0)throw new Error(`${e} is not overridden`);if(!at(l.platform,t))return{state:t};let n,i=l.settings.requestAnswer;i==="ask"&&l.prompter?n=await l.prompter(e):n=i==="ask"?"allow":i;let o=l.overrides.get(e);if(o===void 0)return{state:t,answer:n};let r=In(e,l.platform,o,n);return n==="once"&&r==="granted"&&l.once.add(e),r!==o&&(l.overrides.set(e,r),B(),S(),J(e,"request")),{state:r,answer:n}}function Ne(e){if(!Ie(e))throw new Error(`Unknown permission "${String(e)}". Use one of: ${Ee.join(", ")}, or android:<android.permission.NAME>.`);return e}function Pt(e,t){let n=Ne(e);if(!ae.includes(t))throw new Error(`Unknown state "${String(t)}". Use one of: ${ae.join(", ")}.`);let i=t,o=le(n,l.platform),r=l.platform==="ios"&&i==="blocked"?"denied":i;if(!o.includes(r))throw new Error(`${R(n).label} can't be "${i}" on ${l.platform}. It can be: ${o.join(", ")}.`);return(l.overrides.get(n)!==r||l.once.has(n))&&(l.overrides.set(n,r),l.once.delete(n),D(n).changedAt=Y(),B(),S(),J(n,"tool")),v()}function St(e){let t=Ne(e);return l.overrides.delete(t)&&(l.once.delete(t),D(t).changedAt=Y(),B(),S(),J(t,"tool")),v()}function De(){if(l.overrides.size>0){let e=Y();for(let t of l.overrides.keys())D(t).changedAt=e;l.overrides.clear(),l.once.clear(),B(),S(),J(null,"tool")}return v()}function zn(){return Object.fromEntries(l.overrides)}function Hn(e){let t=Y();for(let n of l.overrides.keys())D(n).changedAt=t;l.overrides.clear(),l.once.clear();for(let[n,i]of Object.entries(e)){let o=n;!i||!Ie(o)||(l.overrides.set(o,st(o,l.platform,i)),D(o).changedAt=t)}return B(),S(),J(null,"tool"),v()}function kt(e){let t={};for(let[i,o]of Object.entries(e))o!==void 0&&(t[i]=o);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=ut({...l.settings,...t});return l.settings=n,B(),S(),v()}function Fn(){l.log=[];for(let e of l.seen.values())e.calls=0,e.lastCallAt=null;return S(),v()}function Vn(e,t){if(!e||!t)return null;let n=i=>i==="granted"||i==="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 v(){if(l.snapshot)return l.snapshot;let e=new Set([...l.seen.keys(),...l.overrides.keys()]),t=i=>{let o=Ee.indexOf(i);return o===-1?1e3:o},n=Array.from(e).filter(i=>{let o=R(i).only;return!o||o===l.platform}).sort((i,o)=>t(i)-t(o)||i.localeCompare(o)).map(i=>{let o=l.seen.get(i),r=l.overrides.get(i)??null,s=o?.real??null;return{id:i,label:R(i).label,states:le(i,l.platform),override:r,real:s,effective:r??s,sources:o?Array.from(o.sources).sort():[],calls:o?.calls??0,lastCallAt:o?.lastCallAt??null,lastReadAt:o?.lastReadAt??null,changedAt:o?.changedAt??null,stale:o?.changedAt!=null&&o.lastReadAt!=null&&o.lastReadAt<o.changedAt,once:l.once.has(i),warning:Vn(r,s),canRequestReal:l.realRequesters.has(i)}});return l.snapshot={platform:l.platform,host:l.host,libraries:Array.from(l.libraries).sort(),permissions:n,overriddenCount:l.overrides.size,settings:l.settings,log:l.log.slice(0,Mn)},l.snapshot}function X(e){return l.listeners.add(e),()=>l.listeners.delete(e)}var de=10,Le=[{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"}}],Wn=[{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 N(e){return Le.find(t=>t.plugin===e)?.library??`Capacitor ${e}`}var xt=e=>e==="denied"||e==="blocked"||e==="restricted";function ue(e){let t=new Set;for(let n of Object.keys(e)){let i=W(n);i&&t.add(i)}return Array.from(t)}function j(e){return e&&typeof e=="object"?e:{}}var Et=false;function Kn(){if(Et)return true;if(!kn())return false;Et=true;let e=Z();se({plugin:"*",methods:["checkPermissions"],order:de,promise:async(t,n)=>{let i=j(await n()),o=ue(i);if(o.length===0)return i;for(let r of o){let s=K(r,i,e);q(r,s,N(t.plugin));let a=w(r);C({source:N(t.plugin),method:`${t.plugin}.checkPermissions`,permission:r,kind:"check",real:s,returned:a??s,overridden:a!==null})}return ct(i,w,e)}}),se({plugin:"*",methods:["requestPermissions"],order:de,promise:async(t,n)=>{let i=Array.isArray(t.options.permissions)?t.options.permissions.map(String):null,o=d=>{let c=W(d);return c!==null&&w(c)!==null},r=i??Object.keys(j(await V(t.plugin,"checkPermissions").catch(()=>({}))));if(!r.some(o)){let d=j(await n());for(let c of ue(d)){let g=K(c,d,e);q(c,g,N(t.plugin)),C({source:N(t.plugin),method:`${t.plugin}.requestPermissions`,permission:c,kind:"request",real:g,returned:g,overridden:false})}return d}let s=r.filter(d=>!o(d)),a=s.length?j(await V(t.plugin,"requestPermissions",{...t.options,permissions:s})):j(await V(t.plugin,"checkPermissions").catch(()=>({})));for(let d of ue(a)){if(w(d)!==null)continue;let c=K(d,a,e);q(d,c,N(t.plugin)),C({source:N(t.plugin),method:`${t.plugin}.requestPermissions`,permission:d,kind:"request",real:c,returned:c,overridden:false})}let u=new Set;for(let d of r.filter(o)){let c=W(d);if(u.has(c))continue;u.add(c);let{state:g,answer:P}=await At(c);C({source:N(t.plugin),method:`${t.plugin}.requestPermissions`,permission:c,kind:"request",real:null,returned:g,overridden:true,answer:P})}for(let d of r)d in a||(a={...a,[d]:"prompt"});return ct(a,w,e)}});for(let t of Wn)se({plugin:t.plugin,methods:t.methods,order:de,promise:(n,i)=>{let o=t.permission(n.options),r=w(o);if(L().enforce&&r==="limited"&&t.plugin==="Geolocation")return i().then(a=>ke(a));if(!L().enforce||!xt(r))return i();let s=t.message(o);return C({source:N(t.plugin),method:`${t.plugin}.${n.method}`,permission:o,kind:"gated",real:null,returned:r,overridden:true,error:s}),Promise.reject(new Error(s))}});se({plugin:"Geolocation",methods:["watchPosition"],order:de,callback:(t,n,i)=>{let o=w("location");if(L().enforce&&o==="limited")return i((s,a)=>n(a?s:ke(s),a));if(!L().enforce||!xt(o))return i(n);let r="Location permission was denied";return C({source:N("Geolocation"),method:"Geolocation.watchPosition",permission:"location",kind:"gated",real:null,returned:o,overridden:true,error:r}),setTimeout(()=>n(null,new Error(r)),0),xn()}});for(let t of Le){if(!ot(t.plugin))continue;let n=Object.keys(t.aliases);ce(t.library,n);for(let i of n){let o=t.aliases[i];Un(i,async()=>{let r=j(await V(t.plugin,"requestPermissions",{permissions:[o]})),s=K(i,r,e);return C({source:t.library,method:`${t.plugin}.requestPermissions (system)`,permission:i,kind:"request",real:s,returned:s,overridden:false}),s})}}return true}async function Gn(){let e=Z();for(let t of Le)if(ot(t.plugin))try{let n=j(await V(t.plugin,"checkPermissions"));for(let i of ue(n))q(i,K(i,n,e),t.library)}catch{}}var It={geolocation:"location",camera:"camera",microphone:"microphone",notifications:"notifications",push:"notifications"},qe=e=>e==="denied"||e==="blocked"||e==="restricted";function Me(e){return e==="undetermined"?"prompt":qe(e)?"denied":"granted"}function pe(e){return e==="prompt"?"undetermined":e==="granted"?"granted":e==="denied"?"denied":null}var Ct=()=>globalThis.navigator;function Yn(){return{code:1,message:"User denied Geolocation",PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3}}function Jn(e){let t=globalThis.DOMException;return t?new t(e,"NotAllowedError"):Object.assign(new Error(e),{name:"NotAllowedError"})}async function $e(e){let t=w(e);return t!=="undetermined"?t:(await At(e)).state}var Ue=new Map;function Zn(e,t,n){let i=globalThis.EventTarget,o=new i;o.onchange=null,o.name=t,Object.defineProperty(o,"state",{enumerable:true,get:()=>{let a=w(e);return a===null?n?.state??"prompt":Me(a)}}),o.addEventListener("change",a=>o.onchange?.(a));let r=globalThis.Event;n?.addEventListener?.("change",()=>{w(e)===null&&r&&o.dispatchEvent(new r("change"))});let s=globalThis.WeakRef;if(s){let a=Ue.get(e);a||Ue.set(e,a=new Set),a.add(new s(o))}return o}function Xn(e){let t=globalThis.Event;if(t){for(let[n,i]of Ue)if(!(e!==null&&n!==e))for(let o of i){let r=o.deref();r?r.dispatchEvent(new t("change")):i.delete(o)}}}var Tt=new WeakMap,me=new WeakSet;function Q(e,t,n){if(!e)return;let i=e[t];if(typeof i!="function"||me.has(i))return;let o=n(i);me.add(o),Tt.set(o,i);try{e[t]=o}catch{Object.defineProperty(e,t,{configurable:true,writable:true,value:o})}}function je(){let e=Ct();if(!e)return;e.permissions?.query&&Q(e.permissions,"query",o=>async function(r){let s=It[String(r?.name)];if(!s)return o.call(this,r);let a=await o.call(this,r).catch(()=>null);a&&q(s,pe(a.state),"navigator.permissions");let u=w(s);return C({source:"navigator.permissions",method:"permissions.query",permission:s,kind:"check",real:a?pe(a.state):null,returned:u??(a?pe(a.state):null),overridden:u!==null}),Zn(s,r.name,a)});let t=e.geolocation,n=o=>Q(t,o,r=>function(s,a,u){if(w("location")===null||!L().enforce)return r.call(this,s,a,u);let d=0,c=false;if($e("location").then(P=>{if(c)return;if(qe(P)){C({source:"navigator.geolocation",method:`geolocation.${o}`,permission:"location",kind:"gated",real:null,returned:P,overridden:true,error:"User denied Geolocation"}),a?.(Yn());return}let O=P==="limited";d=r.call(this,O?H=>s(ke(H)):s,a,u)}),o!=="watchPosition")return;let g=Math.floor(Math.random()*1e9)+1;return Be.set(g,()=>{c=true,d&&e.geolocation.clearWatch(d)}),g});n("getCurrentPosition"),n("watchPosition"),Q(t,"clearWatch",o=>function(r){let s=Be.get(r);if(s){Be.delete(r),s();return}return o.call(this,r)}),Q(e.mediaDevices,"getUserMedia",o=>async function(r){let s=[];if(r?.video&&s.push("camera"),r?.audio&&s.push("microphone"),L().enforce)for(let a of s){if(w(a)===null)continue;let u=await $e(a);if(qe(u))throw C({source:"navigator.mediaDevices",method:"mediaDevices.getUserMedia",permission:a,kind:"gated",real:null,returned:u,overridden:true,error:"Permission denied"}),Jn("Permission denied")}return o.call(this,r)});let i=globalThis.Notification;if(i&&!me.has(i)){me.add(i);let o=(()=>{let r=Object.getPrototypeOf(i),s=Object.getOwnPropertyDescriptor(i,"permission")??Object.getOwnPropertyDescriptor(r??{},"permission");return s?.get?String(s.get.call(i)):String(s?.value??"default")})();Object.defineProperty(i,"permission",{configurable:true,get:()=>{let r=w("notifications");if(r===null)return o;let s=Me(r);return s==="prompt"?"default":s}}),Q(i,"requestPermission",r=>async function(...s){if(w("notifications")===null)return r.apply(this,s);let a=Me(await $e("notifications")??"undetermined"),u=a==="prompt"?"default":a,d=s[0];return typeof d=="function"&&d(u),u})}}var Be=new Map,Ot=false;function Qn(){if(Ot)return true;let e=Ct();if(!e)return false;Ot=true,je(),setTimeout(je,0),vt(({id:t})=>{je(),Xn(t??null)}),e.geolocation&&ce("navigator.geolocation",["location"]),e.mediaDevices?.getUserMedia&&ce("navigator.mediaDevices",["camera","microphone"]),globalThis.Notification&&ce("Notification",["notifications"]);for(let[t,n]of Object.entries(It))t!=="push"&&Tt.get(e.permissions?.query)?.call(e.permissions,{name:t})?.then(i=>q(n,pe(i.state),"navigator.permissions"))?.catch(()=>{});return true}function ee(e,t,n,i){let o=e.createElement(t);return Object.assign(o.style,n),i!==void 0&&(o.textContent=i),o}var Rt={alert(e,t,n,i){let o=globalThis.document;if(!o?.body){i?.onDismiss?.();return}let r=ee(o,"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 s=ee(o,"div",{width:"100%",maxWidth:"290px",background:"#f2f2f7",color:"#000",borderRadius:"14px",overflow:"hidden",textAlign:"center"});s.appendChild(ee(o,"div",{padding:"18px 16px 4px",fontWeight:"600",fontSize:"17px",lineHeight:"22px"},e)),t&&s.appendChild(ee(o,"div",{padding:"0 16px 16px",fontSize:"13px",lineHeight:"18px",whiteSpace:"pre-line"},t));let a=false,u=()=>{a=true,r.remove()},d=n?.length?n:[{text:"OK"}];for(let c of d){let g=ee(o,"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:c.style==="cancel"?"600":"400",cursor:"pointer"},c.text);g.addEventListener("click",()=>{a||(u(),c.onPress?.())}),s.appendChild(g)}r.appendChild(s),i?.cancelable&&r.addEventListener("click",c=>{a||c.target!==r||(u(),i.onDismiss?.())}),o.body.appendChild(r)}};var _e=null;function ze(e){_e=e&&e.trim()?e.trim():null}function Nt(){return _e?{name:_e}:null}function Dt(){let e=Nt()?.name;return typeof e=="string"&&e?e:"This app"}var ei={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 ti(e){let t=ei[e],n=Nt();if(!t||!n)return null;let i=Dt(),o=r=>typeof r=="string"&&r.trim()?r.replace(/\$\(PRODUCT_NAME\)/g,i).trim():null;for(let r of t.plist){let s=o(n.ios?.infoPlist?.[r]);if(s)return s}for(let[r,s]of t.plugins)for(let a of n.plugins??[])if(Array.isArray(a)&&a[0]===r&&a[1]&&typeof a[1]=="object"){let u=o(a[1][s]);if(u)return u}return null}var Lt="Test prompt from Buoy. Your phone's settings won't change.",qt=Promise.resolve();function Mt(e){return t=>{let n=()=>new Promise(o=>{let r=Z(),s=R(t),a=Dt(),u=r==="ios"?`Allow \u201C${a}\u201D to ${s.purpose}?`:`Allow ${a} to ${s.purpose}?`,d=Cn(t,r),c=false,g=O=>{c||(c=true,o(O))},P=r==="ios"?ti(t):null;e.alert(u,P?`${P}
|
|
2
2
|
|
|
3
|
-
${ft}`:ft,d.map(L=>({text:L.label,style:L.answer==="deny"?"cancel":"default",onPress:()=>y(L.answer)})),{cancelable:r==="android",onDismiss:()=>y("deny")})}),i=ht.then(n,n);return ht=i.catch(()=>{}),i}}var gt="__buoyPermissionsInstalled";function Mn(){ie("App","appStateChange",{isActive:false}),ie("App","pause",{}),setTimeout(()=>{ie("App","resume",{}),ie("App","appStateChange",{isActive:true})},60)}function Ee(){let e=Qt();if(!e)return false;let t=globalThis;if(t[gt])return false;t[gt]=true,rt({platform:e,host:{isSimulator:null,deviceName:null,bundleId:null}}),yn(),vn($n(Ln));let n=globalThis.document?.title??null;return ut(n),en("App")&&Xt("App","getInfo").then(i=>ut(i?.name??n)).catch(()=>{}),On()?(An(({from:i})=>{i==="tool"&&_().notifyApp&&Mn()}),tn().then(i=>{i&&rt({platform:e,host:{isSimulator:i.isSimulator,deviceName:i.deviceName,bundleId:i.bundleId}})}),setTimeout(()=>{Nn()},1500),true):false}import{useEffect as Bn,useSyncExternalStore as yt}from"react";var bt={};Jt(bt,{AccessibilityInfo:()=>zn,ActivityIndicator:()=>zi,Alert:()=>Vi,Animated:()=>Hn,AppRegistry:()=>Vn,AppState:()=>Wn,Appearance:()=>Fn,BackHandler:()=>Kn,Button:()=>Hi,CheckBox:()=>li,Clipboard:()=>Gn,DeviceEventEmitter:()=>ki,Dimensions:()=>Yn,Easing:()=>Jn,FlatList:()=>ci,I18nManager:()=>Zn,Image:()=>di,ImageBackground:()=>ui,InteractionManager:()=>Qn,Keyboard:()=>Xn,KeyboardAvoidingView:()=>pi,LayoutAnimation:()=>ei,Linking:()=>ti,LogBox:()=>Pi,Modal:()=>Ui,NativeEventEmitter:()=>ni,NativeModules:()=>jn,PanResponder:()=>ii,Picker:()=>mi,PixelRatio:()=>oi,Platform:()=>wt,Pressable:()=>_i,ProgressBar:()=>fi,RefreshControl:()=>hi,SafeAreaView:()=>gi,ScrollView:()=>Pt,SectionList:()=>yi,Share:()=>ri,StatusBar:()=>bi,StyleSheet:()=>ce,Switch:()=>ji,Text:()=>h,TextInput:()=>$i,Touchable:()=>wi,TouchableHighlight:()=>Mi,TouchableNativeFeedback:()=>vi,TouchableOpacity:()=>x,TouchableWithoutFeedback:()=>Bi,UIManager:()=>si,Vibration:()=>ai,View:()=>b,VirtualizedList:()=>Ai,YellowBox:()=>Si,findNodeHandle:()=>Fi,unstable_createElement:()=>Un,useColorScheme:()=>xi,useLocaleContext:()=>Ci,useWindowDimensions:()=>Ii});Zt(bt,_n);import*as _n from"react-native-web";import{unstable_createElement as Un,NativeModules as jn,AccessibilityInfo as zn,Animated as Hn,Appearance as Fn,AppRegistry as Vn,AppState as Wn,BackHandler as Kn,Clipboard as Gn,Dimensions as Yn,Easing as Jn,I18nManager as Zn,Keyboard as Xn,InteractionManager as Qn,LayoutAnimation as ei,Linking as ti,NativeEventEmitter as ni,PanResponder as ii,PixelRatio as oi,Platform as wt,Share as ri,StyleSheet as ce,UIManager as si,Vibration as ai,CheckBox as li,FlatList as ci,Image as di,ImageBackground as ui,KeyboardAvoidingView as pi,Picker as mi,ProgressBar as fi,RefreshControl as hi,SafeAreaView as gi,SectionList as yi,StatusBar as bi,Touchable as wi,TouchableNativeFeedback as vi,VirtualizedList as Ai,YellowBox as Si,LogBox as Pi,DeviceEventEmitter as ki,useColorScheme as xi,useLocaleContext as Ci,useWindowDimensions as Ii}from"react-native-web";import*as S from"react-native-web";import{createElement as Te,forwardRef as vt,useCallback as Ri,useRef as Ei}from"react";import{useEffect as Ti,useState as Oi}from"react";import{createPortal as Ni}from"react-dom";var Li='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as Di}from"react/jsx-runtime";var Q=Symbol.for("@buoy-gg/portal-host"),At=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function St(){let e=document;if(e[Q])return e[Q].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Li});let n=()=>{let l=document.fullscreenElement,y=l&&l.tagName!=="CANVAS"?l:document.body;t.parentElement!==y&&y.appendChild(t)},i=new Map,o=l=>{(!t.contains(l.target)||!At(l.target))&&i.set(l.code||l.key,{key:l.key,code:l.code,location:l.location,keyCode:l.keyCode,which:l.which,altKey:l.altKey,ctrlKey:l.ctrlKey,metaKey:l.metaKey,shiftKey:l.shiftKey})},r=l=>{i.delete(l.code||l.key)},c=()=>i.clear(),a=()=>{let l=[...i.values()];i.clear();for(let y of l)document.dispatchEvent(new KeyboardEvent("keyup",{...y,bubbles:true}))},u=l=>{At(l.target)&&l.stopPropagation()},d=l=>l.stopPropagation();return n(),document.addEventListener("fullscreenchange",n),document.addEventListener("keydown",o,true),document.addEventListener("keyup",r,true),window.addEventListener("blur",c),t.addEventListener("focusin",a),t.addEventListener("keydown",u),t.addEventListener("keyup",u),t.addEventListener("keypress",u),t.addEventListener("wheel",d,{passive:true}),e[Q]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",n),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",r,true),window.removeEventListener("blur",c),t.remove(),delete e[Q]}},t}function qi({children:e}){let[t,n]=Oi(null);return Ti(()=>{let i=St(),o=document[Q];return o.users++,n(i),()=>{--o.users===0&&o.dispose()}},[]),t?Ni(Di("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function k(e){let t=vt((i,o)=>{let{accessibilityState:r,accessibilityValue:c,...a}=i;for(let u of["busy","checked","disabled","expanded","selected"])r?.[u]!==void 0&&a[`aria-${u}`]===void 0&&(a[`aria-${u}`]=r[u]);for(let[u,d]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))c?.[u]!==void 0&&a[`aria-${d}`]===void 0&&(a[`aria-${d}`]=c[u]);return Te(e,{...a,ref:o})}),n=e.State;return n&&Object.assign(t,{State:n}),t.displayName=e.displayName??e.name??"NativeWebView",t}var b=k(S.View),h=k(S.Text),$i=k(S.TextInput),x=k(S.TouchableOpacity),Mi=k(S.TouchableHighlight),Bi=k(S.TouchableWithoutFeedback),_i=k(S.Pressable),Pt=k(S.ScrollView),kt=vt((e,t)=>{let n=Ei(null),i=Ri(o=>{if(o){let r=o;for(;r.parentElement&&r.parentElement!==document.body;)r=r.parentElement;r.parentElement===document.body&&(n.current=r,Object.assign(r.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),St().appendChild(r))}else n.current&&(document.body.appendChild(n.current),n.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return Te(qi,null,Te(S.Modal,{...e,ref:i}))});kt.displayName="Modal";var Ui=k(kt),ji=k(S.Switch),zi=k(S.ActivityIndicator),Hi=k(S.Button),Fi=S.findNodeHandle,Vi={alert(e,t,n,i){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.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",o.appendChild(r),t){let d=document.createElement("p");d.textContent=t,d.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(d)}let c=document.createElement("div");c.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let a=n?.length?n:[{text:"OK"}],u=()=>{o.close?.(),o.remove()};for(let d of a){let l=document.createElement("button");l.type="button",l.textContent=d.text??"OK",l.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${d.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,l.onclick=()=>{u(),d.onPress?.()},c.appendChild(l)}o.addEventListener("cancel",d=>{d.preventDefault(),i?.cancelable!==false&&(u(),i?.onDismiss?.())}),o.appendChild(c),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{FloatingTool as xt,PermissionsIcon as Ct,X as Wi,dismissFloatingTool as Ki,getFloatingTools as Gi,night as ee,openBuoyTool as Yi,openFloatingTool as It}from"@buoy-gg/shared-ui/web";import{jsx as P,jsxs as Oe}from"react/jsx-runtime";var de="permissions-chip",Ji=8e3,Rt={id:de,render:e=>P(Ot,{...e})},Zi=()=>Gi().some(e=>e.id===de);function Xi(){It(Rt)}var j=null,Ne=new Set,ue=()=>{};function pe(e){j&&clearTimeout(j.timer),j=e;for(let t of Array.from(Ne))t();ue()}function Qi(e){return Ne.add(e),()=>{Ne.delete(e)}}var Et=()=>j;function eo(){pe({overrides:Cn(),timer:setTimeout(()=>pe(null),Ji)}),Ce()}function to(){let e=j;e&&(pe(null),In(e.overrides))}var Tt=false;function no(){if(Tt)return;Tt=true;let e=false;ue=()=>{let t=(kn()||j!==null)&&_().showChip;t&&!e?It(Rt):!t&&Zi()&&Ki(de),e=t},Z(ue),ue()}function Ot({id:e,revealToken:t}){let n=yt(Z,w,w),i=yt(Qi,Et,Et);Bn(()=>{i&&n.overriddenCount>0&&pe(null)},[i,n.overriddenCount]);let o=n.permissions.filter(a=>a.override!==null),r=o.length===1?o[0]:null,c=r?`${r.label}: ${r.once&&r.override==="granted"?"Allowed Once":D(r.id,n.platform,r.override)}`:`${o.length} permissions simulated`;return i&&o.length===0?P(xt,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:"Move or hide the permissions strip",handleAdornment:P(Ct,{size:12}),children:Oe(b,{style:I.row,children:[P(h,{style:I.title,numberOfLines:1,testID:"permissions-chip-summary",children:"Real permissions"}),P(x,{testID:"permissions-chip-undo",accessibilityRole:"button",accessibilityLabel:"Undo, put the simulated permissions back",onPress:to,style:I.undo,hitSlop:{top:8,bottom:8,left:8,right:8},children:P(h,{style:I.undoText,children:"Undo"})})]})}):P(xt,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the permissions strip. ${c}`,handleAdornment:P(Ct,{size:12}),children:Oe(b,{style:I.row,children:[Oe(x,{testID:"permissions-chip-open",accessibilityRole:"button",accessibilityLabel:`${c}. Open Permissions`,onPress:()=>{Yi("permissions")},style:I.open,children:[P(b,{style:I.dot}),P(h,{style:I.title,numberOfLines:1,testID:"permissions-chip-summary",children:c})]}),P(b,{style:I.separator}),P(x,{testID:"permissions-chip-reset",accessibilityRole:"button",accessibilityLabel:"Use real permissions",onPress:eo,style:I.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:P(Wi,{size:16,color:ee.color.textSecondary})})]})})}var I=ce.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:ee.color.accent},title:{color:ee.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:ee.color.accent,fontSize:14,fontWeight:"600"},separator:{width:ce.hairlineWidth,height:20,backgroundColor:ee.color.separator}});import{PermissionsIcon as io,PERMISSIONS_ICON_COLOR as oo,createToolFactory as ro,defineToolPreset as so}from"@buoy-gg/shared-ui/web";import{useEffect as ao,useState as lo,useSyncExternalStore as co}from"react";import{capacitorPlatform as uo}from"@buoy-gg/license/web";import{reloadApp as po}from"@buoy-gg/shared-ui/web";var Le={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"}},Nt={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"}},mo=[{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",...Le},{method:"getLastKnownPositionAsync",permission:"location",...Le},{method:"watchPositionImplAsync",permission:"location",...Le},{method:"startGeofencingAsync",permission:"locationBackground",...Nt},{method:"startLocationUpdatesAsync",permission:"locationBackground",...Nt}]},{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 fo(){let e=globalThis.expo?.modules;return e&&typeof e=="object"?e:null}function ho(e){try{return new Set(Object.keys(e))}catch{return new Set}}function go(e,t=[]){return e.flavor!=="privileges"?[]:t.length>0?t.slice(0,1):[false]}async function Lt(){let e=fo();if(!e)return;let t=ho(e),n=J(),i=[];for(let o of mo){if(!t.has(o.module))continue;let r=e[o.module];if(!r)continue;let c=new Set;for(let a of o.permissions){if(c.has(a.permission))continue;let u=r[a.get],d=u?.__buoyPermissionsOriginal??u;typeof d=="function"&&(c.add(a.permission),i.push(Promise.resolve().then(()=>d.apply(r,go(a))).then(l=>U(a.permission,cn(l,n),o.library)).catch(()=>{})))}}await Promise.all(i)}import{createSyncAdapter as yo}from"@buoy-gg/shared-ui/web";import{BUOY_SYNTHETIC_MARK as bo}from"@buoy-gg/shared-ui/web";var Dt=null;function De(e){try{Dt?.emit("appStateDidChange",{app_state:e,[bo]:true})}catch{}}function wo(){J()==="ios"&&De("inactive"),De("background")}function vo(){De("active")}var me=null,qt=false,$t=null;function Ao(){return qt}function fe(){return $t?($t(),true):false}function So(){!Dt||qt||(me&&clearTimeout(me),me=setTimeout(()=>{me=null,wo(),setTimeout(vo,60)},120))}function he(e){return e&&typeof e=="object"?e:{}}function qe(e){return e.permission??e.id??e.permissionId??e.name}function te(e,t){let n=e[t];if(typeof n=="boolean")return n;if(n==="true")return true;if(n==="false")return false}var Mt=yo({version:1,getSnapshot(){return w()},subscribe(e){return Z(e)},actions:{async getState(){return await Lt(),Ao()?{...w(),settingsStandInOpen:true}:w()},setOverride(e){let t=he(e),n=qe(t),i=t.state??t.status??t.value;if(n===void 0||i===void 0)throw new Error('setOverride needs `permission` (e.g. "location", "camera", "notifications") and `state` ("undetermined", "granted", "limited", "denied", "blocked" or "restricted").');return fe(),st(n,i)},clearOverride(e){let t=qe(he(e));if(t===void 0)throw new Error("clearOverride needs `permission`.");return fe(),at(t)},requestReal(e){let t=qe(he(e));if(t===void 0)throw new Error("requestReal needs `permission`.");return wn(t)},resetAll(){return fe(),Ce()},updateSettings(e){let t=he(e);return lt({requestAnswer:t.requestAnswer??t.answer,persist:te(t,"persist"),showChip:te(t,"showChip"),notifyApp:te(t,"notifyApp"),enforce:te(t,"enforce"),interceptSettings:te(t,"interceptSettings")})},clearLog(){return Rn()},simulateReturnFromSettings(){return fe()||So(),w()}}});import{useEffect as Po,useReducer as ko,useState as Bt}from"react";import{Check as xo,ChevronLeft as Co,ChevronRight as _t,NightCard as N,NightFootnote as z,NightRows as $e,NightSectionLabel as Ut,night as m,useSafeAreaInsets as Io,useToolScreenHeader as Ro}from"@buoy-gg/shared-ui/web";import{Fragment as jt,jsx as p,jsxs as g}from"react/jsx-runtime";var Me=1500,Eo=()=>{let e=globalThis.__buoyRealNow;return typeof e=="function"?e():Date.now()};function To(e,t){return e.effective?e.once&&e.effective==="granted"?"Allowed Once":D(e.id,t,e.effective):"Not Checked"}function zt({snapshot:e,onAction:t,onReload:n,browserOnly:i}){let o=Io({minBottom:16}),[r,c]=Bt(null),[a,u]=Bt({name:"list"}),d=(v,ye)=>{c(null),t(v,ye).catch(be=>{c(be instanceof Error?be.message:String(be))})},l=a.name==="detail"?e?.permissions.find(v=>v.id===a.id):void 0,y=()=>u(a.name==="detail"&&a.from==="other"?{name:"other"}:{name:"list"}),C=a.name==="other"?"Other Permissions":l?l.label:null,L=Ro(C?{title:C,onBack:y,searchable:false}:null,[C,a.name,a.name==="detail"?a.from:null]);if(!e)return p(b,{style:f.waiting,testID:"permissions-waiting",children:p(z,{centered:true,children:"Waiting for the app\u2026"})});let{platform:ge,permissions:Be}=e,_e=Be.filter(v=>v.calls>0||v.override!==null),ne=Be.filter(v=>!(v.calls>0||v.override!==null)),Ue=(v,ye)=>u({name:"detail",id:v,from:ye}),H;return i?H=p(N,{padded:true,children:p(h,{style:f.empty,testID:"permissions-browser-only",children:"This app runs in a plain browser. The browser keeps its own permissions. Buoy can't change them here. This tool works when the app runs on a phone with Capacitor."})}):a.name==="detail"&&l?H=p(Lo,{row:l,platform:ge,log:e.log,run:d,onPicked:y}):a.name==="other"?H=g(b,{children:[p(Ht,{rows:ne,platform:ge,onOpen:v=>Ue(v,"other")}),p(z,{children:"Your app can ask for these but hasn't yet."})]}):H=g(jt,{children:[_e.length>0?p(Ht,{rows:_e,platform:ge,onOpen:v=>Ue(v,"list"),onReload:n}):p(N,{padded:true,children:p(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."})}),ne.length>0?p(N,{children:g(x,{testID:"permissions-other",accessibilityRole:"button",accessibilityLabel:`Other Permissions, ${ne.length}`,activeOpacity:.6,onPress:()=>u({name:"other"}),style:f.row,children:[p(h,{style:f.rowTitle,children:"Other Permissions"}),g(b,{style:f.rowRight,children:[p(h,{style:f.rowValue,children:ne.length}),p(_t,{size:16,color:m.color.textTertiary})]})]})}):null,e.overriddenCount>0?p(N,{children:p(x,{testID:"permissions-reset",accessibilityRole:"button",accessibilityLabel:"Use Real Permissions",activeOpacity:.6,onPress:()=>d("resetAll"),style:f.row,children:p(h,{style:f.destructive,children:"Use Real Permissions"})})}):null]}),g(Pt,{style:f.fill,contentContainerStyle:[f.content,{paddingBottom:o.bottom}],testID:"permissions-scroll",children:[!L&&a.name!=="list"?g(x,{testID:"permissions-back",accessibilityRole:"button",accessibilityLabel:"Back",onPress:y,style:f.inlineBack,children:[p(Co,{size:18,color:m.color.accent}),p(h,{style:f.inlineBackText,children:a.name==="detail"&&a.from==="other"?"Other Permissions":"Permissions"}),C?p(h,{style:f.inlineTitle,children:C}):null]}):null,r?p(z,{tone:"danger",centered:true,children:p(h,{testID:"permissions-error",children:r})}):null,H]})}function Ht({rows:e,platform:t,onOpen:n,onReload:i}){let[,o]=ko(u=>u+1,0),r=Eo(),c=e.filter(u=>u.stale&&u.changedAt!==null&&r-u.changedAt<Me).map(u=>Me-(r-u.changedAt)),a=c.length>0?Math.min(...c):null;return Po(()=>{if(a===null)return;let u=setTimeout(o,a+50);return()=>clearTimeout(u)},[a]),p(N,{children:p($e,{children:e.map(u=>{let d=u.stale&&u.changedAt!==null&&r-u.changedAt>=Me;return g(b,{children:[p(Oo,{row:u,platform:t,onPress:()=>n(u.id)}),d?g(b,{style:f.stale,testID:`permissions-stale-${u.id}`,children:[p(h,{style:f.staleText,children:"The app hasn't checked again since this changed."}),i?p(x,{testID:`permissions-reload-${u.id}`,accessibilityRole:"button",accessibilityLabel:"Reload App",onPress:i,hitSlop:{top:8,bottom:8,left:8,right:8},children:p(h,{style:f.staleAction,children:"Reload App"})}):null]}):null]},u.id)})})})}function Oo({row:e,platform:t,onPress:n}){let i=e.override!==null,o=To(e,t),r=e.real?D(e.id,t,e.real):"Not Checked";return g(x,{testID:`permissions-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.label}: ${o}${i?`, simulated. Phone: ${r}`:""}`,activeOpacity:.6,onPress:n,style:f.row,children:[g(b,{style:f.rowLeft,children:[p(h,{style:f.rowTitle,children:e.label}),i?g(h,{style:f.rowSub,testID:`permissions-phone-${e.id}`,children:["Phone: ",r]}):null]}),g(b,{style:f.rowRight,children:[i?p(b,{style:f.dot}):null,p(h,{style:[f.rowValue,i?f.rowValueSimulated:null],testID:`permissions-value-${e.id}`,numberOfLines:1,children:o}),p(_t,{size:16,color:m.color.textTertiary})]})]})}function Ft({title:e,detail:t,selected:n,testID:i,onPress:o}){return g(x,{testID:i,accessibilityRole:"button",accessibilityLabel:`${e}. ${t}`,accessibilityState:{selected:n},activeOpacity:.6,onPress:o,style:f.option,children:[g(b,{style:f.optionText,children:[p(h,{style:f.rowTitle,children:e}),p(h,{style:f.optionDetail,children:t})]}),p(b,{style:f.check,children:n?p(xo,{size:18,color:m.color.accent}):null})]})}var No={check:"Checked",request:"Asked",settings:"Opened Settings",gated:"Needed it"};function Lo({row:e,platform:t,log:n,run:i,onPicked:o}){let r=e.real?D(e.id,t,e.real):null,c=d=>{d===null?i("clearOverride",{permission:e.id}):i("setOverride",{permission:e.id,state:d}),o()},a=n.filter(d=>d.permission===e.id).slice(0,8),u=e.canRequestReal&&e.real==="undetermined";return g(jt,{children:[g(b,{children:[p(Ut,{children:"What the app sees"}),p(N,{children:g($e,{children:[p(Ft,{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:()=>c(null)},"real"),e.states.map(d=>p(Ft,{title:D(e.id,t,d),detail:ln(e.id,t,d),selected:e.override===d,testID:`permissions-state-${e.id}-${d}`,onPress:()=>c(d)},d))]})})]}),u?g(b,{children:[p(N,{children:p(x,{testID:`permissions-request-real-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Show the real system prompt for ${e.label}`,activeOpacity:.6,onPress:()=>i("requestReal",{permission:e.id}),style:f.row,children:p(h,{style:f.action,children:"Show Real Prompt"})})}),p(z,{children:e.warning??"Asks the phone for real, so calls that need this permission work."})]}):e.warning?p(z,{tone:"warning",children:p(h,{testID:`permissions-warning-${e.id}`,children:e.warning})}):null,a.length>0?g(b,{children:[p(Ut,{children:"Recent"}),p(N,{children:p($e,{children:a.map(d=>p(qo,{entry:d,platform:t},d.id))})}),e.sources.length>0?g(z,{children:["Read through ",e.sources.join(", ")]}):null]}):null]})}function Do(e){let t=new Date(e),n=i=>String(i).padStart(2,"0");return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function qo({entry:e,platform:t}){let n=e.error?"Failed":e.returned&&e.permission?e.answer==="once"&&e.returned==="granted"?"Allowed Once":D(e.permission,t,e.returned):"";return g(b,{style:f.recentRow,testID:`permissions-log-${e.id}`,children:[p(h,{style:f.recentTime,children:Do(e.at)}),p(h,{style:f.recentVerb,numberOfLines:1,children:No[e.kind]}),p(h,{style:[f.recentResult,e.error?f.recentFailed:null],numberOfLines:1,children:n})]})}var f=ce.create({fill:{flex:1},content:{paddingHorizontal:m.gutter,paddingTop:12,gap:m.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},empty:{color:m.color.textSecondary,fontSize:m.font.body,lineHeight:20},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:50,paddingHorizontal:m.rowPadH,paddingVertical:10},rowLeft:{flexShrink:1,gap:2},rowTitle:{color:m.color.text,fontSize:m.font.row},rowSub:{color:m.color.textTertiary,fontSize:m.font.caption},rowRight:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},rowValue:{color:m.color.textSecondary,fontSize:m.font.row},rowValueSimulated:{color:m.color.accent},dot:{width:7,height:7,borderRadius:4,backgroundColor:m.color.accent},stale:{flexDirection:"row",alignItems:"center",flexWrap:"wrap",columnGap:10,rowGap:4,paddingHorizontal:m.rowPadH,paddingBottom:12,marginTop:-4},staleText:{color:m.color.textSecondary,fontSize:m.font.caption,flexShrink:1},staleAction:{color:m.color.accent,fontSize:m.font.caption,fontWeight:"600"},destructive:{color:m.color.danger,fontSize:m.font.row},action:{color:m.color.accent,fontSize:m.font.row},option:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:m.rowPadH,paddingVertical:11,minHeight:50},optionText:{flex:1,gap:2},optionDetail:{color:m.color.textTertiary,fontSize:m.font.caption,lineHeight:17},check:{width:20,alignItems:"center"},inlineBack:{flexDirection:"row",alignItems:"center",gap:4,marginBottom:-8},inlineBackText:{color:m.color.accent,fontSize:m.font.row},inlineTitle:{color:m.color.text,fontSize:m.font.row,fontWeight:"600",marginLeft:"auto"},recentRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:m.rowPadH,paddingVertical:10},recentTime:{color:m.color.textTertiary,fontSize:m.font.caption,fontVariant:["tabular-nums"]},recentVerb:{color:m.color.text,fontSize:m.font.body,flex:1},recentResult:{color:m.color.textSecondary,fontSize:m.font.body},recentFailed:{color:m.color.danger}});import{jsx as $o}from"react/jsx-runtime";var Mo=Mt.actions;async function Bo(e,t){let n=Mo[e];if(!n)throw new Error(`Unknown permissions action: ${e}`);return n(t)}function _o(){po("auto","buoy permissions").catch(()=>{})}function Vt(){let[e]=lo(()=>wt.OS==="web"&&!uo());ao(()=>{Ee(),Lt()},[]);let t=co(Z,w,w);return $o(zt,{snapshot:t,onAction:Bo,onReload:_o,browserOnly:e})}import{jsx as Uo}from"react/jsx-runtime";var Wt=so({id:"permissions",name:"PERMISSIONS",description:"Test denied, blocked, limited and not-asked permission states",slot:"both",color:oo,icon:({size:e,color:t})=>Uo(io,{size:e,color:t}),component:Vt,modal:{subtitle:"choose what the app is allowed to do"}}),jo=ro(Wt);import{PermissionsIcon as zo,PERMISSIONS_ICON_COLOR as Ho}from"@buoy-gg/shared-ui/web";var Fo=typeof navigator<"u"&&navigator.product==="ReactNative",Vo=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})();(Fo||Vo)&&typeof He<"u"&&He&&(Ee(),no());export{ve as KNOWN_PERMISSION_IDS,de as PERMISSIONS_CHIP_ID,Ho as PERMISSIONS_ICON_COLOR,re as PERMISSION_STATES,Vt as PermissionsBody,Ot as PermissionsChip,zo as PermissionsIcon,zt as PermissionsToolView,at as clearPermissionOverride,jo as createPermissionsTool,O as getPermissionOverride,w as getPermissionsSnapshot,Ee as installPermissions,Pn as isPermissionOverridden,Xi as openPermissionsChip,R as permissionInfo,Mt as permissionsSyncAdapter,Wt as permissionsToolPreset,Ce as resetPermissions,st as setPermissionOverride,D as stateLabel,Z as subscribePermissions,se as supportedStates,lt as updatePermissionSettings};
|
|
3
|
+
${Lt}`:Lt,d.map(O=>({text:O.label,style:O.answer==="deny"?"cancel":"default",onPress:()=>g(O.answer)})),{cancelable:r==="android",onDismiss:()=>g("deny")})}),i=qt.then(n,n);return qt=i.catch(()=>{}),i}}var fe="__buoyPermissionsInstalled";function ni(){re("App","appStateChange",{isActive:false}),re("App","pause",{}),setTimeout(()=>{re("App","resume",{}),re("App","appStateChange",{isActive:true})},60)}function He(){let e=An(),t=globalThis;if(!e)return ii(t);if(t[fe])return false;t[fe]=true,Re({platform:e,host:{isSimulator:null,deviceName:null,bundleId:null}}),bt(),wt(Mt(Rt));let n=globalThis.document?.title??null;return ze(n),Pn("App")&&vn("App","getInfo").then(i=>ze(i?.name??n)).catch(()=>{}),Kn()?(vt(({from:i})=>{i==="tool"&&L().notifyApp&&ni()}),Sn().then(i=>{i&&Re({platform:e,host:{isSimulator:i.isSimulator,deviceName:i.deviceName,bundleId:i.bundleId}})}),setTimeout(()=>{Gn()},1500),true):false}function ii(e){return e[fe]||typeof globalThis.document>"u"?false:(e[fe]=true,Re({platform:"android",host:{isSimulator:null,deviceName:null,bundleId:null}}),bt(),wt(Mt(Rt)),ze(globalThis.document?.title??null),Qn())}import{useEffect as oi,useSyncExternalStore as $t}from"react";var Ut={};bn(Ut,{AccessibilityInfo:()=>li,ActivityIndicator:()=>lo,Alert:()=>po,Animated:()=>ci,AppRegistry:()=>ui,AppState:()=>pi,Appearance:()=>di,BackHandler:()=>mi,Button:()=>co,CheckBox:()=>Ci,Clipboard:()=>fi,DeviceEventEmitter:()=>Fi,Dimensions:()=>hi,Easing:()=>gi,FlatList:()=>Ti,I18nManager:()=>yi,Image:()=>Oi,ImageBackground:()=>Ri,InteractionManager:()=>wi,Keyboard:()=>bi,KeyboardAvoidingView:()=>Ni,LayoutAnimation:()=>vi,Linking:()=>Ai,LogBox:()=>Hi,Modal:()=>so,NativeEventEmitter:()=>Pi,NativeModules:()=>ai,PanResponder:()=>Si,Picker:()=>Di,PixelRatio:()=>ki,Platform:()=>jt,Pressable:()=>ro,ProgressBar:()=>Li,RefreshControl:()=>qi,SafeAreaView:()=>Mi,ScrollView:()=>Ht,SectionList:()=>$i,Share:()=>xi,StatusBar:()=>Ui,StyleSheet:()=>he,Switch:()=>ao,Text:()=>h,TextInput:()=>no,Touchable:()=>ji,TouchableHighlight:()=>io,TouchableNativeFeedback:()=>Bi,TouchableOpacity:()=>I,TouchableWithoutFeedback:()=>oo,UIManager:()=>Ei,Vibration:()=>Ii,View:()=>b,VirtualizedList:()=>_i,YellowBox:()=>zi,findNodeHandle:()=>uo,unstable_createElement:()=>si,useColorScheme:()=>Vi,useLocaleContext:()=>Wi,useWindowDimensions:()=>Ki});wn(Ut,ri);import*as ri from"react-native-web";import{unstable_createElement as si,NativeModules as ai,AccessibilityInfo as li,Animated as ci,Appearance as di,AppRegistry as ui,AppState as pi,BackHandler as mi,Clipboard as fi,Dimensions as hi,Easing as gi,I18nManager as yi,Keyboard as bi,InteractionManager as wi,LayoutAnimation as vi,Linking as Ai,NativeEventEmitter as Pi,PanResponder as Si,PixelRatio as ki,Platform as jt,Share as xi,StyleSheet as he,UIManager as Ei,Vibration as Ii,CheckBox as Ci,FlatList as Ti,Image as Oi,ImageBackground as Ri,KeyboardAvoidingView as Ni,Picker as Di,ProgressBar as Li,RefreshControl as qi,SafeAreaView as Mi,SectionList as $i,StatusBar as Ui,Touchable as ji,TouchableNativeFeedback as Bi,VirtualizedList as _i,YellowBox as zi,LogBox as Hi,DeviceEventEmitter as Fi,useColorScheme as Vi,useLocaleContext as Wi,useWindowDimensions as Ki}from"react-native-web";import*as k from"react-native-web";import{createElement as Fe,forwardRef as Bt,useCallback as Gi,useRef as Yi}from"react";import{useEffect as Ji,useState as Zi}from"react";import{createPortal as Xi}from"react-dom";var Qi='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as eo}from"react/jsx-runtime";var te=Symbol.for("@buoy-gg/portal-host"),_t=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function zt(){let e=document;if(e[te])return e[te].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Qi});let n=()=>{let c=document.fullscreenElement,g=c&&c.tagName!=="CANVAS"?c:document.body;t.parentElement!==g&&g.appendChild(t)},i=new Map,o=c=>{(!t.contains(c.target)||!_t(c.target))&&i.set(c.code||c.key,{key:c.key,code:c.code,location:c.location,keyCode:c.keyCode,which:c.which,altKey:c.altKey,ctrlKey:c.ctrlKey,metaKey:c.metaKey,shiftKey:c.shiftKey})},r=c=>{i.delete(c.code||c.key)},s=()=>i.clear(),a=()=>{let c=[...i.values()];i.clear();for(let g of c)document.dispatchEvent(new KeyboardEvent("keyup",{...g,bubbles:true}))},u=c=>{_t(c.target)&&c.stopPropagation()},d=c=>c.stopPropagation();return n(),document.addEventListener("fullscreenchange",n),document.addEventListener("keydown",o,true),document.addEventListener("keyup",r,true),window.addEventListener("blur",s),t.addEventListener("focusin",a),t.addEventListener("keydown",u),t.addEventListener("keyup",u),t.addEventListener("keypress",u),t.addEventListener("wheel",d,{passive:true}),e[te]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",n),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",r,true),window.removeEventListener("blur",s),t.remove(),delete e[te]}},t}function to({children:e}){let[t,n]=Zi(null);return Ji(()=>{let i=zt(),o=document[te];return o.users++,n(i),()=>{--o.users===0&&o.dispose()}},[]),t?Xi(eo("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function E(e){let t=Bt((i,o)=>{let{accessibilityState:r,accessibilityValue:s,...a}=i;for(let u of["busy","checked","disabled","expanded","selected"])r?.[u]!==void 0&&a[`aria-${u}`]===void 0&&(a[`aria-${u}`]=r[u]);for(let[u,d]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[u]!==void 0&&a[`aria-${d}`]===void 0&&(a[`aria-${d}`]=s[u]);return Fe(e,{...a,ref:o})}),n=e.State;return n&&Object.assign(t,{State:n}),t.displayName=e.displayName??e.name??"NativeWebView",t}var b=E(k.View),h=E(k.Text),no=E(k.TextInput),I=E(k.TouchableOpacity),io=E(k.TouchableHighlight),oo=E(k.TouchableWithoutFeedback),ro=E(k.Pressable),Ht=E(k.ScrollView),Ft=Bt((e,t)=>{let n=Yi(null),i=Gi(o=>{if(o){let r=o;for(;r.parentElement&&r.parentElement!==document.body;)r=r.parentElement;r.parentElement===document.body&&(n.current=r,Object.assign(r.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),zt().appendChild(r))}else n.current&&(document.body.appendChild(n.current),n.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return Fe(to,null,Fe(k.Modal,{...e,ref:i}))});Ft.displayName="Modal";var so=E(Ft),ao=E(k.Switch),lo=E(k.ActivityIndicator),co=E(k.Button),uo=k.findNodeHandle,po={alert(e,t,n,i){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.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",o.appendChild(r),t){let d=document.createElement("p");d.textContent=t,d.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(d)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let a=n?.length?n:[{text:"OK"}],u=()=>{o.close?.(),o.remove()};for(let d of a){let c=document.createElement("button");c.type="button",c.textContent=d.text??"OK",c.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${d.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,c.onclick=()=>{u(),d.onPress?.()},s.appendChild(c)}o.addEventListener("cancel",d=>{d.preventDefault(),i?.cancelable!==false&&(u(),i?.onDismiss?.())}),o.appendChild(s),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{FloatingTool as Vt,PermissionsIcon as Wt,X as mo,dismissFloatingTool as fo,getFloatingTools as ho,night as ne,openBuoyTool as go,openFloatingTool as Kt}from"@buoy-gg/shared-ui/web";import{jsx as x,jsxs as Ve}from"react/jsx-runtime";var ge="permissions-chip",yo=8e3,Gt={id:ge,render:e=>x(Zt,{...e})},bo=()=>ho().some(e=>e.id===ge);function wo(){Kt(Gt)}var _=null,We=new Set,ye=()=>{};function be(e){_&&clearTimeout(_.timer),_=e;for(let t of Array.from(We))t();ye()}function vo(e){return We.add(e),()=>{We.delete(e)}}var Yt=()=>_;function Ao(){be({overrides:zn(),timer:setTimeout(()=>be(null),yo)}),De()}function Po(){let e=_;e&&(be(null),Hn(e.overrides))}var Jt=false;function So(){if(Jt)return;Jt=true;let e=false;ye=()=>{let t=(_n()||_!==null)&&L().showChip;t&&!e?Kt(Gt):!t&&bo()&&fo(ge),e=t},X(ye),ye()}function Zt({id:e,revealToken:t}){let n=$t(X,v,v),i=$t(vo,Yt,Yt);oi(()=>{i&&n.overriddenCount>0&&be(null)},[i,n.overriddenCount]);let o=n.permissions.filter(a=>a.override!==null),r=o.length===1?o[0]:null,s=r?`${r.label}: ${r.once&&r.override==="granted"?"Allowed Once":$(r.id,n.platform,r.override)}`:`${o.length} permissions simulated`;return i&&o.length===0?x(Vt,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:"Move or hide the permissions strip",handleAdornment:x(Wt,{size:12}),children:Ve(b,{style:T.row,children:[x(h,{style:T.title,numberOfLines:1,testID:"permissions-chip-summary",children:"Real permissions"}),x(I,{testID:"permissions-chip-undo",accessibilityRole:"button",accessibilityLabel:"Undo, put the simulated permissions back",onPress:Po,style:T.undo,hitSlop:{top:8,bottom:8,left:8,right:8},children:x(h,{style:T.undoText,children:"Undo"})})]})}):x(Vt,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the permissions strip. ${s}`,handleAdornment:x(Wt,{size:12}),children:Ve(b,{style:T.row,children:[Ve(I,{testID:"permissions-chip-open",accessibilityRole:"button",accessibilityLabel:`${s}. Open Permissions`,onPress:()=>{go("permissions")},style:T.open,children:[x(b,{style:T.dot}),x(h,{style:T.title,numberOfLines:1,testID:"permissions-chip-summary",children:s})]}),x(b,{style:T.separator}),x(I,{testID:"permissions-chip-reset",accessibilityRole:"button",accessibilityLabel:"Use real permissions",onPress:Ao,style:T.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:x(mo,{size:16,color:ne.color.textSecondary})})]})})}var T=he.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:ne.color.accent},title:{color:ne.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:ne.color.accent,fontSize:14,fontWeight:"600"},separator:{width:he.hairlineWidth,height:20,backgroundColor:ne.color.separator}});import{PermissionsIcon as ko,PERMISSIONS_ICON_COLOR as xo,createToolFactory as Eo,defineToolPreset as Io}from"@buoy-gg/shared-ui/web";import{useEffect as Co,useState as To,useSyncExternalStore as Oo}from"react";import{capacitorPlatform as Ro}from"@buoy-gg/license/web";import{reloadApp as No}from"@buoy-gg/shared-ui/web";var Ke={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"}},Do=[{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",...Ke},{method:"getLastKnownPositionAsync",permission:"location",...Ke},{method:"watchPositionImplAsync",permission:"location",...Ke},{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 Lo(){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 Mo(e,t=[]){return e.flavor!=="privileges"?[]:t.length>0?t.slice(0,1):[false]}async function Qt(){let e=Lo();if(!e)return;let t=qo(e),n=Z(),i=[];for(let o of Do){if(!t.has(o.module))continue;let r=e[o.module];if(!r)continue;let s=new Set;for(let a of o.permissions){if(s.has(a.permission))continue;let u=r[a.get],d=u?.__buoyPermissionsOriginal??u;typeof d=="function"&&(s.add(a.permission),i.push(Promise.resolve().then(()=>d.apply(r,Mo(a))).then(c=>q(a.permission,On(c,n),o.library)).catch(()=>{})))}}await Promise.all(i)}import{createSyncAdapter as $o}from"@buoy-gg/shared-ui/web";import{BUOY_SYNTHETIC_MARK as Uo}from"@buoy-gg/shared-ui/web";var en=null;function Ge(e){try{en?.emit("appStateDidChange",{app_state:e,[Uo]:true})}catch{}}function jo(){Z()==="ios"&&Ge("inactive"),Ge("background")}function Bo(){Ge("active")}var we=null,tn=false,nn=null;function _o(){return tn}function ve(){return nn?(nn(),true):false}function zo(){!en||tn||(we&&clearTimeout(we),we=setTimeout(()=>{we=null,jo(),setTimeout(Bo,60)},120))}function Ae(e){return e&&typeof e=="object"?e:{}}function Ye(e){return e.permission??e.id??e.permissionId??e.name}function ie(e,t){let n=e[t];if(typeof n=="boolean")return n;if(n==="true")return true;if(n==="false")return false}var on=$o({version:1,getSnapshot(){return v()},subscribe(e){return X(e)},actions:{async getState(){return await Qt(),_o()?{...v(),settingsStandInOpen:true}:v()},setOverride(e){let t=Ae(e),n=Ye(t),i=t.state??t.status??t.value;if(n===void 0||i===void 0)throw new Error('setOverride needs `permission` (e.g. "location", "camera", "notifications") and `state` ("undetermined", "granted", "limited", "denied", "blocked" or "restricted").');return ve(),Pt(n,i)},clearOverride(e){let t=Ye(Ae(e));if(t===void 0)throw new Error("clearOverride needs `permission`.");return ve(),St(t)},requestReal(e){let t=Ye(Ae(e));if(t===void 0)throw new Error("requestReal needs `permission`.");return jn(t)},resetAll(){return ve(),De()},updateSettings(e){let t=Ae(e);return kt({requestAnswer:t.requestAnswer??t.answer,persist:ie(t,"persist"),showChip:ie(t,"showChip"),notifyApp:ie(t,"notifyApp"),enforce:ie(t,"enforce"),interceptSettings:ie(t,"interceptSettings")})},clearLog(){return Fn()},simulateReturnFromSettings(){return ve()||zo(),v()}}});import{useEffect as Ho,useReducer as Fo,useState as rn}from"react";import{Check as Vo,ChevronLeft as Wo,ChevronRight as sn,NightCard as M,NightFootnote as z,NightRows as Je,NightSectionLabel as an,night as m,useSafeAreaInsets as Ko,useToolScreenHeader as Go}from"@buoy-gg/shared-ui/web";import{Fragment as ln,jsx as p,jsxs as y}from"react/jsx-runtime";var Ze=1500,Yo=()=>{let e=globalThis.__buoyRealNow;return typeof e=="function"?e():Date.now()};function Jo(e,t){return e.effective?e.once&&e.effective==="granted"?"Allowed Once":$(e.id,t,e.effective):"Not Checked"}function cn({snapshot:e,onAction:t,onReload:n,browserOnly:i}){let o=Ko({minBottom:16}),[r,s]=rn(null),[a,u]=rn({name:"list"}),d=(A,Pe)=>{s(null),t(A,Pe).catch(Se=>{s(Se instanceof Error?Se.message:String(Se))})},c=a.name==="detail"?e?.permissions.find(A=>A.id===a.id):void 0,g=()=>u(a.name==="detail"&&a.from==="other"?{name:"other"}:{name:"list"}),P=a.name==="other"?"Other Permissions":c?c.label:null,O=Go(P?{title:P,onBack:g,searchable:false}:null,[P,a.name,a.name==="detail"?a.from:null]);if(!e)return p(b,{style:f.waiting,testID:"permissions-waiting",children:p(z,{centered:true,children:"Waiting for the app\u2026"})});let{platform:H,permissions:Xe}=e,Qe=Xe.filter(A=>A.calls>0||A.override!==null),oe=Xe.filter(A=>!(A.calls>0||A.override!==null)),et=(A,Pe)=>u({name:"detail",id:A,from:Pe}),F;return i?F=p(M,{padded:true,children:p(h,{style:f.empty,testID:"permissions-browser-only",children:"This app runs in a plain browser. The browser keeps its own permissions. Buoy can't change them here. This tool works when the app runs on a phone with Capacitor."})}):a.name==="detail"&&c?F=p(Qo,{row:c,platform:H,log:e.log,run:d,onPicked:g}):a.name==="other"?F=y(b,{children:[p(dn,{rows:oe,platform:H,onOpen:A=>et(A,"other")}),p(z,{children:"Your app can ask for these but hasn't yet."})]}):F=y(ln,{children:[Qe.length>0?p(dn,{rows:Qe,platform:H,onOpen:A=>et(A,"list"),onReload:n}):p(M,{padded:true,children:p(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."})}),oe.length>0?p(M,{children:y(I,{testID:"permissions-other",accessibilityRole:"button",accessibilityLabel:`Other Permissions, ${oe.length}`,activeOpacity:.6,onPress:()=>u({name:"other"}),style:f.row,children:[p(h,{style:f.rowTitle,children:"Other Permissions"}),y(b,{style:f.rowRight,children:[p(h,{style:f.rowValue,children:oe.length}),p(sn,{size:16,color:m.color.textTertiary})]})]})}):null,e.overriddenCount>0?p(M,{children:p(I,{testID:"permissions-reset",accessibilityRole:"button",accessibilityLabel:"Use Real Permissions",activeOpacity:.6,onPress:()=>d("resetAll"),style:f.row,children:p(h,{style:f.destructive,children:"Use Real Permissions"})})}):null]}),y(Ht,{style:f.fill,contentContainerStyle:[f.content,{paddingBottom:o.bottom}],testID:"permissions-scroll",children:[!O&&a.name!=="list"?y(I,{testID:"permissions-back",accessibilityRole:"button",accessibilityLabel:"Back",onPress:g,style:f.inlineBack,children:[p(Wo,{size:18,color:m.color.accent}),p(h,{style:f.inlineBackText,children:a.name==="detail"&&a.from==="other"?"Other Permissions":"Permissions"}),P?p(h,{style:f.inlineTitle,children:P}):null]}):null,r?p(z,{tone:"danger",centered:true,children:p(h,{testID:"permissions-error",children:r})}):null,F]})}function dn({rows:e,platform:t,onOpen:n,onReload:i}){let[,o]=Fo(u=>u+1,0),r=Yo(),s=e.filter(u=>u.stale&&u.changedAt!==null&&r-u.changedAt<Ze).map(u=>Ze-(r-u.changedAt)),a=s.length>0?Math.min(...s):null;return Ho(()=>{if(a===null)return;let u=setTimeout(o,a+50);return()=>clearTimeout(u)},[a]),p(M,{children:p(Je,{children:e.map(u=>{let d=u.stale&&u.changedAt!==null&&r-u.changedAt>=Ze;return y(b,{children:[p(Zo,{row:u,platform:t,onPress:()=>n(u.id)}),d?y(b,{style:f.stale,testID:`permissions-stale-${u.id}`,children:[p(h,{style:f.staleText,children:"The app hasn't checked again since this changed."}),i?p(I,{testID:`permissions-reload-${u.id}`,accessibilityRole:"button",accessibilityLabel:"Reload App",onPress:i,hitSlop:{top:8,bottom:8,left:8,right:8},children:p(h,{style:f.staleAction,children:"Reload App"})}):null]}):null]},u.id)})})})}function Zo({row:e,platform:t,onPress:n}){let i=e.override!==null,o=Jo(e,t),r=e.real?$(e.id,t,e.real):"Not Checked";return y(I,{testID:`permissions-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.label}: ${o}${i?`, simulated. Phone: ${r}`:""}`,activeOpacity:.6,onPress:n,style:f.row,children:[y(b,{style:f.rowLeft,children:[p(h,{style:f.rowTitle,children:e.label}),i?y(h,{style:f.rowSub,testID:`permissions-phone-${e.id}`,children:["Phone: ",r]}):null]}),y(b,{style:f.rowRight,children:[i?p(b,{style:f.dot}):null,p(h,{style:[f.rowValue,i?f.rowValueSimulated:null],testID:`permissions-value-${e.id}`,numberOfLines:1,children:o}),p(sn,{size:16,color:m.color.textTertiary})]})]})}function un({title:e,detail:t,selected:n,testID:i,onPress:o}){return y(I,{testID:i,accessibilityRole:"button",accessibilityLabel:`${e}. ${t}`,accessibilityState:{selected:n},activeOpacity:.6,onPress:o,style:f.option,children:[y(b,{style:f.optionText,children:[p(h,{style:f.rowTitle,children:e}),p(h,{style:f.optionDetail,children:t})]}),p(b,{style:f.check,children:n?p(Vo,{size:18,color:m.color.accent}):null})]})}var Xo={check:"Checked",request:"Asked",settings:"Opened Settings",gated:"Needed it"};function Qo({row:e,platform:t,log:n,run:i,onPicked:o}){let r=e.real?$(e.id,t,e.real):null,s=d=>{d===null?i("clearOverride",{permission:e.id}):i("setOverride",{permission:e.id,state:d}),o()},a=n.filter(d=>d.permission===e.id).slice(0,8),u=e.canRequestReal&&e.real==="undetermined";return y(ln,{children:[y(b,{children:[p(an,{children:"What the app sees"}),p(M,{children:y(Je,{children:[p(un,{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:()=>s(null)},"real"),e.states.map(d=>p(un,{title:$(e.id,t,d),detail:Tn(e.id,t,d),selected:e.override===d,testID:`permissions-state-${e.id}-${d}`,onPress:()=>s(d)},d))]})})]}),u?y(b,{children:[p(M,{children:p(I,{testID:`permissions-request-real-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Show the real system prompt for ${e.label}`,activeOpacity:.6,onPress:()=>i("requestReal",{permission:e.id}),style:f.row,children:p(h,{style:f.action,children:"Show Real Prompt"})})}),p(z,{children:e.warning??"Asks the phone for real, so calls that need this permission work."})]}):e.warning?p(z,{tone:"warning",children:p(h,{testID:`permissions-warning-${e.id}`,children:e.warning})}):null,a.length>0?y(b,{children:[p(an,{children:"Recent"}),p(M,{children:p(Je,{children:a.map(d=>p(tr,{entry:d,platform:t},d.id))})}),e.sources.length>0?y(z,{children:["Read through ",e.sources.join(", ")]}):null]}):null]})}function er(e){let t=new Date(e),n=i=>String(i).padStart(2,"0");return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function tr({entry:e,platform:t}){let n=e.error?"Failed":e.returned&&e.permission?e.answer==="once"&&e.returned==="granted"?"Allowed Once":$(e.permission,t,e.returned):"";return y(b,{style:f.recentRow,testID:`permissions-log-${e.id}`,children:[p(h,{style:f.recentTime,children:er(e.at)}),p(h,{style:f.recentVerb,numberOfLines:1,children:Xo[e.kind]}),p(h,{style:[f.recentResult,e.error?f.recentFailed:null],numberOfLines:1,children:n})]})}var f=he.create({fill:{flex:1},content:{paddingHorizontal:m.gutter,paddingTop:12,gap:m.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},empty:{color:m.color.textSecondary,fontSize:m.font.body,lineHeight:20},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:50,paddingHorizontal:m.rowPadH,paddingVertical:10},rowLeft:{flexShrink:1,gap:2},rowTitle:{color:m.color.text,fontSize:m.font.row},rowSub:{color:m.color.textTertiary,fontSize:m.font.caption},rowRight:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},rowValue:{color:m.color.textSecondary,fontSize:m.font.row},rowValueSimulated:{color:m.color.accent},dot:{width:7,height:7,borderRadius:4,backgroundColor:m.color.accent},stale:{flexDirection:"row",alignItems:"center",flexWrap:"wrap",columnGap:10,rowGap:4,paddingHorizontal:m.rowPadH,paddingBottom:12,marginTop:-4},staleText:{color:m.color.textSecondary,fontSize:m.font.caption,flexShrink:1},staleAction:{color:m.color.accent,fontSize:m.font.caption,fontWeight:"600"},destructive:{color:m.color.danger,fontSize:m.font.row},action:{color:m.color.accent,fontSize:m.font.row},option:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:m.rowPadH,paddingVertical:11,minHeight:50},optionText:{flex:1,gap:2},optionDetail:{color:m.color.textTertiary,fontSize:m.font.caption,lineHeight:17},check:{width:20,alignItems:"center"},inlineBack:{flexDirection:"row",alignItems:"center",gap:4,marginBottom:-8},inlineBackText:{color:m.color.accent,fontSize:m.font.row},inlineTitle:{color:m.color.text,fontSize:m.font.row,fontWeight:"600",marginLeft:"auto"},recentRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:m.rowPadH,paddingVertical:10},recentTime:{color:m.color.textTertiary,fontSize:m.font.caption,fontVariant:["tabular-nums"]},recentVerb:{color:m.color.text,fontSize:m.font.body,flex:1},recentResult:{color:m.color.textSecondary,fontSize:m.font.body},recentFailed:{color:m.color.danger}});import{jsx as nr}from"react/jsx-runtime";var ir=on.actions;async function or(e,t){let n=ir[e];if(!n)throw new Error(`Unknown permissions action: ${e}`);return n(t)}function rr(){No("auto","buoy permissions").catch(()=>{})}function pn(){let[e]=To(()=>jt.OS==="web"&&!Ro());Co(()=>{He(),Qt()},[]);let t=Oo(X,v,v);return nr(cn,{snapshot:t,onAction:or,onReload:rr,browserOnly:e})}import{jsx as sr}from"react/jsx-runtime";var mn=Io({id:"permissions",name:"PERMISSIONS",description:"Test denied, blocked, limited and not-asked permission states",slot:"both",color:xo,icon:({size:e,color:t})=>sr(ko,{size:e,color:t}),component:pn,modal:{subtitle:"choose what the app is allowed to do"}}),ar=Eo(mn);import{PermissionsIcon as lr,PERMISSIONS_ICON_COLOR as cr}from"@buoy-gg/shared-ui/web";var fn=typeof navigator<"u"&&navigator.product==="ReactNative",dr=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})(),ur=!fn&&typeof globalThis.document<"u";(fn||dr||ur)&&typeof it<"u"&&it&&(He(),So());export{Ee as KNOWN_PERMISSION_IDS,ge as PERMISSIONS_CHIP_ID,cr as PERMISSIONS_ICON_COLOR,ae as PERMISSION_STATES,pn as PermissionsBody,Zt as PermissionsChip,lr as PermissionsIcon,cn as PermissionsToolView,St as clearPermissionOverride,ar as createPermissionsTool,w as getPermissionOverride,v as getPermissionsSnapshot,He as installPermissions,Bn as isPermissionOverridden,wo as openPermissionsChip,R as permissionInfo,on as permissionsSyncAdapter,mn as permissionsToolPreset,De as resetPermissions,Pt as setPermissionOverride,$ as stateLabel,X as subscribePermissions,le as supportedStates,kt 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.71",
|
|
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,17 +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.71"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@buoy-gg/license": "7.0.
|
|
23
|
+
"@buoy-gg/license": "7.0.71",
|
|
24
24
|
"react": "*"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/react": "^19.1.0",
|
|
28
28
|
"@types/react-native": "^0.73.0",
|
|
29
29
|
"typescript": "~5.8.3",
|
|
30
|
-
"@buoy-gg/license": "^7.0.
|
|
30
|
+
"@buoy-gg/license": "^7.0.71"
|
|
31
31
|
},
|
|
32
32
|
"react-native-builder-bob": {
|
|
33
33
|
"source": "src",
|