diff --git a/repl/src/evaluate.ts b/repl/src/evaluate.ts index 87191bd8..f08d0d80 100644 --- a/repl/src/evaluate.ts +++ b/repl/src/evaluate.ts @@ -3,6 +3,7 @@ import './tone'; import './midi'; import './voicings'; import './tonal'; +import gist from './gist.js'; import shapeshifter from './shapeshifter'; import { minify } from './parse'; import * as Tone from 'tone'; @@ -27,7 +28,7 @@ hackLiteral(String, ['mini', 'm'], bootstrapped.mini); // comment out this line hackLiteral(String, ['pure', 'p'], bootstrapped.pure); // comment out this line if you panic // this will add everything to global scope, which is accessed by eval -Object.assign(globalThis, bootstrapped, Tone, toneHelpers); +Object.assign(globalThis, bootstrapped, Tone, toneHelpers, { gist }); export const evaluate: any = async (code: string) => { const shapeshifted = shapeshifter(code); // transform syntactically correct js code to semantically usable code diff --git a/repl/src/gist.js b/repl/src/gist.js new file mode 100644 index 00000000..716f797f --- /dev/null +++ b/repl/src/gist.js @@ -0,0 +1,6 @@ +// this is a shortcut to eval code from a gist +// why? to be able to shorten strudel code + e.g. be able to change instruments after links have been generated +export default (route) => + fetch(`https://gist.githubusercontent.com/${route}?cachebust=${Date.now()}`) + .then((res) => res.text()) + .then((code) => eval(code));