How to use the @wasmer/wasmfs.WasmFs function in @wasmer/wasmfs

To help you get started, we’ve selected a few @wasmer/wasmfs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wasmerio / wasmer-js / packages / wasm-terminal / src / wasm-terminal-config.ts View on Github external
/*ROLLUP_REPLACE_INLINE
    if (config.processWorkerUrl) {
      console.warn(
        "The unoptimized bundle of wasm-terminal is currently being used. The process worker does not need to be passed, as it is already inlined into the bundle. If you would like to pass in the process worker url and improve performance, please use the optimized bundle. Instructions can be found in the documentation."
      );
    }
    ROLLUP_REPLACE_INLINE*/

    // Assign our values
    this.fetchCommand = config.fetchCommand;
    this.processWorkerUrl = config.processWorkerUrl;

    if (config.wasmFs) {
      this.wasmFs = config.wasmFs;
    } else {
      this.wasmFs = new WasmFs();
    }
  }
}
github wasmerio / webassembly.sh / src / services / wapm / wapm.js View on Github external
constructor(externalWasmBinaryCache) {
    this.wapmInstalledPackages = [];
    this.wapmCommands = {};
    this.uploadedCommands = {};
    this.cachedModules = {};

    this.wasmFs = new WasmFs();
    // For the file uploads
    this.wasmFs.fs.mkdirSync("/tmp/", { recursive: true });

    // Launch off an update request to our storage
    this._updateFromStorage();
    this.callbackCommands = {
      wapm: this._wapmCallbackCommand.bind(this),
      welcome,
      about,
      help,
      download,
      curl,
    };
    this.externalWasmBinaryCache = externalWasmBinaryCache;

    // Create a hidden input on the page for opening files
github wasmerio / wasmer-js / packages / wasm-terminal / src / process / process.ts View on Github external
constructor(
    commandOptions: CommandOptions,
    wasmFsJson: any,
    dataCallback: Function,
    endCallback: Function,
    errorCallback: Function,
    sharedStdinBuffer?: SharedArrayBuffer,
    startStdinReadCallback?: Function
  ) {
    this.commandOptions = commandOptions;

    this.wasmFs = new WasmFs();
    this.wasmFs.fromJSON(wasmFsJson);
    this.originalWasmFsJson = wasmFsJson;

    this.dataCallback = dataCallback;
    this.endCallback = endCallback;
    this.errorCallback = errorCallback;

    let sharedStdin: Int32Array | undefined = undefined;
    if (sharedStdinBuffer) {
      sharedStdin = new Int32Array(sharedStdinBuffer);
    }

    if (commandOptions.module) {
      this.command = new WASICommand(commandOptions);
    } else {
      this.command = new CallbackCommand(commandOptions);
github wasmerio / wasmer-js / examples / wasm-shell / components / wasm-terminal.tsx View on Github external
constructor() {
    super();
    this.wasmFs = new WasmFs();
    this.wasmTerminal = new WasmTerminal({
      fetchCommand: fetchCommandHandler,
      processWorkerUrl,
      wasmFs: this.wasmFs
    });

    const TINY_PNG =
      "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==";
    const deser = new Buffer(TINY_PNG, "base64");
    const contents = Uint8Array.from(deser);
    this.wasmFs.volume.writeFileSync("/tiny.png", contents);

    this.container = null;
  }

@wasmer/wasmfs

Isomorphic library to provide a sandboxed node fs implementation for Node and Browsers. 📂

MIT
Latest version published 4 years ago

Package Health Score

58 / 100
Full package analysis

Popular @wasmer/wasmfs functions