Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/core/dash-wasm/src/browser.ts
1067 views
1
import { asyncKernel, FileSystemSpec } from "@cowasm/kernel";
2
import { join } from "path";
3
import debug from "debug";
4
import { Options, DashWasmAsync, getEnv } from "./common";
5
6
const { ENV, USR } = getEnv();
7
8
const log = debug("dash-wasm:browser");
9
10
import fs_zip from "./fs.zip";
11
12
const DASH = join(USR, "bin", "sh");
13
14
export default async function asyncDash(
15
opts?: Options
16
): Promise<DashWasmAsync> {
17
log("creating async CoWasm kernel...");
18
const fs = getFilesystem(opts);
19
const kernel = await asyncKernel({
20
env: ENV,
21
fs,
22
});
23
return new DashWasmAsync(kernel, DASH);
24
}
25
26
function getFilesystem(_opts?: Options): FileSystemSpec[] {
27
return [
28
{
29
type: "zipurl",
30
zipurl: fs_zip,
31
mountpoint: USR,
32
},
33
// And the rest of the native filesystem.
34
{ type: "dev" },
35
];
36
}
37
38