MCPcopy Create free account
hub / github.com/Tencent/libpag / transform

Function transform

web/script/plugin/rollup-plugin-replace.js:7–28  ·  view source on GitHub ↗
(code, id)

Source from the content-addressed store, hash-verified

5 return {
6 name: 'replaceFunc',
7 transform(code, id) {
8 let codeStr = `${code}`;
9 const magic = new MagicString(codeStr);
10 replaceFunctionConfig.forEach((item) => {
11 if (item.type === 'string') {
12 const startOffset = codeStr.indexOf(item.start);
13 if (startOffset > -1) {
14 magic.overwrite(startOffset, startOffset + item.start.length, item.replaceStr);
15 }
16 } else {
17 const startOffset = codeStr.indexOf(item.start);
18 const endOffset = codeStr.indexOf(item.end);
19 if (startOffset > -1 && endOffset > startOffset && item.replaceStr) {
20 magic.overwrite(startOffset, endOffset, item.replaceStr);
21 }
22 }
23 });
24 return {
25 code: magic.toString(),
26 map: magic.generateMap({ hires: true }),
27 };
28 },
29 };
30}

Callers 6

mainFunction · 0.85
GradientPaintMethod · 0.85
getShaderMethod · 0.85
ToLowerCaseFunction · 0.85
ToUpperCaseFunction · 0.85
IsEndWidthSuffixFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected