MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / elementStyleUsingPlugin

Function elementStyleUsingPlugin

packages/tooling/src/vite.plugin.transform.ts:28–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26 * statement before the next match.
27 */
28export function elementStyleUsingPlugin(): Plugin {
29 return {
30 name: 'alphatab:lower-element-style-using',
31 enforce: 'pre',
32 transform: {
33 filter: { id: /\.tsx?$/ },
34 handler(code, id) {
35 if (!code.includes('ElementStyleHelper')) {
36 return null;
37 }
38
39 const program = parseAst(
40 code,
41 { lang: id.endsWith('.tsx') ? 'tsx' : 'ts', sourceType: 'module' },
42 id
43 );
44
45 const ms = new MagicString(code);
46 walk(program, node => {
47 if (node.type === 'BlockStatement' || node.type === 'Program') {
48 rewriteBody((node as BlockStatement | Program).body as Statement[], ms);
49 }
50 });
51
52 if (!ms.hasChanged()) {
53 return null;
54 }
55
56 return {
57 code: ms.toString(),
58 map: ms.generateMap({ hires: 'boundary', source: id })
59 };
60 }
61 }
62 };
63}
64
65function rewriteBody(body: Statement[], ms: MagicString): void {
66 let open: { id: string; lastStmtEnd: number } | null = null;

Callers 2

vite.config.tsFile · 0.90
defaultBuildUserConfigFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected