@pushframe/sdk 0.1.5 → 0.1.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 (288) hide show
  1. package/lib/commonjs/PushframeProvider.js +69 -0
  2. package/lib/commonjs/PushframeProvider.js.map +1 -0
  3. package/lib/commonjs/PushframeScreen.js +69 -0
  4. package/lib/commonjs/PushframeScreen.js.map +1 -0
  5. package/lib/commonjs/bindings.js +73 -0
  6. package/lib/commonjs/bindings.js.map +1 -0
  7. package/lib/commonjs/components/ButtonComponent.js +72 -0
  8. package/lib/commonjs/components/ButtonComponent.js.map +1 -0
  9. package/lib/commonjs/components/FlatListComponent.js +73 -0
  10. package/lib/commonjs/components/FlatListComponent.js.map +1 -0
  11. package/lib/commonjs/components/ImageComponent.js +67 -0
  12. package/lib/commonjs/components/ImageComponent.js.map +1 -0
  13. package/lib/commonjs/components/PushFrameComponent.js +179 -0
  14. package/lib/commonjs/components/PushFrameComponent.js.map +1 -0
  15. package/lib/commonjs/components/PushFrameProvider.js +115 -0
  16. package/lib/commonjs/components/PushFrameProvider.js.map +1 -0
  17. package/lib/commonjs/components/PushFrameScreen.js +39 -0
  18. package/lib/commonjs/components/PushFrameScreen.js.map +1 -0
  19. package/lib/commonjs/components/ScrollViewComponent.js +64 -0
  20. package/lib/commonjs/components/ScrollViewComponent.js.map +1 -0
  21. package/lib/commonjs/components/StackComponent.js +61 -0
  22. package/lib/commonjs/components/StackComponent.js.map +1 -0
  23. package/lib/commonjs/components/TextComponent.js +62 -0
  24. package/lib/commonjs/components/TextComponent.js.map +1 -0
  25. package/lib/commonjs/conditions.js +44 -0
  26. package/lib/commonjs/conditions.js.map +1 -0
  27. package/lib/commonjs/context/PushFrameContext.js +33 -0
  28. package/lib/commonjs/context/PushFrameContext.js.map +1 -0
  29. package/lib/commonjs/index.js +200 -0
  30. package/lib/commonjs/index.js.map +1 -0
  31. package/lib/commonjs/overlays/BottomSheetHost.js +144 -0
  32. package/lib/commonjs/overlays/BottomSheetHost.js.map +1 -0
  33. package/lib/commonjs/overlays/ToastHost.js +135 -0
  34. package/lib/commonjs/overlays/ToastHost.js.map +1 -0
  35. package/lib/commonjs/package.json +1 -0
  36. package/lib/commonjs/primitives/ActivityIndicator.js +24 -0
  37. package/lib/commonjs/primitives/ActivityIndicator.js.map +1 -0
  38. package/lib/commonjs/primitives/FlatList.js +34 -0
  39. package/lib/commonjs/primitives/FlatList.js.map +1 -0
  40. package/lib/commonjs/primitives/Image.js +33 -0
  41. package/lib/commonjs/primitives/Image.js.map +1 -0
  42. package/lib/commonjs/primitives/KeyboardAvoidingView.js +24 -0
  43. package/lib/commonjs/primitives/KeyboardAvoidingView.js.map +1 -0
  44. package/lib/commonjs/primitives/Modal.js +24 -0
  45. package/lib/commonjs/primitives/Modal.js.map +1 -0
  46. package/lib/commonjs/primitives/Pressable.js +26 -0
  47. package/lib/commonjs/primitives/Pressable.js.map +1 -0
  48. package/lib/commonjs/primitives/SafeAreaView.js +38 -0
  49. package/lib/commonjs/primitives/SafeAreaView.js.map +1 -0
  50. package/lib/commonjs/primitives/ScrollView.js +26 -0
  51. package/lib/commonjs/primitives/ScrollView.js.map +1 -0
  52. package/lib/commonjs/primitives/StatusBar.js +24 -0
  53. package/lib/commonjs/primitives/StatusBar.js.map +1 -0
  54. package/lib/commonjs/primitives/Switch.js +28 -0
  55. package/lib/commonjs/primitives/Switch.js.map +1 -0
  56. package/lib/commonjs/primitives/Text.js +37 -0
  57. package/lib/commonjs/primitives/Text.js.map +1 -0
  58. package/lib/commonjs/primitives/TextInput.js +31 -0
  59. package/lib/commonjs/primitives/TextInput.js.map +1 -0
  60. package/lib/commonjs/primitives/View.js +24 -0
  61. package/lib/commonjs/primitives/View.js.map +1 -0
  62. package/lib/commonjs/primitives/index.js +97 -0
  63. package/lib/commonjs/primitives/index.js.map +1 -0
  64. package/lib/commonjs/registry/ComponentRegistry.js +70 -0
  65. package/lib/commonjs/registry/ComponentRegistry.js.map +1 -0
  66. package/lib/commonjs/registry.js +94 -0
  67. package/lib/commonjs/registry.js.map +1 -0
  68. package/lib/commonjs/renderer/RecursiveRenderer.js +202 -0
  69. package/lib/commonjs/renderer/RecursiveRenderer.js.map +1 -0
  70. package/lib/commonjs/renderer/bindingResolver.js +98 -0
  71. package/lib/commonjs/renderer/bindingResolver.js.map +1 -0
  72. package/lib/commonjs/renderer/conditionalEvaluator.js +31 -0
  73. package/lib/commonjs/renderer/conditionalEvaluator.js.map +1 -0
  74. package/lib/commonjs/renderer.js +107 -0
  75. package/lib/commonjs/renderer.js.map +1 -0
  76. package/lib/commonjs/schema.js +79 -0
  77. package/lib/commonjs/schema.js.map +1 -0
  78. package/lib/commonjs/transformer/index.js +1055 -0
  79. package/lib/commonjs/transformer/index.js.map +1 -0
  80. package/lib/commonjs/transport.js +86 -0
  81. package/lib/commonjs/transport.js.map +1 -0
  82. package/lib/module/PushframeProvider.js +62 -0
  83. package/lib/module/PushframeProvider.js.map +1 -0
  84. package/lib/module/PushframeScreen.js +65 -0
  85. package/lib/module/PushframeScreen.js.map +1 -0
  86. package/lib/module/bindings.js +68 -0
  87. package/lib/module/bindings.js.map +1 -0
  88. package/lib/module/components/ButtonComponent.js +67 -0
  89. package/lib/module/components/ButtonComponent.js.map +1 -0
  90. package/lib/module/components/FlatListComponent.js +68 -0
  91. package/lib/module/components/FlatListComponent.js.map +1 -0
  92. package/lib/module/components/ImageComponent.js +62 -0
  93. package/lib/module/components/ImageComponent.js.map +1 -0
  94. package/lib/module/components/PushFrameComponent.js +174 -0
  95. package/lib/module/components/PushFrameComponent.js.map +1 -0
  96. package/lib/module/components/PushFrameProvider.js +110 -0
  97. package/lib/module/components/PushFrameProvider.js.map +1 -0
  98. package/lib/module/components/PushFrameScreen.js +34 -0
  99. package/lib/module/components/PushFrameScreen.js.map +1 -0
  100. package/lib/module/components/ScrollViewComponent.js +59 -0
  101. package/lib/module/components/ScrollViewComponent.js.map +1 -0
  102. package/lib/module/components/StackComponent.js +56 -0
  103. package/lib/module/components/StackComponent.js.map +1 -0
  104. package/lib/module/components/TextComponent.js +57 -0
  105. package/lib/module/components/TextComponent.js.map +1 -0
  106. package/lib/module/conditions.js +40 -0
  107. package/lib/module/conditions.js.map +1 -0
  108. package/lib/module/context/PushFrameContext.js +29 -0
  109. package/lib/module/context/PushFrameContext.js.map +1 -0
  110. package/lib/module/index.js +99 -0
  111. package/lib/module/index.js.map +1 -0
  112. package/lib/module/overlays/BottomSheetHost.js +139 -0
  113. package/lib/module/overlays/BottomSheetHost.js.map +1 -0
  114. package/lib/module/overlays/ToastHost.js +130 -0
  115. package/lib/module/overlays/ToastHost.js.map +1 -0
  116. package/lib/module/primitives/ActivityIndicator.js +19 -0
  117. package/lib/module/primitives/ActivityIndicator.js.map +1 -0
  118. package/lib/module/primitives/FlatList.js +29 -0
  119. package/lib/module/primitives/FlatList.js.map +1 -0
  120. package/lib/module/primitives/Image.js +28 -0
  121. package/lib/module/primitives/Image.js.map +1 -0
  122. package/lib/module/primitives/KeyboardAvoidingView.js +19 -0
  123. package/lib/module/primitives/KeyboardAvoidingView.js.map +1 -0
  124. package/lib/module/primitives/Modal.js +19 -0
  125. package/lib/module/primitives/Modal.js.map +1 -0
  126. package/lib/module/primitives/Pressable.js +21 -0
  127. package/lib/module/primitives/Pressable.js.map +1 -0
  128. package/lib/module/primitives/SafeAreaView.js +33 -0
  129. package/lib/module/primitives/SafeAreaView.js.map +1 -0
  130. package/lib/module/primitives/ScrollView.js +21 -0
  131. package/lib/module/primitives/ScrollView.js.map +1 -0
  132. package/lib/module/primitives/StatusBar.js +19 -0
  133. package/lib/module/primitives/StatusBar.js.map +1 -0
  134. package/lib/module/primitives/Switch.js +23 -0
  135. package/lib/module/primitives/Switch.js.map +1 -0
  136. package/lib/module/primitives/Text.js +32 -0
  137. package/lib/module/primitives/Text.js.map +1 -0
  138. package/lib/module/primitives/TextInput.js +26 -0
  139. package/lib/module/primitives/TextInput.js.map +1 -0
  140. package/lib/module/primitives/View.js +19 -0
  141. package/lib/module/primitives/View.js.map +1 -0
  142. package/lib/module/primitives/index.js +16 -0
  143. package/lib/module/primitives/index.js.map +1 -0
  144. package/lib/module/registry/ComponentRegistry.js +66 -0
  145. package/lib/module/registry/ComponentRegistry.js.map +1 -0
  146. package/lib/module/registry.js +88 -0
  147. package/lib/module/registry.js.map +1 -0
  148. package/lib/module/renderer/RecursiveRenderer.js +197 -0
  149. package/lib/module/renderer/RecursiveRenderer.js.map +1 -0
  150. package/lib/module/renderer/bindingResolver.js +92 -0
  151. package/lib/module/renderer/bindingResolver.js.map +1 -0
  152. package/lib/module/renderer/conditionalEvaluator.js +28 -0
  153. package/lib/module/renderer/conditionalEvaluator.js.map +1 -0
  154. package/lib/module/renderer.js +103 -0
  155. package/lib/module/renderer.js.map +1 -0
  156. package/lib/module/schema.js +74 -0
  157. package/lib/module/schema.js.map +1 -0
  158. package/lib/module/transformer/index.js +1051 -0
  159. package/lib/module/transformer/index.js.map +1 -0
  160. package/lib/module/transport.js +82 -0
  161. package/lib/module/transport.js.map +1 -0
  162. package/lib/typescript/PushframeProvider.d.ts +58 -0
  163. package/lib/typescript/PushframeProvider.d.ts.map +1 -0
  164. package/lib/typescript/PushframeScreen.d.ts +36 -0
  165. package/lib/typescript/PushframeScreen.d.ts.map +1 -0
  166. package/lib/typescript/bindings.d.ts +29 -0
  167. package/lib/typescript/bindings.d.ts.map +1 -0
  168. package/lib/typescript/components/ButtonComponent.d.ts +11 -0
  169. package/lib/typescript/components/ButtonComponent.d.ts.map +1 -0
  170. package/lib/typescript/components/FlatListComponent.d.ts +28 -0
  171. package/lib/typescript/components/FlatListComponent.d.ts.map +1 -0
  172. package/lib/typescript/components/ImageComponent.d.ts +12 -0
  173. package/lib/typescript/components/ImageComponent.d.ts.map +1 -0
  174. package/lib/typescript/components/PushFrameComponent.d.ts +48 -0
  175. package/lib/typescript/components/PushFrameComponent.d.ts.map +1 -0
  176. package/lib/typescript/components/PushFrameProvider.d.ts +51 -0
  177. package/lib/typescript/components/PushFrameProvider.d.ts.map +1 -0
  178. package/lib/typescript/components/PushFrameScreen.d.ts +15 -0
  179. package/lib/typescript/components/PushFrameScreen.d.ts.map +1 -0
  180. package/lib/typescript/components/ScrollViewComponent.d.ts +19 -0
  181. package/lib/typescript/components/ScrollViewComponent.d.ts.map +1 -0
  182. package/lib/typescript/components/StackComponent.d.ts +16 -0
  183. package/lib/typescript/components/StackComponent.d.ts.map +1 -0
  184. package/lib/typescript/components/TextComponent.d.ts +13 -0
  185. package/lib/typescript/components/TextComponent.d.ts.map +1 -0
  186. package/lib/typescript/conditions.d.ts +12 -0
  187. package/lib/typescript/conditions.d.ts.map +1 -0
  188. package/lib/typescript/context/PushFrameContext.d.ts +57 -0
  189. package/lib/typescript/context/PushFrameContext.d.ts.map +1 -0
  190. package/lib/typescript/index.d.ts +74 -0
  191. package/lib/typescript/index.d.ts.map +1 -0
  192. package/lib/typescript/overlays/BottomSheetHost.d.ts +21 -0
  193. package/lib/typescript/overlays/BottomSheetHost.d.ts.map +1 -0
  194. package/lib/typescript/overlays/ToastHost.d.ts +12 -0
  195. package/lib/typescript/overlays/ToastHost.d.ts.map +1 -0
  196. package/lib/typescript/primitives/ActivityIndicator.d.ts +12 -0
  197. package/lib/typescript/primitives/ActivityIndicator.d.ts.map +1 -0
  198. package/lib/typescript/primitives/FlatList.d.ts +29 -0
  199. package/lib/typescript/primitives/FlatList.d.ts.map +1 -0
  200. package/lib/typescript/primitives/Image.d.ts +20 -0
  201. package/lib/typescript/primitives/Image.d.ts.map +1 -0
  202. package/lib/typescript/primitives/KeyboardAvoidingView.d.ts +12 -0
  203. package/lib/typescript/primitives/KeyboardAvoidingView.d.ts.map +1 -0
  204. package/lib/typescript/primitives/Modal.d.ts +12 -0
  205. package/lib/typescript/primitives/Modal.d.ts.map +1 -0
  206. package/lib/typescript/primitives/Pressable.d.ts +14 -0
  207. package/lib/typescript/primitives/Pressable.d.ts.map +1 -0
  208. package/lib/typescript/primitives/SafeAreaView.d.ts +20 -0
  209. package/lib/typescript/primitives/SafeAreaView.d.ts.map +1 -0
  210. package/lib/typescript/primitives/ScrollView.d.ts +15 -0
  211. package/lib/typescript/primitives/ScrollView.d.ts.map +1 -0
  212. package/lib/typescript/primitives/StatusBar.d.ts +12 -0
  213. package/lib/typescript/primitives/StatusBar.d.ts.map +1 -0
  214. package/lib/typescript/primitives/Switch.d.ts +19 -0
  215. package/lib/typescript/primitives/Switch.d.ts.map +1 -0
  216. package/lib/typescript/primitives/Text.d.ts +25 -0
  217. package/lib/typescript/primitives/Text.d.ts.map +1 -0
  218. package/lib/typescript/primitives/TextInput.d.ts +25 -0
  219. package/lib/typescript/primitives/TextInput.d.ts.map +1 -0
  220. package/lib/typescript/primitives/View.d.ts +12 -0
  221. package/lib/typescript/primitives/View.d.ts.map +1 -0
  222. package/lib/typescript/primitives/index.d.ts +27 -0
  223. package/lib/typescript/primitives/index.d.ts.map +1 -0
  224. package/lib/typescript/registry/ComponentRegistry.d.ts +21 -0
  225. package/lib/typescript/registry/ComponentRegistry.d.ts.map +1 -0
  226. package/lib/typescript/registry.d.ts +57 -0
  227. package/lib/typescript/registry.d.ts.map +1 -0
  228. package/lib/typescript/renderer/RecursiveRenderer.d.ts +32 -0
  229. package/lib/typescript/renderer/RecursiveRenderer.d.ts.map +1 -0
  230. package/lib/typescript/renderer/bindingResolver.d.ts +26 -0
  231. package/lib/typescript/renderer/bindingResolver.d.ts.map +1 -0
  232. package/lib/typescript/renderer/conditionalEvaluator.d.ts +15 -0
  233. package/lib/typescript/renderer/conditionalEvaluator.d.ts.map +1 -0
  234. package/lib/typescript/renderer.d.ts +29 -0
  235. package/lib/typescript/renderer.d.ts.map +1 -0
  236. package/lib/typescript/schema.d.ts +84 -0
  237. package/lib/typescript/schema.d.ts.map +1 -0
  238. package/lib/typescript/transformer/index.d.ts +49 -0
  239. package/lib/typescript/transformer/index.d.ts.map +1 -0
  240. package/lib/typescript/transport.d.ts +19 -0
  241. package/lib/typescript/transport.d.ts.map +1 -0
  242. package/package.json +20 -18
  243. package/src/PushframeProvider.tsx +119 -0
  244. package/src/PushframeScreen.tsx +107 -0
  245. package/src/bindings.ts +72 -0
  246. package/src/components/ButtonComponent.tsx +87 -0
  247. package/src/components/FlatListComponent.tsx +86 -0
  248. package/src/components/ImageComponent.tsx +70 -0
  249. package/src/components/PushFrameComponent.tsx +221 -0
  250. package/src/components/PushFrameProvider.tsx +177 -0
  251. package/src/components/PushFrameScreen.tsx +30 -0
  252. package/src/components/ScrollViewComponent.tsx +65 -0
  253. package/src/components/StackComponent.tsx +69 -0
  254. package/src/components/TextComponent.tsx +60 -0
  255. package/src/conditions.ts +46 -0
  256. package/src/context/PushFrameContext.ts +89 -0
  257. package/src/index.ts +119 -0
  258. package/src/overlays/BottomSheetHost.tsx +175 -0
  259. package/src/overlays/ToastHost.tsx +147 -0
  260. package/src/primitives/ActivityIndicator.tsx +21 -0
  261. package/src/primitives/FlatList.tsx +49 -0
  262. package/src/primitives/Image.tsx +26 -0
  263. package/src/primitives/KeyboardAvoidingView.tsx +21 -0
  264. package/src/primitives/Modal.tsx +17 -0
  265. package/src/primitives/Pressable.tsx +19 -0
  266. package/src/primitives/SafeAreaView.tsx +42 -0
  267. package/src/primitives/ScrollView.tsx +21 -0
  268. package/src/primitives/StatusBar.tsx +17 -0
  269. package/src/primitives/Switch.tsx +24 -0
  270. package/src/primitives/Text.tsx +43 -0
  271. package/src/primitives/TextInput.tsx +42 -0
  272. package/src/primitives/View.tsx +17 -0
  273. package/src/primitives/index.ts +38 -0
  274. package/src/registry/ComponentRegistry.ts +99 -0
  275. package/src/registry.ts +99 -0
  276. package/src/renderer/RecursiveRenderer.tsx +242 -0
  277. package/src/renderer/bindingResolver.ts +94 -0
  278. package/src/renderer/conditionalEvaluator.ts +29 -0
  279. package/src/renderer.tsx +124 -0
  280. package/src/schema.ts +132 -0
  281. package/src/transformer/index.ts +1016 -0
  282. package/src/transport.ts +104 -0
  283. package/dist/index.d.mts +0 -534
  284. package/dist/index.d.ts +0 -534
  285. package/dist/index.js +0 -1572
  286. package/dist/index.js.map +0 -1
  287. package/dist/index.mjs +0 -1541
  288. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import { ScrollView } from 'react-native';
3
+ import type { PushframeComponentProps } from '../registry';
4
+
5
+ export interface ScrollViewProps {
6
+ horizontal?: boolean;
7
+ padding?: number;
8
+ paddingTop?: number;
9
+ paddingBottom?: number;
10
+ paddingLeft?: number;
11
+ paddingRight?: number;
12
+ backgroundColor?: string;
13
+ flex?: number;
14
+ showsScrollIndicator?: boolean;
15
+ contentPadding?: number;
16
+ contentPaddingTop?: number;
17
+ contentPaddingBottom?: number;
18
+ contentPaddingLeft?: number;
19
+ contentPaddingRight?: number;
20
+ }
21
+
22
+ export function ScrollViewComponent({ props, children }: PushframeComponentProps<ScrollViewProps>) {
23
+ const {
24
+ horizontal = false,
25
+ padding,
26
+ paddingTop,
27
+ paddingBottom,
28
+ paddingLeft,
29
+ paddingRight,
30
+ backgroundColor,
31
+ flex,
32
+ showsScrollIndicator = true,
33
+ contentPadding,
34
+ contentPaddingTop,
35
+ contentPaddingBottom,
36
+ contentPaddingLeft,
37
+ contentPaddingRight,
38
+ } = props;
39
+
40
+ return (
41
+ <ScrollView
42
+ horizontal={horizontal}
43
+ showsHorizontalScrollIndicator={horizontal ? showsScrollIndicator : false}
44
+ showsVerticalScrollIndicator={!horizontal ? showsScrollIndicator : false}
45
+ style={[
46
+ padding !== undefined && { padding },
47
+ paddingTop !== undefined && { paddingTop },
48
+ paddingBottom !== undefined && { paddingBottom },
49
+ paddingLeft !== undefined && { paddingLeft },
50
+ paddingRight !== undefined && { paddingRight },
51
+ backgroundColor !== undefined && { backgroundColor },
52
+ flex !== undefined && { flex },
53
+ ]}
54
+ contentContainerStyle={[
55
+ contentPadding !== undefined && { padding: contentPadding },
56
+ contentPaddingTop !== undefined && { paddingTop: contentPaddingTop },
57
+ contentPaddingBottom !== undefined && { paddingBottom: contentPaddingBottom },
58
+ contentPaddingLeft !== undefined && { paddingLeft: contentPaddingLeft },
59
+ contentPaddingRight !== undefined && { paddingRight: contentPaddingRight },
60
+ ]}
61
+ >
62
+ {children}
63
+ </ScrollView>
64
+ );
65
+ }
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import type { PushframeComponentProps } from '../registry';
4
+
5
+ export interface StackProps {
6
+ direction?: 'vertical' | 'horizontal';
7
+ padding?: number;
8
+ paddingTop?: number;
9
+ paddingBottom?: number;
10
+ paddingLeft?: number;
11
+ paddingRight?: number;
12
+ gap?: number;
13
+ backgroundColor?: string;
14
+ flex?: number;
15
+ alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
16
+ justifyContent?:
17
+ | 'flex-start'
18
+ | 'flex-end'
19
+ | 'center'
20
+ | 'space-between'
21
+ | 'space-around'
22
+ | 'space-evenly';
23
+ }
24
+
25
+ export function StackComponent({ props, children }: PushframeComponentProps<StackProps>) {
26
+ const {
27
+ direction = 'vertical',
28
+ padding,
29
+ paddingTop,
30
+ paddingBottom,
31
+ paddingLeft,
32
+ paddingRight,
33
+ gap,
34
+ backgroundColor,
35
+ flex,
36
+ alignItems,
37
+ justifyContent,
38
+ } = props;
39
+
40
+ return (
41
+ <View
42
+ style={[
43
+ styles.base,
44
+ direction === 'horizontal' && styles.horizontal,
45
+ padding !== undefined && { padding },
46
+ paddingTop !== undefined && { paddingTop },
47
+ paddingBottom !== undefined && { paddingBottom },
48
+ paddingLeft !== undefined && { paddingLeft },
49
+ paddingRight !== undefined && { paddingRight },
50
+ gap !== undefined && { gap },
51
+ backgroundColor !== undefined && { backgroundColor },
52
+ flex !== undefined && { flex },
53
+ alignItems !== undefined && { alignItems },
54
+ justifyContent !== undefined && { justifyContent },
55
+ ]}
56
+ >
57
+ {children}
58
+ </View>
59
+ );
60
+ }
61
+
62
+ const styles = StyleSheet.create({
63
+ base: {
64
+ flexDirection: 'column',
65
+ },
66
+ horizontal: {
67
+ flexDirection: 'row',
68
+ },
69
+ });
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import { Text, StyleSheet } from 'react-native';
3
+ import type { PushframeComponentProps } from '../registry';
4
+
5
+ export type TextSize = 'heading' | 'subheading' | 'body' | 'caption';
6
+ export type TextWeight = 'normal' | 'medium' | 'bold';
7
+
8
+ export interface TextProps {
9
+ content?: string;
10
+ size?: TextSize;
11
+ weight?: TextWeight;
12
+ color?: string;
13
+ align?: 'left' | 'center' | 'right';
14
+ numberOfLines?: number;
15
+ }
16
+
17
+ const SIZE_STYLES: Record<TextSize, { fontSize: number; lineHeight: number }> = {
18
+ heading: { fontSize: 24, lineHeight: 32 },
19
+ subheading: { fontSize: 18, lineHeight: 26 },
20
+ body: { fontSize: 16, lineHeight: 24 },
21
+ caption: { fontSize: 12, lineHeight: 18 },
22
+ };
23
+
24
+ const WEIGHT_MAP: Record<TextWeight, '400' | '500' | '700'> = {
25
+ normal: '400',
26
+ medium: '500',
27
+ bold: '700',
28
+ };
29
+
30
+ export function TextComponent({ props }: PushframeComponentProps<TextProps>) {
31
+ const {
32
+ content = '',
33
+ size = 'body',
34
+ weight = 'normal',
35
+ color,
36
+ align,
37
+ numberOfLines,
38
+ } = props;
39
+
40
+ return (
41
+ <Text
42
+ style={[
43
+ styles.base,
44
+ SIZE_STYLES[size],
45
+ { fontWeight: WEIGHT_MAP[weight] },
46
+ color !== undefined && { color },
47
+ align !== undefined && { textAlign: align },
48
+ ]}
49
+ numberOfLines={numberOfLines}
50
+ >
51
+ {content}
52
+ </Text>
53
+ );
54
+ }
55
+
56
+ const styles = StyleSheet.create({
57
+ base: {
58
+ color: '#1a1a1a',
59
+ },
60
+ });
@@ -0,0 +1,46 @@
1
+ import type { Condition } from './schema';
2
+ import { resolveValue } from './bindings';
3
+ import type { PushframeContext } from './bindings';
4
+
5
+ /**
6
+ * Evaluate a condition against the current context.
7
+ *
8
+ * Returns true → node should render
9
+ * Returns false → node should be skipped
10
+ *
11
+ * When no condition is provided, always returns true.
12
+ */
13
+ export function evaluateCondition(
14
+ condition: Condition | undefined,
15
+ context: PushframeContext,
16
+ ): boolean {
17
+ if (!condition) return true;
18
+
19
+ const resolved = resolveValue(condition.if, context);
20
+ const operator = condition.operator ?? (condition.equals !== undefined ? 'equals' : 'truthy');
21
+
22
+ switch (operator) {
23
+ case 'truthy':
24
+ return Boolean(resolved);
25
+
26
+ case 'falsy':
27
+ return !resolved;
28
+
29
+ case 'equals': {
30
+ const rhs = resolveValue(condition.equals ?? null, context);
31
+ return resolved === rhs;
32
+ }
33
+
34
+ case 'notEquals': {
35
+ const rhs = resolveValue(condition.equals ?? null, context);
36
+ return resolved !== rhs;
37
+ }
38
+
39
+ default: {
40
+ // Exhaustive check — TypeScript will catch new operators at compile time.
41
+ const _exhaustive: never = operator;
42
+ console.warn('[Pushframe] Unknown condition operator:', _exhaustive);
43
+ return true;
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,89 @@
1
+ import { createContext, useContext } from 'react';
2
+ import type React from 'react';
3
+ import type { ComponentRegistry } from '../registry/ComponentRegistry';
4
+
5
+ // ---------------------------------------------------------------------------
6
+ // Schema types
7
+ // ---------------------------------------------------------------------------
8
+
9
+ export interface SchemaNode {
10
+ id?: string;
11
+ type: string;
12
+ props?: Record<string, unknown>;
13
+ children?: SchemaNode[];
14
+ /** Per-item render template for flatlist nodes. */
15
+ itemTemplate?: SchemaNode;
16
+ actions?: Action[];
17
+ /**
18
+ * Conditional render expression. String values are resolved against the
19
+ * context via {{}} binding syntax. Non-string values (boolean, number, null)
20
+ * are coerced directly. Falsy → node is hidden.
21
+ */
22
+ if?: unknown;
23
+ }
24
+
25
+ export interface FlatListSchemaNode extends SchemaNode {
26
+ type: 'flatlist';
27
+ itemTemplate: SchemaNode;
28
+ }
29
+
30
+ export interface Action {
31
+ trigger: string;
32
+ action: string;
33
+ payload?: Record<string, unknown>;
34
+ }
35
+
36
+ // ---------------------------------------------------------------------------
37
+ // Overlay payload types
38
+ // ---------------------------------------------------------------------------
39
+
40
+ export interface ToastPayload {
41
+ message: string;
42
+ duration?: number;
43
+ type?: 'success' | 'error' | 'info' | 'warning';
44
+ }
45
+
46
+ export interface BottomSheetPayload {
47
+ schema: SchemaNode;
48
+ context?: Record<string, unknown>;
49
+ }
50
+
51
+ export interface ScrollToPayload {
52
+ x?: number;
53
+ y?: number;
54
+ animated?: boolean;
55
+ }
56
+
57
+ // ---------------------------------------------------------------------------
58
+ // Context value
59
+ // ---------------------------------------------------------------------------
60
+
61
+ export interface PushFrameContextValue {
62
+ apiKey: string;
63
+ baseUrl: string;
64
+ appVersion?: string;
65
+ globalContext: Record<string, unknown>;
66
+ registry: ComponentRegistry;
67
+ loadingComponent?: React.ReactNode;
68
+ fallbackComponent?: React.ReactNode;
69
+ onAction?: (action: string, payload?: Record<string, unknown>) => void;
70
+ onError?: (error: Error) => void;
71
+ // Overlay imperatives
72
+ showToast: (payload: ToastPayload) => void;
73
+ showBottomSheet: (payload: BottomSheetPayload) => void;
74
+ dismissBottomSheet: () => void;
75
+ }
76
+
77
+ // ---------------------------------------------------------------------------
78
+ // Context and hook
79
+ // ---------------------------------------------------------------------------
80
+
81
+ export const PushFrameContext = createContext<PushFrameContextValue | null>(null);
82
+
83
+ export function usePushFrameContext(): PushFrameContextValue {
84
+ const ctx = useContext(PushFrameContext);
85
+ if (!ctx) {
86
+ throw new Error('[PushFrame] usePushFrameContext must be called inside <PushFrame.Provider>');
87
+ }
88
+ return ctx;
89
+ }
package/src/index.ts ADDED
@@ -0,0 +1,119 @@
1
+ /**
2
+ * @pushframe/sdk — Server-Driven UI for React Native
3
+ *
4
+ * Usage:
5
+ * import { PushFrame } from '@pushframe/sdk';
6
+ *
7
+ * <PushFrame.Provider apiKey="..." context={...}>
8
+ * <PushFrame.Screen name="home" />
9
+ * <PushFrame.Component name="promo-banner" />
10
+ * </PushFrame.Provider>
11
+ */
12
+
13
+ // ---------------------------------------------------------------------------
14
+ // Component imports (for namespace assembly)
15
+ // ---------------------------------------------------------------------------
16
+
17
+ import { PushFrameProvider } from './components/PushFrameProvider';
18
+ import { PushFrameScreen } from './components/PushFrameScreen';
19
+ import { PushFrameComponent } from './components/PushFrameComponent';
20
+ import { Text } from './primitives/Text';
21
+ import { View } from './primitives/View';
22
+ import { ScrollView } from './primitives/ScrollView';
23
+ import { Image } from './primitives/Image';
24
+ import { Pressable } from './primitives/Pressable';
25
+ import { TextInput } from './primitives/TextInput';
26
+ import { FlatList } from './primitives/FlatList';
27
+ import { Modal } from './primitives/Modal';
28
+ import { ActivityIndicator } from './primitives/ActivityIndicator';
29
+ import { Switch } from './primitives/Switch';
30
+ import { KeyboardAvoidingView } from './primitives/KeyboardAvoidingView';
31
+ import { SafeAreaView } from './primitives/SafeAreaView';
32
+ import { StatusBar } from './primitives/StatusBar';
33
+
34
+ // ---------------------------------------------------------------------------
35
+ // PushFrame namespace — the primary API surface
36
+ // ---------------------------------------------------------------------------
37
+
38
+ /**
39
+ * The PushFrame namespace. Import this as the single entry-point for the SDK.
40
+ *
41
+ * Slot components:
42
+ * - PushFrame.Provider — wraps the app, initialises registry and context
43
+ * - PushFrame.Screen — full-page slot (fetches /screens/:name, applies flex:1)
44
+ * - PushFrame.Component — inline slot (fetches /components/:name)
45
+ *
46
+ * Primitives (used internally by RecursiveRenderer, available for direct use):
47
+ * - PushFrame.Text, PushFrame.View, PushFrame.ScrollView, PushFrame.Image
48
+ * - PushFrame.Pressable, PushFrame.TextInput, PushFrame.FlatList
49
+ * - PushFrame.Modal, PushFrame.ActivityIndicator, PushFrame.Switch
50
+ * - PushFrame.KeyboardAvoidingView, PushFrame.SafeAreaView, PushFrame.StatusBar
51
+ */
52
+ export const PushFrame = {
53
+ // Slot components
54
+ Provider: PushFrameProvider,
55
+ Screen: PushFrameScreen,
56
+ Component: PushFrameComponent,
57
+
58
+ // Primitives
59
+ Text,
60
+ View,
61
+ ScrollView,
62
+ Image,
63
+ Pressable,
64
+ TextInput,
65
+ FlatList,
66
+ Modal,
67
+ ActivityIndicator,
68
+ Switch,
69
+ KeyboardAvoidingView,
70
+ SafeAreaView,
71
+ StatusBar,
72
+ } as const;
73
+
74
+ // ---------------------------------------------------------------------------
75
+ // Named exports (for tree-shaking and selective imports)
76
+ // ---------------------------------------------------------------------------
77
+
78
+ // Slot components
79
+ export { PushFrameProvider } from './components/PushFrameProvider';
80
+ export type { PushFrameProviderProps } from './components/PushFrameProvider';
81
+ export { PushFrameScreen } from './components/PushFrameScreen';
82
+ export { PushFrameComponent } from './components/PushFrameComponent';
83
+ export type { PushFrameSlotProps } from './components/PushFrameComponent';
84
+
85
+ // Context
86
+ export { PushFrameContext, usePushFrameContext } from './context/PushFrameContext';
87
+ export type {
88
+ PushFrameContextValue,
89
+ SchemaNode,
90
+ FlatListSchemaNode,
91
+ Action,
92
+ ToastPayload,
93
+ BottomSheetPayload,
94
+ ScrollToPayload,
95
+ } from './context/PushFrameContext';
96
+
97
+ // Registry
98
+ export { ComponentRegistry } from './registry/ComponentRegistry';
99
+
100
+ // Renderer
101
+ export { RecursiveRenderer } from './renderer/RecursiveRenderer';
102
+ export type { RecursiveRendererProps, DispatchAction } from './renderer/RecursiveRenderer';
103
+
104
+ // Binding utilities
105
+ export { resolveValue, resolveProps, resolveDeep } from './renderer/bindingResolver';
106
+ export { evaluateIf } from './renderer/conditionalEvaluator';
107
+
108
+ // Primitives
109
+ export * from './primitives/index';
110
+
111
+ // Transformer (Craft.js → SDUI; intended for backend / dashboard use)
112
+ export { transformCraftToSDUI } from './transformer/index';
113
+ export type {
114
+ CraftNode,
115
+ CraftSchema,
116
+ SDUINode,
117
+ CustomComponentDef,
118
+ CustomComponentsMap,
119
+ } from './transformer/index';
@@ -0,0 +1,175 @@
1
+ import React, {
2
+ forwardRef,
3
+ useImperativeHandle,
4
+ useState,
5
+ useRef,
6
+ useCallback,
7
+ useEffect,
8
+ } from 'react';
9
+ import {
10
+ View,
11
+ Modal,
12
+ Pressable,
13
+ StyleSheet,
14
+ Animated,
15
+ Dimensions,
16
+ } from 'react-native';
17
+ import type { BottomSheetPayload } from '../context/PushFrameContext';
18
+ import type { SchemaNode } from '../context/PushFrameContext';
19
+
20
+ // ---------------------------------------------------------------------------
21
+ // Imperative handle
22
+ // ---------------------------------------------------------------------------
23
+
24
+ export interface BottomSheetHostHandle {
25
+ show(payload: BottomSheetPayload): void;
26
+ dismiss(): void;
27
+ }
28
+
29
+ // ---------------------------------------------------------------------------
30
+ // Props from Provider (renderer callback)
31
+ // ---------------------------------------------------------------------------
32
+
33
+ export interface BottomSheetHostProps {
34
+ /**
35
+ * Callback to render a SchemaNode inside the bottom sheet.
36
+ * Provided by the Provider which has access to registry and context.
37
+ */
38
+ renderContent: (
39
+ schema: SchemaNode,
40
+ context?: Record<string, unknown>,
41
+ ) => React.ReactElement | null;
42
+ }
43
+
44
+ // ---------------------------------------------------------------------------
45
+ // BottomSheetHost
46
+ // ---------------------------------------------------------------------------
47
+
48
+ const SCREEN_HEIGHT = Dimensions.get('window').height;
49
+
50
+ /**
51
+ * Rendered by PushFrameProvider at the root level.
52
+ * Exposes imperative `show()` and `dismiss()` handles.
53
+ * Zero third-party dependencies — built with Animated + Modal.
54
+ */
55
+ export const BottomSheetHost = forwardRef<BottomSheetHostHandle, BottomSheetHostProps>(
56
+ function BottomSheetHost({ renderContent }, ref) {
57
+ const [visible, setVisible] = useState(false);
58
+ const [payload, setPayload] = useState<BottomSheetPayload | null>(null);
59
+ const translateY = useRef(new Animated.Value(SCREEN_HEIGHT)).current;
60
+
61
+ const animateIn = useCallback(() => {
62
+ Animated.spring(translateY, {
63
+ toValue: 0,
64
+ useNativeDriver: true,
65
+ bounciness: 4,
66
+ }).start();
67
+ }, [translateY]);
68
+
69
+ const animateOut = useCallback(
70
+ (onDone?: () => void) => {
71
+ Animated.timing(translateY, {
72
+ toValue: SCREEN_HEIGHT,
73
+ duration: 250,
74
+ useNativeDriver: true,
75
+ }).start(() => {
76
+ onDone?.();
77
+ });
78
+ },
79
+ [translateY],
80
+ );
81
+
82
+ useEffect(() => {
83
+ if (visible) {
84
+ translateY.setValue(SCREEN_HEIGHT);
85
+ animateIn();
86
+ }
87
+ }, [visible, translateY, animateIn]);
88
+
89
+ const dismiss = useCallback(() => {
90
+ animateOut(() => {
91
+ setVisible(false);
92
+ setPayload(null);
93
+ });
94
+ }, [animateOut]);
95
+
96
+ useImperativeHandle(
97
+ ref,
98
+ () => ({
99
+ show(p: BottomSheetPayload) {
100
+ setPayload(p);
101
+ setVisible(true);
102
+ },
103
+ dismiss() {
104
+ dismiss();
105
+ },
106
+ }),
107
+ [dismiss],
108
+ );
109
+
110
+ if (!visible || !payload) return null;
111
+
112
+ return (
113
+ <Modal
114
+ visible={visible}
115
+ transparent
116
+ animationType="none"
117
+ onRequestClose={dismiss}
118
+ statusBarTranslucent
119
+ >
120
+ {/* Backdrop */}
121
+ <Pressable style={styles.backdrop} onPress={dismiss} />
122
+
123
+ {/* Sheet */}
124
+ <Animated.View style={[styles.sheet, { transform: [{ translateY }] }]}>
125
+ <View style={styles.handle} />
126
+ <View style={styles.content}>
127
+ {renderContent(payload.schema, payload.context)}
128
+ </View>
129
+ </Animated.View>
130
+ </Modal>
131
+ );
132
+ },
133
+ );
134
+
135
+ // ---------------------------------------------------------------------------
136
+ // Styles
137
+ // ---------------------------------------------------------------------------
138
+
139
+ const styles = StyleSheet.create({
140
+ backdrop: {
141
+ ...StyleSheet.absoluteFillObject,
142
+ backgroundColor: 'rgba(0,0,0,0.5)',
143
+ },
144
+ sheet: {
145
+ position: 'absolute',
146
+ bottom: 0,
147
+ left: 0,
148
+ right: 0,
149
+ backgroundColor: '#fff',
150
+ borderTopLeftRadius: 16,
151
+ borderTopRightRadius: 16,
152
+ paddingBottom: 34, // safe-area approximation
153
+ minHeight: 200,
154
+ maxHeight: '80%',
155
+ shadowColor: '#000',
156
+ shadowOffset: { width: 0, height: -4 },
157
+ shadowOpacity: 0.15,
158
+ shadowRadius: 12,
159
+ elevation: 20,
160
+ },
161
+ handle: {
162
+ alignSelf: 'center',
163
+ width: 36,
164
+ height: 4,
165
+ borderRadius: 2,
166
+ backgroundColor: '#d1d5db',
167
+ marginTop: 12,
168
+ marginBottom: 8,
169
+ },
170
+ content: {
171
+ flex: 1,
172
+ paddingHorizontal: 16,
173
+ paddingTop: 8,
174
+ },
175
+ });