@earendil-works/djs 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ // The package's main entry point (`@earendil-works/djs`): the Sandbox API with the
2
+ // shipped module, wasm/djs.wasm, as its default; `$DJS_WASM` overrides it (D3106).
3
+ // Each entry point loads only its own module, so a bundler copies only the modules an
4
+ // application imports.
5
+ import { Sandbox as Base, loadModule as load } from "./sandbox.js";
6
+ import { envVar } from "./env.js";
7
+ export * from "./sandbox.js";
8
+ /** This entry point's module: `$DJS_WASM`, else the package's djs.wasm. */
9
+ export function defaultWasmPath() {
10
+ return envVar("DJS_WASM") ?? new URL("../wasm/djs.wasm", import.meta.url);
11
+ }
12
+ /** Compiles djs-wasm once per location and caches it; default: this entry point's module. */
13
+ export function loadModule(location = defaultWasmPath()) {
14
+ return load(location);
15
+ }
16
+ /** The Sandbox, with this entry point's module as the default. */
17
+ export class Sandbox extends Base {
18
+ static defaultModule() {
19
+ return defaultWasmPath();
20
+ }
21
+ }