@rivm-loculus-tools/sequence-editor 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitkeep +0 -0
- package/CHANGELOG.md +8 -0
- package/LICENSE +288 -0
- package/eslint.config.js +16 -0
- package/package.json +140 -3
- package/scripts/update-exports.js +9 -0
- package/src/classes/services/EditorWorkerService/EditorWorkerService.ts +163 -0
- package/src/classes/services/EditorWorkerService/index.ts +1 -0
- package/src/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.ts +37 -0
- package/src/classes/services/SequenceEditorEventBusService/index.ts +1 -0
- package/src/classes/workers/EngineWorker/EngineWorker.ts +196 -0
- package/src/classes/workers/EngineWorker/index.ts +1 -0
- package/src/components/app/App/App.tsx +22 -0
- package/src/components/app/App/index.ts +1 -0
- package/src/components/pages/EmptyWorkspace.tsx +43 -0
- package/src/components/pages/SequenceEditorErrorPage/SequenceEditorErrorPage.tsx +16 -0
- package/src/components/pages/SequenceEditorErrorPage/index.ts +1 -0
- package/src/components/pages/SequenceEditorMainPage/SequenceEditorMainPage.tsx +76 -0
- package/src/components/pages/SequenceEditorMainPage/index.ts +1 -0
- package/src/components/ui/SequenceEditor/SequenceEditor.tsx +896 -0
- package/src/components/ui/SequenceEditor/SequenceEditorGotoPositionDialog.tsx +108 -0
- package/src/components/ui/SequenceEditor/SequenceEditorStatusBar.tsx +72 -0
- package/src/components/ui/SequenceEditor/index.ts +1 -0
- package/src/components/ui/SequenceEditorPage/SequenceEditorPage.tsx +23 -0
- package/src/components/ui/SequenceEditorPage/index.ts +1 -0
- package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawer.tsx +234 -0
- package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerColorForm.tsx +73 -0
- package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerKeyboardShortcuts.tsx +230 -0
- package/src/components/ui/SequenceEditorPageDrawer/index.ts +1 -0
- package/src/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.tsx +71 -0
- package/src/components/ui/SequenceEditorPageHeader/index.ts +1 -0
- package/src/components/ui/SequenceEditorSearchBar/SequenceEditorSearchBar.tsx +35 -0
- package/src/components/ui/SequenceEditorSearchBar/index.ts +1 -0
- package/src/constants/editor.ts +15 -0
- package/src/constants/index.ts +3 -0
- package/src/constants/keyboard.ts +154 -0
- package/src/constants/palette.ts +227 -0
- package/src/models/editor.ts +6 -0
- package/src/models/index.ts +3 -0
- package/src/models/model.ts +295 -0
- package/src/models/palette.ts +68 -0
- package/src/stores/sequenceEditorStore/index.ts +1 -0
- package/src/stores/sequenceEditorStore/sequenceEditorStore.ts +103 -0
- package/src/utils/EditorUtil/EditorUtil.ts +892 -0
- package/src/utils/EditorUtil/index.ts +1 -0
- package/src/utils/EngineErrorUtil/EngineErrorUtil.ts +25 -0
- package/src/utils/PaletteUtil/PaletteUtil.ts +31 -0
- package/src/utils/PaletteUtil/index.ts +1 -0
- package/tsconfig.build.json +14 -0
- package/tsconfig.json +32 -0
- package/vite.config.ts +177 -0
- package/README.md +0 -3
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { createStore } from 'zustand';
|
|
2
|
+
import {
|
|
3
|
+
createJSONStorage,
|
|
4
|
+
persist,
|
|
5
|
+
} from 'zustand/middleware';
|
|
6
|
+
import type {
|
|
7
|
+
FastaDataStoreActions,
|
|
8
|
+
FastaDataStoreState,
|
|
9
|
+
} from '@rivm-loculus-tools/common-frontend/stores/fastaDataStore';
|
|
10
|
+
import {
|
|
11
|
+
createFastaDataStoreActions,
|
|
12
|
+
createFastaDataStoreInitialState,
|
|
13
|
+
} from '@rivm-loculus-tools/common-frontend/stores/fastaDataStore';
|
|
14
|
+
|
|
15
|
+
import type {
|
|
16
|
+
AminoAcidPalette,
|
|
17
|
+
EditorSelection,
|
|
18
|
+
EngineMeta,
|
|
19
|
+
EngineSearchResult,
|
|
20
|
+
NucleotidePalette,
|
|
21
|
+
} from '../../models';
|
|
22
|
+
import {
|
|
23
|
+
ALI_VIEW_DEFAULT_AMINO_ACID_PALETTE,
|
|
24
|
+
ALI_VIEW_DEFAULT_NUCLEOTIDE_PALETTE,
|
|
25
|
+
} from '../../constants';
|
|
26
|
+
|
|
27
|
+
export type SequenceEditorStore = SequenceEditorStoreActions & SequenceEditorStoreState;
|
|
28
|
+
|
|
29
|
+
export interface SequenceEditorStoreActions extends FastaDataStoreActions {
|
|
30
|
+
setAminoAcidPalette: (palette: AminoAcidPalette) => void;
|
|
31
|
+
setLatestMessage: (message: null | string) => void;
|
|
32
|
+
setMeta: (meta: EngineMeta | null) => void;
|
|
33
|
+
setNucleotidePalette: (palette: NucleotidePalette) => void;
|
|
34
|
+
setSearchQuery: (query: string) => void;
|
|
35
|
+
setSearchResult: (results: EngineSearchResult | null) => void;
|
|
36
|
+
setSearchResultHighlightedIndex: (index: null | number) => void;
|
|
37
|
+
setSelection: (selection: EditorSelection | null) => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface SequenceEditorStoreState extends FastaDataStoreState {
|
|
41
|
+
aminoAcidPalette: AminoAcidPalette;
|
|
42
|
+
latestMessage: null | string;
|
|
43
|
+
meta: EngineMeta | null;
|
|
44
|
+
nucleotidePalette: NucleotidePalette;
|
|
45
|
+
searchQuery: string;
|
|
46
|
+
searchResult: EngineSearchResult | null;
|
|
47
|
+
searchResultHighlightedIndex: null | number;
|
|
48
|
+
selection: EditorSelection | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const createSequenceEditorStoreInitialState = (): SequenceEditorStoreState => ({
|
|
52
|
+
...createFastaDataStoreInitialState(),
|
|
53
|
+
aminoAcidPalette: ALI_VIEW_DEFAULT_AMINO_ACID_PALETTE,
|
|
54
|
+
latestMessage: null,
|
|
55
|
+
meta: null,
|
|
56
|
+
nucleotidePalette: ALI_VIEW_DEFAULT_NUCLEOTIDE_PALETTE,
|
|
57
|
+
searchQuery: '',
|
|
58
|
+
searchResult: null,
|
|
59
|
+
searchResultHighlightedIndex: null,
|
|
60
|
+
selection: null,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const sequenceEditorStore = createStore<SequenceEditorStore>()(
|
|
64
|
+
persist(
|
|
65
|
+
(set, get) => {
|
|
66
|
+
const initialState = createSequenceEditorStoreInitialState();
|
|
67
|
+
const fastaDataStoreActions = createFastaDataStoreActions({ get, set });
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
...initialState,
|
|
71
|
+
...fastaDataStoreActions,
|
|
72
|
+
setAminoAcidPalette: (palette: AminoAcidPalette) => set({ aminoAcidPalette: palette }),
|
|
73
|
+
setLatestMessage: (message: null | string) => set({ latestMessage: message }),
|
|
74
|
+
setMeta: (meta: EngineMeta | null) => set({ meta }),
|
|
75
|
+
setNucleotidePalette: (palette: NucleotidePalette) => set({ nucleotidePalette: palette }),
|
|
76
|
+
setSearchQuery: (query: string) => {
|
|
77
|
+
const { setSearchResult, setSearchResultHighlightedIndex: setSearchResultsHighlightedIndex } = get();
|
|
78
|
+
set({ searchQuery: query });
|
|
79
|
+
if (!query) {
|
|
80
|
+
setSearchResultsHighlightedIndex(null);
|
|
81
|
+
setSearchResult(null);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
setSearchResult: (results: EngineSearchResult | null) => {
|
|
85
|
+
const { setSearchResultHighlightedIndex: setSearchResultsHighlightedIndex } = get();
|
|
86
|
+
set({ searchResult: results });
|
|
87
|
+
setSearchResultsHighlightedIndex(null);
|
|
88
|
+
},
|
|
89
|
+
setSearchResultHighlightedIndex: (index: null | number) => set({ searchResultHighlightedIndex: index }),
|
|
90
|
+
setSelection: (selection: EditorSelection | null) => set({ selection }),
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'LOCULUS-SEQUENCE-EDITOR-Configuration',
|
|
95
|
+
partialize: (state) => ({
|
|
96
|
+
aminoAcidPalette: state.aminoAcidPalette,
|
|
97
|
+
nucleotidePalette: state.nucleotidePalette,
|
|
98
|
+
}),
|
|
99
|
+
storage: createJSONStorage(() => localStorage),
|
|
100
|
+
version: 1,
|
|
101
|
+
},
|
|
102
|
+
),
|
|
103
|
+
);
|