MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / rewriteCurrentScript

Function rewriteCurrentScript

packages/extension/rewrite/runtime.ts:49–74  ·  view source on GitHub ↗
(groups: Group[])

Source from the content-addressed store, hash-verified

47}
48
49export async function rewriteCurrentScript(groups: Group[]): Promise<void> {
50 const current = getCurrentScript()
51 if (!current) {
52 return
53 }
54
55 const src = current.src
56
57 try {
58 const response = await fetch(src)
59 const original = await response.text()
60 const { content: rewritten, changed } = applyGroups(original, groups)
61
62 if (changed) {
63 logger.log(`Rewrote script: ${src}`)
64 }
65
66 const content = patchFigmaDelete(rewritten)
67 withCurrentScript(current, () => {
68 new Function(content)()
69 })
70 } catch (error) {
71 logger.error(error)
72 replaceScript(current, `${src}?fallback`)
73 }
74}

Callers 3

figma.tsFile · 0.90
figma.tsFile · 0.90
runtime.test.tsFile · 0.90

Calls 5

applyGroupsFunction · 0.90
getCurrentScriptFunction · 0.85
patchFigmaDeleteFunction · 0.85
withCurrentScriptFunction · 0.85
replaceScriptFunction · 0.85

Tested by

no test coverage detected