Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*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();
}
}
}
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
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);
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;
}