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-24 04:04:05 +00:00
|
|
|
import {App} from './App';
|
|
|
|
|
import { createEditorFS } from './filesystem';
|
|
|
|
|
import { registerOpenSCADLanguage } from './language/openscad-register-language';
|
|
|
|
|
import { zipArchives } from './zip-archives';
|
2023-03-25 11:59:50 +00:00
|
|
|
import {readStateFromFragment} from './fragment-state'
|
2023-03-24 04:33:39 +00:00
|
|
|
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();
|
|
|
|
|
}
|
2023-03-24 04:04:05 +00:00
|
|
|
|
|
|
|
|
(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() ?? {
|
2023-03-25 11:59:50 +00:00
|
|
|
params: {
|
2023-03-25 19:30:34 +00:00
|
|
|
source: defaultScad,
|
|
|
|
|
features: [],
|
2023-03-24 04:33:39 +00:00
|
|
|
}
|
2023-03-25 19:30:34 +00:00
|
|
|
};
|
2023-03-24 04:33:39 +00:00
|
|
|
|
2023-03-25 15:23:54 +00:00
|
|
|
const defaultFeatures = ['manifold', 'fast-csg', 'lazy-union'];
|
|
|
|
|
defaultFeatures.forEach(f => {
|
|
|
|
|
if (initialState.params.features.indexOf(f) < 0)
|
|
|
|
|
initialState.params.features.push(f);
|
|
|
|
|
});
|
|
|
|
|
|
2023-03-24 04:04:05 +00:00
|
|
|
const root = ReactDOM.createRoot(
|
|
|
|
|
document.getElementById('root') as HTMLElement
|
|
|
|
|
);
|
|
|
|
|
root.render(
|
|
|
|
|
<React.StrictMode>
|
2023-03-24 04:33:39 +00:00
|
|
|
<App initialState={initialState} />
|
2023-03-24 04:04:05 +00:00
|
|
|
</React.StrictMode>
|
|
|
|
|
);
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|