1# @strudel/transpiler 2 3This package contains a JS code transpiler with a plugin system that can be used to transform the code. 4 5A plugin can be registered via a `registerTranspilerPlugin` call : 6 7```js 8registerTranspilerPlugin({ 9 walk: (context) => ({ 10 enter: function(node, parent, prop, index) {}, 11 leave: function(node, parent, prop, index) {} 12 }) 13}) 14``` 15 16where the enter/leave functions (both optional) follow the `estree-walker` walk API. 17 184 plugins are currently hosted inside `@strudel/transpiler` 19 20- mini: add locations of mini notation strings (double quoted or backticked) for highlighting 21- widgets: add handling of sliders & draw widgets 22- sample: make it possible to call a sample without await 23- kabelsalat: transform the code to handle the `K(..)` kabelsalat notation 24 25it also 26 27- adds return statement to the last expression 28- handles label capturing for block-based eval 29 30## Install 31 32```sh 33npm i @strudel/transpiler 34``` 35 36## Use 37 38```js 39import { transpiler } from '@strudel/core'; 40import { evaluate } from '@strudel/core'; 41 42transpiler('note("c3 [e3,g3]")', { wrapAsync: false, addReturn: false, simpleLocs: true }); 43/* mini('c3 [e3,g3]').withMiniLocation(7,17) */ 44 45evaluate(note('c3 [e3,g3]'), transpiler); // returns pattern of above code 46```