21 lines
874 B
TypeScript
21 lines
874 B
TypeScript
import React from 'react';
|
|
import { createRoot } from 'react-dom/client';
|
|
import Editor from './Editor.tsx';
|
|
import { validateProject } from '../engine/schema.ts';
|
|
|
|
const root = document.getElementById('root')!;
|
|
async function start() {
|
|
const response = await fetch('./project.forma.json');
|
|
if (!response.ok) throw Error('Не удалось загрузить проект Forma');
|
|
const project = await response.json();
|
|
validateProject(project);
|
|
createRoot(root).render(<Editor initialProject={project} browserOnly />);
|
|
}
|
|
void start().catch((error) => {
|
|
root.replaceChildren();
|
|
const message = document.createElement('p');
|
|
message.style.cssText = 'padding:32px;font:16px/1.6 system-ui';
|
|
message.textContent = 'Не удалось открыть проект. Обнови страницу. ' + String(error.message || error);
|
|
root.append(message);
|
|
});
|