MCPcopy Create free account
hub / github.com/aagentah/nw_wrld / loadAssetOptionInputModule

Function loadAssetOptionInputModule

test/assetOptionInput.test.js:17–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15);
16
17const loadAssetOptionInputModule = () => {
18 const source = fs.readFileSync(assetOptionInputPath, "utf8");
19 const { code } = babel.transformSync(source, {
20 filename: assetOptionInputPath,
21 babelrc: false,
22 configFile: false,
23 presets: [
24 ["@babel/preset-env", { targets: { node: "current" }, modules: "commonjs" }],
25 ["@babel/preset-react", { runtime: "automatic" }],
26 ["@babel/preset-typescript", { isTSX: true, allExtensions: true }],
27 ],
28 });
29
30 const module = { exports: {} };
31 const sandbox = {
32 module,
33 exports: module.exports,
34 require: (specifier) => {
35 if (specifier === "react") {
36 return {
37 memo: (value) => value,
38 useEffect: () => {},
39 useMemo: (factory) => factory(),
40 useRef: (value) => ({ current: value }),
41 useState: (value) => [value, () => {}],
42 };
43 }
44 if (specifier === "react/jsx-runtime") {
45 return {
46 Fragment: Symbol.for("react.fragment"),
47 jsx: () => null,
48 jsxs: () => null,
49 };
50 }
51 if (specifier === "./FormInputs") {
52 return {
53 Select: () => null,
54 TextInput: () => null,
55 };
56 }
57 if (specifier === "../core/constants") {
58 return { CUSTOM_VALUE: "__nw_wrld_custom__" };
59 }
60 if (specifier === "../core/utils") {
61 return {
62 isPlainObject: (value) =>
63 Boolean(value) &&
64 typeof value === "object" &&
65 !Array.isArray(value) &&
66 Object.prototype.toString.call(value) === "[object Object]",
67 };

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected