import { inject, reactive, ref } from 'vue';
import { Engine, Project, Service, RegionWidgets, emitter } from '@vtj/engine';
let _project: Project;
export default function useCore() {
  const engine = inject<Engine>('$engine') as Engine;
  const region = inject<RegionWidgets>('$region') as RegionWidgets;
  if (!_project) {
    // @ts-ignore：实例实例化过深警告，暂时找不到解决方法
    _project = reactive<Project>(engine?.project as Project);
  }
  // const project = reactive<Project>(engine?.project as Project);
  const isDesignerActive = ref(true);
  return {
    engine,
    region,
    project: _project,
    service: engine?.service as Service,
    emitter,
    isDesignerActive
  };
}
