Skip to content

Commit

Permalink
Merge pull request #783 from permaweb/twilson63/chore-weavedrive-close
Browse files Browse the repository at this point in the history
chore: update loader and container
  • Loading branch information
twilson63 authored Jun 9, 2024
2 parents 2f73d1f + d2abd37 commit d1153b1
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 56 deletions.
4 changes: 2 additions & 2 deletions dev-cli/src/versions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
export const VERSION = {
"CLI": "0.0.57",
"IMAGE": "0.0.37"
"CLI": "0.0.58",
"IMAGE": "0.0.38"
}
117 changes: 63 additions & 54 deletions loader/src/formats/wasm64-emscripten.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -630,60 +630,66 @@ var Module = (() => {

missingGlobal("asm", "Please use wasmExports instead");

function missingLibrarySymbol(sym) {
if (typeof globalThis != "undefined" && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
Object.defineProperty(globalThis, sym, {
configurable: true,
get() {
var msg = `\`${sym}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`;
var librarySymbol = sym;
if (!librarySymbol.startsWith("_")) {
librarySymbol = "$" + sym;
}
msg += ` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${librarySymbol}')`;
if (isExportedByForceFilesystem(sym)) {
msg += ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you";
}
warnOnce(msg);
return undefined;
}
});
}
unexportedRuntimeSymbol(sym);
}

function unexportedRuntimeSymbol(sym) {
if (!Object.getOwnPropertyDescriptor(Module, sym)) {
Object.defineProperty(Module, sym, {
configurable: true,
get() {
var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
if (isExportedByForceFilesystem(sym)) {
msg += ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you";
}
abort(msg);
}
});
}
}

function __asyncjs__weavedrive_open(c_filename, mode) {
return Asyncify.handleAsync(async () => {
const filename = UTF8ToString(Number(c_filename));
if (!Module.WeaveDrive) {
return Promise.resolve(null);
}
const drive = Module.WeaveDrive(Module, FS);
return await drive.open(filename);
});
}

function __asyncjs__weavedrive_read(fd, dst_ptr, length) {
return Asyncify.handleAsync(async () => {
const drive = Module.WeaveDrive(Module, FS);
return Promise.resolve(await drive.read(fd, dst_ptr, length));
});
}
function missingLibrarySymbol(sym) {
if (typeof globalThis != "undefined" && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
Object.defineProperty(globalThis, sym, {
configurable: true,
get() {
var msg = `\`${sym}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`;
var librarySymbol = sym;
if (!librarySymbol.startsWith("_")) {
librarySymbol = "$" + sym;
}
msg += ` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${librarySymbol}')`;
if (isExportedByForceFilesystem(sym)) {
msg += ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you";
}
warnOnce(msg);
return undefined;
}
});
}
unexportedRuntimeSymbol(sym);
}

function unexportedRuntimeSymbol(sym) {
if (!Object.getOwnPropertyDescriptor(Module, sym)) {
Object.defineProperty(Module, sym, {
configurable: true,
get() {
var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
if (isExportedByForceFilesystem(sym)) {
msg += ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you";
}
abort(msg);
}
});
}
}

function __asyncjs__weavedrive_open(c_filename, mode) {
return Asyncify.handleAsync(async () => {
const filename = UTF8ToString(Number(c_filename));
if (!Module.WeaveDrive) {
return Promise.resolve(null);
}
const drive = Module.WeaveDrive(Module, FS);
return await drive.open(filename);
});
}

function __asyncjs__weavedrive_read(fd, dst_ptr, length) {
return Asyncify.handleAsync(async () => {
const drive = Module.WeaveDrive(Module, FS);
return Promise.resolve(await drive.read(fd, dst_ptr, length));
});
}
function __asyncjs__weavedrive_close(fd) {
return Asyncify.handleAsync(async () => {
const drive = Module.WeaveDrive(Module, FS);
return drive.close(fd);
});
}

/** @constructor */ function ExitStatus(status) {
this.name = "ExitStatus";
Expand Down Expand Up @@ -4949,6 +4955,9 @@ var Module = (() => {

var wasmImports = {
/** @export */ __assert_fail: ___assert_fail,
/** @export */ __asyncjs__weavedrive_close: __asyncjs__weavedrive_close,


/** @export */ __asyncjs__weavedrive_open: __asyncjs__weavedrive_open,
/** @export */ __asyncjs__weavedrive_read: __asyncjs__weavedrive_read,
/** @export */ __cxa_throw: ___cxa_throw,
Expand Down

0 comments on commit d1153b1

Please sign in to comment.