Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use URL to get path to wasm asset #104

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions host/javascript/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { App, AsyncMutex } from './app.js';
export type { TextCoder, FileSystem, Timers, Network, WasiContext, Persistence } from './interfaces.js';
export * from './error.js';
export { HandleMap } from './handle_map.js';
export type { FileSystem, Network, Persistence, TextCoder, Timers, WasiContext } from './interfaces.js';
export { SecurityValuesMap } from './security.js';
export * from './error.js';
export * from './wasm.js';
3 changes: 3 additions & 0 deletions host/javascript/src/common/wasm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function corePath(): string {
return process.env.CORE_PATH ?? new URL('../assets/core-async.wasm', import.meta.url).pathname;
}
2 changes: 0 additions & 2 deletions host/javascript/src/node/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { jest } from '@jest/globals';

import { Server, createServer as httpCreateServer } from 'node:http';
import { fileURLToPath } from 'node:url';
import { resolve as resolvePath, dirname } from 'node:path';
Expand Down
5 changes: 2 additions & 3 deletions host/javascript/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import {
Persistence
} from '../common/index.js';
import { fetchErrorToHostError, systemErrorToWasiError } from './error.js';
import { loadCoreFile } from './wasm.js';
import { corePath } from '../common/wasm.js';

export { PerformError, UnexpectedError, ValidationError } from '../common/index.js';
export { fetchErrorToHostError, systemErrorToWasiError } from './error.js';
export { corePath, loadCoreFile } from './wasm.js';

const ASSETS_FOLDER = 'superface';

Expand Down Expand Up @@ -223,7 +222,7 @@ class InternalClient {
}

await this.app.loadCore(
await loadCoreFile()
await fs.readFile(corePath())
);
await this.app.init(new WASI({ env: process.env, version: 'preview1' } as any)); // TODO: node typings do not include version https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/wasi.d.ts#L68-L110

Expand Down
10 changes: 0 additions & 10 deletions host/javascript/src/node/wasm.ts

This file was deleted.