{"version":3,"file":"index.cjs","sources":["../../../../../src/sdk/index.ts"],"sourcesContent":["/**\r\n * LLM2UI SDK Entry Point\r\n * \r\n * Main entry point for the LLM2UI JSON Renderer SDK.\r\n * Provides a simple API for rendering UI from JSON schemas,\r\n * similar to amis low-code framework.\r\n * \r\n * @module @llm2ui/renderer\r\n * @see Requirements 14.1, 14.2, 14.4\r\n * \r\n * @example\r\n * ```typescript\r\n * import { render, createRenderer, LLM2UI } from '@llm2ui/renderer';\r\n * \r\n * // Simple render\r\n * render(schema, document.getElementById('app'));\r\n * \r\n * // With options\r\n * const renderer = createRenderer({ theme: 'dark' });\r\n * renderer.render(schema, container);\r\n * \r\n * // React component\r\n * <LLM2UI schema={schema} onEvent={handleEvent} />\r\n * ```\r\n */\r\n\r\n// Re-export core types\r\nexport type {\r\n  UISchema,\r\n  UIComponent,\r\n  DataContext,\r\n  EventBinding,\r\n  EventAction,\r\n  StyleProps,\r\n  ValidationResult,\r\n  ValidationError,\r\n} from '../types';\r\n\r\n// Re-export component registry types\r\nexport type {\r\n  PlatformType,\r\n  ComponentCategory,\r\n  ComponentDefinition,\r\n  PropSchema,\r\n  ComponentExample,\r\n} from '../lib/component-registry';\r\n\r\n// Re-export renderer types\r\nexport type {\r\n  EventHandler,\r\n  RenderOptions,\r\n  UIRendererProps,\r\n} from '../lib/renderer';\r\n\r\n// Re-export core functionality\r\nexport {\r\n  // Renderer\r\n  render as renderToReact,\r\n  UIRenderer,\r\n  useRenderer,\r\n} from '../lib/renderer';\r\n\r\nexport {\r\n  // Component Registry\r\n  ComponentRegistry,\r\n  defaultRegistry,\r\n  validateComponentDefinition,\r\n} from '../lib/component-registry';\r\n\r\nexport {\r\n  // Schema Generator\r\n  SchemaGenerator,\r\n  createSchemaGenerator,\r\n} from '../lib/schema-generator';\r\n\r\nexport type {\r\n  SchemaGeneratorOptions,\r\n  GeneratedSchema,\r\n} from '../lib/schema-generator';\r\n\r\nexport {\r\n  // Template Manager\r\n  TemplateManager,\r\n  defaultTemplateManager,\r\n} from '../lib/template-manager';\r\n\r\nexport type {\r\n  TemplateLayer,\r\n  ComponentTemplate,\r\n} from '../lib/template-manager';\r\n\r\nexport {\r\n  // Platform Adapter\r\n  PlatformAdapter,\r\n  createPlatformAdapter,\r\n} from '../lib/platform-adapter';\r\n\r\nexport type {\r\n  PlatformMapping,\r\n} from '../lib/platform-adapter';\r\n\r\nexport {\r\n  // Validation\r\n  validateJSON,\r\n  validateUISchema,\r\n} from '../lib/validation';\r\n\r\nexport {\r\n  // Data Binding\r\n  parseBindingExpression,\r\n  resolveBindings,\r\n  extractDataFields,\r\n} from '../lib/data-binding';\r\n\r\nexport {\r\n  // Serialization\r\n  serialize,\r\n  deserialize,\r\n  schemasEqual,\r\n} from '../lib/serialization';\r\n\r\nexport {\r\n  // shadcn Components\r\n  registerShadcnComponents,\r\n  initializeDefaultRegistry,\r\n} from '../lib/shadcn-components';\r\n\r\n// SDK-specific types and interfaces\r\n\r\nimport type { ComponentType } from 'react';\r\nimport { createElement } from 'react';\r\nimport { createRoot, type Root } from 'react-dom/client';\r\nimport type { UISchema } from '../types';\r\nimport type { PlatformType } from '../lib/component-registry';\r\nimport { UIRenderer, type EventHandler } from '../lib/renderer';\r\nimport { defaultRegistry, ComponentRegistry } from '../lib/component-registry';\r\nimport { initializeDefaultRegistry } from '../lib/shadcn-components';\r\n\r\n/**\r\n * Custom component definition for SDK registration\r\n * Simplified version of ComponentDefinition for external use\r\n */\r\nexport interface CustomComponentDefinition {\r\n  /** Component name/type identifier */\r\n  name: string;\r\n  /** The actual React component */\r\n  component: ComponentType<Record<string, unknown>>;\r\n  /** Component description */\r\n  description?: string;\r\n  /** Component category for organization */\r\n  category?: 'input' | 'layout' | 'display' | 'feedback' | 'navigation' | string;\r\n  /** Props schema for validation */\r\n  propsSchema?: Record<string, {\r\n    type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function';\r\n    required?: boolean;\r\n    default?: unknown;\r\n    description?: string;\r\n    enum?: string[];\r\n  }>;\r\n  /** Searchable tags */\r\n  tags?: string[];\r\n  /** Icon name */\r\n  icon?: string;\r\n}\r\n\r\n/**\r\n * SDK Renderer Options\r\n * Configuration options for creating a renderer instance\r\n */\r\nexport interface RendererOptions {\r\n  /** Target platform for rendering */\r\n  platform?: PlatformType;\r\n  /** Theme mode */\r\n  theme?: 'light' | 'dark';\r\n  /** Locale for internationalization */\r\n  locale?: string;\r\n  /** Global event handler callback */\r\n  onEvent?: EventHandler;\r\n  /** Custom components to register (simple format) */\r\n  customComponents?: Record<string, ComponentType<Record<string, unknown>>>;\r\n  /** Custom component definitions with full metadata */\r\n  customComponentDefinitions?: CustomComponentDefinition[];\r\n  /** Component registry to use (defaults to defaultRegistry) */\r\n  registry?: ComponentRegistry;\r\n  /** Whether to show error boundaries */\r\n  showErrors?: boolean;\r\n}\r\n\r\n/**\r\n * UI Event emitted by the renderer\r\n */\r\nexport interface UIEvent {\r\n  /** Event type */\r\n  type: string;\r\n  /** Component ID that triggered the event */\r\n  componentId: string;\r\n  /** Event payload */\r\n  payload?: unknown;\r\n  /** Original DOM event */\r\n  originalEvent?: Event;\r\n}\r\n\r\n/**\r\n * Event listener function type\r\n */\r\nexport type EventListener = (event: UIEvent) => void;\r\n\r\n/**\r\n * LLM2UI Renderer Instance\r\n * Main renderer class for managing UI lifecycle\r\n */\r\nexport class LLM2UIRenderer {\r\n  private root: Root | null = null;\r\n  private container: HTMLElement | null = null;\r\n  private currentSchema: UISchema | null = null;\r\n  private options: RendererOptions;\r\n  private eventListeners: Map<string, Set<EventListener>> = new Map();\r\n  private registry: ComponentRegistry;\r\n  private initialized: boolean = false;\r\n  private registeredCustomComponents: Set<string> = new Set();\r\n\r\n  constructor(options: RendererOptions = {}) {\r\n    this.options = options;\r\n    this.registry = options.registry || defaultRegistry;\r\n  }\r\n\r\n  /**\r\n   * Initialize the renderer (register default components)\r\n   */\r\n  private ensureInitialized(): void {\r\n    if (this.initialized) return;\r\n    \r\n    // Initialize default shadcn components if using default registry\r\n    if (this.registry === defaultRegistry) {\r\n      initializeDefaultRegistry();\r\n    }\r\n\r\n    // Register custom components if provided (simple format)\r\n    if (this.options.customComponents) {\r\n      for (const [name, component] of Object.entries(this.options.customComponents)) {\r\n        this.registerComponent({\r\n          name,\r\n          component,\r\n          description: `Custom component: ${name}`,\r\n        });\r\n      }\r\n    }\r\n\r\n    // Register custom component definitions if provided (full format)\r\n    if (this.options.customComponentDefinitions) {\r\n      for (const definition of this.options.customComponentDefinitions) {\r\n        this.registerComponent(definition);\r\n      }\r\n    }\r\n\r\n    this.initialized = true;\r\n  }\r\n\r\n  /**\r\n   * Register a custom component\r\n   * @param definition - The custom component definition\r\n   * @throws Error if the component name is invalid\r\n   * \r\n   * @example\r\n   * ```typescript\r\n   * renderer.registerComponent({\r\n   *   name: 'MyButton',\r\n   *   component: MyButtonComponent,\r\n   *   description: 'A custom button component',\r\n   *   category: 'input',\r\n   *   propsSchema: {\r\n   *     variant: { type: 'string', enum: ['primary', 'secondary'] },\r\n   *     disabled: { type: 'boolean', default: false }\r\n   *   }\r\n   * });\r\n   * ```\r\n   */\r\n  registerComponent(definition: CustomComponentDefinition): void {\r\n    if (!definition.name || typeof definition.name !== 'string') {\r\n      throw new Error('Component name is required and must be a string');\r\n    }\r\n\r\n    if (!definition.component) {\r\n      throw new Error('Component is required');\r\n    }\r\n\r\n    try {\r\n      this.registry.register({\r\n        name: definition.name,\r\n        component: definition.component,\r\n        description: definition.description || `Custom component: ${definition.name}`,\r\n        category: definition.category,\r\n        propsSchema: definition.propsSchema,\r\n        tags: definition.tags,\r\n        icon: definition.icon,\r\n      });\r\n      this.registeredCustomComponents.add(definition.name);\r\n    } catch (error) {\r\n      // Re-throw with more context\r\n      throw new Error(`Failed to register component \"${definition.name}\": ${error instanceof Error ? error.message : String(error)}`);\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Register multiple custom components at once\r\n   * @param definitions - Array of custom component definitions\r\n   * \r\n   * @example\r\n   * ```typescript\r\n   * renderer.registerComponents([\r\n   *   { name: 'MyButton', component: MyButton },\r\n   *   { name: 'MyInput', component: MyInput, category: 'input' }\r\n   * ]);\r\n   * ```\r\n   */\r\n  registerComponents(definitions: CustomComponentDefinition[]): void {\r\n    for (const definition of definitions) {\r\n      this.registerComponent(definition);\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Unregister a custom component\r\n   * @param name - The component name to unregister\r\n   * @returns True if the component was unregistered\r\n   * \r\n   * @example\r\n   * ```typescript\r\n   * renderer.unregisterComponent('MyButton');\r\n   * ```\r\n   */\r\n  unregisterComponent(name: string): boolean {\r\n    if (!this.registeredCustomComponents.has(name)) {\r\n      return false;\r\n    }\r\n\r\n    const result = this.registry.unregister(name);\r\n    if (result) {\r\n      this.registeredCustomComponents.delete(name);\r\n    }\r\n    return result;\r\n  }\r\n\r\n  /**\r\n   * Check if a custom component is registered\r\n   * @param name - The component name to check\r\n   * @returns True if the component is registered\r\n   */\r\n  hasComponent(name: string): boolean {\r\n    return this.registry.has(name);\r\n  }\r\n\r\n  /**\r\n   * Get all registered custom component names\r\n   * @returns Array of custom component names registered via this renderer\r\n   */\r\n  getCustomComponentNames(): string[] {\r\n    return Array.from(this.registeredCustomComponents);\r\n  }\r\n\r\n  /**\r\n   * Get the component registry\r\n   * @returns The component registry instance\r\n   */\r\n  getRegistry(): ComponentRegistry {\r\n    return this.registry;\r\n  }\r\n\r\n  /**\r\n   * Render a UISchema to a container element\r\n   * @param schema - The UISchema to render\r\n   * @param container - Target DOM container\r\n   */\r\n  render(schema: UISchema, container: HTMLElement): void {\r\n    this.ensureInitialized();\r\n    \r\n    // Clean up existing render if different container\r\n    if (this.container && this.container !== container) {\r\n      this.destroy();\r\n    }\r\n\r\n    this.container = container;\r\n    this.currentSchema = schema;\r\n\r\n    // Create React root if needed\r\n    if (!this.root) {\r\n      this.root = createRoot(container);\r\n    }\r\n\r\n    // Create event handler that emits to listeners\r\n    const handleEvent: EventHandler = (action, event, componentId) => {\r\n      // Call global onEvent handler\r\n      if (this.options.onEvent) {\r\n        this.options.onEvent(action, event, componentId);\r\n      }\r\n\r\n      // Emit to registered listeners\r\n      const uiEvent: UIEvent = {\r\n        type: action.type,\r\n        componentId,\r\n        payload: action,\r\n        originalEvent: event.nativeEvent,\r\n      };\r\n\r\n      this.emit(action.type, uiEvent);\r\n      this.emit('*', uiEvent); // Wildcard listener\r\n    };\r\n\r\n    // Render the UIRenderer component\r\n    this.root.render(\r\n      createElement(UIRenderer, {\r\n        schema,\r\n        registry: this.registry,\r\n        onEvent: handleEvent,\r\n        showErrors: this.options.showErrors ?? false,\r\n      })\r\n    );\r\n  }\r\n\r\n  /**\r\n   * Update the rendered UI with a new schema\r\n   * @param schema - New UISchema to render\r\n   */\r\n  update(schema: UISchema): void {\r\n    if (!this.container) {\r\n      throw new Error('Renderer not initialized. Call render() first.');\r\n    }\r\n    this.render(schema, this.container);\r\n  }\r\n\r\n  /**\r\n   * Destroy the renderer and clean up resources\r\n   */\r\n  destroy(): void {\r\n    if (this.root) {\r\n      this.root.unmount();\r\n      this.root = null;\r\n    }\r\n    this.container = null;\r\n    this.currentSchema = null;\r\n    this.eventListeners.clear();\r\n    // Note: We don't unregister custom components on destroy\r\n    // as they might be used by other renderers sharing the same registry\r\n  }\r\n\r\n  /**\r\n   * Register an event listener\r\n   * @param event - Event type to listen for (or '*' for all events)\r\n   * @param handler - Event handler function\r\n   */\r\n  on(event: string, handler: EventListener): void {\r\n    if (!this.eventListeners.has(event)) {\r\n      this.eventListeners.set(event, new Set());\r\n    }\r\n    this.eventListeners.get(event)!.add(handler);\r\n  }\r\n\r\n  /**\r\n   * Remove an event listener\r\n   * @param event - Event type\r\n   * @param handler - Handler to remove (if omitted, removes all handlers for event)\r\n   */\r\n  off(event: string, handler?: EventListener): void {\r\n    if (!handler) {\r\n      this.eventListeners.delete(event);\r\n      return;\r\n    }\r\n\r\n    const listeners = this.eventListeners.get(event);\r\n    if (listeners) {\r\n      listeners.delete(handler);\r\n      if (listeners.size === 0) {\r\n        this.eventListeners.delete(event);\r\n      }\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Emit an event to registered listeners\r\n   */\r\n  private emit(event: string, uiEvent: UIEvent): void {\r\n    const listeners = this.eventListeners.get(event);\r\n    if (listeners) {\r\n      for (const listener of listeners) {\r\n        try {\r\n          listener(uiEvent);\r\n        } catch (error) {\r\n          console.error(`Error in event listener for \"${event}\":`, error);\r\n        }\r\n      }\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Get the current schema\r\n   */\r\n  getSchema(): UISchema | null {\r\n    return this.currentSchema;\r\n  }\r\n\r\n  /**\r\n   * Get the container element\r\n   */\r\n  getContainer(): HTMLElement | null {\r\n    return this.container;\r\n  }\r\n\r\n  /**\r\n   * Check if renderer is mounted\r\n   */\r\n  isMounted(): boolean {\r\n    return this.root !== null && this.container !== null;\r\n  }\r\n}\r\n\r\n/**\r\n * Create a new renderer instance with options\r\n * @param options - Renderer configuration options\r\n * @returns LLM2UIRenderer instance\r\n * \r\n * @example\r\n * ```typescript\r\n * const renderer = createRenderer({\r\n *   theme: 'dark',\r\n *   onEvent: (action, event, componentId) => {\r\n *     console.log('Event:', action.type, componentId);\r\n *   }\r\n * });\r\n * \r\n * renderer.render(schema, document.getElementById('app'));\r\n * renderer.on('click', (event) => console.log('Clicked:', event.componentId));\r\n * ```\r\n */\r\nexport function createRenderer(options: RendererOptions = {}): LLM2UIRenderer {\r\n  return new LLM2UIRenderer(options);\r\n}\r\n\r\n/**\r\n * Register a custom component globally to the default registry\r\n * @param definition - The custom component definition\r\n * \r\n * @example\r\n * ```typescript\r\n * import { registerCustomComponent } from '@llm2ui/renderer';\r\n * \r\n * registerCustomComponent({\r\n *   name: 'MyButton',\r\n *   component: MyButtonComponent,\r\n *   description: 'A custom button component',\r\n *   category: 'input',\r\n *   propsSchema: {\r\n *     variant: { type: 'string', enum: ['primary', 'secondary'] }\r\n *   }\r\n * });\r\n * ```\r\n */\r\nexport function registerCustomComponent(definition: CustomComponentDefinition): void {\r\n  if (!definition.name || typeof definition.name !== 'string') {\r\n    throw new Error('Component name is required and must be a string');\r\n  }\r\n\r\n  if (!definition.component) {\r\n    throw new Error('Component is required');\r\n  }\r\n\r\n  defaultRegistry.register({\r\n    name: definition.name,\r\n    component: definition.component,\r\n    description: definition.description || `Custom component: ${definition.name}`,\r\n    category: definition.category,\r\n    propsSchema: definition.propsSchema,\r\n    tags: definition.tags,\r\n    icon: definition.icon,\r\n  });\r\n}\r\n\r\n/**\r\n * Register multiple custom components globally to the default registry\r\n * @param definitions - Array of custom component definitions\r\n * \r\n * @example\r\n * ```typescript\r\n * import { registerCustomComponents } from '@llm2ui/renderer';\r\n * \r\n * registerCustomComponents([\r\n *   { name: 'MyButton', component: MyButton },\r\n *   { name: 'MyInput', component: MyInput, category: 'input' }\r\n * ]);\r\n * ```\r\n */\r\nexport function registerCustomComponents(definitions: CustomComponentDefinition[]): void {\r\n  for (const definition of definitions) {\r\n    registerCustomComponent(definition);\r\n  }\r\n}\r\n\r\n/**\r\n * Unregister a custom component from the default registry\r\n * @param name - The component name to unregister\r\n * @returns True if the component was unregistered\r\n */\r\nexport function unregisterCustomComponent(name: string): boolean {\r\n  return defaultRegistry.unregister(name);\r\n}\r\n\r\n/**\r\n * Render a UISchema to a container element (convenience function)\r\n * Creates a renderer instance and renders immediately\r\n * \r\n * @param schema - The UISchema to render\r\n * @param container - Target DOM container\r\n * @param options - Optional renderer options\r\n * @returns LLM2UIRenderer instance for further control\r\n * \r\n * @example\r\n * ```typescript\r\n * const renderer = render(schema, document.getElementById('app'));\r\n * \r\n * // Later, update or destroy\r\n * renderer.update(newSchema);\r\n * renderer.destroy();\r\n * ```\r\n */\r\nexport function render(\r\n  schema: UISchema,\r\n  container: HTMLElement,\r\n  options: RendererOptions = {}\r\n): LLM2UIRenderer {\r\n  const renderer = createRenderer(options);\r\n  renderer.render(schema, container);\r\n  return renderer;\r\n}\r\n\r\n// Re-export React component wrapper\r\nexport { LLM2UI } from './react/LLM2UI';\r\nexport type { LLM2UIProps, LLM2UIEvent, LLM2UIEventCallback } from './react/LLM2UI';\r\n\r\n// Re-export Vue component wrapper (requires Vue 3 as peer dependency)\r\nexport {\r\n  LLM2UI as LLM2UIVue,\r\n  createLLM2UIComponent,\r\n  useLLM2UI,\r\n  isVueAvailable,\r\n} from './vue/LLM2UI';\r\nexport type {\r\n  LLM2UIProps as LLM2UIVueProps,\r\n  LLM2UIEmits as LLM2UIVueEmits,\r\n  LLM2UIEvent as LLM2UIVueEvent,\r\n} from './vue/LLM2UI';\r\n"],"names":["LLM2UIRenderer","options","__publicField","defaultRegistry","initializeDefaultRegistry","name","component","definition","error","definitions","result","schema","container","createRoot","handleEvent","action","event","componentId","uiEvent","createElement","UIRenderer","handler","listeners","listener","createRenderer","registerCustomComponent","registerCustomComponents","unregisterCustomComponent","render","renderer"],"mappings":"iaAmNO,MAAMA,CAAe,CAU1B,YAAYC,EAA2B,GAAI,CATnCC,EAAA,YAAoB,MACpBA,EAAA,iBAAgC,MAChCA,EAAA,qBAAiC,MACjCA,EAAA,gBACAA,EAAA,0BAAsD,KACtDA,EAAA,iBACAA,EAAA,mBAAuB,IACvBA,EAAA,sCAA8C,KAGpD,KAAK,QAAUD,EACf,KAAK,SAAWA,EAAQ,UAAYE,EAAAA,eACtC,CAKQ,mBAA0B,CAChC,GAAI,MAAK,YAQT,IALI,KAAK,WAAaA,mBACpBC,4BAAAA,EAIE,KAAK,QAAQ,iBACf,SAAW,CAACC,EAAMC,CAAS,IAAK,OAAO,QAAQ,KAAK,QAAQ,gBAAgB,EAC1E,KAAK,kBAAkB,CACrB,KAAAD,EACA,UAAAC,EACA,YAAa,qBAAqBD,CAAI,EAAA,CACvC,EAKL,GAAI,KAAK,QAAQ,2BACf,UAAWE,KAAc,KAAK,QAAQ,2BACpC,KAAK,kBAAkBA,CAAU,EAIrC,KAAK,YAAc,GACrB,CAqBA,kBAAkBA,EAA6C,CAC7D,GAAI,CAACA,EAAW,MAAQ,OAAOA,EAAW,MA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