Skip to content

Commit 1fa57ed

Browse files
committed
Fixed relative URLs for both micropip and mip
1 parent 4db4ec0 commit 1fa57ed

10 files changed

+15
-12
lines changed

Diff for: docs/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: docs/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: docs/toml-DiUM0_qs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: docs/zip-CFEEYRfx.js

-2
This file was deleted.

Diff for: docs/zip-CFEEYRfx.js.map

-1
This file was deleted.

Diff for: docs/zip-DPXsOtR5.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: esm/interpreter/micropython.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fetch from '@webreflection/fetch';
33
import { createProgress, writeFile } from './_utils.js';
44
import { getFormat, loader, loadProgress, registerJSModule, run, runAsync, runEvent } from './_python.js';
55
import { stdio, buffered } from './_io.js';
6-
import { absoluteURL } from '../utils.js';
6+
import { absoluteURL, fixedRelative } from '../utils.js';
77
import mip from '../python/mip.js';
88
import { zip } from '../3rd-party.js';
99

@@ -44,7 +44,7 @@ export default {
4444
this.writeFile(interpreter, './mip.py', mip);
4545
if (config.packages) {
4646
progress('Loading packages');
47-
await py_imports(config.packages);
47+
await py_imports(config.packages.map(fixedRelative, baseURL));
4848
progress('Loaded packages');
4949
}
5050
progress('Loaded MicroPython');

Diff for: esm/interpreter/pyodide.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { create } from 'gc-hook';
33
import { RUNNING_IN_WORKER, createProgress, writeFile } from './_utils.js';
44
import { getFormat, loader, loadProgress, registerJSModule, run, runAsync, runEvent } from './_python.js';
55
import { stdio } from './_io.js';
6-
import { IDBMapSync, isArray } from '../utils.js';
6+
import { IDBMapSync, isArray, fixedRelative } from '../utils.js';
77

88
const type = 'pyodide';
99
const toJsOptions = { dict_converter: Object.fromEntries };
@@ -101,7 +101,7 @@ export default {
101101
if (!save) storage.clear();
102102
// otherwise check if cache is known
103103
else if (packages) {
104-
packages = packages.slice(0).sort();
104+
packages = packages.map(fixedRelative, baseURL).sort();
105105
// packages are uniquely stored as JSON key
106106
const key = stringify(packages);
107107
if (storage.has(key)) {

Diff for: esm/utils.js

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ const { all, resolve } = new Proxy(Promise, {
2020
const absoluteURL = (path, base = location.href) =>
2121
new URL(path, base.replace(/^blob:/, '')).href;
2222

23+
function fixedRelative(path) {
24+
'use strict';
25+
return path.startsWith('.') ? absoluteURL(path, this) : path;
26+
}
27+
2328
/* c8 ignore start */
2429
let id = 0;
2530
const nodeInfo = (node, type) => ({
@@ -144,5 +149,6 @@ export {
144149
all,
145150
resolve,
146151
absoluteURL,
152+
fixedRelative,
147153
nodeInfo,
148154
};

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@
9494
"to-json-callback": "^0.1.1"
9595
},
9696
"worker": {
97-
"blob": "sha256-fH3KC/dEPpvYJaLteD5BhwHUo3eOXk+xcMrnO0EdlL0="
97+
"blob": "sha256-DiH3IPiWffby3RtkyH5gFzBwrJa/Qnc9RmPLpN+OlF8="
9898
}
9999
}

0 commit comments

Comments
 (0)