@rivm-loculus-tools/sequence-editor 1.0.1 → 1.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.
Files changed (27) hide show
  1. package/dist/_chunks/SequenceEditor.js +191 -171
  2. package/dist/_chunks/SequenceEditor.js.map +1 -1
  3. package/dist/_chunks/SequenceEditorEventBusService.js.map +1 -1
  4. package/dist/assets/{index-B5Du4hQk.js → index-DsKOK2HN.js} +2 -2
  5. package/dist/assets/index-DsKOK2HN.js.map +1 -0
  6. package/dist/classes/services/EditorWorkerService/EditorWorkerService.d.ts +7 -2
  7. package/dist/classes/services/EditorWorkerService/index.js +26 -1
  8. package/dist/classes/services/EditorWorkerService/index.js.map +1 -1
  9. package/dist/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.d.ts +2 -0
  10. package/dist/classes/workers/EngineWorker/EngineWorker.d.ts +7 -2
  11. package/dist/classes/workers/EngineWorker/index.js +27 -1
  12. package/dist/classes/workers/EngineWorker/index.js.map +1 -1
  13. package/dist/components/ui/SequenceEditorPageHeader/index.js +69 -38
  14. package/dist/components/ui/SequenceEditorPageHeader/index.js.map +1 -1
  15. package/dist/models/config.models.d.ts +2 -0
  16. package/dist/models/editor.models.d.ts +26 -10
  17. package/dist/models/editor.models.js.map +1 -1
  18. package/dist/pages/SequenceEditorMainPage/index.js +18 -39
  19. package/dist/pages/SequenceEditorMainPage/index.js.map +1 -1
  20. package/dist/utils/EditorUtil/EditorUtil.d.ts +4 -2
  21. package/dist/utils/EditorUtil/index.js +81 -28
  22. package/dist/utils/EditorUtil/index.js.map +1 -1
  23. package/dist/utils/SequenceEditorStandardConfigUtil/SequenceEditorStandardConfigUtil.d.ts +2 -1
  24. package/dist/utils/SequenceEditorStandardConfigUtil/index.js +0 -1
  25. package/dist/utils/SequenceEditorStandardConfigUtil/index.js.map +1 -1
  26. package/package.json +3 -3
  27. package/dist/assets/index-B5Du4hQk.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { MoveDirection } from '@rivm-loculus-tools/sequence-editor-wasm';
2
- import { EngineMeta, EngineSearchResult, EngineViewportResult, EngineWorkerApi, ViewportBounds } from '../../../models/editor.models';
2
+ import { EngineMeta, EngineSearchResult, EngineViewportResult, EngineWorkerApi, MoveRowsOptions, ViewportBounds } from '../../../models/editor.models';
3
3
  /**
4
4
  * MSA engine Web Worker.
5
5
  *
@@ -27,9 +27,14 @@ export declare class EngineWorker implements EngineWorkerApi {
27
27
  load(fastaContent: string): Promise<number>;
28
28
  meta(): Promise<EngineMeta>;
29
29
  moveHorizontal(row: number, columns: number[], direction: MoveDirection): Promise<void>;
30
+ moveRows(rows: number[], options: MoveRowsOptions): Promise<void>;
30
31
  moveRowsDown(rows: number[]): Promise<void>;
32
+ moveRowsGrouped(rows: number[], targetRow: number): Promise<void>;
33
+ moveRowsRelative(rows: number[], delta: number): Promise<void>;
34
+ moveRowsToBottom(rows: number[]): Promise<void>;
35
+ moveRowsToTop(rows: number[]): Promise<void>;
31
36
  moveRowsUp(rows: number[]): Promise<void>;
32
- mutate(rows: number[], column: number, base: string): Promise<void>;
37
+ mutate(rows: number[], columns: number[], base: string): Promise<void>;
33
38
  name(row: number): Promise<string>;
34
39
  redo(): Promise<boolean>;
35
40
  search(query: string, checkRecordNames: boolean): Promise<EngineSearchResult>;
@@ -43,14 +43,40 @@ var r = class {
43
43
  async moveHorizontal(e, t, n) {
44
44
  (await this.requireEngine()).move_horizontal(e, this.toRowIndices(t), n);
45
45
  }
46
+ async moveRows(e, t) {
47
+ switch (t.mode) {
48
+ case "bottom":
49
+ await this.moveRowsToBottom(e);
50
+ break;
51
+ case "grouped":
52
+ await this.moveRowsGrouped(e, t.targetRow);
53
+ break;
54
+ case "relative":
55
+ await this.moveRowsRelative(e, t.delta);
56
+ break;
57
+ case "top": await this.moveRowsToTop(e);
58
+ }
59
+ }
46
60
  async moveRowsDown(e) {
47
61
  (await this.requireEngine()).move_rows_down(this.toRowIndices(e));
48
62
  }
63
+ async moveRowsGrouped(e, t) {
64
+ (await this.requireEngine()).move_rows_grouped(this.toRowIndices(e), t);
65
+ }
66
+ async moveRowsRelative(e, t) {
67
+ (await this.requireEngine()).move_rows_relative(this.toRowIndices(e), t);
68
+ }
69
+ async moveRowsToBottom(e) {
70
+ (await this.requireEngine()).move_rows_to_bottom(this.toRowIndices(e));
71
+ }
72
+ async moveRowsToTop(e) {
73
+ (await this.requireEngine()).move_rows_to_top(this.toRowIndices(e));
74
+ }
49
75
  async moveRowsUp(e) {
50
76
  (await this.requireEngine()).move_rows_up(this.toRowIndices(e));
51
77
  }
52
78
  async mutate(e, t, n) {
53
- (await this.requireEngine()).mutate_base_subset(this.toRowIndices(e), t, n.charCodeAt(0));
79
+ (await this.requireEngine()).mutate_base(this.toRowIndices(e), this.toRowIndices(t), n.charCodeAt(0));
54
80
  }
55
81
  async name(e) {
56
82
  return (await this.requireEngine()).get_name(e);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["expose","init","EngineWorker","rows","column","bytes","MsaEngine","fastaContent","engine","row","columns","direction","base","query","checkRecordNames","bounds","readingFrame","value"],"sources":["../../../../src/classes/workers/EngineWorker/EngineWorker.ts"],"sourcesContent":["/// <reference lib=\"webworker\" />\nimport { expose } from 'comlink';\nimport type { MoveDirection } from '@rivm-loculus-tools/sequence-editor-wasm';\nimport init, { MsaEngine } from '@rivm-loculus-tools/sequence-editor-wasm';\n\nimport type {\n EngineMeta,\n EngineSearchResult,\n EngineViewportResult,\n EngineWorkerApi,\n ViewportBounds,\n} from '../../../models/editor.models';\n\n/**\n * MSA engine Web Worker.\n *\n * This worker is the **single owner** of the `MsaEngine` WASM instance and its\n * linear memory for the lifetime of the page. All Rust calls happen here, off\n * the main thread, so FASTA parsing, structural mutations, and undo/redo\n * snapshots never stall the React render loop.\n *\n * The class is exposed to the main thread through comlink, so every public\n * method is proxied as an asynchronous call across the worker boundary.\n */\nexport class EngineWorker implements EngineWorkerApi {\n private engine: MsaEngine | null = null;\n private initialization: null | Promise<void> = null;\n\n public async delete(rows: number[], column: number): Promise<void> {\n const engine = await this.requireEngine();\n engine.delete_at_subset(this.toRowIndices(rows), column);\n }\n\n public async deleteColumn(column: number): Promise<void> {\n const engine = await this.requireEngine();\n engine.delete_column(column);\n }\n\n public async exportGappedFasta(): Promise<string> {\n const engine = await this.requireEngine();\n const bytes = engine.export_gapped_fasta();\n return new TextDecoder().decode(bytes);\n }\n\n public async exportUngappedFasta(): Promise<string> {\n const engine = await this.requireEngine();\n const bytes = engine.export_ungapped_fasta();\n return new TextDecoder().decode(bytes);\n }\n\n /**\n * Idempotently instantiates the WASM module and constructs the engine.\n * Safe to call multiple times; concurrent callers share one initialization.\n */\n public async initialize(): Promise<void> {\n if (this.engine) {\n return;\n }\n if (!this.initialization) {\n this.initialization = (async () => {\n await init(undefined);\n this.engine = new MsaEngine();\n })();\n this.initialization.catch(() => {\n this.initialization = null;\n });\n }\n await this.initialization;\n }\n\n public async insert(rows: number[], column: number): Promise<void> {\n const engine = await this.requireEngine();\n engine.insert_at_subset(this.toRowIndices(rows), column);\n }\n\n public async load(fastaContent: string): Promise<number> {\n const engine = await this.requireEngine();\n return engine.load_fasta(fastaContent);\n }\n\n public async meta(): Promise<EngineMeta> {\n const engine = await this.requireEngine();\n return {\n alignmentWidth: engine.get_alignment_width(),\n redoDepth: engine.redo_depth(),\n sequenceCount: engine.get_sequence_count(),\n undoDepth: engine.undo_depth(),\n };\n }\n\n public async moveHorizontal(row: number, columns: number[], direction: MoveDirection): Promise<void> {\n const engine = await this.requireEngine();\n engine.move_horizontal(row, this.toRowIndices(columns), direction);\n }\n\n public async moveRowsDown(rows: number[]): Promise<void> {\n const engine = await this.requireEngine();\n engine.move_rows_down(this.toRowIndices(rows));\n }\n\n public async moveRowsUp(rows: number[]): Promise<void> {\n const engine = await this.requireEngine();\n engine.move_rows_up(this.toRowIndices(rows));\n }\n\n public async mutate(rows: number[], column: number, base: string): Promise<void> {\n const engine = await this.requireEngine();\n engine.mutate_base_subset(this.toRowIndices(rows), column, base.charCodeAt(0));\n }\n\n public async name(row: number): Promise<string> {\n const engine = await this.requireEngine();\n return engine.get_name(row);\n }\n\n public async redo(): Promise<boolean> {\n const engine = await this.requireEngine();\n return engine.redo();\n }\n\n public async search(query: string, checkRecordNames: boolean): Promise<EngineSearchResult> {\n const engine = await this.requireEngine();\n return engine.search(query, checkRecordNames) as EngineSearchResult;\n }\n\n public async translate(bounds: ViewportBounds, readingFrame: number): Promise<EngineViewportResult> {\n const engine = await this.requireEngine();\n this.validateBounds(bounds);\n const bytes = engine.translate(\n bounds.startRow,\n bounds.endRow,\n bounds.startCol,\n bounds.endCol,\n readingFrame,\n );\n return this.buildViewportResult(bytes, bounds);\n }\n\n public async undo(): Promise<boolean> {\n const engine = await this.requireEngine();\n return engine.undo();\n }\n\n public async viewport(bounds: ViewportBounds): Promise<EngineViewportResult> {\n const engine = await this.requireEngine();\n this.validateBounds(bounds);\n const bytes = engine.update_viewport(\n bounds.startRow,\n bounds.endRow,\n bounds.startCol,\n bounds.endCol,\n );\n return this.buildViewportResult(bytes, bounds);\n }\n\n /** Builds a fixed-stride viewport result from the engine's returned bytes. */\n private buildViewportResult(bytes: Uint8Array, bounds: ViewportBounds): EngineViewportResult {\n const columns = bounds.endCol - bounds.startCol + 1;\n const rows = columns > 0 ? Math.floor(bytes.byteLength / columns) : 0;\n return {\n bytes,\n cols: columns,\n rows,\n startCol: bounds.startCol,\n startRow: bounds.startRow,\n };\n }\n\n /** Returns the initialized engine, initializing it first if necessary. */\n private async requireEngine(): Promise<MsaEngine> {\n await this.initialize();\n if (!this.engine) {\n throw new Error('Engine failed to initialize');\n }\n return this.engine;\n }\n\n /** Converts a plain row-index list into the typed array the WASM API expects. */\n private toRowIndices(rows: number[]): Uint32Array {\n return new Uint32Array(rows);\n }\n\n /** Validates that viewport/translation bounds are safe, non-negative, and ordered. */\n private validateBounds(bounds: ViewportBounds): void {\n const values = [bounds.startRow, bounds.endRow, bounds.startCol, bounds.endCol];\n if (!values.every((value) => Number.isSafeInteger(value) && value >= 0)) {\n throw new Error('Viewport bounds must be non-negative safe integers');\n }\n if (bounds.startRow > bounds.endRow || bounds.startCol > bounds.endCol) {\n throw new Error('Viewport bounds must be ordered (start <= end)');\n }\n }\n}\n\nexpose(new EngineWorker());\n"],"mappings":";;;AAwBA,IAAaE,IAAb,MAAqD;CACnD,SAAmC;CACnC,iBAA+C;CAE/C,MAAa,OAAO,GAAgB,GAA+B;EAEjE,CAAA,MADqB,KAAK,cAAc,EAAA,CACjC,iBAAiB,KAAK,aAAaC,CAAI,GAAGC,CAAM;CACzD;CAEA,MAAa,aAAa,GAA+B;EAEvD,CAAA,MADqB,KAAK,cAAc,EAAA,CACjC,cAAcA,CAAM;CAC7B;CAEA,MAAa,oBAAqC;EAEhD,IAAMC,KAAQ,MADO,KAAK,cAAc,EAAA,CACnB,oBAAoB;EACzC,OAAO,IAAI,YAAY,CAAC,CAAC,OAAOA,CAAK;CACvC;CAEA,MAAa,sBAAuC;EAElD,IAAMA,KAAQ,MADO,KAAK,cAAc,EAAA,CACnB,sBAAsB;EAC3C,OAAO,IAAI,YAAY,CAAC,CAAC,OAAOA,CAAK;CACvC;CAMA,MAAa,aAA4B;EACvC,AAAI,KAAK,WAGJ,KAAK,mBACR,KAAK,kBAAkB,YAAY;GAEjC,AADA,MAAMJ,EAAK,KAAA,CAAS,GACpB,KAAK,SAAS,IAAIK,EAAU;EAC9B,EAAA,CAAG,GACH,KAAK,eAAe,YAAY;GAC9B,KAAK,iBAAiB;EACxB,CAAC,IAEH,MAAM,KAAK;CACb;CAEA,MAAa,OAAO,GAAgB,GAA+B;EAEjE,CAAA,MADqB,KAAK,cAAc,EAAA,CACjC,iBAAiB,KAAK,aAAaH,CAAI,GAAGC,CAAM;CACzD;CAEA,MAAa,KAAK,GAAuC;EAEvD,QAAO,MADc,KAAK,cAAc,EAAA,CAC1B,WAAWG,CAAY;CACvC;CAEA,MAAa,OAA4B;EACvC,IAA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CACrB;CAEA,MAAa,SAAS,GAAuD;EAC3E,IAAMP,IAAS,MAAM,KAAK,cAAc;EACxC,KAAK,eAAeO,CAAM;EAC1B,IAAMV,IAAQG,EAAO,gBACnBO,EAAO,UACPA,EAAO,QACPA,EAAO,UACPA,EAAO,MACT;EACA,OAAO,KAAK,oBAAoBV,GAAOU,CAAM;CAC/C;CAGA,oBAA4B,GAAmB,GAA8C;EAC3F,IAAML,IAAUK,EAAO,SAASA,EAAO,WAAW;EAElD,OAAO;GACL;GACA,MAAML;GACN,MAJWA,IAAU,IAAI,KAAK,MAAML,EAAM,aAAaK,CAAO,IAAI;GAKlE,UAAUK,EAAO;GACjB,UAAUA,EAAO;EACnB;CACF;CAGA,MAAc,gBAAoC;EAEhD,IADA,MAAM,KAAK,WAAW,GAClB,CAAC,KAAK,QACR,MAAU,MAAM,6BAA6B;EAE/C,OAAO,KAAK;CACd;CAGA,aAAqB,GAA6B;EAChD,OAAO,IAAI,YAAYZ,CAAI;CAC7B;CAGA,eAAuB,GAA8B;EAEnD,IAAI,CAAC;GADWY,EAAO;GAAUA,EAAO;GAAQA,EAAO;GAAUA,EAAO;EACnE,CAAA,CAAO,OAAO,MAAU,OAAO,cAAcE,CAAK,KAAKA,KAAS,CAAC,GACpE,MAAU,MAAM,oDAAoD;EAEtE,IAAIF,EAAO,WAAWA,EAAO,UAAUA,EAAO,WAAWA,EAAO,QAC9D,MAAU,MAAM,gDAAgD;CAEpE;AACF;AAEAf,EAAO,IAAIE,EAAa,CAAC"}
1
+ {"version":3,"file":"index.js","names":["expose","init","EngineWorker","rows","column","bytes","MsaEngine","fastaContent","engine","row","columns","direction","options","targetRow","delta","base","query","checkRecordNames","bounds","readingFrame","value"],"sources":["../../../../src/classes/workers/EngineWorker/EngineWorker.ts"],"sourcesContent":["/// <reference lib=\"webworker\" />\nimport { expose } from 'comlink';\nimport type { MoveDirection } from '@rivm-loculus-tools/sequence-editor-wasm';\nimport init, { MsaEngine } from '@rivm-loculus-tools/sequence-editor-wasm';\n\nimport type {\n EngineMeta,\n EngineSearchResult,\n EngineViewportResult,\n EngineWorkerApi,\n MoveRowsOptions,\n ViewportBounds,\n} from '../../../models/editor.models';\n\n/**\n * MSA engine Web Worker.\n *\n * This worker is the **single owner** of the `MsaEngine` WASM instance and its\n * linear memory for the lifetime of the page. All Rust calls happen here, off\n * the main thread, so FASTA parsing, structural mutations, and undo/redo\n * snapshots never stall the React render loop.\n *\n * The class is exposed to the main thread through comlink, so every public\n * method is proxied as an asynchronous call across the worker boundary.\n */\nexport class EngineWorker implements EngineWorkerApi {\n private engine: MsaEngine | null = null;\n private initialization: null | Promise<void> = null;\n\n public async delete(rows: number[], column: number): Promise<void> {\n const engine = await this.requireEngine();\n engine.delete_at_subset(this.toRowIndices(rows), column);\n }\n\n public async deleteColumn(column: number): Promise<void> {\n const engine = await this.requireEngine();\n engine.delete_column(column);\n }\n\n public async exportGappedFasta(): Promise<string> {\n const engine = await this.requireEngine();\n const bytes = engine.export_gapped_fasta();\n return new TextDecoder().decode(bytes);\n }\n\n public async exportUngappedFasta(): Promise<string> {\n const engine = await this.requireEngine();\n const bytes = engine.export_ungapped_fasta();\n return new TextDecoder().decode(bytes);\n }\n\n /**\n * Idempotently instantiates the WASM module and constructs the engine.\n * Safe to call multiple times; concurrent callers share one initialization.\n */\n public async initialize(): Promise<void> {\n if (this.engine) {\n return;\n }\n if (!this.initialization) {\n this.initialization = (async () => {\n await init(undefined);\n this.engine = new MsaEngine();\n })();\n this.initialization.catch(() => {\n this.initialization = null;\n });\n }\n await this.initialization;\n }\n\n public async insert(rows: number[], column: number): Promise<void> {\n const engine = await this.requireEngine();\n engine.insert_at_subset(this.toRowIndices(rows), column);\n }\n\n public async load(fastaContent: string): Promise<number> {\n const engine = await this.requireEngine();\n return engine.load_fasta(fastaContent);\n }\n\n public async meta(): Promise<EngineMeta> {\n const engine = await this.requireEngine();\n return {\n alignmentWidth: engine.get_alignment_width(),\n redoDepth: engine.redo_depth(),\n sequenceCount: engine.get_sequence_count(),\n undoDepth: engine.undo_depth(),\n };\n }\n\n public async moveHorizontal(row: number, columns: number[], direction: MoveDirection): Promise<void> {\n const engine = await this.requireEngine();\n engine.move_horizontal(row, this.toRowIndices(columns), direction);\n }\n\n public async moveRows(rows: number[], options: MoveRowsOptions): Promise<void> {\n switch (options.mode) {\n case 'bottom': {\n await this.moveRowsToBottom(rows);\n break;\n }\n case 'grouped': {\n await this.moveRowsGrouped(rows, options.targetRow);\n break;\n }\n case 'relative': {\n await this.moveRowsRelative(rows, options.delta);\n break;\n }\n case 'top': {\n await this.moveRowsToTop(rows);\n break;\n }\n default: {\n break;\n }\n }\n }\n\n public async moveRowsDown(rows: number[]): Promise<void> {\n const engine = await this.requireEngine();\n engine.move_rows_down(this.toRowIndices(rows));\n }\n\n public async moveRowsGrouped(rows: number[], targetRow: number): Promise<void> {\n const engine = await this.requireEngine();\n engine.move_rows_grouped(this.toRowIndices(rows), targetRow);\n }\n\n public async moveRowsRelative(rows: number[], delta: number): Promise<void> {\n const engine = await this.requireEngine();\n engine.move_rows_relative(this.toRowIndices(rows), delta);\n }\n\n public async moveRowsToBottom(rows: number[]): Promise<void> {\n const engine = await this.requireEngine();\n engine.move_rows_to_bottom(this.toRowIndices(rows));\n }\n\n public async moveRowsToTop(rows: number[]): Promise<void> {\n const engine = await this.requireEngine();\n engine.move_rows_to_top(this.toRowIndices(rows));\n }\n\n public async moveRowsUp(rows: number[]): Promise<void> {\n const engine = await this.requireEngine();\n engine.move_rows_up(this.toRowIndices(rows));\n }\n\n public async mutate(rows: number[], columns: number[], base: string): Promise<void> {\n const engine = await this.requireEngine();\n engine.mutate_base(this.toRowIndices(rows), this.toRowIndices(columns), base.charCodeAt(0));\n }\n\n public async name(row: number): Promise<string> {\n const engine = await this.requireEngine();\n return engine.get_name(row);\n }\n\n public async redo(): Promise<boolean> {\n const engine = await this.requireEngine();\n return engine.redo();\n }\n\n public async search(query: string, checkRecordNames: boolean): Promise<EngineSearchResult> {\n const engine = await this.requireEngine();\n return engine.search(query, checkRecordNames) as EngineSearchResult;\n }\n\n public async translate(bounds: ViewportBounds, readingFrame: number): Promise<EngineViewportResult> {\n const engine = await this.requireEngine();\n this.validateBounds(bounds);\n const bytes = engine.translate(\n bounds.startRow,\n bounds.endRow,\n bounds.startCol,\n bounds.endCol,\n readingFrame,\n );\n return this.buildViewportResult(bytes, bounds);\n }\n\n public async undo(): Promise<boolean> {\n const engine = await this.requireEngine();\n return engine.undo();\n }\n\n public async viewport(bounds: ViewportBounds): Promise<EngineViewportResult> {\n const engine = await this.requireEngine();\n this.validateBounds(bounds);\n const bytes = engine.update_viewport(\n bounds.startRow,\n bounds.endRow,\n bounds.startCol,\n bounds.endCol,\n );\n return this.buildViewportResult(bytes, bounds);\n }\n\n /** Builds a fixed-stride viewport result from the engine's returned bytes. */\n private buildViewportResult(bytes: Uint8Array, bounds: ViewportBounds): EngineViewportResult {\n const columns = bounds.endCol - bounds.startCol + 1;\n const rows = columns > 0 ? Math.floor(bytes.byteLength / columns) : 0;\n return {\n bytes,\n cols: columns,\n rows,\n startCol: bounds.startCol,\n startRow: bounds.startRow,\n };\n }\n\n /** Returns the initialized engine, initializing it first if necessary. */\n private async requireEngine(): Promise<MsaEngine> {\n await this.initialize();\n if (!this.engine) {\n throw new Error('Engine failed to initialize');\n }\n return this.engine;\n }\n\n /** Converts a plain row-index list into the typed array the WASM API expects. */\n private toRowIndices(rows: number[]): Uint32Array {\n return new Uint32Array(rows);\n }\n\n /** Validates that viewport/translation bounds are safe, non-negative, and ordered. */\n private validateBounds(bounds: ViewportBounds): void {\n const values = [bounds.startRow, bounds.endRow, bounds.startCol, bounds.endCol];\n if (!values.every((value) => Number.isSafeInteger(value) && value >= 0)) {\n throw new Error('Viewport bounds must be non-negative safe integers');\n }\n if (bounds.startRow > bounds.endRow || bounds.startCol > bounds.endCol) {\n throw new Error('Viewport bounds must be ordered (start <= end)');\n }\n }\n}\n\nexpose(new EngineWorker());\n"],"mappings":";;;AAyB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AAO;GAAUA,EAAO;GAAQA,EAAO;GAAUA,EAAO;EACnE,CAAA,CAAO,OAAO,MAAU,OAAO,cAAcE,CAAK,KAAKA,KAAS,CAAC,GACpE,MAAU,MAAM,oDAAoD;EAEtE,IAAIF,EAAO,WAAWA,EAAO,UAAUA,EAAO,WAAWA,EAAO,QAC9D,MAAU,MAAM,gDAAgD;CAEpE;AACF;AAEAlB,EAAO,IAAIE,EAAa,CAAC"}
@@ -1,61 +1,92 @@
1
1
  import { t as e } from "../../../_chunks/sequenceEditorStore.js";
2
2
  import { t } from "../../../_chunks/react.js";
3
3
  import { t as n } from "../../../_chunks/SequenceEditorEventBusService.js";
4
- import { useCallback as r } from "react";
5
- import { IconButton as i, Tooltip as a } from "@mui/material";
6
- import { container as o } from "tsyringe";
7
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
8
- import { FastaPageHeaderCenterComponent as u } from "@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderCenterComponent";
9
- import { FastaPageHeaderImportButton as d } from "@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderImportButton";
10
- import { FastaPageHeaderResetButton as f } from "@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderResetButton";
11
- import { PageCommonHeader as p } from "@rivm-loculus-tools/common-frontend/components/ui/PageCommonHeader";
12
- import m from "@mui/icons-material/BiotechOutlined";
13
- import h from "@mui/icons-material/Undo";
14
- import g from "@mui/icons-material/Redo";
15
- import { PageHeaderDocumentationButton as _ } from "@rivm-loculus-tools/common-frontend/components/ui/PageHeaderDocumentationButton";
4
+ import { useCallback as r, useMemo as i } from "react";
5
+ import { IconButton as a, Tooltip as o } from "@mui/material";
6
+ import { container as s } from "tsyringe";
7
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
8
+ import { FastaPageHeaderCenterComponent as d } from "@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderCenterComponent";
9
+ import { FastaPageHeaderImportButton as f } from "@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderImportButton";
10
+ import { FastaPageHeaderResetButton as p } from "@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderResetButton";
11
+ import { PageCommonHeader as m } from "@rivm-loculus-tools/common-frontend/components/ui/PageCommonHeader";
12
+ import h from "@mui/icons-material/Code";
13
+ import g from "@mui/icons-material/Publish";
14
+ import _ from "@mui/icons-material/Undo";
15
+ import v from "@mui/icons-material/Redo";
16
+ import { ButtonWithMenu as y } from "@rivm-loculus-tools/common-frontend/components/ui/ButtonWithMenu";
17
+ import b from "@mui/icons-material/FileDownloadOutlined";
16
18
  //#region src/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.tsx
17
- var v = () => {
18
- let v = t(e, (e) => e.resetDataset), y = t(e, (e) => e.meta), b = r(() => {
19
- v();
20
- }, [v]), x = r(() => {
21
- o.resolve(n).emit("onUndo");
22
- }, []), S = r(() => {
23
- o.resolve(n).emit("onRedo");
24
- }, []);
25
- return /* @__PURE__ */ c(p, {
26
- centerComponent: /* @__PURE__ */ c(u, { store: e }),
27
- icon: /* @__PURE__ */ c(m, { sx: { fontSize: 24 } }),
28
- rightComponent: /* @__PURE__ */ l(s, { children: [
29
- /* @__PURE__ */ c(d, {}),
30
- /* @__PURE__ */ c(a, {
19
+ var x = () => {
20
+ let x = t(e, (e) => e.resetDataset), S = t(e, (e) => e.meta), C = r(() => {
21
+ x();
22
+ }, [x]), w = r(() => {
23
+ s.resolve(n).emit("onUndo");
24
+ }, []), T = r(() => {
25
+ s.resolve(n).emit("onRedo");
26
+ }, []), E = r(() => {
27
+ s.resolve(n).emit("onExportUngappedFasta");
28
+ }, []), D = r(() => {
29
+ s.resolve(n).emit("onExportGappedFasta");
30
+ }, []), O = r(() => {
31
+ alert("Not implemented");
32
+ }, []), k = i(() => [
33
+ {
34
+ icon: /* @__PURE__ */ l(g, { fontSize: "small" }),
35
+ label: "Export to loculus",
36
+ onClick: O
37
+ },
38
+ {
39
+ icon: /* @__PURE__ */ l(h, { fontSize: "small" }),
40
+ label: "Save as Ungapped Fasta (.fasta)",
41
+ onClick: E
42
+ },
43
+ {
44
+ icon: /* @__PURE__ */ l(h, { fontSize: "small" }),
45
+ label: "Save as Gapped Fasta (.fasta)",
46
+ onClick: D
47
+ }
48
+ ], [
49
+ E,
50
+ D,
51
+ O
52
+ ]);
53
+ return /* @__PURE__ */ l(m, {
54
+ centerComponent: /* @__PURE__ */ l(d, { store: e }),
55
+ rightComponent: /* @__PURE__ */ u(c, { children: [
56
+ /* @__PURE__ */ l(o, {
31
57
  title: "Undo last action",
32
- children: /* @__PURE__ */ c(i, {
58
+ children: /* @__PURE__ */ l(a, {
33
59
  color: "inherit",
34
- disabled: y?.undoDepth === 0,
35
- onClick: x,
60
+ disabled: S?.undoDepth === 0,
61
+ onClick: w,
36
62
  size: "small",
37
63
  sx: { opacity: .85 },
38
- children: /* @__PURE__ */ c(h, { fontSize: "small" })
64
+ children: /* @__PURE__ */ l(_, { fontSize: "small" })
39
65
  })
40
66
  }),
41
- /* @__PURE__ */ c(a, {
67
+ /* @__PURE__ */ l(o, {
42
68
  title: "Redo last action",
43
- children: /* @__PURE__ */ c(i, {
69
+ children: /* @__PURE__ */ l(a, {
44
70
  color: "inherit",
45
- disabled: y?.redoDepth === 0,
46
- onClick: S,
71
+ disabled: S?.redoDepth === 0,
72
+ onClick: T,
47
73
  size: "small",
48
74
  sx: { opacity: .85 },
49
- children: /* @__PURE__ */ c(g, { fontSize: "small" })
75
+ children: /* @__PURE__ */ l(v, { fontSize: "small" })
50
76
  })
51
77
  }),
52
- /* @__PURE__ */ c(f, { onReset: b }),
53
- /* @__PURE__ */ c(_, {})
78
+ /* @__PURE__ */ l(p, { onReset: C }),
79
+ /* @__PURE__ */ l(f, {}),
80
+ /* @__PURE__ */ l(y, {
81
+ items: k,
82
+ label: "Export",
83
+ startIcon: /* @__PURE__ */ l(b, {})
84
+ })
54
85
  ] }),
55
86
  title: "Sequence Editor"
56
87
  });
57
88
  };
58
89
  //#endregion
59
- export { v as SequenceEditorPageHeader };
90
+ export { x as SequenceEditorPageHeader };
60
91
 
61
92
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_Fragment","sequenceEditorStore","SequenceEditorEventBusService","BiotechOutlinedIcon","UndoIcon","RedoIcon","SequenceEditorPageHeader","resetDataset","useStore","state","meta","onReset","useCallback","onUndoButtonClick","onRedoButtonClick","PageCommonHeader","FastaPageHeaderCenterComponent","Fragment","FastaPageHeaderImportButton","Tooltip","IconButton","FastaPageHeaderResetButton","PageHeaderDocumentationButton"],"sources":["../../../../src/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport { FastaPageHeaderCenterComponent } from '@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderCenterComponent';\nimport { FastaPageHeaderImportButton } from '@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderImportButton';\nimport { FastaPageHeaderResetButton } from '@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderResetButton';\nimport { PageCommonHeader } from '@rivm-loculus-tools/common-frontend/components/ui/PageCommonHeader';\nimport { useCallback } from 'react';\nimport { useStore } from 'zustand';\nimport BiotechOutlinedIcon from '@mui/icons-material/BiotechOutlined';\nimport UndoIcon from '@mui/icons-material/Undo';\nimport RedoIcon from '@mui/icons-material/Redo';\nimport {\n IconButton,\n Tooltip,\n} from '@mui/material';\nimport { PageHeaderDocumentationButton } from '@rivm-loculus-tools/common-frontend/components/ui/PageHeaderDocumentationButton';\n\nimport { sequenceEditorStore } from '../../../stores/sequenceEditorStore';\nimport { SequenceEditorEventBusService } from '../../../classes/services/SequenceEditorEventBusService';\n\nexport const SequenceEditorPageHeader = () => {\n const resetDataset = useStore(sequenceEditorStore, (state) => state.resetDataset);\n const meta = useStore(sequenceEditorStore, (state) => state.meta);\n\n const onReset = useCallback(() => {\n resetDataset();\n }, [resetDataset]);\n\n const onUndoButtonClick = useCallback(() => {\n container.resolve(SequenceEditorEventBusService).emit('onUndo');\n }, []);\n\n const onRedoButtonClick = useCallback(() => {\n container.resolve(SequenceEditorEventBusService).emit('onRedo');\n }, []);\n\n return (\n <PageCommonHeader\n centerComponent={<FastaPageHeaderCenterComponent store={sequenceEditorStore} />}\n icon={<BiotechOutlinedIcon sx={{ fontSize: 24 }} />}\n rightComponent={(\n <>\n <FastaPageHeaderImportButton />\n <Tooltip title={'Undo last action'}>\n <IconButton\n color={'inherit'}\n disabled={meta?.undoDepth === 0}\n onClick={onUndoButtonClick}\n size={'small'}\n sx={{ opacity: 0.85 }}\n >\n <UndoIcon fontSize={'small'} />\n </IconButton>\n </Tooltip>\n <Tooltip title={'Redo last action'}>\n <IconButton\n color={'inherit'}\n disabled={meta?.redoDepth === 0}\n onClick={onRedoButtonClick}\n size={'small'}\n sx={{ opacity: 0.85 }}\n >\n <RedoIcon fontSize={'small'} />\n </IconButton>\n </Tooltip>\n <FastaPageHeaderResetButton onReset={onReset} />\n <PageHeaderDocumentationButton />\n </>\n )}\n title={'Sequence Editor'}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAaM,UAAiC;CAC5C,IAAMC,IAAeC,EAASP,IAAsB,MAAUQ,EAAM,YAAY,GAC1EC,IAAOF,EAASP,IAAsB,MAAUQ,EAAM,IAAI,GAE1DE,IAAUC,QAAkB;EAChC,EAAa;CACf,GAAG,CAACL,CAAY,CAAC,GAEXM,IAAoBD,QAAkB;EAC1C,EAAU,QAAQV,CAA6B,CAAC,CAAC,KAAK,QAAQ;CAChE,GAAG,CAAC,CAAC,GAECY,IAAoBF,QAAkB;EAC1C,EAAU,QAAQV,CAA6B,CAAC,CAAC,KAAK,QAAQ;CAChE,GAAG,CAAC,CAAC;CAEL,OACE,kBAACa,GAAD;EACE,iBAAiB,kBAACC,GAAD,EAAgC,OAAOf,EAAsB,CAAA;EAC9E,MAAM,kBAACE,GAAD,EAAqB,IAAI,EAAE,UAAU,GAAG,EAAI,CAAA;EAClD,gBACE,kBAAAH,GAAA,EAAA,UAAA;GACE,kBAACkB,GAAD,CAA8B,CAAA;GAC9B,kBAACC,GAAD;IAAS,OAAO;IACd,UAAA,kBAACC,GAAD;KACE,OAAO;KACP,UAAUV,GAAM,cAAc;KAC9B,SAASG;KACT,MAAM;KACN,IAAI,EAAE,SAAS,IAAK;KAEpB,UAAA,kBAACT,GAAD,EAAU,UAAU,QAAU,CAAA;IACpB,CAAA;GACL,CAAA;GACT,kBAACe,GAAD;IAAS,OAAO;IACd,UAAA,kBAACC,GAAD;KACE,OAAO;KACP,UAAUV,GAAM,cAAc;KAC9B,SAASI;KACT,MAAM;KACN,IAAI,EAAE,SAAS,IAAK;KAEpB,UAAA,kBAACT,GAAD,EAAU,UAAU,QAAU,CAAA;IACpB,CAAA;GACL,CAAA;GACT,kBAACgB,GAAD,EAAqC,WAAU,CAAA;GAC/C,kBAACC,GAAD,CAAgC,CAAA;EAChC,EAAA,CAAA;EAEJ,OAAO;CACR,CAAA;AAEL"}
1
+ {"version":3,"file":"index.js","names":["_Fragment","sequenceEditorStore","SequenceEditorEventBusService","CodeIcon","PublishIcon","UndoIcon","RedoIcon","FileDownloadOutlinedIcon","SequenceEditorPageHeader","resetDataset","useStore","state","meta","onReset","useCallback","onUndoButtonClick","onRedoButtonClick","onClickExportFasta","onClickExportGappedFasta","onClickUploadToLoculus","exportExportMenuItems","useMemo","PageCommonHeader","FastaPageHeaderCenterComponent","Fragment","Tooltip","IconButton","FastaPageHeaderResetButton","FastaPageHeaderImportButton","ButtonWithMenu"],"sources":["../../../../src/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport { FastaPageHeaderCenterComponent } from '@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderCenterComponent';\nimport { FastaPageHeaderImportButton } from '@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderImportButton';\nimport { FastaPageHeaderResetButton } from '@rivm-loculus-tools/common-frontend/components/fasta/FastaPageHeaderResetButton';\nimport { PageCommonHeader } from '@rivm-loculus-tools/common-frontend/components/ui/PageCommonHeader';\nimport {\n useCallback,\n useMemo,\n} from 'react';\nimport CodeIcon from '@mui/icons-material/Code';\nimport PublishIcon from '@mui/icons-material/Publish';\nimport { useStore } from 'zustand';\nimport UndoIcon from '@mui/icons-material/Undo';\nimport RedoIcon from '@mui/icons-material/Redo';\nimport {\n IconButton,\n Tooltip,\n} from '@mui/material';\nimport { ButtonWithMenu } from '@rivm-loculus-tools/common-frontend/components/ui/ButtonWithMenu';\nimport type { ButtonWithMenuProps } from '@rivm-loculus-tools/common-frontend/components/ui/ButtonWithMenu';\nimport FileDownloadOutlinedIcon from '@mui/icons-material/FileDownloadOutlined';\n\nimport { sequenceEditorStore } from '../../../stores/sequenceEditorStore';\nimport { SequenceEditorEventBusService } from '../../../classes/services/SequenceEditorEventBusService';\n\nexport const SequenceEditorPageHeader = () => {\n const resetDataset = useStore(sequenceEditorStore, (state) => state.resetDataset);\n const meta = useStore(sequenceEditorStore, (state) => state.meta);\n\n const onReset = useCallback(() => {\n resetDataset();\n }, [resetDataset]);\n\n const onUndoButtonClick = useCallback(() => {\n container.resolve(SequenceEditorEventBusService).emit('onUndo');\n }, []);\n\n const onRedoButtonClick = useCallback(() => {\n container.resolve(SequenceEditorEventBusService).emit('onRedo');\n }, []);\n\n const onClickExportFasta = useCallback(() => {\n container.resolve(SequenceEditorEventBusService).emit('onExportUngappedFasta');\n }, []);\n\n const onClickExportGappedFasta = useCallback(() => {\n container.resolve(SequenceEditorEventBusService).emit('onExportGappedFasta');\n }, []);\n\n const onClickUploadToLoculus = useCallback(() => {\n alert('Not implemented');\n }, []);\n\n const exportExportMenuItems: ButtonWithMenuProps['items'] = useMemo(() => [\n {\n icon: <PublishIcon fontSize={'small'} />,\n label: 'Export to loculus',\n onClick: onClickUploadToLoculus,\n },\n {\n icon: <CodeIcon fontSize={'small'} />,\n label: 'Save as Ungapped Fasta (.fasta)',\n onClick: onClickExportFasta,\n },\n {\n icon: <CodeIcon fontSize={'small'} />,\n label: 'Save as Gapped Fasta (.fasta)',\n onClick: onClickExportGappedFasta,\n },\n ], [onClickExportFasta, onClickExportGappedFasta, onClickUploadToLoculus]);\n\n return (\n <PageCommonHeader\n centerComponent={<FastaPageHeaderCenterComponent store={sequenceEditorStore} />}\n rightComponent={(\n <>\n <Tooltip title={'Undo last action'}>\n <IconButton\n color={'inherit'}\n disabled={meta?.undoDepth === 0}\n onClick={onUndoButtonClick}\n size={'small'}\n sx={{ opacity: 0.85 }}\n >\n <UndoIcon fontSize={'small'} />\n </IconButton>\n </Tooltip>\n <Tooltip title={'Redo last action'}>\n <IconButton\n color={'inherit'}\n disabled={meta?.redoDepth === 0}\n onClick={onRedoButtonClick}\n size={'small'}\n sx={{ opacity: 0.85 }}\n >\n <RedoIcon fontSize={'small'} />\n </IconButton>\n </Tooltip>\n <FastaPageHeaderResetButton onReset={onReset} />\n <FastaPageHeaderImportButton />\n <ButtonWithMenu\n items={exportExportMenuItems}\n label={'Export'}\n startIcon={<FileDownloadOutlinedIcon />}\n />\n </>\n )}\n title={'Sequence Editor'}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,IAAaQ,UAAiC;CAC5C,IAAMC,IAAeC,EAAST,IAAsB,MAAUU,EAAM,YAAY,GAC1EC,IAAOF,EAAST,IAAsB,MAAUU,EAAM,IAAI,GAE1DE,IAAUC,QAAkB;EAChC,EAAa;CACf,GAAG,CAACL,CAAY,CAAC,GAEXM,IAAoBD,QAAkB;EAC1C,EAAU,QAAQZ,CAA6B,CAAC,CAAC,KAAK,QAAQ;CAChE,GAAG,CAAC,CAAC,GAECc,IAAoBF,QAAkB;EAC1C,EAAU,QAAQZ,CAA6B,CAAC,CAAC,KAAK,QAAQ;CAChE,GAAG,CAAC,CAAC,GAECe,IAAqBH,QAAkB;EAC3C,EAAU,QAAQZ,CAA6B,CAAC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CAAA;GACvC,CAAA;EACD,EAAA,CAAA;EAEJ,OAAO;CACR,CAAA;AAEL"}
@@ -1,3 +1,5 @@
1
+ import { DialogAction } from '@gen-epix/ui-core-components/components/Dialog';
1
2
  import { ConfigBase } from '@rivm-loculus-tools/common-frontend/models/config.models';
2
3
  export interface SequenceEditorConfig extends ConfigBase {
4
+ fastaImportExtraActions?: DialogAction[];
3
5
  }
@@ -132,9 +132,14 @@ export interface EngineWorkerApi {
132
132
  load: (fastaContent: string) => Promise<number>;
133
133
  meta: () => Promise<EngineMeta>;
134
134
  moveHorizontal: (row: number, columns: number[], direction: MoveDirection) => Promise<void>;
135
+ moveRows: (rows: number[], options: MoveRowsOptions) => Promise<void>;
135
136
  moveRowsDown: (rows: number[]) => Promise<void>;
137
+ moveRowsGrouped: (rows: number[], targetRow: number) => Promise<void>;
138
+ moveRowsRelative: (rows: number[], delta: number) => Promise<void>;
139
+ moveRowsToBottom: (rows: number[]) => Promise<void>;
140
+ moveRowsToTop: (rows: number[]) => Promise<void>;
136
141
  moveRowsUp: (rows: number[]) => Promise<void>;
137
- mutate: (rows: number[], column: number, base: string) => Promise<void>;
142
+ mutate: (rows: number[], columns: number[], base: string) => Promise<void>;
138
143
  name: (row: number) => Promise<string>;
139
144
  redo: () => Promise<boolean>;
140
145
  search: (query: string, checkRecordNames: boolean) => Promise<EngineSearchResult>;
@@ -142,6 +147,15 @@ export interface EngineWorkerApi {
142
147
  undo: () => Promise<boolean>;
143
148
  viewport: (bounds: ViewportBounds) => Promise<EngineViewportResult>;
144
149
  }
150
+ export type GridGeometry = {
151
+ cellHeight: number;
152
+ cellWidth: number;
153
+ dividerWidth: number;
154
+ labelWidth: number;
155
+ numOverscanCols: number;
156
+ numOverscanRows: number;
157
+ rulerHeight: number;
158
+ };
145
159
  /**
146
160
  * Wire protocol between the main thread and the MSA Web Worker.
147
161
  *
@@ -160,15 +174,6 @@ export interface EngineWorkerApi {
160
174
  * - **No JSON for hot paths.** Only small plain objects are structured-cloned;
161
175
  * binary data is always transferred via the shared SAB.
162
176
  */
163
- export type GridGeometry = {
164
- cellHeight: number;
165
- cellWidth: number;
166
- dividerWidth: number;
167
- labelWidth: number;
168
- numOverscanCols: number;
169
- numOverscanRows: number;
170
- rulerHeight: number;
171
- };
172
177
  export type GridPoint = {
173
178
  col: number;
174
179
  row: number;
@@ -194,6 +199,17 @@ export type Meta = {
194
199
  undoDepth: number;
195
200
  width: number;
196
201
  };
202
+ export type MoveRowsOptions = {
203
+ delta: number;
204
+ mode: 'relative';
205
+ } | {
206
+ mode: 'bottom';
207
+ } | {
208
+ mode: 'grouped';
209
+ targetRow: number;
210
+ } | {
211
+ mode: 'top';
212
+ };
197
213
  /**The following types match the Rust `search_algorithms::Match` and search_algorithms::SearchResult structures. */
198
214
  export type SearchMatch = {
199
215
  col: number;
@@ -1 +1 @@
1
- {"version":3,"file":"editor.models.js","names":["EDITOR_DIRECTION","\"DOWN\"","\"LEFT\"","\"RIGHT\"","\"UP\"","EDITOR_PATH_PROPERTIES_TYPE","\"CELL\"","\"DIVIDER\"","\"LABEL\"","\"RULER\"","MATRIX_TYPE","\"AMINO_ACID\"","\"NUCLEOTIDE\"","\"RECORD_NAME\""],"sources":["../../src/models/editor.models.ts"],"sourcesContent":["import type { MoveDirection } from '@rivm-loculus-tools/sequence-editor-wasm';\n\nexport enum EDITOR_DIRECTION {\n DOWN = 'DOWN',\n LEFT = 'LEFT',\n RIGHT = 'RIGHT',\n UP = 'UP',\n}\n\nexport enum EDITOR_PATH_PROPERTIES_TYPE {\n CELL = 'CELL',\n DIVIDER = 'DIVIDER',\n LABEL = 'LABEL',\n RULER = 'RULER',\n}\n\n\nexport enum MATRIX_TYPE {\n AMINO_ACID = 'amino_acid',\n NUCLEOTIDE = 'nucleotide',\n RECORD_NAME = 'record_name',\n}\n\nexport type EditorAssembly = {\n cells: EditorAssemblyCells;\n divider: EditorAssemblyDivider;\n labels: EditorAssemblyLabels;\n ruler: EditorAssemblyRuler;\n};\n\nexport type EditorAssemblyCells = {\n pathPropertiesMap: Map<Path2D, EditorPathProperties>;\n};\n\nexport type EditorAssemblyDivider = {\n pathPropertiesMap: Map<Path2D, EditorPathProperties>;\n};\n\nexport type EditorAssemblyLabels = {\n pathPropertiesMap: Map<Path2D, EditorPathProperties>;\n};\n\nexport type EditorAssemblyRuler = {\n pathPropertiesMap: Map<Path2D, EditorPathProperties>;\n};\n\nexport type EditorPathProperties = {\n col: number;\n row: number;\n type: EDITOR_PATH_PROPERTIES_TYPE.CELL;\n} | {\n col: number;\n type: EDITOR_PATH_PROPERTIES_TYPE.RULER;\n} | {\n row: number;\n type: EDITOR_PATH_PROPERTIES_TYPE.LABEL;\n} | {\n type: EDITOR_PATH_PROPERTIES_TYPE.DIVIDER;\n};\n\nexport type EditorSelection = {\n cells?: { // when a rectangular block of cells is selected\n endCol: number;\n endRow: number;\n startCol: number;\n startRow: number;\n };\n cols?: number[]; // when entire columns are selected\n rows?: number[]; // when entire rows are selected\n};\n\n/** Metadata describing the currently loaded alignment. */\nexport type EngineMeta = {\n alignmentWidth: number;\n redoDepth: number;\n sequenceCount: number;\n undoDepth: number;\n};\n\n/** A single search match, matching the Rust `search_algorithms::Match`. */\nexport type EngineSearchMatch = {\n col: number;\n matrix_type: MATRIX_TYPE;\n row: number;\n};\n\n/** Search results, matching the Rust `search_algorithms::SearchResult`. */\nexport type EngineSearchResult = {\n num_matches: number;\n positions: EngineSearchMatch[];\n query: string;\n truncated: boolean;\n};\n\n/**\n * Timing breakdown for a single request, measured in milliseconds via\n * `performance.now()`. All fields are optional so non-instrumented responses\n * (e.g. `ready`) can omit them.\n *\n * The full call-to-render latency decomposes as:\n *\n * total = bridgeOut + engineMs + bridgeBack + renderMs\n *\n * where:\n * - `engineMs` : time spent inside the Rust call (measured in worker)\n * - `workerMs` : total time the worker held the request, including the\n * Rust call + response postMessage setup (measured in worker)\n * - `bridgeOut` : main→worker postMessage latency (computed on main thread\n * as `workerReceiveTs - sentTs`, see `TimingMarks`)\n * - `bridgeBack` : worker→main postMessage latency (computed on main thread\n * as `receivedTs - workerDoneTs`)\n * - `renderMs` : time from promise resolution to browser paint (measured\n * with `requestAnimationFrame` in the harness)\n */\nexport type EngineTiming = {\n /** Time inside the Rust engine call (ms). */\n engineMs: number;\n /** Total time the worker held the request (ms): from receive to postMessage. */\n workerMs: number;\n};\n\n/** A fetched viewport or translation slice plus the metadata to interpret it. */\nexport type EngineViewportResult = {\n /** Row-major bytes, transferred from the worker via comlink. */\n bytes: Uint8Array;\n /** Number of columns per row (may be less than requested if clamped). */\n cols: number;\n /** Number of rows actually present in `bytes`. */\n rows: number;\n /** Column index of the first column in the slice. */\n startCol: number;\n /** Row index of the first row in the slice. */\n startRow: number;\n};\n\n/**\n * Contract implemented by the `EngineWorker` class and exposed to the main\n * thread through comlink. Every method is asynchronous so comlink can proxy it\n * across the worker boundary.\n */\nexport interface EngineWorkerApi {\n delete: (rows: number[], column: number) => Promise<void>;\n deleteColumn: (column: number) => Promise<void>;\n exportGappedFasta: () => Promise<string>;\n exportUngappedFasta: () => Promise<string>;\n /** Idempotently initializes the WASM engine; resolves once it is ready. */\n initialize: () => Promise<void>;\n insert: (rows: number[], column: number) => Promise<void>;\n load: (fastaContent: string) => Promise<number>;\n meta: () => Promise<EngineMeta>;\n moveHorizontal: (row: number, columns: number[], direction: MoveDirection) => Promise<void>;\n moveRowsDown: (rows: number[]) => Promise<void>;\n moveRowsUp: (rows: number[]) => Promise<void>;\n mutate: (rows: number[], column: number, base: string) => Promise<void>;\n name: (row: number) => Promise<string>;\n redo: () => Promise<boolean>;\n search: (query: string, checkRecordNames: boolean) => Promise<EngineSearchResult>;\n translate: (bounds: ViewportBounds, readingFrame: number) => Promise<EngineViewportResult>;\n undo: () => Promise<boolean>;\n viewport: (bounds: ViewportBounds) => Promise<EngineViewportResult>;\n}\n\n\n/**\n * Wire protocol between the main thread and the MSA Web Worker.\n *\n * Design goals:\n * - **Zero-copy for binary payloads via SharedArrayBuffer.** Viewport\n * responses write into a single SAB created at worker init. The worker\n * sends a tiny control message (`{sabLen, data: ViewportResult}`) and the\n * main thread reads bytes directly from shared memory — no per-call\n * structured clone of binary data.\n * - **O(1) response correlation.** Every request carries a monotonically\n * increasing `reqId`; the client keeps a `Map<reqId, resolver>` for\n * constant-time dispatch.\n * - **Typed arrays for index vectors.** Row-index lists travel as\n * `Uint32Array` (not `number[]`) to avoid per-element number boxing and to\n * match the wasm-bindgen `&[usize]` slice mapping directly.\n * - **No JSON for hot paths.** Only small plain objects are structured-cloned;\n * binary data is always transferred via the shared SAB.\n */\n\n// ---------------------------------------------------------------------------\n// Shared types\n// ---------------------------------------------------------------------------\n\nexport type GridGeometry = {\n cellHeight: number;\n cellWidth: number;\n dividerWidth: number;\n labelWidth: number;\n numOverscanCols: number;\n numOverscanRows: number;\n rulerHeight: number;\n};\n\nexport type GridPoint = {\n col: number;\n row: number;\n surface: 'cell' | 'gutter' | 'ruler';\n};\n\nexport type GridRange = {\n endCol: number;\n endRow: number;\n startCol: number;\n startRow: number;\n};\n\nexport type GridRangeWithRowNames = {\n range: GridRange;\n rowNames: string[];\n};\n\nexport type GridRangeWithViewportResults = {\n range: GridRange;\n viewportResult: EngineViewportResult;\n};\n\nexport type Meta = {\n redoDepth: number;\n sequences: number;\n undoDepth: number;\n width: number;\n};\n\n// ---------------------------------------------------------------------------\n// Main → Worker requests\n// ---------------------------------------------------------------------------\n\n/**The following types match the Rust `search_algorithms::Match` and search_algorithms::SearchResult structures. */\nexport type SearchMatch = {\n col: number;\n matrix_type: MATRIX_TYPE;\n row: number;\n};\n\n// ---------------------------------------------------------------------------\n// Worker → Main responses\n// ---------------------------------------------------------------------------\n\nexport type SearchResult = EngineSearchResult;\n\n/** Summary statistics for a set of measured values. */\nexport type Stats = {\n count: number;\n max: number;\n mean: number;\n median: number;\n min: number;\n p95: number;\n};\n\nexport type StatusBarSelectionStats = {\n cols: number;\n pos: number;\n selectedSeqs: number;\n totalSelectedChars: number;\n};\n\n/** Inclusive column/row bounds for a viewport or translation request. */\nexport type ViewportBounds = {\n endCol: number;\n endRow: number;\n startCol: number;\n startRow: number;\n};\n\n/** A fetched viewport slice plus the metadata needed to interpret it. */\nexport type ViewportResult = {\n /** Number of columns per row (may be less than requested if clamped). */\n cols: number;\n /** Number of rows actually present in `bytes`. */\n rows: number;\n /** Column index of the first column in the slice. */\n startCol: number;\n /** Row index of the first row in the slice. */\n startRow: number;\n};\n\nexport type VisibleGridRange = {\n cache: GridRange;\n visible: GridRange;\n};\n\nexport type VisibleGridRangeWithArguments = {\n geometry: GridGeometry;\n scrollLeft: number;\n scrollTop: number;\n viewportHeight: number;\n viewportWidth: number;\n visibleGridRange: VisibleGridRange;\n};\n\n/** Debug info exposed to the scrolling viewport status bar. */\nexport type WindowInfo = {\n bufBytes: number;\n bufEnd: number;\n bufStart: number;\n fetching: boolean;\n visEnd: number;\n visStart: number;\n};\n"],"mappings":";AAEA,IAAYA,IAAL,yBAAA,GAAA;QACL,EAAAC,OAAA,QACA,EAAAC,OAAA,QACA,EAAAC,QAAA,SACA,EAAAC,KAAA;AACF,EAAA,CAAA,CAAA,GAEYC,IAAL,yBAAA,GAAA;QACL,EAAAC,OAAA,QACA,EAAAC,UAAA,WACA,EAAAC,QAAA,SACA,EAAAC,QAAA;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;QACL,EAAAC,aAAA,cACA,EAAAC,aAAA,cACA,EAAAC,cAAA;AACF,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"editor.models.js","names":["EDITOR_DIRECTION","\"DOWN\"","\"LEFT\"","\"RIGHT\"","\"UP\"","EDITOR_PATH_PROPERTIES_TYPE","\"CELL\"","\"DIVIDER\"","\"LABEL\"","\"RULER\"","MATRIX_TYPE","\"AMINO_ACID\"","\"NUCLEOTIDE\"","\"RECORD_NAME\""],"sources":["../../src/models/editor.models.ts"],"sourcesContent":["import type { MoveDirection } from '@rivm-loculus-tools/sequence-editor-wasm';\n\nexport enum EDITOR_DIRECTION {\n DOWN = 'DOWN',\n LEFT = 'LEFT',\n RIGHT = 'RIGHT',\n UP = 'UP',\n}\n\nexport enum EDITOR_PATH_PROPERTIES_TYPE {\n CELL = 'CELL',\n DIVIDER = 'DIVIDER',\n LABEL = 'LABEL',\n RULER = 'RULER',\n}\n\n\nexport enum MATRIX_TYPE {\n AMINO_ACID = 'amino_acid',\n NUCLEOTIDE = 'nucleotide',\n RECORD_NAME = 'record_name',\n}\n\nexport type EditorAssembly = {\n cells: EditorAssemblyCells;\n divider: EditorAssemblyDivider;\n labels: EditorAssemblyLabels;\n ruler: EditorAssemblyRuler;\n};\n\nexport type EditorAssemblyCells = {\n pathPropertiesMap: Map<Path2D, EditorPathProperties>;\n};\n\nexport type EditorAssemblyDivider = {\n pathPropertiesMap: Map<Path2D, EditorPathProperties>;\n};\n\nexport type EditorAssemblyLabels = {\n pathPropertiesMap: Map<Path2D, EditorPathProperties>;\n};\n\nexport type EditorAssemblyRuler = {\n pathPropertiesMap: Map<Path2D, EditorPathProperties>;\n};\n\nexport type EditorPathProperties = {\n col: number;\n row: number;\n type: EDITOR_PATH_PROPERTIES_TYPE.CELL;\n} | {\n col: number;\n type: EDITOR_PATH_PROPERTIES_TYPE.RULER;\n} | {\n row: number;\n type: EDITOR_PATH_PROPERTIES_TYPE.LABEL;\n} | {\n type: EDITOR_PATH_PROPERTIES_TYPE.DIVIDER;\n};\n\nexport type EditorSelection = {\n cells?: { // when a rectangular block of cells is selected\n endCol: number;\n endRow: number;\n startCol: number;\n startRow: number;\n };\n cols?: number[]; // when entire columns are selected\n rows?: number[]; // when entire rows are selected\n};\n\n/** Metadata describing the currently loaded alignment. */\nexport type EngineMeta = {\n alignmentWidth: number;\n redoDepth: number;\n sequenceCount: number;\n undoDepth: number;\n};\n\n/** A single search match, matching the Rust `search_algorithms::Match`. */\nexport type EngineSearchMatch = {\n col: number;\n matrix_type: MATRIX_TYPE;\n row: number;\n};\n\n/** Search results, matching the Rust `search_algorithms::SearchResult`. */\nexport type EngineSearchResult = {\n num_matches: number;\n positions: EngineSearchMatch[];\n query: string;\n truncated: boolean;\n};\n\n/**\n * Timing breakdown for a single request, measured in milliseconds via\n * `performance.now()`. All fields are optional so non-instrumented responses\n * (e.g. `ready`) can omit them.\n *\n * The full call-to-render latency decomposes as:\n *\n * total = bridgeOut + engineMs + bridgeBack + renderMs\n *\n * where:\n * - `engineMs` : time spent inside the Rust call (measured in worker)\n * - `workerMs` : total time the worker held the request, including the\n * Rust call + response postMessage setup (measured in worker)\n * - `bridgeOut` : main→worker postMessage latency (computed on main thread\n * as `workerReceiveTs - sentTs`, see `TimingMarks`)\n * - `bridgeBack` : worker→main postMessage latency (computed on main thread\n * as `receivedTs - workerDoneTs`)\n * - `renderMs` : time from promise resolution to browser paint (measured\n * with `requestAnimationFrame` in the harness)\n */\nexport type EngineTiming = {\n /** Time inside the Rust engine call (ms). */\n engineMs: number;\n /** Total time the worker held the request (ms): from receive to postMessage. */\n workerMs: number;\n};\n\n/** A fetched viewport or translation slice plus the metadata to interpret it. */\nexport type EngineViewportResult = {\n /** Row-major bytes, transferred from the worker via comlink. */\n bytes: Uint8Array;\n /** Number of columns per row (may be less than requested if clamped). */\n cols: number;\n /** Number of rows actually present in `bytes`. */\n rows: number;\n /** Column index of the first column in the slice. */\n startCol: number;\n /** Row index of the first row in the slice. */\n startRow: number;\n};\n\n/**\n * Contract implemented by the `EngineWorker` class and exposed to the main\n * thread through comlink. Every method is asynchronous so comlink can proxy it\n * across the worker boundary.\n */\nexport interface EngineWorkerApi {\n delete: (rows: number[], column: number) => Promise<void>;\n deleteColumn: (column: number) => Promise<void>;\n exportGappedFasta: () => Promise<string>;\n exportUngappedFasta: () => Promise<string>;\n /** Idempotently initializes the WASM engine; resolves once it is ready. */\n initialize: () => Promise<void>;\n insert: (rows: number[], column: number) => Promise<void>;\n load: (fastaContent: string) => Promise<number>;\n meta: () => Promise<EngineMeta>;\n moveHorizontal: (row: number, columns: number[], direction: MoveDirection) => Promise<void>;\n moveRows: (rows: number[], options: MoveRowsOptions) => Promise<void>;\n moveRowsDown: (rows: number[]) => Promise<void>;\n moveRowsGrouped: (rows: number[], targetRow: number) => Promise<void>;\n moveRowsRelative: (rows: number[], delta: number) => Promise<void>;\n moveRowsToBottom: (rows: number[]) => Promise<void>;\n moveRowsToTop: (rows: number[]) => Promise<void>;\n moveRowsUp: (rows: number[]) => Promise<void>;\n mutate: (rows: number[], columns: number[], base: string) => Promise<void>;\n name: (row: number) => Promise<string>;\n redo: () => Promise<boolean>;\n search: (query: string, checkRecordNames: boolean) => Promise<EngineSearchResult>;\n translate: (bounds: ViewportBounds, readingFrame: number) => Promise<EngineViewportResult>;\n undo: () => Promise<boolean>;\n viewport: (bounds: ViewportBounds) => Promise<EngineViewportResult>;\n}\n\nexport type GridGeometry = {\n cellHeight: number;\n cellWidth: number;\n dividerWidth: number;\n labelWidth: number;\n numOverscanCols: number;\n numOverscanRows: number;\n rulerHeight: number;\n};\n\n\n/**\n * Wire protocol between the main thread and the MSA Web Worker.\n *\n * Design goals:\n * - **Zero-copy for binary payloads via SharedArrayBuffer.** Viewport\n * responses write into a single SAB created at worker init. The worker\n * sends a tiny control message (`{sabLen, data: ViewportResult}`) and the\n * main thread reads bytes directly from shared memory — no per-call\n * structured clone of binary data.\n * - **O(1) response correlation.** Every request carries a monotonically\n * increasing `reqId`; the client keeps a `Map<reqId, resolver>` for\n * constant-time dispatch.\n * - **Typed arrays for index vectors.** Row-index lists travel as\n * `Uint32Array` (not `number[]`) to avoid per-element number boxing and to\n * match the wasm-bindgen `&[usize]` slice mapping directly.\n * - **No JSON for hot paths.** Only small plain objects are structured-cloned;\n * binary data is always transferred via the shared SAB.\n */\n\n// ---------------------------------------------------------------------------\n// Shared types\n// ---------------------------------------------------------------------------\n\nexport type GridPoint = {\n col: number;\n row: number;\n surface: 'cell' | 'gutter' | 'ruler';\n};\n\nexport type GridRange = {\n endCol: number;\n endRow: number;\n startCol: number;\n startRow: number;\n};\n\nexport type GridRangeWithRowNames = {\n range: GridRange;\n rowNames: string[];\n};\n\nexport type GridRangeWithViewportResults = {\n range: GridRange;\n viewportResult: EngineViewportResult;\n};\n\nexport type Meta = {\n redoDepth: number;\n sequences: number;\n undoDepth: number;\n width: number;\n};\n\nexport type MoveRowsOptions =\n | { delta: number; mode: 'relative' }\n | { mode: 'bottom' }\n | { mode: 'grouped'; targetRow: number }\n | { mode: 'top' };\n\n// ---------------------------------------------------------------------------\n// Main → Worker requests\n// ---------------------------------------------------------------------------\n\n/**The following types match the Rust `search_algorithms::Match` and search_algorithms::SearchResult structures. */\nexport type SearchMatch = {\n col: number;\n matrix_type: MATRIX_TYPE;\n row: number;\n};\n\n// ---------------------------------------------------------------------------\n// Worker → Main responses\n// ---------------------------------------------------------------------------\n\nexport type SearchResult = EngineSearchResult;\n\n/** Summary statistics for a set of measured values. */\nexport type Stats = {\n count: number;\n max: number;\n mean: number;\n median: number;\n min: number;\n p95: number;\n};\n\nexport type StatusBarSelectionStats = {\n cols: number;\n pos: number;\n selectedSeqs: number;\n totalSelectedChars: number;\n};\n\n/** Inclusive column/row bounds for a viewport or translation request. */\nexport type ViewportBounds = {\n endCol: number;\n endRow: number;\n startCol: number;\n startRow: number;\n};\n\n/** A fetched viewport slice plus the metadata needed to interpret it. */\nexport type ViewportResult = {\n /** Number of columns per row (may be less than requested if clamped). */\n cols: number;\n /** Number of rows actually present in `bytes`. */\n rows: number;\n /** Column index of the first column in the slice. */\n startCol: number;\n /** Row index of the first row in the slice. */\n startRow: number;\n};\n\nexport type VisibleGridRange = {\n cache: GridRange;\n visible: GridRange;\n};\n\nexport type VisibleGridRangeWithArguments = {\n geometry: GridGeometry;\n scrollLeft: number;\n scrollTop: number;\n viewportHeight: number;\n viewportWidth: number;\n visibleGridRange: VisibleGridRange;\n};\n\n/** Debug info exposed to the scrolling viewport status bar. */\nexport type WindowInfo = {\n bufBytes: number;\n bufEnd: number;\n bufStart: number;\n fetching: boolean;\n visEnd: number;\n visStart: number;\n};\n"],"mappings":";AAEA,IAAYA,IAAL,yBAAA,GAAA;QACL,EAAAC,OAAA,QACA,EAAAC,OAAA,QACA,EAAAC,QAAA,SACA,EAAAC,KAAA;AACF,EAAA,CAAA,CAAA,GAEYC,IAAL,yBAAA,GAAA;QACL,EAAAC,OAAA,QACA,EAAAC,UAAA,WACA,EAAAC,QAAA,SACA,EAAAC,QAAA;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;QACL,EAAAC,aAAA,cACA,EAAAC,aAAA,cACA,EAAAC,cAAA;AACF,EAAA,CAAA,CAAA"}
@@ -1,63 +1,42 @@
1
1
  import { t as e } from "../../_chunks/sequenceEditorStore.js";
2
2
  import { t } from "../../_chunks/react.js";
3
3
  import { t as n } from "../../_chunks/SequenceEditor.js";
4
- import { useCallback as r, useMemo as i } from "react";
5
- import { container as a } from "tsyringe";
6
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ import { FastaDataImportDialogLoader as a } from "@rivm-loculus-tools/common-frontend/components/fasta/FastaDataImportDialogLoader";
6
+ import { BackdropSpinner as o } from "@gen-epix/ui-core-components/components/BackdropSpinner";
7
+ import { FastaNotLoaded as s } from "@rivm-loculus-tools/common-frontend/components/fasta/FastaNotLoaded";
7
8
  import c from "@mui/icons-material/BiotechOutlined";
8
- import { FastaDataEventBusService as l } from "@rivm-loculus-tools/common-frontend/classes/services/FastaDataEventBusService";
9
- import { ErrorUtil as u } from "@rivm-loculus-tools/common-frontend/utils/ErrorUtil";
10
- import { UrlUtil as d } from "@rivm-loculus-tools/common-frontend/utils/UrlUtil";
11
- import { FastaDataImportDialogLoader as f } from "@rivm-loculus-tools/common-frontend/components/fasta/FastaDataImportDialogLoader";
12
- import { BackdropSpinner as p } from "@gen-epix/ui-core-components/components/BackdropSpinner";
13
- import { FastaNotLoaded as m } from "@rivm-loculus-tools/common-frontend/components/fasta/FastaNotLoaded";
14
- import { LOADING_STATUS as h } from "@rivm-loculus-tools/common-frontend/models/fasta.models";
15
- import { PageCommon as g } from "@rivm-loculus-tools/common-frontend/components/ui/PageCommon";
9
+ import { LOADING_STATUS as l } from "@rivm-loculus-tools/common-frontend/models/fasta.models";
10
+ import { PageCommon as u } from "@rivm-loculus-tools/common-frontend/components/ui/PageCommon";
11
+ import { useConfig as d } from "@rivm-loculus-tools/common-frontend/hooks/useConfig";
16
12
  //#region src/pages/SequenceEditorMainPage/SequenceEditorMainPage.tsx
17
- var _ = () => {
18
- let _ = t(e, (e) => e.loadingStatus), v = t(e, (e) => e.setData), y = t(e, (e) => e.rawFasta), b = r(async () => {
19
- try {
20
- let e = await (await fetch("/sample-data/sarscov2_demo.fasta")).text();
21
- await v(e), a.resolve(l).emit("onCloseImportDialog");
22
- } catch (e) {
23
- a.resolve(l).emit("onCloseImportDialog");
24
- let t = `Failed to load demo dataset: ${u.getErrorMessage(e, "Unknown error")}`;
25
- a.resolve(l).emit("onShowImportDialog", t);
26
- } finally {
27
- d.clearSearchParams();
28
- }
29
- }, [v]), x = i(() => [{
30
- autoFocus: !0,
31
- color: "secondary",
32
- label: "Demo (SARS-CoV-2)",
33
- onClick: b,
34
- variant: "contained"
35
- }], [b]);
36
- return /* @__PURE__ */ s(g, {
13
+ var f = () => {
14
+ let f = d(), p = t(e, (e) => e.loadingStatus), m = t(e, (e) => e.rawFasta);
15
+ return /* @__PURE__ */ i(u, {
37
16
  isNoInteraction: !1,
38
17
  title: "Sequence Editor",
39
18
  children: [
40
- y && /* @__PURE__ */ o(n, {}),
41
- !y && /* @__PURE__ */ o(m, {
19
+ m && /* @__PURE__ */ r(n, {}),
20
+ !m && /* @__PURE__ */ r(s, {
42
21
  description: "Load a FASTA sequence file to enable the editor.",
43
- icon: /* @__PURE__ */ o(c, { sx: {
22
+ icon: /* @__PURE__ */ r(c, { sx: {
44
23
  color: "text.disabled",
45
24
  fontSize: 72
46
25
  } }),
47
26
  title: "No FASTA Sequence Loaded"
48
27
  }),
49
- /* @__PURE__ */ o(f, {
50
- extraActions: x,
28
+ /* @__PURE__ */ r(a, {
29
+ extraActions: f?.fastaImportExtraActions,
51
30
  store: e
52
31
  }),
53
- /* @__PURE__ */ o(p, {
32
+ /* @__PURE__ */ r(o, {
54
33
  label: "Computing phylogenetic tree",
55
- open: _ === h.LOADING
34
+ open: p === l.LOADING
56
35
  })
57
36
  ]
58
37
  });
59
38
  };
60
39
  //#endregion
61
- export { _ as SequenceEditorMainPage };
40
+ export { f as SequenceEditorMainPage };
62
41
 
63
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["sequenceEditorStore","SequenceEditor","BiotechOutlinedIcon","SequenceEditorMainPage","loadingStatus","useStore","state","setData","rawFasta","onClickLoadDemoData","useCallback","demoFastaText","container","FastaDataEventBusService","err","errorMessage","ErrorUtil","extraFastaDataImportDialogLoaderActions","useMemo","PageCommon","FastaNotLoaded","FastaDataImportDialogLoader","BackdropSpinner","LOADING_STATUS"],"sources":["../../../src/pages/SequenceEditorMainPage/SequenceEditorMainPage.tsx"],"sourcesContent":["import { container } from 'tsyringe';\nimport { useStore } from 'zustand';\nimport {\n useCallback,\n useMemo,\n} from 'react';\nimport { FastaDataEventBusService } from '@rivm-loculus-tools/common-frontend/classes/services/FastaDataEventBusService';\nimport { ErrorUtil } from '@rivm-loculus-tools/common-frontend/utils/ErrorUtil';\nimport { UrlUtil } from '@rivm-loculus-tools/common-frontend/utils/UrlUtil';\nimport type { DialogAction } from '@gen-epix/ui-core-components/components/Dialog';\nimport { FastaDataImportDialogLoader } from '@rivm-loculus-tools/common-frontend/components/fasta/FastaDataImportDialogLoader';\nimport { BackdropSpinner } from '@gen-epix/ui-core-components/components/BackdropSpinner';\nimport { FastaNotLoaded } from '@rivm-loculus-tools/common-frontend/components/fasta/FastaNotLoaded';\nimport BiotechOutlinedIcon from '@mui/icons-material/BiotechOutlined';\nimport { LOADING_STATUS } from '@rivm-loculus-tools/common-frontend/models/fasta.models';\nimport { PageCommon } from '@rivm-loculus-tools/common-frontend/components/ui/PageCommon';\n\nimport { sequenceEditorStore } from '../../stores/sequenceEditorStore';\nimport { SequenceEditor } from '../../components/ui/SequenceEditor';\n\n\nexport const SequenceEditorMainPage = () => {\n const loadingStatus = useStore(sequenceEditorStore, (state) => state.loadingStatus);\n const setData = useStore(sequenceEditorStore, (state) => state.setData);\n const rawFasta = useStore(sequenceEditorStore, (state) => state.rawFasta);\n\n const onClickLoadDemoData = useCallback(async () => {\n try {\n const fastaRes = await fetch('/sample-data/sarscov2_demo.fasta');\n const demoFastaText = await fastaRes.text();\n\n await setData(demoFastaText);\n container.resolve(FastaDataEventBusService).emit('onCloseImportDialog');\n } catch (err: unknown) {\n container.resolve(FastaDataEventBusService).emit('onCloseImportDialog');\n const errorMessage = `Failed to load demo dataset: ${ErrorUtil.getErrorMessage(err, 'Unknown error')}`;\n container.resolve(FastaDataEventBusService).emit('onShowImportDialog', errorMessage);\n } finally {\n UrlUtil.clearSearchParams();\n }\n }, [setData]);\n\n const extraFastaDataImportDialogLoaderActions = useMemo<DialogAction[]>(() => [\n {\n autoFocus: true,\n color: 'secondary',\n label: 'Demo (SARS-CoV-2)',\n onClick: onClickLoadDemoData,\n variant: 'contained',\n },\n ], [onClickLoadDemoData]);\n\n return (\n <PageCommon\n isNoInteraction={false}\n title={'Sequence Editor'}\n >\n {rawFasta && (\n <SequenceEditor />\n )}\n {!rawFasta && (\n <FastaNotLoaded\n description={'Load a FASTA sequence file to enable the editor.'}\n icon={<BiotechOutlinedIcon sx={{ color: 'text.disabled', fontSize: 72 }} />}\n title={'No FASTA Sequence Loaded'}\n />\n )}\n <FastaDataImportDialogLoader\n extraActions={extraFastaDataImportDialogLoaderActions}\n store={sequenceEditorStore}\n />\n <BackdropSpinner\n label={`Computing phylogenetic tree`}\n open={loadingStatus === LOADING_STATUS.LOADING}\n />\n </PageCommon>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,IAAaG,UAA+B;CAC1C,IAAMC,IAAgBC,EAASL,IAAsB,MAAUM,EAAM,aAAa,GAC5EC,IAAUF,EAASL,IAAsB,MAAUM,EAAM,OAAO,GAChEE,IAAWH,EAASL,IAAsB,MAAUM,EAAM,QAAQ,GAElEG,IAAsBC,EAAY,YAAY;EAClD,IAAI;GAEF,IAAMC,IAAgB,OAAM,MADL,MAAM,kCAAkC,EAAA,CAC1B,KAAK;GAG1C,AADA,MAAMJ,EAAQI,CAAa,GAC3BC,EAAU,QAAQC,CAAwB,CAAC,CAAC,KAAK,qBAAqB;EACxE,SAASC,GAAc;GACrB,EAAU,QAAQD,CAAwB,CAAC,CAAC,KAAK,qBAAqB;GACtE,IAAME,IAAe,gCAAgCC,EAAU,gBAAgBF,GAAK,eAAe;GACnG,EAAU,QAAQD,CAAwB,CAAC,CAAC,KAAK,sBAAsBE,CAAY;EACrF,UAAU;GACR,EAAQ,kBAAkB;EAC5B;CACF,GAAG,CAACR,CAAO,CAAC,GAENU,IAA0CC,QAA8B,CAC5E;EACE,WAAW;EACX,OAAO;EACP,OAAO;EACP,SAAST;EACT,SAAS;CACX,CACF,GAAG,CAACA,CAAmB,CAAC;CAExB,OACE,kBAACU,GAAD;EACE,iBAAiB;EACjB,OAAO;EAFT,UAAA;GAIGX,KACC,kBAACP,GAAD,CAAiB,CAAA;GAElB,CAACO,KACA,kBAACY,GAAD;IACE,aAAa;IACb,MAAM,kBAAClB,GAAD,EAAqB,IAAI;KAAE,OAAO;KAAiB,UAAU;IAAG,EAAI,CAAA;IAC1E,OAAO;GACR,CAAA;GAEH,kBAACmB,GAAD;IACE,cAAcJ;IACd,OAAOjB;GACR,CAAA;GACD,kBAACsB,GAAD;IACE,OAAO;IACP,MAAMlB,MAAkBmB,EAAe;GACxC,CAAA;EACS;;AAEhB"}
1
+ {"version":3,"file":"index.js","names":["sequenceEditorStore","SequenceEditor","BiotechOutlinedIcon","SequenceEditorMainPage","config","useConfig","loadingStatus","useStore","state","rawFasta","PageCommon","FastaNotLoaded","FastaDataImportDialogLoader","BackdropSpinner","LOADING_STATUS"],"sources":["../../../src/pages/SequenceEditorMainPage/SequenceEditorMainPage.tsx"],"sourcesContent":["import { useStore } from 'zustand';\nimport { FastaDataImportDialogLoader } from '@rivm-loculus-tools/common-frontend/components/fasta/FastaDataImportDialogLoader';\nimport { BackdropSpinner } from '@gen-epix/ui-core-components/components/BackdropSpinner';\nimport { FastaNotLoaded } from '@rivm-loculus-tools/common-frontend/components/fasta/FastaNotLoaded';\nimport BiotechOutlinedIcon from '@mui/icons-material/BiotechOutlined';\nimport { LOADING_STATUS } from '@rivm-loculus-tools/common-frontend/models/fasta.models';\nimport { PageCommon } from '@rivm-loculus-tools/common-frontend/components/ui/PageCommon';\nimport { useConfig } from '@rivm-loculus-tools/common-frontend/hooks/useConfig';\n\nimport { sequenceEditorStore } from '../../stores/sequenceEditorStore';\nimport { SequenceEditor } from '../../components/ui/SequenceEditor';\nimport type { SequenceEditorConfig } from '../../models/config.models';\n\n\nexport const SequenceEditorMainPage = () => {\n const config = useConfig<SequenceEditorConfig>();\n const loadingStatus = useStore(sequenceEditorStore, (state) => state.loadingStatus);\n const rawFasta = useStore(sequenceEditorStore, (state) => state.rawFasta);\n\n return (\n <PageCommon\n isNoInteraction={false}\n title={'Sequence Editor'}\n >\n {rawFasta && (\n <SequenceEditor />\n )}\n {!rawFasta && (\n <FastaNotLoaded\n description={'Load a FASTA sequence file to enable the editor.'}\n icon={<BiotechOutlinedIcon sx={{ color: 'text.disabled', fontSize: 72 }} />}\n title={'No FASTA Sequence Loaded'}\n />\n )}\n <FastaDataImportDialogLoader\n extraActions={config?.fastaImportExtraActions}\n store={sequenceEditorStore}\n />\n <BackdropSpinner\n label={`Computing phylogenetic tree`}\n open={loadingStatus === LOADING_STATUS.LOADING}\n />\n </PageCommon>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAcA,IAAaG,UAA+B;CAC1C,IAAMC,IAASC,EAAgC,GACzCC,IAAgBC,EAASP,IAAsB,MAAUQ,EAAM,aAAa,GAC5EC,IAAWF,EAASP,IAAsB,MAAUQ,EAAM,QAAQ;CAExE,OACE,kBAACE,GAAD;EACE,iBAAiB;EACjB,OAAO;EAFT,UAAA;GAIGD,KACC,kBAACR,GAAD,CAAiB,CAAA;GAElB,CAACQ,KACA,kBAACE,GAAD;IACE,aAAa;IACb,MAAM,kBAACT,GAAD,EAAqB,IAAI;KAAE,OAAO;KAAiB,UAAU;IAAG,EAAI,CAAA;IAC1E,OAAO;GACR,CAAA;GAEH,kBAACU,GAAD;IACE,cAAcR,GAAQ;IACtB,OAAOJ;GACR,CAAA;GACD,kBAACa,GAAD;IACE,OAAO;IACP,MAAMP,MAAkBQ,EAAe;GACxC,CAAA;EACS;;AAEhB"}
@@ -19,11 +19,13 @@ export declare class EditorUtil {
19
19
  viewportWidth: number;
20
20
  }): EditorAssembly;
21
21
  static getExpandedSelection(currentSelection: EditorSelection, initialSelection: EditorSelection, direction: EDITOR_DIRECTION, metaData: EngineMeta): EditorSelection | null;
22
+ static getMovedRowsEndSelection(selection: EditorSelection | null, direction: EDITOR_DIRECTION, metaData: EngineMeta | null): EditorSelection | null;
23
+ static getMovedRowsGroupedSelection(selection: EditorSelection | null, targetRow: number, metaData: EngineMeta | null): EditorSelection | null;
24
+ static getMovedRowsRelativeSelection(selection: EditorSelection | null, direction: EDITOR_DIRECTION, metaData: EngineMeta | null): EditorSelection | null;
22
25
  static getMovedSelection(selection: EditorSelection | null, direction: EDITOR_DIRECTION, metaData: EngineMeta | null): EditorSelection | null;
23
26
  static getMutateArguments(selection: EditorSelection | null, metaData: EngineMeta, offset?: number): {
24
- endCol: number;
27
+ columns: number[];
25
28
  rows: number[];
26
- startCol: number;
27
29
  } | undefined;
28
30
  /**
29
31
  * Performs a hit-test against the tree assembly's path maps to find the