From a2d7d6e81f6d03a338f9a6e190374605c9775a6e Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sat, 14 Jan 2023 01:27:22 +0100 Subject: [PATCH] fix: mini repl could eval before modules are ready --- website/src/docs/MiniRepl.jsx | 9 +++++---- website/src/pages/learn/getting-started.mdx | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/website/src/docs/MiniRepl.jsx b/website/src/docs/MiniRepl.jsx index 425d18a3..d6a325ff 100644 --- a/website/src/docs/MiniRepl.jsx +++ b/website/src/docs/MiniRepl.jsx @@ -3,8 +3,9 @@ import { initAudioOnFirstClick } from '@strudel.cycles/webaudio'; import { useEffect, useState } from 'react'; import { prebake } from '../repl/prebake'; +let modules; if (typeof window !== 'undefined') { - evalScope( + modules = evalScope( controls, import('@strudel.cycles/core'), // import('@strudel.cycles/tone'), @@ -27,9 +28,9 @@ export function MiniRepl({ tune, drawTime, punchcard, canvasHeight = 100 }) { useEffect(() => { // we have to load this package on the client // because codemirror throws an error on the server - import('@strudel.cycles/react').then((res) => { - setRepl(() => res.MiniRepl); - }); + Promise.all([import('@strudel.cycles/react'), modules]) + .then(([res]) => setRepl(() => res.MiniRepl)) + .catch((err) => console.error(err)); }, []); return Repl ? (
diff --git a/website/src/pages/learn/getting-started.mdx b/website/src/pages/learn/getting-started.mdx index 2ad890e3..fbee92c1 100644 --- a/website/src/pages/learn/getting-started.mdx +++ b/website/src/pages/learn/getting-started.mdx @@ -54,7 +54,7 @@ Alternatively, you can get a taste of what Strudel can do by clicking play on th hh: ['hh27/000_hh27closedhh.wav','hh/000_hh3closedhh.wav'], }, 'github:tidalcycles/Dirt-Samples/master/'); stack( -s("bd,[~ ],hh(3,4)") // drums +s("bd,[~ ],hh*8") // drums .speed(perlin.range(.7,.9)) // random sample speed variation ,"" // bassline .off(1/8,x=>x.add(12).degradeBy(.5)) // random octave jumps