@rpcbase/client 0.227.0 → 0.231.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 (237) hide show
  1. package/package.json +11 -113
  2. package/src/apiClient/getServerApiClient.ts +131 -0
  3. package/src/apiClient/index.ts +86 -0
  4. package/src/index.ts +3 -0
  5. package/src/initClient.ts +32 -0
  6. package/src/types.ts +7 -0
  7. package/AppProvider/AnalyticsContainer.js +0 -56
  8. package/AppProvider/debug.js +0 -4
  9. package/AppProvider/index.tsx +0 -79
  10. package/access-control/ACLForm/components/GrantField/OpSelector.tsx +0 -129
  11. package/access-control/ACLForm/components/GrantField/ResourceSelector.tsx +0 -86
  12. package/access-control/ACLForm/components/GrantField/UsersSelector.tsx +0 -96
  13. package/access-control/ACLForm/components/GrantField/grant-field.scss +0 -26
  14. package/access-control/ACLForm/components/GrantField/icons/CheckMark.tsx +0 -16
  15. package/access-control/ACLForm/components/GrantField/icons/CollapseArrow.tsx +0 -14
  16. package/access-control/ACLForm/components/GrantField/icons/ExpandArrow.tsx +0 -14
  17. package/access-control/ACLForm/components/GrantField/index.tsx +0 -91
  18. package/access-control/ACLForm/components/GrantsList.tsx +0 -48
  19. package/access-control/ACLForm/components/RoleForm.tsx +0 -134
  20. package/access-control/ACLForm/components/RoleView.tsx +0 -115
  21. package/access-control/ACLForm/components/RolesList.tsx +0 -79
  22. package/access-control/ACLForm/components/constants.tsx +0 -1
  23. package/access-control/ACLForm/components/resolver.ts +0 -57
  24. package/access-control/ACLForm/components/role-form.scss +0 -19
  25. package/access-control/ACLForm/index.tsx +0 -48
  26. package/access-control/ACLModal/acl-modal.scss +0 -7
  27. package/access-control/ACLModal/index.tsx +0 -66
  28. package/access-control/PolicyEditor/TargetSelector/QueryBuilder.tsx +0 -48
  29. package/access-control/PolicyEditor/TargetSelector/index.tsx +0 -5
  30. package/access-control/PolicyEditor/TargetSelector/query-builder.scss +0 -9
  31. package/access-control/PolicyEditor/index.tsx +0 -165
  32. package/access-control/index.ts +0 -3
  33. package/apiClient.js +0 -15
  34. package/auth/authProps.js +0 -8
  35. package/auth/components/AccountsList/AccountListItem.js +0 -61
  36. package/auth/components/AccountsList/account-list-item.scss +0 -5
  37. package/auth/components/AccountsList/index.js +0 -17
  38. package/auth/components/Footer/index.js +0 -11
  39. package/auth/components/ForgotPassword/forgot-password.scss +0 -37
  40. package/auth/components/ForgotPassword/index.js +0 -114
  41. package/auth/components/SetNewPassword/index.js +0 -130
  42. package/auth/components/SetNewPassword/set-new-password.scss +0 -47
  43. package/auth/components/SignIn/SignInEmailForm.tsx +0 -115
  44. package/auth/components/SignIn/index.js +0 -69
  45. package/auth/components/SignIn/sign-in.scss +0 -56
  46. package/auth/components/SignOut/index.js +0 -144
  47. package/auth/components/SignOut/sign-out.scss +0 -34
  48. package/auth/components/SignUp/SignUpEmailForm.tsx +0 -98
  49. package/auth/components/SignUp/index.js +0 -66
  50. package/auth/components/SignUp/sign-up.scss +0 -56
  51. package/auth/getTenantId.js +0 -12
  52. package/auth/getUid.js +0 -11
  53. package/auth/helpers/redirectSignIn.native.js +0 -9
  54. package/auth/helpers/redirectSignIn.web.js +0 -7
  55. package/auth/index.js +0 -146
  56. package/auth/signOut.js +0 -20
  57. package/auth/useAuthRouter.js +0 -56
  58. package/env.d.ts +0 -3
  59. package/firebase/index.js +0 -1
  60. package/firebase/sw.js +0 -1
  61. package/form/FileInput/FileUploadContext.tsx +0 -162
  62. package/form/FileInput/FileUploadForm/index.tsx +0 -139
  63. package/form/FileInput/FileUploadForm/usePreventUnload.js +0 -21
  64. package/form/FileInput/UploadButton.tsx +0 -23
  65. package/form/FileInput/constants.ts +0 -16
  66. package/form/FileInput/file-input.scss +0 -1
  67. package/form/FileInput/index.tsx +0 -21
  68. package/form/FileInput/upload-worker/get_file_hash.js +0 -63
  69. package/form/FileInput/upload-worker/index.js +0 -16
  70. package/form/FileInput/upload-worker/no_compress_exts.ts +0 -33
  71. package/form/FileInput/upload-worker/upload_file.js +0 -129
  72. package/form/Form.tsx +0 -23
  73. package/form/Input.tsx +0 -62
  74. package/form/SubmitButton/index.tsx +0 -58
  75. package/form/hook-form.tsx +0 -7
  76. package/form/index.tsx +0 -5
  77. package/getBaseUrl.js +0 -14
  78. package/getObjectId.ts +0 -31
  79. package/hashState.js +0 -158
  80. package/helpers/createBatcher/index.js +0 -36
  81. package/helpers/getInitials.js +0 -39
  82. package/helpers/onReady.js +0 -15
  83. package/helpers/post.js +0 -18
  84. package/helpers/postRPC.js +0 -42
  85. package/helpers/useRPC.js +0 -41
  86. package/helpers/useStoredValue/batchedGetStoredValues.js +0 -30
  87. package/helpers/useStoredValue/index.js +0 -107
  88. package/helpers/useStoredValue/setStoredValues.js +0 -14
  89. package/i18n/en/rb.nav.json +0 -13
  90. package/i18n/en/rb.sign_in.json +0 -11
  91. package/i18n/en/rb.sign_out.json +0 -5
  92. package/i18n/fr/rb.sign_in.json +0 -11
  93. package/i18n/fr/rb.sign_out.json +0 -5
  94. package/i18n/index.js +0 -63
  95. package/index.js +0 -6
  96. package/isEqualValues.js +0 -47
  97. package/jest.config.js +0 -16
  98. package/notifications/Notification/index.js +0 -36
  99. package/notifications/Notification/notification.scss +0 -1
  100. package/notifications/NotificationItem/HeaderStatus.js +0 -93
  101. package/notifications/NotificationItem/index.js +0 -65
  102. package/notifications/NotificationItem/notification-item.scss +0 -25
  103. package/notifications/NotificationsContainer/index.js +0 -37
  104. package/notifications/NotificationsContainer/notifications-container.scss +0 -38
  105. package/notifications/NotificationsContainer/useLLTs.js +0 -28
  106. package/notifications/NotificationsContext/index.js +0 -71
  107. package/notifications/NotificationsContext/useNotificationsList.js +0 -75
  108. package/notifications/NotificationsSettingsModal/SettingsForm.js +0 -52
  109. package/notifications/NotificationsSettingsModal/index.js +0 -48
  110. package/notifications/NotificationsSettingsModal/notifications-settings.scss +0 -1
  111. package/notifications/config.js +0 -1
  112. package/notifications/index.js +0 -4
  113. package/page.js +0 -9
  114. package/publish-output.txt +0 -0
  115. package/rpc.js +0 -32
  116. package/rr-trace/get_fingerprint.js +0 -10
  117. package/rr-trace/get_perf_vitals.js +0 -24
  118. package/rr-trace/get_session_id.js +0 -29
  119. package/rr-trace/index.js +0 -138
  120. package/rr-trace/write_session_data.js +0 -86
  121. package/rts/boot.js +0 -3
  122. package/rts/getUseDocument.js +0 -21
  123. package/rts/getUseQuery/index.js +0 -233
  124. package/rts/getUseQuery/useData.js +0 -55
  125. package/rts/index.js +0 -10
  126. package/rts/rts.js +0 -243
  127. package/rts/signout.ts +0 -8
  128. package/rts/store/constants.js +0 -3
  129. package/rts/store/debug.js +0 -24
  130. package/rts/store/get_collection.js +0 -55
  131. package/rts/store/index.js +0 -100
  132. package/rts/store/replace_query_keys.js +0 -30
  133. package/rts/store/satisfies_projection.js +0 -32
  134. package/rts/store/update_docs.js +0 -47
  135. package/storage/index.jest.js +0 -15
  136. package/storage/index.native.js +0 -38
  137. package/storage/index.web.js +0 -25
  138. package/types.ts +0 -6
  139. package/ui/ActivityIndicator/index.js +0 -113
  140. package/ui/Avatar/index.native.js +0 -31
  141. package/ui/Avatar/index.web.js +0 -37
  142. package/ui/Avatar/styles.js +0 -41
  143. package/ui/ErrorBoundary/index.js +0 -12
  144. package/ui/ExpandableFloatView/exp.scss +0 -15
  145. package/ui/ExpandableFloatView/index.tsx +0 -123
  146. package/ui/ExpandableFloatView/useBackdrop.js +0 -45
  147. package/ui/LottiePlayer/LottiePlayer.js +0 -4
  148. package/ui/LottiePlayer/index.js +0 -8
  149. package/ui/Modal/HashStateModal.js +0 -30
  150. package/ui/Modal/Modal.js +0 -93
  151. package/ui/Modal/ModalForm/AlertBanner.js +0 -82
  152. package/ui/Modal/ModalForm/index.js +0 -188
  153. package/ui/Modal/ModalForm/modal-form.scss +0 -63
  154. package/ui/Modal/index.js +0 -10
  155. package/ui/Modal/modal.scss +0 -101
  156. package/ui/Modal/withHashStateModal.js +0 -24
  157. package/ui/RedboxError/index.js +0 -3
  158. package/ui/Search/SearchHistory/index.js +0 -45
  159. package/ui/Search/SearchHistory/search-history.scss +0 -9
  160. package/ui/Search/SearchHistory/useSearchHistory.tsx +0 -57
  161. package/ui/Search/SearchResults/index.tsx +0 -90
  162. package/ui/Search/index.tsx +0 -298
  163. package/ui/Search/search.scss +0 -0
  164. package/ui/SelectPills/index.tsx +0 -96
  165. package/ui/SelectPills/select-pills.scss +0 -66
  166. package/ui/Tabs/index.tsx +0 -161
  167. package/ui/Tabs/tabs.scss +0 -53
  168. package/ui/Tree/index.js +0 -257
  169. package/ui/Tree/model.js +0 -71
  170. package/ui/Tree/node.js +0 -112
  171. package/ui/Tree/tree.scss +0 -98
  172. package/ui/UserAvatar/default_colors.json +0 -82
  173. package/ui/UserAvatar/index.js +0 -55
  174. package/ui/View/index.tsx +0 -17
  175. package/ui/View/index.web.js +0 -44
  176. package/ui/animations/checkmark.json +0 -1
  177. package/ui/helpers/SizeContext/index.tsx +0 -11
  178. package/ui/helpers/helpers.scss +0 -61
  179. package/ui/helpers/index.ts +0 -6
  180. package/ui/helpers/stopEventPropagation.js +0 -5
  181. package/ui/helpers/useActiveListItemIndex/index.tsx +0 -45
  182. package/ui/helpers/useScrollSelectorIntoView/index.tsx +0 -14
  183. package/ui/helpers/useThrottledMeasure/index.js +0 -47
  184. package/ui/helpers/withSuspense/index.js +0 -37
  185. package/ui/icons/AddAccount.tsx +0 -5
  186. package/ui/icons/Billing.tsx +0 -6
  187. package/ui/icons/Close.tsx +0 -14
  188. package/ui/icons/Organization.tsx +0 -5
  189. package/ui/icons/Signout.tsx +0 -5
  190. package/ui/icons/index.tsx +0 -6
  191. package/ui/nav/AccountsDropdown/SwitchAccounts.tsx +0 -28
  192. package/ui/nav/AccountsDropdown/accounts-dropdown.scss +0 -51
  193. package/ui/nav/AccountsDropdown/index.tsx +0 -90
  194. package/ui/nav/AccountsToggle/index.tsx +0 -24
  195. package/ui/nav/ContentView/ContentViewContext.ts +0 -23
  196. package/ui/nav/ContentView/index.tsx +0 -115
  197. package/ui/nav/HeaderContainer/header.scss +0 -52
  198. package/ui/nav/HeaderContainer/index.tsx +0 -23
  199. package/ui/nav/HeaderContainer/variables.scss +0 -1
  200. package/ui/nav/MorphingDropdown/MorphingDropdownContext.tsx +0 -151
  201. package/ui/nav/MorphingDropdown/MorphingDropdownMenu.tsx +0 -38
  202. package/ui/nav/MorphingDropdown/MorphingDropdownPortal.tsx +0 -166
  203. package/ui/nav/MorphingDropdown/MorphingDropdownToggle.tsx +0 -34
  204. package/ui/nav/MorphingDropdown/index.tsx +0 -16
  205. package/ui/nav/MorphingDropdown/morphing-dropdown.scss +0 -35
  206. package/ui/nav/NotificationsDropdown/index.tsx +0 -52
  207. package/ui/nav/NotificationsDropdown/notifications-dropdown.scss +0 -5
  208. package/ui/nav/NotificationsToggle/NotificationsGlyph.tsx +0 -54
  209. package/ui/nav/NotificationsToggle/index.tsx +0 -12
  210. package/ui/nav/NotificationsToggle/notification-animation.json +0 -1
  211. package/ui/nav/NotificationsToggle/notifications-toggle.scss +0 -26
  212. package/ui/nav/SidebarContainer/index.tsx +0 -48
  213. package/ui/nav/SidebarContainer/sidebar-container.scss +0 -21
  214. package/ui/nav/SlideoutContainer/components/Body.tsx +0 -19
  215. package/ui/nav/SlideoutContainer/components/Header.tsx +0 -23
  216. package/ui/nav/SlideoutContainer/components/Wrapper.tsx +0 -46
  217. package/ui/nav/SlideoutContainer/index.tsx +0 -50
  218. package/ui/nav/SlideoutContainer/slideout-container.scss +0 -40
  219. package/ui/nav/index.ts +0 -13
  220. package/ui/oauth/GitHub.js +0 -38
  221. package/ui/oauth/getGitHubSigninUrl.js +0 -30
  222. package/ui/oauth/index.js +0 -9
  223. package/ui/oauth/oauth.scss +0 -16
  224. package/ui/sortable-hoc/AutoScroller.js +0 -76
  225. package/ui/sortable-hoc/DragHandle.js +0 -31
  226. package/ui/sortable-hoc/Manager.js +0 -54
  227. package/ui/sortable-hoc/README.md +0 -1
  228. package/ui/sortable-hoc/SortableContainer/defaultGetHelperDimensions.js +0 -7
  229. package/ui/sortable-hoc/SortableContainer/defaultShouldCancelStart.js +0 -24
  230. package/ui/sortable-hoc/SortableContainer/index.js +0 -994
  231. package/ui/sortable-hoc/SortableContainer/props.js +0 -81
  232. package/ui/sortable-hoc/SortableElement.js +0 -111
  233. package/ui/sortable-hoc/SortableHandle.js +0 -45
  234. package/ui/sortable-hoc/drag-handle.scss +0 -14
  235. package/ui/sortable-hoc/index.js +0 -9
  236. package/ui/sortable-hoc/utils.js +0 -292
  237. package/ui/springs.ts +0 -17
package/firebase/sw.js DELETED
@@ -1 +0,0 @@
1
- (()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.r(t),e.d(t,{getMessaging:()=>$t,initializeApp:()=>oe,onBackgroundMessage:()=>Ht});const n=function(e){const t=[];let n=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);r<128?t[n++]=r:r<2048?(t[n++]=r>>6|192,t[n++]=63&r|128):55296==(64512&r)&&i+1<e.length&&56320==(64512&e.charCodeAt(i+1))?(r=65536+((1023&r)<<10)+(1023&e.charCodeAt(++i)),t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128)}return t},i={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let t=0;t<e.length;t+=3){const r=e[t],a=t+1<e.length,o=a?e[t+1]:0,s=t+2<e.length,c=s?e[t+2]:0,l=r>>2,u=(3&r)<<4|o>>4;let d=(15&o)<<2|c>>6,p=63&c;s||(p=64,a||(d=64)),i.push(n[l],n[u],n[d],n[p])}return i.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(n(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let n=0,i=0;for(;n<e.length;){const r=e[n++];if(r<128)t[i++]=String.fromCharCode(r);else if(r>191&&r<224){const a=e[n++];t[i++]=String.fromCharCode((31&r)<<6|63&a)}else if(r>239&&r<365){const a=((7&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[i++]=String.fromCharCode(55296+(a>>10)),t[i++]=String.fromCharCode(56320+(1023&a))}else{const a=e[n++],o=e[n++];t[i++]=String.fromCharCode((15&r)<<12|(63&a)<<6|63&o)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let t=0;t<e.length;){const a=n[e.charAt(t++)],o=t<e.length?n[e.charAt(t)]:0;++t;const s=t<e.length?n[e.charAt(t)]:64;++t;const c=t<e.length?n[e.charAt(t)]:64;if(++t,null==a||null==o||null==s||null==c)throw new r;const l=a<<2|o>>4;if(i.push(l),64!==s){const e=o<<4&240|s>>2;if(i.push(e),64!==c){const e=s<<6&192|c;i.push(e)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class r extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const a=function(e){return function(e){const t=n(e);return i.encodeByteArray(t,!0)}(e).replace(/\./g,"")},o=()=>{try{return function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e.g)return e.g;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__||(()=>{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||(()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&function(e){try{return i.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null}(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},s=()=>{var e;return null===(e=o())||void 0===e?void 0:e.config};class c{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),"function"==typeof e&&(this.promise.catch((()=>{})),1===e.length?e(t):e(t,n))}}}function l(){try{return"object"==typeof indexedDB}catch(e){return!1}}function u(){return new Promise(((e,t)=>{try{let n=!0;const i="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(i);r.onsuccess=()=>{r.result.close(),n||self.indexedDB.deleteDatabase(i),e(!0)},r.onupgradeneeded=()=>{n=!1},r.onerror=()=>{var e;t((null===(e=r.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}}))}class d extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,d.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,p.prototype.create)}}class p{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},i=`${this.service}/${e}`,r=this.errors[e],a=r?function(e,t){return e.replace(f,((e,n)=>{const i=t[n];return null!=i?String(i):`<${n}?>`}))}(r,n):"Error",o=`${this.serviceName}: ${a} (${i}).`;return new d(i,o,n)}}const f=/\{\$([^}]+)}/g;function h(e,t){if(e===t)return!0;const n=Object.keys(e),i=Object.keys(t);for(const r of n){if(!i.includes(r))return!1;const n=e[r],a=t[r];if(g(n)&&g(a)){if(!h(n,a))return!1}else if(n!==a)return!1}for(const e of i)if(!n.includes(e))return!1;return!0}function g(e){return null!==e&&"object"==typeof e}function m(e){return e&&e._delegate?e._delegate:e}class b{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}const w="[DEFAULT]";class y{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const e=new c;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const n=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),i=null!==(t=null==e?void 0:e.optional)&&void 0!==t&&t;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(i)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(e){if(i)return null;throw e}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}(e))try{this.getOrInitializeService({instanceIdentifier:w})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch(e){}}}}clearInstance(e=w){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter((e=>"INTERNAL"in e)).map((e=>e.INTERNAL.delete())),...e.filter((e=>"_delete"in e)).map((e=>e._delete()))])}isComponentSet(){return null!=this.component}isInitialized(e=w){return this.instances.has(e)}getOptions(e=w){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:n,options:t});for(const[e,t]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(e)&&t.resolve(i);return i}onInit(e,t){var n;const i=this.normalizeInstanceIdentifier(t),r=null!==(n=this.onInitCallbacks.get(i))&&void 0!==n?n:new Set;r.add(e),this.onInitCallbacks.set(i,r);const a=this.instances.get(i);return a&&e(a,i),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){const n=this.onInitCallbacks.get(t);if(n)for(const i of n)try{i(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(i=e,i===w?void 0:i),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch(e){}var i;return n||null}normalizeInstanceIdentifier(e=w){return this.component?this.component.multipleInstances?e:w:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class v{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new y(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}const S=[];var I;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(I||(I={}));const _={debug:I.DEBUG,verbose:I.VERBOSE,info:I.INFO,warn:I.WARN,error:I.ERROR,silent:I.SILENT},E=I.INFO,C={[I.DEBUG]:"log",[I.VERBOSE]:"log",[I.INFO]:"info",[I.WARN]:"warn",[I.ERROR]:"error"},D=(e,t,...n)=>{if(t<e.logLevel)return;const i=(new Date).toISOString(),r=C[t];if(!r)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[r](`[${i}] ${e.name}:`,...n)},k=(e,t)=>t.some((t=>e instanceof t));let T,A;const O=new WeakMap,M=new WeakMap,B=new WeakMap,N=new WeakMap,j=new WeakMap;let P={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return M.get(e);if("objectStoreNames"===t)return e.objectStoreNames||B.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return $(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function L(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(A||(A=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(H(this),e),$(O.get(this))}:function(...e){return $(t.apply(H(this),e))}:function(e,...n){const i=t.call(H(this),e,...n);return B.set(i,e.sort?e.sort():[e]),$(i)}:(e instanceof IDBTransaction&&function(e){if(M.has(e))return;const t=new Promise(((t,n)=>{const i=()=>{e.removeEventListener("complete",r),e.removeEventListener("error",a),e.removeEventListener("abort",a)},r=()=>{t(),i()},a=()=>{n(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",r),e.addEventListener("error",a),e.addEventListener("abort",a)}));M.set(e,t)}(e),k(e,T||(T=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,P):e);var t}function $(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const i=()=>{e.removeEventListener("success",r),e.removeEventListener("error",a)},r=()=>{t($(e.result)),i()},a=()=>{n(e.error),i()};e.addEventListener("success",r),e.addEventListener("error",a)}));return t.then((t=>{t instanceof IDBCursor&&O.set(t,e)})).catch((()=>{})),j.set(t,e),t}(e);if(N.has(e))return N.get(e);const t=L(e);return t!==e&&(N.set(e,t),j.set(t,e)),t}const H=e=>j.get(e);function F(e,t,{blocked:n,upgrade:i,blocking:r,terminated:a}={}){const o=indexedDB.open(e,t),s=$(o);return i&&o.addEventListener("upgradeneeded",(e=>{i($(o.result),e.oldVersion,e.newVersion,$(o.transaction),e)})),n&&o.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),s.then((e=>{a&&e.addEventListener("close",(()=>a())),r&&e.addEventListener("versionchange",(e=>r(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),s}function R(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(e=>t(e.oldVersion,e))),$(n).then((()=>{}))}const x=["get","getKey","getAll","getAllKeys","count"],V=["put","add","delete","clear"],K=new Map;function U(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(K.get(t))return K.get(t);const n=t.replace(/FromIndex$/,""),i=t!==n,r=V.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!r&&!x.includes(n))return;const a=async function(e,...t){const a=this.transaction(e,r?"readwrite":"readonly");let o=a.store;return i&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),r&&a.done]))[0]};return K.set(t,a),a}var W;W=P,P={...W,get:(e,t,n)=>U(e,t)||W.get(e,t,n),has:(e,t)=>!!U(e,t)||W.has(e,t)};class z{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map((e=>{if(function(e){const t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null})).filter((e=>e)).join(" ")}}const q="@firebase/app",G="0.10.15",J=new class{constructor(e){this.name=e,this._logLevel=E,this._logHandler=D,this._userLogHandler=null,S.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in I))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?_[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,I.DEBUG,...e),this._logHandler(this,I.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,I.VERBOSE,...e),this._logHandler(this,I.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,I.INFO,...e),this._logHandler(this,I.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,I.WARN,...e),this._logHandler(this,I.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,I.ERROR,...e),this._logHandler(this,I.ERROR,...e)}}("@firebase/app"),Y="[DEFAULT]",Q={[q]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/data-connect":"fire-data-connect","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","@firebase/vertexai":"fire-vertex","fire-js":"fire-js",firebase:"fire-js-all"},X=new Map,Z=new Map,ee=new Map;function te(e,t){try{e.container.addComponent(t)}catch(n){J.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function ne(e){const t=e.name;if(ee.has(t))return J.debug(`There were multiple attempts to register component ${t}.`),!1;ee.set(t,e);for(const t of X.values())te(t,e);for(const t of Z.values())te(t,e);return!0}function ie(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}const re=new p("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."});class ae{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new b("app",(()=>this),"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw re.create("app-deleted",{appName:this._name})}}function oe(e,t={}){let n=e;"object"!=typeof t&&(t={name:t});const i=Object.assign({name:Y,automaticDataCollectionEnabled:!1},t),r=i.name;if("string"!=typeof r||!r)throw re.create("bad-app-name",{appName:String(r)});if(n||(n=s()),!n)throw re.create("no-options");const a=X.get(r);if(a){if(h(n,a.options)&&h(i,a.config))return a;throw re.create("duplicate-app",{appName:r})}const o=new v(r);for(const e of ee.values())o.addComponent(e);const c=new ae(n,i,o);return X.set(r,c),c}function se(e,t,n){var i;let r=null!==(i=Q[e])&&void 0!==i?i:e;n&&(r+=`-${n}`);const a=r.match(/\s|\//),o=t.match(/\s|\//);if(a||o){const e=[`Unable to register library "${r}" with version "${t}":`];return a&&e.push(`library name "${r}" contains illegal characters (whitespace or "/")`),a&&o&&e.push("and"),o&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void J.warn(e.join(" "))}ne(new b(`${r}-version`,(()=>({library:r,version:t})),"VERSION"))}const ce="firebase-heartbeat-database",le=1,ue="firebase-heartbeat-store";let de=null;function pe(){return de||(de=F(ce,le,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(ue)}catch(e){console.warn(e)}}}).catch((e=>{throw re.create("idb-open",{originalErrorMessage:e.message})}))),de}async function fe(e,t){try{const n=(await pe()).transaction(ue,"readwrite"),i=n.objectStore(ue);await i.put(t,he(e)),await n.done}catch(e){if(e instanceof d)J.warn(e.message);else{const t=re.create("idb-set",{originalErrorMessage:null==e?void 0:e.message});J.warn(t.message)}}}function he(e){return`${e.name}!${e.options.appId}`}class ge{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new be(t),this._heartbeatsCachePromise=this._storage.read().then((e=>(this._heartbeatsCache=e,e)))}async triggerHeartbeat(){var e,t;try{const n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=me();if(null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)&&(this._heartbeatsCache=await this._heartbeatsCachePromise,null==(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats)))return;if(this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some((e=>e.date===i)))return;return this._heartbeatsCache.heartbeats.push({date:i,agent:n}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter((e=>{const t=new Date(e.date).valueOf();return Date.now()-t<=2592e6})),this._storage.overwrite(this._heartbeatsCache)}catch(e){J.warn(e)}}async getHeartbeatsHeader(){var e;try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)||0===this._heartbeatsCache.heartbeats.length)return"";const t=me(),{heartbeatsToSend:n,unsentEntries:i}=function(e,t=1024){const n=[];let i=e.slice();for(const r of e){const e=n.find((e=>e.agent===r.agent));if(e){if(e.dates.push(r.date),we(n)>t){e.dates.pop();break}}else if(n.push({agent:r.agent,dates:[r.date]}),we(n)>t){n.pop();break}i=i.slice(1)}return{heartbeatsToSend:n,unsentEntries:i}}(this._heartbeatsCache.heartbeats),r=a(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=t,i.length>0?(this._heartbeatsCache.heartbeats=i,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}catch(e){return J.warn(e),""}}}function me(){return(new Date).toISOString().substring(0,10)}class be{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!l()&&u().then((()=>!0)).catch((()=>!1))}async read(){if(await this._canUseIndexedDBPromise){const e=await async function(e){try{const t=(await pe()).transaction(ue),n=await t.objectStore(ue).get(he(e));return await t.done,n}catch(e){if(e instanceof d)J.warn(e.message);else{const t=re.create("idb-get",{originalErrorMessage:null==e?void 0:e.message});J.warn(t.message)}}}(this.app);return(null==e?void 0:e.heartbeats)?e:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const n=await this.read();return fe(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){const n=await this.read();return fe(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:[...n.heartbeats,...e.heartbeats]})}}}function we(e){return a(JSON.stringify({version:2,heartbeats:e})).length}ne(new b("platform-logger",(e=>new z(e)),"PRIVATE")),ne(new b("heartbeat",(e=>new ge(e)),"PRIVATE")),se(q,G,""),se(q,G,"esm2017"),se("fire-js",""),se("firebase","11.0.1","app");const ye="@firebase/installations",ve="0.6.10",Se=1e4,Ie=`w:${ve}`,_e="FIS_v2",Ee="https://firebaseinstallations.googleapis.com/v1",Ce=36e5,De=new p("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function ke(e){return e instanceof d&&e.code.includes("request-failed")}function Te({projectId:e}){return`${Ee}/projects/${e}/installations`}function Ae(e){return{token:e.token,requestStatus:2,expiresIn:(t=e.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()};var t}async function Oe(e,t){const n=(await t.json()).error;return De.create("request-failed",{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function Me({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}async function Be(e){const t=await e();return t.status>=500&&t.status<600?e():t}function Ne(e){return new Promise((t=>{setTimeout(t,e)}))}const je=/^[cdef][\w-]{21}$/,Pe="";function Le(){try{const e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;const t=function(e){var t;return(t=e,btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_")).substr(0,22)}(e);return je.test(t)?t:Pe}catch(e){return Pe}}function $e(e){return`${e.appName}!${e.appId}`}const He=new Map;function Fe(e,t){const n=$e(e);Re(n,t),function(e,t){const n=(!xe&&"BroadcastChannel"in self&&(xe=new BroadcastChannel("[Firebase] FID Change"),xe.onmessage=e=>{Re(e.data.key,e.data.fid)}),xe);n&&n.postMessage({key:e,fid:t}),0===He.size&&xe&&(xe.close(),xe=null)}(n,t)}function Re(e,t){const n=He.get(e);if(n)for(const e of n)e(t)}let xe=null;const Ve="firebase-installations-database",Ke=1,Ue="firebase-installations-store";let We=null;function ze(){return We||(We=F(Ve,Ke,{upgrade:(e,t)=>{0===t&&e.createObjectStore(Ue)}})),We}async function qe(e,t){const n=$e(e),i=(await ze()).transaction(Ue,"readwrite"),r=i.objectStore(Ue),a=await r.get(n);return await r.put(t,n),await i.done,a&&a.fid===t.fid||Fe(e,t.fid),t}async function Ge(e){const t=$e(e),n=(await ze()).transaction(Ue,"readwrite");await n.objectStore(Ue).delete(t),await n.done}async function Je(e,t){const n=$e(e),i=(await ze()).transaction(Ue,"readwrite"),r=i.objectStore(Ue),a=await r.get(n),o=t(a);return void 0===o?await r.delete(n):await r.put(o,n),await i.done,!o||a&&a.fid===o.fid||Fe(e,o.fid),o}async function Ye(e){let t;const n=await Je(e.appConfig,(n=>{const i=function(e){return Ze(e||{fid:Le(),registrationStatus:0})}(n),r=function(e,t){if(0===t.registrationStatus){if(!navigator.onLine)return{installationEntry:t,registrationPromise:Promise.reject(De.create("app-offline"))};const n={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},i=async function(e,t){try{const n=await async function({appConfig:e,heartbeatServiceProvider:t},{fid:n}){const i=Te(e),r=Me(e),a=t.getImmediate({optional:!0});if(a){const e=await a.getHeartbeatsHeader();e&&r.append("x-firebase-client",e)}const o={fid:n,authVersion:_e,appId:e.appId,sdkVersion:Ie},s={method:"POST",headers:r,body:JSON.stringify(o)},c=await Be((()=>fetch(i,s)));if(c.ok){const e=await c.json();return{fid:e.fid||n,registrationStatus:2,refreshToken:e.refreshToken,authToken:Ae(e.authToken)}}throw await Oe("Create Installation",c)}(e,t);return qe(e.appConfig,n)}catch(n){throw ke(n)&&409===n.customData.serverCode?await Ge(e.appConfig):await qe(e.appConfig,{fid:t.fid,registrationStatus:0}),n}}(e,n);return{installationEntry:n,registrationPromise:i}}return 1===t.registrationStatus?{installationEntry:t,registrationPromise:Qe(e)}:{installationEntry:t}}(e,i);return t=r.registrationPromise,r.installationEntry}));return n.fid===Pe?{installationEntry:await t}:{installationEntry:n,registrationPromise:t}}async function Qe(e){let t=await Xe(e.appConfig);for(;1===t.registrationStatus;)await Ne(100),t=await Xe(e.appConfig);if(0===t.registrationStatus){const{installationEntry:t,registrationPromise:n}=await Ye(e);return n||t}return t}function Xe(e){return Je(e,(e=>{if(!e)throw De.create("installation-not-found");return Ze(e)}))}function Ze(e){return 1===(t=e).registrationStatus&&t.registrationTime+Se<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function et({appConfig:e,heartbeatServiceProvider:t},n){const i=function(e,{fid:t}){return`${Te(e)}/${t}/authTokens:generate`}(e,n),r=function(e,{refreshToken:t}){const n=Me(e);return n.append("Authorization",function(e){return`${_e} ${e}`}(t)),n}(e,n),a=t.getImmediate({optional:!0});if(a){const e=await a.getHeartbeatsHeader();e&&r.append("x-firebase-client",e)}const o={installation:{sdkVersion:Ie,appId:e.appId}},s={method:"POST",headers:r,body:JSON.stringify(o)},c=await Be((()=>fetch(i,s)));if(c.ok)return Ae(await c.json());throw await Oe("Generate Auth Token",c)}async function tt(e,t=!1){let n;const i=await Je(e.appConfig,(i=>{if(!it(i))throw De.create("not-registered");const r=i.authToken;if(!t&&(2===(a=r).requestStatus&&!function(e){const t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+Ce}(a)))return i;var a;if(1===r.requestStatus)return n=async function(e,t){let n=await nt(e.appConfig);for(;1===n.authToken.requestStatus;)await Ne(100),n=await nt(e.appConfig);const i=n.authToken;return 0===i.requestStatus?tt(e,t):i}(e,t),i;{if(!navigator.onLine)throw De.create("app-offline");const t=function(e){const t={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},e),{authToken:t})}(i);return n=async function(e,t){try{const n=await et(e,t),i=Object.assign(Object.assign({},t),{authToken:n});return await qe(e.appConfig,i),n}catch(n){if(!ke(n)||401!==n.customData.serverCode&&404!==n.customData.serverCode){const n=Object.assign(Object.assign({},t),{authToken:{requestStatus:0}});await qe(e.appConfig,n)}else await Ge(e.appConfig);throw n}}(e,t),t}}));return n?await n:i.authToken}function nt(e){return Je(e,(e=>{if(!it(e))throw De.create("not-registered");return 1===(t=e.authToken).requestStatus&&t.requestTime+Se<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e;var t}))}function it(e){return void 0!==e&&2===e.registrationStatus}function rt(e){return De.create("missing-app-config-values",{valueName:e})}const at="installations";ne(new b(at,(e=>{const t=e.getProvider("app").getImmediate(),n=function(e){if(!e||!e.options)throw rt("App Configuration");if(!e.name)throw rt("App Name");const t=["projectId","apiKey","appId"];for(const n of t)if(!e.options[n])throw rt(n);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t);return{app:t,appConfig:n,heartbeatServiceProvider:ie(t,"heartbeat"),_delete:()=>Promise.resolve()}}),"PUBLIC")),ne(new b("installations-internal",(e=>{const t=ie(e.getProvider("app").getImmediate(),at).getImmediate();return{getId:()=>async function(e){const t=e,{installationEntry:n,registrationPromise:i}=await Ye(t);return i?i.catch(console.error):tt(t).catch(console.error),n.fid}(t),getToken:e=>async function(e,t=!1){const n=e;return await async function(e){const{registrationPromise:t}=await Ye(e);t&&await t}(n),(await tt(n,t)).token}(t,e)}}),"PRIVATE")),se(ye,ve),se(ye,ve,"esm2017");const ot="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",st="https://fcmregistrations.googleapis.com/v1",ct="FCM_MSG",lt=3,ut=1;var dt,pt;function ft(e){const t=new Uint8Array(e);return btoa(String.fromCharCode(...t)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function ht(e){const t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=atob(t),i=new Uint8Array(n.length);for(let e=0;e<n.length;++e)i[e]=n.charCodeAt(e);return i}!function(e){e[e.DATA_MESSAGE=1]="DATA_MESSAGE",e[e.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION"}(dt||(dt={})),function(e){e.PUSH_RECEIVED="push-received",e.NOTIFICATION_CLICKED="notification-clicked"}(pt||(pt={}));const gt="fcm_token_details_db",mt=5,bt="fcm_token_object_Store",wt="firebase-messaging-database",yt=1,vt="firebase-messaging-store";let St=null;function It(){return St||(St=F(wt,yt,{upgrade:(e,t)=>{0===t&&e.createObjectStore(vt)}})),St}async function _t(e){const t=Ct(e),n=await It(),i=await n.transaction(vt).objectStore(vt).get(t);if(i)return i;{const t=await async function(e){if("databases"in indexedDB){const e=(await indexedDB.databases()).map((e=>e.name));if(!e.includes(gt))return null}let t=null;return(await F(gt,mt,{upgrade:async(n,i,r,a)=>{var o;if(i<2)return;if(!n.objectStoreNames.contains(bt))return;const s=a.objectStore(bt),c=await s.index("fcmSenderId").get(e);if(await s.clear(),c)if(2===i){const e=c;if(!e.auth||!e.p256dh||!e.endpoint)return;t={token:e.fcmToken,createTime:null!==(o=e.createTime)&&void 0!==o?o:Date.now(),subscriptionOptions:{auth:e.auth,p256dh:e.p256dh,endpoint:e.endpoint,swScope:e.swScope,vapidKey:"string"==typeof e.vapidKey?e.vapidKey:ft(e.vapidKey)}}}else if(3===i){const e=c;t={token:e.fcmToken,createTime:e.createTime,subscriptionOptions:{auth:ft(e.auth),p256dh:ft(e.p256dh),endpoint:e.endpoint,swScope:e.swScope,vapidKey:ft(e.vapidKey)}}}else if(4===i){const e=c;t={token:e.fcmToken,createTime:e.createTime,subscriptionOptions:{auth:ft(e.auth),p256dh:ft(e.p256dh),endpoint:e.endpoint,swScope:e.swScope,vapidKey:ft(e.vapidKey)}}}}})).close(),await R(gt),await R("fcm_vapid_details_db"),await R("undefined"),function(e){if(!e||!e.subscriptionOptions)return!1;const{subscriptionOptions:t}=e;return"number"==typeof e.createTime&&e.createTime>0&&"string"==typeof e.token&&e.token.length>0&&"string"==typeof t.auth&&t.auth.length>0&&"string"==typeof t.p256dh&&t.p256dh.length>0&&"string"==typeof t.endpoint&&t.endpoint.length>0&&"string"==typeof t.swScope&&t.swScope.length>0&&"string"==typeof t.vapidKey&&t.vapidKey.length>0}(t)?t:null}(e.appConfig.senderId);if(t)return await Et(e,t),t}}async function Et(e,t){const n=Ct(e),i=(await It()).transaction(vt,"readwrite");return await i.objectStore(vt).put(t,n),await i.done,t}function Ct({appConfig:e}){return e.appId}const Dt=new p("messaging","Messaging",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"only-available-in-window":"This method is available in a Window context.","only-available-in-sw":"This method is available in a service worker context.","permission-default":"The notification permission was not granted and dismissed instead.","permission-blocked":"The notification permission was not granted and blocked instead.","unsupported-browser":"This browser doesn't support the API's required to use the Firebase SDK.","indexed-db-unsupported":"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)","failed-service-worker-registration":"We are unable to register the default service worker. {$browserErrorMessage}","token-subscribe-failed":"A problem occurred while subscribing the user to FCM: {$errorInfo}","token-subscribe-no-token":"FCM returned no token when subscribing the user to push.","token-unsubscribe-failed":"A problem occurred while unsubscribing the user from FCM: {$errorInfo}","token-update-failed":"A problem occurred while updating the user from FCM: {$errorInfo}","token-update-no-token":"FCM returned no token when updating the user to push.","use-sw-after-get-token":"The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.","invalid-sw-registration":"The input to useServiceWorker() must be a ServiceWorkerRegistration.","invalid-bg-handler":"The input to setBackgroundMessageHandler() must be a function.","invalid-vapid-key":"The public VAPID key must be a string.","use-vapid-key-after-get-token":"The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used."});async function kt(e,t){const n={method:"DELETE",headers:await At(e)};try{const i=await fetch(`${Tt(e.appConfig)}/${t}`,n),r=await i.json();if(r.error){const e=r.error.message;throw Dt.create("token-unsubscribe-failed",{errorInfo:e})}}catch(e){throw Dt.create("token-unsubscribe-failed",{errorInfo:null==e?void 0:e.toString()})}}function Tt({projectId:e}){return`${st}/projects/${e}/registrations`}async function At({appConfig:e,installations:t}){const n=await t.getToken();return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e.apiKey,"x-goog-firebase-installations-auth":`FIS ${n}`})}function Ot({p256dh:e,auth:t,endpoint:n,vapidKey:i}){const r={web:{endpoint:n,auth:t,p256dh:e}};return i!==ot&&(r.web.applicationPubKey=i),r}async function Mt(e){const t=await _t(e.firebaseDependencies);t&&(await kt(e.firebaseDependencies,t.token),await async function(e){const t=Ct(e),n=(await It()).transaction(vt,"readwrite");await n.objectStore(vt).delete(t),await n.done}(e.firebaseDependencies));const n=await e.swRegistration.pushManager.getSubscription();return!n||n.unsubscribe()}async function Bt(e,t){const n=await async function(e,t){const n=await At(e),i=Ot(t),r={method:"POST",headers:n,body:JSON.stringify(i)};let a;try{const t=await fetch(Tt(e.appConfig),r);a=await t.json()}catch(e){throw Dt.create("token-subscribe-failed",{errorInfo:null==e?void 0:e.toString()})}if(a.error){const e=a.error.message;throw Dt.create("token-subscribe-failed",{errorInfo:e})}if(!a.token)throw Dt.create("token-subscribe-no-token");return a.token}(e,t),i={token:n,createTime:Date.now(),subscriptionOptions:t};return await Et(e,i),i.token}async function Nt(e,t){const n=function({data:e}){if(!e)return null;try{return e.json()}catch(e){return null}}(e);if(!n)return;t.deliveryMetricsExportedToBigQueryEnabled&&await async function(e,t){const n=function(e,t){var n,i;const r={};return e.from&&(r.project_number=e.from),e.fcmMessageId&&(r.message_id=e.fcmMessageId),r.instance_id=t,e.notification?r.message_type=dt.DISPLAY_NOTIFICATION.toString():r.message_type=dt.DATA_MESSAGE.toString(),r.sdk_platform=lt.toString(),r.package_name=self.origin.replace(/(^\w+:|^)\/\//,""),!e.collapse_key||(r.collapse_key=e.collapse_key),r.event=ut.toString(),!(null===(n=e.fcmOptions)||void 0===n?void 0:n.analytics_label)||(r.analytics_label=null===(i=e.fcmOptions)||void 0===i?void 0:i.analytics_label),r}(t,await e.firebaseDependencies.installations.getId());!function(e,t,n){const i={};i.event_time_ms=Math.floor(Date.now()).toString(),i.source_extension_json_proto3=JSON.stringify({messaging_client_event:t}),!n||(i.compliance_data=function(e){return{privacy_context:{prequest:{origin_associated_product_id:e}}}}(n)),e.logEvents.push(i)}(e,n,t.productId)}(t,n);const i=await jt();if(function(e){return e.some((e=>"visible"===e.visibilityState&&!e.url.startsWith("chrome-extension://")))}(i))return function(e,t){t.isFirebaseMessaging=!0,t.messageType=pt.PUSH_RECEIVED;for(const n of e)n.postMessage(t)}(i,n);if(n.notification&&await function(e){var t;const{actions:n}=e,{maxActions:i}=Notification;return n&&i&&n.length>i&&console.warn(`This browser only supports ${i} actions. The remaining actions will not be displayed.`),self.registration.showNotification(null!==(t=e.title)&&void 0!==t?t:"",e)}(function(e){const t=Object.assign({},e.notification);return t.data={[ct]:e},t}(n)),t&&t.onBackgroundMessageHandler){const e=function(e){const t={from:e.from,collapseKey:e.collapse_key,messageId:e.fcmMessageId};return function(e,t){if(!t.notification)return;e.notification={};const n=t.notification.title;n&&(e.notification.title=n);const i=t.notification.body;i&&(e.notification.body=i);const r=t.notification.image;r&&(e.notification.image=r);const a=t.notification.icon;a&&(e.notification.icon=a)}(t,e),function(e,t){t.data&&(e.data=t.data)}(t,e),function(e,t){var n,i,r,a,o;if(!t.fcmOptions&&!(null===(n=t.notification)||void 0===n?void 0:n.click_action))return;e.fcmOptions={};const s=null!==(r=null===(i=t.fcmOptions)||void 0===i?void 0:i.link)&&void 0!==r?r:null===(a=t.notification)||void 0===a?void 0:a.click_action;s&&(e.fcmOptions.link=s);const c=null===(o=t.fcmOptions)||void 0===o?void 0:o.analytics_label;c&&(e.fcmOptions.analyticsLabel=c)}(t,e),t}(n);"function"==typeof t.onBackgroundMessageHandler?await t.onBackgroundMessageHandler(e):t.onBackgroundMessageHandler.next(e)}}function jt(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function Pt(e){return Dt.create("missing-app-config-values",{valueName:e})}!function(e,t){const n=[];for(let i=0;i<20;i++)n.push(e.charAt(i)),i<19&&n.push(t.charAt(i));n.join("")}("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class Lt{constructor(e,t,n){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;const i=function(e){if(!e||!e.options)throw Pt("App Configuration Object");if(!e.name)throw Pt("App Name");const t=["projectId","apiKey","appId","messagingSenderId"],{options:n}=e;for(const e of t)if(!n[e])throw Pt(e);return{appName:e.name,projectId:n.projectId,apiKey:n.apiKey,appId:n.appId,senderId:n.messagingSenderId}}(e);this.firebaseDependencies={app:e,appConfig:i,installations:t,analyticsProvider:n}}_delete(){return Promise.resolve()}}function $t(e=function(e=Y){const t=X.get(e);if(!t&&e===Y&&s())return oe();if(!t)throw re.create("no-app",{appName:e});return t}()){return async function(){return l()&&await u()&&"PushManager"in self&&"Notification"in self&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}().then((e=>{if(!e)throw Dt.create("unsupported-browser")}),(e=>{throw Dt.create("indexed-db-unsupported")})),ie(m(e),"messaging-sw").getImmediate()}function Ht(e,t){return function(e,t){if(void 0!==self.document)throw Dt.create("only-available-in-sw");return e.onBackgroundMessageHandler=t,()=>{e.onBackgroundMessageHandler=null}}(e=m(e),t)}ne(new b("messaging-sw",(e=>{const t=new Lt(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return self.addEventListener("push",(e=>{e.waitUntil(Nt(e,t))})),self.addEventListener("pushsubscriptionchange",(e=>{e.waitUntil(async function(e,t){var n,i;const{newSubscription:r}=e;if(!r)return void await Mt(t);const a=await _t(t.firebaseDependencies);await Mt(t),t.vapidKey=null!==(i=null===(n=null==a?void 0:a.subscriptionOptions)||void 0===n?void 0:n.vapidKey)&&void 0!==i?i:ot,await async function(e){const t=await async function(e,t){return await e.pushManager.getSubscription()||e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:ht(t)})}(e.swRegistration,e.vapidKey),n={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:ft(t.getKey("auth")),p256dh:ft(t.getKey("p256dh"))},i=await _t(e.firebaseDependencies);if(i){if(function(e,t){const n=t.vapidKey===e.vapidKey,i=t.endpoint===e.endpoint,r=t.auth===e.auth,a=t.p256dh===e.p256dh;return n&&i&&r&&a}(i.subscriptionOptions,n))return Date.now()>=i.createTime+6048e5?async function(e,t){try{const n=await async function(e,t){const n=await At(e),i=Ot(t.subscriptionOptions),r={method:"PATCH",headers:n,body:JSON.stringify(i)};let a;try{const n=await fetch(`${Tt(e.appConfig)}/${t.token}`,r);a=await n.json()}catch(e){throw Dt.create("token-update-failed",{errorInfo:null==e?void 0:e.toString()})}if(a.error){const e=a.error.message;throw Dt.create("token-update-failed",{errorInfo:e})}if(!a.token)throw Dt.create("token-update-no-token");return a.token}(e.firebaseDependencies,t),i=Object.assign(Object.assign({},t),{token:n,createTime:Date.now()});return await Et(e.firebaseDependencies,i),n}catch(e){throw e}}(e,{token:i.token,createTime:Date.now(),subscriptionOptions:n}):i.token;try{await kt(e.firebaseDependencies,i.token)}catch(e){console.warn(e)}return Bt(e.firebaseDependencies,n)}return Bt(e.firebaseDependencies,n)}(t)}(e,t))})),self.addEventListener("notificationclick",(e=>{e.waitUntil(async function(e){var t,n;const i=null===(n=null===(t=e.notification)||void 0===t?void 0:t.data)||void 0===n?void 0:n[ct];if(!i)return;if(e.action)return;e.stopImmediatePropagation(),e.notification.close();const r=function(e){var t,n,i;return(null!==(n=null===(t=e.fcmOptions)||void 0===t?void 0:t.link)&&void 0!==n?n:null===(i=e.notification)||void 0===i?void 0:i.click_action)||("object"==typeof(r=e.data)&&r&&"google.c.a.c_id"in r?self.location.origin:null);var r}(i);if(!r)return;const a=new URL(r,self.location.href),o=new URL(self.location.origin);if(a.host!==o.host)return;let s=await async function(e){const t=await jt();for(const n of t){const t=new URL(n.url,self.location.href);if(e.host===t.host)return n}return null}(a);return s?s=await s.focus():(s=await self.clients.openWindow(r),await new Promise((e=>{setTimeout(e,3e3)}))),s?(i.messageType=pt.NOTIFICATION_CLICKED,i.isFirebaseMessaging=!0,s.postMessage(i)):void 0}(e))})),t}),"PUBLIC")),module.exports=t})();
@@ -1,162 +0,0 @@
1
- import Promise from "bluebird"
2
- import {ReactNode} from "react"
3
- import debug from "debug"
4
- import {createContext, useContext, useState, useRef, useEffect} from "react"
5
-
6
- import {EVENTS, UPLOAD_MAX_CONCURRENCY} from "./constants"
7
-
8
-
9
- const log = debug("drive:upload_context")
10
-
11
- export const FileUploadContext = createContext()
12
-
13
- export const FileUploadContextProvider = ({
14
- onUploadComplete,
15
- children,
16
- }: {
17
- onUploadComplete?: (files: any) => Promise<void>,
18
- children: ReactNode,
19
- }) => {
20
- const workerRef = useRef(null)
21
-
22
- const [canUpload, setCanUpload] = useState(false)
23
- const [isUploading, setIsUploading] = useState(false)
24
- const [selectedFiles, setSelectedFiles] = useState([])
25
- const [processedFiles, setProcessedFiles] = useState(Object.create(null))
26
-
27
- const pendingUploadCallbacksRef = useRef({})
28
-
29
-
30
- const updateProcessedFile = (filename, payload) => {
31
- setProcessedFiles((previousProcessedFiles) => {
32
- const nextProcessedFiles = Object.create(null)
33
- Object.assign(nextProcessedFiles, previousProcessedFiles)
34
-
35
- if (!nextProcessedFiles[filename]) nextProcessedFiles[filename] = {}
36
-
37
- Object.assign(nextProcessedFiles[filename], payload)
38
- return nextProcessedFiles
39
- })
40
- }
41
-
42
- // when all files are ready to upload update parent context
43
- useEffect(() => {
44
- if (!(Object.keys(processedFiles).length > 0)) return
45
-
46
- let isComplete = true
47
- Object.keys(processedFiles).forEach((k) => {
48
- if (processedFiles[k]?.status !== EVENTS.HASH_COMPLETE) {
49
- isComplete = false
50
- }
51
- })
52
-
53
- if (isComplete && !canUpload) {
54
- // wait a bit for transitions to finish
55
- setTimeout(() => {
56
- setCanUpload(true)
57
- }, 300)
58
- }
59
- }, [processedFiles, canUpload, setCanUpload])
60
-
61
- useEffect(() => {
62
- workerRef.current = new Worker(
63
- new URL("./upload-worker/index.js", import.meta.url),
64
- )
65
-
66
- const onMessage = async({data}) => {
67
- log("worker message:", data)
68
- const {type, payload} = data
69
-
70
- if (type === EVENTS.UPLOAD_COMPLETE) {
71
- const {filename, hash} = payload
72
- updateProcessedFile(filename, {
73
- status: EVENTS.UPLOAD_COMPLETE,
74
- })
75
- const cb = pendingUploadCallbacksRef.current[hash]
76
- cb.resolve()
77
- } else if (type === EVENTS.UPLOAD_ERROR) {
78
- const cb = pendingUploadCallbacksRef.current[hash]
79
- cb.reject()
80
- } else if ([EVENTS.HASH_PROGRESS, EVENTS.HASH_COMPLETE].includes(type)) {
81
- //
82
- console.log("got hash event", type, payload)
83
- } else {
84
- throw new Error("unknown message event type")
85
- }
86
- }
87
-
88
- workerRef.current.addEventListener("message", onMessage)
89
-
90
- return () => {
91
- workerRef.current.removeEventListener("message", onMessage)
92
- }
93
- }, [])
94
-
95
-
96
- const startUploadAndWait = ({file, hash}) => new Promise((resolve, reject) => {
97
- console.log("startUploadAndWait", {file, hash})
98
-
99
- workerRef.current.postMessage({type: EVENTS.UPLOAD_FILE, file, hash})
100
-
101
- pendingUploadCallbacksRef.current[hash] = {resolve, reject}
102
- })
103
-
104
-
105
- const uploadAllFiles = async() => {
106
- setCanUpload(false)
107
- setIsUploading(true)
108
-
109
- const getUploadFiles = () => selectedFiles.map((f) => {
110
- const processedFile = processedFiles[f.name]
111
- if (!processedFile) {
112
- throw new Error(`unable to retrieve processed file: ${f.name}`)
113
- }
114
-
115
- return {
116
- file: f,
117
- ...processedFile,
118
- }
119
- })
120
-
121
- await Promise.map(
122
- getUploadFiles(), startUploadAndWait,
123
- {concurrency: UPLOAD_MAX_CONCURRENCY}
124
- )
125
-
126
- if (typeof onUploadComplete === "function") {
127
- await onUploadComplete(getUploadFiles())
128
- }
129
-
130
- setCanUpload(true)
131
- setIsUploading(false)
132
- setSelectedFiles([])
133
- setProcessedFiles(Object.create(null))
134
-
135
- }
136
-
137
- return (
138
- <FileUploadContext.Provider
139
- value={{
140
- workerRef,
141
- //
142
- canUpload,
143
- setCanUpload,
144
- //
145
- isUploading,
146
- setIsUploading,
147
- //
148
- selectedFiles,
149
- setSelectedFiles,
150
- //
151
- processedFiles,
152
- updateProcessedFile,
153
- //
154
- uploadAllFiles,
155
- }}
156
- >
157
- {children}
158
- </FileUploadContext.Provider>
159
- )
160
- }
161
-
162
- export const useFileUploadContext = () => useContext(FileUploadContext)
@@ -1,139 +0,0 @@
1
- import assert from "assert"
2
- import {useEffect} from "react"
3
- import _set from "lodash/set"
4
-
5
- import {formatFileSize} from "@rpcbase/std"
6
-
7
- import {useFileUploadContext} from "../FileUploadContext"
8
-
9
- import usePreventUnload from "./usePreventUnload"
10
-
11
- import {EVENTS} from "../constants"
12
-
13
-
14
- const STATUS_MESSAGES = {
15
- HASH_COMPLETE: "Ready to upload!",
16
- HASHING: "Checking file...",
17
- }
18
-
19
- const FileUploadForm = () => {
20
- const {workerRef,
21
- selectedFiles,
22
- setSelectedFiles, processedFiles, updateProcessedFile} = useFileUploadContext()
23
-
24
- usePreventUnload()
25
-
26
- useEffect(() => {
27
- if (!workerRef.current) return
28
-
29
- const onMessage = ({data: {type, payload}}) => {
30
- // done hashing
31
- if (type === EVENTS.HASH_COMPLETE) {
32
- const {filename, hash} = payload
33
- updateProcessedFile(filename, {
34
- status: EVENTS.HASH_COMPLETE,
35
- hash,
36
- progress: 100,
37
- })
38
- }
39
- // hash_progress
40
- else if (type === EVENTS.HASH_PROGRESS) {
41
- updateProcessedFile(payload.filename, {
42
- status: EVENTS.HASHING,
43
- progress: payload.progress,
44
- })
45
- }
46
- }
47
-
48
- workerRef.current.addEventListener("message", onMessage)
49
-
50
- return () => {
51
- workerRef.current.removeEventListener("message", onMessage)
52
- }
53
- }, [workerRef.current])
54
-
55
- const onClickPicker = async() => {
56
- const dirHandle = await window.showDirectoryPicker({
57
- startIn: "desktop",
58
- })
59
- console.log("got dir hanlde", dirHandle)
60
- }
61
-
62
- useEffect(() => {}, [selectedFiles])
63
-
64
- const onFilesChange = (e) => {
65
- const {files} = e.target
66
-
67
- // TODO: we should have a way to limit to a maximum number of hashes at the same time
68
- Array.from(files).forEach((file) => {
69
- assert(file.webkitRelativePath === "", "expected webkitRelativePath to be ''")
70
-
71
- workerRef.current.postMessage({type: EVENTS.BEGIN_HASH, file})
72
- })
73
- setSelectedFiles(Array.from(files))
74
- }
75
-
76
- return (
77
- <div className="px-3">
78
- <div className="mb-3">
79
- <label htmlFor="file-upload-input-files" className="form-label fw-bold">
80
- Add Files
81
- </label>
82
- <input
83
- className="form-control"
84
- type="file"
85
- id="file-upload-input-files"
86
- accept="*"
87
- multiple
88
- onChange={onFilesChange}
89
- />
90
- </div>
91
-
92
- <div className="text-secondary">OR</div>
93
-
94
- <button
95
- className="btn btn-light mt-2 d-flex flex-row align-items-center"
96
- onClick={onClickPicker}
97
- >
98
- <img src="/static/icons/drive/folder-xs.svg" />
99
- <span className="ms-2">Upload a Folder</span>
100
- </button>
101
-
102
- {selectedFiles.length > 0 && <hr className="mt-4" />}
103
-
104
- <div className="files-list">
105
- {selectedFiles.map((f, i) => {
106
- const progress = processedFiles[f.name]?.progress || 0
107
- const status = STATUS_MESSAGES[processedFiles[f.name]?.status] || "Preparing..."
108
-
109
- return (
110
- <div key={`file-${i}`}>
111
- <div className="d-flex flex-row align-items-center mx-2 mt-3 mb-1">
112
- <img src="/static/icons/drive/file-xs.svg" />
113
- <div className="ms-2 text-truncate">{f.name}</div>
114
- <div className="ms-2 text-secondary text-monospace">{formatFileSize(f.size)}</div>
115
- </div>
116
-
117
- <div className="d-flex flex-row align-items-center">
118
- <div className="progress mt-0" style={{width: 120}}>
119
- <div
120
- className="progress-bar"
121
- role="progressbar"
122
- style={{width: `${progress}%`}}
123
- aria-valuenow={progress}
124
- aria-valuemin={0}
125
- aria-valuemax={100}
126
- />
127
- </div>
128
- <div className="ms-2 text-secondary">{progress}&nbsp;%</div>
129
- <div className="ms-2 text-secondary">Status: {status}</div>
130
- </div>
131
- </div>
132
- )
133
- })}
134
- </div>
135
- </div>
136
- )
137
- }
138
-
139
- export default FileUploadForm
@@ -1,21 +0,0 @@
1
- /* eslint-disable react-hooks/rules-of-hooks */
2
- /* @flow */
3
- import {useEffect} from "react"
4
-
5
-
6
- const usePreventUnload = () => {
7
- if (__DEV__) return
8
-
9
- useEffect(() => {
10
- const onBeforeUnload = (e) => {
11
- e.preventDefault()
12
- e.returnValue = ""
13
- }
14
-
15
- window.addEventListener("beforeunload", onBeforeUnload)
16
-
17
- return () => window.removeEventListener("beforeunload", onBeforeUnload)
18
- }, [])
19
- }
20
-
21
- export default usePreventUnload
@@ -1,23 +0,0 @@
1
- import {SubmitButton} from "../SubmitButton"
2
- import {useFileUploadContext} from "./FileUploadContext"
3
-
4
-
5
- export const UploadButton = () => {
6
- const {canUpload, isUploading, uploadAllFiles} =
7
- useFileUploadContext()
8
-
9
- const onStartUpload = async() => {
10
- await uploadAllFiles()
11
- }
12
-
13
- return (
14
- <SubmitButton
15
- id="file-start-upload-button"
16
- disabled={!canUpload}
17
- isLoading={isUploading}
18
- onClick={onStartUpload}
19
- title="Start Upload"
20
- submittingTitle="Uploading Files..."
21
- />
22
- )
23
- }
@@ -1,16 +0,0 @@
1
- export const UPLOAD_MAX_CONCURRENCY = 1
2
-
3
- export const HASH_CHUNK_SIZE = 2 * 1024 * 1024 // 1 MB
4
-
5
- // must match server chunk size to avoid mongodb chunking again
6
- export const UPLOAD_CHUNK_SIZE = 1 * 1024 * 1024 // 1MB
7
-
8
- export const EVENTS = {
9
- BEGIN_HASH: "BEGIN_HASH",
10
- HASH_PROGRESS: "HASH_PROGRESS",
11
- HASHING: "HASHING",
12
- HASH_COMPLETE: "HASH_COMPLETE",
13
- UPLOAD_FILE: "UPLOAD_FILE",
14
- UPLOAD_COMPLETE: "UPLOAD_COMPLETE",
15
- UPLOAD_ERROR: "UPLOAD_ERROR",
16
- }
@@ -1 +0,0 @@
1
- @import "helpers";
@@ -1,21 +0,0 @@
1
- import {FileUploadContextProvider} from "./FileUploadContext"
2
- import FileUploadForm from "./FileUploadForm"
3
- import {UploadButton} from "./UploadButton"
4
-
5
- import "./file-input.scss"
6
-
7
-
8
- export const FileInput = ({
9
- onUploadComplete,
10
- }: {
11
- onUploadComplete?: (files: any) => void | Promise<void>
12
- }) => {
13
-
14
- return (
15
- <FileUploadContextProvider onUploadComplete={onUploadComplete}>
16
- <FileUploadForm />
17
-
18
- <UploadButton />
19
- </FileUploadContextProvider>
20
- )
21
- }
@@ -1,63 +0,0 @@
1
- /* @flow */
2
- // import {createXXHash128} from "hash-wasm/dist/xxhash128.umd.min.js"
3
- import {createXXHash128} from "hash-wasm-xxhash128"
4
-
5
- import {EVENTS, HASH_CHUNK_SIZE} from "../constants"
6
-
7
- // read and hash the file
8
- const get_file_hash = async(file) => {
9
- if (!file) return
10
-
11
- const hasher = await createXXHash128()
12
-
13
- const reader = new FileReader()
14
- const size = file.size
15
- let chunks_count = 0
16
-
17
- let offset = 0
18
- let bytes_read = 0
19
-
20
- reader.onloadend = async(e) => {
21
- if (e.target.readyState === FileReader.DONE) {
22
- const chunk = new Uint8Array(e.target.result)
23
- bytes_read += chunk.length
24
-
25
- chunks_count++
26
-
27
- console.log(`${chunks_count} hash chunks // ${bytes_read} bytes_read...`)
28
-
29
- await hasher.update(chunk)
30
-
31
- self.postMessage({
32
- type: EVENTS.HASH_PROGRESS,
33
- payload: {
34
- // TODO: use relative path here as well in case we have two same filenames from two dirs
35
- filename: file.name,
36
- progress: ((bytes_read / size) * 100).toFixed(1),
37
- },
38
- })
39
-
40
- if (offset < size) {
41
- offset += HASH_CHUNK_SIZE
42
- const blob = file.slice(offset, offset + HASH_CHUNK_SIZE)
43
- reader.readAsArrayBuffer(blob)
44
- } else {
45
- const hash = hasher.digest()
46
-
47
- self.postMessage({
48
- type: EVENTS.HASH_COMPLETE,
49
- payload: {
50
- filename: file.name,
51
- hash,
52
- },
53
- })
54
- }
55
- }
56
- }
57
-
58
- const blob = file.slice(offset, offset + HASH_CHUNK_SIZE)
59
-
60
- reader.readAsArrayBuffer(blob)
61
- }
62
-
63
- export default get_file_hash
@@ -1,16 +0,0 @@
1
- /* @flow */
2
- import upload_file from "./upload_file"
3
- import get_file_hash from "./get_file_hash"
4
-
5
- import {EVENTS} from "../constants"
6
-
7
-
8
- self.onmessage = ({data: {file, type, hash}}) => {
9
- if (type === EVENTS.BEGIN_HASH) {
10
- get_file_hash(file)
11
- } else if (type === EVENTS.UPLOAD_FILE) {
12
- upload_file(file, hash)
13
- } else {
14
- console.log("upload worker: unknown message", type)
15
- }
16
- }
@@ -1,33 +0,0 @@
1
- // we consider these file types to be already compressed
2
- export const NO_COMPRESS_EXTS = [
3
- ".jpg",
4
- ".jpeg",
5
- ".png",
6
- ".gif",
7
- ".tif",
8
- ".tiff",
9
- ".webp",
10
- ".heif",
11
- ".heic",
12
- ".mp3",
13
- ".aac",
14
- ".ogg",
15
- ".flac",
16
- ".m4a",
17
- ".mp4",
18
- ".m4v",
19
- ".avi",
20
- ".mov",
21
- ".mkv",
22
- ".webm",
23
- ".zip",
24
- ".gzip",
25
- ".gz",
26
- ".rar",
27
- ".7z",
28
- ".bz2",
29
- ".tar.gz",
30
- ".tgz",
31
- ".jar",
32
- ".apk",
33
- ]