Commit e2f36fa6 authored by Boxiang Sun's avatar Boxiang Sun

erp5_notebook: Use ajax replace fetch function when importing wasm

parent 95bd44b6
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
line_list = s.toString().split("\n"); line_list = s.toString().split("\n");
for (i = 0; i < line_list.length; i += 1) { for (i = 0; i < line_list.length; i += 1) {
div = sideEffectDiv("side-effect-print", reportSideEffect); div = sideEffectDiv("side-effect-print", reportSideEffect);
div.innerText = line_list[i]; div.textContent = line_list[i];
} }
}, },
element: function (nodeType, reportSideEffect) { element: function (nodeType, reportSideEffect) {
...@@ -409,14 +409,17 @@ ...@@ -409,14 +409,17 @@
function loadPyodide(info, receiveInstance) { function loadPyodide(info, receiveInstance) {
var queue = new RSVP.Queue(); var queue = new RSVP.Queue();
queue.push(function () { queue.push(function () {
return WebAssembly.compileStreaming(fetch("pyodide.asm.wasm")); return ajax({url: "pyodide.asm.wasm", dataType: "arraybuffer"})
}) })
.push(function (module) { .push(function (evt) {
return WebAssembly.instantiate(module, info); return WebAssembly.instantiate(evt.target.response, info);
})
.push(function (results) {
return receiveInstance(results.instance);
})
.push(undefined, function(error) {
console.log(error);
}) })
.push(function (instance) {
return receiveInstance(instance);
});
return queue; return queue;
} }
...@@ -473,14 +476,19 @@ ...@@ -473,14 +476,19 @@
return pyodideSetting(); return pyodideSetting();
}) })
.push(function () { .push(function () {
return fetch('packages.json'); return ajax({url: 'packages.json'});
}) })
.push(function (response) { .push(function (evt) {
return response.json(); return JSON.parse(evt.target.response);
}) })
.push(function (json) { .push(function (json) {
window.pyodide.packages = json; window.pyodide._module = Module;
window.pyodide.loadedPackages = [];
window.pyodide._module.packages = json;
return; return;
})
.push(undefined, function(error) {
console.log(error);
}); });
return queue; return queue;
} }
......
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