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

Fix handling of internal assets to eliminate the need for dist/dist #260

Merged
merged 1 commit into from
Sep 18, 2024
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: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
"CMakeListst.txt",
"LICENSE.txt"
],
"imports": {
"#monero-ts/monero.js": "./dist/monero.js"
},
"scripts": {
"start": "todo",
"build_web_worker": "webpack --config ./webpack.worker.js",
"build_web_tests": "webpack --config ./webpack.tests.js",
"test": "npm run build_commonjs && node --enable-source-maps node_modules/mocha/bin/_mocha --require @babel/register \"dist/src/test/TestAll\" --timeout 900000000 --exit",
"typedoc": "typedoc ./index.ts --out ./docs/typedocs --excludePrivate --disableSources",
"build_commonjs": "babel ./src --extensions \".js,.ts\" --out-dir ./dist/src && babel ./index.ts --extensions \".ts\" --out-dir ./dist && shx mkdir -p dist/dist && shx cp dist/monero.js dist/dist && shx cp dist/*.js.map dist/dist",
"build_commonjs": "babel ./src --extensions \".js,.ts\" --out-dir ./dist/src && babel ./index.ts --extensions \".ts\" --out-dir ./dist",
"check_babel_version": "babel -V"
},
"build": {
Expand Down
14 changes: 6 additions & 8 deletions src/main/cpp/http_client_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ using namespace std;
EM_JS(const char*, js_send_json_request, (const char* uri, const char* username, const char* password, const char* reject_unauthorized_fn_id, const char* method, const char* body, std::chrono::milliseconds timeout), {
//console.log("EM_JS js_send_json_request(" + UTF8ToString(uri) + ", " + UTF8ToString(username) + ", " + UTF8ToString(password) + ", " + UTF8ToString(method) + ")");

const moneroTs = require("../index");
const HttpClient = moneroTs.HttpClient;
const LibraryUtils = moneroTs.LibraryUtils;
const GenUtils = moneroTs.GenUtils;
const HttpClient = this.HttpClient;
const LibraryUtils = this.LibraryUtils;
const GenUtils = this.GenUtils;

// use asyncify to synchronously return to C++
return Asyncify.handleSleep(function(wakeUp) {
Expand Down Expand Up @@ -66,10 +65,9 @@ EM_JS(const char*, js_send_json_request, (const char* uri, const char* username,
EM_JS(const char*, js_send_binary_request, (const char* uri, const char* username, const char* password, const char* reject_unauthorized_fn_id, const char* method, const char* body, int body_length, std::chrono::milliseconds timeout), {
//console.log("EM_JS js_send_binary_request(" + UTF8ToString(uri) + ", " + UTF8ToString(username) + ", " + UTF8ToString(password) + ", " + UTF8ToString(method) + ")");

const moneroTs = require("../index");
const HttpClient = moneroTs.HttpClient;
const LibraryUtils = moneroTs.LibraryUtils;
const GenUtils = moneroTs.GenUtils;
const HttpClient = this.HttpClient;
const LibraryUtils = this.LibraryUtils;
const GenUtils = this.GenUtils;

// use asyncify to synchronously return to C++
return Asyncify.handleSleep(function(wakeUp) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/ts/common/LibraryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class LibraryUtils {
if (LibraryUtils.WASM_MODULE && LibraryUtils.FULL_LOADED) return LibraryUtils.WASM_MODULE;

// load module
let module = await require("../../../../dist/monero")();
const module = await require("#monero-ts/monero.js")();
LibraryUtils.WASM_MODULE = module;
delete LibraryUtils.WASM_MODULE.then;
LibraryUtils.FULL_LOADED = true;
Expand Down
5 changes: 5 additions & 0 deletions src/main/ts/common/MoneroWebWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import MoneroWalletFull from "../wallet/MoneroWalletFull";

declare const self: any;

// expose some modules to the worker
self.HttpClient = HttpClient;
self.LibraryUtils = LibraryUtils;
self.GenUtils = GenUtils;

/**
* Worker to manage a daemon and wasm wallet off the main thread using messages.
*
Expand Down
2 changes: 0 additions & 2 deletions webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ let configBase = {
extensions: ['.js', '.ts'],
alias: {
"fs": "memfs",
['~']: path.resolve(__dirname + '/app')
},
extensions: ['.js', '.jsx', '.css', '.json', 'otf', 'ttf', 'eot', 'svg', '.ts', '.tsx'],
modules: [
'node_modules',
path.resolve(__dirname + '/src')
],
fallback: { // browser polyfills
assert: require.resolve('assert'),
Expand Down