import Process from "process";
globalThis.Process = Process;

// NB: The only way I've made this work in node+webpack is if:
//
// * we use Worker from worker_threads directly
// * we build each worker's module with webpack as an ESM .mjs bundle
// * we put all the bundles in one directory
// * we load the worker with a URL('./foo.mjs')
//
// Other ways to package/load might work, but definitely seems like
// using worker_threads.Worker directly is needed (rather than through,
// say, the web-worker packages that wraps either worker_threads.Worker
// or the browser Worker to give the same interface). Webpack says ESM
// is necessary but I'm not sure if this is true for either the main
// script or the workers.
import { Worker } from "worker_threads";

function GetMachineWASMWorker() {
    return new Worker(new URL("./machine-wasm.node.mjs", import.meta.url));
}
globalThis.GetMachineWASMWorker = GetMachineWASMWorker;

// Can't just `export *` because we need hub-client below in common.js
import * as Hub from "@remix_labs/hub-client";
export { Hub };

import { fileURLToPath } from 'url';
globalThis.__filename = fileURLToPath(import.meta.url);

export * from "./common.js";
