Skip to content

Commit

Permalink
fix(browser): Fix issue where browsers where unable to boot
Browse files Browse the repository at this point in the history
  • Loading branch information
FranklinWaller committed Dec 18, 2019
1 parent 29f8dc9 commit 8edeae1
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 6 deletions.
43 changes: 43 additions & 0 deletions electron/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
},
"devDependencies": {
"cross-env": "^6.0.3",
"electron": "^4.0.0"
"electron": "^4.0.0",
"worker-plugin": "^3.2.0"
},
"keywords": [
"capacitor",
Expand Down
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"node-sass": "^4.13.0",
"standard-version": "^7.0.1",
"typescript": "^3.7.3",
"url-loader": "^2.2.0"
"url-loader": "^2.2.0",
"worker-plugin": "^3.2.0"
}
}
2 changes: 1 addition & 1 deletion src/js/pages/RegisterPage/RegisterPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function RegisterPage() {
...values,
[name]: event.target.value,
});
}
};
}

function createAccount() {
Expand Down
13 changes: 11 additions & 2 deletions src/js/services/TerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class TerminalService {
this.currentPath = currentPath;
}

async handleCommand(commandName: string, args: string[], envEntriest: any[]) {
async handleCommand(commandName: string, args: string[], envEntriest: any) {
if (commandName.endsWith('.wasm')) {
return this.fs.readFile(commandName);
}
Expand All @@ -43,7 +43,16 @@ export default class TerminalService {
};
}

const kernel = InstanceBag.get<Kernel>('kernel');
const wasmBinary = await fetchCommandFromWAPM(commandName, [], [['PATH', '/']]);
return lowerI64Imports(wasmBinary);
const preparedBin = await kernel.vm.prepareBin(wasmBinary);

return preparedBin;
// args.unshift(commandName);
// const vmOutput = await kernel.spawnProcess(preparedBin, args, {
// env: envEntriest,
// });

// return () => vmOutput;
}
}
6 changes: 6 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');
const WorkerPlugin = require('worker-plugin');

const exclude = '/node_modules';

Expand All @@ -16,6 +17,11 @@ module.exports = {
filename: '[name].js',
publicPath: 'build/',
},
plugins: [
new WorkerPlugin({
globalObject: 'self',
}),
],
module: {
rules: [
{
Expand Down
6 changes: 5 additions & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
<body>
<div id="app"></div>
<script>
if (process.env.NODE_ENV === 'development') {
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'development') {
const script = document.createElement('script');
const base = document.createElement('base');
base.href = 'http://localhost:3000/';

script.src = 'http://localhost:3000/build/index.js';
document.head.appendChild(base);
document.head.appendChild(script);
} else {
const script = document.createElement('script');
Expand Down

0 comments on commit 8edeae1

Please sign in to comment.