mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-13 06:19:33 -04:00
code formatting
This commit is contained in:
@@ -190,7 +190,6 @@ export class StrudelMirror {
|
||||
this.onDraw(haps, time, painters);
|
||||
}, drawTime);
|
||||
|
||||
|
||||
this.prebaked = prebake();
|
||||
autodraw && this.drawFirstFrame();
|
||||
this.repl = repl({
|
||||
|
||||
+20
-24
@@ -172,9 +172,9 @@ export function repl({
|
||||
// These are Pattern.prototype methods that create persistent visualizations
|
||||
// I don't like this approach, feels hacky, but since these methods don't create ids that
|
||||
// can be read through the transpiler, I'm not sure how best to detect them.
|
||||
// Would probably be better to register these methods through some function that would
|
||||
// Would probably be better to register these methods through some function that would
|
||||
// tag them better
|
||||
const nonInlineWidgets = ['punchcard', 'spiral', 'scope', 'pitchwheel', 'spectrum', 'pianoroll', 'wordfall',];
|
||||
const nonInlineWidgets = ['punchcard', 'spiral', 'scope', 'pitchwheel', 'spectrum', 'pianoroll', 'wordfall'];
|
||||
|
||||
for (const widget of nonInlineWidgets) {
|
||||
const widgetRegex = new RegExp(`\\.${widget}\\s*\\(`);
|
||||
@@ -187,17 +187,15 @@ export function repl({
|
||||
|
||||
// Helper function to handle single label code block storage
|
||||
function handleSingleLabelBlock(label, code, options, meta) {
|
||||
|
||||
// Detect if this block contains a non-inline widget
|
||||
// For 'all' label, widget info is already on the label object from extractLabelsFromCode
|
||||
|
||||
// As mentioned in detectActiveVisualizer, this is a bad approach to
|
||||
// As mentioned in detectActiveVisualizer, this is a bad approach to
|
||||
// managing non-inline widgets (or widgets that don't have ids)
|
||||
// and a proper solution would give them widgets in the transpiler, or at least
|
||||
// track where they are so we don't have to futz around with regexes
|
||||
const activeVisualizer = label.activeVisualizer !== undefined
|
||||
? label.activeVisualizer
|
||||
: detectActiveVisualizer(code);
|
||||
const activeVisualizer =
|
||||
label.activeVisualizer !== undefined ? label.activeVisualizer : detectActiveVisualizer(code);
|
||||
|
||||
if (activeVisualizer !== null) {
|
||||
lastActiveVisualizerLabel = label.name;
|
||||
@@ -214,7 +212,6 @@ export function repl({
|
||||
activeVisualizer: activeVisualizer, // Store the widget type if present, null otherwise
|
||||
};
|
||||
|
||||
|
||||
// Clean up any blocks with conflicting ranges
|
||||
for (const [existingKey, existingBlock] of Object.entries(codeBlocks)) {
|
||||
if (existingKey !== label.name && existingBlock.range && options.range) {
|
||||
@@ -412,7 +409,7 @@ export function repl({
|
||||
if (labels.length > 0) {
|
||||
for (let i = 0; i < labels.length; i++) {
|
||||
// processLabeledBlock(labels, i, code, options, meta);
|
||||
// processing transpiler output instead of code is simply to avoid
|
||||
// processing transpiler output instead of code is simply to avoid
|
||||
// extra regex in detecting whether or not an inline widget has been commented out
|
||||
processLabeledBlock(labels, i, meta.output, options, meta);
|
||||
}
|
||||
@@ -514,7 +511,6 @@ export function repl({
|
||||
pending: false,
|
||||
});
|
||||
|
||||
|
||||
afterEval?.({ code, pattern, meta, range: options.range, widgetRemoved });
|
||||
return pattern;
|
||||
} catch (err) {
|
||||
@@ -530,18 +526,18 @@ export function repl({
|
||||
|
||||
export const getTrigger =
|
||||
({ getTime, defaultOutput }) =>
|
||||
async (hap, deadline, duration, cps, t) => {
|
||||
// ^ this signature is different from hap.context.onTrigger, as set by Pattern.onTrigger(onTrigger)
|
||||
// TODO: get rid of deadline after https://codeberg.org/uzu/strudel/pulls/1004
|
||||
try {
|
||||
if (!hap.context.onTrigger || !hap.context.dominantTrigger) {
|
||||
await defaultOutput(hap, deadline, duration, cps, t);
|
||||
}
|
||||
if (hap.context.onTrigger) {
|
||||
// call signature of output / onTrigger is different...
|
||||
await hap.context.onTrigger(hap, getTime(), cps, t);
|
||||
}
|
||||
} catch (err) {
|
||||
errorLogger(err, 'getTrigger');
|
||||
async (hap, deadline, duration, cps, t) => {
|
||||
// ^ this signature is different from hap.context.onTrigger, as set by Pattern.onTrigger(onTrigger)
|
||||
// TODO: get rid of deadline after https://codeberg.org/uzu/strudel/pulls/1004
|
||||
try {
|
||||
if (!hap.context.onTrigger || !hap.context.dominantTrigger) {
|
||||
await defaultOutput(hap, deadline, duration, cps, t);
|
||||
}
|
||||
};
|
||||
if (hap.context.onTrigger) {
|
||||
// call signature of output / onTrigger is different...
|
||||
await hap.context.onTrigger(hap, getTime(), cps, t);
|
||||
}
|
||||
} catch (err) {
|
||||
errorLogger(err, 'getTrigger');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,8 +83,8 @@ export const cleanupDrawContext = (replID) => {
|
||||
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||
|
||||
// clear the big canvas context, ignore inline widgets
|
||||
Object.keys(animationFrames).forEach((id) =>
|
||||
(!replID || id.startsWith(replID)) && !id.startsWith('_') && stopAnimationFrame(id)
|
||||
Object.keys(animationFrames).forEach(
|
||||
(id) => (!replID || id.startsWith(replID)) && !id.startsWith('_') && stopAnimationFrame(id),
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export function transpiler(input, options = {}) {
|
||||
emitMiniLocations = true,
|
||||
emitWidgets = true,
|
||||
blockBased = false,
|
||||
range = []
|
||||
range = [],
|
||||
} = options;
|
||||
|
||||
let ast = parse(input, {
|
||||
|
||||
@@ -10,8 +10,13 @@ import bundleAudioWorkletPlugin from 'vite-plugin-bundle-audioworklet';
|
||||
import tailwind from '@astrojs/tailwind';
|
||||
import AstroPWA from '@vite-pwa/astro';
|
||||
|
||||
const site = `https://strudel.cc/`; // root url without a path
|
||||
const base = '/'; // base path of the strudel site
|
||||
import process from 'node:process';
|
||||
|
||||
const site = process.env.SITE_URL || `https://strudel.cc/`; // root url without a path
|
||||
const base = process.env.BASE_PATH || ''; // base path of the strudel site
|
||||
|
||||
// const site = `https://strudel.cc/`; // root url without a path
|
||||
// const base = '/'; // base path of the strudel site
|
||||
const baseNoTrailing = base.endsWith('/') ? base.slice(0, -1) : base;
|
||||
|
||||
// this rehype plugin fixes relative links
|
||||
|
||||
Reference in New Issue
Block a user