mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-23 04:03:00 -05:00
WIP: Bringing PyScript.next PoC to the main project (#1507)
* kill unwrapped_remote (#1490) * kill unwrapped_remote * linting * don't use callKwargs for python plugins * fix tests and improve types * Bringing PyScript.next PoC to the main project * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Madhur Tandon <20173739+madhur-tandon@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
4467898473
commit
339e40063a
57
pyscript.core/esm/runtimes.js
Normal file
57
pyscript.core/esm/runtimes.js
Normal file
@@ -0,0 +1,57 @@
|
||||
// ⚠️ Part of this file is automatically generated
|
||||
// The :RUNTIMES comment is a delimiter and no code should be written/changed after
|
||||
// See rollup/build_runtimes.cjs to know more
|
||||
|
||||
import { base } from "./runtime/_utils.js";
|
||||
|
||||
/** @type {Map<string, object>} */
|
||||
export const registry = new Map();
|
||||
|
||||
/** @type {Map<string, object>} */
|
||||
export const configs = new Map();
|
||||
|
||||
/** @type {string[]} */
|
||||
export const selectors = [];
|
||||
|
||||
/** @type {string[]} */
|
||||
export const prefixes = [];
|
||||
|
||||
export const runtime = new Proxy(new Map(), {
|
||||
get(map, id) {
|
||||
if (!map.has(id)) {
|
||||
const [type, ...rest] = id.split("@");
|
||||
const runtime = registry.get(type);
|
||||
const url = /^https?:\/\//i.test(rest)
|
||||
? rest[0]
|
||||
: runtime.module(...rest);
|
||||
map.set(id, {
|
||||
url,
|
||||
module: import(url),
|
||||
engine: runtime.engine.bind(runtime),
|
||||
});
|
||||
}
|
||||
const { url, module, engine } = map.get(id);
|
||||
return (config, baseURL) =>
|
||||
module.then((module) => {
|
||||
configs.set(id, config);
|
||||
const fetch = config?.fetch;
|
||||
if (fetch) base.set(fetch, baseURL);
|
||||
return engine(module, config, url);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const register = (runtime) => {
|
||||
for (const type of [].concat(runtime.type)) {
|
||||
registry.set(type, runtime);
|
||||
selectors.push(`script[type="${type}"]`);
|
||||
prefixes.push(`${type}-`);
|
||||
}
|
||||
};
|
||||
|
||||
//:RUNTIMES
|
||||
import micropython from "./runtime/micropython.js";
|
||||
import pyodide from "./runtime/pyodide.js";
|
||||
import ruby from "./runtime/ruby.js";
|
||||
import wasmoon from "./runtime/wasmoon.js";
|
||||
for (const runtime of [micropython, pyodide, ruby, wasmoon]) register(runtime);
|
||||
Reference in New Issue
Block a user