feat(bibliotheque): étape D, la page /bibliotheque (VueFiches en Mixte, GrapheConnaissances par un second adaptateur, axes thème, époque, auteur ; disposition radiale amorcée au cache du graphe), le module de build et la route de la fiche au clic ; /rag et le commutateur mènent à /bibliotheque, /media intact
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,8 @@
|
||||
* d'étendue 1 (aucune position en données) ;
|
||||
* - `disposerEnCache` : la même, mémorisée par signature du graphe (une fois par processus) ;
|
||||
* - `voisinage` : identifiants à `pas` liens au plus d'un nœud (graphe local d'Obsidian) ;
|
||||
* - `boite` : boîte englobante d'un ensemble de points, une seule écriture pour le dessin et la caméra.
|
||||
* - `boite` : boîte englobante d'un ensemble de points, une seule écriture pour le dessin et la caméra ;
|
||||
* - `amorcer` (B9) : pose au cache une disposition calculée ailleurs, sous la même signature.
|
||||
*/
|
||||
|
||||
/** Un nœud : `kind` dit sa forme (principal si dans `kindsPrincipaux`, sinon secondaire). */
|
||||
@@ -122,17 +123,31 @@ export function disposer(noeuds: NoeudGraphe[], liens: LienGraphe[], principaux:
|
||||
|
||||
/** Cache par signature du graphe : au serveur, une fois par processus, pas une fois par requête. */
|
||||
const CACHE = new Map<string, Map<string, Pt>>()
|
||||
const signature = (noeuds: NoeudGraphe[], liens: LienGraphe[], principaux: Set<string>) =>
|
||||
JSON.stringify([noeuds.map((x) => [x.id, x.kind]), liens.map((l) => [l.de, l.vers]), [...principaux]])
|
||||
function garder(sig: string, p: Map<string, Pt>) {
|
||||
if (CACHE.size > 24) CACHE.delete(CACHE.keys().next().value as string)
|
||||
CACHE.set(sig, p)
|
||||
}
|
||||
export function disposerEnCache(noeuds: NoeudGraphe[], liens: LienGraphe[], principaux: Set<string>): Map<string, Pt> {
|
||||
const sig = JSON.stringify([noeuds.map((x) => [x.id, x.kind]), liens.map((l) => [l.de, l.vers]), [...principaux]])
|
||||
const sig = signature(noeuds, liens, principaux)
|
||||
let p = CACHE.get(sig)
|
||||
if (!p) {
|
||||
p = disposer(noeuds, liens, principaux)
|
||||
if (CACHE.size > 24) CACHE.delete(CACHE.keys().next().value as string)
|
||||
CACHE.set(sig, p)
|
||||
garder(sig, p)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
/**
|
||||
* Lot B9 : une disposition déjà calculée (l'arborescence de la bibliothèque, radiale, en O(n)) entre
|
||||
* au cache sous la signature du graphe ; `disposerEnCache` la rend sans calculer de force. Mêmes
|
||||
* nœuds, liens et kinds principaux que ceux que recevra le composant, dans le même ordre.
|
||||
*/
|
||||
export function amorcer(noeuds: NoeudGraphe[], liens: LienGraphe[], principaux: Set<string>, p: Map<string, Pt>): void {
|
||||
garder(signature(noeuds, liens, principaux), p)
|
||||
}
|
||||
|
||||
/** Identifiants à `pas` liens au plus de `id` (le nœud compris) ; `tout` = tous. */
|
||||
export function voisinage(liens: LienGraphe[], id: string, pas: Pas): Set<string> | null {
|
||||
if (pas === 'tout') return null
|
||||
|
||||
Reference in New Issue
Block a user