Merge remote-tracking branch 'origin/HEAD' into notes-and-numbers

This commit is contained in:
Felix Roos 2022-03-06 20:33:41 +01:00
commit 830f0a1026
7 changed files with 35 additions and 8 deletions

View file

@ -5,6 +5,8 @@ import './voicings';
import './tonal.mjs';
import './xen.mjs';
import './tune.mjs';
import './tonal';
import gist from './gist.js';
import shapeshifter from './shapeshifter';
import { minify } from './parse';
import * as Tone from 'tone';
@ -29,7 +31,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

6
repl/src/gist.js Normal file
View file

@ -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));