Commit 0f16aaa5 authored by Boxiang Sun's avatar Boxiang Sun

erp5_notebook: Add a js file to init the pyodide webassembly module loading

Replace the original pyodide.js
parent e84f99f1
var initPyodide = new Promise((resolve, reject) => {
// Loading Pyodide
let wasmURL = `pyodide.asm.wasm`;
let Module = {};
window.Module = Module;
let wasm_promise = WebAssembly.compileStreaming(fetch(wasmURL));
Module.instantiateWasm = (info, receiveInstance) => {
wasm_promise.then(module => WebAssembly.instantiate(module, info))
.then(instance => receiveInstance(instance));
return {};
};
var postRunPromise = new Promise((resolve, reject) => {
Module.postRun = () => {
resolve();
};
});
Promise.all([ postRunPromise, ]).then(() => resolve());
let data_script = document.createElement('script');
data_script.src = `pyodide.asm.data.js`;
data_script.onload = (event) => {
let script = document.createElement('script');
script.src = `pyodide.asm.js`;
script.onload = () => {
window.pyodide = pyodide(Module);
};
document.head.appendChild(script);
};
document.head.appendChild(data_script);
});
initPyodide
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>custom_pyodide.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -11,7 +11,7 @@
<script src="rsvp.js" type="text/javascript"></script>
<script src="marked.js" type="text/javascript"></script>
<script src="pyodide.js" type="text/javascript"></script>
<script src="custom_pyodide.js" type="text/javascript"></script>
<script src="gadget_jsmd_eval.js" type="text/javascript"></script>
</head>
......
/*global window, console, RSVP, document, URL, eval, XMLHttpRequest, marked, pyodide hljs */
/*global window, console, RSVP, document, URL, eval, XMLHttpRequest, marked, pyodide */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, languagePluginLoader) {
(function (window, initPyodide) {
"use strict";
var IODide = function createIODide() {
......@@ -330,7 +330,7 @@
queue = new RSVP.Queue();
queue.push(function () {
return languagePluginLoader;
return initPyodide;
});
for (i = 0; i < len; i += 1) {
queue.push(deferCellExecution(cell_list[i]));
......@@ -352,4 +352,4 @@
}, false);
}(window, languagePluginLoader));
\ No newline at end of file
}(window, initPyodide));
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment