@webority/mobile-core 0.0.29 → 0.2.0

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.
Files changed (242) hide show
  1. package/README.md +32 -0
  2. package/lib/commonjs/api/baseUrl.js +1 -34
  3. package/lib/commonjs/api/clientHeaders.js +1 -0
  4. package/lib/commonjs/api/curl.js +1 -109
  5. package/lib/commonjs/api/minAppVersion.js +1 -0
  6. package/lib/commonjs/api/multipart.js +1 -21
  7. package/lib/commonjs/api/publicClient.js +1 -79
  8. package/lib/commonjs/api/requestDefaults.js +1 -0
  9. package/lib/commonjs/api/responseBodyText.js +1 -0
  10. package/lib/commonjs/api/retry.js +1 -91
  11. package/lib/commonjs/api/tokenRefresh.js +1 -205
  12. package/lib/commonjs/api/userClient.js +1 -265
  13. package/lib/commonjs/auth/authStore.js +1 -265
  14. package/lib/commonjs/auth/index.js +1 -44
  15. package/lib/commonjs/auth/jwt.js +1 -112
  16. package/lib/commonjs/config/index.js +1 -72
  17. package/lib/commonjs/deepLink/index.js +1 -286
  18. package/lib/commonjs/download/adapters/expoFs.js +1 -69
  19. package/lib/commonjs/download/adapters/shared.js +1 -13
  20. package/lib/commonjs/download/index.js +1 -250
  21. package/lib/commonjs/errors/extractApiError.js +1 -0
  22. package/lib/commonjs/errors/index.js +1 -0
  23. package/lib/commonjs/formatters/currency.js +1 -70
  24. package/lib/commonjs/formatters/date.js +1 -167
  25. package/lib/commonjs/formatters/dateMath.js +1 -311
  26. package/lib/commonjs/formatters/formatConfig.js +1 -0
  27. package/lib/commonjs/formatters/house.js +1 -0
  28. package/lib/commonjs/formatters/index.js +1 -246
  29. package/lib/commonjs/formatters/initials.js +1 -32
  30. package/lib/commonjs/formatters/intlCache.js +1 -37
  31. package/lib/commonjs/formatters/number.js +1 -89
  32. package/lib/commonjs/formatters/phone.js +1 -369
  33. package/lib/commonjs/formatters/windowsToIanaTable.js +1 -164
  34. package/lib/commonjs/geolocation/adapters/expoLocation.js +1 -126
  35. package/lib/commonjs/geolocation/index.js +1 -355
  36. package/lib/commonjs/index.js +1 -644
  37. package/lib/commonjs/initSDK.js +1 -66
  38. package/lib/commonjs/initUserAuth.js +1 -37
  39. package/lib/commonjs/logger/crashlytics.js +1 -0
  40. package/lib/commonjs/logger/index.js +1 -301
  41. package/lib/commonjs/logger/redact.js +1 -50
  42. package/lib/commonjs/network/index.js +1 -31
  43. package/lib/commonjs/network/networkStatus.js +1 -171
  44. package/lib/commonjs/permissions/calendar.js +1 -14
  45. package/lib/commonjs/permissions/camera.js +1 -14
  46. package/lib/commonjs/permissions/contacts.js +1 -10
  47. package/lib/commonjs/permissions/index.js +1 -133
  48. package/lib/commonjs/permissions/location.js +1 -14
  49. package/lib/commonjs/permissions/mediaLibrary.js +1 -10
  50. package/lib/commonjs/permissions/notifications.js +1 -10
  51. package/lib/commonjs/permissions/photos.js +1 -14
  52. package/lib/commonjs/phone/countries.js +1 -265
  53. package/lib/commonjs/push/index.js +1 -61
  54. package/lib/commonjs/push/push.js +1 -468
  55. package/lib/commonjs/push/status.js +1 -0
  56. package/lib/commonjs/push/task.js +1 -43
  57. package/lib/commonjs/query/apiBaseQuery.js +1 -0
  58. package/lib/commonjs/query/createAppApi.js +1 -0
  59. package/lib/commonjs/query/index.js +1 -0
  60. package/lib/commonjs/query/listeners.js +1 -0
  61. package/lib/commonjs/query/paging.js +1 -0
  62. package/lib/commonjs/query/tags.js +1 -0
  63. package/lib/commonjs/redux/errorToastMiddleware.js +1 -0
  64. package/lib/commonjs/redux/index.js +1 -0
  65. package/lib/commonjs/redux/rootReducer.js +1 -0
  66. package/lib/commonjs/redux/serializableCheck.js +1 -0
  67. package/lib/commonjs/secureScreen/index.js +1 -0
  68. package/lib/commonjs/share/index.js +1 -70
  69. package/lib/commonjs/smsRetriever/index.js +1 -91
  70. package/lib/commonjs/specs/NativeSmsRetriever.js +1 -15
  71. package/lib/commonjs/sqlite/adapters/expo.js +1 -53
  72. package/lib/commonjs/sqlite/index.js +1 -604
  73. package/lib/commonjs/storage/index.js +1 -214
  74. package/lib/commonjs/types/axios.js +1 -4
  75. package/lib/commonjs/types/globals.d.js +1 -6
  76. package/lib/commonjs/utils/base64.js +1 -24
  77. package/lib/commonjs/utils/imageCompression.js +1 -389
  78. package/lib/commonjs/utils/index.js +1 -19
  79. package/lib/commonjs/validators/index.js +1 -227
  80. package/lib/commonjs/versionCheck/buildNumber.js +1 -0
  81. package/lib/commonjs/versionCheck/index.js +1 -419
  82. package/lib/module/api/baseUrl.js +1 -30
  83. package/lib/module/api/clientHeaders.js +1 -0
  84. package/lib/module/api/curl.js +1 -104
  85. package/lib/module/api/minAppVersion.js +1 -0
  86. package/lib/module/api/multipart.js +1 -16
  87. package/lib/module/api/publicClient.js +1 -75
  88. package/lib/module/api/requestDefaults.js +1 -0
  89. package/lib/module/api/responseBodyText.js +1 -0
  90. package/lib/module/api/retry.js +1 -85
  91. package/lib/module/api/tokenRefresh.js +1 -192
  92. package/lib/module/api/userClient.js +1 -243
  93. package/lib/module/auth/authStore.js +1 -257
  94. package/lib/module/auth/index.js +1 -5
  95. package/lib/module/auth/jwt.js +1 -106
  96. package/lib/module/config/index.js +1 -64
  97. package/lib/module/deepLink/index.js +1 -280
  98. package/lib/module/download/adapters/expoFs.js +1 -64
  99. package/lib/module/download/adapters/shared.js +1 -8
  100. package/lib/module/download/index.js +1 -242
  101. package/lib/module/errors/extractApiError.js +1 -0
  102. package/lib/module/errors/index.js +1 -0
  103. package/lib/module/formatters/currency.js +1 -65
  104. package/lib/module/formatters/date.js +1 -159
  105. package/lib/module/formatters/dateMath.js +1 -295
  106. package/lib/module/formatters/formatConfig.js +1 -0
  107. package/lib/module/formatters/house.js +1 -0
  108. package/lib/module/formatters/index.js +1 -9
  109. package/lib/module/formatters/initials.js +1 -27
  110. package/lib/module/formatters/intlCache.js +1 -30
  111. package/lib/module/formatters/number.js +1 -82
  112. package/lib/module/formatters/phone.js +1 -302
  113. package/lib/module/formatters/windowsToIanaTable.js +1 -160
  114. package/lib/module/geolocation/adapters/expoLocation.js +1 -121
  115. package/lib/module/geolocation/index.js +1 -347
  116. package/lib/module/index.js +1 -57
  117. package/lib/module/initSDK.js +1 -61
  118. package/lib/module/initUserAuth.js +1 -33
  119. package/lib/module/logger/crashlytics.js +1 -0
  120. package/lib/module/logger/index.js +1 -295
  121. package/lib/module/logger/redact.js +1 -44
  122. package/lib/module/network/index.js +1 -4
  123. package/lib/module/network/networkStatus.js +1 -161
  124. package/lib/module/permissions/calendar.js +1 -15
  125. package/lib/module/permissions/camera.js +1 -15
  126. package/lib/module/permissions/contacts.js +1 -11
  127. package/lib/module/permissions/index.js +1 -128
  128. package/lib/module/permissions/location.js +1 -15
  129. package/lib/module/permissions/mediaLibrary.js +1 -11
  130. package/lib/module/permissions/notifications.js +1 -11
  131. package/lib/module/permissions/photos.js +1 -15
  132. package/lib/module/phone/countries.js +1 -261
  133. package/lib/module/push/index.js +1 -4
  134. package/lib/module/push/push.js +1 -452
  135. package/lib/module/push/status.js +1 -0
  136. package/lib/module/push/task.js +1 -38
  137. package/lib/module/query/apiBaseQuery.js +1 -0
  138. package/lib/module/query/createAppApi.js +1 -0
  139. package/lib/module/query/index.js +1 -0
  140. package/lib/module/query/listeners.js +1 -0
  141. package/lib/module/query/paging.js +1 -0
  142. package/lib/module/query/tags.js +1 -0
  143. package/lib/module/redux/errorToastMiddleware.js +1 -0
  144. package/lib/module/redux/index.js +1 -0
  145. package/lib/module/redux/rootReducer.js +1 -0
  146. package/lib/module/redux/serializableCheck.js +1 -0
  147. package/lib/module/secureScreen/index.js +1 -0
  148. package/lib/module/share/index.js +1 -64
  149. package/lib/module/smsRetriever/index.js +1 -86
  150. package/lib/module/specs/NativeSmsRetriever.js +1 -13
  151. package/lib/module/sqlite/adapters/expo.js +1 -48
  152. package/lib/module/sqlite/index.js +1 -594
  153. package/lib/module/storage/index.js +1 -208
  154. package/lib/module/types/axios.js +1 -4
  155. package/lib/module/types/globals.d.js +1 -10
  156. package/lib/module/utils/base64.js +1 -19
  157. package/lib/module/utils/imageCompression.js +1 -383
  158. package/lib/module/utils/index.js +1 -4
  159. package/lib/module/validators/index.js +1 -205
  160. package/lib/module/versionCheck/buildNumber.js +1 -0
  161. package/lib/module/versionCheck/index.js +1 -413
  162. package/lib/typescript/commonjs/api/clientHeaders.d.ts +25 -0
  163. package/lib/typescript/commonjs/api/minAppVersion.d.ts +24 -0
  164. package/lib/typescript/commonjs/api/requestDefaults.d.ts +21 -0
  165. package/lib/typescript/commonjs/api/responseBodyText.d.ts +6 -0
  166. package/lib/typescript/commonjs/api/retry.d.ts +23 -9
  167. package/lib/typescript/commonjs/api/tokenRefresh.d.ts +14 -2
  168. package/lib/typescript/commonjs/api/userClient.d.ts +1 -1
  169. package/lib/typescript/commonjs/auth/authStore.d.ts +76 -0
  170. package/lib/typescript/commonjs/auth/index.d.ts +2 -2
  171. package/lib/typescript/commonjs/config/index.d.ts +31 -2
  172. package/lib/typescript/commonjs/errors/extractApiError.d.ts +69 -0
  173. package/lib/typescript/commonjs/errors/index.d.ts +3 -0
  174. package/lib/typescript/commonjs/formatters/currency.d.ts +22 -7
  175. package/lib/typescript/commonjs/formatters/date.d.ts +13 -13
  176. package/lib/typescript/commonjs/formatters/dateMath.d.ts +4 -2
  177. package/lib/typescript/commonjs/formatters/formatConfig.d.ts +48 -0
  178. package/lib/typescript/commonjs/formatters/house.d.ts +143 -0
  179. package/lib/typescript/commonjs/formatters/index.d.ts +4 -0
  180. package/lib/typescript/commonjs/formatters/number.d.ts +15 -5
  181. package/lib/typescript/commonjs/index.d.ts +26 -8
  182. package/lib/typescript/commonjs/initSDK.d.ts +18 -6
  183. package/lib/typescript/commonjs/initUserAuth.d.ts +29 -0
  184. package/lib/typescript/commonjs/logger/crashlytics.d.ts +31 -0
  185. package/lib/typescript/commonjs/logger/index.d.ts +17 -0
  186. package/lib/typescript/commonjs/push/index.d.ts +3 -1
  187. package/lib/typescript/commonjs/push/push.d.ts +1 -1
  188. package/lib/typescript/commonjs/push/status.d.ts +9 -0
  189. package/lib/typescript/commonjs/query/apiBaseQuery.d.ts +55 -0
  190. package/lib/typescript/commonjs/query/createAppApi.d.ts +21 -0
  191. package/lib/typescript/commonjs/query/index.d.ts +9 -0
  192. package/lib/typescript/commonjs/query/listeners.d.ts +11 -0
  193. package/lib/typescript/commonjs/query/paging.d.ts +42 -0
  194. package/lib/typescript/commonjs/query/tags.d.ts +31 -0
  195. package/lib/typescript/commonjs/redux/errorToastMiddleware.d.ts +51 -0
  196. package/lib/typescript/commonjs/redux/index.d.ts +6 -0
  197. package/lib/typescript/commonjs/redux/rootReducer.d.ts +19 -0
  198. package/lib/typescript/commonjs/redux/serializableCheck.d.ts +14 -0
  199. package/lib/typescript/commonjs/secureScreen/index.d.ts +25 -0
  200. package/lib/typescript/commonjs/versionCheck/buildNumber.d.ts +14 -0
  201. package/lib/typescript/commonjs/versionCheck/index.d.ts +28 -17
  202. package/lib/typescript/module/api/clientHeaders.d.ts +25 -0
  203. package/lib/typescript/module/api/minAppVersion.d.ts +24 -0
  204. package/lib/typescript/module/api/requestDefaults.d.ts +21 -0
  205. package/lib/typescript/module/api/responseBodyText.d.ts +6 -0
  206. package/lib/typescript/module/api/retry.d.ts +23 -9
  207. package/lib/typescript/module/api/tokenRefresh.d.ts +14 -2
  208. package/lib/typescript/module/api/userClient.d.ts +1 -1
  209. package/lib/typescript/module/auth/authStore.d.ts +76 -0
  210. package/lib/typescript/module/auth/index.d.ts +2 -2
  211. package/lib/typescript/module/config/index.d.ts +31 -2
  212. package/lib/typescript/module/errors/extractApiError.d.ts +69 -0
  213. package/lib/typescript/module/errors/index.d.ts +3 -0
  214. package/lib/typescript/module/formatters/currency.d.ts +22 -7
  215. package/lib/typescript/module/formatters/date.d.ts +13 -13
  216. package/lib/typescript/module/formatters/dateMath.d.ts +4 -2
  217. package/lib/typescript/module/formatters/formatConfig.d.ts +48 -0
  218. package/lib/typescript/module/formatters/house.d.ts +143 -0
  219. package/lib/typescript/module/formatters/index.d.ts +4 -0
  220. package/lib/typescript/module/formatters/number.d.ts +15 -5
  221. package/lib/typescript/module/index.d.ts +26 -8
  222. package/lib/typescript/module/initSDK.d.ts +18 -6
  223. package/lib/typescript/module/initUserAuth.d.ts +29 -0
  224. package/lib/typescript/module/logger/crashlytics.d.ts +31 -0
  225. package/lib/typescript/module/logger/index.d.ts +17 -0
  226. package/lib/typescript/module/push/index.d.ts +3 -1
  227. package/lib/typescript/module/push/push.d.ts +1 -1
  228. package/lib/typescript/module/push/status.d.ts +9 -0
  229. package/lib/typescript/module/query/apiBaseQuery.d.ts +55 -0
  230. package/lib/typescript/module/query/createAppApi.d.ts +21 -0
  231. package/lib/typescript/module/query/index.d.ts +9 -0
  232. package/lib/typescript/module/query/listeners.d.ts +11 -0
  233. package/lib/typescript/module/query/paging.d.ts +42 -0
  234. package/lib/typescript/module/query/tags.d.ts +31 -0
  235. package/lib/typescript/module/redux/errorToastMiddleware.d.ts +51 -0
  236. package/lib/typescript/module/redux/index.d.ts +6 -0
  237. package/lib/typescript/module/redux/rootReducer.d.ts +19 -0
  238. package/lib/typescript/module/redux/serializableCheck.d.ts +14 -0
  239. package/lib/typescript/module/secureScreen/index.d.ts +25 -0
  240. package/lib/typescript/module/versionCheck/buildNumber.d.ts +14 -0
  241. package/lib/typescript/module/versionCheck/index.d.ts +28 -17
  242. package/package.json +52 -5
@@ -1,171 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useNetworkStatus = exports.setNetworkStatusImplementation = exports.getNetworkStatus = exports.getLastKnownNetworkStatus = exports.addNetworkStatusListener = void 0;
7
- var ExpoNetwork = _interopRequireWildcard(require("expo-network"));
8
- var _react = require("react");
9
- var _index = require("../logger/index.js");
10
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
- const DEFAULT_STATUS = {
12
- isConnected: true,
13
- isInternetReachable: null,
14
- type: 'unknown'
15
- };
16
- /**
17
- * expo-network is imported directly, not resolved through a seam.
18
- *
19
- * `expo` is a REQUIRED peer of this package, so every consumer has the Expo
20
- * modules by construction and the static-require problem that forced the old
21
- * injection design does not arise. An app wires nothing: connectivity works
22
- * because the library uses Expo, which is the point of the Expo-first policy.
23
- * One backend also means one behaviour, rather than each app choosing.
24
- */
25
- let override = null;
26
- let lastKnown = null;
27
- let stopFollowing = null;
28
- const stopFollowingNetwork = () => {
29
- stopFollowing?.();
30
- stopFollowing = null;
31
- lastKnown = null;
32
- };
33
-
34
- /**
35
- * Replace the backend. Intended for TESTS and for the showcase, which uses it
36
- * to reach error paths that a healthy device never takes; it is not the way an
37
- * app is meant to configure the library. Pass `null` to restore expo-network.
38
- */
39
- const setNetworkStatusImplementation = impl => {
40
- override = impl;
41
- stopFollowingNetwork();
42
- };
43
- exports.setNetworkStatusImplementation = setNetworkStatusImplementation;
44
- const resolveNetInfo = () => override ?? expoNetworkBackend;
45
-
46
- /**
47
- * expo-network in the shape this module already speaks.
48
- *
49
- * The conversion is not cosmetic: expo reports its type as an UPPERCASE enum
50
- * where this module's vocabulary is lowercase, marks every field optional, and
51
- * returns an EventSubscription where an unsubscribe function is expected.
52
- */
53
- const expoNetworkBackend = {
54
- fetch: async () => {
55
- const state = await ExpoNetwork.getNetworkStateAsync();
56
- return {
57
- isConnected: state?.isConnected !== false,
58
- isInternetReachable: state?.isInternetReachable ?? null,
59
- type: state?.type ? String(state.type).toLowerCase() : undefined
60
- };
61
- },
62
- addEventListener: cb => {
63
- const subscription = ExpoNetwork.addNetworkStateListener(state => {
64
- cb({
65
- isConnected: state?.isConnected !== false,
66
- isInternetReachable: state?.isInternetReachable ?? null,
67
- type: state?.type ? String(state.type).toLowerCase() : undefined
68
- });
69
- });
70
- return () => subscription.remove();
71
- }
72
- };
73
- const normalize = state => {
74
- if (!state) {
75
- return DEFAULT_STATUS;
76
- }
77
- return {
78
- isConnected: state.isConnected !== false,
79
- isInternetReachable: state.isInternetReachable,
80
- type: state.type ?? 'unknown'
81
- };
82
- };
83
-
84
- /**
85
- * Imperative one-shot fetch of current network status. Resolves to the default
86
- * online status when NetInfo is unavailable so callers never crash.
87
- */
88
- const getNetworkStatus = async () => {
89
- const ni = resolveNetInfo();
90
- if (!ni) {
91
- return DEFAULT_STATUS;
92
- }
93
- try {
94
- const state = await ni.fetch();
95
- return normalize(state);
96
- } catch (error) {
97
- _index.Logger.error('[network] getNetworkStatus failed', error);
98
- return DEFAULT_STATUS;
99
- }
100
- };
101
-
102
- /**
103
- * Subscribe to network status changes. Returns an unsubscribe function.
104
- */
105
- exports.getNetworkStatus = getNetworkStatus;
106
- const addNetworkStatusListener = listener => {
107
- const ni = resolveNetInfo();
108
- if (!ni) {
109
- return () => undefined;
110
- }
111
- return ni.addEventListener(state => listener(normalize(state)));
112
- };
113
-
114
- /**
115
- * The connectivity the HTTP client checks before every request. One listener,
116
- * attached on first use, keeps it current, so a request costs no native probe:
117
- * one probe seeds the value and the listener's events replace it.
118
- */
119
- exports.addNetworkStatusListener = addNetworkStatusListener;
120
- const getLastKnownNetworkStatus = async () => {
121
- if (!stopFollowing) {
122
- try {
123
- stopFollowing = addNetworkStatusListener(status => {
124
- lastKnown = status;
125
- });
126
- } catch (error) {
127
- _index.Logger.error('[network] could not follow network changes', error);
128
- return getNetworkStatus();
129
- }
130
- }
131
- if (lastKnown) {
132
- return lastKnown;
133
- }
134
- const following = stopFollowing;
135
- const probed = await getNetworkStatus();
136
- if (stopFollowing !== following) {
137
- return probed;
138
- }
139
- // An event that arrived during the probe is newer than the probe.
140
- lastKnown ??= probed;
141
- return lastKnown;
142
- };
143
-
144
- /**
145
- * React hook that returns the current network status and re-renders on change.
146
- * Reports an optimistic online default when NetInfo is not installed.
147
- */
148
- exports.getLastKnownNetworkStatus = getLastKnownNetworkStatus;
149
- const useNetworkStatus = () => {
150
- const [status, setStatus] = (0, _react.useState)(DEFAULT_STATUS);
151
- (0, _react.useEffect)(() => {
152
- let mounted = true;
153
- void getNetworkStatus().then(s => {
154
- if (mounted) {
155
- setStatus(s);
156
- }
157
- });
158
- const unsubscribe = addNetworkStatusListener(s => {
159
- if (mounted) {
160
- setStatus(s);
161
- }
162
- });
163
- return () => {
164
- mounted = false;
165
- unsubscribe();
166
- };
167
- }, []);
168
- return status;
169
- };
170
- exports.useNetworkStatus = useNetworkStatus;
171
- //# sourceMappingURL=networkStatus.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useNetworkStatus=exports.setNetworkStatusImplementation=exports.getNetworkStatus=exports.getLastKnownNetworkStatus=exports.addNetworkStatusListener=void 0;var ExpoNetwork=_interopRequireWildcard(require("expo-network")),_react=require("react"),_index=require("../logger/index.js");function _interopRequireWildcard(t,e){if("function"==typeof WeakMap)var n=new WeakMap,o=new WeakMap;return(_interopRequireWildcard=function(t,e){if(!e&&t&&t.__esModule)return t;var r,s,a={__proto__:null,default:t};if(null===t||"object"!=typeof t&&"function"!=typeof t)return a;if(r=e?o:n){if(r.has(t))return r.get(t);r.set(t,a)}for(const e in t)"default"!==e&&{}.hasOwnProperty.call(t,e)&&((s=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(t,e))&&(s.get||s.set)?r(a,e,s):a[e]=t[e]);return a})(t,e)}const DEFAULT_STATUS={isConnected:!0,isInternetReachable:null,type:"unknown"};let override=null,lastKnown=null,stopFollowing=null;const stopFollowingNetwork=()=>{stopFollowing?.(),stopFollowing=null,lastKnown=null},setNetworkStatusImplementation=t=>{override=t,stopFollowingNetwork()};exports.setNetworkStatusImplementation=setNetworkStatusImplementation;const resolveNetInfo=()=>override??expoNetworkBackend,expoNetworkBackend={fetch:async()=>{const t=await ExpoNetwork.getNetworkStateAsync();return{isConnected:!1!==t?.isConnected,isInternetReachable:t?.isInternetReachable??null,type:t?.type?String(t.type).toLowerCase():void 0}},addEventListener:t=>{const e=ExpoNetwork.addNetworkStateListener(e=>{t({isConnected:!1!==e?.isConnected,isInternetReachable:e?.isInternetReachable??null,type:e?.type?String(e.type).toLowerCase():void 0})});return()=>e.remove()}},normalize=t=>t?{isConnected:!1!==t.isConnected,isInternetReachable:t.isInternetReachable,type:t.type??"unknown"}:DEFAULT_STATUS,getNetworkStatus=async()=>{const t=resolveNetInfo();if(!t)return DEFAULT_STATUS;try{const e=await t.fetch();return normalize(e)}catch(t){return _index.Logger.error("[network] getNetworkStatus failed",t),DEFAULT_STATUS}};exports.getNetworkStatus=getNetworkStatus;const addNetworkStatusListener=t=>{const e=resolveNetInfo();return e?e.addEventListener(e=>t(normalize(e))):()=>{}};exports.addNetworkStatusListener=addNetworkStatusListener;const getLastKnownNetworkStatus=async()=>{if(!stopFollowing)try{stopFollowing=addNetworkStatusListener(t=>{lastKnown=t})}catch(t){return _index.Logger.error("[network] could not follow network changes",t),getNetworkStatus()}if(lastKnown&&!1!==lastKnown.isConnected)return lastKnown;const t=stopFollowing,e=lastKnown,n=await getNetworkStatus();return stopFollowing!==t?n:(lastKnown===e&&(lastKnown=n),lastKnown??n)};exports.getLastKnownNetworkStatus=getLastKnownNetworkStatus;const useNetworkStatus=()=>{const[t,e]=(0,_react.useState)(DEFAULT_STATUS);return(0,_react.useEffect)(()=>{let t=!0;getNetworkStatus().then(n=>{t&&e(n)});const n=addNetworkStatusListener(n=>{t&&e(n)});return()=>{t=!1,n()}},[]),t};exports.useNetworkStatus=useNetworkStatus;
@@ -1,14 +1 @@
1
- "use strict";
2
-
3
- var _index = require("./index.js");
4
- /** The one place `expo-calendar` is named. Import only if you use calendar/reminders. */
5
- const m = require('expo-calendar');
6
- (0, _index.registerPermissionAdapter)('calendar', {
7
- check: m.getCalendarPermissionsAsync,
8
- request: m.requestCalendarPermissionsAsync
9
- });
10
- (0, _index.registerPermissionAdapter)('reminders', {
11
- check: m.getRemindersPermissionsAsync,
12
- request: m.requestRemindersPermissionsAsync
13
- });
14
- //# sourceMappingURL=calendar.js.map
1
+ "use strict";var _index=require("./index.js");const m=require("expo-calendar");(0,_index.registerPermissionAdapter)("calendar",{check:m.getCalendarPermissionsAsync,request:m.requestCalendarPermissionsAsync}),(0,_index.registerPermissionAdapter)("reminders",{check:m.getRemindersPermissionsAsync,request:m.requestRemindersPermissionsAsync});
@@ -1,14 +1 @@
1
- "use strict";
2
-
3
- var _index = require("./index.js");
4
- /** The one place `expo-camera` is named. Import only if you use camera/microphone. */
5
- const m = require('expo-camera');
6
- (0, _index.registerPermissionAdapter)('camera', {
7
- check: m.getCameraPermissionsAsync,
8
- request: m.requestCameraPermissionsAsync
9
- });
10
- (0, _index.registerPermissionAdapter)('microphone', {
11
- check: m.getMicrophonePermissionsAsync,
12
- request: m.requestMicrophonePermissionsAsync
13
- });
14
- //# sourceMappingURL=camera.js.map
1
+ "use strict";var _index=require("./index.js");const m=require("expo-camera");(0,_index.registerPermissionAdapter)("camera",{check:()=>m.Camera.getCameraPermissionsAsync(),request:()=>m.Camera.requestCameraPermissionsAsync()}),(0,_index.registerPermissionAdapter)("microphone",{check:()=>m.Camera.getMicrophonePermissionsAsync(),request:()=>m.Camera.requestMicrophonePermissionsAsync()});
@@ -1,10 +1 @@
1
- "use strict";
2
-
3
- var _index = require("./index.js");
4
- /** The one place `expo-contacts` is named. Import only if you use contacts. */
5
- const m = require('expo-contacts');
6
- (0, _index.registerPermissionAdapter)('contacts', {
7
- check: m.getPermissionsAsync,
8
- request: m.requestPermissionsAsync
9
- });
10
- //# sourceMappingURL=contacts.js.map
1
+ "use strict";var _index=require("./index.js");const m=require("expo-contacts");(0,_index.registerPermissionAdapter)("contacts",{check:m.getPermissionsAsync,request:m.requestPermissionsAsync});
@@ -1,133 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.setPermissionsImplementation = exports.registerPermissionAdapter = exports.Permissions = void 0;
7
- var _reactNative = require("react-native");
8
- var _index = require("../logger/index.js");
9
- // Android only — legacy WRITE_EXTERNAL_STORAGE
10
-
11
- /** The shared response shape every Expo permission function returns. */
12
-
13
- let backend = null;
14
-
15
- /**
16
- * Inject a custom permissions backend at runtime. Pass `null` to reset to the
17
- * default per-kind Expo resolution.
18
- *
19
- * Two legitimate reasons to call this: tests/the showcase reaching a denied,
20
- * blocked or unavailable path a healthy device never takes; and an app that
21
- * genuinely needs `bluetooth` or `storage`, which no Expo module covers.
22
- */
23
- const setPermissionsImplementation = impl => {
24
- backend = impl;
25
- };
26
-
27
- /**
28
- * Populated by the per-package entry points (`./camera`, `./photos`, …), never
29
- * by this file. This module names NO Expo package — Metro resolves every
30
- * literal require() reachable from the static import graph regardless of
31
- * which switch branch would have run, so naming seven packages here would
32
- * make each one a mandatory install for every consumer, whichever kinds they
33
- * actually use. An app wires only the kinds it needs:
34
- *
35
- * import '@webority/mobile-core/permissions/camera';
36
- * import '@webority/mobile-core/permissions/location';
37
- *
38
- * `bluetooth` and `storage` have no Expo module and are never registered here
39
- * — they resolve through `setPermissionsImplementation` only.
40
- */
41
- exports.setPermissionsImplementation = setPermissionsImplementation;
42
- const registry = new Map();
43
-
44
- /** Called by the per-package entry points to register their kind(s). Not for app code. */
45
- const registerPermissionAdapter = (kind, fns) => {
46
- registry.set(kind, fns);
47
- };
48
- exports.registerPermissionAdapter = registerPermissionAdapter;
49
- const resolveExpoModule = kind => registry.get(kind) ?? null;
50
- const toStatus = response => {
51
- if (!response) {
52
- return 'unavailable';
53
- }
54
- if (response.accessPrivileges === 'limited') {
55
- return 'limited';
56
- }
57
- if (response.status === 'granted') {
58
- return 'granted';
59
- }
60
- if (response.status === 'denied') {
61
- return response.canAskAgain ? 'denied' : 'blocked';
62
- }
63
- // 'undetermined' — never asked yet. Treated as 'denied' so callers using
64
- // Permissions.ensure() correctly trigger a request() rather than stalling.
65
- return 'denied';
66
- };
67
- const checkPermission = async kind => {
68
- if (backend) {
69
- return backend.check(kind);
70
- }
71
- const fns = resolveExpoModule(kind);
72
- if (!fns) {
73
- return 'unavailable';
74
- }
75
- try {
76
- return toStatus(await fns.check());
77
- } catch (error) {
78
- _index.Logger.error(`[permissions] check(${kind}) failed`, error);
79
- return 'unavailable';
80
- }
81
- };
82
- const requestPermission = async kind => {
83
- if (backend) {
84
- return backend.request(kind);
85
- }
86
- const fns = resolveExpoModule(kind);
87
- if (!fns) {
88
- return 'unavailable';
89
- }
90
- try {
91
- return toStatus(await fns.request());
92
- } catch (error) {
93
- _index.Logger.error(`[permissions] request(${kind}) failed`, error);
94
- return 'unavailable';
95
- }
96
- };
97
- const openAppSettings = async () => {
98
- try {
99
- await _reactNative.Linking.openSettings();
100
- return true;
101
- } catch (error) {
102
- _index.Logger.error('[permissions] openAppSettings failed', error);
103
- return false;
104
- }
105
- };
106
-
107
- /**
108
- * Cross-platform permissions wrapper. Maps an abstract `PermissionKind`
109
- * (camera, photos, location, notifications, …) to whichever Expo adapter an
110
- * app has registered by importing that kind's entry point — expo-camera,
111
- * expo-image-picker, expo-location, expo-contacts, expo-calendar,
112
- * expo-notifications, expo-media-library. An app imports only the entry
113
- * points for the kinds it actually asks for.
114
- */
115
- const Permissions = exports.Permissions = {
116
- check: checkPermission,
117
- request: requestPermission,
118
- /** Convenience: returns true when the permission is `granted` or `limited`. */
119
- isAuthorized: async kind => {
120
- const s = await checkPermission(kind);
121
- return s === 'granted' || s === 'limited';
122
- },
123
- /** Convenience: check, and request only if not yet granted. */
124
- ensure: async kind => {
125
- const s = await checkPermission(kind);
126
- if (s === 'granted' || s === 'limited' || s === 'blocked' || s === 'unavailable') {
127
- return s;
128
- }
129
- return requestPermission(kind);
130
- },
131
- openSettings: openAppSettings
132
- };
133
- //# sourceMappingURL=index.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setPermissionsImplementation=exports.registerPermissionAdapter=exports.Permissions=void 0;var _reactNative=require("react-native"),_index=require("../logger/index.js");let backend=null;const setPermissionsImplementation=e=>{backend=e};exports.setPermissionsImplementation=setPermissionsImplementation;const registry=new Map,registerPermissionAdapter=(e,s)=>{registry.set(e,s)};exports.registerPermissionAdapter=registerPermissionAdapter;const resolveExpoModule=e=>registry.get(e)??null,toStatus=e=>e?"limited"===e.accessPrivileges?"limited":"granted"===e.status?"granted":"denied"===e.status?e.canAskAgain?"denied":"blocked":"denied":"unavailable",checkPermission=async e=>{if(backend)return backend.check(e);const s=resolveExpoModule(e);if(!s)return"unavailable";try{return toStatus(await s.check())}catch(s){return _index.Logger.error(`[permissions] check(${e}) failed`,s),"unavailable"}},requestPermission=async e=>{if(backend)return backend.request(e);const s=resolveExpoModule(e);if(!s)return"unavailable";try{return toStatus(await s.request())}catch(s){return _index.Logger.error(`[permissions] request(${e}) failed`,s),"unavailable"}},openAppSettings=async()=>{try{return await _reactNative.Linking.openSettings(),!0}catch(e){return _index.Logger.error("[permissions] openAppSettings failed",e),!1}},Permissions=exports.Permissions={check:checkPermission,request:requestPermission,isAuthorized:async e=>{const s=await checkPermission(e);return"granted"===s||"limited"===s},ensure:async e=>{const s=await checkPermission(e);return"granted"===s||"limited"===s||"blocked"===s||"unavailable"===s?s:requestPermission(e)},openSettings:openAppSettings};
@@ -1,14 +1 @@
1
- "use strict";
2
-
3
- var _index = require("./index.js");
4
- /** The one place `expo-location` is named. Import only if you use location/locationAlways. */
5
- const m = require('expo-location');
6
- (0, _index.registerPermissionAdapter)('location', {
7
- check: m.getForegroundPermissionsAsync,
8
- request: m.requestForegroundPermissionsAsync
9
- });
10
- (0, _index.registerPermissionAdapter)('locationAlways', {
11
- check: m.getBackgroundPermissionsAsync,
12
- request: m.requestBackgroundPermissionsAsync
13
- });
14
- //# sourceMappingURL=location.js.map
1
+ "use strict";var _index=require("./index.js");const m=require("expo-location");(0,_index.registerPermissionAdapter)("location",{check:m.getForegroundPermissionsAsync,request:m.requestForegroundPermissionsAsync}),(0,_index.registerPermissionAdapter)("locationAlways",{check:m.getBackgroundPermissionsAsync,request:m.requestBackgroundPermissionsAsync});
@@ -1,10 +1 @@
1
- "use strict";
2
-
3
- var _index = require("./index.js");
4
- /** The one place `expo-media-library` is named. Import only if you use mediaLibrary. */
5
- const m = require('expo-media-library');
6
- (0, _index.registerPermissionAdapter)('mediaLibrary', {
7
- check: m.getPermissionsAsync,
8
- request: m.requestPermissionsAsync
9
- });
10
- //# sourceMappingURL=mediaLibrary.js.map
1
+ "use strict";var _index=require("./index.js");const m=require("expo-media-library");(0,_index.registerPermissionAdapter)("mediaLibrary",{check:m.getPermissionsAsync,request:m.requestPermissionsAsync});
@@ -1,10 +1 @@
1
- "use strict";
2
-
3
- var _index = require("./index.js");
4
- /** The one place `expo-notifications` is named. Import only if you use notifications. */
5
- const m = require('expo-notifications');
6
- (0, _index.registerPermissionAdapter)('notifications', {
7
- check: m.getPermissionsAsync,
8
- request: m.requestPermissionsAsync
9
- });
10
- //# sourceMappingURL=notifications.js.map
1
+ "use strict";var _index=require("./index.js");const m=require("expo-notifications");(0,_index.registerPermissionAdapter)("notifications",{check:m.getPermissionsAsync,request:m.requestPermissionsAsync});
@@ -1,14 +1 @@
1
- "use strict";
2
-
3
- var _index = require("./index.js");
4
- /** The one place `expo-image-picker` is named. Import only if you use photos/photosAdd. */
5
- const m = require('expo-image-picker');
6
- (0, _index.registerPermissionAdapter)('photos', {
7
- check: () => m.getMediaLibraryPermissionsAsync(false),
8
- request: () => m.requestMediaLibraryPermissionsAsync(false)
9
- });
10
- (0, _index.registerPermissionAdapter)('photosAdd', {
11
- check: () => m.getMediaLibraryPermissionsAsync(true),
12
- request: () => m.requestMediaLibraryPermissionsAsync(true)
13
- });
14
- //# sourceMappingURL=photos.js.map
1
+ "use strict";var _index=require("./index.js");const m=require("expo-image-picker");(0,_index.registerPermissionAdapter)("photos",{check:()=>m.getMediaLibraryPermissionsAsync(!1),request:()=>m.requestMediaLibraryPermissionsAsync(!1)}),(0,_index.registerPermissionAdapter)("photosAdd",{check:()=>m.getMediaLibraryPermissionsAsync(!0),request:()=>m.requestMediaLibraryPermissionsAsync(!0)});