catalog.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { z } from "zod";
  2. import { defineCatalog } from "@json-render/core";
  3. import { schema } from "@json-render/react-native/schema";
  4. import {
  5. standardComponentDefinitions,
  6. standardActionDefinitions,
  7. } from "@json-render/react-native/catalog";
  8. /**
  9. * App-specific custom rules for the AI.
  10. *
  11. * Generic React Native rules (layout, tabs, navigation, element integrity)
  12. * are baked into the @json-render/react-native schema as defaultRules.
  13. * Core concepts (initial state, $path, Repeat, pushState/removeState)
  14. * are covered by the core system prompt.
  15. *
  16. * Only app-specific preferences belong here.
  17. */
  18. export const customRules = [
  19. // Placeholder images using Picsum (free, no API key)
  20. 'Image props: { "src": "https://picsum.photos/WIDTH/HEIGHT?random=N" } - use Picsum for any placeholder or example images',
  21. "Use different random numbers for each image to get different photos (e.g., ?random=1, ?random=2, ?random=3)",
  22. "Picsum provides random professional stock photos - great for avatars, hero images, product shots, and backgrounds",
  23. 'Avatar props: { "src": "https://picsum.photos/100/100?random=N" } - use Picsum for avatar images too',
  24. // Icons vs emojis (app uses Ionicons via the custom Icon component)
  25. "CRITICAL: NEVER use emoji characters for UI icons, action buttons, navigation items, or indicators. ALWAYS use the Icon component instead.",
  26. "The Icon component uses Ionicons. Common icon names: heart, heart-outline, chatbubble-outline, share-social-outline, bookmark-outline, bookmark, home, home-outline, search, person, person-outline, add, close, checkmark, ellipsis-horizontal, ellipsis-vertical, camera-outline, notifications-outline, settings-outline, send, arrow-back, arrow-forward, chevron-back, chevron-forward, star, star-outline, eye-outline, eye-off-outline, trash-outline, create-outline, refresh, lock-closed-outline, mail-outline, call-outline, location-outline, time-outline, play, pause, image-outline, menu, filter-outline, globe-outline, link-outline, cloud-outline, download-outline, share-outline.",
  27. "Emojis ARE allowed inside user-generated content such as comment text, post captions, chat messages, and status text - just like real social apps. Only UI chrome (buttons, tabs, indicators) must use the Icon component.",
  28. ];
  29. /**
  30. * React Native catalog
  31. *
  32. * Uses all standard components and actions from @json-render/react-native,
  33. * plus an Icon component powered by Ionicons (@expo/vector-icons).
  34. */
  35. export const catalog = defineCatalog(schema, {
  36. components: {
  37. ...standardComponentDefinitions,
  38. Icon: {
  39. props: z.object({
  40. name: z.string(),
  41. size: z.number().nullable(),
  42. color: z.string().nullable(),
  43. }),
  44. slots: [],
  45. description:
  46. "Icon display using Ionicons. Use for action buttons, navigation items, and indicators. ALWAYS use this instead of emoji characters for UI icons. Use Ionicons naming convention (e.g. heart, heart-outline, chatbubble-outline, share-social-outline).",
  47. example: { name: "heart-outline", size: 24, color: "#007AFF" },
  48. },
  49. },
  50. actions: standardActionDefinitions,
  51. });