Skip to content

Commit f570b46

Browse files
committed
WIP
1 parent a1b1d3e commit f570b46

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed

docs/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esm/interpreter/_remote_package.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// hackity hack hack for PyScript FUN
2+
3+
import { toml } from '../3rd-party.js';
4+
5+
const remote = async (config, packages) => {
6+
const repackaged = [];
7+
for (const pkg of packages) {
8+
if (pkg.endsWith('.toml')) {
9+
const text = await (await fetch(pkg)).text();
10+
const { files, js_modules, packages } = await toml(text);
11+
if (packages)
12+
repackaged.push(...(await remote(config, packages)));
13+
if (js_modules) {
14+
if (!config.js_modules) config.js_modules = {};
15+
const { main, worker } = js_modules;
16+
if (main) {
17+
if (!config.js_modules.main) config.js_modules.main = {};
18+
for (const key in main) {
19+
config.js_modules.main[new URL(key, pkg).href] = main[key];
20+
}
21+
}
22+
if (worker) {
23+
if (!config.js_modules.worker) config.js_modules.worker = {};
24+
for (const key in worker) {
25+
config.js_modules.worker[new URL(key, pkg).href] = worker[key];
26+
}
27+
}
28+
}
29+
if (files) {
30+
if (!config.files) config.files = {};
31+
for (const key in files) {
32+
config.files[new URL(key, pkg).href] = files[key];
33+
}
34+
}
35+
}
36+
else repackaged.push(pkg);
37+
}
38+
return [...new Set(repackaged)];
39+
};
40+
41+
export default remote;

esm/interpreter/pyodide.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createProgress, writeFile } from './_utils.js';
22
import { getFormat, loader, loadProgress, registerJSModule, run, runAsync, runEvent } from './_python.js';
33
import { stdio } from './_io.js';
44
import { IDBMapSync, isArray, fixedRelative, js_modules } from '../utils.js';
5+
import _remote_package from './_remote_package.js';
56

67
const type = 'pyodide';
78
const toJsOptions = { dict_converter: Object.fromEntries };
@@ -88,6 +89,7 @@ export default {
8889
if (!save) storage.clear();
8990
// otherwise check if cache is known
9091
else if (packages) {
92+
config.packages = packages = await _remote_package(config, packages);
9193
// packages_cache = 'passthrough' means: do not use micropip.install
9294
if (config.packages_cache === 'passthrough') {
9395
options.packages = packages;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@
9595
"to-json-callback": "^0.1.1"
9696
},
9797
"worker": {
98-
"blob": "sha256-WA7okaRfT4eGqj3HkcOGiNRTDXg4EBTwE/PBNBTZ/rI="
98+
"blob": "sha256-or/eVGAwbAdeOd7ha5qhvvgTfdnS92Z0Vg6qnwmIgBI="
9999
}
100100
}

0 commit comments

Comments
 (0)