import * as React from 'react';
import { ReactAdaptor } from './react';
import { JimuAdaptor } from './jimu';
import { VueAdaptor } from './vue';

export function Adaptor({ instance, injectProps, global, meta }) {
  const { runtime } = instance.component;

  if (!runtime || runtime === 'react') {
    return (
      <ReactAdaptor instance={instance} injectProps={injectProps} global={global} meta={meta} />
    );
  }

  if (runtime === 'jimu') {
    return <JimuAdaptor instance={instance} global={global} meta={meta} />;
  }

  if (runtime === 'vue') {
    return <VueAdaptor instance={instance} injectProps={injectProps} global={global} meta={meta} />;
  }

  throw new Error(`Invalid runtime [${runtime}]`);
}
