@pushframe/sdk 0.1.1 → 0.1.3
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/dist/index.d.ts +89 -13
- package/dist/index.js +810 -26
- package/dist/index.js.map +1 -1
- package/package.json +14 -12
- package/dist/index.d.mts +0 -458
- package/dist/index.mjs +0 -758
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -127,15 +127,23 @@ declare class ComponentRegistry {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
interface SchemaNode {
|
|
130
|
+
id?: string;
|
|
130
131
|
type: string;
|
|
131
132
|
props?: Record<string, unknown>;
|
|
132
133
|
children?: SchemaNode[];
|
|
134
|
+
/** Per-item render template for flatlist nodes. */
|
|
135
|
+
itemTemplate?: SchemaNode;
|
|
133
136
|
actions?: Action[];
|
|
134
|
-
|
|
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;
|
|
135
143
|
}
|
|
136
144
|
interface FlatListSchemaNode extends SchemaNode {
|
|
137
145
|
type: 'flatlist';
|
|
138
|
-
|
|
146
|
+
itemTemplate: SchemaNode;
|
|
139
147
|
}
|
|
140
148
|
interface Action {
|
|
141
149
|
trigger: string;
|
|
@@ -179,17 +187,22 @@ interface PushFrameTextProps extends TextProps {
|
|
|
179
187
|
/** Pushframe: converted to handlers by RecursiveRenderer before component renders. */
|
|
180
188
|
actions?: Action[];
|
|
181
189
|
/**
|
|
182
|
-
* Text content
|
|
183
|
-
* Pushframe
|
|
190
|
+
* Text content. Takes precedence over `children`.
|
|
191
|
+
* Pushframe schema convention: use `value`.
|
|
184
192
|
*/
|
|
185
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;
|
|
186
199
|
}
|
|
187
200
|
/**
|
|
188
201
|
* Thin wrapper over React Native Text.
|
|
189
|
-
* Strips `if`, `actions` before forwarding to RN.
|
|
190
|
-
*
|
|
202
|
+
* Strips `if`, `actions`, `content` before forwarding to RN.
|
|
203
|
+
* Display priority: value > content > children (children remain in rest).
|
|
191
204
|
*/
|
|
192
|
-
declare function Text({ if: _if, actions: _actions, value,
|
|
205
|
+
declare function Text({ if: _if, actions: _actions, value, content, ...rest }: PushFrameTextProps): react_jsx_runtime.JSX.Element;
|
|
193
206
|
|
|
194
207
|
interface PushFrameViewProps extends ViewProps {
|
|
195
208
|
if?: string;
|
|
@@ -331,11 +344,18 @@ declare function KeyboardAvoidingView({ if: _if, actions: _actions, ...rest }: P
|
|
|
331
344
|
interface PushFrameSafeAreaViewProps extends ViewProps {
|
|
332
345
|
if?: string;
|
|
333
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[];
|
|
334
353
|
}
|
|
335
354
|
/**
|
|
336
355
|
* Thin wrapper over SafeAreaView.
|
|
337
356
|
* Uses react-native-safe-area-context when available, RN core otherwise.
|
|
338
|
-
* Strips `if`, `actions` before forwarding
|
|
357
|
+
* Strips `if`, `actions` before forwarding; passes `edges` through to
|
|
358
|
+
* react-native-safe-area-context (ignored gracefully in the RN core fallback).
|
|
339
359
|
*/
|
|
340
360
|
declare function SafeAreaView({ if: _if, actions: _actions, ...rest }: PushFrameSafeAreaViewProps): react_jsx_runtime.JSX.Element;
|
|
341
361
|
|
|
@@ -365,9 +385,12 @@ interface RecursiveRendererProps {
|
|
|
365
385
|
/**
|
|
366
386
|
* Stateless recursive renderer. Evaluates schema nodes and produces React elements.
|
|
367
387
|
*
|
|
368
|
-
* - Evaluates `if` expression; returns null when falsy
|
|
369
|
-
* - Handles
|
|
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
|
|
370
392
|
* - Resolves all prop bindings against current context
|
|
393
|
+
* - Merges `_propValues` into child context (custom component prop injection)
|
|
371
394
|
* - Wires actions to component event handler props
|
|
372
395
|
* - Looks up component in registry; renders fallback or null when not found
|
|
373
396
|
* - Recurses into children
|
|
@@ -407,9 +430,13 @@ declare function resolveDeep(value: unknown, context: Record<string, unknown>):
|
|
|
407
430
|
* Returns false → node (and its entire subtree) should be skipped
|
|
408
431
|
*
|
|
409
432
|
* Falsy values: false, null, undefined, 0, "" all hide the node.
|
|
410
|
-
* When `ifExpr` is undefined the node always renders.
|
|
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
|
|
411
438
|
*/
|
|
412
|
-
declare function evaluateIf(ifExpr:
|
|
439
|
+
declare function evaluateIf(ifExpr: unknown, context: Record<string, unknown>): boolean;
|
|
413
440
|
|
|
414
441
|
interface PushFrameScrollViewProps extends ScrollViewProps {
|
|
415
442
|
if?: string;
|
|
@@ -422,6 +449,55 @@ interface PushFrameScrollViewProps extends ScrollViewProps {
|
|
|
422
449
|
*/
|
|
423
450
|
declare const ScrollView: React__default.ForwardRefExoticComponent<PushFrameScrollViewProps & React__default.RefAttributes<ScrollView$1>>;
|
|
424
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
|
+
|
|
425
501
|
/**
|
|
426
502
|
* The PushFrame namespace. Import this as the single entry-point for the SDK.
|
|
427
503
|
*
|
|
@@ -455,4 +531,4 @@ declare const PushFrame: {
|
|
|
455
531
|
readonly StatusBar: typeof StatusBar;
|
|
456
532
|
};
|
|
457
533
|
|
|
458
|
-
export { type Action, ActivityIndicator, type BottomSheetPayload, ComponentRegistry, 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, SafeAreaView, type SchemaNode, type ScrollToPayload, ScrollView, StatusBar, Switch, Text, TextInput, type ToastPayload, View, evaluateIf, resolveDeep, resolveProps, resolveValue, usePushFrameContext };
|
|
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 };
|