|
| 1 | +import { contractKeys } from '@galaxy-foundry/reference-contract'; |
| 2 | +import type { ReferenceContractProps } from '@galaxy-foundry/site-kit'; |
| 3 | +import { |
| 4 | + SPECIMENS, |
| 5 | + type Specimen, |
| 6 | + type SpecimenGroup, |
| 7 | +} from '@galaxy-foundry/site-kit/specimens'; |
| 8 | + |
| 9 | +import { contentReader } from './content-reader'; |
| 10 | +import { referenceContract as loadReferenceContract } from './reference-contract'; |
| 11 | +import { base } from './site-base'; |
| 12 | + |
| 13 | +const referenceContract = loadReferenceContract(); |
| 14 | + |
| 15 | +const kindSpecimen = (kind: string): Specimen<ReferenceContractProps> => { |
| 16 | + const term = referenceContract.kinds[kind]; |
| 17 | + return { |
| 18 | + id: kind, |
| 19 | + name: term?.label ?? kind, |
| 20 | + why: |
| 21 | + term?.description ?? |
| 22 | + `The ${kind} reference kind under this Foundry's palette and fallback accent.`, |
| 23 | + props: { |
| 24 | + contract: referenceContract, |
| 25 | + references: [ |
| 26 | + { |
| 27 | + kind, |
| 28 | + ref: `[[gallery-${kind}]]`, |
| 29 | + used_at: 'runtime', |
| 30 | + load: 'upfront', |
| 31 | + mode: 'verbatim', |
| 32 | + evidence: 'corpus-observed', |
| 33 | + }, |
| 34 | + ], |
| 35 | + }, |
| 36 | + }; |
| 37 | +}; |
| 38 | + |
| 39 | +export const TDA_KIND_SPECIMENS: SpecimenGroup<ReferenceContractProps> = { |
| 40 | + id: 'tda-reference-kinds', |
| 41 | + component: 'ReferenceContract', |
| 42 | + importPath: '@galaxy-foundry/site-kit/ReferenceContract.astro', |
| 43 | + summary: |
| 44 | + 'Every reference kind this Foundry declares, derived from its contract so a new kind cannot arrive unseen.', |
| 45 | + surface: 'inline', |
| 46 | + specimens: contractKeys(referenceContract, 'kinds').map(kindSpecimen), |
| 47 | +}; |
| 48 | + |
| 49 | +export const FILTRATION_HERO_SPECIMENS: SpecimenGroup<{ noteCount: number }> = { |
| 50 | + id: 'tda-filtration-hero', |
| 51 | + component: 'FiltrationHero', |
| 52 | + importPath: '../components/FiltrationHero.astro', |
| 53 | + summary: |
| 54 | + 'The interactive frontispiece: a point cloud becomes a complex and leaves one persistent loop.', |
| 55 | + surface: 'isolated', |
| 56 | + specimens: [ |
| 57 | + { |
| 58 | + id: 'stable-loop', |
| 59 | + name: 'Structure across scale', |
| 60 | + why: |
| 61 | + 'The range control makes filtration tangible while the copy connects multiscale structure to the Foundry workflow.', |
| 62 | + props: { noteCount: contentReader.noteTargets().length }, |
| 63 | + }, |
| 64 | + ], |
| 65 | +}; |
| 66 | + |
| 67 | +export const PERSISTENCE_DIVIDER_SPECIMENS: SpecimenGroup<{ seed: string }> = { |
| 68 | + id: 'tda-persistence-divider', |
| 69 | + component: 'PersistenceDivider', |
| 70 | + importPath: '../components/PersistenceDivider.astro', |
| 71 | + summary: |
| 72 | + 'A deterministic barcode used as punctuation between conceptual sections.', |
| 73 | + surface: 'inline', |
| 74 | + specimens: [ |
| 75 | + { |
| 76 | + id: 'section-punctuation', |
| 77 | + name: 'Persistent section break', |
| 78 | + why: |
| 79 | + 'One interval receives the persistent accent, turning a divider into domain-specific hierarchy without adding prose.', |
| 80 | + props: { seed: 'gallery:persistence-divider' }, |
| 81 | + }, |
| 82 | + ], |
| 83 | +}; |
| 84 | + |
| 85 | +export const POINT_CLOUD_SPECIMENS: SpecimenGroup<{ seed: string }> = { |
| 86 | + id: 'tda-point-cloud-fingerprint', |
| 87 | + component: 'PointCloudFingerprint', |
| 88 | + importPath: '../components/PointCloudFingerprint.astro', |
| 89 | + summary: |
| 90 | + 'Seeded geometric marginalia that gives each surface a stable visual fingerprint.', |
| 91 | + surface: 'inline', |
| 92 | + specimens: [ |
| 93 | + { |
| 94 | + id: 'stable-fingerprint', |
| 95 | + name: 'Seeded point cloud', |
| 96 | + why: |
| 97 | + 'The same semantic seed always yields the same points, neighborhood edges, and highlighted loop.', |
| 98 | + props: { seed: 'gallery:point-cloud-fingerprint' }, |
| 99 | + }, |
| 100 | + ], |
| 101 | +}; |
| 102 | + |
| 103 | +export const TOPOLOGY_BREADCRUMB_SPECIMENS: SpecimenGroup<{ |
| 104 | + href: string; |
| 105 | + label: string; |
| 106 | + current: string; |
| 107 | + seed: string; |
| 108 | +}> = { |
| 109 | + id: 'tda-topology-breadcrumb', |
| 110 | + component: 'TopologyBreadcrumb', |
| 111 | + importPath: '../components/TopologyBreadcrumb.astro', |
| 112 | + summary: |
| 113 | + 'Back navigation drawn as connected nodes, paired with a deterministic point-cloud signature.', |
| 114 | + surface: 'inline', |
| 115 | + specimens: [ |
| 116 | + { |
| 117 | + id: 'method-detail', |
| 118 | + name: 'Connected reading path', |
| 119 | + why: |
| 120 | + 'The ordinary collection-to-note relationship is expressed as a tiny graph without weakening breadcrumb semantics.', |
| 121 | + props: { |
| 122 | + href: `${base}/methods/`, |
| 123 | + label: 'Methods', |
| 124 | + current: 'Persistent homology', |
| 125 | + seed: 'gallery:topology-breadcrumb', |
| 126 | + }, |
| 127 | + }, |
| 128 | + ], |
| 129 | +}; |
| 130 | + |
| 131 | +export const TDA_SPECIMENS: readonly SpecimenGroup[] = [ |
| 132 | + TDA_KIND_SPECIMENS, |
| 133 | + FILTRATION_HERO_SPECIMENS, |
| 134 | + PERSISTENCE_DIVIDER_SPECIMENS, |
| 135 | + POINT_CLOUD_SPECIMENS, |
| 136 | + TOPOLOGY_BREADCRUMB_SPECIMENS, |
| 137 | +]; |
| 138 | + |
| 139 | +export const ALL_SPECIMENS: readonly SpecimenGroup[] = [...SPECIMENS, ...TDA_SPECIMENS]; |
| 140 | + |
| 141 | +const groupIds = ALL_SPECIMENS.map((group) => group.id); |
| 142 | +if (new Set(groupIds).size !== groupIds.length) { |
| 143 | + throw new Error('gallery specimen group ids must be unique across shared and TDA groups'); |
| 144 | +} |
| 145 | + |
| 146 | +export const specimenOrigin = (group: SpecimenGroup): 'shared' | 'tda' => |
| 147 | + TDA_SPECIMENS.some((candidate) => candidate.id === group.id) ? 'tda' : 'shared'; |
0 commit comments