import { useMemo, useState } from 'react'; import jsdocJson from '../../../../../doc.json'; import { Textbox } from '../textbox/Textbox'; const isValid = ({ name, description }) => name && !name.startsWith('_') && !!description; const availableFunctions = (() => { const seen = new Set(); // avoid repetition const functions = []; for (const doc of jsdocJson.docs) { if (!isValid(doc)) continue; functions.push(doc); const synonyms = doc.synonyms || []; for (const s of synonyms) { if (!s || seen.has(s)) continue; seen.add(s); // Swap `doc.name` in for `s` in the list of synonyms const synonymsWithDoc = [doc.name, ...synonyms].filter((x) => x && x !== s); functions.push({ ...doc, name: s, // update names for the synonym longname: s, synonyms: synonymsWithDoc, synonyms_text: synonymsWithDoc.join(', '), }); } } return functions.sort((a, b) => /* a.meta.filename.localeCompare(b.meta.filename) + */ a.name.localeCompare(b.name)); })(); const getInnerText = (html) => { var div = document.createElement('div'); div.innerHTML = html; return div.textContent || div.innerText || ''; }; export function Reference() { const [search, setSearch] = useState(''); const visibleFunctions = useMemo(() => { return availableFunctions.filter((entry) => { if (!search) { return true; } const lowerCaseSearch = search.toLowerCase(); return ( entry.name.toLowerCase().includes(lowerCaseSearch) || (entry.synonyms?.some((s) => s.toLowerCase().includes(lowerCaseSearch)) ?? false) ); }); }, [search]); return (
{visibleFunctions.map((entry, i) => ( { const el = document.getElementById(`doc-${i}`); const container = document.getElementById('reference-container'); container.scrollTo(0, el.offsetTop); }} > {entry.name} {/* {entry.meta.filename} */} ))}

API Reference

This is the long list of functions you can use. Remember that you don't need to remember all of those and that you can already make music with a small set of functions!

{visibleFunctions.map((entry, i) => (

{entry.name}

{!!entry.synonyms_text && (

Synonyms: {entry.synonyms_text}

)} {/* {entry.meta.filename} */}

    {entry.params?.map(({ name, type, description }, i) => (
  • {name} : {type?.names?.join(' | ')} {description ? <> - {getInnerText(description)} : ''}
  • ))}
{entry.examples?.map((example, j) => (
                  {example}
                
))}
))}
); }