1
0
Fork 0
onnx-web/gui/src/main.tsx

32 lines
1.0 KiB
TypeScript
Raw Normal View History

2023-01-05 19:42:52 +00:00
/* eslint-disable no-console */
2023-01-05 03:55:25 +00:00
import { mustExist } from '@apextoaster/js-utils';
import { merge } from 'lodash';
2023-01-05 03:55:25 +00:00
import * as React from 'react';
import ReactDOM from 'react-dom/client';
import { QueryClient, QueryClientProvider } from 'react-query';
2023-01-05 03:55:25 +00:00
import { makeClient } from './api/client.js';
import { OnnxWeb } from './components/OnnxWeb.js';
import { ConfigParams, loadConfig } from './config.js';
export async function main() {
const config = await loadConfig();
const client = makeClient(config.api.root);
const params = await client.params();
const merged = merge(params, config.params) as ConfigParams;
const query = new QueryClient();
2023-01-05 03:55:25 +00:00
const appElement = mustExist(document.getElementById('app'));
const app = ReactDOM.createRoot(appElement);
app.render(<QueryClientProvider client={query}>
<OnnxWeb client={client} config={merged} />
</QueryClientProvider>);
2023-01-05 03:55:25 +00:00
}
window.addEventListener('load', () => {
console.log('launching onnx-web');
2023-01-05 19:42:52 +00:00
main().catch((err) => {
console.error('error in main', err);
});
}, false);