@abi-software/mapintegratedvuer 1.16.2 → 1.16.3-simulation.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 (41) hide show
  1. package/dist/{ContentMixin-DiDiS2Ct.js → ContentMixin-CXBghkG4.js} +224 -455
  2. package/dist/{style-t77Cw_0W.js → DynamicMarkerMixin-C077TWyL.js} +1 -1
  3. package/dist/Flatmap-CKWEbXwI.js +103454 -0
  4. package/dist/{Iframe-Drf0INka.js → Iframe-CImGKtGq.js} +2 -2
  5. package/dist/{MultiFlatmap-ZODnXOPU.js → MultiFlatmap-jLxHqKwa.js} +15 -15
  6. package/dist/{Plot-DrEUpK5N.js → Plot-CZP1T3yL.js} +2 -2
  7. package/dist/{Scaffold-BiDz1Mwi.js → Scaffold-Z2Jv6mwD.js} +79 -53
  8. package/dist/Simulation-OtmfB6BF.js +72 -0
  9. package/dist/{index-C753e18_.js → index-Bym6cokq.js} +19683 -20021
  10. package/dist/mapintegratedvuer.js +1 -1
  11. package/dist/mapintegratedvuer.umd.cjs +4271 -231
  12. package/dist/style.css +1 -1
  13. package/package.json +9 -4
  14. package/src/App.vue +290 -260
  15. package/src/assets/styles.scss +1 -1
  16. package/src/components/ContentBar.vue +0 -1
  17. package/src/components/ContentVuer.vue +0 -2
  18. package/src/components/ContextCard.vue +0 -1
  19. package/src/components/DummyRouteComponent.vue +1 -0
  20. package/src/components/EventBus.ts +13 -0
  21. package/src/components/FloatingWindow.vue +125 -0
  22. package/src/components/MapContent.vue +1 -3
  23. package/src/components/PlotComponent.vue +56 -0
  24. package/src/components/SplitFlow.vue +470 -439
  25. package/src/components/scripts/utilities.js +1 -1
  26. package/src/components/viewers/Flatmap.vue +136 -84
  27. package/src/components/viewers/MultiFlatmap.vue +1 -1
  28. package/src/components/viewers/Simulation.vue +65 -15
  29. package/src/components.d.ts +3 -0
  30. package/src/main.js +9 -3
  31. package/src/mixins/ContentMixin.js +419 -390
  32. package/src/services/mapping.js +69 -0
  33. package/src/stores/entries.js +1 -1
  34. package/src/stores/mapping.js +29 -0
  35. package/src/stores/settings.js +0 -4
  36. package/src/stores/simulationPlotStore.js +104 -0
  37. package/src/stores/splitFlow.js +427 -362
  38. package/src/types/simulation.js +18 -0
  39. package/dist/Flatmap-Dh0ybLSL.js +0 -202
  40. package/dist/Simulation-lEXXSWRc.js +0 -28
  41. package/src/components/EventBus.js +0 -3
@@ -0,0 +1,69 @@
1
+ import readXlsxFile from 'read-excel-file'
2
+
3
+ const BASE_URL =
4
+ 'https://raw.githubusercontent.com/hsorby/fc-feature-mapping/main/'
5
+ const INDEX_FILE = 'mapping_index.json'
6
+
7
+ export class MappingService {
8
+ // Find the correct Excel file for the current Flatmap
9
+ static async getMappingIndex() {
10
+ try {
11
+ // Fetch the master index
12
+ const response = await fetch(`${BASE_URL}${INDEX_FILE}`)
13
+ if (!response.ok) throw new Error('Failed to fetch index')
14
+
15
+ const index = await response.json()
16
+
17
+ return index || null
18
+ } catch (e) {
19
+ console.error('Error finding map mapping:', e)
20
+ return null
21
+ }
22
+ }
23
+
24
+ // Fetch and Parse the Excel file
25
+ static async loadMapping(index) {
26
+ const flatmapMap = new Map()
27
+
28
+ for (const entry in index) {
29
+ try {
30
+ const filename = index[entry]
31
+
32
+ const response = await fetch(`${BASE_URL}${filename}`)
33
+ if (!response.ok) throw new Error(`Failed to fetch ${filename}`)
34
+
35
+ // Get the binary data
36
+ const blob = await response.blob()
37
+
38
+ // Parse with read-excel-file
39
+ // rows is an array of arrays: [ ["Header1", "Header2"], ["Row1Col1", "Row1Col2"] ]
40
+ const rows = await readXlsxFile(blob)
41
+
42
+ // Remove header row
43
+ const headers = rows.shift()
44
+ const nameIndex = headers.indexOf('Name')
45
+ const componentIndex = headers.indexOf('Component')
46
+ const flatmapIdIndex = headers.indexOf('Flatmap ID')
47
+
48
+ // Convert to a Lookup Map for fast access
49
+ // Assuming Column 0 = FlatmapID, Column 1 = Component, Column 2 = Variable
50
+ const lookup = new Map()
51
+
52
+ rows.forEach((row) => {
53
+ const flatmapId = row[flatmapIdIndex]
54
+ const component = row[componentIndex]
55
+ const variable = row[nameIndex]
56
+
57
+ if (flatmapId && component && variable) {
58
+ lookup.set(flatmapId, { component, variable })
59
+ }
60
+ })
61
+ flatmapMap.set(entry, lookup)
62
+ } catch (e) {
63
+ console.error('Error parsing mapping file:', e)
64
+ }
65
+ }
66
+
67
+ return flatmapMap
68
+ }
69
+ }
@@ -1,6 +1,6 @@
1
1
  import { defineStore } from 'pinia';
2
2
  import { initialDefaultState } from "../components/scripts/utilities";
3
- import { getKnowledgeSourceFromProvenance } from '@abi-software/flatmapvuer/src/services/flatmapKnowledge.js';
3
+ import { getKnowledgeSourceFromProvenance } from '@abi-software/flatmapvuer';
4
4
 
5
5
  /* eslint-disable no-alert, no-console */
6
6
 
@@ -0,0 +1,29 @@
1
+ import { defineStore } from 'pinia'
2
+ import { MappingService } from '../services/mapping'
3
+
4
+ export const useMappingStore = defineStore('mapping', {
5
+ state: () => ({
6
+ elementMap: new Map(),
7
+ }),
8
+
9
+ actions: {
10
+ async initializeMapping() {
11
+ this.elementMap.clear()
12
+
13
+ // Find which file to load
14
+ const index = await MappingService.getMappingIndex()
15
+
16
+ if (index) {
17
+ // Parse and store
18
+ this.elementMap = await MappingService.loadMapping(index)
19
+ } else {
20
+ console.warn('No index found.')
21
+ }
22
+ },
23
+
24
+ // Helper to get data for a specific element ID
25
+ mapToCellMLIdentifiers(flatmapUuid, flatmapElementId) {
26
+ return this.elementMap.get(flatmapUuid)?.get(flatmapElementId) || { component: undefined, variable: undefined }
27
+ },
28
+ },
29
+ })
@@ -12,7 +12,6 @@ export const useSettingsStore = defineStore('settings', {
12
12
  algoliaId: undefined,
13
13
  pennsieveApi: undefined,
14
14
  flatmapAPI: undefined,
15
- nlLinkPrefix: undefined,
16
15
  mapManager: undefined,
17
16
  rootUrl: undefined,
18
17
  facets: { species: [], gender: [], organ: [] },
@@ -114,9 +113,6 @@ export const useSettingsStore = defineStore('settings', {
114
113
  updateMapManager(mapManager) {
115
114
  this.mapManager = mapManager;
116
115
  },
117
- updateNLLinkPrefix(nlLinkPrefix) {
118
- this.nlLinkPrefix = nlLinkPrefix;
119
- },
120
116
  updateRootUrl(rootUrl) {
121
117
  this.rootUrl = rootUrl;
122
118
  },
@@ -0,0 +1,104 @@
1
+ import { defineStore } from 'pinia'
2
+ import { ref } from 'vue'
3
+ import EventBus from '../components/EventBus'
4
+
5
+ const BASE_Z_INDEX = 100
6
+
7
+ export const useSimulationPlotStore = defineStore('simulationPlots', () => {
8
+ const windows = ref([])
9
+ const zStack = ref([])
10
+ const simulationEntries = ref({})
11
+
12
+ function initListeners() {
13
+ EventBus.on('simulation-response', handleSimulationResponse)
14
+ EventBus.on('simulation-ready', handleSimulationReady)
15
+ }
16
+
17
+ function cleanupListeners() {
18
+ EventBus.off('simulation-response', handleSimulationResponse)
19
+ EventBus.off('simulation-ready', handleSimulationReady)
20
+ }
21
+
22
+ function removeWindow(windowId) {
23
+ const targetWindow = windows.value.find(win => win.id === windowId)
24
+ if (!targetWindow) return
25
+ windows.value = windows.value.filter((win) => win.id !== windowId)
26
+ zStack.value = zStack.value.filter((stackId) => stackId !== windowId)
27
+ EventBus.emit('plot-window-closed', { id: targetWindow.id})
28
+ }
29
+
30
+ function refreshZIndices() {
31
+ windows.value.forEach((win) => {
32
+ // Find where this window sits in the stack
33
+ const stackIndex = zStack.value.indexOf(win.id)
34
+
35
+ // If found, assign zIndex. If not (error case), keep it low.
36
+ if (stackIndex !== -1) {
37
+ win.zIndex = BASE_Z_INDEX + stackIndex
38
+ }
39
+ })
40
+ }
41
+
42
+ function bringToFront(windowId) {
43
+ const stackIndex = zStack.value.indexOf(windowId)
44
+ if (stackIndex === -1) return // Should not happen
45
+
46
+ zStack.value.splice(stackIndex, 1)
47
+
48
+ zStack.value.push(windowId)
49
+
50
+ refreshZIndices()
51
+ }
52
+
53
+ function handleSimulationReady(data) {
54
+ simulationEntries.value[data.resourceId] = { ready: data.ready }
55
+ }
56
+
57
+ function requestSimulation(data) {
58
+ if (data.protocol === null || !simulationEntries.value[data.protocol?.resource]?.ready) return
59
+
60
+ let targetWindow = windows.value.find(win => win.id === data.windowId)
61
+ if (!targetWindow) {
62
+ targetWindow = {
63
+ id: data.windowId,
64
+ ownerId: data.ownerId,
65
+ data: null,
66
+ zIndex: BASE_Z_INDEX,
67
+ x: data.position.x + data.offset.left,
68
+ y: data.position.y + data.offset.top,
69
+ }
70
+ windows.value.push(targetWindow)
71
+ zStack.value.push(targetWindow.id)
72
+ refreshZIndices()
73
+ } else {
74
+ bringToFront(targetWindow.id)
75
+ }
76
+
77
+ EventBus.emit('simulation-data-request', {
78
+ id: 'nz.ac.auckland.simulation-data-request',
79
+ version: '0.1.0',
80
+ payload: data,
81
+ })
82
+ }
83
+
84
+ function handleSimulationResponse(response) {
85
+ if (response.id !== 'nz.ac.auckland.simulation-data-response') return
86
+ const targetWindow = windows.value.find(win => win.id === response.payload.windowId)
87
+
88
+ if (targetWindow) {
89
+ targetWindow.data = response.payload.data
90
+ } else {
91
+ console.warn('Received simulation response for unknown window ID:', response.payload.windowId)
92
+ }
93
+ }
94
+
95
+ return {
96
+ windows,
97
+ bringToFront,
98
+ cleanupListeners,
99
+ handleSimulationResponse,
100
+ requestSimulation,
101
+ initListeners,
102
+ removeWindow,
103
+ }
104
+ })