vanilla-repl-cm6: style + codesplitting

This commit is contained in:
Felix Roos 2023-05-05 11:09:44 +02:00
parent 1f4c2f8c5a
commit d96f3f9dd4
2 changed files with 25 additions and 33 deletions

View file

@ -1,38 +1,29 @@
import { controls, repl, evalScope } from "@strudel.cycles/core"; import { getAudioContext, webaudioOutput, initAudioOnFirstClick, registerSynthSounds } from '@strudel.cycles/webaudio';
import { transpiler } from "@strudel.cycles/transpiler";
import {
getAudioContext,
webaudioOutput,
initAudioOnFirstClick,
registerSynthSounds
} from "@strudel.cycles/webaudio";
import { registerSoundfonts } from "@strudel.cycles/soundfonts";
const initAudio = initAudioOnFirstClick(); const initAudio = initAudioOnFirstClick();
const ctx = getAudioContext(); const ctx = getAudioContext();
const loadModules = (scope = {}) => export async function initStrudel(options = {}) {
evalScope( const [{ controls, repl, evalScope }, { registerSoundfonts }, { transpiler }] = await Promise.all([
import('@strudel.cycles/core'),
import('@strudel.cycles/soundfonts'),
import('@strudel.cycles/transpiler'),
]);
const loadModules = evalScope(
controls, controls,
import("@strudel.cycles/core"), import('@strudel.cycles/core'),
import("@strudel.cycles/mini"), import('@strudel.cycles/mini'),
import("@strudel.cycles/tonal"), import('@strudel.cycles/tonal'),
import("@strudel.cycles/webaudio"), import('@strudel.cycles/webaudio'),
scope
); );
export async function initStrudel(options = {}) { await Promise.all([initAudio, loadModules, registerSynthSounds(), registerSoundfonts()]);
await Promise.all([
initAudio,
loadModules(),
registerSynthSounds(),
registerSoundfonts()
]);
return repl({ return repl({
defaultOutput: webaudioOutput, defaultOutput: webaudioOutput,
getTime: () => ctx.currentTime, getTime: () => ctx.currentTime,
transpiler, transpiler,
...options ...options,
}); });
} }

View file

@ -4,15 +4,6 @@ html {
height: 100%; height: 100%;
} }
#editor {
overflow: auto;
height: 100%;
}
.cm-editor {
height: 100%;
}
main { main {
height: 100%; height: 100%;
display: flex; display: flex;
@ -21,6 +12,16 @@ main {
.container { .container {
flex-grow: 1; flex-grow: 1;
max-height: 100%;
position: relative;
}
#editor {
overflow: auto;
}
.cm-editor {
height: 100%;
} }
#roll { #roll {