@developer_tribe/react-builder 1.0.8 → 1.0.9

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 (216) hide show
  1. package/dist/build-components/BIcon/BIconProps.generated.d.ts +3 -0
  2. package/dist/build-components/BackgroundImage/BackgroundImageProps.generated.d.ts +1 -0
  3. package/dist/build-components/Button/ButtonProps.generated.d.ts +1 -0
  4. package/dist/build-components/Carousel/CarouselProps.generated.d.ts +5 -0
  5. package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +1 -0
  6. package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +1 -0
  7. package/dist/build-components/CarouselItem/CarouselItemProps.generated.d.ts +1 -0
  8. package/dist/build-components/CarouselProvider/CarouselProviderProps.generated.d.ts +1 -0
  9. package/dist/build-components/Image/ImageProps.generated.d.ts +1 -0
  10. package/dist/build-components/Main/MainProps.generated.d.ts +1 -1
  11. package/dist/build-components/Onboard/OnboardProps.generated.d.ts +1 -0
  12. package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +1 -0
  13. package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +1 -0
  14. package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +1 -0
  15. package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +3 -0
  16. package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +1 -0
  17. package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +1 -0
  18. package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +3 -0
  19. package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +3 -0
  20. package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +3 -0
  21. package/dist/build-components/PaywallBackground/PaywallBackgroundProps.generated.d.ts +1 -1
  22. package/dist/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.d.ts +3 -1
  23. package/dist/build-components/PaywallOptions/PaywallOptionsProps.generated.d.ts +1 -1
  24. package/dist/build-components/PaywallProvider/PaywallContext.d.ts +12 -0
  25. package/dist/build-components/PaywallProvider/PaywallProviderProps.generated.d.ts +1 -1
  26. package/dist/build-components/PaywallSubscribeButton/PaywallSubscribeButtonProps.generated.d.ts +1 -0
  27. package/dist/build-components/RadioButton/RadioButtonProps.generated.d.ts +1 -1
  28. package/dist/build-components/Text/TextProps.generated.d.ts +3 -0
  29. package/dist/build-components/View/ViewProps.generated.d.ts +1 -0
  30. package/dist/build-components/patterns.generated.d.ts +372 -374
  31. package/dist/components/BuilderProvider.d.ts +2 -0
  32. package/dist/components/ParamsProvider.d.ts +5 -0
  33. package/dist/components/RenderErrorBoundary.d.ts +28 -0
  34. package/dist/hooks/useSyncHtmlThemeClass.d.ts +7 -0
  35. package/dist/index.cjs.js +5 -5
  36. package/dist/index.cjs.js.map +1 -1
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.esm.js +3 -3
  39. package/dist/index.esm.js.map +1 -1
  40. package/dist/index.native.cjs.js +4 -4
  41. package/dist/index.native.cjs.js.map +1 -1
  42. package/dist/index.native.d.ts +1 -0
  43. package/dist/index.native.esm.js +4 -4
  44. package/dist/index.native.esm.js.map +1 -1
  45. package/dist/migrations/migratePipe.d.ts +14 -0
  46. package/dist/migrations/migrations/1.1.0_normalize_style_attributes.d.ts +2 -0
  47. package/dist/migrations/semver.d.ts +8 -0
  48. package/dist/migrations/types.d.ts +8 -0
  49. package/dist/mockOS/components/SubscriptionModal.d.ts +7 -0
  50. package/dist/mockOS/context/MockOSContextBase.d.ts +1 -0
  51. package/dist/mockOS/hooks/useMockIap.d.ts +3 -0
  52. package/dist/mockOS/index.d.ts +4 -0
  53. package/dist/mockOS/managers/mockOSIapManager.d.ts +6 -0
  54. package/dist/mockOS/managers/subscriptionManager.d.ts +10 -0
  55. package/dist/pages/ProjectDebug.d.ts +14 -0
  56. package/dist/pages/ProjectMigrationPage.d.ts +23 -0
  57. package/dist/pages/ProjectValidationPage.d.ts +15 -0
  58. package/dist/styles.css +1 -1
  59. package/dist/types/Device.d.ts +5 -0
  60. package/dist/utils/__special_exceptions.d.ts +7 -0
  61. package/dist/utils/getImage.d.ts +23 -0
  62. package/dist/utils/pasteNode.d.ts +15 -0
  63. package/dist/utils/patterns.d.ts +1 -2
  64. package/package.json +6 -2
  65. package/scripts/migrate-patterns-to-v2.mjs +131 -0
  66. package/scripts/migrate-samples-to-current.ts +79 -0
  67. package/scripts/prebuild/utils/createGeneratedProps.js +4 -5
  68. package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +32 -21
  69. package/scripts/prebuild/utils/validatePatternJson.js +12 -10
  70. package/src/.DS_Store +0 -0
  71. package/src/AttributesEditor.tsx +41 -11
  72. package/src/RenderPage.tsx +55 -0
  73. package/src/assets/.DS_Store +0 -0
  74. package/src/assets/devices.json +91 -0
  75. package/src/assets/samples/carousel-sample.json +141 -29
  76. package/src/assets/samples/getSamples.ts +9 -0
  77. package/src/assets/samples/paywall-1.json +119 -71
  78. package/src/assets/samples/simple-1.json +28 -16
  79. package/src/assets/samples/simple-2.json +157 -82
  80. package/src/assets/samples/unmigrated-builder1.json +42 -0
  81. package/src/assets/samples/unvalidated-builder1.json +49 -0
  82. package/src/assets/samples/unvalidated-crash1.json +19 -0
  83. package/src/assets/samples/unvalidated-crashcomponent1.json +16 -0
  84. package/src/assets/samples/vpn-onboard-1.json +91 -51
  85. package/src/assets/samples/vpn-onboard-2.json +318 -278
  86. package/src/assets/samples/vpn-onboard-3.json +286 -252
  87. package/src/assets/samples/vpn-onboard-4.json +286 -252
  88. package/src/assets/samples/vpn-onboard-5.json +434 -374
  89. package/src/assets/samples/vpn-onboard-6.json +290 -250
  90. package/src/attributes-editor/Field.tsx +1 -1
  91. package/src/attributes-editor/LayoutPreviewPicker.tsx +5 -2
  92. package/src/build-components/BIcon/BIconProps.generated.ts +3 -0
  93. package/src/build-components/BIcon/pattern.json +12 -9
  94. package/src/build-components/BackgroundImage/BackgroundImage.tsx +3 -1
  95. package/src/build-components/BackgroundImage/BackgroundImageProps.generated.ts +1 -0
  96. package/src/build-components/BackgroundImage/pattern.json +25 -16
  97. package/src/build-components/Button/Button.tsx +26 -3
  98. package/src/build-components/Button/ButtonProps.generated.ts +1 -0
  99. package/src/build-components/Button/pattern.json +10 -6
  100. package/src/build-components/Carousel/CarouselProps.generated.ts +5 -0
  101. package/src/build-components/Carousel/pattern.json +19 -8
  102. package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +1 -0
  103. package/src/build-components/CarouselButtons/pattern.json +11 -5
  104. package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +1 -0
  105. package/src/build-components/CarouselDots/pattern.json +5 -4
  106. package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +1 -0
  107. package/src/build-components/CarouselItem/pattern.json +5 -4
  108. package/src/build-components/CarouselProvider/CarouselProvider.tsx +44 -2
  109. package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +1 -0
  110. package/src/build-components/Image/Image.tsx +2 -1
  111. package/src/build-components/Image/ImageProps.generated.ts +1 -0
  112. package/src/build-components/Image/pattern.json +11 -5
  113. package/src/build-components/Main/MainProps.generated.ts +1 -1
  114. package/src/build-components/Main/pattern.json +12 -9
  115. package/src/build-components/Onboard/OnboardProps.generated.ts +1 -0
  116. package/src/build-components/Onboard/pattern.json +14 -9
  117. package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +1 -0
  118. package/src/build-components/OnboardButton/pattern.json +5 -4
  119. package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +1 -0
  120. package/src/build-components/OnboardButtons/pattern.json +5 -4
  121. package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +1 -0
  122. package/src/build-components/OnboardDot/pattern.json +5 -4
  123. package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +3 -0
  124. package/src/build-components/OnboardFooter/pattern.json +8 -5
  125. package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +1 -0
  126. package/src/build-components/OnboardImage/pattern.json +7 -4
  127. package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +1 -0
  128. package/src/build-components/OnboardItem/pattern.json +18 -9
  129. package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +3 -0
  130. package/src/build-components/OnboardProvider/pattern.json +21 -6
  131. package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +3 -0
  132. package/src/build-components/OnboardSubtitle/pattern.json +10 -6
  133. package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +3 -0
  134. package/src/build-components/OnboardTitle/pattern.json +11 -7
  135. package/src/build-components/PaywallBackground/PaywallBackgroundProps.generated.ts +1 -1
  136. package/src/build-components/PaywallBackground/pattern.json +5 -4
  137. package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +6 -1
  138. package/src/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.ts +3 -1
  139. package/src/build-components/PaywallCloseButton/pattern.json +15 -12
  140. package/src/build-components/PaywallOptions/PaywallOptionButton.tsx +0 -1
  141. package/src/build-components/PaywallOptions/PaywallOptions.tsx +3 -2
  142. package/src/build-components/PaywallOptions/PaywallOptionsProps.generated.ts +1 -1
  143. package/src/build-components/PaywallOptions/pattern.json +14 -11
  144. package/src/build-components/PaywallProvider/PaywallContext.ts +25 -0
  145. package/src/build-components/PaywallProvider/PaywallProvider.tsx +102 -5
  146. package/src/build-components/PaywallProvider/PaywallProviderProps.generated.ts +1 -1
  147. package/src/build-components/PaywallProvider/pattern.json +11 -8
  148. package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButton.tsx +7 -0
  149. package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButtonProps.generated.ts +1 -0
  150. package/src/build-components/PaywallSubscribeButton/pattern.json +16 -13
  151. package/src/build-components/RadioButton/RadioButtonProps.generated.ts +1 -1
  152. package/src/build-components/RadioButton/pattern.json +5 -4
  153. package/src/build-components/Text/Text.tsx +107 -4
  154. package/src/build-components/Text/TextProps.generated.ts +3 -0
  155. package/src/build-components/Text/pattern.json +19 -4
  156. package/src/build-components/View/ViewProps.generated.ts +1 -0
  157. package/src/build-components/View/pattern.json +28 -13
  158. package/src/build-components/other.tsx +15 -0
  159. package/src/build-components/patterns.generated.ts +340 -235
  160. package/src/build-components/useNode.ts +22 -3
  161. package/src/components/Builder.tsx +20 -6
  162. package/src/components/BuilderButton.tsx +75 -38
  163. package/src/components/BuilderProvider.tsx +22 -2
  164. package/src/components/DeviceButton.tsx +12 -5
  165. package/src/components/EditorHeader.tsx +296 -38
  166. package/src/components/ParamsProvider.tsx +7 -0
  167. package/src/components/RenderErrorBoundary.tsx +200 -0
  168. package/src/hooks/useParams.ts +5 -1
  169. package/src/hooks/useSyncHtmlThemeClass.ts +19 -0
  170. package/src/index.native.ts +7 -0
  171. package/src/index.ts +8 -0
  172. package/src/migrations/migratePipe.ts +59 -0
  173. package/src/migrations/migrations/1.1.0_normalize_style_attributes.ts +80 -0
  174. package/src/migrations/semver.ts +24 -0
  175. package/src/migrations/types.ts +9 -0
  176. package/src/mockOS/components/PermissionModal.tsx +3 -2
  177. package/src/mockOS/components/SubscriptionModal.tsx +400 -0
  178. package/src/mockOS/context/MockOSContext.tsx +61 -10
  179. package/src/mockOS/context/MockOSContextBase.ts +1 -0
  180. package/src/mockOS/hooks/useMockIap.ts +11 -0
  181. package/src/mockOS/index.ts +7 -0
  182. package/src/mockOS/managers/mockOSIapManager.ts +10 -0
  183. package/src/mockOS/managers/subscriptionManager.ts +36 -0
  184. package/src/modals/IconPickerModal.tsx +1 -1
  185. package/src/pages/ProjectDebug.tsx +331 -0
  186. package/src/pages/ProjectMigrationPage.tsx +92 -0
  187. package/src/pages/ProjectPage.tsx +313 -161
  188. package/src/pages/ProjectValidationPage.tsx +54 -0
  189. package/src/styles/base/_global.scss +58 -11
  190. package/src/styles/components/_attributes-editor.scss +1 -1
  191. package/src/styles/components/_bottom-bar.scss +7 -4
  192. package/src/styles/components/_editor-shell.scss +126 -4
  193. package/src/styles/components/_mockos-router.scss +3 -2
  194. package/src/styles/components/_ui-components.scss +10 -5
  195. package/src/styles/foundation/_colors.scss +78 -11
  196. package/src/styles/foundation/_mixins.scss +4 -1
  197. package/src/styles/foundation/_sizes.scss +4 -2
  198. package/src/styles/index.scss +1 -0
  199. package/src/styles/layout/_builder.scss +61 -0
  200. package/src/styles/layout/_project-validation.scss +214 -0
  201. package/src/styles/modals/_add-component.scss +4 -2
  202. package/src/styles/modals/_color-modal.scss +4 -2
  203. package/src/styles/modals/_modal-shell.scss +3 -1
  204. package/src/types/Device.ts +5 -0
  205. package/src/utils/__special_exceptions.ts +88 -0
  206. package/src/utils/analyseNode.ts +8 -2
  207. package/src/utils/analyseNodeByPatterns.ts +43 -9
  208. package/src/utils/extractTextStyle.ts +19 -6
  209. package/src/utils/extractViewStyle.ts +68 -59
  210. package/src/utils/getImage.ts +76 -0
  211. package/src/utils/novaToJson.ts +2 -1
  212. package/src/utils/pasteNode.ts +172 -0
  213. package/src/utils/patterns.ts +4 -3
  214. package/dist/android.svg +0 -43
  215. package/dist/apple.svg +0 -16
  216. package/dist/background.jpg +0 -0
@@ -0,0 +1,400 @@
1
+ import React, { useCallback, useEffect } from 'react';
2
+ import { useRenderStore } from '../../store';
3
+
4
+ type SubscriptionModalProps = {
5
+ productId: string;
6
+ onBuy: () => void;
7
+ onCancel: () => void;
8
+ };
9
+
10
+ export function SubscriptionModal({
11
+ productId,
12
+ onBuy,
13
+ onCancel,
14
+ }: SubscriptionModalProps) {
15
+ const device = useRenderStore((s) => s.device);
16
+ const isIOS = device.platform === 'ios';
17
+
18
+ const onOverlayClick = useCallback(
19
+ (e: React.MouseEvent<HTMLDivElement>) => {
20
+ if (e.target === e.currentTarget) onCancel();
21
+ },
22
+ [onCancel],
23
+ );
24
+
25
+ useEffect(() => {
26
+ const onKeyDown = (e: KeyboardEvent) => {
27
+ if (e.key === 'Escape') onCancel();
28
+ };
29
+ window.addEventListener('keydown', onKeyDown);
30
+ return () => window.removeEventListener('keydown', onKeyDown);
31
+ }, [onCancel]);
32
+
33
+ const titleFromProductId = productId
34
+ .split('.')
35
+ .slice(-2)
36
+ .join(' ')
37
+ .replace(/[-_]/g, ' ')
38
+ .replace(/\b\w/g, (c) => c.toUpperCase());
39
+
40
+ // Bottom sheet (both iOS + Android)
41
+ return (
42
+ <div
43
+ style={{
44
+ position: 'absolute',
45
+ top: 0,
46
+ left: 0,
47
+ right: 0,
48
+ bottom: 0,
49
+ backgroundColor: isIOS ? 'rgba(0, 0, 0, 0.35)' : 'rgba(0, 0, 0, 0.5)',
50
+ display: 'flex',
51
+ alignItems: 'flex-end',
52
+ justifyContent: 'stretch',
53
+ zIndex: 9999,
54
+ padding: 0,
55
+ }}
56
+ onClick={onOverlayClick}
57
+ >
58
+ <div
59
+ style={{
60
+ width: '100%',
61
+ backgroundColor: isIOS
62
+ ? 'hsl(var(--card, var(--rb-card, 0 0% 100%)) / 0.96)'
63
+ : 'hsl(var(--card, var(--rb-card, 0 0% 100%)))',
64
+ borderTopLeftRadius: 16,
65
+ borderTopRightRadius: 16,
66
+ overflow: 'hidden',
67
+ backdropFilter: isIOS ? 'blur(20px)' : undefined,
68
+ boxShadow: isIOS
69
+ ? '0 -12px 30px rgba(0,0,0,0.18), 0 -2px 6px rgba(0,0,0,0.08)'
70
+ : '0 -10px 20px rgba(0,0,0,0.22), 0 -2px 6px rgba(0,0,0,0.14)',
71
+ paddingBottom: 'max(12px, env(safe-area-inset-bottom))',
72
+ transform: 'translateY(0px)',
73
+ }}
74
+ >
75
+ <div
76
+ aria-hidden
77
+ style={{
78
+ width: 44,
79
+ height: 5,
80
+ borderRadius: 999,
81
+ background:
82
+ 'hsl(var(--foreground, var(--rb-foreground, 220.9 39.3% 11%)) / 0.18)',
83
+ margin: '10px auto 0',
84
+ }}
85
+ />
86
+
87
+ {isIOS ? (
88
+ <div
89
+ style={{
90
+ padding: '10px 16px 10px',
91
+ textAlign: 'center',
92
+ }}
93
+ >
94
+ <div
95
+ style={{
96
+ display: 'flex',
97
+ justifyContent: 'flex-end',
98
+ marginBottom: 6,
99
+ }}
100
+ >
101
+ <button
102
+ onClick={onCancel}
103
+ aria-label="Close"
104
+ style={{
105
+ width: 28,
106
+ height: 28,
107
+ borderRadius: 999,
108
+ border: 'none',
109
+ background:
110
+ 'hsl(var(--foreground, var(--rb-foreground, 220.9 39.3% 11%)) / 0.06)',
111
+ color:
112
+ 'hsl(var(--foreground, var(--rb-foreground, 220.9 39.3% 11%)) / 0.55)',
113
+ fontSize: 18,
114
+ lineHeight: '28px',
115
+ cursor: 'pointer',
116
+ }}
117
+ >
118
+ ×
119
+ </button>
120
+ </div>
121
+ <div
122
+ style={{
123
+ fontSize: 15,
124
+ fontWeight: 600,
125
+ color: '#000',
126
+ marginBottom: 8,
127
+ lineHeight: 1.3,
128
+ letterSpacing: 0.2,
129
+ }}
130
+ >
131
+ Confirm with Apple ID
132
+ </div>
133
+ <div
134
+ style={{
135
+ fontSize: 13,
136
+ color: '#000',
137
+ lineHeight: 1.4,
138
+ opacity: 0.6,
139
+ }}
140
+ >
141
+ Subscribe to <b>{titleFromProductId}</b>
142
+ </div>
143
+ <div
144
+ style={{
145
+ marginTop: 12,
146
+ padding: '10px 12px',
147
+ borderRadius: 12,
148
+ background:
149
+ 'hsl(var(--foreground, var(--rb-foreground, 220.9 39.3% 11%)) / 0.04)',
150
+ textAlign: 'left',
151
+ }}
152
+ >
153
+ <div
154
+ style={{
155
+ display: 'flex',
156
+ alignItems: 'center',
157
+ gap: 10,
158
+ }}
159
+ >
160
+ <div
161
+ aria-hidden
162
+ style={{
163
+ width: 38,
164
+ height: 38,
165
+ borderRadius: 10,
166
+ background:
167
+ 'linear-gradient(135deg, rgba(0,122,255,0.25), rgba(88,86,214,0.22))',
168
+ border: '1px solid rgba(0,0,0,0.06)',
169
+ }}
170
+ />
171
+ <div style={{ flex: 1, minWidth: 0 }}>
172
+ <div
173
+ style={{
174
+ fontSize: 14,
175
+ fontWeight: 600,
176
+ color: 'rgba(0,0,0,0.88)',
177
+ lineHeight: 1.2,
178
+ whiteSpace: 'nowrap',
179
+ overflow: 'hidden',
180
+ textOverflow: 'ellipsis',
181
+ }}
182
+ title={productId}
183
+ >
184
+ {productId}
185
+ </div>
186
+ <div
187
+ style={{
188
+ marginTop: 2,
189
+ fontSize: 12,
190
+ color: 'rgba(0,0,0,0.55)',
191
+ }}
192
+ >
193
+ Renews automatically until cancelled.
194
+ </div>
195
+ </div>
196
+ <div
197
+ style={{
198
+ fontSize: 13,
199
+ fontWeight: 700,
200
+ color: 'rgba(0,0,0,0.8)',
201
+ }}
202
+ >
203
+ $4.99
204
+ </div>
205
+ </div>
206
+ </div>
207
+ </div>
208
+ ) : (
209
+ <div style={{ padding: '14px 16px 10px' }}>
210
+ <div
211
+ style={{
212
+ display: 'flex',
213
+ justifyContent: 'space-between',
214
+ alignItems: 'center',
215
+ gap: 12,
216
+ }}
217
+ >
218
+ <div
219
+ style={{
220
+ fontSize: 16,
221
+ fontWeight: 600,
222
+ color: 'rgba(0,0,0,0.87)',
223
+ }}
224
+ >
225
+ Subscribe with Google Play
226
+ </div>
227
+ <button
228
+ onClick={onCancel}
229
+ aria-label="Close"
230
+ style={{
231
+ width: 28,
232
+ height: 28,
233
+ borderRadius: 999,
234
+ border: 'none',
235
+ background:
236
+ 'hsl(var(--foreground, var(--rb-foreground, 220.9 39.3% 11%)) / 0.06)',
237
+ color:
238
+ 'hsl(var(--foreground, var(--rb-foreground, 220.9 39.3% 11%)) / 0.55)',
239
+ fontSize: 18,
240
+ lineHeight: '28px',
241
+ cursor: 'pointer',
242
+ }}
243
+ >
244
+ ×
245
+ </button>
246
+ </div>
247
+ <div
248
+ style={{
249
+ marginTop: 8,
250
+ fontSize: 14,
251
+ color: 'rgba(0, 0, 0, 0.6)',
252
+ lineHeight: 1.5,
253
+ }}
254
+ >
255
+ You’re about to subscribe to <b>{titleFromProductId}</b>.
256
+ </div>
257
+
258
+ <div
259
+ style={{
260
+ marginTop: 14,
261
+ padding: '10px 12px',
262
+ borderRadius: 10,
263
+ background:
264
+ 'hsl(var(--foreground, var(--rb-foreground, 220.9 39.3% 11%)) / 0.04)',
265
+ border: '1px solid rgba(0,0,0,0.06)',
266
+ }}
267
+ >
268
+ <div
269
+ style={{
270
+ display: 'flex',
271
+ alignItems: 'center',
272
+ justifyContent: 'space-between',
273
+ gap: 10,
274
+ }}
275
+ >
276
+ <div style={{ minWidth: 0 }}>
277
+ <div
278
+ style={{
279
+ fontSize: 13,
280
+ fontWeight: 600,
281
+ color: 'rgba(0,0,0,0.78)',
282
+ whiteSpace: 'nowrap',
283
+ overflow: 'hidden',
284
+ textOverflow: 'ellipsis',
285
+ }}
286
+ >
287
+ {productId}
288
+ </div>
289
+ <div
290
+ style={{
291
+ marginTop: 2,
292
+ fontSize: 12,
293
+ color: 'rgba(0,0,0,0.55)',
294
+ }}
295
+ >
296
+ Auto-renews • Cancel anytime in Play Store
297
+ </div>
298
+ </div>
299
+ <div
300
+ style={{
301
+ fontSize: 13,
302
+ fontWeight: 700,
303
+ color: 'rgba(0,0,0,0.8)',
304
+ }}
305
+ >
306
+ $4.99
307
+ </div>
308
+ </div>
309
+ </div>
310
+ </div>
311
+ )}
312
+
313
+ {isIOS ? (
314
+ <div
315
+ style={{
316
+ borderTop: '0.5px solid rgba(0, 0, 0, 0.16)',
317
+ display: 'flex',
318
+ }}
319
+ >
320
+ <button
321
+ onClick={onCancel}
322
+ style={{
323
+ flex: 1,
324
+ padding: '13px 0',
325
+ fontSize: 17,
326
+ fontWeight: 400,
327
+ color: '#007AFF',
328
+ background: 'transparent',
329
+ border: 'none',
330
+ borderRight: '0.5px solid rgba(0, 0, 0, 0.16)',
331
+ cursor: 'pointer',
332
+ }}
333
+ >
334
+ Cancel
335
+ </button>
336
+ <button
337
+ onClick={onBuy}
338
+ style={{
339
+ flex: 1,
340
+ padding: '13px 0',
341
+ fontSize: 17,
342
+ fontWeight: 600,
343
+ color: '#007AFF',
344
+ background: 'transparent',
345
+ border: 'none',
346
+ cursor: 'pointer',
347
+ }}
348
+ >
349
+ Subscribe
350
+ </button>
351
+ </div>
352
+ ) : (
353
+ <div
354
+ style={{
355
+ padding: '10px 12px 12px',
356
+ display: 'flex',
357
+ justifyContent: 'flex-end',
358
+ gap: 8,
359
+ }}
360
+ >
361
+ <button
362
+ onClick={onCancel}
363
+ style={{
364
+ padding: '10px 16px',
365
+ fontSize: 14,
366
+ fontWeight: 500,
367
+ color: '#5F6368',
368
+ background: 'transparent',
369
+ border: 'none',
370
+ borderRadius: 4,
371
+ cursor: 'pointer',
372
+ textTransform: 'uppercase',
373
+ letterSpacing: 0.5,
374
+ }}
375
+ >
376
+ Cancel
377
+ </button>
378
+ <button
379
+ onClick={onBuy}
380
+ style={{
381
+ padding: '10px 16px',
382
+ fontSize: 14,
383
+ fontWeight: 700,
384
+ color: '#1A73E8',
385
+ background: 'rgba(26,115,232,0.12)',
386
+ border: 'none',
387
+ borderRadius: 999,
388
+ cursor: 'pointer',
389
+ textTransform: 'uppercase',
390
+ letterSpacing: 0.5,
391
+ }}
392
+ >
393
+ Subscribe
394
+ </button>
395
+ </div>
396
+ )}
397
+ </div>
398
+ </div>
399
+ );
400
+ }
@@ -1,6 +1,13 @@
1
- import React, { ReactNode, useState, useCallback } from 'react';
1
+ import React, {
2
+ ReactNode,
3
+ useCallback,
4
+ useMemo,
5
+ useRef,
6
+ useState,
7
+ } from 'react';
2
8
  import type { PermissionType } from '../managers/mockPermissionManager';
3
9
  import { PermissionModal } from '../components/PermissionModal';
10
+ import { SubscriptionModal } from '../components/SubscriptionModal';
4
11
  import { MockOSRouter } from '../components/MockOSRouter';
5
12
  import { DeviceStatusBar } from '../../components/DeviceStatusBar';
6
13
  import { DeviceNavigationBar } from '../../components/DeviceNavigationBar';
@@ -53,6 +60,12 @@ export function MockOSProvider({
53
60
  const [permission, setPermission] = useState<PermissionType | string | null>(
54
61
  null,
55
62
  );
63
+ const [subscriptionProductId, setSubscriptionProductId] = useState<
64
+ string | null
65
+ >(null);
66
+ const subscriptionResolverRef = useRef<((result: boolean) => void) | null>(
67
+ null,
68
+ );
56
69
  const [currentRoute, setCurrentRoute] = useState<RouteType>(defaultRoute);
57
70
  const [navigationStack, setNavigationStack] = useState<RouteStackItem[]>([
58
71
  { route: defaultRoute, timestamp: Date.now() },
@@ -93,15 +106,46 @@ export function MockOSProvider({
93
106
  return false;
94
107
  }, [navigationStack]);
95
108
 
96
- const value: MockOSContextValue = {
97
- isEnabled: true,
98
- permission,
99
- setPermission,
100
- currentRoute,
101
- navigation,
102
- goBack,
103
- navigationStack,
104
- };
109
+ const requestSubscriptionPurchase = useCallback((productId: string) => {
110
+ // Cancel any existing pending request (resolve false)
111
+ if (subscriptionResolverRef.current) {
112
+ subscriptionResolverRef.current(false);
113
+ subscriptionResolverRef.current = null;
114
+ }
115
+ setSubscriptionProductId(productId);
116
+
117
+ return new Promise<boolean>((resolve) => {
118
+ subscriptionResolverRef.current = resolve;
119
+ });
120
+ }, []);
121
+
122
+ const resolveSubscriptionPurchase = useCallback((result: boolean) => {
123
+ const resolver = subscriptionResolverRef.current;
124
+ subscriptionResolverRef.current = null;
125
+ setSubscriptionProductId(null);
126
+ resolver?.(result);
127
+ }, []);
128
+
129
+ const value: MockOSContextValue = useMemo(
130
+ () => ({
131
+ isEnabled: true,
132
+ permission,
133
+ setPermission,
134
+ requestSubscriptionPurchase,
135
+ currentRoute,
136
+ navigation,
137
+ goBack,
138
+ navigationStack,
139
+ }),
140
+ [
141
+ permission,
142
+ requestSubscriptionPurchase,
143
+ currentRoute,
144
+ navigation,
145
+ goBack,
146
+ navigationStack,
147
+ ],
148
+ );
105
149
 
106
150
  const handleAllow = () => {
107
151
  setPermission(null);
@@ -120,6 +164,13 @@ export function MockOSProvider({
120
164
  onDeny={handleDeny}
121
165
  />
122
166
  )}
167
+ {subscriptionProductId !== null && (
168
+ <SubscriptionModal
169
+ productId={subscriptionProductId}
170
+ onBuy={() => resolveSubscriptionPurchase(true)}
171
+ onCancel={() => resolveSubscriptionPurchase(false)}
172
+ />
173
+ )}
123
174
  <DeviceStatusBar
124
175
  height={statusBarHeight}
125
176
  backgroundColor={statusBarBackgroundColor}
@@ -17,6 +17,7 @@ export interface MockOSContextValue {
17
17
  isEnabled: boolean;
18
18
  permission: PermissionType | string | null;
19
19
  setPermission: (permission: PermissionType | string | null) => void;
20
+ requestSubscriptionPurchase: (productId: string) => Promise<boolean>;
20
21
  // Router
21
22
  currentRoute: RouteType;
22
23
  navigation: (route: RouteType) => void;
@@ -0,0 +1,11 @@
1
+ import { useMemo } from 'react';
2
+ import type { MockOSContextValue } from '../context/MockOSContext';
3
+ import { MockOSIapManager } from '../managers/mockOSIapManager';
4
+
5
+ export function useMockIap(context: MockOSContextValue | null) {
6
+ const iapManager = useMemo(() => {
7
+ return new MockOSIapManager(context);
8
+ }, [context]);
9
+
10
+ return iapManager;
11
+ }
@@ -21,7 +21,14 @@ export type {
21
21
  NavigationDestination,
22
22
  NavigationStackItem,
23
23
  } from './managers/navigationManager';
24
+ export { MockOSIapManager } from './managers/mockOSIapManager';
25
+ export { MockSubscriptionManager } from './managers/subscriptionManager';
26
+ export type {
27
+ SubscriptionPurchaseListener,
28
+ SubscriptionPurchaseResult,
29
+ } from './managers/subscriptionManager';
24
30
 
25
31
  // Hooks
26
32
  export { useMockPermission } from './hooks/useMockPermission';
27
33
  export { useMockNavigation } from './hooks/useMockNavigation';
34
+ export { useMockIap } from './hooks/useMockIap';
@@ -0,0 +1,10 @@
1
+ import type { MockOSContextValue } from '../context/MockOSContext';
2
+ import { MockSubscriptionManager } from './subscriptionManager';
3
+
4
+ export class MockOSIapManager {
5
+ public subscription: MockSubscriptionManager;
6
+
7
+ constructor(context: MockOSContextValue | null) {
8
+ this.subscription = new MockSubscriptionManager(context);
9
+ }
10
+ }
@@ -0,0 +1,36 @@
1
+ import type { MockOSContextValue } from '../context/MockOSContext';
2
+
3
+ export type SubscriptionPurchaseResult = boolean;
4
+ export type SubscriptionPurchaseListener = (
5
+ result: SubscriptionPurchaseResult,
6
+ ) => void;
7
+
8
+ export class MockSubscriptionManager {
9
+ private context: MockOSContextValue | null;
10
+ private listeners = new Set<SubscriptionPurchaseListener>();
11
+
12
+ constructor(context: MockOSContextValue | null) {
13
+ this.context = context;
14
+ }
15
+
16
+ addListener(listener: SubscriptionPurchaseListener): () => void {
17
+ this.listeners.add(listener);
18
+ return () => this.listeners.delete(listener);
19
+ }
20
+
21
+ async buy(productId: string): Promise<boolean> {
22
+ if (this.context === null) {
23
+ const ok =
24
+ typeof window !== 'undefined' &&
25
+ typeof window.confirm === 'function' &&
26
+ window.confirm(`Subscribe to ${productId}?`);
27
+ const result = Boolean(ok);
28
+ this.listeners.forEach((l) => l(result));
29
+ return result;
30
+ }
31
+
32
+ const result = await this.context.requestSubscriptionPurchase(productId);
33
+ this.listeners.forEach((l) => l(result));
34
+ return result;
35
+ }
36
+ }
@@ -80,7 +80,7 @@ export function IconPickerModal({
80
80
  borderRadius: 8,
81
81
  border: isActive ? '2px solid #222' : '1px solid #ddd',
82
82
  padding: '8px 10px',
83
- background: '#fff',
83
+ background: 'hsl(var(--card, var(--rb-card, 0 0% 100%)))',
84
84
  cursor: 'pointer',
85
85
  }}
86
86
  aria-label={`Select icon ${name}`}