Revert "[RC] Ensure dedicated configs per interpreter (#1743)" (#1747)

This reverts commit b4c686f411.
This commit is contained in:
Ted Patrick
2023-09-21 14:11:22 -05:00
committed by GitHub
parent b4c686f411
commit 5079dd19cb
12 changed files with 77 additions and 123 deletions

View File

@@ -9,11 +9,10 @@ import { queryTarget } from "../node_modules/polyscript/esm/script-handler.js";
import { dedent, dispatch } from "../node_modules/polyscript/esm/utils.js";
import { Hook } from "../node_modules/polyscript/esm/worker/hooks.js";
import TYPES from "./types.js";
import configs from "./config.js";
import { ErrorCode } from "./exceptions.js";
import sync from "./sync.js";
import stdlib from "./stdlib.js";
import { ErrorCode } from "./exceptions.js";
import { config, plugins, error } from "./config.js";
import { robustFetch as fetch, getText } from "./fetch.js";
const { assign, defineProperty } = Object;
@@ -21,6 +20,11 @@ const { assign, defineProperty } = Object;
// allows lazy element features on code evaluation
let currentElement;
const TYPES = new Map([
["py", "pyodide"],
["mpy", "micropython"],
]);
// generic helper to disambiguate between custom element and script
const isScript = ({ tagName }) => tagName === "SCRIPT";
@@ -99,12 +103,7 @@ const workerHooks = {
[...hooks.codeAfterRunWorkerAsync].map(dedent).join("\n"),
};
const exportedConfig = {};
export { exportedConfig as config };
for (const [TYPE, interpreter] of TYPES) {
const { config, plugins, error } = configs.get(TYPE);
// create a unique identifier when/if needed
let id = 0;
const getID = (prefix = TYPE) => `${prefix}-${id++}`;
@@ -274,9 +273,6 @@ for (const [TYPE, interpreter] of TYPES) {
// define py-script only if the config didn't throw an error
if (!error) customElements.define(`${TYPE}-script`, PyScriptElement);
// export the used config without allowing leaks through it
exportedConfig[TYPE] = structuredClone(config);
}
// TBD: I think manual worker cases are interesting in pyodide only