| 8 | const assetBase = "/dashboard-plugins/tracedecay/dist"; |
| 9 | |
| 10 | function createReactStub() { |
| 11 | return { |
| 12 | createElement(type, props, ...children) { |
| 13 | return { |
| 14 | type, |
| 15 | props: { ...(props || {}), children: children.length <= 1 ? children[0] : children }, |
| 16 | }; |
| 17 | }, |
| 18 | useState(initial) { |
| 19 | let value = typeof initial === "function" ? initial() : initial; |
| 20 | return [ |
| 21 | value, |
| 22 | (next) => { |
| 23 | value = typeof next === "function" ? next(value) : next; |
| 24 | }, |
| 25 | ]; |
| 26 | }, |
| 27 | useEffect(run) { |
| 28 | run(); |
| 29 | }, |
| 30 | }; |
| 31 | } |
| 32 | |
| 33 | async function loadWrapper({ scriptsByUrl }) { |
| 34 | const source = await readFile(wrapperPath, "utf8"); |