@morscherlab/mld-sdk 0.9.7 → 0.10.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 (56) hide show
  1. package/dist/__tests__/composables/useAppExperiment.test.d.ts +1 -0
  2. package/dist/components/AppTopBar.vue.js +61 -28
  3. package/dist/components/AppTopBar.vue.js.map +1 -1
  4. package/dist/components/AuditTrail.vue.d.ts +1 -1
  5. package/dist/components/ExperimentSelectorModal.vue.d.ts +1 -1
  6. package/dist/components/FormulaInput.vue.js +24 -18
  7. package/dist/components/FormulaInput.vue.js.map +1 -1
  8. package/dist/components/MoleculeInput.vue.js +15 -6
  9. package/dist/components/MoleculeInput.vue.js.map +1 -1
  10. package/dist/components/PlateMapEditor.vue.js +1 -1
  11. package/dist/components/PlateMapEditor.vue.js.map +1 -1
  12. package/dist/components/ScientificNumber.vue.d.ts +1 -1
  13. package/dist/composables/index.d.ts +1 -0
  14. package/dist/composables/index.js +3 -0
  15. package/dist/composables/index.js.map +1 -1
  16. package/dist/composables/useAppExperiment.d.ts +34 -0
  17. package/dist/composables/useAppExperiment.js +91 -0
  18. package/dist/composables/useAppExperiment.js.map +1 -0
  19. package/dist/composables/useAuth.js +26 -25
  20. package/dist/composables/useAuth.js.map +1 -1
  21. package/dist/composables/useAutoGroup.js +7 -32
  22. package/dist/composables/useAutoGroup.js.map +1 -1
  23. package/dist/composables/useForm.js +1 -1
  24. package/dist/composables/useForm.js.map +1 -1
  25. package/dist/composables/usePlatformContext.js +8 -1
  26. package/dist/composables/usePlatformContext.js.map +1 -1
  27. package/dist/composables/useTheme.js +23 -25
  28. package/dist/composables/useTheme.js.map +1 -1
  29. package/dist/composables/useWellPlateEditor.d.ts +1 -0
  30. package/dist/composables/useWellPlateEditor.js +21 -10
  31. package/dist/composables/useWellPlateEditor.js.map +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +3 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/stores/auth.d.ts +1 -1
  36. package/dist/stores/settings.d.ts +1 -1
  37. package/dist/stores/settings.js +17 -30
  38. package/dist/stores/settings.js.map +1 -1
  39. package/dist/styles.css +6920 -6908
  40. package/package.json +1 -1
  41. package/src/__tests__/composables/useAppExperiment.test.ts +560 -0
  42. package/src/components/AppTopBar.vue +38 -2
  43. package/src/components/FormulaInput.vue +17 -16
  44. package/src/components/MoleculeInput.vue +29 -14
  45. package/src/components/PlateMapEditor.vue +1 -1
  46. package/src/composables/index.ts +7 -0
  47. package/src/composables/useAppExperiment.ts +143 -0
  48. package/src/composables/useAuth.ts +29 -31
  49. package/src/composables/useAutoGroup.ts +7 -33
  50. package/src/composables/useForm.ts +1 -1
  51. package/src/composables/usePlatformContext.ts +7 -1
  52. package/src/composables/useTheme.ts +33 -28
  53. package/src/composables/useWellPlateEditor.ts +22 -10
  54. package/src/index.ts +5 -0
  55. package/src/stores/settings.ts +22 -38
  56. package/src/styles/components/formula-input.css +13 -6
@@ -33,8 +33,12 @@ function getDefaultServerHost(): string {
33
33
  }
34
34
 
35
35
  function getDefaultServerPort(): number {
36
- if (typeof window !== 'undefined' && window.location.port) {
37
- return parseInt(window.location.port, 10)
36
+ if (typeof window !== 'undefined') {
37
+ if (window.location.port) {
38
+ return parseInt(window.location.port, 10)
39
+ }
40
+ // Standard ports: 443 for HTTPS, 80 for HTTP (browser omits from location.port)
41
+ return window.location.protocol === 'https:' ? 443 : 80
38
42
  }
39
43
  return 8000
40
44
  }
@@ -92,34 +96,26 @@ export const useSettingsStore = defineStore('mld-settings', () => {
92
96
  // API prefix - can be configured via env variable VITE_API_PREFIX
93
97
  const apiPrefix: string = (import.meta.env?.VITE_API_PREFIX as string | undefined) ?? '/api'
94
98
 
95
- function getApiBaseUrl(): string {
99
+ function _isSameOrigin(): { same: boolean; currentHost: string; currentPort: string } {
96
100
  const currentHost = typeof window !== 'undefined' ? window.location.hostname : 'localhost'
97
101
  const currentPort = typeof window !== 'undefined' ? window.location.port : '8000'
102
+ const effectivePort = currentPort || (window.location.protocol === 'https:' ? '443' : '80')
103
+ const same =
104
+ (serverHost.value === currentHost && String(serverPort.value) === effectivePort) ||
105
+ (serverHost.value === 'localhost' && currentHost !== 'localhost')
106
+ return { same, currentHost, currentPort }
107
+ }
98
108
 
99
- if (serverHost.value === currentHost && String(serverPort.value) === currentPort) {
100
- return apiPrefix
101
- }
102
-
103
- if (serverHost.value === 'localhost' && currentHost !== 'localhost') {
104
- return apiPrefix
105
- }
106
-
109
+ function getApiBaseUrl(): string {
110
+ const { same } = _isSameOrigin()
111
+ if (same) return apiPrefix
107
112
  return `http://${serverHost.value}:${serverPort.value}${apiPrefix}`
108
113
  }
109
114
 
110
115
  function getWsBaseUrl(): string {
111
- const currentHost = typeof window !== 'undefined' ? window.location.hostname : 'localhost'
112
- const currentPort = typeof window !== 'undefined' ? window.location.port : '8000'
116
+ const { same, currentHost, currentPort } = _isSameOrigin()
113
117
  const protocol = typeof window !== 'undefined' && window.location.protocol === 'https:' ? 'wss:' : 'ws:'
114
-
115
- if (serverHost.value === currentHost && String(serverPort.value) === currentPort) {
116
- return `${protocol}//${currentHost}:${currentPort}${apiPrefix}`
117
- }
118
-
119
- if (serverHost.value === 'localhost' && currentHost !== 'localhost') {
120
- return `${protocol}//${currentHost}:${currentPort}${apiPrefix}`
121
- }
122
-
118
+ if (same) return `${protocol}//${currentHost}${currentPort ? ':' + currentPort : ''}${apiPrefix}`
123
119
  return `ws://${serverHost.value}:${serverPort.value}${apiPrefix}`
124
120
  }
125
121
 
@@ -138,19 +134,10 @@ export const useSettingsStore = defineStore('mld-settings', () => {
138
134
  }
139
135
 
140
136
  function applyTheme() {
141
- let isDark = false
142
-
143
- if (theme.value === 'system') {
144
- isDark = window.matchMedia('(prefers-color-scheme: dark)').matches
145
- } else {
146
- isDark = theme.value === 'dark'
147
- }
148
-
149
- if (isDark) {
150
- document.documentElement.classList.add('dark')
151
- } else {
152
- document.documentElement.classList.remove('dark')
153
- }
137
+ const dark = theme.value === 'system'
138
+ ? window.matchMedia('(prefers-color-scheme: dark)').matches
139
+ : theme.value === 'dark'
140
+ document.documentElement.classList.toggle('dark', dark)
154
141
  }
155
142
 
156
143
  watch(theme, () => {
@@ -206,7 +193,6 @@ export const useSettingsStore = defineStore('mld-settings', () => {
206
193
  }
207
194
 
208
195
  return {
209
- // State
210
196
  serverHost,
211
197
  serverPort,
212
198
  requestTimeout,
@@ -215,8 +201,6 @@ export const useSettingsStore = defineStore('mld-settings', () => {
215
201
  theme,
216
202
  colorPalette,
217
203
  tableDensity,
218
-
219
- // Actions
220
204
  initialize,
221
205
  applyTheme,
222
206
  persistSettings,
@@ -65,22 +65,29 @@
65
65
  background-color: var(--bg-tertiary);
66
66
  }
67
67
 
68
- /* Preview */
68
+ /* Preview row */
69
69
  .mld-formula-input__preview {
70
- padding: 0.375rem 0.75rem;
70
+ padding: 0.25rem 0.75rem;
71
71
  background-color: var(--bg-tertiary);
72
72
  border-top: 1px solid var(--border-color);
73
- font-size: 1.125rem;
74
- min-height: 1.75rem;
73
+ min-height: 1.5rem;
75
74
  display: flex;
76
75
  align-items: center;
76
+ justify-content: space-between;
77
+ gap: 0.75rem;
78
+ }
79
+
80
+ .mld-formula-input__preview-formula {
81
+ font-size: 1rem;
82
+ line-height: 1.4;
77
83
  }
78
84
 
79
85
  /* Molecular weight display */
80
86
  .mld-formula-input__mw {
81
- font-size: 0.75rem;
87
+ font-size: 0.6875rem;
82
88
  color: var(--text-muted);
83
- padding-left: 0.125rem;
89
+ white-space: nowrap;
90
+ flex-shrink: 0;
84
91
  }
85
92
 
86
93
  .mld-formula-input__mw::before {