add all web jses (leave out the big data and asm files)
This commit is contained in:
parent
e8868b636f
commit
3b05f4316c
68 changed files with 1408 additions and 0 deletions
25
web/webworker.js
Normal file
25
web/webworker.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
self.languagePluginUrl = 'https://cdn.jsdelivr.net/pyodide/v0.15.0/full/'
|
||||
importScripts('./pyodide.js')
|
||||
|
||||
var onmessage = function(e) { // eslint-disable-line no-unused-vars
|
||||
languagePluginLoader.then(() => {
|
||||
const data = e.data;
|
||||
const keys = Object.keys(data);
|
||||
for (let key of keys) {
|
||||
if (key !== 'python') {
|
||||
// Keys other than python must be arguments for the python script.
|
||||
// Set them on self, so that `from js import key` works.
|
||||
self[key] = data[key];
|
||||
}
|
||||
}
|
||||
|
||||
self.pyodide.runPythonAsync(data.python, () => {})
|
||||
.then((results) => { self.postMessage({results}); })
|
||||
.catch((err) => {
|
||||
// if you prefer messages with the error
|
||||
self.postMessage({error : err.message});
|
||||
// if you prefer onerror events
|
||||
// setTimeout(() => { throw err; });
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue