@opentripplanner/core-utils 12.0.0-alpha.2 → 12.0.0-alpha.4

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.
package/lib/query.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/query.js"],"names":["defaultParams","TIME_FORMATS","getQueryParamProperty","paramInfo","property","query","ensureSingleAccessMode","queryModes","accessCount","filter","m","length","firstAccess","find","push","getUrlParams","window","qs","parse","location","href","split","undefined","getOtpUrlParams","Object","keys","key","startsWith","getTripOptionsFromQuery","keepPlace","options","time","departArrive","date","from","to","getDefaultQueryParamValue","param","default","getDefaultQuery","config","defaultQuery","routingType","queryParams","qp","forEach","name","routingTypes","defaultQueryParams","isParamApplicable","applicable","includes","reduceOtpFlexModes","modes","enabled","reduce","prev","cur","newModes","expandOtpFlexMode","mode","map","join","isNotDefaultQuery","activeModes","sort","mergeFlex","defaultModes","concat","modesEqual","every","value","index","i","getFirstGeocodeResult","text","geocoderConfig","geocoder","search","then","result","firstResult","features","getLocationFromGeocodedFeature","parseLocationString","parts","coordinates","lat","lon","queryParamToLocation","planParamsToQuery","params","fromPlace","toPlace","arriveBy","matchedTimeFormat","timeFormat","Date","OTP_API_TIME_FORMAT","intermediatePlaces","maybeNumber","Number","isNaN","planParamsToQueryAsync","getRoutingParams","currentQuery","ignoreRealtimeUpdates","isItinerary","indexOf","rewriteFunction","itineraryRewrite","profileRewrite","assign","dateValid","OTP_API_DATE_FORMAT","timeValid","minTransitDistance","searchTimeout","onlyTransitTrips","startTimeValid","startTime","endTimeValid","endTime","reducedMode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAOA;AAEO,MAAMA,aAAa,GAAG,CAC3B,YAD2B,EAE3B,iBAF2B,EAG3B,gBAH2B,EAI3B,aAJ2B,EAK3B,iBAL2B,EAM3B,aAN2B,EAO3B,WAP2B,EAQ3B,UAR2B,E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B,CAAnB,EAAqD;AACnDwC,MAAAA,MAAM,CAAC2B,gBAAP,GAA0B,IAA1B;AACD,KA5Bc,CA8Bf;;AACD,GA/BD,MA+BO;AACL;AACA,UAAMC,cAAc,GAAG,sBAAQ5B,MAAM,CAAC6B,SAAf,EAA0BtB,yBAA1B,CAAvB;AACA,UAAMuB,YAAY,GAAG,sBAAQ9B,MAAM,CAAC+B,OAAf,EAAwBxB,yBAAxB,CAArB;;AAEA,QAAI,CAACqB,cAAD,IAAmB,CAACE,YAAxB,EAAsC;AACpC,aAAO9B,MAAM,CAAC4B,cAAd;AACA,aAAO5B,MAAM,CAAC8B,YAAd;AACD;AACF,GA1E2E,CA4E5E;AAEA;;;AACA,MAAI,uBAAO9B,MAAM,CAAC/B,IAAd,CAAJ,EAAyB;AACvB+B,IAAAA,MAAM,CAAC/B,IAAP,IAAe,OAAf;AACD,GAjF2E,CAmF5E;AACA;;;AACA,MAAI+B,MAAM,CAAC/B,IAAP,IAAe,mBAAApB,MAAM,CAACa,KAAP,kEAAca,SAAd,MAA4B,KAA/C,EAAsD;AACpD;AACA,UAAMyD,WAAW,GAAGvE,kBAAkB,CAACuC,MAAM,CAAC/B,IAAP,CAAYvC,KAAZ,CAAkB,GAAlB,CAAD,CAAlB,CAA2CyC,IAA3C,CAAgD,GAAhD,CAApB;AACA6B,IAAAA,MAAM,CAAC/B,IAAP,GAAcD,iBAAiB,CAACgE,WAAD,CAA/B;AACD;;AAED,SAAOhC,MAAP;AACD","sourcesContent":["import { format, isMatch, parse } from \"date-fns\";\nimport getGeocoder from \"@opentripplanner/geocoder/lib\";\nimport qs from \"qs\";\n\nimport { getTransitModes, hasCar, isAccessMode } from \"./itinerary\";\nimport { coordsToString, stringToCoords } from \"./map\";\nimport queryParams from \"./query-params\";\nimport {\n getCurrentTime,\n getCurrentDate,\n OTP_API_DATE_FORMAT,\n OTP_API_TIME_FORMAT\n} from \"./time\";\n\n/* The list of default parameters considered in the settings panel */\n\nexport const defaultParams = [\n \"wheelchair\",\n \"maxWalkDistance\",\n \"walkReluctance\",\n \"maxWalkTime\",\n \"maxBikeDistance\",\n \"maxBikeTime\",\n \"bikeSpeed\",\n \"optimize\",\n \"optimizeBike\",\n \"maxEScooterDistance\",\n \"watts\"\n];\n\n/**\n * List of time formats to parse when reading query params.\n */\nconst TIME_FORMATS = [\n \"HH:mm:ss\",\n \"HH:mm\",\n \"H:mm\",\n \"h:mm:ss a\",\n \"h:mm:ssa\",\n \"h:mm a\",\n \"h:mma\",\n \"h:mm\",\n \"HHmm\",\n \"hmm\",\n \"ha\"\n];\n\n/* A function to retrieve a property value from an entry in the query-params\n * table, checking for either a static value or a function */\n\nexport function getQueryParamProperty(paramInfo, property, query) {\n return typeof paramInfo[property] === \"function\"\n ? paramInfo[property](query)\n : paramInfo[property];\n}\n\nexport function ensureSingleAccessMode(queryModes) {\n // Count the number of access modes\n const accessCount = queryModes.filter(m => isAccessMode(m)).length;\n\n // If multiple access modes are specified, keep only the first one\n if (accessCount > 1) {\n const firstAccess = queryModes.find(m => isAccessMode(m));\n queryModes = queryModes.filter(m => !isAccessMode(m) || m === firstAccess);\n\n // If no access modes are specified, add 'WALK' as the default\n } else if (accessCount === 0) {\n queryModes.push(\"WALK\");\n }\n\n return queryModes;\n}\n\nexport function getUrlParams() {\n if (window) {\n return qs.parse(window.location.href.split(\"?\")[1]);\n }\n return undefined;\n}\n\nexport function getOtpUrlParams() {\n return Object.keys(getUrlParams()).filter(key => !key.startsWith(\"ui_\"));\n}\n\nexport function getTripOptionsFromQuery(query, keepPlace = false) {\n const options = { ...query };\n // Delete time/date options and from/to\n delete options.time;\n delete options.departArrive;\n delete options.date;\n if (!keepPlace) {\n delete options.from;\n delete options.to;\n }\n return options;\n}\n\n/**\n * Gets the query param's default value that is either a constant or by\n * executing the default value function.\n */\nfunction getDefaultQueryParamValue(param) {\n return typeof param.default === \"function\" ? param.default() : param.default;\n}\n\n/**\n * Get the default query to OTP based on the given config.\n */\nexport function getDefaultQuery(config = null) {\n const defaultQuery = { routingType: \"ITINERARY\" };\n queryParams\n .filter(qp => \"default\" in qp)\n .forEach(qp => {\n defaultQuery[qp.name] = getDefaultQueryParamValue(qp);\n });\n if (config) {\n if (config.routingTypes && config.routingTypes.length > 0) {\n defaultQuery.routingType = config.routingTypes[0].key;\n }\n if (config.defaultQueryParams) {\n Object.keys(config.defaultQueryParams).forEach(key => {\n defaultQuery[key] = config.defaultQueryParams[key];\n });\n }\n }\n return defaultQuery;\n}\n\n/**\n * Determine if the specified query param applies to the given query (based on\n * routing type and the param's own applicable function).\n * @param paramInfo an entry from query-params.js\n * @param query the query against which to check if the param applies\n * @param config OTP config\n * @return {Boolean}\n */\nfunction isParamApplicable(paramInfo, query, config) {\n const { applicable, routingTypes } = paramInfo;\n if (!routingTypes.includes(query.routingType)) return false;\n if (typeof applicable === \"function\" && !applicable(query, config)) {\n return false;\n }\n return true;\n}\n\n/**\n * Helper method which replaces OTP flex modes with single FLEX mode that's\n * more useful and easier to work with.\n */\nexport function reduceOtpFlexModes(modes, enabled = true) {\n if (!enabled) return modes;\n\n return modes.reduce((prev, cur) => {\n const newModes = prev;\n // Add the current mode if it is not a flex mode\n if (!cur.includes(\"FLEX\")) {\n newModes.push(cur);\n // If it is a flex mode, do not add it but rather add the custom flex mode\n // if not already present\n } else if (!newModes.includes(\"FLEX\")) {\n newModes.push(\"FLEX\");\n }\n return newModes;\n }, []);\n}\n\n/**\n * Helper method to process a mode string, replacing all instances of FLEX\n * with the full set of FLEX modes used by otp-2\n * @param {*} mode a mode String, not an array\n * @returns a mode String, not an array (with flex modes expanded)\n */\nexport function expandOtpFlexMode(mode) {\n const modes = reduceOtpFlexModes(mode.split(\",\"));\n return modes\n .map(m => {\n // If both the expanded and shrunk modes are included, remove the exapnded one\n if (m === \"FLEX_EGRESS\" || m === \"FLEX_ACCESS\" || m === \"FLEX_DIRECT\") {\n if (mode.includes(\"FLEX\")) return \"\";\n }\n if (m === \"FLEX\") {\n return \"FLEX_EGRESS,FLEX_ACCESS,FLEX_DIRECT\";\n }\n return m;\n })\n .join(\",\");\n}\n\n/**\n * Determines whether the specified query differs from the default query, i.e.,\n * whether the user has modified any trip options (including mode) from their\n * default values.\n */\nexport function isNotDefaultQuery(query, config) {\n const activeModes = reduceOtpFlexModes(\n query.mode.split(\",\").sort(),\n config.modes?.mergeFlex\n );\n if (\n activeModes.length !== 2 ||\n activeModes[0] !== \"TRANSIT\" ||\n activeModes[1] !== \"WALK\"\n ) {\n // Default mode is TRANSIT,WALK. If general TRANSIT is not used, check\n // against available transit modes in config.\n const defaultModes = getTransitModes(config)\n .concat([\"WALK\"])\n .sort();\n const modesEqual =\n activeModes.length === defaultModes.length &&\n activeModes.every((value, index) => {\n return value === defaultModes[index];\n });\n if (!modesEqual) return true;\n }\n // If modes are equal, check the remaining params.\n const defaultQuery = getDefaultQuery(config);\n for (let i = 0; i < defaultParams.length; i++) {\n const param = defaultParams[i];\n const paramInfo = queryParams.find(qp => qp.name === param);\n // If the parameter applies to the query and does not match the default\n // value, the query is not default.\n if (\n isParamApplicable(paramInfo, query, config) &&\n query[param] !== defaultQuery[param]\n ) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Geocode utility for returning the first result for the provided place name text.\n * @param {string} text - text to search\n * @param {Object} geocoderConfig\n * @return {Location}\n */\nasync function getFirstGeocodeResult(text, geocoderConfig) {\n const geocoder = getGeocoder(geocoderConfig);\n // Attempt to geocode search text and return first result if found.\n // TODO: Import geocoder from @opentripplanner\n return geocoder.search({ text }).then(result => {\n const firstResult = result.features && result.features[0];\n if (firstResult) {\n return geocoder.getLocationFromGeocodedFeature(firstResult);\n }\n return null;\n });\n}\n\n/**\n * OTP allows passing a location in the form '123 Main St::lat,lon', so we check\n * for the double colon and parse the coordinates accordingly.\n * @param {string} value - query param for place described above\n * @return {Location} - location or null if the value is falsey or the parsed\n * coordinates do not result in both a lat and lon\n */\nexport function parseLocationString(value) {\n if (!value) return null;\n const parts = value.split(\"::\");\n const coordinates = parts[1]\n ? stringToCoords(parts[1])\n : stringToCoords(parts[0]);\n const name = parts[1] ? parts[0] : coordsToString(coordinates);\n return coordinates.length === 2\n ? {\n name: name || null,\n lat: coordinates[0] || null,\n lon: coordinates[1] || null\n }\n : null;\n}\n\n/**\n * Convert a string query param for a from or to place into a location. If\n * coordinates not provided and geocoder config is present, use the first\n * geocoded result.\n * @param {string} value\n * @param {Object} [geocoderConfig=null]\n * @return {Location}\n */\nasync function queryParamToLocation(value, geocoderConfig) {\n let location = parseLocationString(value);\n if (!location && value && geocoderConfig) {\n // If a valid location was not found, but the place name text exists,\n // attempt to geocode the name.\n location = await getFirstGeocodeResult(value, geocoderConfig);\n }\n return location;\n}\n\n/**\n * Create a otp query based on a the url params.\n *\n * @param {Object} params An object representing the parsed querystring of url\n * params.\n */\nexport function planParamsToQuery(params) {\n const query = {};\n Object.keys(params).forEach(key => {\n switch (key) {\n case \"fromPlace\":\n query.from = parseLocationString(params.fromPlace);\n break;\n case \"toPlace\":\n query.to = parseLocationString(params.toPlace);\n break;\n case \"arriveBy\":\n query.departArrive =\n params.arriveBy === \"true\"\n ? \"ARRIVE\"\n : params.arriveBy === \"false\"\n ? \"DEPART\"\n : \"NOW\";\n break;\n case \"date\":\n query.date = params.date || getCurrentDate();\n break;\n case \"time\":\n {\n // Match one of the supported time formats\n const matchedTimeFormat = TIME_FORMATS.find(timeFormat =>\n isMatch(params.time, timeFormat)\n );\n query.time = matchedTimeFormat\n ? format(\n parse(params.time, matchedTimeFormat, new Date()),\n OTP_API_TIME_FORMAT\n )\n : getCurrentTime();\n }\n break;\n case \"intermediatePlaces\":\n // If query has intermediate places, ensure that they are parsed\n // as locations.\n query.intermediatePlaces = params.intermediatePlaces\n ? params.intermediatePlaces.map(parseLocationString)\n : [];\n break;\n default: {\n const maybeNumber = Number(params[key]);\n // If the param value is an empty string literal and is not a number,\n // use string value. Else, use parsed number value.\n // See https://github.com/opentripplanner/otp-ui/issues/50\n query[key] =\n params[key] === \"\" || Number.isNaN(maybeNumber)\n ? params[key]\n : maybeNumber;\n break;\n }\n }\n });\n return query;\n}\n\n/**\n * Async method to create a otp query based on a the url params. This provides\n * the same functionality as planParamsToQuery, except that it will also attempt\n * to geocode the input from and to strings if no lat/lng values were provided.\n *\n * @param {Object} params An object representing the parsed querystring of url\n * params.\n * @param config the config in the otp-rr store.\n */\nexport async function planParamsToQueryAsync(params, config = {}) {\n // Construct query from plan params.\n const query = planParamsToQuery(params);\n // Attempt to geocode from and to params if the string parsing does not return\n // valid locations.\n if (!query.from) {\n query.from = await queryParamToLocation(params.fromPlace, config.geocoder);\n }\n if (!query.to) {\n query.to = await queryParamToLocation(params.toPlace, config.geocoder);\n }\n return query;\n}\n\n/**\n * Create an object that can be used as a querystring in making an OTP\n * PlannerResource request.\n *\n * See http://otp-docs.ibi-transit.com/api/resource_PlannerResource.html\n *\n * @param {Object} config The OTP application config. See types#configType\n * @param {Object} currentQuery The current query parameters as saved in the\n * application state. This method does some extra logic on top of this data\n * in order to create a request suitable for OTP. See __tests__/query.js#L14 for more.\n * @param {boolean} ignoreRealtimeUpdates If true, will create a request that\n * does not use realtime data.\n */\nexport function getRoutingParams(config, currentQuery, ignoreRealtimeUpdates) {\n const routingType = currentQuery.routingType;\n const isItinerary = routingType === \"ITINERARY\";\n let params = {};\n\n // Start with the universe of OTP parameters defined in query-params.js:\n queryParams\n .filter(qp => {\n // A given parameter is included in the request if all of the following:\n // 1. Must apply to the active routing type (ITINERARY or PROFILE)\n // 2. Must be included in the current user-defined query\n // 3. Must pass the parameter's applicability test, if one is specified\n return (\n qp.routingTypes.indexOf(routingType) !== -1 &&\n qp.name in currentQuery &&\n (typeof qp.applicable !== \"function\" ||\n qp.applicable(currentQuery, config))\n );\n })\n .forEach(qp => {\n // Translate the applicable parameters according to their rewrite\n // functions (if provided)\n const rewriteFunction = isItinerary\n ? qp.itineraryRewrite\n : qp.profileRewrite;\n params = Object.assign(\n params,\n rewriteFunction\n ? rewriteFunction(currentQuery[qp.name])\n : { [qp.name]: currentQuery[qp.name] }\n );\n });\n\n // Additional processing specific to ITINERARY mode\n if (isItinerary) {\n // override ignoreRealtimeUpdates if provided\n if (typeof ignoreRealtimeUpdates === \"boolean\") {\n params.ignoreRealtimeUpdates = ignoreRealtimeUpdates;\n }\n\n // check date/time validity; ignore both if either is invalid\n const dateValid = isMatch(params.date, OTP_API_DATE_FORMAT);\n const timeValid = isMatch(params.time, OTP_API_TIME_FORMAT);\n\n if (!dateValid || !timeValid) {\n delete params.time;\n delete params.date;\n }\n\n // temp: set additional parameters for CAR_HAIL or CAR_RENT trips\n if (\n params.mode &&\n (params.mode.includes(\"CAR_HAIL\") || params.mode.includes(\"CAR_RENT\"))\n ) {\n params.minTransitDistance = \"50%\";\n // increase search timeout because these queries can take a while\n params.searchTimeout = 10000;\n }\n\n // set onlyTransitTrips for car rental searches\n if (params.mode && params.mode.includes(\"CAR_RENT\")) {\n params.onlyTransitTrips = true;\n }\n\n // Additional processing specific to PROFILE mode\n } else {\n // check start and end time validity; ignore both if either is invalid\n const startTimeValid = isMatch(params.startTime, OTP_API_TIME_FORMAT);\n const endTimeValid = isMatch(params.endTime, OTP_API_TIME_FORMAT);\n\n if (!startTimeValid || !endTimeValid) {\n delete params.startTimeValid;\n delete params.endTimeValid;\n }\n }\n\n // TODO: check that valid from/to locations are provided\n\n // hack to add walking to driving/TNC trips\n if (hasCar(params.mode)) {\n params.mode += \",WALK\";\n }\n\n // Replace FLEX placeholder with OTP flex modes\n // Explicit false check allows avoiding a breaking change -- undefined is true\n if (params.mode && config.modes?.mergeFlex !== false) {\n // Ensure query is in reduced format to avoid replacing twice\n const reducedMode = reduceOtpFlexModes(params.mode.split(\",\")).join(\",\");\n params.mode = expandOtpFlexMode(reducedMode);\n }\n\n return params;\n}\n"],"file":"query.js"}
1
+ {"version":3,"sources":["../src/query.js"],"names":["defaultParams","TIME_FORMATS","getQueryParamProperty","paramInfo","property","query","ensureSingleAccessMode","queryModes","accessCount","filter","m","length","firstAccess","find","push","getUrlParams","window","qs","parse","location","href","split","undefined","getOtpUrlParams","Object","keys","key","startsWith","getTripOptionsFromQuery","keepPlace","options","time","departArrive","date","from","to","getDefaultQueryParamValue","param","default","getDefaultQuery","config","defaultQuery","routingType","queryParams","qp","forEach","name","routingTypes","defaultQueryParams","isParamApplicable","applicable","includes","reduceOtpFlexModes","modes","enabled","reduce","prev","cur","newModes","expandOtpFlexMode","mode","map","join","isNotDefaultQuery","activeModes","sort","mergeFlex","defaultModes","concat","modesEqual","every","value","index","i","getFirstGeocodeResult","text","geocoderConfig","geocoder","search","then","result","firstResult","features","getLocationFromGeocodedFeature","parseLocationString","parts","coordinates","lat","lon","queryParamToLocation","planParamsToQuery","params","fromPlace","toPlace","arriveBy","matchedTimeFormat","timeFormat","Date","OTP_API_TIME_FORMAT","intermediatePlaces","maybeNumber","Number","isNaN","planParamsToQueryAsync","getRoutingParams","currentQuery","ignoreRealtimeUpdates","isItinerary","indexOf","rewriteFunction","itineraryRewrite","profileRewrite","assign","dateValid","OTP_API_DATE_FORMAT","timeValid","minTransitDistance","searchTimeout","onlyTransitTrips","startTimeValid","startTime","endTimeValid","endTime","reducedMode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAOA;AAEO,MAAMA,aAAa,GAAG,CAC3B,YAD2B,EAE3B,iBAF2B,EAG3B,gBAH2B,EAI3B,aAJ2B,EAK3B,iBAL2B,EAM3B,aAN2B,EAO3B,WAP2B,EAQ3B,UAR2B,EAS3B,cAT2B,EAU3B,qBAV2B,EAW3B,OAX2B,CAAtB;AAcP;AACA;AACA;;;AACA,MAAMC,YAAY,GAAG,CACnB,UADmB,EAEnB,OAFmB,EAGnB,MAHmB,EAInB,WAJmB,EAKnB,UALmB,EAMnB,QANmB,EAOnB,OAPmB,EAQnB,MARmB,EASnB,MATmB,EAUnB,KAVmB,EAWnB,IAXmB,CAArB;AAcA;AACA;;AAEO,SAASC,qBAAT,CAA+B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AAI,CAACqB,cAAD,IAAmB,CAACE,YAAxB,EAAsC;AACpC,aAAO9B,MAAM,CAAC4B,cAAd;AACA,aAAO5B,MAAM,CAAC8B,YAAd;AACD;AACF,GA1E2E,CA4E5E;AAEA;;;AACA,MAAI,uBAAO9B,MAAM,CAAC/B,IAAd,CAAJ,EAAyB;AACvB+B,IAAAA,MAAM,CAAC/B,IAAP,IAAe,OAAf;AACD,GAjF2E,CAmF5E;AACA;;;AACA,MAAI+B,MAAM,CAAC/B,IAAP,IAAe,mBAAApB,MAAM,CAACa,KAAP,kEAAca,SAAd,MAA4B,KAA/C,EAAsD;AACpD;AACA,UAAMyD,WAAW,GAAGvE,kBAAkB,CAACuC,MAAM,CAAC/B,IAAP,CAAYvC,KAAZ,CAAkB,GAAlB,CAAD,CAAlB,CAA2CyC,IAA3C,CAAgD,GAAhD,CAApB;AACA6B,IAAAA,MAAM,CAAC/B,IAAP,GAAcD,iBAAiB,CAACgE,WAAD,CAA/B;AACD;;AAED,SAAOhC,MAAP;AACD","sourcesContent":["import { format, isMatch, parse } from \"date-fns\";\nimport getGeocoder from \"@opentripplanner/geocoder/lib\";\nimport qs from \"qs\";\n\nimport { getTransitModes, hasCar, isAccessMode } from \"./itinerary\";\nimport { coordsToString, stringToCoords } from \"./map\";\nimport queryParams from \"./query-params\";\nimport {\n getCurrentTime,\n getCurrentDate,\n OTP_API_DATE_FORMAT,\n OTP_API_TIME_FORMAT\n} from \"./time\";\n\n/* The list of default parameters considered in the settings panel */\n\nexport const defaultParams = [\n \"wheelchair\",\n \"maxWalkDistance\",\n \"walkReluctance\",\n \"maxWalkTime\",\n \"maxBikeDistance\",\n \"maxBikeTime\",\n \"bikeSpeed\",\n \"optimize\",\n \"optimizeBike\",\n \"maxEScooterDistance\",\n \"watts\"\n];\n\n/**\n * List of time formats to parse when reading query params.\n */\nconst TIME_FORMATS = [\n \"HH:mm:ss\",\n \"HH:mm\",\n \"H:mm\",\n \"h:mm:ss a\",\n \"h:mm:ssa\",\n \"h:mm a\",\n \"h:mma\",\n \"h:mm\",\n \"HHmm\",\n \"hmm\",\n \"ha\"\n];\n\n/* A function to retrieve a property value from an entry in the query-params\n * table, checking for either a static value or a function */\n\nexport function getQueryParamProperty(paramInfo, property, query) {\n return typeof paramInfo[property] === \"function\"\n ? paramInfo[property](query)\n : paramInfo[property];\n}\n\nexport function ensureSingleAccessMode(queryModes) {\n // Count the number of access modes\n const accessCount = queryModes.filter(m => isAccessMode(m)).length;\n\n // If multiple access modes are specified, keep only the first one\n if (accessCount > 1) {\n const firstAccess = queryModes.find(m => isAccessMode(m));\n queryModes = queryModes.filter(m => !isAccessMode(m) || m === firstAccess);\n\n // If no access modes are specified, add 'WALK' as the default\n } else if (accessCount === 0) {\n queryModes.push(\"WALK\");\n }\n\n return queryModes;\n}\n\nexport function getUrlParams() {\n if (window) {\n return qs.parse(window.location.href.split(\"?\")[1]);\n }\n return undefined;\n}\n\nexport function getOtpUrlParams() {\n return Object.keys(getUrlParams()).filter(key => !key.startsWith(\"ui_\"));\n}\n\nexport function getTripOptionsFromQuery(query, keepPlace = false) {\n const options = { ...query };\n // Delete time/date options and from/to\n delete options.time;\n delete options.departArrive;\n delete options.date;\n if (!keepPlace) {\n delete options.from;\n delete options.to;\n }\n return options;\n}\n\n/**\n * Gets the query param's default value that is either a constant or by\n * executing the default value function.\n */\nfunction getDefaultQueryParamValue(param) {\n return typeof param.default === \"function\" ? param.default() : param.default;\n}\n\n/**\n * Get the default query to OTP based on the given config.\n */\nexport function getDefaultQuery(config = null) {\n const defaultQuery = { routingType: \"ITINERARY\" };\n queryParams\n .filter(qp => \"default\" in qp)\n .forEach(qp => {\n defaultQuery[qp.name] = getDefaultQueryParamValue(qp);\n });\n if (config) {\n if (config.routingTypes && config.routingTypes.length > 0) {\n defaultQuery.routingType = config.routingTypes[0].key;\n }\n if (config.defaultQueryParams) {\n Object.keys(config.defaultQueryParams).forEach(key => {\n defaultQuery[key] = config.defaultQueryParams[key];\n });\n }\n }\n return defaultQuery;\n}\n\n/**\n * Determine if the specified query param applies to the given query (based on\n * routing type and the param's own applicable function).\n * @param paramInfo an entry from query-params.js\n * @param query the query against which to check if the param applies\n * @param config OTP config\n * @return {Boolean}\n */\nfunction isParamApplicable(paramInfo, query, config) {\n const { applicable, routingTypes } = paramInfo;\n if (!routingTypes.includes(query.routingType)) return false;\n if (typeof applicable === \"function\" && !applicable(query, config)) {\n return false;\n }\n return true;\n}\n\n/**\n * Helper method which replaces OTP flex modes with single FLEX mode that's\n * more useful and easier to work with.\n */\nexport function reduceOtpFlexModes(modes, enabled = true) {\n if (!enabled) return modes;\n\n return modes.reduce((prev, cur) => {\n const newModes = prev;\n // Add the current mode if it is not a flex mode\n if (!cur.includes(\"FLEX\")) {\n newModes.push(cur);\n // If it is a flex mode, do not add it but rather add the custom flex mode\n // if not already present\n } else if (!newModes.includes(\"FLEX\")) {\n newModes.push(\"FLEX\");\n }\n return newModes;\n }, []);\n}\n\n/**\n * Helper method to process a mode string, replacing all instances of FLEX\n * with the full set of FLEX modes used by otp-2\n * @param {*} mode a mode String, not an array\n * @returns a mode String, not an array (with flex modes expanded)\n */\nexport function expandOtpFlexMode(mode) {\n const modes = reduceOtpFlexModes(mode.split(\",\"));\n return modes\n .map(m => {\n // If both the expanded and shrunk modes are included, remove the expanded one\n if (m === \"FLEX_EGRESS\" || m === \"FLEX_ACCESS\" || m === \"FLEX_DIRECT\") {\n if (mode.includes(\"FLEX\")) return \"\";\n }\n if (m === \"FLEX\") {\n return \"FLEX_EGRESS,FLEX_ACCESS,FLEX_DIRECT\";\n }\n return m;\n })\n .join(\",\");\n}\n\n/**\n * Determines whether the specified query differs from the default query, i.e.,\n * whether the user has modified any trip options (including mode) from their\n * default values.\n */\nexport function isNotDefaultQuery(query, config) {\n const activeModes = reduceOtpFlexModes(\n query.mode.split(\",\").sort(),\n config.modes?.mergeFlex\n );\n if (\n activeModes.length !== 2 ||\n activeModes[0] !== \"TRANSIT\" ||\n activeModes[1] !== \"WALK\"\n ) {\n // Default mode is TRANSIT,WALK. If general TRANSIT is not used, check\n // against available transit modes in config.\n const defaultModes = getTransitModes(config)\n .concat([\"WALK\"])\n .sort();\n const modesEqual =\n activeModes.length === defaultModes.length &&\n activeModes.every((value, index) => {\n return value === defaultModes[index];\n });\n if (!modesEqual) return true;\n }\n // If modes are equal, check the remaining params.\n const defaultQuery = getDefaultQuery(config);\n for (let i = 0; i < defaultParams.length; i++) {\n const param = defaultParams[i];\n const paramInfo = queryParams.find(qp => qp.name === param);\n // If the parameter applies to the query and does not match the default\n // value, the query is not default.\n if (\n isParamApplicable(paramInfo, query, config) &&\n query[param] !== defaultQuery[param]\n ) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Geocode utility for returning the first result for the provided place name text.\n * @param {string} text - text to search\n * @param {Object} geocoderConfig\n * @return {Location}\n */\nasync function getFirstGeocodeResult(text, geocoderConfig) {\n const geocoder = getGeocoder(geocoderConfig);\n // Attempt to geocode search text and return first result if found.\n // TODO: Import geocoder from @opentripplanner\n return geocoder.search({ text }).then(result => {\n const firstResult = result.features && result.features[0];\n if (firstResult) {\n return geocoder.getLocationFromGeocodedFeature(firstResult);\n }\n return null;\n });\n}\n\n/**\n * OTP allows passing a location in the form '123 Main St::lat,lon', so we check\n * for the double colon and parse the coordinates accordingly.\n * @param {string} value - query param for place described above\n * @return {Location} - location or null if the value is falsey or the parsed\n * coordinates do not result in both a lat and lon\n */\nexport function parseLocationString(value) {\n if (!value) return null;\n const parts = value.split(\"::\");\n const coordinates = parts[1]\n ? stringToCoords(parts[1])\n : stringToCoords(parts[0]);\n const name = parts[1] ? parts[0] : coordsToString(coordinates);\n return coordinates.length === 2\n ? {\n name: name || null,\n lat: coordinates[0] || null,\n lon: coordinates[1] || null\n }\n : null;\n}\n\n/**\n * Convert a string query param for a from or to place into a location. If\n * coordinates not provided and geocoder config is present, use the first\n * geocoded result.\n * @param {string} value\n * @param {Object} [geocoderConfig=null]\n * @return {Location}\n */\nasync function queryParamToLocation(value, geocoderConfig) {\n let location = parseLocationString(value);\n if (!location && value && geocoderConfig) {\n // If a valid location was not found, but the place name text exists,\n // attempt to geocode the name.\n location = await getFirstGeocodeResult(value, geocoderConfig);\n }\n return location;\n}\n\n/**\n * Create a otp query based on a the url params.\n *\n * @param {Object} params An object representing the parsed querystring of url\n * params.\n */\nexport function planParamsToQuery(params) {\n const query = {};\n Object.keys(params).forEach(key => {\n switch (key) {\n case \"fromPlace\":\n query.from = parseLocationString(params.fromPlace);\n break;\n case \"toPlace\":\n query.to = parseLocationString(params.toPlace);\n break;\n case \"arriveBy\":\n query.departArrive =\n params.arriveBy === \"true\"\n ? \"ARRIVE\"\n : params.arriveBy === \"false\"\n ? \"DEPART\"\n : \"NOW\";\n break;\n case \"date\":\n query.date = params.date || getCurrentDate();\n break;\n case \"time\":\n {\n // Match one of the supported time formats\n const matchedTimeFormat = TIME_FORMATS.find(timeFormat =>\n isMatch(params.time, timeFormat)\n );\n query.time = matchedTimeFormat\n ? format(\n parse(params.time, matchedTimeFormat, new Date()),\n OTP_API_TIME_FORMAT\n )\n : getCurrentTime();\n }\n break;\n case \"intermediatePlaces\":\n // If query has intermediate places, ensure that they are parsed\n // as locations.\n query.intermediatePlaces = params.intermediatePlaces\n ? params.intermediatePlaces.map(parseLocationString)\n : [];\n break;\n default: {\n const maybeNumber = Number(params[key]);\n // If the param value is an empty string literal and is not a number,\n // use string value. Else, use parsed number value.\n // See https://github.com/opentripplanner/otp-ui/issues/50\n query[key] =\n params[key] === \"\" || Number.isNaN(maybeNumber)\n ? params[key]\n : maybeNumber;\n break;\n }\n }\n });\n return query;\n}\n\n/**\n * Async method to create a otp query based on a the url params. This provides\n * the same functionality as planParamsToQuery, except that it will also attempt\n * to geocode the input from and to strings if no lat/lng values were provided.\n *\n * @param {Object} params An object representing the parsed querystring of url\n * params.\n * @param config the config in the otp-rr store.\n */\nexport async function planParamsToQueryAsync(params, config = {}) {\n // Construct query from plan params.\n const query = planParamsToQuery(params);\n // Attempt to geocode from and to params if the string parsing does not return\n // valid locations.\n if (!query.from) {\n query.from = await queryParamToLocation(params.fromPlace, config.geocoder);\n }\n if (!query.to) {\n query.to = await queryParamToLocation(params.toPlace, config.geocoder);\n }\n return query;\n}\n\n/**\n * Create an object that can be used as a querystring in making an OTP\n * PlannerResource request.\n *\n * See http://otp-docs.ibi-transit.com/api/resource_PlannerResource.html\n *\n * @param {Object} config The OTP application config. See types#configType\n * @param {Object} currentQuery The current query parameters as saved in the\n * application state. This method does some extra logic on top of this data\n * in order to create a request suitable for OTP. See __tests__/query.js#L14 for more.\n * @param {boolean} ignoreRealtimeUpdates If true, will create a request that\n * does not use realtime data.\n */\nexport function getRoutingParams(config, currentQuery, ignoreRealtimeUpdates) {\n const routingType = currentQuery.routingType;\n const isItinerary = routingType === \"ITINERARY\";\n let params = {};\n\n // Start with the universe of OTP parameters defined in query-params.js:\n queryParams\n .filter(qp => {\n // A given parameter is included in the request if all of the following:\n // 1. Must apply to the active routing type (ITINERARY or PROFILE)\n // 2. Must be included in the current user-defined query\n // 3. Must pass the parameter's applicability test, if one is specified\n return (\n qp.routingTypes.indexOf(routingType) !== -1 &&\n qp.name in currentQuery &&\n (typeof qp.applicable !== \"function\" ||\n qp.applicable(currentQuery, config))\n );\n })\n .forEach(qp => {\n // Translate the applicable parameters according to their rewrite\n // functions (if provided)\n const rewriteFunction = isItinerary\n ? qp.itineraryRewrite\n : qp.profileRewrite;\n params = Object.assign(\n params,\n rewriteFunction\n ? rewriteFunction(currentQuery[qp.name])\n : { [qp.name]: currentQuery[qp.name] }\n );\n });\n\n // Additional processing specific to ITINERARY mode\n if (isItinerary) {\n // override ignoreRealtimeUpdates if provided\n if (typeof ignoreRealtimeUpdates === \"boolean\") {\n params.ignoreRealtimeUpdates = ignoreRealtimeUpdates;\n }\n\n // check date/time validity; ignore both if either is invalid\n const dateValid = isMatch(params.date, OTP_API_DATE_FORMAT);\n const timeValid = isMatch(params.time, OTP_API_TIME_FORMAT);\n\n if (!dateValid || !timeValid) {\n delete params.time;\n delete params.date;\n }\n\n // temp: set additional parameters for CAR_HAIL or CAR_RENT trips\n if (\n params.mode &&\n (params.mode.includes(\"CAR_HAIL\") || params.mode.includes(\"CAR_RENT\"))\n ) {\n params.minTransitDistance = \"50%\";\n // increase search timeout because these queries can take a while\n params.searchTimeout = 10000;\n }\n\n // set onlyTransitTrips for car rental searches\n if (params.mode && params.mode.includes(\"CAR_RENT\")) {\n params.onlyTransitTrips = true;\n }\n\n // Additional processing specific to PROFILE mode\n } else {\n // check start and end time validity; ignore both if either is invalid\n const startTimeValid = isMatch(params.startTime, OTP_API_TIME_FORMAT);\n const endTimeValid = isMatch(params.endTime, OTP_API_TIME_FORMAT);\n\n if (!startTimeValid || !endTimeValid) {\n delete params.startTimeValid;\n delete params.endTimeValid;\n }\n }\n\n // TODO: check that valid from/to locations are provided\n\n // hack to add walking to driving/TNC trips\n if (hasCar(params.mode)) {\n params.mode += \",WALK\";\n }\n\n // Replace FLEX placeholder with OTP flex modes\n // Explicit false check allows avoiding a breaking change -- undefined is true\n if (params.mode && config.modes?.mergeFlex !== false) {\n // Ensure query is in reduced format to avoid replacing twice\n const reducedMode = reduceOtpFlexModes(params.mode.split(\",\")).join(\",\");\n params.mode = expandOtpFlexMode(reducedMode);\n }\n\n return params;\n}\n"],"file":"query.js"}
package/lib/ui.d.ts CHANGED
@@ -1,8 +1,4 @@
1
1
  export declare function isMobile(): boolean;
2
- /**
3
- * Returns true if the user is using a [redacted] browser
4
- */
5
- export declare function isIE(): boolean;
6
2
  /**
7
3
  * Enables scrolling for a specified selector, while disabling scrolling for all
8
4
  * other targets. This is adapted from https://stackoverflow.com/a/41601290/915811
package/lib/ui.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,IAAI,OAAO,CAKlC;AAED;;GAEG;AACH,wBAAgB,IAAI,IAAI,OAAO,CAE9B;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CA4C9D"}
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,IAAI,OAAO,CAKlC;AACD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CA4C9D"}
package/lib/ui.js CHANGED
@@ -1,28 +1,15 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.isMobile = isMobile;
9
- exports.isIE = isIE;
10
7
  exports.enableScrollForSelector = enableScrollForSelector;
11
8
 
12
- var _bowser = _interopRequireDefault(require("bowser"));
13
-
14
9
  function isMobile() {
15
10
  // TODO: consider using 3rd-party library?
16
11
  return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
17
12
  }
18
- /**
19
- * Returns true if the user is using a [redacted] browser
20
- */
21
-
22
-
23
- function isIE() {
24
- return _bowser.default.parse(navigator.userAgent).browser === "Internet Explorer";
25
- }
26
13
  /**
27
14
  * Enables scrolling for a specified selector, while disabling scrolling for all
28
15
  * other targets. This is adapted from https://stackoverflow.com/a/41601290/915811
package/lib/ui.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ui.ts"],"names":["isMobile","test","navigator","userAgent","isIE","bowser","parse","browser","enableScrollForSelector","selector","overlay","document","querySelector","clientY","isOverlayTotallyScrolled","scrollHeight","scrollTop","clientHeight","disableRubberBand","event","clientYDelta","targetTouches","preventDefault","addEventListener","length"],"mappings":";;;;;;;;;;;AAAA;;AAEO,SAASA,QAAT,GAA6B;AAClC;AACA,SAAO,iEAAiEC,IAAjE,CACLC,SAAS,CAACC,SADL,CAAP;AAGD;AAED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;AACD;AACF,GAPH,EAQE,KARF;AAUD","sourcesContent":["import bowser from \"bowser\";\n\nexport function isMobile(): boolean {\n // TODO: consider using 3rd-party library?\n return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(\n navigator.userAgent\n );\n}\n\n/**\n * Returns true if the user is using a [redacted] browser\n */\nexport function isIE(): boolean {\n return bowser.parse(navigator.userAgent).browser === \"Internet Explorer\";\n}\n\n/**\n * Enables scrolling for a specified selector, while disabling scrolling for all\n * other targets. This is adapted from https://stackoverflow.com/a/41601290/915811\n * and intended to fix issues with iOS elastic scrolling, e.g.,\n * https://github.com/conveyal/trimet-mod-otp/issues/92.\n */\nexport function enableScrollForSelector(selector: string): void {\n const overlay = document.querySelector(selector);\n let clientY = null; // remember Y position on touch start\n\n function isOverlayTotallyScrolled(): boolean {\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions\n return overlay.scrollHeight - overlay.scrollTop <= overlay.clientHeight;\n }\n\n function disableRubberBand(event: TouchEvent) {\n const clientYDelta = event.targetTouches[0].clientY - clientY;\n\n if (overlay.scrollTop === 0 && clientYDelta > 0) {\n // element is at the top of its scroll\n event.preventDefault();\n }\n\n if (isOverlayTotallyScrolled() && clientYDelta < 0) {\n // element is at the top of its scroll\n event.preventDefault();\n }\n }\n\n overlay.addEventListener(\n \"touchstart\",\n function(event: TouchEvent) {\n if (event.targetTouches.length === 1) {\n // detect single touch\n clientY = event.targetTouches[0].clientY;\n }\n },\n false\n );\n\n overlay.addEventListener(\n \"touchmove\",\n function(event: TouchEvent) {\n if (event.targetTouches.length === 1) {\n // detect single touch\n disableRubberBand(event);\n }\n },\n false\n );\n}\n"],"file":"ui.js"}
1
+ {"version":3,"sources":["../src/ui.ts"],"names":["isMobile","test","navigator","userAgent","enableScrollForSelector","selector","overlay","document","querySelector","clientY","isOverlayTotallyScrolled","scrollHeight","scrollTop","clientHeight","disableRubberBand","event","clientYDelta","targetTouches","preventDefault","add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,GAPH,EAQE,KARF;AAUD","sourcesContent":["export function isMobile(): boolean {\n // TODO: consider using 3rd-party library?\n return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(\n navigator.userAgent\n );\n}\n/**\n * Enables scrolling for a specified selector, while disabling scrolling for all\n * other targets. This is adapted from https://stackoverflow.com/a/41601290/915811\n * and intended to fix issues with iOS elastic scrolling, e.g.,\n * https://github.com/conveyal/trimet-mod-otp/issues/92.\n */\nexport function enableScrollForSelector(selector: string): void {\n const overlay = document.querySelector(selector);\n let clientY = null; // remember Y position on touch start\n\n function isOverlayTotallyScrolled(): boolean {\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions\n return overlay.scrollHeight - overlay.scrollTop <= overlay.clientHeight;\n }\n\n function disableRubberBand(event: TouchEvent) {\n const clientYDelta = event.targetTouches[0].clientY - clientY;\n\n if (overlay.scrollTop === 0 && clientYDelta > 0) {\n // element is at the top of its scroll\n event.preventDefault();\n }\n\n if (isOverlayTotallyScrolled() && clientYDelta < 0) {\n // element is at the top of its scroll\n event.preventDefault();\n }\n }\n\n overlay.addEventListener(\n \"touchstart\",\n function(event: TouchEvent) {\n if (event.targetTouches.length === 1) {\n // detect single touch\n clientY = event.targetTouches[0].clientY;\n }\n },\n false\n );\n\n overlay.addEventListener(\n \"touchmove\",\n function(event: TouchEvent) {\n if (event.targetTouches.length === 1) {\n // detect single touch\n disableRubberBand(event);\n }\n },\n false\n );\n}\n"],"file":"ui.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentripplanner/core-utils",
3
- "version": "12.0.0-alpha.2",
3
+ "version": "12.0.0-alpha.4",
4
4
  "description": "Core functionality that is shared among numerous UI components",
5
5
  "engines": {
6
6
  "node": ">=13"
@@ -14,10 +14,9 @@
14
14
  "dependencies": {
15
15
  "@conveyal/lonlat": "^1.4.1",
16
16
  "@mapbox/polyline": "^1.1.0",
17
- "@opentripplanner/geocoder": "^1.4.1",
17
+ "@opentripplanner/geocoder": "^1.4.2",
18
18
  "@styled-icons/foundation": "^10.34.0",
19
19
  "@turf/along": "^6.0.1",
20
- "bowser": "^2.7.0",
21
20
  "chroma-js": "^2.4.2",
22
21
  "date-fns": "^2.28.0",
23
22
  "date-fns-tz": "^1.2.2",
package/src/itinerary.ts CHANGED
@@ -294,7 +294,7 @@ export function legElevationAtDistance(
294
294
  const elevDistanceSpan = points[i][0] - start[0];
295
295
  if (distance >= traversed && distance <= traversed + elevDistanceSpan) {
296
296
  // Distance falls within this point and the previous one;
297
- // compute & return iterpolated elevation value
297
+ // compute & return interpolated elevation value
298
298
  if (start[1] === null) {
299
299
  console.warn(
300
300
  "Elevation value does not exist for distance.",
@@ -370,10 +370,10 @@ export function getElevationProfile(
370
370
  * @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393
371
371
  */
372
372
  export function getTextWidth(text: string, font = "22px Arial"): number {
373
- // Create custom type for function including re-used canvas object
373
+ // Create custom type for function including reused canvas object
374
374
  type GetTextWidth = typeof getTextWidth & { canvas: HTMLCanvasElement };
375
375
 
376
- // re-use canvas object for better performance
376
+ // reuse canvas object for better performance
377
377
  const canvas =
378
378
  (getTextWidth as GetTextWidth).canvas ||
379
379
  ((getTextWidth as GetTextWidth).canvas = document.createElement("canvas"));
@@ -674,7 +674,7 @@ export const convertGraphQLResponseToLegacy = (leg: any): any => ({
674
674
  },
675
675
  route: leg.route?.shortName,
676
676
  routeColor: leg.route?.color,
677
- routeId: leg.route?.id,
677
+ routeId: leg.route?.gtfsId,
678
678
  routeLongName: leg.route?.longName,
679
679
  routeShortName: leg.route?.shortName,
680
680
  routeTextColor: leg.route?.textColor,
@@ -57,7 +57,7 @@ query Plan(
57
57
  effectiveStartDate
58
58
  id
59
59
  }
60
- id
60
+ gtfsId: id
61
61
  name
62
62
  timezone
63
63
  url
@@ -164,6 +164,7 @@ query Plan(
164
164
  id
165
165
  }
166
166
  color
167
+ gtfsId
167
168
  id
168
169
  longName
169
170
  shortName
package/src/query.js CHANGED
@@ -174,7 +174,7 @@ export function expandOtpFlexMode(mode) {
174
174
  const modes = reduceOtpFlexModes(mode.split(","));
175
175
  return modes
176
176
  .map(m => {
177
- // If both the expanded and shrunk modes are included, remove the exapnded one
177
+ // If both the expanded and shrunk modes are included, remove the expanded one
178
178
  if (m === "FLEX_EGRESS" || m === "FLEX_ACCESS" || m === "FLEX_DIRECT") {
179
179
  if (mode.includes("FLEX")) return "";
180
180
  }
package/src/ui.ts CHANGED
@@ -1,19 +1,9 @@
1
- import bowser from "bowser";
2
-
3
1
  export function isMobile(): boolean {
4
2
  // TODO: consider using 3rd-party library?
5
3
  return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
6
4
  navigator.userAgent
7
5
  );
8
6
  }
9
-
10
- /**
11
- * Returns true if the user is using a [redacted] browser
12
- */
13
- export function isIE(): boolean {
14
- return bowser.parse(navigator.userAgent).browser === "Internet Explorer";
15
- }
16
-
17
7
  /**
18
8
  * Enables scrolling for a specified selector, while disabling scrolling for all
19
9
  * other targets. This is adapted from https://stackoverflow.com/a/41601290/915811