@oxyhq/bloom 0.4.0 → 0.5.1

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 (275) hide show
  1. package/README.md +105 -90
  2. package/lib/commonjs/bottom-sheet/index.js +2 -2
  3. package/lib/commonjs/context-menu/index.js +18 -19
  4. package/lib/commonjs/context-menu/index.js.map +1 -1
  5. package/lib/commonjs/dialog/BloomDialogProvider.js +61 -0
  6. package/lib/commonjs/dialog/BloomDialogProvider.js.map +1 -0
  7. package/lib/commonjs/dialog/BloomDialogProvider.web.js +45 -0
  8. package/lib/commonjs/dialog/BloomDialogProvider.web.js.map +1 -0
  9. package/lib/commonjs/dialog/Dialog.js +197 -100
  10. package/lib/commonjs/dialog/Dialog.js.map +1 -1
  11. package/lib/commonjs/dialog/Dialog.web.js +194 -84
  12. package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
  13. package/lib/commonjs/dialog/SheetShell.js +149 -0
  14. package/lib/commonjs/dialog/SheetShell.js.map +1 -0
  15. package/lib/commonjs/dialog/alert-store.js +116 -0
  16. package/lib/commonjs/dialog/alert-store.js.map +1 -0
  17. package/lib/commonjs/dialog/alert.js +38 -0
  18. package/lib/commonjs/dialog/alert.js.map +1 -0
  19. package/lib/commonjs/dialog/context.js +10 -2
  20. package/lib/commonjs/dialog/context.js.map +1 -1
  21. package/lib/commonjs/dialog/index.js +8 -24
  22. package/lib/commonjs/dialog/index.js.map +1 -1
  23. package/lib/commonjs/dialog/index.web.js +10 -20
  24. package/lib/commonjs/dialog/index.web.js.map +1 -1
  25. package/lib/commonjs/fonts/FontLoader.js +6 -5
  26. package/lib/commonjs/fonts/FontLoader.js.map +1 -1
  27. package/lib/commonjs/fonts/apply-font-faces.js +4 -4
  28. package/lib/commonjs/fonts/apply-font-faces.web.js +13 -12
  29. package/lib/commonjs/fonts/apply-font-faces.web.js.map +1 -1
  30. package/lib/commonjs/fonts/font-assets.js +2 -2
  31. package/lib/commonjs/fonts/font-data.web.js +22 -0
  32. package/lib/commonjs/fonts/font-data.web.js.map +1 -0
  33. package/lib/commonjs/index.js +101 -66
  34. package/lib/commonjs/index.js.map +1 -1
  35. package/lib/commonjs/index.web.js +101 -66
  36. package/lib/commonjs/index.web.js.map +1 -1
  37. package/lib/commonjs/menu/index.js +21 -23
  38. package/lib/commonjs/menu/index.js.map +1 -1
  39. package/lib/commonjs/select/index.js +26 -27
  40. package/lib/commonjs/select/index.js.map +1 -1
  41. package/lib/commonjs/toast/index.js +42 -13
  42. package/lib/commonjs/toast/index.js.map +1 -1
  43. package/lib/commonjs/toast/index.web.js +19 -15
  44. package/lib/commonjs/toast/index.web.js.map +1 -1
  45. package/lib/module/bottom-sheet/index.js +2 -2
  46. package/lib/module/context-menu/index.js +15 -16
  47. package/lib/module/context-menu/index.js.map +1 -1
  48. package/lib/module/dialog/BloomDialogProvider.js +57 -0
  49. package/lib/module/dialog/BloomDialogProvider.js.map +1 -0
  50. package/lib/module/dialog/BloomDialogProvider.web.js +41 -0
  51. package/lib/module/dialog/BloomDialogProvider.web.js.map +1 -0
  52. package/lib/module/dialog/Dialog.js +199 -87
  53. package/lib/module/dialog/Dialog.js.map +1 -1
  54. package/lib/module/dialog/Dialog.web.js +195 -70
  55. package/lib/module/dialog/Dialog.web.js.map +1 -1
  56. package/lib/module/dialog/SheetShell.js +143 -0
  57. package/lib/module/dialog/SheetShell.js.map +1 -0
  58. package/lib/module/dialog/alert-store.js +107 -0
  59. package/lib/module/dialog/alert-store.js.map +1 -0
  60. package/lib/module/dialog/alert.js +35 -0
  61. package/lib/module/dialog/alert.js.map +1 -0
  62. package/lib/module/dialog/context.js +10 -2
  63. package/lib/module/dialog/context.js.map +1 -1
  64. package/lib/module/dialog/index.js +3 -1
  65. package/lib/module/dialog/index.js.map +1 -1
  66. package/lib/module/dialog/index.web.js +9 -7
  67. package/lib/module/dialog/index.web.js.map +1 -1
  68. package/lib/module/fonts/FontLoader.js +6 -5
  69. package/lib/module/fonts/FontLoader.js.map +1 -1
  70. package/lib/module/fonts/apply-font-faces.js +4 -4
  71. package/lib/module/fonts/apply-font-faces.web.js +13 -10
  72. package/lib/module/fonts/apply-font-faces.web.js.map +1 -1
  73. package/lib/module/fonts/font-assets.js +2 -2
  74. package/lib/module/fonts/font-data.web.js +18 -0
  75. package/lib/module/fonts/font-data.web.js.map +1 -0
  76. package/lib/module/fonts/index.web.js +4 -4
  77. package/lib/module/index.js +2 -3
  78. package/lib/module/index.js.map +1 -1
  79. package/lib/module/index.web.js +2 -3
  80. package/lib/module/index.web.js.map +1 -1
  81. package/lib/module/menu/index.js +11 -13
  82. package/lib/module/menu/index.js.map +1 -1
  83. package/lib/module/select/index.js +27 -28
  84. package/lib/module/select/index.js.map +1 -1
  85. package/lib/module/toast/index.js +41 -11
  86. package/lib/module/toast/index.js.map +1 -1
  87. package/lib/module/toast/index.web.js +18 -13
  88. package/lib/module/toast/index.web.js.map +1 -1
  89. package/lib/typescript/commonjs/bottom-sheet/index.d.ts +1 -1
  90. package/lib/typescript/commonjs/context-menu/index.d.ts +4 -3
  91. package/lib/typescript/commonjs/context-menu/index.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/dialog/BloomDialogProvider.d.ts +27 -0
  93. package/lib/typescript/commonjs/dialog/BloomDialogProvider.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/dialog/BloomDialogProvider.web.d.ts +15 -0
  95. package/lib/typescript/commonjs/dialog/BloomDialogProvider.web.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/dialog/Dialog.d.ts +37 -10
  97. package/lib/typescript/commonjs/dialog/Dialog.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/dialog/Dialog.web.d.ts +26 -10
  99. package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/dialog/SheetShell.d.ts +31 -0
  101. package/lib/typescript/commonjs/dialog/SheetShell.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/dialog/alert-store.d.ts +70 -0
  103. package/lib/typescript/commonjs/dialog/alert-store.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/dialog/alert.d.ts +27 -0
  105. package/lib/typescript/commonjs/dialog/alert.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/dialog/context.d.ts +7 -0
  107. package/lib/typescript/commonjs/dialog/context.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/dialog/index.d.ts +5 -2
  109. package/lib/typescript/commonjs/dialog/index.d.ts.map +1 -1
  110. package/lib/typescript/commonjs/dialog/index.web.d.ts +5 -2
  111. package/lib/typescript/commonjs/dialog/index.web.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/dialog/types.d.ts +70 -15
  113. package/lib/typescript/commonjs/dialog/types.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/fonts/FontLoader.d.ts.map +1 -1
  115. package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts +8 -1
  116. package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/fonts/font-data.web.d.ts +5 -0
  118. package/lib/typescript/commonjs/fonts/font-data.web.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/index.d.ts +3 -3
  120. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  121. package/lib/typescript/commonjs/index.web.d.ts +3 -3
  122. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/menu/index.d.ts +4 -4
  124. package/lib/typescript/commonjs/menu/index.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/select/index.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/toast/index.d.ts +32 -3
  127. package/lib/typescript/commonjs/toast/index.d.ts.map +1 -1
  128. package/lib/typescript/commonjs/toast/index.web.d.ts +14 -7
  129. package/lib/typescript/commonjs/toast/index.web.d.ts.map +1 -1
  130. package/lib/typescript/module/bottom-sheet/index.d.ts +1 -1
  131. package/lib/typescript/module/context-menu/index.d.ts +4 -3
  132. package/lib/typescript/module/context-menu/index.d.ts.map +1 -1
  133. package/lib/typescript/module/dialog/BloomDialogProvider.d.ts +27 -0
  134. package/lib/typescript/module/dialog/BloomDialogProvider.d.ts.map +1 -0
  135. package/lib/typescript/module/dialog/BloomDialogProvider.web.d.ts +15 -0
  136. package/lib/typescript/module/dialog/BloomDialogProvider.web.d.ts.map +1 -0
  137. package/lib/typescript/module/dialog/Dialog.d.ts +37 -10
  138. package/lib/typescript/module/dialog/Dialog.d.ts.map +1 -1
  139. package/lib/typescript/module/dialog/Dialog.web.d.ts +26 -10
  140. package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
  141. package/lib/typescript/module/dialog/SheetShell.d.ts +31 -0
  142. package/lib/typescript/module/dialog/SheetShell.d.ts.map +1 -0
  143. package/lib/typescript/module/dialog/alert-store.d.ts +70 -0
  144. package/lib/typescript/module/dialog/alert-store.d.ts.map +1 -0
  145. package/lib/typescript/module/dialog/alert.d.ts +27 -0
  146. package/lib/typescript/module/dialog/alert.d.ts.map +1 -0
  147. package/lib/typescript/module/dialog/context.d.ts +7 -0
  148. package/lib/typescript/module/dialog/context.d.ts.map +1 -1
  149. package/lib/typescript/module/dialog/index.d.ts +5 -2
  150. package/lib/typescript/module/dialog/index.d.ts.map +1 -1
  151. package/lib/typescript/module/dialog/index.web.d.ts +5 -2
  152. package/lib/typescript/module/dialog/index.web.d.ts.map +1 -1
  153. package/lib/typescript/module/dialog/types.d.ts +70 -15
  154. package/lib/typescript/module/dialog/types.d.ts.map +1 -1
  155. package/lib/typescript/module/fonts/FontLoader.d.ts.map +1 -1
  156. package/lib/typescript/module/fonts/apply-font-faces.web.d.ts +8 -1
  157. package/lib/typescript/module/fonts/apply-font-faces.web.d.ts.map +1 -1
  158. package/lib/typescript/module/fonts/font-data.web.d.ts +5 -0
  159. package/lib/typescript/module/fonts/font-data.web.d.ts.map +1 -0
  160. package/lib/typescript/module/index.d.ts +3 -3
  161. package/lib/typescript/module/index.d.ts.map +1 -1
  162. package/lib/typescript/module/index.web.d.ts +3 -3
  163. package/lib/typescript/module/index.web.d.ts.map +1 -1
  164. package/lib/typescript/module/menu/index.d.ts +4 -4
  165. package/lib/typescript/module/menu/index.d.ts.map +1 -1
  166. package/lib/typescript/module/select/index.d.ts.map +1 -1
  167. package/lib/typescript/module/toast/index.d.ts +32 -3
  168. package/lib/typescript/module/toast/index.d.ts.map +1 -1
  169. package/lib/typescript/module/toast/index.web.d.ts +14 -7
  170. package/lib/typescript/module/toast/index.web.d.ts.map +1 -1
  171. package/package.json +38 -18
  172. package/src/__tests__/Dialog.test.tsx +177 -0
  173. package/src/avatar/Avatar.stories.tsx +69 -0
  174. package/src/bottom-sheet/BottomSheet.stories.tsx +92 -0
  175. package/src/bottom-sheet/index.tsx +3 -3
  176. package/src/button/Button.stories.tsx +94 -0
  177. package/src/context-menu/ContextMenu.stories.tsx +71 -0
  178. package/src/context-menu/index.tsx +12 -12
  179. package/src/dialog/BloomDialogProvider.tsx +61 -0
  180. package/src/dialog/BloomDialogProvider.web.tsx +46 -0
  181. package/src/dialog/Dialog.stories.tsx +112 -0
  182. package/src/dialog/Dialog.tsx +217 -64
  183. package/src/dialog/Dialog.web.tsx +240 -75
  184. package/src/dialog/SheetShell.tsx +154 -0
  185. package/src/dialog/alert-store.ts +126 -0
  186. package/src/dialog/alert.ts +42 -0
  187. package/src/dialog/context.ts +14 -3
  188. package/src/dialog/index.ts +14 -2
  189. package/src/dialog/index.web.ts +20 -8
  190. package/src/dialog/types.ts +73 -16
  191. package/src/fonts/FontLoader.tsx +6 -5
  192. package/src/fonts/apply-font-faces.ts +4 -4
  193. package/src/fonts/apply-font-faces.web.ts +18 -10
  194. package/src/fonts/font-assets.ts +2 -2
  195. package/src/fonts/font-data.web.ts +15 -0
  196. package/src/fonts/index.web.ts +4 -4
  197. package/src/index.ts +17 -3
  198. package/src/index.web.ts +17 -3
  199. package/src/loading/Loading.stories.tsx +60 -0
  200. package/src/menu/Menu.stories.tsx +79 -0
  201. package/src/menu/index.tsx +13 -17
  202. package/src/prompt-input/PromptInput.stories.tsx +82 -0
  203. package/src/select/Select.stories.tsx +84 -0
  204. package/src/select/index.tsx +30 -30
  205. package/src/settings-list/SettingsList.stories.tsx +106 -0
  206. package/src/text-field/TextField.stories.tsx +90 -0
  207. package/src/toast/Toast.stories.tsx +109 -0
  208. package/src/toast/index.tsx +55 -11
  209. package/src/toast/index.web.tsx +33 -13
  210. package/lib/commonjs/fonts/assets/BlomusModernus-Bold.woff2 +0 -0
  211. package/lib/commonjs/fonts/assets/BlomusModernus-Regular.woff2 +0 -0
  212. package/lib/commonjs/fonts/assets/GeistMono-Variable.woff2 +0 -0
  213. package/lib/commonjs/fonts/assets/InterVariable.woff2 +0 -0
  214. package/lib/commonjs/prompt/Prompt.js +0 -267
  215. package/lib/commonjs/prompt/Prompt.js.map +0 -1
  216. package/lib/commonjs/prompt/index.js +0 -61
  217. package/lib/commonjs/prompt/index.js.map +0 -1
  218. package/lib/module/fonts/assets/BlomusModernus-Bold.woff2 +0 -0
  219. package/lib/module/fonts/assets/BlomusModernus-Regular.woff2 +0 -0
  220. package/lib/module/fonts/assets/GeistMono-Variable.woff2 +0 -0
  221. package/lib/module/fonts/assets/InterVariable.woff2 +0 -0
  222. package/lib/module/prompt/Prompt.js +0 -250
  223. package/lib/module/prompt/Prompt.js.map +0 -1
  224. package/lib/module/prompt/index.js +0 -4
  225. package/lib/module/prompt/index.js.map +0 -1
  226. package/lib/typescript/commonjs/__tests__/BloomThemeProvider.fonts-web.test.d.ts +0 -5
  227. package/lib/typescript/commonjs/__tests__/BloomThemeProvider.fonts-web.test.d.ts.map +0 -1
  228. package/lib/typescript/commonjs/__tests__/BloomThemeProvider.test.d.ts +0 -2
  229. package/lib/typescript/commonjs/__tests__/BloomThemeProvider.test.d.ts.map +0 -1
  230. package/lib/typescript/commonjs/__tests__/BottomSheet.test.d.ts +0 -2
  231. package/lib/typescript/commonjs/__tests__/BottomSheet.test.d.ts.map +0 -1
  232. package/lib/typescript/commonjs/__tests__/Button.test.d.ts +0 -2
  233. package/lib/typescript/commonjs/__tests__/Button.test.d.ts.map +0 -1
  234. package/lib/typescript/commonjs/__tests__/Code.test.d.ts +0 -2
  235. package/lib/typescript/commonjs/__tests__/Code.test.d.ts.map +0 -1
  236. package/lib/typescript/commonjs/__tests__/FontLoader.native.test.d.ts +0 -2
  237. package/lib/typescript/commonjs/__tests__/FontLoader.native.test.d.ts.map +0 -1
  238. package/lib/typescript/commonjs/__tests__/Pre.test.d.ts +0 -2
  239. package/lib/typescript/commonjs/__tests__/Pre.test.d.ts.map +0 -1
  240. package/lib/typescript/commonjs/__tests__/SettingsList.test.d.ts +0 -2
  241. package/lib/typescript/commonjs/__tests__/SettingsList.test.d.ts.map +0 -1
  242. package/lib/typescript/commonjs/__tests__/apply-font-faces.test.d.ts +0 -5
  243. package/lib/typescript/commonjs/__tests__/apply-font-faces.test.d.ts.map +0 -1
  244. package/lib/typescript/commonjs/__tests__/theme.test.d.ts +0 -2
  245. package/lib/typescript/commonjs/__tests__/theme.test.d.ts.map +0 -1
  246. package/lib/typescript/commonjs/prompt/Prompt.d.ts +0 -42
  247. package/lib/typescript/commonjs/prompt/Prompt.d.ts.map +0 -1
  248. package/lib/typescript/commonjs/prompt/index.d.ts +0 -3
  249. package/lib/typescript/commonjs/prompt/index.d.ts.map +0 -1
  250. package/lib/typescript/module/__tests__/BloomThemeProvider.fonts-web.test.d.ts +0 -5
  251. package/lib/typescript/module/__tests__/BloomThemeProvider.fonts-web.test.d.ts.map +0 -1
  252. package/lib/typescript/module/__tests__/BloomThemeProvider.test.d.ts +0 -2
  253. package/lib/typescript/module/__tests__/BloomThemeProvider.test.d.ts.map +0 -1
  254. package/lib/typescript/module/__tests__/BottomSheet.test.d.ts +0 -2
  255. package/lib/typescript/module/__tests__/BottomSheet.test.d.ts.map +0 -1
  256. package/lib/typescript/module/__tests__/Button.test.d.ts +0 -2
  257. package/lib/typescript/module/__tests__/Button.test.d.ts.map +0 -1
  258. package/lib/typescript/module/__tests__/Code.test.d.ts +0 -2
  259. package/lib/typescript/module/__tests__/Code.test.d.ts.map +0 -1
  260. package/lib/typescript/module/__tests__/FontLoader.native.test.d.ts +0 -2
  261. package/lib/typescript/module/__tests__/FontLoader.native.test.d.ts.map +0 -1
  262. package/lib/typescript/module/__tests__/Pre.test.d.ts +0 -2
  263. package/lib/typescript/module/__tests__/Pre.test.d.ts.map +0 -1
  264. package/lib/typescript/module/__tests__/SettingsList.test.d.ts +0 -2
  265. package/lib/typescript/module/__tests__/SettingsList.test.d.ts.map +0 -1
  266. package/lib/typescript/module/__tests__/apply-font-faces.test.d.ts +0 -5
  267. package/lib/typescript/module/__tests__/apply-font-faces.test.d.ts.map +0 -1
  268. package/lib/typescript/module/__tests__/theme.test.d.ts +0 -2
  269. package/lib/typescript/module/__tests__/theme.test.d.ts.map +0 -1
  270. package/lib/typescript/module/prompt/Prompt.d.ts +0 -42
  271. package/lib/typescript/module/prompt/Prompt.d.ts.map +0 -1
  272. package/lib/typescript/module/prompt/index.d.ts +0 -3
  273. package/lib/typescript/module/prompt/index.d.ts.map +0 -1
  274. package/src/prompt/Prompt.tsx +0 -247
  275. package/src/prompt/index.ts +0 -13
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buttonToAction = buttonToAction;
7
+ exports.dismissAlert = dismissAlert;
8
+ exports.enqueueAlert = enqueueAlert;
9
+ exports.getAlertQueue = getAlertQueue;
10
+ exports.resolveButtons = resolveButtons;
11
+ exports.subscribeAlerts = subscribeAlerts;
12
+ let idCounter = 0;
13
+ function genId() {
14
+ idCounter += 1;
15
+ return `bloom-alert-${idCounter}`;
16
+ }
17
+
18
+ /**
19
+ * Imperative-alert store.
20
+ *
21
+ * The store sits in module scope so `alert()` works from anywhere — event
22
+ * handlers, async callbacks, top-level helpers — without threading a
23
+ * provider context through every call site.
24
+ *
25
+ * The visible UI is owned by a single subscriber (the `<BloomDialogProvider>`
26
+ * mounted inside the app's React tree). When there is no subscriber yet —
27
+ * because `alert()` was called before the provider mounted, or because the
28
+ * app forgot to mount the provider — entries accumulate in the queue and
29
+ * drain as soon as a subscriber attaches.
30
+ *
31
+ * Multiple subscribers are not supported by design. Two providers would
32
+ * race for the same alert; we instead enforce a single listener and let
33
+ * the most recent subscription win (the older one falls back to no-op).
34
+ */
35
+
36
+ let queue = [];
37
+ let listener = null;
38
+ function emit() {
39
+ if (listener) listener(queue);
40
+ }
41
+
42
+ /**
43
+ * Enqueue an alert. Returns the generated id so callers can dismiss it
44
+ * imperatively (rare — usually the dialog dismisses itself via a button
45
+ * tap). The runtime guarantees this enqueues even before any provider
46
+ * mounts; the provider drains pending entries on subscribe.
47
+ */
48
+ function enqueueAlert(entry) {
49
+ const id = genId();
50
+ queue = [...queue, {
51
+ ...entry,
52
+ id
53
+ }];
54
+ emit();
55
+ return id;
56
+ }
57
+
58
+ /**
59
+ * Remove an alert from the queue. Called by the provider once the bloom
60
+ * Dialog has finished closing for that entry.
61
+ */
62
+ function dismissAlert(id) {
63
+ const next = queue.filter(e => e.id !== id);
64
+ if (next.length === queue.length) return;
65
+ queue = next;
66
+ emit();
67
+ }
68
+
69
+ /**
70
+ * Subscribe to queue changes. Replaces any previously-registered listener
71
+ * (single-subscriber model — see header). Returns an unsubscribe function.
72
+ *
73
+ * On subscribe, the current queue is delivered synchronously so the
74
+ * subscriber can render pending entries that arrived before mount.
75
+ */
76
+ function subscribeAlerts(fn) {
77
+ listener = fn;
78
+ // Deliver the current queue immediately so a freshly-mounted provider
79
+ // catches up with whatever accumulated before it subscribed.
80
+ fn(queue);
81
+ return () => {
82
+ if (listener === fn) listener = null;
83
+ };
84
+ }
85
+
86
+ /** Inspect the current queue. Used internally and by tests. */
87
+ function getAlertQueue() {
88
+ return queue;
89
+ }
90
+
91
+ /**
92
+ * Translate an alert button to the action shape the unified `Dialog`
93
+ * accepts. Pure — no React, no theme — so it can be reused on web and
94
+ * native without forking.
95
+ */
96
+ function buttonToAction(button) {
97
+ return {
98
+ label: button.text,
99
+ onPress: button.onPress ? () => button.onPress?.() : undefined,
100
+ color: button.style === 'destructive' ? 'destructive' : button.style === 'cancel' ? 'cancel' : 'default'
101
+ };
102
+ }
103
+
104
+ /**
105
+ * Compute the effective button set for an alert. Mirrors React Native's
106
+ * `Alert.alert` semantics — an empty/omitted buttons array implies a
107
+ * single `OK` confirmation button.
108
+ */
109
+ function resolveButtons(buttons) {
110
+ if (buttons && buttons.length > 0) return buttons;
111
+ return [{
112
+ text: 'OK',
113
+ style: 'default'
114
+ }];
115
+ }
116
+ //# sourceMappingURL=alert-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["idCounter","genId","queue","listener","emit","enqueueAlert","entry","id","dismissAlert","next","filter","e","length","subscribeAlerts","fn","getAlertQueue","buttonToAction","button","label","text","onPress","undefined","color","style","resolveButtons","buttons"],"sourceRoot":"../../../src","sources":["dialog/alert-store.ts"],"mappings":";;;;;;;;;;;AAEA,IAAIA,SAAS,GAAG,CAAC;AACjB,SAASC,KAAKA,CAAA,EAAW;EACvBD,SAAS,IAAI,CAAC;EACd,OAAO,eAAeA,SAAS,EAAE;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsBA,IAAIE,KAAmB,GAAG,EAAE;AAC5B,IAAIC,QAAyB,GAAG,IAAI;AAEpC,SAASC,IAAIA,CAAA,EAAS;EACpB,IAAID,QAAQ,EAAEA,QAAQ,CAACD,KAAK,CAAC;AAC/B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,YAAYA,CAACC,KAA6B,EAAU;EAClE,MAAMC,EAAE,GAAGN,KAAK,CAAC,CAAC;EAClBC,KAAK,GAAG,CAAC,GAAGA,KAAK,EAAE;IAAE,GAAGI,KAAK;IAAEC;EAAG,CAAC,CAAC;EACpCH,IAAI,CAAC,CAAC;EACN,OAAOG,EAAE;AACX;;AAEA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAACD,EAAU,EAAQ;EAC7C,MAAME,IAAI,GAAGP,KAAK,CAACQ,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACJ,EAAE,KAAKA,EAAE,CAAC;EAC7C,IAAIE,IAAI,CAACG,MAAM,KAAKV,KAAK,CAACU,MAAM,EAAE;EAClCV,KAAK,GAAGO,IAAI;EACZL,IAAI,CAAC,CAAC;AACR;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,eAAeA,CAACC,EAAY,EAAc;EACxDX,QAAQ,GAAGW,EAAE;EACb;EACA;EACAA,EAAE,CAACZ,KAAK,CAAC;EACT,OAAO,MAAM;IACX,IAAIC,QAAQ,KAAKW,EAAE,EAAEX,QAAQ,GAAG,IAAI;EACtC,CAAC;AACH;;AAEA;AACO,SAASY,aAAaA,CAAA,EAA0B;EACrD,OAAOb,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASc,cAAcA,CAACC,MAAmB,EAAgB;EAChE,OAAO;IACLC,KAAK,EAAED,MAAM,CAACE,IAAI;IAClBC,OAAO,EAAEH,MAAM,CAACG,OAAO,GAAG,MAAMH,MAAM,CAACG,OAAO,GAAG,CAAC,GAAGC,SAAS;IAC9DC,KAAK,EACHL,MAAM,CAACM,KAAK,KAAK,aAAa,GAC1B,aAAa,GACbN,MAAM,CAACM,KAAK,KAAK,QAAQ,GACvB,QAAQ,GACR;EACV,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAACC,OAAkC,EAAiB;EAChF,IAAIA,OAAO,IAAIA,OAAO,CAACb,MAAM,GAAG,CAAC,EAAE,OAAOa,OAAO;EACjD,OAAO,CAAC;IAAEN,IAAI,EAAE,IAAI;IAAEI,KAAK,EAAE;EAAU,CAAC,CAAC;AAC3C","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.alert = alert;
7
+ var _alertStore = require("./alert-store.js");
8
+ /**
9
+ * Show a Bloom-styled confirmation dialog. Mirrors React Native's
10
+ * `Alert.alert(title, message?, buttons?)` signature so existing call
11
+ * sites migrate by changing the import only.
12
+ *
13
+ * If no buttons are passed, a single `OK` confirmation is rendered.
14
+ *
15
+ * The alert is enqueued in a module-scope store and rendered by
16
+ * `<BloomDialogProvider>`. Calls made before the provider mounts are
17
+ * queued and drained once the provider attaches — there is no fire-and-
18
+ * forget loss window. Calls made when no provider is ever mounted are
19
+ * silently queued forever; in development, mount the provider once at
20
+ * the app root and the queue will catch up immediately.
21
+ *
22
+ * ```tsx
23
+ * import { alert } from '@oxyhq/bloom';
24
+ *
25
+ * alert('Sign out?', 'You will need to enter your password to sign in again.', [
26
+ * { text: 'Cancel', style: 'cancel' },
27
+ * { text: 'Sign out', style: 'destructive', onPress: doSignOut },
28
+ * ]);
29
+ * ```
30
+ */
31
+ function alert(title, message, buttons) {
32
+ (0, _alertStore.enqueueAlert)({
33
+ title,
34
+ message,
35
+ buttons: (0, _alertStore.resolveButtons)(buttons)
36
+ });
37
+ }
38
+ //# sourceMappingURL=alert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_alertStore","require","alert","title","message","buttons","enqueueAlert","resolveButtons"],"sourceRoot":"../../../src","sources":["dialog/alert.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,KAAKA,CACnBC,KAAa,EACbC,OAAgB,EAChBC,OAAuB,EACjB;EACN,IAAAC,wBAAY,EAAC;IACXH,KAAK;IACLC,OAAO;IACPC,OAAO,EAAE,IAAAE,0BAAc,EAACF,OAAO;EACjC,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -15,6 +15,14 @@ Context.displayName = 'BloomDialogContext';
15
15
  function useDialogContext() {
16
16
  return (0, _react.useContext)(Context);
17
17
  }
18
+
19
+ /**
20
+ * Return a stable handle that can imperatively `open()` and `close()` a
21
+ * `<Dialog>` mounted with the same control.
22
+ *
23
+ * The handle survives across re-renders; mounting a different `<Dialog>`
24
+ * with the same control attaches the new instance via the internal ref.
25
+ */
18
26
  function useDialogControl() {
19
27
  const id = (0, _react.useId)();
20
28
  const control = (0, _react.useRef)({
@@ -24,8 +32,8 @@ function useDialogControl() {
24
32
  return (0, _react.useMemo)(() => ({
25
33
  id,
26
34
  ref: control,
27
- open: options => {
28
- control.current?.open(options);
35
+ open: () => {
36
+ control.current?.open();
29
37
  },
30
38
  close: cb => {
31
39
  control.current?.close(cb);
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","Context","exports","createContext","close","isWithinDialog","displayName","useDialogContext","useContext","useDialogControl","id","useId","control","useRef","open","useMemo","ref","options","current","cb"],"sourceRoot":"../../../src","sources":["dialog/context.ts"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,OAAO,GAAAC,OAAA,CAAAD,OAAA,gBAAG,IAAAE,oBAAa,EAAqB;EACvDC,KAAK,EAAEA,CAAA,KAAM,CAAC,CAAC;EACfC,cAAc,EAAE;AAClB,CAAC,CAAC;AACFJ,OAAO,CAACK,WAAW,GAAG,oBAAoB;AAEnC,SAASC,gBAAgBA,CAAA,EAAuB;EACrD,OAAO,IAAAC,iBAAU,EAACP,OAAO,CAAC;AAC5B;AAEO,SAASQ,gBAAgBA,CAAA,EAAuB;EACrD,MAAMC,EAAE,GAAG,IAAAC,YAAK,EAAC,CAAC;EAClB,MAAMC,OAAO,GAAG,IAAAC,aAAM,EAA+B;IACnDC,IAAI,EAAEA,CAAA,KAAM,CAAC,CAAC;IACdV,KAAK,EAAEA,CAAA,KAAM,CAAC;EAChB,CAAC,CAAC;EAEF,OAAO,IAAAW,cAAO,EACZ,OAAO;IACLL,EAAE;IACFM,GAAG,EAAEJ,OAAO;IACZE,IAAI,EAAGG,OAAO,IAAK;MACjBL,OAAO,CAACM,OAAO,EAAEJ,IAAI,CAACG,OAAO,CAAC;IAChC,CAAC;IACDb,KAAK,EAAGe,EAAE,IAAK;MACbP,OAAO,CAACM,OAAO,EAAEd,KAAK,CAACe,EAAE,CAAC;IAC5B;EACF,CAAC,CAAC,EACF,CAACT,EAAE,CACL,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","Context","exports","createContext","close","isWithinDialog","displayName","useDialogContext","useContext","useDialogControl","id","useId","control","useRef","open","useMemo","ref","current","cb"],"sourceRoot":"../../../src","sources":["dialog/context.ts"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOO,MAAMC,OAAO,GAAAC,OAAA,CAAAD,OAAA,gBAAG,IAAAE,oBAAa,EAAqB;EACvDC,KAAK,EAAEA,CAAA,KAAM,CAAC,CAAC;EACfC,cAAc,EAAE;AAClB,CAAC,CAAC;AACFJ,OAAO,CAACK,WAAW,GAAG,oBAAoB;AAEnC,SAASC,gBAAgBA,CAAA,EAAuB;EACrD,OAAO,IAAAC,iBAAU,EAACP,OAAO,CAAC;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,gBAAgBA,CAAA,EAAuB;EACrD,MAAMC,EAAE,GAAG,IAAAC,YAAK,EAAC,CAAC;EAClB,MAAMC,OAAO,GAAG,IAAAC,aAAM,EAA+B;IACnDC,IAAI,EAAEA,CAAA,KAAM,CAAC,CAAC;IACdV,KAAK,EAAEA,CAAA,KAAM,CAAC;EAChB,CAAC,CAAC;EAEF,OAAO,IAAAW,cAAO,EACZ,OAAO;IACLL,EAAE;IACFM,GAAG,EAAEJ,OAAO;IACZE,IAAI,EAAEA,CAAA,KAAM;MACVF,OAAO,CAACK,OAAO,EAAEH,IAAI,CAAC,CAAC;IACzB,CAAC;IACDV,KAAK,EAAGc,EAAE,IAAK;MACbN,OAAO,CAACK,OAAO,EAAEb,KAAK,CAACc,EAAE,CAAC;IAC5B;EACF,CAAC,CAAC,EACF,CAACR,EAAE,CACL,CAAC;AACH","ignoreList":[]}
@@ -3,40 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Backdrop", {
6
+ Object.defineProperty(exports, "BloomDialogProvider", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _Dialog.Backdrop;
9
+ return _BloomDialogProvider.BloomDialogProvider;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "Close", {
12
+ Object.defineProperty(exports, "Dialog", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _Dialog.Close;
15
+ return _Dialog.Dialog;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "Handle", {
18
+ Object.defineProperty(exports, "alert", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _Dialog.Handle;
22
- }
23
- });
24
- Object.defineProperty(exports, "Inner", {
25
- enumerable: true,
26
- get: function () {
27
- return _Dialog.Inner;
28
- }
29
- });
30
- Object.defineProperty(exports, "Outer", {
31
- enumerable: true,
32
- get: function () {
33
- return _Dialog.Outer;
34
- }
35
- });
36
- Object.defineProperty(exports, "ScrollableInner", {
37
- enumerable: true,
38
- get: function () {
39
- return _Dialog.ScrollableInner;
21
+ return _alert.alert;
40
22
  }
41
23
  });
42
24
  Object.defineProperty(exports, "useDialogContext", {
@@ -52,5 +34,7 @@ Object.defineProperty(exports, "useDialogControl", {
52
34
  }
53
35
  });
54
36
  var _Dialog = require("./Dialog");
37
+ var _BloomDialogProvider = require("./BloomDialogProvider");
38
+ var _alert = require("./alert.js");
55
39
  var _context = require("./context.js");
56
40
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Dialog","require","_context"],"sourceRoot":"../../../src","sources":["dialog/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Dialog","require","_BloomDialogProvider","_alert","_context"],"sourceRoot":"../../../src","sources":["dialog/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA","ignoreList":[]}
@@ -3,40 +3,28 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Backdrop", {
6
+ Object.defineProperty(exports, "BLOOM_DIALOG_CSS", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _DialogWeb.Backdrop;
9
+ return _DialogWeb.BLOOM_DIALOG_CSS;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "Close", {
12
+ Object.defineProperty(exports, "BloomDialogProvider", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _DialogWeb.Close;
15
+ return _BloomDialogProviderWeb.BloomDialogProvider;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "Handle", {
18
+ Object.defineProperty(exports, "Dialog", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _DialogWeb.Handle;
21
+ return _DialogWeb.Dialog;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "Inner", {
24
+ Object.defineProperty(exports, "alert", {
25
25
  enumerable: true,
26
26
  get: function () {
27
- return _DialogWeb.Inner;
28
- }
29
- });
30
- Object.defineProperty(exports, "Outer", {
31
- enumerable: true,
32
- get: function () {
33
- return _DialogWeb.Outer;
34
- }
35
- });
36
- Object.defineProperty(exports, "ScrollableInner", {
37
- enumerable: true,
38
- get: function () {
39
- return _DialogWeb.ScrollableInner;
27
+ return _alert.alert;
40
28
  }
41
29
  });
42
30
  Object.defineProperty(exports, "useDialogContext", {
@@ -52,5 +40,7 @@ Object.defineProperty(exports, "useDialogControl", {
52
40
  }
53
41
  });
54
42
  var _DialogWeb = require("./Dialog.web.js");
43
+ var _BloomDialogProviderWeb = require("./BloomDialogProvider.web.js");
44
+ var _alert = require("./alert.js");
55
45
  var _context = require("./context.js");
56
46
  //# sourceMappingURL=index.web.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_DialogWeb","require","_context"],"sourceRoot":"../../../src","sources":["dialog/index.web.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_DialogWeb","require","_BloomDialogProviderWeb","_alert","_context"],"sourceRoot":"../../../src","sources":["dialog/index.web.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA","ignoreList":[]}
@@ -9,11 +9,12 @@ var _applyFontFacesWeb = require("./apply-font-faces.web.js");
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
10
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
11
  // Reach for the web variant explicitly. The default `./apply-font-faces`
12
- // is a no-op stub that exists so Metro never sees the module-level
13
- // `.woff2` imports on native (Metro's default `assetExts` does not include
14
- // `.woff2`). This file (`FontLoader.tsx`) is only picked up by web
15
- // bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android — so it
16
- // is safe to take a direct dependency on the web implementation here.
12
+ // is a no-op stub on native native loads its fonts via
13
+ // `useFonts(FONT_ASSETS)` in `FontLoader.native.tsx` and has no use for
14
+ // CSS `@font-face` injection. This file (`FontLoader.tsx`) is only picked
15
+ // up by web bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android
16
+ // — so it is safe to take a direct dependency on the web implementation
17
+ // here.
17
18
 
18
19
  /**
19
20
  * Web font loader. Applies the Bloom `@font-face` rules and CSS variables
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_applyFontFacesWeb","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","FontLoader","enabled","children","applied","useRef","current","applyFontFaces","jsx","Fragment"],"sourceRoot":"../../../src","sources":["fonts/FontLoader.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,kBAAA,GAAAD,OAAA;AAAwD,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AANxD;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASkB,UAAUA,CAAC;EAAEC,OAAO;EAAEC;AAA0B,CAAC,EAAE;EACjE,MAAMC,OAAO,GAAG,IAAAC,aAAM,EAAC,KAAK,CAAC;EAC7B,IAAIH,OAAO,IAAI,CAACE,OAAO,CAACE,OAAO,EAAE;IAC/BF,OAAO,CAACE,OAAO,GAAG,IAAI;IACtB,IAAAC,iCAAc,EAAC,CAAC;EAClB;EACA,oBAAO,IAAA1B,WAAA,CAAA2B,GAAA,EAAA3B,WAAA,CAAA4B,QAAA;IAAAN,QAAA,EAAGA;EAAQ,CAAG,CAAC;AACxB","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_applyFontFacesWeb","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","FontLoader","enabled","children","applied","useRef","current","applyFontFaces","jsx","Fragment"],"sourceRoot":"../../../src","sources":["fonts/FontLoader.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAQA,IAAAC,kBAAA,GAAAD,OAAA;AAAwD,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAPxD;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASkB,UAAUA,CAAC;EAAEC,OAAO;EAAEC;AAA0B,CAAC,EAAE;EACjE,MAAMC,OAAO,GAAG,IAAAC,aAAM,EAAC,KAAK,CAAC;EAC7B,IAAIH,OAAO,IAAI,CAACE,OAAO,CAACE,OAAO,EAAE;IAC/BF,OAAO,CAACE,OAAO,GAAG,IAAI;IACtB,IAAAC,iCAAc,EAAC,CAAC;EAClB;EACA,oBAAO,IAAA1B,WAAA,CAAA2B,GAAA,EAAA3B,WAAA,CAAA4B,QAAA;IAAAN,QAAA,EAAGA;EAAQ,CAAG,CAAC;AACxB","ignoreList":[]}
@@ -8,10 +8,10 @@ exports.applyFontFaces = applyFontFaces;
8
8
  // is selected by bundlers via the package.json conditions. RN consumers
9
9
  // never need font-face injection — useFonts handles loading on native.
10
10
  //
11
- // This file MUST have zero `.woff2` imports. Metro parses module-level
12
- // imports at bundle time and would otherwise fail to resolve the `.woff2`
13
- // assets (not in Metro's default `assetExts`). See
14
- // `apply-font-faces.web.ts` for the real implementation.
11
+ // The web variant does NOT pull in any `.woff2` files via asset imports —
12
+ // it imports base64 data URLs from `font-data.web.ts`. This stub stays
13
+ // here so the file split (`*.ts` vs `*.web.ts`) makes the platform
14
+ // intent explicit and so the runtime API surface matches across platforms.
15
15
  function applyFontFaces() {
16
16
  // intentionally empty
17
17
  }
@@ -4,14 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.applyFontFaces = applyFontFaces;
7
- var _BlomusModernusRegular = _interopRequireDefault(require("./assets/BlomusModernus-Regular.woff2"));
8
- var _BlomusModernusBold = _interopRequireDefault(require("./assets/BlomusModernus-Bold.woff2"));
9
- var _InterVariable = _interopRequireDefault(require("./assets/InterVariable.woff2"));
10
- var _GeistMonoVariable = _interopRequireDefault(require("./assets/GeistMono-Variable.woff2"));
7
+ var _fontDataWeb = require("./font-data.web.js");
11
8
  var _tokens = require("./tokens.js");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- /// <reference path="../assets.d.ts" />
14
-
15
9
  const STYLE_ID = 'bloom-fonts';
16
10
 
17
11
  /**
@@ -19,10 +13,17 @@ const STYLE_ID = 'bloom-fonts';
19
13
  *
20
14
  * Web-only. The native counterpart in `apply-font-faces.ts` is a no-op
21
15
  * stub — Metro cannot parse `.woff2` imports, so the file split keeps
22
- * those imports out of the native bundle entirely. Idempotent: safe to
16
+ * the font payload out of the native bundle entirely. Idempotent: safe to
23
17
  * call multiple times; subsequent calls early-return after the
24
18
  * `<style id="bloom-fonts">` tag has been mounted. SSR-safe via the
25
19
  * `typeof document === 'undefined'` guard.
20
+ *
21
+ * The font URLs come from `./font-data.web`, a generated module that
22
+ * embeds the woff2 bytes as base64 data URLs. Inlining (rather than
23
+ * relying on bundler asset loaders for `.woff2`) means consumers do not
24
+ * have to extend Metro's `assetExts` or add a webpack/Vite asset rule —
25
+ * the published JS is self-contained. See `scripts/generate-font-data.mjs`
26
+ * for the rationale and trade-offs.
26
27
  */
27
28
  function applyFontFaces() {
28
29
  if (typeof document === 'undefined') return;
@@ -30,10 +31,10 @@ function applyFontFaces() {
30
31
  const style = document.createElement('style');
31
32
  style.id = STYLE_ID;
32
33
  style.textContent = `
33
- @font-face { font-family: 'BlomusModernus'; src: url(${_BlomusModernusRegular.default}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
34
- @font-face { font-family: 'BlomusModernus'; src: url(${_BlomusModernusBold.default}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
35
- @font-face { font-family: 'Inter'; src: url(${_InterVariable.default}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
36
- @font-face { font-family: 'Geist Mono'; src: url(${_GeistMonoVariable.default}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
34
+ @font-face { font-family: 'BlomusModernus'; src: url(${_fontDataWeb.blomusModernusRegular}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
35
+ @font-face { font-family: 'BlomusModernus'; src: url(${_fontDataWeb.blomusModernusBold}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
36
+ @font-face { font-family: 'Inter'; src: url(${_fontDataWeb.interVariable}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
37
+ @font-face { font-family: 'Geist Mono'; src: url(${_fontDataWeb.geistMonoVariable}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
37
38
  :root {
38
39
  --bloom-font-display: ${_tokens.fontFamilies.display};
39
40
  --bloom-font-sans: ${_tokens.fontFamilies.sans};
@@ -1 +1 @@
1
- {"version":3,"names":["_BlomusModernusRegular","_interopRequireDefault","require","_BlomusModernusBold","_InterVariable","_GeistMonoVariable","_tokens","e","__esModule","default","STYLE_ID","applyFontFaces","document","getElementById","style","createElement","id","textContent","blomusReg","blomusBold","interVar","geistMono","fontFamilies","display","sans","mono","head","appendChild"],"sourceRoot":"../../../src","sources":["fonts/apply-font-faces.web.ts"],"mappings":";;;;;;AACA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,kBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAAwC,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AALxC;;AAOA,MAAMG,QAAQ,GAAG,aAAa;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAA,EAAS;EACrC,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;EACrC,IAAIA,QAAQ,CAACC,cAAc,CAACH,QAAQ,CAAC,EAAE;EAEvC,MAAMI,KAAK,GAAGF,QAAQ,CAACG,aAAa,CAAC,OAAO,CAAC;EAC7CD,KAAK,CAACE,EAAE,GAAGN,QAAQ;EACnBI,KAAK,CAACG,WAAW,GAAG;AACtB,2DAA2DC,8BAAS;AACpE,2DAA2DC,2BAAU;AACrE,kDAAkDC,sBAAQ;AAC1D,uDAAuDC,0BAAS;AAChE;AACA,8BAA8BC,oBAAY,CAACC,OAAO;AAClD,2BAA2BD,oBAAY,CAACE,IAAI;AAC5C,2BAA2BF,oBAAY,CAACG,IAAI;AAC5C;AACA,GAAG;EACDb,QAAQ,CAACc,IAAI,CAACC,WAAW,CAACb,KAAK,CAAC;AAClC","ignoreList":[]}
1
+ {"version":3,"names":["_fontDataWeb","require","_tokens","STYLE_ID","applyFontFaces","document","getElementById","style","createElement","id","textContent","blomusModernusRegular","blomusModernusBold","interVariable","geistMonoVariable","fontFamilies","display","sans","mono","head","appendChild"],"sourceRoot":"../../../src","sources":["fonts/apply-font-faces.web.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,QAAQ,GAAG,aAAa;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAA,EAAS;EACrC,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;EACrC,IAAIA,QAAQ,CAACC,cAAc,CAACH,QAAQ,CAAC,EAAE;EAEvC,MAAMI,KAAK,GAAGF,QAAQ,CAACG,aAAa,CAAC,OAAO,CAAC;EAC7CD,KAAK,CAACE,EAAE,GAAGN,QAAQ;EACnBI,KAAK,CAACG,WAAW,GAAG;AACtB,2DAA2DC,kCAAqB;AAChF,2DAA2DC,+BAAkB;AAC7E,kDAAkDC,0BAAa;AAC/D,uDAAuDC,8BAAiB;AACxE;AACA,8BAA8BC,oBAAY,CAACC,OAAO;AAClD,2BAA2BD,oBAAY,CAACE,IAAI;AAC5C,2BAA2BF,oBAAY,CAACG,IAAI;AAC5C;AACA,GAAG;EACDb,QAAQ,CAACc,IAAI,CAACC,WAAW,CAACb,KAAK,CAAC;AAClC","ignoreList":[]}
@@ -11,8 +11,8 @@ exports.FONT_ASSETS = void 0;
11
11
  // covers all weights at runtime. `@fontsource(-variable)?/*` packages only
12
12
  // publish .woff2 for their variable axes — modern react-native font loading
13
13
  // requires .ttf, so we use the upstream variable TTFs instead. On web,
14
- // `apply-font-faces.web.ts` references the .woff2 variants directly and this
15
- // file is never imported.
14
+ // `apply-font-faces.web.ts` inlines the .woff2 variants as base64 data URLs
15
+ // (see `font-data.web.ts`) and this file is never imported.
16
16
 
17
17
  const FONT_ASSETS = exports.FONT_ASSETS = {
18
18
  BlomusModernus: require('./assets/BlomusModernus-Regular.ttf'),