| import { create } from 'zustand'; |
| import { devtools, persist } from 'zustand/middleware'; |
|
|
| |
| |
| |
| export const useDebugUMAPStore = create( |
| devtools( |
| persist( |
| (set, get) => ({ |
| |
| configs: [], |
| currentConfigIndex: 0, |
| loading: false, |
| error: null, |
|
|
| |
| useCategoryColors: true, |
| baseGlyphSize: 0.25, |
| darkMode: false, |
| showCentroids: true, |
|
|
| |
| overlapRadius: 10, |
| overlapTicks: 140, |
| overlapOriginStrength: 0.03, |
|
|
| |
| currentFonts: [], |
| dilatedFonts: [], |
| mappingFunctions: { mapX: null, mapY: null }, |
| glyphsLoaded: false, |
|
|
| |
| setConfigs: (configs) => set({ configs }), |
| setCurrentConfigIndex: (index) => set({ currentConfigIndex: index }), |
| setLoading: (loading) => set({ loading }), |
| setError: (error) => set({ error }), |
| |
| |
| setLiveResult: (result) => { |
| console.log('📍 Store: Définition du résultat UMAP en direct'); |
| |
| set({ |
| configs: [result], |
| currentConfigIndex: 0, |
| error: null |
| }); |
| }, |
|
|
| |
| setUseCategoryColors: (useCategoryColors) => set({ useCategoryColors }), |
| setBaseGlyphSize: (baseGlyphSize) => set({ baseGlyphSize }), |
| setDarkMode: (darkMode) => set({ darkMode }), |
| setShowCentroids: (showCentroids) => set({ showCentroids }), |
|
|
| |
| setOverlapRadius: (v) => set({ overlapRadius: v }), |
| setOverlapTicks: (v) => set({ overlapTicks: v }), |
| setOverlapOriginStrength: (v) => set({ overlapOriginStrength: v }), |
|
|
| |
| setCurrentFonts: (fonts) => set({ currentFonts: fonts }), |
| setDilatedFonts: (fonts) => set({ dilatedFonts: fonts }), |
| setMappingFunctions: (functions) => set({ mappingFunctions: functions }), |
| setGlyphsLoaded: (loaded) => set({ glyphsLoaded: loaded }), |
|
|
| |
| resetToDefaults: () => set({ |
| currentConfigIndex: 0, |
| useCategoryColors: true, |
| baseGlyphSize: 0.25, |
| darkMode: false, |
| showCentroids: true, |
| overlapRadius: 10, |
| overlapTicks: 140, |
| overlapOriginStrength: 0.03, |
| currentFonts: [], |
| dilatedFonts: [], |
| mappingFunctions: { mapX: null, mapY: null }, |
| glyphsLoaded: false, |
| error: null |
| }), |
|
|
| |
| getCurrentConfig: () => { |
| const { configs, currentConfigIndex } = get(); |
| return configs[currentConfigIndex] || null; |
| }, |
|
|
| getTotalConfigs: () => { |
| const { configs } = get(); |
| return configs.length; |
| } |
| }), |
| { |
| name: 'debug-umap-persist', |
| version: 2, |
| partialize: (state) => ({ |
| useCategoryColors: state.useCategoryColors, |
| baseGlyphSize: state.baseGlyphSize, |
| darkMode: state.darkMode, |
| showCentroids: state.showCentroids, |
| }), |
| migrate: (persisted) => ({ |
| useCategoryColors: persisted?.useCategoryColors ?? true, |
| baseGlyphSize: persisted?.baseGlyphSize ?? 0.25, |
| darkMode: persisted?.darkMode ?? false, |
| showCentroids: persisted?.showCentroids ?? true, |
| }), |
| } |
| ), |
| { |
| name: 'debug-umap-store', |
| } |
| ) |
| ); |
|
|
| |
|
|