- Implemented a script to generate a Tampermonkey userscript from ndView.tsx.
- Extracted and modified the operation page script body to include necessary postMessage functions.
- Added metadata for the userscript including name, namespace, version, and match URL.
- Ensured compatibility with Tampermonkey's GM_download for image capture.
- Moved the Elesite sorting logic to a new module `elesiteTrainOrder.ts`.
- Created utility functions to infer heading direction and sort Elesite entries by train number.
- Updated `injectJavascriptData` to utilize the new sorting logic and handle station sequences.
- Refactored `useElesite` to use the new sorting utility for improved readability and maintainability.
- Introduced `compile-web-script.ts` for generating JavaScript files for userscripts.
- Supports options for minification and obfuscation.
- Generates base JS, minified JS, and obfuscated userscript.
- Configurable via command line arguments and environment variables.
- positionMasters: add fetchMockTrainPositions() targeting
/train-positions/latest on the mock API server
- useTrainMenu: when mockApiFeatureEnabled and not recording/playing,
poll /train-positions/latest every 15s and update mockTrainPositions
(same interval as live mode); on mode switch updates immediately
- useCurrentTrain:
- playing: use local recording data (no network call)
- mock ON idle: fetch from mock API server (15s poll driven by useTrainMenu)
- mock OFF: fetch from real backend as before
- Recording still forces mock OFF so real API data is captured
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add lib/mockApi/positionMasters.ts
- fetchPositionMasters() from jr-shikoku-backend-mock-api-v1.haruk.in
- buildPosLookup() / lookupPos() helpers
- serializePosLookupForJs() for baking into injected scripts
- webviewXhrInterceptor: accept positionMasters in MockApiConfig,
bake _POS_LOOKUP into injected JS, enrich Pos from PosNum on serve
- useTrainMenu: fetch position masters on mock-enable (and at startup
if already enabled); expose positionMasters + lookupPosText()
- useCurrentTrain: fill Pos via lookupPosText when mapping mock data
- mockApi/index.ts: re-export positionMasters types and helpers
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The XHR interceptor baked _MOCK_TRAIN at page load time, so seeking or
advancing a playback frame only changed React state but had no effect
on the already-loaded WebView page.
- webviewXhrInterceptor.ts:
- Expose window.__jrsMockUpdateTrain(newData) from inside the IIFE so
the _MOCK_TRAIN variable can be updated after page load
- Add generateMockUpdateScript(trainPositions) helper: calls
__jrsMockUpdateTrain with fresh data + GetDateTime, then calls
window.setReload() to trigger the page's own redraw cycle
- WebView.tsx:
- Import generateMockUpdateScript
- Add useEffect watching mockTrainPositions (skips first mount since
beforeContentLoaded already has correct data)
- When mockApiFeatureEnabled && mockTrainPositions changes, inject the
update script via webview.current.injectJavaScript()
Result: seeking, prev/next frame, and auto-advance during playback now
immediately update the train position display in the WebView.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Crash fix (React Hooks violation):
- PlaybackTimeline.tsx: move ALL hooks (useRef for PanResponder, useCallback)
to before the early return; use seekRef/totalRef to share values into
PanResponder handlers without stale closure issues
Multiple recordings support:
- trainRecorder.ts: redesign to id-based multi-recording system
- RecordingMeta type for lightweight list (no snapshots)
- TrainRecording now includes id field
- saveRecording/loadRecordingById/deleteRecordingById/loadRecordingList
- migrateOldRecording() migrates old single MOCK_RECORDING key on first launch
- constants/storage.ts: add MOCK_RECORDINGS_INDEX + MOCK_RECORDING_DATA_PREFIX keys
- useTrainMenu: savedRecording → recordingList (RecordingMeta[]) + activeRecording (TrainRecording|null)
- startPlayback(id) loads full recording on demand
- deleteRecording(id) deletes by id and refreshes list
- stopPlayback clears activeRecording
- DataSourceSettings: recording list UI
- shows all recordings with date/time, snapshot count, duration
- ▶ play and 削除 buttons per row
- recording/playing status indicator
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>