From 283083ed383cfb6058f7f4ce39f24c7ea4cfb72c Mon Sep 17 00:00:00 2001 From: David Wheatley Date: Sun, 7 Jul 2024 12:06:19 +0100 Subject: [PATCH] fix: build errors --- src/announcement-data/AnnouncementSystem.ts | 3 ++ .../systems/rolling-stock/BombardierXstar.ts | 15 +++++++ .../systems/rolling-stock/LNERAzuma.tsx | 13 ++++++ .../systems/rolling-stock/TLClass700.tsx | 26 ++++++++++-- .../systems/rolling-stock/TfLElizabeth.tsx | 36 ++++++++++------ .../systems/rolling-stock/TfLJubileeLine.tsx | 42 ++++++++++++------- .../systems/rolling-stock/TfLNorthernLine.tsx | 22 +++++++--- .../systems/rolling-stock/TfWTelevic.tsx | 8 ++++ .../systems/rolling-stock/TfWTrainFx.tsx | 19 ++++++++- .../systems/stations/ScotRail.tsx | 19 +++++++-- 10 files changed, 160 insertions(+), 43 deletions(-) diff --git a/src/announcement-data/AnnouncementSystem.ts b/src/announcement-data/AnnouncementSystem.ts index 42e22d066..85e87e5ec 100644 --- a/src/announcement-data/AnnouncementSystem.ts +++ b/src/announcement-data/AnnouncementSystem.ts @@ -92,6 +92,9 @@ export interface CustomAnnouncementTab { | 'defaultState' > | ICustomButtonPaneProps + /** + * Merged with any personal preset to allow migration if new features are added. + */ defaultState: Record } diff --git a/src/announcement-data/systems/rolling-stock/BombardierXstar.ts b/src/announcement-data/systems/rolling-stock/BombardierXstar.ts index 898080ee2..d86e792bc 100644 --- a/src/announcement-data/systems/rolling-stock/BombardierXstar.ts +++ b/src/announcement-data/systems/rolling-stock/BombardierXstar.ts @@ -455,6 +455,12 @@ export default class BombardierXstar extends TrainAnnouncementSystem { approachingStation: { name: 'Approaching station', component: CustomAnnouncementPane, + defaultState: { + stationCode: this.RealAvailableStationNames[0], + mindTheGap: true, + keepBelongings: false, + cannotUseOyster: false, + }, props: { playHandler: this.playApproachingStationAnnouncement.bind(this), options: { @@ -485,6 +491,11 @@ export default class BombardierXstar extends TrainAnnouncementSystem { stoppedAtStation: { name: 'Stopped at station', component: CustomAnnouncementPane, + defaultState: { + thisStationCode: this.RealAvailableStationNames[0], + terminatesAtCode: this.RealAvailableStationNames[0], + callingAtCodes: [], + }, props: { playHandler: this.playStoppedAtStationAnnouncement.bind(this), presets: announcementPresets.stopped, @@ -516,6 +527,10 @@ export default class BombardierXstar extends TrainAnnouncementSystem { departingStation: { name: 'Departing station', component: CustomAnnouncementPane, + defaultState: { + terminatesAtCode: this.RealAvailableStationNames[0], + nextStationCode: this.RealAvailableStationNames[0], + }, props: { playHandler: this.playDepartingStationAnnouncement.bind(this), options: { diff --git a/src/announcement-data/systems/rolling-stock/LNERAzuma.tsx b/src/announcement-data/systems/rolling-stock/LNERAzuma.tsx index 581f8d212..361e06dca 100644 --- a/src/announcement-data/systems/rolling-stock/LNERAzuma.tsx +++ b/src/announcement-data/systems/rolling-stock/LNERAzuma.tsx @@ -391,6 +391,11 @@ export default class LnerAzuma extends TrainAnnouncementSystem { stoppedAtStation: { name: 'Stopped at station', component: CustomAnnouncementPane, + defaultState: { + thisStationCode: this.ALL_STATIONS[0], + terminatesAtCode: this.ALL_STATIONS[0], + callingAtCodes: [], + }, props: { presets: announcementPresets.stopped, playHandler: this.playStoppedAtStationAnnouncement.bind(this), @@ -422,6 +427,10 @@ export default class LnerAzuma extends TrainAnnouncementSystem { departingStation: { name: 'Route start & departing station', component: CustomAnnouncementPane, + defaultState: { + terminatesAtCode: this.ALL_STATIONS[0], + callingAtCodes: [], + }, props: { presets: announcementPresets.departingStation, playHandler: this.playDepartingStationAnnouncement.bind(this), @@ -447,6 +456,10 @@ export default class LnerAzuma extends TrainAnnouncementSystem { aproachingStation: { name: 'Approaching station', component: CustomAnnouncementPane, + defaultState: { + nextStationCode: this.ALL_STATIONS[0], + terminates: false, + }, props: { playHandler: this.playApproachingStationAnnouncement.bind(this), options: { diff --git a/src/announcement-data/systems/rolling-stock/TLClass700.tsx b/src/announcement-data/systems/rolling-stock/TLClass700.tsx index 2c72e8f76..0519584ff 100644 --- a/src/announcement-data/systems/rolling-stock/TLClass700.tsx +++ b/src/announcement-data/systems/rolling-stock/TLClass700.tsx @@ -800,10 +800,15 @@ export default class ThameslinkClass700 extends TrainAnnouncementSystem { return arr } - readonly customAnnouncementTabs: Record = { + readonly customAnnouncementTabs: Record> = { initialDeparture: { name: 'Initial departure', component: CustomAnnouncementPane, + defaultState: { + terminatesAtCode: this.allAvailableStationsAndTestStations[0].value, + callingAtCodes: [], + isSoutheastern: false, + }, props: { playHandler: this.playInitialDepartureAnnouncement.bind(this), options: { @@ -830,10 +835,17 @@ export default class ThameslinkClass700 extends TrainAnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, approachingStation: { name: 'Approaching station', component: CustomAnnouncementPane, + defaultState: { + stationCode: this.allAvailableStationsAndTestStations[0].value, + isAto: false, + terminatesHere: false, + takeCareAsYouLeave: false, + changeFor: [], + }, props: { playHandler: this.playApproachingStationAnnouncement.bind(this), options: { @@ -890,10 +902,16 @@ export default class ThameslinkClass700 extends TrainAnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, stoppedAtStation: { name: 'Stopped at station', component: CustomAnnouncementPane, + defaultState: { + thisStationCode: this.allAvailableStationsAndTestStations[0].value, + terminatesAtCode: this.allAvailableStationsAndTestStations[0].value, + callingAtCodes: [], + mindTheGap: false, + }, props: { presets: announcementPresets.stopped, playHandler: this.playStoppedAtStationAnnouncement.bind(this), @@ -927,7 +945,7 @@ export default class ThameslinkClass700 extends TrainAnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, announcementButtons: { name: 'Announcement buttons', component: CustomButtonPane, diff --git a/src/announcement-data/systems/rolling-stock/TfLElizabeth.tsx b/src/announcement-data/systems/rolling-stock/TfLElizabeth.tsx index 9236b0bb5..d441bbf1b 100644 --- a/src/announcement-data/systems/rolling-stock/TfLElizabeth.tsx +++ b/src/announcement-data/systems/rolling-stock/TfLElizabeth.tsx @@ -610,9 +610,9 @@ function createNormalStation( name: stn.name, crs: crsCode, audioName: { - b: AllStationFiles.b.includes(crsCode) ? `stations.b.${crsCode}` : null, - m: AllStationFiles.em.includes(crsCode) ? `stations.m.${crsCode}` : null, - e: AllStationFiles.em.includes(crsCode) ? `stations.e.${crsCode}` : null, + b: AllStationFiles.b.includes(crsCode) ? `stations.b.${crsCode}` : undefined, + m: AllStationFiles.em.includes(crsCode) ? `stations.m.${crsCode}` : undefined, + e: AllStationFiles.em.includes(crsCode) ? `stations.e.${crsCode}` : undefined, }, changeFor, exitFor, @@ -1173,7 +1173,7 @@ export default class TfLElizabethLine extends AnnouncementSystem { return } - files.push(thisStation.audioName.e) + files.push(thisStation.audioName.e!!) if (thisStation.crs === destinationStation.crs) { files.push({ id: 'conjoiners.this train terminates here all change please', opts: { delayStart: 1000 } }) @@ -1181,17 +1181,17 @@ export default class TfLElizabethLine extends AnnouncementSystem { files.push({ id: 'conjoiners.this is the train to', opts: { delayStart: 1000 } }) if (viaStation) { - files.push(destinationStation.audioName.m, 'conjoiners.via', viaStation.audioName.e) + files.push(destinationStation.audioName.m!!, 'conjoiners.via', viaStation.audioName.e!!) } else { - files.push(destinationStation.audioName.e) + files.push(destinationStation.audioName.e!!) } files.push({ id: 'conjoiners.next station', opts: { delayStart: 1000 } }) if (nextStation.crs === destinationStation.crs) { - files.push(nextStation.audioName.m, 'conjoiners.where this train terminates') + files.push(nextStation.audioName.m!!, 'conjoiners.where this train terminates') } else { - files.push(nextStation.audioName.e) + files.push(nextStation.audioName.e!!) } } @@ -1204,16 +1204,16 @@ export default class TfLElizabethLine extends AnnouncementSystem { const nextStation = AllStations.find(stn => stn.crs === options.nextStationCrs) if (!nextStation) { - alert(`Invalid station.\n\n${nextStation?.crs}`) + alert(`Invalid station.\n\n${options.nextStationCrs}`) return } files.push({ id: 'conjoiners.next station', opts: { delayStart: 1000 } }) if (options.terminating) { - files.push(nextStation.audioName.m, 'conjoiners.where this train terminates') + files.push(nextStation.audioName.m!!, 'conjoiners.where this train terminates') } else { - files.push(nextStation.audioName.e) + files.push(nextStation.audioName.e!!) } if (nextStation.changeFor.length) { @@ -1237,6 +1237,12 @@ export default class TfLElizabethLine extends AnnouncementSystem { thisStation: { name: 'Stopped at station', component: CustomAnnouncementPane, + defaultState: { + thisStationCrs: AllStationFiles.em[0], + destinationCrs: AllStationFiles.em[0], + viaCrs: 'none', + nextStationCrs: AllStationFiles.em[0], + }, props: { playHandler: this.playAtStationAnnouncement.bind(this), presets: announcementPresets.thisStation, @@ -1270,10 +1276,14 @@ export default class TfLElizabethLine extends AnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, approachingStation: { name: 'Approaching station', component: CustomAnnouncementPane, + defaultState: { + nextStationCrs: AllStationFiles.em[0], + terminating: false, + }, props: { playHandler: this.playApproachingStationAnnouncement.bind(this), presets: announcementPresets.approachingStation, @@ -1291,7 +1301,7 @@ export default class TfLElizabethLine extends AnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, // announcementButtons: { // name: 'Announcement buttons', diff --git a/src/announcement-data/systems/rolling-stock/TfLJubileeLine.tsx b/src/announcement-data/systems/rolling-stock/TfLJubileeLine.tsx index a8b5e8a7c..69f7a710d 100644 --- a/src/announcement-data/systems/rolling-stock/TfLJubileeLine.tsx +++ b/src/announcement-data/systems/rolling-stock/TfLJubileeLine.tsx @@ -260,7 +260,7 @@ export default class TfLJubileeLine extends AnnouncementSystem { const stationData = StationData.find(s => s.name === options.stationName) - if (stationData.fullMessages) { + if (stationData?.fullMessages) { files.push(...stationData.approachingFiles) return await this.playAudioFiles(files, download) @@ -271,9 +271,9 @@ export default class TfLJubileeLine extends AnnouncementSystem { const stnFiles: AudioItem[] = [] if (elizAffectedStations.includes(options.stationName) && options.usePostEliz) { - stnFiles.push(...stationData.postEliz.approachingFiles) + stnFiles.push(...(stationData?.postEliz?.approachingFiles ?? [])) } else { - stnFiles.push(...stationData.approachingFiles) + stnFiles.push(...(stationData?.approachingFiles ?? [])) } stnFiles[0] = { id: stnFiles[0] as string, opts: { delayStart: 250 } } @@ -291,7 +291,7 @@ export default class TfLJubileeLine extends AnnouncementSystem { const stationData = StationData.find(s => s.name === options.stationName) - if (stationData.fullMessages) { + if (stationData?.fullMessages) { files.push(...stationData.standingFiles) return await this.playAudioFiles(files, download) @@ -302,9 +302,9 @@ export default class TfLJubileeLine extends AnnouncementSystem { const stnFiles: AudioItem[] = [] if (elizAffectedStations.includes(options.stationName) && options.usePostEliz) { - stnFiles.push(...stationData.postEliz.standingFiles) + stnFiles.push(...(stationData?.postEliz?.standingFiles ?? [])) } else { - stnFiles.push(...stationData.standingFiles) + stnFiles.push(...(stationData?.standingFiles ?? [])) } stnFiles[0] = { id: stnFiles[0] as string, opts: { delayStart: 250 } } @@ -318,6 +318,9 @@ export default class TfLJubileeLine extends AnnouncementSystem { destinationInfo: { name: 'Destination info', component: CustomAnnouncementPane, + defaultState: { + terminatingStationName: StationData.filter(s => s.canTerminate)[0].name, + }, props: { playHandler: this.playDestinationInfoAnnouncement.bind(this), presets: announcementPresets.destinationInfo, @@ -330,10 +333,15 @@ export default class TfLJubileeLine extends AnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, nextStation: { name: 'Next station', component: CustomAnnouncementPane, + defaultState: { + stationName: StationData[0].name, + doorDirection: 'right', + usePostEliz: true, + }, props: { playHandler: this.playNextStationAnnouncement.bind(this), options: { @@ -351,26 +359,30 @@ export default class TfLJubileeLine extends AnnouncementSystem { { title: 'Right', value: 'right' }, ], type: 'select', - onlyShowWhen: ({ stationName }: { stationName: string }) => { + onlyShowWhen: ({ stationName }) => { const stationData = StationData.find(s => s.name === stationName) - return !stationData.fullMessages + return !stationData?.fullMessages }, }, usePostEliz: { name: 'Use Elizabeth line version', default: true, type: 'boolean', - onlyShowWhen: ({ stationName }: { stationName: string }) => { - return elizAffectedStations.includes(stationName) + onlyShowWhen: ({ stationName }) => { + return elizAffectedStations.includes(stationName as string) }, }, }, }, - }, + } as CustomAnnouncementTab, thisStation: { name: 'Stopped at station', component: CustomAnnouncementPane, + defaultState: { + stationName: StationData[0].name, + usePostEliz: true, + }, props: { playHandler: this.playAtStationAnnouncement.bind(this), options: { @@ -384,13 +396,13 @@ export default class TfLJubileeLine extends AnnouncementSystem { name: 'Use Elizabeth line version', default: true, type: 'boolean', - onlyShowWhen: ({ stationName }: { stationName: string }) => { - return elizAffectedStations.includes(stationName) + onlyShowWhen: ({ stationName }) => { + return elizAffectedStations.includes(stationName as string) }, }, }, }, - }, + } as CustomAnnouncementTab, announcementButtons: { name: 'Announcement buttons', component: CustomButtonPane, diff --git a/src/announcement-data/systems/rolling-stock/TfLNorthernLine.tsx b/src/announcement-data/systems/rolling-stock/TfLNorthernLine.tsx index 60ef9628d..577b1f6b2 100644 --- a/src/announcement-data/systems/rolling-stock/TfLNorthernLine.tsx +++ b/src/announcement-data/systems/rolling-stock/TfLNorthernLine.tsx @@ -816,7 +816,7 @@ export default class TfLNorthernLine extends AnnouncementSystem { } if ((options.terminating && nextStationData.terminatingAudio) || nextStationData.onlyTerminates) { - files.push(...nextStationData.terminatingAudio) + files.push(...(nextStationData.terminatingAudio ?? [])) files.push( { id: 'please ensure you have all your belongings with you', @@ -893,10 +893,13 @@ export default class TfLNorthernLine extends AnnouncementSystem { await this.playAudioFiles(files, download) } - readonly customAnnouncementTabs: Record = { + readonly customAnnouncementTabs: Record> = { destinationInfo: { name: 'Destination info', component: CustomAnnouncementPane, + defaultState: { + stationName: AvailableDestinations[0].station, + }, props: { playHandler: this.playDestinationInfoAnnouncement.bind(this), presets: announcementPresets.destinationInfo, @@ -924,10 +927,15 @@ export default class TfLNorthernLine extends AnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, nextStation: { name: 'Next station', component: CustomAnnouncementPane, + defaultState: { + stationLabel: NextStationData[0].label, + terminating: false, + mindTheGap: true, + }, props: { playHandler: this.playNextStationAnnouncement.bind(this), options: { @@ -957,10 +965,14 @@ export default class TfLNorthernLine extends AnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, thisStation: { name: 'Stopped at station', component: CustomAnnouncementPane, + defaultState: { + stationNameIndex: '0', + terminatingStationName: AvailableDestinations[0].station, + }, props: { playHandler: this.playAtStationAnnouncement.bind(this), options: { @@ -1005,7 +1017,7 @@ export default class TfLNorthernLine extends AnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, announcementButtons: { name: 'Announcement buttons', component: CustomButtonPane, diff --git a/src/announcement-data/systems/rolling-stock/TfWTelevic.tsx b/src/announcement-data/systems/rolling-stock/TfWTelevic.tsx index ceac801f0..1890a53a2 100644 --- a/src/announcement-data/systems/rolling-stock/TfWTelevic.tsx +++ b/src/announcement-data/systems/rolling-stock/TfWTelevic.tsx @@ -489,6 +489,9 @@ export default class TfWTelevic extends TrainAnnouncementSystem { startOfJourney: { name: 'Start of journey', component: CustomAnnouncementPane, + defaultState: { + callingAtCodes: [], + }, props: { playHandler: this.playStartOfJourneyAnnouncement.bind(this), presets: this.announcementPresets.startOfJourney, @@ -512,6 +515,11 @@ export default class TfWTelevic extends TrainAnnouncementSystem { stoppedAtStation: { name: 'Stopped at station', component: CustomAnnouncementPane, + defaultState: { + thisStation: this.StationsAsItems[0].value, + terminus: this.StationsAsItems[0].value, + isTerminusNext: false, + }, props: { playHandler: this.playStoppedAtAnnouncement.bind(this), presets: this.announcementPresets.stoppedAtStation, diff --git a/src/announcement-data/systems/rolling-stock/TfWTrainFx.tsx b/src/announcement-data/systems/rolling-stock/TfWTrainFx.tsx index b9cfaaeed..d3fa80cda 100644 --- a/src/announcement-data/systems/rolling-stock/TfWTrainFx.tsx +++ b/src/announcement-data/systems/rolling-stock/TfWTrainFx.tsx @@ -497,6 +497,9 @@ export default class TfWTrainFx extends TrainAnnouncementSystem { startOfJourney: { name: 'Start of journey', component: CustomAnnouncementPane, + defaultState: { + callingAtCodes: [], + }, props: { playHandler: this.playStartOfJourneyAnnouncement.bind(this), options: { @@ -518,6 +521,10 @@ export default class TfWTrainFx extends TrainAnnouncementSystem { stoppedAtStation: { name: 'At station', component: CustomAnnouncementPane, + defaultState: { + thisStationCode: this.AvailableStationItemMaps.high[0].value, + terminatesAtCode: this.AvailableDestinationOptions[0].value, + }, props: { playHandler: this.playStoppedAtStationAnnouncement.bind(this), options: { @@ -539,6 +546,10 @@ export default class TfWTrainFx extends TrainAnnouncementSystem { departingStop: { name: 'Departing stop', component: CustomAnnouncementPane, + defaultState: { + nextStationCode: this.AvailableStationItemMaps.high[0].value, + terminatesHere: false, + }, props: { playHandler: this.playDepartingStopAnnouncement.bind(this), options: { @@ -555,10 +566,14 @@ export default class TfWTrainFx extends TrainAnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, approachingStation: { name: 'Approaching stop', component: CustomAnnouncementPane, + defaultState: { + nextStationCode: this.AvailableStationItemMaps.high[0].value, + gapType: 'none', + }, props: { playHandler: this.playApproachingStopAnnouncement.bind(this), options: { @@ -593,7 +608,7 @@ export default class TfWTrainFx extends TrainAnnouncementSystem { }, }, }, - }, + } as CustomAnnouncementTab, announcementButtons: { name: 'Announcement buttons', component: CustomButtonPane, diff --git a/src/announcement-data/systems/stations/ScotRail.tsx b/src/announcement-data/systems/stations/ScotRail.tsx index e99039082..31681840b 100644 --- a/src/announcement-data/systems/stations/ScotRail.tsx +++ b/src/announcement-data/systems/stations/ScotRail.tsx @@ -6,6 +6,7 @@ import CustomAnnouncementPane, { ICustomAnnouncementPreset } from '@components/P import { AllStationsTitleValueMap } from '@data/StationManipulators' import { AudioItem, CustomAnnouncementTab } from '../../AnnouncementSystem' import type { IAlternativeServicesState } from '@components/AtosDisruptionAlternatives' +import { platform } from 'os' interface INextTrainAnnouncementOptions { platform: string @@ -16,8 +17,8 @@ interface INextTrainAnnouncementOptions { via: string | 'none' callingAt: { crsCode: string; name: string; randomId: string }[] coaches: string - seating: string - special: string[] + // seating: string + // special: string[] } interface IThroughTrainAnnouncementOptions { @@ -1024,10 +1025,20 @@ export default class ScotRail extends StationAnnouncementSystem { await this.playAudioFiles(files, download) } - readonly customAnnouncementTabs: Record = { + readonly customAnnouncementTabs: Record> = { nextTrain: { name: 'Next train', component: CustomAnnouncementPane, + defaultState: { + platform: AVAILABLE_PLATFORMS[0], + hour: '07', + min: '22', + toc: AVAILABLE_TOCS[0].toLowerCase(), + terminatingStationCode: AVAILABLE_STATIONS.low[0], + via: 'none', + callingAt: [], + coaches: '6', + }, props: { playHandler: this.playNextTrainAnnouncement.bind(this), presets: AnnouncementPresets.nextTrain, @@ -1106,7 +1117,7 @@ export default class ScotRail extends StationAnnouncementSystem { // }, }, }, - }, + } as CustomAnnouncementTab, // fastTrain: { // name: 'Fast train', // component: CustomAnnouncementPane,