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