diff --git a/packages/transpiler/transpiler.mjs b/packages/transpiler/transpiler.mjs index aedf8f3a..72f2e851 100644 --- a/packages/transpiler/transpiler.mjs +++ b/packages/transpiler/transpiler.mjs @@ -1,8 +1,7 @@ -import escodegen from 'escodegen'; -import { parse } from 'acorn'; -import { walk } from 'estree-walker'; -import { isNoteWithOctave } from '@strudel/core'; import { getLeafLocations } from '@strudel/mini'; +import { parse } from 'acorn'; +import escodegen from 'escodegen'; +import { walk } from 'estree-walker'; export function transpiler(input, options = {}) { const { wrapAsync = false, addReturn = true, emitMiniLocations = true, emitWidgets = true } = options; @@ -47,6 +46,9 @@ export function transpiler(input, options = {}) { }); return this.replace(widgetWithLocation(node)); } + if (isBareSamplesCall(node, parent)) { + return this.replace(withAwait(node)); + } }, leave(node, parent, prop, index) {}, }); @@ -119,3 +121,14 @@ function widgetWithLocation(node) { node.callee.name = 'sliderWithID'; return node; } + +function isBareSamplesCall(node, parent) { + return node.type === 'CallExpression' && node.callee.name === 'samples' && parent.type !== 'AwaitExpression'; +} + +function withAwait(node) { + return { + type: 'AwaitExpression', + argument: node, + }; +}