Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async spawnProcess(commandOptionIndex: number) {
// First set up our fallback if we need to
let binaryenScript = "";
if (this.isUsingFallback && this.binaryenScriptPromise) {
binaryenScript = await this.binaryenScriptPromise;
}
// Generate our process
const processWorker = new Worker("./workers/process/process.worker.js");
const processComlink = Comlink.wrap(processWorker);
// @ts-ignore
const process: any = await new processComlink(
this.commandOptionsForProcessesToRun[commandOptionIndex],
// Data Callback
Comlink.proxy((data: Uint8Array) => {
if (
commandOptionIndex <
this.commandOptionsForProcessesToRun.length - 1
) {
// Pass along to the next spawned process
if (this.spawnedProcessToWorker.length > 1) {
this.spawnedProcessToWorker[1].process.receiveStdinChunk(data);
} else {
const newInitialStdinData = new Uint8Array(
data.length + this.initialStdinDataForNextProcess.length
if (!this.wasmTerminalConfig.processWorkerUrl) {
throw new Error("Terminal Config missing the Process Worker URL");
}
let processWorkerUrl = this.wasmTerminalConfig.processWorkerUrl;
/*ROLLUP_REPLACE_INLINE
processWorkerUrl = processWorkerInlinedUrl;
ROLLUP_REPLACE_INLINE*/
// Generate our process
const workerBlobUrl = await this._getBlobUrlForProcessWorker(
processWorkerUrl,
this.wasmTty
);
const processWorker = new Worker(workerBlobUrl);
const processComlink = Comlink.wrap(processWorker);
// Generate our shared buffer
const sharedStdinBuffer = new SharedArrayBuffer(8192);
// Get our filesystem state
const wasmFsJson = this.wasmTerminalConfig.wasmFs.toJSON();
// @ts-ignore
const process: any = await new processComlink(
// Command Options
this.commandOptionsForProcessesToRun[commandOptionIndex],
// WasmFs File System JSON
wasmFsJson,
// Data Callback
Comlink.proxy(
this._processDataCallback.bind(this, {
if (!this.wasmTerminalConfig.processWorkerUrl) {
throw new Error("Terminal Config missing the Process Worker URL");
}
let processWorkerUrl = this.wasmTerminalConfig.processWorkerUrl;
/*ROLLUP_REPLACE_INLINE
processWorkerUrl = processWorkerInlinedUrl;
ROLLUP_REPLACE_INLINE*/
// Generate our process
const workerBlobUrl = await this._getBlobUrlForProcessWorker(
processWorkerUrl,
this.wasmTty
);
const processWorker = new Worker(workerBlobUrl);
const processComlink = Comlink.wrap(processWorker);
// Generate our shared buffer
const sharedStdinBuffer = new SharedArrayBuffer(8192);
// Get our filesystem state
const wasmFsJson = this.wasmTerminalConfig.wasmFs.toJSON();
// Create our Io Device Window
const ioDeviceWindow = new IoDeviceWindow();
// @ts-ignore
const process: any = await new processComlink(
// Command Options
this.commandOptionsForProcessesToRun[commandOptionIndex],
// WasmFs File System JSON
wasmFsJson,
export async function createPenumbraWorker(
url: URL | string,
): Promise {
const worker = new Worker(url /* , { type: 'module' } */);
const penumbraWorker: PenumbraWorker = {
worker,
comlink: wrap(worker),
initialized: false,
};
const Link = penumbraWorker.comlink;
const setup = new Link().then(async (thread: PenumbraWorkerAPI) => {
await thread.setup(proxy(reDispatchEvent));
});
await setup;
penumbraWorker.initialized = true;
return penumbraWorker;
}
/** Initializes web worker threads */
constructor(config: ProxyClientPartitionConfig) {
this._bridge = wrap(config.port);
this.private = config.private;
console.log('Got Bridge: ', this._bridge);
this.state = {};
this._onBotsAdded = new Subject();
this._onBotsRemoved = new Subject();
this._onBotsUpdated = new Subject();
this._onError = new Subject();
this._onEvents = new Subject();
this._onStatusUpdated = new Subject();
}
import {wrap as ComlinkWrap} from 'comlink';
const ParcelWorker = ComlinkWrap(new Worker('./ParcelWorker.js'));
export const workerLoaded = new ParcelWorker();
export async function getFS() {
return (await workerLoaded).getFS();
}
export async function getZip() {
return (await workerLoaded).getZip();
}
export default async function bundle(assets, options) {
return (await workerLoaded).bundle(assets, options);
}
VISUALIZER_MESSAGES,
VISUALIZER_MODE
} from "@enums/visualizerMessages";
import {
getDelay,
getNotesWithNoteEndEvent,
NoteWithIdAndEvent
} from "@utils/MidiPlayer/MidiPlayer.utils";
import { Range } from "@utils/typings/Visualizer";
import { getInstrumentIdByValue } from "midi-instruments";
import { IMidiJSON } from "@typings/midi";
import { MidiSettings } from "@components/TrackList";
import { wrap } from "comlink";
import { OFFSCREEN_2D_CANVAS_SUPPORT } from "@enums/offscreen2dCanvasSupport";
const loadInstrumentWorker: any = wrap(new LoadInstrumentWorker());
export type IScheduleOptions = MidiSettings;
type IEventCallback = (
notes: NoteWithIdAndEvent[],
trackIndex: number,
isLastEvent?: boolean
) => void;
export interface Sampler {
connect: (master: any) => void;
triggerAttack: (note: string, time?: number, velocity?: number) => void;
triggerRelease: (note: string) => void;
add: (key: string, buffer: ArrayBuffer, cb: () => void) => void;
context: AudioContext;
dispose: () => void;