Prebake in settings

Update prebake without reload
This commit is contained in:
John Björk 2026-01-30 20:52:15 +01:00
parent b4e171f5b4
commit 9f2237e11d
No known key found for this signature in database
GPG key ID: 303B6ADF2F569B0A
11 changed files with 292 additions and 37 deletions

View file

@ -6,7 +6,7 @@ This program is free software: you can redistribute it and/or modify it under th
import { code2hash, getPerformanceTimeSeconds, logger, silence } from '@strudel/core';
import { getDrawContext } from '@strudel/draw';
import { evaluate, transpiler } from '@strudel/transpiler';
import { evaluate, evaluateUserPrebake, transpiler } from '@strudel/transpiler';
import {
getAudioContextCurrentTime,
renderPatternAudio,
@ -89,7 +89,7 @@ export function useReplContext() {
prebake: async () =>
Promise.all([modulesLoading, presets]).then(() => {
if (prebakeScript?.length) {
return evaluate(prebakeScript ?? '');
return evaluateUserPrebake(prebakeScript ?? '');
}
}),
onUpdateState: (state) => {
@ -181,6 +181,16 @@ export function useReplContext() {
editorRef.current?.updateSettings(editorSettings);
}, [_settings]);
useEffect(() => {
const prebake = async () =>
Promise.all([modulesLoading, presets]).then(() => {
if (prebakeScript?.length) {
return evaluateUserPrebake(prebakeScript ?? '');
}
});
editorRef.current?.updatePrebake(prebake);
}, [prebakeScript]);
//
// UI Actions
//