@rippling/pebble-sdui-mobile
v0.8.0
Published
Type-safe TypeScript mobile SDK for authoring json-render specs
Maintainers
Keywords
Readme
TypeScript SDK
The TypeScript SDK lets frontend and backend TypeScript code author type-safe SDUI specs for mobile. Platform packages export shared expression helpers, while generated catalog subpaths export components, actions, rendering, introspection, and validation.
Packages and imports
Core authoring helpers come from the platform package:
import { createSpec, equals, truthy, and_ } from '@rippling/pebble-sdui-mobile';Catalog-specific builders come from generated catalog subpaths:
import {
Button,
Text,
VStack,
render,
goBack,
validate,
} from '@rippling/pebble-sdui-mobile/catalogs/MobileGenUICatalogV1';Quick start
import { createSpec, truthy } from '@rippling/pebble-sdui-mobile';
import {
Button,
Text,
VStack,
render,
goBack,
validate,
} from '@rippling/pebble-sdui-mobile/catalogs/MobileGenUICatalogV1';
interface AppState {
userName: string;
isReady: boolean;
}
const { $state, $template } = createSpec<AppState>({
state: {
userName: 'Alice Nguyen',
isReady: true,
},
});
const root = VStack({
id: 'root',
props: { gap: 'space200' },
visible: truthy($state('isReady')),
children: [
Text({
props: {
text: $template`Hello ${$state('userName')}`,
},
}),
Button({
props: {
children: 'Continue',
appearance: 'primary',
},
on: {
press: goBack(),
},
}),
],
});
const spec = render({
root,
state: {
userName: 'Alice Nguyen',
isReady: true,
},
});
const errors = validate(spec);
if (errors.length > 0) {
throw new Error(`Invalid spec:\n${errors.join('\n')}`);
}Authoring steps
- Define a TypeScript state interface.
- Create state helpers with
createSpec<State>({ state }). - Import components/actions from one generated catalog subpath.
- Compose a component tree with generated builder functions.
- Use
$state(),$bindState(),$template,$cond(), andrepeat()for dynamic behavior. - Call the catalog
render({ root, state }). - Call the catalog
validate(spec)for generated, hand-authored, or externally consumed specs.
Human authoring benefits
- Editor autocomplete for component props and event names.
- TypeScript validates state paths and expression result types.
- Component builders enforce whether
childrenandonare allowed. - Action creators enforce action params.
- Catalog
render()stamps platform/catalog metadata.
LLM authoring benefits
- Catalog introspection gives exact names and schemas.
- SDK code is easier to validate and repair than raw JSON.
- Generated builders prevent many invalid tree shapes.
- Validation errors provide deterministic repair feedback.
