@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
@@ -1,100 +0,0 @@
1
- /* @flow */
2
- import debug from "debug"
3
-
4
- import "./debug"
5
-
6
- import {UNDERSCORE_PREFIX} from "./constants"
7
-
8
- import {get_collection} from "./get_collection"
9
- import update_docs from "./update_docs"
10
- import satisfies_projection from "./satisfies_projection"
11
- import replace_query_keys from "./replace_query_keys"
12
-
13
-
14
- const log = debug("rb:rts:store")
15
-
16
- // TODO: listening for changes
17
- // https://github.com/pouchdb/pouchdb/tree/master/packages/node_modules/pouchdb-find#dbcreateindexindex--callback
18
- // const res = await db.createIndex({
19
- // index: {fields: ["name"]}
20
- // })
21
- // // Listen for changes on the database
22
- // const fn = db.changes({
23
- // since: "now",
24
- // live: true,
25
- // include_docs: true
26
- // }).on("change", function(change) {
27
- // // handle change
28
- // console.log("GOT CHANGE", change)
29
- // }).on("error", function (err) {
30
- // // handle errors
31
- // console.log(err)
32
- // })
33
- // fn.cancel()
34
- // console.log("got res", res)
35
- // _cols_store[col_name].getIndexes().then(function (result) {
36
- // console.log("got indexes", result)
37
- // })
38
-
39
-
40
- // TODO: implement store in a shared worker
41
- // TODO: should we filter all docs by projection ? or just the ones where the projection isn't complete ?
42
- const run_query = async({model_name, query, options}, callback) => {
43
- log("run_query", {model_name, query, options})
44
- // console.time("store run_query")
45
-
46
- // TODO: we should prefix model_name with RB_TENANT_ID + env_id
47
- const collection = get_collection(model_name, options)
48
-
49
- const replaced_query = replace_query_keys(query, (k) => (k.startsWith("_") && k !== "_id") ? `${UNDERSCORE_PREFIX}${k}` : k)
50
-
51
- const find_query = {
52
- selector: replaced_query,
53
- // DO NOT INCLUDE FIELDS HERE AS IT USES PICK AND WE WOULD GO through the list twice
54
- // https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-find/src/adapters/local/find/index.js
55
- // fields: [""]
56
- }
57
-
58
- // console.time(`query-${model_name}`)
59
- // https://github.com/pouchdb/pouchdb/tree/master/packages/node_modules/pouchdb-find#dbcreateindexindex--callback
60
- const {docs} = await collection.find(find_query)
61
- // console.timeEnd(`query-${model_name}`)
62
-
63
- let mapped_docs = docs
64
- .map(({_rev, ...doc}) => {
65
- // TODO: handle projections here
66
- const remapped_doc = Object.entries(doc).reduce((new_doc, [key, value]) => {
67
- let new_key = key.startsWith("$_") ? key.replace(/^\$_/, "") : key
68
- new_doc[new_key] = value
69
- return new_doc
70
- }, {})
71
-
72
- return remapped_doc
73
- })
74
-
75
- if (options.projection) {
76
- mapped_docs = mapped_docs.filter((doc) => {
77
- return satisfies_projection(doc, options.projection)
78
- })
79
- }
80
-
81
- if (options.sort) {
82
- mapped_docs = mapped_docs.sort((a, b) => {
83
- for (const key in options.sort) {
84
- // Check if property exists on both objects
85
- if (Object.hasOwn(a, key) && Object.hasOwn(b, key)) {
86
- const dir = options.sort[key] // Direction of sorting: 1 or -1
87
-
88
- if (a[key] < b[key]) return -1 * dir
89
- if (a[key] > b[key]) return 1 * dir
90
- }
91
- }
92
- return 0
93
- })
94
- }
95
-
96
- callback(null, mapped_docs, {source: "cache"})
97
- }
98
-
99
-
100
- export default {run_query, update_docs}
@@ -1,30 +0,0 @@
1
- /* @flow */
2
-
3
-
4
- // WARNING: this is a bit of a toy implementation it's not certain it will work with complex queries where a field isn't referenced by being an object's key
5
- // TODO: this isn't right it's missing a lot of possible queries
6
- // https://chat.openai.com/share/da344eed-e3e1-4c8d-8091-cc26b22a8f2e
7
-
8
- const replace_query_keys = (obj, fn) => {
9
- if (typeof obj !== 'object' || obj === null) {
10
- return obj
11
- }
12
-
13
- if (Array.isArray(obj)) {
14
- return obj.map(item => replace_query_keys(item, fn))
15
- }
16
-
17
- // create an empty new obj with the same prototype as obj
18
- const new_obj = Object.create(Object.getPrototypeOf(obj))
19
-
20
- Object
21
- .keys(obj)
22
- .forEach(key => {
23
- const new_key = fn(key)
24
- new_obj[new_key] = replace_query_keys(obj[key], fn)
25
- })
26
-
27
- return new_obj
28
- }
29
-
30
- export default replace_query_keys
@@ -1,32 +0,0 @@
1
- /* @flow */
2
-
3
- const get_keys = (obj, parent_key = '') => {
4
- return Object.keys(obj).reduce((acc, key) => {
5
- const new_key = parent_key ? `${parent_key}.${key}` : key
6
- if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {
7
- acc.push(...get_keys(obj[key], new_key))
8
- } else {
9
- acc.push(new_key)
10
- }
11
- return acc
12
- }, [])
13
- }
14
-
15
- const set_contains_set = (set_a, set_b) => {
16
- if (set_b.size > set_a.size) return false
17
- for (const b of set_b) if (!set_a.has(b)) return false
18
- return true
19
- }
20
-
21
- const satisfies_projection = (doc, projection) => {
22
- const doc_keys = new Set(get_keys(doc))
23
- const projection_keys = new Set(Object.keys(projection).filter(k => projection[k] === 1))
24
-
25
- if (!projection_keys.has('_id')) {
26
- doc_keys.delete('_id')
27
- }
28
-
29
- return set_contains_set(doc_keys, projection_keys)
30
- }
31
-
32
- module.exports = satisfies_projection
@@ -1,47 +0,0 @@
1
- /* @flow */
2
-
3
- import {get_collection} from "./get_collection"
4
-
5
- import {UNDERSCORE_PREFIX} from "./constants"
6
-
7
-
8
- const update_docs = async(model_name, data, uid) => {
9
- const collection = get_collection(model_name, {uid})
10
-
11
- const all_ids = data.map((doc) => doc._id)
12
-
13
- // https://github.com/pouchdb/pouchdb/tree/master/packages/node_modules/pouchdb-find#dbcreateindexindex--callback
14
- const {docs: current_docs} = await collection.find({
15
- selector: {_id: {$in: all_ids}},
16
- fields: ["_id", "_rev"],
17
- })
18
-
19
- const current_docs_by_id = current_docs.reduce((acc, val) => {
20
- acc[val._id] = val
21
- return acc
22
- }, {})
23
-
24
- // WARNING: tmp
25
- // we don't need to remove docs that aren't present in data because queries are refined with find
26
-
27
- const revs_map = {}
28
- current_docs.forEach((doc) => revs_map[doc._id] = doc._rev)
29
-
30
- const new_docs = data.map((mongo_doc) => {
31
- const current_doc = current_docs_by_id[mongo_doc._id] || {}
32
-
33
- const op = Object.entries(mongo_doc)
34
- .reduce((new_doc, [key, value]) => {
35
- let new_key = key !== "_id" && key.startsWith("_") ? `${UNDERSCORE_PREFIX}${key}` : key
36
- new_doc[new_key] = value
37
- return new_doc
38
- }, current_doc)
39
-
40
- op._rev = revs_map[mongo_doc._id]
41
- return op
42
- })
43
-
44
- await collection.bulkDocs(new_docs)
45
- }
46
-
47
- export default update_docs
@@ -1,15 +0,0 @@
1
- /* @flow */
2
-
3
- const getEmptyStorage = () => {
4
- const storage = {
5
- getItem: (key) => {
6
- },
7
- setItem: (key, value) => {
8
- }
9
- }
10
-
11
- return storage
12
- }
13
-
14
-
15
- export default getEmptyStorage()
@@ -1,38 +0,0 @@
1
- /* @flow */
2
- import {MMKV} from "react-native-mmkv"
3
-
4
- // TODO: add encryption key
5
- // https://github.com/mrousavy/react-native-mmkv#customize
6
- const mmkv = new MMKV
7
-
8
- const getStorage = () => {
9
- const storage = {
10
- getItem: (key) => {
11
- try {
12
- const res = mmkv.getString(key)
13
- if (!res) return
14
- const val = JSON.parse(res)
15
- if (val) return val
16
- } catch (error) {
17
- // There was an error on the native side
18
- console.log("storage.getItem error:", error)
19
- }
20
- },
21
- setItem: (key, value) => {
22
- if (value === null || typeof value === "undefined") {
23
- mmkv.delete(key)
24
- return
25
- } else {
26
- mmkv.set(key, JSON.stringify(value))
27
- }
28
- },
29
- clear: () => {
30
- mmkv.clearAll()
31
- }
32
- }
33
-
34
- return storage
35
- }
36
-
37
-
38
- export default getStorage()
@@ -1,25 +0,0 @@
1
- /* @flow */
2
-
3
- const getStorage = () => {
4
- const storage = {
5
- getItem: (key) => {
6
- try {
7
- const res = localStorage.getItem(key)
8
- if (!res) return
9
- const val = JSON.parse(res)
10
- return val
11
- } catch (error) {
12
- // There was an error on the native side
13
- console.log("storage.getItem error:", error)
14
- }
15
- },
16
- setItem: (key, value) => {
17
- localStorage.setItem(key, JSON.stringify(value))
18
- }
19
- }
20
-
21
- return storage
22
- }
23
-
24
-
25
- export default getStorage()
package/types.ts DELETED
@@ -1,6 +0,0 @@
1
-
2
- export type NestedKeyOf<ObjectType extends object> =
3
- {[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object
4
- ? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}`
5
- : `${Key}`
6
- }[keyof ObjectType & (string | number)];
@@ -1,113 +0,0 @@
1
- /* @flow */
2
- import assert from "assert"
3
- import {useEffect, useRef} from "react"
4
- import {Animated, StyleSheet, View, ViewStyle} from "react-native"
5
-
6
- import {withStyles} from "@ui-kitten/components/theme/theme/withStyles"
7
- import {SpinnerAnimation} from "@ui-kitten/components/ui/spinner/animation"
8
-
9
-
10
- type SizeType = {width: number, height: number}
11
-
12
- type ArcElementStyle = {
13
- container: ViewStyle,
14
- arc: ViewStyle,
15
- overflow?: ViewStyle,
16
- }
17
-
18
- const styles = StyleSheet.create({
19
- noOverflow: {
20
- overflow: "hidden",
21
- },
22
- })
23
-
24
- const ActivityIndicator = ({
25
- animating = true,
26
- size = 24,
27
- strokeWidth = 2.6,
28
- duration = 1600,
29
- color = "#007BFF",
30
- testID = "activity-indicator",
31
- style = {},
32
- }) => {
33
- const animationRef = useRef(new SpinnerAnimation(size, {duration}))
34
-
35
- assert(typeof size === "number")
36
-
37
- useEffect(() => {
38
- if (!animationRef.current) {
39
- animationRef.current = new SpinnerAnimation(size, {duration})
40
- }
41
-
42
- return () => {
43
- animationRef.current?.stop()
44
- animationRef.current?.release()
45
- }
46
- }, [size])
47
-
48
- useEffect(() => {
49
- if (animating) {
50
- animationRef.current?.start()
51
- } else {
52
- animationRef.current?.stop()
53
- }
54
- }, [animating])
55
-
56
- const getComponentStyle = (
57
- source: SpinnerAnimation,
58
- ): {start: ArcElementStyle, end: ArcElementStyle} => {
59
- const start: ArcElementStyle = {
60
- container: source.container,
61
- arc: source.start,
62
- }
63
-
64
- const end: ArcElementStyle = {
65
- container: source.container,
66
- arc: source.end,
67
- overflow: {top: size / 2},
68
- }
69
-
70
- return {start, end}
71
- }
72
-
73
- const renderArcElement = (arcStyle: ArcElementStyle): React.Element<typeof View> => {
74
- const arcSize: SizeType = {width: size, height: size / 2}
75
-
76
- const spinnerStyle = {
77
- borderColor: color,
78
- borderRadius: size,
79
- borderWidth: strokeWidth,
80
- height: size,
81
- width: size,
82
- }
83
-
84
- return (
85
- <Animated.View
86
- style={[StyleSheet.absoluteFill, arcStyle.container, {width: size, height: size}]}
87
- >
88
- <View style={[styles.noOverflow, arcStyle.overflow, arcSize]}>
89
- <Animated.View style={[arcStyle.arc, {width: size, height: size}]}>
90
- <View style={[styles.noOverflow, arcSize]}>
91
- <View style={[spinnerStyle]} />
92
- </View>
93
- </Animated.View>
94
- </View>
95
- </Animated.View>
96
- )
97
- }
98
-
99
- if (!animationRef.current) {
100
- return null
101
- }
102
-
103
- const evaStyle = getComponentStyle(animationRef.current?.toProps())
104
-
105
- return (
106
- <View testID={testID} style={{width: size, height: size, ...style}}>
107
- {renderArcElement(evaStyle.start)}
108
- {renderArcElement(evaStyle.end)}
109
- </View>
110
- )
111
- }
112
-
113
- export default withStyles(ActivityIndicator, () => ({}))
@@ -1,31 +0,0 @@
1
- /* @flow */
2
- import {Text, View} from "react-native"
3
-
4
- // import View from "ui/View"
5
-
6
- import {SIZE_STYLES} from "./styles"
7
-
8
-
9
- const Avatar = ({size = "medium", style = {}, text = "?", color = "#000", textColor = "#FFF"}) => {
10
- const sizeStyles = SIZE_STYLES[size]
11
-
12
- return (
13
- <View
14
- className={"font-monospace"}
15
- style={{
16
- justifyContent: "center",
17
- alignItems: "center",
18
- backgroundColor: color,
19
- userSelect: "none",
20
- ...sizeStyles,
21
- ...style,
22
- }}
23
- >
24
- <Text style={{color: textColor}}>{text}</Text>
25
- </View>
26
- )
27
- }
28
-
29
- export default Avatar
30
-
31
- export {SIZE_STYLES}
@@ -1,37 +0,0 @@
1
- /* @flow */
2
- import {Text} from "react-native"
3
-
4
- import {SIZE_STYLES} from "./styles"
5
-
6
-
7
- const Avatar = ({
8
- className = "",
9
- size = "medium",
10
- style = {},
11
- text = "?",
12
- color = "#000",
13
- textColor = "#FFF",
14
- }) => {
15
- const sizeStyles = SIZE_STYLES[size]
16
-
17
- return (
18
- <div
19
- className={cx("font-monospace", className)}
20
- style={{
21
- display: "flex",
22
- justifyContent: "center",
23
- alignItems: "center",
24
- backgroundColor: color,
25
- userSelect: "none",
26
- ...sizeStyles,
27
- ...style,
28
- }}
29
- >
30
- <Text style={{color: textColor, font: "inherit"}}>{text}</Text>
31
- </div>
32
- )
33
- }
34
-
35
- export default Avatar
36
-
37
- export {SIZE_STYLES}
@@ -1,41 +0,0 @@
1
- /* @flow */
2
- import {getSvgPath} from "figma-squircle"
3
- import {Platform} from "react-native"
4
-
5
-
6
- const CORNER_SMOOTHING = 0.82
7
-
8
- const getSizeProps = ({size, smoothRadius, fallbackRadius}) => ({
9
- width: size,
10
- height: size,
11
- ...Platform.select({
12
- web: {
13
- clipPath: `path('${getSvgPath({
14
- width: size,
15
- height: size,
16
- cornerRadius: smoothRadius,
17
- cornerSmoothing: CORNER_SMOOTHING,
18
- })}')`,
19
- },
20
- native: {borderRadius: fallbackRadius},
21
- }),
22
- })
23
-
24
- export const SIZE_STYLES = {
25
- small: {
26
- ...getSizeProps({size: 22, smoothRadius: 4, fallbackRadius: 3}),
27
- fontSize: 9,
28
- },
29
- medium: {
30
- ...getSizeProps({size: 34, smoothRadius: 8, fallbackRadius: 6}),
31
- fontSize: 15,
32
- },
33
- large: {
34
- ...getSizeProps({size: 48, smoothRadius: 14, fallbackRadius: 6}),
35
- fontSize: 26,
36
- },
37
- xlarge: {
38
- ...getSizeProps({size: 68, smoothRadius: 18, fallbackRadius: 8}),
39
- fontSize: 26,
40
- },
41
- }
@@ -1,12 +0,0 @@
1
- import {ErrorBoundary as ReactErrorBoundary} from "react-error-boundary"
2
-
3
- import {RedBoxError} from "../RedboxError"
4
-
5
- // TODO: in production Redbox should just say there is an error but not display a stacktrace or more info
6
- export const ErrorBoundary = ({children, ...props}) => {
7
- const fallbackRender = ({error}) => {
8
- return <RedBoxError className="redbox-error" error={error} />
9
- }
10
-
11
- return <ReactErrorBoundary fallbackRender={fallbackRender}>{children}</ReactErrorBoundary>
12
- }
@@ -1,15 +0,0 @@
1
- @import "helpers";
2
-
3
- #exp-float-view-backdrop {
4
- // background-color: rgba(0, 0, 0, 0.2);
5
- background-color: $black;
6
- position: fixed;
7
-
8
- // top: 700px;
9
- // right: 1000px;
10
- top: 0;
11
- right: 0;
12
- bottom: 0;
13
- left: 0;
14
- transition: opacity 200ms ease-in-out;
15
- }
@@ -1,123 +0,0 @@
1
- import {motion} from "framer-motion"
2
- import {useRef, useState, useImperativeHandle} from "react"
3
-
4
- import {SPRING_DEFAULT} from "../springs"
5
- import useBackdrop from "./useBackdrop"
6
-
7
- import "./exp.scss"
8
-
9
-
10
- export const ExpandableFloatView = ({
11
- ref,
12
- renderContent,
13
- containerRef,
14
- onGetExpandedRect,
15
- targetRef,
16
- ...props
17
- }) => {
18
- const parentRef = useRef(null)
19
- const wrapperRef = useRef(null)
20
-
21
- const isOpen = useRef(false)
22
- const openedFromRect = useRef(null)
23
-
24
- const [animatedVals, setAnimatedVals] = useState({})
25
-
26
- const getRect = () => {
27
- const boundingRect = containerRef.current.getBoundingClientRect()
28
- const rect = {
29
- left: `${boundingRect.x}px`,
30
- top: `${boundingRect.top}px`,
31
- right: `${window.innerWidth - boundingRect.right}px`,
32
- bottom: `${window.innerHeight - boundingRect.bottom}px`,
33
- }
34
-
35
- return rect
36
- }
37
-
38
- const onOpen = () => {
39
- // eslint-disable-next-line no-use-before-define
40
- showBackdrop()
41
-
42
- isOpen.current = true
43
-
44
- const expandedRect = onGetExpandedRect()
45
-
46
- requestAnimationFrame(() => {
47
- // set the wrapper ref to current + fixed
48
- const rect = getRect()
49
- openedFromRect.current = rect
50
-
51
- const newStyle = {
52
- position: "fixed",
53
- top: rect.top,
54
- right: rect.right,
55
- bottom: rect.bottom,
56
- left: rect.left,
57
- zIndex: 1000,
58
- }
59
- Object.keys(newStyle).forEach((k) => {
60
- wrapperRef.current.style[k] = newStyle[k]
61
- })
62
-
63
- document.body.appendChild(wrapperRef.current)
64
-
65
- setAnimatedVals(expandedRect)
66
- })
67
- }
68
-
69
- const onClose = () => {
70
- isOpen.current = false
71
-
72
- const returnToRect = openedFromRect.current
73
- setAnimatedVals({
74
- top: returnToRect.top,
75
- right: returnToRect.right,
76
- bottom: returnToRect.bottom,
77
- left: returnToRect.left,
78
- zIndex: "unset",
79
- })
80
- }
81
-
82
- const onToggle = () => {
83
- if (isOpen.current) {
84
- onClose()
85
- } else {
86
- onOpen()
87
- }
88
- }
89
-
90
- const {showBackdrop} = useBackdrop(isOpen, onToggle)
91
-
92
- useImperativeHandle(ref, () => {
93
- return {
94
- open: () => {
95
- onOpen()
96
- },
97
- toggle: () => {
98
- onToggle()
99
- },
100
- close: () => onClose(),
101
- }
102
- })
103
-
104
- return (
105
- <>
106
- <div ref={parentRef}>
107
- <motion.div
108
- ref={wrapperRef}
109
- style={{
110
- inset: "unset",
111
- // zIndex: 10000,
112
- // ...styleProps,
113
- }}
114
- transition={SPRING_DEFAULT}
115
- animate={{...animatedVals}}
116
- onClick={(e) => e.stopPropagation()}
117
- >
118
- {renderContent({})}
119
- </motion.div>
120
- </div>
121
- </>
122
- )
123
- }