Commit 75f962bb authored by Richard's avatar Richard Committed by Richard

[erp5_notebook][erp5_officejs]: update iodide to run pyodide

parent 1a24c212
{"dependencies": {"matplotlib": ["cycler", "kiwisolver", "numpy", "pyparsing", "python-dateutil", "pytz"], "numpy": [], "pyparsing": [], "kiwisolver": [], "python-dateutil": [], "xlrd": [], "pandas": ["numpy", "python-dateutil", "pytz"], "cycler": [], "pytz": []}}
\ No newline at end of file
<?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>packages.json</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/json</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>
<?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>pyodide.asm.data.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>
This source diff could not be displayed because it is too large. You can view the blob instead.
<?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>pyodide.asm.html</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</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>
......@@ -12,7 +12,7 @@
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/octet-stream</string> </value>
<value> <string>application/wasm</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
......
/**
* The main bootstrap script for loading pyodide.
*/
var languagePluginLoader = new Promise((resolve, reject) => {
let baseURL = "";
let wasmURL = `${baseURL}pyodide.asm.wasm`;
let wasmXHR = new XMLHttpRequest();
wasmXHR.open('GET', wasmURL, true);
wasmXHR.responseType = 'arraybuffer';
wasmXHR.onload = function() {
let Module = {};
if (wasmXHR.status === 200 || wasmXHR.status === 0) {
Module.wasmBinary = wasmXHR.response;
// This is filled in by the Makefile to be either a local file or the
// deployed location. TODO: This should be done in a less hacky
// way.
const baseURL = '';
////////////////////////////////////////////////////////////
// Package loading
var packages = undefined;
let loadedPackages = new Set();
let loadPackage = (names) => {
// DFS to find all dependencies of the requested packages
let packages = window.pyodide.packages.dependencies;
let queue = new Array(names);
let toLoad = new Set();
while (queue.length) {
const package = queue.pop();
if (!loadedPackages.has(package)) {
toLoad.add(package);
if (packages.hasOwnProperty(package)) {
packages[package].forEach((subpackage) => {
if (!loadedPackages.has(subpackage) && !toLoad.has(subpackage)) {
queue.push(subpackage);
}
});
} else {
console.warn(
`Couldn't download the pyodide.asm.wasm binary. Response was ${wasmXHR.status}`);
reject();
console.log(`Unknown package '${package}'`);
}
}
}
Module.baseURL = baseURL;
Module.postRun = () => {
resolve();
let promise = new Promise((resolve, reject) => {
if (toLoad.size === 0) {
resolve('No new packages to load');
}
pyodide.monitorRunDependencies = (n) => {
if (n === 0) {
toLoad.forEach((package) => loadedPackages.add(package));
delete pyodide.monitorRunDependencies;
const packageList = Array.from(toLoad.keys()).join(', ');
resolve(`Loaded ${packageList}`);
}
};
toLoad.forEach((package) => {
let script = document.createElement('script');
script.src = `pyodide.asm.js`;
script.onload = () => {
window.pyodide = pyodide(Module);
};
script.src = `${baseURL}${package}.js`;
script.onerror = (e) => { reject(e); };
document.body.appendChild(script);
});
// We have to invalidate Python's import caches, or it won't
// see the new files. This is done here so it happens in parallel
// with the fetching over the network.
window.pyodide.runPython('import importlib as _importlib\n' +
'_importlib.invalidate_caches()\n');
});
if (window.iodide !== undefined) {
window.iodide.evalQueue.await([ promise ]);
}
return promise;
};
function fixRecursionLimit(pyodide) {
// The Javascript/Wasm call stack may be too small to handle the default
// Python call stack limit of 1000 frames. This is generally the case on
// Chrom(ium), but not on Firefox. Here, we determine the Javascript call
// stack depth available, and then divide by 50 (determined heuristically)
// to set the maximum Python call stack depth.
let depth = 0;
function recurse() {
depth += 1;
recurse();
}
try {
recurse();
} catch (err) {
;
}
let recursionLimit = depth / 50;
if (recursionLimit > 1000) {
recursionLimit = 1000;
}
pyodide.runPython(
`import sys; sys.setrecursionlimit(int(${recursionLimit}))`);
};
////////////////////////////////////////////////////////////
// Loading Pyodide
let wasmURL = `${baseURL}pyodide.asm.wasm`;
let Module = {};
window.Module = Module;
Module.noImageDecoding = true;
Module.noAudioDecoding = true;
let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
if (isFirefox) {
console.log("Skipping wasm decoding");
Module.noWasmDecoding = true;
}
let wasm_promise = WebAssembly.compileStreaming(fetch(wasmURL));
Module.instantiateWasm = (info, receiveInstance) => {
wasm_promise.then(module => WebAssembly.instantiate(module, info))
.then(instance => receiveInstance(instance));
return {};
};
Module.filePackagePrefixURL = baseURL;
var postRunPromise = new Promise((resolve, reject) => {
Module.postRun = () => {
delete window.Module;
fetch(`${baseURL}packages.json`)
.then((response) => response.json())
.then((json) => {
window.pyodide.packages = json;
fixRecursionLimit(pyodide);
resolve();
});
};
});
var dataLoadPromise = new Promise((resolve, reject) => {
Module.monitorRunDependencies =
(n) => {
if (n === 0) {
delete Module.monitorRunDependencies;
resolve();
}
}
});
Promise.all([ postRunPromise, dataLoadPromise ]).then(() => resolve());
let data_script = document.createElement('script');
data_script.src = `${baseURL}pyodide.asm.data.js`;
data_script.onload = (event) => {
let script = document.createElement('script');
script.src = `${baseURL}pyodide.asm.js`;
script.onload = () => {
window.pyodide = pyodide(Module);
window.pyodide.loadPackage = loadPackage;
};
wasmXHR.send(null);
document.head.appendChild(script);
};
document.head.appendChild(data_script);
////////////////////////////////////////////////////////////
// Iodide-specific functionality, that doesn't make sense
// if not using with Iodide.
if (window.iodide !== undefined) {
// Load the custom CSS for Pyodide
let link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = `${baseURL}renderedhtml.css`;
document.getElementsByTagName('head')[0].appendChild(link);
// Add a custom output handler for Python objects
window.iodide.addOutputHandler({
shouldHandle : (val) => {
return (typeof val === 'function' && pyodide.PyProxy.isPyProxy(val));
},
render : (val) => {
let div = document.createElement('div');
div.className = 'rendered_html';
var element;
if (val._repr_html_ !== undefined) {
let result = val._repr_html_();
if (typeof result === 'string') {
div.appendChild(new DOMParser()
.parseFromString(result, 'text/html')
.body.firstChild);
element = div;
} else {
element = result;
}
} else {
let pre = document.createElement('pre');
pre.textContent = val.toString();
div.appendChild(pre);
element = div;
}
return element;
}
});
}
});
languagePluginLoader
\ No newline at end of file
.rendered_html {
overflow: auto;
max-height: 30em;
color: black;
/* any extras will just be numbers: */
}
.rendered_html em {
font-style: italic;
}
.rendered_html strong {
font-weight: bold;
}
.rendered_html u {
text-decoration: underline;
}
.rendered_html :link {
text-decoration: underline;
}
.rendered_html :visited {
text-decoration: underline;
}
.rendered_html h1 {
font-size: 185.7%;
margin: 1.08em 0 0 0;
font-weight: bold;
line-height: 1.0;
}
.rendered_html h2 {
font-size: 157.1%;
margin: 1.27em 0 0 0;
font-weight: bold;
line-height: 1.0;
}
.rendered_html h3 {
font-size: 128.6%;
margin: 1.55em 0 0 0;
font-weight: bold;
line-height: 1.0;
}
.rendered_html h4 {
font-size: 100%;
margin: 2em 0 0 0;
font-weight: bold;
line-height: 1.0;
}
.rendered_html h5 {
font-size: 100%;
margin: 2em 0 0 0;
font-weight: bold;
line-height: 1.0;
font-style: italic;
}
.rendered_html h6 {
font-size: 100%;
margin: 2em 0 0 0;
font-weight: bold;
line-height: 1.0;
font-style: italic;
}
.rendered_html h1:first-child {
margin-top: 0.538em;
}
.rendered_html h2:first-child {
margin-top: 0.636em;
}
.rendered_html h3:first-child {
margin-top: 0.777em;
}
.rendered_html h4:first-child {
margin-top: 1em;
}
.rendered_html h5:first-child {
margin-top: 1em;
}
.rendered_html h6:first-child {
margin-top: 1em;
}
.rendered_html ul:not(.list-inline),
.rendered_html ol:not(.list-inline) {
padding-left: 2em;
}
.rendered_html ul {
list-style: disc;
}
.rendered_html ul ul {
list-style: square;
margin-top: 0;
}
.rendered_html ul ul ul {
list-style: circle;
}
.rendered_html ol {
list-style: decimal;
}
.rendered_html ol ol {
list-style: upper-alpha;
margin-top: 0;
}
.rendered_html ol ol ol {
list-style: lower-alpha;
}
.rendered_html ol ol ol ol {
list-style: lower-roman;
}
.rendered_html ol ol ol ol ol {
list-style: decimal;
}
.rendered_html * + ul {
margin-top: 1em;
}
.rendered_html * + ol {
margin-top: 1em;
}
.rendered_html hr {
color: black;
background-color: black;
}
.rendered_html pre {
margin: 1em 2em;
padding: 0px;
background-color: white;
}
.rendered_html code {
background-color: #eff0f1;
}
.rendered_html p code {
padding: 1px 5px;
}
.rendered_html pre code {
background-color: white;
}
.rendered_html pre,
.rendered_html code {
border: 0;
color: black;
font-size: 100%;
}
.rendered_html blockquote {
margin: 1em 2em;
}
.rendered_html table {
margin-left: auto;
margin-right: auto;
border: none;
border-collapse: collapse;
border-spacing: 0;
color: black;
font-size: 12px;
table-layout: fixed;
}
.rendered_html thead {
border-bottom: 1px solid black;
vertical-align: bottom;
}
.rendered_html tr,
.rendered_html th,
.rendered_html td {
text-align: right;
vertical-align: middle;
padding: 0.5em 0.5em;
line-height: normal;
white-space: normal;
max-width: none;
border: none;
}
.rendered_html th {
font-weight: bold;
}
.rendered_html tbody tr:nth-child(odd) {
background: #f5f5f5;
}
.rendered_html tbody tr:hover {
background: rgba(66, 165, 245, 0.2);
}
.rendered_html * + table {
margin-top: 1em;
}
.rendered_html p {
text-align: left;
}
.rendered_html * + p {
margin-top: 1em;
}
.rendered_html img {
display: block;
margin-left: auto;
margin-right: auto;
}
.rendered_html * + img {
margin-top: 1em;
}
.rendered_html img,
.rendered_html svg {
max-width: 100%;
height: auto;
}
.rendered_html img.unconfined,
.rendered_html svg.unconfined {
max-width: none;
}
.rendered_html .alert {
margin-bottom: initial;
}
.rendered_html * + .alert {
margin-top: 1em;
}
[dir="rtl"] .rendered_html p {
text-align: right;
}
<?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>renderedhtml.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/css</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>
......@@ -6,6 +6,61 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
......@@ -70,9 +125,12 @@ gadget_notebook.html\n
iodide_master.js\n
iodide_master.css\n
pyodide.js\n
pyodide.asm.data.js\n
pyodide.asm.js\n
pyodide.asm.wasm\n
pyodide.asm.data\n
packages.json\n
renderedhtml.css\n
\n
font-awesome/font-awesome.css\n
font-awesome/font-awesome-webfont.eot\n
......@@ -315,7 +373,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.41850.61151.55500</string> </value>
<value> <string>969.50674.1572.7867</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -333,7 +391,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1534492524.35</float>
<float>1535021998.08</float>
<string>UTC</string>
</tuple>
</state>
......
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