Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bokuweb committed Sep 30, 2024
1 parent b1dfffe commit c4ecf47
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions js/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import EventEmitter from 'node:events';
import { Worker } from 'node:worker_threads';
import { resolveExtention } from './utils';
import { dir, resolveExtention } from './utils';
import { join } from 'node:path';

export const run = (argv: string[]): EventEmitter => {
const emitter = new EventEmitter();
const worker = new Worker(`./entry.${resolveExtention()}`, { workerData: { argv } });
const worker = new Worker(join(dir(), `./entry.${resolveExtention()}`), { workerData: { argv } });

let nextTid = 1;
const workers = [worker];

const spawn = (startArg: number, threadId: Int32Array, memory: WebAssembly.Memory) => {
const worker = new Worker(`./worker.${resolveExtention()}`);
const worker = new Worker(join(dir(), `./worker.${resolveExtention()}`));

workers.push(worker);

Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reg-cli",
"version": "0.0.0-experimental-wasm0",
"version": "0.0.0-experimental-wasm1",
"description": "",
"type": "module",
"start": "node ./dist/cli.mjs",
Expand Down
7 changes: 5 additions & 2 deletions js/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import { join } from 'node:path';

const isCJS = typeof __dirname !== 'undefined';

export const readWasm = () => {
export const dir = (): string => {
const dir = isCJS ? __dirname : path.dirname(fileURLToPath(import.meta.url));
return dir;
};

const file = readFile(join(dir, './reg.wasm'));
export const readWasm = () => {
const file = readFile(join(dir(), './reg.wasm'));
return file;
};

Expand Down

0 comments on commit c4ecf47

Please sign in to comment.