Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
139
Merge Requests
139
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
5f0fdf3f
Commit
5f0fdf3f
authored
Apr 01, 2019
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_notebook: Refine the pyodide initialization
parent
23e13f5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
52 deletions
+32
-52
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
...ateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
+32
-52
No files found.
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
View file @
5f0fdf3f
...
...
@@ -20,29 +20,6 @@
return
;
};
var
Module
=
{};
var
initPyodide
=
new
Promise
((
resolve
,
reject
)
=>
{
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
);
});
// Copied from jio
function
ajax
(
param
)
{
...
...
@@ -280,13 +257,14 @@
}
function
loadPyodide
()
{
let
wasm_promise
=
WebAssembly
.
compileStreaming
(
fetch
(
`pyodide.asm.wasm`
));
Module
.
instantiateWasm
=
function
(
info
,
receiveInstance
)
{
wasm_promise
.
then
(
module
=>
WebAssembly
.
instantiate
(
module
,
info
))
.
then
(
instance
=>
receiveInstance
(
instance
));
return
{};
};
let
wasm_promise
=
WebAssembly
.
compileStreaming
(
fetch
(
`pyodide.asm.wasm`
));
Module
.
instantiateWasm
=
function
(
info
,
receiveInstance
)
{
wasm_promise
.
then
(
module
=>
WebAssembly
.
instantiate
(
module
,
info
))
.
then
(
instance
=>
receiveInstance
(
instance
));
return
{};
};
window
.
Module
=
Module
;
}
function
executePyCell
(
line_list
)
{
...
...
@@ -321,6 +299,19 @@
}
}
function
pyodideSetting
()
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
window
.
pyodide
=
pyodide
(
Module
);
var
postRunPromise
=
new
Promise
((
resolve
,
reject
)
=>
{
Module
.
postRun
=
()
=>
{
resolve
();
};
});
console
.
log
(
"
Setting postRun
"
);
Promise
.
all
([
postRunPromise
,
]).
then
(()
=>
resolve
());
});
}
function
executeCell
(
cell
)
{
if
(
cell
.
_type
===
'
raw
'
)
{
// Do nothing...
...
...
@@ -352,38 +343,27 @@
queue
.
push
(
function
()
{
console
.
log
(
"
Loading webassembly module
"
);
return
loadPyodide
();
})
.
push
(
function
()
{
window
.
Module
=
Module
;
console
.
log
(
"
WIndow Module
"
);
console
.
log
(
window
.
Module
);
console
.
log
(
"
Module
"
);
console
.
log
(
Module
);
})
.
push
(
function
()
{
console
.
log
(
"
Prepare enter initPyodide
"
);
return
initPyodide
;
});
is_pyodide_loaded
=
true
;
/*
queue.push(function () {
})
.
push
(
function
()
{
console
.
log
(
"
Loading pyodide.asm.data.js
"
);
return
loadJSResource
(
`pyodide.asm.data.js`
);
});*/
/*
queue.push(function () {
})
.
push
(
function
()
{
console
.
log
(
"
Loading pyodide.asm.js
"
);
return
loadJSResource
(
'
pyodide.asm.js
'
);
})
.
push
(
function
()
{
console
.
log
(
"
Prepare to set postRun and pyodide
"
);
return
pyodideSetting
();
});
*/
is_pyodide_loaded
=
true
;
}
console
.
log
(
"
Fuck!
"
);
queue
.
push
(
function
()
{
console
.
log
(
"
Executing Python cell
"
);
console
.
log
(
window
.
pyodide
);
return
executePyCell
(
cell
.
_line_list
);
});
return
queue
;
});
return
queue
;
}
return
executeUnknownCellType
(
cell
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment