fix nano-repl prod build

This commit is contained in:
Felix Roos 2022-08-23 18:23:36 +02:00
parent 11a9f3ced3
commit 4dfc34515c
2 changed files with 6 additions and 5 deletions

View file

@ -12,10 +12,11 @@ const createWorker = (func) => new Worker(urlifyFunction(func));
// this is just a setInterval with a counter, running in a worker // this is just a setInterval with a counter, running in a worker
export class ClockWorker { export class ClockWorker {
worker; worker;
interval = 1 / 20; // query span, use powers of 2 to get better float accuracy interval = 1 / 20; // query span, use divisors of 1000 to get better accuracy
tick = 0; tick = 0;
constructor(callback, interval = this.interval) { constructor(callback, interval) {
this.interval = interval; // for some reason the constructor default value won't do in prod build
this.interval = interval || this.interval;
this.worker = createWorker(() => { this.worker = createWorker(() => {
// we cannot use closures here! // we cannot use closures here!
let interval; let interval;
@ -47,7 +48,7 @@ export class ClockWorker {
} }
}; };
}); });
this.worker.postMessage({ interval }); this.setInterval(this.interval);
// const round = (n, d) => Math.round(n * d) / d; // const round = (n, d) => Math.round(n * d) / d;
this.worker.onmessage = (e) => { this.worker.onmessage = (e) => {
if (e.data === 'tick') { if (e.data === 'tick') {

View file

@ -9,7 +9,7 @@ import './style.css';
// import { prebake } from '../../../../../repl/src/prebake.mjs'; // import { prebake } from '../../../../../repl/src/prebake.mjs';
// TODO: only import stuff when play is pressed? // TODO: only import stuff when play is pressed?
await evalScope( evalScope(
controls, controls,
import('@strudel.cycles/core'), import('@strudel.cycles/core'),
// import('@strudel.cycles/tone'), // import('@strudel.cycles/tone'),