Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
2eeb42eb
Commit
2eeb42eb
authored
Aug 22, 2018
by
Roman Yurchak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect repeated loading of the same package from multiple URI
parent
4f665e0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
src/pyodide.js
src/pyodide.js
+15
-5
No files found.
src/pyodide.js
View file @
2eeb42eb
...
...
@@ -18,7 +18,7 @@ var languagePluginLoader = new Promise((resolve, reject) => {
////////////////////////////////////////////////////////////
// Package loading
var
packages
=
undefined
;
let
loadedPackages
=
new
Set
();
let
loadedPackages
=
new
Array
();
let
_uri_to_package_name
=
(
package_uri
)
=>
{
// Generate a unique package name from URI
...
...
@@ -41,22 +41,30 @@ var languagePluginLoader = new Promise((resolve, reject) => {
let
queue
=
new
Array
(
names
);
let
toLoad
=
new
Set
();
while
(
queue
.
length
)
{
const
package_uri
=
queue
.
pop
();
var
package_uri
=
queue
.
pop
();
const
package
=
_uri_to_package_name
(
package_uri
);
if
(
package
==
null
)
{
console
.
log
(
`Invalid package name or URI '
${
package_uri
}
'`
);
break
;
}
else
if
(
package
==
package_uri
)
{
package_uri
=
'
packages.json
'
;
}
console
.
log
(
`Loading
${
package
}
from
${
package_uri
}
`
);
if
(
!
loadedPackages
.
has
(
package
))
{
if
(
package
in
loadedPackages
)
{
if
(
package_uri
!=
loadedPackages
[
package
])
{
console
.
log
(
`Error: URI mismatch, attempting to load package `
+
`
${
package
}
from
${
package_uri
}
while is already `
+
`loaded from
${
loadedPackages
[
package
]}
!`
);
}
}
else
{
toLoad
.
add
(
package
);
if
(
packages
.
hasOwnProperty
(
package
))
{
packages
[
package
].
forEach
((
subpackage
)
=>
{
if
(
!
loadedPackages
.
has
(
subpackage
)
&&
!
toLoad
.
has
(
subpackage
))
{
if
(
!
(
subpackage
in
loadedPackages
)
&&
!
toLoad
.
has
(
subpackage
))
{
queue
.
push
(
subpackage
);
}
});
...
...
@@ -73,7 +81,9 @@ var languagePluginLoader = new Promise((resolve, reject) => {
pyodide
.
monitorRunDependencies
=
(
n
)
=>
{
if
(
n
===
0
)
{
toLoad
.
forEach
((
package
)
=>
loadedPackages
.
add
(
package
));
toLoad
.
forEach
((
package
)
=>
{
loadedPackages
[
package
]
=
package
;
});
delete
pyodide
.
monitorRunDependencies
;
const
packageList
=
Array
.
from
(
toLoad
.
keys
()).
join
(
'
,
'
);
resolve
(
`Loaded
${
packageList
}
`
);
...
...
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