diff --git a/.eslintignore b/.eslintignore index 8b9ef749f..cbac6563d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -15,4 +15,6 @@ vite.config.js !**/*.mjs **/*.tsx **/*.ts -**/*.json \ No newline at end of file +**/*.json +**/dev-dist +**/dist \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 1b1066966..d3aafaaa0 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,4 +8,5 @@ packages/mini/krill-parser.js packages/xen/tunejs.js paper pnpm-lock.yaml -pnpm-workspace.yaml \ No newline at end of file +pnpm-workspace.yaml +**/dev-dist \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index c35a73b5c..8581ce3c1 100644 --- a/.prettierrc +++ b/.prettierrc @@ -7,7 +7,7 @@ "jsxSingleQuote": false, "trailingComma": "all", "bracketSpacing": true, - "jsxBracketSameLine": false, + "bracketSameLine": false, "arrowParens": "always", "proseWrap": "preserve", "htmlWhitespaceSensitivity": "css", diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e29f3d2d0..fe1108978 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,6 +82,10 @@ Please report any problems you've had with the setup instructions! ## Code Style To make sure the code changes only where it should, we are using prettier to unify the code style. + +- You can format all files at once by running `pnpm prettier` from the project root +- Run `pnpm format-check` from the project root to check if all files are well formatted + If you use VSCode, you can 1. install [the prettier extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) @@ -89,6 +93,24 @@ If you use VSCode, you can 3. Choose "Configure Default Formatter..." 4. Select prettier +## ESLint + +To prevent unwanted runtime errors, this project uses [eslint](https://eslint.org/). + +- You can check for lint errors by running `pnpm lint` + +There are also eslint extensions / plugins for most editors. + +## Running Tests + +- Run all tests with `pnpm test` +- Run all tests with UI using `pnpm test-ui` + +## Running all CI Checks + +When opening a PR, the CI runner will automatically check the code style and eslint, as well as run all tests. +You can run the same check with `pnpm check` + ## Package Workflow The project is split into multiple [packages](https://github.com/tidalcycles/strudel/tree/main/packages) with independent versioning. diff --git a/my-patterns/README.md b/my-patterns/README.md index b7f416c6e..1cec5e572 100644 --- a/my-patterns/README.md +++ b/my-patterns/README.md @@ -20,11 +20,8 @@ Example: ### 6. edit `website/astro.config.mjs` to use site: `https://.github.io` and base `/strudel`, like this ```js -export default defineConfig({ - /* ... rest of config ... */ - site: 'https://.github.io', - base: '/strudel', -}); +const site = 'https://.github.io'; +const base = '/strudel'; ``` ### 7. commit & push the changes diff --git a/package.json b/package.json index d072b0a48..b06f37a32 100644 --- a/package.json +++ b/package.json @@ -46,14 +46,15 @@ }, "homepage": "https://strudel.tidalcycles.org", "dependencies": { - "dependency-tree": "^9.0.0", - "vitest": "^0.25.7", "@strudel.cycles/core": "workspace:*", "@strudel.cycles/mini": "workspace:*", "@strudel.cycles/tonal": "workspace:*", "@strudel.cycles/transpiler": "workspace:*", "@strudel.cycles/webaudio": "workspace:*", - "@strudel.cycles/xen": "workspace:*" + "@strudel.cycles/xen": "workspace:*", + "acorn": "^8.8.1", + "dependency-tree": "^9.0.0", + "vitest": "^0.25.7" }, "devDependencies": { "@vitest/ui": "^0.25.7", diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index ad521112c..4e230240d 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -11,15 +11,6 @@ const generic_params = [ /** * Select a sound / sample by name. * - *
- * show all sounds - * - * 808 (6) 808bd (25) 808cy (25) 808hc (5) 808ht (5) 808lc (5) 808lt (5) 808mc (5) 808mt (5) 808oh (5) 808sd (25) 909 (1) ab (12) ade (10) ades2 (9) ades3 (7) ades4 (6) alex (2) alphabet (26) amencutup (32) armora (7) arp (2) arpy (11) auto (11) baa (7) baa2 (7) bass (4) bass0 (3) bass1 (30) bass2 (5) bass3 (11) bassdm (24) bassfoo (3) battles (2) bd (24) bend (4) bev (2) bin (2) birds (10) birds3 (19) bleep (13) blip (2) blue (2) bottle (13) breaks125 (2) breaks152 (1) breaks157 (1) breaks165 (1) breath (1) bubble (8) can (14) casio (3) cb (1) cc (6) chin (4) circus (3) clak (2) click (4) clubkick (5) co (4) coins (1) control (2) cosmicg (15) cp (2) cr (6) crow (4) d (4) db (13) diphone (38) diphone2 (12) dist (16) dork2 (4) dorkbot (2) dr (42) dr2 (6) dr55 (4) dr_few (8) drum (6) drumtraks (13) e (8) east (9) electro1 (13) em2 (6) erk (1) f (1) feel (7) feelfx (8) fest (1) fire (1) flick (17) fm (17) foo (27) future (17) gab (10) gabba (4) gabbaloud (4) gabbalouder (4) glasstap (3) glitch (8) glitch2 (8) gretsch (24) gtr (3) h (7) hand (17) hardcore (12) hardkick (6) haw (6) hc (6) hh (13) hh27 (13) hit (6) hmm (1) ho (6) hoover (6) house (8) ht (16) if (5) ifdrums (3) incoming (8) industrial (32) insect (3) invaders (18) jazz (8) jungbass (20) jungle (13) juno (12) jvbass (13) kicklinn (1) koy (2) kurt (7) latibro (8) led (1) less (4) lighter (33) linnhats (6) lt (16) made (7) made2 (1) mash (2) mash2 (4) metal (10) miniyeah (4) monsterb (6) moog (7) mouth (15) mp3 (4) msg (9) mt (16) mute (28) newnotes (15) noise (1) noise2 (8) notes (15) numbers (9) oc (4) odx (15) off (1) outdoor (6) pad (3) padlong (1) pebbles (1) perc (6) peri (15) pluck (17) popkick (10) print (11) proc (2) procshort (8) psr (30) rave (8) rave2 (4) ravemono (2) realclaps (4) reverbkick (1) rm (2) rs (1) sax (22) sd (2) seawolf (3) sequential (8) sf (18) sheffield (1) short (5) sid (12) sine (6) sitar (8) sn (52) space (18) speakspell (12) speech (7) speechless (10) speedupdown (9) stab (23) stomp (10) subroc3d (11) sugar (2) sundance (6) tabla (26) tabla2 (46) tablex (3) tacscan (22) tech (13) techno (7) tink (5) tok (4) toys (13) trump (11) ul (10) ulgab (5) uxay (3) v (6) voodoo (5) wind (10) wobble (1) world (3) xmas (1) yeah (31) - * - * more info - * - *
- * * @name s * @param {string | Pattern} sound The sound / pattern of sounds to pick * @example @@ -28,20 +19,36 @@ const generic_params = [ */ ['s', 's', 'sound'], /** - * The note or sample number to choose for a synth or sampleset - * Note names currently not working yet, but will hopefully soon. Just stick to numbers for now + * Selects the given index from the sample map. + * Numbers too high will wrap around. + * `n` can also be used to play midi numbers, but it is recommended to use `note` instead. * * @name n - * @param {string | number | Pattern} value note name, note number or sample number + * @param {number | Pattern} value sample index starting from 0 * @example - * s('superpiano').n("<0 1 2 3>").osc() - * @example - * s('superpiano').n("").osc() - * @example - * n("0 1 2 3").s('east').osc() + * s("bd sd,hh*3").n("<0 1>") */ // also see https://github.com/tidalcycles/strudel/pull/63 - ['f', 'n', 'The note or sample number to choose for a synth or sampleset'], + ['f', 'n', 'The sample number to choose for a synth or sampleset'], + /** + * Plays the given note name or midi number. A note name consists of + * + * - a letter (a-g or A-G) + * - optional accidentals (b or #) + * - optional octave number (0-9). Defaults to 3 + * + * Examples of valid note names: `c`, `bb`, `Bb`, `f#`, `c3`, `A4`, `Eb2`, `c#5` + * + * You can also use midi numbers instead of note names, where 69 is mapped to A4 440Hz in 12EDO. + * + * @name note + * @example + * note("c a f e") + * @example + * note("c4 a4 f4 e4") + * @example + * note("60 69 65 64") + */ ['f', 'note', 'The note or pitch to play a sound or synth with'], //['s', 'toArg', 'for internal sound routing'], // ["f", "from", "for internal sound routing"), @@ -386,6 +393,7 @@ const generic_params = [ * * @name detune * @param {number | Pattern} amount between 0 and 1 + * @superdirtOnly * @example * n("0 3 7").s('superzow').octave(3).detune("<0 .25 .5 1 2>").osc() * @@ -398,6 +406,7 @@ const generic_params = [ * @param {number | Pattern} dry 0 = wet, 1 = dry * @example * n("[0,3,7](3,8)").s("superpiano").room(.7).dry("<0 .5 .75 1>").osc() + * @superdirtOnly * */ [ @@ -456,6 +465,7 @@ const generic_params = [ * @param {number | Pattern} wet between 0 and 1 * @example * n("0,4,7").s("supersquare").leslie("<0 .4 .6 1>").osc() + * @superdirtOnly * */ ['f', 'leslie', ''], @@ -466,6 +476,7 @@ const generic_params = [ * @param {number | Pattern} rate 6.7 for fast, 0.7 for slow * @example * n("0,4,7").s("supersquare").leslie(1).lrate("<1 2 4 8>").osc() + * @superdirtOnly * */ // TODO: the rate seems to "lag" (in the example, 1 will be fast) @@ -477,6 +488,7 @@ const generic_params = [ * @param {number | Pattern} meters somewhere between 0 and 1 * @example * n("0,4,7").s("supersquare").leslie(1).lrate(2).lsize("<.1 .5 1>").osc() + * @superdirtOnly * */ ['f', 'lsize', ''], @@ -512,6 +524,7 @@ const generic_params = [ * @param {number | Pattern} octave octave number * @example * n("0,4,7").s('supersquare').octave("<3 4 5 6>").osc() + * @superDirtOnly */ ['i', 'octave', ''], ['f', 'offset', ''], // TODO: what is this? not found in tidal doc @@ -676,6 +689,7 @@ const generic_params = [ * @param {number | string | Pattern} unit see description above * @example * speed("1 2 .5 3").s("bd").unit("c").osc() + * @superdirtOnly * */ [ @@ -692,6 +706,7 @@ const generic_params = [ * @param {number | Pattern} squiz Try passing multiples of 2 to it - 2, 4, 8 etc. * @example * squiz("2 4/2 6 [8 16]").s("bd").osc() + * @superdirtOnly * */ ['f', 'squiz', ''], diff --git a/packages/core/cyclist.mjs b/packages/core/cyclist.mjs index 9b522f05c..6e8171ea5 100644 --- a/packages/core/cyclist.mjs +++ b/packages/core/cyclist.mjs @@ -10,44 +10,49 @@ import { logger } from './logger.mjs'; export class Cyclist { constructor({ interval, onTrigger, onToggle, onError, getTime, latency = 0.1 }) { this.started = false; - this.cps = 1; // TODO - this.phase = 0; - this.getTime = getTime; + this.cps = 1; + this.lastTick = 0; // absolute time when last tick (clock callback) happened + this.lastBegin = 0; // query begin of last tick + this.lastEnd = 0; // query end of last tick + this.getTime = getTime; // get absolute time this.onToggle = onToggle; - this.latency = latency; + this.latency = latency; // fixed trigger time offset const round = (x) => Math.round(x * 1000) / 1000; this.clock = createClock( getTime, + // called slightly before each cycle (phase, duration, tick) => { if (tick === 0) { this.origin = phase; } - const begin = round(phase - this.origin); - this.phase = begin - latency; - const end = round(begin + duration); - const time = getTime(); try { - const haps = this.pattern.queryArc(begin, end); // get Haps + const time = getTime(); + const begin = this.lastEnd; + this.lastBegin = begin; + const end = round(begin + duration * this.cps); + this.lastEnd = end; + const haps = this.pattern.queryArc(begin, end); + const tickdeadline = phase - time; // time left till phase begins + this.lastTick = time + tickdeadline; + haps.forEach((hap) => { if (hap.part.begin.equals(hap.whole.begin)) { - const deadline = hap.whole.begin + this.origin - time + latency; - const duration = hap.duration * 1; - onTrigger?.(hap, deadline, duration); + const deadline = (hap.whole.begin - begin) / this.cps + tickdeadline + latency; + const duration = hap.duration / this.cps; + onTrigger?.(hap, deadline, duration, this.cps); } }); } catch (e) { logger(`[cyclist] error: ${e.message}`); onError?.(e); } - }, // called slightly before each cycle + }, interval, // duration of each cycle ); } - getPhase() { - return this.getTime() - this.origin - this.latency; - } now() { - return this.getTime() - this.origin + this.clock.minLatency; + const secondsSinceLastTick = this.getTime() - this.lastTick - this.clock.duration; + return this.lastBegin + secondsSinceLastTick * this.cps; // + this.clock.minLatency; } setStarted(v) { this.started = v; diff --git a/packages/core/euclid.mjs b/packages/core/euclid.mjs index d8560c8e9..29539cf9a 100644 --- a/packages/core/euclid.mjs +++ b/packages/core/euclid.mjs @@ -11,15 +11,9 @@ This program is free software: you can redistribute it and/or modify it under th */ import { Pattern, timeCat, register, silence } from './pattern.mjs'; -import { rotate, flatten } from './util.mjs'; +import { rotate, flatten, splitAt, zipWith } from './util.mjs'; import Fraction from './fraction.mjs'; -const splitAt = function (index, value) { - return [value.slice(0, index), value.slice(index)]; -}; - -const zipWith = (f, xs, ys) => xs.map((n, i) => f(n, ys[i])); - const left = function (n, x) { const [ons, offs] = n; const [xs, ys] = x; diff --git a/packages/core/evaluate.mjs b/packages/core/evaluate.mjs index 3379824ea..1d7be8e40 100644 --- a/packages/core/evaluate.mjs +++ b/packages/core/evaluate.mjs @@ -6,12 +6,7 @@ This program is free software: you can redistribute it and/or modify it under th import { isPattern } from './index.mjs'; -let scoped = false; export const evalScope = async (...args) => { - if (scoped) { - console.warn('evalScope was called more than once.'); - } - scoped = true; const results = await Promise.allSettled(args); const modules = results.filter((result) => result.status === 'fulfilled').map((r) => r.value); results.forEach((result, i) => { @@ -42,9 +37,6 @@ function safeEval(str, options = {}) { } export const evaluate = async (code, transpiler) => { - if (!scoped) { - await evalScope(); // at least scope Pattern.prototype.boostrap - } if (transpiler) { code = transpiler(code); // transform syntactically correct js code to semantically usable code } diff --git a/packages/core/hap.mjs b/packages/core/hap.mjs index 302519594..c9c91c3ba 100644 --- a/packages/core/hap.mjs +++ b/packages/core/hap.mjs @@ -126,6 +126,19 @@ export class Hap { setContext(context) { return new Hap(this.whole, this.part, this.value, context); } + + ensureObjectValue() { + /* if (isNote(hap.value)) { + // supports primitive hap values that look like notes + hap.value = { note: hap.value }; + } */ + if (typeof this.value !== 'object') { + throw new Error( + `expected hap.value to be an object, but got "${this.value}". Hint: append .note() or .s() to the end`, + 'error', + ); + } + } } export default Hap; diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index dd02e5291..5d67026cd 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -27,6 +27,7 @@ export class Pattern { * Create a pattern. As an end user, you will most likely not create a Pattern directly. * * @param {function} query - The function that maps a {@link State} to an array of {@link Hap}. + * @noAutocomplete */ constructor(query) { this.query = query; @@ -51,6 +52,7 @@ export class Pattern { /** * see {@link Pattern#withValue} + * @noAutocomplete */ fmap(func) { return this.withValue(func); @@ -62,6 +64,7 @@ export class Pattern { * pattern of functions. * @param {Function} whole_func * @param {Function} func + * @noAutocomplete * @returns Pattern */ appWhole(whole_func, pat_val) { @@ -97,6 +100,7 @@ export class Pattern { * are not the same but do intersect, the resulting hap has a timespan of the * intersection. This applies to both the part and the whole timespan. * @param {Pattern} pat_val + * @noAutocomplete * @returns Pattern */ appBoth(pat_val) { @@ -117,6 +121,7 @@ export class Pattern { * are preserved from the pattern of functions (often referred to as the left * hand or inner pattern). * @param {Pattern} pat_val + * @noAutocomplete * @returns Pattern */ appLeft(pat_val) { @@ -147,6 +152,7 @@ export class Pattern { * pattern of values, i.e. structure is preserved from the right hand/outer * pattern. * @param {Pattern} pat_val + * @noAutocomplete * @returns Pattern */ appRight(pat_val) { @@ -332,6 +338,7 @@ export class Pattern { * const haps = pattern.queryArc(0, 1) * console.log(haps) * silence + * @noAutocomplete */ queryArc(begin, end) { try { @@ -347,6 +354,7 @@ export class Pattern { * some calculations easier to express, as all haps are then constrained to * happen within a cycle. * @returns Pattern + * @noAutocomplete */ splitQueries() { const pat = this; @@ -361,6 +369,7 @@ export class Pattern { * timespan before passing it to the original pattern. * @param {Function} func the function to apply * @returns Pattern + * @noAutocomplete */ withQuerySpan(func) { return new Pattern((state) => this.query(state.withSpan(func))); @@ -382,6 +391,7 @@ export class Pattern { * begin and end time of the query timespan. * @param {Function} func the function to apply * @returns Pattern + * @noAutocomplete */ withQueryTime(func) { return new Pattern((state) => this.query(state.withSpan((span) => span.withTime(func)))); @@ -393,6 +403,7 @@ export class Pattern { * present, `whole` timespans). * @param {Function} func * @returns Pattern + * @noAutocomplete */ withHapSpan(func) { return new Pattern((state) => this.query(state).map((hap) => hap.withSpan(func))); @@ -403,6 +414,7 @@ export class Pattern { * begin and end time of the hap timespans. * @param {Function} func the function to apply * @returns Pattern + * @noAutocomplete */ withHapTime(func) { return this.withHapSpan((span) => span.withTime(func)); @@ -412,6 +424,7 @@ export class Pattern { * Returns a new pattern with the given function applied to the list of haps returned by every query. * @param {Function} func * @returns Pattern + * @noAutocomplete */ withHaps(func) { return new Pattern((state) => func(this.query(state))); @@ -421,6 +434,7 @@ export class Pattern { * As with {@link Pattern#withHaps}, but applies the function to every hap, rather than every list of haps. * @param {Function} func * @returns Pattern + * @noAutocomplete */ withHap(func) { return this.withHaps((haps) => haps.map(func)); @@ -430,6 +444,7 @@ export class Pattern { * Returns a new pattern with the context field set to every hap set to the given value. * @param {*} context * @returns Pattern + * @noAutocomplete */ setContext(context) { return this.withHap((hap) => hap.setContext(context)); @@ -439,6 +454,7 @@ export class Pattern { * Returns a new pattern with the given function applied to the context field of every hap. * @param {Function} func * @returns Pattern + * @noAutocomplete */ withContext(func) { return this.withHap((hap) => hap.setContext(func(hap.context))); @@ -447,6 +463,7 @@ export class Pattern { /** * Returns a new pattern with the context field of every hap set to an empty object. * @returns Pattern + * @noAutocomplete */ stripContext() { return this.withHap((hap) => hap.setContext({})); @@ -458,6 +475,7 @@ export class Pattern { * @param {Number} start * @param {Number} end * @returns Pattern + * @noAutocomplete */ withLocation(start, end) { const location = { @@ -500,6 +518,7 @@ export class Pattern { * Returns a new Pattern, which only returns haps that meet the given test. * @param {Function} hap_test - a function which returns false for haps to be removed from the pattern * @returns Pattern + * @noAutocomplete */ filterHaps(hap_test) { return new Pattern((state) => this.query(state).filter(hap_test)); @@ -510,6 +529,7 @@ export class Pattern { * inside haps. * @param {Function} value_test * @returns Pattern + * @noAutocomplete */ filterValues(value_test) { return new Pattern((state) => this.query(state).filter((hap) => value_test(hap.value))); @@ -519,6 +539,7 @@ export class Pattern { * Returns a new pattern, with haps containing undefined values removed from * query results. * @returns Pattern + * @noAutocomplete */ removeUndefineds() { return this.filterValues((val) => val != undefined); @@ -529,6 +550,7 @@ export class Pattern { * with an onset is one with a `whole` timespan that begins at the same time * as its `part` timespan. * @returns Pattern + * @noAutocomplete */ onsetsOnly() { // Returns a new pattern that will only return haps where the start @@ -541,6 +563,7 @@ export class Pattern { * Returns a new pattern, with 'continuous' haps (those without 'whole' * timespans) removed from query results. * @returns Pattern + * @noAutocomplete */ discreteOnly() { // removes continuous haps that don't have a 'whole' timespan @@ -550,6 +573,7 @@ export class Pattern { /** * Combines adjacent haps with the same value and whole. Only * intended for use in tests. + * @noAutocomplete */ defragmentHaps() { // remove continuous haps @@ -604,6 +628,7 @@ export class Pattern { * @param {Boolean} with_context - set to true, otherwise the context field * will be stripped from the resulting haps. * @returns [Hap] + * @noAutocomplete */ firstCycle(with_context = false) { var self = this; @@ -615,6 +640,7 @@ export class Pattern { /** * Accessor for a list of values returned by querying the first cycle. + * @noAutocomplete */ get firstCycleValues() { return this.firstCycle().map((hap) => hap.value); @@ -622,6 +648,7 @@ export class Pattern { /** * More human-readable version of the {@link Pattern#firstCycleValues} accessor. + * @noAutocomplete */ get showFirstCycle() { return this.firstCycle().map( @@ -633,6 +660,7 @@ export class Pattern { * Returns a new pattern, which returns haps sorted in temporal order. Mainly * of use when comparing two patterns for equality, in tests. * @returns Pattern + * @noAutocomplete */ sortHapsByPart() { return this.withHaps((haps) => @@ -812,7 +840,7 @@ export class Pattern { } ////////////////////////////////////////////////////////////////////// -// functions relating to chords/patterns of lists +// functions relating to chords/patterns of lists/lists of patterns // returns Array where each list of haps satisfies eq function groupHapsBy(eq, haps) { @@ -861,6 +889,35 @@ Pattern.prototype.arp = function (pat) { return this.arpWith((haps) => pat.fmap((i) => haps[i % haps.length])); }; +/* + * Takes a time duration followed by one or more patterns, and shifts the given patterns in time, so they are + * distributed equally over the given time duration. They are then combined with the pattern 'weave' is called on, after it has been stretched out (i.e. slowed down by) the time duration. + * @name weave + * @memberof Pattern + * @example pan(saw).weave(4, s("bd(3,8)"), s("~ sd")) + * @example n("0 1 2 3 4 5 6 7").weave(8, s("bd(3,8)"), s("~ sd")) + +addToPrototype('weave', function (t, ...pats) { + return this.weaveWith(t, ...pats.map((x) => set.out(x))); +}); + +*/ +/* + * Like 'weave', but accepts functions rather than patterns, which are applied to the pattern. + * @name weaveWith + * @memberof Pattern + +addToPrototype('weaveWith', function (t, ...funcs) { + const pat = this; + const l = funcs.length; + t = Fraction(t); + if (l == 0) { + return silence; + } + return stack(...funcs.map((func, i) => pat.inside(t, func).early(Fraction(i).div(l))))._slow(t); +}); +*/ + ////////////////////////////////////////////////////////////////////// // compose matrix functions @@ -1103,6 +1160,7 @@ export const silence = new Pattern(() => []); * @returns {Pattern} * @example * pure('e4') // "e4" + * @noAutocomplete */ export function pure(value) { function query(state) { @@ -1343,13 +1401,14 @@ export const func = curry((a, b) => reify(b).func(a)); * * @param {string} name name of the function * @param {function} func function with 1 or more params, where last is the current pattern + * @noAutocomplete * */ -export function register(name, func) { +export function register(name, func, patternify = true) { if (Array.isArray(name)) { const result = {}; for (const name_item of name) { - result[name_item] = register(name_item, func); + result[name_item] = register(name_item, func, patternify); } return result; } @@ -1377,7 +1436,6 @@ export function register(name, func) { }; Pattern.prototype[name] = function (...args) { - args = args.map(reify); // For methods that take a single argument (plus 'this'), allow // multiple arguments but sequence them if (arity === 2 && args.length !== 1) { @@ -1385,6 +1443,7 @@ export function register(name, func) { } else if (arity !== args.length + 1) { throw new Error(`.${name}() expects ${arity - 1} inputs but got ${args.length}.`); } + args = args.map(reify); return pfunc(...args, this); }; @@ -1448,15 +1507,17 @@ export const ceil = register('ceil', function (pat) { * Assumes a numerical pattern, containing unipolar values in the range 0 .. * 1. Returns a new pattern with values scaled to the bipolar range -1 .. 1 * @returns Pattern + * @noAutocomplete */ export const toBipolar = register('toBipolar', function (pat) { return pat.fmap((x) => x * 2 - 1); }); /** - * Assumes a numerical pattern, containing bipolar values in the range -1 .. - * 1. Returns a new pattern with values scaled to the unipolar range 0 .. 1 + * Assumes a numerical pattern, containing bipolar values in the range -1 .. 1 + * Returns a new pattern with values scaled to the unipolar range 0 .. 1 * @returns Pattern + * @noAutocomplete */ export const fromBipolar = register('fromBipolar', function (pat) { return pat.fmap((x) => (x + 1) / 2); @@ -2162,6 +2223,59 @@ const _loopAt = function (factor, pat, cps = 1) { .slow(factor); }; +/* + * Chops samples into the given number of slices, triggering those slices with a given pattern of slice numbers. + * @name slice + * @memberof Pattern + * @returns Pattern + * @example + * await samples('github:tidalcycles/Dirt-Samples/master') + * s("breaks165").slice(8, "0 1 <2 2*2> 3 [4 0] 5 6 7".every(3, rev)).slow(1.5) +const slice = register( + 'slice', + function (npat, ipat, opat) { + return npat.innerBind((n) => + ipat.outerBind((i) => + opat.outerBind((o) => { + // If it's not an object, assume it's a string and make it a 's' control parameter + o = o instanceof Object ? o : { s: o }; + // Remember we must stay pure and avoid editing the object directly + const toAdd = { begin: i / n, end: (i + 1) / n, _slices: n }; + return pure({ ...toAdd, ...o }); + }), + ), + ); + }, + false, // turns off auto-patternification +); +*/ + +/* + * Works the same as slice, but changes the playback speed of each slice to match the duration of its step. + * @name splice + * @memberof Pattern + * @returns Pattern + * @example + * await samples('github:tidalcycles/Dirt-Samples/master') + * s("breaks165").splice(8, "0 1 [2 3 0]@2 3 0@2 7").hurry(0.65) +const splice = register( + 'splice', + function (npat, ipat, opat) { + const sliced = slice(npat, ipat, opat); + return sliced.withHap(function (hap) { + return hap.withValue((v) => ({ + ...{ + speed: (1 / v._slices / hap.whole.duration) * (v.speed || 1), + unit: 'c', + }, + ...v, + })); + }); + }, + false, // turns off auto-patternification + ); + */ + const { loopAt, loopat } = register(['loopAt', 'loopat'], function (factor, pat) { return _loopAt(factor, pat, 1); }); diff --git a/packages/core/repl.mjs b/packages/core/repl.mjs index 045f21021..b5d8cb92e 100644 --- a/packages/core/repl.mjs +++ b/packages/core/repl.mjs @@ -2,6 +2,7 @@ import { Cyclist } from './cyclist.mjs'; import { evaluate as _evaluate } from './evaluate.mjs'; import { logger } from './logger.mjs'; import { setTime } from './time.mjs'; +import { evalScope } from './evaluate.mjs'; export function repl({ interval, @@ -17,13 +18,12 @@ export function repl({ }) { const scheduler = new Cyclist({ interval, - onTrigger: async (hap, deadline, duration) => { + onTrigger: async (hap, deadline, duration, cps) => { try { if (!hap.context.onTrigger || !hap.context.dominantTrigger) { await defaultOutput(hap, deadline, duration); } if (hap.context.onTrigger) { - const cps = 1; // call signature of output / onTrigger is different... await hap.context.onTrigger(getTime() + deadline, hap, getTime(), cps); } @@ -42,6 +42,17 @@ export function repl({ } try { beforeEval?.({ code }); + scheduler.setCps(1); // reset cps in case the code does not contain a setCps call + // problem: when the code does contain a setCps after an awaited promise, + // the cps will be 1 until the promise resolves + // example: + /* + await new Promise(resolve => setTimeout(resolve,1000)) + setCps(.5) + note("c a f e") + */ + // to make sure the setCps inside the code is called immediately, + // it has to be placed first let { pattern } = await _evaluate(code, transpiler); logger(`[eval] code updated`); @@ -58,5 +69,10 @@ export function repl({ const stop = () => scheduler.stop(); const start = () => scheduler.start(); const pause = () => scheduler.pause(); - return { scheduler, evaluate, start, stop, pause }; + const setCps = (cps) => scheduler.setCps(cps); + evalScope({ + setCps, + setcps: setCps, + }); + return { scheduler, evaluate, start, stop, pause, setCps }; } diff --git a/packages/core/test/pattern.test.mjs b/packages/core/test/pattern.test.mjs index 08638d181..43838c53b 100644 --- a/packages/core/test/pattern.test.mjs +++ b/packages/core/test/pattern.test.mjs @@ -959,4 +959,47 @@ describe('Pattern', () => { sameFirst(s('a', 'b').hurry(2), s('a', 'b').fast(2).speed(2)); }); }); + /*describe('composable functions', () => { + it('Can compose functions', () => { + sameFirst(sequence(3, 4).fast(2).rev().fast(2), fast(2).rev().fast(2)(sequence(3, 4))); + }); + it('Can compose by method chaining operators with controls', () => { + sameFirst(s('bd').apply(set.n(3).fast(2)), s('bd').set.n(3).fast(2)); + }); + it('Can compose by method chaining operators and alignments with controls', () => { + sameFirst(s('bd').apply(set.in.n(3).fast(2)), s('bd').set.n(3).fast(2)); + // sameFirst(s('bd').apply(set.squeeze.n(3).fast(2)), s('bd').set.squeeze.n(3).fast(2)); + }); + }); + describe('weave', () => { + it('Can distribute patterns along a pattern', () => { + sameFirst(n(0, 1).weave(2, s('bd', silence), s(silence, 'sd')), sequence(s('bd').n(0), s('sd').n(1))); + }); + }); + describe('slice', () => { + it('Can slice a sample', () => { + sameFirst( + s('break').slice(4, sequence(0, 1, 2, 3)), + sequence( + { begin: 0, end: 0.25, s: 'break', _slices: 4 }, + { begin: 0.25, end: 0.5, s: 'break', _slices: 4 }, + { begin: 0.5, end: 0.75, s: 'break', _slices: 4 }, + { begin: 0.75, end: 1, s: 'break', _slices: 4 }, + ), + ); + }); + }); + describe('splice', () => { + it('Can splice a sample', () => { + sameFirst( + s('break').splice(4, sequence(0, 1, 2, 3)), + sequence( + { begin: 0, end: 0.25, s: 'break', _slices: 4, unit: 'c', speed: 1 }, + { begin: 0.25, end: 0.5, s: 'break', _slices: 4, unit: 'c', speed: 1 }, + { begin: 0.5, end: 0.75, s: 'break', _slices: 4, unit: 'c', speed: 1 }, + { begin: 0.75, end: 1, s: 'break', _slices: 4, unit: 'c', speed: 1 }, + ), + ); + }); + });*/ }); diff --git a/packages/core/util.mjs b/packages/core/util.mjs index 19ff7c126..27256d688 100644 --- a/packages/core/util.mjs +++ b/packages/core/util.mjs @@ -58,6 +58,7 @@ export const valueToMidi = (value, fallbackValue) => { /** * @deprecated does not appear to be referenced or invoked anywhere in the codebase + * @noAutocomplete */ export const getFreq = (noteOrMidi) => { if (typeof noteOrMidi === 'number') { @@ -68,6 +69,7 @@ export const getFreq = (noteOrMidi) => { /** * @deprecated does not appear to be referenced or invoked anywhere in the codebase + * @noAutocomplete */ export const midi2note = (n) => { const oct = Math.floor(n / 12) - 1; @@ -204,3 +206,9 @@ export function parseFractional(numOrString) { } export const fractionalArgs = (fn) => mapArgs(fn, parseFractional); + +export const splitAt = function (index, value) { + return [value.slice(0, index), value.slice(index)]; +}; + +export const zipWith = (f, xs, ys) => xs.map((n, i) => f(n, ys[i])); diff --git a/packages/core/zyklus.mjs b/packages/core/zyklus.mjs index e66d8e2e9..3d25b0544 100644 --- a/packages/core/zyklus.mjs +++ b/packages/core/zyklus.mjs @@ -44,6 +44,6 @@ function createClock( }; const getPhase = () => phase; // setCallback - return { setDuration, start, stop, pause, duration, getPhase, minLatency }; + return { setDuration, start, stop, pause, duration, interval, getPhase, minLatency }; } export default createClock; diff --git a/packages/csound/index.mjs b/packages/csound/index.mjs index 3aabc22b8..31ffa83a5 100644 --- a/packages/csound/index.mjs +++ b/packages/csound/index.mjs @@ -28,9 +28,7 @@ export const csound = register('csound', (instrument, pat) => { logger('[csound] not loaded yet', 'warning'); return; } - if (typeof hap.value !== 'object') { - throw new Error('csound only support objects as hap values'); - } + hap.ensureObjectValue(); let { gain = 0.8 } = hap.value; gain *= 0.2; diff --git a/packages/midi/midi.mjs b/packages/midi/midi.mjs index de04f3555..789938d3f 100644 --- a/packages/midi/midi.mjs +++ b/packages/midi/midi.mjs @@ -5,8 +5,9 @@ This program is free software: you can redistribute it and/or modify it under th */ import * as _WebMidi from 'webmidi'; -import { Pattern, isPattern, isNote, getPlayableNoteValue, logger } from '@strudel.cycles/core'; +import { Pattern, isPattern, logger } from '@strudel.cycles/core'; import { getAudioContext } from '@strudel.cycles/webaudio'; +import { toMidi } from '@strudel.cycles/core'; // if you use WebMidi from outside of this package, make sure to import that instance: export const { WebMidi } = _WebMidi; @@ -63,7 +64,7 @@ function getDevice(output, outputs) { } // Pattern.prototype.midi = function (output: string | number, channel = 1) { -Pattern.prototype.midi = function (output, channel = 1) { +Pattern.prototype.midi = function (output) { if (!supportsMidi()) { throw new Error(`🎹 WebMidi is not enabled. Supported Browsers: https://caniuse.com/?search=webmidi`); } @@ -90,11 +91,6 @@ Pattern.prototype.midi = function (output, channel = 1) { ); } return this.onTrigger((time, hap) => { - let note = getPlayableNoteValue(hap); - const velocity = hap.context?.velocity ?? 0.9; - if (!isNote(note)) { - throw new Error('not a note: ' + note); - } if (!midiReady) { return; } @@ -106,15 +102,34 @@ Pattern.prototype.midi = function (output, channel = 1) { .join(' | ')}`, ); } - // console.log('midi', value, output); + hap.ensureObjectValue(); + + // calculate time const timingOffset = WebMidi.time - getAudioContext().currentTime * 1000; time = time * 1000 + timingOffset; - // const inMs = '+' + (time - Tone.getContext().currentTime) * 1000; - // await enableWebMidi() - device.playNote(note, channel, { - time, - duration: hap.duration.valueOf() * 1000 - 5, - attack: velocity, - }); + + // destructure value + const { note, nrpnn, nrpv, ccn, ccv, midichan = 1 } = hap.value; + const velocity = hap.context?.velocity ?? 0.9; // TODO: refactor velocity + const duration = hap.duration.valueOf() * 1000 - 5; + + if (note) { + const midiNumber = toMidi(note); + device.playNote(midiNumber, midichan, { + time, + duration, + attack: velocity, + }); + } + if (ccv && ccn) { + if (typeof ccv !== 'number' || ccv < 0 || ccv > 1) { + throw new Error('expected ccv to be a number between 0 and 1'); + } + if (!['string', 'number'].includes(typeof ccn)) { + throw new Error('expected ccn to be a number or a string'); + } + const scaled = Math.round(ccv * 127); + device.sendControlChange(ccn, scaled, midichan, { time }); + } }); }; diff --git a/packages/osc/osc.mjs b/packages/osc/osc.mjs index 15909203e..83e03dad8 100644 --- a/packages/osc/osc.mjs +++ b/packages/osc/osc.mjs @@ -39,14 +39,16 @@ let startedAt = -1; /** * * Sends each hap as an OSC message, which can be picked up by SuperCollider or any other OSC-enabled software. + * For more info, read [MIDI & OSC in the docs](https://strudel.tidalcycles.org/learn/input-output) * * @name osc * @memberof Pattern * @returns Pattern */ -Pattern.prototype.osc = async function () { - const osc = await connect(); - return this.onTrigger((time, hap, currentTime, cps = 1) => { +Pattern.prototype.osc = function () { + return this.onTrigger(async (time, hap, currentTime, cps = 1) => { + hap.ensureObjectValue(); + const osc = await connect(); const cycle = hap.wholeOrPart().begin.valueOf(); const delta = hap.duration.valueOf(); // time should be audio time of onset diff --git a/packages/react/README.md b/packages/react/README.md index cd2f50f0e..f65f48b02 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -13,24 +13,43 @@ npm i @strudel.cycles/react Here is a minimal example of how to set up a MiniRepl: ```jsx -import { evalScope, controls } from '@strudel.cycles/core'; +import * as React from 'react'; +import '@strudel.cycles/react/dist/style.css'; import { MiniRepl } from '@strudel.cycles/react'; -import { prebake } from '../repl/src/prebake.mjs'; +import { evalScope, controls } from '@strudel.cycles/core'; +import { samples, initAudioOnFirstClick } from '@strudel.cycles/webaudio'; -evalScope( - controls, - import('@strudel.cycles/core'), - import('@strudel.cycles/tonal'), - import('@strudel.cycles/mini'), - import('@strudel.cycles/webaudio'), - /* probably import other strudel packages */ -); +async function prebake() { + await samples( + 'https://strudel.tidalcycles.org/tidal-drum-machines.json', + 'github:ritchse/tidal-drum-machines/main/machines/' + ); + await samples( + 'https://strudel.tidalcycles.org/EmuSP12.json', + 'https://strudel.tidalcycles.org/EmuSP12/' + ); +} -prebake(); +async function init() { + await evalScope( + controls, + import('@strudel.cycles/core'), + import('@strudel.cycles/mini'), + import('@strudel.cycles/webaudio'), + import('@strudel.cycles/tonal') + ); + await prebake(); + initAudioOnFirstClick(); +} -export function Repl({ tune }) { - return ; +if (typeof window !== 'undefined') { + init(); +} + +export default function App() { + return ; } ``` -For a more sophisticated example, check out the [nano-repl](./examples/nano-repl/)! +- Open [example on stackblitz](https://stackblitz.com/edit/react-ts-saaair?file=tune.tsx,App.tsx) +- Also check out the [nano-repl](./examples/nano-repl/) for a more sophisticated example diff --git a/packages/react/package.json b/packages/react/package.json index 886da0096..400c8ceff 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@strudel.cycles/react", - "version": "0.6.0", + "version": "0.6.4", "description": "React components for strudel", "main": "src/index.js", "publishConfig": { @@ -32,10 +32,13 @@ }, "homepage": "https://github.com/tidalcycles/strudel#readme", "dependencies": { + "@codemirror/autocomplete": "^6.4.0", "@codemirror/lang-javascript": "^6.1.1", "@codemirror/state": "^6.2.0", "@codemirror/view": "^6.7.3", "@lezer/highlight": "^1.1.3", + "@replit/codemirror-emacs": "^6.0.0", + "@replit/codemirror-vim": "^6.0.6", "@strudel.cycles/core": "workspace:*", "@strudel.cycles/transpiler": "workspace:*", "@strudel.cycles/webaudio": "workspace:*", diff --git a/packages/react/src/components/Autocomplete.jsx b/packages/react/src/components/Autocomplete.jsx new file mode 100644 index 000000000..7ec81d2d1 --- /dev/null +++ b/packages/react/src/components/Autocomplete.jsx @@ -0,0 +1,77 @@ +import { createRoot } from 'react-dom/client'; +import jsdoc from '../../../../doc.json'; + +const getDocLabel = (doc) => doc.name || doc.longname; +const getInnerText = (html) => { + var div = document.createElement('div'); + div.innerHTML = html; + return div.textContent || div.innerText || ''; +}; + +export function Autocomplete({ doc }) { + return ( +
+

{getDocLabel(doc)}

+
+
    + {doc.params?.map(({ name, type, description }, i) => ( +
  • + {name} : {type.names?.join(' | ')} {description ? <> - {getInnerText(description)} : ''} +
  • + ))} +
+
+ {doc.examples?.map((example, i) => ( +
+
 {
+                console.log('ola!');
+                navigator.clipboard.writeText(example);
+                e.stopPropagation();
+              }}
+            >
+              {example}
+            
+
+ ))} +
+
+ ); +} + +const jsdocCompletions = jsdoc.docs + .filter( + (doc) => + getDocLabel(doc) && + !getDocLabel(doc).startsWith('_') && + !['package'].includes(doc.kind) && + !['superdirtOnly', 'noAutocomplete'].some((tag) => doc.tags?.find((t) => t.originalTitle === tag)), + ) + // https://codemirror.net/docs/ref/#autocomplete.Completion + .map((doc) /*: Completion */ => ({ + label: getDocLabel(doc), + // detail: 'xxx', // An optional short piece of information to show (with a different style) after the label. + info: () => { + const node = document.createElement('div'); + // if Autocomplete is non-interactive, it could also be rendered at build time.. + // .. using renderToStaticMarkup + createRoot(node).render(); + return node; + }, + type: 'function', // https://codemirror.net/docs/ref/#autocomplete.Completion.type + })); + +export const strudelAutocomplete = (context /* : CompletionContext */) => { + let word = context.matchBefore(/\w*/); + if (word.from == word.to && !context.explicit) return null; + return { + from: word.from, + options: jsdocCompletions, + /* options: [ + { label: 'match', type: 'keyword' }, + { label: 'hello', type: 'variable', info: '(World)' }, + { label: 'magic', type: 'text', apply: '⠁⭒*.✩.*⭒⠁', detail: 'macro' }, + ], */ + }; +}; diff --git a/packages/react/src/components/CodeMirror6.jsx b/packages/react/src/components/CodeMirror6.jsx index 8b05a7278..f33436c65 100644 --- a/packages/react/src/components/CodeMirror6.jsx +++ b/packages/react/src/components/CodeMirror6.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import _CodeMirror from '@uiw/react-codemirror'; import { EditorView, Decoration } from '@codemirror/view'; import { StateField, StateEffect } from '@codemirror/state'; @@ -6,6 +6,10 @@ import { javascript } from '@codemirror/lang-javascript'; import strudelTheme from '../themes/strudel-theme'; import './style.css'; import { useCallback } from 'react'; +import { autocompletion } from '@codemirror/autocomplete'; +//import { strudelAutocomplete } from './Autocomplete'; +import { vim } from '@replit/codemirror-vim'; +import { emacs } from '@replit/codemirror-emacs'; export const setFlash = StateEffect.define(); const flashField = StateField.define({ @@ -49,19 +53,20 @@ const highlightField = StateField.define({ try { for (let e of tr.effects) { if (e.is(setHighlights)) { + const { haps } = e.value; const marks = - e.value + haps .map((hap) => (hap.context.locations || []).map(({ start, end }) => { - const color = hap.context.color || '#FFCA28'; + // const color = hap.context.color || e.value.color || '#FFCA28'; let from = tr.newDoc.line(start.line).from + start.column; let to = tr.newDoc.line(end.line).from + end.column; const l = tr.newDoc.length; if (from > l || to > l) { return; // dont mark outside of range, as it will throw an error } - // const mark = Decoration.mark({ attributes: { style: `outline: 1px solid ${color}` } }); - const mark = Decoration.mark({ attributes: { style: `outline: 1.5px solid ${color};` } }); + //const mark = Decoration.mark({ attributes: { style: `outline: 2px solid ${color};` } }); + const mark = Decoration.mark({ attributes: { class: `outline outline-2 outline-foreground` } }); return mark.range(from, to); }), ) @@ -79,9 +84,27 @@ const highlightField = StateField.define({ provide: (f) => EditorView.decorations.from(f), }); -const extensions = [javascript(), strudelTheme, highlightField, flashField]; +const staticExtensions = [ + javascript(), + highlightField, + flashField, + // javascriptLanguage.data.of({ autocomplete: strudelAutocomplete }), + // autocompletion({ override: [strudelAutocomplete] }), + autocompletion({ override: [] }), // wait for https://github.com/uiwjs/react-codemirror/pull/458 +]; -export default function CodeMirror({ value, onChange, onViewChanged, onSelectionChange, options, editorDidMount }) { +export default function CodeMirror({ + value, + onChange, + onViewChanged, + onSelectionChange, + theme, + keybindings, + fontSize = 18, + fontFamily = 'monospace', + options, + editorDidMount, +}) { const handleOnChange = useCallback( (value) => { onChange?.(value); @@ -102,16 +125,27 @@ export default function CodeMirror({ value, onChange, onViewChanged, onSelection }, [onSelectionChange], ); + const extensions = useMemo(() => { + let bindings = { + vim, + emacs, + }; + if (bindings[keybindings]) { + return [...staticExtensions, bindings[keybindings]()]; + } + return staticExtensions; + }, [keybindings]); return ( - <> +
<_CodeMirror value={value} + theme={theme || strudelTheme} onChange={handleOnChange} onCreateEditor={handleOnCreateEditor} onUpdate={handleOnUpdate} extensions={extensions} /> - +
); } diff --git a/packages/react/src/components/MiniRepl.jsx b/packages/react/src/components/MiniRepl.jsx index fd803ac13..1be987272 100644 --- a/packages/react/src/components/MiniRepl.jsx +++ b/packages/react/src/components/MiniRepl.jsx @@ -7,13 +7,22 @@ import useHighlighting from '../hooks/useHighlighting.mjs'; import useStrudel from '../hooks/useStrudel.mjs'; import CodeMirror6, { flash } from './CodeMirror6'; import { Icon } from './Icon'; -import styles from './MiniRepl.module.css'; import './style.css'; import { logger } from '@strudel.cycles/core'; +import useEvent from '../hooks/useEvent.mjs'; +import useKeydown from '../hooks/useKeydown.mjs'; const getTime = () => getAudioContext().currentTime; -export function MiniRepl({ tune, hideOutsideView = false, enableKeyboard, drawTime, punchcard, canvasHeight = 200 }) { +export function MiniRepl({ + tune, + hideOutsideView = false, + enableKeyboard, + drawTime, + punchcard, + canvasHeight = 200, + theme, +}) { drawTime = drawTime || (punchcard ? [0, 4] : undefined); const evalOnMount = !!drawTime; const drawContext = useCallback( @@ -63,6 +72,27 @@ export function MiniRepl({ tune, hideOutsideView = false, enableKeyboard, drawTi getTime: () => scheduler.now(), }); + // keyboard shortcuts + useKeydown( + useCallback( + async (e) => { + if (view?.hasFocus) { + if (e.ctrlKey || e.altKey) { + if (e.code === 'Enter') { + e.preventDefault(); + flash(view); + await activateCode(); + } else if (e.code === 'Period') { + stop(); + e.preventDefault(); + } + } + } + }, + [activateCode, stop, view], + ), + ); + // set active pattern on ctrl+enter useLayoutEffect(() => { if (enableKeyboard) { @@ -98,20 +128,32 @@ export function MiniRepl({ tune, hideOutsideView = false, enableKeyboard, drawTi ); return ( -
-
-
- -
- {error &&
{error.message}
} + {error &&
{error.message}
}
-
- {show && } +
+ {show && }
{drawTime && ( { - document.addEventListener(name, onTrigger, useCapture); - return () => { - document.removeEventListener(name, onTrigger, useCapture); - }; - }, [onTrigger]); -} diff --git a/packages/react/src/components/MiniRepl.module.css b/packages/react/src/components/MiniRepl.module.css deleted file mode 100644 index cbbb5a3b0..000000000 --- a/packages/react/src/components/MiniRepl.module.css +++ /dev/null @@ -1,27 +0,0 @@ -.container { - @apply rounded-md overflow-hidden bg-[#222222]; -} - -.header { - @apply flex justify-between bg-slate-700 border-t border-slate-500; -} - -.buttons { - @apply flex; -} - -.button { - @apply cursor-pointer w-16 flex items-center justify-center p-1 bg-slate-700 border-r border-slate-500 text-white hover:bg-slate-600; -} - -.buttonDisabled { - @apply w-16 flex items-center justify-center p-1 bg-slate-600 text-slate-400 cursor-not-allowed; -} - -.error { - @apply text-right p-1 text-sm text-red-200; -} - -.body { - @apply overflow-auto relative; -} diff --git a/packages/react/src/components/style.css b/packages/react/src/components/style.css index d3aed9d77..150c98379 100644 --- a/packages/react/src/components/style.css +++ b/packages/react/src/components/style.css @@ -1,14 +1,26 @@ +:root { + --background: #222; + --lineBackground: #22222250; + --foreground: #fff; + --caret: #ffcc00; + --selection: rgba(128, 203, 196, 0.5); + --selectionMatch: #036dd626; + --lineHighlight: #00000050; + --gutterBackground: transparent; + --gutterForeground: #8a919966; +} + .cm-editor { background-color: transparent !important; height: 100%; z-index: 11; - font-size: 18px; +} + +.cm-theme { + width: 100%; + height: 100%; } .cm-theme-light { width: 100%; } - -.cm-line > * { - background: #00000095; -} diff --git a/packages/react/src/hooks/useEvent.mjs b/packages/react/src/hooks/useEvent.mjs new file mode 100644 index 000000000..f349c6e70 --- /dev/null +++ b/packages/react/src/hooks/useEvent.mjs @@ -0,0 +1,12 @@ +import { useEffect } from 'react'; + +function useEvent(name, onTrigger, useCapture = false) { + useEffect(() => { + document.addEventListener(name, onTrigger, useCapture); + return () => { + document.removeEventListener(name, onTrigger, useCapture); + }; + }, [onTrigger]); +} + +export default useEvent; diff --git a/packages/react/src/hooks/useHighlighting.mjs b/packages/react/src/hooks/useHighlighting.mjs index 1b7a2cede..4ce2a9363 100644 --- a/packages/react/src/hooks/useHighlighting.mjs +++ b/packages/react/src/hooks/useHighlighting.mjs @@ -1,5 +1,6 @@ import { useEffect, useRef } from 'react'; import { setHighlights } from '../components/CodeMirror6'; +const round = (x) => Math.round(x * 1000) / 1000; function useHighlighting({ view, pattern, active, getTime }) { const highlights = useRef([]); @@ -14,14 +15,14 @@ function useHighlighting({ view, pattern, active, getTime }) { // force min framerate of 10 fps => fixes crash on tab refocus, where lastEnd could be far away // see https://github.com/tidalcycles/strudel/issues/108 const begin = Math.max(lastEnd.current ?? audioTime, audioTime - 1 / 10, -0.01); // negative time seems buggy - const span = [begin, audioTime + 1 / 60]; + const span = [round(begin), round(audioTime + 1 / 60)]; lastEnd.current = span[1]; highlights.current = highlights.current.filter((hap) => hap.whole.end > audioTime); // keep only highlights that are still active const haps = pattern.queryArc(...span).filter((hap) => hap.hasOnset()); highlights.current = highlights.current.concat(haps); // add potential new onsets - view.dispatch({ effects: setHighlights.of(highlights.current) }); // highlight all still active + new active haps + view.dispatch({ effects: setHighlights.of({ haps: highlights.current }) }); // highlight all still active + new active haps } catch (err) { - view.dispatch({ effects: setHighlights.of([]) }); + view.dispatch({ effects: setHighlights.of({ haps: [] }) }); } frame = requestAnimationFrame(updateHighlights); }); @@ -30,7 +31,7 @@ function useHighlighting({ view, pattern, active, getTime }) { }; } else { highlights.current = []; - view.dispatch({ effects: setHighlights.of([]) }); + view.dispatch({ effects: setHighlights.of({ haps: [] }) }); } } }, [pattern, active, view]); diff --git a/packages/react/src/hooks/useStrudel.mjs b/packages/react/src/hooks/useStrudel.mjs index 527aa708f..0900ebbfe 100644 --- a/packages/react/src/hooks/useStrudel.mjs +++ b/packages/react/src/hooks/useStrudel.mjs @@ -10,7 +10,6 @@ function useStrudel({ getTime, evalOnMount = false, initialCode = '', - autolink = false, beforeEval, afterEval, editPattern, @@ -33,7 +32,7 @@ function useStrudel({ const shouldPaint = useCallback((pat) => !!(pat?.context?.onPaint && drawContext), [drawContext]); // TODO: make sure this hook reruns when scheduler.started changes - const { scheduler, evaluate, start, stop, pause } = useMemo( + const { scheduler, evaluate, start, stop, pause, setCps } = useMemo( () => repl({ interval, @@ -51,15 +50,13 @@ function useStrudel({ setCode(code); beforeEval?.(); }, - afterEval: ({ pattern: _pattern, code }) => { + afterEval: (res) => { + const { pattern: _pattern, code } = res; setActiveCode(code); setPattern(_pattern); setEvalError(); setSchedulerError(); - if (autolink) { - window.location.hash = '#' + encodeURIComponent(btoa(code)); - } - afterEval?.(); + afterEval?.(res); }, onToggle: (v) => { setStarted(v); @@ -156,6 +153,7 @@ function useStrudel({ stop, pause, togglePlay, + setCps, }; } diff --git a/packages/react/src/index.js b/packages/react/src/index.js index e8a4c4478..f9eca1cda 100644 --- a/packages/react/src/index.js +++ b/packages/react/src/index.js @@ -1,9 +1,11 @@ // import 'tailwindcss/tailwind.css'; -export { default as CodeMirror, flash } from './components/CodeMirror6'; -export * from './components/MiniRepl'; -export { default as useHighlighting } from './hooks/useHighlighting'; +export { default as CodeMirror, flash } from './components/CodeMirror6'; // !SSR +export * from './components/MiniRepl'; // !SSR +export { default as useHighlighting } from './hooks/useHighlighting'; // !SSR +export { default as useStrudel } from './hooks/useStrudel'; // !SSR export { default as usePostMessage } from './hooks/usePostMessage'; -export { default as useStrudel } from './hooks/useStrudel'; export { default as useKeydown } from './hooks/useKeydown'; +export { default as useEvent } from './hooks/useEvent'; +export { default as strudelTheme } from './themes/strudel-theme'; export { default as cx } from './cx'; diff --git a/packages/react/src/themes/algoboy.js b/packages/react/src/themes/algoboy.js new file mode 100644 index 000000000..b4db09dec --- /dev/null +++ b/packages/react/src/themes/algoboy.js @@ -0,0 +1,39 @@ +import { tags as t } from '@lezer/highlight'; +import { createTheme } from '@uiw/codemirror-themes'; +export const settings = { + background: '#9bbc0f', + foreground: '#0f380f', // whats that? + caret: '#0f380f', + selection: '#306230', + selectionMatch: '#ffffff26', + lineHighlight: '#8bac0f', + lineBackground: '#9bbc0f50', + //lineBackground: 'transparent', + gutterBackground: 'transparent', + gutterForeground: '#0f380f', + light: true, +}; +export default createTheme({ + theme: 'light', + settings, + styles: [ + { tag: t.keyword, color: '#0f380f' }, + { tag: t.operator, color: '#0f380f' }, + { tag: t.special(t.variableName), color: '#0f380f' }, + { tag: t.typeName, color: '#0f380f' }, + { tag: t.atom, color: '#0f380f' }, + { tag: t.number, color: '#0f380f' }, + { tag: t.definition(t.variableName), color: '#0f380f' }, + { tag: t.string, color: '#0f380f' }, + { tag: t.special(t.string), color: '#0f380f' }, + { tag: t.comment, color: '#0f380f' }, + { tag: t.variableName, color: '#0f380f' }, + { tag: t.tagName, color: '#0f380f' }, + { tag: t.bracket, color: '#0f380f' }, + { tag: t.meta, color: '#0f380f' }, + { tag: t.attributeName, color: '#0f380f' }, + { tag: t.propertyName, color: '#0f380f' }, + { tag: t.className, color: '#0f380f' }, + { tag: t.invalid, color: '#0f380f' }, + ], +}); diff --git a/packages/react/src/themes/blackscreen.js b/packages/react/src/themes/blackscreen.js new file mode 100644 index 000000000..ac9627c37 --- /dev/null +++ b/packages/react/src/themes/blackscreen.js @@ -0,0 +1,37 @@ +import { tags as t } from '@lezer/highlight'; +import { createTheme } from '@uiw/codemirror-themes'; +export const settings = { + background: 'black', + foreground: 'white', // whats that? + caret: 'white', + selection: '#ffffff20', + selectionMatch: '#036dd626', + lineHighlight: '#ffffff10', + lineBackground: '#00000050', + gutterBackground: 'transparent', + gutterForeground: '#8a919966', +}; +export default createTheme({ + theme: 'dark', + settings, + styles: [ + { tag: t.keyword, color: 'white' }, + { tag: t.operator, color: 'white' }, + { tag: t.special(t.variableName), color: 'white' }, + { tag: t.typeName, color: 'white' }, + { tag: t.atom, color: 'white' }, + { tag: t.number, color: 'white' }, + { tag: t.definition(t.variableName), color: 'white' }, + { tag: t.string, color: 'white' }, + { tag: t.special(t.string), color: 'white' }, + { tag: t.comment, color: 'white' }, + { tag: t.variableName, color: 'white' }, + { tag: t.tagName, color: 'white' }, + { tag: t.bracket, color: 'white' }, + { tag: t.meta, color: 'white' }, + { tag: t.attributeName, color: 'white' }, + { tag: t.propertyName, color: 'white' }, + { tag: t.className, color: 'white' }, + { tag: t.invalid, color: 'white' }, + ], +}); diff --git a/packages/react/src/themes/bluescreen.js b/packages/react/src/themes/bluescreen.js new file mode 100644 index 000000000..4f72d8c52 --- /dev/null +++ b/packages/react/src/themes/bluescreen.js @@ -0,0 +1,40 @@ +import { tags as t } from '@lezer/highlight'; +import { createTheme } from '@uiw/codemirror-themes'; +export const settings = { + background: '#051DB5', + lineBackground: '#051DB550', + foreground: 'white', // whats that? + caret: 'white', + selection: 'rgba(128, 203, 196, 0.5)', + selectionMatch: '#036dd626', + // lineHighlight: '#8a91991a', // original + lineHighlight: '#00000050', + gutterBackground: 'transparent', + // gutterForeground: '#8a919966', + gutterForeground: '#8a919966', +}; + +export default createTheme({ + theme: 'dark', + settings, + styles: [ + { tag: t.keyword, color: 'white' }, + { tag: t.operator, color: 'white' }, + { tag: t.special(t.variableName), color: 'white' }, + { tag: t.typeName, color: 'white' }, + { tag: t.atom, color: 'white' }, + { tag: t.number, color: 'white' }, + { tag: t.definition(t.variableName), color: 'white' }, + { tag: t.string, color: 'white' }, + { tag: t.special(t.string), color: 'white' }, + { tag: t.comment, color: 'white' }, + { tag: t.variableName, color: 'white' }, + { tag: t.tagName, color: 'white' }, + { tag: t.bracket, color: 'white' }, + { tag: t.meta, color: 'white' }, + { tag: t.attributeName, color: 'white' }, + { tag: t.propertyName, color: 'white' }, + { tag: t.className, color: 'white' }, + { tag: t.invalid, color: 'white' }, + ], +}); diff --git a/packages/react/src/themes/terminal.js b/packages/react/src/themes/terminal.js new file mode 100644 index 000000000..1374bb867 --- /dev/null +++ b/packages/react/src/themes/terminal.js @@ -0,0 +1,36 @@ +import { tags as t } from '@lezer/highlight'; +import { createTheme } from '@uiw/codemirror-themes'; +export const settings = { + background: 'black', + foreground: '#41FF00', // whats that? + caret: '#41FF00', + selection: '#ffffff20', + selectionMatch: '#036dd626', + lineHighlight: '#ffffff10', + gutterBackground: 'transparent', + gutterForeground: '#8a919966', +}; +export default createTheme({ + theme: 'dark', + settings, + styles: [ + { tag: t.keyword, color: '#41FF00' }, + { tag: t.operator, color: '#41FF00' }, + { tag: t.special(t.variableName), color: '#41FF00' }, + { tag: t.typeName, color: '#41FF00' }, + { tag: t.atom, color: '#41FF00' }, + { tag: t.number, color: '#41FF00' }, + { tag: t.definition(t.variableName), color: '#41FF00' }, + { tag: t.string, color: '#41FF00' }, + { tag: t.special(t.string), color: '#41FF00' }, + { tag: t.comment, color: '#41FF00' }, + { tag: t.variableName, color: '#41FF00' }, + { tag: t.tagName, color: '#41FF00' }, + { tag: t.bracket, color: '#41FF00' }, + { tag: t.meta, color: '#41FF00' }, + { tag: t.attributeName, color: '#41FF00' }, + { tag: t.propertyName, color: '#41FF00' }, + { tag: t.className, color: '#41FF00' }, + { tag: t.invalid, color: '#41FF00' }, + ], +}); diff --git a/packages/react/src/themes/whitescreen.js b/packages/react/src/themes/whitescreen.js new file mode 100644 index 000000000..22abad9e9 --- /dev/null +++ b/packages/react/src/themes/whitescreen.js @@ -0,0 +1,38 @@ +import { tags as t } from '@lezer/highlight'; +import { createTheme } from '@uiw/codemirror-themes'; +export const settings = { + background: 'white', + foreground: 'black', // whats that? + caret: 'black', + selection: 'rgba(128, 203, 196, 0.5)', + selectionMatch: '#ffffff26', + lineHighlight: '#cccccc50', + lineBackground: '#ffffff50', + gutterBackground: 'transparent', + gutterForeground: 'black', + light: true, +}; +export default createTheme({ + theme: 'light', + settings, + styles: [ + { tag: t.keyword, color: 'black' }, + { tag: t.operator, color: 'black' }, + { tag: t.special(t.variableName), color: 'black' }, + { tag: t.typeName, color: 'black' }, + { tag: t.atom, color: 'black' }, + { tag: t.number, color: 'black' }, + { tag: t.definition(t.variableName), color: 'black' }, + { tag: t.string, color: 'black' }, + { tag: t.special(t.string), color: 'black' }, + { tag: t.comment, color: 'black' }, + { tag: t.variableName, color: 'black' }, + { tag: t.tagName, color: 'black' }, + { tag: t.bracket, color: 'black' }, + { tag: t.meta, color: 'black' }, + { tag: t.attributeName, color: 'black' }, + { tag: t.propertyName, color: 'black' }, + { tag: t.className, color: 'black' }, + { tag: t.invalid, color: 'black' }, + ], +}); diff --git a/packages/react/tailwind.config.js b/packages/react/tailwind.config.js index f6cae19be..c5a940fc8 100644 --- a/packages/react/tailwind.config.js +++ b/packages/react/tailwind.config.js @@ -1,7 +1,21 @@ module.exports = { content: ['./src/**/*.{js,jsx,ts,tsx}'], theme: { - extend: {}, + extend: { + colors: { + // codemirror-theme settings + background: 'var(--background)', + lineBackground: 'var(--lineBackground)', + foreground: 'var(--foreground)', + caret: 'var(--caret)', + selection: 'var(--selection)', + selectionMatch: 'var(--selectionMatch)', + gutterBackground: 'var(--gutterBackground)', + gutterForeground: 'var(--gutterForeground)', + gutterBorder: 'var(--gutterBorder)', + lineHighlight: 'var(--lineHighlight)', + }, + }, }, plugins: [], corePlugins: { diff --git a/packages/tonal/tonal.mjs b/packages/tonal/tonal.mjs index 9e47d4a2f..206ea8409 100644 --- a/packages/tonal/tonal.mjs +++ b/packages/tonal/tonal.mjs @@ -123,17 +123,18 @@ export const scaleTranspose = register('scaleTranspose', function (offset /* : n /** * Turns numbers into notes in the scale (zero indexed). Also sets scale for other scale operations, like {@link Pattern#scaleTranspose}. * - * The scale name has the form "TO? N" wher - * - * - T = Tonic - * - O = Octave (optional, defaults to 3) - * - N = Name of scale, available names can be found [here](https://github.com/tonaljs/tonal/blob/main/packages/scale-type/data.ts). + * A scale consists of a root note (e.g. `c4`, `c`, `f#`, `bb4`) followed by a [scale type](https://github.com/tonaljs/tonal/blob/main/packages/scale-type/data.ts). + * The root note defaults to octave 3, if no octave number is given. + * Note that you currently cannot pattern `scale` with the mini notation, because the scale name includes a space. + * This will be improved in the future. Until then, use a sequence function like `cat` or `seq`. * * @memberof Pattern * @name scale * @param {string} scale Name of scale * @returns Pattern * @example + * "0 2 4 6 4 2".scale('C2 major').note() + * @example * "0 2 4 6 4 2" * .scale(seq('C2 major', 'C2 minor').slow(2)) * .note() diff --git a/packages/webaudio/sampler.mjs b/packages/webaudio/sampler.mjs index f94b6b5a8..40a693766 100644 --- a/packages/webaudio/sampler.mjs +++ b/packages/webaudio/sampler.mjs @@ -111,7 +111,9 @@ let sampleCache = { current: undefined }; /** * Loads a collection of samples to use with `s` - * + * @example + * samples('github:tidalcycles/Dirt-Samples/master'); + * s("[bd ~]*2, [~ hh]*2, ~ sd") * @example * samples({ * bd: '808bd/BD0000.WAV', diff --git a/packages/webaudio/webaudio.mjs b/packages/webaudio/webaudio.mjs index 968cb9961..526c49125 100644 --- a/packages/webaudio/webaudio.mjs +++ b/packages/webaudio/webaudio.mjs @@ -193,21 +193,9 @@ function effectSend(input, effect, wet) { // export const webaudioOutput = async (t, hap, ct, cps) => { export const webaudioOutput = async (hap, deadline, hapDuration) => { const ac = getAudioContext(); - /* if (isNote(hap.value)) { - // supports primitive hap values that look like notes - hap.value = { note: hap.value }; - } */ - if (typeof hap.value !== 'object') { - logger( - `hap.value "${hap.value}" is not supported by webaudio output. Hint: append .note() or .s() to the end`, - 'error', - ); - /* throw new Error( - `hap.value "${hap.value}"" is not supported by webaudio output. Hint: append .note() or .s() to the end`, - ); */ - return; - } - // calculate correct time (tone.js workaround) + hap.ensureObjectValue(); + + // calculate absolute time let t = ac.currentTime + deadline; // destructure value let { diff --git a/packages/webdirt/webdirt.mjs b/packages/webdirt/webdirt.mjs index 500d73739..6ae2ff9f3 100644 --- a/packages/webdirt/webdirt.mjs +++ b/packages/webdirt/webdirt.mjs @@ -59,6 +59,7 @@ export function loadWebDirt(config) { * @returns Pattern * @example * s("bd*2 hh sd hh").n("<0 1>").webdirt() + * @noAutocomplete */ Pattern.prototype.webdirt = function () { // create a WebDirt object and initialize Web Audio context diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 477cb7231..9694f77f5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,7 @@ importers: '@strudel.cycles/webaudio': workspace:* '@strudel.cycles/xen': workspace:* '@vitest/ui': ^0.25.7 + acorn: ^8.8.1 c8: ^7.12.0 canvas: ^2.11.0 dependency-tree: ^9.0.0 @@ -32,6 +33,7 @@ importers: '@strudel.cycles/transpiler': link:packages/transpiler '@strudel.cycles/webaudio': link:packages/webaudio '@strudel.cycles/xen': link:packages/xen + acorn: 8.8.2 dependency-tree: 9.0.0 vitest: 0.25.8_@vitest+ui@0.25.8 devDependencies: @@ -159,10 +161,13 @@ importers: packages/react: specifiers: + '@codemirror/autocomplete': ^6.4.0 '@codemirror/lang-javascript': ^6.1.1 '@codemirror/state': ^6.2.0 '@codemirror/view': ^6.7.3 '@lezer/highlight': ^1.1.3 + '@replit/codemirror-emacs': ^6.0.0 + '@replit/codemirror-vim': ^6.0.6 '@strudel.cycles/core': workspace:* '@strudel.cycles/transpiler': workspace:* '@strudel.cycles/webaudio': workspace:* @@ -179,15 +184,18 @@ importers: tailwindcss: ^3.0.24 vite: ^3.2.2 dependencies: + '@codemirror/autocomplete': 6.4.0_a4vbhepr4qhxm5cldqd4jpyase '@codemirror/lang-javascript': 6.1.2 '@codemirror/state': 6.2.0 '@codemirror/view': 6.7.3 '@lezer/highlight': 1.1.3 + '@replit/codemirror-emacs': 6.0.0_cgfc5aojxuwjajwhkrgidrzxoa + '@replit/codemirror-vim': 6.0.6_a4vbhepr4qhxm5cldqd4jpyase '@strudel.cycles/core': link:../core '@strudel.cycles/transpiler': link:../transpiler '@strudel.cycles/webaudio': link:../webaudio '@uiw/codemirror-themes': 4.19.7_a4vbhepr4qhxm5cldqd4jpyase - '@uiw/react-codemirror': 4.19.7_b6o5qp6ml4k7skggixohr5abde + '@uiw/react-codemirror': 4.19.7_r3x7zzmc35ug7i3c2vv4bf5iey react-hook-inview: 4.5.0_sfoxds7t5ydpegc3knd667wn6m devDependencies: '@types/react': 17.0.53 @@ -356,6 +364,8 @@ importers: '@docsearch/react': ^3.1.0 '@headlessui/react': ^1.7.7 '@heroicons/react': ^2.0.13 + '@nanostores/persistent': ^0.7.0 + '@nanostores/react': ^0.4.1 '@strudel.cycles/core': workspace:* '@strudel.cycles/csound': workspace:* '@strudel.cycles/midi': workspace:* @@ -369,21 +379,25 @@ importers: '@strudel.cycles/webaudio': workspace:* '@strudel.cycles/xen': workspace:* '@supabase/supabase-js': ^1.35.3 + '@tailwindcss/forms': ^0.5.3 '@tailwindcss/typography': ^0.5.8 '@types/node': ^18.0.0 '@types/react': ^18.0.26 '@types/react-dom': ^18.0.9 + '@uiw/codemirror-themes-all': ^4.19.8 '@vite-pwa/astro': ^0.0.1 astro: ^1.7.2 canvas: ^2.11.0 fraction.js: ^4.2.0 html-escaper: ^3.0.3 nanoid: ^4.0.0 + nanostores: ^0.7.4 preact: ^10.7.3 react: ^18.2.0 react-dom: ^18.2.0 rehype-autolink-headings: ^6.1.1 rehype-slug: ^5.0.1 + rehype-urls: ^1.1.1 remark-toc: ^8.0.1 tailwindcss: ^3.2.4 vite-plugin-pwa: ^0.14.1 @@ -398,6 +412,8 @@ importers: '@docsearch/react': 3.3.2_y6lbs4o5th67cuzjdmtw5eqh7a '@headlessui/react': 1.7.8_biqbaboplfbrettd7655fr4n2y '@heroicons/react': 2.0.14_react@18.2.0 + '@nanostores/persistent': 0.7.0_nanostores@0.7.4 + '@nanostores/react': 0.4.1_nkfnbc2tpc77iht7asm3uqwau4 '@strudel.cycles/core': link:../packages/core '@strudel.cycles/csound': link:../packages/csound '@strudel.cycles/midi': link:../packages/midi @@ -411,19 +427,23 @@ importers: '@strudel.cycles/webaudio': link:../packages/webaudio '@strudel.cycles/xen': link:../packages/xen '@supabase/supabase-js': 1.35.7 + '@tailwindcss/forms': 0.5.3_tailwindcss@3.2.4 '@tailwindcss/typography': 0.5.9_tailwindcss@3.2.4 '@types/node': 18.11.18 '@types/react': 18.0.27 '@types/react-dom': 18.0.10 + '@uiw/codemirror-themes-all': 4.19.8 astro: 1.9.2_@types+node@18.11.18 canvas: 2.11.0 fraction.js: 4.2.0 nanoid: 4.0.0 + nanostores: 0.7.4 preact: 10.11.3 react: 18.2.0 react-dom: 18.2.0_react@18.2.0 rehype-autolink-headings: 6.1.1 rehype-slug: 5.1.0 + rehype-urls: 1.1.1 remark-toc: 8.0.1 tailwindcss: 3.2.4 devDependencies: @@ -3158,6 +3178,27 @@ packages: - supports-color dev: false + /@nanostores/persistent/0.7.0_nanostores@0.7.4: + resolution: {integrity: sha512-4PAInL/T1hbftZUJ0cmgdFHBMalUoq7BUXFBy7QfyMv/8X3LPTYNh/yxspL7+J+XM3UNvVI7IFRMMs6FBasjhQ==} + engines: {node: ^14.0.0 || ^16.0.0 || >=18.0.0} + peerDependencies: + nanostores: ^0.7.0 + dependencies: + nanostores: 0.7.4 + dev: false + + /@nanostores/react/0.4.1_nkfnbc2tpc77iht7asm3uqwau4: + resolution: {integrity: sha512-lsv0CYrMxczbXtoV/mxFVEoL/uVjEjseoP89srO/5yNAOkJka+dSFS7LYyWEbuvCPO7EgbtkvRpO5V+OztKQOw==} + engines: {node: ^14.0.0 || ^16.0.0 || >=18.0.0} + peerDependencies: + nanostores: ^0.7.0 + react: '>=18.0.0' + dependencies: + nanostores: 0.7.4 + react: 18.2.0 + use-sync-external-store: 1.2.0_react@18.2.0 + dev: false + /@nodelib/fs.scandir/2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -3394,6 +3435,33 @@ packages: tsm: 2.3.0 dev: false + /@replit/codemirror-emacs/6.0.0_cgfc5aojxuwjajwhkrgidrzxoa: + resolution: {integrity: sha512-zxSDg3UKm7811hjqNtgvK9G0IBtCWf82Idb9nZQo0ldmGl4d9SV7oCSuXQ58NmOG4AV7coD7kgFSZhEqHhyQhA==} + peerDependencies: + '@codemirror/autocomplete': ^6.0.2 + '@codemirror/commands': ^6.0.0 + '@codemirror/search': ^6.0.0 + '@codemirror/state': ^6.0.1 + '@codemirror/view': ^6.0.2 + dependencies: + '@codemirror/autocomplete': 6.4.0_a4vbhepr4qhxm5cldqd4jpyase + '@codemirror/state': 6.2.0 + '@codemirror/view': 6.7.3 + dev: false + + /@replit/codemirror-vim/6.0.6_a4vbhepr4qhxm5cldqd4jpyase: + resolution: {integrity: sha512-/Lc+5AmV+T5pTm5P+rWpL+gseNHNye7xaUWpULczHai5ZLVg/ZE3+MBwK3Ai+/SmZKR/mK2YuXgNKnTGToEGYg==} + peerDependencies: + '@codemirror/commands': ^6.0.0 + '@codemirror/language': ^6.1.0 + '@codemirror/search': ^6.2.0 + '@codemirror/state': ^6.0.1 + '@codemirror/view': ^6.0.3 + dependencies: + '@codemirror/state': 6.2.0 + '@codemirror/view': 6.7.3 + dev: false + /@rollup/plugin-babel/5.3.1_3dsfpkpoyvuuxyfgdbpn4j4uzm: resolution: {integrity: sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q==} engines: {node: '>= 10.0.0'} @@ -3554,6 +3622,15 @@ packages: string.prototype.matchall: 4.0.8 dev: true + /@tailwindcss/forms/0.5.3_tailwindcss@3.2.4: + resolution: {integrity: sha512-y5mb86JUoiUgBjY/o6FJSFZSEttfb3Q5gllE4xoKjAAD+vBrnIhE4dViwUuow3va8mpH4s9jyUbUbrRGoRdc2Q==} + peerDependencies: + tailwindcss: '>=3.0.0 || >= 3.0.0-alpha.1' + dependencies: + mini-svg-data-uri: 1.4.4 + tailwindcss: 3.2.4 + dev: false + /@tailwindcss/typography/0.5.9_tailwindcss@3.2.4: resolution: {integrity: sha512-t8Sg3DyynFysV9f4JDOVISGsjazNb48AeIYQwcL+Bsq5uf4RYL75C1giZ43KISjeDGBaTN3Kxh7Xj/vRSMJUUg==} peerDependencies: @@ -3979,9 +4056,10 @@ packages: eslint-visitor-keys: 3.3.0 dev: false - /@uiw/codemirror-extensions-basic-setup/4.19.7_a4vbhepr4qhxm5cldqd4jpyase: + /@uiw/codemirror-extensions-basic-setup/4.19.7_cgfc5aojxuwjajwhkrgidrzxoa: resolution: {integrity: sha512-pk0JTFJAZOGxouBB1pdBtb59qKibO9DW4hER4VSFGBGW3TBDeXUwL/gKujhRpySHG2MtG09cgt4a3XOFIWwXTw==} peerDependencies: + '@codemirror/autocomplete': '>=6.0.0' '@codemirror/state': '>=6.0.0' '@codemirror/view': '>=6.0.0' dependencies: @@ -3994,6 +4072,173 @@ packages: '@codemirror/view': 6.7.3 dev: false + /@uiw/codemirror-theme-abcdef/4.19.8: + resolution: {integrity: sha512-sR7srfMJRGTsAFQYEs+8IogUxUHDsMqNqZ4waIA6rNIvOH9Q1NYFEqTpqf4AeivkNeXm3N1LI+1nQAKhWzWpOA==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-androidstudio/4.19.8: + resolution: {integrity: sha512-xhvEPZ1NvihIJVx7MA1Z8A8NwaTbM6mtBsfwM3mKAmzW6K6JcIJftcKe5z5wSPZk4J3S66vq8RYEMOBygSOdEQ==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-atomone/4.19.8: + resolution: {integrity: sha512-enZR8RPiKohyuEU4DOWA7A/xLs/+NsuvZAuGmg5PU43CQITzK1Wqri43/WxkGGsEIztejX439s1QuYxUwCCeUg==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-aura/4.19.8: + resolution: {integrity: sha512-DLoi2XEPNBD6Cxsp3v/nYw7jJ7sDEXET9+C43KZnk1dQ9H5e0HSpZhOkw1xmaCGzoXn9q7HInPa7GgUEMv8NPA==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-bbedit/4.19.8: + resolution: {integrity: sha512-1vaVaVhMP2IB7H77W9yvPRhVr+8HGBWPDfFEVWAc7tfeU0xC2MFby05gO/7T6K2JWyj2lXnVw/i+oFNeDdcekQ==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-bespin/4.19.8: + resolution: {integrity: sha512-JyzmgCloEWhduH5GVYzHQ3vPc3zC0YVRiu7lOjgdOVRhr49M6KmwTytmbmqXbaqmSZKFUJqiHjz8VswqcNC4dw==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-darcula/4.19.8: + resolution: {integrity: sha512-fPKyzMqCtBfez2ubC/77AP0BfE+XOio+sy8oRYfX3HqRQEivnnEddQJnTZVz0kKSLYSryQHbOMw/qwgInPvBCA==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-dracula/4.19.8: + resolution: {integrity: sha512-YHQJUDnYKrew/YkEPQG3SQFcnKr6MzVbIXxmdKuxlCTrySNFNMK19dKrzY3fwc+Lgpp5r26QLLocTZyCvu1xeA==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-duotone/4.19.8: + resolution: {integrity: sha512-SJkjyKxU2Nazv6uEctvRdz62/ZQ8rBP4xtXrjF/zcjOdWmx2ecUAGn/j5Euw5V55Dr74yIQFs0L+GB5UTHCHDA==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-eclipse/4.19.8: + resolution: {integrity: sha512-6XXzYFC809e5MWT/NNTqoZ0N9H6P8mXwIEGDfigh33VU1TJPPpO1LCWdf59VcXx/xIY0ctDp7rU7hTy3f3tHkw==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-github/4.19.8: + resolution: {integrity: sha512-RUAzHGkG2G2PXTxsH4KbKVCKqPs/+H6xvhCT3Q4YiPj1W2aGSfPwZZ8cLLCm9dYaIh/+H6L+AcoiUtvADjyKsQ==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-gruvbox-dark/4.19.8: + resolution: {integrity: sha512-EQepnqhfcu7HY2uutigzflZ9OFzDcF9eq4xF53UylD+WZBdwq2qarZMQgBfOXZZKYI3XcTny064fa7Xxklhs1g==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-material/4.19.8: + resolution: {integrity: sha512-dm7FtZkJSZ4AV+9vXxKUDnXLTHaqWnsmn9HOb6AmLiHmHcLFLDgeosSBnA80fwXBhd6QswJI0cEnKHAvcC/vFg==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-noctis-lilac/4.19.8: + resolution: {integrity: sha512-vPH8KOiRgcBK1V7/BN04n8K03cfR4CEmOGZUMKpcLlSZwWRe0+JPk6S2qtjbJ072Fsn1ZrcLRYrqtaAJQNOVnw==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-nord/4.19.8: + resolution: {integrity: sha512-qBqKJI9fa35rFefXqaiw3FCXWSpD+65+Weji3g/AgB0m0+MHG+3rkC+rLZ4PE2QpkcMz6wHj89EMwOW9W1i3cA==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-okaidia/4.19.8: + resolution: {integrity: sha512-gxEThgbbfIxKjk7UzD0D8gw5bVpgxDct3e6r9/WegZw7tTvTHMnz9wutGbJp2cYSwdgLHoQJZzZBi6jKhExZSg==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-solarized/4.19.8: + resolution: {integrity: sha512-xHp2i6zWBMw2+kZX0GUYi7pCL3ZL1qWSO8OaleHCkpY3jn+lfLSJOAYYkajvNyu3tPsiKQuAgpCQ6AYFWOr6BQ==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-sublime/4.19.8: + resolution: {integrity: sha512-tapkCty8lwpRw2CAY5bPiK8S2ptdTL4d1X/IkCVyHqbC0B8728iQJu3E4Rrka7yggFx4QGUpyZB9UTIFYURtsw==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-tokyo-night-day/4.19.8: + resolution: {integrity: sha512-HDKp2KDjluubpe+7M31SohWUFCW7wGQIvoD60xr86OkPZDdqsCVUFmna6rqfttV6S2OsgVNJPBzZvOF398Eapg==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-tokyo-night-storm/4.19.8: + resolution: {integrity: sha512-Kp8HIf1H+pgbRx/ZhRsqqN5qfyx3SVVfjnUPGltsdBymqh8QGdr7LC8Tp0P5+Yjb6CqF6Dgx7RnQDj1XZ94rbA==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-tokyo-night/4.19.8: + resolution: {integrity: sha512-LrfB+EgZqBNlMF6Zqk8RrlsfVzKe6Ple7ckvREV6kSuwxncF5FlhzVL3cWgxNfNQ7TJ5ySVSvw4fWOcxIcc1LQ==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-vscode/4.19.8: + resolution: {integrity: sha512-UdUuJfNjG2y88taP5gsEA9AQlhRTURnl+9kl+LOJkQtXavrqp3J8gUAHRhEWxN7k8q8YimsSVcQ4yw0FKAgXQQ==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-theme-xcode/4.19.8: + resolution: {integrity: sha512-VYCRhStYujUNGIkiaZZ1o5OO2Z2edsKkYCCYSy0rwb4G17vT6sd4YDnmJQuF0gzqQkTIdDxSb6aCM9ISkPABlg==} + dependencies: + '@uiw/codemirror-themes': 4.19.8 + dev: false + + /@uiw/codemirror-themes-all/4.19.8: + resolution: {integrity: sha512-0kAWabe46Vkz+gwNfaXvn/0adeUSCTAuZC0d7Nu8ebcr1TjT1fDLFNZIXlwidn40suiXq8FDfZ9euArx3RPg0Q==} + dependencies: + '@uiw/codemirror-theme-abcdef': 4.19.8 + '@uiw/codemirror-theme-androidstudio': 4.19.8 + '@uiw/codemirror-theme-atomone': 4.19.8 + '@uiw/codemirror-theme-aura': 4.19.8 + '@uiw/codemirror-theme-bbedit': 4.19.8 + '@uiw/codemirror-theme-bespin': 4.19.8 + '@uiw/codemirror-theme-darcula': 4.19.8 + '@uiw/codemirror-theme-dracula': 4.19.8 + '@uiw/codemirror-theme-duotone': 4.19.8 + '@uiw/codemirror-theme-eclipse': 4.19.8 + '@uiw/codemirror-theme-github': 4.19.8 + '@uiw/codemirror-theme-gruvbox-dark': 4.19.8 + '@uiw/codemirror-theme-material': 4.19.8 + '@uiw/codemirror-theme-noctis-lilac': 4.19.8 + '@uiw/codemirror-theme-nord': 4.19.8 + '@uiw/codemirror-theme-okaidia': 4.19.8 + '@uiw/codemirror-theme-solarized': 4.19.8 + '@uiw/codemirror-theme-sublime': 4.19.8 + '@uiw/codemirror-theme-tokyo-night': 4.19.8 + '@uiw/codemirror-theme-tokyo-night-day': 4.19.8 + '@uiw/codemirror-theme-tokyo-night-storm': 4.19.8 + '@uiw/codemirror-theme-vscode': 4.19.8 + '@uiw/codemirror-theme-xcode': 4.19.8 + '@uiw/codemirror-themes': 4.19.8 + dev: false + /@uiw/codemirror-themes/4.19.7_a4vbhepr4qhxm5cldqd4jpyase: resolution: {integrity: sha512-M/42RkPI60ItlssmNuEoZO2MQvlY6fRmdX7XRUAhKjxczZoaq8xS6HIvv1whGf2zGsTrwdVTPCm6ls0l17dvPA==} peerDependencies: @@ -4005,7 +4250,15 @@ packages: '@codemirror/view': 6.7.3 dev: false - /@uiw/react-codemirror/4.19.7_b6o5qp6ml4k7skggixohr5abde: + /@uiw/codemirror-themes/4.19.8: + resolution: {integrity: sha512-k+0molX6YuQZ7vYymS5DEl3NcHxVE4VP4J0nB7RBnzLrhDwT2K8R5ie7J2eH+4bpppIK1ZZdZ6Mie7U48dH5dQ==} + dependencies: + '@codemirror/language': 6.4.0 + '@codemirror/state': 6.2.0 + '@codemirror/view': 6.7.3 + dev: false + + /@uiw/react-codemirror/4.19.7_r3x7zzmc35ug7i3c2vv4bf5iey: resolution: {integrity: sha512-IHvpYWVSdiaHX0Fk6oY6YyAJigDnyvSpWKNUTRzsMNxB+8/wqZ8lior4TprXH0zyLxW5F1+bTyifFFTeg+X3Sw==} peerDependencies: '@codemirror/state': '>=6.0.0' @@ -4018,10 +4271,12 @@ packages: '@codemirror/state': 6.2.0 '@codemirror/theme-one-dark': 6.1.0 '@codemirror/view': 6.7.3 - '@uiw/codemirror-extensions-basic-setup': 4.19.7_a4vbhepr4qhxm5cldqd4jpyase + '@uiw/codemirror-extensions-basic-setup': 4.19.7_cgfc5aojxuwjajwhkrgidrzxoa codemirror: 6.0.1 react: 17.0.2 react-dom: 17.0.2_react@17.0.2 + transitivePeerDependencies: + - '@codemirror/autocomplete' dev: false /@vite-pwa/astro/0.0.1: @@ -7250,6 +7505,10 @@ packages: web-namespaces: 2.0.1 dev: false + /hast-util-has-property/1.0.4: + resolution: {integrity: sha512-ghHup2voGfgFoHMGnaLHOjbYFACKrRh9KFttdCzMCbFoBMJXiNi2+XTrPP8+q6cDJM/RSqlCfVWrjp1H201rZg==} + dev: false + /hast-util-has-property/2.0.1: resolution: {integrity: sha512-X2+RwZIMTMKpXUzlotatPzWj8bspCymtXH3cfG3iQKV+wPF53Vgaqxi/eLqGck0wKq1kS9nvoB1wchbCPEL8sg==} dev: false @@ -7593,6 +7852,10 @@ packages: resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} dev: true + /is-arrayish/0.3.2: + resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==} + dev: false + /is-bigint/1.0.4: resolution: {integrity: sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==} dependencies: @@ -9179,6 +9442,11 @@ packages: engines: {node: '>=4'} dev: true + /mini-svg-data-uri/1.4.4: + resolution: {integrity: sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==} + hasBin: true + dev: false + /minimatch/3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: @@ -9407,6 +9675,11 @@ packages: hasBin: true dev: false + /nanostores/0.7.4: + resolution: {integrity: sha512-MBeUVt7NBcXqh7AGT+KSr3O0X/995CZsvcP2QEMP+PXFwb07qv3Vjyq+EX0yS8f12Vv3Tn2g/BvK/OZoMhJlOQ==} + engines: {node: ^14.0.0 || ^16.0.0 || >=18.0.0} + dev: false + /napi-build-utils/1.0.2: resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==} dev: true @@ -10880,6 +11153,14 @@ packages: unified: 10.1.2 dev: false + /rehype-urls/1.1.1: + resolution: {integrity: sha512-ct9Kb/nAL6oe/O5fDc0xjiqm8Z9xgXdorOdDhZAWx7awucyiuYXU7Dax+23Gu24nnGwtdaCW6zslKAYzlEW1lw==} + dependencies: + hast-util-has-property: 1.0.4 + stdopt: 2.2.0 + unist-util-visit: 1.4.1 + dev: false + /rehype/12.0.1: resolution: {integrity: sha512-ey6kAqwLM3X6QnMDILJthGvG1m1ULROS9NT4uG9IDCuv08SFyLlreSuvOa//DgEvbXx62DS6elGVqusWhRUbgw==} dependencies: @@ -11609,6 +11890,12 @@ packages: tslib: 2.5.0 dev: false + /stdopt/2.2.0: + resolution: {integrity: sha512-D/p41NgXOkcj1SeGhfXOwv9z1K6EV3sjAUY5aeepVbgEHv7DpKWLTjhjScyzMWAQCAgUQys1mjH0eArm4cjRGw==} + dependencies: + is-arrayish: 0.3.2 + dev: false + /stream-connect/1.0.2: resolution: {integrity: sha512-68Kl+79cE0RGKemKkhxTSg8+6AGrqBt+cbZAXevg2iJ6Y3zX4JhA/sZeGzLpxW9cXhmqAcE7KnJCisUmIUfnFQ==} engines: {node: '>=0.10.0'} @@ -12475,6 +12762,10 @@ packages: resolution: {integrity: sha512-qF72kLmPxAw0oN2fwpWIqbXAVyEqUzDHMsbtPvOudIlUzXYFIeQIuxXQCRCFh22B7cixvU0MG7m3MW8FTq/S+A==} dev: false + /unist-util-is/3.0.0: + resolution: {integrity: sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==} + dev: false + /unist-util-is/5.2.0: resolution: {integrity: sha512-Glt17jWwZeyqrFqOK0pF1Ded5U3yzJnFr8CG1GMjCWTp9zDo2p+cmD6pWbZU8AgM5WU3IzRv6+rBwhzsGh6hBQ==} dev: false @@ -12523,6 +12814,12 @@ packages: '@types/unist': 2.0.6 dev: false + /unist-util-visit-parents/2.1.2: + resolution: {integrity: sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==} + dependencies: + unist-util-is: 3.0.0 + dev: false + /unist-util-visit-parents/5.1.3: resolution: {integrity: sha512-x6+y8g7wWMyQhL1iZfhIPhDAs7Xwbn9nRosDXl7qoPTSCy0yNxnKc+hWokFifWQIDGi154rdUqKvbCa4+1kLhg==} dependencies: @@ -12530,6 +12827,12 @@ packages: unist-util-is: 5.2.0 dev: false + /unist-util-visit/1.4.1: + resolution: {integrity: sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==} + dependencies: + unist-util-visit-parents: 2.1.2 + dev: false + /unist-util-visit/4.1.2: resolution: {integrity: sha512-MSd8OUGISqHdVvfY9TPhyK2VdUrPgxkUtWSuMHF6XAAFuL4LokseigBnZtPnJMu+FbynTkFNnFlyjxpVKujMRg==} dependencies: @@ -12582,6 +12885,14 @@ packages: punycode: 2.3.0 dev: true + /use-sync-external-store/1.2.0_react@18.2.0: + resolution: {integrity: sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + dependencies: + react: 18.2.0 + dev: false + /utf-8-validate/5.0.10: resolution: {integrity: sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==} engines: {node: '>=6.14.2'} diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index e52a59323..95ae2b412 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -2506,40 +2506,26 @@ exports[`runs examples > example "mul" example index 0 1`] = ` exports[`runs examples > example "n" example index 0 1`] = ` [ - "[ 0/1 → 1/1 | s:superpiano n:0 ]", - "[ 1/1 → 2/1 | s:superpiano n:1 ]", - "[ 2/1 → 3/1 | s:superpiano n:2 ]", - "[ 3/1 → 4/1 | s:superpiano n:3 ]", -] -`; - -exports[`runs examples > example "n" example index 1 1`] = ` -[ - "[ 0/1 → 1/1 | s:superpiano n:c4 ]", - "[ 1/1 → 2/1 | s:superpiano n:d4 ]", - "[ 2/1 → 3/1 | s:superpiano n:e4 ]", - "[ 3/1 → 4/1 | s:superpiano n:g4 ]", -] -`; - -exports[`runs examples > example "n" example index 2 1`] = ` -[ - "[ 0/1 → 1/4 | n:0 s:east ]", - "[ 1/4 → 1/2 | n:1 s:east ]", - "[ 1/2 → 3/4 | n:2 s:east ]", - "[ 3/4 → 1/1 | n:3 s:east ]", - "[ 1/1 → 5/4 | n:0 s:east ]", - "[ 5/4 → 3/2 | n:1 s:east ]", - "[ 3/2 → 7/4 | n:2 s:east ]", - "[ 7/4 → 2/1 | n:3 s:east ]", - "[ 2/1 → 9/4 | n:0 s:east ]", - "[ 9/4 → 5/2 | n:1 s:east ]", - "[ 5/2 → 11/4 | n:2 s:east ]", - "[ 11/4 → 3/1 | n:3 s:east ]", - "[ 3/1 → 13/4 | n:0 s:east ]", - "[ 13/4 → 7/2 | n:1 s:east ]", - "[ 7/2 → 15/4 | n:2 s:east ]", - "[ 15/4 → 4/1 | n:3 s:east ]", + "[ 0/1 → 1/2 | s:bd n:0 ]", + "[ 1/2 → 1/1 | s:sd n:0 ]", + "[ 0/1 → 1/3 | s:hh n:0 ]", + "[ 1/3 → 2/3 | s:hh n:0 ]", + "[ 2/3 → 1/1 | s:hh n:0 ]", + "[ 1/1 → 3/2 | s:bd n:1 ]", + "[ 3/2 → 2/1 | s:sd n:1 ]", + "[ 1/1 → 4/3 | s:hh n:1 ]", + "[ 4/3 → 5/3 | s:hh n:1 ]", + "[ 5/3 → 2/1 | s:hh n:1 ]", + "[ 2/1 → 5/2 | s:bd n:0 ]", + "[ 5/2 → 3/1 | s:sd n:0 ]", + "[ 2/1 → 7/3 | s:hh n:0 ]", + "[ 7/3 → 8/3 | s:hh n:0 ]", + "[ 8/3 → 3/1 | s:hh n:0 ]", + "[ 3/1 → 7/2 | s:bd n:1 ]", + "[ 7/2 → 4/1 | s:sd n:1 ]", + "[ 3/1 → 10/3 | s:hh n:1 ]", + "[ 10/3 → 11/3 | s:hh n:1 ]", + "[ 11/3 → 4/1 | s:hh n:1 ]", ] `; @@ -2580,6 +2566,69 @@ exports[`runs examples > example "never" example index 0 1`] = ` ] `; +exports[`runs examples > example "note" example index 0 1`] = ` +[ + "[ 0/1 → 1/4 | note:c ]", + "[ 1/4 → 1/2 | note:a ]", + "[ 1/2 → 3/4 | note:f ]", + "[ 3/4 → 1/1 | note:e ]", + "[ 1/1 → 5/4 | note:c ]", + "[ 5/4 → 3/2 | note:a ]", + "[ 3/2 → 7/4 | note:f ]", + "[ 7/4 → 2/1 | note:e ]", + "[ 2/1 → 9/4 | note:c ]", + "[ 9/4 → 5/2 | note:a ]", + "[ 5/2 → 11/4 | note:f ]", + "[ 11/4 → 3/1 | note:e ]", + "[ 3/1 → 13/4 | note:c ]", + "[ 13/4 → 7/2 | note:a ]", + "[ 7/2 → 15/4 | note:f ]", + "[ 15/4 → 4/1 | note:e ]", +] +`; + +exports[`runs examples > example "note" example index 1 1`] = ` +[ + "[ 0/1 → 1/4 | note:c4 ]", + "[ 1/4 → 1/2 | note:a4 ]", + "[ 1/2 → 3/4 | note:f4 ]", + "[ 3/4 → 1/1 | note:e4 ]", + "[ 1/1 → 5/4 | note:c4 ]", + "[ 5/4 → 3/2 | note:a4 ]", + "[ 3/2 → 7/4 | note:f4 ]", + "[ 7/4 → 2/1 | note:e4 ]", + "[ 2/1 → 9/4 | note:c4 ]", + "[ 9/4 → 5/2 | note:a4 ]", + "[ 5/2 → 11/4 | note:f4 ]", + "[ 11/4 → 3/1 | note:e4 ]", + "[ 3/1 → 13/4 | note:c4 ]", + "[ 13/4 → 7/2 | note:a4 ]", + "[ 7/2 → 15/4 | note:f4 ]", + "[ 15/4 → 4/1 | note:e4 ]", +] +`; + +exports[`runs examples > example "note" example index 2 1`] = ` +[ + "[ 0/1 → 1/4 | note:60 ]", + "[ 1/4 → 1/2 | note:69 ]", + "[ 1/2 → 3/4 | note:65 ]", + "[ 3/4 → 1/1 | note:64 ]", + "[ 1/1 → 5/4 | note:60 ]", + "[ 5/4 → 3/2 | note:69 ]", + "[ 3/2 → 7/4 | note:65 ]", + "[ 7/4 → 2/1 | note:64 ]", + "[ 2/1 → 9/4 | note:60 ]", + "[ 9/4 → 5/2 | note:69 ]", + "[ 5/2 → 11/4 | note:65 ]", + "[ 11/4 → 3/1 | note:64 ]", + "[ 3/1 → 13/4 | note:60 ]", + "[ 13/4 → 7/2 | note:69 ]", + "[ 7/2 → 15/4 | note:65 ]", + "[ 15/4 → 4/1 | note:64 ]", +] +`; + exports[`runs examples > example "octave" example index 0 1`] = ` [ "[ 0/1 → 1/1 | n:0 s:supersquare octave:3 ]", @@ -3280,6 +3329,31 @@ exports[`runs examples > example "samples" example index 0 1`] = ` ] `; +exports[`runs examples > example "samples" example index 1 1`] = ` +[ + "[ 0/1 → 1/4 | s:bd ]", + "[ 1/2 → 3/4 | s:bd ]", + "[ 1/4 → 1/2 | s:hh ]", + "[ 3/4 → 1/1 | s:hh ]", + "[ 1/2 → 1/1 | s:sd ]", + "[ 1/1 → 5/4 | s:bd ]", + "[ 3/2 → 7/4 | s:bd ]", + "[ 5/4 → 3/2 | s:hh ]", + "[ 7/4 → 2/1 | s:hh ]", + "[ 3/2 → 2/1 | s:sd ]", + "[ 2/1 → 9/4 | s:bd ]", + "[ 5/2 → 11/4 | s:bd ]", + "[ 9/4 → 5/2 | s:hh ]", + "[ 11/4 → 3/1 | s:hh ]", + "[ 5/2 → 3/1 | s:sd ]", + "[ 3/1 → 13/4 | s:bd ]", + "[ 7/2 → 15/4 | s:bd ]", + "[ 13/4 → 7/2 | s:hh ]", + "[ 15/4 → 4/1 | s:hh ]", + "[ 7/2 → 4/1 | s:sd ]", +] +`; + exports[`runs examples > example "saw" example index 0 1`] = ` [ "[ 0/1 → 1/32 | note:c3 ]", @@ -3323,6 +3397,35 @@ exports[`runs examples > example "saw" example index 1 1`] = ` `; exports[`runs examples > example "scale" example index 0 1`] = ` +[ + "[ 0/1 → 1/6 | note:C2 ]", + "[ 1/6 → 1/3 | note:E2 ]", + "[ 1/3 → 1/2 | note:G2 ]", + "[ 1/2 → 2/3 | note:B2 ]", + "[ 2/3 → 5/6 | note:G2 ]", + "[ 5/6 → 1/1 | note:E2 ]", + "[ 1/1 → 7/6 | note:C2 ]", + "[ 7/6 → 4/3 | note:E2 ]", + "[ 4/3 → 3/2 | note:G2 ]", + "[ 3/2 → 5/3 | note:B2 ]", + "[ 5/3 → 11/6 | note:G2 ]", + "[ 11/6 → 2/1 | note:E2 ]", + "[ 2/1 → 13/6 | note:C2 ]", + "[ 13/6 → 7/3 | note:E2 ]", + "[ 7/3 → 5/2 | note:G2 ]", + "[ 5/2 → 8/3 | note:B2 ]", + "[ 8/3 → 17/6 | note:G2 ]", + "[ 17/6 → 3/1 | note:E2 ]", + "[ 3/1 → 19/6 | note:C2 ]", + "[ 19/6 → 10/3 | note:E2 ]", + "[ 10/3 → 7/2 | note:G2 ]", + "[ 7/2 → 11/3 | note:B2 ]", + "[ 11/3 → 23/6 | note:G2 ]", + "[ 23/6 → 4/1 | note:E2 ]", +] +`; + +exports[`runs examples > example "scale" example index 1 1`] = ` [ "[ 0/1 → 1/6 | note:C2 ]", "[ 1/6 → 1/3 | note:E2 ]", @@ -3587,6 +3690,39 @@ exports[`runs examples > example "sine" example index 0 1`] = ` ] `; +exports[`runs examples > example "slice" example index 0 1`] = ` +[ + "[ (15/16 → 1/1) ⇝ 9/8 | begin:0.25 end:0.375 _slices:8 s:breaks165 ]", + "[ 3/4 → 15/16 | begin:0.375 end:0.5 _slices:8 s:breaks165 ]", + "[ 21/32 → 3/4 | begin:0.5 end:0.625 _slices:8 s:breaks165 ]", + "[ 9/16 → 21/32 | begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 3/8 → 9/16 | begin:0.625 end:0.75 _slices:8 s:breaks165 ]", + "[ 3/16 → 3/8 | begin:0.75 end:0.875 _slices:8 s:breaks165 ]", + "[ 0/1 → 3/16 | begin:0.875 end:1 _slices:8 s:breaks165 ]", + "[ 21/16 → 3/2 | begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 9/8 → 21/16 | begin:0.125 end:0.25 _slices:8 s:breaks165 ]", + "[ 15/16 ⇜ (1/1 → 9/8) | begin:0.25 end:0.375 _slices:8 s:breaks165 ]", + "[ 3/2 → 27/16 | begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 27/16 → 15/8 | begin:0.125 end:0.25 _slices:8 s:breaks165 ]", + "[ 15/8 → 63/32 | begin:0.25 end:0.375 _slices:8 s:breaks165 ]", + "[ (63/32 → 2/1) ⇝ 33/16 | begin:0.25 end:0.375 _slices:8 s:breaks165 ]", + "[ 63/32 ⇜ (2/1 → 33/16) | begin:0.25 end:0.375 _slices:8 s:breaks165 ]", + "[ 33/16 → 9/4 | begin:0.375 end:0.5 _slices:8 s:breaks165 ]", + "[ 9/4 → 75/32 | begin:0.5 end:0.625 _slices:8 s:breaks165 ]", + "[ 75/32 → 39/16 | begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 39/16 → 21/8 | begin:0.625 end:0.75 _slices:8 s:breaks165 ]", + "[ 21/8 → 45/16 | begin:0.75 end:0.875 _slices:8 s:breaks165 ]", + "[ 45/16 → 3/1 | begin:0.875 end:1 _slices:8 s:breaks165 ]", + "[ 3/1 → 51/16 | begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 51/16 → 27/8 | begin:0.125 end:0.25 _slices:8 s:breaks165 ]", + "[ 27/8 → 57/16 | begin:0.25 end:0.375 _slices:8 s:breaks165 ]", + "[ 57/16 → 15/4 | begin:0.375 end:0.5 _slices:8 s:breaks165 ]", + "[ 15/4 → 123/32 | begin:0.5 end:0.625 _slices:8 s:breaks165 ]", + "[ 123/32 → 63/16 | begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ (63/16 → 4/1) ⇝ 33/8 | begin:0.625 end:0.75 _slices:8 s:breaks165 ]", +] +`; + exports[`runs examples > example "slow" example index 0 1`] = ` [ "[ 0/1 → 1/1 | s:bd ]", @@ -3712,6 +3848,36 @@ exports[`runs examples > example "speed" example index 1 1`] = ` ] `; +exports[`runs examples > example "splice" example index 0 1`] = ` +[ + "[ 0/1 → 5/26 | speed:0.65 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 5/26 → 5/13 | speed:0.65 unit:c begin:0.125 end:0.25 _slices:8 s:breaks165 ]", + "[ 5/13 → 20/39 | speed:0.9750000000000001 unit:c begin:0.25 end:0.375 _slices:8 s:breaks165 ]", + "[ 20/39 → 25/39 | speed:0.9750000000000001 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]", + "[ 25/39 → 10/13 | speed:0.9750000000000001 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 10/13 → 25/26 | speed:0.65 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]", + "[ (25/26 → 1/1) ⇝ 35/26 | speed:0.325 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 25/26 ⇜ (1/1 → 35/26) | speed:0.325 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 35/26 → 20/13 | speed:0.65 unit:c begin:0.875 end:1 _slices:8 s:breaks165 ]", + "[ 20/13 → 45/26 | speed:0.65 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 45/26 → 25/13 | speed:0.65 unit:c begin:0.125 end:0.25 _slices:8 s:breaks165 ]", + "[ (25/13 → 2/1) ⇝ 80/39 | speed:0.9750000000000001 unit:c begin:0.25 end:0.375 _slices:8 s:breaks165 ]", + "[ 25/13 ⇜ (2/1 → 80/39) | speed:0.9750000000000001 unit:c begin:0.25 end:0.375 _slices:8 s:breaks165 ]", + "[ 80/39 → 85/39 | speed:0.9750000000000001 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]", + "[ 85/39 → 30/13 | speed:0.9750000000000001 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 30/13 → 5/2 | speed:0.65 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]", + "[ 5/2 → 75/26 | speed:0.325 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ (75/26 → 3/1) ⇝ 40/13 | speed:0.65 unit:c begin:0.875 end:1 _slices:8 s:breaks165 ]", + "[ 75/26 ⇜ (3/1 → 40/13) | speed:0.65 unit:c begin:0.875 end:1 _slices:8 s:breaks165 ]", + "[ 40/13 → 85/26 | speed:0.65 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ 85/26 → 45/13 | speed:0.65 unit:c begin:0.125 end:0.25 _slices:8 s:breaks165 ]", + "[ 45/13 → 140/39 | speed:0.9750000000000001 unit:c begin:0.25 end:0.375 _slices:8 s:breaks165 ]", + "[ 140/39 → 145/39 | speed:0.9750000000000001 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]", + "[ 145/39 → 50/13 | speed:0.9750000000000001 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]", + "[ (50/13 → 4/1) ⇝ 105/26 | speed:0.65 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]", +] +`; + exports[`runs examples > example "square" example index 0 1`] = ` [ "[ 0/1 → 1/2 | note:C3 ]", @@ -4128,6 +4294,48 @@ exports[`runs examples > example "vowel" example index 0 1`] = ` ] `; +exports[`runs examples > example "weave" example index 0 1`] = ` +[ + "[ 0/1 → 1/8 | pan:0.015625 s:bd ]", + "[ 3/8 → 1/2 | pan:0.109375 s:bd ]", + "[ 3/4 → 7/8 | pan:0.203125 s:bd ]", + "[ 1/1 → 9/8 | pan:0.265625 s:bd ]", + "[ 11/8 → 3/2 | pan:0.359375 s:bd ]", + "[ 7/4 → 15/8 | pan:0.453125 s:bd ]", + "[ 2/1 → 17/8 | pan:0.515625 s:bd ]", + "[ 19/8 → 5/2 | pan:0.609375 s:bd ]", + "[ 11/4 → 23/8 | pan:0.703125 s:bd ]", + "[ 3/1 → 25/8 | pan:0.765625 s:bd ]", + "[ 27/8 → 7/2 | pan:0.859375 s:bd ]", + "[ 15/4 → 31/8 | pan:0.953125 s:bd ]", + "[ 1/2 → 1/1 | pan:0.6875 s:sd ]", + "[ 3/2 → 2/1 | pan:0.9375 s:sd ]", + "[ 5/2 → 3/1 | pan:0.1875 s:sd ]", + "[ 7/2 → 4/1 | pan:0.4375 s:sd ]", +] +`; + +exports[`runs examples > example "weave" example index 1 1`] = ` +[ + "[ 0/1 → 1/8 | n:0 s:bd ]", + "[ 3/8 → 1/2 | n:0 s:bd ]", + "[ 3/4 → 7/8 | n:0 s:bd ]", + "[ 1/1 → 9/8 | n:1 s:bd ]", + "[ 11/8 → 3/2 | n:1 s:bd ]", + "[ 7/4 → 15/8 | n:1 s:bd ]", + "[ 2/1 → 17/8 | n:2 s:bd ]", + "[ 19/8 → 5/2 | n:2 s:bd ]", + "[ 11/4 → 23/8 | n:2 s:bd ]", + "[ 3/1 → 25/8 | n:3 s:bd ]", + "[ 27/8 → 7/2 | n:3 s:bd ]", + "[ 15/4 → 31/8 | n:3 s:bd ]", + "[ 1/2 → 1/1 | n:4 s:sd ]", + "[ 3/2 → 2/1 | n:5 s:sd ]", + "[ 5/2 → 3/1 | n:6 s:sd ]", + "[ 7/2 → 4/1 | n:7 s:sd ]", +] +`; + exports[`runs examples > example "webdirt" example index 0 1`] = ` [ "[ 0/1 → 1/8 | s:bd n:0 ]", diff --git a/website/astro.config.mjs b/website/astro.config.mjs index 646a3b3ca..a90ce0f6a 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -1,24 +1,47 @@ import { defineConfig } from 'astro/config'; import preact from '@astrojs/preact'; import react from '@astrojs/react'; - import mdx from '@astrojs/mdx'; import remarkToc from 'remark-toc'; import rehypeSlug from 'rehype-slug'; import rehypeAutolinkHeadings from 'rehype-autolink-headings'; +import rehypeUrls from 'rehype-urls'; import tailwind from '@astrojs/tailwind'; import AstroPWA from '@vite-pwa/astro'; // import { visualizer } from 'rollup-plugin-visualizer'; +const site = `https://strudel.tidalcycles.org`; // root url without a path +const base = '/'; // base path of the strudel site + +// this rehype plugin converts relative anchor links to absolute ones +// it wokrs by prepending the absolute page path to anchor links +// example: #gain -> /learn/effects/#gain +// this is necessary when using a base href like +// in this setup, relative anchor links will always link to base, instead of the current page +function absoluteAnchors() { + return (tree, file) => { + const chunks = file.history[0].split('/src/pages/'); // file.history[0] is the file path + const path = chunks[chunks.length - 1].slice(0, -4); // only path inside src/pages, without .mdx + return rehypeUrls((url) => { + if (!url.href.startsWith('#')) { + return; + } + const baseWithSlash = base.endsWith('/') ? base : base + '/'; + const absoluteUrl = baseWithSlash + path + url.href; + // console.log(url.href + ' -> ', absoluteUrl); + return absoluteUrl; + })(tree); + }; +} const options = { // See https://mdxjs.com/advanced/plugins remarkPlugins: [ remarkToc, // E.g. `remark-frontmatter` ], - rehypePlugins: [rehypeSlug, rehypeAutolinkHeadings], + rehypePlugins: [rehypeSlug, [rehypeAutolinkHeadings, { behavior: 'append' }], absoluteAnchors], }; // https://astro.build/config @@ -37,12 +60,18 @@ export default defineConfig({ globPatterns: ['**/*.{js,css,html,ico,png,svg,json,wav,mp3,ogg}'], runtimeCaching: [ { - urlPattern: /^https:\/\/raw\.githubusercontent\.com\/.*/i, + urlPattern: ({ url }) => + [ + /^https:\/\/raw\.githubusercontent\.com\/.*/i, + /^https:\/\/freesound\.org\/.*/i, + /^https:\/\/cdn\.freesound\.org\/.*/i, + /^https:\/\/shabda\.ndre\.gr\/.*/i, + ].some((regex) => regex.test(url)), handler: 'CacheFirst', options: { - cacheName: 'github-files', + cacheName: 'external-samples', expiration: { - maxEntries: 200, + maxEntries: 5000, maxAgeSeconds: 60 * 60 * 24 * 30, // <== 14 days }, cacheableResponse: { @@ -53,7 +82,7 @@ export default defineConfig({ ], }, devOptions: { - enabled: true, + enabled: false, }, manifest: { includeAssets: ['favicon.ico', 'icons/apple-icon-180.png', 'favicon.svg'], @@ -91,8 +120,8 @@ export default defineConfig({ }, }), ], - site: `https://strudel.tidalcycles.org`, - base: '/', + site, + base, vite: { ssr: { // Example: Force a broken package to skip SSR processing, if needed @@ -100,13 +129,3 @@ export default defineConfig({ }, }, }); - -/* - build: { - outDir: '../out', - sourcemap: true, - rollupOptions: { - plugins: [visualizer({ template: 'treemap' })], - }, - }, - */ diff --git a/website/package.json b/website/package.json index b07c9f0f1..8d85481c3 100644 --- a/website/package.json +++ b/website/package.json @@ -21,6 +21,8 @@ "@docsearch/react": "^3.1.0", "@headlessui/react": "^1.7.7", "@heroicons/react": "^2.0.13", + "@nanostores/persistent": "^0.7.0", + "@nanostores/react": "^0.4.1", "@strudel.cycles/core": "workspace:*", "@strudel.cycles/csound": "workspace:*", "@strudel.cycles/midi": "workspace:*", @@ -34,19 +36,23 @@ "@strudel.cycles/webaudio": "workspace:*", "@strudel.cycles/xen": "workspace:*", "@supabase/supabase-js": "^1.35.3", + "@tailwindcss/forms": "^0.5.3", "@tailwindcss/typography": "^0.5.8", "@types/node": "^18.0.0", "@types/react": "^18.0.26", "@types/react-dom": "^18.0.9", + "@uiw/codemirror-themes-all": "^4.19.8", "astro": "^1.7.2", "canvas": "^2.11.0", "fraction.js": "^4.2.0", "nanoid": "^4.0.0", + "nanostores": "^0.7.4", "preact": "^10.7.3", "react": "^18.2.0", "react-dom": "^18.2.0", "rehype-autolink-headings": "^6.1.1", "rehype-slug": "^5.0.1", + "rehype-urls": "^1.1.1", "remark-toc": "^8.0.1", "tailwindcss": "^3.2.4" }, diff --git a/website/public/dependencygraph.svg b/website/public/dependencygraph.svg new file mode 100644 index 000000000..62fadac7c --- /dev/null +++ b/website/public/dependencygraph.svg @@ -0,0 +1,326 @@ + + + + + + + + +@strudel.cycles/core@0.6.8 + +@strudel.cycles/core@0.6.8 + + + +fraction.js@4.2.0 + +fraction.js@4.2.0 + + + + + +@strudel.cycles/csound@0.6.2 + +@strudel.cycles/csound@0.6.2 + + + + + +@strudel.cycles/webaudio@0.6.1 + +@strudel.cycles/webaudio@0.6.1 + + + + + + + + + +@strudel.cycles/embed@0.2.0 + +@strudel.cycles/embed@0.2.0 + + + +@strudel.cycles/midi@0.6.0 + +@strudel.cycles/midi@0.6.0 + + + + + +@strudel.cycles/webaudio@0.6.0 + +@strudel.cycles/webaudio@0.6.0 + + + + + + + + + +@strudel.cycles/mini@0.6.0 + +@strudel.cycles/mini@0.6.0 + + + + + +@strudel.cycles/osc@0.6.0 + +@strudel.cycles/osc@0.6.0 + + + + + + + + + + + +@strudel.cycles/serial@0.6.0 + +@strudel.cycles/serial@0.6.0 + + + + + +@strudel.cycles/soundfonts@0.6.0 + +@strudel.cycles/soundfonts@0.6.0 + + + + + + + +sfumato@0.1.2 + +sfumato@0.1.2 + + + + + +soundfont2@0.4.0 + +soundfont2@0.4.0 + + + + + +@strudel.cycles/tonal@0.6.0 + +@strudel.cycles/tonal@0.6.0 + + + + + + + + + +chord-voicings@0.0.1 + +chord-voicings@0.0.1 + + + + + + + +@strudel.cycles/transpiler@0.6.0 + +@strudel.cycles/transpiler@0.6.0 + + + + + + + + + + + + + + + + + + + +@strudel.cycles/xen@0.6.0 + +@strudel.cycles/xen@0.6.0 + + + + + + + +chord-voicings@0.0.1->@tonaljs/tonal@4.10.0 + + + + + +sfumato@0.1.2->soundfont2@0.4.0 + + + + +@strudel.cycles/core@0.6.8->fraction.js@4.2.0 + + + +@strudel.cycles/csound@0.6.2->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/csound@0.6.2->@strudel.cycles/webaudio@0.6.1 + + + +@strudel.cycles/midi@0.6.0->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/midi@0.6.0->@strudel.cycles/webaudio@0.6.0 + + + +@strudel.cycles/midi@0.6.0->webmidi@3.1.4 + + + +@strudel.cycles/mini@0.6.0->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/osc@0.6.0->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/osc@0.6.0->osc-js@2.4.0 + + + +@strudel.cycles/serial@0.6.0->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/soundfonts@0.6.0->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/soundfonts@0.6.0->@strudel.cycles/webaudio@0.6.0 + + + +@strudel.cycles/soundfonts@0.6.0->sfumato@0.1.2 + + + +@strudel.cycles/soundfonts@0.6.0->soundfont2@0.4.0 + + + +@strudel.cycles/tonal@0.6.0->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/tonal@0.6.0->@tonaljs/tonal@4.10.0 + + + +@strudel.cycles/tonal@0.6.0->chord-voicings@0.0.1 + + + +@strudel.cycles/tonal@0.6.0->webmidi@3.1.4 + + + +@strudel.cycles/transpiler@0.6.0->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/transpiler@0.6.0->acorn@8.8.2 + + + +@strudel.cycles/transpiler@0.6.0->escodegen@2.0.0 + + + +@strudel.cycles/transpiler@0.6.0->estree-walker@3.0.3 + + + +@strudel.cycles/webaudio@0.6.1->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/xen@0.6.0->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/webaudio@0.6.0->@strudel.cycles/core@0.6.8 + + + +@strudel.cycles/csound@0.6.2->@csound/browser@6.18.5 + + + + \ No newline at end of file diff --git a/website/public/fonts/3270/3270-Regular.ttf b/website/public/fonts/3270/3270-Regular.ttf new file mode 100644 index 000000000..d6b55a6ab Binary files /dev/null and b/website/public/fonts/3270/3270-Regular.ttf differ diff --git a/website/public/fonts/3270/LICENSE.txt b/website/public/fonts/3270/LICENSE.txt new file mode 100644 index 000000000..b8f248ab4 --- /dev/null +++ b/website/public/fonts/3270/LICENSE.txt @@ -0,0 +1,51 @@ +Copyright 2022 The 3270font Authors (https://github.com/rbanffy/3270font) + +Copyright (c) 2011-2022, Ricardo Banffy. +Copyright (c) 1993-2011, Paul Mattes. +Copyright (c) 2004-2005, Don Russell. +Copyright (c) 2004, Dick Altenbern. +Copyright (c) 1990, Jeff Sparkes. +Copyright (c) 1989, Georgia Tech Research Corporation (GTRC), Atlanta, GA 30332. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of Ricardo Banffy, Paul Mattes, Don Russell, + Dick Altenbern, Jeff Sparkes, GTRC nor the names of their contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL RICARDO BANFFY, PAUL MATTES, DON RUSSELL, DICK ALTENBERN, JEFF +SPARKES OR GTRC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The Debian Logo glyph is based on the Debian Open Use Logo and is +Copyright (c) 1999 Software in the Public Interest, Inc., and it is +incorporated here under the terms of the Creative Commons +Attribution-ShareAlike 3.0 Unported License. The logo is released +under the terms of the GNU Lesser General Public License, version 3 or +any later version, or, at your option, of the Creative Commons +Attribution-ShareAlike 3.0 Unported License. + +Ubuntu, the Ubuntu logo and the Circle of Friends symbol are +registered trademarks of Canonical Ltd. + +The Fontforge SFD font description file is optionally licensed under +the SIL Open Font License v1.1 with no Reserved Font Name. This +license is available with a FAQ at http://scripts.sil.org/OFL. diff --git a/website/public/fonts/BigBlueTerminal/BigBlue_TerminalPlus.TTF b/website/public/fonts/BigBlueTerminal/BigBlue_TerminalPlus.TTF new file mode 100644 index 000000000..ddcdc328f Binary files /dev/null and b/website/public/fonts/BigBlueTerminal/BigBlue_TerminalPlus.TTF differ diff --git a/website/public/fonts/BigBlueTerminal/LICENSE.txt b/website/public/fonts/BigBlueTerminal/LICENSE.txt new file mode 100644 index 000000000..fd662a7e6 --- /dev/null +++ b/website/public/fonts/BigBlueTerminal/LICENSE.txt @@ -0,0 +1,428 @@ +Attribution-ShareAlike 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More_considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution-ShareAlike 4.0 International Public +License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-ShareAlike 4.0 International Public License ("Public +License"). To the extent this Public License may be interpreted as a +contract, You are granted the Licensed Rights in consideration of Your +acceptance of these terms and conditions, and the Licensor grants You +such rights in consideration of benefits the Licensor receives from +making the Licensed Material available under these terms and +conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. BY-SA Compatible License means a license listed at + creativecommons.org/compatiblelicenses, approved by Creative + Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + e. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name + of a Creative Commons Public License. The License Elements of this + Public License are Attribution and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + i. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + k. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + l. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + m. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. Additional offer from the Licensor -- Adapted Material. + Every recipient of Adapted Material from You + automatically receives an offer from the Licensor to + exercise the Licensed Rights in the Adapted Material + under the conditions of the Adapter's License You apply. + + c. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + b. ShareAlike. + + In addition to the conditions in Section 3(a), if You Share + Adapted Material You produce, the following conditions also apply. + + 1. The Adapter's License You apply must be a Creative Commons + license with the same License Elements, this version or + later, or a BY-SA Compatible License. + + 2. You must include the text of, or the URI or hyperlink to, the + Adapter's License You apply. You may satisfy this condition + in any reasonable manner based on the medium, means, and + context in which You Share Adapted Material. + + 3. You may not offer or impose any additional or different terms + or conditions on, or apply any Effective Technological + Measures to, Adapted Material that restrict exercise of the + rights granted under the Adapter's License You apply. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material, + + including for purposes of Section 3(b); and + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. + diff --git a/website/public/fonts/PressStart2P/OFL.txt b/website/public/fonts/PressStart2P/OFL.txt new file mode 100644 index 000000000..2a6f4a8d7 --- /dev/null +++ b/website/public/fonts/PressStart2P/OFL.txt @@ -0,0 +1,92 @@ +Copyright (c) 2012, Cody "CodeMan38" Boisclair (cody@zone38.net), with Reserved Font Name "Press Start 2P" +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/website/public/fonts/PressStart2P/PressStart2P-Regular.ttf b/website/public/fonts/PressStart2P/PressStart2P-Regular.ttf new file mode 100644 index 000000000..1098ed234 Binary files /dev/null and b/website/public/fonts/PressStart2P/PressStart2P-Regular.ttf differ diff --git a/website/public/pwa/strudel-linux.png b/website/public/pwa/strudel-linux.png new file mode 100644 index 000000000..b60edf70a Binary files /dev/null and b/website/public/pwa/strudel-linux.png differ diff --git a/website/public/pwa/strudel-macos.png b/website/public/pwa/strudel-macos.png new file mode 100644 index 000000000..cb907d163 Binary files /dev/null and b/website/public/pwa/strudel-macos.png differ diff --git a/website/src/components/Footer/AvatarList.astro b/website/src/components/Footer/AvatarList.astro index b75589f5a..86bbcc875 100644 --- a/website/src/components/Footer/AvatarList.astro +++ b/website/src/components/Footer/AvatarList.astro @@ -1,66 +1,64 @@ --- // fetch all commits for just this page's path type Props = { - path: string; + path: string; }; const { path } = Astro.props as Props; -const resolvedPath = `examples/docs/${path}`; -const url = `https://api.github.com/repos/withastro/astro/commits?path=${resolvedPath}`; -const commitsURL = `https://github.com/withastro/astro/commits/main/${resolvedPath}`; +const resolvedPath = `website/src/pages${path}.mdx`; +const url = `https://api.github.com/repos/tidalcycles/strudel/commits?path=${resolvedPath}`; +const commitsURL = `https://github.com/tidalcycles/strudel/commits/main/${resolvedPath}`; type Commit = { - author: { - id: string; - login: string; - }; + author: { + id: string; + login: string; + }; }; async function getCommits(url: string) { - try { - const token = import.meta.env.SNOWPACK_PUBLIC_GITHUB_TOKEN ?? 'hello'; - if (!token) { - throw new Error( - 'Cannot find "SNOWPACK_PUBLIC_GITHUB_TOKEN" used for escaping rate-limiting.' - ); - } + try { + const token = import.meta.env.SNOWPACK_PUBLIC_GITHUB_TOKEN ?? 'hello'; + if (!token) { + throw new Error('Cannot find "SNOWPACK_PUBLIC_GITHUB_TOKEN" used for escaping rate-limiting.'); + } - const auth = `Basic ${Buffer.from(token, 'binary').toString('base64')}`; + const auth = `Basic ${Buffer.from(token, 'binary').toString('base64')}`; - const res = await fetch(url, { - method: 'GET', - headers: { - Authorization: auth, - 'User-Agent': 'astro-docs/1.0', - }, - }); + const res = await fetch(url, { + method: 'GET', + headers: { + Authorization: auth, + 'User-Agent': 'astro-docs/1.0', + }, + }); - const data = await res.json(); + const data = await res.json(); - if (!res.ok) { - throw new Error( - `Request to fetch commits failed. Reason: ${res.statusText} - Message: ${data.message}` - ); - } + if (!res.ok) { + throw new Error( + `Request to fetch commits failed. Reason: ${res.statusText} + Message: ${data.message}`, + ); + } - return data as Commit[]; - } catch (e) { - console.warn(`[error] /src/components/AvatarList.astro + return data as Commit[]; + } catch (e) { + console.warn(`[error] /src/components/AvatarList.astro ${(e as any)?.message ?? e}`); - return [] as Commit[]; - } + return [] as Commit[]; + } } function removeDups(arr: Commit[]) { - const map = new Map(); + const map = new Map(); + for (let item of arr) { + const author = item.author; + // Deduplicate based on author.id + //map.set(author.id, { login: author.login, id: author.id }); + author && map.set(author.id, { login: author.login, id: author.id }); + } - for (let item of arr) { - const author = item.author; - // Deduplicate based on author.id - map.set(author.id, { login: author.login, id: author.id }); - } - - return [...map.values()]; + return [...map.values()]; } const data = await getCommits(url); @@ -70,102 +68,102 @@ const additionalContributors = unique.length - recentContributors.length; // lis --- -
-
    - { - recentContributors.map((item) => ( -
  • - - {`Contributor - -
  • - )) - } -
- { - additionalContributors > 0 && ( - - {`and ${additionalContributors} additional contributor${ - additionalContributors > 1 ? 's' : '' - }.`} - - ) - } - {unique.length === 0 && Contributors} +
+
    + { + recentContributors.map((item) => ( +
  • + + {`Contributor + +
  • + )) + } +
+ { + additionalContributors > 0 && ( + + {`and ${additionalContributors} additional contributor${ + additionalContributors > 1 ? 's' : '' + }.`} + + ) + } + {unique.length === 0 && Contributors}
diff --git a/website/src/components/Footer/Footer.astro b/website/src/components/Footer/Footer.astro deleted file mode 100644 index 1ec756b86..000000000 --- a/website/src/components/Footer/Footer.astro +++ /dev/null @@ -1,19 +0,0 @@ ---- -import AvatarList from './AvatarList.astro'; -type Props = { - path: string; -}; -const { path } = Astro.props as Props; ---- - -
- -
- - diff --git a/website/src/components/HeadCommon.astro b/website/src/components/HeadCommon.astro index ce00f97e2..9e81b0b88 100644 --- a/website/src/components/HeadCommon.astro +++ b/website/src/components/HeadCommon.astro @@ -27,4 +27,61 @@ const base = BASE_URL; + + + + {pwaInfo && } + + diff --git a/website/src/components/Header/Header.astro b/website/src/components/Header/Header.astro index 8bb9497d3..9e2a34c8a 100644 --- a/website/src/components/Header/Header.astro +++ b/website/src/components/Header/Header.astro @@ -19,13 +19,16 @@ const langCode = 'en'; // getLanguageFromURL(currentPage); const sidebar = SIDEBAR[langCode]; --- -