@pushframe/sdk 0.1.4 → 0.1.8

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
package/dist/index.js DELETED
@@ -1,1572 +0,0 @@
1
- 'use strict';
2
-
3
- var React4 = require('react');
4
- var reactNative = require('react-native');
5
- var jsxRuntime = require('react/jsx-runtime');
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
-
9
- var React4__default = /*#__PURE__*/_interopDefault(React4);
10
-
11
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
12
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
13
- }) : x)(function(x) {
14
- if (typeof require !== "undefined") return require.apply(this, arguments);
15
- throw Error('Dynamic require of "' + x + '" is not supported');
16
- });
17
- var PushFrameContext = React4.createContext(null);
18
- function usePushFrameContext() {
19
- const ctx = React4.useContext(PushFrameContext);
20
- if (!ctx) {
21
- throw new Error("[PushFrame] usePushFrameContext must be called inside <PushFrame.Provider>");
22
- }
23
- return ctx;
24
- }
25
- function Text({
26
- if: _if,
27
- actions: _actions,
28
- value,
29
- content,
30
- ...rest
31
- }) {
32
- const textContent = value !== void 0 ? value : content;
33
- if (textContent !== void 0) {
34
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { ...rest, children: textContent });
35
- }
36
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { ...rest });
37
- }
38
- function View({ if: _if, actions: _actions, ...rest }) {
39
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { ...rest });
40
- }
41
- var ScrollView = React4.forwardRef(function ScrollView2({ if: _if, actions: _actions, ...rest }, ref) {
42
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { ref, ...rest });
43
- });
44
- function Image({ if: _if, actions: _actions, src, source, ...rest }) {
45
- const resolvedSource = src ? { uri: src } : source != null ? source : { uri: "" };
46
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Image, { source: resolvedSource, ...rest });
47
- }
48
- function Pressable({ if: _if, actions: _actions, ...rest }) {
49
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { ...rest });
50
- }
51
- function TextInput({
52
- if: _if,
53
- actions: _actions,
54
- onChange,
55
- onSubmit,
56
- ...rest
57
- }) {
58
- return /* @__PURE__ */ jsxRuntime.jsx(
59
- reactNative.TextInput,
60
- {
61
- onChangeText: onChange,
62
- onSubmitEditing: onSubmit ? () => onSubmit() : void 0,
63
- ...rest
64
- }
65
- );
66
- }
67
- function FlatList({
68
- if: _if,
69
- actions: _actions,
70
- items,
71
- direction,
72
- numColumns,
73
- ...rest
74
- }) {
75
- return /* @__PURE__ */ jsxRuntime.jsx(
76
- reactNative.FlatList,
77
- {
78
- data: items,
79
- horizontal: direction === "horizontal",
80
- numColumns,
81
- ...rest
82
- }
83
- );
84
- }
85
- function Modal({ if: _if, actions: _actions, ...rest }) {
86
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { ...rest });
87
- }
88
- function ActivityIndicator({
89
- if: _if,
90
- actions: _actions,
91
- ...rest
92
- }) {
93
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.ActivityIndicator, { ...rest });
94
- }
95
- function Switch({ if: _if, actions: _actions, onChange, ...rest }) {
96
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Switch, { onValueChange: onChange, ...rest });
97
- }
98
- function KeyboardAvoidingView({
99
- if: _if,
100
- actions: _actions,
101
- ...rest
102
- }) {
103
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.KeyboardAvoidingView, { ...rest });
104
- }
105
- var NativeSafeAreaView;
106
- try {
107
- NativeSafeAreaView = __require("react-native-safe-area-context").SafeAreaView;
108
- } catch {
109
- NativeSafeAreaView = __require("react-native").SafeAreaView;
110
- }
111
- function SafeAreaView({ if: _if, actions: _actions, ...rest }) {
112
- return /* @__PURE__ */ jsxRuntime.jsx(NativeSafeAreaView, { ...rest });
113
- }
114
- function StatusBar({ if: _if, actions: _actions, ...rest }) {
115
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.StatusBar, { ...rest });
116
- }
117
-
118
- // src/registry/ComponentRegistry.ts
119
- var BUILT_IN_TYPES = /* @__PURE__ */ new Set([
120
- "text",
121
- "view",
122
- "scrollview",
123
- "image",
124
- "pressable",
125
- "textinput",
126
- "flatlist",
127
- "modal",
128
- "activityindicator",
129
- "switch",
130
- "keyboardavoidingview",
131
- "safeareaview",
132
- "statusbar"
133
- ]);
134
- var BUILT_IN_COMPONENTS = /* @__PURE__ */ new Map([
135
- ["text", Text],
136
- ["view", View],
137
- ["scrollview", ScrollView],
138
- ["image", Image],
139
- ["pressable", Pressable],
140
- ["textinput", TextInput],
141
- ["flatlist", FlatList],
142
- ["modal", Modal],
143
- ["activityindicator", ActivityIndicator],
144
- ["switch", Switch],
145
- ["keyboardavoidingview", KeyboardAvoidingView],
146
- ["safeareaview", SafeAreaView],
147
- ["statusbar", StatusBar]
148
- ]);
149
- var ComponentRegistry = class {
150
- constructor(developerComponents) {
151
- this.components = new Map(BUILT_IN_COMPONENTS);
152
- if (developerComponents) {
153
- for (const [type, component] of Object.entries(developerComponents)) {
154
- if (BUILT_IN_TYPES.has(type)) {
155
- console.warn(
156
- `[PushFrame] ComponentRegistry: "${type}" is a built-in type and cannot be overridden. Registration skipped.`
157
- );
158
- continue;
159
- }
160
- this.components.set(type, component);
161
- }
162
- }
163
- }
164
- /**
165
- * Resolve a type string to its React component.
166
- * Returns null if no component is registered for the type.
167
- */
168
- resolve(type) {
169
- var _a;
170
- return (_a = this.components.get(type)) != null ? _a : null;
171
- }
172
- /**
173
- * Returns all registered type strings (useful for debugging).
174
- */
175
- types() {
176
- return Array.from(this.components.keys());
177
- }
178
- };
179
- var TYPE_COLORS = {
180
- success: "#22c55e",
181
- error: "#ef4444",
182
- info: "#3b82f6",
183
- warning: "#f59e0b"
184
- };
185
- var ToastHost = React4.forwardRef(function ToastHost2(_props, ref) {
186
- var _a, _b;
187
- const [toast, setToast] = React4.useState(null);
188
- const opacity = React4.useRef(new reactNative.Animated.Value(0)).current;
189
- const idRef = React4.useRef(0);
190
- const hide = React4.useCallback(() => {
191
- reactNative.Animated.timing(opacity, {
192
- toValue: 0,
193
- duration: 200,
194
- useNativeDriver: true
195
- }).start(() => {
196
- setToast(null);
197
- });
198
- }, [opacity]);
199
- React4.useEffect(() => {
200
- if (!toast) return;
201
- reactNative.Animated.timing(opacity, {
202
- toValue: 1,
203
- duration: 200,
204
- useNativeDriver: true
205
- }).start();
206
- const timer = setTimeout(() => {
207
- hide();
208
- }, toast.duration);
209
- return () => {
210
- clearTimeout(timer);
211
- };
212
- }, [toast, opacity, hide]);
213
- React4.useImperativeHandle(
214
- ref,
215
- () => ({
216
- show(payload) {
217
- var _a2, _b2;
218
- idRef.current += 1;
219
- setToast({
220
- id: idRef.current,
221
- message: payload.message,
222
- duration: (_a2 = payload.duration) != null ? _a2 : 3e3,
223
- type: (_b2 = payload.type) != null ? _b2 : "info"
224
- });
225
- opacity.setValue(0);
226
- }
227
- }),
228
- [opacity]
229
- );
230
- if (!toast) return null;
231
- const backgroundColor = (_b = TYPE_COLORS[(_a = toast.type) != null ? _a : "info"]) != null ? _b : TYPE_COLORS.info;
232
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles.container, pointerEvents: "none", children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles.toast, { backgroundColor, opacity }], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles.message, children: toast.message }) }) });
233
- });
234
- var styles = reactNative.StyleSheet.create({
235
- container: {
236
- position: "absolute",
237
- bottom: 60,
238
- left: 16,
239
- right: 16,
240
- alignItems: "center",
241
- zIndex: 9999
242
- },
243
- toast: {
244
- paddingVertical: 12,
245
- paddingHorizontal: 20,
246
- borderRadius: 8,
247
- maxWidth: 400,
248
- shadowColor: "#000",
249
- shadowOffset: { width: 0, height: 2 },
250
- shadowOpacity: 0.2,
251
- shadowRadius: 4,
252
- elevation: 6
253
- },
254
- message: {
255
- color: "#fff",
256
- fontSize: 14,
257
- fontWeight: "500",
258
- textAlign: "center"
259
- }
260
- });
261
- var SCREEN_HEIGHT = reactNative.Dimensions.get("window").height;
262
- var BottomSheetHost = React4.forwardRef(
263
- function BottomSheetHost2({ renderContent }, ref) {
264
- const [visible, setVisible] = React4.useState(false);
265
- const [payload, setPayload] = React4.useState(null);
266
- const translateY = React4.useRef(new reactNative.Animated.Value(SCREEN_HEIGHT)).current;
267
- const animateIn = React4.useCallback(() => {
268
- reactNative.Animated.spring(translateY, {
269
- toValue: 0,
270
- useNativeDriver: true,
271
- bounciness: 4
272
- }).start();
273
- }, [translateY]);
274
- const animateOut = React4.useCallback(
275
- (onDone) => {
276
- reactNative.Animated.timing(translateY, {
277
- toValue: SCREEN_HEIGHT,
278
- duration: 250,
279
- useNativeDriver: true
280
- }).start(() => {
281
- onDone == null ? void 0 : onDone();
282
- });
283
- },
284
- [translateY]
285
- );
286
- React4.useEffect(() => {
287
- if (visible) {
288
- translateY.setValue(SCREEN_HEIGHT);
289
- animateIn();
290
- }
291
- }, [visible, translateY, animateIn]);
292
- const dismiss = React4.useCallback(() => {
293
- animateOut(() => {
294
- setVisible(false);
295
- setPayload(null);
296
- });
297
- }, [animateOut]);
298
- React4.useImperativeHandle(
299
- ref,
300
- () => ({
301
- show(p) {
302
- setPayload(p);
303
- setVisible(true);
304
- },
305
- dismiss() {
306
- dismiss();
307
- }
308
- }),
309
- [dismiss]
310
- );
311
- if (!visible || !payload) return null;
312
- return /* @__PURE__ */ jsxRuntime.jsxs(
313
- reactNative.Modal,
314
- {
315
- visible,
316
- transparent: true,
317
- animationType: "none",
318
- onRequestClose: dismiss,
319
- statusBarTranslucent: true,
320
- children: [
321
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { style: styles2.backdrop, onPress: dismiss }),
322
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Animated.View, { style: [styles2.sheet, { transform: [{ translateY }] }], children: [
323
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.handle }),
324
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.content, children: renderContent(payload.schema, payload.context) })
325
- ] })
326
- ]
327
- }
328
- );
329
- }
330
- );
331
- var styles2 = reactNative.StyleSheet.create({
332
- backdrop: {
333
- ...reactNative.StyleSheet.absoluteFillObject,
334
- backgroundColor: "rgba(0,0,0,0.5)"
335
- },
336
- sheet: {
337
- position: "absolute",
338
- bottom: 0,
339
- left: 0,
340
- right: 0,
341
- backgroundColor: "#fff",
342
- borderTopLeftRadius: 16,
343
- borderTopRightRadius: 16,
344
- paddingBottom: 34,
345
- // safe-area approximation
346
- minHeight: 200,
347
- maxHeight: "80%",
348
- shadowColor: "#000",
349
- shadowOffset: { width: 0, height: -4 },
350
- shadowOpacity: 0.15,
351
- shadowRadius: 12,
352
- elevation: 20
353
- },
354
- handle: {
355
- alignSelf: "center",
356
- width: 36,
357
- height: 4,
358
- borderRadius: 2,
359
- backgroundColor: "#d1d5db",
360
- marginTop: 12,
361
- marginBottom: 8
362
- },
363
- content: {
364
- flex: 1,
365
- paddingHorizontal: 16,
366
- paddingTop: 8
367
- }
368
- });
369
-
370
- // src/renderer/bindingResolver.ts
371
- var FULL_BINDING_RE = /^\{\{(.+)\}\}$/;
372
- var INLINE_BINDING_RE = /\{\{([^}]+)\}\}/g;
373
- function evaluateExpression(expr, context) {
374
- try {
375
- const keys = Object.keys(context);
376
- const values = keys.map((k) => context[k]);
377
- const fn = new Function(...keys, `"use strict"; try { return (${expr}); } catch(e) { return undefined; }`);
378
- return fn(...values);
379
- } catch {
380
- return void 0;
381
- }
382
- }
383
- function resolveValue(value, context) {
384
- if (typeof value !== "string") {
385
- return value;
386
- }
387
- const fullMatch = FULL_BINDING_RE.exec(value);
388
- if ((fullMatch == null ? void 0 : fullMatch[1]) !== void 0) {
389
- return evaluateExpression(fullMatch[1].trim(), context);
390
- }
391
- if (INLINE_BINDING_RE.test(value)) {
392
- INLINE_BINDING_RE.lastIndex = 0;
393
- return value.replace(INLINE_BINDING_RE, (_, expr) => {
394
- const resolved = evaluateExpression(expr.trim(), context);
395
- return resolved !== void 0 && resolved !== null ? String(resolved) : "";
396
- });
397
- }
398
- return value;
399
- }
400
- function resolveProps(props, context) {
401
- if (!props) return {};
402
- const resolved = {};
403
- for (const [key, value] of Object.entries(props)) {
404
- resolved[key] = resolveDeep(value, context);
405
- }
406
- return resolved;
407
- }
408
- function resolveDeep(value, context) {
409
- if (Array.isArray(value)) {
410
- return value.map((item) => resolveDeep(item, context));
411
- }
412
- if (typeof value === "object" && value !== null) {
413
- const result = {};
414
- for (const [k, v] of Object.entries(value)) {
415
- result[k] = resolveDeep(v, context);
416
- }
417
- return result;
418
- }
419
- return resolveValue(value, context);
420
- }
421
-
422
- // src/renderer/conditionalEvaluator.ts
423
- function evaluateIf(ifExpr, context) {
424
- if (ifExpr === void 0 || ifExpr === null) return true;
425
- if (typeof ifExpr !== "string") return Boolean(ifExpr);
426
- const resolved = resolveValue(ifExpr, context);
427
- return Boolean(resolved);
428
- }
429
- function buildActionProps(actions, context, dispatchAction) {
430
- const grouped = /* @__PURE__ */ new Map();
431
- for (const action of actions) {
432
- const existing = grouped.get(action.trigger);
433
- if (existing) {
434
- existing.push(action);
435
- } else {
436
- grouped.set(action.trigger, [action]);
437
- }
438
- }
439
- const result = {};
440
- for (const [trigger, triggerActions] of grouped) {
441
- result[trigger] = (..._args) => {
442
- for (const action of triggerActions) {
443
- const resolvedPayload = action.payload !== void 0 ? resolveDeep(action.payload, context) : void 0;
444
- dispatchAction(action.action, resolvedPayload);
445
- }
446
- };
447
- }
448
- return result;
449
- }
450
- function renderFlatListNode(node, context, registry, dispatchAction, fallbackComponent) {
451
- const resolvedProps = resolveProps(node.props, context);
452
- const actionProps = node.actions ? buildActionProps(node.actions, context, dispatchAction) : {};
453
- const {
454
- data: resolvedData,
455
- items: resolvedItems,
456
- keyExtractor: keyExtractorExpr,
457
- direction,
458
- numColumns,
459
- visible: _visible,
460
- _propValues: _pv,
461
- ...restProps
462
- } = resolvedProps;
463
- const items = Array.isArray(resolvedData) ? resolvedData : Array.isArray(resolvedItems) ? resolvedItems : [];
464
- let keyExtractorFn;
465
- if (typeof keyExtractorExpr === "string") {
466
- const extractorExpr = keyExtractorExpr;
467
- keyExtractorFn = (item, index) => {
468
- const itemContext = { ...context, item, index };
469
- const resolved = resolveValue(extractorExpr, itemContext);
470
- return resolved !== void 0 && resolved !== null ? String(resolved) : String(index);
471
- };
472
- }
473
- const renderItemFn = ({ item, index }) => {
474
- const itemContext = { ...context, item, index };
475
- return /* @__PURE__ */ jsxRuntime.jsx(
476
- RecursiveRenderer,
477
- {
478
- node: node.itemTemplate,
479
- context: itemContext,
480
- registry,
481
- dispatchAction,
482
- fallbackComponent
483
- },
484
- keyExtractorFn ? keyExtractorFn(item, index) : index
485
- );
486
- };
487
- const FlatListComponent = registry.resolve("flatlist");
488
- if (!FlatListComponent) {
489
- console.warn('[PushFrame] RecursiveRenderer: "flatlist" not found in registry.');
490
- return fallbackComponent ? fallbackComponent : null;
491
- }
492
- return React4__default.default.createElement(FlatListComponent, {
493
- ...restProps,
494
- ...actionProps,
495
- items,
496
- direction,
497
- numColumns,
498
- keyExtractor: keyExtractorFn,
499
- renderItem: renderItemFn
500
- });
501
- }
502
- function RecursiveRenderer({
503
- node,
504
- context,
505
- registry,
506
- dispatchAction,
507
- fallbackComponent
508
- }) {
509
- if (!evaluateIf(node.if, context)) {
510
- return null;
511
- }
512
- if (node.type === "flatlist") {
513
- return renderFlatListNode(
514
- node,
515
- context,
516
- registry,
517
- dispatchAction,
518
- fallbackComponent
519
- );
520
- }
521
- const resolvedProps = resolveProps(node.props, context);
522
- if (resolvedProps.visible !== void 0 && !resolvedProps.visible) {
523
- return null;
524
- }
525
- const {
526
- visible: _visible,
527
- _propValues: propValuesRaw,
528
- ...propsToForward
529
- } = resolvedProps;
530
- const propValues = propValuesRaw;
531
- const childContext = propValues && Object.keys(propValues).length > 0 ? { ...context, ...propValues } : context;
532
- const actionProps = node.actions ? buildActionProps(node.actions, context, dispatchAction) : {};
533
- const Component = registry.resolve(node.type);
534
- if (!Component) {
535
- console.warn(
536
- `[PushFrame] RecursiveRenderer: Unknown component type "${node.type}". Registered types: ${registry.types().join(", ")}`
537
- );
538
- return fallbackComponent ? fallbackComponent : null;
539
- }
540
- const children = node.children && node.children.length > 0 ? node.children.map((child, index) => /* @__PURE__ */ jsxRuntime.jsx(
541
- RecursiveRenderer,
542
- {
543
- node: child,
544
- context: childContext,
545
- registry,
546
- dispatchAction,
547
- fallbackComponent
548
- },
549
- `${child.type}-${index}`
550
- )) : void 0;
551
- return React4__default.default.createElement(Component, {
552
- ...propsToForward,
553
- ...actionProps,
554
- children
555
- });
556
- }
557
- var DEFAULT_BASE_URL = "https://api.pushframe.io";
558
- function PushFrameProvider({
559
- apiKey,
560
- context = {},
561
- baseUrl = DEFAULT_BASE_URL,
562
- appVersion,
563
- components,
564
- loadingComponent,
565
- fallbackComponent,
566
- onAction,
567
- onError,
568
- children
569
- }) {
570
- const registry = React4.useMemo(
571
- () => new ComponentRegistry(components),
572
- // eslint-disable-next-line react-hooks/exhaustive-deps
573
- []
574
- );
575
- const toastRef = React4.useRef(null);
576
- const bottomSheetRef = React4.useRef(null);
577
- const showToast = React4.useCallback((payload) => {
578
- var _a;
579
- (_a = toastRef.current) == null ? void 0 : _a.show(payload);
580
- }, []);
581
- const showBottomSheet = React4.useCallback((payload) => {
582
- var _a;
583
- (_a = bottomSheetRef.current) == null ? void 0 : _a.show(payload);
584
- }, []);
585
- const dismissBottomSheet = React4.useCallback(() => {
586
- var _a;
587
- (_a = bottomSheetRef.current) == null ? void 0 : _a.dismiss();
588
- }, []);
589
- const renderBottomSheetContent = React4.useCallback(
590
- (schema, sheetContext) => {
591
- const mergedContext = sheetContext ? { ...context, ...sheetContext } : context;
592
- const dispatchAction = (action, payload) => {
593
- if (action === "dismiss-bottom-sheet") {
594
- dismissBottomSheet();
595
- return;
596
- }
597
- if (action === "show-toast") {
598
- showToast(payload);
599
- return;
600
- }
601
- onAction == null ? void 0 : onAction(action, payload);
602
- };
603
- return /* @__PURE__ */ jsxRuntime.jsx(
604
- RecursiveRenderer,
605
- {
606
- node: schema,
607
- context: mergedContext,
608
- registry,
609
- dispatchAction,
610
- fallbackComponent
611
- }
612
- );
613
- },
614
- [context, registry, fallbackComponent, onAction, dismissBottomSheet, showToast]
615
- );
616
- const contextValue = React4.useMemo(
617
- () => ({
618
- apiKey,
619
- baseUrl,
620
- appVersion,
621
- globalContext: context,
622
- registry,
623
- loadingComponent,
624
- fallbackComponent,
625
- onAction,
626
- onError,
627
- showToast,
628
- showBottomSheet,
629
- dismissBottomSheet
630
- }),
631
- [
632
- apiKey,
633
- baseUrl,
634
- appVersion,
635
- context,
636
- registry,
637
- loadingComponent,
638
- fallbackComponent,
639
- onAction,
640
- onError,
641
- showToast,
642
- showBottomSheet,
643
- dismissBottomSheet
644
- ]
645
- );
646
- return /* @__PURE__ */ jsxRuntime.jsxs(PushFrameContext.Provider, { value: contextValue, children: [
647
- children,
648
- /* @__PURE__ */ jsxRuntime.jsx(ToastHost, { ref: toastRef }),
649
- /* @__PURE__ */ jsxRuntime.jsx(BottomSheetHost, { ref: bottomSheetRef, renderContent: renderBottomSheetContent })
650
- ] });
651
- }
652
- async function fetchSchema(baseUrl, apiKey, path) {
653
- var _a;
654
- const url = new URL(path, baseUrl + "/").toString();
655
- const headers = {
656
- Accept: "application/json",
657
- Authorization: `Bearer ${apiKey}`,
658
- "x-project-key": apiKey
659
- };
660
- const res = await fetch(url, { headers });
661
- if (!res.ok) {
662
- throw new Error(`[PushFrame] HTTP ${res.status} fetching "${path}"`);
663
- }
664
- const envelope = await res.json();
665
- return (_a = envelope.schema) != null ? _a : envelope;
666
- }
667
- function PushFrameComponentInternal({
668
- id,
669
- resourceType,
670
- context: slotContext,
671
- isLoading: externalLoading,
672
- loadingComponent: slotLoading,
673
- fallbackComponent: slotFallback,
674
- onAction: slotOnAction,
675
- fullscreen
676
- }) {
677
- const {
678
- apiKey,
679
- baseUrl,
680
- appVersion,
681
- globalContext,
682
- registry,
683
- loadingComponent: providerLoading,
684
- fallbackComponent: providerFallback,
685
- onAction: providerOnAction,
686
- onError,
687
- showToast,
688
- showBottomSheet,
689
- dismissBottomSheet
690
- } = usePushFrameContext();
691
- const [schema, setSchema] = React4.useState(null);
692
- const [fetchError, setFetchError] = React4.useState(null);
693
- const [isFetching, setIsFetching] = React4.useState(true);
694
- const fetchPath = `${resourceType}/${encodeURIComponent(id)}/${encodeURIComponent(appVersion != null ? appVersion : "null")}`;
695
- const mergedContext = slotContext ? { ...globalContext, ...slotContext } : globalContext;
696
- const loadingUI = slotLoading !== void 0 ? slotLoading : providerLoading;
697
- const fallbackUI = slotFallback !== void 0 ? slotFallback : providerFallback;
698
- React4.useEffect(() => {
699
- let cancelled = false;
700
- setSchema(null);
701
- setFetchError(null);
702
- setIsFetching(true);
703
- fetchSchema(baseUrl, apiKey, fetchPath).then((s) => {
704
- if (!cancelled) {
705
- setSchema(s);
706
- setIsFetching(false);
707
- }
708
- }).catch((err) => {
709
- if (!cancelled) {
710
- const error = err instanceof Error ? err : new Error(String(err));
711
- setFetchError(error);
712
- setIsFetching(false);
713
- onError == null ? void 0 : onError(error);
714
- }
715
- });
716
- return () => {
717
- cancelled = true;
718
- };
719
- }, [fetchPath, baseUrl, apiKey, onError]);
720
- const dispatchAction = React4.useCallback(
721
- (action, payload) => {
722
- if (action === "show-toast") {
723
- showToast(payload);
724
- return;
725
- }
726
- if (action === "show-bottom-sheet") {
727
- showBottomSheet(payload);
728
- return;
729
- }
730
- if (action === "dismiss-bottom-sheet") {
731
- dismissBottomSheet();
732
- return;
733
- }
734
- if (action === "scroll-to") {
735
- return;
736
- }
737
- const stopped = slotOnAction == null ? void 0 : slotOnAction(action, payload);
738
- if (stopped) return;
739
- providerOnAction == null ? void 0 : providerOnAction(action, payload);
740
- },
741
- [showToast, showBottomSheet, dismissBottomSheet, slotOnAction, providerOnAction]
742
- );
743
- const isShowingLoader = externalLoading || isFetching;
744
- if (isShowingLoader) {
745
- return loadingUI != null ? loadingUI : null;
746
- }
747
- if (fetchError || !schema) {
748
- return fallbackUI != null ? fallbackUI : null;
749
- }
750
- const rendered = /* @__PURE__ */ jsxRuntime.jsx(
751
- RecursiveRenderer,
752
- {
753
- node: schema,
754
- context: mergedContext,
755
- registry,
756
- dispatchAction,
757
- fallbackComponent: fallbackUI
758
- }
759
- );
760
- if (fullscreen) {
761
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: rendered });
762
- }
763
- return rendered;
764
- }
765
- function PushFrameComponent(props) {
766
- return /* @__PURE__ */ jsxRuntime.jsx(PushFrameComponentInternal, { ...props, resourceType: "components" });
767
- }
768
- function PushFrameScreen(props) {
769
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles3.container, children: /* @__PURE__ */ jsxRuntime.jsx(PushFrameComponentInternal, { ...props, resourceType: "screens", fullscreen: true }) });
770
- }
771
- var styles3 = reactNative.StyleSheet.create({
772
- container: {
773
- flex: 1
774
- }
775
- });
776
-
777
- // src/transformer/index.ts
778
- var BRIDGE_KEYS = /* @__PURE__ */ new Set([
779
- "_schemaId",
780
- "_schemaType",
781
- "_schemaActions",
782
- "_schemaIf",
783
- "_schemaRenderItem"
784
- ]);
785
- var ALIGN_MAP = {
786
- start: "flex-start",
787
- center: "center",
788
- end: "flex-end",
789
- stretch: "stretch",
790
- baseline: "baseline"
791
- };
792
- var DISTRIBUTE_MAP = {
793
- start: "flex-start",
794
- center: "center",
795
- end: "flex-end",
796
- "space-between": "space-between",
797
- "space-around": "space-around",
798
- "space-evenly": "space-evenly"
799
- };
800
- var FIT_TO_RESIZE_MODE = {
801
- cover: "cover",
802
- contain: "contain",
803
- fill: "stretch",
804
- // RN uses 'stretch', not 'fill'
805
- center: "center"
806
- };
807
- var FONT_WEIGHT_MAP = {
808
- regular: "400",
809
- medium: "500",
810
- semibold: "600",
811
- bold: "700"
812
- };
813
- var TEXT_STYLE_PRESETS = {
814
- "heading-1": { fontSize: 28, fontWeight: "700" },
815
- "heading-2": { fontSize: 22, fontWeight: "700" },
816
- "heading-3": { fontSize: 18, fontWeight: "600" },
817
- "body": { fontSize: 16, fontWeight: "400" },
818
- "body-sm": { fontSize: 14, fontWeight: "400" },
819
- "caption": { fontSize: 12, fontWeight: "400" },
820
- "label": { fontSize: 13, fontWeight: "500" },
821
- "overline": { fontSize: 11, fontWeight: "500", textTransform: "uppercase", letterSpacing: 0.8 }
822
- };
823
- var INPUT_TYPE_MAP = {
824
- text: { keyboardType: "default", secureTextEntry: false, autoCapitalize: "sentences", autoCorrect: true },
825
- email: { keyboardType: "email-address", secureTextEntry: false, autoCapitalize: "none", autoCorrect: false },
826
- password: { keyboardType: "default", secureTextEntry: true, autoCapitalize: "none", autoCorrect: false },
827
- number: { keyboardType: "numeric", secureTextEntry: false, autoCapitalize: "none", autoCorrect: false },
828
- decimal: { keyboardType: "decimal-pad", secureTextEntry: false, autoCapitalize: "none", autoCorrect: false },
829
- phone: { keyboardType: "phone-pad", secureTextEntry: false, autoCapitalize: "none", autoCorrect: false },
830
- url: { keyboardType: "url", secureTextEntry: false, autoCapitalize: "none", autoCorrect: false },
831
- search: { keyboardType: "default", secureTextEntry: false, autoCapitalize: "none", autoCorrect: false }
832
- };
833
- function stripBridgeKeys(props) {
834
- const out = {};
835
- for (const k in props) {
836
- if (!BRIDGE_KEYS.has(k)) out[k] = props[k];
837
- }
838
- return out;
839
- }
840
- function extractMeta(raw) {
841
- return {
842
- actions: raw._schemaActions,
843
- condition: raw._schemaIf
844
- };
845
- }
846
- function resolveSizeModeRN(value, axis, out, parentDirection) {
847
- if (value === void 0) return;
848
- if (value === "fill") {
849
- const isMainAxis = parentDirection === "vertical" && axis === "height" || parentDirection === "horizontal" && axis === "width";
850
- if (isMainAxis) {
851
- out.flex = 1;
852
- } else {
853
- out.alignSelf = "stretch";
854
- }
855
- } else if (value === "hug") {
856
- out.alignSelf = "flex-start";
857
- } else {
858
- out[axis] = value;
859
- }
860
- }
861
- function resolvePaddingRN(padding) {
862
- if (padding === void 0) return {};
863
- if (typeof padding === "number") return { padding };
864
- const { top, right, bottom, left } = padding;
865
- if (top === bottom && left === right && top !== void 0 && left !== void 0) {
866
- return { paddingVertical: top, paddingHorizontal: left };
867
- }
868
- return {
869
- ...top !== void 0 ? { paddingTop: top } : {},
870
- ...right !== void 0 ? { paddingRight: right } : {},
871
- ...bottom !== void 0 ? { paddingBottom: bottom } : {},
872
- ...left !== void 0 ? { paddingLeft: left } : {}
873
- };
874
- }
875
- function resolveRadiusRN(radius) {
876
- if (radius === void 0) return {};
877
- if (typeof radius === "number") return { borderRadius: radius };
878
- return {
879
- ...radius.tl !== void 0 ? { borderTopLeftRadius: radius.tl } : {},
880
- ...radius.tr !== void 0 ? { borderTopRightRadius: radius.tr } : {},
881
- ...radius.br !== void 0 ? { borderBottomRightRadius: radius.br } : {},
882
- ...radius.bl !== void 0 ? { borderBottomLeftRadius: radius.bl } : {}
883
- };
884
- }
885
- function resolveBorderRN(border) {
886
- if (!border) return {};
887
- const out = {};
888
- if (border.style) out.borderStyle = border.style;
889
- if (border.color) out.borderColor = border.color;
890
- if (border.widths) {
891
- const w = border.widths;
892
- if (w.top !== void 0) out.borderTopWidth = w.top;
893
- if (w.right !== void 0) out.borderRightWidth = w.right;
894
- if (w.bottom !== void 0) out.borderBottomWidth = w.bottom;
895
- if (w.left !== void 0) out.borderLeftWidth = w.left;
896
- } else if (border.width !== void 0) {
897
- out.borderWidth = border.width;
898
- }
899
- return out;
900
- }
901
- function resolveShadowRN(shadow) {
902
- if (!shadow) return {};
903
- return {
904
- shadowColor: shadow.color,
905
- shadowOffset: { width: shadow.offsetX, height: shadow.offsetY },
906
- shadowRadius: shadow.blur,
907
- shadowOpacity: shadow.opacity,
908
- elevation: Math.round(shadow.blur / 2)
909
- };
910
- }
911
- function resolveTransformRN(props) {
912
- const transforms = [];
913
- if (props.rotate !== void 0 && props.rotate !== 0) transforms.push({ rotate: `${props.rotate}deg` });
914
- if (props.scale !== void 0 && props.scale !== 1) transforms.push({ scale: props.scale });
915
- if (props.translateX !== void 0 && props.translateX !== 0) transforms.push({ translateX: props.translateX });
916
- if (props.translateY !== void 0 && props.translateY !== 0) transforms.push({ translateY: props.translateY });
917
- return transforms.length ? { transform: transforms } : {};
918
- }
919
- function resolvePositionRN(props) {
920
- const out = {};
921
- if (props.position) out.position = props.position;
922
- if (props.position === "absolute") {
923
- if (props.top !== void 0) out.top = props.top;
924
- if (props.right !== void 0) out.right = props.right;
925
- if (props.bottom !== void 0) out.bottom = props.bottom;
926
- if (props.left !== void 0) out.left = props.left;
927
- }
928
- if (props.zIndex !== void 0) out.zIndex = props.zIndex;
929
- return out;
930
- }
931
- function resolveAccessibilityProps(props) {
932
- const out = {};
933
- if (props.accessible !== void 0) out.accessible = props.accessible;
934
- if (props.accessibilityLabel) out.accessibilityLabel = props.accessibilityLabel;
935
- if (props.accessibilityRole) out.accessibilityRole = props.accessibilityRole;
936
- if (props.testID) out.testID = props.testID;
937
- return out;
938
- }
939
- function buildFrameStyle(props, parentDirection) {
940
- var _a, _b, _c, _d;
941
- const style = {};
942
- const frameType = (_a = props.type) != null ? _a : "stack";
943
- if (frameType === "grid") {
944
- if (props.align) style.alignItems = (_b = ALIGN_MAP[props.align]) != null ? _b : props.align;
945
- } else {
946
- style.flexDirection = props.direction === "horizontal" ? "row" : "column";
947
- if (props.align) style.alignItems = (_c = ALIGN_MAP[props.align]) != null ? _c : props.align;
948
- if (props.distribute) style.justifyContent = (_d = DISTRIBUTE_MAP[props.distribute]) != null ? _d : props.distribute;
949
- if (props.gap !== void 0 && props.gap !== 0) style.gap = props.gap;
950
- if (props.wrap === "yes") style.flexWrap = "wrap";
951
- }
952
- resolveSizeModeRN(props.width, "width", style, parentDirection);
953
- resolveSizeModeRN(props.height, "height", style, parentDirection);
954
- if (props.minWidth !== void 0) style.minWidth = props.minWidth;
955
- if (props.maxWidth !== void 0) style.maxWidth = props.maxWidth;
956
- if (props.minHeight !== void 0) style.minHeight = props.minHeight;
957
- if (props.maxHeight !== void 0) style.maxHeight = props.maxHeight;
958
- if (props.aspectRatio !== void 0) style.aspectRatio = props.aspectRatio;
959
- Object.assign(style, resolvePaddingRN(props.padding));
960
- if (props.fill && props.fill !== "transparent") style.backgroundColor = props.fill;
961
- Object.assign(style, resolveRadiusRN(props.radius));
962
- Object.assign(style, resolveBorderRN(props.border));
963
- Object.assign(style, resolveShadowRN(props.shadow));
964
- if (props.opacity !== void 0) style.opacity = props.opacity / 100;
965
- if (props.overflow === true) style.overflow = "hidden";
966
- Object.assign(style, resolvePositionRN(props));
967
- Object.assign(style, resolveTransformRN(props));
968
- return style;
969
- }
970
- function splitFrameStyle(style) {
971
- const OUTER_KEYS = /* @__PURE__ */ new Set([
972
- "flex",
973
- "alignSelf",
974
- "width",
975
- "height",
976
- "minWidth",
977
- "maxWidth",
978
- "minHeight",
979
- "maxHeight",
980
- "aspectRatio",
981
- "position",
982
- "top",
983
- "right",
984
- "bottom",
985
- "left",
986
- "zIndex",
987
- "transform"
988
- ]);
989
- const outer = {};
990
- const inner = {};
991
- for (const [k, v] of Object.entries(style)) {
992
- if (OUTER_KEYS.has(k)) outer[k] = v;
993
- else inner[k] = v;
994
- }
995
- return { outer, inner };
996
- }
997
- function splitScrollStyle(style) {
998
- const CONTENT_KEYS = /* @__PURE__ */ new Set([
999
- "flexDirection",
1000
- "justifyContent",
1001
- "alignItems",
1002
- "flexWrap",
1003
- "gap",
1004
- "padding",
1005
- "paddingTop",
1006
- "paddingRight",
1007
- "paddingBottom",
1008
- "paddingLeft",
1009
- "paddingVertical",
1010
- "paddingHorizontal"
1011
- ]);
1012
- const containerStyle = {};
1013
- const contentStyle = {};
1014
- for (const [k, v] of Object.entries(style)) {
1015
- if (CONTENT_KEYS.has(k)) contentStyle[k] = v;
1016
- else containerStyle[k] = v;
1017
- }
1018
- return { containerStyle, contentStyle };
1019
- }
1020
- function safeAreaEdges(safeArea) {
1021
- if (!safeArea) return [];
1022
- return Object.entries(safeArea).filter(([, v]) => v === true).map(([edge]) => edge);
1023
- }
1024
- function transformScreen(id, raw, children) {
1025
- const { actions, condition } = extractMeta(raw);
1026
- const props = stripBridgeKeys(raw);
1027
- const edges = safeAreaEdges(props.safeArea);
1028
- const hasSafeArea = edges.length > 0;
1029
- const vis = props.visible !== void 0 && props.visible !== true ? { visible: props.visible } : {};
1030
- const style = { flex: 1 };
1031
- if (props.backgroundColor) style.backgroundColor = props.backgroundColor;
1032
- let content;
1033
- if (props.scrollable) {
1034
- const paddingStyle = resolvePaddingRN(props.padding);
1035
- const scrollNode = {
1036
- id: `${id}__scroll`,
1037
- type: "scrollview",
1038
- props: {
1039
- style: { flex: 1 },
1040
- ...Object.keys(paddingStyle).length ? { contentContainerStyle: paddingStyle } : {},
1041
- showsVerticalScrollIndicator: false,
1042
- showsHorizontalScrollIndicator: false
1043
- },
1044
- children
1045
- };
1046
- content = [scrollNode];
1047
- } else {
1048
- Object.assign(style, resolvePaddingRN(props.padding));
1049
- content = children;
1050
- }
1051
- const statusBar = props.statusBarStyle && props.statusBarStyle !== "dark" ? { statusBarStyle: props.statusBarStyle } : {};
1052
- const node = {
1053
- id,
1054
- type: hasSafeArea ? "safeareaview" : "view",
1055
- props: {
1056
- style,
1057
- ...hasSafeArea ? { edges } : {},
1058
- ...statusBar,
1059
- ...vis
1060
- },
1061
- children: content
1062
- };
1063
- if (condition !== void 0) node.if = condition;
1064
- if (actions) node.actions = actions;
1065
- return node;
1066
- }
1067
- function transformFrame(id, raw, children, parentDirection) {
1068
- var _a, _b;
1069
- const { actions, condition } = extractMeta(raw);
1070
- const p = stripBridgeKeys(raw);
1071
- const isGrid = ((_a = p.type) != null ? _a : "stack") === "grid";
1072
- const isScrollable = p.scrollable === true;
1073
- const isPressable = p.pressable === true;
1074
- const direction = p.direction === "horizontal" ? "horizontal" : "vertical";
1075
- const edges = safeAreaEdges(p.safeArea);
1076
- const hasSafeArea = edges.length > 0;
1077
- const access = resolveAccessibilityProps(p);
1078
- const vis = p.visible !== void 0 && p.visible !== true ? { visible: p.visible } : {};
1079
- const fullStyle = buildFrameStyle(p, parentDirection);
1080
- const { outer: sizingStyle, inner: appearanceStyle } = splitFrameStyle(fullStyle);
1081
- const { containerStyle: scrollOuter, contentStyle: scrollContent } = splitScrollStyle(fullStyle);
1082
- function finalize(node) {
1083
- if (condition !== void 0) node.if = condition;
1084
- if (actions && node.type === "pressable") node.actions = actions;
1085
- else if (actions && !isPressable) node.actions = actions;
1086
- return node;
1087
- }
1088
- if (isGrid) {
1089
- const gridStyle = { ...fullStyle, flexDirection: "row", flexWrap: "wrap" };
1090
- delete gridStyle.gap;
1091
- if (p.columnGap !== void 0) gridStyle.columnGap = p.columnGap;
1092
- if (p.rowGap !== void 0) gridStyle.rowGap = p.rowGap;
1093
- const gridView = {
1094
- id: hasSafeArea || isPressable ? `${id}__grid` : id,
1095
- type: "view",
1096
- props: {
1097
- ...Object.keys(gridStyle).length ? { style: gridStyle } : {},
1098
- numColumns: (_b = p.columns) != null ? _b : 2,
1099
- ...access,
1100
- ...hasSafeArea || isPressable ? {} : vis
1101
- },
1102
- children
1103
- };
1104
- if (!hasSafeArea && !isPressable) return finalize(gridView);
1105
- let inner = gridView;
1106
- if (hasSafeArea) {
1107
- inner = {
1108
- id: isPressable ? `${id}__sav` : id,
1109
- type: "safeareaview",
1110
- props: { edges, ...isPressable ? {} : vis },
1111
- children: [gridView]
1112
- };
1113
- }
1114
- if (!isPressable) return finalize(inner);
1115
- return finalize({
1116
- id,
1117
- type: "pressable",
1118
- props: {
1119
- ...Object.keys(sizingStyle).length ? { style: sizingStyle } : {},
1120
- ...actions ? { actions } : {},
1121
- ...vis
1122
- },
1123
- children: [inner]
1124
- });
1125
- }
1126
- if (isScrollable) {
1127
- const scrollNode = {
1128
- id: hasSafeArea || isPressable ? `${id}__scroll` : id,
1129
- type: "scrollview",
1130
- props: {
1131
- ...Object.keys(scrollOuter).length ? { style: scrollOuter } : {},
1132
- ...Object.keys(scrollContent).length ? { contentContainerStyle: scrollContent } : {},
1133
- horizontal: direction === "horizontal",
1134
- showsHorizontalScrollIndicator: p.showScrollIndicator === true,
1135
- showsVerticalScrollIndicator: p.showScrollIndicator === true,
1136
- ...access,
1137
- ...hasSafeArea || isPressable ? {} : vis
1138
- },
1139
- children
1140
- };
1141
- if (!hasSafeArea && !isPressable) return finalize(scrollNode);
1142
- let inner = scrollNode;
1143
- if (hasSafeArea) {
1144
- inner = {
1145
- id: isPressable ? `${id}__sav` : id,
1146
- type: "safeareaview",
1147
- props: {
1148
- edges,
1149
- ...Object.keys(sizingStyle).length ? { style: sizingStyle } : {},
1150
- ...isPressable ? {} : vis
1151
- },
1152
- children: [scrollNode]
1153
- };
1154
- }
1155
- if (!isPressable) return finalize(inner);
1156
- return finalize({
1157
- id,
1158
- type: "pressable",
1159
- props: {
1160
- ...Object.keys(sizingStyle).length ? { style: sizingStyle } : {},
1161
- ...actions ? { actions } : {},
1162
- ...vis
1163
- },
1164
- children: [inner]
1165
- });
1166
- }
1167
- if (!isPressable && !hasSafeArea) {
1168
- return finalize({
1169
- id,
1170
- type: "view",
1171
- props: {
1172
- ...Object.keys(fullStyle).length ? { style: fullStyle } : {},
1173
- ...access,
1174
- ...vis
1175
- },
1176
- children
1177
- });
1178
- }
1179
- if (!isPressable && hasSafeArea) {
1180
- return finalize({
1181
- id,
1182
- type: "safeareaview",
1183
- props: {
1184
- edges,
1185
- ...Object.keys(fullStyle).length ? { style: fullStyle } : {},
1186
- ...access,
1187
- ...vis
1188
- },
1189
- children
1190
- });
1191
- }
1192
- const innerNode = hasSafeArea ? {
1193
- id: `${id}__sav`,
1194
- type: "safeareaview",
1195
- props: {
1196
- edges,
1197
- ...Object.keys(appearanceStyle).length ? { style: appearanceStyle } : {},
1198
- ...access
1199
- },
1200
- children
1201
- } : {
1202
- id: `${id}__content`,
1203
- type: "view",
1204
- props: {
1205
- ...Object.keys(appearanceStyle).length ? { style: appearanceStyle } : {},
1206
- ...access
1207
- },
1208
- children
1209
- };
1210
- return finalize({
1211
- id,
1212
- type: "pressable",
1213
- props: {
1214
- ...Object.keys(sizingStyle).length ? { style: sizingStyle } : {},
1215
- ...actions ? { actions } : {},
1216
- ...vis
1217
- },
1218
- children: [innerNode]
1219
- });
1220
- }
1221
- function transformText(id, raw, parentDirection) {
1222
- var _a, _b;
1223
- const { actions, condition } = extractMeta(raw);
1224
- const props = stripBridgeKeys(raw);
1225
- const style = {};
1226
- if (props.textStyle) {
1227
- const preset = TEXT_STYLE_PRESETS[props.textStyle];
1228
- if (preset) {
1229
- style.fontSize = preset.fontSize;
1230
- style.fontWeight = preset.fontWeight;
1231
- if (preset.lineHeight !== void 0) style.lineHeight = preset.lineHeight;
1232
- if (preset.textTransform) style.textTransform = preset.textTransform;
1233
- if (preset.letterSpacing !== void 0) style.letterSpacing = preset.letterSpacing;
1234
- }
1235
- }
1236
- if (props.color) style.color = props.color;
1237
- if (props.fontSize !== void 0) style.fontSize = props.fontSize;
1238
- if (props.fontWeight) style.fontWeight = (_a = FONT_WEIGHT_MAP[props.fontWeight]) != null ? _a : props.fontWeight;
1239
- if (props.fontFamily) style.fontFamily = props.fontFamily;
1240
- if (props.fontStyle) style.fontStyle = props.fontStyle;
1241
- if (props.lineHeight !== void 0) style.lineHeight = props.lineHeight;
1242
- if (props.letterSpacing !== void 0) style.letterSpacing = props.letterSpacing;
1243
- if (props.align) style.textAlign = props.align;
1244
- if (props.transform && props.transform !== "none") style.textTransform = props.transform;
1245
- if (props.decoration && props.decoration !== "none") style.textDecorationLine = props.decoration;
1246
- if (props.opacity !== void 0) style.opacity = props.opacity / 100;
1247
- Object.assign(style, resolvePositionRN(props));
1248
- resolveSizeModeRN(props.width, "width", style, parentDirection);
1249
- const textProps = {};
1250
- if (typeof props.truncate === "number" && props.truncate > 0) {
1251
- textProps.numberOfLines = props.truncate;
1252
- textProps.ellipsizeMode = "tail";
1253
- }
1254
- if (props.adjustFontSize === true) {
1255
- textProps.adjustsFontSizeToFit = true;
1256
- if (props.minFontSize !== void 0) textProps.minimumFontScale = props.minFontSize;
1257
- }
1258
- if (props.selectable !== void 0) textProps.selectable = props.selectable;
1259
- const node = {
1260
- id,
1261
- type: "text",
1262
- props: {
1263
- // SDK contract: text content lives in the `value` prop.
1264
- // The Craft editor stores text in `content`; map it to `value` here.
1265
- value: (_b = props.content) != null ? _b : "",
1266
- ...Object.keys(style).length ? { style } : {},
1267
- ...textProps,
1268
- ...resolveAccessibilityProps(props),
1269
- ...props.visible !== void 0 && props.visible !== true ? { visible: props.visible } : {}
1270
- }
1271
- };
1272
- if (condition !== void 0) node.if = condition;
1273
- if (actions) node.actions = actions;
1274
- return node;
1275
- }
1276
- function transformImage(id, raw, children, parentDirection) {
1277
- var _a, _b;
1278
- const { actions, condition } = extractMeta(raw);
1279
- const props = stripBridgeKeys(raw);
1280
- const style = {};
1281
- resolveSizeModeRN(props.width, "width", style, parentDirection);
1282
- resolveSizeModeRN(props.height, "height", style, parentDirection);
1283
- if (props.aspectRatio !== void 0) style.aspectRatio = props.aspectRatio;
1284
- Object.assign(style, resolveRadiusRN(props.radius));
1285
- if (props.opacity !== void 0) style.opacity = props.opacity / 100;
1286
- Object.assign(style, resolvePositionRN(props));
1287
- const imageProps = {};
1288
- if (props.src) imageProps.source = { uri: props.src };
1289
- if (props.placeholder) imageProps.defaultSource = { uri: props.placeholder };
1290
- if (props.fallback) imageProps.fallback = { uri: props.fallback };
1291
- imageProps.resizeMode = (_b = FIT_TO_RESIZE_MODE[(_a = props.fit) != null ? _a : "cover"]) != null ? _b : "cover";
1292
- if (props.background === true) imageProps.background = true;
1293
- if (props.decorative) {
1294
- imageProps.accessible = false;
1295
- imageProps.accessibilityElementsHidden = true;
1296
- } else if (props.alt) {
1297
- imageProps.accessible = true;
1298
- imageProps.accessibilityLabel = props.alt;
1299
- }
1300
- if (props.testID) imageProps.testID = props.testID;
1301
- const node = {
1302
- id,
1303
- type: "image",
1304
- props: {
1305
- ...Object.keys(style).length ? { style } : {},
1306
- ...imageProps,
1307
- ...props.visible !== void 0 && props.visible !== true ? { visible: props.visible } : {}
1308
- },
1309
- ...props.background === true && children.length ? { children } : {}
1310
- };
1311
- if (condition !== void 0) node.if = condition;
1312
- if (actions) node.actions = actions;
1313
- return node;
1314
- }
1315
- function transformInput(id, raw, parentDirection) {
1316
- var _a, _b, _c, _d, _e, _f, _g;
1317
- const { actions, condition } = extractMeta(raw);
1318
- const props = stripBridgeKeys(raw);
1319
- const style = {};
1320
- resolveSizeModeRN((_a = props.width) != null ? _a : "fill", "width", style, parentDirection);
1321
- Object.assign(style, resolvePaddingRN(props.padding));
1322
- if (props.opacity !== void 0) style.opacity = props.opacity / 100;
1323
- Object.assign(style, resolvePositionRN(props));
1324
- const inputTypeDefaults = (_c = INPUT_TYPE_MAP[(_b = props.inputType) != null ? _b : "text"]) != null ? _c : INPUT_TYPE_MAP.text;
1325
- const node = {
1326
- id,
1327
- type: "textinput",
1328
- props: {
1329
- ...Object.keys(style).length ? { style } : {},
1330
- ...props.label !== void 0 ? { label: props.label } : {},
1331
- ...props.placeholder !== void 0 ? { placeholder: props.placeholder } : {},
1332
- ...props.value !== void 0 ? { value: props.value } : {},
1333
- ...props.helperText !== void 0 ? { helperText: props.helperText } : {},
1334
- ...props.errorText !== void 0 ? { errorText: props.errorText } : {},
1335
- ...inputTypeDefaults,
1336
- ...props.autoCapitalize ? { autoCapitalize: props.autoCapitalize } : {},
1337
- returnKeyType: (_d = props.returnKey) != null ? _d : "done",
1338
- multiline: (_e = props.multiline) != null ? _e : false,
1339
- ...props.multiline && props.minLines ? { numberOfLines: props.minLines } : {},
1340
- ...props.multiline && props.maxLines ? { maxNumberOfLines: props.maxLines } : {},
1341
- variant: (_f = props.variant) != null ? _f : "outline",
1342
- size: (_g = props.size) != null ? _g : "md",
1343
- ...props.leadingIcon ? { leadingIcon: props.leadingIcon } : {},
1344
- ...props.trailingIcon ? { trailingIcon: props.trailingIcon } : {},
1345
- ...resolveAccessibilityProps(props),
1346
- ...props.visible !== void 0 && props.visible !== true ? { visible: props.visible } : {}
1347
- }
1348
- };
1349
- if (condition !== void 0) node.if = condition;
1350
- if (actions) node.actions = actions;
1351
- return node;
1352
- }
1353
- function transformList(id, raw, children, parentDirection) {
1354
- var _a, _b, _c;
1355
- const { actions, condition } = extractMeta(raw);
1356
- const props = stripBridgeKeys(raw);
1357
- const listType = (_a = props.type) != null ? _a : "stack";
1358
- const direction = props.direction === "horizontal" ? "horizontal" : "vertical";
1359
- const edges = safeAreaEdges(props.safeArea);
1360
- const hasSafeArea = edges.length > 0;
1361
- const vis = props.visible !== void 0 && props.visible !== true ? { visible: props.visible } : {};
1362
- const fullStyle = buildFrameStyle(props, parentDirection);
1363
- const { containerStyle, contentStyle } = splitScrollStyle(fullStyle);
1364
- let itemTemplate;
1365
- if (children.length === 1) {
1366
- itemTemplate = children[0];
1367
- } else if (children.length > 1) {
1368
- itemTemplate = { id: `${id}__template`, type: "view", props: {}, children };
1369
- }
1370
- const flatlistNode = {
1371
- id: hasSafeArea ? `${id}__list` : id,
1372
- type: "flatlist",
1373
- props: {
1374
- ...Object.keys(containerStyle).length ? { style: containerStyle } : {},
1375
- ...Object.keys(contentStyle).length ? { contentContainerStyle: contentStyle } : {},
1376
- // `data` holds the binding expression for the list items array.
1377
- // RecursiveRenderer resolves it and passes items to the FlatList primitive.
1378
- data: props.data,
1379
- keyExtractor: (_b = props.keyExtractor) != null ? _b : "id",
1380
- ...listType === "grid" ? { numColumns: (_c = props.columns) != null ? _c : 2 } : {},
1381
- ...listType === "grid" && props.columnGap ? { columnGap: props.columnGap } : {},
1382
- ...listType === "grid" && props.rowGap ? { rowGap: props.rowGap } : {},
1383
- horizontal: direction === "horizontal",
1384
- showsHorizontalScrollIndicator: props.showScrollIndicator === true,
1385
- showsVerticalScrollIndicator: props.showScrollIndicator === true,
1386
- ...resolveAccessibilityProps(props),
1387
- ...hasSafeArea ? {} : vis
1388
- },
1389
- ...itemTemplate ? { itemTemplate } : {}
1390
- };
1391
- if (!hasSafeArea) {
1392
- if (condition !== void 0) flatlistNode.if = condition;
1393
- if (actions) flatlistNode.actions = actions;
1394
- return flatlistNode;
1395
- }
1396
- const { outer: sizingStyle } = splitFrameStyle(fullStyle);
1397
- const savNode = {
1398
- id,
1399
- type: "safeareaview",
1400
- props: {
1401
- edges,
1402
- ...Object.keys(sizingStyle).length ? { style: sizingStyle } : {},
1403
- ...vis
1404
- },
1405
- children: [flatlistNode]
1406
- };
1407
- if (condition !== void 0) savNode.if = condition;
1408
- if (actions) savNode.actions = actions;
1409
- return savNode;
1410
- }
1411
- function transformIcon(id, raw) {
1412
- var _a, _b;
1413
- const { actions, condition } = extractMeta(raw);
1414
- const props = stripBridgeKeys(raw);
1415
- const style = {};
1416
- if (props.opacity !== void 0) style.opacity = props.opacity / 100;
1417
- Object.assign(style, resolvePositionRN(props));
1418
- const node = {
1419
- id,
1420
- type: "icon",
1421
- props: {
1422
- name: props.name,
1423
- set: (_a = props.set) != null ? _a : "default",
1424
- size: (_b = props.size) != null ? _b : 24,
1425
- ...props.color ? { color: props.color } : {},
1426
- ...Object.keys(style).length ? { style } : {},
1427
- ...resolveAccessibilityProps(props),
1428
- ...props.visible !== void 0 && props.visible !== true ? { visible: props.visible } : {}
1429
- }
1430
- };
1431
- if (condition !== void 0) node.if = condition;
1432
- if (actions) node.actions = actions;
1433
- return node;
1434
- }
1435
- function buildNodeFromSchema(nodeId, schema, customComponents, visited, parentId) {
1436
- var _a, _b, _c, _d, _e;
1437
- if (visited.has(nodeId)) {
1438
- throw new Error(`Circular reference detected at node ${nodeId}`);
1439
- }
1440
- visited.add(nodeId);
1441
- const node = schema[nodeId];
1442
- if (!node) throw new Error(`Node not found: ${nodeId}`);
1443
- const resolvedName = (_a = node.type) == null ? void 0 : _a.resolvedName;
1444
- if (!resolvedName) throw new Error(`Invalid node type at ${nodeId}`);
1445
- const raw = (_b = node.props) != null ? _b : {};
1446
- const parentDirection = parentId ? ((_d = (_c = schema[parentId]) == null ? void 0 : _c.props) == null ? void 0 : _d["direction"]) === "horizontal" ? "horizontal" : "vertical" : "vertical";
1447
- const outputId = nodeId === "ROOT" ? "root" : nodeId;
1448
- const childNodes = ((_e = node.nodes) != null ? _e : []).map(
1449
- (childId) => buildNodeFromSchema(childId, schema, customComponents, visited, nodeId)
1450
- );
1451
- switch (resolvedName) {
1452
- case "PF.Screen":
1453
- return transformScreen(outputId, raw, childNodes);
1454
- case "PF.Frame":
1455
- return transformFrame(outputId, raw, childNodes, parentDirection);
1456
- case "PF.Text":
1457
- return transformText(outputId, raw, parentDirection);
1458
- case "PF.Image":
1459
- return transformImage(outputId, raw, childNodes, parentDirection);
1460
- case "PF.Input":
1461
- return transformInput(outputId, raw, parentDirection);
1462
- case "PF.List":
1463
- return transformList(outputId, raw, childNodes, parentDirection);
1464
- case "PF.Icon":
1465
- return transformIcon(outputId, raw);
1466
- case "Component":
1467
- return resolveCustomComponent(outputId, raw, parentDirection, customComponents);
1468
- default:
1469
- return { id: outputId, type: "view", props: {}, children: childNodes };
1470
- }
1471
- }
1472
- function resolveCustomComponent(id, raw, parentDirection, customComponents) {
1473
- const { actions, condition } = extractMeta(raw);
1474
- const props = stripBridgeKeys(raw);
1475
- const { componentId, componentKey, propValues, ...frameProps } = props;
1476
- const key = componentKey != null ? componentKey : componentId;
1477
- const def = key ? customComponents[key] : void 0;
1478
- const wrapperStyle = buildFrameStyle(frameProps, parentDirection);
1479
- const vis = props.visible !== void 0 && props.visible !== true ? { visible: props.visible } : {};
1480
- if (!def) {
1481
- return {
1482
- id,
1483
- type: "view",
1484
- props: { ...Object.keys(wrapperStyle).length ? { style: wrapperStyle } : {}, ...vis },
1485
- children: []
1486
- };
1487
- }
1488
- const componentVisited = /* @__PURE__ */ new Set();
1489
- const componentRoot = buildNodeFromSchema(
1490
- def.rootNodeId,
1491
- def.nodes,
1492
- customComponents,
1493
- componentVisited
1494
- );
1495
- if (propValues && Object.keys(propValues).length) {
1496
- componentRoot.props = { ...componentRoot.props, _propValues: propValues };
1497
- }
1498
- if (Object.keys(wrapperStyle).length > 0) {
1499
- const wrapper = {
1500
- id,
1501
- type: "view",
1502
- props: { style: wrapperStyle, ...vis },
1503
- children: [componentRoot]
1504
- };
1505
- if (condition !== void 0) wrapper.if = condition;
1506
- if (actions) wrapper.actions = actions;
1507
- return wrapper;
1508
- }
1509
- componentRoot.id = id;
1510
- componentRoot.props = { ...componentRoot.props, ...vis };
1511
- if (condition !== void 0) componentRoot.if = condition;
1512
- if (actions) componentRoot.actions = actions;
1513
- return componentRoot;
1514
- }
1515
- function transformCraftToSDUI(craftJson, customComponents = {}) {
1516
- if (!craftJson || typeof craftJson !== "object") {
1517
- throw new Error("Invalid craft schema");
1518
- }
1519
- const visited = /* @__PURE__ */ new Set();
1520
- return buildNodeFromSchema("ROOT", craftJson, customComponents, visited);
1521
- }
1522
-
1523
- // src/index.ts
1524
- var PushFrame = {
1525
- // Slot components
1526
- Provider: PushFrameProvider,
1527
- Screen: PushFrameScreen,
1528
- Component: PushFrameComponent,
1529
- // Primitives
1530
- Text,
1531
- View,
1532
- ScrollView,
1533
- Image,
1534
- Pressable,
1535
- TextInput,
1536
- FlatList,
1537
- Modal,
1538
- ActivityIndicator,
1539
- Switch,
1540
- KeyboardAvoidingView,
1541
- SafeAreaView,
1542
- StatusBar
1543
- };
1544
-
1545
- exports.ActivityIndicator = ActivityIndicator;
1546
- exports.ComponentRegistry = ComponentRegistry;
1547
- exports.FlatList = FlatList;
1548
- exports.Image = Image;
1549
- exports.KeyboardAvoidingView = KeyboardAvoidingView;
1550
- exports.Modal = Modal;
1551
- exports.Pressable = Pressable;
1552
- exports.PushFrame = PushFrame;
1553
- exports.PushFrameComponent = PushFrameComponent;
1554
- exports.PushFrameContext = PushFrameContext;
1555
- exports.PushFrameProvider = PushFrameProvider;
1556
- exports.PushFrameScreen = PushFrameScreen;
1557
- exports.RecursiveRenderer = RecursiveRenderer;
1558
- exports.SafeAreaView = SafeAreaView;
1559
- exports.ScrollView = ScrollView;
1560
- exports.StatusBar = StatusBar;
1561
- exports.Switch = Switch;
1562
- exports.Text = Text;
1563
- exports.TextInput = TextInput;
1564
- exports.View = View;
1565
- exports.evaluateIf = evaluateIf;
1566
- exports.resolveDeep = resolveDeep;
1567
- exports.resolveProps = resolveProps;
1568
- exports.resolveValue = resolveValue;
1569
- exports.transformCraftToSDUI = transformCraftToSDUI;
1570
- exports.usePushFrameContext = usePushFrameContext;
1571
- //# sourceMappingURL=index.js.map
1572
- //# sourceMappingURL=index.js.map