2023-03-25 11:59:50 +00:00
|
|
|
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
|
|
|
|
|
2023-03-24 01:58:25 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
import ReactDOM from 'react-dom/client';
|
2023-03-26 15:57:09 +01:00
|
|
|
import {App} from './components/App';
|
|
|
|
|
import { createEditorFS } from './fs/filesystem';
|
2023-03-24 04:04:05 +00:00
|
|
|
import { registerOpenSCADLanguage } from './language/openscad-register-language';
|
2023-03-26 15:57:09 +01:00
|
|
|
import { zipArchives } from './fs/zip-archives';
|
2023-03-26 15:28:05 +01:00
|
|
|
import {readStateFromFragment} from './state/fragment-state'
|
|
|
|
|
import { createInitialState } from './state/initial-state';
|
2023-03-25 19:34:07 +00:00
|
|
|
import './index.css';
|
2023-03-25 19:30:34 +00:00
|
|
|
|
|
|
|
|
import debug from 'debug';
|
|
|
|
|
const log = debug('app:log');
|
|
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
|
debug.enable('*');
|
|
|
|
|
log('Logging is enabled!');
|
|
|
|
|
} else {
|
|
|
|
|
debug.disable();
|
|
|
|
|
}
|
2023-03-24 04:04:05 +00:00
|
|
|
|
|
|
|
|
(async () => {
|
|
|
|
|
|
|
|
|
|
const workingDir = '/home';
|
2023-03-26 07:48:04 +01:00
|
|
|
const fs = await createEditorFS(workingDir)!;
|
2023-03-24 04:04:05 +00:00
|
|
|
await registerOpenSCADLanguage(fs, workingDir, zipArchives);
|
|
|
|
|
|
2023-03-26 15:28:05 +01:00
|
|
|
// type Mode = State['view']['layout']['mode'];
|
|
|
|
|
// const mode: Mode = window.matchMedia("(min-width: 768px)").matches
|
|
|
|
|
// ? 'multi' : 'single';
|
2023-03-26 07:48:04 +01:00
|
|
|
|
2023-03-26 15:28:05 +01:00
|
|
|
const initialState = createInitialState(fs, readStateFromFragment());
|
2023-03-25 15:23:54 +00:00
|
|
|
|
2023-03-24 04:04:05 +00:00
|
|
|
const root = ReactDOM.createRoot(
|
|
|
|
|
document.getElementById('root') as HTMLElement
|
|
|
|
|
);
|
|
|
|
|
root.render(
|
|
|
|
|
<React.StrictMode>
|
2023-03-26 07:48:04 +01:00
|
|
|
<App initialState={initialState} fs={fs} />
|
2023-03-24 04:04:05 +00:00
|
|
|
</React.StrictMode>
|
|
|
|
|
);
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|