diff --git a/packages/core/repl.mjs b/packages/core/repl.mjs index 83d7d409a..56a26bb52 100644 --- a/packages/core/repl.mjs +++ b/packages/core/repl.mjs @@ -5,7 +5,6 @@ import { setTime } from './time.mjs'; import { evalScope } from './evaluate.mjs'; import { register } from './pattern.mjs'; import { isTauri } from '../../website/src/tauri.mjs'; -import { CyclistBridge } from '../desktopbridge/cyclistbridge.mjs'; export function repl({ interval, @@ -18,6 +17,7 @@ export function repl({ transpiler, onToggle, editPattern, + createCyclist, }) { //TODO: could maybe be enabled with a command or a switch in settings? const abelinkEnabled = isTauri(); @@ -28,7 +28,7 @@ export function repl({ getTime, onToggle, }; - const scheduler = abelinkEnabled ? new CyclistBridge(cyclistParams) : new Cyclist(cyclistParams); + const scheduler = createCyclist?.(cyclistParams) || new Cyclist(p); const setPattern = (pattern, autostart = true) => { pattern = editPattern?.(pattern) || pattern; diff --git a/packages/react/src/hooks/useStrudel.mjs b/packages/react/src/hooks/useStrudel.mjs index a10998e73..cb154d80b 100644 --- a/packages/react/src/hooks/useStrudel.mjs +++ b/packages/react/src/hooks/useStrudel.mjs @@ -19,6 +19,7 @@ function useStrudel({ drawContext, drawTime = [-2, 2], paintOptions = {}, + createCyclist, // (params) => Cyclist }) { const id = useMemo(() => s4(), []); canvasId = canvasId || `canvas-${id}`; @@ -45,6 +46,7 @@ function useStrudel({ onEvalError?.(err); }, getTime, + createCyclist, drawContext, transpiler, editPattern, diff --git a/website/src/repl/Repl.jsx b/website/src/repl/Repl.jsx index 456f53c60..04f5002c2 100644 --- a/website/src/repl/Repl.jsx +++ b/website/src/repl/Repl.jsx @@ -4,7 +4,7 @@ Copyright (C) 2022 Strudel contributors - see . */ -import { cleanupDraw, cleanupUi, controls, evalScope, getDrawContext, logger } from '@strudel.cycles/core'; +import { cleanupDraw, cleanupUi, controls, evalScope, getDrawContext, logger, Cyclist } from '@strudel.cycles/core'; import { CodeMirror, cx, flash, useHighlighting, useStrudel, useKeydown } from '@strudel.cycles/react'; import { getAudioContext, initAudioOnFirstClick, resetLoadedSounds, webaudioOutput } from '@strudel.cycles/webaudio'; import { createClient } from '@supabase/supabase-js'; @@ -23,6 +23,7 @@ import { settingPatterns } from '../settings.mjs'; import { code2hash, hash2code } from './helpers.mjs'; import { isTauri } from '../tauri.mjs'; import { useWidgets } from '@strudel.cycles/react/src/hooks/useWidgets.mjs'; +import { CyclistBridge } from '@strudel/desktopbridge/cyclistbridge.mjs'; const { latestCode } = settingsMap.get(); @@ -164,6 +165,7 @@ export function Repl({ embedded = false }) { drawContext, // drawTime: [0, 6], paintOptions, + createCyclist: (p) => (isTauri() ? new CyclistBridge(p) : new Cyclist(p)), }); // init code