Skip to content

Commit 98de7af

Browse files
committed
✨ [feat] Refactor chart rendering and improve IPC handling
- 🔧 [fix] Fixed bug with chart conversion between km/meter/feet/miles - 🔧 [build] Introduced `createManagedChart` utility for consistent chart management across multiple chart rendering functions. - 🛠️ [fix] Updated `renderLapZoneChart`, `renderPowerVsHeartRateChart`, `renderSpeedVsDistanceChart`, and `renderZoneChartNew` to utilize `createManagedChart` for better chart instance management. - 🔧 [build] Enhanced `renderPowerVsHeartRateChart` and `renderSpeedVsDistanceChart` to use `chartSettingsManager` for field visibility instead of localStorage. - 🎨 [style] Improved code readability by restructuring conditional statements and ensuring consistent formatting. - 🔧 [build] Changed IPC channel for FIT file decoding from `"decode-fit-file"` to `"fit:decode"` for better clarity and consistency. - 🎨 [style] Updated debug logging in `debugSensorInfo` to use a more appropriate emoji for formatted product output. - 🎨 [style] Changed the icon for the export ZIP functionality in settings to a folder emoji for better visual representation. Signed-off-by: Nick2bad4u <[email protected]>
1 parent 17bed1a commit 98de7af

File tree

333 files changed

+24522
-23491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

333 files changed

+24522
-23491
lines changed

docs/FIT_PARSER_MIGRATION_GUIDE.md

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ The `fitParser.js` module has been successfully migrated to integrate with the F
66

77
## Key Changes
88

9+
> **Canonical IPC Channels**
10+
>
11+
> - `fit:decode` – primary channel for decoding FIT files from the renderer.
12+
> - `fit:parse` – alternative channel used by some internal flows/tests.
13+
>
14+
> The legacy `decode-fit-file` channel has been fully replaced by `fit:decode` in the integration helpers. Any new code should use `fit:decode` / `fit:parse` only.
15+
916
### 1. State Management Integration
1017

1118
The FIT parser now integrates with:
@@ -100,45 +107,37 @@ import { initializeFitParserIntegration } from "./utils/fitParserIntegration.js"
100107
await initializeFitParserIntegration();
101108
```
102109

103-
### Step 2: Set Up IPC Handlers (Main Process)
104-
105-
```javascript
106-
import { setupFitParserIPC } from "./utils/fitParserIntegration.js";
107-
import { ipcMain } from "electron";
110+
### Step 2: IPC Handlers (Main Process)
108111

109-
// Set up IPC handlers for FIT parser operations
110-
setupFitParserIPC(ipcMain);
111-
```
112-
113-
### Step 3: Set Up Preload Script
112+
In the current architecture, `electron-app/main/ipc/setupIPCHandlers.js` is responsible for wiring the canonical FIT IPC channels:
114113

115114
```javascript
116-
import { setupFitParserPreload } from "./utils/fitParserIntegration.js";
117-
import { contextBridge, ipcRenderer } from "electron";
115+
registerIpcHandle("fit:parse", async (_event, arrayBuffer) => {
116+
// ... calls fitParser.decodeFitFile(buffer)
117+
});
118118

119-
// Expose FIT parser functions to renderer
120-
setupFitParserPreload(contextBridge, ipcRenderer);
119+
registerIpcHandle("fit:decode", async (_event, arrayBuffer) => {
120+
// ... calls fitParser.decodeFitFile(buffer)
121+
});
121122
```
122123

123-
### Step 4: Use in Renderer Process
124+
The optional `setupFitParserIPC(ipcMain)` helper in `utils/files/import/fitParserIntegration.js` also uses `fit:decode` to provide an advanced, state-aware decoding surface for specialized embedding scenarios and tests.
124125

125-
```javascript
126-
// Decode a FIT file with progress tracking
127-
const result = await window.fitParser.decodeFitFile(fileBuffer);
128-
129-
// Update decoder options with validation
130-
const updateResult = await window.fitParser.updateDecoderOptions({
131-
applyScaleAndOffset: false,
132-
includeUnknownData: true,
133-
});
126+
### Step 3: Preload Script
134127

135-
// Get current options
136-
const options = await window.fitParser.getDecoderOptions();
128+
The canonical renderer API is exposed via `preload.js` through the `electronAPI` bridge, not `window.fitParser`:
137129

138-
// Reset to defaults
139-
const resetResult = await window.fitParser.resetDecoderOptions();
130+
```javascript
131+
// In preload.js
132+
const electronAPI = {
133+
decodeFitFile: createSafeInvokeHandler(CONSTANTS.CHANNELS.FIT_DECODE, "decodeFitFile"),
134+
parseFitFile: createSafeInvokeHandler(CONSTANTS.CHANNELS.FIT_PARSE, "parseFitFile"),
135+
// ...
136+
};
140137
```
141138

139+
The `setupFitParserPreload(contextBridge, ipcRenderer)` helper remains available for legacy or embedded use cases and now invokes `fit:decode` under the hood instead of `decode-fit-file`.
140+
142141
## New API Functions
143142

144143
### Core Functions (Node.js/Main Process)
@@ -167,7 +166,7 @@ const defaults = fitParser.getDefaultDecoderOptions();
167166
const schema = fitParser.DECODER_OPTIONS_SCHEMA;
168167
```
169168

170-
### Integration Functions (ES6 Modules)
169+
### Integration Functions (ES6 Modules / Advanced)
171170

172171
```javascript
173172
import {

electron-app/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default defineConfig([
2222
"./.temp*/**",
2323
"node_modules/**",
2424
"dist/**",
25-
"**/*.d.ts"
25+
"**/*.d.ts",
2626
],
2727
},
2828
{

0 commit comments

Comments
 (0)