Skip to content

Commit 53e910a

Browse files
committed
Fix worker interpreter version
1 parent 452e83c commit 53e910a

12 files changed

+163
-127
lines changed

docs/index.js

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

docs/index.js.map

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

docs/zip-BIfA-Q-T.js

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

docs/zip-BIfA-Q-T.js.map

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

docs/zip-C10rja2G.js

-2
This file was deleted.

docs/zip-C10rja2G.js.map

-1
This file was deleted.

esm/custom.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { $$ } from 'basic-devtools';
44
import { JSModules, isSync, assign, create, createOverload, createResolved, dedent, defineProperty, nodeInfo, registerJSModules } from './utils.js';
55
import { getDetails } from './script-handler.js';
66
import { registry as defaultRegistry, prefixes, configs } from './interpreters.js';
7-
import { getRuntimeID } from './loader.js';
7+
import { getRuntimeID, resolveConfig } from './loader.js';
88
import { addAllListeners } from './listeners.js';
99
import { Hook, XWorker as XW } from './xworker.js';
1010
import { workers, workersHandler } from './workers.js';
@@ -62,13 +62,20 @@ export const handleCustomType = async (node) => {
6262
try {
6363
const worker = workerURL(node);
6464
if (worker) {
65+
let v = version;
66+
const cfg = node.getAttribute('config') || config || {};
67+
if (!v) {
68+
const [o] = resolveConfig(cfg, configURL);
69+
const details = await o;
70+
v = details.version || details.interpreter;
71+
}
6572
const xworker = XW.call(new Hook(null, hooks), worker, {
6673
...nodeInfo(node, type),
67-
version,
6874
configURL,
75+
version: v,
6976
type: runtime,
7077
custom: type,
71-
config: node.getAttribute('config') || config || {},
78+
config: cfg,
7279
async: !isSync(node),
7380
serviceWorker: node.getAttribute('service-worker'),
7481
});

esm/loader.js

+18-13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ export const getConfigURLAndType = (config, configURL = './config.txt') => {
1717
return [absoluteURL(config), type];
1818
};
1919

20+
export const resolveConfig = (config, configURL, options = {}) => {
21+
const [absolute, type] = getConfigURLAndType(config, configURL);
22+
if (type === 'json') {
23+
options = fetch(absolute).json();
24+
} else if (type === 'toml') {
25+
options = fetch(absolute).text().then(toml);
26+
} else if (type === 'string') {
27+
options = parseString(config);
28+
} else if (type === 'object' && config) {
29+
options = config;
30+
} else if (type === 'txt' && typeof options === 'string') {
31+
options = parseString(options);
32+
}
33+
config = absolute;
34+
return [options, config];
35+
};
36+
2037
const parseString = config => {
2138
try {
2239
return parse(config);
@@ -43,19 +60,7 @@ export const getRuntime = (id, config, configURL, options = {}) => {
4360
if (config) {
4461
// REQUIRES INTEGRATION TEST
4562
/* c8 ignore start */
46-
const [absolute, type] = getConfigURLAndType(config, configURL);
47-
if (type === 'json') {
48-
options = fetch(absolute).json();
49-
} else if (type === 'toml') {
50-
options = fetch(absolute).text().then(toml);
51-
} else if (type === 'string') {
52-
options = parseString(config);
53-
} else if (type === 'object' && config) {
54-
options = config;
55-
} else if (type === 'txt' && typeof options === 'string') {
56-
options = parseString(options);
57-
}
58-
config = absolute;
63+
[options, config] = resolveConfig(config, configURL, options);
5964
/* c8 ignore stop */
6065
}
6166
return resolve(options).then(options => interpreter[id](options, config));

esm/script-handler.js

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export const handle = async (script) => {
150150
const XWorker = $xworker(type, versionValue);
151151
const xworker = new XWorker(url, {
152152
...nodeInfo(script, type),
153+
version: versionValue,
153154
async: isAsync,
154155
config: configValue,
155156
serviceWorker: sw?.value,

package-lock.json

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

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939
"license": "APACHE-2.0",
4040
"devDependencies": {
4141
"@node-loader/import-maps": "^1.1.0",
42-
"@playwright/test": "^1.45.3",
42+
"@playwright/test": "^1.46.1",
4343
"@rollup/plugin-node-resolve": "^15.2.3",
4444
"@rollup/plugin-terser": "^0.4.4",
45-
"@zip.js/zip.js": "^2.7.48",
45+
"@zip.js/zip.js": "^2.7.51",
4646
"c8": "^10.1.2",
4747
"chokidar": "^3.6.0",
48-
"eslint": "^9.8.0",
48+
"eslint": "^9.9.1",
4949
"linkedom": "^0.18.4",
50-
"rollup": "^4.20.0",
50+
"rollup": "^4.21.1",
5151
"static-handler": "^0.4.3",
5252
"typescript": "^5.5.4"
5353
},
@@ -78,14 +78,14 @@
7878
"@webreflection/idb-map": "^0.3.1",
7979
"basic-devtools": "^0.1.6",
8080
"codedent": "^0.1.2",
81-
"coincident": "^2.0.6",
81+
"coincident": "^2.0.7",
8282
"gc-hook": "^0.4.1",
8383
"html-escaper": "^3.0.3",
8484
"proxy-target": "^3.0.2",
8585
"sticky-module": "^0.1.1",
8686
"to-json-callback": "^0.1.1"
8787
},
8888
"worker": {
89-
"blob": "sha256-Hx4kuOT2gB4ft8/m8SE8oCI1P5VB96BdAgxbyFBOBN0="
89+
"blob": "sha256-QDmhtpGRALCZn/gNlUmUSRUiiNDmiCk9Pn61k6Addho="
9090
}
9191
}

test/interpreter/index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Pyodide Worker Version</title>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width,initial-scale=1">
7+
<script type="module" src="../../dist/index.js"></script>
8+
</head>
9+
<body>
10+
<script type="pyodide" version='https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.mjs' worker>
11+
import pyodide
12+
print(pyodide.__version__)
13+
</script>
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)