tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

program-catalogue.ts (1717B)


      1 import { packageReleases, type Release } from './packages.js';
      2 import type { CatalogueEntry } from './protocol.js';
      3 export const exampleGroups = ['Basic Examples', 'Practical Examples', 'Language & Runtime Explorations'] as const;
      4 export function exampleGroup(entry: CatalogueEntry): typeof exampleGroups[number] {
      5   return entry.category ?? (['microscope', 'parser', 'lexer'].includes(entry.id) ? 'Language & Runtime Explorations' : 'Practical Examples');
      6 }
      7 export function libraryLabel(name: string): string {
      8   if (name === 'tricu-lib-packages-base') return 'base · convenience interface';
      9   if (name === 'tricu-lib-packages-io') return 'io · convenience interface';
     10   if (name === 'tricu-compiler') return 'compiler · combined toolchain';
     11   if (name === 'tricu-source-builder') return 'source-builder · native entrypoint';
     12   return name.replace(/^tricu-lib-/u, '').replace(/^tricu-/u, '');
     13 }
     14 // Publication names may be aliases of exactly the same native module. Prefer
     15 // filesystem library publications, while keeping distinct interfaces separate.
     16 // Historical releases remain in the registry and reachable by bundle hash.
     17 export function selectorLibraries(releases: readonly Release[]): Release[] {
     18   const latest = [...new Set(releases.map(r => r.name))].map(name => packageReleases(releases, name)[0]!).filter(r => !r.demo);
     19   latest.sort((a, b) => Number(b.name.startsWith('tricu-lib-')) - Number(a.name.startsWith('tricu-lib-')) || a.name.localeCompare(b.name));
     20   const manifests = new Set<string>();
     21   return latest.filter(r => { if (manifests.has(r.manifest)) return false; manifests.add(r.manifest); return true; })
     22     .sort((a, b) => libraryLabel(a.name).localeCompare(libraryLabel(b.name)));
     23 }