@stackframe/stack-shared 2.8.7 → 2.8.10

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 (476) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/config/format.d.cts +39 -0
  3. package/dist/config/format.d.ts +14 -13
  4. package/dist/config/format.js +147 -206
  5. package/dist/config/format.js.map +1 -0
  6. package/dist/config/schema.d.cts +724 -0
  7. package/dist/config/schema.d.ts +51 -48
  8. package/dist/config/schema.js +230 -172
  9. package/dist/config/schema.js.map +1 -0
  10. package/dist/crud.d.cts +102 -0
  11. package/dist/crud.d.ts +15 -13
  12. package/dist/crud.js +83 -128
  13. package/dist/crud.js.map +1 -0
  14. package/dist/esm/config/format.js +135 -0
  15. package/dist/esm/config/format.js.map +1 -0
  16. package/dist/esm/config/schema.js +199 -0
  17. package/dist/esm/config/schema.js.map +1 -0
  18. package/dist/esm/crud.js +60 -0
  19. package/dist/esm/crud.js.map +1 -0
  20. package/dist/esm/global.d.js +1 -0
  21. package/dist/esm/global.d.js.map +1 -0
  22. package/dist/esm/helpers/password.js +17 -0
  23. package/dist/esm/helpers/password.js.map +1 -0
  24. package/dist/esm/helpers/production-mode.js +50 -0
  25. package/dist/esm/helpers/production-mode.js.map +1 -0
  26. package/dist/esm/hooks/use-async-callback.js +38 -0
  27. package/dist/esm/hooks/use-async-callback.js.map +1 -0
  28. package/dist/esm/hooks/use-async-external-store.js +23 -0
  29. package/dist/esm/hooks/use-async-external-store.js.map +1 -0
  30. package/dist/esm/hooks/use-hash.js +17 -0
  31. package/dist/esm/hooks/use-hash.js.map +1 -0
  32. package/dist/esm/hooks/use-strict-memo.js +61 -0
  33. package/dist/esm/hooks/use-strict-memo.js.map +1 -0
  34. package/dist/esm/index.js +22 -0
  35. package/dist/esm/index.js.map +1 -0
  36. package/dist/esm/interface/adminInterface.js +244 -0
  37. package/dist/esm/interface/adminInterface.js.map +1 -0
  38. package/dist/esm/interface/clientInterface.js +2041 -0
  39. package/dist/esm/interface/clientInterface.js.map +1 -0
  40. package/dist/esm/interface/crud/contact-channels.js +77 -0
  41. package/dist/esm/interface/crud/contact-channels.js.map +1 -0
  42. package/dist/esm/interface/crud/current-user.js +65 -0
  43. package/dist/esm/interface/crud/current-user.js.map +1 -0
  44. package/dist/esm/interface/crud/email-templates.js +52 -0
  45. package/dist/esm/interface/crud/email-templates.js.map +1 -0
  46. package/dist/esm/interface/crud/emails.js +20 -0
  47. package/dist/esm/interface/crud/emails.js.map +1 -0
  48. package/dist/esm/interface/crud/internal-api-keys.js +69 -0
  49. package/dist/esm/interface/crud/internal-api-keys.js.map +1 -0
  50. package/dist/esm/interface/crud/oauth.js +24 -0
  51. package/dist/esm/interface/crud/oauth.js.map +1 -0
  52. package/dist/esm/interface/crud/project-api-keys.js +93 -0
  53. package/dist/esm/interface/crud/project-api-keys.js.map +1 -0
  54. package/dist/esm/interface/crud/project-permissions.js +113 -0
  55. package/dist/esm/interface/crud/project-permissions.js.map +1 -0
  56. package/dist/esm/interface/crud/projects.js +188 -0
  57. package/dist/esm/interface/crud/projects.js.map +1 -0
  58. package/dist/esm/interface/crud/sessions.js +62 -0
  59. package/dist/esm/interface/crud/sessions.js.map +1 -0
  60. package/dist/esm/interface/crud/svix-token.js +22 -0
  61. package/dist/esm/interface/crud/svix-token.js.map +1 -0
  62. package/dist/esm/interface/crud/team-invitation-details.js +23 -0
  63. package/dist/esm/interface/crud/team-invitation-details.js.map +1 -0
  64. package/dist/esm/interface/crud/team-invitation.js +36 -0
  65. package/dist/esm/interface/crud/team-invitation.js.map +1 -0
  66. package/dist/esm/interface/crud/team-member-profiles.js +62 -0
  67. package/dist/esm/interface/crud/team-member-profiles.js.map +1 -0
  68. package/dist/esm/interface/crud/team-memberships.js +60 -0
  69. package/dist/esm/interface/crud/team-memberships.js.map +1 -0
  70. package/dist/esm/interface/crud/team-permissions.js +114 -0
  71. package/dist/esm/interface/crud/team-permissions.js.map +1 -0
  72. package/dist/esm/interface/crud/teams.js +143 -0
  73. package/dist/esm/interface/crud/teams.js.map +1 -0
  74. package/dist/esm/interface/crud/users.js +139 -0
  75. package/dist/esm/interface/crud/users.js.map +1 -0
  76. package/dist/esm/interface/serverInterface.js +485 -0
  77. package/dist/esm/interface/serverInterface.js.map +1 -0
  78. package/dist/esm/interface/webhooks.js +21 -0
  79. package/dist/esm/interface/webhooks.js.map +1 -0
  80. package/dist/esm/known-errors.js +1223 -0
  81. package/dist/esm/known-errors.js.map +1 -0
  82. package/dist/esm/schema-fields.js +484 -0
  83. package/dist/esm/schema-fields.js.map +1 -0
  84. package/dist/esm/sessions.js +168 -0
  85. package/dist/esm/sessions.js.map +1 -0
  86. package/dist/esm/utils/api-keys.js +79 -0
  87. package/dist/esm/utils/api-keys.js.map +1 -0
  88. package/dist/esm/utils/arrays.js +78 -0
  89. package/dist/esm/utils/arrays.js.map +1 -0
  90. package/dist/esm/utils/base64.js +18 -0
  91. package/dist/esm/utils/base64.js.map +1 -0
  92. package/dist/esm/utils/booleans.js +12 -0
  93. package/dist/esm/utils/booleans.js.map +1 -0
  94. package/dist/esm/utils/browser-compat.js +21 -0
  95. package/dist/esm/utils/browser-compat.js.map +1 -0
  96. package/dist/esm/utils/bytes.js +160 -0
  97. package/dist/esm/utils/bytes.js.map +1 -0
  98. package/dist/esm/utils/caches.js +167 -0
  99. package/dist/esm/utils/caches.js.map +1 -0
  100. package/dist/esm/utils/compile-time.js +11 -0
  101. package/dist/esm/utils/compile-time.js.map +1 -0
  102. package/dist/esm/utils/crypto.js +25 -0
  103. package/dist/esm/utils/crypto.js.map +1 -0
  104. package/dist/esm/utils/dates.js +64 -0
  105. package/dist/esm/utils/dates.js.map +1 -0
  106. package/dist/esm/utils/dom.js +11 -0
  107. package/dist/esm/utils/dom.js.map +1 -0
  108. package/dist/esm/utils/env.js +58 -0
  109. package/dist/esm/utils/env.js.map +1 -0
  110. package/dist/esm/utils/errors.js +174 -0
  111. package/dist/esm/utils/errors.js.map +1 -0
  112. package/dist/esm/utils/fs.js +37 -0
  113. package/dist/esm/utils/fs.js.map +1 -0
  114. package/dist/esm/utils/functions.js +12 -0
  115. package/dist/esm/utils/functions.js.map +1 -0
  116. package/dist/esm/utils/geo.js +15 -0
  117. package/dist/esm/utils/geo.js.map +1 -0
  118. package/dist/esm/utils/globals.js +18 -0
  119. package/dist/esm/utils/globals.js.map +1 -0
  120. package/dist/esm/utils/hashes.js +55 -0
  121. package/dist/esm/utils/hashes.js.map +1 -0
  122. package/dist/esm/utils/html.js +13 -0
  123. package/dist/esm/utils/html.js.map +1 -0
  124. package/dist/esm/utils/http.js +60 -0
  125. package/dist/esm/utils/http.js.map +1 -0
  126. package/dist/esm/utils/ips.js +15 -0
  127. package/dist/esm/utils/ips.js.map +1 -0
  128. package/dist/esm/utils/json.js +31 -0
  129. package/dist/esm/utils/json.js.map +1 -0
  130. package/dist/esm/utils/jwt.js +87 -0
  131. package/dist/esm/utils/jwt.js.map +1 -0
  132. package/dist/esm/utils/locks.js +57 -0
  133. package/dist/esm/utils/locks.js.map +1 -0
  134. package/dist/esm/utils/maps.js +181 -0
  135. package/dist/esm/utils/maps.js.map +1 -0
  136. package/dist/esm/utils/math.js +8 -0
  137. package/dist/esm/utils/math.js.map +1 -0
  138. package/dist/esm/utils/node-http.js +42 -0
  139. package/dist/esm/utils/node-http.js.map +1 -0
  140. package/dist/esm/utils/numbers.js +32 -0
  141. package/dist/esm/utils/numbers.js.map +1 -0
  142. package/dist/esm/utils/oauth.js +10 -0
  143. package/dist/esm/utils/oauth.js.map +1 -0
  144. package/dist/esm/utils/objects.js +153 -0
  145. package/dist/esm/utils/objects.js.map +1 -0
  146. package/dist/esm/utils/passkey.js +1 -0
  147. package/dist/esm/utils/passkey.js.map +1 -0
  148. package/dist/esm/utils/promises.js +233 -0
  149. package/dist/esm/utils/promises.js.map +1 -0
  150. package/dist/esm/utils/proxies.js +128 -0
  151. package/dist/esm/utils/proxies.js.map +1 -0
  152. package/dist/esm/utils/react.js +78 -0
  153. package/dist/esm/utils/react.js.map +1 -0
  154. package/dist/esm/utils/results.js +141 -0
  155. package/dist/esm/utils/results.js.map +1 -0
  156. package/dist/esm/utils/sentry.js +20 -0
  157. package/dist/esm/utils/sentry.js.map +1 -0
  158. package/dist/esm/utils/stores.js +195 -0
  159. package/dist/esm/utils/stores.js.map +1 -0
  160. package/dist/esm/utils/strings.js +294 -0
  161. package/dist/esm/utils/strings.js.map +1 -0
  162. package/dist/esm/utils/strings.nicify.test.js +222 -0
  163. package/dist/esm/utils/strings.nicify.test.js.map +1 -0
  164. package/dist/esm/utils/types.js +1 -0
  165. package/dist/esm/utils/types.js.map +1 -0
  166. package/dist/esm/utils/unicode.js +11 -0
  167. package/dist/esm/utils/unicode.js.map +1 -0
  168. package/dist/esm/utils/urls.js +53 -0
  169. package/dist/esm/utils/urls.js.map +1 -0
  170. package/dist/esm/utils/uuids.js +16 -0
  171. package/dist/esm/utils/uuids.js.map +1 -0
  172. package/dist/global.d.d.cts +1 -0
  173. package/dist/global.d.d.ts +1 -0
  174. package/dist/global.d.js +2 -0
  175. package/dist/global.d.js.map +1 -0
  176. package/dist/helpers/password.d.cts +11 -0
  177. package/dist/helpers/password.d.ts +11 -2
  178. package/dist/helpers/password.js +41 -11
  179. package/dist/helpers/password.js.map +1 -0
  180. package/dist/helpers/production-mode.d.cts +12 -0
  181. package/dist/helpers/production-mode.d.ts +9 -3
  182. package/dist/helpers/production-mode.js +72 -45
  183. package/dist/helpers/production-mode.js.map +1 -0
  184. package/dist/hooks/use-async-callback.d.cts +6 -0
  185. package/dist/hooks/use-async-callback.d.ts +6 -3
  186. package/dist/hooks/use-async-callback.js +72 -30
  187. package/dist/hooks/use-async-callback.js.map +1 -0
  188. package/dist/hooks/use-async-external-store.d.cts +7 -0
  189. package/dist/hooks/use-async-external-store.d.ts +5 -2
  190. package/dist/hooks/use-async-external-store.js +47 -19
  191. package/dist/hooks/use-async-external-store.js.map +1 -0
  192. package/dist/hooks/use-hash.d.cts +3 -0
  193. package/dist/hooks/use-hash.d.ts +3 -1
  194. package/dist/hooks/use-hash.js +41 -8
  195. package/dist/hooks/use-hash.js.map +1 -0
  196. package/dist/hooks/use-strict-memo.d.cts +8 -0
  197. package/dist/hooks/use-strict-memo.d.ts +3 -1
  198. package/dist/hooks/use-strict-memo.js +78 -131
  199. package/dist/hooks/use-strict-memo.js.map +1 -0
  200. package/dist/index.d.cts +30 -0
  201. package/dist/index.d.ts +30 -4
  202. package/dist/index.js +42 -4
  203. package/dist/index.js.map +1 -0
  204. package/dist/interface/adminInterface.d.cts +94 -0
  205. package/dist/interface/adminInterface.d.ts +38 -15
  206. package/dist/interface/adminInterface.js +269 -174
  207. package/dist/interface/adminInterface.js.map +1 -0
  208. package/dist/interface/clientInterface.d.cts +260 -0
  209. package/dist/interface/clientInterface.d.ts +25 -18
  210. package/dist/interface/clientInterface.js +2054 -995
  211. package/dist/interface/clientInterface.js.map +1 -0
  212. package/dist/interface/crud/contact-channels.d.cts +180 -0
  213. package/dist/interface/crud/contact-channels.d.ts +30 -25
  214. package/dist/interface/crud/contact-channels.js +101 -59
  215. package/dist/interface/crud/contact-channels.js.map +1 -0
  216. package/dist/interface/crud/current-user.d.cts +205 -0
  217. package/dist/interface/crud/current-user.d.ts +17 -12
  218. package/dist/interface/crud/current-user.js +86 -56
  219. package/dist/interface/crud/current-user.js.map +1 -0
  220. package/dist/interface/crud/email-templates.d.cts +84 -0
  221. package/dist/interface/crud/email-templates.d.ts +24 -19
  222. package/dist/interface/crud/email-templates.js +77 -37
  223. package/dist/interface/crud/email-templates.js.map +1 -0
  224. package/dist/interface/crud/emails.d.cts +69 -0
  225. package/dist/interface/crud/emails.d.ts +12 -7
  226. package/dist/interface/crud/emails.js +54 -12
  227. package/dist/interface/crud/emails.js.map +1 -0
  228. package/dist/interface/crud/internal-api-keys.d.cts +139 -0
  229. package/dist/interface/crud/internal-api-keys.d.ts +22 -17
  230. package/dist/interface/crud/internal-api-keys.js +92 -54
  231. package/dist/interface/crud/internal-api-keys.js.map +1 -0
  232. package/dist/interface/crud/oauth.d.cts +34 -0
  233. package/dist/interface/crud/oauth.d.ts +16 -11
  234. package/dist/interface/crud/oauth.js +48 -14
  235. package/dist/interface/crud/oauth.js.map +1 -0
  236. package/dist/interface/crud/project-api-keys.d.cts +196 -0
  237. package/dist/interface/crud/project-api-keys.d.ts +18 -10
  238. package/dist/interface/crud/project-api-keys.js +121 -74
  239. package/dist/interface/crud/project-api-keys.js.map +1 -0
  240. package/dist/interface/crud/project-permissions.d.cts +160 -0
  241. package/dist/interface/crud/project-permissions.d.ts +38 -33
  242. package/dist/interface/crud/project-permissions.js +148 -90
  243. package/dist/interface/crud/project-permissions.js.map +1 -0
  244. package/dist/interface/crud/projects.d.cts +640 -0
  245. package/dist/interface/crud/projects.d.ts +36 -31
  246. package/dist/interface/crud/projects.js +218 -156
  247. package/dist/interface/crud/projects.js.map +1 -0
  248. package/dist/interface/crud/sessions.d.cts +149 -0
  249. package/dist/interface/crud/sessions.d.ts +21 -16
  250. package/dist/interface/crud/sessions.js +86 -50
  251. package/dist/interface/crud/sessions.js.map +1 -0
  252. package/dist/interface/crud/svix-token.d.cts +26 -0
  253. package/dist/interface/crud/svix-token.d.ts +14 -9
  254. package/dist/interface/crud/svix-token.js +46 -12
  255. package/dist/interface/crud/svix-token.js.map +1 -0
  256. package/dist/interface/crud/team-invitation-details.d.cts +30 -0
  257. package/dist/interface/crud/team-invitation-details.d.ts +12 -7
  258. package/dist/interface/crud/team-invitation-details.js +57 -15
  259. package/dist/interface/crud/team-invitation-details.js.map +1 -0
  260. package/dist/interface/crud/team-invitation.d.cts +49 -0
  261. package/dist/interface/crud/team-invitation.d.ts +13 -8
  262. package/dist/interface/crud/team-invitation.js +69 -27
  263. package/dist/interface/crud/team-invitation.js.map +1 -0
  264. package/dist/interface/crud/team-member-profiles.d.cts +229 -0
  265. package/dist/interface/crud/team-member-profiles.d.ts +20 -15
  266. package/dist/interface/crud/team-member-profiles.js +95 -49
  267. package/dist/interface/crud/team-member-profiles.js.map +1 -0
  268. package/dist/interface/crud/team-memberships.d.cts +74 -0
  269. package/dist/interface/crud/team-memberships.d.ts +22 -17
  270. package/dist/interface/crud/team-memberships.js +85 -45
  271. package/dist/interface/crud/team-memberships.js.map +1 -0
  272. package/dist/interface/crud/team-permissions.d.cts +168 -0
  273. package/dist/interface/crud/team-permissions.d.ts +38 -33
  274. package/dist/interface/crud/team-permissions.js +149 -91
  275. package/dist/interface/crud/team-permissions.js.map +1 -0
  276. package/dist/interface/crud/teams.d.cts +298 -0
  277. package/dist/interface/crud/teams.d.ts +45 -40
  278. package/dist/interface/crud/teams.js +177 -119
  279. package/dist/interface/crud/teams.js.map +1 -0
  280. package/dist/interface/crud/users.d.cts +469 -0
  281. package/dist/interface/crud/users.d.ts +31 -26
  282. package/dist/interface/crud/users.js +172 -118
  283. package/dist/interface/crud/users.js.map +1 -0
  284. package/dist/interface/serverInterface.d.cts +128 -0
  285. package/dist/interface/serverInterface.d.ts +29 -17
  286. package/dist/interface/serverInterface.js +506 -339
  287. package/dist/interface/serverInterface.js.map +1 -0
  288. package/dist/interface/webhooks.d.cts +292 -0
  289. package/dist/interface/webhooks.d.ts +6 -3
  290. package/dist/interface/webhooks.js +45 -15
  291. package/dist/interface/webhooks.js.map +1 -0
  292. package/dist/known-errors.d.cts +444 -0
  293. package/dist/known-errors.d.ts +12 -9
  294. package/dist/known-errors.js +1088 -561
  295. package/dist/known-errors.js.map +1 -0
  296. package/dist/schema-fields.d.cts +163 -0
  297. package/dist/schema-fields.d.ts +116 -114
  298. package/dist/schema-fields.js +593 -427
  299. package/dist/schema-fields.js.map +1 -0
  300. package/dist/sessions.d.cts +109 -0
  301. package/dist/sessions.d.ts +6 -3
  302. package/dist/sessions.js +201 -172
  303. package/dist/sessions.js.map +1 -0
  304. package/dist/utils/api-keys.d.cts +24 -0
  305. package/dist/utils/api-keys.d.ts +5 -4
  306. package/dist/utils/api-keys.js +106 -66
  307. package/dist/utils/api-keys.js.map +1 -0
  308. package/dist/utils/arrays.d.cts +18 -0
  309. package/dist/utils/arrays.d.ts +15 -13
  310. package/dist/utils/arrays.js +101 -168
  311. package/dist/utils/arrays.js.map +1 -0
  312. package/dist/utils/base64.d.cts +4 -0
  313. package/dist/utils/base64.d.ts +4 -2
  314. package/dist/utils/base64.js +41 -20
  315. package/dist/utils/base64.js.map +1 -0
  316. package/dist/utils/booleans.d.cts +6 -0
  317. package/dist/utils/booleans.d.ts +6 -4
  318. package/dist/utils/booleans.js +35 -27
  319. package/dist/utils/booleans.js.map +1 -0
  320. package/dist/utils/browser-compat.d.cts +8 -0
  321. package/dist/utils/browser-compat.d.ts +3 -1
  322. package/dist/utils/browser-compat.js +45 -16
  323. package/dist/utils/browser-compat.js.map +1 -0
  324. package/dist/utils/bytes.d.cts +15 -0
  325. package/dist/utils/bytes.d.ts +15 -13
  326. package/dist/utils/bytes.js +182 -270
  327. package/dist/utils/bytes.js.map +1 -0
  328. package/dist/utils/caches.d.cts +98 -0
  329. package/dist/utils/caches.d.ts +17 -14
  330. package/dist/utils/caches.js +188 -193
  331. package/dist/utils/caches.js.map +1 -0
  332. package/dist/utils/compile-time.d.cts +8 -0
  333. package/dist/utils/compile-time.d.ts +3 -1
  334. package/dist/utils/compile-time.js +35 -10
  335. package/dist/utils/compile-time.js.map +1 -0
  336. package/dist/utils/crypto.d.cts +8 -0
  337. package/dist/utils/crypto.d.ts +4 -2
  338. package/dist/utils/crypto.js +49 -21
  339. package/dist/utils/crypto.js.map +1 -0
  340. package/dist/utils/dates.d.cts +15 -0
  341. package/dist/utils/dates.d.ts +6 -4
  342. package/dist/utils/dates.js +83 -105
  343. package/dist/utils/dates.js.map +1 -0
  344. package/dist/utils/dom.d.cts +3 -0
  345. package/dist/utils/dom.d.ts +3 -1
  346. package/dist/utils/dom.js +35 -7
  347. package/dist/utils/dom.js.map +1 -0
  348. package/dist/utils/env.d.cts +9 -0
  349. package/dist/utils/env.d.ts +6 -4
  350. package/dist/utils/env.js +70 -43
  351. package/dist/utils/env.js.map +1 -0
  352. package/dist/utils/errors.d.cts +223 -0
  353. package/dist/utils/errors.d.ts +14 -11
  354. package/dist/utils/errors.js +148 -126
  355. package/dist/utils/errors.js.map +1 -0
  356. package/dist/utils/fs.d.cts +7 -0
  357. package/dist/utils/fs.d.ts +5 -3
  358. package/dist/utils/fs.js +70 -27
  359. package/dist/utils/fs.js.map +1 -0
  360. package/dist/utils/functions.d.cts +4 -0
  361. package/dist/utils/functions.d.ts +4 -2
  362. package/dist/utils/functions.js +35 -18
  363. package/dist/utils/functions.js.map +1 -0
  364. package/dist/utils/geo.d.cts +22 -0
  365. package/dist/utils/geo.d.ts +6 -3
  366. package/dist/utils/geo.js +39 -9
  367. package/dist/utils/geo.js.map +1 -0
  368. package/dist/utils/globals.d.cts +5 -0
  369. package/dist/utils/globals.d.ts +4 -2
  370. package/dist/utils/globals.js +41 -14
  371. package/dist/utils/globals.js.map +1 -0
  372. package/dist/utils/hashes.d.cts +7 -0
  373. package/dist/utils/hashes.d.ts +7 -5
  374. package/dist/utils/hashes.js +87 -41
  375. package/dist/utils/hashes.js.map +1 -0
  376. package/dist/utils/html.d.cts +4 -0
  377. package/dist/utils/html.d.ts +4 -2
  378. package/dist/utils/html.js +36 -37
  379. package/dist/utils/html.js.map +1 -0
  380. package/dist/utils/http.d.cts +43 -0
  381. package/dist/utils/http.d.ts +6 -4
  382. package/dist/utils/http.js +83 -83
  383. package/dist/utils/http.js.map +1 -0
  384. package/dist/utils/ips.d.cts +6 -0
  385. package/dist/utils/ips.d.ts +6 -4
  386. package/dist/utils/ips.js +48 -35
  387. package/dist/utils/ips.js.map +1 -0
  388. package/dist/utils/json.d.cts +13 -0
  389. package/dist/utils/json.d.ts +9 -6
  390. package/dist/utils/json.js +54 -157
  391. package/dist/utils/json.js.map +1 -0
  392. package/dist/utils/jwt.d.cts +44 -0
  393. package/dist/utils/jwt.d.ts +14 -11
  394. package/dist/utils/jwt.js +119 -84
  395. package/dist/utils/jwt.js.map +1 -0
  396. package/dist/utils/locks.d.cts +15 -0
  397. package/dist/utils/locks.d.ts +3 -2
  398. package/dist/utils/locks.js +76 -56
  399. package/dist/utils/locks.js.map +1 -0
  400. package/dist/utils/maps.d.cts +59 -0
  401. package/dist/utils/maps.d.ts +6 -4
  402. package/dist/utils/maps.js +207 -343
  403. package/dist/utils/maps.js.map +1 -0
  404. package/dist/utils/math.d.cts +6 -0
  405. package/dist/utils/math.d.ts +3 -1
  406. package/dist/utils/math.js +31 -16
  407. package/dist/utils/math.js.map +1 -0
  408. package/dist/utils/node-http.d.cts +15 -0
  409. package/dist/utils/node-http.d.ts +5 -5
  410. package/dist/utils/node-http.js +65 -36
  411. package/dist/utils/node-http.js.map +1 -0
  412. package/dist/utils/numbers.d.cts +5 -0
  413. package/dist/utils/numbers.d.ts +5 -3
  414. package/dist/utils/numbers.js +53 -66
  415. package/dist/utils/numbers.js.map +1 -0
  416. package/dist/utils/oauth.d.cts +8 -0
  417. package/dist/utils/oauth.d.ts +8 -6
  418. package/dist/utils/oauth.js +37 -4
  419. package/dist/utils/oauth.js.map +1 -0
  420. package/dist/utils/objects.d.cts +65 -0
  421. package/dist/utils/objects.d.ts +31 -30
  422. package/dist/utils/objects.js +196 -374
  423. package/dist/utils/objects.js.map +1 -0
  424. package/dist/utils/passkey.d.cts +1 -0
  425. package/dist/utils/passkey.d.ts +1 -1
  426. package/dist/utils/passkey.js +19 -1
  427. package/dist/utils/passkey.js.map +1 -0
  428. package/dist/utils/promises.d.cts +74 -0
  429. package/dist/utils/promises.d.ts +20 -18
  430. package/dist/utils/promises.js +252 -393
  431. package/dist/utils/promises.js.map +1 -0
  432. package/dist/utils/proxies.d.cts +4 -0
  433. package/dist/utils/proxies.d.ts +4 -2
  434. package/dist/utils/proxies.js +150 -161
  435. package/dist/utils/proxies.js.map +1 -0
  436. package/dist/utils/react.d.cts +25 -0
  437. package/dist/utils/react.d.ts +9 -6
  438. package/dist/utils/react.js +88 -134
  439. package/dist/utils/react.js.map +1 -0
  440. package/dist/utils/results.d.cts +78 -0
  441. package/dist/utils/results.d.ts +10 -9
  442. package/dist/utils/results.js +143 -324
  443. package/dist/utils/results.js.map +1 -0
  444. package/dist/utils/sentry.d.cts +5 -0
  445. package/dist/utils/sentry.d.ts +5 -2
  446. package/dist/utils/sentry.js +44 -14
  447. package/dist/utils/sentry.js.map +1 -0
  448. package/dist/utils/stores.d.cts +102 -0
  449. package/dist/utils/stores.d.ts +12 -9
  450. package/dist/utils/stores.js +219 -189
  451. package/dist/utils/stores.js.map +1 -0
  452. package/dist/utils/strings.d.cts +72 -0
  453. package/dist/utils/strings.d.ts +22 -20
  454. package/dist/utils/strings.js +299 -580
  455. package/dist/utils/strings.js.map +1 -0
  456. package/dist/utils/strings.nicify.test.d.cts +2 -0
  457. package/dist/utils/strings.nicify.test.d.ts +2 -1
  458. package/dist/utils/strings.nicify.test.js +168 -158
  459. package/dist/utils/strings.nicify.test.js.map +1 -0
  460. package/dist/utils/types.d.cts +23 -0
  461. package/dist/utils/types.d.ts +8 -6
  462. package/dist/utils/types.js +19 -1
  463. package/dist/utils/types.js.map +1 -0
  464. package/dist/utils/unicode.d.cts +3 -0
  465. package/dist/utils/unicode.d.ts +3 -1
  466. package/dist/utils/unicode.js +34 -21
  467. package/dist/utils/unicode.js.map +1 -0
  468. package/dist/utils/urls.d.cts +20 -0
  469. package/dist/utils/urls.d.ts +10 -8
  470. package/dist/utils/urls.js +76 -165
  471. package/dist/utils/urls.js.map +1 -0
  472. package/dist/utils/uuids.d.cts +4 -0
  473. package/dist/utils/uuids.d.ts +4 -2
  474. package/dist/utils/uuids.js +39 -35
  475. package/dist/utils/uuids.js.map +1 -0
  476. package/package.json +5 -5
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/api-keys.tsx"],"sourcesContent":["import crc32 from 'crc/crc32';\nimport { getBase32CharacterFromIndex } from \"./bytes\";\nimport { generateSecureRandomString } from \"./crypto\";\nimport { StackAssertionError } from \"./errors\";\n\n\nconst STACK_AUTH_MARKER = \"574ck4u7h\";\n\n// API key part lengths\nconst API_KEY_LENGTHS = {\n SECRET_PART: 45,\n ID_PART: 32,\n TYPE_PART: 4,\n SCANNER: 1,\n MARKER: 9,\n CHECKSUM: 8,\n} as const;\n\n/**\n * An api key has the following format:\n * <prefix_without_underscores>_<secret_part_45_chars><id_part_32_chars><type_user_or_team_4_chars><scanner_and_marker_10_chars><checksum_8_chars>\n *\n * The scanner and marker is a base32 character that is used to determine if the api key is a public or private key\n * and if it is a cloud or self-hosted key.\n *\n * The checksum is a crc32 checksum of the api key encoded in hex.\n *\n */\n\ntype ProjectApiKey = {\n id: string,\n prefix: string,\n isPublic: boolean,\n isCloudVersion: boolean,\n secret: string,\n checksum: string,\n type: \"user\" | \"team\",\n}\n\n\nfunction createChecksumSync(checksummablePart: string): string {\n const data = new TextEncoder().encode(checksummablePart);\n const calculated_checksum = crc32(data);\n return calculated_checksum.toString(16).padStart(8, \"0\");\n}\n\nfunction createApiKeyParts(options: Pick<ProjectApiKey, \"id\" | \"isPublic\" | \"isCloudVersion\" | \"type\">) {\n const { id, isPublic, isCloudVersion, type } = options;\n const prefix = isPublic ? \"pk\" : \"sk\";\n const scannerFlag = (isCloudVersion ? 0 : 1) + (isPublic ? 2 : 0) + (/* version */ 0);\n\n const secretPart = generateSecureRandomString();\n const idPart = id.replace(/-/g, \"\");\n const scannerAndMarker = getBase32CharacterFromIndex(scannerFlag).toLowerCase() + STACK_AUTH_MARKER;\n const checksummablePart = `${prefix}_${secretPart}${idPart}${type}${scannerAndMarker}`;\n\n return { checksummablePart, idPart, prefix, scannerAndMarker, type };\n}\n\n\nfunction parseApiKeyParts(secret: string) {\n const regex = new RegExp(\n `^([a-zA-Z0-9_]+)_` + // prefix\n `([a-zA-Z0-9_]{${API_KEY_LENGTHS.SECRET_PART}})` + // secretPart\n `([a-zA-Z0-9_]{${API_KEY_LENGTHS.ID_PART}})` + // idPart\n `([a-zA-Z0-9_]{${API_KEY_LENGTHS.TYPE_PART}})` + // type\n `([a-zA-Z0-9_]{${API_KEY_LENGTHS.SCANNER}})` + // scanner\n `(${STACK_AUTH_MARKER})` + // marker\n `([a-zA-Z0-9_]{${API_KEY_LENGTHS.CHECKSUM}})$` // checksum\n );\n\n const match = secret.match(regex);\n if (!match) {\n throw new StackAssertionError(\"Invalid API key format\");\n }\n\n const [, prefix, secretPart, idPart, type, scannerFlag, marker, checksum] = match;\n\n const isCloudVersion = parseInt(scannerFlag, 32) % 2 === 0;\n const isPublic = (parseInt(scannerFlag, 32) & 2) !== 0;\n\n const checksummablePart = `${prefix}_${secretPart}${idPart}${type}${scannerFlag}${marker}`;\n const restored_id = idPart.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, \"$1-$2-$3-$4-$5\");\n\n if (![\"user\", \"team\"].includes(type)) {\n throw new StackAssertionError(\"Invalid type\");\n }\n\n return { checksummablePart, checksum, id: restored_id, isCloudVersion, isPublic, prefix, type: type as \"user\" | \"team\" };\n}\n\n\nexport function isApiKey(secret: string): boolean {\n return secret.includes(\"_\") && secret.includes(STACK_AUTH_MARKER);\n}\n\nexport function createProjectApiKey(options: Pick<ProjectApiKey, \"id\" | \"isPublic\" | \"isCloudVersion\" | \"type\">): string {\n const { checksummablePart } = createApiKeyParts(options);\n const checksum = createChecksumSync(checksummablePart);\n return `${checksummablePart}${checksum}`;\n}\n\n\nexport function parseProjectApiKey(secret: string): ProjectApiKey {\n const { checksummablePart, checksum, id, isCloudVersion, isPublic, prefix, type } = parseApiKeyParts(secret);\n const calculated_checksum = createChecksumSync(checksummablePart);\n\n if (calculated_checksum !== checksum) {\n throw new StackAssertionError(\"Checksum mismatch\");\n }\n\n return {\n id,\n prefix,\n isPublic,\n isCloudVersion,\n secret,\n checksum,\n type,\n };\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,mBAA4C;AAC5C,oBAA2C;AAC3C,oBAAoC;AAGpC,IAAM,oBAAoB;AAG1B,IAAM,kBAAkB;AAAA,EACtB,aAAa;AAAA,EACb,SAAS;AAAA,EACT,WAAW;AAAA,EACX,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AACZ;AAwBA,SAAS,mBAAmB,mBAAmC;AAC7D,QAAM,OAAO,IAAI,YAAY,EAAE,OAAO,iBAAiB;AACvD,QAAM,0BAAsB,aAAAA,SAAM,IAAI;AACtC,SAAO,oBAAoB,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AACzD;AAEA,SAAS,kBAAkB,SAA6E;AACtG,QAAM,EAAE,IAAI,UAAU,gBAAgB,KAAK,IAAI;AAC/C,QAAM,SAAS,WAAW,OAAO;AACjC,QAAM,eAAe,iBAAiB,IAAI,MAAM,WAAW,IAAI;AAAA,EAAoB;AAEnF,QAAM,iBAAa,0CAA2B;AAC9C,QAAM,SAAS,GAAG,QAAQ,MAAM,EAAE;AAClC,QAAM,uBAAmB,0CAA4B,WAAW,EAAE,YAAY,IAAI;AAClF,QAAM,oBAAoB,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,gBAAgB;AAEpF,SAAO,EAAE,mBAAmB,QAAQ,QAAQ,kBAAkB,KAAK;AACrE;AAGA,SAAS,iBAAiB,QAAgB;AACxC,QAAM,QAAQ,IAAI;AAAA,IAChB,kCACiB,gBAAgB,WAAW,mBAC3B,gBAAgB,OAAO,mBACvB,gBAAgB,SAAS,mBACzB,gBAAgB,OAAO,MACpC,iBAAiB,kBACJ,gBAAgB,QAAQ;AAAA;AAAA,EAC3C;AAEA,QAAM,QAAQ,OAAO,MAAM,KAAK;AAChC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,kCAAoB,wBAAwB;AAAA,EACxD;AAEA,QAAM,CAAC,EAAE,QAAQ,YAAY,QAAQ,MAAM,aAAa,QAAQ,QAAQ,IAAI;AAE5E,QAAM,iBAAiB,SAAS,aAAa,EAAE,IAAI,MAAM;AACzD,QAAM,YAAY,SAAS,aAAa,EAAE,IAAI,OAAO;AAErD,QAAM,oBAAoB,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,MAAM;AACxF,QAAM,cAAc,OAAO,QAAQ,mCAAmC,gBAAgB;AAEtF,MAAI,CAAC,CAAC,QAAQ,MAAM,EAAE,SAAS,IAAI,GAAG;AACpC,UAAM,IAAI,kCAAoB,cAAc;AAAA,EAC9C;AAEA,SAAO,EAAE,mBAAmB,UAAU,IAAI,aAAa,gBAAgB,UAAU,QAAQ,KAA8B;AACzH;AAGO,SAAS,SAAS,QAAyB;AAChD,SAAO,OAAO,SAAS,GAAG,KAAK,OAAO,SAAS,iBAAiB;AAClE;AAEO,SAAS,oBAAoB,SAAqF;AACvH,QAAM,EAAE,kBAAkB,IAAI,kBAAkB,OAAO;AACvD,QAAM,WAAW,mBAAmB,iBAAiB;AACrD,SAAO,GAAG,iBAAiB,GAAG,QAAQ;AACxC;AAGO,SAAS,mBAAmB,QAA+B;AAChE,QAAM,EAAE,mBAAmB,UAAU,IAAI,gBAAgB,UAAU,QAAQ,KAAK,IAAI,iBAAiB,MAAM;AAC3G,QAAM,sBAAsB,mBAAmB,iBAAiB;AAEhE,MAAI,wBAAwB,UAAU;AACpC,UAAM,IAAI,kCAAoB,mBAAmB;AAAA,EACnD;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["crc32"]}
@@ -0,0 +1,18 @@
1
+ declare function typedIncludes<T extends readonly any[]>(arr: T, item: unknown): item is T[number];
2
+ declare function enumerate<T extends readonly any[]>(arr: T): [number, T[number]][];
3
+ declare function isShallowEqual(a: readonly any[], b: readonly any[]): boolean;
4
+ /**
5
+ * Ponyfill for ES2023's findLastIndex.
6
+ */
7
+ declare function findLastIndex<T>(arr: readonly T[], predicate: (item: T) => boolean): number;
8
+ declare function groupBy<T extends any, K>(arr: Iterable<T>, key: (item: T) => K): Map<K, T[]>;
9
+ declare function range(endExclusive: number): number[];
10
+ declare function range(startInclusive: number, endExclusive: number): number[];
11
+ declare function range(startInclusive: number, endExclusive: number, step: number): number[];
12
+ declare function rotateLeft(arr: readonly any[], n: number): any[];
13
+ declare function rotateRight(arr: readonly any[], n: number): any[];
14
+ declare function shuffle<T>(arr: readonly T[]): T[];
15
+ declare function outerProduct<T, U>(arr1: readonly T[], arr2: readonly U[]): [T, U][];
16
+ declare function unique<T>(arr: readonly T[]): T[];
17
+
18
+ export { enumerate, findLastIndex, groupBy, isShallowEqual, outerProduct, range, rotateLeft, rotateRight, shuffle, typedIncludes, unique };
@@ -1,16 +1,18 @@
1
- export declare function typedIncludes<T extends readonly any[]>(arr: T, item: unknown): item is T[number];
2
- export declare function enumerate<T extends readonly any[]>(arr: T): [number, T[number]][];
3
- export declare function isShallowEqual(a: readonly any[], b: readonly any[]): boolean;
1
+ declare function typedIncludes<T extends readonly any[]>(arr: T, item: unknown): item is T[number];
2
+ declare function enumerate<T extends readonly any[]>(arr: T): [number, T[number]][];
3
+ declare function isShallowEqual(a: readonly any[], b: readonly any[]): boolean;
4
4
  /**
5
5
  * Ponyfill for ES2023's findLastIndex.
6
6
  */
7
- export declare function findLastIndex<T>(arr: readonly T[], predicate: (item: T) => boolean): number;
8
- export declare function groupBy<T extends any, K>(arr: Iterable<T>, key: (item: T) => K): Map<K, T[]>;
9
- export declare function range(endExclusive: number): number[];
10
- export declare function range(startInclusive: number, endExclusive: number): number[];
11
- export declare function range(startInclusive: number, endExclusive: number, step: number): number[];
12
- export declare function rotateLeft(arr: readonly any[], n: number): any[];
13
- export declare function rotateRight(arr: readonly any[], n: number): any[];
14
- export declare function shuffle<T>(arr: readonly T[]): T[];
15
- export declare function outerProduct<T, U>(arr1: readonly T[], arr2: readonly U[]): [T, U][];
16
- export declare function unique<T>(arr: readonly T[]): T[];
7
+ declare function findLastIndex<T>(arr: readonly T[], predicate: (item: T) => boolean): number;
8
+ declare function groupBy<T extends any, K>(arr: Iterable<T>, key: (item: T) => K): Map<K, T[]>;
9
+ declare function range(endExclusive: number): number[];
10
+ declare function range(startInclusive: number, endExclusive: number): number[];
11
+ declare function range(startInclusive: number, endExclusive: number, step: number): number[];
12
+ declare function rotateLeft(arr: readonly any[], n: number): any[];
13
+ declare function rotateRight(arr: readonly any[], n: number): any[];
14
+ declare function shuffle<T>(arr: readonly T[]): T[];
15
+ declare function outerProduct<T, U>(arr1: readonly T[], arr2: readonly U[]): [T, U][];
16
+ declare function unique<T>(arr: readonly T[]): T[];
17
+
18
+ export { enumerate, findLastIndex, groupBy, isShallowEqual, outerProduct, range, rotateLeft, rotateRight, shuffle, typedIncludes, unique };
@@ -1,180 +1,113 @@
1
- import { remainder } from "./math";
2
- export function typedIncludes(arr, item) {
3
- return arr.includes(item);
4
- }
5
- import.meta.vitest?.test("typedIncludes", ({ expect }) => {
6
- const arr = [1, 2, 3];
7
- expect(typedIncludes(arr, 1)).toBe(true);
8
- expect(typedIncludes(arr, 4)).toBe(false);
9
- expect(typedIncludes(arr, "1")).toBe(false);
10
- const strArr = ["a", "b", "c"];
11
- expect(typedIncludes(strArr, "a")).toBe(true);
12
- expect(typedIncludes(strArr, "d")).toBe(false);
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/arrays.tsx
21
+ var arrays_exports = {};
22
+ __export(arrays_exports, {
23
+ enumerate: () => enumerate,
24
+ findLastIndex: () => findLastIndex,
25
+ groupBy: () => groupBy,
26
+ isShallowEqual: () => isShallowEqual,
27
+ outerProduct: () => outerProduct,
28
+ range: () => range,
29
+ rotateLeft: () => rotateLeft,
30
+ rotateRight: () => rotateRight,
31
+ shuffle: () => shuffle,
32
+ typedIncludes: () => typedIncludes,
33
+ unique: () => unique
13
34
  });
14
- export function enumerate(arr) {
15
- return arr.map((item, index) => [index, item]);
35
+ module.exports = __toCommonJS(arrays_exports);
36
+ var import_math = require("./math");
37
+ function typedIncludes(arr, item) {
38
+ return arr.includes(item);
16
39
  }
17
- import.meta.vitest?.test("enumerate", ({ expect }) => {
18
- expect(enumerate([])).toEqual([]);
19
- expect(enumerate([1, 2, 3])).toEqual([[0, 1], [1, 2], [2, 3]]);
20
- expect(enumerate(["a", "b", "c"])).toEqual([[0, "a"], [1, "b"], [2, "c"]]);
21
- });
22
- export function isShallowEqual(a, b) {
23
- if (a.length !== b.length)
24
- return false;
25
- for (let i = 0; i < a.length; i++) {
26
- if (a[i] !== b[i])
27
- return false;
28
- }
29
- return true;
40
+ function enumerate(arr) {
41
+ return arr.map((item, index) => [index, item]);
30
42
  }
31
- import.meta.vitest?.test("isShallowEqual", ({ expect }) => {
32
- expect(isShallowEqual([], [])).toBe(true);
33
- expect(isShallowEqual([1, 2, 3], [1, 2, 3])).toBe(true);
34
- expect(isShallowEqual([1, 2, 3], [1, 2, 4])).toBe(false);
35
- expect(isShallowEqual([1, 2, 3], [1, 2])).toBe(false);
36
- expect(isShallowEqual([1, 2], [1, 2, 3])).toBe(false);
37
- // Test with objects (reference equality)
38
- const obj1 = { a: 1 };
39
- const obj2 = { a: 1 };
40
- expect(isShallowEqual([obj1], [obj1])).toBe(true);
41
- expect(isShallowEqual([obj1], [obj2])).toBe(false);
42
- });
43
- /**
44
- * Ponyfill for ES2023's findLastIndex.
45
- */
46
- export function findLastIndex(arr, predicate) {
47
- for (let i = arr.length - 1; i >= 0; i--) {
48
- if (predicate(arr[i]))
49
- return i;
50
- }
51
- return -1;
43
+ function isShallowEqual(a, b) {
44
+ if (a.length !== b.length) return false;
45
+ for (let i = 0; i < a.length; i++) {
46
+ if (a[i] !== b[i]) return false;
47
+ }
48
+ return true;
52
49
  }
53
- import.meta.vitest?.test("findLastIndex", ({ expect }) => {
54
- expect(findLastIndex([], () => true)).toBe(-1);
55
- expect(findLastIndex([1, 2, 3, 4, 5], x => x % 2 === 0)).toBe(3); // 4 is at index 3
56
- expect(findLastIndex([1, 2, 3, 4, 5], x => x > 10)).toBe(-1);
57
- expect(findLastIndex([1, 2, 3, 2, 1], x => x === 2)).toBe(3);
58
- expect(findLastIndex([1, 2, 3], x => x === 1)).toBe(0);
59
- });
60
- export function groupBy(arr, key) {
61
- const result = new Map;
62
- for (const item of arr) {
63
- const k = key(item);
64
- if (result.get(k) === undefined)
65
- result.set(k, []);
66
- result.get(k).push(item);
67
- }
68
- return result;
50
+ function findLastIndex(arr, predicate) {
51
+ for (let i = arr.length - 1; i >= 0; i--) {
52
+ if (predicate(arr[i])) return i;
53
+ }
54
+ return -1;
69
55
  }
70
- import.meta.vitest?.test("groupBy", ({ expect }) => {
71
- expect(groupBy([], (x) => x)).toEqual(new Map());
72
- const numbers = [1, 2, 3, 4, 5, 6];
73
- const grouped = groupBy(numbers, (n) => n % 2 === 0 ? "even" : "odd");
74
- expect(grouped.get("even")).toEqual([2, 4, 6]);
75
- expect(grouped.get("odd")).toEqual([1, 3, 5]);
76
- // Check the actual lengths of the words to ensure our test is correct
77
- const words = ["apple", "banana", "cherry", "date", "elderberry"];
78
- const byLength = groupBy(words, (w) => w.length);
79
- // Adjust expectations based on actual word lengths
80
- expect(byLength.get(5)).toEqual(["apple"]);
81
- expect(byLength.get(6)).toEqual(["banana", "cherry"]);
82
- expect(byLength.get(4)).toEqual(["date"]);
83
- expect(byLength.get(10)).toEqual(["elderberry"]);
84
- });
85
- export function range(startInclusive, endExclusive, step) {
86
- if (endExclusive === undefined) {
87
- endExclusive = startInclusive;
88
- startInclusive = 0;
89
- }
90
- if (step === undefined)
91
- step = 1;
92
- const result = [];
93
- for (let i = startInclusive; step > 0 ? (i < endExclusive) : (i > endExclusive); i += step) {
94
- result.push(i);
95
- }
96
- return result;
56
+ function groupBy(arr, key) {
57
+ const result = /* @__PURE__ */ new Map();
58
+ for (const item of arr) {
59
+ const k = key(item);
60
+ if (result.get(k) === void 0) result.set(k, []);
61
+ result.get(k).push(item);
62
+ }
63
+ return result;
97
64
  }
98
- import.meta.vitest?.test("range", ({ expect }) => {
99
- expect(range(5)).toEqual([0, 1, 2, 3, 4]);
100
- expect(range(2, 5)).toEqual([2, 3, 4]);
101
- expect(range(1, 10, 2)).toEqual([1, 3, 5, 7, 9]);
102
- expect(range(5, 0, -1)).toEqual([5, 4, 3, 2, 1]);
103
- expect(range(0, 0)).toEqual([]);
104
- expect(range(0, 10, 3)).toEqual([0, 3, 6, 9]);
105
- });
106
- export function rotateLeft(arr, n) {
107
- if (arr.length === 0)
108
- return [];
109
- const index = remainder(n, arr.length);
110
- return [...arr.slice(index), ...arr.slice(0, index)];
65
+ function range(startInclusive, endExclusive, step) {
66
+ if (endExclusive === void 0) {
67
+ endExclusive = startInclusive;
68
+ startInclusive = 0;
69
+ }
70
+ if (step === void 0) step = 1;
71
+ const result = [];
72
+ for (let i = startInclusive; step > 0 ? i < endExclusive : i > endExclusive; i += step) {
73
+ result.push(i);
74
+ }
75
+ return result;
111
76
  }
112
- import.meta.vitest?.test("rotateLeft", ({ expect }) => {
113
- expect(rotateLeft([], 1)).toEqual([]);
114
- expect(rotateLeft([1, 2, 3, 4, 5], 0)).toEqual([1, 2, 3, 4, 5]);
115
- expect(rotateLeft([1, 2, 3, 4, 5], 1)).toEqual([2, 3, 4, 5, 1]);
116
- expect(rotateLeft([1, 2, 3, 4, 5], 3)).toEqual([4, 5, 1, 2, 3]);
117
- expect(rotateLeft([1, 2, 3, 4, 5], 5)).toEqual([1, 2, 3, 4, 5]);
118
- expect(rotateLeft([1, 2, 3, 4, 5], 6)).toEqual([2, 3, 4, 5, 1]);
119
- });
120
- export function rotateRight(arr, n) {
121
- return rotateLeft(arr, -n);
77
+ function rotateLeft(arr, n) {
78
+ if (arr.length === 0) return [];
79
+ const index = (0, import_math.remainder)(n, arr.length);
80
+ return [...arr.slice(index), ...arr.slice(0, index)];
122
81
  }
123
- import.meta.vitest?.test("rotateRight", ({ expect }) => {
124
- expect(rotateRight([], 1)).toEqual([]);
125
- expect(rotateRight([1, 2, 3, 4, 5], 0)).toEqual([1, 2, 3, 4, 5]);
126
- expect(rotateRight([1, 2, 3, 4, 5], 1)).toEqual([5, 1, 2, 3, 4]);
127
- expect(rotateRight([1, 2, 3, 4, 5], 3)).toEqual([3, 4, 5, 1, 2]);
128
- expect(rotateRight([1, 2, 3, 4, 5], 5)).toEqual([1, 2, 3, 4, 5]);
129
- expect(rotateRight([1, 2, 3, 4, 5], 6)).toEqual([5, 1, 2, 3, 4]);
130
- });
131
- export function shuffle(arr) {
132
- const result = [...arr];
133
- for (let i = result.length - 1; i > 0; i--) {
134
- const j = Math.floor(Math.random() * (i + 1));
135
- [result[i], result[j]] = [result[j], result[i]];
136
- }
137
- return result;
82
+ function rotateRight(arr, n) {
83
+ return rotateLeft(arr, -n);
138
84
  }
139
- import.meta.vitest?.test("shuffle", ({ expect }) => {
140
- // Test empty array
141
- expect(shuffle([])).toEqual([]);
142
- // Test single element array
143
- expect(shuffle([1])).toEqual([1]);
144
- // Test that shuffle returns a new array
145
- const original = [1, 2, 3, 4, 5];
146
- const shuffled = shuffle(original);
147
- expect(shuffled).not.toBe(original);
148
- // Test that all elements are preserved
149
- expect(shuffled.sort((a, b) => a - b)).toEqual(original);
150
- // Test with a larger array to ensure randomness
151
- // This is a probabilistic test, but it's very unlikely to fail
152
- const large = Array.from({ length: 100 }, (_, i) => i);
153
- const shuffledLarge = shuffle(large);
154
- expect(shuffledLarge).not.toEqual(large);
155
- expect(shuffledLarge.sort((a, b) => a - b)).toEqual(large);
156
- });
157
- export function outerProduct(arr1, arr2) {
158
- return arr1.flatMap((item1) => arr2.map((item2) => [item1, item2]));
85
+ function shuffle(arr) {
86
+ const result = [...arr];
87
+ for (let i = result.length - 1; i > 0; i--) {
88
+ const j = Math.floor(Math.random() * (i + 1));
89
+ [result[i], result[j]] = [result[j], result[i]];
90
+ }
91
+ return result;
159
92
  }
160
- import.meta.vitest?.test("outerProduct", ({ expect }) => {
161
- expect(outerProduct([], [])).toEqual([]);
162
- expect(outerProduct([1], [])).toEqual([]);
163
- expect(outerProduct([], [1])).toEqual([]);
164
- expect(outerProduct([1], [2])).toEqual([[1, 2]]);
165
- expect(outerProduct([1, 2], [3, 4])).toEqual([[1, 3], [1, 4], [2, 3], [2, 4]]);
166
- expect(outerProduct(["a", "b"], [1, 2])).toEqual([["a", 1], ["a", 2], ["b", 1], ["b", 2]]);
167
- });
168
- export function unique(arr) {
169
- return [...new Set(arr)];
93
+ function outerProduct(arr1, arr2) {
94
+ return arr1.flatMap((item1) => arr2.map((item2) => [item1, item2]));
95
+ }
96
+ function unique(arr) {
97
+ return [...new Set(arr)];
170
98
  }
171
- import.meta.vitest?.test("unique", ({ expect }) => {
172
- expect(unique([])).toEqual([]);
173
- expect(unique([1, 2, 3])).toEqual([1, 2, 3]);
174
- expect(unique([1, 2, 2, 3, 1, 3])).toEqual([1, 2, 3]);
175
- // Test with objects (reference equality)
176
- const obj = { a: 1 };
177
- expect(unique([obj, obj])).toEqual([obj]);
178
- // Test with different types
179
- expect(unique([1, "1", true, 1, "1", true])).toEqual([1, "1", true]);
99
+ // Annotate the CommonJS export names for ESM import in node:
100
+ 0 && (module.exports = {
101
+ enumerate,
102
+ findLastIndex,
103
+ groupBy,
104
+ isShallowEqual,
105
+ outerProduct,
106
+ range,
107
+ rotateLeft,
108
+ rotateRight,
109
+ shuffle,
110
+ typedIncludes,
111
+ unique
180
112
  });
113
+ //# sourceMappingURL=arrays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/arrays.tsx"],"sourcesContent":["import { remainder } from \"./math\";\n\nexport function typedIncludes<T extends readonly any[]>(arr: T, item: unknown): item is T[number] {\n return arr.includes(item);\n}\nundefined?.test(\"typedIncludes\", ({ expect }) => {\n const arr = [1, 2, 3] as const;\n expect(typedIncludes(arr, 1)).toBe(true);\n expect(typedIncludes(arr, 4)).toBe(false);\n expect(typedIncludes(arr, \"1\")).toBe(false);\n\n const strArr = [\"a\", \"b\", \"c\"] as const;\n expect(typedIncludes(strArr, \"a\")).toBe(true);\n expect(typedIncludes(strArr, \"d\")).toBe(false);\n});\n\nexport function enumerate<T extends readonly any[]>(arr: T): [number, T[number]][] {\n return arr.map((item, index) => [index, item]);\n}\nundefined?.test(\"enumerate\", ({ expect }) => {\n expect(enumerate([])).toEqual([]);\n expect(enumerate([1, 2, 3])).toEqual([[0, 1], [1, 2], [2, 3]]);\n expect(enumerate([\"a\", \"b\", \"c\"])).toEqual([[0, \"a\"], [1, \"b\"], [2, \"c\"]]);\n});\n\nexport function isShallowEqual(a: readonly any[], b: readonly any[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\nundefined?.test(\"isShallowEqual\", ({ expect }) => {\n expect(isShallowEqual([], [])).toBe(true);\n expect(isShallowEqual([1, 2, 3], [1, 2, 3])).toBe(true);\n expect(isShallowEqual([1, 2, 3], [1, 2, 4])).toBe(false);\n expect(isShallowEqual([1, 2, 3], [1, 2])).toBe(false);\n expect(isShallowEqual([1, 2], [1, 2, 3])).toBe(false);\n // Test with objects (reference equality)\n const obj1 = { a: 1 };\n const obj2 = { a: 1 };\n expect(isShallowEqual([obj1], [obj1])).toBe(true);\n expect(isShallowEqual([obj1], [obj2])).toBe(false);\n});\n\n/**\n * Ponyfill for ES2023's findLastIndex.\n */\nexport function findLastIndex<T>(arr: readonly T[], predicate: (item: T) => boolean): number {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (predicate(arr[i])) return i;\n }\n return -1;\n}\nundefined?.test(\"findLastIndex\", ({ expect }) => {\n expect(findLastIndex([], () => true)).toBe(-1);\n expect(findLastIndex([1, 2, 3, 4, 5], x => x % 2 === 0)).toBe(3); // 4 is at index 3\n expect(findLastIndex([1, 2, 3, 4, 5], x => x > 10)).toBe(-1);\n expect(findLastIndex([1, 2, 3, 2, 1], x => x === 2)).toBe(3);\n expect(findLastIndex([1, 2, 3], x => x === 1)).toBe(0);\n});\n\nexport function groupBy<T extends any, K>(\n arr: Iterable<T>,\n key: (item: T) => K,\n): Map<K, T[]> {\n const result = new Map<K, T[]>;\n for (const item of arr) {\n const k = key(item);\n if (result.get(k) === undefined) result.set(k, []);\n result.get(k)!.push(item);\n }\n return result;\n}\nundefined?.test(\"groupBy\", ({ expect }) => {\n expect(groupBy([], (x) => x)).toEqual(new Map());\n\n const numbers = [1, 2, 3, 4, 5, 6];\n const grouped = groupBy(numbers, (n) => n % 2 === 0 ? \"even\" : \"odd\");\n expect(grouped.get(\"even\")).toEqual([2, 4, 6]);\n expect(grouped.get(\"odd\")).toEqual([1, 3, 5]);\n\n // Check the actual lengths of the words to ensure our test is correct\n const words = [\"apple\", \"banana\", \"cherry\", \"date\", \"elderberry\"];\n\n const byLength = groupBy(words, (w) => w.length);\n // Adjust expectations based on actual word lengths\n expect(byLength.get(5)).toEqual([\"apple\"]);\n expect(byLength.get(6)).toEqual([\"banana\", \"cherry\"]);\n expect(byLength.get(4)).toEqual([\"date\"]);\n expect(byLength.get(10)).toEqual([\"elderberry\"]);\n});\n\nexport function range(endExclusive: number): number[];\nexport function range(startInclusive: number, endExclusive: number): number[];\nexport function range(startInclusive: number, endExclusive: number, step: number): number[];\nexport function range(startInclusive: number, endExclusive?: number, step?: number): number[] {\n if (endExclusive === undefined) {\n endExclusive = startInclusive;\n startInclusive = 0;\n }\n if (step === undefined) step = 1;\n\n const result = [];\n for (let i = startInclusive; step > 0 ? (i < endExclusive) : (i > endExclusive); i += step) {\n result.push(i);\n }\n return result;\n}\nundefined?.test(\"range\", ({ expect }) => {\n expect(range(5)).toEqual([0, 1, 2, 3, 4]);\n expect(range(2, 5)).toEqual([2, 3, 4]);\n expect(range(1, 10, 2)).toEqual([1, 3, 5, 7, 9]);\n expect(range(5, 0, -1)).toEqual([5, 4, 3, 2, 1]);\n expect(range(0, 0)).toEqual([]);\n expect(range(0, 10, 3)).toEqual([0, 3, 6, 9]);\n});\n\n\nexport function rotateLeft(arr: readonly any[], n: number): any[] {\n if (arr.length === 0) return [];\n const index = remainder(n, arr.length);\n return [...arr.slice(index), ...arr.slice(0, index)];\n}\nundefined?.test(\"rotateLeft\", ({ expect }) => {\n expect(rotateLeft([], 1)).toEqual([]);\n expect(rotateLeft([1, 2, 3, 4, 5], 0)).toEqual([1, 2, 3, 4, 5]);\n expect(rotateLeft([1, 2, 3, 4, 5], 1)).toEqual([2, 3, 4, 5, 1]);\n expect(rotateLeft([1, 2, 3, 4, 5], 3)).toEqual([4, 5, 1, 2, 3]);\n expect(rotateLeft([1, 2, 3, 4, 5], 5)).toEqual([1, 2, 3, 4, 5]);\n expect(rotateLeft([1, 2, 3, 4, 5], 6)).toEqual([2, 3, 4, 5, 1]);\n});\n\nexport function rotateRight(arr: readonly any[], n: number): any[] {\n return rotateLeft(arr, -n);\n}\nundefined?.test(\"rotateRight\", ({ expect }) => {\n expect(rotateRight([], 1)).toEqual([]);\n expect(rotateRight([1, 2, 3, 4, 5], 0)).toEqual([1, 2, 3, 4, 5]);\n expect(rotateRight([1, 2, 3, 4, 5], 1)).toEqual([5, 1, 2, 3, 4]);\n expect(rotateRight([1, 2, 3, 4, 5], 3)).toEqual([3, 4, 5, 1, 2]);\n expect(rotateRight([1, 2, 3, 4, 5], 5)).toEqual([1, 2, 3, 4, 5]);\n expect(rotateRight([1, 2, 3, 4, 5], 6)).toEqual([5, 1, 2, 3, 4]);\n});\n\n\nexport function shuffle<T>(arr: readonly T[]): T[] {\n const result = [...arr];\n for (let i = result.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [result[i], result[j]] = [result[j], result[i]];\n }\n return result;\n}\nundefined?.test(\"shuffle\", ({ expect }) => {\n // Test empty array\n expect(shuffle([])).toEqual([]);\n\n // Test single element array\n expect(shuffle([1])).toEqual([1]);\n\n // Test that shuffle returns a new array\n const original = [1, 2, 3, 4, 5];\n const shuffled = shuffle(original);\n expect(shuffled).not.toBe(original);\n\n // Test that all elements are preserved\n expect(shuffled.sort((a, b) => a - b)).toEqual(original);\n\n // Test with a larger array to ensure randomness\n // This is a probabilistic test, but it's very unlikely to fail\n const large = Array.from({ length: 100 }, (_, i) => i);\n const shuffledLarge = shuffle(large);\n expect(shuffledLarge).not.toEqual(large);\n expect(shuffledLarge.sort((a, b) => a - b)).toEqual(large);\n});\n\n\nexport function outerProduct<T, U>(arr1: readonly T[], arr2: readonly U[]): [T, U][] {\n return arr1.flatMap((item1) => arr2.map((item2) => [item1, item2] as [T, U]));\n}\nundefined?.test(\"outerProduct\", ({ expect }) => {\n expect(outerProduct([], [])).toEqual([]);\n expect(outerProduct([1], [])).toEqual([]);\n expect(outerProduct([], [1])).toEqual([]);\n expect(outerProduct([1], [2])).toEqual([[1, 2]]);\n expect(outerProduct([1, 2], [3, 4])).toEqual([[1, 3], [1, 4], [2, 3], [2, 4]]);\n expect(outerProduct([\"a\", \"b\"], [1, 2])).toEqual([[\"a\", 1], [\"a\", 2], [\"b\", 1], [\"b\", 2]]);\n});\n\nexport function unique<T>(arr: readonly T[]): T[] {\n return [...new Set(arr)];\n}\nundefined?.test(\"unique\", ({ expect }) => {\n expect(unique([])).toEqual([]);\n expect(unique([1, 2, 3])).toEqual([1, 2, 3]);\n expect(unique([1, 2, 2, 3, 1, 3])).toEqual([1, 2, 3]);\n // Test with objects (reference equality)\n const obj = { a: 1 };\n expect(unique([obj, obj])).toEqual([obj]);\n // Test with different types\n expect(unique([1, \"1\", true, 1, \"1\", true])).toEqual([1, \"1\", true]);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAEnB,SAAS,cAAwC,KAAQ,MAAkC;AAChG,SAAO,IAAI,SAAS,IAAI;AAC1B;AAYO,SAAS,UAAoC,KAA+B;AACjF,SAAO,IAAI,IAAI,CAAC,MAAM,UAAU,CAAC,OAAO,IAAI,CAAC;AAC/C;AAOO,SAAS,eAAe,GAAmB,GAA4B;AAC5E,MAAI,EAAE,WAAW,EAAE,OAAQ,QAAO;AAClC,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AACjC,QAAI,EAAE,CAAC,MAAM,EAAE,CAAC,EAAG,QAAO;AAAA,EAC5B;AACA,SAAO;AACT;AAiBO,SAAS,cAAiB,KAAmB,WAAyC;AAC3F,WAAS,IAAI,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK;AACxC,QAAI,UAAU,IAAI,CAAC,CAAC,EAAG,QAAO;AAAA,EAChC;AACA,SAAO;AACT;AASO,SAAS,QACd,KACA,KACa;AACb,QAAM,SAAS,oBAAI;AACnB,aAAW,QAAQ,KAAK;AACtB,UAAM,IAAI,IAAI,IAAI;AAClB,QAAI,OAAO,IAAI,CAAC,MAAM,OAAW,QAAO,IAAI,GAAG,CAAC,CAAC;AACjD,WAAO,IAAI,CAAC,EAAG,KAAK,IAAI;AAAA,EAC1B;AACA,SAAO;AACT;AAuBO,SAAS,MAAM,gBAAwB,cAAuB,MAAyB;AAC5F,MAAI,iBAAiB,QAAW;AAC9B,mBAAe;AACf,qBAAiB;AAAA,EACnB;AACA,MAAI,SAAS,OAAW,QAAO;AAE/B,QAAM,SAAS,CAAC;AAChB,WAAS,IAAI,gBAAgB,OAAO,IAAK,IAAI,eAAiB,IAAI,cAAe,KAAK,MAAM;AAC1F,WAAO,KAAK,CAAC;AAAA,EACf;AACA,SAAO;AACT;AAWO,SAAS,WAAW,KAAqB,GAAkB;AAChE,MAAI,IAAI,WAAW,EAAG,QAAO,CAAC;AAC9B,QAAM,YAAQ,uBAAU,GAAG,IAAI,MAAM;AACrC,SAAO,CAAC,GAAG,IAAI,MAAM,KAAK,GAAG,GAAG,IAAI,MAAM,GAAG,KAAK,CAAC;AACrD;AAUO,SAAS,YAAY,KAAqB,GAAkB;AACjE,SAAO,WAAW,KAAK,CAAC,CAAC;AAC3B;AAWO,SAAS,QAAW,KAAwB;AACjD,QAAM,SAAS,CAAC,GAAG,GAAG;AACtB,WAAS,IAAI,OAAO,SAAS,GAAG,IAAI,GAAG,KAAK;AAC1C,UAAM,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,EAAE;AAC5C,KAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AAAA,EAChD;AACA,SAAO;AACT;AAyBO,SAAS,aAAmB,MAAoB,MAA8B;AACnF,SAAO,KAAK,QAAQ,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU,CAAC,OAAO,KAAK,CAAW,CAAC;AAC9E;AAUO,SAAS,OAAU,KAAwB;AAChD,SAAO,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC;AACzB;","names":[]}
@@ -0,0 +1,4 @@
1
+ declare function fileToBase64(file: File): Promise<string>;
2
+ declare function validateBase64Image(base64: string): boolean;
3
+
4
+ export { fileToBase64, validateBase64Image };
@@ -1,2 +1,4 @@
1
- export declare function fileToBase64(file: File): Promise<string>;
2
- export declare function validateBase64Image(base64: string): boolean;
1
+ declare function fileToBase64(file: File): Promise<string>;
2
+ declare function validateBase64Image(base64: string): boolean;
3
+
4
+ export { fileToBase64, validateBase64Image };
@@ -1,23 +1,44 @@
1
- export function fileToBase64(file) {
2
- return new Promise((resolve, reject) => {
3
- const reader = new FileReader();
4
- reader.readAsDataURL(file);
5
- reader.onload = () => resolve(reader.result);
6
- reader.onerror = error => reject(error);
7
- });
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/base64.tsx
21
+ var base64_exports = {};
22
+ __export(base64_exports, {
23
+ fileToBase64: () => fileToBase64,
24
+ validateBase64Image: () => validateBase64Image
25
+ });
26
+ module.exports = __toCommonJS(base64_exports);
27
+ function fileToBase64(file) {
28
+ return new Promise((resolve, reject) => {
29
+ const reader = new FileReader();
30
+ reader.readAsDataURL(file);
31
+ reader.onload = () => resolve(reader.result);
32
+ reader.onerror = (error) => reject(error);
33
+ });
8
34
  }
9
- export function validateBase64Image(base64) {
10
- const base64ImageRegex = /^data:image\/(png|jpg|jpeg|gif|bmp|webp);base64,[A-Za-z0-9+/]+={0,2}$|^[A-Za-z0-9+/]+={0,2}$/;
11
- return base64ImageRegex.test(base64);
35
+ function validateBase64Image(base64) {
36
+ const base64ImageRegex = /^data:image\/(png|jpg|jpeg|gif|bmp|webp);base64,[A-Za-z0-9+/]+={0,2}$|^[A-Za-z0-9+/]+={0,2}$/;
37
+ return base64ImageRegex.test(base64);
12
38
  }
13
- import.meta.vitest?.test("validateBase64Image", ({ expect }) => {
14
- // Valid base64 image strings
15
- expect(validateBase64Image("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==")).toBe(true);
16
- expect(validateBase64Image("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAABAAEDASIAAhEBAxEB/8QAHwAAAQUBA")).toBe(true);
17
- expect(validateBase64Image("ABC123")).toBe(true);
18
- // Invalid base64 image strings
19
- expect(validateBase64Image("data:text/plain;base64,SGVsbG8gV29ybGQ=")).toBe(false);
20
- expect(validateBase64Image("data:image/png;base64,invalid!base64")).toBe(false);
21
- expect(validateBase64Image("not a base64 string")).toBe(false);
22
- expect(validateBase64Image("")).toBe(false);
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ fileToBase64,
42
+ validateBase64Image
23
43
  });
44
+ //# sourceMappingURL=base64.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/base64.tsx"],"sourcesContent":["export function fileToBase64(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => resolve(reader.result as string);\n reader.onerror = error => reject(error);\n });\n}\n\nexport function validateBase64Image(base64: string): boolean {\n const base64ImageRegex = /^data:image\\/(png|jpg|jpeg|gif|bmp|webp);base64,[A-Za-z0-9+/]+={0,2}$|^[A-Za-z0-9+/]+={0,2}$/;\n return base64ImageRegex.test(base64);\n}\nundefined?.test(\"validateBase64Image\", ({ expect }) => {\n // Valid base64 image strings\n expect(validateBase64Image(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==\")).toBe(true);\n expect(validateBase64Image(\"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAABAAEDASIAAhEBAxEB/8QAHwAAAQUBA\")).toBe(true);\n expect(validateBase64Image(\"ABC123\")).toBe(true);\n // Invalid base64 image strings\n expect(validateBase64Image(\"data:text/plain;base64,SGVsbG8gV29ybGQ=\")).toBe(false);\n expect(validateBase64Image(\"data:image/png;base64,invalid!base64\")).toBe(false);\n expect(validateBase64Image(\"not a base64 string\")).toBe(false);\n expect(validateBase64Image(\"\")).toBe(false);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,aAAa,MAA6B;AACxD,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAS,IAAI,WAAW;AAC9B,WAAO,cAAc,IAAI;AACzB,WAAO,SAAS,MAAM,QAAQ,OAAO,MAAgB;AACrD,WAAO,UAAU,WAAS,OAAO,KAAK;AAAA,EACxC,CAAC;AACH;AAEO,SAAS,oBAAoB,QAAyB;AAC3D,QAAM,mBAAmB;AACzB,SAAO,iBAAiB,KAAK,MAAM;AACrC;","names":[]}
@@ -0,0 +1,6 @@
1
+ type Truthy<T> = T extends null | undefined | 0 | "" | false ? false : true;
2
+ type Falsy<T> = T extends null | undefined | 0 | "" | false ? true : false;
3
+ declare function isTruthy<T>(value: T): value is T & Truthy<T>;
4
+ declare function isFalsy<T>(value: T): value is T & Falsy<T>;
5
+
6
+ export { type Falsy, type Truthy, isFalsy, isTruthy };
@@ -1,4 +1,6 @@
1
- export type Truthy<T> = T extends null | undefined | 0 | "" | false ? false : true;
2
- export type Falsy<T> = T extends null | undefined | 0 | "" | false ? true : false;
3
- export declare function isTruthy<T>(value: T): value is T & Truthy<T>;
4
- export declare function isFalsy<T>(value: T): value is T & Falsy<T>;
1
+ type Truthy<T> = T extends null | undefined | 0 | "" | false ? false : true;
2
+ type Falsy<T> = T extends null | undefined | 0 | "" | false ? true : false;
3
+ declare function isTruthy<T>(value: T): value is T & Truthy<T>;
4
+ declare function isFalsy<T>(value: T): value is T & Falsy<T>;
5
+
6
+ export { type Falsy, type Truthy, isFalsy, isTruthy };
@@ -1,30 +1,38 @@
1
- export function isTruthy(value) {
2
- return !!value;
3
- }
4
- import.meta.vitest?.test("isTruthy", ({ expect }) => {
5
- expect(isTruthy(true)).toBe(true);
6
- expect(isTruthy(1)).toBe(true);
7
- expect(isTruthy("hello")).toBe(true);
8
- expect(isTruthy({})).toBe(true);
9
- expect(isTruthy([])).toBe(true);
10
- expect(isTruthy(false)).toBe(false);
11
- expect(isTruthy(0)).toBe(false);
12
- expect(isTruthy("")).toBe(false);
13
- expect(isTruthy(null)).toBe(false);
14
- expect(isTruthy(undefined)).toBe(false);
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/booleans.tsx
21
+ var booleans_exports = {};
22
+ __export(booleans_exports, {
23
+ isFalsy: () => isFalsy,
24
+ isTruthy: () => isTruthy
15
25
  });
16
- export function isFalsy(value) {
17
- return !value;
26
+ module.exports = __toCommonJS(booleans_exports);
27
+ function isTruthy(value) {
28
+ return !!value;
29
+ }
30
+ function isFalsy(value) {
31
+ return !value;
18
32
  }
19
- import.meta.vitest?.test("isFalsy", ({ expect }) => {
20
- expect(isFalsy(false)).toBe(true);
21
- expect(isFalsy(0)).toBe(true);
22
- expect(isFalsy("")).toBe(true);
23
- expect(isFalsy(null)).toBe(true);
24
- expect(isFalsy(undefined)).toBe(true);
25
- expect(isFalsy(true)).toBe(false);
26
- expect(isFalsy(1)).toBe(false);
27
- expect(isFalsy("hello")).toBe(false);
28
- expect(isFalsy({})).toBe(false);
29
- expect(isFalsy([])).toBe(false);
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ isFalsy,
36
+ isTruthy
30
37
  });
38
+ //# sourceMappingURL=booleans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/booleans.tsx"],"sourcesContent":["export type Truthy<T> = T extends null | undefined | 0 | \"\" | false ? false : true;\nexport type Falsy<T> = T extends null | undefined | 0 | \"\" | false ? true : false;\n\nexport function isTruthy<T>(value: T): value is T & Truthy<T> {\n return !!value;\n}\nundefined?.test(\"isTruthy\", ({ expect }) => {\n expect(isTruthy(true)).toBe(true);\n expect(isTruthy(1)).toBe(true);\n expect(isTruthy(\"hello\")).toBe(true);\n expect(isTruthy({})).toBe(true);\n expect(isTruthy([])).toBe(true);\n expect(isTruthy(false)).toBe(false);\n expect(isTruthy(0)).toBe(false);\n expect(isTruthy(\"\")).toBe(false);\n expect(isTruthy(null)).toBe(false);\n expect(isTruthy(undefined)).toBe(false);\n});\n\nexport function isFalsy<T>(value: T): value is T & Falsy<T> {\n return !value;\n}\nundefined?.test(\"isFalsy\", ({ expect }) => {\n expect(isFalsy(false)).toBe(true);\n expect(isFalsy(0)).toBe(true);\n expect(isFalsy(\"\")).toBe(true);\n expect(isFalsy(null)).toBe(true);\n expect(isFalsy(undefined)).toBe(true);\n expect(isFalsy(true)).toBe(false);\n expect(isFalsy(1)).toBe(false);\n expect(isFalsy(\"hello\")).toBe(false);\n expect(isFalsy({})).toBe(false);\n expect(isFalsy([])).toBe(false);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,SAAY,OAAkC;AAC5D,SAAO,CAAC,CAAC;AACX;AAcO,SAAS,QAAW,OAAiC;AAC1D,SAAO,CAAC;AACV;","names":[]}
@@ -0,0 +1,8 @@
1
+ declare function getBrowserCompatibilityReport(): {
2
+ optionalChaining: string | boolean;
3
+ nullishCoalescing: string | boolean;
4
+ weakRef: string | boolean;
5
+ cryptoUuid: string | boolean;
6
+ };
7
+
8
+ export { getBrowserCompatibilityReport };
@@ -1,6 +1,8 @@
1
- export declare function getBrowserCompatibilityReport(): {
1
+ declare function getBrowserCompatibilityReport(): {
2
2
  optionalChaining: string | boolean;
3
3
  nullishCoalescing: string | boolean;
4
4
  weakRef: string | boolean;
5
5
  cryptoUuid: string | boolean;
6
6
  };
7
+
8
+ export { getBrowserCompatibilityReport };