1import { diagramTypes } from './diagram-types.js'23// The launcher is deliberately data-only. Keep this catalog independent from4// the DOM so it can be used by both the initial launcher and the command5// palette without duplicating format metadata.6const GROUP_DEFINITIONS = [7 {8 id: 'flow-sequence',9 label: 'Flow & sequence',10 description: 'Processes, interactions, and timelines.',11 types: ['plantuml', 'mermaid', 'seqdiag', 'actdiag', 'blockdiag', 'bpmn', 'trn'],12 },13 {14 id: 'architecture',15 label: 'Architecture',16 description: 'Systems, components, relationships, and software structure.',17 types: ['c4plantuml', 'structurizr', 'd2', 'graphviz', 'nomnoml', 'umlet'],18 },19 {20 id: 'data-charts',21 label: 'Data & charts',22 description: 'Data models, plots, and technical visualizations.',23 types: ['dbml', 'erd', 'vega', 'vegalite', 'squaring'],24 },25 {26 id: 'network-hardware',27 label: 'Network & hardware',28 description: 'Networks, packets, wiring, and low-level hardware layouts.',29 types: ['nwdiag', 'packetdiag', 'rackdiag', 'bytefield', 'wavedrom', 'symbolator', 'wireviz'],30 },31 {32 id: 'drawing-ascii',33 label: 'Drawing & ASCII',34 description: 'Freeform drawings, markup diagrams, and text-based art.',35 types: ['excalidraw', 'diagramsnet', 'ditaa', 'goat', 'svgbob', 'pikchr', 'tikz'],36 },37]3839const DESCRIPTIONS = {40 plantuml: 'Text-based UML and software diagrams.',41 mermaid: 'Markdown-friendly flowcharts and diagrams.',42 graphviz: 'Graphs and relationship diagrams using DOT.',43 d2: 'Declarative diagrams with a modern, readable syntax.',44 c4plantuml: 'C4 architecture diagrams in PlantUML syntax.',45 blockdiag: 'Block and dependency diagrams.',46 seqdiag: 'Simple sequence diagrams.',47 actdiag: 'Activity and process diagrams.',48 nwdiag: 'Network topology diagrams.',49 packetdiag: 'Packet and protocol layout diagrams.',50 rackdiag: 'Rack and infrastructure diagrams.',51 squaring: 'Squared rectangles and their Smith diagram circuits.',52 bpmn: 'Business process model and notation diagrams.',53 bytefield: 'Structured byte and protocol field diagrams.',54 dbml: 'Database schemas from DBML.',55 diagramsnet: 'Diagrams.net editable drawings.',56 ditaa: 'ASCII art converted into diagrams.',57 erd: 'Entity-relationship database diagrams.',58 excalidraw: 'Hand-drawn style editable diagrams.',59 goat: 'ASCII-art diagrams using the GoAT syntax.',60 nomnoml: 'UML-style diagrams with a lightweight syntax.',61 pikchr: 'Text-based technical illustrations.',62 structurizr: 'C4 architecture diagrams from a workspace model.',63 svgbob: 'ASCII diagrams rendered as SVG.',64 symbolator: 'HDL and digital logic symbol diagrams.',65 tikz: 'Precise TeX-based technical drawings.',66 trn: 'Tabular recipes with ingredient rows and operation columns.',67 umlet: 'Lightweight UML diagrams.',68 vega: 'Programmable data visualizations with Vega.',69 vegalite: 'Concise declarative data visualizations.',70 wavedrom: 'Digital timing and signal diagrams.',71 wireviz: 'Cables and wiring harness diagrams.',72}7374const EXTENSIONS = {75 plantuml: ['.puml', '.pu'], mermaid: ['.mmd'], graphviz: ['.dot', '.gv'], d2: ['.d2'],76 c4plantuml: ['.puml'], blockdiag: ['.diag'], seqdiag: ['.diag'], actdiag: ['.diag'],77 nwdiag: ['.diag'], packetdiag: ['.diag'], rackdiag: ['.diag'], bpmn: ['.bpmn'],78 bytefield: ['.bf'], dbml: ['.dbml'], diagramsnet: ['.drawio'], ditaa: ['.ditaa'],79 erd: ['.erd'], excalidraw: ['.excalidraw'], goat: ['.goat'], nomnoml: ['.nomnoml'],80 pikchr: ['.pikchr'], structurizr: ['.dsl'], svgbob: ['.bob'], symbolator: ['.sv'],81 tikz: ['.tex'], trn: ['.trn'], squaring: ['.squaring'], umlet: ['.uxf'], vega: ['.json'], vegalite: ['.json'], wavedrom: ['.json'],82 wireviz: ['.yaml', '.yml'],83}8485const labels = new Map(diagramTypes.map(type => [type.id, type.label]))8687function normalizeEntry(type, group) {88 return Object.freeze({89 id: type,90 label: labels.get(type),91 description: DESCRIPTIONS[type],92 extensions: Object.freeze([...(EXTENSIONS[type] ?? [])]),93 groupId: group.id,94 groupLabel: group.label,95 })96}9798export const launcherCatalogGroups = Object.freeze(GROUP_DEFINITIONS.map(group => Object.freeze({99 id: group.id,100 label: group.label,101 description: group.description,102 items: Object.freeze(group.types.map(type => normalizeEntry(type, group))),103})))104105const entriesById = new Map(launcherCatalogGroups.flatMap(group => group.items).map(entry => [entry.id, entry]))106107// Flat data follows diagramTypes order, which keeps keyboard and URL ordering108// stable even though the launcher presents formats by category.109export const launcherCatalog = Object.freeze(diagramTypes.map(type => entriesById.get(type.id)))110111export function launcherEntryFor(id) {112 return entriesById.get(id) ?? null113}114115export function filterLauncherCatalog(query = '') {116 const needle = String(query).trim().toLocaleLowerCase()117 if (!needle) return launcherCatalog118 return launcherCatalog.filter(entry => [entry.id, entry.label, entry.description, ...entry.extensions]119 .some(value => value.toLocaleLowerCase().includes(needle)))120}121122// Short aliases make the module convenient for callers that do not need the123// launcher-specific name while retaining the explicit exports above.124export const catalogGroups = launcherCatalogGroups125export const flatCatalog = launcherCatalog126export const catalogEntryFor = launcherEntryFor127export const filterCatalog = filterLauncherCatalog