@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/src/transport.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { ScreenDefinition, PushframeNode } from './schema';
|
|
2
|
+
import { SCHEMA_VERSION } from './schema';
|
|
3
|
+
|
|
4
|
+
/** In-memory cache so repeated renders don't re-fetch the same screen. */
|
|
5
|
+
const cache = new Map<string, ScreenDefinition>();
|
|
6
|
+
|
|
7
|
+
function cacheKey(serverUrl: string, projectKey: string, screenId: string): string {
|
|
8
|
+
return `${serverUrl}|${projectKey}|${screenId}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Server envelope format.
|
|
13
|
+
* The server stores screens as { key, version, schema, publishedAt, ... }.
|
|
14
|
+
* We normalize this to the SDK's ScreenDefinition shape in `normalizeResponse`.
|
|
15
|
+
*/
|
|
16
|
+
interface ServerScreenEnvelope {
|
|
17
|
+
key: string;
|
|
18
|
+
version?: number;
|
|
19
|
+
schema: PushframeNode;
|
|
20
|
+
publishedAt?: string;
|
|
21
|
+
minAppVersion?: string | null;
|
|
22
|
+
maxAppVersion?: string | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Accepts either the raw server envelope or a native ScreenDefinition and
|
|
27
|
+
* always returns a valid ScreenDefinition the renderer can consume.
|
|
28
|
+
*/
|
|
29
|
+
function normalizeResponse(raw: unknown, screenId: string): ScreenDefinition {
|
|
30
|
+
if (raw === null || typeof raw !== 'object') {
|
|
31
|
+
throw new Error(`[Pushframe] Server returned non-object for screen "${screenId}"`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const obj = raw as Record<string, unknown>;
|
|
35
|
+
|
|
36
|
+
// Native SDK format — already has `root` and `schemaVersion`
|
|
37
|
+
if ('root' in obj) {
|
|
38
|
+
return obj as unknown as ScreenDefinition;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Server envelope format — { key, schema, ... }
|
|
42
|
+
if ('schema' in obj) {
|
|
43
|
+
const envelope = obj as unknown as ServerScreenEnvelope;
|
|
44
|
+
return {
|
|
45
|
+
schemaVersion: SCHEMA_VERSION,
|
|
46
|
+
id: envelope.key ?? screenId,
|
|
47
|
+
root: envelope.schema,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
throw new Error(
|
|
52
|
+
`[Pushframe] Unrecognized response shape for screen "${screenId}". ` +
|
|
53
|
+
`Expected { root } or { key, schema } but got keys: ${Object.keys(obj).join(', ')}`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Fetch a screen definition from the Pushframe server.
|
|
59
|
+
*
|
|
60
|
+
* URL: GET {serverUrl}/screens/{screenId}?projectKey={projectKey}
|
|
61
|
+
*
|
|
62
|
+
* Handles both the native SDK format ({ schemaVersion, id, root })
|
|
63
|
+
* and the server envelope format ({ key, version, schema, publishedAt }).
|
|
64
|
+
*
|
|
65
|
+
* Results are cached in memory for the lifetime of the JS bundle.
|
|
66
|
+
* Call `clearScreenCache()` to force a refetch (e.g. on logout or hard reload).
|
|
67
|
+
*/
|
|
68
|
+
export async function fetchScreenDefinition(
|
|
69
|
+
serverUrl: string,
|
|
70
|
+
projectKey: string,
|
|
71
|
+
screenId: string,
|
|
72
|
+
): Promise<ScreenDefinition> {
|
|
73
|
+
const key = cacheKey(serverUrl, projectKey, screenId);
|
|
74
|
+
const cached = cache.get(key);
|
|
75
|
+
if (cached) return cached;
|
|
76
|
+
|
|
77
|
+
const base = serverUrl.replace(/\/$/, '');
|
|
78
|
+
const url = `${base}/screens/${encodeURIComponent(screenId)}?projectKey=${encodeURIComponent(projectKey)}`;
|
|
79
|
+
|
|
80
|
+
const res = await fetch(url, {
|
|
81
|
+
headers: {
|
|
82
|
+
Accept: 'application/json',
|
|
83
|
+
'x-project-key': projectKey,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (!res.ok) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`[Pushframe] Failed to fetch screen "${screenId}": HTTP ${res.status} ${res.statusText}`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const definition = normalizeResponse(await res.json(), screenId);
|
|
94
|
+
cache.set(key, definition);
|
|
95
|
+
return definition;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Invalidate the entire in-memory screen cache.
|
|
100
|
+
* Useful after a forced refresh or when the project key changes.
|
|
101
|
+
*/
|
|
102
|
+
export function clearScreenCache(): void {
|
|
103
|
+
cache.clear();
|
|
104
|
+
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,534 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import React__default, { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import * as react_native from 'react-native';
|
|
4
|
-
import { TextProps, ViewProps, ImageProps, PressableProps, TextInputProps, FlatListProps, ModalProps, ActivityIndicatorProps, SwitchProps, KeyboardAvoidingViewProps, StatusBarProps, ScrollViewProps, ScrollView as ScrollView$1 } from 'react-native';
|
|
5
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
-
|
|
7
|
-
interface PushFrameProviderProps {
|
|
8
|
-
/** Pushframe API key — sent as Authorization header on all fetches. */
|
|
9
|
-
apiKey: string;
|
|
10
|
-
/**
|
|
11
|
-
* Runtime data context. Screens/Components bind to this via {{expressions}}.
|
|
12
|
-
* Merged at the Provider level; slot-level context wins on conflict.
|
|
13
|
-
*/
|
|
14
|
-
context?: Record<string, unknown>;
|
|
15
|
-
/**
|
|
16
|
-
* Base URL of the Pushframe delivery service.
|
|
17
|
-
* Defaults to the production endpoint: https://api.pushframe.io
|
|
18
|
-
*/
|
|
19
|
-
baseUrl?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Semver string appended to fetch paths for schema version targeting.
|
|
22
|
-
* e.g. "1.2.3" → GET /screens/home/1.2.3
|
|
23
|
-
* When not provided, "null" is sent as the appVersion in the URL.
|
|
24
|
-
*/
|
|
25
|
-
appVersion?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Developer-registered native components merged into the ComponentRegistry.
|
|
28
|
-
* Built-in types cannot be overridden — conflicting keys are warned and skipped.
|
|
29
|
-
*/
|
|
30
|
-
components?: Record<string, React__default.ComponentType<unknown>>;
|
|
31
|
-
/** Default loading UI shown while schema is fetching or isLoading=true. */
|
|
32
|
-
loadingComponent?: ReactNode;
|
|
33
|
-
/** Default fallback UI shown on fetch error or unknown component type. */
|
|
34
|
-
fallbackComponent?: ReactNode;
|
|
35
|
-
/**
|
|
36
|
-
* Global action handler. Receives actions that are not handled as built-ins
|
|
37
|
-
* and were not stopped by a slot-level onAction.
|
|
38
|
-
*/
|
|
39
|
-
onAction?: (action: string, payload?: Record<string, unknown>) => void;
|
|
40
|
-
/** Called whenever a fetch or render error occurs. */
|
|
41
|
-
onError?: (error: Error) => void;
|
|
42
|
-
children: ReactNode;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Root provider for the PushFrame SDK.
|
|
46
|
-
*
|
|
47
|
-
* Wrap your app (or a subtree) in this provider. All PushFrame.Screen and
|
|
48
|
-
* PushFrame.Component slots inside will fetch their schemas from the delivery
|
|
49
|
-
* service and render them using the shared ComponentRegistry and context.
|
|
50
|
-
*
|
|
51
|
-
* Also renders the ToastHost and BottomSheetHost overlay hosts at root level
|
|
52
|
-
* so any component in the tree can trigger them via built-in actions.
|
|
53
|
-
*/
|
|
54
|
-
declare function PushFrameProvider({ apiKey, context, baseUrl, appVersion, components, loadingComponent, fallbackComponent, onAction, onError, children, }: PushFrameProviderProps): react_jsx_runtime.JSX.Element;
|
|
55
|
-
|
|
56
|
-
interface PushFrameSlotProps {
|
|
57
|
-
/** ID of the screen/component to fetch from the delivery service. */
|
|
58
|
-
id: string;
|
|
59
|
-
/**
|
|
60
|
-
* Data context local to this slot. Merged with the Provider context;
|
|
61
|
-
* local keys win on conflict.
|
|
62
|
-
*/
|
|
63
|
-
context?: Record<string, unknown>;
|
|
64
|
-
/**
|
|
65
|
-
* External loading signal from the host app. When true, loading UI is shown
|
|
66
|
-
* even if the schema has already been fetched.
|
|
67
|
-
*/
|
|
68
|
-
isLoading?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Loading UI shown while isLoading=true OR schema is being fetched.
|
|
71
|
-
* Falls back to Provider-level loadingComponent.
|
|
72
|
-
*/
|
|
73
|
-
loadingComponent?: ReactNode;
|
|
74
|
-
/**
|
|
75
|
-
* Fallback UI shown on fetch error or unresolvable component type.
|
|
76
|
-
* Falls back to Provider-level fallbackComponent.
|
|
77
|
-
*/
|
|
78
|
-
fallbackComponent?: ReactNode;
|
|
79
|
-
/**
|
|
80
|
-
* Slot-level action handler. Return true to stop the action from bubbling
|
|
81
|
-
* to the Provider-level onAction.
|
|
82
|
-
*/
|
|
83
|
-
onAction?: (action: string, payload?: Record<string, unknown>) => boolean | void;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Fetches a component schema from GET /components/:id[/:appVersion] on the
|
|
87
|
-
* delivery service and renders it inline using RecursiveRenderer.
|
|
88
|
-
*
|
|
89
|
-
* Context is merged: Provider context → slot context (local wins).
|
|
90
|
-
* Actions bubble: slot onAction → Provider onAction.
|
|
91
|
-
* Built-in actions (show-toast, show-bottom-sheet, etc.) are handled internally.
|
|
92
|
-
*/
|
|
93
|
-
declare function PushFrameComponent(props: PushFrameSlotProps): react_jsx_runtime.JSX.Element;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Fetches a screen schema from GET /screens/:id[/:appVersion] on the delivery
|
|
97
|
-
* service and renders it with flex:1 sizing (full-page layout).
|
|
98
|
-
*
|
|
99
|
-
* Identical to PushFrame.Component in behaviour, but:
|
|
100
|
-
* - Fetches from /screens/:id instead of /components/:id
|
|
101
|
-
* - Applies flex:1 to its container so it fills the available space
|
|
102
|
-
*
|
|
103
|
-
* Context is merged: Provider context → slot context (local wins).
|
|
104
|
-
* Actions bubble: slot onAction → Provider onAction.
|
|
105
|
-
* Built-in actions (show-toast, show-bottom-sheet, etc.) are handled internally.
|
|
106
|
-
*/
|
|
107
|
-
declare function PushFrameScreen(props: PushFrameSlotProps): react_jsx_runtime.JSX.Element;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Maps component type strings to React components.
|
|
111
|
-
*
|
|
112
|
-
* Built-ins are always present and cannot be overridden.
|
|
113
|
-
* Developer-registered components are merged on top for non-conflicting types.
|
|
114
|
-
*/
|
|
115
|
-
declare class ComponentRegistry {
|
|
116
|
-
private readonly components;
|
|
117
|
-
constructor(developerComponents?: Record<string, React__default.ComponentType<unknown>>);
|
|
118
|
-
/**
|
|
119
|
-
* Resolve a type string to its React component.
|
|
120
|
-
* Returns null if no component is registered for the type.
|
|
121
|
-
*/
|
|
122
|
-
resolve(type: string): React__default.ComponentType<Record<string, unknown>> | null;
|
|
123
|
-
/**
|
|
124
|
-
* Returns all registered type strings (useful for debugging).
|
|
125
|
-
*/
|
|
126
|
-
types(): string[];
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
interface SchemaNode {
|
|
130
|
-
id?: string;
|
|
131
|
-
type: string;
|
|
132
|
-
props?: Record<string, unknown>;
|
|
133
|
-
children?: SchemaNode[];
|
|
134
|
-
/** Per-item render template for flatlist nodes. */
|
|
135
|
-
itemTemplate?: SchemaNode;
|
|
136
|
-
actions?: Action[];
|
|
137
|
-
/**
|
|
138
|
-
* Conditional render expression. String values are resolved against the
|
|
139
|
-
* context via {{}} binding syntax. Non-string values (boolean, number, null)
|
|
140
|
-
* are coerced directly. Falsy → node is hidden.
|
|
141
|
-
*/
|
|
142
|
-
if?: unknown;
|
|
143
|
-
}
|
|
144
|
-
interface FlatListSchemaNode extends SchemaNode {
|
|
145
|
-
type: 'flatlist';
|
|
146
|
-
itemTemplate: SchemaNode;
|
|
147
|
-
}
|
|
148
|
-
interface Action {
|
|
149
|
-
trigger: string;
|
|
150
|
-
action: string;
|
|
151
|
-
payload?: Record<string, unknown>;
|
|
152
|
-
}
|
|
153
|
-
interface ToastPayload {
|
|
154
|
-
message: string;
|
|
155
|
-
duration?: number;
|
|
156
|
-
type?: 'success' | 'error' | 'info' | 'warning';
|
|
157
|
-
}
|
|
158
|
-
interface BottomSheetPayload {
|
|
159
|
-
schema: SchemaNode;
|
|
160
|
-
context?: Record<string, unknown>;
|
|
161
|
-
}
|
|
162
|
-
interface ScrollToPayload {
|
|
163
|
-
x?: number;
|
|
164
|
-
y?: number;
|
|
165
|
-
animated?: boolean;
|
|
166
|
-
}
|
|
167
|
-
interface PushFrameContextValue {
|
|
168
|
-
apiKey: string;
|
|
169
|
-
baseUrl: string;
|
|
170
|
-
appVersion?: string;
|
|
171
|
-
globalContext: Record<string, unknown>;
|
|
172
|
-
registry: ComponentRegistry;
|
|
173
|
-
loadingComponent?: React__default.ReactNode;
|
|
174
|
-
fallbackComponent?: React__default.ReactNode;
|
|
175
|
-
onAction?: (action: string, payload?: Record<string, unknown>) => void;
|
|
176
|
-
onError?: (error: Error) => void;
|
|
177
|
-
showToast: (payload: ToastPayload) => void;
|
|
178
|
-
showBottomSheet: (payload: BottomSheetPayload) => void;
|
|
179
|
-
dismissBottomSheet: () => void;
|
|
180
|
-
}
|
|
181
|
-
declare const PushFrameContext: React__default.Context<PushFrameContextValue | null>;
|
|
182
|
-
declare function usePushFrameContext(): PushFrameContextValue;
|
|
183
|
-
|
|
184
|
-
interface PushFrameTextProps extends TextProps {
|
|
185
|
-
/** Pushframe: hidden by RecursiveRenderer before component renders. */
|
|
186
|
-
if?: string;
|
|
187
|
-
/** Pushframe: converted to handlers by RecursiveRenderer before component renders. */
|
|
188
|
-
actions?: Action[];
|
|
189
|
-
/**
|
|
190
|
-
* Text content. Takes precedence over `children`.
|
|
191
|
-
* Pushframe schema convention: use `value`.
|
|
192
|
-
*/
|
|
193
|
-
value?: string;
|
|
194
|
-
/**
|
|
195
|
-
* Alias for `value`. The transformer outputs the Craft editor's `content`
|
|
196
|
-
* field here. `value` takes precedence when both are present.
|
|
197
|
-
*/
|
|
198
|
-
content?: string;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Thin wrapper over React Native Text.
|
|
202
|
-
* Strips `if`, `actions`, `content` before forwarding to RN.
|
|
203
|
-
* Display priority: value > content > children (children remain in rest).
|
|
204
|
-
*/
|
|
205
|
-
declare function Text({ if: _if, actions: _actions, value, content, ...rest }: PushFrameTextProps): react_jsx_runtime.JSX.Element;
|
|
206
|
-
|
|
207
|
-
interface PushFrameViewProps extends ViewProps {
|
|
208
|
-
if?: string;
|
|
209
|
-
actions?: Action[];
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Thin wrapper over React Native View.
|
|
213
|
-
* Strips `if`, `actions` before forwarding to RN.
|
|
214
|
-
*/
|
|
215
|
-
declare function View({ if: _if, actions: _actions, ...rest }: PushFrameViewProps): react_jsx_runtime.JSX.Element;
|
|
216
|
-
|
|
217
|
-
interface PushFrameImageProps extends Omit<ImageProps, 'source'> {
|
|
218
|
-
if?: string;
|
|
219
|
-
actions?: Action[];
|
|
220
|
-
/**
|
|
221
|
-
* URI string for the image source. Maps to RN `source={{ uri: src }}`.
|
|
222
|
-
* Takes precedence over the base `source` prop.
|
|
223
|
-
*/
|
|
224
|
-
src?: string;
|
|
225
|
-
/** Pass-through for cases where a static require() source is needed. */
|
|
226
|
-
source?: ImageProps['source'];
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Thin wrapper over React Native Image.
|
|
230
|
-
* `src` maps to `source={{ uri: src }}`.
|
|
231
|
-
* Strips `if`, `actions`, `src` before forwarding to RN.
|
|
232
|
-
*/
|
|
233
|
-
declare function Image({ if: _if, actions: _actions, src, source, ...rest }: PushFrameImageProps): react_jsx_runtime.JSX.Element;
|
|
234
|
-
|
|
235
|
-
interface PushFramePressableProps extends PressableProps {
|
|
236
|
-
if?: string;
|
|
237
|
-
actions?: Action[];
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Thin wrapper over React Native Pressable.
|
|
241
|
-
* Actions with trigger "onPress" and "onLongPress" are wired by RecursiveRenderer
|
|
242
|
-
* and forwarded through as standard RN props.
|
|
243
|
-
* Strips `if`, `actions` before forwarding to RN.
|
|
244
|
-
*/
|
|
245
|
-
declare function Pressable({ if: _if, actions: _actions, ...rest }: PushFramePressableProps): react_jsx_runtime.JSX.Element;
|
|
246
|
-
|
|
247
|
-
interface PushFrameTextInputProps extends Omit<TextInputProps, 'onChange'> {
|
|
248
|
-
if?: string;
|
|
249
|
-
actions?: Action[];
|
|
250
|
-
/**
|
|
251
|
-
* Schema trigger "onChange" — wired by RecursiveRenderer.
|
|
252
|
-
* Mapped to RN `onChangeText` by this component.
|
|
253
|
-
*/
|
|
254
|
-
onChange?: (text: string) => void;
|
|
255
|
-
/**
|
|
256
|
-
* Schema trigger "onSubmit" — wired by RecursiveRenderer.
|
|
257
|
-
* Mapped to RN `onSubmitEditing` by this component.
|
|
258
|
-
*/
|
|
259
|
-
onSubmit?: () => void;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Thin wrapper over React Native TextInput.
|
|
263
|
-
* Maps Pushframe schema triggers to RN event props:
|
|
264
|
-
* onChange → onChangeText
|
|
265
|
-
* onSubmit → onSubmitEditing
|
|
266
|
-
* Strips `if`, `actions`, `onChange`, `onSubmit` before forwarding to RN.
|
|
267
|
-
*/
|
|
268
|
-
declare function TextInput({ if: _if, actions: _actions, onChange, onSubmit, ...rest }: PushFrameTextInputProps): react_jsx_runtime.JSX.Element;
|
|
269
|
-
|
|
270
|
-
interface PushFrameFlatListProps<T = unknown> extends Omit<FlatListProps<T>, 'data' | 'horizontal'> {
|
|
271
|
-
if?: string;
|
|
272
|
-
actions?: Action[];
|
|
273
|
-
/**
|
|
274
|
-
* Resolved array of items. Populated by RecursiveRenderer from the
|
|
275
|
-
* `items` binding expression on the schema node.
|
|
276
|
-
*/
|
|
277
|
-
items?: T[];
|
|
278
|
-
/**
|
|
279
|
-
* "vertical" (default) or "horizontal". Maps to RN `horizontal` boolean.
|
|
280
|
-
*/
|
|
281
|
-
direction?: 'vertical' | 'horizontal';
|
|
282
|
-
/**
|
|
283
|
-
* Number of columns for grid layouts. Forwarded directly to RN FlatList.
|
|
284
|
-
*/
|
|
285
|
-
numColumns?: number;
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Thin wrapper over React Native FlatList.
|
|
289
|
-
* RecursiveRenderer handles this type specially — it resolves `items` from
|
|
290
|
-
* a binding expression and constructs the `renderItem` per-item context.
|
|
291
|
-
*
|
|
292
|
-
* This component maps Pushframe props to RN FlatList props and strips
|
|
293
|
-
* Pushframe-specific props before forwarding.
|
|
294
|
-
*/
|
|
295
|
-
declare function FlatList<T = unknown>({ if: _if, actions: _actions, items, direction, numColumns, ...rest }: PushFrameFlatListProps<T>): react_jsx_runtime.JSX.Element;
|
|
296
|
-
|
|
297
|
-
interface PushFrameModalProps extends ModalProps {
|
|
298
|
-
if?: string;
|
|
299
|
-
actions?: Action[];
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Thin wrapper over React Native Modal.
|
|
303
|
-
* Strips `if`, `actions` before forwarding to RN.
|
|
304
|
-
*/
|
|
305
|
-
declare function Modal({ if: _if, actions: _actions, ...rest }: PushFrameModalProps): react_jsx_runtime.JSX.Element;
|
|
306
|
-
|
|
307
|
-
interface PushFrameActivityIndicatorProps extends ActivityIndicatorProps {
|
|
308
|
-
if?: string;
|
|
309
|
-
actions?: Action[];
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Thin wrapper over React Native ActivityIndicator.
|
|
313
|
-
* Strips `if`, `actions` before forwarding to RN.
|
|
314
|
-
*/
|
|
315
|
-
declare function ActivityIndicator({ if: _if, actions: _actions, ...rest }: PushFrameActivityIndicatorProps): react_jsx_runtime.JSX.Element;
|
|
316
|
-
|
|
317
|
-
interface PushFrameSwitchProps extends Omit<SwitchProps, 'onValueChange' | 'onChange'> {
|
|
318
|
-
if?: string;
|
|
319
|
-
actions?: Action[];
|
|
320
|
-
/**
|
|
321
|
-
* Schema trigger "onChange" — wired by RecursiveRenderer.
|
|
322
|
-
* Mapped to RN `onValueChange` by this component.
|
|
323
|
-
*/
|
|
324
|
-
onChange?: (value: boolean) => void;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Thin wrapper over React Native Switch.
|
|
328
|
-
* Maps Pushframe schema trigger to RN event prop:
|
|
329
|
-
* onChange → onValueChange
|
|
330
|
-
* Strips `if`, `actions`, `onChange` before forwarding to RN.
|
|
331
|
-
*/
|
|
332
|
-
declare function Switch({ if: _if, actions: _actions, onChange, ...rest }: PushFrameSwitchProps): react_jsx_runtime.JSX.Element;
|
|
333
|
-
|
|
334
|
-
interface PushFrameKeyboardAvoidingViewProps extends KeyboardAvoidingViewProps {
|
|
335
|
-
if?: string;
|
|
336
|
-
actions?: Action[];
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Thin wrapper over React Native KeyboardAvoidingView.
|
|
340
|
-
* Strips `if`, `actions` before forwarding to RN.
|
|
341
|
-
*/
|
|
342
|
-
declare function KeyboardAvoidingView({ if: _if, actions: _actions, ...rest }: PushFrameKeyboardAvoidingViewProps): react_jsx_runtime.JSX.Element;
|
|
343
|
-
|
|
344
|
-
interface PushFrameSafeAreaViewProps extends ViewProps {
|
|
345
|
-
if?: string;
|
|
346
|
-
actions?: Action[];
|
|
347
|
-
/**
|
|
348
|
-
* Edges to apply safe-area insets on.
|
|
349
|
-
* Forwarded to react-native-safe-area-context's SafeAreaView when available.
|
|
350
|
-
* Example: ['top', 'bottom']
|
|
351
|
-
*/
|
|
352
|
-
edges?: string[];
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Thin wrapper over SafeAreaView.
|
|
356
|
-
* Uses react-native-safe-area-context when available, RN core otherwise.
|
|
357
|
-
* Strips `if`, `actions` before forwarding; passes `edges` through to
|
|
358
|
-
* react-native-safe-area-context (ignored gracefully in the RN core fallback).
|
|
359
|
-
*/
|
|
360
|
-
declare function SafeAreaView({ if: _if, actions: _actions, ...rest }: PushFrameSafeAreaViewProps): react_jsx_runtime.JSX.Element;
|
|
361
|
-
|
|
362
|
-
interface PushFrameStatusBarProps extends StatusBarProps {
|
|
363
|
-
if?: string;
|
|
364
|
-
actions?: Action[];
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Thin wrapper over React Native StatusBar.
|
|
368
|
-
* Strips `if`, `actions` before forwarding to RN.
|
|
369
|
-
*/
|
|
370
|
-
declare function StatusBar({ if: _if, actions: _actions, ...rest }: PushFrameStatusBarProps): react_jsx_runtime.JSX.Element;
|
|
371
|
-
|
|
372
|
-
interface DispatchAction {
|
|
373
|
-
(actionName: string, payload?: Record<string, unknown>): void;
|
|
374
|
-
}
|
|
375
|
-
interface RecursiveRendererProps {
|
|
376
|
-
node: SchemaNode;
|
|
377
|
-
/** Current merged data context for binding resolution. */
|
|
378
|
-
context: Record<string, unknown>;
|
|
379
|
-
registry: ComponentRegistry;
|
|
380
|
-
/** Handles all actions — built-ins and host-app bubbling. Provided by the slot component. */
|
|
381
|
-
dispatchAction: DispatchAction;
|
|
382
|
-
/** Shown when a component type is not found in the registry. */
|
|
383
|
-
fallbackComponent?: React__default.ReactNode;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Stateless recursive renderer. Evaluates schema nodes and produces React elements.
|
|
387
|
-
*
|
|
388
|
-
* - Evaluates `if` expression (string or non-string); returns null when falsy
|
|
389
|
-
* - Handles `visible` prop: returns null when visible resolves to false
|
|
390
|
-
* - Handles FlatList nodes with per-item context injection via `itemTemplate`
|
|
391
|
-
* - Supports `data` (transformer) and `items` (legacy) as FlatList data source
|
|
392
|
-
* - Resolves all prop bindings against current context
|
|
393
|
-
* - Merges `_propValues` into child context (custom component prop injection)
|
|
394
|
-
* - Wires actions to component event handler props
|
|
395
|
-
* - Looks up component in registry; renders fallback or null when not found
|
|
396
|
-
* - Recurses into children
|
|
397
|
-
*/
|
|
398
|
-
declare function RecursiveRenderer({ node, context, registry, dispatchAction, fallbackComponent, }: RecursiveRendererProps): ReactElement | null;
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Binding resolver for PushFrame {{expression}} syntax.
|
|
402
|
-
*
|
|
403
|
-
* Rules:
|
|
404
|
-
* - A value that is entirely "{{expr}}" resolves to the bound value (any type)
|
|
405
|
-
* - A value with inline bindings "Hello {{user.name}}" resolves to a string
|
|
406
|
-
* - Unresolved paths return undefined — never throws
|
|
407
|
-
* - Non-string values are returned as-is
|
|
408
|
-
*/
|
|
409
|
-
/**
|
|
410
|
-
* Resolve a single prop value against context.
|
|
411
|
-
*
|
|
412
|
-
* - String values: check for full binding "{{expr}}" or inline bindings "Hello {{name}}"
|
|
413
|
-
* - Non-string values: returned as-is
|
|
414
|
-
*/
|
|
415
|
-
declare function resolveValue(value: unknown, context: Record<string, unknown>): unknown;
|
|
416
|
-
/**
|
|
417
|
-
* Resolve all values in a props map against the context.
|
|
418
|
-
* Recursively resolves nested objects and arrays.
|
|
419
|
-
*/
|
|
420
|
-
declare function resolveProps(props: Record<string, unknown> | undefined, context: Record<string, unknown>): Record<string, unknown>;
|
|
421
|
-
/**
|
|
422
|
-
* Recursively resolve binding expressions in a value (including nested objects/arrays).
|
|
423
|
-
*/
|
|
424
|
-
declare function resolveDeep(value: unknown, context: Record<string, unknown>): unknown;
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Evaluate the `if` expression of a SchemaNode against the current context.
|
|
428
|
-
*
|
|
429
|
-
* Returns true → node should render
|
|
430
|
-
* Returns false → node (and its entire subtree) should be skipped
|
|
431
|
-
*
|
|
432
|
-
* Falsy values: false, null, undefined, 0, "" all hide the node.
|
|
433
|
-
* When `ifExpr` is undefined/null the node always renders.
|
|
434
|
-
*
|
|
435
|
-
* Accepts `unknown` to match the transformer's `if?: unknown` output:
|
|
436
|
-
* - String values are resolved as {{}} binding expressions
|
|
437
|
-
* - Non-string values (boolean, number, null) are coerced directly
|
|
438
|
-
*/
|
|
439
|
-
declare function evaluateIf(ifExpr: unknown, context: Record<string, unknown>): boolean;
|
|
440
|
-
|
|
441
|
-
interface PushFrameScrollViewProps extends ScrollViewProps {
|
|
442
|
-
if?: string;
|
|
443
|
-
actions?: Action[];
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Thin wrapper over React Native ScrollView.
|
|
447
|
-
* Forwards ref to support programmatic scrolling (e.g. scroll-to action).
|
|
448
|
-
* Strips `if`, `actions` before forwarding to RN.
|
|
449
|
-
*/
|
|
450
|
-
declare const ScrollView: React__default.ForwardRefExoticComponent<PushFrameScrollViewProps & React__default.RefAttributes<ScrollView$1>>;
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Craft.js → PushFrame SDUI transformer
|
|
454
|
-
*
|
|
455
|
-
* Converts a Craft.js editor schema (produced by the dashboard) into the
|
|
456
|
-
* SDUINode tree consumed by the SDK's RecursiveRenderer at runtime.
|
|
457
|
-
*
|
|
458
|
-
* This module is intended for use by the backend/service layer or the
|
|
459
|
-
* dashboard — it is NOT executed inside the React Native app at runtime.
|
|
460
|
-
*/
|
|
461
|
-
|
|
462
|
-
type CraftNode = {
|
|
463
|
-
type: {
|
|
464
|
-
resolvedName: string;
|
|
465
|
-
};
|
|
466
|
-
props?: Record<string, unknown>;
|
|
467
|
-
nodes?: string[];
|
|
468
|
-
parent?: string;
|
|
469
|
-
};
|
|
470
|
-
type CraftSchema = Record<string, CraftNode>;
|
|
471
|
-
/**
|
|
472
|
-
* The SDUI node shape produced by this transformer and consumed by the SDK's
|
|
473
|
-
* RecursiveRenderer. Aligned with `SchemaNode` from the SDK context.
|
|
474
|
-
*/
|
|
475
|
-
interface SDUINode extends SchemaNode {
|
|
476
|
-
id: string;
|
|
477
|
-
type: string;
|
|
478
|
-
props: Record<string, unknown>;
|
|
479
|
-
children?: SDUINode[];
|
|
480
|
-
/** FlatList per-item render template. */
|
|
481
|
-
itemTemplate?: SDUINode;
|
|
482
|
-
/** Conditional render expression. Falsy → node is hidden. */
|
|
483
|
-
if?: unknown;
|
|
484
|
-
actions?: Action[];
|
|
485
|
-
}
|
|
486
|
-
interface CustomComponentDef {
|
|
487
|
-
rootNodeId: string;
|
|
488
|
-
nodes: CraftSchema;
|
|
489
|
-
}
|
|
490
|
-
type CustomComponentsMap = Record<string, CustomComponentDef>;
|
|
491
|
-
/**
|
|
492
|
-
* Convert a Craft.js editor schema into an SDUINode tree ready for the SDK's
|
|
493
|
-
* RecursiveRenderer.
|
|
494
|
-
*
|
|
495
|
-
* @param craftJson - The full Craft.js node map (keyed by node ID, must include "ROOT").
|
|
496
|
-
* @param customComponents - Optional map of reusable component definitions.
|
|
497
|
-
* @returns The root SDUINode.
|
|
498
|
-
*/
|
|
499
|
-
declare function transformCraftToSDUI(craftJson: CraftSchema, customComponents?: CustomComponentsMap): SDUINode;
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* The PushFrame namespace. Import this as the single entry-point for the SDK.
|
|
503
|
-
*
|
|
504
|
-
* Slot components:
|
|
505
|
-
* - PushFrame.Provider — wraps the app, initialises registry and context
|
|
506
|
-
* - PushFrame.Screen — full-page slot (fetches /screens/:name, applies flex:1)
|
|
507
|
-
* - PushFrame.Component — inline slot (fetches /components/:name)
|
|
508
|
-
*
|
|
509
|
-
* Primitives (used internally by RecursiveRenderer, available for direct use):
|
|
510
|
-
* - PushFrame.Text, PushFrame.View, PushFrame.ScrollView, PushFrame.Image
|
|
511
|
-
* - PushFrame.Pressable, PushFrame.TextInput, PushFrame.FlatList
|
|
512
|
-
* - PushFrame.Modal, PushFrame.ActivityIndicator, PushFrame.Switch
|
|
513
|
-
* - PushFrame.KeyboardAvoidingView, PushFrame.SafeAreaView, PushFrame.StatusBar
|
|
514
|
-
*/
|
|
515
|
-
declare const PushFrame: {
|
|
516
|
-
readonly Provider: typeof PushFrameProvider;
|
|
517
|
-
readonly Screen: typeof PushFrameScreen;
|
|
518
|
-
readonly Component: typeof PushFrameComponent;
|
|
519
|
-
readonly Text: typeof Text;
|
|
520
|
-
readonly View: typeof View;
|
|
521
|
-
readonly ScrollView: React.ForwardRefExoticComponent<PushFrameScrollViewProps & React.RefAttributes<react_native.ScrollView>>;
|
|
522
|
-
readonly Image: typeof Image;
|
|
523
|
-
readonly Pressable: typeof Pressable;
|
|
524
|
-
readonly TextInput: typeof TextInput;
|
|
525
|
-
readonly FlatList: typeof FlatList;
|
|
526
|
-
readonly Modal: typeof Modal;
|
|
527
|
-
readonly ActivityIndicator: typeof ActivityIndicator;
|
|
528
|
-
readonly Switch: typeof Switch;
|
|
529
|
-
readonly KeyboardAvoidingView: typeof KeyboardAvoidingView;
|
|
530
|
-
readonly SafeAreaView: typeof SafeAreaView;
|
|
531
|
-
readonly StatusBar: typeof StatusBar;
|
|
532
|
-
};
|
|
533
|
-
|
|
534
|
-
export { type Action, ActivityIndicator, type BottomSheetPayload, ComponentRegistry, type CraftNode, type CraftSchema, type CustomComponentDef, type CustomComponentsMap, type DispatchAction, FlatList, type FlatListSchemaNode, Image, KeyboardAvoidingView, Modal, Pressable, PushFrame, type PushFrameActivityIndicatorProps, PushFrameComponent, PushFrameContext, type PushFrameContextValue, type PushFrameFlatListProps, type PushFrameImageProps, type PushFrameKeyboardAvoidingViewProps, type PushFrameModalProps, type PushFramePressableProps, PushFrameProvider, type PushFrameProviderProps, type PushFrameSafeAreaViewProps, PushFrameScreen, type PushFrameScrollViewProps, type PushFrameSlotProps, type PushFrameStatusBarProps, type PushFrameSwitchProps, type PushFrameTextInputProps, type PushFrameTextProps, type PushFrameViewProps, RecursiveRenderer, type RecursiveRendererProps, type SDUINode, SafeAreaView, type SchemaNode, type ScrollToPayload, ScrollView, StatusBar, Switch, Text, TextInput, type ToastPayload, View, evaluateIf, resolveDeep, resolveProps, resolveValue, transformCraftToSDUI, usePushFrameContext };
|