_fetchWebAssembly()

in web/src/components/playground.js [283:309]


  _fetchWebAssembly(artifact) {
    // eslint-disable-next-line no-undef
    const go = new Go();
    this._loadingWasm = true;

    let wasmUrl = this.baseUrl
      ? new URL(artifact, this.baseUrl).href
      : artifact;

    WebAssembly.instantiateStreaming(fetch(wasmUrl), go.importObject).then(
      (result) => {
        go.run(result.instance);
        this.updateComplete.then(() => {
          this._loadingWasm = false;
          const event = new CustomEvent('playground-wasm-ready', {
            detail: {
              value: artifact,
            },
            bubbles: true,
            composed: true,
            cancelable: true,
          });
          window.dispatchEvent(event);
        });
      }
    );
  }