File size: 2,478 Bytes
bc20498 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
'use strict';
// ⚠️ Part of this file is automatically generated
// The :RUNTIMES comment is a delimiter and no code should be written/changed after
// See rollup/build_interpreters.cjs to know more
const { base } = require('./interpreter/_utils.js');
/** @type {Map<string, object>} */
const registry = new Map();
exports.registry = registry;
/** @type {Map<string, object>} */
const configs = new Map();
exports.configs = configs;
/** @type {string[]} */
const selectors = [];
exports.selectors = selectors;
/** @type {string[]} */
const prefixes = [];
exports.prefixes = prefixes;
/* c8 ignore start */
const interpreter = new Proxy(new Map(), {
get(map, id) {
if (!map.has(id)) {
const [type, ...rest] = id.split('@');
const interpreter = registry.get(type);
const url = /^(?:\.?\.?\/|https?:\/\/)/i.test(rest)
? rest.join('@')
: interpreter.module(...rest);
map.set(id, {
url,
module: import(/* webpackIgnore: true */url),
engine: interpreter.engine.bind(interpreter),
});
}
const { url, module, engine } = map.get(id);
return (config, baseURL) =>
module.then((module) => {
configs.set(id, config);
for (const entry of ['files', 'fetch']) {
const value = config?.[entry];
if (value) base.set(value, baseURL);
}
for (const entry of ['main', 'worker']) {
const value = config?.js_modules?.[entry];
if (value) base.set(value, baseURL);
}
return engine(module, config, url);
});
},
});
exports.interpreter = interpreter;
/* c8 ignore stop */
const register = (interpreter) => {
for (const type of [].concat(interpreter.type)) {
registry.set(type, interpreter);
selectors.push(`script[type="${type}"]`);
prefixes.push(`${type}-`);
}
};
//:RUNTIMES
const micropython = (require('./interpreter/micropython.js'));
const pyodide = (require('./interpreter/pyodide.js'));
const ruby_wasm_wasi = (require('./interpreter/ruby-wasm-wasi.js'));
const wasmoon = (require('./interpreter/wasmoon.js'));
const webr = (require('./interpreter/webr.js'));
for (const interpreter of [micropython, pyodide, ruby_wasm_wasi, wasmoon, webr])
register(interpreter);
|