import * as api from '@devvit/public-api';
import { UnsandboxedRuntimeLite } from '@devvit/runtime-lite/runtime/UnsandboxedRuntimeLite.js';
import { assignRuntime, startRuntime } from '@devvit/runtime-lite/workers/RuntimeLiteWorker.js';
import { sourceMapExceptionHandler } from './source-maps.js';
// to-do: pull in https://github.com/stephenh/ts-proto/issues/732 to fork and
// use plain globalThis here and everywhere else in runtime-lite.
const box = (globalThis.self ?? globalThis);
// Provide @devvit/public-api in addition to @devvit/protos. Pens are unbundled
// so they must be executed in an environment that provides all imported
// dependencies. Pens are ephemeral and have the lifetime of a pageview.
const runtime = new UnsandboxedRuntimeLite({ '@devvit/public-api': api }, { handleException: sourceMapExceptionHandler });
assignRuntime(box, runtime);
await runtime.init();
startRuntime(box);
