openscad-playground/src/index.tsx

53 lines
1.4 KiB
TypeScript
Raw Normal View History

// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
import React from 'react';
import ReactDOM from 'react-dom/client';
import {App} from './App';
import { createEditorFS } from './filesystem';
import { registerOpenSCADLanguage } from './language/openscad-register-language';
import { zipArchives } from './zip-archives';
import {readStateFromFragment} from './fragment-state'
import { State } from './app-state';
2023-03-25 19:30:34 +00:00
import defaultScad from './default-scad'
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();
}
(async () => {
const workingDir = '/home';
const fs = await createEditorFS(workingDir);
await registerOpenSCADLanguage(fs, workingDir, zipArchives);
2023-03-25 19:30:34 +00:00
const initialState: State = readStateFromFragment() ?? {
params: {
2023-03-25 19:30:34 +00:00
source: defaultScad,
features: [],
}
2023-03-25 19:30:34 +00:00
};
const defaultFeatures = ['manifold', 'fast-csg', 'lazy-union'];
defaultFeatures.forEach(f => {
if (initialState.params.features.indexOf(f) < 0)
initialState.params.features.push(f);
});
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<App initialState={initialState} />
</React.StrictMode>
);
})();