import { ComponentType } from 'react' import { FIXME, RJT_CONSTANT, RJT_CONSTANT_TYPE, RJT_OPERATION, RJT_OPERATION_TYPE, RJT_ACTION, RJT_TEMPLATE, RJT_SERIALIZABLE, RJT_SERIALIZED_ACTION } from './types' export const Serializable = (name: string, Comp: ComponentType): RJT_SERIALIZABLE => { const result = Comp as unknown as RJT_SERIALIZABLE result.__RJT_TYPE__ = '__RJT_COMPONENT__' result.__RJT_NAME__ = name return result } export const Template = (Comp: ComponentType): RJT_TEMPLATE => { const result = Comp as unknown as RJT_TEMPLATE result.__RJT_TYPE__ = '__RJT_TEMPLATE__' return result } export const Action = void, P extends unknown[]>(name: string, ...args: P): RJT_ACTION => { const action: RJT_SERIALIZED_ACTION = { type: '__RJT_ACTION__', name, params: args } return action as unknown as RJT_ACTION } export const Constant = (name: string, type: T): RJT_CONSTANT => { return { type: '__RJT_CONSTANT__', name, kind: type } } export const Operation = ( operation: T, ...operands: RJT_OPERATION['operands'] ): FIXME => { return { type: '__RJT_OPERATION__', operation, operands } }