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';
|
2023-01-10 04:59:08 +00:00
|
|
|
import { merge } from 'lodash';
|
2023-01-05 03:55:25 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
import ReactDOM from 'react-dom/client';
|
2023-01-06 03:01:18 +00:00
|
|
|
import { QueryClient, QueryClientProvider } from 'react-query';
|
2023-01-05 03:55:25 +00:00
|
|
|
|
2023-01-06 16:52:42 +00:00
|
|
|
import { makeClient } from './api/client.js';
|
2023-01-05 16:39:46 +00:00
|
|
|
import { OnnxWeb } from './components/OnnxWeb.js';
|
2023-01-10 04:59:08 +00:00
|
|
|
import { ConfigParams, loadConfig } from './config.js';
|
2023-01-05 16:39:46 +00:00
|
|
|
|
|
|
|
export async function main() {
|
|
|
|
const config = await loadConfig();
|
2023-01-06 03:01:18 +00:00
|
|
|
const client = makeClient(config.api.root);
|
2023-01-10 04:59:08 +00:00
|
|
|
const params = await client.params();
|
|
|
|
const merged = merge(params, config.params) as ConfigParams;
|
2023-01-06 03:01:18 +00:00
|
|
|
const query = new QueryClient();
|
2023-01-05 16:39:46 +00:00
|
|
|
|
2023-01-05 03:55:25 +00:00
|
|
|
const appElement = mustExist(document.getElementById('app'));
|
|
|
|
const app = ReactDOM.createRoot(appElement);
|
2023-01-06 05:53:39 +00:00
|
|
|
app.render(<QueryClientProvider client={query}>
|
2023-01-10 04:59:08 +00:00
|
|
|
<OnnxWeb client={client} config={merged} />
|
2023-01-06 05:53:39 +00:00
|
|
|
</QueryClientProvider>);
|
2023-01-05 03:55:25 +00:00
|
|
|
}
|
|
|
|
|
2023-01-05 16:39:46 +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);
|
|
|
|
});
|
2023-01-05 16:39:46 +00:00
|
|
|
}, false);
|